@seriousgaming/sdk-tools 1.6.1 → 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.
- package/dist/{cli-7A6MKCUJ.js → cli-2DQJACAH.js} +20 -12
- package/dist/{cli-R2MUZQE2.js → cli-3PIJLSRQ.js} +5 -5
- package/dist/{cli-64AB62PM.js → cli-4CHKF4DQ.js} +1 -1
- package/dist/{cli-5IAW3LIF.js → cli-4VZIJYKU.js} +1 -1
- package/dist/{cli-72XDEFU3.js → cli-4XCQUM3E.js} +2 -2
- package/dist/{cli-2GZYGRVL.js → cli-57C72YKJ.js} +14 -14
- package/dist/{cli-OXAUOWCN.js → cli-57V4ARER.js} +1 -1
- package/dist/{cli-N24OHSAN.js → cli-5G7TZHD3.js} +14 -14
- package/dist/{cli-DOXRQ3S5.js → cli-64AA7367.js} +8 -8
- package/dist/{cli-VPRRICZA.js → cli-6HB6HTC6.js} +47 -47
- package/dist/{cli-ZDUADFBY.js → cli-6ZSMW4HR.js} +10 -10
- package/dist/{cli-RCIWBCXD.js → cli-7MBLH4M3.js} +14 -14
- package/dist/{cli-4PXNOJQX.js → cli-7RYIEKMB.js} +10 -10
- package/dist/{cli-6UTPHWRQ.js → cli-7TOLC62D.js} +14 -14
- package/dist/{cli-N45DREM4.js → cli-ATI6OLJU.js} +12 -12
- package/dist/{cli-PGCIHPU7.js → cli-BOXXMDSX.js} +11 -11
- package/dist/{cli-ZDOTXEKL.js → cli-C3OERMIR.js} +1 -1
- package/dist/{cli-OMWC75CC.js → cli-C6G65H6S.js} +2 -2
- package/dist/{cli-ZJFQ7EEA.js → cli-CV4JGVJR.js} +13 -13
- package/dist/{cli-KGM6RRQW.js → cli-CXCL7VRK.js} +13 -13
- package/dist/{cli-O5ABH2WK.js → cli-DEBCP7UH.js} +10 -10
- package/dist/{cli-KOGRWFN7.js → cli-DHOWZCXT.js} +10 -10
- package/dist/{cli-MU5LB43S.js → cli-EDCAH2TC.js} +13 -13
- package/dist/{cli-XSLNH5PR.js → cli-EJVAQCMQ.js} +30 -3
- package/dist/{cli-JZCLIT3O.js → cli-ESA6YNPF.js} +13 -13
- package/dist/{cli-XAT25PRU.js → cli-FP32D3T6.js} +10 -10
- package/dist/{cli-NROTDF5Y.js → cli-FXWWYBYU.js} +11 -11
- package/dist/{cli-TT36JCU5.js → cli-FXY3DKPW.js} +2 -2
- package/dist/{cli-Y3O5F4JN.js → cli-FZ7QAZZP.js} +11 -11
- package/dist/{cli-XOTNXEJA.js → cli-G5DQGZ2E.js} +13 -13
- package/dist/{cli-HSIHDN6K.js → cli-GEQUJF4L.js} +11 -11
- package/dist/{cli-CD5CIJZI.js → cli-GHLILDH7.js} +9 -9
- package/dist/{cli-L7VYSXQK.js → cli-GPAN6XK2.js} +3 -3
- package/dist/{cli-UZZFNXRX.js → cli-GTWEGYSU.js} +12 -12
- package/dist/{cli-LQOHATY2.js → cli-H3J3ICCQ.js} +2 -2
- package/dist/{cli-5ACDPCXI.js → cli-HHPMAV4F.js} +1 -1
- package/dist/{cli-QUSCIUOM.js → cli-HM7CD4VU.js} +13 -13
- package/dist/{cli-HFX3YPUL.js → cli-HYEU3QS6.js} +1 -1
- package/dist/{cli-3BRC32CP.js → cli-IPP5FDCH.js} +12 -12
- package/dist/{cli-KSGB2ZLK.js → cli-JGFJWZFU.js} +1 -1
- package/dist/{cli-RLEGRWFM.js → cli-JIZTQVL2.js} +8 -8
- package/dist/{cli-45OCBG53.js → cli-JPAXKLVT.js} +8 -8
- package/dist/{cli-4VFZHLDG.js → cli-JR5AZLLK.js} +1 -1
- package/dist/{cli-6SGCYEEC.js → cli-JRIIAZ33.js} +8 -8
- package/dist/{cli-3D3ZXWOV.js → cli-JRMHSMYT.js} +13 -13
- package/dist/{cli-DDJYUKQG.js → cli-L5IG7MY2.js} +14 -14
- package/dist/{cli-4SIWLHQO.js → cli-LE5ICDAF.js} +2 -2
- package/dist/{cli-FQRVFGN6.js → cli-LQ4VSM5R.js} +0 -0
- package/dist/{cli-HKORECAG.js → cli-LQERHJFE.js} +2 -2
- package/dist/{cli-JVI24FI6.js → cli-LRQDF3ZO.js} +7 -7
- package/dist/{cli-BJMS3VX3.js → cli-M7WEAIRF.js} +5 -5
- package/dist/{cli-KGT5L7VZ.js → cli-MM3A4SPH.js} +1 -1
- package/dist/{cli-3ZKWV3PN.js → cli-MULKSLA4.js} +10 -10
- package/dist/{cli-C6ZLPK2U.js → cli-MYJGGLC5.js} +2 -2
- package/dist/{cli-Z56ZIVA6.js → cli-NEOLMC2P.js} +12 -12
- package/dist/{cli-ZBN5KAIB.js → cli-NOQBWJQN.js} +1 -1
- package/dist/{cli-EVI36HEM.js → cli-NPPY557S.js} +10 -10
- package/dist/{cli-6K3VQQUS.js → cli-OANH3BTQ.js} +1 -1
- package/dist/{cli-VDBW23SS.js → cli-OQG3Y4RU.js} +10 -10
- package/dist/{cli-6QB2VFPY.js → cli-PIO7NWMH.js} +10 -10
- package/dist/{cli-ILFDANBR.js → cli-PKQNOGBO.js} +7 -7
- package/dist/{cli-RSW6EBBD.js → cli-PVA52RC2.js} +11 -11
- package/dist/{cli-C3CMJSNL.js → cli-R7RG2VMW.js} +10 -10
- package/dist/{cli-JJSWBW4H.js → cli-SOFCTQAL.js} +10 -10
- package/dist/{cli-QY5NZAR7.js → cli-SOMIB4B4.js} +12 -12
- package/dist/{cli-WR3NOY74.js → cli-SPGUVL6Z.js} +14 -14
- package/dist/{cli-IEMKI7J7.js → cli-SWZY7L7K.js} +3 -3
- package/dist/{cli-BUQI5UU4.js → cli-SX3ULO5P.js} +8 -8
- package/dist/{cli-IDVUHGKG.js → cli-T4HWGMY4.js} +7 -7
- package/dist/{cli-Y3DDNMPX.js → cli-TDYKRXUA.js} +12 -12
- package/dist/{cli-HW53ICZC.js → cli-TFMNNVJ7.js} +10 -10
- package/dist/{cli-JZOZOEZM.js → cli-TFZ53OA2.js} +12 -12
- package/dist/{cli-G6CANSPL.js → cli-TJ3PLRHF.js} +10 -10
- package/dist/{cli-7XLHO2FE.js → cli-TPNQLYPC.js} +1 -1
- package/dist/{cli-DFBTZEBX.js → cli-UBQCSUDH.js} +11 -11
- package/dist/{cli-BYCHKSSH.js → cli-UTM4QU67.js} +1 -1
- package/dist/{cli-5SM367K7.js → cli-UY4VDI7W.js} +8 -8
- package/dist/{cli-GFNDW2DL.js → cli-VPON5HGB.js} +12 -12
- package/dist/{cli-XZCJIKIV.js → cli-VYR326C6.js} +13 -13
- package/dist/{cli-MOPSZ3CS.js → cli-WAZD75KE.js} +10 -10
- package/dist/{cli-TTMBBEJC.js → cli-WG36UJRK.js} +12 -12
- package/dist/{cli-UMEBPAZQ.js → cli-WM6SQJ6Q.js} +5 -5
- package/dist/{cli-IP4RXGHM.js → cli-X7E3637I.js} +84 -17
- package/dist/{cli-AV2FYC5G.js → cli-XR2XSWQN.js} +7 -7
- package/dist/{cli-Q6ZBZYK2.js → cli-XTANOFQR.js} +2 -2
- package/dist/{cli-J4UBELKF.js → cli-YSPZZQCP.js} +2 -2
- package/dist/{cli-MJV47HKI.js → cli-Z5HWENER.js} +13 -13
- package/dist/{cli-LK3V4RI5.js → cli-ZBTFLZUL.js} +14 -14
- package/dist/{cli-VQ6HVQW4.js → cli-ZF7IFB54.js} +20 -4
- package/dist/{cli-HOE3WLFH.js → cli-ZKG3OPZ6.js} +9 -9
- package/dist/{cli-TTKICM5P.js → cli-ZQ2Y3U7F.js} +7 -7
- package/dist/{cli-6VNKQ3OX.js → cli-ZRPWZOCW.js} +15 -7
- package/dist/{cli-2NU2LPEE.js → cli-ZTZ5H55T.js} +12 -12
- package/dist/cli.js +36 -34
- package/dist/client.js +178 -69
- package/dist/core/game-settings.d.ts +5 -3
- package/dist/core/session-roster.d.ts +10 -0
- package/dist/dev/console/assets/{index-CuMOOH9m.js → index-CnXlPeLX.js} +47 -47
- package/dist/dev/console/index.html +1 -1
- package/dist/dev/routes.d.ts +5 -2
- package/dist/dev/shell.d.ts +9 -1
- package/dist/dev/view/batch.d.ts +11 -1
- package/dist/dev/view/route.d.ts +18 -1
- package/dist/dev/view/view.d.ts +9 -0
- package/dist/docs/api/index.md +1 -1
- package/dist/docs/api/sdk-commands.md +4 -0
- package/dist/docs/api/sdk-e2e.md +5 -0
- package/dist/docs/api/sdk-tools-client.md +4 -0
- package/dist/docs/api/sdk-ui-testing.md +1 -0
- package/dist/docs/api/sdk-ui.md +28 -0
- package/dist/docs/api/sdk.md +2 -0
- package/dist/docs/changelog.md +11 -0
- package/dist/docs/cli-and-dev-server.md +4 -0
- package/dist/docs/cli-reference.md +17 -2
- package/dist/docs/guides/presentation.md +11 -10
- package/dist/docs/guides/session-hooks.md +16 -0
- package/dist/docs/guides/settings.md +4 -2
- package/dist/docs/guides/upgrading.md +12 -0
- package/dist/docs/page-index.md +5 -5
- package/dist/host/protocol.d.ts +10 -1
- package/dist/host.js +1 -0
- package/dist/playwright.js +178 -69
- package/dist/runtime/manifest-version.d.ts +1 -1
- package/dist/runtime.js +1 -1
- package/dist/schema.json +10 -1
- package/package.json +3 -3
package/dist/playwright.js
CHANGED
|
@@ -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, {
|
|
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
|
-
|
|
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 === "
|
|
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.
|
|
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.
|
|
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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seriousgaming/sdk-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "SDK tooling for building Serious Gaming games",
|
|
5
5
|
"homepage": "https://sdk.seriousgaming.com/",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@mui/icons-material": "^9.4.0",
|
|
75
75
|
"@mui/material": "^9.4.0",
|
|
76
76
|
"@playwright/test": "^1.64.0",
|
|
77
|
-
"@seriousgaming/sdk": "1.
|
|
77
|
+
"@seriousgaming/sdk": "1.7.0",
|
|
78
78
|
"@testing-library/jest-dom": "^7.0.1",
|
|
79
79
|
"@testing-library/react": "^16.3.3",
|
|
80
80
|
"@types/adm-zip": "^0.5.8",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
106
|
"@playwright/test": ">=1.50.0",
|
|
107
|
-
"@seriousgaming/sdk": "^1.
|
|
107
|
+
"@seriousgaming/sdk": "^1.7.0"
|
|
108
108
|
},
|
|
109
109
|
"peerDependenciesMeta": {
|
|
110
110
|
"@playwright/test": {
|