@seriousgaming/sdk-tools 1.1.0 → 1.3.0

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.
Files changed (40) hide show
  1. package/dist/cli.js +565 -309
  2. package/dist/client.js +608 -352
  3. package/dist/core/participant-registry.d.ts +6 -0
  4. package/dist/core/session-roster.d.ts +4 -1
  5. package/dist/dev/brands.d.ts +20 -3
  6. package/dist/dev/console/assets/{index-qxHcu9fJ.js → index-DEV8N0na.js} +47 -47
  7. package/dist/dev/console/index.html +1 -1
  8. package/dist/dev/view/batch.d.ts +17 -9
  9. package/dist/dev/view/view.d.ts +2 -1
  10. package/dist/docs/api/index.md +1 -1
  11. package/dist/docs/api/sdk-commands.md +4 -0
  12. package/dist/docs/api/sdk-e2e.md +4 -0
  13. package/dist/docs/api/sdk-tools-client.md +4 -0
  14. package/dist/docs/api/sdk-ui-testing.md +2 -1
  15. package/dist/docs/api/sdk-ui.md +54 -3
  16. package/dist/docs/api/sdk.md +3 -1
  17. package/dist/docs/changelog.md +41 -0
  18. package/dist/docs/guides/guide.md +35 -4
  19. package/dist/docs/guides/presentation.md +23 -9
  20. package/dist/docs/guides/production-constraints.md +1 -1
  21. package/dist/docs/guides/session.md +50 -9
  22. package/dist/docs/guides/testing.md +9 -0
  23. package/dist/docs/guides/theming-and-branding.md +18 -4
  24. package/dist/docs/guides/ui.md +33 -0
  25. package/dist/docs/guides/upgrading.md +19 -0
  26. package/dist/docs/guides/waiting-room.md +2 -0
  27. package/dist/docs/recipes/create-guide.md +2 -2
  28. package/dist/docs/recipes/make-a-guide-follow-the-scenario.md +9 -9
  29. package/dist/guide/settings.d.ts +7 -0
  30. package/dist/guide/video-registry.d.ts +33 -1
  31. package/dist/host/index.d.ts +4 -2
  32. package/dist/host/protocol.d.ts +27 -2
  33. package/dist/host.js +131 -0
  34. package/dist/runtime/manifest-version.d.ts +1 -1
  35. package/dist/runtime.js +4 -2
  36. package/dist/templates/package/CLAUDE.md.template +1 -1
  37. package/dist/templates/package/claude/rules/workflow-create-guide.md +8 -2
  38. package/dist/validation/facilitator-guide-validator.d.ts +5 -1
  39. package/dist/validation/schema-validation.d.ts +12 -4
  40. package/package.json +3 -3
