@serene-pub/sdk 0.6.0-pr-8 → 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/announce.d.ts +36 -3
- package/dist/announce.js +59 -4
- package/dist/builder.d.ts +5 -7
- package/dist/cadences.d.ts +1 -3
- 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 +172 -7
- package/dist/descriptors.d.ts +86 -12
- package/dist/descriptors.js +83 -5
- package/dist/document.d.ts +1 -1
- package/dist/events.d.ts +68 -25
- package/dist/events.js +35 -2
- package/dist/executor.d.ts +27 -0
- package/dist/executor.js +6 -3
- package/dist/exposure.d.ts +35 -1
- package/dist/exposure.js +64 -2
- package/dist/extension.d.ts +13 -2
- package/dist/extension.js +3 -1
- package/dist/genres.d.ts +61 -3
- package/dist/genres.js +131 -10
- package/dist/hostElements.d.ts +3 -3
- package/dist/hostElements.js +12 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/participants.d.ts +30 -0
- 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/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 +3 -1
- package/dist/sceneSettings.js +3 -1
- package/dist/sessionDossier.d.ts +102 -2
- package/dist/sessionSettings.d.ts +18 -0
- package/dist/shapes.d.ts +9 -0
- package/dist/shapes.js +9 -0
- package/dist/speech.d.ts +14 -3
- package/dist/storyTime.d.ts +77 -1
- package/dist/storyTime.js +111 -4
- package/dist/surfaces.d.ts +38 -1
- package/dist/surfaces.js +3 -0
- package/dist/template.d.ts +13 -1
- package/dist/templateCheck.js +175 -12
- package/dist/templateFit.js +4 -1
- package/dist/validate.js +69 -0
- package/dist/variableLayouts.d.ts +19 -0
- package/dist/variableLayouts.js +19 -0
- package/dist/variables.d.ts +202 -13
- package/dist/variables.js +258 -32
- package/dist/widgets.d.ts +68 -9
- package/dist/widgets.js +10 -2
- package/host-elements.d.ts +4 -2
- package/package.json +1 -1
package/dist/participants.d.ts
CHANGED
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
* the venue says *where*; the resolver says *whether they are here*.
|
|
56
56
|
* @ruling plans/29 R-15 *audience*, R-18 (3), R-21 (4) (ruled 2026-09-15), U5a (2026-09-16), R-18 (3), R-21 (4), ruled 2026-09-16, §6
|
|
57
57
|
*/
|
|
58
|
+
import type { StoryCalendar, StoryTime } from './storyTime.js';
|
|
58
59
|
/**
|
|
59
60
|
* The role-shaped references — no id, resolved against the session and the run.
|
|
60
61
|
*
|
|
@@ -361,6 +362,35 @@ export interface SessionCastV1 {
|
|
|
361
362
|
* reads as `full`.
|
|
362
363
|
*/
|
|
363
364
|
characterDetail?: 'full' | 'brief' | 'speaker-only';
|
|
365
|
+
/**
|
|
366
|
+
* 🚧 The session's story present and the lorebook's declared calendar.
|
|
367
|
+
* Always an object. On a lorebook that keeps no timeline, every value in it
|
|
368
|
+
* is `null`, whatever is stored; on one that keeps a timeline, `null` only
|
|
369
|
+
* where there is truly none.
|
|
370
|
+
*
|
|
371
|
+
* - `timeline`: the Timeline switch of the lorebook that governs the
|
|
372
|
+
* session (its attached lorebook's, else its own notes'); agrees with
|
|
373
|
+
* `SessionSettingsV1.timeline`.
|
|
374
|
+
* - `now`: the session's clock, else its line's clock, else its newest
|
|
375
|
+
* history entry (`from` says which).
|
|
376
|
+
* - `calendar`: the declared calendar, `null` for a free-form book.
|
|
377
|
+
* - `sessionStart`: the day of the session's first live stamped message;
|
|
378
|
+
* `null` when none.
|
|
379
|
+
* @experimental
|
|
380
|
+
*/
|
|
381
|
+
storyTime: {
|
|
382
|
+
timeline: boolean;
|
|
383
|
+
now: (StoryTime & {
|
|
384
|
+
from: 'clock' | 'history' | 'session';
|
|
385
|
+
label?: string;
|
|
386
|
+
}) | null;
|
|
387
|
+
calendar: StoryCalendar | null;
|
|
388
|
+
sessionStart: {
|
|
389
|
+
year: number;
|
|
390
|
+
month: number;
|
|
391
|
+
day: number;
|
|
392
|
+
} | null;
|
|
393
|
+
};
|
|
364
394
|
[k: string]: unknown;
|
|
365
395
|
}
|
|
366
396
|
//# sourceMappingURL=participants.d.ts.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🚧 The rules core enforces from a genre's own fields, by the name a genre uses to point at
|
|
3
|
+
* one. The names differ from the field keys deliberately: the proviso is the rule, the field is
|
|
4
|
+
* the genre's.
|
|
5
|
+
* @experimental
|
|
6
|
+
*/
|
|
7
|
+
export declare const GENRE_PROVISOS: readonly ["turnKeeping", "sheetLatitude", "itemMoveLatitude", "toolKinds"];
|
|
8
|
+
/** @experimental */
|
|
9
|
+
export type GenreProviso = (typeof GENRE_PROVISOS)[number];
|
|
10
|
+
/**
|
|
11
|
+
* 🚧 The side a per-side proviso speaks for: the session owner or a player.
|
|
12
|
+
* @experimental
|
|
13
|
+
*/
|
|
14
|
+
export type ProvisoSide = 'owner' | 'player';
|
|
15
|
+
/**
|
|
16
|
+
* 🚧 `SessionShape.provisos`: for each rule core enforces, the key of the genre's own field in
|
|
17
|
+
* `shape.fields` (or of a value the genre pins in `settings`) that carries it. A genre that
|
|
18
|
+
* names none of a rule has none of it.
|
|
19
|
+
* @experimental
|
|
20
|
+
*/
|
|
21
|
+
export interface GenreProvisos {
|
|
22
|
+
/** A boolean field (or a pinned boolean): on = nobody deletes the latest turn (Keep every turn). */
|
|
23
|
+
turnKeeping?: string;
|
|
24
|
+
/** Per side role, an enum field over `SHEET_LATITUDES` (or a pinned level). */
|
|
25
|
+
sheetLatitude?: {
|
|
26
|
+
owner?: string;
|
|
27
|
+
player?: string;
|
|
28
|
+
};
|
|
29
|
+
/** Per side role, an enum field over `ITEM_MOVE_LATITUDES` (or a pinned level). */
|
|
30
|
+
itemMoveLatitude?: {
|
|
31
|
+
owner?: string;
|
|
32
|
+
player?: string;
|
|
33
|
+
};
|
|
34
|
+
/** A string[] field of tool kinds (or a pinned string[]). */
|
|
35
|
+
toolKinds?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 🚧 The key of the genre's own field (or pinned setting) that carries a proviso, or `null` when
|
|
39
|
+
* the genre names none.
|
|
40
|
+
*
|
|
41
|
+
* A genre that declares `shape.provisos` is read from it alone: a proviso it does not name is
|
|
42
|
+
* `null`. ⏳ A genre with no `shape.provisos` (an undeclared or stored genre written before
|
|
43
|
+
* provisos) answers the core spelling — `keepEveryTurn`, `ownerSheetLatitude` /
|
|
44
|
+
* `playerSheetLatitude`, `ownerItemMoves` / `playerItemMoves`, `tools` — whether or not it holds
|
|
45
|
+
* that key: the value is then whatever the session's cascade carries under it (its fields, its
|
|
46
|
+
* settings, a preset's pin), absent when nothing does. `sheetLatitude` and `itemMoveLatitude`
|
|
47
|
+
* need a `side`; without one the answer is `null`. Pure, never throws.
|
|
48
|
+
* @experimental
|
|
49
|
+
*/
|
|
50
|
+
export declare function provisoFieldOf(genre: {
|
|
51
|
+
shape?: unknown;
|
|
52
|
+
settings?: unknown;
|
|
53
|
+
} | null | undefined, proviso: GenreProviso, side?: ProvisoSide): string | null;
|
|
54
|
+
/**
|
|
55
|
+
* 🚧 A `provisos` declaration's faults, refused at the declaration: not an object, a name that
|
|
56
|
+
* is no proviso, a side that is not owner or player, a value that is not the key of one of the
|
|
57
|
+
* genre's fields or settings, a field of the wrong kind or offering a level outside the
|
|
58
|
+
* levels, a pinned setting of the wrong value. Throws one error, one sentence a fault, each
|
|
59
|
+
* prefixed with `who`. `settings` is the genre's `settings`.
|
|
60
|
+
* @experimental
|
|
61
|
+
*/
|
|
62
|
+
export declare function assertProvisos(shape: unknown, settings: unknown, who: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* 🚧 What a genre leaves unsaid about the rules core enforces: for each proviso (and side) whose
|
|
65
|
+
* core spelling is a key of the genre's `shape.fields` or `settings`, a warning when `provisos`
|
|
66
|
+
* is absent (core reads the spelling for now) or when `provisos` is present and does not name
|
|
67
|
+
* that key (core does not enforce the rule from that field). Never a refusal: a genre expects,
|
|
68
|
+
* it never locks. Pure, never throws.
|
|
69
|
+
* @experimental
|
|
70
|
+
*/
|
|
71
|
+
export declare function provisoWarnings(decl: {
|
|
72
|
+
readonly id: string;
|
|
73
|
+
readonly shape?: unknown;
|
|
74
|
+
readonly settings?: unknown;
|
|
75
|
+
}): string[];
|
|
76
|
+
/**
|
|
77
|
+
* 🚧 A preset's pins a genre does not read: for each setting the preset pins whose key is
|
|
78
|
+
* spelled like a core proviso key (`keepEveryTurn`, the sheet and item-move latitude keys,
|
|
79
|
+
* `tools`) while its genre declares `provisos` and names no such field, a warning — the value
|
|
80
|
+
* is not read. A genre with no `provisos` reads the spelling, so says nothing; an unknown genre
|
|
81
|
+
* (`null`) says nothing. Never a refusal. Pure, never throws.
|
|
82
|
+
* @experimental
|
|
83
|
+
*/
|
|
84
|
+
export declare function presetProvisoWarnings(preset: {
|
|
85
|
+
readonly slug: string;
|
|
86
|
+
readonly genre: string;
|
|
87
|
+
readonly settings?: unknown;
|
|
88
|
+
}, genre: {
|
|
89
|
+
readonly shape?: unknown;
|
|
90
|
+
readonly settings?: unknown;
|
|
91
|
+
} | null | undefined): string[];
|
|
92
|
+
//# sourceMappingURL=provisos.d.ts.map
|
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. */
|