@ttt-productions/chat-core 0.6.0 → 0.6.2

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 (65) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +7 -4
  4. package/dist/index.js.map +1 -1
  5. package/dist/mentions/types.d.ts +10 -7
  6. package/dist/mentions/types.d.ts.map +1 -1
  7. package/dist/mentions/types.js +3 -0
  8. package/dist/mentions/types.js.map +1 -1
  9. package/dist/types.d.ts +18 -120
  10. package/dist/types.d.ts.map +1 -1
  11. package/dist/types.js.map +1 -1
  12. package/package.json +6 -29
  13. package/dist/context/ChatNameResolverContext.d.ts +0 -37
  14. package/dist/context/ChatNameResolverContext.d.ts.map +0 -1
  15. package/dist/context/ChatNameResolverContext.js +0 -44
  16. package/dist/context/ChatNameResolverContext.js.map +0 -1
  17. package/dist/firestore/queries.d.ts +0 -5
  18. package/dist/firestore/queries.d.ts.map +0 -1
  19. package/dist/firestore/queries.js +0 -16
  20. package/dist/firestore/queries.js.map +0 -1
  21. package/dist/hooks/useChatMessages.d.ts +0 -11
  22. package/dist/hooks/useChatMessages.d.ts.map +0 -1
  23. package/dist/hooks/useChatMessages.js +0 -139
  24. package/dist/hooks/useChatMessages.js.map +0 -1
  25. package/dist/hooks/useChatThreadAccess.d.ts +0 -8
  26. package/dist/hooks/useChatThreadAccess.d.ts.map +0 -1
  27. package/dist/hooks/useChatThreadAccess.js +0 -19
  28. package/dist/hooks/useChatThreadAccess.js.map +0 -1
  29. package/dist/mentions/MentionAutocomplete.d.ts +0 -22
  30. package/dist/mentions/MentionAutocomplete.d.ts.map +0 -1
  31. package/dist/mentions/MentionAutocomplete.js +0 -21
  32. package/dist/mentions/MentionAutocomplete.js.map +0 -1
  33. package/dist/mentions/MessageText.d.ts +0 -27
  34. package/dist/mentions/MessageText.d.ts.map +0 -1
  35. package/dist/mentions/MessageText.js +0 -20
  36. package/dist/mentions/MessageText.js.map +0 -1
  37. package/dist/mentions/use-mention-autocomplete.d.ts +0 -81
  38. package/dist/mentions/use-mention-autocomplete.d.ts.map +0 -1
  39. package/dist/mentions/use-mention-autocomplete.js +0 -323
  40. package/dist/mentions/use-mention-autocomplete.js.map +0 -1
  41. package/dist/react/index.d.ts +0 -17
  42. package/dist/react/index.d.ts.map +0 -1
  43. package/dist/react/index.js +0 -13
  44. package/dist/react/index.js.map +0 -1
  45. package/dist/ui/ChatShell.d.ts +0 -22
  46. package/dist/ui/ChatShell.d.ts.map +0 -1
  47. package/dist/ui/ChatShell.js +0 -22
  48. package/dist/ui/ChatShell.js.map +0 -1
  49. package/dist/ui/Composer.d.ts +0 -23
  50. package/dist/ui/Composer.d.ts.map +0 -1
  51. package/dist/ui/Composer.js +0 -140
  52. package/dist/ui/Composer.js.map +0 -1
  53. package/dist/ui/MessageItemDefault.d.ts +0 -11
  54. package/dist/ui/MessageItemDefault.d.ts.map +0 -1
  55. package/dist/ui/MessageItemDefault.js +0 -51
  56. package/dist/ui/MessageItemDefault.js.map +0 -1
  57. package/dist/ui/MessageList.d.ts +0 -17
  58. package/dist/ui/MessageList.d.ts.map +0 -1
  59. package/dist/ui/MessageList.js +0 -90
  60. package/dist/ui/MessageList.js.map +0 -1
  61. package/dist/ui/menus.d.ts +0 -12
  62. package/dist/ui/menus.d.ts.map +0 -1
  63. package/dist/ui/menus.js +0 -12
  64. package/dist/ui/menus.js.map +0 -1
  65. package/src/styles/chat.css +0 -153
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { MAX_CHAT_MESSAGE_LENGTH } from "./constants.js";
2
2
  export { GROUP_GAP_SEC } from "./types.js";
