@quenty/studio-bridge 0.7.1 → 0.8.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 +12 -44
- package/README.md +166 -115
- package/dist/src/bridge/bridge-connection-remote.test.d.ts +7 -0
- package/dist/src/bridge/bridge-connection-remote.test.d.ts.map +1 -0
- package/dist/src/bridge/bridge-connection-remote.test.js +144 -0
- package/dist/src/bridge/bridge-connection-remote.test.js.map +1 -0
- package/dist/src/bridge/bridge-connection.d.ts +112 -0
- package/dist/src/bridge/bridge-connection.d.ts.map +1 -0
- package/dist/src/bridge/bridge-connection.js +528 -0
- package/dist/src/bridge/bridge-connection.js.map +1 -0
- package/dist/src/bridge/bridge-connection.test.d.ts +6 -0
- package/dist/src/bridge/bridge-connection.test.d.ts.map +1 -0
- package/dist/src/bridge/bridge-connection.test.js +773 -0
- package/dist/src/bridge/bridge-connection.test.js.map +1 -0
- package/dist/src/bridge/bridge-session.d.ts +38 -0
- package/dist/src/bridge/bridge-session.d.ts.map +1 -0
- package/dist/src/bridge/bridge-session.js +259 -0
- package/dist/src/bridge/bridge-session.js.map +1 -0
- package/dist/src/bridge/bridge-session.test.d.ts +6 -0
- package/dist/src/bridge/bridge-session.test.d.ts.map +1 -0
- package/dist/src/bridge/bridge-session.test.js +264 -0
- package/dist/src/bridge/bridge-session.test.js.map +1 -0
- package/dist/src/bridge/index.d.ts +13 -0
- package/dist/src/bridge/index.d.ts.map +1 -0
- package/dist/src/bridge/index.js +13 -0
- package/dist/src/bridge/index.js.map +1 -0
- package/dist/src/bridge/internal/__tests__/failover-crash.test.d.ts +9 -0
- package/dist/src/bridge/internal/__tests__/failover-crash.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/__tests__/failover-crash.test.js +159 -0
- package/dist/src/bridge/internal/__tests__/failover-crash.test.js.map +1 -0
- package/dist/src/bridge/internal/__tests__/failover-graceful.test.d.ts +9 -0
- package/dist/src/bridge/internal/__tests__/failover-graceful.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/__tests__/failover-graceful.test.js +218 -0
- package/dist/src/bridge/internal/__tests__/failover-graceful.test.js.map +1 -0
- package/dist/src/bridge/internal/__tests__/failover-inflight.test.d.ts +9 -0
- package/dist/src/bridge/internal/__tests__/failover-inflight.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/__tests__/failover-inflight.test.js +246 -0
- package/dist/src/bridge/internal/__tests__/failover-inflight.test.js.map +1 -0
- package/dist/src/bridge/internal/__tests__/host-client-integration.test.d.ts +10 -0
- package/dist/src/bridge/internal/__tests__/host-client-integration.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/__tests__/host-client-integration.test.js +298 -0
- package/dist/src/bridge/internal/__tests__/host-client-integration.test.js.map +1 -0
- package/dist/src/bridge/internal/bridge-client.d.ts +70 -0
- package/dist/src/bridge/internal/bridge-client.d.ts.map +1 -0
- package/dist/src/bridge/internal/bridge-client.js +344 -0
- package/dist/src/bridge/internal/bridge-client.js.map +1 -0
- package/dist/src/bridge/internal/bridge-client.test.d.ts +7 -0
- package/dist/src/bridge/internal/bridge-client.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/bridge-client.test.js +301 -0
- package/dist/src/bridge/internal/bridge-client.test.js.map +1 -0
- package/dist/src/bridge/internal/bridge-host.d.ts +78 -0
- package/dist/src/bridge/internal/bridge-host.d.ts.map +1 -0
- package/dist/src/bridge/internal/bridge-host.js +383 -0
- package/dist/src/bridge/internal/bridge-host.js.map +1 -0
- package/dist/src/bridge/internal/bridge-host.test.d.ts +7 -0
- package/dist/src/bridge/internal/bridge-host.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/bridge-host.test.js +377 -0
- package/dist/src/bridge/internal/bridge-host.test.js.map +1 -0
- package/dist/src/bridge/internal/environment-detection.d.ts +44 -0
- package/dist/src/bridge/internal/environment-detection.d.ts.map +1 -0
- package/dist/src/bridge/internal/environment-detection.js +91 -0
- package/dist/src/bridge/internal/environment-detection.js.map +1 -0
- package/dist/src/bridge/internal/environment-detection.test.d.ts +7 -0
- package/dist/src/bridge/internal/environment-detection.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/environment-detection.test.js +150 -0
- package/dist/src/bridge/internal/environment-detection.test.js.map +1 -0
- package/dist/src/bridge/internal/hand-off.d.ts +69 -0
- package/dist/src/bridge/internal/hand-off.d.ts.map +1 -0
- package/dist/src/bridge/internal/hand-off.js +178 -0
- package/dist/src/bridge/internal/hand-off.js.map +1 -0
- package/dist/src/bridge/internal/hand-off.test.d.ts +7 -0
- package/dist/src/bridge/internal/hand-off.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/hand-off.test.js +325 -0
- package/dist/src/bridge/internal/hand-off.test.js.map +1 -0
- package/dist/src/bridge/internal/health-endpoint.d.ts +32 -0
- package/dist/src/bridge/internal/health-endpoint.d.ts.map +1 -0
- package/dist/src/bridge/internal/health-endpoint.js +73 -0
- package/dist/src/bridge/internal/health-endpoint.js.map +1 -0
- package/dist/src/bridge/internal/health-endpoint.test.d.ts +6 -0
- package/dist/src/bridge/internal/health-endpoint.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/health-endpoint.test.js +122 -0
- package/dist/src/bridge/internal/health-endpoint.test.js.map +1 -0
- package/dist/src/bridge/internal/host-protocol.d.ts +60 -0
- package/dist/src/bridge/internal/host-protocol.d.ts.map +1 -0
- package/dist/src/bridge/internal/host-protocol.js +184 -0
- package/dist/src/bridge/internal/host-protocol.js.map +1 -0
- package/dist/src/bridge/internal/host-protocol.test.d.ts +6 -0
- package/dist/src/bridge/internal/host-protocol.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/host-protocol.test.js +307 -0
- package/dist/src/bridge/internal/host-protocol.test.js.map +1 -0
- package/dist/src/bridge/internal/session-tracker.d.ts +67 -0
- package/dist/src/bridge/internal/session-tracker.d.ts.map +1 -0
- package/dist/src/bridge/internal/session-tracker.js +138 -0
- package/dist/src/bridge/internal/session-tracker.js.map +1 -0
- package/dist/src/bridge/internal/session-tracker.test.d.ts +6 -0
- package/dist/src/bridge/internal/session-tracker.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/session-tracker.test.js +342 -0
- package/dist/src/bridge/internal/session-tracker.test.js.map +1 -0
- package/dist/src/bridge/internal/transport-client.d.ts +43 -0
- package/dist/src/bridge/internal/transport-client.d.ts.map +1 -0
- package/dist/src/bridge/internal/transport-client.js +146 -0
- package/dist/src/bridge/internal/transport-client.js.map +1 -0
- package/dist/src/bridge/internal/transport-client.test.d.ts +6 -0
- package/dist/src/bridge/internal/transport-client.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/transport-client.test.js +176 -0
- package/dist/src/bridge/internal/transport-client.test.js.map +1 -0
- package/dist/src/bridge/internal/transport-server.d.ts +59 -0
- package/dist/src/bridge/internal/transport-server.d.ts.map +1 -0
- package/dist/src/bridge/internal/transport-server.js +189 -0
- package/dist/src/bridge/internal/transport-server.js.map +1 -0
- package/dist/src/bridge/internal/transport-server.test.d.ts +6 -0
- package/dist/src/bridge/internal/transport-server.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/transport-server.test.js +171 -0
- package/dist/src/bridge/internal/transport-server.test.js.map +1 -0
- package/dist/src/bridge/types.d.ts +117 -0
- package/dist/src/bridge/types.d.ts.map +1 -0
- package/dist/src/bridge/types.js +68 -0
- package/dist/src/bridge/types.js.map +1 -0
- package/dist/src/cli/adapters/cli-command-adapter-handler.test.d.ts +6 -0
- package/dist/src/cli/adapters/cli-command-adapter-handler.test.d.ts.map +1 -0
- package/dist/src/cli/adapters/cli-command-adapter-handler.test.js +260 -0
- package/dist/src/cli/adapters/cli-command-adapter-handler.test.js.map +1 -0
- package/dist/src/cli/adapters/cli-command-adapter.d.ts +39 -0
- package/dist/src/cli/adapters/cli-command-adapter.d.ts.map +1 -0
- package/dist/src/cli/adapters/cli-command-adapter.js +241 -0
- package/dist/src/cli/adapters/cli-command-adapter.js.map +1 -0
- package/dist/src/cli/adapters/cli-command-adapter.test.d.ts +5 -0
- package/dist/src/cli/adapters/cli-command-adapter.test.d.ts.map +1 -0
- package/dist/src/cli/adapters/cli-command-adapter.test.js +188 -0
- package/dist/src/cli/adapters/cli-command-adapter.test.js.map +1 -0
- package/dist/src/cli/adapters/group-builder.d.ts +29 -0
- package/dist/src/cli/adapters/group-builder.d.ts.map +1 -0
- package/dist/src/cli/adapters/group-builder.js +54 -0
- package/dist/src/cli/adapters/group-builder.js.map +1 -0
- package/dist/src/cli/adapters/group-builder.test.d.ts +5 -0
- package/dist/src/cli/adapters/group-builder.test.d.ts.map +1 -0
- package/dist/src/cli/adapters/group-builder.test.js +108 -0
- package/dist/src/cli/adapters/group-builder.test.js.map +1 -0
- package/dist/src/cli/adapters/help-formatter.d.ts +11 -0
- package/dist/src/cli/adapters/help-formatter.d.ts.map +1 -0
- package/dist/src/cli/adapters/help-formatter.js +78 -0
- package/dist/src/cli/adapters/help-formatter.js.map +1 -0
- package/dist/src/cli/adapters/help-formatter.test.d.ts +5 -0
- package/dist/src/cli/adapters/help-formatter.test.d.ts.map +1 -0
- package/dist/src/cli/adapters/help-formatter.test.js +79 -0
- package/dist/src/cli/adapters/help-formatter.test.js.map +1 -0
- package/dist/src/cli/adapters/target-resolver.d.ts +54 -0
- package/dist/src/cli/adapters/target-resolver.d.ts.map +1 -0
- package/dist/src/cli/adapters/target-resolver.js +90 -0
- package/dist/src/cli/adapters/target-resolver.js.map +1 -0
- package/dist/src/cli/adapters/target-resolver.test.d.ts +5 -0
- package/dist/src/cli/adapters/target-resolver.test.d.ts.map +1 -0
- package/dist/src/cli/adapters/target-resolver.test.js +169 -0
- package/dist/src/cli/adapters/target-resolver.test.js.map +1 -0
- package/dist/src/cli/args/global-args.d.ts +2 -0
- package/dist/src/cli/args/global-args.d.ts.map +1 -1
- package/dist/src/cli/cli.d.ts +6 -3
- package/dist/src/cli/cli.d.ts.map +1 -1
- package/dist/src/cli/cli.js +82 -20
- package/dist/src/cli/cli.js.map +1 -1
- package/dist/src/cli/resolve-script-content.d.ts +19 -0
- package/dist/src/cli/resolve-script-content.d.ts.map +1 -0
- package/dist/src/cli/resolve-script-content.js +22 -0
- package/dist/src/cli/resolve-script-content.js.map +1 -0
- package/dist/src/cli/resolve-session.d.ts +21 -0
- package/dist/src/cli/resolve-session.d.ts.map +1 -0
- package/dist/src/cli/resolve-session.js +40 -0
- package/dist/src/cli/resolve-session.js.map +1 -0
- package/dist/src/cli/resolve-session.test.d.ts +5 -0
- package/dist/src/cli/resolve-session.test.d.ts.map +1 -0
- package/dist/src/cli/resolve-session.test.js +112 -0
- package/dist/src/cli/resolve-session.test.js.map +1 -0
- package/dist/src/cli/script-executor.d.ts +1 -0
- package/dist/src/cli/script-executor.d.ts.map +1 -1
- package/dist/src/cli/script-executor.js +7 -1
- package/dist/src/cli/script-executor.js.map +1 -1
- package/dist/src/cli/types.d.ts +11 -0
- package/dist/src/cli/types.d.ts.map +1 -0
- package/dist/src/cli/types.js +5 -0
- package/dist/src/cli/types.js.map +1 -0
- package/dist/src/commands/connect.d.ts +16 -0
- package/dist/src/commands/connect.d.ts.map +1 -0
- package/dist/src/commands/connect.js +15 -0
- package/dist/src/commands/connect.js.map +1 -0
- package/dist/src/commands/connect.test.d.ts +5 -0
- package/dist/src/commands/connect.test.d.ts.map +1 -0
- package/dist/src/commands/connect.test.js +46 -0
- package/dist/src/commands/connect.test.js.map +1 -0
- package/dist/src/commands/console/exec/exec.d.ts +43 -0
- package/dist/src/commands/console/exec/exec.d.ts.map +1 -0
- package/dist/src/commands/console/exec/exec.js +79 -0
- package/dist/src/commands/console/exec/exec.js.map +1 -0
- package/dist/src/commands/console/exec/exec.test.d.ts +5 -0
- package/dist/src/commands/console/exec/exec.test.d.ts.map +1 -0
- package/dist/src/commands/console/exec/exec.test.js +191 -0
- package/dist/src/commands/console/exec/exec.test.js.map +1 -0
- package/dist/src/commands/console/logs/logs.d.ts +23 -0
- package/dist/src/commands/console/logs/logs.d.ts.map +1 -0
- package/dist/src/commands/console/logs/logs.js +80 -0
- package/dist/src/commands/console/logs/logs.js.map +1 -0
- package/dist/src/commands/console/logs/logs.test.d.ts +5 -0
- package/dist/src/commands/console/logs/logs.test.d.ts.map +1 -0
- package/dist/src/commands/console/logs/logs.test.js +111 -0
- package/dist/src/commands/console/logs/logs.test.js.map +1 -0
- package/dist/src/commands/disconnect.d.ts +9 -0
- package/dist/src/commands/disconnect.d.ts.map +1 -0
- package/dist/src/commands/disconnect.js +8 -0
- package/dist/src/commands/disconnect.js.map +1 -0
- package/dist/src/commands/disconnect.test.d.ts +5 -0
- package/dist/src/commands/disconnect.test.d.ts.map +1 -0
- package/dist/src/commands/disconnect.test.js +17 -0
- package/dist/src/commands/disconnect.test.js.map +1 -0
- package/dist/src/commands/explorer/query/query.d.ts +31 -0
- package/dist/src/commands/explorer/query/query.d.ts.map +1 -0
- package/dist/src/commands/explorer/query/query.js +106 -0
- package/dist/src/commands/explorer/query/query.js.map +1 -0
- package/dist/src/commands/explorer/query/query.test.d.ts +5 -0
- package/dist/src/commands/explorer/query/query.test.d.ts.map +1 -0
- package/dist/src/commands/explorer/query/query.test.js +228 -0
- package/dist/src/commands/explorer/query/query.test.js.map +1 -0
- package/dist/src/commands/formatters.test.d.ts +6 -0
- package/dist/src/commands/formatters.test.d.ts.map +1 -0
- package/dist/src/commands/formatters.test.js +211 -0
- package/dist/src/commands/formatters.test.js.map +1 -0
- package/dist/src/commands/framework/action-loader.d.ts +25 -0
- package/dist/src/commands/framework/action-loader.d.ts.map +1 -0
- package/dist/src/commands/framework/action-loader.js +46 -0
- package/dist/src/commands/framework/action-loader.js.map +1 -0
- package/dist/src/commands/framework/action-loader.test.d.ts +5 -0
- package/dist/src/commands/framework/action-loader.test.d.ts.map +1 -0
- package/dist/src/commands/framework/action-loader.test.js +89 -0
- package/dist/src/commands/framework/action-loader.test.js.map +1 -0
- package/dist/src/commands/framework/arg-builder.d.ts +92 -0
- package/dist/src/commands/framework/arg-builder.d.ts.map +1 -0
- package/dist/src/commands/framework/arg-builder.js +137 -0
- package/dist/src/commands/framework/arg-builder.js.map +1 -0
- package/dist/src/commands/framework/arg-builder.test.d.ts +5 -0
- package/dist/src/commands/framework/arg-builder.test.d.ts.map +1 -0
- package/dist/src/commands/framework/arg-builder.test.js +246 -0
- package/dist/src/commands/framework/arg-builder.test.js.map +1 -0
- package/dist/src/commands/framework/command-registry.d.ts +23 -0
- package/dist/src/commands/framework/command-registry.d.ts.map +1 -0
- package/dist/src/commands/framework/command-registry.js +42 -0
- package/dist/src/commands/framework/command-registry.js.map +1 -0
- package/dist/src/commands/framework/command-registry.test.d.ts +5 -0
- package/dist/src/commands/framework/command-registry.test.d.ts.map +1 -0
- package/dist/src/commands/framework/command-registry.test.js +158 -0
- package/dist/src/commands/framework/command-registry.test.js.map +1 -0
- package/dist/src/commands/framework/define-command.d.ts +76 -0
- package/dist/src/commands/framework/define-command.d.ts.map +1 -0
- package/dist/src/commands/framework/define-command.js +28 -0
- package/dist/src/commands/framework/define-command.js.map +1 -0
- package/dist/src/commands/framework/define-command.test.d.ts +5 -0
- package/dist/src/commands/framework/define-command.test.d.ts.map +1 -0
- package/dist/src/commands/framework/define-command.test.js +135 -0
- package/dist/src/commands/framework/define-command.test.js.map +1 -0
- package/dist/src/commands/framework/index.d.ts +8 -0
- package/dist/src/commands/framework/index.d.ts.map +1 -0
- package/dist/src/commands/framework/index.js +8 -0
- package/dist/src/commands/framework/index.js.map +1 -0
- package/dist/src/commands/index.d.ts +20 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/index.js +20 -0
- package/dist/src/commands/index.js.map +1 -0
- package/dist/src/commands/linux/inject-credentials/inject-credentials.d.ts +15 -0
- package/dist/src/commands/linux/inject-credentials/inject-credentials.d.ts.map +1 -0
- package/dist/src/commands/linux/inject-credentials/inject-credentials.js +88 -0
- package/dist/src/commands/linux/inject-credentials/inject-credentials.js.map +1 -0
- package/dist/src/commands/linux/setup/setup.d.ts +19 -0
- package/dist/src/commands/linux/setup/setup.d.ts.map +1 -0
- package/dist/src/commands/linux/setup/setup.js +107 -0
- package/dist/src/commands/linux/setup/setup.js.map +1 -0
- package/dist/src/commands/linux/status/status.d.ts +34 -0
- package/dist/src/commands/linux/status/status.d.ts.map +1 -0
- package/dist/src/commands/linux/status/status.js +134 -0
- package/dist/src/commands/linux/status/status.js.map +1 -0
- package/dist/src/commands/plugin/install/install.d.ts +10 -0
- package/dist/src/commands/plugin/install/install.d.ts.map +1 -0
- package/dist/src/commands/plugin/install/install.js +23 -0
- package/dist/src/commands/plugin/install/install.js.map +1 -0
- package/dist/src/commands/plugin/uninstall/uninstall.d.ts +9 -0
- package/dist/src/commands/plugin/uninstall/uninstall.d.ts.map +1 -0
- package/dist/src/commands/plugin/uninstall/uninstall.js +41 -0
- package/dist/src/commands/plugin/uninstall/uninstall.js.map +1 -0
- package/dist/src/commands/process/close/close.d.ts +22 -0
- package/dist/src/commands/process/close/close.d.ts.map +1 -0
- package/dist/src/commands/process/close/close.js +34 -0
- package/dist/src/commands/process/close/close.js.map +1 -0
- package/dist/src/commands/process/format-state.d.ts +7 -0
- package/dist/src/commands/process/format-state.d.ts.map +1 -0
- package/dist/src/commands/process/format-state.js +19 -0
- package/dist/src/commands/process/format-state.js.map +1 -0
- package/dist/src/commands/process/info/info.d.ts +17 -0
- package/dist/src/commands/process/info/info.d.ts.map +1 -0
- package/dist/src/commands/process/info/info.js +38 -0
- package/dist/src/commands/process/info/info.js.map +1 -0
- package/dist/src/commands/process/info/info.test.d.ts +5 -0
- package/dist/src/commands/process/info/info.test.d.ts.map +1 -0
- package/dist/src/commands/process/info/info.test.js +58 -0
- package/dist/src/commands/process/info/info.test.js.map +1 -0
- package/dist/src/commands/process/launch/launch.d.ts +17 -0
- package/dist/src/commands/process/launch/launch.d.ts.map +1 -0
- package/dist/src/commands/process/launch/launch.js +26 -0
- package/dist/src/commands/process/launch/launch.js.map +1 -0
- package/dist/src/commands/process/launch/launch.test.d.ts +5 -0
- package/dist/src/commands/process/launch/launch.test.d.ts.map +1 -0
- package/dist/src/commands/process/launch/launch.test.js +49 -0
- package/dist/src/commands/process/launch/launch.test.js.map +1 -0
- package/dist/src/commands/process/list/list.d.ts +16 -0
- package/dist/src/commands/process/list/list.d.ts.map +1 -0
- package/dist/src/commands/process/list/list.js +56 -0
- package/dist/src/commands/process/list/list.js.map +1 -0
- package/dist/src/commands/process/list/list.test.d.ts +5 -0
- package/dist/src/commands/process/list/list.test.d.ts.map +1 -0
- package/dist/src/commands/process/list/list.test.js +71 -0
- package/dist/src/commands/process/list/list.test.js.map +1 -0
- package/dist/src/commands/process/run/run.d.ts +31 -0
- package/dist/src/commands/process/run/run.d.ts.map +1 -0
- package/dist/src/commands/process/run/run.js +63 -0
- package/dist/src/commands/process/run/run.js.map +1 -0
- package/dist/src/commands/rgba-to-png.d.ts +17 -0
- package/dist/src/commands/rgba-to-png.d.ts.map +1 -0
- package/dist/src/commands/rgba-to-png.js +85 -0
- package/dist/src/commands/rgba-to-png.js.map +1 -0
- package/dist/src/commands/serve/serve.d.ts +17 -0
- package/dist/src/commands/serve/serve.d.ts.map +1 -0
- package/dist/src/commands/serve/serve.js +128 -0
- package/dist/src/commands/serve/serve.js.map +1 -0
- package/dist/src/commands/serve/serve.test.d.ts +5 -0
- package/dist/src/commands/serve/serve.test.d.ts.map +1 -0
- package/dist/src/commands/serve/serve.test.js +100 -0
- package/dist/src/commands/serve/serve.test.js.map +1 -0
- package/dist/src/commands/viewport/screenshot/screenshot.d.ts +17 -0
- package/dist/src/commands/viewport/screenshot/screenshot.d.ts.map +1 -0
- package/dist/src/commands/viewport/screenshot/screenshot.js +45 -0
- package/dist/src/commands/viewport/screenshot/screenshot.js.map +1 -0
- package/dist/src/commands/viewport/screenshot/screenshot.test.d.ts +5 -0
- package/dist/src/commands/viewport/screenshot/screenshot.test.d.ts.map +1 -0
- package/dist/src/commands/viewport/screenshot/screenshot.test.js +143 -0
- package/dist/src/commands/viewport/screenshot/screenshot.test.js.map +1 -0
- package/dist/src/docker/docker-delegator.d.ts +30 -0
- package/dist/src/docker/docker-delegator.d.ts.map +1 -0
- package/dist/src/docker/docker-delegator.js +201 -0
- package/dist/src/docker/docker-delegator.js.map +1 -0
- package/dist/src/docker/docker-delegator.test.d.ts +2 -0
- package/dist/src/docker/docker-delegator.test.d.ts.map +1 -0
- package/dist/src/docker/docker-delegator.test.js +132 -0
- package/dist/src/docker/docker-delegator.test.js.map +1 -0
- package/dist/src/index.d.ts +9 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.test.d.ts +2 -0
- package/dist/src/index.test.d.ts.map +1 -0
- package/dist/src/index.test.js +51 -0
- package/dist/src/index.test.js.map +1 -0
- package/dist/src/linux/index.d.ts +12 -0
- package/dist/src/linux/index.d.ts.map +1 -0
- package/dist/src/linux/index.js +11 -0
- package/dist/src/linux/index.js.map +1 -0
- package/dist/src/linux/linux-config.d.ts +37 -0
- package/dist/src/linux/linux-config.d.ts.map +1 -0
- package/dist/src/linux/linux-config.js +70 -0
- package/dist/src/linux/linux-config.js.map +1 -0
- package/dist/src/linux/linux-config.test.d.ts +2 -0
- package/dist/src/linux/linux-config.test.d.ts.map +1 -0
- package/dist/src/linux/linux-config.test.js +54 -0
- package/dist/src/linux/linux-config.test.js.map +1 -0
- package/dist/src/linux/linux-credential-writer.d.ts +35 -0
- package/dist/src/linux/linux-credential-writer.d.ts.map +1 -0
- package/dist/src/linux/linux-credential-writer.js +300 -0
- package/dist/src/linux/linux-credential-writer.js.map +1 -0
- package/dist/src/linux/linux-display-manager.d.ts +24 -0
- package/dist/src/linux/linux-display-manager.d.ts.map +1 -0
- package/dist/src/linux/linux-display-manager.js +92 -0
- package/dist/src/linux/linux-display-manager.js.map +1 -0
- package/dist/src/linux/linux-env-guard.d.ts +13 -0
- package/dist/src/linux/linux-env-guard.d.ts.map +1 -0
- package/dist/src/linux/linux-env-guard.js +31 -0
- package/dist/src/linux/linux-env-guard.js.map +1 -0
- package/dist/src/linux/linux-env-guard.test.d.ts +2 -0
- package/dist/src/linux/linux-env-guard.test.d.ts.map +1 -0
- package/dist/src/linux/linux-env-guard.test.js +48 -0
- package/dist/src/linux/linux-env-guard.test.js.map +1 -0
- package/dist/src/linux/linux-fflags.d.ts +17 -0
- package/dist/src/linux/linux-fflags.d.ts.map +1 -0
- package/dist/src/linux/linux-fflags.js +33 -0
- package/dist/src/linux/linux-fflags.js.map +1 -0
- package/dist/src/linux/linux-fflags.test.d.ts +2 -0
- package/dist/src/linux/linux-fflags.test.d.ts.map +1 -0
- package/dist/src/linux/linux-fflags.test.js +55 -0
- package/dist/src/linux/linux-fflags.test.js.map +1 -0
- package/dist/src/linux/linux-prerequisites.d.ts +24 -0
- package/dist/src/linux/linux-prerequisites.d.ts.map +1 -0
- package/dist/src/linux/linux-prerequisites.js +118 -0
- package/dist/src/linux/linux-prerequisites.js.map +1 -0
- package/dist/src/linux/linux-shader-patcher.d.ts +17 -0
- package/dist/src/linux/linux-shader-patcher.d.ts.map +1 -0
- package/dist/src/linux/linux-shader-patcher.js +48 -0
- package/dist/src/linux/linux-shader-patcher.js.map +1 -0
- package/dist/src/linux/linux-shader-patcher.test.d.ts +2 -0
- package/dist/src/linux/linux-shader-patcher.test.d.ts.map +1 -0
- package/dist/src/linux/linux-shader-patcher.test.js +55 -0
- package/dist/src/linux/linux-shader-patcher.test.js.map +1 -0
- package/dist/src/linux/linux-studio-installer.d.ts +10 -0
- package/dist/src/linux/linux-studio-installer.d.ts.map +1 -0
- package/dist/src/linux/linux-studio-installer.js +79 -0
- package/dist/src/linux/linux-studio-installer.js.map +1 -0
- package/dist/src/linux/linux-studio-launcher.d.ts +10 -0
- package/dist/src/linux/linux-studio-launcher.d.ts.map +1 -0
- package/dist/src/linux/linux-studio-launcher.js +73 -0
- package/dist/src/linux/linux-studio-launcher.js.map +1 -0
- package/dist/src/linux/linux-version-resolver.d.ts +18 -0
- package/dist/src/linux/linux-version-resolver.d.ts.map +1 -0
- package/dist/src/linux/linux-version-resolver.js +49 -0
- package/dist/src/linux/linux-version-resolver.js.map +1 -0
- package/dist/src/linux/linux-wine-env.d.ts +11 -0
- package/dist/src/linux/linux-wine-env.d.ts.map +1 -0
- package/dist/src/linux/linux-wine-env.js +33 -0
- package/dist/src/linux/linux-wine-env.js.map +1 -0
- package/dist/src/linux/linux-wine-env.test.d.ts +2 -0
- package/dist/src/linux/linux-wine-env.test.d.ts.map +1 -0
- package/dist/src/linux/linux-wine-env.test.js +47 -0
- package/dist/src/linux/linux-wine-env.test.js.map +1 -0
- package/dist/src/plugin/persistent-plugin-installer.d.ts +21 -0
- package/dist/src/plugin/persistent-plugin-installer.d.ts.map +1 -0
- package/dist/src/plugin/persistent-plugin-installer.js +69 -0
- package/dist/src/plugin/persistent-plugin-installer.js.map +1 -0
- package/dist/src/plugin/persistent-plugin-installer.test.d.ts +5 -0
- package/dist/src/plugin/persistent-plugin-installer.test.d.ts.map +1 -0
- package/dist/src/plugin/persistent-plugin-installer.test.js +109 -0
- package/dist/src/plugin/persistent-plugin-installer.test.js.map +1 -0
- package/dist/src/plugin/plugin-discovery.d.ts +7 -0
- package/dist/src/plugin/plugin-discovery.d.ts.map +1 -0
- package/dist/src/plugin/plugin-discovery.js +18 -0
- package/dist/src/plugin/plugin-discovery.js.map +1 -0
- package/dist/src/plugin/plugin-discovery.test.d.ts +5 -0
- package/dist/src/plugin/plugin-discovery.test.d.ts.map +1 -0
- package/dist/src/plugin/plugin-discovery.test.js +55 -0
- package/dist/src/plugin/plugin-discovery.test.js.map +1 -0
- package/dist/src/plugin/plugin-injector.js +1 -1
- package/dist/src/plugin/plugin-injector.js.map +1 -1
- package/dist/src/process/studio-process-manager.d.ts +7 -3
- package/dist/src/process/studio-process-manager.d.ts.map +1 -1
- package/dist/src/process/studio-process-manager.js +38 -11
- package/dist/src/process/studio-process-manager.js.map +1 -1
- package/dist/src/process/studio-process-manager.test.js +18 -1
- package/dist/src/process/studio-process-manager.test.js.map +1 -1
- package/dist/src/server/action-dispatcher.d.ts +35 -0
- package/dist/src/server/action-dispatcher.d.ts.map +1 -0
- package/dist/src/server/action-dispatcher.js +67 -0
- package/dist/src/server/action-dispatcher.js.map +1 -0
- package/dist/src/server/action-dispatcher.test.d.ts +6 -0
- package/dist/src/server/action-dispatcher.test.d.ts.map +1 -0
- package/dist/src/server/action-dispatcher.test.js +173 -0
- package/dist/src/server/action-dispatcher.test.js.map +1 -0
- package/dist/src/server/index.d.ts +1 -1
- package/dist/src/server/index.d.ts.map +1 -1
- package/dist/src/server/pending-request-map.d.ts +33 -0
- package/dist/src/server/pending-request-map.d.ts.map +1 -0
- package/dist/src/server/pending-request-map.js +69 -0
- package/dist/src/server/pending-request-map.js.map +1 -0
- package/dist/src/server/pending-request-map.test.d.ts +2 -0
- package/dist/src/server/pending-request-map.test.d.ts.map +1 -0
- package/dist/src/server/pending-request-map.test.js +192 -0
- package/dist/src/server/pending-request-map.test.js.map +1 -0
- package/dist/src/server/plugin-detection.test.d.ts +7 -0
- package/dist/src/server/plugin-detection.test.d.ts.map +1 -0
- package/dist/src/server/plugin-detection.test.js +154 -0
- package/dist/src/server/plugin-detection.test.js.map +1 -0
- package/dist/src/server/studio-bridge-server.d.ts +44 -7
- package/dist/src/server/studio-bridge-server.d.ts.map +1 -1
- package/dist/src/server/studio-bridge-server.js +341 -91
- package/dist/src/server/studio-bridge-server.js.map +1 -1
- package/dist/src/server/studio-bridge-server.test.js +231 -207
- package/dist/src/server/studio-bridge-server.test.js.map +1 -1
- package/dist/src/server/web-socket-protocol-basic.test.d.ts +2 -0
- package/dist/src/server/web-socket-protocol-basic.test.d.ts.map +1 -0
- package/dist/src/server/web-socket-protocol-basic.test.js +98 -0
- package/dist/src/server/web-socket-protocol-basic.test.js.map +1 -0
- package/dist/src/server/web-socket-protocol.d.ts +218 -20
- package/dist/src/server/web-socket-protocol.d.ts.map +1 -1
- package/dist/src/server/web-socket-protocol.js +346 -20
- package/dist/src/server/web-socket-protocol.js.map +1 -1
- package/dist/src/server/web-socket-protocol.test.js +572 -146
- package/dist/src/server/web-socket-protocol.test.js.map +1 -1
- package/dist/src/test/e2e/hand-off.test.d.ts +9 -0
- package/dist/src/test/e2e/hand-off.test.d.ts.map +1 -0
- package/dist/src/test/e2e/hand-off.test.js +274 -0
- package/dist/src/test/e2e/hand-off.test.js.map +1 -0
- package/dist/src/test/e2e/persistent-session.test.d.ts +11 -0
- package/dist/src/test/e2e/persistent-session.test.d.ts.map +1 -0
- package/dist/src/test/e2e/persistent-session.test.js +367 -0
- package/dist/src/test/e2e/persistent-session.test.js.map +1 -0
- package/dist/src/test/e2e/split-server.test.d.ts +14 -0
- package/dist/src/test/e2e/split-server.test.d.ts.map +1 -0
- package/dist/src/test/e2e/split-server.test.js +230 -0
- package/dist/src/test/e2e/split-server.test.js.map +1 -0
- package/dist/src/test/helpers/mock-plugin-client.d.ts +69 -0
- package/dist/src/test/helpers/mock-plugin-client.d.ts.map +1 -0
- package/dist/src/test/helpers/mock-plugin-client.js +213 -0
- package/dist/src/test/helpers/mock-plugin-client.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docker/.dockerignore +2 -0
- package/docker/Dockerfile +113 -0
- package/docker/docker-compose.yml +20 -0
- package/docker/entrypoint.sh +19 -0
- package/package.json +8 -6
- package/src/bridge/bridge-connection-remote.test.ts +189 -0
- package/src/bridge/bridge-connection.test.ts +1076 -0
- package/src/bridge/bridge-connection.ts +718 -0
- package/src/bridge/bridge-session.test.ts +336 -0
- package/src/bridge/bridge-session.ts +365 -0
- package/src/bridge/index.ts +42 -0
- package/src/bridge/internal/__tests__/failover-crash.test.ts +191 -0
- package/src/bridge/internal/__tests__/failover-graceful.test.ts +268 -0
- package/src/bridge/internal/__tests__/failover-inflight.test.ts +329 -0
- package/src/bridge/internal/__tests__/host-client-integration.test.ts +387 -0
- package/src/bridge/internal/bridge-client.test.ts +399 -0
- package/src/bridge/internal/bridge-client.ts +434 -0
- package/src/bridge/internal/bridge-host.test.ts +501 -0
- package/src/bridge/internal/bridge-host.ts +531 -0
- package/src/bridge/internal/environment-detection.test.ts +180 -0
- package/src/bridge/internal/environment-detection.ts +119 -0
- package/src/bridge/internal/hand-off.test.ts +408 -0
- package/src/bridge/internal/hand-off.ts +275 -0
- package/src/bridge/internal/health-endpoint.test.ts +147 -0
- package/src/bridge/internal/health-endpoint.ts +100 -0
- package/src/bridge/internal/host-protocol.test.ts +415 -0
- package/src/bridge/internal/host-protocol.ts +255 -0
- package/src/bridge/internal/session-tracker.test.ts +535 -0
- package/src/bridge/internal/session-tracker.ts +198 -0
- package/src/bridge/internal/transport-client.test.ts +241 -0
- package/src/bridge/internal/transport-client.ts +194 -0
- package/src/bridge/internal/transport-server.test.ts +220 -0
- package/src/bridge/internal/transport-server.ts +242 -0
- package/src/bridge/types.ts +161 -0
- package/src/cli/adapters/cli-command-adapter-handler.test.ts +318 -0
- package/src/cli/adapters/cli-command-adapter.test.ts +221 -0
- package/src/cli/adapters/cli-command-adapter.ts +342 -0
- package/src/cli/adapters/group-builder.test.ts +146 -0
- package/src/cli/adapters/group-builder.ts +81 -0
- package/src/cli/adapters/help-formatter.test.ts +97 -0
- package/src/cli/adapters/help-formatter.ts +86 -0
- package/src/cli/adapters/target-resolver.test.ts +222 -0
- package/src/cli/adapters/target-resolver.ts +144 -0
- package/src/cli/args/global-args.ts +2 -0
- package/src/cli/cli.ts +100 -21
- package/src/cli/resolve-script-content.ts +36 -0
- package/src/cli/resolve-session.test.ts +141 -0
- package/src/cli/resolve-session.ts +66 -0
- package/src/cli/script-executor.ts +22 -4
- package/src/cli/types.ts +11 -0
- package/src/commands/connect.test.ts +61 -0
- package/src/commands/connect.ts +32 -0
- package/src/commands/console/exec/exec.test.ts +258 -0
- package/src/commands/console/exec/exec.ts +130 -0
- package/src/commands/console/exec/execute.luau +202 -0
- package/src/commands/console/logs/logs.test.ts +138 -0
- package/src/commands/console/logs/logs.ts +115 -0
- package/src/commands/console/logs/query-logs.luau +76 -0
- package/src/commands/disconnect.test.ts +21 -0
- package/src/commands/disconnect.ts +12 -0
- package/src/commands/explorer/query/query-data-model.luau +206 -0
- package/src/commands/explorer/query/query.test.ts +297 -0
- package/src/commands/explorer/query/query.ts +157 -0
- package/src/commands/formatters.test.ts +237 -0
- package/src/commands/framework/action-loader.test.ts +118 -0
- package/src/commands/framework/action-loader.ts +65 -0
- package/src/commands/framework/arg-builder.test.ts +298 -0
- package/src/commands/framework/arg-builder.ts +203 -0
- package/src/commands/framework/command-registry.test.ts +204 -0
- package/src/commands/framework/command-registry.ts +51 -0
- package/src/commands/framework/define-command.test.ts +161 -0
- package/src/commands/framework/define-command.ts +114 -0
- package/src/commands/framework/index.ts +33 -0
- package/src/commands/index.ts +72 -0
- package/src/commands/linux/inject-credentials/inject-credentials.ts +118 -0
- package/src/commands/linux/setup/setup.ts +145 -0
- package/src/commands/linux/status/status.ts +180 -0
- package/src/commands/plugin/install/install.ts +31 -0
- package/src/commands/plugin/uninstall/uninstall.ts +54 -0
- package/src/commands/process/close/close.ts +52 -0
- package/src/commands/process/format-state.ts +21 -0
- package/src/commands/process/info/info.test.ts +76 -0
- package/src/commands/process/info/info.ts +54 -0
- package/src/commands/process/info/query-state.luau +48 -0
- package/src/commands/process/launch/launch.test.ts +65 -0
- package/src/commands/process/launch/launch.ts +45 -0
- package/src/commands/process/list/list.test.ts +82 -0
- package/src/commands/process/list/list.ts +75 -0
- package/src/commands/process/run/run.ts +98 -0
- package/src/commands/rgba-to-png.ts +98 -0
- package/src/commands/serve/serve.test.ts +139 -0
- package/src/commands/serve/serve.ts +161 -0
- package/src/commands/viewport/screenshot/capture-screenshot.luau +247 -0
- package/src/commands/viewport/screenshot/screenshot.test.ts +181 -0
- package/src/commands/viewport/screenshot/screenshot.ts +71 -0
- package/src/docker/docker-delegator.test.ts +159 -0
- package/src/docker/docker-delegator.ts +240 -0
- package/src/index.test.ts +58 -0
- package/src/index.ts +104 -3
- package/src/linux/README.md +130 -0
- package/src/linux/index.ts +25 -0
- package/src/linux/linux-config.test.ts +66 -0
- package/src/linux/linux-config.ts +102 -0
- package/src/linux/linux-credential-writer.ts +421 -0
- package/src/linux/linux-display-manager.ts +106 -0
- package/src/linux/linux-env-guard.test.ts +62 -0
- package/src/linux/linux-env-guard.ts +38 -0
- package/src/linux/linux-fflags.test.ts +78 -0
- package/src/linux/linux-fflags.ts +48 -0
- package/src/linux/linux-prerequisites.ts +152 -0
- package/src/linux/linux-shader-patcher.test.ts +76 -0
- package/src/linux/linux-shader-patcher.ts +56 -0
- package/src/linux/linux-studio-installer.ts +113 -0
- package/src/linux/linux-studio-launcher.ts +90 -0
- package/src/linux/linux-version-resolver.ts +74 -0
- package/src/linux/linux-wine-env.test.ts +56 -0
- package/src/linux/linux-wine-env.ts +38 -0
- package/src/linux/write-cred.c +48 -0
- package/src/plugin/persistent-plugin-installer.test.ts +168 -0
- package/src/plugin/persistent-plugin-installer.ts +90 -0
- package/src/plugin/plugin-discovery.test.ts +70 -0
- package/src/plugin/plugin-discovery.ts +21 -0
- package/src/plugin/plugin-injector.ts +1 -1
- package/src/process/studio-process-manager.test.ts +22 -1
- package/src/process/studio-process-manager.ts +57 -18
- package/src/server/action-dispatcher.test.ts +240 -0
- package/src/server/action-dispatcher.ts +89 -0
- package/src/server/index.ts +0 -3
- package/src/server/pending-request-map.test.ts +261 -0
- package/src/server/pending-request-map.ts +87 -0
- package/src/server/plugin-detection.test.ts +195 -0
- package/src/server/studio-bridge-server.test.ts +321 -283
- package/src/server/studio-bridge-server.ts +469 -111
- package/src/server/web-socket-protocol-basic.test.ts +131 -0
- package/src/server/web-socket-protocol.test.ts +658 -159
- package/src/server/web-socket-protocol.ts +668 -58
- package/src/test/e2e/hand-off.test.ts +338 -0
- package/src/test/e2e/persistent-session.test.ts +442 -0
- package/src/test/e2e/split-server.test.ts +290 -0
- package/src/test/helpers/mock-plugin-client.ts +276 -0
- package/templates/studio-bridge-plugin/src/Shared/ActionRouter.luau +245 -0
- package/templates/studio-bridge-plugin/src/Shared/DiscoveryStateMachine.luau +203 -0
- package/templates/studio-bridge-plugin/src/Shared/MessageBuffer.luau +144 -0
- package/templates/studio-bridge-plugin/src/Shared/Protocol.luau +132 -0
- package/templates/studio-bridge-plugin/src/StudioBridgePlugin.server.lua +364 -133
- package/templates/studio-bridge-plugin/src/Vendor/png.luau +1247 -0
- package/templates/studio-bridge-plugin-test/test/actions.test.luau +580 -0
- package/templates/studio-bridge-plugin-test/test/discovery.test.luau +622 -0
- package/templates/studio-bridge-plugin-test/test/execute-handler.test.luau +406 -0
- package/templates/studio-bridge-plugin-test/test/hash-lifecycle.test.luau +814 -0
- package/templates/studio-bridge-plugin-test/test/integration.test.luau +1020 -0
- package/templates/studio-bridge-plugin-test/test/new-actions.test.luau +339 -0
- package/templates/studio-bridge-plugin-test/test/plugin-entry.test.luau +493 -0
- package/templates/studio-bridge-plugin-test/test/protocol.test.luau +506 -0
- package/templates/studio-bridge-plugin-test/test/roblox-mocks.luau +108 -0
- package/templates/studio-bridge-plugin-test/test/test-runner.luau +112 -0
- package/dist/src/cli/commands/exec-command.d.ts +0 -15
- package/dist/src/cli/commands/exec-command.d.ts.map +0 -1
- package/dist/src/cli/commands/exec-command.js +0 -35
- package/dist/src/cli/commands/exec-command.js.map +0 -1
- package/dist/src/cli/commands/run-command.d.ts +0 -15
- package/dist/src/cli/commands/run-command.d.ts.map +0 -1
- package/dist/src/cli/commands/run-command.js +0 -47
- package/dist/src/cli/commands/run-command.js.map +0 -1
- package/dist/src/cli/commands/terminal/terminal-command.d.ts +0 -17
- package/dist/src/cli/commands/terminal/terminal-command.d.ts.map +0 -1
- package/dist/src/cli/commands/terminal/terminal-command.js +0 -41
- package/dist/src/cli/commands/terminal/terminal-command.js.map +0 -1
- package/dist/src/cli/commands/terminal/terminal-editor.d.ts +0 -43
- package/dist/src/cli/commands/terminal/terminal-editor.d.ts.map +0 -1
- package/dist/src/cli/commands/terminal/terminal-editor.js +0 -430
- package/dist/src/cli/commands/terminal/terminal-editor.js.map +0 -1
- package/dist/src/cli/commands/terminal/terminal-mode.d.ts +0 -13
- package/dist/src/cli/commands/terminal/terminal-mode.d.ts.map +0 -1
- package/dist/src/cli/commands/terminal/terminal-mode.js +0 -141
- package/dist/src/cli/commands/terminal/terminal-mode.js.map +0 -1
- package/dist/src/server/web-socket-protocol.smoke.test.d.ts +0 -6
- package/dist/src/server/web-socket-protocol.smoke.test.d.ts.map +0 -1
- package/dist/src/server/web-socket-protocol.smoke.test.js +0 -196
- package/dist/src/server/web-socket-protocol.smoke.test.js.map +0 -1
- package/src/cli/commands/exec-command.ts +0 -48
- package/src/cli/commands/run-command.ts +0 -63
- package/src/cli/commands/terminal/terminal-command.ts +0 -54
- package/src/cli/commands/terminal/terminal-editor.ts +0 -500
- package/src/cli/commands/terminal/terminal-mode.ts +0 -184
- package/src/server/web-socket-protocol.smoke.test.ts +0 -255
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
--[[
|
|
2
|
+
Action dispatch module for routing incoming protocol messages to handlers.
|
|
3
|
+
|
|
4
|
+
Maintains a registry of handler functions keyed by message type. When a
|
|
5
|
+
message is dispatched, the router looks up the handler, calls it with
|
|
6
|
+
(payload, requestId, sessionId), and constructs a response message if
|
|
7
|
+
the handler returns a payload table.
|
|
8
|
+
|
|
9
|
+
Error handling:
|
|
10
|
+
- Unknown message type: returns error response with code UNKNOWN_REQUEST
|
|
11
|
+
- Handler throws: returns error response with code INTERNAL_ERROR
|
|
12
|
+
- Handler returns nil: no response is generated
|
|
13
|
+
|
|
14
|
+
No Roblox APIs. Pure logic, testable under Lune.
|
|
15
|
+
]]
|
|
16
|
+
|
|
17
|
+
local ActionRouter = {}
|
|
18
|
+
ActionRouter.__index = ActionRouter
|
|
19
|
+
|
|
20
|
+
-- ---------------------------------------------------------------------------
|
|
21
|
+
-- Constructor
|
|
22
|
+
-- ---------------------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
function ActionRouter.new()
|
|
25
|
+
local self = setmetatable({
|
|
26
|
+
_handlers = {} :: {
|
|
27
|
+
[string]: (payload: { [string]: any }, requestId: string, sessionId: string) -> { [string]: any }?,
|
|
28
|
+
},
|
|
29
|
+
_responseTypes = {} :: { [string]: string },
|
|
30
|
+
_actions = {} :: { [string]: { module: any, hash: string, handlerNames: { string } } },
|
|
31
|
+
}, ActionRouter)
|
|
32
|
+
return self
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
-- ---------------------------------------------------------------------------
|
|
36
|
+
-- Register a handler for a message type
|
|
37
|
+
-- ---------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
function ActionRouter.register(
|
|
40
|
+
self: any,
|
|
41
|
+
messageType: string,
|
|
42
|
+
handler: (
|
|
43
|
+
payload: { [string]: any },
|
|
44
|
+
requestId: string,
|
|
45
|
+
sessionId: string
|
|
46
|
+
) -> { [string]: any }?
|
|
47
|
+
)
|
|
48
|
+
self._handlers[messageType] = handler
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
-- ---------------------------------------------------------------------------
|
|
52
|
+
-- Dispatch an incoming message
|
|
53
|
+
-- ---------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
--[[
|
|
56
|
+
Dispatch an incoming message to the appropriate handler.
|
|
57
|
+
|
|
58
|
+
@param message Table with fields: type, sessionId, payload, requestId?
|
|
59
|
+
@return A response message table, or nil if the handler returns nil.
|
|
60
|
+
]]
|
|
61
|
+
function ActionRouter.dispatch(
|
|
62
|
+
self: any,
|
|
63
|
+
message: {
|
|
64
|
+
type: string,
|
|
65
|
+
sessionId: string,
|
|
66
|
+
payload: { [string]: any },
|
|
67
|
+
requestId: string?,
|
|
68
|
+
}
|
|
69
|
+
): { [string]: any }?
|
|
70
|
+
local handler = self._handlers[message.type]
|
|
71
|
+
|
|
72
|
+
if handler == nil then
|
|
73
|
+
return {
|
|
74
|
+
type = "error",
|
|
75
|
+
sessionId = message.sessionId,
|
|
76
|
+
requestId = message.requestId,
|
|
77
|
+
payload = {
|
|
78
|
+
code = "UNKNOWN_REQUEST",
|
|
79
|
+
message = "Unknown message type: " .. tostring(message.type),
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
local requestId = message.requestId or ""
|
|
85
|
+
local ok, result = pcall(handler, message.payload, requestId, message.sessionId)
|
|
86
|
+
|
|
87
|
+
if not ok then
|
|
88
|
+
return {
|
|
89
|
+
type = "error",
|
|
90
|
+
sessionId = message.sessionId,
|
|
91
|
+
requestId = message.requestId,
|
|
92
|
+
payload = {
|
|
93
|
+
code = "INTERNAL_ERROR",
|
|
94
|
+
message = "Handler error: " .. tostring(result),
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
if result == nil then
|
|
100
|
+
return nil
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
-- Construct response with the appropriate response type
|
|
104
|
+
local responseType = self._responseTypes[message.type] or (message.type .. "Result")
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
type = responseType,
|
|
108
|
+
sessionId = message.sessionId,
|
|
109
|
+
requestId = message.requestId,
|
|
110
|
+
payload = result,
|
|
111
|
+
}
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
-- ---------------------------------------------------------------------------
|
|
115
|
+
-- Set a custom response type for a message type
|
|
116
|
+
-- ---------------------------------------------------------------------------
|
|
117
|
+
|
|
118
|
+
function ActionRouter.setResponseType(self: any, messageType: string, responseType: string)
|
|
119
|
+
self._responseTypes[messageType] = responseType
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
-- ---------------------------------------------------------------------------
|
|
123
|
+
-- Register a dynamic action from source code
|
|
124
|
+
-- ---------------------------------------------------------------------------
|
|
125
|
+
|
|
126
|
+
--[[
|
|
127
|
+
Dynamically register an action from Luau source code received over the wire.
|
|
128
|
+
|
|
129
|
+
The source is expected to be a module that returns a table with a `register`
|
|
130
|
+
function: `function(router, sendMessage?, logBuffer?)`. This mirrors the
|
|
131
|
+
static action module convention.
|
|
132
|
+
|
|
133
|
+
If the source defines a simple handler function instead, it is registered
|
|
134
|
+
directly as the handler for the given action name.
|
|
135
|
+
|
|
136
|
+
@param name The action name (used as the message type if not registered otherwise).
|
|
137
|
+
@param source The Luau source code string.
|
|
138
|
+
@param sendMessage Optional callback for actions that send their own responses.
|
|
139
|
+
@param logBuffer Optional log buffer instance.
|
|
140
|
+
@param responseType Optional response type override.
|
|
141
|
+
@param hash Optional content hash for skip-on-same-hash optimization.
|
|
142
|
+
@return success, error?
|
|
143
|
+
]]
|
|
144
|
+
function ActionRouter.registerAction(
|
|
145
|
+
self: any,
|
|
146
|
+
name: string,
|
|
147
|
+
source: string,
|
|
148
|
+
sendMessage: ((msg: { [string]: any }) -> ())?,
|
|
149
|
+
logBuffer: any?,
|
|
150
|
+
responseType: string?,
|
|
151
|
+
hash: string?
|
|
152
|
+
): (boolean, string?)
|
|
153
|
+
-- Hash-based skip: if the same hash is already installed, skip re-registration
|
|
154
|
+
if hash and self._actions[name] and self._actions[name].hash == hash then
|
|
155
|
+
return true, nil
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
-- If an old module exists, tear it down and remove its handlers
|
|
159
|
+
local oldAction = self._actions[name]
|
|
160
|
+
if oldAction then
|
|
161
|
+
if type(oldAction.module.teardown) == "function" then
|
|
162
|
+
pcall(oldAction.module.teardown)
|
|
163
|
+
end
|
|
164
|
+
for _, handlerName in oldAction.handlerNames do
|
|
165
|
+
self._handlers[handlerName] = nil
|
|
166
|
+
self._responseTypes[handlerName] = nil
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
-- Snapshot handler keys before registration
|
|
171
|
+
local beforeHandlers = {}
|
|
172
|
+
for k, _ in self._handlers do
|
|
173
|
+
beforeHandlers[k] = true
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
-- Load the source code
|
|
177
|
+
local loadOk, moduleOrErr = pcall(function()
|
|
178
|
+
return (loadstring :: any)(source, `@action/{name}`)
|
|
179
|
+
end)
|
|
180
|
+
|
|
181
|
+
if not loadOk or not moduleOrErr then
|
|
182
|
+
return false, `Failed to load action source: {moduleOrErr or "loadstring returned nil"}`
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
-- Execute the loaded chunk to get the module table
|
|
186
|
+
local execOk, moduleTable = pcall(moduleOrErr)
|
|
187
|
+
if not execOk then
|
|
188
|
+
return false, `Failed to execute action module: {moduleTable}`
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
-- If the module has a register function, call it
|
|
192
|
+
if type(moduleTable) == "table" and type(moduleTable.register) == "function" then
|
|
193
|
+
local regOk, regErr = pcall(moduleTable.register, self, sendMessage, logBuffer)
|
|
194
|
+
if not regOk then
|
|
195
|
+
return false, `register() failed: {regErr}`
|
|
196
|
+
end
|
|
197
|
+
elseif type(moduleTable) == "function" then
|
|
198
|
+
-- Simple handler function
|
|
199
|
+
self:register(name, moduleTable)
|
|
200
|
+
else
|
|
201
|
+
return false, `Action module must return a table with .register() or a function`
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
-- Set custom response type if provided
|
|
205
|
+
if responseType then
|
|
206
|
+
self._responseTypes[name] = responseType
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
-- Diff handler keys to find newly registered handler names
|
|
210
|
+
local registeredNames = {}
|
|
211
|
+
for k, _ in self._handlers do
|
|
212
|
+
if not beforeHandlers[k] then
|
|
213
|
+
table.insert(registeredNames, k)
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
-- Store in _actions for hash tracking
|
|
218
|
+
if hash then
|
|
219
|
+
self._actions[name] = {
|
|
220
|
+
module = moduleTable,
|
|
221
|
+
hash = hash,
|
|
222
|
+
handlerNames = registeredNames,
|
|
223
|
+
}
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
return true, nil
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
-- ---------------------------------------------------------------------------
|
|
230
|
+
-- Get installed actions with their hashes
|
|
231
|
+
-- ---------------------------------------------------------------------------
|
|
232
|
+
|
|
233
|
+
--[[
|
|
234
|
+
Returns a map of action name -> content hash for all installed actions.
|
|
235
|
+
Used by the syncActions protocol to determine which actions need updating.
|
|
236
|
+
]]
|
|
237
|
+
function ActionRouter.getInstalledActions(self: any): { [string]: string }
|
|
238
|
+
local result = {}
|
|
239
|
+
for name, info in self._actions do
|
|
240
|
+
result[name] = info.hash
|
|
241
|
+
end
|
|
242
|
+
return result
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
return ActionRouter
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
--[[
|
|
2
|
+
Pure state machine for plugin discovery and connection lifecycle.
|
|
3
|
+
|
|
4
|
+
Manages the states: idle, searching, connecting, connected.
|
|
5
|
+
All external I/O is performed via injected callbacks.
|
|
6
|
+
|
|
7
|
+
The caller drives the loop by calling pollAsync(remainingExecTimeSec)
|
|
8
|
+
repeatedly. The remaining execution time threads through all async
|
|
9
|
+
operations so the entire poll cycle completes within a predictable
|
|
10
|
+
time budget.
|
|
11
|
+
]]
|
|
12
|
+
|
|
13
|
+
local DiscoveryStateMachine = {}
|
|
14
|
+
DiscoveryStateMachine.__index = DiscoveryStateMachine
|
|
15
|
+
|
|
16
|
+
-- ---------------------------------------------------------------------------
|
|
17
|
+
-- Default configuration
|
|
18
|
+
-- ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
local DEFAULT_CONFIG = {
|
|
21
|
+
portRange = { min = 38741, max = 38744 },
|
|
22
|
+
pollIntervalSec = 2,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
-- ---------------------------------------------------------------------------
|
|
26
|
+
-- Constructor
|
|
27
|
+
-- ---------------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
function DiscoveryStateMachine.new(
|
|
30
|
+
config: {
|
|
31
|
+
portRange: { min: number, max: number }?,
|
|
32
|
+
pollIntervalSec: number?,
|
|
33
|
+
}?,
|
|
34
|
+
callbacks: {
|
|
35
|
+
scanPortsAsync: (ports: { number }, timeoutSec: number) -> (number?, string?),
|
|
36
|
+
connectWebSocket: (url: string) -> (boolean, any?),
|
|
37
|
+
onStateChange: (oldState: string, newState: string) -> (),
|
|
38
|
+
onConnected: (connection: any, port: number) -> (),
|
|
39
|
+
onDisconnected: (reason: string?) -> (),
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
local resolvedConfig = {}
|
|
43
|
+
local userConfig = config or {}
|
|
44
|
+
for key, default in DEFAULT_CONFIG do
|
|
45
|
+
if key == "portRange" then
|
|
46
|
+
local userRange = (userConfig :: any).portRange
|
|
47
|
+
if userRange then
|
|
48
|
+
resolvedConfig.portRange = {
|
|
49
|
+
min = userRange.min or default.min,
|
|
50
|
+
max = userRange.max or default.max,
|
|
51
|
+
}
|
|
52
|
+
else
|
|
53
|
+
resolvedConfig.portRange = { min = default.min, max = default.max }
|
|
54
|
+
end
|
|
55
|
+
else
|
|
56
|
+
resolvedConfig[key] = (userConfig :: any)[key] or default
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
local self = setmetatable({
|
|
61
|
+
_config = resolvedConfig,
|
|
62
|
+
_callbacks = callbacks,
|
|
63
|
+
_state = "idle" :: string,
|
|
64
|
+
_nextPollAt = 0, -- os.clock() time for next scan
|
|
65
|
+
_connection = nil :: any?,
|
|
66
|
+
}, DiscoveryStateMachine)
|
|
67
|
+
|
|
68
|
+
return self
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
-- ---------------------------------------------------------------------------
|
|
72
|
+
-- State accessors
|
|
73
|
+
-- ---------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
function DiscoveryStateMachine.getState(self: any): string
|
|
76
|
+
return self._state
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
-- ---------------------------------------------------------------------------
|
|
80
|
+
-- Internal state transition
|
|
81
|
+
-- ---------------------------------------------------------------------------
|
|
82
|
+
|
|
83
|
+
function DiscoveryStateMachine._transitionTo(self: any, newState: string)
|
|
84
|
+
local oldState = self._state
|
|
85
|
+
if oldState == newState then
|
|
86
|
+
return
|
|
87
|
+
end
|
|
88
|
+
self._state = newState
|
|
89
|
+
self._callbacks.onStateChange(oldState, newState)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
-- ---------------------------------------------------------------------------
|
|
93
|
+
-- Public methods
|
|
94
|
+
-- ---------------------------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
function DiscoveryStateMachine.start(self: any)
|
|
97
|
+
if self._state ~= "idle" then
|
|
98
|
+
return
|
|
99
|
+
end
|
|
100
|
+
self._nextPollAt = 0
|
|
101
|
+
self:_transitionTo("searching")
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
function DiscoveryStateMachine.stop(self: any)
|
|
105
|
+
if self._state == "idle" then
|
|
106
|
+
return
|
|
107
|
+
end
|
|
108
|
+
local wasConnected = self._state == "connected"
|
|
109
|
+
self._connection = nil
|
|
110
|
+
self._nextPollAt = 0
|
|
111
|
+
self:_transitionTo("idle")
|
|
112
|
+
if wasConnected then
|
|
113
|
+
self._callbacks.onDisconnected("stopped")
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
function DiscoveryStateMachine.onDisconnect(self: any, reason: string?)
|
|
118
|
+
if self._state ~= "connected" then
|
|
119
|
+
return
|
|
120
|
+
end
|
|
121
|
+
self._connection = nil
|
|
122
|
+
self._nextPollAt = 0
|
|
123
|
+
self._callbacks.onDisconnected(reason)
|
|
124
|
+
self:_transitionTo("searching")
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
--[[
|
|
128
|
+
Run one poll cycle. remainingExecTimeSec is the number of seconds this
|
|
129
|
+
call is allowed to spend on async work (port scanning, connecting).
|
|
130
|
+
The caller subtracts elapsed time before each call so the entire loop
|
|
131
|
+
iteration stays within its time budget.
|
|
132
|
+
|
|
133
|
+
Returns immediately if not time to scan yet, or if in idle/connected state.
|
|
134
|
+
May yield during port scanning and WebSocket connection.
|
|
135
|
+
]]
|
|
136
|
+
function DiscoveryStateMachine.pollAsync(self: any, remainingExecTimeSec: number?)
|
|
137
|
+
if self._state == "idle" or self._state == "connected" then
|
|
138
|
+
return
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
local now = os.clock()
|
|
142
|
+
local timeAvailable = remainingExecTimeSec or 10
|
|
143
|
+
|
|
144
|
+
if self._state == "searching" then
|
|
145
|
+
if now < self._nextPollAt then
|
|
146
|
+
return
|
|
147
|
+
end
|
|
148
|
+
if timeAvailable <= 0 then
|
|
149
|
+
return
|
|
150
|
+
end
|
|
151
|
+
self:_scanPortsAsync(timeAvailable)
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
-- ---------------------------------------------------------------------------
|
|
156
|
+
-- Internal: port scanning
|
|
157
|
+
-- ---------------------------------------------------------------------------
|
|
158
|
+
|
|
159
|
+
function DiscoveryStateMachine._scanPortsAsync(self: any, timeoutSec: number)
|
|
160
|
+
local portMin = self._config.portRange.min
|
|
161
|
+
local portMax = self._config.portRange.max
|
|
162
|
+
|
|
163
|
+
-- scanPortsAsync probes every port in parallel and returns whichever
|
|
164
|
+
-- responds first, so the order is irrelevant. (An earlier version
|
|
165
|
+
-- rotated the starting port via self._currentPort, but the field was
|
|
166
|
+
-- never advanced after a failed scan, making the rotation a no-op.)
|
|
167
|
+
local ports = {}
|
|
168
|
+
for port = portMin, portMax do
|
|
169
|
+
table.insert(ports, port)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
local foundPort, foundBody = self._callbacks.scanPortsAsync(ports, timeoutSec)
|
|
173
|
+
|
|
174
|
+
if foundPort then
|
|
175
|
+
self:_transitionTo("connecting")
|
|
176
|
+
self:_attemptConnect(foundPort, foundBody)
|
|
177
|
+
return
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
-- All ports failed. Schedule next scan at the regular poll interval.
|
|
181
|
+
self._nextPollAt = os.clock() + self._config.pollIntervalSec
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
-- ---------------------------------------------------------------------------
|
|
185
|
+
-- Internal: WebSocket connection attempt
|
|
186
|
+
-- ---------------------------------------------------------------------------
|
|
187
|
+
|
|
188
|
+
function DiscoveryStateMachine._attemptConnect(self: any, port: number, _healthResponse: string?)
|
|
189
|
+
local wsUrl = "ws://localhost:" .. tostring(port) .. "/plugin"
|
|
190
|
+
local success, connection = self._callbacks.connectWebSocket(wsUrl)
|
|
191
|
+
|
|
192
|
+
if success and connection then
|
|
193
|
+
self._connection = connection
|
|
194
|
+
self._nextPollAt = 0
|
|
195
|
+
self:_transitionTo("connected")
|
|
196
|
+
self._callbacks.onConnected(connection, port)
|
|
197
|
+
else
|
|
198
|
+
self._nextPollAt = os.clock() + self._config.pollIntervalSec
|
|
199
|
+
self:_transitionTo("searching")
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
return DiscoveryStateMachine
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
--[[
|
|
2
|
+
Fixed-capacity ring buffer for storing log entries.
|
|
3
|
+
|
|
4
|
+
Entries are added via push(). When the buffer reaches capacity, new entries
|
|
5
|
+
overwrite the oldest. Retrieval via get() supports both "head" (oldest first)
|
|
6
|
+
and "tail" (newest first) directions with an optional count limit.
|
|
7
|
+
|
|
8
|
+
No Roblox APIs. Pure logic, testable under Lune.
|
|
9
|
+
]]
|
|
10
|
+
|
|
11
|
+
local MessageBuffer = {}
|
|
12
|
+
MessageBuffer.__index = MessageBuffer
|
|
13
|
+
|
|
14
|
+
-- ---------------------------------------------------------------------------
|
|
15
|
+
-- Constructor
|
|
16
|
+
-- ---------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
--[[
|
|
19
|
+
Create a new MessageBuffer with the given capacity.
|
|
20
|
+
|
|
21
|
+
@param capacity Maximum number of entries (default 1000).
|
|
22
|
+
]]
|
|
23
|
+
function MessageBuffer.new(capacity: number?)
|
|
24
|
+
local cap = capacity or 1000
|
|
25
|
+
local self = setmetatable({
|
|
26
|
+
_capacity = cap,
|
|
27
|
+
_buffer = {} :: { { level: string, body: string, timestamp: number } },
|
|
28
|
+
_head = 1, -- next write position (1-indexed)
|
|
29
|
+
_count = 0, -- number of entries currently stored
|
|
30
|
+
}, MessageBuffer)
|
|
31
|
+
return self
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
-- ---------------------------------------------------------------------------
|
|
35
|
+
-- Push an entry into the buffer
|
|
36
|
+
-- ---------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
--[[
|
|
39
|
+
Add an entry to the buffer. Overwrites the oldest entry if at capacity.
|
|
40
|
+
|
|
41
|
+
@param entry Table with level, body, timestamp fields.
|
|
42
|
+
]]
|
|
43
|
+
function MessageBuffer.push(
|
|
44
|
+
self: any,
|
|
45
|
+
entry: {
|
|
46
|
+
level: string,
|
|
47
|
+
body: string,
|
|
48
|
+
timestamp: number,
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
self._buffer[self._head] = entry
|
|
52
|
+
self._head = (self._head % self._capacity) + 1
|
|
53
|
+
if self._count < self._capacity then
|
|
54
|
+
self._count = self._count + 1
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
-- ---------------------------------------------------------------------------
|
|
59
|
+
-- Get entries from the buffer
|
|
60
|
+
-- ---------------------------------------------------------------------------
|
|
61
|
+
|
|
62
|
+
--[[
|
|
63
|
+
Retrieve entries from the buffer.
|
|
64
|
+
|
|
65
|
+
@param direction "head" for oldest first, "tail" for newest first (default "tail").
|
|
66
|
+
@param count Maximum number of entries to return (default: all).
|
|
67
|
+
@return Table with entries, total, and bufferCapacity.
|
|
68
|
+
]]
|
|
69
|
+
function MessageBuffer.get(
|
|
70
|
+
self: any,
|
|
71
|
+
direction: string?,
|
|
72
|
+
count: number?
|
|
73
|
+
): {
|
|
74
|
+
entries: { { level: string, body: string, timestamp: number } },
|
|
75
|
+
total: number,
|
|
76
|
+
bufferCapacity: number,
|
|
77
|
+
}
|
|
78
|
+
local dir = direction or "tail"
|
|
79
|
+
local all = self:_toArray()
|
|
80
|
+
local maxCount = count or #all
|
|
81
|
+
local entries = {}
|
|
82
|
+
|
|
83
|
+
if dir == "head" then
|
|
84
|
+
-- Oldest first, take from the start
|
|
85
|
+
for i = 1, math.min(maxCount, #all) do
|
|
86
|
+
table.insert(entries, all[i])
|
|
87
|
+
end
|
|
88
|
+
else
|
|
89
|
+
-- Newest first (tail), take from the end
|
|
90
|
+
local start = math.max(1, #all - maxCount + 1)
|
|
91
|
+
for i = start, #all do
|
|
92
|
+
table.insert(entries, all[i])
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
entries = entries,
|
|
98
|
+
total = self._count,
|
|
99
|
+
bufferCapacity = self._capacity,
|
|
100
|
+
}
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
-- ---------------------------------------------------------------------------
|
|
104
|
+
-- Clear the buffer
|
|
105
|
+
-- ---------------------------------------------------------------------------
|
|
106
|
+
|
|
107
|
+
function MessageBuffer.clear(self: any)
|
|
108
|
+
self._buffer = {}
|
|
109
|
+
self._head = 1
|
|
110
|
+
self._count = 0
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
-- ---------------------------------------------------------------------------
|
|
114
|
+
-- Get the number of entries
|
|
115
|
+
-- ---------------------------------------------------------------------------
|
|
116
|
+
|
|
117
|
+
function MessageBuffer.size(self: any): number
|
|
118
|
+
return self._count
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
-- ---------------------------------------------------------------------------
|
|
122
|
+
-- Internal: convert ring buffer to a chronological array
|
|
123
|
+
-- ---------------------------------------------------------------------------
|
|
124
|
+
|
|
125
|
+
function MessageBuffer._toArray(self: any): { { level: string, body: string, timestamp: number } }
|
|
126
|
+
local result = {}
|
|
127
|
+
if self._count < self._capacity then
|
|
128
|
+
-- Buffer not full: entries are at indices 1..count
|
|
129
|
+
for i = 1, self._count do
|
|
130
|
+
table.insert(result, self._buffer[i])
|
|
131
|
+
end
|
|
132
|
+
else
|
|
133
|
+
-- Buffer full: oldest entry is at _head, wrap around
|
|
134
|
+
for i = self._head, self._capacity do
|
|
135
|
+
table.insert(result, self._buffer[i])
|
|
136
|
+
end
|
|
137
|
+
for i = 1, self._head - 1 do
|
|
138
|
+
table.insert(result, self._buffer[i])
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
return result
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
return MessageBuffer
|