@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.
Files changed (376) hide show
  1. package/README.md +129 -0
  2. package/dist/ai-lanes.d.ts +23 -0
  3. package/dist/ai-lanes.js +34 -0
  4. package/dist/authoring/define-component.d.ts +85 -0
  5. package/dist/configs/CanvasConfig.d.ts +3237 -0
  6. package/dist/configs/CanvasConfig.js +332 -0
  7. package/dist/configs/build-options.d.ts +10 -0
  8. package/dist/configs/build-options.js +68 -0
  9. package/dist/configs/platform.d.ts +15 -0
  10. package/dist/configs/platform.js +17 -0
  11. package/dist/configs/react-native-system.d.ts +3026 -0
  12. package/dist/configs/react-native-system.js +64 -0
  13. package/dist/configs/system.d.ts +2771 -0
  14. package/dist/configs/system.js +74 -0
  15. package/dist/css/properties.generated.d.ts +14 -0
  16. package/dist/css/properties.generated.js +6260 -0
  17. package/dist/css/value-type.d.ts +48 -0
  18. package/dist/css/value-type.js +131 -0
  19. package/dist/css/values.d.ts +33 -0
  20. package/dist/css/values.js +116 -0
  21. package/dist/entities/native/NativeModifier.d.ts +25 -0
  22. package/dist/entities/native/NativeModifier.js +41 -0
  23. package/dist/entities/native/NativeSettings.d.ts +44 -0
  24. package/dist/entities/native/NativeSettings.js +39 -0
  25. package/dist/entities/native/NativeStyleProperty.d.ts +355 -0
  26. package/dist/entities/native/NativeStyleProperty.js +28 -0
  27. package/dist/entities/native/NativeToken.d.ts +31 -0
  28. package/dist/entities/native/NativeToken.js +49 -0
  29. package/dist/entities/system/CanvasRole.d.ts +34 -0
  30. package/dist/entities/system/CanvasRole.js +45 -0
  31. package/dist/entities/system/Component.d.ts +1287 -0
  32. package/dist/entities/system/Component.js +1840 -0
  33. package/dist/entities/system/Composite.d.ts +12 -0
  34. package/dist/entities/system/Composite.js +26 -0
  35. package/dist/entities/system/Device.d.ts +11 -0
  36. package/dist/entities/system/Device.js +18 -0
  37. package/dist/entities/system/File.d.ts +72 -0
  38. package/dist/entities/system/File.js +136 -0
  39. package/dist/entities/system/Font.d.ts +48 -0
  40. package/dist/entities/system/Font.js +56 -0
  41. package/dist/entities/system/GlobalStyle.d.ts +26 -0
  42. package/dist/entities/system/GlobalStyle.js +54 -0
  43. package/dist/entities/system/Guidance.d.ts +85 -0
  44. package/dist/entities/system/Guidance.js +59 -0
  45. package/dist/entities/system/GuidanceStyle.d.ts +14 -0
  46. package/dist/entities/system/GuidanceStyle.js +8 -0
  47. package/dist/entities/system/Icon.d.ts +46 -0
  48. package/dist/entities/system/Icon.js +46 -0
  49. package/dist/entities/system/LinkedSystem.d.ts +504 -0
  50. package/dist/entities/system/LinkedSystem.js +814 -0
  51. package/dist/entities/system/Modifier.d.ts +92 -0
  52. package/dist/entities/system/Modifier.js +120 -0
  53. package/dist/entities/system/Motion.d.ts +28 -0
  54. package/dist/entities/system/Motion.js +48 -0
  55. package/dist/entities/system/Operation.d.ts +100 -0
  56. package/dist/entities/system/Operation.js +236 -0
  57. package/dist/entities/system/Package.d.ts +42 -0
  58. package/dist/entities/system/Package.js +75 -0
  59. package/dist/entities/system/Settings.d.ts +94 -0
  60. package/dist/entities/system/Settings.js +166 -0
  61. package/dist/entities/system/StyleProperty.d.ts +135 -0
  62. package/dist/entities/system/StyleProperty.js +438 -0
  63. package/dist/entities/system/Token.d.ts +67 -0
  64. package/dist/entities/system/Token.js +129 -0
  65. package/dist/entities/system/Tool.d.ts +134 -0
  66. package/dist/entities/system/Tool.js +124 -0
  67. package/dist/entities/system/color.d.ts +64 -0
  68. package/dist/entities/system/color.js +123 -0
  69. package/dist/entities/system/component-module.d.ts +63 -0
  70. package/dist/entities/system/component-module.js +258 -0
  71. package/dist/entities/system/copy-plan.d.ts +98 -0
  72. package/dist/entities/system/copy-plan.js +451 -0
  73. package/dist/entities/system/defineComponent.d.ts +428 -0
  74. package/dist/entities/system/defineComponent.js +337 -0
  75. package/dist/entities/system/element.d.ts +101 -0
  76. package/dist/entities/system/element.js +171 -0
  77. package/dist/entities/system/icon-library.d.ts +64 -0
  78. package/dist/entities/system/icon-library.js +112 -0
  79. package/dist/entities/system/icon-metadata.d.ts +72 -0
  80. package/dist/entities/system/icon-metadata.js +111 -0
  81. package/dist/entities/system/link-declaration.d.ts +27 -0
  82. package/dist/entities/system/link-declaration.js +64 -0
  83. package/dist/entities/system/link-plan.d.ts +160 -0
  84. package/dist/entities/system/link-plan.js +770 -0
  85. package/dist/entities/system/runtime-modules.d.ts +25 -0
  86. package/dist/entities/system/runtime-modules.js +38 -0
  87. package/dist/entities/system/style-bag.d.ts +20 -0
  88. package/dist/entities/system/style-bag.js +246 -0
  89. package/dist/entities/system/token-index.d.ts +89 -0
  90. package/dist/entities/system/token-index.js +112 -0
  91. package/dist/framework/Config.d.ts +2472 -0
  92. package/dist/framework/Config.js +5023 -0
  93. package/dist/framework/Entity.d.ts +127 -0
  94. package/dist/framework/Entity.js +125 -0
  95. package/dist/framework/authoring.d.ts +24 -0
  96. package/dist/framework/authoring.js +7 -0
  97. package/dist/framework/change-hooks.d.ts +119 -0
  98. package/dist/framework/change-hooks.js +131 -0
  99. package/dist/framework/changes.d.ts +88 -0
  100. package/dist/framework/changes.js +246 -0
  101. package/dist/framework/class-names.d.ts +260 -0
  102. package/dist/framework/class-names.js +630 -0
  103. package/dist/framework/coalesce.d.ts +25 -0
  104. package/dist/framework/coalesce.js +60 -0
  105. package/dist/framework/config-op.d.ts +76 -0
  106. package/dist/framework/config-op.js +43 -0
  107. package/dist/framework/config-operation-kind.d.ts +14 -0
  108. package/dist/framework/config-operation-kind.js +14 -0
  109. package/dist/framework/config-ops.d.ts +34 -0
  110. package/dist/framework/config-ops.js +187 -0
  111. package/dist/framework/defineConfig.d.ts +196 -0
  112. package/dist/framework/defineConfig.js +100 -0
  113. package/dist/framework/defineDerivedEntity.d.ts +74 -0
  114. package/dist/framework/defineDerivedEntity.js +83 -0
  115. package/dist/framework/defineEntity.d.ts +318 -0
  116. package/dist/framework/defineEntity.js +183 -0
  117. package/dist/framework/defineSubEntity.d.ts +148 -0
  118. package/dist/framework/defineSubEntity.js +121 -0
  119. package/dist/framework/derived-mutations.d.ts +20 -0
  120. package/dist/framework/derived-mutations.js +38 -0
  121. package/dist/framework/entity-search.d.ts +29 -0
  122. package/dist/framework/entity-search.js +117 -0
  123. package/dist/framework/inline-sources.d.ts +49 -0
  124. package/dist/framework/inline-sources.js +388 -0
  125. package/dist/framework/layer-styles.d.ts +25 -0
  126. package/dist/framework/layer-styles.js +49 -0
  127. package/dist/framework/memo.d.ts +48 -0
  128. package/dist/framework/memo.js +84 -0
  129. package/dist/framework/overlay.d.ts +49 -0
  130. package/dist/framework/overlay.js +17 -0
  131. package/dist/framework/plan.d.ts +49 -0
  132. package/dist/framework/plan.js +73 -0
  133. package/dist/framework/projections.d.ts +480 -0
  134. package/dist/framework/projections.js +974 -0
  135. package/dist/framework/prop-surface.d.ts +132 -0
  136. package/dist/framework/prop-surface.js +278 -0
  137. package/dist/framework/ref-graph.d.ts +71 -0
  138. package/dist/framework/ref-graph.js +158 -0
  139. package/dist/framework/ref-integrity.d.ts +55 -0
  140. package/dist/framework/ref-integrity.js +171 -0
  141. package/dist/framework/registered.d.ts +95 -0
  142. package/dist/framework/registry-dir.d.ts +42 -0
  143. package/dist/framework/registry-dir.js +48 -0
  144. package/dist/framework/registry.d.ts +300 -0
  145. package/dist/framework/registry.js +104 -0
  146. package/dist/framework/rejection.d.ts +58 -0
  147. package/dist/framework/rejection.js +111 -0
  148. package/dist/framework/rename-inference.d.ts +26 -0
  149. package/dist/framework/rename-inference.js +50 -0
  150. package/dist/framework/render-spec.d.ts +296 -0
  151. package/dist/framework/render-spec.js +809 -0
  152. package/dist/framework/schema-version.d.ts +140 -0
  153. package/dist/framework/schema-version.js +214 -0
  154. package/dist/framework/schemas.d.ts +109 -0
  155. package/dist/framework/schemas.js +615 -0
  156. package/dist/framework/session.d.ts +196 -0
  157. package/dist/framework/session.js +367 -0
  158. package/dist/framework/signature.d.ts +15 -0
  159. package/dist/framework/signature.js +83 -0
  160. package/dist/framework/snapshot.d.ts +115 -0
  161. package/dist/framework/snapshot.js +277 -0
  162. package/dist/framework/source-integrity.d.ts +226 -0
  163. package/dist/framework/source-integrity.js +478 -0
  164. package/dist/framework/sources.d.ts +211 -0
  165. package/dist/framework/sources.js +89 -0
  166. package/dist/framework/utils/compiled-schema.d.ts +23 -0
  167. package/dist/framework/utils/compiled-schema.js +46 -0
  168. package/dist/framework/utils/content-key.d.ts +15 -0
  169. package/dist/framework/utils/content-key.js +33 -0
  170. package/dist/framework/utils/enumerated.d.ts +13 -0
  171. package/dist/framework/utils/enumerated.js +19 -0
  172. package/dist/framework/utils/field-path.d.ts +95 -0
  173. package/dist/framework/utils/field-path.js +136 -0
  174. package/dist/framework/utils/field-schema.d.ts +55 -0
  175. package/dist/framework/utils/field-schema.js +183 -0
  176. package/dist/framework/utils/group.d.ts +37 -0
  177. package/dist/framework/utils/group.js +13 -0
  178. package/dist/framework/utils/package-path.d.ts +37 -0
  179. package/dist/framework/utils/package-path.js +61 -0
  180. package/dist/framework/utils/refs.d.ts +194 -0
  181. package/dist/framework/utils/refs.js +403 -0
  182. package/dist/framework/validate-spec.d.ts +27 -0
  183. package/dist/framework/validate-spec.js +45 -0
  184. package/dist/framework/value-domain.d.ts +26 -0
  185. package/dist/framework/value-domain.js +202 -0
  186. package/dist/framework/views-facade.d.ts +15 -0
  187. package/dist/framework/views-facade.js +19 -0
  188. package/dist/index.d.ts +90 -42
  189. package/dist/index.js +86 -37
  190. package/dist/migrations/2.0.0/raw-css.d.ts +11 -0
  191. package/dist/migrations/2.0.0/raw-css.js +72 -0
  192. package/dist/migrations/2.0.0/v1-artifact.d.ts +1559 -0
  193. package/dist/migrations/2.0.0/v1-artifact.js +1018 -0
  194. package/dist/migrations/20260908171448_settings_as_kind.d.ts +22 -0
  195. package/dist/migrations/20260908171448_settings_as_kind.js +89 -0
  196. package/dist/migrations/20260908194245_visible_state_pointer.d.ts +19 -0
  197. package/dist/migrations/20260908194245_visible_state_pointer.js +115 -0
  198. package/dist/migrations/20260909183001_icon_knockout_variants.d.ts +18 -0
  199. package/dist/migrations/20260909183001_icon_knockout_variants.js +8 -0
  200. package/dist/migrations/20260910212453_linked_system_link_ops.d.ts +13 -0
  201. package/dist/migrations/20260910212453_linked_system_link_ops.js +8 -0
  202. package/dist/migrations/index.d.ts +2 -0
  203. package/dist/migrations/index.js +2 -0
  204. package/dist/react-native/style-keys.generated.d.ts +10 -0
  205. package/dist/react-native/style-keys.generated.js +167 -0
  206. package/dist/renderer/RendererErrorBoundary.d.ts +32 -5
  207. package/dist/renderer/RendererErrorBoundary.js +59 -10
  208. package/dist/renderer/UdsRenderer.d.ts +11 -10
  209. package/dist/renderer/UdsRenderer.js +1 -1
  210. package/dist/renderer/assetEntries.d.ts +37 -0
  211. package/dist/renderer/assetEntries.js +39 -0
  212. package/dist/renderer/assetRenderable.d.ts +14 -6
  213. package/dist/renderer/assetRenderable.js +8 -2
  214. package/dist/renderer/componentEntry.d.ts +58 -0
  215. package/dist/renderer/componentEntry.js +71 -0
  216. package/dist/renderer/icon-library.d.ts +20 -0
  217. package/dist/renderer/index.d.ts +7 -7
  218. package/dist/renderer/index.js +5 -5
  219. package/dist/renderer/primitives/SlotRenderer.d.ts +1 -1
  220. package/dist/renderer/primitives/SlotRenderer.js +1 -1
  221. package/dist/renderer/runtimeComponent.d.ts +33 -0
  222. package/dist/renderer/runtimeComponent.js +113 -0
  223. package/dist/renderer/spec-content.d.ts +43 -0
  224. package/dist/renderer/spec-content.js +95 -0
  225. package/dist/renderer/wrapRegistry.d.ts +22 -37
  226. package/dist/renderer/wrapRegistry.js +10 -20
  227. package/dist/renderer/wrappers/event-bridge.js +6 -5
  228. package/dist/renderer/wrappers/hex-normalize.js +6 -5
  229. package/dist/renderer/wrappers/html-aliases.d.ts +7 -2
  230. package/dist/renderer/wrappers/html-aliases.js +36 -19
  231. package/dist/renderer/wrappers/inline-styles.js +7 -6
  232. package/dist/spec/asset-jsx.d.ts +18 -5
  233. package/dist/spec/asset-jsx.js +27 -16
  234. package/dist/spec/collapse-text-labels.d.ts +5 -15
  235. package/dist/spec/collapse-text-labels.js +26 -19
  236. package/dist/spec/empty-node-slots.d.ts +56 -34
  237. package/dist/spec/empty-node-slots.js +87 -47
  238. package/dist/spec/index.d.ts +21 -10
  239. package/dist/spec/index.js +21 -10
  240. package/dist/spec/jsxToSpec.d.ts +14 -9
  241. package/dist/spec/jsxToSpec.js +20 -3
  242. package/dist/spec/preview-elements.d.ts +63 -0
  243. package/dist/spec/preview-elements.js +89 -0
  244. package/dist/spec/rewrite-refs.d.ts +58 -0
  245. package/dist/spec/rewrite-refs.js +250 -0
  246. package/dist/spec/specToJsx.js +18 -29
  247. package/dist/tsconfig.tsbuildinfo +1 -1
  248. package/package.json +39 -52
  249. package/dist/AssetGroup.d.ts +0 -77
  250. package/dist/AssetGroup.js +0 -125
  251. package/dist/Component.d.ts +0 -333
  252. package/dist/Component.js +0 -1061
  253. package/dist/ComponentGroup.d.ts +0 -22
  254. package/dist/ComponentGroup.js +0 -51
  255. package/dist/CompositeStyle.d.ts +0 -30
  256. package/dist/CompositeStyle.js +0 -59
  257. package/dist/Config.d.ts +0 -528
  258. package/dist/Config.js +0 -1712
  259. package/dist/Mode.d.ts +0 -41
  260. package/dist/Mode.js +0 -81
  261. package/dist/Modifier.d.ts +0 -51
  262. package/dist/Modifier.js +0 -97
  263. package/dist/MotionDef.d.ts +0 -81
  264. package/dist/MotionDef.js +0 -212
  265. package/dist/Props.d.ts +0 -332
  266. package/dist/Props.js +0 -35
  267. package/dist/Provider.d.ts +0 -20
  268. package/dist/Provider.js +0 -14
  269. package/dist/StyleProp.d.ts +0 -145
  270. package/dist/StyleProp.js +0 -239
  271. package/dist/Token.d.ts +0 -76
  272. package/dist/Token.js +0 -133
  273. package/dist/TokenGroup.d.ts +0 -33
  274. package/dist/TokenGroup.js +0 -69
  275. package/dist/asset-kind.d.ts +0 -55
  276. package/dist/asset-kind.js +0 -29
  277. package/dist/asset-value.d.ts +0 -23
  278. package/dist/asset-value.js +0 -40
  279. package/dist/brands.d.ts +0 -30
  280. package/dist/brands.js +0 -20
  281. package/dist/captureCallerPath.d.ts +0 -48
  282. package/dist/captureCallerPath.js +0 -95
  283. package/dist/colorExpressions.d.ts +0 -131
  284. package/dist/colorExpressions.js +0 -148
  285. package/dist/component-referrers.d.ts +0 -30
  286. package/dist/component-referrers.js +0 -40
  287. package/dist/config-diagnostics.d.ts +0 -21
  288. package/dist/config-diagnostics.js +0 -12
  289. package/dist/defineAssetGroup.d.ts +0 -200
  290. package/dist/defineAssetGroup.js +0 -323
  291. package/dist/defineProvider.d.ts +0 -29
  292. package/dist/defineProvider.js +0 -60
  293. package/dist/element-marker.d.ts +0 -63
  294. package/dist/element-marker.js +0 -113
  295. package/dist/entity-utils.d.ts +0 -56
  296. package/dist/entity-utils.js +0 -105
  297. package/dist/extension.d.ts +0 -55
  298. package/dist/extension.js +0 -214
  299. package/dist/factories.d.ts +0 -863
  300. package/dist/factories.js +0 -475
  301. package/dist/font-face.d.ts +0 -25
  302. package/dist/font-face.js +0 -72
  303. package/dist/foreign-component-name.d.ts +0 -21
  304. package/dist/foreign-component-name.js +0 -42
  305. package/dist/interpolate.d.ts +0 -20
  306. package/dist/interpolate.js +0 -10
  307. package/dist/jsx/__fixtures__/cross-component-preview.d.ts +0 -3
  308. package/dist/jsx/__fixtures__/cross-component-preview.js +0 -15
  309. package/dist/jsx/jsx-dev-runtime.d.ts +0 -15
  310. package/dist/jsx/jsx-dev-runtime.js +0 -11
  311. package/dist/jsx/jsx-runtime.d.ts +0 -48
  312. package/dist/jsx/jsx-runtime.js +0 -305
  313. package/dist/linked-system-pins.d.ts +0 -30
  314. package/dist/linked-system-pins.js +0 -45
  315. package/dist/linkedNodePrefixes.d.ts +0 -73
  316. package/dist/linkedNodePrefixes.js +0 -99
  317. package/dist/markers.d.ts +0 -235
  318. package/dist/markers.js +0 -70
  319. package/dist/motion-constants.d.ts +0 -37
  320. package/dist/motion-constants.js +0 -61
  321. package/dist/native/NativeConfig.d.ts +0 -56
  322. package/dist/native/NativeConfig.js +0 -162
  323. package/dist/native/assets.d.ts +0 -20
  324. package/dist/native/assets.js +0 -17
  325. package/dist/native/components.d.ts +0 -139
  326. package/dist/native/components.js +0 -67
  327. package/dist/native/index.d.ts +0 -18
  328. package/dist/native/index.js +0 -17
  329. package/dist/native/modes.d.ts +0 -10
  330. package/dist/native/modes.js +0 -11
  331. package/dist/native/types.d.ts +0 -95
  332. package/dist/native/types.js +0 -0
  333. package/dist/native/validation.d.ts +0 -8
  334. package/dist/native/validation.js +0 -885
  335. package/dist/native/values.d.ts +0 -7
  336. package/dist/native/values.js +0 -15
  337. package/dist/native.d.ts +0 -12
  338. package/dist/native.js +0 -10
  339. package/dist/refs.d.ts +0 -204
  340. package/dist/refs.js +0 -129
  341. package/dist/registry-aliases.d.ts +0 -33
  342. package/dist/registry-aliases.js +0 -35
  343. package/dist/registry-dir.d.ts +0 -22
  344. package/dist/registry-dir.js +0 -10
  345. package/dist/renderer/makeRegistry.d.ts +0 -34
  346. package/dist/renderer/makeRegistry.js +0 -52
  347. package/dist/renderer/makeUdsRenderer.d.ts +0 -13
  348. package/dist/renderer/makeUdsRenderer.js +0 -51
  349. package/dist/renderer/wrappers/component-slots.d.ts +0 -41
  350. package/dist/renderer/wrappers/component-slots.js +0 -66
  351. package/dist/renderer/wrappers/slot-resolution.d.ts +0 -25
  352. package/dist/renderer/wrappers/slot-resolution.js +0 -68
  353. package/dist/renderer/wrappers/void-elements.d.ts +0 -37
  354. package/dist/renderer/wrappers/void-elements.js +0 -40
  355. package/dist/spec/layer-props.d.ts +0 -52
  356. package/dist/spec/layer-props.js +0 -149
  357. package/dist/spec/preview-controls.d.ts +0 -44
  358. package/dist/spec/preview-controls.js +0 -139
  359. package/dist/spec/slot-refs.d.ts +0 -39
  360. package/dist/spec/slot-refs.js +0 -56
  361. package/dist/token-override-rows.d.ts +0 -68
  362. package/dist/token-override-rows.js +0 -233
  363. package/dist/tokenValueType.d.ts +0 -34
  364. package/dist/tokenValueType.js +0 -138
  365. package/dist/types/css-properties.d.ts +0 -233
  366. package/dist/types/css-properties.js +0 -14
  367. package/dist/types/css-property-keywords.d.ts +0 -156
  368. package/dist/types/css-property-keywords.js +0 -616
  369. package/dist/types/css-values.d.ts +0 -63
  370. package/dist/types/css-values.js +0 -16
  371. package/dist/types.d.ts +0 -1138
  372. package/dist/types.js +0 -12
  373. package/dist/units.d.ts +0 -14
  374. package/dist/units.js +0 -16
  375. package/dist/utils/index.d.ts +0 -4
  376. package/dist/utils/index.js +0 -4
