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,164 +0,0 @@
|
|
|
1
|
-
import * as Binding from '../../internal/Binding.js';
|
|
2
|
-
import * as Literal from '../../internal/Literal.js';
|
|
3
|
-
import * as Token from '../../internal/Token.js';
|
|
4
|
-
import * as Tree from 'css-tree';
|
|
5
|
-
/** Checks color substitutions inside compound CSS values without widening direct reference domains. */
|
|
6
|
-
export function acceptsColor(expression, property) {
|
|
7
|
-
const value = expression.parts
|
|
8
|
-
.map((part) => {
|
|
9
|
-
if (typeof part === 'string')
|
|
10
|
-
return part;
|
|
11
|
-
if (Binding.is(part) ? part.type === 'color' : part.group === 'color')
|
|
12
|
-
return 'rgb(1 2 3)';
|
|
13
|
-
return 'var(--zyzz-reference)';
|
|
14
|
-
})
|
|
15
|
-
.join('')
|
|
16
|
-
.replace(/(?: !custom)?(?: !important)?$/, '');
|
|
17
|
-
try {
|
|
18
|
-
return (Tree.lexer.matchProperty(Literal.name(property), value).error === null);
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/** Validates explicit variable substitutions in compound values, including every conditional fallback. */
|
|
25
|
-
export function acceptsVariables(expression, property) {
|
|
26
|
-
if (!['filter', 'backdropFilter', 'boxShadow', 'textShadow'].includes(property))
|
|
27
|
-
return false;
|
|
28
|
-
function values(value) {
|
|
29
|
-
if (Token.is(value))
|
|
30
|
-
return values(value.value);
|
|
31
|
-
if (typeof value === 'object')
|
|
32
|
-
return Object.values(value).flatMap(values);
|
|
33
|
-
return [String(value)];
|
|
34
|
-
}
|
|
35
|
-
let candidates = [''];
|
|
36
|
-
for (const part of expression.parts) {
|
|
37
|
-
if (Binding.is(part))
|
|
38
|
-
return false;
|
|
39
|
-
const alternatives = typeof part === 'string' ? [part] : values(part.value);
|
|
40
|
-
// Bound combinations of independent responsive variables before grammar checks.
|
|
41
|
-
if (candidates.length * alternatives.length > 256)
|
|
42
|
-
return false;
|
|
43
|
-
candidates = candidates.flatMap((prefix) => alternatives.map((value) => prefix + value));
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
return candidates.every((value) => Tree.lexer.matchProperty(Literal.name(property), value.replace(/(?: !custom)?(?: !important)?$/, '')).error === null);
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
/** Checks every identifier-token branch before its value becomes a CSS variable. */
|
|
53
|
-
export function acceptsIdentifier(reference, property) {
|
|
54
|
-
function check(value) {
|
|
55
|
-
if (Token.is(value))
|
|
56
|
-
return check(value.value);
|
|
57
|
-
if (typeof value === 'object')
|
|
58
|
-
return Object.values(value).every(check);
|
|
59
|
-
try {
|
|
60
|
-
return (Tree.lexer.matchProperty(Literal.name(property), String(value))
|
|
61
|
-
.error === null);
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return check(reference.value);
|
|
68
|
-
}
|
|
69
|
-
/** Folds cooked template text and literal primitive substitutions; unresolved syntax returns undefined. */
|
|
70
|
-
export function template(node, depth = 0, resolve, context = '') {
|
|
71
|
-
if (depth >= 128)
|
|
72
|
-
return undefined;
|
|
73
|
-
const parts = [];
|
|
74
|
-
for (const [index, quasi] of node.quasis.entries()) {
|
|
75
|
-
if (quasi.value.cooked === null)
|
|
76
|
-
return undefined;
|
|
77
|
-
parts.push(quasi.value.cooked);
|
|
78
|
-
const expression = node.expressions[index];
|
|
79
|
-
if (!expression)
|
|
80
|
-
continue;
|
|
81
|
-
const value = unwrap(expression);
|
|
82
|
-
const prefix = context +
|
|
83
|
-
parts
|
|
84
|
-
.map((part) => typeof part === 'string' ? part : 'var(--zyzz-expression)')
|
|
85
|
-
.join('');
|
|
86
|
-
const reference = resolve?.(expression, prefix) ?? resolve?.(value, prefix);
|
|
87
|
-
if (reference) {
|
|
88
|
-
if (quoted(parts
|
|
89
|
-
.filter((part) => typeof part === 'string')
|
|
90
|
-
.join('')))
|
|
91
|
-
return undefined;
|
|
92
|
-
// var() substitutions must remain whole CSS tokens.
|
|
93
|
-
if (/[%a-zA-Z_\d.-]/.test(node.quasis[index + 1]?.value.cooked?.[0] ?? '') ||
|
|
94
|
-
/[\w.#@+\\-]$/.test(quasi.value.cooked))
|
|
95
|
-
return undefined;
|
|
96
|
-
parts.push(reference);
|
|
97
|
-
}
|
|
98
|
-
else if (value.type === 'Literal' && !('regex' in value)) {
|
|
99
|
-
if (typeof value.value === 'number' && !Number.isFinite(value.value))
|
|
100
|
-
return undefined;
|
|
101
|
-
parts.push(String(value.value));
|
|
102
|
-
}
|
|
103
|
-
else if (value.type === 'UnaryExpression' &&
|
|
104
|
-
(value.operator === '-' || value.operator === '+') &&
|
|
105
|
-
value.argument.type === 'Literal' &&
|
|
106
|
-
typeof value.argument.value === 'number' &&
|
|
107
|
-
Number.isFinite(value.argument.value)) {
|
|
108
|
-
parts.push(String(value.operator === '-' ? -value.argument.value : value.argument.value));
|
|
109
|
-
}
|
|
110
|
-
else if (value.type === 'UnaryExpression' &&
|
|
111
|
-
value.operator === '-' &&
|
|
112
|
-
value.argument.type === 'Literal' &&
|
|
113
|
-
typeof value.argument.value === 'bigint') {
|
|
114
|
-
parts.push(String(-value.argument.value));
|
|
115
|
-
}
|
|
116
|
-
else if (value.type === 'TemplateLiteral') {
|
|
117
|
-
const nested = template(value, depth + 1, resolve, prefix);
|
|
118
|
-
if (nested === undefined)
|
|
119
|
-
return undefined;
|
|
120
|
-
if (typeof nested === 'string')
|
|
121
|
-
parts.push(nested);
|
|
122
|
-
else
|
|
123
|
-
parts.push(...nested.parts);
|
|
124
|
-
}
|
|
125
|
-
else
|
|
126
|
-
return undefined;
|
|
127
|
-
}
|
|
128
|
-
return parts.every((part) => typeof part === 'string')
|
|
129
|
-
? parts.join('')
|
|
130
|
-
: Token.compose(parts);
|
|
131
|
-
}
|
|
132
|
-
/** Returns the expression beneath assertions without evaluating application code. */
|
|
133
|
-
export function unwrap(node) {
|
|
134
|
-
while (node.type === 'TSAsExpression' ||
|
|
135
|
-
node.type === 'TSSatisfiesExpression' ||
|
|
136
|
-
node.type === 'TSNonNullExpression' ||
|
|
137
|
-
node.type === 'TSTypeAssertion')
|
|
138
|
-
node = node.expression;
|
|
139
|
-
return node;
|
|
140
|
-
}
|
|
141
|
-
function quoted(text) {
|
|
142
|
-
let quote = '';
|
|
143
|
-
for (let index = 0; index < text.length; index++) {
|
|
144
|
-
const char = text[index];
|
|
145
|
-
if (char === '\\') {
|
|
146
|
-
index++;
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
if (quote) {
|
|
150
|
-
if (char === quote)
|
|
151
|
-
quote = '';
|
|
152
|
-
}
|
|
153
|
-
else if (char === '"' || char === "'")
|
|
154
|
-
quote = char;
|
|
155
|
-
else if (char === '/' && text[index + 1] === '*') {
|
|
156
|
-
const end = text.indexOf('*/', index + 2);
|
|
157
|
-
if (end < 0)
|
|
158
|
-
return true;
|
|
159
|
-
index = end + 1;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return !!quote;
|
|
163
|
-
}
|
|
164
|
-
//# sourceMappingURL=Expression.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Expression.js","sourceRoot":"","sources":["../../../src/compiler/internal/Expression.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,OAAO,MAAM,2BAA2B,CAAA;AACpD,OAAO,KAAK,OAAO,MAAM,2BAA2B,CAAA;AACpD,OAAO,KAAK,KAAK,MAAM,yBAAyB,CAAA;AAChD,OAAO,KAAK,IAAI,MAAM,UAAU,CAAA;AAEhC,uGAAuG;AACvG,MAAM,UAAU,YAAY,CAC1B,UAA4B,EAC5B,QAAkC;IAElC,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK;SAC3B,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAA;QACzC,IAAI,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,OAAO;YACnE,OAAO,YAAY,CAAA;QACrB,OAAO,uBAAuB,CAAA;IAChC,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC;SACR,OAAO,CAAC,gCAAgC,EAAE,EAAE,CAAC,CAAA;IAEhD,IAAI,CAAC;QACH,OAAO,CACL,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,KAAK,IAAI,CACvE,CAAA;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED,0GAA0G;A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I,KAAK,GAAG,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACjD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,CAAC,CAAA;YACzC,IAAI,GAAG,GAAG,CAAC;gBAAE,OAAO,IAAI,CAAA;YAExB,KAAK,GAAG,GAAG,GAAG,CAAC,CAAA;QACjB,CAAC;IACH,CAAC;IAED,OAAO,CAAC,CAAC,KAAK,CAAA;AAChB,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** Checks complete static values while leaving computed substitutions to CSS. */
|
|
2
|
-
export declare function value(syntax: string, input: string): string | undefined;
|
|
3
|
-
/** Validates packed function headers and body contexts before parser recovery. */
|
|
4
|
-
export declare function validate(source: string): void;
|
|
5
|
-
//# sourceMappingURL=Functions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Functions.d.ts","sourceRoot":"","sources":["../../../src/compiler/internal/Functions.ts"],"names":[],"mappings":"AAKA,iFAAiF;AACjF,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAsFvE;AAED,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CA8G7C"}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
/** Checks CSS function arguments and defaults against native syntax definitions. @module */
|
|
2
|
-
import * as FunctionSyntax from '../../internal/FunctionSyntax.js';
|
|
3
|
-
import * as Lightning from 'lightningcss';
|
|
4
|
-
import * as Tree from 'css-tree';
|
|
5
|
-
/** Checks complete static values while leaving computed substitutions to CSS. */
|
|
6
|
-
export function value(syntax, input) {
|
|
7
|
-
const text = input.trim();
|
|
8
|
-
const body = text.startsWith('{') && text.endsWith('}') ? text.slice(1, -1) : text;
|
|
9
|
-
const parsed = Tree.parse(body, { context: 'value' });
|
|
10
|
-
let computed = false;
|
|
11
|
-
Tree.walk(parsed, (node) => {
|
|
12
|
-
if (node.type === 'Function' &&
|
|
13
|
-
/^(?:--|var$|env$|attr$)/i.test(Tree.ident.decode(node.name)))
|
|
14
|
-
computed = true;
|
|
15
|
-
});
|
|
16
|
-
const normalized = syntax.trim();
|
|
17
|
-
const definition = normalized.startsWith('type(')
|
|
18
|
-
? normalized.slice(5, -1).trim()
|
|
19
|
-
: normalized;
|
|
20
|
-
if (computed || definition === '*')
|
|
21
|
-
return;
|
|
22
|
-
const alternatives = [];
|
|
23
|
-
let start = 0;
|
|
24
|
-
Tree.tokenize(definition, (type, from, to) => {
|
|
25
|
-
if (type === Tree.tokenTypes.Delim && definition.slice(from, to) === '|') {
|
|
26
|
-
alternatives.push(definition.slice(start, from).trim());
|
|
27
|
-
start = to;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
alternatives.push(definition.slice(start).trim());
|
|
31
|
-
for (const alternative of alternatives) {
|
|
32
|
-
try {
|
|
33
|
-
if (alternative.startsWith('<')) {
|
|
34
|
-
if (alternative.startsWith('<string>')) {
|
|
35
|
-
if (Tree.lexer.match(alternative, body).error)
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
else
|
|
39
|
-
Lightning.transform({
|
|
40
|
-
filename: 'argument.css',
|
|
41
|
-
code: new TextEncoder().encode(`@property --argument{syntax:${JSON.stringify(alternative)};inherits:false;initial-value:${body};}`),
|
|
42
|
-
});
|
|
43
|
-
return alternative;
|
|
44
|
-
}
|
|
45
|
-
let multiplier = '';
|
|
46
|
-
let atom = alternative;
|
|
47
|
-
Tree.tokenize(alternative, (type, from, to) => {
|
|
48
|
-
if (type === Tree.tokenTypes.Delim &&
|
|
49
|
-
to === alternative.length &&
|
|
50
|
-
['+', '#'].includes(alternative.slice(from, to))) {
|
|
51
|
-
multiplier = alternative.slice(from, to);
|
|
52
|
-
atom = alternative.slice(0, from);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
const expected = Tree.ident.decode(atom);
|
|
56
|
-
const nodes = parsed.children.toArray();
|
|
57
|
-
let count = 0;
|
|
58
|
-
let comma = false;
|
|
59
|
-
let valid = true;
|
|
60
|
-
for (const node of nodes) {
|
|
61
|
-
if (node.type === 'Operator' &&
|
|
62
|
-
node.value === ',' &&
|
|
63
|
-
multiplier === '#' &&
|
|
64
|
-
count > 0 &&
|
|
65
|
-
!comma) {
|
|
66
|
-
comma = true;
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
if (node.type !== 'Identifier' ||
|
|
70
|
-
Tree.ident.decode(node.name) !== expected ||
|
|
71
|
-
(count > 0 && (multiplier === '' || (multiplier === '#' && !comma)))) {
|
|
72
|
-
valid = false;
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
count++;
|
|
76
|
-
comma = false;
|
|
77
|
-
}
|
|
78
|
-
if (valid && count > 0 && !comma)
|
|
79
|
-
return alternative;
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
/* Another syntax alternative may accept this value. */
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
throw new Error('Invalid CSS function argument for its declared syntax.');
|
|
86
|
-
}
|
|
87
|
-
/** Validates packed function headers and body contexts before parser recovery. */
|
|
88
|
-
export function validate(source) {
|
|
89
|
-
Tree.walk(Tree.parse(source), {
|
|
90
|
-
visit: 'Atrule',
|
|
91
|
-
enter(rule) {
|
|
92
|
-
if (rule.name.toLowerCase() !== 'function')
|
|
93
|
-
return;
|
|
94
|
-
if (!rule.prelude || !rule.block)
|
|
95
|
-
throw new Error('CSS functions require parameters and a body.');
|
|
96
|
-
const prelude = Tree.generate(rule.prelude);
|
|
97
|
-
let opening = 0;
|
|
98
|
-
let closing = -1;
|
|
99
|
-
let depth = 0;
|
|
100
|
-
const commas = [];
|
|
101
|
-
Tree.tokenize(prelude, (type, start, end) => {
|
|
102
|
-
if (closing >= 0)
|
|
103
|
-
return;
|
|
104
|
-
if (type === Tree.tokenTypes.Function ||
|
|
105
|
-
type === Tree.tokenTypes.LeftParenthesis) {
|
|
106
|
-
if (depth === 0) {
|
|
107
|
-
const name = Tree.ident.decode(prelude.slice(start, end - 1));
|
|
108
|
-
if (start !== 0 ||
|
|
109
|
-
type !== Tree.tokenTypes.Function ||
|
|
110
|
-
!name.startsWith('--') ||
|
|
111
|
-
name.length <= 2)
|
|
112
|
-
throw new Error('CSS function names require a dashed identifier.');
|
|
113
|
-
opening = end;
|
|
114
|
-
}
|
|
115
|
-
depth++;
|
|
116
|
-
}
|
|
117
|
-
else if (type === Tree.tokenTypes.RightParenthesis) {
|
|
118
|
-
depth--;
|
|
119
|
-
if (depth === 0)
|
|
120
|
-
closing = start;
|
|
121
|
-
}
|
|
122
|
-
else if (type === Tree.tokenTypes.Comma && depth === 1)
|
|
123
|
-
commas.push(start);
|
|
124
|
-
});
|
|
125
|
-
if (closing < 0)
|
|
126
|
-
throw new Error('Unclosed CSS function parameters.');
|
|
127
|
-
const names = new Set();
|
|
128
|
-
let start = opening;
|
|
129
|
-
for (const end of [...commas, closing]) {
|
|
130
|
-
const parameter = prelude.slice(start, end).trim();
|
|
131
|
-
start = end + 1;
|
|
132
|
-
if (!parameter && end === closing && opening === closing)
|
|
133
|
-
continue;
|
|
134
|
-
let name = '';
|
|
135
|
-
let offset = 0;
|
|
136
|
-
let colon = -1;
|
|
137
|
-
let depth = 0;
|
|
138
|
-
Tree.tokenize(parameter, (type, from, to) => {
|
|
139
|
-
if (from === 0 && type === Tree.tokenTypes.Ident) {
|
|
140
|
-
name = Tree.ident.decode(parameter.slice(from, to));
|
|
141
|
-
offset = to;
|
|
142
|
-
}
|
|
143
|
-
if (type === Tree.tokenTypes.Function ||
|
|
144
|
-
type === Tree.tokenTypes.LeftParenthesis)
|
|
145
|
-
depth++;
|
|
146
|
-
if (type === Tree.tokenTypes.RightParenthesis)
|
|
147
|
-
depth--;
|
|
148
|
-
if (type === Tree.tokenTypes.Colon && depth === 0 && colon < 0)
|
|
149
|
-
colon = from;
|
|
150
|
-
});
|
|
151
|
-
if (!name.startsWith('--') || name.length <= 2 || names.has(name))
|
|
152
|
-
throw new Error('CSS function parameters require unique dashed names.');
|
|
153
|
-
names.add(name);
|
|
154
|
-
const syntax = parameter.slice(offset, colon < 0 ? undefined : colon).trim() || '*';
|
|
155
|
-
if (!FunctionSyntax.accepts(syntax))
|
|
156
|
-
throw new Error('Invalid CSS function parameter syntax.');
|
|
157
|
-
if (colon >= 0)
|
|
158
|
-
value(syntax, parameter.slice(colon + 1));
|
|
159
|
-
}
|
|
160
|
-
const returns = prelude.slice(closing + 1).trim();
|
|
161
|
-
if (returns &&
|
|
162
|
-
(!returns.startsWith('returns ') ||
|
|
163
|
-
!FunctionSyntax.accepts(returns.slice(8))))
|
|
164
|
-
throw new Error('Invalid CSS function return syntax.');
|
|
165
|
-
function body(block) {
|
|
166
|
-
const declarations = Tree.parse(Tree.generate(block).slice(1, -1), {
|
|
167
|
-
context: 'declarationList',
|
|
168
|
-
});
|
|
169
|
-
declarations.children.forEach((node) => {
|
|
170
|
-
if (node.type === 'Atrule' &&
|
|
171
|
-
['media', 'supports', 'container'].includes(node.name) &&
|
|
172
|
-
node.block &&
|
|
173
|
-
node.prelude) {
|
|
174
|
-
if (Tree.lexer.matchAtrulePrelude(node.name, Tree.generate(node.prelude)).error)
|
|
175
|
-
throw new Error('Invalid CSS function condition.');
|
|
176
|
-
body(node.block);
|
|
177
|
-
}
|
|
178
|
-
else if (node.type === 'Declaration' &&
|
|
179
|
-
!node.important &&
|
|
180
|
-
(node.property === 'result' || node.property.startsWith('--'))) {
|
|
181
|
-
value('*', Tree.generate(node.value));
|
|
182
|
-
}
|
|
183
|
-
else
|
|
184
|
-
throw new Error('Invalid CSS function body context.');
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
body(rule.block);
|
|
188
|
-
},
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
//# sourceMappingURL=Functions.js.map
|
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KAAK,CAAC,iCAAiC,CAAC,CAAA;wBACpD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;oBAClB,CAAC;yBAAM,IACL,IAAI,CAAC,IAAI,KAAK,aAAa;wBAC3B,CAAC,IAAI,CAAC,SAAS;wBACf,CAAC,IAAI,CAAC,QAAQ,KAAK,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAC9D,CAAC;wBACD,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;oBACvC,CAAC;;wBAAM,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;gBAC9D,CAAC,CAAC,CAAA;YACJ,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAClB,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** Rejects invalid ordinary offsets and importance in transported keyframes. */
|
|
2
|
-
export declare function validate(source: string): void;
|
|
3
|
-
/** Named timeline percentages are unrestricted; ordinary offsets remain within 0–100%. */
|
|
4
|
-
export declare function accepts(selector: string): boolean;
|
|
5
|
-
//# sourceMappingURL=Keyframes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Keyframes.d.ts","sourceRoot":"","sources":["../../../src/compiler/internal/Keyframes.ts"],"names":[],"mappings":"AAGA,gFAAgF;AAChF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAsB7C;AAED,0FAA0F;AAC1F,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAgCjD"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/** Checks complete keyframe selectors, including named timeline ranges. @module */
|
|
2
|
-
import * as Lightning from 'lightningcss';
|
|
3
|
-
/** Rejects invalid ordinary offsets and importance in transported keyframes. */
|
|
4
|
-
export function validate(source) {
|
|
5
|
-
Lightning.transform({
|
|
6
|
-
filename: 'keyframes.css',
|
|
7
|
-
code: new TextEncoder().encode(source),
|
|
8
|
-
visitor: {
|
|
9
|
-
Rule(rule) {
|
|
10
|
-
if (rule.type !== 'keyframes')
|
|
11
|
-
return;
|
|
12
|
-
for (const frame of rule.value.keyframes) {
|
|
13
|
-
if (frame.selectors.some((selector) => selector.type === 'percentage' &&
|
|
14
|
-
(selector.value < 0 || selector.value > 1)))
|
|
15
|
-
throw new Error('Ordinary keyframe offsets must be within 0–100%.');
|
|
16
|
-
if (frame.declarations.importantDeclarations?.length)
|
|
17
|
-
throw new Error('Keyframes forbid important declarations.');
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
/** Named timeline percentages are unrestricted; ordinary offsets remain within 0–100%. */
|
|
24
|
-
export function accepts(selector) {
|
|
25
|
-
try {
|
|
26
|
-
let valid = false;
|
|
27
|
-
Lightning.transform({
|
|
28
|
-
filename: 'keyframe.css',
|
|
29
|
-
code: new TextEncoder().encode(`@keyframes zyzz {${selector}{opacity:0}}`),
|
|
30
|
-
visitor: {
|
|
31
|
-
StyleSheet(sheet) {
|
|
32
|
-
const rule = sheet.rules[0];
|
|
33
|
-
if (sheet.rules.length !== 1 ||
|
|
34
|
-
rule?.type !== 'keyframes' ||
|
|
35
|
-
rule.value.keyframes.length !== 1)
|
|
36
|
-
return;
|
|
37
|
-
const frame = rule.value.keyframes[0];
|
|
38
|
-
valid =
|
|
39
|
-
frame.selectors.length > 0 &&
|
|
40
|
-
frame.selectors.every((selector) => selector.type !== 'percentage' ||
|
|
41
|
-
(selector.value >= 0 && selector.value <= 1));
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
return valid;
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=Keyframes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Keyframes.js","sourceRoot":"","sources":["../../../src/compiler/internal/Keyframes.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,OAAO,KAAK,SAAS,MAAM,cAAc,CAAA;AAEzC,gFAAgF;AAChF,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,SAAS,CAAC,SAAS,CAAC;QAClB,QAAQ,EAAE,eAAe;QACzB,IAAI,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;QACtC,OAAO,EAAE;YACP,IAAI,CAAC,IAAI;gBACP,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW;oBAAE,OAAM;gBACrC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;oBACzC,IACE,KAAK,CAAC,SAAS,CAAC,IAAI,CAClB,CAAC,QAAQ,EAAE,EAAE,CACX,QAAQ,CAAC,IAAI,KAAK,YAAY;wBAC9B,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,IAAI,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,CAC7C;wBAED,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;oBACrE,IAAI,KAAK,CAAC,YAAY,CAAC,qBAAqB,EAAE,MAAM;wBAClD,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;gBAC/D,CAAC;YACH,CAAC;SACF;KACF,CAAC,CAAA;AACJ,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,OAAO,CAAC,QAAgB;IACtC,IAAI,CAAC;QACH,IAAI,KAAK,GAAG,KAAK,CAAA;QACjB,SAAS,CAAC,SAAS,CAAC;YAClB,QAAQ,EAAE,cAAc;YACxB,IAAI,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAC5B,oBAAoB,QAAQ,cAAc,CAC3C;YACD,OAAO,EAAE;gBACP,UAAU,CAAC,KAAK;oBACd,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;oBAC3B,IACE,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;wBACxB,IAAI,EAAE,IAAI,KAAK,WAAW;wBAC1B,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;wBAEjC,OAAM;oBACR,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAE,CAAA;oBACtC,KAAK;wBACH,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;4BAC1B,KAAK,CAAC,SAAS,CAAC,KAAK,CACnB,CAAC,QAAQ,EAAE,EAAE,CACX,QAAQ,CAAC,IAAI,KAAK,YAAY;gCAC9B,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,IAAI,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC,CAC/C,CAAA;gBACL,CAAC;aACF;SACF,CAAC,CAAA;QACF,OAAO,KAAK,CAAA;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** Derives emitted names from authored bindings rather than source locations. @module */
|
|
2
|
-
import type * as Ast from '@oxc-project/types';
|
|
3
|
-
/** Collects readable declaration paths for calls in constants and namespaces. */
|
|
4
|
-
export declare function collect(program: Ast.Program): ReadonlyMap<number, string>;
|
|
5
|
-
//# sourceMappingURL=Names.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Names.d.ts","sourceRoot":"","sources":["../../../src/compiler/internal/Names.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,OAAO,KAAK,KAAK,GAAG,MAAM,oBAAoB,CAAA;AAI9C,iFAAiF;AACjF,wBAAgB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAyCzE"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as Walker from 'oxc-walker';
|
|
2
|
-
import * as Identity from '../../internal/Identity.js';
|
|
3
|
-
/** Collects readable declaration paths for calls in constants and namespaces. */
|
|
4
|
-
export function collect(program) {
|
|
5
|
-
const names = new Map();
|
|
6
|
-
const ancestors = [];
|
|
7
|
-
Walker.walk(program, {
|
|
8
|
-
enter(node) {
|
|
9
|
-
if (node.type === 'CallExpression') {
|
|
10
|
-
const parts = [];
|
|
11
|
-
for (const ancestor of ancestors) {
|
|
12
|
-
if (ancestor.type === 'TSModuleDeclaration' &&
|
|
13
|
-
ancestor.id.type === 'Identifier')
|
|
14
|
-
parts.push(ancestor.id.name);
|
|
15
|
-
if (ancestor.type === 'VariableDeclarator' &&
|
|
16
|
-
ancestor.id.type === 'Identifier')
|
|
17
|
-
parts.push(ancestor.id.name);
|
|
18
|
-
if (ancestor.type === 'Property' && !ancestor.computed) {
|
|
19
|
-
if (ancestor.key.type === 'Identifier')
|
|
20
|
-
parts.push(ancestor.key.name);
|
|
21
|
-
else if (ancestor.key.type === 'Literal')
|
|
22
|
-
parts.push(String(ancestor.key.value));
|
|
23
|
-
}
|
|
24
|
-
if (ancestor.type === 'FunctionDeclaration' && ancestor.id)
|
|
25
|
-
parts.push(ancestor.id.name);
|
|
26
|
-
}
|
|
27
|
-
names.set(node.start, parts.length ? parts.map(Identity.name).join('-') : 'style');
|
|
28
|
-
}
|
|
29
|
-
ancestors.push(node);
|
|
30
|
-
},
|
|
31
|
-
leave() {
|
|
32
|
-
ancestors.pop();
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
return names;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=Names.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Names.js","sourceRoot":"","sources":["../../../src/compiler/internal/Names.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MA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K,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;gBAChC,CAAC;gBACD,KAAK,CAAC,GAAG,CACP,IAAI,CAAC,KAAK,EACV,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAC5D,CAAA;YACH,CAAC;YACD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACtB,CAAC;QACD,KAAK;YACH,SAAS,CAAC,GAAG,EAAE,CAAA;QACjB,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type * as Native from '../Native.js';
|
|
2
|
-
import type * as Recipe from '../../internal/Recipe.js';
|
|
3
|
-
import type * as Runtime from '../../runtime/NativeDynamic.js';
|
|
4
|
-
import * as Scalar from '../../react-native/internal/Scalar.js';
|
|
5
|
-
import type * as Source from '../Source.js';
|
|
6
|
-
import type * as Static from '../../runtime/NativeStatic.js';
|
|
7
|
-
import * as StyleSheet from '../../react-native/StyleSheet.js';
|
|
8
|
-
import * as Token from '../../internal/Token.js';
|
|
9
|
-
type Step = Runtime.Program['rules'][number]['steps'][number];
|
|
10
|
-
type PreparedStep = Extract<Step, {
|
|
11
|
-
readonly style: string;
|
|
12
|
-
}> | {
|
|
13
|
-
readonly property: keyof typeof Scalar.properties;
|
|
14
|
-
readonly parts: readonly (string | number | Token.Reference | {
|
|
15
|
-
readonly slot: string;
|
|
16
|
-
readonly number?: true;
|
|
17
|
-
})[];
|
|
18
|
-
};
|
|
19
|
-
type PreparedRule = {
|
|
20
|
-
readonly matches: Runtime.Program['rules'][number]['matches'];
|
|
21
|
-
readonly steps: readonly PreparedStep[];
|
|
22
|
-
};
|
|
23
|
-
/** Compiles static fragments and retains scalar assignments in authored order. */
|
|
24
|
-
export declare function compile(recipe: Recipe.Definition, call: Pick<Source.Call, 'slots' | 'recipe'>, options: Native.compile.Options, prepared?: {
|
|
25
|
-
axes: Readonly<Record<string, readonly string[]>>;
|
|
26
|
-
defaults: Readonly<Record<string, string | null>>;
|
|
27
|
-
payloads?: readonly import("../../runtime/Recipe.js").Payload[];
|
|
28
|
-
defaultPayloads?: {
|
|
29
|
-
readonly [axis: string]: {
|
|
30
|
-
readonly [field: string]: string | number;
|
|
31
|
-
};
|
|
32
|
-
} | undefined;
|
|
33
|
-
fonts: Readonly<Record<string, string>> | undefined;
|
|
34
|
-
units: {
|
|
35
|
-
readonly px?: number | undefined;
|
|
36
|
-
readonly rem?: number | undefined;
|
|
37
|
-
} | undefined;
|
|
38
|
-
program: {
|
|
39
|
-
slots: {
|
|
40
|
-
[k: string]: `--${string}`;
|
|
41
|
-
};
|
|
42
|
-
rules: PreparedRule[];
|
|
43
|
-
};
|
|
44
|
-
styles: Readonly<Record<string, Readonly<Record<StyleSheet.ColorScheme, Readonly<Record<string, Readonly<import("../../internal/NativeProperties.js").Output>>>>>>>;
|
|
45
|
-
}): Runtime.create.Options;
|
|
46
|
-
/** Removes dynamic instructions and resolves absolute line heights before publication. */
|
|
47
|
-
export declare function finite(options: Runtime.create.Options): Static.create.Options;
|
|
48
|
-
/** Prepares immutable programs and all set/scheme tables before selection. */
|
|
49
|
-
export declare function prepare(recipe: Recipe.Definition, call: Pick<Source.Call, 'slots' | 'recipe'>, options: Native.compile.Options): {
|
|
50
|
-
axes: Readonly<Record<string, readonly string[]>>;
|
|
51
|
-
defaults: Readonly<Record<string, string | null>>;
|
|
52
|
-
payloads?: readonly import("../../runtime/Recipe.js").Payload[];
|
|
53
|
-
defaultPayloads?: {
|
|
54
|
-
readonly [axis: string]: {
|
|
55
|
-
readonly [field: string]: string | number;
|
|
56
|
-
};
|
|
57
|
-
} | undefined;
|
|
58
|
-
fonts: Readonly<Record<string, string>> | undefined;
|
|
59
|
-
units: {
|
|
60
|
-
readonly px?: number | undefined;
|
|
61
|
-
readonly rem?: number | undefined;
|
|
62
|
-
} | undefined;
|
|
63
|
-
program: {
|
|
64
|
-
slots: {
|
|
65
|
-
[k: string]: `--${string}`;
|
|
66
|
-
};
|
|
67
|
-
rules: PreparedRule[];
|
|
68
|
-
};
|
|
69
|
-
styles: Readonly<Record<string, Readonly<Record<StyleSheet.ColorScheme, Readonly<Record<string, Readonly<import("../../internal/NativeProperties.js").Output>>>>>>>;
|
|
70
|
-
};
|
|
71
|
-
export {};
|
|
72
|
-
//# sourceMappingURL=NativeBindings.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NativeBindings.d.ts","sourceRoot":"","sources":["../../../src/compiler/internal/NativeBindings.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,KAAK,MAAM,MAAM,0BAA0B,CAAA;AACvD,OAAO,KAAK,KAAK,OAAO,MAAM,gCAAgC,CAAA;AAC9D,OAAO,KAAK,MAAM,MAAM,uCAAuC,CAAA;AAC/D,OAAO,KAAK,KAAK,MAAM,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,KAAK,MAAM,MAAM,+BAA+B,CAAA;AAE5D,OAAO,KAAK,UAAU,MAAM,kCAAkC,CAAA;AAC9D,OAAO,KAAK,KAAK,MAAM,yBAAyB,CAAA;AAGhD,KAAK,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAA;AAC7D,KAAK,YAAY,GACb,OAAO,CAAC,IAAI,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GACzC;IACE,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,MAAM,CAAC,UAAU,CAAA;IACjD,QAAQ,CAAC,KAAK,EAAE,SAAS,CACrB,MAAM,GACN,MAAM,GACN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