@q9labsai/chalk-react-native 4.1.5 → 4.1.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.
Files changed (35) hide show
  1. package/dist/android.js +12 -2
  2. package/dist/chunk-4L5GXJ36.js +58 -0
  3. package/dist/{chunk-HXYIJ75K.js → chunk-LZ67SXGB.js} +148 -1
  4. package/dist/{chunk-5HETUU73.js → chunk-MMBE2BVK.js} +11 -2
  5. package/dist/client.js +1 -1
  6. package/dist/diagnostics.d.ts +4 -4
  7. package/dist/diagnostics.d.ts.map +1 -1
  8. package/dist/diagnostics.js +7 -7
  9. package/dist/index.d.ts +3 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +12 -2
  12. package/dist/invites.d.ts +6 -1
  13. package/dist/invites.d.ts.map +1 -1
  14. package/dist/invites.js +8 -39
  15. package/dist/ios-pad.js +12 -2
  16. package/dist/ios-phone.js +12 -2
  17. package/dist/ios.js +12 -2
  18. package/dist/macos.js +12 -2
  19. package/dist/space-client/cloudflare-rtk-native.d.ts +3 -0
  20. package/dist/space-client/cloudflare-rtk-native.d.ts.map +1 -0
  21. package/dist/space-client/create-native-space-client.d.ts.map +1 -1
  22. package/dist/utils/build-chalk-invite-link.d.ts +1 -1
  23. package/dist/utils/build-chalk-invite-link.d.ts.map +1 -1
  24. package/package.json +7 -6
  25. package/src/diagnostics.test.ts +3 -3
  26. package/src/diagnostics.ts +8 -8
  27. package/src/index.ts +3 -0
  28. package/src/invites.test.ts +24 -29
  29. package/src/invites.ts +34 -10
  30. package/src/space-client/cloudflare-rtk-native.test.ts +118 -0
  31. package/src/space-client/cloudflare-rtk-native.ts +104 -0
  32. package/src/space-client/create-native-space-client.test.ts +54 -1
  33. package/src/space-client/create-native-space-client.ts +55 -2
  34. package/src/utils/build-chalk-invite-link.test.ts +3 -3
  35. package/src/utils/build-chalk-invite-link.ts +4 -2
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  AsyncStorageV1PendingTargetStore,
3
+ CloudflareRTKClient,
3
4
  CloudflareSFUClient,
4
5
  createChalkChatFileHttpTransport,
5
6
  createChalkWhiteboardV1Client,
@@ -20,8 +21,10 @@ import { RTCPeerConnection, mediaDevices } from "@cloudflare/react-native-webrtc
20
21
  import { AppState } from "react-native";
21
22
 
22
23
  import { authenticatedNativeCredential, bindNativeAuthenticatedTelemetry, createTelemetry, registerNativeJourneyContext, syncTransportCloseDiagnostic, type RtcPeerConnection, type TelemetryJourney } from "../telemetry";
24
+ import { createNativeRealtimeKitClient } from "./cloudflare-rtk-native";
23
25
 
24
26
  type PlatformDependencies = NonNullable<SpaceClientPlatform["dependencies"]>;
27
+ type NativeMediaClient = ReturnType<NonNullable<PlatformDependencies["createMediaClient"]>>;
25
28
  type MediaFactoryInput = Parameters<NonNullable<PlatformDependencies["createMediaClient"]>>[0];
26
29
  type SyncFactoryInput = Parameters<NonNullable<PlatformDependencies["createSyncClient"]>>[0];
27
30
  type ChatFileFactoryInput = Parameters<NonNullable<PlatformDependencies["createChatFileTransport"]>>[0];
@@ -129,9 +132,19 @@ function joinTracePhase(step: NonNullable<PlatformDiagnostic["step"]>): "authent
129
132
  }
130
133
  }
131
134
 
