@yahoo/uds-create-config 4.33.0 → 4.34.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.
@@ -62,7 +62,12 @@ declare const ReactNativeSystem: ConfigClass<{
62
62
  canvas: _$zod.ZodOptional<_$zod.ZodObject<{
63
63
  packageAliases: _$zod.ZodOptional<_$zod.ZodRecord<_$zod.ZodString, _$zod.ZodString>>;
64
64
  }, _$zod_v4_core0.$strict>>;
65
- }, _$zod_v4_core0.$strip>, _$zod.ZodObject<Omit<Record<never, never>, never> & {}, _$zod_v4_core0.$strip>, "settings", Record<never, never>, Record<never, never>, true, Record<never, never>, Record<never, never>>;
65
+ }, _$zod_v4_core0.$strip>, _$zod.ZodObject<Omit<Record<never, never>, never> & {}, _$zod_v4_core0.$strip>, "settings", Record<never, never>, {
66
+ readonly inputDir: ({
67
+ member,
68
+ config
69
+ }: ComputedInput) => string;
70
+ }, true, Record<never, never>, Record<never, never>>;
66
71
  tokens: EntityClass<_$zod.ZodObject<Omit<{
67
72
  value: _$zod.ZodType<string | number | Ref | ComposedValue, unknown, _$zod_v4_core0.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
68
73
  type: _$zod.ZodOptional<_$zod.ZodString>;
@@ -2271,7 +2276,12 @@ declare const ReactNativeSystem: ConfigClass<{
2271
2276
  canvas: _$zod.ZodOptional<_$zod.ZodObject<{
2272
2277
  packageAliases: _$zod.ZodOptional<_$zod.ZodRecord<_$zod.ZodString, _$zod.ZodString>>;
2273
2278
  }, _$zod_v4_core0.$strict>>;
2274
- }, _$zod_v4_core0.$strip>, _$zod.ZodObject<Omit<Record<never, never>, never> & {}, _$zod_v4_core0.$strip>, "settings", Record<never, never>, Record<never, never>, true, Record<never, never>, Record<never, never>>;
2279
+ }, _$zod_v4_core0.$strip>, _$zod.ZodObject<Omit<Record<never, never>, never> & {}, _$zod_v4_core0.$strip>, "settings", Record<never, never>, {
2280
+ readonly inputDir: ({
2281
+ member,
2282
+ config
2283
+ }: ComputedInput) => string;
2284
+ }, true, Record<never, never>, Record<never, never>>;
2275
2285
  tokens: EntityClass<_$zod.ZodObject<Omit<{
2276
2286
  value: _$zod.ZodType<string | number | Ref | ComposedValue, unknown, _$zod_v4_core0.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
2277
2287
  type: _$zod.ZodOptional<_$zod.ZodString>;
@@ -56,7 +56,12 @@ declare const System: ConfigClass<{
56
56
  pagesDir: _$zod.ZodOptional<_$zod.ZodString>;
57
57
  port: _$zod.ZodOptional<_$zod.ZodNumber>;
58
58
  }, _$zod_v4_core0.$strict>>;
59
- }, _$zod_v4_core0.$strict>, _$zod.ZodObject<Record<never, never>, _$zod_v4_core0.$strip>, "settings", Record<never, never>, Record<never, never>, true, Record<never, never>, Record<never, never>>;
59
+ }, _$zod_v4_core0.$strict>, _$zod.ZodObject<Record<never, never>, _$zod_v4_core0.$strip>, "settings", Record<never, never>, {
60
+ readonly inputDir: ({
61
+ member,
62
+ config
63
+ }: ComputedInput) => string;
64
+ }, true, Record<never, never>, Record<never, never>>;
60
65
  tokens: Omit<EntityClass<_$zod.ZodObject<{
61
66
  value: _$zod.ZodType<string | number | Ref | ComposedValue, unknown, _$zod_v4_core0.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
62
67
  type: _$zod.ZodOptional<_$zod.ZodString>;
@@ -2140,7 +2145,12 @@ declare const System: ConfigClass<{
2140
2145
  pagesDir: _$zod.ZodOptional<_$zod.ZodString>;
2141
2146
  port: _$zod.ZodOptional<_$zod.ZodNumber>;
2142
2147
  }, _$zod_v4_core0.$strict>>;
2143
- }, _$zod_v4_core0.$strict>, _$zod.ZodObject<Record<never, never>, _$zod_v4_core0.$strip>, "settings", Record<never, never>, Record<never, never>, true, Record<never, never>, Record<never, never>>;
2148
+ }, _$zod_v4_core0.$strict>, _$zod.ZodObject<Record<never, never>, _$zod_v4_core0.$strip>, "settings", Record<never, never>, {
2149
+ readonly inputDir: ({
2150
+ member,
2151
+ config
2152
+ }: ComputedInput) => string;
2153
+ }, true, Record<never, never>, Record<never, never>>;
2144
2154
  tokens: Omit<EntityClass<_$zod.ZodObject<{
2145
2155
  value: _$zod.ZodType<string | number | Ref | ComposedValue, unknown, _$zod_v4_core0.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
2146
2156
  type: _$zod.ZodOptional<_$zod.ZodString>;
@@ -1,4 +1,5 @@
1
1
  import { SubEntityClass } from "../../framework/defineSubEntity.js";
2
+ import { ComputedInput } from "../../framework/registry.js";
2
3
  import { EntityClass } from "../../framework/defineEntity.js";
3
4
  import { z } from "zod";
4
5
 
@@ -40,6 +41,11 @@ declare const NativeSettings: EntityClass<z.ZodObject<Omit<{
40
41
  canvas: z.ZodOptional<z.ZodObject<{
41
42
  packageAliases: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
42
43
  }, z.core.$strict>>;
43
- }, z.core.$strip>, z.ZodObject<Omit<Record<never, never>, never> & {}, z.core.$strip>, "settings", Record<never, never>, Record<never, never>, true, Record<never, never>, Record<never, never>>;
44
+ }, z.core.$strip>, z.ZodObject<Omit<Record<never, never>, never> & {}, z.core.$strip>, "settings", Record<never, never>, {
45
+ readonly inputDir: ({
46
+ member,
47
+ config
48
+ }: ComputedInput) => string;
49
+ }, true, Record<never, never>, Record<never, never>>;
44
50
  //#endregion
