@q9labsai/chalk-client 5.1.0 → 5.2.1
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/CHANGELOG.md +125 -0
- package/dist/chat-files/types.d.ts +3 -0
- package/dist/chunk-6LNRDKJF.js +162 -0
- package/dist/{chunk-3ZN7IXOZ.js → chunk-GA3JDPFI.js} +252 -2
- package/dist/{chunk-RJRSLXVT.js → chunk-RVUN6LW4.js} +764 -265
- package/dist/{chunk-K7PNW3KI.js → chunk-TVNI2XUZ.js} +172 -18
- package/dist/client.d.ts +205 -0
- package/dist/connection/dependencies.d.ts +3 -0
- package/dist/connection/diagnostics.d.ts +3 -2
- package/dist/connection/index.d.ts +1 -0
- package/dist/connection/lifecycle.d.ts +1 -0
- package/dist/connection/types.d.ts +2 -0
- package/dist/effect.js +62 -4
- package/dist/generated/http-api.d.ts +201 -0
- package/dist/generated/schemas.d.ts +373 -0
- package/dist/generated/sync.d.ts +74 -3
- package/dist/generated/whiteboard-v1.d.ts +71 -9
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -14
- package/dist/public-invites/code.d.ts +1 -0
- package/dist/public-invites/index.d.ts +1 -0
- package/dist/public-invites/index.js +6 -4
- package/dist/public-invites/words.d.ts +2 -0
- package/dist/space-client/reload-rejoin.d.ts +1 -1
- package/dist/space-client/types.d.ts +10 -1
- package/dist/sync/connect-diagnostics.d.ts +10 -0
- package/dist/sync/index.js +1 -1
- package/dist/sync/types.d.ts +1 -0
- package/dist/sync/v1-client.d.ts +2 -0
- package/dist/sync/v1-types.d.ts +8 -0
- package/dist/whiteboard/index.d.ts +2 -5
- package/dist/whiteboard/types.d.ts +26 -3
- package/dist/whiteboard/v1-client.d.ts +3 -1
- package/dist/whiteboard/v1-codec.d.ts +5 -1
- package/dist/whiteboard/v1-multipart.d.ts +1 -1
- package/dist/whiteboard/view-bounds.d.ts +5 -0
- package/dist/whiteboard/view-versions.d.ts +9 -0
- package/package.json +1 -1
- package/dist/chunk-KHHULLBZ.js +0 -142
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MediaSource, ScreenShareCapture } from "../media/plane";
|
|
2
2
|
import type { ChalkChatAttachment, ChalkChatMessage, ChalkChatReadReceipt, ChalkIncomingMediaRequest, ChalkParticipantMediaState, ChalkReaction, ChalkReactionEvent } from "../collaboration/types";
|
|
3
|
-
import type { ChalkWhiteboardV1Failure } from "../whiteboard/types";
|
|
3
|
+
import type { ChalkWhiteboardDrawPermission, ChalkWhiteboardDrawPolicy, ChalkWhiteboardV1Failure } from "../whiteboard/types";
|
|
4
4
|
import type { AccessGrant } from "../access/grant";
|
|
5
5
|
import type { V1Capability } from "../sync/v1-types";
|
|
6
6
|
import type { ChatControllerEffects } from "./chat-controller";
|
|
@@ -52,6 +52,7 @@ export type ClientFailure = {
|
|
|
52
52
|
readonly code: ErrorCode;
|
|
53
53
|
readonly recoverable: boolean;
|
|
54
54
|
readonly message: string;
|
|
55
|
+
readonly sync?: import("../sync/connect-diagnostics").SyncConnectDiagnostic;
|
|
55
56
|
};
|
|
56
57
|
export type EpisodeSummary = {
|
|
57
58
|
readonly id: string;
|
|
@@ -66,6 +67,7 @@ export type ConnectionSlice = {
|
|
|
66
67
|
readonly lastError: ClientFailure | null;
|
|
67
68
|
/** The Episode ended while this person was in it. */
|
|
68
69
|
readonly episodeEnded: boolean;
|
|
70
|
+
readonly episodeEndReason?: import("../sync/v1-types").V1ControlState["endReason"];
|
|
69
71
|
/** The server removed this person from the call; a person's own leave never sets this. */
|
|
70
72
|
readonly removedByHost: boolean;
|
|
71
73
|
};
|
|
@@ -203,6 +205,12 @@ export type WhiteboardSlice = {
|
|
|
203
205
|
readonly presenting: boolean;
|
|
204
206
|
readonly error: ChalkWhiteboardV1Failure | null;
|
|
205
207
|
};
|
|
208
|
+
/** Who can draw, as Sync last told this person. `canDraw` is false until the board subscription is live. */
|
|
209
|
+
readonly access: {
|
|
210
|
+
readonly canDraw: boolean;
|
|
211
|
+
readonly policy: ChalkWhiteboardDrawPolicy | null;
|
|
212
|
+
readonly permissions: readonly ChalkWhiteboardDrawPermission[];
|
|
213
|
+
};
|
|
206
214
|
};
|
|
207
215
|
export type SpaceSnapshot = {
|
|
208
216
|
readonly connection: ConnectionSlice;
|
|
@@ -253,6 +261,7 @@ export type ClientEventMap = {
|
|
|
253
261
|
};
|
|
254
262
|
readonly episodeEnded: {
|
|
255
263
|
readonly episode: EpisodeSummary | null;
|
|
264
|
+
readonly reason?: ConnectionSlice["episodeEndReason"];
|
|
256
265
|
};
|
|
257
266
|
readonly screenShareStarted: {
|
|
258
267
|
readonly participantId: string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Browsers expose only upgrade/open and hello, never DNS/TCP/TLS progress. */
|
|
2
|
+
export type SyncConnectDiagnostic = {
|
|
3
|
+
readonly stage: "upgrade" | "hello";
|
|
4
|
+
readonly opened: boolean;
|
|
5
|
+
readonly closeCode: number | null;
|
|
6
|
+
readonly closeReason: string | null;
|
|
7
|
+
readonly durationMs: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function safeSyncCloseReason(reason: string | undefined): string | null;
|
|
10
|
+
export declare function formatSyncConnectDiagnostic(diagnostic: SyncConnectDiagnostic): string;
|
package/dist/sync/index.js
CHANGED
package/dist/sync/types.d.ts
CHANGED
package/dist/sync/v1-client.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export declare class V1SyncClient implements V1CollaborationClient {
|
|
|
13
13
|
restartTransport(): void;
|
|
14
14
|
start(): Promise<void>;
|
|
15
15
|
stop(): void;
|
|
16
|
+
/** Announces completed startup; transport recovery resends until acknowledged. */
|
|
17
|
+
confirmEntered(): Promise<void>;
|
|
16
18
|
getSnapshot(): V1EpisodeSnapshot;
|
|
17
19
|
subscribe(listener: (snapshot: V1EpisodeSnapshot) => void): () => void;
|
|
18
20
|
onMediaPause(listener: (pause: V1MediaPause) => void): () => void;
|
package/dist/sync/v1-types.d.ts
CHANGED
|
@@ -37,6 +37,10 @@ export type V1ControlState = {
|
|
|
37
37
|
readonly stateSchemaVersion: number;
|
|
38
38
|
readonly stateDigest: string;
|
|
39
39
|
readonly status: "active" | "ended";
|
|
40
|
+
readonly endReason?: Extract<SyncV1ServerFrame, {
|
|
41
|
+
readonly type: "event";
|
|
42
|
+
readonly name: "episode_ended";
|
|
43
|
+
}>["payload"]["reason"];
|
|
40
44
|
readonly admissionPolicy: V1AdmissionPolicy;
|
|
41
45
|
readonly deadlineAtMs: number;
|
|
42
46
|
readonly deadlineGeneration: number;
|
|
@@ -75,6 +79,8 @@ export type V1EpisodeSnapshot = {
|
|
|
75
79
|
readonly health?: import("./v1-health").SyncHealth;
|
|
76
80
|
/** Cumulative count retained across successful retries; contains no URL or credentials. */
|
|
77
81
|
readonly dialTimeoutCount?: number;
|
|
82
|
+
readonly connectAttempt?: import("./connect-diagnostics").SyncConnectDiagnostic;
|
|
83
|
+
readonly connectFailure?: import("./connect-diagnostics").SyncConnectDiagnostic;
|
|
78
84
|
};
|
|
79
85
|
readonly participantId: string | null;
|
|
80
86
|
readonly participantGeneration: number | null;
|
|
@@ -201,6 +207,8 @@ export type V1SyncClientOptions = {
|
|
|
201
207
|
readonly retryDelayMs?: number;
|
|
202
208
|
readonly collaboration?: V1CollaborationExtensionRequest | false;
|
|
203
209
|
readonly maxPendingCollaborationRequests?: number;
|
|
210
|
+
/** Asks Sync to hold the entry until `confirmEntered()`; set it only when the caller will call that method. */
|
|
211
|
+
readonly entryConfirmation?: boolean;
|
|
204
212
|
};
|
|
205
213
|
export type V1Socket = SyncSocket;
|
|
206
214
|
/** Explicit host pause; control revisions do not identify a self-media operation. */
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const ChalkWhiteboardViewBounds: {
|
|
3
|
-
maxCoordinate: 1000000;
|
|
4
|
-
maxExtent: 2000000;
|
|
5
|
-
};
|
|
1
|
+
export { ChalkWhiteboardViewBounds } from "./view-bounds";
|
|
6
2
|
export { createChalkWhiteboardV1FileDownloadTransport, type ChalkWhiteboardV1FileDownloadTransportOptions } from "./file-download-transport";
|
|
7
3
|
export * from "./types";
|
|
8
4
|
export { ChalkWhiteboardV1Client } from "./v1-client";
|
|
9
5
|
export { decodeWhiteboardV1ServerFrame, encodeWhiteboardV1ClientFrame } from "./v1-codec";
|
|
10
6
|
export { createChalkWhiteboardV1Client, type CreateChalkWhiteboardV1ClientOptions } from "./v1-create";
|
|
11
7
|
export { InMemoryChalkWhiteboardV1PendingOperationStore } from "./v1-persistence";
|
|
8
|
+
export { ChalkWhiteboardViewVersions } from "./view-versions";
|
|
@@ -53,7 +53,15 @@ export type ChalkWhiteboardView = {
|
|
|
53
53
|
readonly width: number;
|
|
54
54
|
readonly height: number;
|
|
55
55
|
readonly bring: boolean;
|
|
56
|
+
/** Real move by default; false marks a passive refresh or heartbeat. */
|
|
57
|
+
readonly lead?: boolean;
|
|
56
58
|
} & ({
|
|
59
|
+
readonly ownerId: string;
|
|
60
|
+
readonly ownerSequence: number;
|
|
61
|
+
} | {
|
|
62
|
+
readonly ownerId?: never;
|
|
63
|
+
readonly ownerSequence?: never;
|
|
64
|
+
}) & ({
|
|
57
65
|
readonly originParticipantId: string;
|
|
58
66
|
readonly originSequence: number;
|
|
59
67
|
readonly originEpoch?: string;
|
|
@@ -67,7 +75,14 @@ export type ChalkWhiteboardV1Commit = {
|
|
|
67
75
|
readonly sceneId: string;
|
|
68
76
|
readonly revision: string;
|
|
69
77
|
};
|
|
70
|
-
export type ChalkWhiteboardV1Operation = "start_scene_subscription" | "submit_update" | "request_snapshot" | "clear" | "set_draw_permission" | "set_presentation" | "get_file_download";
|
|
78
|
+
export type ChalkWhiteboardV1Operation = "start_scene_subscription" | "submit_update" | "request_snapshot" | "clear" | "set_draw_permission" | "set_draw_policy" | "set_presentation" | "get_file_download";
|
|
79
|
+
/** Who can draw in the call. Hosts, the people whose role can manage the board, can always draw under `hosts` and `picked`. */
|
|
80
|
+
export type ChalkWhiteboardDrawPolicy = WhiteboardV1DrawPolicy;
|
|
81
|
+
/** A host's choice for one person. Under `everyone` it overrides the role default; under `picked` `true` means picked; under `hosts` it is kept but ignored. */
|
|
82
|
+
export type ChalkWhiteboardDrawPermission = {
|
|
83
|
+
readonly participantId: string;
|
|
84
|
+
readonly canDraw: boolean;
|
|
85
|
+
};
|
|
71
86
|
export type ChalkWhiteboardV1ErrorCode = "unavailable" | "permission_denied" | "invalid_payload" | "stale_scene" | "cursor_reset_required" | "storage_unavailable" | "file_transfer_failed";
|
|
72
87
|
export type ChalkWhiteboardV1Failure = {
|
|
73
88
|
readonly operation: ChalkWhiteboardV1Operation;
|
|
@@ -100,17 +115,20 @@ export type ChalkWhiteboardV1Transport = {
|
|
|
100
115
|
/** Whether the active subscription negotiated view_v1; remains stable during recovery. */
|
|
101
116
|
readonly supportsViews?: boolean;
|
|
102
117
|
/** Accepts views while subscribed; keeps the latest bring through recovery. False means views are unavailable. */
|
|
118
|
+
readonly forgetParticipant?: (participantId: string) => void;
|
|
103
119
|
readonly sendView?: (view: ChalkWhiteboardView) => boolean;
|
|
104
120
|
readonly requestSnapshot: () => Promise<void>;
|
|
105
121
|
readonly clear: () => Promise<ChalkWhiteboardV1Commit>;
|
|
106
122
|
readonly setDrawPermission: (participantId: string, canDraw: boolean) => Promise<void>;
|
|
123
|
+
/** Sets the call-wide drawing policy. Requires manageWhiteboard and a Sync server with draw_policy_v1. */
|
|
124
|
+
readonly setDrawPolicy?: (policy: ChalkWhiteboardDrawPolicy) => Promise<void>;
|
|
107
125
|
readonly setPresentation?: (presenting: boolean) => Promise<void>;
|
|
108
126
|
readonly files: ChalkWhiteboardV1FileTransport;
|
|
109
127
|
};
|
|
110
128
|
export type ChalkWhiteboardV1PendingOperation = {
|
|
111
129
|
readonly operationId: string;
|
|
112
130
|
readonly frame: Extract<WhiteboardV1ClientFrame, {
|
|
113
|
-
readonly type: "submit_update" | "clear" | "set_draw_permission" | "set_presentation";
|
|
131
|
+
readonly type: "submit_update" | "clear" | "set_draw_permission" | "set_draw_policy" | "set_presentation";
|
|
114
132
|
}>;
|
|
115
133
|
readonly createdAt: number;
|
|
116
134
|
readonly bytes: number;
|
|
@@ -154,12 +172,17 @@ export type ChalkWhiteboardSummary = {
|
|
|
154
172
|
readonly sceneId: string | null;
|
|
155
173
|
readonly revision: string | null;
|
|
156
174
|
readonly capabilities: readonly ChalkWhiteboardV1Capability[];
|
|
175
|
+
/** This person's drawing permission, computed by Sync from the policy, their role and the host's choice for them. */
|
|
157
176
|
readonly canDraw: boolean;
|
|
158
177
|
readonly canClear: boolean;
|
|
178
|
+
/** The call-wide policy, or null when the Sync server predates draw_policy_v1. */
|
|
179
|
+
readonly drawPolicy: ChalkWhiteboardDrawPolicy | null;
|
|
180
|
+
/** The host's per-person choices for people in the call. Empty unless this person is a host. */
|
|
181
|
+
readonly drawPermissions: readonly ChalkWhiteboardDrawPermission[];
|
|
159
182
|
readonly presenting: boolean;
|
|
160
183
|
readonly error: ChalkWhiteboardV1Failure | null;
|
|
161
184
|
};
|
|
162
|
-
import type { WhiteboardV1ClientFrame } from "../generated/whiteboard-v1";
|
|
185
|
+
import type { WhiteboardV1ClientFrame, WhiteboardV1DrawPolicy } from "../generated/whiteboard-v1";
|
|
163
186
|
import type { ChalkWhiteboardV1Capability } from "../collaboration/types";
|
|
164
187
|
import type { SyncClock, SyncIdGenerator, SyncLifecycle, SyncWebSocketFactory } from "../sync/types";
|
|
165
188
|
export type { ChalkWhiteboardV1Capability } from "../collaboration/types";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ChalkWhiteboardV1ClientOptions, type ChalkWhiteboardV1Commit, type ChalkWhiteboardV1Event, type ChalkWhiteboardSummary, type ChalkWhiteboardV1Transport, type ChalkWhiteboardV1UpdateInput, type ChalkWhiteboardView } from "./types";
|
|
1
|
+
import { type ChalkWhiteboardV1ClientOptions, type ChalkWhiteboardV1Commit, type ChalkWhiteboardDrawPolicy, type ChalkWhiteboardV1Event, type ChalkWhiteboardSummary, type ChalkWhiteboardV1Transport, type ChalkWhiteboardV1UpdateInput, type ChalkWhiteboardView } from "./types";
|
|
2
2
|
export declare class ChalkWhiteboardV1Client implements ChalkWhiteboardV1Transport {
|
|
3
3
|
#private;
|
|
4
4
|
readonly files: import("./types").ChalkWhiteboardV1FileTransport;
|
|
@@ -13,9 +13,11 @@ export declare class ChalkWhiteboardV1Client implements ChalkWhiteboardV1Transpo
|
|
|
13
13
|
readonly y: number;
|
|
14
14
|
}): void;
|
|
15
15
|
get supportsViews(): boolean;
|
|
16
|
+
forgetParticipant(participantId: string): void;
|
|
16
17
|
sendView(view: ChalkWhiteboardView): boolean;
|
|
17
18
|
requestSnapshot(): Promise<void>;
|
|
18
19
|
clear(): Promise<ChalkWhiteboardV1Commit>;
|
|
19
20
|
setDrawPermission(participantId: string, canDraw: boolean): Promise<void>;
|
|
21
|
+
setDrawPolicy(policy: ChalkWhiteboardDrawPolicy): Promise<void>;
|
|
20
22
|
setPresentation(presenting: boolean): Promise<void>;
|
|
21
23
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { type WhiteboardV1ServerFrame } from "../generated/whiteboard-v1";
|
|
2
2
|
export declare function encodeWhiteboardV1ClientFrame(frame: unknown): string;
|
|
3
|
-
|
|
3
|
+
/** Negotiated control frames belong to the connection, not the public 5.1 frame union. */
|
|
4
|
+
export declare function decodeWhiteboardV1ServerFrame(wire: string): Exclude<WhiteboardV1ServerFrame, {
|
|
5
|
+
readonly type: "view_ack" | "draw_access";
|
|
6
|
+
}>;
|
|
7
|
+
export declare function decodeWhiteboardV1WireFrame(wire: string): WhiteboardV1ServerFrame;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type WhiteboardV1ClientFrame, type WhiteboardV1ServerFrame } from "../generated/whiteboard-v1";
|
|
2
2
|
export type WhiteboardV1LogicalOperationFrame = Extract<WhiteboardV1ClientFrame, {
|
|
3
|
-
readonly type: "submit_update" | "clear" | "set_draw_permission" | "set_presentation";
|
|
3
|
+
readonly type: "submit_update" | "clear" | "set_draw_permission" | "set_draw_policy" | "set_presentation";
|
|
4
4
|
}>;
|
|
5
5
|
type UpdatePartFrame = Extract<WhiteboardV1ServerFrame, {
|
|
6
6
|
readonly type: "update_part";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ChalkWhiteboardView } from "./types";
|
|
2
|
+
/** Owner sequences are compared only within a connection's authoritative snapshot. */
|
|
3
|
+
export declare class ChalkWhiteboardViewVersions {
|
|
4
|
+
#private;
|
|
5
|
+
isNew(view: ChalkWhiteboardView, participantId?: string): boolean;
|
|
6
|
+
remember(view: ChalkWhiteboardView, participantId?: string): void;
|
|
7
|
+
forgetParticipant(participantId: string): void;
|
|
8
|
+
clear(): void;
|
|
9
|
+
}
|
package/package.json
CHANGED
package/dist/chunk-KHHULLBZ.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createChalkEffectClient,
|
|
3
|
-
parseAccessGrant
|
|
4
|
-
} from "./chunk-3ZN7IXOZ.js";
|
|
5
|
-
|
|
6
|
-
// src/public-invites/client.ts
|
|
7
|
-
import { Effect } from "effect";
|
|
8
|
-
function createChalkPublicClient(options) {
|
|
9
|
-
const baseClientOptions = {
|
|
10
|
-
baseUrl: options.baseUrl,
|
|
11
|
-
credentials: options.credentials ?? (options.runtime === "react-native" ? void 0 : "include"),
|
|
12
|
-
fetch: options.fetch
|
|
13
|
-
};
|
|
14
|
-
const createClient = (guestCredential, requestInit) => createChalkEffectClient({
|
|
15
|
-
...baseClientOptions,
|
|
16
|
-
...requestInit ? { fetch: requestInitFetch(options.fetch, requestInit) } : {},
|
|
17
|
-
headers: requestHeaders(options, guestCredential)
|
|
18
|
-
});
|
|
19
|
-
const createPublicSpace = async (input, idempotency) => {
|
|
20
|
-
const client = await Effect.runPromise(createClient(void 0));
|
|
21
|
-
const response = await Effect.runPromise(
|
|
22
|
-
client.spaces.createPublicSpace({
|
|
23
|
-
headers: { "Idempotency-Key": idempotencyKey(idempotency) },
|
|
24
|
-
payload: { display_name: required(input.displayName, "displayName") }
|
|
25
|
-
})
|
|
26
|
-
);
|
|
27
|
-
return publicSpaceCreated(response);
|
|
28
|
-
};
|
|
29
|
-
const arriveBySpacePublicInvite = async (input, arrival) => {
|
|
30
|
-
const client = await Effect.runPromise(createClient(arrival?.guestCredential ?? options.guestCredential));
|
|
31
|
-
const response = await Effect.runPromise(
|
|
32
|
-
client.spaces.arriveBySpacePublicInvite({
|
|
33
|
-
headers: {
|
|
34
|
-
"Idempotency-Key": idempotencyKey(arrival),
|
|
35
|
-
...arrival?.arrivalHandle === void 0 ? {} : { "X-Chalk-Arrival-Handle": required(arrival.arrivalHandle, "arrivalHandle") }
|
|
36
|
-
},
|
|
37
|
-
payload: {
|
|
38
|
-
display_name: required(input.displayName, "displayName"),
|
|
39
|
-
space_invite_token: required(input.spaceInviteToken, "spaceInviteToken")
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
);
|
|
43
|
-
return publicSpaceArrival(response);
|
|
44
|
-
};
|
|
45
|
-
const getSpacePublicInviteArrival = async (reference) => {
|
|
46
|
-
const normalized = arrivalReference(reference);
|
|
47
|
-
const client = await Effect.runPromise(createClient(normalized.guestCredential ?? options.guestCredential));
|
|
48
|
-
const response = await Effect.runPromise(
|
|
49
|
-
client.spaces.getSpacePublicInviteArrival({
|
|
50
|
-
headers: { "X-Chalk-Arrival-Handle": normalized.arrivalHandle }
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
return publicSpaceArrival(response);
|
|
54
|
-
};
|
|
55
|
-
const refreshSpacePublicInviteAccess = async (input, arrival) => {
|
|
56
|
-
const normalized = refreshInput(input, arrival);
|
|
57
|
-
const client = await Effect.runPromise(createClient(normalized.guestCredential ?? options.guestCredential, normalized.signal ? { signal: normalized.signal } : void 0));
|
|
58
|
-
const response = await Effect.runPromise(
|
|
59
|
-
client.spaces.refreshSpacePublicInviteAccess({
|
|
60
|
-
headers: { "X-Chalk-Arrival-Handle": normalized.arrivalHandle },
|
|
61
|
-
payload: { media_proof: required(normalized.mediaProof, "mediaProof"), replace_media_connection: normalized.replaceMediaConnection ?? false }
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
return parseAccessGrant(response);
|
|
65
|
-
};
|
|
66
|
-
const leaveSpacePublicInviteArrival = async (reference, leaveOptions) => {
|
|
67
|
-
const normalized = arrivalReference(reference);
|
|
68
|
-
const client = await Effect.runPromise(createClient(normalized.guestCredential ?? options.guestCredential, requestInitForLeave(leaveOptions)));
|
|
69
|
-
await Effect.runPromise(
|
|
70
|
-
client.spaces.leaveSpacePublicInviteArrival({
|
|
71
|
-
headers: { "X-Chalk-Arrival-Handle": normalized.arrivalHandle }
|
|
72
|
-
})
|
|
73
|
-
);
|
|
74
|
-
};
|
|
75
|
-
return {
|
|
76
|
-
prepareSpaceEntrance: async (spaceInviteToken) => {
|
|
77
|
-
const client = await Effect.runPromise(createClient(void 0));
|
|
78
|
-
await Effect.runPromise(client.spaces.preparePublicSpaceEntrance({ payload: { space_invite_token: required(spaceInviteToken, "spaceInviteToken") } }));
|
|
79
|
-
},
|
|
80
|
-
arrive: arriveBySpacePublicInvite,
|
|
81
|
-
arriveBySpacePublicInvite,
|
|
82
|
-
create: createPublicSpace,
|
|
83
|
-
createPublicSpace,
|
|
84
|
-
getSpacePublicInviteArrival,
|
|
85
|
-
leave: leaveSpacePublicInviteArrival,
|
|
86
|
-
leaveSpacePublicInviteArrival,
|
|
87
|
-
refresh: refreshSpacePublicInviteAccess,
|
|
88
|
-
refreshSpacePublicInviteAccess,
|
|
89
|
-
status: getSpacePublicInviteArrival
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
var createChalkPublicInviteClient = createChalkPublicClient;
|
|
93
|
-
function requestHeaders(options, guestCredential) {
|
|
94
|
-
const headers = { ...options.headers };
|
|
95
|
-
if (options.runtime === "react-native") {
|
|
96
|
-
headers["X-Chalk-Client"] = "react-native";
|
|
97
|
-
const credential = guestCredential ?? options.guestCredential;
|
|
98
|
-
if (credential !== void 0) headers.Authorization = `ChalkGuest ${required(credential, "guestCredential")}`;
|
|
99
|
-
}
|
|
100
|
-
return headers;
|
|
101
|
-
}
|
|
102
|
-
function idempotencyKey(options) {
|
|
103
|
-
return options?.idempotencyKey === void 0 ? globalThis.crypto.randomUUID() : required(options.idempotencyKey, "idempotencyKey");
|
|
104
|
-
}
|
|
105
|
-
function arrivalReference(reference) {
|
|
106
|
-
if (typeof reference === "string") return { arrivalHandle: required(reference, "arrivalHandle") };
|
|
107
|
-
return { arrivalHandle: required(reference.arrivalHandle, "arrivalHandle"), guestCredential: reference.guestCredential };
|
|
108
|
-
}
|
|
109
|
-
function refreshInput(input, arrival) {
|
|
110
|
-
const values = typeof input === "string" ? { arrivalHandle: arrival?.arrivalHandle, guestCredential: arrival?.guestCredential, mediaProof: input } : { arrivalHandle: input.arrivalHandle ?? arrival?.arrivalHandle, guestCredential: input.guestCredential ?? arrival?.guestCredential, mediaProof: input.mediaProof, replaceMediaConnection: input.replaceMediaConnection, signal: input.signal };
|
|
111
|
-
return {
|
|
112
|
-
...values,
|
|
113
|
-
arrivalHandle: required(values.arrivalHandle ?? "", "arrivalHandle")
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
function requestInitForLeave(options) {
|
|
117
|
-
if (options?.keepalive === void 0) return void 0;
|
|
118
|
-
return { keepalive: options.keepalive };
|
|
119
|
-
}
|
|
120
|
-
function requestInitFetch(fetchImplementation, requestInit) {
|
|
121
|
-
const implementation = fetchImplementation ?? globalThis.fetch;
|
|
122
|
-
return (input, init) => implementation(input, { ...init, ...requestInit });
|
|
123
|
-
}
|
|
124
|
-
function publicSpaceCreated(value) {
|
|
125
|
-
const { arrival, ...created } = value;
|
|
126
|
-
return { ...created, arrival: publicSpaceArrival(arrival) };
|
|
127
|
-
}
|
|
128
|
-
function publicSpaceArrival(value) {
|
|
129
|
-
const { access, ...arrival } = value;
|
|
130
|
-
if (access === void 0) return arrival;
|
|
131
|
-
return { ...arrival, access: access === null ? null : parseAccessGrant(access) };
|
|
132
|
-
}
|
|
133
|
-
function required(value, name) {
|
|
134
|
-
const normalized = value.trim();
|
|
135
|
-
if (!normalized) throw new TypeError(`${name} is required`);
|
|
136
|
-
return normalized;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export {
|
|
140
|
-
createChalkPublicClient,
|
|
141
|
-
createChalkPublicInviteClient
|
|
142
|
-
};
|