@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,135 @@
|
|
|
1
|
+
import type { UrlMatcher } from "../../../shared/lib/match/index.js";
|
|
2
|
+
import type { ResponseStream } from "./stream.js";
|
|
3
|
+
/**
|
|
4
|
+
* A request a rule is deciding about, read-only and decoded on demand.
|
|
5
|
+
*
|
|
6
|
+
* One per request: every rule the request reaches is given this same object,
|
|
7
|
+
* so a plugin may key what it knows about a request on it (a `WeakMap`), and
|
|
8
|
+
* the frames different rules record for one request share one `correlation`.
|
|
9
|
+
*/
|
|
10
|
+
export interface HttpRequestView {
|
|
11
|
+
/** Links every frame of this exchange. */
|
|
12
|
+
readonly correlation: string;
|
|
13
|
+
readonly method: string;
|
|
14
|
+
readonly url: URL;
|
|
15
|
+
/** Lower-cased names. */
|
|
16
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
17
|
+
/** The page that sent it; undefined for service-worker requests. */
|
|
18
|
+
readonly page: string | undefined;
|
|
19
|
+
readonly context: string;
|
|
20
|
+
readonly resourceType: string;
|
|
21
|
+
body(): Uint8Array;
|
|
22
|
+
text(): string;
|
|
23
|
+
json<T = unknown>(): T;
|
|
24
|
+
}
|
|
25
|
+
/** Playwright's `route.abort` error codes. */
|
|
26
|
+
export type AbortErrorCode = "aborted" | "accessdenied" | "addressunreachable" | "blockedbyclient" | "blockedbyresponse" | "connectionaborted" | "connectionclosed" | "connectionfailed" | "connectionrefused" | "connectionreset" | "internetdisconnected" | "namenotresolved" | "timedout" | "failed";
|
|
27
|
+
/**
|
|
28
|
+
* What a rule decided. A closed union: the router carries each member out
|
|
29
|
+
* through a table keyed by `type`, so a new outcome does not compile until
|
|
30
|
+
* the router knows what to do with it.
|
|
31
|
+
*/
|
|
32
|
+
export type HttpOutcome =
|
|
33
|
+
/**
|
|
34
|
+
* Answer with a complete response. A header may carry several values
|
|
35
|
+
* separated by a newline: `set-cookie` is sent as a header line each,
|
|
36
|
+
* any other header as one value, `, `-separated. A header Chromium
|
|
37
|
+
* would refuse — a name that is not a token, a CR or NUL in a value — is
|
|
38
|
+
* the rule's error.
|
|
39
|
+
*/
|
|
40
|
+
{
|
|
41
|
+
readonly type: "fulfill";
|
|
42
|
+
readonly status?: number;
|
|
43
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
44
|
+
readonly body?: Uint8Array | string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Answer with a response that stays open (server streams, SSE): `open`
|
|
48
|
+
* gets the stream to write. The request is redirected to the stage's
|
|
49
|
+
* local stream server, which `route.fulfill` cannot stand in for because
|
|
50
|
+
* it takes the whole body at once. An `open` that throws is the rule's
|
|
51
|
+
* error, as a throwing `handle` is: the page gets the 500 while nothing
|
|
52
|
+
* has gone out, and a cut connection after.
|
|
53
|
+
*/
|
|
54
|
+
| {
|
|
55
|
+
readonly type: "stream";
|
|
56
|
+
open(stream: ResponseStream): void | Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Send to the network, optionally rewritten. Lower rules are skipped.
|
|
60
|
+
* `url` may be relative to the request's, and keeps its scheme:
|
|
61
|
+
* Playwright rewrites a URL within its scheme only.
|
|
62
|
+
*/
|
|
63
|
+
| {
|
|
64
|
+
readonly type: "continue";
|
|
65
|
+
readonly url?: string;
|
|
66
|
+
readonly method?: string;
|
|
67
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
68
|
+
readonly body?: Uint8Array | string;
|
|
69
|
+
}
|
|
70
|
+
/** Let the next matching rule (or the network) decide. */
|
|
71
|
+
| {
|
|
72
|
+
readonly type: "fallback";
|
|
73
|
+
}
|
|
74
|
+
/** Fail the request at the network level. */
|
|
75
|
+
| {
|
|
76
|
+
readonly type: "abort";
|
|
77
|
+
readonly error?: AbortErrorCode;
|
|
78
|
+
};
|
|
79
|
+
/** The network's answer to a request a rule passed through. */
|
|
80
|
+
export interface PassthroughResponse {
|
|
81
|
+
readonly status: number;
|
|
82
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
83
|
+
/** Undefined when the browser did not keep the body (redirects, some errors). */
|
|
84
|
+
readonly body: Uint8Array | undefined;
|
|
85
|
+
}
|
|
86
|
+
export interface HttpRule {
|
|
87
|
+
/** The `protocol` of the frames this rule records. */
|
|
88
|
+
readonly protocol: string;
|
|
89
|
+
/** Names the rule in logs and diagnostics. */
|
|
90
|
+
readonly label: string;
|
|
91
|
+
readonly url: UrlMatcher;
|
|
92
|
+
/** Upper-case HTTP methods. Any method when omitted. */
|
|
93
|
+
readonly method?: string | readonly string[];
|
|
94
|
+
/** Stop matching after this many handled requests. */
|
|
95
|
+
readonly times?: number;
|
|
96
|
+
/** A last, request-aware condition; false falls back to the next rule. */
|
|
97
|
+
readonly match?: (request: HttpRequestView) => boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Record the raw request and how it ended as frames. Default true. A plugin
|
|
100
|
+
* that records decoded frames of its own (Connect) turns this off. A
|
|
101
|
+
* request several recording rules of one protocol see is recorded once.
|
|
102
|
+
*/
|
|
103
|
+
readonly record?: boolean;
|
|
104
|
+
/** The frame endpoint for a request. Defaults to the URL path. */
|
|
105
|
+
readonly endpoint?: (request: HttpRequestView) => string;
|
|
106
|
+
handle(request: HttpRequestView): HttpOutcome | Promise<HttpOutcome>;
|
|
107
|
+
/**
|
|
108
|
+
* Called with the network's response to a request this rule passed on
|
|
109
|
+
* (`continue` or `fallback`). Not called when another rule answered it:
|
|
110
|
+
* that response is a stub's, not the network's.
|
|
111
|
+
*/
|
|
112
|
+
readonly onPassthroughResponse?: (response: PassthroughResponse, request: HttpRequestView) => void;
|
|
113
|
+
/**
|
|
114
|
+
* Called when a request this rule passed on failed at the network level,
|
|
115
|
+
* with the browser's error text (`net::ERR_CONNECTION_RESET`, ...).
|
|
116
|
+
*/
|
|
117
|
+
readonly onPassthroughFailure?: (error: string | undefined, request: HttpRequestView) => void;
|
|
118
|
+
}
|
|
119
|
+
export interface HttpRuleHandle {
|
|
120
|
+
/** Requests this rule handled (matched and decided), not merely saw. */
|
|
121
|
+
readonly hits: number;
|
|
122
|
+
readonly active: boolean;
|
|
123
|
+
/** Stop matching, in every attached context. */
|
|
124
|
+
remove(): Promise<void>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Where plugins put HTTP rules. Rules apply to every attached context, present
|
|
128
|
+
* and future. Later rules win, like Playwright routes and MSW's `use()`, so a
|
|
129
|
+
* test can override a suite-wide stub for one case; a rule that answers
|
|
130
|
+
* `fallback` hands the request to the next one down.
|
|
131
|
+
*/
|
|
132
|
+
export interface HttpRouter {
|
|
133
|
+
add(rule: HttpRule): Promise<HttpRuleHandle>;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["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AS,MAAM,EAAE,CAAC;IAC7C,sDAAsD;IACtD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC;IACvD;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC;IACzD,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACrE;;;;OAIG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAChC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE,eAAe,KACpB,IAAI,CAAC;IACV;;;OAGG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAC/B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,OAAO,EAAE,eAAe,KACpB,IAAI,CAAC;CACV;AAED,MAAM,WAAW,cAAc;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,gDAAgD;IAChD,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IAC1B,GAAG,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../src/entities/plugin/model/http.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { PagePort } from "../../../shared/api/playwright/index.js";
|
|
2
|
+
/** One thing an in-page module observed, on its way to the timeline. */
|
|
3
|
+
export interface PageEntry {
|
|
4
|
+
/** The module's own discriminator: `out`, `in`, `open`, ... */
|
|
5
|
+
readonly type: string;
|
|
6
|
+
/** Epoch milliseconds, by the page's clock. */
|
|
7
|
+
readonly at: number;
|
|
8
|
+
/** A binary payload, base64. */
|
|
9
|
+
readonly data?: string;
|
|
10
|
+
/** A text payload. */
|
|
11
|
+
readonly text?: string;
|
|
12
|
+
readonly meta?: Readonly<Record<string, unknown>>;
|
|
13
|
+
}
|
|
14
|
+
/** What the page runtime hands an installer, inside the page. */
|
|
15
|
+
export interface PageModuleEnv<State = unknown, Config = unknown> {
|
|
16
|
+
readonly window: Window & typeof globalThis;
|
|
17
|
+
readonly config: Config;
|
|
18
|
+
/**
|
|
19
|
+
* Queue an entry. Entries are batched and flushed to Node: a document
|
|
20
|
+
* that navigates sends what it holds on `beforeunload`, one that closes
|
|
21
|
+
* (or an iframe removed) on `pagehide`. What it emits after that, on its
|
|
22
|
+
* way out, can be lost.
|
|
23
|
+
*/
|
|
24
|
+
emit(entry: PageEntry): void;
|
|
25
|
+
/** The page's epoch-millisecond clock. */
|
|
26
|
+
now(): number;
|
|
27
|
+
/** Bytes to base64. */
|
|
28
|
+
encode(bytes: Uint8Array): string;
|
|
29
|
+
/** Base64 to bytes, in a fresh ArrayBuffer of exactly that size. */
|
|
30
|
+
decode(text: string): Uint8Array;
|
|
31
|
+
/** Answer a command the test sends with `PageHost.command`. */
|
|
32
|
+
onCommand(op: string, handler: (args: never) => unknown): void;
|
|
33
|
+
/**
|
|
34
|
+
* Receive the module's state: shortly after load (it comes from Node, so
|
|
35
|
+
* the document's first script may run before it), and on every change.
|
|
36
|
+
* One that throws does not keep the state from the others: it is logged
|
|
37
|
+
* in Node, or fails the `refresh()` that sent the state.
|
|
38
|
+
*/
|
|
39
|
+
onState(handler: (state: State) => void): void;
|
|
40
|
+
/**
|
|
41
|
+
* Undo what `install` did to the page: put back what was wrapped. Runs
|
|
42
|
+
* when the stage detaches, so a document that outlives the stage is left
|
|
43
|
+
* as the stage found it — and in a document the detach did not reach, as
|
|
44
|
+
* soon as the runtime finds the binding gone. One that throws does not
|
|
45
|
+
* stop the others, and is logged in Node while the binding lasts.
|
|
46
|
+
*/
|
|
47
|
+
onDetach(handler: () => void): void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Runs INSIDE the page, so it is serialized with `Function.prototype.toString`.
|
|
51
|
+
* It must be self-contained — no imports, no closure over module scope — and
|
|
52
|
+
* declared with `function`, since an object-method body does not serialize to
|
|
53
|
+
* a valid expression. `register` refuses one whose source is not a function
|
|
54
|
+
* expression: a method, a bound or a native function.
|
|
55
|
+
*/
|
|
56
|
+
export type PageInstaller<State = unknown, Config = unknown> = (env: PageModuleEnv<State, Config>) => void;
|
|
57
|
+
export interface PageSource {
|
|
58
|
+
readonly page: string;
|
|
59
|
+
readonly context: string;
|
|
60
|
+
}
|
|
61
|
+
export interface PageModule<State = unknown, Config = unknown> {
|
|
62
|
+
/** Unique per stage; the key commands and entries are routed by. */
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly install: PageInstaller<State, Config>;
|
|
65
|
+
/** JSON-serializable; fixed for the life of the attachment. */
|
|
66
|
+
readonly config: Config;
|
|
67
|
+
/** The state a freshly loaded page should start with. JSON-serializable. */
|
|
68
|
+
state(): State;
|
|
69
|
+
/** Entries flushed from a page, in emission order. */
|
|
70
|
+
receive(entries: readonly PageEntry[], source: PageSource): void;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Where plugins put code that runs in every page. Modules register at setup;
|
|
74
|
+
* the host injects them all as one init script per attached context, with one
|
|
75
|
+
* binding back to Node.
|
|
76
|
+
*/
|
|
77
|
+
export interface PageHost {
|
|
78
|
+
/**
|
|
79
|
+
* Add a module to the init script. Throws `INVALID_ARGUMENT` for an id
|
|
80
|
+
* already taken or an installer that does not serialize to a function
|
|
81
|
+
* expression, and `INVALID_STATE` once the stage has been attached.
|
|
82
|
+
*/
|
|
83
|
+
register<State, Config>(module: PageModule<State, Config>): void;
|
|
84
|
+
/**
|
|
85
|
+
* Run a module's command handler in every frame of every open page (or of
|
|
86
|
+
* one page, by id) and return each frame's answer. Frames that are going
|
|
87
|
+
* away are skipped; a handler that throws rejects the call.
|
|
88
|
+
*/
|
|
89
|
+
command(module: string, op: string, args?: unknown, options?: {
|
|
90
|
+
readonly page?: string;
|
|
91
|
+
}): Promise<unknown[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Send the module's current `state()` to every frame of every open page.
|
|
94
|
+
* Documents loaded later ask for it when their runtime starts.
|
|
95
|
+
*/
|
|
96
|
+
refresh(module: string): Promise<void>;
|
|
97
|
+
/** The id frames use for `page`. */
|
|
98
|
+
pageId(page: PagePort): string;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../../src/entities/plugin/model/page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AAExE,wEAAwE;AACxE,MAAM,WAAW,SAAS;IACzB,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,sBAAsB;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAClD;AAED,iEAAiE;AACjE,MAAM,WAAW,aAAa,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO;IAC/D,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,UAAU,CAAC;IAC5C,QAAQ,CAAC,MA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AS,EAAE,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;CACjE;AAED;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACxB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IACjE;;;;OAIG;IACH,OAAO,CACN,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAClC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,oCAAoC;IACpC,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../../../src/entities/plugin/model/page.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Clock } from "../../../shared/lib/clock/index.js";
|
|
2
|
+
import type { LogScope, ScopedLogger } from "../../../shared/lib/logger/index.js";
|
|
3
|
+
import type { Frame, FrameFilter, Timeline } from "../../frame/@x/plugin.js";
|
|
4
|
+
import type { Attachment } from "./attachment.js";
|
|
5
|
+
import type { HttpRouter } from "./http.js";
|
|
6
|
+
import type { PageHost } from "./page.js";
|
|
7
|
+
import type { SocketRouter } from "./socket.js";
|
|
8
|
+
export interface WaitForOptions {
|
|
9
|
+
/** Frames to wait for. Default 1. */
|
|
10
|
+
readonly count?: number;
|
|
11
|
+
/** Milliseconds. Default 5000. */
|
|
12
|
+
readonly timeout?: number;
|
|
13
|
+
/** Milliseconds between polls of the page buffers. Default 25. */
|
|
14
|
+
readonly interval?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Everything a plugin may use. A plugin never drives the browser itself:
|
|
18
|
+
* routing and page hooks go through these services, built and owned by the
|
|
19
|
+
* stage, and that is the seam that lets each plugin be unit-tested against
|
|
20
|
+
* fakes and lets several plugins share one browser context without stepping
|
|
21
|
+
* on each other.
|
|
22
|
+
*/
|
|
23
|
+
export interface PluginContext {
|
|
24
|
+
/**
|
|
25
|
+
* The name the plugin is set up under: its own, or the one `named()` gave
|
|
26
|
+
* it. A plugin records its frames with this as their `protocol` (and
|
|
27
|
+
* names its page modules by it), so two instances keep their traffic
|
|
28
|
+
* apart.
|
|
29
|
+
*/
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly timeline: Timeline;
|
|
32
|
+
readonly clock: Clock;
|
|
33
|
+
/** Scoped to the plugin's declared scope. */
|
|
34
|
+
readonly log: ScopedLogger;
|
|
35
|
+
/** HTTP: fetch, XHR, EventSource, and anything else a route can see. */
|
|
36
|
+
readonly http: HttpRouter;
|
|
37
|
+
/** WebSockets. */
|
|
38
|
+
readonly sockets: SocketRouter;
|
|
39
|
+
/** Code that runs inside every page, for what no route can see. */
|
|
40
|
+
readonly pages: PageHost;
|
|
41
|
+
readonly baseURL: string | undefined;
|
|
42
|
+
attachments(): readonly Attachment[];
|
|
43
|
+
/** Flush every page buffer into the timeline. Call before reading frames. */
|
|
44
|
+
sync(): Promise<void>;
|
|
45
|
+
waitFor(filter: FrameFilter, options?: WaitForOptions): Promise<Frame[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Build on another plugin: set it up inside this one and get its API. A
|
|
48
|
+
* protocol layered on others (GraphQL over HTTP and WebSocket, say) is
|
|
49
|
+
* written in terms of theirs instead of re-deriving them. The stage runs
|
|
50
|
+
* the inner plugin's hooks with the outer's; it is not mounted on the
|
|
51
|
+
* stage. Wrap it in `named()` to keep its frames apart from another
|
|
52
|
+
* instance's.
|
|
53
|
+
*/
|
|
54
|
+
use<Api>(plugin: WirePlugin<string, Api>): Api;
|
|
55
|
+
}
|
|
56
|
+
export interface PluginRuntime<Api> {
|
|
57
|
+
/** Mounted on the stage under the plugin's name. */
|
|
58
|
+
readonly api: Api;
|
|
59
|
+
/** A context was attached. Page modules and HTTP rules are already in place. */
|
|
60
|
+
attach?(attachment: Attachment): void | Promise<void>;
|
|
61
|
+
/** A context is being detached. */
|
|
62
|
+
detach?(attachment: Attachment): void | Promise<void>;
|
|
63
|
+
/** The stage is being disposed; release servers and timers. */
|
|
64
|
+
dispose?(): void | Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A protocol, as the stage sees it. The stage knows nothing about any
|
|
68
|
+
* protocol in particular: REST, Connect, WebRTC and the rest are all plugins,
|
|
69
|
+
* and a new protocol is a new plugin, not a change to the stage.
|
|
70
|
+
*/
|
|
71
|
+
export interface WirePlugin<Name extends string = string, Api = unknown> {
|
|
72
|
+
/** The key its API is mounted under: `stage.<name>`. */
|
|
73
|
+
readonly name: Name;
|
|
74
|
+
/** The badge on the plugin's log lines; eight characters fit the column. */
|
|
75
|
+
readonly scope?: LogScope;
|
|
76
|
+
setup(context: PluginContext): PluginRuntime<Api>;
|
|
77
|
+
}
|
|
78
|
+
export type AnyWirePlugin = WirePlugin<string, unknown>;
|
|
79
|
+
/** `{ webrtc: WebRtcApi, connect: ConnectApi }` from `[webrtc(), connect()]`. */
|
|
80
|
+
export type PluginApis<Plugins extends readonly AnyWirePlugin[]> = {
|
|
81
|
+
readonly [Plugin in Plugins[number] as Plugin["name"]]: Plugin extends WirePlugin<string, infer Api> ? Api : never;
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/entities/plugin/model/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,KAAK,EAC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file":"plugin.js","sourceRoot":"","sources":["../../../../src/entities/plugin/model/plugin.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { UrlMatcher } from "../../../shared/lib/match/index.js";
|
|
2
|
+
/** One end of a routed WebSocket: the page's, or the real server's. */
|
|
3
|
+
export interface SocketPeer {
|
|
4
|
+
/** Deliver a message to this end. */
|
|
5
|
+
send(data: string | Uint8Array): void;
|
|
6
|
+
/**
|
|
7
|
+
* Close this end. The page's end takes any code and reason, as a server
|
|
8
|
+
* may close with any code. The server's end is closed by the browser,
|
|
9
|
+
* which sends only 1000 and 3000-4999, no reason without a code, and no
|
|
10
|
+
* reason over 123 bytes of UTF-8: another code goes out as a normal
|
|
11
|
+
* closure, 1000, and the reason is cut to 123 bytes, so the close still
|
|
12
|
+
* happens.
|
|
13
|
+
*/
|
|
14
|
+
close(options?: {
|
|
15
|
+
readonly code?: number;
|
|
16
|
+
readonly reason?: string;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Messages this end sends. One handler; a later call replaces it. Until
|
|
20
|
+
* one is set, what this end sends is dropped, not passed on to the other.
|
|
21
|
+
* A handler that throws, or rejects, fails the rule (see
|
|
22
|
+
* `SocketRule.open`).
|
|
23
|
+
*/
|
|
24
|
+
onMessage(handler: (data: string | Uint8Array) => void): void;
|
|
25
|
+
/**
|
|
26
|
+
* This end closed, by its own doing or through `close()` — and a close
|
|
27
|
+
* the page starts is reported again once `close()` completes it, so a
|
|
28
|
+
* handler must expect to run twice. Setting one turns off the automatic
|
|
29
|
+
* forwarding of a close to the other end: the page's socket then hangs in
|
|
30
|
+
* CLOSING until the handler closes the page's end itself. A handler that
|
|
31
|
+
* throws, or rejects, fails the rule.
|
|
32
|
+
*/
|
|
33
|
+
onClose(handler: (code: number | undefined, reason: string | undefined) => void): void;
|
|
34
|
+
}
|
|
35
|
+
/** A WebSocket a page opened, as the rule that takes it sees it. */
|
|
36
|
+
export interface SocketView {
|
|
37
|
+
/** Links every frame of this connection. */
|
|
38
|
+
readonly correlation: string;
|
|
39
|
+
readonly url: URL;
|
|
40
|
+
readonly context: string;
|
|
41
|
+
/** The page's end. */
|
|
42
|
+
readonly page: SocketPeer;
|
|
43
|
+
/**
|
|
44
|
+
* Open the real server's end and return it. No message is forwarded for
|
|
45
|
+
* you: a rule that wants a proxy wires the two ends together itself, and
|
|
46
|
+
* a direction it does not wire is dropped — a rule that sets only the
|
|
47
|
+
* page's `onMessage` never lets the server's messages reach the page. A
|
|
48
|
+
* close is passed on to the other end unless the end that closed has an
|
|
49
|
+
* `onClose` handler.
|
|
50
|
+
*/
|
|
51
|
+
connectToServer(): SocketPeer;
|
|
52
|
+
}
|
|
53
|
+
export interface SocketRule {
|
|
54
|
+
/**
|
|
55
|
+
* The `protocol` of this rule's frames: those it records, and the fault
|
|
56
|
+
* the stage records when `open` throws.
|
|
57
|
+
*/
|
|
58
|
+
readonly protocol: string;
|
|
59
|
+
/** Names the rule in logs, diagnostics and the fault of a rule that throws. */
|
|
60
|
+
readonly label: string;
|
|
61
|
+
readonly url: UrlMatcher;
|
|
62
|
+
/** Stop taking connections after this many. */
|
|
63
|
+
readonly times?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Take a connection: called once per matching socket. The page's socket
|
|
66
|
+
* opens when this settles — or, for a rule that connects the server,
|
|
67
|
+
* when the server's end opens — and sooner if the rule sends to it. Set
|
|
68
|
+
* the handlers before awaiting anything: an end drops what it sends
|
|
69
|
+
* until it has one.
|
|
70
|
+
*
|
|
71
|
+
* A rule that throws, or rejects — here, or in a handler it set on
|
|
72
|
+
* either end — is a bug in the test: the stage logs it, records a
|
|
73
|
+
* `fault` frame (`meta.reason` `rule-error`, `meta.rule` the label,
|
|
74
|
+
* `meta.error` the message) and closes the page's end with 1011 and a
|
|
75
|
+
* reason naming the rule — and the server's end too, if the rule
|
|
76
|
+
* connected it. Once per socket: what fails after that is not reported
|
|
77
|
+
* again. The ends' `onClose` handlers hear those closes as they hear any
|
|
78
|
+
* other.
|
|
79
|
+
*/
|
|
80
|
+
open(socket: SocketView): void | Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
export interface SocketRuleHandle {
|
|
83
|
+
/** Connections this rule took. */
|
|
84
|
+
readonly hits: number;
|
|
85
|
+
readonly active: boolean;
|
|
86
|
+
/** Stop taking connections. Open ones stay as they are. */
|
|
87
|
+
remove(): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Where plugins put WebSocket rules. Rules apply to every attached context,
|
|
91
|
+
* present and future, and the newest rule that matches a socket takes it; a
|
|
92
|
+
* socket no rule takes goes to the real server.
|
|
93
|
+
*
|
|
94
|
+
* Routing replaces `WebSocket` in every document of the context, so it
|
|
95
|
+
* starts with the first rule and a stage with none leaves the page alone.
|
|
96
|
+
* The replacement reaches a document as it loads: a rule added later applies
|
|
97
|
+
* to the documents loaded after it, unless the plugin called `prepare()`.
|
|
98
|
+
*/
|
|
99
|
+
export interface SocketRouter {
|
|
100
|
+
add(rule: SocketRule): Promise<SocketRuleHandle>;
|
|
101
|
+
/**
|
|
102
|
+
* Start routing as soon as a context is attached, before any rule exists,
|
|
103
|
+
* so a rule added mid-test reaches the pages already open. Call in `setup`.
|
|
104
|
+
*/
|
|
105
|
+
prepare(): void;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=socket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../../../src/entities/plugin/model/socket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAErE,uEAAuE;AACvE,MAAM,WAAW,UAAU;IAC1B,qCAAqC;IACrC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;IACtC;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE;QACf,QAAQ,CAAC,IAAI,CAAC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AAC;CACxB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAY;IAC5B,GAAG,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjD;;;OAGG;IACH,OAAO,IAAI,IAAI,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../../../src/entities/plugin/model/socket.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** How an open response ended. */
|
|
2
|
+
export type StreamEnd =
|
|
3
|
+
/** The rule ended it cleanly. */
|
|
4
|
+
"ended"
|
|
5
|
+
/** The rule reset the connection. */
|
|
6
|
+
| "cut"
|
|
7
|
+
/** The page went away: it closed the stream, navigated, or was closed. */
|
|
8
|
+
| "cancelled";
|
|
9
|
+
/**
|
|
10
|
+
* A response that stays open, written at the test's pace: what a server
|
|
11
|
+
* stream, an event stream or a long poll is made of. A rule gets one by
|
|
12
|
+
* answering `{ type: "stream" }`.
|
|
13
|
+
*/
|
|
14
|
+
export interface ResponseStream {
|
|
15
|
+
/**
|
|
16
|
+
* The request's headers as the server received them, names lower-cased.
|
|
17
|
+
* They include what the browser's network stack adds after Playwright's
|
|
18
|
+
* route has seen the request, such as `last-event-id`.
|
|
19
|
+
*/
|
|
20
|
+
readonly requestHeaders: Readonly<Record<string, string>>;
|
|
21
|
+
/**
|
|
22
|
+
* Set the status and headers. They go out with the first `write`, or at
|
|
23
|
+
* once on `flush`, and a later call replaces them until then. Without a
|
|
24
|
+
* call the response is a bare 200. A header may carry several values
|
|
25
|
+
* separated by a newline (`set-cookie`). `connection` is the stream
|
|
26
|
+
* server's: it closes every connection after one response.
|
|
27
|
+
*/
|
|
28
|
+
head(status: number, headers?: Readonly<Record<string, string>>): void;
|
|
29
|
+
/** Send the head now, before any body: an EventSource opens on it. */
|
|
30
|
+
flush(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Write a chunk. Resolves once it is handed to the socket; rejects with
|
|
33
|
+
* `CLOSED` when the response is over, the page letting go included.
|
|
34
|
+
*/
|
|
35
|
+
write(chunk: Uint8Array | string): Promise<void>;
|
|
36
|
+
/** End the response cleanly. Resolves once it is closed, as `closed` does. */
|
|
37
|
+
end(): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Reset the connection mid-response: no terminator, no trailer — what a
|
|
40
|
+
* network drop looks like to the page.
|
|
41
|
+
*/
|
|
42
|
+
cut(): void;
|
|
43
|
+
/** Resolves when the response is over, with how, once that is on the timeline. */
|
|
44
|
+
readonly closed: Promise<StreamEnd>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../../src/entities/plugin/model/stream.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,MAAM,MAAM,SAAS;AACpB,iCAAiC;AAC/B,OAAO;AACT,qCAAqC;GACnC,KAAK;AACP,0EAA0E;GACxE,WAAW,CAAC;AAEf;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1D;;;;;;OAMG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IACvE,sEAAsE;IACtE,KAAK,IAAI,IAAI,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,8EAA8E;IAC9E,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB;;;OAGG;IACH,GAAG,IAAI,IAAI,CAAC;IACZ,kFAAkF;IAClF,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;CACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../../src/entities/plugin/model/stream.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createRpcClient } from "./lib/client.js";
|
|
2
|
+
export { connect } from "./lib/create-connect.js";
|
|
3
|
+
export { statusOf } from "./lib/status-of.js";
|
|
4
|
+
export type { ClientOptions, ConnectApi, ConnectOptions, HeldCall, HoldOptions, HoldStub, RpcCall, RpcProtocol, RpcServer, ServeOptions, StandaloneClientOptions, StreamCall, StreamEnd, StreamStub, StubHandle, StubOptions, UnaryReply, UnaryStub, } from "./model/types.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/connect/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,YAAY,EACX,aAAa,EACb,UAAU,EACV,cAAc,EACd,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,OAAO,EACP,WAAW,EACX,SAAS,EACT,YAAY,EACZ,uBAAuB,EACvB,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,GACT,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/features/connect/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DescMessage } from "@bufbuild/protobuf";
|
|
2
|
+
import type { Frame } from "../../../entities/frame/index.js";
|
|
3
|
+
import type { RpcCall } from "../model/types.js";
|
|
4
|
+
/**
|
|
5
|
+
* One method's frames as calls: one per correlation, oldest first. A frame
|
|
6
|
+
* another writer left without a correlation is a call of its own.
|
|
7
|
+
*/
|
|
8
|
+
export declare function assembleCalls<I extends DescMessage, O extends DescMessage>(frames: readonly Frame[]): RpcCall<I, O>[];
|
|
9
|
+
//# sourceMappingURL=calls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../../../../src/features/connect/lib/calls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,oBAAoB,CAAC;AAEpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,mBAAmB,CAAC;AAE9D;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,WAAW,EACzE,MAAM,EAAE,SAAS,KAAK,EAAE,GACtB,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CA8CjB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One method's frames as calls: one per correlation, oldest first. A frame
|
|
3
|
+
* another writer left without a correlation is a call of its own.
|
|
4
|
+
*/
|
|
5
|
+
export function assembleCalls(frames) {
|
|
6
|
+
const byCall = new Map();
|
|
7
|
+
for (const frame of frames) {
|
|
8
|
+
const key = frame.correlation ?? `#${frame.seq}`;
|
|
9
|
+
const list = byCall.get(key) ?? [];
|
|
10
|
+
list.push(frame);
|
|
11
|
+
byCall.set(key, list);
|
|
12
|
+
}
|
|
13
|
+
return [...byCall].map(([correlation, own]) => {
|
|
14
|
+
const first = own[0];
|
|
15
|
+
const requests = own.filter((frame) => frame.direction === "out" && frame.value !== undefined);
|
|
16
|
+
// Everything that is not the caller's is the answer: messages, the
|
|
17
|
+
// status, or the fault that stood in for one.
|
|
18
|
+
const answer = own.findLast((frame) => frame.direction !== "out");
|
|
19
|
+
const status = own.findLast((frame) => frame.kind === "response");
|
|
20
|
+
const fault = own.findLast((frame) => frame.kind === "fault");
|
|
21
|
+
return {
|
|
22
|
+
correlation,
|
|
23
|
+
caller: requests[0]?.source,
|
|
24
|
+
answeredBy: answer?.source,
|
|
25
|
+
page: first.page,
|
|
26
|
+
context: first.context,
|
|
27
|
+
protocol: first.meta["rpcProtocol"],
|
|
28
|
+
request: requests[0]?.value,
|
|
29
|
+
requests: requests.map((frame) => frame.value),
|
|
30
|
+
responses: own
|
|
31
|
+
.filter((frame) => frame.direction === "in" &&
|
|
32
|
+
frame.kind === "message" &&
|
|
33
|
+
frame.value !== undefined)
|
|
34
|
+
.map((frame) => frame.value),
|
|
35
|
+
status: status === undefined
|
|
36
|
+
? undefined
|
|
37
|
+
: {
|
|
38
|
+
code: Number(status.meta["code"]),
|
|
39
|
+
message: String(status.meta["message"] ?? ""),
|
|
40
|
+
},
|
|
41
|
+
fault: fault === undefined ? undefined : String(fault.meta["reason"]),
|
|
42
|
+
frames: own,
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=calls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calls.js","sourceRoot":"","sources":["../../../../src/features/connect/lib/calls.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC5B,MAAwB;IAExB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC1C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,KAAK,CA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