@wyw-in-js/transform 2.0.0-alpha.0 → 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/cache.js +7 -0
- package/esm/cache.js.map +1 -1
- package/esm/debug/fileReporter.js +35 -1
- package/esm/debug/fileReporter.js.map +1 -1
- package/esm/eval/broker.js +230 -89
- package/esm/eval/broker.js.map +1 -1
- package/esm/eval/protocol.js.map +1 -1
- package/esm/eval/runner.js +143 -24
- package/esm/eval/runner.js.map +1 -1
- package/esm/module.js +70 -43
- package/esm/module.js.map +1 -1
- package/esm/transform/Entrypoint.types.js.map +1 -1
- package/esm/transform/generators/processEntrypoint.js +35 -20
- package/esm/transform/generators/processEntrypoint.js.map +1 -1
- package/esm/transform/generators/resolveImports.js +48 -2
- package/esm/transform/generators/resolveImports.js.map +1 -1
- package/esm/transform/generators/resolveStaticOxcValues/cache.js +182 -0
- package/esm/transform/generators/resolveStaticOxcValues/cache.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/candidateResolver.js +146 -0
- package/esm/transform/generators/resolveStaticOxcValues/candidateResolver.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/dependencies.js +33 -0
- package/esm/transform/generators/resolveStaticOxcValues/dependencies.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/environment.js +29 -0
- package/esm/transform/generators/resolveStaticOxcValues/environment.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/exportResolver.js +351 -0
- package/esm/transform/generators/resolveStaticOxcValues/exportResolver.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/exportTargets.js +253 -0
- package/esm/transform/generators/resolveStaticOxcValues/exportTargets.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/objectAssign.js +310 -0
- package/esm/transform/generators/resolveStaticOxcValues/objectAssign.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js +74 -0
- package/esm/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/opaqueRuntime.js +229 -0
- package/esm/transform/generators/resolveStaticOxcValues/opaqueRuntime.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/processorStaticExport.js +172 -0
- package/esm/transform/generators/resolveStaticOxcValues/processorStaticExport.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/processorStaticModel.js +476 -0
- package/esm/transform/generators/resolveStaticOxcValues/processorStaticModel.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/processorTarget.js +55 -0
- package/esm/transform/generators/resolveStaticOxcValues/processorTarget.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/programAnalysis.js +123 -0
- package/esm/transform/generators/resolveStaticOxcValues/programAnalysis.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/prune.js +186 -0
- package/esm/transform/generators/resolveStaticOxcValues/prune.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js +183 -0
- package/esm/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/staticExpression.js +298 -0
- package/esm/transform/generators/resolveStaticOxcValues/staticExpression.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js +298 -0
- package/esm/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/types.js +3 -0
- package/esm/transform/generators/resolveStaticOxcValues/types.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js +59 -0
- package/esm/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues.js +1 -2910
- package/esm/transform/generators/resolveStaticOxcValues.js.map +1 -1
- package/esm/transform/generators/transform.js +57 -45
- package/esm/transform/generators/transform.js.map +1 -1
- package/esm/transform/helpers/loadWywOptions.js +33 -4
- package/esm/transform/helpers/loadWywOptions.js.map +1 -1
- package/esm/transform.js +3 -1
- package/esm/transform.js.map +1 -1
- package/esm/utils/EventEmitter.js +42 -9
- package/esm/utils/EventEmitter.js.map +1 -1
- package/esm/utils/applyOxcProcessors/applyOxcProcessors.js +160 -0
- package/esm/utils/applyOxcProcessors/applyOxcProcessors.js.map +1 -0
- package/esm/utils/applyOxcProcessors/cleanupBindings.js +157 -0
- package/esm/utils/applyOxcProcessors/cleanupBindings.js.map +1 -0
- package/esm/utils/applyOxcProcessors/cleanupRemovals.js +431 -0
- package/esm/utils/applyOxcProcessors/cleanupRemovals.js.map +1 -0
- package/esm/utils/applyOxcProcessors/displayName.js +93 -0
- package/esm/utils/applyOxcProcessors/displayName.js.map +1 -0
- package/esm/utils/applyOxcProcessors/expressionValues.js +152 -0
- package/esm/utils/applyOxcProcessors/expressionValues.js.map +1 -0
- package/esm/utils/applyOxcProcessors/processorFactory.js +62 -0
- package/esm/utils/applyOxcProcessors/processorFactory.js.map +1 -0
- package/esm/utils/applyOxcProcessors/processorUsages.js +143 -0
- package/esm/utils/applyOxcProcessors/processorUsages.js.map +1 -0
- package/esm/utils/applyOxcProcessors/sameFileStaticValues.js +207 -0
- package/esm/utils/applyOxcProcessors/sameFileStaticValues.js.map +1 -0
- package/esm/utils/applyOxcProcessors/shared.js +29 -0
- package/esm/utils/applyOxcProcessors/shared.js.map +1 -0
- package/esm/utils/applyOxcProcessors/types.js +2 -0
- package/esm/utils/applyOxcProcessors/types.js.map +1 -0
- package/esm/utils/applyOxcProcessors.js +1 -1216
- package/esm/utils/applyOxcProcessors.js.map +1 -1
- package/esm/utils/collectOxcRuntime/normalizeRuntimeCode.js +157 -0
- package/esm/utils/collectOxcRuntime/normalizeRuntimeCode.js.map +1 -0
- package/esm/utils/collectOxcRuntime/sourceMap.js +36 -0
- package/esm/utils/collectOxcRuntime/sourceMap.js.map +1 -0
- package/esm/utils/collectOxcRuntime/types.js +2 -0
- package/esm/utils/collectOxcRuntime/types.js.map +1 -0
- package/esm/utils/collectOxcRuntime.js +5 -193
- package/esm/utils/collectOxcRuntime.js.map +1 -1
- package/esm/utils/collectOxcTemplateDependencies/expressionExtraction.js +496 -0
- package/esm/utils/collectOxcTemplateDependencies/expressionExtraction.js.map +1 -0
- package/esm/utils/collectOxcTemplateDependencies/expressionReplacements.js +113 -0
- package/esm/utils/collectOxcTemplateDependencies/expressionReplacements.js.map +1 -0
- package/esm/utils/collectOxcTemplateDependencies/scopeAnalysis.js +387 -0
- package/esm/utils/collectOxcTemplateDependencies/scopeAnalysis.js.map +1 -0
- package/esm/utils/collectOxcTemplateDependencies/staticBindings.js +17 -0
- package/esm/utils/collectOxcTemplateDependencies/staticBindings.js.map +1 -0
- package/esm/utils/collectOxcTemplateDependencies/staticEvaluator.js +540 -0
- package/esm/utils/collectOxcTemplateDependencies/staticEvaluator.js.map +1 -0
- package/esm/utils/collectOxcTemplateDependencies/types.js +2 -0
- package/esm/utils/collectOxcTemplateDependencies/types.js.map +1 -0
- package/esm/utils/collectOxcTemplateDependencies.js +3 -1397
- package/esm/utils/collectOxcTemplateDependencies.js.map +1 -1
- package/esm/utils/nativeResolver.js +93 -0
- package/esm/utils/nativeResolver.js.map +1 -0
- package/esm/utils/oxc/ast.js +28 -0
- package/esm/utils/oxc/ast.js.map +1 -0
- package/esm/utils/oxc/parse.js +3 -0
- package/esm/utils/oxc/parse.js.map +1 -0
- package/esm/utils/oxc/replacements.js +14 -0
- package/esm/utils/oxc/replacements.js.map +1 -0
- package/esm/utils/oxc/sourceLocations.js +59 -0
- package/esm/utils/oxc/sourceLocations.js.map +1 -0
- package/esm/utils/oxcPreevalStage/evalStrategy.js +3 -0
- package/esm/utils/oxcPreevalStage/evalStrategy.js.map +1 -0
- package/esm/utils/oxcPreevalStage/prepareCode.js +21 -0
- package/esm/utils/oxcPreevalStage/prepareCode.js.map +1 -0
- package/esm/utils/oxcPreevalStage/prevalExport.js +23 -0
- package/esm/utils/oxcPreevalStage/prevalExport.js.map +1 -0
- package/esm/utils/oxcPreevalStage/processors.js +17 -0
- package/esm/utils/oxcPreevalStage/processors.js.map +1 -0
- package/esm/utils/oxcPreevalStage/staticOverlay.js +18 -0
- package/esm/utils/oxcPreevalStage/staticOverlay.js.map +1 -0
- package/esm/utils/oxcPreevalStage/types.js +2 -0
- package/esm/utils/oxcPreevalStage/types.js.map +1 -0
- package/esm/utils/oxcPreevalStage.js +17 -73
- package/esm/utils/oxcPreevalStage.js.map +1 -1
- package/esm/utils/oxcPreevalTransforms.js +12 -1
- package/esm/utils/oxcPreevalTransforms.js.map +1 -1
- package/esm/utils/processorStaticSemantics.js +157 -0
- package/esm/utils/processorStaticSemantics.js.map +1 -0
- package/esm/utils/resolveWithConditions.js +3 -3
- package/esm/utils/resolveWithConditions.js.map +1 -1
- package/package.json +4 -3
- package/types/cache.js +8 -0
- package/types/debug/fileReporter.js +46 -1
- package/types/eval/broker.d.ts +6 -2
- package/types/eval/broker.js +244 -95
- package/types/eval/protocol.d.ts +15 -1
- package/types/module.d.ts +4 -1
- package/types/module.js +97 -48
- package/types/transform/Entrypoint.types.d.ts +3 -0
- package/types/transform/generators/resolveImports.d.ts +3 -1
- package/types/transform/generators/resolveImports.js +49 -2
- package/types/transform/generators/resolveStaticOxcValues/cache.d.ts +25 -0
- package/types/transform/generators/resolveStaticOxcValues/cache.js +182 -0
- package/types/transform/generators/resolveStaticOxcValues/candidateResolver.d.ts +5 -0
- package/types/transform/generators/resolveStaticOxcValues/candidateResolver.js +149 -0
- package/types/transform/generators/resolveStaticOxcValues/dependencies.d.ts +6 -0
- package/types/transform/generators/resolveStaticOxcValues/dependencies.js +37 -0
- package/types/transform/generators/resolveStaticOxcValues/environment.d.ts +12 -0
- package/types/transform/generators/resolveStaticOxcValues/environment.js +32 -0
- package/types/transform/generators/resolveStaticOxcValues/exportResolver.d.ts +4 -0
- package/types/transform/generators/resolveStaticOxcValues/exportResolver.js +358 -0
- package/types/transform/generators/resolveStaticOxcValues/exportTargets.d.ts +20 -0
- package/types/transform/generators/resolveStaticOxcValues/exportTargets.js +285 -0
- package/types/transform/generators/resolveStaticOxcValues/objectAssign.d.ts +41 -0
- package/types/transform/generators/resolveStaticOxcValues/objectAssign.js +352 -0
- package/types/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.d.ts +6 -0
- package/types/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js +88 -0
- package/types/transform/generators/resolveStaticOxcValues/opaqueRuntime.d.ts +13 -0
- package/types/transform/generators/resolveStaticOxcValues/opaqueRuntime.js +263 -0
- package/types/transform/generators/resolveStaticOxcValues/processorStaticExport.d.ts +4 -0
- package/types/transform/generators/resolveStaticOxcValues/processorStaticExport.js +191 -0
- package/types/transform/generators/resolveStaticOxcValues/processorStaticModel.d.ts +40 -0
- package/types/transform/generators/resolveStaticOxcValues/processorStaticModel.js +516 -0
- package/types/transform/generators/resolveStaticOxcValues/processorTarget.d.ts +5 -0
- package/types/transform/generators/resolveStaticOxcValues/processorTarget.js +62 -0
- package/types/transform/generators/resolveStaticOxcValues/programAnalysis.d.ts +11 -0
- package/types/transform/generators/resolveStaticOxcValues/programAnalysis.js +133 -0
- package/types/transform/generators/resolveStaticOxcValues/prune.d.ts +15 -0
- package/types/transform/generators/resolveStaticOxcValues/prune.js +220 -0
- package/types/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.d.ts +2 -0
- package/types/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js +197 -0
- package/types/transform/generators/resolveStaticOxcValues/staticExpression.d.ts +25 -0
- package/types/transform/generators/resolveStaticOxcValues/staticExpression.js +391 -0
- package/types/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.d.ts +14 -0
- package/types/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js +304 -0
- package/types/transform/generators/resolveStaticOxcValues/types.d.ts +99 -0
- package/types/transform/generators/resolveStaticOxcValues/types.js +2 -0
- package/types/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.d.ts +7 -0
- package/types/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js +64 -0
- package/types/transform/generators/resolveStaticOxcValues.d.ts +1 -2
- package/types/transform/generators/resolveStaticOxcValues.js +1 -3235
- package/types/transform/generators/transform.js +63 -49
- package/types/transform/helpers/loadWywOptions.js +23 -3
- package/types/transform.js +3 -1
- package/types/utils/EventEmitter.d.ts +16 -1
- package/types/utils/EventEmitter.js +44 -9
- package/types/utils/applyOxcProcessors/applyOxcProcessors.d.ts +8 -0
- package/types/utils/applyOxcProcessors/applyOxcProcessors.js +167 -0
- package/types/utils/applyOxcProcessors/cleanupBindings.d.ts +12 -0
- package/types/utils/applyOxcProcessors/cleanupBindings.js +189 -0
- package/types/utils/applyOxcProcessors/cleanupRemovals.d.ts +16 -0
- package/types/utils/applyOxcProcessors/cleanupRemovals.js +482 -0
- package/types/utils/applyOxcProcessors/displayName.d.ts +9 -0
- package/types/utils/applyOxcProcessors/displayName.js +113 -0
- package/types/utils/applyOxcProcessors/expressionValues.d.ts +11 -0
- package/types/utils/applyOxcProcessors/expressionValues.js +170 -0
- package/types/utils/applyOxcProcessors/processorFactory.d.ts +7 -0
- package/types/utils/applyOxcProcessors/processorFactory.js +70 -0
- package/types/utils/applyOxcProcessors/processorUsages.d.ts +16 -0
- package/types/utils/applyOxcProcessors/processorUsages.js +163 -0
- package/types/utils/applyOxcProcessors/sameFileStaticValues.d.ts +23 -0
- package/types/utils/applyOxcProcessors/sameFileStaticValues.js +211 -0
- package/types/utils/applyOxcProcessors/shared.d.ts +10 -0
- package/types/utils/applyOxcProcessors/shared.js +37 -0
- package/types/utils/applyOxcProcessors/types.d.ts +88 -0
- package/types/utils/applyOxcProcessors/types.js +1 -0
- package/types/utils/applyOxcProcessors.d.ts +1 -16
- package/types/utils/applyOxcProcessors.js +1 -1391
- package/types/utils/collectOxcRuntime/normalizeRuntimeCode.d.ts +1 -0
- package/types/utils/collectOxcRuntime/normalizeRuntimeCode.js +185 -0
- package/types/utils/collectOxcRuntime/sourceMap.d.ts +2 -0
- package/types/utils/collectOxcRuntime/sourceMap.js +37 -0
- package/types/utils/collectOxcRuntime/types.d.ts +16 -0
- package/types/utils/collectOxcRuntime/types.js +1 -0
- package/types/utils/collectOxcRuntime.d.ts +2 -12
- package/types/utils/collectOxcRuntime.js +5 -224
- package/types/utils/collectOxcTemplateDependencies/expressionExtraction.d.ts +6 -0
- package/types/utils/collectOxcTemplateDependencies/expressionExtraction.js +550 -0
- package/types/utils/collectOxcTemplateDependencies/expressionReplacements.d.ts +11 -0
- package/types/utils/collectOxcTemplateDependencies/expressionReplacements.js +131 -0
- package/types/utils/collectOxcTemplateDependencies/scopeAnalysis.d.ts +20 -0
- package/types/utils/collectOxcTemplateDependencies/scopeAnalysis.js +434 -0
- package/types/utils/collectOxcTemplateDependencies/staticBindings.d.ts +7 -0
- package/types/utils/collectOxcTemplateDependencies/staticBindings.js +13 -0
- package/types/utils/collectOxcTemplateDependencies/staticEvaluator.d.ts +13 -0
- package/types/utils/collectOxcTemplateDependencies/staticEvaluator.js +626 -0
- package/types/utils/collectOxcTemplateDependencies/types.d.ts +116 -0
- package/types/utils/collectOxcTemplateDependencies/types.js +1 -0
- package/types/utils/collectOxcTemplateDependencies.d.ts +4 -38
- package/types/utils/collectOxcTemplateDependencies.js +3 -1580
- package/types/utils/nativeResolver.d.ts +13 -0
- package/types/utils/nativeResolver.js +91 -0
- package/types/utils/oxc/ast.d.ts +4 -0
- package/types/utils/oxc/ast.js +37 -0
- package/types/utils/oxc/parse.d.ts +3 -0
- package/types/utils/oxc/parse.js +2 -0
- package/types/utils/oxc/replacements.d.ts +12 -0
- package/types/utils/oxc/replacements.js +18 -0
- package/types/utils/oxc/sourceLocations.d.ts +5 -0
- package/types/utils/oxc/sourceLocations.js +63 -0
- package/types/utils/oxcPreevalStage/evalStrategy.d.ts +3 -0
- package/types/utils/oxcPreevalStage/evalStrategy.js +2 -0
- package/types/utils/oxcPreevalStage/prepareCode.d.ts +3 -0
- package/types/utils/oxcPreevalStage/prepareCode.js +20 -0
- package/types/utils/oxcPreevalStage/prevalExport.d.ts +1 -0
- package/types/utils/oxcPreevalStage/prevalExport.js +22 -0
- package/types/utils/oxcPreevalStage/processors.d.ts +10 -0
- package/types/utils/oxcPreevalStage/processors.js +16 -0
- package/types/utils/oxcPreevalStage/staticOverlay.d.ts +3 -0
- package/types/utils/oxcPreevalStage/staticOverlay.js +23 -0
- package/types/utils/oxcPreevalStage/types.d.ts +22 -0
- package/types/utils/oxcPreevalStage/types.js +1 -0
- package/types/utils/oxcPreevalStage.d.ts +2 -18
- package/types/utils/oxcPreevalStage.js +17 -79
- package/types/utils/oxcPreevalTransforms.js +14 -1
- package/types/utils/processorStaticSemantics.d.ts +13 -0
- package/types/utils/processorStaticSemantics.js +191 -0
- package/types/utils/resolveWithConditions.js +3 -3
- package/esm/eval/resolverStrategy.js +0 -51
- package/esm/eval/resolverStrategy.js.map +0 -1
- package/types/eval/resolverStrategy.d.ts +0 -13
- package/types/eval/resolverStrategy.js +0 -46
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAGA,SAAS,iBAAiB;AAgB1B,SAAS,6BAA6B;AAwItC,MAAM,UAAU,UACd,CAAC,CAAC,SACF,OAAO,UAAU,YACjB,UAAU,SACV,OAAQ,MAA6B,SAAS;AAEhD,MAAM,eAAe,SAAuB;CAC1C,MAAM,SAAiB,EAAE;CACzB,MAAM,SAAS;AAEf,QAAO,KAAK,OAAO,CAAC,SAAS,QAAQ;AACnC,MAAI,QAAQ,UAAU,QAAQ,WAAW,QAAQ,SAAS,QAAQ,SAAS;AACzE;;EAGF,MAAM,QAAQ,OAAO;AACrB,MAAI,OAAO,MAAM,EAAE;AACjB,UAAO,KAAK,MAAM;AAClB;;AAGF,MAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,SAAM,SAAS,SAAS;AACtB,QAAI,OAAO,KAAK,EAAE;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ED,QAAO,mBACL,MACA,UACA,UACA,SACA,UACA,YACD","names":[],"sources":["../../src/utils/collectOxcTemplateDependencies.ts"],"version":3,"sourcesContent":["/* eslint-disable no-restricted-syntax,no-continue,@typescript-eslint/no-use-before-define */\n\nimport type { ExpressionValue, Location } from '@wyw-in-js/shared';\nimport { ValueType } from '@wyw-in-js/shared';\nimport type {\n AssignmentExpression,\n Expression,\n ImportDeclaration,\n ImportSpecifier,\n MemberExpression,\n ModuleExportName,\n Node,\n Program,\n TemplateLiteral,\n UpdateExpression,\n VariableDeclaration,\n VariableDeclarator,\n} from 'oxc-parser';\n\nimport { parseOxcProgramCached } from './parseOxc';\n\ntype AnyNode = Node & Record<string, unknown>;\ntype OxcFunctionLikeNode = Node & {\n async: boolean;\n body: Node | null;\n id?: { name: string } | null;\n params: Node[];\n};\ntype BindingKind = 'function' | 'import' | 'param' | 'variable';\ntype ScopedDeclarationKind = 'const' | 'let' | 'var';\n\ntype Binding = {\n declarationKind?: ScopedDeclarationKind;\n declaredAt: number;\n declaration: VariableDeclaration | null;\n declarator: VariableDeclarator | null;\n functionNode?: OxcFunctionLikeNode | null;\n imported?: 'default' | '*' | string;\n importedFrom?: string;\n isRoot: boolean;\n kind: BindingKind;\n name: string;\n scope: Scope;\n};\n\ntype Replacement = {\n end: number;\n start: number;\n value: string;\n};\n\ntype SourceLocation = {\n end: Location;\n filename?: string;\n identifierName: string | null | undefined;\n start: Location;\n};\n\ntype SpanLookup = Set<string> | null;\n\ntype LocationLookup = (offset: number) => Location;\n\ntype ExpressionSpan = {\n end: number;\n start: number;\n};\n\ntype Scope = {\n bindings: Map<string, Binding>;\n depth: number;\n end: number;\n functionBoundary: boolean;\n params: Set<string>;\n parent: Scope | null;\n root: boolean;\n start: number;\n};\n\ntype ReferenceIdentifier = {\n end: number;\n name: string;\n start: number;\n};\n\nexport type OxcStaticImportReference = {\n imported: 'default' | string;\n importLocal?: string;\n local: string;\n source: string;\n};\n\nexport type OxcStaticValue = {\n name: string;\n value: unknown;\n};\n\nexport type OxcStaticValueCandidate = {\n imports: OxcStaticImportReference[];\n name: string;\n source: string;\n};\n\ntype TemplateExtractionResult = {\n code: string;\n dependencyNames: string[];\n expressionValues: Omit<ExpressionValue, 'buildCodeFrameError'>[];\n staticValueCandidates: OxcStaticValueCandidate[];\n staticValues: OxcStaticValue[];\n};\n\ntype ExtractionContext = {\n bindingResolutionCache: Map<string, Map<number, Binding | null>>;\n bindingsByName: Map<string, Binding[]>;\n code: string;\n currentInsertionPoint: number;\n currentExpressionStart: number;\n dependencyNames: Set<string>;\n expressionValues: Omit<ExpressionValue, 'buildCodeFrameError'>[];\n filename: string;\n hoistedBindingNames: Map<string, string>;\n hoistedDeclarations: Map<string, string>;\n hoistedDeclarationsByInsertionPoint: Map<number, string[]>;\n loc: LocationLookup;\n referencesByNode: WeakMap<Node, ReferenceIdentifier[]>;\n replacements: Replacement[];\n rootMutationsByBinding: Map<\n string,\n Array<AssignmentExpression | UpdateExpression>\n >;\n staticImportAliases: Map<string, string>;\n staticValueCandidates: OxcStaticValueCandidate[];\n staticValues: OxcStaticValue[];\n usedNames: Set<string>;\n};\n\ntype ExtractedExpression = {\n expressionCode: string;\n importedFrom: string[];\n kind: ValueType.FUNCTION | ValueType.LAZY;\n staticExpressionCode?: string;\n staticImports: OxcStaticImportReference[];\n staticValue?: unknown;\n};\n\ntype ProgramAnalysis = {\n bindingsByName: Map<string, Binding[]>;\n rootMutationsByBinding: Map<\n string,\n Array<AssignmentExpression | UpdateExpression>\n >;\n targetExpressions: Expression[];\n templateLiterals: TemplateLiteral[];\n usedNames: Set<string>;\n};\n\nconst isNode = (value: unknown): value is Node =>\n !!value &&\n typeof value === 'object' &&\n 'type' in value &&\n typeof (value as { type?: unknown }).type === 'string';\n\nconst getChildren = (node: Node): Node[] => {\n const result: Node[] = [];\n const record = node as AnyNode;\n\n Object.keys(record).forEach((key) => {\n if (key === 'type' || key === 'start' || key === 'end' || key === 'range') {\n return;\n }\n\n const value = record[key];\n if (isNode(value)) {\n result.push(value);\n return;\n }\n\n if (Array.isArray(value)) {\n value.forEach((item) => {\n if (isNode(item)) {\n result.push(item);\n }\n });\n }\n });\n\n return result;\n};\n\nconst parseOxc = (code: string, filename: string): Program => {\n return parseOxcProgramCached(filename, code, 'unambiguous');\n};\n\nconst toSpanKey = (start: number, end: number): string => `${start}:${end}`;\n\nconst createSpanLookup = (spans?: ExpressionSpan[]): SpanLookup => {\n if (!spans || spans.length === 0) {\n return null;\n }\n\n return new Set(spans.map((span) => toSpanKey(span.start, span.end)));\n};\n\nconst matchesSpanLookup = (\n node: Pick<Node, 'start' | 'end'>,\n spanLookup: SpanLookup\n): boolean => !spanLookup || spanLookup.has(toSpanKey(node.start, node.end));\n\nconst createLocationLookup = (code: string): LocationLookup => {\n const lineStarts = [0];\n for (let idx = 0; idx < code.length; idx += 1) {\n if (code[idx] === '\\n') {\n lineStarts.push(idx + 1);\n }\n }\n\n return (offset) => {\n let low = 0;\n let high = lineStarts.length - 1;\n\n while (low <= high) {\n const mid = Math.floor((low + high) / 2);\n const next = lineStarts[mid + 1] ?? Infinity;\n if (lineStarts[mid] <= offset && offset < next) {\n return {\n column: offset - lineStarts[mid],\n line: mid + 1,\n };\n }\n\n if (offset < lineStarts[mid]) {\n high = mid - 1;\n } else {\n low = mid + 1;\n }\n }\n\n const lastLine = lineStarts.length - 1;\n return {\n column: Math.max(0, offset - lineStarts[lastLine]),\n line: lastLine + 1,\n };\n };\n};\n\nconst getSourceLocation = (\n start: number,\n end: number,\n ctx: Pick<ExtractionContext, 'filename' | 'loc'>\n): SourceLocation => ({\n end: ctx.loc(end),\n filename: ctx.filename,\n identifierName: undefined,\n start: ctx.loc(start),\n});\n\nconst createScope = (\n parent: Scope | null,\n node: Pick<Node, 'start' | 'end'>,\n root = false,\n functionBoundary = false\n): Scope => ({\n bindings: new Map(),\n depth: parent ? parent.depth + 1 : 0,\n end: node.end,\n functionBoundary,\n params: new Set(),\n parent,\n root,\n start: node.start,\n});\n\nconst normalizeDeclarationKind = (\n declarationKind: VariableDeclaration['kind']\n): ScopedDeclarationKind => {\n if (declarationKind === 'var') {\n return 'var';\n }\n\n if (declarationKind === 'let') {\n return 'let';\n }\n\n return 'const';\n};\n\nconst moduleExportName = (node: ModuleExportName): string =>\n node.type === 'Literal' ? String(node.value) : node.name;\n\nconst getImportSpecifierInfo = (\n statement: ImportDeclaration,\n specifier: ImportDeclaration['specifiers'][number]\n): { imported: 'default' | '*' | string; local: string } | null => {\n const local = specifier.local?.name;\n if (!local) {\n return null;\n }\n\n if (specifier.type === 'ImportDefaultSpecifier') {\n return {\n imported: 'default',\n local,\n };\n }\n\n if (specifier.type === 'ImportNamespaceSpecifier') {\n return {\n imported: '*',\n local,\n };\n }\n\n if (\n statement.importKind === 'type' ||\n (specifier as ImportSpecifier).importKind === 'type'\n ) {\n return null;\n }\n\n return {\n imported: moduleExportName((specifier as ImportSpecifier).imported),\n local,\n };\n};\n\nconst getDeclarationScope = (\n scope: Scope,\n declarationKind: ScopedDeclarationKind\n): Scope => {\n if (declarationKind !== 'var') {\n return scope;\n }\n\n let current: Scope | null = scope;\n while (current && !current.functionBoundary) {\n current = current.parent;\n }\n\n return current ?? scope;\n};\n\nconst collectBindingNames = (node: Node): string[] => {\n if (node.type === 'Identifier') {\n return [node.name];\n }\n\n if (node.type === 'RestElement') {\n return collectBindingNames(node.argument);\n }\n\n if (node.type === 'AssignmentPattern') {\n return collectBindingNames(node.left);\n }\n\n if (node.type === 'ObjectPattern') {\n return node.properties.flatMap((property) =>\n property.type === 'RestElement'\n ? collectBindingNames(property.argument)\n : collectBindingNames(property.value)\n );\n }\n\n if (node.type === 'ArrayPattern') {\n return node.elements.flatMap((element) =>\n element ? collectBindingNames(element) : []\n );\n }\n\n if (node.type === 'TSParameterProperty') {\n return collectBindingNames(node.parameter);\n }\n\n return [];\n};\n\nconst isInTypeContext = (ancestors: Node[]): boolean =>\n ancestors.some(\n (ancestor) =>\n ancestor.type.startsWith('TS') || ancestor.type.startsWith('JSDoc')\n );\n\nconst isPropertyOnlyIdentifier = (node: Node, parent: Node | null): boolean =>\n !!parent &&\n parent.type === 'MemberExpression' &&\n parent.property === node &&\n !parent.computed;\n\nconst isObjectPropertyKey = (node: Node, parent: Node | null): boolean =>\n !!parent &&\n parent.type === 'Property' &&\n parent.key === node &&\n !parent.computed &&\n parent.value !== node;\n\nconst isBindingPosition = (node: Node, parent: Node | null): boolean => {\n if (!parent) {\n return false;\n }\n\n if (parent.type === 'VariableDeclarator' && parent.id === node) {\n return true;\n }\n\n if (\n (parent.type === 'FunctionDeclaration' ||\n parent.type === 'FunctionExpression' ||\n parent.type === 'ClassDeclaration' ||\n parent.type === 'ClassExpression') &&\n parent.id === node\n ) {\n return true;\n }\n\n if (\n (parent.type === 'ImportSpecifier' ||\n parent.type === 'ImportDefaultSpecifier' ||\n parent.type === 'ImportNamespaceSpecifier') &&\n 'local' in parent &&\n parent.local === node\n ) {\n return true;\n }\n\n return false;\n};\n\nconst visit = (\n node: Node,\n scope: Scope | null,\n enter: (\n node: Node,\n scope: Scope,\n parent: Node | null,\n ancestors: Node[]\n ) => void,\n parent: Node | null = null,\n ancestors: Node[] = []\n): void => {\n const visitNode = (\n currentNode: Node,\n currentScope: Scope | null,\n currentParent: Node | null\n ): void => {\n let nextScope: Scope;\n if (currentNode.type === 'Program') {\n nextScope = createScope(null, currentNode, true, true);\n } else if (\n currentNode.type === 'BlockStatement' ||\n currentNode.type === 'FunctionDeclaration' ||\n currentNode.type === 'FunctionExpression' ||\n currentNode.type === 'ArrowFunctionExpression'\n ) {\n nextScope = createScope(\n currentScope,\n currentNode,\n false,\n currentNode.type !== 'BlockStatement'\n );\n } else if (currentScope) {\n nextScope = currentScope;\n } else {\n nextScope = createScope(null, currentNode, false, true);\n }\n\n if (\n currentNode.type === 'FunctionDeclaration' ||\n currentNode.type === 'FunctionExpression' ||\n currentNode.type === 'ArrowFunctionExpression'\n ) {\n currentNode.params.forEach((param) => {\n collectBindingNames(param).forEach((name) => {\n nextScope.params.add(name);\n nextScope.bindings.set(name, {\n declaredAt: param.start,\n declaration: null,\n declarator: null,\n functionNode: null,\n isRoot: false,\n kind: 'param',\n name,\n scope: nextScope,\n });\n });\n });\n }\n\n enter(currentNode, nextScope, currentParent, ancestors);\n\n ancestors.push(currentNode);\n getChildren(currentNode).forEach((child) =>\n visitNode(child, nextScope, currentNode)\n );\n ancestors.pop();\n };\n\n visitNode(node, scope, parent);\n};\n\nconst analyzeProgram = (\n program: Program,\n {\n collectTargetExpressions = false,\n collectTemplateLiterals = false,\n expressionSpanLookup = null,\n templateSpanLookup = null,\n }: {\n collectTargetExpressions?: boolean;\n collectTemplateLiterals?: boolean;\n expressionSpanLookup?: SpanLookup;\n templateSpanLookup?: SpanLookup;\n } = {}\n): ProgramAnalysis => {\n const bindings = new Map<string, Binding[]>();\n const usedNames = new Set<string>();\n const templateLiterals: TemplateLiteral[] = [];\n const targetExpressions: Expression[] = [];\n\n const addBinding = (scope: Scope, binding: Binding): void => {\n scope.bindings.set(binding.name, binding);\n const existing = bindings.get(binding.name) ?? [];\n existing.push(binding);\n bindings.set(binding.name, existing);\n };\n\n const collectTargets = (node: Node, ancestors: Node[]): void => {\n if (\n collectTemplateLiterals &&\n node.type === 'TemplateLiteral' &&\n node.expressions.length > 0 &&\n !ancestors.some((ancestor) => ancestor.type === 'TemplateLiteral') &&\n matchesSpanLookup(node, templateSpanLookup)\n ) {\n templateLiterals.push(node);\n }\n\n if (\n collectTargetExpressions &&\n expressionSpanLookup &&\n matchesSpanLookup(node, expressionSpanLookup)\n ) {\n targetExpressions.push(node as Expression);\n }\n };\n\n visit(program, null, (node, scope, _parent, ancestors) => {\n collectTargets(node, ancestors);\n\n if (node.type === 'Identifier') {\n usedNames.add(node.name);\n }\n\n if (\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression'\n ) {\n node.params.forEach((param) => {\n collectBindingNames(param).forEach((name) => {\n const binding = scope.bindings.get(name);\n if (binding) {\n addBinding(scope, binding);\n }\n });\n });\n\n if (node.type !== 'FunctionDeclaration') {\n return;\n }\n }\n\n if (node.type === 'ImportDeclaration') {\n const source = node.source.value;\n node.specifiers.forEach((specifier) => {\n const importInfo = getImportSpecifierInfo(node, specifier);\n if (!importInfo) {\n return;\n }\n\n addBinding(scope, {\n declaredAt: specifier.start,\n declaration: null,\n declarator: null,\n functionNode: null,\n imported: importInfo.imported,\n importedFrom: source,\n isRoot: scope.root,\n kind: 'import',\n name: importInfo.local,\n scope,\n });\n });\n return;\n }\n\n if (node.type !== 'VariableDeclaration') {\n if (node.type === 'FunctionDeclaration' && node.id) {\n const declarationScope = scope.parent ?? scope;\n const binding: Binding = {\n declaredAt: node.start,\n declaration: null,\n declarator: null,\n functionNode: node,\n isRoot: declarationScope.root,\n kind: 'function',\n name: node.id.name,\n scope: declarationScope,\n };\n addBinding(declarationScope, binding);\n }\n\n return;\n }\n\n node.declarations.forEach((declarator) => {\n collectBindingNames(declarator.id).forEach((name) => {\n const declarationKind = normalizeDeclarationKind(node.kind);\n const declarationScope = getDeclarationScope(scope, declarationKind);\n const binding: Binding = {\n declarationKind,\n declaredAt: declarator.start,\n declaration: node,\n declarator,\n functionNode: null,\n isRoot: declarationScope.root,\n kind: 'variable',\n name,\n scope: declarationScope,\n };\n addBinding(declarationScope, binding);\n });\n });\n });\n\n return {\n bindingsByName: bindings,\n rootMutationsByBinding: collectRootMutations(program),\n targetExpressions: targetExpressions.sort((a, b) => a.start - b.start),\n templateLiterals,\n usedNames,\n };\n};\n\nconst resolveBindingAt = (\n ctx: Pick<ExtractionContext, 'bindingResolutionCache' | 'bindingsByName'>,\n name: string,\n referenceStart: number\n): Binding | undefined => {\n const cachedBindings = ctx.bindingResolutionCache.get(name);\n if (cachedBindings?.has(referenceStart)) {\n return cachedBindings.get(referenceStart) ?? undefined;\n }\n\n const bindings = ctx.bindingsByName.get(name);\n const bindingCache = cachedBindings ?? new Map<number, Binding | null>();\n if (!cachedBindings) {\n ctx.bindingResolutionCache.set(name, bindingCache);\n }\n\n if (!bindings || bindings.length === 0) {\n bindingCache.set(referenceStart, null);\n return undefined;\n }\n\n let binding: Binding | undefined;\n bindings.forEach((candidate) => {\n if (\n candidate.scope.start > referenceStart ||\n referenceStart >= candidate.scope.end\n ) {\n return;\n }\n\n if (\n !binding ||\n candidate.scope.depth > binding.scope.depth ||\n (candidate.scope.depth === binding.scope.depth &&\n candidate.declaredAt > binding.declaredAt)\n ) {\n binding = candidate;\n }\n });\n\n bindingCache.set(referenceStart, binding ?? null);\n return binding;\n};\n\nconst collectRootMutations = (\n program: Program\n): Map<string, Array<AssignmentExpression | UpdateExpression>> => {\n const mutations = new Map<\n string,\n Array<AssignmentExpression | UpdateExpression>\n >();\n\n const getRootMutationTarget = (\n node: Node\n ): { binding: string; path: Array<string | number> } | null => {\n if (node.type === 'Identifier') {\n return {\n binding: node.name,\n path: [],\n };\n }\n\n if (node.type !== 'MemberExpression') {\n return null;\n }\n\n const parent = getRootMutationTarget(node.object);\n if (!parent) {\n return null;\n }\n\n let key: string | number | null = null;\n if (\n node.computed &&\n node.property.type === 'Literal' &&\n (typeof node.property.value === 'string' ||\n typeof node.property.value === 'number')\n ) {\n key = node.property.value;\n } else if (!node.computed && node.property.type === 'Identifier') {\n key = node.property.name;\n }\n if (key === null) {\n return null;\n }\n\n return {\n binding: parent.binding,\n path: [...parent.path, key],\n };\n };\n\n program.body.forEach((statement) => {\n if (statement.type !== 'ExpressionStatement') {\n return;\n }\n\n const { expression } = statement;\n if (expression.type === 'AssignmentExpression') {\n const target = getRootMutationTarget(expression.left);\n if (!target || target.path.length === 0) {\n return;\n }\n\n const bucket = mutations.get(target.binding) ?? [];\n bucket.push(expression);\n mutations.set(target.binding, bucket);\n return;\n }\n\n if (expression.type === 'UpdateExpression') {\n const target = getRootMutationTarget(expression.argument);\n if (!target || target.path.length === 0) {\n return;\n }\n\n const bucket = mutations.get(target.binding) ?? [];\n bucket.push(expression);\n mutations.set(target.binding, bucket);\n }\n });\n\n return mutations;\n};\n\nconst hasLocalBinding = (scope: Scope, name: string): boolean => {\n let current: Scope | null = scope;\n\n while (current) {\n if (current.bindings.has(name)) {\n return true;\n }\n\n current = current.parent;\n }\n\n return false;\n};\n\nconst hasLocalBindingCached = (\n scope: Scope,\n name: string,\n cache: WeakMap<Scope, Map<string, boolean>>\n): boolean => {\n const scopeCache = cache.get(scope);\n if (scopeCache?.has(name)) {\n return scopeCache.get(name)!;\n }\n\n const result = hasLocalBinding(scope, name);\n const nextScopeCache = scopeCache ?? new Map<string, boolean>();\n nextScopeCache.set(name, result);\n if (!scopeCache) {\n cache.set(scope, nextScopeCache);\n }\n\n return result;\n};\n\nconst findReferences = (\n node: Node,\n referenceCache?: WeakMap<Node, ReferenceIdentifier[]>\n): ReferenceIdentifier[] => {\n const cachedReferences = referenceCache?.get(node);\n if (cachedReferences) {\n return cachedReferences;\n }\n\n const refs = new Map<string, ReferenceIdentifier>();\n const localBindingCache = new WeakMap<Scope, Map<string, boolean>>();\n\n visit(node, null, (current, scope, parent, ancestors) => {\n if (\n current.type !== 'Identifier' ||\n isInTypeContext(ancestors) ||\n isBindingPosition(current, parent) ||\n isPropertyOnlyIdentifier(current, parent) ||\n isObjectPropertyKey(current, parent) ||\n hasLocalBindingCached(scope, current.name, localBindingCache)\n ) {\n return;\n }\n\n const key = `${current.start}:${current.end}:${current.name}`;\n refs.set(key, {\n end: current.end,\n name: current.name,\n start: current.start,\n });\n });\n\n const resolvedReferences = [...refs.values()];\n referenceCache?.set(node, resolvedReferences);\n return resolvedReferences;\n};\n\nconst isBindingDeclaredWithin = (binding: Binding, container: Node): boolean =>\n container.start <= binding.declaredAt && binding.declaredAt < container.end;\n\nconst literalCode = (value: unknown): string | null => {\n if (typeof value === 'number') {\n return Number.isFinite(value) ? JSON.stringify(value) : null;\n }\n\n if (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'boolean'\n ) {\n return JSON.stringify(value);\n }\n\n if (Array.isArray(value)) {\n return JSON.stringify(value);\n }\n\n if (typeof value === 'object' && value !== null) {\n return `(${JSON.stringify(value)})`;\n }\n\n return null;\n};\n\nconst isStaticSerializableValue = (value: unknown): boolean =>\n literalCode(value) !== null;\n\nconst cloneStaticValue = (value: unknown): unknown => {\n if (Array.isArray(value)) {\n return value.map((item) => cloneStaticValue(item));\n }\n\n if (typeof value === 'object' && value !== null) {\n return Object.fromEntries(\n Object.entries(value).map(([key, item]) => [key, cloneStaticValue(item)])\n );\n }\n\n return value;\n};\n\nconst getObjectMember = (\n objectValue: unknown,\n property: string | number\n): unknown | undefined => {\n if (\n objectValue === null ||\n objectValue === undefined ||\n (typeof objectValue !== 'object' &&\n typeof objectValue !== 'string' &&\n typeof objectValue !== 'number' &&\n typeof objectValue !== 'boolean')\n ) {\n return undefined;\n }\n\n return (objectValue as Record<string | number, unknown>)[property];\n};\n\ntype EvalEnv = Map<string, unknown>;\n\nconst oxcStaticCallableValue = Symbol('wyw.oxc.staticCallableValue');\n\ntype OxcStaticCallableValue = {\n [oxcStaticCallableValue]: unknown;\n};\n\nconst isOxcStaticCallableValue = (\n value: unknown\n): value is OxcStaticCallableValue =>\n typeof value === 'object' &&\n value !== null &&\n oxcStaticCallableValue in value;\n\nconst unwrapOxcStaticCallableValue = (value: unknown): unknown =>\n isOxcStaticCallableValue(value) ? value[oxcStaticCallableValue] : value;\n\nexport const createOxcStaticCallableValue = (\n value: unknown\n): OxcStaticCallableValue => ({\n [oxcStaticCallableValue]: value,\n});\n\nconst assignPatternValue = (\n pattern: Node,\n value: unknown,\n ctx: ExtractionContext,\n env: EvalEnv,\n stack: string[]\n): boolean => {\n if (pattern.type === 'Identifier') {\n env.set(pattern.name, value);\n return true;\n }\n\n if (pattern.type === 'AssignmentPattern') {\n return assignPatternValue(\n pattern.left,\n value === undefined\n ? evaluateStatic(pattern.right, ctx, env, stack)\n : value,\n ctx,\n env,\n stack\n );\n }\n\n if (pattern.type === 'ObjectPattern') {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n return pattern.properties.every((property) => {\n if (property.type === 'RestElement') {\n return false;\n }\n\n let key: unknown;\n if (property.computed) {\n key = evaluateStatic(property.key as Expression, ctx, env, stack);\n } else if (property.key.type === 'Identifier') {\n key = property.key.name;\n } else if (property.key.type === 'Literal') {\n key = property.key.value;\n }\n if (key === undefined || key === null) {\n return false;\n }\n\n return assignPatternValue(\n property.value,\n getObjectMember(value, key as string | number),\n ctx,\n env,\n stack\n );\n });\n }\n\n if (pattern.type === 'ArrayPattern') {\n if (!Array.isArray(value)) {\n return false;\n }\n\n return pattern.elements.every((element, index) =>\n element\n ? assignPatternValue(element, value[index], ctx, env, stack)\n : true\n );\n }\n\n return false;\n};\n\nconst applyRootMutation = (\n bindingName: string,\n baseValue: unknown,\n mutation: AssignmentExpression | UpdateExpression,\n ctx: ExtractionContext,\n env: EvalEnv,\n stack: string[]\n): unknown | undefined => {\n const resolvePath = (node: Node): { path: Array<string | number> } | null => {\n if (node.type === 'Identifier') {\n return node.name === bindingName ? { path: [] } : null;\n }\n\n if (node.type !== 'MemberExpression') {\n return null;\n }\n\n const parent = resolvePath(node.object);\n if (!parent) {\n return null;\n }\n\n let key: unknown;\n if (node.computed) {\n key = evaluateStatic(node.property as Expression, ctx, env, stack);\n } else if (node.property.type === 'Identifier') {\n key = node.property.name;\n }\n if (\n key === undefined ||\n key === null ||\n (typeof key !== 'string' && typeof key !== 'number')\n ) {\n return null;\n }\n\n return {\n path: [...parent.path, key],\n };\n };\n\n const pathInfo = resolvePath(\n mutation.type === 'AssignmentExpression' ? mutation.left : mutation.argument\n );\n if (!pathInfo) {\n return undefined;\n }\n\n const cloned = cloneStaticValue(baseValue);\n if (pathInfo.path.length === 0) {\n if (mutation.type !== 'AssignmentExpression') {\n return undefined;\n }\n\n return evaluateStatic(mutation.right, ctx, env, stack);\n }\n\n let target = cloned as Record<string | number, unknown>;\n for (let idx = 0; idx < pathInfo.path.length - 1; idx += 1) {\n const key = pathInfo.path[idx];\n const next = target?.[key];\n if (typeof next !== 'object' || next === null) {\n return undefined;\n }\n\n target = next as Record<string | number, unknown>;\n }\n\n const lastKey = pathInfo.path[pathInfo.path.length - 1]!;\n if (mutation.type === 'AssignmentExpression') {\n const nextValue = evaluateStatic(mutation.right, ctx, env, stack);\n if (nextValue === undefined) {\n return undefined;\n }\n\n target[lastKey] = nextValue;\n return cloned;\n }\n\n const currentValue = target[lastKey];\n if (typeof currentValue !== 'number') {\n return undefined;\n }\n\n target[lastKey] =\n mutation.operator === '++' ? currentValue + 1 : currentValue - 1;\n return cloned;\n};\n\nconst evaluateFunctionCall = (\n fn: OxcFunctionLikeNode,\n args: unknown[],\n ctx: ExtractionContext,\n env: EvalEnv,\n stack: string[]\n): unknown | undefined => {\n if (fn.async || !fn.body) {\n return undefined;\n }\n\n const localEnv = new Map(env);\n for (let idx = 0; idx < fn.params.length; idx += 1) {\n if (!assignPatternValue(fn.params[idx], args[idx], ctx, localEnv, stack)) {\n return undefined;\n }\n }\n\n if (fn.body.type !== 'BlockStatement') {\n return evaluateStatic(fn.body as Expression, ctx, localEnv, stack);\n }\n\n for (const statement of fn.body.body) {\n if (statement.type === 'VariableDeclaration') {\n for (const declarator of statement.declarations) {\n const value = declarator.init\n ? evaluateStatic(declarator.init, ctx, localEnv, stack)\n : undefined;\n if (!assignPatternValue(declarator.id, value, ctx, localEnv, stack)) {\n return undefined;\n }\n }\n continue;\n }\n\n if (statement.type === 'ReturnStatement') {\n if (!statement.argument) {\n return undefined;\n }\n\n return evaluateStatic(statement.argument, ctx, localEnv, stack);\n }\n\n return undefined;\n }\n\n return undefined;\n};\n\nconst getConstantReplacement = (\n binding: Binding | undefined,\n ctx: ExtractionContext\n): string | null => {\n const init = binding?.declarator?.init;\n if (!init) {\n return null;\n }\n\n if (init.type === 'Literal') {\n return literalCode(init.value);\n }\n\n if (\n init.type === 'ObjectExpression' &&\n binding?.isRoot &&\n binding.declarator?.id.type === 'Identifier'\n ) {\n const evaluated = evaluateStatic(binding.declarator.id, ctx);\n return literalCode(evaluated);\n }\n\n return null;\n};\n\nconst replaceIdentifierReferences = (\n expression: Expression,\n replacements: Map<string, string>,\n code: string\n): string => {\n const localReplacements: Replacement[] = [];\n const ancestors: Node[] = [];\n\n const walk = (current: Node, parent: Node | null) => {\n if (\n current.type === 'Identifier' &&\n replacements.has(current.name) &&\n !isInTypeContext(ancestors) &&\n !isBindingPosition(current, parent) &&\n !isPropertyOnlyIdentifier(current, parent) &&\n !isObjectPropertyKey(current, parent)\n ) {\n const replacement = replacements.get(current.name)!;\n // Shorthand property `{ width }` → `{ width: 500 }` when the\n // identifier is the value side of a shorthand ObjectProperty.\n const isShorthandValue =\n !!parent &&\n parent.type === 'Property' &&\n (parent as unknown as { shorthand?: boolean }).shorthand &&\n parent.value === current;\n localReplacements.push({\n start: isShorthandValue ? parent.start : current.start,\n end: current.end,\n value: isShorthandValue\n ? `${current.name}: ${replacement}`\n : replacement,\n });\n }\n\n ancestors.push(current);\n getChildren(current).forEach((child) => walk(child, current));\n ancestors.pop();\n };\n\n walk(expression, null);\n\n let result = code.slice(expression.start, expression.end);\n localReplacements\n .sort((a, b) => b.start - a.start)\n .forEach((replacement) => {\n const start = replacement.start - expression.start;\n const end = replacement.end - expression.start;\n result = result.slice(0, start) + replacement.value + result.slice(end);\n });\n\n return result;\n};\n\nconst applyExpressionReplacements = (\n expression: Expression,\n replacements: Replacement[],\n code: string\n): string => {\n let result = code.slice(expression.start, expression.end);\n replacements\n .sort((a, b) => b.start - a.start)\n .forEach((replacement) => {\n const start = replacement.start - expression.start;\n const end = replacement.end - expression.start;\n result = result.slice(0, start) + replacement.value + result.slice(end);\n });\n return result;\n};\n\nconst staticImportAliasPart = (value: string): string =>\n value.replace(/[^A-Za-z0-9_$]/g, '_') || 'value';\n\nconst allocateStaticImportAlias = (\n binding: Binding,\n imported: string,\n ctx: ExtractionContext\n): string => {\n const key = `${binding.importedFrom ?? ''}\\0${binding.name}\\0${imported}`;\n const existing = ctx.staticImportAliases.get(key);\n if (existing) {\n return existing;\n }\n\n const namespacePart = staticImportAliasPart(binding.name);\n const importedPart = staticImportAliasPart(imported);\n let alias = `_wyw_static_${namespacePart}_${importedPart}`;\n let idx = 1;\n while (ctx.usedNames.has(alias)) {\n idx += 1;\n alias = `_wyw_static_${namespacePart}_${importedPart}_${idx}`;\n }\n\n ctx.usedNames.add(alias);\n ctx.staticImportAliases.set(key, alias);\n return alias;\n};\n\nconst staticMemberPropertyName = (\n expression: MemberExpression\n): string | null => {\n if (!expression.computed && expression.property.type === 'Identifier') {\n return expression.property.name;\n }\n\n if (\n expression.computed &&\n expression.property.type === 'Literal' &&\n typeof expression.property.value === 'string'\n ) {\n return expression.property.value;\n }\n\n return null;\n};\n\nconst collectStaticNamespaceMemberReferences = (\n expression: Expression,\n ctx: ExtractionContext\n): {\n coveredReferenceStarts: Set<number>;\n imports: OxcStaticImportReference[];\n replacements: Replacement[];\n} => {\n const coveredReferenceStarts = new Set<number>();\n const imports = new Map<string, OxcStaticImportReference>();\n const replacements: Replacement[] = [];\n\n const walk = (node: Node): void => {\n if (node.type === 'MemberExpression' && node.object.type === 'Identifier') {\n const binding = resolveBindingAt(\n ctx,\n node.object.name,\n node.object.start\n );\n const imported = staticMemberPropertyName(node);\n if (\n binding?.importedFrom &&\n binding.imported === '*' &&\n imported !== null\n ) {\n const alias = allocateStaticImportAlias(binding, imported, ctx);\n imports.set(`${binding.importedFrom}\\0${imported}\\0${alias}`, {\n imported,\n importLocal: binding.name,\n local: alias,\n source: binding.importedFrom,\n });\n replacements.push({\n end: node.end,\n start: node.start,\n value: alias,\n });\n coveredReferenceStarts.add(node.object.start);\n }\n }\n\n getChildren(node).forEach(walk);\n };\n\n walk(expression);\n\n return {\n coveredReferenceStarts,\n imports: [...imports.values()],\n replacements,\n };\n};\n\nconst isProcessEnvMember = (node: Node): boolean => {\n if (node.type !== 'MemberExpression' || node.computed) {\n return false;\n }\n\n if (\n node.property.type !== 'Identifier' ||\n node.property.name !== 'env'\n ) {\n return false;\n }\n\n return node.object.type === 'Identifier' && node.object.name === 'process';\n};\n\nconst evaluateBinary = (\n expression: Expression,\n ctx: ExtractionContext,\n env: EvalEnv = new Map(),\n stack: string[] = []\n): unknown | undefined => {\n if (expression.type !== 'BinaryExpression') {\n return undefined;\n }\n\n const left = evaluateStatic(expression.left as Expression, ctx, env, stack);\n const right = evaluateStatic(expression.right as Expression, ctx, env, stack);\n if (left === undefined || right === undefined) {\n return undefined;\n }\n\n if (expression.operator === '+') {\n if (typeof left === 'number' && typeof right === 'number') {\n return left + right;\n }\n\n if (\n (typeof left === 'string' || typeof left === 'number') &&\n (typeof right === 'string' || typeof right === 'number')\n ) {\n return `${left}${right}`;\n }\n }\n\n if (typeof left === 'number' && typeof right === 'number') {\n switch (expression.operator) {\n case '-':\n return left - right;\n case '*':\n return left * right;\n case '/':\n return left / right;\n case '%':\n return left % right;\n case '**':\n return left ** right;\n default:\n break;\n }\n }\n\n return undefined;\n};\n\nconst evaluateStatic = (\n expression: Expression,\n ctx: ExtractionContext,\n env: EvalEnv = new Map(),\n stack: string[] = []\n): unknown | undefined => {\n if (\n expression.type === 'TSAsExpression' ||\n expression.type === 'TSSatisfiesExpression' ||\n expression.type === 'TSNonNullExpression' ||\n expression.type === 'TSInstantiationExpression' ||\n expression.type === 'TSTypeAssertion' ||\n expression.type === 'ParenthesizedExpression'\n ) {\n return evaluateStatic(expression.expression as Expression, ctx, env, stack);\n }\n\n if (expression.type === 'Literal') {\n return expression.value;\n }\n\n if (expression.type === 'UnaryExpression') {\n if (expression.operator === 'typeof') {\n const argIsProcessEnvAccess =\n expression.argument.type === 'MemberExpression' &&\n isProcessEnvMember(expression.argument.object);\n const arg = evaluateStatic(\n expression.argument as Expression,\n ctx,\n env,\n stack\n );\n if (arg === undefined) {\n return argIsProcessEnvAccess ? 'undefined' : undefined;\n }\n\n return typeof arg;\n }\n\n const arg = evaluateStatic(\n expression.argument as Expression,\n ctx,\n env,\n stack\n );\n if (arg === undefined) {\n return undefined;\n }\n\n switch (expression.operator) {\n case '-':\n return typeof arg === 'number' ? -arg : undefined;\n case '+':\n return typeof arg === 'number' ? +arg : undefined;\n case '!':\n return !arg;\n case '~':\n return typeof arg === 'number' ? ~arg : undefined;\n case 'void':\n return undefined;\n default:\n return undefined;\n }\n }\n\n if (expression.type === 'LogicalExpression') {\n const left = evaluateStatic(expression.left, ctx, env, stack);\n // process.env.X access is the only source we trust as \"deterministically\n // undefined\" — it's a build-time lookup we control. For everything else,\n // undefined means \"couldn't evaluate\" and we must bail to avoid inlining\n // a wrong fallback when the runtime value isn't actually nullish.\n const leftIsProcessEnvAccess =\n expression.left.type === 'MemberExpression' &&\n isProcessEnvMember(expression.left.object);\n\n if (left === undefined && !leftIsProcessEnvAccess) {\n return undefined;\n }\n\n if (expression.operator === '||') {\n return left || evaluateStatic(expression.right, ctx, env, stack);\n }\n\n if (expression.operator === '??') {\n return left ?? evaluateStatic(expression.right, ctx, env, stack);\n }\n\n if (expression.operator === '&&') {\n return left && evaluateStatic(expression.right, ctx, env, stack);\n }\n\n return undefined;\n }\n\n if (expression.type === 'ConditionalExpression') {\n const test = evaluateStatic(expression.test, ctx, env, stack);\n if (test === undefined) {\n return undefined;\n }\n\n return evaluateStatic(\n test ? expression.consequent : expression.alternate,\n ctx,\n env,\n stack\n );\n }\n\n if (expression.type === 'TemplateLiteral') {\n let result = '';\n\n for (let idx = 0; idx < expression.quasis.length; idx += 1) {\n result += expression.quasis[idx]?.value.cooked ?? '';\n\n const nextExpression = expression.expressions[idx];\n if (!nextExpression) {\n continue;\n }\n\n const value = evaluateStatic(nextExpression, ctx, env, stack);\n if (\n value === undefined ||\n (typeof value !== 'string' && typeof value !== 'number')\n ) {\n return undefined;\n }\n\n result += String(value);\n }\n\n return result;\n }\n\n if (expression.type === 'Identifier') {\n if (env.has(expression.name)) {\n return unwrapOxcStaticCallableValue(env.get(expression.name));\n }\n\n const binding = resolveBindingAt(ctx, expression.name, expression.start);\n if (!binding || binding.importedFrom) {\n return undefined;\n }\n\n if (binding.kind === 'param') {\n return undefined;\n }\n\n if (stack.includes(binding.name)) {\n return undefined;\n }\n\n let value: unknown | undefined;\n const { declarator } = binding;\n const init = declarator?.init;\n if (init) {\n if (declarator.id.type !== 'Identifier') {\n return undefined;\n }\n\n value = evaluateStatic(init, ctx, env, [...stack, binding.name]);\n } else if (binding.functionNode) {\n value = binding.functionNode;\n }\n\n if (\n value !== undefined &&\n binding.isRoot &&\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value)\n ) {\n const mutations = ctx.rootMutationsByBinding.get(binding.name) ?? [];\n let nextValue = cloneStaticValue(value);\n for (const mutation of mutations) {\n if (mutation.start >= ctx.currentExpressionStart) {\n break;\n }\n\n const applied = applyRootMutation(\n binding.name,\n nextValue,\n mutation,\n ctx,\n env,\n [...stack, binding.name]\n );\n if (applied === undefined) {\n return undefined;\n }\n\n nextValue = applied;\n }\n\n return nextValue;\n }\n\n return value;\n }\n\n if (expression.type === 'ObjectExpression') {\n const result: Record<string, unknown> = {};\n\n for (const property of expression.properties) {\n if (property.type === 'SpreadElement') {\n const spreadValue = evaluateStatic(property.argument, ctx, env, stack);\n if (typeof spreadValue !== 'object' || spreadValue === null) {\n return undefined;\n }\n\n Object.assign(result, spreadValue);\n continue;\n }\n\n let key: unknown;\n if (property.computed) {\n key = evaluateStatic(property.key as Expression, ctx, env, stack);\n } else if (property.key.type === 'Identifier') {\n key = property.key.name;\n } else if (property.key.type === 'Literal') {\n key = property.key.value;\n }\n if (\n key === undefined ||\n key === null ||\n (typeof key !== 'string' && typeof key !== 'number')\n ) {\n return undefined;\n }\n\n const value = evaluateStatic(property.value, ctx, env, stack);\n if (value === undefined) {\n return undefined;\n }\n\n result[key] = value;\n }\n\n return result;\n }\n\n if (expression.type === 'ArrayExpression') {\n const result: unknown[] = [];\n\n for (const element of expression.elements) {\n if (!element) {\n return undefined;\n }\n\n if (element.type === 'SpreadElement') {\n const spreadValue = evaluateStatic(element.argument, ctx, env, stack);\n if (!Array.isArray(spreadValue)) {\n return undefined;\n }\n\n result.push(...spreadValue);\n continue;\n }\n\n const value = evaluateStatic(element, ctx, env, stack);\n if (value === undefined) {\n return undefined;\n }\n\n result.push(value);\n }\n\n return result;\n }\n\n if (expression.type === 'MemberExpression') {\n let key: unknown;\n if (expression.computed) {\n key = evaluateStatic(expression.property as Expression, ctx, env, stack);\n } else if (expression.property.type === 'Identifier') {\n key = expression.property.name;\n }\n if (\n key === undefined ||\n key === null ||\n (typeof key !== 'string' && typeof key !== 'number')\n ) {\n return undefined;\n }\n\n if (\n isProcessEnvMember(expression.object) &&\n typeof key === 'string' &&\n !env.has('process')\n ) {\n // Treat process.env.X as deterministically undefined at build time.\n // Reading from real process.env would couple the bundle to whatever\n // happens to be set on the build machine; falling back to the\n // ?? / || branch (or a runtime read) is more predictable.\n return undefined;\n }\n\n const objectValue = evaluateStatic(expression.object, ctx, env, stack);\n if (objectValue === undefined) {\n return undefined;\n }\n\n return getObjectMember(objectValue, key);\n }\n\n if (expression.type === 'NewExpression') {\n if (\n expression.callee.type !== 'Identifier' ||\n expression.arguments.length !== 1\n ) {\n return undefined;\n }\n\n const [argument] = expression.arguments;\n if (!argument || argument.type === 'SpreadElement') {\n return undefined;\n }\n\n const value = evaluateStatic(argument, ctx, env, stack);\n if (value === undefined) {\n return undefined;\n }\n\n if (expression.callee.name === 'String') {\n return String(value);\n }\n\n if (expression.callee.name === 'Number') {\n return Number(value);\n }\n\n if (expression.callee.name === 'Boolean') {\n return Boolean(value);\n }\n\n return undefined;\n }\n\n if (expression.type === 'CallExpression') {\n if (expression.callee.type === 'Identifier') {\n const args = expression.arguments.map((arg) =>\n arg.type === 'SpreadElement'\n ? undefined\n : evaluateStatic(arg, ctx, env, stack)\n );\n if (args.some((value) => value === undefined)) {\n return undefined;\n }\n\n const staticCallable = env.get(expression.callee.name);\n if (\n isOxcStaticCallableValue(staticCallable) &&\n expression.arguments.length === 0\n ) {\n return unwrapOxcStaticCallableValue(staticCallable);\n }\n\n if (expression.callee.name === 'String' && args.length === 1) {\n return String(args[0]);\n }\n\n if (expression.callee.name === 'Number' && args.length === 1) {\n return Number(args[0]);\n }\n\n if (expression.callee.name === 'Boolean' && args.length === 1) {\n return Boolean(args[0]);\n }\n\n const binding = resolveBindingAt(\n ctx,\n expression.callee.name,\n expression.callee.start\n );\n const fn = binding?.functionNode ?? binding?.declarator?.init;\n if (\n fn &&\n (fn.type === 'ArrowFunctionExpression' ||\n fn.type === 'FunctionDeclaration' ||\n fn.type === 'FunctionExpression')\n ) {\n return evaluateFunctionCall(fn, args, ctx, env, [\n ...stack,\n expression.callee.name,\n ]);\n }\n }\n\n if (expression.callee.type === 'MemberExpression') {\n const objectValue = evaluateStatic(\n expression.callee.object,\n ctx,\n env,\n stack\n );\n let key: unknown;\n if (expression.callee.computed) {\n key = evaluateStatic(\n expression.callee.property as Expression,\n ctx,\n env,\n stack\n );\n } else if (expression.callee.property.type === 'Identifier') {\n key = expression.callee.property.name;\n }\n if (typeof objectValue === 'string') {\n if (key === 'toLowerCase' && expression.arguments.length === 0) {\n return objectValue.toLowerCase();\n }\n\n if (key === 'toUpperCase' && expression.arguments.length === 0) {\n return objectValue.toUpperCase();\n }\n }\n }\n }\n\n return evaluateBinary(expression, ctx, env, stack);\n};\n\nconst allocateExpressionName = (ctx: ExtractionContext): string => {\n let base = '_exp';\n let idx = 1;\n while (ctx.usedNames.has(base)) {\n idx += 1;\n base = `_exp${idx}`;\n }\n\n ctx.usedNames.add(base);\n return base;\n};\n\nconst hoistedBindingKey = (binding: Binding): string =>\n `${binding.scope.start}:${binding.scope.end}:${binding.declaredAt}:${binding.name}`;\n\nconst allocateHoistedBindingName = (\n originalName: string,\n ctx: ExtractionContext\n): string => {\n const sanitized = originalName.replace(/[^A-Za-z0-9_$]/g, '_') || 'hoisted';\n const base = /^[A-Za-z_$]/.test(sanitized) ? `_${sanitized}` : '_hoisted';\n let candidate = base;\n let idx = 2;\n\n while (ctx.usedNames.has(candidate)) {\n candidate = `${base}${idx}`;\n idx += 1;\n }\n\n ctx.usedNames.add(candidate);\n return candidate;\n};\n\nconst getHoistedBindingName = (\n binding: Binding,\n ctx: ExtractionContext\n): string => {\n const key = hoistedBindingKey(binding);\n const existing = ctx.hoistedBindingNames.get(key);\n if (existing) {\n return existing;\n }\n\n const next = allocateHoistedBindingName(binding.name, ctx);\n ctx.hoistedBindingNames.set(key, next);\n return next;\n};\n\nconst declarationInitCode = (\n init: Expression,\n ctx: ExtractionContext\n): string => {\n const renamedDependencies = new Map<string, string>();\n findReferences(init, ctx.referencesByNode).forEach(({ name, start }) => {\n const dependency = resolveBindingAt(ctx, name, start);\n if (\n !dependency ||\n dependency.importedFrom ||\n dependency.isRoot ||\n dependency.declarator?.id.type !== 'Identifier'\n ) {\n return;\n }\n\n renamedDependencies.set(name, getHoistedBindingName(dependency, ctx));\n });\n\n return renamedDependencies.size > 0\n ? replaceIdentifierReferences(init, renamedDependencies, ctx.code)\n : ctx.code.slice(init.start, init.end);\n};\n\nconst addHoistedCode = (\n key: string,\n code: string,\n ctx: ExtractionContext\n): void => {\n if (ctx.hoistedDeclarations.has(key)) {\n return;\n }\n\n ctx.hoistedDeclarations.set(key, code);\n const declarations =\n ctx.hoistedDeclarationsByInsertionPoint.get(ctx.currentInsertionPoint) ??\n [];\n declarations.push(code);\n ctx.hoistedDeclarationsByInsertionPoint.set(\n ctx.currentInsertionPoint,\n declarations\n );\n};\n\nconst declarationCode = (binding: Binding, ctx: ExtractionContext): string => {\n const { declarator } = binding;\n if (!declarator) {\n return '';\n }\n\n const { id } = declarator;\n if (id.type !== 'Identifier') {\n const idCode = ctx.code.slice(id.start, id.end);\n if (!declarator.init) {\n return `let ${idCode};`;\n }\n\n return `let ${idCode} = ${declarationInitCode(declarator.init, ctx)};`;\n }\n\n const hoistedName = getHoistedBindingName(binding, ctx);\n if (!declarator.init) {\n return `let ${hoistedName};`;\n }\n\n return `let ${hoistedName} = ${declarationInitCode(declarator.init, ctx)};`;\n};\n\nconst assertHoistable = (\n binding: Binding,\n ctx: ExtractionContext,\n stack: string[] = []\n): void => {\n if (!binding.declarator?.init || binding.importedFrom || binding.isRoot) {\n return;\n }\n\n if (stack.includes(binding.name)) {\n return;\n }\n\n const refs = findReferences(binding.declarator.init, ctx.referencesByNode);\n refs.forEach(({ name, start }) => {\n const nextBinding = resolveBindingAt(ctx, name, start);\n if (!nextBinding) {\n return;\n }\n\n if (nextBinding.kind === 'param') {\n throw new Error(\n `This identifier cannot be used in the template, because it is a function parameter.`\n );\n }\n\n assertHoistable(nextBinding, ctx, [...stack, binding.name]);\n });\n};\n\nconst addHoistedDeclaration = (\n binding: Binding,\n ctx: ExtractionContext,\n stack: string[] = []\n): void => {\n if (\n !binding.declaration ||\n !binding.declarator ||\n binding.importedFrom ||\n binding.isRoot ||\n stack.includes(binding.name)\n ) {\n return;\n }\n\n const hoistSource = binding.declarator.init ?? binding.declarator;\n findReferences(hoistSource, ctx.referencesByNode).forEach(\n ({ name, start }) => {\n const dependency = resolveBindingAt(ctx, name, start);\n if (dependency) {\n addHoistedDeclaration(dependency, ctx, [...stack, binding.name]);\n }\n }\n );\n\n if (!ctx.hoistedDeclarations.has(binding.name)) {\n addHoistedCode(binding.name, declarationCode(binding, ctx), ctx);\n }\n};\n\nconst literalExpressionValue = (\n expression: Expression,\n ctx: ExtractionContext\n): Omit<ExpressionValue, 'buildCodeFrameError'> | null => {\n if (expression.type !== 'Literal') {\n return null;\n }\n\n if (\n expression.value !== null &&\n typeof expression.value !== 'string' &&\n typeof expression.value !== 'number' &&\n typeof expression.value !== 'boolean'\n ) {\n return null;\n }\n\n let type:\n | 'BooleanLiteral'\n | 'NullLiteral'\n | 'NumericLiteral'\n | 'StringLiteral';\n if (expression.value === null) {\n type = 'NullLiteral';\n } else if (typeof expression.value === 'string') {\n type = 'StringLiteral';\n } else if (typeof expression.value === 'number') {\n type = 'NumericLiteral';\n } else {\n type = 'BooleanLiteral';\n }\n\n const loc = getSourceLocation(expression.start, expression.end, ctx);\n const ex =\n expression.value === null\n ? { loc, type }\n : {\n loc,\n type,\n value: expression.value,\n };\n\n return {\n ex,\n kind: ValueType.CONST,\n source: ctx.code.slice(expression.start, expression.end),\n value: expression.value,\n } as unknown as Omit<ExpressionValue, 'buildCodeFrameError'>;\n};\n\nconst extractExpression = (\n expression: Expression,\n ctx: ExtractionContext,\n evaluate: boolean\n): ExtractedExpression => {\n const source = ctx.code.slice(expression.start, expression.end);\n const isFunction =\n expression.type === 'FunctionExpression' ||\n expression.type === 'ArrowFunctionExpression';\n\n if (evaluate) {\n const evaluated = evaluateStatic(expression, ctx);\n const literal = literalCode(evaluated);\n if (literal) {\n findReferences(expression, ctx.referencesByNode).forEach(({ name }) =>\n ctx.dependencyNames.add(name)\n );\n return {\n expressionCode: literal,\n importedFrom: [],\n kind: isFunction ? ValueType.FUNCTION : ValueType.LAZY,\n staticImports: [],\n staticValue: isStaticSerializableValue(evaluated)\n ? cloneStaticValue(evaluated)\n : undefined,\n };\n }\n }\n\n const identifierReplacements = new Map<string, string>();\n const importedFrom: string[] = [];\n const namespaceStatic = collectStaticNamespaceMemberReferences(\n expression,\n ctx\n );\n const staticImports: OxcStaticImportReference[] = [\n ...namespaceStatic.imports,\n ];\n let hasNonStaticLocalReference = false;\n\n findReferences(expression, ctx.referencesByNode).forEach(\n ({ name, start }) => {\n const binding = resolveBindingAt(ctx, name, start);\n if (!binding) {\n return;\n }\n\n if (isFunction && isBindingDeclaredWithin(binding, expression)) {\n return;\n }\n\n ctx.dependencyNames.add(name);\n\n if (binding.importedFrom) {\n importedFrom.push(binding.importedFrom);\n if (binding.imported && binding.imported !== '*') {\n staticImports.push({\n imported: binding.imported,\n local: binding.name,\n source: binding.importedFrom,\n });\n } else if (\n binding.imported === '*' &&\n namespaceStatic.coveredReferenceStarts.has(start)\n ) {\n // The static candidate source gets a synthetic named import alias,\n // while the eval fallback keeps the original namespace expression.\n } else {\n hasNonStaticLocalReference = true;\n }\n return;\n }\n\n const replacement = getConstantReplacement(binding, ctx);\n if (evaluate && replacement) {\n identifierReplacements.set(name, replacement);\n return;\n }\n\n hasNonStaticLocalReference = true;\n assertHoistable(binding, ctx);\n addHoistedDeclaration(binding, ctx);\n if (!binding.isRoot && binding.declarator?.id.type === 'Identifier') {\n identifierReplacements.set(name, getHoistedBindingName(binding, ctx));\n }\n }\n );\n\n return {\n expressionCode:\n identifierReplacements.size > 0\n ? replaceIdentifierReferences(\n expression,\n identifierReplacements,\n ctx.code\n )\n : source,\n importedFrom,\n kind: isFunction ? ValueType.FUNCTION : ValueType.LAZY,\n staticExpressionCode:\n namespaceStatic.replacements.length > 0\n ? applyExpressionReplacements(\n expression,\n namespaceStatic.replacements,\n ctx.code\n )\n : undefined,\n staticImports: hasNonStaticLocalReference ? [] : staticImports,\n };\n};\n\nconst getInsertionPoints = (\n program: Program,\n expressions: Expression[]\n): number[] => {\n if (expressions.length === 0) {\n return [];\n }\n\n if (program.body.length === 0) {\n return expressions.map(() => 0);\n }\n\n const insertionPoints: number[] = [];\n let ownerIndex = 0;\n\n expressions.forEach((expression) => {\n while (\n ownerIndex < program.body.length - 1 &&\n program.body[ownerIndex]!.end < expression.start\n ) {\n ownerIndex += 1;\n }\n\n let owner: Program['body'][number] | undefined = program.body[ownerIndex];\n if (\n !owner ||\n owner.start > expression.start ||\n owner.end < expression.end\n ) {\n owner = program.body.find(\n (statement) =>\n statement.start <= expression.start && statement.end >= expression.end\n );\n }\n\n insertionPoints.push(owner?.start ?? 0);\n });\n\n return insertionPoints;\n};\n\nconst applyReplacements = (\n code: string,\n replacements: Replacement[]\n): string => {\n let result = code;\n replacements\n .sort((a, b) => b.start - a.start)\n .forEach((replacement) => {\n result =\n result.slice(0, replacement.start) +\n replacement.value +\n result.slice(replacement.end);\n });\n\n return result;\n};\n\nconst extractExpressions = (\n code: string,\n filename: string,\n evaluate: boolean,\n program: Program,\n analysis: Pick<\n ProgramAnalysis,\n 'bindingsByName' | 'rootMutationsByBinding' | 'usedNames'\n >,\n expressions: Expression[]\n): TemplateExtractionResult => {\n if (expressions.length === 0) {\n return {\n code,\n dependencyNames: [],\n expressionValues: [],\n staticValueCandidates: [],\n staticValues: [],\n };\n }\n\n const insertionPoints = getInsertionPoints(program, expressions);\n const ctx: ExtractionContext = {\n bindingResolutionCache: new Map(),\n bindingsByName: analysis.bindingsByName,\n code,\n currentInsertionPoint: insertionPoints[0] ?? 0,\n currentExpressionStart: expressions[0].start,\n dependencyNames: new Set(),\n expressionValues: [],\n filename,\n hoistedBindingNames: new Map(),\n hoistedDeclarations: new Map(),\n hoistedDeclarationsByInsertionPoint: new Map(),\n loc: createLocationLookup(code),\n referencesByNode: new WeakMap(),\n replacements: [],\n rootMutationsByBinding: analysis.rootMutationsByBinding,\n staticImportAliases: new Map(),\n staticValueCandidates: [],\n staticValues: [],\n usedNames: new Set(analysis.usedNames),\n };\n\n expressions.forEach((expression, index) => {\n ctx.currentInsertionPoint = insertionPoints[index] ?? 0;\n ctx.currentExpressionStart = expression.start;\n\n const literal = literalExpressionValue(expression, ctx);\n if (literal) {\n ctx.expressionValues.push(literal);\n return;\n }\n\n const {\n expressionCode,\n importedFrom,\n kind,\n staticExpressionCode,\n staticImports,\n staticValue,\n } = extractExpression(expression, ctx, evaluate);\n const expName = allocateExpressionName(ctx);\n\n addHoistedCode(\n expName,\n `const ${expName} = () => (${expressionCode});`,\n ctx\n );\n if (staticValue !== undefined && kind !== ValueType.FUNCTION) {\n ctx.staticValues.push({\n name: expName,\n value: staticValue,\n });\n } else if (staticImports.length > 0 && kind !== ValueType.FUNCTION) {\n const uniqueImports = new Map<string, OxcStaticImportReference>();\n staticImports.forEach((item) => {\n uniqueImports.set(\n `${item.local}\\0${item.importLocal ?? ''}\\0${item.source}\\0${\n item.imported\n }`,\n item\n );\n });\n ctx.staticValueCandidates.push({\n imports: [...uniqueImports.values()],\n name: expName,\n source: staticExpressionCode ?? expressionCode,\n });\n }\n ctx.replacements.push({\n start: expression.start,\n end: expression.end,\n value: `${expName}()`,\n });\n ctx.expressionValues.push({\n ex: {\n loc: getSourceLocation(expression.start, expression.end, ctx),\n name: expName,\n type: 'Identifier',\n },\n importedFrom,\n kind,\n source: ctx.code.slice(expression.start, expression.end),\n } as unknown as Omit<ExpressionValue, 'buildCodeFrameError'>);\n });\n\n ctx.hoistedDeclarationsByInsertionPoint.forEach((declarations, point) => {\n ctx.replacements.push({\n start: point,\n end: point,\n value: `${declarations.join('\\n')}\\n`,\n });\n });\n\n return {\n code: applyReplacements(code, ctx.replacements),\n dependencyNames: [...ctx.dependencyNames],\n expressionValues: ctx.expressionValues,\n staticValueCandidates: ctx.staticValueCandidates,\n staticValues: ctx.staticValues,\n };\n};\n\nexport const isOxcStaticSerializableValue = (value: unknown): boolean =>\n isStaticSerializableValue(value);\n\nexport const evaluateOxcStaticExpressionAt = (\n code: string,\n filename: string,\n expressionSpan: ExpressionSpan,\n staticBindings: Map<string, unknown> = new Map()\n): unknown | undefined => {\n const program = parseOxc(code, filename);\n const analysis = analyzeProgram(program, {\n collectTargetExpressions: true,\n expressionSpanLookup: createSpanLookup([expressionSpan]),\n });\n const [expression] = analysis.targetExpressions;\n if (!expression) {\n return undefined;\n }\n\n const ctx: ExtractionContext = {\n bindingResolutionCache: new Map(),\n bindingsByName: analysis.bindingsByName,\n code,\n currentInsertionPoint: 0,\n currentExpressionStart: expression.start,\n dependencyNames: new Set(),\n expressionValues: [],\n filename,\n hoistedBindingNames: new Map(),\n hoistedDeclarations: new Map(),\n hoistedDeclarationsByInsertionPoint: new Map(),\n loc: createLocationLookup(code),\n referencesByNode: new WeakMap(),\n replacements: [],\n rootMutationsByBinding: analysis.rootMutationsByBinding,\n staticImportAliases: new Map(),\n staticValueCandidates: [],\n staticValues: [],\n usedNames: new Set(analysis.usedNames),\n };\n\n return evaluateStatic(expression, ctx, new Map(staticBindings));\n};\n\nexport const evaluateOxcStaticExpression = (\n source: string,\n filename: string,\n staticBindings: Map<string, unknown> = new Map()\n): unknown | undefined => {\n const code = `const __wyw_static_value = ${source};`;\n const program = parseOxc(code, filename);\n const declaration = program.body[0];\n if (declaration?.type !== 'VariableDeclaration') {\n return undefined;\n }\n\n const [declarator] = declaration.declarations;\n if (!declarator?.init) {\n return undefined;\n }\n\n return evaluateOxcStaticExpressionAt(\n code,\n filename,\n {\n end: declarator.init.end,\n start: declarator.init.start,\n },\n staticBindings\n );\n};\n\nexport const collectOxcExpressionDependencies = (\n code: string,\n filename: string,\n evaluate = false,\n targetExpressionSpans?: ExpressionSpan[]\n): TemplateExtractionResult => {\n const program = parseOxc(code, filename);\n const analysis = analyzeProgram(program, {\n collectTargetExpressions: true,\n expressionSpanLookup: createSpanLookup(targetExpressionSpans),\n });\n\n return extractExpressions(\n code,\n filename,\n evaluate,\n program,\n analysis,\n analysis.targetExpressions\n );\n};\n\nexport const collectOxcTemplateDependencies = (\n code: string,\n filename: string,\n evaluate = false,\n targetTemplateSpans?: ExpressionSpan[]\n): TemplateExtractionResult => {\n const program = parseOxc(code, filename);\n const analysis = analyzeProgram(program, {\n collectTemplateLiterals: true,\n templateSpanLookup: createSpanLookup(targetTemplateSpans),\n });\n const expressions = analysis.templateLiterals.flatMap(\n (template) => template.expressions\n );\n\n return extractExpressions(\n code,\n filename,\n evaluate,\n program,\n analysis,\n expressions\n );\n};\n"],"file":"collectOxcTemplateDependencies.js"}
|
|
1
|
+
{"mappings":"AAMA,SAAS,2BAA2B;AACpC,SAAS,oCAAoC;AAC7C,SACE,kCACA,gCACA,6BACA,+BACA,oCACK","names":[],"sources":["../../src/utils/collectOxcTemplateDependencies.ts"],"version":3,"sourcesContent":["export type {\n OxcStaticImportReference,\n OxcStaticValue,\n OxcStaticValueCandidate,\n StaticBindings,\n} from './collectOxcTemplateDependencies/types';\nexport { lookupStaticBinding } from './collectOxcTemplateDependencies/staticBindings';\nexport { createOxcStaticCallableValue } from './collectOxcTemplateDependencies/staticEvaluator';\nexport {\n collectOxcExpressionDependencies,\n collectOxcTemplateDependencies,\n evaluateOxcStaticExpression,\n evaluateOxcStaticExpressionAt,\n isOxcStaticSerializableValue,\n} from './collectOxcTemplateDependencies/expressionExtraction';\n"],"file":"collectOxcTemplateDependencies.js"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { ResolverFactory } from "oxc-resolver";
|
|
4
|
+
import { parseRequest } from "./parseRequest.js";
|
|
5
|
+
const CJS_DEFAULT_CONDITIONS = [
|
|
6
|
+
"require",
|
|
7
|
+
"node",
|
|
8
|
+
"default"
|
|
9
|
+
];
|
|
10
|
+
const ESM_DEFAULT_CONDITIONS = [
|
|
11
|
+
"node",
|
|
12
|
+
"import",
|
|
13
|
+
"default"
|
|
14
|
+
];
|
|
15
|
+
const FALLBACK_EXTENSIONS = [".json", ".node"];
|
|
16
|
+
const MAX_RESOLVER_CACHE_SIZE = 64;
|
|
17
|
+
const resolverCache = new Map();
|
|
18
|
+
const unique = (items) => Array.from(new Set(items));
|
|
19
|
+
export const expandNativeResolverConditions = (kind, conditionNames) => {
|
|
20
|
+
const defaults = kind === "require" ? CJS_DEFAULT_CONDITIONS : ESM_DEFAULT_CONDITIONS;
|
|
21
|
+
const names = conditionNames?.length ? conditionNames : ["..."];
|
|
22
|
+
const result = [];
|
|
23
|
+
names.forEach((name) => {
|
|
24
|
+
if (name === "...") {
|
|
25
|
+
defaults.forEach((condition) => result.push(condition));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
result.push(name);
|
|
29
|
+
});
|
|
30
|
+
return unique(result);
|
|
31
|
+
};
|
|
32
|
+
const createResolverOptions = ({ conditionNames, extensions, kind, oxcOptions }) => {
|
|
33
|
+
const configuredResolver = oxcOptions?.resolver ?? {};
|
|
34
|
+
const hasConfiguredTsconfig = Object.prototype.hasOwnProperty.call(configuredResolver, "tsconfig");
|
|
35
|
+
const configuredConditionNames = Array.isArray(configuredResolver.conditionNames) ? configuredResolver.conditionNames : undefined;
|
|
36
|
+
const configuredExtensions = Array.isArray(configuredResolver.extensions) ? configuredResolver.extensions : [];
|
|
37
|
+
return {
|
|
38
|
+
...configuredResolver,
|
|
39
|
+
...hasConfiguredTsconfig ? {} : { tsconfig: "auto" },
|
|
40
|
+
conditionNames: expandNativeResolverConditions(kind, conditionNames ?? configuredConditionNames),
|
|
41
|
+
extensions: unique([
|
|
42
|
+
...configuredExtensions,
|
|
43
|
+
...extensions,
|
|
44
|
+
...FALLBACK_EXTENSIONS
|
|
45
|
+
])
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
const getResolver = (options) => {
|
|
49
|
+
const key = JSON.stringify(options);
|
|
50
|
+
const cached = resolverCache.get(key);
|
|
51
|
+
if (cached) {
|
|
52
|
+
resolverCache.delete(key);
|
|
53
|
+
resolverCache.set(key, cached);
|
|
54
|
+
return cached;
|
|
55
|
+
}
|
|
56
|
+
const resolver = new ResolverFactory(options);
|
|
57
|
+
if (resolverCache.size >= MAX_RESOLVER_CACHE_SIZE) {
|
|
58
|
+
const oldestKey = resolverCache.keys().next().value;
|
|
59
|
+
if (oldestKey !== undefined) {
|
|
60
|
+
resolverCache.delete(oldestKey);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
resolverCache.set(key, resolver);
|
|
64
|
+
return resolver;
|
|
65
|
+
};
|
|
66
|
+
export const clearNativeResolverCacheForTest = () => {
|
|
67
|
+
resolverCache.clear();
|
|
68
|
+
};
|
|
69
|
+
export const getNativeResolverCacheSizeForTest = () => resolverCache.size;
|
|
70
|
+
const preferJsOverCjsForExtensionlessFileSpecifier = (specifier, resolved) => {
|
|
71
|
+
if ((specifier.startsWith(".") || path.isAbsolute(specifier)) && path.extname(specifier) === "" && resolved.endsWith(".cjs") && fs.existsSync(`${resolved.slice(0, -4)}.js`)) {
|
|
72
|
+
return `${resolved.slice(0, -4)}.js`;
|
|
73
|
+
}
|
|
74
|
+
return resolved;
|
|
75
|
+
};
|
|
76
|
+
export const resolveWithNativeResolver = ({ conditionNames, extensions, importer, kind, oxcOptions, specifier }) => {
|
|
77
|
+
const { filename, query, hash } = parseRequest(specifier);
|
|
78
|
+
const options = createResolverOptions({
|
|
79
|
+
conditionNames,
|
|
80
|
+
extensions,
|
|
81
|
+
kind,
|
|
82
|
+
oxcOptions
|
|
83
|
+
});
|
|
84
|
+
const resolver = getResolver(options);
|
|
85
|
+
const result = resolver.resolveFileSync(importer, filename);
|
|
86
|
+
if (!result.path) {
|
|
87
|
+
throw new Error(result.error ?? `Cannot resolve module ${specifier}`);
|
|
88
|
+
}
|
|
89
|
+
const resolved = preferJsOverCjsForExtensionlessFileSpecifier(filename, result.path);
|
|
90
|
+
const suffix = `${query ? `?${query}` : ""}${hash ? `#${hash}` : ""}`;
|
|
91
|
+
return `${resolved}${suffix}`;
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=nativeResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,SAAS,uBAAgD;AAQzD,SAAS,oBAAoB;AAE7B,MAAM,yBAAyB;CAAC;CAAW;CAAQ;CAAU;AAC7D,MAAM,yBAAyB;CAAC;CAAQ;CAAU;CAAU;AAC5D,MAAM,sBAAsB,CAAC,SAAS,QAAQ;AAC9C,MAAM,0BAA0B;AAEhC,MAAM,gBAAgB,IAAI,KAA8B;AAWxD,MAAM,UAAa,UAA6B,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC;AAE1E,OAAO,MAAM,kCACX,MACA,mBACa;CACb,MAAM,WACJ,SAAS,YAAY,yBAAyB;CAChD,MAAM,QAAQ,gBAAgB,SAAS,iBAAiB,CAAC,MAAM;CAC/D,MAAM,SAAmB,EAAE;AAE3B,OAAM,SAAS,SAAS;AACtB,MAAI,SAAS,OAAO;AAClB,YAAS,SAAS,cAAc,OAAO,KAAK,UAAU,CAAC;AACvD;;AAGF,SAAO,KAAK,KAAK;GACjB;AAEF,QAAO,OAAO,OAAO;;AAGvB,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AGT,OAAO,MAAM,6BAA6B,EACxC,gBACA,YACA,UACA,MACA,YACA,gBACkC;CAClC,MAAM,EAAE,UAAU,OAAO,SAAS,aAAa,UAAU;CACzD,MAAM,UAAU,sBAAsB;EACpC;EACA;EACA;EACA;EACD,CAAC;CACF,MAAM,WAAW,YAAY,QAAQ;CACrC,MAAM,SAAS,SAAS,gBAAgB,UAAU,SAAS;AAE3D,KAAI,CAAC,OAAO,MAAM;AAChB,QAAM,IAAI,MAAM,OAAO,SAAS,yBAAyB,YAAY;;CAGvE,MAAM,WAAW,6CACf,UACA,OAAO,KACR;CACD,MAAM,SAAS,GAAG,QAAQ,IAAI,UAAU,KAAK,OAAO,IAAI,SAAS;AAEjE,QAAO,GAAG,WAAW","names":[],"sources":["../../src/utils/nativeResolver.ts"],"version":3,"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { ResolverFactory, type NapiResolveOptions } from 'oxc-resolver';\n\nimport type {\n EvalResolverKind,\n OxcOptions,\n StrictOptions,\n} from '@wyw-in-js/shared';\n\nimport { parseRequest } from './parseRequest';\n\nconst CJS_DEFAULT_CONDITIONS = ['require', 'node', 'default'] as const;\nconst ESM_DEFAULT_CONDITIONS = ['node', 'import', 'default'] as const;\nconst FALLBACK_EXTENSIONS = ['.json', '.node'] as const;\nconst MAX_RESOLVER_CACHE_SIZE = 64;\n\nconst resolverCache = new Map<string, ResolverFactory>();\n\nexport type NativeResolverParams = {\n conditionNames?: string[];\n extensions: StrictOptions['extensions'];\n importer: string;\n kind: EvalResolverKind;\n oxcOptions?: OxcOptions;\n specifier: string;\n};\n\nconst unique = <T>(items: readonly T[]): T[] => Array.from(new Set(items));\n\nexport const expandNativeResolverConditions = (\n kind: EvalResolverKind,\n conditionNames?: readonly string[]\n): string[] => {\n const defaults =\n kind === 'require' ? CJS_DEFAULT_CONDITIONS : ESM_DEFAULT_CONDITIONS;\n const names = conditionNames?.length ? conditionNames : ['...'];\n const result: string[] = [];\n\n names.forEach((name) => {\n if (name === '...') {\n defaults.forEach((condition) => result.push(condition));\n return;\n }\n\n result.push(name);\n });\n\n return unique(result);\n};\n\nconst createResolverOptions = ({\n conditionNames,\n extensions,\n kind,\n oxcOptions,\n}: Pick<\n NativeResolverParams,\n 'conditionNames' | 'extensions' | 'kind' | 'oxcOptions'\n>): NapiResolveOptions => {\n const configuredResolver = (oxcOptions?.resolver ?? {}) as NapiResolveOptions;\n const hasConfiguredTsconfig = Object.prototype.hasOwnProperty.call(\n configuredResolver,\n 'tsconfig'\n );\n const configuredConditionNames = Array.isArray(\n configuredResolver.conditionNames\n )\n ? configuredResolver.conditionNames\n : undefined;\n const configuredExtensions = Array.isArray(configuredResolver.extensions)\n ? configuredResolver.extensions\n : [];\n\n return {\n ...configuredResolver,\n ...(hasConfiguredTsconfig ? {} : { tsconfig: 'auto' }),\n conditionNames: expandNativeResolverConditions(\n kind,\n conditionNames ?? configuredConditionNames\n ),\n extensions: unique([\n ...configuredExtensions,\n ...extensions,\n ...FALLBACK_EXTENSIONS,\n ]),\n };\n};\n\nconst getResolver = (options: NapiResolveOptions): ResolverFactory => {\n const key = JSON.stringify(options);\n const cached = resolverCache.get(key);\n if (cached) {\n resolverCache.delete(key);\n resolverCache.set(key, cached);\n return cached;\n }\n\n const resolver = new ResolverFactory(options);\n if (resolverCache.size >= MAX_RESOLVER_CACHE_SIZE) {\n const oldestKey = resolverCache.keys().next().value;\n if (oldestKey !== undefined) {\n resolverCache.delete(oldestKey);\n }\n }\n resolverCache.set(key, resolver);\n return resolver;\n};\n\nexport const clearNativeResolverCacheForTest = (): void => {\n resolverCache.clear();\n};\n\nexport const getNativeResolverCacheSizeForTest = (): number =>\n resolverCache.size;\n\nconst preferJsOverCjsForExtensionlessFileSpecifier = (\n specifier: string,\n resolved: string\n): string => {\n if (\n (specifier.startsWith('.') || path.isAbsolute(specifier)) &&\n path.extname(specifier) === '' &&\n resolved.endsWith('.cjs') &&\n fs.existsSync(`${resolved.slice(0, -4)}.js`)\n ) {\n return `${resolved.slice(0, -4)}.js`;\n }\n\n return resolved;\n};\n\nexport const resolveWithNativeResolver = ({\n conditionNames,\n extensions,\n importer,\n kind,\n oxcOptions,\n specifier,\n}: NativeResolverParams): string => {\n const { filename, query, hash } = parseRequest(specifier);\n const options = createResolverOptions({\n conditionNames,\n extensions,\n kind,\n oxcOptions,\n });\n const resolver = getResolver(options);\n const result = resolver.resolveFileSync(importer, filename);\n\n if (!result.path) {\n throw new Error(result.error ?? `Cannot resolve module ${specifier}`);\n }\n\n const resolved = preferJsOverCjsForExtensionlessFileSpecifier(\n filename,\n result.path\n );\n const suffix = `${query ? `?${query}` : ''}${hash ? `#${hash}` : ''}`;\n\n return `${resolved}${suffix}`;\n};\n"],"file":"nativeResolver.js"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const isOxcNode = (value) => !!value && typeof value === "object" && "type" in value && typeof value.type === "string";
|
|
2
|
+
export const getOxcNodeChildren = (node) => {
|
|
3
|
+
const result = [];
|
|
4
|
+
const record = node;
|
|
5
|
+
Object.keys(record).forEach((key) => {
|
|
6
|
+
if (key === "comments" || key === "end" || key === "errors" || key === "parent" || key === "range" || key === "span" || key === "start" || key === "type") {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const value = record[key];
|
|
10
|
+
if (isOxcNode(value)) {
|
|
11
|
+
result.push(value);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
value.forEach((item) => {
|
|
16
|
+
if (isOxcNode(item)) {
|
|
17
|
+
result.push(item);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
export const walkOxc = (node, enter, parent = null) => {
|
|
25
|
+
enter(node, parent);
|
|
26
|
+
getOxcNodeChildren(node).forEach((child) => walkOxc(child, enter, node));
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=ast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAIA,OAAO,MAAM,aAAa,UACxB,CAAC,CAAC,SACF,OAAO,UAAU,YACjB,UAAU,SACV,OAAQ,MAA6B,SAAS;AAEhD,OAAO,MAAM,sBAAsB,SAAuB;CACxD,MAAM,SAAiB,EAAE;CACzB,MAAM,SAAS;AAEf,QAAO,KAAK,OAAO,CAAC,SAAS,QAAQ;AACnC,MACE,QAAQ,cACR,QAAQ,SACR,QAAQ,YACR,QAAQ,YACR,QAAQ,WACR,QAAQ,UACR,QAAQ,WACR,QAAQ,QACR;AACA;;EAGF,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,MAAM,EAAE;AACpB,UAAO,KAAK,MAAM;AAClB;;AAGF,MAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,SAAM,SAAS,SAAS;AACtB,QAAI,UAAU,KAAK,EAAE;AACnB,YAAO,KAAK,KAAK;;KAEnB;;GAEJ;AAEF,QAAO;;AAGT,OAAO,MAAM,WACX,MACA,OACA,SAAsB,SACb;AACT,OAAM,MAAM,OAAO;AACnB,oBAAmB,KAAK,CAAC,SAAS,UAAU,QAAQ,OAAO,OAAO,KAAK,CAAC","names":[],"sources":["../../../src/utils/oxc/ast.ts"],"version":3,"sourcesContent":["import type { Node } from 'oxc-parser';\n\ntype AnyOxcNode = Node & Record<string, unknown>;\n\nexport const isOxcNode = (value: unknown): value is Node =>\n !!value &&\n typeof value === 'object' &&\n 'type' in value &&\n typeof (value as { type?: unknown }).type === 'string';\n\nexport const getOxcNodeChildren = (node: Node): Node[] => {\n const result: Node[] = [];\n const record = node as AnyOxcNode;\n\n Object.keys(record).forEach((key) => {\n if (\n key === 'comments' ||\n key === 'end' ||\n key === 'errors' ||\n key === 'parent' ||\n key === 'range' ||\n key === 'span' ||\n key === 'start' ||\n key === 'type'\n ) {\n return;\n }\n\n const value = record[key];\n if (isOxcNode(value)) {\n result.push(value);\n return;\n }\n\n if (Array.isArray(value)) {\n value.forEach((item) => {\n if (isOxcNode(item)) {\n result.push(item);\n }\n });\n }\n });\n\n return result;\n};\n\nexport const walkOxc = (\n node: Node,\n enter: (node: Node, parent: Node | null) => void,\n parent: Node | null = null\n): void => {\n enter(node, parent);\n getOxcNodeChildren(node).forEach((child) => walkOxc(child, enter, node));\n};\n"],"file":"ast.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAEA,SAAS,6BAA6B;AAItC,OAAO,MAAM,mBACX,MACA,UACA,aAA4B,kBAChB,sBAAsB,UAAU,MAAM,WAAW","names":[],"sources":["../../../src/utils/oxc/parse.ts"],"version":3,"sourcesContent":["import type { Program } from 'oxc-parser';\n\nimport { parseOxcProgramCached } from '../parseOxc';\n\nexport type OxcSourceType = 'module' | 'unambiguous';\n\nexport const parseOxcProgram = (\n code: string,\n filename: string,\n sourceType: OxcSourceType = 'unambiguous'\n): Program => parseOxcProgramCached(filename, code, sourceType);\n"],"file":"parse.js"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const getReplacementValue = (replacement) => {
|
|
2
|
+
if ("value" in replacement) {
|
|
3
|
+
return replacement.value;
|
|
4
|
+
}
|
|
5
|
+
return replacement.text;
|
|
6
|
+
};
|
|
7
|
+
export const applyOxcReplacements = (code, replacements) => {
|
|
8
|
+
let result = code;
|
|
9
|
+
[...replacements].sort((a, b) => b.start - a.start).forEach((replacement) => {
|
|
10
|
+
result = result.slice(0, replacement.start) + getReplacementValue(replacement) + result.slice(replacement.end);
|
|
11
|
+
});
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=replacements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAcA,MAAM,uBAAuB,gBAAwC;AACnE,KAAI,WAAW,aAAa;AAC1B,SAAO,YAAY;;AAGrB,QAAO,YAAY;;AAGrB,OAAO,MAAM,wBACX,MACA,iBACW;CACX,IAAI,SAAS;AACb,EAAC,GAAG,aAAa,CACd,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,CACjC,SAAS,gBAAgB;AACxB,WACE,OAAO,MAAM,GAAG,YAAY,MAAM,GAClC,oBAAoB,YAAY,GAChC,OAAO,MAAM,YAAY,IAAI;GAC/B;AAEJ,QAAO","names":[],"sources":["../../../src/utils/oxc/replacements.ts"],"version":3,"sourcesContent":["export type OxcValueReplacement = {\n end: number;\n start: number;\n value: string;\n};\n\nexport type OxcTextReplacement = {\n end: number;\n start: number;\n text: string;\n};\n\nexport type OxcReplacement = OxcTextReplacement | OxcValueReplacement;\n\nconst getReplacementValue = (replacement: OxcReplacement): string => {\n if ('value' in replacement) {\n return replacement.value;\n }\n\n return replacement.text;\n};\n\nexport const applyOxcReplacements = (\n code: string,\n replacements: OxcReplacement[]\n): string => {\n let result = code;\n [...replacements]\n .sort((a, b) => b.start - a.start)\n .forEach((replacement) => {\n result =\n result.slice(0, replacement.start) +\n getReplacementValue(replacement) +\n result.slice(replacement.end);\n });\n\n return result;\n};\n"],"file":"replacements.js"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export const createOxcLocationLookup = (code) => {
|
|
2
|
+
const lineStarts = [0];
|
|
3
|
+
for (let idx = 0; idx < code.length; idx += 1) {
|
|
4
|
+
if (code[idx] === "\n") {
|
|
5
|
+
lineStarts.push(idx + 1);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return (offset) => {
|
|
9
|
+
let low = 0;
|
|
10
|
+
let high = lineStarts.length - 1;
|
|
11
|
+
while (low <= high) {
|
|
12
|
+
const mid = Math.floor((low + high) / 2);
|
|
13
|
+
const next = lineStarts[mid + 1] ?? Infinity;
|
|
14
|
+
if (lineStarts[mid] <= offset && offset < next) {
|
|
15
|
+
return {
|
|
16
|
+
column: offset - lineStarts[mid],
|
|
17
|
+
line: mid + 1
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (offset < lineStarts[mid]) {
|
|
21
|
+
high = mid - 1;
|
|
22
|
+
} else {
|
|
23
|
+
low = mid + 1;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const lastLine = lineStarts.length - 1;
|
|
27
|
+
return {
|
|
28
|
+
column: Math.max(0, offset - lineStarts[lastLine]),
|
|
29
|
+
line: lastLine + 1
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export const createOxcSourceLocation = (start, end, loc, filename, identifierName) => ({
|
|
34
|
+
end: loc(end),
|
|
35
|
+
filename: filename ?? undefined,
|
|
36
|
+
identifierName,
|
|
37
|
+
start: loc(start)
|
|
38
|
+
});
|
|
39
|
+
export const buildOxcCodeFrameError = (code, location, message) => {
|
|
40
|
+
const lines = code.split("\n");
|
|
41
|
+
const startLine = location.start.line;
|
|
42
|
+
const endLine = location.end.line;
|
|
43
|
+
const frameStart = Math.max(1, startLine - 2);
|
|
44
|
+
const frameEnd = Math.min(lines.length, endLine + 2);
|
|
45
|
+
const lineNoWidth = String(frameEnd).length;
|
|
46
|
+
const frame = [];
|
|
47
|
+
for (let lineNo = frameStart; lineNo <= frameEnd; lineNo += 1) {
|
|
48
|
+
const marker = lineNo === startLine ? ">" : " ";
|
|
49
|
+
const line = lines[lineNo - 1] ?? "";
|
|
50
|
+
frame.push(line.length > 0 ? `${marker} ${String(lineNo).padStart(lineNoWidth)} | ${line}` : `${marker} ${String(lineNo).padStart(lineNoWidth)} |`);
|
|
51
|
+
if (lineNo === startLine) {
|
|
52
|
+
const pointerLength = startLine === endLine ? Math.max(1, location.end.column - location.start.column) : 1;
|
|
53
|
+
frame.push(` ${" ".repeat(lineNoWidth)} | ${" ".repeat(location.start.column)}${"^".repeat(pointerLength)}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const prefix = location.filename ? `${location.filename}: ` : "";
|
|
57
|
+
return new Error(`${prefix}${message}\n${frame.join("\n")}`);
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=sourceLocations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mapp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,QAAM,KACJ,KAAK,SAAS,IACV,GAAG,OAAO,GAAG,OAAO,OAAO,CAAC,SAAS,YAAY,CAAC,KAAK,SACvD,GAAG,OAAO,GAAG,OAAO,OAAO,CAAC,SAAS,YAAY,CAAC,IACvD;AAED,MAAI,WAAW,WAAW;GACxB,MAAM,gBACJ,cAAc,UACV,KAAK,IAAI,GAAG,SAAS,IAAI,SAAS,SAAS,MAAM,OAAO,GACxD;AACN,SAAM,KACJ,KAAK,IAAI,OAAO,YAAY,CAAC,KAAK,IAAI,OACpC,SAAS,MAAM,OAChB,GAAG,IAAI,OAAO,cAAc,GAC9B;;;CAIL,MAAM,SAAS,SAAS,WAAW,GAAG,SAAS,SAAS,MAAM;AAC9D,QAAO,IAAI,MAAM,GAAG,SAAS,QAAQ,IAAI,MAAM,KAAK,KAAK,GAAG","names":[],"sources":["../../../src/utils/oxc/sourceLocations.ts"],"version":3,"sourcesContent":["import type { SourceLocation } from '@wyw-in-js/shared';\n\nexport type OxcLocationLookup = (offset: number) => SourceLocation['start'];\n\nexport const createOxcLocationLookup = (code: string): OxcLocationLookup => {\n const lineStarts = [0];\n for (let idx = 0; idx < code.length; idx += 1) {\n if (code[idx] === '\\n') {\n lineStarts.push(idx + 1);\n }\n }\n\n return (offset) => {\n let low = 0;\n let high = lineStarts.length - 1;\n\n while (low <= high) {\n const mid = Math.floor((low + high) / 2);\n const next = lineStarts[mid + 1] ?? Infinity;\n if (lineStarts[mid] <= offset && offset < next) {\n return {\n column: offset - lineStarts[mid],\n line: mid + 1,\n };\n }\n\n if (offset < lineStarts[mid]) {\n high = mid - 1;\n } else {\n low = mid + 1;\n }\n }\n\n const lastLine = lineStarts.length - 1;\n return {\n column: Math.max(0, offset - lineStarts[lastLine]),\n line: lastLine + 1,\n };\n };\n};\n\nexport const createOxcSourceLocation = (\n start: number,\n end: number,\n loc: OxcLocationLookup,\n filename?: string | null,\n identifierName?: string | null\n): SourceLocation => ({\n end: loc(end),\n filename: filename ?? undefined,\n identifierName,\n start: loc(start),\n});\n\nexport const buildOxcCodeFrameError = (\n code: string,\n location: SourceLocation,\n message: string\n): Error => {\n const lines = code.split('\\n');\n const startLine = location.start.line;\n const endLine = location.end.line;\n const frameStart = Math.max(1, startLine - 2);\n const frameEnd = Math.min(lines.length, endLine + 2);\n const lineNoWidth = String(frameEnd).length;\n const frame: string[] = [];\n\n for (let lineNo = frameStart; lineNo <= frameEnd; lineNo += 1) {\n const marker = lineNo === startLine ? '>' : ' ';\n const line = lines[lineNo - 1] ?? '';\n frame.push(\n line.length > 0\n ? `${marker} ${String(lineNo).padStart(lineNoWidth)} | ${line}`\n : `${marker} ${String(lineNo).padStart(lineNoWidth)} |`\n );\n\n if (lineNo === startLine) {\n const pointerLength =\n startLine === endLine\n ? Math.max(1, location.end.column - location.start.column)\n : 1;\n frame.push(\n ` ${' '.repeat(lineNoWidth)} | ${' '.repeat(\n location.start.column\n )}${'^'.repeat(pointerLength)}`\n );\n }\n }\n\n const prefix = location.filename ? `${location.filename}: ` : '';\n return new Error(`${prefix}${message}\\n${frame.join('\\n')}`);\n};\n"],"file":"sourceLocations.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAEA,OAAO,MAAM,mBAAmB,YAC9B,QAAQ,MAAM,YAAY;AAE5B,OAAO,MAAM,wBAAwB,YACnC,gBAAgB,QAAQ,KAAK","names":[],"sources":["../../../src/utils/oxcPreevalStage/evalStrategy.ts"],"version":3,"sourcesContent":["import type { OxcPreevalOptions } from './types';\n\nexport const getEvalStrategy = (options: OxcPreevalOptions) =>\n options.eval?.strategy ?? 'hybrid';\n\nexport const usesStaticEvaluation = (options: OxcPreevalOptions): boolean =>\n getEvalStrategy(options) !== 'execute';\n"],"file":"evalStrategy.js"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isFeatureEnabled } from "@wyw-in-js/shared";
|
|
2
|
+
import { removeDangerousCodeWithOxc, replaceImportMetaEnvWithOxc, rewriteDynamicImportsAndAddRequireFallbackWithOxc } from "../oxcPreevalTransforms.js";
|
|
3
|
+
const DYNAMIC_IMPORT_RE = /\bimport(?:\s|\/\*[\s\S]*?\*\/)*\(/;
|
|
4
|
+
const REQUIRE_CALL_RE = /\brequire(?:\s|\/\*[\s\S]*?\*\/)*\(/;
|
|
5
|
+
export const prepareOxcPreevalCode = (code, filename, options, eventEmitter) => {
|
|
6
|
+
let nextCode = eventEmitter.perf("transform:preeval:importMetaEnv", () => replaceImportMetaEnvWithOxc(code, filename));
|
|
7
|
+
if (isFeatureEnabled(options.features, "dangerousCodeRemover", filename)) {
|
|
8
|
+
nextCode = eventEmitter.perf("transform:preeval:removeDangerousCode", () => removeDangerousCodeWithOxc(nextCode, filename, options.codeRemover));
|
|
9
|
+
}
|
|
10
|
+
const shouldRewriteDynamicImports = DYNAMIC_IMPORT_RE.test(nextCode);
|
|
11
|
+
const shouldAddRequireFallback = REQUIRE_CALL_RE.test(nextCode);
|
|
12
|
+
if (shouldRewriteDynamicImports || shouldAddRequireFallback) {
|
|
13
|
+
nextCode = rewriteDynamicImportsAndAddRequireFallbackWithOxc(nextCode, filename, {
|
|
14
|
+
addRequireFallback: shouldAddRequireFallback,
|
|
15
|
+
eventEmitter,
|
|
16
|
+
rewriteDynamicImports: shouldRewriteDynamicImports
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return nextCode;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=prepareCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,SAAS,wBAAwB;AAGjC,SACE,4BACA,6BACA,yDACK;AAGP,MAAM,oBAAoB;AAC1B,MAAM,kBAAkB;AAExB,OAAO,MAAM,yBACX,MACA,UACA,SACA,iBACW;CACX,IAAI,WAAW,aAAa,KAAK,yCAC/B,4BAA4B,MAAM,SAAS,CAC5C;AAED,KAAI,iBAAiB,QAAQ,UAAU,wBAAwB,SAAS,EAAE;AACxE,aAAW,aAAa,KAAK,+CAC3B,2BAA2B,UAAU,UAAU,QAAQ,YAAY,CACpE;;CAGH,MAAM,8BAA8B,kBAAkB,KAAK,SAAS;CACpE,MAAM,2BAA2B,gBAAgB,KAAK,SAAS;AAC/D,KAAI,+BAA+B,0BAA0B;AAC3D,aAAW,kDACT,UACA,UACA;GACE,oBAAoB;GACpB;GACA,uBAAuB;GACxB,CACF;;AAGH,QAAO","names":[],"sources":["../../../src/utils/oxcPreevalStage/prepareCode.ts"],"version":3,"sourcesContent":["import { isFeatureEnabled } from '@wyw-in-js/shared';\n\nimport type { EventEmitter } from '../EventEmitter';\nimport {\n removeDangerousCodeWithOxc,\n replaceImportMetaEnvWithOxc,\n rewriteDynamicImportsAndAddRequireFallbackWithOxc,\n} from '../oxcPreevalTransforms';\nimport type { OxcPreevalOptions } from './types';\n\nconst DYNAMIC_IMPORT_RE = /\\bimport(?:\\s|\\/\\*[\\s\\S]*?\\*\\/)*\\(/;\nconst REQUIRE_CALL_RE = /\\brequire(?:\\s|\\/\\*[\\s\\S]*?\\*\\/)*\\(/;\n\nexport const prepareOxcPreevalCode = (\n code: string,\n filename: string,\n options: OxcPreevalOptions,\n eventEmitter: EventEmitter\n): string => {\n let nextCode = eventEmitter.perf('transform:preeval:importMetaEnv', () =>\n replaceImportMetaEnvWithOxc(code, filename)\n );\n\n if (isFeatureEnabled(options.features, 'dangerousCodeRemover', filename)) {\n nextCode = eventEmitter.perf('transform:preeval:removeDangerousCode', () =>\n removeDangerousCodeWithOxc(nextCode, filename, options.codeRemover)\n );\n }\n\n const shouldRewriteDynamicImports = DYNAMIC_IMPORT_RE.test(nextCode);\n const shouldAddRequireFallback = REQUIRE_CALL_RE.test(nextCode);\n if (shouldRewriteDynamicImports || shouldAddRequireFallback) {\n nextCode = rewriteDynamicImportsAndAddRequireFallbackWithOxc(\n nextCode,\n filename,\n {\n addRequireFallback: shouldAddRequireFallback,\n eventEmitter,\n rewriteDynamicImports: shouldRewriteDynamicImports,\n }\n );\n }\n\n return nextCode;\n};\n"],"file":"prepareCode.js"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { parseSync } from "oxc-parser";
|
|
2
|
+
const parseSourceType = (code, filename) => {
|
|
3
|
+
const parsed = parseSync(filename, code, {
|
|
4
|
+
astType: filename.endsWith(".ts") || filename.endsWith(".tsx") ? "ts" : "js",
|
|
5
|
+
range: true,
|
|
6
|
+
sourceType: "unambiguous"
|
|
7
|
+
});
|
|
8
|
+
const fatalError = parsed.errors.find((error) => error.severity === "Error");
|
|
9
|
+
if (fatalError) {
|
|
10
|
+
throw new Error(fatalError.message);
|
|
11
|
+
}
|
|
12
|
+
return parsed.program.sourceType === "script" ? "script" : "module";
|
|
13
|
+
};
|
|
14
|
+
export const appendOxcWywPreval = (code, filename, dependencyNames) => {
|
|
15
|
+
const uniqueNames = [...new Set(dependencyNames)];
|
|
16
|
+
const properties = uniqueNames.map((name) => `${name}: ${name}`).join(", ");
|
|
17
|
+
const object = uniqueNames.length > 0 ? `{ ${properties} }` : "{}";
|
|
18
|
+
if (parseSourceType(code, filename) === "script") {
|
|
19
|
+
return `${code}\nexports.__wywPreval = ${object};`;
|
|
20
|
+
}
|
|
21
|
+
return `${code}\nexport const __wywPreval = ${object};`;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=prevalExport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,SAAS,iBAAiB;AAE1B,MAAM,mBACJ,MACA,aACwB;CACxB,MAAM,SAAS,UAAU,UAAU,MAAM;EACvC,SACE,SAAS,SAAS,MAAM,IAAI,SAAS,SAAS,OAAO,GAAG,OAAO;EACjE,OAAO;EACP,YAAY;EACb,CAAC;CACF,MAAM,aAAa,OAAO,OAAO,MAAM,UAAU,MAAM,aAAa,QAAQ;AAC5E,KAAI,YAAY;AACd,QAAM,IAAI,MAAM,WAAW,QAAQ;;AAGrC,QAAO,OAAO,QAAQ,eAAe,WAAW,WAAW;;AAG7D,OAAO,MAAM,sBACX,MACA,UACA,oBACW;CACX,MAAM,cAAc,CAAC,GAAG,IAAI,IAAI,gBAAgB,CAAC;CACjD,MAAM,aAAa,YAAY,KAAK,SAAS,GAAG,KAAK,IAAI,OAAO,CAAC,KAAK,KAAK;CAC3E,MAAM,SAAS,YAAY,SAAS,IAAI,KAAK,WAAW,MAAM;AAE9D,KAAI,gBAAgB,MAAM,SAAS,KAAK,UAAU;AAChD,SAAO,GAAG,KAAK,0BAA0B,OAAO;;AAGlD,QAAO,GAAG,KAAK,+BAA+B,OAAO","names":[],"sources":["../../../src/utils/oxcPreevalStage/prevalExport.ts"],"version":3,"sourcesContent":["import { parseSync } from 'oxc-parser';\n\nconst parseSourceType = (\n code: string,\n filename: string\n): 'module' | 'script' => {\n const parsed = parseSync(filename, code, {\n astType:\n filename.endsWith('.ts') || filename.endsWith('.tsx') ? 'ts' : 'js',\n range: true,\n sourceType: 'unambiguous',\n });\n const fatalError = parsed.errors.find((error) => error.severity === 'Error');\n if (fatalError) {\n throw new Error(fatalError.message);\n }\n\n return parsed.program.sourceType === 'script' ? 'script' : 'module';\n};\n\nexport const appendOxcWywPreval = (\n code: string,\n filename: string,\n dependencyNames: string[]\n): string => {\n const uniqueNames = [...new Set(dependencyNames)];\n const properties = uniqueNames.map((name) => `${name}: ${name}`).join(', ');\n const object = uniqueNames.length > 0 ? `{ ${properties} }` : '{}';\n\n if (parseSourceType(code, filename) === 'script') {\n return `${code}\\nexports.__wywPreval = ${object};`;\n }\n\n return `${code}\\nexport const __wywPreval = ${object};`;\n};\n"],"file":"prevalExport.js"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { applyOxcProcessors } from "../applyOxcProcessors.js";
|
|
2
|
+
export const collectPreevalProcessors = (code, fileContext, options, eventEmitter) => {
|
|
3
|
+
const dependencyNames = [];
|
|
4
|
+
const processed = eventEmitter.perf("transform:preeval:processTemplate", () => applyOxcProcessors(code, fileContext, options, (processor) => {
|
|
5
|
+
processor.dependencies.forEach((dependency) => {
|
|
6
|
+
if (dependency.ex.type === "Identifier") {
|
|
7
|
+
dependencyNames.push(dependency.ex.name);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
processor.doEvaltimeReplacement();
|
|
11
|
+
}));
|
|
12
|
+
return {
|
|
13
|
+
dependencyNames,
|
|
14
|
+
processed
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=processors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAGA,SAAS,0BAA0B;AASnC,OAAO,MAAM,4BACX,MACA,aACA,SACA,iBAC+B;CAC/B,MAAM,kBAA4B,EAAE;CACpC,MAAM,YAAY,aAAa,KAAK,2CAClC,mBAAmB,MAAM,aAAa,UAAU,cAAc;AAC5D,YAAU,aAAa,SAAS,eAAe;AAC7C,OAAI,WAAW,GAAG,SAAS,cAAc;AACvC,oBAAgB,KAAK,WAAW,GAAG,KAAK;;IAE1C;AAEF,YAAU,uBAAuB;GACjC,CACH;AAED,QAAO;EACL;EACA;EACD","names":[],"sources":["../../../src/utils/oxcPreevalStage/processors.ts"],"version":3,"sourcesContent":["import type { IFileContext } from '@wyw-in-js/processor-utils';\n\nimport type { EventEmitter } from '../EventEmitter';\nimport { applyOxcProcessors } from '../applyOxcProcessors';\nimport type { ApplyOxcProcessorsResult } from '../applyOxcProcessors/types';\nimport type { OxcPreevalOptions } from './types';\n\ntype PreevalProcessorCollection = {\n dependencyNames: string[];\n processed: ApplyOxcProcessorsResult;\n};\n\nexport const collectPreevalProcessors = (\n code: string,\n fileContext: IFileContext,\n options: OxcPreevalOptions,\n eventEmitter: EventEmitter\n): PreevalProcessorCollection => {\n const dependencyNames: string[] = [];\n const processed = eventEmitter.perf('transform:preeval:processTemplate', () =>\n applyOxcProcessors(code, fileContext, options, (processor) => {\n processor.dependencies.forEach((dependency) => {\n if (dependency.ex.type === 'Identifier') {\n dependencyNames.push(dependency.ex.name);\n }\n });\n\n processor.doEvaltimeReplacement();\n })\n );\n\n return {\n dependencyNames,\n processed,\n };\n};\n"],"file":"processors.js"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { usesStaticEvaluation } from "./evalStrategy.js";
|
|
2
|
+
export const createStaticPreevalOverlay = (processed, dependencyNames, options) => {
|
|
3
|
+
const staticValuesEnabled = usesStaticEvaluation(options);
|
|
4
|
+
const staticValueNames = staticValuesEnabled ? new Set(processed.staticValues.map((item) => item.name)) : null;
|
|
5
|
+
const evalDependencyNames = staticValuesEnabled ? dependencyNames.filter((name) => !staticValueNames.has(name)) : dependencyNames;
|
|
6
|
+
const staticValueCache = new Map();
|
|
7
|
+
if (staticValuesEnabled) {
|
|
8
|
+
processed.staticValues.forEach(({ name, value }) => {
|
|
9
|
+
staticValueCache.set(name, value);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
evalDependencyNames,
|
|
14
|
+
staticValueCache,
|
|
15
|
+
staticValueCandidates: staticValuesEnabled ? processed.staticValueCandidates : []
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=staticOverlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AACA,SAAS,4BAA4B;AAGrC,OAAO,MAAM,8BACX,WACA,iBACA,YACyB;CACzB,MAAM,sBAAsB,qBAAqB,QAAQ;CACzD,MAAM,mBAAmB,sBACrB,IAAI,IAAI,UAAU,aAAa,KAAK,SAAS,KAAK,KAAK,CAAC,GACxD;CACJ,MAAM,sBAAsB,sBACxB,gBAAgB,QAAQ,SAAS,CAAC,iBAAkB,IAAI,KAAK,CAAC,GAC9D;CACJ,MAAM,mBAAmB,IAAI,KAAsB;AAEnD,KAAI,qBAAqB;AACvB,YAAU,aAAa,SAAS,EAAE,MAAM,YAAY;AAClD,oBAAiB,IAAI,MAAM,MAAM;IACjC;;AAGJ,QAAO;EACL;EACA;EACA,uBAAuB,sBACnB,UAAU,wBACV,EAAE;EACP","names":[],"sources":["../../../src/utils/oxcPreevalStage/staticOverlay.ts"],"version":3,"sourcesContent":["import type { ApplyOxcProcessorsResult } from '../applyOxcProcessors/types';\nimport { usesStaticEvaluation } from './evalStrategy';\nimport type { OxcPreevalOptions, StaticPreevalOverlay } from './types';\n\nexport const createStaticPreevalOverlay = (\n processed: ApplyOxcProcessorsResult,\n dependencyNames: string[],\n options: OxcPreevalOptions\n): StaticPreevalOverlay => {\n const staticValuesEnabled = usesStaticEvaluation(options);\n const staticValueNames = staticValuesEnabled\n ? new Set(processed.staticValues.map((item) => item.name))\n : null;\n const evalDependencyNames = staticValuesEnabled\n ? dependencyNames.filter((name) => !staticValueNames!.has(name))\n : dependencyNames;\n const staticValueCache = new Map<string, unknown>();\n\n if (staticValuesEnabled) {\n processed.staticValues.forEach(({ name, value }) => {\n staticValueCache.set(name, value);\n });\n }\n\n return {\n evalDependencyNames,\n staticValueCache,\n staticValueCandidates: staticValuesEnabled\n ? processed.staticValueCandidates\n : [],\n };\n};\n"],"file":"staticOverlay.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"","names":[],"sources":["../../../src/utils/oxcPreevalStage/types.ts"],"version":3,"sourcesContent":["import type { StrictOptions } from '@wyw-in-js/shared';\n\nimport type { EventEmitter } from '../EventEmitter';\nimport type { WYWTransformMetadata } from '../TransformMetadata';\nimport type { OxcStaticValueCandidate } from '../collectOxcTemplateDependencies';\n\nexport type OxcPreevalOptions = Pick<\n StrictOptions,\n | 'classNameSlug'\n | 'codeRemover'\n | 'displayName'\n | 'eval'\n | 'extensions'\n | 'features'\n | 'staticBindings'\n | 'tagResolver'\n> & { eventEmitter?: EventEmitter };\n\nexport type OxcPreevalResult = {\n baseCode: string;\n code: string;\n dependencyNames: string[];\n metadata: WYWTransformMetadata | null;\n processorClassNames: Record<string, string>;\n staticDependencies: string[];\n staticValueCache: Map<string, unknown>;\n staticValueCandidates: OxcStaticValueCandidate[];\n};\n\nexport type StaticPreevalOverlay = {\n evalDependencyNames: string[];\n staticValueCache: Map<string, unknown>;\n staticValueCandidates: OxcStaticValueCandidate[];\n};\n"],"file":"types.js"}
|