@yahoo/uds-v5-wip 1.61.0 → 1.62.0

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 (117) hide show
  1. package/dist/config/dist/AssetGroup.d.ts +75 -0
  2. package/dist/config/dist/AssetGroup.js +114 -0
  3. package/dist/config/dist/Component.d.ts +309 -0
  4. package/dist/config/dist/Component.js +897 -0
  5. package/dist/config/dist/ComponentGroup.d.ts +21 -0
  6. package/dist/config/dist/ComponentGroup.js +46 -0
  7. package/dist/config/dist/CompositeStyle.d.ts +28 -0
  8. package/dist/config/dist/CompositeStyle.js +52 -0
  9. package/dist/config/dist/Config.d.ts +422 -0
  10. package/dist/config/dist/Config.js +1426 -0
  11. package/dist/config/dist/Mode.d.ts +42 -0
  12. package/dist/config/dist/Mode.js +81 -0
  13. package/dist/config/dist/Modifier.d.ts +52 -0
  14. package/dist/config/dist/Modifier.js +97 -0
  15. package/dist/config/dist/MotionDef.d.ts +50 -0
  16. package/dist/config/dist/MotionDef.js +97 -0
  17. package/dist/config/dist/Props.d.ts +235 -126
  18. package/dist/config/dist/Provider.d.ts +21 -0
  19. package/dist/config/dist/Provider.js +14 -0
  20. package/dist/config/dist/StyleProp.d.ts +113 -0
  21. package/dist/config/dist/StyleProp.js +197 -0
  22. package/dist/config/dist/Token.d.ts +56 -0
  23. package/dist/config/dist/Token.js +112 -0
  24. package/dist/config/dist/TokenGroup.d.ts +33 -0
  25. package/dist/config/dist/TokenGroup.js +68 -0
  26. package/dist/config/dist/asset-kind.d.ts +56 -0
  27. package/dist/config/dist/asset-kind.js +29 -0
  28. package/dist/config/dist/brands.d.ts +31 -0
  29. package/dist/config/dist/brands.js +20 -0
  30. package/dist/config/dist/captureCallerPath.d.ts +49 -0
  31. package/dist/config/dist/captureCallerPath.js +95 -0
  32. package/dist/config/dist/colorExpressions.d.ts +132 -0
  33. package/dist/config/dist/colorExpressions.js +148 -0
  34. package/dist/config/dist/defineAssetGroup.d.ts +158 -0
  35. package/dist/config/dist/defineAssetGroup.js +263 -0
  36. package/dist/config/dist/defineProvider.d.ts +30 -0
  37. package/dist/config/dist/defineProvider.js +60 -0
  38. package/dist/config/dist/element-marker.d.ts +55 -0
  39. package/dist/config/dist/element-marker.js +113 -0
  40. package/dist/config/dist/entity-utils.d.ts +27 -0
  41. package/dist/config/dist/entity-utils.js +105 -0
  42. package/dist/config/dist/factories.d.ts +707 -0
  43. package/dist/config/dist/factories.js +393 -0
  44. package/dist/config/dist/foreign-component-name.js +42 -0
  45. package/dist/config/dist/index.d.ts +30 -21
  46. package/dist/config/dist/index.js +26 -14
  47. package/dist/config/dist/interpolate.d.ts +21 -0
  48. package/dist/config/dist/interpolate.js +10 -0
  49. package/dist/config/dist/markers.d.ts +218 -0
  50. package/dist/config/dist/markers.js +67 -0
  51. package/dist/config/dist/refs.d.ts +143 -69
  52. package/dist/config/dist/refs.js +95 -113
  53. package/dist/config/dist/token-override-rows.d.ts +67 -0
  54. package/dist/config/dist/token-override-rows.js +223 -0
  55. package/dist/config/dist/tokenValueType.js +138 -0
  56. package/dist/config/dist/types/css-properties.d.ts +132 -122
  57. package/dist/config/dist/types/css-property-keywords.d.ts +157 -0
  58. package/dist/config/dist/types/css-property-keywords.js +616 -0
  59. package/dist/config/dist/types/css-values.d.ts +18 -16
  60. package/dist/config/dist/types.d.ts +688 -66
  61. package/dist/config/dist/units.d.ts +15 -0
  62. package/dist/config/dist/units.js +16 -0
  63. package/dist/config.d.ts +31 -22
  64. package/dist/config.js +28 -16
  65. package/dist/loader/dist/loader/artifacts.js +26 -9
  66. package/dist/loader/dist/loader.d.ts +11 -23
  67. package/dist/loader/dist/loader.js +54 -99
  68. package/dist/loader/dist/next.js +3 -3
  69. package/dist/loader/dist/transform-runner.js +1 -8
  70. package/dist/loader/dist/unplugin.d.ts +2 -2
  71. package/dist/loader/dist/unplugin.js +2 -2
  72. package/dist/tsconfig.tsbuildinfo +1 -1
  73. package/dist/utils/dist/index.js +1 -0
  74. package/dist/utils/dist/motion-utils/resolveMotionState.d.ts +35 -0
  75. package/dist/utils/dist/motion-utils/resolveMotionState.js +33 -0
  76. package/dist/utils/dist/string-utils/componentClassName.d.ts +41 -8
  77. package/dist/utils/dist/string-utils/componentClassName.js +48 -11
  78. package/dist/utils.d.ts +3 -2
  79. package/dist/utils.js +3 -2
  80. package/package.json +3 -3
  81. package/dist/codegen/dist/loader/getLoaderArtifacts.js +0 -2
  82. package/dist/config/dist/bindRender.d.ts +0 -16
  83. package/dist/config/dist/bindRender.js +0 -310
  84. package/dist/config/dist/className.d.ts +0 -54
  85. package/dist/config/dist/className.js +0 -77
  86. package/dist/config/dist/component-config.d.ts +0 -862
  87. package/dist/config/dist/component-config.js +0 -163
  88. package/dist/config/dist/component-refs.d.ts +0 -121
  89. package/dist/config/dist/createConfig.d.ts +0 -456
  90. package/dist/config/dist/createConfig.js +0 -503
  91. package/dist/config/dist/createStyler.d.ts +0 -35
  92. package/dist/config/dist/createStyler.js +0 -93
  93. package/dist/config/dist/defineComponent.d.ts +0 -317
  94. package/dist/config/dist/defineComponent.js +0 -264
  95. package/dist/config/dist/defineCompositeStyle.d.ts +0 -93
  96. package/dist/config/dist/defineCompositeStyle.js +0 -18
  97. package/dist/config/dist/defineMotionConfig.d.ts +0 -152
  98. package/dist/config/dist/definePreview.d.ts +0 -45
  99. package/dist/config/dist/definePreview.js +0 -35
  100. package/dist/config/dist/defineStyleProp.d.ts +0 -289
  101. package/dist/config/dist/defineStyleProp.js +0 -61
  102. package/dist/config/dist/merge-utils.js +0 -51
  103. package/dist/config/dist/propertyAcceptedTypes.d.ts +0 -19
  104. package/dist/config/dist/propertyAcceptedTypes.js +0 -220
  105. package/dist/config/dist/resolveCompoundProps.d.ts +0 -65
  106. package/dist/config/dist/resolveCompoundProps.js +0 -120
  107. package/dist/config/dist/resolveStyleProp.d.ts +0 -157
  108. package/dist/config/dist/resolveStyleProp.js +0 -260
  109. package/dist/config/dist/runtime-registry.js +0 -37
  110. package/dist/config/dist/serialize.d.ts +0 -47
  111. package/dist/config/dist/serialize.js +0 -111
  112. package/dist/config/dist/sniffTokenType.d.ts +0 -7
  113. package/dist/config/dist/sniffTokenType.js +0 -67
  114. package/dist/config/dist/style-prop-runtime.d.ts +0 -75
  115. package/dist/config/dist/style-prop-runtime.js +0 -390
  116. package/dist/loader/dist/loader/internal-meta.js +0 -59
  117. package/dist/loader/dist/loader/lower-new-api-primitive.js +0 -252
