@runtypelabs/persona 4.25.0 → 4.26.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/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/{types-Db61aI9J.d.cts → types-BwKTZhg9.d.cts} +14 -0
- package/dist/animations/{types-Db61aI9J.d.ts → types-BwKTZhg9.d.ts} +14 -0
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/animations-extra.d.cts +14 -0
- package/dist/animations-extra.d.ts +14 -0
- package/dist/approval-ui-QAKWNFNM.js +1 -0
- package/dist/approval-ui.cjs +2 -2
- package/dist/approval-ui.d.cts +180 -8
- package/dist/approval-ui.d.ts +180 -8
- package/dist/approval-ui.js +2 -2
- package/dist/{artifacts-ui-IGB5YKLO.js → artifacts-ui-NJGMM27I.js} +1 -1
- package/dist/artifacts-ui.cjs +4 -4
- package/dist/artifacts-ui.d.cts +180 -8
- package/dist/artifacts-ui.d.ts +180 -8
- package/dist/artifacts-ui.js +5 -5
- package/dist/chunk-2ANTRKTV.js +1 -0
- package/dist/chunk-4HPTPUC6.js +1 -0
- package/dist/chunk-6V3MNEKB.js +1 -0
- package/dist/chunk-HGUCGM3K.js +9 -0
- package/dist/chunk-IO5VVUKP.js +3 -0
- package/dist/chunk-J4J3Y2P2.js +1 -0
- package/dist/chunk-K6HKIP5K.js +1 -0
- package/dist/chunk-K7NA7G7J.js +1 -0
- package/dist/chunk-MXUTS3LB.js +1 -0
- package/dist/chunk-PDPVORUF.js +1 -0
- package/dist/chunk-QPPJUSZH.js +1 -0
- package/dist/chunk-QRKGQPU7.js +1 -0
- package/dist/chunk-S6PBWE75.js +1 -0
- package/dist/chunk-T7QM7YMF.js +1 -0
- package/dist/chunk-TR2H475E.js +1 -0
- package/dist/chunk-UPO4GUFC.js +1 -0
- package/dist/chunk-ZC66NAIR.js +1 -0
- package/dist/client-history-YPEG45Q4.js +1 -0
- package/dist/client-history.js +1 -0
- package/dist/client-stream-42FOI3EC.js +4 -0
- package/dist/client-stream.js +5 -0
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.js +1 -1
- package/dist/context-mentions-E7HJYWO6.js +161 -0
- package/dist/{context-mentions-inline-I2RDEBAK.js → context-mentions-inline-QVESLW55.js} +1 -1
- package/dist/context-mentions.cjs +7 -7
- package/dist/context-mentions.d.cts +180 -8
- package/dist/context-mentions.d.ts +180 -8
- package/dist/context-mentions.js +8 -8
- package/dist/event-stream-view-FOIJHFQO.js +1 -0
- package/dist/event-stream-view.cjs +1 -1
- package/dist/event-stream-view.d.cts +183 -31
- package/dist/event-stream-view.d.ts +183 -31
- package/dist/event-stream-view.js +1 -1
- package/dist/forms-ui.d.cts +221 -667
- package/dist/forms-ui.d.ts +221 -667
- package/dist/history-shell-QDQ44PSE.js +3 -0
- package/dist/history-shell.js +3 -0
- package/dist/{history-view-BD6OXLNA.js → history-view-NCFBI5GR.js} +2 -2
- package/dist/history-view.cjs +2 -2
- package/dist/history-view.d.cts +35 -1
- package/dist/history-view.d.ts +35 -1
- package/dist/history-view.js +2 -2
- package/dist/index.cjs +80 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +227 -738
- package/dist/index.d.ts +227 -738
- package/dist/index.global.js +3 -215
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +81 -75
- package/dist/index.js.map +1 -1
- package/dist/install.global.js +1 -1
- package/dist/install.global.js.map +1 -1
- package/dist/launcher.global.js +3 -67
- package/dist/launcher.global.js.map +1 -1
- package/dist/markdown-parsers.js +22 -22
- package/dist/runtype-tts-entry-NFBVWR7N.js +1 -0
- package/dist/runtype-tts.js +1 -1
- package/dist/session-actions-ISSKSI66.js +1 -0
- package/dist/session-actions.js +1 -0
- package/dist/session-reconnect.d.cts +180 -8
- package/dist/session-reconnect.d.ts +180 -8
- package/dist/smart-dom-reader.cjs +13 -13
- package/dist/smart-dom-reader.d.cts +180 -8
- package/dist/smart-dom-reader.d.ts +180 -8
- package/dist/smart-dom-reader.js +11 -11
- package/dist/theme-editor-preview.cjs +116 -98
- package/dist/theme-editor-preview.d.cts +182 -8
- package/dist/theme-editor-preview.d.ts +182 -8
- package/dist/theme-editor-preview.js +49 -54
- package/dist/theme-editor.cjs +2 -2
- package/dist/theme-editor.d.cts +181 -23
- package/dist/theme-editor.d.ts +181 -23
- package/dist/theme-editor.js +2 -2
- package/dist/theme-reference.d.cts +14 -0
- package/dist/theme-reference.d.ts +14 -0
- package/dist/ui-extras-entry-WAYFKVNW.js +3 -0
- package/dist/ui-extras.js +72 -0
- package/dist/voice-runtime-UOQOFAFY.js +17 -0
- package/dist/voice-runtime.cjs +17 -1
- package/dist/voice-runtime.d.cts +11650 -232
- package/dist/voice-runtime.d.ts +11650 -232
- package/dist/voice-runtime.js +17 -1
- package/dist/voice-worklet-player.cjs +19 -4
- package/dist/voice-worklet-player.d.cts +9 -10
- package/dist/voice-worklet-player.d.ts +9 -10
- package/dist/voice-worklet-player.js +19 -4
- package/dist/webmcp-polyfill.js +1 -1
- package/dist/webmcp-runtime-V6ZWW3PI.js +6 -0
- package/dist/webmcp-runtime.cjs +2 -2
- package/dist/webmcp-runtime.d.cts +1 -33
- package/dist/webmcp-runtime.d.ts +1 -33
- package/dist/webmcp-runtime.js +2 -2
- package/dist/widget.css +1 -1
- package/package.json +11 -5
- package/src/approval-paused-tool-settle.test.ts +221 -0
- package/src/client-approve.test.ts +311 -0
- package/src/client-history-eager.ts +9 -0
- package/src/client-history-loader.ts +23 -0
- package/src/client-history.ts +579 -0
- package/src/client-resume.ts +177 -0
- package/src/client-stream-eager.ts +12 -0
- package/src/client-stream-loader.ts +25 -0
- package/src/client-stream.ts +1880 -0
- package/src/client.test.ts +31 -1
- package/src/client.ts +293 -2607
- package/src/components/approval-actions.test.ts +27 -0
- package/src/components/approval-actions.ts +27 -3
- package/src/components/message-bubble.test.ts +19 -0
- package/src/components/message-bubble.ts +2 -0
- package/src/components/registry.ts +6 -6
- package/src/components/tool-bubble.test.ts +9 -0
- package/src/components/tool-bubble.ts +1 -0
- package/src/history-shell-bundle.test.ts +54 -0
- package/src/history-shell-eager.ts +12 -0
- package/src/history-shell-loader.ts +27 -0
- package/src/history-shell.ts +2362 -0
- package/src/history-view-loader.ts +2 -0
- package/src/history-view.ts +3 -0
- package/src/index-core.ts +6 -0
- package/src/index-global.ts +90 -248
- package/src/index.ts +13 -0
- package/src/install.ts +6 -4
- package/src/internal/runtype-history-provider.test.ts +1 -0
- package/src/internal/runtype-history-provider.ts +28 -13
- package/src/plugins/registry.ts +8 -8
- package/src/session-actions-chunk.test.ts +55 -0
- package/src/session-actions-eager.ts +11 -0
- package/src/session-actions-loader.ts +37 -0
- package/src/session-actions.ts +909 -0
- package/src/session-history.test.ts +3 -1
- package/src/session.ts +852 -1536
- package/src/session.voice.test.ts +1170 -5
- package/src/styles/widget.css +58 -0
- package/src/theme-editor/state.ts +91 -91
- package/src/types.ts +198 -5
- package/src/ui-ask-user-sheet.ts +382 -0
- package/src/ui-extras-eager.ts +10 -0
- package/src/ui-extras-entry.ts +9 -0
- package/src/ui-extras-loader.ts +26 -0
- package/src/ui.artifact-rail-resize.test.ts +2 -1
- package/src/ui.ask-user-chunk.test.ts +93 -0
- package/src/ui.history-chunk.test.ts +2 -1
- package/src/ui.history-config-provider.test.ts +2 -1
- package/src/ui.history-confirm-fallback.test.ts +142 -0
- package/src/ui.history-controller.test.ts +2 -1
- package/src/ui.history-lifecycle.test.ts +2 -1
- package/src/ui.history-render-hooks.test.ts +2 -1
- package/src/ui.history-shell.test.ts +2 -1
- package/src/ui.rail-overlay.test.ts +2 -1
- package/src/ui.rail-resize.test.ts +2 -1
- package/src/ui.rail-trigger-pending.test.ts +2 -1
- package/src/ui.ts +340 -2770
- package/src/utils/attachment-manager.ts +67 -67
- package/src/utils/constants.ts +3 -0
- package/src/utils/context-mention-controller.ts +323 -323
- package/src/utils/context-mention-manager.ts +40 -40
- package/src/utils/context-mention-orchestrator.ts +28 -0
- package/src/utils/event-stream-buffer.ts +50 -50
- package/src/utils/event-stream-store.ts +43 -43
- package/src/utils/throughput-tracker.ts +34 -34
- package/src/utils/virtual-scroller.ts +67 -67
- package/src/utils/visitor-store.test.ts +50 -0
- package/src/utils/visitor-store.ts +23 -5
- package/src/voice/__fixtures__/voice-wire/README.md +1 -0
- package/src/voice/__fixtures__/voice-wire/client/cancel.json +3 -0
- package/src/voice/__fixtures__/voice-wire/client/context.json +4 -0
- package/src/voice/__fixtures__/voice-wire/client/delegation_result.json +6 -0
- package/src/voice/__fixtures__/voice-wire/client/delegation_update.json +6 -0
- package/src/voice/__fixtures__/voice-wire/client/ping.json +3 -0
- package/src/voice/__fixtures__/voice-wire/client/playback_progress.json +5 -0
- package/src/voice/__fixtures__/voice-wire/client/start.json +3 -0
- package/src/voice/__fixtures__/voice-wire/server/artifact.json +11 -0
- package/src/voice/__fixtures__/voice-wire/server/attached.json +4 -0
- package/src/voice/__fixtures__/voice-wire/server/audio_clear.json +4 -0
- package/src/voice/__fixtures__/voice-wire/server/audio_end.json +3 -0
- package/src/voice/__fixtures__/voice-wire/server/delegation_cancelled.json +5 -0
- package/src/voice/__fixtures__/voice-wire/server/delegation_completed.json +8 -0
- package/src/voice/__fixtures__/voice-wire/server/delegation_started.json +15 -0
- package/src/voice/__fixtures__/voice-wire/server/error.json +6 -0
- package/src/voice/__fixtures__/voice-wire/server/metrics.json +10 -0
- package/src/voice/__fixtures__/voice-wire/server/pong.json +3 -0
- package/src/voice/__fixtures__/voice-wire/server/session_config.json +16 -0
- package/src/voice/__fixtures__/voice-wire/server/transcript_final.json +7 -0
- package/src/voice/__fixtures__/voice-wire/server/transcript_interim.json +4 -0
- package/src/voice/__fixtures__/voice-wire/server/transcript_partial.json +6 -0
- package/src/voice/__fixtures__/voice-wire/server/transcript_update.json +10 -0
- package/src/voice/__fixtures__/voice-wire/server/warning.json +5 -0
- package/src/voice/audio-playback-manager.test.ts +57 -0
- package/src/voice/audio-playback-manager.ts +120 -98
- package/src/voice/browser-voice-provider.ts +37 -37
- package/src/voice/fallback-speech-engine.ts +22 -16
- package/src/voice/keyed-voice-transcript.ts +314 -0
- package/src/voice/mic-state-styles.ts +182 -0
- package/src/voice/read-aloud-controller.ts +46 -44
- package/src/voice/runtype-speech-engine.ts +35 -33
- package/src/voice/runtype-voice-provider.ts +670 -189
- package/src/voice/session-voice-wiring.ts +266 -0
- package/src/voice/voice-delegation.test.ts +71 -0
- package/src/voice/voice-delegation.ts +364 -0
- package/src/voice/voice-turn-tracker.ts +6 -6
- package/src/voice/voice.test.ts +981 -8
- package/src/voice/worklet-playback-engine.test.ts +81 -0
- package/src/voice/worklet-playback-engine.ts +21 -3
- package/src/voice-runtime-loader.ts +4 -1
- package/src/voice-runtime.ts +7 -0
- package/src/webmcp-runtime-entry.ts +41 -39
- package/dist/approval-ui-3NMYNXBD.js +0 -1
- package/dist/chunk-5EIIHQLQ.js +0 -1
- package/dist/chunk-7CO4T5KB.js +0 -1
- package/dist/chunk-EFJBUH5F.js +0 -1
- package/dist/chunk-R2TMIMDI.js +0 -3
- package/dist/chunk-UTVLOTWB.js +0 -9
- package/dist/context-mentions-45MODWOY.js +0 -161
- package/dist/event-stream-view-GL3ADRY2.js +0 -1
- package/dist/runtype-tts-entry-UJAEF7NZ.js +0 -1
- package/dist/voice-runtime-7DA7MJH4.js +0 -1
- package/dist/webmcp-runtime-JI7T4QYF.js +0 -6
|
@@ -114,10 +114,10 @@ export class AttachmentManager {
|
|
|
114
114
|
AttachmentManagerConfig,
|
|
115
115
|
"onFileRejected" | "onAttachmentsChange" | "adapter"
|
|
116
116
|
>;
|
|
117
|
-
|
|
117
|
+
#previewsContainer: HTMLElement | null = null;
|
|
118
118
|
/** In-flight `adapter.add` per attachment id; aborted on remove/clear/destroy. */
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
#pendingAdds = new Map<string, AbortController>();
|
|
120
|
+
#destroyed = false;
|
|
121
121
|
|
|
122
122
|
constructor(config: AttachmentManagerConfig = {}) {
|
|
123
123
|
this.config = {
|
|
@@ -131,12 +131,12 @@ export class AttachmentManager {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/** True when the host supplied an adapter (tiles then show upload state). */
|
|
134
|
-
|
|
134
|
+
#hasCustomAdapter(): boolean {
|
|
135
135
|
return typeof this.config.adapter?.add === "function";
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
return this
|
|
138
|
+
#adapter(): AgentWidgetAttachmentAdapter {
|
|
139
|
+
return this.#hasCustomAdapter()
|
|
140
140
|
? (this.config.adapter as AgentWidgetAttachmentAdapter)
|
|
141
141
|
: BASE64_ADAPTER;
|
|
142
142
|
}
|
|
@@ -145,7 +145,7 @@ export class AttachmentManager {
|
|
|
145
145
|
* Set the previews container element
|
|
146
146
|
*/
|
|
147
147
|
setPreviewsContainer(container: HTMLElement | null): void {
|
|
148
|
-
this
|
|
148
|
+
this.#previewsContainer = container;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
/**
|
|
@@ -153,14 +153,14 @@ export class AttachmentManager {
|
|
|
153
153
|
* rebuild swaps the footer, so pending attachments must follow it.
|
|
154
154
|
*/
|
|
155
155
|
remountPreviews(container: HTMLElement | null): void {
|
|
156
|
-
this
|
|
156
|
+
this.#previewsContainer = container;
|
|
157
157
|
if (container) {
|
|
158
158
|
container.innerHTML = "";
|
|
159
159
|
for (const attachment of this.attachments) {
|
|
160
|
-
this
|
|
160
|
+
this.#renderPreview(attachment);
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
this
|
|
163
|
+
this.#updatePreviewsVisibility();
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
/**
|
|
@@ -236,7 +236,7 @@ export class AttachmentManager {
|
|
|
236
236
|
* Handle an array of files (e.g., clipboard image paste)
|
|
237
237
|
*/
|
|
238
238
|
async handleFiles(files: readonly File[]): Promise<void> {
|
|
239
|
-
if (!files.length || this
|
|
239
|
+
if (!files.length || this.#destroyed) return;
|
|
240
240
|
|
|
241
241
|
const accepted: PendingAttachment[] = [];
|
|
242
242
|
for (const file of files) {
|
|
@@ -265,18 +265,18 @@ export class AttachmentManager {
|
|
|
265
265
|
file,
|
|
266
266
|
previewUrl: isImageFile(file) ? URL.createObjectURL(file) : null,
|
|
267
267
|
contentPart: null,
|
|
268
|
-
status: this
|
|
269
|
-
progress: this
|
|
268
|
+
status: this.#hasCustomAdapter() ? "uploading" : "processing",
|
|
269
|
+
progress: this.#hasCustomAdapter() ? 0 : undefined
|
|
270
270
|
};
|
|
271
271
|
this.attachments.push(attachment);
|
|
272
|
-
this
|
|
272
|
+
this.#renderPreview(attachment);
|
|
273
273
|
accepted.push(attachment);
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
-
this
|
|
277
|
-
this
|
|
276
|
+
this.#updatePreviewsVisibility();
|
|
277
|
+
this.#notify();
|
|
278
278
|
|
|
279
|
-
await Promise.all(accepted.map((attachment) => this
|
|
279
|
+
await Promise.all(accepted.map((attachment) => this.#runAdd(attachment)));
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
/**
|
|
@@ -284,24 +284,24 @@ export class AttachmentManager {
|
|
|
284
284
|
* completions from an aborted or removed attachment write no state and log
|
|
285
285
|
* nothing: the user already moved on.
|
|
286
286
|
*/
|
|
287
|
-
|
|
287
|
+
async #runAdd(attachment: PendingAttachment): Promise<void> {
|
|
288
288
|
const controller = new AbortController();
|
|
289
|
-
this
|
|
289
|
+
this.#pendingAdds.set(attachment.id, controller);
|
|
290
290
|
|
|
291
291
|
const stale = (): boolean =>
|
|
292
|
-
this
|
|
292
|
+
this.#destroyed ||
|
|
293
293
|
controller.signal.aborted ||
|
|
294
|
-
this
|
|
294
|
+
this.#pendingAdds.get(attachment.id) !== controller ||
|
|
295
295
|
!this.attachments.includes(attachment);
|
|
296
296
|
|
|
297
297
|
try {
|
|
298
|
-
const part = await this
|
|
298
|
+
const part = await this.#adapter().add(attachment.file, {
|
|
299
299
|
signal: controller.signal,
|
|
300
300
|
onProgress: (progress) => {
|
|
301
301
|
if (stale() || attachment.status !== "uploading") return;
|
|
302
302
|
attachment.progress = clampProgress(progress);
|
|
303
|
-
this
|
|
304
|
-
this
|
|
303
|
+
this.#updatePreview(attachment);
|
|
304
|
+
this.#notify();
|
|
305
305
|
}
|
|
306
306
|
});
|
|
307
307
|
if (stale()) return;
|
|
@@ -316,31 +316,31 @@ export class AttachmentManager {
|
|
|
316
316
|
attachment.error =
|
|
317
317
|
error instanceof Error ? error.message : String(error ?? "Upload failed");
|
|
318
318
|
} finally {
|
|
319
|
-
if (this
|
|
320
|
-
this
|
|
319
|
+
if (this.#pendingAdds.get(attachment.id) === controller) {
|
|
320
|
+
this.#pendingAdds.delete(attachment.id);
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
this
|
|
324
|
-
this
|
|
323
|
+
this.#updatePreview(attachment);
|
|
324
|
+
this.#notify();
|
|
325
325
|
}
|
|
326
326
|
|
|
327
327
|
/** Retry a failed attachment from its error tile. */
|
|
328
328
|
retryAttachment(id: string): void {
|
|
329
329
|
const attachment = this.attachments.find((a) => a.id === id);
|
|
330
|
-
if (!attachment || attachment.status !== "error" || this
|
|
331
|
-
attachment.status = this
|
|
332
|
-
attachment.progress = this
|
|
330
|
+
if (!attachment || attachment.status !== "error" || this.#destroyed) return;
|
|
331
|
+
attachment.status = this.#hasCustomAdapter() ? "uploading" : "processing";
|
|
332
|
+
attachment.progress = this.#hasCustomAdapter() ? 0 : undefined;
|
|
333
333
|
attachment.error = undefined;
|
|
334
|
-
this
|
|
335
|
-
this
|
|
336
|
-
void this
|
|
334
|
+
this.#updatePreview(attachment);
|
|
335
|
+
this.#notify();
|
|
336
|
+
void this.#runAdd(attachment);
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
/** Abort an in-flight add without touching the attachment's own state. */
|
|
340
|
-
|
|
341
|
-
const controller = this
|
|
340
|
+
#abortAdd(id: string): void {
|
|
341
|
+
const controller = this.#pendingAdds.get(id);
|
|
342
342
|
if (!controller) return;
|
|
343
|
-
this
|
|
343
|
+
this.#pendingAdds.delete(id);
|
|
344
344
|
controller.abort();
|
|
345
345
|
}
|
|
346
346
|
|
|
@@ -353,7 +353,7 @@ export class AttachmentManager {
|
|
|
353
353
|
if (index === -1) return;
|
|
354
354
|
|
|
355
355
|
const attachment = this.attachments[index];
|
|
356
|
-
this
|
|
356
|
+
this.#abortAdd(id);
|
|
357
357
|
|
|
358
358
|
// Revoke the object URL to free memory (only for images)
|
|
359
359
|
if (attachment.previewUrl) {
|
|
@@ -364,7 +364,7 @@ export class AttachmentManager {
|
|
|
364
364
|
this.attachments.splice(index, 1);
|
|
365
365
|
|
|
366
366
|
// Remove from DOM
|
|
367
|
-
const previewEl = this
|
|
367
|
+
const previewEl = this.#previewsContainer?.querySelector(
|
|
368
368
|
`[data-attachment-id="${id}"]`
|
|
369
369
|
);
|
|
370
370
|
if (previewEl) {
|
|
@@ -372,14 +372,14 @@ export class AttachmentManager {
|
|
|
372
372
|
}
|
|
373
373
|
|
|
374
374
|
if (attachment.status === "ready" && attachment.contentPart) {
|
|
375
|
-
this
|
|
375
|
+
this.#releasePart(attachment.contentPart);
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
-
this
|
|
379
|
-
this
|
|
378
|
+
this.#updatePreviewsVisibility();
|
|
379
|
+
this.#notify();
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
|
|
382
|
+
#releasePart(part: ContentPart): void {
|
|
383
383
|
const remove = this.config.adapter?.remove;
|
|
384
384
|
if (!remove) return;
|
|
385
385
|
try {
|
|
@@ -401,47 +401,47 @@ export class AttachmentManager {
|
|
|
401
401
|
*/
|
|
402
402
|
clearAttachments(): void {
|
|
403
403
|
for (const attachment of this.attachments) {
|
|
404
|
-
this
|
|
404
|
+
this.#abortAdd(attachment.id);
|
|
405
405
|
if (attachment.previewUrl) {
|
|
406
406
|
URL.revokeObjectURL(attachment.previewUrl);
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
this.attachments = [];
|
|
411
|
-
this
|
|
411
|
+
this.#pendingAdds.clear();
|
|
412
412
|
|
|
413
413
|
// Clear the previews container
|
|
414
|
-
if (this
|
|
415
|
-
this
|
|
414
|
+
if (this.#previewsContainer) {
|
|
415
|
+
this.#previewsContainer.innerHTML = "";
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
-
this
|
|
419
|
-
this
|
|
418
|
+
this.#updatePreviewsVisibility();
|
|
419
|
+
this.#notify();
|
|
420
420
|
}
|
|
421
421
|
|
|
422
422
|
/** Abort every in-flight upload and stop accepting new work. */
|
|
423
423
|
destroy(): void {
|
|
424
|
-
if (this
|
|
425
|
-
this
|
|
426
|
-
for (const controller of this
|
|
427
|
-
this
|
|
424
|
+
if (this.#destroyed) return;
|
|
425
|
+
this.#destroyed = true;
|
|
426
|
+
for (const controller of this.#pendingAdds.values()) controller.abort();
|
|
427
|
+
this.#pendingAdds.clear();
|
|
428
428
|
for (const attachment of this.attachments) {
|
|
429
429
|
if (attachment.previewUrl) URL.revokeObjectURL(attachment.previewUrl);
|
|
430
430
|
}
|
|
431
431
|
this.attachments = [];
|
|
432
|
-
this
|
|
432
|
+
this.#previewsContainer = null;
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
-
|
|
436
|
-
if (this
|
|
435
|
+
#notify(): void {
|
|
436
|
+
if (this.#destroyed) return;
|
|
437
437
|
this.config.onAttachmentsChange?.(this.getAttachments());
|
|
438
438
|
}
|
|
439
439
|
|
|
440
440
|
/**
|
|
441
441
|
* Render a preview for an attachment (image thumbnail or file icon)
|
|
442
442
|
*/
|
|
443
|
-
|
|
444
|
-
if (!this
|
|
443
|
+
#renderPreview(attachment: PendingAttachment): void {
|
|
444
|
+
if (!this.#previewsContainer) return;
|
|
445
445
|
|
|
446
446
|
const isImage = isImageFile(attachment.file);
|
|
447
447
|
|
|
@@ -572,20 +572,20 @@ export class AttachmentManager {
|
|
|
572
572
|
});
|
|
573
573
|
|
|
574
574
|
previewWrapper.appendChild(removeBtn);
|
|
575
|
-
this
|
|
576
|
-
this
|
|
575
|
+
this.#previewsContainer.appendChild(previewWrapper);
|
|
576
|
+
this.#applyPreviewState(previewWrapper, attachment);
|
|
577
577
|
}
|
|
578
578
|
|
|
579
579
|
/** Repaint only the status layer of a live tile; the thumbnail is untouched. */
|
|
580
|
-
|
|
581
|
-
const tile = this
|
|
580
|
+
#updatePreview(attachment: PendingAttachment): void {
|
|
581
|
+
const tile = this.#previewsContainer?.querySelector<HTMLElement>(
|
|
582
582
|
`[data-attachment-id="${attachment.id}"]`
|
|
583
583
|
);
|
|
584
584
|
if (!tile) return;
|
|
585
|
-
this
|
|
585
|
+
this.#applyPreviewState(tile, attachment);
|
|
586
586
|
}
|
|
587
587
|
|
|
588
|
-
|
|
588
|
+
#applyPreviewState(
|
|
589
589
|
tile: HTMLElement,
|
|
590
590
|
attachment: PendingAttachment
|
|
591
591
|
): void {
|
|
@@ -611,9 +611,9 @@ export class AttachmentManager {
|
|
|
611
611
|
/**
|
|
612
612
|
* Update the visibility of the previews container
|
|
613
613
|
*/
|
|
614
|
-
|
|
615
|
-
if (!this
|
|
616
|
-
this
|
|
614
|
+
#updatePreviewsVisibility(): void {
|
|
615
|
+
if (!this.#previewsContainer) return;
|
|
616
|
+
this.#previewsContainer.style.display =
|
|
617
617
|
this.attachments.length > 0 ? "flex" : "none";
|
|
618
618
|
}
|
|
619
619
|
|
package/src/utils/constants.ts
CHANGED