@@ -1,113 +0,0 @@
1
- import { foreignRegistryKey } from "./foreign-component-name.js";
2
- //#region src/element-marker.ts
3
- const ELEMENT_MARKER_KIND = "element";
4
- function isElementMarker(value) {
5
- return value !== null && typeof value === "object" && value.__kind === "element" && typeof value.type === "string";
6
- }
7
- /**
8
- * A live React element or its `$$typeof`-less husk. `Config.toJSON` runs on the
9
- * in-memory config, where preview elements are still live (carry `$$typeof`);
10
- * the husk shape (`_owner`/`_store`, no live `type`) only appears after a
11
- * structuredClone/JSON round-trip and is matched here defensively.
12
- */
13
- function isElementLikeValue(value) {
14
- return value !== null && typeof value === "object" && ("$$typeof" in value || "_owner" in value || "_store" in value);
15
- }
16
- /**
17
- * The registry key for a React element's `type`: a UDS component's stamped
18
- * `__componentName`, a `foreign:<Name>` for a `forwardRef`/`memo` leaf, an
19
- * intrinsic tag string, or a plain function component's display/name. Returns
20
- * `null` when the type can't be named (an anonymous wrapper) — the caller then
21
- * drops the value rather than emit an unresolvable marker.
22
- */
23
- function elementTypeName(type) {
24
- if (typeof type === "string") return type;
25
- if (!(type !== null && (typeof type === "object" || typeof type === "function"))) return null;
26
- const udsName = type.__componentName;
27
- if (typeof udsName === "string") return udsName;
28
- const foreign = foreignRegistryKey(type);
29
- if (foreign !== null) return foreign;
30
- if (typeof type === "function") {
31
- const fn = type;
32
- if (typeof fn.displayName === "string" && fn.displayName.length > 0) return fn.displayName;
33
- if (typeof fn.name === "string" && fn.name.length > 0) return fn.name;
34
- }
35
- return null;
36
- }
37
- function elementToMarker(element) {
38
- const el = element;
39
- const type = elementTypeName(el.type);
40
- if (type === null) return void 0;
41
- const marker = {
42
- __kind: ELEMENT_MARKER_KIND,
43
- type
44
- };
45
- if (typeof el.key === "string") marker.key = el.key;
46
- if (el.props !== null && typeof el.props === "object") {
47
- const props = serializeElementsDeep(el.props);
48
- if (Object.keys(props).length > 0) marker.props = props;
49
- }
50
- return marker;
51
- }
52
- /**
53
- * Deeply convert every React element value to an {@link ElementMarker},
54
- * preserving the surrounding plain data (axis markers, primitive props, nested
55
- * arrays/objects). A value that can't be named drops out (`undefined`), so an
56
- * anonymous wrapper or a clone-stripped husk is removed rather than serialized
57
- * into something unrenderable. Already-serialized markers carry none of the
58
- * element internals {@link isElementLikeValue} matches, so they pass through.
59
- */
60
- function serializeElementsDeep(value) {
61
- if (isElementLikeValue(value)) return elementToMarker(value);
62
- if (Array.isArray(value)) return value.map(serializeElementsDeep).filter((entry) => entry !== void 0);
63
- if (value !== null && typeof value === "object") {
64
- const out = {};
65
- for (const [key, entry] of Object.entries(value)) {
66
- const cleaned = serializeElementsDeep(entry);
67
- if (cleaned !== void 0) out[key] = cleaned;
68
- }
69
- return out;
70
- }
71
- return value;
72
- }
73
- /**
74
- * Does `value` hold an {@link ElementMarker} anywhere in its plain-data subtree?
75
- * Lets a caller skip the revive walk entirely (and keep prop references stable)
76
- * when there's nothing to revive.
77
- */
78
- function hasElementMarkerDeep(value, isOpaqueLeaf = isElementLikeValue) {
79
- if (isElementMarker(value)) return true;
80
- if (Array.isArray(value)) return value.some((entry) => hasElementMarkerDeep(entry, isOpaqueLeaf));
81
- if (value !== null && typeof value === "object") {
82
- if (isOpaqueLeaf(value)) return false;
83
- return Object.values(value).some((entry) => hasElementMarkerDeep(entry, isOpaqueLeaf));
84
- }
85
- return false;
86
- }
87
- /**
88
- * Inverse of {@link serializeElementsDeep}: deep-walk `value` and turn each
89
- * {@link ElementMarker} into a renderable node via `renderMarker`, preserving
90
- * the surrounding plain data (arrays, objects). A marker's OWN props are left
91
- * for `renderMarker` to handle — they are not pre-revived here, so a marker
92
- * nested inside another marker's props stays inert until its enclosing marker
93
- * renders. This mirrors how `$slot` resolution defers and avoids handing a live
94
- * element (circular `_owner`) back into a renderer that deep-walks props.
95
- *
96
- * `renderMarker` is the framework seam — studio renders each marker through its
97
- * preview `UdsRenderer`; the playground does the same with its bundled renderer.
98
- * Guard with {@link hasElementMarkerDeep} to preserve referential stability for
99
- * marker-free values (this walk always rebuilds the containers it descends).
100
- */
101
- function reviveElementMarkersDeep(value, renderMarker, isOpaqueLeaf = isElementLikeValue) {
102
- if (isElementMarker(value)) return renderMarker(value);
103
- if (Array.isArray(value)) return value.map((entry) => reviveElementMarkersDeep(entry, renderMarker, isOpaqueLeaf));
104
- if (value !== null && typeof value === "object") {
105
- if (isOpaqueLeaf(value)) return value;
106
- const out = {};
107
- for (const [key, entry] of Object.entries(value)) out[key] = reviveElementMarkersDeep(entry, renderMarker, isOpaqueLeaf);
108
- return out;
109
- }
110
- return value;
111
- }
112
- //#endregion
113
- export { ELEMENT_MARKER_KIND, hasElementMarkerDeep, isElementLikeValue, isElementMarker, reviveElementMarkersDeep, serializeElementsDeep };
@@ -1,56 +0,0 @@
1
- import { CssClassName, CssVar } from "./brands.js";
2
-
3
- //#region src/entity-utils.d.ts
4
- /**
5
- * Kebab-case a single identifier. Inserts a hyphen at each upper-case
6
- * boundary and lower-cases the result. Single-segment only — for slashed
7
- * `'namespace/name'` paths, kebab each segment separately.
8
- */
9
- declare function kebabCase(value: string): string;
10
- /**
11
- * Build a CSS variable name from a prefix + namespace + token name.
12
- * Each segment is kebab-cased; dots in the token name are mapped to
13
- * `_` and slashes to `-` since CSS custom-property identifiers reject
14
- * both `.` and `/` (so a `1.5` spacing token emits
15
- * `--<prefix>-spacing-1_5`, and a subpath token `1/2` or
16
- * `always/white` emits `--<prefix>-position-1-2` /
17
- * `--<prefix>-global-always-white` — both valid).
18
- */
19
- declare function buildCssVar(prefix: string, namespace: string, name: string): CssVar;
20
- /**
21
- * Build a `tokenRef → 'var(--<prefix>-<ns>-<name>)'` resolver — the callback
22
- * `resolveColorExpression` consumes to turn `token('ns/name')` refs into CSS var
23
- * references. Splits a ref on its FIRST slash into namespace + name; a ref with
24
- * no usable slash passes through unchanged (already a literal).
25
- *
26
- * The single source of truth shared by the config render-spec bake and codegen
27
- * (`tokenValue.ts`, `prepareCss.ts`), so config-baked and codegen-emitted CSS
28
- * stay byte-identical. The name segment uses the `@yahoo/uds-create-utils` `safeTokenName`
29
- * transform (dots→`_`, slashes→`-`) — NOT `cssSafeSegment` (which also
30
- * kebab-cases) — so multi-segment paths like `spectrum/carbon/0` resolve to a
31
- * valid `--<prefix>-spectrum-carbon-0`.
32
- */
33
- declare function makeTokenRefToCss(prefix: string | undefined): (ref: string) => string;
34
- /**
35
- * Build a composite style's CSS class name: `<prefix>-<name>-<variant>`.
36
- * Both name/variant segments are sanitized so subpath variants like
37
- * `ui5/emphasized` emit `.yos-text-variant-ui5-emphasized` instead of an
38
- * invalid `.text-variant-ui5/emphasized` (which the browser splits at `/`).
39
- *
40
- * The `prefix` namespaces the class the same way it namespaces CSS
41
- * variables and component classes (`componentClassNames`) — an empty
42
- * prefix yields the bare, unprefixed form.
43
- */
44
- declare function buildCompositeClassName(prefix: string, name: string, variant: string): CssClassName;
45
- /**
46
- * Token names that aren't valid CSS identifiers (`2xl`, `3xs`) get an
47
- * underscore prefix so they survive in CSS contexts. Dots are mapped
48
- * to `_` and slashes to `-` — `1.5` would otherwise produce a class
49
- * string the browser splits at the dot (`class="text-1.5"` parses as
50
- * `.text-1` and `.5`), and a subpath token like `1/2` would emit
51
- * `text-1/2` which the browser treats as `.text-1` followed by
52
- * `/2`. Mirrors `safeTokenName` from `@yahoo/uds-create-utils`.
53
- */
54
- declare function toCssSafeName(name: string): CssClassName;
55
- //#endregion
56
- export { buildCompositeClassName, buildCssVar, kebabCase, makeTokenRefToCss, toCssSafeName };
@@ -1,105 +0,0 @@
1
- import { cssClassName, cssVar } from "./brands.js";
2
- //#region src/entity-utils.ts
3
- /**
4
- * Shared helpers used by entity `.derived` getters.
5
- */
6
- /**
7
- * Kebab-case a single identifier. Inserts a hyphen at each upper-case
8
- * boundary and lower-cases the result. Single-segment only — for slashed
9
- * `'namespace/name'` paths, kebab each segment separately.
10
- */
11
- function kebabCase(value) {
12
- return value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").toLowerCase();
13
- }
14
- /**
15
- * Kebab-case + sanitize a single identifier for use inside a CSS custom
16
- * property name or class name. Dots become `_` and slashes become `-`
17
- * (so `1.5` → `1_5`, `1/2` → `1-2`, `ui5/emphasized` → `ui5-emphasized`).
18
- * Mirrors the `safeTokenName` transform used by the runtime styler in
19
- * `@yahoo/uds-create-utils`, so codegen-declared identifiers and runtime-referenced
20
- * identifiers stay in lockstep.
21
- */
22
- function cssSafeSegment(value) {
23
- return kebabCase(value).replace(/\./g, "_").replace(/\//g, "-");
24
- }
25
- /**
26
- * Build a CSS variable name from a prefix + namespace + token name.
27
- * Each segment is kebab-cased; dots in the token name are mapped to
28
- * `_` and slashes to `-` since CSS custom-property identifiers reject
29
- * both `.` and `/` (so a `1.5` spacing token emits
30
- * `--<prefix>-spacing-1_5`, and a subpath token `1/2` or
31
- * `always/white` emits `--<prefix>-position-1-2` /
32
- * `--<prefix>-global-always-white` — both valid).
33
- */
34
- function buildCssVar(prefix, namespace, name) {
35
- return cssVar(`--${prefix}-${kebabCase(namespace)}-${cssSafeSegment(name)}`);
36
- }
37
- /**
38
- * Build a `tokenRef → 'var(--<prefix>-<ns>-<name>)'` resolver — the callback
39
- * `resolveColorExpression` consumes to turn `token('ns/name')` refs into CSS var
40
- * references. Splits a ref on its FIRST slash into namespace + name; a ref with
41
- * no usable slash passes through unchanged (already a literal).
42
- *
43
- * The single source of truth shared by the config render-spec bake and codegen
44
- * (`tokenValue.ts`, `prepareCss.ts`), so config-baked and codegen-emitted CSS
45
- * stay byte-identical. The name segment uses the `@yahoo/uds-create-utils` `safeTokenName`
46
- * transform (dots→`_`, slashes→`-`) — NOT `cssSafeSegment` (which also
47
- * kebab-cases) — so multi-segment paths like `spectrum/carbon/0` resolve to a
48
- * valid `--<prefix>-spectrum-carbon-0`.
49
- */
50
- function makeTokenRefToCss(prefix) {
51
- return (ref) => {
52
- const slashIdx = ref.indexOf("/");
53
- if (slashIdx <= 0 || slashIdx >= ref.length - 1) return ref;
54
- const namespace = kebabCase(ref.slice(0, slashIdx));
55
- const name = ref.slice(slashIdx + 1).replace(/\./g, "_").replace(/\//g, "-");
56
- return prefix ? `var(--${prefix}-${namespace}-${name})` : `var(--${namespace}-${name})`;
57
- };
58
- }
59
- /**
60
- * Build a composite style's CSS class name: `<prefix>-<name>-<variant>`.
61
- * Both name/variant segments are sanitized so subpath variants like
62
- * `ui5/emphasized` emit `.yos-text-variant-ui5-emphasized` instead of an
63
- * invalid `.text-variant-ui5/emphasized` (which the browser splits at `/`).
64
- *
65
- * The `prefix` namespaces the class the same way it namespaces CSS
66
- * variables and component classes (`componentClassNames`) — an empty
67
- * prefix yields the bare, unprefixed form.
68
- */
69
- function buildCompositeClassName(prefix, name, variant) {
70
- const body = `${cssSafeSegment(name)}-${cssSafeSegment(variant)}`;
71
- return cssClassName(prefix ? `${prefix}-${body}` : body);
72
- }
73
- /**
74
- * Build the marker custom-property name a composite group writes (and
75
- * its container style queries read): `--<prefix>-composite-<kebab-name>`.
76
- * Single source of truth — the setter emission and `@container style(...)`
77
- * query both consume this so they stay in lockstep.
78
- */
79
- function buildCompositeMarkerVarName(prefix, name) {
80
- return cssVar(`--${prefix}-composite-${kebabCase(name)}`);
81
- }
82
- /**
83
- * Token names that aren't valid CSS identifiers (`2xl`, `3xs`) get an
84
- * underscore prefix so they survive in CSS contexts. Dots are mapped
85
- * to `_` and slashes to `-` — `1.5` would otherwise produce a class
86
- * string the browser splits at the dot (`class="text-1.5"` parses as
87
- * `.text-1` and `.5`), and a subpath token like `1/2` would emit
88
- * `text-1/2` which the browser treats as `.text-1` followed by
89
- * `/2`. Mirrors `safeTokenName` from `@yahoo/uds-create-utils`.
90
- */
91
- function toCssSafeName(name) {
92
- return cssClassName(cssSafeSegment(/^[0-9]/.test(name) ? `_${name}` : name));
93
- }
94
- /**
95
- * Filter undefined fields out of a partial object literal so optional
96
- * authored properties don't show up as `key: undefined` in `toJSON()`
97
- * output. Mirrors the pattern used by `@yahoo/uds-create-config` `defineX` builders.
98
- */
99
- function compact(input) {
100
- const out = {};
101
- for (const [key, value] of Object.entries(input)) if (value !== void 0) out[key] = value;
102
- return out;
103
- }
104
- //#endregion
105
- export { buildCompositeClassName, buildCompositeMarkerVarName, buildCssVar, compact, cssSafeSegment, kebabCase, makeTokenRefToCss, toCssSafeName };
@@ -1,55 +0,0 @@
1
- import { ComponentDefinition, ComponentExtension, ComponentExtensionRecord } from "./types.js";
2
-
3
- //#region src/extension.d.ts
4
- /** Registry barrel component value: the definition plus the chained extender. */
5
- type LinkedComponentValue = ComponentDefinition & {
6
- extend(patch: ComponentExtension): ComponentDefinition;
7
- };
8
- /**
9
- * Apply an authored extension payload (additive only — `null` anywhere
10
- * throws). Never mutates `def`; applying the returned `inverse` via
11
- * {@link applyComponentExtensionInverse} restores `def` exactly.
12
- */
13
- declare function applyComponentExtension(def: ComponentDefinition, patch: ComponentExtension): {
14
- result: ComponentDefinition;
15
- inverse: ComponentExtension;
16
- };
17
- /**
18
- * Apply an engine-generated inverse. Unlike payloads, inverses carry
19
- * removals (`null` reverts an added path), so removal is permitted here.
20
- * `lenient` skips stale paths (removals of keys that no longer exist,
21
- * children that left the family) instead of throwing — the extension
22
- * DELETE path uses it so a source-shape change can never trap a consumer
23
- * with an extension they cannot remove.
24
- */
25
- declare function applyComponentExtensionInverse(def: ComponentDefinition, inverse: ComponentExtension, options?: {
26
- lenient?: boolean;
27
- }): {
28
- result: ComponentDefinition;
29
- };
30
- /**
31
- * Apply an extension payload to one component inside a FLAT serialized
32
- * components record (the `SerializedConfig.components` shape, where compound
33
- * children are separate sibling entries named by the parent's wire
34
- * `subcomponents` list). This is the build-time re-bind hook: a consumer's
35
- * extension on a linked component is replayed onto the source node's sealed
36
- * config before the node's modules and CSS regenerate, so rendered output
37
- * reflects the extension.
38
- *
39
- * Reconstructs the compound-parent shape (`__subcomponents` from the wire
40
- * name list) so {@link applyComponentExtension}'s validation and merge
41
- * semantics apply unchanged, then flattens the merged children back to their
42
- * sibling entries. Pure — returns a new record; `components` is not mutated.
43
- */
44
- declare function extendSerializedComponents(components: Record<string, ComponentDefinition>, sourceKey: string, payload: ComponentExtension): {
45
- components: Record<string, ComponentDefinition>;
46
- record: ComponentExtensionRecord;
47
- };
48
- /**
49
- * Wrap a registry barrel component definition, attaching the non-enumerable
50
- * `.extend(patch)`. Non-enumerable keeps the barrel value JSON-clean, the
51
- * same convention as `defineComponent`'s chain methods.
52
- */
53
- declare function linkedComponent(def: ComponentDefinition): LinkedComponentValue;
54
- //#endregion
55
- export { LinkedComponentValue, applyComponentExtension, applyComponentExtensionInverse, extendSerializedComponents, linkedComponent };
package/dist/extension.js DELETED
@@ -1,214 +0,0 @@
1
- //#region src/extension.ts
2
- /**
3
- * The extendable surface — non-structural definition fields only, plus the
4
- * `subcomponents` block (child overrides, same per-child surface). Everything
5
- * else (composition: `layers`, `ref`; provenance: `link`, `extension`; any
6
- * future field) is closed until deliberately added here.
7
- */
8
- const EXTENDABLE_FIELD_KEYS = [
9
- "props",
10
- "base",
11
- "defaultProps",
12
- "compoundProps",
13
- "motion",
14
- "metadata"
15
- ];
16
- const EXTENDABLE_FIELDS = new Set(EXTENDABLE_FIELD_KEYS);
17
- const ALLOW_LIST_MESSAGE = `only ${[...EXTENDABLE_FIELD_KEYS, "subcomponents"].map((k) => `"${k}"`).join(", ")} are extendable; composition and provenance stay owned by the source system.`;
18
- function isPlainObject(value) {
19
- return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
20
- }
21
- /**
22
- * `__kind`-tagged objects (`token()` refs, color expressions, element
23
- * markers) are atomic values, not containers — recursing into one would
24
- * union keys across marker shapes and corrupt it.
25
- */
26
- function isMarker(value) {
27
- return isPlainObject(value) && "__kind" in value;
28
- }
29
- /** Mergeable container: a plain object that is not an atomic marker. */
30
- function isMergeable(value) {
31
- return isPlainObject(value) && !isMarker(value);
32
- }
33
- /**
34
- * A consumer-authored `token()` ref means the CONSUMER's namespace — stamp
35
- * it so downstream resolution (consumer derived tables, node replay) never
36
- * mistakes it for a source-namespace ref riding a linked definition.
37
- * System-scoped refs (barrel `token()` utilities) and already-scoped refs
38
- * pass through unchanged. Applied to payload values only — inverses carry
39
- * values captured from the definition, whose scoping is already correct.
40
- */
41
- function stampConsumerScope(value) {
42
- if (!isPlainObject(value)) return value;
43
- if (value.__kind === "token" && value.scope === void 0 && value.system === void 0) return {
44
- ...value,
45
- scope: "consumer"
46
- };
47
- return value;
48
- }
49
- /**
50
- * Merge `patch` into `base` (copy-on-write) and collect the inverse patch.
51
- * Returns the merged node; writes each touched key's inverse into `inverse`.
52
- * `allowRemoval` is false for authored payloads (additive only) and true
53
- * when applying an engine-generated inverse, whose `null`s revert additions.
54
- */
55
- function mergeNode(base, patch, inverse, path, allowRemoval, label = "Component extension", lenient = false) {
56
- const result = { ...base };
57
- for (const [key, patchValue] of Object.entries(patch)) {
58
- if (patchValue === void 0) continue;
59
- const keyPath = path === "" ? key : `${path}.${key}`;
60
- const had = Object.hasOwn(base, key);
61
- const baseValue = base[key];
62
- if (patchValue === null) {
63
- if (!allowRemoval) throw new Error(`${label}: "${keyPath}" is null — extensions add and override values but never remove them.`);
64
- if (!had) {
65
- if (lenient) continue;
66
- throw new Error(`${label}: "${keyPath}" does not exist, so the inverse cannot remove it — the stored inverse is stale.`);
67
- }
68
- delete result[key];
69
- inverse[key] = baseValue;
70
- continue;
71
- }
72
- if (isMergeable(patchValue)) {
73
- const childBase = isMergeable(baseValue) ? baseValue : {};
74
- const childInverse = {};
75
- result[key] = mergeNode(childBase, patchValue, childInverse, keyPath, allowRemoval, label, lenient);
76
- if (!had) inverse[key] = null;
77
- else if (!isMergeable(baseValue)) inverse[key] = baseValue;
78
- else if (Object.keys(childInverse).length > 0) inverse[key] = childInverse;
79
- continue;
80
- }
81
- result[key] = allowRemoval ? patchValue : stampConsumerScope(patchValue);
82
- inverse[key] = had ? baseValue : null;
83
- }
84
- return result;
85
- }
86
- /** Reject any payload root key outside the allow list. */
87
- function assertExtendableRoots(patch) {
88
- for (const key of Object.keys(patch)) if (key !== "subcomponents" && !EXTENDABLE_FIELDS.has(key)) throw new Error(`Component extension: "${key}" cannot be extended — ${ALLOW_LIST_MESSAGE}`);
89
- }
90
- /**
91
- * Shared core for payload and inverse application. Splits the patch into
92
- * definition fields (merged onto the parent) and the `subcomponents` block
93
- * (each entry merged onto the matching `__subcomponents` child).
94
- */
95
- function applyPatch(def, patch, allowRemoval, lenient = false) {
96
- assertExtendableRoots(patch);
97
- const { subcomponents: subPatches, ...fieldPatch } = patch;
98
- const inverse = {};
99
- const result = mergeNode(def, fieldPatch, inverse, "", allowRemoval, void 0, lenient);
100
- if (subPatches !== void 0) {
101
- if (!isMergeable(subPatches)) throw new Error("Component extension: \"subcomponents\" must be an object mapping child component names to their overrides.");
102
- const children = def.__subcomponents;
103
- const subInverse = {};
104
- const mergedChildren = { ...children };
105
- for (const [childName, childPatch] of Object.entries(subPatches)) {
106
- if (childPatch === void 0) continue;
107
- const child = children?.[childName];
108
- if (!child) {
109
- if (lenient) continue;
110
- const known = Object.keys(children ?? {});
111
- const hint = known.length > 0 ? `known subcomponents are ${known.map((n) => `"${n}"`).join(", ")}.` : "this component has no subcomponents.";
112
- throw new Error(`Component extension: subcomponent "${childName}" does not exist — ${hint}`);
113
- }
114
- if (!isMergeable(childPatch)) throw new Error(`Component extension: subcomponent "${childName}" override must be an object.`);
115
- if (Object.hasOwn(childPatch, "subcomponents")) throw new Error(`Component extension: subcomponent "${childName}" cannot declare nested subcomponents.`);
116
- assertExtendableRoots(childPatch);
117
- const childInverse = {};
118
- mergedChildren[childName] = mergeNode(child, childPatch, childInverse, `subcomponents.${childName}`, allowRemoval, void 0, lenient);
119
- if (Object.keys(childInverse).length > 0) subInverse[childName] = childInverse;
120
- }
121
- result.__subcomponents = mergedChildren;
122
- if (Object.keys(subInverse).length > 0) inverse.subcomponents = subInverse;
123
- }
124
- return {
125
- result,
126
- inverse
127
- };
128
- }
129
- /**
130
- * Apply an authored extension payload (additive only — `null` anywhere
131
- * throws). Never mutates `def`; applying the returned `inverse` via
132
- * {@link applyComponentExtensionInverse} restores `def` exactly.
133
- */
134
- function applyComponentExtension(def, patch) {
135
- return applyPatch(def, patch, false);
136
- }
137
- /**
138
- * Apply an engine-generated inverse. Unlike payloads, inverses carry
139
- * removals (`null` reverts an added path), so removal is permitted here.
140
- * `lenient` skips stale paths (removals of keys that no longer exist,
141
- * children that left the family) instead of throwing — the extension
142
- * DELETE path uses it so a source-shape change can never trap a consumer
143
- * with an extension they cannot remove.
144
- */
145
- function applyComponentExtensionInverse(def, inverse, options) {
146
- return { result: applyPatch(def, inverse, true, options?.lenient ?? false).result };
147
- }
148
- /**
149
- * Apply an extension payload to one component inside a FLAT serialized
150
- * components record (the `SerializedConfig.components` shape, where compound
151
- * children are separate sibling entries named by the parent's wire
152
- * `subcomponents` list). This is the build-time re-bind hook: a consumer's
153
- * extension on a linked component is replayed onto the source node's sealed
154
- * config before the node's modules and CSS regenerate, so rendered output
155
- * reflects the extension.
156
- *
157
- * Reconstructs the compound-parent shape (`__subcomponents` from the wire
158
- * name list) so {@link applyComponentExtension}'s validation and merge
159
- * semantics apply unchanged, then flattens the merged children back to their
160
- * sibling entries. Pure — returns a new record; `components` is not mutated.
161
- */
162
- function extendSerializedComponents(components, sourceKey, payload) {
163
- const parent = components[sourceKey];
164
- if (!parent) throw new Error(`Component extension: "${sourceKey}" is not in the components record — cannot apply the extension.`);
165
- const seed = { ...parent };
166
- const childNames = parent.subcomponents ?? [];
167
- if (childNames.length > 0) {
168
- const children = {};
169
- for (const childName of childNames) {
170
- const child = components[childName];
171
- if (child) children[childName] = child;
172
- }
173
- seed.__subcomponents = children;
174
- }
175
- const { result, inverse } = applyComponentExtension(seed, payload);
176
- const { __subcomponents: mergedChildren, ...parentDef } = result;
177
- const next = {
178
- ...components,
179
- [sourceKey]: parentDef
180
- };
181
- for (const [childName, child] of Object.entries(mergedChildren ?? {})) next[childName] = child;
182
- return {
183
- components: next,
184
- record: {
185
- payload,
186
- inverse
187
- }
188
- };
189
- }
190
- /**
191
- * Wrap a registry barrel component definition, attaching the non-enumerable
192
- * `.extend(patch)`. Non-enumerable keeps the barrel value JSON-clean, the
193
- * same convention as `defineComponent`'s chain methods.
194
- */
195
- function linkedComponent(def) {
196
- Object.defineProperty(def, "extend", {
197
- enumerable: false,
198
- configurable: true,
199
- writable: true,
200
- value: function extend(patch) {
201
- if (!def.link) throw new Error("Component extension: this component carries no link marker — .extend() only applies to components linked from another system.");
202
- if (def.extension) throw new Error("Component extension: this component already carries an extension — edit the existing .extend({...}) payload instead of chaining a second one.");
203
- const { result, inverse } = applyComponentExtension(def, patch);
204
- result.extension = {
205
- payload: patch,
206
- inverse
207
- };
208
- return result;
209
- }
210
- });
211
- return def;
212
- }
213
- //#endregion
214
- export { applyComponentExtension, applyComponentExtensionInverse, extendSerializedComponents, linkedComponent };