@seriousgaming/sdk-tools 1.4.0 → 1.6.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/bundling/ui-bundler.d.ts +12 -0
- package/dist/cli-25RWY5BQ.js +41 -0
- package/dist/cli-272KBNJH.js +97 -0
- package/dist/cli-2BH7FX27.js +52 -0
- package/dist/cli-2GOFEW26.js +81 -0
- package/dist/cli-3E3MD5U4.js +21 -0
- package/dist/cli-3HE4AVZG.js +115 -0
- package/dist/cli-4AKVLEC4.js +1387 -0
- package/dist/cli-4BV45LBH.js +126 -0
- package/dist/cli-4LKXZQ2B.js +48 -0
- package/dist/cli-4UWFQNGF.js +54 -0
- package/dist/cli-4YB3ROVR.js +78 -0
- package/dist/cli-57RXC3HQ.js +36 -0
- package/dist/cli-5JEGTVTG.js +96 -0
- package/dist/cli-6AMT3BUO.js +97 -0
- package/dist/cli-6RRVEGFB.js +80 -0
- package/dist/cli-6WXLXJVX.js +36 -0
- package/dist/cli-7OGYADZ3.js +97 -0
- package/dist/cli-AK7OIPWY.js +229 -0
- package/dist/cli-B4TN6PJP.js +124 -0
- package/dist/cli-B6YHEKIJ.js +248 -0
- package/dist/cli-BPYMTOUL.js +89 -0
- package/dist/cli-BWX5E7TQ.js +23 -0
- package/dist/cli-BYJWFFCF.js +37 -0
- package/dist/cli-C3NVCKO6.js +43 -0
- package/dist/cli-C47GJATR.js +42 -0
- package/dist/cli-C5QOJJWX.js +46 -0
- package/dist/cli-C6TH5S7K.js +6417 -0
- package/dist/cli-DL2CVMRF.js +89 -0
- package/dist/cli-DMW2OQIJ.js +76 -0
- package/dist/cli-DZW3XD5F.js +143 -0
- package/dist/cli-E2NLWIFE.js +1331 -0
- package/dist/cli-E33CJRRQ.js +36 -0
- package/dist/cli-E6DJIMYD.js +142 -0
- package/dist/cli-EEFJKIGL.js +151 -0
- package/dist/cli-EVFS55WN.js +185 -0
- package/dist/cli-F2D4GGUA.js +549 -0
- package/dist/cli-FBTRTIZJ.js +226 -0
- package/dist/cli-FWFRKQNE.js +11 -0
- package/dist/cli-FYINNRML.js +760 -0
- package/dist/cli-G522CPRL.js +88 -0
- package/dist/cli-G6KELFSX.js +2847 -0
- package/dist/cli-G6UE5NL4.js +90 -0
- package/dist/cli-GBFM76BF.js +16 -0
- package/dist/cli-GDQ6ILJY.js +101 -0
- package/dist/cli-GFBGYFYD.js +50 -0
- package/dist/cli-GGPDQNM3.js +35 -0
- package/dist/cli-GTSGLN3Z.js +307 -0
- package/dist/cli-GUXKQMJ7.js +13641 -0
- package/dist/cli-GXD36NF2.js +60 -0
- package/dist/cli-HCRTYQQS.js +16 -0
- package/dist/cli-HYY64SUD.js +185 -0
- package/dist/cli-I355WTAF.js +463 -0
- package/dist/cli-IDKYF5XB.js +59 -0
- package/dist/cli-ILKCQNM6.js +8 -0
- package/dist/cli-IRZ5KB7D.js +36 -0
- package/dist/cli-IUS2YCD3.js +31 -0
- package/dist/cli-J4DKUUTK.js +138 -0
- package/dist/cli-JFU22EJ2.js +187 -0
- package/dist/cli-JMZLT65J.js +226 -0
- package/dist/cli-JZM7XTNV.js +89 -0
- package/dist/cli-K2B6WHKA.js +81 -0
- package/dist/cli-KL3756X6.js +126 -0
- package/dist/cli-KNOOKGYW.js +88 -0
- package/dist/cli-LFGRFIEO.js +226 -0
- package/dist/cli-LFM7GJHI.js +0 -0
- package/dist/cli-LMDJCHHD.js +304 -0
- package/dist/cli-LXYPE3L5.js +99 -0
- package/dist/cli-M6BCQRID.js +153 -0
- package/dist/cli-MBNMPVDC.js +367 -0
- package/dist/cli-MJUYJIEP.js +13 -0
- package/dist/cli-MMN4BPO4.js +145 -0
- package/dist/cli-MYJGMA6U.js +40 -0
- package/dist/cli-N6H6T2E2.js +616 -0
- package/dist/cli-O5KP4OVN.js +61 -0
- package/dist/cli-O6PWMJTZ.js +25 -0
- package/dist/cli-ORIG557O.js +141 -0
- package/dist/cli-PFFCNGHI.js +243 -0
- package/dist/cli-PNLYX6R6.js +131 -0
- package/dist/cli-PQBXVLEU.js +649 -0
- package/dist/cli-PTT5RGKO.js +62 -0
- package/dist/cli-Q2XJF5AS.js +127 -0
- package/dist/cli-QEVDDBNO.js +60 -0
- package/dist/cli-QEVE5HUM.js +167 -0
- package/dist/cli-QUIJCBYB.js +391 -0
- package/dist/cli-QUNIRH7A.js +57 -0
- package/dist/cli-QVASWX2A.js +187 -0
- package/dist/cli-QWQMPCL6.js +253 -0
- package/dist/cli-R4PCG5YX.js +131 -0
- package/dist/cli-RA673NGF.js +53 -0
- package/dist/cli-RN6IWTL2.js +36 -0
- package/dist/cli-ROT3DRKU.js +145 -0
- package/dist/cli-RZITKPJX.js +367 -0
- package/dist/cli-S5IVGDDD.js +32 -0
- package/dist/cli-S5QDONIQ.js +218 -0
- package/dist/cli-SIPDUBFL.js +36 -0
- package/dist/cli-SMFSZF2G.js +4009 -0
- package/dist/cli-SRHBXZCN.js +159 -0
- package/dist/cli-TCY5LJ7E.js +88 -0
- package/dist/cli-TDSQSCX4.js +131 -0
- package/dist/cli-TIDQ4WUE.js +257 -0
- package/dist/cli-TLLA6KAP.js +79 -0
- package/dist/cli-TPU4TUR6.js +132 -0
- package/dist/cli-U2UE7I7J.js +30 -0
- package/dist/cli-UELGBQG7.js +101 -0
- package/dist/cli-UHSZBKYO.js +97 -0
- package/dist/cli-UJ4UCL2Z.js +38 -0
- package/dist/cli-UKQYZYFK.js +31 -0
- package/dist/cli-UMFFURZ7.js +81 -0
- package/dist/cli-UNAJ2OTE.js +15 -0
- package/dist/cli-UNJ5X6BU.js +89 -0
- package/dist/cli-UTJU4IYG.js +117 -0
- package/dist/cli-V4GHRWOV.js +1837 -0
- package/dist/cli-VCI3CG36.js +73 -0
- package/dist/cli-VCKOC2EV.js +256 -0
- package/dist/cli-VL2P354N.js +46 -0
- package/dist/cli-WAE26SVW.js +72 -0
- package/dist/cli-WOGIAU2E.js +100 -0
- package/dist/cli-WU43JT4T.js +52 -0
- package/dist/cli-XCO2VQOH.js +122 -0
- package/dist/cli-XSVGKI3R.js +39 -0
- package/dist/cli-YOTGR3NB.js +82 -0
- package/dist/cli-YVVXUD2G.js +197 -0
- package/dist/cli-ZISJ36MM.js +89 -0
- package/dist/cli-ZTWOE3ZT.js +65 -0
- package/dist/cli-ZVSFYDPQ.js +205 -0
- package/dist/cli-ZWPYIXNI.js +68 -0
- package/dist/cli.js +171 -42385
- package/dist/client/build-surfaces.d.ts +33 -0
- package/dist/client/dev-server.d.ts +6 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/playwright.d.ts +62 -0
- package/dist/client.js +339 -56
- package/dist/core/session.d.ts +15 -1
- package/dist/dev/console/assets/{index-BvB-LFQZ.js → index-CuMOOH9m.js} +21 -21
- package/dist/dev/console/index.html +1 -1
- package/dist/dev/public-origins.d.ts +61 -0
- package/dist/dev/shell.d.ts +51 -4
- package/dist/dev/surfaces.d.ts +7 -0
- package/dist/docs/ai-agents.md +5 -0
- package/dist/docs/api/index.md +14 -12
- package/dist/docs/api/sdk-tools-client.md +29 -0
- package/dist/docs/api/sdk-tools-playwright.md +104 -0
- package/dist/docs/changelog-0.x.md +2 -2
- package/dist/docs/changelog.md +56 -4
- package/dist/docs/cli-and-dev-server.md +79 -0
- package/dist/docs/cli-error-codes.md +39 -36
- package/dist/docs/cli-reference.md +93 -32
- package/dist/docs/environment-variables.md +16 -5
- package/dist/docs/guides/ai-facilitation.md +2 -0
- package/dist/docs/guides/capabilities.md +2 -0
- package/dist/docs/guides/designing-a-game.md +31 -4
- package/dist/docs/guides/designing-screens.md +133 -0
- package/dist/docs/guides/endpoints.md +2 -0
- package/dist/docs/guides/engine-testing.md +5 -1
- package/dist/docs/guides/engine.md +2 -0
- package/dist/docs/guides/file-handling.md +3 -1
- 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 +4 -2
- 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 +2 -0
- package/dist/docs/guides/scenarios.md +6 -2
- 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 +2 -0
- package/dist/docs/guides/setup.md +3 -1
- package/dist/docs/guides/speech-generation.md +2 -0
- package/dist/docs/guides/starter-game.md +63 -23
- package/dist/docs/guides/testing.md +35 -18
- 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 +2 -0
- package/dist/docs/guides/waiting-room.md +1 -1
- package/dist/docs/index.md +2 -1
- package/dist/docs/page-index.md +146 -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/e2e-testing.md +19 -20
- 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/use-request-tick.md +2 -2
- package/dist/execution/config-resolver.d.ts +4 -1
- package/dist/playwright.js +32232 -0
- package/dist/runtime/manifest-version.d.ts +1 -1
- package/dist/runtime.js +1 -1
- 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/claude/rules/workflow-test-engine-or-ui.md +1 -1
- package/dist/templates/package/global-setup.ts.template +7 -18
- package/dist/templates/package/playwright.config.ts.liquid +8 -11
- 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/playwright.config.ts +8 -11
- 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 +43 -9
- package/dist/templates/starter-game/testing/e2e/global-setup.ts +7 -18
- 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/prompt.d.ts +5 -5
- package/dist/utils/resource-scan.d.ts +39 -0
- package/package.json +15 -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
|
@@ -73,6 +73,10 @@ export declare const ERROR_CODES: {
|
|
|
73
73
|
readonly category: "usage";
|
|
74
74
|
readonly description: "A file named on the command line does not exist or cannot be read.";
|
|
75
75
|
};
|
|
76
|
+
readonly DOCS_SECTION_NOT_FOUND: {
|
|
77
|
+
readonly category: "usage";
|
|
78
|
+
readonly description: "The page `docs view --section` reads has no heading by that name; the details list the ones it has.";
|
|
79
|
+
};
|
|
76
80
|
readonly RESOURCE_TYPE_UNKNOWN: {
|
|
77
81
|
readonly category: "usage";
|
|
78
82
|
readonly description: "The resource type does not exist, or does not support this operation.";
|
|
@@ -261,6 +265,10 @@ export declare const ERROR_CODES: {
|
|
|
261
265
|
readonly category: "refused";
|
|
262
266
|
readonly description: "Game logic (an engine, hook, endpoint, validator or tick controller) threw. A diagnostic, not an error code: it sits in `diagnostics` under the command's TICK_FAILED, SESSION_ERROR or HANDLER_ERROR, with the file, line and column it threw at.";
|
|
263
267
|
};
|
|
268
|
+
readonly SURFACE_NOT_RENDERED: {
|
|
269
|
+
readonly category: "refused";
|
|
270
|
+
readonly description: "`sdk screenshot` gave up on the page: its surface did not connect, or did not report its first paint before the timeout. error.details carries the page's console errors, failed requests and uncaught exceptions.";
|
|
271
|
+
};
|
|
264
272
|
readonly SETTINGS_STALE: {
|
|
265
273
|
readonly category: "refused";
|
|
266
274
|
readonly description: "The package changed on disk since the session started in a way that applies only at initialisation (a setting, a manifest field such as `teams`, or a capability removed or moved to another scope), so a command that advances or changes play was refused. Run `sdk init`.";
|
|
@@ -301,6 +309,10 @@ export declare const ERROR_CODES: {
|
|
|
301
309
|
readonly category: "environment";
|
|
302
310
|
readonly description: "The dev server could not be stopped.";
|
|
303
311
|
};
|
|
312
|
+
readonly BROWSER_MISSING: {
|
|
313
|
+
readonly category: "environment";
|
|
314
|
+
readonly description: "`sdk screenshot` found no Playwright in the package's dependencies, or no Chromium installed for it. Add `@playwright/test` and run `pnpm exec playwright install chromium`.";
|
|
315
|
+
};
|
|
304
316
|
readonly LLM_NOT_CONFIGURED: {
|
|
305
317
|
readonly category: "environment";
|
|
306
318
|
readonly description: "Logic called generateText, and the dev server or in-process session running it has no platform API key configured.";
|
package/dist/utils/prompt.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Import prompts from here, never from `@inquirer/prompts` directly.
|
|
11
11
|
*/
|
|
12
|
-
import * as
|
|
12
|
+
import type * as Inquirer from '@inquirer/prompts';
|
|
13
13
|
export declare function canPrompt(): boolean;
|
|
14
14
|
/** For tests that drive the prompts through a mock: force the gate open or shut. */
|
|
15
15
|
export declare function setInteractiveOverride(value: boolean | null): void;
|
|
@@ -20,11 +20,11 @@ export declare function setAssumeYes(value: boolean): void;
|
|
|
20
20
|
* prompt is refused.
|
|
21
21
|
*/
|
|
22
22
|
export declare function setPromptUsage(value: string | undefined): void;
|
|
23
|
-
export declare const input: typeof
|
|
24
|
-
export declare const select: typeof
|
|
25
|
-
export declare const checkbox: typeof
|
|
23
|
+
export declare const input: typeof Inquirer.input;
|
|
24
|
+
export declare const select: typeof Inquirer.select;
|
|
25
|
+
export declare const checkbox: typeof Inquirer.checkbox;
|
|
26
26
|
/** A yes/no question that is part of the input, such as 'Add another property?'. */
|
|
27
|
-
export declare const confirm: typeof
|
|
27
|
+
export declare const confirm: typeof Inquirer.confirm;
|
|
28
28
|
/**
|
|
29
29
|
* 'Are you sure?': a confirmation `--yes` answers. Without a terminal and
|
|
30
30
|
* without `--yes` it is a usage error, so a script never deletes by accident
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finding resources on disk.
|
|
3
|
+
*
|
|
4
|
+
* A package declares whatever is on disk (#431) and a resource is named by its
|
|
5
|
+
* directory (#433), so every lookup is a directory scan: there is no list to
|
|
6
|
+
* read and no bundle to open just to learn a name.
|
|
7
|
+
*
|
|
8
|
+
* A resource a game holds exactly one of lives in a fixed slot instead (#435).
|
|
9
|
+
* It has no name, so there is nothing to scan: the slot is the address.
|
|
10
|
+
*/
|
|
11
|
+
import { type ResourceMeta, type ResourceType } from '../templating/resource-metadata.js';
|
|
12
|
+
/** Where one resource's bundle sits, relative to the package root. */
|
|
13
|
+
export declare function bundlePath(meta: ResourceMeta, name?: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Where one resource's files sit inside a built package, relative to `dist/`.
|
|
16
|
+
*
|
|
17
|
+
* The built layout mirrors the authored one (#452): a resource a game holds
|
|
18
|
+
* one of sits at its slot, exactly where its author wrote it. Everything a
|
|
19
|
+
* package may hold several of keeps `<plural>/<identifier>/`, because there
|
|
20
|
+
* the type directory is what stops a hook and a scenario sharing a name from
|
|
21
|
+
* claiming the same folder.
|
|
22
|
+
*
|
|
23
|
+
* A runtime does not need to know which types are singular: manifest version 2
|
|
24
|
+
* carries them under a singular key and the rest under plural keys, so the
|
|
25
|
+
* shape it is already reading says which rule applies.
|
|
26
|
+
*/
|
|
27
|
+
export declare function distPath(meta: ResourceMeta, identifier: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Every resource of one kind on disk, in name order.
|
|
30
|
+
*
|
|
31
|
+
* A slot resource has no name, so this reports the slot when it is filled and
|
|
32
|
+
* nothing when it is not — the callers that fan out over a type still work,
|
|
33
|
+
* and the ones that need the single resource use {@link slotBundleFile}.
|
|
34
|
+
*/
|
|
35
|
+
export declare function resourceNames(packagePath: string, meta: ResourceMeta): string[];
|
|
36
|
+
/** Every bundle of one kind on disk, as package-relative paths in name order. */
|
|
37
|
+
export declare function bundlePaths(packagePath: string, meta: ResourceMeta): string[];
|
|
38
|
+
/** The absolute path to one resource's bundle, or undefined when it is absent. */
|
|
39
|
+
export declare function findBundleFile(packagePath: string, type: ResourceType, identifier?: string): string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seriousgaming/sdk-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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",
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
"types": "./dist/client/index.d.ts",
|
|
33
33
|
"default": "./dist/client.js"
|
|
34
34
|
},
|
|
35
|
+
"./playwright": {
|
|
36
|
+
"types": "./dist/client/playwright.d.ts",
|
|
37
|
+
"default": "./dist/playwright.js"
|
|
38
|
+
},
|
|
35
39
|
"./host": {
|
|
36
40
|
"types": "./dist/host/index.d.ts",
|
|
37
41
|
"default": "./dist/host.js"
|
|
@@ -70,7 +74,7 @@
|
|
|
70
74
|
"@mui/icons-material": "^9.4.0",
|
|
71
75
|
"@mui/material": "^9.4.0",
|
|
72
76
|
"@playwright/test": "^1.64.0",
|
|
73
|
-
"@seriousgaming/sdk": "1.
|
|
77
|
+
"@seriousgaming/sdk": "1.6.0",
|
|
74
78
|
"@testing-library/jest-dom": "^7.0.1",
|
|
75
79
|
"@testing-library/react": "^16.3.3",
|
|
76
80
|
"@types/adm-zip": "^0.5.8",
|
|
@@ -99,7 +103,13 @@
|
|
|
99
103
|
"vitest": "^5.0.3"
|
|
100
104
|
},
|
|
101
105
|
"peerDependencies": {
|
|
102
|
-
"@
|
|
106
|
+
"@playwright/test": ">=1.50.0",
|
|
107
|
+
"@seriousgaming/sdk": "^1.6.0"
|
|
108
|
+
},
|
|
109
|
+
"peerDependenciesMeta": {
|
|
110
|
+
"@playwright/test": {
|
|
111
|
+
"optional": true
|
|
112
|
+
}
|
|
103
113
|
},
|
|
104
114
|
"engines": {
|
|
105
115
|
"node": ">=24"
|
|
@@ -117,8 +127,9 @@
|
|
|
117
127
|
"test:run": "vitest run && vitest run --config cli/dev/console/vitest.config.ts",
|
|
118
128
|
"test:coverage": "vitest run --coverage",
|
|
119
129
|
"test:run:coverage": "vitest run --coverage && vitest run --config cli/dev/console/vitest.config.ts",
|
|
120
|
-
"test:e2e": "pnpm run test:e2e:cli && pnpm run test:integration && pnpm run test:e2e:ui",
|
|
130
|
+
"test:e2e": "pnpm run test:e2e:cli && pnpm run test:e2e:browser && pnpm run test:integration && pnpm run test:e2e:ui",
|
|
121
131
|
"test:e2e:cli": "vitest run --config e2e/vitest.e2e.config.ts",
|
|
132
|
+
"test:e2e:browser": "vitest run --config e2e/vitest.e2e.browser.config.ts",
|
|
122
133
|
"test:integration": "vitest run --config integration/vitest.integration.config.ts",
|
|
123
134
|
"test:conformance": "vitest run --config conformance/vitest.conformance.config.ts",
|
|
124
135
|
"conformance:report": "CONFORMANCE_REPORT=1 vitest run --config conformance/vitest.conformance.config.ts",
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Box, Card, CardContent, Stack, Typography } from '@mui/material';
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
type Props = {
|
|
5
|
-
title: string;
|
|
6
|
-
hint?: string;
|
|
7
|
-
action?: ReactNode;
|
|
8
|
-
children: ReactNode;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/** One card, one heading, one job. Every panel on this surface is built of these. */
|
|
12
|
-
export default function Section({ title, hint, action, children }: Props) {
|
|
13
|
-
return (
|
|
14
|
-
<Card variant="outlined">
|
|
15
|
-
<CardContent>
|
|
16
|
-
<Stack
|
|
17
|
-
direction="row"
|
|
18
|
-
spacing={2}
|
|
19
|
-
sx={{ alignItems: 'flex-start', justifyContent: 'space-between' }}
|
|
20
|
-
>
|
|
21
|
-
<Box>
|
|
22
|
-
<Typography variant="h6" component="h2">
|
|
23
|
-
{title}
|
|
24
|
-
</Typography>
|
|
25
|
-
{hint && (
|
|
26
|
-
<Typography variant="body2" color="text.secondary">
|
|
27
|
-
{hint}
|
|
28
|
-
</Typography>
|
|
29
|
-
)}
|
|
30
|
-
</Box>
|
|
31
|
-
{action}
|
|
32
|
-
</Stack>
|
|
33
|
-
<Box sx={{ mt: 2 }}>{children}</Box>
|
|
34
|
-
</CardContent>
|
|
35
|
-
</Card>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { Button, Stack, Tooltip, Typography } from '@mui/material';
|
|
2
|
-
import type { TeamLinks } from '@seriousgaming/sdk/ui';
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
|
-
|
|
6
|
-
type Props = {
|
|
7
|
-
links: TeamLinks | undefined;
|
|
8
|
-
teamName: string;
|
|
9
|
-
show: boolean;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The two ways a facilitator gets into a stall: observing, and joining.
|
|
14
|
-
*
|
|
15
|
-
* Both are one click. Reading a URL out of a table and typing it into another
|
|
16
|
-
* tab is the thing a facilitator actually does half a dozen times a session,
|
|
17
|
-
* and it is the slowest part of running one.
|
|
18
|
-
*
|
|
19
|
-
* `target="_blank"` rather than navigating this frame: a session surface owns
|
|
20
|
-
* the whole canvas, and replacing it with a player's screen would leave the
|
|
21
|
-
* facilitator with no way back. The host grants `allow-popups` and
|
|
22
|
-
* `allow-popups-to-escape-sandbox` for exactly this.
|
|
23
|
-
*
|
|
24
|
-
* The two links are not the same kind of thing, and the labels say so.
|
|
25
|
-
* Observing admits nobody: an observer has no participant record and no
|
|
26
|
-
* presence, so the stall never sees a fourth person appear. Joining is a real
|
|
27
|
-
* seat at a real stall, which is what you want when you are showing somebody
|
|
28
|
-
* how it works and not what you want when you are checking on them.
|
|
29
|
-
*/
|
|
30
|
-
export default function TeamDoor({ links, teamName, show }: Props) {
|
|
31
|
-
const { t } = useTranslation();
|
|
32
|
-
const [copied, setCopied] = useState(false);
|
|
33
|
-
const [reveal, setReveal] = useState(false);
|
|
34
|
-
|
|
35
|
-
// Empty until the host delivers them, which is one frame rather than never.
|
|
36
|
-
if (!links || !show) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const copyJoinLink = async () => {
|
|
41
|
-
// Feature-detected: `clipboard-write` is delegated to this frame, but
|
|
42
|
-
// Permissions Policy is implemented unevenly and a browser may gate the
|
|
43
|
-
// write on a gesture it does not think it had. Falling back to showing
|
|
44
|
-
// the URL is worse than copying and better than a button that does
|
|
45
|
-
// nothing.
|
|
46
|
-
try {
|
|
47
|
-
await navigator.clipboard.writeText(links.joinUrl);
|
|
48
|
-
setCopied(true);
|
|
49
|
-
setReveal(false);
|
|
50
|
-
} catch {
|
|
51
|
-
setReveal(true);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<Stack spacing={0.5}>
|
|
57
|
-
<Stack direction="row" spacing={1}>
|
|
58
|
-
<Button
|
|
59
|
-
size="small"
|
|
60
|
-
variant="outlined"
|
|
61
|
-
component="a"
|
|
62
|
-
href={links.observeUrl}
|
|
63
|
-
target="_blank"
|
|
64
|
-
rel="noopener"
|
|
65
|
-
>
|
|
66
|
-
{t('door.observe')}
|
|
67
|
-
</Button>
|
|
68
|
-
<Button
|
|
69
|
-
size="small"
|
|
70
|
-
component="a"
|
|
71
|
-
href={links.joinUrl}
|
|
72
|
-
target="_blank"
|
|
73
|
-
rel="noopener"
|
|
74
|
-
>
|
|
75
|
-
{t('door.join')}
|
|
76
|
-
</Button>
|
|
77
|
-
<Tooltip title={t('door.copyHint', { team: teamName })}>
|
|
78
|
-
<Button
|
|
79
|
-
size="small"
|
|
80
|
-
color="inherit"
|
|
81
|
-
aria-label={t('door.copy', { team: teamName })}
|
|
82
|
-
onClick={() => void copyJoinLink()}
|
|
83
|
-
onMouseLeave={() => setCopied(false)}
|
|
84
|
-
>
|
|
85
|
-
{copied ? t('door.copied') : t('door.copyShort')}
|
|
86
|
-
</Button>
|
|
87
|
-
</Tooltip>
|
|
88
|
-
</Stack>
|
|
89
|
-
{reveal && (
|
|
90
|
-
<Typography variant="caption" sx={{ fontFamily: 'monospace', userSelect: 'all' }}>
|
|
91
|
-
{links.joinUrl}
|
|
92
|
-
</Typography>
|
|
93
|
-
)}
|
|
94
|
-
</Stack>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** Display helpers shared by the panels, so one round of a number is decided once. */
|
|
2
|
-
|
|
3
|
-
export const money = (prefix: string, value: number) =>
|
|
4
|
-
`${value < 0 ? '-' : ''}${prefix}${Math.abs(Math.round(value)).toLocaleString()}`;
|
|
5
|
-
|
|
6
|
-
export const percent = (fraction: number) => `${Math.round(fraction * 100)}%`;
|
|
7
|
-
|
|
8
|
-
export const units = (value: number) => Math.round(value).toLocaleString();
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { renderUserInterface } from '@seriousgaming/sdk/ui/testing';
|
|
2
|
-
import { screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
4
|
-
|
|
5
|
-
import type { Context } from '../types';
|
|
6
|
-
import HistoryPanel from './HistoryPanel';
|
|
7
|
-
import './i18n';
|
|
8
|
-
import { baseSettings, baseContext, playedDay } from './test-helpers';
|
|
9
|
-
|
|
10
|
-
/** Day `n`'s results, as the round that closed it recorded them. */
|
|
11
|
-
function dayResults(n: number, profit: number): Context['results'] {
|
|
12
|
-
return { ...playedDay.results, Day: n, Profit: profit, Purse: profit * n };
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
describe('HistoryPanel', () => {
|
|
16
|
-
it('shows nothing before the first day has been played', () => {
|
|
17
|
-
renderUserInterface(<HistoryPanel />, { data: baseContext, settings: baseSettings });
|
|
18
|
-
|
|
19
|
-
expect(screen.queryByText('Every day so far')).not.toBeInTheDocument();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('lists the earlier days from the host, and today from live context', async () => {
|
|
23
|
-
const getPastState = vi.fn(async () => [
|
|
24
|
-
{
|
|
25
|
-
teamId: 'team-1',
|
|
26
|
-
index: 0,
|
|
27
|
-
name: 'Team 1',
|
|
28
|
-
tick: 1,
|
|
29
|
-
recordedAt: 0,
|
|
30
|
-
complete: false,
|
|
31
|
-
context: { results: dayResults(1, 100) },
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
teamId: 'team-1',
|
|
35
|
-
index: 0,
|
|
36
|
-
name: 'Team 1',
|
|
37
|
-
tick: 2,
|
|
38
|
-
recordedAt: 0,
|
|
39
|
-
complete: false,
|
|
40
|
-
context: { results: dayResults(2, 200) },
|
|
41
|
-
},
|
|
42
|
-
]);
|
|
43
|
-
|
|
44
|
-
renderUserInterface(<HistoryPanel />, {
|
|
45
|
-
data: { ...playedDay, results: dayResults(3, 300) },
|
|
46
|
-
settings: baseSettings,
|
|
47
|
-
completedTicks: 3,
|
|
48
|
-
callbacks: { getPastState: getPastState as never },
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
await waitFor(() => expect(screen.getByTestId('day-1')).toBeInTheDocument());
|
|
52
|
-
expect(screen.getByTestId('day-2')).toBeInTheDocument();
|
|
53
|
-
expect(screen.getByTestId('day-3')).toBeInTheDocument();
|
|
54
|
-
expect(getPastState).toHaveBeenCalledWith({
|
|
55
|
-
fromTick: 1,
|
|
56
|
-
toTick: 3,
|
|
57
|
-
capabilityIds: ['results'],
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('still shows today when the history cannot be read', async () => {
|
|
62
|
-
renderUserInterface(<HistoryPanel />, {
|
|
63
|
-
data: { ...playedDay, results: dayResults(2, 200) },
|
|
64
|
-
settings: baseSettings,
|
|
65
|
-
completedTicks: 2,
|
|
66
|
-
callbacks: {
|
|
67
|
-
getPastState: vi.fn(async () => Promise.reject(new Error('no'))) as never,
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
await waitFor(() => expect(screen.getByTestId('day-2')).toBeInTheDocument());
|
|
72
|
-
expect(screen.queryByTestId('day-1')).not.toBeInTheDocument();
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { Box, Table, TableBody, TableCell, TableHead, TableRow, Typography } from '@mui/material';
|
|
2
|
-
import { useUserInterfaceCallbacks, useUserInterfaceData } from '@seriousgaming/sdk/ui';
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
|
-
|
|
6
|
-
import type { Settings, Context } from '../types';
|
|
7
|
-
import { count, money } from './format';
|
|
8
|
-
import Section from './Section';
|
|
9
|
-
|
|
10
|
-
type DayResults = Context['results'];
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Every day the stall has traded, read back from the host's history.
|
|
14
|
-
*
|
|
15
|
-
* The engine keeps only today's `results` in context. Each earlier day is in
|
|
16
|
-
* the round the team closed, which `getPastState` returns, so the table asks
|
|
17
|
-
* for those and adds today's from live context. Nothing grows in context as
|
|
18
|
-
* the days go by, which is what keeps a long session cheap.
|
|
19
|
-
*
|
|
20
|
-
* The history changes only when a tick commits or is undone, and both change
|
|
21
|
-
* `completedTicks`, so that is what the fetch waits on.
|
|
22
|
-
*/
|
|
23
|
-
export default function HistoryPanel() {
|
|
24
|
-
const { data, settings, completedTicks } = useUserInterfaceData<Context, Settings>();
|
|
25
|
-
const { getPastState } = useUserInterfaceCallbacks();
|
|
26
|
-
const { t } = useTranslation();
|
|
27
|
-
const symbol = settings.ui.CurrencySymbol;
|
|
28
|
-
|
|
29
|
-
const [past, setPast] = useState<DayResults[]>([]);
|
|
30
|
-
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
if (completedTicks < 2) {
|
|
33
|
-
setPast([]);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
let cancelled = false;
|
|
37
|
-
getPastState<Context>({ fromTick: 1, toTick: completedTicks, capabilityIds: ['results'] })
|
|
38
|
-
.then((entries) => {
|
|
39
|
-
if (!cancelled) setPast(entries.map((entry) => entry.context.results));
|
|
40
|
-
})
|
|
41
|
-
// History is a nice-to-have on this screen: a failed read leaves the
|
|
42
|
-
// table showing today alone rather than an error.
|
|
43
|
-
.catch(() => {
|
|
44
|
-
if (!cancelled) setPast([]);
|
|
45
|
-
});
|
|
46
|
-
return () => {
|
|
47
|
-
cancelled = true;
|
|
48
|
-
};
|
|
49
|
-
}, [completedTicks, getPastState]);
|
|
50
|
-
|
|
51
|
-
const byDay = new Map<number, DayResults>();
|
|
52
|
-
for (const results of [...past, data.results]) {
|
|
53
|
-
if (results.Day > 0) byDay.set(results.Day, results);
|
|
54
|
-
}
|
|
55
|
-
const days = [...byDay.values()].sort((a, b) => a.Day - b.Day);
|
|
56
|
-
|
|
57
|
-
if (days.length === 0) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const best = Math.max(...days.map((day) => day.Profit));
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<Section title={t('history.title')} hint={t('history.hint')}>
|
|
65
|
-
<Box sx={{ overflowX: 'auto' }}>
|
|
66
|
-
<Table size="small">
|
|
67
|
-
<TableHead>
|
|
68
|
-
<TableRow>
|
|
69
|
-
<TableCell>{t('history.day')}</TableCell>
|
|
70
|
-
<TableCell>{t('history.weather')}</TableCell>
|
|
71
|
-
<TableCell align="right">{t('yesterday.made')}</TableCell>
|
|
72
|
-
<TableCell align="right">{t('yesterday.sold')}</TableCell>
|
|
73
|
-
<TableCell align="right">{t('yesterday.pouredAway')}</TableCell>
|
|
74
|
-
<TableCell align="right">{t('yesterday.turnedAway')}</TableCell>
|
|
75
|
-
<TableCell align="right">{t('yesterday.profit')}</TableCell>
|
|
76
|
-
<TableCell align="right">{t('yesterday.purse')}</TableCell>
|
|
77
|
-
</TableRow>
|
|
78
|
-
</TableHead>
|
|
79
|
-
<TableBody>
|
|
80
|
-
{days.map((day) => {
|
|
81
|
-
const totals = totalsOf(day);
|
|
82
|
-
return (
|
|
83
|
-
<TableRow key={day.Day} data-testid={`day-${day.Day}`}>
|
|
84
|
-
<TableCell>{day.Day}</TableCell>
|
|
85
|
-
<TableCell>
|
|
86
|
-
<Typography variant="body2">
|
|
87
|
-
{t(`weather.${day.Weather}Short`)}
|
|
88
|
-
</Typography>
|
|
89
|
-
</TableCell>
|
|
90
|
-
<TableCell align="right">{count(totals.made)}</TableCell>
|
|
91
|
-
<TableCell align="right">{count(totals.sold)}</TableCell>
|
|
92
|
-
<TableCell align="right">{count(totals.pouredAway)}</TableCell>
|
|
93
|
-
<TableCell align="right">{count(totals.turnedAway)}</TableCell>
|
|
94
|
-
<TableCell
|
|
95
|
-
align="right"
|
|
96
|
-
sx={day.Profit === best ? { fontWeight: 700 } : undefined}
|
|
97
|
-
>
|
|
98
|
-
{money(symbol, day.Profit)}
|
|
99
|
-
</TableCell>
|
|
100
|
-
<TableCell align="right">{money(symbol, day.Purse)}</TableCell>
|
|
101
|
-
</TableRow>
|
|
102
|
-
);
|
|
103
|
-
})}
|
|
104
|
-
</TableBody>
|
|
105
|
-
</Table>
|
|
106
|
-
</Box>
|
|
107
|
-
</Section>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** The day's lines, added up across the menu. */
|
|
112
|
-
function totalsOf(results: DayResults) {
|
|
113
|
-
const lines = Object.values(results.Lines);
|
|
114
|
-
return {
|
|
115
|
-
made: lines.reduce((sum, line) => sum + line.Made, 0),
|
|
116
|
-
sold: lines.reduce((sum, line) => sum + line.Sold, 0),
|
|
117
|
-
pouredAway: lines.reduce((sum, line) => sum + line.PouredAway, 0),
|
|
118
|
-
turnedAway: lines.reduce((sum, line) => sum + line.TurnedAway, 0),
|
|
119
|
-
};
|
|
120
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createMockBrand,
|
|
3
|
-
createMockUserInterfaceTheme,
|
|
4
|
-
renderUserInterface,
|
|
5
|
-
} from '@seriousgaming/sdk/ui/testing';
|
|
6
|
-
import { screen } from '@testing-library/react';
|
|
7
|
-
import { describe, expect, it } from 'vitest';
|
|
8
|
-
|
|
9
|
-
import HostLogo from './HostLogo';
|
|
10
|
-
|
|
11
|
-
describe('the host logo', () => {
|
|
12
|
-
it("shows the host's logo, named for the host", () => {
|
|
13
|
-
const brand = createMockBrand({ name: 'Northwind' });
|
|
14
|
-
renderUserInterface(<HostLogo />, { theme: createMockUserInterfaceTheme({ brand }) });
|
|
15
|
-
|
|
16
|
-
const logo = screen.getByRole('img', { name: 'Northwind' });
|
|
17
|
-
expect(logo).toHaveAttribute('src', brand.logo?.onLight);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('shows nothing when the host sends no logo', () => {
|
|
21
|
-
renderUserInterface(<HostLogo />);
|
|
22
|
-
|
|
23
|
-
expect(screen.queryByTestId('host-logo')).not.toBeInTheDocument();
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Box, useTheme } from '@mui/material';
|
|
2
|
-
import { useBrandLogo } from '@seriousgaming/sdk/ui';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The host's logo, where it sends one, so the stall sits inside whoever is
|
|
6
|
-
* running the session. Nothing at all when the host sends no logo.
|
|
7
|
-
*
|
|
8
|
-
* A host that sent only the other variant gets a panel of the colour the
|
|
9
|
-
* artwork was drawn for, rather than dark ink on a dark bar.
|
|
10
|
-
*/
|
|
11
|
-
export default function HostLogo() {
|
|
12
|
-
const logo = useBrandLogo();
|
|
13
|
-
const mode = useTheme().palette.mode;
|
|
14
|
-
if (!logo) return null;
|
|
15
|
-
|
|
16
|
-
const mismatched = logo.drawnFor !== mode;
|
|
17
|
-
return (
|
|
18
|
-
<Box
|
|
19
|
-
component="img"
|
|
20
|
-
src={logo.src}
|
|
21
|
-
alt={logo.alt}
|
|
22
|
-
data-testid="host-logo"
|
|
23
|
-
sx={{
|
|
24
|
-
height: 28,
|
|
25
|
-
maxWidth: 140,
|
|
26
|
-
objectFit: 'contain',
|
|
27
|
-
flexShrink: 0,
|
|
28
|
-
...(mismatched && {
|
|
29
|
-
bgcolor: logo.drawnFor === 'light' ? '#ffffff' : '#121212',
|
|
30
|
-
borderRadius: 1,
|
|
31
|
-
px: 1,
|
|
32
|
-
py: 0.5,
|
|
33
|
-
boxSizing: 'content-box',
|
|
34
|
-
}),
|
|
35
|
-
}}
|
|
36
|
-
/>
|
|
37
|
-
);
|
|
38
|
-
}
|