@lostgradient/cinder 0.15.0 → 0.16.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/CHANGELOG.md +6 -0
- package/README.md +3 -3
- package/components.json +2 -143
- package/dist/components/access-gate/index.js +379 -327
- package/dist/components/alert-dialog/index.js +170 -172
- package/dist/components/confirm-dialog/index.js +170 -172
- package/dist/components/drawer/index.js +11 -11
- package/dist/components/focus-trap/index.d.ts +1 -0
- package/dist/components/focus-trap/index.js +171 -1
- package/dist/components/icons/index.d.ts +80 -1
- package/dist/components/icons/index.js +1256 -0
- package/dist/components/markdown-editor/index.js +170 -170
- package/dist/components/modal/index.js +20 -20
- package/dist/components/review-editor/index.js +170 -187
- package/dist/components/sheet/index.js +11 -11
- package/dist/components/sidebar/index.js +37 -37
- package/dist/index.d.ts +0 -8
- package/dist/index.js +23202 -30173
- package/dist/server/components/access-gate/index.js +7 -10
- package/dist/server/components/alert-dialog/index.js +4 -4
- package/dist/server/components/approval-card/index.js +6 -6
- package/dist/server/components/autocomplete/index.js +4 -4
- package/dist/server/components/choice-grid/index.js +2 -2
- package/dist/server/components/color-field/index.js +2 -2
- package/dist/server/components/combobox/index.js +3 -3
- package/dist/server/components/command-item/index.js +3 -5
- package/dist/server/components/command-menu/index.js +3 -5
- package/dist/server/components/confirm-dialog/index.js +4 -4
- package/dist/server/components/context-menu/index.js +7 -7
- package/dist/server/components/data-table/index.js +3 -3
- package/dist/server/components/date-picker/index.js +4 -4
- package/dist/server/components/date-range-field/index.js +4 -4
- package/dist/server/components/diff-viewer/index.js +9 -11
- package/dist/server/components/drawer/index.js +4 -4
- package/dist/server/components/dropdown/index.js +7 -7
- package/dist/server/components/faceted-filter-bar/index.js +2 -2
- package/dist/server/components/focus-trap/index.js +7 -2
- package/dist/server/components/icons/index.js +156 -0
- package/dist/server/components/inline-loading/index.js +1 -1
- package/dist/server/components/json-schema-editor/index.js +11 -13
- package/dist/server/components/load-more/index.js +2 -3
- package/dist/server/components/markdown-editor/index.js +13 -12
- package/dist/server/components/menu-bar/index.js +4 -4
- package/dist/server/components/modal/index.js +4 -4
- package/dist/server/components/popover/index.js +3 -3
- package/dist/server/components/review-editor/index.js +169 -122
- package/dist/server/components/schedule-builder/index.js +5 -5
- package/dist/server/components/schema-form/index.js +1 -1
- package/dist/server/components/segment/index.js +3 -3
- package/dist/server/components/segmented-control/index.js +4 -4
- package/dist/server/components/selection-popover/index.js +3 -3
- package/dist/server/components/sheet/index.js +3 -3
- package/dist/server/components/sidebar/index.js +4 -4
- package/dist/server/components/table/index.js +3 -3
- package/dist/server/components/tag-input/index.js +2 -2
- package/dist/server/index.js +272 -316
- package/dist/server/{index.server-dwwqssey.js → index.server-0qh3v3nq.js} +1 -1
- package/dist/server/index.server-25wmev4e.js +2 -0
- package/dist/server/{index.server-zdm63dt8.js → index.server-2c56kqws.js} +107 -25
- package/dist/server/{index.server-y4n8vc08.js → index.server-2pc5cv6c.js} +1 -1
- package/dist/server/{index.server-1vsv7ngz.js → index.server-3g76h7z7.js} +12 -2
- package/dist/server/{index.server-xz99aed4.js → index.server-45n4s30n.js} +12 -12
- package/dist/server/{index.server-zzd5wpbw.js → index.server-4dfs3xwn.js} +1 -1
- package/dist/server/{index.server-vhyjjx9z.js → index.server-4jkqgp17.js} +7 -9
- package/dist/server/{index.server-bmxbsk4y.js → index.server-51sxnete.js} +18 -18
- package/dist/server/{index.server-1bwvsnjk.js → index.server-6rv1rfwq.js} +37 -14
- package/dist/server/{index.server-np3c7kx0.js → index.server-7798gc22.js} +1 -1
- package/dist/server/{index.server-2m1kenak.js → index.server-7kjw6qw5.js} +1 -1
- package/dist/server/{index.server-tfftb7hs.js → index.server-7zpzspk6.js} +1 -1
- package/dist/server/{index.server-7yvpb6z7.js → index.server-894t97kv.js} +4 -4
- package/dist/server/{index.server-47v2fhp4.js → index.server-8b35ekqg.js} +1 -1
- package/dist/server/{index.server-j5hn2qds.js → index.server-8nm871y8.js} +80 -30
- package/dist/server/{index.server-h0cvwvhy.js → index.server-9drzqktm.js} +1 -1
- package/dist/server/{index.server-x9s4m9eg.js → index.server-agsdwg53.js} +1 -1
- package/dist/server/{index.server-hpeavvnq.js → index.server-b4gp066a.js} +1 -1
- package/dist/server/{index.server-gkazv439.js → index.server-bf7d81b4.js} +7 -7
- package/dist/server/{index.server-krqvnt6p.js → index.server-d4ft97bx.js} +4 -2
- package/dist/server/{index.server-t1x9h8cb.js → index.server-dg19y3m7.js} +1 -1
- package/dist/server/{index.server-jt1twhgk.js → index.server-dq0k0qf6.js} +10 -10
- package/dist/server/{index.server-pxq277t5.js → index.server-frb9e55d.js} +1 -1
- package/dist/server/{index.server-9kz37z89.js → index.server-g3726bja.js} +1 -1
- package/dist/server/index.server-gyzmkrnz.js +2 -0
- package/dist/server/{index.server-mr68brd6.js → index.server-jgdtsvz2.js} +1 -1
- package/dist/server/{index.server-p56xxef1.js → index.server-m8ya4p7w.js} +1 -1
- package/dist/server/{index.server-1nq7z1qw.js → index.server-mda2y5g6.js} +1 -1
- package/dist/server/{index.server-jdcq5zza.js → index.server-mehav5vs.js} +7 -7
- package/dist/server/{index.server-e89qfamd.js → index.server-mknhgg07.js} +4 -4
- package/dist/server/{index.server-j570vb03.js → index.server-mvjzcna5.js} +1 -1
- package/dist/server/index.server-n4jxy52q.js +2 -0
- package/dist/server/{index.server-h89zk5ev.js → index.server-ne4gzxvz.js} +7 -7
- package/dist/server/{index.server-eftvmq3f.js → index.server-pfbzz3x7.js} +1 -1
- package/dist/server/{index.server-zrh23kty.js → index.server-pyjzfjfn.js} +1 -1
- package/dist/server/{index.server-rga8sc7j.js → index.server-q1d48s9t.js} +40 -36
- package/dist/server/{index.server-46cjwcqw.js → index.server-qv0kkre4.js} +5 -5
- package/dist/server/{index.server-yhzydqxe.js → index.server-r82zjq88.js} +5 -5
- package/dist/server/{index.server-9ykk1kbg.js → index.server-rbd5ys4z.js} +1 -1
- package/dist/server/{index.server-tcay903b.js → index.server-tnecnach.js} +4 -4
- package/dist/server/{index.server-9ra3xv88.js → index.server-x66zvjfc.js} +9 -9
- package/dist/server/{index.server-6sh11ap6.js → index.server-y4kfz0er.js} +1 -1
- package/dist/server/{index.server-n82rcv0m.js → index.server-z721a5gp.js} +4 -4
- package/dist/server/{index.server-mm1xa3kr.js → index.server-zdhv33ph.js} +51 -20
- package/dist/server/{index.server-t3hknp1c.js → index.server-zm04d9eq.js} +4 -4
- package/dist/server/{index.server-nx9c2ep1.js → index.server-zncgb7mw.js} +2 -2
- package/package.json +10 -130
- package/src/components/focus-trap/index.ts +1 -0
- package/src/components/icons/index.ts +82 -40
- package/src/index.ts +0 -34
- package/src/styles/components.css +0 -4
- package/dist/components/chat/adapter/chat-adapter.d.ts +0 -123
- package/dist/components/chat/adapter/index.d.ts +0 -8
- package/dist/components/chat/artifact/artifact-panel.svelte.d.ts +0 -15
- package/dist/components/chat/artifact/artifact-viewer.svelte.d.ts +0 -10
- package/dist/components/chat/artifact/chat-artifact-layout.svelte.d.ts +0 -23
- package/dist/components/chat/artifact/index.d.ts +0 -3
- package/dist/components/chat/builders.d.ts +0 -25
- package/dist/components/chat/chat.css +0 -16
- package/dist/components/chat/chat.css.d.ts +0 -1
- package/dist/components/chat/chat.schema.d.ts +0 -3
- package/dist/components/chat/chat.schema.js +0 -366
- package/dist/components/chat/chat.svelte.d.ts +0 -31
- package/dist/components/chat/chat.types.d.ts +0 -268
- package/dist/components/chat/chat.variables.d.ts +0 -2
- package/dist/components/chat/chat.variables.js +0 -61
- package/dist/components/chat/container/chat-events.d.ts +0 -22
- package/dist/components/chat/container/chat-history-trigger.svelte.d.ts +0 -15
- package/dist/components/chat/container/chat-jump-controls.svelte.d.ts +0 -24
- package/dist/components/chat/container/chat-participant-typing.svelte.d.ts +0 -31
- package/dist/components/chat/container/chat-search-bar.svelte.d.ts +0 -38
- package/dist/components/chat/container/chat-status-announcer.svelte.d.ts +0 -21
- package/dist/components/chat/container/chat.svelte.d.ts +0 -17
- package/dist/components/chat/container/index.d.ts +0 -12
- package/dist/components/chat/container/scroll-utilities.d.ts +0 -119
- package/dist/components/chat/container/use-chat-disclosure-state.svelte.d.ts +0 -58
- package/dist/components/chat/container/use-chat-keyboard-nav.svelte.d.ts +0 -57
- package/dist/components/chat/container/use-chat-message-groups.svelte.d.ts +0 -74
- package/dist/components/chat/container/use-chat-read-receipts.svelte.d.ts +0 -51
- package/dist/components/chat/container/use-chat-scroll-state.svelte.d.ts +0 -111
- package/dist/components/chat/container/use-chat-search.svelte.d.ts +0 -82
- package/dist/components/chat/container/use-chat-typing-indicator.svelte.d.ts +0 -76
- package/dist/components/chat/container/use-chat-unread-state.svelte.d.ts +0 -80
- package/dist/components/chat/container/use-chat-virtualizer.svelte.d.ts +0 -47
- package/dist/components/chat/conversation-model.d.ts +0 -16
- package/dist/components/chat/export/conversation-export-actions.svelte.d.ts +0 -17
- package/dist/components/chat/export/index.d.ts +0 -8
- package/dist/components/chat/index.d.ts +0 -25
- package/dist/components/chat/index.js +0 -11319
- package/dist/components/chat/input/attachment-kind.d.ts +0 -10
- package/dist/components/chat/input/chat-attachment-preview.svelte.d.ts +0 -8
- package/dist/components/chat/input/chat-attachment-serialization.d.ts +0 -9
- package/dist/components/chat/input/chat-attachment.d.ts +0 -11
- package/dist/components/chat/input/chat-input.svelte.d.ts +0 -79
- package/dist/components/chat/input/index.d.ts +0 -5
- package/dist/components/chat/message/chat-date-separator.svelte.d.ts +0 -12
- package/dist/components/chat/message/chat-message-parts-renderer.svelte.d.ts +0 -4
- package/dist/components/chat/message/chat-message-parts.d.ts +0 -96
- package/dist/components/chat/message/chat-message.svelte.d.ts +0 -91
- package/dist/components/chat/message/chat-read-receipt.svelte.d.ts +0 -27
- package/dist/components/chat/message/image-lightbox.svelte.d.ts +0 -17
- package/dist/components/chat/message/index.d.ts +0 -6
- package/dist/components/chat/message/markdown-preview.svelte.d.ts +0 -8
- package/dist/components/chat/message/message-attachments.svelte.d.ts +0 -17
- package/dist/components/chat/message/message-content.svelte.d.ts +0 -18
- package/dist/components/chat/message/parts/image-part.svelte.d.ts +0 -17
- package/dist/components/chat/message/parts/markdown-part.svelte.d.ts +0 -8
- package/dist/components/chat/message/parts/reasoning-part.svelte.d.ts +0 -12
- package/dist/components/chat/message/parts/step-part.svelte.d.ts +0 -8
- package/dist/components/chat/message/parts/suggestion-part.svelte.d.ts +0 -18
- package/dist/components/chat/message/parts/tool-approval-part.svelte.d.ts +0 -12
- package/dist/components/chat/message/parts/tool-call-part.svelte.d.ts +0 -12
- package/dist/components/chat/message/parts/tool-result-part.svelte.d.ts +0 -8
- package/dist/components/chat/message/tool-call-group.svelte.d.ts +0 -15
- package/dist/components/chat/message/tool-payload-code.svelte.d.ts +0 -9
- package/dist/components/chat/utilities/conversation.d.ts +0 -12
- package/dist/components/chat/utilities/index.d.ts +0 -9
- package/dist/components/chat/utilities/types.d.ts +0 -262
- package/dist/components/chat/utilities/utilities.d.ts +0 -140
- package/dist/components/chat-composer-popover/chat-composer-popover-filter.d.ts +0 -11
- package/dist/components/chat-composer-popover/chat-composer-popover.css +0 -7
- package/dist/components/chat-composer-popover/chat-composer-popover.css.d.ts +0 -1
- package/dist/components/chat-composer-popover/chat-composer-popover.schema.d.ts +0 -3
- package/dist/components/chat-composer-popover/chat-composer-popover.schema.js +0 -150
- package/dist/components/chat-composer-popover/chat-composer-popover.svelte.d.ts +0 -46
- package/dist/components/chat-composer-popover/chat-composer-popover.types.d.ts +0 -77
- package/dist/components/chat-composer-popover/chat-composer-popover.variables.d.ts +0 -2
- package/dist/components/chat-composer-popover/chat-composer-popover.variables.js +0 -61
- package/dist/components/chat-composer-popover/index.d.ts +0 -6
- package/dist/components/chat-composer-popover/index.js +0 -3285
- package/dist/components/chat-conversation-header/chat-conversation-header.css +0 -51
- package/dist/components/chat-conversation-header/chat-conversation-header.css.d.ts +0 -1
- package/dist/components/chat-conversation-header/chat-conversation-header.schema.d.ts +0 -3
- package/dist/components/chat-conversation-header/chat-conversation-header.schema.js +0 -94
- package/dist/components/chat-conversation-header/chat-conversation-header.svelte.d.ts +0 -19
- package/dist/components/chat-conversation-header/chat-conversation-header.types.d.ts +0 -18
- package/dist/components/chat-conversation-header/chat-conversation-header.variables.d.ts +0 -2
- package/dist/components/chat-conversation-header/chat-conversation-header.variables.js +0 -61
- package/dist/components/chat-conversation-header/index.d.ts +0 -5
- package/dist/components/chat-conversation-header/index.js +0 -4278
- package/dist/components/chat-conversation-list/chat-conversation-list.css +0 -127
- package/dist/components/chat-conversation-list/chat-conversation-list.css.d.ts +0 -1
- package/dist/components/chat-conversation-list/chat-conversation-list.schema.d.ts +0 -3
- package/dist/components/chat-conversation-list/chat-conversation-list.schema.js +0 -105
- package/dist/components/chat-conversation-list/chat-conversation-list.svelte.d.ts +0 -21
- package/dist/components/chat-conversation-list/chat-conversation-list.types.d.ts +0 -17
- package/dist/components/chat-conversation-list/chat-conversation-list.variables.d.ts +0 -2
- package/dist/components/chat-conversation-list/chat-conversation-list.variables.js +0 -61
- package/dist/components/chat-conversation-list/conversation-summary.d.ts +0 -30
- package/dist/components/chat-conversation-list/index.d.ts +0 -6
- package/dist/components/chat-conversation-list/index.js +0 -536
- package/dist/server/components/chat/index.js +0 -131
- package/dist/server/components/chat-composer-popover/index.js +0 -26
- package/dist/server/components/chat-conversation-header/index.js +0 -41
- package/dist/server/components/chat-conversation-list/index.js +0 -19
- package/dist/server/index.server-2bbwajb2.js +0 -54
- package/dist/server/index.server-2hqrv7ca.js +0 -9
- package/dist/server/index.server-67qgdypc.js +0 -9
- package/dist/server/index.server-6hnfzc7f.js +0 -263
- package/dist/server/index.server-8rmtb8vx.js +0 -175
- package/dist/server/index.server-a59y47rw.js +0 -59
- package/dist/server/index.server-bfkka7x4.js +0 -2
- package/dist/server/index.server-czf35aba.js +0 -4241
- package/dist/server/index.server-kb6w1a7c.js +0 -27
- package/dist/server/index.server-nphtb2ey.js +0 -76
- package/dist/server/index.server-qkfd0qa7.js +0 -2
- package/dist/server/index.server-rf67m8v5.js +0 -2
- package/dist/server/index.server-rqe5bqgm.js +0 -37
- package/dist/server/index.server-xtjjmsyq.js +0 -315
- package/dist/server/index.server-yq9evnp4.js +0 -38
- package/dist/server/index.server-z1qvwaem.js +0 -74
- package/dist/server/index.server-z7hxtqs1.js +0 -83
- package/src/components/chat/adapter/chat-adapter.ts +0 -132
- package/src/components/chat/adapter/index.ts +0 -15
- package/src/components/chat/artifact/artifact-panel.svelte +0 -112
- package/src/components/chat/artifact/artifact-viewer.svelte +0 -101
- package/src/components/chat/artifact/chat-artifact-layout.svelte +0 -56
- package/src/components/chat/artifact/index.ts +0 -3
- package/src/components/chat/builders.ts +0 -464
- package/src/components/chat/chat.css +0 -16
- package/src/components/chat/chat.examples.json +0 -67
- package/src/components/chat/chat.schema.json +0 -290
- package/src/components/chat/chat.schema.ts +0 -335
- package/src/components/chat/chat.svelte +0 -67
- package/src/components/chat/chat.types.ts +0 -284
- package/src/components/chat/chat.variables.json +0 -1
- package/src/components/chat/chat.variables.ts +0 -3
- package/src/components/chat/container/chat-events.ts +0 -26
- package/src/components/chat/container/chat-history-trigger.svelte +0 -95
- package/src/components/chat/container/chat-jump-controls.svelte +0 -191
- package/src/components/chat/container/chat-participant-typing.svelte +0 -128
- package/src/components/chat/container/chat-search-bar.svelte +0 -219
- package/src/components/chat/container/chat-status-announcer.svelte +0 -22
- package/src/components/chat/container/chat.svelte +0 -1879
- package/src/components/chat/container/index.ts +0 -64
- package/src/components/chat/container/scroll-utilities.ts +0 -204
- package/src/components/chat/container/use-chat-disclosure-state.svelte.ts +0 -62
- package/src/components/chat/container/use-chat-keyboard-nav.svelte.ts +0 -153
- package/src/components/chat/container/use-chat-message-groups.svelte.ts +0 -146
- package/src/components/chat/container/use-chat-read-receipts.svelte.ts +0 -62
- package/src/components/chat/container/use-chat-scroll-state.svelte.ts +0 -292
- package/src/components/chat/container/use-chat-search.svelte.ts +0 -116
- package/src/components/chat/container/use-chat-typing-indicator.svelte.ts +0 -153
- package/src/components/chat/container/use-chat-unread-state.svelte.ts +0 -170
- package/src/components/chat/container/use-chat-virtualizer.svelte.ts +0 -260
- package/src/components/chat/conversation-model.ts +0 -56
- package/src/components/chat/export/conversation-export-actions.svelte +0 -174
- package/src/components/chat/export/index.ts +0 -9
- package/src/components/chat/index.ts +0 -160
- package/src/components/chat/input/attachment-kind.ts +0 -28
- package/src/components/chat/input/chat-attachment-preview.svelte +0 -223
- package/src/components/chat/input/chat-attachment-serialization.ts +0 -63
- package/src/components/chat/input/chat-attachment.ts +0 -12
- package/src/components/chat/input/chat-input.svelte +0 -810
- package/src/components/chat/input/index.ts +0 -9
- package/src/components/chat/message/chat-date-separator.svelte +0 -87
- package/src/components/chat/message/chat-message-parts-renderer.svelte +0 -139
- package/src/components/chat/message/chat-message-parts.ts +0 -163
- package/src/components/chat/message/chat-message.svelte +0 -861
- package/src/components/chat/message/chat-read-receipt.svelte +0 -85
- package/src/components/chat/message/image-lightbox.svelte +0 -255
- package/src/components/chat/message/index.ts +0 -6
- package/src/components/chat/message/markdown-preview.svelte +0 -77
- package/src/components/chat/message/message-attachments.svelte +0 -178
- package/src/components/chat/message/message-content.svelte +0 -132
- package/src/components/chat/message/parts/image-part.svelte +0 -11
- package/src/components/chat/message/parts/markdown-part.svelte +0 -17
- package/src/components/chat/message/parts/reasoning-part.svelte +0 -274
- package/src/components/chat/message/parts/step-part.svelte +0 -127
- package/src/components/chat/message/parts/suggestion-part.svelte +0 -83
- package/src/components/chat/message/parts/tool-approval-part.svelte +0 -298
- package/src/components/chat/message/parts/tool-call-part.svelte +0 -19
- package/src/components/chat/message/parts/tool-result-part.svelte +0 -65
- package/src/components/chat/message/tool-call-group.svelte +0 -274
- package/src/components/chat/message/tool-payload-code.svelte +0 -35
- package/src/components/chat/utilities/conversation.ts +0 -44
- package/src/components/chat/utilities/index.ts +0 -33
- package/src/components/chat/utilities/types.ts +0 -288
- package/src/components/chat/utilities/utilities.ts +0 -507
- package/src/components/chat-composer-popover/chat-composer-popover-filter.ts +0 -68
- package/src/components/chat-composer-popover/chat-composer-popover.css +0 -7
- package/src/components/chat-composer-popover/chat-composer-popover.examples.json +0 -13
- package/src/components/chat-composer-popover/chat-composer-popover.schema.json +0 -90
- package/src/components/chat-composer-popover/chat-composer-popover.schema.ts +0 -95
- package/src/components/chat-composer-popover/chat-composer-popover.svelte +0 -234
- package/src/components/chat-composer-popover/chat-composer-popover.types.ts +0 -88
- package/src/components/chat-composer-popover/chat-composer-popover.variables.json +0 -1
- package/src/components/chat-composer-popover/chat-composer-popover.variables.ts +0 -3
- package/src/components/chat-composer-popover/index.ts +0 -19
- package/src/components/chat-conversation-header/chat-conversation-header.css +0 -51
- package/src/components/chat-conversation-header/chat-conversation-header.examples.json +0 -13
- package/src/components/chat-conversation-header/chat-conversation-header.schema.json +0 -34
- package/src/components/chat-conversation-header/chat-conversation-header.schema.ts +0 -38
- package/src/components/chat-conversation-header/chat-conversation-header.svelte +0 -49
- package/src/components/chat-conversation-header/chat-conversation-header.types.ts +0 -20
- package/src/components/chat-conversation-header/chat-conversation-header.variables.json +0 -1
- package/src/components/chat-conversation-header/chat-conversation-header.variables.ts +0 -3
- package/src/components/chat-conversation-header/index.ts +0 -9
- package/src/components/chat-conversation-list/chat-conversation-list.css +0 -127
- package/src/components/chat-conversation-list/chat-conversation-list.examples.json +0 -13
- package/src/components/chat-conversation-list/chat-conversation-list.schema.json +0 -45
- package/src/components/chat-conversation-list/chat-conversation-list.schema.ts +0 -52
- package/src/components/chat-conversation-list/chat-conversation-list.svelte +0 -75
- package/src/components/chat-conversation-list/chat-conversation-list.types.ts +0 -18
- package/src/components/chat-conversation-list/chat-conversation-list.variables.json +0 -1
- package/src/components/chat-conversation-list/chat-conversation-list.variables.ts +0 -3
- package/src/components/chat-conversation-list/conversation-summary.ts +0 -88
- package/src/components/chat-conversation-list/index.ts +0 -11
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runes helper for chat unread state tracking.
|
|
3
|
-
*
|
|
4
|
-
* Manages:
|
|
5
|
-
* - Unread message count
|
|
6
|
-
* - New message indicator visibility
|
|
7
|
-
* - First unread message ID for divider placement
|
|
8
|
-
* - Screen reader announcements
|
|
9
|
-
*/
|
|
10
|
-
import { untrack } from 'svelte';
|
|
11
|
-
import { useAnnouncer } from '../../../utilities/use-announcer.svelte.ts';
|
|
12
|
-
import { formatUnreadCount, isLargeCount } from './scroll-utilities';
|
|
13
|
-
// ==========================================================================
|
|
14
|
-
// Helper
|
|
15
|
-
// ==========================================================================
|
|
16
|
-
/**
|
|
17
|
-
* Creates reactive state and methods for tracking unread messages.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```svelte
|
|
21
|
-
* <script lang="ts">
|
|
22
|
-
* import { useChatUnreadState } from './use-chat-unread-state.svelte';
|
|
23
|
-
*
|
|
24
|
-
* const unreadState = useChatUnreadState({
|
|
25
|
-
* onUnreadIndicatorChange: (event) => console.log('Unread changed:', event),
|
|
26
|
-
* });
|
|
27
|
-
*
|
|
28
|
-
* // Call in an $effect to process message changes
|
|
29
|
-
* // Pass a getter function for atBottom to avoid creating a scroll dependency
|
|
30
|
-
* $effect(() => {
|
|
31
|
-
* unreadState.processMessages(messages, conversation.id, () => scrollState.atBottom);
|
|
32
|
-
* });
|
|
33
|
-
*
|
|
34
|
-
* // Mark as read when user scrolls to bottom
|
|
35
|
-
* if (atBottom) unreadState.markAllAsRead();
|
|
36
|
-
* </script>
|
|
37
|
-
*
|
|
38
|
-
* <div aria-live="polite" class="sr-only">
|
|
39
|
-
* {unreadState.announcerMessage}
|
|
40
|
-
* </div>
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
export function useChatUnreadState(options) {
|
|
44
|
-
const { announcerDebounceMs = 300, onUnreadIndicatorChange } = options ?? {};
|
|
45
|
-
// Internal reactive state
|
|
46
|
-
let unreadCount = $state(0);
|
|
47
|
-
let newMessageIndicatorVisible = $state(false);
|
|
48
|
-
let firstUnreadId = $state(null);
|
|
49
|
-
// Non-reactive bookkeeping (prevents $effect infinite loops)
|
|
50
|
-
let previousMessageCount = 0;
|
|
51
|
-
let previousLastMessageId = null;
|
|
52
|
-
let previousConversationId = null;
|
|
53
|
-
// Screen reader announcements - use debounce to batch rapid message arrivals
|
|
54
|
-
const announcer = useAnnouncer({ debounceMs: announcerDebounceMs });
|
|
55
|
-
// Derived display values
|
|
56
|
-
const displayUnreadCount = $derived(formatUnreadCount(unreadCount));
|
|
57
|
-
const hasLargeCount = $derived(isLargeCount(unreadCount));
|
|
58
|
-
/**
|
|
59
|
-
* Fire the indicator-change callback from the mutation sites that actually
|
|
60
|
-
* change `unreadCount` / `newMessageIndicatorVisible`. Driving it here (rather
|
|
61
|
-
* than from an `$effect`) avoids the spurious `{ unreadCount: 0,
|
|
62
|
-
* newMessageIndicatorVisible: false }` notification that an effect would emit on
|
|
63
|
-
* mount, and keeps the contract aligned with `onScrollStateChange`, which
|
|
64
|
-
* only fires from its own mutation site.
|
|
65
|
-
*/
|
|
66
|
-
function notifyIndicatorChange() {
|
|
67
|
-
onUnreadIndicatorChange?.({
|
|
68
|
-
unreadCount,
|
|
69
|
-
newMessageIndicatorVisible,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Mark all messages as read (resets unread state).
|
|
74
|
-
*/
|
|
75
|
-
function markAllAsRead() {
|
|
76
|
-
const changed = unreadCount !== 0 || newMessageIndicatorVisible;
|
|
77
|
-
unreadCount = 0;
|
|
78
|
-
newMessageIndicatorVisible = false;
|
|
79
|
-
firstUnreadId = null;
|
|
80
|
-
if (changed)
|
|
81
|
-
notifyIndicatorChange();
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Process messages to detect new arrivals and update unread state.
|
|
85
|
-
* This should be called from an $effect in the parent component.
|
|
86
|
-
*
|
|
87
|
-
* @param getAtBottom - Getter function to read atBottom without creating a dependency.
|
|
88
|
-
*/
|
|
89
|
-
function processMessages(messages, conversationId, getAtBottom) {
|
|
90
|
-
// Check if conversation has changed - reset tracking if so
|
|
91
|
-
if (conversationId !== previousConversationId) {
|
|
92
|
-
// Conversation switched - reset all tracking state
|
|
93
|
-
previousMessageCount = messages.length;
|
|
94
|
-
previousLastMessageId = messages.at(-1)?.id ?? null;
|
|
95
|
-
previousConversationId = conversationId;
|
|
96
|
-
// Reset all unread state when switching conversations
|
|
97
|
-
markAllAsRead();
|
|
98
|
-
return; // Don't trigger new message detection on conversation switch
|
|
99
|
-
}
|
|
100
|
-
const currentCount = messages.length;
|
|
101
|
-
const prevCount = previousMessageCount;
|
|
102
|
-
const currentLastMessageId = messages.at(-1)?.id ?? null;
|
|
103
|
-
// Detect whether new messages were appended (vs prepended history)
|
|
104
|
-
// Appended: last message ID changed AND count increased
|
|
105
|
-
// Prepended: last message ID unchanged but count increased (history loaded)
|
|
106
|
-
const wasAppended = currentCount > prevCount &&
|
|
107
|
-
prevCount > 0 &&
|
|
108
|
-
currentLastMessageId !== null &&
|
|
109
|
-
currentLastMessageId !== previousLastMessageId;
|
|
110
|
-
if (wasAppended) {
|
|
111
|
-
// New messages arrived at the end
|
|
112
|
-
// Read atBottom via getter to avoid creating a reactive dependency
|
|
113
|
-
// The getter is called inside untrack to ensure no dependency tracking
|
|
114
|
-
const atBottom = untrack(getAtBottom);
|
|
115
|
-
if (!atBottom) {
|
|
116
|
-
// User is reading history - show indicator
|
|
117
|
-
const newMessageCount = currentCount - prevCount;
|
|
118
|
-
unreadCount += newMessageCount;
|
|
119
|
-
newMessageIndicatorVisible = true;
|
|
120
|
-
// Set first unread ID if not already set
|
|
121
|
-
// The first new message is at index (currentCount - newMessageCount)
|
|
122
|
-
if (firstUnreadId === null) {
|
|
123
|
-
const firstNewIndex = currentCount - newMessageCount;
|
|
124
|
-
const firstNewMessage = messages[firstNewIndex];
|
|
125
|
-
if (firstNewMessage) {
|
|
126
|
-
firstUnreadId = firstNewMessage.id;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
// Announce to screen readers using accumulated unreadCount
|
|
130
|
-
// (not newMessageCount) to handle debouncing correctly - if multiple
|
|
131
|
-
// batches arrive within the debounce window, we announce the total
|
|
132
|
-
announcer.announce(unreadCount === 1 ? 'New message received' : `${unreadCount} new messages received`);
|
|
133
|
-
// Notify the consumer at the mutation site so the callback reflects the
|
|
134
|
-
// freshly-updated unread state and never fires spuriously on mount.
|
|
135
|
-
notifyIndicatorChange();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
previousMessageCount = currentCount;
|
|
139
|
-
previousLastMessageId = currentLastMessageId;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Cleanup resources.
|
|
143
|
-
*/
|
|
144
|
-
function destroy() {
|
|
145
|
-
announcer.destroy();
|
|
146
|
-
}
|
|
147
|
-
return {
|
|
148
|
-
get unreadCount() {
|
|
149
|
-
return unreadCount;
|
|
150
|
-
},
|
|
151
|
-
get newMessageIndicatorVisible() {
|
|
152
|
-
return newMessageIndicatorVisible;
|
|
153
|
-
},
|
|
154
|
-
get firstUnreadId() {
|
|
155
|
-
return firstUnreadId;
|
|
156
|
-
},
|
|
157
|
-
get displayUnreadCount() {
|
|
158
|
-
return displayUnreadCount;
|
|
159
|
-
},
|
|
160
|
-
get hasLargeCount() {
|
|
161
|
-
return hasLargeCount;
|
|
162
|
-
},
|
|
163
|
-
get announcerMessage() {
|
|
164
|
-
return announcer.message;
|
|
165
|
-
},
|
|
166
|
-
markAllAsRead,
|
|
167
|
-
processMessages,
|
|
168
|
-
destroy,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
export function calculateChatVirtualWindow(input) {
|
|
2
|
-
const itemCount = Math.max(0, Math.trunc(input.itemCount));
|
|
3
|
-
if (itemCount === 0)
|
|
4
|
-
return { startIndex: 0, endIndex: 0 };
|
|
5
|
-
const itemSize = Math.max(1, input.itemSize);
|
|
6
|
-
const overscan = Math.max(0, Math.trunc(input.overscan));
|
|
7
|
-
const scrollTop = Math.max(0, input.scrollTop);
|
|
8
|
-
const containerHeight = Math.max(0, input.containerHeight);
|
|
9
|
-
const visibleCount = Math.max(1, Math.ceil(containerHeight / itemSize));
|
|
10
|
-
const maxStartIndex = Math.max(0, itemCount - visibleCount);
|
|
11
|
-
const startIndex = Math.min(maxStartIndex, Math.max(0, Math.floor(scrollTop / itemSize) - overscan));
|
|
12
|
-
const endIndex = Math.min(itemCount, startIndex + visibleCount + overscan * 2);
|
|
13
|
-
return { startIndex, endIndex };
|
|
14
|
-
}
|
|
15
|
-
export class ChatVirtualizer {
|
|
16
|
-
options;
|
|
17
|
-
#scrollElement = null;
|
|
18
|
-
#scrollOffset = $state(0);
|
|
19
|
-
#measurementVersion = $state(0);
|
|
20
|
-
#offsetsCache = null;
|
|
21
|
-
#offsetsCacheCount = -1;
|
|
22
|
-
#offsetsCacheMeasurementVersion = -1;
|
|
23
|
-
#measuredSizes = new Map();
|
|
24
|
-
constructor(options) {
|
|
25
|
-
this.options = options;
|
|
26
|
-
}
|
|
27
|
-
get virtualItems() {
|
|
28
|
-
return this.#virtualItems();
|
|
29
|
-
}
|
|
30
|
-
get totalSize() {
|
|
31
|
-
const offsets = this.#offsets();
|
|
32
|
-
return offsets[offsets.length - 1] ?? 0;
|
|
33
|
-
}
|
|
34
|
-
get scrollPaddingStart() {
|
|
35
|
-
return this.#scrollPaddingStart();
|
|
36
|
-
}
|
|
37
|
-
get scrollSize() {
|
|
38
|
-
return this.scrollPaddingStart + this.totalSize;
|
|
39
|
-
}
|
|
40
|
-
get scrollOffset() {
|
|
41
|
-
return this.#scrollOffset;
|
|
42
|
-
}
|
|
43
|
-
setScrollElement(element) {
|
|
44
|
-
if (this.#scrollElement === element)
|
|
45
|
-
return;
|
|
46
|
-
this.#scrollElement?.removeEventListener('scroll', this.#handleScroll);
|
|
47
|
-
this.#scrollElement = element;
|
|
48
|
-
this.#scrollOffset = element?.scrollTop ?? 0;
|
|
49
|
-
this.#scrollElement?.addEventListener('scroll', this.#handleScroll, { passive: true });
|
|
50
|
-
}
|
|
51
|
-
scrollElement = (node) => {
|
|
52
|
-
this.setScrollElement(node);
|
|
53
|
-
return () => {
|
|
54
|
-
if (this.#scrollElement === node) {
|
|
55
|
-
this.setScrollElement(null);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
measureElement = (node) => {
|
|
60
|
-
this.measureElementNode(node);
|
|
61
|
-
if (typeof ResizeObserver !== 'function')
|
|
62
|
-
return undefined;
|
|
63
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
64
|
-
this.measureElementNode(node);
|
|
65
|
-
});
|
|
66
|
-
resizeObserver.observe(node);
|
|
67
|
-
return () => {
|
|
68
|
-
resizeObserver.disconnect();
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
measureElementNode(node) {
|
|
72
|
-
if (!node)
|
|
73
|
-
return;
|
|
74
|
-
this.#measureNode(node);
|
|
75
|
-
}
|
|
76
|
-
syncOptions() {
|
|
77
|
-
const count = this.options.getCount();
|
|
78
|
-
const currentKeys = new Set();
|
|
79
|
-
for (let index = 0; index < count; index += 1) {
|
|
80
|
-
currentKeys.add(this.options.getItemKey(index));
|
|
81
|
-
}
|
|
82
|
-
let changed = false;
|
|
83
|
-
for (const key of this.#measuredSizes.keys()) {
|
|
84
|
-
if (!currentKeys.has(key)) {
|
|
85
|
-
this.#measuredSizes.delete(key);
|
|
86
|
-
changed = true;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (changed)
|
|
90
|
-
this.#measurementVersion += 1;
|
|
91
|
-
}
|
|
92
|
-
scrollToIndex(index, options = { align: 'auto' }) {
|
|
93
|
-
const count = this.options.getCount();
|
|
94
|
-
if (count === 0)
|
|
95
|
-
return;
|
|
96
|
-
const clampedIndex = Math.max(0, Math.min(Math.trunc(index), count - 1));
|
|
97
|
-
const offsets = this.#offsets();
|
|
98
|
-
const itemStart = offsets[clampedIndex] ?? 0;
|
|
99
|
-
const itemEnd = offsets[clampedIndex + 1] ?? itemStart + this.#estimatedSize();
|
|
100
|
-
const itemSize = itemEnd - itemStart;
|
|
101
|
-
const viewportHeight = this.#containerHeight();
|
|
102
|
-
const paddingStart = this.#scrollPaddingStart();
|
|
103
|
-
const viewportStart = Math.max(0, this.scrollOffset - paddingStart);
|
|
104
|
-
const viewportEnd = viewportStart + viewportHeight;
|
|
105
|
-
let offset = itemStart + paddingStart;
|
|
106
|
-
if (options.align === 'end') {
|
|
107
|
-
offset = itemEnd + paddingStart - viewportHeight;
|
|
108
|
-
}
|
|
109
|
-
else if (options.align === 'center') {
|
|
110
|
-
offset = itemStart + paddingStart - (viewportHeight - itemSize) / 2;
|
|
111
|
-
}
|
|
112
|
-
else if (options.align === 'auto') {
|
|
113
|
-
if (itemStart >= viewportStart && itemEnd <= viewportEnd)
|
|
114
|
-
return;
|
|
115
|
-
offset =
|
|
116
|
-
itemStart < viewportStart
|
|
117
|
-
? itemStart + paddingStart
|
|
118
|
-
: itemEnd + paddingStart - viewportHeight;
|
|
119
|
-
}
|
|
120
|
-
this.scrollToOffset(offset, options);
|
|
121
|
-
}
|
|
122
|
-
getVirtualItem(index) {
|
|
123
|
-
const count = this.options.getCount();
|
|
124
|
-
if (count === 0)
|
|
125
|
-
return null;
|
|
126
|
-
const clampedIndex = Math.max(0, Math.min(Math.trunc(index), count - 1));
|
|
127
|
-
return this.#virtualItemAt(clampedIndex, this.#offsets());
|
|
128
|
-
}
|
|
129
|
-
scrollToOffset(offset, options) {
|
|
130
|
-
const element = this.#getScrollElement();
|
|
131
|
-
const maximumOffset = Math.max(0, this.scrollSize - this.#containerHeight());
|
|
132
|
-
const top = Math.min(maximumOffset, Math.max(0, offset));
|
|
133
|
-
this.#scrollOffset = top;
|
|
134
|
-
if (element) {
|
|
135
|
-
const behavior = options?.behavior === 'instant' ? 'auto' : options?.behavior;
|
|
136
|
-
if (typeof element.scrollTo === 'function' && behavior && behavior !== 'auto') {
|
|
137
|
-
element.scrollTo({ top, behavior });
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
element.scrollTop = top;
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
#handleScroll = () => {
|
|
145
|
-
this.#scrollOffset = this.#scrollElement?.scrollTop ?? 0;
|
|
146
|
-
};
|
|
147
|
-
#getScrollElement() {
|
|
148
|
-
return this.#scrollElement ?? this.options.getScrollElement();
|
|
149
|
-
}
|
|
150
|
-
#containerHeight() {
|
|
151
|
-
const element = this.#getScrollElement();
|
|
152
|
-
return element?.clientHeight || this.options.getInitialHeight();
|
|
153
|
-
}
|
|
154
|
-
#scrollPaddingStart() {
|
|
155
|
-
return Math.max(0, this.options.getScrollPaddingStart?.() ?? 0);
|
|
156
|
-
}
|
|
157
|
-
#estimatedSize() {
|
|
158
|
-
return Math.max(1, this.options.getEstimatedSize());
|
|
159
|
-
}
|
|
160
|
-
#itemSize(index) {
|
|
161
|
-
const key = this.options.getItemKey(index);
|
|
162
|
-
return this.#measuredSizes.get(key) ?? this.#estimatedSize();
|
|
163
|
-
}
|
|
164
|
-
#offsets() {
|
|
165
|
-
const count = this.options.getCount();
|
|
166
|
-
const measurementVersion = this.#measurementVersion;
|
|
167
|
-
if (this.#offsetsCache &&
|
|
168
|
-
this.#offsetsCacheCount === count &&
|
|
169
|
-
this.#offsetsCacheMeasurementVersion === measurementVersion) {
|
|
170
|
-
return this.#offsetsCache;
|
|
171
|
-
}
|
|
172
|
-
const offsets = Array.from({ length: count + 1 });
|
|
173
|
-
let offset = 0;
|
|
174
|
-
offsets[0] = 0;
|
|
175
|
-
for (let index = 0; index < count; index += 1) {
|
|
176
|
-
offset += this.#itemSize(index);
|
|
177
|
-
offsets[index + 1] = offset;
|
|
178
|
-
}
|
|
179
|
-
this.#offsetsCache = offsets;
|
|
180
|
-
this.#offsetsCacheCount = count;
|
|
181
|
-
this.#offsetsCacheMeasurementVersion = measurementVersion;
|
|
182
|
-
return offsets;
|
|
183
|
-
}
|
|
184
|
-
#readElementSize(node) {
|
|
185
|
-
const rectHeight = node.getBoundingClientRect().height;
|
|
186
|
-
return Math.ceil(rectHeight || node.scrollHeight || node.offsetHeight || 0);
|
|
187
|
-
}
|
|
188
|
-
#measureNode(node) {
|
|
189
|
-
const index = Number(node.dataset['cinderVirtualIndex']);
|
|
190
|
-
if (!Number.isInteger(index) || index < 0 || index >= this.options.getCount())
|
|
191
|
-
return;
|
|
192
|
-
const measuredSize = this.#readElementSize(node);
|
|
193
|
-
if (measuredSize <= 0)
|
|
194
|
-
return;
|
|
195
|
-
const key = this.options.getItemKey(index);
|
|
196
|
-
if (this.#measuredSizes.get(key) === measuredSize)
|
|
197
|
-
return;
|
|
198
|
-
this.#measuredSizes.set(key, measuredSize);
|
|
199
|
-
this.#measurementVersion += 1;
|
|
200
|
-
}
|
|
201
|
-
#startIndex(offsets, scrollTop) {
|
|
202
|
-
const count = Math.max(0, offsets.length - 1);
|
|
203
|
-
let low = 0;
|
|
204
|
-
let high = count;
|
|
205
|
-
while (low < high) {
|
|
206
|
-
const mid = Math.floor((low + high) / 2);
|
|
207
|
-
if ((offsets[mid + 1] ?? 0) <= scrollTop) {
|
|
208
|
-
low = mid + 1;
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
high = mid;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
return low;
|
|
215
|
-
}
|
|
216
|
-
#endIndex(offsets, viewportEnd) {
|
|
217
|
-
const count = Math.max(0, offsets.length - 1);
|
|
218
|
-
let low = 0;
|
|
219
|
-
let high = count;
|
|
220
|
-
while (low < high) {
|
|
221
|
-
const mid = Math.floor((low + high) / 2);
|
|
222
|
-
if ((offsets[mid] ?? 0) < viewportEnd) {
|
|
223
|
-
low = mid + 1;
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
high = mid;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return low;
|
|
230
|
-
}
|
|
231
|
-
#virtualItemAt(index, offsets) {
|
|
232
|
-
const start = offsets[index] ?? 0;
|
|
233
|
-
const end = offsets[index + 1] ?? start + this.#estimatedSize();
|
|
234
|
-
return {
|
|
235
|
-
key: this.options.getItemKey(index),
|
|
236
|
-
index,
|
|
237
|
-
start,
|
|
238
|
-
end,
|
|
239
|
-
size: end - start,
|
|
240
|
-
lane: 0,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
#virtualItems() {
|
|
244
|
-
const count = this.options.getCount();
|
|
245
|
-
if (count === 0)
|
|
246
|
-
return [];
|
|
247
|
-
const offsets = this.#offsets();
|
|
248
|
-
const overscan = Math.max(0, Math.trunc(this.options.getOverscan()));
|
|
249
|
-
const scrollTop = Math.max(0, this.scrollOffset - this.#scrollPaddingStart());
|
|
250
|
-
const viewportEnd = scrollTop + Math.max(0, this.#containerHeight());
|
|
251
|
-
const visibleStartIndex = this.#startIndex(offsets, scrollTop);
|
|
252
|
-
const visibleEndIndex = Math.max(visibleStartIndex + 1, this.#endIndex(offsets, viewportEnd));
|
|
253
|
-
const startIndex = Math.max(0, visibleStartIndex - overscan);
|
|
254
|
-
const endIndex = Math.min(count, visibleEndIndex + overscan);
|
|
255
|
-
return Array.from({ length: endIndex - startIndex }, (_, offset) => {
|
|
256
|
-
const index = startIndex + offset;
|
|
257
|
-
return this.#virtualItemAt(index, offsets);
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Conversationalist data model types for the Chat component.
|
|
3
|
-
*
|
|
4
|
-
* Chat renders immutable transcript snapshots and keeps its public `conversation`
|
|
5
|
-
* prop aligned with the published `conversationalist` package. This file is a
|
|
6
|
-
* type-only bridge so Cinder does not maintain a stale structural mirror.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { ToMarkdownOptions as ConversationalistToMarkdownOptions } from 'conversationalist/markdown';
|
|
12
|
-
|
|
13
|
-
export type {
|
|
14
|
-
AssistantMessage,
|
|
15
|
-
ContainerUploadContent,
|
|
16
|
-
Conversation,
|
|
17
|
-
ConversationActionType,
|
|
18
|
-
ConversationEnvironment,
|
|
19
|
-
ConversationEvent,
|
|
20
|
-
ConversationEventMap,
|
|
21
|
-
ConversationEventType,
|
|
22
|
-
ConversationHistory,
|
|
23
|
-
ConversationHistoryDraft,
|
|
24
|
-
ConversationNodeSnapshot,
|
|
25
|
-
ConversationSnapshot,
|
|
26
|
-
ConversationStatus,
|
|
27
|
-
ImageContent,
|
|
28
|
-
JSONValue,
|
|
29
|
-
Message,
|
|
30
|
-
MessageInput,
|
|
31
|
-
MessageRole,
|
|
32
|
-
MultiModalContent,
|
|
33
|
-
RedactedThinkingContent,
|
|
34
|
-
ServerToolResultContent,
|
|
35
|
-
ServerToolResultType,
|
|
36
|
-
ServerToolUseContent,
|
|
37
|
-
TextContent,
|
|
38
|
-
ThinkingContent,
|
|
39
|
-
TokenUsage,
|
|
40
|
-
ToolAction,
|
|
41
|
-
ToolCall,
|
|
42
|
-
ToolCallInput,
|
|
43
|
-
ToolError,
|
|
44
|
-
ToolErrorCategory,
|
|
45
|
-
ToolInteraction,
|
|
46
|
-
ToolResult,
|
|
47
|
-
ToolResultInput,
|
|
48
|
-
WebSearchToolResultContent,
|
|
49
|
-
} from 'conversationalist';
|
|
50
|
-
export type { ToolCallPair } from 'conversationalist/utilities';
|
|
51
|
-
|
|
52
|
-
/** Base options shared by all transcript export operations. */
|
|
53
|
-
export type ExportOptions = Omit<ConversationalistToMarkdownOptions, 'includeMetadata'>;
|
|
54
|
-
|
|
55
|
-
/** Options for exporting a transcript to markdown. */
|
|
56
|
-
export type ToMarkdownOptions = ConversationalistToMarkdownOptions;
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
export {};
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<script lang="ts">
|
|
6
|
-
import { classNames } from '../../../utilities/class-names.ts';
|
|
7
|
-
import { stringifyOrNull } from '../../../utilities/stringify.ts';
|
|
8
|
-
import { createCopyState } from '../../copy-button/use-copy-state.svelte.ts';
|
|
9
|
-
import Dropdown from '../../dropdown/dropdown.svelte';
|
|
10
|
-
import DropdownItem from '../../dropdown-item/dropdown-item.svelte';
|
|
11
|
-
import DropdownMenu from '../../dropdown-menu/dropdown-menu.svelte';
|
|
12
|
-
import DropdownTrigger from '../../dropdown-trigger/dropdown-trigger.svelte';
|
|
13
|
-
import Check from 'lucide-svelte/icons/check';
|
|
14
|
-
import Copy from 'lucide-svelte/icons/copy';
|
|
15
|
-
import FileCode from 'lucide-svelte/icons/file-code';
|
|
16
|
-
import FileText from 'lucide-svelte/icons/file-text';
|
|
17
|
-
import { getMessages, messagesToMarkdown } from '../utilities';
|
|
18
|
-
let { id, conversation, onexported, onexportfailed, class: className, } = $props();
|
|
19
|
-
const copyState = createCopyState();
|
|
20
|
-
/**
|
|
21
|
-
* Exports the conversation as Markdown.
|
|
22
|
-
* Uses the browser-compatible messagesToMarkdown helper (no Node.js APIs).
|
|
23
|
-
*/
|
|
24
|
-
async function handleExportMarkdown() {
|
|
25
|
-
const messages = getMessages(conversation, { includeHidden: false });
|
|
26
|
-
const markdown = messagesToMarkdown(messages);
|
|
27
|
-
const succeeded = await copyState.trigger('markdown', markdown);
|
|
28
|
-
if (succeeded) {
|
|
29
|
-
onexported?.('markdown');
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
onexportfailed?.('markdown', 'Clipboard access denied. Please copy manually.');
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Exports the conversation as JSON.
|
|
37
|
-
* Includes schema version and strips transient metadata.
|
|
38
|
-
*/
|
|
39
|
-
async function handleExportJSON() {
|
|
40
|
-
// Get messages without hidden ones, strip transient metadata
|
|
41
|
-
const messages = getMessages(conversation, { includeHidden: false });
|
|
42
|
-
const cleanedMessages = messages.map((message) => {
|
|
43
|
-
// Strip transient metadata (keys starting with _) from message metadata
|
|
44
|
-
if (message.metadata) {
|
|
45
|
-
const cleanedMetadata = {};
|
|
46
|
-
for (const [key, value] of Object.entries(message.metadata)) {
|
|
47
|
-
if (!key.startsWith('_')) {
|
|
48
|
-
cleanedMetadata[key] = value;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
...message,
|
|
53
|
-
metadata: Object.keys(cleanedMetadata).length > 0 ? cleanedMetadata : undefined,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
return message;
|
|
57
|
-
});
|
|
58
|
-
const exportData = {
|
|
59
|
-
schemaVersion: '1.0',
|
|
60
|
-
exportedAt: new Date().toISOString(),
|
|
61
|
-
conversationId: conversation.id,
|
|
62
|
-
messages: cleanedMessages,
|
|
63
|
-
};
|
|
64
|
-
// Guard against circular references or other JSON serialization failures
|
|
65
|
-
const json = stringifyOrNull(exportData);
|
|
66
|
-
if (json === null) {
|
|
67
|
-
onexportfailed?.('json', 'Failed to serialize conversation data');
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const succeeded = await copyState.trigger('json', json);
|
|
71
|
-
if (succeeded) {
|
|
72
|
-
onexported?.('json');
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
onexportfailed?.('json', 'Clipboard access denied. Please copy manually.');
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const formatLabels = {
|
|
79
|
-
markdown: 'Markdown',
|
|
80
|
-
json: 'JSON',
|
|
81
|
-
};
|
|
82
|
-
</script>
|
|
83
|
-
|
|
84
|
-
<div class={classNames('conversation-export-actions', className)}>
|
|
85
|
-
<!-- Screen reader announcement for copy success -->
|
|
86
|
-
<div class="sr-only" aria-live="polite" aria-atomic="true">
|
|
87
|
-
{#if copyState.copiedKey}
|
|
88
|
-
Copied as {formatLabels[copyState.copiedKey]}
|
|
89
|
-
{/if}
|
|
90
|
-
</div>
|
|
91
|
-
|
|
92
|
-
<Dropdown {id}>
|
|
93
|
-
<DropdownTrigger class="export-trigger" aria-label="Export conversation" showCaret={false}>
|
|
94
|
-
<Copy class="cinder-icon-sm" />
|
|
95
|
-
</DropdownTrigger>
|
|
96
|
-
<DropdownMenu>
|
|
97
|
-
<!-- Markdown export -->
|
|
98
|
-
<DropdownItem onclick={handleExportMarkdown}>
|
|
99
|
-
{#if copyState.copiedKey === 'markdown'}
|
|
100
|
-
<Check class="cinder-icon-sm export-icon-success" />
|
|
101
|
-
{:else}
|
|
102
|
-
<FileText class="cinder-icon-sm" />
|
|
103
|
-
{/if}
|
|
104
|
-
<span>Copy as {formatLabels.markdown}</span>
|
|
105
|
-
{#if copyState.copiedKey === 'markdown'}
|
|
106
|
-
<span class="copied-label">Copied!</span>
|
|
107
|
-
{/if}
|
|
108
|
-
</DropdownItem>
|
|
109
|
-
|
|
110
|
-
<!-- JSON export -->
|
|
111
|
-
<DropdownItem onclick={handleExportJSON}>
|
|
112
|
-
{#if copyState.copiedKey === 'json'}
|
|
113
|
-
<Check class="cinder-icon-sm export-icon-success" />
|
|
114
|
-
{:else}
|
|
115
|
-
<FileCode class="cinder-icon-sm" />
|
|
116
|
-
{/if}
|
|
117
|
-
<span>Copy as {formatLabels.json}</span>
|
|
118
|
-
{#if copyState.copiedKey === 'json'}
|
|
119
|
-
<span class="copied-label">Copied!</span>
|
|
120
|
-
{/if}
|
|
121
|
-
</DropdownItem>
|
|
122
|
-
</DropdownMenu>
|
|
123
|
-
</Dropdown>
|
|
124
|
-
</div>
|
|
125
|
-
|
|
126
|
-
<style>
|
|
127
|
-
.conversation-export-actions {
|
|
128
|
-
display: flex;
|
|
129
|
-
align-items: center;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/* Style the DropdownTrigger button as icon-only */
|
|
133
|
-
.conversation-export-actions :global(.export-trigger) {
|
|
134
|
-
display: inline-flex;
|
|
135
|
-
align-items: center;
|
|
136
|
-
justify-content: center;
|
|
137
|
-
padding: var(--cinder-space-1-5);
|
|
138
|
-
color: var(--cinder-text-muted);
|
|
139
|
-
background: transparent;
|
|
140
|
-
border: none;
|
|
141
|
-
border-radius: var(--cinder-radius-sm);
|
|
142
|
-
cursor: pointer;
|
|
143
|
-
transition: background-color var(--cinder-duration-fast) var(--cinder-ease-standard);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
@media (hover: hover) {
|
|
147
|
-
.conversation-export-actions :global(.export-trigger:hover) {
|
|
148
|
-
background: var(--cinder-surface-hover);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.conversation-export-actions :global(.export-trigger:focus-visible) {
|
|
153
|
-
outline: var(--cinder-ring-width) solid transparent;
|
|
154
|
-
box-shadow: var(--_cinder-focus-ring-shadow);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
@media (forced-colors: active) {
|
|
158
|
-
.conversation-export-actions :global(.export-trigger:focus-visible) {
|
|
159
|
-
outline: var(--cinder-ring-width) solid ButtonText;
|
|
160
|
-
outline-offset: 3px;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.export-icon-success {
|
|
165
|
-
color: var(--cinder-success);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.copied-label {
|
|
169
|
-
margin-inline-start: auto;
|
|
170
|
-
font-size: var(--cinder-text-xs);
|
|
171
|
-
color: var(--cinder-success);
|
|
172
|
-
font-weight: var(--cinder-font-medium);
|
|
173
|
-
}
|
|
174
|
-
</style>
|