@wyw-in-js/transform 1.1.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 +433 -289
- package/esm/cache.js.map +1 -1
- package/esm/debug/fileReporter.js +171 -134
- package/esm/debug/fileReporter.js.map +1 -1
- package/esm/eval/broker.js +2275 -0
- package/esm/eval/broker.js.map +1 -0
- package/esm/eval/lru.js +36 -0
- package/esm/eval/lru.js.map +1 -0
- package/esm/eval/prepareModuleOnDemand.js +21 -0
- package/esm/eval/prepareModuleOnDemand.js.map +1 -0
- package/esm/eval/protocol.js +2 -0
- package/esm/eval/protocol.js.map +1 -0
- package/esm/eval/runner.js +1878 -0
- package/esm/eval/runner.js.map +1 -0
- package/esm/eval/serialize.js +333 -0
- package/esm/eval/serialize.js.map +1 -0
- package/esm/eval/writeQueue.js +81 -0
- package/esm/eval/writeQueue.js.map +1 -0
- package/esm/evaluators/index.js +11 -12
- package/esm/evaluators/index.js.map +1 -1
- package/esm/index.js +25 -29
- package/esm/index.js.map +1 -1
- package/esm/module.js +923 -520
- package/esm/module.js.map +1 -1
- package/esm/shaker.js +14 -80
- package/esm/shaker.js.map +1 -1
- package/esm/transform/BaseEntrypoint.js +162 -164
- package/esm/transform/BaseEntrypoint.js.map +1 -1
- package/esm/transform/Entrypoint.helpers.js +96 -253
- package/esm/transform/Entrypoint.helpers.js.map +1 -1
- package/esm/transform/Entrypoint.js +336 -270
- package/esm/transform/Entrypoint.js.map +1 -1
- package/esm/transform/Entrypoint.types.js +1 -1
- package/esm/transform/Entrypoint.types.js.map +1 -1
- package/esm/transform/EvaluatedEntrypoint.js +10 -4
- package/esm/transform/EvaluatedEntrypoint.js.map +1 -1
- package/esm/transform/actions/AbortError.js +6 -6
- package/esm/transform/actions/AbortError.js.map +1 -1
- package/esm/transform/actions/BaseAction.js +140 -136
- package/esm/transform/actions/BaseAction.js.map +1 -1
- package/esm/transform/actions/UnprocessedEntrypointError.js +6 -6
- package/esm/transform/actions/UnprocessedEntrypointError.js.map +1 -1
- package/esm/transform/actions/actionRunner.js +63 -66
- package/esm/transform/actions/actionRunner.js.map +1 -1
- package/esm/transform/actions/types.js +1 -1
- package/esm/transform/actions/types.js.map +1 -1
- package/esm/transform/barrelManifest.types.js +2 -0
- package/esm/transform/barrelManifest.types.js.map +1 -0
- package/esm/transform/generators/baseProcessingHandlers.js +15 -17
- package/esm/transform/generators/baseProcessingHandlers.js.map +1 -1
- package/esm/transform/generators/collect.js +27 -55
- package/esm/transform/generators/collect.js.map +1 -1
- package/esm/transform/generators/createStylisPreprocessor.js +353 -321
- package/esm/transform/generators/createStylisPreprocessor.js.map +1 -1
- package/esm/transform/generators/evalFile.js +48 -47
- package/esm/transform/generators/evalFile.js.map +1 -1
- package/esm/transform/generators/extract.js +78 -90
- package/esm/transform/generators/extract.js.map +1 -1
- package/esm/transform/generators/getExports.js +57 -74
- package/esm/transform/generators/getExports.js.map +1 -1
- package/esm/transform/generators/index.js +11 -11
- package/esm/transform/generators/index.js.map +1 -1
- package/esm/transform/generators/processEntrypoint.js +93 -67
- package/esm/transform/generators/processEntrypoint.js.map +1 -1
- package/esm/transform/generators/processImports.js +102 -67
- package/esm/transform/generators/processImports.js.map +1 -1
- package/esm/transform/generators/resolveImports.js +212 -197
- 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 +2 -0
- package/esm/transform/generators/resolveStaticOxcValues.js.map +1 -0
- package/esm/transform/generators/rewriteOxcBarrelImports.js +822 -0
- package/esm/transform/generators/rewriteOxcBarrelImports.js.map +1 -0
- package/esm/transform/generators/transform.js +251 -248
- package/esm/transform/generators/transform.js.map +1 -1
- package/esm/transform/generators/workflow.js +87 -90
- package/esm/transform/generators/workflow.js.map +1 -1
- package/esm/transform/helpers/loadWywOptions.js +183 -74
- package/esm/transform/helpers/loadWywOptions.js.map +1 -1
- package/esm/transform/helpers/withDefaultServices.js +13 -22
- package/esm/transform/helpers/withDefaultServices.js.map +1 -1
- package/esm/transform/isStaticallyEvaluatableModule.js +140 -152
- package/esm/transform/isStaticallyEvaluatableModule.js.map +1 -1
- package/esm/transform/oxcBarrelManifest.js +349 -0
- package/esm/transform/oxcBarrelManifest.js.map +1 -0
- package/esm/transform/rootLog.js +3 -3
- package/esm/transform/rootLog.js.map +1 -1
- package/esm/transform/syntax.js +2 -0
- package/esm/transform/syntax.js.map +1 -0
- package/esm/transform/types.js +2 -2
- package/esm/transform/types.js.map +1 -1
- package/esm/transform.js +125 -147
- package/esm/transform.js.map +1 -1
- package/esm/types.js +4 -1
- package/esm/types.js.map +1 -1
- package/esm/utils/EventEmitter.js +79 -48
- package/esm/utils/EventEmitter.js.map +1 -1
- package/esm/utils/ShakerMetadata.js +2 -2
- package/esm/utils/ShakerMetadata.js.map +1 -1
- package/esm/utils/TransformDiagnostics.js +9 -9
- package/esm/utils/TransformDiagnostics.js.map +1 -1
- package/esm/utils/TransformMetadata.js +24 -26
- package/esm/utils/TransformMetadata.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 +2 -0
- package/esm/utils/applyOxcProcessors.js.map +1 -0
- package/esm/utils/collectOxcExportsAndImports.js +934 -0
- package/esm/utils/collectOxcExportsAndImports.js.map +1 -0
- 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 +32 -0
- package/esm/utils/collectOxcRuntime.js.map +1 -0
- 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 +4 -0
- package/esm/utils/collectOxcTemplateDependencies.js.map +1 -0
- package/esm/utils/dispose-polyfill.js +3 -4
- package/esm/utils/dispose-polyfill.js.map +1 -1
- package/esm/utils/getFileIdx.js +6 -6
- package/esm/utils/getFileIdx.js.map +1 -1
- package/esm/utils/getPluginKey.js +12 -12
- package/esm/utils/getPluginKey.js.map +1 -1
- package/esm/utils/getVisitorKeys.js +9 -3
- package/esm/utils/getVisitorKeys.js.map +1 -1
- package/esm/utils/hasCachedWywPrevalExport.js +23 -0
- package/esm/utils/hasCachedWywPrevalExport.js.map +1 -0
- package/esm/utils/hasWywPreval.js +5 -5
- package/esm/utils/hasWywPreval.js.map +1 -1
- package/esm/utils/importOverrides.js +75 -90
- package/esm/utils/importOverrides.js.map +1 -1
- package/esm/utils/isNode.js +2 -2
- package/esm/utils/isNode.js.map +1 -1
- package/esm/utils/isNotNull.js +2 -2
- package/esm/utils/isNotNull.js.map +1 -1
- package/esm/utils/isSerializable.js +11 -11
- package/esm/utils/isSerializable.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/oxcAstService.js +121 -0
- package/esm/utils/oxcAstService.js.map +1 -0
- package/esm/utils/oxcEmit.js +447 -0
- package/esm/utils/oxcEmit.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 +41 -0
- package/esm/utils/oxcPreevalStage.js.map +1 -0
- package/esm/utils/oxcPreevalTransforms.js +1065 -0
- package/esm/utils/oxcPreevalTransforms.js.map +1 -0
- package/esm/utils/oxcShaker.js +662 -0
- package/esm/utils/oxcShaker.js.map +1 -0
- package/esm/utils/parseOxc.js +37 -0
- package/esm/utils/parseOxc.js.map +1 -0
- package/esm/utils/parseRequest.js +27 -27
- package/esm/utils/parseRequest.js.map +1 -1
- package/esm/utils/peek.js +1 -1
- package/esm/utils/peek.js.map +1 -1
- package/esm/utils/processorLookup.js +125 -0
- package/esm/utils/processorLookup.js.map +1 -0
- package/esm/utils/processorStaticSemantics.js +157 -0
- package/esm/utils/processorStaticSemantics.js.map +1 -0
- package/esm/utils/resolveWithConditions.js +99 -0
- package/esm/utils/resolveWithConditions.js.map +1 -0
- package/esm/vm/createVmContext.js +140 -141
- package/esm/vm/createVmContext.js.map +1 -1
- package/esm/vm/process.js +11 -13
- package/esm/vm/process.js.map +1 -1
- package/package.json +19 -26
- package/types/cache.d.ts +17 -8
- package/types/cache.js +245 -95
- package/types/debug/fileReporter.js +68 -23
- package/types/eval/broker.d.ts +92 -0
- package/types/eval/broker.js +2411 -0
- package/types/eval/lru.d.ts +10 -0
- package/types/eval/lru.js +36 -0
- package/types/eval/prepareModuleOnDemand.d.ts +7 -0
- package/types/eval/prepareModuleOnDemand.js +24 -0
- package/types/eval/protocol.d.ts +111 -0
- package/types/eval/protocol.js +1 -0
- package/types/eval/serialize.d.ts +78 -0
- package/types/eval/serialize.js +357 -0
- package/types/eval/writeQueue.d.ts +13 -0
- package/types/eval/writeQueue.js +80 -0
- package/types/evaluators/index.d.ts +2 -2
- package/types/evaluators/index.js +6 -9
- package/types/index.d.ts +3 -6
- package/types/index.js +24 -82
- package/types/module.d.ts +38 -7
- package/types/module.js +613 -192
- package/types/shaker.d.ts +2 -10
- package/types/shaker.js +10 -100
- package/types/transform/BaseEntrypoint.js +6 -11
- package/types/transform/Entrypoint.d.ts +15 -15
- package/types/transform/Entrypoint.helpers.d.ts +2 -5
- package/types/transform/Entrypoint.helpers.js +43 -203
- package/types/transform/Entrypoint.js +130 -53
- package/types/transform/Entrypoint.types.d.ts +31 -6
- package/types/transform/Entrypoint.types.js +1 -2
- package/types/transform/EvaluatedEntrypoint.d.ts +13 -2
- package/types/transform/EvaluatedEntrypoint.js +7 -6
- package/types/transform/actions/AbortError.js +2 -7
- package/types/transform/actions/BaseAction.js +4 -8
- package/types/transform/actions/UnprocessedEntrypointError.js +2 -7
- package/types/transform/actions/actionRunner.js +8 -12
- package/types/transform/actions/types.d.ts +2 -2
- package/types/transform/actions/types.js +1 -2
- package/types/transform/{barrelManifest.d.ts → barrelManifest.types.d.ts} +0 -2
- package/types/transform/barrelManifest.types.js +1 -0
- package/types/transform/generators/baseProcessingHandlers.d.ts +4 -5
- package/types/transform/generators/baseProcessingHandlers.js +10 -14
- package/types/transform/generators/collect.js +13 -39
- package/types/transform/generators/createStylisPreprocessor.js +19 -60
- package/types/transform/generators/evalFile.d.ts +2 -2
- package/types/transform/generators/evalFile.js +26 -28
- package/types/transform/generators/extract.js +5 -8
- package/types/transform/generators/getExports.js +23 -30
- package/types/transform/generators/index.d.ts +2 -2
- package/types/transform/generators/index.js +11 -14
- package/types/transform/generators/processEntrypoint.d.ts +2 -2
- package/types/transform/generators/processEntrypoint.js +60 -26
- package/types/transform/generators/processImports.d.ts +0 -3
- package/types/transform/generators/processImports.js +60 -20
- package/types/transform/generators/resolveImports.d.ts +3 -1
- package/types/transform/generators/resolveImports.js +66 -23
- 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 -0
- package/types/transform/generators/resolveStaticOxcValues.js +1 -0
- package/types/transform/generators/{rewriteBarrelImports.d.ts → rewriteOxcBarrelImports.d.ts} +2 -3
- package/types/transform/generators/{rewriteBarrelImports.js → rewriteOxcBarrelImports.js} +282 -225
- package/types/transform/generators/transform.d.ts +3 -7
- package/types/transform/generators/transform.js +217 -199
- package/types/transform/generators/workflow.js +62 -45
- package/types/transform/helpers/loadWywOptions.js +115 -21
- package/types/transform/helpers/withDefaultServices.d.ts +1 -1
- package/types/transform/helpers/withDefaultServices.js +6 -44
- package/types/transform/isStaticallyEvaluatableModule.d.ts +1 -2
- package/types/transform/isStaticallyEvaluatableModule.js +125 -126
- package/types/transform/oxcBarrelManifest.d.ts +2 -0
- package/types/transform/{barrelManifest.js → oxcBarrelManifest.js} +156 -97
- package/types/transform/rootLog.js +2 -5
- package/types/transform/syntax.d.ts +38 -0
- package/types/transform/syntax.js +1 -0
- package/types/transform/types.d.ts +9 -6
- package/types/transform/types.js +1 -4
- package/types/transform.d.ts +2 -2
- package/types/transform.js +90 -101
- package/types/types.d.ts +0 -23
- package/types/types.js +1 -2
- package/types/utils/EventEmitter.d.ts +16 -1
- package/types/utils/EventEmitter.js +47 -18
- package/types/utils/ShakerMetadata.js +1 -5
- package/types/utils/TransformDiagnostics.js +3 -7
- package/types/utils/TransformMetadata.js +8 -16
- 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 -0
- package/types/utils/applyOxcProcessors.js +1 -0
- package/types/utils/collectOxcExportsAndImports.d.ts +35 -0
- package/types/utils/collectOxcExportsAndImports.js +957 -0
- 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 +4 -0
- package/types/utils/collectOxcRuntime.js +31 -0
- 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 -0
- package/types/utils/collectOxcTemplateDependencies.js +3 -0
- package/types/utils/getFileIdx.js +1 -4
- package/types/utils/getPluginKey.d.ts +5 -2
- package/types/utils/getPluginKey.js +2 -6
- package/types/utils/getVisitorKeys.d.ts +4 -4
- package/types/utils/getVisitorKeys.js +9 -6
- package/types/utils/hasCachedWywPrevalExport.d.ts +14 -0
- package/types/utils/hasCachedWywPrevalExport.js +30 -0
- package/types/utils/hasWywPreval.js +1 -4
- package/types/utils/importOverrides.js +17 -27
- package/types/utils/isNode.d.ts +2 -2
- package/types/utils/isNode.js +2 -6
- package/types/utils/isNotNull.js +1 -4
- package/types/utils/isSerializable.js +3 -6
- 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/oxcAstService.d.ts +11 -0
- package/types/utils/oxcAstService.js +79 -0
- package/types/utils/oxcEmit.d.ts +19 -0
- package/types/utils/oxcEmit.js +506 -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 +4 -0
- package/types/utils/oxcPreevalStage.js +40 -0
- package/types/utils/oxcPreevalTransforms.d.ts +13 -0
- package/types/utils/oxcPreevalTransforms.js +1192 -0
- package/types/utils/oxcShaker.d.ts +13 -0
- package/types/utils/oxcShaker.js +751 -0
- package/types/utils/parseOxc.d.ts +11 -0
- package/types/utils/parseOxc.js +38 -0
- package/types/utils/parseRequest.js +2 -7
- package/types/utils/peek.js +1 -5
- package/types/utils/processorLookup.d.ts +8 -0
- package/types/utils/processorLookup.js +135 -0
- package/types/utils/processorStaticSemantics.d.ts +13 -0
- package/types/utils/processorStaticSemantics.js +191 -0
- package/types/utils/resolveWithConditions.d.ts +12 -0
- package/types/utils/resolveWithConditions.js +103 -0
- package/types/vm/createVmContext.d.ts +2 -2
- package/types/vm/createVmContext.js +25 -62
- package/types/vm/process.js +20 -26
- package/esm/babel.js +0 -2
- package/esm/babel.js.map +0 -1
- package/esm/options/buildOptions.js +0 -168
- package/esm/options/buildOptions.js.map +0 -1
- package/esm/options/buildOptions.test.js +0 -138
- package/esm/options/buildOptions.test.js.map +0 -1
- package/esm/options/loadBabelOptions.js +0 -24
- package/esm/options/loadBabelOptions.js.map +0 -1
- package/esm/plugins/babel-transform.js +0 -53
- package/esm/plugins/babel-transform.js.map +0 -1
- package/esm/plugins/collector.js +0 -60
- package/esm/plugins/collector.js.map +0 -1
- package/esm/plugins/dynamic-import.js +0 -56
- package/esm/plugins/dynamic-import.js.map +0 -1
- package/esm/plugins/preeval.js +0 -73
- package/esm/plugins/preeval.js.map +0 -1
- package/esm/plugins/shaker.js +0 -680
- package/esm/plugins/shaker.js.map +0 -1
- package/esm/transform/barrelManifest.js +0 -291
- package/esm/transform/barrelManifest.js.map +0 -1
- package/esm/transform/generators/explodeReexports.js +0 -64
- package/esm/transform/generators/explodeReexports.js.map +0 -1
- package/esm/transform/generators/rewriteBarrelImports.js +0 -733
- package/esm/transform/generators/rewriteBarrelImports.js.map +0 -1
- package/esm/utils/addIdentifierToWywPreval.js +0 -68
- package/esm/utils/addIdentifierToWywPreval.js.map +0 -1
- package/esm/utils/collectExportsAndImports.js +0 -1157
- package/esm/utils/collectExportsAndImports.js.map +0 -1
- package/esm/utils/collectTemplateDependencies.js +0 -228
- package/esm/utils/collectTemplateDependencies.js.map +0 -1
- package/esm/utils/createId.js +0 -6
- package/esm/utils/createId.js.map +0 -1
- package/esm/utils/findIdentifiers.js +0 -62
- package/esm/utils/findIdentifiers.js.map +0 -1
- package/esm/utils/getConstantStringValue.js +0 -58
- package/esm/utils/getConstantStringValue.js.map +0 -1
- package/esm/utils/getMemberExpressionPropertyName.js +0 -11
- package/esm/utils/getMemberExpressionPropertyName.js.map +0 -1
- package/esm/utils/getScope.js +0 -6
- package/esm/utils/getScope.js.map +0 -1
- package/esm/utils/getSource.js +0 -15
- package/esm/utils/getSource.js.map +0 -1
- package/esm/utils/getTagProcessor.js +0 -404
- package/esm/utils/getTagProcessor.js.map +0 -1
- package/esm/utils/isExports.js +0 -22
- package/esm/utils/isExports.js.map +0 -1
- package/esm/utils/isGlobal.js +0 -6
- package/esm/utils/isGlobal.js.map +0 -1
- package/esm/utils/isNodePath.js +0 -4
- package/esm/utils/isNodePath.js.map +0 -1
- package/esm/utils/isRemoved.js +0 -46
- package/esm/utils/isRemoved.js.map +0 -1
- package/esm/utils/isRequire.js +0 -13
- package/esm/utils/isRequire.js.map +0 -1
- package/esm/utils/isTypedNode.js +0 -6
- package/esm/utils/isTypedNode.js.map +0 -1
- package/esm/utils/isUnnecessaryReactCall.js +0 -72
- package/esm/utils/isUnnecessaryReactCall.js.map +0 -1
- package/esm/utils/removeDangerousCode.js +0 -276
- package/esm/utils/removeDangerousCode.js.map +0 -1
- package/esm/utils/replaceImportMetaEnv.js +0 -44
- package/esm/utils/replaceImportMetaEnv.js.map +0 -1
- package/esm/utils/scopeHelpers.js +0 -527
- package/esm/utils/scopeHelpers.js.map +0 -1
- package/esm/utils/traversalCache.js +0 -23
- package/esm/utils/traversalCache.js.map +0 -1
- package/esm/utils/unwrapExpression.js +0 -18
- package/esm/utils/unwrapExpression.js.map +0 -1
- package/esm/utils/unwrapSequence.js +0 -14
- package/esm/utils/unwrapSequence.js.map +0 -1
- package/esm/utils/valueToLiteral.js +0 -59
- package/esm/utils/valueToLiteral.js.map +0 -1
- package/esm/utils/visitors/JSXElementsRemover.js +0 -51
- package/esm/utils/visitors/JSXElementsRemover.js.map +0 -1
- package/lib/babel.js +0 -2
- package/lib/babel.js.map +0 -1
- package/lib/cache.js +0 -308
- package/lib/cache.js.map +0 -1
- package/lib/debug/fileReporter.js +0 -153
- package/lib/debug/fileReporter.js.map +0 -1
- package/lib/evaluators/index.js +0 -20
- package/lib/evaluators/index.js.map +0 -1
- package/lib/index.js +0 -286
- package/lib/index.js.map +0 -1
- package/lib/module.js +0 -552
- package/lib/module.js.map +0 -1
- package/lib/options/buildOptions.js +0 -176
- package/lib/options/buildOptions.js.map +0 -1
- package/lib/options/buildOptions.test.js +0 -141
- package/lib/options/buildOptions.test.js.map +0 -1
- package/lib/options/loadBabelOptions.js +0 -31
- package/lib/options/loadBabelOptions.js.map +0 -1
- package/lib/plugins/babel-transform.js +0 -60
- package/lib/plugins/babel-transform.js.map +0 -1
- package/lib/plugins/collector.js +0 -70
- package/lib/plugins/collector.js.map +0 -1
- package/lib/plugins/dynamic-import.js +0 -61
- package/lib/plugins/dynamic-import.js.map +0 -1
- package/lib/plugins/preeval.js +0 -81
- package/lib/plugins/preeval.js.map +0 -1
- package/lib/plugins/shaker.js +0 -691
- package/lib/plugins/shaker.js.map +0 -1
- package/lib/shaker.js +0 -95
- package/lib/shaker.js.map +0 -1
- package/lib/transform/BaseEntrypoint.js +0 -179
- package/lib/transform/BaseEntrypoint.js.map +0 -1
- package/lib/transform/Entrypoint.helpers.js +0 -279
- package/lib/transform/Entrypoint.helpers.js.map +0 -1
- package/lib/transform/Entrypoint.js +0 -289
- package/lib/transform/Entrypoint.js.map +0 -1
- package/lib/transform/Entrypoint.types.js +0 -2
- package/lib/transform/Entrypoint.types.js.map +0 -1
- package/lib/transform/EvaluatedEntrypoint.js +0 -13
- package/lib/transform/EvaluatedEntrypoint.js.map +0 -1
- package/lib/transform/actions/AbortError.js +0 -16
- package/lib/transform/actions/AbortError.js.map +0 -1
- package/lib/transform/actions/BaseAction.js +0 -150
- package/lib/transform/actions/BaseAction.js.map +0 -1
- package/lib/transform/actions/UnprocessedEntrypointError.js +0 -16
- package/lib/transform/actions/UnprocessedEntrypointError.js.map +0 -1
- package/lib/transform/actions/actionRunner.js +0 -82
- package/lib/transform/actions/actionRunner.js.map +0 -1
- package/lib/transform/actions/types.js +0 -2
- package/lib/transform/actions/types.js.map +0 -1
- package/lib/transform/barrelManifest.js +0 -300
- package/lib/transform/barrelManifest.js.map +0 -1
- package/lib/transform/generators/baseProcessingHandlers.js +0 -27
- package/lib/transform/generators/baseProcessingHandlers.js.map +0 -1
- package/lib/transform/generators/collect.js +0 -66
- package/lib/transform/generators/collect.js.map +0 -1
- package/lib/transform/generators/createStylisPreprocessor.js +0 -372
- package/lib/transform/generators/createStylisPreprocessor.js.map +0 -1
- package/lib/transform/generators/evalFile.js +0 -57
- package/lib/transform/generators/evalFile.js.map +0 -1
- package/lib/transform/generators/explodeReexports.js +0 -71
- package/lib/transform/generators/explodeReexports.js.map +0 -1
- package/lib/transform/generators/extract.js +0 -102
- package/lib/transform/generators/extract.js.map +0 -1
- package/lib/transform/generators/getExports.js +0 -85
- package/lib/transform/generators/getExports.js.map +0 -1
- package/lib/transform/generators/index.js +0 -19
- package/lib/transform/generators/index.js.map +0 -1
- package/lib/transform/generators/processEntrypoint.js +0 -76
- package/lib/transform/generators/processEntrypoint.js.map +0 -1
- package/lib/transform/generators/processImports.js +0 -82
- package/lib/transform/generators/processImports.js.map +0 -1
- package/lib/transform/generators/resolveImports.js +0 -221
- package/lib/transform/generators/resolveImports.js.map +0 -1
- package/lib/transform/generators/rewriteBarrelImports.js +0 -743
- package/lib/transform/generators/rewriteBarrelImports.js.map +0 -1
- package/lib/transform/generators/transform.js +0 -272
- package/lib/transform/generators/transform.js.map +0 -1
- package/lib/transform/generators/workflow.js +0 -100
- package/lib/transform/generators/workflow.js.map +0 -1
- package/lib/transform/helpers/loadWywOptions.js +0 -88
- package/lib/transform/helpers/loadWywOptions.js.map +0 -1
- package/lib/transform/helpers/withDefaultServices.js +0 -31
- package/lib/transform/helpers/withDefaultServices.js.map +0 -1
- package/lib/transform/isStaticallyEvaluatableModule.js +0 -159
- package/lib/transform/isStaticallyEvaluatableModule.js.map +0 -1
- package/lib/transform/rootLog.js +0 -9
- package/lib/transform/rootLog.js.map +0 -1
- package/lib/transform/types.js +0 -8
- package/lib/transform/types.js.map +0 -1
- package/lib/transform.js +0 -160
- package/lib/transform.js.map +0 -1
- package/lib/types.js +0 -2
- package/lib/types.js.map +0 -1
- package/lib/utils/EventEmitter.js +0 -61
- package/lib/utils/EventEmitter.js.map +0 -1
- package/lib/utils/ShakerMetadata.js +0 -9
- package/lib/utils/ShakerMetadata.js.map +0 -1
- package/lib/utils/TransformDiagnostics.js +0 -20
- package/lib/utils/TransformDiagnostics.js.map +0 -1
- package/lib/utils/TransformMetadata.js +0 -45
- package/lib/utils/TransformMetadata.js.map +0 -1
- package/lib/utils/addIdentifierToWywPreval.js +0 -75
- package/lib/utils/addIdentifierToWywPreval.js.map +0 -1
- package/lib/utils/collectExportsAndImports.js +0 -1173
- package/lib/utils/collectExportsAndImports.js.map +0 -1
- package/lib/utils/collectTemplateDependencies.js +0 -242
- package/lib/utils/collectTemplateDependencies.js.map +0 -1
- package/lib/utils/createId.js +0 -13
- package/lib/utils/createId.js.map +0 -1
- package/lib/utils/dispose-polyfill.js +0 -9
- package/lib/utils/dispose-polyfill.js.map +0 -1
- package/lib/utils/findIdentifiers.js +0 -73
- package/lib/utils/findIdentifiers.js.map +0 -1
- package/lib/utils/getConstantStringValue.js +0 -66
- package/lib/utils/getConstantStringValue.js.map +0 -1
- package/lib/utils/getFileIdx.js +0 -16
- package/lib/utils/getFileIdx.js.map +0 -1
- package/lib/utils/getMemberExpressionPropertyName.js +0 -18
- package/lib/utils/getMemberExpressionPropertyName.js.map +0 -1
- package/lib/utils/getPluginKey.js +0 -21
- package/lib/utils/getPluginKey.js.map +0 -1
- package/lib/utils/getScope.js +0 -12
- package/lib/utils/getScope.js.map +0 -1
- package/lib/utils/getSource.js +0 -24
- package/lib/utils/getSource.js.map +0 -1
- package/lib/utils/getTagProcessor.js +0 -424
- package/lib/utils/getTagProcessor.js.map +0 -1
- package/lib/utils/getVisitorKeys.js +0 -11
- package/lib/utils/getVisitorKeys.js.map +0 -1
- package/lib/utils/hasWywPreval.js +0 -13
- package/lib/utils/hasWywPreval.js.map +0 -1
- package/lib/utils/importOverrides.js +0 -119
- package/lib/utils/importOverrides.js.map +0 -1
- package/lib/utils/isExports.js +0 -27
- package/lib/utils/isExports.js.map +0 -1
- package/lib/utils/isGlobal.js +0 -13
- package/lib/utils/isGlobal.js.map +0 -1
- package/lib/utils/isNode.js +0 -9
- package/lib/utils/isNode.js.map +0 -1
- package/lib/utils/isNodePath.js +0 -10
- package/lib/utils/isNodePath.js.map +0 -1
- package/lib/utils/isNotNull.js +0 -10
- package/lib/utils/isNotNull.js.map +0 -1
- package/lib/utils/isRemoved.js +0 -52
- package/lib/utils/isRemoved.js.map +0 -1
- package/lib/utils/isRequire.js +0 -18
- package/lib/utils/isRequire.js.map +0 -1
- package/lib/utils/isSerializable.js +0 -19
- package/lib/utils/isSerializable.js.map +0 -1
- package/lib/utils/isTypedNode.js +0 -13
- package/lib/utils/isTypedNode.js.map +0 -1
- package/lib/utils/isUnnecessaryReactCall.js +0 -81
- package/lib/utils/isUnnecessaryReactCall.js.map +0 -1
- package/lib/utils/parseRequest.js +0 -37
- package/lib/utils/parseRequest.js.map +0 -1
- package/lib/utils/peek.js +0 -9
- package/lib/utils/peek.js.map +0 -1
- package/lib/utils/removeDangerousCode.js +0 -284
- package/lib/utils/removeDangerousCode.js.map +0 -1
- package/lib/utils/replaceImportMetaEnv.js +0 -50
- package/lib/utils/replaceImportMetaEnv.js.map +0 -1
- package/lib/utils/scopeHelpers.js +0 -557
- package/lib/utils/scopeHelpers.js.map +0 -1
- package/lib/utils/traversalCache.js +0 -31
- package/lib/utils/traversalCache.js.map +0 -1
- package/lib/utils/unwrapExpression.js +0 -25
- package/lib/utils/unwrapExpression.js.map +0 -1
- package/lib/utils/unwrapSequence.js +0 -20
- package/lib/utils/unwrapSequence.js.map +0 -1
- package/lib/utils/valueToLiteral.js +0 -65
- package/lib/utils/valueToLiteral.js.map +0 -1
- package/lib/utils/visitors/JSXElementsRemover.js +0 -57
- package/lib/utils/visitors/JSXElementsRemover.js.map +0 -1
- package/lib/vm/createVmContext.js +0 -166
- package/lib/vm/createVmContext.js.map +0 -1
- package/lib/vm/process.js +0 -38
- package/lib/vm/process.js.map +0 -1
- package/types/babel.d.ts +0 -2
- package/types/babel.js +0 -2
- package/types/options/buildOptions.d.ts +0 -6
- package/types/options/buildOptions.js +0 -178
- package/types/options/loadBabelOptions.d.ts +0 -3
- package/types/options/loadBabelOptions.js +0 -26
- package/types/plugins/babel-transform.d.ts +0 -4
- package/types/plugins/babel-transform.js +0 -49
- package/types/plugins/collector.d.ts +0 -23
- package/types/plugins/collector.js +0 -62
- package/types/plugins/dynamic-import.d.ts +0 -6
- package/types/plugins/dynamic-import.js +0 -60
- package/types/plugins/preeval.d.ts +0 -16
- package/types/plugins/preeval.js +0 -69
- package/types/plugins/shaker.d.ts +0 -14
- package/types/plugins/shaker.js +0 -724
- package/types/transform/generators/explodeReexports.d.ts +0 -7
- package/types/transform/generators/explodeReexports.js +0 -65
- package/types/utils/addIdentifierToWywPreval.d.ts +0 -4
- package/types/utils/addIdentifierToWywPreval.js +0 -74
- package/types/utils/collectExportsAndImports.d.ts +0 -31
- package/types/utils/collectExportsAndImports.js +0 -1147
- package/types/utils/collectTemplateDependencies.d.ts +0 -17
- package/types/utils/collectTemplateDependencies.js +0 -220
- package/types/utils/createId.d.ts +0 -2
- package/types/utils/createId.js +0 -9
- package/types/utils/findIdentifiers.d.ts +0 -6
- package/types/utils/findIdentifiers.js +0 -67
- package/types/utils/getConstantStringValue.d.ts +0 -2
- package/types/utils/getConstantStringValue.js +0 -94
- package/types/utils/getMemberExpressionPropertyName.d.ts +0 -2
- package/types/utils/getMemberExpressionPropertyName.js +0 -46
- package/types/utils/getScope.d.ts +0 -2
- package/types/utils/getScope.js +0 -10
- package/types/utils/getSource.d.ts +0 -2
- package/types/utils/getSource.js +0 -22
- package/types/utils/getTagProcessor.d.ts +0 -13
- package/types/utils/getTagProcessor.js +0 -411
- package/types/utils/isExports.d.ts +0 -6
- package/types/utils/isExports.js +0 -19
- package/types/utils/isGlobal.d.ts +0 -2
- package/types/utils/isGlobal.js +0 -9
- package/types/utils/isNodePath.d.ts +0 -3
- package/types/utils/isNodePath.js +0 -6
- package/types/utils/isRemoved.d.ts +0 -5
- package/types/utils/isRemoved.js +0 -41
- package/types/utils/isRequire.d.ts +0 -6
- package/types/utils/isRequire.js +0 -14
- package/types/utils/isTypedNode.d.ts +0 -5
- package/types/utils/isTypedNode.js +0 -9
- package/types/utils/isUnnecessaryReactCall.d.ts +0 -3
- package/types/utils/isUnnecessaryReactCall.js +0 -75
- package/types/utils/removeDangerousCode.d.ts +0 -4
- package/types/utils/removeDangerousCode.js +0 -326
- package/types/utils/replaceImportMetaEnv.d.ts +0 -3
- package/types/utils/replaceImportMetaEnv.js +0 -39
- package/types/utils/scopeHelpers.d.ts +0 -12
- package/types/utils/scopeHelpers.js +0 -580
- package/types/utils/traversalCache.d.ts +0 -4
- package/types/utils/traversalCache.js +0 -27
- package/types/utils/unwrapExpression.d.ts +0 -2
- package/types/utils/unwrapExpression.js +0 -57
- package/types/utils/unwrapSequence.d.ts +0 -8
- package/types/utils/unwrapSequence.js +0 -16
- package/types/utils/valueToLiteral.d.ts +0 -3
- package/types/utils/valueToLiteral.js +0 -63
- package/types/utils/visitors/JSXElementsRemover.d.ts +0 -3
- package/types/utils/visitors/JSXElementsRemover.js +0 -51
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import { collectOxcProcessorImportsFromProgram } from "../../../utils/collectOxcExportsAndImports.js";
|
|
2
|
+
import { getOxcNodeChildren } from "../../../utils/oxc/ast.js";
|
|
3
|
+
import { getProcessorForImport } from "../../../utils/processorLookup.js";
|
|
4
|
+
import { resolveProcessorStaticClassName } from "../../../utils/processorStaticSemantics.js";
|
|
5
|
+
import { parseProgram } from "./environment.js";
|
|
6
|
+
import { findObjectPropertyValue, findTopLevelConstExpression, objectPropertyKeyName } from "./programAnalysis.js";
|
|
7
|
+
import { isSafeLiteral, unwrapExpression } from "./staticExpression.js";
|
|
8
|
+
import { GENERATED_HELPER_NAME_RE } from "./types.js";
|
|
9
|
+
export const collectProcessorImportLocals = (action, program, code, filename) => {
|
|
10
|
+
const result = new Set();
|
|
11
|
+
collectOxcProcessorImportsFromProgram(program, code).forEach((item) => {
|
|
12
|
+
if (item.type !== "esm" || item.imported === "*" || item.imported === "side-effect") {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const localName = item.local.name ?? item.local.code;
|
|
16
|
+
if (!localName) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const [processor] = getProcessorForImport({
|
|
20
|
+
imported: item.imported,
|
|
21
|
+
source: item.source
|
|
22
|
+
}, filename, action.services.options.pluginOptions);
|
|
23
|
+
if (!processor) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
result.add(localName);
|
|
27
|
+
const rootLocalName = localName.split(".")[0];
|
|
28
|
+
if (rootLocalName) {
|
|
29
|
+
result.add(rootLocalName);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
export const isStaticWYWMetaValue = (value, seen = new Set()) => {
|
|
35
|
+
if (typeof value !== "object" || value === null) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (seen.has(value)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
seen.add(value);
|
|
42
|
+
const meta = value.__wyw_meta;
|
|
43
|
+
if (typeof meta !== "object" || meta === null) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
const { className, extends: extended } = meta;
|
|
47
|
+
return typeof className === "string" && (extended === null || isStaticWYWMetaValue(extended, seen));
|
|
48
|
+
};
|
|
49
|
+
export const toStaticWYWSelectorMetaValue = (value, seen = new Set()) => {
|
|
50
|
+
if (typeof value !== "object" || value === null || seen.has(value)) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
seen.add(value);
|
|
54
|
+
const meta = value.__wyw_meta;
|
|
55
|
+
if (typeof meta !== "object" || meta === null) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const { className, extends: extended } = meta;
|
|
59
|
+
if (typeof className !== "string") {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const staticExtends = extended === null ? null : toStaticWYWSelectorMetaValue(extended, seen);
|
|
63
|
+
if (extended !== null && staticExtends === null) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return { __wyw_meta: {
|
|
67
|
+
className,
|
|
68
|
+
extends: staticExtends
|
|
69
|
+
} };
|
|
70
|
+
};
|
|
71
|
+
export const staticWYWMetaExtendsReplacementCode = (value) => {
|
|
72
|
+
if (value === null) {
|
|
73
|
+
return "null";
|
|
74
|
+
}
|
|
75
|
+
const selectorMeta = toStaticWYWSelectorMetaValue(value);
|
|
76
|
+
return selectorMeta ? `(${JSON.stringify(selectorMeta)})` : null;
|
|
77
|
+
};
|
|
78
|
+
export const unknownStaticWYWMetaValue = Symbol("unknownStaticWYWMetaValue");
|
|
79
|
+
export const zeroArgFunctionExpressionBody = (expr) => {
|
|
80
|
+
const unwrapped = unwrapExpression(expr);
|
|
81
|
+
if (unwrapped.type !== "ArrowFunctionExpression" || !Array.isArray(unwrapped.params) || unwrapped.params.length !== 0) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const body = unwrapped.body;
|
|
85
|
+
return body && body.type !== "BlockStatement" ? body : null;
|
|
86
|
+
};
|
|
87
|
+
export const isNullLiteralExpression = (node) => {
|
|
88
|
+
const unwrapped = unwrapExpression(node);
|
|
89
|
+
return isSafeLiteral(unwrapped) && unwrapped.value === null;
|
|
90
|
+
};
|
|
91
|
+
export const isNullReturningFunctionExpression = (expr) => {
|
|
92
|
+
const unwrapped = unwrapExpression(expr);
|
|
93
|
+
if (unwrapped.type !== "ArrowFunctionExpression" && unwrapped.type !== "FunctionExpression") {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
if (unwrapped.async || unwrapped.generator) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
const body = unwrapped.body;
|
|
100
|
+
if (!body) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
if (body.type !== "BlockStatement") {
|
|
104
|
+
return isNullLiteralExpression(body);
|
|
105
|
+
}
|
|
106
|
+
if (!Array.isArray(body.body) || body.body.length !== 1) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
const [statement] = body.body;
|
|
110
|
+
return statement?.type === "ReturnStatement" && !!statement.argument && isNullLiteralExpression(statement.argument);
|
|
111
|
+
};
|
|
112
|
+
export const createSameFileStaticWYWMetaHelperResolver = (code, filename) => {
|
|
113
|
+
const declarations = new Map();
|
|
114
|
+
const nullFunctionNames = new Set();
|
|
115
|
+
try {
|
|
116
|
+
const program = parseProgram(code, filename);
|
|
117
|
+
const collectDeclarations = (statement) => {
|
|
118
|
+
if (statement.type === "VariableDeclaration") {
|
|
119
|
+
statement.declarations.forEach((declarator) => {
|
|
120
|
+
if (declarator.id.type !== "Identifier" || !declarator.init) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const { name } = declarator.id;
|
|
124
|
+
const init = declarator.init;
|
|
125
|
+
if (isNullReturningFunctionExpression(init)) {
|
|
126
|
+
nullFunctionNames.add(name);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const unwrapped = unwrapExpression(init);
|
|
130
|
+
if (unwrapped.type === "ObjectExpression" && findObjectPropertyValue(unwrapped, "__wyw_meta")) {
|
|
131
|
+
declarations.set(name, init);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const body = zeroArgFunctionExpressionBody(init);
|
|
135
|
+
if (body && GENERATED_HELPER_NAME_RE.test(name)) {
|
|
136
|
+
declarations.set(name, body);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
program.body.forEach((statement) => {
|
|
142
|
+
if (statement.type === "ExportNamedDeclaration" && statement.declaration) {
|
|
143
|
+
collectDeclarations(statement.declaration);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
collectDeclarations(statement);
|
|
147
|
+
});
|
|
148
|
+
} catch {
|
|
149
|
+
return () => new Map();
|
|
150
|
+
}
|
|
151
|
+
return (seedValues) => {
|
|
152
|
+
const memo = new Map();
|
|
153
|
+
const resolving = new Set();
|
|
154
|
+
const resolveName = (name) => {
|
|
155
|
+
if (seedValues.has(name)) {
|
|
156
|
+
return seedValues.get(name);
|
|
157
|
+
}
|
|
158
|
+
if (memo.has(name)) {
|
|
159
|
+
return memo.get(name);
|
|
160
|
+
}
|
|
161
|
+
const expression = declarations.get(name);
|
|
162
|
+
if (!expression || resolving.has(name)) {
|
|
163
|
+
if (nullFunctionNames.has(name)) {
|
|
164
|
+
memo.set(name, null);
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
return unknownStaticWYWMetaValue;
|
|
168
|
+
}
|
|
169
|
+
resolving.add(name);
|
|
170
|
+
const value = resolveExpression(expression);
|
|
171
|
+
resolving.delete(name);
|
|
172
|
+
memo.set(name, value);
|
|
173
|
+
return value;
|
|
174
|
+
};
|
|
175
|
+
const resolveExpression = (expression) => {
|
|
176
|
+
const unwrapped = unwrapExpression(expression);
|
|
177
|
+
if (isSafeLiteral(unwrapped)) {
|
|
178
|
+
return unwrapped.value;
|
|
179
|
+
}
|
|
180
|
+
if (unwrapped.type === "Identifier") {
|
|
181
|
+
return resolveName(unwrapped.name);
|
|
182
|
+
}
|
|
183
|
+
if (unwrapped.type === "CallExpression") {
|
|
184
|
+
const callee = unwrapExpression(unwrapped.callee);
|
|
185
|
+
if (callee.type === "Identifier" && unwrapped.arguments.length === 0) {
|
|
186
|
+
return resolveName(callee.name);
|
|
187
|
+
}
|
|
188
|
+
return unknownStaticWYWMetaValue;
|
|
189
|
+
}
|
|
190
|
+
if (unwrapped.type !== "ObjectExpression") {
|
|
191
|
+
return unknownStaticWYWMetaValue;
|
|
192
|
+
}
|
|
193
|
+
const value = {};
|
|
194
|
+
for (const property of unwrapped.properties) {
|
|
195
|
+
if (property.type === "SpreadElement") {
|
|
196
|
+
return unknownStaticWYWMetaValue;
|
|
197
|
+
}
|
|
198
|
+
const propertyNode = property;
|
|
199
|
+
if (propertyNode.computed) {
|
|
200
|
+
return unknownStaticWYWMetaValue;
|
|
201
|
+
}
|
|
202
|
+
const propertyKey = propertyNode.key;
|
|
203
|
+
const key = propertyKey ? objectPropertyKeyName(propertyKey) : null;
|
|
204
|
+
const propertyValue = propertyNode.value;
|
|
205
|
+
if (key === null || !propertyValue) {
|
|
206
|
+
return unknownStaticWYWMetaValue;
|
|
207
|
+
}
|
|
208
|
+
const resolved = resolveExpression(propertyValue);
|
|
209
|
+
if (resolved === unknownStaticWYWMetaValue) {
|
|
210
|
+
return unknownStaticWYWMetaValue;
|
|
211
|
+
}
|
|
212
|
+
value[key] = resolved;
|
|
213
|
+
}
|
|
214
|
+
return value;
|
|
215
|
+
};
|
|
216
|
+
const result = new Map();
|
|
217
|
+
declarations.forEach((_expression, name) => {
|
|
218
|
+
if (!GENERATED_HELPER_NAME_RE.test(name)) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const value = resolveName(name);
|
|
222
|
+
if (value !== unknownStaticWYWMetaValue && (value === null || isStaticWYWMetaValue(value))) {
|
|
223
|
+
result.set(name, value);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
return result;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
export const staticWYWMetaTreeValueStatus = (value, seen = new Set()) => {
|
|
230
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
231
|
+
return {
|
|
232
|
+
hasMetadata: false,
|
|
233
|
+
safe: true
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
if (typeof value !== "object") {
|
|
237
|
+
return {
|
|
238
|
+
hasMetadata: false,
|
|
239
|
+
safe: false
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
if (seen.has(value)) {
|
|
243
|
+
return {
|
|
244
|
+
hasMetadata: false,
|
|
245
|
+
safe: false
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
seen.add(value);
|
|
249
|
+
if (Array.isArray(value)) {
|
|
250
|
+
let hasMetadata = false;
|
|
251
|
+
for (const item of value) {
|
|
252
|
+
const status = staticWYWMetaTreeValueStatus(item, seen);
|
|
253
|
+
if (!status.safe) {
|
|
254
|
+
return {
|
|
255
|
+
hasMetadata: false,
|
|
256
|
+
safe: false
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
hasMetadata = hasMetadata || status.hasMetadata;
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
hasMetadata,
|
|
263
|
+
safe: true
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
if ("__wyw_meta" in value) {
|
|
267
|
+
return {
|
|
268
|
+
hasMetadata: isStaticWYWMetaValue(value),
|
|
269
|
+
safe: isStaticWYWMetaValue(value)
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
let hasMetadata = false;
|
|
273
|
+
for (const item of Object.values(value)) {
|
|
274
|
+
const status = staticWYWMetaTreeValueStatus(item, seen);
|
|
275
|
+
if (!status.safe) {
|
|
276
|
+
return {
|
|
277
|
+
hasMetadata: false,
|
|
278
|
+
safe: false
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
hasMetadata = hasMetadata || status.hasMetadata;
|
|
282
|
+
}
|
|
283
|
+
return {
|
|
284
|
+
hasMetadata,
|
|
285
|
+
safe: true
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
export const isStaticWYWMetaTreeValue = (value) => {
|
|
289
|
+
const status = staticWYWMetaTreeValueStatus(value);
|
|
290
|
+
return status.safe && status.hasMetadata;
|
|
291
|
+
};
|
|
292
|
+
export const processorClassNameRuntimeValue = (processor) => resolveProcessorStaticClassName(processor) ?? processor.className;
|
|
293
|
+
export const isProcessorRuntimeClassName = (processor, value) => processor.className === value || resolveProcessorStaticClassName(processor) === value;
|
|
294
|
+
export const isPlainObjectRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
295
|
+
export const isStaticObjectAssignAliasValue = (value) => isStaticWYWMetaValue(value) || isStaticWYWMetaTreeValue(value);
|
|
296
|
+
export const artifactCssText = (artifact) => {
|
|
297
|
+
if (!Array.isArray(artifact) || artifact[0] !== "css") {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
const payload = artifact[1];
|
|
301
|
+
if (Array.isArray(payload)) {
|
|
302
|
+
const [rules] = payload;
|
|
303
|
+
if (typeof rules === "object" && rules !== null) {
|
|
304
|
+
return Object.values(rules).map((rule) => typeof rule === "object" && rule !== null && "cssText" in rule && typeof rule.cssText === "string" ? rule.cssText : "").join("");
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (typeof payload === "object" && payload !== null && "cssText" in payload && typeof payload.cssText === "string") {
|
|
308
|
+
return payload.cssText;
|
|
309
|
+
}
|
|
310
|
+
return null;
|
|
311
|
+
};
|
|
312
|
+
export const isEmptyProcessorClassName = (value, processors, cache) => {
|
|
313
|
+
if (cache.has(value)) {
|
|
314
|
+
return cache.get(value);
|
|
315
|
+
}
|
|
316
|
+
const processor = processors.find((item) => isProcessorRuntimeClassName(item, value));
|
|
317
|
+
if (!processor) {
|
|
318
|
+
cache.set(value, false);
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
if (processor.artifacts.length === 0) {
|
|
322
|
+
try {
|
|
323
|
+
processor.build(new Map());
|
|
324
|
+
} catch {
|
|
325
|
+
cache.set(value, false);
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
const result = processor.artifacts.every((artifact) => {
|
|
330
|
+
const cssText = artifactCssText(artifact);
|
|
331
|
+
return cssText !== null && cssText.trim() === "";
|
|
332
|
+
});
|
|
333
|
+
cache.set(value, result);
|
|
334
|
+
return result;
|
|
335
|
+
};
|
|
336
|
+
export const isProcessorClassName = (value, processors, cache) => {
|
|
337
|
+
if (cache.has(value)) {
|
|
338
|
+
return cache.get(value);
|
|
339
|
+
}
|
|
340
|
+
const processor = processors.find((item) => isProcessorRuntimeClassName(item, value));
|
|
341
|
+
if (!processor) {
|
|
342
|
+
cache.set(value, false);
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
if (processor.artifacts.length === 0) {
|
|
346
|
+
try {
|
|
347
|
+
processor.build(new Map());
|
|
348
|
+
} catch {
|
|
349
|
+
cache.set(value, false);
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
const result = processor.artifacts.every((artifact) => artifactCssText(artifact) !== null);
|
|
354
|
+
cache.set(value, result);
|
|
355
|
+
return result;
|
|
356
|
+
};
|
|
357
|
+
export const isKnownProcessorClassName = (value, processorClassNames) => processorClassNames.has(value);
|
|
358
|
+
export const isSelectorOnlyProcessorValue = (value, processors, cache, seen = new Set()) => {
|
|
359
|
+
if (typeof value === "string") {
|
|
360
|
+
return isEmptyProcessorClassName(value, processors, cache);
|
|
361
|
+
}
|
|
362
|
+
if (Array.isArray(value)) {
|
|
363
|
+
if (seen.has(value)) {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
seen.add(value);
|
|
367
|
+
return value.every((item) => isSelectorOnlyProcessorValue(item, processors, cache, seen));
|
|
368
|
+
}
|
|
369
|
+
if (typeof value === "object" && value !== null) {
|
|
370
|
+
if (seen.has(value)) {
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
seen.add(value);
|
|
374
|
+
return Object.values(value).every((item) => isSelectorOnlyProcessorValue(item, processors, cache, seen));
|
|
375
|
+
}
|
|
376
|
+
return false;
|
|
377
|
+
};
|
|
378
|
+
export const isProcessorClassValue = (value, processors, cache, seen = new Set()) => {
|
|
379
|
+
if (typeof value === "string") {
|
|
380
|
+
return isProcessorClassName(value, processors, cache);
|
|
381
|
+
}
|
|
382
|
+
if (Array.isArray(value)) {
|
|
383
|
+
if (seen.has(value)) {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
seen.add(value);
|
|
387
|
+
return value.every((item) => isProcessorClassValue(item, processors, cache, seen));
|
|
388
|
+
}
|
|
389
|
+
if (typeof value === "object" && value !== null) {
|
|
390
|
+
if (seen.has(value)) {
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
seen.add(value);
|
|
394
|
+
return Object.values(value).every((item) => isProcessorClassValue(item, processors, cache, seen));
|
|
395
|
+
}
|
|
396
|
+
return false;
|
|
397
|
+
};
|
|
398
|
+
export const isKnownProcessorClassValue = (value, processorClassNames, seen = new Set()) => {
|
|
399
|
+
if (typeof value === "string") {
|
|
400
|
+
return isKnownProcessorClassName(value, processorClassNames);
|
|
401
|
+
}
|
|
402
|
+
if (Array.isArray(value)) {
|
|
403
|
+
if (seen.has(value)) {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
seen.add(value);
|
|
407
|
+
return value.every((item) => isKnownProcessorClassValue(item, processorClassNames, seen));
|
|
408
|
+
}
|
|
409
|
+
if (typeof value === "object" && value !== null) {
|
|
410
|
+
if (seen.has(value)) {
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
seen.add(value);
|
|
414
|
+
return Object.values(value).every((item) => isKnownProcessorClassValue(item, processorClassNames, seen));
|
|
415
|
+
}
|
|
416
|
+
return false;
|
|
417
|
+
};
|
|
418
|
+
export const findWYWMetaExtendsExpression = (expr) => {
|
|
419
|
+
const meta = findObjectPropertyValue(expr, "__wyw_meta");
|
|
420
|
+
if (!meta) {
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
return findObjectPropertyValue(meta, "extends");
|
|
424
|
+
};
|
|
425
|
+
export const collectWYWMetaExtendsExpressionsDeep = (program, expr) => {
|
|
426
|
+
const result = [];
|
|
427
|
+
const seenLocals = new Set();
|
|
428
|
+
const seenRanges = new Set();
|
|
429
|
+
const visit = (node, parent = null) => {
|
|
430
|
+
const parentRecord = parent;
|
|
431
|
+
if (parentRecord && parentRecord.type === "Property" && parentRecord.key === node && !parentRecord.computed) {
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
if (node.type === "ObjectExpression") {
|
|
435
|
+
const extendsExpression = findWYWMetaExtendsExpression(node);
|
|
436
|
+
if (extendsExpression) {
|
|
437
|
+
const key = `${extendsExpression.start}:${extendsExpression.end}`;
|
|
438
|
+
if (!seenRanges.has(key)) {
|
|
439
|
+
seenRanges.add(key);
|
|
440
|
+
result.push(extendsExpression);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
if (node.type === "Identifier") {
|
|
445
|
+
const local = findTopLevelConstExpression(program, node.name);
|
|
446
|
+
if (local && !seenLocals.has(node.name)) {
|
|
447
|
+
seenLocals.add(node.name);
|
|
448
|
+
visit(local);
|
|
449
|
+
}
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
getOxcNodeChildren(node).forEach((child) => visit(child, node));
|
|
453
|
+
};
|
|
454
|
+
visit(expr);
|
|
455
|
+
return result;
|
|
456
|
+
};
|
|
457
|
+
export const isStaticMetaObjectExpression = (expr) => {
|
|
458
|
+
const meta = findObjectPropertyValue(expr, "__wyw_meta");
|
|
459
|
+
return !!meta && findObjectPropertyValue(meta, "className") !== null;
|
|
460
|
+
};
|
|
461
|
+
export const collectWYWMetaExtendsHelperNames = (program) => {
|
|
462
|
+
const result = new Set();
|
|
463
|
+
const visit = (node) => {
|
|
464
|
+
if (node.type === "ObjectExpression") {
|
|
465
|
+
const extendsExpression = findWYWMetaExtendsExpression(node);
|
|
466
|
+
const unwrapped = extendsExpression ? unwrapExpression(extendsExpression) : null;
|
|
467
|
+
if (unwrapped?.type === "CallExpression" && unwrapped.callee.type === "Identifier" && unwrapped.arguments.length === 0) {
|
|
468
|
+
result.add(unwrapped.callee.name);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
getOxcNodeChildren(node).forEach(visit);
|
|
472
|
+
};
|
|
473
|
+
visit(program);
|
|
474
|
+
return result;
|
|
475
|
+
};
|
|
476
|
+
//# sourceMappingURL=processorStaticModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAKA,SAAS,6CAA6C;AACtD,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,uCAAuC;AAEhD,SAAS,oBAAoB;AAC7B,SACE,yBACA,6BACA,6BACK;AACP,SAAS,eAAe,wBAAwB;AAEhD,SAAS,gCAAgC;AAEzC,OAAO,MAAM,gCACX,QACA,SACA,MACA,aACgB;CAChB,MAAM,SAAS,IAAI,KAAa;AAEhC,uCAAsC,SAAS,KAAK,CAAC,SAAS,SAAS;AACrE,MACE,KAAK,SAAS,SACd,KAAK,aAAa,OAClB,KAAK,aAAa,eAClB;AACA;;EAGF,MAAM,YAAY,KAAK,MAA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AM,QAAQ,4BAA4B,SAAS,KAAK,KAAK;AAC7D,OAAI,SAAS,CAAC,WAAW,IAAI,KAAK,KAAK,EAAE;AACvC,eAAW,IAAI,KAAK,KAAK;AACzB,UAAM,MAAM;;AAEd;;AAGF,qBAAmB,KAAK,CAAC,SAAS,UAAU,MAAM,OAAO,KAAK,CAAC;;AAGjE,OAAM,KAAK;AACX,QAAO;;AAET,OAAO,MAAM,gCAAgC,SAAwB;CACnE,MAAM,OAAO,wBAAwB,MAAM,aAAa;AACxD,QAAO,CAAC,CAAC,QAAQ,wBAAwB,MAAM,YAAY,KAAK;;AAElE,OAAO,MAAM,oCACX,YACgB;CAChB,MAAM,SAAS,IAAI,KAAa;CAEhC,MAAM,SAAS,SAAqB;AAClC,MAAI,KAAK,SAAS,oBAAoB;GACpC,MAAM,oBAAoB,6BAA6B,KAAK;GAC5D,MAAM,YAAY,oBACd,iBAAiB,kBAAkB,GACnC;AACJ,OACE,WAAW,SAAS,oBACpB,UAAU,OAAO,SAAS,gBAC1B,UAAU,UAAU,WAAW,GAC/B;AACA,WAAO,IAAI,UAAU,OAAO,KAAK;;;AAIrC,qBAAmB,KAAK,CAAC,QAAQ,MAAM;;AAGzC,OAAM,QAAQ;AACd,QAAO","names":[],"sources":["../../../../src/transform/generators/resolveStaticOxcValues/processorStaticModel.ts"],"version":3,"sourcesContent":["/* eslint-disable no-restricted-syntax,no-continue,@typescript-eslint/no-use-before-define */\n\nimport type { BaseProcessor } from '@wyw-in-js/processor-utils';\nimport type { Expression, Node, Program } from 'oxc-parser';\n\nimport { collectOxcProcessorImportsFromProgram } from '../../../utils/collectOxcExportsAndImports';\nimport { getOxcNodeChildren } from '../../../utils/oxc/ast';\nimport { getProcessorForImport } from '../../../utils/processorLookup';\nimport { resolveProcessorStaticClassName } from '../../../utils/processorStaticSemantics';\nimport type { ITransformAction } from '../../types';\nimport { parseProgram } from './environment';\nimport {\n findObjectPropertyValue,\n findTopLevelConstExpression,\n objectPropertyKeyName,\n} from './programAnalysis';\nimport { isSafeLiteral, unwrapExpression } from './staticExpression';\nimport type { AnyNode } from './types';\nimport { GENERATED_HELPER_NAME_RE } from './types';\n\nexport const collectProcessorImportLocals = (\n action: ITransformAction,\n program: Program,\n code: string,\n filename: string\n): Set<string> => {\n const result = new Set<string>();\n\n collectOxcProcessorImportsFromProgram(program, code).forEach((item) => {\n if (\n item.type !== 'esm' ||\n item.imported === '*' ||\n item.imported === 'side-effect'\n ) {\n return;\n }\n\n const localName = item.local.name ?? item.local.code;\n if (!localName) {\n return;\n }\n\n const [processor] = getProcessorForImport(\n {\n imported: item.imported,\n source: item.source,\n },\n filename,\n action.services.options.pluginOptions\n );\n\n if (!processor) {\n return;\n }\n\n result.add(localName);\n const rootLocalName = localName.split('.')[0];\n if (rootLocalName) {\n result.add(rootLocalName);\n }\n });\n\n return result;\n};\n\nexport const isStaticWYWMetaValue = (\n value: unknown,\n seen: Set<unknown> = new Set()\n): boolean => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n if (seen.has(value)) {\n return false;\n }\n seen.add(value);\n\n const meta = (value as { __wyw_meta?: unknown }).__wyw_meta;\n if (typeof meta !== 'object' || meta === null) {\n return false;\n }\n\n const { className, extends: extended } = meta as {\n className?: unknown;\n extends?: unknown;\n };\n\n return (\n typeof className === 'string' &&\n (extended === null || isStaticWYWMetaValue(extended, seen))\n );\n};\n\nexport type StaticWYWSelectorMetaValue = {\n __wyw_meta: {\n className: string;\n extends: StaticWYWSelectorMetaValue | null;\n };\n};\n\nexport const toStaticWYWSelectorMetaValue = (\n value: unknown,\n seen: Set<unknown> = new Set()\n): StaticWYWSelectorMetaValue | null => {\n if (typeof value !== 'object' || value === null || seen.has(value)) {\n return null;\n }\n\n seen.add(value);\n\n const meta = (value as { __wyw_meta?: unknown }).__wyw_meta;\n if (typeof meta !== 'object' || meta === null) {\n return null;\n }\n\n const { className, extends: extended } = meta as {\n className?: unknown;\n extends?: unknown;\n };\n if (typeof className !== 'string') {\n return null;\n }\n\n const staticExtends =\n extended === null ? null : toStaticWYWSelectorMetaValue(extended, seen);\n if (extended !== null && staticExtends === null) {\n return null;\n }\n\n return {\n __wyw_meta: {\n className,\n extends: staticExtends,\n },\n };\n};\n\nexport const staticWYWMetaExtendsReplacementCode = (\n value: unknown\n): string | null => {\n if (value === null) {\n return 'null';\n }\n\n const selectorMeta = toStaticWYWSelectorMetaValue(value);\n return selectorMeta ? `(${JSON.stringify(selectorMeta)})` : null;\n};\n\nexport const unknownStaticWYWMetaValue = Symbol('unknownStaticWYWMetaValue');\n\nexport type UnknownStaticWYWMetaValue = typeof unknownStaticWYWMetaValue;\n\nexport const zeroArgFunctionExpressionBody = (\n expr: Expression\n): Expression | null => {\n const unwrapped = unwrapExpression(expr) as AnyNode;\n if (\n unwrapped.type !== 'ArrowFunctionExpression' ||\n !Array.isArray(unwrapped.params) ||\n unwrapped.params.length !== 0\n ) {\n return null;\n }\n\n const body = unwrapped.body as Node | undefined;\n return body && body.type !== 'BlockStatement' ? (body as Expression) : null;\n};\n\nexport const isNullLiteralExpression = (node: Node): boolean => {\n const unwrapped = unwrapExpression(node);\n return isSafeLiteral(unwrapped) && unwrapped.value === null;\n};\n\nexport const isNullReturningFunctionExpression = (\n expr: Expression\n): boolean => {\n const unwrapped = unwrapExpression(expr) as AnyNode;\n if (\n unwrapped.type !== 'ArrowFunctionExpression' &&\n unwrapped.type !== 'FunctionExpression'\n ) {\n return false;\n }\n\n if (unwrapped.async || unwrapped.generator) {\n return false;\n }\n\n const body = unwrapped.body as Node | undefined;\n if (!body) {\n return false;\n }\n\n if (body.type !== 'BlockStatement') {\n return isNullLiteralExpression(body);\n }\n\n if (!Array.isArray(body.body) || body.body.length !== 1) {\n return false;\n }\n\n const [statement] = body.body;\n return (\n statement?.type === 'ReturnStatement' &&\n !!statement.argument &&\n isNullLiteralExpression(statement.argument)\n );\n};\n\nexport const createSameFileStaticWYWMetaHelperResolver = (\n code: string,\n filename: string\n): ((seedValues: Map<string, unknown>) => Map<string, unknown>) => {\n const declarations = new Map<string, Expression>();\n const nullFunctionNames = new Set<string>();\n\n try {\n const program = parseProgram(code, filename);\n const collectDeclarations = (statement: Node): void => {\n if (statement.type === 'VariableDeclaration') {\n statement.declarations.forEach((declarator) => {\n if (declarator.id.type !== 'Identifier' || !declarator.init) {\n return;\n }\n\n const { name } = declarator.id;\n const init = declarator.init as Expression;\n if (isNullReturningFunctionExpression(init)) {\n nullFunctionNames.add(name);\n return;\n }\n\n const unwrapped = unwrapExpression(init);\n if (\n unwrapped.type === 'ObjectExpression' &&\n findObjectPropertyValue(unwrapped, '__wyw_meta')\n ) {\n declarations.set(name, init);\n return;\n }\n\n const body = zeroArgFunctionExpressionBody(init);\n if (body && GENERATED_HELPER_NAME_RE.test(name)) {\n declarations.set(name, body);\n }\n });\n }\n };\n\n program.body.forEach((statement) => {\n if (\n statement.type === 'ExportNamedDeclaration' &&\n statement.declaration\n ) {\n collectDeclarations(statement.declaration);\n return;\n }\n\n collectDeclarations(statement);\n });\n } catch {\n return () => new Map();\n }\n\n return (seedValues) => {\n const memo = new Map<string, unknown | UnknownStaticWYWMetaValue>();\n const resolving = new Set<string>();\n\n const resolveName = (name: string): unknown | UnknownStaticWYWMetaValue => {\n if (seedValues.has(name)) {\n return seedValues.get(name);\n }\n\n if (memo.has(name)) {\n return memo.get(name)!;\n }\n\n const expression = declarations.get(name);\n if (!expression || resolving.has(name)) {\n if (nullFunctionNames.has(name)) {\n memo.set(name, null);\n return null;\n }\n\n return unknownStaticWYWMetaValue;\n }\n\n resolving.add(name);\n const value = resolveExpression(expression);\n resolving.delete(name);\n memo.set(name, value);\n return value;\n };\n\n const resolveExpression = (\n expression: Node\n ): unknown | UnknownStaticWYWMetaValue => {\n const unwrapped = unwrapExpression(expression);\n if (isSafeLiteral(unwrapped)) {\n return unwrapped.value;\n }\n\n if (unwrapped.type === 'Identifier') {\n return resolveName(unwrapped.name);\n }\n\n if (unwrapped.type === 'CallExpression') {\n const callee = unwrapExpression(unwrapped.callee);\n if (callee.type === 'Identifier' && unwrapped.arguments.length === 0) {\n return resolveName(callee.name);\n }\n\n return unknownStaticWYWMetaValue;\n }\n\n if (unwrapped.type !== 'ObjectExpression') {\n return unknownStaticWYWMetaValue;\n }\n\n const value: Record<string, unknown> = {};\n for (const property of unwrapped.properties) {\n if (property.type === 'SpreadElement') {\n return unknownStaticWYWMetaValue;\n }\n\n const propertyNode = property as AnyNode;\n if (propertyNode.computed) {\n return unknownStaticWYWMetaValue;\n }\n\n const propertyKey = propertyNode.key as Node | undefined;\n const key = propertyKey ? objectPropertyKeyName(propertyKey) : null;\n const propertyValue = propertyNode.value as Expression | undefined;\n if (key === null || !propertyValue) {\n return unknownStaticWYWMetaValue;\n }\n\n const resolved = resolveExpression(propertyValue);\n if (resolved === unknownStaticWYWMetaValue) {\n return unknownStaticWYWMetaValue;\n }\n\n value[key] = resolved;\n }\n\n return value;\n };\n\n const result = new Map<string, unknown>();\n declarations.forEach((_expression, name) => {\n if (!GENERATED_HELPER_NAME_RE.test(name)) {\n return;\n }\n\n const value = resolveName(name);\n if (\n value !== unknownStaticWYWMetaValue &&\n (value === null || isStaticWYWMetaValue(value))\n ) {\n result.set(name, value);\n }\n });\n\n return result;\n };\n};\n\nexport const staticWYWMetaTreeValueStatus = (\n value: unknown,\n seen: Set<unknown> = new Set()\n): { hasMetadata: boolean; safe: boolean } => {\n if (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ) {\n return {\n hasMetadata: false,\n safe: true,\n };\n }\n\n if (typeof value !== 'object') {\n return {\n hasMetadata: false,\n safe: false,\n };\n }\n\n if (seen.has(value)) {\n return {\n hasMetadata: false,\n safe: false,\n };\n }\n seen.add(value);\n\n if (Array.isArray(value)) {\n let hasMetadata = false;\n for (const item of value) {\n const status = staticWYWMetaTreeValueStatus(item, seen);\n if (!status.safe) {\n return {\n hasMetadata: false,\n safe: false,\n };\n }\n\n hasMetadata = hasMetadata || status.hasMetadata;\n }\n\n return {\n hasMetadata,\n safe: true,\n };\n }\n\n if ('__wyw_meta' in value) {\n return {\n hasMetadata: isStaticWYWMetaValue(value),\n safe: isStaticWYWMetaValue(value),\n };\n }\n\n let hasMetadata = false;\n for (const item of Object.values(value)) {\n const status = staticWYWMetaTreeValueStatus(item, seen);\n if (!status.safe) {\n return {\n hasMetadata: false,\n safe: false,\n };\n }\n\n hasMetadata = hasMetadata || status.hasMetadata;\n }\n\n return {\n hasMetadata,\n safe: true,\n };\n};\n\nexport const isStaticWYWMetaTreeValue = (value: unknown): boolean => {\n const status = staticWYWMetaTreeValueStatus(value);\n return status.safe && status.hasMetadata;\n};\n\nexport type StaticProcessorInstance = BaseProcessor;\n\nexport const processorClassNameRuntimeValue = (\n processor: StaticProcessorInstance\n): string => resolveProcessorStaticClassName(processor) ?? processor.className;\n\nexport const isProcessorRuntimeClassName = (\n processor: StaticProcessorInstance,\n value: string\n): boolean =>\n processor.className === value ||\n resolveProcessorStaticClassName(processor) === value;\n\nexport const isPlainObjectRecord = (\n value: unknown\n): value is Record<string, unknown> =>\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n Object.getPrototypeOf(value) === Object.prototype;\n\nexport const isStaticObjectAssignAliasValue = (value: unknown): boolean =>\n isStaticWYWMetaValue(value) || isStaticWYWMetaTreeValue(value);\n\nexport const artifactCssText = (artifact: unknown): string | null => {\n if (!Array.isArray(artifact) || artifact[0] !== 'css') {\n return null;\n }\n\n const payload = artifact[1];\n if (Array.isArray(payload)) {\n const [rules] = payload;\n if (typeof rules === 'object' && rules !== null) {\n return Object.values(rules)\n .map((rule) =>\n typeof rule === 'object' &&\n rule !== null &&\n 'cssText' in rule &&\n typeof (rule as { cssText?: unknown }).cssText === 'string'\n ? (rule as { cssText: string }).cssText\n : ''\n )\n .join('');\n }\n }\n\n if (\n typeof payload === 'object' &&\n payload !== null &&\n 'cssText' in payload &&\n typeof (payload as { cssText?: unknown }).cssText === 'string'\n ) {\n return (payload as { cssText: string }).cssText;\n }\n\n return null;\n};\n\nexport const isEmptyProcessorClassName = (\n value: string,\n processors: StaticProcessorInstance[],\n cache: Map<string, boolean>\n): boolean => {\n if (cache.has(value)) {\n return cache.get(value)!;\n }\n\n const processor = processors.find((item) =>\n isProcessorRuntimeClassName(item, value)\n );\n if (!processor) {\n cache.set(value, false);\n return false;\n }\n\n if (processor.artifacts.length === 0) {\n try {\n processor.build(new Map());\n } catch {\n cache.set(value, false);\n return false;\n }\n }\n\n const result = processor.artifacts.every((artifact) => {\n const cssText = artifactCssText(artifact);\n return cssText !== null && cssText.trim() === '';\n });\n cache.set(value, result);\n return result;\n};\n\nexport const isProcessorClassName = (\n value: string,\n processors: StaticProcessorInstance[],\n cache: Map<string, boolean>\n): boolean => {\n if (cache.has(value)) {\n return cache.get(value)!;\n }\n\n const processor = processors.find((item) =>\n isProcessorRuntimeClassName(item, value)\n );\n if (!processor) {\n cache.set(value, false);\n return false;\n }\n\n if (processor.artifacts.length === 0) {\n try {\n processor.build(new Map());\n } catch {\n cache.set(value, false);\n return false;\n }\n }\n\n const result = processor.artifacts.every(\n (artifact) => artifactCssText(artifact) !== null\n );\n cache.set(value, result);\n return result;\n};\n\nexport const isKnownProcessorClassName = (\n value: string,\n processorClassNames: ReadonlySet<string>\n): boolean => processorClassNames.has(value);\n\nexport const isSelectorOnlyProcessorValue = (\n value: unknown,\n processors: StaticProcessorInstance[],\n cache: Map<string, boolean>,\n seen: Set<unknown> = new Set()\n): boolean => {\n if (typeof value === 'string') {\n return isEmptyProcessorClassName(value, processors, cache);\n }\n\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n return false;\n }\n\n seen.add(value);\n return value.every((item) =>\n isSelectorOnlyProcessorValue(item, processors, cache, seen)\n );\n }\n\n if (typeof value === 'object' && value !== null) {\n if (seen.has(value)) {\n return false;\n }\n\n seen.add(value);\n return Object.values(value).every((item) =>\n isSelectorOnlyProcessorValue(item, processors, cache, seen)\n );\n }\n\n return false;\n};\n\nexport const isProcessorClassValue = (\n value: unknown,\n processors: StaticProcessorInstance[],\n cache: Map<string, boolean>,\n seen: Set<unknown> = new Set()\n): boolean => {\n if (typeof value === 'string') {\n return isProcessorClassName(value, processors, cache);\n }\n\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n return false;\n }\n\n seen.add(value);\n return value.every((item) =>\n isProcessorClassValue(item, processors, cache, seen)\n );\n }\n\n if (typeof value === 'object' && value !== null) {\n if (seen.has(value)) {\n return false;\n }\n\n seen.add(value);\n return Object.values(value).every((item) =>\n isProcessorClassValue(item, processors, cache, seen)\n );\n }\n\n return false;\n};\n\nexport const isKnownProcessorClassValue = (\n value: unknown,\n processorClassNames: ReadonlySet<string>,\n seen: Set<unknown> = new Set()\n): boolean => {\n if (typeof value === 'string') {\n return isKnownProcessorClassName(value, processorClassNames);\n }\n\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n return false;\n }\n\n seen.add(value);\n return value.every((item) =>\n isKnownProcessorClassValue(item, processorClassNames, seen)\n );\n }\n\n if (typeof value === 'object' && value !== null) {\n if (seen.has(value)) {\n return false;\n }\n\n seen.add(value);\n return Object.values(value).every((item) =>\n isKnownProcessorClassValue(item, processorClassNames, seen)\n );\n }\n\n return false;\n};\nexport const findWYWMetaExtendsExpression = (\n expr: Expression\n): Expression | null => {\n const meta = findObjectPropertyValue(expr, '__wyw_meta');\n if (!meta) {\n return null;\n }\n\n return findObjectPropertyValue(meta, 'extends');\n};\n\nexport const collectWYWMetaExtendsExpressionsDeep = (\n program: Program,\n expr: Expression\n): Expression[] => {\n const result: Expression[] = [];\n const seenLocals = new Set<string>();\n const seenRanges = new Set<string>();\n\n const visit = (node: Node, parent: Node | null = null): void => {\n const parentRecord = parent as AnyNode | null;\n if (\n parentRecord &&\n parentRecord.type === 'Property' &&\n parentRecord.key === node &&\n !parentRecord.computed\n ) {\n return;\n }\n\n if (node.type === 'ObjectExpression') {\n const extendsExpression = findWYWMetaExtendsExpression(\n node as Expression\n );\n if (extendsExpression) {\n const key = `${extendsExpression.start}:${extendsExpression.end}`;\n if (!seenRanges.has(key)) {\n seenRanges.add(key);\n result.push(extendsExpression);\n }\n }\n }\n\n if (node.type === 'Identifier') {\n const local = findTopLevelConstExpression(program, node.name);\n if (local && !seenLocals.has(node.name)) {\n seenLocals.add(node.name);\n visit(local);\n }\n return;\n }\n\n getOxcNodeChildren(node).forEach((child) => visit(child, node));\n };\n\n visit(expr);\n return result;\n};\nexport const isStaticMetaObjectExpression = (expr: Node): boolean => {\n const meta = findObjectPropertyValue(expr, '__wyw_meta');\n return !!meta && findObjectPropertyValue(meta, 'className') !== null;\n};\nexport const collectWYWMetaExtendsHelperNames = (\n program: Program\n): Set<string> => {\n const result = new Set<string>();\n\n const visit = (node: Node): void => {\n if (node.type === 'ObjectExpression') {\n const extendsExpression = findWYWMetaExtendsExpression(node);\n const unwrapped = extendsExpression\n ? unwrapExpression(extendsExpression)\n : null;\n if (\n unwrapped?.type === 'CallExpression' &&\n unwrapped.callee.type === 'Identifier' &&\n unwrapped.arguments.length === 0\n ) {\n result.add(unwrapped.callee.name);\n }\n }\n\n getOxcNodeChildren(node).forEach(visit);\n };\n\n visit(program);\n return result;\n};\n"],"file":"processorStaticModel.js"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { applyOxcReplacements } from "../../../utils/oxc/replacements.js";
|
|
2
|
+
import { parseProgram } from "./environment.js";
|
|
3
|
+
import { findExportTarget } from "./exportTargets.js";
|
|
4
|
+
import { collectWYWMetaExtendsExpressionsDeep } from "./processorStaticModel.js";
|
|
5
|
+
import { hasOnlySafeObjectAssignCallArgumentUses, resolveObjectAssignProcessorExpression } from "./objectAssign.js";
|
|
6
|
+
import { isOpaqueRuntimeComponentExpression } from "./opaqueRuntime.js";
|
|
7
|
+
import { collectStaticExpressionDependencies } from "./staticExpressionDependencies.js";
|
|
8
|
+
export const prepareProcessorTarget = (code, filename, program, target, exportedName, opaqueImportNames = new Set()) => {
|
|
9
|
+
const ignoredMutableCallArgumentNames = target.localName && hasOnlySafeObjectAssignCallArgumentUses(program, target.localName) ? new Set([target.localName]) : undefined;
|
|
10
|
+
const dependencyOptions = {
|
|
11
|
+
allowMetadataCalls: true,
|
|
12
|
+
ignoredMutableCallArgumentNames
|
|
13
|
+
};
|
|
14
|
+
const expression = resolveObjectAssignProcessorExpression(program, target.expression);
|
|
15
|
+
const extendsExpressions = collectWYWMetaExtendsExpressionsDeep(program, expression);
|
|
16
|
+
const opaqueExtendsExpressions = extendsExpressions.filter((extendsExpression) => isOpaqueRuntimeComponentExpression(program, extendsExpression, opaqueImportNames));
|
|
17
|
+
if (opaqueExtendsExpressions.length > 0) {
|
|
18
|
+
const replacements = opaqueExtendsExpressions.map((extendsExpression) => ({
|
|
19
|
+
end: extendsExpression.end,
|
|
20
|
+
start: extendsExpression.start,
|
|
21
|
+
text: "null"
|
|
22
|
+
}));
|
|
23
|
+
const evaluationCode = applyOxcReplacements(code, replacements);
|
|
24
|
+
const evaluationProgram = parseProgram(evaluationCode, filename);
|
|
25
|
+
const evaluationTarget = findExportTarget(evaluationProgram, exportedName);
|
|
26
|
+
if (!evaluationTarget || evaluationTarget.kind === "import") {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const evaluationExpression = resolveObjectAssignProcessorExpression(evaluationProgram, evaluationTarget.expression);
|
|
30
|
+
const dependencies = collectStaticExpressionDependencies(evaluationProgram, {
|
|
31
|
+
...evaluationTarget,
|
|
32
|
+
expression: evaluationExpression
|
|
33
|
+
}, dependencyOptions);
|
|
34
|
+
return dependencies ? {
|
|
35
|
+
dependencies,
|
|
36
|
+
evaluationCode,
|
|
37
|
+
evaluationSpan: {
|
|
38
|
+
end: evaluationExpression.end,
|
|
39
|
+
start: evaluationExpression.start
|
|
40
|
+
},
|
|
41
|
+
expression: evaluationExpression,
|
|
42
|
+
opaqueRuntimeBase: true
|
|
43
|
+
} : null;
|
|
44
|
+
}
|
|
45
|
+
const dependencies = collectStaticExpressionDependencies(program, {
|
|
46
|
+
...target,
|
|
47
|
+
expression
|
|
48
|
+
}, dependencyOptions);
|
|
49
|
+
return dependencies ? {
|
|
50
|
+
dependencies,
|
|
51
|
+
expression,
|
|
52
|
+
opaqueRuntimeBase: false
|
|
53
|
+
} : null;
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=processorTarget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAIA,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,4CAA4C;AACrD,SACE,yCACA,8CACK;AACP,SAAS,0CAA0C;AACnD,SAAS,2CAA2C;AAOpD,OAAO,MAAM,0BACX,MACA,UACA,SACA,QACA,cACA,oBAAiC,IAAI,KAAK,KACP;CACnC,MAAM,kCACJ,OAAO,aACP,wCAAwC,SAAS,OAAO,UAAU,GAC9D,IAAI,IAAI,CAAC,OAAO,UAAU,CAAC,GAC3B;CACN,MAAM,oBAA6C;EACjD,oBAAoB;EACpB;EACD;CACD,MAAM,aAAa,uCACjB,SACA,OAAO,WACR;CACD,MAAM,qBAAqB,qCACzB,SACA,WACD;CACD,MAAM,2BAA2B,mBAAmB,QACjD,sBACC,mCACE,SACA,mBACA,kBACD,CACJ;AAED,KAAI,yBAAyB,SAAS,GAAG;EACvC,MAAM,eAAe,yBAAyB,KAAK,uBAAuB;GACxE,KAAK,kBAAkB;GACvB,OAAO,kBAAkB;GACzB,MAAM;GACP,EAAE;EACH,MAAM,iBAAiB,qBAAqB,MAAM,aAAa;EAC/D,MAAM,oBAAoB,aAAa,gBAAgB,SAAS;EAChE,MAAM,mBAAmB,iBAAiB,mBAAmB,aAAa;AAC1E,MAAI,CAAC,oBAAoB,iBAAiB,SAAS,UAAU;AAC3D,UAAO;;EAGT,MAAM,uBAAuB,uCAC3B,mBACA,iBAAiB,WAClB;EACD,MAAM,eAAe,oCACnB,mBACA;GACE,GAAG;GACH,YAAY;GACb,EACD,kBACD;AAED,SAAO,eACH;GACE;GACA;GACA,gBAAgB;IACd,KAAK,qBAAqB;IAC1B,OAAO,qBAAqB;IAC7B;GACD,YAAY;GACZ,mBAAmB;GACpB,GACD;;CAGN,MAAM,eAAe,oCACnB,SACA;EACE,GAAG;EACH;EACD,EACD,kBACD;AACD,QAAO,eACH;EACE;EACA;EACA,mBAAmB;EACpB,GACD","names":[],"sources":["../../../../src/transform/generators/resolveStaticOxcValues/processorTarget.ts"],"version":3,"sourcesContent":["/* eslint-disable no-restricted-syntax,no-continue,@typescript-eslint/no-use-before-define */\n\nimport type { Program } from 'oxc-parser';\n\nimport { applyOxcReplacements } from '../../../utils/oxc/replacements';\nimport { parseProgram } from './environment';\nimport { findExportTarget } from './exportTargets';\nimport { collectWYWMetaExtendsExpressionsDeep } from './processorStaticModel';\nimport {\n hasOnlySafeObjectAssignCallArgumentUses,\n resolveObjectAssignProcessorExpression,\n} from './objectAssign';\nimport { isOpaqueRuntimeComponentExpression } from './opaqueRuntime';\nimport { collectStaticExpressionDependencies } from './staticExpressionDependencies';\nimport type {\n ExportTarget,\n PreparedProcessorTarget,\n StaticExpressionOptions,\n} from './types';\n\nexport const prepareProcessorTarget = (\n code: string,\n filename: string,\n program: Program,\n target: Extract<ExportTarget, { kind: 'expression' }>,\n exportedName: string,\n opaqueImportNames: Set<string> = new Set()\n): PreparedProcessorTarget | null => {\n const ignoredMutableCallArgumentNames =\n target.localName &&\n hasOnlySafeObjectAssignCallArgumentUses(program, target.localName)\n ? new Set([target.localName])\n : undefined;\n const dependencyOptions: StaticExpressionOptions = {\n allowMetadataCalls: true,\n ignoredMutableCallArgumentNames,\n };\n const expression = resolveObjectAssignProcessorExpression(\n program,\n target.expression\n );\n const extendsExpressions = collectWYWMetaExtendsExpressionsDeep(\n program,\n expression\n );\n const opaqueExtendsExpressions = extendsExpressions.filter(\n (extendsExpression) =>\n isOpaqueRuntimeComponentExpression(\n program,\n extendsExpression,\n opaqueImportNames\n )\n );\n\n if (opaqueExtendsExpressions.length > 0) {\n const replacements = opaqueExtendsExpressions.map((extendsExpression) => ({\n end: extendsExpression.end,\n start: extendsExpression.start,\n text: 'null',\n }));\n const evaluationCode = applyOxcReplacements(code, replacements);\n const evaluationProgram = parseProgram(evaluationCode, filename);\n const evaluationTarget = findExportTarget(evaluationProgram, exportedName);\n if (!evaluationTarget || evaluationTarget.kind === 'import') {\n return null;\n }\n\n const evaluationExpression = resolveObjectAssignProcessorExpression(\n evaluationProgram,\n evaluationTarget.expression\n );\n const dependencies = collectStaticExpressionDependencies(\n evaluationProgram,\n {\n ...evaluationTarget,\n expression: evaluationExpression,\n },\n dependencyOptions\n );\n\n return dependencies\n ? {\n dependencies,\n evaluationCode,\n evaluationSpan: {\n end: evaluationExpression.end,\n start: evaluationExpression.start,\n },\n expression: evaluationExpression,\n opaqueRuntimeBase: true,\n }\n : null;\n }\n\n const dependencies = collectStaticExpressionDependencies(\n program,\n {\n ...target,\n expression,\n },\n dependencyOptions\n );\n return dependencies\n ? {\n dependencies,\n expression,\n opaqueRuntimeBase: false,\n }\n : null;\n};\n"],"file":"processorTarget.js"}
|