@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
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
export const unknownProcessorStaticValue = Symbol('unknownProcessorStaticValue');
|
|
2
|
+
export const createProcessorStaticContext = (processor) => {
|
|
3
|
+
const processorWithInternals = processor;
|
|
4
|
+
return {
|
|
5
|
+
addDependency: () => { },
|
|
6
|
+
debug: () => { },
|
|
7
|
+
fileContext: processorWithInternals.context ??
|
|
8
|
+
{},
|
|
9
|
+
metadata: {
|
|
10
|
+
className: processor.className,
|
|
11
|
+
displayName: processor.displayName,
|
|
12
|
+
isReferenced: processor.isReferenced,
|
|
13
|
+
location: processor.location,
|
|
14
|
+
slug: processor.slug,
|
|
15
|
+
tagSource: processor.tagSource,
|
|
16
|
+
},
|
|
17
|
+
options: processorWithInternals.options ??
|
|
18
|
+
{},
|
|
19
|
+
unresolved: (reason, details) => ({
|
|
20
|
+
...(details ? { details } : {}),
|
|
21
|
+
kind: 'unresolved',
|
|
22
|
+
reason,
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export const isProcessorStaticValue = (value) => {
|
|
27
|
+
if (typeof value !== 'object' || value === null || !('kind' in value)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const candidate = value;
|
|
31
|
+
switch (candidate.kind) {
|
|
32
|
+
case 'class-name':
|
|
33
|
+
return typeof candidate.className === 'string';
|
|
34
|
+
case 'opaque-component':
|
|
35
|
+
return (candidate.className === undefined ||
|
|
36
|
+
typeof candidate.className === 'string');
|
|
37
|
+
case 'runtime-callback':
|
|
38
|
+
case 'serializable':
|
|
39
|
+
return true;
|
|
40
|
+
case 'selector-chain':
|
|
41
|
+
return (typeof candidate.className === 'string' &&
|
|
42
|
+
Array.isArray(candidate.selectors) &&
|
|
43
|
+
candidate.selectors.every((selector) => typeof selector === 'string'));
|
|
44
|
+
case 'unresolved':
|
|
45
|
+
return typeof candidate.reason === 'string';
|
|
46
|
+
default:
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
export const getProcessorStaticValue = (processor) => {
|
|
51
|
+
if (!processor.getStaticValue) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const value = processor.getStaticValue(createProcessorStaticContext(processor));
|
|
56
|
+
return isProcessorStaticValue(value) ? value : null;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
export const processorStaticValueToRuntimeValue = (value) => {
|
|
63
|
+
switch (value.kind) {
|
|
64
|
+
case 'class-name':
|
|
65
|
+
return value.value === undefined ? value.className : value.value;
|
|
66
|
+
case 'opaque-component':
|
|
67
|
+
case 'runtime-callback':
|
|
68
|
+
return value.value === undefined
|
|
69
|
+
? unknownProcessorStaticValue
|
|
70
|
+
: value.value;
|
|
71
|
+
case 'selector-chain':
|
|
72
|
+
case 'serializable':
|
|
73
|
+
return value.value;
|
|
74
|
+
case 'unresolved':
|
|
75
|
+
return unknownProcessorStaticValue;
|
|
76
|
+
default:
|
|
77
|
+
return unknownProcessorStaticValue;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
export const resolveProcessorStaticRuntimeValue = (processor) => {
|
|
81
|
+
const staticValue = getProcessorStaticValue(processor);
|
|
82
|
+
return staticValue
|
|
83
|
+
? processorStaticValueToRuntimeValue(staticValue)
|
|
84
|
+
: unknownProcessorStaticValue;
|
|
85
|
+
};
|
|
86
|
+
export const resolveProcessorStaticClassName = (processor) => {
|
|
87
|
+
const staticValue = getProcessorStaticValue(processor);
|
|
88
|
+
if (staticValue?.kind !== 'class-name') {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const runtimeValue = processorStaticValueToRuntimeValue(staticValue);
|
|
92
|
+
return typeof runtimeValue === 'string'
|
|
93
|
+
? runtimeValue
|
|
94
|
+
: staticValue.className;
|
|
95
|
+
};
|
|
96
|
+
export const processorLiteralValue = (expression) => {
|
|
97
|
+
const expressionWithValue = expression;
|
|
98
|
+
if (expression.type === 'StringLiteral' ||
|
|
99
|
+
expression.type === 'NumericLiteral' ||
|
|
100
|
+
expression.type === 'BooleanLiteral' ||
|
|
101
|
+
expression.type === 'Literal') {
|
|
102
|
+
return expressionWithValue.value;
|
|
103
|
+
}
|
|
104
|
+
if (expression.type === 'NullLiteral') {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
return unknownProcessorStaticValue;
|
|
108
|
+
};
|
|
109
|
+
export const processorPropertyKeyName = (key) => {
|
|
110
|
+
if (key.type === 'Identifier') {
|
|
111
|
+
return key.name;
|
|
112
|
+
}
|
|
113
|
+
const value = processorLiteralValue(key);
|
|
114
|
+
return typeof value === 'string' ? value : null;
|
|
115
|
+
};
|
|
116
|
+
export const processorObjectPropertyValue = (expression, name) => {
|
|
117
|
+
if (expression.type !== 'ObjectExpression') {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
const { properties } = expression;
|
|
121
|
+
if (!properties) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
for (const property of properties) {
|
|
125
|
+
if ((property.type === 'ObjectProperty' || property.type === 'Property') &&
|
|
126
|
+
property.key &&
|
|
127
|
+
processorPropertyKeyName(property.key) === name) {
|
|
128
|
+
return property.value ?? null;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
};
|
|
133
|
+
export const processorExpressionToStaticValue = (expression, resolveHelperCall) => {
|
|
134
|
+
const literal = processorLiteralValue(expression);
|
|
135
|
+
if (literal !== unknownProcessorStaticValue) {
|
|
136
|
+
return literal;
|
|
137
|
+
}
|
|
138
|
+
if (expression.type === 'ArrayExpression') {
|
|
139
|
+
const { elements } = expression;
|
|
140
|
+
if (!elements) {
|
|
141
|
+
return unknownProcessorStaticValue;
|
|
142
|
+
}
|
|
143
|
+
const result = [];
|
|
144
|
+
for (const element of elements) {
|
|
145
|
+
if (element === null) {
|
|
146
|
+
result.push(null);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const value = processorExpressionToStaticValue(element, resolveHelperCall);
|
|
150
|
+
if (value === unknownProcessorStaticValue) {
|
|
151
|
+
return unknownProcessorStaticValue;
|
|
152
|
+
}
|
|
153
|
+
result.push(value);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
if (expression.type === 'ObjectExpression') {
|
|
159
|
+
const metaExpression = processorObjectPropertyValue(expression, '__wyw_meta');
|
|
160
|
+
if (!metaExpression || metaExpression.type !== 'ObjectExpression') {
|
|
161
|
+
return unknownProcessorStaticValue;
|
|
162
|
+
}
|
|
163
|
+
const classNameExpression = processorObjectPropertyValue(metaExpression, 'className');
|
|
164
|
+
const className = classNameExpression
|
|
165
|
+
? processorLiteralValue(classNameExpression)
|
|
166
|
+
: unknownProcessorStaticValue;
|
|
167
|
+
if (typeof className !== 'string') {
|
|
168
|
+
return unknownProcessorStaticValue;
|
|
169
|
+
}
|
|
170
|
+
const extendsExpression = processorObjectPropertyValue(metaExpression, 'extends');
|
|
171
|
+
const extended = extendsExpression
|
|
172
|
+
? processorExpressionToStaticValue(extendsExpression, resolveHelperCall)
|
|
173
|
+
: null;
|
|
174
|
+
if (extended === unknownProcessorStaticValue) {
|
|
175
|
+
return unknownProcessorStaticValue;
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
__wyw_meta: {
|
|
179
|
+
className,
|
|
180
|
+
extends: extended,
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
if (expression.type === 'CallExpression') {
|
|
185
|
+
const call = expression;
|
|
186
|
+
if (call.arguments?.length === 0 && call.callee?.type === 'Identifier') {
|
|
187
|
+
return resolveHelperCall(call.callee.name);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return unknownProcessorStaticValue;
|
|
191
|
+
};
|
|
@@ -54,7 +54,7 @@ const resolveWithNodeProcess = (id, parent, conditions) => {
|
|
|
54
54
|
}
|
|
55
55
|
catch {
|
|
56
56
|
throw new Error([
|
|
57
|
-
'[wyw-in-js] Failed to parse
|
|
57
|
+
'[wyw-in-js] Failed to parse custom module resolver output.',
|
|
58
58
|
`stdout: ${stdout}`,
|
|
59
59
|
result.stderr ? `stderr: ${result.stderr.trim()}` : '',
|
|
60
60
|
]
|
|
@@ -69,7 +69,7 @@ const resolveWithNodeProcess = (id, parent, conditions) => {
|
|
|
69
69
|
}
|
|
70
70
|
if (result.status !== 0 || !parsed?.resolved) {
|
|
71
71
|
throw new Error([
|
|
72
|
-
'[wyw-in-js]
|
|
72
|
+
'[wyw-in-js] Custom module resolver fallback failed.',
|
|
73
73
|
`status: ${result.status ?? 'null'}`,
|
|
74
74
|
result.stderr ? `stderr: ${result.stderr.trim()}` : '',
|
|
75
75
|
]
|
|
@@ -87,7 +87,7 @@ export const resolveFilenameWithConditions = (moduleImpl, id, parent, conditions
|
|
|
87
87
|
// Bun crashes on macOS/Silicon in this exact path:
|
|
88
88
|
// Module._resolveFilename(specifier, parent, false, { conditions })
|
|
89
89
|
// We reproduced it both with a tiny standalone script and through the
|
|
90
|
-
// `EvalBroker > passes conditionNames to
|
|
90
|
+
// `EvalBroker > passes conditionNames to native fallback resolution` test,
|
|
91
91
|
// including on Bun 1.3.13. Keep this fallback narrow: only conditioned
|
|
92
92
|
// resolution under Bun goes through a short-lived Node subprocess.
|
|
93
93
|
//
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
export const defaultBundlerOwnedSpecifierPrefixes = [
|
|
2
|
-
"\0",
|
|
3
|
-
"/@",
|
|
4
|
-
"virtual:"
|
|
5
|
-
];
|
|
6
|
-
export const getResolverPrecedence = (mode) => {
|
|
7
|
-
if (mode === "hybrid") {
|
|
8
|
-
return [
|
|
9
|
-
"customResolver",
|
|
10
|
-
"safeOxcResolver",
|
|
11
|
-
"bundlerResolver",
|
|
12
|
-
"nodeFallback"
|
|
13
|
-
];
|
|
14
|
-
}
|
|
15
|
-
if (mode === "bundler") {
|
|
16
|
-
return [
|
|
17
|
-
"customResolver",
|
|
18
|
-
"bundlerResolver",
|
|
19
|
-
"nodeFallback"
|
|
20
|
-
];
|
|
21
|
-
}
|
|
22
|
-
if (mode === "custom") {
|
|
23
|
-
return ["customResolver"];
|
|
24
|
-
}
|
|
25
|
-
return ["nodeFallback"];
|
|
26
|
-
};
|
|
27
|
-
export const classifyHybridResolverSpecifier = (specifier, { bundlerOwnedPrefixes = defaultBundlerOwnedSpecifierPrefixes } = {}) => {
|
|
28
|
-
if (bundlerOwnedPrefixes.some((prefix) => specifier.startsWith(prefix))) {
|
|
29
|
-
return {
|
|
30
|
-
reason: "bundler-owned-prefix",
|
|
31
|
-
route: "bundler"
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
if (!specifier.startsWith("./") && !specifier.startsWith("../")) {
|
|
35
|
-
return {
|
|
36
|
-
reason: "ambiguous-specifier",
|
|
37
|
-
route: "bundler"
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
if (/[?#]/.test(specifier)) {
|
|
41
|
-
return {
|
|
42
|
-
reason: "query-or-hash",
|
|
43
|
-
route: "bundler"
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
reason: "safe-relative-specifier",
|
|
48
|
-
route: "oxc"
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
//# sourceMappingURL=resolverStrategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAmBA,OAAO,MAAM,uCAAuC;CAClD;CACA;CACA;CACD;AAED,OAAO,MAAM,yBACX,SACsB;AACtB,KAAI,SAAS,UAAU;AACrB,SAAO;GACL;GACA;GACA;GACA;GACD;;AAGH,KAAI,SAAS,WAAW;AACtB,SAAO;GAAC;GAAkB;GAAmB;GAAe;;AAG9D,KAAI,SAAS,UAAU;AACrB,SAAO,CAAC,iBAAiB;;AAG3B,QAAO,CAAC,eAAe;;AAGzB,OAAO,MAAM,mCACX,WACA,EACE,uBAAuB,yCACY,EAAE,KACZ;AAC3B,KAAI,qBAAqB,MAAM,WAAW,UAAU,WAAW,OAAO,CAAC,EAAE;AACvE,SAAO;GACL,QAAQ;GACR,OAAO;GACR;;AAGH,KAAI,CAAC,UAAU,WAAW,KAAK,IAAI,CAAC,UAAU,WAAW,MAAM,EAAE;AAC/D,SAAO;GACL,QAAQ;GACR,OAAO;GACR;;AAGH,KAAI,OAAO,KAAK,UAAU,EAAE;AAC1B,SAAO;GACL,QAAQ;GACR,OAAO;GACR;;AAGH,QAAO;EACL,QAAQ;EACR,OAAO;EACR","names":[],"sources":["../../src/eval/resolverStrategy.ts"],"version":3,"sourcesContent":["import type { EvalResolverMode } from '@wyw-in-js/shared';\n\nexport type HybridResolverRoute = 'bundler' | 'oxc';\n\nexport type HybridResolverReason =\n | 'ambiguous-specifier'\n | 'bundler-owned-prefix'\n | 'query-or-hash'\n | 'safe-relative-specifier';\n\nexport type HybridResolverDecision = {\n reason: HybridResolverReason;\n route: HybridResolverRoute;\n};\n\nexport type HybridResolverClassifierOptions = {\n bundlerOwnedPrefixes?: readonly string[];\n};\n\nexport const defaultBundlerOwnedSpecifierPrefixes = [\n '\\0',\n '/@',\n 'virtual:',\n] as const;\n\nexport const getResolverPrecedence = (\n mode: EvalResolverMode\n): readonly string[] => {\n if (mode === 'hybrid') {\n return [\n 'customResolver',\n 'safeOxcResolver',\n 'bundlerResolver',\n 'nodeFallback',\n ];\n }\n\n if (mode === 'bundler') {\n return ['customResolver', 'bundlerResolver', 'nodeFallback'];\n }\n\n if (mode === 'custom') {\n return ['customResolver'];\n }\n\n return ['nodeFallback'];\n};\n\nexport const classifyHybridResolverSpecifier = (\n specifier: string,\n {\n bundlerOwnedPrefixes = defaultBundlerOwnedSpecifierPrefixes,\n }: HybridResolverClassifierOptions = {}\n): HybridResolverDecision => {\n if (bundlerOwnedPrefixes.some((prefix) => specifier.startsWith(prefix))) {\n return {\n reason: 'bundler-owned-prefix',\n route: 'bundler',\n };\n }\n\n if (!specifier.startsWith('./') && !specifier.startsWith('../')) {\n return {\n reason: 'ambiguous-specifier',\n route: 'bundler',\n };\n }\n\n if (/[?#]/.test(specifier)) {\n return {\n reason: 'query-or-hash',\n route: 'bundler',\n };\n }\n\n return {\n reason: 'safe-relative-specifier',\n route: 'oxc',\n };\n};\n"],"file":"resolverStrategy.js"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { EvalResolverMode } from '@wyw-in-js/shared';
|
|
2
|
-
export type HybridResolverRoute = 'bundler' | 'oxc';
|
|
3
|
-
export type HybridResolverReason = 'ambiguous-specifier' | 'bundler-owned-prefix' | 'query-or-hash' | 'safe-relative-specifier';
|
|
4
|
-
export type HybridResolverDecision = {
|
|
5
|
-
reason: HybridResolverReason;
|
|
6
|
-
route: HybridResolverRoute;
|
|
7
|
-
};
|
|
8
|
-
export type HybridResolverClassifierOptions = {
|
|
9
|
-
bundlerOwnedPrefixes?: readonly string[];
|
|
10
|
-
};
|
|
11
|
-
export declare const defaultBundlerOwnedSpecifierPrefixes: readonly ["\0", "/@", "virtual:"];
|
|
12
|
-
export declare const getResolverPrecedence: (mode: EvalResolverMode) => readonly string[];
|
|
13
|
-
export declare const classifyHybridResolverSpecifier: (specifier: string, { bundlerOwnedPrefixes, }?: HybridResolverClassifierOptions) => HybridResolverDecision;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export const defaultBundlerOwnedSpecifierPrefixes = [
|
|
2
|
-
'\0',
|
|
3
|
-
'/@',
|
|
4
|
-
'virtual:',
|
|
5
|
-
];
|
|
6
|
-
export const getResolverPrecedence = (mode) => {
|
|
7
|
-
if (mode === 'hybrid') {
|
|
8
|
-
return [
|
|
9
|
-
'customResolver',
|
|
10
|
-
'safeOxcResolver',
|
|
11
|
-
'bundlerResolver',
|
|
12
|
-
'nodeFallback',
|
|
13
|
-
];
|
|
14
|
-
}
|
|
15
|
-
if (mode === 'bundler') {
|
|
16
|
-
return ['customResolver', 'bundlerResolver', 'nodeFallback'];
|
|
17
|
-
}
|
|
18
|
-
if (mode === 'custom') {
|
|
19
|
-
return ['customResolver'];
|
|
20
|
-
}
|
|
21
|
-
return ['nodeFallback'];
|
|
22
|
-
};
|
|
23
|
-
export const classifyHybridResolverSpecifier = (specifier, { bundlerOwnedPrefixes = defaultBundlerOwnedSpecifierPrefixes, } = {}) => {
|
|
24
|
-
if (bundlerOwnedPrefixes.some((prefix) => specifier.startsWith(prefix))) {
|
|
25
|
-
return {
|
|
26
|
-
reason: 'bundler-owned-prefix',
|
|
27
|
-
route: 'bundler',
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
if (!specifier.startsWith('./') && !specifier.startsWith('../')) {
|
|
31
|
-
return {
|
|
32
|
-
reason: 'ambiguous-specifier',
|
|
33
|
-
route: 'bundler',
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
if (/[?#]/.test(specifier)) {
|
|
37
|
-
return {
|
|
38
|
-
reason: 'query-or-hash',
|
|
39
|
-
route: 'bundler',
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
reason: 'safe-relative-specifier',
|
|
44
|
-
route: 'oxc',
|
|
45
|
-
};
|
|
46
|
-
};
|