@heojeongbo/wirestage 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSES.md +21 -0
- package/README.md +150 -2
- package/dist/app/playwright/index.d.ts +3 -0
- package/dist/app/playwright/index.d.ts.map +1 -0
- package/dist/app/playwright/index.js +2 -0
- package/dist/app/playwright/index.js.map +1 -0
- package/dist/app/playwright/lib/fixture.d.ts +61 -0
- package/dist/app/playwright/lib/fixture.d.ts.map +1 -0
- package/dist/app/playwright/lib/fixture.js +110 -0
- package/dist/app/playwright/lib/fixture.js.map +1 -0
- package/dist/connect.d.ts +7 -0
- package/dist/connect.d.ts.map +1 -0
- package/dist/connect.js +7 -0
- package/dist/connect.js.map +1 -0
- package/dist/entities/frame/@x/plugin.d.ts +9 -0
- package/dist/entities/frame/@x/plugin.d.ts.map +1 -0
- package/dist/entities/frame/@x/plugin.js +2 -0
- package/dist/entities/frame/@x/plugin.js.map +1 -0
- package/dist/entities/frame/index.d.ts +6 -0
- package/dist/entities/frame/index.d.ts.map +1 -0
- package/dist/entities/frame/index.js +4 -0
- package/dist/entities/frame/index.js.map +1 -0
- package/dist/entities/frame/lib/filter.d.ts +8 -0
- package/dist/entities/frame/lib/filter.d.ts.map +1 -0
- package/dist/entities/frame/lib/filter.js +62 -0
- package/dist/entities/frame/lib/filter.js.map +1 -0
- package/dist/entities/frame/lib/payload.d.ts +8 -0
- package/dist/entities/frame/lib/payload.d.ts.map +1 -0
- package/dist/entities/frame/lib/payload.js +42 -0
- package/dist/entities/frame/lib/payload.js.map +1 -0
- package/dist/entities/frame/lib/snapshot.d.ts +15 -0
- package/dist/entities/frame/lib/snapshot.d.ts.map +1 -0
- package/dist/entities/frame/lib/snapshot.js +90 -0
- package/dist/entities/frame/lib/snapshot.js.map +1 -0
- package/dist/entities/frame/lib/timeline.d.ts +23 -0
- package/dist/entities/frame/lib/timeline.d.ts.map +1 -0
- package/dist/entities/frame/lib/timeline.js +122 -0
- package/dist/entities/frame/lib/timeline.js.map +1 -0
- package/dist/entities/frame/model/frame.d.ts +182 -0
- package/dist/entities/frame/model/frame.d.ts.map +1 -0
- package/dist/entities/frame/model/frame.js +2 -0
- package/dist/entities/frame/model/frame.js.map +1 -0
- package/dist/entities/plugin/index.d.ts +9 -0
- package/dist/entities/plugin/index.d.ts.map +1 -0
- package/dist/entities/plugin/index.js +3 -0
- package/dist/entities/plugin/index.js.map +1 -0
- package/dist/entities/plugin/lib/define-plugin.d.ts +8 -0
- package/dist/entities/plugin/lib/define-plugin.d.ts.map +1 -0
- package/dist/entities/plugin/lib/define-plugin.js +9 -0
- package/dist/entities/plugin/lib/define-plugin.js.map +1 -0
- package/dist/entities/plugin/lib/named.d.ts +10 -0
- package/dist/entities/plugin/lib/named.d.ts.map +1 -0
- package/dist/entities/plugin/lib/named.js +17 -0
- package/dist/entities/plugin/lib/named.js.map +1 -0
- package/dist/entities/plugin/model/attachment.d.ts +18 -0
- package/dist/entities/plugin/model/attachment.d.ts.map +1 -0
- package/dist/entities/plugin/model/attachment.js +2 -0
- package/dist/entities/plugin/model/attachment.js.map +1 -0
- package/dist/entities/plugin/model/http.d.ts +135 -0
- package/dist/entities/plugin/model/http.d.ts.map +1 -0
- package/dist/entities/plugin/model/http.js +2 -0
- package/dist/entities/plugin/model/http.js.map +1 -0
- package/dist/entities/plugin/model/page.d.ts +100 -0
- package/dist/entities/plugin/model/page.d.ts.map +1 -0
- package/dist/entities/plugin/model/page.js +2 -0
- package/dist/entities/plugin/model/page.js.map +1 -0
- package/dist/entities/plugin/model/plugin.d.ts +83 -0
- package/dist/entities/plugin/model/plugin.d.ts.map +1 -0
- package/dist/entities/plugin/model/plugin.js +2 -0
- package/dist/entities/plugin/model/plugin.js.map +1 -0
- package/dist/entities/plugin/model/socket.d.ts +107 -0
- package/dist/entities/plugin/model/socket.d.ts.map +1 -0
- package/dist/entities/plugin/model/socket.js +2 -0
- package/dist/entities/plugin/model/socket.js.map +1 -0
- package/dist/entities/plugin/model/stream.d.ts +46 -0
- package/dist/entities/plugin/model/stream.d.ts.map +1 -0
- package/dist/entities/plugin/model/stream.js +2 -0
- package/dist/entities/plugin/model/stream.js.map +1 -0
- package/dist/features/connect/index.d.ts +5 -0
- package/dist/features/connect/index.d.ts.map +1 -0
- package/dist/features/connect/index.js +4 -0
- package/dist/features/connect/index.js.map +1 -0
- package/dist/features/connect/lib/calls.d.ts +9 -0
- package/dist/features/connect/lib/calls.d.ts.map +1 -0
- package/dist/features/connect/lib/calls.js +46 -0
- package/dist/features/connect/lib/calls.js.map +1 -0
- package/dist/features/connect/lib/client.d.ts +33 -0
- package/dist/features/connect/lib/client.d.ts.map +1 -0
- package/dist/features/connect/lib/client.js +147 -0
- package/dist/features/connect/lib/client.js.map +1 -0
- package/dist/features/connect/lib/create-connect.d.ts +14 -0
- package/dist/features/connect/lib/create-connect.d.ts.map +1 -0
- package/dist/features/connect/lib/create-connect.js +124 -0
- package/dist/features/connect/lib/create-connect.js.map +1 -0
- package/dist/features/connect/lib/faults.d.ts +18 -0
- package/dist/features/connect/lib/faults.d.ts.map +1 -0
- package/dist/features/connect/lib/faults.js +85 -0
- package/dist/features/connect/lib/faults.js.map +1 -0
- package/dist/features/connect/lib/protocol.d.ts +42 -0
- package/dist/features/connect/lib/protocol.d.ts.map +1 -0
- package/dist/features/connect/lib/protocol.js +228 -0
- package/dist/features/connect/lib/protocol.js.map +1 -0
- package/dist/features/connect/lib/record.d.ts +14 -0
- package/dist/features/connect/lib/record.d.ts.map +1 -0
- package/dist/features/connect/lib/record.js +36 -0
- package/dist/features/connect/lib/record.js.map +1 -0
- package/dist/features/connect/lib/recorder.d.ts +77 -0
- package/dist/features/connect/lib/recorder.d.ts.map +1 -0
- package/dist/features/connect/lib/recorder.js +209 -0
- package/dist/features/connect/lib/recorder.js.map +1 -0
- package/dist/features/connect/lib/rules.d.ts +51 -0
- package/dist/features/connect/lib/rules.d.ts.map +1 -0
- package/dist/features/connect/lib/rules.js +222 -0
- package/dist/features/connect/lib/rules.js.map +1 -0
- package/dist/features/connect/lib/serve.d.ts +10 -0
- package/dist/features/connect/lib/serve.d.ts.map +1 -0
- package/dist/features/connect/lib/serve.js +78 -0
- package/dist/features/connect/lib/serve.js.map +1 -0
- package/dist/features/connect/lib/status-of.d.ts +11 -0
- package/dist/features/connect/lib/status-of.d.ts.map +1 -0
- package/dist/features/connect/lib/status-of.js +22 -0
- package/dist/features/connect/lib/status-of.js.map +1 -0
- package/dist/features/connect/lib/stubs.d.ts +18 -0
- package/dist/features/connect/lib/stubs.d.ts.map +1 -0
- package/dist/features/connect/lib/stubs.js +174 -0
- package/dist/features/connect/lib/stubs.js.map +1 -0
- package/dist/features/connect/lib/universal.d.ts +19 -0
- package/dist/features/connect/lib/universal.d.ts.map +1 -0
- package/dist/features/connect/lib/universal.js +71 -0
- package/dist/features/connect/lib/universal.js.map +1 -0
- package/dist/features/connect/model/types.d.ts +247 -0
- package/dist/features/connect/model/types.d.ts.map +1 -0
- package/dist/features/connect/model/types.js +2 -0
- package/dist/features/connect/model/types.js.map +1 -0
- package/dist/features/rest/index.d.ts +5 -0
- package/dist/features/rest/index.d.ts.map +1 -0
- package/dist/features/rest/index.js +3 -0
- package/dist/features/rest/index.js.map +1 -0
- package/dist/features/rest/lib/calls.d.ts +8 -0
- package/dist/features/rest/lib/calls.d.ts.map +1 -0
- package/dist/features/rest/lib/calls.js +32 -0
- package/dist/features/rest/lib/calls.js.map +1 -0
- package/dist/features/rest/lib/create-rest.d.ts +8 -0
- package/dist/features/rest/lib/create-rest.d.ts.map +1 -0
- package/dist/features/rest/lib/create-rest.js +136 -0
- package/dist/features/rest/lib/create-rest.js.map +1 -0
- package/dist/features/rest/lib/path.d.ts +14 -0
- package/dist/features/rest/lib/path.d.ts.map +1 -0
- package/dist/features/rest/lib/path.js +58 -0
- package/dist/features/rest/lib/path.js.map +1 -0
- package/dist/features/rest/lib/reply.d.ts +25 -0
- package/dist/features/rest/lib/reply.d.ts.map +1 -0
- package/dist/features/rest/lib/reply.js +40 -0
- package/dist/features/rest/lib/reply.js.map +1 -0
- package/dist/features/rest/model/types.d.ts +74 -0
- package/dist/features/rest/model/types.d.ts.map +1 -0
- package/dist/features/rest/model/types.js +2 -0
- package/dist/features/rest/model/types.js.map +1 -0
- package/dist/features/sse/index.d.ts +4 -0
- package/dist/features/sse/index.d.ts.map +1 -0
- package/dist/features/sse/index.js +3 -0
- package/dist/features/sse/index.js.map +1 -0
- package/dist/features/sse/lib/create-sse.d.ts +9 -0
- package/dist/features/sse/lib/create-sse.d.ts.map +1 -0
- package/dist/features/sse/lib/create-sse.js +121 -0
- package/dist/features/sse/lib/create-sse.js.map +1 -0
- package/dist/features/sse/lib/encode.d.ts +8 -0
- package/dist/features/sse/lib/encode.d.ts.map +1 -0
- package/dist/features/sse/lib/encode.js +29 -0
- package/dist/features/sse/lib/encode.js.map +1 -0
- package/dist/features/sse/model/types.d.ts +68 -0
- package/dist/features/sse/model/types.d.ts.map +1 -0
- package/dist/features/sse/model/types.js +2 -0
- package/dist/features/sse/model/types.js.map +1 -0
- package/dist/features/webrtc/index.d.ts +3 -0
- package/dist/features/webrtc/index.d.ts.map +1 -0
- package/dist/features/webrtc/index.js +2 -0
- package/dist/features/webrtc/index.js.map +1 -0
- package/dist/features/webrtc/lib/create-webrtc.d.ts +9 -0
- package/dist/features/webrtc/lib/create-webrtc.d.ts.map +1 -0
- package/dist/features/webrtc/lib/create-webrtc.js +123 -0
- package/dist/features/webrtc/lib/create-webrtc.js.map +1 -0
- package/dist/features/webrtc/lib/rtc-page-module.d.ts +22 -0
- package/dist/features/webrtc/lib/rtc-page-module.d.ts.map +1 -0
- package/dist/features/webrtc/lib/rtc-page-module.js +161 -0
- package/dist/features/webrtc/lib/rtc-page-module.js.map +1 -0
- package/dist/features/webrtc/lib/to-frame.d.ts +9 -0
- package/dist/features/webrtc/lib/to-frame.d.ts.map +1 -0
- package/dist/features/webrtc/lib/to-frame.js +43 -0
- package/dist/features/webrtc/lib/to-frame.js.map +1 -0
- package/dist/features/webrtc/model/types.d.ts +70 -0
- package/dist/features/webrtc/model/types.d.ts.map +1 -0
- package/dist/features/webrtc/model/types.js +2 -0
- package/dist/features/webrtc/model/types.js.map +1 -0
- package/dist/features/websocket/index.d.ts +3 -0
- package/dist/features/websocket/index.d.ts.map +1 -0
- package/dist/features/websocket/index.js +2 -0
- package/dist/features/websocket/index.js.map +1 -0
- package/dist/features/websocket/lib/create-websocket.d.ts +9 -0
- package/dist/features/websocket/lib/create-websocket.d.ts.map +1 -0
- package/dist/features/websocket/lib/create-websocket.js +34 -0
- package/dist/features/websocket/lib/create-websocket.js.map +1 -0
- package/dist/features/websocket/lib/mock.d.ts +6 -0
- package/dist/features/websocket/lib/mock.d.ts.map +1 -0
- package/dist/features/websocket/lib/mock.js +96 -0
- package/dist/features/websocket/lib/mock.js.map +1 -0
- package/dist/features/websocket/lib/proxy.d.ts +9 -0
- package/dist/features/websocket/lib/proxy.d.ts.map +1 -0
- package/dist/features/websocket/lib/proxy.js +120 -0
- package/dist/features/websocket/lib/proxy.js.map +1 -0
- package/dist/features/websocket/lib/wire.d.ts +16 -0
- package/dist/features/websocket/lib/wire.d.ts.map +1 -0
- package/dist/features/websocket/lib/wire.js +46 -0
- package/dist/features/websocket/lib/wire.js.map +1 -0
- package/dist/features/websocket/model/types.d.ts +133 -0
- package/dist/features/websocket/model/types.d.ts.map +1 -0
- package/dist/features/websocket/model/types.js +2 -0
- package/dist/features/websocket/model/types.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/playwright.d.ts +4 -0
- package/dist/playwright.d.ts.map +1 -0
- package/dist/playwright.js +2 -0
- package/dist/playwright.js.map +1 -0
- package/dist/rest.d.ts +3 -0
- package/dist/rest.d.ts.map +1 -0
- package/dist/rest.js +3 -0
- package/dist/rest.js.map +1 -0
- package/dist/shared/api/http-server/index.d.ts +3 -0
- package/dist/shared/api/http-server/index.d.ts.map +1 -0
- package/dist/shared/api/http-server/index.js +2 -0
- package/dist/shared/api/http-server/index.js.map +1 -0
- package/dist/shared/api/http-server/listen.d.ts +25 -0
- package/dist/shared/api/http-server/listen.d.ts.map +1 -0
- package/dist/shared/api/http-server/listen.js +44 -0
- package/dist/shared/api/http-server/listen.js.map +1 -0
- package/dist/shared/api/playwright/index.d.ts +2 -0
- package/dist/shared/api/playwright/index.d.ts.map +1 -0
- package/dist/shared/api/playwright/index.js +2 -0
- package/dist/shared/api/playwright/index.js.map +1 -0
- package/dist/shared/api/playwright/ports.d.ts +126 -0
- package/dist/shared/api/playwright/ports.d.ts.map +1 -0
- package/dist/shared/api/playwright/ports.js +11 -0
- package/dist/shared/api/playwright/ports.js.map +1 -0
- package/dist/shared/api/stream-server/index.d.ts +3 -0
- package/dist/shared/api/stream-server/index.d.ts.map +1 -0
- package/dist/shared/api/stream-server/index.js +2 -0
- package/dist/shared/api/stream-server/index.js.map +1 -0
- package/dist/shared/api/stream-server/stream-server.d.ts +45 -0
- package/dist/shared/api/stream-server/stream-server.d.ts.map +1 -0
- package/dist/shared/api/stream-server/stream-server.js +167 -0
- package/dist/shared/api/stream-server/stream-server.js.map +1 -0
- package/dist/shared/lib/async/arrivals.d.ts +31 -0
- package/dist/shared/lib/async/arrivals.d.ts.map +1 -0
- package/dist/shared/lib/async/arrivals.js +57 -0
- package/dist/shared/lib/async/arrivals.js.map +1 -0
- package/dist/shared/lib/async/async-queue.d.ts +23 -0
- package/dist/shared/lib/async/async-queue.d.ts.map +1 -0
- package/dist/shared/lib/async/async-queue.js +80 -0
- package/dist/shared/lib/async/async-queue.js.map +1 -0
- package/dist/shared/lib/async/deferred.d.ts +12 -0
- package/dist/shared/lib/async/deferred.d.ts.map +1 -0
- package/dist/shared/lib/async/deferred.js +34 -0
- package/dist/shared/lib/async/deferred.js.map +1 -0
- package/dist/shared/lib/async/index.d.ts +8 -0
- package/dist/shared/lib/async/index.d.ts.map +1 -0
- package/dist/shared/lib/async/index.js +5 -0
- package/dist/shared/lib/async/index.js.map +1 -0
- package/dist/shared/lib/async/run-all.d.ts +8 -0
- package/dist/shared/lib/async/run-all.d.ts.map +1 -0
- package/dist/shared/lib/async/run-all.js +22 -0
- package/dist/shared/lib/async/run-all.js.map +1 -0
- package/dist/shared/lib/bytes/bytes.d.ts +18 -0
- package/dist/shared/lib/bytes/bytes.d.ts.map +1 -0
- package/dist/shared/lib/bytes/bytes.js +48 -0
- package/dist/shared/lib/bytes/bytes.js.map +1 -0
- package/dist/shared/lib/bytes/index.d.ts +3 -0
- package/dist/shared/lib/bytes/index.d.ts.map +1 -0
- package/dist/shared/lib/bytes/index.js +2 -0
- package/dist/shared/lib/bytes/index.js.map +1 -0
- package/dist/shared/lib/clock/clock.d.ts +29 -0
- package/dist/shared/lib/clock/clock.d.ts.map +1 -0
- package/dist/shared/lib/clock/clock.js +85 -0
- package/dist/shared/lib/clock/clock.js.map +1 -0
- package/dist/shared/lib/clock/index.d.ts +3 -0
- package/dist/shared/lib/clock/index.d.ts.map +1 -0
- package/dist/shared/lib/clock/index.js +2 -0
- package/dist/shared/lib/clock/index.js.map +1 -0
- package/dist/shared/lib/cookies/index.d.ts +3 -0
- package/dist/shared/lib/cookies/index.d.ts.map +1 -0
- package/dist/shared/lib/cookies/index.js +2 -0
- package/dist/shared/lib/cookies/index.js.map +1 -0
- package/dist/shared/lib/cookies/set-cookie.d.ts +22 -0
- package/dist/shared/lib/cookies/set-cookie.d.ts.map +1 -0
- package/dist/shared/lib/cookies/set-cookie.js +89 -0
- package/dist/shared/lib/cookies/set-cookie.js.map +1 -0
- package/dist/shared/lib/envelope/envelope.d.ts +50 -0
- package/dist/shared/lib/envelope/envelope.d.ts.map +1 -0
- package/dist/shared/lib/envelope/envelope.js +111 -0
- package/dist/shared/lib/envelope/envelope.js.map +1 -0
- package/dist/shared/lib/envelope/index.d.ts +3 -0
- package/dist/shared/lib/envelope/index.d.ts.map +1 -0
- package/dist/shared/lib/envelope/index.js +2 -0
- package/dist/shared/lib/envelope/index.js.map +1 -0
- package/dist/shared/lib/errors/index.d.ts +3 -0
- package/dist/shared/lib/errors/index.d.ts.map +1 -0
- package/dist/shared/lib/errors/index.js +2 -0
- package/dist/shared/lib/errors/index.js.map +1 -0
- package/dist/shared/lib/errors/wirestage-error.d.ts +28 -0
- package/dist/shared/lib/errors/wirestage-error.d.ts.map +1 -0
- package/dist/shared/lib/errors/wirestage-error.js +16 -0
- package/dist/shared/lib/errors/wirestage-error.js.map +1 -0
- package/dist/shared/lib/id/id.d.ts +10 -0
- package/dist/shared/lib/id/id.d.ts.map +1 -0
- package/dist/shared/lib/id/id.js +26 -0
- package/dist/shared/lib/id/id.js.map +1 -0
- package/dist/shared/lib/id/index.d.ts +2 -0
- package/dist/shared/lib/id/index.d.ts.map +1 -0
- package/dist/shared/lib/id/index.js +2 -0
- package/dist/shared/lib/id/index.js.map +1 -0
- package/dist/shared/lib/logger/index.d.ts +3 -0
- package/dist/shared/lib/logger/index.d.ts.map +1 -0
- package/dist/shared/lib/logger/index.js +2 -0
- package/dist/shared/lib/logger/index.js.map +1 -0
- package/dist/shared/lib/logger/logger.d.ts +46 -0
- package/dist/shared/lib/logger/logger.d.ts.map +1 -0
- package/dist/shared/lib/logger/logger.js +67 -0
- package/dist/shared/lib/logger/logger.js.map +1 -0
- package/dist/shared/lib/match/index.d.ts +3 -0
- package/dist/shared/lib/match/index.d.ts.map +1 -0
- package/dist/shared/lib/match/index.js +2 -0
- package/dist/shared/lib/match/index.js.map +1 -0
- package/dist/shared/lib/match/url-matcher.d.ts +27 -0
- package/dist/shared/lib/match/url-matcher.d.ts.map +1 -0
- package/dist/shared/lib/match/url-matcher.js +88 -0
- package/dist/shared/lib/match/url-matcher.js.map +1 -0
- package/dist/sse.d.ts +3 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/sse.js +3 -0
- package/dist/sse.js.map +1 -0
- package/dist/webrtc.d.ts +3 -0
- package/dist/webrtc.d.ts.map +1 -0
- package/dist/webrtc.js +3 -0
- package/dist/webrtc.js.map +1 -0
- package/dist/websocket.d.ts +3 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +3 -0
- package/dist/websocket.js.map +1 -0
- package/dist/widgets/stage/index.d.ts +3 -0
- package/dist/widgets/stage/index.d.ts.map +1 -0
- package/dist/widgets/stage/index.js +2 -0
- package/dist/widgets/stage/index.js.map +1 -0
- package/dist/widgets/stage/lib/attached-context.d.ts +10 -0
- package/dist/widgets/stage/lib/attached-context.d.ts.map +1 -0
- package/dist/widgets/stage/lib/attached-context.js +2 -0
- package/dist/widgets/stage/lib/attached-context.js.map +1 -0
- package/dist/widgets/stage/lib/create-stage.d.ts +12 -0
- package/dist/widgets/stage/lib/create-stage.d.ts.map +1 -0
- package/dist/widgets/stage/lib/create-stage.js +250 -0
- package/dist/widgets/stage/lib/create-stage.js.map +1 -0
- package/dist/widgets/stage/lib/http-router.d.ts +44 -0
- package/dist/widgets/stage/lib/http-router.d.ts.map +1 -0
- package/dist/widgets/stage/lib/http-router.js +696 -0
- package/dist/widgets/stage/lib/http-router.js.map +1 -0
- package/dist/widgets/stage/lib/page-host.d.ts +36 -0
- package/dist/widgets/stage/lib/page-host.d.ts.map +1 -0
- package/dist/widgets/stage/lib/page-host.js +240 -0
- package/dist/widgets/stage/lib/page-host.js.map +1 -0
- package/dist/widgets/stage/lib/page-runtime.d.ts +93 -0
- package/dist/widgets/stage/lib/page-runtime.d.ts.map +1 -0
- package/dist/widgets/stage/lib/page-runtime.js +247 -0
- package/dist/widgets/stage/lib/page-runtime.js.map +1 -0
- package/dist/widgets/stage/lib/reads.d.ts +21 -0
- package/dist/widgets/stage/lib/reads.d.ts.map +1 -0
- package/dist/widgets/stage/lib/reads.js +97 -0
- package/dist/widgets/stage/lib/reads.js.map +1 -0
- package/dist/widgets/stage/lib/response-stream.d.ts +23 -0
- package/dist/widgets/stage/lib/response-stream.d.ts.map +1 -0
- package/dist/widgets/stage/lib/response-stream.js +108 -0
- package/dist/widgets/stage/lib/response-stream.js.map +1 -0
- package/dist/widgets/stage/lib/socket-router.d.ts +25 -0
- package/dist/widgets/stage/lib/socket-router.d.ts.map +1 -0
- package/dist/widgets/stage/lib/socket-router.js +233 -0
- package/dist/widgets/stage/lib/socket-router.js.map +1 -0
- package/dist/widgets/stage/model/stage.d.ts +88 -0
- package/dist/widgets/stage/model/stage.d.ts.map +1 -0
- package/dist/widgets/stage/model/stage.js +2 -0
- package/dist/widgets/stage/model/stage.js.map +1 -0
- package/package.json +140 -5
- package/src/app/playwright/index.ts +7 -0
- package/src/app/playwright/lib/fixture.ts +201 -0
- package/src/connect.ts +6 -0
- package/src/entities/frame/@x/plugin.ts +8 -0
- package/src/entities/frame/index.ts +19 -0
- package/src/entities/frame/lib/filter.ts +58 -0
- package/src/entities/frame/lib/payload.ts +42 -0
- package/src/entities/frame/lib/snapshot.ts +105 -0
- package/src/entities/frame/lib/timeline.ts +147 -0
- package/src/entities/frame/model/frame.ts +191 -0
- package/src/entities/plugin/index.ts +36 -0
- package/src/entities/plugin/lib/define-plugin.ts +12 -0
- package/src/entities/plugin/lib/named.ts +21 -0
- package/src/entities/plugin/model/attachment.ts +18 -0
- package/src/entities/plugin/model/http.ts +156 -0
- package/src/entities/plugin/model/page.ts +110 -0
- package/src/entities/plugin/model/plugin.ts +96 -0
- package/src/entities/plugin/model/socket.ts +113 -0
- package/src/entities/plugin/model/stream.ts +46 -0
- package/src/features/connect/index.ts +23 -0
- package/src/features/connect/lib/calls.ts +58 -0
- package/src/features/connect/lib/client.ts +203 -0
- package/src/features/connect/lib/create-connect.ts +164 -0
- package/src/features/connect/lib/faults.ts +132 -0
- package/src/features/connect/lib/protocol.ts +321 -0
- package/src/features/connect/lib/record.ts +48 -0
- package/src/features/connect/lib/recorder.ts +306 -0
- package/src/features/connect/lib/rules.ts +385 -0
- package/src/features/connect/lib/serve.ts +114 -0
- package/src/features/connect/lib/status-of.ts +20 -0
- package/src/features/connect/lib/stubs.ts +282 -0
- package/src/features/connect/lib/universal.ts +100 -0
- package/src/features/connect/model/types.ts +305 -0
- package/src/features/rest/index.ts +23 -0
- package/src/features/rest/lib/calls.ts +31 -0
- package/src/features/rest/lib/create-rest.ts +169 -0
- package/src/features/rest/lib/path.ts +70 -0
- package/src/features/rest/lib/reply.ts +74 -0
- package/src/features/rest/model/types.ts +113 -0
- package/src/features/sse/index.ts +10 -0
- package/src/features/sse/lib/create-sse.ts +129 -0
- package/src/features/sse/lib/encode.ts +28 -0
- package/src/features/sse/model/types.ts +72 -0
- package/src/features/webrtc/index.ts +6 -0
- package/src/features/webrtc/lib/create-webrtc.ts +149 -0
- package/src/features/webrtc/lib/rtc-page-module.ts +189 -0
- package/src/features/webrtc/lib/to-frame.ts +63 -0
- package/src/features/webrtc/model/types.ts +80 -0
- package/src/features/websocket/index.ts +15 -0
- package/src/features/websocket/lib/create-websocket.ts +41 -0
- package/src/features/websocket/lib/mock.ts +114 -0
- package/src/features/websocket/lib/proxy.ts +153 -0
- package/src/features/websocket/lib/wire.ts +78 -0
- package/src/features/websocket/model/types.ts +134 -0
- package/src/index.ts +111 -0
- package/src/playwright.ts +8 -0
- package/src/rest.ts +2 -0
- package/src/shared/api/http-server/index.ts +2 -0
- package/src/shared/api/http-server/listen.ts +71 -0
- package/src/shared/api/playwright/index.ts +17 -0
- package/src/shared/api/playwright/ports.ts +150 -0
- package/src/shared/api/stream-server/index.ts +7 -0
- package/src/shared/api/stream-server/stream-server.ts +254 -0
- package/src/shared/lib/async/arrivals.ts +91 -0
- package/src/shared/lib/async/async-queue.ts +101 -0
- package/src/shared/lib/async/deferred.ts +38 -0
- package/src/shared/lib/async/index.ts +11 -0
- package/src/shared/lib/async/run-all.ts +19 -0
- package/src/shared/lib/bytes/bytes.ts +53 -0
- package/src/shared/lib/bytes/index.ts +9 -0
- package/src/shared/lib/clock/clock.ts +114 -0
- package/src/shared/lib/clock/index.ts +2 -0
- package/src/shared/lib/cookies/index.ts +2 -0
- package/src/shared/lib/cookies/set-cookie.ts +105 -0
- package/src/shared/lib/envelope/envelope.ts +133 -0
- package/src/shared/lib/envelope/index.ts +9 -0
- package/src/shared/lib/errors/index.ts +5 -0
- package/src/shared/lib/errors/wirestage-error.ts +50 -0
- package/src/shared/lib/id/id.ts +29 -0
- package/src/shared/lib/id/index.ts +1 -0
- package/src/shared/lib/logger/index.ts +12 -0
- package/src/shared/lib/logger/logger.ts +126 -0
- package/src/shared/lib/match/index.ts +6 -0
- package/src/shared/lib/match/url-matcher.ts +107 -0
- package/src/sse.ts +2 -0
- package/src/webrtc.ts +2 -0
- package/src/websocket.ts +2 -0
- package/src/widgets/stage/index.ts +9 -0
- package/src/widgets/stage/lib/attached-context.ts +10 -0
- package/src/widgets/stage/lib/create-stage.ts +307 -0
- package/src/widgets/stage/lib/http-router.ts +954 -0
- package/src/widgets/stage/lib/page-host.ts +375 -0
- package/src/widgets/stage/lib/page-runtime.ts +314 -0
- package/src/widgets/stage/lib/reads.ts +128 -0
- package/src/widgets/stage/lib/response-stream.ts +139 -0
- package/src/widgets/stage/lib/socket-router.ts +300 -0
- package/src/widgets/stage/model/stage.ts +110 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The page half of the page host. Everything in this file that is exported as
|
|
3
|
+
* a function runs INSIDE the page: it is serialized with `toString()`, so it is
|
|
4
|
+
* self-contained — no imports, no references to module scope.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Install every module, batch what they emit, and answer Node's flushes and
|
|
8
|
+
* commands.
|
|
9
|
+
*
|
|
10
|
+
* Batching is what keeps a 60 Hz channel cheap: one binding call per flush
|
|
11
|
+
* window instead of one per message. The first entry after a quiet spell is
|
|
12
|
+
* not held back, though — it leaves at once, so it reaches Node ahead of a
|
|
13
|
+
* request the page makes right after it and the two land on the timeline in
|
|
14
|
+
* the order they happened.
|
|
15
|
+
*
|
|
16
|
+
* `flush()` returns the binding's promise, so a Node-side `evaluate(flush)`
|
|
17
|
+
* resolves only after Node has appended the entries: a read that flushes
|
|
18
|
+
* first sees everything the page recorded before it.
|
|
19
|
+
*
|
|
20
|
+
* Nothing the runtime does throws into the page's own code: a module whose
|
|
21
|
+
* handler throws is reported to Node, and a binding that has been taken away
|
|
22
|
+
* makes the runtime step aside.
|
|
23
|
+
*/
|
|
24
|
+
export function pageRuntime(scope, init, installers) {
|
|
25
|
+
scope["__wirestage"] ??= {};
|
|
26
|
+
const root = scope["__wirestage"];
|
|
27
|
+
const bind = scope[init.binding];
|
|
28
|
+
// Init scripts run again in every frame and on every navigation; a second
|
|
29
|
+
// run in the same realm would double every entry.
|
|
30
|
+
if (root[init.binding] !== undefined || typeof bind !== "function")
|
|
31
|
+
return;
|
|
32
|
+
const send = bind;
|
|
33
|
+
const queue = [];
|
|
34
|
+
/** Set once the runtime steps aside: a module still emitting talks to nobody. */
|
|
35
|
+
let detached = false;
|
|
36
|
+
let timer;
|
|
37
|
+
/** When the last batch left; far enough back that the first entry is not held. */
|
|
38
|
+
let sentAt = Number.NEGATIVE_INFINITY;
|
|
39
|
+
const commands = new Map();
|
|
40
|
+
const stateHandlers = new Map();
|
|
41
|
+
const detachHandlers = [];
|
|
42
|
+
const now = () => performance.timeOrigin + performance.now();
|
|
43
|
+
/** Undo every module's hooks, newest first: stacked hooks come off in order. */
|
|
44
|
+
const unhook = () => {
|
|
45
|
+
for (const { module, undo } of detachHandlers.splice(0).reverse()) {
|
|
46
|
+
try {
|
|
47
|
+
undo();
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
// One module failing to undo must not keep the rest hooked.
|
|
51
|
+
report(module, "onDetach", error);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
delete root[init.binding];
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Send through the binding. Playwright's throws, synchronously, once it
|
|
58
|
+
* has been removed — in a document the stage's detach did not reach, one
|
|
59
|
+
* that loaded while the stage was detaching. Thrown on from `emit`, that
|
|
60
|
+
* would fail the app's own call (`RTCDataChannel.send()`) or surface as a
|
|
61
|
+
* page error; nothing the runtime holds can reach Node any more, so it
|
|
62
|
+
* steps aside instead, putting back what the modules wrapped.
|
|
63
|
+
*/
|
|
64
|
+
const post = (message) => {
|
|
65
|
+
try {
|
|
66
|
+
return send(message);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
detached = true;
|
|
70
|
+
queue.length = 0;
|
|
71
|
+
unhook();
|
|
72
|
+
return Promise.resolve(undefined);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
/** Tell Node a module's handler threw, so it is logged against the module. */
|
|
76
|
+
const report = (module, handler, error) => {
|
|
77
|
+
// Stepping aside for want of a binding: there is nobody left to tell.
|
|
78
|
+
if (detached)
|
|
79
|
+
return;
|
|
80
|
+
post({ type: "failure", module, handler, error: String(error) }).catch(() => { });
|
|
81
|
+
};
|
|
82
|
+
const flush = () => {
|
|
83
|
+
if (timer !== undefined) {
|
|
84
|
+
clearTimeout(timer);
|
|
85
|
+
timer = undefined;
|
|
86
|
+
}
|
|
87
|
+
if (queue.length === 0)
|
|
88
|
+
return Promise.resolve(undefined);
|
|
89
|
+
sentAt = now();
|
|
90
|
+
return post({ type: "entries", entries: queue.splice(0, queue.length) });
|
|
91
|
+
};
|
|
92
|
+
const schedule = () => {
|
|
93
|
+
const wait = sentAt + init.flushMs - now();
|
|
94
|
+
if (wait <= 0) {
|
|
95
|
+
flush().catch(() => { });
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
timer ??= setTimeout(() => {
|
|
99
|
+
timer = undefined;
|
|
100
|
+
flush().catch(() => { });
|
|
101
|
+
}, wait);
|
|
102
|
+
};
|
|
103
|
+
const encode = (bytes) => {
|
|
104
|
+
let binary = "";
|
|
105
|
+
// Chunked: spreading a large array into fromCharCode overflows the stack.
|
|
106
|
+
for (let i = 0; i < bytes.length; i += 0x8000)
|
|
107
|
+
binary += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
|
|
108
|
+
return btoa(binary);
|
|
109
|
+
};
|
|
110
|
+
const decode = (text) => {
|
|
111
|
+
const binary = atob(text);
|
|
112
|
+
const out = new Uint8Array(binary.length);
|
|
113
|
+
for (let i = 0; i < binary.length; i++)
|
|
114
|
+
out[i] = binary.charCodeAt(i);
|
|
115
|
+
return out;
|
|
116
|
+
};
|
|
117
|
+
/** Run each of a module's state handlers, whatever the others do; return what threw. */
|
|
118
|
+
const applyState = (module, state) => {
|
|
119
|
+
const failures = [];
|
|
120
|
+
for (const handler of stateHandlers.get(module) ?? [])
|
|
121
|
+
try {
|
|
122
|
+
handler(state);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
failures.push(error);
|
|
126
|
+
}
|
|
127
|
+
return failures;
|
|
128
|
+
};
|
|
129
|
+
for (const module of init.modules) {
|
|
130
|
+
const install = installers[module.id];
|
|
131
|
+
if (install === undefined)
|
|
132
|
+
continue;
|
|
133
|
+
const emit = (entry) => {
|
|
134
|
+
if (detached)
|
|
135
|
+
return;
|
|
136
|
+
queue.push({ module: module.id, entry });
|
|
137
|
+
schedule();
|
|
138
|
+
};
|
|
139
|
+
try {
|
|
140
|
+
install({
|
|
141
|
+
window: scope,
|
|
142
|
+
config: module.config,
|
|
143
|
+
emit,
|
|
144
|
+
now,
|
|
145
|
+
encode,
|
|
146
|
+
decode,
|
|
147
|
+
onCommand: (op, handler) => {
|
|
148
|
+
commands.set(`${module.id}\u0000${op}`, handler);
|
|
149
|
+
},
|
|
150
|
+
onState: (handler) => {
|
|
151
|
+
const list = stateHandlers.get(module.id) ?? [];
|
|
152
|
+
list.push(handler);
|
|
153
|
+
stateHandlers.set(module.id, list);
|
|
154
|
+
},
|
|
155
|
+
onDetach: (handler) => {
|
|
156
|
+
detachHandlers.push({ module: module.id, undo: handler });
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
// A broken module must not take the page down with it: an entry puts
|
|
162
|
+
// the failure on its timeline, and Node logs it against the module.
|
|
163
|
+
emit({ type: "error", at: now(), text: String(error) });
|
|
164
|
+
report(module.id, "install", error);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const handle = {
|
|
168
|
+
flush,
|
|
169
|
+
command(module, op, args) {
|
|
170
|
+
if (op === "__state") {
|
|
171
|
+
// Every handler gets the state; the command still fails when one
|
|
172
|
+
// threw, so the `refresh()` that sent it says which module broke.
|
|
173
|
+
const failures = applyState(module, args);
|
|
174
|
+
if (failures.length > 0)
|
|
175
|
+
throw failures[0];
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
const handler = commands.get(`${module}\u0000${op}`);
|
|
179
|
+
return handler === undefined ? undefined : handler(args);
|
|
180
|
+
},
|
|
181
|
+
detach() {
|
|
182
|
+
unhook();
|
|
183
|
+
// After the undos: what they emit still leaves with the last flush.
|
|
184
|
+
detached = true;
|
|
185
|
+
return flush();
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
root[init.binding] = handle;
|
|
189
|
+
// Chromium loses a binding call made from `pagehide` when the main frame
|
|
190
|
+
// navigates — the document is gone before Node hears of it — while one
|
|
191
|
+
// made from `beforeunload` still arrives. `pagehide` stays for the ways
|
|
192
|
+
// out that fire no `beforeunload`: a page closed, an iframe removed.
|
|
193
|
+
for (const type of ["beforeunload", "pagehide"])
|
|
194
|
+
scope.addEventListener(type, () => {
|
|
195
|
+
flush().catch(() => { });
|
|
196
|
+
});
|
|
197
|
+
post({ type: "hello" }).then((states) => {
|
|
198
|
+
const byModule = (states ?? {});
|
|
199
|
+
for (const module of stateHandlers.keys())
|
|
200
|
+
if (byModule[module] !== undefined)
|
|
201
|
+
// No call to fail: Node hears of each failure, and the
|
|
202
|
+
// modules after this one still get their state.
|
|
203
|
+
for (const error of applyState(module, byModule[module]))
|
|
204
|
+
report(module, "onState", error);
|
|
205
|
+
}, () => { });
|
|
206
|
+
}
|
|
207
|
+
/** Flush one frame's runtime. Runs in the page via `frame.evaluate`. */
|
|
208
|
+
export function flushRuntime(binding) {
|
|
209
|
+
const root = globalThis["__wirestage"];
|
|
210
|
+
return root?.[binding]?.flush();
|
|
211
|
+
}
|
|
212
|
+
/** Detach one frame's runtime. Runs in the page via `frame.evaluate`. */
|
|
213
|
+
export function detachRuntime(binding) {
|
|
214
|
+
const root = globalThis["__wirestage"];
|
|
215
|
+
return root?.[binding]?.detach();
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Run one command in one frame's runtime. Runs in the page via
|
|
219
|
+
* `frame.evaluate`. Undefined when the frame has no runtime (a document the
|
|
220
|
+
* init script never ran in); otherwise the handler's answer, or its failure
|
|
221
|
+
* as text — an exception would cross back to Node as a rejected evaluate,
|
|
222
|
+
* indistinguishable from a frame that went away.
|
|
223
|
+
*/
|
|
224
|
+
export function commandRuntime(arg) {
|
|
225
|
+
const root = globalThis["__wirestage"];
|
|
226
|
+
const handle = root?.[arg.binding];
|
|
227
|
+
if (handle === undefined)
|
|
228
|
+
return undefined;
|
|
229
|
+
return Promise.resolve()
|
|
230
|
+
.then(() => handle.command(arg.module, arg.op, arg.args))
|
|
231
|
+
.then((value) => ({ value }), (error) => ({ error: String(error) }));
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* The init script: the runtime, then every installer, then the call.
|
|
235
|
+
*
|
|
236
|
+
* Wrapped in a scope that defines `__name`: esbuild's `keepNames` (on by
|
|
237
|
+
* default in tsx) rewrites `const f = () => {}` into `__name(() => {}, "f")`,
|
|
238
|
+
* so code serialized from a tsx-run process calls a helper the page does not
|
|
239
|
+
* have, and the whole runtime dies with "__name is not defined".
|
|
240
|
+
*/
|
|
241
|
+
export function buildPageScript(init, installers) {
|
|
242
|
+
const list = Object.entries(installers)
|
|
243
|
+
.map(([id, install]) => `${JSON.stringify(id)}: (${install.toString()})`)
|
|
244
|
+
.join(",\n");
|
|
245
|
+
return `(() => {\nconst __name = (target) => target;\n(${pageRuntime.toString()})(globalThis, ${JSON.stringify(init)}, {\n${list}\n});\n})();`;
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=page-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-runtime.js","sourceRoot":"","sources":["../../../../src/widgets/stage/lib/page-runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA+CH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,WAAW,CAC1B,KAA8B,EAC9B,IAAqB,EACrB,UAAqC;IAErC,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,KAAK,CAAC,aAAa,CAA4B,CAAC;IAC7D,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjC,0EAA0E;IAC1E,kDAAkD;IAClD,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,SAAS,IAAI,OAAO,IAAI,KAAK,UAAU;QAAE,OAAO;IAC3E,MAAM,IAAI,GAAG,IAAqD,CAAC;IAEnE,MAAM,KAAK,GAAyC,EAAE,CAAC;IACvD,iFAAiF;IACjF,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,KAAgD,CAAC;IACrD,kFAAkF;IAClF,IAAI,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC;IACtC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAsC,CAAC;IAC/D,MAAM,aAAa,GAAG,IAAI,GAAG,EAAwC,CAAC;IACtE,MAAM,cAAc,GAAgD,EAAE,CAAC;IAEvE,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAC7D,gFAAgF;IAChF,MAAM,MAAM,GAAG,GAAG,EAAE;QACnB,KAAK,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,cAAc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C,SAAS,CAAC,IAAI,CAAC,QAAQ,IAAI,cAAc,CAAC;AAChJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Timeline } from "../../../entities/frame/index.js";
|
|
2
|
+
import type { Clock } from "../../../shared/lib/clock/index.js";
|
|
3
|
+
import type { StageCore } from "../model/stage.js";
|
|
4
|
+
export interface ReadsDeps {
|
|
5
|
+
readonly timeline: Timeline;
|
|
6
|
+
readonly clock: Clock;
|
|
7
|
+
/** Flush every page buffer into the timeline. */
|
|
8
|
+
readonly sync: () => Promise<void>;
|
|
9
|
+
/** Defaults for `waitFor`, in milliseconds. */
|
|
10
|
+
readonly wait: {
|
|
11
|
+
readonly timeout: number;
|
|
12
|
+
readonly interval: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export type StageReads = Pick<StageCore, "frames" | "drain" | "mark" | "since" | "between" | "waitFor" | "report">;
|
|
16
|
+
/**
|
|
17
|
+
* The stage's reads of its timeline. Every one flushes the page buffers
|
|
18
|
+
* first: that flush is what makes arrival order the order things happened in.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createReads(deps: ReadsDeps): StageReads;
|
|
21
|
+
//# sourceMappingURL=reads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reads.d.ts","sourceRoot":"","sources":["../../../../src/widgets/stage/lib/reads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGX,QAAQ,EACR,MAAM,kCAAkC,CAAC;AAE1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,iDAAiD;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CACvE;AASD,MAAM,MAAM,UAAU,GAAG,IAAI,CAC5B,SAAS,EACT,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CACxE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,UAAU,CAmFvD"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { WirestageError } from "../../../shared/lib/errors/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Frames a report holds unless asked otherwise. A report is read from its
|
|
4
|
+
* end, and an unbounded one grows with the test: a long run would attach
|
|
5
|
+
* tens of megabytes, or fail to serialize at all.
|
|
6
|
+
*/
|
|
7
|
+
const REPORT_LIMIT = 1_000;
|
|
8
|
+
/**
|
|
9
|
+
* The stage's reads of its timeline. Every one flushes the page buffers
|
|
10
|
+
* first: that flush is what makes arrival order the order things happened in.
|
|
11
|
+
*/
|
|
12
|
+
export function createReads(deps) {
|
|
13
|
+
const { timeline, clock, sync } = deps;
|
|
14
|
+
const drainCursor = timeline.cursor();
|
|
15
|
+
const requireMarker = (name) => {
|
|
16
|
+
const marker = timeline.marker(name);
|
|
17
|
+
if (marker === undefined)
|
|
18
|
+
throw new WirestageError("INVALID_ARGUMENT", timeline.evicted > 0
|
|
19
|
+
? `no marker "${name}" on the timeline: it was never placed, or it was among the ${timeline.evicted} frame(s) dropped at capacity`
|
|
20
|
+
: `no marker "${name}" on the timeline; place one with stage.mark("${name}")`);
|
|
21
|
+
return marker;
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
async frames(filter) {
|
|
25
|
+
await sync();
|
|
26
|
+
return timeline.frames(filter);
|
|
27
|
+
},
|
|
28
|
+
async drain(filter) {
|
|
29
|
+
await sync();
|
|
30
|
+
return drainCursor.take(filter);
|
|
31
|
+
},
|
|
32
|
+
async mark(name, meta) {
|
|
33
|
+
await sync();
|
|
34
|
+
return timeline.append({
|
|
35
|
+
protocol: "wirestage",
|
|
36
|
+
kind: "marker",
|
|
37
|
+
direction: "none",
|
|
38
|
+
endpoint: name,
|
|
39
|
+
source: "test",
|
|
40
|
+
...(meta === undefined ? {} : { meta }),
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
async since(marker, filter) {
|
|
44
|
+
await sync();
|
|
45
|
+
const after = requireMarker(marker).seq;
|
|
46
|
+
return timeline.frames({
|
|
47
|
+
...filter,
|
|
48
|
+
after: Math.max(after, filter?.after ?? 0),
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
async between(from, to, filter) {
|
|
52
|
+
await sync();
|
|
53
|
+
const start = requireMarker(from).seq;
|
|
54
|
+
const end = requireMarker(to).seq;
|
|
55
|
+
const where = filter?.where;
|
|
56
|
+
return timeline.frames({
|
|
57
|
+
...filter,
|
|
58
|
+
after: Math.max(start, filter?.after ?? 0),
|
|
59
|
+
where: (frame) => frame.seq < end && (where === undefined || where(frame)),
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
async waitFor(filter, options = {}) {
|
|
63
|
+
const count = options.count ?? 1;
|
|
64
|
+
const timeout = options.timeout ?? deps.wait.timeout;
|
|
65
|
+
const interval = options.interval ?? deps.wait.interval;
|
|
66
|
+
const deadline = clock.now() + timeout;
|
|
67
|
+
for (;;) {
|
|
68
|
+
await sync();
|
|
69
|
+
const found = timeline.frames(filter);
|
|
70
|
+
if (found.length >= count)
|
|
71
|
+
return found;
|
|
72
|
+
const remaining = deadline - clock.now();
|
|
73
|
+
if (remaining <= 0)
|
|
74
|
+
throw new WirestageError("TIMEOUT", `waited ${timeout} ms for ${count} frame(s) matching ${describeFilter(filter)}; ${found.length} matched. Last frames:\n${timeline.format(undefined, { limit: 20 })}`, { details: { count, matched: found.length, timeout } });
|
|
75
|
+
await clock.sleep(Math.min(interval, remaining));
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
report(filter, options = {}) {
|
|
79
|
+
const limit = options.limit ?? REPORT_LIMIT;
|
|
80
|
+
return {
|
|
81
|
+
snapshot: timeline.snapshot(filter, { limit }),
|
|
82
|
+
text: timeline.format(filter, { limit }),
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** A filter as JSON, with RegExps and callbacks spelled out instead of lost. */
|
|
88
|
+
function describeFilter(filter) {
|
|
89
|
+
return JSON.stringify(filter, (_key, value) => {
|
|
90
|
+
if (value instanceof RegExp)
|
|
91
|
+
return value.toString();
|
|
92
|
+
if (typeof value === "function")
|
|
93
|
+
return "[function]";
|
|
94
|
+
return value;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=reads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reads.js","sourceRoot":"","sources":["../../../../src/widgets/stage/lib/reads.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAYrE;;;;GAIG;AACH,MAAM,YAAY,GAAG,KAAK,CAAC;AAO3B;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAe;IAC1C,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IACvC,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;IAEtC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAS,EAAE;QAC7C,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,MAAM,KAAK,SAAS;YACvB,MAAM,IAAI,cAAc,CACvB,kBAAkB,EAClB,QAAQ,CAAC,OAAO,GAAG,CAAC;gBACnB,CAAC,CAAC,cAA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C,MAAM,2BAA2B,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,EAAE,EACpK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CACtD,CAAC;gBACH,MAAM,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;YAClD,CAAC;QACF,CAAC;QACD,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,EAAE;YAC1B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,YAAY,CAAC;YAC5C,OAAO;gBACN,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC;gBAC9C,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC;aACxC,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,SAAS,cAAc,CAAC,MAAmB;IAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,KAAc,EAAE,EAAE;QACtD,IAAI,KAAK,YAAY,MAAM;YAAE,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;QACrD,IAAI,OAAO,KAAK,KAAK,UAAU;YAAE,OAAO,YAAY,CAAC;QACrD,OAAO,KAAK,CAAC;IACd,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import type { ResponseStream, StreamEnd } from "../../../entities/plugin/index.js";
|
|
3
|
+
/** A stream as the stage serves it: the rule's end of it, and the stage's. */
|
|
4
|
+
export interface ServedStream {
|
|
5
|
+
/** What the rule writes. */
|
|
6
|
+
readonly stream: ResponseStream;
|
|
7
|
+
/** The stub asked for the end, and `closed` is on its way. */
|
|
8
|
+
readonly closing: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The rule writing the stream failed: answer 500 with `body` while
|
|
11
|
+
* nothing has gone out, and cut the connection after. False when the
|
|
12
|
+
* response was over first — ended, cut, or let go of by the page.
|
|
13
|
+
*/
|
|
14
|
+
fail(body: string): boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A Node response as the stream a rule writes: the adapter between the
|
|
18
|
+
* stream server's sockets and the plugin contract, which knows nothing of
|
|
19
|
+
* Node. `onClose` hears how the response ended before `closed` resolves, so
|
|
20
|
+
* whoever awaits `closed` finds the end already on record.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createResponseStream(request: IncomingMessage, response: ServerResponse, onClose: (end: StreamEnd, failed: boolean) => void): ServedStream;
|
|
23
|
+
//# sourceMappingURL=response-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-stream.d.ts","sourceRoot":"","sources":["../../../../src/widgets/stage/lib/response-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,eAAe,EAEf,cAAc,EACd,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EACX,cAAc,EACd,SAAS,EACT,MAAM,mCAAmC,CAAC;AAK3C,8EAA8E;AAC9E,MAAM,WAAW,YAAY;IAC5B,4BAA4B;IAC5B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,GAChD,YAAY,CAoGd"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { createDeferred } from "../../../shared/lib/async/index.js";
|
|
2
|
+
import { toBytes } from "../../../shared/lib/bytes/index.js";
|
|
3
|
+
import { WirestageError } from "../../../shared/lib/errors/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* A Node response as the stream a rule writes: the adapter between the
|
|
6
|
+
* stream server's sockets and the plugin contract, which knows nothing of
|
|
7
|
+
* Node. `onClose` hears how the response ended before `closed` resolves, so
|
|
8
|
+
* whoever awaits `closed` finds the end already on record.
|
|
9
|
+
*/
|
|
10
|
+
export function createResponseStream(request, response, onClose) {
|
|
11
|
+
let state = "open";
|
|
12
|
+
let failed = false;
|
|
13
|
+
const closed = createDeferred();
|
|
14
|
+
response.once("close", () => {
|
|
15
|
+
// Not ended and not cut: the page let go of it.
|
|
16
|
+
const end = state === "open" ? "cancelled" : state;
|
|
17
|
+
onClose(end, failed);
|
|
18
|
+
closed.resolve(end);
|
|
19
|
+
});
|
|
20
|
+
/** The stream server's own headers (CORS, `connection`), before the rule's. */
|
|
21
|
+
const own = Object.entries(response.getHeaders());
|
|
22
|
+
/** Back to those: what a rule's head set is gone, what it replaced is back. */
|
|
23
|
+
const restore = () => {
|
|
24
|
+
for (const name of response.getHeaderNames())
|
|
25
|
+
response.removeHeader(name);
|
|
26
|
+
for (const [name, value] of own)
|
|
27
|
+
response.setHeader(name, value);
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Whether a write can reach the page. Node drops a write — callback and
|
|
31
|
+
* all — into a socket destroyed or closed for writing, which is what the
|
|
32
|
+
* page letting go leaves, well before the response reports its close.
|
|
33
|
+
*/
|
|
34
|
+
const writable = () => state === "open" && response.socket?.writable === true;
|
|
35
|
+
const requestHeaders = {};
|
|
36
|
+
for (const [name, value] of Object.entries(request.headers))
|
|
37
|
+
requestHeaders[name] = String(value);
|
|
38
|
+
return {
|
|
39
|
+
stream: {
|
|
40
|
+
requestHeaders,
|
|
41
|
+
head(status, headers = {}) {
|
|
42
|
+
// Node checks a status only as the head goes out, and refused by
|
|
43
|
+
// `end()` it leaves the response broken: a 500 after it has no body.
|
|
44
|
+
if (!Number.isInteger(status) || status < 100 || status > 999)
|
|
45
|
+
throw new WirestageError("INVALID_ARGUMENT", `a response status is an integer from 100 to 999, got ${status}`);
|
|
46
|
+
// Kept off the wire until the first write or flush, so a rule that
|
|
47
|
+
// fails before then can still be answered with its 500.
|
|
48
|
+
restore();
|
|
49
|
+
response.statusCode = status;
|
|
50
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
51
|
+
// The stream server's to say: one response per connection.
|
|
52
|
+
if (name.toLowerCase() === "connection")
|
|
53
|
+
continue;
|
|
54
|
+
// Several values, one per line (`set-cookie`): Node sends a
|
|
55
|
+
// header line for each, and refuses a value with a newline.
|
|
56
|
+
const values = value.split("\n");
|
|
57
|
+
response.setHeader(name, values.length > 1 ? values : value);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
flush() {
|
|
61
|
+
response.flushHeaders();
|
|
62
|
+
},
|
|
63
|
+
write(chunk) {
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
if (!writable()) {
|
|
66
|
+
reject(new WirestageError("CLOSED", "the response stream is closed"));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
response.write(toBytes(chunk), (error) => error ? reject(error) : resolve());
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
async end() {
|
|
73
|
+
if (writable()) {
|
|
74
|
+
state = "ended";
|
|
75
|
+
response.end();
|
|
76
|
+
}
|
|
77
|
+
await closed.promise;
|
|
78
|
+
},
|
|
79
|
+
cut() {
|
|
80
|
+
if (!writable())
|
|
81
|
+
return;
|
|
82
|
+
state = "cut";
|
|
83
|
+
response.destroy();
|
|
84
|
+
},
|
|
85
|
+
closed: closed.promise,
|
|
86
|
+
},
|
|
87
|
+
get closing() {
|
|
88
|
+
return state !== "open" && !closed.settled;
|
|
89
|
+
},
|
|
90
|
+
fail(body) {
|
|
91
|
+
if (!writable())
|
|
92
|
+
return false;
|
|
93
|
+
failed = true;
|
|
94
|
+
if (response.headersSent) {
|
|
95
|
+
state = "cut";
|
|
96
|
+
response.destroy();
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
state = "ended";
|
|
100
|
+
restore();
|
|
101
|
+
response
|
|
102
|
+
.writeHead(500, { "content-type": "text/plain; charset=utf-8" })
|
|
103
|
+
.end(body);
|
|
104
|
+
return true;
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=response-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-stream.js","sourceRoot":"","sources":["../../../../src/widgets/stage/lib/response-stream.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAgBrE;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CACnC,OAAwB,EACxB,QAAwB,EACxB,OAAkD;IAElD,IAAI,KAAK,GAA6B,MAAM,CAAC;IAC7C,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,MAAM,MAAM,GAAG,cAAc,EAAa,CAAC;IAC3C,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;QAC3B,gDAAgD;QAChD,MAAM,GAAG,GAAG,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC;QACnD,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACrB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;IACH,+EAA+E;IAC/E,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,C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C;QACD,IAAI,CAAC,IAAI;YACR,IAAI,CAAC,QAAQ,EAAE;gBAAE,OAAO,KAAK,CAAC;YAC9B,MAAM,GAAG,IAAI,CAAC;YACd,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;gBAC1B,KAAK,GAAG,KAAK,CAAC;gBACd,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO,IAAI,CAAC;YACb,CAAC;YACD,KAAK,GAAG,OAAO,CAAC;YAChB,OAAO,EAAE,CAAC;YACV,QAAQ;iBACN,SAAS,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,2BAA2B,EAAE,CAAC;iBAC/D,GAAG,CAAC,IAAI,CAAC,CAAC;YACZ,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Timeline } from "../../../entities/frame/index.js";
|
|
2
|
+
import type { SocketRouter } from "../../../entities/plugin/index.js";
|
|
3
|
+
import type { ScopedLogger } from "../../../shared/lib/logger/index.js";
|
|
4
|
+
import type { AttachedContext } from "./attached-context.js";
|
|
5
|
+
export interface SocketRouterDeps {
|
|
6
|
+
readonly timeline: Timeline;
|
|
7
|
+
readonly log: ScopedLogger;
|
|
8
|
+
readonly correlation: () => string;
|
|
9
|
+
}
|
|
10
|
+
export interface SocketRouterEngine extends SocketRouter {
|
|
11
|
+
attach(attachment: AttachedContext): Promise<void>;
|
|
12
|
+
detach(attachment: AttachedContext): void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Turns WebSocket rules into ONE Playwright WebSocket route per attached
|
|
16
|
+
* context, whose predicate asks the live rule list.
|
|
17
|
+
*
|
|
18
|
+
* One route, because Playwright cannot take a WebSocket route out again: a
|
|
19
|
+
* removed rule, or a detached context, simply stops matching, which sends the
|
|
20
|
+
* socket to the real server. And not before it is needed, because routing
|
|
21
|
+
* replaces `WebSocket` in every document of the context — the first rule
|
|
22
|
+
* installs it, or `prepare()` does at attach.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createSocketRouter(deps: SocketRouterDeps): SocketRouterEngine;
|
|
25
|
+
//# sourceMappingURL=socket-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket-router.d.ts","sourceRoot":"","sources":["../../../../src/widgets/stage/lib/socket-router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,KAAK,EAEX,YAAY,EAIZ,MAAM,mCAAmC,CAAC;AAI3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,MAAM,CAAC;CACnC;AAED,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACvD,MAAM,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,MAAM,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI,CAAC;CAC1C;AA8CD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,GAAG,kBAAkB,CA2N7E"}
|