zyzz 0.0.9 → 0.0.11

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.
Files changed (115) hide show
  1. package/README.md +1 -1
  2. package/dist/Style.js +2 -2
  3. package/dist/Style.js.map +1 -1
  4. package/dist/Vars.d.ts +2 -2
  5. package/dist/Vars.d.ts.map +1 -1
  6. package/dist/Vars.js.map +1 -1
  7. package/dist/compiler/Source.d.ts.map +1 -1
  8. package/dist/compiler/Source.js +10 -0
  9. package/dist/compiler/Source.js.map +1 -1
  10. package/dist/compiler/internal/Contract.d.ts.map +1 -1
  11. package/dist/compiler/internal/Contract.js +11 -6
  12. package/dist/compiler/internal/Contract.js.map +1 -1
  13. package/dist/compiler/internal/Contributions.d.ts.map +1 -1
  14. package/dist/compiler/internal/Contributions.js +592 -556
  15. package/dist/compiler/internal/Contributions.js.map +1 -1
  16. package/dist/compiler/internal/Expression.d.ts +4 -0
  17. package/dist/compiler/internal/Expression.d.ts.map +1 -1
  18. package/dist/compiler/internal/Expression.js +45 -0
  19. package/dist/compiler/internal/Expression.js.map +1 -1
  20. package/dist/compiler/internal/RecipeConditions.js +2 -2
  21. package/dist/compiler/internal/RecipeConditions.js.map +1 -1
  22. package/dist/compiler/internal/Themes.d.ts.map +1 -1
  23. package/dist/compiler/internal/Themes.js +2 -0
  24. package/dist/compiler/internal/Themes.js.map +1 -1
  25. package/dist/default.d.ts +75 -19
  26. package/dist/default.d.ts.map +1 -1
  27. package/dist/default.js +76 -11
  28. package/dist/default.js.map +2 -2
  29. package/dist/default.js.zyzz.json +1 -1
  30. package/dist/internal/Condition.d.ts +1 -1
  31. package/dist/internal/Condition.d.ts.map +1 -1
  32. package/dist/internal/Configuration.js +2 -2
  33. package/dist/internal/Configuration.js.map +1 -1
  34. package/dist/internal/Query.d.ts +2 -2
  35. package/dist/internal/Query.d.ts.map +1 -1
  36. package/dist/internal/Query.js +1 -1
  37. package/dist/internal/Query.js.map +1 -1
  38. package/dist/internal/Theme.d.ts +4 -4
  39. package/dist/internal/Theme.d.ts.map +1 -1
  40. package/dist/internal/Theme.js +6 -6
  41. package/dist/internal/Theme.js.map +1 -1
  42. package/dist/internal/Token.d.ts +185 -2
  43. package/dist/internal/Token.d.ts.map +1 -1
  44. package/dist/internal/Token.js +236 -23
  45. package/dist/internal/Token.js.map +1 -1
  46. package/dist/internal/VariableSets.d.ts.map +1 -1
  47. package/dist/internal/VariableSets.js +9 -6
  48. package/dist/internal/VariableSets.js.map +1 -1
  49. package/dist/unplugin/index.d.ts.map +1 -1
  50. package/dist/unplugin/index.js +14 -0
  51. package/dist/unplugin/index.js.map +1 -1
  52. package/dist/web/colorProfile.d.ts +9 -5
  53. package/dist/web/colorProfile.d.ts.map +1 -1
  54. package/dist/web/colorProfile.js.map +1 -1
  55. package/dist/web/counterStyle.d.ts +13 -9
  56. package/dist/web/counterStyle.d.ts.map +1 -1
  57. package/dist/web/counterStyle.js.map +1 -1
  58. package/dist/web/cssFunction.d.ts +19 -14
  59. package/dist/web/cssFunction.d.ts.map +1 -1
  60. package/dist/web/cssFunction.js.map +1 -1
  61. package/dist/web/fontFace.d.ts +6 -1
  62. package/dist/web/fontFace.d.ts.map +1 -1
  63. package/dist/web/fontFace.js.map +1 -1
  64. package/dist/web/fontFeatureValues.d.ts +11 -7
  65. package/dist/web/fontFeatureValues.d.ts.map +1 -1
  66. package/dist/web/fontFeatureValues.js.map +1 -1
  67. package/dist/web/fontPaletteValues.d.ts +8 -3
  68. package/dist/web/fontPaletteValues.d.ts.map +1 -1
  69. package/dist/web/fontPaletteValues.js.map +1 -1
  70. package/dist/web/internal/Context.d.ts +3 -3
  71. package/dist/web/internal/Context.d.ts.map +1 -1
  72. package/dist/web/keyframes.d.ts +7 -3
  73. package/dist/web/keyframes.d.ts.map +1 -1
  74. package/dist/web/keyframes.js.map +1 -1
  75. package/dist/web/page.d.ts +11 -4
  76. package/dist/web/page.d.ts.map +1 -1
  77. package/dist/web/page.js.map +1 -1
  78. package/dist/web/positionTry.d.ts +6 -1
  79. package/dist/web/positionTry.d.ts.map +1 -1
  80. package/dist/web/positionTry.js.map +1 -1
  81. package/dist/web/property.d.ts +10 -5
  82. package/dist/web/property.d.ts.map +1 -1
  83. package/dist/web/property.js.map +1 -1
  84. package/dist/web/viewTransition.d.ts +10 -6
  85. package/dist/web/viewTransition.d.ts.map +1 -1
  86. package/dist/web/viewTransition.js.map +1 -1
  87. package/package.json +1 -1
  88. package/src/Style.ts +2 -2
  89. package/src/Vars.ts +2 -3
  90. package/src/compiler/Source.ts +19 -0
  91. package/src/compiler/internal/Contract.ts +19 -8
  92. package/src/compiler/internal/Contributions.ts +734 -685
  93. package/src/compiler/internal/Expression.ts +57 -0
  94. package/src/compiler/internal/RecipeConditions.ts +2 -2
  95. package/src/compiler/internal/Themes.ts +2 -0
  96. package/src/default.ts +175 -30
  97. package/src/internal/Condition.ts +3 -3
  98. package/src/internal/Configuration.ts +2 -2
  99. package/src/internal/Query.ts +3 -3
  100. package/src/internal/Theme.ts +12 -12
  101. package/src/internal/Token.ts +253 -33
  102. package/src/internal/VariableSets.ts +28 -25
  103. package/src/unplugin/index.ts +14 -0
  104. package/src/web/colorProfile.ts +25 -10
  105. package/src/web/counterStyle.ts +29 -14
  106. package/src/web/cssFunction.ts +47 -24
  107. package/src/web/fontFace.ts +16 -3
  108. package/src/web/fontFeatureValues.ts +35 -18
  109. package/src/web/fontPaletteValues.ts +25 -11
  110. package/src/web/internal/Context.ts +9 -3
  111. package/src/web/keyframes.ts +24 -9
  112. package/src/web/page.ts +22 -5
  113. package/src/web/positionTry.ts +20 -5
  114. package/src/web/property.ts +23 -9
  115. package/src/web/viewTransition.ts +28 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zyzz",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "license": "MIT",