45
51
  export { CanvasSection, NativeSettings };
@@ -1,4 +1,5 @@
1
1
  import { SubEntityClass } from "../../framework/defineSubEntity.js";
2
+ import { ComputedInput } from "../../framework/registry.js";
2
3
  import { EntityClass } from "../../framework/defineEntity.js";
3
4
  import { Config } from "../../framework/Config.js";
4
5
  import { z } from "zod";
@@ -92,6 +93,16 @@ declare const Settings: EntityClass<z.ZodObject<{
92
93
  pagesDir: z.ZodOptional<z.ZodString>;
93
94
  port: z.ZodOptional<z.ZodNumber>;
94
95
  }, z.core.$strict>>;
95
- }, z.core.$strict>, z.ZodObject<Record<never, never>, z.core.$strip>, "settings", Record<never, never>, Record<never, never>, true, Record<never, never>, Record<never, never>>;
96
+ }, z.core.$strict>, z.ZodObject<Record<never, never>, z.core.$strip>, "settings", Record<never, never>, {
97
+ /**
98
+ * The directory this system's component files are laid out beneath, always defined:
99
+ * `build.inputDir` when authored, else derived from where the files live. Every reader of the
100
+ * layout reads this rather than `build.inputDir`.
101
+ */
102
+ readonly inputDir: ({
103
+ member,
104
+ config
105
+ }: ComputedInput) => string;
106
+ }, true, Record<never, never>, Record<never, never>>;
96
107
  //#endregion
97
108
  export { BuildSection, CSS_DEFAULTS, CssPrefix, CssSection, PLAYGROUND_DEFAULTS, PlaygroundSection, Settings, SystemSection, classPrefixOf, cssPrefixes, varPrefixOf };
@@ -1,7 +1,10 @@
1
+ import { splitRef } from "../../framework/utils/refs.js";
1
2
  import { defineEntity } from "../../framework/defineEntity.js";
2
3
  import { defineSubEntity } from "../../framework/defineSubEntity.js";
3
4
  import { buildFields } from "../../configs/build-options.js";
4
5
  import { parseRootFontSize } from "../../css/root-font-size.js";
