@yahoo/uds-create-config 2.45.0 → 3.0.1
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
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { pathOf } from "../../framework/utils/refs.js";
|
|
2
|
+
import { resolveComponentProps } from "../../framework/projections.js";
|
|
3
|
+
import { Component } from "./Component.js";
|
|
4
|
+
import { Icon } from "./Icon.js";
|
|
5
|
+
import { parseAssetType } from "../../spec/asset-jsx.js";
|
|
6
|
+
//#region src/entities/system/icon-library.ts
|
|
7
|
+
/**
|
|
8
|
+
* The icon-library READ projection — an icon group's node and members as one plain value, beside
|
|
9
|
+
* the entity that stores them.
|
|
10
|
+
*
|
|
11
|
+
* An icon is an entity (`icon:phosphor/StarIcon`) and everything describing the SET lives on the
|
|
12
|
+
* emergent group node — the sizes and variants it ships, and the component a placed glyph renders
|
|
13
|
+
* through. {@link IconLibrary} is that group node read once, so a surface asks a plain value
|
|
14
|
+
* rather than re-querying the config per member.
|
|
15
|
+
*
|
|
16
|
+
* A placed glyph's spec `type` IS the member's ref (`icon:phosphor/StarIcon`) — the same identity
|
|
17
|
+
* the config uses, which is what `parseAssetType` reads.
|
|
18
|
+
*
|
|
19
|
+
* This is the one home for the question "what icon sets does this system have" — Studio owns only
|
|
20
|
+
* UI policy on top (picker state, grid geometry, recents, search ranking). Like `Component.list`,
|
|
21
|
+
* the functions here build fresh values per call: consume them in place or memoize on the config.
|
|
22
|
+
*/
|
|
23
|
+
const EMPTY_VARIANTS = Object.freeze([]);
|
|
24
|
+
const EMPTY_SIZES = Object.freeze({});
|
|
25
|
+
const EMPTY_CATEGORIES = Object.freeze([]);
|
|
26
|
+
/** The spec `type` a placed glyph of this library carries — its own ref. */
|
|
27
|
+
function assetType(library, member) {
|
|
28
|
+
return `icon:${library.path}/${member}`;
|
|
29
|
+
}
|
|
30
|
+
/** One library by its group path — `undefined` when the config has no such set. */
|
|
31
|
+
function iconLibrary(config, path) {
|
|
32
|
+
if (!config) return void 0;
|
|
33
|
+
const meta = config.groupMeta("icon", path);
|
|
34
|
+
if (!meta) return void 0;
|
|
35
|
+
const component = meta.component ? pathOf(meta.component) : void 0;
|
|
36
|
+
const defaults = component ? Component.get(config, component)?.defaultProps : void 0;
|
|
37
|
+
const defaultVariant = typeof defaults?.variant === "string" ? defaults.variant : void 0;
|
|
38
|
+
const defaultSizeKey = typeof defaults?.size === "string" ? defaults.size : void 0;
|
|
39
|
+
return {
|
|
40
|
+
path,
|
|
41
|
+
members: config.members("icon", path).map((member) => member.path.startsWith(`${path}/`) ? member.path.slice(path.length + 1) : member.path),
|
|
42
|
+
sizes: meta.sizes ?? EMPTY_SIZES,
|
|
43
|
+
variants: meta.variants ?? EMPTY_VARIANTS,
|
|
44
|
+
...component !== void 0 ? { component } : {},
|
|
45
|
+
...typeof meta.module === "string" ? { module: meta.module } : {},
|
|
46
|
+
...meta.version !== void 0 ? { version: meta.version } : {},
|
|
47
|
+
...defaultVariant !== void 0 ? { defaultVariant } : {},
|
|
48
|
+
...defaultSizeKey !== void 0 ? { defaultSizeKey } : {}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Every icon library the config declares. */
|
|
52
|
+
function iconLibraries(config) {
|
|
53
|
+
if (!config) return [];
|
|
54
|
+
return Icon.groups(config).map(({ path }) => iconLibrary(config, path)).filter((library) => library !== void 0);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The library a surface should show: the hinted one when a caller carries a slug (a slot's
|
|
58
|
+
* `accepts` ref, a stored fill), else the first library that actually has members. One home for
|
|
59
|
+
* that policy — the toolbar, placement, and the panel all resolve through here, so no surface
|
|
60
|
+
* carries its own idea of a default set. A hint that names no library resolves to `undefined`
|
|
61
|
+
* rather than falling back: the caller knows whether a stale slug should show empty or pick anew.
|
|
62
|
+
*/
|
|
63
|
+
function resolveIconLibrary(config, hint) {
|
|
64
|
+
if (hint) return iconLibrary(config, hint);
|
|
65
|
+
return iconLibraries(config).find((library) => library.members.length > 0);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Every category the library's members carry, RAW as stored (lowercase, unsorted within a member,
|
|
69
|
+
* plural per member), deduplicated and sorted for a filter menu. Casing is display policy — a
|
|
70
|
+
* surface title-cases for headings; values compare and filter by the stored form.
|
|
71
|
+
*/
|
|
72
|
+
function iconCategories(config, libraryPath) {
|
|
73
|
+
if (!config) return EMPTY_CATEGORIES;
|
|
74
|
+
const categories = /* @__PURE__ */ new Set();
|
|
75
|
+
for (const member of config.members("icon", libraryPath)) {
|
|
76
|
+
const glyph = Icon.get(config, member.path);
|
|
77
|
+
for (const category of glyph?.categories ?? []) categories.add(category);
|
|
78
|
+
}
|
|
79
|
+
return [...categories].sort((a, b) => a.localeCompare(b));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The variants a placed glyph may take.
|
|
83
|
+
*
|
|
84
|
+
* The whole library's variants: nothing in the model describes one glyph's own set yet
|
|
85
|
+
* (config-v2 model gap 8 — per-item `variants` narrowing). So a set that ships a variant only
|
|
86
|
+
* some of its glyphs support will offer it for all of them until that closes.
|
|
87
|
+
*/
|
|
88
|
+
function memberVariantOptions(library, _member) {
|
|
89
|
+
return library.variants;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Whether an element type declares a prop that may survive layer-style projection. A placed
|
|
93
|
+
* glyph's type isn't a component, so its prop surface comes from its library instead: the
|
|
94
|
+
* component the set renders through, plus the size and variant axes the set ships.
|
|
95
|
+
*/
|
|
96
|
+
function isDeclaredElementProp(config, elementType, propName) {
|
|
97
|
+
if (!config) return false;
|
|
98
|
+
const component = Component.get(config, elementType);
|
|
99
|
+
if (component) return resolveComponentProps(config, component.path)[propName] !== void 0;
|
|
100
|
+
const parsed = parseAssetType(elementType);
|
|
101
|
+
if (!parsed) return false;
|
|
102
|
+
const library = iconLibrary(config, parsed.slug);
|
|
103
|
+
if (!library?.members.includes(parsed.member)) return false;
|
|
104
|
+
if (library.component) {
|
|
105
|
+
if (resolveComponentProps(config, library.component)[propName] !== void 0) return true;
|
|
106
|
+
}
|
|
107
|
+
if (propName === "size") return Object.keys(library.sizes).length > 0;
|
|
108
|
+
if (propName === "variant") return memberVariantOptions(library, parsed.member).length > 0;
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { assetType, iconCategories, iconLibraries, iconLibrary, isDeclaredElementProp, memberVariantOptions, resolveIconLibrary };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { SubEntityClass } from "../../framework/defineSubEntity.js";
|
|
2
|
+
import { EntityClass } from "../../framework/defineEntity.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//#region src/entities/system/icon-metadata.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Icon metadata formats — the pluggable-ingest half of `metadata: { from, format }`.
|
|
8
|
+
*
|
|
9
|
+
* Every catalog carries the same facts about a glyph (categories, tags, codepoint); nobody agrees
|
|
10
|
+
* on the shape. So the FIELDS are fixed here and each format gets a named adapter: a pure function
|
|
11
|
+
* from a source's raw export to `Record<memberName, metadata>`. The host supplies the bytes — this
|
|
12
|
+
* module runs in the browser too, so nothing here touches a filesystem or resolves a module.
|
|
13
|
+
*
|
|
14
|
+
* The format list is closed on purpose: an entry exists only when its adapter ships, so a config
|
|
15
|
+
* can never declare an ingest nothing implements. Widening is additive (add the adapter, add the
|
|
16
|
+
* name). The list and the adapter table are one file so they cannot drift apart.
|
|
17
|
+
*/
|
|
18
|
+
/** The formats an icon group's `metadata.format` may declare — exactly the shipped adapters. */
|
|
19
|
+
declare const ICON_METADATA_FORMATS: readonly ["phosphor", "uds"];
|
|
20
|
+
declare const iconMetadataFormat: z.ZodEnum<{
|
|
21
|
+
uds: "uds";
|
|
22
|
+
phosphor: "phosphor";
|
|
23
|
+
}>;
|
|
24
|
+
type IconMetadataFormat = (typeof ICON_METADATA_FORMATS)[number];
|
|
25
|
+
/**
|
|
26
|
+
* One member's descriptive facts — the same schema `Icon.fields` registers, owned here so the
|
|
27
|
+
* adapters' output contract and the entity's stored shape cannot diverge.
|
|
28
|
+
*/
|
|
29
|
+
declare const iconMemberMetadata: z.ZodObject<{
|
|
30
|
+
categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
31
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
32
|
+
codepoint: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
knockoutVariants: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
34
|
+
}, z.core.$strict>;
|
|
35
|
+
type IconMemberMetadata = z.infer<typeof iconMemberMetadata>;
|
|
36
|
+
/**
|
|
37
|
+
* The `metadata` group field: where a set's member facts come from (`from`, a ref to the source's
|
|
38
|
+
* Package group) and how to read them (`format`, a shipped adapter). `Package` is the only source
|
|
39
|
+
* kind that exists; when `File`/`Url` land, `from` widens to a union — the shape stays.
|
|
40
|
+
*/
|
|
41
|
+
declare const iconMetadataDeclaration: z.ZodObject<{
|
|
42
|
+
from: EntityClass<z.ZodObject<{
|
|
43
|
+
version: z.ZodOptional<z.ZodString>;
|
|
44
|
+
exports: z.ZodOptional<SubEntityClass<z.ZodObject<{}, z.core.$strict>>>;
|
|
45
|
+
}, z.core.$strict>, z.ZodObject<Record<never, never>, z.core.$strip>, "package", Record<never, never>, Record<never, never>, false>;
|
|
46
|
+
format: z.ZodEnum<{
|
|
47
|
+
uds: "uds";
|
|
48
|
+
phosphor: "phosphor";
|
|
49
|
+
}>;
|
|
50
|
+
}, z.core.$strict>;
|
|
51
|
+
type IconMetadataDeclaration = z.infer<typeof iconMetadataDeclaration>;
|
|
52
|
+
/** A format adapter: raw source data in, per-member metadata out. Throws on a shape it can't read. */
|
|
53
|
+
type IconMetadataAdapter = (raw: unknown) => Record<string, IconMemberMetadata>;
|
|
54
|
+
/**
|
|
55
|
+
* The uds format IS this file schema — `{ [memberName]: { categories?, tags?, codepoint?,
|
|
56
|
+
* knockoutVariants? } }` —
|
|
57
|
+
* the escape hatch a consumer's own script writes. Exported (with a JSON-Schema form below) so
|
|
58
|
+
* writing that script is a validated contract rather than a guess.
|
|
59
|
+
*/
|
|
60
|
+
declare const iconMetadataFile: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
61
|
+
categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
62
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
codepoint: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
knockoutVariants: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
65
|
+
}, z.core.$strict>>;
|
|
66
|
+
type IconMetadataFile = z.infer<typeof iconMetadataFile>;
|
|
67
|
+
/** The uds file contract as JSON Schema — what a generator stamps into `$schema`-aware tooling. */
|
|
68
|
+
declare function iconMetadataFileJsonSchema(): Record<string, unknown>;
|
|
69
|
+
/** Run the named format's adapter. The host resolved and read `raw`; this stays pure. */
|
|
70
|
+
declare function iconMetadata(format: IconMetadataFormat, raw: unknown): Record<string, IconMemberMetadata>;
|
|
71
|
+
//#endregion
|
|
72
|
+
export { ICON_METADATA_FORMATS, IconMemberMetadata, IconMetadataAdapter, IconMetadataDeclaration, IconMetadataFile, IconMetadataFormat, iconMemberMetadata, iconMetadata, iconMetadataDeclaration, iconMetadataFile, iconMetadataFileJsonSchema, iconMetadataFormat };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Package } from "./Package.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/entities/system/icon-metadata.ts
|
|
4
|
+
/**
|
|
5
|
+
* Icon metadata formats — the pluggable-ingest half of `metadata: { from, format }`.
|
|
6
|
+
*
|
|
7
|
+
* Every catalog carries the same facts about a glyph (categories, tags, codepoint); nobody agrees
|
|
8
|
+
* on the shape. So the FIELDS are fixed here and each format gets a named adapter: a pure function
|
|
9
|
+
* from a source's raw export to `Record<memberName, metadata>`. The host supplies the bytes — this
|
|
10
|
+
* module runs in the browser too, so nothing here touches a filesystem or resolves a module.
|
|
11
|
+
*
|
|
12
|
+
* The format list is closed on purpose: an entry exists only when its adapter ships, so a config
|
|
13
|
+
* can never declare an ingest nothing implements. Widening is additive (add the adapter, add the
|
|
14
|
+
* name). The list and the adapter table are one file so they cannot drift apart.
|
|
15
|
+
*/
|
|
16
|
+
/** The formats an icon group's `metadata.format` may declare — exactly the shipped adapters. */
|
|
17
|
+
const ICON_METADATA_FORMATS = ["phosphor", "uds"];
|
|
18
|
+
const iconMetadataFormat = z.enum(ICON_METADATA_FORMATS);
|
|
19
|
+
/**
|
|
20
|
+
* One member's descriptive facts — the same schema `Icon.fields` registers, owned here so the
|
|
21
|
+
* adapters' output contract and the entity's stored shape cannot diverge.
|
|
22
|
+
*/
|
|
23
|
+
const iconMemberMetadata = z.strictObject({
|
|
24
|
+
/** Grouping, PLURAL — every real catalogue lets a glyph belong to several (most of Phosphor's
|
|
25
|
+
* do), or none. Stored RAW as the source spells them (`'health & wellness'`); casing and
|
|
26
|
+
* which one a section heading shows are display policy, not stored facts. */
|
|
27
|
+
categories: z.array(z.string().min(1)).optional(),
|
|
28
|
+
/** Search terms beyond the name. Order carries no meaning; a reorder is not an edit. */
|
|
29
|
+
tags: z.array(z.string()).optional(),
|
|
30
|
+
/** The glyph's code point in a font-backed set — what a native glyphmap reads. */
|
|
31
|
+
codepoint: z.number().optional(),
|
|
32
|
+
/** Variants whose glyph paints a literal white fill by design (a "knockout" meant for dark or
|
|
33
|
+
* branded surfaces) rather than `currentColor`. Such a glyph is invisible on a light surface,
|
|
34
|
+
* so pickers and catalogs preview these variants on a dark one. Rendering is untouched — the
|
|
35
|
+
* field is presentation advice for browsing UIs, and member-owned like the set's `variants`:
|
|
36
|
+
* only a source that knows its own knockouts can flag them. */
|
|
37
|
+
knockoutVariants: z.array(z.string().min(1)).optional()
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* The `metadata` group field: where a set's member facts come from (`from`, a ref to the source's
|
|
41
|
+
* Package group) and how to read them (`format`, a shipped adapter). `Package` is the only source
|
|
42
|
+
* kind that exists; when `File`/`Url` land, `from` widens to a union — the shape stays.
|
|
43
|
+
*/
|
|
44
|
+
const iconMetadataDeclaration = z.strictObject({
|
|
45
|
+
from: Package,
|
|
46
|
+
format: iconMetadataFormat
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* The uds format IS this file schema — `{ [memberName]: { categories?, tags?, codepoint?,
|
|
50
|
+
* knockoutVariants? } }` —
|
|
51
|
+
* the escape hatch a consumer's own script writes. Exported (with a JSON-Schema form below) so
|
|
52
|
+
* writing that script is a validated contract rather than a guess.
|
|
53
|
+
*/
|
|
54
|
+
const iconMetadataFile = z.record(z.string().min(1), iconMemberMetadata);
|
|
55
|
+
/** The uds file contract as JSON Schema — what a generator stamps into `$schema`-aware tooling. */
|
|
56
|
+
function iconMetadataFileJsonSchema() {
|
|
57
|
+
return z.toJSONSchema(iconMetadataFile);
|
|
58
|
+
}
|
|
59
|
+
/** One zod failure as a message an author can act on — path-first, every issue, one line. */
|
|
60
|
+
function describeIssues(error) {
|
|
61
|
+
return error.issues.map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`).join("; ");
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Phosphor's catalogue: `@phosphor-icons/core` exports `icons`, an array of entries keyed by
|
|
65
|
+
* `pascal_name`. Parsed narrow and LOOSE — only the fields the adapter reads are declared, so a
|
|
66
|
+
* core release adding fields is a no-op and one reshaping them is a clean failure, without this
|
|
67
|
+
* package depending on `@phosphor-icons/core` for its types.
|
|
68
|
+
*/
|
|
69
|
+
const phosphorCatalog = z.looseObject({ icons: z.array(z.looseObject({
|
|
70
|
+
pascal_name: z.string().min(1),
|
|
71
|
+
categories: z.array(z.string().min(1)).optional(),
|
|
72
|
+
tags: z.array(z.string()).optional(),
|
|
73
|
+
codepoint: z.number().optional(),
|
|
74
|
+
/** A retired name the react package still exports for back-compat — the SAME drawing, so it
|
|
75
|
+
* carries the same facts. Emitting it is what makes the join total: without alias rows, the
|
|
76
|
+
* 18 aliased exports would sit uncategorized forever. */
|
|
77
|
+
alias: z.looseObject({ pascal_name: z.string().min(1) }).optional()
|
|
78
|
+
})) });
|
|
79
|
+
const phosphor = (raw) => {
|
|
80
|
+
const parsed = phosphorCatalog.safeParse(raw);
|
|
81
|
+
if (!parsed.success) throw new Error(`phosphor metadata source did not match @phosphor-icons/core's catalogue shape — ${describeIssues(parsed.error)}`);
|
|
82
|
+
const members = {};
|
|
83
|
+
const aliases = {};
|
|
84
|
+
for (const entry of parsed.data.icons) {
|
|
85
|
+
const body = {
|
|
86
|
+
...entry.categories ? { categories: [...entry.categories] } : {},
|
|
87
|
+
...entry.tags ? { tags: [...entry.tags] } : {},
|
|
88
|
+
...entry.codepoint !== void 0 ? { codepoint: entry.codepoint } : {}
|
|
89
|
+
};
|
|
90
|
+
members[`${entry.pascal_name}Icon`] = body;
|
|
91
|
+
if (entry.alias) aliases[`${entry.alias.pascal_name}Icon`] = body;
|
|
92
|
+
}
|
|
93
|
+
for (const [name, body] of Object.entries(aliases)) members[name] ??= body;
|
|
94
|
+
return members;
|
|
95
|
+
};
|
|
96
|
+
const uds = (raw) => {
|
|
97
|
+
const parsed = iconMetadataFile.safeParse(raw);
|
|
98
|
+
if (!parsed.success) throw new Error(`uds metadata source did not match the uds file contract ({ [memberName]: { categories?, tags?, codepoint?, knockoutVariants? } }) — ${describeIssues(parsed.error)}`);
|
|
99
|
+
return parsed.data;
|
|
100
|
+
};
|
|
101
|
+
/** Exhaustive by type: a format added to the list without an adapter here fails to compile. */
|
|
102
|
+
const ADAPTERS = {
|
|
103
|
+
phosphor,
|
|
104
|
+
uds
|
|
105
|
+
};
|
|
106
|
+
/** Run the named format's adapter. The host resolved and read `raw`; this stays pure. */
|
|
107
|
+
function iconMetadata(format, raw) {
|
|
108
|
+
return ADAPTERS[format](raw);
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { ICON_METADATA_FORMATS, iconMemberMetadata, iconMetadata, iconMetadataDeclaration, iconMetadataFile, iconMetadataFileJsonSchema, iconMetadataFormat };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Config } from '../../framework/Config';
|
|
2
|
+
import type { LinkDeclaration } from './LinkedSystem';
|
|
3
|
+
export declare const PIN_KIND = "linked-system";
|
|
4
|
+
/** The pin's `link` as stored. */
|
|
5
|
+
export declare function declarationOf(config: Config, slug: string): LinkDeclaration | undefined;
|
|
6
|
+
/** Whether a declaration covers the accessor's path: the whole source, the kind, the path, or a folder above it. */
|
|
7
|
+
export declare function covers({ declared, accessor, path, }: {
|
|
8
|
+
declared: LinkDeclaration | undefined;
|
|
9
|
+
accessor: string;
|
|
10
|
+
path: string;
|
|
11
|
+
}): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The declaration with `removal` taken out of it, or `undefined` when nothing stays declared.
|
|
14
|
+
*
|
|
15
|
+
* A declaration of everything is spelled out first, one kind per accessor the source has rows for, so
|
|
16
|
+
* one kind can be taken out of it; a kind taken whole is spelled out as the source's top-level paths
|
|
17
|
+
* so some can go; a declared folder above a removed path is spelled out as its other members, so the
|
|
18
|
+
* rest of it stays covered.
|
|
19
|
+
*/
|
|
20
|
+
export declare function narrowDeclaration({ config, slug, current, removal, verb, }: {
|
|
21
|
+
config: Config;
|
|
22
|
+
slug: string;
|
|
23
|
+
current: LinkDeclaration;
|
|
24
|
+
removal: ReadonlyMap<string, '*' | readonly string[]>;
|
|
25
|
+
/** The op asking, for the refusal. */
|
|
26
|
+
verb: string;
|
|
27
|
+
}): LinkDeclaration | undefined;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { rejectData } from "../../framework/rejection.js";
|
|
2
|
+
//#region src/entities/system/link-declaration.ts
|
|
3
|
+
const PIN_KIND = "linked-system";
|
|
4
|
+
/** The pin's `link` as stored. */
|
|
5
|
+
function declarationOf(config, slug) {
|
|
6
|
+
const pin = config.storedBody(PIN_KIND, slug);
|
|
7
|
+
if (!pin) rejectData(`No linked system "${slug}".`);
|
|
8
|
+
return pin.link;
|
|
9
|
+
}
|
|
10
|
+
/** Whether a declaration covers the accessor's path: the whole source, the kind, the path, or a folder above it. */
|
|
11
|
+
function covers({ declared, accessor, path }) {
|
|
12
|
+
if (declared === void 0) return false;
|
|
13
|
+
if (declared === "*") return true;
|
|
14
|
+
const paths = declared[accessor];
|
|
15
|
+
if (paths === void 0) return false;
|
|
16
|
+
if (paths === "*") return true;
|
|
17
|
+
return paths.some((declaredPath) => declaredPath === path || path.startsWith(`${declaredPath}/`));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The declaration with `removal` taken out of it, or `undefined` when nothing stays declared.
|
|
21
|
+
*
|
|
22
|
+
* A declaration of everything is spelled out first, one kind per accessor the source has rows for, so
|
|
23
|
+
* one kind can be taken out of it; a kind taken whole is spelled out as the source's top-level paths
|
|
24
|
+
* so some can go; a declared folder above a removed path is spelled out as its other members, so the
|
|
25
|
+
* rest of it stays covered.
|
|
26
|
+
*/
|
|
27
|
+
function narrowDeclaration({ config, slug, current, removal, verb }) {
|
|
28
|
+
const source = config.sourceFor(slug);
|
|
29
|
+
const next = {};
|
|
30
|
+
if (current === "*") for (const kind of config.borrowableKinds(slug)) {
|
|
31
|
+
if (source && source.list(kind).length === 0) continue;
|
|
32
|
+
next[config.accessorOf(kind) ?? kind] = "*";
|
|
33
|
+
}
|
|
34
|
+
else Object.assign(next, current);
|
|
35
|
+
for (const [accessor, paths] of removal) {
|
|
36
|
+
const before = next[accessor];
|
|
37
|
+
if (before === void 0) continue;
|
|
38
|
+
if (paths === "*") {
|
|
39
|
+
delete next[accessor];
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const kind = config.accessors()[accessor]?.kind ?? accessor;
|
|
43
|
+
let declaredPaths;
|
|
44
|
+
if (before === "*") {
|
|
45
|
+
if (!source) rejectData(`Cannot ${verb} ${paths.join(", ")} through "${slug}" — the declaration takes every "${accessor}", and nothing has resolved that link to spell them out. Unlink the kind (\`{ "${accessor}": "*" }\`) instead.`, ["data", accessor]);
|
|
46
|
+
declaredPaths = source.tree(kind).map((node) => node.path);
|
|
47
|
+
} else declaredPaths = before;
|
|
48
|
+
const removed = (candidate) => paths.some((path) => path === candidate || candidate.startsWith(`${path}/`));
|
|
49
|
+
const kept = [];
|
|
50
|
+
for (const declaredPath of declaredPaths) {
|
|
51
|
+
if (removed(declaredPath)) continue;
|
|
52
|
+
if (!paths.some((path) => path.startsWith(`${declaredPath}/`)) || !source) {
|
|
53
|
+
kept.push(declaredPath);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
for (const member of source.members(kind, declaredPath)) if (!removed(member.path)) kept.push(member.path);
|
|
57
|
+
}
|
|
58
|
+
if (kept.length === 0) delete next[accessor];
|
|
59
|
+
else next[accessor] = kept;
|
|
60
|
+
}
|
|
61
|
+
return Object.keys(next).length === 0 ? void 0 : next;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { PIN_KIND, covers, declarationOf, narrowDeclaration };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { EntityAddress } from "../../framework/plan.js";
|
|
2
|
+
import { LinkDeclaration } from "./LinkedSystem.js";
|
|
3
|
+
import { Config, Patch, TreeNode } from "../../framework/Config.js";
|
|
4
|
+
|
|
5
|
+
//#region src/entities/system/link-plan.d.ts
|
|
6
|
+
/** What one op names, keyed by accessor the way the pin's `link` is: every entry of the kind, or the
|
|
7
|
+
* source's paths, where a folder names its members. `'*'` alone is every kind the source offers. */
|
|
8
|
+
type LinkPaths = '*' | Readonly<Record<string, '*' | readonly string[]>>;
|
|
9
|
+
interface LinkPlanInput {
|
|
10
|
+
/** The pin's slug. */
|
|
11
|
+
readonly path: string;
|
|
12
|
+
readonly data: LinkPaths;
|
|
13
|
+
}
|
|
14
|
+
/** One row a link mints. `named` when a path the call named covers it; otherwise it comes along
|
|
15
|
+
* because something linked points at it. */
|
|
16
|
+
interface LinkArrival extends EntityAddress {
|
|
17
|
+
readonly named: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface LinkPlan {
|
|
20
|
+
/** The pin's `link` once the op has run. */
|
|
21
|
+
readonly declared: LinkDeclaration | undefined;
|
|
22
|
+
/** Every row the link mints that is not here through this pin already, named or brought along. */
|
|
23
|
+
readonly arriving: readonly LinkArrival[];
|
|
24
|
+
/** How many rows of this config's own the link writes over — `addresses.length`. */
|
|
25
|
+
readonly replaces: number;
|
|
26
|
+
/** Rows of this config's own deleted so the source's row shows through at the path. */
|
|
27
|
+
readonly addresses: readonly EntityAddress[];
|
|
28
|
+
/** Rows held through another pin, turned into extensions through this one. */
|
|
29
|
+
readonly extended: readonly EntityAddress[];
|
|
30
|
+
/** Members already here from the source's own origin, left alone and kept out of the declaration. */
|
|
31
|
+
readonly shared: readonly EntityAddress[];
|
|
32
|
+
readonly patches: readonly Patch[];
|
|
33
|
+
}
|
|
34
|
+
interface UnlinkPlanInput {
|
|
35
|
+
readonly path: string;
|
|
36
|
+
/** What to stop drawing; everything when omitted. */
|
|
37
|
+
readonly data?: LinkPaths;
|
|
38
|
+
}
|
|
39
|
+
interface UnlinkPlan {
|
|
40
|
+
readonly declared: LinkDeclaration | undefined;
|
|
41
|
+
/** The minted rows the narrower declaration no longer reaches, `cascade` among them. */
|
|
42
|
+
readonly removed: readonly EntityAddress[];
|
|
43
|
+
/** Linked rows unlinked with the named ones because they point at them: left linked, they would
|
|
44
|
+
* bring the named rows back on the next derive. */
|
|
45
|
+
readonly cascade: readonly EntityAddress[];
|
|
46
|
+
/** Why the config would refuse. `undefined` when it would go through. */
|
|
47
|
+
readonly blocked?: string;
|
|
48
|
+
readonly patches: readonly Patch[];
|
|
49
|
+
}
|
|
50
|
+
interface BreakPlanInput {
|
|
51
|
+
readonly path: string;
|
|
52
|
+
/** Whether every value drawn through the pin becomes this config's own before the pin goes. */
|
|
53
|
+
readonly keep?: boolean;
|
|
54
|
+
/** One entity or folder detached through `copy` instead of the whole pin; a read only. */
|
|
55
|
+
readonly data?: LinkPaths;
|
|
56
|
+
}
|
|
57
|
+
type BreakOutcome = 'copied' | 'rebound' | 'follows' | 'dropped';
|
|
58
|
+
type BreakReach = 'direct' | 'taken' | 'indirect' | 'linked';
|
|
59
|
+
interface BreakPlanRow {
|
|
60
|
+
readonly kind: string;
|
|
61
|
+
readonly path: string;
|
|
62
|
+
readonly folder: boolean;
|
|
63
|
+
/** The refs that tie the row to what moves, as this config spells them. */
|
|
64
|
+
readonly refs: readonly string[];
|
|
65
|
+
readonly outcome: BreakOutcome;
|
|
66
|
+
readonly reach: BreakReach;
|
|
67
|
+
}
|
|
68
|
+
interface BreakPlan {
|
|
69
|
+
readonly rows: readonly BreakPlanRow[];
|
|
70
|
+
readonly blocked?: string;
|
|
71
|
+
readonly patches: readonly Patch[];
|
|
72
|
+
}
|
|
73
|
+
/** One top-level node of a source, read against what this config holds at each member path. */
|
|
74
|
+
interface SourceRowState {
|
|
75
|
+
readonly kind: string;
|
|
76
|
+
/** The source's own path, which is also where a link lands it. */
|
|
77
|
+
readonly path: string;
|
|
78
|
+
readonly type: TreeNode['type'];
|
|
79
|
+
readonly name: string;
|
|
80
|
+
/** Members this config can hold. A folder counts its leaves, an item counts one. */
|
|
81
|
+
readonly members: number;
|
|
82
|
+
/** Every member is held through this pin. */
|
|
83
|
+
readonly linked: boolean;
|
|
84
|
+
/** Rows of this config's own a `link` would write over. */
|
|
85
|
+
readonly replaces: number;
|
|
86
|
+
/** Members already here from the source's own origin, through another pin. */
|
|
87
|
+
readonly shared: number;
|
|
88
|
+
/** That origin's name, when `shared` is above zero. */
|
|
89
|
+
readonly sharedOrigin?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Link paths of a source: the declaration that mints them, then the edits that let them show through
|
|
93
|
+
* where this config already holds something.
|
|
94
|
+
*
|
|
95
|
+
* The declaration goes first. A row of this config's own that other rows point at can only be deleted
|
|
96
|
+
* once the declaration covers the path, since the config refuses a delete that leaves a referrer
|
|
97
|
+
* dangling. A row held through another pin is not deleted — that pin's declaration would mint it
|
|
98
|
+
* again, and declaring one path on two pins is a collision nothing derives — so it becomes an
|
|
99
|
+
* extension through this pin: a row of this config's own that shadows the other pin's and follows this
|
|
100
|
+
* source. A member already here from the source's own origin is left alone and kept out of the
|
|
101
|
+
* declaration, so a folder that holds one is declared by its other members.
|
|
102
|
+
*/
|
|
103
|
+
declare function planLink({
|
|
104
|
+
config,
|
|
105
|
+
input
|
|
106
|
+
}: {
|
|
107
|
+
readonly config: Config;
|
|
108
|
+
readonly input: LinkPlanInput;
|
|
109
|
+
}): LinkPlan;
|
|
110
|
+
/**
|
|
111
|
+
* Stop drawing paths of a source. The declaration narrows, or clears, and the rows it minted retire
|
|
112
|
+
* with it inside the apply; nothing authored here moves. Named paths take the linked rows that point
|
|
113
|
+
* at them along (`cascade`), since left linked those would bring them back. A row of this config's own
|
|
114
|
+
* pointing at a minted row would be stranded, and the config refuses that, which `blocked` reports.
|
|
115
|
+
*/
|
|
116
|
+
declare function planUnlink({
|
|
117
|
+
config,
|
|
118
|
+
input
|
|
119
|
+
}: {
|
|
120
|
+
readonly config: Config;
|
|
121
|
+
readonly input: UnlinkPlanInput;
|
|
122
|
+
}): UnlinkPlan;
|
|
123
|
+
/**
|
|
124
|
+
* Break a link: everything drawn through the pin becomes this config's own, or is dropped, and the
|
|
125
|
+
* pin goes.
|
|
126
|
+
*
|
|
127
|
+
* With `keep`, every entity drawn through the pin is copied in — the value the source holds today,
|
|
128
|
+
* written as a row of this config's own — and a row of yours that pointed through the pin has its
|
|
129
|
+
* targets copied too, with the copy pointing it at the copies. The declaration is then cleared and
|
|
130
|
+
* the pin deleted; nothing refers to it by then. Without `keep`, the declaration is cleared and the
|
|
131
|
+
* pin deleted, and a row of yours still pointing through it is what refuses the break.
|
|
132
|
+
*
|
|
133
|
+
* With `data`, the pin stays and the account is of those paths alone: with `keep`, detaching them
|
|
134
|
+
* through `copy` — the rows the copy lands, the rows of yours it rebinds, and the rows still linked
|
|
135
|
+
* that reference what moves; without it, an `unlink` of them — the rows that go, and the refusal a
|
|
136
|
+
* row of yours pointing at one would raise.
|
|
137
|
+
*/
|
|
138
|
+
declare function planBreak({
|
|
139
|
+
config,
|
|
140
|
+
input
|
|
141
|
+
}: {
|
|
142
|
+
readonly config: Config;
|
|
143
|
+
readonly input: BreakPlanInput;
|
|
144
|
+
}): BreakPlan;
|
|
145
|
+
/**
|
|
146
|
+
* The source's top-level tree, one row per node, read against what this config holds at each path.
|
|
147
|
+
*
|
|
148
|
+
* Reads the live source, since the closure only carries what this config already reached and a source
|
|
149
|
+
* with nothing linked would list nothing. Kinds are `borrowableKinds`, the intersection of what the
|
|
150
|
+
* source has and this config can hold. Nothing when no source is attached.
|
|
151
|
+
*/
|
|
152
|
+
declare function sourceRowStates({
|
|
153
|
+
config,
|
|
154
|
+
slug
|
|
155
|
+
}: {
|
|
156
|
+
readonly config: Config;
|
|
157
|
+
readonly slug: string;
|
|
158
|
+
}): SourceRowState[];
|
|
159
|
+
//#endregion
|
|
160
|
+
export { BreakOutcome, BreakPlan, BreakPlanInput, BreakPlanRow, BreakReach, LinkArrival, LinkPaths, LinkPlan, LinkPlanInput, SourceRowState, UnlinkPlan, UnlinkPlanInput, planBreak, planLink, planUnlink, sourceRowStates };
|