@urun-sh/core 0.2.16 → 0.2.18

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/index.d.ts CHANGED
@@ -1,10 +1,46 @@
1
- import { b as AppOptions, a as App$1, K as SessionPhase, T as SessionStatus, O as SessionPhaseName, A as AccessTokenOptions$1, y as RuntimeArtifact, z as RuntimeArtifactDownload, R as Recording, G as Session$1, C as ChannelEndpoint, _ as TransportSession, c as AttachOptions, v as RecordingsAccessor, B as RuntimeArtifactsAccessor, U as SessionStream$1, Z as StreamDataTransport, I as SessionDocumentImpl, Y as StreamChunkOptions, g as ChunkReadable, P as Presence, k as DocConnector, w as RequestOptions, x as RequestStreamOptions, X as StoreOptions, W as Store, e as ChannelMultiplexer, J as SessionFailureKind, a0 as TransportState } from './stream-data-D8AOc7CR.js';
2
- export { L as Layer, l as LayoutConfig, m as LayoutContext, M as MediaChunkBinding, o as MediaChunkSource, p as MediaChunkSourceFactory, q as MediaRecorderChunkSourceOptions, r as PresenceState, s as RecordingBucket, t as RecordingLifecycle, u as RecordingStatus, E as RuntimeAvailability, S as SceneContext, F as SceneGraph, H as SessionDocument, N as SessionPhaseError, V as SessionText, a4 as isPendingRecording, a5 as mediaRecorderChunkSource } from './stream-data-D8AOc7CR.js';
1
+ import { d as AppOptions, c as App$1, Q as SessionPhase, W as SessionStatus, U as SessionPhaseName, A as AccessTokenOptions$1, B as RuntimeArtifact, E as RuntimeArtifactDownload, R as Recording, I as Session$1, C as ChannelEndpoint, a1 as TransportSession, e as AttachOptions, a as ActivationEvent, x as RecordingsAccessor, F as RuntimeArtifactsAccessor, N as SessionEndResult, X as SessionStream$1, a0 as StreamDataTransport, K as SessionDocumentImpl, $ as StreamChunkOptions, i as ChunkReadable, P as Presence, m as DocConnector, y as RequestOptions, z as RequestStreamOptions, _ as StoreOptions, Z as Store, g as ChannelMultiplexer, O as SessionFailureKind, a3 as TransportState } from './stream-data-ChMs2mq2.js';
2
+ export { b as ActivationState, L as Layer, n as LayoutConfig, o as LayoutContext, M as MediaChunkBinding, q as MediaChunkSource, r as MediaChunkSourceFactory, s as MediaRecorderChunkSourceOptions, t as PresenceState, u as RecordingBucket, v as RecordingLifecycle, w as RecordingStatus, G as RuntimeAvailability, S as SceneContext, H as SceneGraph, J as SessionDocument, T as SessionPhaseError, Y as SessionText, a7 as isPendingRecording, a8 as mediaRecorderChunkSource } from './stream-data-ChMs2mq2.js';
3
3
  import 'yjs';
4
4
  import 'y-protocols/awareness';
5
5
 
6
6
  declare function App(appId: string, options: AppOptions): App$1;
7
7
 
