@neta-art/cohub 10.0.0 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -7
- package/dist/board/editor/animation.d.ts +3 -0
- package/dist/board/editor/animation.js +16 -1
- package/dist/board/editor/clipboard.js +7 -0
- package/dist/board/editor/copy.js +23 -18
- package/dist/board/editor/creation.d.ts +7 -3
- package/dist/board/editor/creation.js +5 -4
- package/dist/board/editor/deletion.js +3 -3
- package/dist/board/editor/document.d.ts +8 -2
- package/dist/board/editor/document.js +54 -7
- package/dist/board/editor/editor.d.ts +22 -7
- package/dist/board/editor/editor.js +12 -2
- package/dist/board/editor/index.d.ts +2 -2
- package/dist/board/editor/interaction.d.ts +8 -2
- package/dist/board/editor/interaction.js +34 -1
- package/dist/board/editor/query.d.ts +5 -5
- package/dist/board/editor/query.js +14 -12
- package/dist/board/editor/selection.js +2 -1
- package/dist/board/editor/snapshots.d.ts +0 -2
- package/dist/board/editor/snapshots.js +4 -20
- package/dist/board/export/index.d.ts +25 -4
- package/dist/board/export/index.js +45 -12
- package/dist/board/export/node/index.d.ts +5 -4
- package/dist/board/export/node/index.js +16 -11
- package/dist/board/export/node/scripts.d.ts +16 -0
- package/dist/board/export/node/scripts.js +258 -0
- package/dist/board/export/scene.d.ts +2 -1
- package/dist/board/export/scene.js +24 -7
- package/dist/board/model/animation.d.ts +4 -1
- package/dist/board/model/animation.js +34 -7
- package/dist/board/model/authoring.d.ts +20 -0
- package/dist/board/model/authoring.js +185 -0
- package/dist/board/model/export-plan.js +1 -0
- package/dist/board/model/file-preview.js +1 -1
- package/dist/board/model/file-snapshot.js +3 -2
- package/dist/board/model/image-key.js +7 -3
- package/dist/board/model/index.d.ts +15 -7
- package/dist/board/model/index.js +16 -9
- package/dist/board/model/items/builtin.js +2 -2
- package/dist/board/model/items/create.d.ts +19 -4
- package/dist/board/model/items/create.js +130 -9
- package/dist/board/model/items/index.d.ts +2 -2
- package/dist/board/model/items/index.js +2 -2
- package/dist/board/model/media-playback.d.ts +2 -1
- package/dist/board/model/media-playback.js +15 -5
- package/dist/board/model/media.js +7 -1
- package/dist/board/model/overlay-placement.d.ts +25 -0
- package/dist/board/model/overlay-placement.js +35 -0
- package/dist/board/model/replay.d.ts +1 -1
- package/dist/board/model/replay.js +1 -0
- package/dist/board/model/sampling.d.ts +19 -0
- package/dist/board/model/sampling.js +96 -0
- package/dist/board/model/script-example.d.ts +4 -0
- package/dist/board/model/script-example.js +21 -0
- package/dist/board/model/script-hit.d.ts +27 -0
- package/dist/board/model/script-hit.js +109 -0
- package/dist/board/model/script-index.d.ts +7 -0
- package/dist/board/model/script-index.js +15 -0
- package/dist/board/model/script-observers.d.ts +18 -0
- package/dist/board/model/script-observers.js +92 -0
- package/dist/board/model/script-scene.d.ts +24 -0
- package/dist/board/model/script-scene.js +294 -0
- package/dist/board/model/script.d.ts +149 -0
- package/dist/board/model/script.js +1 -0
- package/dist/board/render/board-background.js +5 -4
- package/dist/board/render/css-color.d.ts +6 -1
- package/dist/board/render/css-color.js +34 -20
- package/dist/board/render/diagnostics.d.ts +20 -0
- package/dist/board/render/diagnostics.js +117 -0
- package/dist/board/render/index.d.ts +9 -6
- package/dist/board/render/index.js +10 -7
- package/dist/board/render/media-interaction.js +1 -1
- package/dist/board/render/palette.d.ts +2 -1
- package/dist/board/render/palette.js +6 -2
- package/dist/board/render/renderers/arrow-card-renderer.js +3 -2
- package/dist/board/render/renderers/audio-card-renderer.js +2 -1
- package/dist/board/render/renderers/board-renderer-registry.d.ts +25 -5
- package/dist/board/render/renderers/board-renderer-registry.js +11 -4
- package/dist/board/render/renderers/custom-card-renderer.d.ts +5 -0
- package/dist/board/render/renderers/{sketch-card-renderer.js → custom-card-renderer.js} +18 -16
- package/dist/board/render/renderers/draw-card-renderer.js +3 -2
- package/dist/board/render/renderers/effect-card-renderer.js +22 -5
- package/dist/board/render/renderers/frame-card-renderer.js +30 -14
- package/dist/board/render/renderers/image-card-renderer.js +43 -4
- package/dist/board/render/renderers/shape-card-renderer.js +10 -27
- package/dist/board/render/renderers/task-card-renderer.d.ts +2 -1
- package/dist/board/render/renderers/task-card-renderer.js +220 -71
- package/dist/board/render/renderers/text-card-renderer.js +5 -3
- package/dist/board/render/renderers/unknown-card-renderer.js +1 -0
- package/dist/board/render/renderers/video-card-renderer.js +2 -1
- package/dist/board/render/sampling.d.ts +22 -0
- package/dist/board/render/sampling.js +21 -0
- package/dist/board/render/script-export.d.ts +11 -0
- package/dist/board/render/script-export.js +86 -0
- package/dist/board/render/script-host.d.ts +31 -0
- package/dist/board/render/script-host.js +446 -0
- package/dist/board/render/script-modules.d.ts +2 -0
- package/dist/board/render/script-modules.js +2 -0
- package/dist/board/render/script-runtime.d.ts +29 -0
- package/dist/board/render/script-runtime.js +223 -0
- package/dist/board/render/script-sandbox.d.ts +4 -0
- package/dist/board/render/script-sandbox.js +173 -0
- package/dist/board/render/script-texture.d.ts +11 -0
- package/dist/board/render/script-texture.js +33 -0
- package/dist/board/render/stroke.d.ts +2 -1
- package/dist/board/render/stroke.js +22 -1
- package/dist/board/render/text-measurement.js +1 -1
- package/dist/board/stage/assets.js +7 -2
- package/dist/board/stage/maintenance.d.ts +5 -0
- package/dist/board/stage/maintenance.js +11 -0
- package/dist/board/stage/scene.d.ts +2 -0
- package/dist/board/stage/scene.js +21 -2
- package/dist/board/stage/script-pointer.d.ts +20 -0
- package/dist/board/stage/script-pointer.js +41 -0
- package/dist/board/stage/stage.d.ts +21 -3
- package/dist/board/stage/stage.js +350 -47
- package/dist/board/stage/texture-pool.js +2 -3
- package/dist/chunks/environment.d.ts +305 -27
- package/dist/chunks/environment.js +12 -4
- package/dist/chunks/host-bridge.d.ts +2 -2
- package/dist/chunks/http.d.ts +90 -7
- package/dist/chunks/http.js +157 -64
- package/dist/chunks/transport.js +4 -2
- package/dist/chunks/websocket.d.ts +9 -1
- package/dist/chunks/websocket.js +16 -2
- package/dist/host-bridge.js +2 -1
- package/dist/http.d.ts +3 -3
- package/dist/index.d.ts +182 -4
- package/dist/index.js +1559 -299
- package/dist/protocol/dist/board-assets.d.ts +1 -0
- package/dist/protocol/dist/board-constants.js +2 -2
- package/dist/protocol/dist/board-model.d.ts +236 -11
- package/dist/protocol/dist/board-model.js +46 -17
- package/dist/protocol/dist/board-patch.js +2 -1
- package/dist/protocol/dist/board-schema.d.ts +4 -2
- package/dist/protocol/dist/board-schema.js +18 -4
- package/dist/protocol/dist/board-script-modules.d.ts +25 -0
- package/dist/protocol/dist/board-script-modules.js +127 -0
- package/dist/protocol/dist/board-task.d.ts +22 -0
- package/dist/{board/model/task.js → protocol/dist/board-task.js} +34 -7
- package/dist/protocol/dist/display/index.d.ts +1 -0
- package/dist/protocol/dist/generation/blocks.d.ts +8 -0
- package/dist/{generation-blocks.js → protocol/dist/generation/blocks.js} +14 -15
- package/dist/protocol/dist/index.d.ts +7 -2
- package/dist/protocol/dist/realtime/types.d.ts +1 -0
- package/dist/protocol/dist/rtc/index.d.ts +1 -0
- package/dist/protocol/dist/task/index.d.ts +4 -0
- package/package.json +2 -1
- package/dist/board/export/node/sketch.d.ts +0 -19
- package/dist/board/export/node/sketch.js +0 -146
- package/dist/board/model/task.d.ts +0 -11
- package/dist/board/render/renderers/sketch-card-renderer.d.ts +0 -5
- package/dist/board/render/sketch-host.d.ts +0 -14
- package/dist/board/render/sketch-host.js +0 -216
- package/dist/types.d.ts +0 -36
|
@@ -152,16 +152,24 @@ const normalizeWebsocketPath = (input, path, replacePaths = []) => {
|
|
|
152
152
|
const normalizeWebsocketUrl = (input) => normalizeWebsocketPath(input, "/ws", ["/asr/ws"]);
|
|
153
153
|
const normalizeVoiceInputWebsocketUrl = (input) => normalizeWebsocketPath(input, "/asr/ws", ["/ws"]);
|
|
154
154
|
const resolveApiBaseUrl = (options = {}) => {
|
|
155
|
-
|
|
155
|
+
const baseUrl = options.baseUrl?.trim() || readProcessEnv()?.COHUB_BASE_URL?.trim();
|
|
156
|
+
if (baseUrl) return normalizeBaseUrl(baseUrl);
|
|
156
157
|
return COHUB_ENVIRONMENTS[resolveCohubEnvironment(options.env)].apiBaseUrl;
|
|
157
158
|
};
|
|
158
|
-
const resolveWebBaseUrl = (options = {}) =>
|
|
159
|
+
const resolveWebBaseUrl = (options = {}) => {
|
|
160
|
+
const url = options.url?.trim() || readProcessEnv()?.COHUB_WEB_URL?.trim();
|
|
161
|
+
if (url) return normalizeBaseUrl(url);
|
|
162
|
+
return COHUB_ENVIRONMENTS[resolveCohubEnvironment(options.env)].webBaseUrl;
|
|
163
|
+
};
|
|
159
164
|
const resolveWebsocketUrl = (options = {}) => {
|
|
160
|
-
|
|
165
|
+
const url = options.url?.trim() || readProcessEnv()?.COHUB_WS_URL?.trim();
|
|
166
|
+
if (url) return normalizeWebsocketUrl(url);
|
|
161
167
|
return COHUB_ENVIRONMENTS[resolveCohubEnvironment(options.env)].websocketUrl;
|
|
162
168
|
};
|
|
163
169
|
const resolveVoiceInputWebsocketUrl = (options = {}) => {
|
|
164
|
-
|
|
170
|
+
const env = readProcessEnv();
|
|
171
|
+
const url = options.url?.trim() || env?.COHUB_VOICE_WS_URL?.trim() || env?.COHUB_WS_URL?.trim();
|
|
172
|
+
if (url) return normalizeVoiceInputWebsocketUrl(url);
|
|
165
173
|
return COHUB_ENVIRONMENTS[resolveCohubEnvironment(options.env)].voiceInputWebsocketUrl;
|
|
166
174
|
};
|
|
167
175
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
//#region ../protocol/dist/host-bridge.d.ts
|
|
3
|
-
declare const HOST_BRIDGE_CAPABILITIES: readonly ["auth.token", "auth.signIn", "auth.session", "notifications", "share", "filePicker", "navigation", "cache", "runtime", "appearance", "launch", "haptics", "files", "navigation.back", "shortcuts", "display"];
|
|
3
|
+
declare const HOST_BRIDGE_CAPABILITIES: readonly ["auth.token", "auth.signIn", "auth.session", "notifications", "share", "filePicker", "navigation", "cache", "runtime", "appearance", "launch", "haptics", "files", "navigation.back", "shortcuts", "display", "media.capture"];
|
|
4
4
|
type HostBridgeCapability = (typeof HOST_BRIDGE_CAPABILITIES)[number];
|
|
5
5
|
declare const hostPlatformSchema: z.ZodEnum<{
|
|
6
6
|
android: "android";
|
|
@@ -31,7 +31,7 @@ declare const HOST_BRIDGE_METHODS: {
|
|
|
31
31
|
web: "web";
|
|
32
32
|
}>;
|
|
33
33
|
hostId: z.ZodString;
|
|
34
|
-
capabilities: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<("appearance" | "auth.session" | "auth.signIn" | "auth.token" | "cache" | "display" | "filePicker" | "files" | "haptics" | "launch" | "navigation" | "navigation.back" | "notifications" | "runtime" | "share" | "shortcuts")[], string[]>>;
|
|
34
|
+
capabilities: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<("appearance" | "auth.session" | "auth.signIn" | "auth.token" | "cache" | "display" | "filePicker" | "files" | "haptics" | "launch" | "media.capture" | "navigation" | "navigation.back" | "notifications" | "runtime" | "share" | "shortcuts")[], string[]>>;
|
|
35
35
|
}, z.core.$strict>;
|
|
36
36
|
};
|
|
37
37
|
readonly "auth.getAccessToken": {
|
package/dist/chunks/http.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $a as BoardPlaybackChangedEvent$1, $n as SpaceCommerceProduct, $
|
|
1
|
+
import { $a as BoardPlaybackChangedEvent$1, $n as SpaceCommerceProduct, $r as SpaceSessionsResponse, $t as PromptTemplateCatalogResponse, An as SessionTurnSignedUrlsResponse, Bc as ContentBlock, Bi as SessionTurnRecord, Br as SpaceMember, Cc as RtcIceServers, Ci as ChannelHealth, Cr as SpaceFsReadFilesResponse, Dn as SessionRecord, En as SessionMessagesResponse, Et as GlobalSearchType, Fc as CreateSpaceCompletionInput, Fn as SkillCatalogResponse, Ft as LabelItemsResponse, Gr as SpacePresenceSnapshot, Gt as PaletteOverviewResponse, Hi as StoredIntermediateMessage, Hr as SpaceModListItem, Ht as MeResponse, Ii as SessionStats, Io as DesktopCommandError, Jn as SpaceCommerceBenefit, Jo as NavigationCall, Jr as SpaceRecord, Jt as PatchResourceLabelsInput, Ka as GenerationContentBlock, Ks as AppAuthorizationRequest$1, Lc as SpaceCompletionResult, Lo as DesktopCommandRecord, Ls as BoardPatch, Lt as LabelListItem, Mi as SessionForkRecord, Mn as SessionTurnWindowResponse, Mr as SpaceFsWriteFileInput, Nn as SessionTurnsPaginatedResponse, Oi as MessageRecord, On as SessionTurnIndexResponse, Ot as InvitationDetail, Po as DesktopCommand, Pr as SpaceInvitationListResponse, Pt as LabelAssignmentRecord, Q as Channel, Qa as BoardChangedEvent$1, Qn as SpaceCommerceOrder, Qo as SpaceFsCopyInput, Qs as RuntimeArchivePage, Rc as SpaceCompletionStreamEvent, Ri as MessageToolCallsFile, Rn as SpaceAccessPolicy, Ro as DesktopCommandStatus, Rr as SpaceListOptions, Si as ChannelConfig, So as AppVersionSource, Tn as SessionMessagesPaginatedResponse, Ur as SpacePendingDiffFileResponse, Ut as ModelCatalogEntry, Vi as SpaceTurnsResponse, Vn as SpaceActivityResponse, Wi as TurnIntermediateMessagesFile, Wr as SpacePendingDiffSummary, Ws as BillingPayload, Xo as SpacePublicEndpoints, Xs as HarnessArchiveIndex, Xt as Permission, Yn as SpaceCommerceBuyerProfile, Yo as NavigationLaunch, Yr as SpaceRole, Yt as PatchResourceLabelsResponse, Za as BoardAwarenessUpdatedEvent$1, _ as AcceptInvitationResponse, _i as UserSessionSourceKey, _t as CronJobRecord, aa as RuntimeStopConfirmation, ac as DisplayCapture, ar as SpaceConfigUpdateResponse, br as SpaceFsPreparingFile, bs as BoardReadInput, cc as DisplayInfo, cn as ReferenceAggregateResponse, cr as SpaceEnvInput, cs as BoardAwarenessUpdate, ct as ClaimReferralResponse, dc as DisplaySession, dn as ReferenceQueryResponse, ds as BoardApplyInput, dt as CreateSpaceInput, ec as RuntimeArchiveUpload, ei as SpaceTurnAuthorFilter, en as PublicReferral, er as SpaceCommerceProductBenefitBinding, es as SpaceFsCopyResponse, fn as ReferenceQueryableType, fr as SpaceFsCreateUploadInput, fs as BoardApplyResult, gc as DisplayVirtualStart, gs as BoardHistoryPage, hi as UserRulesResponse, hn as ReferralDashboard, ho as AppArtifactDescriptor, hs as BoardHistoryInput, ht as CreateSpaceSessionInput, ia as RuntimeStatus, ii as SpaceUsageResponse, io as RealtimePatchOperation, ir as SpaceConfigResponse, ji as SessionFilesResponse, jn as SessionTurnStreamSnapshotResponse, jr as SpaceFsUploadResponse, js as BoardDelta, kn as SessionTurnResponse, lc as DisplayInputEvent, ln as ReferenceDirection, lo as RealtimeRoomHistoryEvent, lr as SpaceFsCompleteUploadInput, lt as CreateInvitationInput, mc as DisplayTreeParams, mi as UserProfile, mo as SessionTurnPatchEvent, ms as BoardCreateInput, mt as CreateSpacePromptResponse, nn as PublicUserPageResponse, oc as DisplayCaptureParams, oi as TaskRunDetailResponse, oo as RealtimeRoomDescriptor, or as SpaceCreateResponse, ot as CheckpointDiffSummary, pi as UserActivityResponse, pr as SpaceFsCreateUploadResponse, pt as CreateSpacePromptInput, qa as GenerationModelDeclaration, qc as RequestSource, qn as SpaceCheckpointDetailResponse, qr as SpacePublicProfile, qs as AppAuthorizationResult, r as CohubEnvironment, ra as RuntimeSessionRecoveryStatus, rn as PublicUserProfile, rr as SpaceConfigInput, rs as SpaceFsCopyStats, si as TaskRunRecord, sn as ReferenceAggregateGroupBy, sr as SpaceDefaultResponse, st as CheckpointRecord, ts as SpaceFsCopyResult, tt as CheckpointDiffFileResponse, uc as DisplayList, ui as UserActivityQuery, un as ReferenceKind, uo as RealtimeRoomMember, ur as SpaceFsCompleteUploadResponse, ut as CreateInvitationResponse, vr as SpaceFsFileResponse, vt as CronJobUpdatePatch, wn as SessionMessageResponse, wr as SpaceFsTreeResponse, wt as GlobalSearchResponse, xo as AppContentKind, xs as BoardReadResult, y as BatchUserProfilesResponse, yi as UserSessionsResponse, yr as SpaceFsMoveInput, ys as BoardPlaybackSnapshot, yt as CursorPageInfo, zc as Usage, zr as SpaceListPage, zt as LabelResourceType } from "./environment.js";
|
|
2
2
|
import { a as WebsocketClientOptions, r as WebsocketClient, s as WebsocketEventPayload } from "./websocket.js";
|
|
3
3
|
import { a as VoiceInputCreateOptions } from "./voice-input.js";
|
|
4
4
|
//#region ../protocol/dist/model/status.d.ts
|
|
@@ -280,7 +280,7 @@ type AppDropResource = {
|
|
|
280
280
|
snapshot?: Record<string, unknown>;
|
|
281
281
|
};
|
|
282
282
|
/** Public design tokens, sent as resolved CSS values. */
|
|
283
|
-
declare const APP_APPEARANCE_TOKENS: readonly ["bg-primary", "bg-content", "bg-surface", "bg-elevated", "bg-input", "bg-hover", "bg-active", "text-primary", "text-secondary", "text-tertiary", "text-placeholder", "text-disabled", "border-primary", "border-subtle", "brand", "brand-hover", "brand-soft", "brand-muted", "brand-border", "brand-ring", "brand-contrast-fg", "error-fg", "selection-bg", "overlay-scrim", "shadow-subtle", "shadow-medium", "shadow-strong", "font-sans", "font-mono"];
|
|
283
|
+
declare const APP_APPEARANCE_TOKENS: readonly ["bg-primary", "bg-content", "bg-surface", "bg-elevated", "bg-input", "bg-hover", "bg-active", "text-primary", "text-secondary", "text-tertiary", "text-placeholder", "text-disabled", "border-primary", "border-subtle", "brand", "brand-hover", "brand-soft", "brand-muted", "brand-border", "brand-ring", "brand-contrast-fg", "error-fg", "success", "warning", "error", "info", "status-running", "selection-bg", "overlay-scrim", "shadow-subtle", "shadow-medium", "shadow-strong", "font-sans", "font-mono"];
|
|
284
284
|
type AppAppearanceToken = (typeof APP_APPEARANCE_TOKENS)[number];
|
|
285
285
|
type AppAppearance = {
|
|
286
286
|
colorScheme: "light" | "dark";
|
|
@@ -353,6 +353,11 @@ type AppNavigationOpenResponse = {
|
|
|
353
353
|
};
|
|
354
354
|
};
|
|
355
355
|
//#endregion
|
|
356
|
+
//#region ../protocol/dist/app-devices.d.ts
|
|
357
|
+
declare const APP_DEVICES: readonly ["camera", "microphone", "screen"];
|
|
358
|
+
type AppDevice = (typeof APP_DEVICES)[number];
|
|
359
|
+
type AppDevicesStatus = "granted" | "denied" | "unavailable";
|
|
360
|
+
//#endregion
|
|
356
361
|
//#region ../protocol/dist/app-promotion-stats.d.ts
|
|
357
362
|
declare const APP_PROMOTION_EVENT_KEYS: readonly ["landing", "ready", "registration_completed", "paywall_viewed", "checkout_started"];
|
|
358
363
|
type AppPromotionEventKey = typeof APP_PROMOTION_EVENT_KEYS[number];
|
|
@@ -413,6 +418,7 @@ type AppRuntimeContext = {
|
|
|
413
418
|
capabilities?: {
|
|
414
419
|
authorization: 2;
|
|
415
420
|
serverGrants: true;
|
|
421
|
+
devices?: true;
|
|
416
422
|
};
|
|
417
423
|
mode?: "bridge" | "broker";
|
|
418
424
|
app: {
|
|
@@ -648,6 +654,8 @@ declare class AppRuntimeApi {
|
|
|
648
654
|
*/
|
|
649
655
|
dispose(): void;
|
|
650
656
|
navigationOpen(target: AppNavigationTarget, call?: AppNavigationCall): Promise<AppNavigationOpenResponse>;
|
|
657
|
+
/** Asks for devices declared with `<meta name="cohub:devices">`; allowing the camera or microphone reloads the App once. */
|
|
658
|
+
requestDevices(devices: AppDevice[]): Promise<AppDevicesStatus>;
|
|
651
659
|
/**
|
|
652
660
|
* Asks the host to close this App: a workspace tab closes, an embedded page
|
|
653
661
|
* forwards the request to its embedder, a standalone page closes the tab.
|
|
@@ -829,6 +837,7 @@ type UnauthorizedContext = {
|
|
|
829
837
|
type CohubClientOptions = {
|
|
830
838
|
env?: CohubEnvironment;
|
|
831
839
|
baseUrl?: string;
|
|
840
|
+
webBaseUrl?: string;
|
|
832
841
|
getAccessToken?: (options?: AccessTokenRequestOptions) => Promise<string | null> | string | null;
|
|
833
842
|
getAuthSessionVersion?: () => AuthSessionVersion;
|
|
834
843
|
onUnauthorized?: (context: UnauthorizedContext) => Promise<void> | void;
|
|
@@ -1241,11 +1250,16 @@ declare class SpaceBoardsApi {
|
|
|
1241
1250
|
create(input: BoardCreateInput): Promise<BoardReadResult>;
|
|
1242
1251
|
}
|
|
1243
1252
|
//#endregion
|
|
1244
|
-
//#region src/
|
|
1245
|
-
type
|
|
1246
|
-
|
|
1253
|
+
//#region src/rtc/index.d.ts
|
|
1254
|
+
type RtcPath = "direct" | "relay";
|
|
1255
|
+
type RtcTransportStats = {
|
|
1256
|
+
path: RtcPath | null;
|
|
1247
1257
|
relayProtocol: string | null;
|
|
1248
1258
|
rttMs: number | null;
|
|
1259
|
+
};
|
|
1260
|
+
//#endregion
|
|
1261
|
+
//#region src/display-stats.d.ts
|
|
1262
|
+
type DisplayConnectionStats = RtcTransportStats & {
|
|
1249
1263
|
fps: number | null;
|
|
1250
1264
|
bitrate: number | null;
|
|
1251
1265
|
width: number | null;
|
|
@@ -1317,7 +1331,7 @@ declare function connectDisplay(api: SpaceDisplaysApi, displayId: string, option
|
|
|
1317
1331
|
declare class SpaceDisplaysApi {
|
|
1318
1332
|
private readonly transport;
|
|
1319
1333
|
readonly spaceId: string;
|
|
1320
|
-
private ice;
|
|
1334
|
+
private readonly ice;
|
|
1321
1335
|
constructor(transport: HttpTransport, spaceId: string);
|
|
1322
1336
|
private path;
|
|
1323
1337
|
list(options?: {
|
|
@@ -2343,6 +2357,7 @@ declare class TasksApi {
|
|
|
2343
2357
|
constructor(transport: HttpTransport, websocketClient?: WebsocketClient | null);
|
|
2344
2358
|
get(taskRunId: string, options?: {
|
|
2345
2359
|
signal?: AbortSignal;
|
|
2360
|
+
include?: readonly "boards"[];
|
|
2346
2361
|
}): Promise<TaskRunDetailResponse>;
|
|
2347
2362
|
wait(taskRunId: string, options?: TaskWaitOptions): Promise<TaskRunRecord>;
|
|
2348
2363
|
getMany(taskRunIds: string[], options?: {
|
|
@@ -2487,6 +2502,7 @@ type AppExtractedPageMeta = {
|
|
|
2487
2502
|
themeColor?: string | null;
|
|
2488
2503
|
surface?: "window" | "overlay" | null;
|
|
2489
2504
|
fileHandlers?: string[];
|
|
2505
|
+
devices?: AppDevice[];
|
|
2490
2506
|
sourcePath?: string | null;
|
|
2491
2507
|
extractedAt?: string | null;
|
|
2492
2508
|
};
|
|
@@ -2509,6 +2525,7 @@ type AppMeta = Record<string, unknown> & {
|
|
|
2509
2525
|
presentation?: AppPresentationMeta;
|
|
2510
2526
|
/** File extensions the App opens (`[".board"]`), from `<meta name="cohub:file-handlers">`. */
|
|
2511
2527
|
fileHandlers?: string[];
|
|
2528
|
+
devices?: AppDevice[];
|
|
2512
2529
|
extracted?: AppExtractedPageMeta;
|
|
2513
2530
|
source?: RequestSource;
|
|
2514
2531
|
};
|
|
@@ -3018,6 +3035,71 @@ declare class WorkCommerceApi extends AppCommerceApi {}
|
|
|
3018
3035
|
/** @deprecated Use `AppCommerceOrder`. */
|
|
3019
3036
|
type WorkCommerceOrder = AppCommerceOrder;
|
|
3020
3037
|
//#endregion
|
|
3038
|
+
//#region src/apis/rooms.d.ts
|
|
3039
|
+
type RoomView = {
|
|
3040
|
+
room: RealtimeRoomDescriptor;
|
|
3041
|
+
participantId: string;
|
|
3042
|
+
members: RealtimeRoomMember[];
|
|
3043
|
+
sequence: number;
|
|
3044
|
+
};
|
|
3045
|
+
type RoomInvite = {
|
|
3046
|
+
invite: string;
|
|
3047
|
+
expiresAt: string;
|
|
3048
|
+
};
|
|
3049
|
+
type RoomCreated = RoomInvite & {
|
|
3050
|
+
room: RealtimeRoomDescriptor;
|
|
3051
|
+
url: string | null;
|
|
3052
|
+
};
|
|
3053
|
+
type RoomEvent = RealtimeRoomHistoryEvent & {
|
|
3054
|
+
self: boolean;
|
|
3055
|
+
};
|
|
3056
|
+
type RoomEvents = {
|
|
3057
|
+
events: RoomEvent[];
|
|
3058
|
+
cursor: number;
|
|
3059
|
+
truncated: boolean;
|
|
3060
|
+
};
|
|
3061
|
+
type RoomEventsQuery = {
|
|
3062
|
+
after?: number;
|
|
3063
|
+
types?: string[];
|
|
3064
|
+
waitMs?: number;
|
|
3065
|
+
limit?: number;
|
|
3066
|
+
signal?: AbortSignal;
|
|
3067
|
+
};
|
|
3068
|
+
declare class RoomsApi {
|
|
3069
|
+
private readonly transport;
|
|
3070
|
+
constructor(transport: HttpTransport);
|
|
3071
|
+
create(input: {
|
|
3072
|
+
appId: string;
|
|
3073
|
+
code?: string;
|
|
3074
|
+
expiresInSeconds?: number;
|
|
3075
|
+
maxParticipants?: number;
|
|
3076
|
+
seatPerUser?: boolean;
|
|
3077
|
+
}): Promise<RoomCreated>;
|
|
3078
|
+
join(input: {
|
|
3079
|
+
invite: string;
|
|
3080
|
+
presence?: Record<string, unknown> | null;
|
|
3081
|
+
idleSeconds?: number;
|
|
3082
|
+
}): Promise<RoomView>;
|
|
3083
|
+
get(roomId: string): Promise<RoomView>;
|
|
3084
|
+
events(roomId: string, query?: RoomEventsQuery): Promise<RoomEvents>;
|
|
3085
|
+
publish(roomId: string, type: string, data?: unknown): Promise<{
|
|
3086
|
+
sequence: number;
|
|
3087
|
+
eventId: string;
|
|
3088
|
+
}>;
|
|
3089
|
+
setPresence(roomId: string, presence: Record<string, unknown> | null): Promise<{
|
|
3090
|
+
member: RealtimeRoomMember;
|
|
3091
|
+
sequence: number;
|
|
3092
|
+
}>;
|
|
3093
|
+
invite(roomId: string, input?: {
|
|
3094
|
+
expiresInSeconds?: number;
|
|
3095
|
+
}): Promise<RoomInvite>;
|
|
3096
|
+
leave(roomId: string): Promise<{
|
|
3097
|
+
left: boolean;
|
|
3098
|
+
}>;
|
|
3099
|
+
private path;
|
|
3100
|
+
private post;
|
|
3101
|
+
}
|
|
3102
|
+
//#endregion
|
|
3021
3103
|
//#region src/http.d.ts
|
|
3022
3104
|
declare class CohubHttpClient {
|
|
3023
3105
|
readonly spaces: SpacesApi;
|
|
@@ -3038,6 +3120,7 @@ declare class CohubHttpClient {
|
|
|
3038
3120
|
readonly referrals: ReferralsApi;
|
|
3039
3121
|
readonly apps: AppsApi;
|
|
3040
3122
|
readonly appCommerce: AppCommerceApi;
|
|
3123
|
+
readonly rooms: RoomsApi;
|
|
3041
3124
|
/** @deprecated Use `apps`. */
|
|
3042
3125
|
get works(): AppsApi;
|
|
3043
3126
|
/** @deprecated Use `appCommerce`. */
|
|
@@ -3051,4 +3134,4 @@ declare class CohubHttpClient {
|
|
|
3051
3134
|
}
|
|
3052
3135
|
declare const createHttpClient: (options?: CohubClientOptions) => CohubHttpClient;
|
|
3053
3136
|
//#endregion
|
|
3054
|
-
export {
|
|
3137
|
+
export { AppPromotionStatsResponse as $, PublicAssetPurpose as $n, AppNavigationLaunch as $r, SpaceFileStream as $t, DesktopCommandsApi as A, ModelStatusEntry as Ai, SessionPatchStatus as An, AppRuntimeAppResolver as Ar, WorkPublicOwnerRecord as At, AppContent as B, BoardChangedEvent as Bn, AppRuntimeShellContext as Br, WorkViewStatsResponse as Bt, WorkCommerceEntitlement as C, SpaceStartupResponse as Ci, SessionGenerationStreamClient as Cn, sanitizeAccessToken as Cr, WorkPresentationMeta as Ct, WorkCommercePurchaseResponse as D, GenerationUsageBilling as Di, SessionPatchApplyResult as Dn, AppDiagnosticListener as Dr, WorkPromotionProviderStatus as Dt, WorkCommerceProductResolveResponse as E, GenerationTaskResult as Ei, SessionPatchApplyInput as En, AppDiagnostic as Er, WorkPromotionProvider as Et, UiCommandsApi as F, DisplayConnectionState as Fn, AppRuntimeError as Fr, WorkStatus as Ft, AppGetResponse as G, BoardSubscriptionHandlers as Gn, createAppRuntime as Gr, TaskWaitOptions as Gt, AppCreateInput as H, BoardClientOptions as Hn, OriginBrokerTransport as Hr, ReferralsApi as Ht, WaitForDesktopCommandOptions as I, connectDisplay as In, AppRuntimeInvocationContext as Ir, WorkTargetType as It, AppPromotionCreateInput as J, ReferencesApi as Jn, resolveAppTransport as Jr, SessionEventName as Jt, AppMeta as K, SessionAccessApi as Kn, createOriginAppResolver as Kr, TasksApi as Kt, WaitForUiCommandOptions as L, DisplayConnectionStats as Ln, AppRuntimeModeConfig as Lr, WorkUpdateInput as Lt, UiCommandError as M, SpaceDisplaysApi as Mn, AppRuntimeCheckoutState as Mr, WorkRecord as Mt, UiCommandRecord as N, ConnectDisplayOptions as Nn, AppRuntimeCheckoutStatus as Nr, WorkResolveResponse as Nt, CreateDesktopCommandInput as O, ListGenerationModelsResponse as Oi, SessionPatchReducer as On, AppIdResolver as Or, WorkPromotionRecord as Ot, UiCommandStatus as P, DisplayConnection as Pn, AppRuntimeContext as Pr, WorkSessionResponse as Pt, AppPromotionRecord as Q, PublicAssetMimeType as Qn, AppNavigationCall as Qr, SpaceEventName as Qt, AppActionRunResponse as R, RtcTransportStats as Rn, AppRuntimeRequestOptions as Rr, WorkVersionRecord as Rt, WorkCommerceCreditConsumeStatus as S, SpaceWebhookTriggerResponse as Si, GenerationStreamTurnUpdatedEvent as Sn, matchesUnauthorizedErrorToken as Sr, WorkMeta as St, WorkCommerceOrder as T, CreateGenerationTaskResponse as Ti, parseAssistantMessageCommit as Tn, AppContextChangedListener as Tr, WorkPromotionEventResponse as Tt, AppDetailResponse as U, BoardEventName as Un, ParentBridgeTransport as Ur, UsersApi as Ut, AppContentDownload as V, BoardClient as Vn, AppRuntimeTransport as Vr, WorkVisibility as Vt, AppExtractedPageMeta as W, BoardPlaybackChangedEvent as Wn, PopupBrokerTransport as Wr, UserApi as Wt, AppPromotionProvider as X, CreatePublicAssetUploadInput as Xn, AppDevice as Xr, SpaceChannelBindingRecord as Xt, AppPromotionEventResponse as Y, SearchApi as Yn, APP_DEVICES as Yr, SessionSubscriptionHandlers as Yt, AppPromotionProviderStatus as Z, CreatePublicAssetUploadResponse as Zn, AppDevicesStatus as Zr, SpaceClient as Zt, AppCommerceProductResolveResponse as _, PublicFileListResponse as _i, GenerationStreamLifecycleEvent as _n, HttpTraceContext as _r, WorkContentDownload as _t, RoomEvents as a, AppAppearanceToken as ai, WebSocketConnectionState as an, UploadChatImageAttachmentInput as ar, AppStatus as at, WorkCommerceCheckoutStatus as b, PublicFileUrlResponse as bi, GenerationStreamSubscribeOptions as bn, UnauthorizedContext as br, WorkExtractedPageMeta as bt, RoomView as c, AppRuntimeAnchor as ci, PublicInviteApi as cn, SkillsApi as cr, AppVersionRecord as ct, AppCommerceCheckoutStatus as d, AppWindowState as di, AssistantMessageCommit as dn, GenerationsApi as dr, AppViewerGrantRecord as dt, AppNavigationOpenMessage as ei, SpacePublicFilesApi as en, PublicAssetUploadProgress as er, AppPublicOwnerRecord as et, AppCommerceCreditConsumeResponse as f, AppWindowStatus as fi, GenerationStreamCommitEvent as fn, CronJobsApi as fr, AppVisibility as ft, AppCommerceOrder as g, PublicFileListEntry as gi, GenerationStreamIntermediateMessage as gn, HttpError as gr, WorkContent as gt, AppCommerceEntitlementsResponse as h, PublicFileCreateUploadResponse as hi, GenerationStreamFinalizedEvent as hn, Fetch as hr, WorkAuthorizeResponse as ht, RoomEvent as i, AppAppearance as ii, WaitForSpaceFsCopyOptions as in, UploadChatAttachmentInput as ir, AppSessionResponse as it, UiCommand as j, ModelStatusResponse as ji, createSessionPatchReducer as jn, AppRuntimeAuthorizationResult as jr, WorkPublicSpaceRecord as jt, CreateUiCommandInput as k, PublicGenerationDeclaration as ki, SessionPatchState as kn, AppRuntimeApi as kr, WorkPromotionStatsResponse as kt, RoomsApi as l, AppRuntimeConfigureRequest as li, buildSpaceInvitePath as ln, PromptsApi as lr, AppViewSource as lt, AppCommerceEntitlement as m, PublicFileCreateUploadInput as mi, GenerationStreamEvent as mn, CohubClientOptions as mr, PublicAppVersionSummary as mt, createHttpClient as n, AppNavigationTarget as ni, SpaceWebhooksApi as nn, PublicAssetsApi as nr, AppRecord as nt, RoomEventsQuery as o, AppDropResource as oi, BuildSpaceInvitePathInput as on, UploadGenerationInputInput as or, AppTargetType as ot, AppCommerceCreditConsumeStatus as p, appAppearanceVar as pi, GenerationStreamErrorEvent as pn, ChannelsApi as pr, AppsApi as pt, AppPresentationMeta as q, ReferenceResourceSelector as qn, createSlugAppIdResolver as qr, OpenSpaceFileOptions as qt, RoomCreated as r, APP_APPEARANCE_TOKENS as ri, SpacesApi as rn, UploadAppSourceInput as rr, AppResolveResponse as rt, RoomInvite as s, AppDropResourceType as si, BuildSpacePathInput as sn, UploadPublicAssetInput as sr, AppUpdateInput as st, CohubHttpClient as t, AppNavigationOpenResponse as ti, SpaceTurnListOptions as tn, PublicAssetUploadProtocol as tr, AppPublicSpaceRecord as tt, AppCommerceApi as u, AppRuntimeRect as ui, buildSpacePath as un, ModelsApi as ur, AppViewStatsResponse as ut, AppCommercePurchaseResponse as v, PublicFileUploadEntryInput as vi, GenerationStreamOutOfSyncEvent as vn, HttpTransport as vr, WorkCreateInput as vt, WorkCommerceEntitlementsResponse as w, CreateGenerationTaskRequest as wi, createSessionGenerationStreamClient as wn, AppAuthorizationRequest as wr, WorkPromotionCreateInput as wt, WorkCommerceCreditConsumeResponse as x, SpaceWebhookListItem as xi, GenerationStreamSubscriptionHandlers as xn, joinApiUrl as xr, WorkGetResponse as xt, WorkCommerceApi as y, PublicFileUploadPlanEntry as yi, GenerationStreamStateEvent as yn, RawHttpResponse as yr, WorkDetailResponse as yt, AppAuthorizeResponse as z, BoardAwarenessUpdatedEvent as zn, AppRuntimeResolvedApp as zr, WorkViewSource as zt };
|
package/dist/chunks/http.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M as isUuid, h as getRealtimeSpaceRoom, m as getRealtimeBoardRoom, n as HttpTransport, t as HttpError } from "./transport.js";
|
|
2
2
|
import { l as resolveExecutionToken, o as resolveApiBaseUrl } from "./environment.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region ../protocol/dist/model/metrics.js
|
|
@@ -360,11 +360,6 @@ z.object({
|
|
|
360
360
|
quality: z.number().int().min(1).max(100).optional(),
|
|
361
361
|
maxSize: z.number().int().min(1).max(DISPLAY_DIMENSION_MAX).optional()
|
|
362
362
|
});
|
|
363
|
-
z.object({
|
|
364
|
-
urls: z.union([z.string().min(1).max(512), z.array(z.string().min(1).max(512)).min(1).max(16)]),
|
|
365
|
-
username: z.string().max(512).optional(),
|
|
366
|
-
credential: z.string().max(512).optional()
|
|
367
|
-
});
|
|
368
363
|
z.object({
|
|
369
364
|
offer: z.string().min(1).max(65536),
|
|
370
365
|
control: z.boolean().optional()
|
|
@@ -1258,17 +1253,78 @@ var SpaceBoardsApi = class {
|
|
|
1258
1253
|
}
|
|
1259
1254
|
};
|
|
1260
1255
|
//#endregion
|
|
1256
|
+
//#region src/rtc/index.ts
|
|
1257
|
+
const ICE_REFRESH_MARGIN_MS = 3e5;
|
|
1258
|
+
var IceServerCache = class {
|
|
1259
|
+
load;
|
|
1260
|
+
cached = null;
|
|
1261
|
+
constructor(load) {
|
|
1262
|
+
this.load = load;
|
|
1263
|
+
}
|
|
1264
|
+
async get(signal) {
|
|
1265
|
+
if (this.cached && this.cached.refreshAt > Date.now()) return this.cached.value;
|
|
1266
|
+
const value = await this.load(signal);
|
|
1267
|
+
this.cached = {
|
|
1268
|
+
value,
|
|
1269
|
+
refreshAt: Date.parse(value.expiresAt) - ICE_REFRESH_MARGIN_MS
|
|
1270
|
+
};
|
|
1271
|
+
return value;
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
function waitForIceGathering(pc, timeoutMs, signal) {
|
|
1275
|
+
if (pc.iceGatheringState === "complete") return Promise.resolve();
|
|
1276
|
+
if (signal?.aborted) return Promise.reject(signal.reason ?? new DOMException("Aborted", "AbortError"));
|
|
1277
|
+
return new Promise((resolve, reject) => {
|
|
1278
|
+
const cleanup = () => {
|
|
1279
|
+
clearTimeout(timer);
|
|
1280
|
+
pc.removeEventListener("icegatheringstatechange", check);
|
|
1281
|
+
signal?.removeEventListener("abort", abort);
|
|
1282
|
+
};
|
|
1283
|
+
const done = () => {
|
|
1284
|
+
cleanup();
|
|
1285
|
+
resolve();
|
|
1286
|
+
};
|
|
1287
|
+
const check = () => {
|
|
1288
|
+
if (pc.iceGatheringState === "complete") done();
|
|
1289
|
+
};
|
|
1290
|
+
const abort = () => {
|
|
1291
|
+
cleanup();
|
|
1292
|
+
reject(signal?.reason ?? new DOMException("Aborted", "AbortError"));
|
|
1293
|
+
};
|
|
1294
|
+
const timer = setTimeout(done, timeoutMs);
|
|
1295
|
+
pc.addEventListener("icegatheringstatechange", check);
|
|
1296
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
const statNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
1300
|
+
function readRtcTransportStats(report) {
|
|
1301
|
+
const stats = {
|
|
1302
|
+
path: null,
|
|
1303
|
+
relayProtocol: null,
|
|
1304
|
+
rttMs: null
|
|
1305
|
+
};
|
|
1306
|
+
report.forEach((entry) => {
|
|
1307
|
+
if (entry.type !== "candidate-pair" || !entry.nominated || entry.state !== "succeeded") return;
|
|
1308
|
+
const local = report.get(String(entry.localCandidateId));
|
|
1309
|
+
const remote = report.get(String(entry.remoteCandidateId));
|
|
1310
|
+
stats.path = local?.candidateType === "relay" || remote?.candidateType === "relay" ? "relay" : "direct";
|
|
1311
|
+
if (local?.candidateType === "relay" && typeof local.relayProtocol === "string") stats.relayProtocol = local.relayProtocol;
|
|
1312
|
+
const rtt = statNumber(entry.currentRoundTripTime);
|
|
1313
|
+
if (rtt !== null) stats.rttMs = Math.round(rtt * 1e3);
|
|
1314
|
+
});
|
|
1315
|
+
return stats;
|
|
1316
|
+
}
|
|
1317
|
+
//#endregion
|
|
1261
1318
|
//#region src/display-stats.ts
|
|
1262
|
-
const num = (value) => typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
1263
1319
|
function perFrame(seconds, previousSeconds, frames, previousFrames) {
|
|
1264
1320
|
const count = frames - previousFrames;
|
|
1265
1321
|
return count > 0 ? Math.round((seconds - previousSeconds) * 1e3 / count) : null;
|
|
1266
1322
|
}
|
|
1267
1323
|
function readDisplayStats(report, previous, fallbackRttMs = null) {
|
|
1324
|
+
const transport = readRtcTransportStats(report);
|
|
1268
1325
|
const stats = {
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
rttMs: fallbackRttMs,
|
|
1326
|
+
...transport,
|
|
1327
|
+
rttMs: transport.rttMs ?? fallbackRttMs,
|
|
1272
1328
|
fps: null,
|
|
1273
1329
|
bitrate: null,
|
|
1274
1330
|
width: null,
|
|
@@ -1280,27 +1336,19 @@ function readDisplayStats(report, previous, fallbackRttMs = null) {
|
|
|
1280
1336
|
};
|
|
1281
1337
|
let counters = null;
|
|
1282
1338
|
report.forEach((entry) => {
|
|
1283
|
-
if (entry.type === "candidate-pair" && entry.nominated && entry.state === "succeeded") {
|
|
1284
|
-
const local = report.get(String(entry.localCandidateId));
|
|
1285
|
-
const remote = report.get(String(entry.remoteCandidateId));
|
|
1286
|
-
stats.path = local?.candidateType === "relay" || remote?.candidateType === "relay" ? "relay" : "direct";
|
|
1287
|
-
if (local?.candidateType === "relay" && typeof local.relayProtocol === "string") stats.relayProtocol = local.relayProtocol;
|
|
1288
|
-
const rtt = num(entry.currentRoundTripTime);
|
|
1289
|
-
if (rtt !== null) stats.rttMs = Math.round(rtt * 1e3);
|
|
1290
|
-
}
|
|
1291
1339
|
if (entry.type === "inbound-rtp" && entry.kind === "video") {
|
|
1292
|
-
stats.fps =
|
|
1293
|
-
stats.width =
|
|
1294
|
-
stats.height =
|
|
1295
|
-
stats.packetsLost =
|
|
1296
|
-
stats.freezes =
|
|
1340
|
+
stats.fps = statNumber(entry.framesPerSecond);
|
|
1341
|
+
stats.width = statNumber(entry.frameWidth);
|
|
1342
|
+
stats.height = statNumber(entry.frameHeight);
|
|
1343
|
+
stats.packetsLost = statNumber(entry.packetsLost);
|
|
1344
|
+
stats.freezes = statNumber(entry.freezeCount);
|
|
1297
1345
|
counters = {
|
|
1298
|
-
at:
|
|
1299
|
-
bytes:
|
|
1300
|
-
jitterBufferDelay:
|
|
1301
|
-
jitterBufferEmitted:
|
|
1302
|
-
decodeTime:
|
|
1303
|
-
decoded:
|
|
1346
|
+
at: statNumber(entry.timestamp) ?? 0,
|
|
1347
|
+
bytes: statNumber(entry.bytesReceived) ?? 0,
|
|
1348
|
+
jitterBufferDelay: statNumber(entry.jitterBufferDelay) ?? 0,
|
|
1349
|
+
jitterBufferEmitted: statNumber(entry.jitterBufferEmittedCount) ?? 0,
|
|
1350
|
+
decodeTime: statNumber(entry.totalDecodeTime) ?? 0,
|
|
1351
|
+
decoded: statNumber(entry.framesDecoded) ?? 0
|
|
1304
1352
|
};
|
|
1305
1353
|
if (previous && counters.at > previous.at) {
|
|
1306
1354
|
stats.bitrate = Math.round((counters.bytes - previous.bytes) * 8 * 1e3 / (counters.at - previous.at));
|
|
@@ -1372,7 +1420,7 @@ var DisplayConnection = class DisplayConnection {
|
|
|
1372
1420
|
const connection = new DisplayConnection(api, displayId, options.control ?? true, pc);
|
|
1373
1421
|
try {
|
|
1374
1422
|
await pc.setLocalDescription(await pc.createOffer());
|
|
1375
|
-
await
|
|
1423
|
+
await waitForIceGathering(pc, options.gatherTimeoutMs ?? DEFAULT_GATHER_TIMEOUT_MS, options.signal);
|
|
1376
1424
|
const offer = pc.localDescription?.sdp;
|
|
1377
1425
|
if (!offer) throw new Error("The browser produced no offer");
|
|
1378
1426
|
const session = await api.openSession(displayId, {
|
|
@@ -1506,38 +1554,15 @@ var DisplayConnection = class DisplayConnection {
|
|
|
1506
1554
|
}
|
|
1507
1555
|
}
|
|
1508
1556
|
};
|
|
1509
|
-
function gathered(pc, timeoutMs, signal) {
|
|
1510
|
-
if (pc.iceGatheringState === "complete") return Promise.resolve();
|
|
1511
|
-
return new Promise((resolve, reject) => {
|
|
1512
|
-
const done = () => {
|
|
1513
|
-
clearTimeout(timer);
|
|
1514
|
-
pc.removeEventListener("icegatheringstatechange", check);
|
|
1515
|
-
signal?.removeEventListener("abort", abort);
|
|
1516
|
-
resolve();
|
|
1517
|
-
};
|
|
1518
|
-
const check = () => {
|
|
1519
|
-
if (pc.iceGatheringState === "complete") done();
|
|
1520
|
-
};
|
|
1521
|
-
const abort = () => {
|
|
1522
|
-
clearTimeout(timer);
|
|
1523
|
-
pc.removeEventListener("icegatheringstatechange", check);
|
|
1524
|
-
reject(signal?.reason ?? new DOMException("Aborted", "AbortError"));
|
|
1525
|
-
};
|
|
1526
|
-
const timer = setTimeout(done, timeoutMs);
|
|
1527
|
-
pc.addEventListener("icegatheringstatechange", check);
|
|
1528
|
-
signal?.addEventListener("abort", abort, { once: true });
|
|
1529
|
-
});
|
|
1530
|
-
}
|
|
1531
1557
|
function connectDisplay(api, displayId, options) {
|
|
1532
1558
|
return DisplayConnection.open(api, displayId, options);
|
|
1533
1559
|
}
|
|
1534
1560
|
//#endregion
|
|
1535
1561
|
//#region src/apis/displays.ts
|
|
1536
|
-
const ICE_REFRESH_MARGIN_MS = 3e5;
|
|
1537
1562
|
var SpaceDisplaysApi = class {
|
|
1538
1563
|
transport;
|
|
1539
1564
|
spaceId;
|
|
1540
|
-
ice =
|
|
1565
|
+
ice = new IceServerCache((signal) => this.transport.request(`/api/spaces/${this.spaceId}/rtc/ice-servers`, { signal }));
|
|
1541
1566
|
constructor(transport, spaceId) {
|
|
1542
1567
|
this.transport = transport;
|
|
1543
1568
|
this.spaceId = spaceId;
|
|
@@ -1581,14 +1606,8 @@ var SpaceDisplaysApi = class {
|
|
|
1581
1606
|
signal: options.signal
|
|
1582
1607
|
});
|
|
1583
1608
|
}
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
const value = await this.transport.request(`/api/spaces/${this.spaceId}/rtc/ice-servers`, { signal: options.signal });
|
|
1587
|
-
this.ice = {
|
|
1588
|
-
value,
|
|
1589
|
-
refreshAt: Date.parse(value.expiresAt) - ICE_REFRESH_MARGIN_MS
|
|
1590
|
-
};
|
|
1591
|
-
return value;
|
|
1609
|
+
iceServers(options = {}) {
|
|
1610
|
+
return this.ice.get(options.signal);
|
|
1592
1611
|
}
|
|
1593
1612
|
connect(displayId, options) {
|
|
1594
1613
|
return connectDisplay(this, displayId, options);
|
|
@@ -4215,7 +4234,8 @@ var TasksApi = class {
|
|
|
4215
4234
|
this.websocketClient = websocketClient;
|
|
4216
4235
|
}
|
|
4217
4236
|
get(taskRunId, options) {
|
|
4218
|
-
|
|
4237
|
+
const query = options?.include?.length ? `?include=${options.include.join(",")}` : "";
|
|
4238
|
+
return this.transport.request(`/api/tasks/${taskRunId}${query}`, { signal: options?.signal });
|
|
4219
4239
|
}
|
|
4220
4240
|
async wait(taskRunId, options = {}) {
|
|
4221
4241
|
if (options.signal?.aborted) throw new DOMException("The task wait was aborted.", "AbortError");
|
|
@@ -4746,6 +4766,77 @@ var AppCommerceApi = class {
|
|
|
4746
4766
|
/** @deprecated Use `AppCommerceApi`. */
|
|
4747
4767
|
var WorkCommerceApi = class extends AppCommerceApi {};
|
|
4748
4768
|
//#endregion
|
|
4769
|
+
//#region src/apis/rooms.ts
|
|
4770
|
+
const MAX_WAIT_PER_READ_MS = 25e3;
|
|
4771
|
+
var RoomsApi = class {
|
|
4772
|
+
transport;
|
|
4773
|
+
constructor(transport) {
|
|
4774
|
+
this.transport = transport;
|
|
4775
|
+
}
|
|
4776
|
+
create(input) {
|
|
4777
|
+
return this.post("", input);
|
|
4778
|
+
}
|
|
4779
|
+
join(input) {
|
|
4780
|
+
return this.post("/join", input);
|
|
4781
|
+
}
|
|
4782
|
+
get(roomId) {
|
|
4783
|
+
return this.transport.request(this.path(roomId));
|
|
4784
|
+
}
|
|
4785
|
+
async events(roomId, query = {}) {
|
|
4786
|
+
const deadline = Date.now() + Math.max(0, query.waitMs ?? 0);
|
|
4787
|
+
const result = {
|
|
4788
|
+
events: [],
|
|
4789
|
+
cursor: query.after ?? 0,
|
|
4790
|
+
truncated: false
|
|
4791
|
+
};
|
|
4792
|
+
if (query.limit !== void 0 && query.limit <= 0) return result;
|
|
4793
|
+
let after = query.after;
|
|
4794
|
+
for (;;) {
|
|
4795
|
+
const waitMs = Math.min(Math.max(0, deadline - Date.now()), MAX_WAIT_PER_READ_MS);
|
|
4796
|
+
const params = new URLSearchParams();
|
|
4797
|
+
if (after !== void 0) params.set("after", String(after));
|
|
4798
|
+
if (query.types?.length) params.set("types", query.types.join(","));
|
|
4799
|
+
if (query.limit !== void 0) params.set("limit", String(query.limit - result.events.length));
|
|
4800
|
+
if (waitMs > 0) params.set("wait", String(waitMs));
|
|
4801
|
+
const page = await this.transport.request(`${this.path(roomId)}/events?${params}`, { signal: query.signal });
|
|
4802
|
+
result.events.push(...page.events);
|
|
4803
|
+
result.cursor = page.cursor;
|
|
4804
|
+
result.truncated ||= page.truncated;
|
|
4805
|
+
if (result.events.some((event) => !event.self) || result.events.length >= (query.limit ?? Number.POSITIVE_INFINITY) || waitMs === 0 || Date.now() >= deadline || query.signal?.aborted) return result;
|
|
4806
|
+
after = page.cursor;
|
|
4807
|
+
}
|
|
4808
|
+
}
|
|
4809
|
+
publish(roomId, type, data) {
|
|
4810
|
+
return this.post(`/${encodeURIComponent(roomId)}/events`, {
|
|
4811
|
+
type,
|
|
4812
|
+
data: data ?? null
|
|
4813
|
+
});
|
|
4814
|
+
}
|
|
4815
|
+
setPresence(roomId, presence) {
|
|
4816
|
+
return this.transport.request(`${this.path(roomId)}/presence`, {
|
|
4817
|
+
method: "PUT",
|
|
4818
|
+
headers: { "Content-Type": "application/json" },
|
|
4819
|
+
body: JSON.stringify({ presence })
|
|
4820
|
+
});
|
|
4821
|
+
}
|
|
4822
|
+
invite(roomId, input = {}) {
|
|
4823
|
+
return this.post(`/${encodeURIComponent(roomId)}/invites`, input);
|
|
4824
|
+
}
|
|
4825
|
+
leave(roomId) {
|
|
4826
|
+
return this.transport.request(`${this.path(roomId)}/seat`, { method: "DELETE" });
|
|
4827
|
+
}
|
|
4828
|
+
path(roomId) {
|
|
4829
|
+
return `/api/rooms/${encodeURIComponent(roomId)}`;
|
|
4830
|
+
}
|
|
4831
|
+
post(path, body) {
|
|
4832
|
+
return this.transport.request(`/api/rooms${path}`, {
|
|
4833
|
+
method: "POST",
|
|
4834
|
+
headers: { "Content-Type": "application/json" },
|
|
4835
|
+
body: JSON.stringify(body)
|
|
4836
|
+
});
|
|
4837
|
+
}
|
|
4838
|
+
};
|
|
4839
|
+
//#endregion
|
|
4749
4840
|
//#region src/http.ts
|
|
4750
4841
|
var CohubHttpClient = class {
|
|
4751
4842
|
spaces;
|
|
@@ -4766,6 +4857,7 @@ var CohubHttpClient = class {
|
|
|
4766
4857
|
referrals;
|
|
4767
4858
|
apps;
|
|
4768
4859
|
appCommerce;
|
|
4860
|
+
rooms;
|
|
4769
4861
|
/** @deprecated Use `apps`. */
|
|
4770
4862
|
get works() {
|
|
4771
4863
|
return this.apps;
|
|
@@ -4806,6 +4898,7 @@ var CohubHttpClient = class {
|
|
|
4806
4898
|
this.referrals = new ReferralsApi(this.transport);
|
|
4807
4899
|
this.apps = new AppsApi(this.transport);
|
|
4808
4900
|
this.appCommerce = new AppCommerceApi(this.transport);
|
|
4901
|
+
this.rooms = new RoomsApi(this.transport);
|
|
4809
4902
|
this.desktop = new DesktopCommandsApi(this.transport);
|
|
4810
4903
|
}
|
|
4811
4904
|
space(spaceId) {
|
|
@@ -4814,4 +4907,4 @@ var CohubHttpClient = class {
|
|
|
4814
4907
|
};
|
|
4815
4908
|
const createHttpClient = (options) => new CohubHttpClient(options);
|
|
4816
4909
|
//#endregion
|
|
4817
|
-
export {
|
|
4910
|
+
export { isTerminalDesktopCommandStatus as $, BoardClient as A, CronJobsApi as B, SessionPatchReducer as C, connectDisplay as D, DisplayConnection as E, PublicAssetsApi as F, DESKTOP_COMMAND_OPEN_TIMEOUT_MS as G, DESKTOP_COMMAND_ACCEPT_TIMEOUT_MS as H, SkillsApi as I, DESKTOP_COMMAND_SETTLEMENT_GRACE_SECONDS as J, DESKTOP_COMMAND_PAYLOAD_MAX_BYTES as K, PromptsApi as L, SessionAccessApi as M, ReferencesApi as N, readRtcTransportStats as O, SearchApi as P, isDesktopCallMethod as Q, ModelsApi as R, parseAssistantMessageCommit as S, SpaceDisplaysApi as T, DESKTOP_COMMAND_DEFAULT_TIMEOUT_MS as U, ChannelsApi as V, DESKTOP_COMMAND_MAX_TIMEOUT_MS as W, DESKTOP_COMMAND_VERSION as X, DESKTOP_COMMAND_TERMINAL_TTL_SECONDS as Y, defaultDesktopCommandTimeoutMs as Z, PublicInviteApi as _, WorkCommerceApi as a, DISPLAY_INPUT_MAX_SCHEDULE_MS as at, SessionGenerationStreamClient as b, AppsApi as c, normalizeDisplayPoint as ct, UserApi as d, parseDesktopCommand as et, TasksApi as f, SpacesApi as g, SpaceWebhooksApi as h, AppCommerceApi as i, DISPLAY_ELEMENT_REF_PATTERN as it, ensureRealtimeConnected as j, waitForIceGathering as k, ReferralsApi as l, splitDisplayText as lt, SpacePublicFilesApi as m, createHttpClient as n, resolveOpenSurface as nt, DesktopCommandsApi as o, DISPLAY_INPUT_MAX_TEXT as ot, SpaceClient as p, DESKTOP_COMMAND_PENDING_TTL_SECONDS as q, RoomsApi as r, NAVIGATION_ERROR_MESSAGE_MAX_LENGTH as rt, UiCommandsApi as s, DISPLAY_SYSTEM_ACTIONS as st, CohubHttpClient as t, parseDesktopCommandId as tt, UsersApi as u, buildSpaceInvitePath as v, createSessionPatchReducer as w, createSessionGenerationStreamClient as x, buildSpacePath as y, GenerationsApi as z };
|
package/dist/chunks/transport.js
CHANGED
|
@@ -152,6 +152,8 @@ const WS_COMPACT_STREAM_CAPABILITY = "session.compact_stream.v1";
|
|
|
152
152
|
const WS_ROOM_SUBSCRIPTION_CAPABILITY = "realtime.rooms.v1";
|
|
153
153
|
const WS_BOARD_AWARENESS_CAPABILITY = "board.awareness.v1";
|
|
154
154
|
const WS_REALTIME_ROOM_CAPABILITY = "realtime.room.v1";
|
|
155
|
+
const WS_REALTIME_ROOM_RTC_CAPABILITY = "realtime.room.rtc.v1";
|
|
156
|
+
const WS_REALTIME_ROOM_HISTORY_CAPABILITY = "realtime.room.history.v1";
|
|
155
157
|
const REALTIME_DOMAINS = [
|
|
156
158
|
"system",
|
|
157
159
|
"session",
|
|
@@ -282,7 +284,7 @@ function joinApiUrl(baseUrl, path) {
|
|
|
282
284
|
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
283
285
|
if (!base) return normalizedPath;
|
|
284
286
|
if (/^https?:\/\//i.test(base)) try {
|
|
285
|
-
return new URL(normalizedPath
|
|
287
|
+
return new URL(`.${normalizedPath}`, `${base}/`).href;
|
|
286
288
|
} catch {}
|
|
287
289
|
return `${base}${normalizedPath}`;
|
|
288
290
|
}
|
|
@@ -507,4 +509,4 @@ var HttpTransport = class {
|
|
|
507
509
|
}
|
|
508
510
|
};
|
|
509
511
|
//#endregion
|
|
510
|
-
export {
|
|
512
|
+
export { requestSourceToHeaders as A, isRequestSourceClientId as C, normalizeRequestSource as D, mergeRequestSourceIntoMeta as E, isUuid as M, isUuidLike as N, parseRequestSourceFromHeaders as O, isUuidOrShortUuid as P, hasRequestSourceIdentity as S, isRequestSourceUuid as T, isRealtimeDomain as _, sanitizeAccessToken as a, COHUB_SOURCE_HEADER_NAMES as b, WS_BOARD_AWARENESS_CAPABILITY as c, WS_REALTIME_ROOM_HISTORY_CAPABILITY as d, WS_REALTIME_ROOM_RTC_CAPABILITY as f, getSessionTurnPatchStreamKey as g, getRealtimeSpaceRoom as h, matchesUnauthorizedErrorToken as i, resolveRequestSourceChannel as j, readRequestSourceFromEnv as k, WS_COMPACT_STREAM_CAPABILITY as l, getRealtimeBoardRoom as m, HttpTransport as n, REALTIME_ROOM_EVENT_NAME_PATTERN as o, WS_ROOM_SUBSCRIPTION_CAPABILITY as p, joinApiUrl as r, REALTIME_ROOM_MAX_PAYLOAD_BYTES as s, HttpError as t, WS_REALTIME_ROOM_CAPABILITY as u, normalizeRealtimeRooms as v, isRequestSourceEmpty as w, REQUEST_SOURCE_VIA_MAX_LENGTH as x, COHUB_SOURCE_HEADER as y };
|