3
3
  export { isContinuation } from "./grouping.js";
4
- export type { ChatAttachment, ChatId, ChatThreadV1, ChatMessageV1, ChatAccessMode, ChatCoreConfig, ChatAttachmentConfig, SendAttachmentInput, SendAttachmentFn, ModerationHandlers, MessageRenderer, MessageRendererRegistry, ChatNameResolver, ChatPrewarmSenders, ChatMentionConfig, } from "./types.js";
4
+ export type { ChatAttachment, ChatId, ChatThreadV1, ChatMessageV1, ChatAccessMode, SendAttachmentInput, SendAttachmentFn, ModerationHandlers, ChatNameResolver, ChatPrewarmSenders, } from "./types.js";
5
5
  export type { MentionRef, ParsedSegment, MentionProvider, RecentMentionsAdapter, MentionAnchor, } from "./mentions/types.js";
6
6
  export { parseMentionTokens, formatMentionToken } from "./mentions/parser.js";
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,YAAY,EACR,cAAc,EACd,MAAM,EACN,YAAY,EACZ,aAAa,EACb,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,GACpB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACR,UAAU,EACV,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,aAAa,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,YAAY,EACR,cAAc,EACd,MAAM,EACN,YAAY,EACZ,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,GACrB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACR,UAAU,EACV,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,aAAa,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -1,9 +1,12 @@
1
- // Server-safe barrel. React UI, hooks, and the ChatNameResolver context
2
- // live on the "/react" subpath. Cloud Functions and other server code
3
- // import from this barrel only.
1
+ // Pure chat-core barrel. No React, no Firebase (client or admin) reachable from
2
+ // here safe for Cloud Functions, scripts, and future native/TV clients that
3
+ // only need the parser, contracts, and grouping logic.
4
+ //
5
+ // The chat React UI, hooks, Firestore-client adapter config, and render types
6
+ // live in @ttt-productions/chat-react. Pure chat schemas live in
7
+ // @ttt-productions/chat-schemas.
4
8
  export { MAX_CHAT_MESSAGE_LENGTH } from "./constants.js";
5
9
  export { GROUP_GAP_SEC } from "./types.js";
6
10
  export { isContinuation } from "./grouping.js";
7
11
  export { parseMentionTokens, formatMentionToken } from "./mentions/parser.js";
8
- // CSS: import "@ttt-productions/chat-core/styles" in your app layout.
9
12
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,sEAAsE;AACtE,gCAAgC;AAEhC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AA0B/C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,sEAAsE"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,8EAA8E;AAC9E,uDAAuD;AACvD,EAAE;AACF,8EAA8E;AAC9E,iEAAiE;AACjE,iCAAiC;AAEjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAqB/C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -9,8 +9,10 @@
9
9
  * Wire format — mentions are encoded inline in the message's `text` field as
10
10
  * `@[kind:id|displayText]` tokens. The renderer parses them out at display
11
11
  * time. No schema change to ChatMessage.
12
+ *
13
+ * These are the PURE mention contracts. The React-coupled render type for
14
+ * autocomplete rows (`renderResult`) lives in @ttt-productions/chat-react.
12
15
  */
