@serene-pub/sdk 0.6.0-pr-2 → 0.6.0-pr-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/README.md +24 -20
- package/dist/actions.d.ts +150 -68
- package/dist/actions.js +90 -36
- package/dist/annexFields.d.ts +8 -4
- package/dist/annexFields.js +5 -2
- package/dist/announce.d.ts +78 -28
- package/dist/announce.js +14 -5
- package/dist/attributes.d.ts +9 -6
- package/dist/attributes.js +9 -5
- package/dist/bands.d.ts +41 -6
- package/dist/bands.js +83 -33
- package/dist/builder.d.ts +161 -58
- package/dist/builder.js +128 -22
- package/dist/candidates.d.ts +5 -3
- package/dist/candidates.js +3 -2
- package/dist/clauses.d.ts +2 -1
- package/dist/clauses.js +2 -1
- package/dist/component.d.ts +24 -7
- package/dist/component.js +16 -6
- package/dist/componentBuild.d.ts +16 -5
- package/dist/componentBuild.js +14 -5
- package/dist/componentClient.d.ts +61 -30
- package/dist/componentClient.js +11 -1
- package/dist/componentImports.d.ts +8 -5
- package/dist/componentImports.js +23 -4
- package/dist/componentModule.js +2 -1
- package/dist/componentWire.d.ts +2 -1
- package/dist/componentWire.js +34 -2
- package/dist/config.d.ts +28 -14
- package/dist/config.js +20 -10
- package/dist/connections.d.ts +9 -4
- package/dist/connections.js +7 -4
- package/dist/declarations.d.ts +46 -17
- package/dist/declarations.js +46 -15
- package/dist/descriptors.d.ts +242 -97
- package/dist/descriptors.js +145 -41
- package/dist/dev.d.ts +6 -5
- package/dist/dev.js +6 -5
- package/dist/document.d.ts +74 -25
- package/dist/document.js +32 -11
- package/dist/dowry.d.ts +241 -0
- package/dist/dowry.js +315 -0
- package/dist/engines.d.ts +16 -7
- package/dist/engines.js +6 -4
- package/dist/eventMapLaws.d.ts +19 -8
- package/dist/eventMapLaws.js +9 -6
- package/dist/events.d.ts +101 -39
- package/dist/events.js +106 -33
- package/dist/executor.d.ts +122 -41
- package/dist/executor.js +195 -96
- package/dist/extension.d.ts +99 -35
- package/dist/extension.js +43 -9
- package/dist/facets.d.ts +2 -1
- package/dist/facets.js +4 -2
- package/dist/foldedSections.d.ts +4 -2
- package/dist/foldedSections.js +2 -1
- package/dist/genres.d.ts +123 -41
- package/dist/genres.js +127 -22
- package/dist/guardedConnection.d.ts +4 -3
- package/dist/guardedConnection.js +4 -3
- package/dist/handlebarsReach.d.ts +1 -1
- package/dist/handlebarsReach.js +1 -1
- package/dist/hash.d.ts +16 -5
- package/dist/hash.js +14 -4
- package/dist/hookGrants.d.ts +3 -2
- package/dist/hookGrants.js +6 -4
- package/dist/hooks.d.ts +21 -16
- package/dist/hooks.js +12 -10
- package/dist/hostElements.d.ts +41 -17
- package/dist/hostElements.js +49 -17
- package/dist/i18n.d.ts +5 -3
- package/dist/i18n.js +5 -3
- package/dist/identity.d.ts +5 -4
- package/dist/identity.js +5 -4
- package/dist/index.d.ts +5 -0
- package/dist/index.js +15 -0
- package/dist/layout.d.ts +36 -15
- package/dist/layout.js +2 -2
- package/dist/loadouts.d.ts +97 -0
- package/dist/loadouts.js +81 -0
- package/dist/media.d.ts +26 -4
- package/dist/media.js +2 -1
- package/dist/messageBlocks.d.ts +44 -32
- package/dist/messageBlocks.js +23 -18
- package/dist/migration.d.ts +16 -8
- package/dist/migration.js +14 -8
- package/dist/names.d.ts +2 -1
- package/dist/names.js +2 -1
- package/dist/nodeInput.d.ts +2 -1
- package/dist/nodeInput.js +2 -1
- package/dist/participants.d.ts +22 -15
- package/dist/participants.js +14 -12
- package/dist/personGate.d.ts +2 -1
- package/dist/personGate.js +2 -1
- package/dist/pluginHarness.d.ts +8 -3
- package/dist/pluginHarness.js +4 -2
- package/dist/pluginPermissions.d.ts +2 -1
- package/dist/pluginPermissions.js +12 -1
- package/dist/pluginRuleRef.d.ts +2 -2
- package/dist/pluginRuleRef.js +1 -1
- package/dist/predicates.d.ts +16 -11
- package/dist/predicates.js +7 -6
- package/dist/preview.d.ts +8 -3
- package/dist/preview.js +2 -1
- package/dist/promptBlocks.d.ts +5 -3
- package/dist/promptBlocks.js +5 -3
- package/dist/rankingDecisions.d.ts +2 -1
- package/dist/rankingDecisions.js +2 -1
- package/dist/receipt.d.ts +65 -29
- package/dist/receipt.js +9 -4
- package/dist/receiverRules.js +3 -2
- package/dist/refs.d.ts +34 -9
- package/dist/refs.js +33 -13
- package/dist/registry.d.ts +42 -23
- package/dist/registry.js +7 -5
- package/dist/review.d.ts +16 -5
- package/dist/review.js +11 -4
- package/dist/sampling.d.ts +54 -0
- package/dist/sampling.js +95 -3
- package/dist/sceneSettings.d.ts +312 -0
- package/dist/sceneSettings.js +425 -0
- package/dist/scope.d.ts +6 -4
- package/dist/scope.js +4 -3
- package/dist/scripts.d.ts +81 -14
- package/dist/scripts.js +90 -11
- package/dist/sessionDossier.d.ts +521 -0
- package/dist/sessionDossier.js +33 -0
- package/dist/sessionLayout.d.ts +303 -19
- package/dist/sessionLayout.js +354 -40
- package/dist/sessionSettings.d.ts +8 -5
- package/dist/settings.d.ts +45 -20
- package/dist/settings.js +19 -12
- package/dist/settingsSlot.d.ts +11 -8
- package/dist/settingsSlot.js +11 -8
- package/dist/shapes.d.ts +103 -41
- package/dist/shapes.js +105 -40
- package/dist/sheets.d.ts +4 -2
- package/dist/sheets.js +6 -3
- package/dist/statShapes.d.ts +2 -1
- package/dist/statShapes.js +2 -1
- package/dist/status.d.ts +13 -9
- package/dist/status.js +8 -6
- package/dist/storage.d.ts +2 -1
- package/dist/storage.js +2 -1
- package/dist/storyTime.d.ts +13 -7
- package/dist/storyTime.js +11 -6
- package/dist/strokes.d.ts +176 -0
- package/dist/strokes.js +281 -0
- package/dist/surfaces.d.ts +54 -25
- package/dist/surfaces.js +3 -3
- package/dist/template.d.ts +9 -5
- package/dist/template.js +5 -3
- package/dist/templateCheck.d.ts +2 -2
- package/dist/templateCheck.js +2 -2
- package/dist/templateFit.d.ts +37 -8
- package/dist/templateFit.js +92 -8
- package/dist/templateIds.d.ts +3 -3
- package/dist/templateIds.js +3 -3
- package/dist/templateScopeAt.d.ts +21 -11
- package/dist/templateScopeAt.js +21 -11
- package/dist/testing.d.ts +11 -4
- package/dist/testing.js +13 -5
- package/dist/tokenizers.d.ts +2 -2
- package/dist/tokenizers.js +2 -2
- package/dist/turnLock.d.ts +4 -2
- package/dist/turnLock.js +2 -1
- package/dist/turnOrder.d.ts +17 -11
- package/dist/turnOrder.js +9 -5
- package/dist/validate.d.ts +11 -8
- package/dist/validate.js +81 -10
- package/dist/values.d.ts +17 -8
- package/dist/values.js +11 -6
- package/dist/variables.d.ts +46 -7
- package/dist/variables.js +87 -6
- package/dist/verdicts.d.ts +20 -13
- package/dist/verdicts.js +17 -11
- package/dist/widgetDecls.d.ts +8 -4
- package/dist/widgetDecls.js +4 -2
- package/dist/widgets.d.ts +987 -94
- package/dist/widgets.js +93 -18
- package/dist/wire.d.ts +13 -6
- package/dist/wire.js +3 -3
- package/dist/worldinfo.d.ts +11 -6
- package/dist/worldinfo.js +8 -4
- package/host-elements.d.ts +13 -0
- package/package.json +1 -1
package/dist/sessionLayout.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The **session layout** (`SessionLayoutV1
|
|
2
|
+
* The **session layout** (`SessionLayoutV1`) — the ONE layout
|
|
3
3
|
* format: what the screen draws, what a person arranges, what a genre or a
|
|
4
4
|
* plugin ships (`GenreLayoutDecl.preset`), and what a **session layout preset**
|
|
5
5
|
* row stores. Plain JSON, stored verbatim; every reader reads it defensively,
|
|
@@ -17,6 +17,13 @@
|
|
|
17
17
|
* - `arrangedGrid` — the arrangement per zone: whole grid cells (`cols` ×
|
|
18
18
|
* `rows`) and each widget's cell box. Where a zone has one, it is what draws.
|
|
19
19
|
*
|
|
20
|
+
* Three slots can name one zone, so what the screen DRAWS is a reading of
|
|
21
|
+
* them, and there is one: {@link resolveDrawn} (→ {@link DrawnLayout}) decides
|
|
22
|
+
* which slot draws each zone, drops retired widgets, gives every placed
|
|
23
|
+
* instance one pin ({@link pinnedOf}: absent means pinned) and walks each
|
|
24
|
+
* side's width ladder ({@link zoneRungAt}). The id readers that ask "is it
|
|
25
|
+
* drawn" ({@link drawnWidgetIds}, {@link primaryPlaced}) are that answer.
|
|
26
|
+
*
|
|
20
27
|
* A named layout adds `widgetSettings` and `widgetStyles` (per-instance values
|
|
21
28
|
* and style pins), so one blob is the portable layout. A session keeps those
|
|
22
29
|
* two in its own rows instead, and its row adds the surface manager's
|
|
@@ -40,6 +47,7 @@
|
|
|
40
47
|
* package SHIPS ({@link validateSessionLayout}), where refusing is right. No
|
|
41
48
|
* `svelte` import, ever: a linked package that imports svelte gives the app a
|
|
42
49
|
* second Svelte.
|
|
50
|
+
* @ruling NOMENCLATURE §9
|
|
43
51
|
*/
|
|
44
52
|
import { parsePluginWidgetId } from './surfaces.js';
|
|
45
53
|
// ── Zones ───────────────────────────────────────────────────────────────────
|
|
@@ -52,16 +60,34 @@ export const INSTANCE_NAME_SEPARATOR = '#';
|
|
|
52
60
|
export const INSTANCE_NAME = /^[a-z0-9][a-z0-9-]{0,31}$/;
|
|
53
61
|
/** Core's widget id grammar — the bare half a package never namespaces. */
|
|
54
62
|
const CORE_WIDGET_ID = /^[a-z][a-z0-9-]*$/;
|
|
55
|
-
/** The widget a placed id
|
|
56
|
-
|
|
63
|
+
/** The widget half of a placed id as written — the id up to its `#`, else the id — before any alias. */
|
|
64
|
+
function writtenWidgetOf(instanceId) {
|
|
57
65
|
const at = instanceId.indexOf(INSTANCE_NAME_SEPARATOR);
|
|
58
66
|
return at > 0 ? instanceId.slice(0, at) : instanceId;
|
|
59
67
|
}
|
|
60
|
-
/** The instance name
|
|
61
|
-
|
|
68
|
+
/** The instance name half as written (`2` of `world-state#2`), before any alias. */
|
|
69
|
+
function writtenNameOf(instanceId) {
|
|
62
70
|
const at = instanceId.indexOf(INSTANCE_NAME_SEPARATOR);
|
|
63
71
|
return at > 0 && at < instanceId.length - 1 ? instanceId.slice(at + 1) : null;
|
|
64
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* The widget a placed id is a copy of: the id up to its `#`, else the id —
|
|
75
|
+
* read through {@link WIDGET_ID_ALIASES}, so `world-state` is a copy of
|
|
76
|
+
* `stats`. @experimental
|
|
77
|
+
*/
|
|
78
|
+
export function widgetOfInstance(instanceId) {
|
|
79
|
+
return resolveWidgetAlias(instanceId).widgetId;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The instance name of a copy (`sanctum` of `messages#sanctum`), or `null` for
|
|
83
|
+
* the widget itself. An aliased id answers the name it reads as
|
|
84
|
+
* (`world-state` → `world`, {@link resolveWidgetAlias}), so the pair
|
|
85
|
+
* {@link widgetOfInstance} · `instanceNameOf` always names one copy.
|
|
86
|
+
* @experimental
|
|
87
|
+
*/
|
|
88
|
+
export function instanceNameOf(instanceId) {
|
|
89
|
+
return writtenNameOf(resolveWidgetAlias(instanceId).instanceId);
|
|
90
|
+
}
|
|
65
91
|
/** Is this placed id a copy of `widgetId` — the widget itself or one of its instances? @experimental */
|
|
66
92
|
export function isInstanceOf(instanceId, widgetId) {
|
|
67
93
|
return widgetOfInstance(instanceId) === widgetId;
|
|
@@ -91,7 +117,7 @@ export function isWidgetInstanceId(id) {
|
|
|
91
117
|
* field are one thing to arrange, and the field's shape is a setting on
|
|
92
118
|
* `messages` rather than a widget beside it.
|
|
93
119
|
*
|
|
94
|
-
* `inventory` is one because
|
|
120
|
+
* `inventory` is one because core's Inventory widget was removed (2026-09-25)
|
|
95
121
|
* for now, with no replacement. Adventure and Lair shipped it, so layouts and
|
|
96
122
|
* presets saved from them name it; dropping it here is what makes such a
|
|
97
123
|
* layout open on the widgets it still has — nothing drawn in its place, no
|
|
@@ -99,8 +125,65 @@ export function isWidgetInstanceId(id) {
|
|
|
99
125
|
* the stats widget draws as a list. Take it off this list if the widget comes
|
|
100
126
|
* back.
|
|
101
127
|
* @experimental
|
|
128
|
+
* @ruling R79
|
|
102
129
|
*/
|
|
103
130
|
export const RETIRED_WIDGET_IDS = new Set(['composer', 'inventory']);
|
|
131
|
+
/**
|
|
132
|
+
* ⏳ Widget ids that are another widget now — an ALIAS, not a retirement: a
|
|
133
|
+
* stored layout, preset or arrangement that places one keeps drawing what it
|
|
134
|
+
* drew, as a copy of the widget it became with the settings it meant
|
|
135
|
+
* ({@link resolveWidgetAlias}). Every id reader goes through it
|
|
136
|
+
* ({@link widgetOfInstance}, {@link resolveDrawn}, {@link validateSessionLayout}),
|
|
137
|
+
* so an aliased id is neither retired nor unknown.
|
|
138
|
+
*
|
|
139
|
+
* `world-state` is one since the Stats uplift: World State was Stats drawn for the world, as a strip — one
|
|
140
|
+
* capability, so one widget, with `owners` and `arrangement` settings. A
|
|
141
|
+
* layout written today places `stats#world` with those settings itself (and
|
|
142
|
+
* `title: 'World State'`, as core's shipped layouts do).
|
|
143
|
+
* REMOVE in 0.7.0, with the `world-state` declaration (rewritten layouts
|
|
144
|
+
* have had a release to land).
|
|
145
|
+
* @experimental
|
|
146
|
+
* @ruling PLAN-core-widgets W7 (2026-10-11)
|
|
147
|
+
*/
|
|
148
|
+
export const WIDGET_ID_ALIASES = Object.freeze({
|
|
149
|
+
'world-state': Object.freeze({
|
|
150
|
+
id: 'stats',
|
|
151
|
+
instanceName: 'world',
|
|
152
|
+
// `title` is core's own setting (every widget has one): an existing
|
|
153
|
+
// placed World State keeps its name rather than reading "Stats".
|
|
154
|
+
settings: Object.freeze({ owners: 'world', arrangement: 'strip', title: 'World State' }),
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
const NO_SETTINGS = Object.freeze({});
|
|
158
|
+
/** An instance name cut to {@link INSTANCE_NAME}'s length, never ending on a `-`. */
|
|
159
|
+
const nameWithin = (name) => name.slice(0, 32).replace(/-+$/, '');
|
|
160
|
+
/**
|
|
161
|
+
* Read a placed id through {@link WIDGET_ID_ALIASES}. An id that is no alias
|
|
162
|
+
* answers itself, its widget and no settings.
|
|
163
|
+
*
|
|
164
|
+
* The id it reads as is stable — `world-state` is always `stats#world`,
|
|
165
|
+
* `world-state#n` always `stats#world-n` — and, given the ids already placed
|
|
166
|
+
* (`taken`), collision-safe: one a layout already places is skipped for the
|
|
167
|
+
* next free `-2`, `-3`… So a caller rewriting a layout passes every id it
|
|
168
|
+
* places.
|
|
169
|
+
* @experimental
|
|
170
|
+
*/
|
|
171
|
+
export function resolveWidgetAlias(instanceId, taken) {
|
|
172
|
+
const written = writtenWidgetOf(instanceId);
|
|
173
|
+
const alias = Object.hasOwn(WIDGET_ID_ALIASES, written) ? WIDGET_ID_ALIASES[written] : undefined;
|
|
174
|
+
if (!alias)
|
|
175
|
+
return { widgetId: written, instanceId, impliedSettings: NO_SETTINGS, aliasedFrom: null };
|
|
176
|
+
const own = writtenNameOf(instanceId);
|
|
177
|
+
const name = nameWithin(own ? `${alias.instanceName}-${own}` : alias.instanceName);
|
|
178
|
+
let canonical = `${alias.id}${INSTANCE_NAME_SEPARATOR}${name}`;
|
|
179
|
+
if (taken) {
|
|
180
|
+
const placed = new Set(taken);
|
|
181
|
+
placed.delete(instanceId);
|
|
182
|
+
for (let n = 2; placed.has(canonical); n++)
|
|
183
|
+
canonical = `${alias.id}${INSTANCE_NAME_SEPARATOR}${nameWithin(name.slice(0, 32 - `-${n}`.length))}-${n}`;
|
|
184
|
+
}
|
|
185
|
+
return { widgetId: alias.id, instanceId: canonical, impliedSettings: alias.settings, aliasedFrom: written };
|
|
186
|
+
}
|
|
104
187
|
// ── Reading ids ─────────────────────────────────────────────────────────────
|
|
105
188
|
const isObj = (x) => !!x && typeof x === 'object' && !Array.isArray(x);
|
|
106
189
|
const strings = (x) => Array.isArray(x) ? x.filter((s) => typeof s === 'string') : [];
|
|
@@ -169,51 +252,278 @@ export function middleWidgetIds(layout) {
|
|
|
169
252
|
return [...new Set([...gridIn(layout, 'middle'), ...(arrangedIn(layout, 'middle') ?? [])])];
|
|
170
253
|
}
|
|
171
254
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
255
|
+
* The width ladder a side zone walks when it declares no `rules` of its own:
|
|
256
|
+
* an overlay drawer below the rail rung, a docked rail above it, wider and
|
|
257
|
+
* then two columns on a very wide box. The left docks later than the right,
|
|
258
|
+
* because the right is where a fresh session's widgets land.
|
|
259
|
+
*
|
|
260
|
+
* From 1200 to 1440 — where the left has just docked beside the right — each
|
|
261
|
+
* side's rail is 248px rather than 264, so two docked columns, their gaps and
|
|
262
|
+
* the stage's 696px measure fit a 1216px session box (a 1280 window):
|
|
263
|
+
* 248 + 248 + 2×8 + 696 = 1208. At 264 they needed 1240 and both sides tucked.
|
|
264
|
+
* @experimental
|
|
265
|
+
*/
|
|
266
|
+
export const DEFAULT_SIDE_RULES = {
|
|
267
|
+
right: [
|
|
268
|
+
{ min: 0, mode: 'drawer', width: 320 },
|
|
269
|
+
{ min: 760, mode: 'rail', width: 264 },
|
|
270
|
+
{ min: 1200, width: 248 },
|
|
271
|
+
{ min: 1440, width: 264 },
|
|
272
|
+
{ min: 1900, width: 300 },
|
|
273
|
+
{ min: 2400, width: 344, columns: 2 },
|
|
274
|
+
],
|
|
275
|
+
left: [
|
|
276
|
+
{ min: 0, mode: 'drawer', width: 320 },
|
|
277
|
+
{ min: 1200, mode: 'rail', width: 248 },
|
|
278
|
+
{ min: 1440, width: 264 },
|
|
279
|
+
{ min: 1900, width: 300 },
|
|
280
|
+
{ min: 2400, width: 344, columns: 2 },
|
|
281
|
+
],
|
|
282
|
+
};
|
|
283
|
+
/** The width ladder a strip walks when it declares none: always a row. @experimental */
|
|
284
|
+
export const DEFAULT_STRIP_RULES = [{ min: 0, mode: 'row' }];
|
|
285
|
+
/**
|
|
286
|
+
* A zone's width ladder at `inline` px — its own `rules`, else the default
|
|
287
|
+
* ladder for where it is drawn ({@link DEFAULT_SIDE_RULES},
|
|
288
|
+
* {@link DEFAULT_STRIP_RULES}) — with the pin refinement {@link ZoneRung}
|
|
289
|
+
* describes. The one walk: the page's rails, the editor's simulator and
|
|
290
|
+
* {@link resolveDrawn} all read a ladder through it.
|
|
291
|
+
* @experimental
|
|
292
|
+
*/
|
|
293
|
+
export function zoneRungAt(def, inline) {
|
|
294
|
+
const strip = def.kind === 'strip';
|
|
295
|
+
const own = Array.isArray(def.rules)
|
|
296
|
+
? def.rules.filter((r) => isObj(r) && typeof r.min === 'number')
|
|
297
|
+
: null;
|
|
298
|
+
const rules = own ?? (strip ? DEFAULT_STRIP_RULES : DEFAULT_SIDE_RULES[def.side === 'left' ? 'left' : 'right']);
|
|
299
|
+
const out = { mode: 'row', width: 264, columns: 1 };
|
|
300
|
+
for (const rule of [...rules].sort((a, b) => a.min - b.min)) {
|
|
301
|
+
if (inline < rule.min)
|
|
302
|
+
break;
|
|
303
|
+
if (rule.mode !== undefined)
|
|
304
|
+
out.mode = rule.mode;
|
|
305
|
+
if (rule.width !== undefined)
|
|
306
|
+
out.width = rule.width;
|
|
307
|
+
if (rule.columns !== undefined)
|
|
308
|
+
out.columns = rule.columns;
|
|
309
|
+
}
|
|
310
|
+
if (strip) {
|
|
311
|
+
if (out.mode !== 'hidden')
|
|
312
|
+
out.mode = 'row';
|
|
313
|
+
}
|
|
314
|
+
else if (out.mode === 'rail' && def.pinned === false)
|
|
315
|
+
out.mode = 'icons';
|
|
316
|
+
return out;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Is this placement pinned? **Absent means pinned; `false` is the only value
|
|
320
|
+
* that unpins.** The ONE pin rule of the session layout, for every slot that
|
|
321
|
+
* carries the field — an arranged item, a grid entry and a zone — so a layout
|
|
322
|
+
* saved before a slot had the field reads exactly as it drew: docked.
|
|
323
|
+
* Anything that is not `false` (a missing field, `true`, junk) is pinned.
|
|
324
|
+
*
|
|
325
|
+
* What a pin means is where it sits: an arranged item's or a grid entry's is
|
|
326
|
+
* that widget's (docked in its side column, or a rail icon that flies out);
|
|
327
|
+
* a zone's is the un-arranged side's (a docked rail, or an icon strip —
|
|
328
|
+
* {@link zoneRungAt}). ⚠ Not the widget envelope's `layout.v1.pinned`, which
|
|
329
|
+
* a host tells a widget about its own box.
|
|
330
|
+
* @experimental
|
|
331
|
+
*/
|
|
332
|
+
export function pinnedOf(placement) {
|
|
333
|
+
return placement?.pinned !== false;
|
|
334
|
+
}
|
|
335
|
+
/** An arranged frame read as the page reads it: whole numbers of cells and an item list, else none. */
|
|
336
|
+
function frameIn(layout, zone) {
|
|
337
|
+
const frame = isObj(layout.arrangedGrid) ? layout.arrangedGrid[zone] : undefined;
|
|
338
|
+
if (!isObj(frame) || typeof frame.cols !== 'number' || typeof frame.rows !== 'number' || !Array.isArray(frame.items))
|
|
339
|
+
return null;
|
|
340
|
+
const items = frame.items.filter((i) => isObj(i) && typeof i.id === 'string' && !!i.id && ['x', 'y', 'w', 'h'].every((k) => typeof i[k] === 'number'));
|
|
341
|
+
return { cols: frame.cols, rows: frame.rows, items };
|
|
342
|
+
}
|
|
343
|
+
/** The grid's well-formed entries, as written. */
|
|
344
|
+
function gridEntries(layout) {
|
|
345
|
+
const widgets = isObj(layout.widgetGrid) && Array.isArray(layout.widgetGrid.widgets) ? layout.widgetGrid.widgets : [];
|
|
346
|
+
return widgets.filter((w) => isObj(w) && typeof w.id === 'string' && !!w.id && ZONE_IDS.includes(w.zone));
|
|
347
|
+
}
|
|
348
|
+
/** Is this instance a copy of a retired widget? No reader draws one. */
|
|
349
|
+
const retired = (instanceId) => RETIRED_WIDGET_IDS.has(widgetOfInstance(instanceId));
|
|
350
|
+
/** An instance's widget, read through the aliases, and the settings an alias implies. */
|
|
351
|
+
function widgetFacts(instanceId) {
|
|
352
|
+
const r = resolveWidgetAlias(instanceId);
|
|
353
|
+
return r.aliasedFrom ? { widgetId: r.widgetId, impliedSettings: r.impliedSettings } : { widgetId: r.widgetId };
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* What a session layout draws at a session box of `box.inline` px: per zone,
|
|
357
|
+
* the instances it draws in reading order, each with one `pinned`, plus the
|
|
358
|
+
* facts a renderer draws the zone by. Pure and total — any value reads; what
|
|
359
|
+
* it cannot read places nothing.
|
|
360
|
+
*
|
|
361
|
+
* **The precedence, written once.** Three slots can name one zone; this is
|
|
362
|
+
* the one place that decides which draws.
|
|
174
363
|
*
|
|
175
|
-
* -
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
364
|
+
* - **The middle draws its arrangement whenever the layout has one** — an
|
|
365
|
+
* empty one included, else the grid's middle entries by `order`. The
|
|
366
|
+
* arrangement is the editor's capture of what a person laid out; an
|
|
367
|
+
* emptied middle is a decision, and the primary floor (the app's) is what
|
|
368
|
+
* puts the conversation back.
|
|
369
|
+
* - **A side draws its arrangement when that places anything, else its zone
|
|
370
|
+
* lists** — every `zoneLayout` zone drawn on that side (by its `side`,
|
|
371
|
+
* never its key) in order, with any grid entry naming the side folded in
|
|
372
|
+
* after the first zone's list, but only when a zone is there to hold it.
|
|
373
|
+
* An arrangement of nothing is the editor's leftover, not a decision: a
|
|
374
|
+
* side that loses its last card goes back to its list.
|
|
375
|
+
* - **When a side has no arrangement, its width ladder decides how it is
|
|
376
|
+
* drawn** ({@link zoneRungAt}): docked as a rail, an icon strip, a drawer
|
|
377
|
+
* or hidden — the zone's pin refining the rail. An arranged side is not
|
|
378
|
+
* asked: each instance's own pin decides whether it docks.
|
|
379
|
+
* - **A strip draws its list.**
|
|
182
380
|
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
381
|
+
* Read in that order — middle, left, right, strips — an instance is drawn
|
|
382
|
+
* once, where it is first drawn. A copy of a retired widget
|
|
383
|
+
* ({@link RETIRED_WIDGET_IDS}) is never drawn; an aliased id
|
|
384
|
+
* ({@link WIDGET_ID_ALIASES}) is drawn as the widget it became, under the id
|
|
385
|
+
* it was placed by, with the settings it implies. Every `pinned` is
|
|
386
|
+
* {@link pinnedOf}'s: an arranged item's and a grid entry's own, a listed
|
|
387
|
+
* instance's its zone's.
|
|
388
|
+
*
|
|
389
|
+
* The box's `block` size is not read today: no rung is a height.
|
|
185
390
|
* @experimental
|
|
186
391
|
*/
|
|
187
|
-
export function
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
392
|
+
export function resolveDrawn(layout, box) {
|
|
393
|
+
const doc = isObj(layout) ? layout : {};
|
|
394
|
+
const inline = typeof box?.inline === 'number' && Number.isFinite(box.inline) ? box.inline : 0;
|
|
395
|
+
const seen = new Set();
|
|
396
|
+
/** Admit an instance once, in reading order, never a retired one. */
|
|
397
|
+
const admit = (id) => {
|
|
398
|
+
if (retired(id) || seen.has(id))
|
|
399
|
+
return false;
|
|
400
|
+
seen.add(id);
|
|
401
|
+
return true;
|
|
192
402
|
};
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
403
|
+
const grid = gridEntries(doc);
|
|
404
|
+
const gridZone = (zone) => grid
|
|
405
|
+
.filter((w) => w.zone === zone)
|
|
406
|
+
.map((w, n) => ({ w, order: typeof w.order === 'number' ? w.order : n }))
|
|
407
|
+
.sort((a, b) => a.order - b.order)
|
|
408
|
+
.map(({ w }) => w);
|
|
409
|
+
const fromGrid = (w, pinned = pinnedOf(w)) => ({
|
|
410
|
+
instanceId: w.id,
|
|
411
|
+
...widgetFacts(w.id),
|
|
412
|
+
pinned,
|
|
413
|
+
...(typeof w.group === 'string' ? { group: w.group } : {}),
|
|
414
|
+
...(isObj(w.anchor) ? { anchor: { ...w.anchor } } : {}),
|
|
415
|
+
...(isObj(w.size) ? { size: w.size } : {}),
|
|
416
|
+
...(typeof w.colSpan === 'number' ? { colSpan: w.colSpan } : {}),
|
|
417
|
+
});
|
|
418
|
+
/** An arrangement's live items in reading order (by row, then column), admitted. */
|
|
419
|
+
const arrangedInstances = (items) => [...items]
|
|
420
|
+
.sort((a, b) => a.y - b.y || a.x - b.x)
|
|
421
|
+
.filter((i) => admit(i.id))
|
|
422
|
+
.map((i) => ({
|
|
423
|
+
instanceId: i.id,
|
|
424
|
+
...widgetFacts(i.id),
|
|
425
|
+
cells: { x: i.x, y: i.y, w: i.w, h: i.h },
|
|
426
|
+
pinned: pinnedOf(i),
|
|
427
|
+
...(typeof i.group === 'string' ? { group: i.group } : {}),
|
|
428
|
+
...(isObj(i.anchor) ? { anchor: { ...i.anchor } } : {}),
|
|
429
|
+
}));
|
|
430
|
+
// The middle.
|
|
431
|
+
const middleFrame = frameIn(doc, 'middle');
|
|
432
|
+
const middle = middleFrame
|
|
433
|
+
? {
|
|
434
|
+
zone: 'middle',
|
|
435
|
+
kind: 'middle',
|
|
436
|
+
drawnFrom: 'arrangement',
|
|
437
|
+
arrangement: { cols: middleFrame.cols, rows: middleFrame.rows },
|
|
438
|
+
pinned: true,
|
|
439
|
+
instances: arrangedInstances(middleFrame.items),
|
|
200
440
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
441
|
+
: {
|
|
442
|
+
zone: 'middle',
|
|
443
|
+
kind: 'middle',
|
|
444
|
+
drawnFrom: 'grid',
|
|
445
|
+
pinned: true,
|
|
446
|
+
instances: gridZone('middle')
|
|
447
|
+
.filter((w) => admit(w.id))
|
|
448
|
+
.map((w) => fromGrid(w)),
|
|
449
|
+
};
|
|
450
|
+
// The sides.
|
|
451
|
+
const zonesRaw = isObj(doc.zoneLayout) ? doc.zoneLayout.zones : undefined;
|
|
452
|
+
const defs = isObj(zonesRaw)
|
|
453
|
+
? Object.entries(zonesRaw).filter((e) => isObj(e[1]))
|
|
454
|
+
: [];
|
|
455
|
+
const side = (edge) => {
|
|
456
|
+
const zones = defs.filter(([, d]) => zoneDrawnAt(d) === edge);
|
|
457
|
+
const first = zones[0]?.[1];
|
|
458
|
+
const pinned = first ? pinnedOf(first) : true;
|
|
459
|
+
const rung = zoneRungAt(first ?? { kind: 'side', side: edge, widgets: [] }, inline);
|
|
460
|
+
const base = { zone: edge, kind: 'side', side: edge, zoneKey: zones[0]?.[0] ?? null, pinned, rung };
|
|
461
|
+
const frame = frameIn(doc, edge);
|
|
462
|
+
if (frame && frame.items.some((i) => !retired(i.id)))
|
|
463
|
+
return {
|
|
464
|
+
...base,
|
|
465
|
+
drawnFrom: 'arrangement',
|
|
466
|
+
arrangement: { cols: frame.cols, rows: frame.rows },
|
|
467
|
+
instances: arrangedInstances(frame.items),
|
|
468
|
+
};
|
|
469
|
+
const instances = [];
|
|
470
|
+
zones.forEach(([, def], n) => {
|
|
471
|
+
const listed = pinnedOf(def);
|
|
472
|
+
for (const id of strings(def.widgets))
|
|
473
|
+
if (admit(id))
|
|
474
|
+
instances.push({ instanceId: id, ...widgetFacts(id), pinned: listed });
|
|
475
|
+
// A grid entry naming this side is drawn in its first zone, after
|
|
476
|
+
// what that zone lists — and nowhere, when no zone is here.
|
|
477
|
+
if (n === 0)
|
|
478
|
+
for (const w of gridZone(edge))
|
|
479
|
+
if (admit(w.id))
|
|
480
|
+
instances.push(fromGrid(w, listed));
|
|
481
|
+
});
|
|
482
|
+
return { ...base, drawnFrom: 'ladder', instances };
|
|
483
|
+
};
|
|
484
|
+
const left = side('left');
|
|
485
|
+
const right = side('right');
|
|
486
|
+
// The strips.
|
|
487
|
+
const strips = defs
|
|
488
|
+
.filter(([, d]) => d.kind === 'strip')
|
|
489
|
+
.map(([key, def]) => {
|
|
490
|
+
const d = def;
|
|
491
|
+
return {
|
|
492
|
+
zoneKey: key,
|
|
493
|
+
area: d.area === 'bottom' ? 'bottom' : 'top',
|
|
494
|
+
rung: zoneRungAt(d, inline),
|
|
495
|
+
instances: strings(d.widgets)
|
|
496
|
+
.filter((id) => admit(id))
|
|
497
|
+
.map((id) => ({ instanceId: id, ...widgetFacts(id), pinned: pinnedOf(d) })),
|
|
498
|
+
};
|
|
499
|
+
});
|
|
500
|
+
return { left, middle, right, strips };
|
|
501
|
+
}
|
|
502
|
+
/** Every instance a drawn layout draws, in its reading order: middle, left, right, strips. @experimental */
|
|
503
|
+
export function drawnInstances(drawn) {
|
|
504
|
+
return [
|
|
505
|
+
...drawn.middle.instances,
|
|
506
|
+
...drawn.left.instances,
|
|
507
|
+
...drawn.right.instances,
|
|
508
|
+
...drawn.strips.flatMap((s) => s.instances),
|
|
509
|
+
];
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Every widget instance id the layout DRAWS, in reading order — middle, left,
|
|
513
|
+
* right, then any strips: {@link resolveDrawn}'s answer as ids, so the
|
|
514
|
+
* precedence is that function's and nowhere else. An entry an arrangement
|
|
515
|
+
* shadows is named but not drawn; a retired widget is never drawn.
|
|
516
|
+
* @experimental
|
|
517
|
+
*/
|
|
518
|
+
export function drawnWidgetIds(layout) {
|
|
519
|
+
// Membership does not depend on the box: only a side's presentation does.
|
|
520
|
+
return drawnInstances(resolveDrawn(layout, { inline: 0 })).map((i) => i.instanceId);
|
|
211
521
|
}
|
|
212
522
|
/**
|
|
213
523
|
* Does the layout DRAW any instance of `primaryId` — the bare id or a
|
|
214
524
|
* `#name` copy — anywhere? The **primary floor**'s question: placement is
|
|
215
525
|
* free, and the one rule left is that a layout draws its genre's primary
|
|
216
|
-
* widget somewhere.
|
|
526
|
+
* widget somewhere. Asked of {@link resolveDrawn}, like every "is it drawn".
|
|
217
527
|
* @experimental
|
|
218
528
|
*/
|
|
219
529
|
export function primaryPlaced(layout, primaryId) {
|
|
@@ -267,6 +577,10 @@ function isAnchor(x) {
|
|
|
267
577
|
* `maxInstances` (readers draw the first ones in reading order);
|
|
268
578
|
* - with `opts.unknownWidgets: 'warn'` too, a widget `opts.widgets` does not
|
|
269
579
|
* hold (it draws a labelled placeholder).
|
|
580
|
+
*
|
|
581
|
+
* An aliased id (`world-state`, {@link WIDGET_ID_ALIASES}) is checked as the
|
|
582
|
+
* widget it became: neither retired nor unknown, and counted against that
|
|
583
|
+
* widget's `maxInstances`.
|
|
270
584
|
* @experimental
|
|
271
585
|
*/
|
|
272
586
|
export function validateSessionLayout(layout, opts = {}) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The settings document (
|
|
2
|
+
* The settings document (ruled 2026-09-21).
|
|
3
3
|
*
|
|
4
4
|
* Every setting a person can see in session settings reaches every run as
|
|
5
5
|
* **one resolved document**, defaults applied. A run's `sessionScope` was a
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* `session`, so `$.input.session.fields.tone` reads in any spec and no spec
|
|
10
10
|
* knows which table a setting came from.
|
|
11
11
|
*
|
|
12
|
-
* `fields` is the cascade's answer
|
|
12
|
+
* `fields` is the cascade's answer: for every declared key, the
|
|
13
13
|
* session's stored value, else the genre's pinned value, else the field's
|
|
14
14
|
* core default. A key nobody declares or pins is absent.
|
|
15
15
|
*
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* The widget envelope's `session.v1` is a projection of this document:
|
|
21
21
|
* widgets receive `title`, `fields`, `turnOrder`, `channels`, `cast`,
|
|
22
22
|
* `annex` — never `guests` or `pipelines`.
|
|
23
|
+
* @ruling PLAN-turn-order §4.12, R13, §4.13
|
|
23
24
|
*/
|
|
24
25
|
import type { SessionCastV1 } from './participants.js';
|
|
25
26
|
import type { TurnOrderV1 } from './turnOrder.js';
|
|
@@ -35,10 +36,11 @@ export interface SessionSettingsV1 {
|
|
|
35
36
|
/** Every declared genre field: default, then the session's value over it. */
|
|
36
37
|
fields: Record<string, unknown>;
|
|
37
38
|
/**
|
|
38
|
-
* 🚧 What a person's persona-less line is called in this session
|
|
39
|
+
* 🚧 What a person's persona-less line is called in this session:
|
|
39
40
|
* the session's own value, else the genre's `playerLabel` (in `en`), else
|
|
40
41
|
* absent — and absent whenever the genre declares none, whatever is
|
|
41
42
|
* stored. Read, never stamped on a row.
|
|
43
|
+
* @ruling R4
|
|
42
44
|
*/
|
|
43
45
|
playerLabel?: string;
|
|
44
46
|
scenario: string | null;
|
|
@@ -53,11 +55,12 @@ export interface SessionSettingsV1 {
|
|
|
53
55
|
params: Record<string, Record<string, unknown>>;
|
|
54
56
|
}>;
|
|
55
57
|
/**
|
|
56
|
-
* The session's turn order — the state, as `set-turn-order` wrote it
|
|
57
|
-
*
|
|
58
|
+
* The session's turn order — the state, as `set-turn-order` wrote it.
|
|
59
|
+
* What the session chose is
|
|
58
60
|
* `pipelines[<its turn-order spec>].rebinds.strategy`; what it may choose
|
|
59
61
|
* is the node's `expose.swaps` on the registry. The document carries no
|
|
60
62
|
* turn-order special case.
|
|
63
|
+
* @ruling R28 (the modder pass)
|
|
61
64
|
*/
|
|
62
65
|
turnOrder: TurnOrderV1;
|
|
63
66
|
/** Read-only from the pipeline layer: written by no outlet except `set-turn-order`. */
|