zyzz 0.0.28 → 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 -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
|
@@ -1,73 +1,38 @@
|
|
|
1
1
|
/** Adapts standard descriptor extensions that precede the pinned parser's grammar. @module */
|
|
2
|
-
import * as ColorProfiles from './ColorProfiles.js'
|
|
3
|
-
import * as Descriptors from './Descriptors.js'
|
|
4
|
-
import * as Functions from './Functions.js'
|
|
5
|
-
import * as Identifiers from './Identifiers.js'
|
|
6
|
-
import * as Keyframes from './Keyframes.js'
|
|
7
2
|
import * as Lightning from 'lightningcss'
|
|
8
|
-
import * as
|
|
9
|
-
import * as ViewTransitions from './ViewTransitions.js'
|
|
3
|
+
import * as Results from './Results.js'
|
|
10
4
|
|
|
11
|
-
/**
|
|
5
|
+
/** A stylesheet whose newer at-keywords travel through the parser under markers. */
|
|
6
|
+
type Transport = {
|
|
7
|
+
readonly code: string
|
|
8
|
+
readonly features: string
|
|
9
|
+
readonly import: string
|
|
10
|
+
readonly palette: string
|
|
11
|
+
readonly property: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Parses structured contributions while retaining newer font descriptors.
|
|
16
|
+
* The engine validates newer at-rules and renames the at-keywords the parser cannot round-trip.
|
|
17
|
+
*/
|
|
12
18
|
export function transform<C extends Lightning.CustomAtRules>(
|
|
13
19
|
options: Lightning.TransformOptions<C>,
|
|
14
20
|
): Lightning.TransformResult {
|
|
15
21
|
// Stylesheets without an @ byte cannot require at-keyword transport.
|
|
16
22
|
if (!options.code.includes(64)) return Lightning.transform(options)
|
|
17
23
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
if (/@function\b/i.test(source)) Functions.validate(source)
|
|
26
|
-
const properties = /@property\b/i.test(source) && Properties.validate(source)
|
|
27
|
-
let propertyMarker = 'zyzz-property'
|
|
28
|
-
while (source.includes(propertyMarker)) propertyMarker += '-x'
|
|
29
|
-
validateFeatures(source)
|
|
30
|
-
// The pinned visitor cannot round-trip the nested Option used for anonymous import layers.
|
|
31
|
-
// Give emitted anonymous layers a temporary name while URL visitors run, then restore them.
|
|
32
|
-
let importMarker = 'zyzz-anonymous-import'
|
|
33
|
-
while (source.includes(importMarker)) importMarker += '-x'
|
|
34
|
-
const imports = options.visitor
|
|
35
|
-
? source.replace(
|
|
36
|
-
/^(\s*@import\s+(?:url\()?"(?:\\.|[^"\\])*"\)?\s+)layer(?=[\s;])/gm,
|
|
37
|
-
`$1layer(${importMarker})`,
|
|
38
|
-
)
|
|
39
|
-
: source
|
|
40
|
-
const lower = source.toLowerCase()
|
|
41
|
-
let marker = '-zyzz-ffv-000000000'
|
|
42
|
-
let suffix = 0
|
|
43
|
-
while (lower.includes(marker))
|
|
44
|
-
marker = `-zyzz-ffv-${(++suffix).toString(36).padStart(9, '0')}`
|
|
45
|
-
let paletteMarker = '-zyzz-fpv-000000000'
|
|
46
|
-
let paletteSuffix = 0
|
|
47
|
-
while (lower.includes(paletteMarker))
|
|
48
|
-
paletteMarker = `-zyzz-fpv-${(++paletteSuffix).toString(36).padStart(9, '0')}`
|
|
49
|
-
// The pinned parser silently drops font-family lists from palette rules.
|
|
50
|
-
const registered = properties
|
|
51
|
-
? rename(imports, 'property', propertyMarker)
|
|
52
|
-
: imports
|
|
53
|
-
const features = lower.includes('@font-feature-values')
|
|
54
|
-
? rename(registered, 'font-feature-values', marker)
|
|
55
|
-
: registered
|
|
56
|
-
const renamed = lower.includes('@font-palette-values')
|
|
57
|
-
? rename(features, 'font-palette-values', paletteMarker)
|
|
58
|
-
: features
|
|
59
|
-
if (lower.includes('@color-profile')) ColorProfiles.validate(renamed)
|
|
60
|
-
if (lower.includes('@keyframes')) Keyframes.validate(renamed)
|
|
61
|
-
if (source.toLowerCase().includes('@view-transition')) {
|
|
62
|
-
let marker = '-zyzz-view-transition'
|
|
63
|
-
while (source.includes(marker)) marker += '-x'
|
|
64
|
-
ViewTransitions.validate(rename(renamed, 'view-transition', marker), marker)
|
|
65
|
-
}
|
|
66
|
-
if (source === renamed) return Lightning.transform(options)
|
|
24
|
+
const transport = Results.call<Transport | null>('css.transport', {
|
|
25
|
+
code: new TextDecoder().decode(options.code),
|
|
26
|
+
visitor: Boolean(options.visitor),
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
if (!transport) return Lightning.transform(options)
|
|
30
|
+
|
|
67
31
|
const result = Lightning.transform({
|
|
68
32
|
...options,
|
|
69
|
-
code: new TextEncoder().encode(
|
|
33
|
+
code: new TextEncoder().encode(transport.code),
|
|
70
34
|
})
|
|
35
|
+
|
|
71
36
|
return {
|
|
72
37
|
...result,
|
|
73
38
|
code: new TextEncoder().encode(
|
|
@@ -76,22 +41,20 @@ export function transform<C extends Lightning.CustomAtRules>(
|
|
|
76
41
|
rename(
|
|
77
42
|
new TextDecoder()
|
|
78
43
|
.decode(result.code)
|
|
79
|
-
.replaceAll(`layer(${
|
|
80
|
-
|
|
44
|
+
.replaceAll(`layer(${transport.import})`, 'layer'),
|
|
45
|
+
transport.property,
|
|
81
46
|
'property',
|
|
82
47
|
),
|
|
83
|
-
|
|
48
|
+
transport.features,
|
|
84
49
|
'font-feature-values',
|
|
85
50
|
),
|
|
86
|
-
|
|
51
|
+
transport.palette,
|
|
87
52
|
'font-palette-values',
|
|
88
53
|
),
|
|
89
54
|
),
|
|
90
55
|
}
|
|
91
56
|
}
|
|
92
57
|
|
|
93
|
-
// Contribution extraction validates feature blocks and their descriptors before this adapter.
|
|
94
|
-
// At-keyword substitution keeps Lightning's token/URL traversal without discarding newer descriptors.
|
|
95
58
|
/** Renames actual at-keywords without touching strings, comments, or function arguments. */
|
|
96
59
|
export function rename(source: string, before: string, after: string): string {
|
|
97
60
|
let output = ''
|
|
@@ -149,54 +112,3 @@ export function relocateImport(
|
|
|
149
112
|
},
|
|
150
113
|
}
|
|
151
114
|
}
|
|
152
|
-
|
|
153
|
-
// Validate the standard rule before shielding the newer font-display descriptor.
|
|
154
|
-
function validateFeatures(source: string): void {
|
|
155
|
-
if (!source.toLowerCase().includes('@font-feature-values')) return
|
|
156
|
-
const masked = source.replace(
|
|
157
|
-
/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\/\*[\s\S]*?\*\//g,
|
|
158
|
-
(value) => ' '.repeat(value.length),
|
|
159
|
-
)
|
|
160
|
-
for (const match of masked.matchAll(/@font-feature-values(?=[\s{])/gi)) {
|
|
161
|
-
const start = match.index
|
|
162
|
-
const open = masked.indexOf('{', start)
|
|
163
|
-
if (open < 0) throw new Error('Invalid font-feature-values block.')
|
|
164
|
-
let depth = 1
|
|
165
|
-
let end = open + 1
|
|
166
|
-
let plain = source.slice(start, open + 1)
|
|
167
|
-
let cursor = open + 1
|
|
168
|
-
for (; end < masked.length && depth; end++) {
|
|
169
|
-
const char = masked[end]
|
|
170
|
-
if (char === '{') depth++
|
|
171
|
-
else if (char === '}') depth--
|
|
172
|
-
else if (depth === 1 && masked.slice(end).match(/^font-display\s*:/i)) {
|
|
173
|
-
const finish = masked.indexOf(';', end)
|
|
174
|
-
const close = masked.indexOf('}', end)
|
|
175
|
-
const boundary = finish >= 0 && finish < close ? finish : close
|
|
176
|
-
if (boundary < 0) throw new Error('Invalid font-display descriptor.')
|
|
177
|
-
const descriptor = source.slice(end, boundary)
|
|
178
|
-
const names = Identifiers.list(
|
|
179
|
-
descriptor.slice(descriptor.indexOf(':') + 1),
|
|
180
|
-
'space',
|
|
181
|
-
)
|
|
182
|
-
if (
|
|
183
|
-
names?.length !== 1 ||
|
|
184
|
-
!['auto', 'block', 'fallback', 'optional', 'swap'].includes(
|
|
185
|
-
names[0]!.replace(/[A-Z]/g, (letter) => letter.toLowerCase()),
|
|
186
|
-
)
|
|
187
|
-
)
|
|
188
|
-
throw new Error('Invalid font-display descriptor.')
|
|
189
|
-
plain += source.slice(cursor, end)
|
|
190
|
-
cursor = boundary + (boundary === finish ? 1 : 0)
|
|
191
|
-
end = cursor - 1
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (depth) throw new Error('Invalid font-feature-values block.')
|
|
195
|
-
plain += source.slice(cursor, end)
|
|
196
|
-
Lightning.transform({
|
|
197
|
-
filename: 'font-feature-values.css',
|
|
198
|
-
code: new TextEncoder().encode(plain),
|
|
199
|
-
errorRecovery: false,
|
|
200
|
-
})
|
|
201
|
-
}
|
|
202
|
-
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marks native compilation inside a host-owned graph context.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Option key of `Native.compile` for an adapter that compiles a module as a member of its own
|
|
8
|
+
* graph. Extraction then validates contributed CSS without relocating relative assets, and it
|
|
9
|
+
* links no other module.
|
|
10
|
+
*/
|
|
11
|
+
export const key = Symbol('zyzz.source.graph')
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs compiler operations in the Rust engine and rebuilds their frozen results and errors.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import type * as Mapping from '@jridgewell/gen-mapping'
|
|
6
|
+
import * as StyleSheet from '../../react-native/StyleSheet.js'
|
|
7
|
+
import * as Variants from '../../react-native/Variants.js'
|
|
8
|
+
import * as Css from '../../web/Css.js'
|
|
9
|
+
import * as ClassName from '../../web/internal/ClassName.js'
|
|
10
|
+
import * as Engine from '../../web/internal/Engine.js'
|
|
11
|
+
import * as ThemeRules from '../../web/internal/Themes.js'
|
|
12
|
+
import * as Wire from '../../web/internal/Wire.js'
|
|
13
|
+
import type * as Graph from '../Graph.js'
|
|
14
|
+
import * as Native from '../Native.js'
|
|
15
|
+
import * as Source from '../Source.js'
|
|
16
|
+
import type * as Transform from '../Transform.js'
|
|
17
|
+
import * as Edits from './Edits.js'
|
|
18
|
+
import * as Stylesheets from './Stylesheets.js'
|
|
19
|
+
|
|
20
|
+
/** A failure as the engine encodes it. */
|
|
21
|
+
type Failure = {
|
|
22
|
+
readonly diagnostics?: readonly unknown[] | undefined
|
|
23
|
+
readonly message: string
|
|
24
|
+
readonly name: string
|
|
25
|
+
readonly source?: string | undefined
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** One module's transform output as the engine encodes it. */
|
|
29
|
+
export type Module = Records & {
|
|
30
|
+
readonly code: string
|
|
31
|
+
readonly css: string
|
|
32
|
+
readonly cssMap: Mapping.EncodedSourceMap
|
|
33
|
+
readonly map: Transform.compile.ReturnType['map']
|
|
34
|
+
readonly shared?: readonly ThemeRules.Resource[] | undefined
|
|
35
|
+
readonly vars: Readonly<Record<string, string>>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** One native graph module as the engine encodes it. */
|
|
39
|
+
type NativeModule = {
|
|
40
|
+
readonly code: string
|
|
41
|
+
readonly edits: readonly Edits.Edit[]
|
|
42
|
+
readonly map: Mapping.EncodedSourceMap
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A `native.compile` result as the engine encodes it. */
|
|
46
|
+
export type NativeOutput = {
|
|
47
|
+
readonly code: string
|
|
48
|
+
readonly edits: readonly Edits.Edit[]
|
|
49
|
+
readonly map: string
|
|
50
|
+
readonly recipes: Readonly<Record<string, unknown>>
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** A module's class, rule, and unit records as the engine encodes them. */
|
|
54
|
+
type Records = {
|
|
55
|
+
readonly classes: Readonly<Record<string, string>>
|
|
56
|
+
readonly rules: Readonly<Record<string, string>>
|
|
57
|
+
readonly units: readonly (readonly [string, boolean, string])[]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** One rendered stylesheet as the engine encodes it. */
|
|
61
|
+
type Rendered = {
|
|
62
|
+
readonly assets: Readonly<Record<string, string>>
|
|
63
|
+
readonly css: string
|
|
64
|
+
readonly id?: string | undefined
|
|
65
|
+
readonly map: Mapping.EncodedSourceMap
|
|
66
|
+
readonly owners: Readonly<Record<string, string>>
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A graph result as the engine encodes it. Modules whose output the host last decoded are `0`,
|
|
71
|
+
* and `prune` drops every other decoded module.
|
|
72
|
+
*/
|
|
73
|
+
export type Output = {
|
|
74
|
+
readonly contracts: Readonly<Record<string, string>>
|
|
75
|
+
readonly dependencies: Readonly<Record<string, readonly string[]>>
|
|
76
|
+
readonly modules: Readonly<Record<string, Module | NativeModule | 0>>
|
|
77
|
+
readonly packed?: readonly Rendered[] | undefined
|
|
78
|
+
readonly prune?: true | undefined
|
|
79
|
+
readonly reset?: Rendered | undefined
|
|
80
|
+
readonly same?: true | undefined
|
|
81
|
+
readonly shared?: Rendered | undefined
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Runs an engine operation on JSON input.
|
|
86
|
+
* @param operation - Operation name, such as `graph.compile`.
|
|
87
|
+
* @param input - Input data, serialized as JSON.
|
|
88
|
+
* @returns The parsed result.
|
|
89
|
+
* @throws {Source.ExtractError} For source the compiler does not support.
|
|
90
|
+
* @throws {Css.CompileError} For CSS emission failures.
|
|
91
|
+
* @throws {Native.CompileError} For native features outside the static boundary.
|
|
92
|
+
*/
|
|
93
|
+
export function call<result>(operation: string, input: unknown): result {
|
|
94
|
+
return decode(Engine.call(operation, JSON.stringify(input)))
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Runs `transform.compile`. JSON text never holds a raw NUL, so a string source follows one and
|
|
99
|
+
* crosses without escaping. The engine writes the module's records after one, and they decode
|
|
100
|
+
* when first read.
|
|
101
|
+
* @param input - Options, with the source when it is not a string.
|
|
102
|
+
* @param source - Module text.
|
|
103
|
+
* @returns The output `Transform.compile` returns.
|
|
104
|
+
* @throws {Source.ExtractError} For source the compiler does not support.
|
|
105
|
+
* @throws {Css.CompileError} For CSS emission failures.
|
|
106
|
+
*/
|
|
107
|
+
export function transform(
|
|
108
|
+
input: unknown,
|
|
109
|
+
source?: string | undefined,
|
|
110
|
+
): Transform.compile.ReturnType {
|
|
111
|
+
const json = JSON.stringify(input)
|
|
112
|
+
const text = Engine.call(
|
|
113
|
+
'transform.compile',
|
|
114
|
+
source === undefined ? json : `${json}\0${source}`,
|
|
115
|
+
)
|
|
116
|
+
const split = text.indexOf('\0')
|
|
117
|
+
|
|
118
|
+
// Failures write no records, and decoding throws them.
|
|
119
|
+
if (split === -1) return module(decode<Module>(text), source)
|
|
120
|
+
|
|
121
|
+
return module(
|
|
122
|
+
decode<Omit<Module, keyof Records>>(text.slice(0, split)),
|
|
123
|
+
source,
|
|
124
|
+
text.slice(split + 1),
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Parses an engine result, throwing the failure it encodes.
|
|
130
|
+
* @param json - The engine's JSON result.
|
|
131
|
+
* @returns The parsed result.
|
|
132
|
+
* @throws {Source.ExtractError} For source the compiler does not support.
|
|
133
|
+
* @throws {Css.CompileError} For CSS emission failures.
|
|
134
|
+
* @throws {Native.CompileError} For native features outside the static boundary.
|
|
135
|
+
*/
|
|
136
|
+
export function decode<result>(json: string): result {
|
|
137
|
+
const output = JSON.parse(json) as {
|
|
138
|
+
readonly error?: Failure | undefined
|
|
139
|
+
} | null
|
|
140
|
+
|
|
141
|
+
if (output?.error) throw failure(output.error)
|
|
142
|
+
|
|
143
|
+
return output as result
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Lists each packed stylesheet section's import chain of a library contract, which hosts
|
|
148
|
+
* resolve before compiling the graph.
|
|
149
|
+
* @param contract - Serialized library contract.
|
|
150
|
+
* @param moduleId - Host-resolved identity of the contract's module.
|
|
151
|
+
* @returns One specifier chain per stylesheet section, in section order.
|
|
152
|
+
* @throws {SyntaxError} For malformed contract JSON.
|
|
153
|
+
* @throws {Error} For unsupported or invalid contract metadata.
|
|
154
|
+
*/
|
|
155
|
+
export function dependencies(
|
|
156
|
+
contract: string,
|
|
157
|
+
moduleId: string,
|
|
158
|
+
): readonly (readonly string[])[] {
|
|
159
|
+
return call<{ readonly dependencies: readonly (readonly string[])[] }>(
|
|
160
|
+
'contract.dependencies',
|
|
161
|
+
{ contract, moduleId },
|
|
162
|
+
).dependencies
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function failure(error: Failure): Error {
|
|
166
|
+
if (error.name === 'Source.ExtractError')
|
|
167
|
+
return new Source.ExtractError(
|
|
168
|
+
error.diagnostics as readonly Source.Diagnostic[],
|
|
169
|
+
)
|
|
170
|
+
if (error.name === 'Css.CompileError')
|
|
171
|
+
return new Css.CompileError(error.diagnostics as readonly Css.Diagnostic[])
|
|
172
|
+
if (error.name === 'Native.CompileError')
|
|
173
|
+
return new Native.CompileError(error.message)
|
|
174
|
+
if (error.name === 'StyleSheet.CompileError')
|
|
175
|
+
return new StyleSheet.CompileError(
|
|
176
|
+
error.diagnostics as readonly StyleSheet.Diagnostic[],
|
|
177
|
+
)
|
|
178
|
+
if (error.name === 'StyleSheet.SelectionError')
|
|
179
|
+
return new StyleSheet.SelectionError(error.message)
|
|
180
|
+
if (error.name === 'Stylesheets.ConflictError')
|
|
181
|
+
return new Stylesheets.ConflictError(error.source ?? '', error.message)
|
|
182
|
+
if (error.name === 'Variants.CompileError')
|
|
183
|
+
return new Variants.CompileError(error.message)
|
|
184
|
+
if (error.name === 'SyntaxError') return new SyntaxError(error.message)
|
|
185
|
+
|
|
186
|
+
return new Error(error.message)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Deeply freezes decoded JSON data, giving its objects null prototypes as compiled tables have.
|
|
191
|
+
* @param value - Data parsed from engine JSON.
|
|
192
|
+
* @returns The same data, frozen.
|
|
193
|
+
*/
|
|
194
|
+
export function frozen(value: unknown): unknown {
|
|
195
|
+
if (Array.isArray(value)) return Object.freeze(value.map(frozen))
|
|
196
|
+
if (value === null || typeof value !== 'object') return value
|
|
197
|
+
|
|
198
|
+
return Object.freeze(
|
|
199
|
+
Object.assign(
|
|
200
|
+
Object.create(null),
|
|
201
|
+
Object.fromEntries(
|
|
202
|
+
Object.entries(value).map(([key, entry]) => [key, frozen(entry)]),
|
|
203
|
+
),
|
|
204
|
+
),
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Rebuilds a frozen graph result, keeping the decoded module objects the engine reports
|
|
210
|
+
* unchanged.
|
|
211
|
+
* @param value - The encoded graph result.
|
|
212
|
+
* @param previous - The result of the same compiler's previous call.
|
|
213
|
+
* @param decoded - The same compiler's last decoded module per identity, updated in place.
|
|
214
|
+
* @returns The output `Graph.compile` returns.
|
|
215
|
+
*/
|
|
216
|
+
export function graph(
|
|
217
|
+
value: Output,
|
|
218
|
+
previous?: Graph.compile.ReturnType | undefined,
|
|
219
|
+
decoded?: Map<string, Transform.compile.ReturnType> | undefined,
|
|
220
|
+
): Graph.compile.ReturnType {
|
|
221
|
+
if (value.same && previous) return previous
|
|
222
|
+
|
|
223
|
+
const modules = Object.fromEntries(
|
|
224
|
+
Object.entries(value.modules).map(([id, encoded]) => [
|
|
225
|
+
id,
|
|
226
|
+
(() => {
|
|
227
|
+
if (encoded === 0) return decoded!.get(id)!
|
|
228
|
+
if ('edits' in encoded) return nativeModule(encoded)
|
|
229
|
+
|
|
230
|
+
return module(encoded)
|
|
231
|
+
})(),
|
|
232
|
+
]),
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
if (decoded) {
|
|
236
|
+
for (const [id, output] of Object.entries(modules)) decoded.set(id, output)
|
|
237
|
+
if (value.prune)
|
|
238
|
+
for (const id of decoded.keys())
|
|
239
|
+
if (!Object.hasOwn(modules, id)) decoded.delete(id)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return Object.freeze({
|
|
243
|
+
...(value.reset
|
|
244
|
+
? { [Stylesheets.reset]: rendered(value.reset) as Stylesheets.Resource }
|
|
245
|
+
: {}),
|
|
246
|
+
...(value.packed
|
|
247
|
+
? {
|
|
248
|
+
[Stylesheets.packed]: Object.freeze(
|
|
249
|
+
value.packed.map((resource) => rendered(resource)),
|
|
250
|
+
) as readonly Stylesheets.Resource[],
|
|
251
|
+
}
|
|
252
|
+
: {}),
|
|
253
|
+
...(value.shared
|
|
254
|
+
? {
|
|
255
|
+
sharedCss: value.shared.css,
|
|
256
|
+
sharedCssMap: value.shared.map,
|
|
257
|
+
sharedAssets: Object.freeze(
|
|
258
|
+
Object.assign(Object.create(null), value.shared.assets),
|
|
259
|
+
),
|
|
260
|
+
sharedAssetOwners: Object.freeze(
|
|
261
|
+
Object.assign(Object.create(null), value.shared.owners),
|
|
262
|
+
),
|
|
263
|
+
}
|
|
264
|
+
: {}),
|
|
265
|
+
contracts: Object.freeze({ ...value.contracts }),
|
|
266
|
+
dependencies: Object.freeze(
|
|
267
|
+
Object.assign(
|
|
268
|
+
Object.create(null),
|
|
269
|
+
Object.fromEntries(
|
|
270
|
+
Object.entries(value.dependencies).map(([id, targets]) => [
|
|
271
|
+
id,
|
|
272
|
+
Object.freeze([...targets]),
|
|
273
|
+
]),
|
|
274
|
+
),
|
|
275
|
+
),
|
|
276
|
+
),
|
|
277
|
+
modules: Object.freeze(modules),
|
|
278
|
+
}) as Graph.compile.ReturnType
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** Graph option for hosts that read module code, stylesheets, and configuration catalogs only. */
|
|
282
|
+
export const lean = Symbol('lean graph output')
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Rebuilds one module's frozen transform output. Records decode when first read, so a module
|
|
286
|
+
* whose classes, rules, and units are never read skips their parsing.
|
|
287
|
+
* @param value - The encoded module, with its records unless `records` holds them.
|
|
288
|
+
* @param source - Module text the engine left out of the maps' `sourcesContent`.
|
|
289
|
+
* @param records - The encoded records, which `transform.compile` writes apart.
|
|
290
|
+
* @returns The output `Transform.compile` returns.
|
|
291
|
+
*/
|
|
292
|
+
export function module(
|
|
293
|
+
value: Omit<Module, keyof Records> & Partial<Records>,
|
|
294
|
+
source?: string | undefined,
|
|
295
|
+
records?: string | undefined,
|
|
296
|
+
): Transform.compile.ReturnType {
|
|
297
|
+
// The engine writes `0` for content the caller supplied separately, so it crosses once.
|
|
298
|
+
if (source !== undefined)
|
|
299
|
+
for (const map of [value.cssMap, value.map]) {
|
|
300
|
+
const contents = map.sourcesContent as (string | null | 0)[] | undefined
|
|
301
|
+
|
|
302
|
+
for (let index = 0; index < (contents?.length ?? 0); index++)
|
|
303
|
+
if (contents![index] === 0) contents![index] = source
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
let decoded: Records | undefined =
|
|
307
|
+
records === undefined ? (value as Records) : undefined
|
|
308
|
+
let classes: Transform.compile.ReturnType['classes'] | undefined
|
|
309
|
+
let rules: Transform.compile.ReturnType[typeof ClassName.rules] | undefined
|
|
310
|
+
let units: Transform.compile.ReturnType[typeof ClassName.units] | undefined
|
|
311
|
+
const read = () => (decoded ??= JSON.parse(records!) as Records)
|
|
312
|
+
|
|
313
|
+
const result = {
|
|
314
|
+
...(value.shared
|
|
315
|
+
? {
|
|
316
|
+
[ThemeRules.shared]: Object.freeze(
|
|
317
|
+
value.shared.map((resource) => Object.freeze(resource)),
|
|
318
|
+
),
|
|
319
|
+
}
|
|
320
|
+
: {}),
|
|
321
|
+
// Parsed records are fresh, so they freeze in place rather than as copies.
|
|
322
|
+
get classes() {
|
|
323
|
+
return (classes ??= Object.freeze(read().classes))
|
|
324
|
+
},
|
|
325
|
+
code: value.code,
|
|
326
|
+
css: value.css,
|
|
327
|
+
cssMap: value.cssMap,
|
|
328
|
+
map: value.map,
|
|
329
|
+
vars: Object.freeze(Object.setPrototypeOf(value.vars, null)),
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
Object.defineProperties(result, {
|
|
333
|
+
[ClassName.rules]: {
|
|
334
|
+
enumerable: false,
|
|
335
|
+
get: () => (rules ??= Object.freeze(read().rules)),
|
|
336
|
+
},
|
|
337
|
+
[ClassName.units]: {
|
|
338
|
+
enumerable: false,
|
|
339
|
+
get: () =>
|
|
340
|
+
(units ??= new Map(
|
|
341
|
+
read().units.map(([key, borrowed, name]) => [
|
|
342
|
+
key,
|
|
343
|
+
{ borrowed, name },
|
|
344
|
+
]),
|
|
345
|
+
)),
|
|
346
|
+
},
|
|
347
|
+
})
|
|
348
|
+
|
|
349
|
+
return Object.freeze(result) as Transform.compile.ReturnType
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Encodes native options as the engine reads them. Sets are written in the `Css.compile` wire
|
|
354
|
+
* format, so the engine decodes them as it decodes literal definitions.
|
|
355
|
+
* @param options - Native options of `Native.compile` or a native graph.
|
|
356
|
+
* @returns The engine's native input.
|
|
357
|
+
*/
|
|
358
|
+
export function native(
|
|
359
|
+
options: Omit<Native.compile.Options, 'moduleId' | 'source'>,
|
|
360
|
+
) {
|
|
361
|
+
return {
|
|
362
|
+
colorScheme: options.colorScheme,
|
|
363
|
+
contextual: options.contextual,
|
|
364
|
+
fonts: options.fonts,
|
|
365
|
+
platform: options.platform,
|
|
366
|
+
runtime: options[Edits.runtime],
|
|
367
|
+
set: options.set,
|
|
368
|
+
units: options.units,
|
|
369
|
+
vars:
|
|
370
|
+
options.vars === undefined
|
|
371
|
+
? undefined
|
|
372
|
+
: Wire.encode({
|
|
373
|
+
styles: { styles: [] },
|
|
374
|
+
vars: options.vars,
|
|
375
|
+
} as unknown as Css.compile.Options),
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// A graph's native module carries the web output shape with empty CSS.
|
|
380
|
+
function nativeModule(value: NativeModule): Transform.compile.ReturnType {
|
|
381
|
+
return Object.freeze({
|
|
382
|
+
[ClassName.rules]: Object.freeze({}),
|
|
383
|
+
classes: Object.freeze({}),
|
|
384
|
+
[Edits.key]: value.edits,
|
|
385
|
+
code: value.code,
|
|
386
|
+
css: '',
|
|
387
|
+
cssMap: {
|
|
388
|
+
version: 3 as const,
|
|
389
|
+
names: [],
|
|
390
|
+
sources: [],
|
|
391
|
+
mappings: '',
|
|
392
|
+
},
|
|
393
|
+
map: value.map,
|
|
394
|
+
vars: Object.freeze({}),
|
|
395
|
+
}) as Transform.compile.ReturnType
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function rendered(value: Rendered) {
|
|
399
|
+
return Object.freeze({
|
|
400
|
+
...(value.id === undefined ? {} : { id: value.id }),
|
|
401
|
+
css: value.css,
|
|
402
|
+
map: value.map,
|
|
403
|
+
assets: Object.freeze(Object.assign(Object.create(null), value.assets)),
|
|
404
|
+
owners: Object.freeze(Object.assign(Object.create(null), value.owners)),
|
|
405
|
+
})
|
|
406
|
+
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/** Parses authoring modules while retaining TypeScript assertion syntax. @module */
|
|
2
2
|
import * as Parser from 'oxc-parser'
|
|
3
3
|
|
|
4
|
-
/** Parsed modules supplied by the host for a single compilation. */
|
|
5
|
-
export const cache = Symbol('parsed modules')
|
|
6
|
-
|
|
7
4
|
/** Preserves JSX authoring and retries TypeScript files with assertion-aware grammar. */
|
|
8
5
|
export function parse(options: parse.Options) {
|
|
9
6
|
const settings = {
|