stitchkit 0.94.0 → 0.95.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +104 -0
- package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
- package/dist/agent-runtime/contained-darwin.d.ts +38 -0
- package/dist/agent-runtime/contained-darwin.d.ts.map +1 -0
- package/dist/agent-runtime/contained-files.d.ts +11 -26
- package/dist/agent-runtime/contained-files.d.ts.map +1 -1
- package/dist/agent-runtime/contained-scan.d.ts +21 -0
- package/dist/agent-runtime/contained-scan.d.ts.map +1 -0
- package/dist/agent-runtime/contained-write.d.ts +9 -0
- package/dist/agent-runtime/contained-write.d.ts.map +1 -0
- package/dist/agent-runtime/deferred-tool-types.d.ts +3 -2
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/agent-runtime/harness-control.d.ts +0 -1
- package/dist/agent-runtime/harness-control.d.ts.map +1 -1
- package/dist/agent-runtime/harness.d.ts +0 -5
- package/dist/agent-runtime/harness.d.ts.map +1 -1
- package/dist/agent-runtime/managed-tools.d.ts +3 -2
- package/dist/agent-runtime/managed-tools.d.ts.map +1 -1
- package/dist/agent-runtime/provider-origin.d.ts +7 -0
- package/dist/agent-runtime/provider-origin.d.ts.map +1 -1
- package/dist/agent-runtime/run-operation-lifecycle.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +1 -1
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-records.d.ts +34 -0
- package/dist/agent-runtime/schedule-records.d.ts.map +1 -0
- package/dist/agent-runtime/schedules.d.ts +34 -0
- package/dist/agent-runtime/schedules.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +434 -0
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-ordering.d.ts +18 -0
- package/dist/agent-runtime/store-conformance-ordering.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-support.d.ts +130 -0
- package/dist/agent-runtime/store-conformance-support.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-terminal.d.ts +12 -0
- package/dist/agent-runtime/store-conformance-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance.d.ts.map +1 -1
- package/dist/application/admission-rate.d.ts +21 -0
- package/dist/application/admission-rate.d.ts.map +1 -0
- package/dist/application/admission-run.d.ts +8 -0
- package/dist/application/admission-run.d.ts.map +1 -0
- package/dist/application/admission.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-lock.d.ts +9 -34
- package/dist/application/diagnostic-journal-lock.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-storage.d.ts.map +1 -1
- package/dist/application/kernel-resource-context.d.ts.map +1 -1
- package/dist/application/notification-outbox.d.ts.map +1 -1
- package/dist/application/process-lifecycle-transitions.d.ts +175 -0
- package/dist/application/process-lifecycle-transitions.d.ts.map +1 -0
- package/dist/application/process-lifecycle.d.ts +3 -131
- package/dist/application/process-lifecycle.d.ts.map +1 -1
- package/dist/application/schedule.d.ts +0 -1
- package/dist/application/schedule.d.ts.map +1 -1
- package/dist/application/watch-hub-core.d.ts +122 -0
- package/dist/application/watch-hub-core.d.ts.map +1 -0
- package/dist/application/watch-hub.d.ts +2 -2
- package/dist/application/watch-hub.d.ts.map +1 -1
- package/dist/browser/client-executors.d.ts +14 -0
- package/dist/browser/client-executors.d.ts.map +1 -0
- package/dist/browser/client-multipart.d.ts +1 -1
- package/dist/browser/client-multipart.d.ts.map +1 -1
- package/dist/browser/client.d.ts +3 -2
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/http-fetch.d.ts +22 -0
- package/dist/browser/http-fetch.d.ts.map +1 -0
- package/dist/browser/http.d.ts +1 -3
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/live-state-core.d.ts +63 -0
- package/dist/browser/live-state-core.d.ts.map +1 -0
- package/dist/browser/live-state.d.ts.map +1 -1
- package/dist/browser/realtime-client.d.ts +26 -0
- package/dist/browser/realtime-client.d.ts.map +1 -0
- package/dist/browser/socket-io-connection.d.ts +82 -0
- package/dist/browser/socket-io-connection.d.ts.map +1 -0
- package/dist/browser/socket-io-peer.d.ts +20 -0
- package/dist/browser/socket-io-peer.d.ts.map +1 -0
- package/dist/browser/socket-io-trace.d.ts +31 -0
- package/dist/browser/socket-io-trace.d.ts.map +1 -0
- package/dist/browser/socket-io.d.ts +2 -18
- package/dist/browser/socket-io.d.ts.map +1 -1
- package/dist/contract/client-types.d.ts +134 -0
- package/dist/contract/client-types.d.ts.map +1 -0
- package/dist/contract/define-validation.d.ts +30 -0
- package/dist/contract/define-validation.d.ts.map +1 -0
- package/dist/contract/define.d.ts +3 -357
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/runtime-context.d.ts +131 -0
- package/dist/contract/runtime-context.d.ts.map +1 -0
- package/dist/contract/tool-options.d.ts +105 -0
- package/dist/contract/tool-options.d.ts.map +1 -0
- package/dist/contract/tool-view.d.ts +15 -2
- package/dist/contract/tool-view.d.ts.map +1 -1
- package/dist/durability/contract.d.ts +83 -0
- package/dist/durability/contract.d.ts.map +1 -1
- package/dist/durability/effect.d.ts +24 -0
- package/dist/durability/effect.d.ts.map +1 -0
- package/dist/durability/engine.d.ts +2 -2
- package/dist/durability/engine.d.ts.map +1 -1
- package/dist/durability/events.d.ts +2 -0
- package/dist/durability/events.d.ts.map +1 -1
- package/dist/durability/ledger.d.ts +11 -0
- package/dist/durability/ledger.d.ts.map +1 -1
- package/dist/durability/parks.d.ts +22 -0
- package/dist/durability/parks.d.ts.map +1 -0
- package/dist/durability/scheduler.d.ts +1 -0
- package/dist/durability/scheduler.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.js +4 -4
- package/dist/entrypoints/agent-runtime/harness.js +127 -116
- package/dist/entrypoints/agent-runtime/sandbox.js +4 -4
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +3 -3
- package/dist/entrypoints/agent-runtime/sqlite/node.js +3 -3
- package/dist/entrypoints/agent-runtime/testing.js +246 -214
- package/dist/entrypoints/agent-runtime.js +224 -203
- package/dist/entrypoints/application/diagnostic-journal.js +63 -203
- package/dist/entrypoints/application/opentelemetry.js +1 -1
- package/dist/entrypoints/application.d.ts +2 -1
- package/dist/entrypoints/application.d.ts.map +1 -1
- package/dist/entrypoints/application.js +506 -380
- package/dist/entrypoints/cli.d.ts +4 -1
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +57 -35
- package/dist/entrypoints/contract.d.ts +5 -2
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +3 -2
- package/dist/entrypoints/files.d.ts +2 -0
- package/dist/entrypoints/files.d.ts.map +1 -1
- package/dist/entrypoints/files.js +98 -2
- package/dist/entrypoints/index.d.ts +4 -2
- package/dist/entrypoints/index.d.ts.map +1 -1
- package/dist/entrypoints/index.js +348 -282
- package/dist/entrypoints/live.js +89 -71
- package/dist/entrypoints/node.d.ts +2 -1
- package/dist/entrypoints/node.d.ts.map +1 -1
- package/dist/entrypoints/node.js +13 -12
- package/dist/entrypoints/react.js +1 -1
- package/dist/entrypoints/remote.js +4 -4
- package/dist/entrypoints/server.d.ts +4 -2
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +293 -79
- package/dist/entrypoints/testing.d.ts +2 -1
- package/dist/entrypoints/testing.d.ts.map +1 -1
- package/dist/entrypoints/testing.js +288 -281
- package/dist/entrypoints/tools/connections.js +2 -2
- package/dist/entrypoints/tools/invoker.js +4 -4
- package/dist/entrypoints/tools.d.ts +6 -3
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +245 -202
- package/dist/entrypoints/tracking.js +325 -274
- package/dist/files/boundary.d.ts.map +1 -1
- package/dist/files/file-io.d.ts +14 -0
- package/dist/files/file-io.d.ts.map +1 -0
- package/dist/index-1j8pm5t0.js +412 -0
- package/dist/{index-kvj7f4hq.js → index-2bxbyab0.js} +10 -2
- package/dist/{index-xnj9bgxe.js → index-2gxzjvyr.js} +2 -162
- package/dist/index-4gcnakhx.js +82 -0
- package/dist/{index-j05z5gn4.js → index-55hkhm67.js} +136 -119
- package/dist/{index-cq4qfycf.js → index-79z7m7dt.js} +227 -59
- package/dist/{index-r7nmqpsg.js → index-7p1f0vp2.js} +1 -1
- package/dist/{index-dcpdvjsc.js → index-863ea9jb.js} +4 -4
- package/dist/index-8p52kd5p.js +242 -0
- package/dist/{index-97ac4gph.js → index-8zja4pkf.js} +26 -4
- package/dist/{index-2qzskm8h.js → index-dce5wxcq.js} +1 -1
- package/dist/index-e01r054k.js +105 -0
- package/dist/{index-sees8yf8.js → index-ensd0r74.js} +118 -111
- package/dist/{index-1nd48tm9.js → index-gxrt5h6v.js} +2 -1
- package/dist/{index-e87kakm4.js → index-ham5sz8m.js} +112 -110
- package/dist/{index-kj2wbeta.js → index-het2he5g.js} +280 -196
- package/dist/{index-vcvkq30w.js → index-hmp4800j.js} +3 -3
- package/dist/{index-gyr48nzg.js → index-k30h66yd.js} +71 -151
- package/dist/{index-2cr1cqhn.js → index-khtgb21r.js} +2 -2
- package/dist/{index-x4799c19.js → index-ndddxtyx.js} +11 -11
- package/dist/{index-dydjcp8z.js → index-np4m8hd3.js} +38 -36
- package/dist/{index-p81267c2.js → index-p3vsv1fb.js} +621 -357
- package/dist/{index-mp5sn43f.js → index-p9e0w8hs.js} +2 -2
- package/dist/{index-rewkc2hj.js → index-p9sh0xx4.js} +3 -3
- package/dist/{index-70yj2ebz.js → index-paz6sgdp.js} +107 -103
- package/dist/{index-bn2cjajt.js → index-px2gm2jp.js} +26 -102
- package/dist/index-s812ycat.js +65 -0
- package/dist/{index-xsqjkha9.js → index-sp1tzwnb.js} +2 -2
- package/dist/{index-n6hxg8as.js → index-t9rhjr9f.js} +615 -566
- package/dist/{index-zeemqhqx.js → index-v260df89.js} +88 -80
- package/dist/{index-fdp6hdxn.js → index-w906953s.js} +5 -1
- package/dist/{index-mdzh02yc.js → index-wdkt63w3.js} +1 -1
- package/dist/{index-58k4fp34.js → index-wsm5w4ee.js} +1 -1
- package/dist/{index-v38qyerb.js → index-xw3s75nj.js} +1 -1
- package/dist/internal/atomic-file.d.ts +23 -2
- package/dist/internal/atomic-file.d.ts.map +1 -1
- package/dist/internal/exclusive-lock.d.ts +51 -0
- package/dist/internal/exclusive-lock.d.ts.map +1 -0
- package/dist/internal/process-identity.d.ts +47 -0
- package/dist/internal/process-identity.d.ts.map +1 -0
- package/dist/internal/with-exclusive-lock.d.ts +67 -0
- package/dist/internal/with-exclusive-lock.d.ts.map +1 -0
- package/dist/live/watch-client.d.ts.map +1 -1
- package/dist/observability/audit.d.ts +2 -2
- package/dist/observability/audit.d.ts.map +1 -1
- package/dist/observability/event.d.ts +2 -1
- package/dist/observability/event.d.ts.map +1 -1
- package/dist/primitives/export-operation.d.ts +1 -1
- package/dist/primitives/export-operation.d.ts.map +1 -1
- package/dist/realtime/registry.d.ts +0 -5
- package/dist/realtime/registry.d.ts.map +1 -1
- package/dist/server/bun.d.ts +0 -1
- package/dist/server/bun.d.ts.map +1 -1
- package/dist/server/context-contribution.d.ts +1 -1
- package/dist/server/context-contribution.d.ts.map +1 -1
- package/dist/server/context.d.ts +1 -1
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/endpoint-response.d.ts +2 -1
- package/dist/server/endpoint-response.d.ts.map +1 -1
- package/dist/server/error-dispatch.d.ts +1 -1
- package/dist/server/error-dispatch.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +1 -1
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/handler-state.d.ts +1 -1
- package/dist/server/handler-state.d.ts.map +1 -1
- package/dist/server/implement-registry.d.ts +54 -0
- package/dist/server/implement-registry.d.ts.map +1 -0
- package/dist/server/implement.d.ts +9 -55
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/middleware/auth.d.ts +1 -31
- package/dist/server/middleware/auth.d.ts.map +1 -1
- package/dist/server/middleware/jwt.d.ts +31 -0
- package/dist/server/middleware/jwt.d.ts.map +1 -0
- package/dist/server/multipart-reader.d.ts +22 -0
- package/dist/server/multipart-reader.d.ts.map +1 -0
- package/dist/server/multipart.d.ts +1 -1
- package/dist/server/multipart.d.ts.map +1 -1
- package/dist/server/oauth/cimd.d.ts +88 -0
- package/dist/server/oauth/cimd.d.ts.map +1 -0
- package/dist/server/oauth/endpoints.d.ts +39 -0
- package/dist/server/oauth/endpoints.d.ts.map +1 -0
- package/dist/server/oauth/provider.d.ts +1 -68
- package/dist/server/oauth/provider.d.ts.map +1 -1
- package/dist/server/streaming-pump.d.ts +66 -0
- package/dist/server/streaming-pump.d.ts.map +1 -0
- package/dist/server/streaming-route.d.ts +12 -5
- package/dist/server/streaming-route.d.ts.map +1 -1
- package/dist/server/types.d.ts +4 -1
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/unix-client-bun.d.ts.map +1 -1
- package/dist/server/unix-client-http1.d.ts +76 -0
- package/dist/server/unix-client-http1.d.ts.map +1 -0
- package/dist/server/unix-client.d.ts.map +1 -1
- package/dist/testing/handler-clients.d.ts +2 -1
- package/dist/testing/handler-clients.d.ts.map +1 -1
- package/dist/testing/realtime-probe.d.ts +33 -0
- package/dist/testing/realtime-probe.d.ts.map +1 -0
- package/dist/testing/surface-conformance.d.ts +0 -31
- package/dist/testing/surface-conformance.d.ts.map +1 -1
- package/dist/testing/surface-manifest-digest.d.ts +44 -0
- package/dist/testing/surface-manifest-digest.d.ts.map +1 -0
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/tools/agent.d.ts +1 -1
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/cli/args-fields.d.ts +31 -0
- package/dist/tools/cli/args-fields.d.ts.map +1 -0
- package/dist/tools/cli/args-route.d.ts +42 -0
- package/dist/tools/cli/args-route.d.ts.map +1 -0
- package/dist/tools/cli/args-view.d.ts +32 -0
- package/dist/tools/cli/args-view.d.ts.map +1 -0
- package/dist/tools/cli/args.d.ts +2 -65
- package/dist/tools/cli/args.d.ts.map +1 -1
- package/dist/tools/cli/argument-error.d.ts +5 -0
- package/dist/tools/cli/argument-error.d.ts.map +1 -0
- package/dist/tools/cli/checkpoint.d.ts.map +1 -1
- package/dist/tools/cli/command.d.ts +1 -1
- package/dist/tools/cli/command.d.ts.map +1 -1
- package/dist/tools/cli/config.d.ts +1 -1
- package/dist/tools/cli/config.d.ts.map +1 -1
- package/dist/tools/cli/format.d.ts +2 -1
- package/dist/tools/cli/format.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +2 -1
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/managed-surface.d.ts +1 -1
- package/dist/tools/cli/managed-surface.d.ts.map +1 -1
- package/dist/tools/cli/policy.d.ts +1 -1
- package/dist/tools/cli/policy.d.ts.map +1 -1
- package/dist/tools/cli/prepare.d.ts.map +1 -1
- package/dist/tools/cli/run-managed.d.ts.map +1 -1
- package/dist/tools/cli/session.d.ts +1 -1
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/cli/update.d.ts +19 -0
- package/dist/tools/cli/update.d.ts.map +1 -1
- package/dist/tools/cli/view.d.ts +1 -1
- package/dist/tools/cli/view.d.ts.map +1 -1
- package/dist/tools/cli/wait.d.ts +1 -1
- package/dist/tools/cli/wait.d.ts.map +1 -1
- package/dist/tools/connections/runtime.d.ts +1 -1
- package/dist/tools/connections/runtime.d.ts.map +1 -1
- package/dist/tools/execute-args.d.ts +23 -0
- package/dist/tools/execute-args.d.ts.map +1 -0
- package/dist/tools/execute-hooks.d.ts +146 -0
- package/dist/tools/execute-hooks.d.ts.map +1 -0
- package/dist/tools/execute-result.d.ts +40 -0
- package/dist/tools/execute-result.d.ts.map +1 -0
- package/dist/tools/execute.d.ts +4 -193
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/internal/surface-projector.d.ts +2 -1
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts +2 -1
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/lifecycle.d.ts +1 -1
- package/dist/tools/lifecycle.d.ts.map +1 -1
- package/dist/tools/mcp/mount.d.ts +1 -1
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/prepare.d.ts +2 -1
- package/dist/tools/mcp/prepare.d.ts.map +1 -1
- package/dist/tools/mcp/progress.d.ts +1 -1
- package/dist/tools/mcp/progress.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts +3 -2
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/dist/tools/mcp/round-context.d.ts +38 -0
- package/dist/tools/mcp/round-context.d.ts.map +1 -0
- package/dist/tools/mcp/round-policy.d.ts +1 -1
- package/dist/tools/mcp/round-policy.d.ts.map +1 -1
- package/dist/tools/mcp/round.d.ts +3 -11
- package/dist/tools/mcp/round.d.ts.map +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts +2 -1
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
- package/dist/tools/mount.d.ts +3 -1
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/native-definition.d.ts +2 -1
- package/dist/tools/native-definition.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-tools.d.ts +2 -1
- package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-types.d.ts +2 -1
- package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +3 -1
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/tool-logger.d.ts +1 -1
- package/dist/tools/tool-logger.d.ts.map +1 -1
- package/dist/tracking/client-listeners.d.ts +30 -0
- package/dist/tracking/client-listeners.d.ts.map +1 -0
- package/dist/tracking/client-visit.d.ts +61 -0
- package/dist/tracking/client-visit.d.ts.map +1 -0
- package/dist/tracking/client.d.ts +3 -2
- package/dist/tracking/client.d.ts.map +1 -1
- package/llms/application.2.txt +271 -7
- package/llms/application.txt +66 -289
- package/llms/cli.2.txt +80 -0
- package/llms/cli.txt +45 -74
- package/llms/contract.txt +3 -3
- package/llms/files.txt +3 -0
- package/llms/stitchkit.txt +3 -3
- package/llms/tools.2.txt +88 -279
- package/llms/tools.3.txt +288 -0
- package/llms/tools.txt +27 -65
- package/llms/{upgrading-0.37.0-0.50.0.txt → upgrading-0.37.0-0.53.0.txt} +25 -3
- package/llms/{upgrading-0.53.0-0.67.0.txt → upgrading-0.55.0-0.68.0.txt} +53 -25
- package/llms/{upgrading-0.68.0-0.94.0.txt → upgrading-0.69.0-0.95.0.txt} +45 -53
- package/llms/upgrading.txt +3 -3
- package/llms-full.txt +216 -43
- package/llms.txt +8 -8
- package/package.json +1 -1
- package/dist/index-e2z3ahw9.js +0 -325
- package/dist/index-mkm15s49.js +0 -394
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
createUrlBuilders,
|
|
16
16
|
parseNDJSON,
|
|
17
17
|
parseSSE
|
|
18
|
-
} from "../index-
|
|
18
|
+
} from "../index-ham5sz8m.js";
|
|
19
19
|
import {
|
|
20
20
|
REALTIME_REJECTION_KEY,
|
|
21
21
|
asRealtimeRejection,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
isModuleNotFound,
|
|
24
24
|
parseRealtimeRequestAcknowledgement,
|
|
25
25
|
parseRealtimeRequestArguments
|
|
26
|
-
} from "../index-
|
|
26
|
+
} from "../index-ndddxtyx.js";
|
|
27
27
|
import {
|
|
28
28
|
RealtimeRequestDisconnectedError,
|
|
29
29
|
RealtimeRequestInvalidAcknowledgementError,
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
RealtimeRequestPhaseSchema,
|
|
32
32
|
RealtimeRequestRejectedError,
|
|
33
33
|
RealtimeRequestTimeoutError
|
|
34
|
-
} from "../index-
|
|
34
|
+
} from "../index-dce5wxcq.js";
|
|
35
35
|
import"../index-48ffdxgk.js";
|
|
36
36
|
import {
|
|
37
37
|
createContractFactory,
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
defineErrors,
|
|
40
40
|
encodeCursor,
|
|
41
41
|
paginatedSchema
|
|
42
|
-
} from "../index-
|
|
42
|
+
} from "../index-7p1f0vp2.js";
|
|
43
43
|
import {
|
|
44
44
|
ContractStreamFrameSchema,
|
|
45
45
|
DEFAULT_CONTRACT_STREAM_FRAME_BYTES
|
|
@@ -49,19 +49,20 @@ import {
|
|
|
49
49
|
LiveStatePhaseSchema,
|
|
50
50
|
LiveStateStopReasonSchema,
|
|
51
51
|
createLiveStateController
|
|
52
|
-
} from "../index-
|
|
52
|
+
} from "../index-1j8pm5t0.js";
|
|
53
53
|
import"../index-d9pk3td4.js";
|
|
54
54
|
import {
|
|
55
55
|
ApiError,
|
|
56
56
|
createHttpClient
|
|
57
|
-
} from "../index-
|
|
57
|
+
} from "../index-v260df89.js";
|
|
58
58
|
import"../index-rxfy4cq7.js";
|
|
59
59
|
import {
|
|
60
60
|
ALL_TRANSPORTS,
|
|
61
61
|
TOOL_TRANSPORTS,
|
|
62
62
|
defineContract,
|
|
63
63
|
withToolView
|
|
64
|
-
} from "../index-
|
|
64
|
+
} from "../index-k30h66yd.js";
|
|
65
|
+
import"../index-4gcnakhx.js";
|
|
65
66
|
import {
|
|
66
67
|
ManagedFilePathSchema,
|
|
67
68
|
ManagedFileRefSchema
|
|
@@ -92,93 +93,7 @@ import {
|
|
|
92
93
|
} from "../index-2vtcmrj9.js";
|
|
93
94
|
import"../index-kzfs85xp.js";
|
|
94
95
|
import"../index-hffjpmq9.js";
|
|
95
|
-
// src/browser/
|
|
96
|
-
var DEFAULT_RETRY = { minDelayMs: 100, maxDelayMs: 30000, jitter: 0.5 };
|
|
97
|
-
|
|
98
|
-
class ResumableAbortError extends Error {
|
|
99
|
-
constructor() {
|
|
100
|
-
super("Resumable iterator was aborted");
|
|
101
|
-
this.name = "ResumableAbortError";
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function sleep(ms, signal) {
|
|
105
|
-
return new Promise((resolve, reject) => {
|
|
106
|
-
const timer = setTimeout(() => {
|
|
107
|
-
signal?.removeEventListener("abort", onAbort);
|
|
108
|
-
resolve();
|
|
109
|
-
}, ms);
|
|
110
|
-
function onAbort() {
|
|
111
|
-
clearTimeout(timer);
|
|
112
|
-
reject(new ResumableAbortError);
|
|
113
|
-
}
|
|
114
|
-
if (signal?.aborted) {
|
|
115
|
-
clearTimeout(timer);
|
|
116
|
-
reject(new ResumableAbortError);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
async function* resumableIterator(config) {
|
|
123
|
-
const backoff = createBackoff(config.retry ?? DEFAULT_RETRY, config.random);
|
|
124
|
-
let cursor;
|
|
125
|
-
let attempt = 0;
|
|
126
|
-
for (;; ) {
|
|
127
|
-
if (config.signal?.aborted)
|
|
128
|
-
return;
|
|
129
|
-
try {
|
|
130
|
-
const source = await config.open(cursor);
|
|
131
|
-
for await (const item of source) {
|
|
132
|
-
if (config.signal?.aborted)
|
|
133
|
-
return;
|
|
134
|
-
attempt = 0;
|
|
135
|
-
backoff.reset();
|
|
136
|
-
cursor = config.advance(item, cursor);
|
|
137
|
-
yield item;
|
|
138
|
-
if (config.isTerminal?.(item))
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
throw new Error("Resumable source ended without a terminal item");
|
|
142
|
-
} catch (error) {
|
|
143
|
-
if (config.signal?.aborted || error instanceof ResumableAbortError)
|
|
144
|
-
return;
|
|
145
|
-
attempt += 1;
|
|
146
|
-
const delayMs = backoff.next();
|
|
147
|
-
config.onAttempt?.({ number: attempt, delayMs, error });
|
|
148
|
-
try {
|
|
149
|
-
await sleep(delayMs, config.signal);
|
|
150
|
-
} catch {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
// src/browser/retained.ts
|
|
157
|
-
function createRetainedTopics() {
|
|
158
|
-
const last = {};
|
|
159
|
-
return {
|
|
160
|
-
record(topic, payload) {
|
|
161
|
-
last[topic] = payload;
|
|
162
|
-
},
|
|
163
|
-
replay(topic, handler) {
|
|
164
|
-
const value = last[topic];
|
|
165
|
-
if (value !== undefined)
|
|
166
|
-
handler(value);
|
|
167
|
-
},
|
|
168
|
-
get(topic) {
|
|
169
|
-
return last[topic];
|
|
170
|
-
},
|
|
171
|
-
clear(topic) {
|
|
172
|
-
if (topic !== undefined) {
|
|
173
|
-
delete last[topic];
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
for (const key of Object.keys(last))
|
|
177
|
-
Reflect.deleteProperty(last, key);
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
// src/browser/socket-io.ts
|
|
96
|
+
// src/browser/socket-io-trace.ts
|
|
182
97
|
var realtimeRequestTraces = new WeakMap;
|
|
183
98
|
function observeRealtimeRequestPhase(trace, phase) {
|
|
184
99
|
const observation = {
|
|
@@ -241,52 +156,83 @@ function socketIoPacketIdentity(data, expected) {
|
|
|
241
156
|
function packetIdentityKey(identity) {
|
|
242
157
|
return `${identity.namespace}:${identity.id}`;
|
|
243
158
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
159
|
+
function createRequestTracer(onRequestPhase) {
|
|
160
|
+
const requestTracesByNativeKey = new Map;
|
|
161
|
+
const observedRequestEngines = new WeakSet;
|
|
162
|
+
let startingRequestTrace = null;
|
|
163
|
+
return {
|
|
164
|
+
start(event, onPhase) {
|
|
165
|
+
if (!onRequestPhase && !onPhase)
|
|
166
|
+
return;
|
|
167
|
+
const trace = {
|
|
168
|
+
requestId: randomHex(16),
|
|
169
|
+
event,
|
|
170
|
+
startedAt: performance.now(),
|
|
171
|
+
observeClient: onRequestPhase,
|
|
172
|
+
observeRequest: onPhase,
|
|
173
|
+
closed: false
|
|
174
|
+
};
|
|
175
|
+
return trace;
|
|
176
|
+
},
|
|
177
|
+
close(trace, phase) {
|
|
178
|
+
if (!trace || trace.closed)
|
|
179
|
+
return;
|
|
180
|
+
trace.closed = true;
|
|
181
|
+
if (trace.nativeKey)
|
|
182
|
+
requestTracesByNativeKey.delete(trace.nativeKey);
|
|
183
|
+
observeRealtimeRequestPhase(trace, phase);
|
|
184
|
+
},
|
|
185
|
+
starting(trace, emit) {
|
|
186
|
+
startingRequestTrace = trace ?? null;
|
|
187
|
+
try {
|
|
188
|
+
return emit();
|
|
189
|
+
} finally {
|
|
190
|
+
startingRequestTrace = null;
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
observeEachOpen(target, current) {
|
|
194
|
+
if (!onRequestPhase)
|
|
195
|
+
return;
|
|
196
|
+
target.io.on("open", () => {
|
|
197
|
+
const socket = current();
|
|
198
|
+
if (socket)
|
|
199
|
+
this.observe(socket);
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
observe(target) {
|
|
203
|
+
const engine = target.io.engine;
|
|
204
|
+
if (!engine || observedRequestEngines.has(engine))
|
|
205
|
+
return;
|
|
206
|
+
observedRequestEngines.add(engine);
|
|
207
|
+
engine.on("packetCreate", (packet) => {
|
|
208
|
+
if (!startingRequestTrace || packet.type !== "message")
|
|
209
|
+
return;
|
|
210
|
+
const identity = socketIoPacketIdentity(packet.data, "event");
|
|
211
|
+
if (!identity)
|
|
212
|
+
return;
|
|
213
|
+
const key = packetIdentityKey(identity);
|
|
214
|
+
startingRequestTrace.nativeKey = key;
|
|
215
|
+
requestTracesByNativeKey.set(key, startingRequestTrace);
|
|
216
|
+
observeRealtimeRequestPhase(startingRequestTrace, "engine-handoff");
|
|
217
|
+
});
|
|
218
|
+
engine.on("packet", (packet) => {
|
|
219
|
+
if (packet.type !== "message")
|
|
220
|
+
return;
|
|
221
|
+
const identity = socketIoPacketIdentity(packet.data, "ack");
|
|
222
|
+
if (!identity)
|
|
223
|
+
return;
|
|
224
|
+
const key = packetIdentityKey(identity);
|
|
225
|
+
const trace = requestTracesByNativeKey.get(key);
|
|
226
|
+
if (!trace || trace.closed)
|
|
227
|
+
return;
|
|
228
|
+
observeRealtimeRequestPhase(trace, "engine-ack-received");
|
|
229
|
+
requestTracesByNativeKey.delete(key);
|
|
278
230
|
});
|
|
279
231
|
}
|
|
280
|
-
return pending;
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
function toIoAuth(auth) {
|
|
284
|
-
if (typeof auth !== "function")
|
|
285
|
-
return auth;
|
|
286
|
-
return (cb) => {
|
|
287
|
-
Promise.resolve().then(auth).then(cb, () => cb({}));
|
|
288
232
|
};
|
|
289
233
|
}
|
|
234
|
+
|
|
235
|
+
// src/browser/realtime-client.ts
|
|
290
236
|
function assertRealtimeClientTransport(transport) {
|
|
291
237
|
for (const capability of ["on", "emit", "emitWithAck", "onConnectionChange"]) {
|
|
292
238
|
if (typeof Reflect.get(transport, capability) !== "function") {
|
|
@@ -361,6 +307,244 @@ function bindRealtimeClient(contract, transport, { onRejected, logger } = {}) {
|
|
|
361
307
|
onConnectionChange: (listener) => transport.onConnectionChange(listener)
|
|
362
308
|
};
|
|
363
309
|
}
|
|
310
|
+
// src/browser/resumable.ts
|
|
311
|
+
var DEFAULT_RETRY = { minDelayMs: 100, maxDelayMs: 30000, jitter: 0.5 };
|
|
312
|
+
|
|
313
|
+
class ResumableAbortError extends Error {
|
|
314
|
+
constructor() {
|
|
315
|
+
super("Resumable iterator was aborted");
|
|
316
|
+
this.name = "ResumableAbortError";
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function sleep(ms, signal) {
|
|
320
|
+
return new Promise((resolve, reject) => {
|
|
321
|
+
const timer = setTimeout(() => {
|
|
322
|
+
signal?.removeEventListener("abort", onAbort);
|
|
323
|
+
resolve();
|
|
324
|
+
}, ms);
|
|
325
|
+
function onAbort() {
|
|
326
|
+
clearTimeout(timer);
|
|
327
|
+
reject(new ResumableAbortError);
|
|
328
|
+
}
|
|
329
|
+
if (signal?.aborted) {
|
|
330
|
+
clearTimeout(timer);
|
|
331
|
+
reject(new ResumableAbortError);
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
async function* resumableIterator(config) {
|
|
338
|
+
const backoff = createBackoff(config.retry ?? DEFAULT_RETRY, config.random);
|
|
339
|
+
let cursor;
|
|
340
|
+
let attempt = 0;
|
|
341
|
+
for (;; ) {
|
|
342
|
+
if (config.signal?.aborted)
|
|
343
|
+
return;
|
|
344
|
+
try {
|
|
345
|
+
const source = await config.open(cursor);
|
|
346
|
+
for await (const item of source) {
|
|
347
|
+
if (config.signal?.aborted)
|
|
348
|
+
return;
|
|
349
|
+
attempt = 0;
|
|
350
|
+
backoff.reset();
|
|
351
|
+
cursor = config.advance(item, cursor);
|
|
352
|
+
yield item;
|
|
353
|
+
if (config.isTerminal?.(item))
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
throw new Error("Resumable source ended without a terminal item");
|
|
357
|
+
} catch (error) {
|
|
358
|
+
if (config.signal?.aborted || error instanceof ResumableAbortError)
|
|
359
|
+
return;
|
|
360
|
+
attempt += 1;
|
|
361
|
+
const delayMs = backoff.next();
|
|
362
|
+
config.onAttempt?.({ number: attempt, delayMs, error });
|
|
363
|
+
try {
|
|
364
|
+
await sleep(delayMs, config.signal);
|
|
365
|
+
} catch {
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// src/browser/retained.ts
|
|
372
|
+
function createRetainedTopics() {
|
|
373
|
+
const last = {};
|
|
374
|
+
return {
|
|
375
|
+
record(topic, payload) {
|
|
376
|
+
last[topic] = payload;
|
|
377
|
+
},
|
|
378
|
+
replay(topic, handler) {
|
|
379
|
+
const value = last[topic];
|
|
380
|
+
if (value !== undefined)
|
|
381
|
+
handler(value);
|
|
382
|
+
},
|
|
383
|
+
get(topic) {
|
|
384
|
+
return last[topic];
|
|
385
|
+
},
|
|
386
|
+
clear(topic) {
|
|
387
|
+
if (topic !== undefined) {
|
|
388
|
+
delete last[topic];
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
for (const key of Object.keys(last))
|
|
392
|
+
Reflect.deleteProperty(last, key);
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
// src/browser/socket-io-connection.ts
|
|
397
|
+
function toIoAuth(auth) {
|
|
398
|
+
if (typeof auth !== "function")
|
|
399
|
+
return auth;
|
|
400
|
+
return (cb) => {
|
|
401
|
+
Promise.resolve().then(auth).then(cb, () => cb({}));
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
function ioOptions(config) {
|
|
405
|
+
return {
|
|
406
|
+
path: config.path ?? "/socket.io/",
|
|
407
|
+
withCredentials: config.withCredentials ?? true,
|
|
408
|
+
auth: toIoAuth(config.auth),
|
|
409
|
+
...config.query && { query: config.query },
|
|
410
|
+
...config.extraHeaders && { extraHeaders: config.extraHeaders },
|
|
411
|
+
transports: config.transports ?? ["websocket", "polling"],
|
|
412
|
+
autoConnect: false,
|
|
413
|
+
reconnection: true,
|
|
414
|
+
reconnectionAttempts: config.reconnectionAttempts ?? Infinity,
|
|
415
|
+
reconnectionDelay: config.reconnectionDelay ?? 1000,
|
|
416
|
+
reconnectionDelayMax: config.reconnectionDelayMax ?? 5000,
|
|
417
|
+
timeout: config.timeout ?? 20000
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
function reportPeerFailure(config, error) {
|
|
421
|
+
if (!config.onConnectError)
|
|
422
|
+
throw error;
|
|
423
|
+
config.onConnectError({
|
|
424
|
+
message: error instanceof Error ? error.message : String(error),
|
|
425
|
+
data: error,
|
|
426
|
+
terminal: true
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
function awaitAcknowledgement(input) {
|
|
430
|
+
const { active, event } = input;
|
|
431
|
+
return new Promise((resolve, reject) => {
|
|
432
|
+
let settled = false;
|
|
433
|
+
const finish = (result) => {
|
|
434
|
+
if (settled)
|
|
435
|
+
return;
|
|
436
|
+
settled = true;
|
|
437
|
+
input.pendingRequestDisconnects.delete(onDisconnect);
|
|
438
|
+
active.off("disconnect", onDisconnect);
|
|
439
|
+
result();
|
|
440
|
+
};
|
|
441
|
+
const onDisconnect = () => {
|
|
442
|
+
finish(() => {
|
|
443
|
+
input.closeTrace("disconnected");
|
|
444
|
+
reject(new RealtimeRequestDisconnectedError(event));
|
|
445
|
+
});
|
|
446
|
+
};
|
|
447
|
+
input.pendingRequestDisconnects.add(onDisconnect);
|
|
448
|
+
active.on("disconnect", onDisconnect);
|
|
449
|
+
const acknowledgement = input.emit();
|
|
450
|
+
acknowledgement.then((value) => finish(() => resolve(value)), () => {
|
|
451
|
+
finish(() => {
|
|
452
|
+
const connected = active.connected;
|
|
453
|
+
input.closeTrace(connected ? "timeout" : "disconnected");
|
|
454
|
+
reject(connected ? new RealtimeRequestTimeoutError(event, input.timeoutMs) : new RealtimeRequestDisconnectedError(event));
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
function createStickyEvents(retain) {
|
|
460
|
+
const names = retain ? retain.map(String) : [];
|
|
461
|
+
const known = new Set(names);
|
|
462
|
+
const retained = names.length > 0 ? createRetainedTopics() : null;
|
|
463
|
+
return {
|
|
464
|
+
record(socket) {
|
|
465
|
+
if (!retained)
|
|
466
|
+
return;
|
|
467
|
+
for (const name of names) {
|
|
468
|
+
socket.on(name, (payload) => retained.record(name, payload));
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
replay(name, handler) {
|
|
472
|
+
if (retained && known.has(name))
|
|
473
|
+
retained.replay(name, (payload) => handler(payload));
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
function createRecycle(delay) {
|
|
478
|
+
let timer = null;
|
|
479
|
+
const clear = () => {
|
|
480
|
+
if (timer === null)
|
|
481
|
+
return;
|
|
482
|
+
clearTimeout(timer);
|
|
483
|
+
timer = null;
|
|
484
|
+
};
|
|
485
|
+
return {
|
|
486
|
+
clear,
|
|
487
|
+
schedule(run) {
|
|
488
|
+
if (delay === false)
|
|
489
|
+
return;
|
|
490
|
+
clear();
|
|
491
|
+
timer = setTimeout(() => {
|
|
492
|
+
timer = null;
|
|
493
|
+
run();
|
|
494
|
+
}, delay);
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
function connectErrorReport(error, socket) {
|
|
499
|
+
return {
|
|
500
|
+
message: error.message,
|
|
501
|
+
data: Reflect.get(error, "data"),
|
|
502
|
+
terminal: socket !== null && !socket.active
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// src/browser/socket-io-peer.ts
|
|
507
|
+
var SOCKET_IO_CLIENT = "socket.io-client";
|
|
508
|
+
var ioLoader = null;
|
|
509
|
+
function loadIo() {
|
|
510
|
+
if (!ioLoader) {
|
|
511
|
+
ioLoader = import(/* webpackIgnore: true */ SOCKET_IO_CLIENT).then((mod) => mod.io, (cause) => {
|
|
512
|
+
ioLoader = null;
|
|
513
|
+
throw new Error("stitchkit: createSocketIOClient needs the \"socket.io-client\" peer — install it (e.g. `bun add socket.io-client`). Shipping one self-contained artifact instead? Pass `peers: { client: () => import('socket.io-client') }` so your bundler puts it inside.", { cause });
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
return ioLoader;
|
|
517
|
+
}
|
|
518
|
+
function isIoModule(module) {
|
|
519
|
+
if (typeof module !== "object" || module === null)
|
|
520
|
+
return false;
|
|
521
|
+
return typeof Reflect.get(module, "io") === "function";
|
|
522
|
+
}
|
|
523
|
+
function createIoResolver(injected) {
|
|
524
|
+
if (!injected)
|
|
525
|
+
return loadIo;
|
|
526
|
+
let pending = null;
|
|
527
|
+
return () => {
|
|
528
|
+
if (!pending) {
|
|
529
|
+
pending = injected().then((module) => {
|
|
530
|
+
const io = isIoModule(module) ? module.io : null;
|
|
531
|
+
if (!io) {
|
|
532
|
+
pending = null;
|
|
533
|
+
throw new Error("stitchkit: the loader passed in `peers.client` did not return the \"socket.io-client\" module — it must resolve to the module itself, as `() => import('socket.io-client')`.");
|
|
534
|
+
}
|
|
535
|
+
return io;
|
|
536
|
+
}, (cause) => {
|
|
537
|
+
pending = null;
|
|
538
|
+
if (!isModuleNotFound(cause))
|
|
539
|
+
throw cause;
|
|
540
|
+
throw new Error('stitchkit: createSocketIOClient could not load "socket.io-client" through the loader passed in `peers` — the artifact does not contain it. Check that the loader is a literal `import(\'socket.io-client\')` your bundler can follow, and that "socket.io-client" is a dependency of the package being bundled.', { cause });
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
return pending;
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// src/browser/socket-io.ts
|
|
364
548
|
function createRealtimeClient(contract, { onRejected, logger, onRequestPhase, ...config }) {
|
|
365
549
|
const transport = createSocketIOClientInternal(config, onRequestPhase);
|
|
366
550
|
const bound = bindRealtimeClient(contract, transport, { onRejected, logger });
|
|
@@ -381,125 +565,46 @@ function createSocketIOClientInternal(config, onRequestPhase) {
|
|
|
381
565
|
const resolveIo = createIoResolver(config.peers?.client);
|
|
382
566
|
let desiredConnected = false;
|
|
383
567
|
let loadingPeer = false;
|
|
384
|
-
|
|
568
|
+
const recycle = createRecycle(config.reconnectOnServerDisconnect ?? 1000);
|
|
385
569
|
const pendingRequestDisconnects = new Set;
|
|
386
|
-
const
|
|
387
|
-
const observedRequestEngines = new WeakSet;
|
|
388
|
-
let startingRequestTrace = null;
|
|
389
|
-
const serverDisconnectDelay = config.reconnectOnServerDisconnect ?? 1000;
|
|
570
|
+
const tracer = createRequestTracer(onRequestPhase);
|
|
390
571
|
const connectionListeners = new Set;
|
|
391
572
|
const subscriptions = new Set;
|
|
392
|
-
const
|
|
393
|
-
const retainSet = new Set(retainNames);
|
|
394
|
-
const retained = retainNames.length > 0 ? createRetainedTopics() : null;
|
|
573
|
+
const sticky = createStickyEvents(config.retain);
|
|
395
574
|
function notifyConnection(connected, reason) {
|
|
396
575
|
for (const listener of connectionListeners)
|
|
397
576
|
listener(connected, reason);
|
|
398
577
|
}
|
|
399
|
-
function clearReconnectTimer() {
|
|
400
|
-
if (reconnectTimer !== null) {
|
|
401
|
-
clearTimeout(reconnectTimer);
|
|
402
|
-
reconnectTimer = null;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
function attachRequestPhaseEngineListeners(target) {
|
|
406
|
-
const engine = target.io.engine;
|
|
407
|
-
if (!engine || observedRequestEngines.has(engine))
|
|
408
|
-
return;
|
|
409
|
-
observedRequestEngines.add(engine);
|
|
410
|
-
engine.on("packetCreate", (packet) => {
|
|
411
|
-
if (!startingRequestTrace || packet.type !== "message")
|
|
412
|
-
return;
|
|
413
|
-
const identity = socketIoPacketIdentity(packet.data, "event");
|
|
414
|
-
if (!identity)
|
|
415
|
-
return;
|
|
416
|
-
const key = packetIdentityKey(identity);
|
|
417
|
-
startingRequestTrace.nativeKey = key;
|
|
418
|
-
requestTracesByNativeKey.set(key, startingRequestTrace);
|
|
419
|
-
observeRealtimeRequestPhase(startingRequestTrace, "engine-handoff");
|
|
420
|
-
});
|
|
421
|
-
engine.on("packet", (packet) => {
|
|
422
|
-
if (packet.type !== "message")
|
|
423
|
-
return;
|
|
424
|
-
const identity = socketIoPacketIdentity(packet.data, "ack");
|
|
425
|
-
if (!identity)
|
|
426
|
-
return;
|
|
427
|
-
const key = packetIdentityKey(identity);
|
|
428
|
-
const trace = requestTracesByNativeKey.get(key);
|
|
429
|
-
if (!trace || trace.closed)
|
|
430
|
-
return;
|
|
431
|
-
observeRealtimeRequestPhase(trace, "engine-ack-received");
|
|
432
|
-
requestTracesByNativeKey.delete(key);
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
578
|
function openSocket(io) {
|
|
436
579
|
if (!desiredConnected || socket)
|
|
437
580
|
return;
|
|
438
|
-
socket = io(config.url,
|
|
439
|
-
|
|
440
|
-
withCredentials: config.withCredentials ?? true,
|
|
441
|
-
auth: toIoAuth(config.auth),
|
|
442
|
-
...config.query && { query: config.query },
|
|
443
|
-
...config.extraHeaders && { extraHeaders: config.extraHeaders },
|
|
444
|
-
transports: config.transports ?? ["websocket", "polling"],
|
|
445
|
-
autoConnect: false,
|
|
446
|
-
reconnection: true,
|
|
447
|
-
reconnectionAttempts: config.reconnectionAttempts ?? Infinity,
|
|
448
|
-
reconnectionDelay: config.reconnectionDelay ?? 1000,
|
|
449
|
-
reconnectionDelayMax: config.reconnectionDelayMax ?? 5000,
|
|
450
|
-
timeout: config.timeout ?? 20000
|
|
451
|
-
});
|
|
452
|
-
if (onRequestPhase) {
|
|
453
|
-
socket.io.on("open", () => {
|
|
454
|
-
if (socket)
|
|
455
|
-
attachRequestPhaseEngineListeners(socket);
|
|
456
|
-
});
|
|
457
|
-
}
|
|
581
|
+
socket = io(config.url, ioOptions(config));
|
|
582
|
+
tracer.observeEachOpen(socket, () => socket);
|
|
458
583
|
socket.on("connect", () => notifyConnection(true));
|
|
459
584
|
socket.on("disconnect", (reason) => {
|
|
460
585
|
notifyConnection(false, reason);
|
|
461
|
-
if (reason === "io server disconnect"
|
|
586
|
+
if (reason === "io server disconnect") {
|
|
462
587
|
const current = socket;
|
|
463
|
-
|
|
464
|
-
reconnectTimer = setTimeout(() => {
|
|
465
|
-
reconnectTimer = null;
|
|
588
|
+
recycle.schedule(() => {
|
|
466
589
|
if (socket === current && current && !current.connected)
|
|
467
590
|
current.connect();
|
|
468
|
-
}
|
|
591
|
+
});
|
|
469
592
|
}
|
|
470
593
|
});
|
|
471
594
|
socket.io.on("reconnect_failed", () => {
|
|
472
595
|
desiredConnected = false;
|
|
473
596
|
});
|
|
474
597
|
socket.on("connect_error", (error) => {
|
|
475
|
-
const
|
|
476
|
-
if (terminal)
|
|
598
|
+
const report = connectErrorReport(error, socket);
|
|
599
|
+
if (report.terminal)
|
|
477
600
|
desiredConnected = false;
|
|
478
|
-
config.onConnectError?.(
|
|
479
|
-
message: error.message,
|
|
480
|
-
data: Reflect.get(error, "data"),
|
|
481
|
-
terminal
|
|
482
|
-
});
|
|
601
|
+
config.onConnectError?.(report);
|
|
483
602
|
});
|
|
484
|
-
|
|
485
|
-
for (const name of retainNames) {
|
|
486
|
-
socket.on(name, (payload) => retained.record(name, payload));
|
|
487
|
-
}
|
|
488
|
-
}
|
|
603
|
+
sticky.record(socket);
|
|
489
604
|
for (const attach of subscriptions)
|
|
490
605
|
attach(socket);
|
|
491
606
|
socket.connect();
|
|
492
607
|
}
|
|
493
|
-
function reportPeerFailure(error) {
|
|
494
|
-
desiredConnected = false;
|
|
495
|
-
if (!config.onConnectError)
|
|
496
|
-
throw error;
|
|
497
|
-
config.onConnectError({
|
|
498
|
-
message: error instanceof Error ? error.message : String(error),
|
|
499
|
-
data: error,
|
|
500
|
-
terminal: true
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
608
|
return {
|
|
504
609
|
get connected() {
|
|
505
610
|
return socket?.connected ?? false;
|
|
@@ -520,12 +625,13 @@ function createSocketIOClientInternal(config, onRequestPhase) {
|
|
|
520
625
|
openSocket(io);
|
|
521
626
|
}, (error) => {
|
|
522
627
|
loadingPeer = false;
|
|
523
|
-
|
|
628
|
+
desiredConnected = false;
|
|
629
|
+
reportPeerFailure(config, error);
|
|
524
630
|
});
|
|
525
631
|
},
|
|
526
632
|
disconnect() {
|
|
527
633
|
desiredConnected = false;
|
|
528
|
-
|
|
634
|
+
recycle.clear();
|
|
529
635
|
for (const reject of [...pendingRequestDisconnects])
|
|
530
636
|
reject();
|
|
531
637
|
if (!socket)
|
|
@@ -545,10 +651,8 @@ function createSocketIOClientInternal(config, onRequestPhase) {
|
|
|
545
651
|
subscriptions.add(attach);
|
|
546
652
|
if (socket)
|
|
547
653
|
attach(socket);
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
retained.replay(name, (payload) => fn(payload));
|
|
551
|
-
}
|
|
654
|
+
const fn = handler;
|
|
655
|
+
sticky.replay(name, fn);
|
|
552
656
|
return () => {
|
|
553
657
|
subscriptions.delete(attach);
|
|
554
658
|
socket?.off(name, handler);
|
|
@@ -564,22 +668,8 @@ function createSocketIOClientInternal(config, onRequestPhase) {
|
|
|
564
668
|
return true;
|
|
565
669
|
},
|
|
566
670
|
emitWithAck(event, args, options) {
|
|
567
|
-
const trace =
|
|
568
|
-
|
|
569
|
-
event,
|
|
570
|
-
startedAt: performance.now(),
|
|
571
|
-
observeClient: onRequestPhase,
|
|
572
|
-
observeRequest: options.onPhase,
|
|
573
|
-
closed: false
|
|
574
|
-
} : undefined;
|
|
575
|
-
const closeTrace = (phase) => {
|
|
576
|
-
if (!trace || trace.closed)
|
|
577
|
-
return;
|
|
578
|
-
trace.closed = true;
|
|
579
|
-
if (trace.nativeKey)
|
|
580
|
-
requestTracesByNativeKey.delete(trace.nativeKey);
|
|
581
|
-
observeRealtimeRequestPhase(trace, phase);
|
|
582
|
-
};
|
|
671
|
+
const trace = tracer.start(event, options.onPhase);
|
|
672
|
+
const closeTrace = (phase) => tracer.close(trace, phase);
|
|
583
673
|
const active = socket;
|
|
584
674
|
if (!active?.connected) {
|
|
585
675
|
const pending2 = Promise.reject(new RealtimeRequestDisconnectedError(event));
|
|
@@ -589,39 +679,15 @@ function createSocketIOClientInternal(config, onRequestPhase) {
|
|
|
589
679
|
return pending2;
|
|
590
680
|
}
|
|
591
681
|
if (trace)
|
|
592
|
-
|
|
593
|
-
const pending =
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
result();
|
|
602
|
-
};
|
|
603
|
-
const onDisconnect = () => {
|
|
604
|
-
finish(() => {
|
|
605
|
-
closeTrace("disconnected");
|
|
606
|
-
reject(new RealtimeRequestDisconnectedError(event));
|
|
607
|
-
});
|
|
608
|
-
};
|
|
609
|
-
pendingRequestDisconnects.add(onDisconnect);
|
|
610
|
-
active.on("disconnect", onDisconnect);
|
|
611
|
-
let acknowledgement;
|
|
612
|
-
startingRequestTrace = trace ?? null;
|
|
613
|
-
try {
|
|
614
|
-
acknowledgement = active.timeout(options.timeoutMs).emitWithAck(event, ...args);
|
|
615
|
-
} finally {
|
|
616
|
-
startingRequestTrace = null;
|
|
617
|
-
}
|
|
618
|
-
acknowledgement.then((value) => finish(() => resolve(value)), () => {
|
|
619
|
-
finish(() => {
|
|
620
|
-
const connected = active.connected;
|
|
621
|
-
closeTrace(connected ? "timeout" : "disconnected");
|
|
622
|
-
reject(connected ? new RealtimeRequestTimeoutError(event, options.timeoutMs) : new RealtimeRequestDisconnectedError(event));
|
|
623
|
-
});
|
|
624
|
-
});
|
|
682
|
+
tracer.observe(active);
|
|
683
|
+
const pending = awaitAcknowledgement({
|
|
684
|
+
active,
|
|
685
|
+
event,
|
|
686
|
+
args,
|
|
687
|
+
timeoutMs: options.timeoutMs,
|
|
688
|
+
pendingRequestDisconnects,
|
|
689
|
+
closeTrace,
|
|
690
|
+
emit: () => tracer.starting(trace, () => active.timeout(options.timeoutMs).emitWithAck(event, ...args))
|
|
625
691
|
});
|
|
626
692
|
if (trace)
|
|
627
693
|
realtimeRequestTraces.set(pending, trace);
|