@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,113 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
export interface RuntimeCode {
|
|
7
|
+
expressions: string
|
|
8
|
+
render: string
|
|
9
|
+
hydration: string
|
|
10
|
+
styles: string
|
|
11
|
+
script: string
|
|
12
|
+
stateInit: string
|
|
13
|
+
bundle: string
|
|
14
|
+
npmImports: Array<ScriptImport>
|
|
15
|
+
}
|
|
16
|
+
export interface ScriptImport {
|
|
17
|
+
source: string
|
|
18
|
+
specifiers: string
|
|
19
|
+
typeOnly: boolean
|
|
20
|
+
sideEffect: boolean
|
|
21
|
+
}
|
|
22
|
+
export declare function generateRuntimeCode(inputJson: string): RuntimeCode
|
|
23
|
+
export declare function generateCodegenIntent(): string
|
|
24
|
+
export declare function resolveComponentsNative(irJson: string, componentsJson: string): string
|
|
25
|
+
/** Discover all components in a directory */
|
|
26
|
+
export declare function discoverComponentsNative(baseDir: string): any
|
|
27
|
+
export declare function extractStylesNative(source: string): Array<string>
|
|
28
|
+
export declare function extractPageBindingsNative(script: string): Array<string>
|
|
29
|
+
/** Discover layouts in a directory */
|
|
30
|
+
export declare function discoverLayoutsNative(layoutsDir: string): any
|
|
31
|
+
export interface VirtualModule {
|
|
32
|
+
id: string
|
|
33
|
+
code: string
|
|
34
|
+
}
|
|
35
|
+
export interface BundlePlan {
|
|
36
|
+
entry: string
|
|
37
|
+
platform: string
|
|
38
|
+
format: string
|
|
39
|
+
resolveRoots: Array<string>
|
|
40
|
+
virtualModules: Array<VirtualModule>
|
|
41
|
+
}
|
|
42
|
+
export interface FinalizedOutput {
|
|
43
|
+
html: string
|
|
44
|
+
js: string
|
|
45
|
+
npmImports: string
|
|
46
|
+
styles: Array<string>
|
|
47
|
+
hasErrors: boolean
|
|
48
|
+
errors: Array<string>
|
|
49
|
+
bundlePlan?: BundlePlan
|
|
50
|
+
}
|
|
51
|
+
export declare function finalizeOutputNative(irJson: any, compiledJson: any): FinalizedOutput
|
|
52
|
+
export declare function processLayoutNative(source: string, layoutJson: string, propsJson: string): string
|
|
53
|
+
export declare function parseTemplateNative(html: string, filePath: string): any
|
|
54
|
+
export declare function parseScriptNative(html: string): any | null
|
|
55
|
+
export declare function isComponentTagNative(tagName: string): boolean
|
|
56
|
+
export interface ExpressionAnalysisResult {
|
|
57
|
+
id: string
|
|
58
|
+
classification: string
|
|
59
|
+
dependencies: Array<string>
|
|
60
|
+
usesState: boolean
|
|
61
|
+
usesLoopContext: boolean
|
|
62
|
+
}
|
|
63
|
+
export interface EvaluatedExpression {
|
|
64
|
+
id: string
|
|
65
|
+
expressionType: string
|
|
66
|
+
dependencies: Array<string>
|
|
67
|
+
usesState: boolean
|
|
68
|
+
usesLoopContext: boolean
|
|
69
|
+
classificationJson: string
|
|
70
|
+
}
|
|
71
|
+
export interface AnalysisOutput {
|
|
72
|
+
results: Array<ExpressionAnalysisResult>
|
|
73
|
+
bindingCount: number
|
|
74
|
+
}
|
|
75
|
+
export declare function lowerFragmentsNative(nodesJson: string, expressionsJson: string, filePath: string): string
|
|
76
|
+
export declare function evaluateExpressionNative(id: string, code: string, knownBindingsJson: string, loopContextJson?: string | undefined | null): EvaluatedExpression
|
|
77
|
+
export declare function classifyExpressionNative(code: string): string
|
|
78
|
+
export declare function analyzeExpressions(inputJson: string): AnalysisOutput
|
|
79
|
+
export interface Binding {
|
|
80
|
+
id: string
|
|
81
|
+
type: string
|
|
82
|
+
target: string
|
|
83
|
+
expression: string
|
|
84
|
+
location?: SourceLocation
|
|
85
|
+
loopContext?: LoopContext
|
|
86
|
+
}
|
|
87
|
+
export interface TransformOutput {
|
|
88
|
+
html: string
|
|
89
|
+
bindings: Array<Binding>
|
|
90
|
+
}
|
|
91
|
+
export declare function transformTemplateNative(nodesJson: string, expressionsJson: string): TransformOutput
|
|
92
|
+
export interface CompilerError {
|
|
93
|
+
code: string
|
|
94
|
+
errorType: string
|
|
95
|
+
message: string
|
|
96
|
+
guarantee: string
|
|
97
|
+
file: string
|
|
98
|
+
line: number
|
|
99
|
+
column: number
|
|
100
|
+
context?: string
|
|
101
|
+
hints: Array<string>
|
|
102
|
+
}
|
|
103
|
+
export interface SourceLocation {
|
|
104
|
+
line: number
|
|
105
|
+
column: number
|
|
106
|
+
}
|
|
107
|
+
export interface LoopContext {
|
|
108
|
+
variables: Array<string>
|
|
109
|
+
mapSource?: string
|
|
110
|
+
}
|
|
111
|
+
export declare function validateIr(irJson: string): CompilerError | null
|
|
112
|
+
export declare function compileBridge(): string
|
|
113
|
+
export declare class ResolutionContext { }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const { join } = require('path');
|
|
2
|
+
const { statSync } = require('fs');
|
|
3
|
+
|
|
4
|
+
let nativeBinding;
|
|
5
|
+
|
|
6
|
+
// Get the mtime of the .node file to bust bun's cache
|
|
7
|
+
const nodePath = join(__dirname, 'compiler-native.node');
|
|
8
|
+
const mtime = statSync(nodePath).mtimeMs;
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
// Clear require cache to force reload
|
|
12
|
+
delete require.cache[require.resolve('./compiler-native.node')];
|
|
13
|
+
nativeBinding = require('./compiler-native.node');
|
|
14
|
+
} catch (e) {
|
|
15
|
+
console.error('[Zenith Native] Failed to load native binding:', e.message);
|
|
16
|
+
throw e;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = nativeBinding;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zenithbuild/compiler-native",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"types": "index.d.ts",
|
|
6
|
+
"napi": {
|
|
7
|
+
"name": "compiler-native",
|
|
8
|
+
"package": {
|
|
9
|
+
"name": "@zenithbuild/compiler-native"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "napi build --release",
|
|
14
|
+
"build:debug": "napi build"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@napi-rs/cli": "^2.18.4"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zenithbuild/compiler",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "The Iron Heart: Native Compiler for the Zenith Framework",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js",
|
|
9
|
+
"./config": "./dist/core/config/index.js",
|
|
10
|
+
"./plugins": "./dist/core/plugins/index.js",
|
|
11
|
+
"./runtime": "./dist/runtime/index.js"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"native/compiler-native/index.js",
|
|
16
|
+
"native/compiler-native/index.d.ts",
|
|
17
|
+
"native/compiler-native/package.json",
|
|
18
|
+
"native/compiler-native/compiler-native.node"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc && cd native/compiler-native && npm run build",
|
|
25
|
+
"test": "bun test"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"esbuild": "^0.20.0",
|
|
29
|
+
"ws": "^8.16.0",
|
|
30
|
+
"rolldown": "latest",
|
|
31
|
+
"@zenithbuild/router": "1.0.1",
|
|
32
|
+
"acorn": "^8.15.0",
|
|
33
|
+
"es-module-lexer": "^2.0.0",
|
|
34
|
+
"marked": "^17.0.1",
|
|
35
|
+
"parse5": "^8.0.0",
|
|
36
|
+
"picocolors": "^1.1.1",
|
|
37
|
+
"prompts": "^2.4.2",
|
|
38
|
+
"glob": "^10.3.10"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^20.11.0",
|
|
42
|
+
"@types/acorn": "^6.0.4",
|
|
43
|
+
"@types/marked": "^6.0.0",
|
|
44
|
+
"@types/parse5": "^7.0.0",
|
|
45
|
+
"@types/prompts": "^2.4.9",
|
|
46
|
+
"typescript": "^5.3.3",
|
|
47
|
+
"bun-types": "latest"
|
|
48
|
+
}
|
|
49
|
+
}
|