@aparte/core 0.3.0-alpha.0 → 0.5.0-alpha.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/README.md +26 -2
- package/dist/client/aparte-client.d.ts +7 -1
- package/dist/client/aparte-client.d.ts.map +1 -1
- package/dist/components/bubble/aparte-chat-bubble.d.ts +26 -2
- package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
- package/dist/components/chat/aparte-chat.d.ts +13 -0
- package/dist/components/chat/aparte-chat.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-attachments.d.ts +3 -2
- package/dist/components/composer/aparte-composer-attachments.d.ts.map +1 -1
- package/dist/components/viewport/aparte-chat-viewport.d.ts +17 -4
- package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
- package/dist/config/aparte-config.d.ts +64 -7
- package/dist/config/aparte-config.d.ts.map +1 -1
- package/dist/config/icon-provider.d.ts +21 -21
- package/dist/config/icon-provider.d.ts.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/conversations/conversation-controller.d.ts.map +1 -1
- package/dist/custom-elements.json +3435 -3000
- package/dist/host/aparte-chat-host.d.ts +58 -1
- package/dist/host/aparte-chat-host.d.ts.map +1 -1
- package/dist/{index-CW2BCAqn.js → index-Dn7TH14G.js} +282 -81
- package/dist/index-Dn7TH14G.js.map +1 -0
- package/dist/index.css +75 -8
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +216 -62
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +3 -1
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js +34 -30
- package/dist/index.node.js.map +1 -1
- package/dist/primitives/select/aparte-optgroup.d.ts +2 -0
- package/dist/primitives/select/aparte-optgroup.d.ts.map +1 -1
- package/dist/primitives/select/aparte-select.d.ts +2 -0
- package/dist/primitives/select/aparte-select.d.ts.map +1 -1
- package/dist/renderers/index.d.ts +1 -1
- package/dist/renderers/index.d.ts.map +1 -1
- package/dist/renderers/segment-renderers.d.ts +23 -0
- package/dist/renderers/segment-renderers.d.ts.map +1 -1
- package/dist/types/imperative-api.d.ts +13 -0
- package/dist/types/imperative-api.d.ts.map +1 -1
- package/dist/types/models.d.ts +56 -9
- package/dist/types/models.d.ts.map +1 -1
- package/dist/utils/files-to-attachments.d.ts +27 -0
- package/dist/utils/files-to-attachments.d.ts.map +1 -0
- package/dist/utils/is-awaiting-reply.d.ts +22 -0
- package/dist/utils/is-awaiting-reply.d.ts.map +1 -0
- package/package.json +8 -1
- package/dist/index-CW2BCAqn.js.map +0 -1
|
@@ -78,6 +78,23 @@ export declare class AparteChatHost {
|
|
|
78
78
|
private _pendingSiblings?;
|
|
79
79
|
/** Abort handle for an in-flight {@link streamTokens} loop. */
|
|
80
80
|
private _streamAbort?;
|
|
81
|
+
/** Segment chunks written to the bubble, awaiting one coalesced state sync. */
|
|
82
|
+
/**
|
|
83
|
+
* Buffered segment text, per segment id, as `base + text` — an **absolute**
|
|
84
|
+
* target, never a delta.
|
|
85
|
+
*
|
|
86
|
+
* Why absolute: the immediate paint (`appendToSegment` below) writes through the
|
|
87
|
+
* viewport into the very segment object the framework list holds — they are the
|
|
88
|
+
* same object, handed to both by `addSegment`. A delta added at flush time would
|
|
89
|
+
* therefore land on content that already contains it, and every chunk came out
|
|
90
|
+
* doubled. `base` is captured before the paint, so whoever mutates the shared
|
|
91
|
+
* object in between cannot change the result.
|
|
92
|
+
*/
|
|
93
|
+
private readonly _segmentBuffer;
|
|
94
|
+
/** {@link streamTokens} text written to the bubble, awaiting the same sync. */
|
|
95
|
+
private _tokenBuffer;
|
|
96
|
+
/** Handle of the scheduled coalesced sync, or null when none is pending. */
|
|
97
|
+
private _flushHandle;
|
|
81
98
|
private _conversationId;
|
|
82
99
|
private _controller?;
|
|
83
100
|
private _teardown;
|
|
@@ -129,8 +146,35 @@ export declare class AparteChatHost {
|
|
|
129
146
|
updateSegment(segmentId: string, updates: Partial<AparteSegment>): void;
|
|
130
147
|
/** Remove a transient segment (e.g. pipeline-waiting indicator). */
|
|
131
148
|
removeSegment(segmentId: string): void;
|
|
132
|
-
/**
|
|
149
|
+
/**
|
|
150
|
+
* Append text to a segment's content in the last message — the streaming path
|
|
151
|
+
* for thinking blocks, tool pills and any segment that grows token by token.
|
|
152
|
+
*
|
|
153
|
+
* Two writes, deliberately asymmetric:
|
|
154
|
+
* 1. straight into the bubble, every chunk, so the text appears immediately —
|
|
155
|
+
* the same direct path `appendToken` uses;
|
|
156
|
+
* 2. into the framework's message list, **coalesced to once per frame**.
|
|
157
|
+
*
|
|
158
|
+
* It used to do only (2), synchronously: a full list rebuild plus
|
|
159
|
+
* `setMessages` + `onMessagesChange` for every chunk, i.e. one complete
|
|
160
|
+
* framework render per token. At 60 tok/s from a local model that is unusable,
|
|
161
|
+
* and nothing in the imperative API hinted that `appendToSegment` cost so much
|
|
162
|
+
* more than `injectTokenStream`. Consumers had to write their own rAF batcher.
|
|
163
|
+
*
|
|
164
|
+
* Any structural change flushes the buffer first (see
|
|
165
|
+
* {@link _flushStreamState}), so ordering is never observable.
|
|
166
|
+
*/
|
|
133
167
|
appendToSegment(segmentId: string, content: string): void;
|
|
168
|
+
/** Schedule the coalesced segment-state sync (idempotent within a frame). */
|
|
169
|
+
private _scheduleStreamFlush;
|
|
170
|
+
/**
|
|
171
|
+
* Write every buffered stream chunk — segment chunks and {@link streamTokens}
|
|
172
|
+
* text alike — into the framework's message list in **one** update. Called by
|
|
173
|
+
* the scheduled frame, and eagerly by any mutation that would otherwise observe
|
|
174
|
+
* a stale list (a new segment, a new message, a conversation swap): flushing
|
|
175
|
+
* first keeps the emitted order identical to the call order.
|
|
176
|
+
*/
|
|
177
|
+
private _flushStreamState;
|
|
134
178
|
/** Read the current message list. */
|
|
135
179
|
getMessages(): AparteMessage[];
|
|
136
180
|
/** Clear all messages + reset viewport state. */
|
|
@@ -148,8 +192,21 @@ export declare class AparteChatHost {
|
|
|
148
192
|
* appends each token, completes the message at the end. Per-framework
|
|
149
193
|
* wrappers adapt their native stream type (RxJS Observable, AsyncIterable,
|
|
150
194
|
* ReadableStream) into this.
|
|
195
|
+
*
|
|
196
|
+
* Each token reaches the bubble immediately and the framework's message list
|
|
197
|
+
* is synced **once per frame** (same discipline as {@link appendToSegment}),
|
|
198
|
+
* with a guaranteed flush before completion and on abort. Before that sync
|
|
199
|
+
* existed the two disagreed: the DOM had the reply, the framework list still
|
|
200
|
+
* held `content: ''` — so any re-render from state wiped it, and a custom
|
|
201
|
+
* bubble (which renders from that state) showed nothing at all.
|
|
151
202
|
*/
|
|
152
203
|
streamTokens(messageId: string, tokens: AsyncIterable<string>): Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Buffer a streamed token for the coalesced state sync. A different message id
|
|
206
|
+
* (a second stream started without stopping the first) flushes the previous
|
|
207
|
+
* one, so text never migrates between messages.
|
|
208
|
+
*/
|
|
209
|
+
private _bufferToken;
|
|
153
210
|
/** Abort an in-flight {@link streamTokens} loop. */
|
|
154
211
|
stopTokenStream(): void;
|
|
155
212
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aparte-chat-host.d.ts","sourceRoot":"","sources":["../../src/host/aparte-chat-host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,aAAa,EACb,aAAa,EAIhB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACH,4BAA4B,EAE/B,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"aparte-chat-host.d.ts","sourceRoot":"","sources":["../../src/host/aparte-chat-host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,aAAa,EACb,aAAa,EAIhB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACH,4BAA4B,EAE/B,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK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