@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/storyTime.d.ts
CHANGED
|
@@ -40,6 +40,58 @@ export interface StoryTime {
|
|
|
40
40
|
/** 0–59; read only beside an hour. */
|
|
41
41
|
minute?: number | null;
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* 🚧 One part of a date value: its number, and the calendar's name for it when
|
|
45
|
+
* the calendar names one.
|
|
46
|
+
* @experimental
|
|
47
|
+
*/
|
|
48
|
+
export interface StoryDatePart {
|
|
49
|
+
number: number;
|
|
50
|
+
name?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 🚧 A story date as a layout reads it (owner 2026-11-15). The same value on
|
|
54
|
+
* every dated row and on the current date, so a layout prints all of them one
|
|
55
|
+
* way. `name` comes only from the lorebook's calendar and is absent where it
|
|
56
|
+
* names nothing (free-form: no names). The value carries everything needed to
|
|
57
|
+
* print it; a layout has no calendar.
|
|
58
|
+
* @experimental
|
|
59
|
+
*/
|
|
60
|
+
export interface StoryDateValue {
|
|
61
|
+
/**
|
|
62
|
+
* `name`: the era-spelled year (`Year 412 AR`), only under a declared calendar.
|
|
63
|
+
* For a date that calendar cannot place it is the fallback spelling `Year 412`
|
|
64
|
+
* and the month and day carry no name: the date prints as `formatStoryTime`'s
|
|
65
|
+
* free-form text.
|
|
66
|
+
*/
|
|
67
|
+
year: StoryDatePart;
|
|
68
|
+
/** `name`: the month's name. */
|
|
69
|
+
month: StoryDatePart | null;
|
|
70
|
+
/** `name`: the weekday. */
|
|
71
|
+
day: StoryDatePart | null;
|
|
72
|
+
time: {
|
|
73
|
+
hour: number;
|
|
74
|
+
minute: number;
|
|
75
|
+
} | null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 🚧 How far a row's date is from the session's current date: row minus now.
|
|
79
|
+
* Magnitudes carry no names (a month name labels a position, not a length). A
|
|
80
|
+
* part is `null` where it was not compared or could not be known, never 0 for
|
|
81
|
+
* "unknown".
|
|
82
|
+
* @experimental
|
|
83
|
+
*/
|
|
84
|
+
export interface StoryDateDelta {
|
|
85
|
+
sign: -1 | 0 | 1;
|
|
86
|
+
/** Non-negative. */
|
|
87
|
+
year: number;
|
|
88
|
+
month: number | null;
|
|
89
|
+
day: number | null;
|
|
90
|
+
time: {
|
|
91
|
+
hour: number;
|
|
92
|
+
minute: number;
|
|
93
|
+
} | null;
|
|
94
|
+
}
|
|
43
95
|
/**
|
|
44
96
|
* The range each part of a story time takes on EVERY rung of the calendar —
|
|
45
97
|
* the free-form rule, and the one validity definition for a stored date.
|
|
@@ -155,14 +207,38 @@ export interface StoryEra {
|
|
|
155
207
|
backwards?: boolean;
|
|
156
208
|
}
|
|
157
209
|
/**
|
|
158
|
-
* One extra day in one month, every `every` years (a year divisible by it)
|
|
210
|
+
* One extra day in one month, every `every` years (a year divisible by it) —
|
|
211
|
+
* except every `skipEvery` years, except every `keepEvery` years. The real
|
|
212
|
+
* (Gregorian) rule is `{ every: 4, month: 2, skipEvery: 100, keepEvery: 400 }`;
|
|
213
|
+
* a rule with neither is every `every` years, as ever. The rule is a chain of
|
|
214
|
+
* levels (`storyLeapLevels`), at most `STORY_LEAP_MAX_LEVELS`: the last level
|
|
215
|
+
* that divides a year decides — an odd-numbered level adds the day, an
|
|
216
|
+
* even-numbered one takes it away.
|
|
159
217
|
* @experimental
|
|
160
218
|
*/
|
|
161
219
|
export interface StoryLeapRule {
|
|
162
220
|
every: number;
|
|
163
221
|
/** 1-based. */
|
|
164
222
|
month: number;
|
|
223
|
+
/** 🚧 A whole multiple of `every`: years divisible by it are not leap years … */
|
|
224
|
+
skipEvery?: number;
|
|
225
|
+
/** 🚧 … unless also divisible by this, a whole multiple of `skipEvery` (needs it). */
|
|
226
|
+
keepEvery?: number;
|
|
227
|
+
/** 🚧 The levels after `keepEvery`, each a whole multiple of the one before (needs `keepEvery`). */
|
|
228
|
+
more?: number[];
|
|
165
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* 🚧 The most levels a leap rule may chain (`every`, `skipEvery`, `keepEvery`
|
|
232
|
+
* and `more` together).
|
|
233
|
+
* @experimental
|
|
234
|
+
*/
|
|
235
|
+
export declare const STORY_LEAP_MAX_LEVELS = 8;
|
|
236
|
+
/**
|
|
237
|
+
* 🚧 A leap rule's levels in order — `[every, skipEvery?, keepEvery?, ...more]`,
|
|
238
|
+
* stopping at the first absent (falsy) level.
|
|
239
|
+
* @experimental
|
|
240
|
+
*/
|
|
241
|
+
export declare function storyLeapLevels(rule: StoryLeapRule): number[];
|
|
166
242
|
/**
|
|
167
243
|
* A book's declared calendar — the rung above free-form.
|
|
168
244
|
*
|
package/dist/storyTime.js
CHANGED
|
@@ -177,6 +177,34 @@ export function formatStoryTime(time, calendar) {
|
|
|
177
177
|
out += `, Day ${time.day}`;
|
|
178
178
|
return out + clock;
|
|
179
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* 🚧 The most levels a leap rule may chain (`every`, `skipEvery`, `keepEvery`
|
|
182
|
+
* and `more` together).
|
|
183
|
+
* @experimental
|
|
184
|
+
*/
|
|
185
|
+
export const STORY_LEAP_MAX_LEVELS = 8;
|
|
186
|
+
/**
|
|
187
|
+
* 🚧 A leap rule's levels in order — `[every, skipEvery?, keepEvery?, ...more]`,
|
|
188
|
+
* stopping at the first absent (falsy) level.
|
|
189
|
+
* @experimental
|
|
190
|
+
*/
|
|
191
|
+
export function storyLeapLevels(rule) {
|
|
192
|
+
const out = [rule.every];
|
|
193
|
+
if (!rule.skipEvery)
|
|
194
|
+
return out;
|
|
195
|
+
out.push(rule.skipEvery);
|
|
196
|
+
if (!rule.keepEvery)
|
|
197
|
+
return out;
|
|
198
|
+
out.push(rule.keepEvery);
|
|
199
|
+
if (Array.isArray(rule.more)) {
|
|
200
|
+
for (const n of rule.more) {
|
|
201
|
+
if (!n)
|
|
202
|
+
break;
|
|
203
|
+
out.push(n);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return out;
|
|
207
|
+
}
|
|
180
208
|
const isInt = (n) => typeof n === 'number' && Number.isInteger(n);
|
|
181
209
|
const floorDiv = (a, b) => Math.floor(a / b);
|
|
182
210
|
const mod = (a, b) => ((a % b) + b) % b;
|
|
@@ -223,6 +251,38 @@ export function storyCalendarProblems(calendar, opts) {
|
|
|
223
251
|
out.push('A leap rule needs a whole number of years, 1 or more.');
|
|
224
252
|
if (!isInt(c.leap.month) || c.leap.month < 1 || c.leap.month > months)
|
|
225
253
|
out.push('A leap rule must name one of the months.');
|
|
254
|
+
const { every, skipEvery, keepEvery } = c.leap;
|
|
255
|
+
if (skipEvery !== undefined && (!isInt(skipEvery) || skipEvery < 1 || (isInt(every) && every >= 1 && skipEvery % every !== 0)))
|
|
256
|
+
out.push('A leap rule’s skipped years must be a whole number, a multiple of its leap years.');
|
|
257
|
+
if (keepEvery !== undefined) {
|
|
258
|
+
if (skipEvery === undefined)
|
|
259
|
+
out.push('A leap rule can keep years only when it skips some.');
|
|
260
|
+
else if (!isInt(keepEvery) || keepEvery < 1 || (isInt(skipEvery) && skipEvery >= 1 && keepEvery % skipEvery !== 0))
|
|
261
|
+
out.push('A leap rule’s kept years must be a whole number, a multiple of its skipped years.');
|
|
262
|
+
}
|
|
263
|
+
const more = c.leap.more;
|
|
264
|
+
if (more !== undefined) {
|
|
265
|
+
const further = 'Each further level of a leap rule must be a whole number, a multiple of the level before.';
|
|
266
|
+
if (!Array.isArray(more))
|
|
267
|
+
out.push(further);
|
|
268
|
+
else {
|
|
269
|
+
if (keepEvery === undefined)
|
|
270
|
+
out.push('A leap rule can add more levels only after its kept years.');
|
|
271
|
+
else {
|
|
272
|
+
let before = keepEvery;
|
|
273
|
+
let bad = false;
|
|
274
|
+
for (const n of more) {
|
|
275
|
+
if (!isInt(n) || n < 1 || !isInt(before) || before < 1 || n % before !== 0)
|
|
276
|
+
bad = true;
|
|
277
|
+
before = n;
|
|
278
|
+
}
|
|
279
|
+
if (bad)
|
|
280
|
+
out.push(further);
|
|
281
|
+
}
|
|
282
|
+
if (3 + more.length > STORY_LEAP_MAX_LEVELS)
|
|
283
|
+
out.push(`A leap rule has at most ${STORY_LEAP_MAX_LEVELS} levels.`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
226
286
|
}
|
|
227
287
|
if (c.eras !== undefined) {
|
|
228
288
|
if (!Array.isArray(c.eras))
|
|
@@ -301,7 +361,13 @@ export function parseStoryCalendar(value) {
|
|
|
301
361
|
if (c.yearLabel !== undefined)
|
|
302
362
|
out.yearLabel = c.yearLabel;
|
|
303
363
|
if (c.leap != null)
|
|
304
|
-
out.leap = {
|
|
364
|
+
out.leap = {
|
|
365
|
+
every: c.leap.every,
|
|
366
|
+
month: c.leap.month,
|
|
367
|
+
...(c.leap.skipEvery !== undefined ? { skipEvery: c.leap.skipEvery } : {}),
|
|
368
|
+
...(c.leap.keepEvery !== undefined ? { keepEvery: c.leap.keepEvery } : {}),
|
|
369
|
+
...(c.leap.more !== undefined && c.leap.more.length > 0 ? { more: [...c.leap.more] } : {}),
|
|
370
|
+
};
|
|
305
371
|
if (c.eras !== undefined)
|
|
306
372
|
out.eras = c.eras.map((e) => ({ name: e.name.trim(), start: e.start, ...(e.backwards ? { backwards: true } : {}) }));
|
|
307
373
|
if (c.periods !== undefined)
|
|
@@ -310,7 +376,22 @@ export function parseStoryCalendar(value) {
|
|
|
310
376
|
out.seasons = { days: c.seasons.days, labels: [...c.seasons.labels] };
|
|
311
377
|
return out;
|
|
312
378
|
}
|
|
313
|
-
const isLeapYear = (year, calendar) =>
|
|
379
|
+
const isLeapYear = (year, calendar) => {
|
|
380
|
+
const leap = calendar.leap;
|
|
381
|
+
if (!leap)
|
|
382
|
+
return false;
|
|
383
|
+
let count = 0;
|
|
384
|
+
for (const level of storyLeapLevels(leap)) {
|
|
385
|
+
if (mod(year, level) !== 0)
|
|
386
|
+
break;
|
|
387
|
+
count++;
|
|
388
|
+
}
|
|
389
|
+
return count % 2 === 1;
|
|
390
|
+
};
|
|
391
|
+
/** Leap days in the years before `year + 1` (years `…, year - 1, year`), counted from year 0. */
|
|
392
|
+
const leapDaysThrough = (year, leap) => leap
|
|
393
|
+
? storyLeapLevels(leap).reduce((n, level, i) => n + (i % 2 === 0 ? 1 : -1) * floorDiv(year, level), 0)
|
|
394
|
+
: 0;
|
|
314
395
|
/**
|
|
315
396
|
* How many days a month has in a given year — its length, plus the leap day
|
|
316
397
|
* when the leap rule names it and the year is a leap year.
|
|
@@ -373,7 +454,7 @@ export function storyDayIndex(time, calendar) {
|
|
|
373
454
|
return null;
|
|
374
455
|
const yearDays = calendar.months.reduce((n, m) => n + m.days, 0);
|
|
375
456
|
const y = time.year - 1;
|
|
376
|
-
let days = y * yearDays + (
|
|
457
|
+
let days = y * yearDays + leapDaysThrough(y, calendar.leap);
|
|
377
458
|
for (let m = 1; m < time.month; m++)
|
|
378
459
|
days += storyDaysInMonth(time.year, m, calendar);
|
|
379
460
|
return days + time.day - 1;
|
|
@@ -448,7 +529,9 @@ export function nextStoryTime(from, calendar) {
|
|
|
448
529
|
*/
|
|
449
530
|
export function storyTimeOfDayIndex(index, calendar) {
|
|
450
531
|
const yearDays = calendar.months.reduce((n, m) => n + m.days, 0);
|
|
451
|
-
const
|
|
532
|
+
const leap = calendar.leap;
|
|
533
|
+
const average = yearDays +
|
|
534
|
+
(leap ? storyLeapLevels(leap).reduce((n, level, i) => n + (i % 2 === 0 ? 1 : -1) / level, 0) : 0);
|
|
452
535
|
const startOf = (year) => storyDayIndex({ year, month: 1, day: 1 }, calendar);
|
|
453
536
|
// An estimate by the average year, then corrected: at most a step or two.
|
|
454
537
|
let year = Math.floor(index / average) + 1;
|
|
@@ -511,11 +594,13 @@ export function advanceStoryTime(from, by, unit, calendar) {
|
|
|
511
594
|
return { problem: `The clock does not land: ${landing}` };
|
|
512
595
|
const spelled = formatStoryTime(start, calendar);
|
|
513
596
|
const out = { ...start };
|
|
514
|
-
const stepDays = (days) => {
|
|
597
|
+
const stepDays = (days, past) => {
|
|
515
598
|
if (days === 0)
|
|
516
599
|
return null;
|
|
517
600
|
if (!has(out.month) || !has(out.day))
|
|
518
|
-
return
|
|
601
|
+
return past === 'midnight'
|
|
602
|
+
? `The clock has no date at ${spelled}, so it can't run past midnight.`
|
|
603
|
+
: `The clock has no day at ${spelled}, so it can't count days.`;
|
|
519
604
|
if (calendar) {
|
|
520
605
|
const moved = storyTimeOfDayIndex(storyDayIndex(out, calendar) + days, calendar);
|
|
521
606
|
out.year = moved.year;
|
|
@@ -533,10 +618,10 @@ export function advanceStoryTime(from, by, unit, calendar) {
|
|
|
533
618
|
const total = (has(out.hour) ? out.hour : 0) * 60 + (has(out.minute) ? out.minute : 0) + by * (unit === 'hours' ? 60 : 1);
|
|
534
619
|
out.hour = floorDiv(mod(total, 1440), 60);
|
|
535
620
|
out.minute = mod(total, 60);
|
|
536
|
-
problem = stepDays(floorDiv(total, 1440));
|
|
621
|
+
problem = stepDays(floorDiv(total, 1440), 'midnight');
|
|
537
622
|
}
|
|
538
623
|
else if (unit === 'days')
|
|
539
|
-
problem = stepDays(by);
|
|
624
|
+
problem = stepDays(by, 'days');
|
|
540
625
|
else if (unit === 'months') {
|
|
541
626
|
if (!has(out.month))
|
|
542
627
|
return { problem: `The clock stands at ${spelled}, with no month to count months from.` };
|
|
@@ -593,6 +678,30 @@ export const STORY_CALENDAR_PRESETS = [
|
|
|
593
678
|
leap: { every: 4, month: 2 },
|
|
594
679
|
},
|
|
595
680
|
},
|
|
681
|
+
{
|
|
682
|
+
id: 'real-calendar',
|
|
683
|
+
name: 'The real calendar',
|
|
684
|
+
calendar: {
|
|
685
|
+
months: [
|
|
686
|
+
{ name: 'January', days: 31 },
|
|
687
|
+
{ name: 'February', days: 28 },
|
|
688
|
+
{ name: 'March', days: 31 },
|
|
689
|
+
{ name: 'April', days: 30 },
|
|
690
|
+
{ name: 'May', days: 31 },
|
|
691
|
+
{ name: 'June', days: 30 },
|
|
692
|
+
{ name: 'July', days: 31 },
|
|
693
|
+
{ name: 'August', days: 31 },
|
|
694
|
+
{ name: 'September', days: 30 },
|
|
695
|
+
{ name: 'October', days: 31 },
|
|
696
|
+
{ name: 'November', days: 30 },
|
|
697
|
+
{ name: 'December', days: 31 },
|
|
698
|
+
],
|
|
699
|
+
weekdays: WEEK,
|
|
700
|
+
firstWeekday: 0,
|
|
701
|
+
yearLabel: '',
|
|
702
|
+
leap: { every: 4, month: 2, skipEvery: 100, keepEvery: 400 },
|
|
703
|
+
},
|
|
704
|
+
},
|
|
596
705
|
{
|
|
597
706
|
id: 'thirty-day-months',
|
|
598
707
|
name: 'Twelve months of thirty days',
|
package/dist/surfaces.d.ts
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
import type { TurnOrderV1 } from './turnOrder.js';
|
|
51
51
|
import type { ComponentFramework } from './extension.js';
|
|
52
52
|
import type { SettingsSchema } from './settings.js';
|
|
53
|
-
import { type ActionsV1, type AnnexV1, type AttendanceV1, type LayoutV1, type MessageV1, type SessionV1, type ViewerV1, type WidgetRequestKind, type WidgetEvent, type WidgetPayload, type WidgetProtocolVersion, type WidgetScopedSectionName, type WidgetSectionScope, type WidgetWriteGrant, type AppletGrant } from './widgets.js';
|
|
53
|
+
import { type ActionsV1, type AnnexV1, type AttendanceV1, type LayoutV1, type MessageV1, type SessionV1, type ViewerV1, type WidgetRequestKind, type WidgetEvent, type WidgetPayload, type WidgetProtocolVersion, type WidgetScopedSectionName, type WidgetSectionScope, type WidgetWriteGrant, type AppletGrant, type FrontEndMount } from './widgets.js';
|
|
54
54
|
/**
|
|
55
55
|
* Where a package's entry module lives, in the order the toolchain looks.
|
|
56
56
|
* One list, shared by `serene-pub build` and the preview harness, so "the
|
|
@@ -156,13 +156,36 @@ export type HostFrameMessage = {
|
|
|
156
156
|
assetsBase?: string;
|
|
157
157
|
/** 🚧 M0 (L1): whether the viewer has this session in full screen as the frame boots; later changes arrive as the `fullscreen` event. Absent from hosts that predate it. */
|
|
158
158
|
fullscreen?: boolean;
|
|
159
|
+
/** 🚧 m3-core: what this frame is mounted as — `applet` (the launcher, and an applet genre's session view), `widget` (a frame placed in a session), `page` (a plugin page). Absent from hosts that predate it. */
|
|
160
|
+
mount?: FrontEndMount;
|
|
161
|
+
/**
|
|
162
|
+
* 🚧 m3: whether a session is mounted around this frame — `true` on a session page (the
|
|
163
|
+
* `session` section follows), `false` for an applet's launcher (no session ever comes),
|
|
164
|
+
* absent from hosts that predate it and from mounts that are neither. The same `applet`
|
|
165
|
+
* mount serves both places, so this is how a frame tells the launcher from the game
|
|
166
|
+
* without waiting to see which section arrives first.
|
|
167
|
+
*/
|
|
168
|
+
inSession?: boolean;
|
|
159
169
|
} | {
|
|
160
170
|
t: 'session';
|
|
161
171
|
session: SessionV1;
|
|
162
172
|
} | {
|
|
163
173
|
t: 'messages';
|
|
164
174
|
messages: MessageV1[];
|
|
165
|
-
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Replace the held row with this `id` — in `messages` and in any `channel`
|
|
178
|
+
* list holding it; an id not held is ignored. Adds and removes still arrive
|
|
179
|
+
* as full `messages` / `channel` lists. A host sends it only to a peer that
|
|
180
|
+
* takes it: a component's wire (core's `WidgetWireOptions.peerTakesOneMessage`),
|
|
181
|
+
* or a frame that declared `takes: ['message']` on its `ready`. It comes when
|
|
182
|
+
* exactly one held row changed, that row is still generating, and ids, order
|
|
183
|
+
* and lanes are unchanged. Everything else arrives as full `messages` /
|
|
184
|
+
* `channel` lists: the row's first appearance (a row joining the log is an
|
|
185
|
+
* add), every add / remove / reorder / lane move, and the settled row (no
|
|
186
|
+
* longer generating). It only ever replaces a row the receiver already holds.
|
|
187
|
+
*/
|
|
188
|
+
| {
|
|
166
189
|
t: 'message';
|
|
167
190
|
message: MessageV1;
|
|
168
191
|
} | {
|
|
@@ -357,6 +380,27 @@ export type HostFrameMessage = {
|
|
|
357
380
|
*/
|
|
358
381
|
export type FrameHostMessage = {
|
|
359
382
|
t: 'ready';
|
|
383
|
+
/**
|
|
384
|
+
* 🚧 The host messages this frame takes beyond the ones every frame
|
|
385
|
+
* gets. One entry today, `'message'`: declared, a streamed update to a
|
|
386
|
+
* row the frame already holds arrives as `{ t: 'message' }` (that one
|
|
387
|
+
* row, to replace by id) instead of the whole list again.
|
|
388
|
+
*
|
|
389
|
+
* Not a grant: it asks for nothing the frame is not already sent — the
|
|
390
|
+
* row is the same row the lists carry, under the same lane scoping. Not
|
|
391
|
+
* a read: it says nothing about which sections the frame wants.
|
|
392
|
+
*
|
|
393
|
+
* Absent, empty, or without `'message'`: full lists, always, as before.
|
|
394
|
+
* Read on every `ready`: a replayed `ready` without it turns it off, and
|
|
395
|
+
* a new port starts without it. A frame may ignore `message` only by not
|
|
396
|
+
* declaring it. A host that predates this field ignores it and keeps
|
|
397
|
+
* posting full lists, so a declaring frame still handles `messages` and
|
|
398
|
+
* `channel`.
|
|
399
|
+
*
|
|
400
|
+
* @experimental
|
|
401
|
+
* @ruling ★P14 (2026-11-13), ★M-1 (2026-11-14)
|
|
402
|
+
*/
|
|
403
|
+
takes?: 'message'[];
|
|
360
404
|
}
|
|
361
405
|
/**
|
|
362
406
|
* ⏳ Fire a function by name.
|
|
@@ -475,6 +519,9 @@ export type FrameHostMessage = {
|
|
|
475
519
|
* that needs an answer must therefore tolerate not getting one, just as it
|
|
476
520
|
* ignores a host message it has never heard of.
|
|
477
521
|
*
|
|
522
|
+
* `ready`'s optional `takes` is part of 2; it needs no new version, because a
|
|
523
|
+
* host that does not read it keeps the old behaviour (full lists).
|
|
524
|
+
*
|
|
478
525
|
* A v1 frame keeps working unchanged: it never sends the frame → host
|
|
479
526
|
* additions, and it must already ignore host messages it does not recognise. A
|
|
480
527
|
* v2 host must still accept `init` from a v1 frame — the version says what the
|
package/dist/surfaces.js
CHANGED
|
@@ -125,6 +125,9 @@ export function parsePluginWidgetId(id) {
|
|
|
125
125
|
* that needs an answer must therefore tolerate not getting one, just as it
|
|
126
126
|
* ignores a host message it has never heard of.
|
|
127
127
|
*
|
|
128
|
+
* `ready`'s optional `takes` is part of 2; it needs no new version, because a
|
|
129
|
+
* host that does not read it keeps the old behaviour (full lists).
|
|
130
|
+
*
|
|
128
131
|
* A v1 frame keeps working unchanged: it never sends the frame → host
|
|
129
132
|
* additions, and it must already ignore host messages it does not recognise. A
|
|
130
133
|
* v2 host must still accept `init` from a v1 frame — the version says what the
|
package/dist/template.d.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { I18n, SlotDecl } from './descriptors.js';
|
|
12
12
|
import type { FieldDecl } from './settings.js';
|
|
13
|
+
import type { VariableLayoutOffer } from './variableLayouts.js';
|
|
13
14
|
/** @experimental */
|
|
14
15
|
export interface TemplateRef {
|
|
15
16
|
/** The root identifier, e.g. `message` in `{{ message.author.name }}`. */
|
|
@@ -99,6 +100,17 @@ export interface VarField {
|
|
|
99
100
|
* answer for a dropped key and a null one.
|
|
100
101
|
*/
|
|
101
102
|
optional?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* 🚧 Root only: the variable whose **variable layout** writes this key out
|
|
105
|
+
* (`core:var/characters@1`) — the key `rendersAt` maps to it. Only such a
|
|
106
|
+
* key may be named by the `layout` helper (Handlebars) or filter (Liquid),
|
|
107
|
+
* and its layouts are the ones that variable offers. Set by the host on the
|
|
108
|
+
* scope it checks against (`laidOutScope`); absent on plain data — a port's
|
|
109
|
+
* output, a prompt field, an annex key — which never has a layout.
|
|
110
|
+
* ⚠ Not the variable's own `scope` (what its layout reads), and ignored on
|
|
111
|
+
* a nested field.
|
|
112
|
+
*/
|
|
113
|
+
laidOutBy?: string;
|
|
102
114
|
}
|
|
103
115
|
/**
|
|
104
116
|
* What one root name in a template's scope is.
|
|
@@ -162,9 +174,17 @@ export interface TemplateFinding {
|
|
|
162
174
|
* - `unknown-name` — a root the scope does not have.
|
|
163
175
|
* - `unknown-path` — a field the declared type contradicts.
|
|
164
176
|
* - `unknown-helper` — a Handlebars helper nobody registered.
|
|
177
|
+
* - 🚧 `layout-argument` — a `layout` call that does not name a laid-out key
|
|
178
|
+
* and a quoted layout reference (`{{{layout characters "core/json@1"}}}`).
|
|
179
|
+
* - 🚧 `unknown-layout` — a layout reference that is malformed, or that the
|
|
180
|
+
* key's variable does not offer.
|
|
181
|
+
* - 🚧 `shape-mismatch` — a template that treats a typed value as a shape it
|
|
182
|
+
* is not (an object printed bare, `each` over a non-list, `@key` over a
|
|
183
|
+
* list, `formatDate` of a non-date) in a variable layout. Always a warning,
|
|
184
|
+
* never refused.
|
|
165
185
|
* @experimental
|
|
166
186
|
*/
|
|
167
|
-
export type TemplateFindingKind = 'syntax' | 'unknown-name' | 'unknown-path' | 'unknown-helper';
|
|
187
|
+
export type TemplateFindingKind = 'syntax' | 'unknown-name' | 'unknown-path' | 'unknown-helper' | 'layout-argument' | 'unknown-layout' | 'shape-mismatch';
|
|
168
188
|
/**
|
|
169
189
|
* What a host's engines register, as names — the checker's input
|
|
170
190
|
* (`@serene-pub/sdk/template-check`). Declared here, on the barrel, so a
|
|
@@ -192,6 +212,23 @@ export interface TemplateCheckOptions {
|
|
|
192
212
|
* undeclared. Non-empty: name and path findings are warnings.
|
|
193
213
|
*/
|
|
194
214
|
untyped?: readonly string[];
|
|
215
|
+
/**
|
|
216
|
+
* 🚧 The layouts each laid-out variable offers, by variable id — what a
|
|
217
|
+
* `layout` call may name for a key whose root carries `laidOutBy`. A
|
|
218
|
+
* reference its variable does not offer is an error. Absent (no host in
|
|
219
|
+
* view, as in the packager): a reference can't be checked, and is a
|
|
220
|
+
* warning. ⚠ Not a preset's `variableLayouts` (the one layout a preset
|
|
221
|
+
* chooses per variable).
|
|
222
|
+
*/
|
|
223
|
+
variableLayoutOffers?: Readonly<Record<string, readonly VariableLayoutOffer[]>>;
|
|
224
|
+
/**
|
|
225
|
+
* 🚧 The source is a variable layout, checked against its variable's own
|
|
226
|
+
* scope; only then are `shape-mismatch` findings reported (a context
|
|
227
|
+
* template receives laid-out keys as text, so the declared shapes do not
|
|
228
|
+
* describe what it prints).
|
|
229
|
+
* @experimental
|
|
230
|
+
*/
|
|
231
|
+
variableLayout?: boolean;
|
|
195
232
|
}
|
|
196
233
|
/** @experimental */
|
|
197
234
|
export interface TemplateSourceCheck {
|
package/dist/templateCheck.d.ts
CHANGED
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
* - **unknown-path** — a field the declared type positively contradicts
|
|
21
21
|
* (`characters.nmae`, a field read straight off a list).
|
|
22
22
|
* - **unknown-helper** — a Handlebars helper nobody registered.
|
|
23
|
+
* - **layout-argument** — a `layout` call that does not name a variable in
|
|
24
|
+
* scope that a variable layout writes out, and a layout reference in quotes.
|
|
25
|
+
* - **unknown-layout** — a layout reference that is malformed, or that the
|
|
26
|
+
* variable does not offer (checked only when the host supplies offers).
|
|
23
27
|
*
|
|
24
28
|
* Conservative by construction: an `'any'` root, a record's author-chosen
|
|
25
29
|
* key, a dynamic lookup (`lookup`, `a[k]`) and a subexpression's result are
|
|
@@ -57,4 +61,24 @@ export declare function checkTemplateSource(engine: string, src: string, scope:
|
|
|
57
61
|
* @experimental
|
|
58
62
|
*/
|
|
59
63
|
export declare function checkTemplateSourceReport(engine: string, src: string, scope: TemplateScope, options?: TemplateCheckOptions): TemplateSourceCheck;
|
|
64
|
+
/** One `layout` call in a source, as the render pre-pass reads it. @experimental */
|
|
65
|
+
export interface VariableLayoutCall {
|
|
66
|
+
/** The variable's name as written: `characters`. */
|
|
67
|
+
key: string;
|
|
68
|
+
/** The layout reference as written, grammatical or not: `core/json@1`. */
|
|
69
|
+
reference: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Every `layout` call in `src`, in source order, duplicates kept, calls inside
|
|
73
|
+
* blocks included. A call is listed when its key is a simple root name and its
|
|
74
|
+
* reference a string literal — whether or not the reference is well-formed or
|
|
75
|
+
* offered, because the render pre-pass must see every call it will meet and
|
|
76
|
+
* the check is what refuses. A call written wrongly (a path for a key, a
|
|
77
|
+
* reference that is not a literal, the wrong number of arguments, a Liquid
|
|
78
|
+
* `layout` that is not the first filter) is not listed. Same parser and walk
|
|
79
|
+
* as {@link checkTemplateSource}. A source that does not parse, or an engine
|
|
80
|
+
* this checker does not read, lists nothing.
|
|
81
|
+
* @experimental
|
|
82
|
+
*/
|
|
83
|
+
export declare function variableLayoutCalls(engine: string, src: string, options?: TemplateCheckOptions): VariableLayoutCall[];
|
|
60
84
|
//# sourceMappingURL=templateCheck.d.ts.map
|