@@ -1,122 +1,104 @@
1
- import { kebabCase } from "../../utils/dist/string-utils/kebabCase.js";
2
- import { safeTokenName } from "../../utils/dist/string-utils/cssVar.js";
3
- import "../../utils/dist/index.js";
4
1
  //#region ../config/dist/refs.js
5
- /**
6
- * Token references inside `defineVars` token values + downstream CSS
7
- * emission. Authors point one token at another via the `token()` helper:
8
- *
9
- * defineVars({
10
- * spectrum: { 'blue/500': { value: '#1167f4' } },
11
- * color: { brand: { value: token('spectrum/blue/500') } },
12
- * })
13
- *
14
- * At CSS-declaration time this expands to a CSS variable alias:
15
- *
16
- * --uds-spectrum-blue-500: #1167f4;
17
- * --uds-color-brand: var(--uds-spectrum-blue-500);
18
- *
19
- * Aliases are a purely syntactic transform — no graph walk, no cycle
20
- * detection. CSS handles aliasing (and any cascade cycles) at runtime.
21
- * Aliases pointing at unknown tokens resolve to a `var(...)` with no
22
- * `:root` declaration; the browser falls back to the property's
23
- * initial value.
24
- */
25
- /**
26
- * Resolve a token value to its CSS form. `TokenMarker` from
27
- * `token('ns/name')` becomes `var(--<prefix>-<ns>-<name>)`; string
28
- * literals pass through unchanged.
29
- *
30
- * The CSS variable name follows `defineVars`'s `:root` declaration
31
- * convention: `kebabCase` on the namespace, `safeTokenName` on the
32
- * token name.
33
- */
34
- function resolveTokenValue(value, configPrefix) {
35
- if (typeof value === "string") return value;
36
- const ref = value.ref;
37
- const slashIdx = ref.indexOf("/");
38
- if (slashIdx <= 0 || slashIdx >= ref.length - 1) return ref;
39
- return refToVar(ref.slice(0, slashIdx), ref.slice(slashIdx + 1), configPrefix);
40
- }
41
- function refToVar(namespace, name, configPrefix) {
42
- const cssPrefix = kebabCase(namespace);
43
- const cssName = safeTokenName(name);
44
- return `var(${configPrefix ? `--${configPrefix}-${cssPrefix}-${cssName}` : `--${cssPrefix}-${cssName}`})`;
45
- }
46
- /**
47
- * Type-guard: a value is a `TokenWithModifier` marker.
48
- */
49
- function isTokenWithModifier(value) {
50
- return typeof value === "object" && value !== null && "$token" in value && "$modifier" in value;
51
- }
52
- /**
53
- * Resolve a `TokenWithModifier` marker to its CSS value:
54
- * - `darken(N)` → `color-mix(in oklch, var(...), light-dark(black, white) N%)`
55
- * - `lighten(N)` → `color-mix(in oklch, var(...), light-dark(white, black) N%)`
56
- *
57
- * Output matches the runtime helpers `darker` / `lighter` in
58
- * `createConfig.ts` byte-for-byte so mechanical conversion of legacy
59
- * callback-form components preserves compiled CSS.
60
- */
61
- function resolveTokenWithModifier(marker, configPrefix) {
62
- const slashIdx = marker.$token.indexOf("/");
63
- if (slashIdx <= 0 || slashIdx >= marker.$token.length - 1) return marker.$token;
64
- const resolved = refToVar(marker.$token.slice(0, slashIdx), marker.$token.slice(slashIdx + 1), configPrefix);
65
- const amount = marker.$modifier.amount;
66
- if (marker.$modifier.type === "darken") return `color-mix(in oklch, ${resolved}, light-dark(black, white) ${amount}%)`;
67
- return `color-mix(in oklch, ${resolved}, light-dark(white, black) ${amount}%)`;
68
- }
69
- /**
70
- * Author-time helper that produces a darkened color-token reference for
71
- * use in component-config style blocks. Takes a `TokenMarker` (from
72
- * `token('ns/name')`) plus a mix amount, and returns a structured
73
- * marker (`{ $token, $modifier }`) that codegen resolves at build
74
- * time to:
75
- *
76
- * color-mix(in oklch, var(--<prefix>-<ns>-<name>),
77
- * light-dark(black, white) <amount>%)
78
- *
79
- * defineComponent
80
- * .layers({ root: 'div' })
81
- * .config(({ enums, token }) => ({
82
- * props: {
83
- * variant: enums({
84
- * brand: {
85
- * root: {
86
- * backgroundColor: token('bg/brand'),
87
- * _hover: { backgroundColor: darken(token('bg/brand'), 10) },
88
- * },
89
- * },
90
- * }),
91
- * },
92
- * }));
93
- *
94
- * The token reference stays portable across configs with different
95
- * prefixes because the prefix is supplied at codegen time, not at
96
- * author time.
97
- */
98
- function darken(ref, amount) {
2
+ function token(ref) {
99
3
  return {
100
- $token: ref.ref,
101
- $modifier: {
102
- type: "darken",
103
- amount
104
- }
4
+ __kind: "token",
5
+ ref
105
6
  };
106
7
  }
107
- /**
108
- * Author-time helper that produces a lightened color-token reference.
109
- * Mirror of `darken()` — see its JSDoc. Resolves at codegen time to
110
- * `color-mix(in oklch, var(--<prefix>-<ns>-<name>), light-dark(white, black) N%)`.
111
- */
112
- function lighten(ref, amount) {
8
+ function tokenGroup(ref) {
113
9
  return {
114
- $token: ref.ref,
115
- $modifier: {
116
- type: "lighten",
117
- amount
10
+ __kind: "tokenGroup",
11
+ ref
12
+ };
13
+ }
14
+ function composite(ref) {
15
+ return Object.assign({
16
+ __kind: "composite",
17
+ ref
18
+ }, { on(layer) {
19
+ return {
20
+ __kind: "composite",
21
+ ref,
22
+ layer
23
+ };
24
+ } });
25
+ }
26
+ function mode(ref) {
27
+ return {
28
+ __kind: "mode",
29
+ ref
30
+ };
31
+ }
32
+ function styleProp(ref) {
33
+ const marker = {
34
+ __kind: "styleProp",
35
+ ref
36
+ };
37
+ Object.defineProperty(marker, "on", {
38
+ enumerable: false,
39
+ configurable: true,
40
+ writable: true,
41
+ value(layer) {
42
+ const next = {
43
+ __kind: "styleProp",
44
+ ref,
45
+ layer
46
+ };
47
+ Object.defineProperty(next, "on", {
48
+ enumerable: false,
49
+ configurable: true,
50
+ writable: true,
51
+ value: marker.on
52
+ });
53
+ return next;
118
54
  }
55
+ });
56
+ return marker;
57
+ }
58
+ function tag(ref) {
59
+ return {
60
+ __kind: "tag",
61
+ ref
62
+ };
63
+ }
64
+ function component(ref) {
65
+ return {
66
+ __kind: "component",
67
+ ref
119
68
  };
120
69
  }
70
+ function assetGroup(ref) {
71
+ return {
72
+ __kind: "assetGroup",
73
+ ref
74
+ };
75
+ }
76
+ function isRefOf(value, kind) {
77
+ return typeof value === "object" && value !== null && value.__kind === kind;
78
+ }
79
+ function isTokenRef(value) {
80
+ return isRefOf(value, "token");
81
+ }
82
+ function isTokenGroupRef(value) {
83
+ return isRefOf(value, "tokenGroup");
84
+ }
85
+ function isCompositeRef(value) {
86
+ return isRefOf(value, "composite");
87
+ }
88
+ function isModeRef(value) {
89
+ return isRefOf(value, "mode");
90
+ }
91
+ function isStylePropRef(value) {
92
+ return isRefOf(value, "styleProp");
93
+ }
94
+ function isTagRef(value) {
95
+ return isRefOf(value, "tag");
96
+ }
97
+ function isComponentRef(value) {
98
+ return isRefOf(value, "component");
99
+ }
100
+ function isAssetGroupRef(value) {
101
+ return isRefOf(value, "assetGroup");
102
+ }
121
103
  //#endregion
122
- export { darken, isTokenWithModifier, lighten, resolveTokenValue, resolveTokenWithModifier };
104
+ export { assetGroup, component, composite, isAssetGroupRef, isComponentRef, isCompositeRef, isModeRef, isStylePropRef, isTagRef, isTokenGroupRef, isTokenRef, mode, styleProp, tag, token, tokenGroup };
@@ -0,0 +1,67 @@
1
+ import { TokenModifierKey } from "./types.js";
2
+
3
+ //#region ../config/dist/token-override-rows.d.ts
4
+ //#region src/token-override-rows.d.ts
5
+ type OverrideModeRef = `${string}.${string}`;
6
+ type ModifierTreeValue<TValue> = TValue | {
7
+ value?: TValue;
8
+ [modifier: TokenModifierKey]: ModifierTreeValue<TValue> | undefined;
9
+ };
10
+ type ModifierTree<TValue> = Partial<Record<TokenModifierKey, ModifierTreeValue<TValue>>>;
11
+ type ModifierUpdateValue<TValue> = TValue | null | ModifierUpdateObject<TValue>;
12
+ interface ModifierUpdateObject<TValue> {
13
+ value?: TValue | null;
14
+ [key: string]: ModifierUpdateValue<TValue> | undefined;
15
+ [modifier: TokenModifierKey]: ModifierUpdateValue<TValue> | undefined;
16
+ }
17
+ type ModifierUpdate<TValue> = Record<string, ModifierUpdateValue<TValue> | undefined>;
18
+ interface ModeBackedModifierInput {
19
+ modifier: TokenModifierKey;
20
+ mode: string;
21
+ option: string;
22
+ label?: string;
23
+ modeOrder: number;
24
+ optionOrder: number;
25
+ }
26
+ interface ModeBackedModifierDefinition extends ModeBackedModifierInput {
27
+ modeRef: OverrideModeRef;
28
+ }
29
+ interface ModeBackedModifierLookup {
30
+ byModifier: ReadonlyMap<TokenModifierKey, ModeBackedModifierDefinition>;
31
+ byModeRef: ReadonlyMap<OverrideModeRef, ModeBackedModifierDefinition>;
32
+ }
33
+ interface OverrideRow<TValue = string> {
34
+ modes: OverrideModeRef[];
35
+ value: TValue;
36
+ sourceModifierPath: TokenModifierKey[];
37
+ sourceOrder: number;
38
+ }
39
+ interface ModeBackedModeMetadata {
40
+ name: string;
41
+ options: readonly {
42
+ name: string;
43
+ label?: string;
44
+ }[];
45
+ }
46
+ interface ModeBackedModifierMetadata {
47
+ modifier: TokenModifierKey;
48
+ selector?: unknown;
49
+ }
50
+ declare function createModeBackedModifierLookup(inputs: readonly ModeBackedModifierInput[]): ModeBackedModifierLookup;
51
+ declare function buildModeBackedModifierLookup(modes: readonly ModeBackedModeMetadata[], modifiers: readonly ModeBackedModifierMetadata[]): ModeBackedModifierLookup;
52
+ declare function modifierTreeToOverrideRows<TValue>(modifiers: ModifierTree<TValue> | undefined, lookup: ModeBackedModifierLookup): OverrideRow<TValue>[];
53
+ declare function overrideRowsToModifierTree<TValue>(rows: readonly OverrideRow<TValue>[], lookup: ModeBackedModifierLookup): ModifierTree<TValue>;
54
+ declare function resolveOverrideRowValue<TValue>(baseValue: TValue, rows: readonly Pick<OverrideRow<TValue>, 'modes' | 'value'>[], activeModes: Iterable<OverrideModeRef>): TValue;
55
+ declare function modifierPathToId(path: readonly TokenModifierKey[]): string;
56
+ declare function modifierIdToPath(id: string): TokenModifierKey[];
57
+ declare function buildNestedModifierUpdate<TValue>(modifierPath: readonly TokenModifierKey[], value: ModifierUpdateValue<TValue>): Record<TokenModifierKey, ModifierUpdateValue<TValue>>;
58
+ /**
59
+ * Combines multiple token-modifier update payloads into one patch
60
+ * object. Later updates win on scalar/null leaves; object branches
61
+ * deep-merge so swap operations can delete one nested row and set
62
+ * another nested row under the same parent modifier in a single
63
+ * patch.
64
+ */
65
+ declare function mergeModifierUpdates<TValue>(...updates: readonly ModifierUpdate<TValue>[]): Record<string, ModifierUpdateValue<TValue>>; //#endregion
66
+ //#endregion
67
+ export { ModeBackedModifierDefinition, ModeBackedModifierInput, ModeBackedModifierLookup, OverrideModeRef, OverrideRow, buildModeBackedModifierLookup, buildNestedModifierUpdate, createModeBackedModifierLookup, mergeModifierUpdates, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, overrideRowsToModifierTree, resolveOverrideRowValue };
@@ -0,0 +1,223 @@
1
+ //#region ../config/dist/token-override-rows.js
2
+ function createModeBackedModifierLookup(inputs) {
3
+ const byModifier = /* @__PURE__ */ new Map();
4
+ const byModeRef = /* @__PURE__ */ new Map();
5
+ for (const input of inputs) {
6
+ const definition = {
7
+ ...input,
8
+ modeRef: `${input.mode}.${input.option}`
9
+ };
10
+ byModifier.set(input.modifier, definition);
11
+ byModeRef.set(definition.modeRef, definition);
12
+ }
13
+ return {
14
+ byModifier,
15
+ byModeRef
16
+ };
17
+ }
18
+ function buildModeBackedModifierLookup(modes, modifiers) {
19
+ const optionMetadata = /* @__PURE__ */ new Map();
20
+ modes.forEach((mode, modeOrder) => {
21
+ mode.options.forEach((option, optionOrder) => {
22
+ optionMetadata.set(`${mode.name}/${option.name}`, {
23
+ mode: mode.name,
24
+ option: option.name,
25
+ label: option.label ?? option.name,
26
+ modeOrder,
27
+ optionOrder
28
+ });
29
+ });
30
+ });
31
+ const inputs = [];
32
+ for (const modifier of modifiers) {
33
+ const marker = getModeMarker(modifier.selector);
34
+ if (!marker) continue;
35
+ const metadata = optionMetadata.get(marker.ref);
36
+ if (!metadata) continue;
37
+ inputs.push({
38
+ ...metadata,
39
+ modifier: modifier.modifier
40
+ });
41
+ }
42
+ return createModeBackedModifierLookup(inputs);
43
+ }
44
+ function modifierTreeToOverrideRows(modifiers, lookup) {
45
+ const rows = [];
46
+ let sourceOrder = 0;
47
+ const visit = (value, modifierPath) => {
48
+ const node = asModifierNode(value);
49
+ const modes = canonicalizeModifierPath(modifierPath, lookup);
50
+ if (!node) {
51
+ rows.push({
52
+ modes,
53
+ value,
54
+ sourceModifierPath: modifierPath,
55
+ sourceOrder
56
+ });
57
+ sourceOrder++;
58
+ return;
59
+ }
60
+ if (Object.hasOwn(node, "value") && node.value !== void 0) {
61
+ rows.push({
62
+ modes,
63
+ value: node.value,
64
+ sourceModifierPath: modifierPath,
65
+ sourceOrder
66
+ });
67
+ sourceOrder++;
68
+ }
69
+ for (const [key, nestedValue] of Object.entries(node)) {
70
+ if (key === "value" || nestedValue === void 0) continue;
71
+ if (!isModifierKey(key) || !lookup.byModifier.has(key)) continue;
72
+ visit(nestedValue, [...modifierPath, key]);
73
+ }
74
+ };
75
+ for (const [modifier, value] of Object.entries(modifiers ?? {})) {
76
+ if (value === void 0) continue;
77
+ if (!isModifierKey(modifier) || !lookup.byModifier.has(modifier)) continue;
78
+ visit(value, [modifier]);
79
+ }
80
+ return rows;
81
+ }
82
+ function overrideRowsToModifierTree(rows, lookup) {
83
+ const tree = {};
84
+ for (const row of rows) {
85
+ const path = resolveWritableModifierPath(row, lookup);
86
+ if (path.length === 0) continue;
87
+ assignModifierPath(tree, path, row.value);
88
+ }
89
+ return tree;
90
+ }
91
+ function resolveOverrideRowValue(baseValue, rows, activeModes) {
92
+ const active = new Set(activeModes);
93
+ let resolved = baseValue;
94
+ let bestSpecificity = -1;
95
+ let bestOrder = -1;
96
+ rows.forEach((row, order) => {
97
+ if (!row.modes.every((mode) => active.has(mode))) return;
98
+ const specificity = row.modes.length;
99
+ if (specificity < bestSpecificity) return;
100
+ if (specificity === bestSpecificity && order < bestOrder) return;
101
+ resolved = row.value;
102
+ bestSpecificity = specificity;
103
+ bestOrder = order;
104
+ });
105
+ return resolved;
106
+ }
107
+ function modifierPathToId(path) {
108
+ return path.join(".");
109
+ }
110
+ function modifierIdToPath(id) {
111
+ return id.split(".").filter(isModifierKey).map((part) => part);
112
+ }
113
+ function buildNestedModifierUpdate(modifierPath, value) {
114
+ if (modifierPath.length === 0) return {};
115
+ const [first, ...rest] = modifierPath;
116
+ if (!first) return {};
117
+ if (rest.length === 0) return { [first]: value };
118
+ return { [first]: buildNestedModifierUpdate(rest, value) };
119
+ }
120
+ /**
121
+ * Combines multiple token-modifier update payloads into one patch
122
+ * object. Later updates win on scalar/null leaves; object branches
123
+ * deep-merge so swap operations can delete one nested row and set
124
+ * another nested row under the same parent modifier in a single
125
+ * patch.
126
+ */
127
+ function mergeModifierUpdates(...updates) {
128
+ const merged = {};
129
+ for (const update of updates) mergeModifierUpdateInto(merged, update);
130
+ return merged;
131
+ }
132
+ function getModeMarker(selector) {
133
+ if (typeof selector !== "object" || selector === null) return null;
134
+ const marker = selector;
135
+ if (marker.__kind !== "mode" || typeof marker.ref !== "string") return null;
136
+ return {
137
+ __kind: "mode",
138
+ ref: marker.ref
139
+ };
140
+ }
141
+ function mergeModifierUpdateInto(target, update) {
142
+ for (const [key, value] of Object.entries(update)) {
143
+ if (value === void 0) continue;
144
+ const current = target[key];
145
+ if (isModifierUpdateObject(current) && isModifierUpdateObject(value)) {
146
+ target[key] = mergeModifierUpdateObjects(current, value);
147
+ continue;
148
+ }
149
+ target[key] = value;
150
+ }
151
+ }
152
+ function mergeModifierUpdateObjects(current, update) {
153
+ const merged = {};
154
+ for (const [key, value] of Object.entries(current)) if (value !== void 0) merged[key] = value;
155
+ mergeModifierUpdateInto(merged, update);
156
+ return merged;
157
+ }
158
+ function isModifierUpdateObject(value) {
159
+ return typeof value === "object" && value !== null;
160
+ }
161
+ function canonicalizeModifierPath(modifierPath, lookup) {
162
+ return modifierPath.map((modifier) => lookup.byModifier.get(modifier)).filter((definition) => definition !== void 0).sort(compareModeBackedModifiers).map((definition) => definition.modeRef);
163
+ }
164
+ function resolveWritableModifierPath(row, lookup) {
165
+ if (pathMatchesModes(row.sourceModifierPath, row.modes, lookup)) return row.sourceModifierPath;
166
+ return row.modes.map((modeRef) => lookup.byModeRef.get(modeRef)).filter((definition) => definition !== void 0).sort(compareModeBackedModifiers).map((definition) => definition.modifier);
167
+ }
168
+ function pathMatchesModes(path, modes, lookup) {
169
+ if (path.length !== modes.length) return false;
170
+ const pathModes = canonicalizeModifierPath(path, lookup);
171
+ const expectedModes = [...modes].sort((a, b) => compareModeBackedModifiersByRef(a, b, lookup));
172
+ return pathModes.length === expectedModes.length && pathModes.every((mode, index) => mode === expectedModes[index]);
173
+ }
174
+ function assignModifierPath(tree, path, value) {
175
+ const [modifier, ...rest] = path;
176
+ if (!modifier) return;
177
+ if (rest.length === 0) {
178
+ tree[modifier] = mergeLeafValue(tree[modifier], value);
179
+ return;
180
+ }
181
+ const current = tree[modifier];
182
+ const node = asWritableModifierNode(current);
183
+ tree[modifier] = node;
184
+ assignModifierPath(node, rest, value);
185
+ }
186
+ function mergeLeafValue(current, value) {
187
+ const node = asModifierNode(current);
188
+ if (!node) return value;
189
+ return {
190
+ ...node,
191
+ value
192
+ };
193
+ }
194
+ function asWritableModifierNode(current) {
195
+ const node = asModifierNode(current);
196
+ if (node) return { ...node };
197
+ if (current !== void 0) return { value: current };
198
+ return {};
199
+ }
200
+ function asModifierNode(value) {
201
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
202
+ if (Object.hasOwn(value, "value")) return value;
203
+ if (Object.keys(value).some(isModifierKey)) return value;
204
+ return null;
205
+ }
206
+ function isModifierKey(value) {
207
+ return value.startsWith("_");
208
+ }
209
+ function compareModeBackedModifiers(a, b) {
210
+ if (a.modeOrder !== b.modeOrder) return a.modeOrder - b.modeOrder;
211
+ if (a.optionOrder !== b.optionOrder) return a.optionOrder - b.optionOrder;
212
+ return a.modifier.localeCompare(b.modifier);
213
+ }
214
+ function compareModeBackedModifiersByRef(a, b, lookup) {
215
+ const aDefinition = lookup.byModeRef.get(a);
216
+ const bDefinition = lookup.byModeRef.get(b);
217
+ if (aDefinition && bDefinition) return compareModeBackedModifiers(aDefinition, bDefinition);
218
+ if (aDefinition) return -1;
219
+ if (bDefinition) return 1;
220
+ return a.localeCompare(b);
221
+ }
222
+ //#endregion
223
+ export { buildModeBackedModifierLookup, buildNestedModifierUpdate, createModeBackedModifierLookup, mergeModifierUpdates, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, overrideRowsToModifierTree, resolveOverrideRowValue };
@@ -0,0 +1,138 @@
1
+ //#region ../config/dist/tokenValueType.js
2
+ const CSS_STRING_KEYWORDS = new Set([
3
+ "inherit",
4
+ "initial",
5
+ "unset",
6
+ "revert",
7
+ "revert-layer",
8
+ "auto",
9
+ "none",
10
+ "currentColor",
11
+ "currentcolor",
12
+ "transparent",
13
+ "min-content",
14
+ "max-content",
15
+ "fit-content"
16
+ ]);
17
+ const HEX_COLOR_RE = /^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
18
+ const COLOR_FUNCTION_RE = /^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|light-dark)\s*\(/i;
19
+ const GRADIENT_FUNCTION_RE = /^(?:linear|radial|conic|repeating-linear|repeating-radial|repeating-conic)-gradient\s*\(/i;
20
+ const EASING_FUNCTION_RE = /^(?:cubic-bezier|steps)\s*\(/i;
21
+ const EASING_KEYWORDS = new Set([
22
+ "linear",
23
+ "ease",
24
+ "ease-in",
25
+ "ease-out",
26
+ "ease-in-out",
27
+ "step-start",
28
+ "step-end"
29
+ ]);
30
+ const NAMED_COLOR_KEYWORDS = new Set([
31
+ "aliceblue",
32
+ "antiquewhite",
33
+ "aqua",
34
+ "aquamarine",
35
+ "azure",
36
+ "beige",
37
+ "bisque",
38
+ "black",
39
+ "blue",
40
+ "brown",
41
+ "crimson",
42
+ "cyan",
43
+ "fuchsia",
44
+ "gold",
45
+ "gray",
46
+ "grey",
47
+ "green",
48
+ "indigo",
49
+ "lavender",
50
+ "lime",
51
+ "magenta",
52
+ "maroon",
53
+ "navy",
54
+ "olive",
55
+ "orange",
56
+ "pink",
57
+ "purple",
58
+ "red",
59
+ "salmon",
60
+ "silver",
61
+ "teal",
62
+ "tomato",
63
+ "violet",
64
+ "white",
65
+ "yellow"
66
+ ]);
67
+ const NUMBER_RE_SRC = "(?:\\d+(?:\\.\\d+)?|\\.\\d+)";
68
+ const DIMENSION_RE = new RegExp(`^-?${NUMBER_RE_SRC}(?:px|rem|em|%|vh|vw|vmin|vmax|vi|vb|svh|svw|lvh|lvw|dvh|dvw|ch|ex|cap|ic|lh|rlh|pt|pc|in|cm|mm|q|fr|deg|turn|rad|grad)$`, "i");
69
+ const DURATION_RE = new RegExp(`^-?${NUMBER_RE_SRC}(?:ms|s)$`, "i");
70
+ const PURE_NUMBER_RE = new RegExp(`^-?${NUMBER_RE_SRC}$`);
71
+ const RATIO_RE = /^\d+(?:\.\d+)?\s*\/\s*\d+(?:\.\d+)?$/;
72
+ const SHADOW_LENGTH_RE = /(?:^|[\s,])-?\d+(?:\.\d+)?(?:px|rem|em|ch|ex)/i;
73
+ const SHADOW_COLOR_RE = /(?:rgba?|hsla?|color|oklch|oklab|lch|lab|hwb)\(|#[0-9a-fA-F]{3,8}\b/;
74
+ function looksLikeShadow(value) {
75
+ return SHADOW_LENGTH_RE.test(value) && SHADOW_COLOR_RE.test(value);
76
+ }
77
+ /**
78
+ * Heuristic CSS-value classifier. Given a raw value string, returns the
79
+ * best-guess type or `undefined` when no confident match is possible
80
+ * (e.g. `var(...)` references). Used by `Token.sniffValueType` and as
81
+ * the value-shape tier of {@link resolveTokenValueType}.
82
+ */
83
+ function sniffTokenType(value) {
84
+ const v = value.trim();
85
+ if (v.length === 0) return void 0;
86
+ if (CSS_STRING_KEYWORDS.has(v)) return "string";
87
+ if (v.startsWith("var(")) return void 0;
88
+ if (COLOR_FUNCTION_RE.test(v)) return "color";
89
+ if (HEX_COLOR_RE.test(v)) return "color";
90
+ if (NAMED_COLOR_KEYWORDS.has(v.toLowerCase())) return "color";
91
+ if (GRADIENT_FUNCTION_RE.test(v)) return "gradient";
92
+ if (EASING_FUNCTION_RE.test(v)) return "easing-function";
93
+ if (EASING_KEYWORDS.has(v.toLowerCase())) return "easing-function";
94
+ if (DURATION_RE.test(v)) return "time";
95
+ if (DIMENSION_RE.test(v)) {
96
+ if (v.endsWith("%")) return "percentage";
97
+ if (/(deg|rad|grad|turn)$/i.test(v)) return "angle";
98
+ return "length";
99
+ }
100
+ if (PURE_NUMBER_RE.test(v)) return "number";
101
+ if (RATIO_RE.test(v)) return "ratio";
102
+ if (looksLikeShadow(v)) return "shadow";
103
+ }
104
+ /**
105
+ * Resolve a token's effective {@link CssValueTypeName} using the
106
+ * canonical 3-tier precedence:
107
+ *
108
+ * 1. Per-token explicit `type` — authored override always wins.
109
+ * 2. Value-shape sniff — handles `'#1167f4' → color` even inside a
110
+ * `string` group, and `'transparent' → string` even inside a
111
+ * `color` group.
112
+ * 3. Group `type` — least-specific fallback for legacy untyped
113
+ * values.
114
+ *
115
+ * `length-percentage` narrows to `length` / `percentage` / `angle` /
116
+ * `time` based on the trailing suffix; `string` narrows to `shadow`
117
+ * when the value looks like a CSS shadow declaration.
118
+ */
119
+ function resolveTokenValueType(token, groupType) {
120
+ let resolved;
121
+ if (token.type) resolved = token.type;
122
+ else {
123
+ resolved = sniffTokenType(token.value);
124
+ if (resolved === void 0 && groupType) resolved = groupType;
125
+ }
126
+ if (resolved === void 0) return void 0;
127
+ const trimmed = token.value.trim();
128
+ if (resolved === "length-percentage") {
129
+ if (trimmed.endsWith("%")) return "percentage";
130
+ if (/(deg|rad|grad|turn)$/.test(trimmed)) return "angle";
131
+ if (/(ms|s)$/.test(trimmed)) return "time";
132
+ return "length";
133
+ }
134
+ if (resolved === "string" && looksLikeShadow(trimmed)) return "shadow";
135
+ return resolved;
136
+ }
137
+ //#endregion
138
+ export { resolveTokenValueType, sniffTokenType };