13
- import type { ReactNode } from 'react';
14
16
  /**
15
17
  * Resolved mention — the value that ends up in the wire token after the user
16
18
  * selects an autocomplete result.
@@ -44,13 +46,15 @@ export type ParsedSegment<TKind extends string = string> = {
44
46
  * - `search` — async query. Receives the current query string (after the
45
47
  * trigger character), the consumer-supplied `context`, and an optional
46
48
  * `signal` for cancellation. Returns up to whatever limit the provider
47
- * chooses; chat-core renders all returned results.
48
- * - `renderResult` — optional custom row UI. When omitted, the autocomplete
49
- * renders the `displayText` plain.
49
+ * chooses; the chat UI renders all returned results.
50
50
  *
51
51
  * `TContext` is consumer-owned — pass anything you need inside `search`
52
- * (Firestore db, current user id, surface-specific filters). chat-core never
53
- * inspects it.
52
+ * (Firestore db, current user id, surface-specific filters). The mention
53
+ * system never inspects it.
54
+ *
55
+ * Optional per-row custom rendering (`renderResult`) is a React concern and is
56
+ * layered on top of this pure provider by `RenderableMentionProvider` in
57
+ * @ttt-productions/chat-react.
54
58
  */
55
59
  export type MentionProvider<TKind extends string = string, TContext = unknown> = {
56
60
  kind: TKind;
@@ -60,7 +64,6 @@ export type MentionProvider<TKind extends string = string, TContext = unknown> =
60
64
  context: TContext;
61
65
  signal?: AbortSignal;
62
66
  }) => Promise<MentionRef<TKind>[]>;
63
- renderResult?: (ref: MentionRef<TKind>) => ReactNode;
64
67
  };
65
68
  /**
66
69
  * Optional recent-mentions adapter. When provided, the autocomplete UI shows
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/mentions/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,IAAI;IACtD,IAAI,EAAE,KAAK,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,IACnD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;CAAE,CAAC;AAEhD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,eAAe,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EAAE,QAAQ,GAAG,OAAO,IAAI;IAC/E,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,CAAC,IAAI,EAAE;QACb,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,QAAQ,CAAC;QAClB,MAAM,CAAC,EAAE,WAAW,CAAC;KACtB,KAAK,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC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EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,CAAC,IAAI,EAAE;QACb,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,QAAQ,CAAC;QAClB,MAAM,CAAC,EAAE,WAAW,CAAC;KACtB,KAAK,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,qBAAqB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,IAAI;IACjE,SAAS,EAAE,MAAM,UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACpE,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,IAAI;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;CACxB,CAAC"}
@@ -9,6 +9,9 @@
9
9
  * Wire format — mentions are encoded inline in the message's `text` field as
10
10
  * `@[kind:id|displayText]` tokens. The renderer parses them out at display
11
11
  * time. No schema change to ChatMessage.
12
+ *
13
+ * These are the PURE mention contracts. The React-coupled render type for
14
+ * autocomplete rows (`renderResult`) lives in @ttt-productions/chat-react.
12
15
  */
13
16
  export {};
14
17
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/mentions/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/mentions/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
package/dist/types.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- import type { Firestore } from "firebase/firestore";
2
- import type { FirebaseStorage } from "firebase/storage";
3
- import type { MediaOriginSpec } from "@ttt-productions/media-schemas";
4
1
  import type { ChatAttachment, ReplyTo } from "@ttt-productions/chat-schemas";
5
2
  export type { ChatAttachment };
6
3
  export type ChatId = string;
@@ -25,94 +22,28 @@ export type ChatMessageV1 = {
25
22
  meta?: Record<string, unknown>;
26
23
  };
27
24
  /**
28
- * Access mode controls how chat-core decides whether the current user
29
- * can read/write a thread.
25
+ * Access mode controls how chat decides whether the current user can
26
+ * read/write a thread.
30
27
  *
31
- * - "firestore-rules" — chat-core trusts Firestore rules. canAccessThread
32
- * returns true for any signed-in user; if rules deny, onSnapshot will
33
- * surface permission-denied. Use this when access depends on data the
34
- * client doesn't reliably know up-front (entity membership, invite
35
- * participation, etc.).
28
+ * - "firestore-rules" trust Firestore rules. canAccessThread returns true
29
+ * for any signed-in user; if rules deny, onSnapshot will surface
30
+ * permission-denied. Use this when access depends on data the client doesn't
31
+ * reliably know up-front (entity membership, invite participation, etc.).
36
32
  *
37
- * - "explicit-allowlist" — chat-core enforces access client-side via
38
- * threadAllowedUserIds. The list is required in this mode. Use this
39
- * when the consumer already knows the participants (admin/support
40
- * threads).
33
+ * - "explicit-allowlist" access is enforced client-side via
34
+ * threadAllowedUserIds. The list is required in this mode. Use this when the
35
+ * consumer already knows the participants (admin/support threads).
41
36
  *
42
37
  * Admins (`isAdmin: true`) bypass both modes.
43
38
  */