8
+ declare const DEFAULT_GATEWAY_URL = "https://api.urun.sh";
9
+ interface CreateClientTokenOptions {
10
+
11
+ baseUrl?: string;
12
+
13
+ expiresIn?: number;
14
+
15
+ allowedFunctions?: string[];
16
+
17
+ allowedOrigins?: string[];
18
+
19
+ maxSessionS?: number;
20
+
21
+ subject?: string;
22
+
23
+ metadata?: Record<string, unknown>;
24
+
25
+ fetch?: typeof fetch;
26
+ }
27
+
28
+ interface ClientToken {
29
+
30
+ token: string;
31
+
32
+ expiresAt: Date;
33
+
34
+ orgId: string;
35
+ }
36
+
37
+ declare class ClientTokenError extends Error {
38
+ readonly status?: number;
39
+ constructor(message: string, status?: number);
40
+ }
41
+
42
+ declare function createClientToken(apiKey: string, options?: CreateClientTokenOptions): Promise<ClientToken>;
43
+
8
44
  interface AccessTokenOptions {
9
45
  forceRefresh?: boolean;
10
46
  reason?: 'initial' | 'unauthorized' | 'background';
@@ -191,6 +227,8 @@ declare class SessionStream implements SessionStream$1 {
191
227
 
192
228
  private _onActivity?;
193
229
  private _track;
230
+
231
+ private _overrideTrack;
194
232
  private _handlers;
195
233
  private _unsubscribeTransport;
196
234
 
@@ -217,6 +255,8 @@ declare class SessionStream implements SessionStream$1 {
217
255
  private _deliver;
218
256
  get track(): MediaStreamTrack | null;
219
257
 
258
+ _setOverrideTrack(track: MediaStreamTrack | null): void;
259
+
220
260
  private _claimBrowserProducer;
221
261
  attach(track: MediaStreamTrack): Promise<void>;
222
262
 
@@ -247,13 +287,19 @@ declare class Session implements Session$1 {
247
287
 
248
288
  private _docConnector;
249
289
 
290
+ private _docEndpointKey;
291
+
250
292
  private _streamData;
251
293
 
252
294
  private _presence;
253
295
 
254
296
  private _activity;
255
297
 
298
+ private _activation;
299
+
256
300
  private _activeRequests;
301
+ private _endHandler?;
302
+ private _endPromise?;
257
303
 
258
304
  private _recordingsAuth?;
259
305
 
@@ -266,6 +312,10 @@ declare class Session implements Session$1 {
266
312
  private _recoveryHooks;
267
313
 
268
314
  private _lifecycleUnsub;
315
+
316
+ private _dialNegotiation;
317
+
318
+ private _dialNegotiationStarted;
269
319
  constructor(sessionId: string, multiplexer: ChannelEndpoint, transport: TransportSession, recordingsAuth?: RecordingsClientOptions, artifactsAuth?: RuntimeArtifactsClientOptions);
270
320
  private _wireControlDocIncarnation;
271
321
 
@@ -280,6 +330,8 @@ declare class Session implements Session$1 {
280
330
 
281
331
  onPhase(handler: (phase: SessionPhase) => void): () => void;
282
332
 
333
+ onActivation(handler: (event: ActivationEvent) => void): () => void;
334
+
283
335
  whenLive(options?: WhenLiveOptions): Promise<void>;
284
336
 
285
337
  get recordings(): RecordingsAccessor;
@@ -287,6 +339,8 @@ declare class Session implements Session$1 {
287
339
  setArtifactsAuth(auth: RuntimeArtifactsClientOptions): void;
288
340
  private _requireArtifactsAuth;
289
341
  setSessionId(sessionId: string): void;
342
+
343
+ setEndHandler(handler: () => Promise<SessionEndResult>): void;
290
344
  stream(name: string): SessionStream;
291
345
 
292
346
  doc(key: string): SessionDocumentImpl;
@@ -320,6 +374,13 @@ declare class Session implements Session$1 {
320
374
  recover(): void;
321
375
 
322
376
  onRecovery(hook: () => void): () => void;
377
+
378
+ negotiateMediaTransport(opts?: {
379
+ allowWebTransport?: boolean;
380
+ }): void;
381
+
382
+ get mediaTransport(): 'webtransport' | 'webrtc' | null;
383
+ end(): Promise<SessionEndResult>;
323
384
  disconnect(): void;
324
385
  }
325
386
 
@@ -327,6 +388,70 @@ declare const FOREGROUND_COALESCE_MS = 250;
327
388
 
328
389
  declare function observePageLifecycle(onForeground: () => void): () => void;
329
390
 
391
+ declare const ACTIVATION_STILL_AFTER_MS = 15000;
392
+
393
+ declare const ACTIVATION_COLD_BOOT_AFTER_MS = 45000;
394
+
395
+ declare const ACTIVATION_DEGRADED_AFTER_MS = 120000;
396
+
397
+ declare const ACTIVATION_HINT_PATH = "desired.activation";
398
+
399
+ declare function activationHintFrom(value: unknown): string | undefined;
400
+
401
+ interface ActivationStreamLike {
402
+
403
+ readonly track: MediaStreamTrack | null;
404
+
405
+ on(event: 'track', handler: (track: MediaStreamTrack | null) => void): () => void;
406
+ }
407
+
408
+ interface ActivationMonitorOptions {
409
+
410
+ onPhase(handler: (phase: SessionPhase) => void): () => void;
411
+
412
+ hint(): unknown;
413
+
414
+ onData?(name: string, handler: (payload: unknown) => void): () => void;
415
+ }
416
+
417
+ declare class ActivationMonitor {
418
+ private _options;
419
+ private _watches;
420
+ private _handlers;
421
+
422
+ private _liveAt;
423
+ private _stopped;
424
+ private _offPhase;
425
+ constructor(_options: ActivationMonitorOptions);
426
+
427
+ watch(name: string, stream: ActivationStreamLike): void;
428
+
429
+ unwatch(name: string): void;
430
+
431
+ onActivation(handler: (event: ActivationEvent) => void): () => void;
432
+
433
+ dispose(): void;
434
+
435
+ private _hookFirstMediaSignals;
436
+
437
+ private _arm;
438
+
439
+ private _firstMedia;
440
+
441
+ private _settle;
442
+ private _emit;
443
+ }
444
+
445
+ declare const BACKOFF_BASE_MS = 500;
446
+
447
+ declare const BACKOFF_MAX_MS = 15000;
448
+
449
+ declare const BACKOFF_MAX_ATTEMPTS = 6;
450
+
451
+ declare function computeBackoffDelay(attempt: number, random?: () => number): number;
452
+
453
+ declare function isRetryableSessionError(error: unknown): boolean;
454
+
330
455
  declare function createStore(options: StoreOptions): Store & {
331
456
  _getInternals(): {
332
457
  multiplexer: ChannelMultiplexer;
@@ -341,6 +466,25 @@ interface VideoStreamOptions {
341
466
 
342
467
  declare function videoStream(source: ReadableStream<Uint8Array>, options?: VideoStreamOptions): MediaStream;
343
468
 
469
+ declare class SessionEndUnavailableError extends Error {
470
+ readonly code = "session_end_unavailable";
471
+ constructor(message?: string, options?: {
472
+ cause?: unknown;
473
+ });
474
+ }
475
+
476
+ declare class SessionEndError extends Error {
477
+ readonly code: string;
478
+ readonly httpStatus?: number;
479
+ readonly requestId: string;
480
+ constructor(message: string, options: {
481
+ requestId: string;
482
+ code?: string;
483
+ httpStatus?: number;
484
+ cause?: unknown;
485
+ });
486
+ }
487
+
344
488
  declare class RequestError extends Error {
345
489
 
346
490
  readonly requestId?: string;
@@ -560,6 +704,8 @@ interface MediaSession {
560
704
  lossPct: number;
561
705
  jitterMs: number;
562
706
  };
707
+
708
+ readonly firstMedia: Promise<void>;
563
709
  }
564
710
 
565
711
  interface Signaling {
@@ -708,6 +854,8 @@ declare class WebTransportSession implements MediaSession {
708
854
  private lastStats;
709
855
  private firstFrameResolve;
710
856
  private firstFrameReject;
857
+
858
+ readonly firstMedia: Promise<void>;
711
859
  constructor(offer: NonNullable<TransportOfferResponse['webtransport']>, sessionId: string, canvas: HTMLCanvasElement);
712
860
 
713
861
  start(): Promise<void>;
@@ -741,6 +889,10 @@ declare class WebRtcSession implements MediaSession {
741
889
  private deadCb;
742
890
  private deadFired;
743
891
  private unsubscribers;
892
+ private firstMediaResolve;
893
+ private firstMediaReject;
894
+
895
+ readonly firstMedia: Promise<void>;
744
896
  constructor(transport: ConsumingTransport, streamName?: string);
745
897
 
746
898
  start(): Promise<void>;
@@ -798,4 +950,4 @@ declare class FrameReassembler {
798
950
  private requestKeyframe;
799
951
  }
800
952
 
801
- export { ACTIVITY_DOM_EVENTS, ACTIVITY_FIELD, ACTIVITY_STAMP_MIN_INTERVAL_MS, type ActivityAwareness, type ActivityTracker, type ActivityTrackerOptions, App, App$1 as AppInterface, AppOptions, AttachOptions, type CaptureClaim, CaptureController, type CaptureControllerOptions, type CaptureKind, CaptureUnavailableError, ChunkReadable, type ConsumingTransport, DEFAULT_DOC_SYNC_TIMEOUT_MS, DEFAULT_PRODUCE_ACK_TIMEOUT_MS, DEFAULT_WHEN_LIVE_TIMEOUT_MS, DGRAM_HEADER_BYTES, type DgramHeader, FOREGROUND_COALESCE_MS, FrameReassembler, INPUT_PRESENCE_DEFAULT_HZ, INPUT_PRESENCE_FIELD, type InputPresenceAwareness, type InputPresencePublisher, type InputPresencePublisherOptions, type InputPresenceState, InvalidDurationError, type MediaSession, type NegotiatorOptions, PermanentLockedError, type PhaseObservable, PinRequiresActiveTempError, Presence, type PrewakeOptions, type PrewakeResult, type PrewakeStatus, ProduceAckTimeoutError, type ReassembledFrame, type ReassemblerCallbacks, type ReassemblerOptions, Recording, RecordingNotFoundError, RecordingsAccessor, RecordingsClient, type RecordingsClientOptions, RecordingsError, RecordingsUnauthorizedError, RequestAbortError, RequestCancelledError, RequestDocSyncError, RequestError, RequestOptions, RequestStreamOptions, RequestTimeoutError, RetainNotTempError, type RetentionIntent, RuntimeArtifact, RuntimeArtifactDownload, RuntimeArtifactNotFoundError, RuntimeArtifactsAccessor, RuntimeArtifactsClient, type RuntimeArtifactsClientOptions, RuntimeArtifactsError, RuntimeArtifactsUnauthorizedError, Session, SessionAllocationError, SessionFailedError, SessionFailureKind, Session$1 as SessionInterface, SessionPhase, SessionPhaseName, SessionStatus, SessionStream$1 as SessionStream, type SignalCarrier, type Signaling, Store, StoreOptions, StreamChunkOptions, StreamDirectionConflict, type TransportEstablishedNotify, TransportNegotiator, type TransportOfferRequest, type TransportOfferResponse, TransportSessionSignaling, TransportState, type VideoStreamOptions, WT_CONTROL_FRAME_MAX, WebRtcSession, WebTransportSession, type WhenLiveOptions, WtControlDecoder, type WtControlMessage, createActivityTracker, createInputPresencePublisher, createRecordingsClient, createRuntimeArtifactsClient, createStore, describeSessionFailure, describeSessionPhase, encodeWtControlFrame, isDurationString, isWakingPhase, normalizeRetention, observePageLifecycle, parseDgramHeader, prewake, sessionFailureFromMediaError, sharedCaptureController, videoStream, whenLive, writeDgramHeader };
953
+ export { ACTIVATION_COLD_BOOT_AFTER_MS, ACTIVATION_DEGRADED_AFTER_MS, ACTIVATION_HINT_PATH, ACTIVATION_STILL_AFTER_MS, ACTIVITY_DOM_EVENTS, ACTIVITY_FIELD, ACTIVITY_STAMP_MIN_INTERVAL_MS, ActivationEvent, ActivationMonitor, type ActivationMonitorOptions, type ActivationStreamLike, type ActivityAwareness, type ActivityTracker, type ActivityTrackerOptions, App, App$1 as AppInterface, AppOptions, AttachOptions, BACKOFF_BASE_MS, BACKOFF_MAX_ATTEMPTS, BACKOFF_MAX_MS, type CaptureClaim, CaptureController, type CaptureControllerOptions, type CaptureKind, CaptureUnavailableError, ChunkReadable, type ClientToken, ClientTokenError, type ConsumingTransport, type CreateClientTokenOptions, DEFAULT_DOC_SYNC_TIMEOUT_MS, DEFAULT_GATEWAY_URL, DEFAULT_PRODUCE_ACK_TIMEOUT_MS, DEFAULT_WHEN_LIVE_TIMEOUT_MS, DGRAM_HEADER_BYTES, type DgramHeader, FOREGROUND_COALESCE_MS, FrameReassembler, INPUT_PRESENCE_DEFAULT_HZ, INPUT_PRESENCE_FIELD, type InputPresenceAwareness, type InputPresencePublisher, type InputPresencePublisherOptions, type InputPresenceState, InvalidDurationError, type MediaSession, type NegotiatorOptions, PermanentLockedError, type PhaseObservable, PinRequiresActiveTempError, Presence, type PrewakeOptions, type PrewakeResult, type PrewakeStatus, ProduceAckTimeoutError, type ReassembledFrame, type ReassemblerCallbacks, type ReassemblerOptions, Recording, RecordingNotFoundError, RecordingsAccessor, RecordingsClient, type RecordingsClientOptions, RecordingsError, RecordingsUnauthorizedError, RequestAbortError, RequestCancelledError, RequestDocSyncError, RequestError, RequestOptions, RequestStreamOptions, RequestTimeoutError, RetainNotTempError, type RetentionIntent, RuntimeArtifact, RuntimeArtifactDownload, RuntimeArtifactNotFoundError, RuntimeArtifactsAccessor, RuntimeArtifactsClient, type RuntimeArtifactsClientOptions, RuntimeArtifactsError, RuntimeArtifactsUnauthorizedError, Session, SessionAllocationError, SessionEndError, SessionEndResult, SessionEndUnavailableError, SessionFailedError, SessionFailureKind, Session$1 as SessionInterface, SessionPhase, SessionPhaseName, SessionStatus, SessionStream$1 as SessionStream, type SignalCarrier, type Signaling, Store, StoreOptions, StreamChunkOptions, StreamDirectionConflict, type TransportEstablishedNotify, TransportNegotiator, type TransportOfferRequest, type TransportOfferResponse, TransportSessionSignaling, TransportState, type VideoStreamOptions, WT_CONTROL_FRAME_MAX, WebRtcSession, WebTransportSession, type WhenLiveOptions, WtControlDecoder, type WtControlMessage, activationHintFrom, computeBackoffDelay, createActivityTracker, createClientToken, createInputPresencePublisher, createRecordingsClient, createRuntimeArtifactsClient, createStore, describeSessionFailure, describeSessionPhase, encodeWtControlFrame, isDurationString, isRetryableSessionError, isWakingPhase, normalizeRetention, observePageLifecycle, parseDgramHeader, prewake, sessionFailureFromMediaError, sharedCaptureController, videoStream, whenLive, writeDgramHeader };