@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.
Files changed (145) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -0
  3. package/dist/build-analyzer.d.ts +44 -0
  4. package/dist/build-analyzer.js +87 -0
  5. package/dist/bundler.d.ts +31 -0
  6. package/dist/bundler.js +86 -0
  7. package/dist/core/components/index.d.ts +9 -0
  8. package/dist/core/components/index.js +13 -0
  9. package/dist/core/config/index.d.ts +11 -0
  10. package/dist/core/config/index.js +10 -0
  11. package/dist/core/config/loader.d.ts +17 -0
  12. package/dist/core/config/loader.js +60 -0
  13. package/dist/core/config/types.d.ts +98 -0
  14. package/dist/core/config/types.js +32 -0
  15. package/dist/core/index.d.ts +7 -0
  16. package/dist/core/index.js +6 -0
  17. package/dist/core/lifecycle/index.d.ts +16 -0
  18. package/dist/core/lifecycle/index.js +19 -0
  19. package/dist/core/lifecycle/zen-mount.d.ts +66 -0
  20. package/dist/core/lifecycle/zen-mount.js +151 -0
  21. package/dist/core/lifecycle/zen-unmount.d.ts +54 -0
  22. package/dist/core/lifecycle/zen-unmount.js +76 -0
  23. package/dist/core/plugins/bridge.d.ts +116 -0
  24. package/dist/core/plugins/bridge.js +121 -0
  25. package/dist/core/plugins/index.d.ts +6 -0
  26. package/dist/core/plugins/index.js +6 -0
  27. package/dist/core/plugins/registry.d.ts +67 -0
  28. package/dist/core/plugins/registry.js +113 -0
  29. package/dist/core/reactivity/index.d.ts +30 -0
  30. package/dist/core/reactivity/index.js +33 -0
  31. package/dist/core/reactivity/tracking.d.ts +74 -0
  32. package/dist/core/reactivity/tracking.js +136 -0
  33. package/dist/core/reactivity/zen-batch.d.ts +45 -0
  34. package/dist/core/reactivity/zen-batch.js +54 -0
  35. package/dist/core/reactivity/zen-effect.d.ts +48 -0
  36. package/dist/core/reactivity/zen-effect.js +98 -0
  37. package/dist/core/reactivity/zen-memo.d.ts +43 -0
  38. package/dist/core/reactivity/zen-memo.js +100 -0
  39. package/dist/core/reactivity/zen-ref.d.ts +44 -0
  40. package/dist/core/reactivity/zen-ref.js +34 -0
  41. package/dist/core/reactivity/zen-signal.d.ts +48 -0
  42. package/dist/core/reactivity/zen-signal.js +84 -0
  43. package/dist/core/reactivity/zen-state.d.ts +35 -0
  44. package/dist/core/reactivity/zen-state.js +147 -0
  45. package/dist/core/reactivity/zen-untrack.d.ts +38 -0
  46. package/dist/core/reactivity/zen-untrack.js +41 -0
  47. package/dist/css/index.d.ts +73 -0
  48. package/dist/css/index.js +246 -0
  49. package/dist/discovery/componentDiscovery.d.ts +42 -0
  50. package/dist/discovery/componentDiscovery.js +56 -0
  51. package/dist/discovery/layouts.d.ts +13 -0
  52. package/dist/discovery/layouts.js +41 -0
  53. package/dist/errors/compilerError.d.ts +31 -0
  54. package/dist/errors/compilerError.js +51 -0
  55. package/dist/finalize/finalizeOutput.d.ts +32 -0
  56. package/dist/finalize/finalizeOutput.js +62 -0
  57. package/dist/finalize/generateFinalBundle.d.ts +24 -0
  58. package/dist/finalize/generateFinalBundle.js +68 -0
  59. package/dist/index.d.ts +36 -0
  60. package/dist/index.js +51 -0
  61. package/dist/ir/types.d.ts +181 -0
  62. package/dist/ir/types.js +8 -0
  63. package/dist/output/types.d.ts +30 -0
  64. package/dist/output/types.js +6 -0
  65. package/dist/parse/detectMapExpressions.d.ts +45 -0
  66. package/dist/parse/detectMapExpressions.js +77 -0
  67. package/dist/parse/parseScript.d.ts +8 -0
  68. package/dist/parse/parseScript.js +36 -0
  69. package/dist/parse/parseTemplate.d.ts +11 -0
  70. package/dist/parse/parseTemplate.js +487 -0
  71. package/dist/parse/parseZenFile.d.ts +11 -0
  72. package/dist/parse/parseZenFile.js +50 -0
  73. package/dist/parse/scriptAnalysis.d.ts +25 -0
  74. package/dist/parse/scriptAnalysis.js +60 -0
  75. package/dist/parse/trackLoopContext.d.ts +20 -0
  76. package/dist/parse/trackLoopContext.js +62 -0
  77. package/dist/parseZenFile.d.ts +10 -0
  78. package/dist/parseZenFile.js +55 -0
  79. package/dist/runtime/analyzeAndEmit.d.ts +20 -0
  80. package/dist/runtime/analyzeAndEmit.js +70 -0
  81. package/dist/runtime/build.d.ts +6 -0
  82. package/dist/runtime/build.js +13 -0
  83. package/dist/runtime/bundle-generator.d.ts +27 -0
  84. package/dist/runtime/bundle-generator.js +1263 -0
  85. package/dist/runtime/client-runtime.d.ts +41 -0
  86. package/dist/runtime/client-runtime.js +397 -0
  87. package/dist/runtime/dataExposure.d.ts +52 -0
  88. package/dist/runtime/dataExposure.js +227 -0
  89. package/dist/runtime/generateDOM.d.ts +21 -0
  90. package/dist/runtime/generateDOM.js +194 -0
  91. package/dist/runtime/generateHydrationBundle.d.ts +15 -0
  92. package/dist/runtime/generateHydrationBundle.js +399 -0
  93. package/dist/runtime/hydration.d.ts +53 -0
  94. package/dist/runtime/hydration.js +271 -0
  95. package/dist/runtime/navigation.d.ts +58 -0
  96. package/dist/runtime/navigation.js +372 -0
  97. package/dist/runtime/serve.d.ts +13 -0
  98. package/dist/runtime/serve.js +76 -0
  99. package/dist/runtime/thinRuntime.d.ts +23 -0
  100. package/dist/runtime/thinRuntime.js +158 -0
  101. package/dist/runtime/transformIR.d.ts +19 -0
  102. package/dist/runtime/transformIR.js +285 -0
  103. package/dist/runtime/wrapExpression.d.ts +24 -0
  104. package/dist/runtime/wrapExpression.js +76 -0
  105. package/dist/runtime/wrapExpressionWithLoop.d.ts +17 -0
  106. package/dist/runtime/wrapExpressionWithLoop.js +75 -0
  107. package/dist/spa-build.d.ts +26 -0
  108. package/dist/spa-build.js +866 -0
  109. package/dist/ssg-build.d.ts +32 -0
  110. package/dist/ssg-build.js +408 -0
  111. package/dist/test/analyze-emit.test.d.ts +1 -0
  112. package/dist/test/analyze-emit.test.js +88 -0
  113. package/dist/test/bundler-contract.test.d.ts +1 -0
  114. package/dist/test/bundler-contract.test.js +137 -0
  115. package/dist/test/compiler-authority.test.d.ts +1 -0
  116. package/dist/test/compiler-authority.test.js +90 -0
  117. package/dist/test/component-instance-test.d.ts +1 -0
  118. package/dist/test/component-instance-test.js +115 -0
  119. package/dist/test/error-native-bridge.test.d.ts +1 -0
  120. package/dist/test/error-native-bridge.test.js +51 -0
  121. package/dist/test/error-serialization.test.d.ts +1 -0
  122. package/dist/test/error-serialization.test.js +38 -0
  123. package/dist/test/macro-inlining.test.d.ts +1 -0
  124. package/dist/test/macro-inlining.test.js +178 -0
  125. package/dist/test/validate-test.d.ts +6 -0
  126. package/dist/test/validate-test.js +95 -0
  127. package/dist/transform/classifyExpression.d.ts +46 -0
  128. package/dist/transform/classifyExpression.js +354 -0
  129. package/dist/transform/componentResolver.d.ts +15 -0
  130. package/dist/transform/componentResolver.js +30 -0
  131. package/dist/transform/expressionTransformer.d.ts +19 -0
  132. package/dist/transform/expressionTransformer.js +333 -0
  133. package/dist/transform/fragmentLowering.d.ts +25 -0
  134. package/dist/transform/fragmentLowering.js +468 -0
  135. package/dist/transform/layoutProcessor.d.ts +5 -0
  136. package/dist/transform/layoutProcessor.js +34 -0
  137. package/dist/transform/transformTemplate.d.ts +11 -0
  138. package/dist/transform/transformTemplate.js +33 -0
  139. package/dist/validate/invariants.d.ts +23 -0
  140. package/dist/validate/invariants.js +55 -0
  141. package/native/compiler-native/compiler-native.node +0 -0
  142. package/native/compiler-native/index.d.ts +113 -0
  143. package/native/compiler-native/index.js +19 -0
  144. package/native/compiler-native/package.json +19 -0
  145. 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
+ }