@seriousgaming/sdk-tools 1.6.0 → 1.7.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 (135) hide show
  1. package/dist/agent/guidance.md +350 -0
  2. package/dist/{cli-I355WTAF.js → cli-2DQJACAH.js} +20 -12
  3. package/dist/{cli-PTT5RGKO.js → cli-3PIJLSRQ.js} +5 -5
  4. package/dist/{cli-O6PWMJTZ.js → cli-4CHKF4DQ.js} +1 -1
  5. package/dist/{cli-UJ4UCL2Z.js → cli-4VZIJYKU.js} +1 -1
  6. package/dist/{cli-O5KP4OVN.js → cli-4XCQUM3E.js} +2 -2
  7. package/dist/{cli-6WXLXJVX.js → cli-57C72YKJ.js} +14 -14
  8. package/dist/{cli-GFBGYFYD.js → cli-57V4ARER.js} +1 -1
  9. package/dist/{cli-IRZ5KB7D.js → cli-5G7TZHD3.js} +14 -14
  10. package/dist/{cli-QEVDDBNO.js → cli-64AA7367.js} +8 -8
  11. package/dist/{cli-LMDJCHHD.js → cli-6HB6HTC6.js} +47 -47
  12. package/dist/{cli-TCY5LJ7E.js → cli-6ZSMW4HR.js} +10 -10
  13. package/dist/{cli-RN6IWTL2.js → cli-7MBLH4M3.js} +14 -14
  14. package/dist/{cli-K2B6WHKA.js → cli-7RYIEKMB.js} +10 -10
  15. package/dist/{cli-ZVSFYDPQ.js → cli-7TOLC62D.js} +16 -14
  16. package/dist/{cli-LXYPE3L5.js → cli-ATI6OLJU.js} +12 -12
  17. package/dist/{cli-ROT3DRKU.js → cli-BOXXMDSX.js} +16 -18
  18. package/dist/{cli-UKQYZYFK.js → cli-C3OERMIR.js} +1 -1
  19. package/dist/{cli-VCKOC2EV.js → cli-C6G65H6S.js} +2 -2
  20. package/dist/{cli-ORIG557O.js → cli-CV4JGVJR.js} +17 -27
  21. package/dist/{cli-HYY64SUD.js → cli-CXCL7VRK.js} +13 -13
  22. package/dist/{cli-FBTRTIZJ.js → cli-DEBCP7UH.js} +10 -10
  23. package/dist/{cli-BPYMTOUL.js → cli-DHOWZCXT.js} +10 -10
  24. package/dist/{cli-E6DJIMYD.js → cli-EDCAH2TC.js} +17 -23
  25. package/dist/{cli-C6TH5S7K.js → cli-EJVAQCMQ.js} +30 -3
  26. package/dist/{cli-DZW3XD5F.js → cli-ESA6YNPF.js} +17 -25
  27. package/dist/{cli-UTJU4IYG.js → cli-FP32D3T6.js} +10 -10
  28. package/dist/{cli-EVFS55WN.js → cli-FXWWYBYU.js} +22 -25
  29. package/dist/{cli-MBNMPVDC.js → cli-FXY3DKPW.js} +8 -5
  30. package/dist/{cli-G6UE5NL4.js → cli-FZ7QAZZP.js} +11 -11
  31. package/dist/{cli-KL3756X6.js → cli-G5DQGZ2E.js} +17 -19
  32. package/dist/{cli-JFU22EJ2.js → cli-GEQUJF4L.js} +11 -11
  33. package/dist/{cli-WAE26SVW.js → cli-GHLILDH7.js} +9 -9
  34. package/dist/{cli-PFFCNGHI.js → cli-GPAN6XK2.js} +3 -3
  35. package/dist/{cli-LFGRFIEO.js → cli-GTWEGYSU.js} +12 -12
  36. package/dist/{cli-4BV45LBH.js → cli-H3J3ICCQ.js} +2 -2
  37. package/dist/{cli-3E3MD5U4.js → cli-HHPMAV4F.js} +1 -1
  38. package/dist/{cli-M6BCQRID.js → cli-HM7CD4VU.js} +18 -29
  39. package/dist/{cli-DMW2OQIJ.js → cli-HYEU3QS6.js} +1 -1
  40. package/dist/{cli-TPU4TUR6.js → cli-IPP5FDCH.js} +12 -12
  41. package/dist/{cli-UELGBQG7.js → cli-JGFJWZFU.js} +1 -1
  42. package/dist/{cli-2GOFEW26.js → cli-JIZTQVL2.js} +8 -8
  43. package/dist/{cli-GXD36NF2.js → cli-JPAXKLVT.js} +8 -8
  44. package/dist/{cli-YVVXUD2G.js → cli-JR5AZLLK.js} +7 -2
  45. package/dist/{cli-PQBXVLEU.js → cli-JRIIAZ33.js} +8 -8
  46. package/dist/{cli-3HE4AVZG.js → cli-JRMHSMYT.js} +17 -21
  47. package/dist/{cli-SIPDUBFL.js → cli-L5IG7MY2.js} +14 -14
  48. package/dist/{cli-FYINNRML.js → cli-LE5ICDAF.js} +27 -70
  49. package/dist/{cli-LFM7GJHI.js → cli-LQ4VSM5R.js} +0 -0
  50. package/dist/{cli-RA673NGF.js → cli-LQERHJFE.js} +4 -4
  51. package/dist/{cli-ZWPYIXNI.js → cli-LRQDF3ZO.js} +7 -7
  52. package/dist/{cli-V4GHRWOV.js → cli-M7WEAIRF.js} +5 -5
  53. package/dist/{cli-GUXKQMJ7.js → cli-MM3A4SPH.js} +1 -1
  54. package/dist/{cli-5JEGTVTG.js → cli-MULKSLA4.js} +12 -12
  55. package/dist/{cli-B4TN6PJP.js → cli-MYJGGLC5.js} +2 -2
  56. package/dist/{cli-7OGYADZ3.js → cli-NEOLMC2P.js} +12 -12
  57. package/dist/{cli-IDKYF5XB.js → cli-NOQBWJQN.js} +1 -1
  58. package/dist/{cli-TLLA6KAP.js → cli-NPPY557S.js} +10 -10
  59. package/dist/{cli-GTSGLN3Z.js → cli-OANH3BTQ.js} +1 -1
  60. package/dist/{cli-UMFFURZ7.js → cli-OQG3Y4RU.js} +10 -10
  61. package/dist/{cli-6RRVEGFB.js → cli-PIO7NWMH.js} +10 -10
  62. package/dist/{cli-GDQ6ILJY.js → cli-PKQNOGBO.js} +7 -7
  63. package/dist/{cli-DL2CVMRF.js → cli-PVA52RC2.js} +11 -11
  64. package/dist/{cli-JZM7XTNV.js → cli-R7RG2VMW.js} +10 -10
  65. package/dist/{cli-ZISJ36MM.js → cli-SOFCTQAL.js} +10 -10
  66. package/dist/{cli-6AMT3BUO.js → cli-SOMIB4B4.js} +12 -12
  67. package/dist/{cli-E33CJRRQ.js → cli-SPGUVL6Z.js} +14 -14
  68. package/dist/{cli-4AKVLEC4.js → cli-SWZY7L7K.js} +3 -3
  69. package/dist/{cli-C3NVCKO6.js → cli-SX3ULO5P.js} +8 -8
  70. package/dist/{cli-S5QDONIQ.js → cli-T4HWGMY4.js} +7 -7
  71. package/dist/{cli-272KBNJH.js → cli-TDYKRXUA.js} +12 -12
  72. package/dist/{cli-UNJ5X6BU.js → cli-TFMNNVJ7.js} +10 -10
  73. package/dist/{cli-PNLYX6R6.js → cli-TFZ53OA2.js} +12 -12
  74. package/dist/{cli-KNOOKGYW.js → cli-TJ3PLRHF.js} +10 -10
  75. package/dist/{cli-JMZLT65J.js → cli-TPNQLYPC.js} +1 -1
  76. package/dist/{cli-QEVE5HUM.js → cli-UBQCSUDH.js} +11 -11
  77. package/dist/{cli-E2NLWIFE.js → cli-UTM4QU67.js} +1 -1
  78. package/dist/{cli-U2UE7I7J.js → cli-UY4VDI7W.js} +8 -8
  79. package/dist/{cli-XCO2VQOH.js → cli-VPON5HGB.js} +19 -17
  80. package/dist/{cli-Q2XJF5AS.js → cli-VYR326C6.js} +18 -21
  81. package/dist/{cli-G522CPRL.js → cli-WAZD75KE.js} +10 -10
  82. package/dist/{cli-R4PCG5YX.js → cli-WG36UJRK.js} +12 -12
  83. package/dist/{cli-GBFM76BF.js → cli-WM6SQJ6Q.js} +5 -5
  84. package/dist/{cli-G6KELFSX.js → cli-X7E3637I.js} +84 -17
  85. package/dist/{cli-AK7OIPWY.js → cli-XR2XSWQN.js} +13 -17
  86. package/dist/{cli-GGPDQNM3.js → cli-XTANOFQR.js} +2 -2
  87. package/dist/{cli-BYJWFFCF.js → cli-YSPZZQCP.js} +2 -2
  88. package/dist/{cli-EEFJKIGL.js → cli-Z5HWENER.js} +17 -25
  89. package/dist/{cli-57RXC3HQ.js → cli-ZBTFLZUL.js} +14 -14
  90. package/dist/{cli-SMFSZF2G.js → cli-ZF7IFB54.js} +21 -4
  91. package/dist/{cli-VCI3CG36.js → cli-ZKG3OPZ6.js} +9 -9
  92. package/dist/{cli-WOGIAU2E.js → cli-ZQ2Y3U7F.js} +7 -7
  93. package/dist/{cli-QUIJCBYB.js → cli-ZRPWZOCW.js} +15 -7
  94. package/dist/{cli-UHSZBKYO.js → cli-ZTZ5H55T.js} +12 -12
  95. package/dist/cli.js +36 -34
  96. package/dist/client.js +178 -69
  97. package/dist/core/game-settings.d.ts +5 -3
  98. package/dist/core/session-roster.d.ts +10 -0
  99. package/dist/dev/console/assets/{index-CuMOOH9m.js → index-CnXlPeLX.js} +47 -47
  100. package/dist/dev/console/index.html +1 -1
  101. package/dist/dev/routes.d.ts +5 -2
  102. package/dist/dev/shell.d.ts +9 -1
  103. package/dist/dev/view/batch.d.ts +11 -1
  104. package/dist/dev/view/route.d.ts +18 -1
  105. package/dist/dev/view/view.d.ts +9 -0
  106. package/dist/docs/ai-agents.md +1 -1
  107. package/dist/docs/api/index.md +1 -1
  108. package/dist/docs/api/sdk-commands.md +4 -0
  109. package/dist/docs/api/sdk-e2e.md +5 -0
  110. package/dist/docs/api/sdk-tools-client.md +4 -0
  111. package/dist/docs/api/sdk-ui-testing.md +1 -0
  112. package/dist/docs/api/sdk-ui.md +28 -0
  113. package/dist/docs/api/sdk.md +2 -0
  114. package/dist/docs/changelog.md +26 -0
  115. package/dist/docs/cli-and-dev-server.md +4 -0
  116. package/dist/docs/cli-reference.md +17 -2
  117. package/dist/docs/getting-started.md +1 -1
  118. package/dist/docs/guides/presentation.md +11 -10
  119. package/dist/docs/guides/session-hooks.md +16 -0
  120. package/dist/docs/guides/settings.md +4 -2
  121. package/dist/docs/guides/starter-game.md +1 -1
  122. package/dist/docs/guides/upgrading.md +31 -2
  123. package/dist/docs/page-index.md +6 -6
  124. package/dist/host/protocol.d.ts +10 -1
  125. package/dist/host.js +1 -0
  126. package/dist/playwright.js +178 -69
  127. package/dist/runtime/manifest-version.d.ts +1 -1
  128. package/dist/runtime.js +1 -1
  129. package/dist/schema.json +10 -1
  130. package/dist/templates/package/CLAUDE.md.template +7 -346
  131. package/dist/templates/package/claude/rules/workflow-create-engine.md +2 -2
  132. package/dist/templates/package/claude/rules/workflow-create-guide.md +2 -2
  133. package/dist/templates/package/claude/rules/workflow-create-user-interface.md +1 -1
  134. package/dist/templates/package/claude/rules/workflow-update-sdk-version.md +3 -3
  135. package/package.json +3 -3