44
39
  export type ChatAccessMode = "firestore-rules" | "explicit-allowlist";
45
- export type ChatCoreConfig = {
46
- db: Firestore;
47
- chatCollectionPath: string | string[];
48
- messagesSubcollection?: string;
49
- threadId: string;
50
- currentUserId: string;
51
- currentUserDisplayName?: string;
52
- isAdmin: boolean;
53
- /**
54
- * REQUIRED. See ChatAccessMode docs.
55
- */
56
- accessMode: ChatAccessMode;
57
- /**
58
- * Required iff accessMode === "explicit-allowlist". Ignored otherwise.
59
- */
60
- threadAllowedUserIds?: string[];
61
- createdAtField?: string;
62
- pageSize?: number;
63
- /**
64
- * Optional mention system configuration. When present, the composer enables
65
- * `@`-trigger autocomplete using the supplied providers and renders mention
66
- * chips in messages. Each provider corresponds to one mention kind.
67
- */
68
- mentionConfig?: ChatMentionConfig;
69
- };
70
- /**
71
- * Pluggable upload-path strategy for chat attachments.
72
- *
73
- * Consumers supply this to tell chat-core (a) what opaque origin identifier
74
- * to record for the upload, (b) how to build the Firebase Storage path for
75
- * the temporary upload, and (c) optional extra metadata to attach to the
76
- * Storage object.
77
- *
78
- * `buildUploadPath` and `buildUploadMetadata` receive the userId and
79
- * attachmentId so consumers can interpolate them per their own conventions.
80
- * chat-core does not interpret `originId` — it forwards it via callbacks
81
- * and uses it for adapter identity only.
82
- */
83
- export type ChatUploadAdapter = {
84
- /** Opaque origin identifier (e.g. "chat-attachment"). Not interpreted by chat-core. */
85
- originId: string;
86
- /** Build the Firebase Storage path for the upload. Called once per attachment. */
87
- buildUploadPath: (args: {
88
- userId: string;
89
- attachmentId: string;
90
- }) => string;
91
- /** Optional extra metadata merged onto the Storage object metadata (e.g. customMetadata). */
92
- buildUploadMetadata?: (args: {
93
- userId: string;
94
- attachmentId: string;
95
- }) => Record<string, unknown>;
96
- };
97
- export type ChatAttachmentConfig = {
98
- attachmentSpec: MediaOriginSpec;
99
- storage: FirebaseStorage;
100
- /** The current user's auth uid. Forwarded to `uploadAdapter` callbacks. */
101
- userId: string;
102
- /**
103
- * Pluggable upload-path strategy. Consumers wire this to their app's
104
- * conventions (for example: originId "chat-attachment", path
105
- * `uploads/chat-attachment/{userId}/{attachmentId}`).
106
- */
107
- uploadAdapter: ChatUploadAdapter;
108
- };
109
40
  /**
110
- * Called by Composer after the file has been uploaded to Storage. The consumer
111
- * wires this to a backend callable (`startUpload`) that writes the pendingMedia
112
- * doc with the caption text + reply pointer. The processor will create the
113
- * message doc itself after media moderation succeeds.
41
+ * Called by the composer after the file has been uploaded to Storage. The
42
+ * consumer wires this to a backend callable (`startUpload`) that writes the
43
+ * pendingMedia doc with the caption text + reply pointer. The processor will
44
+ * create the message doc itself after media moderation succeeds.
114
45
  *
115
- * No message doc is created at this point — Composer should render an
46
+ * No message doc is created at this point the composer should render an
116
47
  * optimistic local "uploading" state until the listener delivers the real
117
48
  * message after processing completes.
118
49
  */