5
5
  "description": "Modern, universal, simple styling library for the Web and React Native",
6
6
  "repository": {
package/src/Style.ts CHANGED
@@ -459,8 +459,8 @@ export function define(
459
459
  ? Query.resolve(
460
460
  key,
461
461
  theme?.[Token.definition].queries ?? {
462
- breakpoints: {},
463
- containers: {},
462
+ breakpoint: {},
463
+ container: {},
464
464
  containerNames: [],
465
465
  },
466
466
  )
package/src/Vars.ts CHANGED
@@ -45,7 +45,7 @@ export type Definition<values extends Values = Values> = (Values extends values
45
45
  export type References<values, root extends boolean = true> = {
46
46
  readonly [key in Exclude<
47
47
  keyof values,
48
- root extends true ? 'breakpoints' | 'containers' | 'containerNames' : never
48
+ root extends true ? 'breakpoint' | 'containerNames' : never
49
49
  >]: values[key] extends Value
50
50
  ? Token.Reference<Domain<Scalar<values[key]>>> & {
51
51
  readonly [Token.scalar]: Scalar<values[key]>
@@ -184,8 +184,7 @@ export type Mappings = Readonly<
184
184
  /** Type carrier for configured shorthand lookup. */
185
185
  export type Mapped<values, mappings> = (Pick<
186
186
  values,
187
- keyof values &
188
- ('breakpoints' | 'containers' | 'containerNames' | 'typography')
187
+ keyof values & ('breakpoint' | 'container' | 'containerNames' | 'typography')
189
188
  > extends infer metadata extends Theme.Tokens
190
189
  ? metadata
191
190
  : {}) & {
@@ -31,6 +31,7 @@ import type * as Theme from '../internal/Theme.js'
31
31
  import * as Themes from './internal/Themes.js'
32
32
  import * as ThemeValues from '../web/internal/Themes.js'
33
33
  import * as Token from '../internal/Token.js'
34
+ import * as Literal from '../internal/Literal.js'
34
35
  import * as Typography from '../internal/Typography.js'
35
36
  import * as Value from '../internal/Value.js'
36
37
  import * as Vars from './internal/Vars.js'
@@ -1021,6 +1022,8 @@ export function extract(options: extract.Options): extract.ReturnType {
1021
1022
  : targets.every(
1022
1023
  (target) =>
1023
1024
  Token.acceptsReference(part, target) ||
1025
+ (part.contract.variableSet &&
1026
+ Expression.acceptsVariables(template, target)) ||
1024
1027
  (part.group === 'color' &&
1025
1028
  Expression.acceptsColor(template, target)),
1026
1029
  ))
@@ -1181,6 +1184,22 @@ export function extract(options: extract.Options): extract.ReturnType {
1181
1184
  )
1182
1185
 
1183
1186
  function validate(style: Style.NamedStyle, path: readonly string[]) {
1187
+ for (const declaration of style.declarations) {
1188
+ if (
1189
+ Token.is(declaration.value) &&
1190
+ declaration.value.contract.variableSet &&
1191
+ Literal.rule(declaration.property)?.kind === 'identifier' &&
1192
+ !Expression.acceptsIdentifier(
1193
+ declaration.value,
1194
+ declaration.property,
1195
+ )
1196
+ )
1197
+ report(
1198
+ 'invalid_literal',
1199
+ 'Variable value is incompatible with this property.',
1200
+ call,
1201
+ )
1202
+ }
1184
1203
  if (style.targets?.web)
1185
1204
  validate(style.targets.web, [...path, 'targets', 'web'])
1186
1205
  for (const rule of style.rules ?? []) {
@@ -26,7 +26,7 @@ export function read(
26
26
  if (
27
27
  ![
28
28
  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
29
- 22, 23, 24, 25, 26, 27,
29
+ 22, 23, 24, 25, 26, 27, 28,
30
30
  ].includes(data.version as number)
31
31
  )
32
32
  throw new Error('Unsupported Zyzz contract version.')
@@ -102,8 +102,8 @@ export function read(
102
102
  for (const [name, value] of Object.entries(record(data.themes))) {
103
103
  const entry = record(value)
104
104
  const identity = string(entry.identity)
105
- if (entry.variableSet === true && (data.version as number) < 26)
106
- throw new Error('Vars contracts require contract version 26 or later.')
105
+ if (entry.variableSet === true && (data.version as number) < 28)
106
+ throw new Error('Vars contracts require contract version 28 or later.')
107
107
  const mappings = VariableSets.mappings(entry.mappings)
108
108
  if (
109
109
  entry.cssOutput !== undefined &&
@@ -294,7 +294,7 @@ export function read(
294
294
  if (
295
295
  ![
296
296
  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
297
- 27,
297
+ 27, 28,
298
298
  ].includes(data.version as number) ||
299
299
  ![
300
300
  'cssFunction',
@@ -419,6 +419,14 @@ export function read(
419
419
  entry.options === undefined ? undefined : record(decode(entry.options))
420
420
 
421
421
  if (options) {
422
+ if (
423
+ entry.variableConfig === true &&
424
+ JSON.stringify(VariableSets.mappings(entry.variableMappings) ?? {}) !==
425
+ JSON.stringify(definition[Token.definition].contract.mappings ?? {})
426
+ )
427
+ throw new Error(
428
+ 'Configuration mappings disagree with linked variable metadata.',
429
+ )
422
430
  if (entry.variableConfig === true)
423
431
  Config.create(
424
432
  variableOptions(
@@ -722,16 +730,19 @@ export function write(
722
730
  if (
723
731
  Object.values(themes).some(
724
732
  (theme) =>
725
- theme[Token.definition].contract.defaultLayer !== undefined,
733
+ theme[Token.definition].contract.variableSet ||
734
+ theme[Token.definition].queries,
726
735
  )
727
736
  )
728
- return 27
737
+ return 28
738
+
729
739
  if (
730
740
  Object.values(themes).some(
731
- (theme) => theme[Token.definition].contract.variableSet,
741
+ (theme) =>
742
+ theme[Token.definition].contract.defaultLayer !== undefined,
732
743
  )
733
744
  )
734
- return 26
745
+ return 27
735
746
  if (
736
747
  Object.values(themes).some(
737
748
  (theme) =>