@ttt-productions/chat-react 0.12.11 → 0.12.13
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/context/ChatAttachmentMediaContext.d.ts +22 -9
- package/dist/context/ChatAttachmentMediaContext.d.ts.map +1 -1
- package/dist/context/ChatAttachmentMediaContext.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/realtime/channel-client.d.ts +46 -0
- package/dist/realtime/channel-client.d.ts.map +1 -1
- package/dist/realtime/channel-client.js +294 -21
- package/dist/realtime/channel-client.js.map +1 -1
- package/dist/realtime/diagnostics.d.ts +76 -0
- package/dist/realtime/diagnostics.d.ts.map +1 -0
- package/dist/realtime/diagnostics.js +111 -0
- package/dist/realtime/diagnostics.js.map +1 -0
- package/dist/realtime/index.d.ts +2 -0
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime/index.js +1 -0
- package/dist/realtime/index.js.map +1 -1
- package/dist/realtime/transport.d.ts +9 -0
- package/dist/realtime/transport.d.ts.map +1 -1
- package/dist/realtime/transport.js +1 -0
- package/dist/realtime/transport.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import type { MediaPreviewProps } from "@ttt-productions/media-viewer";
|
|
2
|
+
import type { MediaPreviewProps, MediaViewerType } from "@ttt-productions/media-viewer";
|
|
3
|
+
import type { ChatAttachment } from "@ttt-productions/chat-core";
|
|
3
4
|
/**
|
|
4
|
-
* The
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* MediaPreview props.
|
|
5
|
+
* The media kinds chat actually renders through the injected component. Chat only ever
|
|
6
|
+
* mounts it for image/video/audio attachments; text/markdown render as the package's own
|
|
7
|
+
* download link and never reach this slot. Computed as the intersection of chat-core's
|
|
8
|
+
* `ChatAttachment['type']` and media-viewer's `MediaViewerType`, so it stays in the chat +
|
|
9
|
+
* media-viewer domains with no ttt-core dependency (ARCH-201) and tracks either union
|
|
10
|
+
* automatically if a kind is added or removed.
|
|
11
11
|
*/
|
|
12
|
-
export type
|
|
12
|
+
export type ChatAttachmentMediaKind = Extract<ChatAttachment["type"], MediaViewerType>;
|
|
13
|
+
/**
|
|
14
|
+
* The component chat attachments render their media through. Defaults to the bare
|
|
15
|
+
* media-viewer `MediaViewer` when no provider is present; the consuming app injects its own
|
|
16
|
+
* wrapper (recovery adapter, diagnostics, telemetry — whatever the app's one display path
|
|
17
|
+
* adds) so chat media rides the SAME display pipeline as every other surface. chat-react
|
|
18
|
+
* stays app-agnostic: it renders whatever component it is handed with plain MediaPreview
|
|
19
|
+
* props — except `type`, which is REQUIRED and narrowed to the kind chat provides, so the
|
|
20
|
+
* consuming wrapper never has to narrow an all-optional classification (no dead
|
|
21
|
+
* mime/name/'other' branch).
|
|
22
|
+
*/
|
|
23
|
+
export type ChatAttachmentMediaComponent = React.ComponentType<Omit<MediaPreviewProps, "type"> & {
|
|
24
|
+
type: ChatAttachmentMediaKind;
|
|
25
|
+
}>;
|
|
13
26
|
export type ChatAttachmentMediaProviderProps = {
|
|
14
27
|
mediaComponent: ChatAttachmentMediaComponent;
|
|
15
28
|
children: React.ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatAttachmentMediaContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatAttachmentMediaContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatAttachmentMediaContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatAttachmentMediaContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC;AAEvF;;;;;;;;;GASG;AACH,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAAC,aAAa,CAC5D,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,GAAG;IAAE,IAAI,EAAE,uBAAuB,CAAA;CAAE,CACpE,CAAC;AAIF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,cAAc,EAAE,4BAA4B,CAAC;IAC7C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,gCAAgC,qBAOlF;AAED,sEAAsE;AACtE,wBAAgB,+BAA+B,IAAI,4BAA4B,GAAG,IAAI,CAErF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatAttachmentMediaContext.js","sourceRoot":"","sources":["../../src/context/ChatAttachmentMediaContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatAttachmentMediaContext.js","sourceRoot":"","sources":["../../src/context/ChatAttachmentMediaContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA4B/B,MAAM,0BAA0B,GAAG,KAAK,CAAC,aAAa,CAAsC,IAAI,CAAC,CAAC;AAOlG;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,KAAuC;IACjF,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC3C,OAAO,CACL,KAAC,0BAA0B,CAAC,QAAQ,IAAC,KAAK,EAAE,cAAc,YACvD,QAAQ,GAC2B,CACvC,CAAC;AACJ,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,+BAA+B;IAC7C,OAAO,KAAK,CAAC,UAAU,CAAC,0BAA0B,CAAC,CAAC;AACtD,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport type { MediaPreviewProps, MediaViewerType } from \"@ttt-productions/media-viewer\";\nimport type { ChatAttachment } from \"@ttt-productions/chat-core\";\n\n/**\n * The media kinds chat actually renders through the injected component. Chat only ever\n * mounts it for image/video/audio attachments; text/markdown render as the package's own\n * download link and never reach this slot. Computed as the intersection of chat-core's\n * `ChatAttachment['type']` and media-viewer's `MediaViewerType`, so it stays in the chat +\n * media-viewer domains with no ttt-core dependency (ARCH-201) and tracks either union\n * automatically if a kind is added or removed.\n */\nexport type ChatAttachmentMediaKind = Extract<ChatAttachment[\"type\"], MediaViewerType>;\n\n/**\n * The component chat attachments render their media through. Defaults to the bare\n * media-viewer `MediaViewer` when no provider is present; the consuming app injects its own\n * wrapper (recovery adapter, diagnostics, telemetry — whatever the app's one display path\n * adds) so chat media rides the SAME display pipeline as every other surface. chat-react\n * stays app-agnostic: it renders whatever component it is handed with plain MediaPreview\n * props — except `type`, which is REQUIRED and narrowed to the kind chat provides, so the\n * consuming wrapper never has to narrow an all-optional classification (no dead\n * mime/name/'other' branch).\n */\nexport type ChatAttachmentMediaComponent = React.ComponentType<\n Omit<MediaPreviewProps, \"type\"> & { type: ChatAttachmentMediaKind }\n>;\n\nconst ChatAttachmentMediaContext = React.createContext<ChatAttachmentMediaComponent | null>(null);\n\nexport type ChatAttachmentMediaProviderProps = {\n mediaComponent: ChatAttachmentMediaComponent;\n children: React.ReactNode;\n};\n\n/**\n * Optional (unlike ChatAttachmentUrlProvider, which is required): without it,\n * attachments render through the package's own MediaViewer exactly as before.\n */\nexport function ChatAttachmentMediaProvider(props: ChatAttachmentMediaProviderProps) {\n const { mediaComponent, children } = props;\n return (\n <ChatAttachmentMediaContext.Provider value={mediaComponent}>\n {children}\n </ChatAttachmentMediaContext.Provider>\n );\n}\n\n/** Nullable hook — consumers fall back to the package MediaViewer. */\nexport function useChatAttachmentMediaComponent(): ChatAttachmentMediaComponent | null {\n return React.useContext(ChatAttachmentMediaContext);\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export { ChatNameResolverProvider, useChatNameResolver, useOptionalChatNameResol
|
|
|
8
8
|
export type { UseChatMessagesResult } from "./hooks/useChatMessages.js";
|
|
9
9
|
export { useChatMessages } from "./hooks/useChatMessages.js";
|
|
10
10
|
export { canAccessThread } from "./hooks/useChatThreadAccess.js";
|
|
11
|
-
export { createRealtimeChatClient, createInboxClient, ChannelClient, InboxClient, useRealtimeChatMessages, browserSocketFactory, ChatAccessDeniedError, isChatAccessDeniedError, CHAT_SUBPROTOCOL, CHAT_CLOSE_CODES, CLIENT_FRAME, SERVER_FRAME, buildFrame, parseFrame, } from "./realtime/index.js";
|
|
12
|
-
export type { RealtimeChatClient, RealtimeTransportConfig, ChannelClientState, ChannelClientConfig, InboxClientState, InboxClientConfig, UseRealtimeChatMessagesResult, GrantProvider, TransportTimers, RealtimeStatus, RealtimeSocket, SocketFactory, SocketHandlers, ChannelRefTuple, WireMessageRow, WireInboxSnapshot, WireRegistryEntry, ServerFrame, } from "./realtime/index.js";
|
|
11
|
+
export { createRealtimeChatClient, createInboxClient, ChannelClient, InboxClient, useRealtimeChatMessages, browserSocketFactory, ChatAccessDeniedError, isChatAccessDeniedError, CHAT_SUBPROTOCOL, CHAT_CLOSE_CODES, CLIENT_FRAME, SERVER_FRAME, buildFrame, parseFrame, CHAT_CLIENT_DIAGNOSTIC_EVENTS, } from "./realtime/index.js";
|
|
12
|
+
export type { RealtimeChatClient, RealtimeTransportConfig, ChatClientDiagnosticsOption, ChatClientDiagnosticsSink, ChatClientDiagnosticEventName, ChannelClientState, ChannelClientConfig, InboxClientState, InboxClientConfig, UseRealtimeChatMessagesResult, GrantProvider, TransportTimers, RealtimeStatus, RealtimeSocket, SocketFactory, SocketHandlers, ChannelRefTuple, WireMessageRow, WireInboxSnapshot, WireRegistryEntry, ServerFrame, } from "./realtime/index.js";
|
|
13
13
|
export type { ChatShellProps } from "./ui/ChatShell.js";
|
|
14
14
|
export { ChatShell } from "./ui/ChatShell.js";
|
|
15
15
|
export { MessageList } from "./ui/MessageList.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,2BAA2B,EAC3B,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,uBAAuB,EACvB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,uCAAuC,CAAC;AAM/C,YAAY,EACV,4BAA4B,EAC5B,gCAAgC,GACjC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,yCAAyC,CAAC;AAGjD,YAAY,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AAC1F,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAE9C,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAKjE,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,uBAAu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2BAA2B,EAC3B,yBAAyB,EACzB,6BAA6B,EAC7B,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,6BAA6B,EAC7B,aAAa,EACb,eAAe,EACf,cAAc,EACd,cAAc,EACd,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAU7B,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,YAAY,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,GAC9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,sBAAsB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,GAC7B,MAAM,wCAAwC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export { canAccessThread } from "./hooks/useChatThreadAccess.js";
|
|
|
7
7
|
// Realtime (Cloudflare Durable Object) transport — the client half of the chat
|
|
8
8
|
// worker wire protocol. Opt-in via `ChatCoreConfig.transport === 'realtime'`; the
|
|
9
9
|
// firestore transport stays the unchanged default. See docs/packages/chat-react.md.
|
|
10
|
-
export { createRealtimeChatClient, createInboxClient, ChannelClient, InboxClient, useRealtimeChatMessages, browserSocketFactory, ChatAccessDeniedError, isChatAccessDeniedError, CHAT_SUBPROTOCOL, CHAT_CLOSE_CODES, CLIENT_FRAME, SERVER_FRAME, buildFrame, parseFrame, } from "./realtime/index.js";
|
|
10
|
+
export { createRealtimeChatClient, createInboxClient, ChannelClient, InboxClient, useRealtimeChatMessages, browserSocketFactory, ChatAccessDeniedError, isChatAccessDeniedError, CHAT_SUBPROTOCOL, CHAT_CLOSE_CODES, CLIENT_FRAME, SERVER_FRAME, buildFrame, parseFrame, CHAT_CLIENT_DIAGNOSTIC_EVENTS, } from "./realtime/index.js";
|
|
11
11
|
export { ChatShell } from "./ui/ChatShell.js";
|
|
12
12
|
export { MessageList } from "./ui/MessageList.js";
|
|
13
13
|
export { Composer } from "./ui/Composer.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AA2Bb,OAAO,EACL,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,uCAAuC,CAAC;AAU/C,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,yCAAyC,CAAC;AAIjD,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,+EAA+E;AAC/E,kFAAkF;AAClF,oFAAoF;AACpF,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,UAAU,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AA2Bb,OAAO,EACL,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,uCAAuC,CAAC;AAU/C,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,yCAAyC,CAAC;AAIjD,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,+EAA+E;AAC/E,kFAAkF;AAClF,oFAAoF;AACpF,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,6BAA6B,GAC9B,MAAM,qBAAqB,CAAC;AAkC7B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAyB,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EACL,mBAAmB,GAEpB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,sBAAsB,GAKvB,MAAM,wCAAwC,CAAC","sourcesContent":["\"use client\";\n\n// @ttt-productions/chat-react — chat React UI, hooks, the Firebase-client\n// adapter config types, and React render types. Depends on the pure\n// @ttt-productions/chat-core for contracts, parser, and grouping.\n//\n// Apps import chat CSS via \"@ttt-productions/chat-react/styles\".\n\n// React-coupled config + render types (previously on chat-core root).\nexport type {\n ChatCoreConfig,\n ChatTransportMode,\n ChatRealtimeTransportConfig,\n ChatAttachmentConfig,\n ChatUploadAdapter,\n ChatMentionConfig,\n MessageRenderer,\n MessageRendererRegistry,\n RenderableMentionProvider,\n MentionResultRenderer,\n} from \"./types.js\";\n\n// Attachment-URL resolver context (render-time URL building from mediaAssetId).\nexport type {\n ChatAttachmentUrlResolver,\n ChatAttachmentUrlProviderProps,\n} from \"./context/ChatAttachmentUrlContext.js\";\nexport {\n ChatAttachmentUrlProvider,\n useChatAttachmentUrlResolver,\n} from \"./context/ChatAttachmentUrlContext.js\";\n\n// Attachment media-component injection (optional) — the app hands chat its own\n// display-path wrapper (recovery adapter, diagnostics, telemetry) so chat\n// media rides the same pipeline as every other surface; default stays the\n// package MediaViewer.\nexport type {\n ChatAttachmentMediaComponent,\n ChatAttachmentMediaProviderProps,\n} from \"./context/ChatAttachmentMediaContext.js\";\nexport {\n ChatAttachmentMediaProvider,\n useChatAttachmentMediaComponent,\n} from \"./context/ChatAttachmentMediaContext.js\";\n\n// Name-resolver context.\nexport type { ChatNameResolverProviderProps } from \"./context/ChatNameResolverContext.js\";\nexport {\n ChatNameResolverProvider,\n useChatNameResolver,\n useOptionalChatNameResolver,\n useResolvedSenderName,\n} from \"./context/ChatNameResolverContext.js\";\n\nexport type { UseChatMessagesResult } from \"./hooks/useChatMessages.js\";\nexport { useChatMessages } from \"./hooks/useChatMessages.js\";\nexport { canAccessThread } from \"./hooks/useChatThreadAccess.js\";\n\n// Realtime (Cloudflare Durable Object) transport — the client half of the chat\n// worker wire protocol. Opt-in via `ChatCoreConfig.transport === 'realtime'`; the\n// firestore transport stays the unchanged default. See docs/packages/chat-react.md.\nexport {\n createRealtimeChatClient,\n createInboxClient,\n ChannelClient,\n InboxClient,\n useRealtimeChatMessages,\n browserSocketFactory,\n ChatAccessDeniedError,\n isChatAccessDeniedError,\n CHAT_SUBPROTOCOL,\n CHAT_CLOSE_CODES,\n CLIENT_FRAME,\n SERVER_FRAME,\n buildFrame,\n parseFrame,\n CHAT_CLIENT_DIAGNOSTIC_EVENTS,\n} from \"./realtime/index.js\";\nexport type {\n RealtimeChatClient,\n RealtimeTransportConfig,\n ChatClientDiagnosticsOption,\n ChatClientDiagnosticsSink,\n ChatClientDiagnosticEventName,\n ChannelClientState,\n ChannelClientConfig,\n InboxClientState,\n InboxClientConfig,\n UseRealtimeChatMessagesResult,\n GrantProvider,\n TransportTimers,\n RealtimeStatus,\n RealtimeSocket,\n SocketFactory,\n SocketHandlers,\n ChannelRefTuple,\n WireMessageRow,\n WireInboxSnapshot,\n WireRegistryEntry,\n ServerFrame,\n} from \"./realtime/index.js\";\n\n// TODO (re-export when a consumer needs them): the moderation-overlay helpers\n// `RevisionKind`, `ModerationOverlay`, `applyModerationOverlay`, `overlayFromRow`,\n// and `MODERATION_REDACTED_TEXT` live in `./realtime` but are intentionally NOT\n// re-exported from this package root yet — the consuming app's renderer reads moderation\n// state off `message.meta` (the realtime client applies the overlay internally), so\n// nothing imports them from here today. Add them to the block above when a consumer\n// genuinely needs to apply the overlay directly. (Comment-only; rides the next publish.)\n\nexport type { ChatShellProps } from \"./ui/ChatShell.js\";\nexport { ChatShell } from \"./ui/ChatShell.js\";\nexport { MessageList } from \"./ui/MessageList.js\";\nexport type { ComposerProps, ComposerHandle } from \"./ui/Composer.js\";\nexport { Composer } from \"./ui/Composer.js\";\nexport type { MessageItemDefaultProps } from \"./ui/MessageItemDefault.js\";\nexport { MessageItemDefault } from \"./ui/MessageItemDefault.js\";\nexport { MessageActions, ThreadActions } from \"./ui/menus.js\";\nexport { MessageText, type MessageTextProps } from \"./mentions/MessageText.js\";\nexport {\n MentionAutocomplete,\n type MentionAutocompleteProps,\n} from \"./mentions/MentionAutocomplete.js\";\nexport {\n useMentionAutocomplete,\n type UseMentionAutocompleteArgs,\n type UseMentionAutocompleteResult,\n type AutocompleteState,\n type AutocompleteResultGroup,\n} from \"./mentions/use-mention-autocomplete.js\";\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ChatMessageV1 } from '@ttt-productions/chat-core';
|
|
2
2
|
import type { SocketFactory } from './socket.js';
|
|
3
3
|
import type { GrantProvider, TransportTimers, RealtimeStatus } from './shared.js';
|
|
4
|
+
import { type ChatClientDiagnosticsOption } from './diagnostics.js';
|
|
4
5
|
export interface ChannelClientState {
|
|
5
6
|
status: RealtimeStatus;
|
|
6
7
|
/** Ordered ascending by seq; optimistic messages (no seq yet) sort to the tail. */
|
|
@@ -45,6 +46,16 @@ export interface ChannelClientConfig {
|
|
|
45
46
|
maxAttempts?: number | null;
|
|
46
47
|
random?: () => number;
|
|
47
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* OPT-IN structured client diagnostics (default OFF — absent/`false` changes
|
|
51
|
+
* nothing and costs one nullish check per decision point). `true` emits one
|
|
52
|
+
* `console.debug` line per decision with a stable `chat_client_*` event name
|
|
53
|
+
* and a compact, content-free JSON payload; a function routes those entries
|
|
54
|
+
* into the app's own logger instead. Never logs message text, captions,
|
|
55
|
+
* filenames, URLs, tokens, or previews — ids, seqs, states, counts, and codes
|
|
56
|
+
* only. See `./diagnostics.ts`.
|
|
57
|
+
*/
|
|
58
|
+
diagnostics?: ChatClientDiagnosticsOption;
|
|
48
59
|
}
|
|
49
60
|
export declare class ChannelClient {
|
|
50
61
|
private readonly config;
|
|
@@ -90,6 +101,18 @@ export declare class ChannelClient {
|
|
|
90
101
|
* send that exceeds the attempt/age cap is flipped to a visible failed state
|
|
91
102
|
* (retry affordance) instead of staying a ghost. */
|
|
92
103
|
private pendingSends;
|
|
104
|
+
/**
|
|
105
|
+
* The structured diagnostics emitter, or null when diagnostics are off (the
|
|
106
|
+
* default). Every call site uses `this.diag?.(...)` so the off path constructs
|
|
107
|
+
* no payload at all.
|
|
108
|
+
*/
|
|
109
|
+
private readonly diag;
|
|
110
|
+
/** Monotonic socket-open attempt counter (diagnostics correlation only). */
|
|
111
|
+
private connectAttempt;
|
|
112
|
+
/** Why the CURRENT connect attempt is happening (diagnostics only). */
|
|
113
|
+
private reconnectCause;
|
|
114
|
+
/** The last close code observed, carried into the next attempt's cause line. */
|
|
115
|
+
private lastCloseCode;
|
|
93
116
|
constructor(config: ChannelClientConfig);
|
|
94
117
|
getState(): ChannelClientState;
|
|
95
118
|
subscribe(fn: (s: ChannelClientState) => void): () => void;
|
|
@@ -218,7 +241,25 @@ export declare class ChannelClient {
|
|
|
218
241
|
* `resync:false` (already caught up) is a no-op beyond advancing the cursor.
|
|
219
242
|
*/
|
|
220
243
|
private applyChannelSnapshot;
|
|
244
|
+
/**
|
|
245
|
+
* Apply one server row (a live `message` frame or a resume-delta row) and record
|
|
246
|
+
* the decision the client made about it.
|
|
247
|
+
*
|
|
248
|
+
* Diagnostics bounding: a LIVE frame always emits one `chat_client_frame_applied`
|
|
249
|
+
* line; a DELTA row emits one only when it is materially interesting (carries an
|
|
250
|
+
* attachment state, carries a moderation kind, or reconciles one of our optimistic
|
|
251
|
+
* sends) — a 500-row backlog is otherwise summarized by `chat_client_resume_result`
|
|
252
|
+
* rather than spamming 500 lines. Attachment transitions ALWAYS emit, from either
|
|
253
|
+
* source, because an in-place attachment mutation is the exact event this
|
|
254
|
+
* instrumentation exists to prove.
|
|
255
|
+
*/
|
|
221
256
|
private applyMessage;
|
|
257
|
+
/**
|
|
258
|
+
* The pre-merge view of a row's seq: whether we already hold that seq, its current
|
|
259
|
+
* attachment state, and whether this row reconciles a live optimistic send.
|
|
260
|
+
* Diagnostics-only — never called when diagnostics are off.
|
|
261
|
+
*/
|
|
262
|
+
private priorRowFacts;
|
|
222
263
|
/**
|
|
223
264
|
* Merge a server message: reconcile an optimistic echo by clientMessageId (swap
|
|
224
265
|
* the `optimistic:` row for the canonical seq row), or insert/replace by seq.
|
|
@@ -227,6 +268,11 @@ export declare class ChannelClient {
|
|
|
227
268
|
private mergeMessage;
|
|
228
269
|
private applyAck;
|
|
229
270
|
private applyHistoryPage;
|
|
271
|
+
/**
|
|
272
|
+
* A seq -> attachmentState map of the rows currently held (diagnostics-only, so a
|
|
273
|
+
* later in-place mutation can be reported as an explicit `old -> new` transition).
|
|
274
|
+
*/
|
|
275
|
+
private snapshotAttachmentStates;
|
|
230
276
|
private applyTyping;
|
|
231
277
|
private sendFrame;
|
|
232
278
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-client.d.ts","sourceRoot":"","sources":["../../src/realtime/channel-client.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAahE,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,aAAa,CAAC;AASjE,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"channel-client.d.ts","sourceRoot":"","sources":["../../src/realtime/channel-client.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAahE,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,aAAa,CAAC;AASjE,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAKL,KAAK,2BAA2B,EACjC,MAAM,kBAAkB,CAAC;AA6C1B,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,cAAc,CAAC;IACvB,mFAAmF;IACnF,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,4EAA4E;IAC5E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,6DAA6D;IAC7D,eAAe,EAAE,OAAO,CAAC;IACzB,2FAA2F;IAC3F,QAAQ,EAAE,OAAO,CA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