@kortix/sdk 0.13.4 → 0.13.7
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/README.md +63 -6
- package/dist/browser/cache/idb-sync-cache.d.ts +19 -1
- package/dist/browser/cache/idb-sync-cache.d.ts.map +1 -1
- package/dist/browser/cache/idb-sync-cache.js +39 -4
- package/dist/browser/cache/idb-sync-cache.js.map +1 -1
- package/dist/browser/session-sync/server-transcript-mirror.d.ts +82 -0
- package/dist/browser/session-sync/server-transcript-mirror.d.ts.map +1 -0
- package/dist/browser/session-sync/server-transcript-mirror.js +143 -0
- package/dist/browser/session-sync/server-transcript-mirror.js.map +1 -0
- package/dist/browser/session-sync/session-sync-registry.d.ts +11 -1
- package/dist/browser/session-sync/session-sync-registry.d.ts.map +1 -1
- package/dist/browser/session-sync/session-sync-registry.js +117 -9
- package/dist/browser/session-sync/session-sync-registry.js.map +1 -1
- package/dist/browser/session-sync/visibility.d.ts +19 -0
- package/dist/browser/session-sync/visibility.d.ts.map +1 -0
- package/dist/browser/session-sync/visibility.js +16 -0
- package/dist/browser/session-sync/visibility.js.map +1 -0
- package/dist/browser/stores/sandbox-connection-store.d.ts +13 -1
- package/dist/browser/stores/sandbox-connection-store.d.ts.map +1 -1
- package/dist/browser/stores/sandbox-connection-store.js +6 -3
- package/dist/browser/stores/sandbox-connection-store.js.map +1 -1
- package/dist/browser/stores/session-working-store.d.ts +10 -5
- package/dist/browser/stores/session-working-store.d.ts.map +1 -1
- package/dist/browser/stores/session-working-store.js +32 -8
- package/dist/browser/stores/session-working-store.js.map +1 -1
- package/dist/browser/stores/sync-store.d.ts +56 -2
- package/dist/browser/stores/sync-store.d.ts.map +1 -1
- package/dist/browser/stores/sync-store.js +682 -402
- package/dist/browser/stores/sync-store.js.map +1 -1
- package/dist/core/auth/app-viewer.d.ts +57 -0
- package/dist/core/auth/app-viewer.d.ts.map +1 -0
- package/dist/core/auth/app-viewer.js +82 -0
- package/dist/core/auth/app-viewer.js.map +1 -0
- package/dist/core/auth/session.d.ts +45 -0
- package/dist/core/auth/session.d.ts.map +1 -0
- package/dist/core/auth/session.js +113 -0
- package/dist/core/auth/session.js.map +1 -0
- package/dist/core/client/kortix.d.ts +37 -29
- package/dist/core/client/kortix.d.ts.map +1 -1
- package/dist/core/client/kortix.js +61 -8
- package/dist/core/client/kortix.js.map +1 -1
- package/dist/core/http/config.d.ts +4 -2
- package/dist/core/http/config.d.ts.map +1 -1
- package/dist/core/http/config.js.map +1 -1
- package/dist/core/http/opencode-errors.d.ts +17 -0
- package/dist/core/http/opencode-errors.d.ts.map +1 -1
- package/dist/core/http/opencode-errors.js +25 -0
- package/dist/core/http/opencode-errors.js.map +1 -1
- package/dist/core/rest/platform-client/auth.d.ts +120 -0
- package/dist/core/rest/platform-client/auth.d.ts.map +1 -0
- package/dist/core/rest/platform-client/auth.js +98 -0
- package/dist/core/rest/platform-client/auth.js.map +1 -0
- package/dist/core/rest/platform-client/host-boundary.d.ts +5 -0
- package/dist/core/rest/platform-client/host-boundary.d.ts.map +1 -1
- package/dist/core/rest/platform-client/host-boundary.js.map +1 -1
- package/dist/core/rest/projects-client/accounts.d.ts +57 -0
- package/dist/core/rest/projects-client/accounts.d.ts.map +1 -1
- package/dist/core/rest/projects-client/accounts.js +31 -0
- package/dist/core/rest/projects-client/accounts.js.map +1 -1
- package/dist/core/rest/projects-client/apps.d.ts +9 -0
- package/dist/core/rest/projects-client/apps.d.ts.map +1 -1
- package/dist/core/rest/projects-client/apps.js.map +1 -1
- package/dist/core/rest/projects-client/billing.d.ts +2 -0
- package/dist/core/rest/projects-client/billing.d.ts.map +1 -1
- package/dist/core/rest/projects-client/billing.js.map +1 -1
- package/dist/core/rest/projects-client/channels.d.ts +0 -3
- package/dist/core/rest/projects-client/channels.d.ts.map +1 -1
- package/dist/core/rest/projects-client/channels.js +0 -6
- package/dist/core/rest/projects-client/channels.js.map +1 -1
- package/dist/core/rest/projects-client/connectors.d.ts +104 -19
- package/dist/core/rest/projects-client/connectors.d.ts.map +1 -1
- package/dist/core/rest/projects-client/connectors.js +56 -2
- package/dist/core/rest/projects-client/connectors.js.map +1 -1
- package/dist/core/rest/projects-client/index.d.ts +1 -2
- package/dist/core/rest/projects-client/index.d.ts.map +1 -1
- package/dist/core/rest/projects-client/index.js +1 -2
- package/dist/core/rest/projects-client/index.js.map +1 -1
- package/dist/core/rest/projects-client/oauth-clients.d.ts +47 -0
- package/dist/core/rest/projects-client/oauth-clients.d.ts.map +1 -0
- package/dist/core/rest/projects-client/oauth-clients.js +33 -0
- package/dist/core/rest/projects-client/oauth-clients.js.map +1 -0
- package/dist/core/rest/projects-client/projects.d.ts +23 -6
- package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
- package/dist/core/rest/projects-client/projects.js +6 -3
- package/dist/core/rest/projects-client/projects.js.map +1 -1
- package/dist/core/rest/projects-client/session-sandbox.d.ts +52 -0
- package/dist/core/rest/projects-client/session-sandbox.d.ts.map +1 -1
- package/dist/core/rest/projects-client/session-sandbox.js.map +1 -1
- package/dist/core/rest/projects-client/sessions.d.ts +142 -34
- package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
- package/dist/core/rest/projects-client/sessions.js +48 -19
- package/dist/core/rest/projects-client/sessions.js.map +1 -1
- package/dist/core/runtime/attachment-part.d.ts +26 -0
- package/dist/core/runtime/attachment-part.d.ts.map +1 -0
- package/dist/core/runtime/attachment-part.js +41 -0
- package/dist/core/runtime/attachment-part.js.map +1 -0
- package/dist/core/runtime/client.d.ts +4 -2
- package/dist/core/runtime/client.d.ts.map +1 -1
- package/dist/core/runtime/client.js +3 -2
- package/dist/core/runtime/client.js.map +1 -1
- package/dist/core/runtime/opencode-v2-event-aliases.d.ts +184 -0
- package/dist/core/runtime/opencode-v2-event-aliases.d.ts.map +1 -0
- package/dist/core/runtime/opencode-v2-event-aliases.js +2 -0
- package/dist/core/runtime/opencode-v2-event-aliases.js.map +1 -0
- package/dist/core/runtime/pty.d.ts +11 -1
- package/dist/core/runtime/pty.d.ts.map +1 -1
- package/dist/core/runtime/pty.js +19 -6
- package/dist/core/runtime/pty.js.map +1 -1
- package/dist/core/session/connection.d.ts +64 -0
- package/dist/core/session/connection.d.ts.map +1 -0
- package/dist/core/session/connection.js +36 -0
- package/dist/core/session/connection.js.map +1 -0
- package/dist/core/session/index.d.ts +2 -0
- package/dist/core/session/index.d.ts.map +1 -1
- package/dist/core/session/index.js +2 -0
- package/dist/core/session/index.js.map +1 -1
- package/dist/core/session/open-bundle.d.ts +110 -0
- package/dist/core/session/open-bundle.d.ts.map +1 -0
- package/dist/core/session/open-bundle.js +183 -0
- package/dist/core/session/open-bundle.js.map +1 -0
- package/dist/core/session/poll-owner.d.ts +35 -0
- package/dist/core/session/poll-owner.d.ts.map +1 -0
- package/dist/core/session/poll-owner.js +90 -0
- package/dist/core/session/poll-owner.js.map +1 -0
- package/dist/core/session/preview-auth.d.ts +25 -0
- package/dist/core/session/preview-auth.d.ts.map +1 -1
- package/dist/core/session/preview-auth.js +31 -1
- package/dist/core/session/preview-auth.js.map +1 -1
- package/dist/core/session/preview-config.d.ts +26 -0
- package/dist/core/session/preview-config.d.ts.map +1 -0
- package/dist/core/session/preview-config.js +95 -0
- package/dist/core/session/preview-config.js.map +1 -0
- package/dist/core/session/preview-options.d.ts +25 -0
- package/dist/core/session/preview-options.d.ts.map +1 -0
- package/dist/core/session/preview-options.js +45 -0
- package/dist/core/session/preview-options.js.map +1 -0
- package/dist/core/session/preview.d.ts +8 -3
- package/dist/core/session/preview.d.ts.map +1 -1
- package/dist/core/session/preview.js +11 -4
- package/dist/core/session/preview.js.map +1 -1
- package/dist/core/session/rewind.d.ts +67 -24
- package/dist/core/session/rewind.d.ts.map +1 -1
- package/dist/core/session/rewind.js +74 -26
- package/dist/core/session/rewind.js.map +1 -1
- package/dist/core/session/server-store/active.d.ts +10 -12
- package/dist/core/session/server-store/active.d.ts.map +1 -1
- package/dist/core/session/server-store/active.js +11 -9
- package/dist/core/session/server-store/active.js.map +1 -1
- package/dist/core/session/server-store/url-helpers.d.ts +11 -2
- package/dist/core/session/server-store/url-helpers.d.ts.map +1 -1
- package/dist/core/session/server-store/url-helpers.js +11 -2
- package/dist/core/session/server-store/url-helpers.js.map +1 -1
- package/dist/core/session/static-file-preview.d.ts +50 -0
- package/dist/core/session/static-file-preview.d.ts.map +1 -0
- package/dist/core/session/static-file-preview.js +91 -0
- package/dist/core/session/static-file-preview.js.map +1 -0
- package/dist/core/session/url.d.ts +25 -2
- package/dist/core/session/url.d.ts.map +1 -1
- package/dist/core/session/url.js +87 -11
- package/dist/core/session/url.js.map +1 -1
- package/dist/core/session/wake-escalation.d.ts +188 -0
- package/dist/core/session/wake-escalation.d.ts.map +1 -0
- package/dist/core/session/wake-escalation.js +241 -0
- package/dist/core/session/wake-escalation.js.map +1 -0
- package/dist/core/session/working.d.ts +107 -2
- package/dist/core/session/working.d.ts.map +1 -1
- package/dist/core/session/working.js +206 -7
- package/dist/core/session/working.js.map +1 -1
- package/dist/core/session-sync/durable-log.d.ts +96 -0
- package/dist/core/session-sync/durable-log.d.ts.map +1 -0
- package/dist/core/session-sync/durable-log.js +94 -0
- package/dist/core/session-sync/durable-log.js.map +1 -0
- package/dist/core/session-sync/fragment.d.ts +27 -0
- package/dist/core/session-sync/fragment.d.ts.map +1 -0
- package/dist/core/session-sync/fragment.js +24 -0
- package/dist/core/session-sync/fragment.js.map +1 -0
- package/dist/core/session-sync/session-sync-controller.d.ts +117 -11
- package/dist/core/session-sync/session-sync-controller.d.ts.map +1 -1
- package/dist/core/session-sync/session-sync-controller.js +278 -26
- package/dist/core/session-sync/session-sync-controller.js.map +1 -1
- package/dist/core/stream/keepalive.d.ts +17 -0
- package/dist/core/stream/keepalive.d.ts.map +1 -0
- package/dist/core/stream/keepalive.js +19 -0
- package/dist/core/stream/keepalive.js.map +1 -0
- package/dist/core/turns/grouping.d.ts.map +1 -1
- package/dist/core/turns/grouping.js +73 -23
- package/dist/core/turns/grouping.js.map +1 -1
- package/dist/core/turns/types.d.ts +5 -0
- package/dist/core/turns/types.d.ts.map +1 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/dist/kortix.esm.min.js +25 -25
- package/dist/kortix.global.js +25 -25
- package/dist/node/app-viewer.d.ts +41 -0
- package/dist/node/app-viewer.d.ts.map +1 -0
- package/dist/node/app-viewer.js +150 -0
- package/dist/node/app-viewer.js.map +1 -0
- package/dist/node/auth.d.ts +84 -0
- package/dist/node/auth.d.ts.map +1 -0
- package/dist/node/auth.js +414 -0
- package/dist/node/auth.js.map +1 -0
- package/dist/node/server.d.ts +19 -0
- package/dist/node/server.d.ts.map +1 -1
- package/dist/node/server.js +13 -1
- package/dist/node/server.js.map +1 -1
- package/dist/platform/auth-core.d.ts +13 -1
- package/dist/platform/auth-core.d.ts.map +1 -1
- package/dist/platform/auth-core.js +13 -1
- package/dist/platform/auth-core.js.map +1 -1
- package/dist/react/bedrock-invokable.d.ts +58 -0
- package/dist/react/bedrock-invokable.d.ts.map +1 -0
- package/dist/react/bedrock-invokable.js +83 -0
- package/dist/react/bedrock-invokable.js.map +1 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +7 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/model-flatten.d.ts +14 -1
- package/dist/react/model-flatten.d.ts.map +1 -1
- package/dist/react/model-flatten.js +3 -4
- package/dist/react/model-flatten.js.map +1 -1
- package/dist/react/opencode.d.ts +3 -1
- package/dist/react/opencode.d.ts.map +1 -1
- package/dist/react/opencode.js +5 -1
- package/dist/react/opencode.js.map +1 -1
- package/dist/react/provider-selection.d.ts +58 -0
- package/dist/react/provider-selection.d.ts.map +1 -1
- package/dist/react/provider-selection.js +253 -2
- package/dist/react/provider-selection.js.map +1 -1
- package/dist/react/session-start-giveup.d.ts +12 -0
- package/dist/react/session-start-giveup.d.ts.map +1 -0
- package/dist/react/session-start-giveup.js +13 -0
- package/dist/react/session-start-giveup.js.map +1 -0
- package/dist/react/session-title-sync.d.ts.map +1 -1
- package/dist/react/session-title-sync.js +15 -5
- package/dist/react/session-title-sync.js.map +1 -1
- package/dist/react/sign-in-with-kortix.d.ts +346 -0
- package/dist/react/sign-in-with-kortix.d.ts.map +1 -0
- package/dist/react/sign-in-with-kortix.js +65 -0
- package/dist/react/sign-in-with-kortix.js.map +1 -0
- package/dist/react/use-admin-accounts.d.ts +36 -1
- package/dist/react/use-admin-accounts.d.ts.map +1 -1
- package/dist/react/use-admin-accounts.js +19 -0
- package/dist/react/use-admin-accounts.js.map +1 -1
- package/dist/react/use-gateway-routing-policy.d.ts +1 -0
- package/dist/react/use-gateway-routing-policy.d.ts.map +1 -1
- package/dist/react/use-gateway-routing-policy.js +12 -1
- package/dist/react/use-gateway-routing-policy.js.map +1 -1
- package/dist/react/use-kortix-app-viewer.d.ts +13 -0
- package/dist/react/use-kortix-app-viewer.d.ts.map +1 -0
- package/dist/react/use-kortix-app-viewer.js +29 -0
- package/dist/react/use-kortix-app-viewer.js.map +1 -0
- package/dist/react/use-model-defaults.d.ts +7 -0
- package/dist/react/use-model-defaults.d.ts.map +1 -1
- package/dist/react/use-model-defaults.js +7 -1
- package/dist/react/use-model-defaults.js.map +1 -1
- package/dist/react/use-model-enablement.d.ts.map +1 -1
- package/dist/react/use-model-enablement.js +5 -1
- package/dist/react/use-model-enablement.js.map +1 -1
- package/dist/react/use-model-store.d.ts +31 -0
- package/dist/react/use-model-store.d.ts.map +1 -1
- package/dist/react/use-model-store.js +31 -2
- package/dist/react/use-model-store.js.map +1 -1
- package/dist/react/use-opencode-events/handle-event.d.ts.map +1 -1
- package/dist/react/use-opencode-events/handle-event.js +26 -0
- package/dist/react/use-opencode-events/handle-event.js.map +1 -1
- package/dist/react/use-opencode-events/helpers.d.ts +49 -5
- package/dist/react/use-opencode-events/helpers.d.ts.map +1 -1
- package/dist/react/use-opencode-events/helpers.js +54 -6
- package/dist/react/use-opencode-events/helpers.js.map +1 -1
- package/dist/react/use-opencode-events/index.d.ts.map +1 -1
- package/dist/react/use-opencode-events/index.js +80 -8
- package/dist/react/use-opencode-events/index.js.map +1 -1
- package/dist/react/use-opencode-events/rehydrate-targets.d.ts +18 -0
- package/dist/react/use-opencode-events/rehydrate-targets.d.ts.map +1 -0
- package/dist/react/use-opencode-events/rehydrate-targets.js +20 -0
- package/dist/react/use-opencode-events/rehydrate-targets.js.map +1 -0
- package/dist/react/use-opencode-events/stream-revival.d.ts +37 -0
- package/dist/react/use-opencode-events/stream-revival.d.ts.map +1 -0
- package/dist/react/use-opencode-events/stream-revival.js +53 -0
- package/dist/react/use-opencode-events/stream-revival.js.map +1 -0
- package/dist/react/use-opencode-events/use-event-stream-refs.d.ts.map +1 -1
- package/dist/react/use-opencode-events/use-event-stream-refs.js +14 -2
- package/dist/react/use-opencode-events/use-event-stream-refs.js.map +1 -1
- package/dist/react/use-opencode-local.d.ts.map +1 -1
- package/dist/react/use-opencode-local.js +27 -8
- package/dist/react/use-opencode-local.js.map +1 -1
- package/dist/react/use-opencode-pty.d.ts +7 -1
- package/dist/react/use-opencode-pty.d.ts.map +1 -1
- package/dist/react/use-opencode-pty.js +6 -2
- package/dist/react/use-opencode-pty.js.map +1 -1
- package/dist/react/use-opencode-sessions/agents.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/agents.js +13 -2
- package/dist/react/use-opencode-sessions/agents.js.map +1 -1
- package/dist/react/use-opencode-sessions/commands.d.ts +12 -0
- package/dist/react/use-opencode-sessions/commands.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/commands.js +15 -3
- package/dist/react/use-opencode-sessions/commands.js.map +1 -1
- package/dist/react/use-opencode-sessions/index.d.ts +1 -0
- package/dist/react/use-opencode-sessions/index.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/index.js +1 -0
- package/dist/react/use-opencode-sessions/index.js.map +1 -1
- package/dist/react/use-opencode-sessions/keys.d.ts +8 -0
- package/dist/react/use-opencode-sessions/keys.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/keys.js +8 -0
- package/dist/react/use-opencode-sessions/keys.js.map +1 -1
- package/dist/react/use-opencode-sessions/providers.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/providers.js +56 -5
- package/dist/react/use-opencode-sessions/providers.js.map +1 -1
- package/dist/react/use-opencode-sessions/shared.d.ts +23 -0
- package/dist/react/use-opencode-sessions/shared.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/shared.js +31 -0
- package/dist/react/use-opencode-sessions/shared.js.map +1 -1
- package/dist/react/use-opencode-sessions/vcs.d.ts +28 -0
- package/dist/react/use-opencode-sessions/vcs.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/vcs.js +42 -0
- package/dist/react/use-opencode-sessions/vcs.js.map +1 -0
- package/dist/react/use-poll-owner.d.ts +14 -0
- package/dist/react/use-poll-owner.d.ts.map +1 -0
- package/dist/react/use-poll-owner.js +32 -0
- package/dist/react/use-poll-owner.js.map +1 -0
- package/dist/react/use-project-llm-gateway.d.ts +27 -0
- package/dist/react/use-project-llm-gateway.d.ts.map +1 -0
- package/dist/react/use-project-llm-gateway.js +41 -0
- package/dist/react/use-project-llm-gateway.js.map +1 -0
- package/dist/react/use-project-models.d.ts +9 -0
- package/dist/react/use-project-models.d.ts.map +1 -1
- package/dist/react/use-project-models.js +24 -1
- package/dist/react/use-project-models.js.map +1 -1
- package/dist/react/use-runtime-reconnect.d.ts +11 -0
- package/dist/react/use-runtime-reconnect.d.ts.map +1 -1
- package/dist/react/use-runtime-reconnect.js +34 -3
- package/dist/react/use-runtime-reconnect.js.map +1 -1
- package/dist/react/use-session-prompts.d.ts +53 -3
- package/dist/react/use-session-prompts.d.ts.map +1 -1
- package/dist/react/use-session-prompts.js +133 -21
- package/dist/react/use-session-prompts.js.map +1 -1
- package/dist/react/use-session-send.d.ts +17 -0
- package/dist/react/use-session-send.d.ts.map +1 -1
- package/dist/react/use-session-send.js +54 -5
- package/dist/react/use-session-send.js.map +1 -1
- package/dist/react/use-session-start-give-up.d.ts +20 -0
- package/dist/react/use-session-start-give-up.d.ts.map +1 -0
- package/dist/react/use-session-start-give-up.js +60 -0
- package/dist/react/use-session-start-give-up.js.map +1 -0
- package/dist/react/use-session-sync.d.ts +35 -1
- package/dist/react/use-session-sync.d.ts.map +1 -1
- package/dist/react/use-session-sync.js +135 -53
- package/dist/react/use-session-sync.js.map +1 -1
- package/dist/react/use-session-working.d.ts +55 -0
- package/dist/react/use-session-working.d.ts.map +1 -1
- package/dist/react/use-session-working.js +114 -13
- package/dist/react/use-session-working.js.map +1 -1
- package/dist/react/use-session.d.ts +13 -13
- package/dist/react/use-session.d.ts.map +1 -1
- package/dist/react/use-session.js +74 -53
- package/dist/react/use-session.js.map +1 -1
- package/dist/react/use-static-file-preview.d.ts +12 -0
- package/dist/react/use-static-file-preview.d.ts.map +1 -0
- package/dist/react/use-static-file-preview.js +119 -0
- package/dist/react/use-static-file-preview.js.map +1 -0
- package/dist/react/use-wake-escalation.d.ts +51 -0
- package/dist/react/use-wake-escalation.d.ts.map +1 -0
- package/dist/react/use-wake-escalation.js +62 -0
- package/dist/react/use-wake-escalation.js.map +1 -0
- package/package.json +6 -4
- package/dist/browser/session-sync/session-transcript-cache.d.ts +0 -79
- package/dist/browser/session-sync/session-transcript-cache.d.ts.map +0 -1
- package/dist/browser/session-sync/session-transcript-cache.js +0 -91
- package/dist/browser/session-sync/session-transcript-cache.js.map +0 -1
- package/dist/core/rest/projects-client/public-voice-join.d.ts +0 -59
- package/dist/core/rest/projects-client/public-voice-join.d.ts.map +0 -1
- package/dist/core/rest/projects-client/public-voice-join.js +0 -64
- package/dist/core/rest/projects-client/public-voice-join.js.map +0 -1
- package/dist/core/rest/projects-client/transcription.d.ts +0 -5
- package/dist/core/rest/projects-client/transcription.d.ts.map +0 -1
- package/dist/core/rest/projects-client/transcription.js +0 -14
- package/dist/core/rest/projects-client/transcription.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/core/session/preview.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA6CH;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAMf;AAED
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/core/session/preview.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA6CH;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAMf;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAUnE;AAED,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ5E"}
|
|
@@ -59,13 +59,20 @@ export function buildPreviewAuthEndpoint(previewUrl, serverUrl) {
|
|
|
59
59
|
derivePreviewAuthEndpoint(previewUrl));
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
62
|
+
* Preview ORIGIN form: `p{port}-{sandbox}.{host}` locally, or the deployed
|
|
63
|
+
* `{env}-p{port}-{sandbox}.{domain}`.
|
|
64
|
+
*
|
|
65
|
+
* These can't use the host-only `/v1/p/` session cookie — it never reaches
|
|
66
|
+
* another hostname — so they authenticate the FIRST request with a one-shot
|
|
67
|
+
* `?token`, which the proxy exchanges for a cookie on the preview origin and
|
|
68
|
+
* then strips. Every later request (sub-resources, `fetch`, WebSockets) rides
|
|
69
|
+
* that cookie, which is the only credential an app's own code can carry.
|
|
65
70
|
*/
|
|
66
71
|
export function isSubdomainPreviewUrl(candidateUrl) {
|
|
67
72
|
try {
|
|
68
|
-
|
|
73
|
+
const { hostname } = new URL(candidateUrl);
|
|
74
|
+
return (/^p\d+-[^.]+\./.test(hostname)
|
|
75
|
+
|| /^(?:dev|staging|prod|preview)-p\d+-[a-z0-9-]+\./i.test(hostname));
|
|
69
76
|
}
|
|
70
77
|
catch {
|
|
71
78
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../src/core/session/preview.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,SAAS,yBAAyB,CAAC,YAAoB;IACrD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;QAElC,IAAI,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/C,OAAO,GAAG,GAAG,CAAC,MAAM,YAAY,CAAC;QACnC,CAAC;QAED,MAAM,YAAY,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACjD,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE,CAAC;YACxB,OAAO,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC;QACtE,CAAC;QAED,OAAO,GAAG,GAAG,CAAC,MAAM,YAAY,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,YAAoB,EAAE,SAAkB;IACjE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;QAClC,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC;QAC1B,MAAM,aAAa,GACjB,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC;YACzC,uBAAuB,CAAC,IAAI,C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;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,UAAkB,EAClB,SAAkB;IAElB,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3D,OAAO,CACL,CAAC,SAAS,CAAC,CAAC,CAAC,yBAAyB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACzD,yBAAyB,CAAC,UAAU,CAAC,CACtC,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAoB;IACxD,IAAI,CAAC;QACH,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;QAC3C,OAAO,CACL,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC;eAC3B,kDAAkD,CAAC,IAAI,CAAC,QAAQ,CAAC,CACrE,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,kBAAkB,CAAC,UAAkB,EAAE,KAAa;IAClE,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;QAC9B,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACnC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,UAAU,CAAC;IACpB,CAAC;AACH,CAAC"}
|
|
@@ -9,16 +9,27 @@
|
|
|
9
9
|
* 1. Which locally-known messages does a staged rewind hide?
|
|
10
10
|
* 2. When is a message id inside the range a committed rewind must delete?
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
12
|
+
* The window is a SET of message ids, captured at stage time. It used to be a
|
|
13
|
+
* lexical id RANGE — `id >= messageId && id <= watermark` — which assumed ids
|
|
14
|
+
* ascend with time. OpenCode 1.18.15 retired that invariant outright (turn
|
|
15
|
+
* exit now reads `lastAssistant.parentID === lastUser.id`, and
|
|
16
|
+
* `MessageV2.latest()` orders by `time.created` with the id only as a
|
|
17
|
+
* tie-break), and the range failed in both directions:
|
|
18
|
+
*
|
|
19
|
+
* - **under-delete** — a reverted assistant message whose id happens to sort
|
|
20
|
+
* BELOW the boundary falls outside the interval, survives the commit,
|
|
21
|
+
* is orphaned, and reappears at the top of the chat;
|
|
22
|
+
* - **over-delete** — `ascendingId` stubs sit ~2.8e13 above every real id, so
|
|
23
|
+
* a single in-flight optimistic message pushed the watermark to
|
|
24
|
+
* effectively infinity and the interval swallowed the user's replacement
|
|
25
|
+
* prompt and its answer.
|
|
26
|
+
*
|
|
27
|
+
* Membership has neither failure. `hiddenIds` is the exact list of messages
|
|
28
|
+
* that were part of the abandoned trajectory at the moment the rewind was
|
|
29
|
+
* staged: nothing minted afterwards can enter it, and nothing inside it can
|
|
30
|
+
* escape on an id comparison. `watermark` is retained as a published field —
|
|
31
|
+
* it names the newest message known at stage time — and still answers
|
|
32
|
+
* {@link isWithinRewindWindow} for a legacy state that carries no `hiddenIds`.
|
|
22
33
|
*/
|
|
23
34
|
export interface SessionRewindState {
|
|
24
35
|
/** The message the rewind pointer sits at — hidden along with everything
|
|
@@ -26,10 +37,25 @@ export interface SessionRewindState {
|
|
|
26
37
|
messageId: string;
|
|
27
38
|
/**
|
|
28
39
|
* The newest message id known locally at the moment this rewind was staged
|
|
29
|
-
* (or first observed)
|
|
30
|
-
*
|
|
40
|
+
* (or first observed) — see {@link newestMessageId}.
|
|
41
|
+
*
|
|
42
|
+
* No longer the upper bound of anything: {@link hiddenIds} is the window.
|
|
43
|
+
* Retained because it is a published field, and because it is the only
|
|
44
|
+
* bound available to a legacy state that carries no `hiddenIds`.
|
|
31
45
|
*/
|
|
32
46
|
watermark: string;
|
|
47
|
+
/**
|
|
48
|
+
* The exact messages this rewind abandons — the boundary message and
|
|
49
|
+
* everything that followed it in the transcript, captured ONCE at stage
|
|
50
|
+
* time and never recomputed. Membership in this list is the whole of the
|
|
51
|
+
* hide/delete test; see the module comment for the two failures the lexical
|
|
52
|
+
* range it replaced produced.
|
|
53
|
+
*
|
|
54
|
+
* Optional only for backward compatibility: a `SessionRewindState` built by
|
|
55
|
+
* an older consumer (or restored from one) has none, and falls back to the
|
|
56
|
+
* legacy range. Everything in this SDK populates it.
|
|
57
|
+
*/
|
|
58
|
+
hiddenIds?: readonly string[];
|
|
33
59
|
/**
|
|
34
60
|
* False once the replacement prompt has been sent (or a
|
|
35
61
|
* `session.next.revert.committed` wire event says the server has). The
|
|
@@ -40,32 +66,49 @@ export interface SessionRewindState {
|
|
|
40
66
|
*/
|
|
41
67
|
staged: boolean;
|
|
42
68
|
}
|
|
43
|
-
/** Whether `id`
|
|
44
|
-
*
|
|
45
|
-
*
|
|
69
|
+
/** Whether `id` is one of the messages this rewind abandons.
|
|
70
|
+
*
|
|
71
|
+
* Membership in the set captured at stage time — never a comparison between
|
|
72
|
+
* two id strings, which say nothing about which message came first. The
|
|
73
|
+
* legacy `[messageId, watermark]` range answers only for a state that
|
|
74
|
+
* carries no captured set. */
|
|
46
75
|
export declare function isWithinRewindWindow(id: string, rewind: SessionRewindState): boolean;
|
|
47
76
|
/**
|
|
48
|
-
* The newest
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
77
|
+
* The newest message in `messages`, by `time.created` with the id as the only
|
|
78
|
+
* tie-break — the same order the server's own `MessageV2.latest()` uses.
|
|
79
|
+
* `null` for an empty list.
|
|
80
|
+
*
|
|
81
|
+
* Deliberately a max-scan, not "the last element": most callers pass an
|
|
82
|
+
* ordered list, but an optimistic entry appended out of order must never win
|
|
83
|
+
* by position alone. A message with no `time` cannot be dated, so it competes
|
|
84
|
+
* on its id only.
|
|
52
85
|
*/
|
|
53
86
|
export declare function newestMessageId<T extends {
|
|
54
87
|
info: {
|
|
55
88
|
id: string;
|
|
89
|
+
time?: {
|
|
90
|
+
created?: number;
|
|
91
|
+
};
|
|
56
92
|
};
|
|
57
93
|
}>(messages: T[]): string | null;
|
|
58
94
|
/**
|
|
59
95
|
* Build the state for a freshly staged (or freshly discovered) rewind.
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
96
|
+
*
|
|
97
|
+
* The window is captured HERE and never recomputed: `hiddenIds` is the
|
|
98
|
+
* boundary message plus every message that follows it in `messages`, taken in
|
|
99
|
+
* the order the caller holds them — which is the server's own
|
|
100
|
+
* `time.created` page order, not an id order. Falls back to `messageId`
|
|
101
|
+
* itself when the boundary is not in the list (a cross-tab or reload
|
|
102
|
+
* discovery with no synced messages for this session), which hides only the
|
|
103
|
+
* boundary message — the narrowest correct answer with no other information
|
|
104
|
+
* available.
|
|
65
105
|
*/
|
|
66
106
|
export declare function stageSessionRewind<T extends {
|
|
67
107
|
info: {
|
|
68
108
|
id: string;
|
|
109
|
+
time?: {
|
|
110
|
+
created?: number;
|
|
111
|
+
};
|
|
69
112
|
};
|
|
70
113
|
}>(messages: T[], messageId: string): SessionRewindState;
|
|
71
114
|
/** Hide the target message and every message up to the staged watermark.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewind.d.ts","sourceRoot":"","sources":["../../../src/core/session/rewind.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rewind.d.ts","sourceRoot":"","sources":["../../../src/core/session/rewind.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,MAAM,WAAW,kBAAkB;IACjC;6BACyB;IACzB,SAAS,EAAE,M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|
|
10
10
|
* 2. When is a message id inside the range a committed rewind must delete?
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
12
|
+
* The window is a SET of message ids, captured at stage time. It used to be a
|
|
13
|
+
* lexical id RANGE — `id >= messageId && id <= watermark` — which assumed ids
|
|
14
|
+
* ascend with time. OpenCode 1.18.15 retired that invariant outright (turn
|
|
15
|
+
* exit now reads `lastAssistant.parentID === lastUser.id`, and
|
|
16
|
+
* `MessageV2.latest()` orders by `time.created` with the id only as a
|
|
17
|
+
* tie-break), and the range failed in both directions:
|
|
18
|
+
*
|
|
19
|
+
* - **under-delete** — a reverted assistant message whose id happens to sort
|
|
20
|
+
* BELOW the boundary falls outside the interval, survives the commit,
|
|
21
|
+
* is orphaned, and reappears at the top of the chat;
|
|
22
|
+
* - **over-delete** — `ascendingId` stubs sit ~2.8e13 above every real id, so
|
|
23
|
+
* a single in-flight optimistic message pushed the watermark to
|
|
24
|
+
* effectively infinity and the interval swallowed the user's replacement
|
|
25
|
+
* prompt and its answer.
|
|
26
|
+
*
|
|
27
|
+
* Membership has neither failure. `hiddenIds` is the exact list of messages
|
|
28
|
+
* that were part of the abandoned trajectory at the moment the rewind was
|
|
29
|
+
* staged: nothing minted afterwards can enter it, and nothing inside it can
|
|
30
|
+
* escape on an id comparison. `watermark` is retained as a published field —
|
|
31
|
+
* it names the newest message known at stage time — and still answers
|
|
32
|
+
* {@link isWithinRewindWindow} for a legacy state that carries no `hiddenIds`.
|
|
22
33
|
*/
|
|
23
|
-
/** Whether `id`
|
|
24
|
-
*
|
|
25
|
-
*
|
|
34
|
+
/** Whether `id` is one of the messages this rewind abandons.
|
|
35
|
+
*
|
|
36
|
+
* Membership in the set captured at stage time — never a comparison between
|
|
37
|
+
* two id strings, which say nothing about which message came first. The
|
|
38
|
+
* legacy `[messageId, watermark]` range answers only for a state that
|
|
39
|
+
* carries no captured set. */
|
|
26
40
|
export function isWithinRewindWindow(id, rewind) {
|
|
41
|
+
if (rewind.hiddenIds)
|
|
42
|
+
return rewind.hiddenIds.includes(id);
|
|
27
43
|
return id >= rewind.messageId && id <= rewind.watermark;
|
|
28
44
|
}
|
|
29
45
|
/**
|
|
30
|
-
* The newest
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
46
|
+
* The newest message in `messages`, by `time.created` with the id as the only
|
|
47
|
+
* tie-break — the same order the server's own `MessageV2.latest()` uses.
|
|
48
|
+
* `null` for an empty list.
|
|
49
|
+
*
|
|
50
|
+
* Deliberately a max-scan, not "the last element": most callers pass an
|
|
51
|
+
* ordered list, but an optimistic entry appended out of order must never win
|
|
52
|
+
* by position alone. A message with no `time` cannot be dated, so it competes
|
|
53
|
+
* on its id only.
|
|
34
54
|
*/
|
|
35
55
|
export function newestMessageId(messages) {
|
|
36
|
-
let
|
|
56
|
+
let bestId = null;
|
|
57
|
+
let bestCreated;
|
|
37
58
|
for (const message of messages) {
|
|
38
|
-
|
|
39
|
-
|
|
59
|
+
const { id } = message.info;
|
|
60
|
+
const created = message.info.time?.created;
|
|
61
|
+
if (bestId === null) {
|
|
62
|
+
bestId = id;
|
|
63
|
+
bestCreated = created;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (created !== undefined && bestCreated !== undefined) {
|
|
67
|
+
if (created > bestCreated || (created === bestCreated && id > bestId)) {
|
|
68
|
+
bestId = id;
|
|
69
|
+
bestCreated = created;
|
|
70
|
+
}
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (created !== undefined && bestCreated === undefined) {
|
|
74
|
+
bestId = id;
|
|
75
|
+
bestCreated = created;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (created === undefined && bestCreated === undefined && id > bestId) {
|
|
79
|
+
bestId = id;
|
|
80
|
+
}
|
|
40
81
|
}
|
|
41
|
-
return
|
|
82
|
+
return bestId;
|
|
42
83
|
}
|
|
43
84
|
/**
|
|
44
85
|
* Build the state for a freshly staged (or freshly discovered) rewind.
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
86
|
+
*
|
|
87
|
+
* The window is captured HERE and never recomputed: `hiddenIds` is the
|
|
88
|
+
* boundary message plus every message that follows it in `messages`, taken in
|
|
89
|
+
* the order the caller holds them — which is the server's own
|
|
90
|
+
* `time.created` page order, not an id order. Falls back to `messageId`
|
|
91
|
+
* itself when the boundary is not in the list (a cross-tab or reload
|
|
92
|
+
* discovery with no synced messages for this session), which hides only the
|
|
93
|
+
* boundary message — the narrowest correct answer with no other information
|
|
94
|
+
* available.
|
|
50
95
|
*/
|
|
51
96
|
export function stageSessionRewind(messages, messageId) {
|
|
97
|
+
const boundary = messages.findIndex((message) => message.info.id === messageId);
|
|
98
|
+
const hiddenIds = boundary === -1 ? [messageId] : messages.slice(boundary).map((message) => message.info.id);
|
|
52
99
|
return {
|
|
53
100
|
messageId,
|
|
54
101
|
watermark: newestMessageId(messages) ?? messageId,
|
|
102
|
+
hiddenIds,
|
|
55
103
|
staged: true,
|
|
56
104
|
};
|
|
57
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewind.js","sourceRoot":"","sources":["../../../src/core/session/rewind.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rewind.js","sourceRoot":"","sources":["../../../src/core/session/rewind.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAsCH;;;;;+BAK+B;AAC/B,MAAM,UAAU,oBAAoB,CAAC,EAAU,EAAE,MAA0B;IACzE,IAAI,MAAM,CAAC,SAAS;QAAE,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC3D,OAAO,EAAE,IAAI,MAAM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CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC;IAChF,MAAM,SAAS,GACb,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7F,OAAO;QACL,SAAS;QACT,SAAS,EAAE,eAAe,CAAC,QAAQ,CAAC,IAAI,SAAS;QACjD,SAAS;QACT,MAAM,EAAE,IAAI;KACb,CAAC;AACJ,CAAC;AAED;;4EAE4E;AAC5E,MAAM,UAAU,oBAAoB,CAClC,QAAa,EACb,MAAiC;IAEjC,IAAI,CAAC,MAAM;QAAE,OAAO,QAAQ,CAAC;IAC7B,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1F,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3D,CAAC;AAED;;;4EAG4E;AAC5E,MAAM,UAAU,mBAAmB,CACjC,MAAiC;IAEjC,OAAO,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AAChE,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ResolvedPreviewOptions } from '../preview-options.js';
|
|
1
2
|
/**
|
|
2
3
|
* Active-runtime resolution, framework-free. These are the read helpers the
|
|
3
4
|
* isomorphic core (`createKortix`, the opencode client factory) resolves the
|
|
@@ -32,18 +33,15 @@ export declare function getActiveDbSandboxId(): string | undefined;
|
|
|
32
33
|
*/
|
|
33
34
|
export declare function getBackendPort(): number;
|
|
34
35
|
/**
|
|
35
|
-
*
|
|
36
|
+
* Preview URL options for the ACTIVE runtime — the ambient path, used where no
|
|
37
|
+
* session handle is in scope: `useSandboxProxy`, `proxySandboxUrl`,
|
|
38
|
+
* `buildStaticFilePreviewUrl`, the session panel's app-preview iframe.
|
|
36
39
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* and 403'd the preview proxy).
|
|
40
|
+
* A thin binding of the active sandbox id to `resolvePreviewOptions`, which is
|
|
41
|
+
* the single producer of a complete options bag. It deliberately assembles
|
|
42
|
+
* nothing itself: this function once did, and quietly omitted
|
|
43
|
+
* `previewUrlTemplate`, which made every ambient preview fall back to the path
|
|
44
|
+
* proxy. See preview-options.ts.
|
|
43
45
|
*/
|
|
44
|
-
export declare function deriveSubdomainOpts():
|
|
45
|
-
sandboxId: string;
|
|
46
|
-
backendPort: number;
|
|
47
|
-
apiBaseUrl: string;
|
|
48
|
-
};
|
|
46
|
+
export declare function deriveSubdomainOpts(): ResolvedPreviewOptions;
|
|
49
47
|
//# sourceMappingURL=active.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active.d.ts","sourceRoot":"","sources":["../../../../src/core/session/server-store/active.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"active.d.ts","sourceRoot":"","sources":["../../../../src/core/session/server-store/active.ts"],"names":[],"mappings":"AAOA,OAAO,EAAyB,KAAK,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAExF;;;;;GAKG;AAEH;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAQ7C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAEvD;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,SAAS,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAOvC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,IAAI,sBAAsB,CAM5D"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { platformConfig } from '../../http/config.js';
|
|
2
2
|
import { getCurrentRuntimeDbSandboxId, getCurrentRuntimeSandboxId, getCurrentRuntimeUrl, } from '../current-runtime.js';
|
|
3
3
|
import { getBackendUrl, getDefaultSandboxUrl } from './url-helpers.js';
|
|
4
|
+
import { resolvePreviewOptions } from '../preview-options.js';
|
|
4
5
|
/**
|
|
5
6
|
* Active-runtime resolution, framework-free. These are the read helpers the
|
|
6
7
|
* isomorphic core (`createKortix`, the opencode client factory) resolves the
|
|
@@ -57,20 +58,21 @@ export function getBackendPort() {
|
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
|
-
*
|
|
61
|
+
* Preview URL options for the ACTIVE runtime — the ambient path, used where no
|
|
62
|
+
* session handle is in scope: `useSandboxProxy`, `proxySandboxUrl`,
|
|
63
|
+
* `buildStaticFilePreviewUrl`, the session panel's app-preview iframe.
|
|
61
64
|
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* and 403'd the preview proxy).
|
|
65
|
+
* A thin binding of the active sandbox id to `resolvePreviewOptions`, which is
|
|
66
|
+
* the single producer of a complete options bag. It deliberately assembles
|
|
67
|
+
* nothing itself: this function once did, and quietly omitted
|
|
68
|
+
* `previewUrlTemplate`, which made every ambient preview fall back to the path
|
|
69
|
+
* proxy. See preview-options.ts.
|
|
68
70
|
*/
|
|
69
71
|
export function deriveSubdomainOpts() {
|
|
70
|
-
return {
|
|
72
|
+
return resolvePreviewOptions({
|
|
71
73
|
sandboxId: getActiveSandboxId() || '',
|
|
72
74
|
backendPort: getBackendPort(),
|
|
73
75
|
apiBaseUrl: getBackendUrl(),
|
|
74
|
-
};
|
|
76
|
+
});
|
|
75
77
|
}
|
|
76
78
|
//# sourceMappingURL=active.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active.js","sourceRoot":"","sources":["../../../../src/core/session/server-store/active.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"active.js","sourceRoot":"","sources":["../../../../src/core/session/server-store/active.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAA+B,MAAM,oBAAoB,CAAC;AAExF;;;;;GAKG;AAEH;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,OAAO,GAAG,oBAAoB,EAAE,CAAC;IACvC,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAC5B,4EAA4E;IAC5E,qEAAqE;IACrE,IAAI,cAAc,EAAE,CAAC,cAAc,IAAI,KAAK;QAAE,OAAO,EAAE,CAAC;IACxD,gEAAgE;IAChE,OAAO,oBAAoB,EAAE,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,0BAA0B,EAAE,IAAI,cAAc,EAAE,CAAC,SAAS,IAAI,SAAS,CAAC;AACjF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,4BAA4B,EAAE,IAAI,SAAS,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC;QACrC,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACjF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC,CAAC,yBAAyB;IACxC,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,qBAAqB,CAAC;QAC3B,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE;QACrC,WAAW,EAAE,cAAc,EAAE;QAC7B,UAAU,EAAE,aAAa,EAAE;KAC5B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The backend base URL.
|
|
3
|
-
*
|
|
2
|
+
* The backend base URL.
|
|
3
|
+
*
|
|
4
|
+
* CONTROL traffic — the OpenCode/daemon REST channel on port 8000 — routes
|
|
5
|
+
* through the path proxy, `/v1/p/{sandboxId}/{port}/*`, and stays there: it is
|
|
6
|
+
* a programmatic transport with a per-request bearer token, not a browser
|
|
7
|
+
* surface, so a per-preview origin buys it nothing and would put turn delivery
|
|
8
|
+
* behind wildcard DNS, a certificate and an edge Worker.
|
|
9
|
+
*
|
|
10
|
+
* BROWSER traffic goes to the preview ORIGIN this deployment advertises via
|
|
11
|
+
* `GET /v1/p/config` — see core/session/preview-config.ts and `rewriteLocalhostUrl`.
|
|
12
|
+
* Those are the only two forms, and only those two functions choose between them.
|
|
4
13
|
*/
|
|
5
14
|
export declare function getBackendUrl(): string;
|
|
6
15
|
export declare function getDefaultSandboxUrl(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-helpers.d.ts","sourceRoot":"","sources":["../../../../src/core/session/server-store/url-helpers.ts"],"names":[],"mappings":"AAUA
|
|
1
|
+
{"version":3,"file":"url-helpers.d.ts","sourceRoot":"","sources":["../../../../src/core/session/server-store/url-helpers.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,wBAAgB,oBAAoB,IAAI,MAAM,CAM7C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAErE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7E"}
|
|
@@ -8,8 +8,17 @@ function stripTrailingSlashes(s) {
|
|
|
8
8
|
return s.slice(0, end);
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* The backend base URL.
|
|
12
|
-
*
|
|
11
|
+
* The backend base URL.
|
|
12
|
+
*
|
|
13
|
+
* CONTROL traffic — the OpenCode/daemon REST channel on port 8000 — routes
|
|
14
|
+
* through the path proxy, `/v1/p/{sandboxId}/{port}/*`, and stays there: it is
|
|
15
|
+
* a programmatic transport with a per-request bearer token, not a browser
|
|
16
|
+
* surface, so a per-preview origin buys it nothing and would put turn delivery
|
|
17
|
+
* behind wildcard DNS, a certificate and an edge Worker.
|
|
18
|
+
*
|
|
19
|
+
* BROWSER traffic goes to the preview ORIGIN this deployment advertises via
|
|
20
|
+
* `GET /v1/p/config` — see core/session/preview-config.ts and `rewriteLocalhostUrl`.
|
|
21
|
+
* Those are the only two forms, and only those two functions choose between them.
|
|
13
22
|
*/
|
|
14
23
|
export function getBackendUrl() {
|
|
15
24
|
return stripTrailingSlashes(platformConfig().backendUrl || 'http://localhost:8008/v1');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-helpers.js","sourceRoot":"","sources":["../../../../src/core/session/server-store/url-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,mEAAmE;AACnE,mEAAmE;AACnE,SAAS,oBAAoB,CAAC,CAAS;IACrC,IAAI,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,SAAS;QAAE,GAAG,EAAE,CAAC;IAChE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACzB,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"url-helpers.js","sourceRoot":"","sources":["../../../../src/core/session/server-store/url-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,mEAAmE;AACnE,mEAAmE;AACnE,SAAS,oBAAoB,CAAC,CAAS;IACrC,IAAI,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,SAAS;QAAE,GAAG,EAAE,CAAC;IAChE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACzB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,oBAAoB,CAAC,cAAc,EAAE,CAAC,UAAU,IAAI,0BAA0B,CAAC,CAAC;AACzF,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,4EAA4E;IAC5E,mEAAmE;IACnE,MAAM,SAAS,GAAG,cAAc,EAAE,CAAC,SAAS,CAAC;IAC7C,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,CAAC;IAC1B,OAAO,GAAG,aAAa,EAAE,MAAM,SAAS,OAAO,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACnD,OAAO,GAAG,aAAa,EAAE,MAAM,SAAS,OAAO,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,UAAkB;IAC3D,OAAO,mBAAmB,CAAC,UAAU,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAa,EAAE,IAAY;IACnE,OAAO,GAAG,aAAa,EAAE,mBAAmB,KAAK,IAAI,IAAI,EAAE,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framing a file from the sandbox's static file server.
|
|
3
|
+
*
|
|
4
|
+
* A host that wants to SHOW an HTML file has exactly one correct move: load it
|
|
5
|
+
* from the server that ships inside the sandbox (port 3211, `/open?path=…`) and
|
|
6
|
+
* frame that URL. The tempting shortcut — hand the file's text to an iframe as
|
|
7
|
+
* `srcDoc` — cannot work, and not for a reason a flag can fix: `srcDoc` gives
|
|
8
|
+
* the document no URL at all, so `./style.css`, `img/logo.png` and `app.js`
|
|
9
|
+
* have no base to resolve against. A page written as a page arrives unstyled.
|
|
10
|
+
*
|
|
11
|
+
* Two rules live here rather than in the hook, because both are decisions and
|
|
12
|
+
* neither needs a network to be reasoned about.
|
|
13
|
+
*/
|
|
14
|
+
import { type SubdomainUrlOptions } from './url.js';
|
|
15
|
+
/** Where to frame from, and where to ask whether framing will work yet. */
|
|
16
|
+
export interface StaticFilePreviewTargets {
|
|
17
|
+
/** The proxied `/open?path=…` URL for the file itself. */
|
|
18
|
+
previewUrl: string;
|
|
19
|
+
/** The same service's `/health`, used to wait out a still-booting sandbox. */
|
|
20
|
+
healthUrl: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Resolve both URLs for one file, or `null` when there is nothing to address.
|
|
24
|
+
*
|
|
25
|
+
* The `null` is the whole point. `buildStaticFilePreviewUrl` answers with the
|
|
26
|
+
* INTERNAL form — `http://localhost:3211/open?path=…` — when no sandbox is
|
|
27
|
+
* bound, which is honest for a link that will be re-resolved on click and
|
|
28
|
+
* actively wrong for anything that loads or probes it now: that port is on the
|
|
29
|
+
* viewer's own machine. Framing it shows whatever the user happens to be
|
|
30
|
+
* running; probing it can answer `200` and mark a preview "ready" that can
|
|
31
|
+
* never load. A sandbox binds asynchronously, so every caller passes through
|
|
32
|
+
* this state on the way to a working preview — it is the common case, not an
|
|
33
|
+
* edge one.
|
|
34
|
+
*/
|
|
35
|
+
export declare function staticFilePreviewTargets(path: string | undefined, options: SubdomainUrlOptions): StaticFilePreviewTargets | null;
|
|
36
|
+
/** Gap between liveness probes, ms. */
|
|
37
|
+
export declare const STATIC_FILE_HEALTH_RETRY_MS = 1500;
|
|
38
|
+
/**
|
|
39
|
+
* How many probes before the wait becomes a reported failure.
|
|
40
|
+
*
|
|
41
|
+
* 20 × 1.5s ≈ 30s. The bound is not a guess about how long a sandbox takes to
|
|
42
|
+
* boot — it is the line past which silence stops being informative. Without it
|
|
43
|
+
* a surface spins "Starting preview server…" for the life of the tab; with it
|
|
44
|
+
* the user gets a sentence and a Retry.
|
|
45
|
+
*/
|
|
46
|
+
export declare const STATIC_FILE_HEALTH_MAX_ATTEMPTS = 20;
|
|
47
|
+
/** Whether a caller that has made `attempts` probes should make another. */
|
|
48
|
+
export declare function shouldRetryStaticFileHealth(attempts: number): boolean;
|
|
49
|
+
export declare function authenticatedUrlAddresses(authenticatedUrl: string | null | undefined, previewUrl: string | undefined): boolean;
|
|
50
|
+
//# sourceMappingURL=static-file-preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-file-preview.d.ts","sourceRoot":"","sources":["../../../src/core/session/static-file-preview.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,OAAO,CAAC;AAEf,2EAA2E;AAC3E,MAAM,WAAW,wBAAwB;IACvC,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,EAAE,mBAAmB,GAC3B,wBAAwB,GAAG,IAAI,CAQjC;AAED,uCAAuC;AACvC,eAAO,MAAM,2BAA2B,OAAQ,CAAC;AAEjD;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAElD,4EAA4E;AAC5E,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAErE;AAiCD,wBAAgB,yBAAyB,CACvC,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC3C,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAKT"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framing a file from the sandbox's static file server.
|
|
3
|
+
*
|
|
4
|
+
* A host that wants to SHOW an HTML file has exactly one correct move: load it
|
|
5
|
+
* from the server that ships inside the sandbox (port 3211, `/open?path=…`) and
|
|
6
|
+
* frame that URL. The tempting shortcut — hand the file's text to an iframe as
|
|
7
|
+
* `srcDoc` — cannot work, and not for a reason a flag can fix: `srcDoc` gives
|
|
8
|
+
* the document no URL at all, so `./style.css`, `img/logo.png` and `app.js`
|
|
9
|
+
* have no base to resolve against. A page written as a page arrives unstyled.
|
|
10
|
+
*
|
|
11
|
+
* Two rules live here rather than in the hook, because both are decisions and
|
|
12
|
+
* neither needs a network to be reasoned about.
|
|
13
|
+
*/
|
|
14
|
+
import { buildStaticFileHealthPreviewUrl, buildStaticFilePreviewUrl, hasPreviewTarget, } from './url.js';
|
|
15
|
+
/**
|
|
16
|
+
* Resolve both URLs for one file, or `null` when there is nothing to address.
|
|
17
|
+
*
|
|
18
|
+
* The `null` is the whole point. `buildStaticFilePreviewUrl` answers with the
|
|
19
|
+
* INTERNAL form — `http://localhost:3211/open?path=…` — when no sandbox is
|
|
20
|
+
* bound, which is honest for a link that will be re-resolved on click and
|
|
21
|
+
* actively wrong for anything that loads or probes it now: that port is on the
|
|
22
|
+
* viewer's own machine. Framing it shows whatever the user happens to be
|
|
23
|
+
* running; probing it can answer `200` and mark a preview "ready" that can
|
|
24
|
+
* never load. A sandbox binds asynchronously, so every caller passes through
|
|
25
|
+
* this state on the way to a working preview — it is the common case, not an
|
|
26
|
+
* edge one.
|
|
27
|
+
*/
|
|
28
|
+
export function staticFilePreviewTargets(path, options) {
|
|
29
|
+
if (!path)
|
|
30
|
+
return null;
|
|
31
|
+
if (!hasPreviewTarget(options))
|
|
32
|
+
return null;
|
|
33
|
+
const previewUrl = buildStaticFilePreviewUrl(path, options);
|
|
34
|
+
if (!previewUrl)
|
|
35
|
+
return null;
|
|
36
|
+
return { previewUrl, healthUrl: buildStaticFileHealthPreviewUrl(options) };
|
|
37
|
+
}
|
|
38
|
+
/** Gap between liveness probes, ms. */
|
|
39
|
+
export const STATIC_FILE_HEALTH_RETRY_MS = 1_500;
|
|
40
|
+
/**
|
|
41
|
+
* How many probes before the wait becomes a reported failure.
|
|
42
|
+
*
|
|
43
|
+
* 20 × 1.5s ≈ 30s. The bound is not a guess about how long a sandbox takes to
|
|
44
|
+
* boot — it is the line past which silence stops being informative. Without it
|
|
45
|
+
* a surface spins "Starting preview server…" for the life of the tab; with it
|
|
46
|
+
* the user gets a sentence and a Retry.
|
|
47
|
+
*/
|
|
48
|
+
export const STATIC_FILE_HEALTH_MAX_ATTEMPTS = 20;
|
|
49
|
+
/** Whether a caller that has made `attempts` probes should make another. */
|
|
50
|
+
export function shouldRetryStaticFileHealth(attempts) {
|
|
51
|
+
return attempts < STATIC_FILE_HEALTH_MAX_ATTEMPTS;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Does an authenticated preview URL address the file we are asking for?
|
|
55
|
+
*
|
|
56
|
+
* `useAuthenticatedPreviewUrl` resolves in an effect, so on the render where a
|
|
57
|
+
* viewer switches to a different file it still holds the PREVIOUS file's URL.
|
|
58
|
+
* Framing that shows the page the user just navigated away from.
|
|
59
|
+
*
|
|
60
|
+
* Compare NORMALIZED, never by prefix. The subdomain form authenticates with a
|
|
61
|
+
* one-shot `token` that `appendPreviewToken` adds through `URLSearchParams`,
|
|
62
|
+
* which re-serializes the WHOLE query — and the static file URL is the one
|
|
63
|
+
* preview URL that has a query, so `?path=/workspace/a.html` comes back as
|
|
64
|
+
* `?path=%2Fworkspace%2Fa.html`. No prefix of the original survives that, and a
|
|
65
|
+
* prefix test shipped a preview stuck on "Starting preview server…" forever:
|
|
66
|
+
* the server was up, the URL was authenticated, and the check said it belonged
|
|
67
|
+
* to a different file. A prefix is wrong in the other direction too —
|
|
68
|
+
* `a.html.bak` starts with the URL for `a.html`.
|
|
69
|
+
*
|
|
70
|
+
* Both sides go through the same `URL` round-trip, so both carry the same
|
|
71
|
+
* encoding; `token` is dropped because it is the credential, not the address.
|
|
72
|
+
*/
|
|
73
|
+
function normalizeAddress(candidate) {
|
|
74
|
+
try {
|
|
75
|
+
const url = new URL(candidate);
|
|
76
|
+
url.searchParams.delete('token');
|
|
77
|
+
url.searchParams.sort();
|
|
78
|
+
return url.toString();
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export function authenticatedUrlAddresses(authenticatedUrl, previewUrl) {
|
|
85
|
+
if (!authenticatedUrl || !previewUrl)
|
|
86
|
+
return false;
|
|
87
|
+
const authenticated = normalizeAddress(authenticatedUrl);
|
|
88
|
+
const wanted = normalizeAddress(previewUrl);
|
|
89
|
+
return authenticated !== null && authenticated === wanted;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=static-file-preview.js.map
|