@seriousgaming/sdk-tools 1.2.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.
- package/dist/cli.js +366 -296
- package/dist/client.js +458 -388
- package/dist/core/participant-registry.d.ts +6 -0
- package/dist/core/session-roster.d.ts +4 -1
- package/dist/dev/console/assets/{index-BNLEVOQA.js → index-DEV8N0na.js} +47 -47
- package/dist/dev/console/index.html +1 -1
- package/dist/dev/view/batch.d.ts +17 -9
- package/dist/dev/view/view.d.ts +2 -1
- package/dist/docs/api/index.md +1 -1
- package/dist/docs/api/sdk-commands.md +4 -0
- package/dist/docs/api/sdk-e2e.md +4 -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 +33 -1
- package/dist/docs/api/sdk.md +3 -1
- package/dist/docs/changelog.md +16 -0
- package/dist/docs/guides/presentation.md +23 -9
- package/dist/docs/guides/session.md +47 -8
- package/dist/docs/guides/testing.md +9 -0
- package/dist/docs/guides/ui.md +33 -0
- package/dist/docs/guides/upgrading.md +11 -0
- package/dist/docs/guides/waiting-room.md +2 -0
- package/dist/host/protocol.d.ts +27 -2
- package/dist/runtime/manifest-version.d.ts +1 -1
- package/dist/runtime.js +4 -2
- package/package.json +3 -3
package/dist/client.js
CHANGED
|
@@ -259,6 +259,7 @@ var COMMAND_FIELDS = {
|
|
|
259
259
|
removeTeam: { teamIndex: "number" },
|
|
260
260
|
renameTeam: { teamId: "string", name: "string" },
|
|
261
261
|
renameOwnTeam: { name: "string", "participantId?": "string", "teamId?": "string" },
|
|
262
|
+
renameSelf: { name: "string", "participantId?": "string", "teamId?": "string" },
|
|
262
263
|
addParticipant: { teamId: "string", "name?": "string" },
|
|
263
264
|
renameParticipant: { participantId: "string", name: "string" },
|
|
264
265
|
moveParticipant: { participantId: "string", teamId: "string" },
|
|
@@ -2700,7 +2701,9 @@ function gameOverrideRefusal(overrides) {
|
|
|
2700
2701
|
// cli/runtime/manifest-version.ts
|
|
2701
2702
|
var SUPPORTED_FEATURES = [
|
|
2702
2703
|
// A validator's `Scenario` gate (§15.8).
|
|
2703
|
-
"scenario-validation"
|
|
2704
|
+
"scenario-validation",
|
|
2705
|
+
// The presentation as a host overlay a session surface may open (§6.4).
|
|
2706
|
+
"presentation-overlay"
|
|
2704
2707
|
];
|
|
2705
2708
|
function unsupportedFeatures(manifest) {
|
|
2706
2709
|
return (manifest.requires ?? []).filter((feature) => !SUPPORTED_FEATURES.includes(feature));
|
|
@@ -22394,6 +22397,7 @@ function swallow() {
|
|
|
22394
22397
|
|
|
22395
22398
|
// cli/core/participant-registry.ts
|
|
22396
22399
|
import { EventEmitter } from "events";
|
|
22400
|
+
var MAX_PARTICIPANT_NAME_LENGTH = 60;
|
|
22397
22401
|
var ParticipantRegistry = class extends EventEmitter {
|
|
22398
22402
|
teams = /* @__PURE__ */ new Map();
|
|
22399
22403
|
/**
|
|
@@ -23663,6 +23667,16 @@ var SessionRoster = class {
|
|
|
23663
23667
|
if (!teamId) throw new DeniedError("The caller is not on a team");
|
|
23664
23668
|
return this.renameTeam(teamId, command.name);
|
|
23665
23669
|
}
|
|
23670
|
+
renameSelf(command) {
|
|
23671
|
+
if (!command.participantId)
|
|
23672
|
+
throw new DeniedError("Only a participant can rename themselves");
|
|
23673
|
+
const trimmed = command.name.trim();
|
|
23674
|
+
if (!trimmed) throw new DeniedError("A name cannot be blank");
|
|
23675
|
+
if (trimmed.length > MAX_PARTICIPANT_NAME_LENGTH) {
|
|
23676
|
+
throw new DeniedError(`A name is at most ${MAX_PARTICIPANT_NAME_LENGTH} characters`);
|
|
23677
|
+
}
|
|
23678
|
+
return this.renameParticipant(command.participantId, trimmed);
|
|
23679
|
+
}
|
|
23666
23680
|
async addParticipant(teamId, name) {
|
|
23667
23681
|
if (!this.host.state.getTeamIndexes().some((i) => `team-${i + 1}` === teamId)) {
|
|
23668
23682
|
throw new DeniedError(`Unknown team "${teamId}"`);
|
|
@@ -25090,6 +25104,7 @@ var PLAY_STAGE = /* @__PURE__ */ new Set([
|
|
|
25090
25104
|
"renameParticipant",
|
|
25091
25105
|
"moveParticipant",
|
|
25092
25106
|
"renameOwnTeam",
|
|
25107
|
+
"renameSelf",
|
|
25093
25108
|
"extendTick"
|
|
25094
25109
|
]);
|
|
25095
25110
|
var STALE_BLOCKED = /* @__PURE__ */ new Set([
|
|
@@ -25744,6 +25759,8 @@ var Session = class {
|
|
|
25744
25759
|
return this.roster.renameTeam(command.teamId, command.name);
|
|
25745
25760
|
case "renameOwnTeam":
|
|
25746
25761
|
return this.roster.renameOwnTeam(command);
|
|
25762
|
+
case "renameSelf":
|
|
25763
|
+
return this.roster.renameSelf(command);
|
|
25747
25764
|
case "addParticipant":
|
|
25748
25765
|
return this.roster.addParticipant(command.teamId, command.name);
|
|
25749
25766
|
case "renameParticipant":
|
|
@@ -25916,6 +25933,12 @@ var Session = class {
|
|
|
25916
25933
|
await deleteBlobs(this.options.packagePath, retentions);
|
|
25917
25934
|
}
|
|
25918
25935
|
setLocale(locale) {
|
|
25936
|
+
const supported = this.packageConfiguration()?.game?.definition.supportedLocales;
|
|
25937
|
+
if (supported?.length && !supported.includes(locale)) {
|
|
25938
|
+
throw new DeniedError(
|
|
25939
|
+
`"${locale}" is not one of this game's locales (${supported.join(", ")})`
|
|
25940
|
+
);
|
|
25941
|
+
}
|
|
25919
25942
|
this.locale = locale;
|
|
25920
25943
|
this.executor.setLocale(locale);
|
|
25921
25944
|
return void 0;
|
|
@@ -29666,102 +29689,415 @@ function mountableSurfaces(config) {
|
|
|
29666
29689
|
].filter((surface) => surface !== null);
|
|
29667
29690
|
}
|
|
29668
29691
|
|
|
29669
|
-
// cli/dev/
|
|
29670
|
-
function
|
|
29671
|
-
|
|
29692
|
+
// cli/dev/view/batch.ts
|
|
29693
|
+
function projectContext2(context, surface) {
|
|
29694
|
+
const declared = /* @__PURE__ */ new Set([...surface.reads, ...surface.writes]);
|
|
29695
|
+
const projected = {};
|
|
29696
|
+
for (const [capability, values] of Object.entries(context)) {
|
|
29697
|
+
if (declared.has(capability)) projected[capability] = values;
|
|
29698
|
+
}
|
|
29699
|
+
return projected;
|
|
29672
29700
|
}
|
|
29673
|
-
function
|
|
29674
|
-
const
|
|
29675
|
-
|
|
29676
|
-
|
|
29677
|
-
|
|
29678
|
-
|
|
29679
|
-
|
|
29680
|
-
|
|
29681
|
-
|
|
29682
|
-
|
|
29683
|
-
|
|
29684
|
-
|
|
29685
|
-
|
|
29686
|
-
|
|
29687
|
-
|
|
29688
|
-
|
|
29689
|
-
|
|
29690
|
-
|
|
29691
|
-
|
|
29692
|
-
|
|
29693
|
-
|
|
29694
|
-
|
|
29695
|
-
|
|
29696
|
-
|
|
29697
|
-
|
|
29698
|
-
|
|
29699
|
-
|
|
29700
|
-
|
|
29701
|
-
|
|
29702
|
-
|
|
29703
|
-
|
|
29704
|
-
|
|
29705
|
-
|
|
29706
|
-
|
|
29707
|
-
|
|
29708
|
-
|
|
29709
|
-
|
|
29710
|
-
|
|
29711
|
-
|
|
29712
|
-
|
|
29713
|
-
|
|
29714
|
-
|
|
29715
|
-
|
|
29716
|
-
|
|
29717
|
-
|
|
29718
|
-
|
|
29719
|
-
|
|
29720
|
-
|
|
29721
|
-
|
|
29722
|
-
|
|
29723
|
-
|
|
29724
|
-
|
|
29725
|
-
|
|
29726
|
-
|
|
29727
|
-
|
|
29728
|
-
|
|
29729
|
-
|
|
29730
|
-
|
|
29731
|
-
|
|
29732
|
-
|
|
29733
|
-
|
|
29734
|
-
|
|
29735
|
-
|
|
29736
|
-
|
|
29737
|
-
|
|
29738
|
-
|
|
29739
|
-
|
|
29740
|
-
|
|
29701
|
+
function settingsFor(state2, surface, { withoutSession = false } = {}) {
|
|
29702
|
+
const settings = withoutSession ? state2.settingsWithoutSession : state2.settings;
|
|
29703
|
+
return Object.fromEntries(
|
|
29704
|
+
surface.settings.filter((identifier) => identifier in settings).map((identifier) => [identifier, settings[identifier]])
|
|
29705
|
+
);
|
|
29706
|
+
}
|
|
29707
|
+
function draftSettingsFor(state2, surface, viewer) {
|
|
29708
|
+
const scenarioId = viewer.scenario ?? null;
|
|
29709
|
+
const draft = state2.scenarioDrafts?.find((entry) => entry.scenarioId === scenarioId);
|
|
29710
|
+
const settings = draft?.settings ?? {};
|
|
29711
|
+
return Object.fromEntries(
|
|
29712
|
+
surface.settings.filter((identifier) => identifier in settings).map((identifier) => [identifier, settings[identifier]])
|
|
29713
|
+
);
|
|
29714
|
+
}
|
|
29715
|
+
function sessionKeyFor(state2, surface, { sessionless = false } = {}) {
|
|
29716
|
+
const outside = surface.kind === "scenario-editor" || surface.kind === "presentation" && sessionless;
|
|
29717
|
+
return outside ? `outside-session:${state2.game.identifier}` : state2.session.sessionKey;
|
|
29718
|
+
}
|
|
29719
|
+
function themeMessages(theme) {
|
|
29720
|
+
return [
|
|
29721
|
+
{ type: "setTheme", payload: theme.palette },
|
|
29722
|
+
{ type: "themePreferenceChanged", preference: theme.preference }
|
|
29723
|
+
];
|
|
29724
|
+
}
|
|
29725
|
+
function assetUrls(assetOrigin) {
|
|
29726
|
+
return {
|
|
29727
|
+
blobPrefix: `${assetOrigin}/assets/blobs/`,
|
|
29728
|
+
scenarioAssetPrefix: `${assetOrigin}/assets/scenario/`,
|
|
29729
|
+
sharedAssetPrefix: `${assetOrigin}/assets/shared/`,
|
|
29730
|
+
assetAuthRedeemUrl: `${assetOrigin}/assets/auth/redeem`
|
|
29731
|
+
};
|
|
29732
|
+
}
|
|
29733
|
+
function teamOf(state2, teamIndex) {
|
|
29734
|
+
if (teamIndex === void 0) return state2.teams[0];
|
|
29735
|
+
return state2.teams.find((team) => team.index === teamIndex);
|
|
29736
|
+
}
|
|
29737
|
+
function teamList(state2) {
|
|
29738
|
+
return [...state2.teams].sort((a, b) => a.index - b.index).map((team) => ({ teamId: team.teamId, index: team.index, name: team.name }));
|
|
29739
|
+
}
|
|
29740
|
+
var IDLE_TIMER2 = {
|
|
29741
|
+
enabled: false,
|
|
29742
|
+
paused: false,
|
|
29743
|
+
nextTickAt: null,
|
|
29744
|
+
intervalMs: null,
|
|
29745
|
+
pausedAt: null,
|
|
29746
|
+
pausedMs: 0,
|
|
29747
|
+
extendedMs: 0,
|
|
29748
|
+
scheduleStartedAt: null
|
|
29749
|
+
};
|
|
29750
|
+
function buildBatch(options) {
|
|
29751
|
+
const { surface, state: state2, theme, origin, assetOrigin } = options;
|
|
29752
|
+
const common = [
|
|
29753
|
+
{ type: "setLocale", payload: { locale: state2.session.locale } },
|
|
29754
|
+
{ type: "setAssetUrls", payload: assetUrls(assetOrigin ?? origin) },
|
|
29755
|
+
...theme ? themeMessages(theme) : []
|
|
29756
|
+
];
|
|
29757
|
+
switch (surface.kind) {
|
|
29758
|
+
case "game":
|
|
29759
|
+
case "waiting-room":
|
|
29760
|
+
return [...playerBatch(options), ...common];
|
|
29761
|
+
case "session":
|
|
29762
|
+
return [...sessionBatch(options), ...common];
|
|
29763
|
+
// The two settings editors are sent the same batch (§12.3): neither is
|
|
29764
|
+
// told which slot it fills, since each is its own bundle.
|
|
29765
|
+
case "setup":
|
|
29766
|
+
return [{ type: "setSettings", payload: settingsFor(state2, surface) }, ...common];
|
|
29767
|
+
case "scenario-editor":
|
|
29768
|
+
return [
|
|
29769
|
+
{ type: "setSettings", payload: draftSettingsFor(state2, surface, options.viewer) },
|
|
29770
|
+
...common
|
|
29771
|
+
];
|
|
29772
|
+
case "presentation":
|
|
29773
|
+
return [...presentationBatch(options), ...common];
|
|
29774
|
+
}
|
|
29775
|
+
return common;
|
|
29776
|
+
}
|
|
29777
|
+
function crossTeamData(state2, surface, ownTeamIndex) {
|
|
29778
|
+
const across = new Set(surface.crossTeamReads);
|
|
29779
|
+
return [...state2.teams].sort((a, b) => a.index - b.index).map((team) => ({
|
|
29780
|
+
teamId: team.teamId,
|
|
29781
|
+
index: team.index,
|
|
29782
|
+
name: team.name,
|
|
29783
|
+
context: team.index === ownTeamIndex ? projectContext2(team.context, surface) : Object.fromEntries(
|
|
29784
|
+
Object.entries(team.context).filter(
|
|
29785
|
+
([capability]) => across.has(capability)
|
|
29786
|
+
)
|
|
29787
|
+
)
|
|
29788
|
+
}));
|
|
29789
|
+
}
|
|
29790
|
+
function joinUrl(origin, teamIndex) {
|
|
29791
|
+
return `${origin}/team/${teamIndex + 1}/join?bare`;
|
|
29792
|
+
}
|
|
29793
|
+
function playerBatch({
|
|
29794
|
+
surface,
|
|
29795
|
+
state: state2,
|
|
29796
|
+
viewer,
|
|
29797
|
+
origin,
|
|
29798
|
+
roundProcessing
|
|
29799
|
+
}) {
|
|
29800
|
+
const team = teamOf(state2, viewer.teamIndex);
|
|
29801
|
+
const participant = viewer.observer ? void 0 : team?.participants.find((p) => p.id === viewer.participantId) ?? team?.participants[0];
|
|
29802
|
+
const messages2 = [
|
|
29803
|
+
{
|
|
29804
|
+
type: "stateChanged",
|
|
29805
|
+
payload: projectContext2(team?.context ?? {}, surface),
|
|
29806
|
+
// §12.5: the head tick, so a review scrubber can be bounded and a
|
|
29807
|
+
// cache invalidated on undo.
|
|
29808
|
+
completedTicks: team?.completedTicks ?? state2.session.completedTicks
|
|
29809
|
+
},
|
|
29810
|
+
{ type: "setSettings", payload: settingsFor(state2, surface) }
|
|
29811
|
+
];
|
|
29812
|
+
if (participant) {
|
|
29813
|
+
messages2.push({
|
|
29814
|
+
type: "setParticipant",
|
|
29815
|
+
payload: {
|
|
29816
|
+
id: participant.id,
|
|
29817
|
+
name: participant.name,
|
|
29818
|
+
index: participant.index,
|
|
29819
|
+
teamId: team?.teamId ?? "team-1"
|
|
29820
|
+
},
|
|
29821
|
+
// There are no accounts here, so every name is the participant's
|
|
29822
|
+
// own to change (§12.5).
|
|
29823
|
+
canRenameSelf: true
|
|
29741
29824
|
});
|
|
29742
|
-
}
|
|
29743
|
-
|
|
29744
|
-
|
|
29745
|
-
|
|
29746
|
-
|
|
29747
|
-
|
|
29748
|
-
|
|
29749
|
-
|
|
29750
|
-
|
|
29751
|
-
|
|
29752
|
-
|
|
29825
|
+
}
|
|
29826
|
+
messages2.push(
|
|
29827
|
+
{ type: "setViewerRole", role: viewer.observer ? "observer" : "participant" },
|
|
29828
|
+
{ type: "setRunKind", runKind: state2.session.runKind },
|
|
29829
|
+
{ type: "setScenarioName", scenarioName: state2.game.scenarioName },
|
|
29830
|
+
{
|
|
29831
|
+
type: "setOwnTeam",
|
|
29832
|
+
payload: team ? { teamId: team.teamId, index: team.index, name: team.name } : { teamId: "team-1", index: 0, name: "Team 1" }
|
|
29833
|
+
},
|
|
29834
|
+
{
|
|
29835
|
+
type: "setOwnTeamJoinLink",
|
|
29836
|
+
payload: team ? { joinUrl: joinUrl(origin, team.index) } : (
|
|
29837
|
+
// §12.3, as amended: a host with nothing to offer says so
|
|
29838
|
+
// rather than staying silent, so a surface rendering a join
|
|
29839
|
+
// panel shows nothing instead of waiting for a message that
|
|
29840
|
+
// never comes.
|
|
29841
|
+
null
|
|
29842
|
+
)
|
|
29843
|
+
},
|
|
29844
|
+
{ type: "setParticipantList", participants: team?.participants ?? [] },
|
|
29845
|
+
{ type: "setTeamList", payload: teamList(state2) },
|
|
29846
|
+
{ type: "setTimer", payload: team?.timer ?? IDLE_TIMER2 }
|
|
29847
|
+
);
|
|
29848
|
+
if (surface.kind === "game") {
|
|
29849
|
+
messages2.push({ type: "setRoundProcessing", processing: roundProcessing === true });
|
|
29850
|
+
}
|
|
29851
|
+
if ((surface.kind === "game" || surface.kind === "waiting-room") && surface.crossTeamReads.length > 0 && state2.session.mode === "shared-state") {
|
|
29852
|
+
messages2.push({
|
|
29853
|
+
type: "setCrossTeamData",
|
|
29854
|
+
payload: crossTeamData(state2, surface, team?.index)
|
|
29753
29855
|
});
|
|
29754
|
-
}
|
|
29755
|
-
|
|
29756
|
-
|
|
29757
|
-
|
|
29758
|
-
|
|
29759
|
-
|
|
29760
|
-
|
|
29761
|
-
|
|
29762
|
-
|
|
29763
|
-
|
|
29764
|
-
|
|
29856
|
+
}
|
|
29857
|
+
return messages2;
|
|
29858
|
+
}
|
|
29859
|
+
function sessionBatch({
|
|
29860
|
+
surface,
|
|
29861
|
+
state: state2,
|
|
29862
|
+
gameName,
|
|
29863
|
+
origin,
|
|
29864
|
+
overlays
|
|
29865
|
+
}) {
|
|
29866
|
+
return [
|
|
29867
|
+
{
|
|
29868
|
+
type: "setSessionMeta",
|
|
29869
|
+
payload: {
|
|
29870
|
+
sessionId: "dev-session",
|
|
29871
|
+
name: gameName,
|
|
29872
|
+
readOnly: false,
|
|
29873
|
+
waitingRoomOpen: state2.session.waitingRoomOpen,
|
|
29874
|
+
joinPin: null,
|
|
29875
|
+
canSetLocale: true
|
|
29876
|
+
}
|
|
29877
|
+
},
|
|
29878
|
+
{ type: "setSessionData", payload: sessionData(state2, surface) },
|
|
29879
|
+
{ type: "setSettings", payload: settingsFor(state2, surface) },
|
|
29880
|
+
{ type: "setTeamConfiguration", payload: teamConfiguration(state2) },
|
|
29881
|
+
{ type: "setTeamList", payload: teamList(state2) },
|
|
29882
|
+
{
|
|
29883
|
+
type: "setParticipantList",
|
|
29884
|
+
participants: participantList(state2)
|
|
29885
|
+
},
|
|
29886
|
+
{ type: "setTeamLinks", payload: teamLinks(state2, origin) },
|
|
29887
|
+
{ type: "setWalkthroughLink", payload: walkthroughLink(origin) },
|
|
29888
|
+
{ type: "setRunKind", runKind: state2.session.runKind },
|
|
29889
|
+
{ type: "setScenarioName", scenarioName: state2.game.scenarioName },
|
|
29890
|
+
{ type: "setAvailableOverlays", overlays: overlays ?? availableOverlays() }
|
|
29891
|
+
];
|
|
29892
|
+
}
|
|
29893
|
+
function presentationBatch({
|
|
29894
|
+
surface,
|
|
29895
|
+
state: state2,
|
|
29896
|
+
gameName,
|
|
29897
|
+
origin,
|
|
29898
|
+
sessionless
|
|
29899
|
+
}) {
|
|
29900
|
+
return [
|
|
29901
|
+
{
|
|
29902
|
+
type: "setPresentation",
|
|
29903
|
+
payload: {
|
|
29904
|
+
game: {
|
|
29905
|
+
name: state2.game.name,
|
|
29906
|
+
// Without a session, as the scenario resolves it alone (§6.15.1).
|
|
29907
|
+
maxTicks: sessionless ? gameSettingsOf(state2.settingsWithoutSession).maxTicks : state2.session.maxTicks,
|
|
29908
|
+
mode: state2.session.mode,
|
|
29909
|
+
scenarioName: state2.game.scenarioName
|
|
29910
|
+
},
|
|
29911
|
+
session: sessionless ? null : {
|
|
29912
|
+
// The dev server runs one session; its id is the
|
|
29913
|
+
// one the session surface is told (above).
|
|
29914
|
+
id: "dev-session",
|
|
29915
|
+
name: gameName,
|
|
29916
|
+
completedTicks: Math.max(
|
|
29917
|
+
state2.session.completedTicks,
|
|
29918
|
+
...state2.teams.map((team) => team.completedTicks)
|
|
29919
|
+
),
|
|
29920
|
+
data: sessionData(state2, surface),
|
|
29921
|
+
teams: teamList(state2),
|
|
29922
|
+
participants: participantList(state2),
|
|
29923
|
+
// A deck puts these on the projector, so no observe
|
|
29924
|
+
// URL: watching a team is the facilitator's tool.
|
|
29925
|
+
joinLinks: teamLinks(state2, origin).map(({ teamId, joinUrl: joinUrl2 }) => ({
|
|
29926
|
+
teamId,
|
|
29927
|
+
joinUrl: joinUrl2
|
|
29928
|
+
})),
|
|
29929
|
+
joinPin: null
|
|
29930
|
+
}
|
|
29931
|
+
}
|
|
29932
|
+
},
|
|
29933
|
+
{
|
|
29934
|
+
type: "setSettings",
|
|
29935
|
+
payload: settingsFor(state2, surface, { withoutSession: sessionless })
|
|
29936
|
+
}
|
|
29937
|
+
];
|
|
29938
|
+
}
|
|
29939
|
+
function walkthroughLink(origin) {
|
|
29940
|
+
return { url: `${origin}/walkthrough` };
|
|
29941
|
+
}
|
|
29942
|
+
function availableOverlays(offered = {}) {
|
|
29943
|
+
return [
|
|
29944
|
+
...offered.guide ? ["facilitator-guide"] : [],
|
|
29945
|
+
"print-sheets",
|
|
29946
|
+
...offered.presentation ? ["presentation"] : []
|
|
29947
|
+
];
|
|
29948
|
+
}
|
|
29949
|
+
function offersPresentationOverlay(config) {
|
|
29950
|
+
return config?.presentation !== void 0 && (config.requires ?? []).includes(PRESENTATION_OVERLAY);
|
|
29951
|
+
}
|
|
29952
|
+
var PRESENTATION_OVERLAY = "presentation-overlay";
|
|
29953
|
+
function participantList(state2) {
|
|
29954
|
+
return state2.teams.flatMap(
|
|
29955
|
+
(team) => team.participants.map((participant) => ({
|
|
29956
|
+
id: participant.id,
|
|
29957
|
+
name: participant.name,
|
|
29958
|
+
index: participant.index,
|
|
29959
|
+
connected: participant.connected,
|
|
29960
|
+
teamId: team.teamId
|
|
29961
|
+
}))
|
|
29962
|
+
);
|
|
29963
|
+
}
|
|
29964
|
+
function teamLinks(state2, origin) {
|
|
29965
|
+
return [...state2.teams].sort((a, b) => a.index - b.index).map((team) => ({
|
|
29966
|
+
teamId: team.teamId,
|
|
29967
|
+
joinUrl: joinUrl(origin, team.index),
|
|
29968
|
+
observeUrl: `${origin}/team/${team.index + 1}/observe`
|
|
29969
|
+
}));
|
|
29970
|
+
}
|
|
29971
|
+
function teamConfiguration(state2) {
|
|
29972
|
+
return {
|
|
29973
|
+
mode: state2.session.mode,
|
|
29974
|
+
...state2.session.teamBounds.min === void 0 ? {} : { min: state2.session.teamBounds.min },
|
|
29975
|
+
max: state2.session.teamBounds.max
|
|
29976
|
+
};
|
|
29977
|
+
}
|
|
29978
|
+
function sessionData(state2, surface) {
|
|
29979
|
+
const teams = {};
|
|
29980
|
+
for (const team of state2.teams) {
|
|
29981
|
+
const own5 = {};
|
|
29982
|
+
for (const [capability, values] of Object.entries(team.context)) {
|
|
29983
|
+
if (!(capability in state2.shared)) own5[capability] = values;
|
|
29984
|
+
}
|
|
29985
|
+
teams[team.teamId] = {
|
|
29986
|
+
context: projectContext2(own5, surface),
|
|
29987
|
+
completedTicks: team.completedTicks,
|
|
29988
|
+
timer: team.timer ?? IDLE_TIMER2,
|
|
29989
|
+
// Monotonic per delivery. One session, one host, so the tick is a
|
|
29990
|
+
// sufficient clock; the wrapper only compares it with itself.
|
|
29991
|
+
revision: team.completedTicks
|
|
29992
|
+
};
|
|
29993
|
+
}
|
|
29994
|
+
return {
|
|
29995
|
+
// The dev server only ever sends snapshots, so the revision is a
|
|
29996
|
+
// baseline the wrapper never compares a delta against.
|
|
29997
|
+
shared: {
|
|
29998
|
+
context: projectContext2(state2.shared, surface),
|
|
29999
|
+
revision: state2.session.completedTicks
|
|
30000
|
+
},
|
|
30001
|
+
teams
|
|
30002
|
+
};
|
|
30003
|
+
}
|
|
30004
|
+
|
|
30005
|
+
// cli/dev/routes.ts
|
|
30006
|
+
function runOf(req) {
|
|
30007
|
+
return req.query.run === "walkthrough" ? "walkthrough" : "session";
|
|
30008
|
+
}
|
|
30009
|
+
function registerRoutes(app, deps) {
|
|
30010
|
+
const { session, packagePath, runFor } = deps;
|
|
30011
|
+
app.get("/api/state", async (req, res) => {
|
|
30012
|
+
res.json((await runFor(runOf(req))).project());
|
|
30013
|
+
});
|
|
30014
|
+
app.get("/api/surfaces", (req, res) => {
|
|
30015
|
+
const origin = deps.assetOrigin(req.headers.host);
|
|
30016
|
+
res.json(
|
|
30017
|
+
mountableSurfaces(session.packageConfiguration()).map((mountable) => ({
|
|
30018
|
+
...mountable,
|
|
30019
|
+
origin
|
|
30020
|
+
}))
|
|
30021
|
+
);
|
|
30022
|
+
});
|
|
30023
|
+
app.get("/api/session", async (req, res) => {
|
|
30024
|
+
const run = await runFor(runOf(req));
|
|
30025
|
+
res.json({
|
|
30026
|
+
instanceId: deps.instanceId,
|
|
30027
|
+
inSetup: run.inSetup,
|
|
30028
|
+
diagnostics: run.diagnostics(),
|
|
30029
|
+
sessionOverrides: run.sessionOverrides(),
|
|
30030
|
+
pending: run.pendingChanges(),
|
|
30031
|
+
warnings: deps.notices(run)
|
|
30032
|
+
});
|
|
30033
|
+
});
|
|
30034
|
+
app.post("/api/command", express.json({ limit: "20mb" }), async (req, res) => {
|
|
30035
|
+
const invalid2 = commandError(req.body);
|
|
30036
|
+
if (invalid2) {
|
|
30037
|
+
res.status(400).json({ error: invalid2 });
|
|
30038
|
+
return;
|
|
30039
|
+
}
|
|
30040
|
+
const command = req.body;
|
|
30041
|
+
try {
|
|
30042
|
+
if (rebuildsWalkthrough(command, runOf(req))) {
|
|
30043
|
+
res.json(await deps.settleWalkthroughReset(command));
|
|
30044
|
+
return;
|
|
30045
|
+
}
|
|
30046
|
+
const run = await runFor(runOf(req));
|
|
30047
|
+
const result = isQuery(command) ? await run.query(command) : await run.submit(command);
|
|
30048
|
+
if (command.type === "callEndpoint" && command.external && "type" in result && result.type === "endpoint") {
|
|
30049
|
+
const blobs = blobLinks(
|
|
30050
|
+
result.response,
|
|
30051
|
+
(blobId) => `${req.protocol}://${req.get("host")}/api/blobs/${encodeURIComponent(blobId)}`
|
|
30052
|
+
);
|
|
30053
|
+
res.json(Object.keys(blobs).length > 0 ? { ...result, blobs } : result);
|
|
30054
|
+
return;
|
|
30055
|
+
}
|
|
30056
|
+
res.json(result);
|
|
30057
|
+
} catch (error) {
|
|
30058
|
+
res.status(500).json({ error: errorMessage(error, "Command failed") });
|
|
30059
|
+
}
|
|
30060
|
+
});
|
|
30061
|
+
app.post("/api/walkthrough/reset", async (_req, res) => {
|
|
30062
|
+
try {
|
|
30063
|
+
res.json((await deps.resetWalkthrough()).project());
|
|
30064
|
+
} catch (error) {
|
|
30065
|
+
res.status(500).json({ error: errorMessage(error, "Walkthrough reset failed") });
|
|
30066
|
+
}
|
|
30067
|
+
});
|
|
30068
|
+
app.get("/api/scenarios", (_req, res) => {
|
|
30069
|
+
const config = session.packageConfiguration();
|
|
30070
|
+
res.json({
|
|
30071
|
+
activeScenarioId: session.activeScenario()?.definition.identifier ?? null,
|
|
30072
|
+
scenarios: (config?.scenarios ?? []).map((scenario) => ({
|
|
30073
|
+
id: scenario.definition.identifier,
|
|
30074
|
+
default: scenario.definition.default === true,
|
|
30075
|
+
locales: scenario.definition.locales ?? {}
|
|
30076
|
+
}))
|
|
30077
|
+
});
|
|
30078
|
+
});
|
|
30079
|
+
app.get("/api/brands", (req, res) => {
|
|
30080
|
+
const assetOrigin = deps.assetOrigin(req.headers.host);
|
|
30081
|
+
res.json({ brands: deps.brands().map((brand) => summarise(brand, assetOrigin)) });
|
|
30082
|
+
});
|
|
30083
|
+
app.get("/api/locales", (_req, res) => {
|
|
30084
|
+
const game = session.packageConfiguration()?.game;
|
|
30085
|
+
res.json({
|
|
30086
|
+
active: session.project().session.locale,
|
|
30087
|
+
supported: game?.definition.supportedLocales ?? ["en"],
|
|
30088
|
+
names: game?.definition.locales ?? {}
|
|
30089
|
+
});
|
|
30090
|
+
});
|
|
30091
|
+
app.post("/api/scenarios", express.json(), async (req, res) => {
|
|
30092
|
+
const body = req.body;
|
|
30093
|
+
if (typeof body?.identifier !== "string") {
|
|
30094
|
+
res.status(400).json({ error: "An identifier is required" });
|
|
30095
|
+
return;
|
|
30096
|
+
}
|
|
30097
|
+
try {
|
|
30098
|
+
const result = await saveSessionScenario(session, packagePath, {
|
|
30099
|
+
identifier: body.identifier,
|
|
30100
|
+
...typeof body.name === "string" ? { name: body.name } : {},
|
|
29765
30101
|
...body.overwrite === void 0 ? {} : { overwrite: body.overwrite },
|
|
29766
30102
|
...body.draft === true ? { draft: true } : {}
|
|
29767
30103
|
});
|
|
@@ -29829,6 +30165,14 @@ function registerRoutes(app, deps) {
|
|
|
29829
30165
|
app.get("/api/guide", (_req, res) => {
|
|
29830
30166
|
res.json({ guide: session.effectiveGuide() });
|
|
29831
30167
|
});
|
|
30168
|
+
app.get("/api/overlays", (_req, res) => {
|
|
30169
|
+
res.json({
|
|
30170
|
+
overlays: availableOverlays({
|
|
30171
|
+
guide: session.effectiveGuide() !== null,
|
|
30172
|
+
presentation: offersPresentationOverlay(session.packageConfiguration())
|
|
30173
|
+
})
|
|
30174
|
+
});
|
|
30175
|
+
});
|
|
29832
30176
|
app.get("/api/guide/content/:locale/:chapter", async (req, res) => {
|
|
29833
30177
|
const guide = session.guide();
|
|
29834
30178
|
if (!guide) {
|
|
@@ -29945,8 +30289,8 @@ function serveAsset(req, res, root2) {
|
|
|
29945
30289
|
|
|
29946
30290
|
// cli/dev/view/commands.ts
|
|
29947
30291
|
var FRAME_COMMANDS = {
|
|
29948
|
-
game: /* @__PURE__ */ new Set(["updateData", "requestTick", "renameOwnTeam"]),
|
|
29949
|
-
"waiting-room": /* @__PURE__ */ new Set(["updateData", "requestTick", "renameOwnTeam"]),
|
|
30292
|
+
game: /* @__PURE__ */ new Set(["updateData", "requestTick", "renameOwnTeam", "renameSelf"]),
|
|
30293
|
+
"waiting-room": /* @__PURE__ */ new Set(["updateData", "requestTick", "renameOwnTeam", "renameSelf"]),
|
|
29950
30294
|
session: /* @__PURE__ */ new Set([
|
|
29951
30295
|
"updateSessionData",
|
|
29952
30296
|
"updateSharedData",
|
|
@@ -29955,6 +30299,7 @@ var FRAME_COMMANDS = {
|
|
|
29955
30299
|
"resetGame",
|
|
29956
30300
|
"resetWalkthrough",
|
|
29957
30301
|
"setWaitingRoom",
|
|
30302
|
+
"setLocale",
|
|
29958
30303
|
"createTeam",
|
|
29959
30304
|
"renameTeam",
|
|
29960
30305
|
"renameParticipant",
|
|
@@ -29974,7 +30319,9 @@ var FRAME_COMMANDS = {
|
|
|
29974
30319
|
var NO_TEAM_ID = {
|
|
29975
30320
|
setWaitingRoom: "The waiting room is session-wide, so setWaitingRoom takes no teamId",
|
|
29976
30321
|
renameOwnTeam: "renameOwnTeam renames the caller's own team, which the host resolves; it takes no teamId",
|
|
29977
|
-
resetWalkthrough: "A walkthrough holds one team, so resetWalkthrough takes no teamId"
|
|
30322
|
+
resetWalkthrough: "A walkthrough holds one team, so resetWalkthrough takes no teamId",
|
|
30323
|
+
setLocale: "The locale is the session's, so setLocale takes no teamId",
|
|
30324
|
+
renameSelf: "renameSelf renames the caller, whom the host resolves; it takes no teamId"
|
|
29978
30325
|
};
|
|
29979
30326
|
var FRAME_QUERIES = {
|
|
29980
30327
|
game: /* @__PURE__ */ new Set(["callEndpoint", "getPastState", "getAllTeamsParticipants"]),
|
|
@@ -30014,6 +30361,11 @@ function commandFor(message, surface, viewer) {
|
|
|
30014
30361
|
if (message.teamId !== void 0 && message.type in NO_TEAM_ID) {
|
|
30015
30362
|
return { refused: NO_TEAM_ID[message.type] };
|
|
30016
30363
|
}
|
|
30364
|
+
if (message.type === "renameSelf" && message.participantId !== void 0) {
|
|
30365
|
+
return {
|
|
30366
|
+
refused: "renameSelf renames the caller, whom the host resolves; it takes no participantId"
|
|
30367
|
+
};
|
|
30368
|
+
}
|
|
30017
30369
|
const scope = teamScope(viewer);
|
|
30018
30370
|
const actor = actorOf(viewer);
|
|
30019
30371
|
const role = roleOf(viewer);
|
|
@@ -30072,6 +30424,8 @@ function commandFor(message, surface, viewer) {
|
|
|
30072
30424
|
};
|
|
30073
30425
|
case "setWaitingRoom":
|
|
30074
30426
|
return { type: "setWaitingRoom", open: message.open === true };
|
|
30427
|
+
case "setLocale":
|
|
30428
|
+
return { type: "setLocale", locale: String(message.locale) };
|
|
30075
30429
|
case "resetWalkthrough":
|
|
30076
30430
|
return { type: "resetWalkthrough" };
|
|
30077
30431
|
case "createTeam":
|
|
@@ -30087,6 +30441,8 @@ function commandFor(message, surface, viewer) {
|
|
|
30087
30441
|
};
|
|
30088
30442
|
case "renameOwnTeam":
|
|
30089
30443
|
return { type: "renameOwnTeam", name: String(message.name), ...actor };
|
|
30444
|
+
case "renameSelf":
|
|
30445
|
+
return { type: "renameSelf", name: String(message.name), ...actor };
|
|
30090
30446
|
case "renameParticipant":
|
|
30091
30447
|
return {
|
|
30092
30448
|
type: "renameParticipant",
|
|
@@ -30210,295 +30566,6 @@ function routeHref(route) {
|
|
|
30210
30566
|
return search2 ? `${path3}?${search2}` : path3;
|
|
30211
30567
|
}
|
|
30212
30568
|
|
|
30213
|
-
// cli/dev/view/batch.ts
|
|
30214
|
-
function projectContext2(context, surface) {
|
|
30215
|
-
const declared = /* @__PURE__ */ new Set([...surface.reads, ...surface.writes]);
|
|
30216
|
-
const projected = {};
|
|
30217
|
-
for (const [capability, values] of Object.entries(context)) {
|
|
30218
|
-
if (declared.has(capability)) projected[capability] = values;
|
|
30219
|
-
}
|
|
30220
|
-
return projected;
|
|
30221
|
-
}
|
|
30222
|
-
function settingsFor(state2, surface, { withoutSession = false } = {}) {
|
|
30223
|
-
const settings = withoutSession ? state2.settingsWithoutSession : state2.settings;
|
|
30224
|
-
return Object.fromEntries(
|
|
30225
|
-
surface.settings.filter((identifier) => identifier in settings).map((identifier) => [identifier, settings[identifier]])
|
|
30226
|
-
);
|
|
30227
|
-
}
|
|
30228
|
-
function draftSettingsFor(state2, surface, viewer) {
|
|
30229
|
-
const scenarioId = viewer.scenario ?? null;
|
|
30230
|
-
const draft = state2.scenarioDrafts?.find((entry) => entry.scenarioId === scenarioId);
|
|
30231
|
-
const settings = draft?.settings ?? {};
|
|
30232
|
-
return Object.fromEntries(
|
|
30233
|
-
surface.settings.filter((identifier) => identifier in settings).map((identifier) => [identifier, settings[identifier]])
|
|
30234
|
-
);
|
|
30235
|
-
}
|
|
30236
|
-
function sessionKeyFor(state2, surface, { sessionless = false } = {}) {
|
|
30237
|
-
const outside = surface.kind === "scenario-editor" || surface.kind === "presentation" && sessionless;
|
|
30238
|
-
return outside ? `outside-session:${state2.game.identifier}` : state2.session.sessionKey;
|
|
30239
|
-
}
|
|
30240
|
-
function themeMessages(theme) {
|
|
30241
|
-
return [
|
|
30242
|
-
{ type: "setTheme", payload: theme.palette },
|
|
30243
|
-
{ type: "themePreferenceChanged", preference: theme.preference }
|
|
30244
|
-
];
|
|
30245
|
-
}
|
|
30246
|
-
function assetUrls(assetOrigin) {
|
|
30247
|
-
return {
|
|
30248
|
-
blobPrefix: `${assetOrigin}/assets/blobs/`,
|
|
30249
|
-
scenarioAssetPrefix: `${assetOrigin}/assets/scenario/`,
|
|
30250
|
-
sharedAssetPrefix: `${assetOrigin}/assets/shared/`,
|
|
30251
|
-
assetAuthRedeemUrl: `${assetOrigin}/assets/auth/redeem`
|
|
30252
|
-
};
|
|
30253
|
-
}
|
|
30254
|
-
function teamOf(state2, teamIndex) {
|
|
30255
|
-
if (teamIndex === void 0) return state2.teams[0];
|
|
30256
|
-
return state2.teams.find((team) => team.index === teamIndex);
|
|
30257
|
-
}
|
|
30258
|
-
function teamList(state2) {
|
|
30259
|
-
return [...state2.teams].sort((a, b) => a.index - b.index).map((team) => ({ teamId: team.teamId, index: team.index, name: team.name }));
|
|
30260
|
-
}
|
|
30261
|
-
var IDLE_TIMER2 = {
|
|
30262
|
-
enabled: false,
|
|
30263
|
-
paused: false,
|
|
30264
|
-
nextTickAt: null,
|
|
30265
|
-
intervalMs: null,
|
|
30266
|
-
pausedAt: null,
|
|
30267
|
-
pausedMs: 0,
|
|
30268
|
-
extendedMs: 0,
|
|
30269
|
-
scheduleStartedAt: null
|
|
30270
|
-
};
|
|
30271
|
-
function buildBatch(options) {
|
|
30272
|
-
const { surface, state: state2, theme, origin, assetOrigin } = options;
|
|
30273
|
-
const common = [
|
|
30274
|
-
{ type: "setLocale", payload: { locale: state2.session.locale } },
|
|
30275
|
-
{ type: "setAssetUrls", payload: assetUrls(assetOrigin ?? origin) },
|
|
30276
|
-
...theme ? themeMessages(theme) : []
|
|
30277
|
-
];
|
|
30278
|
-
switch (surface.kind) {
|
|
30279
|
-
case "game":
|
|
30280
|
-
case "waiting-room":
|
|
30281
|
-
return [...playerBatch(options), ...common];
|
|
30282
|
-
case "session":
|
|
30283
|
-
return [...sessionBatch(options), ...common];
|
|
30284
|
-
// The two settings editors are sent the same batch (§12.3): neither is
|
|
30285
|
-
// told which slot it fills, since each is its own bundle.
|
|
30286
|
-
case "setup":
|
|
30287
|
-
return [{ type: "setSettings", payload: settingsFor(state2, surface) }, ...common];
|
|
30288
|
-
case "scenario-editor":
|
|
30289
|
-
return [
|
|
30290
|
-
{ type: "setSettings", payload: draftSettingsFor(state2, surface, options.viewer) },
|
|
30291
|
-
...common
|
|
30292
|
-
];
|
|
30293
|
-
case "presentation":
|
|
30294
|
-
return [...presentationBatch(options), ...common];
|
|
30295
|
-
}
|
|
30296
|
-
return common;
|
|
30297
|
-
}
|
|
30298
|
-
function crossTeamData(state2, surface, ownTeamIndex) {
|
|
30299
|
-
const across = new Set(surface.crossTeamReads);
|
|
30300
|
-
return [...state2.teams].sort((a, b) => a.index - b.index).map((team) => ({
|
|
30301
|
-
teamId: team.teamId,
|
|
30302
|
-
index: team.index,
|
|
30303
|
-
name: team.name,
|
|
30304
|
-
context: team.index === ownTeamIndex ? projectContext2(team.context, surface) : Object.fromEntries(
|
|
30305
|
-
Object.entries(team.context).filter(
|
|
30306
|
-
([capability]) => across.has(capability)
|
|
30307
|
-
)
|
|
30308
|
-
)
|
|
30309
|
-
}));
|
|
30310
|
-
}
|
|
30311
|
-
function joinUrl(origin, teamIndex) {
|
|
30312
|
-
return `${origin}/team/${teamIndex + 1}/join?bare`;
|
|
30313
|
-
}
|
|
30314
|
-
function playerBatch({
|
|
30315
|
-
surface,
|
|
30316
|
-
state: state2,
|
|
30317
|
-
viewer,
|
|
30318
|
-
origin,
|
|
30319
|
-
roundProcessing
|
|
30320
|
-
}) {
|
|
30321
|
-
const team = teamOf(state2, viewer.teamIndex);
|
|
30322
|
-
const participant = viewer.observer ? void 0 : team?.participants.find((p) => p.id === viewer.participantId) ?? team?.participants[0];
|
|
30323
|
-
const messages2 = [
|
|
30324
|
-
{
|
|
30325
|
-
type: "stateChanged",
|
|
30326
|
-
payload: projectContext2(team?.context ?? {}, surface),
|
|
30327
|
-
// §12.5: the head tick, so a review scrubber can be bounded and a
|
|
30328
|
-
// cache invalidated on undo.
|
|
30329
|
-
completedTicks: team?.completedTicks ?? state2.session.completedTicks
|
|
30330
|
-
},
|
|
30331
|
-
{ type: "setSettings", payload: settingsFor(state2, surface) }
|
|
30332
|
-
];
|
|
30333
|
-
if (participant) {
|
|
30334
|
-
messages2.push({
|
|
30335
|
-
type: "setParticipant",
|
|
30336
|
-
payload: {
|
|
30337
|
-
id: participant.id,
|
|
30338
|
-
name: participant.name,
|
|
30339
|
-
index: participant.index,
|
|
30340
|
-
teamId: team?.teamId ?? "team-1"
|
|
30341
|
-
}
|
|
30342
|
-
});
|
|
30343
|
-
}
|
|
30344
|
-
messages2.push(
|
|
30345
|
-
{ type: "setViewerRole", role: viewer.observer ? "observer" : "participant" },
|
|
30346
|
-
{ type: "setRunKind", runKind: state2.session.runKind },
|
|
30347
|
-
{ type: "setScenarioName", scenarioName: state2.game.scenarioName },
|
|
30348
|
-
{
|
|
30349
|
-
type: "setOwnTeam",
|
|
30350
|
-
payload: team ? { teamId: team.teamId, index: team.index, name: team.name } : { teamId: "team-1", index: 0, name: "Team 1" }
|
|
30351
|
-
},
|
|
30352
|
-
{
|
|
30353
|
-
type: "setOwnTeamJoinLink",
|
|
30354
|
-
payload: team ? { joinUrl: joinUrl(origin, team.index) } : (
|
|
30355
|
-
// §12.3, as amended: a host with nothing to offer says so
|
|
30356
|
-
// rather than staying silent, so a surface rendering a join
|
|
30357
|
-
// panel shows nothing instead of waiting for a message that
|
|
30358
|
-
// never comes.
|
|
30359
|
-
null
|
|
30360
|
-
)
|
|
30361
|
-
},
|
|
30362
|
-
{ type: "setParticipantList", participants: team?.participants ?? [] },
|
|
30363
|
-
{ type: "setTeamList", payload: teamList(state2) },
|
|
30364
|
-
{ type: "setTimer", payload: team?.timer ?? IDLE_TIMER2 }
|
|
30365
|
-
);
|
|
30366
|
-
if (surface.kind === "game") {
|
|
30367
|
-
messages2.push({ type: "setRoundProcessing", processing: roundProcessing === true });
|
|
30368
|
-
}
|
|
30369
|
-
if ((surface.kind === "game" || surface.kind === "waiting-room") && surface.crossTeamReads.length > 0 && state2.session.mode === "shared-state") {
|
|
30370
|
-
messages2.push({
|
|
30371
|
-
type: "setCrossTeamData",
|
|
30372
|
-
payload: crossTeamData(state2, surface, team?.index)
|
|
30373
|
-
});
|
|
30374
|
-
}
|
|
30375
|
-
return messages2;
|
|
30376
|
-
}
|
|
30377
|
-
function sessionBatch({
|
|
30378
|
-
surface,
|
|
30379
|
-
state: state2,
|
|
30380
|
-
gameName,
|
|
30381
|
-
origin,
|
|
30382
|
-
hasGuide
|
|
30383
|
-
}) {
|
|
30384
|
-
return [
|
|
30385
|
-
{
|
|
30386
|
-
type: "setSessionMeta",
|
|
30387
|
-
payload: {
|
|
30388
|
-
sessionId: "dev-session",
|
|
30389
|
-
name: gameName,
|
|
30390
|
-
readOnly: false,
|
|
30391
|
-
waitingRoomOpen: state2.session.waitingRoomOpen,
|
|
30392
|
-
joinPin: null
|
|
30393
|
-
}
|
|
30394
|
-
},
|
|
30395
|
-
{ type: "setSessionData", payload: sessionData(state2, surface) },
|
|
30396
|
-
{ type: "setSettings", payload: settingsFor(state2, surface) },
|
|
30397
|
-
{ type: "setTeamConfiguration", payload: teamConfiguration(state2) },
|
|
30398
|
-
{ type: "setTeamList", payload: teamList(state2) },
|
|
30399
|
-
{
|
|
30400
|
-
type: "setParticipantList",
|
|
30401
|
-
participants: state2.teams.flatMap(
|
|
30402
|
-
(team) => team.participants.map((participant) => ({
|
|
30403
|
-
id: participant.id,
|
|
30404
|
-
name: participant.name,
|
|
30405
|
-
index: participant.index,
|
|
30406
|
-
connected: participant.connected,
|
|
30407
|
-
teamId: team.teamId
|
|
30408
|
-
}))
|
|
30409
|
-
)
|
|
30410
|
-
},
|
|
30411
|
-
{ type: "setTeamLinks", payload: teamLinks(state2, origin) },
|
|
30412
|
-
{ type: "setWalkthroughLink", payload: walkthroughLink(origin) },
|
|
30413
|
-
{ type: "setRunKind", runKind: state2.session.runKind },
|
|
30414
|
-
{ type: "setScenarioName", scenarioName: state2.game.scenarioName },
|
|
30415
|
-
{ type: "setAvailableOverlays", overlays: availableOverlays(hasGuide) }
|
|
30416
|
-
];
|
|
30417
|
-
}
|
|
30418
|
-
function presentationBatch({
|
|
30419
|
-
surface,
|
|
30420
|
-
state: state2,
|
|
30421
|
-
gameName,
|
|
30422
|
-
sessionless
|
|
30423
|
-
}) {
|
|
30424
|
-
return [
|
|
30425
|
-
{
|
|
30426
|
-
type: "setPresentation",
|
|
30427
|
-
payload: {
|
|
30428
|
-
game: {
|
|
30429
|
-
name: state2.game.name,
|
|
30430
|
-
// Without a session, as the scenario resolves it alone (§6.15.1).
|
|
30431
|
-
maxTicks: sessionless ? gameSettingsOf(state2.settingsWithoutSession).maxTicks : state2.session.maxTicks,
|
|
30432
|
-
mode: state2.session.mode,
|
|
30433
|
-
scenarioName: state2.game.scenarioName
|
|
30434
|
-
},
|
|
30435
|
-
session: sessionless ? null : {
|
|
30436
|
-
// The dev server runs one session; its id is the
|
|
30437
|
-
// one the session surface is told (above).
|
|
30438
|
-
id: "dev-session",
|
|
30439
|
-
name: gameName,
|
|
30440
|
-
completedTicks: Math.max(
|
|
30441
|
-
state2.session.completedTicks,
|
|
30442
|
-
...state2.teams.map((team) => team.completedTicks)
|
|
30443
|
-
),
|
|
30444
|
-
data: sessionData(state2, surface),
|
|
30445
|
-
teams: teamList(state2)
|
|
30446
|
-
}
|
|
30447
|
-
}
|
|
30448
|
-
},
|
|
30449
|
-
{
|
|
30450
|
-
type: "setSettings",
|
|
30451
|
-
payload: settingsFor(state2, surface, { withoutSession: sessionless })
|
|
30452
|
-
}
|
|
30453
|
-
];
|
|
30454
|
-
}
|
|
30455
|
-
function walkthroughLink(origin) {
|
|
30456
|
-
return { url: `${origin}/walkthrough` };
|
|
30457
|
-
}
|
|
30458
|
-
function availableOverlays(hasGuide = false) {
|
|
30459
|
-
return hasGuide ? ["facilitator-guide", "print-sheets"] : ["print-sheets"];
|
|
30460
|
-
}
|
|
30461
|
-
function teamLinks(state2, origin) {
|
|
30462
|
-
return [...state2.teams].sort((a, b) => a.index - b.index).map((team) => ({
|
|
30463
|
-
teamId: team.teamId,
|
|
30464
|
-
joinUrl: joinUrl(origin, team.index),
|
|
30465
|
-
observeUrl: `${origin}/team/${team.index + 1}/observe`
|
|
30466
|
-
}));
|
|
30467
|
-
}
|
|
30468
|
-
function teamConfiguration(state2) {
|
|
30469
|
-
return {
|
|
30470
|
-
mode: state2.session.mode,
|
|
30471
|
-
...state2.session.teamBounds.min === void 0 ? {} : { min: state2.session.teamBounds.min },
|
|
30472
|
-
max: state2.session.teamBounds.max
|
|
30473
|
-
};
|
|
30474
|
-
}
|
|
30475
|
-
function sessionData(state2, surface) {
|
|
30476
|
-
const teams = {};
|
|
30477
|
-
for (const team of state2.teams) {
|
|
30478
|
-
const own5 = {};
|
|
30479
|
-
for (const [capability, values] of Object.entries(team.context)) {
|
|
30480
|
-
if (!(capability in state2.shared)) own5[capability] = values;
|
|
30481
|
-
}
|
|
30482
|
-
teams[team.teamId] = {
|
|
30483
|
-
context: projectContext2(own5, surface),
|
|
30484
|
-
completedTicks: team.completedTicks,
|
|
30485
|
-
timer: team.timer ?? IDLE_TIMER2,
|
|
30486
|
-
// Monotonic per delivery. One session, one host, so the tick is a
|
|
30487
|
-
// sufficient clock; the wrapper only compares it with itself.
|
|
30488
|
-
revision: team.completedTicks
|
|
30489
|
-
};
|
|
30490
|
-
}
|
|
30491
|
-
return {
|
|
30492
|
-
// The dev server only ever sends snapshots, so the revision is a
|
|
30493
|
-
// baseline the wrapper never compares a delta against.
|
|
30494
|
-
shared: {
|
|
30495
|
-
context: projectContext2(state2.shared, surface),
|
|
30496
|
-
revision: state2.session.completedTicks
|
|
30497
|
-
},
|
|
30498
|
-
teams
|
|
30499
|
-
};
|
|
30500
|
-
}
|
|
30501
|
-
|
|
30502
30569
|
// cli/dev/view/viewer.ts
|
|
30503
30570
|
function resolveViewer(state2, route) {
|
|
30504
30571
|
const base = {
|
|
@@ -30613,7 +30680,7 @@ function viewMessages(page, state2, options) {
|
|
|
30613
30680
|
origin: options.origin,
|
|
30614
30681
|
assetOrigin: options.assetOrigin,
|
|
30615
30682
|
gameName: options.gameName,
|
|
30616
|
-
|
|
30683
|
+
overlays: options.overlays,
|
|
30617
30684
|
roundProcessing: options.roundProcessing
|
|
30618
30685
|
});
|
|
30619
30686
|
}
|
|
@@ -31257,7 +31324,10 @@ Install the package's dependencies to serve its surfaces.
|
|
|
31257
31324
|
origin: this.consoleOrigin(view.host),
|
|
31258
31325
|
assetOrigin: origin,
|
|
31259
31326
|
gameName: state2.game.name,
|
|
31260
|
-
|
|
31327
|
+
overlays: availableOverlays({
|
|
31328
|
+
guide: session.effectiveGuide() !== null,
|
|
31329
|
+
presentation: offersPresentationOverlay(session.packageConfiguration())
|
|
31330
|
+
}),
|
|
31261
31331
|
roundProcessing
|
|
31262
31332
|
});
|
|
31263
31333
|
return { page, messages: messages2 };
|