@yahoo/uds-create-config 4.10.2 → 4.10.4

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 (103) hide show
  1. package/dist/configs/CanvasConfig.d.ts +165 -77
  2. package/dist/configs/documentation.d.ts +1 -1
  3. package/dist/configs/react-native-system.d.ts +111 -52
  4. package/dist/configs/system.d.ts +121 -87
  5. package/dist/configs/system.js +4 -0
  6. package/dist/entities/documentation/Documentation.d.ts +1 -1
  7. package/dist/entities/native/NativeModifier.d.ts +1 -1
  8. package/dist/entities/native/NativeSettings.d.ts +1 -1
  9. package/dist/entities/native/NativeStyleProperty.d.ts +2 -2
  10. package/dist/entities/native/NativeToken.d.ts +4 -3
  11. package/dist/entities/system/CanvasRole.d.ts +1 -1
  12. package/dist/entities/system/Component.d.ts +23 -13
  13. package/dist/entities/system/Component.js +41 -15
  14. package/dist/entities/system/Composite.d.ts +1 -1
  15. package/dist/entities/system/Device.d.ts +1 -1
  16. package/dist/entities/system/File.d.ts +2 -2
  17. package/dist/entities/system/Font.d.ts +1 -1
  18. package/dist/entities/system/GlobalStyle.d.ts +1 -1
  19. package/dist/entities/system/Guidance.d.ts +1 -1
  20. package/dist/entities/system/GuidanceStyle.d.ts +1 -1
  21. package/dist/entities/system/Icon.d.ts +63 -11
  22. package/dist/entities/system/Icon.js +70 -14
  23. package/dist/entities/system/LinkedSystem.d.ts +1 -1
  24. package/dist/entities/system/Modifier.d.ts +2 -2
  25. package/dist/entities/system/Motion.d.ts +1 -1
  26. package/dist/entities/system/Package.d.ts +1 -1
  27. package/dist/entities/system/Settings.d.ts +1 -1
  28. package/dist/entities/system/StyleProperty.d.ts +12 -19
  29. package/dist/entities/system/StyleProperty.js +7 -10
  30. package/dist/entities/system/Token.d.ts +4 -3
  31. package/dist/entities/system/defineComponent.d.ts +21 -6
  32. package/dist/entities/system/defineComponent.js +7 -12
  33. package/dist/entities/system/glyph-identity.d.ts +7 -0
  34. package/dist/entities/system/glyph-identity.js +153 -0
  35. package/dist/entities/system/icon-domain-invariants.d.ts +11 -0
  36. package/dist/entities/system/icon-domain-invariants.js +178 -0
  37. package/dist/entities/system/icon-library.d.ts +93 -34
  38. package/dist/entities/system/icon-library.js +218 -50
  39. package/dist/entities/system/icon-metadata.d.ts +10 -4
  40. package/dist/entities/system/icon-metadata.js +45 -5
  41. package/dist/entities/system/runtime-modules.js +5 -5
  42. package/dist/entities/system/style-bag.js +14 -2
  43. package/dist/framework/Config.d.ts +1 -1
  44. package/dist/framework/Config.js +34 -5
  45. package/dist/framework/defineConfig.d.ts +6 -3
  46. package/dist/framework/defineEntity.d.ts +54 -15
  47. package/dist/framework/defineEntity.js +56 -2
  48. package/dist/framework/projections.d.ts +40 -2
  49. package/dist/framework/projections.js +99 -5
  50. package/dist/framework/prop-surface.d.ts +6 -5
  51. package/dist/framework/prop-surface.js +12 -14
  52. package/dist/framework/registry.d.ts +17 -1
  53. package/dist/framework/registry.js +2 -1
  54. package/dist/framework/render-spec.d.ts +6 -5
  55. package/dist/framework/render-spec.js +16 -11
  56. package/dist/framework/schema-version.d.ts +1 -1
  57. package/dist/framework/schema-version.js +5 -5
  58. package/dist/framework/signature.js +5 -1
  59. package/dist/framework/utils/group.d.ts +15 -1
  60. package/dist/framework/utils/ref-grammar.d.ts +35 -0
  61. package/dist/framework/utils/ref-grammar.js +76 -0
  62. package/dist/framework/utils/refs.d.ts +13 -45
  63. package/dist/framework/utils/refs.js +31 -94
  64. package/dist/framework/value-domain.js +53 -8
  65. package/dist/index.d.ts +6 -6
  66. package/dist/index.js +5 -5
  67. package/dist/migrations/2.0.0/v1-artifact.d.ts +62 -45
  68. package/dist/migrations/2.0.0/v1-artifact.js +5 -7
  69. package/dist/migrations/20260921044042_icon_library_without_component.d.ts +19 -0
  70. package/dist/migrations/20260921044042_icon_library_without_component.js +86 -0
  71. package/dist/migrations/20260922013625_icon_libraries.d.ts +18 -0
  72. package/dist/migrations/20260922013625_icon_libraries.js +8 -0
  73. package/dist/renderer/UdsRenderer.d.ts +8 -1
  74. package/dist/renderer/UdsRenderer.js +7 -3
  75. package/dist/renderer/glyphEntries.d.ts +32 -0
  76. package/dist/renderer/glyphEntries.js +48 -0
  77. package/dist/renderer/glyphRenderable.d.ts +10 -0
  78. package/dist/renderer/glyphRenderable.js +40 -0
  79. package/dist/renderer/icon-library.d.ts +18 -11
  80. package/dist/renderer/index.d.ts +4 -2
  81. package/dist/renderer/index.js +4 -2
  82. package/dist/renderer/resolveGlyph.d.ts +47 -0
  83. package/dist/renderer/resolveGlyph.js +78 -0
  84. package/dist/renderer/wrapRegistry.d.ts +13 -4
  85. package/dist/renderer/wrapRegistry.js +7 -5
  86. package/dist/renderer/wrappers/component-refs.js +6 -2
  87. package/dist/renderer/wrappers/glyph-props.d.ts +15 -0
  88. package/dist/renderer/wrappers/glyph-props.js +65 -0
  89. package/dist/spec/glyph-jsx.d.ts +41 -0
  90. package/dist/spec/{asset-jsx.js → glyph-jsx.js} +7 -25
  91. package/dist/spec/index.d.ts +2 -2
  92. package/dist/spec/index.js +2 -2
  93. package/dist/spec/jsxToSpec.d.ts +10 -4
  94. package/dist/spec/jsxToSpec.js +21 -4
  95. package/dist/spec/specToJsx.d.ts +20 -9
  96. package/dist/spec/specToJsx.js +77 -16
  97. package/dist/tsconfig.tsbuildinfo +1 -1
  98. package/package.json +2 -2
  99. package/dist/renderer/assetEntries.d.ts +0 -37
  100. package/dist/renderer/assetEntries.js +0 -38
  101. package/dist/renderer/assetRenderable.d.ts +0 -25
  102. package/dist/renderer/assetRenderable.js +0 -19
  103. package/dist/spec/asset-jsx.d.ts +0 -61
