From 6beba921bc4a46feb9985f219cd73fb6c3848d6a Mon Sep 17 00:00:00 2001 From: "jyc.dev" Date: Sun, 23 Nov 2025 21:23:56 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Parse=20walk=20write=20(v4)=20(#?= =?UTF-8?q?1136)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/curvy-rivers-build.md | 5 + .changeset/thin-carrots-throw.md | 5 + babel.config.js | 3 - package.json | 1 - packages/handles/playwright.config.ts | 4 +- packages/internals/package.json | 6 +- packages/internals/src/lib/ast/ast.spec.ts | 133 +- packages/internals/src/lib/ast/ast.ts | 49 +- packages/internals/src/lib/ast/astImports.ts | 96 +- .../src/lib/ast/oxcCommentsToEsrapComments.js | 135 + packages/internals/src/lib/fs/fs.spec.ts | 4 +- packages/internals/src/lib/index.ts | 12 +- .../vite-plugin-kit-routes/src/lib/ast.ts | 182 +- .../src/lib/nullifyImports.spec.ts | 91 +- .../src/lib/nullifyImports.ts | 107 +- .../src/lib/plugin.spec.ts | 2 +- .../vite-plugin-stripper/src/lib/plugin.ts | 87 +- .../src/lib/testHelper.ts | 7 +- .../src/lib/transformStrip.spec.ts | 3799 ++--------------- .../src/lib/transformStrip.ts | 405 +- .../src/lib/transformWarningThrow.spec.ts | 46 - .../src/lib/transformWarningThrow.ts | 46 - .../vite-plugin-stripper/src/shared/User.ts | 2 +- packages/vite-plugin-stripper/vite.config.ts | 1 - pnpm-lock.yaml | 613 ++- pnpm-workspace.yaml | 9 +- 26 files changed, 1356 insertions(+), 4494 deletions(-) create mode 100644 .changeset/curvy-rivers-build.md create mode 100644 .changeset/thin-carrots-throw.md delete mode 100644 babel.config.js create mode 100644 packages/internals/src/lib/ast/oxcCommentsToEsrapComments.js delete mode 100644 packages/vite-plugin-stripper/src/lib/transformWarningThrow.spec.ts delete mode 100644 packages/vite-plugin-stripper/src/lib/transformWarningThrow.ts diff --git a/.changeset/curvy-rivers-build.md b/.changeset/curvy-rivers-build.md new file mode 100644 index 00000000..b7a6158a --- /dev/null +++ b/.changeset/curvy-rivers-build.md @@ -0,0 +1,5 @@ +--- +'vite-plugin-stripper': minor +--- + +remove option `log_on_throw_is_not_a_new_class` (ping me if you want support of it again!) diff --git a/.changeset/thin-carrots-throw.md b/.changeset/thin-carrots-throw.md new file mode 100644 index 00000000..9ec48221 --- /dev/null +++ b/.changeset/thin-carrots-throw.md @@ -0,0 +1,5 @@ +--- +'@kitql/internals': minor +--- + +rmv `babel` & `recast` in favor of `oxc` diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index 7f6cefab..00000000 --- a/babel.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'], -} diff --git a/package.json b/package.json index ef06d7c8..842976d6 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "oxlint": "catalog:linting-oxc", "oxlint-tsgolint": "catalog:linting-oxc", "prettier": "catalog:formatting", - "rimraf": "catalog:tooling", "vitest": "catalog:testing" } } diff --git a/packages/handles/playwright.config.ts b/packages/handles/playwright.config.ts index f280aecf..d4c91f3c 100644 --- a/packages/handles/playwright.config.ts +++ b/packages/handles/playwright.config.ts @@ -5,8 +5,8 @@ const config: PlaywrightTestConfig = { command: 'npm run build && npm run preview', port: 4173, }, - retries: 3, - timeout: 5000, + retries: 5, + timeout: 7000, testMatch: /(.+\.)?(e2e)\.[jt]s/, use: { baseURL: 'http://localhost:4173', diff --git a/packages/internals/package.json b/packages/internals/package.json index 2f80a428..f3589b64 100644 --- a/packages/internals/package.json +++ b/packages/internals/package.json @@ -44,10 +44,10 @@ "vitest": "catalog:testing" }, "dependencies": { - "@babel/parser": "catalog:tooling", - "@babel/types": "catalog:tooling", "@kitql/helpers": "workspace:*", - "recast": "catalog:tooling", + "esrap": "catalog:tooling", + "oxc-parser": "catalog:tooling", + "oxc-walker": "catalog:tooling", "svelte": "catalog:svelte-dep" }, "sideEffects": false, diff --git a/packages/internals/src/lib/ast/ast.spec.ts b/packages/internals/src/lib/ast/ast.spec.ts index c007f26a..ecd73c66 100644 --- a/packages/internals/src/lib/ast/ast.spec.ts +++ b/packages/internals/src/lib/ast/ast.spec.ts @@ -12,7 +12,7 @@ describe('parse', function () { @annotation class Test {} `) - expect(parsed.type).toMatchInlineSnapshot(`"File"`) + expect(parsed.program.type).toMatchInlineSnapshot(`"Program"`) }) it('parse with top level await', async function () { @@ -46,40 +46,33 @@ const b = "hello" const ast = parse(code) expect(print(ast).code).toMatchInlineSnapshot(` - "// import { performance } from 'perf_hooks' + "import { BackendMethod, remult, type Allowed } from 'remult'; + + // import { performance } from 'perf_hooks' // import { AUTH_SECRET } from "$env/static/private" // const helpers = async () => { - // const { AUTH_SECRET } = await import('$env/static/private') - // return { AUTH_SECRET } - // } - // if (import.meta.env.SSR) { + // const { AUTH_SECRET } = await import('$env/static/private') + // return { AUTH_SECRET } // } - import { BackendMethod, remult, type Allowed } from "remult"; - export class ActionsController { - @BackendMethod({ - allowed: () => remult.user === undefined - }) - static async read(info: Allowed) { - const { - plop - } = await import("./toto.js"); - - const { - AUTH_SECRET - } = await import("$env/static/private"); - - const { - performance: p - } = await import("perf_hooks"); - - const start = p.now(); - console.info("AUTH_SECRET", AUTH_SECRET); - const end = p.now(); - console.info(end - start); - plop(); - return AUTH_SECRET + " " + info; - } + @BackendMethod({ allowed: () => remult.user === undefined }) + static async read(info: Allowed// if (import.meta.env.SSR) { + // } + ) { + const { plop } = await import('./toto.js'); + const { AUTH_SECRET } = await import('$env/static/private'); + const { performance: p } = await import('perf_hooks'); + const start = p.now(); + + console.info('AUTH_SECRET', AUTH_SECRET); + + const end = p.now(); + + console.info(end - start); + plop(); + + return AUTH_SECRET + ' ' + info; + } }" `) }) @@ -89,45 +82,49 @@ const b = "hello" const ast = parse(code) expect(print(ast).code).toMatchInlineSnapshot(` - "// Only unauthenticated users can call this method - import { BackendMethod, Entity, Fields, remult, type Allowed } from "remult"; - import { AUTH_SECRET } from "$env/static/private"; - - @Entity("users", { - allowApiCrud: true, - - backendPrefilter: () => { - console.info("AUTH_SECRET_backendPrefilter", AUTH_SECRET); - console.info("backendPrefilter_top_secret"); - return {}; - }, - - backendPreprocessFilter: f => { - console.info("AUTH_SECRET_backendPreprocessFilter", AUTH_SECRET); - console.info("backendPreprocessFilter_top_secret"); - return f; - }, - - sqlExpression: () => { - console.info("AUTH_SECRET_sqlExpression", AUTH_SECRET); - console.info("sqlExpression_top_secret"); - return "users"; - } + "import { BackendMethod, Entity, Fields, remult, type Allowed } from 'remult'; + import { AUTH_SECRET } from '$env/static/private'; + + @Entity('users', { + allowApiCrud: true, + + backendPrefilter: () => { + console.info('AUTH_SECRET_backendPrefilter', AUTH_SECRET); + console.info('backendPrefilter_top_secret'); + + return {}; + }, + + backendPreprocessFilter: (f) => { + console.info('AUTH_SECRET_backendPreprocessFilter', AUTH_SECRET); + console.info('backendPreprocessFilter_top_secret'); + + return f; + }, + + sqlExpression: () => { + console.info('AUTH_SECRET_sqlExpression', AUTH_SECRET); + console.info('sqlExpression_top_secret'); + + return 'users'; + } }) export class User { - @Fields.uuid() - id = ""; - - @Fields.string() - name = ""; - - @BackendMethod({ - allowed: () => remult.user === undefined - }) - static async hi(info: Allowed) { - console.info("AUTH_SECRET", AUTH_SECRET); - return AUTH_SECRET + " " + info; - } + @Fields.id() + id = ''; + + @Fields.string() + name = ''; + + @BackendMethod({ + // Only unauthenticated users can call this method + allowed: () => remult.user === undefined + }) + static async hi(info: Allowed) { + console.info('AUTH_SECRET', AUTH_SECRET); + + return AUTH_SECRET + ' ' + info; + } }" `) }) diff --git a/packages/internals/src/lib/ast/ast.ts b/packages/internals/src/lib/ast/ast.ts index 8d039c26..32499caa 100644 --- a/packages/internals/src/lib/ast/ast.ts +++ b/packages/internals/src/lib/ast/ast.ts @@ -1,33 +1,42 @@ -import babel from '@babel/parser' -import * as recast from 'recast' +import { print as esrap_print } from 'esrap' +import ts from 'esrap/languages/ts' +import { parseSync } from 'oxc-parser' +import type { ParseResult, Statement } from 'oxc-parser' +import { walk } from 'oxc-walker' -export type Statement = recast.types.namedTypes.Statement -export type ParseResult = babel.ParseResult -export const { visit, builders } = recast.types +import { oxcCommentsToEsrapComments } from './oxcCommentsToEsrapComments.js' -/** @deprecated Use `parse` instead */ -export function parseTs(source: string | null) { - const parsed = babel.parse(source ?? '', { - sourceType: 'module', - plugins: ['typescript', 'importAssertions', 'decorators-legacy'], - }) +export { walk } +export type KitQLParseResult = ParseResult & { code: string } +export type ParseOptions = { filename?: string; lang?: 'ts' } +export type { Statement } - return parsed.program as ParseResult['program'] -} - -export function parse(code_ast: string | ParseResult) { +export function parse(code_ast: string | null | KitQLParseResult, options?: ParseOptions) { if (code_ast === null || typeof code_ast === 'string') { - const parsed = babel.parse(code_ast ?? '', { + const parsed = parseSync(options?.filename ?? 'default.ts', code_ast ?? '', { sourceType: 'module', - plugins: ['typescript', 'importAssertions', 'decorators-legacy'], + lang: options?.lang ?? 'ts', }) - return parsed + return { ...parsed, code: code_ast ?? '' } as KitQLParseResult } return code_ast } -export function print(node: recast.types.namedTypes.Program, options?: recast.Options) { - return recast.prettyPrint(node, options) +export function print(ast: KitQLParseResult, options?: {}) { + const { ast: ast_with_comments, comments } = oxcCommentsToEsrapComments( + ast.code, + // @ts-expect-error + ast.program, + ast.comments, + ) + + try { + return esrap_print(ast_with_comments, ts({ comments })) + } catch (error) { + console.dir(error, { depth: null }) + // console.dir(ast.program, { depth: null }) + throw error + } } diff --git a/packages/internals/src/lib/ast/astImports.ts b/packages/internals/src/lib/ast/astImports.ts index 9fcb0ceb..66414b73 100644 --- a/packages/internals/src/lib/ast/astImports.ts +++ b/packages/internals/src/lib/ast/astImports.ts @@ -1,4 +1,4 @@ -import { parse, visit, type ParseResult } from './ast.js' +import { parse, walk, type KitQLParseResult } from './ast.js' export type ImportInfo = { name: string @@ -12,63 +12,65 @@ export type UserInfo = { } export const imports = ( - code_or_program: string | ParseResult, -): { program: ParseResult; importsList: ImportInfo[] } => { - const program = parse(code_or_program) + code_or_program: string | KitQLParseResult, +): { program: KitQLParseResult; importsList: ImportInfo[] } => { + const parsed = parse(code_or_program) const importsList: ImportInfo[] = [] - visit(program, { - visitImportDeclaration(path: any) { - const source = path.node.source.value as string - const isTypeOnly = path.node.importKind === 'type' + walk(parsed.program, { + enter(node, parent, ctx) { + if (node.type === 'ImportDeclaration') { + const source = node.source.value as string + const isTypeOnly = node.importKind === 'type' - // Handle bare imports (import "source") - if (!path.node.specifiers || path.node.specifiers.length === 0) { - importsList.push({ - name: 'default', - type: 'default', - source, - }) - return false - } - - // Process all specifiers in this import declaration - path.node.specifiers?.forEach((specifier: any) => { - if (specifier.type === 'ImportDefaultSpecifier') { - // Default import: import Name from 'source' + // Handle bare imports (import "source") + if (!node.specifiers || node.specifiers.length === 0) { importsList.push({ - name: specifier.local.name, + name: 'default', type: 'default', source, }) - } else if (specifier.type === 'ImportNamespaceSpecifier') { - // Namespace import: import * as Name from 'source' - importsList.push({ - name: specifier.local.name, - type: 'namespace', - source, - }) - } else if (specifier.type === 'ImportSpecifier') { - // Named import: import { name } from 'source' - // or type import: import type { name } from 'source' - const importedName = specifier.imported?.name || specifier.local.name - const localName = specifier.local.name + return false + } - // Handle type imports - const importType = isTypeOnly || specifier.importKind === 'type' ? 'type' : 'named' + // Process all specifiers in this import declaration + node.specifiers?.forEach((specifier: any) => { + if (specifier.type === 'ImportDefaultSpecifier') { + // Default import: import Name from 'source' + importsList.push({ + name: specifier.local.name, + type: 'default', + source, + }) + } else if (specifier.type === 'ImportNamespaceSpecifier') { + // Namespace import: import * as Name from 'source' + importsList.push({ + name: specifier.local.name, + type: 'namespace', + source, + }) + } else if (specifier.type === 'ImportSpecifier') { + // Named import: import { name } from 'source' + // or type import: import type { name } from 'source' + const importedName = specifier.imported?.name || specifier.local.name + const localName = specifier.local.name - importsList.push({ - name: importedName, - type: importType, - localName: importedName !== localName ? localName : undefined, - source, - }) - } - }) + // Handle type imports + const importType = isTypeOnly || specifier.importKind === 'type' ? 'type' : 'named' - return false + importsList.push({ + name: importedName, + type: importType, + localName: importedName !== localName ? localName : undefined, + source, + }) + } + }) + + return false + } }, }) - return { program, importsList } + return { program: parsed, importsList } } diff --git a/packages/internals/src/lib/ast/oxcCommentsToEsrapComments.js b/packages/internals/src/lib/ast/oxcCommentsToEsrapComments.js new file mode 100644 index 00000000..319bf2d5 --- /dev/null +++ b/packages/internals/src/lib/ast/oxcCommentsToEsrapComments.js @@ -0,0 +1,135 @@ +// @ts-check + +/** @import { TSESTree } from '@typescript-eslint/types' */ +/** @import { Comment as OxcComment } from 'oxc-parser' */ + +/** @param {string} code + * @param {TSESTree.Program} oxc_ast + * @param { OxcComment[]} oxc_comments + * + * @deprecated To be replaced by adding in oxc parse option `{ loc: true }` + * when https://github.com/oxc-project/oxc/issues/10307 is done + */ +export function oxcCommentsToEsrapComments(code, oxc_ast, oxc_comments) { + oxc_comments = oxc_comments.map((comment) => { + const startPos = getPositionFromOffset(code, comment.start) + const endPos = getPositionFromOffset(code, comment.end) + + let value = comment.value + // Normalize indentation for block comments with newlines (same as acorn) + if (comment.type === 'Block' && /\n/.test(value)) { + let a = comment.start + while (a > 0 && code[a - 1] !== '\n') a -= 1 + + let b = a + while (/[ \t]/.test(code[b])) b += 1 + + const indentation = code.slice(a, b) + value = value.replace(new RegExp(`^${indentation}`, 'gm'), '') + } + + return { + type: comment.type, + value, + start: comment.start, + end: comment.end, + loc: { + start: startPos, + end: endPos, + }, + } + }) + + // Add location information to AST nodes + addLocationToNode(oxc_ast, code) + + return { + ast: oxc_ast, + comments: /** @type {TSESTree.Comment[]} */ (/** @type {any} */ (oxc_comments)), + } +} + +/** + * Add location information to AST nodes using a more efficient approach + * @param {any} node + * @param {string} source + * @param {Set} visited + */ +function addLocationToNode(node, source, visited = new Set()) { + if (!node || typeof node !== 'object' || visited.has(node)) { + return + } + + visited.add(node) + + // Add loc to current node if it has start/end + if (node.start !== undefined && node.end !== undefined) { + node.loc = { + start: getPositionFromOffset(source, node.start), + end: getPositionFromOffset(source, node.end), + } + } + + // Known non-AST properties to skip (much smaller and more maintainable) + const skipProperties = new Set([ + 'type', + 'start', + 'end', + 'loc', + 'range', + 'raw', + 'value', + 'name', + 'operator', + 'prefix', + 'postfix', + 'regex', + 'flags', + 'pattern', + 'computed', + 'optional', + 'shorthand', + 'method', + 'kind', + 'definite', + 'declare', + 'generator', + 'async', + 'directive', + ]) + + // Process all properties, filtering out known non-AST properties + for (const [key, value] of Object.entries(node)) { + if (skipProperties.has(key)) continue + + if (value && typeof value === 'object') { + if (Array.isArray(value)) { + value.forEach((item) => addLocationToNode(item, source, visited)) + } else { + addLocationToNode(value, source, visited) + } + } + } +} + +/** + * Convert byte offset to line/column position + * @param {string} source + * @param {number} offset + * @returns {{ line: number, column: number }} + */ +function getPositionFromOffset(source, offset) { + let line = 1 + let column = 0 + + for (let i = 0; i < offset && i < source.length; i++) { + if (source[i] === '\n') { + line++ + column = 0 + } else { + column++ + } + } + + return { line, column } +} diff --git a/packages/internals/src/lib/fs/fs.spec.ts b/packages/internals/src/lib/fs/fs.spec.ts index 4cf01cc1..871da109 100644 --- a/packages/internals/src/lib/fs/fs.spec.ts +++ b/packages/internals/src/lib/fs/fs.spec.ts @@ -4,8 +4,8 @@ import { findFileOrUp, getFilesUnder, getRelativePackagePath, read, relative, wr describe('getRelativePackagePath', () => { it('should get package path single', async () => { - const path = getRelativePackagePath('recast') - expect(path).toMatchInlineSnapshot(`"node_modules/recast"`) + const path = getRelativePackagePath('esrap') + expect(path).toMatchInlineSnapshot(`"node_modules/esrap"`) }) it('should get package path with / and in root', async () => { diff --git a/packages/internals/src/lib/index.ts b/packages/internals/src/lib/index.ts index 29bd9626..e4d76256 100644 --- a/packages/internals/src/lib/index.ts +++ b/packages/internals/src/lib/index.ts @@ -8,15 +8,7 @@ export { findFileOrUp, } from './fs/fs.js' -export type { Statement, ParseResult } from './ast/ast.js' -export { - parse, - /** @deprecated Use `parse` instead */ - parseTs, - visit, - print, - /** @deprecated */ - builders, -} from './ast/ast.js' +export type { KitQLParseResult, ParseOptions, Statement } from './ast/ast.js' +export { walk, parse, print } from './ast/ast.js' export { extractHtmlElementAttr_Text } from './ast/astHtml.js' diff --git a/packages/vite-plugin-kit-routes/src/lib/ast.ts b/packages/vite-plugin-kit-routes/src/lib/ast.ts index dda19890..283510e3 100644 --- a/packages/vite-plugin-kit-routes/src/lib/ast.ts +++ b/packages/vite-plugin-kit-routes/src/lib/ast.ts @@ -1,5 +1,5 @@ import { cyan, red, yellow } from '@kitql/helpers' -import { parse, read, visit } from '@kitql/internals' +import { parse, read, walk } from '@kitql/internals' import { log, routes_path } from './plugin.js' @@ -10,41 +10,45 @@ export const getMethodsOfServerFiles = (pathFile: string) => { const exportedNames: string[] = [] try { const codeParsed = parse(code) - visit(codeParsed, { - visitExportNamedDeclaration(path) { - const declaration = path.node.declaration + walk(codeParsed.program, { + enter(node) { + if (node.type === 'ExportNamedDeclaration') { + const declaration = node.declaration - // Check for variable declarations - if (declaration?.type === 'VariableDeclaration') { - declaration.declarations.forEach((declaration) => { - if ( - declaration.type === 'VariableDeclarator' && - declaration.id.type === 'Identifier' && - declaration.id.name - ) { - exportedNames.push(declaration.id.name) + // Check for variable declarations + if (declaration?.type === 'VariableDeclaration') { + declaration.declarations.forEach((declaration) => { + if ( + declaration.type === 'VariableDeclarator' && + declaration.id.type === 'Identifier' && + declaration.id.name + ) { + exportedNames.push(declaration.id.name) + } + }) + } + + // Check for function declarations + if (declaration?.type === 'FunctionDeclaration') { + if (declaration.id && declaration.id.name && !String(declaration.id.name).startsWith('_')) { + exportedNames.push(String(declaration.id.name)) } - }) - } + } - // Check for function declarations - if (declaration?.type === 'FunctionDeclaration') { - if (declaration.id && declaration.id.name && !String(declaration.id.name).startsWith('_')) { - exportedNames.push(String(declaration.id.name)) + // Check for export specifiers (for aliased exports) + const specifiers = node.specifiers + if (specifiers) { + specifiers.forEach((specifier) => { + const exported = specifier.exported as any + const exportedName = exported.name || exported.value + if (exportedName) { + exportedNames.push(String(exportedName)) + } + }) } - } - // Check for export specifiers (for aliased exports) - const specifiers = path.node.specifiers - if (specifiers) { - specifiers.forEach((specifier) => { - if (specifier.exported.name) { - exportedNames.push(String(specifier.exported.name)) - } - }) + return false } - - return false }, }) } catch (error) { @@ -64,35 +68,37 @@ export const getActionsOfServerPages = (pathFile: string) => { let actions: string[] = [] try { const codeParsed = parse(code) - visit(codeParsed, { - visitExportNamedDeclaration(path) { - // @ts-ignore - const declarations = path.node.declaration?.declarations - if (declarations) { - declarations.forEach((declaration: any) => { - if (declaration.id.name === 'actions') { - const properties = - // if } satisfies Actions - declaration.init.expression?.properties ?? - // if no satisfies Actions - declaration.init.properties + walk(codeParsed.program, { + enter(node) { + if (node.type === 'ExportNamedDeclaration') { + // @ts-ignore + const declarations = node.declaration?.declarations + if (declarations) { + declarations.forEach((declaration: any) => { + if (declaration.id.name === 'actions') { + const properties = + // if } satisfies Actions + declaration.init.expression?.properties ?? + // if no satisfies Actions + declaration.init.properties - if (properties) { - properties.forEach((property: any) => { - if (property.key.name) { - actions.push(property.key.name) - } else if (property.key.value) { - actions.push(property.key.value) - } - }) + if (properties) { + properties.forEach((property: any) => { + if (property.key.name) { + actions.push(property.key.name) + } else if (property.key.value) { + actions.push(property.key.value) + } + }) + } } - } - if (declaration.id.name === 'load') { - withLoad = true - } - }) + if (declaration.id.name === 'load') { + withLoad = true + } + }) + } + return false } - return false }, }) @@ -266,39 +272,43 @@ export const getExportsFromFile = (code: string, exportName?: string) => { const codeParsed = parse(code) let result: any = null - visit(codeParsed, { - visitExportNamedDeclaration(path) { - if (exportName) { - // Looking for a specific named export - const specifiers = path.node.specifiers - if (specifiers) { - specifiers.forEach((specifier) => { - if (specifier.exported.name === exportName && specifier.local) { - result = specifier.local.name - } - }) - } + walk(codeParsed.program, { + enter(node) { + if (node.type === 'ExportNamedDeclaration') { + if (exportName) { + // Looking for a specific named export + const specifiers = node.specifiers + if (specifiers) { + specifiers.forEach((specifier) => { + const exported = specifier.exported as any + const exportedName = exported.name || exported.value + if (exportedName === exportName && specifier.local) { + const local = specifier.local as any + result = local.name + } + }) + } - const declaration = path.node.declaration - if (declaration?.type === 'VariableDeclaration') { - declaration.declarations.forEach((declaration) => { - if ( - declaration.type === 'VariableDeclarator' && - declaration.id.type === 'Identifier' && - declaration.id.name === exportName - ) { - result = declaration.init - } - }) + const declaration = node.declaration + if (declaration?.type === 'VariableDeclaration') { + declaration.declarations.forEach((declaration) => { + if ( + declaration.type === 'VariableDeclarator' && + declaration.id.type === 'Identifier' && + declaration.id.name === exportName + ) { + result = declaration.init + } + }) + } } + return false + } else if (node.type === 'ExportDefaultDeclaration') { + if (!exportName) { + result = node.declaration + } + return false } - return false - }, - visitExportDefaultDeclaration(path) { - if (!exportName) { - result = path.node.declaration - } - return false }, }) diff --git a/packages/vite-plugin-stripper/src/lib/nullifyImports.spec.ts b/packages/vite-plugin-stripper/src/lib/nullifyImports.spec.ts index e53808d6..b7c6a2f2 100644 --- a/packages/vite-plugin-stripper/src/lib/nullifyImports.spec.ts +++ b/packages/vite-plugin-stripper/src/lib/nullifyImports.spec.ts @@ -27,31 +27,31 @@ describe('package', () => { const transformed = await nullifyImports(code, ['mongodb']) expect(toInfoCode(transformed)).toMatchInlineSnapshot(` - { - "code": "let ObjectId = null; + { + "code": "let ObjectId = null; - @Entity("tasks", { - allowApiCrud: true - }) - export class Task { - @Fields.string({ - valueConverter: { - fromDb: x => x?.toString(), + @Entity('tasks', { allowApiCrud: true }) + export class Task { + @Fields.string({ + valueConverter: { + fromDb: (x) => x?.toString(), + + toDb: (x) => { + const r = new ObjectId(x); - toDb: x => { - const r = new ObjectId(x); - console.log(r); - return r; - } - } - }) - aMongoDbIdField = ""; - }", - "info": [ - "Nullify import from 'mongodb'", - ], - } - `) + console.log(r); + + return r; + } + } + }) + aMongoDbIdField = ''; + }", + "info": [ + "Nullify 'ObjectId' from 'mongodb'", + ], + } + `) }) it('2 replaces', async () => { @@ -76,30 +76,29 @@ describe('package', () => { const transformed = await nullifyImports(code, ['mongodb']) expect(toInfoCode(transformed)).toMatchInlineSnapshot(` - { - "code": "let ObjectId = null; - let demo = null; + { + "code": "let ObjectId = null; + let demo = null; - @Entity("tasks", { - allowApiCrud: true - }) - export class Task { - @Fields.string({ - valueConverter: { - fromDb: x => x?.toString(), + @Entity('tasks', { allowApiCrud: true }) + export class Task { + @Fields.string({ + valueConverter: { + fromDb: (x) => x?.toString(), - toDb: x => { - const r = new ObjectId(x); - const u = demo; - } - } - }) - aMongoDbIdField = ""; - }", - "info": [ - "Nullify import from 'mongodb'", - ], - } - `) + toDb: (x) => { + const r = new ObjectId(x); + const u = demo; + } + } + }) + aMongoDbIdField = ''; + }", + "info": [ + "Nullify 'ObjectId' from 'mongodb'", + "Nullify 'demo' from 'mongodb'", + ], + } + `) }) }) diff --git a/packages/vite-plugin-stripper/src/lib/nullifyImports.ts b/packages/vite-plugin-stripper/src/lib/nullifyImports.ts index 56123336..478e39b7 100644 --- a/packages/vite-plugin-stripper/src/lib/nullifyImports.ts +++ b/packages/vite-plugin-stripper/src/lib/nullifyImports.ts @@ -1,49 +1,92 @@ -import { builders, parse, visit } from '@kitql/internals' -import type { ParseResult } from '@kitql/internals' +import { parse, walk } from '@kitql/internals' +import type { KitQLParseResult, ParseOptions } from '@kitql/internals' export const nullifyImports = async ( - code_ast: string | ParseResult, + code_ast: string | KitQLParseResult, packages_to_strip: string[], + opts?: ParseOptions, ) => { try { - const ast = parse(code_ast) + const ast = parse(code_ast, opts) - const packages_striped: string[] = [] + const nullifyed: string[] = [] - visit(ast, { - visitImportDeclaration(path: any) { - const packageName = path.node.source.value - if (packages_to_strip.includes(String(packageName))) { - const specifiers = path.node.specifiers! - const replacementNodes = specifiers - .map((specifier: any) => { - if (specifier.type === 'ImportSpecifier') { - return builders.variableDeclaration('let', [ - builders.variableDeclarator( - builders.identifier(String(specifier.imported.name)), - builders.literal(null), - ), - ]) - } - }) - .filter(Boolean) // Remove undefined values + walk(ast.program, { + enter(node, parent) { + if (node.type === 'ImportDeclaration') { + const packageName = node.source.value + if (packages_to_strip.includes(String(packageName))) { + const specifiers = node.specifiers + const replacementNodes = specifiers + .map((specifier: any) => { + if (specifier.type === 'ImportSpecifier') { + nullifyed.push( + `Nullify '${String(specifier.imported.name)}' from '${String(packageName)}'`, + ) + // Create a variable declaration that sets the import to null + return { + type: 'VariableDeclaration', + kind: 'let', + declarations: [ + { + type: 'VariableDeclarator', + id: { + type: 'Identifier', + name: String(specifier.imported.name), + }, + init: { + type: 'Literal', + value: null, + }, + }, + ], + } + } + return null + }) + .filter((node): node is any => node !== null) // Remove null values and assert type - if (replacementNodes.length > 0) { - path.replace(...replacementNodes) - packages_striped.push(String(packageName)) - } else { - path.prune() + if (replacementNodes.length > 0) { + // Replace the node in the parent's body + if ( + parent && + 'type' in parent && + (parent.type === 'Program' || parent.type === 'BlockStatement') && + Array.isArray(parent.body) + ) { + const index = parent.body.indexOf(node) + if (index !== -1) { + // Remove the import declaration + parent.body.splice(index, 1) + // Insert the replacement nodes + parent.body.splice(index, 0, ...replacementNodes) + } + } + } else { + // Remove the node from the parent's body + if ( + parent && + 'type' in parent && + (parent.type === 'Program' || parent.type === 'BlockStatement') && + Array.isArray(parent.body) + ) { + const index = parent.body.indexOf(node) + if (index !== -1) { + parent.body.splice(index, 1) + } + } + } } + return false } - return false }, }) return { code_ast: ast, - info: packages_striped.map((pkg) => `Nullify import from '${pkg}'`), + ast, + info: nullifyed, } - } catch (error) { - return { code_ast, info: [] } - } + } catch (error) {} + return { code_ast, ast: null, info: [] } } diff --git a/packages/vite-plugin-stripper/src/lib/plugin.spec.ts b/packages/vite-plugin-stripper/src/lib/plugin.spec.ts index ee402707..0b315832 100644 --- a/packages/vite-plugin-stripper/src/lib/plugin.spec.ts +++ b/packages/vite-plugin-stripper/src/lib/plugin.spec.ts @@ -256,7 +256,7 @@ describe('Plugin build output', () => { // The Entity decorator and class structure should be there expect(outputContent).toContain('Entity') expect(outputContent).toContain('User') - expect(outputContent).toContain('Fields.uuid') + expect(outputContent).toContain('Fields.id') expect(outputContent).toContain('Fields.string') // The BackendMethod decorator should be there diff --git a/packages/vite-plugin-stripper/src/lib/plugin.ts b/packages/vite-plugin-stripper/src/lib/plugin.ts index 03473b82..0a2bddf8 100644 --- a/packages/vite-plugin-stripper/src/lib/plugin.ts +++ b/packages/vite-plugin-stripper/src/lib/plugin.ts @@ -1,13 +1,10 @@ -import { readFileSync } from 'fs' import type { PluginOption } from 'vite' -import { watchAndRun } from 'vite-plugin-watch-and-run' import { gray, green, Log, yellow } from '@kitql/helpers' -import { getFilesUnder, print, type ParseResult } from '@kitql/internals' +import { print, type KitQLParseResult } from '@kitql/internals' import { nullifyImports } from './nullifyImports.js' import { transformStrip, type StripConfig } from './transformStrip.js' -import { transformWarningThrow, type WarningThrow } from './transformWarningThrow.js' export type ViteStripperOptions = { /** @@ -67,13 +64,6 @@ export type ViteStripperOptions = { */ nullify?: string[] - /** - * If true, skip warnings if a throw is not a class. - * - * @default false - */ - log_on_throw_is_not_a_new_class?: boolean - /** * internal usage ;-) */ @@ -100,16 +90,6 @@ export type ViteStripperOptions = { */ export function stripper(options?: ViteStripperOptions): PluginOption { const log = new Log('stripper') - let listOrThrow: WarningThrow[] = [] - - const display = () => { - listOrThrow.forEach((item) => { - log.error( - `Throw is not a new class in ${yellow(item.relativePathFile)}:${yellow(String(item.line))}`, - ) - }) - listOrThrow = [] - } const getProjectPath = () => { return process.cwd() + '/src' @@ -120,25 +100,6 @@ export function stripper(options?: ViteStripperOptions): PluginOption { name: 'vite-plugin-stripper', enforce: 'pre', - config: async () => { - if (options?.log_on_throw_is_not_a_new_class) { - const files = getFilesUnder(getProjectPath()) - listOrThrow = [] - for (let i = 0; i < files.length; i++) { - const absolutePath = getProjectPath() + '/' + files[i] - const code = readFileSync(absolutePath, { encoding: 'utf8' }) - const { list } = await transformWarningThrow( - absolutePath, - getProjectPath(), - code, - options?.log_on_throw_is_not_a_new_class, - ) - listOrThrow.push(...list) - } - display() - } - }, - applyToEnvironment(environment) { return environment.name === 'client' }, @@ -164,25 +125,29 @@ export function stripper(options?: ViteStripperOptions): PluginOption { } const allInfos: string[] = [] - let code_ast: string | ParseResult = code + let code_ast: string | KitQLParseResult = code if (options && options?.nullify && options.nullify.length > 0) { - const { info, code_ast: transformed } = await nullifyImports(code_ast, options.nullify) + const { info, ast: transformed } = await nullifyImports(code_ast, options.nullify) // Update the code for later transforms & return it - code_ast = transformed + if (transformed !== null) { + code_ast = transformed + } allInfos.push(...info) } if (options && options?.strip && options.strip.length > 0) { - const { info, code_ast: transformed } = await transformStrip(code_ast, options.strip) + const { info, ast: transformed } = await transformStrip(code_ast, options.strip) // Update the code for later transforms & return it - code_ast = transformed + if (transformed !== null) { + code_ast = transformed + } allInfos.push(...info) } - if (allInfos.length > 0) { + if (allInfos.length > 0 && typeof code_ast !== 'string' && code_ast !== null) { const toRet = print(code_ast) if (options?.debug) { @@ -203,35 +168,5 @@ export function stripper(options?: ViteStripperOptions): PluginOption { }, ] - if (options?.log_on_throw_is_not_a_new_class) { - plugins.push( - // Run the thing when any changes happens in the project - watchAndRun([ - { - name: 'vite-plugin-stripper-throw-not-new-class', - logs: [], - watch: ['**'], - run: async (server, absolutePath) => { - if (options?.log_on_throw_is_not_a_new_class) { - // Only file in our project - if (absolutePath && absolutePath.startsWith(getProjectPath())) { - const code = readFileSync(absolutePath, { encoding: 'utf8' }) - - const { list } = await transformWarningThrow( - absolutePath, - getProjectPath(), - code, - options?.log_on_throw_is_not_a_new_class, - ) - listOrThrow.push(...list) - display() - } - } - }, - }, - ]), - ) - } - return plugins } diff --git a/packages/vite-plugin-stripper/src/lib/testHelper.ts b/packages/vite-plugin-stripper/src/lib/testHelper.ts index 86dee5a5..20b0f52a 100644 --- a/packages/vite-plugin-stripper/src/lib/testHelper.ts +++ b/packages/vite-plugin-stripper/src/lib/testHelper.ts @@ -1,15 +1,16 @@ -import type { ParseResult } from '@kitql/internals' +import type { KitQLParseResult } from '@kitql/internals' import { print } from '@kitql/internals' -export const toInfoCode = (input: { code_ast: string | ParseResult; info: string[] }) => { +export const toInfoCode = (input: { code_ast: string | KitQLParseResult; info: string[] }) => { if (typeof input.code_ast === 'string') { return { info: input.info, code: input.code_ast, } } + const { code } = print(input.code_ast) return { info: input.info, - code: print(input.code_ast!.program).code, + code, } } diff --git a/packages/vite-plugin-stripper/src/lib/transformStrip.spec.ts b/packages/vite-plugin-stripper/src/lib/transformStrip.spec.ts index 6ffe3e76..50f8f05e 100644 --- a/packages/vite-plugin-stripper/src/lib/transformStrip.spec.ts +++ b/packages/vite-plugin-stripper/src/lib/transformStrip.spec.ts @@ -36,42 +36,38 @@ export class ActionsController { const data = await transformStrip(code, [{ decorator: 'BackendMethod' }]) expect(toInfoCode(data)).toMatchInlineSnapshot(` { - "code": "import { BackendMethod, remult, type Allowed } from "remult"; - import { performance } from "perf_hooks"; + "code": "import { BackendMethod, remult, type Allowed } from 'remult'; + import { performance } from 'perf_hooks'; const helpers = async () => { - const { - AUTH_SECRET - } = await import("$env/static/private"); + const { AUTH_SECRET } = await import('$env/static/private'); - return { - AUTH_SECRET - }; + return { AUTH_SECRET }; }; export class ActionsController { - @BackendMethod({ - allowed: () => remult.user === undefined - }) - static async read(info: Allowed) { - if (import.meta.env.SSR) { - const { - plop - } = await import("./toto.js"); - - const { - AUTH_SECRET - } = await import("$env/static/private"); - - helpers(); - const start = performance.now(); - console.info("AUTH_SECRET", AUTH_SECRET); - const end = performance.now(); - console.info(end - start); - plop(); - return AUTH_SECRET + " " + info; - } - } + @BackendMethod({ allowed: () => remult.user === undefined }) + static async read(info: Allowed// if (import.meta.env.SSR) { + // } + ) { + if (import.meta.env.SSR) { + const { plop } = await import('./toto.js'); + const { AUTH_SECRET } = await import('$env/static/private'); + + helpers(); + + const start = performance.now(); + + console.info('AUTH_SECRET', AUTH_SECRET); + + const end = performance.now(); + + console.info(end - start); + plop(); + + return AUTH_SECRET + ' ' + info; + } + } }", "info": [ "Wrapped with if(import.meta.env.SSR): ["ActionsController","BackendMethod","read"]", @@ -116,3201 +112,41 @@ export class TasksController { const transformed = await transformStrip(code, [{ decorator: 'BackendMethod' }]) - expect(transformed).toMatchInlineSnapshot(` + expect(toInfoCode(transformed)).toMatchInlineSnapshot(` { - "code_ast": Node { - "comments": [ - { - "end": 673, - "loc": SourceLocation { - "end": Position { - "column": 45, - "index": 673, - "line": 22, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 2, - "index": 630, - "line": 22, - }, - }, - "start": 630, - "type": "CommentLine", - "value": " console.log("AUTH_SECRET", AUTH_SECRET);", - }, - ], - "end": 817, - "errors": [], - "loc": SourceLocation { - "end": Position { - "column": 1, - "index": 817, - "line": 30, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 0, - "index": 0, - "line": 1, - }, - }, - "name": null, - "program": Node { - "body": [ - Node { - "assertions": [], - "end": 54, - "importKind": "value", - "loc": SourceLocation { - "end": Position { - "column": 54, - "index": 54, - "line": 1, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 0, - "index": 0, - "line": 1, - }, - }, - "source": Node { - "end": 53, - "extra": { - "raw": ""remult"", - "rawValue": "remult", - }, - "loc": SourceLocation { - "end": Position { - "column": 53, - "index": 53, - "line": 1, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 45, - "index": 45, - "line": 1, - }, - }, - "start": 45, - "type": "StringLiteral", - "value": "remult", - }, - "specifiers": [ - Node { - "end": 14, - "id": null, - "importKind": "value", - "imported": Node { - "end": 14, - "loc": SourceLocation { - "end": Position { - "column": 14, - "index": 14, - "line": 1, - }, - "filename": undefined, - "identifierName": "Allow", - "start": Position { - "column": 9, - "index": 9, - "line": 1, - }, - }, - "name": "Allow", - "optional": false, - "start": 9, - "type": "Identifier", - "typeAnnotation": null, - }, - "loc": SourceLocation { - "end": Position { - "column": 14, - "index": 14, - "line": 1, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 9, - "index": 9, - "line": 1, - }, - }, - "local": Node { - "end": 14, - "loc": SourceLocation { - "end": Position { - "column": 14, - "index": 14, - "line": 1, - }, - "filename": undefined, - "identifierName": "Allow", - "start": Position { - "column": 9, - "index": 9, - "line": 1, - }, - }, - "name": "Allow", - "optional": false, - "range": undefined, - "start": 9, - "type": "Identifier", - "typeAnnotation": null, - }, - "name": null, - "start": 9, - "type": "ImportSpecifier", - }, - Node { - "end": 29, - "id": null, - "importKind": "value", - "imported": Node { - "end": 29, - "loc": SourceLocation { - "end": Position { - "column": 29, - "index": 29, - "line": 1, - }, - "filename": undefined, - "identifierName": "BackendMethod", - "start": Position { - "column": 16, - "index": 16, - "line": 1, - }, - }, - "name": "BackendMethod", - "optional": false, - "start": 16, - "type": "Identifier", - "typeAnnotation": null, - }, - "loc": SourceLocation { - "end": Position { - "column": 29, - "index": 29, - "line": 1, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 16, - "index": 16, - "line": 1, - }, - }, - "local": Node { - "end": 29, - "loc": SourceLocation { - "end": Position { - "column": 29, - "index": 29, - "line": 1, - }, - "filename": undefined, - "identifierName": "BackendMethod", - "start": Position { - "column": 16, - "index": 16, - "line": 1, - }, - }, - "name": "BackendMethod", - "optional": false, - "range": undefined, - "start": 16, - "type": "Identifier", - "typeAnnotation": null, - }, - "name": null, - "start": 16, - "type": "ImportSpecifier", - }, - Node { - "end": 37, - "id": null, - "importKind": "value", - "imported": Node { - "end": 37, - "loc": SourceLocation { - "end": Position { - "column": 37, - "index": 37, - "line": 1, - }, - "filename": undefined, - "identifierName": "remult", - "start": Position { - "column": 31, - "index": 31, - "line": 1, - }, - }, - "name": "remult", - "optional": false, - "start": 31, - "type": "Identifier", - "typeAnnotation": null, - }, - "loc": SourceLocation { - "end": Position { - "column": 37, - "index": 37, - "line": 1, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 31, - "index": 31, - "line": 1, - }, - }, - "local": Node { - "end": 37, - "loc": SourceLocation { - "end": Position { - "column": 37, - "index": 37, - "line": 1, - }, - "filename": undefined, - "identifierName": "remult", - "start": Position { - "column": 31, - "index": 31, - "line": 1, - }, - }, - "name": "remult", - "optional": false, - "range": undefined, - "start": 31, - "type": "Identifier", - "typeAnnotation": null, - }, - "name": null, - "start": 31, - "type": "ImportSpecifier", - }, - ], - "start": 0, - "type": "ImportDeclaration", - }, - Node { - "assertions": [], - "end": 85, - "importKind": "value", - "loc": SourceLocation { - "end": Position { - "column": 30, - "index": 85, - "line": 2, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 0, - "index": 55, - "line": 2, - }, - }, - "source": Node { - "end": 84, - "extra": { - "raw": ""./task"", - "rawValue": "./task", - }, - "loc": SourceLocation { - "end": Position { - "column": 29, - "index": 84, - "line": 2, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 21, - "index": 76, - "line": 2, - }, - }, - "start": 76, - "type": "StringLiteral", - "value": "./task", - }, - "specifiers": [ - Node { - "end": 68, - "id": null, - "importKind": "value", - "imported": Node { - "end": 68, - "loc": SourceLocation { - "end": Position { - "column": 13, - "index": 68, - "line": 2, - }, - "filename": undefined, - "identifierName": "Task", - "start": Position { - "column": 9, - "index": 64, - "line": 2, - }, - }, - "name": "Task", - "optional": false, - "start": 64, - "type": "Identifier", - "typeAnnotation": null, - }, - "loc": SourceLocation { - "end": Position { - "column": 13, - "index": 68, - "line": 2, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 9, - "index": 64, - "line": 2, - }, - }, - "local": Node { - "end": 68, - "loc": SourceLocation { - "end": Position { - "column": 13, - "index": 68, - "line": 2, - }, - "filename": undefined, - "identifierName": "Task", - "start": Position { - "column": 9, - "index": 64, - "line": 2, - }, - }, - "name": "Task", - "optional": false, - "range": undefined, - "start": 64, - "type": "Identifier", - "typeAnnotation": null, - }, - "name": null, - "start": 64, - "type": "ImportSpecifier", - }, - ], - "start": 55, - "type": "ImportDeclaration", - }, - Node { - "assertions": [], - "end": 136, - "importKind": "value", - "loc": SourceLocation { - "end": Position { - "column": 50, - "index": 136, - "line": 3, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 0, - "index": 86, - "line": 3, - }, - }, - "source": Node { - "end": 135, - "extra": { - "raw": ""$env/static/private"", - "rawValue": "$env/static/private", - }, - "loc": SourceLocation { - "end": Position { - "column": 49, - "index": 135, - "line": 3, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 28, - "index": 114, - "line": 3, - }, - }, - "start": 114, - "type": "StringLiteral", - "value": "$env/static/private", - }, - "specifiers": [ - Node { - "end": 106, - "id": null, - "importKind": "value", - "imported": Node { - "end": 106, - "loc": SourceLocation { - "end": Position { - "column": 20, - "index": 106, - "line": 3, - }, - "filename": undefined, - "identifierName": "AUTH_SECRET", - "start": Position { - "column": 9, - "index": 95, - "line": 3, - }, - }, - "name": "AUTH_SECRET", - "optional": false, - "start": 95, - "type": "Identifier", - "typeAnnotation": null, - }, - "loc": SourceLocation { - "end": Position { - "column": 20, - "index": 106, - "line": 3, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 9, - "index": 95, - "line": 3, - }, - }, - "local": Node { - "end": 106, - "loc": SourceLocation { - "end": Position { - "column": 20, - "index": 106, - "line": 3, - }, - "filename": undefined, - "identifierName": "AUTH_SECRET", - "start": Position { - "column": 9, - "index": 95, - "line": 3, - }, - }, - "name": "AUTH_SECRET", - "optional": false, - "range": undefined, - "start": 95, - "type": "Identifier", - "typeAnnotation": null, - }, - "name": null, - "start": 95, - "type": "ImportSpecifier", - }, - ], - "start": 86, - "type": "ImportDeclaration", - }, - Node { - "assertions": [], - "declaration": Node { - "body": Node { - "body": [ - Node { - "abstract": false, - "access": null, - "accessibility": null, - "async": true, - "body": Node { - "body": [ - Node { - "declarations": [ - Node { - "end": 246, - "id": Node { - "end": 226, - "loc": SourceLocation { - "end": Position { - "column": 16, - "index": 226, - "line": 7, - }, - "filename": undefined, - "identifierName": "taskRepo", - "start": Position { - "column": 8, - "index": 218, - "line": 7, - }, - }, - "name": "taskRepo", - "optional": false, - "start": 218, - "type": "Identifier", - "typeAnnotation": null, - }, - "init": Node { - "arguments": [ - Node { - "end": 245, - "loc": SourceLocation { - "end": Position { - "column": 35, - "index": 245, - "line": 7, - }, - "filename": undefined, - "identifierName": "Task", - "start": Position { - "column": 31, - "index": 241, - "line": 7, - }, - }, - "name": "Task", - "optional": false, - "start": 241, - "type": "Identifier", - "typeAnnotation": null, - }, - ], - "callee": Node { - "computed": false, - "end": 240, - "loc": SourceLocation { - "end": Position { - "column": 30, - "index": 240, - "line": 7, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 19, - "index": 229, - "line": 7, - }, - }, - "object": Node { - "end": 235, - "loc": SourceLocation { - "end": Position { - "column": 25, - "index": 235, - "line": 7, - }, - "filename": undefined, - "identifierName": "remult", - "start": Position { - "column": 19, - "index": 229, - "line": 7, - }, - }, - "name": "remult", - "optional": false, - "start": 229, - "type": "Identifier", - "typeAnnotation": null, - }, - "optional": false, - "property": Node { - "end": 240, - "loc": SourceLocation { - "end": Position { - "column": 30, - "index": 240, - "line": 7, - }, - "filename": undefined, - "identifierName": "repo", - "start": Position { - "column": 26, - "index": 236, - "line": 7, - }, - }, - "name": "repo", - "optional": false, - "start": 236, - "type": "Identifier", - "typeAnnotation": null, - }, - "start": 229, - "type": "MemberExpression", - }, - "end": 246, - "loc": SourceLocation { - "end": Position { - "column": 36, - "index": 246, - "line": 7, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 19, - "index": 229, - "line": 7, - }, - }, - "optional": false, - "start": 229, - "type": "CallExpression", - "typeArguments": null, - }, - "loc": SourceLocation { - "end": Position { - "column": 36, - "index": 246, - "line": 7, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 8, - "index": 218, - "line": 7, - }, - }, - "start": 218, - "type": "VariableDeclarator", - }, - ], - "end": 247, - "kind": "const", - "loc": SourceLocation { - "end": Position { - "column": 37, - "index": 247, - "line": 7, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 2, - "index": 212, - "line": 7, - }, - }, - "start": 212, - "type": "VariableDeclaration", - }, - ], - "directives": [], - "end": 250, - "loc": SourceLocation { - "end": Position { - "column": 2, - "index": 250, - "line": 8, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 39, - "index": 208, - "line": 6, - }, - }, - "start": 208, - "type": "BlockStatement", - }, - "computed": false, - "decorators": null, - "defaults": [], - "definite": false, - "end": 250, - "expression": false, - "generator": false, - "id": null, - "key": Node { - "end": 187, - "loc": SourceLocation { - "end": Position { - "column": 18, - "index": 187, - "line": 6, - }, - "filename": undefined, - "identifierName": "yop1", - "start": Position { - "column": 14, - "index": 183, - "line": 6, - }, - }, - "name": "yop1", - "optional": false, - "start": 183, - "type": "Identifier", - "typeAnnotation": null, - }, - "kind": "method", - "loc": SourceLocation { - "end": Position { - "column": 2, - "index": 250, - "line": 8, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 1, - "index": 170, - "line": 6, - }, - }, - "optional": false, - "override": false, - "params": [ - Node { - "end": 206, - "loc": SourceLocation { - "end": Position { - "column": 37, - "index": 206, - "line": 6, - }, - "filename": undefined, - "identifierName": "completed", - "start": Position { - "column": 19, - "index": 188, - "line": 6, - }, - }, - "name": "completed", - "optional": false, - "start": 188, - "type": "Identifier", - "typeAnnotation": Node { - "end": 206, - "loc": SourceLocation { - "end": Position { - "column": 37, - "index": 206, - "line": 6, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 28, - "index": 197, - "line": 6, - }, - }, - "start": 197, - "type": "TSTypeAnnotation", - "typeAnnotation": Node { - "end": 206, - "loc": SourceLocation { - "end": Position { - "column": 37, - "index": 206, - "line": 6, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 30, - "index": 199, - "line": 6, - }, - }, - "start": 199, - "type": "TSBooleanKeyword", - }, - }, - }, - ], - "predicate": null, - "readonly": false, - "rest": null, - "returnType": null, - "start": 170, - "static": true, - "type": "ClassMethod", - "typeParameters": null, - }, - Node { - "abstract": false, - "access": null, - "accessibility": null, - "async": true, - "body": Node { - "body": [ - { - "alternate": null, - "consequent": { - "body": [ - Node { - "end": 396, - "expression": Node { - "arguments": [ - Node { - "end": 381, - "extra": { - "raw": ""AUTH_SECRET"", - "rawValue": "AUTH_SECRET", - }, - "loc": SourceLocation { - "end": Position { - "column": 27, - "index": 381, - "line": 12, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 14, - "index": 368, - "line": 12, - }, - }, - "start": 368, - "type": "StringLiteral", - "value": "AUTH_SECRET", - }, - Node { - "end": 394, - "loc": SourceLocation { - "end": Position { - "column": 40, - "index": 394, - "line": 12, - }, - "filename": undefined, - "identifierName": "AUTH_SECRET", - "start": Position { - "column": 29, - "index": 383, - "line": 12, - }, - }, - "name": "AUTH_SECRET", - "optional": false, - "start": 383, - "type": "Identifier", - "typeAnnotation": null, - }, - ], - "callee": Node { - "computed": false, - "end": 367, - "loc": SourceLocation { - "end": Position { - "column": 13, - "index": 367, - "line": 12, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 2, - "index": 356, - "line": 12, - }, - }, - "object": Node { - "end": 363, - "loc": SourceLocation { - "end": Position { - "column": 9, - "index": 363, - "line": 12, - }, - "filename": undefined, - "identifierName": "console", - "start": Position { - "column": 2, - "index": 356, - "line": 12, - }, - }, - "name": "console", - "optional": false, - "start": 356, - "type": "Identifier", - "typeAnnotation": null, - }, - "optional": false, - "property": Node { - "end": 367, - "loc": SourceLocation { - "end": Position { - "column": 13, - "index": 367, - "line": 12, - }, - "filename": undefined, - "identifierName": "log", - "start": Position { - "column": 10, - "index": 364, - "line": 12, - }, - }, - "name": "log", - "optional": false, - "start": 364, - "type": "Identifier", - "typeAnnotation": null, - }, - "start": 356, - "type": "MemberExpression", - }, - "end": 395, - "loc": SourceLocation { - "end": Position { - "column": 41, - "index": 395, - "line": 12, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 2, - "index": 356, - "line": 12, - }, - }, - "optional": false, - "start": 356, - "type": "CallExpression", - "typeArguments": null, - }, - "loc": SourceLocation { - "end": Position { - "column": 42, - "index": 396, - "line": 12, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 2, - "index": 356, - "line": 12, - }, - }, - "start": 356, - "type": "ExpressionStatement", - }, - Node { - "declarations": [ - Node { - "end": 434, - "id": Node { - "end": 414, - "loc": SourceLocation { - "end": Position { - "column": 16, - "index": 414, - "line": 14, - }, - "filename": undefined, - "identifierName": "taskRepo", - "start": Position { - "column": 8, - "index": 406, - "line": 14, - }, - }, - "name": "taskRepo", - "optional": false, - "start": 406, - "type": "Identifier", - "typeAnnotation": null, - }, - "init": Node { - "arguments": [ - Node { - "end": 433, - "loc": SourceLocation { - "end": Position { - "column": 35, - "index": 433, - "line": 14, - }, - "filename": undefined, - "identifierName": "Task", - "start": Position { - "column": 31, - "index": 429, - "line": 14, - }, - }, - "name": "Task", - "optional": false, - "start": 429, - "type": "Identifier", - "typeAnnotation": null, - }, - ], - "callee": Node { - "computed": false, - "end": 428, - "loc": SourceLocation { - "end": Position { - "column": 30, - "index": 428, - "line": 14, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 19, - "index": 417, - "line": 14, - }, - }, - "object": Node { - "end": 423, - "loc": SourceLocation { - "end": Position { - "column": 25, - "index": 423, - "line": 14, - }, - "filename": undefined, - "identifierName": "remult", - "start": Position { - "column": 19, - "index": 417, - "line": 14, - }, - }, - "name": "remult", - "optional": false, - "start": 417, - "type": "Identifier", - "typeAnnotation": null, - }, - "optional": false, - "property": Node { - "end": 428, - "loc": SourceLocation { - "end": Position { - "column": 30, - "index": 428, - "line": 14, - }, - "filename": undefined, - "identifierName": "repo", - "start": Position { - "column": 26, - "index": 424, - "line": 14, - }, - }, - "name": "repo", - "optional": false, - "start": 424, - "type": "Identifier", - "typeAnnotation": null, - }, - "start": 417, - "type": "MemberExpression", - }, - "end": 434, - "loc": SourceLocation { - "end": Position { - "column": 36, - "index": 434, - "line": 14, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 19, - "index": 417, - "line": 14, - }, - }, - "optional": false, - "start": 417, - "type": "CallExpression", - "typeArguments": null, - }, - "loc": SourceLocation { - "end": Position { - "column": 36, - "index": 434, - "line": 14, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 8, - "index": 406, - "line": 14, - }, - }, - "start": 406, - "type": "VariableDeclarator", - }, - ], - "end": 435, - "kind": "const", - "loc": SourceLocation { - "end": Position { - "column": 37, - "index": 435, - "line": 14, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 2, - "index": 400, - "line": 14, - }, - }, - "start": 400, - "type": "VariableDeclaration", - }, - Node { - "await": false, - "body": Node { - "body": [ - Node { - "end": 529, - "expression": Node { - "all": false, - "argument": Node { - "arguments": [ - Node { - "end": 527, - "loc": SourceLocation { - "end": Position { - "column": 45, - "index": 527, - "line": 16, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 23, - "index": 505, - "line": 16, - }, - }, - "properties": [ - Node { - "argument": Node { - "end": 514, - "loc": SourceLocation { - "end": Position { - "column": 32, - "index": 514, - "line": 16, - }, - "filename": undefined, - "identifierName": "task", - "start": Position { - "column": 28, - "index": 510, - "line": 16, - }, - }, - "name": "task", - "optional": false, - "start": 510, - "type": "Identifier", - "typeAnnotation": null, - }, - "end": 514, - "loc": SourceLocation { - "end": Position { - "column": 32, - "index": 514, - "line": 16, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 25, - "index": 507, - "line": 16, - }, - }, - "start": 507, - "type": "SpreadElement", - }, - Node { - "accessibility": null, - "computed": false, - "end": 525, - "extra": { - "shorthand": true, - }, - "key": Node { - "end": 525, - "loc": SourceLocation { - "end": Position { - "column": 43, - "index": 525, - "line": 16, - }, - "filename": undefined, - "identifierName": "completed", - "start": Position { - "column": 34, - "index": 516, - "line": 16, - }, - }, - "name": "completed", - "optional": false, - "start": 516, - "type": "Identifier", - "typeAnnotation": null, - }, - "loc": SourceLocation { - "end": Position { - "column": 43, - "index": 525, - "line": 16, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 34, - "index": 516, - "line": 16, - }, - }, - "method": false, - "shorthand": true, - "start": 516, - "type": "ObjectProperty", - "value": Node { - "end": 525, - "loc": SourceLocation { - "end": Position { - "column": 43, - "index": 525, - "line": 16, - }, - "filename": undefined, - "identifierName": "completed", - "start": Position { - "column": 34, - "index": 516, - "line": 16, - }, - }, - "name": "completed", - "optional": false, - "range": undefined, - "start": 516, - "type": "Identifier", - "typeAnnotation": null, - }, - }, - ], - "start": 505, - "type": "ObjectExpression", - }, - ], - "callee": Node { - "computed": false, - "end": 504, - "loc": SourceLocation { - "end": Position { - "column": 22, - "index": 504, - "line": 16, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 9, - "index": 491, - "line": 16, - }, - }, - "object": Node { - "end": 499, - "loc": SourceLocation { - "end": Position { - "column": 17, - "index": 499, - "line": 16, - }, - "filename": undefined, - "identifierName": "taskRepo", - "start": Position { - "column": 9, - "index": 491, - "line": 16, - }, - }, - "name": "taskRepo", - "optional": false, - "start": 491, - "type": "Identifier", - "typeAnnotation": null, - }, - "optional": false, - "property": Node { - "end": 504, - "loc": SourceLocation { - "end": Position { - "column": 22, - "index": 504, - "line": 16, - }, - "filename": undefined, - "identifierName": "save", - "start": Position { - "column": 18, - "index": 500, - "line": 16, - }, - }, - "name": "save", - "optional": false, - "start": 500, - "type": "Identifier", - "typeAnnotation": null, - }, - "start": 491, - "type": "MemberExpression", - }, - "end": 528, - "loc": SourceLocation { - "end": Position { - "column": 46, - "index": 528, - "line": 16, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 9, - "index": 491, - "line": 16, - }, - }, - "optional": false, - "start": 491, - "type": "CallExpression", - "typeArguments": null, - }, - "end": 528, - "loc": SourceLocation { - "end": Position { - "column": 46, - "index": 528, - "line": 16, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 3, - "index": 485, - "line": 16, - }, - }, - "start": 485, - "type": "AwaitExpression", - }, - "loc": SourceLocation { - "end": Position { - "column": 47, - "index": 529, - "line": 16, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 3, - "index": 485, - "line": 16, - }, - }, - "start": 485, - "type": "ExpressionStatement", - }, - ], - "directives": [], - "end": 533, - "loc": SourceLocation { - "end": Position { - "column": 3, - "index": 533, - "line": 17, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 44, - "index": 480, - "line": 15, - }, - }, - "start": 480, - "type": "BlockStatement", - }, - "end": 533, - "left": Node { - "declarations": [ - Node { - "end": 453, - "id": Node { - "end": 453, - "loc": SourceLocation { - "end": Position { - "column": 17, - "index": 453, - "line": 15, - }, - "filename": undefined, - "identifierName": "task", - "start": Position { - "column": 13, - "index": 449, - "line": 15, - }, - }, - "name": "task", - "optional": false, - "start": 449, - "type": "Identifier", - "typeAnnotation": null, - }, - "init": null, - "loc": SourceLocation { - "end": Position { - "column": 17, - "index": 453, - "line": 15, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 13, - "index": 449, - "line": 15, - }, - }, - "start": 449, - "type": "VariableDeclarator", - }, - ], - "end": 453, - "kind": "const", - "loc": SourceLocation { - "end": Position { - "column": 17, - "index": 453, - "line": 15, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 7, - "index": 443, - "line": 15, - }, - }, - "start": 443, - "type": "VariableDeclaration", - }, - "loc": SourceLocation { - "end": Position { - "column": 3, - "index": 533, - "line": 17, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 2, - "index": 438, - "line": 15, - }, - }, - "right": Node { - "all": false, - "argument": Node { - "arguments": [], - "callee": Node { - "computed": false, - "end": 476, - "loc": SourceLocation { - "end": Position { - "column": 40, - "index": 476, - "line": 15, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 27, - "index": 463, - "line": 15, - }, - }, - "object": Node { - "end": 471, - "loc": SourceLocation { - "end": Position { - "column": 35, - "index": 471, - "line": 15, - }, - "filename": undefined, - "identifierName": "taskRepo", - "start": Position { - "column": 27, - "index": 463, - "line": 15, - }, - }, - "name": "taskRepo", - "optional": false, - "start": 463, - "type": "Identifier", - "typeAnnotation": null, - }, - "optional": false, - "property": Node { - "end": 476, - "loc": SourceLocation { - "end": Position { - "column": 40, - "index": 476, - "line": 15, - }, - "filename": undefined, - "identifierName": "find", - "start": Position { - "column": 36, - "index": 472, - "line": 15, - }, - }, - "name": "find", - "optional": false, - "start": 472, - "type": "Identifier", - "typeAnnotation": null, - }, - "start": 463, - "type": "MemberExpression", - }, - "end": 478, - "loc": SourceLocation { - "end": Position { - "column": 42, - "index": 478, - "line": 15, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 27, - "index": 463, - "line": 15, - }, - }, - "optional": false, - "start": 463, - "type": "CallExpression", - "typeArguments": null, - }, - "end": 478, - "loc": SourceLocation { - "end": Position { - "column": 42, - "index": 478, - "line": 15, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 21, - "index": 457, - "line": 15, - }, - }, - "start": 457, - "type": "AwaitExpression", - }, - "start": 438, - "type": "ForOfStatement", - }, - ], - "directives": [], - "type": "BlockStatement", - }, - "test": { - "computed": false, - "object": { - "computed": false, - "object": { - "meta": { - "name": "import", - "optional": false, - "type": "Identifier", - "typeAnnotation": null, - }, - "property": { - "name": "meta", - "optional": false, - "type": "Identifier", - "typeAnnotation": null, - }, - "type": "MetaProperty", - }, - "optional": false, - "property": { - "name": "env", - "optional": false, - "type": "Identifier", - "typeAnnotation": null, - }, - "type": "MemberExpression", - }, - "optional": false, - "property": { - "name": "SSR", - "optional": false, - "type": "Identifier", - "typeAnnotation": null, - }, - "type": "MemberExpression", - }, - "type": "IfStatement", - }, - ], - "directives": [], - "end": 536, - "loc": SourceLocation { - "end": Position { - "column": 2, - "index": 536, - "line": 18, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 50, - "index": 352, - "line": 11, - }, - }, - "start": 352, - "type": "BlockStatement", - }, - "computed": false, - "decorators": [ - Node { - "end": 301, - "expression": Node { - "arguments": [ - Node { - "end": 300, - "loc": SourceLocation { - "end": Position { - "column": 48, - "index": 300, - "line": 10, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 16, - "index": 268, - "line": 10, - }, - }, - "properties": [ - Node { - "accessibility": null, - "computed": false, - "end": 298, - "key": Node { - "end": 277, - "loc": SourceLocation { - "end": Position { - "column": 25, - "index": 277, - "line": 10, - }, - "filename": undefined, - "identifierName": "allowed", - "start": Position { - "column": 18, - "index": 270, - "line": 10, - }, - }, - "name": "allowed", - "optional": false, - "start": 270, - "type": "Identifier", - "typeAnnotation": null, - }, - "loc": SourceLocation { - "end": Position { - "column": 46, - "index": 298, - "line": 10, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 18, - "index": 270, - "line": 10, - }, - }, - "method": false, - "shorthand": false, - "start": 270, - "type": "ObjectProperty", - "value": Node { - "computed": false, - "end": 298, - "loc": SourceLocation { - "end": Position { - "column": 46, - "index": 298, - "line": 10, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 27, - "index": 279, - "line": 10, - }, - }, - "object": Node { - "end": 284, - "loc": SourceLocation { - "end": Position { - "column": 32, - "index": 284, - "line": 10, - }, - "filename": undefined, - "identifierName": "Allow", - "start": Position { - "column": 27, - "index": 279, - "line": 10, - }, - }, - "name": "Allow", - "optional": false, - "start": 279, - "type": "Identifier", - "typeAnnotation": null, - }, - "optional": false, - "property": Node { - "end": 298, - "loc": SourceLocation { - "end": Position { - "column": 46, - "index": 298, - "line": 10, - }, - "filename": undefined, - "identifierName": "authenticated", - "start": Position { - "column": 33, - "index": 285, - "line": 10, - }, - }, - "name": "authenticated", - "optional": false, - "start": 285, - "type": "Identifier", - "typeAnnotation": null, - }, - "start": 279, - "type": "MemberExpression", - }, - }, - ], - "start": 268, - "type": "ObjectExpression", - }, - ], - "callee": Node { - "end": 267, - "loc": SourceLocation { - "end": Position { - "column": 15, - "index": 267, - "line": 10, - }, - "filename": undefined, - "identifierName": "BackendMethod", - "start": Position { - "column": 2, - "index": 254, - "line": 10, - }, - }, - "name": "BackendMethod", - "optional": false, - "start": 254, - "type": "Identifier", - "typeAnnotation": null, - }, - "end": 301, - "loc": SourceLocation { - "end": Position { - "column": 49, - "index": 301, - "line": 10, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 2, - "index": 254, - "line": 10, - }, - }, - "optional": false, - "start": 254, - "type": "CallExpression", - "typeArguments": null, - }, - "loc": SourceLocation { - "end": Position { - "column": 49, - "index": 301, - "line": 10, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 1, - "index": 253, - "line": 10, - }, - }, - "start": 253, - "type": "Decorator", - }, - ], - "defaults": [], - "definite": false, - "end": 536, - "expression": false, - "generator": false, - "id": null, - "key": Node { - "end": 331, - "loc": SourceLocation { - "end": Position { - "column": 29, - "index": 331, - "line": 11, - }, - "filename": undefined, - "identifierName": "setAllCompleted", - "start": Position { - "column": 14, - "index": 316, - "line": 11, - }, - }, - "name": "setAllCompleted", - "optional": false, - "start": 316, - "type": "Identifier", - "typeAnnotation": null, - }, - "kind": "method", - "loc": SourceLocation { - "end": Position { - "column": 2, - "index": 536, - "line": 18, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 1, - "index": 253, - "line": 10, - }, - }, - "optional": false, - "override": false, - "params": [ - Node { - "end": 350, - "loc": SourceLocation { - "end": Position { - "column": 48, - "index": 350, - "line": 11, - }, - "filename": undefined, - "identifierName": "completed", - "start": Position { - "column": 30, - "index": 332, - "line": 11, - }, - }, - "name": "completed", - "optional": false, - "start": 332, - "type": "Identifier", - "typeAnnotation": Node { - "end": 350, - "loc": SourceLocation { - "end": Position { - "column": 48, - "index": 350, - "line": 11, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 39, - "index": 341, - "line": 11, - }, - }, - "start": 341, - "type": "TSTypeAnnotation", - "typeAnnotation": Node { - "end": 350, - "loc": SourceLocation { - "end": Position { - "column": 48, - "index": 350, - "line": 11, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 41, - "index": 343, - "line": 11, - }, - }, - "start": 343, - "type": "TSBooleanKeyword", - }, - }, - }, - ], - "predicate": null, - "readonly": false, - "rest": null, - "returnType": null, - "start": 253, - "static": true, - "type": "ClassMethod", - "typeParameters": null, - }, - Node { - "abstract": false, - "access": null, - "accessibility": null, - "async": true, - "body": Node { - "body": [ - { - "alternate": null, - "consequent": { - "body": [ - Node { - "declarations": [ - Node { - "end": 711, - "id": Node { - "end": 691, - "loc": SourceLocation { - "end": Position { - "column": 16, - "index": 691, - "line": 24, - }, - "filename": undefined, - "identifierName": "taskRepo", - "start": Position { - "column": 8, - "index": 683, - "line": 24, - }, - }, - "name": "taskRepo", - "optional": false, - "start": 683, - "type": "Identifier", - "typeAnnotation": null, - }, - "init": Node { - "arguments": [ - Node { - "end": 710, - "loc": SourceLocation { - "end": Position { - "column": 35, - "index": 710, - "line": 24, - }, - "filename": undefined, - "identifierName": "Task", - "start": Position { - "column": 31, - "index": 706, - "line": 24, - }, - }, - "name": "Task", - "optional": false, - "start": 706, - "type": "Identifier", - "typeAnnotation": null, - }, - ], - "callee": Node { - "computed": false, - "end": 705, - "loc": SourceLocation { - "end": Position { - "column": 30, - "index": 705, - "line": 24, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 19, - "index": 694, - "line": 24, - }, - }, - "object": Node { - "end": 700, - "loc": SourceLocation { - "end": Position { - "column": 25, - "index": 700, - "line": 24, - }, - "filename": undefined, - "identifierName": "remult", - "start": Position { - "column": 19, - "index": 694, - "line": 24, - }, - }, - "name": "remult", - "optional": false, - "start": 694, - "type": "Identifier", - "typeAnnotation": null, - }, - "optional": false, - "property": Node { - "end": 705, - "loc": SourceLocation { - "end": Position { - "column": 30, - "index": 705, - "line": 24, - }, - "filename": undefined, - "identifierName": "repo", - "start": Position { - "column": 26, - "index": 701, - "line": 24, - }, - }, - "name": "repo", - "optional": false, - "start": 701, - "type": "Identifier", - "typeAnnotation": null, - }, - "start": 694, - "type": "MemberExpression", - }, - "end": 711, - "loc": SourceLocation { - "end": Position { - "column": 36, - "index": 711, - "line": 24, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 19, - "index": 694, - "line": 24, - }, - }, - "optional": false, - "start": 694, - "type": "CallExpression", - "typeArguments": null, - }, - "loc": SourceLocation { - "end": Position { - "column": 36, - "index": 711, - "line": 24, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 8, - "index": 683, - "line": 24, - }, - }, - "start": 683, - "type": "VariableDeclarator", - }, - ], - "end": 712, - "kind": "const", - "leadingComments": [ - { - "end": 673, - "loc": SourceLocation { - "end": Position { - "column": 45, - "index": 673, - "line": 22, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 2, - "index": 630, - "line": 22, - }, - }, - "start": 630, - "type": "CommentLine", - "value": " console.log("AUTH_SECRET", AUTH_SECRET);", - }, - ], - "loc": SourceLocation { - "end": Position { - "column": 37, - "index": 712, - "line": 24, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 2, - "index": 677, - "line": 24, - }, - }, - "start": 677, - "type": "VariableDeclaration", - }, - Node { - "await": false, - "body": Node { - "body": [ - Node { - "end": 806, - "expression": Node { - "all": false, - "argument": Node { - "arguments": [ - Node { - "end": 804, - "loc": SourceLocation { - "end": Position { - "column": 45, - "index": 804, - "line": 26, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 23, - "index": 782, - "line": 26, - }, - }, - "properties": [ - Node { - "argument": Node { - "end": 791, - "loc": SourceLocation { - "end": Position { - "column": 32, - "index": 791, - "line": 26, - }, - "filename": undefined, - "identifierName": "task", - "start": Position { - "column": 28, - "index": 787, - "line": 26, - }, - }, - "name": "task", - "optional": false, - "start": 787, - "type": "Identifier", - "typeAnnotation": null, - }, - "end": 791, - "loc": SourceLocation { - "end": Position { - "column": 32, - "index": 791, - "line": 26, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 25, - "index": 784, - "line": 26, - }, - }, - "start": 784, - "type": "SpreadElement", - }, - Node { - "accessibility": null, - "computed": false, - "end": 802, - "extra": { - "shorthand": true, - }, - "key": Node { - "end": 802, - "loc": SourceLocation { - "end": Position { - "column": 43, - "index": 802, - "line": 26, - }, - "filename": undefined, - "identifierName": "completed", - "start": Position { - "column": 34, - "index": 793, - "line": 26, - }, - }, - "name": "completed", - "optional": false, - "start": 793, - "type": "Identifier", - "typeAnnotation": null, - }, - "loc": SourceLocation { - "end": Position { - "column": 43, - "index": 802, - "line": 26, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 34, - "index": 793, - "line": 26, - }, - }, - "method": false, - "shorthand": true, - "start": 793, - "type": "ObjectProperty", - "value": Node { - "end": 802, - "loc": SourceLocation { - "end": Position { - "column": 43, - "index": 802, - "line": 26, - }, - "filename": undefined, - "identifierName": "completed", - "start": Position { - "column": 34, - "index": 793, - "line": 26, - }, - }, - "name": "completed", - "optional": false, - "range": undefined, - "start": 793, - "type": "Identifier", - "typeAnnotation": null, - }, - }, - ], - "start": 782, - "type": "ObjectExpression", - }, - ], - "callee": Node { - "computed": false, - "end": 781, - "loc": SourceLocation { - "end": Position { - "column": 22, - "index": 781, - "line": 26, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 9, - "index": 768, - "line": 26, - }, - }, - "object": Node { - "end": 776, - "loc": SourceLocation { - "end": Position { - "column": 17, - "index": 776, - "line": 26, - }, - "filename": undefined, - "identifierName": "taskRepo", - "start": Position { - "column": 9, - "index": 768, - "line": 26, - }, - }, - "name": "taskRepo", - "optional": false, - "start": 768, - "type": "Identifier", - "typeAnnotation": null, - }, - "optional": false, - "property": Node { - "end": 781, - "loc": SourceLocation { - "end": Position { - "column": 22, - "index": 781, - "line": 26, - }, - "filename": undefined, - "identifierName": "save", - "start": Position { - "column": 18, - "index": 777, - "line": 26, - }, - }, - "name": "save", - "optional": false, - "start": 777, - "type": "Identifier", - "typeAnnotation": null, - }, - "start": 768, - "type": "MemberExpression", - }, - "end": 805, - "loc": SourceLocation { - "end": Position { - "column": 46, - "index": 805, - "line": 26, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 9, - "index": 768, - "line": 26, - }, - }, - "optional": false, - "start": 768, - "type": "CallExpression", - "typeArguments": null, - }, - "end": 805, - "loc": SourceLocation { - "end": Position { - "column": 46, - "index": 805, - "line": 26, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 3, - "index": 762, - "line": 26, - }, - }, - "start": 762, - "type": "AwaitExpression", - }, - "loc": SourceLocation { - "end": Position { - "column": 47, - "index": 806, - "line": 26, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 3, - "index": 762, - "line": 26, - }, - }, - "start": 762, - "type": "ExpressionStatement", - }, - ], - "directives": [], - "end": 810, - "loc": SourceLocation { - "end": Position { - "column": 3, - "index": 810, - "line": 27, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 44, - "index": 757, - "line": 25, - }, - }, - "start": 757, - "type": "BlockStatement", - }, - "end": 810, - "left": Node { - "declarations": [ - Node { - "end": 730, - "id": Node { - "end": 730, - "loc": SourceLocation { - "end": Position { - "column": 17, - "index": 730, - "line": 25, - }, - "filename": undefined, - "identifierName": "task", - "start": Position { - "column": 13, - "index": 726, - "line": 25, - }, - }, - "name": "task", - "optional": false, - "start": 726, - "type": "Identifier", - "typeAnnotation": null, - }, - "init": null, - "loc": SourceLocation { - "end": Position { - "column": 17, - "index": 730, - "line": 25, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 13, - "index": 726, - "line": 25, - }, - }, - "start": 726, - "type": "VariableDeclarator", - }, - ], - "end": 730, - "kind": "const", - "loc": SourceLocation { - "end": Position { - "column": 17, - "index": 730, - "line": 25, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 7, - "index": 720, - "line": 25, - }, - }, - "start": 720, - "type": "VariableDeclaration", - }, - "loc": SourceLocation { - "end": Position { - "column": 3, - "index": 810, - "line": 27, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 2, - "index": 715, - "line": 25, - }, - }, - "right": Node { - "all": false, - "argument": Node { - "arguments": [], - "callee": Node { - "computed": false, - "end": 753, - "loc": SourceLocation { - "end": Position { - "column": 40, - "index": 753, - "line": 25, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 27, - "index": 740, - "line": 25, - }, - }, - "object": Node { - "end": 748, - "loc": SourceLocation { - "end": Position { - "column": 35, - "index": 748, - "line": 25, - }, - "filename": undefined, - "identifierName": "taskRepo", - "start": Position { - "column": 27, - "index": 740, - "line": 25, - }, - }, - "name": "taskRepo", - "optional": false, - "start": 740, - "type": "Identifier", - "typeAnnotation": null, - }, - "optional": false, - "property": Node { - "end": 753, - "loc": SourceLocation { - "end": Position { - "column": 40, - "index": 753, - "line": 25, - }, - "filename": undefined, - "identifierName": "find", - "start": Position { - "column": 36, - "index": 749, - "line": 25, - }, - }, - "name": "find", - "optional": false, - "start": 749, - "type": "Identifier", - "typeAnnotation": null, - }, - "start": 740, - "type": "MemberExpression", - }, - "end": 755, - "loc": SourceLocation { - "end": Position { - "column": 42, - "index": 755, - "line": 25, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 27, - "index": 740, - "line": 25, - }, - }, - "optional": false, - "start": 740, - "type": "CallExpression", - "typeArguments": null, - }, - "end": 755, - "loc": SourceLocation { - "end": Position { - "column": 42, - "index": 755, - "line": 25, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 21, - "index": 734, - "line": 25, - }, - }, - "start": 734, - "type": "AwaitExpression", - }, - "start": 715, - "type": "ForOfStatement", - }, - ], - "directives": [], - "type": "BlockStatement", - }, - "test": { - "computed": false, - "object": { - "computed": false, - "object": { - "meta": { - "name": "import", - "optional": false, - "type": "Identifier", - "typeAnnotation": null, - }, - "property": { - "name": "meta", - "optional": false, - "type": "Identifier", - "typeAnnotation": null, - }, - "type": "MetaProperty", - }, - "optional": false, - "property": { - "name": "env", - "optional": false, - "type": "Identifier", - "typeAnnotation": null, - }, - "type": "MemberExpression", - }, - "optional": false, - "property": { - "name": "SSR", - "optional": false, - "type": "Identifier", - "typeAnnotation": null, - }, - "type": "MemberExpression", - }, - "type": "IfStatement", - }, - ], - "directives": [], - "end": 813, - "loc": SourceLocation { - "end": Position { - "column": 2, - "index": 813, - "line": 28, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 38, - "index": 626, - "line": 21, - }, - }, - "start": 626, - "type": "BlockStatement", - }, - "computed": false, - "decorators": [ - Node { - "end": 587, - "expression": Node { - "arguments": [ - Node { - "end": 586, - "loc": SourceLocation { - "end": Position { - "column": 48, - "index": 586, - "line": 20, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 16, - "index": 554, - "line": 20, - }, - }, - "properties": [ - Node { - "accessibility": null, - "computed": false, - "end": 584, - "key": Node { - "end": 563, - "loc": SourceLocation { - "end": Position { - "column": 25, - "index": 563, - "line": 20, - }, - "filename": undefined, - "identifierName": "allowed", - "start": Position { - "column": 18, - "index": 556, - "line": 20, - }, - }, - "name": "allowed", - "optional": false, - "start": 556, - "type": "Identifier", - "typeAnnotation": null, - }, - "loc": SourceLocation { - "end": Position { - "column": 46, - "index": 584, - "line": 20, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 18, - "index": 556, - "line": 20, - }, - }, - "method": false, - "shorthand": false, - "start": 556, - "type": "ObjectProperty", - "value": Node { - "computed": false, - "end": 584, - "loc": SourceLocation { - "end": Position { - "column": 46, - "index": 584, - "line": 20, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 27, - "index": 565, - "line": 20, - }, - }, - "object": Node { - "end": 570, - "loc": SourceLocation { - "end": Position { - "column": 32, - "index": 570, - "line": 20, - }, - "filename": undefined, - "identifierName": "Allow", - "start": Position { - "column": 27, - "index": 565, - "line": 20, - }, - }, - "name": "Allow", - "optional": false, - "start": 565, - "type": "Identifier", - "typeAnnotation": null, - }, - "optional": false, - "property": Node { - "end": 584, - "loc": SourceLocation { - "end": Position { - "column": 46, - "index": 584, - "line": 20, - }, - "filename": undefined, - "identifierName": "authenticated", - "start": Position { - "column": 33, - "index": 571, - "line": 20, - }, - }, - "name": "authenticated", - "optional": false, - "start": 571, - "type": "Identifier", - "typeAnnotation": null, - }, - "start": 565, - "type": "MemberExpression", - }, - }, - ], - "start": 554, - "type": "ObjectExpression", - }, - ], - "callee": Node { - "end": 553, - "loc": SourceLocation { - "end": Position { - "column": 15, - "index": 553, - "line": 20, - }, - "filename": undefined, - "identifierName": "BackendMethod", - "start": Position { - "column": 2, - "index": 540, - "line": 20, - }, - }, - "name": "BackendMethod", - "optional": false, - "start": 540, - "type": "Identifier", - "typeAnnotation": null, - }, - "end": 587, - "loc": SourceLocation { - "end": Position { - "column": 49, - "index": 587, - "line": 20, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 2, - "index": 540, - "line": 20, - }, - }, - "optional": false, - "start": 540, - "type": "CallExpression", - "typeArguments": null, - }, - "loc": SourceLocation { - "end": Position { - "column": 49, - "index": 587, - "line": 20, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 1, - "index": 539, - "line": 20, - }, - }, - "start": 539, - "type": "Decorator", - }, - ], - "defaults": [], - "definite": false, - "end": 813, - "expression": false, - "generator": false, - "id": null, - "key": Node { - "end": 605, - "loc": SourceLocation { - "end": Position { - "column": 17, - "index": 605, - "line": 21, - }, - "filename": undefined, - "identifierName": "Yop", - "start": Position { - "column": 14, - "index": 602, - "line": 21, - }, - }, - "name": "Yop", - "optional": false, - "start": 602, - "type": "Identifier", - "typeAnnotation": null, - }, - "kind": "method", - "loc": SourceLocation { - "end": Position { - "column": 2, - "index": 813, - "line": 28, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 1, - "index": 539, - "line": 20, - }, - }, - "optional": false, - "override": false, - "params": [ - Node { - "end": 624, - "loc": SourceLocation { - "end": Position { - "column": 36, - "index": 624, - "line": 21, - }, - "filename": undefined, - "identifierName": "completed", - "start": Position { - "column": 18, - "index": 606, - "line": 21, - }, - }, - "name": "completed", - "optional": false, - "start": 606, - "type": "Identifier", - "typeAnnotation": Node { - "end": 624, - "loc": SourceLocation { - "end": Position { - "column": 36, - "index": 624, - "line": 21, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 27, - "index": 615, - "line": 21, - }, - }, - "start": 615, - "type": "TSTypeAnnotation", - "typeAnnotation": Node { - "end": 624, - "loc": SourceLocation { - "end": Position { - "column": 36, - "index": 624, - "line": 21, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 29, - "index": 617, - "line": 21, - }, - }, - "start": 617, - "type": "TSBooleanKeyword", - }, - }, - }, - ], - "predicate": null, - "readonly": false, - "rest": null, - "returnType": null, - "start": 539, - "static": true, - "type": "ClassMethod", - "typeParameters": null, - }, - ], - "end": 815, - "loc": SourceLocation { - "end": Position { - "column": 1, - "index": 815, - "line": 29, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 29, - "index": 167, - "line": 5, - }, - }, - "start": 167, - "type": "ClassBody", - }, - "end": 815, - "id": Node { - "end": 166, - "loc": SourceLocation { - "end": Position { - "column": 28, - "index": 166, - "line": 5, - }, - "filename": undefined, - "identifierName": "TasksController", - "start": Position { - "column": 13, - "index": 151, - "line": 5, - }, - }, - "name": "TasksController", - "optional": false, - "start": 151, - "type": "Identifier", - "typeAnnotation": null, - }, - "implements": [], - "loc": SourceLocation { - "end": Position { - "column": 1, - "index": 815, - "line": 29, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 7, - "index": 145, - "line": 5, - }, - }, - "start": 145, - "superClass": null, - "superTypeParameters": null, - "type": "ClassDeclaration", - "typeParameters": null, - }, - "end": 815, - "exportKind": "value", - "loc": SourceLocation { - "end": Position { - "column": 1, - "index": 815, - "line": 29, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 0, - "index": 138, - "line": 5, - }, - }, - "source": null, - "specifiers": [], - "start": 138, - "type": "ExportNamedDeclaration", - }, - ], - "directives": [], - "end": 817, - "extra": { - "topLevelAwait": false, - }, - "interpreter": null, - "loc": SourceLocation { - "end": Position { - "column": 1, - "index": 817, - "line": 30, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 0, - "index": 0, - "line": 1, - }, - }, - "sourceType": "module", - "start": 0, - "type": "Program", - }, - "start": 0, - "type": "File", - }, + "code": "import { Allow, BackendMethod, remult } from "remult"; + import { Task } from "./task"; + import { AUTH_SECRET } from "$env/static/private"; + + export class TasksController { + static async yop1(completed: boolean) { + const taskRepo = remult.repo(Task); + } + + @BackendMethod({ allowed: Allow.authenticated }) + static async setAllCompleted(completed: boolean) { + if (import.meta.env.SSR) { + console.log("AUTH_SECRET", AUTH_SECRET); + + const taskRepo = remult.repo(Task); + + for (const task of await taskRepo.find()) { + await taskRepo.save({ ...task, completed }); + } + } + } + + @BackendMethod({ allowed: Allow.authenticated }) + static async Yop(completed: boolean) { + if (import.meta.env.SSR) { + const taskRepo = remult.repo(Task); + + for (const task of await taskRepo.find()) { + await taskRepo.save({ ...task, completed }); + } + } + } + }", "info": [ "Wrapped with if(import.meta.env.SSR): ["TasksController","BackendMethod","setAllCompleted"]", "Wrapped with if(import.meta.env.SSR): ["TasksController","BackendMethod","Yop"]", @@ -3376,31 +212,29 @@ export class TasksController { const transformed = await transformStrip(code, [{ decorator: 'BackendMethod' }]) expect(toInfoCode(transformed)).toMatchInlineSnapshot(` - { - "code": "import { Allow, BackendMethod, remult } from "remult"; - import { Task } from "./task"; - import { AUTH_SECRET } from "$env/static/private"; + { + "code": "import { Allow, BackendMethod, remult } from "remult"; + import { Task } from "./task"; + import { AUTH_SECRET } from "$env/static/private"; - export class TasksController { - static async yop1(completed: boolean) { - const taskRepo = remult.repo(Task); - } - - static async setAllCompleted(completed: boolean) { - console.log("AUTH_SECRET", AUTH_SECRET); - const taskRepo = remult.repo(Task); - - for (const task of await taskRepo.find()) { - await taskRepo.save({ - ...task, - completed - }); - } - } - }", - "info": [], - } - `) + export class TasksController { + static async yop1(completed: boolean) { + const taskRepo = remult.repo(Task); + } + + static async setAllCompleted(completed: boolean) { + console.log("AUTH_SECRET", AUTH_SECRET); + + const taskRepo = remult.repo(Task); + + for (const task of await taskRepo.find()) { + await taskRepo.save({ ...task, completed }); + } + } + }", + "info": [], + } + `) }) it('should strip also unused methods', async () => { @@ -3410,7 +244,7 @@ export class TasksController { @Entity() export class Ent { - @Fields.uuid() + @Fields.id() id!: string; } @@ -3435,38 +269,39 @@ export class TasksController { const transformed = await transformStrip(code, [{ decorator: 'BackendMethod' }]) expect(toInfoCode(transformed)).toMatchInlineSnapshot(` - { - "code": "import { TOP_SECRET, TOP_SECRET_NOT_USED } from "$env/static/private"; - import { stry0 } from "@kitql/helper"; - import { BackendMethod, Entity, Fields, remult } from "remult"; - - @Entity() - export class Ent { - @Fields.uuid() - id!: string; - } + { + "code": "import { TOP_SECRET, TOP_SECRET_NOT_USED } from '$env/static/private'; + import { stry0 } from '@kitql/helper'; + import { BackendMethod, Entity, Fields, remult } from 'remult'; + + @Entity() + export class Ent { + @Fields.id() + id: string; + } - const getInfo = () => { - const client = {}; - console.log(TOP_SECRET); - return client; - }; - - export class EntController { - @BackendMethod({ - allowed: false - }) - static async init(hello: string) { - if (import.meta.env.SSR) { - const client = getInfo(); - } - } - }", - "info": [ - "Wrapped with if(import.meta.env.SSR): ["EntController","BackendMethod","init"]", - ], - } - `) + const getInfo = () => { + const client = {}; + + console.log(TOP_SECRET); + + return client; + }; + + export class EntController { + @BackendMethod({ allowed: false }) + static async init(hello: string// Do a lot of things here + ) { + if (import.meta.env.SSR) { + const client = getInfo(); + } + } + }", + "info": [ + "Wrapped with if(import.meta.env.SSR): ["EntController","BackendMethod","init"]", + ], + } + `) }) it('should strip just the right things', async () => { @@ -3476,7 +311,7 @@ export class TasksController { allowApiCrud: Allow.authenticated, }) export class User2 { - @Fields.uuid() + @Fields.id() id = '' @Fields.string({ @@ -3494,35 +329,29 @@ export class TasksController { const transformed = await transformStrip(code, [{ decorator: 'BackendMethod' }]) expect(toInfoCode(transformed)).toMatchInlineSnapshot(` - { - "code": "import { Allow, BackendMethod, Entity, Fields, Validators } from "remult"; - - @Entity("userstest", { - allowApiCrud: Allow.authenticated - }) - export class User2 { - @Fields.uuid() - id = ""; - - @Fields.string({ - validate: [Validators.required, Validators.uniqueOnBackend] - }) - email = ""; - - @BackendMethod({ - allowed: Allow.everyone - }) - async testMethod() { - if (import.meta.env.SSR) { - console.log("hello"); - } - } - }", - "info": [ - "Wrapped with if(import.meta.env.SSR): ["User2","BackendMethod","testMethod"]", - ], - } - `) + { + "code": "import { Allow, BackendMethod, Entity, Fields, Validators } from 'remult'; + + @Entity('userstest', { allowApiCrud: Allow.authenticated }) + export class User2 { + @Fields.id() + id = ''; + + @Fields.string({ validate: [Validators.required, Validators.uniqueOnBackend] }) + email = ''; + + @BackendMethod({ allowed: Allow.everyone }) + async testMethod() { + if (import.meta.env.SSR) { + console.log('hello'); + } + } + }", + "info": [ + "Wrapped with if(import.meta.env.SSR): ["User2","BackendMethod","testMethod"]", + ], + } + `) }) it('should strip unused stuff when decorator', async () => { @@ -3532,7 +361,7 @@ export class TasksController { allowApiCrud: Allow.authenticated, }) export class User2 { - @Fields.uuid() + @Fields.id() id = '' @Fields.string({}) @@ -3548,33 +377,29 @@ export class TasksController { const transformed = await transformStrip(code, [{ decorator: 'BackendMethod' }]) expect(toInfoCode(transformed)).toMatchInlineSnapshot(` - { - "code": "import { Allow, BackendMethod, Entity, Fields, Validators } from "remult"; - - @Entity("userstest", { - allowApiCrud: Allow.authenticated - }) - export class User2 { - @Fields.uuid() - id = ""; - - @Fields.string({}) - email = ""; - - @BackendMethod({ - allowed: Allow.everyone - }) - async testMethod() { - if (import.meta.env.SSR) { - console.log("hello"); - } - } - }", - "info": [ - "Wrapped with if(import.meta.env.SSR): ["User2","BackendMethod","testMethod"]", - ], - } - `) + { + "code": "import { Allow, BackendMethod, Entity, Fields, Validators } from 'remult'; + + @Entity('userstest', { allowApiCrud: Allow.authenticated }) + export class User2 { + @Fields.id() + id = ''; + + @Fields.string({}) + email = ''; + + @BackendMethod({ allowed: Allow.everyone }) + async testMethod() { + if (import.meta.env.SSR) { + console.log('hello'); + } + } + }", + "info": [ + "Wrapped with if(import.meta.env.SSR): ["User2","BackendMethod","testMethod"]", + ], + } + `) }) it('should strip imports that are in the BackendMethod', async () => { @@ -3584,7 +409,7 @@ export class TasksController { allowApiCrud: Allow.authenticated, }) export class User2 { - @Fields.uuid() + @Fields.id() id = '' @Fields.string({}) @@ -3600,33 +425,29 @@ export class TasksController { const transformed = await transformStrip(code, [{ decorator: 'BackendMethod' }]) expect(toInfoCode(transformed)).toMatchInlineSnapshot(` - { - "code": "import { Allow, BackendMethod, Entity, Fields, Validators } from "remult"; - - @Entity("userstest", { - allowApiCrud: Allow.authenticated - }) - export class User2 { - @Fields.uuid() - id = ""; - - @Fields.string({}) - email = ""; - - @BackendMethod({ - allowed: Allow.everyone - }) - async testMethod() { - if (import.meta.env.SSR) { - console.log("hello", Validators.required); - } - } - }", - "info": [ - "Wrapped with if(import.meta.env.SSR): ["User2","BackendMethod","testMethod"]", - ], - } - `) + { + "code": "import { Allow, BackendMethod, Entity, Fields, Validators } from 'remult'; + + @Entity('userstest', { allowApiCrud: Allow.authenticated }) + export class User2 { + @Fields.id() + id = ''; + + @Fields.string({}) + email = ''; + + @BackendMethod({ allowed: Allow.everyone }) + async testMethod() { + if (import.meta.env.SSR) { + console.log('hello', Validators.required); + } + } + }", + "info": [ + "Wrapped with if(import.meta.env.SSR): ["User2","BackendMethod","testMethod"]", + ], + } + `) }) it('should NOT strip imports that are in both in BackendMethod and not in', async () => { @@ -3636,7 +457,7 @@ export class TasksController { allowApiCrud: Allow.authenticated, }) export class User2 { - @Fields.uuid() + @Fields.id() id = '' @Fields.string({ @@ -3654,35 +475,29 @@ export class TasksController { const transformed = await transformStrip(code, [{ decorator: 'BackendMethod' }]) expect(toInfoCode(transformed)).toMatchInlineSnapshot(` - { - "code": "import { Allow, BackendMethod, Entity, Fields, Validators } from "remult"; - - @Entity("userstest", { - allowApiCrud: Allow.authenticated - }) - export class User2 { - @Fields.uuid() - id = ""; - - @Fields.string({ - validate: [Validators.required, Validators.uniqueOnBackend] - }) - email = ""; - - @BackendMethod({ - allowed: Allow.everyone - }) - async testMethod() { - if (import.meta.env.SSR) { - console.log("hello", Validators.required); - } - } - }", - "info": [ - "Wrapped with if(import.meta.env.SSR): ["User2","BackendMethod","testMethod"]", - ], - } - `) + { + "code": "import { Allow, BackendMethod, Entity, Fields, Validators } from 'remult'; + + @Entity('userstest', { allowApiCrud: Allow.authenticated }) + export class User2 { + @Fields.id() + id = ''; + + @Fields.string({ validate: [Validators.required, Validators.uniqueOnBackend] }) + email = ''; + + @BackendMethod({ allowed: Allow.everyone }) + async testMethod() { + if (import.meta.env.SSR) { + console.log('hello', Validators.required); + } + } + }", + "info": [ + "Wrapped with if(import.meta.env.SSR): ["User2","BackendMethod","testMethod"]", + ], + } + `) }) it('should strip import types', async () => { @@ -3705,26 +520,28 @@ export class TasksController { const transformed = await transformStrip(code, [{ decorator: 'BackendMethod' }]) expect(toInfoCode(transformed)).toMatchInlineSnapshot(` - { - "code": "import { AUTH_SECRET } from "$env/static/private"; - import { BackendMethod, type Allowed, remult } from "remult"; - - export class ActionsController { - @BackendMethod({ - allowed: () => remult.user === undefined - }) - static async read(info: Allowed) { - if (import.meta.env.SSR) { - console.log("AUTH_SECRET", AUTH_SECRET); - return AUTH_SECRET + " " + info; - } - } - }", - "info": [ - "Wrapped with if(import.meta.env.SSR): ["ActionsController","BackendMethod","read"]", - ], - } - `) + { + "code": "import { AUTH_SECRET } from '$env/static/private'; + import { BackendMethod, type Allowed, remult } from 'remult'; + + export class ActionsController { + @BackendMethod({ + // Only unauthenticated users can call this method + allowed: () => remult.user === undefined + }) + static async read(info: Allowed) { + if (import.meta.env.SSR) { + console.log('AUTH_SECRET', AUTH_SECRET); + + return AUTH_SECRET + ' ' + info; + } + } + }", + "info": [ + "Wrapped with if(import.meta.env.SSR): ["ActionsController","BackendMethod","read"]", + ], + } + `) }) }) @@ -3740,7 +557,7 @@ import { BackendMethod, Entity, Fields, remult, type Allowed } from "remult"; } }) export class User { - @Fields.uuid() + @Fields.id() id = '' @Fields.string() @@ -3763,42 +580,46 @@ export class User { { decorator: 'Entity', args_1: [{ fn: 'backendPrefilter' }] }, ]) expect(toInfoCode(transformed)).toMatchInlineSnapshot(` - { - "code": "let AUTH_SECRET = null; - let AUTH_SECRET_NOT_USED = null; - import { BackendMethod, Entity, Fields, remult, type Allowed } from "remult"; - - @Entity("users", { - backendPrefilter: async () => { - if (import.meta.env.SSR) { - console.log("backendPrefilter"); - return {}; - } - } - }) - export class User { - @Fields.uuid() - id = ""; - - @Fields.string() - name = ""; - - @BackendMethod({ - allowed: () => remult.user === undefined - }) - static async hi(info: Allowed) { - if (import.meta.env.SSR) { - console.info("AUTH_SECRET", AUTH_SECRET); - return AUTH_SECRET + " " + info; - } - } - }", - "info": [ - "Wrapped with if(import.meta.env.SSR): ["User","Entity","backendPrefilter"]", - "Wrapped with if(import.meta.env.SSR): ["User","BackendMethod","hi"]", - ], - } - `) + { + "code": "let AUTH_SECRET = null; + let AUTH_SECRET_NOT_USED = null; + + import { BackendMethod, Entity, Fields, remult, type Allowed } from "remult"; + + @Entity('users', { + backendPrefilter: async () => { + if (import.meta.env.SSR) { + console.log('backendPrefilter'); + + return {}; + } + } + }) + export class User { + @Fields.id() + id = ''; + + @Fields.string() + name = ''; + + @BackendMethod({ + // Only unauthenticated users can call this method + allowed: () => remult.user === undefined + }) + static async hi(info: Allowed) { + if (import.meta.env.SSR) { + console.info('AUTH_SECRET', AUTH_SECRET); + + return AUTH_SECRET + ' ' + info; + } + } + }", + "info": [ + "Wrapped with if(import.meta.env.SSR): ["User","Entity","backendPrefilter"]", + "Wrapped with if(import.meta.env.SSR): ["User","BackendMethod","hi"]", + ], + } + `) }) it('should strip @BackendMethod in @Entity with excludeEntityKeys', async () => { @@ -3812,7 +633,7 @@ import { BackendMethod, Entity, Fields, remult, type Allowed } from "remult"; } }) export class User { - @Fields.uuid() + @Fields.id() id = '' @Fields.string() @@ -3843,38 +664,42 @@ export class User { }, ]) expect(toInfoCode(transformed)).toMatchInlineSnapshot(` - { - "code": "let AUTH_SECRET = null; - let AUTH_SECRET_NOT_USED = null; - import { BackendMethod, Entity, Fields, remult, type Allowed } from "remult"; - - @Entity("users", { - backendPrefilter: () => { - console.log("backendPrefilter"); - return {}; - } - }) - export class User { - @Fields.uuid() - id = ""; - - @Fields.string() - name = ""; - - @BackendMethod({ - allowed: () => remult.user === undefined - }) - static async hi(info: Allowed) { - if (import.meta.env.SSR) { - console.info("AUTH_SECRET", AUTH_SECRET); - return AUTH_SECRET + " " + info; - } - } - }", - "info": [ - "Wrapped with if(import.meta.env.SSR): ["User","BackendMethod","hi"]", - ], - } - `) + { + "code": "let AUTH_SECRET = null; + let AUTH_SECRET_NOT_USED = null; + + import { BackendMethod, Entity, Fields, remult, type Allowed } from "remult"; + + @Entity('users', { + backendPrefilter: () => { + console.log('backendPrefilter'); + + return {}; + } + }) + export class User { + @Fields.id() + id = ''; + + @Fields.string() + name = ''; + + @BackendMethod({ + // Only unauthenticated users can call this method + allowed: () => remult.user === undefined + }) + static async hi(info: Allowed) { + if (import.meta.env.SSR) { + console.info('AUTH_SECRET', AUTH_SECRET); + + return AUTH_SECRET + ' ' + info; + } + } + }", + "info": [ + "Wrapped with if(import.meta.env.SSR): ["User","BackendMethod","hi"]", + ], + } + `) }) }) diff --git a/packages/vite-plugin-stripper/src/lib/transformStrip.ts b/packages/vite-plugin-stripper/src/lib/transformStrip.ts index cde74363..37fa3f0c 100644 --- a/packages/vite-plugin-stripper/src/lib/transformStrip.ts +++ b/packages/vite-plugin-stripper/src/lib/transformStrip.ts @@ -1,4 +1,4 @@ -import { parse, visit, type ParseResult } from '@kitql/internals' +import { parse, walk, type KitQLParseResult, type ParseOptions } from '@kitql/internals' // Define the type for the decorator config export type StripConfig = { @@ -7,11 +7,15 @@ export type StripConfig = { } export const transformStrip = async ( - code_ast: string | ParseResult, + code_ast: string | KitQLParseResult, decorators_config: StripConfig[], + opts?: ParseOptions, ) => { try { - const ast = parse(code_ast) + const ast = parse(code_ast, opts) + if (ast.errors.length > 0) { + return { code_ast, ast: null, info: [] } + } let currentClassName = '' // Variable to hold the current class name const decorators_wrapped: { decorator: string; functionName: string; className: string }[] = [] @@ -19,222 +23,231 @@ export const transformStrip = async ( const entityNameMap = new Map() // Map class names to their entity names // First pass: identify classes with special decorators and filters - visit(ast, { - visitClassDeclaration(path: any) { - // @ts-ignore - const className = path.node.id.name - // @ts-ignore - const decorators: any[] = path.node.decorators || [] - - decorators.forEach((decorator) => { - if (!decorator.expression.callee) return - - const decoratorName = decorator.expression.callee.name - // Find matching config for this decorator - const config = decorators_config.find((c) => c.decorator === decoratorName) - - // If this is an Entity-like decorator, store the entity name - if (config && decorator.expression.arguments && decorator.expression.arguments.length >= 1) { - const entityNameArg = decorator.expression.arguments[0] - if (entityNameArg && entityNameArg.value) { - entityNameMap.set(className, entityNameArg.value) + walk(ast.program, { + enter(node) { + if (node.type === 'ClassDeclaration') { + const className = node.id?.name || '' + const decorators: any[] = node.decorators || [] + + decorators.forEach((decorator) => { + if (!decorator.expression.callee) return + + const decoratorName = decorator.expression.callee.name + // Find matching config for this decorator + const config = decorators_config.find((c) => c.decorator === decoratorName) + + // If this is an Entity-like decorator, store the entity name + if (config && decorator.expression.arguments && decorator.expression.arguments.length >= 1) { + const entityNameArg = decorator.expression.arguments[0] + if (entityNameArg && entityNameArg.value) { + entityNameMap.set(className, entityNameArg.value) + } } - } - - if ( - config && - config.args_1 && - decorator.expression.arguments && - decorator.expression.arguments.length >= 2 - ) { - // Check if the second argument (options) has any of the specified function names - const options = decorator.expression.arguments[1] - if (options && options.properties) { - const hasSpecialFilter = options.properties.some((prop: any) => - config.args_1?.some((c) => c.fn === prop.key.name), - ) - if (hasSpecialFilter) { - entityClassesWithSpecialFilters.push(className) - - // Wrap these special functions in if(import.meta.env.SSR) - options.properties.forEach((prop: any) => { - if (config.args_1?.some((c) => c.fn === prop.key.name)) { - if (prop.value && prop.value.body && prop.value.body.body) { - const originalBody = prop.value.body.body - - // Find the matching config entry - const matchingConfig = config.args_1?.find((c) => c.fn === prop.key.name) - - // Get the entity name for this class - const entityName = entityNameMap.get(className) - - // Check if we need to exclude this entity based on entity name - const shouldExclude = - (entityName && matchingConfig?.excludeEntityKeys?.includes(entityName)) || false - - // Only wrap if not excluded - if (!shouldExclude) { - // Create the if statement wrapping the original body - prop.value.body.body = [ - { - type: 'IfStatement', - test: { - type: 'MemberExpression', - object: { + if ( + config && + config.args_1 && + decorator.expression.arguments && + decorator.expression.arguments.length >= 2 + ) { + // Check if the second argument (options) has any of the specified function names + const options = decorator.expression.arguments[1] + if (options && options.properties) { + const hasSpecialFilter = options.properties.some((prop: any) => + config.args_1?.some((c) => c.fn === prop.key.name), + ) + + if (hasSpecialFilter) { + entityClassesWithSpecialFilters.push(className) + + // Wrap these special functions in if(import.meta.env.SSR) + options.properties.forEach((prop: any) => { + if (config.args_1?.some((c) => c.fn === prop.key.name)) { + if (prop.value && prop.value.body && prop.value.body.body) { + const originalBody = prop.value.body.body + + // Find the matching config entry + const matchingConfig = config.args_1?.find((c) => c.fn === prop.key.name) + + // Get the entity name for this class + const entityName = entityNameMap.get(className) + + // Check if we need to exclude this entity based on entity name + const shouldExclude = + (entityName && matchingConfig?.excludeEntityKeys?.includes(entityName)) || false + + // Only wrap if not excluded + if (!shouldExclude) { + // Create the if statement wrapping the original body + prop.value.body.body = [ + { + type: 'IfStatement', + test: { type: 'MemberExpression', object: { - type: 'MetaProperty', - meta: { type: 'Identifier', name: 'import' }, - property: { type: 'Identifier', name: 'meta' }, + type: 'MemberExpression', + object: { + type: 'MetaProperty', + meta: { type: 'Identifier', name: 'import', start: 0, end: 0 }, + property: { type: 'Identifier', name: 'meta', start: 0, end: 0 }, + start: 0, + end: 0, + }, + property: { type: 'Identifier', name: 'env', start: 0, end: 0 }, + start: 0, + end: 0, }, - property: { type: 'Identifier', name: 'env' }, - }, - property: { type: 'Identifier', name: 'SSR' }, - }, - consequent: { - type: 'BlockStatement', - body: originalBody, + property: { type: 'Identifier', name: 'SSR', start: 0, end: 0 }, + start: 0, + end: 0, + } as any, + consequent: { + type: 'BlockStatement', + body: originalBody, + start: 0, + end: 0, + } as any, + alternate: null, + start: 0, + end: 0, }, - alternate: null, - }, - ] - - // Record that we wrapped this function - decorators_wrapped.push({ - className, - decorator: decoratorName, - functionName: prop.key.name, - }) + ] + + // Record that we wrapped this function + decorators_wrapped.push({ + className, + decorator: decoratorName, + functionName: prop.key.name, + }) + } } } - } - }) + }) + } } } - } - }) - - this.traverse(path) + }) + } }, }) // Second pass: wrap functions with decorators in if(import.meta.env.SSR) condition - visit(ast, { - visitClassDeclaration(path: any) { - // @ts-ignore - currentClassName = path.node.id.name - this.traverse(path) - }, - visitFunction(path: any) { - // @ts-ignore - const decorators: any[] = path.node.decorators || [] - let foundDecorator = false - // let decoratorName = '' - - // Initialize functionName with a default value - let functionName = '???' - - // Check if the function is a standalone function or a method in a class - if (path.node.id && path.node.id.name) { - // Standalone function - functionName = typeof path.node.id.name === 'string' ? path.node.id.name : 'IdentifierKind' - // @ts-ignore - } else if (path.node.key && path.node.key.name) { - // @ts-ignore - functionName = path.node.key.name + walk(ast.program, { + enter(node) { + if (node.type === 'ClassDeclaration') { + currentClassName = node.id?.name || '' } + if (node.type === 'MethodDefinition') { + const decorators: any[] = node.decorators || [] + let foundDecorator = false - // Check if any of the decorators match our list - decorators.forEach((decorator) => { - if (decorator.expression.callee) { - const name = decorator.expression.callee.name - const matchingConfig = decorators_config.find((c) => c.decorator === name) + // Initialize functionName with a default value + let functionName = '???' - if (matchingConfig) { - foundDecorator = true - // decoratorName = name + // Check if the method has a name + if (node.key && node.key.type === 'Identifier') { + functionName = node.key.name + } - // Push both the decorator name and the associated function name - decorators_wrapped.push({ - className: currentClassName, - decorator: name, - functionName, - }) + // Check if any of the decorators match our list + decorators.forEach((decorator) => { + if (decorator.expression.callee) { + const name = decorator.expression.callee.name + const matchingConfig = decorators_config.find((c) => c.decorator === name) + + if (matchingConfig) { + foundDecorator = true + + // Push both the decorator name and the associated function name + decorators_wrapped.push({ + className: currentClassName, + decorator: name, + functionName, + }) + } } - } - }) - - // Check if this function is in a class with special filters and has a special name - const isInEntityClass = entityClassesWithSpecialFilters.includes(currentClassName) - const isSpecialFunction = - functionName && - decorators_config.some((config) => config.args_1?.some((c) => functionName.startsWith(c.fn))) - - // Get the entity name for this class - const entityName = entityNameMap.get(currentClassName) - - // Check if this entity should be excluded - const shouldExclude = - entityName && - decorators_config.some((config) => - config.args_1?.some( - (c) => functionName.startsWith(c.fn) && c.excludeEntityKeys?.includes(entityName), - ), - ) - - // If one of the decorators was found OR it's a special function in a tracked class, wrap the function body in if(import.meta.env.SSR) - if ( - (foundDecorator || (isInEntityClass && isSpecialFunction && !shouldExclude)) && - path.node.body && - path.node.body.body - ) { - const originalBody = path.node.body.body - - // Create the if statement wrapping the original body - path.node.body.body = [ - { - type: 'IfStatement', - test: { - type: 'MemberExpression', - object: { + }) + + // Check if this function is in a class with special filters and has a special name + const isInEntityClass = entityClassesWithSpecialFilters.includes(currentClassName) + const isSpecialFunction = + functionName && + decorators_config.some((config) => config.args_1?.some((c) => functionName.startsWith(c.fn))) + + // Get the entity name for this class + const entityName = entityNameMap.get(currentClassName) + + // Check if this entity should be excluded + const shouldExclude = + entityName && + decorators_config.some((config) => + config.args_1?.some( + (c) => functionName.startsWith(c.fn) && c.excludeEntityKeys?.includes(entityName), + ), + ) + + // If one of the decorators was found OR it's a special function in a tracked class, wrap the function body in if(import.meta.env.SSR) + if ( + (foundDecorator || (isInEntityClass && isSpecialFunction && !shouldExclude)) && + node.value && + node.value.body && + node.value.body.body + ) { + const originalBody = node.value.body.body + + // Create the if statement wrapping the original body + node.value.body.body = [ + { + type: 'IfStatement', + test: { type: 'MemberExpression', object: { - type: 'MetaProperty', - meta: { type: 'Identifier', name: 'import' }, - property: { type: 'Identifier', name: 'meta' }, + type: 'MemberExpression', + object: { + type: 'MetaProperty', + meta: { type: 'Identifier', name: 'import', start: 0, end: 0 }, + property: { type: 'Identifier', name: 'meta', start: 0, end: 0 }, + start: 0, + end: 0, + }, + property: { type: 'Identifier', name: 'env', start: 0, end: 0 }, + start: 0, + end: 0, }, - property: { type: 'Identifier', name: 'env' }, - }, - property: { type: 'Identifier', name: 'SSR' }, - }, - consequent: { - type: 'BlockStatement', - body: originalBody, + property: { type: 'Identifier', name: 'SSR', start: 0, end: 0 }, + start: 0, + end: 0, + } as any, + consequent: { + type: 'BlockStatement', + body: originalBody, + start: 0, + end: 0, + } as any, + alternate: null, + start: 0, + end: 0, }, - alternate: null, - }, - ] - - // If it's a special function but not already recorded, add it to the list - if (isInEntityClass && isSpecialFunction && !foundDecorator) { - // Find the decorator config that has this special function - const matchingConfig = decorators_config.find((config) => - config.args_1?.some((c) => functionName.startsWith(c.fn)), - ) + ] + + // If it's a special function but not already recorded, add it to the list + if (isInEntityClass && isSpecialFunction && !foundDecorator) { + // Find the decorator config that has this special function + const matchingConfig = decorators_config.find((config) => + config.args_1?.some((c) => functionName.startsWith(c.fn)), + ) - // Use the decorator name from the config instead of hardcoding "Entity" - const decoratorNameFromConfig = matchingConfig ? matchingConfig.decorator : 'Unknown' + // Use the decorator name from the config instead of hardcoding "Entity" + const decoratorNameFromConfig = matchingConfig ? matchingConfig.decorator : 'Unknown' - decorators_wrapped.push({ - className: currentClassName, - decorator: decoratorNameFromConfig, - functionName, - }) + decorators_wrapped.push({ + className: currentClassName, + decorator: decoratorNameFromConfig, + functionName, + }) + } } } - - this.traverse(path) }, }) @@ -243,10 +256,14 @@ export const transformStrip = async ( `Wrapped with if(import.meta.env.SSR): ${JSON.stringify(Object.values(decorator))}`, ) - return { code_ast: ast, info } + return { + code_ast: ast, + ast, + info, + } } catch (error) { // if anything happens, just return the original code console.error('Error in transformDecorator:', error) - return { code_ast, info: [] } } + return { code_ast, ast: null, info: [] } } diff --git a/packages/vite-plugin-stripper/src/lib/transformWarningThrow.spec.ts b/packages/vite-plugin-stripper/src/lib/transformWarningThrow.spec.ts deleted file mode 100644 index 7d0558a6..00000000 --- a/packages/vite-plugin-stripper/src/lib/transformWarningThrow.spec.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { describe, expect, it } from 'vitest' - -import { transformWarningThrow } from './transformWarningThrow.js' - -describe('warning on throw is not a class', () => { - it('should not warn', async () => { - const code = `import type { RequestHandler } from './$types' - - export const GET: RequestHandler = async () => { - throw new Error('Not implemented') - return new Response() - }` - - const transformed = await transformWarningThrow('myfile', '', code, true) - - expect(transformed).toMatchInlineSnapshot(` - { - "list": [], - } - `) - }) - - it('should warn', async () => { - const code = `import type { RequestHandler } from './$types' - - export const GET: RequestHandler = async () => { - throw 7 - return new Response() - } - ` - - const transformed = await transformWarningThrow('myfile', '', code, true) - - expect(transformed).toMatchInlineSnapshot(` - { - "list": [ - { - "line": 4, - "pathFile": "myfile", - "relativePathFile": "myfile", - }, - ], - } - `) - }) -}) diff --git a/packages/vite-plugin-stripper/src/lib/transformWarningThrow.ts b/packages/vite-plugin-stripper/src/lib/transformWarningThrow.ts deleted file mode 100644 index e5a63982..00000000 --- a/packages/vite-plugin-stripper/src/lib/transformWarningThrow.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { parse, visit } from '@kitql/internals' - -export type WarningThrow = { - relativePathFile: string - pathFile: string - line: number -} - -export const transformWarningThrow = async ( - pathFile: string, - prjPath: string, - code: string, - log_on_throw_is_not_a_new_class: boolean, -) => { - try { - const codeParsed = parse(code) - - const list: WarningThrow[] = [] - - visit(codeParsed, { - visitFunction(path: any) { - // Existing code for processing functions... - this.traverse(path) - }, - visitThrowStatement(path: any) { - if (log_on_throw_is_not_a_new_class) { - const thrownExpr = path.node.argument - // Check if thrownExpr is not a class - if (thrownExpr && thrownExpr.type !== 'NewExpression') { - list.push({ - relativePathFile: pathFile.replace(prjPath, ''), - pathFile, - line: path.node.loc?.start.line ?? 0, - }) - } - } - this.traverse(path) - }, - }) - - return { list } - } catch (error) { - // if anything happens, just return the original code - return { list: [] } - } -} diff --git a/packages/vite-plugin-stripper/src/shared/User.ts b/packages/vite-plugin-stripper/src/shared/User.ts index fc9c092f..1dc7ca3e 100644 --- a/packages/vite-plugin-stripper/src/shared/User.ts +++ b/packages/vite-plugin-stripper/src/shared/User.ts @@ -21,7 +21,7 @@ import { AUTH_SECRET } from '$env/static/private' }, }) export class User { - @Fields.uuid() + @Fields.id() id = '' @Fields.string() diff --git a/packages/vite-plugin-stripper/vite.config.ts b/packages/vite-plugin-stripper/vite.config.ts index dd5e7406..6acf3ca5 100644 --- a/packages/vite-plugin-stripper/vite.config.ts +++ b/packages/vite-plugin-stripper/vite.config.ts @@ -21,7 +21,6 @@ export default defineConfig(() => ({ plugins: [ stripper({ debug: true, - log_on_throw_is_not_a_new_class: true, // decorators: ['BackendMethod'], // hard: true, nullify: ['$env/static/private', 'oslo/password'], diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4d975601..2872762a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -176,27 +176,24 @@ catalogs: specifier: 3.2.4 version: 3.2.4 tooling: - '@babel/parser': - specifier: 7.28.4 - version: 7.28.4 - '@babel/types': - specifier: 7.28.4 - version: 7.28.4 commander: specifier: 14.0.0 version: 14.0.0 esbuild: specifier: 0.25.0 version: 0.25.0 + esrap: + specifier: https://pkg.pr.new/sveltejs/esrap@87 + version: 2.1.2 ora: specifier: 9.0.0 version: 9.0.0 - recast: - specifier: ^0.23.4 - version: 0.23.4 - rimraf: - specifier: 6.0.1 - version: 6.0.1 + oxc-parser: + specifier: 0.95.0 + version: 0.95.0 + oxc-walker: + specifier: 0.5.2 + version: 0.5.2 tsx: specifier: 4.20.3 version: 4.20.3 @@ -238,9 +235,6 @@ importers: prettier: specifier: catalog:formatting version: 3.6.1 - rimraf: - specifier: catalog:tooling - version: 6.0.1 vitest: specifier: catalog:testing version: 3.2.4(@types/debug@4.1.12)(@types/node@22.13.9)(@vitest/ui@3.2.4)(jiti@1.21.7)(jsdom@27.0.0(postcss@8.5.6))(lightningcss@1.28.2)(sass@1.85.1)(terser@5.37.0)(tsx@4.20.3)(yaml@2.8.1) @@ -388,7 +382,7 @@ importers: version: 5.43.6 svelte-check: specifier: catalog:svelte - version: 4.3.0(picomatch@4.0.2)(svelte@5.43.6)(typescript@5.9.2) + version: 4.3.0(picomatch@4.0.3)(svelte@5.43.6)(typescript@5.9.2) tslib: specifier: catalog:lib-author-helper version: 2.8.0 @@ -452,18 +446,18 @@ importers: packages/internals: dependencies: - '@babel/parser': - specifier: catalog:tooling - version: 7.28.4 - '@babel/types': - specifier: catalog:tooling - version: 7.28.4 '@kitql/helpers': specifier: workspace:* version: link:../helpers/dist - recast: + esrap: + specifier: catalog:tooling + version: https://pkg.pr.new/sveltejs/esrap@87 + oxc-parser: + specifier: catalog:tooling + version: 0.95.0 + oxc-walker: specifier: catalog:tooling - version: 0.23.4 + version: 0.5.2(oxc-parser@0.95.0) svelte: specifier: catalog:svelte-dep version: 5.40.0 @@ -491,7 +485,7 @@ importers: version: 6.0.1(rollup@4.41.1) svelte-check: specifier: catalog:svelte - version: 4.3.0(picomatch@4.0.3)(svelte@5.40.0)(typescript@5.9.2) + version: 4.3.0(picomatch@4.0.2)(svelte@5.40.0)(typescript@5.9.2) tslib: specifier: catalog:lib-author-helper version: 2.8.0 @@ -932,9 +926,18 @@ packages: resolution: {integrity: sha512-WyOx8cJQ+FQus4Mm4uPIZA64gbk3Wxh0so5Lcii0aJifqwoVOlfFtorjLE0Hen4OYyHZMXDWqMmaQemBhgxFRQ==} engines: {node: '>=14'} + '@emnapi/core@1.6.0': + resolution: {integrity: sha512-zq/ay+9fNIJJtJiZxdTnXS20PllcYMX3OE23ESc4HK/bdYu3cOWYVhsOhVnXALfU/uqJIxn5NBPd9z4v+SfoSg==} + '@emnapi/runtime@1.4.0': resolution: {integrity: sha512-64WYIf4UYcdLnbKn/umDlNjQDSS8AgZrI/R9+x5ilkUVFxXcA1Ebl+gQLc/6mERA4407Xof0R7wEyEuj091CVw==} + '@emnapi/runtime@1.6.0': + resolution: {integrity: sha512-obtUmAHTMjll499P+D9A3axeJFlhdjOWdKUNs/U6QIGT7V5RjcUW1xToAzjvmgTSQhDbYn/NwfTRoJcQ2rNBxA==} + + '@emnapi/wasi-threads@1.1.0': + resolution: {integrity: sha512-WI0DdZ8xFSbgMjR1sFsKABJ/C5OnRrjT06JXbZKexJGrDuPTzZdDYfFlsgcCXCyf+suG5QU2e/y1Wo2V/OapLQ==} + '@esbuild/aix-ppc64@0.25.0': resolution: {integrity: sha512-O7vun9Sf8DFjH2UtqK8Ku3LkquL9SZL8OLY1T5NZkA34+wG3OQF7cl4Ql8vdNzM6fzBbYfLaiRLIOZ+2FOCgBQ==} engines: {node: '>=18'} @@ -1361,6 +1364,9 @@ packages: '@mdx-js/mdx@3.1.0': resolution: {integrity: sha512-/QxEhPAvGwbQmy1Px8F899L5Uc2KZ6JtXwlCgJmjSTBedwOZkByYcBG4GceIGPXRDsmfxhHazuS+hlOShRLeDw==} + '@napi-rs/wasm-runtime@1.0.7': + resolution: {integrity: sha512-SeDnOO0Tk7Okiq6DbXmmBODgOAb9dp9gjlphokTUxmt8U3liIP1ZsozBahH69j/RJv+Rfs6IwUKHTgQYJ/HBAw==} + '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -1376,6 +1382,98 @@ packages: '@oslojs/encoding@1.1.0': resolution: {integrity: sha512-70wQhgYmndg4GCPxPPxPGevRKqTIJ2Nh4OkiMWmDAVYsTQ+Ta7Sq+rPevXyXGdzr30/qZBnyOalCszoMxlyldQ==} + '@oxc-parser/binding-android-arm64@0.95.0': + resolution: {integrity: sha512-dZyxhhvJigwWL1wgnLlqyEiSeuqO0WdDH9H+if0dPcBM4fKa5fjVkaUcJT1jBMcBTnkjxMwTXYZy5TK60N0fjg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@oxc-parser/binding-darwin-arm64@0.95.0': + resolution: {integrity: sha512-zun9+V33kyCtNec9oUSWwb0qi3fB8pXwum1yGFECPEr55g/CrWju6/Jv4hwwNBeW2tK9Ch/PRstEtYmOLMhHpg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@oxc-parser/binding-darwin-x64@0.95.0': + resolution: {integrity: sha512-9djMQ/t6Ns/UXtziwUe562uVJMbhtuLtCj+Xav+HMVT/rhV9gWO8PQOG7AwDLUBjJanItsrfqrGtqhNxtZ701w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@oxc-parser/binding-freebsd-x64@0.95.0': + resolution: {integrity: sha512-GK6k0PgCVkkeRZtHgcosCYbXIRySpJpuPw/OInfLGFh8f3x9gp2l8Fbcfx+YO+ZOHFBCd2NNedGqw8wMgouxfA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@oxc-parser/binding-linux-arm-gnueabihf@0.95.0': + resolution: {integrity: sha512-+g/lFITtyHHEk69cunOHuiT5cX+mpUTcbGYNe8suguZ7FqgNwai+PnGv0ctCvtgxBPVfckfUK8c3RvFKo+vi/w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxc-parser/binding-linux-arm-musleabihf@0.95.0': + resolution: {integrity: sha512-SXNasDtPw8ycNV7VEvFxb4LETmykvWKUhHR7K3us818coXYpDj54P8WEx8hJobP/9skuuiFuKHmtYLdjX8wntA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxc-parser/binding-linux-arm64-gnu@0.95.0': + resolution: {integrity: sha512-0LzebARTU0ROfD6pDK4h1pFn+09meErCZ0MA2TaW08G72+GNneEsksPufOuI+9AxVSRa+jKE3fu0wavvhZgSkg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + + '@oxc-parser/binding-linux-arm64-musl@0.95.0': + resolution: {integrity: sha512-Pvi1lGe/G+mJZ3hUojMP/aAHAzHA25AEtVr8/iuz7UV72t/15NOgJYr9kELMUMNjPqpr3vKUgXTFmTtAxp11Qw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + + '@oxc-parser/binding-linux-riscv64-gnu@0.95.0': + resolution: {integrity: sha512-pUEVHIOVNDfhk4sTlLhn6mrNENhE4/dAwemxIfqpcSyBlYG0xYZND1F3jjR2yWY6DakXZ6VSuDbtiv1LPNlOLw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + + '@oxc-parser/binding-linux-s390x-gnu@0.95.0': + resolution: {integrity: sha512-5+olaepHTE3J/+w7g0tr3nocvv5BKilAJnzj4L8tWBCLEZbL6olJcGVoldUO+3cgg1SO1xJywP5BuLhT0mDUDw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + + '@oxc-parser/binding-linux-x64-gnu@0.95.0': + resolution: {integrity: sha512-8huzHlK/N98wrnYKxIcYsK8ZGBWomQchu/Mzi6m+CtbhjWOv9DmK0jQ2fUWImtluQVpTwS0uZT06d3g7XIkJrA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + + '@oxc-parser/binding-linux-x64-musl@0.95.0': + resolution: {integrity: sha512-bWnrLfGDcx/fab0+UQnFbVFbiykof/btImbYf+cI2pU/1Egb2x+OKSmM5Qt0nEUiIpM5fgJmYXxTopybSZOKYA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + + '@oxc-parser/binding-wasm32-wasi@0.95.0': + resolution: {integrity: sha512-0JLyqkZu1HnQIZ4e5LBGOtzqua1QwFEUOoMSycdoerXqayd4LK2b7WMfAx8eCIf+jGm1Uj6f3R00nlsx8g1faQ==} + engines: {node: '>=14.0.0'} + cpu: [wasm32] + + '@oxc-parser/binding-win32-arm64-msvc@0.95.0': + resolution: {integrity: sha512-RWvaA6s1SYlBj9CxwHfNn0CRlkPdv9fEUAXfZkGQPdP5e1ppIaO2KYE0sUov/zzp9hPTMMsTMHl4dcIbb+pHCQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@oxc-parser/binding-win32-x64-msvc@0.95.0': + resolution: {integrity: sha512-BQpgl7rDjFvCIHudmUR0dCwc4ylBYZl4CPVinlD3NhkMif4WD5dADckoo5ES/KOpFyvwcbKZX+grP63cjHi26g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@oxc-project/types@0.95.0': + resolution: {integrity: sha512-vACy7vhpMPhjEJhULNxrdR0D943TkA/MigMpJCHmBHvMXxRStRi/dPtTlfQ3uDwWSzRpT8z+7ImjZVf8JWBocQ==} + '@oxlint-tsgolint/darwin-arm64@0.5.1': resolution: {integrity: sha512-UufHg95w3mto7D78QJkrBfxJlTBSQYj/6nAgfK8L/hBXMEt79VfEF2SyjByiDd98/QWqMygEt5b9rnfFtwLgRQ==} cpu: [arm64] @@ -1844,6 +1942,9 @@ packages: '@tsconfig/node16@1.0.4': resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} + '@tybys/wasm-util@0.10.1': + resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==} + '@types/acorn@4.0.6': resolution: {integrity: sha512-veQTnWP+1D/xbxVrPC3zHnCZRjSrKfhbMUlEA43iMZLu7EsnTtkJklIuwrCPbOi8YkvDQAiW05VQQFvvz9oieQ==} @@ -2132,17 +2233,10 @@ packages: resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} engines: {node: '>=8'} - assert@2.1.0: - resolution: {integrity: sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw==} - assertion-error@2.0.1: resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} engines: {node: '>=12'} - ast-types@0.16.1: - resolution: {integrity: sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg==} - engines: {node: '>=4'} - ast-v8-to-istanbul@0.3.3: resolution: {integrity: sha512-MuXMrSLVVoA6sYN/6Hke18vMzrT4TZNbZIj/hvh0fnYFpO+/kFXcLIaiPwXXWaQUPg4yJD8fj+lfJ7/1EBconw==} @@ -2166,10 +2260,6 @@ packages: asynckit@0.4.0: resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} - available-typed-arrays@1.0.5: - resolution: {integrity: sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==} - engines: {node: '>= 0.4'} - axios@1.8.1: resolution: {integrity: sha512-NN+fvwH/kV01dYUQ3PTOZns4LWtWhOFCAhQ/pHb88WQ1hNe5V/dvFwc4VJcDL11LT9xSX0QtsR8sWUuyOuOq7g==} @@ -2236,10 +2326,6 @@ packages: resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} engines: {node: '>= 0.4'} - call-bind@1.0.7: - resolution: {integrity: sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==} - engines: {node: '>= 0.4'} - callsites@3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} @@ -2480,18 +2566,10 @@ packages: resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} engines: {node: '>=0.10.0'} - define-data-property@1.1.4: - resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} - engines: {node: '>= 0.4'} - define-lazy-prop@2.0.0: resolution: {integrity: sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==} engines: {node: '>=8'} - define-properties@1.2.1: - resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} - engines: {node: '>= 0.4'} - defu@6.1.4: resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==} @@ -2736,8 +2814,12 @@ packages: resolution: {integrity: sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==} engines: {node: '>=0.10'} - esrap@2.1.0: - resolution: {integrity: sha512-yzmPNpl7TBbMRC5Lj2JlJZNPml0tzqoqP5B1JXycNUwtqma9AKCO0M2wHrdgsHcy1WRW7S9rJknAMtByg3usgA==} + esrap@2.1.2: + resolution: {integrity: sha512-DgvlIQeowRNyvLPWW4PT7Gu13WznY288Du086E751mwwbsgr29ytBiYeLzAGIo0qk3Ujob0SDk8TiSaM5WQzNg==} + + esrap@https://pkg.pr.new/sveltejs/esrap@87: + resolution: {tarball: https://pkg.pr.new/sveltejs/esrap@87} + version: 2.1.2 esrecurse@4.3.0: resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} @@ -2880,9 +2962,6 @@ packages: fontkit@2.0.4: resolution: {integrity: sha512-syetQadaUEDNdxdugga9CpEYVaQIxOwk7GlwZWWZ19//qW4zE5bknOKeMBDYAASwnpaSHKJITRLMF9m1fp3s6g==} - for-each@0.3.3: - resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} - foreground-child@3.1.1: resolution: {integrity: sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==} engines: {node: '>=14'} @@ -2954,11 +3033,6 @@ packages: resolution: {integrity: sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==} hasBin: true - glob@11.0.0: - resolution: {integrity: sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==} - engines: {node: 20 || >=22} - hasBin: true - globals@11.12.0: resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} engines: {node: '>=4'} @@ -2996,9 +3070,6 @@ packages: resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} engines: {node: '>=8'} - has-property-descriptors@1.0.2: - resolution: {integrity: sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==} - has-symbols@1.1.0: resolution: {integrity: sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==} engines: {node: '>= 0.4'} @@ -3145,9 +3216,6 @@ packages: resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==} engines: {node: '>=8'} - inherits@2.0.4: - resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} - inline-style-parser@0.2.4: resolution: {integrity: sha512-0aO8FkhNZlj/ZIbNi7Lxxr12obT7cL1moPfE4tg1LkX7LlLfC6DeX4l2ZEud1ukP9jNQyNnfzQVqwbwmAATY4Q==} @@ -3160,17 +3228,9 @@ packages: is-alphanumerical@2.0.1: resolution: {integrity: sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==} - is-arguments@1.1.1: - resolution: {integrity: sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==} - engines: {node: '>= 0.4'} - is-arrayish@0.3.2: resolution: {integrity: sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==} - is-callable@1.2.7: - resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} - engines: {node: '>= 0.4'} - is-core-module@2.13.1: resolution: {integrity: sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==} @@ -3195,10 +3255,6 @@ packages: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} engines: {node: '>=8'} - is-generator-function@1.0.10: - resolution: {integrity: sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==} - engines: {node: '>= 0.4'} - is-glob@4.0.3: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} @@ -3218,10 +3274,6 @@ packages: is-module@1.0.0: resolution: {integrity: sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==} - is-nan@1.3.2: - resolution: {integrity: sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==} - engines: {node: '>= 0.4'} - is-number@7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} @@ -3243,10 +3295,6 @@ packages: resolution: {integrity: sha512-2AT6j+gXe/1ueqbW6fLZJiIw3F8iXGJtt0yDrZaBhAZEG1raiTxKWU+IPqMCzQAXOUCKdA4UDMgacKH25XG2Cw==} engines: {node: '>=4'} - is-typed-array@1.1.10: - resolution: {integrity: sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A==} - engines: {node: '>= 0.4'} - is-unicode-supported@2.1.0: resolution: {integrity: sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==} engines: {node: '>=18'} @@ -3285,10 +3333,6 @@ packages: jackspeak@3.4.3: resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==} - jackspeak@4.0.2: - resolution: {integrity: sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==} - engines: {node: 20 || >=22} - jiti@1.21.7: resolution: {integrity: sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A==} hasBin: true @@ -3478,10 +3522,6 @@ packages: lru-cache@10.4.3: resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} - lru-cache@11.0.2: - resolution: {integrity: sha512-123qHRfJBmo2jXDbo/a5YOQrJoHF/GNQTLzQ5+IdK5pWpceK17yRc6ozlWd25FxvGKQbIUs91fDFkXmDHTKcyA==} - engines: {node: 20 || >=22} - lru-cache@11.2.2: resolution: {integrity: sha512-F9ODfyqML2coTIsQpSkRHnLSZMtkU8Q+mSfcaIyKwy58u+8k5nvAYeiNhsyMARvzNcXJ9QfWVrcPsC9e9rAxtg==} engines: {node: 20 || >=22} @@ -3490,6 +3530,9 @@ packages: resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==} hasBin: true + magic-regexp@0.10.0: + resolution: {integrity: sha512-Uly1Bu4lO1hwHUW0CQeSWuRtzCMNO00CmXtS8N6fyvB3B979GOEEeAkiTUDsmbYLAbvpUS/Kt5c4ibosAzVyVg==} + magic-string@0.30.17: resolution: {integrity: sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==} @@ -3712,10 +3755,6 @@ packages: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} engines: {node: '>=4'} - minimatch@10.0.1: - resolution: {integrity: sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==} - engines: {node: 20 || >=22} - minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} @@ -3805,18 +3844,6 @@ packages: nth-check@2.1.1: resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==} - object-is@1.1.5: - resolution: {integrity: sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==} - engines: {node: '>= 0.4'} - - object-keys@1.1.1: - resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} - engines: {node: '>= 0.4'} - - object.assign@4.1.5: - resolution: {integrity: sha512-byy+U7gp+FVwmyzKPYhW2h5l3crpmGsxl7X2s8y43IgxvG4g3QZ6CffDtsNQy1WsmZpQbO+ybo0AlW7TY6DcBQ==} - engines: {node: '>= 0.4'} - ofetch@1.4.1: resolution: {integrity: sha512-QZj2DfGplQAr2oj9KzceK9Hwz6Whxazmn85yYeVuS3u9XTMOGMRx0kO95MQ+vLsj/S/NwBDMMLU5hpxvI6Tklw==} @@ -3857,6 +3884,15 @@ packages: outdent@0.5.0: resolution: {integrity: sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q==} + oxc-parser@0.95.0: + resolution: {integrity: sha512-Te8fE/SmiiKWIrwBwxz5Dod87uYvsbcZ9JAL5ylPg1DevyKgTkxCXnPEaewk1Su2qpfNmry5RHoN+NywWFCG+A==} + engines: {node: ^20.19.0 || >=22.12.0} + + oxc-walker@0.5.2: + resolution: {integrity: sha512-XYoZqWwApSKUmSDEFeOKdy3Cdh95cOcSU8f7yskFWE4Rl3cfL5uwyY+EV7Brk9mdNLy+t5SseJajd6g7KncvlA==} + peerDependencies: + oxc-parser: '>=0.72.0' + oxlint-tsgolint@0.5.1: resolution: {integrity: sha512-C1MgHZRjs1uWJzRybwxlqHm2qvv8KrX0sEfZIaIWphJ9FJG5aUqEkGGa2Oug48hUgNbFgNB+KUpO7d8+7raAZQ==} hasBin: true @@ -3967,10 +4003,6 @@ packages: resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==} engines: {node: '>=16 || 14 >=14.18'} - path-scurry@2.0.0: - resolution: {integrity: sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==} - engines: {node: 20 || >=22} - path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} @@ -4218,10 +4250,6 @@ packages: resolution: {integrity: sha512-yDMz9g+VaZkqBYS/ozoBJwaBhTbZo3UNYQHNRw1D3UFQB8oHB4uS/tAODO+ZLjGWmUbKnIlOWO+aaIiAxrUWHA==} engines: {node: '>= 14.16.0'} - recast@0.23.4: - resolution: {integrity: sha512-qtEDqIZGVcSZCHniWwZWbRy79Dc6Wp3kT/UmDA2RJKBPg7+7k51aQBZirHmUGn5uvHf2rg8DkjizrN26k61ATw==} - engines: {node: '>= 4'} - recma-build-jsx@1.0.0: resolution: {integrity: sha512-8GtdyqaBcDfva+GUKDr3nev3VpKAhup1+RvkMvUxURHpW7QyIvk9F5wz7Vzo06CEMSilw6uArgRqhpiUcWp8ew==} @@ -4250,6 +4278,10 @@ packages: regex@6.0.1: resolution: {integrity: sha512-uorlqlzAKjKQZ5P+kTJr3eeJGSVroLKoHmquUj4zHWuR+hEyNqlXsSKlYYF5F4NI6nl7tWCs0apKJ0lmfsXAPA==} + regexp-tree@0.1.27: + resolution: {integrity: sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==} + hasBin: true + rehype-expressive-code@0.41.2: resolution: {integrity: sha512-vHYfWO9WxAw6kHHctddOt+P4266BtyT1mrOIuxJD+1ELuvuJAa5uBIhYt0OVMyOhlvf57hzWOXJkHnMhpaHyxw==} @@ -4342,11 +4374,6 @@ packages: resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} - rimraf@6.0.1: - resolution: {integrity: sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==} - engines: {node: 20 || >=22} - hasBin: true - rollup-plugin-visualizer@6.0.1: resolution: {integrity: sha512-NjlGElvLXCSZSAi3gNRZbfX3qlQbQcJ9TW97c5JpqfVwMhttj9YwEdPwcvbKj91RnMX2PWAjonvSEv6UEYtnRQ==} engines: {node: '>=18'} @@ -4409,10 +4436,6 @@ packages: set-cookie-parser@2.6.0: resolution: {integrity: sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==} - set-function-length@1.2.2: - resolution: {integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==} - engines: {node: '>= 0.4'} - sh-syntax@0.5.8: resolution: {integrity: sha512-JfVoxf4FxQI5qpsPbkHhZo+n6N9YMJobyl4oGEUBb/31oQYlgTjkXQD8PBiafS2UbWoxrTO0Z5PJUBXEPAG1Zw==} engines: {node: '>=16.0.0'} @@ -4455,7 +4478,6 @@ packages: sitemap@8.0.0: resolution: {integrity: sha512-+AbdxhM9kJsHtruUF39bwS/B0Fytw6Fr1o4ZAIAEqA6cke2xcoO2GleBw9Zw7nRzILVEgz7zBM5GiTJjie1G9A==} engines: {node: '>=14.0.0', npm: '>=6.0.0'} - deprecated: 'SECURITY: Multiple vulnerabilities fixed in 8.0.1 (XML injection, path traversal, command injection, protocol injection). Upgrade immediately: npm install sitemap@8.0.1' hasBin: true slash@3.0.0: @@ -4530,10 +4552,6 @@ packages: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} engines: {node: '>=8'} - strip-ansi@7.1.0: - resolution: {integrity: sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==} - engines: {node: '>=12'} - strip-ansi@7.1.2: resolution: {integrity: sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==} engines: {node: '>=12'} @@ -4739,6 +4757,9 @@ packages: resolution: {integrity: sha512-S/5/0kFftkq27FPNye0XM1e2NsnoD/3FS+pBmbjmmtLT6I+i344KoOf7pvXreaFsDamWeaJX55nczA1m5PsBDg==} engines: {node: '>=16'} + type-level-regexp@0.1.17: + resolution: {integrity: sha512-wTk4DH3cxwk196uGLK/E9pE45aLfeKJacKmcEgEOA/q5dnPGNxXt0cfYdFxb57L+sEpf1oJH4Dnx/pnRcku9jg==} + typescript-eslint@8.46.1: resolution: {integrity: sha512-VHgijW803JafdSsDO8I761r3SHrgk4T00IdyQ+/UsthtgPRsBWQLqoSxOolxTpxRKi1kGXK0bSz4CoAc9ObqJA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -4751,9 +4772,6 @@ packages: engines: {node: '>=14.17'} hasBin: true - ufo@1.5.4: - resolution: {integrity: sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==} - ufo@1.6.1: resolution: {integrity: sha512-9a4/uxlTWJ4+a5i0ooc1rU7C7YOw3wT+UGqdeNNHWnOF9qcMBgLRS+4IYUqbczewFx4mLEig6gawh7X6mFlEkA==} @@ -4816,6 +4834,10 @@ packages: resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} engines: {node: '>= 4.0.0'} + unplugin@2.3.10: + resolution: {integrity: sha512-6NCPkv1ClwH+/BGE9QeoTIl09nuiAt0gS28nn1PvYXsGKRwM2TCbFA2QiilmehPDTXIe684k4rZI1yl3A1PCUw==} + engines: {node: '>=18.12.0'} + unstorage@1.17.1: resolution: {integrity: sha512-KKGwRTT0iVBCErKemkJCLs7JdxNVfqTPc/85ae1XES0+bsHbc/sFBfVi5kJp156cc51BHinIH2l3k0EZ24vOBQ==} peerDependencies: @@ -4884,9 +4906,6 @@ packages: util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} - util@0.12.5: - resolution: {integrity: sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==} - v8-compile-cache-lib@3.0.1: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} @@ -5038,6 +5057,9 @@ packages: resolution: {integrity: sha512-n4W4YFyz5JzOfQeA8oN7dUYpR+MBP3PIUsn2jLjWXwK5ASUzt0Jc/A5sAUZoCYFJRGF0FBKJ+1JjN43rNdsQzA==} engines: {node: '>=20'} + webpack-virtual-modules@0.6.2: + resolution: {integrity: sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==} + whatwg-encoding@3.1.1: resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==} engines: {node: '>=18'} @@ -5057,10 +5079,6 @@ packages: resolution: {integrity: sha512-n1brCuqClxfFfq/Rb0ICg9giSZqCS+pLtccdag6C2HyufBrh3fBOiy9nb6ggRMvWOVH5GrdJskj5iGTZNxd7SA==} engines: {node: '>=4'} - which-typed-array@1.1.9: - resolution: {integrity: sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==} - engines: {node: '>= 0.4'} - which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} @@ -5636,11 +5654,27 @@ snapshots: '@ctrl/tinycolor@4.1.0': {} + '@emnapi/core@1.6.0': + dependencies: + '@emnapi/wasi-threads': 1.1.0 + tslib: 2.8.1 + optional: true + '@emnapi/runtime@1.4.0': dependencies: tslib: 2.8.0 optional: true + '@emnapi/runtime@1.6.0': + dependencies: + tslib: 2.8.1 + optional: true + + '@emnapi/wasi-threads@1.1.0': + dependencies: + tslib: 2.8.1 + optional: true + '@esbuild/aix-ppc64@0.25.0': optional: true @@ -5791,7 +5825,7 @@ snapshots: '@expressive-code/plugin-shiki@0.41.2': dependencies: '@expressive-code/core': 0.41.2 - shiki: 3.13.0 + shiki: 3.2.2 '@expressive-code/plugin-text-markers@0.41.2': dependencies: @@ -5944,7 +5978,7 @@ snapshots: dependencies: string-width: 5.1.2 string-width-cjs: string-width@4.2.3 - strip-ansi: 7.1.0 + strip-ansi: 7.1.2 strip-ansi-cjs: strip-ansi@6.0.1 wrap-ansi: 8.1.0 wrap-ansi-cjs: wrap-ansi@7.0.0 @@ -6033,6 +6067,13 @@ snapshots: - acorn - supports-color + '@napi-rs/wasm-runtime@1.0.7': + dependencies: + '@emnapi/core': 1.6.0 + '@emnapi/runtime': 1.6.0 + '@tybys/wasm-util': 0.10.1 + optional: true + '@nodelib/fs.scandir@2.1.5': dependencies: '@nodelib/fs.stat': 2.0.5 @@ -6047,6 +6088,55 @@ snapshots: '@oslojs/encoding@1.1.0': {} + '@oxc-parser/binding-android-arm64@0.95.0': + optional: true + + '@oxc-parser/binding-darwin-arm64@0.95.0': + optional: true + + '@oxc-parser/binding-darwin-x64@0.95.0': + optional: true + + '@oxc-parser/binding-freebsd-x64@0.95.0': + optional: true + + '@oxc-parser/binding-linux-arm-gnueabihf@0.95.0': + optional: true + + '@oxc-parser/binding-linux-arm-musleabihf@0.95.0': + optional: true + + '@oxc-parser/binding-linux-arm64-gnu@0.95.0': + optional: true + + '@oxc-parser/binding-linux-arm64-musl@0.95.0': + optional: true + + '@oxc-parser/binding-linux-riscv64-gnu@0.95.0': + optional: true + + '@oxc-parser/binding-linux-s390x-gnu@0.95.0': + optional: true + + '@oxc-parser/binding-linux-x64-gnu@0.95.0': + optional: true + + '@oxc-parser/binding-linux-x64-musl@0.95.0': + optional: true + + '@oxc-parser/binding-wasm32-wasi@0.95.0': + dependencies: + '@napi-rs/wasm-runtime': 1.0.7 + optional: true + + '@oxc-parser/binding-win32-arm64-msvc@0.95.0': + optional: true + + '@oxc-parser/binding-win32-x64-msvc@0.95.0': + optional: true + + '@oxc-project/types@0.95.0': {} + '@oxlint-tsgolint/darwin-arm64@0.5.1': optional: true @@ -6510,6 +6600,11 @@ snapshots: '@tsconfig/node16@1.0.4': optional: true + '@tybys/wasm-util@0.10.1': + dependencies: + tslib: 2.8.1 + optional: true + '@types/acorn@4.0.6': dependencies: '@types/estree': 1.0.7 @@ -6727,7 +6822,7 @@ snapshots: dependencies: '@vitest/spy': 3.2.4 estree-walker: 3.0.3 - magic-string: 0.30.19 + magic-string: 0.30.17 optionalDependencies: vite: 7.0.2(@types/node@22.13.9)(jiti@1.21.7)(lightningcss@1.28.2)(sass@1.85.1)(terser@5.37.0)(tsx@4.20.3)(yaml@2.8.1) @@ -6744,7 +6839,7 @@ snapshots: '@vitest/snapshot@3.2.4': dependencies: '@vitest/pretty-format': 3.2.4 - magic-string: 0.30.19 + magic-string: 0.30.17 pathe: 2.0.3 '@vitest/spy@3.2.4': @@ -6871,20 +6966,8 @@ snapshots: array-union@2.1.0: {} - assert@2.1.0: - dependencies: - call-bind: 1.0.7 - is-nan: 1.3.2 - object-is: 1.1.5 - object.assign: 4.1.5 - util: 0.12.5 - assertion-error@2.0.1: {} - ast-types@0.16.1: - dependencies: - tslib: 2.8.0 - ast-v8-to-istanbul@0.3.3: dependencies: '@jridgewell/trace-mapping': 0.3.25 @@ -7010,8 +7093,6 @@ snapshots: asynckit@0.4.0: {} - available-typed-arrays@1.0.5: {} - axios@1.8.1: dependencies: follow-redirects: 1.15.9 @@ -7088,14 +7169,6 @@ snapshots: es-errors: 1.3.0 function-bind: 1.1.2 - call-bind@1.0.7: - dependencies: - es-define-property: 1.0.1 - es-errors: 1.3.0 - function-bind: 1.1.2 - get-intrinsic: 1.3.0 - set-function-length: 1.2.2 - callsites@3.1.0: {} camelcase@8.0.0: {} @@ -7313,20 +7386,8 @@ snapshots: deepmerge@4.3.1: {} - define-data-property@1.1.4: - dependencies: - es-define-property: 1.0.1 - es-errors: 1.3.0 - gopd: 1.2.0 - define-lazy-prop@2.0.0: {} - define-properties@1.2.1: - dependencies: - define-data-property: 1.1.4 - has-property-descriptors: 1.0.2 - object-keys: 1.1.1 - defu@6.1.4: {} delayed-stream@1.0.0: {} @@ -7606,7 +7667,11 @@ snapshots: dependencies: estraverse: 5.3.0 - esrap@2.1.0: + esrap@2.1.2: + dependencies: + '@jridgewell/sourcemap-codec': 1.5.5 + + esrap@https://pkg.pr.new/sveltejs/esrap@87: dependencies: '@jridgewell/sourcemap-codec': 1.5.5 @@ -7762,10 +7827,6 @@ snapshots: unicode-properties: 1.4.1 unicode-trie: 2.0.0 - for-each@0.3.3: - dependencies: - is-callable: 1.2.7 - foreground-child@3.1.1: dependencies: cross-spawn: 7.0.6 @@ -7851,15 +7912,6 @@ snapshots: package-json-from-dist: 1.0.0 path-scurry: 1.11.1 - glob@11.0.0: - dependencies: - foreground-child: 3.1.1 - jackspeak: 4.0.2 - minimatch: 10.0.1 - minipass: 7.1.2 - package-json-from-dist: 1.0.0 - path-scurry: 2.0.0 - globals@11.12.0: {} globals@14.0.0: {} @@ -7897,10 +7949,6 @@ snapshots: has-flag@4.0.0: {} - has-property-descriptors@1.0.2: - dependencies: - es-define-property: 1.0.1 - has-symbols@1.1.0: {} has-tostringtag@1.0.2: @@ -8169,8 +8217,6 @@ snapshots: indent-string@4.0.0: {} - inherits@2.0.4: {} - inline-style-parser@0.2.4: {} iron-webcrypto@1.2.1: {} @@ -8182,15 +8228,8 @@ snapshots: is-alphabetical: 2.0.1 is-decimal: 2.0.1 - is-arguments@1.1.1: - dependencies: - call-bind: 1.0.7 - has-tostringtag: 1.0.2 - is-arrayish@0.3.2: {} - is-callable@1.2.7: {} - is-core-module@2.13.1: dependencies: hasown: 2.0.2 @@ -8205,10 +8244,6 @@ snapshots: is-fullwidth-code-point@3.0.0: {} - is-generator-function@1.0.10: - dependencies: - has-tostringtag: 1.0.2 - is-glob@4.0.3: dependencies: is-extglob: 2.1.1 @@ -8223,11 +8258,6 @@ snapshots: is-module@1.0.0: {} - is-nan@1.3.2: - dependencies: - call-bind: 1.0.7 - define-properties: 1.2.1 - is-number@7.0.0: {} is-plain-obj@4.1.0: {} @@ -8246,14 +8276,6 @@ snapshots: dependencies: better-path-resolve: 1.0.0 - is-typed-array@1.1.10: - dependencies: - available-typed-arrays: 1.0.5 - call-bind: 1.0.7 - for-each: 0.3.3 - gopd: 1.2.0 - has-tostringtag: 1.0.2 - is-unicode-supported@2.1.0: {} is-windows@1.0.2: {} @@ -8295,10 +8317,6 @@ snapshots: optionalDependencies: '@pkgjs/parseargs': 0.11.0 - jackspeak@4.0.2: - dependencies: - '@isaacs/cliui': 8.0.2 - jiti@1.21.7: optional: true @@ -8478,15 +8496,23 @@ snapshots: lru-cache@10.4.3: {} - lru-cache@11.0.2: {} - lru-cache@11.2.2: {} lz-string@1.5.0: {} + magic-regexp@0.10.0: + dependencies: + estree-walker: 3.0.3 + magic-string: 0.30.19 + mlly: 1.7.4 + regexp-tree: 0.1.27 + type-level-regexp: 0.1.17 + ufo: 1.6.1 + unplugin: 2.3.10 + magic-string@0.30.17: dependencies: - '@jridgewell/sourcemap-codec': 1.5.0 + '@jridgewell/sourcemap-codec': 1.5.5 magic-string@0.30.19: dependencies: @@ -8993,10 +9019,6 @@ snapshots: min-indent@1.0.1: {} - minimatch@10.0.1: - dependencies: - brace-expansion: 2.0.1 - minimatch@3.1.2: dependencies: brace-expansion: 1.1.11 @@ -9027,7 +9049,7 @@ snapshots: acorn: 8.15.0 pathe: 2.0.3 pkg-types: 1.3.1 - ufo: 1.5.4 + ufo: 1.6.1 mri@1.2.0: {} @@ -9067,20 +9089,6 @@ snapshots: dependencies: boolbase: 1.0.0 - object-is@1.1.5: - dependencies: - call-bind: 1.0.7 - define-properties: 1.2.1 - - object-keys@1.1.1: {} - - object.assign@4.1.5: - dependencies: - call-bind: 1.0.7 - define-properties: 1.2.1 - has-symbols: 1.1.0 - object-keys: 1.1.1 - ofetch@1.4.1: dependencies: destr: 2.0.5 @@ -9143,6 +9151,31 @@ snapshots: outdent@0.5.0: {} + oxc-parser@0.95.0: + dependencies: + '@oxc-project/types': 0.95.0 + optionalDependencies: + '@oxc-parser/binding-android-arm64': 0.95.0 + '@oxc-parser/binding-darwin-arm64': 0.95.0 + '@oxc-parser/binding-darwin-x64': 0.95.0 + '@oxc-parser/binding-freebsd-x64': 0.95.0 + '@oxc-parser/binding-linux-arm-gnueabihf': 0.95.0 + '@oxc-parser/binding-linux-arm-musleabihf': 0.95.0 + '@oxc-parser/binding-linux-arm64-gnu': 0.95.0 + '@oxc-parser/binding-linux-arm64-musl': 0.95.0 + '@oxc-parser/binding-linux-riscv64-gnu': 0.95.0 + '@oxc-parser/binding-linux-s390x-gnu': 0.95.0 + '@oxc-parser/binding-linux-x64-gnu': 0.95.0 + '@oxc-parser/binding-linux-x64-musl': 0.95.0 + '@oxc-parser/binding-wasm32-wasi': 0.95.0 + '@oxc-parser/binding-win32-arm64-msvc': 0.95.0 + '@oxc-parser/binding-win32-x64-msvc': 0.95.0 + + oxc-walker@0.5.2(oxc-parser@0.95.0): + dependencies: + magic-regexp: 0.10.0 + oxc-parser: 0.95.0 + oxlint-tsgolint@0.5.1: optionalDependencies: '@oxlint-tsgolint/darwin-arm64': 0.5.1 @@ -9273,11 +9306,6 @@ snapshots: lru-cache: 10.4.3 minipass: 7.1.2 - path-scurry@2.0.0: - dependencies: - lru-cache: 11.0.2 - minipass: 7.1.2 - path-type@4.0.0: {} pathe@1.1.2: {} @@ -9456,14 +9484,6 @@ snapshots: readdirp@4.0.2: {} - recast@0.23.4: - dependencies: - assert: 2.1.0 - ast-types: 0.16.1 - esprima: 4.0.1 - source-map: 0.6.1 - tslib: 2.8.0 - recma-build-jsx@1.0.0: dependencies: '@types/estree': 1.0.7 @@ -9511,6 +9531,8 @@ snapshots: dependencies: regex-utilities: 2.3.0 + regexp-tree@0.1.27: {} + rehype-expressive-code@0.41.2: dependencies: expressive-code: 0.41.2 @@ -9664,11 +9686,6 @@ snapshots: reusify@1.0.4: {} - rimraf@6.0.1: - dependencies: - glob: 11.0.0 - package-json-from-dist: 1.0.0 - rollup-plugin-visualizer@6.0.1(rollup@4.41.1): dependencies: open: 8.4.2 @@ -9743,15 +9760,6 @@ snapshots: set-cookie-parser@2.6.0: {} - set-function-length@1.2.2: - dependencies: - define-data-property: 1.1.4 - es-errors: 1.3.0 - function-bind: 1.1.2 - get-intrinsic: 1.3.0 - gopd: 1.2.0 - has-property-descriptors: 1.0.2 - sh-syntax@0.5.8: dependencies: tslib: 2.8.1 @@ -9848,7 +9856,8 @@ snapshots: source-map: 0.6.1 optional: true - source-map@0.6.1: {} + source-map@0.6.1: + optional: true source-map@0.7.4: {} @@ -9901,10 +9910,6 @@ snapshots: dependencies: ansi-regex: 5.0.1 - strip-ansi@7.1.0: - dependencies: - ansi-regex: 6.0.1 - strip-ansi@7.1.2: dependencies: ansi-regex: 6.0.1 @@ -9939,25 +9944,13 @@ snapshots: supports-preserve-symlinks-flag@1.0.0: {} - svelte-check@4.3.0(picomatch@4.0.2)(svelte@5.43.6)(typescript@5.9.2): + svelte-check@4.3.0(picomatch@4.0.2)(svelte@5.40.0)(typescript@5.9.2): dependencies: '@jridgewell/trace-mapping': 0.3.25 chokidar: 4.0.3 fdir: 6.4.6(picomatch@4.0.2) picocolors: 1.1.1 sade: 1.8.1 - svelte: 5.43.6 - typescript: 5.9.2 - transitivePeerDependencies: - - picomatch - - svelte-check@4.3.0(picomatch@4.0.3)(svelte@5.40.0)(typescript@5.9.2): - dependencies: - '@jridgewell/trace-mapping': 0.3.25 - chokidar: 4.0.3 - fdir: 6.4.6(picomatch@4.0.3) - picocolors: 1.1.1 - sade: 1.8.1 svelte: 5.40.0 typescript: 5.9.2 transitivePeerDependencies: @@ -10011,7 +10004,7 @@ snapshots: axobject-query: 4.1.0 clsx: 2.1.1 esm-env: 1.2.2 - esrap: 2.1.0 + esrap: 2.1.2 is-reference: 3.0.3 locate-character: 3.0.0 magic-string: 0.30.17 @@ -10028,7 +10021,7 @@ snapshots: axobject-query: 4.1.0 clsx: 2.1.1 esm-env: 1.2.2 - esrap: 2.1.0 + esrap: 2.1.2 is-reference: 3.0.3 locate-character: 3.0.0 magic-string: 0.30.19 @@ -10165,6 +10158,8 @@ snapshots: type-fest@4.37.0: {} + type-level-regexp@0.1.17: {} + typescript-eslint@8.46.1(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.2): dependencies: '@typescript-eslint/eslint-plugin': 8.46.1(@typescript-eslint/parser@8.46.1(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.2))(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.2) @@ -10178,8 +10173,6 @@ snapshots: typescript@5.9.2: {} - ufo@1.5.4: {} - ufo@1.6.1: {} ultrahtml@1.6.0: {} @@ -10264,6 +10257,13 @@ snapshots: universalify@0.1.2: {} + unplugin@2.3.10: + dependencies: + '@jridgewell/remapping': 2.3.5 + acorn: 8.15.0 + picomatch: 4.0.3 + webpack-virtual-modules: 0.6.2 + unstorage@1.17.1: dependencies: anymatch: 3.1.3 @@ -10281,14 +10281,6 @@ snapshots: util-deprecate@1.0.2: {} - util@0.12.5: - dependencies: - inherits: 2.0.4 - is-arguments: 1.1.1 - is-generator-function: 1.0.10 - is-typed-array: 1.1.10 - which-typed-array: 1.1.9 - v8-compile-cache-lib@3.0.1: optional: true @@ -10428,6 +10420,8 @@ snapshots: webidl-conversions@8.0.0: {} + webpack-virtual-modules@0.6.2: {} + whatwg-encoding@3.1.1: dependencies: iconv-lite: 0.6.3 @@ -10446,15 +10440,6 @@ snapshots: which-pm-runs@1.1.0: {} - which-typed-array@1.1.9: - dependencies: - available-typed-arrays: 1.0.5 - call-bind: 1.0.7 - for-each: 0.3.3 - gopd: 1.2.0 - has-tostringtag: 1.0.2 - is-typed-array: 1.1.10 - which@2.0.2: dependencies: isexe: 2.0.0 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 11d05f79..654df3a2 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -10,14 +10,13 @@ packages: catalogs: tooling: + esrap: https://pkg.pr.new/sveltejs/esrap@87 + oxc-parser: 0.95.0 + oxc-walker: 0.5.2 'typescript': '5.9.2' 'esbuild': '0.25.0' - '@babel/parser': 7.28.4 - '@babel/types': 7.28.4 - 'rimraf': '6.0.1' 'commander': '14.0.0' 'ora': '9.0.0' - 'recast': '^0.23.4' 'tsx': '4.20.3' vite: @@ -49,7 +48,7 @@ catalogs: jsonc-eslint-parser: 2.4.0 yaml-eslint-parser: 1.3.0 - formatting: + formatting: 'prettier': '^3.6.1' '@ianvs/prettier-plugin-sort-imports': '^4.7.0' 'prettier-plugin-sh': '^0.18.0' -- 2.51.2