@quenty/studio-bridge 0.21.1 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +109 -17
- package/build-scripts/transform-add-session-attribute.lua +1 -0
- package/deploy.nevermore.json +10 -0
- package/dist/src/bridge/bridge-connection.d.ts +26 -2
- package/dist/src/bridge/bridge-connection.d.ts.map +1 -1
- package/dist/src/bridge/bridge-connection.js +159 -14
- package/dist/src/bridge/bridge-connection.js.map +1 -1
- package/dist/src/bridge/bridge-connection.test.js +81 -0
- package/dist/src/bridge/bridge-connection.test.js.map +1 -1
- package/dist/src/bridge/bridge-session.d.ts +35 -2
- package/dist/src/bridge/bridge-session.d.ts.map +1 -1
- package/dist/src/bridge/bridge-session.js +185 -28
- package/dist/src/bridge/bridge-session.js.map +1 -1
- package/dist/src/bridge/bridge-session.test.js +6 -4
- package/dist/src/bridge/bridge-session.test.js.map +1 -1
- package/dist/src/bridge/index.d.ts +1 -1
- package/dist/src/bridge/index.d.ts.map +1 -1
- package/dist/src/bridge/index.js.map +1 -1
- package/dist/src/bridge/internal/bridge-client.d.ts +4 -0
- package/dist/src/bridge/internal/bridge-client.d.ts.map +1 -1
- package/dist/src/bridge/internal/bridge-client.js +20 -7
- package/dist/src/bridge/internal/bridge-client.js.map +1 -1
- package/dist/src/bridge/internal/bridge-client.test.js +18 -0
- package/dist/src/bridge/internal/bridge-client.test.js.map +1 -1
- package/dist/src/bridge/internal/bridge-host.d.ts +13 -1
- package/dist/src/bridge/internal/bridge-host.d.ts.map +1 -1
- package/dist/src/bridge/internal/bridge-host.js +35 -0
- package/dist/src/bridge/internal/bridge-host.js.map +1 -1
- package/dist/src/bridge/internal/bridge-host.test.js +31 -0
- package/dist/src/bridge/internal/bridge-host.test.js.map +1 -1
- package/dist/src/bridge/internal/hand-off.d.ts.map +1 -1
- package/dist/src/bridge/internal/hand-off.js +4 -1
- package/dist/src/bridge/internal/hand-off.js.map +1 -1
- package/dist/src/bridge/internal/host-protocol.d.ts +8 -0
- package/dist/src/bridge/internal/host-protocol.d.ts.map +1 -1
- package/dist/src/bridge/internal/host-protocol.js +120 -13
- package/dist/src/bridge/internal/host-protocol.js.map +1 -1
- package/dist/src/bridge/internal/host-protocol.test.js +13 -0
- package/dist/src/bridge/internal/host-protocol.test.js.map +1 -1
- package/dist/src/bridge/internal/instance-state.d.ts +9 -0
- package/dist/src/bridge/internal/instance-state.d.ts.map +1 -0
- package/dist/src/bridge/internal/instance-state.js +28 -0
- package/dist/src/bridge/internal/instance-state.js.map +1 -0
- package/dist/src/bridge/internal/transport-client.d.ts.map +1 -1
- package/dist/src/bridge/internal/transport-client.js +2 -1
- package/dist/src/bridge/internal/transport-client.js.map +1 -1
- package/dist/src/bridge/internal/transport-server.d.ts.map +1 -1
- package/dist/src/bridge/internal/transport-server.js +5 -1
- package/dist/src/bridge/internal/transport-server.js.map +1 -1
- package/dist/src/bridge/types.d.ts +43 -4
- package/dist/src/bridge/types.d.ts.map +1 -1
- package/dist/src/bridge/types.js.map +1 -1
- package/dist/src/cli/adapters/cli-command-adapter-handler.test.js +24 -0
- package/dist/src/cli/adapters/cli-command-adapter-handler.test.js.map +1 -1
- package/dist/src/cli/adapters/cli-command-adapter.d.ts +6 -0
- package/dist/src/cli/adapters/cli-command-adapter.d.ts.map +1 -1
- package/dist/src/cli/adapters/cli-command-adapter.js +107 -11
- package/dist/src/cli/adapters/cli-command-adapter.js.map +1 -1
- package/dist/src/cli/adapters/group-builder.d.ts +3 -0
- package/dist/src/cli/adapters/group-builder.d.ts.map +1 -1
- package/dist/src/cli/adapters/group-builder.js +34 -15
- package/dist/src/cli/adapters/group-builder.js.map +1 -1
- package/dist/src/cli/adapters/group-builder.test.js +26 -2
- package/dist/src/cli/adapters/group-builder.test.js.map +1 -1
- package/dist/src/cli/adapters/help-formatter.d.ts.map +1 -1
- package/dist/src/cli/adapters/help-formatter.js +4 -3
- package/dist/src/cli/adapters/help-formatter.js.map +1 -1
- package/dist/src/cli/adapters/help-formatter.test.js +1 -1
- package/dist/src/cli/adapters/help-formatter.test.js.map +1 -1
- package/dist/src/cli/adapters/playtest-edit-guard.test.d.ts +2 -0
- package/dist/src/cli/adapters/playtest-edit-guard.test.d.ts.map +1 -0
- package/dist/src/cli/adapters/playtest-edit-guard.test.js +28 -0
- package/dist/src/cli/adapters/playtest-edit-guard.test.js.map +1 -0
- package/dist/src/cli/args/global-args.d.ts +1 -1
- package/dist/src/cli/args/global-args.d.ts.map +1 -1
- package/dist/src/cli/cli-output-context.d.ts +14 -0
- package/dist/src/cli/cli-output-context.d.ts.map +1 -0
- package/dist/src/cli/cli-output-context.js +39 -0
- package/dist/src/cli/cli-output-context.js.map +1 -0
- package/dist/src/cli/cli-output-context.test.d.ts +2 -0
- package/dist/src/cli/cli-output-context.test.d.ts.map +1 -0
- package/dist/src/cli/cli-output-context.test.js +38 -0
- package/dist/src/cli/cli-output-context.test.js.map +1 -0
- package/dist/src/cli/cli.js +40 -17
- package/dist/src/cli/cli.js.map +1 -1
- package/dist/src/cli/managed-studio-run.d.ts +21 -0
- package/dist/src/cli/managed-studio-run.d.ts.map +1 -0
- package/dist/src/cli/managed-studio-run.js +75 -0
- package/dist/src/cli/managed-studio-run.js.map +1 -0
- package/dist/src/cli/managed-studio-run.test.d.ts +2 -0
- package/dist/src/cli/managed-studio-run.test.d.ts.map +1 -0
- package/dist/src/cli/managed-studio-run.test.js +52 -0
- package/dist/src/cli/managed-studio-run.test.js.map +1 -0
- package/dist/src/cli/resolve-session.js +1 -1
- package/dist/src/cli/resolve-session.js.map +1 -1
- package/dist/src/cli/resolve-session.test.js +1 -1
- package/dist/src/cli/resolve-session.test.js.map +1 -1
- package/dist/src/cli/script-executor.d.ts +13 -1
- package/dist/src/cli/script-executor.d.ts.map +1 -1
- package/dist/src/cli/script-executor.js +77 -47
- package/dist/src/cli/script-executor.js.map +1 -1
- package/dist/src/commands/console/exec/exec.d.ts +17 -0
- package/dist/src/commands/console/exec/exec.d.ts.map +1 -1
- package/dist/src/commands/console/exec/exec.js +39 -7
- package/dist/src/commands/console/exec/exec.js.map +1 -1
- package/dist/src/commands/console/exec/exec.test.js +62 -3
- package/dist/src/commands/console/exec/exec.test.js.map +1 -1
- package/dist/src/commands/console/logs/logs.d.ts +30 -2
- package/dist/src/commands/console/logs/logs.d.ts.map +1 -1
- package/dist/src/commands/console/logs/logs.js +82 -7
- package/dist/src/commands/console/logs/logs.js.map +1 -1
- package/dist/src/commands/console/logs/logs.test.js +63 -4
- package/dist/src/commands/console/logs/logs.test.js.map +1 -1
- package/dist/src/commands/explorer/export/export.d.ts +19 -0
- package/dist/src/commands/explorer/export/export.d.ts.map +1 -0
- package/dist/src/commands/explorer/export/export.js +37 -0
- package/dist/src/commands/explorer/export/export.js.map +1 -0
- package/dist/src/commands/explorer/export/export.test.d.ts +2 -0
- package/dist/src/commands/explorer/export/export.test.d.ts.map +1 -0
- package/dist/src/commands/explorer/export/export.test.js +25 -0
- package/dist/src/commands/explorer/export/export.test.js.map +1 -0
- package/dist/src/commands/explorer/find/find.d.ts +28 -0
- package/dist/src/commands/explorer/find/find.d.ts.map +1 -0
- package/dist/src/commands/explorer/find/find.js +75 -0
- package/dist/src/commands/explorer/find/find.js.map +1 -0
- package/dist/src/commands/explorer/find/find.test.d.ts +2 -0
- package/dist/src/commands/explorer/find/find.test.d.ts.map +1 -0
- package/dist/src/commands/explorer/find/find.test.js +44 -0
- package/dist/src/commands/explorer/find/find.test.js.map +1 -0
- package/dist/src/commands/explorer/grep/grep.d.ts +24 -0
- package/dist/src/commands/explorer/grep/grep.d.ts.map +1 -0
- package/dist/src/commands/explorer/grep/grep.js +63 -0
- package/dist/src/commands/explorer/grep/grep.js.map +1 -0
- package/dist/src/commands/explorer/grep/grep.test.d.ts +2 -0
- package/dist/src/commands/explorer/grep/grep.test.d.ts.map +1 -0
- package/dist/src/commands/explorer/grep/grep.test.js +42 -0
- package/dist/src/commands/explorer/grep/grep.test.js.map +1 -0
- package/dist/src/commands/explorer/import/import.d.ts +21 -0
- package/dist/src/commands/explorer/import/import.d.ts.map +1 -0
- package/dist/src/commands/explorer/import/import.js +37 -0
- package/dist/src/commands/explorer/import/import.js.map +1 -0
- package/dist/src/commands/explorer/import/import.test.d.ts +2 -0
- package/dist/src/commands/explorer/import/import.test.d.ts.map +1 -0
- package/dist/src/commands/explorer/import/import.test.js +45 -0
- package/dist/src/commands/explorer/import/import.test.js.map +1 -0
- package/dist/src/commands/formatters.test.js +7 -1
- package/dist/src/commands/formatters.test.js.map +1 -1
- package/dist/src/commands/framework/action-loader.d.ts +5 -1
- package/dist/src/commands/framework/action-loader.d.ts.map +1 -1
- package/dist/src/commands/framework/action-loader.js +9 -2
- package/dist/src/commands/framework/action-loader.js.map +1 -1
- package/dist/src/commands/framework/action-loader.test.js +23 -0
- package/dist/src/commands/framework/action-loader.test.js.map +1 -1
- package/dist/src/commands/framework/arg-builder.d.ts +15 -2
- package/dist/src/commands/framework/arg-builder.d.ts.map +1 -1
- package/dist/src/commands/framework/arg-builder.js +22 -2
- package/dist/src/commands/framework/arg-builder.js.map +1 -1
- package/dist/src/commands/framework/define-command.d.ts +19 -3
- package/dist/src/commands/framework/define-command.d.ts.map +1 -1
- package/dist/src/commands/framework/define-command.js.map +1 -1
- package/dist/src/commands/framework/index.d.ts +1 -1
- package/dist/src/commands/framework/index.d.ts.map +1 -1
- package/dist/src/commands/framework/index.js.map +1 -1
- package/dist/src/commands/index.d.ts +11 -0
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +11 -0
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/linux/inject-credentials/inject-credentials.d.ts.map +1 -1
- package/dist/src/commands/linux/inject-credentials/inject-credentials.js +1 -3
- package/dist/src/commands/linux/inject-credentials/inject-credentials.js.map +1 -1
- package/dist/src/commands/linux/setup/setup.d.ts.map +1 -1
- package/dist/src/commands/linux/setup/setup.js +1 -3
- package/dist/src/commands/linux/setup/setup.js.map +1 -1
- package/dist/src/commands/linux/status/status.d.ts +9 -1
- package/dist/src/commands/linux/status/status.d.ts.map +1 -1
- package/dist/src/commands/linux/status/status.js +66 -86
- package/dist/src/commands/linux/status/status.js.map +1 -1
- package/dist/src/commands/playtest/player/add/add.d.ts +17 -0
- package/dist/src/commands/playtest/player/add/add.d.ts.map +1 -0
- package/dist/src/commands/playtest/player/add/add.js +45 -0
- package/dist/src/commands/playtest/player/add/add.js.map +1 -0
- package/dist/src/commands/playtest/player/list/list.d.ts +13 -0
- package/dist/src/commands/playtest/player/list/list.d.ts.map +1 -0
- package/dist/src/commands/playtest/player/list/list.js +33 -0
- package/dist/src/commands/playtest/player/list/list.js.map +1 -0
- package/dist/src/commands/playtest/player/playtest-players.d.ts +36 -0
- package/dist/src/commands/playtest/player/playtest-players.d.ts.map +1 -0
- package/dist/src/commands/playtest/player/playtest-players.js +187 -0
- package/dist/src/commands/playtest/player/playtest-players.js.map +1 -0
- package/dist/src/commands/playtest/player/playtest-players.test.d.ts +2 -0
- package/dist/src/commands/playtest/player/playtest-players.test.d.ts.map +1 -0
- package/dist/src/commands/playtest/player/playtest-players.test.js +89 -0
- package/dist/src/commands/playtest/player/playtest-players.test.js.map +1 -0
- package/dist/src/commands/playtest/player/remove/remove.d.ts +17 -0
- package/dist/src/commands/playtest/player/remove/remove.d.ts.map +1 -0
- package/dist/src/commands/playtest/player/remove/remove.js +42 -0
- package/dist/src/commands/playtest/player/remove/remove.js.map +1 -0
- package/dist/src/commands/playtest/playtest-sessions.d.ts +49 -0
- package/dist/src/commands/playtest/playtest-sessions.d.ts.map +1 -0
- package/dist/src/commands/playtest/playtest-sessions.js +283 -0
- package/dist/src/commands/playtest/playtest-sessions.js.map +1 -0
- package/dist/src/commands/playtest/playtest-sessions.test.d.ts +2 -0
- package/dist/src/commands/playtest/playtest-sessions.test.d.ts.map +1 -0
- package/dist/src/commands/playtest/playtest-sessions.test.js +87 -0
- package/dist/src/commands/playtest/playtest-sessions.test.js.map +1 -0
- package/dist/src/commands/playtest/restart/restart.d.ts +23 -0
- package/dist/src/commands/playtest/restart/restart.d.ts.map +1 -0
- package/dist/src/commands/playtest/restart/restart.js +105 -0
- package/dist/src/commands/playtest/restart/restart.js.map +1 -0
- package/dist/src/commands/playtest/run/run.d.ts +47 -0
- package/dist/src/commands/playtest/run/run.d.ts.map +1 -0
- package/dist/src/commands/playtest/run/run.js +137 -0
- package/dist/src/commands/playtest/run/run.js.map +1 -0
- package/dist/src/commands/playtest/start/start.d.ts +42 -0
- package/dist/src/commands/playtest/start/start.d.ts.map +1 -0
- package/dist/src/commands/playtest/start/start.js +70 -0
- package/dist/src/commands/playtest/start/start.js.map +1 -0
- package/dist/src/commands/playtest/stop/stop.d.ts +15 -0
- package/dist/src/commands/playtest/stop/stop.d.ts.map +1 -0
- package/dist/src/commands/playtest/stop/stop.js +24 -0
- package/dist/src/commands/playtest/stop/stop.js.map +1 -0
- package/dist/src/commands/process/close/close.d.ts +19 -10
- package/dist/src/commands/process/close/close.d.ts.map +1 -1
- package/dist/src/commands/process/close/close.js +118 -15
- package/dist/src/commands/process/close/close.js.map +1 -1
- package/dist/src/commands/process/close/close.test.d.ts +2 -0
- package/dist/src/commands/process/close/close.test.d.ts.map +1 -0
- package/dist/src/commands/process/close/close.test.js +190 -0
- package/dist/src/commands/process/close/close.test.js.map +1 -0
- package/dist/src/commands/process/info/info.d.ts +45 -5
- package/dist/src/commands/process/info/info.d.ts.map +1 -1
- package/dist/src/commands/process/info/info.js +117 -13
- package/dist/src/commands/process/info/info.js.map +1 -1
- package/dist/src/commands/process/info/info.test.js +140 -38
- package/dist/src/commands/process/info/info.test.js.map +1 -1
- package/dist/src/commands/process/launch/launch.d.ts +11 -1
- package/dist/src/commands/process/launch/launch.d.ts.map +1 -1
- package/dist/src/commands/process/launch/launch.js +37 -7
- package/dist/src/commands/process/launch/launch.js.map +1 -1
- package/dist/src/commands/process/launch/launch.test.js +99 -20
- package/dist/src/commands/process/launch/launch.test.js.map +1 -1
- package/dist/src/commands/process/list/list.d.ts +2 -1
- package/dist/src/commands/process/list/list.d.ts.map +1 -1
- package/dist/src/commands/process/list/list.js +9 -6
- package/dist/src/commands/process/list/list.js.map +1 -1
- package/dist/src/commands/process/list/list.test.js +1 -0
- package/dist/src/commands/process/list/list.test.js.map +1 -1
- package/dist/src/commands/process/run/run.d.ts +9 -0
- package/dist/src/commands/process/run/run.d.ts.map +1 -1
- package/dist/src/commands/process/run/run.js +15 -5
- package/dist/src/commands/process/run/run.js.map +1 -1
- package/dist/src/commands/serve/serve.d.ts +2 -0
- package/dist/src/commands/serve/serve.d.ts.map +1 -1
- package/dist/src/commands/serve/serve.js +17 -4
- package/dist/src/commands/serve/serve.js.map +1 -1
- package/dist/src/commands/serve/serve.test.js +9 -2
- package/dist/src/commands/serve/serve.test.js.map +1 -1
- package/dist/src/commands/viewport/screenshot/screenshot.d.ts.map +1 -1
- package/dist/src/commands/viewport/screenshot/screenshot.js +4 -1
- package/dist/src/commands/viewport/screenshot/screenshot.js.map +1 -1
- package/dist/src/commands/viewport/screenshot/screenshot.test.js +5 -9
- package/dist/src/commands/viewport/screenshot/screenshot.test.js.map +1 -1
- package/dist/src/deploy/deploy-places.d.ts +39 -0
- package/dist/src/deploy/deploy-places.d.ts.map +1 -0
- package/dist/src/deploy/deploy-places.js +162 -0
- package/dist/src/deploy/deploy-places.js.map +1 -0
- package/dist/src/deploy/deploy-places.test.d.ts +2 -0
- package/dist/src/deploy/deploy-places.test.d.ts.map +1 -0
- package/dist/src/deploy/deploy-places.test.js +96 -0
- package/dist/src/deploy/deploy-places.test.js.map +1 -0
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/plugin/persistent-plugin-installer.d.ts.map +1 -1
- package/dist/src/plugin/persistent-plugin-installer.js +2 -1
- package/dist/src/plugin/persistent-plugin-installer.js.map +1 -1
- package/dist/src/plugin/persistent-plugin-installer.test.js +3 -0
- package/dist/src/plugin/persistent-plugin-installer.test.js.map +1 -1
- package/dist/src/plugin/plugin-build-version.d.ts +7 -0
- package/dist/src/plugin/plugin-build-version.d.ts.map +1 -0
- package/dist/src/plugin/plugin-build-version.js +42 -0
- package/dist/src/plugin/plugin-build-version.js.map +1 -0
- package/dist/src/plugin/plugin-build-version.test.d.ts +2 -0
- package/dist/src/plugin/plugin-build-version.test.d.ts.map +1 -0
- package/dist/src/plugin/plugin-build-version.test.js +41 -0
- package/dist/src/plugin/plugin-build-version.test.js.map +1 -0
- package/dist/src/plugin/plugin-injector.d.ts.map +1 -1
- package/dist/src/plugin/plugin-injector.js +7 -1
- package/dist/src/plugin/plugin-injector.js.map +1 -1
- package/dist/src/process/studio-process-closer.d.ts +35 -0
- package/dist/src/process/studio-process-closer.d.ts.map +1 -0
- package/dist/src/process/studio-process-closer.js +129 -0
- package/dist/src/process/studio-process-closer.js.map +1 -0
- package/dist/src/process/studio-process-closer.test.d.ts +2 -0
- package/dist/src/process/studio-process-closer.test.d.ts.map +1 -0
- package/dist/src/process/studio-process-closer.test.js +80 -0
- package/dist/src/process/studio-process-closer.test.js.map +1 -0
- package/dist/src/process/studio-settings.d.ts +14 -0
- package/dist/src/process/studio-settings.d.ts.map +1 -0
- package/dist/src/process/studio-settings.js +50 -0
- package/dist/src/process/studio-settings.js.map +1 -0
- package/dist/src/process/studio-settings.test.d.ts +2 -0
- package/dist/src/process/studio-settings.test.d.ts.map +1 -0
- package/dist/src/process/studio-settings.test.js +16 -0
- package/dist/src/process/studio-settings.test.js.map +1 -0
- package/dist/src/process/studio-window-state.d.ts +13 -0
- package/dist/src/process/studio-window-state.d.ts.map +1 -0
- package/dist/src/process/studio-window-state.js +48 -0
- package/dist/src/process/studio-window-state.js.map +1 -0
- package/dist/src/server/studio-bridge-server.d.ts +3 -1
- package/dist/src/server/studio-bridge-server.d.ts.map +1 -1
- package/dist/src/server/studio-bridge-server.js +12 -4
- package/dist/src/server/studio-bridge-server.js.map +1 -1
- package/dist/src/server/web-socket-protocol.d.ts +173 -6
- package/dist/src/server/web-socket-protocol.d.ts.map +1 -1
- package/dist/src/server/web-socket-protocol.js +244 -1
- package/dist/src/server/web-socket-protocol.js.map +1 -1
- package/dist/src/server/web-socket-protocol.test.js +48 -0
- package/dist/src/server/web-socket-protocol.test.js.map +1 -1
- package/dist/src/test/e2e/persistent-session.test.js +121 -0
- package/dist/src/test/e2e/persistent-session.test.js.map +1 -1
- package/dist/src/test/e2e/split-server.test.d.ts +3 -5
- package/dist/src/test/e2e/split-server.test.d.ts.map +1 -1
- package/dist/src/test/e2e/split-server.test.js +3 -5
- package/dist/src/test/e2e/split-server.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docker/Dockerfile +3 -0
- package/package.json +8 -6
- package/src/bridge/bridge-connection.test.ts +126 -0
- package/src/bridge/bridge-connection.ts +217 -22
- package/src/bridge/bridge-session.test.ts +6 -4
- package/src/bridge/bridge-session.ts +273 -28
- package/src/bridge/index.ts +3 -0
- package/src/bridge/internal/bridge-client.test.ts +23 -0
- package/src/bridge/internal/bridge-client.ts +25 -7
- package/src/bridge/internal/bridge-host.test.ts +38 -0
- package/src/bridge/internal/bridge-host.ts +47 -0
- package/src/bridge/internal/hand-off.ts +4 -1
- package/src/bridge/internal/host-protocol.test.ts +15 -0
- package/src/bridge/internal/host-protocol.ts +148 -37
- package/src/bridge/internal/instance-state.ts +34 -0
- package/src/bridge/internal/transport-client.ts +2 -1
- package/src/bridge/internal/transport-server.ts +5 -1
- package/src/bridge/types.ts +47 -2
- package/src/cli/adapters/cli-command-adapter-handler.test.ts +28 -0
- package/src/cli/adapters/cli-command-adapter.ts +150 -18
- package/src/cli/adapters/group-builder.test.ts +34 -2
- package/src/cli/adapters/group-builder.ts +52 -20
- package/src/cli/adapters/help-formatter.test.ts +1 -1
- package/src/cli/adapters/help-formatter.ts +4 -3
- package/src/cli/adapters/playtest-edit-guard.test.ts +54 -0
- package/src/cli/args/global-args.ts +1 -1
- package/src/cli/cli-output-context.test.ts +55 -0
- package/src/cli/cli-output-context.ts +50 -0
- package/src/cli/cli.ts +49 -17
- package/src/cli/managed-studio-run.test.ts +71 -0
- package/src/cli/managed-studio-run.ts +135 -0
- package/src/cli/resolve-session.test.ts +1 -1
- package/src/cli/resolve-session.ts +1 -1
- package/src/cli/script-executor.ts +99 -51
- package/src/commands/console/exec/exec.test.ts +96 -3
- package/src/commands/console/exec/exec.ts +59 -6
- package/src/commands/console/exec/execute.lua +356 -240
- package/src/commands/console/exec/execute.spec.lua +286 -0
- package/src/commands/console/logs/logs.test.ts +76 -4
- package/src/commands/console/logs/logs.ts +132 -17
- package/src/commands/console/logs/query-logs.lua +85 -52
- package/src/commands/console/logs/query-logs.spec.lua +132 -0
- package/src/commands/explorer/export/export-instances.lua +108 -0
- package/src/commands/explorer/export/export-instances.spec.lua +87 -0
- package/src/commands/explorer/export/export.test.ts +27 -0
- package/src/commands/explorer/export/export.ts +60 -0
- package/src/commands/explorer/find/find-instances.lua +174 -0
- package/src/commands/explorer/find/find-instances.spec.lua +122 -0
- package/src/commands/explorer/find/find.test.ts +53 -0
- package/src/commands/explorer/find/find.ts +113 -0
- package/src/commands/explorer/grep/grep-scripts.lua +214 -0
- package/src/commands/explorer/grep/grep-scripts.spec.lua +130 -0
- package/src/commands/explorer/grep/grep.test.ts +45 -0
- package/src/commands/explorer/grep/grep.ts +93 -0
- package/src/commands/explorer/import/import-instances.lua +106 -0
- package/src/commands/explorer/import/import-instances.spec.lua +84 -0
- package/src/commands/explorer/import/import.test.ts +60 -0
- package/src/commands/explorer/import/import.ts +66 -0
- package/src/commands/explorer/query/query-data-model.lua +124 -152
- package/src/commands/explorer/query/query-data-model.spec.lua +150 -0
- package/src/commands/formatters.test.ts +7 -1
- package/src/commands/framework/action-loader.test.ts +28 -0
- package/src/commands/framework/action-loader.ts +10 -2
- package/src/commands/framework/arg-builder.ts +26 -3
- package/src/commands/framework/define-command.ts +32 -3
- package/src/commands/framework/index.ts +1 -0
- package/src/commands/index.ts +50 -0
- package/src/commands/linux/inject-credentials/inject-credentials.ts +1 -3
- package/src/commands/linux/setup/setup.ts +1 -3
- package/src/commands/linux/status/status.ts +105 -98
- package/src/commands/playtest/player/add/add.ts +85 -0
- package/src/commands/playtest/player/list/list.ts +57 -0
- package/src/commands/playtest/player/playtest-players.test.ts +146 -0
- package/src/commands/playtest/player/playtest-players.ts +270 -0
- package/src/commands/playtest/player/remove/remove.ts +78 -0
- package/src/commands/playtest/playtest-sessions.test.ts +143 -0
- package/src/commands/playtest/playtest-sessions.ts +417 -0
- package/src/commands/playtest/restart/restart.ts +199 -0
- package/src/commands/playtest/run/playtest-runner.luau +264 -0
- package/src/commands/playtest/run/playtest-runner.spec.lua +71 -0
- package/src/commands/playtest/run/run-playtest-script.lua +139 -0
- package/src/commands/playtest/run/run-playtest-script.spec.lua +43 -0
- package/src/commands/playtest/run/run.ts +239 -0
- package/src/commands/playtest/start/start-playtest.lua +108 -0
- package/src/commands/playtest/start/start.ts +138 -0
- package/src/commands/playtest/stop/end-playtest.lua +47 -0
- package/src/commands/playtest/stop/stop.ts +51 -0
- package/src/commands/process/close/close.test.ts +250 -0
- package/src/commands/process/close/close.ts +183 -17
- package/src/commands/process/info/info.test.ts +198 -44
- package/src/commands/process/info/info.ts +204 -15
- package/src/commands/process/info/query-state.lua +42 -29
- package/src/commands/process/info/query-state.spec.lua +39 -0
- package/src/commands/process/launch/launch.test.ts +138 -21
- package/src/commands/process/launch/launch.ts +69 -9
- package/src/commands/process/list/list.test.ts +1 -0
- package/src/commands/process/list/list.ts +14 -6
- package/src/commands/process/run/run.ts +26 -5
- package/src/commands/serve/serve.test.ts +17 -2
- package/src/commands/serve/serve.ts +25 -6
- package/src/commands/viewport/screenshot/capture-screenshot.lua +175 -182
- package/src/commands/viewport/screenshot/capture-screenshot.spec.lua +129 -0
- package/src/commands/viewport/screenshot/screenshot.test.ts +7 -10
- package/src/commands/viewport/screenshot/screenshot.ts +6 -1
- package/src/deploy/deploy-places.test.ts +127 -0
- package/src/deploy/deploy-places.ts +229 -0
- package/src/index.ts +11 -0
- package/src/plugin/persistent-plugin-installer.test.ts +4 -0
- package/src/plugin/persistent-plugin-installer.ts +2 -1
- package/src/plugin/plugin-build-version.test.ts +55 -0
- package/src/plugin/plugin-build-version.ts +53 -0
- package/src/plugin/plugin-injector.ts +7 -1
- package/src/process/studio-process-closer.test.ts +107 -0
- package/src/process/studio-process-closer.ts +187 -0
- package/src/process/studio-settings.test.ts +18 -0
- package/src/process/studio-settings.ts +61 -0
- package/src/process/studio-window-state.ts +65 -0
- package/src/server/studio-bridge-server.ts +15 -4
- package/src/server/web-socket-protocol.test.ts +55 -0
- package/src/server/web-socket-protocol.ts +468 -8
- package/src/test/e2e/persistent-session.test.ts +137 -0
- package/src/test/e2e/split-server.test.ts +3 -5
- package/templates/studio-bridge-plugin/default.project.json +3 -0
- package/templates/studio-bridge-plugin/src/Shared/ActionRouter.lua +208 -159
- package/templates/studio-bridge-plugin/src/Shared/ActionRouter.spec.lua +418 -0
- package/templates/studio-bridge-plugin/src/Shared/BuiltInActions.lua +94 -0
- package/templates/studio-bridge-plugin/src/Shared/BuiltInActions.spec.lua +166 -0
- package/templates/studio-bridge-plugin/src/Shared/DiscoveryStateMachine.lua +118 -137
- package/templates/studio-bridge-plugin/src/Shared/DiscoveryStateMachine.spec.lua +228 -0
- package/templates/studio-bridge-plugin/src/Shared/MessageBuffer.lua +80 -109
- package/templates/studio-bridge-plugin/src/Shared/MessageBuffer.spec.lua +116 -0
- package/templates/studio-bridge-plugin/src/Shared/StudioBridgeConnection.lua +233 -0
- package/templates/studio-bridge-plugin/src/Shared/StudioBridgeConnection.spec.lua +239 -0
- package/templates/studio-bridge-plugin/src/Shared/StudioBridgeLogUtils.lua +53 -0
- package/templates/studio-bridge-plugin/src/Shared/StudioBridgeLogUtils.spec.lua +27 -0
- package/templates/studio-bridge-plugin/src/Shared/StudioBridgeSessionUtils.lua +164 -0
- package/templates/studio-bridge-plugin/src/Shared/StudioBridgeSessionUtils.spec.lua +159 -0
- package/templates/studio-bridge-plugin/src/StudioBridgePlugin.server.lua +266 -368
- package/templates/studio-bridge-plugin/src/Vendor/png.lua +8 -2
- package/test/default.project.json +41 -0
- package/test/jest.config.lua +3 -0
- package/test/scripts/Server/ServerMain.server.lua +10 -0
- package/tsconfig.json +1 -0
- package/templates/studio-bridge-plugin/src/Shared/Protocol.lua +0 -132
- package/templates/studio-bridge-plugin-test/test/actions.test.lua +0 -580
- package/templates/studio-bridge-plugin-test/test/discovery.test.lua +0 -622
- package/templates/studio-bridge-plugin-test/test/execute-handler.test.lua +0 -517
- package/templates/studio-bridge-plugin-test/test/hash-lifecycle.test.lua +0 -814
- package/templates/studio-bridge-plugin-test/test/integration.test.lua +0 -1020
- package/templates/studio-bridge-plugin-test/test/new-actions.test.lua +0 -339
- package/templates/studio-bridge-plugin-test/test/plugin-entry.test.lua +0 -493
- package/templates/studio-bridge-plugin-test/test/protocol.test.lua +0 -506
- package/templates/studio-bridge-plugin-test/test/roblox-mocks.lua +0 -108
- package/templates/studio-bridge-plugin-test/test/test-runner.lua +0 -112
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
--!strict
|
|
2
|
+
--[[
|
|
3
|
+
@class grep-scripts.spec.lua
|
|
4
|
+
]]
|
|
5
|
+
|
|
6
|
+
local require = require(script.Parent.loader).load(script)
|
|
7
|
+
|
|
8
|
+
local HttpService = game:GetService("HttpService")
|
|
9
|
+
|
|
10
|
+
local ActionRouter = require("ActionRouter")
|
|
11
|
+
local GrepScriptsAction = require("grep-scripts")
|
|
12
|
+
local Jest = require("Jest")
|
|
13
|
+
|
|
14
|
+
local describe = Jest.Globals.describe
|
|
15
|
+
local expect = Jest.Globals.expect
|
|
16
|
+
local it = Jest.Globals.it
|
|
17
|
+
|
|
18
|
+
local function setup(): any
|
|
19
|
+
local router = ActionRouter.new()
|
|
20
|
+
GrepScriptsAction.register(router)
|
|
21
|
+
|
|
22
|
+
local root = Instance.new("Folder")
|
|
23
|
+
root.Name = `GrepScriptsSpec{HttpService:GenerateGUID(false)}`
|
|
24
|
+
|
|
25
|
+
-- Setting Source needs plugin security, so the specs supply each script's text
|
|
26
|
+
local sources: { [Instance]: string } = {}
|
|
27
|
+
local function addScript(className: string, name: string, source: string)
|
|
28
|
+
local script = Instance.new(className)
|
|
29
|
+
script.Name = name
|
|
30
|
+
script.Parent = root
|
|
31
|
+
sources[script] = source
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
addScript("ModuleScript", "Combat", "local damage = 10\r\nfunction Combat.Hit()\n\treturn DAMAGE * 2\nend")
|
|
35
|
+
addScript("Script", "Main", "print('ready')\nlocal Combat = require(script.Parent.Combat)")
|
|
36
|
+
|
|
37
|
+
local readSource = GrepScriptsAction._readSource
|
|
38
|
+
GrepScriptsAction._readSource = function(script: LuaSourceContainer): string
|
|
39
|
+
return sources[script] or ""
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
root.Parent = workspace
|
|
43
|
+
|
|
44
|
+
local controller = {
|
|
45
|
+
root = root,
|
|
46
|
+
rootPath = `Workspace.{root.Name}`,
|
|
47
|
+
grep = function(payload: { [string]: any }): any
|
|
48
|
+
return router:Dispatch({ type = "grepScripts", sessionId = "session-1", payload = payload })
|
|
49
|
+
end,
|
|
50
|
+
Destroy = function(_self)
|
|
51
|
+
GrepScriptsAction._readSource = readSource
|
|
52
|
+
root:Destroy()
|
|
53
|
+
end,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return controller
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
local function getLocations(response: any): { string }
|
|
60
|
+
local locations = {}
|
|
61
|
+
for _, match in response.payload.matches do
|
|
62
|
+
local name = string.match(match.path, "[^%.]+$")
|
|
63
|
+
table.insert(locations, `{name}:{match.line}`)
|
|
64
|
+
end
|
|
65
|
+
table.sort(locations)
|
|
66
|
+
return locations
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
describe("grepScripts", function()
|
|
70
|
+
it("should find plain text case-insensitively, with line numbers", function()
|
|
71
|
+
local controller = setup()
|
|
72
|
+
|
|
73
|
+
local response = controller.grep({ root = controller.rootPath, pattern = "damage" })
|
|
74
|
+
|
|
75
|
+
expect(response.type).toEqual("grepScriptsResult")
|
|
76
|
+
expect(getLocations(response)).toEqual({ "Combat:1", "Combat:3" })
|
|
77
|
+
expect(response.payload.searched).toEqual(2)
|
|
78
|
+
controller:Destroy()
|
|
79
|
+
end)
|
|
80
|
+
|
|
81
|
+
it("should keep case with caseSensitive and drop carriage returns", function()
|
|
82
|
+
local controller = setup()
|
|
83
|
+
|
|
84
|
+
local response = controller.grep({ root = controller.rootPath, pattern = "damage", caseSensitive = true })
|
|
85
|
+
|
|
86
|
+
expect(getLocations(response)).toEqual({ "Combat:1" })
|
|
87
|
+
expect(response.payload.matches[1].text).toEqual("local damage = 10")
|
|
88
|
+
controller:Destroy()
|
|
89
|
+
end)
|
|
90
|
+
|
|
91
|
+
it("should treat the pattern plainly unless luaPattern is set", function()
|
|
92
|
+
local controller = setup()
|
|
93
|
+
|
|
94
|
+
local plain = controller.grep({ root = controller.rootPath, pattern = "require(" })
|
|
95
|
+
local pattern = controller.grep({ root = controller.rootPath, pattern = "^print%(", luaPattern = true })
|
|
96
|
+
|
|
97
|
+
expect(getLocations(plain)).toEqual({ "Main:2" })
|
|
98
|
+
expect(getLocations(pattern)).toEqual({ "Main:1" })
|
|
99
|
+
controller:Destroy()
|
|
100
|
+
end)
|
|
101
|
+
|
|
102
|
+
it("should keep a pattern's classes when matching case-insensitively", function()
|
|
103
|
+
local controller = setup()
|
|
104
|
+
|
|
105
|
+
local response = controller.grep({ root = controller.rootPath, pattern = "^%S+ DAMAGE", luaPattern = true })
|
|
106
|
+
|
|
107
|
+
expect(getLocations(response)).toEqual({ "Combat:1" })
|
|
108
|
+
controller:Destroy()
|
|
109
|
+
end)
|
|
110
|
+
|
|
111
|
+
it("should stop at the limit and say so", function()
|
|
112
|
+
local controller = setup()
|
|
113
|
+
|
|
114
|
+
local response = controller.grep({ root = controller.rootPath, pattern = "combat", limit = 1 })
|
|
115
|
+
|
|
116
|
+
expect(#response.payload.matches).toEqual(1)
|
|
117
|
+
expect(response.payload.truncated).toEqual(true)
|
|
118
|
+
controller:Destroy()
|
|
119
|
+
end)
|
|
120
|
+
|
|
121
|
+
it("should refuse an invalid Lua pattern", function()
|
|
122
|
+
local controller = setup()
|
|
123
|
+
|
|
124
|
+
local response = controller.grep({ root = controller.rootPath, pattern = "[", luaPattern = true })
|
|
125
|
+
|
|
126
|
+
expect(response.type).toEqual("error")
|
|
127
|
+
expect(response.payload.code).toEqual("INVALID_PAYLOAD")
|
|
128
|
+
controller:Destroy()
|
|
129
|
+
end)
|
|
130
|
+
end)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { formatGrepText, grepScriptsHandlerAsync } from './grep.js';
|
|
3
|
+
|
|
4
|
+
describe('grepScriptsHandlerAsync', () => {
|
|
5
|
+
it('reports each match as path:line: text', async () => {
|
|
6
|
+
const session = {
|
|
7
|
+
grepScriptsAsync: vi.fn().mockResolvedValue({
|
|
8
|
+
matches: [
|
|
9
|
+
{
|
|
10
|
+
path: 'ServerScriptService.Main',
|
|
11
|
+
className: 'Script',
|
|
12
|
+
line: 4,
|
|
13
|
+
text: '\tlocal damage = 10',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
path: 'ServerScriptService.Main',
|
|
17
|
+
className: 'Script',
|
|
18
|
+
line: 9,
|
|
19
|
+
text: 'damage += 1',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
searched: 12,
|
|
23
|
+
truncated: false,
|
|
24
|
+
}),
|
|
25
|
+
} as any;
|
|
26
|
+
|
|
27
|
+
const result = await grepScriptsHandlerAsync(session, {
|
|
28
|
+
pattern: 'damage',
|
|
29
|
+
caseSensitive: true,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
expect(session.grepScriptsAsync).toHaveBeenCalledWith({
|
|
33
|
+
pattern: 'damage',
|
|
34
|
+
caseSensitive: true,
|
|
35
|
+
root: undefined,
|
|
36
|
+
luaPattern: undefined,
|
|
37
|
+
limit: undefined,
|
|
38
|
+
});
|
|
39
|
+
expect(result.summary).toBe('2 matching line(s) in 1 of 12 scripts');
|
|
40
|
+
|
|
41
|
+
const text = formatGrepText(result);
|
|
42
|
+
expect(text).toContain('ServerScriptService.Main');
|
|
43
|
+
expect(text).toContain('local damage = 10');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `explorer grep` — search the source of every script in Studio.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { OutputHelper } from '@quenty/cli-output-helpers';
|
|
6
|
+
import { defineCommand } from '../../framework/define-command.js';
|
|
7
|
+
import { arg } from '../../framework/arg-builder.js';
|
|
8
|
+
import type { BridgeSession } from '../../../bridge/index.js';
|
|
9
|
+
import type { GrepMatch } from '../../../server/web-socket-protocol.js';
|
|
10
|
+
|
|
11
|
+
export interface GrepOptions {
|
|
12
|
+
pattern: string;
|
|
13
|
+
root?: string;
|
|
14
|
+
luaPattern?: boolean;
|
|
15
|
+
caseSensitive?: boolean;
|
|
16
|
+
limit?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface GrepResult {
|
|
20
|
+
matches: GrepMatch[];
|
|
21
|
+
searched: number;
|
|
22
|
+
/** True when the search stopped at --limit; there may be more. */
|
|
23
|
+
truncated: boolean;
|
|
24
|
+
summary: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function grepScriptsHandlerAsync(
|
|
28
|
+
session: BridgeSession,
|
|
29
|
+
options: GrepOptions
|
|
30
|
+
): Promise<GrepResult> {
|
|
31
|
+
const result = await session.grepScriptsAsync({
|
|
32
|
+
pattern: options.pattern,
|
|
33
|
+
root: options.root,
|
|
34
|
+
luaPattern: options.luaPattern,
|
|
35
|
+
caseSensitive: options.caseSensitive,
|
|
36
|
+
limit: options.limit,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const scripts = new Set(result.matches.map((m) => m.path)).size;
|
|
40
|
+
return {
|
|
41
|
+
...result,
|
|
42
|
+
summary: result.truncated
|
|
43
|
+
? `First ${result.matches.length} matching lines; raise --limit to see more`
|
|
44
|
+
: `${result.matches.length} matching line(s) in ${scripts} of ${result.searched} scripts`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** `path:line: text`, like grep. */
|
|
49
|
+
export function formatGrepText(result: GrepResult): string {
|
|
50
|
+
if (result.matches.length === 0) return 'No matches';
|
|
51
|
+
const lines = result.matches.map(
|
|
52
|
+
(m) =>
|
|
53
|
+
`${OutputHelper.formatHint(m.path)}:${OutputHelper.formatDim(
|
|
54
|
+
String(m.line)
|
|
55
|
+
)}: ${m.text.trim()}`
|
|
56
|
+
);
|
|
57
|
+
lines.push(OutputHelper.formatDim(result.summary));
|
|
58
|
+
return lines.join('\n');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const grepCommand = defineCommand<GrepOptions, GrepResult>({
|
|
62
|
+
group: 'explorer',
|
|
63
|
+
name: 'grep',
|
|
64
|
+
description: 'Search the source of every script for text',
|
|
65
|
+
category: 'execution',
|
|
66
|
+
safety: 'read',
|
|
67
|
+
scope: 'session',
|
|
68
|
+
args: {
|
|
69
|
+
pattern: arg.positional({
|
|
70
|
+
description: 'Text to find (plain and case-insensitive by default)',
|
|
71
|
+
}),
|
|
72
|
+
luaPattern: arg.flag({
|
|
73
|
+
description: 'Treat the pattern as a Lua pattern',
|
|
74
|
+
}),
|
|
75
|
+
caseSensitive: arg.flag({
|
|
76
|
+
description: 'Match case',
|
|
77
|
+
alias: 's',
|
|
78
|
+
}),
|
|
79
|
+
root: arg.option({
|
|
80
|
+
description:
|
|
81
|
+
'Dot-separated path to search under (default: the whole DataModel)',
|
|
82
|
+
}),
|
|
83
|
+
limit: arg.option({
|
|
84
|
+
description: 'Stop after this many matching lines (default: 200)',
|
|
85
|
+
type: 'number',
|
|
86
|
+
alias: 'n',
|
|
87
|
+
}),
|
|
88
|
+
},
|
|
89
|
+
cli: {
|
|
90
|
+
format: formatGrepText,
|
|
91
|
+
},
|
|
92
|
+
handler: async (session, args) => grepScriptsHandlerAsync(session, args),
|
|
93
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
--!strict
|
|
2
|
+
--[=[
|
|
3
|
+
Action that decodes a base64 binary model (.rbxm), deserializes it with
|
|
4
|
+
SerializationService, and parents the instances under `parentPath`.
|
|
5
|
+
|
|
6
|
+
Request: `{ type: "importInstances", payload: { data, parentPath } }`
|
|
7
|
+
Response: `{ type: "importInstancesResult", payload: { paths } }`
|
|
8
|
+
|
|
9
|
+
@class ImportInstancesAction
|
|
10
|
+
]=]
|
|
11
|
+
|
|
12
|
+
local ImportInstancesAction = {}
|
|
13
|
+
|
|
14
|
+
--[=[
|
|
15
|
+
Registers the `importInstances` handler.
|
|
16
|
+
]=]
|
|
17
|
+
function ImportInstancesAction.register(router: any)
|
|
18
|
+
router:setResponseType("importInstances", "importInstancesResult")
|
|
19
|
+
router:register(
|
|
20
|
+
"importInstances",
|
|
21
|
+
function(payload: { [string]: any }, _requestId: string, _sessionId: string): { [string]: any }?
|
|
22
|
+
if type(payload.data) ~= "string" or type(payload.parentPath) ~= "string" then
|
|
23
|
+
return {
|
|
24
|
+
success = false,
|
|
25
|
+
code = "INVALID_PAYLOAD",
|
|
26
|
+
message = "importInstances needs data and parentPath strings",
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
local parent = ImportInstancesAction._resolveInstance(payload.parentPath)
|
|
31
|
+
if not parent then
|
|
32
|
+
return {
|
|
33
|
+
success = false,
|
|
34
|
+
code = "INSTANCE_NOT_FOUND",
|
|
35
|
+
message = `Instance not found at path: {payload.parentPath}`,
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
local decodeOk, decoded = pcall(function()
|
|
40
|
+
return game:GetService("EncodingService"):Base64Decode(buffer.fromstring(payload.data))
|
|
41
|
+
end)
|
|
42
|
+
if not decodeOk then
|
|
43
|
+
return {
|
|
44
|
+
success = false,
|
|
45
|
+
code = "DECODE_FAILED",
|
|
46
|
+
message = `Failed to base64 decode data: {decoded}`,
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
local deserializeOk, instances = pcall(function()
|
|
51
|
+
return game:GetService("SerializationService"):DeserializeInstancesAsync(decoded)
|
|
52
|
+
end)
|
|
53
|
+
if not deserializeOk then
|
|
54
|
+
return {
|
|
55
|
+
success = false,
|
|
56
|
+
code = "DESERIALIZE_FAILED",
|
|
57
|
+
message = `Failed to deserialize instances: {instances}`,
|
|
58
|
+
}
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
local paths = {}
|
|
62
|
+
for _, instance in instances do
|
|
63
|
+
instance.Parent = parent
|
|
64
|
+
table.insert(paths, instance:GetFullName())
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
paths = paths,
|
|
69
|
+
}
|
|
70
|
+
end
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
--[[
|
|
75
|
+
Walks `path` down from game, falling back to GetService for top-level names
|
|
76
|
+
that are not children by that name. A leading "game" is optional.
|
|
77
|
+
]]
|
|
78
|
+
function ImportInstancesAction._resolveInstance(path: string): Instance?
|
|
79
|
+
local parts = string.split(path, ".")
|
|
80
|
+
local startIndex = if parts[1] == "game" then 2 else 1
|
|
81
|
+
|
|
82
|
+
local current: Instance = game
|
|
83
|
+
for index = startIndex, #parts do
|
|
84
|
+
local part = parts[index]
|
|
85
|
+
|
|
86
|
+
local ok, child = pcall(current.FindFirstChild, current, part)
|
|
87
|
+
if ok and child then
|
|
88
|
+
current = child
|
|
89
|
+
continue
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
if current ~= game then
|
|
93
|
+
return nil
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
local serviceOk, service = pcall(game.GetService, game, part)
|
|
97
|
+
if not (serviceOk and service) then
|
|
98
|
+
return nil
|
|
99
|
+
end
|
|
100
|
+
current = service
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
return current
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
return ImportInstancesAction
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
--!strict
|
|
2
|
+
--[[
|
|
3
|
+
@class import-instances.spec.lua
|
|
4
|
+
]]
|
|
5
|
+
|
|
6
|
+
local require = require(script.Parent.loader).load(script)
|
|
7
|
+
|
|
8
|
+
local HttpService = game:GetService("HttpService")
|
|
9
|
+
|
|
10
|
+
local ActionRouter = require("ActionRouter")
|
|
11
|
+
local ImportInstancesAction = require("import-instances")
|
|
12
|
+
local Jest = require("Jest")
|
|
13
|
+
|
|
14
|
+
local describe = Jest.Globals.describe
|
|
15
|
+
local expect = Jest.Globals.expect
|
|
16
|
+
local it = Jest.Globals.it
|
|
17
|
+
|
|
18
|
+
local function setup(): any
|
|
19
|
+
local router = ActionRouter.new()
|
|
20
|
+
ImportInstancesAction.register(router)
|
|
21
|
+
|
|
22
|
+
local parent = Instance.new("Folder")
|
|
23
|
+
parent.Name = `ImportInstancesSpec{HttpService:GenerateGUID(false)}`
|
|
24
|
+
parent.Parent = workspace
|
|
25
|
+
|
|
26
|
+
local model = Instance.new("IntValue")
|
|
27
|
+
model.Name = "Score"
|
|
28
|
+
model.Value = 42
|
|
29
|
+
local serialized = game:GetService("SerializationService"):SerializeInstancesAsync({ model })
|
|
30
|
+
model:Destroy()
|
|
31
|
+
|
|
32
|
+
local controller = {
|
|
33
|
+
parent = parent,
|
|
34
|
+
parentPath = `Workspace.{parent.Name}`,
|
|
35
|
+
data = buffer.tostring(game:GetService("EncodingService"):Base64Encode(serialized)),
|
|
36
|
+
import = function(payload: { [string]: any }): any
|
|
37
|
+
return router:Dispatch({ type = "importInstances", sessionId = "session-1", payload = payload })
|
|
38
|
+
end,
|
|
39
|
+
Destroy = function(_self)
|
|
40
|
+
parent:Destroy()
|
|
41
|
+
end,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return controller
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe("importInstances", function()
|
|
48
|
+
it("should parent the deserialized instances under the parent path", function()
|
|
49
|
+
local controller = setup()
|
|
50
|
+
|
|
51
|
+
local response = controller.import({ data = controller.data, parentPath = controller.parentPath })
|
|
52
|
+
|
|
53
|
+
expect(response.type).toEqual("importInstancesResult")
|
|
54
|
+
expect(response.payload.paths).toEqual({ `{controller.parent:GetFullName()}.Score` })
|
|
55
|
+
expect((controller.parent:FindFirstChild("Score") :: IntValue).Value).toEqual(42)
|
|
56
|
+
|
|
57
|
+
controller:Destroy()
|
|
58
|
+
end)
|
|
59
|
+
|
|
60
|
+
it("should fail when the parent path does not resolve", function()
|
|
61
|
+
local controller = setup()
|
|
62
|
+
|
|
63
|
+
local response = controller.import({ data = controller.data, parentPath = "Workspace.DoesNotExist" })
|
|
64
|
+
|
|
65
|
+
expect(response.type).toEqual("error")
|
|
66
|
+
expect(response.payload.code).toEqual("INSTANCE_NOT_FOUND")
|
|
67
|
+
|
|
68
|
+
controller:Destroy()
|
|
69
|
+
end)
|
|
70
|
+
|
|
71
|
+
it("should fail on data that is not a model", function()
|
|
72
|
+
local controller = setup()
|
|
73
|
+
|
|
74
|
+
local response = controller.import({
|
|
75
|
+
data = buffer.tostring(game:GetService("EncodingService"):Base64Encode(buffer.fromstring("nope"))),
|
|
76
|
+
parentPath = controller.parentPath,
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
expect(response.type).toEqual("error")
|
|
80
|
+
expect(response.payload.code).toEqual("DESERIALIZE_FAILED")
|
|
81
|
+
|
|
82
|
+
controller:Destroy()
|
|
83
|
+
end)
|
|
84
|
+
end)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { describe, it, expect, vi, afterEach } from 'vitest';
|
|
2
|
+
import * as fs from 'fs/promises';
|
|
3
|
+
import * as os from 'os';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import { importInstancesHandlerAsync } from './import.js';
|
|
6
|
+
|
|
7
|
+
describe('importInstancesHandlerAsync', () => {
|
|
8
|
+
const dirs: string[] = [];
|
|
9
|
+
|
|
10
|
+
afterEach(async () => {
|
|
11
|
+
for (const dir of dirs) {
|
|
12
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
13
|
+
}
|
|
14
|
+
dirs.length = 0;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
async function writeModelAsync(contents: string): Promise<string> {
|
|
18
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'sb-import-'));
|
|
19
|
+
dirs.push(dir);
|
|
20
|
+
const file = path.join(dir, 'model.rbxm');
|
|
21
|
+
await fs.writeFile(file, contents);
|
|
22
|
+
return file;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function createSession() {
|
|
26
|
+
return {
|
|
27
|
+
importInstancesAsync: vi
|
|
28
|
+
.fn()
|
|
29
|
+
.mockResolvedValue({ paths: ['Workspace.Map'] }),
|
|
30
|
+
} as any;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
it('sends the file as base64 under Workspace by default', async () => {
|
|
34
|
+
const file = await writeModelAsync('<roblox!model');
|
|
35
|
+
const session = createSession();
|
|
36
|
+
|
|
37
|
+
const result = await importInstancesHandlerAsync(session, { file });
|
|
38
|
+
|
|
39
|
+
expect(session.importInstancesAsync).toHaveBeenCalledWith(
|
|
40
|
+
Buffer.from('<roblox!model').toString('base64'),
|
|
41
|
+
'Workspace'
|
|
42
|
+
);
|
|
43
|
+
expect(result.paths).toEqual(['Workspace.Map']);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('uses the given parent', async () => {
|
|
47
|
+
const file = await writeModelAsync('<roblox!model');
|
|
48
|
+
const session = createSession();
|
|
49
|
+
|
|
50
|
+
await importInstancesHandlerAsync(session, {
|
|
51
|
+
file,
|
|
52
|
+
parent: 'ServerStorage',
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
expect(session.importInstancesAsync).toHaveBeenCalledWith(
|
|
56
|
+
expect.any(String),
|
|
57
|
+
'ServerStorage'
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `explorer import` — insert a binary model (.rbxm) into a connected Studio
|
|
3
|
+
* session.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as fs from 'fs/promises';
|
|
7
|
+
import { defineCommand } from '../../framework/define-command.js';
|
|
8
|
+
import { arg } from '../../framework/arg-builder.js';
|
|
9
|
+
import type { BridgeSession } from '../../../bridge/index.js';
|
|
10
|
+
|
|
11
|
+
export interface ImportResult {
|
|
12
|
+
paths: string[];
|
|
13
|
+
summary: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ImportOptions {
|
|
17
|
+
file: string;
|
|
18
|
+
parent?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface ImportArgs {
|
|
22
|
+
file: string;
|
|
23
|
+
parent?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function importInstancesHandlerAsync(
|
|
27
|
+
session: BridgeSession,
|
|
28
|
+
options: ImportOptions
|
|
29
|
+
): Promise<ImportResult> {
|
|
30
|
+
const data = await fs.readFile(options.file);
|
|
31
|
+
const result = await session.importInstancesAsync(
|
|
32
|
+
data.toString('base64'),
|
|
33
|
+
options.parent ?? 'Workspace'
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
paths: result.paths,
|
|
38
|
+
summary: `Imported ${result.paths.length} instance(s): ${result.paths.join(
|
|
39
|
+
', '
|
|
40
|
+
)}`,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const importCommand = defineCommand<ImportArgs, ImportResult>({
|
|
45
|
+
group: 'explorer',
|
|
46
|
+
name: 'import',
|
|
47
|
+
description: 'Insert a binary model (.rbxm) into Studio',
|
|
48
|
+
category: 'execution',
|
|
49
|
+
safety: 'mutate',
|
|
50
|
+
changesDataModel: true,
|
|
51
|
+
scope: 'session',
|
|
52
|
+
args: {
|
|
53
|
+
file: arg.positional({
|
|
54
|
+
description: 'Path to a .rbxm file',
|
|
55
|
+
}),
|
|
56
|
+
parent: arg.option({
|
|
57
|
+
description:
|
|
58
|
+
'Dot-separated path of the parent instance (default: Workspace)',
|
|
59
|
+
}),
|
|
60
|
+
},
|
|
61
|
+
handler: async (session, args) =>
|
|
62
|
+
importInstancesHandlerAsync(session, {
|
|
63
|
+
file: args.file,
|
|
64
|
+
parent: args.parent,
|
|
65
|
+
}),
|
|
66
|
+
});
|