zyzz 0.0.28 → 0.0.30
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 -1267
- 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 -961
- 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/Literal.d.ts +4 -1
- package/dist/internal/Literal.d.ts.map +1 -1
- package/dist/internal/Literal.js +4 -2
- package/dist/internal/Literal.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/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.map +1 -1
- package/dist/vite/index.js +696 -201
- 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 -1803
- package/src/compiler/Transform.ts +16 -1315
- 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/Literal.ts +4 -2
- 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/unplugin/index.ts +6 -6
- package/src/vite/index.ts +922 -221
- 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 -393
- 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 -13
- package/dist/compiler/internal/Selectors.d.ts.map +0 -1
- package/dist/compiler/internal/Selectors.js +0 -280
- 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 -610
- 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 -353
- 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
|
+
}
|
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',
|
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 })
|
|
@@ -29,39 +29,62 @@ export function create(options: create.Options) {
|
|
|
29
29
|
...input,
|
|
30
30
|
classes: new Set(input.className.split(/\s+/).filter(Boolean)),
|
|
31
31
|
}))
|
|
32
|
+
// Only conditional arguments select a precompiled case.
|
|
33
|
+
const conditional = inputs.some((input) => input.condition !== undefined)
|
|
32
34
|
|
|
33
35
|
return (...entries: readonly Entry[]) => {
|
|
34
36
|
let mask = 0
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
if (conditional)
|
|
38
|
+
for (let index = 0; index < inputs.length; index++) {
|
|
39
|
+
const condition = inputs[index]!.condition
|
|
40
|
+
if (condition !== undefined && entries[index]) mask |= 1 << condition
|
|
41
|
+
}
|
|
38
42
|
const className = options.cases?.[mask] ?? options.className
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
// Mutable while entries merge, then returned as immutable props.
|
|
44
|
+
const result: {
|
|
45
|
+
className: string
|
|
46
|
+
style?: Record<string, string | number | undefined>
|
|
47
|
+
} & Record<string, unknown> = { className }
|
|
48
|
+
let attributes = false
|
|
49
|
+
let external: string[] | undefined
|
|
50
|
+
let style: Record<string, string | number | undefined> | undefined
|
|
51
|
+
for (let index = 0; index < entries.length; index++) {
|
|
52
|
+
const entry = entries[index]
|
|
45
53
|
if (!entry) continue
|
|
46
54
|
const input = inputs[index]!
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
for (const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
// Owners replace only what earlier entries added, so the first contributions skip deletion.
|
|
56
|
+
if (attributes || style)
|
|
57
|
+
for (const owner of input.owners) {
|
|
58
|
+
if (attributes)
|
|
59
|
+
for (const attribute of owner.attributes) delete result[attribute]
|
|
60
|
+
if (style) for (const slot of owner.slots) delete style[slot]
|
|
61
|
+
}
|
|
62
|
+
// An application's own class list adds nothing beyond the composition class.
|
|
63
|
+
if (entry.className !== input.className)
|
|
64
|
+
for (const name of entry.className.split(/\s+/))
|
|
65
|
+
if (name && !input.classes.has(name)) (external ??= []).push(name)
|
|
66
|
+
for (const name in entry)
|
|
67
|
+
if (name.startsWith('data-') && Object.hasOwn(entry, name)) {
|
|
68
|
+
result[name] = entry[name as `data-${string}`]
|
|
69
|
+
attributes = true
|
|
70
|
+
}
|
|
71
|
+
const inline = entry.style
|
|
72
|
+
if (inline) {
|
|
73
|
+
style ??= {}
|
|
74
|
+
for (const name in inline) {
|
|
75
|
+
if (!Object.hasOwn(inline, name)) continue
|
|
76
|
+
// Reinsert overwritten keys so inline shorthand/longhand ordering follows arguments.
|
|
77
|
+
delete style[name]
|
|
78
|
+
style[name] = inline[name as keyof typeof inline]
|
|
79
|
+
}
|
|
59
80
|
}
|
|
60
81
|
}
|
|
61
|
-
|
|
62
|
-
...
|
|
63
|
-
|
|
64
|
-
|
|
82
|
+
result.className = external
|
|
83
|
+
? [className, ...external].filter(Boolean).join(' ')
|
|
84
|
+
: className || ''
|
|
85
|
+
if (style && Object.keys(style).length) result.style = style
|
|
86
|
+
return result as style.Props & {
|
|
87
|
+
readonly [name: `data-${string}`]: string | undefined
|
|
65
88
|
}
|
|
66
89
|
}
|
|
67
90
|
}
|
package/src/runtime/Recipe.ts
CHANGED
|
@@ -37,25 +37,32 @@ export type Payload = {
|
|
|
37
37
|
*/
|
|
38
38
|
export function create(options: create.Options) {
|
|
39
39
|
const props = Props.create({ className: options.className })
|
|
40
|
-
|
|
40
|
+
// Attribute names and defaults are fixed, so calls only read the selection.
|
|
41
|
+
const axes = Object.keys(options.axes).map((axis) => ({
|
|
42
|
+
attribute: `data-${axis}` as const,
|
|
43
|
+
axis,
|
|
44
|
+
fallback: Object.hasOwn(options.defaults, axis)
|
|
45
|
+
? options.defaults[axis]
|
|
46
|
+
: undefined,
|
|
47
|
+
}))
|
|
41
48
|
|
|
42
49
|
return (input: Record<string, unknown> & style.Options = {}) => {
|
|
43
50
|
const overrides: style.Options = input
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
// Props are fresh on every call, so selection attributes extend them in place.
|
|
52
|
+
const result = props(overrides) as style.Props &
|
|
53
|
+
Record<`data-${string}`, string>
|
|
47
54
|
|
|
48
|
-
for (const
|
|
49
|
-
const selected = Object.hasOwn(input, axis)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
for (const entry of axes) {
|
|
56
|
+
const selected = Object.hasOwn(input, entry.axis)
|
|
57
|
+
? input[entry.axis]
|
|
58
|
+
: undefined
|
|
59
|
+
const value = (selected === undefined ? entry.fallback : selected) as
|
|
60
|
+
| string
|
|
61
|
+
| boolean
|
|
62
|
+
| null
|
|
63
|
+
| undefined
|
|
57
64
|
if (value !== null && value !== undefined)
|
|
58
|
-
result[
|
|
65
|
+
result[entry.attribute] = String(value)
|
|
59
66
|
}
|
|
60
67
|
|
|
61
68
|
return options.html ? Html.from(result) : result
|
package/src/unplugin/index.ts
CHANGED
|
@@ -5,15 +5,14 @@ import * as Fs from 'node:fs/promises'
|
|
|
5
5
|
import * as Path from 'node:path'
|
|
6
6
|
import * as Reset from '../node/Reset.js'
|
|
7
7
|
import * as Snapshot from '../node/internal/Snapshot.js'
|
|
8
|
-
import * as Syntax from '../compiler/internal/Syntax.js'
|
|
9
8
|
import { createUnplugin } from 'unplugin'
|
|
10
9
|
import type { UnpluginBuildContext } from 'unplugin'
|
|
11
10
|
import * as Graph from '../compiler/Graph.js'
|
|
12
11
|
import * as AtRules from '../compiler/internal/AtRules.js'
|
|
13
12
|
import * as Catalogs from '../compiler/internal/Catalogs.js'
|
|
14
13
|
import * as ClassName from '../web/internal/ClassName.js'
|
|
15
|
-
import * as Contract from '../compiler/internal/Contract.js'
|
|
16
14
|
import * as Contracts from '../node/internal/Contracts.js'
|
|
15
|
+
import * as Results from '../compiler/internal/Results.js'
|
|
17
16
|
import * as Vite from '../vite/index.js'
|
|
18
17
|
import * as ThemeRules from '../web/internal/Themes.js'
|
|
19
18
|
|
|
@@ -218,10 +217,12 @@ const portable = createUnplugin<Options | undefined, false>(
|
|
|
218
217
|
})
|
|
219
218
|
if (source === undefined) return false
|
|
220
219
|
contracts[file] = source
|
|
221
|
-
const
|
|
222
|
-
|
|
220
|
+
for (const dependency of Results.dependencies(
|
|
221
|
+
contracts[file]!,
|
|
222
|
+
file,
|
|
223
|
+
)) {
|
|
223
224
|
let owner = file
|
|
224
|
-
for (const specifier of
|
|
225
|
+
for (const specifier of dependency) {
|
|
225
226
|
const target = await resolve(specifier, owner)
|
|
226
227
|
if (!target)
|
|
227
228
|
throw new Error(
|
|
@@ -289,7 +290,6 @@ const portable = createUnplugin<Options | undefined, false>(
|
|
|
289
290
|
const result = compiler.compile({
|
|
290
291
|
[ClassName.complete]: true,
|
|
291
292
|
[ThemeRules.shared]: 'all',
|
|
292
|
-
[Syntax.cache]: snapshot.programs(modules),
|
|
293
293
|
compiler: options.compiler,
|
|
294
294
|
reset: options.reset ? Reset.read() : undefined,
|
|
295
295
|
contracts,
|