@@ -1,4 +1,3 @@
1
- import { AssetComponentMap } from "./asset-jsx.js";
2
1
  import { Spec } from "@json-render/core";
3
2
 
4
3
  //#region src/spec/specToJsx.d.ts
@@ -14,21 +13,33 @@ interface SpecToJsxOptions {
14
13
  */
15
14
  omitImports?: boolean;
16
15
  /**
17
- * `asset group slug → component tag used for JSX export`
18
- * (e.g. `{ icons: 'Icon' }`).
19
- *
20
- * This is derived from `Config.assetGroups[*].component`. It does not affect
21
- * asset registration or rendering; it only controls whether a stored asset node
22
- * like `yahoo-os:asset:icons/Trophy` prints as `<Icon name="Trophy" />`
23
- * instead of the fallback `<Trophy />`.
16
+ * Icon library slug → the module its members import from (`{ phosphor: '@phosphor-icons/react' }`).
17
+ * A placed glyph, and a glyph a prop holds, then import from that module under `memberImports`
18
+ * instead of joining the component imports.
24
19
  */
25
- assetComponents?: AssetComponentMap;
20
+ glyphModules?: Readonly<Record<string, string>>;
21
+ /**
22
+ * Component type → prop → the icon libraries its values come from, in declaration order. A string
23
+ * value of such a prop is a member name in the stored form; authored code holds the component, so
24
+ * it prints as the identifier (`name={StarIcon}`) and the member is imported from the library
25
+ * `glyphMembers` says holds it, or from the first of those libraries `glyphModules` names a
26
+ * module for.
27
+ */
28
+ glyphProps?: Readonly<Record<string, Readonly<Record<string, readonly string[]>>>>;
29
+ /**
30
+ * Icon library slug → the member names it holds. A prop that binds several libraries names them
31
+ * all, and only this says which one a bare member name came from, so the import points at the
32
+ * package that exports it.
33
+ */
34
+ glyphMembers?: Readonly<Record<string, readonly string[]>>;
26
35
  }
