@playdrop/playdrop-cli 0.16.2 → 0.16.11
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/bin/playdrop +1 -2
- package/config/client-meta.json +4 -4
- package/dist/apiClient.d.ts +2 -2
- package/dist/apiClient.js +16 -20
- package/dist/appUrls.d.ts +2 -2
- package/dist/appUrls.js +31 -33
- package/dist/apps/build.d.ts +2 -2
- package/dist/apps/build.js +83 -83
- package/dist/apps/index.d.ts +7 -7
- package/dist/apps/index.js +8 -8
- package/dist/apps/loadCheck.d.ts +28 -16
- package/dist/apps/loadCheck.js +411 -279
- package/dist/apps/registration.d.ts +3 -3
- package/dist/apps/registration.js +1 -1
- package/dist/apps/staticHtml.d.ts +3 -3
- package/dist/apps/staticHtml.js +90 -91
- package/dist/apps/surfaceProfiles.d.ts +2 -2
- package/dist/apps/surfaceProfiles.js +6 -6
- package/dist/apps/upload.d.ts +5 -5
- package/dist/apps/upload.js +75 -81
- package/dist/apps/validate.d.ts +2 -2
- package/dist/apps/validate.js +18 -22
- package/dist/assetSpecs.d.ts +2 -2
- package/dist/assetSpecs.js +35 -35
- package/dist/assets/model-artifacts.d.ts +1 -1
- package/dist/assets/model-artifacts.js +81 -77
- package/dist/assets/model-worker.d.ts +1 -1
- package/dist/assets/model-worker.js +6 -6
- package/dist/browser.js +9 -9
- package/dist/catalogue-utils.d.ts +1 -1
- package/dist/catalogue-utils.js +26 -26
- package/dist/catalogue.d.ts +21 -16
- package/dist/catalogue.js +509 -413
- package/dist/clientInfo.d.ts +1 -1
- package/dist/clientInfo.js +28 -28
- package/dist/commandContext.d.ts +5 -5
- package/dist/commandContext.js +19 -23
- package/dist/commands/accounts.js +6 -6
- package/dist/commands/ads.js +16 -16
- package/dist/commands/agents.d.ts +2 -2
- package/dist/commands/agents.js +131 -127
- package/dist/commands/boosts.js +41 -31
- package/dist/commands/browse.d.ts +2 -2
- package/dist/commands/browse.js +168 -128
- package/dist/commands/build.js +9 -9
- package/dist/commands/captureListing.d.ts +8 -8
- package/dist/commands/captureListing.js +292 -332
- package/dist/commands/changelog.js +1 -1
- package/dist/commands/chat.js +51 -53
- package/dist/commands/check.d.ts +1 -1
- package/dist/commands/check.js +44 -44
- package/dist/commands/clients.d.ts +3 -3
- package/dist/commands/clients.js +67 -64
- package/dist/commands/comments.js +36 -29
- package/dist/commands/create.js +305 -312
- package/dist/commands/createRemixContent.d.ts +1 -1
- package/dist/commands/createRemixContent.js +65 -60
- package/dist/commands/creations.js +205 -135
- package/dist/commands/credits.js +37 -27
- package/dist/commands/detail.js +40 -34
- package/dist/commands/dev.js +103 -126
- package/dist/commands/devBrowser.js +74 -65
- package/dist/commands/devRuntimeAssets.d.ts +4 -4
- package/dist/commands/devRuntimeAssets.js +38 -40
- package/dist/commands/devServer.d.ts +4 -4
- package/dist/commands/devServer.js +183 -174
- package/dist/commands/devShared.d.ts +3 -3
- package/dist/commands/devShared.js +31 -31
- package/dist/commands/doctor.d.ts +5 -5
- package/dist/commands/doctor.js +63 -57
- package/dist/commands/documentation.js +42 -32
- package/dist/commands/feedback.js +59 -42
- package/dist/commands/format.js +9 -9
- package/dist/commands/generation.d.ts +2 -2
- package/dist/commands/generation.js +344 -326
- package/dist/commands/init.d.ts +4 -4
- package/dist/commands/init.js +64 -61
- package/dist/commands/login.d.ts +2 -2
- package/dist/commands/login.js +42 -62
- package/dist/commands/logout.js +4 -4
- package/dist/commands/marketing.d.ts +8 -8
- package/dist/commands/marketing.js +246 -297
- package/dist/commands/notes.js +19 -19
- package/dist/commands/notifications.js +34 -22
- package/dist/commands/npmProcess.js +3 -3
- package/dist/commands/ownedRuntimeImageValidation.d.ts +1 -1
- package/dist/commands/ownedRuntimeImageValidation.js +19 -17
- package/dist/commands/play.js +12 -21
- package/dist/commands/publicPages.js +8 -4
- package/dist/commands/review.js +123 -110
- package/dist/commands/search.js +107 -88
- package/dist/commands/tags.js +10 -12
- package/dist/commands/taskCaptureSession.d.ts +3 -3
- package/dist/commands/taskCaptureSession.js +3 -3
- package/dist/commands/tweaks.js +25 -23
- package/dist/commands/upgrade.js +40 -31
- package/dist/commands/upload-content.d.ts +5 -5
- package/dist/commands/upload-content.js +130 -122
- package/dist/commands/upload-graph.d.ts +1 -1
- package/dist/commands/upload-graph.js +7 -11
- package/dist/commands/upload.d.ts +7 -7
- package/dist/commands/upload.js +196 -217
- package/dist/commands/validate.js +33 -32
- package/dist/commands/versionsBrowse.js +61 -51
- package/dist/commands/whoami.js +11 -14
- package/dist/commands/worker/archive-staging.d.ts +9 -0
- package/dist/commands/worker/archive-staging.js +257 -0
- package/dist/commands/worker/instrument-evidence.d.ts +1 -1
- package/dist/commands/worker/instrument-evidence.js +41 -43
- package/dist/commands/worker/provider-telemetry.d.ts +2 -1
- package/dist/commands/worker/provider-telemetry.js +181 -64
- package/dist/commands/worker/runtime.d.ts +18 -3
- package/dist/commands/worker/runtime.js +291 -239
- package/dist/commands/worker.d.ts +83 -22
- package/dist/commands/worker.js +1980 -1411
- package/dist/commands/workspaces.d.ts +2 -2
- package/dist/commands/workspaces.js +57 -57
- package/dist/config.js +23 -20
- package/dist/devAuth.d.ts +3 -3
- package/dist/devAuth.js +20 -17
- package/dist/environment.d.ts +1 -1
- package/dist/environment.js +34 -34
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +7 -7
- package/dist/externalAssetPackValidation.d.ts +1 -1
- package/dist/externalAssetPackValidation.js +9 -9
- package/dist/http.d.ts +1 -1
- package/dist/http.js +9 -9
- package/dist/index.js +657 -664
- package/dist/listingCaptureLease.js +23 -23
- package/dist/listingPreflight.d.ts +2 -2
- package/dist/listingPreflight.js +33 -33
- package/dist/messages.js +6 -14
- package/dist/output.js +9 -9
- package/dist/playwright.d.ts +1 -1
- package/dist/playwright.js +35 -40
- package/dist/proxyFetch.js +30 -27
- package/dist/recorderRelease.js +8 -8
- package/dist/refs.d.ts +5 -5
- package/dist/refs.js +40 -37
- package/dist/sessionCookie.js +15 -21
- package/dist/shellProbe.js +5 -5
- package/dist/taskSelection.d.ts +3 -3
- package/dist/taskSelection.js +67 -62
- package/dist/taskUtils.d.ts +1 -1
- package/dist/taskUtils.js +4 -4
- package/dist/tweakStaleness.d.ts +3 -3
- package/dist/tweakStaleness.js +8 -8
- package/dist/uploadLog.d.ts +3 -3
- package/dist/uploadLog.js +51 -51
- package/dist/versionCompare.js +3 -3
- package/dist/workerAppProject.d.ts +1 -1
- package/dist/workerAppProject.js +10 -17
- package/dist/workspaceAuth.d.ts +1 -1
- package/dist/workspaceAuth.js +28 -22
- package/node_modules/@playdrop/ai-client/dist/index.d.ts +35 -35
- package/node_modules/@playdrop/ai-client/dist/index.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/client.d.ts +34 -33
- package/node_modules/@playdrop/api-client/dist/client.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/core/errors.d.ts +1 -1
- package/node_modules/@playdrop/api-client/dist/core/errors.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/core/request.d.ts +2 -2
- package/node_modules/@playdrop/api-client/dist/core/request.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/admin.d.ts +2 -2
- package/node_modules/@playdrop/api-client/dist/domains/admin.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/admin.js +4 -1
- package/node_modules/@playdrop/api-client/dist/domains/agent-tasks.d.ts +4 -3
- package/node_modules/@playdrop/api-client/dist/domains/agent-tasks.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/agent-tasks.js +12 -0
- package/node_modules/@playdrop/api-client/dist/domains/ai.d.ts +2 -2
- package/node_modules/@playdrop/api-client/dist/domains/ai.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts +4 -4
- package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/asset-packs.d.ts +4 -4
- package/node_modules/@playdrop/api-client/dist/domains/asset-packs.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts +4 -4
- package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/auth.d.ts +2 -2
- package/node_modules/@playdrop/api-client/dist/domains/auth.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/chat.d.ts +2 -2
- package/node_modules/@playdrop/api-client/dist/domains/chat.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/comments.d.ts +3 -3
- package/node_modules/@playdrop/api-client/dist/domains/comments.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/free-credits.d.ts +2 -2
- package/node_modules/@playdrop/api-client/dist/domains/free-credits.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/me.d.ts +2 -2
- package/node_modules/@playdrop/api-client/dist/domains/me.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/payments.d.ts +2 -2
- package/node_modules/@playdrop/api-client/dist/domains/payments.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/player-meta.d.ts +2 -2
- package/node_modules/@playdrop/api-client/dist/domains/player-meta.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/playtrade.d.ts +3 -3
- package/node_modules/@playdrop/api-client/dist/domains/playtrade.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/playtrade.js +2 -2
- package/node_modules/@playdrop/api-client/dist/domains/search.d.ts +2 -2
- package/node_modules/@playdrop/api-client/dist/domains/search.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/tags.d.ts +2 -2
- package/node_modules/@playdrop/api-client/dist/domains/tags.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/index.d.ts +19 -18
- package/node_modules/@playdrop/api-client/dist/index.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/index.js +7 -2
- package/node_modules/@playdrop/boxel-core/dist/src/entity-cleaner.d.ts +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/entity-cleaner.js +47 -47
- package/node_modules/@playdrop/boxel-core/dist/src/entity-cleaner.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/entity-utils.d.ts +3 -3
- package/node_modules/@playdrop/boxel-core/dist/src/entity-utils.js +32 -47
- package/node_modules/@playdrop/boxel-core/dist/src/entity-utils.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/format-utils.js +16 -18
- package/node_modules/@playdrop/boxel-core/dist/src/format-utils.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/geometry.d.ts +2 -2
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/index.d.ts +4 -4
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/common.d.ts +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/index.d.ts +3 -3
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/textured-builder.d.ts +2 -2
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/textured-builder.js +44 -45
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/textured-builder.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/types.d.ts +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/voxel-builder.d.ts +2 -2
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/voxel-builder.js +40 -44
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/voxel-builder.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/builder.d.ts +2 -2
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/builder.js +30 -34
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/builder.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/index.d.ts +4 -4
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/index.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/scanner.d.ts +3 -3
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/scanner.js +23 -20
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/scanner.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/artifacts.d.ts +3 -3
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/artifacts.js +3 -3
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/face-map.d.ts +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/face-map.js +21 -21
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/face-map.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/index.d.ts +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/index.js +2 -2
- package/node_modules/@playdrop/boxel-core/dist/src/index.d.ts +19 -19
- package/node_modules/@playdrop/boxel-core/dist/src/materials.d.ts +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/materials.js +12 -16
- package/node_modules/@playdrop/boxel-core/dist/src/materials.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/palette_tools.d.ts +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/palette_tools.js +38 -41
- package/node_modules/@playdrop/boxel-core/dist/src/palette_tools.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/serialization.d.ts +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/serialization.js +54 -56
- package/node_modules/@playdrop/boxel-core/dist/src/serialization.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/textures.d.ts +3 -3
- package/node_modules/@playdrop/boxel-core/dist/src/textures.js +39 -45
- package/node_modules/@playdrop/boxel-core/dist/src/textures.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/infer-face.d.ts +2 -2
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/infer-face.js +39 -43
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/infer-face.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/layer-mode.d.ts +3 -3
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/layer-mode.js +35 -35
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/layer-mode.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/merge-overlay.d.ts +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/merge-overlay.js +18 -18
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/merge-overlay.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/slice.d.ts +3 -3
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/slice.js +50 -48
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/slice.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/upscale.d.ts +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/upscale.js +22 -26
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/upscale.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/slice.d.ts +2 -2
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/slice.js +8 -8
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/slice.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/textured-to-voxel.d.ts +2 -2
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/textured-to-voxel.js +23 -28
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/textured-to-voxel.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/types.d.ts +8 -8
- package/node_modules/@playdrop/boxel-core/dist/src/validation.d.ts +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/validation.js +93 -95
- package/node_modules/@playdrop/boxel-core/dist/src/validation.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/voxels/greedy-mesher.d.ts +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/voxels/greedy-mesher.js +2 -2
- package/node_modules/@playdrop/boxel-core/dist/src/voxels/greedy-mesher.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/voxels.d.ts +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/voxels.js +2 -7
- package/node_modules/@playdrop/boxel-core/dist/src/voxels.js.map +1 -1
- package/node_modules/@playdrop/boxel-three/dist/src/animations.d.ts +3 -3
- package/node_modules/@playdrop/boxel-three/dist/src/builders.d.ts +4 -4
- package/node_modules/@playdrop/boxel-three/dist/src/context.d.ts +3 -3
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/glb.d.ts +6 -6
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/glb.js +9 -1
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/image.d.ts +3 -3
- package/node_modules/@playdrop/boxel-three/dist/src/index.d.ts +17 -17
- package/node_modules/@playdrop/boxel-three/dist/src/instantiate.d.ts +9 -9
- package/node_modules/@playdrop/boxel-three/dist/src/nodes.d.ts +3 -3
- package/node_modules/@playdrop/boxel-three/dist/src/nodes.js +1 -1
- package/node_modules/@playdrop/boxel-three/dist/src/overlays.d.ts +2 -2
- package/node_modules/@playdrop/boxel-three/dist/src/primitives.d.ts +1 -1
- package/node_modules/@playdrop/boxel-three/dist/src/scene.d.ts +1 -1
- package/node_modules/@playdrop/boxel-three/dist/src/skinned-mesh.d.ts +2 -2
- package/node_modules/@playdrop/boxel-three/dist/src/texture-atlas.d.ts +1 -1
- package/node_modules/@playdrop/boxel-three/dist/src/textures.d.ts +3 -3
- package/node_modules/@playdrop/boxel-three/dist/src/types.d.ts +4 -4
- package/node_modules/@playdrop/boxel-three/dist/src/voxels/faces.d.ts +2 -2
- package/node_modules/@playdrop/boxel-three/dist/src/voxels/mesher.d.ts +1 -1
- package/node_modules/@playdrop/boxel-three/dist/test/fixtures/render-worker.d.ts +1 -1
- package/node_modules/@playdrop/config/client-meta.json +4 -4
- package/node_modules/@playdrop/config/dist/src/client-meta.d.ts +1 -1
- package/node_modules/@playdrop/config/dist/src/client-meta.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/client-meta.js +10 -10
- package/node_modules/@playdrop/config/dist/src/constants.js +10 -10
- package/node_modules/@playdrop/config/dist/src/creator-plans.d.ts +1 -1
- package/node_modules/@playdrop/config/dist/src/creator-plans.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/creator-plans.js +27 -28
- package/node_modules/@playdrop/config/dist/src/deployment.d.ts +4 -4
- package/node_modules/@playdrop/config/dist/src/deployment.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/deployment.js +42 -41
- package/node_modules/@playdrop/config/dist/src/game-arena.js +12 -12
- package/node_modules/@playdrop/config/dist/src/index.d.ts +9 -9
- package/node_modules/@playdrop/config/dist/src/index.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/index.js +24 -25
- package/node_modules/@playdrop/config/dist/src/public-deployment.d.ts +4 -4
- package/node_modules/@playdrop/config/dist/src/public-deployment.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/public-deployment.js +41 -39
- package/node_modules/@playdrop/config/dist/src/runtime-client-meta.js +1 -3
- package/node_modules/@playdrop/config/dist/src/runtime-service-origins.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/runtime-service-origins.js +23 -25
- package/node_modules/@playdrop/config/dist/src/server/fastify.d.ts +5 -5
- package/node_modules/@playdrop/config/dist/src/server/fastify.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/server/fastify.js +44 -46
- package/node_modules/@playdrop/config/dist/src/server/logging.d.ts +1 -1
- package/node_modules/@playdrop/config/dist/src/server/logging.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/server/logging.js +6 -8
- package/node_modules/@playdrop/config/dist/src/types.d.ts +2 -2
- package/node_modules/@playdrop/config/dist/test/creator-plans.test.js +12 -12
- package/node_modules/@playdrop/config/dist/test/deployment.test.js +59 -59
- package/node_modules/@playdrop/config/dist/test/fastify.test.js +4 -4
- package/node_modules/@playdrop/config/dist/test/game-arena.test.js +8 -8
- package/node_modules/@playdrop/config/dist/test/logging.test.js +6 -6
- package/node_modules/@playdrop/config/dist/test/validateClientEnvironment.test.js +57 -57
- package/node_modules/@playdrop/config/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@playdrop/types/dist/agent-task-playtest.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/agent-task-terminal.d.ts +2 -2
- package/node_modules/@playdrop/types/dist/agent-task-terminal.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/api.d.ts +314 -250
- package/node_modules/@playdrop/types/dist/api.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/api.js +40 -59
- package/node_modules/@playdrop/types/dist/app-capability-filters.d.ts +2 -2
- package/node_modules/@playdrop/types/dist/app-playtest-tape.d.ts +6 -6
- package/node_modules/@playdrop/types/dist/app-playtest-tape.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/app-review.d.ts +2 -2
- package/node_modules/@playdrop/types/dist/app-review.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/app-review.js +1 -6
- package/node_modules/@playdrop/types/dist/app.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/asset-pack.d.ts +5 -5
- package/node_modules/@playdrop/types/dist/asset-spec.d.ts +4 -4
- package/node_modules/@playdrop/types/dist/asset.d.ts +11 -11
- package/node_modules/@playdrop/types/dist/attachment-policy.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/chat.d.ts +3 -3
- package/node_modules/@playdrop/types/dist/creator-public-image.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/graph.d.ts +4 -4
- package/node_modules/@playdrop/types/dist/index.d.ts +25 -25
- package/node_modules/@playdrop/types/dist/instrument-evidence.d.ts +2 -2
- package/node_modules/@playdrop/types/dist/instrument-evidence.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/instrument-evidence.js +2 -11
- package/node_modules/@playdrop/types/dist/locale.d.ts +2 -2
- package/node_modules/@playdrop/types/dist/locale.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/locale.js +2 -17
- package/node_modules/@playdrop/types/dist/owned-assets.d.ts +2 -2
- package/node_modules/@playdrop/types/dist/owned-assets.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/player-meta.d.ts +3 -3
- package/node_modules/@playdrop/types/dist/player-meta.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/playtest-notes.d.ts +11 -11
- package/node_modules/@playdrop/types/dist/playtest-notes.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/playtrade.d.ts +8 -5
- package/node_modules/@playdrop/types/dist/playtrade.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/realtime.d.ts +1 -1
- package/node_modules/@playdrop/types/dist/tweaks.d.ts +4 -4
- package/node_modules/@playdrop/types/dist/tweaks.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/tweaks.js +12 -2
- package/node_modules/@playdrop/types/dist/version.d.ts +14 -14
- package/node_modules/@playdrop/types/dist/version.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/version.js +4 -1
- package/node_modules/@playdrop/vox-three/dist/src/index.d.ts +1 -1
- package/node_modules/@playdrop/vox-three/dist/src/vox.d.ts +2 -2
- package/node_modules/@playdrop/vox-three/dist/src/vox.js +20 -18
- package/node_modules/@playdrop/vox-three/dist/src/vox.js.map +1 -1
- package/node_modules/@playdrop/vox-three/dist/test/vox.test.js +11 -14
- package/node_modules/@playdrop/vox-three/dist/test/vox.test.js.map +1 -1
- package/package.json +1 -1
|
@@ -22,30 +22,27 @@ const node_http_1 = __importDefault(require("node:http"));
|
|
|
22
22
|
const node_path_1 = require("node:path");
|
|
23
23
|
const npmProcess_1 = require("./npmProcess");
|
|
24
24
|
exports.DEV_ROUTER_PORT = 8888;
|
|
25
|
-
const DEV_ROUTER_HOST =
|
|
26
|
-
const CONTROL_PREFIX =
|
|
25
|
+
const DEV_ROUTER_HOST = "127.0.0.1";
|
|
26
|
+
const CONTROL_PREFIX = "/_playdrop";
|
|
27
27
|
const DEV_ROUTER_PROTOCOL_VERSION = 3;
|
|
28
|
-
const APPROVED_PLAYDROP_WEB_ORIGINS = new Set([
|
|
29
|
-
'https://playdrop.ai',
|
|
30
|
-
'https://www.playdrop.ai',
|
|
31
|
-
]);
|
|
28
|
+
const APPROVED_PLAYDROP_WEB_ORIGINS = new Set(["https://playdrop.ai", "https://www.playdrop.ai"]);
|
|
32
29
|
const CONTENT_TYPE_BY_EXTENSION = {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
30
|
+
".html": "text/html; charset=utf-8",
|
|
31
|
+
".js": "application/javascript; charset=utf-8",
|
|
32
|
+
".mjs": "application/javascript; charset=utf-8",
|
|
33
|
+
".cjs": "application/javascript; charset=utf-8",
|
|
34
|
+
".css": "text/css; charset=utf-8",
|
|
35
|
+
".json": "application/json; charset=utf-8",
|
|
36
|
+
".png": "image/png",
|
|
37
|
+
".jpg": "image/jpeg",
|
|
38
|
+
".jpeg": "image/jpeg",
|
|
39
|
+
".svg": "image/svg+xml",
|
|
40
|
+
".webp": "image/webp",
|
|
41
|
+
".glb": "model/gltf-binary",
|
|
42
|
+
".gltf": "model/gltf+json",
|
|
43
|
+
".wasm": "application/wasm",
|
|
44
|
+
".mp4": "video/mp4",
|
|
45
|
+
".webm": "video/webm",
|
|
49
46
|
};
|
|
50
47
|
const routerMountsById = new Map();
|
|
51
48
|
const routerMountIdsByKey = new Map();
|
|
@@ -64,37 +61,37 @@ function resolveApprovedDevRouterOrigin(originHeader) {
|
|
|
64
61
|
if (APPROVED_PLAYDROP_WEB_ORIGINS.has(parsedOrigin.origin)) {
|
|
65
62
|
return parsedOrigin.origin;
|
|
66
63
|
}
|
|
67
|
-
const isLocalWebOrigin = (parsedOrigin.protocol ===
|
|
68
|
-
|
|
64
|
+
const isLocalWebOrigin = (parsedOrigin.protocol === "http:" || parsedOrigin.protocol === "https:") &&
|
|
65
|
+
(parsedOrigin.hostname === "localhost" || parsedOrigin.hostname === "127.0.0.1");
|
|
69
66
|
return isLocalWebOrigin ? parsedOrigin.origin : null;
|
|
70
67
|
}
|
|
71
68
|
function resolveContentType(filePath) {
|
|
72
69
|
const extension = (0, node_path_1.extname)(filePath).toLowerCase();
|
|
73
|
-
return CONTENT_TYPE_BY_EXTENSION[extension] ||
|
|
70
|
+
return CONTENT_TYPE_BY_EXTENSION[extension] || "application/octet-stream";
|
|
74
71
|
}
|
|
75
72
|
function getCliEntrypointPath() {
|
|
76
|
-
return (0, node_path_1.resolve)(__dirname,
|
|
73
|
+
return (0, node_path_1.resolve)(__dirname, "..", "index.js");
|
|
77
74
|
}
|
|
78
75
|
function buildMountKey(creatorUsername, appType, appName) {
|
|
79
76
|
return `${creatorUsername}:${appType}:${appName}`;
|
|
80
77
|
}
|
|
81
78
|
function encodeMountConflictError(details) {
|
|
82
|
-
const encoded = Buffer.from(JSON.stringify(details),
|
|
79
|
+
const encoded = Buffer.from(JSON.stringify(details), "utf8").toString("base64url");
|
|
83
80
|
return `mount_conflict:${encoded}`;
|
|
84
81
|
}
|
|
85
82
|
function parseMountConflictError(message) {
|
|
86
|
-
if (!message.startsWith(
|
|
83
|
+
if (!message.startsWith("mount_conflict:")) {
|
|
87
84
|
return null;
|
|
88
85
|
}
|
|
89
86
|
try {
|
|
90
|
-
const decoded = Buffer.from(message.slice(
|
|
87
|
+
const decoded = Buffer.from(message.slice("mount_conflict:".length), "base64url").toString("utf8");
|
|
91
88
|
const payload = JSON.parse(decoded);
|
|
92
|
-
if (typeof payload.ref !==
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
89
|
+
if (typeof payload.ref !== "string" ||
|
|
90
|
+
typeof payload.ownerPid !== "number" ||
|
|
91
|
+
!Number.isInteger(payload.ownerPid) ||
|
|
92
|
+
payload.ownerPid <= 0 ||
|
|
93
|
+
typeof payload.repoRoot !== "string" ||
|
|
94
|
+
typeof payload.htmlPath !== "string") {
|
|
98
95
|
return null;
|
|
99
96
|
}
|
|
100
97
|
return {
|
|
@@ -114,30 +111,30 @@ function buildLocalDevAppUrl(input) {
|
|
|
114
111
|
}
|
|
115
112
|
function respondWithBuffer(res, method, statusCode, contentType, payload) {
|
|
116
113
|
res.statusCode = statusCode;
|
|
117
|
-
res.setHeader(
|
|
118
|
-
res.setHeader(
|
|
119
|
-
res.setHeader(
|
|
120
|
-
if (method ===
|
|
114
|
+
res.setHeader("Content-Type", contentType);
|
|
115
|
+
res.setHeader("Content-Length", String(payload.length));
|
|
116
|
+
res.setHeader("Cache-Control", "no-store");
|
|
117
|
+
if (method === "HEAD") {
|
|
121
118
|
res.end();
|
|
122
119
|
return;
|
|
123
120
|
}
|
|
124
121
|
res.end(payload);
|
|
125
122
|
}
|
|
126
123
|
function respondWithText(res, method, statusCode, message) {
|
|
127
|
-
const payload = Buffer.from(message,
|
|
128
|
-
respondWithBuffer(res, method, statusCode,
|
|
124
|
+
const payload = Buffer.from(message, "utf8");
|
|
125
|
+
respondWithBuffer(res, method, statusCode, "text/plain; charset=utf-8", payload);
|
|
129
126
|
}
|
|
130
127
|
function sendJson(res, statusCode, payload) {
|
|
131
|
-
const body = Buffer.from(JSON.stringify(payload),
|
|
132
|
-
respondWithBuffer(res,
|
|
128
|
+
const body = Buffer.from(JSON.stringify(payload), "utf8");
|
|
129
|
+
respondWithBuffer(res, "GET", statusCode, "application/json; charset=utf-8", body);
|
|
133
130
|
}
|
|
134
131
|
function isPidAlive(pid) {
|
|
135
132
|
if (!Number.isInteger(pid) || pid <= 0) {
|
|
136
133
|
return false;
|
|
137
134
|
}
|
|
138
|
-
if (process.platform ===
|
|
135
|
+
if (process.platform === "linux") {
|
|
139
136
|
const info = readLinuxProcessInfo(pid);
|
|
140
|
-
return info !== null && info.state !==
|
|
137
|
+
return info !== null && info.state !== "Z";
|
|
141
138
|
}
|
|
142
139
|
try {
|
|
143
140
|
process.kill(pid, 0);
|
|
@@ -148,25 +145,28 @@ function isPidAlive(pid) {
|
|
|
148
145
|
}
|
|
149
146
|
}
|
|
150
147
|
function readLinuxProcessInfo(pid) {
|
|
151
|
-
if (!Number.isInteger(pid) || pid <= 0 || process.platform !==
|
|
148
|
+
if (!Number.isInteger(pid) || pid <= 0 || process.platform !== "linux") {
|
|
152
149
|
return null;
|
|
153
150
|
}
|
|
154
151
|
try {
|
|
155
|
-
const raw = (0, node_fs_1.readFileSync)(`/proc/${pid}/stat`,
|
|
156
|
-
const commandEnd = raw.lastIndexOf(
|
|
152
|
+
const raw = (0, node_fs_1.readFileSync)(`/proc/${pid}/stat`, "utf8");
|
|
153
|
+
const commandEnd = raw.lastIndexOf(")");
|
|
157
154
|
if (commandEnd < 0) {
|
|
158
155
|
return null;
|
|
159
156
|
}
|
|
160
|
-
const fields = raw
|
|
157
|
+
const fields = raw
|
|
158
|
+
.slice(commandEnd + 2)
|
|
159
|
+
.trim()
|
|
160
|
+
.split(/\s+/u);
|
|
161
161
|
const state = fields[0];
|
|
162
162
|
const groupId = Number(fields[2]);
|
|
163
|
-
if (typeof state !==
|
|
163
|
+
if (typeof state !== "string" || !Number.isInteger(groupId) || groupId <= 0) {
|
|
164
164
|
return null;
|
|
165
165
|
}
|
|
166
166
|
return { state, groupId };
|
|
167
167
|
}
|
|
168
168
|
catch (error) {
|
|
169
|
-
if (error?.code ===
|
|
169
|
+
if (error?.code === "ENOENT") {
|
|
170
170
|
return null;
|
|
171
171
|
}
|
|
172
172
|
throw error;
|
|
@@ -201,8 +201,8 @@ function findRouterMountByCreatorAndApp(creatorUsername, appName) {
|
|
|
201
201
|
return match;
|
|
202
202
|
}
|
|
203
203
|
function resolveStaticPath(staticRoot, rawRelativePath) {
|
|
204
|
-
const normalizedRelativePath = (0, node_path_1.normalize)(rawRelativePath.replace(/^\/+/,
|
|
205
|
-
if (!normalizedRelativePath || normalizedRelativePath ===
|
|
204
|
+
const normalizedRelativePath = (0, node_path_1.normalize)(rawRelativePath.replace(/^\/+/, ""));
|
|
205
|
+
if (!normalizedRelativePath || normalizedRelativePath === "." || normalizedRelativePath.startsWith("..")) {
|
|
206
206
|
return null;
|
|
207
207
|
}
|
|
208
208
|
const absolutePath = (0, node_path_1.resolve)(staticRoot, normalizedRelativePath);
|
|
@@ -213,10 +213,10 @@ function resolveStaticPath(staticRoot, rawRelativePath) {
|
|
|
213
213
|
return absolutePath;
|
|
214
214
|
}
|
|
215
215
|
function parseMountPath(pathname) {
|
|
216
|
-
if (!pathname.startsWith(
|
|
216
|
+
if (!pathname.startsWith("/apps/dev/")) {
|
|
217
217
|
return null;
|
|
218
218
|
}
|
|
219
|
-
const segments = pathname.split(
|
|
219
|
+
const segments = pathname.split("/").filter(Boolean);
|
|
220
220
|
if (segments.length < 6) {
|
|
221
221
|
return null;
|
|
222
222
|
}
|
|
@@ -228,7 +228,7 @@ function parseMountPath(pathname) {
|
|
|
228
228
|
}
|
|
229
229
|
return {
|
|
230
230
|
key: buildMountKey(decodeURIComponent(creatorUsername), decodeURIComponent(appType), decodeURIComponent(appName)),
|
|
231
|
-
assetPath: rest.map((entry) => decodeURIComponent(entry)).join(
|
|
231
|
+
assetPath: rest.map((entry) => decodeURIComponent(entry)).join("/"),
|
|
232
232
|
};
|
|
233
233
|
}
|
|
234
234
|
function getOwnedRuntimeAssetFile(mount, ownedAssetName, role) {
|
|
@@ -243,19 +243,19 @@ async function readJsonBody(req) {
|
|
|
243
243
|
for await (const chunk of req) {
|
|
244
244
|
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
245
245
|
}
|
|
246
|
-
const raw = Buffer.concat(chunks).toString(
|
|
246
|
+
const raw = Buffer.concat(chunks).toString("utf8").trim();
|
|
247
247
|
return raw ? JSON.parse(raw) : {};
|
|
248
248
|
}
|
|
249
249
|
function spawnDevScript(projectInfo) {
|
|
250
|
-
if (!projectInfo.projectDir || !projectInfo.packageJson || typeof projectInfo.packageJson.scripts?.dev !==
|
|
250
|
+
if (!projectInfo.projectDir || !projectInfo.packageJson || typeof projectInfo.packageJson.scripts?.dev !== "string") {
|
|
251
251
|
return null;
|
|
252
252
|
}
|
|
253
|
-
const npm = (0, npmProcess_1.resolveNpmInvocation)([
|
|
253
|
+
const npm = (0, npmProcess_1.resolveNpmInvocation)(["run", "dev"]);
|
|
254
254
|
const child = (0, node_child_process_1.spawn)(npm.command, npm.args, {
|
|
255
255
|
cwd: projectInfo.projectDir,
|
|
256
|
-
stdio:
|
|
256
|
+
stdio: "inherit",
|
|
257
257
|
env: { ...process.env },
|
|
258
|
-
detached: process.platform !==
|
|
258
|
+
detached: process.platform !== "win32",
|
|
259
259
|
});
|
|
260
260
|
return child;
|
|
261
261
|
}
|
|
@@ -266,7 +266,7 @@ function signalProcess(pid, signal, useGroup) {
|
|
|
266
266
|
return true;
|
|
267
267
|
}
|
|
268
268
|
catch (error) {
|
|
269
|
-
if (error?.code ===
|
|
269
|
+
if (error?.code === "ESRCH") {
|
|
270
270
|
return false;
|
|
271
271
|
}
|
|
272
272
|
throw error;
|
|
@@ -276,13 +276,13 @@ function isProcessGroupAlive(pid) {
|
|
|
276
276
|
if (!Number.isInteger(pid) || pid <= 0) {
|
|
277
277
|
return false;
|
|
278
278
|
}
|
|
279
|
-
if (process.platform ===
|
|
280
|
-
for (const entry of (0, node_fs_1.readdirSync)(
|
|
279
|
+
if (process.platform === "linux") {
|
|
280
|
+
for (const entry of (0, node_fs_1.readdirSync)("/proc", { withFileTypes: true })) {
|
|
281
281
|
if (!entry.isDirectory() || !/^\d+$/u.test(entry.name)) {
|
|
282
282
|
continue;
|
|
283
283
|
}
|
|
284
284
|
const info = readLinuxProcessInfo(Number(entry.name));
|
|
285
|
-
if (info && info.groupId === pid && info.state !==
|
|
285
|
+
if (info && info.groupId === pid && info.state !== "Z") {
|
|
286
286
|
return true;
|
|
287
287
|
}
|
|
288
288
|
}
|
|
@@ -293,10 +293,10 @@ function isProcessGroupAlive(pid) {
|
|
|
293
293
|
return true;
|
|
294
294
|
}
|
|
295
295
|
catch (error) {
|
|
296
|
-
if (error?.code ===
|
|
296
|
+
if (error?.code === "ESRCH") {
|
|
297
297
|
return false;
|
|
298
298
|
}
|
|
299
|
-
if (error?.code ===
|
|
299
|
+
if (error?.code === "EPERM") {
|
|
300
300
|
return true;
|
|
301
301
|
}
|
|
302
302
|
throw error;
|
|
@@ -315,7 +315,7 @@ async function waitForChildExit(child, timeoutMs) {
|
|
|
315
315
|
}
|
|
316
316
|
settled = true;
|
|
317
317
|
clearTimeout(timeout);
|
|
318
|
-
child.off(
|
|
318
|
+
child.off("exit", onExit);
|
|
319
319
|
resolvePromise(true);
|
|
320
320
|
};
|
|
321
321
|
const timeout = setTimeout(() => {
|
|
@@ -323,11 +323,11 @@ async function waitForChildExit(child, timeoutMs) {
|
|
|
323
323
|
return;
|
|
324
324
|
}
|
|
325
325
|
settled = true;
|
|
326
|
-
child.off(
|
|
326
|
+
child.off("exit", onExit);
|
|
327
327
|
resolvePromise(!pid || !isPidAlive(pid));
|
|
328
328
|
}, timeoutMs);
|
|
329
329
|
timeout.unref?.();
|
|
330
|
-
child.once(
|
|
330
|
+
child.once("exit", onExit);
|
|
331
331
|
});
|
|
332
332
|
}
|
|
333
333
|
async function waitForProcessGroupExit(pid, timeoutMs) {
|
|
@@ -344,12 +344,12 @@ async function waitForProcessGroupExit(pid, timeoutMs) {
|
|
|
344
344
|
return !isProcessGroupAlive(pid);
|
|
345
345
|
}
|
|
346
346
|
async function terminateWindowsProcessTree(pid, timeoutMs) {
|
|
347
|
-
const windowsRoot = process.env.SystemRoot?.trim() || process.env.WINDIR?.trim() ||
|
|
348
|
-
const taskkillPath = (0, node_path_1.join)(windowsRoot,
|
|
347
|
+
const windowsRoot = process.env.SystemRoot?.trim() || process.env.WINDIR?.trim() || "C:\\Windows";
|
|
348
|
+
const taskkillPath = (0, node_path_1.join)(windowsRoot, "System32", "taskkill.exe");
|
|
349
349
|
await new Promise((resolvePromise) => {
|
|
350
350
|
let settled = false;
|
|
351
|
-
const taskkill = (0, node_child_process_1.spawn)(taskkillPath, [
|
|
352
|
-
stdio:
|
|
351
|
+
const taskkill = (0, node_child_process_1.spawn)(taskkillPath, ["/PID", String(pid), "/T", "/F"], {
|
|
352
|
+
stdio: "ignore",
|
|
353
353
|
windowsHide: true,
|
|
354
354
|
});
|
|
355
355
|
const settle = () => {
|
|
@@ -365,8 +365,8 @@ async function terminateWindowsProcessTree(pid, timeoutMs) {
|
|
|
365
365
|
settle();
|
|
366
366
|
}, timeoutMs);
|
|
367
367
|
timeout.unref?.();
|
|
368
|
-
taskkill.once(
|
|
369
|
-
taskkill.once(
|
|
368
|
+
taskkill.once("error", settle);
|
|
369
|
+
taskkill.once("close", settle);
|
|
370
370
|
});
|
|
371
371
|
}
|
|
372
372
|
async function terminateChildProcessTree(child, timeoutMs = 2000) {
|
|
@@ -374,20 +374,20 @@ async function terminateChildProcessTree(child, timeoutMs = 2000) {
|
|
|
374
374
|
if (!child || !pid || !isPidAlive(pid)) {
|
|
375
375
|
return;
|
|
376
376
|
}
|
|
377
|
-
if (process.platform ===
|
|
377
|
+
if (process.platform === "win32") {
|
|
378
378
|
await terminateWindowsProcessTree(pid, timeoutMs);
|
|
379
379
|
if (isPidAlive(pid)) {
|
|
380
|
-
signalProcess(pid,
|
|
380
|
+
signalProcess(pid, "SIGKILL", false);
|
|
381
381
|
await waitForChildExit(child, timeoutMs);
|
|
382
382
|
}
|
|
383
383
|
return;
|
|
384
384
|
}
|
|
385
|
-
signalProcess(pid,
|
|
385
|
+
signalProcess(pid, "SIGTERM", true);
|
|
386
386
|
const exited = await waitForProcessGroupExit(pid, timeoutMs);
|
|
387
387
|
if (exited) {
|
|
388
388
|
return;
|
|
389
389
|
}
|
|
390
|
-
signalProcess(pid,
|
|
390
|
+
signalProcess(pid, "SIGKILL", true);
|
|
391
391
|
await waitForProcessGroupExit(pid, timeoutMs);
|
|
392
392
|
}
|
|
393
393
|
async function fetchRouterJson(path, init = {}, port = exports.DEV_ROUTER_PORT) {
|
|
@@ -397,11 +397,11 @@ async function fetchRouterJson(path, init = {}, port = exports.DEV_ROUTER_PORT)
|
|
|
397
397
|
return null;
|
|
398
398
|
}
|
|
399
399
|
const payload = await response.json().catch(() => null);
|
|
400
|
-
throw new Error(typeof payload?.error ===
|
|
400
|
+
throw new Error(typeof payload?.error === "string"
|
|
401
401
|
? payload.error
|
|
402
402
|
: `router_request_failed:${response.status}`);
|
|
403
403
|
}
|
|
404
|
-
return await response.json();
|
|
404
|
+
return (await response.json());
|
|
405
405
|
}
|
|
406
406
|
async function fetchRouterHealth(port = exports.DEV_ROUTER_PORT, timeoutMs = 400) {
|
|
407
407
|
const controller = new AbortController();
|
|
@@ -409,14 +409,14 @@ async function fetchRouterHealth(port = exports.DEV_ROUTER_PORT, timeoutMs = 400
|
|
|
409
409
|
timeout.unref?.();
|
|
410
410
|
try {
|
|
411
411
|
const response = await fetch(`http://${DEV_ROUTER_HOST}:${port}${CONTROL_PREFIX}/health`, {
|
|
412
|
-
method:
|
|
412
|
+
method: "GET",
|
|
413
413
|
signal: controller.signal,
|
|
414
414
|
});
|
|
415
415
|
if (!response.ok) {
|
|
416
416
|
return null;
|
|
417
417
|
}
|
|
418
418
|
const payload = await response.json().catch(() => null);
|
|
419
|
-
if (!payload || typeof payload !==
|
|
419
|
+
if (!payload || typeof payload !== "object" || payload.status !== "ok") {
|
|
420
420
|
return null;
|
|
421
421
|
}
|
|
422
422
|
return payload;
|
|
@@ -429,9 +429,9 @@ async function fetchRouterHealth(port = exports.DEV_ROUTER_PORT, timeoutMs = 400
|
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
431
|
function isCompatibleRouterHealth(health) {
|
|
432
|
-
return health.protocolVersion === DEV_ROUTER_PROTOCOL_VERSION
|
|
433
|
-
|
|
434
|
-
|
|
432
|
+
return (health.protocolVersion === DEV_ROUTER_PROTOCOL_VERSION &&
|
|
433
|
+
health.capabilities?.runtimeAssetManifest === true &&
|
|
434
|
+
health.capabilities?.runtimeAssetManifestLookup === true);
|
|
435
435
|
}
|
|
436
436
|
async function ensureDevRouterRunning(port = exports.DEV_ROUTER_PORT) {
|
|
437
437
|
const existingHealth = await fetchRouterHealth(port);
|
|
@@ -444,10 +444,10 @@ async function ensureDevRouterRunning(port = exports.DEV_ROUTER_PORT) {
|
|
|
444
444
|
const cliEntrypoint = getCliEntrypointPath();
|
|
445
445
|
const childEnv = { ...process.env };
|
|
446
446
|
delete childEnv.PLAYDROP_WORKER_CONTEXT;
|
|
447
|
-
const child = (0, node_child_process_1.spawn)(process.execPath, [cliEntrypoint,
|
|
447
|
+
const child = (0, node_child_process_1.spawn)(process.execPath, [cliEntrypoint, "project", "_dev-router", "serve"], {
|
|
448
448
|
cwd: resolveDevRouterWorkingDirectory(cliEntrypoint),
|
|
449
449
|
detached: true,
|
|
450
|
-
stdio:
|
|
450
|
+
stdio: "ignore",
|
|
451
451
|
env: {
|
|
452
452
|
...childEnv,
|
|
453
453
|
PLAYDROP_DEV_ROUTER_PORT: String(port),
|
|
@@ -462,22 +462,22 @@ async function ensureDevRouterRunning(port = exports.DEV_ROUTER_PORT) {
|
|
|
462
462
|
}
|
|
463
463
|
await new Promise((resolveTimeout) => setTimeout(resolveTimeout, 150));
|
|
464
464
|
}
|
|
465
|
-
throw new Error(
|
|
465
|
+
throw new Error("dev_router_start_failed");
|
|
466
466
|
}
|
|
467
467
|
function resolveDevRouterWorkingDirectory(cliEntrypoint) {
|
|
468
468
|
return (0, node_path_1.dirname)((0, node_path_1.resolve)(cliEntrypoint));
|
|
469
469
|
}
|
|
470
470
|
async function registerDevMount(input, port = exports.DEV_ROUTER_PORT) {
|
|
471
471
|
const response = await fetch(`http://${DEV_ROUTER_HOST}:${port}${CONTROL_PREFIX}/mounts`, {
|
|
472
|
-
method:
|
|
473
|
-
headers: {
|
|
472
|
+
method: "POST",
|
|
473
|
+
headers: { "Content-Type": "application/json" },
|
|
474
474
|
body: JSON.stringify(input),
|
|
475
475
|
});
|
|
476
|
-
const payload = await response.json().catch(() => null);
|
|
476
|
+
const payload = (await response.json().catch(() => null));
|
|
477
477
|
if (!response.ok || !payload) {
|
|
478
478
|
throw new Error(`mount_register_failed:${response.status}`);
|
|
479
479
|
}
|
|
480
|
-
if (
|
|
480
|
+
if ("error" in payload) {
|
|
481
481
|
throw new Error(encodeMountConflictError({
|
|
482
482
|
ref: `${payload.creatorUsername}/${payload.appType}/${payload.appName}`,
|
|
483
483
|
ownerPid: payload.ownerPid,
|
|
@@ -492,14 +492,14 @@ async function registerDevMount(input, port = exports.DEV_ROUTER_PORT) {
|
|
|
492
492
|
}
|
|
493
493
|
async function heartbeatDevMount(mountId, ownerPid, port = exports.DEV_ROUTER_PORT) {
|
|
494
494
|
await fetchRouterJson(`${CONTROL_PREFIX}/mounts/${encodeURIComponent(mountId)}/heartbeat`, {
|
|
495
|
-
method:
|
|
496
|
-
headers: {
|
|
495
|
+
method: "POST",
|
|
496
|
+
headers: { "Content-Type": "application/json" },
|
|
497
497
|
body: JSON.stringify({ ownerPid }),
|
|
498
498
|
}, port);
|
|
499
499
|
}
|
|
500
500
|
async function unregisterDevMount(mountId, port = exports.DEV_ROUTER_PORT) {
|
|
501
501
|
const response = await fetch(`http://${DEV_ROUTER_HOST}:${port}${CONTROL_PREFIX}/mounts/${encodeURIComponent(mountId)}`, {
|
|
502
|
-
method:
|
|
502
|
+
method: "DELETE",
|
|
503
503
|
});
|
|
504
504
|
if (!response.ok && response.status !== 404) {
|
|
505
505
|
throw new Error(`mount_unregister_failed:${response.status}`);
|
|
@@ -508,17 +508,15 @@ async function unregisterDevMount(mountId, port = exports.DEV_ROUTER_PORT) {
|
|
|
508
508
|
async function updateMountedDevRuntimeAssetManifest(input) {
|
|
509
509
|
const port = input.port ?? exports.DEV_ROUTER_PORT;
|
|
510
510
|
const response = await fetch(`http://${DEV_ROUTER_HOST}:${port}${CONTROL_PREFIX}/apps/dev/${encodeURIComponent(input.creatorUsername)}/${encodeURIComponent(input.appName)}/runtime-assets`, {
|
|
511
|
-
method:
|
|
512
|
-
headers: {
|
|
511
|
+
method: "POST",
|
|
512
|
+
headers: { "Content-Type": "application/json" },
|
|
513
513
|
body: JSON.stringify({
|
|
514
514
|
runtimeAssetManifest: input.runtimeAssetManifest ?? null,
|
|
515
515
|
}),
|
|
516
516
|
});
|
|
517
517
|
if (!response.ok) {
|
|
518
|
-
const payload = await response.json().catch(() => null);
|
|
519
|
-
throw new Error(typeof payload?.error ===
|
|
520
|
-
? payload.error
|
|
521
|
-
: `runtime_asset_manifest_update_failed:${response.status}`);
|
|
518
|
+
const payload = (await response.json().catch(() => null));
|
|
519
|
+
throw new Error(typeof payload?.error === "string" ? payload.error : `runtime_asset_manifest_update_failed:${response.status}`);
|
|
522
520
|
}
|
|
523
521
|
}
|
|
524
522
|
async function startDevServer(options) {
|
|
@@ -527,7 +525,7 @@ async function startDevServer(options) {
|
|
|
527
525
|
let closing = false;
|
|
528
526
|
const devProcess = spawnDevScript(projectInfo);
|
|
529
527
|
if (devProcess) {
|
|
530
|
-
devProcess.on(
|
|
528
|
+
devProcess.on("exit", (code) => {
|
|
531
529
|
if (closing) {
|
|
532
530
|
return;
|
|
533
531
|
}
|
|
@@ -539,8 +537,8 @@ async function startDevServer(options) {
|
|
|
539
537
|
const startedDevProcess = Boolean(devProcess);
|
|
540
538
|
const staticRoot = (0, node_path_1.resolve)((0, node_path_1.dirname)(htmlPath));
|
|
541
539
|
const repoRoot = (0, node_path_1.resolve)(projectInfo.projectDir ?? (0, node_path_1.dirname)(htmlPath));
|
|
542
|
-
let mountId =
|
|
543
|
-
let appUrl =
|
|
540
|
+
let mountId = "";
|
|
541
|
+
let appUrl = "";
|
|
544
542
|
try {
|
|
545
543
|
await ensureDevRouterRunning(port);
|
|
546
544
|
const registeredMount = await registerDevMount({
|
|
@@ -600,7 +598,7 @@ async function isDevServerAvailable(input, timeoutMs = 1000) {
|
|
|
600
598
|
...input,
|
|
601
599
|
port,
|
|
602
600
|
}), {
|
|
603
|
-
method:
|
|
601
|
+
method: "GET",
|
|
604
602
|
signal: controller.signal,
|
|
605
603
|
});
|
|
606
604
|
return response.ok;
|
|
@@ -615,34 +613,34 @@ async function isDevServerAvailable(input, timeoutMs = 1000) {
|
|
|
615
613
|
function createDevRouterServer(initialPort = exports.DEV_ROUTER_PORT) {
|
|
616
614
|
let activePort = initialPort;
|
|
617
615
|
const handleRequest = async (req, res) => {
|
|
618
|
-
const method = req.method ||
|
|
619
|
-
const allowedOrigin = resolveApprovedDevRouterOrigin(typeof req.headers.origin ===
|
|
616
|
+
const method = req.method || "GET";
|
|
617
|
+
const allowedOrigin = resolveApprovedDevRouterOrigin(typeof req.headers.origin === "string" ? req.headers.origin : undefined);
|
|
620
618
|
if (allowedOrigin) {
|
|
621
|
-
res.setHeader(
|
|
619
|
+
res.setHeader("Access-Control-Allow-Origin", allowedOrigin);
|
|
622
620
|
}
|
|
623
|
-
res.setHeader(
|
|
624
|
-
res.setHeader(
|
|
625
|
-
res.setHeader(
|
|
626
|
-
res.setHeader(
|
|
627
|
-
if (method ===
|
|
621
|
+
res.setHeader("Vary", "Origin");
|
|
622
|
+
res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
|
|
623
|
+
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Playdrop-Client, X-Playdrop-Client-Version, X-Playdrop-Client-Build, X-Playdrop-Platform, X-Playdrop-Platform-Version");
|
|
624
|
+
res.setHeader("Access-Control-Allow-Private-Network", "true");
|
|
625
|
+
if (method === "OPTIONS") {
|
|
628
626
|
res.statusCode = 200;
|
|
629
|
-
res.setHeader(
|
|
627
|
+
res.setHeader("Access-Control-Max-Age", "600");
|
|
630
628
|
res.end();
|
|
631
629
|
return;
|
|
632
630
|
}
|
|
633
631
|
let requestUrl;
|
|
634
632
|
try {
|
|
635
|
-
requestUrl = new URL(req.url ||
|
|
633
|
+
requestUrl = new URL(req.url || "/", `http://${DEV_ROUTER_HOST}:${activePort}`);
|
|
636
634
|
}
|
|
637
635
|
catch {
|
|
638
|
-
respondWithText(res, method, 400,
|
|
636
|
+
respondWithText(res, method, 400, "Invalid URL path");
|
|
639
637
|
return;
|
|
640
638
|
}
|
|
641
639
|
const pathname = decodeURIComponent(requestUrl.pathname);
|
|
642
640
|
const searchParams = requestUrl.searchParams;
|
|
643
|
-
if (pathname === `${CONTROL_PREFIX}/health` && method ===
|
|
641
|
+
if (pathname === `${CONTROL_PREFIX}/health` && method === "GET") {
|
|
644
642
|
sendJson(res, 200, {
|
|
645
|
-
status:
|
|
643
|
+
status: "ok",
|
|
646
644
|
protocolVersion: DEV_ROUTER_PROTOCOL_VERSION,
|
|
647
645
|
capabilities: {
|
|
648
646
|
runtimeAssetManifest: true,
|
|
@@ -651,17 +649,19 @@ function createDevRouterServer(initialPort = exports.DEV_ROUTER_PORT) {
|
|
|
651
649
|
});
|
|
652
650
|
return;
|
|
653
651
|
}
|
|
654
|
-
if (pathname.startsWith(`${CONTROL_PREFIX}/apps/dev/`) &&
|
|
652
|
+
if (pathname.startsWith(`${CONTROL_PREFIX}/apps/dev/`) &&
|
|
653
|
+
pathname.endsWith("/runtime-assets") &&
|
|
654
|
+
method === "GET") {
|
|
655
655
|
cleanupStaleRouterMounts();
|
|
656
|
-
const segments = pathname.split(
|
|
656
|
+
const segments = pathname.split("/").filter(Boolean);
|
|
657
657
|
if (segments.length !== 6) {
|
|
658
|
-
sendJson(res, 404, { error:
|
|
658
|
+
sendJson(res, 404, { error: "runtime_asset_manifest_not_found" });
|
|
659
659
|
return;
|
|
660
660
|
}
|
|
661
|
-
const creatorUsername = decodeURIComponent(segments[3] ??
|
|
662
|
-
const appName = decodeURIComponent(segments[4] ??
|
|
661
|
+
const creatorUsername = decodeURIComponent(segments[3] ?? "");
|
|
662
|
+
const appName = decodeURIComponent(segments[4] ?? "");
|
|
663
663
|
if (!creatorUsername || !appName) {
|
|
664
|
-
sendJson(res, 400, { error:
|
|
664
|
+
sendJson(res, 400, { error: "invalid_runtime_asset_manifest_lookup" });
|
|
665
665
|
return;
|
|
666
666
|
}
|
|
667
667
|
let mount;
|
|
@@ -669,28 +669,30 @@ function createDevRouterServer(initialPort = exports.DEV_ROUTER_PORT) {
|
|
|
669
669
|
mount = findRouterMountByCreatorAndApp(creatorUsername, appName);
|
|
670
670
|
}
|
|
671
671
|
catch (error) {
|
|
672
|
-
const message = error instanceof Error ? error.message :
|
|
672
|
+
const message = error instanceof Error ? error.message : "ambiguous_mount_lookup";
|
|
673
673
|
sendJson(res, 409, { error: message });
|
|
674
674
|
return;
|
|
675
675
|
}
|
|
676
676
|
if (!mount?.runtimeAssetManifest) {
|
|
677
|
-
sendJson(res, 404, { error:
|
|
677
|
+
sendJson(res, 404, { error: "runtime_asset_manifest_not_found" });
|
|
678
678
|
return;
|
|
679
679
|
}
|
|
680
680
|
sendJson(res, 200, mount.runtimeAssetManifest.response);
|
|
681
681
|
return;
|
|
682
682
|
}
|
|
683
|
-
if (pathname.startsWith(`${CONTROL_PREFIX}/apps/dev/`) &&
|
|
683
|
+
if (pathname.startsWith(`${CONTROL_PREFIX}/apps/dev/`) &&
|
|
684
|
+
pathname.endsWith("/runtime-assets") &&
|
|
685
|
+
method === "POST") {
|
|
684
686
|
cleanupStaleRouterMounts();
|
|
685
|
-
const segments = pathname.split(
|
|
687
|
+
const segments = pathname.split("/").filter(Boolean);
|
|
686
688
|
if (segments.length !== 6) {
|
|
687
|
-
sendJson(res, 404, { error:
|
|
689
|
+
sendJson(res, 404, { error: "runtime_asset_manifest_not_found" });
|
|
688
690
|
return;
|
|
689
691
|
}
|
|
690
|
-
const creatorUsername = decodeURIComponent(segments[3] ??
|
|
691
|
-
const appName = decodeURIComponent(segments[4] ??
|
|
692
|
+
const creatorUsername = decodeURIComponent(segments[3] ?? "");
|
|
693
|
+
const appName = decodeURIComponent(segments[4] ?? "");
|
|
692
694
|
if (!creatorUsername || !appName) {
|
|
693
|
-
sendJson(res, 400, { error:
|
|
695
|
+
sendJson(res, 400, { error: "invalid_runtime_asset_manifest_lookup" });
|
|
694
696
|
return;
|
|
695
697
|
}
|
|
696
698
|
let mount;
|
|
@@ -698,12 +700,12 @@ function createDevRouterServer(initialPort = exports.DEV_ROUTER_PORT) {
|
|
|
698
700
|
mount = findRouterMountByCreatorAndApp(creatorUsername, appName);
|
|
699
701
|
}
|
|
700
702
|
catch (error) {
|
|
701
|
-
const message = error instanceof Error ? error.message :
|
|
703
|
+
const message = error instanceof Error ? error.message : "ambiguous_mount_lookup";
|
|
702
704
|
sendJson(res, 409, { error: message });
|
|
703
705
|
return;
|
|
704
706
|
}
|
|
705
707
|
if (!mount) {
|
|
706
|
-
sendJson(res, 404, { error:
|
|
708
|
+
sendJson(res, 404, { error: "runtime_asset_manifest_not_found" });
|
|
707
709
|
return;
|
|
708
710
|
}
|
|
709
711
|
const body = await readJsonBody(req);
|
|
@@ -712,7 +714,7 @@ function createDevRouterServer(initialPort = exports.DEV_ROUTER_PORT) {
|
|
|
712
714
|
sendJson(res, 200, { ok: true });
|
|
713
715
|
return;
|
|
714
716
|
}
|
|
715
|
-
if (pathname === `${CONTROL_PREFIX}/mounts` && method ===
|
|
717
|
+
if (pathname === `${CONTROL_PREFIX}/mounts` && method === "POST") {
|
|
716
718
|
cleanupStaleRouterMounts();
|
|
717
719
|
const body = await readJsonBody(req);
|
|
718
720
|
const creatorUsername = body.creatorUsername?.trim();
|
|
@@ -722,8 +724,15 @@ function createDevRouterServer(initialPort = exports.DEV_ROUTER_PORT) {
|
|
|
722
724
|
const staticRoot = body.staticRoot?.trim();
|
|
723
725
|
const repoRoot = body.repoRoot?.trim();
|
|
724
726
|
const ownerPid = Number(body.ownerPid);
|
|
725
|
-
if (!creatorUsername ||
|
|
726
|
-
|
|
727
|
+
if (!creatorUsername ||
|
|
728
|
+
!appType ||
|
|
729
|
+
!appName ||
|
|
730
|
+
!htmlPath ||
|
|
731
|
+
!staticRoot ||
|
|
732
|
+
!repoRoot ||
|
|
733
|
+
!Number.isInteger(ownerPid) ||
|
|
734
|
+
ownerPid <= 0) {
|
|
735
|
+
sendJson(res, 400, { error: "invalid_mount_request" });
|
|
727
736
|
return;
|
|
728
737
|
}
|
|
729
738
|
const key = buildMountKey(creatorUsername, appType, appName);
|
|
@@ -733,7 +742,7 @@ function createDevRouterServer(initialPort = exports.DEV_ROUTER_PORT) {
|
|
|
733
742
|
if (existingMount && isPidAlive(existingMount.ownerPid)) {
|
|
734
743
|
if (existingMount.htmlPath !== htmlPath || existingMount.staticRoot !== staticRoot) {
|
|
735
744
|
sendJson(res, 409, {
|
|
736
|
-
error:
|
|
745
|
+
error: "mount_conflict",
|
|
737
746
|
creatorUsername,
|
|
738
747
|
appType,
|
|
739
748
|
appName,
|
|
@@ -781,22 +790,22 @@ function createDevRouterServer(initialPort = exports.DEV_ROUTER_PORT) {
|
|
|
781
790
|
});
|
|
782
791
|
return;
|
|
783
792
|
}
|
|
784
|
-
if (pathname.startsWith(`${CONTROL_PREFIX}/mounts/`) && pathname.endsWith(
|
|
793
|
+
if (pathname.startsWith(`${CONTROL_PREFIX}/mounts/`) && pathname.endsWith("/heartbeat") && method === "POST") {
|
|
785
794
|
cleanupStaleRouterMounts();
|
|
786
|
-
const mountId = pathname.slice(`${CONTROL_PREFIX}/mounts/`.length, -
|
|
795
|
+
const mountId = pathname.slice(`${CONTROL_PREFIX}/mounts/`.length, -"/heartbeat".length).replace(/\/$/, "");
|
|
787
796
|
const mount = routerMountsById.get(mountId);
|
|
788
797
|
if (!mount) {
|
|
789
|
-
sendJson(res, 404, { error:
|
|
798
|
+
sendJson(res, 404, { error: "mount_not_found" });
|
|
790
799
|
return;
|
|
791
800
|
}
|
|
792
801
|
const body = await readJsonBody(req);
|
|
793
802
|
const ownerPid = Number(body.ownerPid);
|
|
794
803
|
if (!Number.isInteger(ownerPid) || ownerPid <= 0) {
|
|
795
|
-
sendJson(res, 400, { error:
|
|
804
|
+
sendJson(res, 400, { error: "invalid_mount_owner_pid" });
|
|
796
805
|
return;
|
|
797
806
|
}
|
|
798
807
|
if (ownerPid !== mount.ownerPid) {
|
|
799
|
-
sendJson(res, 409, { error:
|
|
808
|
+
sendJson(res, 409, { error: "mount_owner_pid_mismatch" });
|
|
800
809
|
return;
|
|
801
810
|
}
|
|
802
811
|
mount.ownerPid = ownerPid;
|
|
@@ -804,97 +813,97 @@ function createDevRouterServer(initialPort = exports.DEV_ROUTER_PORT) {
|
|
|
804
813
|
sendJson(res, 200, { ok: true });
|
|
805
814
|
return;
|
|
806
815
|
}
|
|
807
|
-
if (pathname.startsWith(`${CONTROL_PREFIX}/mounts/`) && method ===
|
|
816
|
+
if (pathname.startsWith(`${CONTROL_PREFIX}/mounts/`) && method === "DELETE") {
|
|
808
817
|
const mountId = pathname.slice(`${CONTROL_PREFIX}/mounts/`.length);
|
|
809
818
|
removeRouterMount(mountId);
|
|
810
819
|
sendJson(res, 200, { ok: true });
|
|
811
820
|
return;
|
|
812
821
|
}
|
|
813
|
-
if (method !==
|
|
814
|
-
res.setHeader(
|
|
815
|
-
respondWithText(res, method, 405,
|
|
822
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
823
|
+
res.setHeader("Allow", "GET, HEAD, POST, DELETE, OPTIONS");
|
|
824
|
+
respondWithText(res, method, 405, "Method not allowed");
|
|
816
825
|
return;
|
|
817
826
|
}
|
|
818
827
|
cleanupStaleRouterMounts();
|
|
819
828
|
const parsedMountPath = parseMountPath(pathname);
|
|
820
829
|
if (!parsedMountPath) {
|
|
821
|
-
respondWithText(res, method, 404,
|
|
830
|
+
respondWithText(res, method, 404, "Not found");
|
|
822
831
|
return;
|
|
823
832
|
}
|
|
824
833
|
const mountId = routerMountIdsByKey.get(parsedMountPath.key);
|
|
825
834
|
const mount = mountId ? routerMountsById.get(mountId) : null;
|
|
826
835
|
if (!mount) {
|
|
827
|
-
respondWithText(res, method, 404,
|
|
836
|
+
respondWithText(res, method, 404, "Not found");
|
|
828
837
|
return;
|
|
829
838
|
}
|
|
830
|
-
if (parsedMountPath.assetPath ===
|
|
839
|
+
if (parsedMountPath.assetPath === "_playdrop/runtime-assets") {
|
|
831
840
|
if (!mount.runtimeAssetManifest) {
|
|
832
|
-
sendJson(res, 500, { error:
|
|
841
|
+
sendJson(res, 500, { error: "runtime_asset_manifest_not_registered" });
|
|
833
842
|
return;
|
|
834
843
|
}
|
|
835
844
|
sendJson(res, 200, mount.runtimeAssetManifest.response);
|
|
836
845
|
return;
|
|
837
846
|
}
|
|
838
|
-
if (parsedMountPath.assetPath.startsWith(
|
|
839
|
-
const ownedAssetName = parsedMountPath.assetPath.slice(
|
|
840
|
-
const role = (searchParams.get(
|
|
847
|
+
if (parsedMountPath.assetPath.startsWith("_playdrop/runtime-assets/files/")) {
|
|
848
|
+
const ownedAssetName = parsedMountPath.assetPath.slice("_playdrop/runtime-assets/files/".length).trim();
|
|
849
|
+
const role = (searchParams.get("role") || "primary").trim().toLowerCase();
|
|
841
850
|
if (!ownedAssetName || !role) {
|
|
842
|
-
respondWithText(res, method, 400,
|
|
851
|
+
respondWithText(res, method, 400, "Invalid runtime asset file request");
|
|
843
852
|
return;
|
|
844
853
|
}
|
|
845
854
|
const ownedFile = getOwnedRuntimeAssetFile(mount, ownedAssetName, role);
|
|
846
855
|
if (!ownedFile) {
|
|
847
|
-
respondWithText(res, method, 404,
|
|
856
|
+
respondWithText(res, method, 404, "Not found");
|
|
848
857
|
return;
|
|
849
858
|
}
|
|
850
859
|
try {
|
|
851
860
|
const stats = (0, node_fs_1.statSync)(ownedFile.absolutePath);
|
|
852
861
|
if (!stats.isFile()) {
|
|
853
|
-
respondWithText(res, method, 404,
|
|
862
|
+
respondWithText(res, method, 404, "Not found");
|
|
854
863
|
return;
|
|
855
864
|
}
|
|
856
865
|
const content = (0, node_fs_1.readFileSync)(ownedFile.absolutePath);
|
|
857
866
|
respondWithBuffer(res, method, 200, ownedFile.contentType || resolveContentType(ownedFile.absolutePath), content);
|
|
858
867
|
}
|
|
859
868
|
catch {
|
|
860
|
-
respondWithText(res, method, 404,
|
|
869
|
+
respondWithText(res, method, 404, "Not found");
|
|
861
870
|
}
|
|
862
871
|
return;
|
|
863
872
|
}
|
|
864
|
-
if (parsedMountPath.assetPath ===
|
|
873
|
+
if (parsedMountPath.assetPath === "index.html") {
|
|
865
874
|
try {
|
|
866
875
|
const freshHtml = (0, node_fs_1.readFileSync)(mount.htmlPath);
|
|
867
|
-
respondWithBuffer(res, method, 200,
|
|
876
|
+
respondWithBuffer(res, method, 200, "text/html; charset=utf-8", freshHtml);
|
|
868
877
|
}
|
|
869
878
|
catch (error) {
|
|
870
|
-
respondWithText(res, method, 500, `Failed to read app file: ${error?.message ||
|
|
879
|
+
respondWithText(res, method, 500, `Failed to read app file: ${error?.message || "unknown error"}`);
|
|
871
880
|
}
|
|
872
881
|
return;
|
|
873
882
|
}
|
|
874
883
|
const absolutePath = resolveStaticPath(mount.staticRoot, parsedMountPath.assetPath);
|
|
875
884
|
if (!absolutePath) {
|
|
876
|
-
respondWithText(res, method, 400,
|
|
885
|
+
respondWithText(res, method, 400, "Invalid static asset path");
|
|
877
886
|
return;
|
|
878
887
|
}
|
|
879
888
|
try {
|
|
880
889
|
const stats = (0, node_fs_1.statSync)(absolutePath);
|
|
881
890
|
if (!stats.isFile()) {
|
|
882
|
-
respondWithText(res, method, 404,
|
|
891
|
+
respondWithText(res, method, 404, "Not found");
|
|
883
892
|
return;
|
|
884
893
|
}
|
|
885
894
|
const content = (0, node_fs_1.readFileSync)(absolutePath);
|
|
886
895
|
respondWithBuffer(res, method, 200, resolveContentType(absolutePath), content);
|
|
887
896
|
}
|
|
888
897
|
catch {
|
|
889
|
-
respondWithText(res, method, 404,
|
|
898
|
+
respondWithText(res, method, 404, "Not found");
|
|
890
899
|
}
|
|
891
900
|
};
|
|
892
901
|
const server = node_http_1.default.createServer((req, res) => {
|
|
893
902
|
void handleRequest(req, res);
|
|
894
903
|
});
|
|
895
|
-
server.on(
|
|
904
|
+
server.on("listening", () => {
|
|
896
905
|
const address = server.address();
|
|
897
|
-
if (address && typeof address ===
|
|
906
|
+
if (address && typeof address === "object" && typeof address.port === "number") {
|
|
898
907
|
activePort = address.port;
|
|
899
908
|
}
|
|
900
909
|
});
|
|
@@ -903,20 +912,20 @@ function createDevRouterServer(initialPort = exports.DEV_ROUTER_PORT) {
|
|
|
903
912
|
async function listenDevRouterServer(server, port = exports.DEV_ROUTER_PORT) {
|
|
904
913
|
await new Promise((resolveListen, rejectListen) => {
|
|
905
914
|
const onError = (error) => {
|
|
906
|
-
server.off(
|
|
915
|
+
server.off("listening", onListening);
|
|
907
916
|
rejectListen(error);
|
|
908
917
|
};
|
|
909
918
|
const onListening = () => {
|
|
910
|
-
server.off(
|
|
919
|
+
server.off("error", onError);
|
|
911
920
|
resolveListen();
|
|
912
921
|
};
|
|
913
|
-
server.once(
|
|
914
|
-
server.once(
|
|
922
|
+
server.once("error", onError);
|
|
923
|
+
server.once("listening", onListening);
|
|
915
924
|
server.listen(port, DEV_ROUTER_HOST);
|
|
916
925
|
});
|
|
917
926
|
const address = server.address();
|
|
918
|
-
if (!address || typeof address !==
|
|
919
|
-
throw new Error(
|
|
927
|
+
if (!address || typeof address !== "object" || typeof address.port !== "number") {
|
|
928
|
+
throw new Error("dev_router_port_unavailable");
|
|
920
929
|
}
|
|
921
930
|
return address.port;
|
|
922
931
|
}
|