@yahoo/uds-create-config 2.45.0 → 3.0.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.
- package/README.md +129 -0
- package/dist/ai-lanes.d.ts +23 -0
- package/dist/ai-lanes.js +34 -0
- package/dist/authoring/define-component.d.ts +85 -0
- package/dist/configs/CanvasConfig.d.ts +3237 -0
- package/dist/configs/CanvasConfig.js +332 -0
- package/dist/configs/build-options.d.ts +10 -0
- package/dist/configs/build-options.js +68 -0
- package/dist/configs/platform.d.ts +15 -0
- package/dist/configs/platform.js +17 -0
- package/dist/configs/react-native-system.d.ts +3026 -0
- package/dist/configs/react-native-system.js +64 -0
- package/dist/configs/system.d.ts +2771 -0
- package/dist/configs/system.js +74 -0
- package/dist/css/properties.generated.d.ts +14 -0
- package/dist/css/properties.generated.js +6260 -0
- package/dist/css/value-type.d.ts +48 -0
- package/dist/css/value-type.js +131 -0
- package/dist/css/values.d.ts +33 -0
- package/dist/css/values.js +116 -0
- package/dist/entities/native/NativeModifier.d.ts +25 -0
- package/dist/entities/native/NativeModifier.js +41 -0
- package/dist/entities/native/NativeSettings.d.ts +44 -0
- package/dist/entities/native/NativeSettings.js +39 -0
- package/dist/entities/native/NativeStyleProperty.d.ts +355 -0
- package/dist/entities/native/NativeStyleProperty.js +28 -0
- package/dist/entities/native/NativeToken.d.ts +31 -0
- package/dist/entities/native/NativeToken.js +49 -0
- package/dist/entities/system/CanvasRole.d.ts +34 -0
- package/dist/entities/system/CanvasRole.js +45 -0
- package/dist/entities/system/Component.d.ts +1287 -0
- package/dist/entities/system/Component.js +1840 -0
- package/dist/entities/system/Composite.d.ts +12 -0
- package/dist/entities/system/Composite.js +26 -0
- package/dist/entities/system/Device.d.ts +11 -0
- package/dist/entities/system/Device.js +18 -0
- package/dist/entities/system/File.d.ts +72 -0
- package/dist/entities/system/File.js +136 -0
- package/dist/entities/system/Font.d.ts +48 -0
- package/dist/entities/system/Font.js +56 -0
- package/dist/entities/system/GlobalStyle.d.ts +26 -0
- package/dist/entities/system/GlobalStyle.js +54 -0
- package/dist/entities/system/Guidance.d.ts +85 -0
- package/dist/entities/system/Guidance.js +59 -0
- package/dist/entities/system/GuidanceStyle.d.ts +14 -0
- package/dist/entities/system/GuidanceStyle.js +8 -0
- package/dist/entities/system/Icon.d.ts +46 -0
- package/dist/entities/system/Icon.js +46 -0
- package/dist/entities/system/LinkedSystem.d.ts +504 -0
- package/dist/entities/system/LinkedSystem.js +814 -0
- package/dist/entities/system/Modifier.d.ts +92 -0
- package/dist/entities/system/Modifier.js +120 -0
- package/dist/entities/system/Motion.d.ts +28 -0
- package/dist/entities/system/Motion.js +48 -0
- package/dist/entities/system/Operation.d.ts +100 -0
- package/dist/entities/system/Operation.js +236 -0
- package/dist/entities/system/Package.d.ts +42 -0
- package/dist/entities/system/Package.js +75 -0
- package/dist/entities/system/Settings.d.ts +94 -0
- package/dist/entities/system/Settings.js +166 -0
- package/dist/entities/system/StyleProperty.d.ts +135 -0
- package/dist/entities/system/StyleProperty.js +438 -0
- package/dist/entities/system/Token.d.ts +67 -0
- package/dist/entities/system/Token.js +129 -0
- package/dist/entities/system/Tool.d.ts +134 -0
- package/dist/entities/system/Tool.js +124 -0
- package/dist/entities/system/color.d.ts +64 -0
- package/dist/entities/system/color.js +123 -0
- package/dist/entities/system/component-module.d.ts +63 -0
- package/dist/entities/system/component-module.js +258 -0
- package/dist/entities/system/copy-plan.d.ts +98 -0
- package/dist/entities/system/copy-plan.js +451 -0
- package/dist/entities/system/defineComponent.d.ts +428 -0
- package/dist/entities/system/defineComponent.js +337 -0
- package/dist/entities/system/element.d.ts +101 -0
- package/dist/entities/system/element.js +171 -0
- package/dist/entities/system/icon-library.d.ts +64 -0
- package/dist/entities/system/icon-library.js +112 -0
- package/dist/entities/system/icon-metadata.d.ts +72 -0
- package/dist/entities/system/icon-metadata.js +111 -0
- package/dist/entities/system/link-declaration.d.ts +27 -0
- package/dist/entities/system/link-declaration.js +64 -0
- package/dist/entities/system/link-plan.d.ts +160 -0
- package/dist/entities/system/link-plan.js +770 -0
- package/dist/entities/system/runtime-modules.d.ts +25 -0
- package/dist/entities/system/runtime-modules.js +38 -0
- package/dist/entities/system/style-bag.d.ts +20 -0
- package/dist/entities/system/style-bag.js +246 -0
- package/dist/entities/system/token-index.d.ts +89 -0
- package/dist/entities/system/token-index.js +112 -0
- package/dist/framework/Config.d.ts +2472 -0
- package/dist/framework/Config.js +5023 -0
- package/dist/framework/Entity.d.ts +127 -0
- package/dist/framework/Entity.js +125 -0
- package/dist/framework/authoring.d.ts +24 -0
- package/dist/framework/authoring.js +7 -0
- package/dist/framework/change-hooks.d.ts +119 -0
- package/dist/framework/change-hooks.js +131 -0
- package/dist/framework/changes.d.ts +88 -0
- package/dist/framework/changes.js +246 -0
- package/dist/framework/class-names.d.ts +260 -0
- package/dist/framework/class-names.js +630 -0
- package/dist/framework/coalesce.d.ts +25 -0
- package/dist/framework/coalesce.js +60 -0
- package/dist/framework/config-op.d.ts +76 -0
- package/dist/framework/config-op.js +43 -0
- package/dist/framework/config-operation-kind.d.ts +14 -0
- package/dist/framework/config-operation-kind.js +14 -0
- package/dist/framework/config-ops.d.ts +34 -0
- package/dist/framework/config-ops.js +187 -0
- package/dist/framework/defineConfig.d.ts +196 -0
- package/dist/framework/defineConfig.js +100 -0
- package/dist/framework/defineDerivedEntity.d.ts +74 -0
- package/dist/framework/defineDerivedEntity.js +83 -0
- package/dist/framework/defineEntity.d.ts +318 -0
- package/dist/framework/defineEntity.js +183 -0
- package/dist/framework/defineSubEntity.d.ts +148 -0
- package/dist/framework/defineSubEntity.js +121 -0
- package/dist/framework/derived-mutations.d.ts +20 -0
- package/dist/framework/derived-mutations.js +38 -0
- package/dist/framework/entity-search.d.ts +29 -0
- package/dist/framework/entity-search.js +117 -0
- package/dist/framework/inline-sources.d.ts +49 -0
- package/dist/framework/inline-sources.js +388 -0
- package/dist/framework/layer-styles.d.ts +25 -0
- package/dist/framework/layer-styles.js +49 -0
- package/dist/framework/memo.d.ts +48 -0
- package/dist/framework/memo.js +84 -0
- package/dist/framework/overlay.d.ts +49 -0
- package/dist/framework/overlay.js +17 -0
- package/dist/framework/plan.d.ts +49 -0
- package/dist/framework/plan.js +73 -0
- package/dist/framework/projections.d.ts +480 -0
- package/dist/framework/projections.js +974 -0
- package/dist/framework/prop-surface.d.ts +132 -0
- package/dist/framework/prop-surface.js +278 -0
- package/dist/framework/ref-graph.d.ts +71 -0
- package/dist/framework/ref-graph.js +158 -0
- package/dist/framework/ref-integrity.d.ts +55 -0
- package/dist/framework/ref-integrity.js +171 -0
- package/dist/framework/registered.d.ts +95 -0
- package/dist/framework/registry-dir.d.ts +42 -0
- package/dist/framework/registry-dir.js +48 -0
- package/dist/framework/registry.d.ts +300 -0
- package/dist/framework/registry.js +104 -0
- package/dist/framework/rejection.d.ts +58 -0
- package/dist/framework/rejection.js +111 -0
- package/dist/framework/rename-inference.d.ts +26 -0
- package/dist/framework/rename-inference.js +50 -0
- package/dist/framework/render-spec.d.ts +296 -0
- package/dist/framework/render-spec.js +809 -0
- package/dist/framework/schema-version.d.ts +140 -0
- package/dist/framework/schema-version.js +214 -0
- package/dist/framework/schemas.d.ts +109 -0
- package/dist/framework/schemas.js +615 -0
- package/dist/framework/session.d.ts +196 -0
- package/dist/framework/session.js +367 -0
- package/dist/framework/signature.d.ts +15 -0
- package/dist/framework/signature.js +83 -0
- package/dist/framework/snapshot.d.ts +115 -0
- package/dist/framework/snapshot.js +277 -0
- package/dist/framework/source-integrity.d.ts +226 -0
- package/dist/framework/source-integrity.js +478 -0
- package/dist/framework/sources.d.ts +211 -0
- package/dist/framework/sources.js +89 -0
- package/dist/framework/utils/compiled-schema.d.ts +23 -0
- package/dist/framework/utils/compiled-schema.js +46 -0
- package/dist/framework/utils/content-key.d.ts +15 -0
- package/dist/framework/utils/content-key.js +33 -0
- package/dist/framework/utils/enumerated.d.ts +13 -0
- package/dist/framework/utils/enumerated.js +19 -0
- package/dist/framework/utils/field-path.d.ts +95 -0
- package/dist/framework/utils/field-path.js +136 -0
- package/dist/framework/utils/field-schema.d.ts +55 -0
- package/dist/framework/utils/field-schema.js +183 -0
- package/dist/framework/utils/group.d.ts +37 -0
- package/dist/framework/utils/group.js +13 -0
- package/dist/framework/utils/package-path.d.ts +37 -0
- package/dist/framework/utils/package-path.js +61 -0
- package/dist/framework/utils/refs.d.ts +194 -0
- package/dist/framework/utils/refs.js +403 -0
- package/dist/framework/validate-spec.d.ts +27 -0
- package/dist/framework/validate-spec.js +45 -0
- package/dist/framework/value-domain.d.ts +26 -0
- package/dist/framework/value-domain.js +202 -0
- package/dist/framework/views-facade.d.ts +15 -0
- package/dist/framework/views-facade.js +19 -0
- package/dist/index.d.ts +90 -42
- package/dist/index.js +86 -37
- package/dist/migrations/2.0.0/raw-css.d.ts +11 -0
- package/dist/migrations/2.0.0/raw-css.js +72 -0
- package/dist/migrations/2.0.0/v1-artifact.d.ts +1559 -0
- package/dist/migrations/2.0.0/v1-artifact.js +1018 -0
- package/dist/migrations/20260908171448_settings_as_kind.d.ts +22 -0
- package/dist/migrations/20260908171448_settings_as_kind.js +89 -0
- package/dist/migrations/20260908194245_visible_state_pointer.d.ts +19 -0
- package/dist/migrations/20260908194245_visible_state_pointer.js +115 -0
- package/dist/migrations/20260909183001_icon_knockout_variants.d.ts +18 -0
- package/dist/migrations/20260909183001_icon_knockout_variants.js +8 -0
- package/dist/migrations/20260910212453_linked_system_link_ops.d.ts +13 -0
- package/dist/migrations/20260910212453_linked_system_link_ops.js +8 -0
- package/dist/migrations/index.d.ts +2 -0
- package/dist/migrations/index.js +2 -0
- package/dist/react-native/style-keys.generated.d.ts +10 -0
- package/dist/react-native/style-keys.generated.js +167 -0
- package/dist/renderer/RendererErrorBoundary.d.ts +32 -5
- package/dist/renderer/RendererErrorBoundary.js +59 -10
- package/dist/renderer/UdsRenderer.d.ts +11 -10
- package/dist/renderer/UdsRenderer.js +1 -1
- package/dist/renderer/assetEntries.d.ts +37 -0
- package/dist/renderer/assetEntries.js +39 -0
- package/dist/renderer/assetRenderable.d.ts +14 -6
- package/dist/renderer/assetRenderable.js +8 -2
- package/dist/renderer/componentEntry.d.ts +58 -0
- package/dist/renderer/componentEntry.js +71 -0
- package/dist/renderer/icon-library.d.ts +20 -0
- package/dist/renderer/index.d.ts +7 -7
- package/dist/renderer/index.js +5 -5
- package/dist/renderer/primitives/SlotRenderer.d.ts +1 -1
- package/dist/renderer/primitives/SlotRenderer.js +1 -1
- package/dist/renderer/runtimeComponent.d.ts +33 -0
- package/dist/renderer/runtimeComponent.js +113 -0
- package/dist/renderer/spec-content.d.ts +43 -0
- package/dist/renderer/spec-content.js +95 -0
- package/dist/renderer/wrapRegistry.d.ts +22 -37
- package/dist/renderer/wrapRegistry.js +10 -20
- package/dist/renderer/wrappers/event-bridge.js +6 -5
- package/dist/renderer/wrappers/hex-normalize.js +6 -5
- package/dist/renderer/wrappers/html-aliases.d.ts +7 -2
- package/dist/renderer/wrappers/html-aliases.js +36 -19
- package/dist/renderer/wrappers/inline-styles.js +7 -6
- package/dist/spec/asset-jsx.d.ts +18 -5
- package/dist/spec/asset-jsx.js +27 -16
- package/dist/spec/collapse-text-labels.d.ts +5 -15
- package/dist/spec/collapse-text-labels.js +26 -19
- package/dist/spec/empty-node-slots.d.ts +56 -34
- package/dist/spec/empty-node-slots.js +87 -47
- package/dist/spec/index.d.ts +21 -10
- package/dist/spec/index.js +21 -10
- package/dist/spec/jsxToSpec.d.ts +14 -9
- package/dist/spec/jsxToSpec.js +20 -3
- package/dist/spec/preview-elements.d.ts +63 -0
- package/dist/spec/preview-elements.js +89 -0
- package/dist/spec/rewrite-refs.d.ts +58 -0
- package/dist/spec/rewrite-refs.js +250 -0
- package/dist/spec/specToJsx.js +18 -29
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +39 -52
- package/dist/AssetGroup.d.ts +0 -77
- package/dist/AssetGroup.js +0 -125
- package/dist/Component.d.ts +0 -333
- package/dist/Component.js +0 -1061
- package/dist/ComponentGroup.d.ts +0 -22
- package/dist/ComponentGroup.js +0 -51
- package/dist/CompositeStyle.d.ts +0 -30
- package/dist/CompositeStyle.js +0 -59
- package/dist/Config.d.ts +0 -528
- package/dist/Config.js +0 -1712
- package/dist/Mode.d.ts +0 -41
- package/dist/Mode.js +0 -81
- package/dist/Modifier.d.ts +0 -51
- package/dist/Modifier.js +0 -97
- package/dist/MotionDef.d.ts +0 -81
- package/dist/MotionDef.js +0 -212
- package/dist/Props.d.ts +0 -332
- package/dist/Props.js +0 -35
- package/dist/Provider.d.ts +0 -20
- package/dist/Provider.js +0 -14
- package/dist/StyleProp.d.ts +0 -145
- package/dist/StyleProp.js +0 -239
- package/dist/Token.d.ts +0 -76
- package/dist/Token.js +0 -133
- package/dist/TokenGroup.d.ts +0 -33
- package/dist/TokenGroup.js +0 -69
- package/dist/asset-kind.d.ts +0 -55
- package/dist/asset-kind.js +0 -29
- package/dist/asset-value.d.ts +0 -23
- package/dist/asset-value.js +0 -40
- package/dist/brands.d.ts +0 -30
- package/dist/brands.js +0 -20
- package/dist/captureCallerPath.d.ts +0 -48
- package/dist/captureCallerPath.js +0 -95
- package/dist/colorExpressions.d.ts +0 -131
- package/dist/colorExpressions.js +0 -148
- package/dist/component-referrers.d.ts +0 -30
- package/dist/component-referrers.js +0 -40
- package/dist/config-diagnostics.d.ts +0 -21
- package/dist/config-diagnostics.js +0 -12
- package/dist/defineAssetGroup.d.ts +0 -200
- package/dist/defineAssetGroup.js +0 -323
- package/dist/defineProvider.d.ts +0 -29
- package/dist/defineProvider.js +0 -60
- package/dist/element-marker.d.ts +0 -63
- package/dist/element-marker.js +0 -113
- package/dist/entity-utils.d.ts +0 -56
- package/dist/entity-utils.js +0 -105
- package/dist/extension.d.ts +0 -55
- package/dist/extension.js +0 -214
- package/dist/factories.d.ts +0 -863
- package/dist/factories.js +0 -475
- package/dist/font-face.d.ts +0 -25
- package/dist/font-face.js +0 -72
- package/dist/foreign-component-name.d.ts +0 -21
- package/dist/foreign-component-name.js +0 -42
- package/dist/interpolate.d.ts +0 -20
- package/dist/interpolate.js +0 -10
- package/dist/jsx/__fixtures__/cross-component-preview.d.ts +0 -3
- package/dist/jsx/__fixtures__/cross-component-preview.js +0 -15
- package/dist/jsx/jsx-dev-runtime.d.ts +0 -15
- package/dist/jsx/jsx-dev-runtime.js +0 -11
- package/dist/jsx/jsx-runtime.d.ts +0 -48
- package/dist/jsx/jsx-runtime.js +0 -305
- package/dist/linked-system-pins.d.ts +0 -30
- package/dist/linked-system-pins.js +0 -45
- package/dist/linkedNodePrefixes.d.ts +0 -73
- package/dist/linkedNodePrefixes.js +0 -99
- package/dist/markers.d.ts +0 -235
- package/dist/markers.js +0 -70
- package/dist/motion-constants.d.ts +0 -37
- package/dist/motion-constants.js +0 -61
- package/dist/native/NativeConfig.d.ts +0 -56
- package/dist/native/NativeConfig.js +0 -162
- package/dist/native/assets.d.ts +0 -20
- package/dist/native/assets.js +0 -17
- package/dist/native/components.d.ts +0 -139
- package/dist/native/components.js +0 -67
- package/dist/native/index.d.ts +0 -18
- package/dist/native/index.js +0 -17
- package/dist/native/modes.d.ts +0 -10
- package/dist/native/modes.js +0 -11
- package/dist/native/types.d.ts +0 -95
- package/dist/native/types.js +0 -0
- package/dist/native/validation.d.ts +0 -8
- package/dist/native/validation.js +0 -885
- package/dist/native/values.d.ts +0 -7
- package/dist/native/values.js +0 -15
- package/dist/native.d.ts +0 -12
- package/dist/native.js +0 -10
- package/dist/refs.d.ts +0 -204
- package/dist/refs.js +0 -129
- package/dist/registry-aliases.d.ts +0 -33
- package/dist/registry-aliases.js +0 -35
- package/dist/registry-dir.d.ts +0 -22
- package/dist/registry-dir.js +0 -10
- package/dist/renderer/makeRegistry.d.ts +0 -34
- package/dist/renderer/makeRegistry.js +0 -52
- package/dist/renderer/makeUdsRenderer.d.ts +0 -13
- package/dist/renderer/makeUdsRenderer.js +0 -51
- package/dist/renderer/wrappers/component-slots.d.ts +0 -41
- package/dist/renderer/wrappers/component-slots.js +0 -66
- package/dist/renderer/wrappers/slot-resolution.d.ts +0 -25
- package/dist/renderer/wrappers/slot-resolution.js +0 -68
- package/dist/renderer/wrappers/void-elements.d.ts +0 -37
- package/dist/renderer/wrappers/void-elements.js +0 -40
- package/dist/spec/layer-props.d.ts +0 -52
- package/dist/spec/layer-props.js +0 -149
- package/dist/spec/preview-controls.d.ts +0 -44
- package/dist/spec/preview-controls.js +0 -139
- package/dist/spec/slot-refs.d.ts +0 -39
- package/dist/spec/slot-refs.js +0 -56
- package/dist/token-override-rows.d.ts +0 -68
- package/dist/token-override-rows.js +0 -233
- package/dist/tokenValueType.d.ts +0 -34
- package/dist/tokenValueType.js +0 -138
- package/dist/types/css-properties.d.ts +0 -233
- package/dist/types/css-properties.js +0 -14
- package/dist/types/css-property-keywords.d.ts +0 -156
- package/dist/types/css-property-keywords.js +0 -616
- package/dist/types/css-values.d.ts +0 -63
- package/dist/types/css-values.js +0 -16
- package/dist/types.d.ts +0 -1138
- package/dist/types.js +0 -12
- package/dist/units.d.ts +0 -14
- package/dist/units.js +0 -16
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/index.js +0 -4
package/dist/spec/slot-refs.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
//#region src/spec/slot-refs.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* `$slot` resolution utilities for json-render specs.
|
|
4
|
-
*
|
|
5
|
-
* UDS extends json-render's prop-value markers with a `$slot` reference
|
|
6
|
-
* that points to another element in the same Spec's `elements` map:
|
|
7
|
-
*
|
|
8
|
-
* { "$slot": "btn1" } // single ref
|
|
9
|
-
* { "$slot": ["btn1", "btn2"] } // multi-ref (e.g. Card.actions)
|
|
10
|
-
*
|
|
11
|
-
* Used for composition patterns where a slot prop on one component
|
|
12
|
-
* (Card.actions, Button.startIcon) receives whole sub-trees of other
|
|
13
|
-
* elements. The shared helpers here are consumed by:
|
|
14
|
-
*
|
|
15
|
-
* - `wrapSlotResolution` (renderer wrapper) — resolves $slot refs to
|
|
16
|
-
* rendered React children at paint time.
|
|
17
|
-
* - `prepareRenderSpec` (studio) — injects $slot-referenced keys
|
|
18
|
-
* into the parent's `children` array so json-render's `Renderer`
|
|
19
|
-
* traverses them (otherwise an unreferenced element in the
|
|
20
|
-
* `elements` map is never visited).
|
|
21
|
-
* - Inspection / debug surfaces (layers panel, dev code panel,
|
|
22
|
-
* control inference, RPC routes) that need to skip past $slot
|
|
23
|
-
* prop markers when inspecting "real" prop values.
|
|
24
|
-
*/
|
|
25
|
-
declare function isSlotRef(value: unknown): value is {
|
|
26
|
-
$slot: string | string[];
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Walk a Spec's `elements` map and return, for each parent element
|
|
30
|
-
* that has at least one `$slot`-prop reference, the set of element
|
|
31
|
-
* keys it references. Used by render-time and edit-time code that
|
|
32
|
-
* needs to know "which sibling elements does this parent pull in
|
|
33
|
-
* through slot props."
|
|
34
|
-
*/
|
|
35
|
-
declare function collectSlotRefs(elements: Record<string, {
|
|
36
|
-
props?: Record<string, unknown>;
|
|
37
|
-
} | undefined>): Map<string, Set<string>>;
|
|
38
|
-
//#endregion
|
|
39
|
-
export { collectSlotRefs, isSlotRef };
|
package/dist/spec/slot-refs.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
//#region src/spec/slot-refs.ts
|
|
2
|
-
/**
|
|
3
|
-
* `$slot` resolution utilities for json-render specs.
|
|
4
|
-
*
|
|
5
|
-
* UDS extends json-render's prop-value markers with a `$slot` reference
|
|
6
|
-
* that points to another element in the same Spec's `elements` map:
|
|
7
|
-
*
|
|
8
|
-
* { "$slot": "btn1" } // single ref
|
|
9
|
-
* { "$slot": ["btn1", "btn2"] } // multi-ref (e.g. Card.actions)
|
|
10
|
-
*
|
|
11
|
-
* Used for composition patterns where a slot prop on one component
|
|
12
|
-
* (Card.actions, Button.startIcon) receives whole sub-trees of other
|
|
13
|
-
* elements. The shared helpers here are consumed by:
|
|
14
|
-
*
|
|
15
|
-
* - `wrapSlotResolution` (renderer wrapper) — resolves $slot refs to
|
|
16
|
-
* rendered React children at paint time.
|
|
17
|
-
* - `prepareRenderSpec` (studio) — injects $slot-referenced keys
|
|
18
|
-
* into the parent's `children` array so json-render's `Renderer`
|
|
19
|
-
* traverses them (otherwise an unreferenced element in the
|
|
20
|
-
* `elements` map is never visited).
|
|
21
|
-
* - Inspection / debug surfaces (layers panel, dev code panel,
|
|
22
|
-
* control inference, RPC routes) that need to skip past $slot
|
|
23
|
-
* prop markers when inspecting "real" prop values.
|
|
24
|
-
*/
|
|
25
|
-
function isSlotRef(value) {
|
|
26
|
-
if (typeof value !== "object" || value === null) return false;
|
|
27
|
-
if (!("$slot" in value)) return false;
|
|
28
|
-
const inner = value.$slot;
|
|
29
|
-
return typeof inner === "string" || Array.isArray(inner);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Walk a Spec's `elements` map and return, for each parent element
|
|
33
|
-
* that has at least one `$slot`-prop reference, the set of element
|
|
34
|
-
* keys it references. Used by render-time and edit-time code that
|
|
35
|
-
* needs to know "which sibling elements does this parent pull in
|
|
36
|
-
* through slot props."
|
|
37
|
-
*/
|
|
38
|
-
function collectSlotRefs(elements) {
|
|
39
|
-
const parentToSlotKeys = /* @__PURE__ */ new Map();
|
|
40
|
-
for (const [key, el] of Object.entries(elements)) {
|
|
41
|
-
if (!el?.props) continue;
|
|
42
|
-
for (const value of Object.values(el.props)) {
|
|
43
|
-
if (!isSlotRef(value)) continue;
|
|
44
|
-
const refs = Array.isArray(value.$slot) ? value.$slot : [value.$slot];
|
|
45
|
-
let slotKeys = parentToSlotKeys.get(key);
|
|
46
|
-
if (!slotKeys) {
|
|
47
|
-
slotKeys = /* @__PURE__ */ new Set();
|
|
48
|
-
parentToSlotKeys.set(key, slotKeys);
|
|
49
|
-
}
|
|
50
|
-
for (const ref of refs) slotKeys.add(ref);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return parentToSlotKeys;
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
export { collectSlotRefs, isSlotRef };
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { TokenModifierKey } from "./types.js";
|
|
2
|
-
|
|
3
|
-
//#region src/token-override-rows.d.ts
|
|
4
|
-
type OverrideModeRef = `${string}.${string}`;
|
|
5
|
-
type ModifierTreeValue<TValue> = TValue | {
|
|
6
|
-
value?: TValue;
|
|
7
|
-
[modifier: TokenModifierKey]: ModifierTreeValue<TValue> | undefined;
|
|
8
|
-
};
|
|
9
|
-
type ModifierTree<TValue> = Partial<Record<TokenModifierKey, ModifierTreeValue<TValue>>>;
|
|
10
|
-
type ModifierUpdateValue<TValue> = TValue | null | ModifierUpdateObject<TValue>;
|
|
11
|
-
interface ModifierUpdateObject<TValue> {
|
|
12
|
-
value?: TValue | null;
|
|
13
|
-
[key: string]: ModifierUpdateValue<TValue> | undefined;
|
|
14
|
-
[modifier: TokenModifierKey]: ModifierUpdateValue<TValue> | undefined;
|
|
15
|
-
}
|
|
16
|
-
type ModifierUpdate<TValue> = Record<string, ModifierUpdateValue<TValue> | undefined>;
|
|
17
|
-
interface ModeBackedModifierInput {
|
|
18
|
-
modifier: TokenModifierKey;
|
|
19
|
-
mode: string;
|
|
20
|
-
option: string;
|
|
21
|
-
label?: string;
|
|
22
|
-
modeOrder: number;
|
|
23
|
-
optionOrder: number;
|
|
24
|
-
}
|
|
25
|
-
interface ModeBackedModifierDefinition extends ModeBackedModifierInput {
|
|
26
|
-
modeRef: OverrideModeRef;
|
|
27
|
-
}
|
|
28
|
-
interface ModeBackedModifierLookup {
|
|
29
|
-
byModifier: ReadonlyMap<TokenModifierKey, ModeBackedModifierDefinition>;
|
|
30
|
-
byModeRef: ReadonlyMap<OverrideModeRef, ModeBackedModifierDefinition>;
|
|
31
|
-
}
|
|
32
|
-
interface OverrideRow<TValue = string> {
|
|
33
|
-
modes: OverrideModeRef[];
|
|
34
|
-
value: TValue;
|
|
35
|
-
sourceModifierPath: TokenModifierKey[];
|
|
36
|
-
sourceOrder: number;
|
|
37
|
-
}
|
|
38
|
-
interface ModeBackedModeMetadata {
|
|
39
|
-
name: string;
|
|
40
|
-
options: readonly {
|
|
41
|
-
name: string;
|
|
42
|
-
label?: string;
|
|
43
|
-
}[];
|
|
44
|
-
}
|
|
45
|
-
interface ModeBackedModifierMetadata {
|
|
46
|
-
modifier: TokenModifierKey;
|
|
47
|
-
selector?: unknown;
|
|
48
|
-
}
|
|
49
|
-
declare function createModeBackedModifierLookup(inputs: readonly ModeBackedModifierInput[]): ModeBackedModifierLookup;
|
|
50
|
-
declare function buildModeBackedModifierLookup(modes: readonly ModeBackedModeMetadata[], modifiers: readonly ModeBackedModifierMetadata[]): ModeBackedModifierLookup;
|
|
51
|
-
declare function modifierTreeToOverrideRows<TValue>(modifiers: ModifierTree<TValue> | undefined, lookup: ModeBackedModifierLookup): OverrideRow<TValue>[];
|
|
52
|
-
declare function overrideRowsToModifierTree<TValue>(rows: readonly OverrideRow<TValue>[], lookup: ModeBackedModifierLookup): ModifierTree<TValue>;
|
|
53
|
-
declare function resolveOverrideRowValue<TValue>(baseValue: TValue, rows: readonly Pick<OverrideRow<TValue>, 'modes' | 'value'>[], activeModes: Iterable<OverrideModeRef>): TValue;
|
|
54
|
-
/** Return the winning authored row using shared specificity/order semantics. */
|
|
55
|
-
declare function resolveOverrideRow<TRow extends Pick<OverrideRow<unknown>, 'modes' | 'value'>>(rows: readonly TRow[], activeModes: Iterable<OverrideModeRef>): TRow | undefined;
|
|
56
|
-
declare function modifierPathToId(path: readonly TokenModifierKey[]): string;
|
|
57
|
-
declare function modifierIdToPath(id: string): TokenModifierKey[];
|
|
58
|
-
declare function buildNestedModifierUpdate<TValue>(modifierPath: readonly TokenModifierKey[], value: ModifierUpdateValue<TValue>): Record<TokenModifierKey, ModifierUpdateValue<TValue>>;
|
|
59
|
-
/**
|
|
60
|
-
* Combines multiple token-modifier update payloads into one patch
|
|
61
|
-
* object. Later updates win on scalar/null leaves; object branches
|
|
62
|
-
* deep-merge so swap operations can delete one nested row and set
|
|
63
|
-
* another nested row under the same parent modifier in a single
|
|
64
|
-
* patch.
|
|
65
|
-
*/
|
|
66
|
-
declare function mergeModifierUpdates<TValue>(...updates: readonly ModifierUpdate<TValue>[]): Record<string, ModifierUpdateValue<TValue>>;
|
|
67
|
-
//#endregion
|
|
68
|
-
export { ModeBackedModifierDefinition, ModeBackedModifierInput, ModeBackedModifierLookup, ModifierTree, OverrideModeRef, OverrideRow, buildModeBackedModifierLookup, buildNestedModifierUpdate, createModeBackedModifierLookup, mergeModifierUpdates, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, overrideRowsToModifierTree, resolveOverrideRow, resolveOverrideRowValue };
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
//#region src/token-override-rows.ts
|
|
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 = asModeModifierNode(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 resolved = resolveOverrideRow(rows, activeModes);
|
|
93
|
-
return resolved === void 0 ? baseValue : resolved.value;
|
|
94
|
-
}
|
|
95
|
-
/** Return the winning authored row using shared specificity/order semantics. */
|
|
96
|
-
function resolveOverrideRow(rows, activeModes) {
|
|
97
|
-
const active = new Set(activeModes);
|
|
98
|
-
let resolved;
|
|
99
|
-
let bestSpecificity = -1;
|
|
100
|
-
let bestOrder = -1;
|
|
101
|
-
rows.forEach((row, order) => {
|
|
102
|
-
if (!row.modes.every((mode) => active.has(mode))) return;
|
|
103
|
-
const specificity = row.modes.length;
|
|
104
|
-
if (specificity < bestSpecificity) return;
|
|
105
|
-
if (specificity === bestSpecificity && order < bestOrder) return;
|
|
106
|
-
resolved = row;
|
|
107
|
-
bestSpecificity = specificity;
|
|
108
|
-
bestOrder = order;
|
|
109
|
-
});
|
|
110
|
-
return resolved;
|
|
111
|
-
}
|
|
112
|
-
function modifierPathToId(path) {
|
|
113
|
-
return path.join(".");
|
|
114
|
-
}
|
|
115
|
-
function modifierIdToPath(id) {
|
|
116
|
-
return id.split(".").filter(isModifierKey).map((part) => part);
|
|
117
|
-
}
|
|
118
|
-
function buildNestedModifierUpdate(modifierPath, value) {
|
|
119
|
-
if (modifierPath.length === 0) return {};
|
|
120
|
-
const [first, ...rest] = modifierPath;
|
|
121
|
-
if (!first) return {};
|
|
122
|
-
if (rest.length === 0) return { [first]: value };
|
|
123
|
-
return { [first]: buildNestedModifierUpdate(rest, value) };
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Combines multiple token-modifier update payloads into one patch
|
|
127
|
-
* object. Later updates win on scalar/null leaves; object branches
|
|
128
|
-
* deep-merge so swap operations can delete one nested row and set
|
|
129
|
-
* another nested row under the same parent modifier in a single
|
|
130
|
-
* patch.
|
|
131
|
-
*/
|
|
132
|
-
function mergeModifierUpdates(...updates) {
|
|
133
|
-
const merged = {};
|
|
134
|
-
for (const update of updates) mergeModifierUpdateInto(merged, update);
|
|
135
|
-
return merged;
|
|
136
|
-
}
|
|
137
|
-
function getModeMarker(selector) {
|
|
138
|
-
if (typeof selector !== "object" || selector === null) return null;
|
|
139
|
-
const marker = selector;
|
|
140
|
-
if (marker.__kind !== "mode" || typeof marker.ref !== "string") return null;
|
|
141
|
-
return {
|
|
142
|
-
__kind: "mode",
|
|
143
|
-
ref: marker.ref
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function mergeModifierUpdateInto(target, update) {
|
|
147
|
-
for (const [key, value] of Object.entries(update)) {
|
|
148
|
-
if (value === void 0) continue;
|
|
149
|
-
const current = target[key];
|
|
150
|
-
if (isModifierUpdateObject(current) && isModifierUpdateObject(value)) {
|
|
151
|
-
target[key] = mergeModifierUpdateObjects(current, value);
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
target[key] = value;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
function mergeModifierUpdateObjects(current, update) {
|
|
158
|
-
const merged = {};
|
|
159
|
-
for (const [key, value] of Object.entries(current)) if (value !== void 0) merged[key] = value;
|
|
160
|
-
mergeModifierUpdateInto(merged, update);
|
|
161
|
-
return merged;
|
|
162
|
-
}
|
|
163
|
-
function isModifierUpdateObject(value) {
|
|
164
|
-
return typeof value === "object" && value !== null;
|
|
165
|
-
}
|
|
166
|
-
function canonicalizeModifierPath(modifierPath, lookup) {
|
|
167
|
-
return modifierPath.map((modifier) => lookup.byModifier.get(modifier)).filter((definition) => definition !== void 0).sort(compareModeBackedModifiers).map((definition) => definition.modeRef);
|
|
168
|
-
}
|
|
169
|
-
function resolveWritableModifierPath(row, lookup) {
|
|
170
|
-
if (pathMatchesModes(row.sourceModifierPath, row.modes, lookup)) return row.sourceModifierPath;
|
|
171
|
-
return row.modes.map((modeRef) => lookup.byModeRef.get(modeRef)).filter((definition) => definition !== void 0).sort(compareModeBackedModifiers).map((definition) => definition.modifier);
|
|
172
|
-
}
|
|
173
|
-
function pathMatchesModes(path, modes, lookup) {
|
|
174
|
-
if (path.length !== modes.length) return false;
|
|
175
|
-
const pathModes = canonicalizeModifierPath(path, lookup);
|
|
176
|
-
const expectedModes = [...modes].sort((a, b) => compareModeBackedModifiersByRef(a, b, lookup));
|
|
177
|
-
return pathModes.length === expectedModes.length && pathModes.every((mode, index) => mode === expectedModes[index]);
|
|
178
|
-
}
|
|
179
|
-
function assignModifierPath(tree, path, value) {
|
|
180
|
-
const [modifier, ...rest] = path;
|
|
181
|
-
if (!modifier) return;
|
|
182
|
-
if (rest.length === 0) {
|
|
183
|
-
tree[modifier] = mergeLeafValue(tree[modifier], value);
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
const current = tree[modifier];
|
|
187
|
-
const node = asWritableModifierNode(current);
|
|
188
|
-
tree[modifier] = node;
|
|
189
|
-
assignModifierPath(node, rest, value);
|
|
190
|
-
}
|
|
191
|
-
function mergeLeafValue(current, value) {
|
|
192
|
-
const node = asModifierNode(current);
|
|
193
|
-
if (!node) return value;
|
|
194
|
-
return {
|
|
195
|
-
...node,
|
|
196
|
-
value
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
function asModeModifierNode(value) {
|
|
200
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
201
|
-
if (Object.hasOwn(value, "__kind")) return null;
|
|
202
|
-
return asModifierNode(value);
|
|
203
|
-
}
|
|
204
|
-
function asWritableModifierNode(current) {
|
|
205
|
-
const node = asModifierNode(current);
|
|
206
|
-
if (node) return { ...node };
|
|
207
|
-
if (current !== void 0) return { value: current };
|
|
208
|
-
return {};
|
|
209
|
-
}
|
|
210
|
-
function asModifierNode(value) {
|
|
211
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
212
|
-
if (Object.hasOwn(value, "value")) return value;
|
|
213
|
-
if (Object.keys(value).some(isModifierKey)) return value;
|
|
214
|
-
return null;
|
|
215
|
-
}
|
|
216
|
-
function isModifierKey(value) {
|
|
217
|
-
return value.startsWith("_");
|
|
218
|
-
}
|
|
219
|
-
function compareModeBackedModifiers(a, b) {
|
|
220
|
-
if (a.modeOrder !== b.modeOrder) return a.modeOrder - b.modeOrder;
|
|
221
|
-
if (a.optionOrder !== b.optionOrder) return a.optionOrder - b.optionOrder;
|
|
222
|
-
return a.modifier.localeCompare(b.modifier);
|
|
223
|
-
}
|
|
224
|
-
function compareModeBackedModifiersByRef(a, b, lookup) {
|
|
225
|
-
const aDefinition = lookup.byModeRef.get(a);
|
|
226
|
-
const bDefinition = lookup.byModeRef.get(b);
|
|
227
|
-
if (aDefinition && bDefinition) return compareModeBackedModifiers(aDefinition, bDefinition);
|
|
228
|
-
if (aDefinition) return -1;
|
|
229
|
-
if (bDefinition) return 1;
|
|
230
|
-
return a.localeCompare(b);
|
|
231
|
-
}
|
|
232
|
-
//#endregion
|
|
233
|
-
export { buildModeBackedModifierLookup, buildNestedModifierUpdate, createModeBackedModifierLookup, mergeModifierUpdates, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, overrideRowsToModifierTree, resolveOverrideRow, resolveOverrideRowValue };
|
package/dist/tokenValueType.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal token value-type resolution. Lives outside `index.ts` —
|
|
3
|
-
* consumers reach for `Token.derived.cssValueType` instead. The static
|
|
4
|
-
* `Token.sniffValueType(value)` helper is the one entry point exposed
|
|
5
|
-
* to picker UIs that don't yet have a `Token` instance to derive from.
|
|
6
|
-
*/
|
|
7
|
-
import type { TokenType } from './types';
|
|
8
|
-
import type { CssValueTypeName } from './types/css-values';
|
|
9
|
-
/**
|
|
10
|
-
* Heuristic CSS-value classifier. Given a raw value string, returns the
|
|
11
|
-
* best-guess type or `undefined` when no confident match is possible
|
|
12
|
-
* (e.g. `var(...)` references). Used by `Token.sniffValueType` and as
|
|
13
|
-
* the value-shape tier of {@link resolveTokenValueType}.
|
|
14
|
-
*/
|
|
15
|
-
export declare function sniffTokenType(value: string): TokenType | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Resolve a token's effective {@link CssValueTypeName} using the
|
|
18
|
-
* canonical 3-tier precedence:
|
|
19
|
-
*
|
|
20
|
-
* 1. Per-token explicit `type` — authored override always wins.
|
|
21
|
-
* 2. Value-shape sniff — handles `'#1167f4' → color` even inside a
|
|
22
|
-
* `string` group, and `'transparent' → string` even inside a
|
|
23
|
-
* `color` group.
|
|
24
|
-
* 3. Group `type` — least-specific fallback for legacy untyped
|
|
25
|
-
* values.
|
|
26
|
-
*
|
|
27
|
-
* `length-percentage` narrows to `length` / `percentage` / `angle` /
|
|
28
|
-
* `time` based on the trailing suffix; `string` narrows to `shadow`
|
|
29
|
-
* when the value looks like a CSS shadow declaration.
|
|
30
|
-
*/
|
|
31
|
-
export declare function resolveTokenValueType(token: {
|
|
32
|
-
value: string;
|
|
33
|
-
type?: TokenType;
|
|
34
|
-
}, groupType: TokenType | undefined): CssValueTypeName | undefined;
|
package/dist/tokenValueType.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
//#region src/tokenValueType.ts
|
|
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 };
|