@joiner-platform/cli 0.0.0-stage → 0.1.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/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 +148 -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 +196 -0
- package/skills/tile-creator/references/assets.md +124 -0
- package/skills/tile-creator/references/backend-api.md +308 -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,47 @@
|
|
|
1
|
+
*,
|
|
2
|
+
*::before,
|
|
3
|
+
*::after {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
:root {
|
|
8
|
+
color-scheme: light dark;
|
|
9
|
+
--app-bg-base: #f8f9fa;
|
|
10
|
+
--app-fg-base: #1f2937;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@media (prefers-color-scheme: dark) {
|
|
14
|
+
:root {
|
|
15
|
+
--app-bg-base: #101012;
|
|
16
|
+
--app-fg-base: #f8fafc;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
html,
|
|
21
|
+
body {
|
|
22
|
+
height: 100dvh;
|
|
23
|
+
margin: 0;
|
|
24
|
+
padding: 0;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
body {
|
|
29
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
30
|
+
background-color: var(--app-bg-base);
|
|
31
|
+
color: var(--app-fg-base);
|
|
32
|
+
-webkit-tap-highlight-color: transparent;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#root {
|
|
36
|
+
height: 100dvh;
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
overflow-y: auto;
|
|
40
|
+
padding-top: var(--poe-safe-area-inset-top, env(safe-area-inset-top));
|
|
41
|
+
padding-left: var(--poe-safe-area-inset-left, env(safe-area-inset-left));
|
|
42
|
+
padding-right: var(--poe-safe-area-inset-right, env(safe-area-inset-right));
|
|
43
|
+
padding-bottom: var(
|
|
44
|
+
--poe-safe-area-inset-bottom,
|
|
45
|
+
env(safe-area-inset-bottom)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"allowImportingTsExtensions": true,
|
|
10
|
+
"types": ["bun-types", "vite/client", "joiner-sdk/vite-client"]
|
|
11
|
+
},
|
|
12
|
+
"include": ["tile/src", "synced-store", "ui", "tests", "client.ts"]
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// owner: jyoung-q
|
|
2
|
+
/**
|
|
3
|
+
* Poe app templates for scaffolding new apps.
|
|
4
|
+
*
|
|
5
|
+
* Exports template names and a function to resolve template directories.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { resolve } from "node:path";
|
|
9
|
+
|
|
10
|
+
export const TEMPLATES = [
|
|
11
|
+
"react",
|
|
12
|
+
"vanilla-js",
|
|
13
|
+
"solidjs",
|
|
14
|
+
"preact",
|
|
15
|
+
"phaserjs",
|
|
16
|
+
] as const;
|
|
17
|
+
export type TemplateName = (typeof TEMPLATES)[number];
|
|
18
|
+
|
|
19
|
+
/** Resolve the base template directory. */
|
|
20
|
+
export function baseTemplateDir(): string {
|
|
21
|
+
return resolve(import.meta.dir, "base");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Resolve a framework-specific template directory. */
|
|
25
|
+
export function frameworkTemplateDir(template: TemplateName): string {
|
|
26
|
+
return resolve(import.meta.dir, template);
|
|
27
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@poe-tile/templates",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "index.ts",
|
|
6
|
+
"types": "index.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./index.ts",
|
|
10
|
+
"default": "./index.ts"
|
|
11
|
+
},
|
|
12
|
+
"./test-utils/customized-manager": "./tests/fixtures/customized-manager.ts"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"generate-test-apps": "bun scripts/generate.ts && bun install --ignore-scripts --no-save",
|
|
16
|
+
"generate:cleanup": "bun scripts/cleanup.ts",
|
|
17
|
+
"test": "bun test tests/check-source.test.ts tests/playwright-version.test.ts tests/happy-dom-version.test.ts tests/native-gesture-defaults.test.ts tests/visual-check.test.ts tests/install-diagnostics.test.ts tests/render-check-scaffold.test.ts tests/sdk-dependency-key.test.ts",
|
|
18
|
+
"test:generated": "bun test tests/generated-templates.test.ts",
|
|
19
|
+
"test:generated:packaged-sdk": "bun scripts/verify-local-sdk-tarball.ts",
|
|
20
|
+
"test:slow": "bun run generate-test-apps && bun test ./tests/*.test.slow.ts --reporter=junit --reporter-outfile=junit-slow.xml",
|
|
21
|
+
"verify:all-sdks": "bun scripts/verify-all-sdks.ts",
|
|
22
|
+
"lint": "biome lint --error-on-warnings .",
|
|
23
|
+
"format:check": "biome format ."
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/bun": "^1"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"typescript": "^6 || ^7"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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, viewport-fit=cover">
|
|
6
|
+
<meta name="color-scheme" content="light dark">
|
|
7
|
+
<title>{{APP_NAME}}</title>
|
|
8
|
+
<link rel="stylesheet" href="styles.css">
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="root"></div>
|
|
12
|
+
<script type="module" src="src/entry.ts"></script>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry point — the only file that imports joiner-sdk.
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
applyNativeAppGestureOverrides,
|
|
6
|
+
createPoe,
|
|
7
|
+
createVerticalScrollBounceMount,
|
|
8
|
+
PostMessageEnvironment,
|
|
9
|
+
} from "joiner-sdk/v1/client.js";
|
|
10
|
+
import { todoClientConfig } from "../../client";
|
|
11
|
+
import { createApp } from "../../ui/App";
|
|
12
|
+
|
|
13
|
+
applyNativeAppGestureOverrides();
|
|
14
|
+
|
|
15
|
+
const environment = new PostMessageEnvironment();
|
|
16
|
+
const Poe = createPoe({ environment });
|
|
17
|
+
const store = Poe.setupStore(todoClientConfig);
|
|
18
|
+
|
|
19
|
+
const root = document.getElementById("root");
|
|
20
|
+
if (root) {
|
|
21
|
+
// Wait for authoritative data (cached locally OR first server pull —
|
|
22
|
+
// whichever wins) before mounting so the UI never paints with empty
|
|
23
|
+
// state on revisit. Resolves immediately when the host sets
|
|
24
|
+
// `is-new` on the parent <poe-tile>, since a fresh instance has no
|
|
25
|
+
// data to load.
|
|
26
|
+
void store.waitForBootstrap().then(
|
|
27
|
+
() => {
|
|
28
|
+
const appRoot = createVerticalScrollBounceMount(root);
|
|
29
|
+
createApp(appRoot, store);
|
|
30
|
+
},
|
|
31
|
+
() => {
|
|
32
|
+
// Client termination before bootstrap is handled by the host.
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Happy-dom UI tests for the phaser todo app.
|
|
3
|
+
*
|
|
4
|
+
* Phaser itself doesn't run in happy-dom (no real WebGL/canvas), so the App's
|
|
5
|
+
* `canRenderCanvas()` guard skips the `new Phaser.Game()` construction here
|
|
6
|
+
* and the DOM-side controls (`#todo-input`, `#add-btn`, `#todo-list`) remain
|
|
7
|
+
* the only thing exercised. That's fine — these tests verify the
|
|
8
|
+
* synced-store wiring (mutations propagate; cross-client sync works); the
|
|
9
|
+
* Phaser rendering layer is exercised by the Playwright E2E tests against a
|
|
10
|
+
* real browser.
|
|
11
|
+
*/
|
|
12
|
+
import { afterEach, describe, expect, test } from "bun:test";
|
|
13
|
+
import { createPoeTileTestHarness, tick } from "joiner-sdk/v1/test-utils.js";
|
|
14
|
+
import { todoBackendConfig } from "../synced-store/backend-config";
|
|
15
|
+
import type { TodoSchema } from "../synced-store/schema";
|
|
16
|
+
import { createApp } from "./App";
|
|
17
|
+
|
|
18
|
+
const mounted: HTMLElement[] = [];
|
|
19
|
+
|
|
20
|
+
function mountApp(store: Parameters<typeof createApp>[1]): HTMLElement {
|
|
21
|
+
const container = document.createElement("div");
|
|
22
|
+
document.body.appendChild(container);
|
|
23
|
+
mounted.push(container);
|
|
24
|
+
createApp(container, store);
|
|
25
|
+
return container;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Yields with the SDK's `tick()` (a microtask plus a macrotask) instead of a
|
|
29
|
+
// raw `setTimeout`, which the repo's `.grit/no-settimeout-in-tests` plugin
|
|
30
|
+
// rejects, and retries by recursion because `noAwaitInLoops` bans `await`
|
|
31
|
+
// inside a loop body. A scaffold committed with `--internal-mono-repo` is
|
|
32
|
+
// linted by both rules on its first run.
|
|
33
|
+
async function waitFor(fn: () => boolean, timeoutMs = 2000): Promise<void> {
|
|
34
|
+
const deadline = Date.now() + timeoutMs;
|
|
35
|
+
const attempt = async (): Promise<void> => {
|
|
36
|
+
if (fn()) return;
|
|
37
|
+
if (Date.now() > deadline) {
|
|
38
|
+
throw new Error("waitFor: condition not met within timeout");
|
|
39
|
+
}
|
|
40
|
+
await tick();
|
|
41
|
+
return attempt();
|
|
42
|
+
};
|
|
43
|
+
return attempt();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe("Phaser Todo App UI", () => {
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
for (const el of mounted) el.remove();
|
|
49
|
+
mounted.length = 0;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("user-1 can add a todo from the DOM controls", async () => {
|
|
53
|
+
const harness = createPoeTileTestHarness<TodoSchema>({
|
|
54
|
+
store: { backendConfig: todoBackendConfig },
|
|
55
|
+
});
|
|
56
|
+
const { store } = await harness.createClient({ userId: "user-1" });
|
|
57
|
+
|
|
58
|
+
const container = mountApp(store);
|
|
59
|
+
|
|
60
|
+
await waitFor(() => !!container.querySelector("#todo-input"));
|
|
61
|
+
expect(container.querySelector("#todo-input")).toBeInTheDocument();
|
|
62
|
+
|
|
63
|
+
const input = container.querySelector("#todo-input") as HTMLInputElement;
|
|
64
|
+
const addBtn = container.querySelector("#add-btn") as HTMLButtonElement;
|
|
65
|
+
|
|
66
|
+
input.value = "Buy milk";
|
|
67
|
+
addBtn.click();
|
|
68
|
+
|
|
69
|
+
await waitFor(() => (container.textContent ?? "").includes("Buy milk"));
|
|
70
|
+
expect(container).toHaveTextContent("Buy milk");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("todo added by user-2 appears in user-1's list", async () => {
|
|
74
|
+
const harness = createPoeTileTestHarness<TodoSchema>({
|
|
75
|
+
store: { backendConfig: todoBackendConfig },
|
|
76
|
+
});
|
|
77
|
+
const { store: store1 } = await harness.createClient({ userId: "user-1" });
|
|
78
|
+
const { store: store2 } = await harness.createClient({ userId: "user-2" });
|
|
79
|
+
|
|
80
|
+
const container = mountApp(store1);
|
|
81
|
+
|
|
82
|
+
await waitFor(() => !!container.querySelector("#todo-input"));
|
|
83
|
+
expect(container.querySelector("#todo-input")).toBeInTheDocument();
|
|
84
|
+
|
|
85
|
+
await store2.mutate.setTodo({
|
|
86
|
+
id: "todo-from-user-2",
|
|
87
|
+
text: "Pick up groceries",
|
|
88
|
+
completed: false,
|
|
89
|
+
createdAt: 1000,
|
|
90
|
+
order: 1,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
await waitFor(() =>
|
|
94
|
+
(container.textContent ?? "").includes("Pick up groceries"),
|
|
95
|
+
);
|
|
96
|
+
expect(container).toHaveTextContent("Pick up groceries");
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phaser-rendered todo demo. Renders a real DOM control bar (input + buttons +
|
|
3
|
+
* list) for accessibility and tests, plus a Phaser canvas where each todo
|
|
4
|
+
* appears as a colored circle. Clicking a circle removes the todo; clicking
|
|
5
|
+
* "Add" creates one at a hash-stable position.
|
|
6
|
+
*
|
|
7
|
+
* Synced-store is the source of truth. The Phaser scene is a pure renderer:
|
|
8
|
+
* it reads from a `getSnapshot()` callback that closes over the live data.
|
|
9
|
+
*
|
|
10
|
+
* Phaser is imported dynamically in `phaser-scene.ts` and only when canvas
|
|
11
|
+
* support is detected — Phaser touches `Image` at module load, which throws
|
|
12
|
+
* in headless DOMs (happy-dom). DOM-side controls work in either environment.
|
|
13
|
+
*/
|
|
14
|
+
import { type PoeUserInfo, usableDisplayName } from "joiner-sdk/v1/shared.js";
|
|
15
|
+
import type { TodoItem, TodoStoreClient } from "../client";
|
|
16
|
+
import type { SceneHandle } from "./phaser-scene";
|
|
17
|
+
|
|
18
|
+
function escapeHtml(text: string): string {
|
|
19
|
+
return text
|
|
20
|
+
.replace(/&/g, "&")
|
|
21
|
+
.replace(/</g, "<")
|
|
22
|
+
.replace(/>/g, ">")
|
|
23
|
+
.replace(/"/g, """);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function canRenderCanvas(): boolean {
|
|
27
|
+
try {
|
|
28
|
+
const c = document.createElement("canvas");
|
|
29
|
+
const ctx = c.getContext("webgl") || c.getContext("2d");
|
|
30
|
+
return !!ctx;
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function createApp(root: HTMLElement, store: TodoStoreClient): void {
|
|
37
|
+
root.innerHTML = "";
|
|
38
|
+
|
|
39
|
+
const layout = document.createElement("div");
|
|
40
|
+
layout.style.position = "relative";
|
|
41
|
+
layout.style.width = "100%";
|
|
42
|
+
layout.style.minHeight = "320px";
|
|
43
|
+
layout.style.height = "100%";
|
|
44
|
+
root.appendChild(layout);
|
|
45
|
+
|
|
46
|
+
const controls = document.createElement("div");
|
|
47
|
+
controls.style.position = "relative";
|
|
48
|
+
controls.style.zIndex = "1";
|
|
49
|
+
controls.style.padding = "12px";
|
|
50
|
+
controls.style.background = "#0a0d12";
|
|
51
|
+
controls.style.color = "#e5e7eb";
|
|
52
|
+
controls.style.fontFamily = "system-ui, sans-serif";
|
|
53
|
+
controls.innerHTML = `
|
|
54
|
+
<h1 style="margin:0 0 8px 0; font-size:18px;">{{APP_NAME}}</h1>
|
|
55
|
+
<div style="display:flex; gap:8px; align-items:center;">
|
|
56
|
+
<input id="todo-input" placeholder="What needs to be done?" style="flex:1; padding:6px;" />
|
|
57
|
+
<button id="add-btn" type="button">Add</button>
|
|
58
|
+
</div>
|
|
59
|
+
<ul id="todo-list" style="margin:8px 0 0 0; padding-left:20px; max-height:120px; overflow:auto;"></ul>
|
|
60
|
+
`;
|
|
61
|
+
layout.appendChild(controls);
|
|
62
|
+
|
|
63
|
+
const stage = document.createElement("div");
|
|
64
|
+
stage.id = "phaser-stage";
|
|
65
|
+
stage.style.position = "relative";
|
|
66
|
+
stage.style.width = "100%";
|
|
67
|
+
stage.style.height = "320px";
|
|
68
|
+
stage.style.background = "#111827";
|
|
69
|
+
stage.style.touchAction = "none";
|
|
70
|
+
stage.style.overflow = "hidden";
|
|
71
|
+
layout.appendChild(stage);
|
|
72
|
+
|
|
73
|
+
let todos: TodoItem[] = [];
|
|
74
|
+
let users = new Map<string, PoeUserInfo>();
|
|
75
|
+
let scene: SceneHandle | null = null;
|
|
76
|
+
|
|
77
|
+
function getDisplayName(userId: string): string {
|
|
78
|
+
const info = users.get(userId);
|
|
79
|
+
// Never render an internal id (`u_<hex>` / `u_migrated_...` /
|
|
80
|
+
// `private-...`) as a name; the shared masker returns "" when nothing
|
|
81
|
+
// usable is present.
|
|
82
|
+
return usableDisplayName(info) || "Player";
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function renderList(): void {
|
|
86
|
+
const list = controls.querySelector("#todo-list");
|
|
87
|
+
if (!list) return;
|
|
88
|
+
list.innerHTML = todos
|
|
89
|
+
.map(
|
|
90
|
+
(t) => `
|
|
91
|
+
<li data-id="${escapeHtml(t.id)}" style="margin-bottom:4px;">
|
|
92
|
+
<input type="checkbox" ${t.completed ? "checked" : ""} />
|
|
93
|
+
<span style="text-decoration: ${t.completed ? "line-through" : "none"}">${escapeHtml(t.text)}</span>
|
|
94
|
+
<span style="color:#9ca3af; font-size:0.85em; margin-left:8px;">— ${escapeHtml(getDisplayName(t.createdBy))}</span>
|
|
95
|
+
<button type="button" class="delete-btn">Delete</button>
|
|
96
|
+
</li>`,
|
|
97
|
+
)
|
|
98
|
+
.join("");
|
|
99
|
+
for (const li of list.querySelectorAll("li")) {
|
|
100
|
+
const { id } = (li as HTMLElement).dataset;
|
|
101
|
+
if (!id) continue;
|
|
102
|
+
li.querySelector("input[type=checkbox]")?.addEventListener(
|
|
103
|
+
"change",
|
|
104
|
+
() => {
|
|
105
|
+
const todo = todos.find((t) => t.id === id);
|
|
106
|
+
if (todo) {
|
|
107
|
+
store.mutate.setTodo({ id: todo.id, completed: !todo.completed });
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
);
|
|
111
|
+
li.querySelector(".delete-btn")?.addEventListener("click", () =>
|
|
112
|
+
store.mutate.removeTodo({ id }),
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function addTodo(): void {
|
|
118
|
+
const input = controls.querySelector("#todo-input") as HTMLInputElement;
|
|
119
|
+
const text = input.value.trim();
|
|
120
|
+
if (!text) return;
|
|
121
|
+
const now = Date.now();
|
|
122
|
+
const maxOrder = todos.reduce((max, t) => Math.max(max, t.order), 0);
|
|
123
|
+
store.mutate.setTodo({
|
|
124
|
+
id: crypto.randomUUID(),
|
|
125
|
+
text,
|
|
126
|
+
completed: false,
|
|
127
|
+
createdAt: now,
|
|
128
|
+
order: maxOrder + 1,
|
|
129
|
+
});
|
|
130
|
+
input.value = "";
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
controls.querySelector("#add-btn")?.addEventListener("click", addTodo);
|
|
134
|
+
controls.querySelector("#todo-input")?.addEventListener("keydown", (e) => {
|
|
135
|
+
if ((e as KeyboardEvent).key === "Enter") addTodo();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
if (canRenderCanvas()) {
|
|
139
|
+
void import("./phaser-scene")
|
|
140
|
+
.then(({ startPhaserScene }) => {
|
|
141
|
+
scene = startPhaserScene(
|
|
142
|
+
stage,
|
|
143
|
+
() => ({ todos, users }),
|
|
144
|
+
(id) => {
|
|
145
|
+
store.mutate.removeTodo({ id });
|
|
146
|
+
},
|
|
147
|
+
);
|
|
148
|
+
scene?.render();
|
|
149
|
+
})
|
|
150
|
+
.catch(() => {
|
|
151
|
+
// Phaser failed to load — DOM controls still function.
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
store.subscribe(
|
|
156
|
+
(tx) => tx.table("items").entries().toArray(),
|
|
157
|
+
(entries) => {
|
|
158
|
+
todos = entries
|
|
159
|
+
.map(([, v]) => v as TodoItem)
|
|
160
|
+
.sort((a, b) => a.order - b.order);
|
|
161
|
+
renderList();
|
|
162
|
+
scene?.render();
|
|
163
|
+
},
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
store.subscribe(
|
|
167
|
+
(tx) => tx.table("$userInfo").entries().toArray(),
|
|
168
|
+
(entries) => {
|
|
169
|
+
const map = new Map<string, PoeUserInfo>();
|
|
170
|
+
for (const [, v] of entries) {
|
|
171
|
+
const info = v;
|
|
172
|
+
map.set(info.userId, info);
|
|
173
|
+
}
|
|
174
|
+
users = map;
|
|
175
|
+
renderList();
|
|
176
|
+
},
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
renderList();
|
|
180
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phaser-side rendering for the todo demo. Imported lazily by ui/App.ts so
|
|
3
|
+
* test/headless environments without a real canvas (happy-dom) never load
|
|
4
|
+
* the Phaser module — Phaser touches `Image` at top-level evaluation, which
|
|
5
|
+
* throws in non-browser DOMs.
|
|
6
|
+
*/
|
|
7
|
+
import {
|
|
8
|
+
type PoeUserInfo,
|
|
9
|
+
resolveRenderBudgetDefaults,
|
|
10
|
+
} from "joiner-sdk/v1/client.js";
|
|
11
|
+
import Phaser from "phaser";
|
|
12
|
+
import type { TodoItem } from "../client";
|
|
13
|
+
|
|
14
|
+
const PALETTE = [0xef4444, 0xf59e0b, 0x10b981, 0x3b82f6, 0x8b5cf6, 0xec4899];
|
|
15
|
+
|
|
16
|
+
function hashInt(s: string): number {
|
|
17
|
+
let h = 2166136261;
|
|
18
|
+
for (let i = 0; i < s.length; i++) {
|
|
19
|
+
h ^= s.charCodeAt(i);
|
|
20
|
+
h = Math.imul(h, 16777619);
|
|
21
|
+
}
|
|
22
|
+
return h >>> 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface TodoView {
|
|
26
|
+
circle: Phaser.GameObjects.Arc;
|
|
27
|
+
label: Phaser.GameObjects.Text;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface SceneHandle {
|
|
31
|
+
render(): void;
|
|
32
|
+
destroy(): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
class TodoScene extends Phaser.Scene {
|
|
36
|
+
static readonly KEY = "TodoScene";
|
|
37
|
+
private getSnapshot!: () => {
|
|
38
|
+
todos: TodoItem[];
|
|
39
|
+
users: Map<string, PoeUserInfo>;
|
|
40
|
+
};
|
|
41
|
+
private onRemove!: (id: string) => void;
|
|
42
|
+
private views = new Map<string, TodoView>();
|
|
43
|
+
|
|
44
|
+
constructor() {
|
|
45
|
+
super(TodoScene.KEY);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
init(data: {
|
|
49
|
+
getSnapshot: () => { todos: TodoItem[]; users: Map<string, PoeUserInfo> };
|
|
50
|
+
onRemove: (id: string) => void;
|
|
51
|
+
}): void {
|
|
52
|
+
this.getSnapshot = data.getSnapshot;
|
|
53
|
+
this.onRemove = data.onRemove;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
create(): void {
|
|
57
|
+
this.scale.on("resize", () => this.render());
|
|
58
|
+
this.render();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Split into placement/create/update/prune helpers rather than one loop:
|
|
62
|
+
// the repo caps cognitive complexity at 10 per function, and a scaffold
|
|
63
|
+
// committed with `--internal-mono-repo` is linted by that cap.
|
|
64
|
+
render(): void {
|
|
65
|
+
const { todos } = this.getSnapshot();
|
|
66
|
+
const seenIds = new Set<string>();
|
|
67
|
+
for (const todo of todos) {
|
|
68
|
+
seenIds.add(todo.id);
|
|
69
|
+
this.renderTodo(todo);
|
|
70
|
+
}
|
|
71
|
+
this.pruneViews(seenIds);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Deterministic position + color, so a todo lands in the same spot for everyone. */
|
|
75
|
+
private placementFor(todo: TodoItem): {
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
color: number;
|
|
79
|
+
} {
|
|
80
|
+
const seed = hashInt(todo.id);
|
|
81
|
+
const width = this.scale.width;
|
|
82
|
+
const height = this.scale.height;
|
|
83
|
+
return {
|
|
84
|
+
x: 60 + ((seed >>> 0) % Math.max(1, Math.floor(width - 120))),
|
|
85
|
+
y: 60 + (((seed >>> 8) >>> 0) % Math.max(1, Math.floor(height - 120))),
|
|
86
|
+
color: PALETTE[seed % PALETTE.length] ?? 0x3b82f6,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private renderTodo(todo: TodoItem): void {
|
|
91
|
+
const { x, y, color } = this.placementFor(todo);
|
|
92
|
+
const view = this.views.get(todo.id);
|
|
93
|
+
if (view) {
|
|
94
|
+
view.circle.setPosition(x, y);
|
|
95
|
+
view.circle.setFillStyle(color, todo.completed ? 0.4 : 1);
|
|
96
|
+
view.label.setPosition(x, y);
|
|
97
|
+
view.label.setText(todo.text.slice(0, 12));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
this.views.set(todo.id, this.createTodoView(todo, x, y, color));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private createTodoView(
|
|
104
|
+
todo: TodoItem,
|
|
105
|
+
x: number,
|
|
106
|
+
y: number,
|
|
107
|
+
color: number,
|
|
108
|
+
): TodoView {
|
|
109
|
+
const circle = this.add.circle(x, y, 28, color, todo.completed ? 0.4 : 1);
|
|
110
|
+
circle.setStrokeStyle(2, 0x111827, 1);
|
|
111
|
+
circle.setInteractive({ useHandCursor: true });
|
|
112
|
+
circle.on("pointerdown", () => this.onRemove(todo.id));
|
|
113
|
+
const label = this.add.text(x, y, todo.text.slice(0, 12), {
|
|
114
|
+
fontFamily: "system-ui, sans-serif",
|
|
115
|
+
fontSize: "12px",
|
|
116
|
+
color: "#ffffff",
|
|
117
|
+
});
|
|
118
|
+
label.setOrigin(0.5, 0.5);
|
|
119
|
+
return { circle, label };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private pruneViews(seenIds: Set<string>): void {
|
|
123
|
+
for (const [id, view] of this.views) {
|
|
124
|
+
if (seenIds.has(id)) continue;
|
|
125
|
+
view.circle.destroy();
|
|
126
|
+
view.label.destroy();
|
|
127
|
+
this.views.delete(id);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function startPhaserScene(
|
|
133
|
+
parent: HTMLElement,
|
|
134
|
+
getSnapshot: () => { todos: TodoItem[]; users: Map<string, PoeUserInfo> },
|
|
135
|
+
onRemove: (id: string) => void,
|
|
136
|
+
): SceneHandle | null {
|
|
137
|
+
try {
|
|
138
|
+
// Platform render-budget defaults, mapped into Phaser's own game
|
|
139
|
+
// config: `fps.limit` caps the loop at the resolved target on mobile
|
|
140
|
+
// (high-refresh Android panels otherwise run at 90-120 Hz, a real
|
|
141
|
+
// battery cost); desktop stays uncapped. Phaser owns the render
|
|
142
|
+
// loop, so use this pure resolver — NOT `createRenderBudget()`,
|
|
143
|
+
// which assumes your code drives the loop (see the tile-creator
|
|
144
|
+
// docs on render budgets).
|
|
145
|
+
const defaults = resolveRenderBudgetDefaults();
|
|
146
|
+
const game = new Phaser.Game({
|
|
147
|
+
type: Phaser.AUTO,
|
|
148
|
+
parent,
|
|
149
|
+
...(defaults.targetFps !== null
|
|
150
|
+
? { fps: { limit: defaults.targetFps } }
|
|
151
|
+
: {}),
|
|
152
|
+
// Default powerPreference (Phaser requests "high-performance" by
|
|
153
|
+
// default): the high-power GPU hint is a battery cost tiles
|
|
154
|
+
// should not pay by default.
|
|
155
|
+
render: { powerPreference: defaults.powerPreference },
|
|
156
|
+
backgroundColor: "#111827",
|
|
157
|
+
scale: {
|
|
158
|
+
mode: Phaser.Scale.RESIZE,
|
|
159
|
+
autoCenter: Phaser.Scale.CENTER_BOTH,
|
|
160
|
+
width: parent.clientWidth || 600,
|
|
161
|
+
height: parent.clientHeight || 320,
|
|
162
|
+
},
|
|
163
|
+
scene: [TodoScene],
|
|
164
|
+
});
|
|
165
|
+
game.scene.start(TodoScene.KEY, { getSnapshot, onRemove });
|
|
166
|
+
const scene = game.scene.getScene(TodoScene.KEY) as TodoScene;
|
|
167
|
+
return {
|
|
168
|
+
render: () => scene.render(),
|
|
169
|
+
destroy: () => game.destroy(true),
|
|
170
|
+
};
|
|
171
|
+
} catch {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { poeTile } from "joiner-sdk/vite";
|
|
2
|
+
import { defineConfig } from "vite";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
root: "tile",
|
|
6
|
+
build: {
|
|
7
|
+
outDir: "../dist",
|
|
8
|
+
emptyOutDir: true,
|
|
9
|
+
// Inline all assets as data URLs in the JS bundle. Poe apps run in a
|
|
10
|
+
// sandboxed iframe with origin `null`, so relative asset URLs fail to
|
|
11
|
+
// resolve in Phaser's XHR loader. Inlining as data URLs sidesteps that.
|
|
12
|
+
assetsInlineLimit: 10 * 1024 * 1024,
|
|
13
|
+
rollupOptions: {
|
|
14
|
+
output: {
|
|
15
|
+
entryFileNames: "tile-frontend.js",
|
|
16
|
+
assetFileNames: "[name][extname]",
|
|
17
|
+
// Bundle dynamic imports (e.g. ./phaser-scene) into the entry
|
|
18
|
+
// chunk. The Poe sandbox iframe has origin `null`, which breaks
|
|
19
|
+
// runtime resolution of relative chunk URLs. The dynamic import
|
|
20
|
+
// in source is what keeps Phaser out of unit-test (happy-dom)
|
|
21
|
+
// module evaluation; at build time we collapse it to a single
|
|
22
|
+
// bundle so the browser doesn't need a second fetch.
|
|
23
|
+
inlineDynamicImports: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
plugins: [poeTile({ backendEntryPoint: "src/backend.ts" })],
|
|
28
|
+
});
|