@serene-pub/sdk 0.6.0-pr-7 → 0.6.0-pr-9
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/annexFields.d.ts +14 -0
- package/dist/annexFields.js +7 -0
- package/dist/announce.d.ts +62 -16
- package/dist/announce.js +90 -4
- package/dist/appletCard.d.ts +17 -0
- package/dist/appletCard.js +60 -0
- package/dist/attributes.d.ts +3 -3
- package/dist/attributes.js +1 -1
- package/dist/builder.d.ts +28 -13
- package/dist/builder.js +57 -5
- package/dist/cadences.d.ts +8 -1
- package/dist/cadences.js +27 -2
- package/dist/characterProfile.d.ts +137 -0
- package/dist/characterProfile.js +24 -0
- package/dist/component.d.ts +1 -1
- package/dist/componentImports.d.ts +1 -1
- package/dist/componentImports.js +2 -0
- package/dist/componentWire.js +28 -0
- package/dist/conditions.d.ts +5 -1
- package/dist/conditions.js +7 -0
- package/dist/declarations.d.ts +63 -1
- package/dist/declarations.js +176 -7
- package/dist/descriptors.d.ts +145 -6
- package/dist/descriptors.js +106 -5
- package/dist/document.d.ts +9 -1
- package/dist/document.js +44 -1
- package/dist/events.d.ts +82 -8
- package/dist/events.js +42 -5
- package/dist/executor.d.ts +27 -0
- package/dist/executor.js +32 -8
- package/dist/exposure.d.ts +35 -1
- package/dist/exposure.js +64 -2
- package/dist/extension.d.ts +30 -2
- package/dist/extension.js +3 -1
- package/dist/fit.d.ts +4 -1
- package/dist/fit.js +43 -1
- package/dist/functions.d.ts +7 -1
- package/dist/functions.js +3 -1
- package/dist/genres.d.ts +67 -2
- package/dist/genres.js +160 -8
- package/dist/hookGrants.js +10 -0
- package/dist/hostElements.d.ts +3 -3
- package/dist/hostElements.js +12 -4
- package/dist/index.d.ts +5 -0
- package/dist/index.js +10 -0
- package/dist/layout.d.ts +18 -0
- package/dist/libraryDraft.d.ts +2 -0
- package/dist/libraryDraft.js +5 -1
- package/dist/lorebookFile.d.ts +8 -0
- package/dist/lorebookFile.js +21 -0
- package/dist/participants.d.ts +83 -8
- package/dist/participants.js +9 -5
- package/dist/pluginPermissions.js +1 -1
- package/dist/promptBlocks.d.ts +5 -1
- package/dist/promptBlocks.js +23 -8
- package/dist/provisos.d.ts +92 -0
- package/dist/provisos.js +273 -0
- package/dist/receiverRules.js +1 -1
- package/dist/registrations.d.ts +154 -14
- package/dist/registrations.js +293 -23
- package/dist/registry.js +6 -3
- package/dist/repertoires.d.ts +13 -1
- package/dist/repertoires.js +5 -1
- package/dist/rulesetDocument.d.ts +11 -0
- package/dist/rulesetDocument.js +17 -0
- package/dist/rulesetSections.d.ts +12 -0
- package/dist/rulesetSections.js +8 -0
- package/dist/rulesets.js +6 -0
- package/dist/sceneSettings.d.ts +7 -1
- package/dist/sceneSettings.js +10 -5
- package/dist/sessionDossier.d.ts +159 -2
- package/dist/sessionLayout.d.ts +296 -85
- package/dist/sessionLayout.js +397 -133
- package/dist/sessionSettings.d.ts +18 -0
- package/dist/settings.d.ts +28 -1
- package/dist/settings.js +50 -2
- package/dist/shapes.d.ts +15 -1
- package/dist/shapes.js +15 -1
- package/dist/sheetLatitude.d.ts +148 -0
- package/dist/sheetLatitude.js +161 -0
- package/dist/speech.d.ts +14 -3
- package/dist/storyTime.d.ts +77 -1
- package/dist/storyTime.js +117 -8
- package/dist/surfaces.d.ts +49 -2
- package/dist/surfaces.js +3 -0
- package/dist/template.d.ts +38 -1
- package/dist/templateCheck.d.ts +24 -0
- package/dist/templateCheck.js +465 -10
- package/dist/templateFit.js +8 -1
- package/dist/templateIds.d.ts +6 -0
- package/dist/templateIds.js +9 -0
- package/dist/turnLock.d.ts +10 -1
- package/dist/turnLock.js +6 -1
- package/dist/turnOrder.d.ts +37 -4
- package/dist/turnOrder.js +49 -11
- package/dist/validate.d.ts +4 -2
- package/dist/validate.js +84 -11
- package/dist/variableLayouts.d.ts +160 -0
- package/dist/variableLayouts.js +202 -0
- package/dist/variables.d.ts +237 -20
- package/dist/variables.js +292 -33
- package/dist/widgetDecls.js +12 -0
- package/dist/widgets.d.ts +449 -47
- package/dist/widgets.js +31 -0
- package/host-elements.d.ts +4 -2
- package/package.json +1 -1
package/dist/sessionLayout.js
CHANGED
|
@@ -7,28 +7,27 @@
|
|
|
7
7
|
*
|
|
8
8
|
* ## The shape in one paragraph
|
|
9
9
|
*
|
|
10
|
-
* Its **arrangement** is `panels` ({@link
|
|
11
|
-
* **panels**, a panel being a box
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
10
|
+
* Its **arrangement** is `panels` ({@link PanelLayoutV2}): three plain
|
|
11
|
+
* stacks — `left`, `middle`, `right` — of **panels**, a panel being a box
|
|
12
|
+
* that holds widgets as tabs, the thing a person drags and sees. There is no
|
|
13
|
+
* pin: every panel is open. A panel may state a `priority` (`low` gives way
|
|
14
|
+
* first when a zone runs short; absent is its open widget's declaration), and
|
|
15
|
+
* the layout's look — `backing`, `opacity`, `gap`, `behind`, `behindDim` — sits inside `panels` too.
|
|
16
|
+
* When `panels` is present it is the whole truth.
|
|
16
17
|
*
|
|
17
|
-
* ⏳
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* directly: they are a side's width ladder ({@link zoneRungAt}), not where
|
|
25
|
-
* anything is placed.
|
|
18
|
+
* ⏳ Version 1 panels (the middle as `above` / `primary` / `below`, a pin per
|
|
19
|
+
* panel) and, before them, three slots — `zoneLayout`, `widgetGrid` and
|
|
20
|
+
* `arrangedGrid`, three views of one placement — are still typed and still
|
|
21
|
+
* read: 0.6 is in users' hands and plugin manifests carry them. The old slots
|
|
22
|
+
* become version 1 by {@link panelsFromSlots}, and version 1 becomes version 2
|
|
23
|
+
* by {@link panelsV2Of} — the ONE converter every reader reuses. The slots
|
|
24
|
+
* are dropped at the 0.7 squash, with `panelsFromSlots`.
|
|
26
25
|
*
|
|
27
26
|
* What the screen DRAWS is one reading: {@link resolveDrawn} (→
|
|
28
|
-
* {@link DrawnLayout}) reads {@link panelsOf}, drops retired widgets,
|
|
29
|
-
* every panel
|
|
30
|
-
*
|
|
31
|
-
*
|
|
27
|
+
* {@link DrawnLayout}) reads {@link panelsOf}, drops retired widgets, and
|
|
28
|
+
* gives every panel a height and a priority (its own, else its widget's
|
|
29
|
+
* declaration). The id readers that ask "is it drawn"
|
|
30
|
+
* ({@link drawnWidgetIds}, {@link primaryPlaced}) are that answer.
|
|
32
31
|
*
|
|
33
32
|
* A named layout adds `widgetSettings` and `widgetStyles` (per-instance values
|
|
34
33
|
* and style pins), so one blob is the portable layout. A session keeps those
|
|
@@ -45,14 +44,15 @@
|
|
|
45
44
|
* everything about the widget (its declaration, its style rows) is read
|
|
46
45
|
* through {@link widgetOfInstance}.
|
|
47
46
|
*
|
|
48
|
-
* ## The
|
|
47
|
+
* ## The converters, and what is deliberately not here
|
|
49
48
|
*
|
|
50
|
-
* The
|
|
51
|
-
* read as panels
|
|
52
|
-
*
|
|
49
|
+
* The SDK owns two converters, and no other: {@link panelsFromSlots} (the old
|
|
50
|
+
* slots read as version 1 panels) and {@link panelsV2Of} (version 1, or the
|
|
51
|
+
* slots, read as version 2). They are here rather than in the app because
|
|
52
|
+
* four readers need the same answer — the packager's compiler, plugin manifests in the wild
|
|
53
53
|
* (which ship the old slots and keep working with no manifest change), the
|
|
54
54
|
* goldens, and the app's boot pass that writes `panels` onto stored rows — and
|
|
55
|
-
* two
|
|
55
|
+
* two answers to one conversion would be a bug. Every other normaliser, the renderer
|
|
56
56
|
* and all measurement are the app's, which reads a stored blob it did not
|
|
57
57
|
* write and must repair rather than refuse. This module types the format,
|
|
58
58
|
* reads the ids out of it, and checks a layout a package SHIPS
|
|
@@ -125,9 +125,11 @@ export function isWidgetInstanceId(id) {
|
|
|
125
125
|
* an arrangement may still carry one — all three are stored verbatim and
|
|
126
126
|
* nothing rewrites them — so every reader drops it.
|
|
127
127
|
*
|
|
128
|
-
* `composer` is one
|
|
129
|
-
*
|
|
130
|
-
*
|
|
128
|
+
* `composer` is NOT one: it is a widget again — the owner's R8, 2026-11-05,
|
|
129
|
+
* "Split the messages, composer and activity status/turn select into three
|
|
130
|
+
* widgets", which supersedes NOMENCLATURE §23's 2026-09-16 "composer (the
|
|
131
|
+
* widget) — Merged into messages". Only the ⏳ old slots still never draw
|
|
132
|
+
* one ({@link LEGACY_SLOT_DROPPED}).
|
|
131
133
|
*
|
|
132
134
|
* `inventory` is one because core's Inventory widget was removed (2026-09-25)
|
|
133
135
|
* for now, with no replacement. Adventure and Lair shipped it, so layouts and
|
|
@@ -139,7 +141,26 @@ export function isWidgetInstanceId(id) {
|
|
|
139
141
|
* @experimental
|
|
140
142
|
* @ruling R79
|
|
141
143
|
*/
|
|
142
|
-
export const RETIRED_WIDGET_IDS = new Set(['
|
|
144
|
+
export const RETIRED_WIDGET_IDS = new Set(['inventory']);
|
|
145
|
+
/**
|
|
146
|
+
* ⏳ Widget ids the OLD-SLOT path drops, so a slot-era blob never revives a
|
|
147
|
+
* composer: before the split (2026-11-05) the field was `messages`' own, and
|
|
148
|
+
* a slot that names `composer` meant nothing. Read ONLY by {@link panelsFromSlots}'s
|
|
149
|
+
* conversion — nowhere else; a `panels` layout places `composer` freely.
|
|
150
|
+
* @experimental
|
|
151
|
+
*/
|
|
152
|
+
export const LEGACY_SLOT_DROPPED = new Set(['composer']);
|
|
153
|
+
/**
|
|
154
|
+
* 🚧 The ids of the two widgets the conversation splits into, for a copy of
|
|
155
|
+
* `messages`: `messages` → `composer`, `turn-line`; `messages#x` →
|
|
156
|
+
* `composer#x`, `turn-line#x`. Pure.
|
|
157
|
+
* @experimental
|
|
158
|
+
*/
|
|
159
|
+
export function conversationSplitIds(instanceId) {
|
|
160
|
+
const name = instanceNameOf(instanceId);
|
|
161
|
+
const at = name === null ? '' : `${INSTANCE_NAME_SEPARATOR}${name}`;
|
|
162
|
+
return { composer: `composer${at}`, turnLine: `turn-line${at}` };
|
|
163
|
+
}
|
|
143
164
|
/**
|
|
144
165
|
* ⏳ Widget ids that are another widget now — an ALIAS, not a retirement: a
|
|
145
166
|
* stored layout, preset or arrangement that places one keeps drawing what it
|
|
@@ -196,6 +217,16 @@ export function resolveWidgetAlias(instanceId, taken) {
|
|
|
196
217
|
}
|
|
197
218
|
return { widgetId: alias.id, instanceId: canonical, impliedSettings: alias.settings, aliasedFrom: written };
|
|
198
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* 🚧 A {@link PanelGap} in px.
|
|
222
|
+
* @experimental
|
|
223
|
+
*/
|
|
224
|
+
export const PANEL_GAP_PX = Object.freeze({ tight: 4, comfortable: 12, spacious: 24 });
|
|
225
|
+
/**
|
|
226
|
+
* 🚧 The look a layout that states none has.
|
|
227
|
+
* @experimental
|
|
228
|
+
*/
|
|
229
|
+
export const DEFAULT_PANEL_LOOK = Object.freeze({ backing: 'card', opacity: 100, gap: 'comfortable', behind: 'background', behindDim: 0 });
|
|
199
230
|
// ── Reading the old slots ───────────────────────────────────────────────────
|
|
200
231
|
const isObj = (x) => !!x && typeof x === 'object' && !Array.isArray(x);
|
|
201
232
|
const strings = (x) => Array.isArray(x) ? x.filter((s) => typeof s === 'string') : [];
|
|
@@ -267,6 +298,8 @@ function slotWidgetIds(layout) {
|
|
|
267
298
|
}
|
|
268
299
|
/** Is this instance a copy of a retired widget? No reader draws one. */
|
|
269
300
|
const retired = (instanceId) => RETIRED_WIDGET_IDS.has(widgetOfInstance(instanceId));
|
|
301
|
+
/** Does the OLD-SLOT path drop this instance — retired, or a {@link LEGACY_SLOT_DROPPED} widget? Read only by `convertSlots`. */
|
|
302
|
+
const slotDropped = (instanceId) => retired(instanceId) || LEGACY_SLOT_DROPPED.has(widgetOfInstance(instanceId));
|
|
270
303
|
const byRow = (a, b) => a.y - b.y || a.x - b.x;
|
|
271
304
|
const byColumn = (a, b) => a.x - b.x || a.y - b.y;
|
|
272
305
|
/** An arranged item read as a slot item. */
|
|
@@ -320,7 +353,7 @@ function convertSlots(layout, opts = {}) {
|
|
|
320
353
|
const seen = new Set();
|
|
321
354
|
/** Admit an instance once, in the old reading order — middle, left, right, strips — never a retired one. */
|
|
322
355
|
const admit = (id) => {
|
|
323
|
-
if (
|
|
356
|
+
if (slotDropped(id) || seen.has(id))
|
|
324
357
|
return false;
|
|
325
358
|
seen.add(id);
|
|
326
359
|
return true;
|
|
@@ -359,7 +392,7 @@ function convertSlots(layout, opts = {}) {
|
|
|
359
392
|
const side = (edge) => {
|
|
360
393
|
const frame = frameIn(doc, edge);
|
|
361
394
|
let items;
|
|
362
|
-
if (frame && frame.items.some((i) => !
|
|
395
|
+
if (frame && frame.items.some((i) => !slotDropped(i.id)))
|
|
363
396
|
items = frame.items.map(fromArranged);
|
|
364
397
|
else {
|
|
365
398
|
items = [];
|
|
@@ -468,7 +501,7 @@ function convertSlots(layout, opts = {}) {
|
|
|
468
501
|
*
|
|
469
502
|
* Every instance is admitted once, where the old readers drew it first —
|
|
470
503
|
* middle, left, right, strips — and a copy of a retired widget never
|
|
471
|
-
* ({@link RETIRED_WIDGET_IDS}). An aliased id ({@link WIDGET_ID_ALIASES})
|
|
504
|
+
* ({@link RETIRED_WIDGET_IDS}), nor of a {@link LEGACY_SLOT_DROPPED} one. An aliased id ({@link WIDGET_ID_ALIASES})
|
|
472
505
|
* stays the id as placed, the key its settings and style pin live under.
|
|
473
506
|
* Keys run `p1…pn` in discovery order: the primary, above, below, left, right.
|
|
474
507
|
* @experimental
|
|
@@ -476,50 +509,232 @@ function convertSlots(layout, opts = {}) {
|
|
|
476
509
|
export function panelsFromSlots(layout, opts) {
|
|
477
510
|
return convertSlots(layout, opts).panels;
|
|
478
511
|
}
|
|
479
|
-
/** Is this a stored `panels` slot a reader can walk? (Not a validation: {@link validateSessionLayout} is.) */
|
|
512
|
+
/** Is this a stored `panels` slot a reader can walk — version 2, or a version 1 with its primary? (Not a validation: {@link validateSessionLayout} is.) */
|
|
480
513
|
function storedPanels(layout) {
|
|
481
514
|
if (!isObj(layout))
|
|
482
515
|
return null;
|
|
483
516
|
const p = layout.panels;
|
|
517
|
+
if (isObj(p) && p.version === 2)
|
|
518
|
+
return p;
|
|
484
519
|
return isObj(p) && p.version === 1 && isObj(p.middle) && isObj(p.middle.primary) ? p : null;
|
|
485
520
|
}
|
|
486
|
-
/**
|
|
521
|
+
/** A stored zone's panels, defensively: the objects of a list. */
|
|
522
|
+
const panelList = (x) => (Array.isArray(x) ? x.filter((p) => isObj(p)) : []);
|
|
523
|
+
/** A property of an object, when it is an own one. */
|
|
524
|
+
const ownOf = (o, key) => (isObj(o) && Object.hasOwn(o, key) ? o[key] : undefined);
|
|
525
|
+
/** Settings keys of a copy of `messages` that the split moves to its composer. */
|
|
526
|
+
const COMPOSER_KEYS = ['composer', 'otherTabsComposer', 'showActions'];
|
|
527
|
+
/** The keys of a copy of `messages` the split drops, after `nextUp`. */
|
|
528
|
+
const DROPPED_KEYS = ['composerPosition', 'showComposer', 'showMessages', 'showNudge'];
|
|
529
|
+
/** A stored panel rebuilt as a version 2 panel: only what version 2 has. */
|
|
530
|
+
function flattenPanel(panel) {
|
|
531
|
+
const p = panel;
|
|
532
|
+
return {
|
|
533
|
+
key: typeof p.key === 'string' ? p.key : '',
|
|
534
|
+
tabs: strings(p.tabs),
|
|
535
|
+
...(p.open !== undefined ? { open: p.open } : {}),
|
|
536
|
+
...(p.height !== undefined ? { height: p.height } : {}),
|
|
537
|
+
...(p.title !== undefined ? { title: p.title } : {}),
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
/** {@link panelsV2Of}, and the keys of the panels the converter's floor made (none for a stored layout). */
|
|
541
|
+
function convertToV2(layout, opts = {}) {
|
|
542
|
+
const doc = isObj(layout) ? layout : {};
|
|
543
|
+
const stored = doc.panels;
|
|
544
|
+
if (isObj(stored) && stored.version === 2)
|
|
545
|
+
return { panels: stored, settingsMoves: [], styleCopies: [], floorKeys: new Set() };
|
|
546
|
+
// The version 1 source: a stored one, else the old slots.
|
|
547
|
+
let source;
|
|
548
|
+
let floor = false;
|
|
549
|
+
const v1 = storedPanels(doc);
|
|
550
|
+
if (v1 && v1.version === 1)
|
|
551
|
+
source = v1;
|
|
552
|
+
else {
|
|
553
|
+
const converted = convertSlots(doc, opts);
|
|
554
|
+
source = converted.panels;
|
|
555
|
+
floor = converted.floor;
|
|
556
|
+
}
|
|
557
|
+
// Flatten: left, the middle top to bottom, right. Version 1 predates the
|
|
558
|
+
// split of Messages, so a `composer` written into one is slot-era too: it is
|
|
559
|
+
// dropped like the old slots drop it (LEGACY_SLOT_DROPPED), and a panel left
|
|
560
|
+
// with no tabs goes — it never blocks the split below.
|
|
561
|
+
const mid = source.middle;
|
|
562
|
+
const unretired = (p) => {
|
|
563
|
+
const tabs = p.tabs.filter((id) => !LEGACY_SLOT_DROPPED.has(widgetOfInstance(id)));
|
|
564
|
+
if (tabs.length === p.tabs.length)
|
|
565
|
+
return p;
|
|
566
|
+
const { open, ...rest } = p;
|
|
567
|
+
return { ...rest, tabs, ...(open !== undefined && tabs.includes(open) ? { open } : {}) };
|
|
568
|
+
};
|
|
569
|
+
const list = (v) => panelList(v).map(flattenPanel).map(unretired).filter((p) => p.tabs.length > 0);
|
|
570
|
+
const primary = unretired(flattenPanel(mid.primary));
|
|
571
|
+
const zones = {
|
|
572
|
+
left: list(source.left),
|
|
573
|
+
middle: [...list(mid.above), ...(primary.tabs.length > 0 ? [primary] : []), ...list(mid.below)],
|
|
574
|
+
right: list(source.right),
|
|
575
|
+
};
|
|
576
|
+
const floorPanels = new Set(floor ? [primary] : []);
|
|
577
|
+
// Settings and style pins LAYER, per instance: the layout's own, then the
|
|
578
|
+
// caller's (stored rows) over them — a key the caller passes wins; a key only
|
|
579
|
+
// the layout carries still counts. Callers apply each move to whichever store
|
|
580
|
+
// holds that key.
|
|
581
|
+
const layered = (own, over) => {
|
|
582
|
+
if (!isObj(own) && !isObj(over))
|
|
583
|
+
return undefined;
|
|
584
|
+
const out = {};
|
|
585
|
+
for (const src of [own, over])
|
|
586
|
+
if (isObj(src))
|
|
587
|
+
for (const [id, v] of Object.entries(src))
|
|
588
|
+
out[id] = isObj(v) && isObj(out[id]) ? { ...out[id], ...v } : v;
|
|
589
|
+
return out;
|
|
590
|
+
};
|
|
591
|
+
const S = layered(doc.widgetSettings, opts.widgetSettings);
|
|
592
|
+
const T = layered(doc.widgetStyles, opts.widgetStyles);
|
|
593
|
+
const settingOf = (id, key) => ownOf(ownOf(S, id), key);
|
|
594
|
+
// The composer and turn line, once per composing copy of Messages.
|
|
595
|
+
const order = ['middle', 'left', 'right'];
|
|
596
|
+
const placed = new Set(order.flatMap((z) => zones[z].flatMap((p) => p.tabs)));
|
|
597
|
+
const composed = new Map();
|
|
598
|
+
const turned = new Map();
|
|
599
|
+
const styled = [];
|
|
600
|
+
const made = new Set();
|
|
601
|
+
if (![...placed].some((id) => isInstanceOf(id, 'composer'))) {
|
|
602
|
+
for (const z of order) {
|
|
603
|
+
const next = [];
|
|
604
|
+
for (const panel of zones[z]) {
|
|
605
|
+
const m = panel.tabs.find((id) => isInstanceOf(id, CONVERSATION) && settingOf(id, 'showComposer') !== false);
|
|
606
|
+
if (m === undefined) {
|
|
607
|
+
next.push(panel);
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
610
|
+
const { composer, turnLine } = conversationSplitIds(m);
|
|
611
|
+
const nextUp = settingOf(m, 'nextUp');
|
|
612
|
+
const nextUpIs = nextUp === 'head' || nextUp === 'list' || nextUp === 'hidden' ? nextUp : settingOf(m, 'showNudge') === false ? 'hidden' : 'head';
|
|
613
|
+
const pair = [];
|
|
614
|
+
if (nextUpIs !== 'hidden' && !placed.has(turnLine)) {
|
|
615
|
+
pair.push({ key: '', tabs: [turnLine], height: 'fit' });
|
|
616
|
+
turned.set(m, turnLine);
|
|
617
|
+
styled.push({ from: m, to: turnLine });
|
|
618
|
+
}
|
|
619
|
+
if (!placed.has(composer)) {
|
|
620
|
+
pair.push({ key: '', tabs: [composer], height: 'fit' });
|
|
621
|
+
composed.set(m, composer);
|
|
622
|
+
styled.push({ from: m, to: composer });
|
|
623
|
+
}
|
|
624
|
+
pair.forEach((p) => made.add(p));
|
|
625
|
+
if (floorPanels.has(panel))
|
|
626
|
+
pair.forEach((p) => floorPanels.add(p));
|
|
627
|
+
if (settingOf(m, 'composerPosition') === 'top')
|
|
628
|
+
next.push(...pair, panel);
|
|
629
|
+
else
|
|
630
|
+
next.push(panel, ...pair);
|
|
631
|
+
}
|
|
632
|
+
zones[z] = next;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
// Keys for the new panels continue the counter, in final array order.
|
|
636
|
+
let n = 0;
|
|
637
|
+
for (const z of order)
|
|
638
|
+
for (const p of zones[z]) {
|
|
639
|
+
const at = /^p(\d+)$/.exec(p.key);
|
|
640
|
+
if (at)
|
|
641
|
+
n = Math.max(n, Number(at[1]));
|
|
642
|
+
}
|
|
643
|
+
for (const z of order)
|
|
644
|
+
for (const p of zones[z])
|
|
645
|
+
if (made.has(p))
|
|
646
|
+
p.key = `p${++n}`;
|
|
647
|
+
const floorKeys = new Set([...floorPanels].map((p) => p.key));
|
|
648
|
+
// Settings the split moves or drops, in the order they are found.
|
|
649
|
+
const settingsMoves = [];
|
|
650
|
+
if (isObj(S))
|
|
651
|
+
for (const [id, values] of Object.entries(S)) {
|
|
652
|
+
if (!isObj(values))
|
|
653
|
+
continue;
|
|
654
|
+
const has = (k) => Object.hasOwn(values, k);
|
|
655
|
+
if (isInstanceOf(id, CONVERSATION)) {
|
|
656
|
+
for (const key of COMPOSER_KEYS)
|
|
657
|
+
if (has(key)) {
|
|
658
|
+
const to = composed.get(id);
|
|
659
|
+
settingsMoves.push(to ? { from: id, to, key, value: values[key] } : { drop: id, key });
|
|
660
|
+
}
|
|
661
|
+
if (has('nextUp')) {
|
|
662
|
+
const to = turned.get(id);
|
|
663
|
+
settingsMoves.push(to ? { from: id, to, key: 'nextUp', value: values.nextUp } : { drop: id, key: 'nextUp' });
|
|
664
|
+
}
|
|
665
|
+
for (const key of DROPPED_KEYS)
|
|
666
|
+
if (has(key))
|
|
667
|
+
settingsMoves.push({ drop: id, key });
|
|
668
|
+
}
|
|
669
|
+
if (has('hostCard'))
|
|
670
|
+
settingsMoves.push({ drop: id, key: 'hostCard' });
|
|
671
|
+
if (isInstanceOf(id, CONVERSATION) && has('backingMode'))
|
|
672
|
+
settingsMoves.push({ drop: id, key: 'backingMode' });
|
|
673
|
+
}
|
|
674
|
+
// Style pins the new widgets take from the Messages copy they came from.
|
|
675
|
+
const present = (id) => ownOf(T, id) !== undefined && ownOf(T, id) !== null;
|
|
676
|
+
const styleCopies = styled.filter(({ from, to }) => present(from) && !present(to));
|
|
677
|
+
return { panels: { version: 2, left: zones.left, middle: zones.middle, right: zones.right }, settingsMoves, styleCopies, floorKeys };
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* 🚧 The layout's arrangement as {@link PanelLayoutV2} — the ONE converter,
|
|
681
|
+
* with {@link panelsFromSlots} (old slots → version 1): every reader reuses
|
|
682
|
+
* it, and the app's boot pass writes its answer. Pure, deterministic, total
|
|
683
|
+
* and non-mutating.
|
|
684
|
+
*
|
|
685
|
+
* A stored version 2 is returned as it is (the same object), with nothing to
|
|
686
|
+
* move. Otherwise the source is a stored version 1, else
|
|
687
|
+
* {@link panelsFromSlots}; it is flattened — left, the middle as `above`,
|
|
688
|
+
* `primary`, `below`, right — each panel keeping `key`, `tabs`, `open`,
|
|
689
|
+
* `height` and `title` and dropping the pin.
|
|
690
|
+
*
|
|
691
|
+
* **The split.** Before it, the log, the field and the turn line were one
|
|
692
|
+
* widget. For each panel's first tab that is a copy of `messages` with its
|
|
693
|
+
* composer showing (`showComposer` not `false`), a turn-line panel (unless
|
|
694
|
+
* `nextUp` reads as `hidden`, the legacy `showNudge: false` included) and a
|
|
695
|
+
* composer panel — `height: 'fit'` — are inserted right after it, or before
|
|
696
|
+
* it when `composerPosition` is `'top'`; their ids are
|
|
697
|
+
* {@link conversationSplitIds}. A layout that already places a `composer`
|
|
698
|
+
* gets nothing. New keys continue the `p<n>` counter.
|
|
699
|
+
*
|
|
700
|
+
* `settingsMoves` lists what the split does to the stored settings (a key to
|
|
701
|
+
* move onto the new instance, or to drop) and `styleCopies` the style pins
|
|
702
|
+
* the new instances copy; the CALLER applies both. No look is written.
|
|
703
|
+
* @experimental
|
|
704
|
+
*/
|
|
705
|
+
export function panelsV2Of(layout, opts) {
|
|
706
|
+
const { floorKeys: _floorKeys, ...conversion } = convertToV2(layout, opts);
|
|
707
|
+
return conversion;
|
|
708
|
+
}
|
|
709
|
+
/** {@link panelsV2Of}'s panels, and the keys of the converter's floor panels. */
|
|
487
710
|
function panelsWithFloor(layout, opts) {
|
|
488
|
-
const
|
|
489
|
-
return
|
|
711
|
+
const { panels, floorKeys } = convertToV2(layout, opts);
|
|
712
|
+
return { panels, floorKeys };
|
|
490
713
|
}
|
|
491
714
|
/**
|
|
492
|
-
* The layout's panels: `
|
|
493
|
-
*
|
|
494
|
-
*
|
|
715
|
+
* The layout's panels as version 2: {@link panelsV2Of}'s `panels` — a stored
|
|
716
|
+
* version 2 as it is, anything else converted. What every reader reads.
|
|
717
|
+
* ⚠ Its return type changed with version 2 (was {@link PanelLayoutV1}).
|
|
495
718
|
* @experimental
|
|
496
719
|
*/
|
|
497
720
|
export function panelsOf(layout, opts) {
|
|
498
|
-
return
|
|
721
|
+
return panelsV2Of(layout, opts).panels;
|
|
499
722
|
}
|
|
500
|
-
/**
|
|
501
|
-
const panelList = (x) => (Array.isArray(x) ? x.filter((p) => isObj(p)) : []);
|
|
502
|
-
/** Every panel's tabs, as written, in reading order — middle (above, primary, below), left, right — the floor's left out. */
|
|
723
|
+
/** Every panel's tabs, as written, in reading order — middle, left, right — the floor's left out. */
|
|
503
724
|
function panelTabs(layout, zones = ZONE_IDS) {
|
|
504
|
-
const { panels,
|
|
725
|
+
const { panels, floorKeys } = panelsWithFloor(layout);
|
|
505
726
|
const out = [];
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
panelList(panels.middle.below).forEach(take);
|
|
512
|
-
}
|
|
513
|
-
if (zones.includes('left'))
|
|
514
|
-
panelList(panels.left).forEach(take);
|
|
515
|
-
if (zones.includes('right'))
|
|
516
|
-
panelList(panels.right).forEach(take);
|
|
727
|
+
for (const z of ['middle', 'left', 'right'])
|
|
728
|
+
if (zones.includes(z))
|
|
729
|
+
for (const p of panelList(panels[z]))
|
|
730
|
+
if (!floorKeys.has(p.key))
|
|
731
|
+
out.push(...strings(p.tabs));
|
|
517
732
|
return out;
|
|
518
733
|
}
|
|
519
734
|
// ── Reading ids ─────────────────────────────────────────────────────────────
|
|
520
735
|
/**
|
|
521
736
|
* Every widget instance id the layout NAMES, each once: its panels' tabs in
|
|
522
|
-
* reading order — and, while it has no `panels`, then whatever the ⏳ old
|
|
737
|
+
* reading order (middle, left, right) — and, while it has no `panels`, then whatever the ⏳ old
|
|
523
738
|
* slots name that the conversion did not keep (a retired widget, an entry an
|
|
524
739
|
* arrangement shadows). What a check reads when the question is "does this
|
|
525
740
|
* layout mention it at all" (a genre's omitted widgets). The floor's
|
|
@@ -534,8 +749,8 @@ export function layoutWidgetIds(layout) {
|
|
|
534
749
|
return [...out];
|
|
535
750
|
}
|
|
536
751
|
/**
|
|
537
|
-
* The widget instance ids the MIDDLE's panels hold
|
|
538
|
-
*
|
|
752
|
+
* The widget instance ids the MIDDLE's panels hold, top to bottom, each
|
|
753
|
+
* once. The floor's conversation is not held.
|
|
539
754
|
* @experimental
|
|
540
755
|
*/
|
|
541
756
|
export function middleWidgetIds(layout) {
|
|
@@ -552,6 +767,7 @@ export function middleWidgetIds(layout) {
|
|
|
552
767
|
* the stage's 696px measure fit a 1216px session box (a 1280 window):
|
|
553
768
|
* 248 + 248 + 2×8 + 696 = 1208. At 264 they needed 1240 and both sides tucked.
|
|
554
769
|
* @experimental
|
|
770
|
+
* @deprecated ⏳ removed at 0.7 (owner's call) — no reader walks a width ladder now.
|
|
555
771
|
*/
|
|
556
772
|
export const DEFAULT_SIDE_RULES = {
|
|
557
773
|
right: [
|
|
@@ -570,7 +786,11 @@ export const DEFAULT_SIDE_RULES = {
|
|
|
570
786
|
{ min: 2400, width: 344, columns: 2 },
|
|
571
787
|
],
|
|
572
788
|
};
|
|
573
|
-
/**
|
|
789
|
+
/**
|
|
790
|
+
* The width ladder a strip walks when it declares none: always a row.
|
|
791
|
+
* @experimental
|
|
792
|
+
* @deprecated ⏳ removed at 0.7 (owner's call) — no reader walks a width ladder now.
|
|
793
|
+
*/
|
|
574
794
|
export const DEFAULT_STRIP_RULES = [{ min: 0, mode: 'row' }];
|
|
575
795
|
/**
|
|
576
796
|
* A zone's width ladder at `inline` px — its own `rules`, else the default
|
|
@@ -579,6 +799,7 @@ export const DEFAULT_STRIP_RULES = [{ min: 0, mode: 'row' }];
|
|
|
579
799
|
* describes. The one walk: the page's rails, the editor's simulator and
|
|
580
800
|
* {@link resolveDrawn} all read a ladder through it.
|
|
581
801
|
* @experimental
|
|
802
|
+
* @deprecated ⏳ removed at 0.7 (owner's call) — {@link resolveDrawn} no longer walks a ladder.
|
|
582
803
|
*/
|
|
583
804
|
export function zoneRungAt(def, inline) {
|
|
584
805
|
const strip = def.kind === 'strip';
|
|
@@ -616,6 +837,7 @@ export function zoneRungAt(def, inline) {
|
|
|
616
837
|
* envelope's `layout.v1.pinned`, which a host tells a widget about its own
|
|
617
838
|
* box.
|
|
618
839
|
* @experimental
|
|
840
|
+
* @deprecated ⏳ removed at 0.7 (owner's call) — version 2 has no pin; still read by {@link panelsFromSlots}.
|
|
619
841
|
*/
|
|
620
842
|
export function pinnedOf(placement) {
|
|
621
843
|
return placement?.pinned !== false;
|
|
@@ -625,40 +847,56 @@ function widgetFacts(instanceId) {
|
|
|
625
847
|
const r = resolveWidgetAlias(instanceId);
|
|
626
848
|
return r.aliasedFrom ? { widgetId: r.widgetId, impliedSettings: r.impliedSettings } : { widgetId: r.widgetId };
|
|
627
849
|
}
|
|
628
|
-
/** A stored height, read: `fit`, `fill` or a whole share of 1–12; anything else is
|
|
629
|
-
function
|
|
850
|
+
/** A stored height, read: `fit`, `fill` or a whole share of 1–12; anything else is absent. */
|
|
851
|
+
function validHeight(x) {
|
|
630
852
|
if (x === 'fit' || x === 'fill')
|
|
631
853
|
return x;
|
|
632
854
|
if (isObj(x) && isInt(x.share) && x.share >= 1 && x.share <= 12)
|
|
633
855
|
return { share: x.share };
|
|
634
|
-
return
|
|
856
|
+
return undefined;
|
|
857
|
+
}
|
|
858
|
+
const isPriority = (x) => x === 'high' || x === 'normal' || x === 'low';
|
|
859
|
+
const isBacking = (x) => x === 'card' || x === 'glass' || x === 'none';
|
|
860
|
+
const isGap = (x) => x === 'tight' || x === 'comfortable' || x === 'spacious';
|
|
861
|
+
/** The layout's look as a stored version 2 states it, else the default. */
|
|
862
|
+
function lookOf(layout) {
|
|
863
|
+
const p = isObj(layout) && isObj(layout.panels) && layout.panels.version === 2 ? layout.panels : {};
|
|
864
|
+
const gap = isGap(p.gap) ? p.gap : DEFAULT_PANEL_LOOK.gap;
|
|
865
|
+
return {
|
|
866
|
+
backing: isBacking(p.backing) ? p.backing : DEFAULT_PANEL_LOOK.backing,
|
|
867
|
+
opacity: typeof p.opacity === 'number' && Number.isFinite(p.opacity) ? Math.min(100, Math.max(0, p.opacity)) : DEFAULT_PANEL_LOOK.opacity,
|
|
868
|
+
gap,
|
|
869
|
+
behind: p.behind === 'backdrop' ? 'backdrop' : 'background',
|
|
870
|
+
behindDim: typeof p.behindDim === 'number' && Number.isFinite(p.behindDim) ? Math.min(100, Math.max(0, p.behindDim)) : 0,
|
|
871
|
+
gapPx: PANEL_GAP_PX[gap],
|
|
872
|
+
};
|
|
635
873
|
}
|
|
636
874
|
/**
|
|
637
|
-
* What a session layout draws
|
|
638
|
-
* its
|
|
639
|
-
*
|
|
640
|
-
* nothing.
|
|
875
|
+
* What a session layout draws: per zone, its panels top to bottom, each with
|
|
876
|
+
* its tabs, the tab shown, a height and a priority — and the layout's look.
|
|
877
|
+
* Pure and total — any value reads; what it cannot read places nothing.
|
|
641
878
|
*
|
|
642
|
-
* It reads {@link panelsOf}: the layout's `panels
|
|
643
|
-
* through {@link panelsFromSlots}. A tab that is a copy of a
|
|
644
|
-
* ({@link RETIRED_WIDGET_IDS}) is not drawn, a panel left with
|
|
645
|
-
*
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
*
|
|
879
|
+
* It reads {@link panelsOf}: the layout's `panels` (version 1 converted), else
|
|
880
|
+
* the ⏳ old slots through {@link panelsFromSlots}. A tab that is a copy of a
|
|
881
|
+
* retired widget ({@link RETIRED_WIDGET_IDS}) is not drawn, a panel left with
|
|
882
|
+
* no tab is not drawn, and an instance is drawn once, in its first panel in
|
|
883
|
+
* reading order — middle, left, right. An aliased id
|
|
884
|
+
* ({@link WIDGET_ID_ALIASES}) is drawn as the widget it became, under the id
|
|
885
|
+
* it was placed by, with the settings it implies.
|
|
649
886
|
*
|
|
650
|
-
* A
|
|
651
|
-
*
|
|
652
|
-
* `
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
* The box's `block` size is not read today: no rung is a height.
|
|
887
|
+
* A panel's `height` is its stored one, else its open tab's declaration
|
|
888
|
+
* (`opts.widgets`, `panel.height`), else `fill`; its `priority` likewise
|
|
889
|
+
* (`panel.priority`, else `'normal'`). There is no pin: every `pinned` is
|
|
890
|
+
* `true`, and no width ladder is walked, so `box` is not read.
|
|
656
891
|
* @experimental
|
|
657
892
|
*/
|
|
658
|
-
export function resolveDrawn(layout, box) {
|
|
893
|
+
export function resolveDrawn(layout, box, opts = {}) {
|
|
659
894
|
const doc = isObj(layout) ? layout : {};
|
|
660
|
-
const
|
|
661
|
-
const
|
|
895
|
+
const { panels, floorKeys } = panelsWithFloor(doc);
|
|
896
|
+
const decls = new Map();
|
|
897
|
+
for (const w of (Array.isArray(opts?.widgets) ? opts.widgets : []))
|
|
898
|
+
if (isObj(w) && typeof w.id === 'string')
|
|
899
|
+
decls.set(w.id, w);
|
|
662
900
|
const seen = new Set();
|
|
663
901
|
/** Admit an instance once, in reading order, never a retired one. */
|
|
664
902
|
const admit = (id) => {
|
|
@@ -667,66 +905,49 @@ export function resolveDrawn(layout, box) {
|
|
|
667
905
|
seen.add(id);
|
|
668
906
|
return true;
|
|
669
907
|
};
|
|
670
|
-
const draw = (p
|
|
908
|
+
const draw = (p) => {
|
|
671
909
|
const tabs = strings(p.tabs)
|
|
672
910
|
.filter((id) => id && admit(id))
|
|
673
|
-
.map((id) => ({ instanceId: id, ...widgetFacts(id), pinned }));
|
|
911
|
+
.map((id) => ({ instanceId: id, ...widgetFacts(id), pinned: true }));
|
|
674
912
|
const open = typeof p.open === 'string' && tabs.some((t) => t.instanceId === p.open) ? p.open : (tabs[0]?.instanceId ?? '');
|
|
913
|
+
const decl = decls.get(tabs.find((t) => t.instanceId === open)?.widgetId ?? '')?.panel;
|
|
914
|
+
const declHeight = isObj(decl) && (decl.height === 'fit' || decl.height === 'fill') ? decl.height : undefined;
|
|
915
|
+
const declPriority = isObj(decl) && isPriority(decl.priority) ? decl.priority : undefined;
|
|
675
916
|
return {
|
|
676
917
|
key: typeof p.key === 'string' ? p.key : '',
|
|
677
918
|
tabs,
|
|
678
919
|
open,
|
|
679
|
-
pinned,
|
|
680
|
-
height:
|
|
920
|
+
pinned: true,
|
|
921
|
+
height: validHeight(p.height) ?? declHeight ?? 'fill',
|
|
922
|
+
priority: isPriority(p.priority) ? p.priority : (declPriority ?? 'normal'),
|
|
681
923
|
...(typeof p.title === 'string' ? { title: p.title } : {}),
|
|
924
|
+
...(floorKeys.has(p.key) ? { floor: true } : {}),
|
|
682
925
|
};
|
|
683
926
|
};
|
|
684
|
-
const
|
|
685
|
-
|
|
686
|
-
const above = drawn(panelList(panels.middle.above).map((p) => draw(p, true)));
|
|
687
|
-
const primary = { ...draw(panels.middle.primary, true), ...(floor ? { floor: true } : {}) };
|
|
688
|
-
const below = drawn(panelList(panels.middle.below).map((p) => draw(p, true)));
|
|
689
|
-
const middlePanels = [...above, primary, ...below];
|
|
690
|
-
const middle = {
|
|
691
|
-
zone: 'middle',
|
|
692
|
-
kind: 'middle',
|
|
693
|
-
pinned: true,
|
|
694
|
-
panels: middlePanels,
|
|
695
|
-
instances: middlePanels.filter((p) => !p.floor).flatMap((p) => p.tabs),
|
|
696
|
-
above,
|
|
697
|
-
primary,
|
|
698
|
-
below,
|
|
699
|
-
};
|
|
700
|
-
// The sides.
|
|
701
|
-
const defs = zoneEntries(doc);
|
|
702
|
-
const side = (edge) => {
|
|
703
|
-
const own = drawn(panelList(panels[edge]).map((p) => draw(p, pinnedOf(p))));
|
|
704
|
-
const zone = defs.find(([, d]) => d.kind !== 'strip' && zoneDrawnAt(d) === edge);
|
|
705
|
-
const def = zone?.[1];
|
|
706
|
-
const pinned = own.length ? own.some((p) => p.pinned) : def ? pinnedOf(def) : true;
|
|
707
|
-
const rung = zoneRungAt({ ...(def ?? { kind: 'side', side: edge, widgets: [] }), pinned }, inline);
|
|
927
|
+
const zone = (z) => {
|
|
928
|
+
const own = panelList(panels[z]).map(draw).filter((p) => p.tabs.length > 0);
|
|
708
929
|
return {
|
|
709
|
-
zone:
|
|
710
|
-
kind: 'side',
|
|
711
|
-
side:
|
|
712
|
-
|
|
713
|
-
pinned,
|
|
714
|
-
rung,
|
|
930
|
+
zone: z,
|
|
931
|
+
kind: z === 'middle' ? 'middle' : 'side',
|
|
932
|
+
...(z === 'middle' ? {} : { side: z }),
|
|
933
|
+
pinned: true,
|
|
715
934
|
panels: own,
|
|
716
|
-
instances: own.flatMap((p) => p.tabs),
|
|
935
|
+
instances: own.filter((p) => !p.floor).flatMap((p) => p.tabs),
|
|
717
936
|
};
|
|
718
937
|
};
|
|
719
|
-
|
|
720
|
-
const
|
|
721
|
-
|
|
938
|
+
// Reading order is middle, left, right: the draw order decides who keeps a repeated id.
|
|
939
|
+
const middle = zone('middle');
|
|
940
|
+
const left = zone('left');
|
|
941
|
+
const right = zone('right');
|
|
942
|
+
return { left, middle, right, look: lookOf(doc) };
|
|
722
943
|
}
|
|
723
944
|
/** Every instance a drawn layout draws, in its reading order: middle, left, right — the floor's left out. @experimental */
|
|
724
945
|
export function drawnInstances(drawn) {
|
|
725
946
|
return [...drawn.middle.instances, ...drawn.left.instances, ...drawn.right.instances];
|
|
726
947
|
}
|
|
727
948
|
/**
|
|
728
|
-
* Every widget instance id the layout DRAWS, in reading order — the middle
|
|
729
|
-
*
|
|
949
|
+
* Every widget instance id the layout DRAWS, in reading order — the middle,
|
|
950
|
+
* left, right: {@link resolveDrawn}'s answer as ids.
|
|
730
951
|
* A retired widget is never drawn, and the floor's conversation is not the
|
|
731
952
|
* layout's.
|
|
732
953
|
* @experimental
|
|
@@ -767,12 +988,18 @@ function isAnchor(x) {
|
|
|
767
988
|
* the verdict lists every problem rather than the first.
|
|
768
989
|
*
|
|
769
990
|
* **Errors** (the layout is refused):
|
|
770
|
-
* - `panels` of the wrong shape: `{ version:
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
*
|
|
775
|
-
*
|
|
991
|
+
* - `panels` of the wrong shape: `{ version: 2, left, middle, right,
|
|
992
|
+
* backing?, opacity?, gap? }`, each zone a list of panels top to bottom
|
|
993
|
+
* and the middle never empty; version 1's `{ version: 1, left, middle: {
|
|
994
|
+
* above, primary, below }, right }` is still checked (and warned about);
|
|
995
|
+
* any other version is refused. A panel has a key no other panel has, at
|
|
996
|
+
* least one tab, `open` one of its tabs, `height` `fit`, `fill` or `{ share }`
|
|
997
|
+
* (an integer 1–12); in version 2 `priority` is `high`, `normal` or `low`
|
|
998
|
+
* and `pinned` is refused (there is no pin), `backing` is `card`, `glass`
|
|
999
|
+
* or `none`, `opacity` a number from 0 to 100, `gap` `tight`,
|
|
1000
|
+
* `comfortable` or `spacious`, `behind` `background` or `backdrop`,
|
|
1001
|
+
* `behindDim` a number from 0 to 100; in version 1 `pinned` is absent or `false`,
|
|
1002
|
+
* refused on a middle panel. An instance id in two panels, or twice in one;
|
|
776
1003
|
* - an ⏳ old slot of the wrong shape: `zoneLayout` and `widgetGrid` are `version: 1`;
|
|
777
1004
|
* a grid entry and an arrangement name a zone, `left`, `middle` or
|
|
778
1005
|
* `right`; a `zoneLayout` zone is keyed by where the page draws it — a
|
|
@@ -792,6 +1019,10 @@ function isAnchor(x) {
|
|
|
792
1019
|
*
|
|
793
1020
|
* **Warnings** (the layout draws, not as written):
|
|
794
1021
|
* - a key that is not a slot (readers ignore it) and a retired widget;
|
|
1022
|
+
* - `panels-v1:` — version 1 panels are converted on read ({@link panelsV2Of});
|
|
1023
|
+
* ship version 2;
|
|
1024
|
+
* - in the old slots, a placed copy of a {@link LEGACY_SLOT_DROPPED} widget (a
|
|
1025
|
+
* slot-era composer): the slots never draw it;
|
|
795
1026
|
* - `panels` that place no copy of the conversation: the session draws one
|
|
796
1027
|
* by the primary floor — unless the genre withholds it, which the genre's
|
|
797
1028
|
* own checks judge (a layout carries no roles);
|
|
@@ -1011,9 +1242,10 @@ export function validateSessionLayout(layout, opts = {}) {
|
|
|
1011
1242
|
const panelPlaced = new Map();
|
|
1012
1243
|
if (pl !== undefined) {
|
|
1013
1244
|
const keys = new Set();
|
|
1245
|
+
const v2 = isObj(pl) && pl.version === 2;
|
|
1014
1246
|
const panel = (p, zone, at, middle) => {
|
|
1015
1247
|
if (!isObj(p))
|
|
1016
|
-
return errors.push(`${at}: a panel is an object — { key, tabs, open?, pinned
|
|
1248
|
+
return errors.push(`${at}: a panel is an object — { key, tabs, open?, ${v2 ? 'priority?' : 'pinned?'}, height?, title? }`);
|
|
1017
1249
|
if (typeof p.key !== 'string' || !p.key)
|
|
1018
1250
|
errors.push(`${at}.key: a non-empty string`);
|
|
1019
1251
|
else if (keys.has(p.key))
|
|
@@ -1035,11 +1267,15 @@ export function validateSessionLayout(layout, opts = {}) {
|
|
|
1035
1267
|
if (p.open !== undefined && !(typeof p.open === 'string' && Array.isArray(p.tabs) && p.tabs.includes(p.open)))
|
|
1036
1268
|
errors.push(`${at}.open: one of its tabs`);
|
|
1037
1269
|
if (p.pinned !== undefined) {
|
|
1038
|
-
if (
|
|
1270
|
+
if (v2)
|
|
1271
|
+
errors.push(`${at}.pinned: there is no pin in version 2 — every panel is open; leave it out`);
|
|
1272
|
+
else if (middle)
|
|
1039
1273
|
errors.push(`${at}.pinned: a middle panel never pins — leave it out`);
|
|
1040
1274
|
else if (p.pinned !== false)
|
|
1041
1275
|
errors.push(`${at}.pinned: absent (docked) or false (in the rail)`);
|
|
1042
1276
|
}
|
|
1277
|
+
if (v2 && p.priority !== undefined && !isPriority(p.priority))
|
|
1278
|
+
errors.push(`${at}.priority: 'high', 'normal' or 'low'`);
|
|
1043
1279
|
const h = p.height;
|
|
1044
1280
|
if (h !== undefined && h !== 'fit' && h !== 'fill' && !(isObj(h) && isInt(h.share) && h.share >= 1 && h.share <= 12))
|
|
1045
1281
|
errors.push(`${at}.height: 'fit', 'fill' or { share } — a whole number of twelfths, 1 to 12`);
|
|
@@ -1051,9 +1287,33 @@ export function validateSessionLayout(layout, opts = {}) {
|
|
|
1051
1287
|
return errors.push(`${at}: a list of panels, top to bottom`);
|
|
1052
1288
|
x.forEach((p, n) => panel(p, zone, `${at}[${n}]`, middle));
|
|
1053
1289
|
};
|
|
1054
|
-
if (!isObj(pl) || pl.version !== 1)
|
|
1055
|
-
errors.push('panels: { version:
|
|
1290
|
+
if (!isObj(pl) || (pl.version !== 1 && pl.version !== 2))
|
|
1291
|
+
errors.push('panels: { version: 2, left: [ … ], middle: [ … ], right: [ … ], backing?, opacity?, gap? } — or version 1, ' +
|
|
1292
|
+
'{ version: 1, left: [ … ], middle: { above: [ … ], primary: { … }, below: [ … ] }, right: [ … ] }');
|
|
1293
|
+
else if (pl.version === 2) {
|
|
1294
|
+
if (![pl.left, pl.middle, pl.right].every(Array.isArray))
|
|
1295
|
+
errors.push('panels: { version: 2, left: [ … ], middle: [ … ], right: [ … ], backing?, opacity?, gap? }');
|
|
1296
|
+
if (isObj(pl.middle) || 'above' in pl || 'primary' in pl || 'below' in pl)
|
|
1297
|
+
errors.push("panels.middle: one list of panels, top to bottom — above / primary / below are version 1's");
|
|
1298
|
+
if (!isObj(pl.middle))
|
|
1299
|
+
list(pl.middle, 'middle', 'panels.middle', true);
|
|
1300
|
+
if (Array.isArray(pl.middle) && pl.middle.length === 0)
|
|
1301
|
+
errors.push('panels.middle: the middle is never empty — at least one panel');
|
|
1302
|
+
list(pl.left, 'left', 'panels.left', false);
|
|
1303
|
+
list(pl.right, 'right', 'panels.right', false);
|
|
1304
|
+
if (pl.backing !== undefined && !isBacking(pl.backing))
|
|
1305
|
+
errors.push("panels.backing: 'card', 'glass' or 'none'");
|
|
1306
|
+
if (pl.opacity !== undefined && !(typeof pl.opacity === 'number' && Number.isFinite(pl.opacity) && pl.opacity >= 0 && pl.opacity <= 100))
|
|
1307
|
+
errors.push('panels.opacity: a number from 0 to 100');
|
|
1308
|
+
if (pl.gap !== undefined && !isGap(pl.gap))
|
|
1309
|
+
errors.push("panels.gap: 'tight', 'comfortable' or 'spacious'");
|
|
1310
|
+
if (pl.behind !== undefined && pl.behind !== 'background' && pl.behind !== 'backdrop')
|
|
1311
|
+
errors.push("panels.behind: 'background' or 'backdrop'");
|
|
1312
|
+
if (pl.behindDim !== undefined && !(typeof pl.behindDim === 'number' && Number.isFinite(pl.behindDim) && pl.behindDim >= 0 && pl.behindDim <= 100))
|
|
1313
|
+
errors.push('panels.behindDim: a number from 0 to 100');
|
|
1314
|
+
}
|
|
1056
1315
|
else {
|
|
1316
|
+
warnings.push('panels-v1: version 1 panels are converted on read (panelsV2Of) — ship { version: 2, … }');
|
|
1057
1317
|
const mid = pl.middle;
|
|
1058
1318
|
if (!isObj(mid))
|
|
1059
1319
|
errors.push('panels.middle: { above: [ … ], primary: { key, tabs }, below: [ … ] }');
|
|
@@ -1064,9 +1324,9 @@ export function validateSessionLayout(layout, opts = {}) {
|
|
|
1064
1324
|
}
|
|
1065
1325
|
list(pl.left, 'left', 'panels.left', false);
|
|
1066
1326
|
list(pl.right, 'right', 'panels.right', false);
|
|
1067
|
-
if (![...panelPlaced.keys()].some((id) => isInstanceOf(id, CONVERSATION) && !retired(id)))
|
|
1068
|
-
warnings.push(`panels place no copy of the conversation ('${CONVERSATION}') — a session draws one anyway (the primary floor), unless its genre withholds it for a role: 'primary' widget`);
|
|
1069
1327
|
}
|
|
1328
|
+
if (isObj(pl) && (pl.version === 1 || pl.version === 2) && ![...panelPlaced.keys()].some((id) => isInstanceOf(id, CONVERSATION) && !retired(id)))
|
|
1329
|
+
warnings.push(`panels place no copy of the conversation ('${CONVERSATION}') — a session draws one anyway (the primary floor), unless its genre withholds it for a role: 'primary' widget`);
|
|
1070
1330
|
}
|
|
1071
1331
|
// Warnings: what draws, but not as written.
|
|
1072
1332
|
const drawn = new Set(drawnWidgetIds(layout));
|
|
@@ -1081,6 +1341,10 @@ export function validateSessionLayout(layout, opts = {}) {
|
|
|
1081
1341
|
warnings.push(`'${id}' names a retired widget — no reader draws it`);
|
|
1082
1342
|
continue;
|
|
1083
1343
|
}
|
|
1344
|
+
if (!storedPanels(layout) && LEGACY_SLOT_DROPPED.has(widgetOfInstance(id))) {
|
|
1345
|
+
warnings.push(`'${id}' is a slot-era composer — the old slots never draw it; place the Composer in panels`);
|
|
1346
|
+
continue;
|
|
1347
|
+
}
|
|
1084
1348
|
if (drawn.has(id))
|
|
1085
1349
|
continue;
|
|
1086
1350
|
// Named, and never drawn: the page reads each zone one way
|