@urun-sh/core 0.2.46 → 0.2.48

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/dist/internal.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __urunCreateRequire } from 'node:module'; const require = globalThis.require ?? __urunCreateRequire(import.meta.url);
2
- import{E as r,H as t,I as a,J as n,L as s,M as p,N as m,R as c,S as i,T as l,U as f,V as x,W as S,X as C,a as e,b as o}from"./chunk-DUCJ3UFC.mjs";export{e as ChannelMultiplexer,i as DOC_SYNC_WIRE_CONTRACT_VERSION,o as DeferredChannelMultiplexer,x as DeferredDocConnector,s as LoopbackStreamData,S as SessionDocumentImpl,c as TransportSession,r as allocateSession,C as createPresence,f as createWebsocketDocConnector,l as deriveYjsServerUrl,n as ensureNodeWebRTC,t as isNodeRuntime,a as nodeMediasoupHandlerName,m as streamDataLabel,p as transportStreamData};
2
+ import{E as r,H as t,I as n,J as a,L as s,M as p,N as m,R as c,S as i,T as l,U as S,V as f,W as x,X as C,a as e,b as o}from"./chunk-BQIH7RYF.mjs";export{e as ChannelMultiplexer,i as DOC_SYNC_WIRE_CONTRACT_VERSION,o as DeferredChannelMultiplexer,f as DeferredDocConnector,s as LoopbackStreamData,x as SessionDocumentImpl,c as TransportSession,r as allocateSession,C as createPresence,S as createWebsocketDocConnector,l as deriveYjsServerUrl,a as ensureNodeWebRTC,t as isNodeRuntime,n as nodeMediasoupHandlerName,m as streamDataLabel,p as transportStreamData};
@@ -35,6 +35,19 @@ declare function mediaRecorderChunkSource(binding: MediaChunkBinding, options?:
35
35
 
36
36
  declare const DOC_SYNC_WIRE_CONTRACT_VERSION = 1;
37
37
 
38
+ interface DocConnectionState {
39
+
40
+ connected: boolean;
41
+
42
+ consecutiveFailures: number;
43
+
44
+ lastCloseCode: number | null;
45
+
46
+ lastCloseReason: string | null;
47
+ }
48
+
49
+ type DocTokenSupplier = () => string | undefined | Promise<string | undefined>;
50
+
38
51
  interface DocConnection {
39
52
 
40
53
  readonly awareness: Awareness;
@@ -45,6 +58,8 @@ interface DocConnection {
45
58
 
46
59
  ensureConnected?(): void;
47
60
 
61
+ onConnectionState?(handler: (state: DocConnectionState) => void): () => void;
62
+
48
63
  destroy(): void;
49
64
  }
50
65
 
@@ -58,9 +73,13 @@ interface WebsocketDocConnectorOptions {
58
73
 
59
74
  sessionId: string;
60
75
 
61
- token?: string;
76
+ token?: string | DocTokenSupplier;
62
77
 
63
78
  WebSocketPolyfill?: typeof WebSocket;
79
+
80
+ maxBackoffTimeMs?: number;
81
+
82
+ dialTimeoutMs?: number;
64
83
  }
65
84
 
66
85
  declare function createWebsocketDocConnector(opts: WebsocketDocConnectorOptions): DocConnector;
@@ -104,8 +123,39 @@ interface RuntimeAvailability {
104
123
  state: 'unavailable' | 'starting' | 'busy';
105
124
 
106
125
  reason?: string;
126
+
127
+ wake?: RuntimeWakeDetail;
128
+ }
129
+
130
+ type RuntimeWakeReasonCode = 'capture-attested' | 'no-portable-golden' | 'portable-golden-release-mismatch' | 'portable-golden-attestation-invalid';
131
+
132
+ interface RuntimeWakeGolden {
133
+ snapshotId: string;
134
+ snapshotCompatKey: string;
135
+ artifactSizeBytes: number;
136
+ durableArenaBytes: number;
137
+ volatileArenaBytes: 0;
138
+ uncoveredWeightBytes: number;
139
+ }
140
+ interface RuntimeWakeDetailBase {
141
+ schema: 'urun.runtime.wake.v1';
142
+ expectationBasis: 'snapshot-registry';
143
+ restoreObservation: 'not-observed';
107
144
  }
108
145
 
146
+ type RuntimeWakeDetail = (RuntimeWakeDetailBase & {
147
+ portability: 'portable';
148
+ expectedWakePath: 'portable-golden-restore';
149
+ reasonCode: 'capture-attested';
150
+ golden: RuntimeWakeGolden;
151
+ }) | (RuntimeWakeDetailBase & {
152
+ portability: 'none';
153
+ expectedWakePath: 'cold-boot';
154
+ reasonCode: Exclude<RuntimeWakeReasonCode, 'capture-attested'>;
155
+
156
+ golden?: never;
157
+ });
158
+
109
159
  type SessionFailureKind = 'create-failed' | 'never-live' | 'transport-failed' | 'media-permission' | 'ended' | 'runtime-failed' | 'expired' | 'produce-timeout';
110
160
 
111
161
  interface SessionPhaseError {
@@ -278,6 +328,8 @@ interface SessionDocument {
278
328
  readonly synced: boolean;
279
329
 
280
330
  onSynced(handler: () => void): () => void;
331
+
332
+ onConnectionState?(handler: (state: DocConnectionState) => void): () => void;
281
333
  }
282
334
 
283
335
  interface SessionStream {
@@ -527,6 +579,8 @@ interface SessionGatewayResponse {
527
579
 
528
580
  runtime_reason?: string;
529
581
 
582
+ runtime_wake?: unknown;
583
+
530
584
  ends_at?: string;
531
585
  error_code?: string;
532
586
  error_message?: string;
@@ -748,28 +802,12 @@ declare class TransportSession {
748
802
 
749
803
  private _wakingSince;
750
804
 
751
- private _mediaMonitorTimer;
752
-
753
- private _lastInboundTotal;
754
-
755
- private _mediaEverFlowed;
756
-
757
- private _lastInboundAdvanceAt;
805
+ private _mediaProbeTimer;
758
806
 
759
- private _mediaDeathHandled;
760
-
761
- private _decodeSignalSeen;
762
-
763
- private _lastFramesDecoded;
764
-
765
- private _lastDecodeAdvanceAt;
807
+ private _joinProbes;
766
808
 
767
809
  private _decodeDeathHandled;
768
810
 
769
- private _latestInboundSample;
770
-
771
- private _decodeWindowStartSample;
772
-
773
811
  private _selectedCandidatePair;
774
812
 
775
813
  private _candidatePairDiagnosticEmitted;
@@ -902,13 +940,14 @@ declare class TransportSession {
902
940
 
903
941
  private _closeConsumersByProducer;
904
942
  private _mediaPollMs;
905
- private _mediaStallTimeoutMs;
906
943
 
907
- private _startMediaMonitor;
908
- private _stopMediaMonitor;
909
- private _sampleMediaLiveness;
944
+ private _firstFrameWindowMs;
945
+
946
+ private _startMediaProbe;
947
+ private _stopMediaProbe;
910
948
 
911
- private _checkDecodeLiveness;
949
+ private _resetJoinProbes;
950
+ private _sampleMediaArrival;
912
951
 
913
952
  private _renegotiate;
914
953
 
@@ -974,6 +1013,8 @@ declare class SessionDocumentImpl implements SessionDocument {
974
1013
 
975
1014
  ensureConnected(): void;
976
1015
 
1016
+ onConnectionState(handler: (state: DocConnectionState) => void): () => void;
1017
+
977
1018
  onSynced(handler: () => void): () => void;
978
1019
 
979
1020
  set(patch: Record<string, unknown>): void;
@@ -1032,4 +1073,4 @@ interface DataChannelTransport {
1032
1073
 
1033
1074
  declare function transportStreamData(transport: DataChannelTransport): StreamDataTransport;
1034
1075
 
1035
- export { type SessionStatus as $, type AccessTokenOptions$1 as A, type RecordingLifecycle as B, type ChannelEndpoint as C, DERIVED_LEG_SEP as D, type RecordingStatus as E, type RecordingsAccessor as F, type ReleaseSessionBeaconOptions as G, type RequestOptions as H, type RequestStreamOptions as I, type RuntimeArtifact as J, type RuntimeArtifactDownload as K, LoopbackStreamData as L, type MediaChunkBinding as M, type RuntimeArtifactsAccessor as N, type RuntimeAvailability as O, type Presence as P, type SessionDiagnostic as Q, type Recording as R, type Session as S, type SessionDocument as T, SessionDocumentImpl as U, type SessionEndResult as V, type SessionFailureKind as W, type SessionPhase as X, type SessionPhaseError as Y, type SessionPhaseName as Z, type SessionStartOptions as _, type AccessTokenOptions as a, type SessionStream as a0, type SessionText as a1, type Store as a2, type StoreOptions as a3, type StreamChunkOptions as a4, type StreamDataTransport as a5, TransportSession as a6, type TransportSessionOptions as a7, type TransportState as a8, allocateSession as a9, createPresence as aa, createWebsocketDocConnector as ab, deriveYjsServerUrl as ac, derivedLegName as ad, derivedLegRole as ae, isPendingRecording as af, mediaRecorderChunkSource as ag, prewake as ah, releaseSessionBeacon as ai, streamDataLabel as aj, transportStreamData as ak, type ActivationEvent as b, type ActivationState as c, type AllocateSessionOptions as d, type AllocatedSession as e, type App as f, type AppOptions as g, type AttachOptions as h, type ChannelMessage as i, ChannelMultiplexer as j, type ChannelName as k, type ChunkReadable as l, DOC_SYNC_WIRE_CONTRACT_VERSION as m, DeferredChannelMultiplexer as n, DeferredDocConnector as o, type DerivedLegRole as p, type DocConnection as q, type DocConnector as r, type MediaChunkSource as s, type MediaChunkSourceFactory as t, type MediaRecorderChunkSourceOptions as u, type PresenceState as v, type PrewakeOptions as w, type PrewakeResult as x, type PrewakeStatus as y, type RecordingBucket as z };
1076
+ export { type SessionFailureKind as $, type AccessTokenOptions$1 as A, type PrewakeStatus as B, type ChannelEndpoint as C, DERIVED_LEG_SEP as D, type RecordingBucket as E, type RecordingLifecycle as F, type RecordingStatus as G, type RecordingsAccessor as H, type ReleaseSessionBeaconOptions as I, type RequestOptions as J, type RequestStreamOptions as K, LoopbackStreamData as L, type MediaChunkBinding as M, type RuntimeArtifact as N, type RuntimeArtifactDownload as O, type Presence as P, type RuntimeArtifactsAccessor as Q, type Recording as R, type RuntimeAvailability as S, type RuntimeWakeDetail as T, type RuntimeWakeGolden as U, type RuntimeWakeReasonCode as V, type Session as W, type SessionDiagnostic as X, type SessionDocument as Y, SessionDocumentImpl as Z, type SessionEndResult as _, type AccessTokenOptions as a, type SessionPhase as a0, type SessionPhaseError as a1, type SessionPhaseName as a2, type SessionStartOptions as a3, type SessionStatus as a4, type SessionStream as a5, type SessionText as a6, type Store as a7, type StoreOptions as a8, type StreamChunkOptions as a9, type StreamDataTransport as aa, TransportSession as ab, type TransportSessionOptions as ac, type TransportState as ad, allocateSession as ae, createPresence as af, createWebsocketDocConnector as ag, deriveYjsServerUrl as ah, derivedLegName as ai, derivedLegRole as aj, isPendingRecording as ak, mediaRecorderChunkSource as al, prewake as am, releaseSessionBeacon as an, streamDataLabel as ao, transportStreamData as ap, type ActivationEvent as b, type ActivationState as c, type AllocateSessionOptions as d, type AllocatedSession as e, type App as f, type AppOptions as g, type AttachOptions as h, type ChannelMessage as i, ChannelMultiplexer as j, type ChannelName as k, type ChunkReadable as l, DOC_SYNC_WIRE_CONTRACT_VERSION as m, DeferredChannelMultiplexer as n, DeferredDocConnector as o, type DerivedLegRole as p, type DocConnection as q, type DocConnectionState as r, type DocConnector as s, type DocTokenSupplier as t, type MediaChunkSource as u, type MediaChunkSourceFactory as v, type MediaRecorderChunkSourceOptions as w, type PresenceState as x, type PrewakeOptions as y, type PrewakeResult as z };
@@ -35,6 +35,19 @@ declare function mediaRecorderChunkSource(binding: MediaChunkBinding, options?:
35
35
 
36
36
  declare const DOC_SYNC_WIRE_CONTRACT_VERSION = 1;
37
37
 
38
+ interface DocConnectionState {
39
+
40
+ connected: boolean;
41
+
42
+ consecutiveFailures: number;
43
+
44
+ lastCloseCode: number | null;
45
+
46
+ lastCloseReason: string | null;
47
+ }
48
+
49
+ type DocTokenSupplier = () => string | undefined | Promise<string | undefined>;
50
+
38
51
  interface DocConnection {
39
52
 
40
53
  readonly awareness: Awareness;
@@ -45,6 +58,8 @@ interface DocConnection {
45
58
 
46
59
  ensureConnected?(): void;
47
60
 
61
+ onConnectionState?(handler: (state: DocConnectionState) => void): () => void;
62
+
48
63
  destroy(): void;
49
64
  }
50
65
 
@@ -58,9 +73,13 @@ interface WebsocketDocConnectorOptions {
58
73
 
59
74
  sessionId: string;
60
75
 
61
- token?: string;
76
+ token?: string | DocTokenSupplier;
62
77
 
63
78
  WebSocketPolyfill?: typeof WebSocket;
79
+
80
+ maxBackoffTimeMs?: number;
81
+
82
+ dialTimeoutMs?: number;
64
83
  }
65
84
 
66
85
  declare function createWebsocketDocConnector(opts: WebsocketDocConnectorOptions): DocConnector;
@@ -104,8 +123,39 @@ interface RuntimeAvailability {
104
123
  state: 'unavailable' | 'starting' | 'busy';
105
124
 
106
125
  reason?: string;
126
+
127
+ wake?: RuntimeWakeDetail;
128
+ }
129
+
130
+ type RuntimeWakeReasonCode = 'capture-attested' | 'no-portable-golden' | 'portable-golden-release-mismatch' | 'portable-golden-attestation-invalid';
131
+
132
+ interface RuntimeWakeGolden {
133
+ snapshotId: string;
134
+ snapshotCompatKey: string;
135
+ artifactSizeBytes: number;
136
+ durableArenaBytes: number;
137
+ volatileArenaBytes: 0;
138
+ uncoveredWeightBytes: number;
139
+ }
140
+ interface RuntimeWakeDetailBase {
141
+ schema: 'urun.runtime.wake.v1';
142
+ expectationBasis: 'snapshot-registry';
143
+ restoreObservation: 'not-observed';
107
144
  }
108
145
 
146
+ type RuntimeWakeDetail = (RuntimeWakeDetailBase & {
147
+ portability: 'portable';
148
+ expectedWakePath: 'portable-golden-restore';
149
+ reasonCode: 'capture-attested';
150
+ golden: RuntimeWakeGolden;
151
+ }) | (RuntimeWakeDetailBase & {
152
+ portability: 'none';
153
+ expectedWakePath: 'cold-boot';
154
+ reasonCode: Exclude<RuntimeWakeReasonCode, 'capture-attested'>;
155
+
156
+ golden?: never;
157
+ });
158
+
109
159
  type SessionFailureKind = 'create-failed' | 'never-live' | 'transport-failed' | 'media-permission' | 'ended' | 'runtime-failed' | 'expired' | 'produce-timeout';
110
160
 
111
161
  interface SessionPhaseError {
@@ -278,6 +328,8 @@ interface SessionDocument {
278
328
  readonly synced: boolean;
279
329
 
280
330
  onSynced(handler: () => void): () => void;
331
+
332
+ onConnectionState?(handler: (state: DocConnectionState) => void): () => void;
281
333
  }
282
334
 
283
335
  interface SessionStream {
@@ -527,6 +579,8 @@ interface SessionGatewayResponse {
527
579
 
528
580
  runtime_reason?: string;
529
581
 
582
+ runtime_wake?: unknown;
583
+
530
584
  ends_at?: string;
531
585
  error_code?: string;
532
586
  error_message?: string;
@@ -748,28 +802,12 @@ declare class TransportSession {
748
802
 
749
803
  private _wakingSince;
750
804
 
751
- private _mediaMonitorTimer;
752
-
753
- private _lastInboundTotal;
754
-
755
- private _mediaEverFlowed;
756
-
757
- private _lastInboundAdvanceAt;
805
+ private _mediaProbeTimer;
758
806
 
759
- private _mediaDeathHandled;
760
-
761
- private _decodeSignalSeen;
762
-
763
- private _lastFramesDecoded;
764
-
765
- private _lastDecodeAdvanceAt;
807
+ private _joinProbes;
766
808
 
767
809
  private _decodeDeathHandled;
768
810
 
769
- private _latestInboundSample;
770
-
771
- private _decodeWindowStartSample;
772
-
773
811
  private _selectedCandidatePair;
774
812
 
775
813
  private _candidatePairDiagnosticEmitted;
@@ -902,13 +940,14 @@ declare class TransportSession {
902
940
 
903
941
  private _closeConsumersByProducer;
904
942
  private _mediaPollMs;
905
- private _mediaStallTimeoutMs;
906
943
 
907
- private _startMediaMonitor;
908
- private _stopMediaMonitor;
909
- private _sampleMediaLiveness;
944
+ private _firstFrameWindowMs;
945
+
946
+ private _startMediaProbe;
947
+ private _stopMediaProbe;
910
948
 
911
- private _checkDecodeLiveness;
949
+ private _resetJoinProbes;
950
+ private _sampleMediaArrival;
912
951
 
913
952
  private _renegotiate;
914
953
 
@@ -974,6 +1013,8 @@ declare class SessionDocumentImpl implements SessionDocument {
974
1013
 
975
1014
  ensureConnected(): void;
976
1015
 
1016
+ onConnectionState(handler: (state: DocConnectionState) => void): () => void;
1017
+
977
1018
  onSynced(handler: () => void): () => void;
978
1019
 
979
1020
  set(patch: Record<string, unknown>): void;
@@ -1032,4 +1073,4 @@ interface DataChannelTransport {
1032
1073
 
1033
1074
  declare function transportStreamData(transport: DataChannelTransport): StreamDataTransport;
1034
1075
 
1035
- export { type SessionStatus as $, type AccessTokenOptions$1 as A, type RecordingLifecycle as B, type ChannelEndpoint as C, DERIVED_LEG_SEP as D, type RecordingStatus as E, type RecordingsAccessor as F, type ReleaseSessionBeaconOptions as G, type RequestOptions as H, type RequestStreamOptions as I, type RuntimeArtifact as J, type RuntimeArtifactDownload as K, LoopbackStreamData as L, type MediaChunkBinding as M, type RuntimeArtifactsAccessor as N, type RuntimeAvailability as O, type Presence as P, type SessionDiagnostic as Q, type Recording as R, type Session as S, type SessionDocument as T, SessionDocumentImpl as U, type SessionEndResult as V, type SessionFailureKind as W, type SessionPhase as X, type SessionPhaseError as Y, type SessionPhaseName as Z, type SessionStartOptions as _, type AccessTokenOptions as a, type SessionStream as a0, type SessionText as a1, type Store as a2, type StoreOptions as a3, type StreamChunkOptions as a4, type StreamDataTransport as a5, TransportSession as a6, type TransportSessionOptions as a7, type TransportState as a8, allocateSession as a9, createPresence as aa, createWebsocketDocConnector as ab, deriveYjsServerUrl as ac, derivedLegName as ad, derivedLegRole as ae, isPendingRecording as af, mediaRecorderChunkSource as ag, prewake as ah, releaseSessionBeacon as ai, streamDataLabel as aj, transportStreamData as ak, type ActivationEvent as b, type ActivationState as c, type AllocateSessionOptions as d, type AllocatedSession as e, type App as f, type AppOptions as g, type AttachOptions as h, type ChannelMessage as i, ChannelMultiplexer as j, type ChannelName as k, type ChunkReadable as l, DOC_SYNC_WIRE_CONTRACT_VERSION as m, DeferredChannelMultiplexer as n, DeferredDocConnector as o, type DerivedLegRole as p, type DocConnection as q, type DocConnector as r, type MediaChunkSource as s, type MediaChunkSourceFactory as t, type MediaRecorderChunkSourceOptions as u, type PresenceState as v, type PrewakeOptions as w, type PrewakeResult as x, type PrewakeStatus as y, type RecordingBucket as z };
1076
+ export { type SessionFailureKind as $, type AccessTokenOptions$1 as A, type PrewakeStatus as B, type ChannelEndpoint as C, DERIVED_LEG_SEP as D, type RecordingBucket as E, type RecordingLifecycle as F, type RecordingStatus as G, type RecordingsAccessor as H, type ReleaseSessionBeaconOptions as I, type RequestOptions as J, type RequestStreamOptions as K, LoopbackStreamData as L, type MediaChunkBinding as M, type RuntimeArtifact as N, type RuntimeArtifactDownload as O, type Presence as P, type RuntimeArtifactsAccessor as Q, type Recording as R, type RuntimeAvailability as S, type RuntimeWakeDetail as T, type RuntimeWakeGolden as U, type RuntimeWakeReasonCode as V, type Session as W, type SessionDiagnostic as X, type SessionDocument as Y, SessionDocumentImpl as Z, type SessionEndResult as _, type AccessTokenOptions as a, type SessionPhase as a0, type SessionPhaseError as a1, type SessionPhaseName as a2, type SessionStartOptions as a3, type SessionStatus as a4, type SessionStream as a5, type SessionText as a6, type Store as a7, type StoreOptions as a8, type StreamChunkOptions as a9, type StreamDataTransport as aa, TransportSession as ab, type TransportSessionOptions as ac, type TransportState as ad, allocateSession as ae, createPresence as af, createWebsocketDocConnector as ag, deriveYjsServerUrl as ah, derivedLegName as ai, derivedLegRole as aj, isPendingRecording as ak, mediaRecorderChunkSource as al, prewake as am, releaseSessionBeacon as an, streamDataLabel as ao, transportStreamData as ap, type ActivationEvent as b, type ActivationState as c, type AllocateSessionOptions as d, type AllocatedSession as e, type App as f, type AppOptions as g, type AttachOptions as h, type ChannelMessage as i, ChannelMultiplexer as j, type ChannelName as k, type ChunkReadable as l, DOC_SYNC_WIRE_CONTRACT_VERSION as m, DeferredChannelMultiplexer as n, DeferredDocConnector as o, type DerivedLegRole as p, type DocConnection as q, type DocConnectionState as r, type DocConnector as s, type DocTokenSupplier as t, type MediaChunkSource as u, type MediaChunkSourceFactory as v, type MediaRecorderChunkSourceOptions as w, type PresenceState as x, type PrewakeOptions as y, type PrewakeResult as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urun-sh/core",
3
- "version": "0.2.46",
3
+ "version": "0.2.48",
4
4
  "description": "Core transport and channel primitives for the urun TypeScript SDK",
5
5
  "repository": {
6
6
  "type": "git",