@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.
Files changed (303) hide show
  1. package/README.md +30 -2
  2. package/bundled-resources/poe-tile-templates/base/CLAUDE.md +72 -0
  3. package/bundled-resources/poe-tile-templates/base/README.md +7 -0
  4. package/bundled-resources/poe-tile-templates/base/_bunfig.toml +8 -0
  5. package/bundled-resources/poe-tile-templates/base/_gitignore +18 -0
  6. package/bundled-resources/poe-tile-templates/base/client.ts +12 -0
  7. package/bundled-resources/poe-tile-templates/base/package.json +36 -0
  8. package/bundled-resources/poe-tile-templates/base/playwright.config.ts +38 -0
  9. package/bundled-resources/poe-tile-templates/base/scripts/check-source.ts +148 -0
  10. package/bundled-resources/poe-tile-templates/base/scripts/dev.ts +19 -0
  11. package/bundled-resources/poe-tile-templates/base/scripts/doctor.sh +29 -0
  12. package/bundled-resources/poe-tile-templates/base/scripts/visual-check.ts +64 -0
  13. package/bundled-resources/poe-tile-templates/base/synced-store/backend-config.ts +9 -0
  14. package/bundled-resources/poe-tile-templates/base/synced-store/client-config.ts +8 -0
  15. package/bundled-resources/poe-tile-templates/base/synced-store/data/items.ts +16 -0
  16. package/bundled-resources/poe-tile-templates/base/synced-store/mutators/index.ts +10 -0
  17. package/bundled-resources/poe-tile-templates/base/synced-store/mutators/remove-todo.ts +5 -0
  18. package/bundled-resources/poe-tile-templates/base/synced-store/mutators/set-todo.ts +20 -0
  19. package/bundled-resources/poe-tile-templates/base/synced-store/mutators/types.ts +5 -0
  20. package/bundled-resources/poe-tile-templates/base/synced-store/mutators.test.ts +138 -0
  21. package/bundled-resources/poe-tile-templates/base/synced-store/schema.ts +40 -0
  22. package/bundled-resources/poe-tile-templates/base/tests/e2e.test.playwright.ts +92 -0
  23. package/bundled-resources/poe-tile-templates/base/tests/mobile-viewport.test.playwright.ts +111 -0
  24. package/bundled-resources/poe-tile-templates/base/tests/render-check.test.playwright.ts +128 -0
  25. package/bundled-resources/poe-tile-templates/base/tests/screenshot.test.playwright.ts +86 -0
  26. package/bundled-resources/poe-tile-templates/base/tests/setup-dom.ts +70 -0
  27. package/bundled-resources/poe-tile-templates/base/tile/src/backend.ts +3 -0
  28. package/bundled-resources/poe-tile-templates/base/tile/styles.css +47 -0
  29. package/bundled-resources/poe-tile-templates/base/tsconfig.json +13 -0
  30. package/bundled-resources/poe-tile-templates/coverage.config.json +6 -0
  31. package/bundled-resources/poe-tile-templates/index.ts +27 -0
  32. package/bundled-resources/poe-tile-templates/package.json +31 -0
  33. package/bundled-resources/poe-tile-templates/phaserjs/package.partial.json +6 -0
  34. package/bundled-resources/poe-tile-templates/phaserjs/tile/index.html +14 -0
  35. package/bundled-resources/poe-tile-templates/phaserjs/tile/src/entry.ts +35 -0
  36. package/bundled-resources/poe-tile-templates/phaserjs/ui/App.test.happydom.tsx +98 -0
  37. package/bundled-resources/poe-tile-templates/phaserjs/ui/App.ts +180 -0
  38. package/bundled-resources/poe-tile-templates/phaserjs/ui/phaser-scene.ts +174 -0
  39. package/bundled-resources/poe-tile-templates/phaserjs/vite.config.ts +28 -0
  40. package/bundled-resources/poe-tile-templates/preact/package.partial.json +9 -0
  41. package/bundled-resources/poe-tile-templates/preact/postcss.config.js +5 -0
  42. package/bundled-resources/poe-tile-templates/preact/tile/index.html +14 -0
  43. package/bundled-resources/poe-tile-templates/preact/tile/src/entry.tsx +36 -0
  44. package/bundled-resources/poe-tile-templates/preact/tile/styles.css +51 -0
  45. package/bundled-resources/poe-tile-templates/preact/tsconfig.json +15 -0
  46. package/bundled-resources/poe-tile-templates/preact/ui/App.test.happydom.tsx +69 -0
  47. package/bundled-resources/poe-tile-templates/preact/ui/App.tsx +116 -0
  48. package/bundled-resources/poe-tile-templates/preact/vite.config.ts +18 -0
  49. package/bundled-resources/poe-tile-templates/react/package.partial.json +12 -0
  50. package/bundled-resources/poe-tile-templates/react/postcss.config.js +5 -0
  51. package/bundled-resources/poe-tile-templates/react/tile/index.html +14 -0
  52. package/bundled-resources/poe-tile-templates/react/tile/src/entry.tsx +38 -0
  53. package/bundled-resources/poe-tile-templates/react/tile/styles.css +51 -0
  54. package/bundled-resources/poe-tile-templates/react/tsconfig.json +14 -0
  55. package/bundled-resources/poe-tile-templates/react/ui/App.test.happydom.tsx +71 -0
  56. package/bundled-resources/poe-tile-templates/react/ui/App.tsx +110 -0
  57. package/bundled-resources/poe-tile-templates/react/vite.config.ts +21 -0
  58. package/bundled-resources/poe-tile-templates/scripts/cleanup.ts +10 -0
  59. package/bundled-resources/poe-tile-templates/scripts/generate.ts +57 -0
  60. package/bundled-resources/poe-tile-templates/scripts/install-diagnostics.ts +52 -0
  61. package/bundled-resources/poe-tile-templates/scripts/paths.ts +7 -0
  62. package/bundled-resources/poe-tile-templates/scripts/sdk-dependency-key.ts +288 -0
  63. package/bundled-resources/poe-tile-templates/scripts/verify-all-sdks.ts +132 -0
  64. package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-command.ts +30 -0
  65. package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-tarball.ts +397 -0
  66. package/bundled-resources/poe-tile-templates/solidjs/_bunfig.toml +14 -0
  67. package/bundled-resources/poe-tile-templates/solidjs/package.partial.json +13 -0
  68. package/bundled-resources/poe-tile-templates/solidjs/postcss.config.js +5 -0
  69. package/bundled-resources/poe-tile-templates/solidjs/tests/solid-plugin.ts +49 -0
  70. package/bundled-resources/poe-tile-templates/solidjs/tile/index.html +14 -0
  71. package/bundled-resources/poe-tile-templates/solidjs/tile/src/entry.tsx +36 -0
  72. package/bundled-resources/poe-tile-templates/solidjs/tile/styles.css +51 -0
  73. package/bundled-resources/poe-tile-templates/solidjs/tsconfig.json +15 -0
  74. package/bundled-resources/poe-tile-templates/solidjs/ui/App.test.happydom.tsx +70 -0
  75. package/bundled-resources/poe-tile-templates/solidjs/ui/App.tsx +129 -0
  76. package/bundled-resources/poe-tile-templates/solidjs/vite.config.ts +18 -0
  77. package/bundled-resources/poe-tile-templates/tests/check-source.test.ts +131 -0
  78. package/bundled-resources/poe-tile-templates/tests/dev-script.test.slow.ts +166 -0
  79. package/bundled-resources/poe-tile-templates/tests/fixtures/customized-manager.ts +67 -0
  80. package/bundled-resources/poe-tile-templates/tests/fixtures/extended-mutators.ts.txt +106 -0
  81. package/bundled-resources/poe-tile-templates/tests/fixtures/multiplayer-verification.test.playwright.ts.txt +103 -0
  82. package/bundled-resources/poe-tile-templates/tests/fixtures/replace-starter-schema.ts +67 -0
  83. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/phaserjs.tsx.txt +85 -0
  84. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/preact.tsx.txt +69 -0
  85. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/react.tsx.txt +73 -0
  86. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/seating.ts.txt +54 -0
  87. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/solidjs.tsx.txt +70 -0
  88. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/vanilla-js.tsx.txt +85 -0
  89. package/bundled-resources/poe-tile-templates/tests/generated-templates.test.ts +278 -0
  90. package/bundled-resources/poe-tile-templates/tests/happy-dom-version.test.ts +27 -0
  91. package/bundled-resources/poe-tile-templates/tests/install-diagnostics.test.ts +99 -0
  92. package/bundled-resources/poe-tile-templates/tests/native-gesture-defaults.test.ts +23 -0
  93. package/bundled-resources/poe-tile-templates/tests/playwright-version.test.ts +84 -0
  94. package/bundled-resources/poe-tile-templates/tests/render-check-scaffold.test.ts +56 -0
  95. package/bundled-resources/poe-tile-templates/tests/sdk-dependency-key.test.ts +129 -0
  96. package/bundled-resources/poe-tile-templates/tests/visual-check.test.ts +90 -0
  97. package/bundled-resources/poe-tile-templates/vanilla-js/package.partial.json +3 -0
  98. package/bundled-resources/poe-tile-templates/vanilla-js/tile/index.html +14 -0
  99. package/bundled-resources/poe-tile-templates/vanilla-js/tile/src/entry.ts +35 -0
  100. package/bundled-resources/poe-tile-templates/vanilla-js/ui/App.test.happydom.tsx +96 -0
  101. package/bundled-resources/poe-tile-templates/vanilla-js/ui/App.ts +113 -0
  102. package/bundled-resources/poe-tile-templates/vanilla-js/vite.config.ts +17 -0
  103. package/cli.ts +134 -0
  104. package/index.ts +96 -0
  105. package/package.json +48 -5
  106. package/skills/audio-generation/.generated-by-poe-templated-docs +0 -0
  107. package/skills/audio-generation/SKILL.md +125 -0
  108. package/skills/finish-prototype/.generated-by-poe-templated-docs +0 -0
  109. package/skills/finish-prototype/SKILL.md +22 -0
  110. package/skills/help-me-build/.generated-by-poe-templated-docs +0 -0
  111. package/skills/help-me-build/SKILL.md +56 -0
  112. package/skills/image-generation/.generated-by-poe-templated-docs +0 -0
  113. package/skills/image-generation/SKILL.md +128 -0
  114. package/skills/one-shot/.generated-by-poe-templated-docs +0 -0
  115. package/skills/one-shot/SKILL.md +22 -0
  116. package/skills/platform-prototype/.generated-by-poe-templated-docs +0 -0
  117. package/skills/platform-prototype/SKILL.md +60 -0
  118. package/skills/platform-subagent/.generated-by-poe-templated-docs +0 -0
  119. package/skills/platform-subagent/SKILL.md +16 -0
  120. package/skills/poe-tiles-cli/.generated-by-poe-templated-docs +0 -0
  121. package/skills/poe-tiles-cli/SKILL.md +609 -0
  122. package/skills/poe-tiles-cli/references/device-motion.md +40 -0
  123. package/skills/poe-tiles-cli/references/player-updates.md +41 -0
  124. package/skills/prototype/.generated-by-poe-templated-docs +0 -0
  125. package/skills/prototype/SKILL.md +148 -0
  126. package/skills/publish/.generated-by-poe-templated-docs +0 -0
  127. package/skills/publish/SKILL.md +73 -0
  128. package/skills/synced-store/.generated-by-poe-templated-docs +0 -0
  129. package/skills/synced-store/SKILL.md +583 -0
  130. package/skills/synced-store/references/actions.md +85 -0
  131. package/skills/synced-store/references/api-patterns.md +245 -0
  132. package/skills/synced-store/references/architecture-scaling-and-performance.md +280 -0
  133. package/skills/synced-store/references/client-api-reference.md +263 -0
  134. package/skills/synced-store/references/data-visibility.md +95 -0
  135. package/skills/synced-store/references/external-stores.md +162 -0
  136. package/skills/synced-store/references/file-uploads.md +216 -0
  137. package/skills/synced-store/references/getting-user-info-of-members.md +228 -0
  138. package/skills/synced-store/references/limitations.md +72 -0
  139. package/skills/synced-store/references/live-data-limit-hook.md +131 -0
  140. package/skills/synced-store/references/mutator-rules.md +169 -0
  141. package/skills/synced-store/references/platform.md +49 -0
  142. package/skills/synced-store/references/schema-and-bindings.md +85 -0
  143. package/skills/synced-store/references/schema-libraries.md +57 -0
  144. package/skills/synced-store/references/schema-migrations.md +119 -0
  145. package/skills/synced-store/references/searchable-tables.md +27 -0
  146. package/skills/synced-store/references/server-forking.md +115 -0
  147. package/skills/synced-store/references/singleton-tables.md +61 -0
  148. package/skills/synced-store/references/sort-keys.md +253 -0
  149. package/skills/synced-store/references/ui-patterns.md +95 -0
  150. package/skills/tile-creator/.generated-by-poe-templated-docs +0 -0
  151. package/skills/tile-creator/SKILL.md +196 -0
  152. package/skills/tile-creator/references/assets.md +124 -0
  153. package/skills/tile-creator/references/backend-api.md +308 -0
  154. package/skills/tile-creator/references/cli-limitations.md +64 -0
  155. package/skills/tile-creator/references/cli.md +604 -0
  156. package/skills/tile-creator/references/client-api.md +2407 -0
  157. package/skills/tile-creator/references/composing-apps.md +166 -0
  158. package/skills/tile-creator/references/e2e-tests.md +55 -0
  159. package/skills/tile-creator/references/game-ux-best-practices.md +57 -0
  160. package/skills/tile-creator/references/migrating-pre-rename-tiles.md +79 -0
  161. package/skills/tile-creator/references/multiplayer-api-recipe.md +205 -0
  162. package/skills/tile-creator/references/native-results.md +100 -0
  163. package/skills/tile-creator/references/platform-integration.md +201 -0
  164. package/skills/tile-creator/references/power-report.md +199 -0
  165. package/skills/tile-creator/references/publish-rollout.md +166 -0
  166. package/skills/tile-creator/references/publishing.md +33 -0
  167. package/skills/tile-creator/references/push-notification-guidelines.md +58 -0
  168. package/skills/tile-creator/references/render-check.md +266 -0
  169. package/skills/tile-creator/references/running-the-client-api-on-a-server-owned-by-the-user.md +95 -0
  170. package/skills/tile-creator/references/safe-area-insets.md +79 -0
  171. package/skills/tile-creator/references/sandbox-limitations.md +32 -0
  172. package/skills/tile-creator/references/scaffolded-tile-folder-structure.md +48 -0
  173. package/skills/tile-creator/references/scaffolding-a-new-app.md +202 -0
  174. package/skills/tile-creator/references/simulations.md +125 -0
  175. package/skills/tile-creator/references/synced-store-client-reference.md +92 -0
  176. package/skills/tile-creator/references/troubleshooting.md +22 -0
  177. package/skills/tile-creator/references/turn-based-mutator.md +43 -0
  178. package/skills/tile-creator/references/user-erasure.md +14 -0
  179. package/skills/tile-creator/references/vite-plugin.md +166 -0
  180. package/skills/tile-creator/references/workspace-retention.md +72 -0
  181. package/src/admin-conversions-client.ts +28 -0
  182. package/src/admin-reviews-client.ts +36 -0
  183. package/src/api.generated.ts +1527 -0
  184. package/src/auth-token.ts +198 -0
  185. package/src/bounded-read.ts +35 -0
  186. package/src/bun-version.ts +33 -0
  187. package/src/checkout-base.ts +207 -0
  188. package/src/cli-bun-version.ts +16 -0
  189. package/src/cli-env.ts +28 -0
  190. package/src/cli-name.ts +23 -0
  191. package/src/client.ts +2474 -0
  192. package/src/collect-files.ts +226 -0
  193. package/src/commands/accounts.ts +55 -0
  194. package/src/commands/admin-abandon-conversion.ts +60 -0
  195. package/src/commands/admin-reviews.ts +66 -0
  196. package/src/commands/admin.ts +219 -0
  197. package/src/commands/auth.ts +89 -0
  198. package/src/commands/checkout-prototype.ts +67 -0
  199. package/src/commands/creator-source-capability.ts +11 -0
  200. package/src/commands/doctor-bun.ts +145 -0
  201. package/src/commands/doctor-command.ts +64 -0
  202. package/src/commands/doctor-package-json.ts +47 -0
  203. package/src/commands/doctor-sdk-pin.ts +156 -0
  204. package/src/commands/doctor-store-keys-lexer.ts +213 -0
  205. package/src/commands/doctor-store-keys-scan.ts +262 -0
  206. package/src/commands/doctor-store-keys.ts +196 -0
  207. package/src/commands/doctor.ts +371 -0
  208. package/src/commands/init/blank-scaffold-templates.ts +397 -0
  209. package/src/commands/init/index.ts +170 -0
  210. package/src/commands/init/internal-toolchain.ts +49 -0
  211. package/src/commands/init/manager-test-template.ts +107 -0
  212. package/src/commands/init/multiplayer-test-template.ts +217 -0
  213. package/src/commands/init/name-input.tsx +167 -0
  214. package/src/commands/init/no-store-scaffold-templates.ts +281 -0
  215. package/src/commands/init/no-store-scaffold.ts +134 -0
  216. package/src/commands/init/package-json-scripts.ts +72 -0
  217. package/src/commands/init/scaffold.ts +960 -0
  218. package/src/commands/init/sdk-tarball-url.generated.ts +4 -0
  219. package/src/commands/init/sdk-tarball-url.ts +31 -0
  220. package/src/commands/init/template-picker.tsx +147 -0
  221. package/src/commands/inspect-child-entry.ts +107 -0
  222. package/src/commands/inspect-contract.ts +87 -0
  223. package/src/commands/inspect-freshness.ts +217 -0
  224. package/src/commands/inspect-lock.ts +201 -0
  225. package/src/commands/inspect-options.ts +360 -0
  226. package/src/commands/inspect-orchestrate.ts +375 -0
  227. package/src/commands/inspect-process.ts +172 -0
  228. package/src/commands/inspect-ready.ts +65 -0
  229. package/src/commands/inspect-report.ts +235 -0
  230. package/src/commands/inspect-run-state.ts +296 -0
  231. package/src/commands/inspect-run.ts +157 -0
  232. package/src/commands/inspect-watchdog.ts +74 -0
  233. package/src/commands/install-joiner.ts +208 -0
  234. package/src/commands/login.ts +308 -0
  235. package/src/commands/models.ts +40 -0
  236. package/src/commands/parse-options.ts +36 -0
  237. package/src/commands/remix-package-json.ts +64 -0
  238. package/src/commands/remix.ts +379 -0
  239. package/src/commands/sdk-url.ts +141 -0
  240. package/src/commands/simulations.ts +133 -0
  241. package/src/commands/skills.ts +108 -0
  242. package/src/commands/store-files.ts +92 -0
  243. package/src/commands/stores.ts +703 -0
  244. package/src/commands/tiles-channel-commands.ts +115 -0
  245. package/src/commands/tiles-checkout.ts +351 -0
  246. package/src/commands/tiles-gallery-command.ts +95 -0
  247. package/src/commands/tiles-get-helpers.ts +27 -0
  248. package/src/commands/tiles-inspect.ts +276 -0
  249. package/src/commands/tiles-power-command.ts +308 -0
  250. package/src/commands/tiles-power-format.ts +396 -0
  251. package/src/commands/tiles-power-versions.ts +299 -0
  252. package/src/commands/tiles-publish-helpers.ts +145 -0
  253. package/src/commands/tiles-upload-command.ts +277 -0
  254. package/src/commands/tiles-version-commands.ts +201 -0
  255. package/src/commands/tiles-visibility-command.ts +103 -0
  256. package/src/commands/tiles.ts +257 -0
  257. package/src/commands/upgrade.ts +307 -0
  258. package/src/commit-in-progress.ts +42 -0
  259. package/src/creator-source-context.ts +97 -0
  260. package/src/creator-source-publish.ts +52 -0
  261. package/src/deferred-assets.ts +125 -0
  262. package/src/distribution.ts +28 -0
  263. package/src/errors.ts +61 -0
  264. package/src/install-command.ts +43 -0
  265. package/src/output.ts +62 -0
  266. package/src/poe-tile-config-files.ts +100 -0
  267. package/src/poe-tile-config-players.ts +168 -0
  268. package/src/poe-tile-config-remix.ts +166 -0
  269. package/src/poe-tile-config.ts +831 -0
  270. package/src/power-report-client.ts +55 -0
  271. package/src/prototype-startup.ts +21 -0
  272. package/src/publish-change-summary.ts +55 -0
  273. package/src/publish-overrides-validation.ts +49 -0
  274. package/src/publish-pack.ts +167 -0
  275. package/src/publish-phases.ts +57 -0
  276. package/src/publish-retry.ts +51 -0
  277. package/src/publish-tile-from-config.ts +434 -0
  278. package/src/recorder-stream.ts +169 -0
  279. package/src/remix-provenance.ts +156 -0
  280. package/src/resolve-client-credential.ts +71 -0
  281. package/src/resolve-media-uploads.ts +147 -0
  282. package/src/sdk-dependency.ts +54 -0
  283. package/src/sdk-skills.ts +85 -0
  284. package/src/should-skip-client-setup.ts +20 -0
  285. package/src/simulation-snapshot.ts +123 -0
  286. package/src/simulation-types.ts +74 -0
  287. package/src/simulations-client.ts +112 -0
  288. package/src/source-bundle.ts +466 -0
  289. package/src/staged-publish-cleanup.ts +44 -0
  290. package/src/staged-publish-deferred.ts +160 -0
  291. package/src/staged-publish.ts +401 -0
  292. package/src/store-file-upload.ts +268 -0
  293. package/src/store-request.ts +168 -0
  294. package/src/tar-canonical.ts +41 -0
  295. package/src/tar-extensions.ts +159 -0
  296. package/src/tar-extract.ts +193 -0
  297. package/src/tar-parse.ts +224 -0
  298. package/src/tar.ts +231 -0
  299. package/src/template-check-scripts.ts +18 -0
  300. package/src/tile-gallery-client.ts +82 -0
  301. package/src/types.ts +258 -0
  302. package/src/upload-concurrency.ts +54 -0
  303. 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
+ }