package/dist/cli.js CHANGED
@@ -3395,10 +3395,12 @@ function gameOverrideRefusal(overrides) {
3395
3395
 
3396
3396
  // cli/runtime/manifest-version.ts
3397
3397
  var MANIFEST_VERSION = 3;
3398
- var SPEC_REVISION = "1.1";
3398
+ var SPEC_REVISION = "1.3";
3399
3399
  var SUPPORTED_FEATURES = [
3400
3400
  // A validator's `Scenario` gate (§15.8).
3401
- "scenario-validation"
3401
+ "scenario-validation",
3402
+ // The presentation as a host overlay a session surface may open (§6.4).
3403
+ "presentation-overlay"
3402
3404
  ];
3403
3405
  function unsupportedFeatures(manifest) {
3404
3406
  return (manifest.requires ?? []).filter((feature) => !SUPPORTED_FEATURES.includes(feature));
@@ -4545,7 +4547,7 @@ function validateSettingsOverrides(overrides, schemas, sourceLabel) {
4545
4547
  ${errors.join("\n")}` } : { valid: true };
4546
4548
  }
4547
4549
  function validatePartialOverride(override2, settingsSchema) {
4548
- const validator = settingsAjv.compile(withoutRequired(settingsSchema));
4550
+ const validator = settingsAjv.compile(closed(withoutRequired(settingsSchema)));
4549
4551
  return validator(override2) ? null : validator.errors ?? [];
4550
4552
  }
4551
4553
  var SCHEMA_MAP_KEYWORDS = ["properties", "patternProperties", "definitions", "$defs"];
@@ -4573,6 +4575,53 @@ function withoutRequired(schema2) {
4573
4575
  }
4574
4576
  return copy;
4575
4577
  }
4578
+ var COMBINATOR_KEYWORDS = ["allOf", "anyOf", "oneOf", "if", "not", "$ref"];
4579
+ function closed(schema2) {
4580
+ if (typeof schema2 !== "object" || schema2 === null) return schema2;
4581
+ const copy = { ...schema2 };
4582
+ for (const keyword of SCHEMA_MAP_KEYWORDS) {
4583
+ const map3 = schema2[keyword];
4584
+ if (map3 && typeof map3 === "object") {
4585
+ copy[keyword] = Object.fromEntries(
4586
+ Object.entries(map3).map(([key, value]) => [key, closed(value)])
4587
+ );
4588
+ }
4589
+ }
4590
+ if (typeof schema2.additionalProperties === "object") {
4591
+ copy.additionalProperties = closed(schema2.additionalProperties);
4592
+ }
4593
+ if (Array.isArray(schema2.items)) copy.items = schema2.items.map(closed);
4594
+ else if (schema2.items !== void 0) copy.items = closed(schema2.items);
4595
+ if (isPlainOpen(schema2)) copy.additionalProperties = false;
4596
+ return copy;
4597
+ }
4598
+ function isPlainOpen(schema2) {
4599
+ return schema2.properties !== void 0 && schema2.additionalProperties === void 0 && schema2.patternProperties === void 0 && !COMBINATOR_KEYWORDS.some((keyword) => keyword in schema2);
4600
+ }
4601
+ function openSettingsObjects(schema2, at = "") {
4602
+ if (typeof schema2 !== "object" || schema2 === null) return [];
4603
+ const found = isPlainOpen(schema2) ? [at] : [];
4604
+ for (const keyword of SCHEMA_MAP_KEYWORDS) {
4605
+ const map3 = schema2[keyword];
4606
+ if (!map3 || typeof map3 !== "object") continue;
4607
+ for (const [key, value] of Object.entries(map3)) {
4608
+ found.push(...openSettingsObjects(value, `${at}/${keyword}/${key}`));
4609
+ }
4610
+ }
4611
+ if (typeof schema2.additionalProperties === "object") {
4612
+ found.push(
4613
+ ...openSettingsObjects(schema2.additionalProperties, `${at}/additionalProperties`)
4614
+ );
4615
+ }
4616
+ if (Array.isArray(schema2.items)) {
4617
+ schema2.items.forEach(
4618
+ (item, index3) => found.push(...openSettingsObjects(item, `${at}/items/${index3}`))
4619
+ );
4620
+ } else if (schema2.items !== void 0) {
4621
+ found.push(...openSettingsObjects(schema2.items, `${at}/items`));
4622
+ }
4623
+ return found;
4624
+ }
4576
4625
 
4577
4626
  // cli/discovery/manifest-paths.ts
4578
4627
  import { posix } from "path";
@@ -8184,7 +8233,42 @@ var VIDEO_PROVIDERS = {
8184
8233
  embedHosts: ["www.youtube-nocookie.com"]
8185
8234
  }
8186
8235
  };
8187
- var ALLOWED_KEYS = /* @__PURE__ */ new Set(["provider", "id"]);
8236
+ var FILE_VIDEO_PROVIDER = "file";
8237
+ var FILE_VIDEO_EXTENSIONS = {
8238
+ src: ["mp4", "webm"],
8239
+ poster: ["png", "jpg", "jpeg", "gif", "webp", "avif"],
8240
+ captions: ["vtt"]
8241
+ };
8242
+ var ALLOWED_KEYS = {
8243
+ youtube: /* @__PURE__ */ new Set(["provider", "id"]),
8244
+ [FILE_VIDEO_PROVIDER]: /* @__PURE__ */ new Set(["provider", "src", "title", "poster", "captions"])
8245
+ };
8246
+ var SUPPORTED_PROVIDERS = [...Object.keys(VIDEO_PROVIDERS), FILE_VIDEO_PROVIDER];
8247
+ var CHAPTER_BASE = "https://guide.invalid/content/locale/chapter.md";
8248
+ function guideAssetPath(reference) {
8249
+ if (/^[a-z][a-z0-9+.-]*:/i.test(reference) || reference.startsWith("/")) return void 0;
8250
+ if (reference.includes("\\") || /[?#]/.test(reference)) return void 0;
8251
+ let resolved;
8252
+ try {
8253
+ resolved = new URL(reference, CHAPTER_BASE);
8254
+ } catch {
8255
+ return void 0;
8256
+ }
8257
+ if (resolved.origin !== "https://guide.invalid" || !resolved.pathname.startsWith("/assets/")) {
8258
+ return void 0;
8259
+ }
8260
+ try {
8261
+ const path3 = decodeURIComponent(resolved.pathname.slice("/assets/".length));
8262
+ const segments = path3.split("/");
8263
+ return segments.some((s) => s === "" || s === "." || s === ".." || s.includes("\\")) ? void 0 : path3;
8264
+ } catch {
8265
+ return void 0;
8266
+ }
8267
+ }
8268
+ function extensionOf(path3) {
8269
+ const dot = path3.lastIndexOf(".");
8270
+ return dot === -1 ? "" : path3.slice(dot + 1).toLowerCase();
8271
+ }
8188
8272
  function parseVideoBlock(body) {
8189
8273
  const entries = {};
8190
8274
  for (const rawLine of body.split("\n")) {
@@ -8196,9 +8280,6 @@ function parseVideoBlock(body) {
8196
8280
  }
8197
8281
  const key = match2[1];
8198
8282
  const value = match2[2].trim();
8199
- if (!ALLOWED_KEYS.has(key)) {
8200
- return { ok: false, error: `Unknown key "${key}" in video block` };
8201
- }
8202
8283
  if (key in entries) {
8203
8284
  return { ok: false, error: `Duplicate key "${key}" in video block` };
8204
8285
  }
@@ -8208,13 +8289,20 @@ function parseVideoBlock(body) {
8208
8289
  if (!provider) {
8209
8290
  return { ok: false, error: 'Video block is missing "provider"' };
8210
8291
  }
8211
- const registered = VIDEO_PROVIDERS[provider];
8212
- if (!registered) {
8292
+ const allowed = ALLOWED_KEYS[provider];
8293
+ if (!allowed) {
8213
8294
  return {
8214
8295
  ok: false,
8215
- error: `Unknown video provider "${provider}". Supported providers: ${Object.keys(VIDEO_PROVIDERS).join(", ")}`
8296
+ error: `Unknown video provider "${provider}". Supported providers: ${SUPPORTED_PROVIDERS.join(", ")}`
8216
8297
  };
8217
8298
  }
8299
+ for (const key of Object.keys(entries)) {
8300
+ if (!allowed.has(key)) {
8301
+ return { ok: false, error: `Unknown key "${key}" in video block` };
8302
+ }
8303
+ }
8304
+ if (provider === FILE_VIDEO_PROVIDER) return parseFileVideo(entries);
8305
+ const registered = VIDEO_PROVIDERS[provider];
8218
8306
  const id = entries.id;
8219
8307
  if (!id) {
8220
8308
  return { ok: false, error: 'Video block is missing "id"' };
@@ -8225,7 +8313,43 @@ function parseVideoBlock(body) {
8225
8313
  error: `Video id "${id}" is not a valid ${provider} id`
8226
8314
  };
8227
8315
  }
8228
- return { ok: true, provider, id, embedUrl: registered.embedUrl(id) };
8316
+ return { ok: true, kind: "embed", provider, id, embedUrl: registered.embedUrl(id) };
8317
+ }
8318
+ function parseFileVideo(entries) {
8319
+ if (!entries.src) {
8320
+ return { ok: false, error: 'Video block is missing "src"' };
8321
+ }
8322
+ const files = {};
8323
+ for (const key of Object.keys(
8324
+ FILE_VIDEO_EXTENSIONS
8325
+ )) {
8326
+ const reference = entries[key];
8327
+ if (reference === void 0) continue;
8328
+ const path3 = guideAssetPath(reference);
8329
+ if (!path3) {
8330
+ return {
8331
+ ok: false,
8332
+ error: `Video ${key} "${reference}" must be a file in the guide's assets/ directory`
8333
+ };
8334
+ }
8335
+ const extensions = FILE_VIDEO_EXTENSIONS[key];
8336
+ if (!extensions.includes(extensionOf(path3))) {
8337
+ return {
8338
+ ok: false,
8339
+ error: `Video ${key} "${reference}" must be a ${extensions.map((e) => `.${e}`).join(", ")} file`
8340
+ };
8341
+ }
8342
+ files[key] = path3;
8343
+ }
8344
+ return {
8345
+ ok: true,
8346
+ kind: "file",
8347
+ provider: FILE_VIDEO_PROVIDER,
8348
+ src: files.src,
8349
+ ...files.poster ? { poster: files.poster } : {},
8350
+ ...files.captions ? { captions: files.captions } : {},
8351
+ ...entries.title ? { title: entries.title } : {}
8352
+ };
8229
8353
  }
8230
8354
 
8231
8355
  // ../node_modules/.pnpm/ccount@2.0.1/node_modules/ccount/index.js
@@ -21436,6 +21560,16 @@ function settingReferences(markdown) {
21436
21560
  walk3(parse2(markdown).children, false);
21437
21561
  return references;
21438
21562
  }
21563
+ function strayFences(markdown) {
21564
+ const lines = [];
21565
+ visit(parse2(markdown), "text", (node2) => {
21566
+ const start = node2.position?.start.line ?? 0;
21567
+ node2.value.split("\n").forEach((text5, offset) => {
21568
+ if (/^:{3,}\s*$/.test(text5)) lines.push(start + offset);
21569
+ });
21570
+ });
21571
+ return lines;
21572
+ }
21439
21573
 
21440
21574
  // cli/validation/guide-settings-validator.ts
