@yahoo/uds-create-config 5.91.4 → 5.91.5
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/system.js +2 -0
- package/dist/entities/system/Component.d.ts +60 -0
- package/dist/entities/system/Component.js +9 -2
- package/dist/framework/Config.d.ts +1 -1
- package/dist/framework/Config.js +1 -1
- package/dist/framework/render-spec.d.ts +68 -2
- package/dist/framework/render-spec.js +181 -9
- package/dist/framework/schema-version.d.ts +1 -1
- package/dist/framework/schema-version.js +5 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/migrations/20261110145811_computed_visibility.d.ts +10 -0
- package/dist/migrations/20261110145811_computed_visibility.js +10 -0
- package/dist/renderer/wrappers/html-aliases.d.ts +5 -3
- package/dist/renderer/wrappers/html-aliases.js +52 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/configs/system.js
CHANGED
|
@@ -47,6 +47,7 @@ import { tokenGetDetailMigration } from "../migrations/20261108042210_token_get_
|
|
|
47
47
|
import { lintRulesByGroupMigration } from "../migrations/20261109144822_lint_rules_by_group.js";
|
|
48
48
|
import { stringPropUniqueIdsMigration } from "../migrations/20261109205852_string_prop_unique_ids.js";
|
|
49
49
|
import { anatomyNodeOverridesMigration } from "../migrations/20261109214535_anatomy_node_overrides.js";
|
|
50
|
+
import { computedVisibilityMigration } from "../migrations/20261110145811_computed_visibility.js";
|
|
50
51
|
import { CanvasRole } from "../entities/system/CanvasRole.js";
|
|
51
52
|
import { GlobalStyle } from "../entities/system/GlobalStyle.js";
|
|
52
53
|
import { Guidance } from "../entities/system/Guidance.js";
|
|
@@ -230,5 +231,6 @@ if (!registeredSchemaMigrations().has(20261108042210)) registerSchemaMigrations(
|
|
|
230
231
|
if (!registeredSchemaMigrations().has(20261109144822)) registerSchemaMigrations(lintRulesByGroupMigration);
|
|
231
232
|
if (!registeredSchemaMigrations().has(20261109205852)) registerSchemaMigrations(stringPropUniqueIdsMigration);
|
|
232
233
|
if (!registeredSchemaMigrations().has(20261109214535)) registerSchemaMigrations(anatomyNodeOverridesMigration);
|
|
234
|
+
if (!registeredSchemaMigrations().has(20261110145811)) registerSchemaMigrations(computedVisibilityMigration);
|
|
233
235
|
//#endregion
|
|
234
236
|
export { System };
|
|
@@ -397,6 +397,16 @@ declare const visibilityDefinition: z.ZodUnion<readonly [z.ZodUnion<readonly [z.
|
|
|
397
397
|
lt: z.ZodOptional<z.ZodNumber>;
|
|
398
398
|
lte: z.ZodOptional<z.ZodNumber>;
|
|
399
399
|
$index: z.ZodLiteral<true>;
|
|
400
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
401
|
+
not: z.ZodOptional<z.ZodLiteral<true>>;
|
|
402
|
+
eq: z.ZodOptional<z.ZodUnknown>;
|
|
403
|
+
neq: z.ZodOptional<z.ZodUnknown>;
|
|
404
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
405
|
+
gte: z.ZodOptional<z.ZodNumber>;
|
|
406
|
+
lt: z.ZodOptional<z.ZodNumber>;
|
|
407
|
+
lte: z.ZodOptional<z.ZodNumber>;
|
|
408
|
+
$computed: z.ZodString;
|
|
409
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
400
410
|
}, z.core.$strict>]>, z.ZodObject<{
|
|
401
411
|
$or: z.ZodArray<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodPipe<z.ZodObject<{
|
|
402
412
|
not: z.ZodOptional<z.ZodLiteral<true>>;
|
|
@@ -443,6 +453,16 @@ declare const visibilityDefinition: z.ZodUnion<readonly [z.ZodUnion<readonly [z.
|
|
|
443
453
|
lt: z.ZodOptional<z.ZodNumber>;
|
|
444
454
|
lte: z.ZodOptional<z.ZodNumber>;
|
|
445
455
|
$index: z.ZodLiteral<true>;
|
|
456
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
457
|
+
not: z.ZodOptional<z.ZodLiteral<true>>;
|
|
458
|
+
eq: z.ZodOptional<z.ZodUnknown>;
|
|
459
|
+
neq: z.ZodOptional<z.ZodUnknown>;
|
|
460
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
461
|
+
gte: z.ZodOptional<z.ZodNumber>;
|
|
462
|
+
lt: z.ZodOptional<z.ZodNumber>;
|
|
463
|
+
lte: z.ZodOptional<z.ZodNumber>;
|
|
464
|
+
$computed: z.ZodString;
|
|
465
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
446
466
|
}, z.core.$strict>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodPipe<z.ZodObject<{
|
|
447
467
|
not: z.ZodOptional<z.ZodLiteral<true>>;
|
|
448
468
|
eq: z.ZodOptional<z.ZodUnknown>;
|
|
@@ -488,6 +508,16 @@ declare const visibilityDefinition: z.ZodUnion<readonly [z.ZodUnion<readonly [z.
|
|
|
488
508
|
lt: z.ZodOptional<z.ZodNumber>;
|
|
489
509
|
lte: z.ZodOptional<z.ZodNumber>;
|
|
490
510
|
$index: z.ZodLiteral<true>;
|
|
511
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
512
|
+
not: z.ZodOptional<z.ZodLiteral<true>>;
|
|
513
|
+
eq: z.ZodOptional<z.ZodUnknown>;
|
|
514
|
+
neq: z.ZodOptional<z.ZodUnknown>;
|
|
515
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
516
|
+
gte: z.ZodOptional<z.ZodNumber>;
|
|
517
|
+
lt: z.ZodOptional<z.ZodNumber>;
|
|
518
|
+
lte: z.ZodOptional<z.ZodNumber>;
|
|
519
|
+
$computed: z.ZodString;
|
|
520
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
491
521
|
}, z.core.$strict>]>>]>>;
|
|
492
522
|
}, z.core.$strict>, z.ZodArray<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodPipe<z.ZodObject<{
|
|
493
523
|
not: z.ZodOptional<z.ZodLiteral<true>>;
|
|
@@ -534,6 +564,16 @@ declare const visibilityDefinition: z.ZodUnion<readonly [z.ZodUnion<readonly [z.
|
|
|
534
564
|
lt: z.ZodOptional<z.ZodNumber>;
|
|
535
565
|
lte: z.ZodOptional<z.ZodNumber>;
|
|
536
566
|
$index: z.ZodLiteral<true>;
|
|
567
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
568
|
+
not: z.ZodOptional<z.ZodLiteral<true>>;
|
|
569
|
+
eq: z.ZodOptional<z.ZodUnknown>;
|
|
570
|
+
neq: z.ZodOptional<z.ZodUnknown>;
|
|
571
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
572
|
+
gte: z.ZodOptional<z.ZodNumber>;
|
|
573
|
+
lt: z.ZodOptional<z.ZodNumber>;
|
|
574
|
+
lte: z.ZodOptional<z.ZodNumber>;
|
|
575
|
+
$computed: z.ZodString;
|
|
576
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
537
577
|
}, z.core.$strict>]>, z.ZodObject<{
|
|
538
578
|
$or: z.ZodArray<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodPipe<z.ZodObject<{
|
|
539
579
|
not: z.ZodOptional<z.ZodLiteral<true>>;
|
|
@@ -580,6 +620,16 @@ declare const visibilityDefinition: z.ZodUnion<readonly [z.ZodUnion<readonly [z.
|
|
|
580
620
|
lt: z.ZodOptional<z.ZodNumber>;
|
|
581
621
|
lte: z.ZodOptional<z.ZodNumber>;
|
|
582
622
|
$index: z.ZodLiteral<true>;
|
|
623
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
624
|
+
not: z.ZodOptional<z.ZodLiteral<true>>;
|
|
625
|
+
eq: z.ZodOptional<z.ZodUnknown>;
|
|
626
|
+
neq: z.ZodOptional<z.ZodUnknown>;
|
|
627
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
628
|
+
gte: z.ZodOptional<z.ZodNumber>;
|
|
629
|
+
lt: z.ZodOptional<z.ZodNumber>;
|
|
630
|
+
lte: z.ZodOptional<z.ZodNumber>;
|
|
631
|
+
$computed: z.ZodString;
|
|
632
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
583
633
|
}, z.core.$strict>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodPipe<z.ZodObject<{
|
|
584
634
|
not: z.ZodOptional<z.ZodLiteral<true>>;
|
|
585
635
|
eq: z.ZodOptional<z.ZodUnknown>;
|
|
@@ -625,6 +675,16 @@ declare const visibilityDefinition: z.ZodUnion<readonly [z.ZodUnion<readonly [z.
|
|
|
625
675
|
lt: z.ZodOptional<z.ZodNumber>;
|
|
626
676
|
lte: z.ZodOptional<z.ZodNumber>;
|
|
627
677
|
$index: z.ZodLiteral<true>;
|
|
678
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
679
|
+
not: z.ZodOptional<z.ZodLiteral<true>>;
|
|
680
|
+
eq: z.ZodOptional<z.ZodUnknown>;
|
|
681
|
+
neq: z.ZodOptional<z.ZodUnknown>;
|
|
682
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
683
|
+
gte: z.ZodOptional<z.ZodNumber>;
|
|
684
|
+
lt: z.ZodOptional<z.ZodNumber>;
|
|
685
|
+
lte: z.ZodOptional<z.ZodNumber>;
|
|
686
|
+
$computed: z.ZodString;
|
|
687
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
628
688
|
}, z.core.$strict>]>>]>>;
|
|
629
689
|
}, z.core.$strict>]>>, z.ZodLiteral<false>, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodObject<{
|
|
630
690
|
__ref: z.ZodString;
|
|
@@ -1360,10 +1360,17 @@ const indexCondition = z.strictObject({
|
|
|
1360
1360
|
...comparisonOperands,
|
|
1361
1361
|
not: z.literal(true).optional()
|
|
1362
1362
|
});
|
|
1363
|
+
const computedCondition = z.strictObject({
|
|
1364
|
+
$computed: z.string(),
|
|
1365
|
+
args: z.record(z.string(), z.unknown()).optional(),
|
|
1366
|
+
...comparisonOperands,
|
|
1367
|
+
not: z.literal(true).optional()
|
|
1368
|
+
});
|
|
1363
1369
|
const singleCondition = z.union([
|
|
1364
1370
|
stateCondition,
|
|
1365
1371
|
itemCondition,
|
|
1366
|
-
indexCondition
|
|
1372
|
+
indexCondition,
|
|
1373
|
+
computedCondition
|
|
1367
1374
|
]);
|
|
1368
1375
|
const orCondition = z.strictObject({ $or: z.array(z.union([singleCondition, z.array(singleCondition)])) });
|
|
1369
1376
|
/**
|
|
@@ -1409,7 +1416,7 @@ const visibility = z.union([
|
|
|
1409
1416
|
z.array(z.union([singleCondition, orCondition])),
|
|
1410
1417
|
z.literal(false),
|
|
1411
1418
|
flatCondition
|
|
1412
|
-
], { error: "a condition is `{ \"$state\": \"<prop>\" }` for a prop that is set, `{ \"$state\": \"<prop>\", \"eq\": \"<value>\" }` for one value of it (`neq`, `gt`, `gte`, `lt`, `lte` and `not: true` also work), `{ \"$or\": [ … ] }` for any of several, a list of conditions that must all hold, or `false` for a position only an interaction shows" });
|
|
1419
|
+
], { error: "a condition is `{ \"$state\": \"<prop>\" }` for a prop that is set, `{ \"$state\": \"<prop>\", \"eq\": \"<value>\" }` for one value of it (`neq`, `gt`, `gte`, `lt`, `lte` and `not: true` also work), `{ \"$computed\": \"<function ref>\", \"args\": { … } }` for a value a function computes, `{ \"$or\": [ … ] }` for any of several, a list of conditions that must all hold, or `false` for a position only an interaction shows" });
|
|
1413
1420
|
/** What an event on a node does to the state model: json-render's own `setState`, its path and the
|
|
1414
1421
|
* value to write, which may itself be a choice on the state (`{ $cond, $then, $else }`). */
|
|
1415
1422
|
const stateAction = z.strictObject({
|
|
@@ -74,7 +74,7 @@ interface RecordedSource {
|
|
|
74
74
|
* The dense-counter `2` a short-lived scheme stamped before the chain existed reads as the mint
|
|
75
75
|
* that replaced it (see `detectedWireVersion`).
|
|
76
76
|
*/
|
|
77
|
-
declare const SERIALIZED_CONFIG_VERSION =
|
|
77
|
+
declare const SERIALIZED_CONFIG_VERSION = 20261110145811;
|
|
78
78
|
interface SerializedConfig {
|
|
79
79
|
/** See {@link SERIALIZED_CONFIG_VERSION}. Always written; a stored artifact may lack it. */
|
|
80
80
|
readonly version: number;
|
package/dist/framework/Config.js
CHANGED
|
@@ -6583,7 +6583,7 @@ var Config = class Config {
|
|
|
6583
6583
|
* links from the provided sources. A declared `linkedKind` with no provided source throws. */
|
|
6584
6584
|
hydrateFrom(stored, options) {
|
|
6585
6585
|
const claimed = schemaVersionOf(stored);
|
|
6586
|
-
if (claimed >
|
|
6586
|
+
if (claimed > 20261110145811) throw new SchemaVersionTooNew(claimed);
|
|
6587
6587
|
const wire = upgradeSerializedConfig(stored);
|
|
6588
6588
|
if (!Array.isArray(wire.ownedKinds) || typeof wire.items !== "object" || wire.items === null) throw new ConfigFormatError(`Config "${stored.name ?? "system-config"}" cannot be hydrated: this is not a serialized config-v2 config (no "ownedKinds"/"items"). A pre-cutover build artifact converts through the registered cutover migration — import the config type's module (e.g. \`configs/system\`) before hydrating.`);
|
|
6589
6589
|
const leftover = wire.options;
|
|
@@ -29,6 +29,13 @@ interface RenderElement {
|
|
|
29
29
|
};
|
|
30
30
|
readonly key?: string;
|
|
31
31
|
};
|
|
32
|
+
/** A node the render writes once per item of a list json-render's `repeat` can't name — one a
|
|
33
|
+
* module-scope function computes — with the arms of the same `.map` sharing `group`. The spec
|
|
34
|
+
* carries one row; {@link unrollRows} writes the rest once the list can be settled. */
|
|
35
|
+
readonly rows?: {
|
|
36
|
+
readonly source: unknown;
|
|
37
|
+
readonly group?: string;
|
|
38
|
+
};
|
|
32
39
|
}
|
|
33
40
|
interface RenderSpec {
|
|
34
41
|
readonly root: string;
|
|
@@ -62,6 +69,40 @@ interface ComputedValue {
|
|
|
62
69
|
/** The functions `$computed` values call, by ref — what a preview bundle registers and an
|
|
63
70
|
* expansion or renderer is handed. */
|
|
64
71
|
type ComputedFunctions = Record<string, ComputedFunction>;
|
|
72
|
+
/**
|
|
73
|
+
* A value the render reads off one of its own painted elements once the browser has laid it out:
|
|
74
|
+
* hook state an effect fills from the layer's size (`offsetWidth`) or its computed style (a custom
|
|
75
|
+
* property a rule sets). `value` is the state's value once read, with `{ $layout }` and `{ $style }`
|
|
76
|
+
* leaves for what the layer's element answers; `initial` is the state the render starts in, which
|
|
77
|
+
* is what paints wherever nothing measures (a server render, a test, an expansion given no
|
|
78
|
+
* `measure`).
|
|
79
|
+
*/
|
|
80
|
+
interface MeasuredValue {
|
|
81
|
+
readonly $measure: string;
|
|
82
|
+
readonly value: unknown;
|
|
83
|
+
readonly initial?: unknown;
|
|
84
|
+
}
|
|
85
|
+
/** One read off a layer's painted element: a size in pixels, or a computed style property. */
|
|
86
|
+
type MeasureRead = {
|
|
87
|
+
readonly $layout: MeasureLayout;
|
|
88
|
+
} | {
|
|
89
|
+
readonly $style: string;
|
|
90
|
+
};
|
|
91
|
+
/** The element sizes a `{ $layout }` leaf reads. */
|
|
92
|
+
declare const MEASURE_LAYOUTS: readonly ["offsetWidth", "offsetHeight", "clientWidth", "clientHeight"];
|
|
93
|
+
type MeasureLayout = (typeof MEASURE_LAYOUTS)[number];
|
|
94
|
+
/** A host's answer for one read: `instance` is the key of the instance whose layer is read. An
|
|
95
|
+
* `undefined` answer (nothing painted yet, an empty style, a zero size) leaves the state at its
|
|
96
|
+
* initial value, as the render's own guards do. */
|
|
97
|
+
type MeasureReader = (request: MeasureRequest) => unknown;
|
|
98
|
+
/** One read a `{ $measure }` asks of a host: the instance's key, the component it is an instance of,
|
|
99
|
+
* and the layer whose element answers. */
|
|
100
|
+
interface MeasureRequest {
|
|
101
|
+
readonly instance: string;
|
|
102
|
+
readonly component: string;
|
|
103
|
+
readonly layer: string;
|
|
104
|
+
readonly read: MeasureRead;
|
|
105
|
+
}
|
|
65
106
|
/** The current item of a repeated node while its row is emitted. */
|
|
66
107
|
interface RepeatRow {
|
|
67
108
|
readonly item: unknown;
|
|
@@ -80,6 +121,14 @@ interface ResolveContext {
|
|
|
80
121
|
* state carries would otherwise read that seed as `undefined` and pick a branch the render never
|
|
81
122
|
* takes. */
|
|
82
123
|
readonly seededOnly?: boolean;
|
|
124
|
+
/** The key of the instance being expanded: what a `{ $id }` is made unique by, and whose layers
|
|
125
|
+
* a `{ $measure }` reads. */
|
|
126
|
+
readonly instance?: string;
|
|
127
|
+
/** The path of the component that instance is of. */
|
|
128
|
+
readonly component?: string;
|
|
129
|
+
/** Reads a layer's painted element for a `{ $measure }`. Absent, every measured value is its
|
|
130
|
+
* initial one. */
|
|
131
|
+
readonly measure?: MeasureReader;
|
|
83
132
|
}
|
|
84
133
|
/**
|
|
85
134
|
* The registry key of an element rendered THROUGH a package factory — `motion.create(Box)`, spelled
|
|
@@ -125,6 +174,17 @@ declare function entryKeyOf(nodes: Record<string, {
|
|
|
125
174
|
* and that was always stated rather than run.
|
|
126
175
|
*/
|
|
127
176
|
declare function deriveSpec(config: Config, path: string): RenderSpec | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* A spec with every `rows` node written once per item of its list, the way `expandSpec` unrolls an
|
|
179
|
+
* instance's anatomy: the arms of one `.map` together, in item order. Each row's tree settles its
|
|
180
|
+
* `$item` and `$index` reads (and anything else `context` can settle) against its own item. The first
|
|
181
|
+
* row keeps the spec's keys, so what addresses a node addresses its first row; row `n` suffixes every
|
|
182
|
+
* key in its tree with `#n`. A list that can't be settled leaves its one row as it is, and an empty
|
|
183
|
+
* one writes no row, as the module renders none.
|
|
184
|
+
*
|
|
185
|
+
* OPEN: a `rows` node inside another one's tree is written once per outer row, not unrolled itself.
|
|
186
|
+
*/
|
|
187
|
+
declare function unrollRows(spec: RenderSpec, state: Record<string, unknown>, context?: ResolveContext): RenderSpec;
|
|
128
188
|
/**
|
|
129
189
|
* The props a spec's actions write — the root of every `setState` path under any element's `on`.
|
|
130
190
|
* These are the props a preview must keep LIVE: their conditions stay for the renderer to judge
|
|
@@ -213,6 +273,9 @@ interface ExpandOptions {
|
|
|
213
273
|
/** The functions `$computed` values call. Absent, a computed value stays on the element for the
|
|
214
274
|
* renderer, and a node repeated over a computed list emits once. */
|
|
215
275
|
readonly functions?: ComputedFunctions;
|
|
276
|
+
/** Reads a layer's painted element for a `{ $measure }` value. Absent, a measured value is the
|
|
277
|
+
* state the render starts in, which is what a render with no layout paints. */
|
|
278
|
+
readonly measure?: MeasureReader;
|
|
216
279
|
}
|
|
217
280
|
interface ExpansionResult {
|
|
218
281
|
readonly spec: RenderSpec;
|
|
@@ -239,7 +302,10 @@ interface ExpansionResult {
|
|
|
239
302
|
*/
|
|
240
303
|
declare function specWithResolvedVisibility(spec: RenderSpec, state: Record<string, unknown>, options?: {
|
|
241
304
|
/** Props the renderer keeps deciding at paint time — a choice reading one is left as it is. */readonly live?: ReadonlySet<string>; /** The functions `$computed` values call; absent, a computed value is left for the renderer. */
|
|
242
|
-
readonly functions?: ComputedFunctions;
|
|
305
|
+
readonly functions?: ComputedFunctions; /** Reads a painted layer for a `$measure`; absent, a measured value is its initial one. */
|
|
306
|
+
readonly measure?: MeasureReader; /** The key the spec's `$id` values are made unique by, and the instance a `$measure` reads. */
|
|
307
|
+
readonly instance?: string; /** The component the spec paints, whose layers a `$measure` reads. */
|
|
308
|
+
readonly component?: string;
|
|
243
309
|
}): RenderSpec;
|
|
244
310
|
/** The comparison a `$state` test can make: json-render's own operator set, minus the state pointer
|
|
245
311
|
* and the `not` modifier. Typed off the library so an operator it adds is a typecheck failure here
|
|
@@ -492,4 +558,4 @@ declare function expandSpec(config: Config, spec: RenderSpec, options?: ExpandOp
|
|
|
492
558
|
*/
|
|
493
559
|
declare function expandComponent(config: Config, path: string, props?: Record<string, unknown>, options?: ExpandOptions): ExpansionResult;
|
|
494
560
|
//#endregion
|
|
495
|
-
export { ANATOMY_MARKER, ComponentSpec, ComponentSpecs, ComputedFunctions, ComputedValue, ExpandOptions, ExpansionResult, MOTION_FACTORY, RenderElement, RenderSpec, RepeatRow, RepeatSpec, ResolveContext, SlotTarget, VisibilityOperator, VisibilityTerm, anatomyElementComponent, anatomyTextProp, boundElementType, componentSpec, deriveSpec, entryKeyOf, expandComponent, expandSpec, instanceSpec, layerTextProp, liveStateProps, previewSpec, propInto, propsIntoLayer, readStatePointer, resolveValue, resolveVisibility, routeOf, routesOf, slotTargetsOf, specWithResolvedVisibility, statePointerProp, valueForwardsOf, visibilityStateProps, visibilityTerms, withoutTruthyTerm, wrappedElementKey };
|
|
561
|
+
export { ANATOMY_MARKER, ComponentSpec, ComponentSpecs, ComputedFunctions, ComputedValue, ExpandOptions, ExpansionResult, MEASURE_LAYOUTS, MOTION_FACTORY, MeasureLayout, MeasureRead, MeasureReader, MeasureRequest, MeasuredValue, RenderElement, RenderSpec, RepeatRow, RepeatSpec, ResolveContext, SlotTarget, VisibilityOperator, VisibilityTerm, anatomyElementComponent, anatomyTextProp, boundElementType, componentSpec, deriveSpec, entryKeyOf, expandComponent, expandSpec, instanceSpec, layerTextProp, liveStateProps, previewSpec, propInto, propsIntoLayer, readStatePointer, resolveValue, resolveVisibility, routeOf, routesOf, slotTargetsOf, specWithResolvedVisibility, statePointerProp, unrollRows, valueForwardsOf, visibilityStateProps, visibilityTerms, withoutTruthyTerm, wrappedElementKey };
|
|
@@ -13,6 +13,13 @@ import { graftPreviewElements } from "../spec/preview-elements.js";
|
|
|
13
13
|
import { conditionHolds } from "./layer-styles.js";
|
|
14
14
|
import { componentLayerClass, componentPropClasses, componentRuleClasses, componentStateAttributes, forcedModifierAttributes, layerJsMotionPresets, layerRoutedProps, splitStyleProps, styleRuleMotionClasses } from "./class-names.js";
|
|
15
15
|
//#region src/framework/render-spec.ts
|
|
16
|
+
/** The element sizes a `{ $layout }` leaf reads. */
|
|
17
|
+
const MEASURE_LAYOUTS = [
|
|
18
|
+
"offsetWidth",
|
|
19
|
+
"offsetHeight",
|
|
20
|
+
"clientWidth",
|
|
21
|
+
"clientHeight"
|
|
22
|
+
];
|
|
16
23
|
/** A repeat source that is one prop binding: `{ "$state": "/stops" }`, settled by the cell alone. */
|
|
17
24
|
function isStateSource(source) {
|
|
18
25
|
return typeof source === "object" && source !== null && "$state" in source && Object.keys(source).length === 1;
|
|
@@ -270,12 +277,120 @@ function projectSpec(config, path) {
|
|
|
270
277
|
};
|
|
271
278
|
}
|
|
272
279
|
repeatParents(anatomy, elements);
|
|
280
|
+
computedRows(anatomy, elements);
|
|
273
281
|
return {
|
|
274
282
|
root: entryKeyOf(elements),
|
|
275
283
|
elements
|
|
276
284
|
};
|
|
277
285
|
}
|
|
278
286
|
/**
|
|
287
|
+
* A node repeated over a list json-render can't repeat, which keeps its source as `rows` so
|
|
288
|
+
* {@link unrollRows} can write a row per item. A parent `repeatParents` gave a json-render repeat
|
|
289
|
+
* already renders its children per item, so those children carry nothing.
|
|
290
|
+
*/
|
|
291
|
+
function computedRows(anatomy, elements) {
|
|
292
|
+
const repeatedByParent = /* @__PURE__ */ new Set();
|
|
293
|
+
for (const element of Object.values(elements)) {
|
|
294
|
+
if (element.repeat === void 0) continue;
|
|
295
|
+
for (const child of element.children ?? []) repeatedByParent.add(child);
|
|
296
|
+
}
|
|
297
|
+
for (const [key, node] of Object.entries(anatomy)) {
|
|
298
|
+
const repeat = node?.repeat;
|
|
299
|
+
const element = elements[key];
|
|
300
|
+
if (!repeat || !element || repeatedByParent.has(key)) continue;
|
|
301
|
+
elements[key] = {
|
|
302
|
+
...element,
|
|
303
|
+
rows: {
|
|
304
|
+
source: repeat.source,
|
|
305
|
+
...repeat.group !== void 0 ? { group: repeat.group } : {}
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* A spec with every `rows` node written once per item of its list, the way `expandSpec` unrolls an
|
|
312
|
+
* instance's anatomy: the arms of one `.map` together, in item order. Each row's tree settles its
|
|
313
|
+
* `$item` and `$index` reads (and anything else `context` can settle) against its own item. The first
|
|
314
|
+
* row keeps the spec's keys, so what addresses a node addresses its first row; row `n` suffixes every
|
|
315
|
+
* key in its tree with `#n`. A list that can't be settled leaves its one row as it is, and an empty
|
|
316
|
+
* one writes no row, as the module renders none.
|
|
317
|
+
*
|
|
318
|
+
* OPEN: a `rows` node inside another one's tree is written once per outer row, not unrolled itself.
|
|
319
|
+
*/
|
|
320
|
+
function unrollRows(spec, state, context = {}) {
|
|
321
|
+
if (!Object.values(spec.elements).some((element) => element.rows)) return spec;
|
|
322
|
+
const elements = { ...spec.elements };
|
|
323
|
+
const copyRow = (key, suffix, row) => {
|
|
324
|
+
const element = spec.elements[key];
|
|
325
|
+
if (!element) return key;
|
|
326
|
+
const rowKey = `${key}${suffix}`;
|
|
327
|
+
const settling = {
|
|
328
|
+
...context,
|
|
329
|
+
row
|
|
330
|
+
};
|
|
331
|
+
const props = {};
|
|
332
|
+
for (const [name, value] of Object.entries(element.props ?? {})) props[name] = resolveValue(value, state, settling);
|
|
333
|
+
const visible = element.visible === void 0 ? void 0 : resolveVisibility(element.visible, state, settling) ?? element.visible;
|
|
334
|
+
const children = element.children?.map((child) => copyRow(child, suffix, row));
|
|
335
|
+
const slots = element.slots ? Object.fromEntries(Object.entries(element.slots).map(([name, fills]) => [name, fills.map((fill) => copyRow(fill, suffix, row))])) : void 0;
|
|
336
|
+
const { rows: _rows, ...rest } = element;
|
|
337
|
+
elements[rowKey] = {
|
|
338
|
+
...rest,
|
|
339
|
+
...element.props ? { props } : {},
|
|
340
|
+
...visible !== void 0 ? { visible } : {},
|
|
341
|
+
...children ? { children } : {},
|
|
342
|
+
...slots ? { slots } : {}
|
|
343
|
+
};
|
|
344
|
+
return rowKey;
|
|
345
|
+
};
|
|
346
|
+
const unrolled = (keys) => {
|
|
347
|
+
const out = [];
|
|
348
|
+
for (let at = 0; at < keys.length;) {
|
|
349
|
+
const rows = spec.elements[keys[at] ?? ""]?.rows;
|
|
350
|
+
if (!rows) {
|
|
351
|
+
out.push(keys[at]);
|
|
352
|
+
at += 1;
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
const arms = [];
|
|
356
|
+
while (at < keys.length) {
|
|
357
|
+
const arm = spec.elements[keys[at] ?? ""]?.rows;
|
|
358
|
+
if (!arm || arm.group !== rows.group || arms.length > 0 && rows.group === void 0) break;
|
|
359
|
+
arms.push(keys[at]);
|
|
360
|
+
at += 1;
|
|
361
|
+
}
|
|
362
|
+
const list = resolveValue(rows.source, state, {
|
|
363
|
+
...context,
|
|
364
|
+
settle: true
|
|
365
|
+
});
|
|
366
|
+
if (!Array.isArray(list)) {
|
|
367
|
+
out.push(...arms);
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
for (const arm of arms) delete elements[arm];
|
|
371
|
+
list.forEach((item, index) => {
|
|
372
|
+
const suffix = index === 0 ? "" : `#${index + 1}`;
|
|
373
|
+
for (const arm of arms) out.push(copyRow(arm, suffix, {
|
|
374
|
+
item,
|
|
375
|
+
index
|
|
376
|
+
}));
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
return out;
|
|
380
|
+
};
|
|
381
|
+
for (const [key, element] of Object.entries(spec.elements)) {
|
|
382
|
+
if (!element.children?.some((child) => spec.elements[child]?.rows)) continue;
|
|
383
|
+
elements[key] = {
|
|
384
|
+
...elements[key] ?? element,
|
|
385
|
+
children: unrolled(element.children)
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
return {
|
|
389
|
+
...spec,
|
|
390
|
+
elements
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
279
394
|
* A node the render writes once per item of a prop's list, as json-render repeats it: the parent
|
|
280
395
|
* carries `repeat: { statePath }` and renders its children once per item, each inside the scope
|
|
281
396
|
* `$item` and `$index` read from, so the matrix unrolls the preview's list the way the module does.
|
|
@@ -463,7 +578,12 @@ function specWithResolvedVisibility(spec, state, options = {}) {
|
|
|
463
578
|
let changed = false;
|
|
464
579
|
const elements = {};
|
|
465
580
|
const live = options.live;
|
|
466
|
-
const context = {
|
|
581
|
+
const context = {
|
|
582
|
+
functions: options.functions,
|
|
583
|
+
measure: options.measure,
|
|
584
|
+
instance: options.instance,
|
|
585
|
+
component: options.component
|
|
586
|
+
};
|
|
467
587
|
for (const [key, element] of Object.entries(spec.elements)) {
|
|
468
588
|
const resolved = element.visible === void 0 ? void 0 : resolveVisibility(element.visible, state, context);
|
|
469
589
|
let props = element.props;
|
|
@@ -643,6 +763,17 @@ function readBinding(test, state, context) {
|
|
|
643
763
|
return item !== null && typeof item === "object" ? readStatePointer(item, test.$item) : void 0;
|
|
644
764
|
}
|
|
645
765
|
if (test.$index === true) return context.row ? context.row.index : UNREADABLE;
|
|
766
|
+
if (typeof test.$computed === "string") {
|
|
767
|
+
const { $computed, args } = test;
|
|
768
|
+
const value = resolveValue({
|
|
769
|
+
$computed,
|
|
770
|
+
args
|
|
771
|
+
}, state, {
|
|
772
|
+
...context,
|
|
773
|
+
settle: true
|
|
774
|
+
});
|
|
775
|
+
return isExpression(value) ? UNREADABLE : value;
|
|
776
|
+
}
|
|
646
777
|
return UNREADABLE;
|
|
647
778
|
}
|
|
648
779
|
/** The keys that make a record one of json-render's expressions rather than a settled value. */
|
|
@@ -652,7 +783,8 @@ const EXPRESSION_KEYS = new Set([
|
|
|
652
783
|
"$index",
|
|
653
784
|
"$cond",
|
|
654
785
|
"$computed",
|
|
655
|
-
"$template"
|
|
786
|
+
"$template",
|
|
787
|
+
"$id"
|
|
656
788
|
]);
|
|
657
789
|
/** Whether a value is still one of json-render's expressions rather than a settled value. */
|
|
658
790
|
function isExpression(value) {
|
|
@@ -661,6 +793,40 @@ function isExpression(value) {
|
|
|
661
793
|
return false;
|
|
662
794
|
}
|
|
663
795
|
const NO_ARGS = {};
|
|
796
|
+
/** An id unique to one instance, from the name the render gave it (`useId()` in a local): every
|
|
797
|
+
* character an id reference (`url(#…)`) can't carry becomes `-`. */
|
|
798
|
+
function instanceId(instance, name) {
|
|
799
|
+
return `uds-${instance}-${name}`.replace(/[^A-Za-z0-9_-]/g, "-");
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* A `{ $measure }` settled: its `value` with every `{ $layout }` and `{ $style }` leaf read off the
|
|
803
|
+
* instance's layer, or its `initial` while any read has no answer, including when nothing measures.
|
|
804
|
+
*/
|
|
805
|
+
function measuredValue(record, state, context) {
|
|
806
|
+
const initial = () => resolveValue(record.initial, state, context);
|
|
807
|
+
const { measure, instance, component } = context;
|
|
808
|
+
const layer = record.$measure;
|
|
809
|
+
if (!measure || instance === void 0 || component === void 0 || typeof layer !== "string") return initial();
|
|
810
|
+
let unanswered = false;
|
|
811
|
+
const read = (value) => {
|
|
812
|
+
if (typeof value !== "object" || value === null) return value;
|
|
813
|
+
if (Array.isArray(value)) return value.map(read);
|
|
814
|
+
const leaf = value;
|
|
815
|
+
if (typeof leaf.$layout === "string" || typeof leaf.$style === "string") {
|
|
816
|
+
const answer = measure({
|
|
817
|
+
instance,
|
|
818
|
+
component,
|
|
819
|
+
layer,
|
|
820
|
+
read: leaf
|
|
821
|
+
});
|
|
822
|
+
if (answer === void 0) unanswered = true;
|
|
823
|
+
return answer;
|
|
824
|
+
}
|
|
825
|
+
return Object.fromEntries(Object.entries(leaf).map(([key, member]) => [key, read(member)]));
|
|
826
|
+
};
|
|
827
|
+
const measured = read(record.value);
|
|
828
|
+
return unanswered ? initial() : resolveValue(measured, state, context);
|
|
829
|
+
}
|
|
664
830
|
/**
|
|
665
831
|
* A value settled against a prop bag as far as this reader can: a `$state` reads the bag, `$item`
|
|
666
832
|
* and `$index` the current row, `$cond` picks its arm, `$computed` calls its function when the
|
|
@@ -695,6 +861,8 @@ function resolveValue(value, state, context = {}) {
|
|
|
695
861
|
for (const key in args) if (isExpression(args[key])) return value;
|
|
696
862
|
return fn(args);
|
|
697
863
|
}
|
|
864
|
+
if (typeof record.$measure === "string") return measuredValue(record, state, context);
|
|
865
|
+
if (typeof record.$id === "string") return context.instance === void 0 ? value : instanceId(context.instance, record.$id);
|
|
698
866
|
if ("$template" in record) return value;
|
|
699
867
|
if (typeof record.$state === "string" || typeof record.$item === "string" || record.$index === true) {
|
|
700
868
|
if (Object.keys(record).length === 1) {
|
|
@@ -1391,11 +1559,17 @@ function expandInstance(sink, path, instanceProps, content, hint, instanceSlots)
|
|
|
1391
1559
|
const placed = emit(key, `${keyHint}•${key}`, row);
|
|
1392
1560
|
return placed ? [placed] : [];
|
|
1393
1561
|
};
|
|
1562
|
+
const settling = (row) => ({
|
|
1563
|
+
functions: sink.functions,
|
|
1564
|
+
row,
|
|
1565
|
+
instance: hint,
|
|
1566
|
+
component: path,
|
|
1567
|
+
measure: sink.measure
|
|
1568
|
+
});
|
|
1394
1569
|
const emitRepeated = (keys, keyHint, row) => {
|
|
1395
1570
|
const source = anatomy[keys[0] ?? ""]?.repeat?.source;
|
|
1396
1571
|
const list = resolveValue(source, state, {
|
|
1397
|
-
|
|
1398
|
-
row,
|
|
1572
|
+
...settling(row),
|
|
1399
1573
|
settle: true
|
|
1400
1574
|
});
|
|
1401
1575
|
if (!Array.isArray(list)) {
|
|
@@ -1432,10 +1606,7 @@ function expandInstance(sink, path, instanceProps, content, hint, instanceSlots)
|
|
|
1432
1606
|
};
|
|
1433
1607
|
const emitKeys = (keys, keyHint, row) => repeatGroups(keys).flatMap((group) => anatomy[group[0] ?? ""]?.repeat ? emitRepeated(group, keyHint, row) : emitOne(group[0] ?? "", keyHint, row));
|
|
1434
1608
|
const emitNode = (key, node, keyHint, row) => {
|
|
1435
|
-
const resolving =
|
|
1436
|
-
functions: sink.functions,
|
|
1437
|
-
row
|
|
1438
|
-
};
|
|
1609
|
+
const resolving = settling(row);
|
|
1439
1610
|
const visible = resolveVisibility(node.visible, state, resolving);
|
|
1440
1611
|
const layer = layerOf(node.element);
|
|
1441
1612
|
const isRoot = key === hostNode;
|
|
@@ -1587,6 +1758,7 @@ function expandSpec(config, spec, options = {}) {
|
|
|
1587
1758
|
config,
|
|
1588
1759
|
rendered: options.rendered,
|
|
1589
1760
|
functions: options.functions,
|
|
1761
|
+
measure: options.measure,
|
|
1590
1762
|
elements: {},
|
|
1591
1763
|
unresolved: /* @__PURE__ */ new Set(),
|
|
1592
1764
|
expanding: []
|
|
@@ -1655,4 +1827,4 @@ function withoutKey(record, key) {
|
|
|
1655
1827
|
return rest;
|
|
1656
1828
|
}
|
|
1657
1829
|
//#endregion
|
|
1658
|
-
export { ANATOMY_MARKER, MOTION_FACTORY, anatomyElementComponent, anatomyTextProp, andListOf, boundElementType, componentSpec, deriveSpec, entryKeyOf, expandComponent, expandSpec, instanceSpec, isExpression, layerTextProp, liveStateProps, previewSpec, propInto, propsIntoLayer, readStatePointer, resolveValue, resolveVisibility, routeOf, routesOf, slotAnatomyPropOf, slotTargetsOf, specWithResolvedVisibility, spelled, statePointerProp, valueForwardsOf, visibilityStateProps, visibilityTerms, withoutTruthyTerm, wrappedElementKey };
|
|
1830
|
+
export { ANATOMY_MARKER, MEASURE_LAYOUTS, MOTION_FACTORY, anatomyElementComponent, anatomyTextProp, andListOf, boundElementType, componentSpec, deriveSpec, entryKeyOf, expandComponent, expandSpec, instanceSpec, isExpression, layerTextProp, liveStateProps, previewSpec, propInto, propsIntoLayer, readStatePointer, resolveValue, resolveVisibility, routeOf, routesOf, slotAnatomyPropOf, slotTargetsOf, specWithResolvedVisibility, spelled, statePointerProp, unrollRows, valueForwardsOf, visibilityStateProps, visibilityTerms, withoutTruthyTerm, wrappedElementKey };
|
|
@@ -15,7 +15,7 @@ import { Patch, SerializedConfig } from "./Config.js";
|
|
|
15
15
|
* sets this constant to its own older timestamp; the merge ref then carries a registered migration
|
|
16
16
|
* newer than the constant, and the assertion fails until the author re-mints.
|
|
17
17
|
*/
|
|
18
|
-
declare const CURRENT_SCHEMA_VERSION =
|
|
18
|
+
declare const CURRENT_SCHEMA_VERSION = 20261110145811;
|
|
19
19
|
/** What the walkers need to see of an envelope — loose on purpose, so a typed `SerializedConfig`
|
|
20
20
|
* and a raw old-shape record both flow in without casts. */
|
|
21
21
|
interface VersionStamped {
|
|
@@ -13,7 +13,7 @@ import { ConfigFormatError } from "./rejection.js";
|
|
|
13
13
|
* sets this constant to its own older timestamp; the merge ref then carries a registered migration
|
|
14
14
|
* newer than the constant, and the assertion fails until the author re-mints.
|
|
15
15
|
*/
|
|
16
|
-
const CURRENT_SCHEMA_VERSION =
|
|
16
|
+
const CURRENT_SCHEMA_VERSION = 20261110145811;
|
|
17
17
|
/** The mint that moved `options` into the `settings` kind — restated here, rather than imported
|
|
18
18
|
* from the migration that owns it, because that migration imports this module. */
|
|
19
19
|
const SETTINGS_AS_KIND_VERSION = 20260908171448;
|
|
@@ -45,7 +45,7 @@ function registerSchemaMigrations(...migrations) {
|
|
|
45
45
|
for (const migration of migrations) {
|
|
46
46
|
if (migration.version !== 1 && !isMintTimestamp(migration.version)) throw new Error(`Schema migration version ${migration.version} is not a mint timestamp — mint one with \`date +%Y%m%d%H%M%S\`, like a supabase migration.`);
|
|
47
47
|
if (REGISTERED.has(migration.version)) throw new Error(`A schema migration at version ${migration.version} is already registered.`);
|
|
48
|
-
if (migration.version >
|
|
48
|
+
if (migration.version > 20261110145811) throw new Error(`Schema migration ${migration.version} is newer than CURRENT_SCHEMA_VERSION (${CURRENT_SCHEMA_VERSION}) — a stale branch merged, or the mint forgot to bump the constant. Re-mint: set CURRENT_SCHEMA_VERSION to the newest migration version.`);
|
|
49
49
|
REGISTERED.set(migration.version, migration);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -102,7 +102,7 @@ function pendingFor(version, target, options) {
|
|
|
102
102
|
* Already-current input passes through untouched — same reference, so hot paths pay nothing.
|
|
103
103
|
*/
|
|
104
104
|
function upgradeSerializedConfig(json, options) {
|
|
105
|
-
const target = options?.target ??
|
|
105
|
+
const target = options?.target ?? 20261110145811;
|
|
106
106
|
const version = detectedWireVersion(json);
|
|
107
107
|
if (version > target) throw new SchemaVersionTooNew(version, target);
|
|
108
108
|
const raw = json;
|
|
@@ -160,7 +160,7 @@ function upgradedSources(json, options) {
|
|
|
160
160
|
* meaning under the current schema and replay skips it — reported by the caller, not swallowed here.
|
|
161
161
|
*/
|
|
162
162
|
function upgradePatch(patch, writtenAt, options) {
|
|
163
|
-
const target = options?.target ??
|
|
163
|
+
const target = options?.target ?? 20261110145811;
|
|
164
164
|
if (writtenAt > target) throw new SchemaVersionTooNew(writtenAt, target);
|
|
165
165
|
let current = patch;
|
|
166
166
|
for (const migration of pendingFor(writtenAt, target, options)) {
|
|
@@ -179,7 +179,7 @@ function upgradePatch(patch, writtenAt, options) {
|
|
|
179
179
|
* stamp would cause.
|
|
180
180
|
*/
|
|
181
181
|
function upgradeDraftEntries(draft, options) {
|
|
182
|
-
const target = options?.target ??
|
|
182
|
+
const target = options?.target ?? 20261110145811;
|
|
183
183
|
const entries = [];
|
|
184
184
|
const held = [];
|
|
185
185
|
const retired = [];
|