zyzz 0.0.3 → 0.0.5
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/README.md +34 -19
- package/dist/Config.d.ts +16 -167
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +7 -246
- package/dist/Config.js.map +1 -1
- package/dist/Style.d.ts +15 -12
- package/dist/Style.d.ts.map +1 -1
- package/dist/Style.js +51 -26
- package/dist/Style.js.map +1 -1
- package/dist/Vars.d.ts +114 -0
- package/dist/Vars.d.ts.map +1 -0
- package/dist/Vars.js +42 -0
- package/dist/Vars.js.map +1 -0
- package/dist/compiler/Graph.js +11 -8
- package/dist/compiler/Graph.js.map +1 -1
- package/dist/compiler/Native.d.ts +5 -5
- package/dist/compiler/Native.d.ts.map +1 -1
- package/dist/compiler/Native.js +21 -21
- package/dist/compiler/Native.js.map +1 -1
- package/dist/compiler/Source.d.ts +8 -6
- package/dist/compiler/Source.d.ts.map +1 -1
- package/dist/compiler/Source.js +47 -14
- package/dist/compiler/Source.js.map +1 -1
- package/dist/compiler/Transform.d.ts +1 -1
- package/dist/compiler/Transform.d.ts.map +1 -1
- package/dist/compiler/Transform.js +58 -22
- package/dist/compiler/Transform.js.map +1 -1
- package/dist/compiler/internal/Compositions.d.ts +5 -0
- package/dist/compiler/internal/Compositions.d.ts.map +1 -1
- package/dist/compiler/internal/Compositions.js +22 -3
- package/dist/compiler/internal/Compositions.js.map +1 -1
- package/dist/compiler/internal/Configurations.d.ts.map +1 -1
- package/dist/compiler/internal/Configurations.js +73 -12
- package/dist/compiler/internal/Configurations.js.map +1 -1
- package/dist/compiler/internal/Contract.d.ts +1 -1
- package/dist/compiler/internal/Contract.d.ts.map +1 -1
- package/dist/compiler/internal/Contract.js +155 -13
- package/dist/compiler/internal/Contract.js.map +1 -1
- package/dist/compiler/internal/Contributions.js +1 -1
- package/dist/compiler/internal/Contributions.js.map +1 -1
- package/dist/compiler/internal/Dynamic.js +1 -1
- package/dist/compiler/internal/Dynamic.js.map +1 -1
- package/dist/compiler/internal/Expression.d.ts +3 -0
- package/dist/compiler/internal/Expression.d.ts.map +1 -1
- package/dist/compiler/internal/Expression.js +21 -0
- package/dist/compiler/internal/Expression.js.map +1 -1
- package/dist/compiler/internal/Identifiers.d.ts +1 -1
- package/dist/compiler/internal/Identifiers.d.ts.map +1 -1
- package/dist/compiler/internal/Identifiers.js +2 -2
- package/dist/compiler/internal/Identifiers.js.map +1 -1
- package/dist/compiler/internal/NativeBindings.d.ts +1 -1
- package/dist/compiler/internal/NativeBindings.d.ts.map +1 -1
- package/dist/compiler/internal/NativeBindings.js +3 -3
- package/dist/compiler/internal/NativeBindings.js.map +1 -1
- package/dist/compiler/internal/PackedStyles.d.ts +1 -1
- package/dist/compiler/internal/PackedStyles.d.ts.map +1 -1
- package/dist/compiler/internal/PackedStyles.js +15 -25
- package/dist/compiler/internal/PackedStyles.js.map +1 -1
- package/dist/compiler/internal/Recipes.js +1 -1
- package/dist/compiler/internal/Recipes.js.map +1 -1
- package/dist/compiler/internal/Selectors.js +1 -1
- package/dist/compiler/internal/Selectors.js.map +1 -1
- package/dist/compiler/internal/Themes.d.ts +12 -3
- package/dist/compiler/internal/Themes.d.ts.map +1 -1
- package/dist/compiler/internal/Themes.js +192 -52
- package/dist/compiler/internal/Themes.js.map +1 -1
- package/dist/compiler/internal/{Variables.d.ts → Vars.d.ts} +1 -1
- package/dist/compiler/internal/Vars.d.ts.map +1 -0
- package/dist/compiler/internal/{Variables.js → Vars.js} +3 -3
- package/dist/compiler/internal/Vars.js.map +1 -0
- package/dist/default.d.ts +147 -2562
- package/dist/default.d.ts.map +1 -1
- package/dist/default.js +85 -80
- package/dist/default.js.map +2 -2
- package/dist/default.js.zyzz.json +1 -1
- package/dist/esbuild/index.d.ts +3 -0
- package/dist/esbuild/index.d.ts.map +1 -0
- package/dist/esbuild/index.js +5 -0
- package/dist/esbuild/index.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/internal/Authoring.d.ts +1 -1
- package/dist/internal/Authoring.d.ts.map +1 -1
- package/dist/internal/Authoring.js +4 -4
- package/dist/internal/Authoring.js.map +1 -1
- package/dist/internal/Binding.d.ts +1 -1
- package/dist/internal/Binding.d.ts.map +1 -1
- package/dist/internal/Completion.d.ts +19 -0
- package/dist/internal/Completion.d.ts.map +1 -0
- package/dist/internal/Completion.js +2 -0
- package/dist/internal/Completion.js.map +1 -0
- package/dist/internal/Condition.d.ts +3 -1
- package/dist/internal/Condition.d.ts.map +1 -1
- package/dist/internal/Condition.js.map +1 -1
- package/dist/internal/Configuration.d.ts +248 -0
- package/dist/internal/Configuration.d.ts.map +1 -0
- package/dist/internal/Configuration.js +343 -0
- package/dist/internal/Configuration.js.map +1 -0
- package/dist/{Theme.d.ts → internal/Theme.d.ts} +15 -13
- package/dist/internal/Theme.d.ts.map +1 -0
- package/dist/{Theme.js → internal/Theme.js} +39 -12
- package/dist/internal/Theme.js.map +1 -0
- package/dist/internal/Token.d.ts +46 -16
- package/dist/internal/Token.d.ts.map +1 -1
- package/dist/internal/Token.js +89 -5
- package/dist/internal/Token.js.map +1 -1
- package/dist/internal/Typography.d.ts +13 -5
- package/dist/internal/Typography.d.ts.map +1 -1
- package/dist/internal/Typography.js +42 -6
- package/dist/internal/Typography.js.map +1 -1
- package/dist/internal/Value.d.ts +6 -1
- package/dist/internal/Value.d.ts.map +1 -1
- package/dist/internal/Value.js.map +1 -1
- package/dist/internal/VariableSets.d.ts +20 -0
- package/dist/internal/VariableSets.d.ts.map +1 -0
- package/dist/internal/VariableSets.js +317 -0
- package/dist/internal/VariableSets.js.map +1 -0
- package/dist/next/loader.js +15 -5
- package/dist/next/loader.js.map +1 -1
- package/dist/node/Host.d.ts.map +1 -1
- package/dist/node/Host.js +1 -1
- package/dist/node/Host.js.map +1 -1
- package/dist/react-native/Host.d.ts +2 -2
- package/dist/react-native/Host.d.ts.map +1 -1
- package/dist/react-native/Host.js +4 -4
- package/dist/react-native/Host.js.map +1 -1
- package/dist/react-native/StyleSheet.d.ts +9 -8
- package/dist/react-native/StyleSheet.d.ts.map +1 -1
- package/dist/react-native/StyleSheet.js +29 -23
- package/dist/react-native/StyleSheet.js.map +1 -1
- package/dist/react-native/Variants.d.ts +3 -3
- package/dist/react-native/Variants.d.ts.map +1 -1
- package/dist/react-native/Variants.js +2 -2
- package/dist/react-native/react.d.ts +1 -1
- package/dist/react-native/react.d.ts.map +1 -1
- package/dist/react-native/react.js +5 -5
- package/dist/react-native/react.js.map +1 -1
- package/dist/rollup/index.d.ts +3 -0
- package/dist/rollup/index.d.ts.map +1 -0
- package/dist/rollup/index.js +5 -0
- package/dist/rollup/index.js.map +1 -0
- package/dist/runtime/Appearance.d.ts +7 -7
- package/dist/runtime/Appearance.d.ts.map +1 -1
- package/dist/runtime/Appearance.js +15 -15
- package/dist/runtime/Appearance.js.map +1 -1
- package/dist/runtime/Dynamic.d.ts.map +1 -1
- package/dist/runtime/Dynamic.js +4 -1
- package/dist/runtime/Dynamic.js.map +1 -1
- package/dist/runtime/NativeContext.d.ts +4 -4
- package/dist/runtime/NativeContext.d.ts.map +1 -1
- package/dist/runtime/NativeContext.js +5 -5
- package/dist/runtime/NativeContext.js.map +1 -1
- package/dist/runtime/NativeDynamic.d.ts +1 -1
- package/dist/runtime/NativeDynamic.d.ts.map +1 -1
- package/dist/runtime/NativeDynamic.js.map +1 -1
- package/dist/runtime/Props.d.ts +1 -1
- package/dist/runtime/Props.js +3 -3
- package/dist/runtime/Props.js.map +1 -1
- package/dist/runtime/Selection.d.ts +14 -10
- package/dist/runtime/Selection.d.ts.map +1 -1
- package/dist/runtime/Selection.js +19 -18
- package/dist/runtime/Selection.js.map +1 -1
- package/dist/styleFunction.d.ts +14 -14
- package/dist/styleFunction.d.ts.map +1 -1
- package/dist/styleFunction.js.map +1 -1
- package/dist/unplugin/index.d.ts +20 -0
- package/dist/unplugin/index.d.ts.map +1 -0
- package/dist/unplugin/index.js +498 -0
- package/dist/unplugin/index.js.map +1 -0
- package/dist/variants.d.ts +3 -3
- package/dist/variants.d.ts.map +1 -1
- package/dist/variants.js.map +1 -1
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +6 -3
- package/dist/vite/index.js.map +1 -1
- package/dist/web/Css.d.ts +4 -3
- package/dist/web/Css.d.ts.map +1 -1
- package/dist/web/Css.js +4 -4
- package/dist/web/Css.js.map +1 -1
- package/dist/web/internal/Themes.d.ts +3 -2
- package/dist/web/internal/Themes.d.ts.map +1 -1
- package/dist/web/internal/Themes.js +42 -6
- package/dist/web/internal/Themes.js.map +1 -1
- package/dist/webpack/index.d.ts +3 -0
- package/dist/webpack/index.d.ts.map +1 -0
- package/dist/webpack/index.js +5 -0
- package/dist/webpack/index.js.map +1 -0
- package/package.json +23 -2
- package/src/Config.ts +43 -685
- package/src/Style.ts +97 -34
- package/src/Vars.ts +299 -0
- package/src/compiler/Graph.ts +14 -9
- package/src/compiler/Native.ts +29 -32
- package/src/compiler/Source.ts +59 -21
- package/src/compiler/Transform.ts +73 -23
- package/src/compiler/internal/Compositions.ts +36 -3
- package/src/compiler/internal/Configurations.ts +83 -11
- package/src/compiler/internal/Contract.ts +207 -15
- package/src/compiler/internal/Contributions.ts +1 -1
- package/src/compiler/internal/Dynamic.ts +1 -1
- package/src/compiler/internal/Expression.ts +26 -0
- package/src/compiler/internal/Identifiers.ts +2 -1
- package/src/compiler/internal/NativeBindings.ts +3 -3
- package/src/compiler/internal/PackedStyles.ts +22 -26
- package/src/compiler/internal/Recipes.ts +1 -1
- package/src/compiler/internal/Selectors.ts +1 -1
- package/src/compiler/internal/Themes.ts +266 -57
- package/src/compiler/internal/{Variables.ts → Vars.ts} +2 -2
- package/src/default.ts +173 -154
- package/src/esbuild/index.ts +5 -0
- package/src/index.ts +4 -4
- package/src/internal/Authoring.ts +5 -7
- package/src/internal/Binding.ts +1 -1
- package/src/internal/Completion.ts +42 -0
- package/src/internal/Condition.ts +31 -1
- package/src/internal/Configuration.ts +970 -0
- package/src/{Theme.ts → internal/Theme.ts} +75 -20
- package/src/internal/Token.ts +258 -85
- package/src/internal/Typography.ts +71 -16
- package/src/internal/Value.ts +45 -26
- package/src/internal/VariableSets.ts +458 -0
- package/src/next/loader.ts +19 -5
- package/src/node/Host.ts +1 -2
- package/src/react-native/Host.ts +6 -6
- package/src/react-native/StyleSheet.ts +49 -42
- package/src/react-native/Variants.ts +3 -3
- package/src/react-native/react.ts +6 -6
- package/src/rollup/index.ts +5 -0
- package/src/runtime/Appearance.ts +20 -20
- package/src/runtime/Dynamic.ts +4 -1
- package/src/runtime/NativeContext.ts +8 -8
- package/src/runtime/NativeDynamic.ts +2 -4
- package/src/runtime/Props.ts +3 -3
- package/src/runtime/Selection.ts +44 -33
- package/src/styleFunction.ts +22 -19
- package/src/unplugin/index.ts +600 -0
- package/src/variants.ts +7 -5
- package/src/vite/index.ts +5 -4
- package/src/web/Css.ts +10 -7
- package/src/web/internal/Themes.ts +52 -9
- package/src/webpack/index.ts +5 -0
- package/dist/Theme.d.ts.map +0 -1
- package/dist/Theme.js.map +0 -1
- package/dist/compiler/internal/Variables.d.ts.map +0 -1
- package/dist/compiler/internal/Variables.js.map +0 -1
|
@@ -4,7 +4,33 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type * as Ast from '@oxc-project/types'
|
|
6
6
|
import * as Binding from '../../internal/Binding.js'
|
|
7
|
+
import * as Literal from '../../internal/Literal.js'
|
|
7
8
|
import * as Token from '../../internal/Token.js'
|
|
9
|
+
import * as Tree from 'css-tree'
|
|
10
|
+
|
|
11
|
+
/** Checks color substitutions inside compound CSS values without widening direct reference domains. */
|
|
12
|
+
export function acceptsColor(
|
|
13
|
+
expression: Token.Expression,
|
|
14
|
+
property: keyof Literal.Properties,
|
|
15
|
+
): boolean {
|
|
16
|
+
const value = expression.parts
|
|
17
|
+
.map((part) => {
|
|
18
|
+
if (typeof part === 'string') return part
|
|
19
|
+
if (Binding.is(part) ? part.type === 'color' : part.group === 'color')
|
|
20
|
+
return 'rgb(1 2 3)'
|
|
21
|
+
return 'var(--zyzz-reference)'
|
|
22
|
+
})
|
|
23
|
+
.join('')
|
|
24
|
+
.replace(/ !important$/, '')
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
return (
|
|
28
|
+
Tree.lexer.matchProperty(Literal.name(property), value).error === null
|
|
29
|
+
)
|
|
30
|
+
} catch {
|
|
31
|
+
return false
|
|
32
|
+
}
|
|
33
|
+
}
|
|
8
34
|
|
|
9
35
|
/** Folds cooked template text and literal primitive substitutions; unresolved syntax returns undefined. */
|
|
10
36
|
export function template(
|
|
@@ -99,8 +99,9 @@ export function read(value: string): string | undefined {
|
|
|
99
99
|
/** Reads an explicit authoring identity shared with uncompiled execution. */
|
|
100
100
|
export function explicit(
|
|
101
101
|
call: import('@oxc-project/types').CallExpression,
|
|
102
|
+
index = 1,
|
|
102
103
|
): string | undefined {
|
|
103
|
-
const argument = call.arguments[
|
|
104
|
+
const argument = call.arguments[index]
|
|
104
105
|
if (!argument) return undefined
|
|
105
106
|
if (argument.type !== 'ObjectExpression' || argument.properties.length !== 1)
|
|
106
107
|
throw new Error('Definition options require one literal id.')
|
|
@@ -19,13 +19,13 @@ export function compile(
|
|
|
19
19
|
return {
|
|
20
20
|
...prepared,
|
|
21
21
|
styles: StyleSheet.select(prepared.styles, {
|
|
22
|
-
|
|
22
|
+
set: options.set ?? 'default',
|
|
23
23
|
colorScheme: options.colorScheme,
|
|
24
24
|
}),
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
/** Prepares immutable programs and all
|
|
28
|
+
/** Prepares immutable programs and all set/scheme tables before selection. */
|
|
29
29
|
export function prepare(
|
|
30
30
|
recipe: Recipe.Definition,
|
|
31
31
|
call: Pick<Source.Call, 'slots' | 'recipe'>,
|
|
@@ -131,7 +131,7 @@ export function prepare(
|
|
|
131
131
|
styles: { styles: fragments },
|
|
132
132
|
fonts: options.fonts,
|
|
133
133
|
platform: options.platform,
|
|
134
|
-
|
|
134
|
+
vars: options.vars,
|
|
135
135
|
units: options.units,
|
|
136
136
|
})
|
|
137
137
|
return {
|
|
@@ -8,7 +8,7 @@ import * as ConditionalRecipe from '../../runtime/ConditionalRecipe.js'
|
|
|
8
8
|
import * as Literal from '../../internal/Literal.js'
|
|
9
9
|
import type * as Source from '../Source.js'
|
|
10
10
|
import type * as Style from '../../Style.js'
|
|
11
|
-
import type * as Theme from '../../Theme.js'
|
|
11
|
+
import type * as Theme from '../../internal/Theme.js'
|
|
12
12
|
import * as Token from '../../internal/Token.js'
|
|
13
13
|
|
|
14
14
|
/** Portable composition inputs; selection behavior remains in the compiled callable. */
|
|
@@ -94,11 +94,10 @@ export function read(
|
|
|
94
94
|
)
|
|
95
95
|
// Catalog themes share identities and paths but retain distinct fallback values.
|
|
96
96
|
tokens.set(
|
|
97
|
-
JSON.stringify(
|
|
98
|
-
value.contract[Token.identity],
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
]),
|
|
97
|
+
JSON.stringify(
|
|
98
|
+
[value.contract[Token.identity], value.path, value.value],
|
|
99
|
+
encode,
|
|
100
|
+
),
|
|
102
101
|
value,
|
|
103
102
|
)
|
|
104
103
|
return
|
|
@@ -320,14 +319,9 @@ export function read(
|
|
|
320
319
|
const name = string(value)
|
|
321
320
|
if (
|
|
322
321
|
!field ||
|
|
323
|
-
[
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
'className',
|
|
327
|
-
'variables',
|
|
328
|
-
'key',
|
|
329
|
-
'ref',
|
|
330
|
-
].includes(field) ||
|
|
322
|
+
['__proto__', 'style', 'className', 'vars', 'key', 'ref'].includes(
|
|
323
|
+
field,
|
|
324
|
+
) ||
|
|
331
325
|
!slots.includes(name)
|
|
332
326
|
)
|
|
333
327
|
throw new Error('Invalid packed dynamic slot.')
|
|
@@ -430,22 +424,24 @@ export function write(definition: Definition): unknown {
|
|
|
430
424
|
cssOutput: definition.style.cssOutput ?? 'atomic',
|
|
431
425
|
},
|
|
432
426
|
},
|
|
433
|
-
|
|
434
|
-
if (Token.is(value))
|
|
435
|
-
return {
|
|
436
|
-
identity: value.contract[Token.identity],
|
|
437
|
-
kind: 'token',
|
|
438
|
-
path: value.path,
|
|
439
|
-
value: value.value,
|
|
440
|
-
}
|
|
441
|
-
if (Token.isExpression(value))
|
|
442
|
-
return { kind: 'expression', parts: value.parts }
|
|
443
|
-
return value
|
|
444
|
-
},
|
|
427
|
+
encode,
|
|
445
428
|
),
|
|
446
429
|
)
|
|
447
430
|
}
|
|
448
431
|
|
|
432
|
+
function encode(_: string, value: unknown): unknown {
|
|
433
|
+
if (Token.is(value))
|
|
434
|
+
return {
|
|
435
|
+
identity: value.contract[Token.identity],
|
|
436
|
+
kind: 'token',
|
|
437
|
+
path: value.path,
|
|
438
|
+
value: value.value,
|
|
439
|
+
}
|
|
440
|
+
if (Token.isExpression(value))
|
|
441
|
+
return { kind: 'expression', parts: value.parts }
|
|
442
|
+
return value
|
|
443
|
+
}
|
|
444
|
+
|
|
449
445
|
function array(value: unknown): unknown[] {
|
|
450
446
|
if (!Array.isArray(value)) throw new Error('Expected a packed style array.')
|
|
451
447
|
return value
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type * as Ast from '@oxc-project/types'
|
|
3
3
|
import * as Walker from 'oxc-walker'
|
|
4
4
|
import * as Condition from '../../internal/Condition.js'
|
|
5
|
-
import * as Theme from '../../Theme.js'
|
|
5
|
+
import * as Theme from '../../internal/Theme.js'
|
|
6
6
|
import * as AtRules from './AtRules.js'
|
|
7
7
|
import * as Identity from '../../internal/Identity.js'
|
|
8
8
|
import * as Identifiers from './Identifiers.js'
|