@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/provisos.js
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🚧 **Genre provisos** (owner ruling G3D, 2026-11-18: a rule like honour mode is a genre
|
|
3
|
+
* setting its pipelines can reference).
|
|
4
|
+
*
|
|
5
|
+
* Purpose: say which of a genre's OWN fields (or pinned settings) carries each rule core
|
|
6
|
+
* enforces — keeping every turn, sheet latitude, item-move latitude, the tool kinds — and read
|
|
7
|
+
* that answer back, so core never looks for a field by a spelling of its own.
|
|
8
|
+
*
|
|
9
|
+
* Why it exists: a rule read from a field by core's own spelling (`keepEveryTurn`,
|
|
10
|
+
* `ownerSheetLatitude` …) reaches a genre only by an accident of spelling: a field spelled
|
|
11
|
+
* otherwise is silently ignored, and one spelled so by chance silently becomes a rule. A genre
|
|
12
|
+
* names the field; core reads the name.
|
|
13
|
+
*
|
|
14
|
+
* Owns: the proviso names, the shape of `SessionShape.provisos`, its validation at `genre()`,
|
|
15
|
+
* the reader (`provisoFieldOf`), the warnings, and the ⏳ legacy spellings (read only while a
|
|
16
|
+
* genre declares no `provisos`).
|
|
17
|
+
*
|
|
18
|
+
* Does NOT own: what a rule does or its sentences (the host's gates and the SDK's
|
|
19
|
+
* `sheetLatitudeAllows`); the field's label, default or members (the genre's); the value in
|
|
20
|
+
* force (the host resolves the cascade and passes the value in).
|
|
21
|
+
*
|
|
22
|
+
* ⚠ Not a ruleset's rules (a ruleset is the game's maths; a proviso is the table's permission
|
|
23
|
+
* a genre exposes); not a setting (the field or pin is the setting — the proviso only names it).
|
|
24
|
+
*
|
|
25
|
+
* Pure: no I/O, never throws except `assertProvisos` — it runs in the browser too.
|
|
26
|
+
*/
|
|
27
|
+
import { ITEM_MOVE_LATITUDES, SHEET_LATITUDES } from './sheetLatitude.js';
|
|
28
|
+
/**
|
|
29
|
+
* 🚧 The rules core enforces from a genre's own fields, by the name a genre uses to point at
|
|
30
|
+
* one. The names differ from the field keys deliberately: the proviso is the rule, the field is
|
|
31
|
+
* the genre's.
|
|
32
|
+
* @experimental
|
|
33
|
+
*/
|
|
34
|
+
export const GENRE_PROVISOS = Object.freeze([
|
|
35
|
+
'turnKeeping',
|
|
36
|
+
'sheetLatitude',
|
|
37
|
+
'itemMoveLatitude',
|
|
38
|
+
'toolKinds',
|
|
39
|
+
]);
|
|
40
|
+
const SIDES = ['owner', 'player'];
|
|
41
|
+
/** ⏳ Core's own spellings of the fields: read only while a genre's `provisos` is absent. */
|
|
42
|
+
const LEGACY_SPELLINGS = {
|
|
43
|
+
turnKeeping: 'keepEveryTurn',
|
|
44
|
+
sheetLatitude: { owner: 'ownerSheetLatitude', player: 'playerSheetLatitude' },
|
|
45
|
+
itemMoveLatitude: { owner: 'ownerItemMoves', player: 'playerItemMoves' },
|
|
46
|
+
toolKinds: 'tools',
|
|
47
|
+
};
|
|
48
|
+
const SIDED = ['sheetLatitude', 'itemMoveLatitude'];
|
|
49
|
+
function isPlain(v) {
|
|
50
|
+
return v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
51
|
+
}
|
|
52
|
+
function has(o, key) {
|
|
53
|
+
return isPlain(o) && Object.prototype.hasOwnProperty.call(o, key);
|
|
54
|
+
}
|
|
55
|
+
function legacyKey(proviso, side) {
|
|
56
|
+
const spelled = LEGACY_SPELLINGS[proviso];
|
|
57
|
+
if (typeof spelled === 'string')
|
|
58
|
+
return spelled;
|
|
59
|
+
return side ? spelled[side] : null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 🚧 The key of the genre's own field (or pinned setting) that carries a proviso, or `null` when
|
|
63
|
+
* the genre names none.
|
|
64
|
+
*
|
|
65
|
+
* A genre that declares `shape.provisos` is read from it alone: a proviso it does not name is
|
|
66
|
+
* `null`. ⏳ A genre with no `shape.provisos` (an undeclared or stored genre written before
|
|
67
|
+
* provisos) answers the core spelling — `keepEveryTurn`, `ownerSheetLatitude` /
|
|
68
|
+
* `playerSheetLatitude`, `ownerItemMoves` / `playerItemMoves`, `tools` — whether or not it holds
|
|
69
|
+
* that key: the value is then whatever the session's cascade carries under it (its fields, its
|
|
70
|
+
* settings, a preset's pin), absent when nothing does. `sheetLatitude` and `itemMoveLatitude`
|
|
71
|
+
* need a `side`; without one the answer is `null`. Pure, never throws.
|
|
72
|
+
* @experimental
|
|
73
|
+
*/
|
|
74
|
+
export function provisoFieldOf(genre, proviso, side) {
|
|
75
|
+
const shape = isPlain(genre?.shape) ? genre.shape : undefined;
|
|
76
|
+
const sided = SIDED.includes(proviso);
|
|
77
|
+
if (sided && !side)
|
|
78
|
+
return null;
|
|
79
|
+
const declared = shape?.provisos;
|
|
80
|
+
if (declared === undefined)
|
|
81
|
+
return legacyKey(proviso, side);
|
|
82
|
+
if (!isPlain(declared))
|
|
83
|
+
return null;
|
|
84
|
+
const named = declared[proviso];
|
|
85
|
+
const value = sided ? (isPlain(named) && side ? named[side] : undefined) : named;
|
|
86
|
+
return typeof value === 'string' && value !== '' ? value : null;
|
|
87
|
+
}
|
|
88
|
+
const SHAPE_SENTENCE = "provisos is { turnKeeping?, sheetLatitude?: { owner?, player? }, itemMoveLatitude?: { owner?, player? }, toolKinds? } — each names one of this genre's fields or settings";
|
|
89
|
+
const EXPECTED_FIELD = {
|
|
90
|
+
turnKeeping: 'a boolean field',
|
|
91
|
+
sheetLatitude: `an enum field of ${SHEET_LATITUDES.join(', ')}`,
|
|
92
|
+
itemMoveLatitude: `an enum field of ${ITEM_MOVE_LATITUDES.join(', ')}`,
|
|
93
|
+
toolKinds: 'a string[] field',
|
|
94
|
+
};
|
|
95
|
+
const EXPECTED_FIELD_TYPE = {
|
|
96
|
+
turnKeeping: 'boolean',
|
|
97
|
+
sheetLatitude: 'enum',
|
|
98
|
+
itemMoveLatitude: 'enum',
|
|
99
|
+
toolKinds: 'string[]',
|
|
100
|
+
};
|
|
101
|
+
const EXPECTED_PIN = {
|
|
102
|
+
turnKeeping: 'a boolean',
|
|
103
|
+
sheetLatitude: `one of ${SHEET_LATITUDES.join(', ')}`,
|
|
104
|
+
itemMoveLatitude: `one of ${ITEM_MOVE_LATITUDES.join(', ')}`,
|
|
105
|
+
toolKinds: 'a list of strings',
|
|
106
|
+
};
|
|
107
|
+
function levelsOf(proviso) {
|
|
108
|
+
if (proviso === 'sheetLatitude')
|
|
109
|
+
return SHEET_LATITUDES;
|
|
110
|
+
if (proviso === 'itemMoveLatitude')
|
|
111
|
+
return ITEM_MOVE_LATITUDES;
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
/** A pinned value read through a `{ value, lock? }` wrapper when the genre stated one. */
|
|
115
|
+
function pinnedValue(v) {
|
|
116
|
+
if (isPlain(v) && 'value' in v && Object.keys(v).every((k) => k === 'value' || k === 'lock' || k === 'askAtStart'))
|
|
117
|
+
return v.value;
|
|
118
|
+
return v;
|
|
119
|
+
}
|
|
120
|
+
function pinFits(proviso, value) {
|
|
121
|
+
const levels = levelsOf(proviso);
|
|
122
|
+
if (levels)
|
|
123
|
+
return typeof value === 'string' && levels.includes(value);
|
|
124
|
+
if (proviso === 'turnKeeping')
|
|
125
|
+
return typeof value === 'boolean';
|
|
126
|
+
return Array.isArray(value) && value.every((v) => typeof v === 'string');
|
|
127
|
+
}
|
|
128
|
+
function checkNamed(proviso, path, key, fields, settings, problems) {
|
|
129
|
+
if (typeof key !== 'string' || key === '') {
|
|
130
|
+
problems.push(`provisos.${path}: the key of one of this genre's fields or settings, as a string`);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (has(fields, key)) {
|
|
134
|
+
const decl = fields[key];
|
|
135
|
+
const type = isPlain(decl) && typeof decl.type === 'string' ? decl.type : 'unknown';
|
|
136
|
+
if (type !== EXPECTED_FIELD_TYPE[proviso]) {
|
|
137
|
+
const article = /^[aeiou]/.test(type) ? 'an' : 'a';
|
|
138
|
+
problems.push(`provisos.${path}: names the field '${key}', which is ${article} ${type} field — ${proviso} needs ${EXPECTED_FIELD[proviso]}`);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const levels = levelsOf(proviso);
|
|
142
|
+
if (levels && isPlain(decl)) {
|
|
143
|
+
const offered = Array.isArray(decl.of) && decl.of.length
|
|
144
|
+
? decl.of.filter((v) => typeof v === 'string')
|
|
145
|
+
: Array.isArray(decl.members)
|
|
146
|
+
? decl.members.flatMap((m) => (isPlain(m) && typeof m.key === 'string' ? [m.key] : []))
|
|
147
|
+
: [];
|
|
148
|
+
const stray = offered.find((v) => !levels.includes(v));
|
|
149
|
+
if (stray !== undefined)
|
|
150
|
+
problems.push(`provisos.${path}: the field '${key}' offers '${stray}', which is not one of ${levels.join(', ')}`);
|
|
151
|
+
}
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (has(settings, key)) {
|
|
155
|
+
const value = pinnedValue(settings[key]);
|
|
156
|
+
if (!pinFits(proviso, value))
|
|
157
|
+
problems.push(`provisos.${path}: names the setting '${key}', pinned to ${JSON.stringify(value)} — ${proviso} needs ${EXPECTED_PIN[proviso]}`);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
problems.push(`provisos.${path}: names '${key}', which is neither one of this genre's fields (shape.fields) nor one of its settings — declare the field, or pin the value in settings`);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 🚧 A `provisos` declaration's faults, refused at the declaration: not an object, a name that
|
|
164
|
+
* is no proviso, a side that is not owner or player, a value that is not the key of one of the
|
|
165
|
+
* genre's fields or settings, a field of the wrong kind or offering a level outside the
|
|
166
|
+
* levels, a pinned setting of the wrong value. Throws one error, one sentence a fault, each
|
|
167
|
+
* prefixed with `who`. `settings` is the genre's `settings`.
|
|
168
|
+
* @experimental
|
|
169
|
+
*/
|
|
170
|
+
export function assertProvisos(shape, settings, who) {
|
|
171
|
+
const raw = isPlain(shape) ? shape.provisos : undefined;
|
|
172
|
+
if (raw === undefined)
|
|
173
|
+
return;
|
|
174
|
+
const problems = [];
|
|
175
|
+
const fields = isPlain(shape) ? shape.fields : undefined;
|
|
176
|
+
if (!isPlain(raw)) {
|
|
177
|
+
problems.push(SHAPE_SENTENCE);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
181
|
+
if (!GENRE_PROVISOS.includes(k)) {
|
|
182
|
+
problems.push(`provisos.${k}: not a proviso core enforces — one of ${GENRE_PROVISOS.join(', ')}`);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
const proviso = k;
|
|
186
|
+
if (!SIDED.includes(proviso)) {
|
|
187
|
+
checkNamed(proviso, k, v, fields, settings, problems);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (!isPlain(v)) {
|
|
191
|
+
problems.push(`provisos.${k}: { owner?, player? } — each names one of this genre's fields or settings`);
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
for (const [side, key] of Object.entries(v)) {
|
|
195
|
+
if (!SIDES.includes(side)) {
|
|
196
|
+
problems.push(`provisos.${k}.${side}: not a side — owner or player`);
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
checkNamed(proviso, `${k}.${side}`, key, fields, settings, problems);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (problems.length)
|
|
204
|
+
throw new Error(`${who}: ${problems.join('\n')}`);
|
|
205
|
+
}
|
|
206
|
+
const RULE_WORDS = {
|
|
207
|
+
turnKeeping: 'Keep every turn',
|
|
208
|
+
sheetLatitude: { owner: "the session owner's sheet editing", player: "players' sheet editing" },
|
|
209
|
+
itemMoveLatitude: { owner: "the session owner's item moves", player: "players' item moves" },
|
|
210
|
+
toolKinds: 'the tools a session may use',
|
|
211
|
+
};
|
|
212
|
+
function snippetOf(proviso, side, spelling) {
|
|
213
|
+
return side
|
|
214
|
+
? `${proviso}: { ${side}: '${spelling}' }`
|
|
215
|
+
: `${proviso}: '${spelling}'`;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* 🚧 What a genre leaves unsaid about the rules core enforces: for each proviso (and side) whose
|
|
219
|
+
* core spelling is a key of the genre's `shape.fields` or `settings`, a warning when `provisos`
|
|
220
|
+
* is absent (core reads the spelling for now) or when `provisos` is present and does not name
|
|
221
|
+
* that key (core does not enforce the rule from that field). Never a refusal: a genre expects,
|
|
222
|
+
* it never locks. Pure, never throws.
|
|
223
|
+
* @experimental
|
|
224
|
+
*/
|
|
225
|
+
export function provisoWarnings(decl) {
|
|
226
|
+
const shape = isPlain(decl.shape) ? decl.shape : undefined;
|
|
227
|
+
const absent = shape?.provisos === undefined;
|
|
228
|
+
const out = [];
|
|
229
|
+
for (const proviso of GENRE_PROVISOS) {
|
|
230
|
+
const sides = SIDED.includes(proviso) ? SIDES : [undefined];
|
|
231
|
+
for (const side of sides) {
|
|
232
|
+
const spelling = legacyKey(proviso, side);
|
|
233
|
+
if (spelling === null)
|
|
234
|
+
continue;
|
|
235
|
+
if (!has(shape?.fields, spelling) && !has(decl.settings, spelling))
|
|
236
|
+
continue;
|
|
237
|
+
const words = RULE_WORDS[proviso];
|
|
238
|
+
const rule = typeof words === 'string' ? words : words[side];
|
|
239
|
+
const snippet = snippetOf(proviso, side, spelling);
|
|
240
|
+
if (absent)
|
|
241
|
+
out.push(`genre '${decl.id}': '${spelling}' is spelled like a rule core enforces (${rule}), and provisos names no field for it — core reads it by that spelling for now. Name it: provisos: { ${snippet} }.`);
|
|
242
|
+
else if (provisoFieldOf(decl, proviso, side) !== spelling)
|
|
243
|
+
out.push(`genre '${decl.id}': '${spelling}' is spelled like a rule core enforces (${rule}), and provisos does not name it, so core does not enforce it from that field. Name it: provisos: { ${snippet} }, or rename the field.`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return out;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* 🚧 A preset's pins a genre does not read: for each setting the preset pins whose key is
|
|
250
|
+
* spelled like a core proviso key (`keepEveryTurn`, the sheet and item-move latitude keys,
|
|
251
|
+
* `tools`) while its genre declares `provisos` and names no such field, a warning — the value
|
|
252
|
+
* is not read. A genre with no `provisos` reads the spelling, so says nothing; an unknown genre
|
|
253
|
+
* (`null`) says nothing. Never a refusal. Pure, never throws.
|
|
254
|
+
* @experimental
|
|
255
|
+
*/
|
|
256
|
+
export function presetProvisoWarnings(preset, genre) {
|
|
257
|
+
if (!genre || !isPlain(preset.settings))
|
|
258
|
+
return [];
|
|
259
|
+
const out = [];
|
|
260
|
+
for (const proviso of GENRE_PROVISOS) {
|
|
261
|
+
const sides = SIDED.includes(proviso) ? SIDES : [undefined];
|
|
262
|
+
for (const side of sides) {
|
|
263
|
+
const spelling = legacyKey(proviso, side);
|
|
264
|
+
if (spelling === null || !has(preset.settings, spelling))
|
|
265
|
+
continue;
|
|
266
|
+
if (provisoFieldOf(genre, proviso, side) === spelling)
|
|
267
|
+
continue;
|
|
268
|
+
out.push(`preset '${preset.slug}': it sets '${spelling}', which its genre '${preset.genre}' does not name as a proviso, so the setting is not read. Name the field in the genre's provisos, or remove it from the preset.`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return out;
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=provisos.js.map
|
package/dist/receiverRules.js
CHANGED
|
@@ -48,7 +48,7 @@ const CORE_OWNER = 'core';
|
|
|
48
48
|
/** Global presence booleans a remote can only have meant OFF when it wrote `"false"`. */
|
|
49
49
|
const PRESENCE_GLOBALS = new Set(['hidden', 'inert']);
|
|
50
50
|
/** Attributes holding a URL: trimmed before they are judged, and written trimmed. */
|
|
51
|
-
const URL_ATTRIBUTES = new Set(['href', 'src']);
|
|
51
|
+
const URL_ATTRIBUTES = new Set(['href', 'src', 'playlist']);
|
|
52
52
|
/** The ends the URL parser strips (C0 controls and space) and the ends `trim` strips (Unicode white space). */
|
|
53
53
|
const URL_EDGES = /^[\u0000- \s]+|[\u0000- \s]+$/g;
|
|
54
54
|
/** Core's box only: an `img src` on another host, over TLS. */
|
package/dist/registrations.d.ts
CHANGED
|
@@ -29,6 +29,14 @@
|
|
|
29
29
|
* trigger is a different registration. Two alike in one layer warn, never
|
|
30
30
|
* refuse (R34).
|
|
31
31
|
*
|
|
32
|
+
* ## One registration runs
|
|
33
|
+
*
|
|
34
|
+
* An event declared `runsOne` runs exactly one of its registrations: the
|
|
35
|
+
* session's choice, else the one marked `default: true`. Each registration is
|
|
36
|
+
* an option a session's owner picks, named by its `label`. A later layer's
|
|
37
|
+
* `default` replaces the earlier layers' (`effectiveRegistrations`); the door
|
|
38
|
+
* refuses two marks in one layer and warns when none is marked.
|
|
39
|
+
*
|
|
32
40
|
* ## Objects first; strings warn (R30, A18)
|
|
33
41
|
*
|
|
34
42
|
* `register()` takes the declared objects — an event (`coreEvents.…`, a
|
|
@@ -46,6 +54,7 @@ import { type I18n } from './i18n.js';
|
|
|
46
54
|
import { type EventDef, type SessionEventDecl } from './events.js';
|
|
47
55
|
import { type CadenceRef } from './cadences.js';
|
|
48
56
|
import { type ConditionDecl } from './conditions.js';
|
|
57
|
+
import { type ClauseMode } from './clauses.js';
|
|
49
58
|
import { type NormalizedAction } from './actions.js';
|
|
50
59
|
/**
|
|
51
60
|
* The trigger families — open (LS1): Live is a later family, and a closed
|
|
@@ -87,15 +96,16 @@ export type RoutineMode = 'off' | 'review' | 'full';
|
|
|
87
96
|
/** The routine modes. @experimental */
|
|
88
97
|
export declare const ROUTINE_MODES: readonly RoutineMode[];
|
|
89
98
|
/**
|
|
90
|
-
*
|
|
91
|
-
* which is at most the system's.
|
|
99
|
+
* A routine's run limit (R11, RG2) — each at most the owner's user setting,
|
|
100
|
+
* which is at most the system's. It counts a routine group's runs (a routine
|
|
101
|
+
* with no routine group is one of its own), and is valid on any cadence.
|
|
92
102
|
* @experimental
|
|
93
|
-
* @ruling R11
|
|
103
|
+
* @ruling R11, RG2
|
|
94
104
|
*/
|
|
95
105
|
export interface RoutineCaps {
|
|
96
106
|
/** How long the session may go without a person's interaction before the routine stops running. */
|
|
97
107
|
readonly idleTimeoutMinutes?: number;
|
|
98
|
-
/** How many
|
|
108
|
+
/** How many runs may happen since the last interaction. */
|
|
99
109
|
readonly maxRunsInRow?: number;
|
|
100
110
|
}
|
|
101
111
|
/**
|
|
@@ -110,7 +120,11 @@ export interface RegistrationDecl {
|
|
|
110
120
|
readonly trigger: Trigger;
|
|
111
121
|
/** The spec id of the pipeline that runs. */
|
|
112
122
|
readonly pipeline: string;
|
|
113
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* Runs only when this holds over the session's published values (R31: absent = always). A
|
|
125
|
+
* registration on an event also reads that event's payload, under the reserved name `event`
|
|
126
|
+
* (`event.asked` on Turn order asked); an action's or a routine's `when` has no event to read.
|
|
127
|
+
*/
|
|
114
128
|
readonly when?: ConditionDecl;
|
|
115
129
|
/** Changes to the pipeline's declared defaults (R38). */
|
|
116
130
|
readonly values?: RegistrationValues;
|
|
@@ -120,7 +134,10 @@ export interface RegistrationDecl {
|
|
|
120
134
|
readonly mode?: RoutineMode;
|
|
121
135
|
/** Routines only (R18): default false — a firing that finds one waiting is refused. */
|
|
122
136
|
readonly allowStacking?: boolean;
|
|
123
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* Routines only (R11, RG2), an administrator's: the run limit counts a routine group's runs (a
|
|
139
|
+
* routine with no routine group is one of its own); valid on any cadence.
|
|
140
|
+
*/
|
|
124
141
|
readonly caps?: RoutineCaps;
|
|
125
142
|
/**
|
|
126
143
|
* 🚧 How old a line must be before this registration's run may name it in `sources` — a message
|
|
@@ -128,11 +145,52 @@ export interface RegistrationDecl {
|
|
|
128
145
|
* 20 for a routine, 0 for an action or an event (a person vouches; the scene closed).
|
|
129
146
|
*/
|
|
130
147
|
readonly minAge?: number;
|
|
131
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* What the settings call it, when not the pipeline's name — on an event where one registration
|
|
150
|
+
* runs, the name of the option a session's owner picks.
|
|
151
|
+
*/
|
|
152
|
+
readonly label?: I18n;
|
|
153
|
+
/**
|
|
154
|
+
* 🚧 On an event where one registration runs (`EventDef.runsOne`): the one that
|
|
155
|
+
* runs when the session chose none. At most one per event in a layer; a later
|
|
156
|
+
* layer's mark replaces the earlier layers' (`effectiveRegistrations`). Refused
|
|
157
|
+
* on any other trigger (`registrationFindings`).
|
|
158
|
+
* ⚠ Not a pipeline's default preset (`.defaults()`), not a field's `default` value.
|
|
159
|
+
* @ruling programme 2.3, TC2, TN1 (owner 2026-11-18)
|
|
160
|
+
*/
|
|
161
|
+
readonly default?: true;
|
|
162
|
+
/**
|
|
163
|
+
* 🚧 The routine group this routine belongs to (its key). Set by `register(routineGroup(…), …)`
|
|
164
|
+
* or a preset's `change: [{ of, group }]`. Absent: the routine is a routine group of its own
|
|
165
|
+
* (the host's reading); the SDK never adds `group` to such a declaration.
|
|
166
|
+
*/
|
|
167
|
+
readonly group?: string;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 🚧 A routine group: routines that share one cadence, one `when`, one stacking switch and one
|
|
171
|
+
* run limit (RG1, RG2). Made with `routineGroup(cadence, { key, … })`; a routine joins it with
|
|
172
|
+
* `register(group, pipeline)` or a preset's `change: [{ of, group }]`. A routine with no routine
|
|
173
|
+
* group is a routine group of its own (the host's reading).
|
|
174
|
+
* @experimental
|
|
175
|
+
* @ruling RG1, RG2, RG3, RN1
|
|
176
|
+
*/
|
|
177
|
+
export interface RoutineGroupDecl {
|
|
178
|
+
/** Author-chosen slug: lowercase letters, digits and dashes. */
|
|
179
|
+
readonly key: string;
|
|
180
|
+
/** When the routine group fires. */
|
|
181
|
+
readonly cadence: CadenceRef;
|
|
132
182
|
readonly label?: I18n;
|
|
183
|
+
/** Over the session's published values; a routine group has no event to read. */
|
|
184
|
+
readonly when?: ConditionDecl;
|
|
185
|
+
/** Default false — a firing that finds one waiting is refused. */
|
|
186
|
+
readonly allowStacking?: boolean;
|
|
187
|
+
/** The routine group's run limit. */
|
|
188
|
+
readonly caps?: RoutineCaps;
|
|
189
|
+
/** How its routines run: `sequential` (default, one after another) or `parallel` (side by side). */
|
|
190
|
+
readonly run?: ClauseMode;
|
|
133
191
|
}
|
|
134
192
|
/** What `register()` takes beside the trigger and the pipeline. @experimental */
|
|
135
|
-
export type RegistrationOptions = Omit<RegistrationDecl, 'key' | 'trigger' | 'pipeline'>;
|
|
193
|
+
export type RegistrationOptions = Omit<RegistrationDecl, 'key' | 'trigger' | 'pipeline' | 'group'>;
|
|
136
194
|
/** 🚧 The routine default (ruled 2026-10-24). @experimental */
|
|
137
195
|
export declare const DEFAULT_ROUTINE_MIN_AGE = 20;
|
|
138
196
|
/** 🚧 A registration's effective minAge. @experimental */
|
|
@@ -172,9 +230,25 @@ export declare function actionHandlesOf(s: {
|
|
|
172
230
|
contributes?: unknown;
|
|
173
231
|
}): Record<string, ActionHandle>;
|
|
174
232
|
/** What `register()` accepts as a trigger: the declared objects, or a string (warned, R30). @experimental */
|
|
175
|
-
export type TriggerInput = EventDef | SessionEventDecl | ActionHandle | CadenceRef | Trigger | string;
|
|
233
|
+
export type TriggerInput = EventDef | SessionEventDecl | ActionHandle | CadenceRef | RoutineGroupDecl | Trigger | string;
|
|
176
234
|
/** What `register()` accepts as a pipeline: the spec you built or compiled, `use('…')`, or a string (warned, R30). @experimental */
|
|
177
235
|
export type PipelineInput = BuiltSpec | SpecDocument | ExternalRef | string;
|
|
236
|
+
/**
|
|
237
|
+
* 🚧 Declare a routine group: routines that fire together on `cadence`, counted and limited as
|
|
238
|
+
* one. `key` is the author's slug (`scenes`, `world-turns`). A routine joins it with
|
|
239
|
+
* `register(group, pipeline)` or a preset's `change: [{ of, group }]`. Judges nothing but the
|
|
240
|
+
* shape; the values are `routineGroupFindings`'s.
|
|
241
|
+
* @experimental
|
|
242
|
+
* @ruling RG1, RG2, RG3, RN1
|
|
243
|
+
*/
|
|
244
|
+
export declare function routineGroup(cadence: CadenceRef, opts: {
|
|
245
|
+
key: string;
|
|
246
|
+
label?: I18n;
|
|
247
|
+
when?: ConditionDecl;
|
|
248
|
+
allowStacking?: boolean;
|
|
249
|
+
caps?: RoutineCaps;
|
|
250
|
+
run?: ClauseMode;
|
|
251
|
+
}): RoutineGroupDecl;
|
|
178
252
|
/** The arrow a registration key joins its two halves with. @experimental */
|
|
179
253
|
export declare const REGISTRATION_KEY_JOIN = "\u2192";
|
|
180
254
|
/** A trigger's half of a registration key. @experimental */
|
|
@@ -197,6 +271,7 @@ export declare function registrationKeyOf(trigger: Trigger | TriggerInput, pipel
|
|
|
197
271
|
export declare function triggerOf(input: TriggerInput): {
|
|
198
272
|
trigger: Trigger;
|
|
199
273
|
spelled?: string;
|
|
274
|
+
group?: string;
|
|
200
275
|
};
|
|
201
276
|
/** The spec id a registration names, and the range a `use()` carried. @internal */
|
|
202
277
|
export declare function pipelineOf(input: PipelineInput): {
|
|
@@ -209,7 +284,8 @@ export declare function pipelineOf(input: PipelineInput): {
|
|
|
209
284
|
* key is derived (A8); `opts` are the registration's `when`, `values`,
|
|
210
285
|
* `order` and, for a routine, `mode`, `allowStacking` and `caps`. Nothing
|
|
211
286
|
* here refuses what the door judges (fit, cadence options, duplicates): call
|
|
212
|
-
* `registrationFindings`, which a package build and a host both do.
|
|
287
|
+
* `registrationFindings`, which a package build and a host both do. A routine
|
|
288
|
+
* group (`routineGroup(…)`) as the trigger makes the routine a member of it.
|
|
213
289
|
* @experimental
|
|
214
290
|
* @ruling D1, A8, R30
|
|
215
291
|
*/
|
|
@@ -258,7 +334,7 @@ export declare function emitCycles(decls: readonly RegistrationDecl[], pipeline:
|
|
|
258
334
|
* story clock, a session that has one;
|
|
259
335
|
* · the pipeline resolves, and **fits** the trigger (R4, R12);
|
|
260
336
|
* · routine-only fields (`mode`, `allowStacking`, `caps`) sit on routines,
|
|
261
|
-
* caps
|
|
337
|
+
* caps within the system's (RG2);
|
|
262
338
|
* · `values` set the slots a registration may (never a connection), on
|
|
263
339
|
* nodes the pipeline has;
|
|
264
340
|
* · the pipeline exposes no model plumbing to the owner (ruled 10-12);
|
|
@@ -268,6 +344,19 @@ export declare function emitCycles(decls: readonly RegistrationDecl[], pipeline:
|
|
|
268
344
|
* @ruling §11-2, R4, R11, R12, R30, R34, A11, A12, LS1
|
|
269
345
|
*/
|
|
270
346
|
export declare function registrationFindings(decls: readonly RegistrationDecl[], ctx?: RegistrationContext): Finding[];
|
|
347
|
+
/**
|
|
348
|
+
* 🚧 **The routine group door**: the whole-list check a host calls beside
|
|
349
|
+
* `registrationFindings`, which stays per registration. It judges each routine
|
|
350
|
+
* group (shape, key, cadence, clock, `run`, stacking, run limit, `when`, label,
|
|
351
|
+
* duplicates), each registration's `group` (a routine's, naming a declared
|
|
352
|
+
* routine group, never restating what the routine group owns), and warns about
|
|
353
|
+
* a routine group no routine is in. A host passes the effective routine groups
|
|
354
|
+
* (`effectiveRoutineGroups`) with the effective registrations. `groups` of
|
|
355
|
+
* `null` or `undefined`: a check the context cannot support is skipped.
|
|
356
|
+
* @experimental
|
|
357
|
+
* @ruling RG1, RG2, RG3
|
|
358
|
+
*/
|
|
359
|
+
export declare function routineGroupFindings(decls: readonly RegistrationDecl[], groups: readonly RoutineGroupDecl[] | null | undefined, ctx?: RegistrationContext): Finding[];
|
|
271
360
|
/**
|
|
272
361
|
* Author presets a pipeline ships that are not its declared defaults (R38,
|
|
273
362
|
* PLAN-layering D5): only the `default: true` one (`.defaults()`) is read;
|
|
@@ -291,6 +380,11 @@ export interface RegistrationChange {
|
|
|
291
380
|
readonly key: string;
|
|
292
381
|
readonly values?: RegistrationValues;
|
|
293
382
|
readonly mode?: RoutineMode;
|
|
383
|
+
/**
|
|
384
|
+
* Over the session's published values; for a registration on an event, also that event's
|
|
385
|
+
* payload under the reserved name `event` (`event.asked` on Turn order asked). Absent for
|
|
386
|
+
* actions and routines.
|
|
387
|
+
*/
|
|
294
388
|
readonly when?: ConditionDecl;
|
|
295
389
|
readonly allowStacking?: boolean;
|
|
296
390
|
readonly caps?: RoutineCaps;
|
|
@@ -302,17 +396,41 @@ export interface RegistrationChange {
|
|
|
302
396
|
readonly minAge?: number;
|
|
303
397
|
readonly order?: number;
|
|
304
398
|
readonly label?: I18n;
|
|
399
|
+
/** A preset marks the option that runs by default. */
|
|
400
|
+
readonly default?: true;
|
|
401
|
+
/** 🚧 Places the routine into a routine group (its key); the routine's key, trigger and state are unchanged. */
|
|
402
|
+
readonly group?: string;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* 🚧 A change to one routine group, named by its key: each stated field
|
|
406
|
+
* replaces the earlier layer's whole (`caps` included).
|
|
407
|
+
* @experimental
|
|
408
|
+
* @ruling RG1, RN1
|
|
409
|
+
*/
|
|
410
|
+
export interface RoutineGroupChange {
|
|
411
|
+
readonly key: string;
|
|
412
|
+
readonly cadence?: CadenceRef;
|
|
413
|
+
readonly label?: I18n;
|
|
414
|
+
readonly when?: ConditionDecl;
|
|
415
|
+
readonly allowStacking?: boolean;
|
|
416
|
+
readonly caps?: RoutineCaps;
|
|
417
|
+
readonly run?: ClauseMode;
|
|
305
418
|
}
|
|
306
419
|
/**
|
|
307
420
|
* A preset's changes on top of the genre's defaults (R2): registrations it
|
|
308
|
-
* adds, the keys it drops, and the changes it makes to the rest
|
|
421
|
+
* adds, the keys it drops, and the changes it makes to the rest — and the
|
|
422
|
+
* routine groups it declares or changes.
|
|
309
423
|
* @experimental
|
|
310
|
-
* @ruling R2, R3
|
|
424
|
+
* @ruling R2, R3, RG1
|
|
311
425
|
*/
|
|
312
426
|
export interface PresetRegistrationChanges {
|
|
313
427
|
readonly register?: readonly RegistrationDecl[];
|
|
314
428
|
readonly drop?: readonly string[];
|
|
315
429
|
readonly change?: readonly RegistrationChange[];
|
|
430
|
+
/** 🚧 Routine groups this preset declares. */
|
|
431
|
+
readonly groups?: readonly RoutineGroupDecl[];
|
|
432
|
+
/** 🚧 Changes to the genre's routine groups. */
|
|
433
|
+
readonly changeGroups?: readonly RoutineGroupChange[];
|
|
316
434
|
}
|
|
317
435
|
/**
|
|
318
436
|
* One session row over the effective registrations: a change to one
|
|
@@ -352,11 +470,33 @@ export type EffectiveRegistration = RegistrationDecl & {
|
|
|
352
470
|
* a session's rows (PLAN-layering D4). Pure; the host's resolver reuses it.
|
|
353
471
|
* A dropped registration is gone; a routine switched Off stays, with
|
|
354
472
|
* `mode: 'off'` (R8). Sorted by `order`, then key (R24). Within one layer the
|
|
355
|
-
* first of two alike wins — the door warns about the second (R34).
|
|
473
|
+
* first of two alike wins — the door warns about the second (R34). A layer
|
|
474
|
+
* that marks a registration `default` on an event takes the mark from the
|
|
475
|
+
* others on that event: a later layer's default replaces the earlier layers'.
|
|
476
|
+
* A session's change row never carries the mark: the session's choice is its
|
|
477
|
+
* own column, read by the host. A routine in a routine group carries `group`
|
|
478
|
+
* (from its declaration, or a layer's change) and nothing else about it
|
|
479
|
+
* changes; its routine group's cadence, `when`, stacking and run limit are
|
|
480
|
+
* read from `effectiveRoutineGroups`.
|
|
356
481
|
* @experimental
|
|
357
482
|
* @ruling R2, R8, R22, R24, R34
|
|
358
483
|
*/
|
|
359
484
|
export declare function effectiveRegistrations(genreDefaults: readonly RegistrationDecl[] | undefined, presetChanges?: PresetRegistrationChanges | null, sessionRows?: readonly SessionRegistrationRow[] | null): EffectiveRegistration[];
|
|
485
|
+
/**
|
|
486
|
+
* 🚧 **Effective routine groups** — the genre's routine groups ⊕ a preset's
|
|
487
|
+
* changes ⊕ a session's changes, layered as `effectiveRegistrations` is: the
|
|
488
|
+
* genre's by key (the first of two alike in a layer wins); the preset's
|
|
489
|
+
* `changeGroups` on the ones present (an unknown key is ignored); the preset's
|
|
490
|
+
* `groups` set by key (replacing a genre's of that key, origin `preset`); the
|
|
491
|
+
* session's changes on the ones present. Sorted by key. Pure; refuses nothing
|
|
492
|
+
* (`routineGroupFindings` judges).
|
|
493
|
+
* @experimental
|
|
494
|
+
* @ruling RG1, RG2
|
|
495
|
+
*/
|
|
496
|
+
export declare function effectiveRoutineGroups(genreGroups: readonly RoutineGroupDecl[] | undefined, presetChanges?: PresetRegistrationChanges | null, sessionChanges?: readonly RoutineGroupChange[] | null): Array<RoutineGroupDecl & {
|
|
497
|
+
readonly origin: 'genre' | 'preset' | (string & {});
|
|
498
|
+
readonly changedBy?: readonly string[];
|
|
499
|
+
}>;
|
|
360
500
|
/** Do two triggers name the same thing (event, action, or cadence id)? @experimental */
|
|
361
501
|
export declare function sameTrigger(a: Trigger, b: Trigger): boolean;
|
|
362
502
|
/**
|