@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/templateCheck.js
CHANGED
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
* @experimental
|
|
38
38
|
*/
|
|
39
39
|
import Handlebars from 'handlebars';
|
|
40
|
-
import { Liquid, Tag,
|
|
40
|
+
import { ForTag, Hash, Liquid, Output, Tag, TokenKind, Value, analyzeSync, toValueSync, } from 'liquidjs';
|
|
41
41
|
import { handlebars as handlebarsEngine, liquid as liquidEngine } from './engines.js';
|
|
42
|
-
import { enterHandlebarsBlock, nearestName, resolveHandlebarsPath, rootHandlebarsReach, typeOfHandlebarsPath, } from './handlebarsReach.js';
|
|
42
|
+
import { asVarField, enterHandlebarsBlock, nearestName, resolveHandlebarsPath, rootHandlebarsReach, typeOfHandlebarsPath, } from './handlebarsReach.js';
|
|
43
43
|
import { resolvePath } from './template.js';
|
|
44
|
-
import { VARIABLE_LAYOUT_HELPER, parseVariableLayoutReference } from './variableLayouts.js';
|
|
44
|
+
import { FORMAT_DATE_DELTA_HELPER, FORMAT_DATE_HELPER, VARIABLE_LAYOUT_HELPER, parseVariableLayoutReference, } from './variableLayouts.js';
|
|
45
45
|
/**
|
|
46
46
|
* Helpers Handlebars itself registers. A host's own (`json`, `isSet`, …) are
|
|
47
47
|
* an input — {@link TemplateCheckOptions.helpers} — never hard-coded here.
|
|
@@ -87,7 +87,7 @@ export function checkTemplateSourceReport(engine, src, scope, options = {}) {
|
|
|
87
87
|
catch (err) {
|
|
88
88
|
return { checked: true, findings: [syntaxFinding(err, lines)] };
|
|
89
89
|
}
|
|
90
|
-
const sink = new FindingSink(scope, options.untyped ?? [], lines, isHandlebars ? 'handlebars' : 'liquid', options.variableLayoutOffers);
|
|
90
|
+
const sink = new FindingSink(scope, options.untyped ?? [], lines, isHandlebars ? 'handlebars' : 'liquid', options.variableLayoutOffers, options.variableLayout === true);
|
|
91
91
|
try {
|
|
92
92
|
if (isHandlebars)
|
|
93
93
|
walkHandlebars(parsed, scope, helperSet(options), sink);
|
|
@@ -179,20 +179,43 @@ const LAYOUT_WORDS = {
|
|
|
179
179
|
const laidOutByOf = (decl) => decl && decl !== 'any' && !Array.isArray(decl) && typeof decl.laidOutBy === 'string'
|
|
180
180
|
? decl.laidOutBy
|
|
181
181
|
: undefined;
|
|
182
|
+
/** A date value, by shape: an object whose `year` is an object carrying a numeric `number`. */
|
|
183
|
+
const isDateShape = (f) => {
|
|
184
|
+
const year = f.fields?.year;
|
|
185
|
+
return f.type === 'object' && year?.type === 'object' && year.fields?.number?.type === 'number';
|
|
186
|
+
};
|
|
187
|
+
/** A date delta, by shape: an object with a `sign`. */
|
|
188
|
+
const isDateDeltaShape = (f) => f.type === 'object' && !!f.fields?.sign;
|
|
189
|
+
/** What the date helper and filter each take, by name. */
|
|
190
|
+
const DATE_SHAPES = {
|
|
191
|
+
[FORMAT_DATE_HELPER]: {
|
|
192
|
+
is: isDateShape,
|
|
193
|
+
what: 'a date',
|
|
194
|
+
example: "a row's date or currentDate",
|
|
195
|
+
},
|
|
196
|
+
[FORMAT_DATE_DELTA_HELPER]: {
|
|
197
|
+
is: isDateDeltaShape,
|
|
198
|
+
what: 'a date delta',
|
|
199
|
+
example: "a row's dateDelta",
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
const withArticle = (f) => (f.type === 'object' ? 'an object' : `a ${f.type}`);
|
|
182
203
|
class FindingSink {
|
|
183
204
|
scope;
|
|
184
205
|
untyped;
|
|
185
206
|
lines;
|
|
186
207
|
engine;
|
|
187
208
|
offers;
|
|
209
|
+
variableLayout;
|
|
188
210
|
findings = [];
|
|
189
211
|
seen = new Set();
|
|
190
|
-
constructor(scope, untyped, lines, engine = 'handlebars', offers) {
|
|
212
|
+
constructor(scope, untyped, lines, engine = 'handlebars', offers, variableLayout = false) {
|
|
191
213
|
this.scope = scope;
|
|
192
214
|
this.untyped = untyped;
|
|
193
215
|
this.lines = lines;
|
|
194
216
|
this.engine = engine;
|
|
195
217
|
this.offers = offers;
|
|
218
|
+
this.variableLayout = variableLayout;
|
|
196
219
|
}
|
|
197
220
|
get nameSeverity() {
|
|
198
221
|
return this.untyped.length ? 'warning' : 'error';
|
|
@@ -271,6 +294,63 @@ class FindingSink {
|
|
|
271
294
|
...this.where(line, column, name.length, tag),
|
|
272
295
|
});
|
|
273
296
|
}
|
|
297
|
+
/** A typed value treated as a shape it is not. Always a warning: the engines render it anyway. */
|
|
298
|
+
shapeMismatch(path, message, fix, at, tag) {
|
|
299
|
+
// Only a variable layout is read against its variable's declared shapes.
|
|
300
|
+
if (!this.variableLayout)
|
|
301
|
+
return;
|
|
302
|
+
this.push({
|
|
303
|
+
kind: 'shape-mismatch',
|
|
304
|
+
severity: 'warning',
|
|
305
|
+
name: path,
|
|
306
|
+
path,
|
|
307
|
+
message,
|
|
308
|
+
fix,
|
|
309
|
+
...at,
|
|
310
|
+
...(tag ? { tag } : {}),
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
/** A value written bare whose declared type is not text. */
|
|
314
|
+
printedBare(field, path, at, tag) {
|
|
315
|
+
if (field.type !== 'object' && field.type !== 'list' && field.type !== 'record')
|
|
316
|
+
return;
|
|
317
|
+
const [what, fix] = field.type === 'object'
|
|
318
|
+
? [
|
|
319
|
+
'an object, so printing it writes [object Object]',
|
|
320
|
+
'print one of its fields, loop over it, or pass it to a helper (formatDate for a date)',
|
|
321
|
+
]
|
|
322
|
+
: field.type === 'list'
|
|
323
|
+
? [
|
|
324
|
+
'a list, so printing it writes its entries run together, not their fields',
|
|
325
|
+
'loop over it, print one of its entries, or pass it to a helper',
|
|
326
|
+
]
|
|
327
|
+
: [
|
|
328
|
+
'a record, so printing it writes [object Object]',
|
|
329
|
+
'loop over it, print one of its entries, or pass it to a helper',
|
|
330
|
+
];
|
|
331
|
+
const sentence = fix[0].toUpperCase() + fix.slice(1);
|
|
332
|
+
this.shapeMismatch(path, `'${path}' is ${what}. ${sentence}.`, fix, at, tag);
|
|
333
|
+
}
|
|
334
|
+
/** A loop over a value that is not a list. */
|
|
335
|
+
loopOver(field, path, at, tag) {
|
|
336
|
+
if (field.type === 'list' || field.type === 'record')
|
|
337
|
+
return;
|
|
338
|
+
const message = field.type === 'object'
|
|
339
|
+
? `'${path}' is an object with fixed fields, not a list, so looping over it walks its field names and values, not entries. Print its fields by name, or loop over a list.`
|
|
340
|
+
: `'${path}' is ${withArticle(field)}, not a list, so looping over it does not visit entries. Loop over a list, or print it directly.`;
|
|
341
|
+
this.shapeMismatch(path, message, 'loop over a list, or print the value directly', at, tag);
|
|
342
|
+
}
|
|
343
|
+
/** `@key` where the loop is over a list. */
|
|
344
|
+
listKey(at, tag) {
|
|
345
|
+
this.shapeMismatch('@key', "A list's entries have positions, not keys, so '@key' is the position. A layout written for a keyed value reads like this; read the entry's own fields instead.", "read the entry's own fields instead of '@key'", at, tag);
|
|
346
|
+
}
|
|
347
|
+
/** A date helper or filter given a typed value that is not the shape it takes. */
|
|
348
|
+
dateInput(helper, field, path, at, tag) {
|
|
349
|
+
const shape = DATE_SHAPES[helper];
|
|
350
|
+
if (!shape || shape.is(field))
|
|
351
|
+
return;
|
|
352
|
+
this.shapeMismatch(path, `'${path}' is ${withArticle(field)}, not ${shape.what}, so ${helper} cannot format it. Pass ${shape.what} (${shape.example}).`, `pass ${shape.what} to ${helper}`, at, tag);
|
|
353
|
+
}
|
|
274
354
|
/** Report whatever a resolution says is wrong. */
|
|
275
355
|
resolution(r, path, line, column, tag) {
|
|
276
356
|
if (r.kind === 'unknown-root')
|
|
@@ -402,6 +482,8 @@ function walkHandlebars(ast, scope, helpers, sink, layoutCalls) {
|
|
|
402
482
|
end: s?.end ?? 0,
|
|
403
483
|
};
|
|
404
484
|
};
|
|
485
|
+
/** The nearest `each` is over a declared list: `@key` there is a position. */
|
|
486
|
+
let eachOverList = false;
|
|
405
487
|
const ref = (node, reach, tag) => {
|
|
406
488
|
if (!node)
|
|
407
489
|
return;
|
|
@@ -410,6 +492,8 @@ function walkHandlebars(ast, scope, helpers, sink, layoutCalls) {
|
|
|
410
492
|
if (!isPath(node))
|
|
411
493
|
return;
|
|
412
494
|
const path = readPath(node);
|
|
495
|
+
if (path.data && eachOverList && !path.depth && path.parts.join('.') === 'key')
|
|
496
|
+
sink.listKey(atOf(node.loc), tag);
|
|
413
497
|
if (path.data || !path.parts.length)
|
|
414
498
|
return;
|
|
415
499
|
const r = resolveHandlebarsPath(path, reach, scope);
|
|
@@ -464,6 +548,12 @@ function walkHandlebars(ast, scope, helpers, sink, layoutCalls) {
|
|
|
464
548
|
else if (name === undefined)
|
|
465
549
|
ref(node.path, reach, tag);
|
|
466
550
|
args(node, reach, tag);
|
|
551
|
+
const first = node.params?.[0];
|
|
552
|
+
if (name !== undefined && name in DATE_SHAPES && isPath(first)) {
|
|
553
|
+
const field = asVarField(typeOfHandlebarsPath(readPath(first), reach, scope));
|
|
554
|
+
if (field)
|
|
555
|
+
sink.dateInput(name, field, first.original, atOf(first.loc), tag);
|
|
556
|
+
}
|
|
467
557
|
};
|
|
468
558
|
const program = (p, reach) => {
|
|
469
559
|
for (const stmt of p?.body ?? [])
|
|
@@ -482,7 +572,13 @@ function walkHandlebars(ast, scope, helpers, sink, layoutCalls) {
|
|
|
482
572
|
const name = simpleName(m.path);
|
|
483
573
|
if (name !== undefined && helpers.has(name))
|
|
484
574
|
return;
|
|
485
|
-
|
|
575
|
+
ref(m.path, reach, tag);
|
|
576
|
+
if (isPath(m.path)) {
|
|
577
|
+
const field = asVarField(typeOfHandlebarsPath(readPath(m.path), reach, scope));
|
|
578
|
+
if (field)
|
|
579
|
+
sink.printedBare(field, m.path.original, atOf(m.path.loc), tag);
|
|
580
|
+
}
|
|
581
|
+
return;
|
|
486
582
|
}
|
|
487
583
|
case 'BlockStatement': {
|
|
488
584
|
const b = node;
|
|
@@ -500,7 +596,16 @@ function walkHandlebars(ast, scope, helpers, sink, layoutCalls) {
|
|
|
500
596
|
const target = (helper === 'each' || helper === 'with') && isPath(first)
|
|
501
597
|
? typeOfHandlebarsPath(readPath(first), reach, scope)
|
|
502
598
|
: undefined;
|
|
599
|
+
if (helper === 'each' && isPath(first)) {
|
|
600
|
+
const field = asVarField(target);
|
|
601
|
+
if (field)
|
|
602
|
+
sink.loopOver(field, first.original, atOf(first.loc), tag);
|
|
603
|
+
}
|
|
604
|
+
const outerEachOverList = eachOverList;
|
|
605
|
+
if (helper === 'each')
|
|
606
|
+
eachOverList = asVarField(target)?.type === 'list';
|
|
503
607
|
program(b.program, enterHandlebarsBlock(reach, helper, target, b.program?.blockParams ?? []));
|
|
608
|
+
eachOverList = outerEachOverList;
|
|
504
609
|
// An `{{else}}` runs in the reach the block was opened in: an
|
|
505
610
|
// `each` over nothing, a `with` of nothing — never the element.
|
|
506
611
|
program(b.inverse, enterHandlebarsBlock(reach, 'if', undefined, b.inverse?.blockParams ?? []));
|
|
@@ -678,6 +783,9 @@ function walkLiquid(templates, src, scope, sink) {
|
|
|
678
783
|
const key = call.key;
|
|
679
784
|
sink.layoutCall(key, call.keyAt, call.reference, call.referenceAt, scope[key] === undefined && key in analysis.globals, tag);
|
|
680
785
|
});
|
|
786
|
+
// A global use by where it starts: loop variables and assigns are not in
|
|
787
|
+
// `globals`, so a shape is only judged on a name the scope supplies.
|
|
788
|
+
const typedAt = new Map();
|
|
681
789
|
for (const [root, uses] of Object.entries(analysis.globals))
|
|
682
790
|
for (const use of uses) {
|
|
683
791
|
const { row, col } = use.location;
|
|
@@ -686,11 +794,14 @@ function walkLiquid(templates, src, scope, sink) {
|
|
|
686
794
|
// A dynamic segment (`a[k]`) ends what can be checked; `k` is
|
|
687
795
|
// reported on its own, as the analyser lists it separately.
|
|
688
796
|
const segs = [];
|
|
797
|
+
let whole = true;
|
|
689
798
|
for (const s of use.segments.slice(1)) {
|
|
690
799
|
if (typeof s === 'string' || typeof s === 'number')
|
|
691
800
|
segs.push(String(s));
|
|
692
|
-
else
|
|
801
|
+
else {
|
|
802
|
+
whole = false;
|
|
693
803
|
break;
|
|
804
|
+
}
|
|
694
805
|
}
|
|
695
806
|
const decl = scope[root];
|
|
696
807
|
if (decl === undefined) {
|
|
@@ -700,7 +811,53 @@ function walkLiquid(templates, src, scope, sink) {
|
|
|
700
811
|
const r = resolveLiquidPath(decl, segs, root);
|
|
701
812
|
if (!r.ok)
|
|
702
813
|
sink.badPath(r, root, written, row, col);
|
|
814
|
+
else if (whole && r.checked && r.field)
|
|
815
|
+
typedAt.set(start, r.field);
|
|
703
816
|
}
|
|
817
|
+
liquidShapes(templates, lines, typedAt, sink);
|
|
818
|
+
}
|
|
819
|
+
/** The written path a Liquid token spans, when it is a plain property access. */
|
|
820
|
+
const liquidPathToken = (t) => {
|
|
821
|
+
const tok = t;
|
|
822
|
+
return tok?.kind === TokenKind.PropertyAccess
|
|
823
|
+
? { begin: tok.begin, end: tok.end, text: tok.getText() }
|
|
824
|
+
: undefined;
|
|
825
|
+
};
|
|
826
|
+
/** Shape mismatches in Liquid: an output with no filter, a `for` collection, a date filter's input. */
|
|
827
|
+
function liquidShapes(templates, lines, typedAt, sink) {
|
|
828
|
+
const at = (p) => ({
|
|
829
|
+
...positionAtOffset(lines, p.begin),
|
|
830
|
+
start: p.begin,
|
|
831
|
+
end: p.end,
|
|
832
|
+
});
|
|
833
|
+
const typed = (t) => {
|
|
834
|
+
const p = liquidPathToken(t);
|
|
835
|
+
const field = p && typedAt.get(p.begin);
|
|
836
|
+
return p && field ? { p, field } : undefined;
|
|
837
|
+
};
|
|
838
|
+
liquidNodes(templates, (t, tag) => {
|
|
839
|
+
if (t instanceof Output) {
|
|
840
|
+
const postfix = t.value.initial.postfix;
|
|
841
|
+
const first = postfix.length === 1 ? typed(postfix[0]) : undefined;
|
|
842
|
+
if (!first)
|
|
843
|
+
return;
|
|
844
|
+
const filter = t.value.filters[0];
|
|
845
|
+
if (!filter)
|
|
846
|
+
sink.printedBare(first.field, first.p.text, at(first.p), tag);
|
|
847
|
+
}
|
|
848
|
+
else if (t instanceof ForTag) {
|
|
849
|
+
const c = typed(t.collection);
|
|
850
|
+
if (c)
|
|
851
|
+
sink.loopOver(c.field, c.p.text, at(c.p), tag);
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
for (const { value, tag } of liquidValues(templates)) {
|
|
855
|
+
const postfix = value.initial.postfix;
|
|
856
|
+
const first = postfix.length === 1 ? typed(postfix[0]) : undefined;
|
|
857
|
+
const filter = value.filters[0];
|
|
858
|
+
if (first && filter && filter.name in DATE_SHAPES)
|
|
859
|
+
sink.dateInput(filter.name, first.field, first.p.text, at(first.p), tag);
|
|
860
|
+
}
|
|
704
861
|
}
|
|
705
862
|
/** A tag or output's `{{ … }}`/`{% … %}` span. */
|
|
706
863
|
const tokenSpan = (t) => {
|
|
@@ -714,20 +871,26 @@ const tokenSpan = (t) => {
|
|
|
714
871
|
*/
|
|
715
872
|
function liquidValues(templates) {
|
|
716
873
|
const out = [];
|
|
717
|
-
|
|
718
|
-
const tag = tokenSpan(t);
|
|
874
|
+
liquidNodes(templates, (t, tag) => {
|
|
719
875
|
const impl = t;
|
|
720
876
|
if (impl.arguments)
|
|
721
877
|
for (const arg of impl.arguments())
|
|
722
878
|
if (arg instanceof Value)
|
|
723
879
|
out.push({ value: arg, tag });
|
|
880
|
+
});
|
|
881
|
+
return out;
|
|
882
|
+
}
|
|
883
|
+
/** Every node of a parsed template, children after their parent, in source order. */
|
|
884
|
+
function liquidNodes(templates, visit) {
|
|
885
|
+
const walk = (t) => {
|
|
886
|
+
visit(t, tokenSpan(t));
|
|
887
|
+
const impl = t;
|
|
724
888
|
if (impl.children)
|
|
725
889
|
for (const child of toValueSync(impl.children(false, true)) ?? [])
|
|
726
|
-
|
|
890
|
+
walk(child);
|
|
727
891
|
};
|
|
728
892
|
for (const t of templates)
|
|
729
|
-
|
|
730
|
-
return out;
|
|
893
|
+
walk(t);
|
|
731
894
|
}
|
|
732
895
|
/** Judge the shape of the `layout` filter at `index` in `value`. One judgement for the check and the listing. */
|
|
733
896
|
function liquidLayoutCall(value, index, lines) {
|
package/dist/templateFit.js
CHANGED
|
@@ -367,7 +367,10 @@ export function variableSeedFindings(seeds, checking, variable = getVariable) {
|
|
|
367
367
|
});
|
|
368
368
|
continue;
|
|
369
369
|
}
|
|
370
|
-
const result = checking.check(seed.engine, seed.body, decl.scope,
|
|
370
|
+
const result = checking.check(seed.engine, seed.body, decl.scope, {
|
|
371
|
+
...checking.options,
|
|
372
|
+
variableLayout: true,
|
|
373
|
+
});
|
|
371
374
|
const refuse = new Set(checking.refuse ?? SCOPE_FINDING_KINDS);
|
|
372
375
|
// Names and paths the scope does not supply — never a parse finding:
|
|
373
376
|
// the packager does not know the instance's helpers, filters and block
|
package/dist/validate.js
CHANGED
|
@@ -1222,6 +1222,75 @@ export function validate(doc, options = {}) {
|
|
|
1222
1222
|
fix: `add connection: slot.connectionOf('${generate.key}') to '${n.key}', so the prompt is written for the connection that sends it`,
|
|
1223
1223
|
});
|
|
1224
1224
|
}
|
|
1225
|
+
// ── firsthand (opt-in, 2026-11-15) — the reads agree ──────────────────────
|
|
1226
|
+
// `firsthandFor` leaves out what the speaker was not there for, on each of
|
|
1227
|
+
// three reads: session history, earlier scenes, history entries. Among the
|
|
1228
|
+
// read types the document holds, if one has a node wired with it and
|
|
1229
|
+
// another has none, the prompt would carry reads that disagree: warn on
|
|
1230
|
+
// every node of each unwired type. A wired history-entries node whose
|
|
1231
|
+
// `exclusions` reach no eligibility check leaves nothing out: warn on it.
|
|
1232
|
+
{
|
|
1233
|
+
const READS = [
|
|
1234
|
+
{
|
|
1235
|
+
id: 'core:query/session-history',
|
|
1236
|
+
reads: 'reads every message',
|
|
1237
|
+
fed: 'the session history',
|
|
1238
|
+
short: 'the history',
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
id: 'core:query/earlier-scenes',
|
|
1242
|
+
reads: "reads every earlier scene's summary",
|
|
1243
|
+
fed: 'the earlier scenes',
|
|
1244
|
+
short: 'the earlier scenes',
|
|
1245
|
+
},
|
|
1246
|
+
{
|
|
1247
|
+
id: 'core:query/history-entries',
|
|
1248
|
+
reads: 'reads every history entry',
|
|
1249
|
+
fed: 'the history entries',
|
|
1250
|
+
short: 'the history entries',
|
|
1251
|
+
},
|
|
1252
|
+
];
|
|
1253
|
+
const wiredFor = (n) => {
|
|
1254
|
+
const v = n.config?.firsthandFor;
|
|
1255
|
+
if (v !== undefined && v !== null && v !== false)
|
|
1256
|
+
return true;
|
|
1257
|
+
return doc.edges.some((e) => e.to === n.key && e.toPort.split('.')[0] === 'firsthandFor');
|
|
1258
|
+
};
|
|
1259
|
+
const present = READS.map((r) => ({
|
|
1260
|
+
...r,
|
|
1261
|
+
nodes: doc.nodes.filter((n) => n.definitionId === r.id && n.definitionVersion === 1),
|
|
1262
|
+
})).filter((r) => r.nodes.length > 0);
|
|
1263
|
+
const feds = present.filter((r) => r.nodes.some(wiredFor));
|
|
1264
|
+
if (feds.length > 0)
|
|
1265
|
+
for (const r of present.filter((p) => !p.nodes.some(wiredFor)))
|
|
1266
|
+
for (const n of r.nodes) {
|
|
1267
|
+
const leaves = feds.length === 1 && feds[0].id === READS[0].id ? 'leaves' : 'leave';
|
|
1268
|
+
const names = feds.length === 1 && feds[0].short === 'the history' ? 'names' : 'name';
|
|
1269
|
+
f.push({
|
|
1270
|
+
law: 'firsthand 2026-11-15',
|
|
1271
|
+
severity: 'warning',
|
|
1272
|
+
nodeKey: n.key,
|
|
1273
|
+
message: `'${n.key}' ${r.reads}, while ${feds.map((x) => x.fed).join(' and ')} beside it ${leaves} out what the speaker was not there for`,
|
|
1274
|
+
fix: `wire firsthandFor (and firsthandBy, if ${feds.map((x) => x.short).join(' and ')} ${names} one) on '${n.key}' as on ${feds.map((x) => x.short).join(' and ')}`,
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
for (const n of present.find((r) => r.id === 'core:query/history-entries')?.nodes ?? []) {
|
|
1278
|
+
if (!wiredFor(n))
|
|
1279
|
+
continue;
|
|
1280
|
+
const reaches = doc.edges.some((e) => e.from === n.key &&
|
|
1281
|
+
e.fromPort === 'exclusions' &&
|
|
1282
|
+
e.toPort.split('.')[0] === 'exclusions' &&
|
|
1283
|
+
doc.nodes.some((t) => t.key === e.to && t.definitionId === 'core:task/eligibility'));
|
|
1284
|
+
if (!reaches)
|
|
1285
|
+
f.push({
|
|
1286
|
+
law: 'firsthand 2026-11-15',
|
|
1287
|
+
severity: 'warning',
|
|
1288
|
+
nodeKey: n.key,
|
|
1289
|
+
message: `'${n.key}' leaves out the history entries the speaker was not there for, but its exclusions reach no eligibility check, so nothing is left out`,
|
|
1290
|
+
fix: `wire $.${n.key}.exclusions into the eligibility check's exclusions, beside the lore reads'`,
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1225
1294
|
// ── T1 — a template fits where it is rendered (typed templates P5) ─────────
|
|
1226
1295
|
// Collisions and forbidden kinds in a template node's scope, a band with
|
|
1227
1296
|
// no variable, and — given the checker — every template source the
|
|
@@ -64,6 +64,25 @@ export declare function formatVariableLayoutReference(parts: VariableLayoutRefer
|
|
|
64
64
|
* @experimental
|
|
65
65
|
*/
|
|
66
66
|
export declare const VARIABLE_LAYOUT_HELPER = "layout";
|
|
67
|
+
/**
|
|
68
|
+
* 🚧 The helper (Handlebars) and filter (Liquid) that print a date value:
|
|
69
|
+
* `{{formatDate date}}`, `{{ date | formatDate }}`. Prints from the value
|
|
70
|
+
* alone (the calendar's spelling when it carries names); prints nothing for
|
|
71
|
+
* null or a value of the wrong shape. Named apart from the `date` field
|
|
72
|
+
* because a Handlebars `{{date}}` inside a row would call a helper named
|
|
73
|
+
* `date`, and Liquid already has a `date` filter.
|
|
74
|
+
* @experimental
|
|
75
|
+
*/
|
|
76
|
+
export declare const FORMAT_DATE_HELPER = "formatDate";
|
|
77
|
+
/**
|
|
78
|
+
* 🚧 The helper / filter that prints a date delta: `{{formatDateDelta dateDelta}}`,
|
|
79
|
+
* `{{ dateDelta | formatDateDelta }}`. Prints from the value alone (sign, then
|
|
80
|
+
* year, month, day, time); prints nothing for null or a value of the wrong
|
|
81
|
+
* shape. Named apart from the `dateDelta` field for the reason
|
|
82
|
+
* `FORMAT_DATE_HELPER` is.
|
|
83
|
+
* @experimental
|
|
84
|
+
*/
|
|
85
|
+
export declare const FORMAT_DATE_DELTA_HELPER = "formatDateDelta";
|
|
67
86
|
/**
|
|
68
87
|
* One layout a variable offers, as a `layout` call's completion and hover
|
|
69
88
|
* list it, and as the template check accepts it
|
package/dist/variableLayouts.js
CHANGED
|
@@ -78,6 +78,25 @@ export function formatVariableLayoutReference(parts) {
|
|
|
78
78
|
* @experimental
|
|
79
79
|
*/
|
|
80
80
|
export const VARIABLE_LAYOUT_HELPER = 'layout';
|
|
81
|
+
/**
|
|
82
|
+
* 🚧 The helper (Handlebars) and filter (Liquid) that print a date value:
|
|
83
|
+
* `{{formatDate date}}`, `{{ date | formatDate }}`. Prints from the value
|
|
84
|
+
* alone (the calendar's spelling when it carries names); prints nothing for
|
|
85
|
+
* null or a value of the wrong shape. Named apart from the `date` field
|
|
86
|
+
* because a Handlebars `{{date}}` inside a row would call a helper named
|
|
87
|
+
* `date`, and Liquid already has a `date` filter.
|
|
88
|
+
* @experimental
|
|
89
|
+
*/
|
|
90
|
+
export const FORMAT_DATE_HELPER = 'formatDate';
|
|
91
|
+
/**
|
|
92
|
+
* 🚧 The helper / filter that prints a date delta: `{{formatDateDelta dateDelta}}`,
|
|
93
|
+
* `{{ dateDelta | formatDateDelta }}`. Prints from the value alone (sign, then
|
|
94
|
+
* year, month, day, time); prints nothing for null or a value of the wrong
|
|
95
|
+
* shape. Named apart from the `dateDelta` field for the reason
|
|
96
|
+
* `FORMAT_DATE_HELPER` is.
|
|
97
|
+
* @experimental
|
|
98
|
+
*/
|
|
99
|
+
export const FORMAT_DATE_DELTA_HELPER = 'formatDateDelta';
|
|
81
100
|
/**
|
|
82
101
|
* A variable id split into owner, name and major, or `null` when it is not
|
|
83
102
|
* one — `core:var/characters@1`. A camelCase name is tolerated: the variable
|