21441
21575
  function typesOf2(schema2) {
@@ -21506,6 +21640,11 @@ function validateGuideSettings(chapters, context) {
21506
21640
  const warnings = [];
21507
21641
  const used = /* @__PURE__ */ new Set();
21508
21642
  for (const chapter of chapters) {
21643
+ for (const line of strayFences(chapter.markdown)) {
21644
+ warnings.push(
21645
+ `${chapter.label}:${line}: this ::: closes nothing, so a block above it ended early; a :::when that holds another ::: block needs more colons than it, as in ::::when`
21646
+ );
21647
+ }
21509
21648
  for (const reference of settingReferences(chapter.markdown)) {
21510
21649
  const where3 = `${chapter.label}:${reference.line}`;
21511
21650
  const directive2 = reference.kind === "value" ? ":setting" : ":::when";
@@ -21570,6 +21709,7 @@ function validateGuideSettings(chapters, context) {
21570
21709
  }
21571
21710
 
21572
21711
  // cli/validation/facilitator-guide-validator.ts
21712
+ var LARGE_VIDEO_FILE_BYTES = 25 * 1024 * 1024;
21573
21713
  var VIDEO_BLOCK_PATTERN = /^[ \t]*```video[ \t]*\r?\n([\s\S]*?)^[ \t]*```[ \t]*$/gm;
21574
21714
  var IMAGE_PATTERN = /!\[[^\]]*\]\(([^()\s]+)(?:\s+"[^"]*")?\)/g;
21575
21715
  function listChapters(localeDir) {
@@ -21628,6 +21768,27 @@ function validateFacilitatorGuideContent(options) {
21628
21768
  const parsed = parseVideoBlock(match2[1]);
21629
21769
  if (!parsed.ok) {
21630
21770
  errors.push(`${label4}: ${parsed.error}`);
21771
+ continue;
21772
+ }
21773
+ if (parsed.kind !== "file") continue;
21774
+ const assetsDir = join26(rootDirectory, "assets");
21775
+ for (const [key, path3] of [
21776
+ ["src", parsed.src],
21777
+ ["poster", parsed.poster],
21778
+ ["captions", parsed.captions]
21779
+ ]) {
21780
+ if (path3 === void 0) continue;
21781
+ const file = join26(assetsDir, path3);
21782
+ if (!existsSync12(file) || !statSync2(file).isFile()) {
21783
+ errors.push(
21784
+ `${label4}: video ${key} "assets/${path3}" does not resolve to a file`
21785
+ );
21786
+ } else if (key === "src" && statSync2(file).size > LARGE_VIDEO_FILE_BYTES) {
21787
+ const megabytes = Math.round(statSync2(file).size / (1024 * 1024));
21788
+ warnings.push(
21789
+ `${label4}: video "assets/${path3}" is ${megabytes} MB; every upload of the package carries it, so consider compressing it or embedding it from YouTube`
21790
+ );
21791
+ }
21631
21792
  }
21632
21793
  }
21633
21794
  for (const match2 of content3.matchAll(IMAGE_PATTERN)) {
@@ -21924,6 +22085,7 @@ function validateGame(game, config) {
21924
22085
  }
21925
22086
  }
21926
22087
  warnings.push(...namesBeyondMax("game", declared));
22088
+ warnings.push(...openSettingsObjectWarnings(config));
21927
22089
  for (const scenario of config.scenarios ?? []) {
21928
22090
  const overrides = scenarioGame(scenario);
21929
22091
  if (!overrides?.teams) continue;
@@ -22286,6 +22448,13 @@ function collectMissingSettingsDefaults(config) {
22286
22448
  }
22287
22449
  return errors;
22288
22450
  }
22451
+ function openSettingsObjectWarnings(config) {
22452
+ return (config.settings ?? []).flatMap(
22453
+ (settings) => openSettingsObjects(settings.definition.settingsSchema).map(
22454
+ (pointer) => `Settings "${settings.definition.identifier}" leaves the object at ${pointer === "" ? "the top of its settingsSchema" : `settingsSchema${pointer}`} open. A key it does not declare is refused all the same; add "additionalProperties": false so the schema says so.`
22455
+ )
22456
+ );
22457
+ }
22289
22458
  function collectVestigialRequired(config) {
22290
22459
  const errors = [];
22291
22460
  for (const settings of config.settings ?? []) {
@@ -24179,6 +24348,7 @@ var COMMAND_FIELDS = {
24179
24348
  removeTeam: { teamIndex: "number" },
24180
24349
  renameTeam: { teamId: "string", name: "string" },
24181
24350
  renameOwnTeam: { name: "string", "participantId?": "string", "teamId?": "string" },
24351
+ renameSelf: { name: "string", "participantId?": "string", "teamId?": "string" },
24182
24352
  addParticipant: { teamId: "string", "name?": "string" },
24183
24353
  renameParticipant: { participantId: "string", name: "string" },
24184
24354
  moveParticipant: { participantId: "string", teamId: "string" },
@@ -26892,6 +27062,7 @@ function swallow() {
26892
27062
 
26893
27063
  // cli/core/participant-registry.ts
26894
27064
  import { EventEmitter } from "events";
27065
+ var MAX_PARTICIPANT_NAME_LENGTH = 60;
26895
27066
  var ParticipantRegistry = class extends EventEmitter {
26896
27067
  teams = /* @__PURE__ */ new Map();
26897
27068
  /**
@@ -28138,6 +28309,16 @@ var SessionRoster = class {
28138
28309
  if (!teamId) throw new DeniedError("The caller is not on a team");
28139
28310
  return this.renameTeam(teamId, command.name);
28140
28311
  }
28312
+ renameSelf(command) {
28313
+ if (!command.participantId)
28314
+ throw new DeniedError("Only a participant can rename themselves");
28315
+ const trimmed = command.name.trim();
28316
+ if (!trimmed) throw new DeniedError("A name cannot be blank");
28317
+ if (trimmed.length > MAX_PARTICIPANT_NAME_LENGTH) {
28318
+ throw new DeniedError(`A name is at most ${MAX_PARTICIPANT_NAME_LENGTH} characters`);
28319
+ }
28320
+ return this.renameParticipant(command.participantId, trimmed);
28321
+ }
28141
28322
  async addParticipant(teamId, name) {
28142
28323
  if (!this.host.state.getTeamIndexes().some((i) => `team-${i + 1}` === teamId)) {
28143
28324
  throw new DeniedError(`Unknown team "${teamId}"`);
@@ -29391,6 +29572,7 @@ var PLAY_STAGE = /* @__PURE__ */ new Set([
29391
29572
  "renameParticipant",
29392
29573
  "moveParticipant",
29393
29574
  "renameOwnTeam",
29575
+ "renameSelf",
29394
29576
  "extendTick"
29395
29577
  ]);
29396
29578
  var STALE_BLOCKED = /* @__PURE__ */ new Set([
@@ -30045,6 +30227,8 @@ var Session = class {
30045
30227
  return this.roster.renameTeam(command.teamId, command.name);
30046
30228
  case "renameOwnTeam":
30047
30229
  return this.roster.renameOwnTeam(command);
30230
+ case "renameSelf":
30231
+ return this.roster.renameSelf(command);
30048
30232
  case "addParticipant":
30049
30233
  return this.roster.addParticipant(command.teamId, command.name);
30050
30234
  case "renameParticipant":
@@ -30217,6 +30401,12 @@ var Session = class {
30217
30401
  await deleteBlobs(this.options.packagePath, retentions);
30218
30402
  }
30219
30403
  setLocale(locale) {
30404
+ const supported = this.packageConfiguration()?.game?.definition.supportedLocales;
30405
+ if (supported?.length && !supported.includes(locale)) {
30406
+ throw new DeniedError(
30407
+ `"${locale}" is not one of this game's locales (${supported.join(", ")})`
30408
+ );
30409
+ }
30220
30410
  this.locale = locale;
30221
30411
  this.executor.setLocale(locale);
30222
30412
  return void 0;
@@ -37430,7 +37620,16 @@ var BRAND_FILE_SCHEMA = {
37430
37620
  properties: { onLight: { type: "string" }, onDark: { type: "string" } },
37431
37621
  additionalProperties: false
37432
37622
  },
37433
- icon: { type: "string", minLength: 1 },
37623
+ icon: {
37624
+ oneOf: [
37625
+ { type: "string", minLength: 1 },
37626
+ {
37627
+ type: "object",
37628
+ properties: { onLight: { type: "string" }, onDark: { type: "string" } },
37629
+ additionalProperties: false
37630
+ }
37631
+ ]
37632
+ },
37434
37633
  fonts: {
37435
37634
  type: "object",
37436
37635
  properties: { heading: FONT_SCHEMA, body: FONT_SCHEMA },
@@ -37517,7 +37716,12 @@ function readBrandFile(path3, id, defaults) {
37517
37716
  if (data.logo?.onDark) checkPath(path3, root2, data.logo.onDark, "/logo/onDark");
37518
37717
  if (data.loader?.onLight) checkPath(path3, root2, data.loader.onLight, "/loader/onLight");
37519
37718
  if (data.loader?.onDark) checkPath(path3, root2, data.loader.onDark, "/loader/onDark");
37520
- if (data.icon) checkPath(path3, root2, data.icon, "/icon");
37719
+ const icon = typeof data.icon === "string" ? { onLight: data.icon, onDark: data.icon } : data.icon;
37720
+ if (typeof data.icon === "string") checkPath(path3, root2, data.icon, "/icon");
37721
+ else {
37722
+ if (icon?.onLight) checkPath(path3, root2, icon.onLight, "/icon/onLight");
37723
+ if (icon?.onDark) checkPath(path3, root2, icon.onDark, "/icon/onDark");
37724
+ }
37521
37725
  for (const slot3 of ["heading", "body"]) {
37522
37726
  data.fonts?.[slot3]?.sources.forEach(
37523
37727
  (source, index3) => checkPath(path3, root2, source.url, `/fonts/${slot3}/sources/${index3}/url`)
@@ -37533,7 +37737,7 @@ function readBrandFile(path3, id, defaults) {
37533
37737
  brand: {
37534
37738
  name: data.name,
37535
37739
  ...data.logo && (data.logo.onLight || data.logo.onDark) ? { logo: data.logo } : {},
37536
- ...data.icon ? { icon: data.icon } : {},
37740
+ ...icon && (icon.onLight || icon.onDark) ? { icon } : {},
37537
37741
  ...data.fonts && (data.fonts.heading || data.fonts.body) ? { fonts: data.fonts } : {}
37538
37742
  }
37539
37743
  };
@@ -37628,7 +37832,12 @@ function summarise(brand, assetOrigin) {
37628
37832
  ...source.logo.onDark ? { onDark: url(source.logo.onDark) } : {}
37629
37833
  }
37630
37834
  } : {},
37631
- ...source.icon ? { icon: url(source.icon) } : {},
37835
+ ...source.icon ? {
37836
+ icon: {
37837
+ ...source.icon.onLight ? { onLight: url(source.icon.onLight) } : {},
37838
+ ...source.icon.onDark ? { onDark: url(source.icon.onDark) } : {}
37839
+ }
37840
+ } : {},
37632
37841
  ...fonts ? { fonts } : {}
37633
37842
  }
37634
37843
  }
@@ -37871,6 +38080,319 @@ function mountableSurfaces(config) {
37871
38080
  ].filter((surface) => surface !== null);
37872
38081
  }
37873
38082
 
38083
+ // cli/dev/view/batch.ts
38084
+ function projectContext2(context, surface) {
38085
+ const declared = /* @__PURE__ */ new Set([...surface.reads, ...surface.writes]);
38086
+ const projected = {};
38087
+ for (const [capability, values] of Object.entries(context)) {
38088
+ if (declared.has(capability)) projected[capability] = values;
38089
+ }
38090
+ return projected;
38091
+ }
38092
+ function settingsFor(state2, surface, { withoutSession = false } = {}) {
38093
+ const settings = withoutSession ? state2.settingsWithoutSession : state2.settings;
38094
+ return Object.fromEntries(
38095
+ surface.settings.filter((identifier) => identifier in settings).map((identifier) => [identifier, settings[identifier]])
38096
+ );
38097
+ }
38098
+ function draftSettingsFor(state2, surface, viewer) {
38099
+ const scenarioId = viewer.scenario ?? null;
38100
+ const draft = state2.scenarioDrafts?.find((entry) => entry.scenarioId === scenarioId);
38101
+ const settings = draft?.settings ?? {};
38102
+ return Object.fromEntries(
38103
+ surface.settings.filter((identifier) => identifier in settings).map((identifier) => [identifier, settings[identifier]])
38104
+ );
38105
+ }
38106
+ function sessionKeyFor(state2, surface, { sessionless = false } = {}) {
38107
+ const outside = surface.kind === "scenario-editor" || surface.kind === "presentation" && sessionless;
38108
+ return outside ? `outside-session:${state2.game.identifier}` : state2.session.sessionKey;
38109
+ }
38110
+ function themeMessages(theme) {
38111
+ return [
38112
+ { type: "setTheme", payload: theme.palette },
38113
+ { type: "themePreferenceChanged", preference: theme.preference }
38114
+ ];
38115
+ }
38116
+ function assetUrls(assetOrigin) {
38117
+ return {
38118
+ blobPrefix: `${assetOrigin}/assets/blobs/`,
38119
+ scenarioAssetPrefix: `${assetOrigin}/assets/scenario/`,
38120
+ sharedAssetPrefix: `${assetOrigin}/assets/shared/`,
38121
+ assetAuthRedeemUrl: `${assetOrigin}/assets/auth/redeem`
38122
+ };
38123
+ }
38124
+ function teamOf(state2, teamIndex) {
38125
+ if (teamIndex === void 0) return state2.teams[0];
38126
+ return state2.teams.find((team) => team.index === teamIndex);
38127
+ }
38128
+ function teamList(state2) {
38129
+ return [...state2.teams].sort((a, b) => a.index - b.index).map((team) => ({ teamId: team.teamId, index: team.index, name: team.name }));
38130
+ }
38131
+ var IDLE_TIMER2 = {
38132
+ enabled: false,
38133
+ paused: false,
38134
+ nextTickAt: null,
38135
+ intervalMs: null,
38136
+ pausedAt: null,
38137
+ pausedMs: 0,
38138
+ extendedMs: 0,
38139
+ scheduleStartedAt: null
38140
+ };
38141
+ function buildBatch(options) {
38142
+ const { surface, state: state2, theme, origin, assetOrigin } = options;
38143
+ const common = [
38144
+ { type: "setLocale", payload: { locale: state2.session.locale } },
38145
+ { type: "setAssetUrls", payload: assetUrls(assetOrigin ?? origin) },
38146
+ ...theme ? themeMessages(theme) : []
38147
+ ];
38148
+ switch (surface.kind) {
38149
+ case "game":
38150
+ case "waiting-room":
38151
+ return [...playerBatch(options), ...common];
38152
+ case "session":
38153
+ return [...sessionBatch(options), ...common];
38154
+ // The two settings editors are sent the same batch (§12.3): neither is
38155
+ // told which slot it fills, since each is its own bundle.
38156
+ case "setup":
38157
+ return [{ type: "setSettings", payload: settingsFor(state2, surface) }, ...common];
38158
+ case "scenario-editor":
38159
+ return [
38160
+ { type: "setSettings", payload: draftSettingsFor(state2, surface, options.viewer) },
38161
+ ...common
38162
+ ];
38163
+ case "presentation":
38164
+ return [...presentationBatch(options), ...common];
38165
+ }
38166
+ return common;
38167
+ }
38168
+ function crossTeamData(state2, surface, ownTeamIndex) {
38169
+ const across = new Set(surface.crossTeamReads);
38170
+ return [...state2.teams].sort((a, b) => a.index - b.index).map((team) => ({
38171
+ teamId: team.teamId,
38172
+ index: team.index,
38173
+ name: team.name,
38174
+ context: team.index === ownTeamIndex ? projectContext2(team.context, surface) : Object.fromEntries(
38175
+ Object.entries(team.context).filter(
38176
+ ([capability]) => across.has(capability)
38177
+ )
38178
+ )
38179
+ }));
38180
+ }
38181
+ function joinUrl(origin, teamIndex) {
38182
+ return `${origin}/team/${teamIndex + 1}/join?bare`;
38183
+ }
38184
+ function playerBatch({
38185
+ surface,
38186
+ state: state2,
38187
+ viewer,
38188
+ origin,
38189
+ roundProcessing
38190
+ }) {
38191
+ const team = teamOf(state2, viewer.teamIndex);
38192
+ const participant = viewer.observer ? void 0 : team?.participants.find((p) => p.id === viewer.participantId) ?? team?.participants[0];
38193
+ const messages2 = [
38194
+ {
38195
+ type: "stateChanged",
38196
+ payload: projectContext2(team?.context ?? {}, surface),
38197
+ // §12.5: the head tick, so a review scrubber can be bounded and a
38198
+ // cache invalidated on undo.
38199
+ completedTicks: team?.completedTicks ?? state2.session.completedTicks
38200
+ },
38201
+ { type: "setSettings", payload: settingsFor(state2, surface) }
38202
+ ];
38203
+ if (participant) {
38204
+ messages2.push({
38205
+ type: "setParticipant",
38206
+ payload: {
38207
+ id: participant.id,
38208
+ name: participant.name,
38209
+ index: participant.index,
38210
+ teamId: team?.teamId ?? "team-1"
38211
+ },
38212
+ // There are no accounts here, so every name is the participant's
38213
+ // own to change (§12.5).
38214
+ canRenameSelf: true
38215
+ });
38216
+ }
38217
+ messages2.push(
38218
+ { type: "setViewerRole", role: viewer.observer ? "observer" : "participant" },
38219
+ { type: "setRunKind", runKind: state2.session.runKind },
38220
+ { type: "setScenarioName", scenarioName: state2.game.scenarioName },
38221
+ {
38222
+ type: "setOwnTeam",
38223
+ payload: team ? { teamId: team.teamId, index: team.index, name: team.name } : { teamId: "team-1", index: 0, name: "Team 1" }
38224
+ },
38225
+ {
38226
+ type: "setOwnTeamJoinLink",
38227
+ payload: team ? { joinUrl: joinUrl(origin, team.index) } : (
38228
+ // §12.3, as amended: a host with nothing to offer says so
38229
+ // rather than staying silent, so a surface rendering a join
38230
+ // panel shows nothing instead of waiting for a message that
38231
+ // never comes.
38232
+ null
38233
+ )
38234
+ },
38235
+ { type: "setParticipantList", participants: team?.participants ?? [] },
38236
+ { type: "setTeamList", payload: teamList(state2) },
38237
+ { type: "setTimer", payload: team?.timer ?? IDLE_TIMER2 }
38238
+ );
38239
+ if (surface.kind === "game") {
38240
+ messages2.push({ type: "setRoundProcessing", processing: roundProcessing === true });
38241
+ }
38242
+ if ((surface.kind === "game" || surface.kind === "waiting-room") && surface.crossTeamReads.length > 0 && state2.session.mode === "shared-state") {
38243
+ messages2.push({
38244
+ type: "setCrossTeamData",
38245
+ payload: crossTeamData(state2, surface, team?.index)
38246
+ });
38247
+ }
38248
+ return messages2;
38249
+ }
38250
+ function sessionBatch({
38251
+ surface,
38252
+ state: state2,
38253
+ gameName,
38254
+ origin,
38255
+ overlays
38256
+ }) {
38257
+ return [
38258
+ {
38259
+ type: "setSessionMeta",
38260
+ payload: {
38261
+ sessionId: "dev-session",
38262
+ name: gameName,
38263
+ readOnly: false,
38264
+ waitingRoomOpen: state2.session.waitingRoomOpen,
38265
+ joinPin: null,
38266
+ canSetLocale: true
38267
+ }
38268
+ },
38269
+ { type: "setSessionData", payload: sessionData(state2, surface) },
38270
+ { type: "setSettings", payload: settingsFor(state2, surface) },
38271
+ { type: "setTeamConfiguration", payload: teamConfiguration(state2) },
38272
+ { type: "setTeamList", payload: teamList(state2) },
38273
+ {
38274
+ type: "setParticipantList",
38275
+ participants: participantList(state2)
38276
+ },
38277
+ { type: "setTeamLinks", payload: teamLinks(state2, origin) },
38278
+ { type: "setWalkthroughLink", payload: walkthroughLink(origin) },
38279
+ { type: "setRunKind", runKind: state2.session.runKind },
38280
+ { type: "setScenarioName", scenarioName: state2.game.scenarioName },
38281
+ { type: "setAvailableOverlays", overlays: overlays ?? availableOverlays() }
38282
+ ];
38283
+ }
38284
+ function presentationBatch({
38285
+ surface,
38286
+ state: state2,
38287
+ gameName,
38288
+ origin,
38289
+ sessionless
38290
+ }) {
38291
+ return [
38292
+ {
38293
+ type: "setPresentation",
38294
+ payload: {
38295
+ game: {
38296
+ name: state2.game.name,
38297
+ // Without a session, as the scenario resolves it alone (§6.15.1).
38298
+ maxTicks: sessionless ? gameSettingsOf(state2.settingsWithoutSession).maxTicks : state2.session.maxTicks,
38299
+ mode: state2.session.mode,
38300
+ scenarioName: state2.game.scenarioName
38301
+ },
38302
+ session: sessionless ? null : {
38303
+ // The dev server runs one session; its id is the
38304
+ // one the session surface is told (above).
38305
+ id: "dev-session",
38306
+ name: gameName,
38307
+ completedTicks: Math.max(
38308
+ state2.session.completedTicks,
38309
+ ...state2.teams.map((team) => team.completedTicks)
38310
+ ),
38311
+ data: sessionData(state2, surface),
38312
+ teams: teamList(state2),
38313
+ participants: participantList(state2),
38314
+ // A deck puts these on the projector, so no observe
38315
+ // URL: watching a team is the facilitator's tool.
38316
+ joinLinks: teamLinks(state2, origin).map(({ teamId, joinUrl: joinUrl2 }) => ({
38317
+ teamId,
38318
+ joinUrl: joinUrl2
38319
+ })),
38320
+ joinPin: null
38321
+ }
38322
+ }
38323
+ },
38324
+ {
38325
+ type: "setSettings",
38326
+ payload: settingsFor(state2, surface, { withoutSession: sessionless })
38327
+ }
38328
+ ];
38329
+ }
38330
+ function walkthroughLink(origin) {
38331
+ return { url: `${origin}/walkthrough` };
38332
+ }
38333
+ function availableOverlays(offered = {}) {
38334
+ return [
38335
+ ...offered.guide ? ["facilitator-guide"] : [],
38336
+ "print-sheets",
38337
+ ...offered.presentation ? ["presentation"] : []
38338
+ ];
38339
+ }
38340
+ function offersPresentationOverlay(config) {
38341
+ return config?.presentation !== void 0 && (config.requires ?? []).includes(PRESENTATION_OVERLAY);
38342
+ }
38343
+ var PRESENTATION_OVERLAY = "presentation-overlay";
38344
+ function participantList(state2) {
38345
+ return state2.teams.flatMap(
38346
+ (team) => team.participants.map((participant) => ({
38347
+ id: participant.id,
38348
+ name: participant.name,
38349
+ index: participant.index,
38350
+ connected: participant.connected,
38351
+ teamId: team.teamId
38352
+ }))
38353
+ );
38354
+ }
38355
+ function teamLinks(state2, origin) {
38356
+ return [...state2.teams].sort((a, b) => a.index - b.index).map((team) => ({
38357
+ teamId: team.teamId,
38358
+ joinUrl: joinUrl(origin, team.index),
38359
+ observeUrl: `${origin}/team/${team.index + 1}/observe`
38360
+ }));
38361
+ }
38362
+ function teamConfiguration(state2) {
38363
+ return {
38364
+ mode: state2.session.mode,
38365
+ ...state2.session.teamBounds.min === void 0 ? {} : { min: state2.session.teamBounds.min },
38366
+ max: state2.session.teamBounds.max
38367
+ };
38368
+ }
38369
+ function sessionData(state2, surface) {
38370
+ const teams = {};
38371
+ for (const team of state2.teams) {
38372
+ const own5 = {};
38373
+ for (const [capability, values] of Object.entries(team.context)) {
38374
+ if (!(capability in state2.shared)) own5[capability] = values;
38375
+ }
38376
+ teams[team.teamId] = {
38377
+ context: projectContext2(own5, surface),
38378
+ completedTicks: team.completedTicks,
38379
+ timer: team.timer ?? IDLE_TIMER2,
38380
+ // Monotonic per delivery. One session, one host, so the tick is a
38381
+ // sufficient clock; the wrapper only compares it with itself.
38382
+ revision: team.completedTicks
38383
+ };
38384
+ }
38385
+ return {
38386
+ // The dev server only ever sends snapshots, so the revision is a
38387
+ // baseline the wrapper never compares a delta against.
38388
+ shared: {
38389
+ context: projectContext2(state2.shared, surface),
38390
+ revision: state2.session.completedTicks
38391
+ },
38392
+ teams
38393
+ };
38394
+ }
38395
+
37874
38396
  // cli/dev/routes.ts
37875
38397
  function runOf(req) {
37876
38398
  return req.query.run === "walkthrough" ? "walkthrough" : "session";
@@ -38034,6 +38556,14 @@ function registerRoutes(app, deps) {
38034
38556
  app.get("/api/guide", (_req, res) => {
38035
38557
  res.json({ guide: session.effectiveGuide() });
38036
38558
  });
38559
+ app.get("/api/overlays", (_req, res) => {
38560
+ res.json({
38561
+ overlays: availableOverlays({
38562
+ guide: session.effectiveGuide() !== null,
38563
+ presentation: offersPresentationOverlay(session.packageConfiguration())
38564
+ })
38565
+ });
38566
+ });
38037
38567
  app.get("/api/guide/content/:locale/:chapter", async (req, res) => {
38038
38568
  const guide = session.guide();
38039
38569
  if (!guide) {
@@ -38150,8 +38680,8 @@ function serveAsset(req, res, root2) {
38150
38680
 
38151
38681
  // cli/dev/view/commands.ts
38152
38682
  var FRAME_COMMANDS = {
38153
- game: /* @__PURE__ */ new Set(["updateData", "requestTick", "renameOwnTeam"]),
38154
- "waiting-room": /* @__PURE__ */ new Set(["updateData", "requestTick", "renameOwnTeam"]),
38683
+ game: /* @__PURE__ */ new Set(["updateData", "requestTick", "renameOwnTeam", "renameSelf"]),
38684
+ "waiting-room": /* @__PURE__ */ new Set(["updateData", "requestTick", "renameOwnTeam", "renameSelf"]),
38155
38685
  session: /* @__PURE__ */ new Set([
38156
38686
  "updateSessionData",
38157
38687
  "updateSharedData",
@@ -38160,6 +38690,7 @@ var FRAME_COMMANDS = {
38160
38690
  "resetGame",
38161
38691
  "resetWalkthrough",
38162
38692
  "setWaitingRoom",
38693
+ "setLocale",
38163
38694
  "createTeam",
38164
38695
  "renameTeam",
38165
38696
  "renameParticipant",
@@ -38179,7 +38710,9 @@ var FRAME_COMMANDS = {
38179
38710
  var NO_TEAM_ID = {
38180
38711
  setWaitingRoom: "The waiting room is session-wide, so setWaitingRoom takes no teamId",
38181
38712
  renameOwnTeam: "renameOwnTeam renames the caller's own team, which the host resolves; it takes no teamId",
38182
- resetWalkthrough: "A walkthrough holds one team, so resetWalkthrough takes no teamId"
38713
+ resetWalkthrough: "A walkthrough holds one team, so resetWalkthrough takes no teamId",
38714
+ setLocale: "The locale is the session's, so setLocale takes no teamId",
38715
+ renameSelf: "renameSelf renames the caller, whom the host resolves; it takes no teamId"
38183
38716
  };
38184
38717
  var FRAME_QUERIES = {
38185
38718
  game: /* @__PURE__ */ new Set(["callEndpoint", "getPastState", "getAllTeamsParticipants"]),
@@ -38219,6 +38752,11 @@ function commandFor(message, surface, viewer) {
38219
38752
  if (message.teamId !== void 0 && message.type in NO_TEAM_ID) {
38220
38753
  return { refused: NO_TEAM_ID[message.type] };
38221
38754
  }
38755
+ if (message.type === "renameSelf" && message.participantId !== void 0) {
38756
+ return {
38757
+ refused: "renameSelf renames the caller, whom the host resolves; it takes no participantId"
38758
+ };
38759
+ }
38222
38760
  const scope = teamScope(viewer);
38223
38761
  const actor = actorOf(viewer);
38224
38762
  const role = roleOf(viewer);
@@ -38277,6 +38815,8 @@ function commandFor(message, surface, viewer) {
38277
38815
  };
38278
38816
  case "setWaitingRoom":
38279
38817
  return { type: "setWaitingRoom", open: message.open === true };
38818
+ case "setLocale":
38819
+ return { type: "setLocale", locale: String(message.locale) };
38280
38820
  case "resetWalkthrough":
38281
38821
  return { type: "resetWalkthrough" };
38282
38822
  case "createTeam":
@@ -38292,6 +38832,8 @@ function commandFor(message, surface, viewer) {
38292
38832
  };
38293
38833
  case "renameOwnTeam":
38294
38834
  return { type: "renameOwnTeam", name: String(message.name), ...actor };
38835
+ case "renameSelf":
38836
+ return { type: "renameSelf", name: String(message.name), ...actor };
38295
38837
  case "renameParticipant":
38296
38838
  return {
38297
38839
  type: "renameParticipant",
@@ -38415,295 +38957,6 @@ function routeHref(route) {
38415
38957
  return search2 ? `${path3}?${search2}` : path3;
38416
38958
  }
38417
38959
 
38418
- // cli/dev/view/batch.ts
38419
- function projectContext2(context, surface) {
38420
- const declared = /* @__PURE__ */ new Set([...surface.reads, ...surface.writes]);
38421
- const projected = {};
38422
- for (const [capability, values] of Object.entries(context)) {
38423
- if (declared.has(capability)) projected[capability] = values;
38424
- }
38425
- return projected;
38426
- }
38427
- function settingsFor(state2, surface, { withoutSession = false } = {}) {
38428
- const settings = withoutSession ? state2.settingsWithoutSession : state2.settings;
38429
- return Object.fromEntries(
38430
- surface.settings.filter((identifier) => identifier in settings).map((identifier) => [identifier, settings[identifier]])
38431
- );
38432
- }
38433
- function draftSettingsFor(state2, surface, viewer) {
38434
- const scenarioId = viewer.scenario ?? null;
38435
- const draft = state2.scenarioDrafts?.find((entry) => entry.scenarioId === scenarioId);
38436
- const settings = draft?.settings ?? {};
38437
- return Object.fromEntries(
38438
- surface.settings.filter((identifier) => identifier in settings).map((identifier) => [identifier, settings[identifier]])
38439
- );
38440
- }
38441
- function sessionKeyFor(state2, surface, { sessionless = false } = {}) {
38442
- const outside = surface.kind === "scenario-editor" || surface.kind === "presentation" && sessionless;
38443
- return outside ? `outside-session:${state2.game.identifier}` : state2.session.sessionKey;
38444
- }
38445
- function themeMessages(theme) {
38446
- return [
38447
- { type: "setTheme", payload: theme.palette },
38448
- { type: "themePreferenceChanged", preference: theme.preference }
38449
- ];
38450
- }
38451
- function assetUrls(assetOrigin) {
38452
- return {
38453
- blobPrefix: `${assetOrigin}/assets/blobs/`,
38454
- scenarioAssetPrefix: `${assetOrigin}/assets/scenario/`,
38455
- sharedAssetPrefix: `${assetOrigin}/assets/shared/`,
38456
- assetAuthRedeemUrl: `${assetOrigin}/assets/auth/redeem`
38457
- };
38458
- }
38459
- function teamOf(state2, teamIndex) {
38460
- if (teamIndex === void 0) return state2.teams[0];
38461
- return state2.teams.find((team) => team.index === teamIndex);
38462
- }
38463
- function teamList(state2) {
38464
- return [...state2.teams].sort((a, b) => a.index - b.index).map((team) => ({ teamId: team.teamId, index: team.index, name: team.name }));
38465
- }
38466
- var IDLE_TIMER2 = {
38467
- enabled: false,
38468
- paused: false,
38469
- nextTickAt: null,
38470
- intervalMs: null,
38471
- pausedAt: null,
38472
- pausedMs: 0,
38473
- extendedMs: 0,
38474
- scheduleStartedAt: null
38475
- };
38476
- function buildBatch(options) {
38477
- const { surface, state: state2, theme, origin, assetOrigin } = options;
38478
- const common = [
38479
- { type: "setLocale", payload: { locale: state2.session.locale } },
38480
- { type: "setAssetUrls", payload: assetUrls(assetOrigin ?? origin) },
38481
- ...theme ? themeMessages(theme) : []
38482
- ];
38483
- switch (surface.kind) {
38484
- case "game":
38485
- case "waiting-room":
38486
- return [...playerBatch(options), ...common];
38487
- case "session":
38488
- return [...sessionBatch(options), ...common];
38489
- // The two settings editors are sent the same batch (§12.3): neither is
38490
- // told which slot it fills, since each is its own bundle.
38491
- case "setup":
38492
- return [{ type: "setSettings", payload: settingsFor(state2, surface) }, ...common];
38493
- case "scenario-editor":
38494
- return [
38495
- { type: "setSettings", payload: draftSettingsFor(state2, surface, options.viewer) },
38496
- ...common
38497
- ];
38498
- case "presentation":
38499
- return [...presentationBatch(options), ...common];
38500
- }
38501
- return common;
38502
- }
38503
- function crossTeamData(state2, surface, ownTeamIndex) {
38504
- const across = new Set(surface.crossTeamReads);
38505
- return [...state2.teams].sort((a, b) => a.index - b.index).map((team) => ({
38506
- teamId: team.teamId,
38507
- index: team.index,
38508
- name: team.name,
38509
- context: team.index === ownTeamIndex ? projectContext2(team.context, surface) : Object.fromEntries(
38510
- Object.entries(team.context).filter(
38511
- ([capability]) => across.has(capability)
38512
- )
38513
- )
38514
- }));
38515
- }
38516
- function joinUrl(origin, teamIndex) {
38517
- return `${origin}/team/${teamIndex + 1}/join?bare`;
38518
- }
38519
- function playerBatch({
38520
- surface,
38521
- state: state2,
38522
- viewer,
38523
- origin,
38524
- roundProcessing
38525
- }) {
38526
- const team = teamOf(state2, viewer.teamIndex);
38527
- const participant = viewer.observer ? void 0 : team?.participants.find((p) => p.id === viewer.participantId) ?? team?.participants[0];
38528
- const messages2 = [
38529
- {
38530
- type: "stateChanged",
38531
- payload: projectContext2(team?.context ?? {}, surface),
38532
- // §12.5: the head tick, so a review scrubber can be bounded and a
38533
- // cache invalidated on undo.
38534
- completedTicks: team?.completedTicks ?? state2.session.completedTicks
38535
- },
38536
- { type: "setSettings", payload: settingsFor(state2, surface) }
38537
- ];
38538
- if (participant) {
38539
- messages2.push({
38540
- type: "setParticipant",
38541
- payload: {
38542
- id: participant.id,
38543
- name: participant.name,
38544
- index: participant.index,
38545
- teamId: team?.teamId ?? "team-1"
38546
- }
38547
- });
38548
- }
38549
- messages2.push(
38550
- { type: "setViewerRole", role: viewer.observer ? "observer" : "participant" },
38551
- { type: "setRunKind", runKind: state2.session.runKind },
38552
- { type: "setScenarioName", scenarioName: state2.game.scenarioName },
38553
- {
38554
- type: "setOwnTeam",
38555
- payload: team ? { teamId: team.teamId, index: team.index, name: team.name } : { teamId: "team-1", index: 0, name: "Team 1" }
38556
- },
38557
- {
38558
- type: "setOwnTeamJoinLink",
38559
- payload: team ? { joinUrl: joinUrl(origin, team.index) } : (
38560
- // §12.3, as amended: a host with nothing to offer says so
38561
- // rather than staying silent, so a surface rendering a join
38562
- // panel shows nothing instead of waiting for a message that
38563
- // never comes.
38564
- null
38565
- )
38566
- },
38567
- { type: "setParticipantList", participants: team?.participants ?? [] },
38568
- { type: "setTeamList", payload: teamList(state2) },
38569
- { type: "setTimer", payload: team?.timer ?? IDLE_TIMER2 }
38570
- );
38571
- if (surface.kind === "game") {
38572
- messages2.push({ type: "setRoundProcessing", processing: roundProcessing === true });
38573
- }
38574
- if ((surface.kind === "game" || surface.kind === "waiting-room") && surface.crossTeamReads.length > 0 && state2.session.mode === "shared-state") {
38575
- messages2.push({
38576
- type: "setCrossTeamData",
38577
- payload: crossTeamData(state2, surface, team?.index)
38578
- });
38579
- }
38580
- return messages2;
38581
- }
38582
- function sessionBatch({
38583
- surface,
38584
- state: state2,
38585
- gameName,
38586
- origin,
38587
- hasGuide
38588
- }) {
38589
- return [
38590
- {
38591
- type: "setSessionMeta",
38592
- payload: {
38593
- sessionId: "dev-session",
38594
- name: gameName,
38595
- readOnly: false,
38596
- waitingRoomOpen: state2.session.waitingRoomOpen,
38597
- joinPin: null
38598
- }
38599
- },
38600
- { type: "setSessionData", payload: sessionData(state2, surface) },
38601
- { type: "setSettings", payload: settingsFor(state2, surface) },
38602
- { type: "setTeamConfiguration", payload: teamConfiguration(state2) },
38603
- { type: "setTeamList", payload: teamList(state2) },
38604
- {
38605
- type: "setParticipantList",
38606
- participants: state2.teams.flatMap(
38607
- (team) => team.participants.map((participant) => ({
38608
- id: participant.id,
38609
- name: participant.name,
38610
- index: participant.index,
38611
- connected: participant.connected,
38612
- teamId: team.teamId
38613
- }))
38614
- )
38615
- },
38616
- { type: "setTeamLinks", payload: teamLinks(state2, origin) },
38617
- { type: "setWalkthroughLink", payload: walkthroughLink(origin) },
38618
- { type: "setRunKind", runKind: state2.session.runKind },
38619
- { type: "setScenarioName", scenarioName: state2.game.scenarioName },
38620
- { type: "setAvailableOverlays", overlays: availableOverlays(hasGuide) }
38621
- ];
38622
- }
38623
- function presentationBatch({
38624
- surface,
38625
- state: state2,
38626
- gameName,
38627
- sessionless
38628
- }) {
38629
- return [
38630
- {
38631
- type: "setPresentation",
38632
- payload: {
38633
- game: {
38634
- name: state2.game.name,
38635
- // Without a session, as the scenario resolves it alone (§6.15.1).
38636
- maxTicks: sessionless ? gameSettingsOf(state2.settingsWithoutSession).maxTicks : state2.session.maxTicks,
38637
- mode: state2.session.mode,
38638
- scenarioName: state2.game.scenarioName
38639
- },
38640
- session: sessionless ? null : {
38641
- // The dev server runs one session; its id is the
38642
- // one the session surface is told (above).
38643
- id: "dev-session",
38644
- name: gameName,
38645
- completedTicks: Math.max(
38646
- state2.session.completedTicks,
38647
- ...state2.teams.map((team) => team.completedTicks)
38648
- ),
38649
- data: sessionData(state2, surface),
38650
- teams: teamList(state2)
38651
- }
38652
- }
38653
- },
38654
- {
38655
- type: "setSettings",
38656
- payload: settingsFor(state2, surface, { withoutSession: sessionless })
38657
- }
38658
- ];
38659
- }
38660
- function walkthroughLink(origin) {
38661
- return { url: `${origin}/walkthrough` };
38662
- }
38663
- function availableOverlays(hasGuide = false) {
38664
- return hasGuide ? ["facilitator-guide", "print-sheets"] : ["print-sheets"];
38665
- }
38666
- function teamLinks(state2, origin) {
38667
- return [...state2.teams].sort((a, b) => a.index - b.index).map((team) => ({
38668
- teamId: team.teamId,
38669
- joinUrl: joinUrl(origin, team.index),
38670
- observeUrl: `${origin}/team/${team.index + 1}/observe`
38671
- }));
38672
- }
38673
- function teamConfiguration(state2) {
38674
- return {
38675
- mode: state2.session.mode,
38676
- ...state2.session.teamBounds.min === void 0 ? {} : { min: state2.session.teamBounds.min },
38677
- max: state2.session.teamBounds.max
38678
- };
38679
- }
38680
- function sessionData(state2, surface) {
38681
- const teams = {};
38682
- for (const team of state2.teams) {
38683
- const own5 = {};
38684
- for (const [capability, values] of Object.entries(team.context)) {
38685
- if (!(capability in state2.shared)) own5[capability] = values;
38686
- }
38687
- teams[team.teamId] = {
38688
- context: projectContext2(own5, surface),
38689
- completedTicks: team.completedTicks,
38690
- timer: team.timer ?? IDLE_TIMER2,
38691
- // Monotonic per delivery. One session, one host, so the tick is a
38692
- // sufficient clock; the wrapper only compares it with itself.
38693
- revision: team.completedTicks
38694
- };
38695
- }
38696
- return {
38697
- // The dev server only ever sends snapshots, so the revision is a
38698
- // baseline the wrapper never compares a delta against.
38699
- shared: {
38700
- context: projectContext2(state2.shared, surface),
38701
- revision: state2.session.completedTicks
38702
- },
38703
- teams
38704
- };
38705
- }
38706
-
38707
38960
  // cli/dev/view/viewer.ts
38708
38961
  function resolveViewer(state2, route) {
38709
38962
  const base = {
@@ -38818,7 +39071,7 @@ function viewMessages(page, state2, options) {
38818
39071
  origin: options.origin,
38819
39072
  assetOrigin: options.assetOrigin,
38820
39073
  gameName: options.gameName,
38821
- hasGuide: options.hasGuide,
39074
+ overlays: options.overlays,
38822
39075
  roundProcessing: options.roundProcessing
38823
39076
  });
38824
39077
  }
@@ -39462,7 +39715,10 @@ Install the package's dependencies to serve its surfaces.
39462
39715
  origin: this.consoleOrigin(view.host),
39463
39716
  assetOrigin: origin,
39464
39717
  gameName: state2.game.name,
39465
- hasGuide: session.effectiveGuide() !== null,
39718
+ overlays: availableOverlays({
39719
+ guide: session.effectiveGuide() !== null,
39720
+ presentation: offersPresentationOverlay(session.packageConfiguration())
39721
+ }),
39466
39722
  roundProcessing
39467
39723
  });
39468
39724
  return { page, messages: messages2 };