@zenithbuild/compiler 1.0.16 → 1.3.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/native/compiler-native/compiler-native.node +0 -0
- package/native/compiler-native/index.d.ts +46 -7
- package/native/compiler-native/index.js +332 -17
- package/package.json +2 -2
- package/dist/build-analyzer.d.ts +0 -44
- package/dist/build-analyzer.js +0 -87
- package/dist/bundler.d.ts +0 -31
- package/dist/bundler.js +0 -86
- package/dist/compiler-native-ep39xj7a.node +0 -0
- package/dist/compiler-native-ftk9z446.node +0 -0
- package/dist/core/components/index.d.ts +0 -9
- package/dist/core/components/index.js +0 -13
- package/dist/core/config/index.d.ts +0 -11
- package/dist/core/config/index.js +0 -10
- package/dist/core/config/loader.d.ts +0 -17
- package/dist/core/config/loader.js +0 -60
- package/dist/core/config/types.d.ts +0 -98
- package/dist/core/config/types.js +0 -32
- package/dist/core/index.d.ts +0 -7
- package/dist/core/index.js +0 -6
- package/dist/core/lifecycle/index.d.ts +0 -16
- package/dist/core/lifecycle/index.js +0 -19
- package/dist/core/lifecycle/zen-mount.d.ts +0 -66
- package/dist/core/lifecycle/zen-mount.js +0 -151
- package/dist/core/lifecycle/zen-unmount.d.ts +0 -54
- package/dist/core/lifecycle/zen-unmount.js +0 -76
- package/dist/core/plugins/bridge.d.ts +0 -116
- package/dist/core/plugins/bridge.js +0 -121
- package/dist/core/plugins/index.d.ts +0 -6
- package/dist/core/plugins/index.js +0 -6
- package/dist/core/plugins/registry.d.ts +0 -67
- package/dist/core/plugins/registry.js +0 -112
- package/dist/core/reactivity/index.d.ts +0 -30
- package/dist/core/reactivity/index.js +0 -33
- package/dist/core/reactivity/tracking.d.ts +0 -74
- package/dist/core/reactivity/tracking.js +0 -136
- package/dist/core/reactivity/zen-batch.d.ts +0 -45
- package/dist/core/reactivity/zen-batch.js +0 -54
- package/dist/core/reactivity/zen-effect.d.ts +0 -48
- package/dist/core/reactivity/zen-effect.js +0 -98
- package/dist/core/reactivity/zen-memo.d.ts +0 -43
- package/dist/core/reactivity/zen-memo.js +0 -100
- package/dist/core/reactivity/zen-ref.d.ts +0 -44
- package/dist/core/reactivity/zen-ref.js +0 -34
- package/dist/core/reactivity/zen-signal.d.ts +0 -48
- package/dist/core/reactivity/zen-signal.js +0 -84
- package/dist/core/reactivity/zen-state.d.ts +0 -35
- package/dist/core/reactivity/zen-state.js +0 -147
- package/dist/core/reactivity/zen-untrack.d.ts +0 -38
- package/dist/core/reactivity/zen-untrack.js +0 -41
- package/dist/css/index.d.ts +0 -73
- package/dist/css/index.js +0 -246
- package/dist/discovery/componentDiscovery.d.ts +0 -42
- package/dist/discovery/componentDiscovery.js +0 -56
- package/dist/discovery/layouts.d.ts +0 -13
- package/dist/discovery/layouts.js +0 -41
- package/dist/errors/compilerError.d.ts +0 -31
- package/dist/errors/compilerError.js +0 -51
- package/dist/finalize/finalizeOutput.d.ts +0 -32
- package/dist/finalize/finalizeOutput.js +0 -62
- package/dist/finalize/generateFinalBundle.d.ts +0 -24
- package/dist/finalize/generateFinalBundle.js +0 -68
- package/dist/index.d.ts +0 -38
- package/dist/index.js +0 -57
- package/dist/ir/types.d.ts +0 -181
- package/dist/ir/types.js +0 -8
- package/dist/output/types.d.ts +0 -30
- package/dist/output/types.js +0 -6
- package/dist/parse/detectMapExpressions.d.ts +0 -45
- package/dist/parse/detectMapExpressions.js +0 -77
- package/dist/parse/parseScript.d.ts +0 -8
- package/dist/parse/parseScript.js +0 -36
- package/dist/parse/parseTemplate.d.ts +0 -11
- package/dist/parse/parseTemplate.js +0 -487
- package/dist/parse/parseZenFile.d.ts +0 -11
- package/dist/parse/parseZenFile.js +0 -50
- package/dist/parse/scriptAnalysis.d.ts +0 -25
- package/dist/parse/scriptAnalysis.js +0 -60
- package/dist/parse/trackLoopContext.d.ts +0 -20
- package/dist/parse/trackLoopContext.js +0 -62
- package/dist/parseZenFile.d.ts +0 -10
- package/dist/parseZenFile.js +0 -55
- package/dist/runtime/analyzeAndEmit.d.ts +0 -20
- package/dist/runtime/analyzeAndEmit.js +0 -70
- package/dist/runtime/build.d.ts +0 -6
- package/dist/runtime/build.js +0 -13
- package/dist/runtime/bundle-generator.d.ts +0 -27
- package/dist/runtime/bundle-generator.js +0 -1438
- package/dist/runtime/client-runtime.d.ts +0 -41
- package/dist/runtime/client-runtime.js +0 -397
- package/dist/runtime/dataExposure.d.ts +0 -52
- package/dist/runtime/dataExposure.js +0 -227
- package/dist/runtime/generateDOM.d.ts +0 -21
- package/dist/runtime/generateDOM.js +0 -194
- package/dist/runtime/generateHydrationBundle.d.ts +0 -15
- package/dist/runtime/generateHydrationBundle.js +0 -399
- package/dist/runtime/hydration.d.ts +0 -53
- package/dist/runtime/hydration.js +0 -271
- package/dist/runtime/navigation.d.ts +0 -58
- package/dist/runtime/navigation.js +0 -372
- package/dist/runtime/serve.d.ts +0 -13
- package/dist/runtime/serve.js +0 -76
- package/dist/runtime/thinRuntime.d.ts +0 -23
- package/dist/runtime/thinRuntime.js +0 -158
- package/dist/runtime/transformIR.d.ts +0 -19
- package/dist/runtime/transformIR.js +0 -285
- package/dist/runtime/wrapExpression.d.ts +0 -24
- package/dist/runtime/wrapExpression.js +0 -76
- package/dist/runtime/wrapExpressionWithLoop.d.ts +0 -17
- package/dist/runtime/wrapExpressionWithLoop.js +0 -75
- package/dist/spa-build.d.ts +0 -26
- package/dist/spa-build.js +0 -857
- package/dist/ssg-build.d.ts +0 -32
- package/dist/ssg-build.js +0 -408
- package/dist/test/analyze-emit.test.d.ts +0 -1
- package/dist/test/analyze-emit.test.js +0 -88
- package/dist/test/bundler-contract.test.d.ts +0 -1
- package/dist/test/bundler-contract.test.js +0 -137
- package/dist/test/compiler-authority.test.d.ts +0 -1
- package/dist/test/compiler-authority.test.js +0 -90
- package/dist/test/component-instance-test.d.ts +0 -1
- package/dist/test/component-instance-test.js +0 -115
- package/dist/test/error-native-bridge.test.d.ts +0 -1
- package/dist/test/error-native-bridge.test.js +0 -51
- package/dist/test/error-serialization.test.d.ts +0 -1
- package/dist/test/error-serialization.test.js +0 -38
- package/dist/test/macro-inlining.test.d.ts +0 -1
- package/dist/test/macro-inlining.test.js +0 -178
- package/dist/test/validate-test.d.ts +0 -6
- package/dist/test/validate-test.js +0 -95
- package/dist/transform/classifyExpression.d.ts +0 -46
- package/dist/transform/classifyExpression.js +0 -359
- package/dist/transform/componentResolver.d.ts +0 -15
- package/dist/transform/componentResolver.js +0 -24
- package/dist/transform/expressionTransformer.d.ts +0 -19
- package/dist/transform/expressionTransformer.js +0 -333
- package/dist/transform/fragmentLowering.d.ts +0 -25
- package/dist/transform/fragmentLowering.js +0 -468
- package/dist/transform/layoutProcessor.d.ts +0 -5
- package/dist/transform/layoutProcessor.js +0 -34
- package/dist/transform/transformTemplate.d.ts +0 -11
- package/dist/transform/transformTemplate.js +0 -33
- package/dist/validate/invariants.d.ts +0 -23
- package/dist/validate/invariants.js +0 -55
|
Binary file
|
|
@@ -12,6 +12,7 @@ export interface RuntimeCode {
|
|
|
12
12
|
stateInit: string
|
|
13
13
|
bundle: string
|
|
14
14
|
npmImports: Array<ScriptImport>
|
|
15
|
+
errors: Array<string>
|
|
15
16
|
}
|
|
16
17
|
export interface ScriptImport {
|
|
17
18
|
source: string
|
|
@@ -26,8 +27,7 @@ export declare function resolveComponentsNative(irJson: string, componentsJson:
|
|
|
26
27
|
export declare function discoverComponentsNative(baseDir: string): any
|
|
27
28
|
export declare function extractStylesNative(source: string): Array<string>
|
|
28
29
|
export declare function extractPageBindingsNative(script: string): Array<string>
|
|
29
|
-
|
|
30
|
-
export declare function discoverLayoutsNative(layoutsDir: string): any
|
|
30
|
+
export declare function extractPagePropsNative(script: string): Array<string>
|
|
31
31
|
export interface VirtualModule {
|
|
32
32
|
id: string
|
|
33
33
|
code: string
|
|
@@ -39,20 +39,59 @@ export interface BundlePlan {
|
|
|
39
39
|
resolveRoots: Array<string>
|
|
40
40
|
virtualModules: Array<VirtualModule>
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Manifest export for the bundler's capability-based chunking.
|
|
44
|
+
* This is the Compiler → Bundler handshake contract.
|
|
45
|
+
*/
|
|
46
|
+
export interface ZenManifestExport {
|
|
47
|
+
/** Entry point path */
|
|
48
|
+
entry: string
|
|
49
|
+
/** Pre-rendered HTML template */
|
|
50
|
+
template: string
|
|
51
|
+
/** Whether this page uses reactive state */
|
|
52
|
+
usesState: boolean
|
|
53
|
+
/** Whether this page has event handlers */
|
|
54
|
+
hasEvents: boolean
|
|
55
|
+
/** Whether this page is fully static */
|
|
56
|
+
isStatic: boolean
|
|
57
|
+
/** CSS classes used by this page (for pruning) */
|
|
58
|
+
cssClasses: Array<string>
|
|
59
|
+
/** Required runtime capabilities (as strings for JS interop) */
|
|
60
|
+
requiredCapabilities: Array<string>
|
|
61
|
+
/** Compiled script content (author code) */
|
|
62
|
+
script: string
|
|
63
|
+
/** Compiled expressions */
|
|
64
|
+
expressions: string
|
|
65
|
+
/** Compiled styles */
|
|
66
|
+
styles: string
|
|
67
|
+
/** NPM imports */
|
|
68
|
+
npmImports: string
|
|
69
|
+
}
|
|
42
70
|
export interface FinalizedOutput {
|
|
43
71
|
html: string
|
|
44
|
-
js: string
|
|
45
|
-
npmImports: string
|
|
46
|
-
styles: Array<string>
|
|
47
72
|
hasErrors: boolean
|
|
48
73
|
errors: Array<string>
|
|
49
|
-
|
|
74
|
+
/** Manifest for bundler's capability-based chunking */
|
|
75
|
+
manifest?: ZenManifestExport
|
|
50
76
|
}
|
|
51
77
|
export declare function finalizeOutputNative(irJson: any, compiledJson: any): FinalizedOutput
|
|
52
|
-
export declare function processLayoutNative(source: string, layoutJson: string, propsJson: string): string
|
|
53
78
|
export declare function parseTemplateNative(html: string, filePath: string): any
|
|
54
79
|
export declare function parseScriptNative(html: string): any | null
|
|
55
80
|
export declare function isComponentTagNative(tagName: string): boolean
|
|
81
|
+
/**
|
|
82
|
+
* Full Zenith compilation entry point - the "One True Syscall"
|
|
83
|
+
*
|
|
84
|
+
* Combines: parse_template + parse_script → ZenIR → component resolution →
|
|
85
|
+
* transform → finalize → FinalizedOutput
|
|
86
|
+
*/
|
|
87
|
+
export interface ParseFullOptions {
|
|
88
|
+
mode?: string
|
|
89
|
+
useCache?: boolean
|
|
90
|
+
components?: any
|
|
91
|
+
layout?: any
|
|
92
|
+
props?: any
|
|
93
|
+
}
|
|
94
|
+
export declare function parseFullZenNative(source: string, filePath: string, optionsJson: string): any
|
|
56
95
|
export interface ExpressionAnalysisResult {
|
|
57
96
|
id: string
|
|
58
97
|
classification: string
|
|
@@ -1,19 +1,334 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/* prettier-ignore */
|
|
4
|
+
|
|
5
|
+
/* auto-generated by NAPI-RS */
|
|
6
|
+
|
|
7
|
+
const { existsSync, readFileSync } = require('fs')
|
|
8
|
+
const { join } = require('path')
|
|
9
|
+
|
|
10
|
+
const { platform, arch } = process
|
|
11
|
+
|
|
12
|
+
let nativeBinding = null
|
|
13
|
+
let localFileExisted = false
|
|
14
|
+
let loadError = null
|
|
15
|
+
|
|
16
|
+
function isMusl() {
|
|
17
|
+
// For Node 10
|
|
18
|
+
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
19
|
+
try {
|
|
20
|
+
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
|
21
|
+
return readFileSync(lddPath, 'utf8').includes('musl')
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return true
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
const { glibcVersionRuntime } = process.report.getReport().header
|
|
27
|
+
return !glibcVersionRuntime
|
|
28
|
+
}
|
|
17
29
|
}
|
|
18
30
|
|
|
19
|
-
|
|
31
|
+
switch (platform) {
|
|
32
|
+
case 'android':
|
|
33
|
+
switch (arch) {
|
|
34
|
+
case 'arm64':
|
|
35
|
+
localFileExisted = existsSync(join(__dirname, 'compiler-native.android-arm64.node'))
|
|
36
|
+
try {
|
|
37
|
+
if (localFileExisted) {
|
|
38
|
+
nativeBinding = require('./compiler-native.android-arm64.node')
|
|
39
|
+
} else {
|
|
40
|
+
nativeBinding = require('@zenithbuild/compiler-native-android-arm64')
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
loadError = e
|
|
44
|
+
}
|
|
45
|
+
break
|
|
46
|
+
case 'arm':
|
|
47
|
+
localFileExisted = existsSync(join(__dirname, 'compiler-native.android-arm-eabi.node'))
|
|
48
|
+
try {
|
|
49
|
+
if (localFileExisted) {
|
|
50
|
+
nativeBinding = require('./compiler-native.android-arm-eabi.node')
|
|
51
|
+
} else {
|
|
52
|
+
nativeBinding = require('@zenithbuild/compiler-native-android-arm-eabi')
|
|
53
|
+
}
|
|
54
|
+
} catch (e) {
|
|
55
|
+
loadError = e
|
|
56
|
+
}
|
|
57
|
+
break
|
|
58
|
+
default:
|
|
59
|
+
throw new Error(`Unsupported architecture on Android ${arch}`)
|
|
60
|
+
}
|
|
61
|
+
break
|
|
62
|
+
case 'win32':
|
|
63
|
+
switch (arch) {
|
|
64
|
+
case 'x64':
|
|
65
|
+
localFileExisted = existsSync(
|
|
66
|
+
join(__dirname, 'compiler-native.win32-x64-msvc.node')
|
|
67
|
+
)
|
|
68
|
+
try {
|
|
69
|
+
if (localFileExisted) {
|
|
70
|
+
nativeBinding = require('./compiler-native.win32-x64-msvc.node')
|
|
71
|
+
} else {
|
|
72
|
+
nativeBinding = require('@zenithbuild/compiler-native-win32-x64-msvc')
|
|
73
|
+
}
|
|
74
|
+
} catch (e) {
|
|
75
|
+
loadError = e
|
|
76
|
+
}
|
|
77
|
+
break
|
|
78
|
+
case 'ia32':
|
|
79
|
+
localFileExisted = existsSync(
|
|
80
|
+
join(__dirname, 'compiler-native.win32-ia32-msvc.node')
|
|
81
|
+
)
|
|
82
|
+
try {
|
|
83
|
+
if (localFileExisted) {
|
|
84
|
+
nativeBinding = require('./compiler-native.win32-ia32-msvc.node')
|
|
85
|
+
} else {
|
|
86
|
+
nativeBinding = require('@zenithbuild/compiler-native-win32-ia32-msvc')
|
|
87
|
+
}
|
|
88
|
+
} catch (e) {
|
|
89
|
+
loadError = e
|
|
90
|
+
}
|
|
91
|
+
break
|
|
92
|
+
case 'arm64':
|
|
93
|
+
localFileExisted = existsSync(
|
|
94
|
+
join(__dirname, 'compiler-native.win32-arm64-msvc.node')
|
|
95
|
+
)
|
|
96
|
+
try {
|
|
97
|
+
if (localFileExisted) {
|
|
98
|
+
nativeBinding = require('./compiler-native.win32-arm64-msvc.node')
|
|
99
|
+
} else {
|
|
100
|
+
nativeBinding = require('@zenithbuild/compiler-native-win32-arm64-msvc')
|
|
101
|
+
}
|
|
102
|
+
} catch (e) {
|
|
103
|
+
loadError = e
|
|
104
|
+
}
|
|
105
|
+
break
|
|
106
|
+
default:
|
|
107
|
+
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
108
|
+
}
|
|
109
|
+
break
|
|
110
|
+
case 'darwin':
|
|
111
|
+
localFileExisted = existsSync(join(__dirname, 'compiler-native.darwin-universal.node'))
|
|
112
|
+
try {
|
|
113
|
+
if (localFileExisted) {
|
|
114
|
+
nativeBinding = require('./compiler-native.darwin-universal.node')
|
|
115
|
+
} else {
|
|
116
|
+
nativeBinding = require('@zenithbuild/compiler-native-darwin-universal')
|
|
117
|
+
}
|
|
118
|
+
break
|
|
119
|
+
} catch {}
|
|
120
|
+
switch (arch) {
|
|
121
|
+
case 'x64':
|
|
122
|
+
localFileExisted = existsSync(join(__dirname, 'compiler-native.darwin-x64.node'))
|
|
123
|
+
try {
|
|
124
|
+
if (localFileExisted) {
|
|
125
|
+
nativeBinding = require('./compiler-native.darwin-x64.node')
|
|
126
|
+
} else {
|
|
127
|
+
nativeBinding = require('@zenithbuild/compiler-native-darwin-x64')
|
|
128
|
+
}
|
|
129
|
+
} catch (e) {
|
|
130
|
+
loadError = e
|
|
131
|
+
}
|
|
132
|
+
break
|
|
133
|
+
case 'arm64':
|
|
134
|
+
localFileExisted = existsSync(
|
|
135
|
+
join(__dirname, 'compiler-native.darwin-arm64.node')
|
|
136
|
+
)
|
|
137
|
+
try {
|
|
138
|
+
if (localFileExisted) {
|
|
139
|
+
nativeBinding = require('./compiler-native.darwin-arm64.node')
|
|
140
|
+
} else {
|
|
141
|
+
nativeBinding = require('@zenithbuild/compiler-native-darwin-arm64')
|
|
142
|
+
}
|
|
143
|
+
} catch (e) {
|
|
144
|
+
loadError = e
|
|
145
|
+
}
|
|
146
|
+
break
|
|
147
|
+
default:
|
|
148
|
+
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
|
149
|
+
}
|
|
150
|
+
break
|
|
151
|
+
case 'freebsd':
|
|
152
|
+
if (arch !== 'x64') {
|
|
153
|
+
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
|
154
|
+
}
|
|
155
|
+
localFileExisted = existsSync(join(__dirname, 'compiler-native.freebsd-x64.node'))
|
|
156
|
+
try {
|
|
157
|
+
if (localFileExisted) {
|
|
158
|
+
nativeBinding = require('./compiler-native.freebsd-x64.node')
|
|
159
|
+
} else {
|
|
160
|
+
nativeBinding = require('@zenithbuild/compiler-native-freebsd-x64')
|
|
161
|
+
}
|
|
162
|
+
} catch (e) {
|
|
163
|
+
loadError = e
|
|
164
|
+
}
|
|
165
|
+
break
|
|
166
|
+
case 'linux':
|
|
167
|
+
switch (arch) {
|
|
168
|
+
case 'x64':
|
|
169
|
+
if (isMusl()) {
|
|
170
|
+
localFileExisted = existsSync(
|
|
171
|
+
join(__dirname, 'compiler-native.linux-x64-musl.node')
|
|
172
|
+
)
|
|
173
|
+
try {
|
|
174
|
+
if (localFileExisted) {
|
|
175
|
+
nativeBinding = require('./compiler-native.linux-x64-musl.node')
|
|
176
|
+
} else {
|
|
177
|
+
nativeBinding = require('@zenithbuild/compiler-native-linux-x64-musl')
|
|
178
|
+
}
|
|
179
|
+
} catch (e) {
|
|
180
|
+
loadError = e
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
localFileExisted = existsSync(
|
|
184
|
+
join(__dirname, 'compiler-native.linux-x64-gnu.node')
|
|
185
|
+
)
|
|
186
|
+
try {
|
|
187
|
+
if (localFileExisted) {
|
|
188
|
+
nativeBinding = require('./compiler-native.linux-x64-gnu.node')
|
|
189
|
+
} else {
|
|
190
|
+
nativeBinding = require('@zenithbuild/compiler-native-linux-x64-gnu')
|
|
191
|
+
}
|
|
192
|
+
} catch (e) {
|
|
193
|
+
loadError = e
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
break
|
|
197
|
+
case 'arm64':
|
|
198
|
+
if (isMusl()) {
|
|
199
|
+
localFileExisted = existsSync(
|
|
200
|
+
join(__dirname, 'compiler-native.linux-arm64-musl.node')
|
|
201
|
+
)
|
|
202
|
+
try {
|
|
203
|
+
if (localFileExisted) {
|
|
204
|
+
nativeBinding = require('./compiler-native.linux-arm64-musl.node')
|
|
205
|
+
} else {
|
|
206
|
+
nativeBinding = require('@zenithbuild/compiler-native-linux-arm64-musl')
|
|
207
|
+
}
|
|
208
|
+
} catch (e) {
|
|
209
|
+
loadError = e
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
localFileExisted = existsSync(
|
|
213
|
+
join(__dirname, 'compiler-native.linux-arm64-gnu.node')
|
|
214
|
+
)
|
|
215
|
+
try {
|
|
216
|
+
if (localFileExisted) {
|
|
217
|
+
nativeBinding = require('./compiler-native.linux-arm64-gnu.node')
|
|
218
|
+
} else {
|
|
219
|
+
nativeBinding = require('@zenithbuild/compiler-native-linux-arm64-gnu')
|
|
220
|
+
}
|
|
221
|
+
} catch (e) {
|
|
222
|
+
loadError = e
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
break
|
|
226
|
+
case 'arm':
|
|
227
|
+
if (isMusl()) {
|
|
228
|
+
localFileExisted = existsSync(
|
|
229
|
+
join(__dirname, 'compiler-native.linux-arm-musleabihf.node')
|
|
230
|
+
)
|
|
231
|
+
try {
|
|
232
|
+
if (localFileExisted) {
|
|
233
|
+
nativeBinding = require('./compiler-native.linux-arm-musleabihf.node')
|
|
234
|
+
} else {
|
|
235
|
+
nativeBinding = require('@zenithbuild/compiler-native-linux-arm-musleabihf')
|
|
236
|
+
}
|
|
237
|
+
} catch (e) {
|
|
238
|
+
loadError = e
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
localFileExisted = existsSync(
|
|
242
|
+
join(__dirname, 'compiler-native.linux-arm-gnueabihf.node')
|
|
243
|
+
)
|
|
244
|
+
try {
|
|
245
|
+
if (localFileExisted) {
|
|
246
|
+
nativeBinding = require('./compiler-native.linux-arm-gnueabihf.node')
|
|
247
|
+
} else {
|
|
248
|
+
nativeBinding = require('@zenithbuild/compiler-native-linux-arm-gnueabihf')
|
|
249
|
+
}
|
|
250
|
+
} catch (e) {
|
|
251
|
+
loadError = e
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
break
|
|
255
|
+
case 'riscv64':
|
|
256
|
+
if (isMusl()) {
|
|
257
|
+
localFileExisted = existsSync(
|
|
258
|
+
join(__dirname, 'compiler-native.linux-riscv64-musl.node')
|
|
259
|
+
)
|
|
260
|
+
try {
|
|
261
|
+
if (localFileExisted) {
|
|
262
|
+
nativeBinding = require('./compiler-native.linux-riscv64-musl.node')
|
|
263
|
+
} else {
|
|
264
|
+
nativeBinding = require('@zenithbuild/compiler-native-linux-riscv64-musl')
|
|
265
|
+
}
|
|
266
|
+
} catch (e) {
|
|
267
|
+
loadError = e
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
localFileExisted = existsSync(
|
|
271
|
+
join(__dirname, 'compiler-native.linux-riscv64-gnu.node')
|
|
272
|
+
)
|
|
273
|
+
try {
|
|
274
|
+
if (localFileExisted) {
|
|
275
|
+
nativeBinding = require('./compiler-native.linux-riscv64-gnu.node')
|
|
276
|
+
} else {
|
|
277
|
+
nativeBinding = require('@zenithbuild/compiler-native-linux-riscv64-gnu')
|
|
278
|
+
}
|
|
279
|
+
} catch (e) {
|
|
280
|
+
loadError = e
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
break
|
|
284
|
+
case 's390x':
|
|
285
|
+
localFileExisted = existsSync(
|
|
286
|
+
join(__dirname, 'compiler-native.linux-s390x-gnu.node')
|
|
287
|
+
)
|
|
288
|
+
try {
|
|
289
|
+
if (localFileExisted) {
|
|
290
|
+
nativeBinding = require('./compiler-native.linux-s390x-gnu.node')
|
|
291
|
+
} else {
|
|
292
|
+
nativeBinding = require('@zenithbuild/compiler-native-linux-s390x-gnu')
|
|
293
|
+
}
|
|
294
|
+
} catch (e) {
|
|
295
|
+
loadError = e
|
|
296
|
+
}
|
|
297
|
+
break
|
|
298
|
+
default:
|
|
299
|
+
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
300
|
+
}
|
|
301
|
+
break
|
|
302
|
+
default:
|
|
303
|
+
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (!nativeBinding) {
|
|
307
|
+
if (loadError) {
|
|
308
|
+
throw loadError
|
|
309
|
+
}
|
|
310
|
+
throw new Error(`Failed to load native binding`)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const { generateRuntimeCode, generateCodegenIntent, ResolutionContext, resolveComponentsNative, discoverComponentsNative, extractStylesNative, extractPageBindingsNative, extractPagePropsNative, finalizeOutputNative, parseTemplateNative, parseScriptNative, isComponentTagNative, parseFullZenNative, lowerFragmentsNative, evaluateExpressionNative, classifyExpressionNative, analyzeExpressions, transformTemplateNative, validateIr, compileBridge } = nativeBinding
|
|
314
|
+
|
|
315
|
+
module.exports.generateRuntimeCode = generateRuntimeCode
|
|
316
|
+
module.exports.generateCodegenIntent = generateCodegenIntent
|
|
317
|
+
module.exports.ResolutionContext = ResolutionContext
|
|
318
|
+
module.exports.resolveComponentsNative = resolveComponentsNative
|
|
319
|
+
module.exports.discoverComponentsNative = discoverComponentsNative
|
|
320
|
+
module.exports.extractStylesNative = extractStylesNative
|
|
321
|
+
module.exports.extractPageBindingsNative = extractPageBindingsNative
|
|
322
|
+
module.exports.extractPagePropsNative = extractPagePropsNative
|
|
323
|
+
module.exports.finalizeOutputNative = finalizeOutputNative
|
|
324
|
+
module.exports.parseTemplateNative = parseTemplateNative
|
|
325
|
+
module.exports.parseScriptNative = parseScriptNative
|
|
326
|
+
module.exports.isComponentTagNative = isComponentTagNative
|
|
327
|
+
module.exports.parseFullZenNative = parseFullZenNative
|
|
328
|
+
module.exports.lowerFragmentsNative = lowerFragmentsNative
|
|
329
|
+
module.exports.evaluateExpressionNative = evaluateExpressionNative
|
|
330
|
+
module.exports.classifyExpressionNative = classifyExpressionNative
|
|
331
|
+
module.exports.analyzeExpressions = analyzeExpressions
|
|
332
|
+
module.exports.transformTemplateNative = transformTemplateNative
|
|
333
|
+
module.exports.validateIr = validateIr
|
|
334
|
+
module.exports.compileBridge = compileBridge
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenithbuild/compiler",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "The Iron Heart: Native Compiler for the Zenith Framework",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -46,4 +46,4 @@
|
|
|
46
46
|
"typescript": "^5.3.3",
|
|
47
47
|
"bun-types": "latest"
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
}
|
package/dist/build-analyzer.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zenith Build Analyzer
|
|
3
|
-
*
|
|
4
|
-
* Analyzes .zen page source to determine build strategy:
|
|
5
|
-
* - Static: Pure HTML+CSS, no JS needed
|
|
6
|
-
* - Hydration: Has state/events/hooks, needs page-specific JS
|
|
7
|
-
* - SSR: Uses useFetchServer, needs server rendering
|
|
8
|
-
* - SPA: Uses ZenLink with passHref, needs client router
|
|
9
|
-
*/
|
|
10
|
-
export interface PageAnalysis {
|
|
11
|
-
/** Page has state declarations that need hydration */
|
|
12
|
-
hasState: boolean;
|
|
13
|
-
/** Page has event handlers (onclick, etc.) */
|
|
14
|
-
hasEventHandlers: boolean;
|
|
15
|
-
/** Page uses lifecycle hooks (zenOnMount, zenOnUnmount) */
|
|
16
|
-
hasLifecycleHooks: boolean;
|
|
17
|
-
/** Page uses useFetchServer (requires SSR) */
|
|
18
|
-
usesServerFetch: boolean;
|
|
19
|
-
/** Page uses useFetchClient (client-side data) */
|
|
20
|
-
usesClientFetch: boolean;
|
|
21
|
-
/** Page uses ZenLink with passHref (SPA navigation) */
|
|
22
|
-
usesZenLink: boolean;
|
|
23
|
-
/** Page uses reactive expressions in templates */
|
|
24
|
-
hasReactiveExpressions: boolean;
|
|
25
|
-
/** Computed: page needs any JavaScript */
|
|
26
|
-
needsHydration: boolean;
|
|
27
|
-
/** Computed: page is purely static (no JS) */
|
|
28
|
-
isStatic: boolean;
|
|
29
|
-
/** Computed: page needs SSR */
|
|
30
|
-
needsSSR: boolean;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Analyze a .zen page source to determine build requirements
|
|
34
|
-
*/
|
|
35
|
-
export declare function analyzePageSource(source: string): PageAnalysis;
|
|
36
|
-
/**
|
|
37
|
-
* Get a human-readable summary of the page analysis
|
|
38
|
-
*/
|
|
39
|
-
export declare function getAnalysisSummary(analysis: PageAnalysis): string;
|
|
40
|
-
/**
|
|
41
|
-
* Determine build output type for a page
|
|
42
|
-
*/
|
|
43
|
-
export type BuildOutputType = 'static' | 'hydrated' | 'ssr';
|
|
44
|
-
export declare function getBuildOutputType(analysis: PageAnalysis): BuildOutputType;
|
package/dist/build-analyzer.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zenith Build Analyzer
|
|
3
|
-
*
|
|
4
|
-
* Analyzes .zen page source to determine build strategy:
|
|
5
|
-
* - Static: Pure HTML+CSS, no JS needed
|
|
6
|
-
* - Hydration: Has state/events/hooks, needs page-specific JS
|
|
7
|
-
* - SSR: Uses useFetchServer, needs server rendering
|
|
8
|
-
* - SPA: Uses ZenLink with passHref, needs client router
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Analyze a .zen page source to determine build requirements
|
|
12
|
-
*/
|
|
13
|
-
export function analyzePageSource(source) {
|
|
14
|
-
// Extract script content for analysis
|
|
15
|
-
const scriptMatch = source.match(/<script[^>]*>([\s\S]*?)<\/script>/i);
|
|
16
|
-
const scriptContent = scriptMatch?.[1] || '';
|
|
17
|
-
// Extract template content (everything outside script/style)
|
|
18
|
-
const templateContent = source
|
|
19
|
-
.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, '')
|
|
20
|
-
.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, '');
|
|
21
|
-
// Check for state declarations: "state varName = ..."
|
|
22
|
-
const hasState = /\bstate\s+\w+\s*=/.test(scriptContent);
|
|
23
|
-
// Check for event handlers in template
|
|
24
|
-
const hasEventHandlers = /\bon(click|change|input|submit|focus|blur|keydown|keyup|keypress|mousedown|mouseup|mouseover|mouseout|mouseenter|mouseleave)\s*=\s*["'{]/.test(templateContent);
|
|
25
|
-
// Check for lifecycle hooks
|
|
26
|
-
const hasLifecycleHooks = /\bzen(OnMount|OnUnmount)\s*\(/.test(scriptContent);
|
|
27
|
-
// Check for server fetch
|
|
28
|
-
const usesServerFetch = /\buseFetchServer\s*\(/.test(scriptContent);
|
|
29
|
-
// Check for client fetch
|
|
30
|
-
const usesClientFetch = /\buseFetchClient\s*\(/.test(scriptContent);
|
|
31
|
-
// Check for ZenLink with passHref
|
|
32
|
-
const usesZenLink = /<ZenLink[^>]*passHref[^>]*>/.test(templateContent);
|
|
33
|
-
// Check for reactive expressions in template: {expression}
|
|
34
|
-
// Must be actual expressions, not just static text
|
|
35
|
-
// Exclude attribute values like href="/path"
|
|
36
|
-
const hasReactiveExpressions = /{[^{}]+}/.test(templateContent);
|
|
37
|
-
// Compute derived properties
|
|
38
|
-
const needsHydration = hasState || hasEventHandlers || hasLifecycleHooks ||
|
|
39
|
-
usesClientFetch || hasReactiveExpressions;
|
|
40
|
-
const isStatic = !needsHydration && !usesServerFetch;
|
|
41
|
-
const needsSSR = usesServerFetch;
|
|
42
|
-
return {
|
|
43
|
-
hasState,
|
|
44
|
-
hasEventHandlers,
|
|
45
|
-
hasLifecycleHooks,
|
|
46
|
-
usesServerFetch,
|
|
47
|
-
usesClientFetch,
|
|
48
|
-
usesZenLink,
|
|
49
|
-
hasReactiveExpressions,
|
|
50
|
-
needsHydration,
|
|
51
|
-
isStatic,
|
|
52
|
-
needsSSR
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Get a human-readable summary of the page analysis
|
|
57
|
-
*/
|
|
58
|
-
export function getAnalysisSummary(analysis) {
|
|
59
|
-
const flags = [];
|
|
60
|
-
if (analysis.isStatic) {
|
|
61
|
-
flags.push('STATIC (no JS)');
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
if (analysis.hasState)
|
|
65
|
-
flags.push('state');
|
|
66
|
-
if (analysis.hasEventHandlers)
|
|
67
|
-
flags.push('events');
|
|
68
|
-
if (analysis.hasLifecycleHooks)
|
|
69
|
-
flags.push('lifecycle');
|
|
70
|
-
if (analysis.hasReactiveExpressions)
|
|
71
|
-
flags.push('reactive');
|
|
72
|
-
if (analysis.usesClientFetch)
|
|
73
|
-
flags.push('clientFetch');
|
|
74
|
-
}
|
|
75
|
-
if (analysis.needsSSR)
|
|
76
|
-
flags.push('SSR');
|
|
77
|
-
if (analysis.usesZenLink)
|
|
78
|
-
flags.push('SPA');
|
|
79
|
-
return flags.length > 0 ? flags.join(', ') : 'minimal';
|
|
80
|
-
}
|
|
81
|
-
export function getBuildOutputType(analysis) {
|
|
82
|
-
if (analysis.needsSSR)
|
|
83
|
-
return 'ssr';
|
|
84
|
-
if (analysis.needsHydration)
|
|
85
|
-
return 'hydrated';
|
|
86
|
-
return 'static';
|
|
87
|
-
}
|
package/dist/bundler.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @zenithbuild/core - Page Script Bundler
|
|
3
|
-
*
|
|
4
|
-
* COMPILER-FIRST ARCHITECTURE
|
|
5
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
6
|
-
*
|
|
7
|
-
* This bundler performs ZERO inference. It executes exactly what the compiler specifies.
|
|
8
|
-
*
|
|
9
|
-
* Rules:
|
|
10
|
-
* - If a BundlePlan is provided, bundling MUST occur
|
|
11
|
-
* - If bundling fails, throw a hard error (no fallback)
|
|
12
|
-
* - The bundler never inspects source code for intent
|
|
13
|
-
* - No temp files, no heuristics, no recovery
|
|
14
|
-
*
|
|
15
|
-
* Bundler failure = compiler bug.
|
|
16
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
17
|
-
*/
|
|
18
|
-
import type { BundlePlan } from './ir/types';
|
|
19
|
-
/**
|
|
20
|
-
* Execute a compiler-emitted BundlePlan
|
|
21
|
-
*
|
|
22
|
-
* This is a PURE PLAN EXECUTOR. It does not:
|
|
23
|
-
* - Inspect source code for imports
|
|
24
|
-
* - Decide whether bundling is needed
|
|
25
|
-
* - Fall back on failure
|
|
26
|
-
* - Use temp files
|
|
27
|
-
*
|
|
28
|
-
* @param plan - Compiler-emitted BundlePlan (must exist; caller must not call if no plan)
|
|
29
|
-
* @throws Error if bundling fails (no fallback, no recovery)
|
|
30
|
-
*/
|
|
31
|
-
export declare function bundlePageScript(plan: BundlePlan): Promise<string>;
|