@@ -128,57 +59,24 @@ export type SendAttachmentInput = {
128
59
  replyTo?: ChatMessageV1["replyTo"];
129
60
  };
130
61
  export type SendAttachmentFn = (input: SendAttachmentInput) => Promise<void>;
131
- /**
132
- * Pluggable mention system config. When attached to ChatCoreConfig, the
133
- * composer enables `@`-trigger autocomplete and the message renderer parses
134
- * mention tokens out of `text`.
135
- *
136
- * Generic over `TKind` and `TContext` is intentionally NOT exposed here at
137
- * the type level — `ChatCoreConfig` would have to become generic too, which
138
- * cascades. Instead this type accepts permissive `string`-keyed providers;
139
- * consumers binding stricter kind unions narrow at the call site via their
140
- * provider definitions.
141
- */
142
- export type ChatMentionConfig = {
143
- /** Providers in display order. */
144
- providers: import('./mentions/types.js').MentionProvider<string, unknown>[];
145
- /** Context object forwarded to every provider's `search`. */
146
- context: unknown;
147
- /** Optional recent-mentions adapter. */
148
- recent?: import('./mentions/types.js').RecentMentionsAdapter<string>;
149
- /** Trigger character. Defaults to `'@'`. */
150
- trigger?: string;
151
- /** Minimum query length before search fires. Default: 0. */
152
- minQueryLength?: number;
153
- /** Search debounce window in ms. Default: 200. */
154
- searchDebounceMs?: number;
155
- /**
156
- * Optional custom renderer for mentions inside rendered message text.
157
- * When omitted, the default chip (`<span class="chat-mention-chip">`) is
158
- * used. Receives the resolved MentionRef.
159
- */
160
- renderMention?: (ref: import('./mentions/types.js').MentionRef) => import('react').ReactNode;
161
- };
162
62
  export type ModerationHandlers = {
163
63
  onReportMessage?: (messageId: string, reason?: string) => void | Promise<void>;
164
64
  onReportThread?: (threadId: string, reason?: string) => void | Promise<void>;
165
65
  onDeleteMessage?: (messageId: string) => void | Promise<void>;
166
66
  onDeleteThread?: (threadId: string) => void | Promise<void>;
167
67
  };
168
- export type MessageRenderer = (m: ChatMessageV1) => React.ReactNode;
169
- export type MessageRendererRegistry = Record<string, MessageRenderer>;
170
68
  /** Max seconds between messages to be grouped as continuation */
171
69
  export declare const GROUP_GAP_SEC = 120;
172
70
  /**
173
71
  * Resolves a senderId to a display name synchronously from app-side cache.
174
- * Returns null if the sender is unknown or the cache hasn't loaded yet —
175
- * chat-core will render a stable fallback ("User") in that case.
72
+ * Returns null if the sender is unknown or the cache hasn't loaded yet
73
+ * the chat UI will render a stable fallback ("User") in that case.
176
74
  */
177
75
  export type ChatNameResolver = (senderId: string) => string | null;
178
76
  /**
179
- * Optional pre-warm callback. chat-core calls this with the deduped list of
77
+ * Optional pre-warm callback. The chat UI calls this with the deduped list of
180
78
  * senderIds visible in the current message page so the consuming app can
181
- * batch-fetch names into its cache. Implementations should be idempotent —
79
+ * batch-fetch names into its cache. Implementations should be idempotent
182
80
  * the same id list will be passed across re-renders.
183
81
  */
