@zenithbuild/compiler 0.5.0-beta.2.6 → 0.6.0
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/README.md +6 -0
- package/dist/index.js +24 -5
- package/package.json +1 -1
- package/target/release/zenith-compiler +0 -0
package/README.md
CHANGED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
The Iron Heart of the Zenith framework. High-performance native compiler and build-time architect.
|
|
7
7
|
|
|
8
|
+
## Canonical Docs
|
|
9
|
+
|
|
10
|
+
- Compiler boundary: `../zenith-docs/documentation/contracts/compiler-boundary.md`
|
|
11
|
+
- IR envelope: `../zenith-docs/documentation/contracts/ir-envelope.md`
|
|
12
|
+
- Component script hoisting: `../zenith-docs/documentation/contracts/component-script-hoisting.md`
|
|
13
|
+
|
|
8
14
|
## Overview
|
|
9
15
|
|
|
10
16
|
@zenithbuild/compiler owns everything related to structure, wiring, and validation. It is a coordinated companion to `@zenithbuild/core`.
|
package/dist/index.js
CHANGED
|
@@ -5,13 +5,32 @@ import { fileURLToPath } from 'node:url'
|
|
|
5
5
|
const __filename = fileURLToPath(import.meta.url)
|
|
6
6
|
const __dirname = path.dirname(__filename)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Compile Zenith source.
|
|
10
|
+
*
|
|
11
|
+
* Back-compat: compile(filePath) reads from file.
|
|
12
|
+
* New mode: compile({ source, filePath }) or compile(source, filePath) uses stdin.
|
|
13
|
+
*
|
|
14
|
+
* @param {string|{ source: string, filePath: string }} entryPathOrSource - File path, or source string, or { source, filePath }
|
|
15
|
+
* @param {string|object} [filePathOrOptions] - File path (when first arg is source string), or options (ignored)
|
|
16
|
+
* @returns {object} Parsed JSON output (includes warnings array)
|
|
17
|
+
*/
|
|
18
|
+
export function compile(entryPathOrSource, filePathOrOptions = {}) {
|
|
9
19
|
const bin = path.resolve(__dirname, '../target/release/zenith-compiler')
|
|
10
|
-
|
|
20
|
+
let args
|
|
21
|
+
let spawnOpts = { encoding: 'utf8' }
|
|
11
22
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
if (typeof entryPathOrSource === 'object' && entryPathOrSource !== null && 'source' in entryPathOrSource && 'filePath' in entryPathOrSource) {
|
|
24
|
+
args = ['--stdin', entryPathOrSource.filePath]
|
|
25
|
+
spawnOpts.input = entryPathOrSource.source
|
|
26
|
+
} else if (typeof entryPathOrSource === 'string' && typeof filePathOrOptions === 'string') {
|
|
27
|
+
args = ['--stdin', filePathOrOptions]
|
|
28
|
+
spawnOpts.input = entryPathOrSource
|
|
29
|
+
} else {
|
|
30
|
+
args = [entryPathOrSource]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const result = spawnSync(bin, args, spawnOpts)
|
|
15
34
|
|
|
16
35
|
if (result.status !== 0) {
|
|
17
36
|
throw new Error(result.stderr || 'Compiler execution failed')
|
package/package.json
CHANGED
|
Binary file
|