@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
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { ComponentRef } from "./refs.js";
|
|
2
|
-
import { FontAssetMember } from "./types.js";
|
|
3
|
-
|
|
4
|
-
//#region src/defineAssetGroup.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Static metadata an icon-class member may carry (the UDS v3 generated
|
|
7
|
-
* icons stamp this shape). All fields optional — metadata-less
|
|
8
|
-
* libraries (Phosphor) fall back to the documented harvest convention
|
|
9
|
-
* (PascalCase export key + component-shaped value).
|
|
10
|
-
*/
|
|
11
|
-
interface IconAssetMetadata {
|
|
12
|
-
readonly name?: string;
|
|
13
|
-
readonly isSvgIcon?: boolean;
|
|
14
|
-
readonly variants?: readonly string[];
|
|
15
|
-
readonly category?: string;
|
|
16
|
-
readonly tags?: readonly string[];
|
|
17
|
-
/**
|
|
18
|
-
* Variants whose glyph paints a literal white fill by design (a "knockout"
|
|
19
|
-
* meant for dark or branded surfaces) rather than `currentColor`. Such a
|
|
20
|
-
* glyph is invisible on a light surface, so pickers and catalogs preview
|
|
21
|
-
* these variants on a dark surface. Rendering is untouched — the flag is
|
|
22
|
-
* presentation advice for browsing UIs only.
|
|
23
|
-
*/
|
|
24
|
-
readonly knockoutVariants?: readonly string[];
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Author-supplied metadata layered over a harvested member. `name` is the
|
|
28
|
-
* member's identity, `isSvgIcon` controls the harvest itself, and `variants`
|
|
29
|
-
* states what the glyph can actually render — none of those can be overlaid
|
|
30
|
-
* (an overlaid `variants` would silently hide real variants from the picker).
|
|
31
|
-
* The descriptive fields are fair game for annotating a third-party library
|
|
32
|
-
* whose own `.metadata` doesn't carry them.
|
|
33
|
-
*/
|
|
34
|
-
type IconAssetMetadataOverlay = Pick<IconAssetMetadata, 'category' | 'tags' | 'knockoutVariants'>;
|
|
35
|
-
/**
|
|
36
|
-
* One icon-class member — a React component (plain function or a
|
|
37
|
-
* forwardRef/memo exotic) optionally carrying static `.metadata`.
|
|
38
|
-
* Typed structurally so `@yahoo/uds-create-config` doesn't depend on React types
|
|
39
|
-
* here; the renderer casts at the registry boundary.
|
|
40
|
-
*/
|
|
41
|
-
type IconAssetMember = ((props: never) => unknown) & {
|
|
42
|
-
readonly metadata?: IconAssetMetadata;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Icon branch — `type` is optional so icon authors never declare the
|
|
46
|
-
* class. `sizes` is required unless `props` is used (which normalizes
|
|
47
|
-
* into the flat fields). It's load-bearing render data (the `<svg>`
|
|
48
|
-
* shell reads px from it) and the picker's size-option list is derived
|
|
49
|
-
* from its keys.
|
|
50
|
-
*/
|
|
51
|
-
interface IconAssetGroupConfig<P = Record<string, unknown>> {
|
|
52
|
-
type?: 'icon';
|
|
53
|
-
/** Named size → px (`{ sm: 16, md: 24 }`). Picker options = keys. */
|
|
54
|
-
sizes?: Readonly<Record<string, number>>;
|
|
55
|
-
/**
|
|
56
|
-
* Group-level variant superset the picker starts from. Omitted ⇒
|
|
57
|
-
* harvested union of members' `.metadata.variants` (first-seen
|
|
58
|
-
* order), which by construction can't drift behind the library.
|
|
59
|
-
* Required (in practice) for metadata-less libraries.
|
|
60
|
-
*/
|
|
61
|
-
variants?: readonly string[];
|
|
62
|
-
/** Display label. Defaults to the title-cased registration key. */
|
|
63
|
-
label?: string;
|
|
64
|
-
/**
|
|
65
|
-
* Source-library version shown in the Assets UI (e.g. `2.1.1`). Authored,
|
|
66
|
-
* not derived — a set's published version rarely matches the npm package
|
|
67
|
-
* that ships its glyphs. Omitted ⇒ no version is shown.
|
|
68
|
-
*/
|
|
69
|
-
version?: string;
|
|
70
|
-
description?: string;
|
|
71
|
-
/**
|
|
72
|
-
* Filter harvested members by their export key — return `false` to skip one.
|
|
73
|
-
* A large third-party package often ships more than its canonical glyph set
|
|
74
|
-
* (Phosphor exports both `HouseIcon` and a deprecated bare `House` alias, plus
|
|
75
|
-
* non-glyph `IconBase`/`IconContext`). Passing the package wildcard is required
|
|
76
|
-
* for codegen to bundle live members, so this predicate is how you narrow that
|
|
77
|
-
* wildcard to the real icons (e.g. `(n) => n.endsWith('Icon')`). Applied before
|
|
78
|
-
* the PascalCase / component-shape checks; runs over every export key.
|
|
79
|
-
*/
|
|
80
|
-
include?: (name: string) => boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Per-member metadata layered over the harvested `.metadata`, keyed by asset
|
|
83
|
-
* name. Use it to annotate a third-party library whose glyphs don't carry a
|
|
84
|
-
* field themselves — e.g. flag `knockoutVariants` from a list the package
|
|
85
|
-
* exports separately. Overlay fields win over harvested ones. A key that
|
|
86
|
-
* exists in the member map but wasn't harvested (filtered by `include`, or
|
|
87
|
-
* skipped by the naming rules) is ignored; a key that names nothing in the
|
|
88
|
-
* member map is a typo and throws.
|
|
89
|
-
*/
|
|
90
|
-
memberMetadata?: Readonly<Record<string, IconAssetMetadataOverlay>>;
|
|
91
|
-
/**
|
|
92
|
-
* Authoring sugar mirroring the member component's own prop axes. Each entry
|
|
93
|
-
* is a picker value-set, NOT a style map: keys are the member's
|
|
94
|
-
* prop names, values are the allowed choices. Exactly ONE entry must be a
|
|
95
|
-
* named→px MAP (the size axis); at most one entry may be an ARRAY (the variant
|
|
96
|
-
* axis). Normalized at config-eval into the flat `sizes`/`variants` fields.
|
|
97
|
-
* Cannot be combined with those flat fields. Type the members via
|
|
98
|
-
* `defineAssetGroup<IconProps>(...)` to constrain keys to the component's
|
|
99
|
-
* props (e.g. `variant` → its enum).
|
|
100
|
-
*/
|
|
101
|
-
props?: { [K in keyof P]?: Readonly<Record<string, number>> | readonly NonNullable<P[K]>[] };
|
|
102
|
-
/**
|
|
103
|
-
* The component that authors this group's members in exported code —
|
|
104
|
-
* e.g. `'Icon'` so a placed asset node `yahoo-os:asset:icons/Trophy`
|
|
105
|
-
* round-trips through code views as `<Icon name="Trophy" … />`. There
|
|
106
|
-
* is no implicit link between a group and a component (a group's members
|
|
107
|
-
* and a component's `name` enum are decoupled even when built from the
|
|
108
|
-
* same package), so the authoring component is declared explicitly.
|
|
109
|
-
* It is also the component a placed member *renders through* on the canvas:
|
|
110
|
-
* the resolved `Icon` owns the set-specific size/variant→glyph mapping. Omit
|
|
111
|
-
* it for a component-less system: members render bare and exporters fall back
|
|
112
|
-
* to the bare member tag. Accepts a typed `ComponentRef` (from
|
|
113
|
-
* `component()`) or a bare string.
|
|
114
|
-
*/
|
|
115
|
-
component?: string | ComponentRef;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Font branch — `type: 'font'` declares the class. The `never` fields
|
|
119
|
-
* make icon-class props a compile error inside a `{ type: 'font' }`
|
|
120
|
-
* literal regardless of property order (the union is ordering-free,
|
|
121
|
-
* unlike the chained-methods spelling it replaced).
|
|
122
|
-
*/
|
|
123
|
-
interface FontAssetGroupConfig {
|
|
124
|
-
type: 'font';
|
|
125
|
-
label?: string;
|
|
126
|
-
/** Source-library version shown in the Assets UI (e.g. `2.1.1`). */
|
|
127
|
-
version?: string;
|
|
128
|
-
description?: string;
|
|
129
|
-
/**
|
|
130
|
-
* FontIDs to fold in as deprecated at registration — each listed
|
|
131
|
-
* member is stamped `deprecated: true`. Deprecated fonts stay fully
|
|
132
|
-
* selectable (no hard block); the flag only lets the picker badge them.
|
|
133
|
-
* An id not present in the member map is ignored.
|
|
134
|
-
*/
|
|
135
|
-
deprecated?: readonly string[];
|
|
136
|
-
/** Icon-class prop — excluded on the font branch at the type level. */
|
|
137
|
-
sizes?: never;
|
|
138
|
-
/** Icon-class prop — excluded on the font branch at the type level. */
|
|
139
|
-
variants?: never;
|
|
140
|
-
/** Icon-class prop — excluded on the font branch at the type level. */
|
|
141
|
-
props?: never;
|
|
142
|
-
/** Icon-class prop — excluded on the font branch at the type level. */
|
|
143
|
-
component?: never;
|
|
144
|
-
}
|
|
145
|
-
type AssetGroupConfig = IconAssetGroupConfig<Record<string, unknown>> | FontAssetGroupConfig;
|
|
146
|
-
interface AssetGroupDefinitionBase {
|
|
147
|
-
/** Invariant ref tag — identical for every asset class. */
|
|
148
|
-
readonly __kind: 'assetGroup';
|
|
149
|
-
/**
|
|
150
|
-
* The group's slug — late-bound from the `registerAssetGroups`
|
|
151
|
-
* record key. Reading before registration throws.
|
|
152
|
-
*/
|
|
153
|
-
readonly ref: string;
|
|
154
|
-
readonly label?: string;
|
|
155
|
-
readonly version?: string;
|
|
156
|
-
readonly description?: string;
|
|
157
|
-
}
|
|
158
|
-
interface IconAssetGroupDefinition extends AssetGroupDefinitionBase {
|
|
159
|
-
readonly assetKind: 'icon';
|
|
160
|
-
/** Harvested members, keyed by asset name (the `${assetName}` id segment). */
|
|
161
|
-
readonly members: Readonly<Record<string, IconAssetMember>>;
|
|
162
|
-
/** Per-member harvested `.metadata` (name/variants/category/tags). */
|
|
163
|
-
readonly memberMetadata: Readonly<Record<string, IconAssetMetadata>>;
|
|
164
|
-
readonly sizes: Readonly<Record<string, number>>;
|
|
165
|
-
/** Resolved variant superset — declared, or the harvested union. */
|
|
166
|
-
readonly variants: readonly string[];
|
|
167
|
-
/** Authoring component for code export (`'Icon'`), if declared. */
|
|
168
|
-
readonly component?: string;
|
|
169
|
-
}
|
|
170
|
-
interface FontAssetGroupDefinition extends AssetGroupDefinitionBase {
|
|
171
|
-
readonly assetKind: 'font';
|
|
172
|
-
/** Members keyed by `FontID` (kebab-case) — pure-JSON data records. */
|
|
173
|
-
readonly members: Readonly<Record<string, FontAssetMember>>;
|
|
174
|
-
}
|
|
175
|
-
type AssetGroupDefinition = IconAssetGroupDefinition | FontAssetGroupDefinition;
|
|
176
|
-
/**
|
|
177
|
-
* `defineAssetGroup(members)` return value — the only thing you can do
|
|
178
|
-
* with it is `.config({...})`, which completes the definition. The
|
|
179
|
-
* overloads branch the return type on the config union's discriminant.
|
|
180
|
-
* The phantom `P` generic flows from `defineAssetGroup<P>(...)` and
|
|
181
|
-
* constrains the `props` block keys/values to the member component's
|
|
182
|
-
* own props.
|
|
183
|
-
*/
|
|
184
|
-
interface AssetGroupBuilder<P = Record<string, unknown>> {
|
|
185
|
-
config(config: IconAssetGroupConfig<P>): IconAssetGroupDefinition;
|
|
186
|
-
config(config: FontAssetGroupConfig): FontAssetGroupDefinition;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Attach icon metadata to a single one-off icon and hand it back
|
|
190
|
-
* unchanged. `isSvgIcon: true` is implied —
|
|
191
|
-
* the point of the call is to mark the component as an icon so the
|
|
192
|
-
* group harvest picks it up. Slots still point at the *group*, never
|
|
193
|
-
* at this.
|
|
194
|
-
*/
|
|
195
|
-
declare function defineAssetIcon<T>(component: T, metadata: Omit<IconAssetMetadata, 'isSvgIcon'>): T & {
|
|
196
|
-
readonly metadata: IconAssetMetadata;
|
|
197
|
-
};
|
|
198
|
-
declare function defineAssetGroup<P = Record<string, unknown>>(members: Readonly<Record<string, unknown>>): AssetGroupBuilder<P>;
|
|
199
|
-
//#endregion
|
|
200
|
-
export { AssetGroupBuilder, AssetGroupConfig, AssetGroupDefinition, FontAssetGroupConfig, FontAssetGroupDefinition, IconAssetGroupConfig, IconAssetGroupDefinition, IconAssetMember, IconAssetMetadata, IconAssetMetadataOverlay, defineAssetGroup, defineAssetIcon };
|
package/dist/defineAssetGroup.js
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import { attachSourcePath, captureCallerPath } from "./captureCallerPath.js";
|
|
2
|
-
import { isComponentRef } from "./refs.js";
|
|
3
|
-
//#region src/defineAssetGroup.ts
|
|
4
|
-
/**
|
|
5
|
-
* `defineAssetGroup(members).config({...})` — the asset registration
|
|
6
|
-
* factory. Members are positional (matching
|
|
7
|
-
* `defineTokenGroup(tokens)`, wildcard-import friendly); everything
|
|
8
|
-
* else lives in one chained `.config({...})` discriminated-union.
|
|
9
|
-
*
|
|
10
|
-
* The return value does double duty, the same way `BoundComponent` is
|
|
11
|
-
* both a `ComponentDefinition` and an `FC`:
|
|
12
|
-
*
|
|
13
|
-
* - it is the registerable group (`uds.registerAssetGroups({ icons })`
|
|
14
|
-
* reads `members` + config fields off it), and
|
|
15
|
-
* - it carries the embedded `__kind: 'assetGroup'` / `ref` tag that
|
|
16
|
-
* `isAssetGroupRef()` / `slot().accepts(...)` read.
|
|
17
|
-
*
|
|
18
|
-
* The `ref` slug is bound late: `registerAssetGroups` stamps the
|
|
19
|
-
* registration key onto the object (the key IS the slug — same
|
|
20
|
-
* late-binding precedent as `Component.registryKey`'s namespace
|
|
21
|
-
* getter). Reading `ref` before registration throws — an unregistered
|
|
22
|
-
* group has no identity to point at.
|
|
23
|
-
*/
|
|
24
|
-
/** Icon-class asset names are PascalCase identifiers — each asset class has its own naming rule (fonts use kebab-case below). */
|
|
25
|
-
const PASCAL_CASE = /^[A-Z][A-Za-z0-9]*$/;
|
|
26
|
-
/** Font-class asset names are kebab-case `FontID`s (`yas`, `centra-no2`). */
|
|
27
|
-
const KEBAB_CASE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
28
|
-
/**
|
|
29
|
-
* Component-shaped: a plain function component, or a forwardRef/memo
|
|
30
|
-
* exotic (an object stamped with React's `$$typeof` symbol).
|
|
31
|
-
*/
|
|
32
|
-
function isComponentShaped(value) {
|
|
33
|
-
if (typeof value === "function") return true;
|
|
34
|
-
return typeof value === "object" && value !== null && typeof value.$$typeof === "symbol";
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Read and *sanitize* a member's static `.metadata`. The harvest is the
|
|
38
|
-
* trust boundary for arbitrary wildcard imports, so loosely-shaped
|
|
39
|
-
* fields are dropped rather than cast — `variants: 'outline'` must not
|
|
40
|
-
* iterate char-by-char into `['o','u','t',…]` downstream.
|
|
41
|
-
*/
|
|
42
|
-
function readIconMetadata(value) {
|
|
43
|
-
if (typeof value !== "function" && typeof value !== "object") return;
|
|
44
|
-
if (value === null) return void 0;
|
|
45
|
-
const metadata = value.metadata;
|
|
46
|
-
if (metadata === null || typeof metadata !== "object") return void 0;
|
|
47
|
-
const raw = metadata;
|
|
48
|
-
const out = {};
|
|
49
|
-
if (typeof raw.name === "string" && raw.name.length > 0) out.name = raw.name;
|
|
50
|
-
if (typeof raw.isSvgIcon === "boolean") out.isSvgIcon = raw.isSvgIcon;
|
|
51
|
-
if (isStringArray(raw.variants)) out.variants = raw.variants;
|
|
52
|
-
Object.assign(out, sanitizeOverlayFields(raw));
|
|
53
|
-
return out;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* The author-overlayable subset of icon metadata, sanitized the same way the
|
|
57
|
-
* harvest sanitizes a member's own `.metadata`: loosely-shaped values are
|
|
58
|
-
* dropped, never cast. Shared by {@link readIconMetadata} and the
|
|
59
|
-
* `memberMetadata` overlay so the two entry points into the wire form can't
|
|
60
|
-
* disagree about what a well-formed field is.
|
|
61
|
-
*/
|
|
62
|
-
function sanitizeOverlayFields(raw) {
|
|
63
|
-
const out = {};
|
|
64
|
-
if (typeof raw.category === "string") out.category = raw.category;
|
|
65
|
-
if (isStringArray(raw.tags)) out.tags = raw.tags;
|
|
66
|
-
if (isStringArray(raw.knockoutVariants)) out.knockoutVariants = raw.knockoutVariants;
|
|
67
|
-
return out;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Layer the author's `memberMetadata` overlay onto the harvested metadata.
|
|
71
|
-
* Only well-formed overlay fields replace harvested ones, so a sparse entry
|
|
72
|
-
* (`{ knockoutVariants: [...] }`) leaves the library's category/tags intact.
|
|
73
|
-
*
|
|
74
|
-
* Keys are asset names (post-rename). A key that names nothing in the source
|
|
75
|
-
* export map is a typo and throws by name. A key that IS an export but was not
|
|
76
|
-
* harvested — filtered out by `include`, or skipped by the naming rules — is
|
|
77
|
-
* ignored, so an author narrowing a wildcard doesn't also have to prune a
|
|
78
|
-
* boilerplate overlay (the emitted v3 config lists the package's knockout
|
|
79
|
-
* glyphs unconditionally).
|
|
80
|
-
*/
|
|
81
|
-
function applyMetadataOverlay(harvested, overlay, sourceKeys) {
|
|
82
|
-
if (overlay === void 0) return harvested;
|
|
83
|
-
const out = { ...harvested };
|
|
84
|
-
for (const [name, fields] of Object.entries(overlay)) {
|
|
85
|
-
if (out[name] === void 0) {
|
|
86
|
-
if (sourceKeys.has(name)) continue;
|
|
87
|
-
throw new Error(`defineAssetGroup: \`memberMetadata.${name}\` names an asset that does not exist in the member map — overlay keys must match a member's asset name.`);
|
|
88
|
-
}
|
|
89
|
-
out[name] = {
|
|
90
|
-
...out[name],
|
|
91
|
-
...sanitizeOverlayFields(fields)
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
return out;
|
|
95
|
-
}
|
|
96
|
-
function isStringArray(value) {
|
|
97
|
-
return Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Icon-class harvest. Wildcard `import * as` carries everything a
|
|
101
|
-
* package exports — helpers, constants, possibly `default` — so
|
|
102
|
-
* non-matching exports are *skipped*, not errors:
|
|
103
|
-
*
|
|
104
|
-
* - `.metadata.isSvgIcon === true` is definitive — the member is an
|
|
105
|
-
* icon (named via `.metadata.name`, falling back to the export key).
|
|
106
|
-
* - `.metadata.isSvgIcon === false` is the explicit opt-out — skipped.
|
|
107
|
-
* Unrelated metadata (no `isSvgIcon` field) does NOT opt out; the
|
|
108
|
-
* convention below still applies, so one foreign metadata shape
|
|
109
|
-
* can't silently shrink the harvest.
|
|
110
|
-
* - Otherwise the documented convention applies: PascalCase export
|
|
111
|
-
* key + component-shaped value (covers metadata-less Phosphor-style
|
|
112
|
-
* libraries).
|
|
113
|
-
* - `default` is never registered literally — it registers only when
|
|
114
|
-
* explicit icon metadata supplies a usable PascalCase name (i.e. it
|
|
115
|
-
* gets renamed), and is otherwise skipped as wildcard noise. This
|
|
116
|
-
* deliberately includes an explicit-icon `default` whose
|
|
117
|
-
* `.metadata.name` fails the PascalCase rule: it is *skipped*, not
|
|
118
|
-
* thrown — unlike the same mistake on a named export (below). A
|
|
119
|
-
* `default` carries no authored intent to register under a literal
|
|
120
|
-
* name, so an unusable name on it is noise, not an author error.
|
|
121
|
-
*
|
|
122
|
-
* The loud failures inside the skip-friendly walk: an explicit icon
|
|
123
|
-
* (`isSvgIcon: true`) on a *named* export whose resolved name fails the
|
|
124
|
-
* PascalCase rule, or two members resolving to the same name — both
|
|
125
|
-
* are author errors, not wildcard noise.
|
|
126
|
-
*/
|
|
127
|
-
function harvestIconMembers(raw, include) {
|
|
128
|
-
const members = {};
|
|
129
|
-
const memberMetadata = {};
|
|
130
|
-
for (const [key, value] of Object.entries(raw)) {
|
|
131
|
-
if (include && !include(key)) continue;
|
|
132
|
-
if (!isComponentShaped(value)) continue;
|
|
133
|
-
const metadata = readIconMetadata(value);
|
|
134
|
-
const isExplicitIcon = metadata?.isSvgIcon === true;
|
|
135
|
-
if (metadata?.isSvgIcon === false) continue;
|
|
136
|
-
const name = isExplicitIcon ? metadata?.name ?? key : key;
|
|
137
|
-
if (key === "default") {
|
|
138
|
-
if (!isExplicitIcon || !PASCAL_CASE.test(name)) continue;
|
|
139
|
-
} else if (!isExplicitIcon) {
|
|
140
|
-
if (!PASCAL_CASE.test(key)) continue;
|
|
141
|
-
} else if (!PASCAL_CASE.test(name)) throw new Error(`defineAssetGroup: icon member "${key}" resolves to asset name "${name}", which is not a PascalCase identifier — icon asset names become the asset-id name segment. Rename the export or set \`.metadata.name\`.`);
|
|
142
|
-
if (members[name] !== void 0) throw new Error(`defineAssetGroup: two icon members resolve to the asset name "${name}" — asset names must be unique within a group.`);
|
|
143
|
-
members[name] = value;
|
|
144
|
-
memberMetadata[name] = metadata ?? {};
|
|
145
|
-
}
|
|
146
|
-
if (Object.keys(members).length === 0) throw new Error("defineAssetGroup: no icon members harvested — expected PascalCase component exports (or components carrying `.metadata.isSvgIcon`). For a font group, declare `.config({ type: 'font' })`.");
|
|
147
|
-
return {
|
|
148
|
-
members,
|
|
149
|
-
memberMetadata
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Font-class guard. Unlike the icon wildcard filter, font members come
|
|
154
|
-
* from an explicit data map where every entry is intended — a member
|
|
155
|
-
* failing the class contract (`fontFamily` + `declarations[]`) is a
|
|
156
|
-
* named config-load error, never a silent skip.
|
|
157
|
-
*/
|
|
158
|
-
function guardFontMembers(raw) {
|
|
159
|
-
const members = {};
|
|
160
|
-
for (const [key, value] of Object.entries(raw)) {
|
|
161
|
-
if (!KEBAB_CASE.test(key)) throw new Error(`defineAssetGroup: font member "${key}" is not a kebab-case FontID — font asset names become the asset-id name segment (e.g. "yas", "centra-no2").`);
|
|
162
|
-
const record = value;
|
|
163
|
-
const fontFamily = record?.fontFamily;
|
|
164
|
-
const declarations = record?.declarations;
|
|
165
|
-
if (typeof fontFamily !== "string" || fontFamily.length === 0) throw new Error(`defineAssetGroup: font member "${key}" fails the 'font' class contract — missing a non-empty \`fontFamily\` string.`);
|
|
166
|
-
if (!Array.isArray(declarations)) throw new Error(`defineAssetGroup: font member "${key}" fails the 'font' class contract — missing a \`declarations\` array.`);
|
|
167
|
-
members[key] = value;
|
|
168
|
-
}
|
|
169
|
-
if (Object.keys(members).length === 0) throw new Error("defineAssetGroup: font group has no members — pass the font declarations map (e.g. FONT_DECLARATIONS_MAP).");
|
|
170
|
-
return members;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Stamp `deprecated: true` on each member named in the `deprecated` list.
|
|
174
|
-
* Shallow-copies only the affected records so the caller's source map is
|
|
175
|
-
* never mutated; ids not in the member map are ignored (governance lists
|
|
176
|
-
* routinely outlive the fonts they name).
|
|
177
|
-
*/
|
|
178
|
-
function foldInDeprecated(members, deprecated) {
|
|
179
|
-
if (!deprecated?.length) return members;
|
|
180
|
-
const flagged = new Set(deprecated);
|
|
181
|
-
for (const id of flagged) {
|
|
182
|
-
const member = members[id];
|
|
183
|
-
if (member) members[id] = {
|
|
184
|
-
...member,
|
|
185
|
-
deprecated: true
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
return members;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Variant superset when `config.variants` is omitted: the harvested
|
|
192
|
-
* union of members' `.metadata.variants`, first-seen order.
|
|
193
|
-
*/
|
|
194
|
-
function deriveVariantUnion(memberMetadata) {
|
|
195
|
-
const union = [];
|
|
196
|
-
for (const metadata of Object.values(memberMetadata)) for (const variant of metadata.variants ?? []) if (!union.includes(variant)) union.push(variant);
|
|
197
|
-
return union;
|
|
198
|
-
}
|
|
199
|
-
/** Internal slug slot the late-bound `ref` getter reads. @internal */
|
|
200
|
-
const ASSET_GROUP_SLUG_KEY = "__slug";
|
|
201
|
-
/**
|
|
202
|
-
* Safe slug read for error messages — never throws, unlike the `ref`
|
|
203
|
-
* getter. Returns `undefined` for an unregistered group. @internal
|
|
204
|
-
*/
|
|
205
|
-
function readAssetGroupSlug(value) {
|
|
206
|
-
if (typeof value !== "object" || value === null) return void 0;
|
|
207
|
-
const slug = value[ASSET_GROUP_SLUG_KEY];
|
|
208
|
-
return typeof slug === "string" ? slug : void 0;
|
|
209
|
-
}
|
|
210
|
-
function defineHidden(target, key, value) {
|
|
211
|
-
Object.defineProperty(target, key, {
|
|
212
|
-
enumerable: false,
|
|
213
|
-
configurable: true,
|
|
214
|
-
writable: true,
|
|
215
|
-
value
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Stamp the invariant `__kind: 'assetGroup'` ref tag. Deliberately
|
|
220
|
-
* deferred to the end of `.config()` so an unconfigured builder never
|
|
221
|
-
* passes `isAssetGroupRef()` — the guard's truth implies a complete,
|
|
222
|
-
* registerable group.
|
|
223
|
-
*/
|
|
224
|
-
function stampRefTag(target) {
|
|
225
|
-
Object.defineProperty(target, "__kind", {
|
|
226
|
-
enumerable: false,
|
|
227
|
-
configurable: true,
|
|
228
|
-
writable: false,
|
|
229
|
-
value: "assetGroup"
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Attach icon metadata to a single one-off icon and hand it back
|
|
234
|
-
* unchanged. `isSvgIcon: true` is implied —
|
|
235
|
-
* the point of the call is to mark the component as an icon so the
|
|
236
|
-
* group harvest picks it up. Slots still point at the *group*, never
|
|
237
|
-
* at this.
|
|
238
|
-
*/
|
|
239
|
-
function defineAssetIcon(component, metadata) {
|
|
240
|
-
Object.defineProperty(component, "metadata", {
|
|
241
|
-
enumerable: true,
|
|
242
|
-
configurable: true,
|
|
243
|
-
writable: true,
|
|
244
|
-
value: {
|
|
245
|
-
isSvgIcon: true,
|
|
246
|
-
...metadata
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
return component;
|
|
250
|
-
}
|
|
251
|
-
function defineAssetGroup(members) {
|
|
252
|
-
const out = {};
|
|
253
|
-
attachSourcePath(out, captureCallerPath());
|
|
254
|
-
Object.defineProperty(out, ASSET_GROUP_SLUG_KEY, {
|
|
255
|
-
enumerable: false,
|
|
256
|
-
configurable: true,
|
|
257
|
-
writable: true,
|
|
258
|
-
value: void 0
|
|
259
|
-
});
|
|
260
|
-
Object.defineProperty(out, "ref", {
|
|
261
|
-
enumerable: false,
|
|
262
|
-
configurable: true,
|
|
263
|
-
get() {
|
|
264
|
-
const slug = readAssetGroupSlug(out);
|
|
265
|
-
if (slug === void 0) throw new Error("AssetGroup.ref read before registration — the slug is late-bound from the `registerAssetGroups({ <slug>: group })` record key. Register the group first.");
|
|
266
|
-
return slug;
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
Object.defineProperty(out, "config", {
|
|
270
|
-
enumerable: false,
|
|
271
|
-
configurable: true,
|
|
272
|
-
writable: true,
|
|
273
|
-
value(config) {
|
|
274
|
-
if (out.assetKind !== void 0) throw new Error("defineAssetGroup: .config({...}) may only be called once per group.");
|
|
275
|
-
if (config.label !== void 0) out.label = config.label;
|
|
276
|
-
if (config.version !== void 0) out.version = config.version;
|
|
277
|
-
if (config.description !== void 0) out.description = config.description;
|
|
278
|
-
if (config.type === "font") {
|
|
279
|
-
const fontMembers = foldInDeprecated(guardFontMembers(members), config.deprecated);
|
|
280
|
-
out.assetKind = "font";
|
|
281
|
-
defineHidden(out, "members", fontMembers);
|
|
282
|
-
stampRefTag(out);
|
|
283
|
-
return out;
|
|
284
|
-
}
|
|
285
|
-
let resolvedSizes = config.sizes;
|
|
286
|
-
let resolvedVariants = config.variants;
|
|
287
|
-
if (config.props !== void 0) {
|
|
288
|
-
if (config.sizes !== void 0 || config.variants !== void 0) throw new Error("defineAssetGroup: `props` cannot be combined with the flat `sizes`/`variants` fields — use one or the other.");
|
|
289
|
-
const mapEntries = [];
|
|
290
|
-
const arrayEntries = [];
|
|
291
|
-
for (const [key, value] of Object.entries(config.props)) {
|
|
292
|
-
if (value === void 0) continue;
|
|
293
|
-
if (Array.isArray(value)) arrayEntries.push([key, value]);
|
|
294
|
-
else if (typeof value === "object" && value !== null) mapEntries.push([key, value]);
|
|
295
|
-
else throw new Error(`defineAssetGroup: \`props.${key}\` must be a named→px map (size axis) or an array (variant axis).`);
|
|
296
|
-
}
|
|
297
|
-
if (mapEntries.length !== 1) throw new Error("defineAssetGroup: `props` requires exactly one named→px map entry (the size axis).");
|
|
298
|
-
if (arrayEntries.length > 1) throw new Error("defineAssetGroup: `props` supports at most one array entry (the variant axis) — the serialized format holds a single variant axis.");
|
|
299
|
-
const [, sizeMap] = mapEntries[0];
|
|
300
|
-
resolvedSizes = sizeMap;
|
|
301
|
-
if (arrayEntries.length === 1) {
|
|
302
|
-
const [, variantValues] = arrayEntries[0];
|
|
303
|
-
resolvedVariants = variantValues;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
if (resolvedSizes === void 0 || Object.keys(resolvedSizes).length === 0) throw new Error("defineAssetGroup: icon groups require a non-empty `sizes` map (named size → px) — declare it via `props: { size: {…} }` or the flat `sizes` field. The picker derives its size options from the keys.");
|
|
307
|
-
const { members: harvested, memberMetadata: harvestedMetadata } = harvestIconMembers(members, config.include);
|
|
308
|
-
const memberMetadata = applyMetadataOverlay(harvestedMetadata, config.memberMetadata, new Set(Object.keys(members)));
|
|
309
|
-
out.assetKind = "icon";
|
|
310
|
-
defineHidden(out, "members", harvested);
|
|
311
|
-
defineHidden(out, "memberMetadata", memberMetadata);
|
|
312
|
-
out.sizes = { ...resolvedSizes };
|
|
313
|
-
out.variants = resolvedVariants ? [...resolvedVariants] : deriveVariantUnion(memberMetadata);
|
|
314
|
-
const componentName = isComponentRef(config.component) ? config.component.ref : config.component;
|
|
315
|
-
if (componentName !== void 0) out.component = componentName;
|
|
316
|
-
stampRefTag(out);
|
|
317
|
-
return out;
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
return out;
|
|
321
|
-
}
|
|
322
|
-
//#endregion
|
|
323
|
-
export { ASSET_GROUP_SLUG_KEY, defineAssetGroup, defineAssetIcon, readAssetGroupSlug };
|
package/dist/defineProvider.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ProviderComponent, ProviderRenderFn } from "./factories.js";
|
|
2
|
-
|
|
3
|
-
//#region src/defineProvider.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Pair a React context with a Provider component + matching hook in
|
|
6
|
-
* one declaration. The render-fn receives the props, returns
|
|
7
|
-
* `{ context, render }` — `context` is what the hook returns; `render`
|
|
8
|
-
* is the JSX (typically `<>{children}<Portal /></>` and similar).
|
|
9
|
-
*
|
|
10
|
-
* export const [ToastProvider, useToast] = defineProvider<ToastCtx>(
|
|
11
|
-
* ({ children }) => {
|
|
12
|
-
* const [toasts, setToasts] = useState<ToastItem[]>([]);
|
|
13
|
-
* return {
|
|
14
|
-
* context: { addToast, dismissToast, updateToast },
|
|
15
|
-
* render: <>{children}<Portal /></>,
|
|
16
|
-
* };
|
|
17
|
-
* },
|
|
18
|
-
* );
|
|
19
|
-
*
|
|
20
|
-
* uds.registerProviders({ ToastProvider });
|
|
21
|
-
*
|
|
22
|
-
* Lives in its own module so the React (`createContext`) imports don't
|
|
23
|
-
* land in the static graph of every consumer importing `@yahoo/uds-create-config`
|
|
24
|
-
* — Turbopack flags `createContext` reaching a server-component module
|
|
25
|
-
* as an error.
|
|
26
|
-
*/
|
|
27
|
-
declare function defineProvider<TContext, TProps = Record<never, never>>(renderFn: ProviderRenderFn<TContext, TProps>): [ProviderComponent<TProps>, () => TContext];
|
|
28
|
-
//#endregion
|
|
29
|
-
export { defineProvider };
|
package/dist/defineProvider.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { attachSourcePath, captureCallerPath } from "./captureCallerPath.js";
|
|
3
|
-
import { createContext, createElement, useContext } from "react";
|
|
4
|
-
//#region src/defineProvider.ts
|
|
5
|
-
/**
|
|
6
|
-
* Pair a React context with a Provider component + matching hook in
|
|
7
|
-
* one declaration. The render-fn receives the props, returns
|
|
8
|
-
* `{ context, render }` — `context` is what the hook returns; `render`
|
|
9
|
-
* is the JSX (typically `<>{children}<Portal /></>` and similar).
|
|
10
|
-
*
|
|
11
|
-
* export const [ToastProvider, useToast] = defineProvider<ToastCtx>(
|
|
12
|
-
* ({ children }) => {
|
|
13
|
-
* const [toasts, setToasts] = useState<ToastItem[]>([]);
|
|
14
|
-
* return {
|
|
15
|
-
* context: { addToast, dismissToast, updateToast },
|
|
16
|
-
* render: <>{children}<Portal /></>,
|
|
17
|
-
* };
|
|
18
|
-
* },
|
|
19
|
-
* );
|
|
20
|
-
*
|
|
21
|
-
* uds.registerProviders({ ToastProvider });
|
|
22
|
-
*
|
|
23
|
-
* Lives in its own module so the React (`createContext`) imports don't
|
|
24
|
-
* land in the static graph of every consumer importing `@yahoo/uds-create-config`
|
|
25
|
-
* — Turbopack flags `createContext` reaching a server-component module
|
|
26
|
-
* as an error.
|
|
27
|
-
*/
|
|
28
|
-
function defineProvider(renderFn) {
|
|
29
|
-
const Context = createContext(null);
|
|
30
|
-
const marker = {};
|
|
31
|
-
function Provider(props) {
|
|
32
|
-
const result = renderFn(props);
|
|
33
|
-
return createElement(Context.Provider, { value: result.context }, result.render);
|
|
34
|
-
}
|
|
35
|
-
Provider.displayName = "Provider";
|
|
36
|
-
Object.defineProperty(Provider, "__udsProvider", {
|
|
37
|
-
enumerable: false,
|
|
38
|
-
configurable: true,
|
|
39
|
-
writable: false,
|
|
40
|
-
value: marker
|
|
41
|
-
});
|
|
42
|
-
function useProviderContext() {
|
|
43
|
-
let ctx;
|
|
44
|
-
try {
|
|
45
|
-
ctx = useContext(Context);
|
|
46
|
-
} catch {
|
|
47
|
-
return {};
|
|
48
|
-
}
|
|
49
|
-
if (ctx === null) {
|
|
50
|
-
const name = marker.name ?? "Provider";
|
|
51
|
-
const hookName = name.replace(/Provider$/, "");
|
|
52
|
-
throw new Error(`use${hookName} must be used within ${name}`);
|
|
53
|
-
}
|
|
54
|
-
return ctx;
|
|
55
|
-
}
|
|
56
|
-
attachSourcePath(Provider, captureCallerPath());
|
|
57
|
-
return [Provider, useProviderContext];
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
|
-
export { defineProvider };
|
package/dist/element-marker.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
//#region src/element-marker.d.ts
|
|
2
|
-
declare const ELEMENT_MARKER_KIND = "element";
|
|
3
|
-
/** Serializable stand-in for a React element authored as a preview prop value. */
|
|
4
|
-
interface ElementMarker {
|
|
5
|
-
readonly __kind: typeof ELEMENT_MARKER_KIND;
|
|
6
|
-
/**
|
|
7
|
-
* Registry-resolvable type — `foreign:<Name>` for a third-party leaf,
|
|
8
|
-
* a registered UDS component's name, or an intrinsic tag (`'svg'`).
|
|
9
|
-
*/
|
|
10
|
-
readonly type: string;
|
|
11
|
-
/** Author-set element key (preserved so revived list children stay keyed). */
|
|
12
|
-
readonly key?: string;
|
|
13
|
-
/** Serialized props; a nested element value is itself an `ElementMarker`. */
|
|
14
|
-
readonly props?: Record<string, unknown>;
|
|
15
|
-
}
|
|
16
|
-
declare function isElementMarker(value: unknown): value is ElementMarker;
|
|
17
|
-
/**
|
|
18
|
-
* A live React element or its `$$typeof`-less husk. `Config.toJSON` runs on the
|
|
19
|
-
* in-memory config, where preview elements are still live (carry `$$typeof`);
|
|
20
|
-
* the husk shape (`_owner`/`_store`, no live `type`) only appears after a
|
|
21
|
-
* structuredClone/JSON round-trip and is matched here defensively.
|
|
22
|
-
*/
|
|
23
|
-
declare function isElementLikeValue(value: unknown): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Deeply convert every React element value to an {@link ElementMarker},
|
|
26
|
-
* preserving the surrounding plain data (axis markers, primitive props, nested
|
|
27
|
-
* arrays/objects). A value that can't be named drops out (`undefined`), so an
|
|
28
|
-
* anonymous wrapper or a clone-stripped husk is removed rather than serialized
|
|
29
|
-
* into something unrenderable. Already-serialized markers carry none of the
|
|
30
|
-
* element internals {@link isElementLikeValue} matches, so they pass through.
|
|
31
|
-
*/
|
|
32
|
-
declare function serializeElementsDeep(value: unknown): unknown;
|
|
33
|
-
/**
|
|
34
|
-
* Treat a matched object as an opaque leaf the deep walk stops at, rather than
|
|
35
|
-
* recursing into it. The walks run at render time, where a prop may already
|
|
36
|
-
* hold a live React element whose `_owner` fiber chain is circular — descending
|
|
37
|
-
* into one never terminates, and it can't contain an un-revived marker anyway.
|
|
38
|
-
* Defaults to {@link isElementLikeValue}.
|
|
39
|
-
*/
|
|
40
|
-
type OpaqueLeafPredicate = (value: object) => boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Does `value` hold an {@link ElementMarker} anywhere in its plain-data subtree?
|
|
43
|
-
* Lets a caller skip the revive walk entirely (and keep prop references stable)
|
|
44
|
-
* when there's nothing to revive.
|
|
45
|
-
*/
|
|
46
|
-
declare function hasElementMarkerDeep(value: unknown, isOpaqueLeaf?: OpaqueLeafPredicate): boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Inverse of {@link serializeElementsDeep}: deep-walk `value` and turn each
|
|
49
|
-
* {@link ElementMarker} into a renderable node via `renderMarker`, preserving
|
|
50
|
-
* the surrounding plain data (arrays, objects). A marker's OWN props are left
|
|
51
|
-
* for `renderMarker` to handle — they are not pre-revived here, so a marker
|
|
52
|
-
* nested inside another marker's props stays inert until its enclosing marker
|
|
53
|
-
* renders. This mirrors how `$slot` resolution defers and avoids handing a live
|
|
54
|
-
* element (circular `_owner`) back into a renderer that deep-walks props.
|
|
55
|
-
*
|
|
56
|
-
* `renderMarker` is the framework seam — studio renders each marker through its
|
|
57
|
-
* preview `UdsRenderer`; the playground does the same with its bundled renderer.
|
|
58
|
-
* Guard with {@link hasElementMarkerDeep} to preserve referential stability for
|
|
59
|
-
* marker-free values (this walk always rebuilds the containers it descends).
|
|
60
|
-
*/
|
|
61
|
-
declare function reviveElementMarkersDeep(value: unknown, renderMarker: (marker: ElementMarker) => unknown, isOpaqueLeaf?: OpaqueLeafPredicate): unknown;
|
|
62
|
-
//#endregion
|
|
63
|
-
export { ELEMENT_MARKER_KIND, ElementMarker, OpaqueLeafPredicate, hasElementMarkerDeep, isElementLikeValue, isElementMarker, reviveElementMarkersDeep, serializeElementsDeep };
|