184
82
  export type ChatPrewarmSenders = (senderIds: string[]) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAY7E,YAAY,EAAE,cAAc,EAAE,CAAC;AAM/B,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B,MAAM,MAAM,YAAY,GAAG;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;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ources":["../src/types.ts"],"names":[],"mappings":"AAsGA,+CAA+C;AAC/C,kDAAkD;AAClD,+CAA+C;AAE/C,iEAAiE;AACjE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ttt-productions/chat-core",
3
- "version": "0.6.0",
4
- "description": "Shared Firestore chat core (realtime newest window + infinite older pagination) for TTT Productions apps",
3
+ "version": "0.6.2",
4
+ "description": "Pure chat contracts, mention parser/serializer, and grouping helpers for TTT Productions apps (no React, no Firebase)",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ttt-productions/ttt-packages.git",
@@ -11,23 +11,15 @@
11
11
  "main": "dist/index.js",
12
12
  "module": "dist/index.js",
13
13
  "types": "dist/index.d.ts",
14
- "sideEffects": [
15
- "src/styles/*.css"
16
- ],
14
+ "sideEffects": false,
17
15
  "files": [
18
- "dist",
19
- "src/styles"
16
+ "dist"
20
17
  ],
21
18
  "exports": {
22
19
  ".": {
23
20
  "types": "./dist/index.d.ts",
24
21
  "default": "./dist/index.js"
25
- },
26
- "./react": {
27
- "types": "./dist/react/index.d.ts",
28
- "default": "./dist/react/index.js"
29
- },
30
- "./styles": "./src/styles/chat.css"
22
+ }
31
23
  },
32
24
  "scripts": {
33
25
  "build": "tsc",
@@ -35,25 +27,10 @@
35
27
  "typecheck": "tsc --noEmit",
36
28
  "prepublishOnly": "npm run clean && npm run build"
37
29
  },
38
- "peerDependencies": {
39
- "@tanstack/react-query": ">=5.0.0",
40
- "firebase": ">=10.0.0",
41
- "react": ">=19.0.0",
42
- "react-dom": ">=19.0.0"
43
- },
44
30
  "dependencies": {
45
- "@ttt-productions/chat-schemas": "*",
46
- "@ttt-productions/ui-core": "*",
47
- "@ttt-productions/firebase-helpers": "*",
48
- "@ttt-productions/mobile-core": "*",
49
- "@ttt-productions/file-input": "*",
50
- "@ttt-productions/upload-ui": "*",
51
- "@ttt-productions/media-viewer": "*",
52
- "@ttt-productions/media-schemas": "*"
31
+ "@ttt-productions/chat-schemas": "0.4.0"
53
32
  },
54
33
  "devDependencies": {
55
- "@types/react": "^19.0.0",
56
- "react": "^19.0.0",
57
34
  "typescript": "^5.8.3"
58
35
  },
59
36
  "author": "DJ (TTT Productions)",
