@ai-matrx/messaging 0.16.1 → 0.17.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/CHANGELOG.md +16 -0
- package/dist/index.cjs +24 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -30
- package/dist/index.d.ts +8 -30
- package/dist/index.js +28 -105
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +30 -112
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +8 -30
- package/dist/react.d.ts +8 -30
- package/dist/react.js +32 -108
- package/dist/react.js.map +1 -1
- package/package.json +17 -2
package/dist/react.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ReactNode, ComponentType, KeyboardEvent, SVGProps } from 'react';
|
|
2
2
|
import { MatrxJsonObject, MatrxTransport } from '@ai-matrx/agents/matrx';
|
|
3
3
|
import { RealtimeClientLike, RealtimeManager } from '@ai-matrx/realtime';
|
|
4
|
+
import { SessionIdentity as SessionIdentity$1, SessionIdentitySnapshot as SessionIdentitySnapshot$1, SessionIdentityDiagnostic } from '@ai-matrx/data/session-identity';
|
|
5
|
+
export { SERVER_SESSION_IDENTITY } from '@ai-matrx/data/session-identity';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* THE MESSAGING DOMAIN TYPES.
|
|
@@ -755,38 +757,14 @@ type MessagingSupabaseInternal = SupabaseLike & RealtimeClientLike;
|
|
|
755
757
|
* proven at compile time in `supabase-shape.test.ts`.
|
|
756
758
|
*/
|
|
757
759
|
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
* `resolving` until the first `getSession()` answers. A user-scoped read or
|
|
761
|
-
* write issued in this window would name a guess.
|
|
762
|
-
*/
|
|
763
|
-
readonly state: "resolving" | "resolved";
|
|
764
|
-
/** Who the session says is acting, or `null` for nobody. */
|
|
765
|
-
readonly userId: UserId | null;
|
|
766
|
-
}
|
|
767
|
-
interface SessionIdentity {
|
|
768
|
-
/**
|
|
769
|
-
* False when the client handed to us has no auth source at all — a
|
|
770
|
-
* misconfiguration, not "nobody is signed in", and the two get different
|
|
771
|
-
* sentences.
|
|
772
|
-
*/
|
|
773
|
-
readonly hasAuthSource: boolean;
|
|
774
|
-
/** Stable reference until the acting user actually changes. */
|
|
775
|
-
snapshot(): SessionIdentitySnapshot;
|
|
776
|
-
subscribe(listener: () => void): () => void;
|
|
777
|
-
dispose(): void;
|
|
778
|
-
}
|
|
760
|
+
type SessionIdentitySnapshot = SessionIdentitySnapshot$1<UserId>;
|
|
761
|
+
type SessionIdentity = SessionIdentity$1<UserId>;
|
|
779
762
|
interface SessionIdentityOptions {
|
|
780
763
|
readonly client: MessagingSupabaseClient;
|
|
781
|
-
readonly onDiagnostic?: ((event:
|
|
782
|
-
level: "info" | "warn" | "error";
|
|
783
|
-
message: string;
|
|
784
|
-
remedy?: string | undefined;
|
|
785
|
-
}) => void) | undefined;
|
|
764
|
+
readonly onDiagnostic?: ((event: SessionIdentityDiagnostic) => void) | undefined;
|
|
786
765
|
}
|
|
787
|
-
/** The
|
|
788
|
-
declare
|
|
789
|
-
declare function createSessionIdentity(options: SessionIdentityOptions): SessionIdentity;
|
|
766
|
+
/** The acting user of `client`'s session, in messaging's words (public as `createSessionIdentity`). */
|
|
767
|
+
declare function createMessagingSessionIdentity(options: SessionIdentityOptions): SessionIdentity;
|
|
790
768
|
|
|
791
769
|
/**
|
|
792
770
|
* THE DATA CONTRACT — the ONE place a messaging table or RPC name exists.
|
|
@@ -1990,4 +1968,4 @@ declare function summarizeText(content: string, maxLength?: number): string;
|
|
|
1990
1968
|
/** Serialize picked references into a fence the platform's other readers accept. */
|
|
1991
1969
|
declare function composeFence(references: readonly MatrxReference[]): string;
|
|
1992
1970
|
|
|
1993
|
-
export { type ActionChoice, type ActionContext, type ActionHandler, type ActionOutcome, type ActionReceipt, type ActionRegistry, type ActorPresentation, AgentTag, type AiCallArgs, type AiCapability, type AiResult, AlertIcon, type Attachment, Avatar, BotIcon, CheckIcon, ChevronLeftIcon, type ClientMessageId, ClockIcon, CloseIcon, Composer, type ComposerAttachment, type ComposerInputRenderProps, type Conversation, type ConversationAiContext, type ConversationCursor, type ConversationId, ConversationList, type ConversationListProps, type ConversationReadCutoff, type ConversationReadFailure, type ConversationRowWrapperProps, ConversationSkeleton, type ConversationSummary, type ConversationThread, type ConversationType, ConversationView, type ConversationViewProps, DEFAULT_MESSAGING_ARCHIVE_FILTER, type DeliveryState, DeliveryTick, DoubleCheckIcon, type DraftMessage, EmptyState, type EngineDiagnostic, type IncomingMessageContext, type JsonObject, type JsonValue, LinkIcon, MESSAGING_EVENTS, MESSAGING_RPC_SCHEMA, MESSAGING_SCHEMA, type MatrxReference, type Message, type MessageAction, MessageActionChips, type MessageActionRenderProps, type MessageActionRenderer, MessageBubble, type MessageCursor, type MessageGroup, type MessageId, type MessageKind, type MessageWrapperProps, type MessagingAgentIdentity, type MessagingAgents, type MessagingAi, type MessagingAiOptions, type MessagingArchiveFilter, type MessagingEngine, type MessagingEngineOptions, MessagingError, type MessagingErrorCode, type MessagingHost, type MessagingIdentity, MessagingInbox, type MessagingInboxProps, MessagingProvider, type MessagingProviderProps, type MessagingRepository, type MessagingSnapshot, type MessagingStore, type MessagingSupabaseClient, type MessagingSupabaseInternal, type OrganizationId, type Outbox, type OutboxEntry, type OutboxOptions, type OutboxStorage, type Page, PaperclipIcon, type Participant, type ParticipantRole, type PendingSoftExpiries, PlusIcon, type PostgrestFilterLike, type PostgrestLikeResponse, type PostgrestTableLike, RPCS, type ReadCache, type ReadCacheOptions, ReferenceCard, type ReferenceRenderer, ReplyIcon, type RepositoryOptions,
|
|
1971
|
+
export { type ActionChoice, type ActionContext, type ActionHandler, type ActionOutcome, type ActionReceipt, type ActionRegistry, type ActorPresentation, AgentTag, type AiCallArgs, type AiCapability, type AiResult, AlertIcon, type Attachment, Avatar, BotIcon, CheckIcon, ChevronLeftIcon, type ClientMessageId, ClockIcon, CloseIcon, Composer, type ComposerAttachment, type ComposerInputRenderProps, type Conversation, type ConversationAiContext, type ConversationCursor, type ConversationId, ConversationList, type ConversationListProps, type ConversationReadCutoff, type ConversationReadFailure, type ConversationRowWrapperProps, ConversationSkeleton, type ConversationSummary, type ConversationThread, type ConversationType, ConversationView, type ConversationViewProps, DEFAULT_MESSAGING_ARCHIVE_FILTER, type DeliveryState, DeliveryTick, DoubleCheckIcon, type DraftMessage, EmptyState, type EngineDiagnostic, type IncomingMessageContext, type JsonObject, type JsonValue, LinkIcon, MESSAGING_EVENTS, MESSAGING_RPC_SCHEMA, MESSAGING_SCHEMA, type MatrxReference, type Message, type MessageAction, MessageActionChips, type MessageActionRenderProps, type MessageActionRenderer, MessageBubble, type MessageCursor, type MessageGroup, type MessageId, type MessageKind, type MessageWrapperProps, type MessagingAgentIdentity, type MessagingAgents, type MessagingAi, type MessagingAiOptions, type MessagingArchiveFilter, type MessagingEngine, type MessagingEngineOptions, MessagingError, type MessagingErrorCode, type MessagingHost, type MessagingIdentity, MessagingInbox, type MessagingInboxProps, MessagingProvider, type MessagingProviderProps, type MessagingRepository, type MessagingSnapshot, type MessagingStore, type MessagingSupabaseClient, type MessagingSupabaseInternal, type OrganizationId, type Outbox, type OutboxEntry, type OutboxOptions, type OutboxStorage, type Page, PaperclipIcon, type Participant, type ParticipantRole, type PendingSoftExpiries, PlusIcon, type PostgrestFilterLike, type PostgrestLikeResponse, type PostgrestTableLike, RPCS, type ReadCache, type ReadCacheOptions, ReferenceCard, type ReferenceRenderer, ReplyIcon, type RepositoryOptions, type SchemaLike, SearchIcon, SendIcon, type SessionIdentity, type SessionIdentitySnapshot, type SessionResolver, SparklesIcon, type SupabaseLike, TABLES, type TextSegment, TypingDots, type UseComposerResult, type UseConversationResult, type UseConversationsResult, type UseMessageActionResult, type UseMessagingAiResult, type UseTypistsResult, type UserId, type UserSummary, UsersIcon, asClientMessageId, asConversationId, asMessageId, asOrganizationId, asUserId, composeFence, conversationContextVariables, conversationTopic, createActionRegistry, createMemoryOutboxStorage, createMessagingAi, createMessagingEngine, createMessagingRepository, createMessagingStore, createOutbox, createReadCache, createMessagingSessionIdentity as createSessionIdentity, createWebOutboxStorage, effectiveActorKey, extractReferences, formatConversationTime, formatDateSeparator, formatLastSeen, formatMessageTime, formatTypists, groupMessages, inboxTopic, invalidResponse, isLapsed, isSameDay, messagingClientId, normalizeMessagingError, optimisticMessage, participantNames, projectConversationSummary, projectMessage, projectMessageAction, projectParticipantRole, projectUserSummary, resolveActor, softExpiryTime, splitText, summarizeText, toMessagingArchiveFilter, unreadCutoff, useComposer, useConversation, useConversations, useMessageAction, useMessagingAi, useMessagingHost, useMessagingSnapshot, useOnlineUserIds, useRequiredMessagingHost, useTypists, writeNotApplied };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ReactNode, ComponentType, KeyboardEvent, SVGProps } from 'react';
|
|
2
2
|
import { MatrxJsonObject, MatrxTransport } from '@ai-matrx/agents/matrx';
|
|
3
3
|
import { RealtimeClientLike, RealtimeManager } from '@ai-matrx/realtime';
|
|
4
|
+
import { SessionIdentity as SessionIdentity$1, SessionIdentitySnapshot as SessionIdentitySnapshot$1, SessionIdentityDiagnostic } from '@ai-matrx/data/session-identity';
|
|
5
|
+
export { SERVER_SESSION_IDENTITY } from '@ai-matrx/data/session-identity';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* THE MESSAGING DOMAIN TYPES.
|
|
@@ -755,38 +757,14 @@ type MessagingSupabaseInternal = SupabaseLike & RealtimeClientLike;
|
|
|
755
757
|
* proven at compile time in `supabase-shape.test.ts`.
|
|
756
758
|
*/
|
|
757
759
|
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
* `resolving` until the first `getSession()` answers. A user-scoped read or
|
|
761
|
-
* write issued in this window would name a guess.
|
|
762
|
-
*/
|
|
763
|
-
readonly state: "resolving" | "resolved";
|
|
764
|
-
/** Who the session says is acting, or `null` for nobody. */
|
|
765
|
-
readonly userId: UserId | null;
|
|
766
|
-
}
|
|
767
|
-
interface SessionIdentity {
|
|
768
|
-
/**
|
|
769
|
-
* False when the client handed to us has no auth source at all — a
|
|
770
|
-
* misconfiguration, not "nobody is signed in", and the two get different
|
|
771
|
-
* sentences.
|
|
772
|
-
*/
|
|
773
|
-
readonly hasAuthSource: boolean;
|
|
774
|
-
/** Stable reference until the acting user actually changes. */
|
|
775
|
-
snapshot(): SessionIdentitySnapshot;
|
|
776
|
-
subscribe(listener: () => void): () => void;
|
|
777
|
-
dispose(): void;
|
|
778
|
-
}
|
|
760
|
+
type SessionIdentitySnapshot = SessionIdentitySnapshot$1<UserId>;
|
|
761
|
+
type SessionIdentity = SessionIdentity$1<UserId>;
|
|
779
762
|
interface SessionIdentityOptions {
|
|
780
763
|
readonly client: MessagingSupabaseClient;
|
|
781
|
-
readonly onDiagnostic?: ((event:
|
|
782
|
-
level: "info" | "warn" | "error";
|
|
783
|
-
message: string;
|
|
784
|
-
remedy?: string | undefined;
|
|
785
|
-
}) => void) | undefined;
|
|
764
|
+
readonly onDiagnostic?: ((event: SessionIdentityDiagnostic) => void) | undefined;
|
|
786
765
|
}
|
|
787
|
-
/** The
|
|
788
|
-
declare
|
|
789
|
-
declare function createSessionIdentity(options: SessionIdentityOptions): SessionIdentity;
|
|
766
|
+
/** The acting user of `client`'s session, in messaging's words (public as `createSessionIdentity`). */
|
|
767
|
+
declare function createMessagingSessionIdentity(options: SessionIdentityOptions): SessionIdentity;
|
|
790
768
|
|
|
791
769
|
/**
|
|
792
770
|
* THE DATA CONTRACT — the ONE place a messaging table or RPC name exists.
|
|
@@ -1990,4 +1968,4 @@ declare function summarizeText(content: string, maxLength?: number): string;
|
|
|
1990
1968
|
/** Serialize picked references into a fence the platform's other readers accept. */
|
|
1991
1969
|
declare function composeFence(references: readonly MatrxReference[]): string;
|
|
1992
1970
|
|
|
1993
|
-
export { type ActionChoice, type ActionContext, type ActionHandler, type ActionOutcome, type ActionReceipt, type ActionRegistry, type ActorPresentation, AgentTag, type AiCallArgs, type AiCapability, type AiResult, AlertIcon, type Attachment, Avatar, BotIcon, CheckIcon, ChevronLeftIcon, type ClientMessageId, ClockIcon, CloseIcon, Composer, type ComposerAttachment, type ComposerInputRenderProps, type Conversation, type ConversationAiContext, type ConversationCursor, type ConversationId, ConversationList, type ConversationListProps, type ConversationReadCutoff, type ConversationReadFailure, type ConversationRowWrapperProps, ConversationSkeleton, type ConversationSummary, type ConversationThread, type ConversationType, ConversationView, type ConversationViewProps, DEFAULT_MESSAGING_ARCHIVE_FILTER, type DeliveryState, DeliveryTick, DoubleCheckIcon, type DraftMessage, EmptyState, type EngineDiagnostic, type IncomingMessageContext, type JsonObject, type JsonValue, LinkIcon, MESSAGING_EVENTS, MESSAGING_RPC_SCHEMA, MESSAGING_SCHEMA, type MatrxReference, type Message, type MessageAction, MessageActionChips, type MessageActionRenderProps, type MessageActionRenderer, MessageBubble, type MessageCursor, type MessageGroup, type MessageId, type MessageKind, type MessageWrapperProps, type MessagingAgentIdentity, type MessagingAgents, type MessagingAi, type MessagingAiOptions, type MessagingArchiveFilter, type MessagingEngine, type MessagingEngineOptions, MessagingError, type MessagingErrorCode, type MessagingHost, type MessagingIdentity, MessagingInbox, type MessagingInboxProps, MessagingProvider, type MessagingProviderProps, type MessagingRepository, type MessagingSnapshot, type MessagingStore, type MessagingSupabaseClient, type MessagingSupabaseInternal, type OrganizationId, type Outbox, type OutboxEntry, type OutboxOptions, type OutboxStorage, type Page, PaperclipIcon, type Participant, type ParticipantRole, type PendingSoftExpiries, PlusIcon, type PostgrestFilterLike, type PostgrestLikeResponse, type PostgrestTableLike, RPCS, type ReadCache, type ReadCacheOptions, ReferenceCard, type ReferenceRenderer, ReplyIcon, type RepositoryOptions,
|
|
1971
|
+
export { type ActionChoice, type ActionContext, type ActionHandler, type ActionOutcome, type ActionReceipt, type ActionRegistry, type ActorPresentation, AgentTag, type AiCallArgs, type AiCapability, type AiResult, AlertIcon, type Attachment, Avatar, BotIcon, CheckIcon, ChevronLeftIcon, type ClientMessageId, ClockIcon, CloseIcon, Composer, type ComposerAttachment, type ComposerInputRenderProps, type Conversation, type ConversationAiContext, type ConversationCursor, type ConversationId, ConversationList, type ConversationListProps, type ConversationReadCutoff, type ConversationReadFailure, type ConversationRowWrapperProps, ConversationSkeleton, type ConversationSummary, type ConversationThread, type ConversationType, ConversationView, type ConversationViewProps, DEFAULT_MESSAGING_ARCHIVE_FILTER, type DeliveryState, DeliveryTick, DoubleCheckIcon, type DraftMessage, EmptyState, type EngineDiagnostic, type IncomingMessageContext, type JsonObject, type JsonValue, LinkIcon, MESSAGING_EVENTS, MESSAGING_RPC_SCHEMA, MESSAGING_SCHEMA, type MatrxReference, type Message, type MessageAction, MessageActionChips, type MessageActionRenderProps, type MessageActionRenderer, MessageBubble, type MessageCursor, type MessageGroup, type MessageId, type MessageKind, type MessageWrapperProps, type MessagingAgentIdentity, type MessagingAgents, type MessagingAi, type MessagingAiOptions, type MessagingArchiveFilter, type MessagingEngine, type MessagingEngineOptions, MessagingError, type MessagingErrorCode, type MessagingHost, type MessagingIdentity, MessagingInbox, type MessagingInboxProps, MessagingProvider, type MessagingProviderProps, type MessagingRepository, type MessagingSnapshot, type MessagingStore, type MessagingSupabaseClient, type MessagingSupabaseInternal, type OrganizationId, type Outbox, type OutboxEntry, type OutboxOptions, type OutboxStorage, type Page, PaperclipIcon, type Participant, type ParticipantRole, type PendingSoftExpiries, PlusIcon, type PostgrestFilterLike, type PostgrestLikeResponse, type PostgrestTableLike, RPCS, type ReadCache, type ReadCacheOptions, ReferenceCard, type ReferenceRenderer, ReplyIcon, type RepositoryOptions, type SchemaLike, SearchIcon, SendIcon, type SessionIdentity, type SessionIdentitySnapshot, type SessionResolver, SparklesIcon, type SupabaseLike, TABLES, type TextSegment, TypingDots, type UseComposerResult, type UseConversationResult, type UseConversationsResult, type UseMessageActionResult, type UseMessagingAiResult, type UseTypistsResult, type UserId, type UserSummary, UsersIcon, asClientMessageId, asConversationId, asMessageId, asOrganizationId, asUserId, composeFence, conversationContextVariables, conversationTopic, createActionRegistry, createMemoryOutboxStorage, createMessagingAi, createMessagingEngine, createMessagingRepository, createMessagingStore, createOutbox, createReadCache, createMessagingSessionIdentity as createSessionIdentity, createWebOutboxStorage, effectiveActorKey, extractReferences, formatConversationTime, formatDateSeparator, formatLastSeen, formatMessageTime, formatTypists, groupMessages, inboxTopic, invalidResponse, isLapsed, isSameDay, messagingClientId, normalizeMessagingError, optimisticMessage, participantNames, projectConversationSummary, projectMessage, projectMessageAction, projectParticipantRole, projectUserSummary, resolveActor, softExpiryTime, splitText, summarizeText, toMessagingArchiveFilter, unreadCutoff, useComposer, useConversation, useConversations, useMessageAction, useMessagingAi, useMessagingHost, useMessagingSnapshot, useOnlineUserIds, useRequiredMessagingHost, useTypists, writeNotApplied };
|
package/dist/react.js
CHANGED
|
@@ -415,22 +415,9 @@ import {
|
|
|
415
415
|
|
|
416
416
|
// src/core/channels.ts
|
|
417
417
|
import { defineChannelNamespace } from "@ai-matrx/realtime";
|
|
418
|
-
|
|
419
|
-
// src/core/slot.ts
|
|
420
|
-
var NAMESPACE = "ai-matrx.messaging";
|
|
421
|
-
function globalSlot(name, create) {
|
|
422
|
-
const key = /* @__PURE__ */ Symbol.for(`${NAMESPACE}.${name}`);
|
|
423
|
-
const host = globalThis;
|
|
424
|
-
const existing = host[key];
|
|
425
|
-
if (existing !== void 0) return existing;
|
|
426
|
-
const created = create();
|
|
427
|
-
host[key] = created;
|
|
428
|
-
return created;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
// src/core/channels.ts
|
|
418
|
+
import { globalSlot } from "@ai-matrx/kit/global-slot";
|
|
432
419
|
function namespaces() {
|
|
433
|
-
return globalSlot("channel-namespaces", () => ({
|
|
420
|
+
return globalSlot("ai-matrx.messaging.channel-namespaces", () => ({
|
|
434
421
|
inbox: defineChannelNamespace({
|
|
435
422
|
namespace: "messaging-inbox",
|
|
436
423
|
parts: ["userId"],
|
|
@@ -1879,89 +1866,30 @@ function createReadCache(options) {
|
|
|
1879
1866
|
}
|
|
1880
1867
|
|
|
1881
1868
|
// src/core/session-identity.ts
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
}
|
|
1895
|
-
function userIdOf(session) {
|
|
1896
|
-
const id = session?.user?.id;
|
|
1897
|
-
return typeof id === "string" && id.length > 0 ? asUserId(id) : null;
|
|
1898
|
-
}
|
|
1899
|
-
var NO_AUTH_SOURCE = {
|
|
1900
|
-
message: "Messaging cannot tell who is signed in: the Supabase client it was given has no auth session source.",
|
|
1901
|
-
remedy: "Pass your app's browser Supabase client \u2014 the same client it signs in with \u2014 to <MessagingProvider client={...}> or createMessagingRepository({ client }). Messaging reads the acting user from that client's session; there is no prop or option for a user id, on purpose (DD-241)."
|
|
1869
|
+
import {
|
|
1870
|
+
authOf,
|
|
1871
|
+
createSessionIdentity as createDataSessionIdentity,
|
|
1872
|
+
noAuthSourceMessage,
|
|
1873
|
+
sessionUserId,
|
|
1874
|
+
unreadableSessionMessage
|
|
1875
|
+
} from "@ai-matrx/data/session-identity";
|
|
1876
|
+
import { authOf as authOf2, SERVER_SESSION_IDENTITY } from "@ai-matrx/data/session-identity";
|
|
1877
|
+
var MESSAGING_SESSION_WORDS = {
|
|
1878
|
+
product: "Messaging",
|
|
1879
|
+
noAuthSourceRemedy: "Pass your app's browser Supabase client \u2014 the same client it signs in with \u2014 to <MessagingProvider client={...}> or createMessagingRepository({ client }). Messaging reads the acting user from that client's session; there is no prop or option for a user id, on purpose (DD-241).",
|
|
1880
|
+
unreadableRemedy: "Messages stay unavailable on this device until the session can be read. Reload the page; if it persists, sign in again."
|
|
1902
1881
|
};
|
|
1903
|
-
function
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
if (disposed) return;
|
|
1910
|
-
if (current.state === state && current.userId === userId) return;
|
|
1911
|
-
current = Object.freeze({ state, userId });
|
|
1912
|
-
for (const listener of [...listeners]) listener();
|
|
1913
|
-
};
|
|
1914
|
-
const subscribeOnly = (hasAuthSource) => ({
|
|
1915
|
-
hasAuthSource,
|
|
1916
|
-
snapshot: () => current,
|
|
1917
|
-
subscribe: (listener) => {
|
|
1918
|
-
listeners.add(listener);
|
|
1919
|
-
return () => {
|
|
1920
|
-
listeners.delete(listener);
|
|
1921
|
-
};
|
|
1922
|
-
},
|
|
1923
|
-
dispose: () => {
|
|
1924
|
-
disposed = true;
|
|
1925
|
-
listeners.clear();
|
|
1926
|
-
}
|
|
1927
|
-
});
|
|
1928
|
-
const auth = authOf(client);
|
|
1929
|
-
if (auth === null) {
|
|
1930
|
-
onDiagnostic?.({ level: "error", ...NO_AUTH_SOURCE });
|
|
1931
|
-
current = Object.freeze({ state: "resolved", userId: null });
|
|
1932
|
-
return subscribeOnly(false);
|
|
1933
|
-
}
|
|
1934
|
-
void (async () => {
|
|
1935
|
-
try {
|
|
1936
|
-
const result = await auth.getSession();
|
|
1937
|
-
publish("resolved", userIdOf(result?.data?.session));
|
|
1938
|
-
} catch (error) {
|
|
1939
|
-
onDiagnostic?.({
|
|
1940
|
-
level: "warn",
|
|
1941
|
-
message: `Messaging could not read the signed-in session: ${String(
|
|
1942
|
-
error?.message ?? error
|
|
1943
|
-
)}`,
|
|
1944
|
-
remedy: "Messages stay unavailable on this device until the session can be read. Reload the page; if it persists, sign in again."
|
|
1945
|
-
});
|
|
1946
|
-
publish("resolved", null);
|
|
1947
|
-
}
|
|
1948
|
-
})();
|
|
1949
|
-
const subscription = auth.onAuthStateChange((_event, session) => {
|
|
1950
|
-
publish("resolved", userIdOf(session));
|
|
1882
|
+
function createMessagingSessionIdentity(options) {
|
|
1883
|
+
return createDataSessionIdentity({
|
|
1884
|
+
client: options.client,
|
|
1885
|
+
words: MESSAGING_SESSION_WORDS,
|
|
1886
|
+
toUserId: asUserId,
|
|
1887
|
+
onDiagnostic: options.onDiagnostic
|
|
1951
1888
|
});
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
subscribe: base.subscribe,
|
|
1957
|
-
dispose: () => {
|
|
1958
|
-
base.dispose();
|
|
1959
|
-
try {
|
|
1960
|
-
subscription.data.subscription.unsubscribe();
|
|
1961
|
-
} catch {
|
|
1962
|
-
}
|
|
1963
|
-
}
|
|
1964
|
-
};
|
|
1889
|
+
}
|
|
1890
|
+
function userIdOf(session) {
|
|
1891
|
+
const id = sessionUserId(session);
|
|
1892
|
+
return id === null ? null : asUserId(id);
|
|
1965
1893
|
}
|
|
1966
1894
|
function actingUserIdOf(identity) {
|
|
1967
1895
|
return new Promise((resolve, reject) => {
|
|
@@ -1989,11 +1917,8 @@ function noSignedInUserError() {
|
|
|
1989
1917
|
);
|
|
1990
1918
|
}
|
|
1991
1919
|
function noAuthSourceError() {
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
NO_AUTH_SOURCE.message,
|
|
1995
|
-
NO_AUTH_SOURCE.remedy
|
|
1996
|
-
);
|
|
1920
|
+
const { message, remedy } = noAuthSourceMessage(MESSAGING_SESSION_WORDS);
|
|
1921
|
+
return new MessagingError("misconfigured", message, remedy);
|
|
1997
1922
|
}
|
|
1998
1923
|
async function readActingUserId(client) {
|
|
1999
1924
|
const auth = authOf(client);
|
|
@@ -2005,9 +1930,7 @@ async function readActingUserId(client) {
|
|
|
2005
1930
|
} catch (error) {
|
|
2006
1931
|
throw new MessagingError(
|
|
2007
1932
|
"session-unavailable",
|
|
2008
|
-
|
|
2009
|
-
error?.message ?? error
|
|
2010
|
-
)}`,
|
|
1933
|
+
unreadableSessionMessage(MESSAGING_SESSION_WORDS, error),
|
|
2011
1934
|
"Reload the page and try again; if it persists, sign in again.",
|
|
2012
1935
|
error
|
|
2013
1936
|
);
|
|
@@ -2640,10 +2563,11 @@ function createMessagingRepository(options) {
|
|
|
2640
2563
|
}
|
|
2641
2564
|
|
|
2642
2565
|
// src/react/provider.tsx
|
|
2566
|
+
import { globalSlot as globalSlot2 } from "@ai-matrx/kit/global-slot";
|
|
2643
2567
|
import { jsx } from "react/jsx-runtime";
|
|
2644
2568
|
function messagingContext() {
|
|
2645
|
-
return
|
|
2646
|
-
"react-context",
|
|
2569
|
+
return globalSlot2(
|
|
2570
|
+
"ai-matrx.messaging.react-context",
|
|
2647
2571
|
() => createContext(null)
|
|
2648
2572
|
);
|
|
2649
2573
|
}
|
|
@@ -2659,7 +2583,7 @@ function useSessionUserId(client, onDiagnostic) {
|
|
|
2659
2583
|
diagnosticRef.current = onDiagnostic;
|
|
2660
2584
|
const identity = useMemo(() => {
|
|
2661
2585
|
if (client == null) return null;
|
|
2662
|
-
return
|
|
2586
|
+
return createMessagingSessionIdentity({
|
|
2663
2587
|
client,
|
|
2664
2588
|
onDiagnostic: (event) => {
|
|
2665
2589
|
(diagnosticRef.current ?? defaultDiagnostics)(event);
|
|
@@ -4549,7 +4473,7 @@ export {
|
|
|
4549
4473
|
createMessagingStore,
|
|
4550
4474
|
createOutbox,
|
|
4551
4475
|
createReadCache,
|
|
4552
|
-
createSessionIdentity,
|
|
4476
|
+
createMessagingSessionIdentity as createSessionIdentity,
|
|
4553
4477
|
createWebOutboxStorage,
|
|
4554
4478
|
effectiveActorKey,
|
|
4555
4479
|
extractReferences,
|