@heojeongbo/wirestage 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +126 -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 +102 -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 +43 -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 +120 -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 +62 -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 +107 -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 +129 -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 +117 -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 +43 -0
- package/dist/shared/api/stream-server/stream-server.d.ts.map +1 -0
- package/dist/shared/api/stream-server/stream-server.js +160 -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 +248 -0
- package/dist/widgets/stage/lib/create-stage.js.map +1 -0
- package/dist/widgets/stage/lib/http-router.d.ts +35 -0
- package/dist/widgets/stage/lib/http-router.d.ts.map +1 -0
- package/dist/widgets/stage/lib/http-router.js +455 -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 +9 -0
- package/dist/widgets/stage/lib/response-stream.d.ts.map +1 -0
- package/dist/widgets/stage/lib/response-stream.js +56 -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 +204 -0
- package/dist/widgets/stage/lib/socket-router.js.map +1 -0
- package/dist/widgets/stage/model/stage.d.ts +86 -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 +147 -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 +108 -0
- package/src/entities/plugin/model/stream.ts +43 -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 +128 -0
- package/src/features/sse/lib/encode.ts +28 -0
- package/src/features/sse/model/types.ts +66 -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 +141 -0
- package/src/features/websocket/lib/wire.ts +78 -0
- package/src/features/websocket/model/types.ts +130 -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 +145 -0
- package/src/shared/api/stream-server/index.ts +7 -0
- package/src/shared/api/stream-server/stream-server.ts +246 -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 +305 -0
- package/src/widgets/stage/lib/http-router.ts +620 -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 +66 -0
- package/src/widgets/stage/lib/socket-router.ts +271 -0
- package/src/widgets/stage/model/stage.ts +108 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { WirestageError } from "../../../shared/lib/errors/index.js";
|
|
2
|
+
import { buildPageScript, commandRuntime, detachRuntime, flushRuntime, } from "./page-runtime.js";
|
|
3
|
+
/** How to take a hook back out, where this Playwright can. */
|
|
4
|
+
const remover = (handle) => handle?.dispose === undefined
|
|
5
|
+
? undefined
|
|
6
|
+
: () => handle.dispose();
|
|
7
|
+
/**
|
|
8
|
+
* Node half of the page host: one binding and one init script per context,
|
|
9
|
+
* carrying every registered module.
|
|
10
|
+
*
|
|
11
|
+
* Modules are sealed at the first attach. An init script cannot be amended
|
|
12
|
+
* after the fact, so a module registered later would silently be missing from
|
|
13
|
+
* pages of the contexts already attached; failing loudly is the better DX.
|
|
14
|
+
*/
|
|
15
|
+
export function createPageHost(deps) {
|
|
16
|
+
const modules = new Map();
|
|
17
|
+
const attachments = new Set();
|
|
18
|
+
const installed = new WeakMap();
|
|
19
|
+
const binding = `__wirestage_${deps.stage}`;
|
|
20
|
+
const { flushMs, timeoutMs } = deps;
|
|
21
|
+
let sealed = false;
|
|
22
|
+
/** Every frame of every open page: page hooks run in iframes too. */
|
|
23
|
+
const openFrames = (among, pageFilter) => {
|
|
24
|
+
const frames = [];
|
|
25
|
+
for (const attachment of among)
|
|
26
|
+
for (const page of attachment.context.pages())
|
|
27
|
+
if (!page.isClosed() &&
|
|
28
|
+
(pageFilter === undefined || deps.pageId(page) === pageFilter))
|
|
29
|
+
frames.push(...page.frames());
|
|
30
|
+
return frames;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* `work`'s value, or undefined once `timeoutMs` have passed — with `late`
|
|
34
|
+
* logged, and the work left to finish on its own.
|
|
35
|
+
*/
|
|
36
|
+
const inTime = async (work, late) => {
|
|
37
|
+
const waiting = new AbortController();
|
|
38
|
+
try {
|
|
39
|
+
return await Promise.race([
|
|
40
|
+
work.then((value) => ({ value })),
|
|
41
|
+
deps.clock.sleep(timeoutMs, waiting.signal).then(() => {
|
|
42
|
+
deps.log.warn(late, { timeoutMs });
|
|
43
|
+
return undefined;
|
|
44
|
+
},
|
|
45
|
+
// The work finished first.
|
|
46
|
+
() => undefined),
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
waiting.abort();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Evaluate in one frame, within the time a frame is given. A frame that
|
|
55
|
+
* is navigating or gone has nothing to say, which is not a failure.
|
|
56
|
+
*/
|
|
57
|
+
const ask = async (frame, pageFunction, arg, what) => {
|
|
58
|
+
try {
|
|
59
|
+
return await inTime(frame.evaluate(pageFunction, arg), `a frame did not answer a ${what} in time and was passed over; what it recorded may be missing (is a dialog open?)`);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
deps.log.debug(`${what} skipped`, {}, error);
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Take the binding or the init script back out, within the same time.
|
|
68
|
+
* Playwright's `dispose()` reaches every page of the context, and a page
|
|
69
|
+
* with a dialog open answers nothing until the dialog closes: a detach
|
|
70
|
+
* that waited for it would hang the test's teardown.
|
|
71
|
+
*/
|
|
72
|
+
const release = async (remove, what) => {
|
|
73
|
+
try {
|
|
74
|
+
await inTime(remove(), `the page ${what} was not taken out in time; detaching goes on, and Playwright removes it once the page responds (is a dialog open?)`);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
// A context that closed first took it with it.
|
|
78
|
+
deps.log.debug("page hook already gone", {}, error);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const receive = (source, message, attachment) => {
|
|
82
|
+
if (message.type === "hello") {
|
|
83
|
+
const states = {};
|
|
84
|
+
for (const [id, module] of modules)
|
|
85
|
+
try {
|
|
86
|
+
states[id] = module.state();
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
// One plugin's bug: its module starts without a state, every
|
|
90
|
+
// other module with its own, and the log says whose it was.
|
|
91
|
+
deps.log.error("page module failed to give its state", { module: id }, error);
|
|
92
|
+
}
|
|
93
|
+
return states;
|
|
94
|
+
}
|
|
95
|
+
const page = deps.pageId(source.page);
|
|
96
|
+
if (message.type === "failure") {
|
|
97
|
+
deps.log.error(`page module failed in its ${message.handler} handler`, { module: message.module, page }, message.error);
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
const byModule = new Map();
|
|
101
|
+
for (const { module, entry } of message.entries) {
|
|
102
|
+
const list = byModule.get(module) ?? [];
|
|
103
|
+
list.push(entry);
|
|
104
|
+
byModule.set(module, list);
|
|
105
|
+
}
|
|
106
|
+
for (const [id, entries] of byModule) {
|
|
107
|
+
const module = modules.get(id);
|
|
108
|
+
if (module === undefined)
|
|
109
|
+
continue;
|
|
110
|
+
try {
|
|
111
|
+
module.receive(entries, { page, context: attachment.id });
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
deps.log.error("page module failed to receive entries", { module: id }, error);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
};
|
|
119
|
+
const command = async (module, op, args, options = {}) => {
|
|
120
|
+
// No module, no runtime handler: a frame would have nothing to answer.
|
|
121
|
+
if (!modules.has(module))
|
|
122
|
+
return [];
|
|
123
|
+
const results = await Promise.all(openFrames(attachments, options.page).map((frame) => ask(frame, commandRuntime, { binding, module, op, args }, "command")));
|
|
124
|
+
const answers = [];
|
|
125
|
+
const failures = [];
|
|
126
|
+
for (const result of results) {
|
|
127
|
+
// No answer, or a frame the init script never ran in.
|
|
128
|
+
const outcome = result?.value;
|
|
129
|
+
if (outcome === undefined)
|
|
130
|
+
continue;
|
|
131
|
+
if ("error" in outcome)
|
|
132
|
+
failures.push(outcome.error);
|
|
133
|
+
else
|
|
134
|
+
answers.push(outcome.value);
|
|
135
|
+
}
|
|
136
|
+
if (failures.length > 0)
|
|
137
|
+
// Not "no frame answered": the module's own code failed in the page.
|
|
138
|
+
throw new WirestageError("INVALID_STATE", `page module "${module}" failed to run "${op}" in ${failures.length} frame(s): ${failures[0]}`, { details: { module, op, failures } });
|
|
139
|
+
return answers;
|
|
140
|
+
};
|
|
141
|
+
return {
|
|
142
|
+
register(module) {
|
|
143
|
+
if (sealed)
|
|
144
|
+
throw new WirestageError("INVALID_STATE", `page module "${module.id}" registered after the stage was attached; register every plugin before calling attach()`);
|
|
145
|
+
if (modules.has(module.id))
|
|
146
|
+
throw new WirestageError("INVALID_ARGUMENT", `page module "${module.id}" is already registered`);
|
|
147
|
+
try {
|
|
148
|
+
// Parsed the way the init script will use it. A source that is
|
|
149
|
+
// not an expression — a method, a bound or a native function —
|
|
150
|
+
// is a SyntaxError there that takes every module down with it,
|
|
151
|
+
// and nothing in Node would say so.
|
|
152
|
+
new Function(`return (${module.install.toString()});`);
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
throw new WirestageError("INVALID_ARGUMENT", `page module "${module.id}" cannot run in the page: its install does not serialize to a function expression (${String(error)}); declare it with \`function\` or as an arrow function, not as an object method or a bound function`, { cause: error });
|
|
156
|
+
}
|
|
157
|
+
modules.set(module.id, module);
|
|
158
|
+
},
|
|
159
|
+
async attach(attachment) {
|
|
160
|
+
sealed = true;
|
|
161
|
+
attachments.add(attachment);
|
|
162
|
+
if (modules.size === 0)
|
|
163
|
+
return;
|
|
164
|
+
const before = installed.get(attachment.context);
|
|
165
|
+
if (before !== undefined) {
|
|
166
|
+
// Still in the context from an earlier attach this Playwright
|
|
167
|
+
// could not take back: point it at the new attachment.
|
|
168
|
+
before.current = attachment;
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const slot = { current: attachment };
|
|
172
|
+
installed.set(attachment.context, slot);
|
|
173
|
+
const installers = {};
|
|
174
|
+
for (const [id, module] of modules)
|
|
175
|
+
installers[id] = module.install;
|
|
176
|
+
try {
|
|
177
|
+
slot.removeBinding = remover((await attachment.context.exposeBinding(binding, (source, message) => slot.current === undefined
|
|
178
|
+
? undefined
|
|
179
|
+
: receive(source, message, slot.current))));
|
|
180
|
+
slot.removeScript = remover((await attachment.context.addInitScript({
|
|
181
|
+
content: buildPageScript({
|
|
182
|
+
binding,
|
|
183
|
+
flushMs,
|
|
184
|
+
modules: [...modules].map(([id, m]) => ({
|
|
185
|
+
id,
|
|
186
|
+
config: m.config,
|
|
187
|
+
})),
|
|
188
|
+
}, installers),
|
|
189
|
+
})));
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
installed.delete(attachment.context);
|
|
193
|
+
// A binding left behind would make the next attach fail with
|
|
194
|
+
// "already registered".
|
|
195
|
+
if (slot.removeBinding !== undefined)
|
|
196
|
+
await release(slot.removeBinding, "binding");
|
|
197
|
+
throw error;
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
async detach(attachment) {
|
|
201
|
+
if (!attachments.delete(attachment))
|
|
202
|
+
return;
|
|
203
|
+
const slot = installed.get(attachment.context);
|
|
204
|
+
if (slot === undefined)
|
|
205
|
+
return;
|
|
206
|
+
const { removeBinding, removeScript } = slot;
|
|
207
|
+
// A Playwright that cannot take a binding or an init script back
|
|
208
|
+
// leaves them in the context, switched off; they serve it again if
|
|
209
|
+
// it is attached again.
|
|
210
|
+
const removable = removeBinding !== undefined && removeScript !== undefined;
|
|
211
|
+
if (removable) {
|
|
212
|
+
installed.delete(attachment.context);
|
|
213
|
+
// The init script first: a document that loaded while the open
|
|
214
|
+
// ones were being detached would start a runtime no detach
|
|
215
|
+
// reaches, and then lose its binding under it.
|
|
216
|
+
await release(removeScript, "init script");
|
|
217
|
+
}
|
|
218
|
+
// Undo the hooks in the documents that are open, and take what they
|
|
219
|
+
// still hold, while the binding is there to carry it.
|
|
220
|
+
await Promise.all(openFrames([attachment]).map((frame) => ask(frame, detachRuntime, binding, "detach")));
|
|
221
|
+
slot.current = undefined;
|
|
222
|
+
if (removable)
|
|
223
|
+
await release(removeBinding, "binding");
|
|
224
|
+
},
|
|
225
|
+
async sync() {
|
|
226
|
+
if (modules.size === 0)
|
|
227
|
+
return;
|
|
228
|
+
await Promise.all(openFrames(attachments).map((frame) => ask(frame, flushRuntime, binding, "flush")));
|
|
229
|
+
},
|
|
230
|
+
command,
|
|
231
|
+
async refresh(module) {
|
|
232
|
+
const target = modules.get(module);
|
|
233
|
+
if (target === undefined)
|
|
234
|
+
throw new WirestageError("INVALID_ARGUMENT", `no page module "${module}" is registered`);
|
|
235
|
+
await command(module, "__state", target.state());
|
|
236
|
+
},
|
|
237
|
+
pageId: deps.pageId,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=page-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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gBAC/C,MAAM,OAAO,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;YAC5C,CAAC;YACD,oEAAoE;YACpE,sDAAsD;YACtD,MAAM,OAAO,CAAC,GAAG,CAChB,UAAU,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACtC,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,CAAC,CAC5C,CACD,CAAC;YACF,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;YACzB,IAAI,SAAS;gBAAE,MAAM,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;QACxD,CAAC;QACD,KAAK,CAAC,IAAI;YACT,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC;gBAAE,OAAO;YAC/B,MAAM,OAAO,CAAC,GAAG,CAChB,UAAU,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACrC,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAC1C,CACD,CAAC;QACH,CAAC;QACD,OAAO;QACP,KAAK,CAAC,OAAO,CAAC,MAAM;YACnB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACnC,IAAI,MAAM,KAAK,SAAS;gBACvB,MAAM,IAAI,cAAc,CACvB,kBAAkB,EAClB,mBAAmB,MAAM,iBAAiB,CAC1C,CAAC;YACH,MAAM,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QAClD,CAAC;QACD,MAAM,EAAE,IAAI,CAAC,MAAM;KACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
export interface PageRuntimeInit {
|
|
7
|
+
/** The binding Node exposed; also the runtime's key in `__wirestage`. */
|
|
8
|
+
readonly binding: string;
|
|
9
|
+
/** How long entries may wait for company before the batch is flushed. */
|
|
10
|
+
readonly flushMs: number;
|
|
11
|
+
readonly modules: readonly {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly config: unknown;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
/** Messages the runtime sends through the binding. */
|
|
17
|
+
export type RuntimeMessage = {
|
|
18
|
+
readonly type: "hello";
|
|
19
|
+
} | {
|
|
20
|
+
readonly type: "entries";
|
|
21
|
+
readonly entries: readonly {
|
|
22
|
+
readonly module: string;
|
|
23
|
+
readonly entry: unknown;
|
|
24
|
+
}[];
|
|
25
|
+
} | {
|
|
26
|
+
/** A module's own handler threw, with no call to reject: Node logs it. */
|
|
27
|
+
readonly type: "failure";
|
|
28
|
+
readonly module: string;
|
|
29
|
+
/** `install`, `onState` or `onDetach`. */
|
|
30
|
+
readonly handler: string;
|
|
31
|
+
readonly error: string;
|
|
32
|
+
};
|
|
33
|
+
/** What the runtime publishes on `globalThis.__wirestage[binding]`. */
|
|
34
|
+
export interface RuntimeHandle {
|
|
35
|
+
flush(): Promise<unknown>;
|
|
36
|
+
command(module: string, op: string, args: unknown): unknown;
|
|
37
|
+
/** Undo every module's hooks, send what is still held, and step aside. */
|
|
38
|
+
detach(): Promise<unknown>;
|
|
39
|
+
}
|
|
40
|
+
/** A command's answer, or why its handler failed. */
|
|
41
|
+
export type CommandResult = {
|
|
42
|
+
readonly value: unknown;
|
|
43
|
+
} | {
|
|
44
|
+
readonly error: string;
|
|
45
|
+
};
|
|
46
|
+
type Installer = (env: unknown) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Install every module, batch what they emit, and answer Node's flushes and
|
|
49
|
+
* commands.
|
|
50
|
+
*
|
|
51
|
+
* Batching is what keeps a 60 Hz channel cheap: one binding call per flush
|
|
52
|
+
* window instead of one per message. The first entry after a quiet spell is
|
|
53
|
+
* not held back, though — it leaves at once, so it reaches Node ahead of a
|
|
54
|
+
* request the page makes right after it and the two land on the timeline in
|
|
55
|
+
* the order they happened.
|
|
56
|
+
*
|
|
57
|
+
* `flush()` returns the binding's promise, so a Node-side `evaluate(flush)`
|
|
58
|
+
* resolves only after Node has appended the entries: a read that flushes
|
|
59
|
+
* first sees everything the page recorded before it.
|
|
60
|
+
*
|
|
61
|
+
* Nothing the runtime does throws into the page's own code: a module whose
|
|
62
|
+
* handler throws is reported to Node, and a binding that has been taken away
|
|
63
|
+
* makes the runtime step aside.
|
|
64
|
+
*/
|
|
65
|
+
export declare function pageRuntime(scope: Record<string, unknown>, init: PageRuntimeInit, installers: Record<string, Installer>): void;
|
|
66
|
+
/** Flush one frame's runtime. Runs in the page via `frame.evaluate`. */
|
|
67
|
+
export declare function flushRuntime(binding: string): Promise<unknown> | undefined;
|
|
68
|
+
/** Detach one frame's runtime. Runs in the page via `frame.evaluate`. */
|
|
69
|
+
export declare function detachRuntime(binding: string): Promise<unknown> | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Run one command in one frame's runtime. Runs in the page via
|
|
72
|
+
* `frame.evaluate`. Undefined when the frame has no runtime (a document the
|
|
73
|
+
* init script never ran in); otherwise the handler's answer, or its failure
|
|
74
|
+
* as text — an exception would cross back to Node as a rejected evaluate,
|
|
75
|
+
* indistinguishable from a frame that went away.
|
|
76
|
+
*/
|
|
77
|
+
export declare function commandRuntime(arg: {
|
|
78
|
+
readonly binding: string;
|
|
79
|
+
readonly module: string;
|
|
80
|
+
readonly op: string;
|
|
81
|
+
readonly args: unknown;
|
|
82
|
+
}): Promise<CommandResult> | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* The init script: the runtime, then every installer, then the call.
|
|
85
|
+
*
|
|
86
|
+
* Wrapped in a scope that defines `__name`: esbuild's `keepNames` (on by
|
|
87
|
+
* default in tsx) rewrites `const f = () => {}` into `__name(() => {}, "f")`,
|
|
88
|
+
* so code serialized from a tsx-run process calls a helper the page does not
|
|
89
|
+
* have, and the whole runtime dies with "__name is not defined".
|
|
90
|
+
*/
|
|
91
|
+
export declare function buildPageScript(init: PageRuntimeInit, installers: Readonly<Record<string, Installer>>): string;
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=page-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-runtime.d.ts","sourceRoot":"","sources":["../../../../src/widgets/stage/lib/page-runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,eAAe;IAC/B,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,SAAS;QAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;KACzB,EAAE,CAAC;CACJ;AAED,sDAAsD;AACtD,MAAM,MAAM,cAAc,GACvB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1B;IACA,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,SAAS;QAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;KACxB,EAAE,CAAC;CACH,GACD;IACA,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACtB,CAAC;AAEL,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC7B,KAAK,IAAI,OAAO,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AAM,EAAE,SAAS,CAAC,CAAC,GAC7C,MAAM,CAKR"}
|
|
@@ -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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,KAAK,EAAE,CAAC,EACrC,CAAC,KAAc,EAAiB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAC7D,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC9B,IAAqB,EACrB,UAA+C;IAE/C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;SACrC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACxE,IAAI,CAAC,KAAK,CAAC,CAAC;IACd,OAAO,kDAAkD,WAAW,CAAC,QAAQ,EAAE,iBAAiB,IAAI,CAAC,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"}
|