container/viewer
2026-11-18 21:57:16 +00:00
..
.vscode Add continuous integration 2021-07-04 00:06:50 +02:00
scripts Integrate Offshore bank into SVG board and migrate viewer to Vite 2026-11-18 21:57:16 +00:00
src Integrate Offshore bank into SVG board and migrate viewer to Vite 2026-11-18 21:57:16 +00:00
tests Integrate Offshore bank into SVG board and migrate viewer to Vite 2026-11-18 21:57:16 +00:00
.browserslistrc Move viewer into own folder 2021-07-03 21:27:24 +02:00
.eslintrc.js Add continuous integration 2021-07-04 00:06:50 +02:00
.gitignore ✨ (viewer) Enable loading game directly from json file 2021-10-14 22:23:29 +02:00
index.html Integrate Offshore bank into SVG board and migrate viewer to Vite 2026-11-18 21:57:16 +00:00
package.json Integrate Offshore bank into SVG board and migrate viewer to Vite 2026-11-18 21:57:16 +00:00
README.md Integrate Offshore bank into SVG board and migrate viewer to Vite 2026-11-18 21:57:16 +00:00
tsconfig.json Integrate Offshore bank into SVG board and migrate viewer to Vite 2026-11-18 21:57:16 +00:00
vite.config.ts Integrate Offshore bank into SVG board and migrate viewer to Vite 2026-11-18 21:57:16 +00:00

Container viewer

Use Node.js 24 and pnpm 11. From the repository root, install with pnpm install --frozen-lockfile. The workspace explicitly permits esbuild's required platform-binary installation script.

Local development

pnpm --dir viewer serve

Add ?offshoreIsland=1 to opt into Offshore Island in the local demo. Without that query parameter the demo remains classic. The expansion panel displays public auctions, escrow and holding areas; its bid, return-price, distribution, default and loading controls follow the engine's legal moves.

Add ?chapter=supply-chain to open a tutorial. The other chapter IDs are buildings, selling, bidding, keep-cargo and scoring.

Build and check

pnpm --dir viewer check
pnpm --dir viewer test:tutorial
pnpm --dir viewer test:unit
pnpm --dir viewer build
pnpm --dir viewer package
pnpm --dir viewer test:browser
pnpm --dir viewer test:offshore:browser
pnpm --dir viewer test:tutorial:browser

Browser checks use Playwright Chromium. Set CHROMIUM_EXECUTABLE if using an existing installation. pnpm --dir viewer preview:tutorial serves the built viewer on port 5197.

The Vue 2 type checker needs zod available directly in this workspace to resolve the protocol's schema types through pnpm's symlinks. It is a development dependency.

Package compatibility

The Vue 2 viewer uses Vite for development and builds; no OpenSSL legacy provider or Vue CLI setup is needed. build produces the standalone demo, while package produces the classic-script UMD viewer for BGS.

Load Vue 2 before dist/container-viewer.umd.min.js and include dist/container-viewer.css separately; the bundle does not inject CSS. The existing container.launch and container.launchTutorial globals are retained. Deploy the matching container-viewer.umd.min.locale-*.js sidecars beside the minified entry, keeping their filenames: non-English translations are loaded lazily as native ES modules relative to that script URL. Serve them with a JavaScript MIME type and allow CORS when hosting assets on another origin. English is bundled. The readable container-viewer.umd.js build uses its own container-viewer.umd.locale-*.js sidecars. Publish/deploy JS, CSS and matching sidecars together (do not upload only the entry bundle).

Tutorials on BGS

Upload the same JS, CSS and locale sidecars as the ordinary viewer. The container global exposes both launch and launchTutorial. Chapter metadata is exported as chapterCards from src/tutorial/lessons.ts; enter these IDs, versions, titles and descriptions in the BGS version's Tutorial settings.

Lessons run the real engine locally with deterministic opponents and private player views. The extra lesson controls make drag actions accessible on mobile. Chapter progress survives refresh. Playback controls return to the previous step, replay the current step or go back to the start. No live game or chat messages are sent.

Shared accessibility preference

The viewer follows BGS's boolean colorBlind preference (default false). Its eye icon updates the same shared preference through update:preference. Shapes identify container colours across pieces, factories, value cards, trade controls, tutorials and the journal. Player numbers match ships, boards and island rows. No engine state or colour identifiers are changed.

Register { "name": "colorBlind", "label": "Color-blind mode", "type": "checkbox", "default": false } in the BGS viewer preferences.