@seriousgaming/sdk-tools 1.3.0 → 1.5.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 +4055 -2646
- package/dist/client.js +807 -172
- package/dist/core/session-host.d.ts +4 -2
- package/dist/core/settings-locks.d.ts +27 -2
- package/dist/dev/console/assets/{index-DEV8N0na.js → index-BVF8exas.js} +22 -22
- package/dist/dev/console/index.html +1 -1
- package/dist/dev/public-origins.d.ts +61 -0
- package/dist/dev/routes.d.ts +4 -0
- package/dist/dev/shell.d.ts +32 -4
- package/dist/dev/view/batch.d.ts +7 -1
- package/dist/docs/ai-agents.md +5 -0
- package/dist/docs/api/index.md +1 -1
- package/dist/docs/api/sdk-tools-client.md +1 -0
- package/dist/docs/api/sdk.md +79 -2
- package/dist/docs/changelog-0.x.md +2 -2
- package/dist/docs/changelog.md +62 -4
- package/dist/docs/cli-and-dev-server.md +58 -0
- package/dist/docs/cli-error-codes.md +39 -36
- package/dist/docs/cli-reference.md +68 -21
- package/dist/docs/concepts/terminology.md +1 -1
- package/dist/docs/environment-variables.md +10 -5
- package/dist/docs/guides/ai-facilitation.md +2 -0
- package/dist/docs/guides/capabilities.md +4 -0
- package/dist/docs/guides/designing-a-game.md +2 -0
- package/dist/docs/guides/designing-screens.md +133 -0
- package/dist/docs/guides/endpoints.md +4 -2
- package/dist/docs/guides/engine-testing.md +6 -2
- package/dist/docs/guides/engine.md +2 -0
- package/dist/docs/guides/file-handling.md +116 -22
- package/dist/docs/guides/games.md +3 -1
- package/dist/docs/guides/global-settings.md +2 -0
- package/dist/docs/guides/guide.md +2 -0
- package/dist/docs/guides/hooks.md +2 -0
- package/dist/docs/guides/index.md +9 -0
- package/dist/docs/guides/internationalization.md +2 -0
- package/dist/docs/guides/llm-integration.md +5 -3
- package/dist/docs/guides/multi-team-games.md +3 -1
- package/dist/docs/guides/patterns.md +2 -0
- package/dist/docs/guides/presentation.md +1 -1
- package/dist/docs/guides/production-constraints.md +2 -0
- package/dist/docs/guides/scenario-editor.md +3 -1
- package/dist/docs/guides/scenarios.md +15 -3
- package/dist/docs/guides/session-game-flow.md +365 -0
- package/dist/docs/guides/session-hooks.md +205 -0
- package/dist/docs/guides/session.md +27 -565
- package/dist/docs/guides/settings.md +64 -2
- package/dist/docs/guides/setup.md +3 -1
- package/dist/docs/guides/speech-generation.md +2 -0
- package/dist/docs/guides/starter-game.md +61 -21
- package/dist/docs/guides/testing.md +2 -0
- package/dist/docs/guides/tick-controller.md +3 -1
- package/dist/docs/guides/type-safety.md +2 -0
- package/dist/docs/guides/ui-files-and-llms.md +328 -0
- package/dist/docs/guides/ui-participants.md +281 -0
- package/dist/docs/guides/ui-styling.md +263 -0
- package/dist/docs/guides/ui-ticks.md +247 -0
- package/dist/docs/guides/ui.md +11 -1092
- package/dist/docs/guides/upgrading.md +2 -0
- package/dist/docs/guides/validators.md +64 -4
- package/dist/docs/guides/waiting-room.md +1 -1
- package/dist/docs/index.md +2 -1
- package/dist/docs/page-index.md +145 -0
- package/dist/docs/recipes/adapt-a-game-for-walkthroughs.md +1 -1
- package/dist/docs/recipes/adapt-ui-for-observers.md +1 -1
- package/dist/docs/recipes/create-presentation.md +11 -0
- package/dist/docs/recipes/create-scenario-editor.md +1 -0
- package/dist/docs/recipes/create-session-ui.md +2 -1
- package/dist/docs/recipes/create-setup.md +1 -0
- package/dist/docs/recipes/create-user-interface.md +1 -0
- package/dist/docs/recipes/create-waiting-room-ui.md +1 -0
- package/dist/docs/recipes/design-state-for-concurrent-writes.md +1 -1
- package/dist/docs/recipes/fix-duplicate-packages.md +2 -2
- package/dist/docs/recipes/index.md +3 -0
- package/dist/docs/recipes/screenshot-a-surface.md +80 -0
- package/dist/docs/recipes/test-a-multi-role-game.md +1 -1
- package/dist/docs/recipes/upload-and-display-files.md +7 -7
- package/dist/docs/recipes/use-request-tick.md +2 -2
- package/dist/docs/recipes/validate-scenarios.md +4 -1
- package/dist/execution/config-resolver.d.ts +4 -1
- package/dist/execution/endpoint-runner.d.ts +6 -0
- package/dist/execution/logic-calls.d.ts +7 -2
- package/dist/execution/scenario-gates.d.ts +21 -1
- package/dist/guide/settings.d.ts +1 -1
- package/dist/host.js +64 -2
- package/dist/runtime/manifest-version.d.ts +1 -1
- package/dist/runtime.js +7 -2
- package/dist/storage/asset-resolver.d.ts +24 -1
- package/dist/storage/blob-store.d.ts +7 -0
- package/dist/templates/package/CLAUDE.md.template +14 -5
- package/dist/templates/package/DESIGN.md.liquid +39 -7
- package/dist/templates/package/README.md.liquid +1 -1
- package/dist/templates/package/claude/rules/workflow-create-user-interface.md +1 -1
- package/dist/templates/package/pnpm-workspace.yaml.template +13 -0
- package/dist/templates/starter-game/capabilities/pacing/capability.sdk.json +18 -0
- package/dist/templates/starter-game/package.json +2 -0
- package/dist/templates/starter-game/presentation/defaults.ts +52 -0
- package/dist/templates/starter-game/presentation/index.html +20 -0
- package/dist/templates/starter-game/presentation/presentation.sdk.json +10 -0
- package/dist/templates/starter-game/presentation/src/App.tsx +55 -0
- package/dist/templates/starter-game/presentation/src/Band.tsx +40 -0
- package/dist/templates/starter-game/presentation/src/Slides.tsx +415 -0
- package/dist/templates/starter-game/presentation/src/WeatherIcon.tsx +21 -0
- package/dist/templates/starter-game/presentation/src/i18n.ts +88 -0
- package/dist/templates/starter-game/presentation/src/main.tsx +15 -0
- package/dist/templates/starter-game/presentation/src/stalls.test.ts +196 -0
- package/dist/templates/starter-game/presentation/src/stalls.ts +199 -0
- package/dist/templates/starter-game/presentation/types.ts +94 -0
- package/dist/templates/starter-game/seriousgaming.sdk.json +2 -1
- package/dist/templates/starter-game/session/defaults.ts +6 -0
- package/dist/templates/starter-game/session/index.html +1 -1
- package/dist/templates/starter-game/session/session.sdk.json +2 -2
- package/dist/templates/starter-game/session/src/App.test.tsx +436 -115
- package/dist/templates/starter-game/session/src/App.tsx +372 -222
- package/dist/templates/starter-game/session/src/JoinCodes.tsx +184 -0
- package/dist/templates/starter-game/session/src/ManagePanel.tsx +188 -0
- package/dist/templates/starter-game/session/src/Results.tsx +340 -0
- package/dist/templates/starter-game/session/src/SessionBar.tsx +179 -0
- package/dist/templates/starter-game/session/src/SessionPanels.tsx +105 -0
- package/dist/templates/starter-game/session/src/SidePanel.tsx +89 -0
- package/dist/templates/starter-game/session/src/StallCard.tsx +253 -0
- package/dist/templates/starter-game/session/src/TopBar.tsx +36 -0
- package/dist/templates/starter-game/session/src/i18n.ts +91 -24
- package/dist/templates/starter-game/session/src/status.ts +28 -0
- package/dist/templates/starter-game/session/types.ts +8 -2
- package/dist/templates/starter-game/shared/Awning.tsx +31 -0
- package/dist/templates/starter-game/shared/HostLogo.test.tsx +38 -0
- package/dist/templates/starter-game/shared/HostLogo.tsx +48 -0
- package/dist/templates/starter-game/shared/StallIcons.tsx +83 -0
- package/dist/templates/starter-game/shared/days.ts +11 -0
- package/dist/templates/starter-game/shared/format.test.ts +13 -0
- package/dist/templates/starter-game/{ui/src → shared}/format.ts +1 -1
- package/dist/templates/starter-game/testing/e2e/game.spec.ts +42 -8
- package/dist/templates/starter-game/ui/defaults.ts +3 -0
- package/dist/templates/starter-game/ui/src/App.test.tsx +197 -29
- package/dist/templates/starter-game/ui/src/App.tsx +176 -99
- package/dist/templates/starter-game/ui/src/DayBar.test.tsx +50 -7
- package/dist/templates/starter-game/ui/src/DayBar.tsx +96 -38
- package/dist/templates/starter-game/ui/src/DaysTable.tsx +69 -0
- package/dist/templates/starter-game/ui/src/FirstDay.tsx +37 -0
- package/dist/templates/starter-game/ui/src/Header.tsx +257 -0
- package/dist/templates/starter-game/ui/src/Lesson.tsx +63 -0
- package/dist/templates/starter-game/ui/src/MakeRow.tsx +98 -71
- package/dist/templates/starter-game/ui/src/Notices.tsx +59 -0
- package/dist/templates/starter-game/ui/src/PastDay.tsx +88 -0
- package/dist/templates/starter-game/ui/src/Section.tsx +26 -26
- package/dist/templates/starter-game/ui/src/ThemeToggle.tsx +25 -11
- package/dist/templates/starter-game/ui/src/TodayPanel.test.tsx +37 -33
- package/dist/templates/starter-game/ui/src/TodayPanel.tsx +66 -52
- package/dist/templates/starter-game/ui/src/WeatherCard.tsx +47 -0
- package/dist/templates/starter-game/ui/src/WeekOver.tsx +145 -0
- package/dist/templates/starter-game/ui/src/YesterdayPanel.tsx +65 -114
- package/dist/templates/starter-game/ui/src/days.ts +58 -0
- package/dist/templates/starter-game/ui/src/i18n.ts +86 -32
- package/dist/templates/starter-game/ui/src/test-helpers.ts +1 -0
- package/dist/templates/starter-game/ui/src/theme.ts +8 -8
- package/dist/templates/starter-game/ui/types.ts +6 -0
- package/dist/templates/starter-game/ui/ui.sdk.json +1 -1
- package/dist/templates/starter-game/validators/daylimit/defaults.ts +13 -0
- package/dist/templates/starter-game/validators/daylimit/logic/logic.test.ts +20 -0
- package/dist/templates/starter-game/validators/daylimit/logic/logic.ts +23 -0
- package/dist/templates/starter-game/validators/daylimit/types.ts +23 -0
- package/dist/templates/starter-game/validators/daylimit/validator.sdk.json +10 -0
- package/dist/templates/starter-game/waiting_room/src/App.test.tsx +83 -5
- package/dist/templates/starter-game/waiting_room/src/App.tsx +262 -119
- package/dist/templates/starter-game/waiting_room/src/i18n.ts +8 -4
- package/dist/utils/error-codes.d.ts +12 -0
- package/dist/utils/local-refs.d.ts +40 -0
- package/dist/utils/schema-members.d.ts +19 -0
- package/package.json +11 -4
- package/dist/templates/starter-game/session/src/Section.tsx +0 -37
- package/dist/templates/starter-game/session/src/TeamDoor.tsx +0 -96
- package/dist/templates/starter-game/session/src/format.ts +0 -8
- package/dist/templates/starter-game/ui/src/HistoryPanel.test.tsx +0 -74
- package/dist/templates/starter-game/ui/src/HistoryPanel.tsx +0 -120
- package/dist/templates/starter-game/ui/src/HostLogo.test.tsx +0 -25
- package/dist/templates/starter-game/ui/src/HostLogo.tsx +0 -38
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Refuse a scenario whose settings break your game's rules, at build and when one is saved, never when a session starts.
|
|
4
4
|
|
|
5
|
-
**Keywords:** validate scenario, scenario rules, settings conflict, required scenario value, empty default, Scenario gate, scenario-validation, custom scenario check
|
|
5
|
+
**Keywords:** validate scenario, scenario rules, settings conflict, required scenario value, empty default, Scenario gate, scenario-validation, scenario-files, missing file, custom scenario check
|
|
6
6
|
|
|
7
7
|
## Prerequisites
|
|
8
8
|
|
|
@@ -72,6 +72,8 @@ Refuse a scenario whose settings break your game's rules, at build and when one
|
|
|
72
72
|
|
|
73
73
|
6. Optionally, show the same problems in your scenario editor by calling `scenarioProblems(settings.ui)` and marking each field whose setting a problem names
|
|
74
74
|
|
|
75
|
+
7. Optionally, check the files the scenario names: add `"scenario-files"` to `requires`, and the gate receives `callbacks.describeAsset` and `callbacks.readAsset`, resolved against the scenario being judged. See [Checking the files a scenario names](../guides/validators.md#checking-the-files-a-scenario-names)
|
|
76
|
+
|
|
75
77
|
## Verify
|
|
76
78
|
|
|
77
79
|
- `pnpm run sdk build --validate-only` passes
|
|
@@ -82,6 +84,7 @@ Refuse a scenario whose settings break your game's rules, at build and when one
|
|
|
82
84
|
- _`FEATURE_UNDECLARED` at `/requires`_: add `"scenario-validation"` to `requires`
|
|
83
85
|
- _`SCENARIO_REFUSED` for 'The defaults'_: no scenario is the default, so a session can run on the defaults alone, and they break a rule. Mark a scenario `"default": true`, or change the defaults
|
|
84
86
|
- _A placeholder that is also a real choice_: the gate sees values, not where they came from, so it cannot tell a scenario that chose `0` from one that forgot. Use an obviously empty default (`""`, `[]` or `{}`)
|
|
87
|
+
- _'needs the "scenario-files" feature'_: the gate called `readAsset` or `describeAsset`, which it is handed only when `requires` lists `"scenario-files"`
|
|
85
88
|
- _'Validator scenariocheck threw'_: the gate threw, which counts as a problem so that a broken rule never lets a scenario through. Check the settings it reads are listed in `settings`
|
|
86
89
|
|
|
87
90
|
## Related
|
|
@@ -50,7 +50,10 @@ export declare class ConfigResolver {
|
|
|
50
50
|
/**
|
|
51
51
|
* Resolve the active scenario from a provided ID or the game's default.
|
|
52
52
|
* Returns null if the game declares no scenarios, or when null is passed
|
|
53
|
-
*
|
|
53
|
+
* for a game with no default scenario (the settings defaults).
|
|
54
|
+
*
|
|
55
|
+
* A game that declares a default never runs on none (§6.7), so null is
|
|
56
|
+
* refused for it, naming the default.
|
|
54
57
|
*/
|
|
55
58
|
resolveScenario(scenarioId?: string | null): SDKScenario | null;
|
|
56
59
|
/**
|
|
@@ -57,6 +57,12 @@ export interface EndpointCallArgs {
|
|
|
57
57
|
* (§6.12). The session's when absent.
|
|
58
58
|
*/
|
|
59
59
|
scenarioName?: string | null;
|
|
60
|
+
/**
|
|
61
|
+
* The root directory of the scenario a scenario-scoped call is made on,
|
|
62
|
+
* which its `asset:` references resolve against (§6.5), or null for a
|
|
63
|
+
* draft of no scenario.
|
|
64
|
+
*/
|
|
65
|
+
scenarioRoot?: string | null;
|
|
60
66
|
}
|
|
61
67
|
/**
|
|
62
68
|
* One endpoint call's outcome: the response its caller receives, and, for an
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
* own copy and drifting.
|
|
12
12
|
*/
|
|
13
13
|
import type { ApiUse, ResolvedPackageManifest, LogicMeta, Participant, RunKind, RunMeta, SignatureCallbacks } from '@seriousgaming/sdk';
|
|
14
|
-
import type { BlobRetention } from '../storage/blob-store';
|
|
15
14
|
import { type ExecutorCallbacksDeps } from './executor-callbacks';
|
|
16
15
|
import { type LogicOrigin, type SourceMapRegistry } from './logic-failure';
|
|
17
16
|
import type { LogicKind, LogicResource } from './logic-loader';
|
|
@@ -159,8 +158,14 @@ export declare class LogicCalls {
|
|
|
159
158
|
* The callbacks a resource receives: the raw runtime callbacks, built
|
|
160
159
|
* fresh so they read the live game, with every one its `uses` does not
|
|
161
160
|
* declare replaced by a throwing stub.
|
|
161
|
+
*
|
|
162
|
+
* `onDraft` is a scenario-scoped call's: its files are the draft's, and
|
|
163
|
+
* `asset:` resolves against the scenario being written, not the session's
|
|
164
|
+
* (§6.5, §6.12, §16.2).
|
|
162
165
|
*/
|
|
163
|
-
callbacksFor(resourceIdentifier: string, uses: readonly ApiUse[] | undefined,
|
|
166
|
+
callbacksFor(resourceIdentifier: string, uses: readonly ApiUse[] | undefined, onDraft?: {
|
|
167
|
+
scenarioRoot: string | null;
|
|
168
|
+
}): SignatureCallbacks;
|
|
164
169
|
/**
|
|
165
170
|
* Bound one call into author logic that runs as part of a tick, or of the
|
|
166
171
|
* initialisation a tick starts from (§11.10).
|
|
@@ -6,11 +6,29 @@
|
|
|
6
6
|
* board, so the build can run it on a package's own scenarios and the dev
|
|
7
7
|
* server on a scenario about to be saved, with only the package and a loader.
|
|
8
8
|
*/
|
|
9
|
-
import type
|
|
9
|
+
import { type ResolvedPackageManifest, type ScenarioProblem } from '@seriousgaming/sdk';
|
|
10
10
|
import { LogicLoader } from './logic-loader';
|
|
11
11
|
import type { SessionSettingsOverrides } from './types';
|
|
12
12
|
/** The `requires` feature name a package using the `Scenario` gate lists (§15.8). */
|
|
13
13
|
export declare const SCENARIO_VALIDATION = "scenario-validation";
|
|
14
|
+
/** The `requires` feature name a package whose `Scenario` gate reads files lists (§15.8). */
|
|
15
|
+
export declare const SCENARIO_FILES = "scenario-files";
|
|
16
|
+
/**
|
|
17
|
+
* Where the files of the scenario being judged resolve (§15.8): as that
|
|
18
|
+
* scenario resolves them, so a gate finds exactly the files a session started
|
|
19
|
+
* on it would.
|
|
20
|
+
*/
|
|
21
|
+
export interface ScenarioFileRoots {
|
|
22
|
+
/** The scenario's root directory, which `asset:` resolves against, or null for none. */
|
|
23
|
+
scenarioRoot: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Which blobs `blob:` resolves to: none for a package scenario, which can
|
|
26
|
+
* name no blob; the ones a draft can read, its `scenario` blobs, for a
|
|
27
|
+
* draft (§6.12); and every one for the session's own settings saved as a
|
|
28
|
+
* scenario, whose files the save takes with it.
|
|
29
|
+
*/
|
|
30
|
+
blobs: 'none' | 'draft' | 'all';
|
|
31
|
+
}
|
|
14
32
|
/** A problem one validator found with a scenario. */
|
|
15
33
|
export interface ScenarioGateProblem extends ScenarioProblem {
|
|
16
34
|
validatorIdentifier: string;
|
|
@@ -29,6 +47,8 @@ export declare function runScenarioGates(options: {
|
|
|
29
47
|
locale?: string;
|
|
30
48
|
loader?: LogicLoader;
|
|
31
49
|
boundMs?: number;
|
|
50
|
+
/** Where the scenario's files resolve. None at all when absent: the defaults alone. */
|
|
51
|
+
files?: ScenarioFileRoots;
|
|
32
52
|
}): Promise<ScenarioGateProblem[]>;
|
|
33
53
|
/** One line per problem, naming the validator and the setting. */
|
|
34
54
|
export declare function describeScenarioProblems(problems: ScenarioGateProblem[]): string[];
|
package/dist/guide/settings.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ type Lookup = {
|
|
|
35
35
|
} | {
|
|
36
36
|
found: false;
|
|
37
37
|
};
|
|
38
|
-
/** The value at `identifier.key.key
|
|
38
|
+
/** The value at a setting path (§6.1a), `identifier.key.key…`, in resolved settings. */
|
|
39
39
|
export declare function lookupSetting(settings: GuideSettings, path: string): Lookup;
|
|
40
40
|
/** How a value reads in the guide, or null when it is not a renderable kind. */
|
|
41
41
|
export declare function formatSettingValue(value: unknown, locale: string): string | null;
|
package/dist/host.js
CHANGED
|
@@ -739,6 +739,66 @@ function chapterSources(locales, chapters, requested) {
|
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
741
|
|
|
742
|
+
// ../sdk/lib/build/tick-validation.js
|
|
743
|
+
var MAX_EFFECTIVE_TICK_INTERVAL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
744
|
+
|
|
745
|
+
// ../sdk/lib/build/setting-path.js
|
|
746
|
+
var NOT_PLAIN = /[.[\]"\s]/u;
|
|
747
|
+
function isPlainKey(key) {
|
|
748
|
+
return key !== "" && !NOT_PLAIN.test(key);
|
|
749
|
+
}
|
|
750
|
+
function parseSettingPath(path2) {
|
|
751
|
+
const steps = [];
|
|
752
|
+
let at = 0;
|
|
753
|
+
while (at < path2.length) {
|
|
754
|
+
if (path2[at] === "[") {
|
|
755
|
+
const end2 = closingQuote(path2, at + 1);
|
|
756
|
+
if (end2 === void 0 || path2[end2 + 1] !== "]")
|
|
757
|
+
return void 0;
|
|
758
|
+
let key2;
|
|
759
|
+
try {
|
|
760
|
+
key2 = JSON.parse(path2.slice(at + 1, end2 + 1));
|
|
761
|
+
} catch {
|
|
762
|
+
return void 0;
|
|
763
|
+
}
|
|
764
|
+
if (typeof key2 !== "string")
|
|
765
|
+
return void 0;
|
|
766
|
+
steps.push(key2);
|
|
767
|
+
at = end2 + 2;
|
|
768
|
+
continue;
|
|
769
|
+
}
|
|
770
|
+
if (steps.length > 0) {
|
|
771
|
+
if (path2[at] !== ".")
|
|
772
|
+
return void 0;
|
|
773
|
+
at += 1;
|
|
774
|
+
}
|
|
775
|
+
let end = at;
|
|
776
|
+
while (end < path2.length && path2[end] !== "." && path2[end] !== "[")
|
|
777
|
+
end += 1;
|
|
778
|
+
const key = path2.slice(at, end);
|
|
779
|
+
if (!isPlainKey(key))
|
|
780
|
+
return void 0;
|
|
781
|
+
steps.push(key);
|
|
782
|
+
at = end;
|
|
783
|
+
}
|
|
784
|
+
const [identifier, ...keys] = steps;
|
|
785
|
+
return identifier === void 0 ? void 0 : { identifier, keys };
|
|
786
|
+
}
|
|
787
|
+
function closingQuote(path2, start) {
|
|
788
|
+
if (path2[start] !== '"')
|
|
789
|
+
return void 0;
|
|
790
|
+
for (let at = start + 1; at < path2.length; at += 1) {
|
|
791
|
+
if (path2[at] === "\\")
|
|
792
|
+
at += 1;
|
|
793
|
+
else if (path2[at] === '"')
|
|
794
|
+
return at;
|
|
795
|
+
}
|
|
796
|
+
return void 0;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// ../sdk/lib/build/validators.js
|
|
800
|
+
var SCENARIO_GATE_READ_LIMIT_BYTES = 10 * 1024 * 1024;
|
|
801
|
+
|
|
742
802
|
// ../node_modules/.pnpm/ccount@2.0.1/node_modules/ccount/index.js
|
|
743
803
|
function ccount(value, character) {
|
|
744
804
|
const source = String(value);
|
|
@@ -11940,8 +12000,10 @@ function isUint8Array2(value) {
|
|
|
11940
12000
|
|
|
11941
12001
|
// cli/guide/settings.ts
|
|
11942
12002
|
function lookupSetting(settings, path2) {
|
|
11943
|
-
const
|
|
11944
|
-
if (!
|
|
12003
|
+
const parsed = parseSettingPath(path2);
|
|
12004
|
+
if (!parsed || parsed.keys.length === 0) return { found: false };
|
|
12005
|
+
const { identifier, keys } = parsed;
|
|
12006
|
+
if (!Object.prototype.hasOwnProperty.call(settings, identifier)) return { found: false };
|
|
11945
12007
|
let value = settings[identifier];
|
|
11946
12008
|
for (const key of keys) {
|
|
11947
12009
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
@@ -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.5";
|
|
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
|
@@ -13,6 +13,9 @@ var UndeclaredApiUseError = class extends Error {
|
|
|
13
13
|
// ../sdk/lib/build/tick-validation.js
|
|
14
14
|
var MAX_EFFECTIVE_TICK_INTERVAL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
15
15
|
|
|
16
|
+
// ../sdk/lib/build/validators.js
|
|
17
|
+
var SCENARIO_GATE_READ_LIMIT_BYTES = 10 * 1024 * 1024;
|
|
18
|
+
|
|
16
19
|
// cli/runtime/guarded-callbacks.ts
|
|
17
20
|
var API_USE_TO_CALLBACK = {
|
|
18
21
|
generateText: "generateText",
|
|
@@ -302,7 +305,7 @@ function readTickControllerResult(label, result) {
|
|
|
302
305
|
|
|
303
306
|
// cli/runtime/manifest-version.ts
|
|
304
307
|
var MANIFEST_VERSION = 3;
|
|
305
|
-
var SPEC_REVISION = "1.
|
|
308
|
+
var SPEC_REVISION = "1.5";
|
|
306
309
|
function isLaterSpecRevision(revision, than) {
|
|
307
310
|
const [major, minor] = revision.split(".").map(Number);
|
|
308
311
|
const [thanMajor, thanMinor] = than.split(".").map(Number);
|
|
@@ -312,7 +315,9 @@ var SUPPORTED_FEATURES = [
|
|
|
312
315
|
// A validator's `Scenario` gate (§15.8).
|
|
313
316
|
"scenario-validation",
|
|
314
317
|
// The presentation as a host overlay a session surface may open (§6.4).
|
|
315
|
-
"presentation-overlay"
|
|
318
|
+
"presentation-overlay",
|
|
319
|
+
// File reads in a validator's `Scenario` gate (§15.8).
|
|
320
|
+
"scenario-files"
|
|
316
321
|
];
|
|
317
322
|
function unsupportedFeatures(manifest) {
|
|
318
323
|
return (manifest.requires ?? []).filter((feature) => !SUPPORTED_FEATURES.includes(feature));
|
|
@@ -10,13 +10,25 @@
|
|
|
10
10
|
* server's blob store.
|
|
11
11
|
*
|
|
12
12
|
* The dispatch lives here so every engine-side and endpoint-side caller
|
|
13
|
-
* (`readAsset`, `extractText`) shares a single
|
|
13
|
+
* (`readAsset`, `describeAsset`, `extractText`) shares a single
|
|
14
|
+
* implementation.
|
|
14
15
|
*/
|
|
16
|
+
import type { AssetDescription } from '@seriousgaming/sdk';
|
|
17
|
+
/**
|
|
18
|
+
* The media type of a package file, by its extension: the table in §16.3,
|
|
19
|
+
* which the build judges a file setting's `accept` by and the dev server
|
|
20
|
+
* serves files under. `media-types.test.ts` holds the two to each other.
|
|
21
|
+
*/
|
|
22
|
+
export declare const EXTENSION_MEDIA_TYPES: Readonly<Record<string, string>>;
|
|
23
|
+
/** What a file whose extension §16.3's table does not list is. */
|
|
24
|
+
export declare const UNLISTED_MEDIA_TYPE = "application/octet-stream";
|
|
15
25
|
export interface ResolvedAsset {
|
|
16
26
|
data: Buffer;
|
|
17
27
|
mimeType: string;
|
|
18
28
|
name: string;
|
|
19
29
|
}
|
|
30
|
+
/** The media type §16.3's table names for a file's extension, compared case-insensitively. */
|
|
31
|
+
export declare function mediaTypeOf(path: string): string;
|
|
20
32
|
/**
|
|
21
33
|
* Returns true when `value` is a string starting with one of the known
|
|
22
34
|
* asset URI scheme prefixes.
|
|
@@ -47,3 +59,14 @@ export declare function resolveSharedAsset(packagePath: string, path: string): P
|
|
|
47
59
|
* scenario root before passing it in.
|
|
48
60
|
*/
|
|
49
61
|
export declare function readAssetByReference(packagePath: string, scenarioRootDirectory: string | null, reference: string): Promise<ResolvedAsset>;
|
|
62
|
+
/**
|
|
63
|
+
* Describe what an `asset:<path>`, `shared:<path>`, or `blob:<id>` reference
|
|
64
|
+
* names, as {@link readAssetByReference} would resolve it, without reading the
|
|
65
|
+
* bytes: its MIME type and size, or undefined when there is no such file. An
|
|
66
|
+
* `asset:` reference with no active scenario names no file.
|
|
67
|
+
*
|
|
68
|
+
* A reference with none of the three prefixes, or a path escaping its
|
|
69
|
+
* directory, is a mistake rather than a missing file, so it throws as
|
|
70
|
+
* {@link readAssetByReference} does.
|
|
71
|
+
*/
|
|
72
|
+
export declare function describeAssetByReference(packagePath: string, scenarioRootDirectory: string | null, reference: string): Promise<AssetDescription | undefined>;
|
|
@@ -35,6 +35,13 @@ export declare function storeBlob(packagePath: string, data: Buffer, name: strin
|
|
|
35
35
|
* Throws if the blob does not exist.
|
|
36
36
|
*/
|
|
37
37
|
export declare function readBlob(packagePath: string, id: string): Promise<BlobData>;
|
|
38
|
+
/**
|
|
39
|
+
* A stored blob's metadata and size, read without its bytes, or undefined
|
|
40
|
+
* when the store holds no such blob.
|
|
41
|
+
*/
|
|
42
|
+
export declare function describeBlob(packagePath: string, id: string): Promise<(BlobMeta & {
|
|
43
|
+
size: number;
|
|
44
|
+
}) | undefined>;
|
|
38
45
|
/**
|
|
39
46
|
* Delete every blob held under one of `retentions` (§16.2). A deleted blob is
|
|
40
47
|
* read as an unknown one: {@link readBlob} throws, and the asset route 404s.
|
|
@@ -33,11 +33,16 @@ The SDK's documentation ships inside it, so it describes the version installed h
|
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
35
|
pnpm run --silent sdk docs view # the documentation tree
|
|
36
|
+
pnpm run --silent sdk docs view page-index.md # every page: summary and length
|
|
36
37
|
pnpm run --silent sdk docs view recipes/index.md # every recipe, one line each
|
|
37
38
|
pnpm run --silent sdk docs view recipes/create-hook.md # one document
|
|
39
|
+
pnpm run --silent sdk docs view guides/session.md --outline # the headings of a page, with section lengths
|
|
40
|
+
pnpm run --silent sdk docs view guides/session.md --section 'Building the session UI' # one section
|
|
38
41
|
pnpm run --silent sdk docs view cli-reference.md # every command and flag
|
|
39
42
|
```
|
|
40
43
|
|
|
44
|
+
Some guides run past 50,000 characters, more than one read may show you. Before reading a long page whole, find it in `page-index.md`, list its headings with `--outline`, and read the section you need with `--section`.
|
|
45
|
+
|
|
41
46
|
The same files are on disk in `node_modules/@seriousgaming/sdk-tools/dist/docs/`, so you can search them with `grep -rn`. Start from `recipes/` for a task, `guides/` for a whole subject, and `concepts/` for the model.
|
|
42
47
|
|
|
43
48
|
`pnpm run sdk docs export` copies them into the package, for a tool that cannot read `node_modules`. The same docs for the newest release are at https://sdk.seriousgaming.com/llms.txt; prefer the installed copy, which matches the version this package runs.
|
|
@@ -81,7 +86,7 @@ Data flows: surfaces write decisions with `setData`, a tick runs the engine, and
|
|
|
81
86
|
├── waiting_room/ # THE holding screen
|
|
82
87
|
├── setup/ # THE settings form at session creation (sdk new setup)
|
|
83
88
|
├── scenario_editor/ # THE scenario authoring screen (sdk new scenario_editor)
|
|
84
|
-
├── presentation/ # THE slide deck
|
|
89
|
+
├── presentation/ # THE slide deck the facilitator projects
|
|
85
90
|
├── tick_controller/ # THE timer, for timed rounds (sdk new tick_controller)
|
|
86
91
|
├── guide/ # THE facilitator guide (markdown per locale, plus assets)
|
|
87
92
|
├── capabilities/<name>/ # Data definitions
|
|
@@ -147,7 +152,7 @@ pnpm run generate # regenerate types after a hand edit (
|
|
|
147
152
|
pnpm run build # validate, generate and bundle into dist/
|
|
148
153
|
```
|
|
149
154
|
|
|
150
|
-
A slot command takes no identifier. The starter game fills every slot but `setup`, `scenario_editor
|
|
155
|
+
A slot command takes no identifier. The starter game fills every slot but `setup`, `scenario_editor` and `tick_controller`, and `new` refuses a filled slot. `update package` changes the manifest, which takes no identifier either.
|
|
151
156
|
|
|
152
157
|
### Playing the game from the CLI
|
|
153
158
|
|
|
@@ -297,15 +302,16 @@ expect(session.team(0).context.results.Day).toBe(1);
|
|
|
297
302
|
|
|
298
303
|
### Testing a surface
|
|
299
304
|
|
|
300
|
-
Every surface but the presentation scaffolds an `App.test.tsx`; the starter game's own tests are worked examples, and `pnpm run --silent sdk docs view guides/testing.md` is the reference.
|
|
305
|
+
Every surface but the presentation scaffolds an `App.test.tsx`; the starter game's own tests are worked examples, and `pnpm run --silent sdk docs view guides/testing.md` is the reference. A deck is tested through what its slides show, kept in plain functions (`presentation/src/stalls.test.ts`), and a Playwright spec that it opens.
|
|
301
306
|
|
|
302
307
|
- **Render through the helper**: `renderUserInterface()` from `@seriousgaming/sdk/ui/testing` (or `renderSessionUserInterface<SessionData>()`, or `renderSettingsEditor()` for setup and the scenario editor). It supplies every provider the host does; pass `data`, `settings`, `callbacks` and the rest as options
|
|
303
308
|
- **Never `vi.mock` the SDK, and never wire its providers by hand**
|
|
304
309
|
- **Use `fireEvent.change` on controlled inputs**: the mock `setData` does not update the value between `userEvent.type` keystrokes
|
|
310
|
+
- **Look at every screen you change**, at phone and desktop size: `pnpm run --silent sdk screenshot /team/1/player/1 --width 390 --height 844 --json`, then again with `--width 1280 --height 800`. Open each PNG, fix text that is cut off, overlaps or is hard to read, and clear the `consoleErrors`, `failedRequests` and `uncaughtExceptions` it lists. Reach the state first with `sdk tick` (`recipes/screenshot-a-surface.md`)
|
|
305
311
|
|
|
306
312
|
## Presentations
|
|
307
313
|
|
|
308
|
-
The `presentation/` slot holds the facilitator's slide deck, built with `@seriousgaming/deck` at the SDK's version. It reads every team's state and writes nothing. A facilitator exports it to PDF or PowerPoint and edits the copy, so:
|
|
314
|
+
The `presentation/` slot holds the facilitator's slide deck, built with `@seriousgaming/deck` at the SDK's version. It reads every team's state and writes nothing. The starter game's deck is a worked example: a title, a slide a day, and the results. A facilitator exports it to PDF or PowerPoint and edits the copy, so:
|
|
309
315
|
|
|
310
316
|
- **Use the building blocks** (`Heading`, `Text`, `Bullets`, `Table`) for anything a facilitator might edit; anything else exports as a picture
|
|
311
317
|
- **Render with `session === null`**, showing labelled sample figures where results would go
|
|
@@ -338,4 +344,7 @@ Upgrade only when the user asks, or when the changelog has a fix the task needs,
|
|
|
338
344
|
| A hook reads empty data in a surface | Two copies of a package with React context: add it to `resolve.dedupe` in `vite.config.ts` |
|
|
339
345
|
| Anything else | `pnpm run --silent sdk docs view troubleshooting.md` |
|
|
340
346
|
|
|
341
|
-
Keep `DESIGN.md` up to date as the game changes
|
|
347
|
+
Keep `DESIGN.md` up to date as the game changes, and hold to two habits for every surface:
|
|
348
|
+
|
|
349
|
+
- **Brief first.** Before you build or redesign a screen, write its brief under 'User interfaces' in `DESIGN.md`: who uses it and on what device, its one main action, its layout, the states it must handle, and the game's identity
|
|
350
|
+
- **Check, then go round once more.** Once it is built, check every screen at phone and desktop size against `pnpm run --silent sdk docs view guides/designing-screens.md`, fix what you find, and check again
|
|
@@ -100,17 +100,49 @@ What the model simplifies, and what it deliberately leaves out.
|
|
|
100
100
|
|
|
101
101
|
## User interfaces
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
Write each screen's brief here before you build it, then check the built screen against it. `pnpm run --silent sdk docs view guides/designing-screens.md` explains each prompt, and what to check afterwards.
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
- **Views:** the tabs or panels, and what each is for
|
|
107
|
-
- **How a player submits:** what they change, and what tells them a write did not land
|
|
105
|
+
### Who plays, and on what
|
|
108
106
|
|
|
109
|
-
|
|
107
|
+
Who uses each screen, where they are, and the device in their hand.
|
|
110
108
|
|
|
111
|
-
|
|
109
|
+
**Example:** 'Participants on their own phones, standing in teams of three; the facilitator on a laptop that is also on the projector.'
|
|
112
110
|
|
|
113
|
-
|
|
111
|
+
### Tone
|
|
112
|
+
|
|
113
|
+
How the game should feel to play.
|
|
114
|
+
|
|
115
|
+
**Example:** 'Quick and light. A market stall, not a spreadsheet.'
|
|
116
|
+
|
|
117
|
+
### Key screens
|
|
118
|
+
|
|
119
|
+
Each screen, the one main action on it, and what the person needs to see to take it. A game holds one participant surface, so several views are components inside `ui/` rather than separate resources. For `setup/` and `scenario_editor/`, if the game has them, also name the settings resources each `configures`.
|
|
120
|
+
|
|
121
|
+
**Example:**
|
|
122
|
+
|
|
123
|
+
- **`ui/`, today:** set how many of each item to make. Needs the forecast and what is left of capacity
|
|
124
|
+
- **`ui/`, history:** compare past days. No action; the profit for each day comes first
|
|
125
|
+
- **`session/`:** spot the stall that has stopped changing its numbers, and step in
|
|
126
|
+
- **`waiting_room/`:** name the team while everyone arrives
|
|
127
|
+
- **`presentation/`:** the briefing, a slide a round, and the results for the debrief
|
|
128
|
+
|
|
129
|
+
### Layout
|
|
130
|
+
|
|
131
|
+
The pattern each screen follows, and how it changes between a phone and a laptop.
|
|
132
|
+
|
|
133
|
+
**Example:** 'One column on a phone, with the decision first and the open button pinned to the bottom. Two columns from tablet width, with today beside yesterday.'
|
|
134
|
+
|
|
135
|
+
### States
|
|
136
|
+
|
|
137
|
+
What each screen shows before play, mid-round, while a round is processed, after the last round, when a write is refused, and to an observer.
|
|
138
|
+
|
|
139
|
+
**Example:** 'Before the first day, the results panel says when results will appear. A refused plan shows the validator's reason under the slider that was moved.'
|
|
140
|
+
|
|
141
|
+
### Identity
|
|
142
|
+
|
|
143
|
+
What makes this game look like itself on top of the host's theme: the accent layer, iconography and imagery from the game's world, and the words it uses for things.
|
|
144
|
+
|
|
145
|
+
**Example:** 'Rounded, card-like panels; illustrated weather icons; "stall" for team and "open up" for submit.'
|
|
114
146
|
|
|
115
147
|
---
|
|
116
148
|
|
|
@@ -73,7 +73,7 @@ pnpm run build
|
|
|
73
73
|
├── session/ # THE session interface: the facilitator's screen
|
|
74
74
|
├── waiting_room/ # THE holding screen, shown before and between
|
|
75
75
|
├── guide/ # THE facilitator guide, as markdown chapters
|
|
76
|
-
├── presentation/ # THE slide deck the facilitator projects
|
|
76
|
+
├── presentation/ # THE slide deck the facilitator projects
|
|
77
77
|
├── setup/ # THE form a facilitator fills in at session creation (`new setup`)
|
|
78
78
|
├── scenario_editor/ # THE editor for authoring lasting scenarios (`new scenario_editor`)
|
|
79
79
|
├── capabilities/ # The shape of the game's state
|
|
@@ -15,7 +15,7 @@ A user interface is a React app that reads game state and (optionally) sends dec
|
|
|
15
15
|
```
|
|
16
16
|
2. **Confirm the capabilities exist.** A UI reads (and optionally writes) capabilities by their short names. Create any that are missing first.
|
|
17
17
|
3. **Change or create the bundle.** The starter game already has a `ui/`, so change it with `pnpm run sdk update ui --patch '[...]'`; `new ui` refuses while `ui/` exists. In an empty package, `pnpm run sdk new ui '{ ... }'`. Declare every capability the UI shows in `reads`, and add `writes` only for the ones it sends back via `setData`. A UI receives exactly what it declares.
|
|
18
|
-
4. **Implement the components** under `ui/src/` (the entry component is `App.tsx`), with `useUserInterfaceData()` for `data`, `settings`, `setData` and `completedTicks`. Default to MUI; another library must integrate with `useUserInterfaceTheme` so dark mode and colour palettes work, and text on a theme colour uses that colour's `contrastText`. Remember a viewer's own choices with `useViewerStorage`, never `localStorage`. Put every string in `src/i18n.ts`. `pnpm run --silent sdk docs view guides/ui.md` is the reference for every hook.
|
|
18
|
+
4. **Implement the components** under `ui/src/` (the entry component is `App.tsx`), with `useUserInterfaceData()` for `data`, `settings`, `setData` and `completedTicks`. Default to MUI; another library must integrate with `useUserInterfaceTheme` so dark mode and colour palettes work, and text on a theme colour uses that colour's `contrastText`. Remember a viewer's own choices with `useViewerStorage`, never `localStorage`. Put every string in `src/i18n.ts`. `pnpm run --silent sdk docs view guides/ui.md` is the reference for every hook, with the topic pages it links.
|
|
19
19
|
5. **Await every write.** `setData` returns a promise that rejects when the host refuses the write. Route writes through `useMutationReporter`, as the starter game's `ui/src/writes.ts` does, so the participant sees the refusal. Never retry a write automatically: on a `conflict` the host has already retried and given up, so offer `failure.retry` behind a 'Try again' button instead.
|
|
20
20
|
6. **Add a test** beside the component (`App.test.tsx`), rendered with `renderUserInterface()` (or `renderSessionUserInterface<SessionData>()`, `renderSettingsEditor()`) from `@seriousgaming/sdk/ui/testing`, as the starter game's tests do. `pnpm run --silent sdk docs view guides/testing.md` has the harness.
|
|
21
21
|
7. **Verify**: `pnpm run build` and `pnpm test:run`. A running dev server hot-reloads the UI. The user starts the dev server (`pnpm run sdk dev`) when they want to see it; never start it yourself.
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
# Refuse any version published less than seven days ago, so a compromised
|
|
2
|
+
# release is not pulled in before anyone has had time to catch it. pnpm's own
|
|
3
|
+
# default is one day. Given a range, pnpm picks the newest release in it that is
|
|
4
|
+
# old enough, so this steps a dependency down rather than failing your install.
|
|
5
|
+
#
|
|
6
|
+
# The SDK's own packages are exempt. You chose them by running `new package`,
|
|
7
|
+
# and a game scaffolded on the day of an SDK release would otherwise refuse the
|
|
8
|
+
# very version that scaffolded it. Everything they depend on is still held to
|
|
9
|
+
# the seven days.
|
|
10
|
+
minimumReleaseAge: 10080
|
|
11
|
+
minimumReleaseAgeExclude:
|
|
12
|
+
- '@seriousgaming/*'
|
|
13
|
+
|
|
1
14
|
# A transitive dependency of the SDK packages whose parent pins it to a range
|
|
2
15
|
# that only reaches a version with a security advisory against it. Your package
|
|
3
16
|
# does not depend on it directly, and nothing you change in package.json moves
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"definition": {
|
|
3
|
+
"scope": "shared",
|
|
4
|
+
"variablesSchema": {
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"LastOpenDay": {
|
|
8
|
+
"type": "integer",
|
|
9
|
+
"description": "The last day a stall may open. The facilitator lowers it to hold the room at a day, and raises it to let them on; the default opens all ten",
|
|
10
|
+
"default": 10,
|
|
11
|
+
"minimum": 0
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"required": ["LastOpenDay"],
|
|
15
|
+
"additionalProperties": false
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -32,8 +32,10 @@
|
|
|
32
32
|
"@emotion/styled": "^11.14.1",
|
|
33
33
|
"@fontsource-variable/roboto-mono": "^5.3.0",
|
|
34
34
|
"@fontsource-variable/work-sans": "^5.3.0",
|
|
35
|
+
"@mui/icons-material": "^9.4.0",
|
|
35
36
|
"@mui/material": "^9.4.0",
|
|
36
37
|
"@mui/stylis-plugin-rtl": "^9.4.0",
|
|
38
|
+
"@seriousgaming/deck": "workspace:*",
|
|
37
39
|
"i18next": "^26.4.2",
|
|
38
40
|
"react": "^19.3.0",
|
|
39
41
|
"react-dom": "^19.3.0",
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// This file is auto-generated from the schemas the resource declares: the values
|
|
2
|
+
// a session starts with, for use as test fixtures.
|
|
3
|
+
// Do not edit this file directly. It will be regenerated on build.
|
|
4
|
+
|
|
5
|
+
import type { Context, TeamContext, SharedContext, Settings } from './types';
|
|
6
|
+
|
|
7
|
+
export const defaultContext: Context = {
|
|
8
|
+
plan: {
|
|
9
|
+
Make: {},
|
|
10
|
+
},
|
|
11
|
+
weather: {
|
|
12
|
+
Today: 'sunny',
|
|
13
|
+
Expected: {},
|
|
14
|
+
},
|
|
15
|
+
results: {
|
|
16
|
+
Day: 0,
|
|
17
|
+
Weather: 'sunny',
|
|
18
|
+
Lines: {},
|
|
19
|
+
Takings: 0,
|
|
20
|
+
Spent: 0,
|
|
21
|
+
Profit: 0,
|
|
22
|
+
Purse: 0,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const defaultTeamContext: TeamContext = {
|
|
27
|
+
plan: {
|
|
28
|
+
Make: {},
|
|
29
|
+
},
|
|
30
|
+
weather: {
|
|
31
|
+
Today: 'sunny',
|
|
32
|
+
Expected: {},
|
|
33
|
+
},
|
|
34
|
+
results: {
|
|
35
|
+
Day: 0,
|
|
36
|
+
Weather: 'sunny',
|
|
37
|
+
Lines: {},
|
|
38
|
+
Takings: 0,
|
|
39
|
+
Spent: 0,
|
|
40
|
+
Profit: 0,
|
|
41
|
+
Purse: 0,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const defaultSharedContext: SharedContext = {};
|
|
46
|
+
|
|
47
|
+
export const defaultSettings: Settings = {
|
|
48
|
+
session: {
|
|
49
|
+
ShowJoinLinks: true,
|
|
50
|
+
CurrencySymbol: '£',
|
|
51
|
+
},
|
|
52
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Lemonade Stand</title>
|
|
7
|
+
<style>
|
|
8
|
+
html,
|
|
9
|
+
body,
|
|
10
|
+
#root {
|
|
11
|
+
height: 100%;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
</style>
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<div id="root"></div>
|
|
18
|
+
<script type="module" src="./src/main.tsx"></script>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { brandFromTheme, Deck } from '@seriousgaming/deck';
|
|
2
|
+
import { usePresentation } from '@seriousgaming/sdk/ui';
|
|
3
|
+
import { useEffect, useMemo } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
|
|
6
|
+
import type { Settings, SharedContext, TeamContext } from '../types';
|
|
7
|
+
import { useSlides } from './Slides';
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
A presentation is the facilitator's slide deck. It is read-only, and it renders
|
|
11
|
+
with or without a session: in a game's library, while rehearsing or to export
|
|
12
|
+
it beforehand, `session` is null, so every slide must make sense without
|
|
13
|
+
results.
|
|
14
|
+
|
|
15
|
+
The host's theme becomes the deck's brand here, so the slides pick up the same
|
|
16
|
+
colours as every other surface.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** Where to open when nothing is remembered: wherever the room has got to. */
|
|
20
|
+
function startFor(rounds: number, played: number | null): string {
|
|
21
|
+
if (!played) return 'title';
|
|
22
|
+
return played >= rounds ? 'results' : `day-${played + 1}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default function App() {
|
|
26
|
+
const { game, session, theme, locale } = usePresentation<
|
|
27
|
+
Settings,
|
|
28
|
+
TeamContext,
|
|
29
|
+
SharedContext
|
|
30
|
+
>();
|
|
31
|
+
const { i18n } = useTranslation();
|
|
32
|
+
const language = locale.locale;
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
void i18n.changeLanguage(language);
|
|
36
|
+
}, [i18n, language]);
|
|
37
|
+
|
|
38
|
+
const brand = useMemo(() => brandFromTheme(theme), [theme]);
|
|
39
|
+
const slides = useSlides();
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Deck
|
|
43
|
+
brand={brand}
|
|
44
|
+
title={game.name}
|
|
45
|
+
dir={i18n.dir(language)}
|
|
46
|
+
lang={language}
|
|
47
|
+
// Come back to the same slide after a reload or a break. Each session
|
|
48
|
+
// keeps its own place; rehearsing without one has one of its own.
|
|
49
|
+
rememberAs={session ? `session:${session.id}` : 'com.example.lemonade'}
|
|
50
|
+
startAt={startFor(game.maxTicks ?? 10, session?.completedTicks ?? null)}
|
|
51
|
+
>
|
|
52
|
+
{slides}
|
|
53
|
+
</Deck>
|
|
54
|
+
);
|
|
55
|
+
}
|