27
36
  interface SpecToJsxResult {
28
37
  /** Generated JSX source code */
29
38
  jsx: string;
30
39
  /** Component names used (for imports) */
31
40
  imports: string[];
41
+ /** Glyph members used, by the module they import from — only with `glyphModules`. */
42
+ memberImports: Record<string, string[]>;
32
43
  }
33
44
  declare function specToJsx(spec: Spec, options?: SpecToJsxOptions): SpecToJsxResult;
34
45
  //#endregion
@@ -1,6 +1,37 @@
1
- import { assetJsxForm, jsxIdentifier } from "./asset-jsx.js";
1
+ import { glyphJsxForm, jsxIdentifier, parseGlyphType } from "./glyph-jsx.js";
2
2
  import { serializeProps } from "@json-render/codegen";
3
3
  //#region src/spec/specToJsx.ts
4
+ /** Record a glyph member as imported from the library that lists it, else from the first of `slugs`
5
+ * whose module is known; `false` when none of them names one. */
6
+ function importMember({ ctx, slugs, name }) {
7
+ const holder = slugs.find((slug) => ctx.glyphMembers?.[slug]?.includes(name));
8
+ for (const slug of holder ? [holder, ...slugs] : slugs) {
9
+ const module = ctx.glyphModules?.[slug];
10
+ if (!module) continue;
11
+ const names = ctx.members.get(module) ?? /* @__PURE__ */ new Set();
12
+ names.add(name);
13
+ ctx.members.set(module, names);
14
+ return true;
15
+ }
16
+ return false;
17
+ }
18
+ /** A stored glyph value — the member ref, or the member's name under a prop the config declares as
19
+ * a glyph — as its name plus the libraries it could be imported from. A ref names its own library,
20
+ * so it answers with that one; a bare name answers with the prop's whole domain. */
21
+ function glyphValue({ value, libraries }) {
22
+ const marker = value?.__ref;
23
+ if (typeof marker === "string") {
24
+ const parsed = parseGlyphType(marker);
25
+ return parsed ? {
26
+ slugs: [parsed.slug],
27
+ name: parsed.member
28
+ } : void 0;
29
+ }
30
+ if (typeof value === "string" && libraries && libraries.length > 0) return {
31
+ slugs: libraries,
32
+ name: value
33
+ };
34
+ }
4
35
  function statePathToExpression(path) {
5
36
  return `state${path.split("/").filter(Boolean).map((s) => `.${s}`).join("")}`;
6
37
  }
@@ -72,7 +103,7 @@ function collectUsedComponentTypes(spec) {
72
103
  }
73
104
  return types;
74
105
  }
