@yahoo/uds-create-config 5.108.3 → 5.108.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.
|
@@ -4,7 +4,7 @@ import { createSliceMemo } from "../../framework/memo.js";
|
|
|
4
4
|
import { moduleViewOf, registerModuleView } from "../../framework/module-views.js";
|
|
5
5
|
import { File } from "./File.js";
|
|
6
6
|
import { Settings, classPrefixOf, prefixed, varPrefixOf } from "./Settings.js";
|
|
7
|
-
import { sourceVarPrefix } from "../../framework/projections.js";
|
|
7
|
+
import { heldLinked, sourceVarPrefix } from "../../framework/projections.js";
|
|
8
8
|
import { hasJsMotion } from "./motion-presets.js";
|
|
9
9
|
import { stylePropClassBase, stylePropOwnClasses } from "../../framework/class-names.js";
|
|
10
10
|
import { Component } from "./Component.js";
|
|
@@ -526,6 +526,21 @@ function linkedComponentModule(config, componentPathOrRef) {
|
|
|
526
526
|
const asked = typeof componentPathOrRef === "string" ? componentPathOrRef : componentPathOrRef.__ref;
|
|
527
527
|
const parsed = asked.includes(":") ? splitRef(asked) : void 0;
|
|
528
528
|
const askedSource = parsed?.kind === "component" ? parsed.source : void 0;
|
|
529
|
+
const row = askedSource !== void 0 && parsed !== void 0 ? heldRow({
|
|
530
|
+
config,
|
|
531
|
+
slug: askedSource,
|
|
532
|
+
path: parsed.path
|
|
533
|
+
}) : void 0;
|
|
534
|
+
if (row !== void 0) {
|
|
535
|
+
const held = linkedComponentModule(config, row);
|
|
536
|
+
return held && {
|
|
537
|
+
...held,
|
|
538
|
+
source: {
|
|
539
|
+
...held.source,
|
|
540
|
+
componentRef: asked
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
}
|
|
529
544
|
const ref = splitRef(file.__ref);
|
|
530
545
|
const slug = ref.source ?? askedSource;
|
|
531
546
|
if (!slug) return void 0;
|
|
@@ -556,6 +571,38 @@ function linkedComponentModule(config, componentPathOrRef) {
|
|
|
556
571
|
};
|
|
557
572
|
}
|
|
558
573
|
/**
|
|
574
|
+
* The row of this config's that holds `slug`'s component at `path` ({@link heldLinked}), or
|
|
575
|
+
* `undefined` when there's none. Every route the stylesheet emits the component through and that ends
|
|
576
|
+
* at `slug` (`bridge~yos` for `yos`) has to be held by a row, since the stylesheet emits the pin's
|
|
577
|
+
* rules for a route that doesn't hold it. Where routes are held by different rows, the first route's
|
|
578
|
+
* row answers.
|
|
579
|
+
*/
|
|
580
|
+
function heldRow({ config, slug, path }) {
|
|
581
|
+
let first;
|
|
582
|
+
for (const [route, paths] of reachedComponents(config)) {
|
|
583
|
+
if (route !== slug && sourceHops(route).at(-1) !== slug) continue;
|
|
584
|
+
if (!paths.has(path)) continue;
|
|
585
|
+
const row = heldLinked({
|
|
586
|
+
config,
|
|
587
|
+
slug: route,
|
|
588
|
+
kind: Component.kind
|
|
589
|
+
}).get(path);
|
|
590
|
+
if (row === void 0) return void 0;
|
|
591
|
+
first ??= row;
|
|
592
|
+
}
|
|
593
|
+
return first;
|
|
594
|
+
}
|
|
595
|
+
const reachedComponentsCache = /* @__PURE__ */ new WeakMap();
|
|
596
|
+
/** Each slug the stylesheet emits linked components for (`reachedSlugs`), with the paths of the
|
|
597
|
+
* components it reaches through it. */
|
|
598
|
+
function reachedComponents(config) {
|
|
599
|
+
const cached = reachedComponentsCache.get(config);
|
|
600
|
+
if (cached) return cached;
|
|
601
|
+
const reached = new Map(config.reachedSlugs().filter((route) => config.drawnSourceFor(route) !== void 0).map((route) => [route, new Set(config.sourceClosure(route, Component.kind).map(pathOf))]));
|
|
602
|
+
reachedComponentsCache.set(config, reached);
|
|
603
|
+
return reached;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
559
606
|
* The published identity a slug is pinned at, looked for through the chain: `yos` is declared by the
|
|
560
607
|
* bridge this config links, not by this config.
|
|
561
608
|
*/
|
|
@@ -2107,6 +2107,9 @@ declare class Config {
|
|
|
2107
2107
|
* attribution and upgrade detection. Breaking a link is deleting the pin, once nothing refers
|
|
2108
2108
|
* through it.
|
|
2109
2109
|
*
|
|
2110
|
+
* `keepIdentityRefs` and `keepPointers` leave some sourced refs in place. `toJSON` records the closure
|
|
2111
|
+
* they reach, so the serialized result still loads with no sources attached.
|
|
2112
|
+
*
|
|
2110
2113
|
* Local refs are untouched — the point is to remove dependence on other systems, not to flatten this
|
|
2111
2114
|
* one into literals.
|
|
2112
2115
|
*/
|
|
@@ -2129,13 +2132,17 @@ declare class Config {
|
|
|
2129
2132
|
* makes a dissolve an ordinary recorded edit, so it survives being replayed. */
|
|
2130
2133
|
withMaterializedExtensions({
|
|
2131
2134
|
slug,
|
|
2132
|
-
only
|
|
2135
|
+
only,
|
|
2136
|
+
keepPointers
|
|
2133
2137
|
}?: {
|
|
2134
2138
|
slug?: string;
|
|
2135
2139
|
only?: {
|
|
2136
2140
|
kind: string;
|
|
2137
2141
|
path: string;
|
|
2138
2142
|
};
|
|
2143
|
+
/** Leaves an extension as it is when its source has the entity it points at
|
|
2144
|
+
* (`InlineOptions.keepPointers`). */
|
|
2145
|
+
keepPointers?: boolean;
|
|
2139
2146
|
}): this;
|
|
2140
2147
|
/**
|
|
2141
2148
|
* The config a ref resolves in — this one for a local ref or a ref qualified with this config's own
|
package/dist/framework/Config.js
CHANGED
|
@@ -4366,6 +4366,9 @@ var Config = class Config {
|
|
|
4366
4366
|
* attribution and upgrade detection. Breaking a link is deleting the pin, once nothing refers
|
|
4367
4367
|
* through it.
|
|
4368
4368
|
*
|
|
4369
|
+
* `keepIdentityRefs` and `keepPointers` leave some sourced refs in place. `toJSON` records the closure
|
|
4370
|
+
* they reach, so the serialized result still loads with no sources attached.
|
|
4371
|
+
*
|
|
4369
4372
|
* Local refs are untouched — the point is to remove dependence on other systems, not to flatten this
|
|
4370
4373
|
* one into literals.
|
|
4371
4374
|
*/
|
|
@@ -4388,7 +4391,7 @@ var Config = class Config {
|
|
|
4388
4391
|
* flattening `update` onto the envelope it was supposed to have removed, put the value back inside
|
|
4389
4392
|
* `extend`, and then refuse to drop the pin because the extension still referenced it. `replace`
|
|
4390
4393
|
* makes a dissolve an ordinary recorded edit, so it survives being replayed. */
|
|
4391
|
-
withMaterializedExtensions({ slug, only } = {}) {
|
|
4394
|
+
withMaterializedExtensions({ slug, only, keepPointers } = {}) {
|
|
4392
4395
|
const patches = [];
|
|
4393
4396
|
for (const kind of this.ownedKinds()) {
|
|
4394
4397
|
if (only !== void 0 && only.kind !== kind) continue;
|
|
@@ -4399,6 +4402,7 @@ var Config = class Config {
|
|
|
4399
4402
|
if (!isExtendedRef(extension)) continue;
|
|
4400
4403
|
if (slug !== void 0 && sourceOf(extension) !== slug) continue;
|
|
4401
4404
|
if (only === void 0 && sourceOf(extension) === void 0) continue;
|
|
4405
|
+
if (keepPointers && this.resolveRef({ __ref: extension.__ref })) continue;
|
|
4402
4406
|
const resolved = this.resolveExtension({
|
|
4403
4407
|
kind,
|
|
4404
4408
|
path,
|
|
@@ -6204,9 +6208,10 @@ var Config = class Config {
|
|
|
6204
6208
|
const path = pathOf(target);
|
|
6205
6209
|
const entity = source.resolve(kind, path);
|
|
6206
6210
|
if (!entity) continue;
|
|
6211
|
+
const pointer = source.borrowedFrom(kind, path) === void 0 ? void 0 : source.storedBody(kind, path);
|
|
6207
6212
|
kinds.add(kind);
|
|
6208
6213
|
items[kind] ??= {};
|
|
6209
|
-
items[kind][path] = entity.toJSON();
|
|
6214
|
+
items[kind][path] = pointer ?? entity.toJSON();
|
|
6210
6215
|
}
|
|
6211
6216
|
const settings = source.resolve("settings", "settings");
|
|
6212
6217
|
if (settings && source.ownedKinds().includes("settings")) {
|
|
@@ -29,6 +29,13 @@ import { Ref } from "./utils/refs.js";
|
|
|
29
29
|
*/
|
|
30
30
|
interface InlineOptions {
|
|
31
31
|
readonly keepIdentityRefs?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* A row or folder stored as a pointer at an entity an attached source has stays that pointer, and
|
|
34
|
+
* only its delta is walked. A reader that keeps the sources attached sets it, so the config still
|
|
35
|
+
* says which of its rows are another system's (`heldLinked`) and a route through it draws as the
|
|
36
|
+
* config does. Any other pointer is materialized, or refused, as it would be without this.
|
|
37
|
+
*/
|
|
38
|
+
readonly keepPointers?: boolean;
|
|
32
39
|
/**
|
|
33
40
|
* Called for a ref that can be neither inlined nor requalified, in place of the refusal. The ref is
|
|
34
41
|
* left as it is so the walk reaches every other ref. A plan sets this to name every such ref rather
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MINTED, collectRefs, entityRefOf, isRef, kindOf, pathOf, ref, rewriteRefs, sourceOf } from "./utils/refs.js";
|
|
1
|
+
import { MINTED, collectRefs, entityRefOf, isExtendedRef, isRef, kindOf, pathOf, ref, rewriteRefs, sourceOf } from "./utils/refs.js";
|
|
2
2
|
import { rejectData } from "./rejection.js";
|
|
3
3
|
import { kindBorrowable } from "./registry.js";
|
|
4
4
|
//#region src/framework/inline-sources.ts
|
|
@@ -249,6 +249,14 @@ function rewrittenBody({ body, kind, config, slug, options }) {
|
|
|
249
249
|
});
|
|
250
250
|
return sameBody(body, inlined) ? void 0 : inlined;
|
|
251
251
|
}
|
|
252
|
+
/** The stored pointer at `kind:path` when {@link InlineOptions.keepPointers} keeps it: one into a
|
|
253
|
+
* source this walk takes, at an entity that source has. */
|
|
254
|
+
function keptPointer({ config, kind, path, slug, options }) {
|
|
255
|
+
if (!options?.keepPointers) return void 0;
|
|
256
|
+
const stored = config.storedBody(kind, path);
|
|
257
|
+
if (!isExtendedRef(stored) || !wants(stored, slug)) return void 0;
|
|
258
|
+
return config.resolveRef({ __ref: stored.__ref }) ? stored : void 0;
|
|
259
|
+
}
|
|
252
260
|
/**
|
|
253
261
|
* Every item and group body of `config`, rewritten by {@link inlineSourcedRefs}.
|
|
254
262
|
*
|
|
@@ -257,8 +265,8 @@ function rewrittenBody({ body, kind, config, slug, options }) {
|
|
|
257
265
|
* the pin's own `delete`, once nothing refers through it.
|
|
258
266
|
*
|
|
259
267
|
* Groups are walked as well as items. A group body carries fields like any entity, so a ref hiding in
|
|
260
|
-
* one would otherwise survive a walk that only visited items
|
|
261
|
-
*
|
|
268
|
+
* one would otherwise survive a walk that only visited items. What does survive is what the options
|
|
269
|
+
* keep: an identity ref (`keepIdentityRefs`) and a pointer row or folder (`keepPointers`).
|
|
262
270
|
*/
|
|
263
271
|
/**
|
|
264
272
|
* Where each thing borrowed through `slug` will live once the pin is gone — `style-property:bg@ds` →
|
|
@@ -328,11 +336,36 @@ function inlineAllSources(config, slug, options) {
|
|
|
328
336
|
});
|
|
329
337
|
}
|
|
330
338
|
}
|
|
331
|
-
const materialized = config.applyAll(detaching).withMaterializedExtensions({
|
|
339
|
+
const materialized = config.applyAll(detaching).withMaterializedExtensions({
|
|
340
|
+
slug,
|
|
341
|
+
keepPointers: options?.keepPointers
|
|
342
|
+
});
|
|
332
343
|
const rewrites = [];
|
|
333
344
|
for (const kind of materialized.ownedKinds()) {
|
|
334
345
|
if (materialized.entityOf(kind)?.sourceIdentity) continue;
|
|
335
346
|
for (const item of materialized.list(kind)) {
|
|
347
|
+
const pointer = keptPointer({
|
|
348
|
+
config: materialized,
|
|
349
|
+
kind,
|
|
350
|
+
path: item.path,
|
|
351
|
+
slug,
|
|
352
|
+
options: walk
|
|
353
|
+
});
|
|
354
|
+
if (pointer !== void 0) {
|
|
355
|
+
if (!holdsWantedRef(pointer.extend, slug)) continue;
|
|
356
|
+
const extend = inlineSourcedRefs(pointer.extend, materialized, slug, walk);
|
|
357
|
+
if (sameBody(pointer.extend, extend)) continue;
|
|
358
|
+
rewrites.push({
|
|
359
|
+
kind,
|
|
360
|
+
operation: "replace",
|
|
361
|
+
path: item.path,
|
|
362
|
+
data: {
|
|
363
|
+
...pointer,
|
|
364
|
+
extend
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
336
369
|
const data = rewrittenBody({
|
|
337
370
|
body: item.toJSON(),
|
|
338
371
|
kind,
|
|
@@ -403,6 +436,20 @@ function withoutPointer(meta) {
|
|
|
403
436
|
return kept;
|
|
404
437
|
}
|
|
405
438
|
function detachedGroupMeta({ config, kind, groupPath, slug, options }) {
|
|
439
|
+
if (options?.keepPointers) {
|
|
440
|
+
const stored = config.authoredGroups(kind).find((group) => group.path === groupPath)?.meta;
|
|
441
|
+
const kept = stored?.ref;
|
|
442
|
+
const owner = isRef(kept) ? config.configFor(kept) : void 0;
|
|
443
|
+
if (stored && isRef(kept) && wants(kept, slug) && owner && declaresGroup(owner, kept)) {
|
|
444
|
+
const { ref: _kept, ...fields } = stored;
|
|
445
|
+
if (!holdsWantedRef(fields, slug)) return void 0;
|
|
446
|
+
const inlined = inlineSourcedRefs(fields, config, slug, options);
|
|
447
|
+
return sameBody(fields, inlined) ? void 0 : {
|
|
448
|
+
...inlined,
|
|
449
|
+
ref: kept
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
}
|
|
406
453
|
const meta = config.groups(kind).find((group) => group.path === groupPath)?.meta ?? {};
|
|
407
454
|
const pointer = meta.ref;
|
|
408
455
|
if (!isRef(pointer) || !wants(pointer, slug)) {
|