@@ -11,7 +11,7 @@
11
11
  * (or the reverse) is caught before either ships.
12
12
  */
13
13
  import type { ContextDeletePath, EndpointFailure, HostOverlay, Participant, PastStateEntry, PastStateQuery, ThemePreference, TimerState, ValidationRejection } from '@seriousgaming/sdk';
14
- import type { CrossTeamData, MutationOutcome, OwnTeamJoinLink, PresentationGame, PresentationSession, RunKind, SessionData, SessionHookFailure, SessionMeta, SharedState, TeamConfiguration, TeamInfo, TeamLinks, TeamState, UserInterfaceLocale, UserInterfaceTheme, ViewerRole, WalkthroughLink } from '@seriousgaming/sdk/ui';
14
+ import type { CrossTeamData, MutationOutcome, OwnTeamJoinLink, PresentationGame, PresentationSession, RunKind, SessionData, SessionHookFailure, SessionMeta, SharedState, TeamConfiguration, TeamInfo, SessionJoinLink, TeamLinks, TeamState, UserInterfaceLocale, UserInterfaceTheme, ViewerRole, WalkthroughLink } from '@seriousgaming/sdk/ui';
15
15
  /**
16
16
  * Version of the host↔iframe handshake protocol. Both ends stamp it on the
17
17
  * `ready`/`init` window messages and warn (without blocking) when the peer's
@@ -414,6 +414,15 @@ export type HostSessionPortMessage = {
414
414
  type: 'setTeamLinks';
415
415
  payload: TeamLinks[];
416
416
  }
417
+ /**
418
+ * One join link for the whole session (§12.3, §13.4), or `null` when the
419
+ * host has none or the game's `teams.sessionJoin` is false. Facilitator-
420
+ * only, and naming no team: the host places whoever follows it.
421
+ */
422
+ | {
423
+ type: 'setSessionJoinLink';
424
+ payload: SessionJoinLink | null;
425
+ }
417
426
  /**
418
427
  * Whether this session surface belongs to the game being played or to a
419
428
  * walkthrough beside it (§5.7). Sent in the initial batch and never again.
package/dist/host.js CHANGED
@@ -189,6 +189,7 @@ var SURFACES = {
189
189
  "setTeamList",
190
190
  "setParticipantList",
191
191
  "setTeamLinks",
192
+ "setSessionJoinLink",
192
193
  "setAvailableOverlays",
193
194
  "setRunKind",
194
195
  "setScenarioName",
@@ -1817,6 +1817,10 @@ var schema_default = {
1817
1817
  minProperties: 1,
1818
1818
  additionalProperties: false
1819
1819
  }
1820
+ },
1821
+ sessionJoin: {
1822
+ type: "boolean",
1823
+ description: "Whether a session may offer one join link for the whole session, through which the host places each person in a team of its choosing. Defaults to true. Set it false when a game depends on who is in which team, such as one role per team, and hand out team links instead. The default for the `game` settings' `teams.sessionJoin`"
1820
1824
  }
1821
1825
  },
1822
1826
  additionalProperties: false
@@ -1869,7 +1873,8 @@ var schema_default = {
1869
1873
  },
1870
1874
  additionalProperties: false
1871
1875
  },
1872
- defaultNames: { $ref: "#/$defs/GameSettingConstraint" }
1876
+ defaultNames: { $ref: "#/$defs/GameSettingConstraint" },
1877
+ sessionJoin: { $ref: "#/$defs/GameSettingConstraint" }
1873
1878
  },
1874
1879
  additionalProperties: false
1875
1880
  },
@@ -1946,6 +1951,10 @@ var schema_default = {
1946
1951
  minProperties: 1,
1947
1952
  additionalProperties: false
1948
1953
  }
1954
+ },
1955
+ sessionJoin: {
1956
+ type: "boolean",
1957
+ description: "Whether the host may offer one join link for the whole session, placing each person in a team of its choosing. Read once as the session is created, so only the game and its scenarios set it"
1949
1958
  }
1950
1959
  },
1951
1960
  additionalProperties: false
@@ -2717,6 +2726,7 @@ var TITLES = {
2717
2726
  "teams.perTeam.minParticipants": "Minimum participants per team",
2718
2727
  "teams.perTeam.maxParticipants": "Maximum participants per team",
2719
2728
  "teams.defaultNames": "Default team names",
2729
+ "teams.sessionJoin": "Offer a session join link",
2720
2730
  "waitingRoom.openOnStart": "Open the waiting room on start"
2721
2731
  };
2722
2732
  function gameSettingsDefaults(manifest) {
@@ -2730,7 +2740,8 @@ function gameSettingsDefaults(manifest) {
2730
2740
  minParticipants: teams?.perTeam?.minParticipants ?? null,
2731
2741
  maxParticipants: teams?.perTeam?.maxParticipants ?? null
2732
2742
  },
2733
- defaultNames: teams?.defaultNames ?? []
2743
+ defaultNames: teams?.defaultNames ?? [],
2744
+ sessionJoin: teams?.sessionJoin !== false
2734
2745
  },
2735
2746
  waitingRoom: { openOnStart: manifest.waitingRoom?.openOnStart === true }
2736
2747
  };
@@ -2812,7 +2823,8 @@ function gameSettingsOf(resolved) {
2812
2823
  minParticipants: game.teams?.perTeam?.minParticipants ?? null,
2813
2824
  maxParticipants: game.teams?.perTeam?.maxParticipants ?? null
2814
2825
  },
2815
- defaultNames: game.teams?.defaultNames ?? neutral.teams.defaultNames
2826
+ defaultNames: game.teams?.defaultNames ?? neutral.teams.defaultNames,
2827
+ sessionJoin: game.teams?.sessionJoin !== false
2816
2828
  },
2817
2829
  waitingRoom: { openOnStart: game.waitingRoom?.openOnStart === true }
2818
2830
  };
@@ -2834,6 +2846,10 @@ function gameOverrideRefusal(overrides) {
2834
2846
  if ("waitingRoom" in game) {
2835
2847
  return "game.waitingRoom.openOnStart cannot be set for a session: it seeds the waiting room as the session is created, before setup. Set it in the manifest or a scenario instead";
2836
2848
  }
2849
+ const teams = game.teams;
2850
+ if (teams !== null && typeof teams === "object" && "sessionJoin" in teams) {
2851
+ return "game.teams.sessionJoin cannot be set for a session: it is read as the session is created, before setup, so the session link cannot switch on and off while people are arriving. Set it in the manifest or a scenario instead";
2852
+ }
2837
2853
  return null;
2838
2854
  }
2839
2855
 
@@ -5389,6 +5405,7 @@ var COMMAND_FIELDS = {
5389
5405
  renameOwnTeam: { name: "string", "participantId?": "string", "teamId?": "string" },
5390
5406
  renameSelf: { name: "string", "participantId?": "string", "teamId?": "string" },
5391
5407
  addParticipant: { teamId: "string", "name?": "string" },
5408
+ joinSession: { "name?": "string" },
5392
5409
  renameParticipant: { participantId: "string", name: "string" },
5393
5410
  moveParticipant: { participantId: "string", teamId: "string" },
5394
5411
  setWaitingRoom: { open: "boolean" },
@@ -24303,6 +24320,29 @@ var SessionRoster = class {
24303
24320
  await this.fireHook("participantJoin", record2);
24304
24321
  return void 0;
24305
24322
  }
24323
+ /**
24324
+ * Join through the session link (§13.4).
24325
+ *
24326
+ * Which team is this host's own choice, and nothing a game may rely on:
24327
+ * the one with the fewest participants, the lowest index on a tie, so a
24328
+ * room scanning one code fills its teams evenly. It creates an ordinary
24329
+ * participant with an ordinary `participantJoin`, exactly as a team link
24330
+ * does.
24331
+ */
24332
+ async joinSession(name) {
24333
+ if (this.host.runKind === "walkthrough") {
24334
+ throw new DeniedError("A walkthrough holds one participant, so it has no session link");
24335
+ }
24336
+ if (!this.host.settings().teams.sessionJoin) {
24337
+ throw new DeniedError(
24338
+ "This game offers no session link: its teams.sessionJoin is false. Join through a team link instead"
24339
+ );
24340
+ }
24341
+ const { state: state2, participants } = this.host;
24342
+ const placement = state2.getTeamIndexes().map((index3) => ({ index: index3, held: participants.list(`team-${index3 + 1}`).length })).sort((a, b) => a.held - b.held || a.index - b.index)[0];
24343
+ if (!placement) throw new DeniedError("The session has no team to join");
24344
+ return this.addParticipant(`team-${placement.index + 1}`, name);
24345
+ }
24306
24346
  renameParticipant(participantId, name) {
24307
24347
  const teamId = this.findParticipantTeam(participantId);
24308
24348
  if (!teamId) throw new DeniedError(`Unknown participant "${participantId}"`);
@@ -25733,6 +25773,7 @@ var PLAY_STAGE = /* @__PURE__ */ new Set([
25733
25773
  "updateContext",
25734
25774
  "updateSharedContext",
25735
25775
  "addParticipant",
25776
+ "joinSession",
25736
25777
  "renameParticipant",
25737
25778
  "moveParticipant",
25738
25779
  "renameOwnTeam",
@@ -26409,6 +26450,8 @@ var Session = class {
26409
26450
  return this.roster.renameSelf(command);
26410
26451
  case "addParticipant":
26411
26452
  return this.roster.addParticipant(command.teamId, command.name);
26453
+ case "joinSession":
26454
+ return this.roster.joinSession(command.name);
26412
26455
  case "renameParticipant":
26413
26456
  return this.roster.renameParticipant(command.participantId, command.name);
26414
26457
  case "moveParticipant":
@@ -30182,6 +30225,7 @@ function sessionBatch({
30182
30225
  participants: participantList(state2)
30183
30226
  },
30184
30227
  { type: "setTeamLinks", payload: teamLinks(state2, origin) },
30228
+ { type: "setSessionJoinLink", payload: sessionJoinLink(state2, origin) },
30185
30229
  { type: "setWalkthroughLink", payload: walkthroughLink(origin) },
30186
30230
  { type: "setRunKind", runKind: state2.session.runKind },
30187
30231
  { type: "setScenarioName", scenarioName: state2.game.scenarioName },
@@ -30224,7 +30268,8 @@ function presentationBatch({
30224
30268
  teamId,
30225
30269
  joinUrl: joinUrl2
30226
30270
  })),
30227
- joinPin: null
30271
+ joinPin: null,
30272
+ sessionJoinLink: sessionJoinLink(state2, origin)
30228
30273
  }
30229
30274
  }
30230
30275
  },
@@ -30266,6 +30311,11 @@ function teamLinks(state2, origin) {
30266
30311
  observeUrl: `${origin}/team/${team.index + 1}/observe`
30267
30312
  }));