75
- function renderElement(key, spec, depth, assetComponents, ancestors) {
106
+ function renderElement(key, spec, depth, ctx, ancestors) {
76
107
  const element = spec.elements[key];
77
108
  if (!element) return "";
78
109
  const indent = " ".repeat(depth);
@@ -82,16 +113,36 @@ function renderElement(key, spec, depth, assetComponents, ancestors) {
82
113
  const slotKeys = collectSlotKeys(element.slots);
83
114
  const slotAttrs = [];
84
115
  for (const [propName, fills] of Object.entries(element.slots ?? {})) if (fills.length === 1) {
85
- const rendered = renderElement(fills[0], spec, 0, assetComponents, withSelf).trim();
116
+ const rendered = renderElement(fills[0], spec, 0, ctx, withSelf).trim();
86
117
  slotAttrs.push(`${propName}={${rendered}}`);
87
118
  } else {
88
- const rendered = fills.map((r) => renderElement(r, spec, 0, assetComponents, withSelf).trim()).filter(Boolean);
119
+ const rendered = fills.map((r) => renderElement(r, spec, 0, ctx, withSelf).trim()).filter(Boolean);
89
120
  slotAttrs.push(`${propName}={<>${rendered.join("")}</>}`);
90
121
  }
91
- const assetForm = assetJsxForm(element.type, assetComponents);
92
- const tag = assetForm?.tag ?? jsxIdentifier(element.type);
93
- const nameAttr = assetForm?.nameAttr ? `name="${assetForm.nameAttr}"` : "";
94
- if (assetForm?.nameAttr) delete propsWithoutSlots.name;
122
+ const tag = glyphJsxForm(element.type)?.tag ?? jsxIdentifier(element.type);
123
+ const placed = parseGlyphType(element.type);
124
+ if (placed) importMember({
125
+ ctx,
126
+ slugs: [placed.slug],
127
+ name: placed.member
128
+ });
129
+ const glyphAttrs = [];
130
+ const declaredGlyphs = ctx.glyphProps?.[element.type] ?? {};
131
+ for (const [prop, value] of Object.entries(propsWithoutSlots)) {
132
+ const glyph = glyphValue({
133
+ value,
134
+ libraries: declaredGlyphs[prop]
135
+ });
136
+ if (!glyph) continue;
137
+ glyphAttrs.push(`${prop}={${glyph.name}}`);
138
+ importMember({
139
+ ctx,
140
+ slugs: glyph.slugs,
141
+ name: glyph.name
142
+ });
143
+ delete propsWithoutSlots[prop];
144
+ }
145
+ const nameAttr = glyphAttrs.join(" ");
95
146
  const staticAttrs = Object.keys(propsWithoutSlots).length > 0 ? serializeProps(propsWithoutSlots) : "";
96
147
  const eventAttrs = [];
97
148
  if (element.on && typeof element.on === "object") {
@@ -134,7 +185,7 @@ function renderElement(key, spec, depth, assetComponents, ancestors) {
134
185
  if (inlineContent !== null) childLines.push(`${" ".repeat(depth + 1)}${inlineContent}`);
135
186
  for (const childKey of childKeys) {
136
187
  if (!spec.elements[childKey]) continue;
137
- childLines.push(renderElement(childKey, spec, depth + 1, assetComponents, withSelf));
188
+ childLines.push(renderElement(childKey, spec, depth + 1, ctx, withSelf));
138
189
  }
139
190
  jsxLine = `${indent}<${tag}${propsStr}>\n${childLines.join("\n")}\n${indent}</${tag}>`;
140
191
  }
@@ -151,18 +202,28 @@ function specToJsx(spec, options) {
151
202
  const importSource = options?.importSource ?? "./uds/components";
152
203
  if (!spec.elements[spec.root]) return {
153
204
  jsx: "",
154
- imports: []
205
+ imports: [],
206
+ memberImports: {}
207
+ };
208
+ const ctx = {
209
+ glyphModules: options?.glyphModules,
210
+ glyphProps: options?.glyphProps,
211
+ glyphMembers: options?.glyphMembers,
212
+ members: /* @__PURE__ */ new Map()
155
213
  };
156
- const assetComponents = options?.assetComponents;
157
- const sortedImports = [...new Set([...collectUsedComponentTypes(spec)].map((type) => assetJsxForm(type, assetComponents)?.importName ?? jsxIdentifier(type)))].sort();
158
- const jsxTree = renderElement(spec.root, spec, 0, assetComponents, /* @__PURE__ */ new Set());
214
+ const jsxTree = renderElement(spec.root, spec, 0, ctx, /* @__PURE__ */ new Set());
215
+ const fromLibraries = new Set([...ctx.members.values()].flatMap((names) => [...names]));
216
+ const sortedImports = [...new Set([...collectUsedComponentTypes(spec)].map((type) => glyphJsxForm(type)?.importName ?? jsxIdentifier(type)).filter((name) => !fromLibraries.has(name)))].sort();
217
+ const memberImports = Object.fromEntries([...ctx.members.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([module, names]) => [module, [...names].sort()]));
159
218
  if (options?.omitImports) return {
160
219
  jsx: jsxTree,
161
- imports: sortedImports
220
+ imports: sortedImports,
221
+ memberImports
162
222
  };
163
223
  return {
164
- jsx: `${`import { ${sortedImports.join(", ")} } from '${importSource}';`}\n\n${jsxTree}`,
165
- imports: sortedImports
224
+ jsx: `${[...sortedImports.length ? [`import { ${sortedImports.join(", ")} } from '${importSource}';`] : [], ...Object.entries(memberImports).map(([module, names]) => `import { ${names.join(", ")} } from '${module}';`)].join("\n")}\n\n${jsxTree}`,
225
+ imports: sortedImports,
226
+ memberImports
166
227
  };
167
228
  }
168
229
  //#endregion