@@ -1,37 +0,0 @@
1
- import * as React from "react";
2
- import type { ChatNameResolver, ChatPrewarmSenders } from "../types.js";
3
- type ChatNameResolverContextValue = {
4
- resolveName: ChatNameResolver;
5
- prewarm?: ChatPrewarmSenders;
6
- };
7
- export type ChatNameResolverProviderProps = {
8
- resolveName: ChatNameResolver;
9
- prewarm?: ChatPrewarmSenders;
10
- children: React.ReactNode;
11
- };
12
- /**
13
- * Wraps any chat-core consumer (typically the whole app shell) and provides
14
- * a name resolver. Required for any tree that renders <ChatShell>, <MessageList>,
15
- * or <MessageItemDefault>.
16
- */
17
- export declare function ChatNameResolverProvider(props: ChatNameResolverProviderProps): import("react/jsx-runtime").JSX.Element;
18
- /**
19
- * Strict hook — throws if no provider is wrapped. Used inside chat-core's
20
- * own renderers (MessageItemDefault, ReplyQuote) so a missing setup surfaces
21
- * immediately on first render rather than silently rendering "User".
22
- */
23
- export declare function useChatNameResolver(): ChatNameResolverContextValue;
24
- /**
25
- * Optional variant — returns null instead of throwing when no provider is
26
- * wrapped. Used internally by useChatMessages so headless callers (tests,
27
- * data-only consumers that don't render UI) can still use the hook.
28
- */
29
- export declare function useOptionalChatNameResolver(): ChatNameResolverContextValue | null;
30
- /**
31
- * Convenience hook for renderers. Returns a resolved string — never null —
32
- * by falling back to "User" when the cache hasn't filled yet. Re-renders
33
- * automatically once the upstream cache settles.
34
- */
35
- export declare function useResolvedSenderName(senderId: string): string;
36
- export {};
37
- //# sourceMappingURL=ChatNameResolverContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChatNameResolverContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatNameResolverContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExE,KAAK,4BAA4B,GAAG;IAClC,WAAW,EAAE,gBAAgB,CAAC;IAC9B,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B,CAAC;AAIF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,WAAW,EAAE,gBAAgB,CAAC;IAC9B,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,2CAQ5E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,4BAA4B,CAQlE;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI,4BAA4B,GAAG,IAAI,CAEjF;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG9D"}
@@ -1,44 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import * as React from "react";
4
- const ChatNameResolverContext = React.createContext(null);
5
- /**
6
- * Wraps any chat-core consumer (typically the whole app shell) and provides
7
- * a name resolver. Required for any tree that renders <ChatShell>, <MessageList>,
8
- * or <MessageItemDefault>.
9
- */
10
- export function ChatNameResolverProvider(props) {
11
- const { resolveName, prewarm, children } = props;
12
- const value = React.useMemo(() => ({ resolveName, prewarm }), [resolveName, prewarm]);
13
- return (_jsx(ChatNameResolverContext.Provider, { value: value, children: children }));
14
- }
15
- /**
16
- * Strict hook — throws if no provider is wrapped. Used inside chat-core's
17
- * own renderers (MessageItemDefault, ReplyQuote) so a missing setup surfaces
18
- * immediately on first render rather than silently rendering "User".
19
- */
20
- export function useChatNameResolver() {
21
- const ctx = React.useContext(ChatNameResolverContext);
22
- if (!ctx) {
23
- throw new Error("[chat-core] ChatNameResolverProvider is required. Wrap your ChatShell tree with <ChatNameResolverProvider>.");
24
- }
25
- return ctx;
26
- }
27
- /**
28
- * Optional variant — returns null instead of throwing when no provider is
29
- * wrapped. Used internally by useChatMessages so headless callers (tests,
30
- * data-only consumers that don't render UI) can still use the hook.
31
- */
32
- export function useOptionalChatNameResolver() {
33
- return React.useContext(ChatNameResolverContext);
34
- }
35
- /**
36
- * Convenience hook for renderers. Returns a resolved string — never null —
37
- * by falling back to "User" when the cache hasn't filled yet. Re-renders
38
- * automatically once the upstream cache settles.
39
- */
40
- export function useResolvedSenderName(senderId) {
41
- const { resolveName } = useChatNameResolver();
42
- return resolveName(senderId) ?? "User";
43
- }
44
- //# sourceMappingURL=ChatNameResolverContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChatNameResolverContext.js","sourceRoot":"","sources":["../../src/context/ChatNameResolverContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,MAAM,uBAAuB,GAAG,KAAK,CAAC,aAAa,CAAsC,IAAI,CAAC,CAAC;AAQ/F;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAoC;IAC3E,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACjD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;IACtF,OAAO,CACL,KAAC,uBAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAC3C,QAAQ,GACwB,CACpC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC;IACtD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,6GAA6G,CAC9G,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO,KAAK,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAgB;IACpD,MAAM,EAAE,WAAW,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAC9C,OAAO,WAAW,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC;AACzC,CAAC"}
@@ -1,5 +0,0 @@
1
- import type { Firestore, Query, DocumentData } from "firebase/firestore";
2
- export declare function threadDocPath(chatCollectionPath: string | string[], threadId: string): string[];
3
- export declare function messagesColPath(chatCollectionPath: string | string[], threadId: string, messagesSubcollection?: string): [string, string, ...string[]];
4
- export declare function newestWindowQuery(db: Firestore, chatCollectionPath: string | string[], threadId: string, createdAtField: string, pageSize: number, messagesSubcollection?: string): Query<DocumentData>;
5
- //# sourceMappingURL=queries.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/firestore/queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAOzE,wBAAgB,aAAa,CAAC,kBAAkB,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAE/F;AAED,wBAAgB,eAAe,CAC7B,kBAAkB,EAAE,MAAM,GAAG,MAAM,EAAE,EACrC,QAAQ,EAAE,MAAM,EAChB,qBAAqB,SAAa,GACjC,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAG/B;AAED,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,SAAS,EACb,kBAAkB,EAAE,MAAM,GAAG,MAAM,EAAE,EACrC,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,EAChB,qBAAqB,SAAa,GACjC,KAAK,CAAC,YAAY,CAAC,CAOrB"}
@@ -1,16 +0,0 @@
1
- import { collection, query, orderBy, limit } from "firebase/firestore";
2
- function normalizeSegments(path) {
3
- return Array.isArray(path) ? path : [path];
4
- }
5
- export function threadDocPath(chatCollectionPath, threadId) {
6
- return [...normalizeSegments(chatCollectionPath), threadId];
7
- }
8
- export function messagesColPath(chatCollectionPath, threadId, messagesSubcollection = "messages") {
9
- const segments = [...normalizeSegments(chatCollectionPath), threadId, messagesSubcollection];
10
- return segments;
11
- }
12
- export function newestWindowQuery(db, chatCollectionPath, threadId, createdAtField, pageSize, messagesSubcollection = "messages") {
13
- const path = messagesColPath(chatCollectionPath, threadId, messagesSubcollection);
14
- return query(collection(db, path[0], ...path.slice(1)), orderBy(createdAtField, "desc"), limit(pageSize));
15
- }
16
- //# sourceMappingURL=queries.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queries.js","sourceRoot":"","sources":["../../src/firestore/queries.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEvE,SAAS,iBAAiB,CAAC,IAAuB;IAChD,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,kBAAqC,EAAE,QAAgB;IACnF,OAAO,CAAC,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,kBAAqC,EACrC,QAAgB,EAChB,qBAAqB,GAAG,UAAU;IAElC,MAAM,QAAQ,GAAG,CAAC,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,EAAE,QAAQ,EAAE,qBAAqB,CAAC,CAAC;IAC7F,OAAO,QAAyC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,EAAa,EACb,kBAAqC,EACrC,QAAgB,EAChB,cAAsB,EACtB,QAAgB,EAChB,qBAAqB,GAAG,UAAU;IAElC,MAAM,IAAI,GAAG,eAAe,CAAC,kBAAkB,EAAE,QAAQ,EAAE,qBAAqB,CAAC,CAAC;IAClF,OAAO,KAAK,CACV,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACzC,OAAO,CAAC,cAAc,EAAE,MAAM,CAAC,EAC/B,KAAK,CAAC,QAAQ,CAAC,CAChB,CAAC;AACJ,CAAC"}
@@ -1,11 +0,0 @@
1
- import type { ChatCoreConfig, ChatMessageV1 } from "../types.js";
2
- export type UseChatMessagesResult = {
3
- allowed: boolean;
4
- isInitialLoading: boolean;
5
- messages: ChatMessageV1[];
6
- fetchOlder: () => Promise<void>;
7
- hasOlder: boolean;
8
- isFetchingOlder: boolean;
9
- };
10
- export declare function useChatMessages(config: ChatCoreConfig): UseChatMessagesResult;
11
- //# sourceMappingURL=useChatMessages.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useChatMessages.d.ts","sourceRoot":"","sources":["../../src/hooks/useChatMessages.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAcjE,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAsDF,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,qBAAqB,CA4I7E"}