@urun-sh/core 0.2.6 → 0.2.8

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 +1,2 @@
1
- import{a as e,b as r,c as o,d as t,e as a,g as n,h as p,i as s,j as m,l as c,m as i,n as f,o as x}from"./chunk-H23H4OCS.mjs";export{e as ChannelMultiplexer,r as DeferredChannelMultiplexer,f as DeferredDocConnector,n as LoopbackStreamData,m as TransportSession,x as createPresence,i as createWebsocketDocConnector,c as deriveYjsServerUrl,a as ensureNodeWebRTC,o as isNodeRuntime,t as nodeMediasoupHandlerName,s as streamDataLabel,p as transportStreamData};
1
+ import { createRequire as __urunCreateRequire } from 'node:module'; const require = globalThis.require ?? __urunCreateRequire(import.meta.url);
2
+ import{A as f,B as x,C,D as l,a as e,b as r,q as o,r as t,s as a,u as n,v as p,w as s,x as m,y as c,z as i}from"./chunk-C2B5BLQW.mjs";export{e as ChannelMultiplexer,c as DOC_SYNC_WIRE_CONTRACT_VERSION,r as DeferredChannelMultiplexer,x as DeferredDocConnector,n as LoopbackStreamData,C as SessionDocumentImpl,m as TransportSession,l as createPresence,f as createWebsocketDocConnector,i as deriveYjsServerUrl,a as ensureNodeWebRTC,o as isNodeRuntime,t as nodeMediasoupHandlerName,s as streamDataLabel,p as transportStreamData};
@@ -33,6 +33,8 @@ interface MediaRecorderChunkSourceOptions {
33
33
 
34
34
  declare function mediaRecorderChunkSource(binding: MediaChunkBinding, options?: MediaRecorderChunkSourceOptions): MediaChunkSource;
35
35
 
36
+ declare const DOC_SYNC_WIRE_CONTRACT_VERSION = 1;
37
+
36
38
  interface DocConnection {
37
39
 
38
40
  readonly awareness: Awareness;
@@ -41,6 +43,8 @@ interface DocConnection {
41
43
 
42
44
  onSync(handler: (synced: boolean) => void): () => void;
43
45
 
46
+ ensureConnected?(): void;
47
+
44
48
  destroy(): void;
45
49
  }
46
50
 
@@ -93,9 +97,15 @@ declare function createPresence(awareness: Awareness): Presence;
93
97
 
94
98
  type TransportState = 'connecting' | 'connected' | 'reconnecting' | 'renegotiating' | 'disconnected' | 'failed';
95
99
 
96
- type SessionPhaseName = 'idle' | 'queued' | 'provisioning' | 'connecting' | 'live' | 'error' | 'ended';
100
+ type SessionPhaseName = 'idle' | 'queued' | 'unavailable' | 'provisioning' | 'connecting' | 'live' | 'error' | 'ended';
101
+
102
+ interface RuntimeAvailability {
103
+ state: 'unavailable' | 'starting' | 'busy';
104
+
105
+ reason?: string;
106
+ }
97
107
 
98
- type SessionFailureKind = 'create-failed' | 'never-live' | 'transport-failed' | 'media-permission' | 'ended';
108
+ type SessionFailureKind = 'create-failed' | 'never-live' | 'transport-failed' | 'media-permission' | 'ended' | 'runtime-failed';
99
109
 
100
110
  interface SessionPhaseError {
101
111
 
@@ -117,6 +127,10 @@ interface SessionPhase {
117
127
  depth: number;
118
128
  };
119
129
 
130
+ runtime?: RuntimeAvailability;
131
+
132
+ wakingSince?: number;
133
+
120
134
  requestId?: string;
121
135
 
122
136
  sessionId?: string;
@@ -143,6 +157,10 @@ interface SessionStatus {
143
157
  depth: number;
144
158
  };
145
159
 
160
+ runtime?: RuntimeAvailability;
161
+
162
+ wakingSince?: number;
163
+
146
164
  error?: SessionPhaseError;
147
165
  }
148
166
 
@@ -371,6 +389,10 @@ interface Session {
371
389
 
372
390
  readonly artifacts: RuntimeArtifactsAccessor;
373
391
 
392
+ recover(): void;
393
+
394
+ onRecovery(hook: () => void): () => void;
395
+
374
396
  disconnect(): void;
375
397
  }
376
398
 
@@ -610,6 +632,8 @@ declare class TransportSession {
610
632
 
611
633
  private _connectStartedAt;
612
634
 
635
+ private _wakingSince;
636
+
613
637
  private _mediaMonitorTimer;
614
638
 
615
639
  private _lastInboundTotal;
@@ -748,6 +772,8 @@ declare class TransportSession {
748
772
  private _checkDecodeLiveness;
749
773
 
750
774
  private _renegotiate;
775
+
776
+ recover(): void;
751
777
  private _attemptReconnect;
752
778
  private _connectUrls;
753
779
  private _connectOnce;
@@ -764,11 +790,74 @@ declare class TransportSession {
764
790
 
765
791
  private _setPhase;
766
792
 
793
+ reportAdmission(update: {
794
+ status: 'queued' | 'pending';
795
+ requestId?: string;
796
+ queue?: {
797
+ position: number;
798
+ depth: number;
799
+ };
800
+ runtime?: RuntimeAvailability;
801
+ }): void;
802
+
767
803
  private _emitError;
768
804
 
769
805
  reportAllocationFailure(error: Error, httpStatus?: number): void;
770
806
  }
771
807
 
808
+ declare class SessionDocumentImpl implements SessionDocument {
809
+ private _doc;
810
+ private _root;
811
+ private _awareness;
812
+ private _listeners;
813
+ private _key;
814
+ private _sessionId;
815
+ private _connection;
816
+ private _connUnsub;
817
+
818
+ private _synced;
819
+
820
+ private _syncWaiters;
821
+
822
+ private _texts;
823
+ private _observer;
824
+ constructor(key: string, sessionId: string, connector?: DocConnector | null);
825
+
826
+ get awareness(): Awareness;
827
+
828
+ setSessionId(sessionId: string): void;
829
+
830
+ get synced(): boolean;
831
+
832
+ ensureConnected(): void;
833
+
834
+ onSynced(handler: () => void): () => void;
835
+
836
+ set(patch: Record<string, unknown>): void;
837
+ get(path?: string, defaultValue?: unknown): unknown;
838
+ on(event: 'change', handler: (snap: Record<string, unknown>) => void): () => void;
839
+
840
+ text(field: string): SessionTextImpl;
841
+ dispose(): void;
842
+ private _markSynced;
843
+
844
+ private applyPatch;
845
+ private snapshot;
846
+ private notify;
847
+ }
848
+
849
+ declare class SessionTextImpl implements SessionText {
850
+ private _ytext;
851
+ private _delta;
852
+ private _observer;
853
+ constructor(_ytext: Y.Text);
854
+ append(text: string): void;
855
+ toString(): string;
856
+ get length(): number;
857
+ on(event: 'delta', handler: (inserted: string) => void): () => void;
858
+ dispose(): void;
859
+ }
860
+
772
861
  interface StreamDataTransport {
773
862
 
774
863
  readonly consumerId: string;
@@ -800,4 +889,4 @@ interface DataChannelTransport {
800
889
 
801
890
  declare function transportStreamData(transport: DataChannelTransport): StreamDataTransport;
802
891
 
803
- export { createWebsocketDocConnector as $, type AccessTokenOptions as A, type SceneGraph as B, type ChannelEndpoint as C, DeferredChannelMultiplexer as D, type Session as E, type SessionDocument as F, type SessionFailureKind as G, type SessionPhase as H, type SessionPhaseError as I, type SessionPhaseName as J, type SessionStartOptions as K, type Layer as L, type MediaChunkBinding as M, type SessionStatus as N, type SessionStream as O, type Presence as P, type SessionText as Q, type Recording as R, type SceneContext as S, type Store as T, type StoreOptions as U, type StreamChunkOptions as V, type StreamDataTransport as W, TransportSession as X, type TransportSessionOptions as Y, type TransportState as Z, createPresence as _, type App as a, deriveYjsServerUrl as a0, isPendingRecording as a1, mediaRecorderChunkSource as a2, streamDataLabel as a3, transportStreamData as a4, type AppOptions as b, type AttachOptions as c, type ChannelMessage as d, ChannelMultiplexer as e, type ChannelName as f, type ChunkReadable as g, DeferredDocConnector as h, type DocConnection as i, type DocConnector as j, type LayoutConfig as k, type LayoutContext as l, LoopbackStreamData as m, type MediaChunkSource as n, type MediaChunkSourceFactory as o, type MediaRecorderChunkSourceOptions as p, type PresenceState as q, type RecordingBucket as r, type RecordingLifecycle as s, type RecordingStatus as t, type RecordingsAccessor as u, type RequestOptions as v, type RequestStreamOptions as w, type RuntimeArtifact as x, type RuntimeArtifactDownload as y, type RuntimeArtifactsAccessor as z };
892
+ export { type TransportSessionOptions as $, type AccessTokenOptions as A, type RuntimeArtifactsAccessor as B, type ChannelEndpoint as C, DOC_SYNC_WIRE_CONTRACT_VERSION as D, type RuntimeAvailability as E, type SceneGraph as F, type Session as G, type SessionDocument as H, SessionDocumentImpl as I, type SessionFailureKind as J, type SessionPhase as K, type Layer as L, type MediaChunkBinding as M, type SessionPhaseError as N, type SessionPhaseName as O, type Presence as P, type SessionStartOptions as Q, type Recording as R, type SceneContext as S, type SessionStatus as T, type SessionStream as U, type SessionText as V, type Store as W, type StoreOptions as X, type StreamChunkOptions as Y, type StreamDataTransport as Z, TransportSession as _, type App as a, type TransportState as a0, createPresence as a1, createWebsocketDocConnector as a2, deriveYjsServerUrl as a3, isPendingRecording as a4, mediaRecorderChunkSource as a5, streamDataLabel as a6, transportStreamData as a7, type AppOptions as b, type AttachOptions as c, type ChannelMessage as d, ChannelMultiplexer as e, type ChannelName as f, type ChunkReadable as g, DeferredChannelMultiplexer as h, DeferredDocConnector as i, type DocConnection as j, type DocConnector as k, type LayoutConfig as l, type LayoutContext as m, LoopbackStreamData as n, type MediaChunkSource as o, type MediaChunkSourceFactory as p, type MediaRecorderChunkSourceOptions as q, type PresenceState as r, type RecordingBucket as s, type RecordingLifecycle as t, type RecordingStatus as u, type RecordingsAccessor as v, type RequestOptions as w, type RequestStreamOptions as x, type RuntimeArtifact as y, type RuntimeArtifactDownload as z };
@@ -33,6 +33,8 @@ interface MediaRecorderChunkSourceOptions {
33
33
 
34
34
  declare function mediaRecorderChunkSource(binding: MediaChunkBinding, options?: MediaRecorderChunkSourceOptions): MediaChunkSource;
35
35
 
36
+ declare const DOC_SYNC_WIRE_CONTRACT_VERSION = 1;
37
+
36
38
  interface DocConnection {
37
39
 
38
40
  readonly awareness: Awareness;
@@ -41,6 +43,8 @@ interface DocConnection {
41
43
 
42
44
  onSync(handler: (synced: boolean) => void): () => void;
43
45
 
46
+ ensureConnected?(): void;
47
+
44
48
  destroy(): void;
45
49
  }
46
50
 
@@ -93,9 +97,15 @@ declare function createPresence(awareness: Awareness): Presence;
93
97
 
94
98
  type TransportState = 'connecting' | 'connected' | 'reconnecting' | 'renegotiating' | 'disconnected' | 'failed';
95
99
 
96
- type SessionPhaseName = 'idle' | 'queued' | 'provisioning' | 'connecting' | 'live' | 'error' | 'ended';
100
+ type SessionPhaseName = 'idle' | 'queued' | 'unavailable' | 'provisioning' | 'connecting' | 'live' | 'error' | 'ended';
101
+
102
+ interface RuntimeAvailability {
103
+ state: 'unavailable' | 'starting' | 'busy';
104
+
105
+ reason?: string;
106
+ }
97
107
 
98
- type SessionFailureKind = 'create-failed' | 'never-live' | 'transport-failed' | 'media-permission' | 'ended';
108
+ type SessionFailureKind = 'create-failed' | 'never-live' | 'transport-failed' | 'media-permission' | 'ended' | 'runtime-failed';
99
109
 
100
110
  interface SessionPhaseError {
101
111
 
@@ -117,6 +127,10 @@ interface SessionPhase {
117
127
  depth: number;
118
128
  };
119
129
 
130
+ runtime?: RuntimeAvailability;
131
+
132
+ wakingSince?: number;
133
+
120
134
  requestId?: string;
121
135
 
122
136
  sessionId?: string;
@@ -143,6 +157,10 @@ interface SessionStatus {
143
157
  depth: number;
144
158
  };
145
159
 
160
+ runtime?: RuntimeAvailability;
161
+
162
+ wakingSince?: number;
163
+
146
164
  error?: SessionPhaseError;
147
165
  }
148
166
 
@@ -371,6 +389,10 @@ interface Session {
371
389
 
372
390
  readonly artifacts: RuntimeArtifactsAccessor;
373
391
 
392
+ recover(): void;
393
+
394
+ onRecovery(hook: () => void): () => void;
395
+
374
396
  disconnect(): void;
375
397
  }
376
398
 
@@ -610,6 +632,8 @@ declare class TransportSession {
610
632
 
611
633
  private _connectStartedAt;
612
634
 
635
+ private _wakingSince;
636
+
613
637
  private _mediaMonitorTimer;
614
638
 
615
639
  private _lastInboundTotal;
@@ -748,6 +772,8 @@ declare class TransportSession {
748
772
  private _checkDecodeLiveness;
749
773
 
750
774
  private _renegotiate;
775
+
776
+ recover(): void;
751
777
  private _attemptReconnect;
752
778
  private _connectUrls;
753
779
  private _connectOnce;
@@ -764,11 +790,74 @@ declare class TransportSession {
764
790
 
765
791
  private _setPhase;
766
792
 
793
+ reportAdmission(update: {
794
+ status: 'queued' | 'pending';
795
+ requestId?: string;
796
+ queue?: {
797
+ position: number;
798
+ depth: number;
799
+ };
800
+ runtime?: RuntimeAvailability;
801
+ }): void;
802
+
767
803
  private _emitError;
768
804
 
769
805
  reportAllocationFailure(error: Error, httpStatus?: number): void;
770
806
  }
771
807
 
808
+ declare class SessionDocumentImpl implements SessionDocument {
809
+ private _doc;
810
+ private _root;
811
+ private _awareness;
812
+ private _listeners;
813
+ private _key;
814
+ private _sessionId;
815
+ private _connection;
816
+ private _connUnsub;
817
+
818
+ private _synced;
819
+
820
+ private _syncWaiters;
821
+
822
+ private _texts;
823
+ private _observer;
824
+ constructor(key: string, sessionId: string, connector?: DocConnector | null);
825
+
826
+ get awareness(): Awareness;
827
+
828
+ setSessionId(sessionId: string): void;
829
+
830
+ get synced(): boolean;
831
+
832
+ ensureConnected(): void;
833
+
834
+ onSynced(handler: () => void): () => void;
835
+
836
+ set(patch: Record<string, unknown>): void;
837
+ get(path?: string, defaultValue?: unknown): unknown;
838
+ on(event: 'change', handler: (snap: Record<string, unknown>) => void): () => void;
839
+
840
+ text(field: string): SessionTextImpl;
841
+ dispose(): void;
842
+ private _markSynced;
843
+
844
+ private applyPatch;
845
+ private snapshot;
846
+ private notify;
847
+ }
848
+
849
+ declare class SessionTextImpl implements SessionText {
850
+ private _ytext;
851
+ private _delta;
852
+ private _observer;
853
+ constructor(_ytext: Y.Text);
854
+ append(text: string): void;
855
+ toString(): string;
856
+ get length(): number;
857
+ on(event: 'delta', handler: (inserted: string) => void): () => void;
858
+ dispose(): void;
859
+ }
860
+
772
861
  interface StreamDataTransport {
773
862
 
774
863
  readonly consumerId: string;
@@ -800,4 +889,4 @@ interface DataChannelTransport {
800
889
 
801
890
  declare function transportStreamData(transport: DataChannelTransport): StreamDataTransport;
802
891
 
803
- export { createWebsocketDocConnector as $, type AccessTokenOptions as A, type SceneGraph as B, type ChannelEndpoint as C, DeferredChannelMultiplexer as D, type Session as E, type SessionDocument as F, type SessionFailureKind as G, type SessionPhase as H, type SessionPhaseError as I, type SessionPhaseName as J, type SessionStartOptions as K, type Layer as L, type MediaChunkBinding as M, type SessionStatus as N, type SessionStream as O, type Presence as P, type SessionText as Q, type Recording as R, type SceneContext as S, type Store as T, type StoreOptions as U, type StreamChunkOptions as V, type StreamDataTransport as W, TransportSession as X, type TransportSessionOptions as Y, type TransportState as Z, createPresence as _, type App as a, deriveYjsServerUrl as a0, isPendingRecording as a1, mediaRecorderChunkSource as a2, streamDataLabel as a3, transportStreamData as a4, type AppOptions as b, type AttachOptions as c, type ChannelMessage as d, ChannelMultiplexer as e, type ChannelName as f, type ChunkReadable as g, DeferredDocConnector as h, type DocConnection as i, type DocConnector as j, type LayoutConfig as k, type LayoutContext as l, LoopbackStreamData as m, type MediaChunkSource as n, type MediaChunkSourceFactory as o, type MediaRecorderChunkSourceOptions as p, type PresenceState as q, type RecordingBucket as r, type RecordingLifecycle as s, type RecordingStatus as t, type RecordingsAccessor as u, type RequestOptions as v, type RequestStreamOptions as w, type RuntimeArtifact as x, type RuntimeArtifactDownload as y, type RuntimeArtifactsAccessor as z };
892
+ export { type TransportSessionOptions as $, type AccessTokenOptions as A, type RuntimeArtifactsAccessor as B, type ChannelEndpoint as C, DOC_SYNC_WIRE_CONTRACT_VERSION as D, type RuntimeAvailability as E, type SceneGraph as F, type Session as G, type SessionDocument as H, SessionDocumentImpl as I, type SessionFailureKind as J, type SessionPhase as K, type Layer as L, type MediaChunkBinding as M, type SessionPhaseError as N, type SessionPhaseName as O, type Presence as P, type SessionStartOptions as Q, type Recording as R, type SceneContext as S, type SessionStatus as T, type SessionStream as U, type SessionText as V, type Store as W, type StoreOptions as X, type StreamChunkOptions as Y, type StreamDataTransport as Z, TransportSession as _, type App as a, type TransportState as a0, createPresence as a1, createWebsocketDocConnector as a2, deriveYjsServerUrl as a3, isPendingRecording as a4, mediaRecorderChunkSource as a5, streamDataLabel as a6, transportStreamData as a7, type AppOptions as b, type AttachOptions as c, type ChannelMessage as d, ChannelMultiplexer as e, type ChannelName as f, type ChunkReadable as g, DeferredChannelMultiplexer as h, DeferredDocConnector as i, type DocConnection as j, type DocConnector as k, type LayoutConfig as l, type LayoutContext as m, LoopbackStreamData as n, type MediaChunkSource as o, type MediaChunkSourceFactory as p, type MediaRecorderChunkSourceOptions as q, type PresenceState as r, type RecordingBucket as s, type RecordingLifecycle as t, type RecordingStatus as u, type RecordingsAccessor as v, type RequestOptions as w, type RequestStreamOptions as x, type RuntimeArtifact as y, type RuntimeArtifactDownload as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urun-sh/core",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Core transport and channel primitives for the urun TypeScript SDK",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,6 +17,21 @@
17
17
  "exports": {
18
18
  ".": {
19
19
  "types": "./dist/index.d.ts",
20
+ "edge-light": {
21
+ "types": "./dist/index.browser.d.ts",
22
+ "import": "./dist/index.browser.mjs",
23
+ "require": "./dist/index.browser.js"
24
+ },
25
+ "workerd": {
26
+ "types": "./dist/index.browser.d.ts",
27
+ "import": "./dist/index.browser.mjs",
28
+ "require": "./dist/index.browser.js"
29
+ },
30
+ "worker": {
31
+ "types": "./dist/index.browser.d.ts",
32
+ "import": "./dist/index.browser.mjs",
33
+ "require": "./dist/index.browser.js"
34
+ },
20
35
  "browser": {
21
36
  "types": "./dist/index.browser.d.ts",
22
37
  "import": "./dist/index.browser.mjs",
@@ -27,6 +42,21 @@
27
42
  },
28
43
  "./internal": {
29
44
  "types": "./dist/internal.d.ts",
45
+ "edge-light": {
46
+ "types": "./dist/internal.browser.d.ts",
47
+ "import": "./dist/internal.browser.mjs",
48
+ "require": "./dist/internal.browser.js"
49
+ },
50
+ "workerd": {
51
+ "types": "./dist/internal.browser.d.ts",
52
+ "import": "./dist/internal.browser.mjs",
53
+ "require": "./dist/internal.browser.js"
54
+ },
55
+ "worker": {
56
+ "types": "./dist/internal.browser.d.ts",
57
+ "import": "./dist/internal.browser.mjs",
58
+ "require": "./dist/internal.browser.js"
59
+ },
30
60
  "browser": {
31
61
  "types": "./dist/internal.browser.d.ts",
32
62
  "import": "./dist/internal.browser.mjs",
@@ -69,6 +99,7 @@
69
99
  },
70
100
  "license": "MIT",
71
101
  "dependencies": {
102
+ "debug": "^4.4.3",
72
103
  "y-protocols": "1.0.7",
73
104
  "y-websocket": "3.0.0",
74
105
  "yjs": "^13.6.31"