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
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
import * as ConditionalRecipe from '../../runtime/ConditionalRecipe.js';
|
|
2
|
-
import * as Expression from './Expression.js';
|
|
3
|
-
import * as RecipeConditions from './RecipeConditions.js';
|
|
4
|
-
import * as RecipePayloads from './RecipePayloads.js';
|
|
5
|
-
import * as Themes from './Themes.js';
|
|
6
|
-
function object(node) {
|
|
7
|
-
if (node.type !== 'ObjectExpression')
|
|
8
|
-
throw new Themes.InvalidError('Recipes require static object bodies.', node);
|
|
9
|
-
}
|
|
10
|
-
function entries(node) {
|
|
11
|
-
if (node.type !== 'ObjectExpression')
|
|
12
|
-
throw new Themes.InvalidError('Recipes require static object bodies.', node);
|
|
13
|
-
const seen = new Set();
|
|
14
|
-
return node.properties.map((property) => {
|
|
15
|
-
if (property.type !== 'Property' ||
|
|
16
|
-
property.computed ||
|
|
17
|
-
property.method ||
|
|
18
|
-
property.shorthand ||
|
|
19
|
-
property.kind !== 'init')
|
|
20
|
-
throw new Themes.InvalidError('Recipe structure requires explicit static keys.', property);
|
|
21
|
-
const key = property.key.type === 'Identifier'
|
|
22
|
-
? property.key.name
|
|
23
|
-
: property.key.type === 'Literal'
|
|
24
|
-
? String(property.key.value)
|
|
25
|
-
: undefined;
|
|
26
|
-
if (key === undefined || seen.has(key))
|
|
27
|
-
throw new Themes.InvalidError('Recipe keys must be unique.', property);
|
|
28
|
-
seen.add(key);
|
|
29
|
-
return [key, property];
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
function choice(node, choices) {
|
|
33
|
-
if (node.type !== 'Literal' ||
|
|
34
|
-
!(node.value === null ||
|
|
35
|
-
typeof node.value === 'string' ||
|
|
36
|
-
typeof node.value === 'boolean'))
|
|
37
|
-
throw new Themes.InvalidError('Selections require literal choice names, booleans, or null.', node);
|
|
38
|
-
if (node.value === null)
|
|
39
|
-
return null;
|
|
40
|
-
const value = String(node.value);
|
|
41
|
-
if (!choices.includes(value))
|
|
42
|
-
throw new Themes.InvalidError('Unknown recipe choice.', node);
|
|
43
|
-
return value;
|
|
44
|
-
}
|
|
45
|
-
function predicate(attribute, value) {
|
|
46
|
-
const quoted = '"' +
|
|
47
|
-
value.replace(
|
|
48
|
-
// oxlint-disable-next-line no-control-regex -- CSS strings require hexadecimal escapes for control characters.
|
|
49
|
-
/[\x00-\x1f\x7f"\\]/g, (character) => `\\${character.codePointAt(0).toString(16)} `) +
|
|
50
|
-
'"';
|
|
51
|
-
return `[${attribute}=${quoted}]`;
|
|
52
|
-
}
|
|
53
|
-
/** Expands every finite alternative while retaining authored style-node locations. */
|
|
54
|
-
export function expand(node, options) {
|
|
55
|
-
const bindings = RecipePayloads.create(options);
|
|
56
|
-
const payloads = [];
|
|
57
|
-
const defaultsValidators = new Map();
|
|
58
|
-
const types = Object.create(null);
|
|
59
|
-
const defaultPayloads = Object.create(null);
|
|
60
|
-
const properties = [];
|
|
61
|
-
const fields = new Map(entries(node));
|
|
62
|
-
const axes = Object.create(null);
|
|
63
|
-
const defaults = Object.create(null);
|
|
64
|
-
for (const [key, property] of fields)
|
|
65
|
-
if (![
|
|
66
|
-
'base',
|
|
67
|
-
'variants',
|
|
68
|
-
'defaultVariants',
|
|
69
|
-
'compoundVariants',
|
|
70
|
-
'conditions',
|
|
71
|
-
].includes(key))
|
|
72
|
-
throw new Themes.InvalidError(`Unknown recipe field: ${key}.`, property);
|
|
73
|
-
const conditions = fields.get('conditions');
|
|
74
|
-
const named = (conditions ? entries(conditions.value) : []).map(([name, property]) => RecipeConditions.read({
|
|
75
|
-
name,
|
|
76
|
-
node: property.value,
|
|
77
|
-
queries: options.queries,
|
|
78
|
-
}));
|
|
79
|
-
const regions = RecipeConditions.regions(named);
|
|
80
|
-
const base = fields.get('base');
|
|
81
|
-
if (base) {
|
|
82
|
-
object(base.value);
|
|
83
|
-
if (named.length ||
|
|
84
|
-
base.value.properties.some((property) => property.type === 'Property' &&
|
|
85
|
-
!property.computed &&
|
|
86
|
-
(property.key.type === 'Identifier'
|
|
87
|
-
? property.key.name === 'targets'
|
|
88
|
-
: property.key.type === 'Literal' &&
|
|
89
|
-
property.key.value === 'targets')))
|
|
90
|
-
properties.push(group(base.value, '&', base.value));
|
|
91
|
-
else
|
|
92
|
-
properties.push(...base.value.properties);
|
|
93
|
-
}
|
|
94
|
-
function group(node, key, value) {
|
|
95
|
-
return {
|
|
96
|
-
type: 'Property',
|
|
97
|
-
kind: 'init',
|
|
98
|
-
method: false,
|
|
99
|
-
shorthand: false,
|
|
100
|
-
start: node.start,
|
|
101
|
-
end: node.end,
|
|
102
|
-
computed: false,
|
|
103
|
-
key: {
|
|
104
|
-
type: 'Literal',
|
|
105
|
-
value: key,
|
|
106
|
-
raw: JSON.stringify(key),
|
|
107
|
-
start: node.start,
|
|
108
|
-
end: node.end,
|
|
109
|
-
},
|
|
110
|
-
value,
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
const rules = [];
|
|
114
|
-
const variants = fields.get('variants');
|
|
115
|
-
for (const [axis, property] of variants ? entries(variants.value) : []) {
|
|
116
|
-
if (!/^[a-z][a-z0-9-]*$/.test(axis) ||
|
|
117
|
-
axis.startsWith('zyzz-condition-') ||
|
|
118
|
-
[
|
|
119
|
-
'class',
|
|
120
|
-
'className',
|
|
121
|
-
'conditions',
|
|
122
|
-
'key',
|
|
123
|
-
'ref',
|
|
124
|
-
'style',
|
|
125
|
-
'vars',
|
|
126
|
-
].includes(axis))
|
|
127
|
-
throw new Themes.InvalidError('Recipe axes require lowercase data-attribute names and cannot use reserved props.', property);
|
|
128
|
-
const choices = entries(property.value);
|
|
129
|
-
if (!choices.length)
|
|
130
|
-
throw new Themes.InvalidError('Recipe axes require at least one choice.', property);
|
|
131
|
-
for (const [key, property] of choices)
|
|
132
|
-
if ((property.key.type === 'Literal' &&
|
|
133
|
-
typeof property.key.value === 'number') ||
|
|
134
|
-
key.includes('\0') ||
|
|
135
|
-
/[\ud800-\udfff]/u.test(key))
|
|
136
|
-
throw new Themes.InvalidError('Recipe choice names require CSS-safe strings.', property);
|
|
137
|
-
axes[axis] = choices.map(([key]) => key);
|
|
138
|
-
for (const [key, style] of choices) {
|
|
139
|
-
if (key === '__proto__' &&
|
|
140
|
-
(style.value.type === 'ArrowFunctionExpression' ||
|
|
141
|
-
style.value.type === 'FunctionExpression'))
|
|
142
|
-
throw new Themes.InvalidError('Dynamic choice names cannot use __proto__.', style);
|
|
143
|
-
const models = Array.from({ length: named.length + 1 }, (_, context) => bindings.read(style.value, `${options.identity}-${Object.keys(axes).length}-${choices.findIndex(([name]) => name === key)}-${context}`));
|
|
144
|
-
const first = models[0];
|
|
145
|
-
if (first) {
|
|
146
|
-
types[axis] ??= Object.create(null);
|
|
147
|
-
types[axis][key] = options.source.slice(first.type.start, first.type.end);
|
|
148
|
-
const payload = {
|
|
149
|
-
axis,
|
|
150
|
-
choice: key,
|
|
151
|
-
slots: models.map((model) => Object.fromEntries(Object.entries(model.slots).map(([field, slot]) => [
|
|
152
|
-
field,
|
|
153
|
-
slot.name,
|
|
154
|
-
]))),
|
|
155
|
-
};
|
|
156
|
-
payloads.push(payload);
|
|
157
|
-
defaultsValidators.set(payload, first);
|
|
158
|
-
}
|
|
159
|
-
rules.push({
|
|
160
|
-
matches: [[axis, [key]]],
|
|
161
|
-
property: style,
|
|
162
|
-
suffix: '',
|
|
163
|
-
...(first ? { bodies: models.map((model) => model.body) } : {}),
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
const defaultVariants = fields.get('defaultVariants');
|
|
168
|
-
for (const [axis, property] of defaultVariants
|
|
169
|
-
? entries(defaultVariants.value)
|
|
170
|
-
: []) {
|
|
171
|
-
if (!Object.hasOwn(axes, axis))
|
|
172
|
-
throw new Themes.InvalidError('Unknown default variant axis.', property);
|
|
173
|
-
if (property.value.type === 'Identifier' &&
|
|
174
|
-
property.value.name === 'undefined')
|
|
175
|
-
continue;
|
|
176
|
-
if (property.value.type === 'ObjectExpression') {
|
|
177
|
-
const selections = entries(property.value);
|
|
178
|
-
const selected = selections[0];
|
|
179
|
-
const payload = selected &&
|
|
180
|
-
payloads.find((item) => item.axis === axis && item.choice === selected[0]);
|
|
181
|
-
if (selections.length !== 1 || !selected || !payload)
|
|
182
|
-
throw new Themes.InvalidError('Dynamic defaults require exactly one declared dynamic choice.', property);
|
|
183
|
-
const values = Object.create(null);
|
|
184
|
-
for (const [field, input] of entries(selected[1].value)) {
|
|
185
|
-
const node = input.value;
|
|
186
|
-
const value = node.type === 'TemplateLiteral'
|
|
187
|
-
? Expression.template(node)
|
|
188
|
-
: node.type === 'Literal'
|
|
189
|
-
? node.value
|
|
190
|
-
: node.type === 'UnaryExpression' &&
|
|
191
|
-
node.argument.type === 'Literal' &&
|
|
192
|
-
typeof node.argument.value === 'number' &&
|
|
193
|
-
(node.operator === '-' || node.operator === '+')
|
|
194
|
-
? node.operator === '-'
|
|
195
|
-
? -node.argument.value
|
|
196
|
-
: node.argument.value
|
|
197
|
-
: undefined;
|
|
198
|
-
if (!Object.hasOwn(payload.slots[0], field) ||
|
|
199
|
-
(typeof value !== 'string' && typeof value !== 'number'))
|
|
200
|
-
throw new Themes.InvalidError('Dynamic defaults require complete scalar payloads.', input);
|
|
201
|
-
if (!defaultsValidators.get(payload).acceptsValue(field, value))
|
|
202
|
-
throw new Themes.InvalidError('Dynamic default does not match its declared payload type.', input);
|
|
203
|
-
values[field] = value;
|
|
204
|
-
}
|
|
205
|
-
if (Object.keys(values).length !== Object.keys(payload.slots[0]).length)
|
|
206
|
-
throw new Themes.InvalidError('Dynamic defaults require complete scalar payloads.', property);
|
|
207
|
-
defaults[axis] = selected[0];
|
|
208
|
-
defaultPayloads[axis] = values;
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
defaults[axis] = choice(property.value, axes[axis]);
|
|
212
|
-
if (payloads.some((item) => item.axis === axis && item.choice === defaults[axis]))
|
|
213
|
-
throw new Themes.InvalidError('Dynamic choices require a scoped payload.', property);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
const compounds = fields.get('compoundVariants');
|
|
217
|
-
if (compounds) {
|
|
218
|
-
if (compounds.value.type !== 'ArrayExpression')
|
|
219
|
-
throw new Themes.InvalidError('Compounds require a static array.', compounds);
|
|
220
|
-
for (const [index, element] of compounds.value.elements.entries()) {
|
|
221
|
-
if (!element)
|
|
222
|
-
throw new Themes.InvalidError('Compounds require dense entries.', compounds);
|
|
223
|
-
const fields = new Map(entries(element));
|
|
224
|
-
const when = fields.get('when');
|
|
225
|
-
const style = fields.get('style');
|
|
226
|
-
if (!when || !style || fields.size !== 2)
|
|
227
|
-
throw new Themes.InvalidError('Compounds require only when and style.', element);
|
|
228
|
-
const matches = [];
|
|
229
|
-
for (const [axis, property] of entries(when.value)) {
|
|
230
|
-
if (!Object.hasOwn(axes, axis))
|
|
231
|
-
throw new Themes.InvalidError('Unknown compound variant axis.', property);
|
|
232
|
-
const values = property.value.type === 'ArrayExpression'
|
|
233
|
-
? property.value.elements
|
|
234
|
-
: [property.value];
|
|
235
|
-
if (!values.length || values.some((value) => !value))
|
|
236
|
-
throw new Themes.InvalidError('Compound matches require nonempty choices.', property);
|
|
237
|
-
matches.push([
|
|
238
|
-
axis,
|
|
239
|
-
values.map((value) => {
|
|
240
|
-
const selected = choice(value, axes[axis]);
|
|
241
|
-
if (selected === null)
|
|
242
|
-
throw new Themes.InvalidError('Compounds match choice names, not null.', value);
|
|
243
|
-
return selected;
|
|
244
|
-
}),
|
|
245
|
-
]);
|
|
246
|
-
}
|
|
247
|
-
// Distinct zero-specificity suffixes preserve repeated compound groups.
|
|
248
|
-
rules.push({
|
|
249
|
-
matches,
|
|
250
|
-
property: style,
|
|
251
|
-
suffix: `:where(*, .__zyzz-compound-${index})`,
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
const tree = { ...node, properties: [] };
|
|
256
|
-
for (const region of regions) {
|
|
257
|
-
let target = tree;
|
|
258
|
-
for (const { node: source, rule } of region.rules) {
|
|
259
|
-
const existing = target.properties.find((property) => property.type === 'Property' &&
|
|
260
|
-
property.key.type === 'Literal' &&
|
|
261
|
-
property.key.value === rule);
|
|
262
|
-
if (existing)
|
|
263
|
-
target = existing.value;
|
|
264
|
-
else {
|
|
265
|
-
const nested = { ...node, properties: [] };
|
|
266
|
-
target.properties.push(group(source, rule, nested));
|
|
267
|
-
target = nested;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
for (const { bodies, matches, property, suffix } of rules) {
|
|
271
|
-
if (bodies) {
|
|
272
|
-
const [axis, choices] = matches[0];
|
|
273
|
-
const sources = [-1, ...region.active];
|
|
274
|
-
for (const [index, condition] of sources.entries()) {
|
|
275
|
-
const attribute = condition === -1
|
|
276
|
-
? `data-${axis}`
|
|
277
|
-
: ConditionalRecipe.attribute({ axis, condition });
|
|
278
|
-
const excluded = sources
|
|
279
|
-
.slice(index + 1)
|
|
280
|
-
.map((condition) => `:not([${ConditionalRecipe.attribute({ axis, condition })}])`)
|
|
281
|
-
.join('');
|
|
282
|
-
const selector = `&:where(${predicate(attribute, condition === -1 ? choices[0] : `s${choices[0]}`)}${excluded})`;
|
|
283
|
-
target.properties.push(group(property.key, selector, bodies[condition + 1]));
|
|
284
|
-
}
|
|
285
|
-
continue;
|
|
286
|
-
}
|
|
287
|
-
object(property.value);
|
|
288
|
-
const selector = '&' +
|
|
289
|
-
matches
|
|
290
|
-
.map(([axis, choices]) => {
|
|
291
|
-
const sources = [-1, ...region.active];
|
|
292
|
-
const alternatives = sources.flatMap((condition, index) => {
|
|
293
|
-
const attribute = condition === -1
|
|
294
|
-
? `data-${axis}`
|
|
295
|
-
: ConditionalRecipe.attribute({ axis, condition });
|
|
296
|
-
const excluded = sources
|
|
297
|
-
.slice(index + 1)
|
|
298
|
-
.map((condition) => `:not([${ConditionalRecipe.attribute({ axis, condition })}])`)
|
|
299
|
-
.join('');
|
|
300
|
-
return choices.map((choice) => predicate(attribute, condition === -1 ? choice : `s${choice}`) + excluded);
|
|
301
|
-
});
|
|
302
|
-
return `:where(${alternatives.join(',')})`;
|
|
303
|
-
})
|
|
304
|
-
.join('') +
|
|
305
|
-
suffix;
|
|
306
|
-
target.properties.push(group(property.key, selector, property.value));
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
properties.push(...tree.properties);
|
|
310
|
-
return {
|
|
311
|
-
bindings,
|
|
312
|
-
types,
|
|
313
|
-
body: { ...node, properties },
|
|
314
|
-
...(!named.length
|
|
315
|
-
? {
|
|
316
|
-
[payloads.length ? 'dynamicRecipe' : 'staticRecipe']: {
|
|
317
|
-
axes,
|
|
318
|
-
defaults,
|
|
319
|
-
rules: [
|
|
320
|
-
...(base
|
|
321
|
-
? [{ matches: [], value: base.value }]
|
|
322
|
-
: []),
|
|
323
|
-
...rules.map(({ matches, property, bodies }) => ({
|
|
324
|
-
matches,
|
|
325
|
-
value: bodies?.[0] ?? property.value,
|
|
326
|
-
})),
|
|
327
|
-
],
|
|
328
|
-
},
|
|
329
|
-
}
|
|
330
|
-
: {}),
|
|
331
|
-
recipe: {
|
|
332
|
-
axes,
|
|
333
|
-
defaults,
|
|
334
|
-
...(payloads.length ? { payloads, defaultPayloads } : {}),
|
|
335
|
-
...(named.length ? { conditions: named.map(({ name }) => name) } : {}),
|
|
336
|
-
},
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
//# sourceMappingURL=Recipes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Recipes.js","sourceRoot":"","sources":["../../../src/compiler/internal/Recipes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,iBAAiB,MAAM,oCAAoC,CAAA;AAGvE,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAOrC,SAAS,MAAM,CAAC,IAAc;IAC5B,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB;QAClC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,uCAAuC,EAAE,IAAI,CAAC,CAAA;AAChF,CAAC;AAED,SAAS,OAAO,CAAC,IAAc;IAC7B,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB;QAClC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,uCAAuC,EAAE,IAAI,CAAC,CAAA;IAE9E,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QACtC,IACE,QAAQ,CAAC,IAAI,KAAK,UAAU;YAC5B,QAAQ,CAAC,QAAQ;YACjB,QAAQ,CAAC,MAAM;YACf,QAAQ,CAAC,SAAS;YAClB,QAAQ,C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AAI;4BACN,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAA6B,EAAE,CAAC;4BAC9D,CAAC,CAAC,EAAE,CAAC;wBACP,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;4BAC/C,OAAO;4BACP,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,IAAK,QAAQ,CAAC,KAA8B;yBAC/D,CAAC,CAAC;qBACJ;iBACF;aACF;YACH,CAAC,CAAC,EAAE,CAAC;QACP,MAAM,EAAE;YACN,IAAI;YACJ,QAAQ;YACR,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzD,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACvE;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** Resolves selector objects and portable style definition identities. @module */
|
|
2
|
-
import type * as Ast from '@oxc-project/types';
|
|
3
|
-
import type * as Scope from './Scope.js';
|
|
4
|
-
import * as Themes from './Themes.js';
|
|
5
|
-
/** Collects scoped selectors, local identities, exported style references, and composed definitions. */
|
|
6
|
-
export declare function scan(program: Ast.Program, scope: Scope.Tracker, namespace: string, calls: readonly Ast.CallExpression[], links?: Readonly<Record<string, Themes.Link>>, selectorKeys?: ReadonlySet<number>, cssNamespaces?: ReadonlyMap<number, string>, moduleId?: string, composed?: readonly Ast.Node[]): {
|
|
7
|
-
compositions: Map<number, Ast.CallExpression | Themes.Link>;
|
|
8
|
-
conditions: Map<number, string>;
|
|
9
|
-
exports: Record<string, Themes.Link>;
|
|
10
|
-
identities: Map<number, string>;
|
|
11
|
-
localConditions: Set<string>;
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=Selectors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Selectors.d.ts","sourceRoot":"","sources":["../../../src/compiler/internal/Selectors.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,OAAO,KAAK,KAAK,GAAG,MAAM,oBAAoB,CAAA;AAS9C,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,wGAAwG;AACxG,wBAAgB,IAAI,CAClB,OAAO,EAAE,GAAG,CAAC,OAAO,EACpB,KAAK,EAAE,KAAK,CAAC,OAAO,EACpB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,SAAS,GAAG,CAAC,cAAc,EAAE,EACpC,KAAK,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAM,EACjD,YAAY,GAAE,WAAW,CAAC,MAAM,CAAa,EAC7C,aAAa,GAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAa,EACtD,QAAQ,SAAY,EACpB,QAAQ,GAAE,SAAS,GAAG,CAAC,IAAI,EAAO;;;;;;EAyUnC"}
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import * as Walker from 'oxc-walker';
|
|
2
|
-
import * as Condition from '../../internal/Condition.js';
|
|
3
|
-
import * as Theme from '../../internal/Theme.js';
|
|
4
|
-
import * as AtRules from './AtRules.js';
|
|
5
|
-
import * as Identity from '../../internal/Identity.js';
|
|
6
|
-
import * as Identifiers from './Identifiers.js';
|
|
7
|
-
import * as Names from './Names.js';
|
|
8
|
-
import * as Expression from './Expression.js';
|
|
9
|
-
import * as Themes from './Themes.js';
|
|
10
|
-
/** Collects scoped selectors, local identities, exported style references, and composed definitions. */
|
|
11
|
-
export function scan(program, scope, namespace, calls, links = {}, selectorKeys = new Set(), cssNamespaces = new Map(), moduleId = namespace, composed = []) {
|
|
12
|
-
const authoredNames = Names.collect(program);
|
|
13
|
-
const conditions = new Map();
|
|
14
|
-
const localConditions = new Set();
|
|
15
|
-
const identities = new Map();
|
|
16
|
-
const exports = Object.create(null);
|
|
17
|
-
const definitions = new Map(calls.map((call) => [call.start, call]));
|
|
18
|
-
const declarations = new Map();
|
|
19
|
-
const bindings = new Map();
|
|
20
|
-
const namespaces = new Map();
|
|
21
|
-
const importedNames = new Map();
|
|
22
|
-
const imported = new Map();
|
|
23
|
-
const compositions = new Map();
|
|
24
|
-
const names = new Map();
|
|
25
|
-
const publicNames = new Map();
|
|
26
|
-
const namespaceNames = new Map();
|
|
27
|
-
const publicNamespaces = new Map();
|
|
28
|
-
function members(node) {
|
|
29
|
-
const result = new Map();
|
|
30
|
-
if (node.body?.type !== 'TSModuleBlock')
|
|
31
|
-
return result;
|
|
32
|
-
for (const statement of node.body.body) {
|
|
33
|
-
if (statement.type !== 'ExportNamedDeclaration')
|
|
34
|
-
continue;
|
|
35
|
-
const declaration = statement.declaration;
|
|
36
|
-
if (declaration?.type !== 'VariableDeclaration' ||
|
|
37
|
-
declaration.kind !== 'const')
|
|
38
|
-
continue;
|
|
39
|
-
for (const variable of declaration.declarations)
|
|
40
|
-
if (variable.id.type === 'Identifier' && variable.init)
|
|
41
|
-
result.set(variable.id.name, variable.init);
|
|
42
|
-
}
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
for (const statement of program.body) {
|
|
46
|
-
if (statement.type === 'ImportDeclaration' &&
|
|
47
|
-
statement.importKind !== 'type')
|
|
48
|
-
for (const specifier of statement.specifiers) {
|
|
49
|
-
if (specifier.type === 'ImportSpecifier' &&
|
|
50
|
-
specifier.importKind === 'type')
|
|
51
|
-
continue;
|
|
52
|
-
const link = links[specifier.local.name];
|
|
53
|
-
if (link?.kind === 'style-reference') {
|
|
54
|
-
imported.set(specifier.start, link);
|
|
55
|
-
importedNames.set(specifier.local.name, link);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
const declaration = statement.type === 'ExportNamedDeclaration'
|
|
59
|
-
? statement.declaration
|
|
60
|
-
: statement;
|
|
61
|
-
if (declaration?.type === 'VariableDeclaration' &&
|
|
62
|
-
declaration.kind === 'const')
|
|
63
|
-
for (const variable of declaration.declarations)
|
|
64
|
-
if (variable.id.type === 'Identifier' && variable.init) {
|
|
65
|
-
names.set(variable.id.name, variable.init);
|
|
66
|
-
if (statement.type === 'ExportNamedDeclaration')
|
|
67
|
-
publicNames.set(variable.id.name, variable.id.name);
|
|
68
|
-
}
|
|
69
|
-
if (declaration?.type === 'TSModuleDeclaration' &&
|
|
70
|
-
declaration.id.type === 'Identifier' &&
|
|
71
|
-
declaration.kind !== 'global') {
|
|
72
|
-
namespaceNames.set(declaration.id.name, members(declaration));
|
|
73
|
-
if (statement.type === 'ExportNamedDeclaration')
|
|
74
|
-
publicNamespaces.set(declaration.id.name, members(declaration));
|
|
75
|
-
}
|
|
76
|
-
if (statement.type === 'ExportNamedDeclaration' &&
|
|
77
|
-
!statement.source &&
|
|
78
|
-
statement.exportKind !== 'type')
|
|
79
|
-
for (const specifier of statement.specifiers) {
|
|
80
|
-
if (specifier.exportKind === 'type')
|
|
81
|
-
continue;
|
|
82
|
-
publicNames.set(specifier.exported.type === 'Identifier'
|
|
83
|
-
? specifier.exported.name
|
|
84
|
-
: specifier.exported.value, specifier.local.type === 'Identifier'
|
|
85
|
-
? specifier.local.name
|
|
86
|
-
: specifier.local.value);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (!calls.length && !imported.size)
|
|
90
|
-
return { compositions, conditions, exports, identities, localConditions };
|
|
91
|
-
const exposed = new Map();
|
|
92
|
-
for (const [name, local] of publicNames) {
|
|
93
|
-
const imported = importedNames.get(local);
|
|
94
|
-
if (imported)
|
|
95
|
-
exports[name] = imported;
|
|
96
|
-
const value = names.get(local);
|
|
97
|
-
if (value)
|
|
98
|
-
exposed.set(value, [...(exposed.get(value) ?? []), [name]]);
|
|
99
|
-
const namespace = namespaceNames.get(local);
|
|
100
|
-
if (namespace)
|
|
101
|
-
publicNamespaces.set(name, namespace);
|
|
102
|
-
}
|
|
103
|
-
for (const [name, values] of publicNamespaces)
|
|
104
|
-
for (const [member, value] of values)
|
|
105
|
-
exposed.set(value, [...(exposed.get(value) ?? []), [name, member]]);
|
|
106
|
-
if (!selectorKeys.size && !exposed.size && !composed.length)
|
|
107
|
-
return { compositions, conditions, exports, identities, localConditions };
|
|
108
|
-
const nodes = [];
|
|
109
|
-
Walker.walk(program, {
|
|
110
|
-
scopeTracker: scope,
|
|
111
|
-
enter(node, parent) {
|
|
112
|
-
if (node.type === 'Property' && selectorKeys.has(node.key.start))
|
|
113
|
-
nodes.push({ node, parent });
|
|
114
|
-
if (node.type === 'VariableDeclarator')
|
|
115
|
-
nodes.push({ node, parent });
|
|
116
|
-
if (node.type === 'Identifier') {
|
|
117
|
-
const declaration = scope.getDeclaration(node.name);
|
|
118
|
-
if (declaration)
|
|
119
|
-
declarations.set(node.start, declaration.node.start);
|
|
120
|
-
}
|
|
121
|
-
if (node.type === 'VariableDeclaration' && node.kind === 'const')
|
|
122
|
-
for (const variable of node.declarations)
|
|
123
|
-
if (variable.id.type === 'Identifier' && variable.init)
|
|
124
|
-
bindings.set(variable.id.start, variable.init);
|
|
125
|
-
if (node.type === 'TSModuleDeclaration' && node.id.type === 'Identifier')
|
|
126
|
-
namespaces.set(node.id.start, members(node));
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
function link(call) {
|
|
130
|
-
const id = Identifiers.explicit(call);
|
|
131
|
-
const prefix = cssNamespaces.get(call.start);
|
|
132
|
-
const name = `z-style-${id === undefined ? `${prefix ? `${prefix}-` : ''}${Identity.compact(moduleId).slice(-6)}-${authoredNames.get(call.start)}` : `id-${prefix ? `${prefix}-` : ''}${Identity.requireId(id, 'style').slice(3)}`}`;
|
|
133
|
-
identities.set(call.start, name);
|
|
134
|
-
return {
|
|
135
|
-
binding: name,
|
|
136
|
-
call: { start: call.start, end: call.end, name, tokenType: '{}' },
|
|
137
|
-
definition: Theme.define({}),
|
|
138
|
-
kind: 'style-reference',
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
// Composition reads the definition itself, so only selector references claim an identity.
|
|
142
|
-
function target(node, seen = new Set()) {
|
|
143
|
-
node = Expression.unwrap(node);
|
|
144
|
-
if (seen.has(node))
|
|
145
|
-
return undefined;
|
|
146
|
-
seen.add(node);
|
|
147
|
-
if (node.type === 'CallExpression' &&
|
|
148
|
-
definitions.get(node.start)?.end === node.end)
|
|
149
|
-
return node;
|
|
150
|
-
if (node.type === 'Identifier') {
|
|
151
|
-
const declaration = declarations.get(node.start);
|
|
152
|
-
if (declaration === undefined)
|
|
153
|
-
return undefined;
|
|
154
|
-
const external = imported.get(declaration);
|
|
155
|
-
if (external)
|
|
156
|
-
return external;
|
|
157
|
-
const value = bindings.get(declaration);
|
|
158
|
-
return value ? target(value, seen) : undefined;
|
|
159
|
-
}
|
|
160
|
-
if (node.type === 'MemberExpression' && !node.optional) {
|
|
161
|
-
const name = (() => {
|
|
162
|
-
if (!node.computed && node.property.type === 'Identifier')
|
|
163
|
-
return node.property.name;
|
|
164
|
-
if (node.property.type === 'Literal' &&
|
|
165
|
-
typeof node.property.value === 'string')
|
|
166
|
-
return node.property.value;
|
|
167
|
-
return undefined;
|
|
168
|
-
})();
|
|
169
|
-
if (name === undefined)
|
|
170
|
-
return undefined;
|
|
171
|
-
if (node.object.type === 'Identifier') {
|
|
172
|
-
const declaration = declarations.get(node.object.start);
|
|
173
|
-
const value = declaration === undefined
|
|
174
|
-
? undefined
|
|
175
|
-
: namespaces.get(declaration)?.get(name);
|
|
176
|
-
if (value)
|
|
177
|
-
return target(value, seen);
|
|
178
|
-
}
|
|
179
|
-
const object = target(node.object, seen);
|
|
180
|
-
return object && !('type' in object) ? object.members?.[name] : undefined;
|
|
181
|
-
}
|
|
182
|
-
return undefined;
|
|
183
|
-
}
|
|
184
|
-
function resolve(node) {
|
|
185
|
-
const value = target(node);
|
|
186
|
-
return value && 'type' in value ? link(value) : value;
|
|
187
|
-
}
|
|
188
|
-
for (const node of composed) {
|
|
189
|
-
const value = target(node);
|
|
190
|
-
if (value)
|
|
191
|
-
compositions.set(node.start, value);
|
|
192
|
-
}
|
|
193
|
-
for (const { node } of nodes) {
|
|
194
|
-
if (node.type === 'VariableDeclarator' && node.init)
|
|
195
|
-
for (const [key, member] of exposed.get(node.init) ?? []) {
|
|
196
|
-
const resolved = resolve(node.init);
|
|
197
|
-
if (!resolved || key === undefined)
|
|
198
|
-
continue;
|
|
199
|
-
if (member === undefined)
|
|
200
|
-
exports[key] = resolved;
|
|
201
|
-
else {
|
|
202
|
-
const previous = exports[key];
|
|
203
|
-
const name = Array.from(key, (char) => char.codePointAt(0).toString(16)).join('-');
|
|
204
|
-
exports[key] = {
|
|
205
|
-
binding: `z-style-${namespace}-namespace-${name}`,
|
|
206
|
-
call: { start: -1, end: -1, name: '', tokenType: '{}' },
|
|
207
|
-
definition: Theme.define({}),
|
|
208
|
-
kind: 'style-reference',
|
|
209
|
-
members: { ...previous?.members, [member]: resolved },
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
if (node.type !== 'Property')
|
|
214
|
-
continue;
|
|
215
|
-
if (node.method || node.kind !== 'init' || node.shorthand)
|
|
216
|
-
throw new Themes.InvalidError('Selectors require explicit string keys and style objects.', node);
|
|
217
|
-
const key = Expression.unwrap(node.key);
|
|
218
|
-
let selector = '';
|
|
219
|
-
if (key.type === 'Literal' && typeof key.value === 'string')
|
|
220
|
-
selector = key.value;
|
|
221
|
-
else if (key.type === 'TemplateLiteral' && node.computed) {
|
|
222
|
-
selector = key.quasis[0].value.cooked ?? '';
|
|
223
|
-
for (const [index, expression] of key.expressions.entries()) {
|
|
224
|
-
const value = Expression.unwrap(expression);
|
|
225
|
-
if (value.type !== 'Identifier' && value.type !== 'MemberExpression')
|
|
226
|
-
throw new Themes.InvalidError('Selector interpolations require style definitions without calling them.', expression);
|
|
227
|
-
const reference = resolve(value);
|
|
228
|
-
if (!reference ||
|
|
229
|
-
reference.members ||
|
|
230
|
-
(reference.call.start >= 0 &&
|
|
231
|
-
reference.call.end > node.start &&
|
|
232
|
-
!importedHas(reference)))
|
|
233
|
-
throw new Themes.InvalidError('Selector interpolations require previously declared style definitions.', expression);
|
|
234
|
-
selector += `.${reference.call.name}${key.quasis[index + 1].value.cooked ?? ''}`;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
else
|
|
238
|
-
throw new Themes.InvalidError('Selectors require literal strings or templates referencing style definitions.', key);
|
|
239
|
-
try {
|
|
240
|
-
if (!Condition.nested(selector) || selector.trimStart().startsWith('@'))
|
|
241
|
-
throw new Error('Selectors require an explicit & target.');
|
|
242
|
-
selector = Condition.normalize(selector);
|
|
243
|
-
let local = false;
|
|
244
|
-
AtRules.transform({
|
|
245
|
-
filename: 'selectors.css',
|
|
246
|
-
code: new TextEncoder().encode(`.z{${selector}{color:red}}`),
|
|
247
|
-
errorRecovery: false,
|
|
248
|
-
visitor: {
|
|
249
|
-
Rule(rule) {
|
|
250
|
-
if (rule.type !== 'style')
|
|
251
|
-
return;
|
|
252
|
-
const selectors = rule.value.selectors;
|
|
253
|
-
if (!selectors.some((parts) => parts.some((part) => part.type === 'nesting')))
|
|
254
|
-
return;
|
|
255
|
-
local = selectors.every((parts) => {
|
|
256
|
-
const last = parts.findLastIndex((part) => part.type === 'combinator');
|
|
257
|
-
return parts
|
|
258
|
-
.slice(last + 1)
|
|
259
|
-
.some((part) => part.type === 'nesting');
|
|
260
|
-
});
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
});
|
|
264
|
-
conditions.set(node.key.start, selector);
|
|
265
|
-
if (local)
|
|
266
|
-
localConditions.add(selector);
|
|
267
|
-
}
|
|
268
|
-
catch (error) {
|
|
269
|
-
throw new Themes.InvalidError(error.message, node);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
function importedHas(reference) {
|
|
273
|
-
function contains(value) {
|
|
274
|
-
return (value === reference || Object.values(value.members ?? {}).some(contains));
|
|
275
|
-
}
|
|
276
|
-
return [...imported.values()].some(contains);
|
|
277
|
-
}
|
|
278
|
-
return { compositions, conditions, exports, identities, localConditions };
|
|
279
|
-
}
|
|
280
|
-
//# sourceMappingURL=Selectors.js.map
|