6
+ import { createSliceMemo } from "../../framework/memo.js";
7
+ import { resolveInputDir } from "../../framework/registry-dir.js";
5
8
  import { z } from "zod";
6
9
  //#region src/entities/system/Settings.ts
7
10
  /**
@@ -153,6 +156,67 @@ const PlaygroundSection = defineSubEntity({
153
156
  singleton: true,
154
157
  fields: playgroundFields
155
158
  });
159
+ /** The folders of a path, file name dropped. */
160
+ const foldersOf = (file) => file.split("/").slice(0, -1);
161
+ /** The folders every one of `lists` starts with. */
162
+ function sharedFolders(lists) {
163
+ return lists.reduce((shared, folders) => {
164
+ let length = 0;
165
+ while (length < shared.length && shared[length] === folders[length]) length += 1;
166
+ return shared.slice(0, length);
167
+ });
168
+ }
169
+ /** The paths of the local files this system's components are implemented in. */
170
+ function localComponentFiles(config) {
171
+ const paths = /* @__PURE__ */ new Set();
172
+ for (const component of config.list("component")) {
173
+ const file = component.toJSON().file;
174
+ if (!file?.__ref) continue;
175
+ const target = splitRef(file.__ref);
176
+ if (target.kind === "file" && !target.source) paths.add(target.path);
177
+ }
178
+ return [...paths];
179
+ }
180
+ /** `from` and every local file they import, directly or through another. */
181
+ function reachedFiles(config, from) {
182
+ const bodies = new Map(config.list("file").map((item) => [item.path, item.toJSON()]));
183
+ const reached = new Set(from);
184
+ const queue = [...from];
185
+ while (queue.length > 0) {
186
+ const imports = bodies.get(queue.pop() ?? "")?.imports;
187
+ if (!imports || typeof imports !== "object") continue;
188
+ for (const edge of Object.values(imports)) {
189
+ const target = edge.target?.__ref;
190
+ if (!target) continue;
191
+ const file = splitRef(target);
192
+ if (file.kind !== "file" || file.source || reached.has(file.path)) continue;
193
+ reached.add(file.path);
194
+ queue.push(file.path);
195
+ }
196
+ }
197
+ return [...reached];
198
+ }
199
+ /**
200
+ * The root of a system that declares no `inputDir`. Component files under one `uds/components/`
201
+ * folder are laid out beneath that folder, the convention's layout. Otherwise the root is the deepest
202
+ * folder shared by the component files and every local file they import. A file nothing imports,
203
+ * such as the config's own source, has no place in the output and doesn't count. Empty when there is
204
+ * none: a system with no local component files has nothing to lay out, and one whose files share no
205
+ * folder keeps the layout it had.
206
+ *
207
+ * OPEN: that root moves when a file is added outside it. UDS-4567 replaces this with a rule every
208
+ * registered file has to meet.
209
+ */
210
+ const derivedInputDir = createSliceMemo({
211
+ kinds: ["component", "file"],
212
+ compute: (config) => {
213
+ const components = localComponentFiles(config);
214
+ if (components.length === 0) return "";
215
+ const shared = sharedFolders(components.map(foldersOf));
216
+ for (let end = shared.length; end >= 2; end -= 1) if (shared[end - 2] === "uds" && shared[end - 1] === "components") return shared.slice(0, end).join("/");
217
+ return sharedFolders(reachedFiles(config, components).map(foldersOf)).join("/");
218
+ }
219
+ });
156
220
  const Settings = defineEntity({
157
221
  kind: "settings",
158
222
  label: "Settings",
@@ -171,7 +235,14 @@ const Settings = defineEntity({
171
235
  build: BuildSection,
172
236
  css: CssSection,
173
237
  playground: PlaygroundSection
174
- }
238
+ },
239
+ computed: {
240
+ /**
241
+ * The directory this system's component files are laid out beneath, always defined:
242
+ * `build.inputDir` when authored, else derived from where the files live. Every reader of the
243
+ * layout reads this rather than `build.inputDir`.
244
+ */
245
+ inputDir: ({ member, config }) => resolveInputDir(member.build) ?? derivedInputDir(config) }
175
246
  });
176
247
  //#endregion
