zyzz 0.0.27 → 0.0.29
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/binding/wasi/wasi-worker.mjs +186 -0
- package/binding/wasi/zyzz.wasi.cjs +2302 -0
- package/binding/wasi/zyzz.wasm32-wasi.wasm +0 -0
- package/binding/zyzz.linux-x64-gnu.node +0 -0
- package/dist/babel/index.d.ts.map +1 -1
- package/dist/babel/index.js +2 -4
- package/dist/babel/index.js.map +1 -1
- package/dist/babel/internal/Compilation.d.ts +0 -1
- package/dist/babel/internal/Compilation.d.ts.map +1 -1
- package/dist/compiler/Graph.d.ts +14 -11
- package/dist/compiler/Graph.d.ts.map +1 -1
- package/dist/compiler/Graph.js +57 -1442
- package/dist/compiler/Graph.js.map +1 -1
- package/dist/compiler/Native.d.ts +7 -9
- package/dist/compiler/Native.d.ts.map +1 -1
- package/dist/compiler/Native.js +12 -716
- package/dist/compiler/Native.js.map +1 -1
- package/dist/compiler/Source.d.ts +122 -24
- package/dist/compiler/Source.d.ts.map +1 -1
- package/dist/compiler/Source.js +10 -1113
- package/dist/compiler/Source.js.map +1 -1
- package/dist/compiler/Transform.d.ts +4 -3
- package/dist/compiler/Transform.d.ts.map +1 -1
- package/dist/compiler/Transform.js +13 -958
- package/dist/compiler/Transform.js.map +1 -1
- package/dist/compiler/internal/AtRules.d.ts +5 -1
- package/dist/compiler/internal/AtRules.d.ts.map +1 -1
- package/dist/compiler/internal/AtRules.js +12 -106
- package/dist/compiler/internal/AtRules.js.map +1 -1
- package/dist/compiler/internal/Context.d.ts +11 -0
- package/dist/compiler/internal/Context.d.ts.map +1 -0
- package/dist/compiler/internal/Context.js +11 -0
- package/dist/compiler/internal/Context.js.map +1 -0
- package/dist/compiler/internal/Results.d.ts +148 -0
- package/dist/compiler/internal/Results.d.ts.map +1 -0
- package/dist/compiler/internal/Results.js +259 -0
- package/dist/compiler/internal/Results.js.map +1 -0
- package/dist/compiler/internal/Syntax.d.ts +0 -2
- package/dist/compiler/internal/Syntax.d.ts.map +1 -1
- package/dist/compiler/internal/Syntax.js +0 -2
- package/dist/compiler/internal/Syntax.js.map +1 -1
- package/dist/compiler/internal/Wire.d.ts +17 -0
- package/dist/compiler/internal/Wire.d.ts.map +1 -0
- package/dist/compiler/internal/Wire.js +795 -0
- package/dist/compiler/internal/Wire.js.map +1 -0
- package/dist/internal/Addon.d.ts +28 -0
- package/dist/internal/Addon.d.ts.map +1 -0
- package/dist/internal/Addon.js +87 -0
- package/dist/internal/Addon.js.map +1 -0
- package/dist/internal/Authoring.d.ts.map +1 -1
- package/dist/internal/Authoring.js +37 -7
- package/dist/internal/Authoring.js.map +1 -1
- package/dist/internal/Configuration.d.ts +6 -1
- package/dist/internal/Configuration.d.ts.map +1 -1
- package/dist/internal/Configuration.js.map +1 -1
- package/dist/internal/Literal.d.ts +5 -2
- package/dist/internal/Literal.d.ts.map +1 -1
- package/dist/internal/Literal.js +7 -2
- package/dist/internal/Literal.js.map +1 -1
- package/dist/internal/Theme.d.ts +4 -0
- package/dist/internal/Theme.d.ts.map +1 -1
- package/dist/internal/Theme.js.map +1 -1
- package/dist/internal/Token.d.ts +2 -1
- package/dist/internal/Token.d.ts.map +1 -1
- package/dist/internal/Token.js +2 -2
- package/dist/internal/Token.js.map +1 -1
- package/dist/internal/Vlq.d.ts +14 -0
- package/dist/internal/Vlq.d.ts.map +1 -0
- package/dist/internal/Vlq.js +47 -0
- package/dist/internal/Vlq.js.map +1 -0
- package/dist/internal/Wasm.d.ts +22 -0
- package/dist/internal/Wasm.d.ts.map +1 -0
- package/dist/internal/Wasm.js +83 -0
- package/dist/internal/Wasm.js.map +1 -0
- package/dist/metro/Graph.d.ts +0 -1
- package/dist/metro/Graph.d.ts.map +1 -1
- package/dist/metro/transformer.d.ts.map +1 -1
- package/dist/metro/transformer.js +0 -1
- package/dist/metro/transformer.js.map +1 -1
- package/dist/next/internal/Project.d.ts.map +1 -1
- package/dist/next/internal/Project.js +2 -5
- package/dist/next/internal/Project.js.map +1 -1
- package/dist/node/Host.d.ts.map +1 -1
- package/dist/node/Host.js +0 -2
- package/dist/node/Host.js.map +1 -1
- package/dist/node/internal/Contracts.d.ts.map +1 -1
- package/dist/node/internal/Contracts.js +3 -7
- package/dist/node/internal/Contracts.js.map +1 -1
- package/dist/node/internal/Snapshot.d.ts +0 -1
- package/dist/node/internal/Snapshot.d.ts.map +1 -1
- package/dist/node/internal/Snapshot.js +0 -6
- package/dist/node/internal/Snapshot.js.map +1 -1
- package/dist/runtime/Composition.d.ts +2 -3
- package/dist/runtime/Composition.d.ts.map +1 -1
- package/dist/runtime/Composition.js +51 -30
- package/dist/runtime/Composition.js.map +1 -1
- package/dist/runtime/Recipe.d.ts.map +1 -1
- package/dist/runtime/Recipe.js +16 -12
- package/dist/runtime/Recipe.js.map +1 -1
- package/dist/styleFunction.d.ts +11 -2
- package/dist/styleFunction.d.ts.map +1 -1
- package/dist/styleFunction.js +3 -1
- package/dist/styleFunction.js.map +1 -1
- package/dist/unplugin/index.d.ts.map +1 -1
- package/dist/unplugin/index.js +3 -6
- package/dist/unplugin/index.js.map +1 -1
- package/dist/vite/index.d.ts +7 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +862 -216
- package/dist/vite/index.js.map +1 -1
- package/dist/web/Css.d.ts +8 -3
- package/dist/web/Css.d.ts.map +1 -1
- package/dist/web/Css.js +5 -721
- package/dist/web/Css.js.map +1 -1
- package/dist/web/internal/Block.d.ts +0 -2
- package/dist/web/internal/Block.d.ts.map +1 -1
- package/dist/web/internal/Block.js +1 -12
- package/dist/web/internal/Block.js.map +1 -1
- package/dist/web/internal/ClassName.d.ts +23 -18
- package/dist/web/internal/ClassName.d.ts.map +1 -1
- package/dist/web/internal/ClassName.js +26 -55
- package/dist/web/internal/ClassName.js.map +1 -1
- package/dist/web/internal/Contributions.d.ts +3 -5
- package/dist/web/internal/Contributions.d.ts.map +1 -1
- package/dist/web/internal/Contributions.js +0 -45
- package/dist/web/internal/Contributions.js.map +1 -1
- package/dist/web/internal/Engine.browser.d.ts +8 -0
- package/dist/web/internal/Engine.browser.d.ts.map +1 -0
- package/dist/web/internal/Engine.browser.js +42 -0
- package/dist/web/internal/Engine.browser.js.map +1 -0
- package/dist/web/internal/Engine.d.ts +9 -0
- package/dist/web/internal/Engine.d.ts.map +1 -0
- package/dist/web/internal/Engine.js +14 -0
- package/dist/web/internal/Engine.js.map +1 -0
- package/dist/web/internal/Themes.d.ts +1 -9
- package/dist/web/internal/Themes.d.ts.map +1 -1
- package/dist/web/internal/Themes.js +3 -221
- package/dist/web/internal/Themes.js.map +1 -1
- package/dist/web/internal/Wasm.generated.d.ts +4 -0
- package/dist/web/internal/Wasm.generated.d.ts.map +1 -0
- package/dist/web/internal/Wasm.generated.js +4 -0
- package/dist/web/internal/Wasm.generated.js.map +1 -0
- package/dist/web/internal/Wire.d.ts +19 -0
- package/dist/web/internal/Wire.d.ts.map +1 -0
- package/dist/web/internal/Wire.js +387 -0
- package/dist/web/internal/Wire.js.map +1 -0
- package/package.json +20 -1
- package/src/babel/index.ts +2 -5
- package/src/babel/internal/Compilation.ts +0 -1
- package/src/compiler/Graph.ts +89 -1930
- package/src/compiler/Native.ts +18 -871
- package/src/compiler/Source.ts +144 -1579
- package/src/compiler/Transform.ts +16 -1312
- package/src/compiler/internal/AtRules.ts +27 -115
- package/src/compiler/internal/Context.ts +11 -0
- package/src/compiler/internal/Results.ts +406 -0
- package/src/compiler/internal/Syntax.ts +0 -3
- package/src/compiler/internal/Wire.ts +1045 -0
- package/src/internal/Addon.ts +118 -0
- package/src/internal/Authoring.ts +53 -18
- package/src/internal/Configuration.ts +38 -1
- package/src/internal/Literal.ts +7 -2
- package/src/internal/Theme.ts +15 -0
- package/src/internal/Token.ts +2 -2
- package/src/internal/Vlq.ts +59 -0
- package/src/internal/Wasm.ts +111 -0
- package/src/metro/transformer.ts +0 -1
- package/src/next/internal/Project.ts +2 -9
- package/src/node/Host.ts +0 -2
- package/src/node/internal/Contracts.ts +3 -7
- package/src/node/internal/Snapshot.ts +0 -8
- package/src/runtime/Composition.ts +48 -25
- package/src/runtime/Recipe.ts +21 -14
- package/src/styleFunction.ts +31 -2
- package/src/unplugin/index.ts +6 -6
- package/src/vite/index.ts +1157 -241
- package/src/web/Css.ts +12 -908
- package/src/web/internal/Block.ts +0 -14
- package/src/web/internal/ClassName.ts +52 -85
- package/src/web/internal/Contributions.ts +3 -59
- package/src/web/internal/Engine.browser.ts +51 -0
- package/src/web/internal/Engine.ts +17 -0
- package/src/web/internal/Themes.ts +3 -279
- package/src/web/internal/Wasm.generated.ts +3 -0
- package/src/web/internal/Wire.ts +466 -0
- package/src/web/internal/wasm.d.ts +9 -0
- package/dist/compiler/internal/Applications.d.ts +0 -55
- package/dist/compiler/internal/Applications.d.ts.map +0 -1
- package/dist/compiler/internal/Applications.js +0 -352
- package/dist/compiler/internal/Applications.js.map +0 -1
- package/dist/compiler/internal/ColorProfiles.d.ts +0 -3
- package/dist/compiler/internal/ColorProfiles.d.ts.map +0 -1
- package/dist/compiler/internal/ColorProfiles.js +0 -84
- package/dist/compiler/internal/ColorProfiles.js.map +0 -1
- package/dist/compiler/internal/CompositionBindings.d.ts +0 -16
- package/dist/compiler/internal/CompositionBindings.d.ts.map +0 -1
- package/dist/compiler/internal/CompositionBindings.js +0 -89
- package/dist/compiler/internal/CompositionBindings.js.map +0 -1
- package/dist/compiler/internal/Compositions.d.ts +0 -37
- package/dist/compiler/internal/Compositions.d.ts.map +0 -1
- package/dist/compiler/internal/Compositions.js +0 -494
- package/dist/compiler/internal/Compositions.js.map +0 -1
- package/dist/compiler/internal/Configurations.d.ts +0 -26
- package/dist/compiler/internal/Configurations.d.ts.map +0 -1
- package/dist/compiler/internal/Configurations.js +0 -259
- package/dist/compiler/internal/Configurations.js.map +0 -1
- package/dist/compiler/internal/Contract.d.ts +0 -30
- package/dist/compiler/internal/Contract.d.ts.map +0 -1
- package/dist/compiler/internal/Contract.js +0 -753
- package/dist/compiler/internal/Contract.js.map +0 -1
- package/dist/compiler/internal/Contributions.d.ts +0 -54
- package/dist/compiler/internal/Contributions.d.ts.map +0 -1
- package/dist/compiler/internal/Contributions.js +0 -1151
- package/dist/compiler/internal/Contributions.js.map +0 -1
- package/dist/compiler/internal/Descriptors.d.ts +0 -15
- package/dist/compiler/internal/Descriptors.d.ts.map +0 -1
- package/dist/compiler/internal/Descriptors.js +0 -192
- package/dist/compiler/internal/Descriptors.js.map +0 -1
- package/dist/compiler/internal/Dynamic.d.ts +0 -14
- package/dist/compiler/internal/Dynamic.d.ts.map +0 -1
- package/dist/compiler/internal/Dynamic.js +0 -175
- package/dist/compiler/internal/Dynamic.js.map +0 -1
- package/dist/compiler/internal/Expression.d.ts +0 -19
- package/dist/compiler/internal/Expression.d.ts.map +0 -1
- package/dist/compiler/internal/Expression.js +0 -164
- package/dist/compiler/internal/Expression.js.map +0 -1
- package/dist/compiler/internal/Functions.d.ts +0 -5
- package/dist/compiler/internal/Functions.d.ts.map +0 -1
- package/dist/compiler/internal/Functions.js +0 -191
- package/dist/compiler/internal/Functions.js.map +0 -1
- package/dist/compiler/internal/Keyframes.d.ts +0 -5
- package/dist/compiler/internal/Keyframes.d.ts.map +0 -1
- package/dist/compiler/internal/Keyframes.js +0 -51
- package/dist/compiler/internal/Keyframes.js.map +0 -1
- package/dist/compiler/internal/Names.d.ts +0 -5
- package/dist/compiler/internal/Names.d.ts.map +0 -1
- package/dist/compiler/internal/Names.js +0 -37
- package/dist/compiler/internal/Names.js.map +0 -1
- package/dist/compiler/internal/NativeBindings.d.ts +0 -72
- package/dist/compiler/internal/NativeBindings.d.ts.map +0 -1
- package/dist/compiler/internal/NativeBindings.js +0 -171
- package/dist/compiler/internal/NativeBindings.js.map +0 -1
- package/dist/compiler/internal/NativeMedia.d.ts +0 -14
- package/dist/compiler/internal/NativeMedia.d.ts.map +0 -1
- package/dist/compiler/internal/NativeMedia.js +0 -287
- package/dist/compiler/internal/NativeMedia.js.map +0 -1
- package/dist/compiler/internal/NativeVars.d.ts +0 -28
- package/dist/compiler/internal/NativeVars.d.ts.map +0 -1
- package/dist/compiler/internal/NativeVars.js +0 -160
- package/dist/compiler/internal/NativeVars.js.map +0 -1
- package/dist/compiler/internal/PackedStyles.d.ts +0 -37
- package/dist/compiler/internal/PackedStyles.d.ts.map +0 -1
- package/dist/compiler/internal/PackedStyles.js +0 -344
- package/dist/compiler/internal/PackedStyles.js.map +0 -1
- package/dist/compiler/internal/Properties.d.ts +0 -5
- package/dist/compiler/internal/Properties.d.ts.map +0 -1
- package/dist/compiler/internal/Properties.js +0 -82
- package/dist/compiler/internal/Properties.js.map +0 -1
- package/dist/compiler/internal/RecipeConditions.d.ts +0 -41
- package/dist/compiler/internal/RecipeConditions.d.ts.map +0 -1
- package/dist/compiler/internal/RecipeConditions.js +0 -82
- package/dist/compiler/internal/RecipeConditions.js.map +0 -1
- package/dist/compiler/internal/RecipePayloads.d.ts +0 -31
- package/dist/compiler/internal/RecipePayloads.d.ts.map +0 -1
- package/dist/compiler/internal/RecipePayloads.js +0 -99
- package/dist/compiler/internal/RecipePayloads.js.map +0 -1
- package/dist/compiler/internal/Recipes.d.ts +0 -32
- package/dist/compiler/internal/Recipes.d.ts.map +0 -1
- package/dist/compiler/internal/Recipes.js +0 -339
- package/dist/compiler/internal/Recipes.js.map +0 -1
- package/dist/compiler/internal/Selectors.d.ts +0 -12
- package/dist/compiler/internal/Selectors.d.ts.map +0 -1
- package/dist/compiler/internal/Selectors.js +0 -268
- package/dist/compiler/internal/Selectors.js.map +0 -1
- package/dist/compiler/internal/Static.d.ts +0 -39
- package/dist/compiler/internal/Static.d.ts.map +0 -1
- package/dist/compiler/internal/Static.js +0 -534
- package/dist/compiler/internal/Static.js.map +0 -1
- package/dist/compiler/internal/Themes.d.ts +0 -190
- package/dist/compiler/internal/Themes.d.ts.map +0 -1
- package/dist/compiler/internal/Themes.js +0 -1577
- package/dist/compiler/internal/Themes.js.map +0 -1
- package/dist/compiler/internal/Vars.d.ts +0 -33
- package/dist/compiler/internal/Vars.d.ts.map +0 -1
- package/dist/compiler/internal/Vars.js +0 -387
- package/dist/compiler/internal/Vars.js.map +0 -1
- package/dist/compiler/internal/ViewTransitions.d.ts +0 -3
- package/dist/compiler/internal/ViewTransitions.d.ts.map +0 -1
- package/dist/compiler/internal/ViewTransitions.js +0 -68
- package/dist/compiler/internal/ViewTransitions.js.map +0 -1
- package/dist/internal/Cascade.d.ts +0 -74
- package/dist/internal/Cascade.d.ts.map +0 -1
- package/dist/internal/Cascade.js +0 -210
- package/dist/internal/Cascade.js.map +0 -1
- package/src/compiler/internal/Applications.ts +0 -554
- package/src/compiler/internal/ColorProfiles.ts +0 -93
- package/src/compiler/internal/CompositionBindings.ts +0 -120
- package/src/compiler/internal/Compositions.ts +0 -678
- package/src/compiler/internal/Configurations.ts +0 -349
- package/src/compiler/internal/Contract.ts +0 -1028
- package/src/compiler/internal/Contributions.ts +0 -1561
- package/src/compiler/internal/Descriptors.ts +0 -242
- package/src/compiler/internal/Dynamic.ts +0 -275
- package/src/compiler/internal/Expression.ts +0 -218
- package/src/compiler/internal/Functions.ts +0 -206
- package/src/compiler/internal/Keyframes.ts +0 -62
- package/src/compiler/internal/Names.ts +0 -48
- package/src/compiler/internal/NativeBindings.ts +0 -235
- package/src/compiler/internal/NativeMedia.ts +0 -342
- package/src/compiler/internal/NativeVars.ts +0 -231
- package/src/compiler/internal/PackedStyles.ts +0 -473
- package/src/compiler/internal/Properties.ts +0 -121
- package/src/compiler/internal/RecipeConditions.ts +0 -139
- package/src/compiler/internal/RecipePayloads.ts +0 -132
- package/src/compiler/internal/Recipes.ts +0 -531
- package/src/compiler/internal/Selectors.ts +0 -339
- package/src/compiler/internal/Static.ts +0 -784
- package/src/compiler/internal/Themes.ts +0 -2398
- package/src/compiler/internal/Vars.ts +0 -516
- package/src/compiler/internal/ViewTransitions.ts +0 -82
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads the Rust compiler addon for the current platform, falling back to its WebAssembly build.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import * as Fs from 'node:fs'
|
|
6
|
+
import * as Module from 'node:module'
|
|
7
|
+
import * as Path from 'node:path'
|
|
8
|
+
import * as Url from 'node:url'
|
|
9
|
+
|
|
10
|
+
/** Functions the Rust addon exports. Structured values cross as JSON strings. */
|
|
11
|
+
export type Exports = {
|
|
12
|
+
/** Runs a named compiler operation on UTF-8 JSON input and returns its UTF-8 JSON result. */
|
|
13
|
+
readonly call: (operation: string, input: string) => string
|
|
14
|
+
/** An incremental graph compiler whose caches live as long as the instance. */
|
|
15
|
+
readonly Graph: new () => {
|
|
16
|
+
/** Compiles one JSON graph snapshot and returns its JSON result. */
|
|
17
|
+
readonly compile: (input: string) => string
|
|
18
|
+
}
|
|
19
|
+
/** Version of the compiler crate, which also proves the addon loaded. */
|
|
20
|
+
readonly version: () => string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Thrown when no addon build loads for the current platform. */
|
|
24
|
+
export class LoadError extends Error {
|
|
25
|
+
/** Lists every candidate and why it failed. */
|
|
26
|
+
constructor(failures: readonly (readonly [string, unknown])[]) {
|
|
27
|
+
super(
|
|
28
|
+
`Unable to load the Zyzz compiler addon for ${process.platform}-${process.arch}. Tried:\n${failures
|
|
29
|
+
.map(
|
|
30
|
+
([candidate, error]) =>
|
|
31
|
+
`- ${candidate}: ${error instanceof Error ? error.message : String(error)}`,
|
|
32
|
+
)
|
|
33
|
+
.join('\n')}`,
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
/** Stable namespaced error identifier. */
|
|
37
|
+
override name = 'Addon.LoadError'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Node caches native addons per process, so one resolved handle serves every caller.
|
|
41
|
+
let loaded: Exports | undefined
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Returns the addon, resolving it on first use.
|
|
45
|
+
* Candidates are the repository's local build, the platform package, then the local and packaged
|
|
46
|
+
* WebAssembly builds.
|
|
47
|
+
* @returns The addon exports.
|
|
48
|
+
* @throws {LoadError} If no candidate loads.
|
|
49
|
+
*/
|
|
50
|
+
export function load(): Exports {
|
|
51
|
+
loaded ??= resolve()
|
|
52
|
+
|
|
53
|
+
return loaded
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function resolve(): Exports {
|
|
57
|
+
const require = Module.createRequire(import.meta.url)
|
|
58
|
+
const directory = Path.dirname(Url.fileURLToPath(import.meta.url))
|
|
59
|
+
const failures: [string, unknown][] = []
|
|
60
|
+
|
|
61
|
+
for (const target of targets()) {
|
|
62
|
+
// Source and built modules both sit two levels below the package root.
|
|
63
|
+
const local = Path.resolve(
|
|
64
|
+
directory,
|
|
65
|
+
'../../binding',
|
|
66
|
+
`zyzz.${target}.node`,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
for (const candidate of [local, `@zyzz/binding-${target}`]) {
|
|
70
|
+
if (candidate === local && !Fs.existsSync(local)) continue
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
return require(candidate) as Exports
|
|
74
|
+
} catch (error) {
|
|
75
|
+
failures.push([candidate, error])
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const wasi = Path.resolve(directory, '../../binding/wasi/zyzz.wasi.cjs')
|
|
81
|
+
|
|
82
|
+
for (const candidate of [wasi, '@zyzz/binding-wasm32-wasi']) {
|
|
83
|
+
if (candidate === wasi && !Fs.existsSync(wasi)) continue
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
return require(candidate) as Exports
|
|
87
|
+
} catch (error) {
|
|
88
|
+
failures.push([candidate, error])
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
throw new LoadError(failures)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Lists the napi-rs platform suffixes this process can load, most specific first. */
|
|
96
|
+
function targets(): readonly string[] {
|
|
97
|
+
const { arch, platform } = process
|
|
98
|
+
|
|
99
|
+
if (platform === 'darwin') return [`darwin-${arch}`, 'darwin-universal']
|
|
100
|
+
if (platform === 'win32') return [`win32-${arch}-msvc`]
|
|
101
|
+
if (platform === 'linux') return [`linux-${arch}-${musl() ? 'musl' : 'gnu'}`]
|
|
102
|
+
|
|
103
|
+
return [`${platform}-${arch}`]
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Detects musl libc, whose binaries differ from glibc builds. */
|
|
107
|
+
function musl(): boolean {
|
|
108
|
+
const report = process.report?.getReport() as
|
|
109
|
+
| { header?: { glibcVersionRuntime?: string } }
|
|
110
|
+
| undefined
|
|
111
|
+
if (report?.header?.glibcVersionRuntime) return false
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
return Fs.readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
|
|
115
|
+
} catch {
|
|
116
|
+
return true
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -10,6 +10,10 @@ import type * as Theme from './Theme.js'
|
|
|
10
10
|
/** Private ownership used by uncompiled composition; never spread onto DOM props. */
|
|
11
11
|
export const metadata = Symbol.for('zyzz.authoring')
|
|
12
12
|
|
|
13
|
+
// Static definitions retain their style data so later compositions can read it,
|
|
14
|
+
// including definitions created by another bundled copy of the runtime.
|
|
15
|
+
const data = Symbol.for('zyzz.style')
|
|
16
|
+
|
|
13
17
|
/** Identity and replaceable attribute/slot ownership for an applied definition. */
|
|
14
18
|
export type Owner = {
|
|
15
19
|
readonly name: string
|
|
@@ -77,24 +81,54 @@ export function create(
|
|
|
77
81
|
if (!dynamic && !id && Object.keys(input as object).length === 0)
|
|
78
82
|
Identity.requireId(undefined, 'Empty style')
|
|
79
83
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
const define = (input: unknown) =>
|
|
85
|
+
(
|
|
86
|
+
Style.define as (
|
|
87
|
+
input: Record<string, unknown>,
|
|
88
|
+
options: Style.define.Options,
|
|
89
|
+
) => Style.Definition
|
|
90
|
+
)(
|
|
91
|
+
{ style: body(input as Record<string, unknown>) },
|
|
92
|
+
{ vars: options.theme },
|
|
93
|
+
).styles[0]!
|
|
94
|
+
|
|
95
|
+
const style = (() => {
|
|
96
|
+
if (dynamic) return undefined
|
|
97
|
+
if (!Array.isArray(input)) return define(input)
|
|
98
|
+
|
|
99
|
+
// Mirrors compiled composition: each entry is one ordered declaration segment.
|
|
100
|
+
const rules: Style.Rule[] = []
|
|
101
|
+
for (const [index, entry] of (input as readonly unknown[]).entries()) {
|
|
102
|
+
if (typeof entry !== 'function') {
|
|
103
|
+
rules.push({ style: define(entry) })
|
|
104
|
+
continue
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const style = Object.getOwnPropertyDescriptor(entry, data)?.value as
|
|
108
|
+
| Style.NamedStyle
|
|
109
|
+
| undefined
|
|
110
|
+
if (style) {
|
|
111
|
+
rules.push({ style })
|
|
112
|
+
continue
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Compiled callables carry only class names, so an explicit id names the composite.
|
|
116
|
+
if (id) return undefined
|
|
117
|
+
|
|
118
|
+
throw new Style.InvalidError([
|
|
119
|
+
{
|
|
120
|
+
code: 'invalid_structure',
|
|
121
|
+
message:
|
|
122
|
+
'Composition entries require literal objects or static style definitions. Compositions of compiled definitions require an explicit id, and variants and dynamic styles are applied with cx.',
|
|
123
|
+
path: [String(index)],
|
|
124
|
+
},
|
|
125
|
+
])
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return { name: 'style', declarations: [], rules } satisfies Style.NamedStyle
|
|
129
|
+
})()
|
|
130
|
+
|
|
131
|
+
const className = id ? `z-style-${id}` : Identity.style(style!, namespace)
|
|
98
132
|
const props = Props.create({ className })
|
|
99
133
|
const apply = (values?: style.Options & Record<string, unknown>) => {
|
|
100
134
|
let result = props(values as style.Options)
|
|
@@ -124,6 +158,7 @@ export function create(
|
|
|
124
158
|
Object.defineProperty(apply, Symbol.toPrimitive, {
|
|
125
159
|
value: () => `.${className}`,
|
|
126
160
|
})
|
|
161
|
+
if (style) Object.defineProperty(apply, data, { value: style })
|
|
127
162
|
return apply as style.ReturnType
|
|
128
163
|
}
|
|
129
164
|
|
|
@@ -625,15 +625,52 @@ export type StyleFactory<
|
|
|
625
625
|
? [options?: style.DefinitionOptions]
|
|
626
626
|
: [invalid: never, unavailable: never]
|
|
627
627
|
: [invalid: never, unavailable: never]
|
|
628
|
-
|
|
628
|
+
// TypeScript types a call that matches no overload with this signature. Other
|
|
629
|
+
// inputs leave `callback` at its constraint, so their definitions stay static.
|
|
630
|
+
): ((...args: never[]) => unknown) extends callback
|
|
631
|
+
? style.ReturnType<output>
|
|
632
|
+
: style.Dynamic<values, output>
|
|
629
633
|
<const styles extends Record<string, unknown>>(
|
|
630
634
|
styles: styles &
|
|
631
635
|
NoInfer<Body<styles, tokens, layers, mappings>> &
|
|
632
636
|
Completion.Properties<tokens>,
|
|
633
637
|
options?: style.DefinitionOptions,
|
|
634
638
|
): style.ReturnType<output>
|
|
639
|
+
<const entries>(
|
|
640
|
+
styles: entries & Entries<entries, tokens, layers, mappings>,
|
|
641
|
+
...options: entries extends readonly unknown[]
|
|
642
|
+
? [options?: style.DefinitionOptions]
|
|
643
|
+
: [invalid: never, unavailable: never]
|
|
644
|
+
): style.ReturnType<output>
|
|
635
645
|
}
|
|
636
646
|
|
|
647
|
+
// Composition entries are static definitions or checked literal objects.
|
|
648
|
+
type Entries<
|
|
649
|
+
entries,
|
|
650
|
+
tokens extends Theme.Tokens,
|
|
651
|
+
layers extends string,
|
|
652
|
+
mappings extends Shorthands.Map,
|
|
653
|
+
> = {
|
|
654
|
+
readonly [index in keyof entries]: Entry<
|
|
655
|
+
entries[index],
|
|
656
|
+
tokens,
|
|
657
|
+
layers,
|
|
658
|
+
mappings
|
|
659
|
+
>
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// Distributes over mixed element unions so each member keeps its own contract.
|
|
663
|
+
type Entry<
|
|
664
|
+
entry,
|
|
665
|
+
tokens extends Theme.Tokens,
|
|
666
|
+
layers extends string,
|
|
667
|
+
mappings extends Shorthands.Map,
|
|
668
|
+
> = entry extends (...args: never) => unknown
|
|
669
|
+
? style.Composable<entry>
|
|
670
|
+
: entry &
|
|
671
|
+
NoInfer<Body<entry, tokens, layers, mappings>> &
|
|
672
|
+
Completion.Properties<tokens>
|
|
673
|
+
|
|
637
674
|
type Keys<styles> = styles extends unknown ? keyof styles : never
|
|
638
675
|
|
|
639
676
|
/** Checked declaration body shared by configured styles and recipe choices. */
|
package/src/internal/Literal.ts
CHANGED
|
@@ -528,7 +528,8 @@ const fragmentation = {
|
|
|
528
528
|
'verso',
|
|
529
529
|
],
|
|
530
530
|
} as const
|
|
531
|
-
|
|
531
|
+
/** CSS-wide keywords accepted by every property. */
|
|
532
|
+
export const globals = new Set<string>([
|
|
532
533
|
'inherit',
|
|
533
534
|
'initial',
|
|
534
535
|
'revert',
|
|
@@ -744,7 +745,8 @@ export const namedColors = [
|
|
|
744
745
|
'yellow',
|
|
745
746
|
'yellowgreen',
|
|
746
747
|
] as const
|
|
747
|
-
|
|
748
|
+
/** Deprecated and current system color keywords. */
|
|
749
|
+
export const systemColors = [
|
|
748
750
|
'ActiveBorder',
|
|
749
751
|
'ActiveCaption',
|
|
750
752
|
'AppWorkspace',
|
|
@@ -1588,7 +1590,10 @@ const properties = {
|
|
|
1588
1590
|
direction: { kind: 'enum', values: ['ltr', 'rtl'] },
|
|
1589
1591
|
display: {
|
|
1590
1592
|
kind: 'enum',
|
|
1593
|
+
// The Compat Standard keeps the legacy box keywords that -webkit-line-clamp requires.
|
|
1591
1594
|
values: [
|
|
1595
|
+
'-webkit-box',
|
|
1596
|
+
'-webkit-inline-box',
|
|
1592
1597
|
'block',
|
|
1593
1598
|
'block flex',
|
|
1594
1599
|
'block flow',
|
package/src/internal/Theme.ts
CHANGED
|
@@ -38,6 +38,14 @@ export type StyleFactory<tokens extends Tokens> = {
|
|
|
38
38
|
(values extends Binding.Inputs<values> ? unknown : never),
|
|
39
39
|
options?: style.DefinitionOptions,
|
|
40
40
|
): style.Dynamic<values>
|
|
41
|
+
<const entries>(
|
|
42
|
+
styles: entries & {
|
|
43
|
+
readonly [index in keyof entries]: Entry<entries[index], tokens>
|
|
44
|
+
},
|
|
45
|
+
...options: entries extends readonly unknown[]
|
|
46
|
+
? [options?: style.DefinitionOptions]
|
|
47
|
+
: [invalid: never, unavailable: never]
|
|
48
|
+
): style.ReturnType
|
|
41
49
|
<const styles extends Record<string, unknown>>(
|
|
42
50
|
styles: styles & NoInfer<Style.Accepted<styles, tokens>>,
|
|
43
51
|
options?: style.DefinitionOptions,
|
|
@@ -56,6 +64,13 @@ export type StyleFactory<tokens extends Tokens> = {
|
|
|
56
64
|
): style.ReturnType
|
|
57
65
|
}
|
|
58
66
|
|
|
67
|
+
// Distributes over mixed element unions so each member keeps its own contract.
|
|
68
|
+
type Entry<entry, tokens extends Tokens> = entry extends (
|
|
69
|
+
...args: never
|
|
70
|
+
) => unknown
|
|
71
|
+
? style.Composable<entry>
|
|
72
|
+
: entry & NoInfer<Style.Accepted<entry, tokens>>
|
|
73
|
+
|
|
59
74
|
/**
|
|
60
75
|
* Defines scalar tokens and typography sets without defaults or environment access.
|
|
61
76
|
* Colors currently use the supported literal color grammar; spacing and radius
|
package/src/internal/Token.ts
CHANGED
|
@@ -11,8 +11,8 @@ import type * as VariableSets from '../Vars.js'
|
|
|
11
11
|
import * as Literal from './Literal.js'
|
|
12
12
|
import * as VariableData from './VariableSets.js'
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
const propertyGroups = {
|
|
14
|
+
/** Ordered category fallbacks shared by runtime lookup and inferred token names. */
|
|
15
|
+
export const propertyGroups = {
|
|
16
16
|
accentColor: ['accentColor', 'color'],
|
|
17
17
|
animation: ['animate'],
|
|
18
18
|
aspectRatio: ['aspect'],
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** Encodes and decodes one source map segment of Base64 VLQ fields. @module */
|
|
2
|
+
|
|
3
|
+
const alphabet =
|
|
4
|
+
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
|
5
|
+
const digits = new Map(
|
|
6
|
+
[...alphabet].map((character, index) => [character, index]),
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Reads every field of one segment.
|
|
11
|
+
* @param segment - Base64 VLQ text between separators.
|
|
12
|
+
* @returns Each signed field, in order.
|
|
13
|
+
*/
|
|
14
|
+
export function decode(segment: string): number[] {
|
|
15
|
+
const fields: number[] = []
|
|
16
|
+
let shift = 0
|
|
17
|
+
let value = 0
|
|
18
|
+
|
|
19
|
+
for (const character of segment) {
|
|
20
|
+
const digit = digits.get(character)
|
|
21
|
+
if (digit === undefined) throw new Error('Invalid source map segment.')
|
|
22
|
+
|
|
23
|
+
value += (digit & 31) << shift
|
|
24
|
+
|
|
25
|
+
if (digit & 32) {
|
|
26
|
+
shift += 5
|
|
27
|
+
continue
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
fields.push(value & 1 ? -(value >>> 1) : value >>> 1)
|
|
31
|
+
shift = 0
|
|
32
|
+
value = 0
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return fields
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Writes the fields of one segment.
|
|
40
|
+
* @param fields - Signed fields, in order.
|
|
41
|
+
* @returns Base64 VLQ text without separators.
|
|
42
|
+
*/
|
|
43
|
+
export function encode(fields: readonly number[]): string {
|
|
44
|
+
let output = ''
|
|
45
|
+
|
|
46
|
+
for (const field of fields) {
|
|
47
|
+
let value = field < 0 ? (-field << 1) | 1 : field << 1
|
|
48
|
+
|
|
49
|
+
do {
|
|
50
|
+
let digit = value & 31
|
|
51
|
+
|
|
52
|
+
value >>>= 5
|
|
53
|
+
if (value > 0) digit |= 32
|
|
54
|
+
output += alphabet[digit]
|
|
55
|
+
} while (value > 0)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return output
|
|
59
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instantiates the WebAssembly compiler synchronously from its bytes, for hosts without the native addon.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** Operations the WebAssembly module runs on UTF-8 JSON input. */
|
|
7
|
+
export type Instance = {
|
|
8
|
+
/** Runs a named operation and returns its UTF-8 JSON result. */
|
|
9
|
+
readonly call: (operation: string, input: string) => string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type Exports = {
|
|
13
|
+
readonly memory: WebAssembly.Memory
|
|
14
|
+
readonly zyzz_alloc: (length: number) => number
|
|
15
|
+
readonly zyzz_call: (
|
|
16
|
+
operation: number,
|
|
17
|
+
operationLength: number,
|
|
18
|
+
input: number,
|
|
19
|
+
inputLength: number,
|
|
20
|
+
) => bigint
|
|
21
|
+
readonly zyzz_free: (pointer: number, length: number) => void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Thrown when the module traps, with the panic message it printed. */
|
|
25
|
+
export class TrapError extends Error {
|
|
26
|
+
/** Stable namespaced error identifier. */
|
|
27
|
+
override name = 'Wasm.TrapError'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Compiles and instantiates the module without awaiting, so synchronous APIs can call it.
|
|
32
|
+
* A trap leaves Rust state undefined, so the next call starts a fresh instance.
|
|
33
|
+
* @param bytes - The `crates/wasm` module.
|
|
34
|
+
* @returns The instance's operations.
|
|
35
|
+
*/
|
|
36
|
+
export function instantiate(bytes: BufferSource): Instance {
|
|
37
|
+
const module = new WebAssembly.Module(bytes)
|
|
38
|
+
const encoder = new TextEncoder()
|
|
39
|
+
const decoder = new TextDecoder()
|
|
40
|
+
let exports: Exports | undefined
|
|
41
|
+
let stderr = ''
|
|
42
|
+
|
|
43
|
+
function start(): Exports {
|
|
44
|
+
stderr = ''
|
|
45
|
+
// The reactor reads no files, clock, or environment. WASI output only carries panic messages.
|
|
46
|
+
const wasi = {
|
|
47
|
+
environ_get: () => 0,
|
|
48
|
+
environ_sizes_get: (count: number, size: number) => {
|
|
49
|
+
const view = new DataView(exports!.memory.buffer)
|
|
50
|
+
view.setUint32(count, 0, true)
|
|
51
|
+
view.setUint32(size, 0, true)
|
|
52
|
+
return 0
|
|
53
|
+
},
|
|
54
|
+
fd_write: (_: number, iovs: number, length: number, written: number) => {
|
|
55
|
+
const memory = exports!.memory.buffer
|
|
56
|
+
const view = new DataView(memory)
|
|
57
|
+
let total = 0
|
|
58
|
+
for (let index = 0; index < length; index++) {
|
|
59
|
+
const pointer = view.getUint32(iovs + index * 8, true)
|
|
60
|
+
const size = view.getUint32(iovs + index * 8 + 4, true)
|
|
61
|
+
stderr += decoder.decode(new Uint8Array(memory, pointer, size))
|
|
62
|
+
total += size
|
|
63
|
+
}
|
|
64
|
+
view.setUint32(written, total, true)
|
|
65
|
+
return 0
|
|
66
|
+
},
|
|
67
|
+
proc_exit: (code: number) => {
|
|
68
|
+
throw new TrapError(`WebAssembly compiler exited with code ${code}.`)
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
const instance = new WebAssembly.Instance(module, {
|
|
72
|
+
wasi_snapshot_preview1: wasi,
|
|
73
|
+
})
|
|
74
|
+
return instance.exports as unknown as Exports
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function write(target: Exports, text: string): readonly [number, number] {
|
|
78
|
+
const bytes = encoder.encode(text)
|
|
79
|
+
const pointer = target.zyzz_alloc(bytes.length)
|
|
80
|
+
new Uint8Array(target.memory.buffer, pointer, bytes.length).set(bytes)
|
|
81
|
+
return [pointer, bytes.length]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
call(operation, input) {
|
|
86
|
+
const target = (exports ??= start())
|
|
87
|
+
try {
|
|
88
|
+
const [operationPointer, operationLength] = write(target, operation)
|
|
89
|
+
const [inputPointer, inputLength] = write(target, input)
|
|
90
|
+
const packed = target.zyzz_call(
|
|
91
|
+
operationPointer,
|
|
92
|
+
operationLength,
|
|
93
|
+
inputPointer,
|
|
94
|
+
inputLength,
|
|
95
|
+
)
|
|
96
|
+
const pointer = Number(packed >> 32n)
|
|
97
|
+
const length = Number(packed & 0xffffffffn)
|
|
98
|
+
const output = decoder.decode(
|
|
99
|
+
new Uint8Array(target.memory.buffer, pointer, length),
|
|
100
|
+
)
|
|
101
|
+
target.zyzz_free(pointer, length)
|
|
102
|
+
return output
|
|
103
|
+
} catch (error) {
|
|
104
|
+
exports = undefined
|
|
105
|
+
if (error instanceof WebAssembly.RuntimeError)
|
|
106
|
+
throw new TrapError(stderr.trim() || error.message, { cause: error })
|
|
107
|
+
throw error
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
}
|
|
111
|
+
}
|
package/src/metro/transformer.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** Retains filesystem snapshots and an incremental graph within a Next.js loader worker. @module */
|
|
2
|
-
import * as Contract from '../../compiler/internal/Contract.js'
|
|
3
2
|
import * as Contracts from '../../node/internal/Contracts.js'
|
|
4
3
|
import * as Fs from 'node:fs/promises'
|
|
5
4
|
import * as Graph from '../../compiler/Graph.js'
|
|
6
5
|
import * as Path from 'node:path'
|
|
7
6
|
import * as Reset from '../../node/Reset.js'
|
|
7
|
+
import * as Results from '../../compiler/internal/Results.js'
|
|
8
8
|
import * as Stylesheets from '../../compiler/internal/Stylesheets.js'
|
|
9
9
|
import * as Syntax from '../../compiler/internal/Syntax.js'
|
|
10
10
|
|
|
@@ -80,7 +80,6 @@ export function create(options: create.Options) {
|
|
|
80
80
|
if (tracked.has(file)) return
|
|
81
81
|
tracked.add(file)
|
|
82
82
|
}
|
|
83
|
-
const programs = new Map<string, ReturnType<typeof Syntax.parse>>()
|
|
84
83
|
const reads = new Map<string, Promise<string>>()
|
|
85
84
|
function read(file: string) {
|
|
86
85
|
let pending = reads.get(file)
|
|
@@ -266,7 +265,6 @@ export function create(options: create.Options) {
|
|
|
266
265
|
const links: Record<string, string | null> = Object.create(null)
|
|
267
266
|
imports[name] = links
|
|
268
267
|
const parsed = parse(name, modules[name]!)
|
|
269
|
-
programs.set(name, parsed)
|
|
270
268
|
|
|
271
269
|
const resolutions = await Promise.all(
|
|
272
270
|
parsed.program.body.map(async (node) => {
|
|
@@ -355,11 +353,7 @@ export function create(options: create.Options) {
|
|
|
355
353
|
if (!library || library.source !== contracts[file]) {
|
|
356
354
|
library = {
|
|
357
355
|
source: contracts[file]!,
|
|
358
|
-
dependencies:
|
|
359
|
-
contracts[file]!,
|
|
360
|
-
new Map(),
|
|
361
|
-
file,
|
|
362
|
-
).stylesheets.map((section) => section.dependency ?? []),
|
|
356
|
+
dependencies: Results.dependencies(contracts[file]!, file),
|
|
363
357
|
}
|
|
364
358
|
libraries.set(file, library)
|
|
365
359
|
}
|
|
@@ -384,7 +378,6 @@ export function create(options: create.Options) {
|
|
|
384
378
|
for (const file of Object.keys(contracts)) await dependencies(file)
|
|
385
379
|
|
|
386
380
|
const graph = compiler.compile({
|
|
387
|
-
[Syntax.cache]: programs,
|
|
388
381
|
[Stylesheets.entry]: id(context.resourcePath),
|
|
389
382
|
contracts,
|
|
390
383
|
development: options.development,
|
package/src/node/Host.ts
CHANGED
|
@@ -17,7 +17,6 @@ import * as Contracts from './internal/Contracts.js'
|
|
|
17
17
|
import * as Relative from '../compiler/internal/Relative.js'
|
|
18
18
|
import * as Scheme from '../internal/Scheme.js'
|
|
19
19
|
import * as Snapshot from './internal/Snapshot.js'
|
|
20
|
-
import * as Syntax from '../compiler/internal/Syntax.js'
|
|
21
20
|
import * as Source from '../compiler/Source.js'
|
|
22
21
|
import * as Transform from '../compiler/Transform.js'
|
|
23
22
|
import * as ThemeRules from '../web/internal/Themes.js'
|
|
@@ -464,7 +463,6 @@ export async function create(options: create.Options): Promise<Runtime> {
|
|
|
464
463
|
[ClassName.complete]: true,
|
|
465
464
|
[ThemeRules.shared]:
|
|
466
465
|
options.modules === false && !native ? 'all' : undefined,
|
|
467
|
-
[Syntax.cache]: snapshot.programs(modules),
|
|
468
466
|
compiler: options.compiler,
|
|
469
467
|
native,
|
|
470
468
|
modules,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as Crypto from 'node:crypto'
|
|
3
3
|
import * as Path from 'node:path'
|
|
4
4
|
import * as Graph from '../../compiler/Graph.js'
|
|
5
|
-
import * as
|
|
5
|
+
import * as Results from '../../compiler/internal/Results.js'
|
|
6
6
|
import * as Syntax from '../../compiler/internal/Syntax.js'
|
|
7
7
|
|
|
8
8
|
/** Creates a reader whose derived contracts persist across the builds of one adapter instance. */
|
|
@@ -50,7 +50,6 @@ export function create() {
|
|
|
50
50
|
Record<string, string | null>
|
|
51
51
|
> = Object.create(null)
|
|
52
52
|
const modules: Record<string, string> = Object.create(null)
|
|
53
|
-
const programs = new Map<string, ReturnType<typeof Syntax.parse>>()
|
|
54
53
|
const next = new Set(active).add(file)
|
|
55
54
|
let authored = false
|
|
56
55
|
|
|
@@ -67,10 +66,9 @@ export function create() {
|
|
|
67
66
|
if (contract === undefined) return undefined
|
|
68
67
|
|
|
69
68
|
contracts[target] = contract
|
|
70
|
-
for (const
|
|
71
|
-
.stylesheets) {
|
|
69
|
+
for (const dependency of Results.dependencies(contract, target)) {
|
|
72
70
|
let owner = target
|
|
73
|
-
for (const specifier of
|
|
71
|
+
for (const specifier of dependency) {
|
|
74
72
|
const resolved = await options.resolve(specifier, owner)
|
|
75
73
|
if (!resolved)
|
|
76
74
|
throw new Error(
|
|
@@ -191,7 +189,6 @@ export function create() {
|
|
|
191
189
|
|
|
192
190
|
const entry = await parse(path)
|
|
193
191
|
modules[moduleId] = entry.source
|
|
194
|
-
programs.set(moduleId, entry.parsed)
|
|
195
192
|
const links: Record<string, string | null> = Object.create(null)
|
|
196
193
|
imports[moduleId] = links
|
|
197
194
|
|
|
@@ -290,7 +287,6 @@ export function create() {
|
|
|
290
287
|
const graph = (() => {
|
|
291
288
|
try {
|
|
292
289
|
return Graph.compile({
|
|
293
|
-
[Syntax.cache]: programs,
|
|
294
290
|
compiler: false,
|
|
295
291
|
contracts,
|
|
296
292
|
imports,
|
|
@@ -29,14 +29,6 @@ export function create() {
|
|
|
29
29
|
syntax.delete(moduleId)
|
|
30
30
|
},
|
|
31
31
|
parse,
|
|
32
|
-
programs(modules: Readonly<Record<string, string>>) {
|
|
33
|
-
return new Map(
|
|
34
|
-
Object.entries(modules).map(([moduleId, source]) => [
|
|
35
|
-
moduleId,
|
|
36
|
-
parse({ moduleId, source }),
|
|
37
|
-
]),
|
|
38
|
-
)
|
|
39
|
-
},
|
|
40
32
|
async read(file: string) {
|
|
41
33
|
try {
|
|
42
34
|
const stat = await Fs.promises.stat(file, { bigint: true })
|