@joiner-platform/cli 0.0.0-stage → 0.1.1
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/README.md +30 -2
- package/bundled-resources/poe-tile-templates/base/CLAUDE.md +72 -0
- package/bundled-resources/poe-tile-templates/base/README.md +7 -0
- package/bundled-resources/poe-tile-templates/base/_bunfig.toml +8 -0
- package/bundled-resources/poe-tile-templates/base/_gitignore +18 -0
- package/bundled-resources/poe-tile-templates/base/client.ts +12 -0
- package/bundled-resources/poe-tile-templates/base/package.json +36 -0
- package/bundled-resources/poe-tile-templates/base/playwright.config.ts +38 -0
- package/bundled-resources/poe-tile-templates/base/scripts/check-source.ts +148 -0
- package/bundled-resources/poe-tile-templates/base/scripts/dev.ts +19 -0
- package/bundled-resources/poe-tile-templates/base/scripts/doctor.sh +29 -0
- package/bundled-resources/poe-tile-templates/base/scripts/visual-check.ts +64 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/backend-config.ts +9 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/client-config.ts +8 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/data/items.ts +16 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/index.ts +10 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/remove-todo.ts +5 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/set-todo.ts +20 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/types.ts +5 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators.test.ts +138 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/schema.ts +40 -0
- package/bundled-resources/poe-tile-templates/base/tests/e2e.test.playwright.ts +92 -0
- package/bundled-resources/poe-tile-templates/base/tests/mobile-viewport.test.playwright.ts +111 -0
- package/bundled-resources/poe-tile-templates/base/tests/render-check.test.playwright.ts +128 -0
- package/bundled-resources/poe-tile-templates/base/tests/screenshot.test.playwright.ts +86 -0
- package/bundled-resources/poe-tile-templates/base/tests/setup-dom.ts +70 -0
- package/bundled-resources/poe-tile-templates/base/tile/src/backend.ts +3 -0
- package/bundled-resources/poe-tile-templates/base/tile/styles.css +47 -0
- package/bundled-resources/poe-tile-templates/base/tsconfig.json +13 -0
- package/bundled-resources/poe-tile-templates/coverage.config.json +6 -0
- package/bundled-resources/poe-tile-templates/index.ts +27 -0
- package/bundled-resources/poe-tile-templates/package.json +31 -0
- package/bundled-resources/poe-tile-templates/phaserjs/package.partial.json +6 -0
- package/bundled-resources/poe-tile-templates/phaserjs/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/phaserjs/tile/src/entry.ts +35 -0
- package/bundled-resources/poe-tile-templates/phaserjs/ui/App.test.happydom.tsx +98 -0
- package/bundled-resources/poe-tile-templates/phaserjs/ui/App.ts +180 -0
- package/bundled-resources/poe-tile-templates/phaserjs/ui/phaser-scene.ts +174 -0
- package/bundled-resources/poe-tile-templates/phaserjs/vite.config.ts +28 -0
- package/bundled-resources/poe-tile-templates/preact/package.partial.json +9 -0
- package/bundled-resources/poe-tile-templates/preact/postcss.config.js +5 -0
- package/bundled-resources/poe-tile-templates/preact/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/preact/tile/src/entry.tsx +36 -0
- package/bundled-resources/poe-tile-templates/preact/tile/styles.css +51 -0
- package/bundled-resources/poe-tile-templates/preact/tsconfig.json +15 -0
- package/bundled-resources/poe-tile-templates/preact/ui/App.test.happydom.tsx +69 -0
- package/bundled-resources/poe-tile-templates/preact/ui/App.tsx +116 -0
- package/bundled-resources/poe-tile-templates/preact/vite.config.ts +18 -0
- package/bundled-resources/poe-tile-templates/react/package.partial.json +12 -0
- package/bundled-resources/poe-tile-templates/react/postcss.config.js +5 -0
- package/bundled-resources/poe-tile-templates/react/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/react/tile/src/entry.tsx +38 -0
- package/bundled-resources/poe-tile-templates/react/tile/styles.css +51 -0
- package/bundled-resources/poe-tile-templates/react/tsconfig.json +14 -0
- package/bundled-resources/poe-tile-templates/react/ui/App.test.happydom.tsx +71 -0
- package/bundled-resources/poe-tile-templates/react/ui/App.tsx +110 -0
- package/bundled-resources/poe-tile-templates/react/vite.config.ts +21 -0
- package/bundled-resources/poe-tile-templates/scripts/cleanup.ts +10 -0
- package/bundled-resources/poe-tile-templates/scripts/generate.ts +57 -0
- package/bundled-resources/poe-tile-templates/scripts/install-diagnostics.ts +52 -0
- package/bundled-resources/poe-tile-templates/scripts/paths.ts +7 -0
- package/bundled-resources/poe-tile-templates/scripts/sdk-dependency-key.ts +288 -0
- package/bundled-resources/poe-tile-templates/scripts/verify-all-sdks.ts +132 -0
- package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-command.ts +30 -0
- package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-tarball.ts +397 -0
- package/bundled-resources/poe-tile-templates/solidjs/_bunfig.toml +14 -0
- package/bundled-resources/poe-tile-templates/solidjs/package.partial.json +13 -0
- package/bundled-resources/poe-tile-templates/solidjs/postcss.config.js +5 -0
- package/bundled-resources/poe-tile-templates/solidjs/tests/solid-plugin.ts +49 -0
- package/bundled-resources/poe-tile-templates/solidjs/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/solidjs/tile/src/entry.tsx +36 -0
- package/bundled-resources/poe-tile-templates/solidjs/tile/styles.css +51 -0
- package/bundled-resources/poe-tile-templates/solidjs/tsconfig.json +15 -0
- package/bundled-resources/poe-tile-templates/solidjs/ui/App.test.happydom.tsx +70 -0
- package/bundled-resources/poe-tile-templates/solidjs/ui/App.tsx +129 -0
- package/bundled-resources/poe-tile-templates/solidjs/vite.config.ts +18 -0
- package/bundled-resources/poe-tile-templates/tests/check-source.test.ts +131 -0
- package/bundled-resources/poe-tile-templates/tests/dev-script.test.slow.ts +166 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/customized-manager.ts +67 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/extended-mutators.ts.txt +106 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/multiplayer-verification.test.playwright.ts.txt +103 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/replace-starter-schema.ts +67 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/phaserjs.tsx.txt +85 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/preact.tsx.txt +69 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/react.tsx.txt +73 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/seating.ts.txt +54 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/solidjs.tsx.txt +70 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/vanilla-js.tsx.txt +85 -0
- package/bundled-resources/poe-tile-templates/tests/generated-templates.test.ts +278 -0
- package/bundled-resources/poe-tile-templates/tests/happy-dom-version.test.ts +27 -0
- package/bundled-resources/poe-tile-templates/tests/install-diagnostics.test.ts +99 -0
- package/bundled-resources/poe-tile-templates/tests/native-gesture-defaults.test.ts +23 -0
- package/bundled-resources/poe-tile-templates/tests/playwright-version.test.ts +84 -0
- package/bundled-resources/poe-tile-templates/tests/render-check-scaffold.test.ts +56 -0
- package/bundled-resources/poe-tile-templates/tests/sdk-dependency-key.test.ts +129 -0
- package/bundled-resources/poe-tile-templates/tests/visual-check.test.ts +90 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/package.partial.json +3 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/tile/src/entry.ts +35 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/ui/App.test.happydom.tsx +96 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/ui/App.ts +113 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/vite.config.ts +17 -0
- package/cli.ts +134 -0
- package/index.ts +96 -0
- package/package.json +48 -5
- package/skills/audio-generation/.generated-by-poe-templated-docs +0 -0
- package/skills/audio-generation/SKILL.md +125 -0
- package/skills/finish-prototype/.generated-by-poe-templated-docs +0 -0
- package/skills/finish-prototype/SKILL.md +22 -0
- package/skills/help-me-build/.generated-by-poe-templated-docs +0 -0
- package/skills/help-me-build/SKILL.md +56 -0
- package/skills/image-generation/.generated-by-poe-templated-docs +0 -0
- package/skills/image-generation/SKILL.md +128 -0
- package/skills/one-shot/.generated-by-poe-templated-docs +0 -0
- package/skills/one-shot/SKILL.md +22 -0
- package/skills/platform-prototype/.generated-by-poe-templated-docs +0 -0
- package/skills/platform-prototype/SKILL.md +60 -0
- package/skills/platform-subagent/.generated-by-poe-templated-docs +0 -0
- package/skills/platform-subagent/SKILL.md +16 -0
- package/skills/poe-tiles-cli/.generated-by-poe-templated-docs +0 -0
- package/skills/poe-tiles-cli/SKILL.md +609 -0
- package/skills/poe-tiles-cli/references/device-motion.md +40 -0
- package/skills/poe-tiles-cli/references/player-updates.md +41 -0
- package/skills/prototype/.generated-by-poe-templated-docs +0 -0
- package/skills/prototype/SKILL.md +149 -0
- package/skills/publish/.generated-by-poe-templated-docs +0 -0
- package/skills/publish/SKILL.md +73 -0
- package/skills/synced-store/.generated-by-poe-templated-docs +0 -0
- package/skills/synced-store/SKILL.md +583 -0
- package/skills/synced-store/references/actions.md +85 -0
- package/skills/synced-store/references/api-patterns.md +245 -0
- package/skills/synced-store/references/architecture-scaling-and-performance.md +280 -0
- package/skills/synced-store/references/client-api-reference.md +263 -0
- package/skills/synced-store/references/data-visibility.md +95 -0
- package/skills/synced-store/references/external-stores.md +162 -0
- package/skills/synced-store/references/file-uploads.md +216 -0
- package/skills/synced-store/references/getting-user-info-of-members.md +228 -0
- package/skills/synced-store/references/limitations.md +72 -0
- package/skills/synced-store/references/live-data-limit-hook.md +131 -0
- package/skills/synced-store/references/mutator-rules.md +169 -0
- package/skills/synced-store/references/platform.md +49 -0
- package/skills/synced-store/references/schema-and-bindings.md +85 -0
- package/skills/synced-store/references/schema-libraries.md +57 -0
- package/skills/synced-store/references/schema-migrations.md +119 -0
- package/skills/synced-store/references/searchable-tables.md +27 -0
- package/skills/synced-store/references/server-forking.md +115 -0
- package/skills/synced-store/references/singleton-tables.md +61 -0
- package/skills/synced-store/references/sort-keys.md +253 -0
- package/skills/synced-store/references/ui-patterns.md +95 -0
- package/skills/tile-creator/.generated-by-poe-templated-docs +0 -0
- package/skills/tile-creator/SKILL.md +197 -0
- package/skills/tile-creator/references/assets.md +124 -0
- package/skills/tile-creator/references/backend-api.md +354 -0
- package/skills/tile-creator/references/cli-limitations.md +64 -0
- package/skills/tile-creator/references/cli.md +604 -0
- package/skills/tile-creator/references/client-api.md +2407 -0
- package/skills/tile-creator/references/composing-apps.md +166 -0
- package/skills/tile-creator/references/e2e-tests.md +55 -0
- package/skills/tile-creator/references/game-ux-best-practices.md +57 -0
- package/skills/tile-creator/references/migrating-pre-rename-tiles.md +79 -0
- package/skills/tile-creator/references/multiplayer-api-recipe.md +205 -0
- package/skills/tile-creator/references/native-results.md +100 -0
- package/skills/tile-creator/references/platform-integration.md +201 -0
- package/skills/tile-creator/references/power-report.md +199 -0
- package/skills/tile-creator/references/publish-rollout.md +166 -0
- package/skills/tile-creator/references/publishing.md +33 -0
- package/skills/tile-creator/references/push-notification-guidelines.md +58 -0
- package/skills/tile-creator/references/render-check.md +266 -0
- package/skills/tile-creator/references/running-the-client-api-on-a-server-owned-by-the-user.md +95 -0
- package/skills/tile-creator/references/safe-area-insets.md +79 -0
- package/skills/tile-creator/references/sandbox-limitations.md +32 -0
- package/skills/tile-creator/references/scaffolded-tile-folder-structure.md +48 -0
- package/skills/tile-creator/references/scaffolding-a-new-app.md +202 -0
- package/skills/tile-creator/references/simulations.md +125 -0
- package/skills/tile-creator/references/synced-store-client-reference.md +92 -0
- package/skills/tile-creator/references/troubleshooting.md +22 -0
- package/skills/tile-creator/references/turn-based-mutator.md +43 -0
- package/skills/tile-creator/references/user-erasure.md +14 -0
- package/skills/tile-creator/references/vite-plugin.md +166 -0
- package/skills/tile-creator/references/workspace-retention.md +72 -0
- package/src/admin-conversions-client.ts +28 -0
- package/src/admin-reviews-client.ts +36 -0
- package/src/api.generated.ts +1527 -0
- package/src/auth-token.ts +198 -0
- package/src/bounded-read.ts +35 -0
- package/src/bun-version.ts +33 -0
- package/src/checkout-base.ts +207 -0
- package/src/cli-bun-version.ts +16 -0
- package/src/cli-env.ts +28 -0
- package/src/cli-name.ts +23 -0
- package/src/client.ts +2474 -0
- package/src/collect-files.ts +226 -0
- package/src/commands/accounts.ts +55 -0
- package/src/commands/admin-abandon-conversion.ts +60 -0
- package/src/commands/admin-reviews.ts +66 -0
- package/src/commands/admin.ts +219 -0
- package/src/commands/auth.ts +89 -0
- package/src/commands/checkout-prototype.ts +67 -0
- package/src/commands/creator-source-capability.ts +11 -0
- package/src/commands/doctor-bun.ts +145 -0
- package/src/commands/doctor-command.ts +64 -0
- package/src/commands/doctor-package-json.ts +47 -0
- package/src/commands/doctor-sdk-pin.ts +156 -0
- package/src/commands/doctor-store-keys-lexer.ts +213 -0
- package/src/commands/doctor-store-keys-scan.ts +262 -0
- package/src/commands/doctor-store-keys.ts +196 -0
- package/src/commands/doctor.ts +371 -0
- package/src/commands/init/blank-scaffold-templates.ts +397 -0
- package/src/commands/init/index.ts +170 -0
- package/src/commands/init/internal-toolchain.ts +49 -0
- package/src/commands/init/manager-test-template.ts +107 -0
- package/src/commands/init/multiplayer-test-template.ts +217 -0
- package/src/commands/init/name-input.tsx +167 -0
- package/src/commands/init/no-store-scaffold-templates.ts +281 -0
- package/src/commands/init/no-store-scaffold.ts +134 -0
- package/src/commands/init/package-json-scripts.ts +72 -0
- package/src/commands/init/scaffold.ts +960 -0
- package/src/commands/init/sdk-tarball-url.generated.ts +4 -0
- package/src/commands/init/sdk-tarball-url.ts +31 -0
- package/src/commands/init/template-picker.tsx +147 -0
- package/src/commands/inspect-child-entry.ts +107 -0
- package/src/commands/inspect-contract.ts +87 -0
- package/src/commands/inspect-freshness.ts +217 -0
- package/src/commands/inspect-lock.ts +201 -0
- package/src/commands/inspect-options.ts +360 -0
- package/src/commands/inspect-orchestrate.ts +375 -0
- package/src/commands/inspect-process.ts +172 -0
- package/src/commands/inspect-ready.ts +65 -0
- package/src/commands/inspect-report.ts +235 -0
- package/src/commands/inspect-run-state.ts +296 -0
- package/src/commands/inspect-run.ts +157 -0
- package/src/commands/inspect-watchdog.ts +74 -0
- package/src/commands/install-joiner.ts +208 -0
- package/src/commands/login.ts +308 -0
- package/src/commands/models.ts +40 -0
- package/src/commands/parse-options.ts +36 -0
- package/src/commands/remix-package-json.ts +64 -0
- package/src/commands/remix.ts +379 -0
- package/src/commands/sdk-url.ts +141 -0
- package/src/commands/simulations.ts +133 -0
- package/src/commands/skills.ts +108 -0
- package/src/commands/store-files.ts +92 -0
- package/src/commands/stores.ts +703 -0
- package/src/commands/tiles-channel-commands.ts +115 -0
- package/src/commands/tiles-checkout.ts +351 -0
- package/src/commands/tiles-gallery-command.ts +95 -0
- package/src/commands/tiles-get-helpers.ts +27 -0
- package/src/commands/tiles-inspect.ts +276 -0
- package/src/commands/tiles-power-command.ts +308 -0
- package/src/commands/tiles-power-format.ts +396 -0
- package/src/commands/tiles-power-versions.ts +299 -0
- package/src/commands/tiles-publish-helpers.ts +145 -0
- package/src/commands/tiles-upload-command.ts +277 -0
- package/src/commands/tiles-version-commands.ts +201 -0
- package/src/commands/tiles-visibility-command.ts +103 -0
- package/src/commands/tiles.ts +257 -0
- package/src/commands/upgrade.ts +307 -0
- package/src/commit-in-progress.ts +42 -0
- package/src/creator-source-context.ts +97 -0
- package/src/creator-source-publish.ts +52 -0
- package/src/deferred-assets.ts +125 -0
- package/src/distribution.ts +28 -0
- package/src/errors.ts +61 -0
- package/src/install-command.ts +43 -0
- package/src/output.ts +62 -0
- package/src/poe-tile-config-files.ts +100 -0
- package/src/poe-tile-config-players.ts +168 -0
- package/src/poe-tile-config-remix.ts +166 -0
- package/src/poe-tile-config.ts +831 -0
- package/src/power-report-client.ts +55 -0
- package/src/prototype-startup.ts +21 -0
- package/src/publish-change-summary.ts +55 -0
- package/src/publish-overrides-validation.ts +49 -0
- package/src/publish-pack.ts +167 -0
- package/src/publish-phases.ts +57 -0
- package/src/publish-retry.ts +51 -0
- package/src/publish-tile-from-config.ts +434 -0
- package/src/recorder-stream.ts +169 -0
- package/src/remix-provenance.ts +156 -0
- package/src/resolve-client-credential.ts +71 -0
- package/src/resolve-media-uploads.ts +147 -0
- package/src/sdk-dependency.ts +54 -0
- package/src/sdk-skills.ts +85 -0
- package/src/should-skip-client-setup.ts +20 -0
- package/src/simulation-snapshot.ts +123 -0
- package/src/simulation-types.ts +74 -0
- package/src/simulations-client.ts +112 -0
- package/src/source-bundle.ts +466 -0
- package/src/staged-publish-cleanup.ts +44 -0
- package/src/staged-publish-deferred.ts +160 -0
- package/src/staged-publish.ts +401 -0
- package/src/store-file-upload.ts +268 -0
- package/src/store-request.ts +168 -0
- package/src/tar-canonical.ts +41 -0
- package/src/tar-extensions.ts +159 -0
- package/src/tar-extract.ts +193 -0
- package/src/tar-parse.ts +224 -0
- package/src/tar.ts +231 -0
- package/src/template-check-scripts.ts +18 -0
- package/src/tile-gallery-client.ts +82 -0
- package/src/types.ts +258 -0
- package/src/upload-concurrency.ts +54 -0
- package/src/whole-tile.ts +52 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// owner: aroe
|
|
2
|
+
/**
|
|
3
|
+
* Player-count config field for `.poe-tile.json` (v5+), split out of
|
|
4
|
+
* `poe-tile-config.ts` so the validator stays in a focused companion file.
|
|
5
|
+
*
|
|
6
|
+
* The {@link TilePlayerCount} type, the {@link MAX_PLAYERS} /
|
|
7
|
+
* {@link PLAYERS_FIELD_MAX_BYTES} caps, and {@link normalizePlayerCount} are
|
|
8
|
+
* INLINED copies of the canonical definitions in `@lib/tile-registry`
|
|
9
|
+
* (`tile-registry-interface.ts` + `players-codec.ts`). The CLI deliberately
|
|
10
|
+
* carries no `workspace:*` runtime deps (see `packaging.test.ts`), exactly
|
|
11
|
+
* like the inlined `TILE_HANDLE_REGEX` / `DISPLAY_NAME_MAX_LENGTH`. Drift
|
|
12
|
+
* between this copy and the upstream canonical value/behavior is caught by
|
|
13
|
+
* `workspace-sync.test.ts`, which imports both and compares them.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A tile's player-count facet. `max` absent means "no creator-declared upper
|
|
18
|
+
* bound" (an open/party tile); `recommended` ⊆ `[min, max ?? MAX_PLAYERS]`.
|
|
19
|
+
* Counts total seats (humans + AI). Mirrors `TilePlayerCount` in
|
|
20
|
+
* `@lib/tile-registry`.
|
|
21
|
+
*/
|
|
22
|
+
export type TilePlayerCount = {
|
|
23
|
+
min: number;
|
|
24
|
+
max?: number;
|
|
25
|
+
recommended?: { min: number; max: number };
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Maximum total seats a tile may declare. Inlined from
|
|
30
|
+
* `@lib/tile-registry` (`MAX_PLAYERS`); drift-guarded by
|
|
31
|
+
* `workspace-sync.test.ts`.
|
|
32
|
+
*/
|
|
33
|
+
export const MAX_PLAYERS = 1000;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Raw byte cap on the serialized `players` value. Inlined from
|
|
37
|
+
* `@lib/tile-registry` (`PLAYERS_FIELD_MAX_BYTES`); drift-guarded by
|
|
38
|
+
* `workspace-sync.test.ts`. The CLI caps `JSON.stringify(players)` against
|
|
39
|
+
* this — there is no separate pre-parse point because `readPoeTileConfig`
|
|
40
|
+
* parses the whole config document up front.
|
|
41
|
+
*/
|
|
42
|
+
export const PLAYERS_FIELD_MAX_BYTES = 256;
|
|
43
|
+
|
|
44
|
+
function isPositiveInt(value: unknown): value is number {
|
|
45
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Validate `min`: a positive integer no greater than {@link MAX_PLAYERS}. */
|
|
49
|
+
function parsePlayersMin(obj: Record<string, unknown>): number {
|
|
50
|
+
const min = obj["min"];
|
|
51
|
+
if (!isPositiveInt(min) || min > MAX_PLAYERS) {
|
|
52
|
+
throw new Error(`players.min must be an integer in 1..${MAX_PLAYERS}.`);
|
|
53
|
+
}
|
|
54
|
+
return min;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Validate optional `max`: a positive integer in `min..MAX_PLAYERS`; absent = no cap. */
|
|
58
|
+
function parsePlayersMax(
|
|
59
|
+
obj: Record<string, unknown>,
|
|
60
|
+
min: number,
|
|
61
|
+
): number | undefined {
|
|
62
|
+
const max = obj["max"];
|
|
63
|
+
if (max === undefined) return undefined;
|
|
64
|
+
if (!isPositiveInt(max) || max < min || max > MAX_PLAYERS) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`players.max, when set, must be an integer in ${min}..${MAX_PLAYERS} (>= min).`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return max;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Validate optional `recommended`: `{ min, max }` positive integers satisfying
|
|
74
|
+
* `min <= recommended.min <= recommended.max <= upper` (upper = `max ?? MAX_PLAYERS`).
|
|
75
|
+
*/
|
|
76
|
+
function parsePlayersRecommended(
|
|
77
|
+
obj: Record<string, unknown>,
|
|
78
|
+
min: number,
|
|
79
|
+
upper: number,
|
|
80
|
+
): { min: number; max: number } | undefined {
|
|
81
|
+
const rawRec = obj["recommended"];
|
|
82
|
+
if (rawRec === undefined) return undefined;
|
|
83
|
+
if (typeof rawRec !== "object" || rawRec === null || Array.isArray(rawRec)) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
"players.recommended, when set, must be an object { min, max }.",
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
const rec = rawRec as Record<string, unknown>;
|
|
89
|
+
const recMin = rec["min"];
|
|
90
|
+
const recMax = rec["max"];
|
|
91
|
+
if (!isPositiveInt(recMin) || !isPositiveInt(recMax)) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
"players.recommended.min and players.recommended.max must be positive integers.",
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
if (!(min <= recMin && recMin <= recMax && recMax <= upper)) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
`players.recommended must satisfy min <= recommended.min <= recommended.max <= ${upper}.`,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return { min: recMin, max: recMax };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Validate an unknown value as a {@link TilePlayerCount} and return a clean,
|
|
106
|
+
* canonical copy (fresh objects, only `min` / `max` / `recommended`). Throws
|
|
107
|
+
* with a field-pathed message on any invariant violation.
|
|
108
|
+
*
|
|
109
|
+
* INLINED copy of `normalizePlayerCount` in `@lib/tile-registry`; kept
|
|
110
|
+
* behaviorally identical (drift-guarded by `workspace-sync.test.ts`).
|
|
111
|
+
*/
|
|
112
|
+
export function normalizePlayerCount(value: unknown): TilePlayerCount {
|
|
113
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
114
|
+
throw new Error("players must be an object { min, max?, recommended? }.");
|
|
115
|
+
}
|
|
116
|
+
const obj = value as Record<string, unknown>;
|
|
117
|
+
const min = parsePlayersMin(obj);
|
|
118
|
+
const max = parsePlayersMax(obj, min);
|
|
119
|
+
const recommended = parsePlayersRecommended(obj, min, max ?? MAX_PLAYERS);
|
|
120
|
+
return {
|
|
121
|
+
min,
|
|
122
|
+
...(max !== undefined ? { max } : {}),
|
|
123
|
+
...(recommended !== undefined ? { recommended } : {}),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Validate the optional `.poe-tile.json` `players` field. Returns the
|
|
129
|
+
* canonical {@link TilePlayerCount} when set, `null` when the creator wrote
|
|
130
|
+
* the explicit clear sentinel (`"players": null`), or `undefined` when the
|
|
131
|
+
* field is absent (preserve-on-republish).
|
|
132
|
+
*
|
|
133
|
+
* Throws when `players` is present under a pre-v5 `$schema` (a loud "bump to
|
|
134
|
+
* v5" error — never a silent drop), when the serialized value exceeds
|
|
135
|
+
* {@link PLAYERS_FIELD_MAX_BYTES}, or when it fails {@link normalizePlayerCount}.
|
|
136
|
+
* Callers prepend the config-file context to the thrown message.
|
|
137
|
+
*/
|
|
138
|
+
export function parsePlayersConfigField(opts: {
|
|
139
|
+
raw: unknown;
|
|
140
|
+
schemaSupportsPlayers: boolean;
|
|
141
|
+
configFilename: string;
|
|
142
|
+
schemaUrl: string;
|
|
143
|
+
}): TilePlayerCount | null | undefined {
|
|
144
|
+
const { raw, schemaSupportsPlayers, configFilename, schemaUrl } = opts;
|
|
145
|
+
if (raw === undefined) return undefined;
|
|
146
|
+
if (!schemaSupportsPlayers) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
`${configFilename}.players requires $schema ${JSON.stringify(schemaUrl)} (v5). Bump the $schema URL to use players — it is not supported under the v2/v3/v4 schemas.`,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
// `null` is the explicit clear sentinel (un-declare on republish).
|
|
152
|
+
if (raw === null) return null;
|
|
153
|
+
const serializedBytes = new TextEncoder().encode(
|
|
154
|
+
JSON.stringify(raw),
|
|
155
|
+
).byteLength;
|
|
156
|
+
if (serializedBytes > PLAYERS_FIELD_MAX_BYTES) {
|
|
157
|
+
throw new Error(
|
|
158
|
+
`${configFilename}.players is ${serializedBytes} bytes serialized; the maximum is ${PLAYERS_FIELD_MAX_BYTES}.`,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
try {
|
|
162
|
+
return normalizePlayerCount(raw);
|
|
163
|
+
} catch (err) {
|
|
164
|
+
throw new Error(
|
|
165
|
+
`${configFilename}.${err instanceof Error ? err.message : String(err)}`,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// owner: jyoung-q
|
|
2
|
+
/**
|
|
3
|
+
* Remix-provenance config field for `.poe-tile.json` (v9+), split out of
|
|
4
|
+
* `poe-tile-config.ts` so the validator stays in a focused companion file
|
|
5
|
+
* (mirrors `poe-tile-config-players.ts`).
|
|
6
|
+
*
|
|
7
|
+
* {@link SOURCE_BUNDLE_ID_MAX_LENGTH}, {@link REMIX_OF_FIELD_MAX_BYTES}, and
|
|
8
|
+
* {@link normalizeRemixSource} are INLINED copies of the canonical definitions
|
|
9
|
+
* in `@lib/tile-registry` (`tile-registry-interface.ts` +
|
|
10
|
+
* `remix-source-codec.ts`). The CLI deliberately carries no `workspace:*`
|
|
11
|
+
* runtime deps (see `packaging.test.ts`), exactly like the inlined
|
|
12
|
+
* players/handle copies. Drift between this copy and the upstream
|
|
13
|
+
* canonical value/behavior is caught by `workspace-sync.test.ts`, which
|
|
14
|
+
* imports both and compares them.
|
|
15
|
+
*
|
|
16
|
+
* This validates SHAPE only — and so does the server. Whether the claim is
|
|
17
|
+
* TRUE is checked nowhere: a creator can hand-write any `remixOf` they like
|
|
18
|
+
* and it will be stored. That is safe because the credit renders only on the
|
|
19
|
+
* declaring app's own detail page, never on the named app's.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** Inlined from `@lib/tile-registry` (`TILE_HANDLE_MAX_LENGTH`); drift-guarded. */
|
|
23
|
+
const REMIX_SOURCE_TILE_ID_MAX_LENGTH = 100;
|
|
24
|
+
|
|
25
|
+
/** Inlined from `@lib/tile-registry` (`SOURCE_BUNDLE_ID_MAX_LENGTH`); drift-guarded. */
|
|
26
|
+
export const SOURCE_BUNDLE_ID_MAX_LENGTH = 128;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Raw byte cap on the serialized `remixOf` value. Inlined from
|
|
30
|
+
* `@lib/tile-registry` (`REMIX_OF_FIELD_MAX_BYTES`); drift-guarded by
|
|
31
|
+
* `workspace-sync.test.ts`. The CLI caps `JSON.stringify(remixOf)` against
|
|
32
|
+
* this — there is no separate pre-parse point because `readPoeTileConfig`
|
|
33
|
+
* parses the whole config document up front.
|
|
34
|
+
*/
|
|
35
|
+
export const REMIX_OF_FIELD_MAX_BYTES = 512;
|
|
36
|
+
|
|
37
|
+
const SOURCE_BUNDLE_ID_PATTERN = /^[a-f0-9]+$/;
|
|
38
|
+
|
|
39
|
+
const REMIX_OF_FIELDS = ["tileId", "versionNumber", "sourceBundleId"] as const;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The published Tile — and the exact publish of it — this app was remixed
|
|
43
|
+
* from. Mirrors `TileRemixSource` in `@lib/tile-registry`.
|
|
44
|
+
*/
|
|
45
|
+
export type PoeTileConfigRemixOf = {
|
|
46
|
+
/** Registry id of the Tile this one was remixed from. */
|
|
47
|
+
tileId: string;
|
|
48
|
+
/** The source Tile's publish version number at the branch point. */
|
|
49
|
+
versionNumber: number;
|
|
50
|
+
/** Content-addressed source-bundle id (hex digest) at the branch point. */
|
|
51
|
+
sourceBundleId: string;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
function requireNonEmptyString(
|
|
55
|
+
value: unknown,
|
|
56
|
+
field: string,
|
|
57
|
+
maxLength: number,
|
|
58
|
+
): string {
|
|
59
|
+
if (typeof value !== "string") {
|
|
60
|
+
throw new Error(`remixOf.${field} must be a string.`);
|
|
61
|
+
}
|
|
62
|
+
const trimmed = value.trim();
|
|
63
|
+
if (trimmed.length === 0) {
|
|
64
|
+
throw new Error(`remixOf.${field} must not be empty.`);
|
|
65
|
+
}
|
|
66
|
+
if (trimmed.length > maxLength) {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`remixOf.${field} must be at most ${maxLength} characters.`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return trimmed;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Validate an unknown value as a remix-source declaration and return a fresh,
|
|
76
|
+
* canonical copy. Throws with a field-pathed message on any violation.
|
|
77
|
+
*
|
|
78
|
+
* INLINED copy of `normalizeRemixSource` in `@lib/tile-registry`; kept
|
|
79
|
+
* behaviorally identical (drift-guarded by `workspace-sync.test.ts`).
|
|
80
|
+
*/
|
|
81
|
+
export function normalizeRemixSource(value: unknown): PoeTileConfigRemixOf {
|
|
82
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
"remixOf must be a JSON object with tileId, versionNumber, and sourceBundleId.",
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
const raw = value as Record<string, unknown>;
|
|
88
|
+
const unknownKeys = Object.keys(raw).filter(
|
|
89
|
+
(key) => !REMIX_OF_FIELDS.includes(key as (typeof REMIX_OF_FIELDS)[number]),
|
|
90
|
+
);
|
|
91
|
+
if (unknownKeys.length > 0) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`remixOf has unknown field(s): ${unknownKeys.sort().join(", ")}.`,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const tileId = requireNonEmptyString(
|
|
98
|
+
raw["tileId"],
|
|
99
|
+
"tileId",
|
|
100
|
+
REMIX_SOURCE_TILE_ID_MAX_LENGTH,
|
|
101
|
+
);
|
|
102
|
+
const versionNumber = raw["versionNumber"];
|
|
103
|
+
if (
|
|
104
|
+
typeof versionNumber !== "number" ||
|
|
105
|
+
!Number.isSafeInteger(versionNumber) ||
|
|
106
|
+
versionNumber < 1
|
|
107
|
+
) {
|
|
108
|
+
throw new Error("remixOf.versionNumber must be a positive integer.");
|
|
109
|
+
}
|
|
110
|
+
const sourceBundleId = requireNonEmptyString(
|
|
111
|
+
raw["sourceBundleId"],
|
|
112
|
+
"sourceBundleId",
|
|
113
|
+
SOURCE_BUNDLE_ID_MAX_LENGTH,
|
|
114
|
+
).toLowerCase();
|
|
115
|
+
if (!SOURCE_BUNDLE_ID_PATTERN.test(sourceBundleId)) {
|
|
116
|
+
throw new Error(
|
|
117
|
+
"remixOf.sourceBundleId must be a lowercase hex content-addressed id.",
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return { tileId, versionNumber, sourceBundleId };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Validate the optional `.poe-tile.json` `remixOf` field. Returns the
|
|
126
|
+
* canonical object when set, `null` when the creator wrote the explicit clear
|
|
127
|
+
* sentinel (`"remixOf": null`), or `undefined` when the field is absent
|
|
128
|
+
* (preserve-on-republish).
|
|
129
|
+
*
|
|
130
|
+
* Throws when `remixOf` is present under a pre-v9 `$schema` (a loud "bump to
|
|
131
|
+
* v9" error — never a silent drop), when the serialized value exceeds
|
|
132
|
+
* {@link REMIX_OF_FIELD_MAX_BYTES}, or when it fails
|
|
133
|
+
* {@link normalizeRemixSource}. Callers prepend the config-file context to the
|
|
134
|
+
* thrown message.
|
|
135
|
+
*/
|
|
136
|
+
export function parseRemixOfConfigField(opts: {
|
|
137
|
+
raw: unknown;
|
|
138
|
+
schemaSupportsRemixOf: boolean;
|
|
139
|
+
configFilename: string;
|
|
140
|
+
schemaUrl: string;
|
|
141
|
+
}): PoeTileConfigRemixOf | null | undefined {
|
|
142
|
+
const { raw, schemaSupportsRemixOf, configFilename, schemaUrl } = opts;
|
|
143
|
+
if (raw === undefined) return undefined;
|
|
144
|
+
if (!schemaSupportsRemixOf) {
|
|
145
|
+
throw new Error(
|
|
146
|
+
`${configFilename}.remixOf requires $schema ${JSON.stringify(schemaUrl)} (v9). Bump the $schema URL to use remixOf — it is not supported under the v2–v8 schemas.`,
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
// `null` is the explicit clear sentinel (drop the attribution on republish).
|
|
150
|
+
if (raw === null) return null;
|
|
151
|
+
const serializedBytes = new TextEncoder().encode(
|
|
152
|
+
JSON.stringify(raw),
|
|
153
|
+
).byteLength;
|
|
154
|
+
if (serializedBytes > REMIX_OF_FIELD_MAX_BYTES) {
|
|
155
|
+
throw new Error(
|
|
156
|
+
`${configFilename}.remixOf is ${serializedBytes} bytes serialized; the maximum is ${REMIX_OF_FIELD_MAX_BYTES}.`,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
return normalizeRemixSource(raw);
|
|
161
|
+
} catch (err) {
|
|
162
|
+
throw new Error(
|
|
163
|
+
`${configFilename}.${err instanceof Error ? err.message : String(err)}`,
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
}
|