177
248
  export { BuildSection, CSS_DEFAULTS, CssSection, PLAYGROUND_DEFAULTS, PlaygroundSection, Settings, SystemSection, classPrefixOf, cssPrefixes, varPrefixOf };
@@ -1,6 +1,6 @@
1
1
  import { ref, splitRef } from "../../framework/utils/refs.js";
2
- import { Settings } from "./Settings.js";
3
2
  import { createSliceMemo } from "../../framework/memo.js";
3
+ import { Settings } from "./Settings.js";
4
4
  import { File } from "./File.js";
5
5
  import { Component } from "./Component.js";
6
6
  import { contentKey } from "../../framework/utils/content-key.js";
@@ -65,7 +65,8 @@ function componentRuntimeKey(config) {
65
65
  version: COMPONENT_MODULE_BUILD_VERSION,
66
66
  name: config.name,
67
67
  settings: Settings.get(config)?.toJSON(),
68
- entities: componentRuntimeEntitiesKey(config)
68
+ entities: componentRuntimeEntitiesKey(config),
69
+ inputDir: Settings.get(config)?.inputDir
69
70
  });
70
71
  }
71
72
  /** Every local sealed file -> the components it declares. One file is one module. */
@@ -1,7 +1,7 @@
1
1
  import { isRef, kindOf, pathOf, ref, splitRef } from "../../framework/utils/refs.js";
2
2
  import { parseRootFontSize } from "../../css/root-font-size.js";
3
- import { CSS_DEFAULTS, Settings } from "./Settings.js";
4
3
  import { createSliceMemo } from "../../framework/memo.js";
4
+ import { CSS_DEFAULTS, Settings } from "./Settings.js";
5
5
  import { cssVar, resolveTokenValue } from "../../framework/projections.js";
6
6
  //#region src/entities/system/token-values.ts
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import { isRef, kindOf, memberOf, pathOf, refLeaf } from "./utils/refs.js";
2
2
  import { forwardsOf, rootLayerOf } from "../entities/system/element.js";
3
- import { classPrefixOf } from "../entities/system/Settings.js";
4
3
  import { createSliceMemo } from "./memo.js";
4
+ import { classPrefixOf } from "../entities/system/Settings.js";
5
5
  import { storedPreview } from "./preview-store.js";
6
6
  import { authoredValue, className, negatedCssValue, renderStyleValue, resolveComponentProps, stylePropLeafForToken, stylePropValueLeaves, stylePropertyPathFor } from "./projections.js";
7
7
  import { ruleApplies } from "./layer-styles.js";
@@ -4,9 +4,9 @@ import { forwardedPropName, forwardsOf, rootLayerOf } from "../entities/system/e
4
4
  import { fontFamilyStack } from "../entities/system/Font.js";
5
5
  import { listedIn } from "./utils/enumerated.js";
6
6
  import { modifierCategory } from "../entities/system/Modifier.js";
7
+ import { createSliceMemo } from "./memo.js";
7
8
  import { classPrefixOf, varPrefixOf } from "../entities/system/Settings.js";
8
9
  import { StyleProperty, leavesOfStylePropValue } from "../entities/system/StyleProperty.js";
9
- import { createSliceMemo } from "./memo.js";
10
10
  import { isConditionalPreview, storedPreview, unconditionalPreviewProps } from "./preview-store.js";
11
11
  //#region src/framework/projections.ts
