@ai-matrx/meet 0.7.85 → 0.8.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/dist/react.cjs CHANGED
@@ -280,19 +280,8 @@ __export(react_exports, {
280
280
  });
281
281
  module.exports = __toCommonJS(react_exports);
282
282
 
283
- // src/core/slot.ts
284
- var NAMESPACE = "ai-matrx.meet";
285
- function globalSlot(name, create) {
286
- const key = /* @__PURE__ */ Symbol.for(`${NAMESPACE}.${name}`);
287
- const host = globalThis;
288
- const existing = host[key];
289
- if (existing !== void 0) return existing;
290
- const created = create();
291
- host[key] = created;
292
- return created;
293
- }
294
-
295
283
  // src/react/provider.tsx
284
+ var import_global_slot2 = require("@ai-matrx/kit/global-slot");
296
285
  var import_react = require("react");
297
286
  var import_react2 = require("@ai-matrx/realtime/react");
298
287
 
@@ -1179,8 +1168,9 @@ function fileDownloadPath(fileId) {
1179
1168
 
1180
1169
  // src/core/channels.ts
1181
1170
  var import_realtime = require("@ai-matrx/realtime");
1171
+ var import_global_slot = require("@ai-matrx/kit/global-slot");
1182
1172
  function namespaces() {
1183
- return globalSlot("channel-namespaces", () => ({
1173
+ return (0, import_global_slot.globalSlot)("ai-matrx.meet.channel-namespaces", () => ({
1184
1174
  user: (0, import_realtime.defineChannelNamespace)({
1185
1175
  namespace: "meet-user",
1186
1176
  parts: ["userId"],
@@ -3763,87 +3753,20 @@ function snippetRuns(snippet) {
3763
3753
  }
3764
3754
 
3765
3755
  // src/core/session-identity.ts
3766
- var RESOLVING = Object.freeze({
3767
- state: "resolving",
3768
- userId: null
3769
- });
3770
- var SERVER_SESSION_IDENTITY = RESOLVING;
3771
- function authOf(client) {
3772
- const candidate = client.auth;
3773
- if (candidate === null || typeof candidate !== "object") return null;
3774
- const auth = candidate;
3775
- if (typeof auth.getSession !== "function") return null;
3776
- if (typeof auth.onAuthStateChange !== "function") return null;
3777
- return auth;
3778
- }
3779
- function userIdOf(session) {
3780
- const id = session?.user?.id;
3781
- return typeof id === "string" && id.length > 0 ? asUserId(id) : null;
3782
- }
3783
- function createSessionIdentity(options) {
3784
- const { client, onDiagnostic } = options;
3785
- const listeners = /* @__PURE__ */ new Set();
3786
- let current = RESOLVING;
3787
- let disposed = false;
3788
- const publish = (state, userId) => {
3789
- if (disposed) return;
3790
- if (current.state === state && current.userId === userId) return;
3791
- current = Object.freeze({ state, userId });
3792
- for (const listener of [...listeners]) listener();
3793
- };
3794
- const auth = authOf(client);
3795
- if (auth === null) {
3796
- onDiagnostic?.({
3797
- level: "error",
3798
- message: "Meet cannot tell who is signed in: the Supabase client it was given has no auth session source.",
3799
- remedy: "Pass your app's browser Supabase client to <MeetProvider client={...}> \u2014 the same client it signs in with. Meet reads the acting user from that client's session; there is no prop for a user id, on purpose."
3800
- });
3801
- current = Object.freeze({ state: "resolved", userId: null });
3802
- return {
3803
- snapshot: () => current,
3804
- subscribe: (listener) => {
3805
- listeners.add(listener);
3806
- return () => listeners.delete(listener);
3807
- },
3808
- dispose: () => {
3809
- disposed = true;
3810
- listeners.clear();
3811
- }
3812
- };
3813
- }
3814
- void (async () => {
3815
- try {
3816
- const result = await auth.getSession();
3817
- publish("resolved", userIdOf(result?.data?.session));
3818
- } catch (error) {
3819
- onDiagnostic?.({
3820
- level: "warn",
3821
- message: `Meet could not read the signed-in session: ${String(
3822
- error?.message ?? error
3823
- )}`,
3824
- remedy: "Calls and meetings stay unavailable on this device until the session can be read. Reload the page; if it persists, sign in again."
3825
- });
3826
- publish("resolved", null);
3827
- }
3828
- })();
3829
- const subscription = auth.onAuthStateChange((_event, session) => {
3830
- publish("resolved", userIdOf(session));
3756
+ var import_session_identity = require("@ai-matrx/data/session-identity");
3757
+ var import_session_identity2 = require("@ai-matrx/data/session-identity");
3758
+ var MEET_SESSION_WORDS = {
3759
+ product: "Meet",
3760
+ noAuthSourceRemedy: "Pass your app's browser Supabase client to <MeetProvider client={...}> \u2014 the same client it signs in with. Meet reads the acting user from that client's session; there is no prop for a user id, on purpose.",
3761
+ unreadableRemedy: "Calls and meetings stay unavailable on this device until the session can be read. Reload the page; if it persists, sign in again."
3762
+ };
3763
+ function createMeetSessionIdentity(options) {
3764
+ return (0, import_session_identity.createSessionIdentity)({
3765
+ client: options.client,
3766
+ words: MEET_SESSION_WORDS,
3767
+ toUserId: asUserId,
3768
+ onDiagnostic: options.onDiagnostic
3831
3769
  });
3832
- return {
3833
- snapshot: () => current,
3834
- subscribe: (listener) => {
3835
- listeners.add(listener);
3836
- return () => listeners.delete(listener);
3837
- },
3838
- dispose: () => {
3839
- disposed = true;
3840
- listeners.clear();
3841
- try {
3842
- subscription.data.subscription.unsubscribe();
3843
- } catch {
3844
- }
3845
- }
3846
- };
3847
3770
  }
3848
3771
 
3849
3772
  // src/core/room-events.ts
@@ -5487,7 +5410,7 @@ async function createCameraPreview(deviceId2, effect) {
5487
5410
 
5488
5411
  // src/react/provider.tsx
5489
5412
  var import_jsx_runtime = require("react/jsx-runtime");
5490
- var MeetContext = globalSlot("react.context", () => (0, import_react.createContext)(null));
5413
+ var MeetContext = (0, import_global_slot2.globalSlot)("ai-matrx.meet.react.context", () => (0, import_react.createContext)(null));
5491
5414
  function defaultDiagnostics(event) {
5492
5415
  const line = `[@ai-matrx/meet] ${event.message}${event.remedy !== void 0 ? `
5493
5416
  \u2192 ${event.remedy}` : ""}`;
@@ -5509,13 +5432,13 @@ function deviceId() {
5509
5432
  }
5510
5433
  }
5511
5434
  function useSessionIdentity(client, report) {
5512
- const [snapshot, setSnapshot] = (0, import_react.useState)(SERVER_SESSION_IDENTITY);
5435
+ const [snapshot, setSnapshot] = (0, import_react.useState)(import_session_identity2.SERVER_SESSION_IDENTITY);
5513
5436
  (0, import_react.useEffect)(() => {
5514
5437
  if (client == null) {
5515
- setSnapshot(SERVER_SESSION_IDENTITY);
5438
+ setSnapshot(import_session_identity2.SERVER_SESSION_IDENTITY);
5516
5439
  return void 0;
5517
5440
  }
5518
- const identity = createSessionIdentity({ client, onDiagnostic: report });
5441
+ const identity = createMeetSessionIdentity({ client, onDiagnostic: report });
5519
5442
  setSnapshot(identity.snapshot());
5520
5443
  const unsubscribe = identity.subscribe(() => setSnapshot(identity.snapshot()));
5521
5444
  return () => {