@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.
- package/dist/configs/CanvasConfig.d.ts +165 -77
- package/dist/configs/documentation.d.ts +1 -1
- package/dist/configs/react-native-system.d.ts +111 -52
- package/dist/configs/system.d.ts +121 -87
- package/dist/configs/system.js +4 -0
- package/dist/entities/documentation/Documentation.d.ts +1 -1
- package/dist/entities/native/NativeModifier.d.ts +1 -1
- package/dist/entities/native/NativeSettings.d.ts +1 -1
- package/dist/entities/native/NativeStyleProperty.d.ts +2 -2
- package/dist/entities/native/NativeToken.d.ts +4 -3
- package/dist/entities/system/CanvasRole.d.ts +1 -1
- package/dist/entities/system/Component.d.ts +23 -13
- package/dist/entities/system/Component.js +41 -15
- package/dist/entities/system/Composite.d.ts +1 -1
- package/dist/entities/system/Device.d.ts +1 -1
- package/dist/entities/system/File.d.ts +2 -2
- package/dist/entities/system/Font.d.ts +1 -1
- package/dist/entities/system/GlobalStyle.d.ts +1 -1
- package/dist/entities/system/Guidance.d.ts +1 -1
- package/dist/entities/system/GuidanceStyle.d.ts +1 -1
- package/dist/entities/system/Icon.d.ts +63 -11
- package/dist/entities/system/Icon.js +70 -14
- package/dist/entities/system/LinkedSystem.d.ts +1 -1
- package/dist/entities/system/Modifier.d.ts +2 -2
- package/dist/entities/system/Motion.d.ts +1 -1
- package/dist/entities/system/Package.d.ts +1 -1
- package/dist/entities/system/Settings.d.ts +1 -1
- package/dist/entities/system/StyleProperty.d.ts +12 -19
- package/dist/entities/system/StyleProperty.js +7 -10
- package/dist/entities/system/Token.d.ts +4 -3
- package/dist/entities/system/defineComponent.d.ts +21 -6
- package/dist/entities/system/defineComponent.js +7 -12
- package/dist/entities/system/glyph-identity.d.ts +7 -0
- package/dist/entities/system/glyph-identity.js +153 -0
- package/dist/entities/system/icon-domain-invariants.d.ts +11 -0
- package/dist/entities/system/icon-domain-invariants.js +178 -0
- package/dist/entities/system/icon-library.d.ts +93 -34
- package/dist/entities/system/icon-library.js +218 -50
- package/dist/entities/system/icon-metadata.d.ts +10 -4
- package/dist/entities/system/icon-metadata.js +45 -5
- package/dist/entities/system/runtime-modules.js +5 -5
- package/dist/entities/system/style-bag.js +14 -2
- package/dist/framework/Config.d.ts +1 -1
- package/dist/framework/Config.js +34 -5
- package/dist/framework/defineConfig.d.ts +6 -3
- package/dist/framework/defineEntity.d.ts +54 -15
- package/dist/framework/defineEntity.js +56 -2
- package/dist/framework/projections.d.ts +40 -2
- package/dist/framework/projections.js +99 -5
- package/dist/framework/prop-surface.d.ts +6 -5
- package/dist/framework/prop-surface.js +12 -14
- package/dist/framework/registry.d.ts +17 -1
- package/dist/framework/registry.js +2 -1
- package/dist/framework/render-spec.d.ts +6 -5
- package/dist/framework/render-spec.js +16 -11
- package/dist/framework/schema-version.d.ts +1 -1
- package/dist/framework/schema-version.js +5 -5
- package/dist/framework/signature.js +5 -1
- package/dist/framework/utils/group.d.ts +15 -1
- package/dist/framework/utils/ref-grammar.d.ts +35 -0
- package/dist/framework/utils/ref-grammar.js +76 -0
- package/dist/framework/utils/refs.d.ts +13 -45
- package/dist/framework/utils/refs.js +31 -94
- package/dist/framework/value-domain.js +53 -8
- package/dist/index.d.ts +6 -6
- package/dist/index.js +5 -5
- package/dist/migrations/2.0.0/v1-artifact.d.ts +62 -45
- package/dist/migrations/2.0.0/v1-artifact.js +5 -7
- package/dist/migrations/20260921044042_icon_library_without_component.d.ts +19 -0
- package/dist/migrations/20260921044042_icon_library_without_component.js +86 -0
- package/dist/migrations/20260922013625_icon_libraries.d.ts +18 -0
- package/dist/migrations/20260922013625_icon_libraries.js +8 -0
- package/dist/renderer/UdsRenderer.d.ts +8 -1
- package/dist/renderer/UdsRenderer.js +7 -3
- package/dist/renderer/glyphEntries.d.ts +32 -0
- package/dist/renderer/glyphEntries.js +48 -0
- package/dist/renderer/glyphRenderable.d.ts +10 -0
- package/dist/renderer/glyphRenderable.js +40 -0
- package/dist/renderer/icon-library.d.ts +18 -11
- package/dist/renderer/index.d.ts +4 -2
- package/dist/renderer/index.js +4 -2
- package/dist/renderer/resolveGlyph.d.ts +47 -0
- package/dist/renderer/resolveGlyph.js +78 -0
- package/dist/renderer/wrapRegistry.d.ts +13 -4
- package/dist/renderer/wrapRegistry.js +7 -5
- package/dist/renderer/wrappers/component-refs.js +6 -2
- package/dist/renderer/wrappers/glyph-props.d.ts +15 -0
- package/dist/renderer/wrappers/glyph-props.js +65 -0
- package/dist/spec/glyph-jsx.d.ts +41 -0
- package/dist/spec/{asset-jsx.js → glyph-jsx.js} +7 -25
- package/dist/spec/index.d.ts +2 -2
- package/dist/spec/index.js +2 -2
- package/dist/spec/jsxToSpec.d.ts +10 -4
- package/dist/spec/jsxToSpec.js +21 -4
- package/dist/spec/specToJsx.d.ts +20 -9
- package/dist/spec/specToJsx.js +77 -16
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/renderer/assetEntries.d.ts +0 -37
- package/dist/renderer/assetEntries.js +0 -38
- package/dist/renderer/assetRenderable.d.ts +0 -25
- package/dist/renderer/assetRenderable.js +0 -19
- package/dist/spec/asset-jsx.d.ts +0 -61
package/dist/spec/specToJsx.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
18
|
-
*
|
|
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
|
-
|
|
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
|
package/dist/spec/specToJsx.js
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
|
-
import {
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
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,
|
|
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
|
|
157
|
-
const
|
|
158
|
-
const
|
|
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
|