@zenithbuild/compiler 1.0.2
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/LICENSE +21 -0
- package/README.md +30 -0
- package/dist/build-analyzer.d.ts +44 -0
- package/dist/build-analyzer.js +87 -0
- package/dist/bundler.d.ts +31 -0
- package/dist/bundler.js +86 -0
- package/dist/core/components/index.d.ts +9 -0
- package/dist/core/components/index.js +13 -0
- package/dist/core/config/index.d.ts +11 -0
- package/dist/core/config/index.js +10 -0
- package/dist/core/config/loader.d.ts +17 -0
- package/dist/core/config/loader.js +60 -0
- package/dist/core/config/types.d.ts +98 -0
- package/dist/core/config/types.js +32 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.js +6 -0
- package/dist/core/lifecycle/index.d.ts +16 -0
- package/dist/core/lifecycle/index.js +19 -0
- package/dist/core/lifecycle/zen-mount.d.ts +66 -0
- package/dist/core/lifecycle/zen-mount.js +151 -0
- package/dist/core/lifecycle/zen-unmount.d.ts +54 -0
- package/dist/core/lifecycle/zen-unmount.js +76 -0
- package/dist/core/plugins/bridge.d.ts +116 -0
- package/dist/core/plugins/bridge.js +121 -0
- package/dist/core/plugins/index.d.ts +6 -0
- package/dist/core/plugins/index.js +6 -0
- package/dist/core/plugins/registry.d.ts +67 -0
- package/dist/core/plugins/registry.js +113 -0
- package/dist/core/reactivity/index.d.ts +30 -0
- package/dist/core/reactivity/index.js +33 -0
- package/dist/core/reactivity/tracking.d.ts +74 -0
- package/dist/core/reactivity/tracking.js +136 -0
- package/dist/core/reactivity/zen-batch.d.ts +45 -0
- package/dist/core/reactivity/zen-batch.js +54 -0
- package/dist/core/reactivity/zen-effect.d.ts +48 -0
- package/dist/core/reactivity/zen-effect.js +98 -0
- package/dist/core/reactivity/zen-memo.d.ts +43 -0
- package/dist/core/reactivity/zen-memo.js +100 -0
- package/dist/core/reactivity/zen-ref.d.ts +44 -0
- package/dist/core/reactivity/zen-ref.js +34 -0
- package/dist/core/reactivity/zen-signal.d.ts +48 -0
- package/dist/core/reactivity/zen-signal.js +84 -0
- package/dist/core/reactivity/zen-state.d.ts +35 -0
- package/dist/core/reactivity/zen-state.js +147 -0
- package/dist/core/reactivity/zen-untrack.d.ts +38 -0
- package/dist/core/reactivity/zen-untrack.js +41 -0
- package/dist/css/index.d.ts +73 -0
- package/dist/css/index.js +246 -0
- package/dist/discovery/componentDiscovery.d.ts +42 -0
- package/dist/discovery/componentDiscovery.js +56 -0
- package/dist/discovery/layouts.d.ts +13 -0
- package/dist/discovery/layouts.js +41 -0
- package/dist/errors/compilerError.d.ts +31 -0
- package/dist/errors/compilerError.js +51 -0
- package/dist/finalize/finalizeOutput.d.ts +32 -0
- package/dist/finalize/finalizeOutput.js +62 -0
- package/dist/finalize/generateFinalBundle.d.ts +24 -0
- package/dist/finalize/generateFinalBundle.js +68 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +51 -0
- package/dist/ir/types.d.ts +181 -0
- package/dist/ir/types.js +8 -0
- package/dist/output/types.d.ts +30 -0
- package/dist/output/types.js +6 -0
- package/dist/parse/detectMapExpressions.d.ts +45 -0
- package/dist/parse/detectMapExpressions.js +77 -0
- package/dist/parse/parseScript.d.ts +8 -0
- package/dist/parse/parseScript.js +36 -0
- package/dist/parse/parseTemplate.d.ts +11 -0
- package/dist/parse/parseTemplate.js +487 -0
- package/dist/parse/parseZenFile.d.ts +11 -0
- package/dist/parse/parseZenFile.js +50 -0
- package/dist/parse/scriptAnalysis.d.ts +25 -0
- package/dist/parse/scriptAnalysis.js +60 -0
- package/dist/parse/trackLoopContext.d.ts +20 -0
- package/dist/parse/trackLoopContext.js +62 -0
- package/dist/parseZenFile.d.ts +10 -0
- package/dist/parseZenFile.js +55 -0
- package/dist/runtime/analyzeAndEmit.d.ts +20 -0
- package/dist/runtime/analyzeAndEmit.js +70 -0
- package/dist/runtime/build.d.ts +6 -0
- package/dist/runtime/build.js +13 -0
- package/dist/runtime/bundle-generator.d.ts +27 -0
- package/dist/runtime/bundle-generator.js +1263 -0
- package/dist/runtime/client-runtime.d.ts +41 -0
- package/dist/runtime/client-runtime.js +397 -0
- package/dist/runtime/dataExposure.d.ts +52 -0
- package/dist/runtime/dataExposure.js +227 -0
- package/dist/runtime/generateDOM.d.ts +21 -0
- package/dist/runtime/generateDOM.js +194 -0
- package/dist/runtime/generateHydrationBundle.d.ts +15 -0
- package/dist/runtime/generateHydrationBundle.js +399 -0
- package/dist/runtime/hydration.d.ts +53 -0
- package/dist/runtime/hydration.js +271 -0
- package/dist/runtime/navigation.d.ts +58 -0
- package/dist/runtime/navigation.js +372 -0
- package/dist/runtime/serve.d.ts +13 -0
- package/dist/runtime/serve.js +76 -0
- package/dist/runtime/thinRuntime.d.ts +23 -0
- package/dist/runtime/thinRuntime.js +158 -0
- package/dist/runtime/transformIR.d.ts +19 -0
- package/dist/runtime/transformIR.js +285 -0
- package/dist/runtime/wrapExpression.d.ts +24 -0
- package/dist/runtime/wrapExpression.js +76 -0
- package/dist/runtime/wrapExpressionWithLoop.d.ts +17 -0
- package/dist/runtime/wrapExpressionWithLoop.js +75 -0
- package/dist/spa-build.d.ts +26 -0
- package/dist/spa-build.js +866 -0
- package/dist/ssg-build.d.ts +32 -0
- package/dist/ssg-build.js +408 -0
- package/dist/test/analyze-emit.test.d.ts +1 -0
- package/dist/test/analyze-emit.test.js +88 -0
- package/dist/test/bundler-contract.test.d.ts +1 -0
- package/dist/test/bundler-contract.test.js +137 -0
- package/dist/test/compiler-authority.test.d.ts +1 -0
- package/dist/test/compiler-authority.test.js +90 -0
- package/dist/test/component-instance-test.d.ts +1 -0
- package/dist/test/component-instance-test.js +115 -0
- package/dist/test/error-native-bridge.test.d.ts +1 -0
- package/dist/test/error-native-bridge.test.js +51 -0
- package/dist/test/error-serialization.test.d.ts +1 -0
- package/dist/test/error-serialization.test.js +38 -0
- package/dist/test/macro-inlining.test.d.ts +1 -0
- package/dist/test/macro-inlining.test.js +178 -0
- package/dist/test/validate-test.d.ts +6 -0
- package/dist/test/validate-test.js +95 -0
- package/dist/transform/classifyExpression.d.ts +46 -0
- package/dist/transform/classifyExpression.js +354 -0
- package/dist/transform/componentResolver.d.ts +15 -0
- package/dist/transform/componentResolver.js +30 -0
- package/dist/transform/expressionTransformer.d.ts +19 -0
- package/dist/transform/expressionTransformer.js +333 -0
- package/dist/transform/fragmentLowering.d.ts +25 -0
- package/dist/transform/fragmentLowering.js +468 -0
- package/dist/transform/layoutProcessor.d.ts +5 -0
- package/dist/transform/layoutProcessor.js +34 -0
- package/dist/transform/transformTemplate.d.ts +11 -0
- package/dist/transform/transformTemplate.js +33 -0
- package/dist/validate/invariants.d.ts +23 -0
- package/dist/validate/invariants.js +55 -0
- package/native/compiler-native/compiler-native.node +0 -0
- package/native/compiler-native/index.d.ts +113 -0
- package/native/compiler-native/index.js +19 -0
- package/native/compiler-native/package.json +19 -0
- package/package.json +49 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expression Wrapper with Loop Context Support
|
|
3
|
+
*
|
|
4
|
+
* Phase 7: Wraps expressions that reference loop variables from map iterations
|
|
5
|
+
*
|
|
6
|
+
* Generates runtime functions that accept (state, loaderData, props, stores, loopContext)
|
|
7
|
+
* and evaluate expressions with both global state and loop-scoped variables available
|
|
8
|
+
*/
|
|
9
|
+
import type { ExpressionIR, LoopContext } from '../ir/types';
|
|
10
|
+
import type { ExpressionDataDependencies } from './dataExposure';
|
|
11
|
+
/**
|
|
12
|
+
* Generate an expression wrapper that accepts loop context
|
|
13
|
+
*
|
|
14
|
+
* Phase 7: Expressions inside map loops need access to loop variables (e.g., todo, index)
|
|
15
|
+
* in addition to global state (state, loaderData, props, stores)
|
|
16
|
+
*/
|
|
17
|
+
export declare function wrapExpressionWithLoopContext(expr: ExpressionIR, loopContext?: LoopContext, dependencies?: ExpressionDataDependencies): string;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expression Wrapper with Loop Context Support
|
|
3
|
+
*
|
|
4
|
+
* Phase 7: Wraps expressions that reference loop variables from map iterations
|
|
5
|
+
*
|
|
6
|
+
* Generates runtime functions that accept (state, loaderData, props, stores, loopContext)
|
|
7
|
+
* and evaluate expressions with both global state and loop-scoped variables available
|
|
8
|
+
*/
|
|
9
|
+
import { transformExpressionJSX } from '../transform/expressionTransformer';
|
|
10
|
+
/**
|
|
11
|
+
* Generate an expression wrapper that accepts loop context
|
|
12
|
+
*
|
|
13
|
+
* Phase 7: Expressions inside map loops need access to loop variables (e.g., todo, index)
|
|
14
|
+
* in addition to global state (state, loaderData, props, stores)
|
|
15
|
+
*/
|
|
16
|
+
export function wrapExpressionWithLoopContext(expr, loopContext, dependencies) {
|
|
17
|
+
const { id, code } = expr;
|
|
18
|
+
const escapedCode = code.replace(/`/g, '\\`').replace(/\$/g, '\\$');
|
|
19
|
+
if (!loopContext || loopContext.variables.length === 0) {
|
|
20
|
+
// No loop context - use standard wrapper (will be handled by wrapExpression)
|
|
21
|
+
return '';
|
|
22
|
+
}
|
|
23
|
+
// Determine arguments based on dependencies
|
|
24
|
+
const args = [];
|
|
25
|
+
if (dependencies?.usesState || (dependencies?.stateProperties && dependencies.stateProperties.length > 0))
|
|
26
|
+
args.push('state');
|
|
27
|
+
if (dependencies?.usesLoaderData)
|
|
28
|
+
args.push('loaderData');
|
|
29
|
+
if (dependencies?.usesProps)
|
|
30
|
+
args.push('props');
|
|
31
|
+
if (dependencies?.usesStores)
|
|
32
|
+
args.push('stores');
|
|
33
|
+
// Phase 7: Always add loopContext as the last argument
|
|
34
|
+
args.push('loopContext');
|
|
35
|
+
const argsStr = args.join(', ');
|
|
36
|
+
// Generate function that merges state and loop context
|
|
37
|
+
// Loop context variables take precedence over state properties with the same name
|
|
38
|
+
const loopVarsDecl = loopContext.variables.map(v => ` const ${v} = loopContext?.${v};`).join('\n');
|
|
39
|
+
const loopVarsObject = `{ ${loopContext.variables.join(', ')} }`;
|
|
40
|
+
// Create merged context for expression evaluation
|
|
41
|
+
// Order: loopContext > stores > props > loaderData > state
|
|
42
|
+
const contextMerge = [];
|
|
43
|
+
if (dependencies?.usesState || (dependencies?.stateProperties && dependencies.stateProperties.length > 0))
|
|
44
|
+
contextMerge.push('state');
|
|
45
|
+
if (dependencies?.usesStores)
|
|
46
|
+
contextMerge.push('stores');
|
|
47
|
+
if (dependencies?.usesProps)
|
|
48
|
+
contextMerge.push('props');
|
|
49
|
+
if (dependencies?.usesLoaderData)
|
|
50
|
+
contextMerge.push('loaderData');
|
|
51
|
+
if (loopContext)
|
|
52
|
+
contextMerge.push('loopContext');
|
|
53
|
+
const contextObject = contextMerge.length > 0
|
|
54
|
+
? `const __ctx = Object.assign({}, ${contextMerge.join(', ')});`
|
|
55
|
+
: `const __ctx = loopContext || {};`;
|
|
56
|
+
// Transform JSX
|
|
57
|
+
// The fix for 'undefined' string assignment is applied within transformExpressionJSX
|
|
58
|
+
// by ensuring that any remaining text is properly quoted as a string literal
|
|
59
|
+
// or recognized as an existing h() call.
|
|
60
|
+
const transformedCode = transformExpressionJSX(code);
|
|
61
|
+
return `
|
|
62
|
+
// Expression with loop context: ${escapedCode}
|
|
63
|
+
// Loop variables: ${loopContext.variables.join(', ')}
|
|
64
|
+
const ${id} = (${argsStr}) => {
|
|
65
|
+
try {
|
|
66
|
+
${contextObject}
|
|
67
|
+
with (__ctx) {
|
|
68
|
+
return ${transformedCode};
|
|
69
|
+
}
|
|
70
|
+
} catch (e) {
|
|
71
|
+
console.warn('[Zenith] Expression evaluation error for "${escapedCode}":', e);
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
};`;
|
|
75
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zenith SPA Build System
|
|
3
|
+
*
|
|
4
|
+
* Builds all pages into a single index.html with:
|
|
5
|
+
* - Route manifest
|
|
6
|
+
* - Compiled page modules (inlined)
|
|
7
|
+
* - Runtime router
|
|
8
|
+
* - Shell HTML with router outlet
|
|
9
|
+
*/
|
|
10
|
+
interface SPABuildOptions {
|
|
11
|
+
/** Pages directory */
|
|
12
|
+
pagesDir: string;
|
|
13
|
+
/** Output directory */
|
|
14
|
+
outDir: string;
|
|
15
|
+
/** Base directory for components/layouts */
|
|
16
|
+
baseDir?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Build SPA from pages directory
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildSPA(options: SPABuildOptions): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Watch mode for development (future)
|
|
24
|
+
*/
|
|
25
|
+
export declare function watchSPA(_options: SPABuildOptions): void;
|
|
26
|
+
export {};
|