@serene-pub/sdk 0.6.0-pr-4 → 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 +23 -19
- package/dist/actions.d.ts +149 -67
- package/dist/actions.js +89 -35
- 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 +188 -95
- 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 +4 -3
- package/dist/identity.js +4 -3
- 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 +99 -36
- package/dist/shapes.js +101 -35
- 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/bands.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Bands as template variables
|
|
2
|
+
* Bands as template variables.
|
|
3
3
|
*
|
|
4
4
|
* A **band** is the ranker's word for one source's slice of the context window
|
|
5
5
|
* (`bandIntent`, candidates.ts). A source that puts its own band in the window
|
|
@@ -27,9 +27,10 @@
|
|
|
27
27
|
* when the slot says `rendersBands` — every band declared upstream of the
|
|
28
28
|
* named in-port, followed through any node that takes candidates in
|
|
29
29
|
* (concatenation, fusion, ranking). `rendersAt` is that answer.
|
|
30
|
+
* @ruling typed templates P2 (2026-09-27)
|
|
30
31
|
*/
|
|
31
32
|
import { getDefinition } from './descriptors.js';
|
|
32
|
-
import {
|
|
33
|
+
import { getVariable } from './variables.js';
|
|
33
34
|
/**
|
|
34
35
|
* The shape a candidates port carries. Written out rather than imported from
|
|
35
36
|
* `shapes.ts`, which reaches the descriptor module this one is read from.
|
|
@@ -64,15 +65,7 @@ export const ASSEMBLE_OWN_TEMPLATE_NAMES = [
|
|
|
64
65
|
];
|
|
65
66
|
/** The declared variable id of one band entry — a declaration, or its id as a registry row carries it. */
|
|
66
67
|
const variableIdOf = (v) => typeof v === 'string' ? v : v?.id;
|
|
67
|
-
|
|
68
|
-
* A **core** variable that already renders a top-level name, if any — the
|
|
69
|
-
* names core's own nodes put in a template (`characters`, `scenario`, …). A
|
|
70
|
-
* plugin variable sharing a root is not by itself a collision: two plugins'
|
|
71
|
-
* bands meaning different things is, and the definitions check names both.
|
|
72
|
-
*/
|
|
73
|
-
const otherVariableRendering = (key, id) => allVariables().find((v) => v.id !== id &&
|
|
74
|
-
v.id.startsWith('core:') &&
|
|
75
|
-
Object.prototype.hasOwnProperty.call(v.scope, key));
|
|
68
|
+
const hasOwn = (o, key) => Object.prototype.hasOwnProperty.call(o, key);
|
|
76
69
|
/**
|
|
77
70
|
* Refuse a definition's band declarations — at `describe…Definition`, where
|
|
78
71
|
* the author is.
|
|
@@ -80,14 +73,18 @@ const otherVariableRendering = (key, id) => allVariables().find((v) => v.id !==
|
|
|
80
73
|
* - the key is an identifier (a band is a template name);
|
|
81
74
|
* - the variable is registered (`defineVariable` / `definePluginVariable`) and
|
|
82
75
|
* its scope declares the key, because a layout renders `{ [key]: value }`;
|
|
83
|
-
* - the key
|
|
84
|
-
*
|
|
85
|
-
*
|
|
76
|
+
* - the key is not one of Assemble's own names.
|
|
77
|
+
*
|
|
78
|
+
* **Not refused here: a key some other definition, or some core variable,
|
|
79
|
+
* already uses** (owner ruling 2026-10-13, ★1). A key is a local name and
|
|
80
|
+
* means one variable *within one template's scope* — `bandsReaching` and
|
|
81
|
+
* `rendersAt` refuse two meanings meeting in one document, and law T1 reports
|
|
82
|
+
* it. Two pipelines that never meet may each mean their own `characterLore`.
|
|
86
83
|
*
|
|
87
84
|
* Each refusal names the fix.
|
|
88
85
|
* @internal
|
|
89
86
|
*/
|
|
90
|
-
export function checkBandDeclarations(d
|
|
87
|
+
export function checkBandDeclarations(d) {
|
|
91
88
|
const bands = d.bands;
|
|
92
89
|
for (const key of Object.keys(d.bandPorts ?? {}))
|
|
93
90
|
if (!bands || !Object.prototype.hasOwnProperty.call(bands, key))
|
|
@@ -121,11 +118,6 @@ export function checkBandDeclarations(d, others) {
|
|
|
121
118
|
throw new Error(`'${d.id}' declares band '${key}', which collides with Assemble's own '${key}' — a ` +
|
|
122
119
|
`template reading {{{${key}}}} would get one or the other depending on order. ` +
|
|
123
120
|
`Rename the band.`);
|
|
124
|
-
const core = otherVariableRendering(key, id);
|
|
125
|
-
if (core)
|
|
126
|
-
throw new Error(`'${d.id}' declares band '${key}' as '${id}', which collides with '${core.id}' — that ` +
|
|
127
|
-
`variable already renders the top-level name '${key}'. A band key means one thing; ` +
|
|
128
|
-
`rename the band.`);
|
|
129
121
|
const ports = d.bandPorts?.[key];
|
|
130
122
|
if (ports !== undefined) {
|
|
131
123
|
const out = Object.keys(d.ports?.out ?? {});
|
|
@@ -139,17 +131,71 @@ export function checkBandDeclarations(d, others) {
|
|
|
139
131
|
`that publish the band's candidates in bandPorts, or leave '${key}' out of bandPorts ` +
|
|
140
132
|
`if every out-port may carry it.`);
|
|
141
133
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* What is wrong with a node rendering `key` as `id`, as the end of a sentence
|
|
138
|
+
* that begins with what renders it — or `undefined` when nothing is.
|
|
139
|
+
*
|
|
140
|
+
* The facts a band declaration states, asked of every rendered key: a layout
|
|
141
|
+
* is written against its variable's scope and renders `{ [key]: value }`, so
|
|
142
|
+
* a key the scope does not name reaches no layout, and a variable nobody
|
|
143
|
+
* registered has no layout, no type and no picker.
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
146
|
+
export function rendersProblem(key, id) {
|
|
147
|
+
if (!isBandKey(key))
|
|
148
|
+
return (`'${key}', which is not an identifier — a rendered key is a top-level template name. ` +
|
|
149
|
+
`Rename it '${bandKeySuggestion(key)}'.`);
|
|
150
|
+
if (typeof id !== 'string' || !id)
|
|
151
|
+
return `'${key}' without a variable. Name the variable it renders: { ${key}: 'core:var/…@1' }.`;
|
|
152
|
+
const v = getVariable(id);
|
|
153
|
+
if (!v)
|
|
154
|
+
return (`'${key}' as '${id}', which is not registered. Declare it with definePluginVariable() ` +
|
|
155
|
+
`(defineVariable() in core) before the definition or spec that names it — the layout ` +
|
|
156
|
+
`picker and the template editor read it from the registry.`);
|
|
157
|
+
if (!hasOwn(v.scope, key))
|
|
158
|
+
return (`'${key}' as '${id}', whose scope does not declare '${key}' (it declares ` +
|
|
159
|
+
`${Object.keys(v.scope).map((k) => `'${k}'`).join(', ') || 'nothing'}). A layout renders ` +
|
|
160
|
+
`the value as {{{${key}}}}, so add '${key}' to the variable's scope.`);
|
|
161
|
+
if (ASSEMBLE_OWN_TEMPLATE_NAMES.includes(key))
|
|
162
|
+
return `'${key}', which collides with Assemble's own '${key}'. Render it under another name.`;
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Refuse a definition's static `renders` (owner ruling 2026-10-13) — at
|
|
167
|
+
* `describe…Definition`, like its bands, and for the same reasons
|
|
168
|
+
* (`rendersProblem`). Until then nothing read a `renders` entry until a run
|
|
169
|
+
* did, and a key whose variable did not declare it rendered nothing.
|
|
170
|
+
* @internal
|
|
171
|
+
*/
|
|
172
|
+
export function checkRendersDeclarations(d) {
|
|
173
|
+
for (const [slotName, slot] of Object.entries((d.slots ?? {}))) {
|
|
174
|
+
if (slot.kind !== 'variables')
|
|
175
|
+
continue;
|
|
176
|
+
for (const [key, id] of Object.entries(slot.renders ?? {})) {
|
|
177
|
+
const problem = rendersProblem(key, id);
|
|
178
|
+
if (problem)
|
|
179
|
+
throw new Error(`'${d.id}' slot '${slotName}' renders ${problem}`);
|
|
150
180
|
}
|
|
151
181
|
}
|
|
152
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* What one placement's `variables` slot renders, before any band: the slot's
|
|
185
|
+
* static `renders`, with each key the **spec's own `renders`** names for this
|
|
186
|
+
* node (`NodeOpts.renders`, owner ruling 2026-10-13) re-pointed at the
|
|
187
|
+
* spec's variable. Only keys the slot already renders — the spec says what a
|
|
188
|
+
* key *means* here, it does not add keys; `validate()` reports one it names
|
|
189
|
+
* that no slot renders (law T1).
|
|
190
|
+
* @experimental
|
|
191
|
+
*/
|
|
192
|
+
export function effectiveRenders(slot, node) {
|
|
193
|
+
const out = { ...(slot.renders ?? {}) };
|
|
194
|
+
for (const [key, id] of Object.entries(node?.renders ?? {}))
|
|
195
|
+
if (hasOwn(out, key))
|
|
196
|
+
out[key] = id;
|
|
197
|
+
return out;
|
|
198
|
+
}
|
|
153
199
|
/** Two declarers naming one band differently, or a band shadowing a name the node renders. @experimental */
|
|
154
200
|
export class BandCollisionError extends Error {
|
|
155
201
|
}
|
|
@@ -233,17 +279,21 @@ export function bandsReaching(doc, nodeKey, port, describe = defaultDescribe) {
|
|
|
233
279
|
* @experimental
|
|
234
280
|
*/
|
|
235
281
|
export function rendersAt(doc, nodeKey, slot, describe) {
|
|
236
|
-
|
|
282
|
+
// The spec's own `renders` for this node first: a band reaching a key the
|
|
283
|
+
// spec re-pointed has to agree with the spec, not with the definition.
|
|
284
|
+
const own = effectiveRenders(slot, doc.nodes.find((n) => n.key === nodeKey));
|
|
285
|
+
const out = { ...own };
|
|
237
286
|
const from = slot.rendersBands?.from;
|
|
238
287
|
if (!from)
|
|
239
288
|
return out;
|
|
240
289
|
const reaching = bandsReaching(doc, nodeKey, from, describe);
|
|
241
290
|
for (const [band, { variable, declarer }] of Object.entries(reaching)) {
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
244
|
-
if (
|
|
291
|
+
const mine = own[band];
|
|
292
|
+
if (mine !== undefined) {
|
|
293
|
+
if (mine !== variable)
|
|
245
294
|
throw new BandCollisionError(`band '${band}' declared by ${declarer} as '${variable}' collides with '${nodeKey}''s ` +
|
|
246
|
-
`own '${band}', which it renders as '${
|
|
295
|
+
`own '${band}', which it renders as '${mine}'. Rename the band, or — if this ` +
|
|
296
|
+
`spec means that band here — say so on the node: renders: { ${band}: '${variable}' }.`);
|
|
247
297
|
continue;
|
|
248
298
|
}
|
|
249
299
|
if (ASSEMBLE_OWN_TEMPLATE_NAMES.includes(band))
|