@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,107 @@
|
|
|
1
|
+
// owner: jyoung-q
|
|
2
|
+
/** Executable manager assertions for the default multiplayer starter. */
|
|
3
|
+
export const MANAGER_TEST_TS = `import { expect, test } from "bun:test";
|
|
4
|
+
import { defineBackendConfig } from "joiner-sdk/v1/backend.js";
|
|
5
|
+
import {
|
|
6
|
+
defineClientConfig,
|
|
7
|
+
type InferMutatorHandlers,
|
|
8
|
+
notifyActivity,
|
|
9
|
+
setTurn,
|
|
10
|
+
} from "joiner-sdk/v1/client.js";
|
|
11
|
+
import { createPoeTileInManagerTestHarness } from "joiner-sdk/v1/test-utils.js";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { tileHooks } from "./hooks";
|
|
14
|
+
import { tileMutators } from "./mutators";
|
|
15
|
+
import { tileSchema } from "./schema";
|
|
16
|
+
|
|
17
|
+
// Keep the app's table types intact. Re-defining its tables here erases their
|
|
18
|
+
// concrete types and makes its existing handlers incompatible with this fixture.
|
|
19
|
+
// Replace passTurn with your real turn mutator when adding app-specific checks.
|
|
20
|
+
const schema = {
|
|
21
|
+
...tileSchema,
|
|
22
|
+
mutators: {
|
|
23
|
+
...tileSchema.mutators,
|
|
24
|
+
passTurn: { input: z.object({ nextUserId: z.string(), now: z.number() }) },
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const mutators: InferMutatorHandlers<typeof schema> = {
|
|
28
|
+
...tileMutators,
|
|
29
|
+
passTurn: async (ctx, { nextUserId, now }) => {
|
|
30
|
+
// setTurn already marks the recipient unread and updates the Activity tab.
|
|
31
|
+
// It also clears the previous turn. Routine turns are silent; do not
|
|
32
|
+
// add a second unread increment/push.
|
|
33
|
+
await setTurn(ctx, { userIds: [nextUserId], push: false });
|
|
34
|
+
await notifyActivity(ctx, {
|
|
35
|
+
preview: "Turn passed",
|
|
36
|
+
previewTimestamp: now,
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
const clientConfig = defineClientConfig<typeof schema>({
|
|
41
|
+
schemaVersion: schema.schemaVersion,
|
|
42
|
+
mutators,
|
|
43
|
+
hooks: tileHooks,
|
|
44
|
+
});
|
|
45
|
+
const backendConfig = defineBackendConfig({
|
|
46
|
+
schema,
|
|
47
|
+
mutators,
|
|
48
|
+
hooks: tileHooks,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("passing a turn updates the opponent without adding actor unread or pushes", async () => {
|
|
52
|
+
const h = await createPoeTileInManagerTestHarness({
|
|
53
|
+
tile: { typeId: "turn-example", clientConfig, backendConfig },
|
|
54
|
+
users: ["alice", "bob"],
|
|
55
|
+
});
|
|
56
|
+
try {
|
|
57
|
+
// These are real Poe clients; store tables and mutators are inferred.
|
|
58
|
+
const alice = h.tile("alice").poe;
|
|
59
|
+
const bob = h.tile("bob").poe;
|
|
60
|
+
await (await bob.store.mutate.passTurn({ nextUserId: "alice", now: 1000 }))
|
|
61
|
+
.confirmed;
|
|
62
|
+
// Initialization/previous turns can already mark Alice unread. Wait for
|
|
63
|
+
// those effects before taking a baseline; never assume it starts at zero.
|
|
64
|
+
const beforeAlice = await h
|
|
65
|
+
.manager("alice")
|
|
66
|
+
.wait(
|
|
67
|
+
(v) =>
|
|
68
|
+
v.turnActive && v.unreadCount === 1 && v.previewTimestamp === 1000,
|
|
69
|
+
);
|
|
70
|
+
const beforeBob = await h
|
|
71
|
+
.manager("bob")
|
|
72
|
+
.wait((v) => v.previewTimestamp === 1000);
|
|
73
|
+
|
|
74
|
+
await (await alice.store.mutate.passTurn({ nextUserId: "bob", now: 2000 }))
|
|
75
|
+
.confirmed;
|
|
76
|
+
// Confirmation is not a substitute for waiting on each manager projection.
|
|
77
|
+
const afterBob = await h
|
|
78
|
+
.manager("bob")
|
|
79
|
+
.wait(
|
|
80
|
+
(v) =>
|
|
81
|
+
v.turnActive &&
|
|
82
|
+
v.unreadCount === beforeBob.unreadCount + 1 &&
|
|
83
|
+
v.previewTimestamp === 2000,
|
|
84
|
+
);
|
|
85
|
+
const afterAlice = await h
|
|
86
|
+
.manager("alice")
|
|
87
|
+
.wait((v) => !v.turnActive && v.previewTimestamp === 2000);
|
|
88
|
+
expect(afterAlice.unreadCount).toBe(beforeAlice.unreadCount);
|
|
89
|
+
expect(afterAlice.pushes).toHaveLength(beforeAlice.pushes.length);
|
|
90
|
+
expect(afterBob.pushes).toHaveLength(beforeBob.pushes.length);
|
|
91
|
+
expect(afterBob.preview).toBe("Turn passed");
|
|
92
|
+
expect(afterBob.previewTimestamp).toBeGreaterThan(
|
|
93
|
+
beforeBob.previewTimestamp!,
|
|
94
|
+
);
|
|
95
|
+
// Re-marking the same recipient must not add unread or another push.
|
|
96
|
+
await (await alice.store.mutate.passTurn({ nextUserId: "bob", now: 3000 }))
|
|
97
|
+
.confirmed;
|
|
98
|
+
const repeatedBob = await h
|
|
99
|
+
.manager("bob")
|
|
100
|
+
.wait((v) => v.previewTimestamp === 3000);
|
|
101
|
+
expect(repeatedBob.unreadCount).toBe(afterBob.unreadCount);
|
|
102
|
+
expect(repeatedBob.pushes).toHaveLength(afterBob.pushes.length);
|
|
103
|
+
} finally {
|
|
104
|
+
h.dispose();
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
`;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// owner: jyoung-q
|
|
2
|
+
/** Shared Playwright helpers emitted into every new Poe tile scaffold. */
|
|
3
|
+
export const MULTIPLAYER_TEST_HELPERS_TS = `import {
|
|
4
|
+
type Browser,
|
|
5
|
+
type BrowserContext,
|
|
6
|
+
type BrowserContextOptions,
|
|
7
|
+
expect,
|
|
8
|
+
type Frame,
|
|
9
|
+
type Locator,
|
|
10
|
+
type Page,
|
|
11
|
+
} from "@playwright/test";
|
|
12
|
+
import {
|
|
13
|
+
type TestServer,
|
|
14
|
+
waitForBlobFrame,
|
|
15
|
+
} from "joiner-sdk/v1/test-utils/playwright.js";
|
|
16
|
+
|
|
17
|
+
export interface TileTestUser {
|
|
18
|
+
userId: string;
|
|
19
|
+
clientId: string;
|
|
20
|
+
username: string;
|
|
21
|
+
displayName: string;
|
|
22
|
+
profilePicture: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface TwoUserTile {
|
|
26
|
+
alice: { context: BrowserContext; page: Page; frame: Frame };
|
|
27
|
+
bob: { context: BrowserContext; page: Page; frame: Frame };
|
|
28
|
+
close: () => Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const ALICE: TileTestUser = {
|
|
32
|
+
userId: "alice",
|
|
33
|
+
clientId: "client-alice",
|
|
34
|
+
username: "alice",
|
|
35
|
+
displayName: "Alice",
|
|
36
|
+
profilePicture: "https://example.com/alice.png",
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const BOB: TileTestUser = {
|
|
40
|
+
userId: "bob",
|
|
41
|
+
clientId: "client-bob",
|
|
42
|
+
username: "bob",
|
|
43
|
+
displayName: "Bob",
|
|
44
|
+
profilePicture: "https://example.com/bob.png",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
function sessionUrl(args: {
|
|
48
|
+
server: TestServer;
|
|
49
|
+
tileTypeId: string;
|
|
50
|
+
instanceId: string;
|
|
51
|
+
user: TileTestUser;
|
|
52
|
+
}): string {
|
|
53
|
+
return args.server.sessionUrl({
|
|
54
|
+
tileTypeId: args.tileTypeId,
|
|
55
|
+
instanceId: args.instanceId,
|
|
56
|
+
userId: args.user.userId,
|
|
57
|
+
clientId: args.user.clientId,
|
|
58
|
+
useIndexedDb: true,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function closeContexts(contexts: BrowserContext[]): Promise<void> {
|
|
63
|
+
await Promise.allSettled(contexts.map((context) => context.close()));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Opens two independent browser contexts on one admitted tile instance.
|
|
68
|
+
* \`addUserToInstance\` is required: sharing an instanceId alone does not admit
|
|
69
|
+
* the second user to the room or fire the tile's onAddUsers hook.
|
|
70
|
+
*/
|
|
71
|
+
export async function openTwoUserTile(args: {
|
|
72
|
+
server: TestServer;
|
|
73
|
+
browser: Browser;
|
|
74
|
+
tileTypeId: string;
|
|
75
|
+
instanceId: string;
|
|
76
|
+
readySelector: string;
|
|
77
|
+
contextOptions?: BrowserContextOptions;
|
|
78
|
+
alice?: TileTestUser;
|
|
79
|
+
bob?: TileTestUser;
|
|
80
|
+
}): Promise<TwoUserTile> {
|
|
81
|
+
const alice = args.alice ?? ALICE;
|
|
82
|
+
const bob = args.bob ?? BOB;
|
|
83
|
+
const contexts: BrowserContext[] = [];
|
|
84
|
+
try {
|
|
85
|
+
const aliceContext = await args.browser.newContext(args.contextOptions);
|
|
86
|
+
contexts.push(aliceContext);
|
|
87
|
+
const bobContext = await args.browser.newContext(args.contextOptions);
|
|
88
|
+
contexts.push(bobContext);
|
|
89
|
+
await args.server.addUserToInstance({
|
|
90
|
+
storeTypeId: args.tileTypeId,
|
|
91
|
+
instanceId: args.instanceId,
|
|
92
|
+
userId: alice.userId,
|
|
93
|
+
addedBy: alice.userId,
|
|
94
|
+
userInfo: {
|
|
95
|
+
userId: alice.userId,
|
|
96
|
+
username: alice.username,
|
|
97
|
+
displayName: alice.displayName,
|
|
98
|
+
profilePicture: alice.profilePicture,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
await args.server.addUserToInstance({
|
|
102
|
+
storeTypeId: args.tileTypeId,
|
|
103
|
+
instanceId: args.instanceId,
|
|
104
|
+
userId: bob.userId,
|
|
105
|
+
addedBy: alice.userId,
|
|
106
|
+
userInfo: {
|
|
107
|
+
userId: bob.userId,
|
|
108
|
+
username: bob.username,
|
|
109
|
+
displayName: bob.displayName,
|
|
110
|
+
profilePicture: bob.profilePicture,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
const alicePage = await aliceContext.newPage();
|
|
114
|
+
const bobPage = await bobContext.newPage();
|
|
115
|
+
await Promise.all([
|
|
116
|
+
alicePage.goto(
|
|
117
|
+
sessionUrl({
|
|
118
|
+
server: args.server,
|
|
119
|
+
tileTypeId: args.tileTypeId,
|
|
120
|
+
instanceId: args.instanceId,
|
|
121
|
+
user: alice,
|
|
122
|
+
}),
|
|
123
|
+
),
|
|
124
|
+
bobPage.goto(
|
|
125
|
+
sessionUrl({
|
|
126
|
+
server: args.server,
|
|
127
|
+
tileTypeId: args.tileTypeId,
|
|
128
|
+
instanceId: args.instanceId,
|
|
129
|
+
user: bob,
|
|
130
|
+
}),
|
|
131
|
+
),
|
|
132
|
+
]);
|
|
133
|
+
const [aliceFrame, bobFrame] = await Promise.all([
|
|
134
|
+
waitForBlobFrame(alicePage),
|
|
135
|
+
waitForBlobFrame(bobPage),
|
|
136
|
+
]);
|
|
137
|
+
await Promise.all(
|
|
138
|
+
[aliceFrame, bobFrame].map((frame) =>
|
|
139
|
+
expect(frame.locator(args.readySelector)).toBeVisible({
|
|
140
|
+
timeout: 15_000,
|
|
141
|
+
}),
|
|
142
|
+
),
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
alice: { context: aliceContext, page: alicePage, frame: aliceFrame },
|
|
147
|
+
bob: { context: bobContext, page: bobPage, frame: bobFrame },
|
|
148
|
+
close: () => closeContexts(contexts),
|
|
149
|
+
};
|
|
150
|
+
} catch (error) {
|
|
151
|
+
await closeContexts(contexts);
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export async function expectTileState(args: {
|
|
157
|
+
frame: Frame;
|
|
158
|
+
selector: string;
|
|
159
|
+
state: string;
|
|
160
|
+
timeoutMs?: number;
|
|
161
|
+
}): Promise<void> {
|
|
162
|
+
await expect(args.frame.locator(args.selector)).toHaveAttribute(
|
|
163
|
+
"data-state",
|
|
164
|
+
args.state,
|
|
165
|
+
{ timeout: args.timeoutMs ?? 10_000 },
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Assert rejection through the disabled UI state. Playwright intentionally
|
|
171
|
+
* waits rather than clicking disabled controls, so clicking one would turn a
|
|
172
|
+
* correct UI into a test timeout.
|
|
173
|
+
*/
|
|
174
|
+
export async function expectDisabledAndUnchanged(args: {
|
|
175
|
+
locator: Locator;
|
|
176
|
+
attribute: string;
|
|
177
|
+
value: string;
|
|
178
|
+
}): Promise<void> {
|
|
179
|
+
await expect(args.locator).toBeDisabled();
|
|
180
|
+
await expect(args.locator).toHaveAttribute(args.attribute, args.value);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Wait for a rendered state without hanging on ambient looping decoration. */
|
|
184
|
+
export async function waitForVisualReady(args: {
|
|
185
|
+
frame: Frame;
|
|
186
|
+
readySelector: string;
|
|
187
|
+
timeoutMs?: number;
|
|
188
|
+
}): Promise<void> {
|
|
189
|
+
const timeout = args.timeoutMs ?? 5000;
|
|
190
|
+
const region = args.frame.locator(args.readySelector);
|
|
191
|
+
await expect(region).toBeVisible({ timeout });
|
|
192
|
+
await expect
|
|
193
|
+
.poll(
|
|
194
|
+
() =>
|
|
195
|
+
region.evaluateAll((elements) => {
|
|
196
|
+
const element = elements[0];
|
|
197
|
+
if (!element) return -1;
|
|
198
|
+
return element
|
|
199
|
+
.getAnimations({ subtree: true })
|
|
200
|
+
.filter((animation) => {
|
|
201
|
+
const endTime = animation.effect?.getComputedTiming().endTime;
|
|
202
|
+
return (
|
|
203
|
+
typeof endTime === "number" &&
|
|
204
|
+
Number.isFinite(endTime) &&
|
|
205
|
+
animation.playState !== "finished" &&
|
|
206
|
+
animation.playState !== "idle"
|
|
207
|
+
);
|
|
208
|
+
}).length;
|
|
209
|
+
}),
|
|
210
|
+
{
|
|
211
|
+
timeout,
|
|
212
|
+
message: \`Waiting for finite animations in \${args.readySelector}\`,
|
|
213
|
+
},
|
|
214
|
+
)
|
|
215
|
+
.toBe(0);
|
|
216
|
+
}
|
|
217
|
+
`;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// owner: jyoung-q
|
|
2
|
+
/**
|
|
3
|
+
* Ink-based name input for the `tiles init` flow. Replaces the previous
|
|
4
|
+
* readline `App name:` prompt with live regex validation: an inline
|
|
5
|
+
* red-text error appears as soon as the typed value violates the rule
|
|
6
|
+
* (rather than only after pressing Enter), and the resolved output path
|
|
7
|
+
* is shown in dim text so users notice when `--output-dir` is in play.
|
|
8
|
+
*
|
|
9
|
+
* Cold-start trick: this module statically imports Ink + React. Callers
|
|
10
|
+
* MUST gate it behind `await import("./name-input.js")` so the Ink load
|
|
11
|
+
* cost is paid only when a user actually needs the prompt. See the
|
|
12
|
+
* dynamic import in `index.ts`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { resolve } from "node:path";
|
|
16
|
+
import { Box, render, Text, useInput } from "ink";
|
|
17
|
+
import TextInput from "ink-text-input";
|
|
18
|
+
import type React from "react";
|
|
19
|
+
import { createElement, useRef, useState } from "react";
|
|
20
|
+
import { cliName } from "../../cli-name.js";
|
|
21
|
+
import { CliError } from "../../errors.js";
|
|
22
|
+
import {
|
|
23
|
+
INVALID_NAME_HINT,
|
|
24
|
+
VALID_NAME_MAX_LENGTH,
|
|
25
|
+
VALID_NAME_RE,
|
|
26
|
+
} from "./scaffold.js";
|
|
27
|
+
|
|
28
|
+
interface NameInputProps {
|
|
29
|
+
parentDir: string;
|
|
30
|
+
onSubmit: (name: string) => void;
|
|
31
|
+
onCancel: () => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Stateless-from-the-outside name prompt. Resolves via callback rather
|
|
36
|
+
* than internal Promise so the component is directly testable through
|
|
37
|
+
* the local `render()` helper in `test-utils.ts`; the promise wrapping
|
|
38
|
+
* lives in `pickName` below.
|
|
39
|
+
*
|
|
40
|
+
* Submission rule: Enter only fires `onSubmit` when the trimmed value
|
|
41
|
+
* passes `VALID_NAME_RE`. Pressing Enter on an invalid value is a no-op
|
|
42
|
+
* (the inline error is already visible, so there's nothing to add).
|
|
43
|
+
*/
|
|
44
|
+
export function NameInput({
|
|
45
|
+
parentDir,
|
|
46
|
+
onSubmit,
|
|
47
|
+
onCancel,
|
|
48
|
+
}: NameInputProps): React.ReactElement {
|
|
49
|
+
const [value, setValue] = useState("");
|
|
50
|
+
// Ref-mirror the value so our outer `useInput` (and TextInput's
|
|
51
|
+
// `onSubmit`, which captures props in a closure that ink rebinds via
|
|
52
|
+
// useEffect) can read the latest value without hitting the
|
|
53
|
+
// commit-vs-effect race documented in template-picker.tsx.
|
|
54
|
+
const valueRef = useRef(value);
|
|
55
|
+
valueRef.current = value;
|
|
56
|
+
|
|
57
|
+
useInput((input, key) => {
|
|
58
|
+
if (key.ctrl && input === "c") {
|
|
59
|
+
onCancel();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (key.return) {
|
|
63
|
+
const t = valueRef.current.trim();
|
|
64
|
+
if (!VALID_NAME_RE.test(t) || t.length > VALID_NAME_MAX_LENGTH) return;
|
|
65
|
+
onSubmit(t);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const trimmed = value.trim();
|
|
70
|
+
const valid =
|
|
71
|
+
VALID_NAME_RE.test(trimmed) && trimmed.length <= VALID_NAME_MAX_LENGTH;
|
|
72
|
+
const showError = trimmed.length > 0 && !valid;
|
|
73
|
+
// Resolved path is shown so users notice when `--output-dir` is in
|
|
74
|
+
// play. We deliberately don't `existsSync` it here — collisions are
|
|
75
|
+
// the scaffolder's responsibility (see `scaffold.ts` "Directory
|
|
76
|
+
// already exists" throw), and a per-keystroke filesystem probe
|
|
77
|
+
// produced misleading mid-typing warnings (e.g. `/foo/d` matching
|
|
78
|
+
// while the user was on their way to typing `documents-app`).
|
|
79
|
+
const targetPath = trimmed.length > 0 ? resolve(parentDir, trimmed) : "";
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<Box flexDirection="column" marginY={1}>
|
|
83
|
+
<Box>
|
|
84
|
+
<Text>App name: </Text>
|
|
85
|
+
<TextInput value={value} onChange={setValue} />
|
|
86
|
+
</Box>
|
|
87
|
+
{showError ? (
|
|
88
|
+
<Box marginTop={1}>
|
|
89
|
+
<Text color="red">{INVALID_NAME_HINT}</Text>
|
|
90
|
+
</Box>
|
|
91
|
+
) : null}
|
|
92
|
+
{valid && targetPath !== "" ? (
|
|
93
|
+
<Box marginTop={1}>
|
|
94
|
+
<Text dimColor>Will create at {targetPath}</Text>
|
|
95
|
+
</Box>
|
|
96
|
+
) : null}
|
|
97
|
+
<Box marginTop={1}>
|
|
98
|
+
<Text dimColor>
|
|
99
|
+
{showError
|
|
100
|
+
? "Fix the error to continue · Ctrl-C to cancel"
|
|
101
|
+
: "Enter to confirm · Ctrl-C to cancel"}
|
|
102
|
+
</Text>
|
|
103
|
+
</Box>
|
|
104
|
+
</Box>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Minimal shape of the renderer `pickName` needs. Satisfied by both
|
|
110
|
+
* ink's real `render` and the synthetic-stream `render` in
|
|
111
|
+
* `test-utils.ts`, which lets tests drive the wrapper without a TTY.
|
|
112
|
+
*/
|
|
113
|
+
export type InkRenderer = (tree: React.ReactElement) => {
|
|
114
|
+
unmount: () => void;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Production default for `pickName`'s `renderFn` parameter. Exported so
|
|
119
|
+
* it can be unit-tested directly via `spyOn(inkModule, "render")` —
|
|
120
|
+
* otherwise the inlined arrow form is uncovered by the test suite
|
|
121
|
+
* (production-only invocation against a real TTY).
|
|
122
|
+
*/
|
|
123
|
+
export const defaultRenderer: InkRenderer = (tree) =>
|
|
124
|
+
render(tree, { exitOnCtrlC: false });
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Mount `<NameInput>` against the real terminal and resolve with the
|
|
128
|
+
* typed name. Throws `CliError` when stdout isn't a TTY (so non-TTY
|
|
129
|
+
* callers get a clear pointer to the positional argument instead of a
|
|
130
|
+
* hung process) or when the user presses Ctrl-C.
|
|
131
|
+
*
|
|
132
|
+
* `renderFn` is injectable so the wrapper body is fully covered in
|
|
133
|
+
* tests via the synthetic-stream `render` in `test-utils.ts`.
|
|
134
|
+
* Production callers pass nothing and get `defaultRenderer`.
|
|
135
|
+
*/
|
|
136
|
+
export async function pickName(
|
|
137
|
+
parentDir: string,
|
|
138
|
+
renderFn: InkRenderer = defaultRenderer,
|
|
139
|
+
): Promise<string> {
|
|
140
|
+
// Check BOTH streams: stdin must be a TTY for Ink's `useInput` to call
|
|
141
|
+
// `setRawMode` (otherwise Ink throws inside a useEffect AFTER pickName
|
|
142
|
+
// has returned its Promise — the throw never rejects the Promise, so
|
|
143
|
+
// the process hangs with a stack trace). stdout must be a TTY for ink
|
|
144
|
+
// to render frames the user can see. If either is missing, fail fast
|
|
145
|
+
// here with a clear error.
|
|
146
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
147
|
+
throw new CliError(
|
|
148
|
+
`Cannot prompt for an app name in a non-TTY environment. ` +
|
|
149
|
+
`Pass the app name as a positional argument: ${cliName()} tiles init <app-name>.`,
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
return new Promise<string>((resolve, reject) => {
|
|
153
|
+
const instance = renderFn(
|
|
154
|
+
createElement(NameInput, {
|
|
155
|
+
parentDir,
|
|
156
|
+
onSubmit: (name: string) => {
|
|
157
|
+
instance.unmount();
|
|
158
|
+
resolve(name);
|
|
159
|
+
},
|
|
160
|
+
onCancel: () => {
|
|
161
|
+
instance.unmount();
|
|
162
|
+
reject(new CliError("Cancelled."));
|
|
163
|
+
},
|
|
164
|
+
}),
|
|
165
|
+
);
|
|
166
|
+
});
|
|
167
|
+
}
|