@ttt-productions/chat-core 0.5.8 → 0.6.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/mentions/types.d.ts +11 -11
- package/dist/mentions/types.js +2 -2
- package/dist/types.d.ts +8 -8
- package/package.json +1 -1
package/dist/mentions/types.d.ts
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
*
|
|
4
4
|
* chat-core owns the mention infrastructure (parsing, autocomplete UI, keyboard
|
|
5
5
|
* behavior, composer insertion, message text rendering) but knows nothing about
|
|
6
|
-
* what a "user" or "
|
|
6
|
+
* what a "user" or "entity" is. The consumer parameterizes `TKind` to its own
|
|
7
7
|
* union and supplies one `MentionProvider` per kind.
|
|
8
8
|
*
|
|
9
|
-
* Wire format
|
|
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
12
|
*/
|
|
13
13
|
import type { ReactNode } from 'react';
|
|
14
14
|
/**
|
|
15
|
-
* Resolved mention
|
|
15
|
+
* Resolved mention — the value that ends up in the wire token after the user
|
|
16
16
|
* selects an autocomplete result.
|
|
17
17
|
*
|
|
18
18
|
* `kind` is the discriminator supplied by the consumer (e.g. `'member'`, `'tag'`); `id` is the
|
|
@@ -38,17 +38,17 @@ export type ParsedSegment<TKind extends string = string> = {
|
|
|
38
38
|
/**
|
|
39
39
|
* Provider supplying autocomplete results for one mention kind.
|
|
40
40
|
*
|
|
41
|
-
* - `kind`
|
|
41
|
+
* - `kind` — the discriminator. Must match `MentionRef.kind` for results
|
|
42
42
|
* returned by `search`.
|
|
43
|
-
* - `label`
|
|
44
|
-
* - `search`
|
|
43
|
+
* - `label` — human-readable label for the section / tab.
|
|
44
|
+
* - `search` — async query. Receives the current query string (after the
|
|
45
45
|
* trigger character), the consumer-supplied `context`, and an optional
|
|
46
46
|
* `signal` for cancellation. Returns up to whatever limit the provider
|
|
47
47
|
* chooses; chat-core renders all returned results.
|
|
48
|
-
* - `renderResult`
|
|
48
|
+
* - `renderResult` — optional custom row UI. When omitted, the autocomplete
|
|
49
49
|
* renders the `displayText` plain.
|
|
50
50
|
*
|
|
51
|
-
* `TContext` is consumer-owned
|
|
51
|
+
* `TContext` is consumer-owned — pass anything you need inside `search`
|
|
52
52
|
* (Firestore db, current user id, surface-specific filters). chat-core never
|
|
53
53
|
* inspects it.
|
|
54
54
|
*/
|
|
@@ -67,7 +67,7 @@ export type MentionProvider<TKind extends string = string, TContext = unknown> =
|
|
|
67
67
|
* recent picks when the user opens the dropdown without typing a query
|
|
68
68
|
* (or after typing fewer than the configured minimum characters).
|
|
69
69
|
*
|
|
70
|
-
* `getRecent` MAY be async
|
|
70
|
+
* `getRecent` MAY be async — the autocomplete renders a spinner while it
|
|
71
71
|
* resolves. `recordUse` is fired after a successful selection so consumers
|
|
72
72
|
* can persist usage.
|
|
73
73
|
*/
|
|
@@ -80,8 +80,8 @@ export type RecentMentionsAdapter<TKind extends string = string> = {
|
|
|
80
80
|
* text buffer. Tracked in component state so positionally-collocated mentions
|
|
81
81
|
* with the same display string disambiguate on send.
|
|
82
82
|
*
|
|
83
|
-
* - `start` / `end`
|
|
84
|
-
* - `ref`
|
|
83
|
+
* - `start` / `end` — character offsets into the current textarea value.
|
|
84
|
+
* - `ref` — the resolved MentionRef.
|
|
85
85
|
*/
|
|
86
86
|
export type MentionAnchor<TKind extends string = string> = {
|
|
87
87
|
start: number;
|
package/dist/mentions/types.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* chat-core owns the mention infrastructure (parsing, autocomplete UI, keyboard
|
|
5
5
|
* behavior, composer insertion, message text rendering) but knows nothing about
|
|
6
|
-
* what a "user" or "
|
|
6
|
+
* what a "user" or "entity" is. The consumer parameterizes `TKind` to its own
|
|
7
7
|
* union and supplies one `MentionProvider` per kind.
|
|
8
8
|
*
|
|
9
|
-
* Wire format
|
|
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
12
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -28,13 +28,13 @@ export type ChatMessageV1 = {
|
|
|
28
28
|
* Access mode controls how chat-core decides whether the current user
|
|
29
29
|
* can read/write a thread.
|
|
30
30
|
*
|
|
31
|
-
* - "firestore-rules"
|
|
31
|
+
* - "firestore-rules" — chat-core trusts Firestore rules. canAccessThread
|
|
32
32
|
* returns true for any signed-in user; if rules deny, onSnapshot will
|
|
33
33
|
* surface permission-denied. Use this when access depends on data the
|
|
34
|
-
* client doesn't reliably know up-front (
|
|
34
|
+
* client doesn't reliably know up-front (entity membership, invite
|
|
35
35
|
* participation, etc.).
|
|
36
36
|
*
|
|
37
|
-
* - "explicit-allowlist"
|
|
37
|
+
* - "explicit-allowlist" — chat-core enforces access client-side via
|
|
38
38
|
* threadAllowedUserIds. The list is required in this mode. Use this
|
|
39
39
|
* when the consumer already knows the participants (admin/support
|
|
40
40
|
* threads).
|
|
@@ -77,7 +77,7 @@ export type ChatCoreConfig = {
|
|
|
77
77
|
*
|
|
78
78
|
* `buildUploadPath` and `buildUploadMetadata` receive the userId and
|
|
79
79
|
* attachmentId so consumers can interpolate them per their own conventions.
|
|
80
|
-
* chat-core does not interpret `originId`
|
|
80
|
+
* chat-core does not interpret `originId` — it forwards it via callbacks
|
|
81
81
|
* and uses it for adapter identity only.
|
|
82
82
|
*/
|
|
83
83
|
export type ChatUploadAdapter = {
|
|
@@ -112,7 +112,7 @@ export type ChatAttachmentConfig = {
|
|
|
112
112
|
* doc with the caption text + reply pointer. The processor will create the
|
|
113
113
|
* message doc itself after media moderation succeeds.
|
|
114
114
|
*
|
|
115
|
-
* No message doc is created at this point
|
|
115
|
+
* No message doc is created at this point — Composer should render an
|
|
116
116
|
* optimistic local "uploading" state until the listener delivers the real
|
|
117
117
|
* message after processing completes.
|
|
118
118
|
*/
|
|
@@ -134,7 +134,7 @@ export type SendAttachmentFn = (input: SendAttachmentInput) => Promise<void>;
|
|
|
134
134
|
* mention tokens out of `text`.
|
|
135
135
|
*
|
|
136
136
|
* Generic over `TKind` and `TContext` is intentionally NOT exposed here at
|
|
137
|
-
* the type level
|
|
137
|
+
* the type level — `ChatCoreConfig` would have to become generic too, which
|
|
138
138
|
* cascades. Instead this type accepts permissive `string`-keyed providers;
|
|
139
139
|
* consumers binding stricter kind unions narrow at the call site via their
|
|
140
140
|
* provider definitions.
|
|
@@ -171,14 +171,14 @@ export type MessageRendererRegistry = Record<string, MessageRenderer>;
|
|
|
171
171
|
export declare const GROUP_GAP_SEC = 120;
|
|
172
172
|
/**
|
|
173
173
|
* 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
|
|
174
|
+
* Returns null if the sender is unknown or the cache hasn't loaded yet —
|
|
175
175
|
* chat-core will render a stable fallback ("User") in that case.
|
|
176
176
|
*/
|
|
177
177
|
export type ChatNameResolver = (senderId: string) => string | null;
|
|
178
178
|
/**
|
|
179
179
|
* Optional pre-warm callback. chat-core calls this with the deduped list of
|
|
180
180
|
* senderIds visible in the current message page so the consuming app can
|
|
181
|
-
* batch-fetch names into its cache. Implementations should be idempotent
|
|
181
|
+
* batch-fetch names into its cache. Implementations should be idempotent —
|
|
182
182
|
* the same id list will be passed across re-renders.
|
|
183
183
|
*/
|
|
184
184
|
export type ChatPrewarmSenders = (senderIds: string[]) => void;
|
package/package.json
CHANGED