12
12
  /**
package/dist/index.js CHANGED
@@ -24,10 +24,11 @@ import { MODIFIER_CATEGORIES, Modifier, WEB_ACTIVATIONS, modeAxes, modifierAxes,
24
24
  import { BUILD_DEFAULTS } from "./configs/build-options.js";
25
25
  import { resolveValueType, sniffValueType } from "./css/value-type.js";
26
26
  import { parseRootFontSize } from "./css/root-font-size.js";
27
+ import { createSliceMemo } from "./framework/memo.js";
28
+ import { resolveInputDir, resolveOutDir, resolveRegistryDir } from "./framework/registry-dir.js";
27
29
  import { BuildSection, CSS_DEFAULTS, CssSection, PLAYGROUND_DEFAULTS, PlaygroundSection, Settings, SystemSection, classPrefixOf, cssPrefixes, varPrefixOf } from "./entities/system/Settings.js";
28
30
  import { isIdentifier, isReservedWord } from "./framework/utils/identifier.js";
29
31
  import { STYLE_PROP_VALUE_FORMS, STYLE_PROP_VALUE_LEAVES, StyleProperty, classifyStylePropValue, cssPropertyNames, leavesOfStylePropValue, stylePropValueFormOf, stylePropValueSchema, toCssPropertyName } from "./entities/system/StyleProperty.js";
30
- import { createSliceMemo } from "./framework/memo.js";
31
32
  import { UNCONDITIONAL_PREVIEW_KEY, storedPreview, unconditionalPreviewProps } from "./framework/preview-store.js";
32
33
  import { authoredBag, authoredValue, className, cssPropValue, cssVar, cssVarRef, declaredPropDefaults, declaredPropRouting, glyphComponentOf, glyphLibrariesOf, glyphPropsOf, heldLinked, iconToolAxisOptions, iconToolFor, iconToolOf, iconToolsOf, keyedPreviewConditions, linkedVarNaming, memberFromLeaf, memberLeaves, negatedCssValue, opacityPercentage, previewConditionalProps, previewConditions, previewDefaults, previewMatrix, propOwner, propValueDomain, propValueFromAxis, refListOf, renderStyleValue, resolveComponentProps, resolveFieldValue, resolveTokenValue, resolveTokenValueUnder, routedBag, sourceVarPrefix, styleAliasesOf, styleDeclarations, stylePropEntries, stylePropLeafForToken, stylePropNegates, stylePropTokenGroup, stylePropTokenPath, stylePropTokenValues, stylePropValueFromLeaf, stylePropValueLeaves, stylePropValues, stylePropertiesWriting, stylePropertyAccepts, stylePropertyFor, stylePropertyPathFor, validateComponentProps } from "./framework/projections.js";
33
34
  import { codeSlotsOf, forwardClaims, forwardedLayers, intoName, isValueSlot, layerPropRoutes, propApplies, propRegistryRef, renderBindingsOf, routedProp, routedPropIn, routesContent, slotCodeForms, standsInForCode, surfaceProp, surfaceProps } from "./framework/prop-surface.js";
@@ -94,7 +95,6 @@ import { bindStateRef, bindingPath, condArms, condValue, containsMarker, layerPr
94
95
  import { runChangeHooks } from "./framework/change-hooks.js";
95
96
  import { baseOf, changeOf, changeValueAt, changesOf, describeBody, summarizeChanges } from "./framework/changes.js";
96
97
  import { DERIVED_MUTATIONS } from "./framework/derived-mutations.js";
97
- import { resolveInputDir, resolveOutDir, resolveRegistryDir } from "./framework/registry-dir.js";
98
98
  import { inferredRenames } from "./framework/rename-inference.js";
99
99
  import { ConfigSession, memoryConfigSource } from "./framework/session.js";
100
100
  import { EXPORT_MEMBER, packageKey, packageName } from "./framework/utils/package-path.js";
@@ -230,7 +230,12 @@ declare function loadV1Artifact(studio: V1Artifact, options?: LoadV1Options): Co
230
230
  pagesDir: _$zod.ZodOptional<_$zod.ZodString>;
231
231
  port: _$zod.ZodOptional<_$zod.ZodNumber>;
232
232
  }, _$zod_v4_core0.$strict>>;
233
- }, _$zod_v4_core0.$strict>, _$zod.ZodObject<Record<never, never>, _$zod_v4_core0.$strip>, "settings", Record<never, never>, Record<never, never>, true, Record<never, never>, Record<never, never>>;
233
+ }, _$zod_v4_core0.$strict>, _$zod.ZodObject<Record<never, never>, _$zod_v4_core0.$strip>, "settings", Record<never, never>, {
234
+ readonly inputDir: ({
235
+ member,
236
+ config
237
+ }: ComputedInput) => string;
238
+ }, true, Record<never, never>, Record<never, never>>;
234
239
  tokens: Omit<EntityClass<_$zod.ZodObject<{
235
240
  value: _$zod.ZodType<string | number | Ref | ComposedValue, unknown, _$zod_v4_core0.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
236
241
  type: _$zod.ZodOptional<_$zod.ZodString>;