132
- function createMediaClient(apiBaseURL: string, input: MediaFactoryInput, fetch: typeof globalThis.fetch, observePeerConnection: ((peerConnection: RtcPeerConnection) => () => void) | undefined, journey: TelemetryJourney | undefined) {
135
+ function createMediaClient(apiBaseURL: string, input: MediaFactoryInput, fetch: typeof globalThis.fetch, observePeerConnection: ((peerConnection: RtcPeerConnection) => () => void) | undefined, journey: TelemetryJourney | undefined): NativeMediaClient {
133
136
  const { subject } = input.access;
134
- return new CloudflareSFUClient({
137
+ if (input.access.media.provider === "cloudflare_rtk") {
138
+ const client = new CloudflareRTKClient({
139
+ authToken: input.access.media.clientPayload.token,
140
+ participantId: subject.participantId,
141
+ clientFactory: createNativeRealtimeKitClient,
142
+ onError: input.onFailure,
143
+ onScreenEnded: input.onScreenEnded,
144
+ });
145
+ return createRTKConnectionMediaClient(client);
146
+ }
147
+ const client = new CloudflareSFUClient({
135
148
  bootstrap: input.access.media.clientPayload,
136
149
  participantId: subject.participantId,
137
150
  transport: createCloudflareSFUHTTPTransport({
@@ -151,6 +164,46 @@ function createMediaClient(apiBaseURL: string, input: MediaFactoryInput, fetch:
151
164
  onError: input.onFailure,
152
165
  onScreenEnded: input.onScreenEnded,
153
166
  });
167
+ return createSFUConnectionMediaClient(client);
168
+ }
169
+
170
+ function createRTKConnectionMediaClient(client: CloudflareRTKClient): NativeMediaClient {
171
+ return {
172
+ setLocalPublicationTarget: client.setLocalPublicationTarget.bind(client),
173
+ observeLocalPublications: client.observeLocalPublications.bind(client),
174
+ observeRemotePublications: client.observeRemotePublications.bind(client),
175
+ start: client.start.bind(client),
176
+ stop: client.stop.bind(client),
177
+ restart: (input) => {
178
+ if (!("provider" in input) || input.provider !== "cloudflare_rtk") throw new TypeError("The RealtimeKit adapter requires a Cloudflare RealtimeKit access grant");
179
+ return client.restart(input);
180
+ },
181
+ prepareLocalTrack: client.prepareLocalTrack.bind(client),
182
+ clearPreparedLocalTrack: client.clearPreparedLocalTrack.bind(client),
183
+ getSnapshot: client.getSnapshot.bind(client),
184
+ subscribe: client.subscribe.bind(client),
185
+ };
186
+ }
187
+
188
+ function createSFUConnectionMediaClient(client: CloudflareSFUClient): NativeMediaClient {
189
+ return {
190
+ setLocalPublicationTarget: client.setLocalPublicationTarget.bind(client),
191
+ observeLocalPublications: client.observeLocalPublications.bind(client),
192
+ observeRemotePublications: client.observeRemotePublications.bind(client),
193
+ start: client.start.bind(client),
194
+ stop: client.stop.bind(client),
195
+ restart: (input) => {
196
+ if ("provider" in input) {
197
+ if (input.provider !== "cloudflare_sfu") throw new TypeError("The Cloudflare SFU adapter requires a Cloudflare SFU access grant");
198
+ return client.restart(input.clientPayload);
199
+ }
200
+ return client.restart(input);
201
+ },
202
+ prepareLocalTrack: client.prepareLocalTrack.bind(client),
203
+ clearPreparedLocalTrack: client.clearPreparedLocalTrack.bind(client),
204
+ getSnapshot: client.getSnapshot.bind(client),
205
+ subscribe: client.subscribe.bind(client),
206
+ };
154
207
  }
155
208
 
156
209
  function createSyncClient(syncURL: string, input: SyncFactoryInput, lifecycle: ReturnType<typeof createReactNativeSyncLifecycle>, webSocket: ReturnType<typeof createReactNativeWebSocketFactory>, storage: ReactNativeAsyncStorage | undefined) {
@@ -2,11 +2,11 @@ import { describe, expect, it } from "vitest";
2
2
  import { buildChalkInviteLink } from "./build-chalk-invite-link";
3
3
 
4
4
  describe("buildChalkInviteLink", () => {
5
- it("builds a Chalk invite link with the public host", () => {
6
- expect(buildChalkInviteLink("join-token-123")).toBe("https://chalkmeet.com/j/join-token-123");
5
+ it("builds a canonical Space invite link with the public host", () => {
6
+ expect(buildChalkInviteLink("design-lab", "cspi1.key.payload.signature")).toBe("https://chalkmeet.com/space/design-lab#spaceInviteToken=cspi1.key.payload.signature");
7
7
  });
8
8
 
9
9
  it("normalizes trailing slashes on custom origins", () => {
10
- expect(buildChalkInviteLink("join-token-123", "https://chalk.q9labs.ai/")).toBe("https://chalk.q9labs.ai/j/join-token-123");
10
+ expect(buildChalkInviteLink("design-lab", "cspi1.key.payload.signature", "https://chalk.q9labs.ai/")).toBe("https://chalk.q9labs.ai/space/design-lab#spaceInviteToken=cspi1.key.payload.signature");
11
11
  });
12
12
  });
@@ -1,5 +1,7 @@
1
1
  const PUBLIC_INVITE_ORIGIN = "https://chalkmeet.com";
2
2
 
3
- export function buildChalkInviteLink(joinToken: string, origin = PUBLIC_INVITE_ORIGIN): string {
4
- return `${origin.replace(/\/+$/, "")}/j/${joinToken}`;
3
+ export function buildChalkInviteLink(spaceSlug: string, spaceInviteToken: string, origin = PUBLIC_INVITE_ORIGIN): string {
4
+ const link = new URL(`/space/${encodeURIComponent(spaceSlug)}`, origin.replace(/\/+$/u, ""));
5
+ link.hash = new URLSearchParams({ spaceInviteToken }).toString();
6
+ return link.toString();
5
7
  }