@yahoo/uds-create-config 2.44.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/asset-value.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
//#region src/asset-value.ts
|
|
2
|
-
/**
|
|
3
|
-
* Assemble a `font-family` CSS value from a font member — the primary
|
|
4
|
-
* family (always double-quoted, so multi-word names are valid) followed by
|
|
5
|
-
* its fallback stack. `fallback` rides `FontAssetMember`'s open index as
|
|
6
|
-
* `unknown`, so read it defensively: a `string` is appended verbatim (it
|
|
7
|
-
* may itself be a comma list), a `string[]` is joined, anything else is
|
|
8
|
-
* ignored. Fallback entries are emitted verbatim — they're generic keywords
|
|
9
|
-
* (`sans-serif`) or already-formatted names.
|
|
10
|
-
*/
|
|
11
|
-
function resolveFontStack(member) {
|
|
12
|
-
const primary = `"${member.fontFamily}"`;
|
|
13
|
-
const { fallback } = member;
|
|
14
|
-
if (typeof fallback === "string" && fallback.length > 0) return `${primary}, ${fallback}`;
|
|
15
|
-
if (Array.isArray(fallback) && fallback.every((entry) => typeof entry === "string")) {
|
|
16
|
-
const stack = fallback.filter((entry) => entry.length > 0);
|
|
17
|
-
return stack.length > 0 ? `${primary}, ${stack.join(", ")}` : primary;
|
|
18
|
-
}
|
|
19
|
-
return primary;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Resolve a `<slug>/<member>` asset ref to its `font-family` CSS stack.
|
|
23
|
-
* Every failure is a named throw (no silent string fallthrough): a
|
|
24
|
-
* malformed ref, an unregistered group, a non-font group, or a missing
|
|
25
|
-
* member each name the offending ref so config load fails loudly.
|
|
26
|
-
*/
|
|
27
|
-
function resolveAssetRefCss(ref, assetGroups) {
|
|
28
|
-
const slash = ref.indexOf("/");
|
|
29
|
-
if (slash <= 0 || slash === ref.length - 1) throw new Error(`asset('${ref}') is malformed — expected a '<group>/<member>' ref.`);
|
|
30
|
-
const slug = ref.slice(0, slash);
|
|
31
|
-
const memberName = ref.slice(slash + 1);
|
|
32
|
-
const group = assetGroups.get(slug);
|
|
33
|
-
if (!group) throw new Error(`asset('${ref}') — no asset group is registered under slug '${slug}'.`);
|
|
34
|
-
if (group.assetKind !== "font") throw new Error(`asset('${ref}') — group '${slug}' is a '${group.assetKind}' group; only font groups can be referenced as a token value.`);
|
|
35
|
-
const member = group.members?.[memberName];
|
|
36
|
-
if (!member) throw new Error(`asset('${ref}') — member '${memberName}' is not registered in font group '${slug}'.`);
|
|
37
|
-
return resolveFontStack(member);
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
export { resolveAssetRefCss, resolveFontStack };
|
package/dist/brands.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//#region src/brands.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Branded CSS string types.
|
|
4
|
-
*
|
|
5
|
-
* Every member that emits CSS — variable refs, selectors, class names,
|
|
6
|
-
* declarations — returns a `Css<Kind>` instead of a plain `string`. The
|
|
7
|
-
* brand erases at runtime; the compiler uses it to catch raw user strings
|
|
8
|
-
* being passed into a CSS-emission slot.
|
|
9
|
-
*
|
|
10
|
-
* Brands are a one-way door: once they flow through the codegen surface
|
|
11
|
-
* we lean on them at every emission site, so we lock the shape in here.
|
|
12
|
-
*/
|
|
13
|
-
type Css<Kind extends string> = string & {
|
|
14
|
-
readonly __cssBrand: Kind;
|
|
15
|
-
};
|
|
16
|
-
type CssVar = Css<'var'>;
|
|
17
|
-
type CssSelector = Css<'selector'>;
|
|
18
|
-
type CssClassName = Css<'className'>;
|
|
19
|
-
type CssDeclaration = Css<'declaration'>;
|
|
20
|
-
/**
|
|
21
|
-
* Stamp a plain string with a CSS brand. The brand is a phantom — no
|
|
22
|
-
* runtime work. All emission helpers funnel through these so the cast
|
|
23
|
-
* lives in one place.
|
|
24
|
-
*/
|
|
25
|
-
declare function cssVar(value: string): CssVar;
|
|
26
|
-
declare function cssSelector(value: string): CssSelector;
|
|
27
|
-
declare function cssClassName(value: string): CssClassName;
|
|
28
|
-
declare function cssDeclaration(value: string): CssDeclaration;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { Css, CssClassName, CssDeclaration, CssSelector, CssVar, cssClassName, cssDeclaration, cssSelector, cssVar };
|
package/dist/brands.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
//#region src/brands.ts
|
|
2
|
-
/**
|
|
3
|
-
* Stamp a plain string with a CSS brand. The brand is a phantom — no
|
|
4
|
-
* runtime work. All emission helpers funnel through these so the cast
|
|
5
|
-
* lives in one place.
|
|
6
|
-
*/
|
|
7
|
-
function cssVar(value) {
|
|
8
|
-
return value;
|
|
9
|
-
}
|
|
10
|
-
function cssSelector(value) {
|
|
11
|
-
return value;
|
|
12
|
-
}
|
|
13
|
-
function cssClassName(value) {
|
|
14
|
-
return value;
|
|
15
|
-
}
|
|
16
|
-
function cssDeclaration(value) {
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
export { cssClassName, cssDeclaration, cssSelector, cssVar };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
//#region src/captureCallerPath.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Inspect the current call stack and return the first frame whose file
|
|
4
|
-
* path sits outside the `@yahoo/uds-create-config` package itself — i.e. the
|
|
5
|
-
* user's authoring site.
|
|
6
|
-
*
|
|
7
|
-
* Stashing the path at definition time gives every config object its
|
|
8
|
-
* origin for free. Consumers (codegen, CSS scanner, AI prompt builder)
|
|
9
|
-
* read `__sourcePath` off the config map directly instead of walking
|
|
10
|
-
* the AST to re-derive where each registration was authored.
|
|
11
|
-
*
|
|
12
|
-
* The skip predicate matches `/packages/config/` (workspace
|
|
13
|
-
* layout) and `/@yahoo/uds-create-config/` (consumer node_modules layout) so
|
|
14
|
-
* internal frames never leak through. Returns `undefined` when no
|
|
15
|
-
* eligible frame is found.
|
|
16
|
-
*
|
|
17
|
-
* Stack format coverage:
|
|
18
|
-
* - Bun / V8 in-process: ` at fn (/abs/path.ts:L:C)` or bare
|
|
19
|
-
* ` at /abs/path.ts:L:C` (no parens).
|
|
20
|
-
* - Node native stacks: `file:///abs/path.ts:L:C` URL form.
|
|
21
|
-
* - Source-mapped frames downleveled through tsdown: `.js` files.
|
|
22
|
-
*
|
|
23
|
-
* The regex picks the first `(...).ext:line:col` token; the
|
|
24
|
-
* surrounding `at fn` / paren wrapping is ignored.
|
|
25
|
-
*/
|
|
26
|
-
declare function captureCallerPath(): string | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* Non-enumerable `__sourcePath` slot key. Centralized so codegen
|
|
29
|
-
* consumers and authoring helpers agree on one spelling.
|
|
30
|
-
*/
|
|
31
|
-
declare const SOURCE_PATH_KEY: "__sourcePath";
|
|
32
|
-
/**
|
|
33
|
-
* Attach `__sourcePath` to a config object non-enumerably.
|
|
34
|
-
* `JSON.stringify` ignores non-enumerable properties so the wire format
|
|
35
|
-
* stays clean.
|
|
36
|
-
*
|
|
37
|
-
* No-op when `path` is `undefined` — keeps the config shape stable
|
|
38
|
-
* when the stack-walk yields no eligible frame.
|
|
39
|
-
*/
|
|
40
|
-
declare function attachSourcePath<T extends object>(target: T, path: string | undefined): T;
|
|
41
|
-
/**
|
|
42
|
-
* Read `__sourcePath` off a config object. Returns `undefined` when
|
|
43
|
-
* the slot was never set (e.g. configs produced outside the `define*`
|
|
44
|
-
* helpers).
|
|
45
|
-
*/
|
|
46
|
-
declare function readSourcePath(target: unknown): string | undefined;
|
|
47
|
-
//#endregion
|
|
48
|
-
export { SOURCE_PATH_KEY, attachSourcePath, captureCallerPath, readSourcePath };
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
//#region src/captureCallerPath.ts
|
|
2
|
-
/**
|
|
3
|
-
* Inspect the current call stack and return the first frame whose file
|
|
4
|
-
* path sits outside the `@yahoo/uds-create-config` package itself — i.e. the
|
|
5
|
-
* user's authoring site.
|
|
6
|
-
*
|
|
7
|
-
* Stashing the path at definition time gives every config object its
|
|
8
|
-
* origin for free. Consumers (codegen, CSS scanner, AI prompt builder)
|
|
9
|
-
* read `__sourcePath` off the config map directly instead of walking
|
|
10
|
-
* the AST to re-derive where each registration was authored.
|
|
11
|
-
*
|
|
12
|
-
* The skip predicate matches `/packages/config/` (workspace
|
|
13
|
-
* layout) and `/@yahoo/uds-create-config/` (consumer node_modules layout) so
|
|
14
|
-
* internal frames never leak through. Returns `undefined` when no
|
|
15
|
-
* eligible frame is found.
|
|
16
|
-
*
|
|
17
|
-
* Stack format coverage:
|
|
18
|
-
* - Bun / V8 in-process: ` at fn (/abs/path.ts:L:C)` or bare
|
|
19
|
-
* ` at /abs/path.ts:L:C` (no parens).
|
|
20
|
-
* - Node native stacks: `file:///abs/path.ts:L:C` URL form.
|
|
21
|
-
* - Source-mapped frames downleveled through tsdown: `.js` files.
|
|
22
|
-
*
|
|
23
|
-
* The regex picks the first `(...).ext:line:col` token; the
|
|
24
|
-
* surrounding `at fn` / paren wrapping is ignored.
|
|
25
|
-
*/
|
|
26
|
-
const INTERNAL_FRAME_MARKERS = ["/packages/config/", "/@yahoo/uds-create-config/"];
|
|
27
|
-
const FRAME_PATH_RE = /\(?(?:file:\/\/)?(\/[^):\s]+?\.[cm]?[jt]sx?):\d+(?::\d+)?\)?/;
|
|
28
|
-
const TEST_FILE_RE = /\.test\.[jt]sx?$/;
|
|
29
|
-
function isInternalFrame(path) {
|
|
30
|
-
if (TEST_FILE_RE.test(path)) return false;
|
|
31
|
-
return INTERNAL_FRAME_MARKERS.some((marker) => path.includes(marker));
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* `@yahoo/uds-create-codegen`'s `loadConfig` bundles `uds.config.ts` with
|
|
35
|
-
* `Bun.build` and runs the bundle from `<cwd>/.uds/config-bundle/`.
|
|
36
|
-
* The bundle's inline sourcemap maps frames back to paths *relative
|
|
37
|
-
* to the bundle output dir* — e.g.
|
|
38
|
-
* `apps/studio/.uds/config-bundle/src/uds/components/button.tsx`,
|
|
39
|
-
* not the original `apps/studio/src/uds/components/button.tsx`.
|
|
40
|
-
* Strip the segment so `Component.sourceFilePath` resolves to a
|
|
41
|
-
* readable on-disk path. Matches `/.uds/config-bundle/` so it's
|
|
42
|
-
* agnostic to which app the bundle was emitted under.
|
|
43
|
-
*/
|
|
44
|
-
const CONFIG_BUNDLE_PATH_SEGMENT = "/.uds/config-bundle/";
|
|
45
|
-
function normalizeBundlePath(path) {
|
|
46
|
-
const idx = path.indexOf(CONFIG_BUNDLE_PATH_SEGMENT);
|
|
47
|
-
if (idx === -1) return path;
|
|
48
|
-
return path.slice(0, idx + 1) + path.slice(idx + 20);
|
|
49
|
-
}
|
|
50
|
-
function captureCallerPath() {
|
|
51
|
-
const stack = (/* @__PURE__ */ new Error()).stack;
|
|
52
|
-
if (!stack) return void 0;
|
|
53
|
-
for (const line of stack.split("\n")) {
|
|
54
|
-
const match = line.match(FRAME_PATH_RE);
|
|
55
|
-
if (!match) continue;
|
|
56
|
-
const path = normalizeBundlePath(match[1]);
|
|
57
|
-
if (isInternalFrame(path)) continue;
|
|
58
|
-
return path;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Non-enumerable `__sourcePath` slot key. Centralized so codegen
|
|
63
|
-
* consumers and authoring helpers agree on one spelling.
|
|
64
|
-
*/
|
|
65
|
-
const SOURCE_PATH_KEY = "__sourcePath";
|
|
66
|
-
/**
|
|
67
|
-
* Attach `__sourcePath` to a config object non-enumerably.
|
|
68
|
-
* `JSON.stringify` ignores non-enumerable properties so the wire format
|
|
69
|
-
* stays clean.
|
|
70
|
-
*
|
|
71
|
-
* No-op when `path` is `undefined` — keeps the config shape stable
|
|
72
|
-
* when the stack-walk yields no eligible frame.
|
|
73
|
-
*/
|
|
74
|
-
function attachSourcePath(target, path) {
|
|
75
|
-
if (!path) return target;
|
|
76
|
-
Object.defineProperty(target, SOURCE_PATH_KEY, {
|
|
77
|
-
enumerable: false,
|
|
78
|
-
configurable: true,
|
|
79
|
-
writable: true,
|
|
80
|
-
value: path
|
|
81
|
-
});
|
|
82
|
-
return target;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Read `__sourcePath` off a config object. Returns `undefined` when
|
|
86
|
-
* the slot was never set (e.g. configs produced outside the `define*`
|
|
87
|
-
* helpers).
|
|
88
|
-
*/
|
|
89
|
-
function readSourcePath(target) {
|
|
90
|
-
if (target === null || typeof target !== "object" && typeof target !== "function") return;
|
|
91
|
-
const value = target[SOURCE_PATH_KEY];
|
|
92
|
-
return typeof value === "string" ? value : void 0;
|
|
93
|
-
}
|
|
94
|
-
//#endregion
|
|
95
|
-
export { SOURCE_PATH_KEY, attachSourcePath, captureCallerPath, readSourcePath };
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { TokenRef } from "./refs.js";
|
|
2
|
-
import { CssAngle, CssColor, CssLength, CssPercentage } from "./types/css-values.js";
|
|
3
|
-
|
|
4
|
-
//#region src/colorExpressions.d.ts
|
|
5
|
-
/** Position used for gradient stops + radial center — a CSS length or percentage. */
|
|
6
|
-
type LengthOrPercent = CssLength | CssPercentage;
|
|
7
|
-
/** Line direction keyword for `linear-gradient(to <dir>, …)`. */
|
|
8
|
-
type LineDirection = 'top' | 'right' | 'bottom' | 'left' | 'top right' | 'top left' | 'bottom right' | 'bottom left';
|
|
9
|
-
/** Color space accepted by `color-mix()` and gradient `<color-interpolation-method>`. */
|
|
10
|
-
type ColorSpace = 'srgb' | 'srgb-linear' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'hsl' | 'hwb';
|
|
11
|
-
/** Radial gradient extent keyword. */
|
|
12
|
-
type RadialSize = 'closest-side' | 'closest-corner' | 'farthest-side' | 'farthest-corner';
|
|
13
|
-
interface MixExpr {
|
|
14
|
-
readonly __kind: 'mix';
|
|
15
|
-
readonly from: ColorValue;
|
|
16
|
-
readonly to: ColorValue;
|
|
17
|
-
readonly amount: CssPercentage;
|
|
18
|
-
readonly colorSpace?: ColorSpace;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* `darken(color, N)` / `lighten(color, N)` — one-arg shade shorthands that
|
|
22
|
-
* blend a color toward black (darken) or white (lighten) by `amount`%, using
|
|
23
|
-
* `light-dark(...)` so the blend direction flips per color scheme. A focused
|
|
24
|
-
* pair alongside the general `mix`; resolves through the same pipeline.
|
|
25
|
-
*/
|
|
26
|
-
interface ShadeExpr {
|
|
27
|
-
readonly __kind: 'darken' | 'lighten';
|
|
28
|
-
readonly color: ColorValue;
|
|
29
|
-
/** Mix percentage toward black/white — `10` → `10%`. */
|
|
30
|
-
readonly amount: number;
|
|
31
|
-
}
|
|
32
|
-
interface GradientStop {
|
|
33
|
-
readonly color: ColorValue;
|
|
34
|
-
readonly at?: LengthOrPercent;
|
|
35
|
-
}
|
|
36
|
-
interface LinearGradientExpr {
|
|
37
|
-
readonly __kind: 'linear-gradient';
|
|
38
|
-
readonly angle?: CssAngle | `to ${LineDirection}`;
|
|
39
|
-
readonly stops: readonly GradientStop[];
|
|
40
|
-
readonly interpolation?: ColorSpace;
|
|
41
|
-
readonly repeating?: boolean;
|
|
42
|
-
}
|
|
43
|
-
interface RadialGradientExpr {
|
|
44
|
-
readonly __kind: 'radial-gradient';
|
|
45
|
-
readonly shape?: 'circle' | 'ellipse';
|
|
46
|
-
readonly size?: RadialSize;
|
|
47
|
-
readonly position?: LengthOrPercent | 'center' | 'top' | 'right' | 'bottom' | 'left';
|
|
48
|
-
readonly stops: readonly GradientStop[];
|
|
49
|
-
readonly interpolation?: ColorSpace;
|
|
50
|
-
readonly repeating?: boolean;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Any expression / marker that resolves to a CSS color value.
|
|
54
|
-
*
|
|
55
|
-
* `TokenRef` here is intentionally un-narrowed by token type. When
|
|
56
|
-
* the `Registered*` augmentations grow a `__type` slot, this can
|
|
57
|
-
* narrow to color-typed tokens — until then runtime + patch
|
|
58
|
-
* validation catches type mismatches.
|
|
59
|
-
*/
|
|
60
|
-
type ColorValue = CssColor | TokenRef | MixExpr;
|
|
61
|
-
/** Anything that resolves to a CSS `background-image`-eligible value. */
|
|
62
|
-
type GradientValue = TokenRef | LinearGradientExpr | RadialGradientExpr;
|
|
63
|
-
/** Union of every structured expression authored via these helpers. */
|
|
64
|
-
type ColorExpression = MixExpr | ShadeExpr | LinearGradientExpr | RadialGradientExpr;
|
|
65
|
-
declare function isMixExpr(value: unknown): value is MixExpr;
|
|
66
|
-
declare function isLinearGradientExpr(value: unknown): value is LinearGradientExpr;
|
|
67
|
-
declare function isRadialGradientExpr(value: unknown): value is RadialGradientExpr;
|
|
68
|
-
declare function isColorExpression(value: unknown): value is ColorExpression;
|
|
69
|
-
/**
|
|
70
|
-
* `color-mix(in <space>, <from> <amount>, <to>)` — blend `from` and
|
|
71
|
-
* `to` at the given percentage. Inputs can be CSS color literals,
|
|
72
|
-
* `token('ns/name')` markers, or other `mix()` outputs.
|
|
73
|
-
*
|
|
74
|
-
* mix(token('bg/primary'), 'transparent', '20%')
|
|
75
|
-
* mix('#000', token('bg/accent'), '40%', 'oklab')
|
|
76
|
-
*/
|
|
77
|
-
declare function mix(from: ColorValue, to: ColorValue, amount: CssPercentage, colorSpace?: ColorSpace): MixExpr;
|
|
78
|
-
/**
|
|
79
|
-
* Opacity sugar — `alpha(color, 0.2)` resolves to
|
|
80
|
-
* `color-mix(in srgb, color 20%, transparent)`, which renders as
|
|
81
|
-
* `color` at 20% opacity. The numeric API matches `rgba()` and the
|
|
82
|
-
* CSS `opacity` property (both 0..1).
|
|
83
|
-
*
|
|
84
|
-
* Out-of-range values clamp to `[0, 1]`. The mix amount is the
|
|
85
|
-
* color's share of the blend (`color-mix(in srgb, A X%, B)` defines
|
|
86
|
-
* `X%` as A's proportion), so `opacity * 100` is exactly what goes on
|
|
87
|
-
* the wire.
|
|
88
|
-
*/
|
|
89
|
-
declare function alpha(color: ColorValue, opacity: number): MixExpr;
|
|
90
|
-
/**
|
|
91
|
-
* `darken(color, 10)` → `color-mix(in oklch, color, light-dark(black, white) 10%)`
|
|
92
|
-
* — blends `color` toward black in light mode, white in dark mode. Pairs with
|
|
93
|
-
* `lighten`. `color` is usually a `token('bg/brand')` ref but accepts any
|
|
94
|
-
* `ColorValue`.
|
|
95
|
-
*/
|
|
96
|
-
declare function darken(color: ColorValue, amount: number): ShadeExpr;
|
|
97
|
-
/** Mirror of `darken()`; blends toward white in light mode, black in dark. */
|
|
98
|
-
declare function lighten(color: ColorValue, amount: number): ShadeExpr;
|
|
99
|
-
/**
|
|
100
|
-
* `linear-gradient(<angle>, <stop1>, <stop2>, …)` — directional
|
|
101
|
-
* gradient. `angle` accepts a CSS angle (`'135deg'`) or a `to <dir>`
|
|
102
|
-
* keyword. Stops carry a `color` and optional `at` position — bare
|
|
103
|
-
* stops let the engine space evenly.
|
|
104
|
-
*/
|
|
105
|
-
declare function linearGradient(spec: {
|
|
106
|
-
angle?: CssAngle | `to ${LineDirection}`;
|
|
107
|
-
stops: readonly GradientStop[];
|
|
108
|
-
interpolation?: ColorSpace;
|
|
109
|
-
repeating?: boolean;
|
|
110
|
-
}): LinearGradientExpr;
|
|
111
|
-
/**
|
|
112
|
-
* `radial-gradient(<shape> <size> at <position>, <stop1>, …)` —
|
|
113
|
-
* gradient radiating outward from `position`. Defaults match CSS
|
|
114
|
-
* (ellipse at center).
|
|
115
|
-
*/
|
|
116
|
-
declare function radialGradient(spec: {
|
|
117
|
-
shape?: 'circle' | 'ellipse';
|
|
118
|
-
size?: RadialSize;
|
|
119
|
-
position?: LengthOrPercent | 'center' | 'top' | 'right' | 'bottom' | 'left';
|
|
120
|
-
stops: readonly GradientStop[];
|
|
121
|
-
interpolation?: ColorSpace;
|
|
122
|
-
repeating?: boolean;
|
|
123
|
-
}): RadialGradientExpr;
|
|
124
|
-
type TokenRefToCss = (ref: string) => string;
|
|
125
|
-
/**
|
|
126
|
-
* Resolve any structured color expression to its CSS string. The
|
|
127
|
-
* single entry point codegen calls after `isColorExpression` fires.
|
|
128
|
-
*/
|
|
129
|
-
declare function resolveColorExpression(expr: ColorExpression, tokenRefToCss: TokenRefToCss): string;
|
|
130
|
-
//#endregion
|
|
131
|
-
export { ColorExpression, ColorSpace, ColorValue, GradientStop, GradientValue, LengthOrPercent, LineDirection, LinearGradientExpr, MixExpr, RadialGradientExpr, RadialSize, TokenRefToCss, alpha, darken, isColorExpression, isLinearGradientExpr, isMixExpr, isRadialGradientExpr, lighten, linearGradient, mix, radialGradient, resolveColorExpression };
|
package/dist/colorExpressions.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { isTokenRef } from "./refs.js";
|
|
2
|
-
//#region src/colorExpressions.ts
|
|
3
|
-
function hasKind(value, kind) {
|
|
4
|
-
return typeof value === "object" && value !== null && value.__kind === kind;
|
|
5
|
-
}
|
|
6
|
-
function isMixExpr(value) {
|
|
7
|
-
return hasKind(value, "mix");
|
|
8
|
-
}
|
|
9
|
-
function isShadeExpr(value) {
|
|
10
|
-
return hasKind(value, "darken") || hasKind(value, "lighten");
|
|
11
|
-
}
|
|
12
|
-
function isLinearGradientExpr(value) {
|
|
13
|
-
return hasKind(value, "linear-gradient");
|
|
14
|
-
}
|
|
15
|
-
function isRadialGradientExpr(value) {
|
|
16
|
-
return hasKind(value, "radial-gradient");
|
|
17
|
-
}
|
|
18
|
-
function isColorExpression(value) {
|
|
19
|
-
return isMixExpr(value) || isShadeExpr(value) || isLinearGradientExpr(value) || isRadialGradientExpr(value);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* `color-mix(in <space>, <from> <amount>, <to>)` — blend `from` and
|
|
23
|
-
* `to` at the given percentage. Inputs can be CSS color literals,
|
|
24
|
-
* `token('ns/name')` markers, or other `mix()` outputs.
|
|
25
|
-
*
|
|
26
|
-
* mix(token('bg/primary'), 'transparent', '20%')
|
|
27
|
-
* mix('#000', token('bg/accent'), '40%', 'oklab')
|
|
28
|
-
*/
|
|
29
|
-
function mix(from, to, amount, colorSpace) {
|
|
30
|
-
return {
|
|
31
|
-
__kind: "mix",
|
|
32
|
-
from,
|
|
33
|
-
to,
|
|
34
|
-
amount,
|
|
35
|
-
colorSpace
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Opacity sugar — `alpha(color, 0.2)` resolves to
|
|
40
|
-
* `color-mix(in srgb, color 20%, transparent)`, which renders as
|
|
41
|
-
* `color` at 20% opacity. The numeric API matches `rgba()` and the
|
|
42
|
-
* CSS `opacity` property (both 0..1).
|
|
43
|
-
*
|
|
44
|
-
* Out-of-range values clamp to `[0, 1]`. The mix amount is the
|
|
45
|
-
* color's share of the blend (`color-mix(in srgb, A X%, B)` defines
|
|
46
|
-
* `X%` as A's proportion), so `opacity * 100` is exactly what goes on
|
|
47
|
-
* the wire.
|
|
48
|
-
*/
|
|
49
|
-
function alpha(color, opacity) {
|
|
50
|
-
return {
|
|
51
|
-
__kind: "mix",
|
|
52
|
-
from: color,
|
|
53
|
-
to: "transparent",
|
|
54
|
-
amount: `${Math.round(Math.max(0, Math.min(1, opacity)) * 100)}%`,
|
|
55
|
-
colorSpace: "srgb"
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* `darken(color, 10)` → `color-mix(in oklch, color, light-dark(black, white) 10%)`
|
|
60
|
-
* — blends `color` toward black in light mode, white in dark mode. Pairs with
|
|
61
|
-
* `lighten`. `color` is usually a `token('bg/brand')` ref but accepts any
|
|
62
|
-
* `ColorValue`.
|
|
63
|
-
*/
|
|
64
|
-
function darken(color, amount) {
|
|
65
|
-
return {
|
|
66
|
-
__kind: "darken",
|
|
67
|
-
color,
|
|
68
|
-
amount
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
/** Mirror of `darken()`; blends toward white in light mode, black in dark. */
|
|
72
|
-
function lighten(color, amount) {
|
|
73
|
-
return {
|
|
74
|
-
__kind: "lighten",
|
|
75
|
-
color,
|
|
76
|
-
amount
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* `linear-gradient(<angle>, <stop1>, <stop2>, …)` — directional
|
|
81
|
-
* gradient. `angle` accepts a CSS angle (`'135deg'`) or a `to <dir>`
|
|
82
|
-
* keyword. Stops carry a `color` and optional `at` position — bare
|
|
83
|
-
* stops let the engine space evenly.
|
|
84
|
-
*/
|
|
85
|
-
function linearGradient(spec) {
|
|
86
|
-
return {
|
|
87
|
-
__kind: "linear-gradient",
|
|
88
|
-
...spec
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* `radial-gradient(<shape> <size> at <position>, <stop1>, …)` —
|
|
93
|
-
* gradient radiating outward from `position`. Defaults match CSS
|
|
94
|
-
* (ellipse at center).
|
|
95
|
-
*/
|
|
96
|
-
function radialGradient(spec) {
|
|
97
|
-
return {
|
|
98
|
-
__kind: "radial-gradient",
|
|
99
|
-
...spec
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function resolveColorValue(value, tokenRefToCss) {
|
|
103
|
-
if (typeof value === "string") return value;
|
|
104
|
-
if (isMixExpr(value)) return resolveMixExpr(value, tokenRefToCss);
|
|
105
|
-
if (isTokenRef(value)) return tokenRefToCss(value.ref);
|
|
106
|
-
return "";
|
|
107
|
-
}
|
|
108
|
-
function resolveMixExpr(expr, tokenRefToCss) {
|
|
109
|
-
const space = expr.colorSpace ?? "srgb";
|
|
110
|
-
const from = resolveColorValue(expr.from, tokenRefToCss);
|
|
111
|
-
const to = resolveColorValue(expr.to, tokenRefToCss);
|
|
112
|
-
return `color-mix(in ${space}, ${from} ${expr.amount}, ${to})`;
|
|
113
|
-
}
|
|
114
|
-
function resolveShadeExpr(expr, tokenRefToCss) {
|
|
115
|
-
return `color-mix(in oklch, ${resolveColorValue(expr.color, tokenRefToCss)}, ${expr.__kind === "darken" ? "light-dark(black, white)" : "light-dark(white, black)"} ${expr.amount}%)`;
|
|
116
|
-
}
|
|
117
|
-
function renderStops(stops, tokenRefToCss) {
|
|
118
|
-
const parts = [];
|
|
119
|
-
for (const stop of stops) {
|
|
120
|
-
const color = resolveColorValue(stop.color, tokenRefToCss);
|
|
121
|
-
parts.push(stop.at !== void 0 ? `${color} ${stop.at}` : color);
|
|
122
|
-
}
|
|
123
|
-
return parts.join(", ");
|
|
124
|
-
}
|
|
125
|
-
function resolveLinearGradientExpr(expr, tokenRefToCss) {
|
|
126
|
-
const fn = expr.repeating ? "repeating-linear-gradient" : "linear-gradient";
|
|
127
|
-
const prefix = expr.angle !== void 0 ? `${expr.angle}, ` : "";
|
|
128
|
-
return `${fn}(${expr.interpolation ? `in ${expr.interpolation}, ` : ""}${prefix}${renderStops(expr.stops, tokenRefToCss)})`;
|
|
129
|
-
}
|
|
130
|
-
function resolveRadialGradientExpr(expr, tokenRefToCss) {
|
|
131
|
-
const fn = expr.repeating ? "repeating-radial-gradient" : "radial-gradient";
|
|
132
|
-
const shapeAndSize = [expr.shape ?? "", expr.size ?? ""].filter(Boolean).join(" ");
|
|
133
|
-
const positionPart = expr.position ? ` at ${expr.position}` : "";
|
|
134
|
-
const head = shapeAndSize || positionPart ? `${shapeAndSize}${positionPart}, ` : "";
|
|
135
|
-
return `${fn}(${expr.interpolation ? `in ${expr.interpolation}, ` : ""}${head}${renderStops(expr.stops, tokenRefToCss)})`;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Resolve any structured color expression to its CSS string. The
|
|
139
|
-
* single entry point codegen calls after `isColorExpression` fires.
|
|
140
|
-
*/
|
|
141
|
-
function resolveColorExpression(expr, tokenRefToCss) {
|
|
142
|
-
if (isMixExpr(expr)) return resolveMixExpr(expr, tokenRefToCss);
|
|
143
|
-
if (isShadeExpr(expr)) return resolveShadeExpr(expr, tokenRefToCss);
|
|
144
|
-
if (isLinearGradientExpr(expr)) return resolveLinearGradientExpr(expr, tokenRefToCss);
|
|
145
|
-
return resolveRadialGradientExpr(expr, tokenRefToCss);
|
|
146
|
-
}
|
|
147
|
-
//#endregion
|
|
148
|
-
export { alpha, darken, isColorExpression, isLinearGradientExpr, isMixExpr, isRadialGradientExpr, lighten, linearGradient, mix, radialGradient, resolveColorExpression };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Config } from "./Config.js";
|
|
2
|
-
|
|
3
|
-
//#region src/component-referrers.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Components that would dangle if `component` were deleted. Three reference
|
|
6
|
-
* channels, all on *other* components:
|
|
7
|
-
* - **layer / render-spec ref** — a component renders the target as one of
|
|
8
|
-
* its layers (`Layer.renders.kind === 'component'`), surfaced via the
|
|
9
|
-
* config's `dependentsOf({ kind: 'component' })` reverse walk;
|
|
10
|
-
* - **extends** — a component value-extends the target (`extendsFrom`);
|
|
11
|
-
* - **subcomponent** — the target owns child components declared through
|
|
12
|
-
* `.subcomponents({...})` (`derived.subcomponentOf`), which would lose
|
|
13
|
-
* their parent.
|
|
14
|
-
*
|
|
15
|
-
* The result is a deduped list of qualified referrer descriptions
|
|
16
|
-
* (`component:`, `extends:`, `subcomponent:` prefixes) for the
|
|
17
|
-
* `component-delete` validator's `REFERRERS_BLOCK` message. Self-references
|
|
18
|
-
* are excluded.
|
|
19
|
-
*
|
|
20
|
-
* This lives in `@yahoo/uds-create-config` — the lowest common dependency —
|
|
21
|
-
* so it has a single home shared by both consumers: the server-side
|
|
22
|
-
* `component-delete` validator (the source of truth for the actual refusal)
|
|
23
|
-
* and the Studio GUI, which calls it to disable the delete affordance up
|
|
24
|
-
* front so the user never triggers a delete the validator would reject.
|
|
25
|
-
* `component` is the bare registry name (the `config.components` key), not a
|
|
26
|
-
* namespaced spec type.
|
|
27
|
-
*/
|
|
28
|
-
declare function findComponentReferrers(config: Config, component: string): string[];
|
|
29
|
-
//#endregion
|
|
30
|
-
export { findComponentReferrers };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
//#region src/component-referrers.ts
|
|
2
|
-
/**
|
|
3
|
-
* Components that would dangle if `component` were deleted. Three reference
|
|
4
|
-
* channels, all on *other* components:
|
|
5
|
-
* - **layer / render-spec ref** — a component renders the target as one of
|
|
6
|
-
* its layers (`Layer.renders.kind === 'component'`), surfaced via the
|
|
7
|
-
* config's `dependentsOf({ kind: 'component' })` reverse walk;
|
|
8
|
-
* - **extends** — a component value-extends the target (`extendsFrom`);
|
|
9
|
-
* - **subcomponent** — the target owns child components declared through
|
|
10
|
-
* `.subcomponents({...})` (`derived.subcomponentOf`), which would lose
|
|
11
|
-
* their parent.
|
|
12
|
-
*
|
|
13
|
-
* The result is a deduped list of qualified referrer descriptions
|
|
14
|
-
* (`component:`, `extends:`, `subcomponent:` prefixes) for the
|
|
15
|
-
* `component-delete` validator's `REFERRERS_BLOCK` message. Self-references
|
|
16
|
-
* are excluded.
|
|
17
|
-
*
|
|
18
|
-
* This lives in `@yahoo/uds-create-config` — the lowest common dependency —
|
|
19
|
-
* so it has a single home shared by both consumers: the server-side
|
|
20
|
-
* `component-delete` validator (the source of truth for the actual refusal)
|
|
21
|
-
* and the Studio GUI, which calls it to disable the delete affordance up
|
|
22
|
-
* front so the user never triggers a delete the validator would reject.
|
|
23
|
-
* `component` is the bare registry name (the `config.components` key), not a
|
|
24
|
-
* namespaced spec type.
|
|
25
|
-
*/
|
|
26
|
-
function findComponentReferrers(config, component) {
|
|
27
|
-
const referrers = /* @__PURE__ */ new Set();
|
|
28
|
-
for (const ref of config.dependentsOf({
|
|
29
|
-
kind: "component",
|
|
30
|
-
name: component
|
|
31
|
-
})) if (ref.kind === "component" && ref.name !== component) referrers.add(`component:${ref.name}`);
|
|
32
|
-
for (const [name, comp] of config.components) {
|
|
33
|
-
if (name === component) continue;
|
|
34
|
-
if (comp.extendsFrom === component) referrers.add(`extends:${name}`);
|
|
35
|
-
if (comp.derived.subcomponentOf === component) referrers.add(`subcomponent:${name}`);
|
|
36
|
-
}
|
|
37
|
-
return [...referrers];
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
export { findComponentReferrers };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//#region src/config-diagnostics.d.ts
|
|
2
|
-
/** A stable definition locator that UI, CLI, and migration callers can show. */
|
|
3
|
-
interface ConfigDiagnosticDefinition {
|
|
4
|
-
kind: string;
|
|
5
|
-
name?: string;
|
|
6
|
-
}
|
|
7
|
-
/** Platform-neutral structured config diagnostic. */
|
|
8
|
-
interface ConfigDiagnostic<TCode extends string = string> {
|
|
9
|
-
code: TCode;
|
|
10
|
-
severity: 'error' | 'warning';
|
|
11
|
-
path: readonly (string | number)[];
|
|
12
|
-
definition: ConfigDiagnosticDefinition;
|
|
13
|
-
reason: string;
|
|
14
|
-
}
|
|
15
|
-
/** Structured config failure shared by platform validators. */
|
|
16
|
-
declare class ConfigValidationError<TDiagnostic extends ConfigDiagnostic = ConfigDiagnostic> extends Error {
|
|
17
|
-
readonly diagnostics: readonly TDiagnostic[];
|
|
18
|
-
constructor(diagnostics: readonly TDiagnostic[], message?: string);
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
export { ConfigDiagnostic, ConfigDiagnosticDefinition, ConfigValidationError };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//#region src/config-diagnostics.ts
|
|
2
|
-
/** Structured config failure shared by platform validators. */
|
|
3
|
-
var ConfigValidationError = class extends Error {
|
|
4
|
-
diagnostics;
|
|
5
|
-
constructor(diagnostics, message = "Invalid config") {
|
|
6
|
-
super(diagnostics.length === 0 ? message : `${message}: ${diagnostics.map((diagnostic) => diagnostic.reason).join("; ")}`);
|
|
7
|
-
this.name = "ConfigValidationError";
|
|
8
|
-
this.diagnostics = diagnostics;
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
//#endregion
|
|
12
|
-
export { ConfigValidationError };
|