30268
30313
  }
30314
+ function sessionJoinLink(state2, origin) {
30315
+ if (state2.session.runKind === "walkthrough") return null;
30316
+ if (!gameSettingsOf(state2.settings).teams.sessionJoin) return null;
30317
+ return { joinUrl: `${origin}/join?bare` };
30318
+ }
30269
30319
  function teamConfiguration(state2) {
30270
30320
  return {
30271
30321
  mode: state2.session.mode,
@@ -30300,17 +30350,82 @@ function sessionData(state2, surface) {
30300
30350
  };
30301
30351
  }
30302
30352
 
30353
+ // cli/dev/view/route.ts
30354
+ var PATTERNS = [
30355
+ [/^\/walkthrough\/?$/, () => ({ kind: "player", teamIndex: 0, participant: 1 })],
30356
+ [/^\/team\/(\d+)\/player\/(\d+)\/?$/, (m) => player(m[1], m[2])],
30357
+ [/^\/team\/(\d+)\/player\/?$/, (m) => player(m[1], "1")],
30358
+ [/^\/team\/(\d+)\/observe\/?$/, (m) => ({ kind: "observer", teamIndex: index2(m[1]) })],
30359
+ [/^\/team\/(\d+)\/join\/?$/, (m) => ({ kind: "join", teamIndex: index2(m[1]) })],
30360
+ [/^\/team\/(\d+)\/waiting-room\/?$/, (m) => ({ kind: "waiting-room", teamIndex: index2(m[1]) })],
30361
+ [/^\/join\/?$/, () => ({ kind: "session-join" })],
30362
+ [/^\/setup\/?$/, () => ({ kind: "setup" })],
30363
+ [/^\/scenario-editor\/?$/, () => ({ kind: "scenario-editor" })],
30364
+ [/^\/guide\/?$/, () => ({ kind: "guide" })],
30365
+ [/^\/print\/?$/, () => ({ kind: "print" })],
30366
+ [/^\/presentation\/?$/, () => ({ kind: "presentation" })]
30367
+ ];
30368
+ function player(team, participant) {
30369
+ return {
30370
+ kind: "player",
30371
+ teamIndex: index2(team),
30372
+ participant: Math.max(1, Number(participant))
30373
+ };
30374
+ }
30375
+ function index2(team) {
30376
+ return Math.max(0, Number(team) - 1);
30377
+ }
30378
+ var LOCAL_ORIGINS_FLAG = "local-origins";
30379
+ function wantsLocalOrigins(search2) {
30380
+ return new URLSearchParams(search2).has(LOCAL_ORIGINS_FLAG);
30381
+ }
30382
+ function parseRoute(pathname, search2) {
30383
+ const query = new URLSearchParams(search2);
30384
+ const bare = query.has("bare");
30385
+ const preview = query.has("preview");
30386
+ const scenario = query.get("scenario");
30387
+ const run = /^\/walkthrough(\/|$)/.test(pathname) ? "walkthrough" : "session";
30388
+ for (const [pattern, build2] of PATTERNS) {
30389
+ const match2 = pathname.match(pattern);
30390
+ if (match2) {
30391
+ return {
30392
+ ...build2(match2),
30393
+ bare,
30394
+ run,
30395
+ ...scenario === null ? {} : { scenario },
30396
+ ...preview ? { preview } : {}
30397
+ };
30398
+ }
30399
+ }
30400
+ return { kind: "console", bare, run };
30401
+ }
30402
+ function routeHref(route) {
30403
+ const team = (route.teamIndex ?? 0) + 1;
30404
+ const path3 = route.run === "walkthrough" ? "/walkthrough" : route.kind === "player" ? `/team/${team}/player/${route.participant ?? 1}` : route.kind === "observer" ? `/team/${team}/observe` : route.kind === "join" ? `/team/${team}/join` : route.kind === "session-join" ? "/join" : route.kind === "waiting-room" ? `/team/${team}/waiting-room` : route.kind === "console" ? "/" : `/${route.kind}`;
30405
+ const query = new URLSearchParams();
30406
+ if (route.scenario !== void 0) query.set("scenario", route.scenario);
30407
+ if (route.preview) query.set("preview", "");
30408
+ if (route.bare) query.set("bare", "");
30409
+ const search2 = query.toString().replace(/(bare|preview)=(?=&|$)/g, "$1");
30410
+ return search2 ? `${path3}?${search2}` : path3;
30411
+ }
30412
+
30303
30413
  // cli/dev/routes.ts
30304
30414
  function runOf(req) {
30305
30415
  return req.query.run === "walkthrough" ? "walkthrough" : "session";
30306
30416
  }
30417
+ function localOrigins(req, res) {
30418
+ if (req.query[LOCAL_ORIGINS_FLAG] === void 0) return false;
30419
+ res.setHeader("Cache-Control", "no-store");
30420
+ return true;
30421
+ }
30307
30422
  function registerRoutes(app, deps) {
30308
30423
  const { session, packagePath, runFor } = deps;
30309
30424
  app.get("/api/state", async (req, res) => {
30310
30425
  res.json((await runFor(runOf(req))).project());
30311
30426
  });
30312
30427
  app.get("/api/surfaces", (req, res) => {
30313
- const origin = deps.assetOrigin(req.headers.host);
30428
+ const origin = deps.assetOrigin(req.headers.host, localOrigins(req, res));
30314
30429
  res.json(
30315
30430
  mountableSurfaces(session.packageConfiguration()).map((mountable) => ({
30316
30431
  ...mountable,
@@ -30375,7 +30490,7 @@ function registerRoutes(app, deps) {
30375
30490
  });
30376
30491
  });
30377
30492
  app.get("/api/brands", (req, res) => {
30378
- const assetOrigin = deps.assetOrigin(req.headers.host);
30493
+ const assetOrigin = deps.assetOrigin(req.headers.host, localOrigins(req, res));
30379
30494
  res.json({ brands: deps.brands().map((brand) => summarise(brand, assetOrigin)) });
30380
30495
  });
30381
30496
  app.get("/api/locales", (_req, res) => {
@@ -30846,61 +30961,6 @@ function queryFor(message, surface, viewer) {
30846
30961
  }
30847
30962
  }
30848
30963
 
30849
- // cli/dev/view/route.ts
30850
- var PATTERNS = [
30851
- [/^\/walkthrough\/?$/, () => ({ kind: "player", teamIndex: 0, participant: 1 })],
30852
- [/^\/team\/(\d+)\/player\/(\d+)\/?$/, (m) => player(m[1], m[2])],
30853
- [/^\/team\/(\d+)\/player\/?$/, (m) => player(m[1], "1")],
30854
- [/^\/team\/(\d+)\/observe\/?$/, (m) => ({ kind: "observer", teamIndex: index2(m[1]) })],
30855
- [/^\/team\/(\d+)\/join\/?$/, (m) => ({ kind: "join", teamIndex: index2(m[1]) })],
30856
- [/^\/team\/(\d+)\/waiting-room\/?$/, (m) => ({ kind: "waiting-room", teamIndex: index2(m[1]) })],
30857
- [/^\/setup\/?$/, () => ({ kind: "setup" })],
30858
- [/^\/scenario-editor\/?$/, () => ({ kind: "scenario-editor" })],
30859
- [/^\/guide\/?$/, () => ({ kind: "guide" })],
30860
- [/^\/print\/?$/, () => ({ kind: "print" })],
30861
- [/^\/presentation\/?$/, () => ({ kind: "presentation" })]
30862
- ];
30863
- function player(team, participant) {
30864
- return {
30865
- kind: "player",
30866
- teamIndex: index2(team),
30867
- participant: Math.max(1, Number(participant))
30868
- };
30869
- }
30870
- function index2(team) {
30871
- return Math.max(0, Number(team) - 1);
30872
- }
30873
- function parseRoute(pathname, search2) {
30874
- const query = new URLSearchParams(search2);
30875
- const bare = query.has("bare");
30876
- const preview = query.has("preview");
30877
- const scenario = query.get("scenario");
30878
- const run = /^\/walkthrough(\/|$)/.test(pathname) ? "walkthrough" : "session";
30879
- for (const [pattern, build2] of PATTERNS) {
30880
- const match2 = pathname.match(pattern);
30881
- if (match2) {
30882
- return {
30883
- ...build2(match2),
30884
- bare,
30885
- run,
30886
- ...scenario === null ? {} : { scenario },
30887
- ...preview ? { preview } : {}
30888
- };
30889
- }
30890
- }
30891
- return { kind: "console", bare, run };
30892
- }
30893
- function routeHref(route) {
30894
- const team = (route.teamIndex ?? 0) + 1;
30895
- const path3 = route.run === "walkthrough" ? "/walkthrough" : route.kind === "player" ? `/team/${team}/player/${route.participant ?? 1}` : route.kind === "observer" ? `/team/${team}/observe` : route.kind === "join" ? `/team/${team}/join` : route.kind === "waiting-room" ? `/team/${team}/waiting-room` : route.kind === "console" ? "/" : `/${route.kind}`;
30896
- const query = new URLSearchParams();
30897
- if (route.scenario !== void 0) query.set("scenario", route.scenario);
30898
- if (route.preview) query.set("preview", "");
30899
- if (route.bare) query.set("bare", "");
30900
- const search2 = query.toString().replace(/(bare|preview)=(?=&|$)/g, "$1");
30901
- return search2 ? `${path3}?${search2}` : path3;
30902
- }
30903
-
30904
30964
  // cli/dev/view/viewer.ts
30905
30965
  function resolveViewer(state2, route) {
30906
30966
  const base2 = {
@@ -30944,6 +31004,7 @@ var VIEW_ROUTES = /* @__PURE__ */ new Set([
30944
31004
  "observer",
30945
31005
  "waiting-room",
30946
31006
  "join",
31007
+ "session-join",
30947
31008
  "setup"
30948
31009
  ]);
30949
31010
  function isViewRoute(route) {
@@ -30958,6 +31019,12 @@ function resolveView(state2, route, surfaces) {
30958
31019
  if (!inSetup && effective.kind === "setup") {
30959
31020
  return { status: "closed", configurable };
30960
31021
  }
31022
+ if (effective.kind === "session-join") {
31023
+ return {
31024
+ status: "session-join",
31025
+ offered: state2.session.runKind !== "walkthrough" && gameSettingsOf(state2.settings).teams.sessionJoin
31026
+ };
31027
+ }
30961
31028
  if (effective.kind === "join") {
30962
31029
  const team = state2.teams.find((candidate) => candidate.index === effective.teamIndex);
30963
31030
  if (!team) return { status: "join", team: null };
@@ -31029,7 +31096,7 @@ var REINITIALISING_CAUSES = /* @__PURE__ */ new Set([
31029
31096
  "selectScenario",
31030
31097
  REINITIALISED_ON_CHANGE
31031
31098
  ]);
31032
- var CONSOLE_ROUTE = /^\/(?:$|team\/\d+(?:\/(?:player(?:\/\d+)?|observe|join|waiting-room))?\/?$|walkthrough\/?$|setup\/?$|scenario-editor\/?$|guide\/?$|print\/?$|presentation\/?$)/;
31099
+ var CONSOLE_ROUTE = /^\/(?:$|team\/\d+(?:\/(?:player(?:\/\d+)?|observe|join|waiting-room))?\/?$|join\/?$|walkthrough\/?$|setup\/?$|scenario-editor\/?$|guide\/?$|print\/?$|presentation\/?$)/;
31033
31100
  var DELEGATED_FEATURES = [
31034
31101
  "clipboard-write",
31035
31102
  "autoplay",
@@ -31324,9 +31391,12 @@ var DevShell = class {
31324
31391
  * public one where given, else the same host on the asset port. A browser
31325
31392
  * on another machine reached us by an address `localhost` would not
31326
31393
  * resolve to on its side.
31394
+ *
31395
+ * `local` skips the public one, for a client that has said it runs here
31396
+ * (`?local-origins`): it may not reach the proxy in front of us at all.
31327
31397
  */
31328
- assetOrigin(host) {
31329
- const configured = this.publicAssetUrl;
31398
+ assetOrigin(host, local = false) {
31399
+ const configured = local ? null : this.publicAssetUrl;
31330
31400
  if (configured) return configured;
31331
31401
  const name = (host ?? "localhost").replace(/:\d+$/, "") || "localhost";
31332
31402
  return `http://${name}:${this.assetPort}`;
@@ -31440,7 +31510,7 @@ var DevShell = class {
31440
31510
  settleWalkthroughReset: (command) => this.settleWalkthroughReset(command),
31441
31511
  packagePath: this.options.packagePath,
31442
31512
  vitePort: () => this.vitePort,
31443
- assetOrigin: (host) => this.assetOrigin(host),
31513
+ assetOrigin: (host, local) => this.assetOrigin(host, local),
31444
31514
  instanceId: this.instanceId,
31445
31515
  notices: (run) => this.notices(run),
31446
31516
  brands: () => this.currentBrands()
@@ -31458,10 +31528,12 @@ ${MISSING_CONSOLE_MESSAGE}
31458
31528
  res.status(503).type("text/plain").send(MISSING_CONSOLE_MESSAGE);
31459
31529
  return;
31460
31530
  }
31531
+ const local = wantsLocalOrigins(req.url.split("?")[1] ?? "");
31461
31532
  res.setHeader(
31462
31533
  "Permissions-Policy",
31463
- delegatedFeatures(this.assetOrigin(req.headers.host))
31534
+ delegatedFeatures(this.assetOrigin(req.headers.host, local))
31464
31535
  );
31536
+ if (local) res.setHeader("Cache-Control", "no-store");
31465
31537
  res.sendFile("index.html", { root: console_.path });
31466
31538
  });
31467
31539
  this.app.use(express2.static(console_.path));
@@ -31661,7 +31733,11 @@ Install the package's dependencies to serve its surfaces.
31661
31733
  socket.close(4e3, "Not a viewer page");
31662
31734
  return;
31663
31735
  }
31664
- this.views.set(socket, { route, host: request.headers.host });
31736
+ this.views.set(socket, {
31737
+ route,
31738
+ host: request.headers.host,
31739
+ localOrigins: wantsLocalOrigins(location.search)
31740
+ });
31665
31741
  void this.sendView(socket).then(() => this.syncPresence(route.run));
31666
31742
  socket.on("message", (raw) => void this.receiveView(socket, raw));
31667
31743
  socket.on("close", () => {
@@ -31721,7 +31797,10 @@ Install the package's dependencies to serve its surfaces.
31721
31797
  // -----------------------------------------------------------------------
31722
31798
  /** What one viewer page is owed, now. */
31723
31799
  viewOf(session, view, state2 = session.project()) {
31724
- const origin = this.assetOrigin(view.host);
31800
+ if (view.joined !== void 0) {
31801
+ return { page: { status: "redirect", href: view.joined }, messages: [] };
31802
+ }
31803
+ const origin = this.assetOrigin(view.host, view.localOrigins);
31725
31804
  const surfaces = mountableSurfaces(session.packageConfiguration()).map(
31726
31805
  (surface) => ({ ...surface, origin })
31727
31806
  );
@@ -31862,7 +31941,9 @@ Install the package's dependencies to serve its surfaces.
31862
31941
  try {
31863
31942
  const session = await this.runFor(view.route.run);
31864
31943
  const { page } = this.viewOf(session, view);
31865
- if (page.status === "surface") {
31944
+ if (page.status === "session-join" && frameMessage.type === "joinSession") {
31945
+ result = await this.joinThroughSessionLink(session, view, socket, frameMessage);
31946
+ } else if (page.status === "surface") {
31866
31947
  const command = queryFor(frameMessage, page.surface, page.viewer) ?? commandFor(frameMessage, page.surface, page.viewer);
31867
31948
  if (isFrameRefusal(command)) {
31868
31949
  result = { ok: false, outcome: { kind: "denied", message: command.refused } };
@@ -31878,6 +31959,34 @@ Install the package's dependencies to serve its surfaces.
31878
31959
  }
31879
31960
  if (requestId) send(socket, { type: "result", requestId, result });
31880
31961
  }
31962
+ /**
31963
+ * Join from the session link's page (§13.4): the session places the
31964
+ * newcomer, and the page is sent on to the participant it made.
31965
+ */
31966
+ async joinThroughSessionLink(session, view, socket, message) {
31967
+ const before = new Set(
31968
+ session.project().teams.flatMap((t) => t.participants.map((p) => p.id))
31969
+ );
31970
+ const name = typeof message.name === "string" ? message.name : void 0;
31971
+ const result = await session.submit({
31972
+ type: "joinSession",
31973
+ ...name === void 0 ? {} : { name }
31974
+ });
31975
+ if (!result.ok) return result;
31976
+ for (const team of session.project().teams) {
31977
+ const position2 = team.participants.findIndex((p) => !before.has(p.id));
31978
+ if (position2 === -1) continue;
31979
+ view.joined = routeHref({
31980
+ kind: "player",
31981
+ teamIndex: team.index,
31982
+ participant: position2 + 1,
31983
+ bare: true
31984
+ });
31985
+ await this.sendView(socket, session);
31986
+ break;
31987
+ }
31988
+ return result;
31989
+ }
31881
31990
  broadcast(event, run) {
31882
31991
  let payload = null;
31883
31992
  this.sockets?.clients.forEach((client) => {
@@ -26,7 +26,7 @@ export declare const MANIFEST_VERSION = 3;
26
26
  * section is stamped, it is the revision at the top of the appendix.
27
27
  * `spec-revision.test.ts` holds the two together.
28
28
  */
29
- export declare const SPEC_REVISION = "1.5";
29
+ export declare const SPEC_REVISION = "1.6";
30
30
  /**
31
31
  * Whether specification revision `revision` is later than `than`, both as
32
32
  * `major.minor`. A runtime MAY warn when a package's `builtWith.specRevision`
package/dist/runtime.js CHANGED
@@ -305,7 +305,7 @@ function readTickControllerResult(label, result) {
305
305
 
306
306
  // cli/runtime/manifest-version.ts
307
307
  var MANIFEST_VERSION = 3;
308
- var SPEC_REVISION = "1.5";
308
+ var SPEC_REVISION = "1.6";
309
309
  function isLaterSpecRevision(revision, than) {
310
310
  const [major, minor] = revision.split(".").map(Number);
311
311
  const [thanMajor, thanMinor] = than.split(".").map(Number);
package/dist/schema.json CHANGED
@@ -682,6 +682,10 @@
682
682
  "minProperties": 1,
683
683
  "additionalProperties": false
684
684
  }
685
+ },
686
+ "sessionJoin": {
687
+ "type": "boolean",
688
+ "description": "Whether a session may offer one join link for the whole session, through which the host places each person in a team of its choosing. Defaults to true. Set it false when a game depends on who is in which team, such as one role per team, and hand out team links instead. The default for the `game` settings' `teams.sessionJoin`"
685
689
  }
686
690
  },
687
691
  "additionalProperties": false
@@ -734,7 +738,8 @@
734
738
  },
735
739
  "additionalProperties": false
736
740
  },
737
- "defaultNames": { "$ref": "#/$defs/GameSettingConstraint" }
741
+ "defaultNames": { "$ref": "#/$defs/GameSettingConstraint" },
742
+ "sessionJoin": { "$ref": "#/$defs/GameSettingConstraint" }
738
743
  },
739
744
  "additionalProperties": false
740
745
  },
@@ -811,6 +816,10 @@
811
816
  "minProperties": 1,
812
817
  "additionalProperties": false
813
818
  }
819
+ },
820
+ "sessionJoin": {
821
+ "type": "boolean",
822
+ "description": "Whether the host may offer one join link for the whole session, placing each person in a team of its choosing. Read once as the session is created, so only the game and its scenarios set it"
814
823
  }
815
824
  },
816
825
  "additionalProperties": false