@adea-ai/ui 0.153.0 → 0.154.1
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 +10 -10
- package/dist/NOTICE +10 -1
- package/dist/components/composites/about-dialog/about-dialog.d.ts.map +1 -1
- package/dist/components/composites/about-dialog/about-dialog.js +3 -1
- package/dist/components/composites/about-dialog/about-dialog.js.map +1 -1
- package/dist/components/composites/accent-picker/accent-picker.js +20 -9
- package/dist/components/composites/accent-picker/accent-picker.js.map +1 -1
- package/dist/components/composites/account-menu/account-menu.d.ts.map +1 -1
- package/dist/components/composites/account-menu/account-menu.js +20 -10
- package/dist/components/composites/account-menu/account-menu.js.map +1 -1
- package/dist/components/composites/action-button/action-button.d.ts.map +1 -1
- package/dist/components/composites/action-button/action-button.js +37 -24
- package/dist/components/composites/action-button/action-button.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-choices.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-choices.js +7 -3
- package/dist/components/composites/appearance-editor/appearance-choices.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-editor.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-editor.js +11 -6
- package/dist/components/composites/appearance-editor/appearance-editor.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-rows.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-rows.js +8 -3
- package/dist/components/composites/appearance-editor/appearance-rows.js.map +1 -1
- package/dist/components/composites/appearance-editor/font-settings-group.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/font-settings-group.js +8 -4
- package/dist/components/composites/appearance-editor/font-settings-group.js.map +1 -1
- package/dist/components/composites/catalog-browser/catalog-browser-group.d.ts.map +1 -1
- package/dist/components/composites/catalog-browser/catalog-browser-group.js +7 -3
- package/dist/components/composites/catalog-browser/catalog-browser-group.js.map +1 -1
- package/dist/components/composites/catalog-browser/catalog-browser.d.ts.map +1 -1
- package/dist/components/composites/catalog-browser/catalog-browser.js +8 -4
- package/dist/components/composites/catalog-browser/catalog-browser.js.map +1 -1
- package/dist/components/composites/chain-of-thought/chain-of-thought.d.ts.map +1 -1
- package/dist/components/composites/chain-of-thought/chain-of-thought.js +3 -1
- package/dist/components/composites/chain-of-thought/chain-of-thought.js.map +1 -1
- package/dist/components/composites/chat/chat.d.ts.map +1 -1
- package/dist/components/composites/chat/chat.js +5 -1
- package/dist/components/composites/chat/chat.js.map +1 -1
- package/dist/components/composites/checkpoint/checkpoint.d.ts.map +1 -1
- package/dist/components/composites/checkpoint/checkpoint.js +3 -1
- package/dist/components/composites/checkpoint/checkpoint.js.map +1 -1
- package/dist/components/composites/confirmation/confirmation.d.ts.map +1 -1
- package/dist/components/composites/confirmation/confirmation.js +11 -5
- package/dist/components/composites/confirmation/confirmation.js.map +1 -1
- package/dist/components/composites/context/context.d.ts.map +1 -1
- package/dist/components/composites/context/context.js +7 -4
- package/dist/components/composites/context/context.js.map +1 -1
- package/dist/components/composites/file-tree/file-tree.d.ts.map +1 -1
- package/dist/components/composites/file-tree/file-tree.js +7 -3
- package/dist/components/composites/file-tree/file-tree.js.map +1 -1
- package/dist/components/composites/help-center/help-center.d.ts.map +1 -1
- package/dist/components/composites/help-center/help-center.js +3 -1
- package/dist/components/composites/help-center/help-center.js.map +1 -1
- package/dist/components/composites/icon-picker/icon-picker.d.ts +2 -2
- package/dist/components/composites/icon-picker/icon-picker.d.ts.map +1 -1
- package/dist/components/composites/icon-picker/icon-picker.js +77 -71
- package/dist/components/composites/icon-picker/icon-picker.js.map +1 -1
- package/dist/components/composites/icon-picker/shell-icons.d.ts.map +1 -1
- package/dist/components/composites/icon-picker/shell-icons.js +119 -59
- package/dist/components/composites/icon-picker/shell-icons.js.map +1 -1
- package/dist/components/composites/inline-citation/inline-citation.d.ts.map +1 -1
- package/dist/components/composites/inline-citation/inline-citation.js +5 -2
- package/dist/components/composites/inline-citation/inline-citation.js.map +1 -1
- package/dist/components/composites/list-row/list-row-control.d.ts.map +1 -1
- package/dist/components/composites/list-row/list-row-control.js +3 -4
- package/dist/components/composites/list-row/list-row-control.js.map +1 -1
- package/dist/components/composites/message-scroller/message-scroller.d.ts.map +1 -1
- package/dist/components/composites/message-scroller/message-scroller.js +5 -2
- package/dist/components/composites/message-scroller/message-scroller.js.map +1 -1
- package/dist/components/composites/model-selector/model-selector.d.ts +15 -1
- package/dist/components/composites/model-selector/model-selector.d.ts.map +1 -1
- package/dist/components/composites/model-selector/model-selector.js +271 -33
- package/dist/components/composites/model-selector/model-selector.js.map +1 -1
- package/dist/components/composites/plan/plan.d.ts.map +1 -1
- package/dist/components/composites/plan/plan.js +3 -1
- package/dist/components/composites/plan/plan.js.map +1 -1
- package/dist/components/composites/queue/queue.d.ts.map +1 -1
- package/dist/components/composites/queue/queue.js +11 -5
- package/dist/components/composites/queue/queue.js.map +1 -1
- package/dist/components/composites/reasoning/reasoning.d.ts.map +1 -1
- package/dist/components/composites/reasoning/reasoning.js +3 -1
- package/dist/components/composites/reasoning/reasoning.js.map +1 -1
- package/dist/components/composites/scene-controls/scene-controls.d.ts.map +1 -1
- package/dist/components/composites/scene-controls/scene-controls.js +14 -7
- package/dist/components/composites/scene-controls/scene-controls.js.map +1 -1
- package/dist/components/composites/settings/settings.d.ts.map +1 -1
- package/dist/components/composites/settings/settings.js +77 -67
- package/dist/components/composites/settings/settings.js.map +1 -1
- package/dist/components/composites/sources/sources.d.ts.map +1 -1
- package/dist/components/composites/sources/sources.js +39 -39
- package/dist/components/composites/sources/sources.js.map +1 -1
- package/dist/components/composites/stack-trace/stack-trace.d.ts.map +1 -1
- package/dist/components/composites/stack-trace/stack-trace.js +9 -4
- package/dist/components/composites/stack-trace/stack-trace.js.map +1 -1
- package/dist/components/composites/stat/stat.d.ts.map +1 -1
- package/dist/components/composites/stat/stat.js +4 -1
- package/dist/components/composites/stat/stat.js.map +1 -1
- package/dist/components/composites/subagent/subagent.d.ts.map +1 -1
- package/dist/components/composites/subagent/subagent.js +3 -1
- package/dist/components/composites/subagent/subagent.js.map +1 -1
- package/dist/components/composites/task/task.d.ts.map +1 -1
- package/dist/components/composites/task/task.js +3 -1
- package/dist/components/composites/task/task.js.map +1 -1
- package/dist/components/composites/terminal/ansi.d.ts.map +1 -1
- package/dist/components/composites/terminal/ansi.js +16 -0
- package/dist/components/composites/terminal/ansi.js.map +1 -1
- package/dist/components/composites/terminal/terminal.d.ts.map +1 -1
- package/dist/components/composites/terminal/terminal.js +15 -7
- package/dist/components/composites/terminal/terminal.js.map +1 -1
- package/dist/components/composites/test-results/test-results.d.ts.map +1 -1
- package/dist/components/composites/test-results/test-results.js +15 -7
- package/dist/components/composites/test-results/test-results.js.map +1 -1
- package/dist/components/composites/tool/tool.d.ts.map +1 -1
- package/dist/components/composites/tool/tool.js +3 -1
- package/dist/components/composites/tool/tool.js.map +1 -1
- package/dist/components/composites/tree/tree.d.ts.map +1 -1
- package/dist/components/composites/tree/tree.js +3 -1
- package/dist/components/composites/tree/tree.js.map +1 -1
- package/dist/components/composites/update-dialog/update-dialog.d.ts.map +1 -1
- package/dist/components/composites/update-dialog/update-dialog.js +34 -24
- package/dist/components/composites/update-dialog/update-dialog.js.map +1 -1
- package/dist/components/composites/workspace-mark/workspace-mark.d.ts.map +1 -1
- package/dist/components/composites/workspace-mark/workspace-mark.js +17 -12
- package/dist/components/composites/workspace-mark/workspace-mark.js.map +1 -1
- package/dist/components/composites/workspace-switcher/workspace-reorder-dialog.d.ts.map +1 -1
- package/dist/components/composites/workspace-switcher/workspace-reorder-dialog.js +5 -2
- package/dist/components/composites/workspace-switcher/workspace-reorder-dialog.js.map +1 -1
- package/dist/components/composites/workspace-switcher/workspace-switcher.d.ts.map +1 -1
- package/dist/components/composites/workspace-switcher/workspace-switcher.js +9 -4
- package/dist/components/composites/workspace-switcher/workspace-switcher.js.map +1 -1
- package/dist/components/conversation/busy-send-button.d.ts.map +1 -1
- package/dist/components/conversation/busy-send-button.js +9 -5
- package/dist/components/conversation/busy-send-button.js.map +1 -1
- package/dist/components/conversation/conversation-avatar.d.ts.map +1 -1
- package/dist/components/conversation/conversation-avatar.js +6 -3
- package/dist/components/conversation/conversation-avatar.js.map +1 -1
- package/dist/components/conversation/conversation-surface.d.ts.map +1 -1
- package/dist/components/conversation/conversation-surface.js +3 -1
- package/dist/components/conversation/conversation-surface.js.map +1 -1
- package/dist/components/conversation/internal/chat-composer-shell.d.ts.map +1 -1
- package/dist/components/conversation/internal/chat-composer-shell.js +9 -4
- package/dist/components/conversation/internal/chat-composer-shell.js.map +1 -1
- package/dist/components/conversation/message-composer.d.ts.map +1 -1
- package/dist/components/conversation/message-composer.js +9 -4
- package/dist/components/conversation/message-composer.js.map +1 -1
- package/dist/components/conversation/message-row.d.ts.map +1 -1
- package/dist/components/conversation/message-row.js +11 -5
- package/dist/components/conversation/message-row.js.map +1 -1
- package/dist/components/conversation/thread-panel.d.ts.map +1 -1
- package/dist/components/conversation/thread-panel.js +3 -1
- package/dist/components/conversation/thread-panel.js.map +1 -1
- package/dist/components/conversation/transcript-composition.d.ts.map +1 -1
- package/dist/components/conversation/transcript-composition.js +3 -1
- package/dist/components/conversation/transcript-composition.js.map +1 -1
- package/dist/components/layout/floating-preview/floating-preview.d.ts.map +1 -1
- package/dist/components/layout/floating-preview/floating-preview.js +5 -2
- package/dist/components/layout/floating-preview/floating-preview.js.map +1 -1
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.d.ts.map +1 -1
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js +3 -1
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js.map +1 -1
- package/dist/components/layout/shell-rail/shell-rail.d.ts.map +1 -1
- package/dist/components/layout/shell-rail/shell-rail.js +3 -1
- package/dist/components/layout/shell-rail/shell-rail.js.map +1 -1
- package/dist/components/layout/side-rail/side-rail.d.ts.map +1 -1
- package/dist/components/layout/side-rail/side-rail.js +46 -42
- package/dist/components/layout/side-rail/side-rail.js.map +1 -1
- package/dist/components/layout/sidebar-nav/sidebar-nav.d.ts.map +1 -1
- package/dist/components/layout/sidebar-nav/sidebar-nav.js +3 -1
- package/dist/components/layout/sidebar-nav/sidebar-nav.js.map +1 -1
- package/dist/components/layout/split-layout/split-layout.d.ts.map +1 -1
- package/dist/components/layout/split-layout/split-layout.js +5 -2
- package/dist/components/layout/split-layout/split-layout.js.map +1 -1
- package/dist/components/layout/top-bar/top-bar.d.ts.map +1 -1
- package/dist/components/layout/top-bar/top-bar.js +16 -13
- package/dist/components/layout/top-bar/top-bar.js.map +1 -1
- package/dist/components/theme/appearance-panel.d.ts.map +1 -1
- package/dist/components/theme/appearance-panel.js +3 -1
- package/dist/components/theme/appearance-panel.js.map +1 -1
- package/dist/components/theme/theme-mode-toggle.d.ts.map +1 -1
- package/dist/components/theme/theme-mode-toggle.js +6 -3
- package/dist/components/theme/theme-mode-toggle.js.map +1 -1
- package/dist/components/theme/theme-toggle.d.ts.map +1 -1
- package/dist/components/theme/theme-toggle.js +6 -3
- package/dist/components/theme/theme-toggle.js.map +1 -1
- package/dist/components/ui/accordion/accordion.d.ts.map +1 -1
- package/dist/components/ui/accordion/accordion.js +3 -1
- package/dist/components/ui/accordion/accordion.js.map +1 -1
- package/dist/components/ui/alert/alert.d.ts.map +1 -1
- package/dist/components/ui/alert/alert.js +15 -9
- package/dist/components/ui/alert/alert.js.map +1 -1
- package/dist/components/ui/annotation-surface/annotation-surface.d.ts.map +1 -1
- package/dist/components/ui/annotation-surface/annotation-surface.js +5 -4
- package/dist/components/ui/annotation-surface/annotation-surface.js.map +1 -1
- package/dist/components/ui/attachment/attachment.d.ts.map +1 -1
- package/dist/components/ui/attachment/attachment.js +18 -9
- package/dist/components/ui/attachment/attachment.js.map +1 -1
- package/dist/components/ui/badge/badge.d.ts.map +1 -1
- package/dist/components/ui/badge/badge.js +30 -11
- package/dist/components/ui/badge/badge.js.map +1 -1
- package/dist/components/ui/breadcrumb/breadcrumb.d.ts.map +1 -1
- package/dist/components/ui/breadcrumb/breadcrumb.js +5 -2
- package/dist/components/ui/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/components/ui/button/button.d.ts.map +1 -1
- package/dist/components/ui/button/button.js +37 -13
- package/dist/components/ui/button/button.js.map +1 -1
- package/dist/components/ui/calendar/calendar.d.ts.map +1 -1
- package/dist/components/ui/calendar/calendar.js +5 -2
- package/dist/components/ui/calendar/calendar.js.map +1 -1
- package/dist/components/ui/carousel/carousel.d.ts.map +1 -1
- package/dist/components/ui/carousel/carousel.js +12 -6
- package/dist/components/ui/carousel/carousel.js.map +1 -1
- package/dist/components/ui/checkbox/checkbox.d.ts +13 -0
- package/dist/components/ui/checkbox/checkbox.d.ts.map +1 -1
- package/dist/components/ui/checkbox/checkbox.js +296 -21
- package/dist/components/ui/checkbox/checkbox.js.map +1 -1
- package/dist/components/ui/code-block/code-block.d.ts.map +1 -1
- package/dist/components/ui/code-block/code-block.js +9 -6
- package/dist/components/ui/code-block/code-block.js.map +1 -1
- package/dist/components/ui/combobox/combobox.d.ts.map +1 -1
- package/dist/components/ui/combobox/combobox.js +8 -11
- package/dist/components/ui/combobox/combobox.js.map +1 -1
- package/dist/components/ui/command/command.d.ts.map +1 -1
- package/dist/components/ui/command/command.js +4 -2
- package/dist/components/ui/command/command.js.map +1 -1
- package/dist/components/ui/detail-panel/detail-panel.d.ts.map +1 -1
- package/dist/components/ui/detail-panel/detail-panel.js +3 -1
- package/dist/components/ui/detail-panel/detail-panel.js.map +1 -1
- package/dist/components/ui/dialog/dialog-layer.d.ts.map +1 -1
- package/dist/components/ui/dialog/dialog-layer.js +10 -10
- package/dist/components/ui/dialog/dialog-layer.js.map +1 -1
- package/dist/components/ui/dialog/dialog.d.ts.map +1 -1
- package/dist/components/ui/dialog/dialog.js +3 -1
- package/dist/components/ui/dialog/dialog.js.map +1 -1
- package/dist/components/ui/dropdown-menu/menu-parts.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu/menu-parts.js +7 -3
- package/dist/components/ui/dropdown-menu/menu-parts.js.map +1 -1
- package/dist/components/ui/empty/empty-state.d.ts.map +1 -1
- package/dist/components/ui/empty/empty-state.js +3 -1
- package/dist/components/ui/empty/empty-state.js.map +1 -1
- package/dist/components/ui/field/field.d.ts.map +1 -1
- package/dist/components/ui/field/field.js +12 -6
- package/dist/components/ui/field/field.js.map +1 -1
- package/dist/components/ui/input/input-control.d.ts +2 -0
- package/dist/components/ui/input/input-control.d.ts.map +1 -1
- package/dist/components/ui/input/input-control.js +24 -6
- package/dist/components/ui/input/input-control.js.map +1 -1
- package/dist/components/ui/input/input.d.ts.map +1 -1
- package/dist/components/ui/input/input.js +47 -48
- package/dist/components/ui/input/input.js.map +1 -1
- package/dist/components/ui/input-group/input-group.d.ts.map +1 -1
- package/dist/components/ui/input-group/input-group.js +1 -8
- package/dist/components/ui/input-group/input-group.js.map +1 -1
- package/dist/components/ui/kbd/kbd.d.ts +23 -10
- package/dist/components/ui/kbd/kbd.d.ts.map +1 -1
- package/dist/components/ui/kbd/kbd.js +42 -11
- package/dist/components/ui/kbd/kbd.js.map +1 -1
- package/dist/components/ui/message/index.d.ts +1 -1
- package/dist/components/ui/message/index.d.ts.map +1 -1
- package/dist/components/ui/message/index.js +2 -2
- package/dist/components/ui/message/message.d.ts.map +1 -1
- package/dist/components/ui/message/message.js +5 -3
- package/dist/components/ui/message/message.js.map +1 -1
- package/dist/components/ui/message/parse-message-text.d.ts +32 -0
- package/dist/components/ui/message/parse-message-text.d.ts.map +1 -1
- package/dist/components/ui/message/parse-message-text.js +63 -3
- package/dist/components/ui/message/parse-message-text.js.map +1 -1
- package/dist/components/ui/native-select/native-select.d.ts.map +1 -1
- package/dist/components/ui/native-select/native-select.js +4 -9
- package/dist/components/ui/native-select/native-select.js.map +1 -1
- package/dist/components/ui/navigation-menu/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu/navigation-menu.js +3 -1
- package/dist/components/ui/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/ui/pagination/pagination.d.ts.map +1 -1
- package/dist/components/ui/pagination/pagination.js +7 -3
- package/dist/components/ui/pagination/pagination.js.map +1 -1
- package/dist/components/ui/questionnaire/questionnaire.d.ts.map +1 -1
- package/dist/components/ui/questionnaire/questionnaire.js +9 -4
- package/dist/components/ui/questionnaire/questionnaire.js.map +1 -1
- package/dist/components/ui/radio-group/radio-group.d.ts.map +1 -1
- package/dist/components/ui/radio-group/radio-group.js +4 -9
- package/dist/components/ui/radio-group/radio-group.js.map +1 -1
- package/dist/components/ui/resizable/resizable.d.ts.map +1 -1
- package/dist/components/ui/resizable/resizable.js +3 -1
- package/dist/components/ui/resizable/resizable.js.map +1 -1
- package/dist/components/ui/select/select.d.ts.map +1 -1
- package/dist/components/ui/select/select.js +7 -3
- package/dist/components/ui/select/select.js.map +1 -1
- package/dist/components/ui/sheet/sheet.d.ts.map +1 -1
- package/dist/components/ui/sheet/sheet.js +3 -1
- package/dist/components/ui/sheet/sheet.js.map +1 -1
- package/dist/components/ui/spinner/spinner.d.ts.map +1 -1
- package/dist/components/ui/spinner/spinner.js +3 -1
- package/dist/components/ui/spinner/spinner.js.map +1 -1
- package/dist/components/ui/status-chip/status-chip.d.ts.map +1 -1
- package/dist/components/ui/status-chip/status-chip.js +35 -30
- package/dist/components/ui/status-chip/status-chip.js.map +1 -1
- package/dist/components/ui/switch/switch.d.ts +7 -0
- package/dist/components/ui/switch/switch.d.ts.map +1 -1
- package/dist/components/ui/switch/switch.js +255 -17
- package/dist/components/ui/switch/switch.js.map +1 -1
- package/dist/components/ui/textarea/textarea.d.ts.map +1 -1
- package/dist/components/ui/textarea/textarea.js +1 -8
- package/dist/components/ui/textarea/textarea.js.map +1 -1
- package/dist/components/ui/toast/toast.d.ts.map +1 -1
- package/dist/components/ui/toast/toast.js +3 -1
- package/dist/components/ui/toast/toast.js.map +1 -1
- package/dist/components/ui/tooltip/deferred-tooltip.d.ts.map +1 -1
- package/dist/components/ui/tooltip/deferred-tooltip.js +10 -4
- package/dist/components/ui/tooltip/deferred-tooltip.js.map +1 -1
- package/dist/components/ui/tooltip/index.d.ts +1 -0
- package/dist/components/ui/tooltip/index.d.ts.map +1 -1
- package/dist/components/ui/tooltip/index.js +2 -1
- package/dist/components/ui/tooltip/lazy-tooltip.d.ts +40 -0
- package/dist/components/ui/tooltip/lazy-tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip/lazy-tooltip.js +61 -0
- package/dist/components/ui/tooltip/lazy-tooltip.js.map +1 -0
- package/dist/components/ui/trace/trace.d.ts.map +1 -1
- package/dist/components/ui/trace/trace.js +82 -68
- package/dist/components/ui/trace/trace.js.map +1 -1
- package/dist/components/ui/typography/typography.d.ts +1 -1
- package/dist/components/ui/typography/typography.d.ts.map +1 -1
- package/dist/components/ui/typography/typography.js +5 -6
- package/dist/components/ui/typography/typography.js.map +1 -1
- package/dist/index.js +3 -2
- package/dist/lib/clipboard.d.ts.map +1 -1
- package/dist/lib/clipboard.js +3 -0
- package/dist/lib/clipboard.js.map +1 -1
- package/dist/lib/fast-icon.d.ts +18 -0
- package/dist/lib/fast-icon.d.ts.map +1 -0
- package/dist/lib/fast-icon.js +75 -0
- package/dist/lib/fast-icon.js.map +1 -0
- package/dist/lib/form-field.d.ts +1 -1
- package/dist/lib/form-field.js +3 -1
- package/dist/lib/form-field.js.map +1 -1
- package/dist/lib/observe-resize.d.ts +14 -0
- package/dist/lib/observe-resize.d.ts.map +1 -0
- package/dist/lib/observe-resize.js +19 -0
- package/dist/lib/observe-resize.js.map +1 -0
- package/dist/lib/overlay.d.ts +1 -1
- package/dist/lib/overlay.d.ts.map +1 -1
- package/dist/lib/overlay.js +1 -1
- package/dist/lib/overlay.js.map +1 -1
- package/dist/lint/index.d.ts +1 -0
- package/dist/lint/index.d.ts.map +1 -1
- package/dist/lint.js +251 -118
- package/dist/lint.js.map +1 -1
- package/dist/r/action-button.json +3 -1
- package/dist/r/floating-preview.json +2 -1
- package/dist/r/icon-picker.json +0 -1
- package/dist/r/lib.json +10 -0
- package/dist/r/model-selector.json +1 -0
- package/dist/r/plan.json +2 -1
- package/dist/r/queue.json +2 -1
- package/dist/r/registry.json +33 -9
- package/dist/r/scene-controls.json +2 -1
- package/dist/r/side-rail.json +1 -0
- package/dist/r/src/components/composites/about-dialog/about-dialog.tsx +5 -1
- package/dist/r/src/components/composites/accent-picker/accent-picker.tsx +22 -17
- package/dist/r/src/components/composites/account-menu/account-menu.tsx +21 -9
- package/dist/r/src/components/composites/action-button/action-button.tsx +38 -21
- package/dist/r/src/components/composites/appearance-editor/appearance-choices.tsx +7 -1
- package/dist/r/src/components/composites/appearance-editor/appearance-editor.tsx +13 -1
- package/dist/r/src/components/composites/appearance-editor/appearance-rows.tsx +13 -1
- package/dist/r/src/components/composites/appearance-editor/font-settings-group.tsx +13 -1
- package/dist/r/src/components/composites/catalog-browser/catalog-browser-group.tsx +11 -1
- package/dist/r/src/components/composites/catalog-browser/catalog-browser.tsx +11 -1
- package/dist/r/src/components/composites/chain-of-thought/chain-of-thought.tsx +5 -1
- package/dist/r/src/components/composites/chat/chat.tsx +11 -1
- package/dist/r/src/components/composites/checkpoint/checkpoint.tsx +5 -1
- package/dist/r/src/components/composites/confirmation/confirmation.tsx +15 -1
- package/dist/r/src/components/composites/context/context.tsx +9 -1
- package/dist/r/src/components/composites/file-tree/file-tree.tsx +11 -1
- package/dist/r/src/components/composites/help-center/help-center.tsx +5 -1
- package/dist/r/src/components/composites/icon-picker/icon-picker.tsx +59 -31
- package/dist/r/src/components/composites/icon-picker/shell-icons.ts +121 -59
- package/dist/r/src/components/composites/inline-citation/inline-citation.tsx +6 -1
- package/dist/r/src/components/composites/list-row/list-row-control.tsx +7 -5
- package/dist/r/src/components/composites/message-scroller/message-scroller.tsx +6 -1
- package/dist/r/src/components/composites/model-selector/model-selector.tsx +197 -11
- package/dist/r/src/components/composites/plan/plan.tsx +5 -1
- package/dist/r/src/components/composites/queue/queue.tsx +15 -1
- package/dist/r/src/components/composites/reasoning/reasoning.tsx +5 -1
- package/dist/r/src/components/composites/scene-controls/scene-controls.tsx +17 -1
- package/dist/r/src/components/composites/settings/settings.tsx +23 -14
- package/dist/r/src/components/composites/sources/sources.tsx +27 -20
- package/dist/r/src/components/composites/stack-trace/stack-trace.tsx +13 -1
- package/dist/r/src/components/composites/stat/stat.tsx +9 -1
- package/dist/r/src/components/composites/subagent/subagent.tsx +5 -1
- package/dist/r/src/components/composites/task/task.tsx +5 -1
- package/dist/r/src/components/composites/terminal/ansi.ts +18 -0
- package/dist/r/src/components/composites/terminal/terminal.tsx +17 -7
- package/dist/r/src/components/composites/test-results/test-results.tsx +17 -7
- package/dist/r/src/components/composites/tool/tool.tsx +5 -1
- package/dist/r/src/components/composites/tree/tree.tsx +5 -1
- package/dist/r/src/components/composites/update-dialog/update-dialog.tsx +35 -15
- package/dist/r/src/components/composites/workspace-mark/workspace-mark.tsx +14 -7
- package/dist/r/src/components/composites/workspace-switcher/workspace-reorder-dialog.tsx +6 -1
- package/dist/r/src/components/composites/workspace-switcher/workspace-switcher.tsx +13 -1
- package/dist/r/src/components/conversation/busy-send-button.tsx +11 -1
- package/dist/r/src/components/conversation/conversation-avatar.tsx +7 -1
- package/dist/r/src/components/conversation/conversation-surface.tsx +5 -1
- package/dist/r/src/components/conversation/internal/chat-composer-shell.tsx +13 -1
- package/dist/r/src/components/conversation/message-composer.tsx +13 -1
- package/dist/r/src/components/conversation/message-row.tsx +15 -1
- package/dist/r/src/components/conversation/thread-panel.tsx +5 -1
- package/dist/r/src/components/conversation/transcript-composition.tsx +5 -1
- package/dist/r/src/components/layout/floating-preview/floating-preview.tsx +6 -1
- package/dist/r/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +5 -1
- package/dist/r/src/components/layout/shell-rail/shell-rail.tsx +5 -1
- package/dist/r/src/components/layout/side-rail/side-rail.tsx +16 -19
- package/dist/r/src/components/layout/sidebar-nav/sidebar-nav.tsx +5 -1
- package/dist/r/src/components/layout/split-layout/split-layout.tsx +6 -1
- package/dist/r/src/components/layout/top-bar/top-bar.tsx +8 -8
- package/dist/r/src/components/theme/appearance-panel.tsx +6 -1
- package/dist/r/src/components/theme/theme-mode-toggle.tsx +7 -1
- package/dist/r/src/components/theme/theme-toggle.tsx +7 -1
- package/dist/r/src/components/ui/accordion/accordion.tsx +5 -1
- package/dist/r/src/components/ui/alert/alert.tsx +20 -3
- package/dist/r/src/components/ui/annotation-surface/annotation-surface.tsx +6 -3
- package/dist/r/src/components/ui/attachment/attachment.tsx +19 -8
- package/dist/r/src/components/ui/badge/badge.tsx +24 -8
- package/dist/r/src/components/ui/breadcrumb/breadcrumb.tsx +9 -1
- package/dist/r/src/components/ui/button/button.tsx +47 -16
- package/dist/r/src/components/ui/calendar/calendar.tsx +6 -1
- package/dist/r/src/components/ui/carousel/carousel.tsx +15 -5
- package/dist/r/src/components/ui/checkbox/checkbox.tsx +260 -22
- package/dist/r/src/components/ui/code-block/code-block.tsx +11 -5
- package/dist/r/src/components/ui/combobox/combobox.tsx +8 -9
- package/dist/r/src/components/ui/command/command.tsx +8 -4
- package/dist/r/src/components/ui/detail-panel/detail-panel.tsx +5 -1
- package/dist/r/src/components/ui/dialog/dialog-layer.tsx +16 -18
- package/dist/r/src/components/ui/dialog/dialog.tsx +5 -1
- package/dist/r/src/components/ui/dropdown-menu/menu-parts.tsx +11 -1
- package/dist/r/src/components/ui/empty/empty-state.tsx +5 -1
- package/dist/r/src/components/ui/field/field.tsx +14 -5
- package/dist/r/src/components/ui/input/input-control.tsx +28 -19
- package/dist/r/src/components/ui/input/input.tsx +9 -12
- package/dist/r/src/components/ui/input-group/input-group.tsx +1 -8
- package/dist/r/src/components/ui/kbd/kbd.tsx +53 -12
- package/dist/r/src/components/ui/message/index.ts +3 -0
- package/dist/r/src/components/ui/message/message.tsx +11 -2
- package/dist/r/src/components/ui/message/parse-message-text.ts +94 -2
- package/dist/r/src/components/ui/native-select/native-select.tsx +6 -9
- package/dist/r/src/components/ui/navigation-menu/navigation-menu.tsx +5 -1
- package/dist/r/src/components/ui/pagination/pagination.tsx +11 -1
- package/dist/r/src/components/ui/questionnaire/questionnaire.tsx +13 -1
- package/dist/r/src/components/ui/radio-group/radio-group.tsx +6 -9
- package/dist/r/src/components/ui/resizable/resizable.tsx +5 -1
- package/dist/r/src/components/ui/select/select.tsx +11 -1
- package/dist/r/src/components/ui/sheet/sheet.tsx +5 -1
- package/dist/r/src/components/ui/spinner/spinner.tsx +5 -1
- package/dist/r/src/components/ui/status-chip/status-chip.tsx +14 -7
- package/dist/r/src/components/ui/switch/switch.tsx +235 -28
- package/dist/r/src/components/ui/textarea/textarea.tsx +1 -8
- package/dist/r/src/components/ui/toast/toast.tsx +5 -1
- package/dist/r/src/components/ui/tooltip/deferred-tooltip.tsx +14 -8
- package/dist/r/src/components/ui/tooltip/index.ts +1 -0
- package/dist/r/src/components/ui/tooltip/lazy-tooltip.tsx +73 -0
- package/dist/r/src/components/ui/trace/trace.tsx +61 -28
- package/dist/r/src/components/ui/typography/typography.tsx +6 -5
- package/dist/r/src/lib/clipboard.ts +4 -0
- package/dist/r/src/lib/fast-icon.ts +88 -0
- package/dist/r/src/lib/form-field.ts +7 -7
- package/dist/r/src/lib/observe-resize.ts +28 -0
- package/dist/r/src/lib/overlay.ts +1 -1
- package/dist/r/subagent.json +2 -1
- package/dist/r/tool.json +2 -1
- package/dist/r/tooltip.json +5 -0
- package/dist/r/top-bar.json +1 -0
- package/dist/r/trace.json +0 -1
- package/package.json +1 -1
- package/registry.json +33 -9
- package/src/components/composites/about-dialog/about-dialog.tsx +5 -1
- package/src/components/composites/accent-picker/accent-picker.tsx +22 -17
- package/src/components/composites/account-menu/account-menu.tsx +21 -9
- package/src/components/composites/action-button/action-button.tsx +38 -21
- package/src/components/composites/appearance-editor/appearance-choices.tsx +7 -1
- package/src/components/composites/appearance-editor/appearance-editor.tsx +13 -1
- package/src/components/composites/appearance-editor/appearance-rows.tsx +13 -1
- package/src/components/composites/appearance-editor/font-settings-group.tsx +13 -1
- package/src/components/composites/catalog-browser/catalog-browser-group.tsx +11 -1
- package/src/components/composites/catalog-browser/catalog-browser.tsx +11 -1
- package/src/components/composites/chain-of-thought/chain-of-thought.tsx +5 -1
- package/src/components/composites/chat/chat.tsx +11 -1
- package/src/components/composites/checkpoint/checkpoint.tsx +5 -1
- package/src/components/composites/confirmation/confirmation.tsx +15 -1
- package/src/components/composites/context/context.tsx +9 -1
- package/src/components/composites/file-tree/file-tree.tsx +11 -1
- package/src/components/composites/help-center/help-center.tsx +5 -1
- package/src/components/composites/icon-picker/icon-picker.tsx +59 -31
- package/src/components/composites/icon-picker/shell-icons.ts +121 -59
- package/src/components/composites/inline-citation/inline-citation.tsx +6 -1
- package/src/components/composites/list-row/list-row-control.tsx +7 -5
- package/src/components/composites/message-scroller/message-scroller.tsx +6 -1
- package/src/components/composites/model-selector/model-selector.tsx +197 -11
- package/src/components/composites/plan/plan.tsx +5 -1
- package/src/components/composites/queue/queue.tsx +15 -1
- package/src/components/composites/reasoning/reasoning.tsx +5 -1
- package/src/components/composites/scene-controls/scene-controls.tsx +17 -1
- package/src/components/composites/settings/settings.tsx +23 -14
- package/src/components/composites/sources/sources.tsx +27 -20
- package/src/components/composites/stack-trace/stack-trace.tsx +13 -1
- package/src/components/composites/stat/stat.tsx +9 -1
- package/src/components/composites/subagent/subagent.tsx +5 -1
- package/src/components/composites/task/task.tsx +5 -1
- package/src/components/composites/terminal/ansi.ts +18 -0
- package/src/components/composites/terminal/terminal.tsx +17 -7
- package/src/components/composites/test-results/test-results.tsx +17 -7
- package/src/components/composites/tool/tool.tsx +5 -1
- package/src/components/composites/tree/tree.tsx +5 -1
- package/src/components/composites/update-dialog/update-dialog.tsx +35 -15
- package/src/components/composites/workspace-mark/workspace-mark.tsx +14 -7
- package/src/components/composites/workspace-switcher/workspace-reorder-dialog.tsx +6 -1
- package/src/components/composites/workspace-switcher/workspace-switcher.tsx +13 -1
- package/src/components/conversation/busy-send-button.tsx +11 -1
- package/src/components/conversation/conversation-avatar.tsx +7 -1
- package/src/components/conversation/conversation-surface.tsx +5 -1
- package/src/components/conversation/internal/chat-composer-shell.tsx +13 -1
- package/src/components/conversation/message-composer.tsx +13 -1
- package/src/components/conversation/message-row.tsx +15 -1
- package/src/components/conversation/thread-panel.tsx +5 -1
- package/src/components/conversation/transcript-composition.tsx +5 -1
- package/src/components/layout/floating-preview/floating-preview.tsx +6 -1
- package/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +5 -1
- package/src/components/layout/shell-rail/shell-rail.tsx +5 -1
- package/src/components/layout/side-rail/side-rail.tsx +16 -19
- package/src/components/layout/sidebar-nav/sidebar-nav.tsx +5 -1
- package/src/components/layout/split-layout/split-layout.tsx +6 -1
- package/src/components/layout/top-bar/top-bar.tsx +8 -8
- package/src/components/theme/appearance-panel.tsx +6 -1
- package/src/components/theme/theme-mode-toggle.tsx +7 -1
- package/src/components/theme/theme-toggle.tsx +7 -1
- package/src/components/ui/accordion/accordion.tsx +5 -1
- package/src/components/ui/alert/alert.tsx +20 -3
- package/src/components/ui/annotation-surface/annotation-surface.tsx +6 -3
- package/src/components/ui/attachment/attachment.tsx +19 -8
- package/src/components/ui/badge/badge.tsx +24 -8
- package/src/components/ui/breadcrumb/breadcrumb.tsx +9 -1
- package/src/components/ui/button/button.tsx +47 -16
- package/src/components/ui/calendar/calendar.tsx +6 -1
- package/src/components/ui/carousel/carousel.tsx +15 -5
- package/src/components/ui/checkbox/checkbox.tsx +260 -22
- package/src/components/ui/code-block/code-block.tsx +11 -5
- package/src/components/ui/combobox/combobox.tsx +8 -9
- package/src/components/ui/command/command.tsx +8 -4
- package/src/components/ui/detail-panel/detail-panel.tsx +5 -1
- package/src/components/ui/dialog/dialog-layer.tsx +16 -18
- package/src/components/ui/dialog/dialog.tsx +5 -1
- package/src/components/ui/dropdown-menu/menu-parts.tsx +11 -1
- package/src/components/ui/empty/empty-state.tsx +5 -1
- package/src/components/ui/field/field.tsx +14 -5
- package/src/components/ui/input/input-control.tsx +28 -19
- package/src/components/ui/input/input.tsx +9 -12
- package/src/components/ui/input-group/input-group.tsx +1 -8
- package/src/components/ui/kbd/kbd.tsx +53 -12
- package/src/components/ui/message/index.ts +3 -0
- package/src/components/ui/message/message.tsx +11 -2
- package/src/components/ui/message/parse-message-text.ts +94 -2
- package/src/components/ui/native-select/native-select.tsx +6 -9
- package/src/components/ui/navigation-menu/navigation-menu.tsx +5 -1
- package/src/components/ui/pagination/pagination.tsx +11 -1
- package/src/components/ui/questionnaire/questionnaire.tsx +13 -1
- package/src/components/ui/radio-group/radio-group.tsx +6 -9
- package/src/components/ui/resizable/resizable.tsx +5 -1
- package/src/components/ui/select/select.tsx +11 -1
- package/src/components/ui/sheet/sheet.tsx +5 -1
- package/src/components/ui/spinner/spinner.tsx +5 -1
- package/src/components/ui/status-chip/status-chip.tsx +14 -7
- package/src/components/ui/switch/switch.tsx +235 -28
- package/src/components/ui/textarea/textarea.tsx +1 -8
- package/src/components/ui/toast/toast.tsx +5 -1
- package/src/components/ui/tooltip/deferred-tooltip.tsx +14 -8
- package/src/components/ui/tooltip/index.ts +1 -0
- package/src/components/ui/tooltip/lazy-tooltip.tsx +73 -0
- package/src/components/ui/trace/trace.tsx +61 -28
- package/src/components/ui/typography/typography.tsx +6 -5
- package/src/lib/clipboard.ts +4 -0
- package/src/lib/fast-icon.ts +88 -0
- package/src/lib/form-field.ts +7 -7
- package/src/lib/observe-resize.ts +28 -0
- package/src/lib/overlay.ts +1 -1
- package/src/lint/index.ts +199 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","names":["createMemo","For","Index","Match","Show","splitProps","Switch","cn","CodeBlock","InlineCode","parseMessageText","role","label","streaming","anchorId","Message","props","local","rest","_el$","_tmpl$","_$spread","_$mergeProps","undefined","class","_$insert","children","MessageHeader","avatar","time","_el$2","_tmpl$2","_el$3","firstChild","_$createComponent","when","avatarSlot","_$memo","timeSlot","_el$4","_tmpl$3","MessageContent","_el$5","_tmpl$4","MessageActions","_el$6","_tmpl$5","MessageFooter","_el$7","_tmpl$6","index","language","code","complete","count","render","numbers","text","codeBlockProps","block","citations","sameBlock","a","b","kind","raw","MessageText","previous","previousCount","citationCount","blocks","next","merged","map","codeIndexes","lastIsProse","last","at","_el$8","_tmpl$8","each","BlockView","codeProps","codeIndex","_tmpl$7","chosen","choice","heading","_el$0","_tmpl$9","Inline","nodes","inline","_$effect","_$setAttribute","level","list","ordered","fallback","_el$10","_tmpl$1","items","item","_el$11","_tmpl$10","_el$1","_tmpl$0","_el$12","start","quote","_el$13","_tmpl$11","paragraph","_el$14","_tmpl$12","node","strong","_el$15","_tmpl$13","em","_el$16","_tmpl$14","link","_el$17","_tmpl$15","href","cite","marker"],"sources":["../../../../src/components/ui/message/message.tsx"],"sourcesContent":["import {\n createMemo,\n For,\n Index,\n Match,\n Show,\n splitProps,\n Switch,\n type ComponentProps,\n type JSX,\n} from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { CodeBlock, InlineCode, type CodeBlockProps } from '../code-block'\nimport { parseMessageText, type MessageBlock, type MessageInline } from './parse-message-text'\n\n/**\n * Message.\n *\n * One turn. The two speakers are laid out differently on purpose, and that is\n * the whole design:\n *\n * - **The person's turn is a bubble on the trailing edge** — short, bounded, and\n * easy to find when scrolling back through a long session.\n * - **The assistant's turn is the page.** It has no surface, spans the reading\n * column, and holds everything the agent did *for that request* — activity\n * (a `Trace`), prose, code, a pending decision — in one place, so a turn\n * reads as an answer with its working underneath it rather than as a chain of\n * unrelated cards.\n *\n * `label` is the turn's accessible name (\"You\", \"Assistant\"): the avatar and\n * name are not drawn for every turn, because a transcript that repeats a speaker\n * on every line is one nobody reads, but the name must still be announced.\n * `streaming` sets `aria-busy`, which tells assistive technology to wait for the\n * turn to settle before reading it instead of announcing every token.\n *\n * `anchorId` is the stable identity `MessageScroller` uses to keep the reader's\n * place when older turns are inserted above it.\n */\nexport type MessageRole = 'user' | 'assistant' | 'system'\n\nexport type MessageProps = Omit<ComponentProps<'article'>, 'role'> & {\n role: MessageRole\n label: string\n streaming?: boolean\n anchorId?: string\n}\n\nexport function Message(props: MessageProps) {\n const [local, rest] = splitProps(props, [\n 'class',\n 'role',\n 'label',\n 'streaming',\n 'anchorId',\n 'children',\n ])\n return (\n <article\n data-slot=\"message\"\n data-role={local.role}\n data-anchor-id={local.anchorId}\n aria-label={local.label}\n aria-busy={local.streaming || undefined}\n class={cn(\n 'group/message mx-auto flex w-full max-w-3xl min-w-0 flex-col gap-2 py-2',\n // The engine may skip layout for turns far off screen; the intrinsic size\n // keeps the scrollbar honest while it does.\n '[content-visibility:auto] [contain-intrinsic-size:auto_6rem]',\n {\n 'items-end ps-[clamp(0rem,12%,4rem)]': local.role === 'user',\n 'items-stretch': local.role !== 'user',\n },\n local.class\n )}\n {...rest}\n >\n {local.children}\n </article>\n )\n}\n\n/** The speaker's mark and name, for the turns that draw one. */\nexport function MessageHeader(\n props: ComponentProps<'header'> & { avatar?: JSX.Element; time?: JSX.Element }\n) {\n const [local, rest] = splitProps(props, ['class', 'avatar', 'time', 'children'])\n return (\n <header\n data-slot=\"message-header\"\n class={cn('flex items-center gap-2 text-xs text-muted-foreground', local.class)}\n {...rest}\n >\n <Show when={local.avatar}>{(avatarSlot) => <>{avatarSlot()}</>}</Show>\n <span class=\"font-medium text-foreground\">{local.children}</span>\n <Show when={local.time}>{(timeSlot) => <span class=\"tabular-nums\">{timeSlot()}</span>}</Show>\n </header>\n )\n}\n\n/** The turn's parts, stacked. Gap is the rhythm between prose, activity and code. */\nexport function MessageContent(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class', 'children'])\n return (\n <div\n data-slot=\"message-content\"\n class={cn(\n 'flex w-full max-w-3xl min-w-0 flex-col gap-3 font-content text-content',\n local.class\n )}\n {...rest}\n >\n {local.children}\n </div>\n )\n}\n\n/**\n * Actions that belong to the turn (copy, retry). Hidden until the turn is hovered\n * or focused so the column is not a wall of buttons, but never `display: none`:\n * a control that only exists under the pointer cannot be reached by keyboard,\n * and on a touch screen there is no hover, so coarse pointers always see them.\n */\nexport function MessageActions(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class', 'children'])\n return (\n <div\n data-slot=\"message-actions\"\n class={cn(\n 'flex items-center gap-1 opacity-0 transition-opacity ease-out group-focus-within/message:opacity-100 group-hover/message:opacity-100 [@media(hover:none)]:opacity-100',\n local.class\n )}\n {...rest}\n >\n {local.children}\n </div>\n )\n}\n\nexport function MessageFooter(props: ComponentProps<'footer'>) {\n const [local, rest] = splitProps(props, ['class', 'children'])\n return (\n <footer\n data-slot=\"message-footer\"\n class={cn('flex min-w-0 items-center gap-2 text-xs text-muted-foreground', local.class)}\n {...rest}\n >\n {local.children}\n </footer>\n )\n}\n\n/** The props of a fenced block the host may set. */\nexport type MessageCodeBlockProps = Pick<\n CodeBlockProps,\n 'loadHighlight' | 'maxHeight' | 'wrap' | 'showLineNumbers' | 'lineMarks' | 'lineLimit'\n>\n\n/** What the host is told about a fenced block when it chooses that block's props. */\nexport type MessageCodeBlockInfo = Readonly<{\n /** Position among the text's fenced blocks, from 0. */\n index: number\n language: string | undefined\n code: string\n complete: boolean\n}>\n\n/**\n * How `MessageText` draws citation markers. `count` is how many sources the host\n * has; a `[^n]` marker is a citation only when every `n` is within it. `render`\n * receives the 1-based source numbers and draws the marker, so the host decides\n * what a number means (`messageCitations` in the inline-citation composite does\n * this for a `Source` list).\n */\nexport type MessageCitations = Readonly<{\n count: number\n render: (numbers: readonly number[]) => JSX.Element\n}>\n\nexport type MessageTextProps = Omit<ComponentProps<'div'>, 'children'> & {\n text: string\n /** True while text may still arrive: a trailing open fence renders as partial code. */\n streaming?: boolean\n /**\n * Forwarded to each fenced block, e.g. to supply a lazy highlighter. A function\n * chooses per block, which is how line marks reach a block: marks belong to the\n * host's knowledge of the code (a diff, a failing line), never to the text.\n */\n codeBlockProps?: MessageCodeBlockProps | ((block: MessageCodeBlockInfo) => MessageCodeBlockProps)\n /** Without it, `[^1]` stays the literal text it was written as. */\n citations?: MessageCitations\n}\n\nfunction sameBlock(a: MessageBlock | undefined, b: MessageBlock): boolean {\n return (\n a !== undefined &&\n a.kind === b.kind &&\n a.raw === b.raw &&\n (a.kind !== 'code' || (b.kind === 'code' && a.complete === b.complete))\n )\n}\n\n/**\n * Text, read safely.\n *\n * Renders `parseMessageText`'s blocks as elements: nothing is interpreted as\n * HTML and a link only becomes an anchor when its scheme is http, https or\n * mailto. Blocks are kept by *position* and reuse their previous parsed object\n * when unchanged, so a streaming turn updates the block that is growing and\n * leaves every earlier paragraph and code block — and any selection or focus\n * inside them — untouched.\n */\nexport function MessageText(props: MessageTextProps) {\n const [local, rest] = splitProps(props, [\n 'class',\n 'text',\n 'streaming',\n 'codeBlockProps',\n 'citations',\n ])\n let previous: readonly MessageBlock[] = []\n let previousCount = 0\n // Only the number of sources reaches the parser, so a new `render` function\n // does not reparse the text, and a changed count does.\n const citationCount = () => local.citations?.count ?? 0\n const blocks = createMemo(() => {\n const count = citationCount()\n if (count !== previousCount) previous = []\n previousCount = count\n const next = parseMessageText(local.text, {\n streaming: local.streaming,\n citations: count || undefined,\n })\n const merged = next.map((block, index) =>\n sameBlock(previous[index], block) ? previous[index]! : block\n )\n previous = merged\n return merged\n })\n // The nth fenced block, so a host can address it. Blocks keep their positions\n // while text streams in after them, so an index stays attached to its block.\n const codeIndexes = createMemo(() => {\n let next = 0\n return blocks().map((block) => (block.kind === 'code' ? next++ : -1))\n })\n const lastIsProse = () => {\n const last = blocks().at(-1)\n return last !== undefined && last.kind !== 'code'\n }\n return (\n <div data-slot=\"message-text\" class={cn('flex min-w-0 flex-col gap-3', local.class)} {...rest}>\n <Index each={blocks()}>\n {(block, index) => (\n <BlockView\n block={block()}\n codeProps={local.codeBlockProps}\n codeIndex={() => codeIndexes()[index] ?? 0}\n citations={local.citations}\n />\n )}\n </Index>\n <Show when={local.streaming && lastIsProse()}>\n <span class=\"streaming-caret\" aria-hidden=\"true\" />\n </Show>\n </div>\n )\n}\n\nfunction BlockView(props: {\n block: MessageBlock\n codeProps?: MessageTextProps['codeBlockProps']\n codeIndex: () => number\n citations?: MessageCitations\n}) {\n return (\n <Switch>\n <Match when={props.block.kind === 'code' && props.block}>\n {(block) => {\n const code = () => block() as Extract<MessageBlock, { kind: 'code' }>\n const chosen = () => {\n const choice = props.codeProps\n return typeof choice === 'function'\n ? choice({\n index: props.codeIndex(),\n language: code().language,\n code: code().code,\n complete: code().complete,\n })\n : choice\n }\n return (\n <CodeBlock\n code={code().code}\n language={code().language}\n complete={code().complete}\n {...chosen()}\n />\n )\n }}\n </Match>\n <Match when={props.block.kind === 'heading' && props.block}>\n {(block) => {\n const heading = () => block() as Extract<MessageBlock, { kind: 'heading' }>\n return (\n <p\n role=\"heading\"\n aria-level={heading().level + 2}\n class=\"font-semibold text-foreground [overflow-wrap:anywhere]\"\n >\n <Inline nodes={heading().inline} citations={props.citations} />\n </p>\n )\n }}\n </Match>\n <Match when={props.block.kind === 'list' && props.block}>\n {(block) => {\n const list = () => block() as Extract<MessageBlock, { kind: 'list' }>\n return (\n <Show\n when={list().ordered}\n fallback={\n <ul class=\"m-0 ms-5 flex list-disc flex-col gap-1 p-0 marker:text-muted-foreground\">\n <For each={list().items}>\n {(item) => (\n <li class=\"[overflow-wrap:anywhere]\">\n <Inline nodes={item} citations={props.citations} />\n </li>\n )}\n </For>\n </ul>\n }\n >\n <ol\n start={list().start}\n class=\"m-0 ms-5 flex list-decimal flex-col gap-1 p-0 marker:text-muted-foreground\"\n >\n <For each={list().items}>\n {(item) => (\n <li class=\"[overflow-wrap:anywhere]\">\n <Inline nodes={item} citations={props.citations} />\n </li>\n )}\n </For>\n </ol>\n </Show>\n )\n }}\n </Match>\n <Match when={props.block.kind === 'quote' && props.block}>\n {(block) => {\n const quote = () => block() as Extract<MessageBlock, { kind: 'quote' }>\n return (\n <blockquote class=\"m-0 border-s-2 border-border ps-3 whitespace-pre-wrap text-muted-foreground [overflow-wrap:anywhere]\">\n <Inline nodes={quote().inline} citations={props.citations} />\n </blockquote>\n )\n }}\n </Match>\n <Match when={props.block.kind === 'paragraph' && props.block}>\n {(block) => {\n const paragraph = () => block() as Extract<MessageBlock, { kind: 'paragraph' }>\n return (\n <p class=\"m-0 whitespace-pre-wrap [overflow-wrap:anywhere]\">\n <Inline nodes={paragraph().inline} citations={props.citations} />\n </p>\n )\n }}\n </Match>\n </Switch>\n )\n}\n\nfunction Inline(props: { nodes: readonly MessageInline[]; citations?: MessageCitations }) {\n // By position, not identity: the parser returns fresh nodes for the growing\n // paragraph on every streamed token, and a keyed list would rebuild each one.\n return (\n <Index each={props.nodes}>\n {(node) => (\n <Switch>\n {/* Fragments keep the reads reactive: Match runs its callback untracked. */}\n <Match when={node().kind === 'text' && node()}>\n {(text) => <>{(text() as { text: string }).text}</>}\n </Match>\n <Match when={node().kind === 'code' && node()}>\n {(code) => <InlineCode>{(code() as { text: string }).text}</InlineCode>}\n </Match>\n <Match when={node().kind === 'strong' && node()}>\n {(strong) => (\n <strong class=\"font-semibold\">\n <Inline\n nodes={(strong() as { children: readonly MessageInline[] }).children}\n citations={props.citations}\n />\n </strong>\n )}\n </Match>\n <Match when={node().kind === 'em' && node()}>\n {(em) => (\n <em>\n <Inline\n nodes={(em() as { children: readonly MessageInline[] }).children}\n citations={props.citations}\n />\n </em>\n )}\n </Match>\n <Match when={node().kind === 'link' && node()}>\n {(link) => (\n <a\n href={(link() as { href: string }).href}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n class=\"text-primary underline underline-offset-2 hover:no-underline\"\n >\n <Inline nodes={(link() as { children: readonly MessageInline[] }).children} />\n </a>\n )}\n </Match>\n <Match when={node().kind === 'cite' && node()}>\n {(cite) => {\n const marker = () => cite() as { numbers: readonly number[]; raw: string }\n // The parser read this as a citation only while the host had sources;\n // if they have gone since, the marker is the text it was written as.\n // Match invokes this callback untracked; JSX keeps renderer and\n // same-count source replacements reactive without replacing the block.\n return (\n <>{props.citations ? props.citations.render(marker().numbers) : marker().raw}</>\n )\n }}\n </Match>\n </Switch>\n )}\n </Index>\n )\n}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
+
{"version":3,"file":"message.js","names":["createMemo","For","Index","Match","Show","splitProps","Switch","cn","CodeBlock","InlineCode","parseMessageTextIncremental","role","label","streaming","anchorId","Message","props","local","rest","_el$","_tmpl$","_$spread","_$mergeProps","undefined","class","_$insert","children","MessageHeader","avatar","time","_el$2","_tmpl$2","_el$3","firstChild","_$createComponent","when","avatarSlot","_$memo","timeSlot","_el$4","_tmpl$3","MessageContent","_el$5","_tmpl$4","MessageActions","_el$6","_tmpl$5","MessageFooter","_el$7","_tmpl$6","index","language","code","complete","count","render","numbers","text","codeBlockProps","block","citations","sameBlock","a","b","kind","raw","MessageText","previous","previousCount","parsed","citationCount","blocks","next","merged","map","codeIndexes","lastIsProse","last","at","_el$8","_tmpl$8","each","BlockView","codeProps","codeIndex","_tmpl$7","chosen","choice","heading","_el$0","_tmpl$9","Inline","nodes","inline","_$effect","_$setAttribute","level","list","ordered","fallback","_el$10","_tmpl$1","items","item","_el$11","_tmpl$10","_el$1","_tmpl$0","_el$12","start","quote","_el$13","_tmpl$11","paragraph","_el$14","_tmpl$12","node","strong","_el$15","_tmpl$13","em","_el$16","_tmpl$14","link","_el$17","_tmpl$15","href","cite","marker"],"sources":["../../../../src/components/ui/message/message.tsx"],"sourcesContent":["import {\n createMemo,\n For,\n Index,\n Match,\n Show,\n splitProps,\n Switch,\n type ComponentProps,\n type JSX,\n} from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { CodeBlock, InlineCode, type CodeBlockProps } from '../code-block'\nimport {\n parseMessageTextIncremental,\n type MessageBlock,\n type MessageInline,\n type MessageParse,\n} from './parse-message-text'\n\n/**\n * Message.\n *\n * One turn. The two speakers are laid out differently on purpose, and that is\n * the whole design:\n *\n * - **The person's turn is a bubble on the trailing edge** — short, bounded, and\n * easy to find when scrolling back through a long session.\n * - **The assistant's turn is the page.** It has no surface, spans the reading\n * column, and holds everything the agent did *for that request* — activity\n * (a `Trace`), prose, code, a pending decision — in one place, so a turn\n * reads as an answer with its working underneath it rather than as a chain of\n * unrelated cards.\n *\n * `label` is the turn's accessible name (\"You\", \"Assistant\"): the avatar and\n * name are not drawn for every turn, because a transcript that repeats a speaker\n * on every line is one nobody reads, but the name must still be announced.\n * `streaming` sets `aria-busy`, which tells assistive technology to wait for the\n * turn to settle before reading it instead of announcing every token.\n *\n * `anchorId` is the stable identity `MessageScroller` uses to keep the reader's\n * place when older turns are inserted above it.\n */\nexport type MessageRole = 'user' | 'assistant' | 'system'\n\nexport type MessageProps = Omit<ComponentProps<'article'>, 'role'> & {\n role: MessageRole\n label: string\n streaming?: boolean\n anchorId?: string\n}\n\nexport function Message(props: MessageProps) {\n const [local, rest] = splitProps(props, [\n 'class',\n 'role',\n 'label',\n 'streaming',\n 'anchorId',\n 'children',\n ])\n return (\n <article\n data-slot=\"message\"\n data-role={local.role}\n data-anchor-id={local.anchorId}\n aria-label={local.label}\n aria-busy={local.streaming || undefined}\n class={cn(\n 'group/message mx-auto flex w-full max-w-3xl min-w-0 flex-col gap-2 py-2',\n // The engine may skip layout for turns far off screen; the intrinsic size\n // keeps the scrollbar honest while it does.\n '[content-visibility:auto] [contain-intrinsic-size:auto_6rem]',\n {\n 'items-end ps-[clamp(0rem,12%,4rem)]': local.role === 'user',\n 'items-stretch': local.role !== 'user',\n },\n local.class\n )}\n {...rest}\n >\n {local.children}\n </article>\n )\n}\n\n/** The speaker's mark and name, for the turns that draw one. */\nexport function MessageHeader(\n props: ComponentProps<'header'> & { avatar?: JSX.Element; time?: JSX.Element }\n) {\n const [local, rest] = splitProps(props, ['class', 'avatar', 'time', 'children'])\n return (\n <header\n data-slot=\"message-header\"\n class={cn('flex items-center gap-2 text-xs text-muted-foreground', local.class)}\n {...rest}\n >\n <Show when={local.avatar}>{(avatarSlot) => <>{avatarSlot()}</>}</Show>\n <span class=\"font-medium text-foreground\">{local.children}</span>\n <Show when={local.time}>{(timeSlot) => <span class=\"tabular-nums\">{timeSlot()}</span>}</Show>\n </header>\n )\n}\n\n/** The turn's parts, stacked. Gap is the rhythm between prose, activity and code. */\nexport function MessageContent(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class', 'children'])\n return (\n <div\n data-slot=\"message-content\"\n class={cn(\n 'flex w-full max-w-3xl min-w-0 flex-col gap-3 font-content text-content',\n local.class\n )}\n {...rest}\n >\n {local.children}\n </div>\n )\n}\n\n/**\n * Actions that belong to the turn (copy, retry). Hidden until the turn is hovered\n * or focused so the column is not a wall of buttons, but never `display: none`:\n * a control that only exists under the pointer cannot be reached by keyboard,\n * and on a touch screen there is no hover, so coarse pointers always see them.\n */\nexport function MessageActions(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class', 'children'])\n return (\n <div\n data-slot=\"message-actions\"\n class={cn(\n 'flex items-center gap-1 opacity-0 transition-opacity ease-out group-focus-within/message:opacity-100 group-hover/message:opacity-100 [@media(hover:none)]:opacity-100',\n local.class\n )}\n {...rest}\n >\n {local.children}\n </div>\n )\n}\n\nexport function MessageFooter(props: ComponentProps<'footer'>) {\n const [local, rest] = splitProps(props, ['class', 'children'])\n return (\n <footer\n data-slot=\"message-footer\"\n class={cn('flex min-w-0 items-center gap-2 text-xs text-muted-foreground', local.class)}\n {...rest}\n >\n {local.children}\n </footer>\n )\n}\n\n/** The props of a fenced block the host may set. */\nexport type MessageCodeBlockProps = Pick<\n CodeBlockProps,\n 'loadHighlight' | 'maxHeight' | 'wrap' | 'showLineNumbers' | 'lineMarks' | 'lineLimit'\n>\n\n/** What the host is told about a fenced block when it chooses that block's props. */\nexport type MessageCodeBlockInfo = Readonly<{\n /** Position among the text's fenced blocks, from 0. */\n index: number\n language: string | undefined\n code: string\n complete: boolean\n}>\n\n/**\n * How `MessageText` draws citation markers. `count` is how many sources the host\n * has; a `[^n]` marker is a citation only when every `n` is within it. `render`\n * receives the 1-based source numbers and draws the marker, so the host decides\n * what a number means (`messageCitations` in the inline-citation composite does\n * this for a `Source` list).\n */\nexport type MessageCitations = Readonly<{\n count: number\n render: (numbers: readonly number[]) => JSX.Element\n}>\n\nexport type MessageTextProps = Omit<ComponentProps<'div'>, 'children'> & {\n text: string\n /** True while text may still arrive: a trailing open fence renders as partial code. */\n streaming?: boolean\n /**\n * Forwarded to each fenced block, e.g. to supply a lazy highlighter. A function\n * chooses per block, which is how line marks reach a block: marks belong to the\n * host's knowledge of the code (a diff, a failing line), never to the text.\n */\n codeBlockProps?: MessageCodeBlockProps | ((block: MessageCodeBlockInfo) => MessageCodeBlockProps)\n /** Without it, `[^1]` stays the literal text it was written as. */\n citations?: MessageCitations\n}\n\nfunction sameBlock(a: MessageBlock | undefined, b: MessageBlock): boolean {\n return (\n a !== undefined &&\n a.kind === b.kind &&\n a.raw === b.raw &&\n (a.kind !== 'code' || (b.kind === 'code' && a.complete === b.complete))\n )\n}\n\n/**\n * Text, read safely.\n *\n * Renders `parseMessageText`'s blocks as elements: nothing is interpreted as\n * HTML and a link only becomes an anchor when its scheme is http, https or\n * mailto. Blocks are kept by *position* and reuse their previous parsed object\n * when unchanged, so a streaming turn updates the block that is growing and\n * leaves every earlier paragraph and code block — and any selection or focus\n * inside them — untouched.\n */\nexport function MessageText(props: MessageTextProps) {\n const [local, rest] = splitProps(props, [\n 'class',\n 'text',\n 'streaming',\n 'codeBlockProps',\n 'citations',\n ])\n let previous: readonly MessageBlock[] = []\n let previousCount = 0\n let parsed: MessageParse | undefined\n // Only the number of sources reaches the parser, so a new `render` function\n // does not reparse the text, and a changed count does.\n const citationCount = () => local.citations?.count ?? 0\n const blocks = createMemo(() => {\n const count = citationCount()\n if (count !== previousCount) previous = []\n previousCount = count\n // A streamed reply only grows, so each delta parses the tail it touched\n // rather than the whole reply (which made a long reply quadratic).\n parsed = parseMessageTextIncremental(parsed, local.text, {\n streaming: local.streaming,\n citations: count || undefined,\n })\n const next = parsed.blocks\n const merged = next.map((block, index) =>\n sameBlock(previous[index], block) ? previous[index]! : block\n )\n previous = merged\n return merged\n })\n // The nth fenced block, so a host can address it. Blocks keep their positions\n // while text streams in after them, so an index stays attached to its block.\n const codeIndexes = createMemo(() => {\n let next = 0\n return blocks().map((block) => (block.kind === 'code' ? next++ : -1))\n })\n const lastIsProse = () => {\n const last = blocks().at(-1)\n return last !== undefined && last.kind !== 'code'\n }\n return (\n <div data-slot=\"message-text\" class={cn('flex min-w-0 flex-col gap-3', local.class)} {...rest}>\n <Index each={blocks()}>\n {(block, index) => (\n <BlockView\n block={block()}\n codeProps={local.codeBlockProps}\n codeIndex={() => codeIndexes()[index] ?? 0}\n citations={local.citations}\n />\n )}\n </Index>\n <Show when={local.streaming && lastIsProse()}>\n <span class=\"streaming-caret\" aria-hidden=\"true\" />\n </Show>\n </div>\n )\n}\n\nfunction BlockView(props: {\n block: MessageBlock\n codeProps?: MessageTextProps['codeBlockProps']\n codeIndex: () => number\n citations?: MessageCitations\n}) {\n return (\n <Switch>\n <Match when={props.block.kind === 'code' && props.block}>\n {(block) => {\n const code = () => block() as Extract<MessageBlock, { kind: 'code' }>\n const chosen = () => {\n const choice = props.codeProps\n return typeof choice === 'function'\n ? choice({\n index: props.codeIndex(),\n language: code().language,\n code: code().code,\n complete: code().complete,\n })\n : choice\n }\n return (\n <CodeBlock\n code={code().code}\n language={code().language}\n complete={code().complete}\n {...chosen()}\n />\n )\n }}\n </Match>\n <Match when={props.block.kind === 'heading' && props.block}>\n {(block) => {\n const heading = () => block() as Extract<MessageBlock, { kind: 'heading' }>\n return (\n <p\n role=\"heading\"\n aria-level={heading().level + 2}\n class=\"font-semibold text-foreground [overflow-wrap:anywhere]\"\n >\n <Inline nodes={heading().inline} citations={props.citations} />\n </p>\n )\n }}\n </Match>\n <Match when={props.block.kind === 'list' && props.block}>\n {(block) => {\n const list = () => block() as Extract<MessageBlock, { kind: 'list' }>\n return (\n <Show\n when={list().ordered}\n fallback={\n <ul class=\"m-0 ms-5 flex list-disc flex-col gap-1 p-0 marker:text-muted-foreground\">\n <For each={list().items}>\n {(item) => (\n <li class=\"[overflow-wrap:anywhere]\">\n <Inline nodes={item} citations={props.citations} />\n </li>\n )}\n </For>\n </ul>\n }\n >\n <ol\n start={list().start}\n class=\"m-0 ms-5 flex list-decimal flex-col gap-1 p-0 marker:text-muted-foreground\"\n >\n <For each={list().items}>\n {(item) => (\n <li class=\"[overflow-wrap:anywhere]\">\n <Inline nodes={item} citations={props.citations} />\n </li>\n )}\n </For>\n </ol>\n </Show>\n )\n }}\n </Match>\n <Match when={props.block.kind === 'quote' && props.block}>\n {(block) => {\n const quote = () => block() as Extract<MessageBlock, { kind: 'quote' }>\n return (\n <blockquote class=\"m-0 border-s-2 border-border ps-3 whitespace-pre-wrap text-muted-foreground [overflow-wrap:anywhere]\">\n <Inline nodes={quote().inline} citations={props.citations} />\n </blockquote>\n )\n }}\n </Match>\n <Match when={props.block.kind === 'paragraph' && props.block}>\n {(block) => {\n const paragraph = () => block() as Extract<MessageBlock, { kind: 'paragraph' }>\n return (\n <p class=\"m-0 whitespace-pre-wrap [overflow-wrap:anywhere]\">\n <Inline nodes={paragraph().inline} citations={props.citations} />\n </p>\n )\n }}\n </Match>\n </Switch>\n )\n}\n\nfunction Inline(props: { nodes: readonly MessageInline[]; citations?: MessageCitations }) {\n // By position, not identity: the parser returns fresh nodes for the growing\n // paragraph on every streamed token, and a keyed list would rebuild each one.\n return (\n <Index each={props.nodes}>\n {(node) => (\n <Switch>\n {/* Fragments keep the reads reactive: Match runs its callback untracked. */}\n <Match when={node().kind === 'text' && node()}>\n {(text) => <>{(text() as { text: string }).text}</>}\n </Match>\n <Match when={node().kind === 'code' && node()}>\n {(code) => <InlineCode>{(code() as { text: string }).text}</InlineCode>}\n </Match>\n <Match when={node().kind === 'strong' && node()}>\n {(strong) => (\n <strong class=\"font-semibold\">\n <Inline\n nodes={(strong() as { children: readonly MessageInline[] }).children}\n citations={props.citations}\n />\n </strong>\n )}\n </Match>\n <Match when={node().kind === 'em' && node()}>\n {(em) => (\n <em>\n <Inline\n nodes={(em() as { children: readonly MessageInline[] }).children}\n citations={props.citations}\n />\n </em>\n )}\n </Match>\n <Match when={node().kind === 'link' && node()}>\n {(link) => (\n <a\n href={(link() as { href: string }).href}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n class=\"text-primary underline underline-offset-2 hover:no-underline\"\n >\n <Inline nodes={(link() as { children: readonly MessageInline[] }).children} />\n </a>\n )}\n </Match>\n <Match when={node().kind === 'cite' && node()}>\n {(cite) => {\n const marker = () => cite() as { numbers: readonly number[]; raw: string }\n // The parser read this as a citation only while the host had sources;\n // if they have gone since, the marker is the text it was written as.\n // Match invokes this callback untracked; JSX keeps renderer and\n // same-count source replacements reactive without replacing the block.\n return (\n <>{props.citations ? props.citations.render(marker().numbers) : marker().raw}</>\n )\n }}\n </Match>\n </Switch>\n )}\n </Index>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoDA,SAAgBe,QAAQC,OAAqB;CAC3C,MAAM,CAACC,OAAOC,QAAQb,WAAWW,OAAO;EACtC;EACA;EACA;EACA;EACA;EACA;CAAU,CACX;CACD,cAAA;EAAA,IAAAG,OAAAC,OAAA;EAAAC,OAAAF,MAAAG,WAAA;GAAA,KAAA,eAAA;IAAA,OAGeL,MAAMN;GAAI;GAAA,KAAA,oBAAA;IAAA,OACLM,MAAMH;GAAQ;GAAA,KAAA,gBAAA;IAAA,OAClBG,MAAML;GAAK;GAAA,KAAA,eAAA;IAAA,OACZK,MAAMJ,aAAaU,KAAAA;GAAS;GAAA,KAAA,WAAA;IAAA,OAChChB,GACL,2EAGA,gEACA;KACE,uCAAuCU,MAAMN,SAAS;KACtD,iBAAiBM,MAAMN,SAAS;IAClC,GACAM,MAAMO,KACR;GAAC;EAAA,GACGN,IAAI,GAAA,OAAA,IAAA;EAAAO,OAAAN,YAEPF,MAAMS,QAAQ;EAAA,OAAAP;CAAA,EAAA,CAAA;AAGrB;;AAGA,SAAgBQ,cACdX,OACA;CACA,MAAM,CAACC,OAAOC,QAAQb,WAAWW,OAAO;EAAC;EAAS;EAAU;EAAQ;CAAU,CAAC;CAC/E,cAAA;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,KAAK,CAAC,CAAsBG,IAAI,CAAA;MAAA,OAAAF;KAAA,EAAA,CAAA;IAO1C,CAAA;IAAA1F,gBAEF/B,OAAK;KAAA,IAACgC,OAAI;MAAA,OAAEE,WAAA+E,KAAK,CAAC,CAACpD,SAAS,MAAM,CAAA,CAAA,KAAIoD,KAAK;KAAC;KAAA1F,WACzCqG,SAAS;MACT,MAAMC,eAAeD,KAAK;MAK1B,OAAA1F,WACKA,WAAA,CAAA,CAAArB,MAAM4C,SAAS,CAAA,CAAA,IAAG5C,MAAM4C,UAAUL,OAAOyE,OAAO,CAAC,CAACxE,OAAO,IAAIwE,OAAO,CAAC,CAAC/D,GAAG;KAEhF;IAAC,CAAA;GAAA;EAAA,EAAA,CAAA;CAGN,CAAA;AAGP"}
|
|
@@ -108,4 +108,36 @@ export declare function parseMessageText(text: string, options?: {
|
|
|
108
108
|
streaming?: boolean;
|
|
109
109
|
citations?: number;
|
|
110
110
|
}): readonly MessageBlock[];
|
|
111
|
+
export type MessageParseOptions = {
|
|
112
|
+
streaming?: boolean;
|
|
113
|
+
citations?: number;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* A parse that the next, longer text can continue from. See
|
|
117
|
+
* {@link parseMessageTextIncremental}.
|
|
118
|
+
*/
|
|
119
|
+
export type MessageParse = Readonly<{
|
|
120
|
+
/** The normalised text that was parsed. */
|
|
121
|
+
text: string;
|
|
122
|
+
streaming: boolean;
|
|
123
|
+
citations: number;
|
|
124
|
+
blocks: readonly MessageBlock[];
|
|
125
|
+
/** The offset in `text` where each block's first line starts. */
|
|
126
|
+
starts: readonly number[];
|
|
127
|
+
}>;
|
|
128
|
+
/**
|
|
129
|
+
* `parseMessageText`, resumed.
|
|
130
|
+
*
|
|
131
|
+
* A streaming reply grows by appending, and reparsing the whole text per token
|
|
132
|
+
* makes a long reply quadratic. When `text` extends `previous.text` under the same
|
|
133
|
+
* options, only its final line can still change, since it may be unfinished. A block
|
|
134
|
+
* that ends before that line is terminated by a finished line (a blank line, a
|
|
135
|
+
* closing fence, or the line that starts the next block), so appending cannot
|
|
136
|
+
* change it. Only the tail from the last block that starts before the final line
|
|
137
|
+
* is parsed again, and the earlier blocks are returned as the same objects. The
|
|
138
|
+
* parser keeps no state across a block boundary, so the tail parsed alone gives
|
|
139
|
+
* exactly the blocks a full parse gives there. Anything else (an edit, a
|
|
140
|
+
* different option) is a full parse.
|
|
141
|
+
*/
|
|
142
|
+
export declare function parseMessageTextIncremental(previous: MessageParse | undefined, text: string, options?: MessageParseOptions): MessageParse;
|
|
111
143
|
//# sourceMappingURL=parse-message-text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-message-text.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/message/parse-message-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,OAAO,EAAE,QAAQ,EAAE,CAAA;AAEnB,MAAM,MAAM,aAAa,GACrB,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GACxC,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GACxC,QAAQ,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAA;CAAE,CAAC,GAChE,QAAQ,CAAC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAA;CAAE,CAAC,GAC5D,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAA;CAAE,CAAC;AAC9E,mFAAmF;GACjF,QAAQ,CAAC;IAAE,IAAI,E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C,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,SAAS,YAAY,EAAE,CAAA;IAC/B,iEAAiE;IACjE,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CAC1B,CAAC,CAAA;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,mBAAwB,GAChC,YAAY,CAmCd"}
|
|
@@ -313,10 +313,61 @@ function bracketMatches(text) {
|
|
|
313
313
|
}
|
|
314
314
|
/** Parse text into blocks. Pure, total, and linear in the length of `text`. */
|
|
315
315
|
function parseMessageText(text, options = {}) {
|
|
316
|
+
return parseLines(text.replace(/\r\n?/g, "\n"), options).blocks;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* `parseMessageText`, resumed.
|
|
320
|
+
*
|
|
321
|
+
* A streaming reply grows by appending, and reparsing the whole text per token
|
|
322
|
+
* makes a long reply quadratic. When `text` extends `previous.text` under the same
|
|
323
|
+
* options, only its final line can still change, since it may be unfinished. A block
|
|
324
|
+
* that ends before that line is terminated by a finished line (a blank line, a
|
|
325
|
+
* closing fence, or the line that starts the next block), so appending cannot
|
|
326
|
+
* change it. Only the tail from the last block that starts before the final line
|
|
327
|
+
* is parsed again, and the earlier blocks are returned as the same objects. The
|
|
328
|
+
* parser keeps no state across a block boundary, so the tail parsed alone gives
|
|
329
|
+
* exactly the blocks a full parse gives there. Anything else (an edit, a
|
|
330
|
+
* different option) is a full parse.
|
|
331
|
+
*/
|
|
332
|
+
function parseMessageTextIncremental(previous, text, options = {}) {
|
|
333
|
+
const normalized = text.replace(/\r\n?/g, "\n");
|
|
334
|
+
const streaming = options.streaming ?? false;
|
|
335
|
+
const citations = options.citations ?? 0;
|
|
336
|
+
if (previous && previous.streaming === streaming && previous.citations === citations && previous.blocks.length > 0 && normalized.length >= previous.text.length && normalized.startsWith(previous.text)) {
|
|
337
|
+
const lastLine = previous.text.lastIndexOf("\n") + 1;
|
|
338
|
+
let keep = previous.starts.length - 1;
|
|
339
|
+
while (keep >= 0 && previous.starts[keep] >= lastLine) keep -= 1;
|
|
340
|
+
if (keep > 0) {
|
|
341
|
+
const resumeAt = previous.starts[keep];
|
|
342
|
+
const tail = parseLines(normalized.slice(resumeAt), options);
|
|
343
|
+
return {
|
|
344
|
+
text: normalized,
|
|
345
|
+
streaming,
|
|
346
|
+
citations,
|
|
347
|
+
blocks: [...previous.blocks.slice(0, keep), ...tail.blocks],
|
|
348
|
+
starts: [...previous.starts.slice(0, keep), ...tail.starts.map((start) => start + resumeAt)]
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return {
|
|
353
|
+
text: normalized,
|
|
354
|
+
streaming,
|
|
355
|
+
citations,
|
|
356
|
+
...parseLines(normalized, options)
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
function parseLines(text, options) {
|
|
316
360
|
const inline = (source) => parseInline(source, 0, { citations: options.citations });
|
|
317
|
-
const lines = text.
|
|
361
|
+
const lines = text.split("\n");
|
|
362
|
+
const lineStarts = [];
|
|
363
|
+
for (let line = 0, offset = 0; line < lines.length; line++) {
|
|
364
|
+
lineStarts.push(offset);
|
|
365
|
+
offset += lines[line].length + 1;
|
|
366
|
+
}
|
|
318
367
|
const blocks = [];
|
|
368
|
+
const starts = [];
|
|
319
369
|
let paragraph = [];
|
|
370
|
+
let paragraphStart = 0;
|
|
320
371
|
const flushParagraph = () => {
|
|
321
372
|
if (paragraph.length === 0) return;
|
|
322
373
|
const raw = paragraph.join("\n");
|
|
@@ -325,6 +376,7 @@ function parseMessageText(text, options = {}) {
|
|
|
325
376
|
inline: inline(raw),
|
|
326
377
|
raw
|
|
327
378
|
});
|
|
379
|
+
starts.push(lineStarts[paragraphStart]);
|
|
328
380
|
paragraph = [];
|
|
329
381
|
};
|
|
330
382
|
let index = 0;
|
|
@@ -336,6 +388,7 @@ function parseMessageText(text, options = {}) {
|
|
|
336
388
|
const marker = fence.marker;
|
|
337
389
|
const language = fence.language || void 0;
|
|
338
390
|
const { code, closed, next } = readFence(lines, index + 1, fence);
|
|
391
|
+
starts.push(lineStarts[index]);
|
|
339
392
|
index = next;
|
|
340
393
|
blocks.push({
|
|
341
394
|
kind: "code",
|
|
@@ -354,6 +407,7 @@ function parseMessageText(text, options = {}) {
|
|
|
354
407
|
const heading = headingOf(line);
|
|
355
408
|
if (heading) {
|
|
356
409
|
flushParagraph();
|
|
410
|
+
starts.push(lineStarts[index]);
|
|
357
411
|
blocks.push({
|
|
358
412
|
kind: "heading",
|
|
359
413
|
level: heading.level,
|
|
@@ -367,6 +421,7 @@ function parseMessageText(text, options = {}) {
|
|
|
367
421
|
const ordered = bullet ? null : ORDERED.exec(line);
|
|
368
422
|
if (bullet || ordered) {
|
|
369
423
|
flushParagraph();
|
|
424
|
+
starts.push(lineStarts[index]);
|
|
370
425
|
const items = [];
|
|
371
426
|
const rawLines = [];
|
|
372
427
|
const isOrdered = ordered !== null;
|
|
@@ -404,6 +459,7 @@ function parseMessageText(text, options = {}) {
|
|
|
404
459
|
}
|
|
405
460
|
if (QUOTE.exec(line)) {
|
|
406
461
|
flushParagraph();
|
|
462
|
+
starts.push(lineStarts[index]);
|
|
407
463
|
const quoted = [];
|
|
408
464
|
while (index < lines.length) {
|
|
409
465
|
const match = QUOTE.exec(lines[index]);
|
|
@@ -419,12 +475,16 @@ function parseMessageText(text, options = {}) {
|
|
|
419
475
|
});
|
|
420
476
|
continue;
|
|
421
477
|
}
|
|
478
|
+
if (paragraph.length === 0) paragraphStart = index;
|
|
422
479
|
paragraph.push(line);
|
|
423
480
|
index += 1;
|
|
424
481
|
}
|
|
425
482
|
flushParagraph();
|
|
426
|
-
return
|
|
483
|
+
return {
|
|
484
|
+
blocks,
|
|
485
|
+
starts
|
|
486
|
+
};
|
|
427
487
|
}
|
|
428
|
-
export { parseInline, parseMessageText, safeHref, splitCodeFences };
|
|
488
|
+
export { parseInline, parseMessageText, parseMessageTextIncremental, safeHref, splitCodeFences };
|
|
429
489
|
|
|
430
490
|
//# sourceMappingURL=parse-message-text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-message-text.js","names":[],"sources":["../../../../src/components/ui/message/parse-message-text.ts"],"sourcesContent":["/**\n * A small, safe reading of model and user text.\n *\n * Assistant output is untrusted: it can contain anything a model, a tool result\n * or a pasted web page put there. This parser therefore produces *data* —\n * blocks and inline spans — and the renderer turns that data into text nodes and\n * a fixed set of elements. There is no HTML pass, no `innerHTML`, and no\n * attribute built from the text other than a link `href` that has passed\n * `safeHref`.\n *\n * It reads a deliberately small subset of Markdown: fenced code, headings,\n * flat lists, block quotes, paragraphs, and inline code, bold, italic and links.\n * Anything it does not recognise stays as paragraph text with its line breaks\n * (the paragraph renders `white-space: pre-wrap`), so unsupported syntax\n * degrades to readable source instead of vanishing.\n *\n * A citation marker, `[^1]` or `[^1,2]`, is read only when the caller says how\n * many sources it has (`citations`) and every number names one of them. A marker\n * the host cannot resolve stays literal text: it is never a citation by shape\n * alone, and `arr[1]` or a footnote the model invented is not one either.\n *\n * Streaming is a first-class input. `streaming: true` means the text may end\n * mid-construct, so an unterminated fence is a *partial* code block — shown as\n * code from its first line, flagged incomplete — and an unterminated inline\n * span stays literal until its closing delimiter arrives. Once streaming stops,\n * an unterminated fence is just a code block that ends at the end of the text.\n */\n\nimport { safeHref } from '#lib/url'\n\nexport { safeHref }\n\nexport type MessageInline =\n | Readonly<{ kind: 'text'; text: string }>\n | Readonly<{ kind: 'code'; text: string }>\n | Readonly<{ kind: 'strong'; children: readonly MessageInline[] }>\n | Readonly<{ kind: 'em'; children: readonly MessageInline[] }>\n | Readonly<{ kind: 'link'; href: string; children: readonly MessageInline[] }>\n /** A resolved citation marker: 1-based source numbers, each within `citations`. */\n | Readonly<{ kind: 'cite'; numbers: readonly number[]; raw: string }>\n\nexport type MessageBlock =\n | Readonly<{ kind: 'paragraph'; inline: readonly MessageInline[]; raw: string }>\n | Readonly<{\n kind: 'heading'\n level: 1 | 2 | 3 | 4\n inline: readonly MessageInline[]\n raw: string\n }>\n | Readonly<{\n kind: 'list'\n ordered: boolean\n start: number\n items: readonly (readonly MessageInline[])[]\n raw: string\n }>\n | Readonly<{ kind: 'quote'; inline: readonly MessageInline[]; raw: string }>\n | Readonly<{\n kind: 'code'\n language: string | undefined\n code: string\n /** False while the fence is still open and the text may still grow. */\n complete: boolean\n raw: string\n }>\n\nconst WHITESPACE = /\\s/\n\n/**\n * An opening fence: up to three spaces, a run of three or more backticks or of\n * three or more tildes, then an info string that holds no backtick. The first\n * word of the info string is the language. This is a scan, not one pattern,\n * because a pattern whose classes overlap (`[^\\s`]*` then `[^`]*`) retries every\n * split of a long info string when a stray backtick ends it: three backticks, a\n * long run of `a` and a trailing backtick took quadratic time.\n */\nfunction fenceOpen(line: string): Readonly<{ marker: string; language: string }> | undefined {\n let start = 0\n while (start < 3 && line.charCodeAt(start) === 32) start += 1\n const mark = line[start]\n if (mark !== '`' && mark !== '~') return undefined\n let end = start + 1\n while (line[end] === mark) end += 1\n if (end - start < 3) return undefined\n if (line.includes('`', end)) return undefined\n let wordStart = end\n while (line[wordStart] === ' ' || line[wordStart] === '\\t') wordStart += 1\n let wordEnd = wordStart\n while (wordEnd < line.length && !WHITESPACE.test(line[wordEnd]!)) wordEnd += 1\n return { marker: line.slice(start, end), language: line.slice(wordStart, wordEnd) }\n}\ntype FenceOpen = NonNullable<ReturnType<typeof fenceOpen>>\n\n/**\n * The body of a fence that opened on `lines[start - 1]`: every line up to a\n * closing run of the same mark at least as long as the opening one, or to the end\n * of the text when none comes.\n */\nfunction readFence(\n lines: readonly string[],\n start: number,\n fence: FenceOpen\n): Readonly<{ code: string; closed: boolean; next: number }> {\n const body: string[] = []\n let index = start\n while (index < lines.length) {\n const candidate = lines[index]!\n const close = /^ {0,3}(`{3,}|~{3,})[ \\t]*$/.exec(candidate)\n if (close && close[1]![0] === fence.marker[0] && close[1]!.length >= fence.marker.length)\n return { code: body.join('\\n'), closed: true, next: index + 1 }\n body.push(candidate)\n index += 1\n }\n return { code: body.join('\\n'), closed: false, next: index }\n}\n\nexport type FenceSegment =\n | Readonly<{ kind: 'prose'; text: string }>\n | Readonly<{\n kind: 'code'\n language: string | undefined\n code: string\n /** False while the fence is still open and the text may still grow. */\n complete: boolean\n }>\n\n/**\n * Text split into fenced code and the prose between, by the same fence grammar\n * `parseMessageText` reads. For a renderer that draws code blocks but leaves the\n * prose as written (`MessageBody`).\n */\nexport function splitCodeFences(\n text: string,\n options: { streaming?: boolean } = {}\n): readonly FenceSegment[] {\n const lines = text.replace(/\\r\\n?/g, '\\n').split('\\n')\n const segments: FenceSegment[] = []\n let prose: string[] = []\n const flushProse = () => {\n if (prose.length > 0) segments.push({ kind: 'prose', text: prose.join('\\n') })\n prose = []\n }\n let index = 0\n while (index < lines.length) {\n const line = lines[index]!\n const fence = fenceOpen(line)\n if (!fence) {\n prose.push(line)\n index += 1\n continue\n }\n flushProse()\n const block = readFence(lines, index + 1, fence)\n segments.push({\n kind: 'code',\n language: fence.language || undefined,\n code: block.code,\n complete: block.closed || !options.streaming,\n })\n index = block.next\n }\n flushProse()\n return segments\n}\n\n// The lookahead after each marker's spaces makes that run maximal, so a line\n// that fails later (`.` stops at U+2028) cannot retry every shorter run.\nconst BULLET = /^ {0,3}[-*+][ \\t]+(?![ \\t])(.*)$/\nconst ORDERED = /^ {0,3}(\\d{1,9})[.)][ \\t]+(?![ \\t])(.*)$/\nconst QUOTE = /^ {0,3}>[ \\t]?(.*)$/\n\nconst isBlank = (char: string | undefined) => char === ' ' || char === '\\t'\nconst LINE_TERMINATOR = /[\\n\\r\\u2028\\u2029]/\n\n/**\n * An ATX heading: up to three spaces, one to four `#`, spaces or tabs, then the\n * text, with any trailing spaces and closing `#` run removed. This is a scan for\n * the reason `fenceOpen` is: the equivalent pattern (`(.+?)[ \\t]*#*[ \\t]*$`)\n * retries the closing check from every position of a long run of spaces.\n */\nfunction headingOf(line: string): Readonly<{ level: 1 | 2 | 3 | 4; text: string }> | undefined {\n let start = 0\n while (start < 3 && line.charCodeAt(start) === 32) start += 1\n let marks = start\n while (line[marks] === '#') marks += 1\n const level = marks - start\n if (level < 1 || level > 4 || !isBlank(line[marks])) return undefined\n let textStart = marks\n while (isBlank(line[textStart])) textStart += 1\n if (textStart === line.length) {\n // Only blanks follow the marker: the text is the last of them, which needs a second one.\n return textStart - marks >= 2\n ? { level: level as 1 | 2 | 3 | 4, text: line[line.length - 1]! }\n : undefined\n }\n if (LINE_TERMINATOR.test(line.slice(textStart))) return undefined\n // Drop the longest tail of blanks, a run of `#`, and blanks again.\n let textEnd = line.length\n while (textEnd > textStart && isBlank(line[textEnd - 1])) textEnd -= 1\n while (textEnd > textStart && line[textEnd - 1] === '#') textEnd -= 1\n while (textEnd > textStart && isBlank(line[textEnd - 1])) textEnd -= 1\n // Text that is nothing but a closing run keeps its first character.\n return {\n level: level as 1 | 2 | 3 | 4,\n text: line.slice(textStart, Math.max(textEnd, textStart + 1)),\n }\n}\n\nconst MAX_INLINE_DEPTH = 4\n\n/** A marker may cite at most this many sources, so one cannot flood a sentence. */\nconst MAX_CITED_SOURCES = 6\nconst CITATION = /\\[\\^(\\d{1,4}(?:[ \\t]*,[ \\t]*\\d{1,4}){0,5})\\]/y\n\nexport type ParseInlineOptions = {\n /** How many sources the host has. Without it no marker is a citation. */\n citations?: number\n /** Inside a link label, where a citation (itself a button) must not nest. */\n inLink?: boolean\n}\n\nfunction citationAt(text: string, index: number, count: number): MessageInline | undefined {\n CITATION.lastIndex = index\n const match = CITATION.exec(text)\n if (!match) return undefined\n const numbers = [...new Set(match[1]!.split(',').map((part) => Number(part.trim())))]\n if (numbers.length > MAX_CITED_SOURCES) return undefined\n if (numbers.some((number) => number < 1 || number > count)) return undefined\n return { kind: 'cite', numbers, raw: match[0] }\n}\n\n/** Inline spans. Delimiters must close on the same block, or they stay literal. */\nexport function parseInline(\n text: string,\n depth = 0,\n options: ParseInlineOptions = {}\n): readonly MessageInline[] {\n const out: MessageInline[] = []\n let brackets: ReadonlyMap<number, number> | undefined\n let paren = -2\n let buffer = ''\n const flush = () => {\n if (buffer) out.push({ kind: 'text', text: buffer })\n buffer = ''\n }\n let index = 0\n while (index < text.length) {\n const char = text[index]!\n if (char === '`') {\n let ticks = 1\n while (text[index + ticks] === '`') ticks += 1\n const fence = '`'.repeat(ticks)\n const close = text.indexOf(fence, index + ticks)\n if (close > index + ticks) {\n flush()\n out.push({ kind: 'code', text: text.slice(index + ticks, close).replace(/^ (.*) $/, '$1') })\n index = close + ticks\n continue\n }\n buffer += fence\n index += ticks\n continue\n }\n if (depth < MAX_INLINE_DEPTH && (char === '*' || char === '_')) {\n const double = text[index + 1] === char\n const delimiter = double ? char + char : char\n const start = index + delimiter.length\n // Word-internal underscores cannot open emphasis. Reject before scanning,\n // and consume both marks so the second cannot rescan the remaining pairs.\n if (char === '_' && index > 0 && /[A-Za-z0-9]/.test(text[index - 1] ?? '')) {\n buffer += delimiter\n index = start\n continue\n }\n const next = text[start]\n // A delimiter opens only before a non-space, so `a * b * c` and `2 * 3` stay arithmetic.\n if (next !== undefined && !/\\s/.test(next)) {\n const close = findClosing(text, delimiter, start)\n if (double && !(close > start && !/\\s/.test(text[close - 1] ?? ' '))) {\n // An opener that does not close stays literal as a pair. Retrying its\n // second mark as emphasis would scan to the end of the line again, so a\n // line of unclosed `**a ` would be quadratic.\n buffer += delimiter\n index = start\n continue\n }\n if (close > start && !/\\s/.test(text[close - 1] ?? ' ')) {\n flush()\n out.push({\n kind: double ? 'strong' : 'em',\n children: parseInline(text.slice(start, close), depth + 1, options),\n })\n index = close + delimiter.length\n continue\n }\n }\n }\n if (char === '[' && text[index + 1] === '^' && options.citations && !options.inLink) {\n const cite = citationAt(text, index, options.citations)\n if (cite && cite.kind === 'cite') {\n flush()\n out.push(cite)\n index += cite.raw.length\n continue\n }\n }\n if (depth < MAX_INLINE_DEPTH && char === '[') {\n brackets ??= bracketMatches(text)\n const labelEnd = brackets.get(index) ?? -1\n if (labelEnd > index && text[labelEnd + 1] === '(') {\n // The nearest `)` is remembered: a run of `[a](` with no `)` after it\n // would otherwise search to the end of the text from every opener.\n if (paren !== -1 && paren < labelEnd + 2) paren = text.indexOf(')', labelEnd + 2)\n const hrefEnd = paren\n if (hrefEnd > labelEnd + 1) {\n const href = safeHref(text.slice(labelEnd + 2, hrefEnd))\n if (href) {\n flush()\n out.push({\n kind: 'link',\n href,\n children: parseInline(text.slice(index + 1, labelEnd), depth + 1, {\n ...options,\n inLink: true,\n }),\n })\n index = hrefEnd + 1\n continue\n }\n }\n }\n }\n buffer += char\n index += 1\n }\n flush()\n return out\n}\n\nfunction findClosing(text: string, delimiter: string, from: number): number {\n let index = from\n while (index < text.length) {\n if (text[index] === '`') {\n // Skip a code span so `**a `**` b**` closes where the code ends.\n const close = text.indexOf('`', index + 1)\n if (close < 0) return -1\n index = close + 1\n continue\n }\n if (text[index] === delimiter[0]) {\n let end = index + 1\n while (text[end] === delimiter[0]) end += 1\n const run = end - index\n if (delimiter.length === 1) {\n // Emphasis closes on a run of one (or an odd run, whose last mark closes).\n // An even run is `**` pairs: strong spans inside the emphasis, which the\n // inner parse reads. One pass, and the scan stops at the next odd run, so\n // a line of unclosed delimiters is still linear.\n if (run % 2 === 1) return end - 1\n } else if (run >= delimiter.length) {\n // Strong closes on the last two marks of a run.\n return end - delimiter.length\n }\n index = end\n continue\n }\n index += 1\n }\n return -1\n}\n\n/**\n * The `]` that closes each `[`, found in one pass. A match never crosses a\n * newline, and an unmatched `[` has no entry. Scanning forward from every `[`\n * instead is quadratic on a long line of unclosed brackets, which a pasted page\n * or a hostile model can use to hang the renderer.\n */\nfunction bracketMatches(text: string): ReadonlyMap<number, number> {\n const matches = new Map<number, number>()\n const open: number[] = []\n for (let index = 0; index < text.length; index += 1) {\n const char = text[index]\n if (char === '[') open.push(index)\n else if (char === ']') {\n const start = open.pop()\n if (start !== undefined) matches.set(start, index)\n } else if (char === '\\n') open.length = 0\n }\n return matches\n}\n\n/** Parse text into blocks. Pure, total, and linear in the length of `text`. */\nexport function parseMessageText(\n text: string,\n options: { streaming?: boolean; citations?: number } = {}\n): readonly MessageBlock[] {\n const inline = (source: string) => parseInline(source, 0, { citations: options.citations })\n const lines = text.replace(/\\r\\n?/g, '\\n').split('\\n')\n const blocks: MessageBlock[] = []\n let paragraph: string[] = []\n const flushParagraph = () => {\n if (paragraph.length === 0) return\n const raw = paragraph.join('\\n')\n blocks.push({ kind: 'paragraph', inline: inline(raw), raw })\n paragraph = []\n }\n\n let index = 0\n while (index < lines.length) {\n const line = lines[index]!\n const fence = fenceOpen(line)\n if (fence) {\n flushParagraph()\n const marker = fence.marker\n const language = fence.language || undefined\n const { code, closed, next } = readFence(lines, index + 1, fence)\n index = next\n blocks.push({\n kind: 'code',\n language,\n code,\n complete: closed || !options.streaming,\n raw: `${marker}${language ?? ''}\\n${code}${closed ? `\\n${marker}` : ''}`,\n })\n continue\n }\n if (line.trim() === '') {\n flushParagraph()\n index += 1\n continue\n }\n const heading = headingOf(line)\n if (heading) {\n flushParagraph()\n blocks.push({\n kind: 'heading',\n level: heading.level,\n inline: inline(heading.text),\n raw: line,\n })\n index += 1\n continue\n }\n const bullet = BULLET.exec(line)\n const ordered = bullet ? null : ORDERED.exec(line)\n if (bullet || ordered) {\n flushParagraph()\n const items: MessageInline[][] = []\n const rawLines: string[] = []\n const isOrdered = ordered !== null\n const start = ordered ? Number(ordered[1]) : 1\n while (index < lines.length) {\n const current = lines[index]!\n const match = isOrdered ? ORDERED.exec(current) : BULLET.exec(current)\n if (match) {\n items.push([...inline(isOrdered ? match[2]! : match[1]!)])\n rawLines.push(current)\n index += 1\n continue\n }\n // An indented continuation belongs to the previous item.\n if (/^ {2,}\\S/.test(current) && items.length > 0) {\n // Append in place: copying the accumulated spans on every continuation\n // makes a long item quadratic in its number of lines. Push one span at\n // a time, because spreading a line of many spans into `push` exceeds\n // the engine's argument limit and throws.\n const item = items[items.length - 1]!\n item.push({ kind: 'text', text: ' ' })\n for (const span of inline(current.trim())) item.push(span)\n rawLines.push(current)\n index += 1\n continue\n }\n break\n }\n blocks.push({ kind: 'list', ordered: isOrdered, start, items, raw: rawLines.join('\\n') })\n continue\n }\n const quote = QUOTE.exec(line)\n if (quote) {\n flushParagraph()\n const quoted: string[] = []\n while (index < lines.length) {\n const match = QUOTE.exec(lines[index]!)\n if (!match) break\n quoted.push(match[1]!)\n index += 1\n }\n const raw = quoted.join('\\n')\n blocks.push({ kind: 'quote', inline: inline(raw), raw })\n continue\n }\n paragraph.push(line)\n index += 1\n }\n flushParagraph()\n return blocks\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,IAAM,aAAa;;;;;;;;;AAUnB,SAAS,UAAU,MAA0E;CAC3F,IAAI,QAAQ;CACZ,OAAO,QAAQ,KAAK,KAAK,WAAW,KAAK,MAAM,IAAI,SAAS;CAC5D,MAAM,OAAO,KAAK;CAClB,IAAI,SAAS,OAAO,SAAS,KAAK,OAAO,KAAA;CACzC,IAAI,MAAM,QAAQ;CAClB,OAAO,KAAK,SAAS,MAAM,OAAO;CAClC,IAAI,MAAM,QAAQ,GAAG,OAAO,KAAA;CAC5B,IAAI,KAAK,SAAS,KAAK,GAAG,GAAG,OAAO,KAAA;CACpC,IAAI,YAAY;CAChB,OAAO,KAAK,eAAe,OAAO,KAAK,eAAe,KAAM,aAAa;CACzE,IAAI,UAAU;CACd,OAAO,UAAU,KAAK,UAAU,CAAC,WAAW,KAAK,KAAK,QAAS,GAAG,WAAW;CAC7E,OAAO;EAAE,QAAQ,KAAK,MAAM,OAAO,GAAG;EAAG,UAAU,KAAK,MAAM,WAAW,OAAO;CAAE;AACpF;;;;;;AAQA,SAAS,UACP,OACA,OACA,OAC2D;CAC3D,MAAM,OAAiB,CAAC;CAC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AAM,KAAK,CAAC,GAAG,OAAO,YAAY,MAAM,KAAM,MAAM,EAAG,CAAC,CAAC;KACzD,SAAS,KAAK,OAAO;KACrB,SAAS;KACT;IACF;IAEA,IAAI,WAAW,KAAK,OAAO,KAAK,MAAM,SAAS,GAAG;KAKhD,MAAM,OAAO,MAAM,MAAM,SAAS;KAClC,KAAK,KAAK;MAAE,MAAM;MAAQ,MAAM;KAAI,CAAC;KACrC,KAAK,MAAM,QAAQ,OAAO,QAAQ,KAAK,CAAC,GAAG,KAAK,KAAK,IAAI;KACzD,SAAS,KAAK,OAAO;KACrB,SAAS;KACT;IACF;IACA;GACF;GACA,OAAO,KAAK;IAAE,MAAM;IAAQ,SAAS;IAAW;IAAO;IAAO,KAAK,SAAS,KAAK,IAAI;GAAE,CAAC;GACxF;EACF;EAEA,IADc,MAAM,KAAK,IACrB,GAAO;GACT,eAAe;GACf,MAAM,SAAmB,CAAC;GAC1B,OAAO,QAAQ,MAAM,QAAQ;IAC3B,MAAM,QAAQ,MAAM,KAAK,MAAM,MAAO;IACtC,IAAI,CAAC,OAAO;IACZ,OAAO,KAAK,MAAM,EAAG;IACrB,SAAS;GACX;GACA,MAAM,MAAM,OAAO,KAAK,IAAI;GAC5B,OAAO,KAAK;IAAE,MAAM;IAAS,QAAQ,OAAO,GAAG;IAAG;GAAI,CAAC;GACvD;EACF;EACA,UAAU,KAAK,IAAI;EACnB,SAAS;CACX;CACA,eAAe;CACf,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"parse-message-text.js","names":[],"sources":["../../../../src/components/ui/message/parse-message-text.ts"],"sourcesContent":["/**\n * A small, safe reading of model and user text.\n *\n * Assistant output is untrusted: it can contain anything a model, a tool result\n * or a pasted web page put there. This parser therefore produces *data* —\n * blocks and inline spans — and the renderer turns that data into text nodes and\n * a fixed set of elements. There is no HTML pass, no `innerHTML`, and no\n * attribute built from the text other than a link `href` that has passed\n * `safeHref`.\n *\n * It reads a deliberately small subset of Markdown: fenced code, headings,\n * flat lists, block quotes, paragraphs, and inline code, bold, italic and links.\n * Anything it does not recognise stays as paragraph text with its line breaks\n * (the paragraph renders `white-space: pre-wrap`), so unsupported syntax\n * degrades to readable source instead of vanishing.\n *\n * A citation marker, `[^1]` or `[^1,2]`, is read only when the caller says how\n * many sources it has (`citations`) and every number names one of them. A marker\n * the host cannot resolve stays literal text: it is never a citation by shape\n * alone, and `arr[1]` or a footnote the model invented is not one either.\n *\n * Streaming is a first-class input. `streaming: true` means the text may end\n * mid-construct, so an unterminated fence is a *partial* code block — shown as\n * code from its first line, flagged incomplete — and an unterminated inline\n * span stays literal until its closing delimiter arrives. Once streaming stops,\n * an unterminated fence is just a code block that ends at the end of the text.\n */\n\nimport { safeHref } from '#lib/url'\n\nexport { safeHref }\n\nexport type MessageInline =\n | Readonly<{ kind: 'text'; text: string }>\n | Readonly<{ kind: 'code'; text: string }>\n | Readonly<{ kind: 'strong'; children: readonly MessageInline[] }>\n | Readonly<{ kind: 'em'; children: readonly MessageInline[] }>\n | Readonly<{ kind: 'link'; href: string; children: readonly MessageInline[] }>\n /** A resolved citation marker: 1-based source numbers, each within `citations`. */\n | Readonly<{ kind: 'cite'; numbers: readonly number[]; raw: string }>\n\nexport type MessageBlock =\n | Readonly<{ kind: 'paragraph'; inline: readonly MessageInline[]; raw: string }>\n | Readonly<{\n kind: 'heading'\n level: 1 | 2 | 3 | 4\n inline: readonly MessageInline[]\n raw: string\n }>\n | Readonly<{\n kind: 'list'\n ordered: boolean\n start: number\n items: readonly (readonly MessageInline[])[]\n raw: string\n }>\n | Readonly<{ kind: 'quote'; inline: readonly MessageInline[]; raw: string }>\n | Readonly<{\n kind: 'code'\n language: string | undefined\n code: string\n /** False while the fence is still open and the text may still grow. */\n complete: boolean\n raw: string\n }>\n\nconst WHITESPACE = /\\s/\n\n/**\n * An opening fence: up to three spaces, a run of three or more backticks or of\n * three or more tildes, then an info string that holds no backtick. The first\n * word of the info string is the language. This is a scan, not one pattern,\n * because a pattern whose classes overlap (`[^\\s`]*` then `[^`]*`) retries every\n * split of a long info string when a stray backtick ends it: three backticks, a\n * long run of `a` and a trailing backtick took quadratic time.\n */\nfunction fenceOpen(line: string): Readonly<{ marker: string; language: string }> | undefined {\n let start = 0\n while (start < 3 && line.charCodeAt(start) === 32) start += 1\n const mark = line[start]\n if (mark !== '`' && mark !== '~') return undefined\n let end = start + 1\n while (line[end] === mark) end += 1\n if (end - start < 3) return undefined\n if (line.includes('`', end)) return undefined\n let wordStart = end\n while (line[wordStart] === ' ' || line[wordStart] === '\\t') wordStart += 1\n let wordEnd = wordStart\n while (wordEnd < line.length && !WHITESPACE.test(line[wordEnd]!)) wordEnd += 1\n return { marker: line.slice(start, end), language: line.slice(wordStart, wordEnd) }\n}\ntype FenceOpen = NonNullable<ReturnType<typeof fenceOpen>>\n\n/**\n * The body of a fence that opened on `lines[start - 1]`: every line up to a\n * closing run of the same mark at least as long as the opening one, or to the end\n * of the text when none comes.\n */\nfunction readFence(\n lines: readonly string[],\n start: number,\n fence: FenceOpen\n): Readonly<{ code: string; closed: boolean; next: number }> {\n const body: string[] = []\n let index = start\n while (index < lines.length) {\n const candidate = lines[index]!\n const close = /^ {0,3}(`{3,}|~{3,})[ \\t]*$/.exec(candidate)\n if (close && close[1]![0] === fence.marker[0] && close[1]!.length >= fence.marker.length)\n return { code: body.join('\\n'), closed: true, next: index + 1 }\n body.push(candidate)\n index += 1\n }\n return { code: body.join('\\n'), closed: false, next: index }\n}\n\nexport type FenceSegment =\n | Readonly<{ kind: 'prose'; text: string }>\n | Readonly<{\n kind: 'code'\n language: string | undefined\n code: string\n /** False while the fence is still open and the text may still grow. */\n complete: boolean\n }>\n\n/**\n * Text split into fenced code and the prose between, by the same fence grammar\n * `parseMessageText` reads. For a renderer that draws code blocks but leaves the\n * prose as written (`MessageBody`).\n */\nexport function splitCodeFences(\n text: string,\n options: { streaming?: boolean } = {}\n): readonly FenceSegment[] {\n const lines = text.replace(/\\r\\n?/g, '\\n').split('\\n')\n const segments: FenceSegment[] = []\n let prose: string[] = []\n const flushProse = () => {\n if (prose.length > 0) segments.push({ kind: 'prose', text: prose.join('\\n') })\n prose = []\n }\n let index = 0\n while (index < lines.length) {\n const line = lines[index]!\n const fence = fenceOpen(line)\n if (!fence) {\n prose.push(line)\n index += 1\n continue\n }\n flushProse()\n const block = readFence(lines, index + 1, fence)\n segments.push({\n kind: 'code',\n language: fence.language || undefined,\n code: block.code,\n complete: block.closed || !options.streaming,\n })\n index = block.next\n }\n flushProse()\n return segments\n}\n\n// The lookahead after each marker's spaces makes that run maximal, so a line\n// that fails later (`.` stops at U+2028) cannot retry every shorter run.\nconst BULLET = /^ {0,3}[-*+][ \\t]+(?![ \\t])(.*)$/\nconst ORDERED = /^ {0,3}(\\d{1,9})[.)][ \\t]+(?![ \\t])(.*)$/\nconst QUOTE = /^ {0,3}>[ \\t]?(.*)$/\n\nconst isBlank = (char: string | undefined) => char === ' ' || char === '\\t'\nconst LINE_TERMINATOR = /[\\n\\r\\u2028\\u2029]/\n\n/**\n * An ATX heading: up to three spaces, one to four `#`, spaces or tabs, then the\n * text, with any trailing spaces and closing `#` run removed. This is a scan for\n * the reason `fenceOpen` is: the equivalent pattern (`(.+?)[ \\t]*#*[ \\t]*$`)\n * retries the closing check from every position of a long run of spaces.\n */\nfunction headingOf(line: string): Readonly<{ level: 1 | 2 | 3 | 4; text: string }> | undefined {\n let start = 0\n while (start < 3 && line.charCodeAt(start) === 32) start += 1\n let marks = start\n while (line[marks] === '#') marks += 1\n const level = marks - start\n if (level < 1 || level > 4 || !isBlank(line[marks])) return undefined\n let textStart = marks\n while (isBlank(line[textStart])) textStart += 1\n if (textStart === line.length) {\n // Only blanks follow the marker: the text is the last of them, which needs a second one.\n return textStart - marks >= 2\n ? { level: level as 1 | 2 | 3 | 4, text: line[line.length - 1]! }\n : undefined\n }\n if (LINE_TERMINATOR.test(line.slice(textStart))) return undefined\n // Drop the longest tail of blanks, a run of `#`, and blanks again.\n let textEnd = line.length\n while (textEnd > textStart && isBlank(line[textEnd - 1])) textEnd -= 1\n while (textEnd > textStart && line[textEnd - 1] === '#') textEnd -= 1\n while (textEnd > textStart && isBlank(line[textEnd - 1])) textEnd -= 1\n // Text that is nothing but a closing run keeps its first character.\n return {\n level: level as 1 | 2 | 3 | 4,\n text: line.slice(textStart, Math.max(textEnd, textStart + 1)),\n }\n}\n\nconst MAX_INLINE_DEPTH = 4\n\n/** A marker may cite at most this many sources, so one cannot flood a sentence. */\nconst MAX_CITED_SOURCES = 6\nconst CITATION = /\\[\\^(\\d{1,4}(?:[ \\t]*,[ \\t]*\\d{1,4}){0,5})\\]/y\n\nexport type ParseInlineOptions = {\n /** How many sources the host has. Without it no marker is a citation. */\n citations?: number\n /** Inside a link label, where a citation (itself a button) must not nest. */\n inLink?: boolean\n}\n\nfunction citationAt(text: string, index: number, count: number): MessageInline | undefined {\n CITATION.lastIndex = index\n const match = CITATION.exec(text)\n if (!match) return undefined\n const numbers = [...new Set(match[1]!.split(',').map((part) => Number(part.trim())))]\n if (numbers.length > MAX_CITED_SOURCES) return undefined\n if (numbers.some((number) => number < 1 || number > count)) return undefined\n return { kind: 'cite', numbers, raw: match[0] }\n}\n\n/** Inline spans. Delimiters must close on the same block, or they stay literal. */\nexport function parseInline(\n text: string,\n depth = 0,\n options: ParseInlineOptions = {}\n): readonly MessageInline[] {\n const out: MessageInline[] = []\n let brackets: ReadonlyMap<number, number> | undefined\n let paren = -2\n let buffer = ''\n const flush = () => {\n if (buffer) out.push({ kind: 'text', text: buffer })\n buffer = ''\n }\n let index = 0\n while (index < text.length) {\n const char = text[index]!\n if (char === '`') {\n let ticks = 1\n while (text[index + ticks] === '`') ticks += 1\n const fence = '`'.repeat(ticks)\n const close = text.indexOf(fence, index + ticks)\n if (close > index + ticks) {\n flush()\n out.push({ kind: 'code', text: text.slice(index + ticks, close).replace(/^ (.*) $/, '$1') })\n index = close + ticks\n continue\n }\n buffer += fence\n index += ticks\n continue\n }\n if (depth < MAX_INLINE_DEPTH && (char === '*' || char === '_')) {\n const double = text[index + 1] === char\n const delimiter = double ? char + char : char\n const start = index + delimiter.length\n // Word-internal underscores cannot open emphasis. Reject before scanning,\n // and consume both marks so the second cannot rescan the remaining pairs.\n if (char === '_' && index > 0 && /[A-Za-z0-9]/.test(text[index - 1] ?? '')) {\n buffer += delimiter\n index = start\n continue\n }\n const next = text[start]\n // A delimiter opens only before a non-space, so `a * b * c` and `2 * 3` stay arithmetic.\n if (next !== undefined && !/\\s/.test(next)) {\n const close = findClosing(text, delimiter, start)\n if (double && !(close > start && !/\\s/.test(text[close - 1] ?? ' '))) {\n // An opener that does not close stays literal as a pair. Retrying its\n // second mark as emphasis would scan to the end of the line again, so a\n // line of unclosed `**a ` would be quadratic.\n buffer += delimiter\n index = start\n continue\n }\n if (close > start && !/\\s/.test(text[close - 1] ?? ' ')) {\n flush()\n out.push({\n kind: double ? 'strong' : 'em',\n children: parseInline(text.slice(start, close), depth + 1, options),\n })\n index = close + delimiter.length\n continue\n }\n }\n }\n if (char === '[' && text[index + 1] === '^' && options.citations && !options.inLink) {\n const cite = citationAt(text, index, options.citations)\n if (cite && cite.kind === 'cite') {\n flush()\n out.push(cite)\n index += cite.raw.length\n continue\n }\n }\n if (depth < MAX_INLINE_DEPTH && char === '[') {\n brackets ??= bracketMatches(text)\n const labelEnd = brackets.get(index) ?? -1\n if (labelEnd > index && text[labelEnd + 1] === '(') {\n // The nearest `)` is remembered: a run of `[a](` with no `)` after it\n // would otherwise search to the end of the text from every opener.\n if (paren !== -1 && paren < labelEnd + 2) paren = text.indexOf(')', labelEnd + 2)\n const hrefEnd = paren\n if (hrefEnd > labelEnd + 1) {\n const href = safeHref(text.slice(labelEnd + 2, hrefEnd))\n if (href) {\n flush()\n out.push({\n kind: 'link',\n href,\n children: parseInline(text.slice(index + 1, labelEnd), depth + 1, {\n ...options,\n inLink: true,\n }),\n })\n index = hrefEnd + 1\n continue\n }\n }\n }\n }\n buffer += char\n index += 1\n }\n flush()\n return out\n}\n\nfunction findClosing(text: string, delimiter: string, from: number): number {\n let index = from\n while (index < text.length) {\n if (text[index] === '`') {\n // Skip a code span so `**a `**` b**` closes where the code ends.\n const close = text.indexOf('`', index + 1)\n if (close < 0) return -1\n index = close + 1\n continue\n }\n if (text[index] === delimiter[0]) {\n let end = index + 1\n while (text[end] === delimiter[0]) end += 1\n const run = end - index\n if (delimiter.length === 1) {\n // Emphasis closes on a run of one (or an odd run, whose last mark closes).\n // An even run is `**` pairs: strong spans inside the emphasis, which the\n // inner parse reads. One pass, and the scan stops at the next odd run, so\n // a line of unclosed delimiters is still linear.\n if (run % 2 === 1) return end - 1\n } else if (run >= delimiter.length) {\n // Strong closes on the last two marks of a run.\n return end - delimiter.length\n }\n index = end\n continue\n }\n index += 1\n }\n return -1\n}\n\n/**\n * The `]` that closes each `[`, found in one pass. A match never crosses a\n * newline, and an unmatched `[` has no entry. Scanning forward from every `[`\n * instead is quadratic on a long line of unclosed brackets, which a pasted page\n * or a hostile model can use to hang the renderer.\n */\nfunction bracketMatches(text: string): ReadonlyMap<number, number> {\n const matches = new Map<number, number>()\n const open: number[] = []\n for (let index = 0; index < text.length; index += 1) {\n const char = text[index]\n if (char === '[') open.push(index)\n else if (char === ']') {\n const start = open.pop()\n if (start !== undefined) matches.set(start, index)\n } else if (char === '\\n') open.length = 0\n }\n return matches\n}\n\n/** Parse text into blocks. Pure, total, and linear in the length of `text`. */\nexport function parseMessageText(\n text: string,\n options: { streaming?: boolean; citations?: number } = {}\n): readonly MessageBlock[] {\n return parseLines(text.replace(/\\r\\n?/g, '\\n'), options).blocks\n}\n\nexport type MessageParseOptions = { streaming?: boolean; citations?: number }\n\n/**\n * A parse that the next, longer text can continue from. See\n * {@link parseMessageTextIncremental}.\n */\nexport type MessageParse = Readonly<{\n /** The normalised text that was parsed. */\n text: string\n streaming: boolean\n citations: number\n blocks: readonly MessageBlock[]\n /** The offset in `text` where each block's first line starts. */\n starts: readonly number[]\n}>\n\n/**\n * `parseMessageText`, resumed.\n *\n * A streaming reply grows by appending, and reparsing the whole text per token\n * makes a long reply quadratic. When `text` extends `previous.text` under the same\n * options, only its final line can still change, since it may be unfinished. A block\n * that ends before that line is terminated by a finished line (a blank line, a\n * closing fence, or the line that starts the next block), so appending cannot\n * change it. Only the tail from the last block that starts before the final line\n * is parsed again, and the earlier blocks are returned as the same objects. The\n * parser keeps no state across a block boundary, so the tail parsed alone gives\n * exactly the blocks a full parse gives there. Anything else (an edit, a\n * different option) is a full parse.\n */\nexport function parseMessageTextIncremental(\n previous: MessageParse | undefined,\n text: string,\n options: MessageParseOptions = {}\n): MessageParse {\n const normalized = text.replace(/\\r\\n?/g, '\\n')\n const streaming = options.streaming ?? false\n const citations = options.citations ?? 0\n if (\n previous &&\n previous.streaming === streaming &&\n previous.citations === citations &&\n previous.blocks.length > 0 &&\n normalized.length >= previous.text.length &&\n normalized.startsWith(previous.text)\n ) {\n // Only the final line can still change (it may not be finished), and with it\n // the block it belongs to or the one it ends. Resume from the last block that\n // starts before that line: every block before it ends at a finished line.\n const lastLine = previous.text.lastIndexOf('\\n') + 1\n let keep = previous.starts.length - 1\n while (keep >= 0 && previous.starts[keep]! >= lastLine) keep -= 1\n if (keep > 0) {\n const resumeAt = previous.starts[keep]!\n const tail = parseLines(normalized.slice(resumeAt), options)\n return {\n text: normalized,\n streaming,\n citations,\n blocks: [...previous.blocks.slice(0, keep), ...tail.blocks],\n starts: [\n ...previous.starts.slice(0, keep),\n ...tail.starts.map((start) => start + resumeAt),\n ],\n }\n }\n }\n const full = parseLines(normalized, options)\n return { text: normalized, streaming, citations, ...full }\n}\n\nfunction parseLines(\n text: string,\n options: MessageParseOptions\n): { blocks: MessageBlock[]; starts: number[] } {\n const inline = (source: string) => parseInline(source, 0, { citations: options.citations })\n const lines = text.split('\\n')\n // The offset where each line starts, so a block can record where it began.\n const lineStarts: number[] = []\n for (let line = 0, offset = 0; line < lines.length; line++) {\n lineStarts.push(offset)\n offset += lines[line]!.length + 1\n }\n const blocks: MessageBlock[] = []\n const starts: number[] = []\n let paragraph: string[] = []\n let paragraphStart = 0\n const flushParagraph = () => {\n if (paragraph.length === 0) return\n const raw = paragraph.join('\\n')\n blocks.push({ kind: 'paragraph', inline: inline(raw), raw })\n starts.push(lineStarts[paragraphStart]!)\n paragraph = []\n }\n\n let index = 0\n while (index < lines.length) {\n const line = lines[index]!\n const fence = fenceOpen(line)\n if (fence) {\n flushParagraph()\n const marker = fence.marker\n const language = fence.language || undefined\n const { code, closed, next } = readFence(lines, index + 1, fence)\n starts.push(lineStarts[index]!)\n index = next\n blocks.push({\n kind: 'code',\n language,\n code,\n complete: closed || !options.streaming,\n raw: `${marker}${language ?? ''}\\n${code}${closed ? `\\n${marker}` : ''}`,\n })\n continue\n }\n if (line.trim() === '') {\n flushParagraph()\n index += 1\n continue\n }\n const heading = headingOf(line)\n if (heading) {\n flushParagraph()\n starts.push(lineStarts[index]!)\n blocks.push({\n kind: 'heading',\n level: heading.level,\n inline: inline(heading.text),\n raw: line,\n })\n index += 1\n continue\n }\n const bullet = BULLET.exec(line)\n const ordered = bullet ? null : ORDERED.exec(line)\n if (bullet || ordered) {\n flushParagraph()\n starts.push(lineStarts[index]!)\n const items: MessageInline[][] = []\n const rawLines: string[] = []\n const isOrdered = ordered !== null\n const start = ordered ? Number(ordered[1]) : 1\n while (index < lines.length) {\n const current = lines[index]!\n const match = isOrdered ? ORDERED.exec(current) : BULLET.exec(current)\n if (match) {\n items.push([...inline(isOrdered ? match[2]! : match[1]!)])\n rawLines.push(current)\n index += 1\n continue\n }\n // An indented continuation belongs to the previous item.\n if (/^ {2,}\\S/.test(current) && items.length > 0) {\n // Append in place: copying the accumulated spans on every continuation\n // makes a long item quadratic in its number of lines. Push one span at\n // a time, because spreading a line of many spans into `push` exceeds\n // the engine's argument limit and throws.\n const item = items[items.length - 1]!\n item.push({ kind: 'text', text: ' ' })\n for (const span of inline(current.trim())) item.push(span)\n rawLines.push(current)\n index += 1\n continue\n }\n break\n }\n blocks.push({ kind: 'list', ordered: isOrdered, start, items, raw: rawLines.join('\\n') })\n continue\n }\n const quote = QUOTE.exec(line)\n if (quote) {\n flushParagraph()\n starts.push(lineStarts[index]!)\n const quoted: string[] = []\n while (index < lines.length) {\n const match = QUOTE.exec(lines[index]!)\n if (!match) break\n quoted.push(match[1]!)\n index += 1\n }\n const raw = quoted.join('\\n')\n blocks.push({ kind: 'quote', inline: inline(raw), raw })\n continue\n }\n if (paragraph.length === 0) paragraphStart = index\n paragraph.push(line)\n index += 1\n }\n flushParagraph()\n return { blocks, starts }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,IAAM,aAAa;;;;;;;;;AAUnB,SAAS,UAAU,MAA0E;CAC3F,IAAI,QAAQ;CACZ,OAAO,QAAQ,KAAK,KAAK,WAAW,KAAK,MAAM,IAAI,SAAS;CAC5D,MAAM,OAAO,KAAK;CAClB,IAAI,SAAS,OAAO,SAAS,KAAK,OAAO,KAAA;CACzC,IAAI,MAAM,QAAQ;CAClB,OAAO,KAAK,SAAS,MAAM,OAAO;CAClC,IAAI,MAAM,QAAQ,GAAG,OAAO,KAAA;CAC5B,IAAI,KAAK,SAAS,KAAK,GAAG,GAAG,OAAO,KAAA;CACpC,IAAI,YAAY;CAChB,OAAO,KAAK,eAAe,OAAO,KAAK,eAAe,KAAM,aAAa;CACzE,IAAI,UAAU;CACd,OAAO,UAAU,KAAK,UAAU,CAAC,WAAW,KAAK,KAAK,QAAS,GAAG,WAAW;CAC7E,OAAO;EAAE,QAAQ,KAAK,MAAM,OAAO,GAAG;EAAG,UAAU,KAAK,MAAM,WAAW,OAAO;CAAE;AACpF;;;;;;AAQA,SAAS,UACP,OACA,OACA,OAC2D;CAC3D,MAAM,OAAiB,CAAC;CACxB,IAAI,QAAQ;CACZ,OAAO,QAAQ,MAAM,QAAQ;EAC3B,MAAM,YAAY,MAAM;EACxB,MAAM,QAAQ,8BAA8B,KAAK,SAAS;EAC1D,IAAI,SAAS,MAAM,EAAE,CA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ACrB,SAAS;KACT;IACF;IAEA,IAAI,WAAW,KAAK,OAAO,KAAK,MAAM,SAAS,GAAG;KAKhD,MAAM,OAAO,MAAM,MAAM,SAAS;KAClC,KAAK,KAAK;MAAE,MAAM;MAAQ,MAAM;KAAI,CAAC;KACrC,KAAK,MAAM,QAAQ,OAAO,QAAQ,KAAK,CAAC,GAAG,KAAK,KAAK,IAAI;KACzD,SAAS,KAAK,OAAO;KACrB,SAAS;KACT;IACF;IACA;GACF;GACA,OAAO,KAAK;IAAE,MAAM;IAAQ,SAAS;IAAW;IAAO;IAAO,KAAK,SAAS,KAAK,IAAI;GAAE,CAAC;GACxF;EACF;EAEA,IADc,MAAM,KAAK,IACrB,GAAO;GACT,eAAe;GACf,OAAO,KAAK,WAAW,MAAO;GAC9B,MAAM,SAAmB,CAAC;GAC1B,OAAO,QAAQ,MAAM,QAAQ;IAC3B,MAAM,QAAQ,MAAM,KAAK,MAAM,MAAO;IACtC,IAAI,CAAC,OAAO;IACZ,OAAO,KAAK,MAAM,EAAG;IACrB,SAAS;GACX;GACA,MAAM,MAAM,OAAO,KAAK,IAAI;GAC5B,OAAO,KAAK;IAAE,MAAM;IAAS,QAAQ,OAAO,GAAG;IAAG;GAAI,CAAC;GACvD;EACF;EACA,IAAI,UAAU,WAAW,GAAG,iBAAiB;EAC7C,UAAU,KAAK,IAAI;EACnB,SAAS;CACX;CACA,eAAe;CACf,OAAO;EAAE;EAAQ;CAAO;AAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-select.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/native-select/native-select.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"native-select.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/native-select/native-select.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAS9C,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,GAAG;IACvE;;;;;OAKG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;IACzB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,mEAAmE;IACnE,OAAO,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAA;IACvC,2EAA2E;IAC3E,YAAY,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAA;CACjD,CAAA;AA4CD;;;;;;;;;GASG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAC,CAAA;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,kCAgGpD"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { useFormFieldControl } from "../../../lib/form-field.js";
|
|
2
2
|
import { cn } from "../../../lib/utils.js";
|
|
3
|
+
import { fastIcon } from "../../../lib/fast-icon.js";
|
|
3
4
|
import { className, createComponent, effect, insert, mergeProps, spread, template, use } from "solid-js/web";
|
|
4
5
|
import { ChevronDownIcon } from "lucide-solid";
|
|
5
6
|
import { For, Show, createEffect, onMount, splitProps } from "solid-js";
|
|
6
7
|
// src/components/ui/native-select/native-select.tsx
|
|
7
8
|
var _tmpl$ = /*#__PURE__*/ template(`<span data-slot=native-select-wrapper><select data-slot=native-select>`);
|
|
8
9
|
var _tmpl$2 = /*#__PURE__*/ template(`<option>`);
|
|
10
|
+
var ChevronDownIcon$1 = fastIcon(ChevronDownIcon);
|
|
9
11
|
function setSelectedValue(select, value, multiple) {
|
|
10
12
|
if (value === void 0) return;
|
|
11
13
|
if (multiple && Array.isArray(value)) {
|
|
@@ -41,14 +43,7 @@ function NativeSelect(props) {
|
|
|
41
43
|
"aria-invalid",
|
|
42
44
|
"aria-errormessage"
|
|
43
45
|
]);
|
|
44
|
-
const field = useFormFieldControl("control",
|
|
45
|
-
id: local.id,
|
|
46
|
-
"aria-label": local["aria-label"],
|
|
47
|
-
"aria-labelledby": local["aria-labelledby"],
|
|
48
|
-
"aria-describedby": local["aria-describedby"],
|
|
49
|
-
"aria-invalid": local["aria-invalid"],
|
|
50
|
-
"aria-errormessage": local["aria-errormessage"]
|
|
51
|
-
});
|
|
46
|
+
const field = useFormFieldControl("control", local);
|
|
52
47
|
let select;
|
|
53
48
|
createEffect(() => {
|
|
54
49
|
local.options;
|
|
@@ -118,7 +113,7 @@ function NativeSelect(props) {
|
|
|
118
113
|
})()
|
|
119
114
|
})
|
|
120
115
|
}));
|
|
121
|
-
insert(_el$, createComponent(ChevronDownIcon, {
|
|
116
|
+
insert(_el$, createComponent(ChevronDownIcon$1, {
|
|
122
117
|
"data-slot": "native-select-icon",
|
|
123
118
|
"aria-hidden": "true",
|
|
124
119
|
get ["class"]() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-select.js","names":["ChevronDownIcon","createEffect","For","onMount","Show","splitProps","useFormFieldControl","cn","size","wrapperClass","options","defaultValue","setSelectedValue","select","value","multiple","undefined","Array","isArray","selected","Set","map","String","option","has","isControlledOptionSelected","some","item","initializeDefaultSelection","defaultValues","defaultSelected","label","disabled","NativeSelect","props","local","rest","field","id","Boolean","_el$","_tmpl$","_el$2","firstChild","_$use","element","_$spread","_$mergeProps","class","_$insert","_$createComponent","when","fallback","children","each","_el$3","_tmpl$2","_$effect","_p$","_v$","_v$2","e","t","_$className"],"sources":["../../../../src/components/ui/native-select/native-select.tsx"],"sourcesContent":["import { ChevronDownIcon } from 'lucide-solid'\nimport type { ComponentProps } from 'solid-js'\nimport { createEffect, For, onMount, Show, splitProps } from 'solid-js'\nimport { useFormFieldControl } from '#lib/form-field'\nimport { cn } from '#lib/utils'\n\nexport type NativeSelectProps = Omit<ComponentProps<'select'>, 'size'> & {\n /**\n * The control rung, matching `Input` and `SelectTrigger`: `sm` for a dense\n * toolbar or pane filter, `md` (the default) everywhere else. This replaces the\n * native `size` attribute, which turns a select into a list box, a different\n * control that this styled single-line select is not.\n */\n size?: 'sm' | 'md' | 'lg'\n /**\n * Layout classes for the element that wraps the select and its chevron: a\n * width or `max-w-*`, `flex-1`, `col-span-*`, a margin. `class` reaches the\n * `<select>` itself, which is the wrong box for any of those, because the\n * wrapper is what a flex or grid parent lays out. The select fills the\n * wrapper, so the chevron stays at the control's edge at any width.\n */\n wrapperClass?: string\n /** Render the choices from data instead of raw option children. */\n options?: readonly NativeSelectOption[]\n /** Initialize an uncontrolled selection after its native options mount. */\n defaultValue?: ComponentProps<'select'>['value']\n}\n\nfunction setSelectedValue(\n select: HTMLSelectElement,\n value: ComponentProps<'select'>['value'],\n multiple: boolean\n) {\n if (value === undefined) return\n\n if (multiple && Array.isArray(value)) {\n const selected = new Set(value.map(String))\n for (const option of select.options) option.selected = selected.has(option.value)\n return\n }\n\n select.value = String(Array.isArray(value) ? (value[0] ?? '') : value)\n}\n\nfunction isControlledOptionSelected(\n value: ComponentProps<'select'>['value'],\n option: string,\n multiple: boolean\n): boolean | undefined {\n if (value === undefined) return undefined\n if (multiple && Array.isArray(value)) return value.some((item) => String(item) === option)\n return String(Array.isArray(value) ? (value[0] ?? '') : value) === option\n}\n\nfunction initializeDefaultSelection(\n select: HTMLSelectElement,\n value: ComponentProps<'select'>['value'],\n multiple: boolean\n) {\n if (value === undefined) return\n\n const defaultValues =\n multiple && Array.isArray(value)\n ? new Set(value.map(String))\n : new Set([String(Array.isArray(value) ? (value[0] ?? '') : value)])\n\n for (const option of select.options) option.defaultSelected = defaultValues.has(option.value)\n setSelectedValue(select, value, multiple)\n}\n\n/**\n * NativeSelect.\n *\n * A styled native `<select>` for compact, finite choices. Use `Select` when the\n * list needs a custom popover, typed options, or runtime filtering; this keeps\n * the browser's built-in keyboard, form, option, and label behavior.\n *\n * Translated from shadcn/ui's MIT-licensed NativeSelect wrapper to SolidJS and\n * the Adea token system; see the root NOTICE for source and attribution.\n */\nexport type NativeSelectOption = Readonly<{\n value: string\n label: string\n disabled?: boolean\n}>\n\nexport function NativeSelect(props: NativeSelectProps) {\n const [local, rest] = splitProps(props, [\n 'class',\n 'wrapperClass',\n 'size',\n 'children',\n 'defaultValue',\n 'options',\n 'id',\n 'aria-label',\n 'aria-labelledby',\n 'aria-describedby',\n 'aria-invalid',\n 'aria-errormessage',\n ])\n const field = useFormFieldControl('control', {\n id: local.id,\n 'aria-label': local['aria-label'],\n 'aria-labelledby': local['aria-labelledby'],\n 'aria-describedby': local['aria-describedby'],\n 'aria-invalid': local['aria-invalid'],\n 'aria-errormessage': local['aria-errormessage'],\n })\n let select: HTMLSelectElement | undefined\n\n // Set selection after native options exist; setting select.value before its\n // children are mounted makes browsers fall back to the first option.\n createEffect(() => {\n // Replacing option objects rebuilds native options even when value is unchanged.\n // Reapply the controlled value after that render rather than accepting the\n // browser's first enabled option as an implicit selection.\n void local.options\n if (!select) return\n setSelectedValue(select, rest.value, Boolean(rest.multiple))\n })\n onMount(() => {\n if (select && rest.value === undefined) {\n initializeDefaultSelection(select, local.defaultValue, Boolean(rest.multiple))\n }\n })\n\n return (\n <span\n data-slot=\"native-select-wrapper\"\n class={cn('relative inline-flex min-w-0', local.wrapperClass)}\n >\n <select\n ref={(element) => {\n select = element\n }}\n data-slot=\"native-select\"\n id={field?.id ?? local.id}\n aria-label={local['aria-label']}\n aria-labelledby={field?.['aria-labelledby'] ?? local['aria-labelledby']}\n aria-describedby={field?.['aria-describedby'] ?? local['aria-describedby']}\n aria-invalid={field?.['aria-invalid'] ?? local['aria-invalid']}\n aria-errormessage={field?.['aria-errormessage'] ?? local['aria-errormessage']}\n class={cn(\n 'w-full min-w-0 appearance-none rounded-md border border-input bg-transparent',\n {\n 'h-control-sm px-control-sm pr-8 text-xs': local.size === 'sm',\n 'h-control-md px-control-md pr-9 text-sm':\n local.size === 'md' || local.size === undefined,\n 'h-control-lg px-control-lg pr-9 text-sm': local.size === 'lg',\n },\n 'transition-[color,box-shadow,border-color] ease-out outline-none',\n 'focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-primary-subtle',\n 'aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive-subtle',\n 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30',\n local.class\n )}\n {...rest}\n >\n <Show when={local.options} fallback={local.children}>\n {(options) => (\n <For each={options()}>\n {(option) => (\n <option\n value={option.value}\n disabled={option.disabled}\n selected={isControlledOptionSelected(\n rest.value,\n option.value,\n Boolean(rest.multiple)\n )}\n >\n {option.label}\n </option>\n )}\n </For>\n )}\n </Show>\n </select>\n <ChevronDownIcon\n data-slot=\"native-select-icon\"\n aria-hidden=\"true\"\n class={cn(\n 'pointer-events-none absolute end-2 top-1/2 -translate-y-1/2 text-muted-foreground',\n local.size === 'sm' ? 'size-3.5' : 'size-4'\n )}\n />\n </span>\n )\n}\n"],"mappings":";;;;;;;;AA4BA,SAASY,iBACPC,QACAC,OACAC,UACA;CACA,IAAID,UAAUE,KAAAA,GAAW;CAEzB,IAAID,YAAYE,MAAMC,QAAQJ,KAAK,GAAG;EACpC,MAAMK,WAAW,IAAIC,IAAIN,MAAMO,IAAIC,MAAM,CAAC;EAC1C,KAAK,MAAMC,UAAUV,OAAOH,SAASa,OAAOJ,WAAWA,SAASK,IAAID,OAAOT,KAAK;EAChF;CACF;CAEAD,OAAOC,QAAQQ,OAAOL,MAAMC,QAAQJ,KAAK,IAAKA,MAAM,MAAM,KAAMA,KAAK;AACvE;AAEA,SAASW,2BACPX,OACAS,QACAR,UACqB;CACrB,IAAID,UAAUE,KAAAA,GAAW,OAAOA,KAAAA;CAChC,IAAID,YAAYE,MAAMC,QAAQJ,KAAK,GAAG,OAAOA,MAAMY,MAAMC,SAASL,OAAOK,IAAI,MAAMJ,MAAM;CACzF,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AA7C,KAAAA;MAAA8C,GAAA9C,KAAAA;KAAA,CAAA;KAAAyC,aAAAF,MAAAzC,QANMS,OAAOT,KAAK;KAAA,OAAAyC;IAAA,EAAA,CAAA;GAUtB,CAAA;EAEJ,CAAA,CAAA;EAAAN,OAAAT,MAAAU,gBAGJlD,iBAAe;GAAA,aAAA;GAAA,eAAA;GAAA,KAAA,WAAA;IAAA,OAGPO,GACL,qFACA4B,MAAM3B,SAAS,OAAO,aAAa,QACrC;GAAC;EAAA,CAAA,GAAA,IAAA;EAAAiD,aAAAM,UAAAvB,MAvDIjC,GAAG,gCAAgC4B,MAAM1B,YAAY,CAAC,CAAA;EAAA,OAAA+B;CAAA,EAAA,CAAA;AA2DnE"}
|
|
1
|
+
{"version":3,"file":"native-select.js","names":["ChevronDownIcon","LucideChevronDownIcon","createEffect","For","onMount","Show","splitProps","useFormFieldControl","cn","fastIcon","size","wrapperClass","options","defaultValue","setSelectedValue","select","value","multiple","undefined","Array","isArray","selected","Set","map","String","option","has","isControlledOptionSelected","some","item","initializeDefaultSelection","defaultValues","defaultSelected","label","disabled","NativeSelect","props","local","rest","field","Boolean","_el$","_tmpl$","_el$2","firstChild","_$use","element","_$spread","_$mergeProps","id","class","_$insert","_$createComponent","when","fallback","children","each","_el$3","_tmpl$2","_$effect","_p$","_v$","_v$2","e","t","_$className"],"sources":["../../../../src/components/ui/native-select/native-select.tsx"],"sourcesContent":["import { ChevronDownIcon as LucideChevronDownIcon } from 'lucide-solid'\nimport type { ComponentProps } from 'solid-js'\nimport { createEffect, For, onMount, Show, splitProps } from 'solid-js'\nimport { useFormFieldControl } from '#lib/form-field'\nimport { cn } from '#lib/utils'\nimport { fastIcon } from '#lib/fast-icon'\n\n// lucide icons drawn from a cloned template (see fastIcon).\nconst ChevronDownIcon = fastIcon(LucideChevronDownIcon)\n\nexport type NativeSelectProps = Omit<ComponentProps<'select'>, 'size'> & {\n /**\n * The control rung, matching `Input` and `SelectTrigger`: `sm` for a dense\n * toolbar or pane filter, `md` (the default) everywhere else. This replaces the\n * native `size` attribute, which turns a select into a list box, a different\n * control that this styled single-line select is not.\n */\n size?: 'sm' | 'md' | 'lg'\n /**\n * Layout classes for the element that wraps the select and its chevron: a\n * width or `max-w-*`, `flex-1`, `col-span-*`, a margin. `class` reaches the\n * `<select>` itself, which is the wrong box for any of those, because the\n * wrapper is what a flex or grid parent lays out. The select fills the\n * wrapper, so the chevron stays at the control's edge at any width.\n */\n wrapperClass?: string\n /** Render the choices from data instead of raw option children. */\n options?: readonly NativeSelectOption[]\n /** Initialize an uncontrolled selection after its native options mount. */\n defaultValue?: ComponentProps<'select'>['value']\n}\n\nfunction setSelectedValue(\n select: HTMLSelectElement,\n value: ComponentProps<'select'>['value'],\n multiple: boolean\n) {\n if (value === undefined) return\n\n if (multiple && Array.isArray(value)) {\n const selected = new Set(value.map(String))\n for (const option of select.options) option.selected = selected.has(option.value)\n return\n }\n\n select.value = String(Array.isArray(value) ? (value[0] ?? '') : value)\n}\n\nfunction isControlledOptionSelected(\n value: ComponentProps<'select'>['value'],\n option: string,\n multiple: boolean\n): boolean | undefined {\n if (value === undefined) return undefined\n if (multiple && Array.isArray(value)) return value.some((item) => String(item) === option)\n return String(Array.isArray(value) ? (value[0] ?? '') : value) === option\n}\n\nfunction initializeDefaultSelection(\n select: HTMLSelectElement,\n value: ComponentProps<'select'>['value'],\n multiple: boolean\n) {\n if (value === undefined) return\n\n const defaultValues =\n multiple && Array.isArray(value)\n ? new Set(value.map(String))\n : new Set([String(Array.isArray(value) ? (value[0] ?? '') : value)])\n\n for (const option of select.options) option.defaultSelected = defaultValues.has(option.value)\n setSelectedValue(select, value, multiple)\n}\n\n/**\n * NativeSelect.\n *\n * A styled native `<select>` for compact, finite choices. Use `Select` when the\n * list needs a custom popover, typed options, or runtime filtering; this keeps\n * the browser's built-in keyboard, form, option, and label behavior.\n *\n * Translated from shadcn/ui's MIT-licensed NativeSelect wrapper to SolidJS and\n * the Adea token system; see the root NOTICE for source and attribution.\n */\nexport type NativeSelectOption = Readonly<{\n value: string\n label: string\n disabled?: boolean\n}>\n\nexport function NativeSelect(props: NativeSelectProps) {\n const [local, rest] = splitProps(props, [\n 'class',\n 'wrapperClass',\n 'size',\n 'children',\n 'defaultValue',\n 'options',\n 'id',\n 'aria-label',\n 'aria-labelledby',\n 'aria-describedby',\n 'aria-invalid',\n 'aria-errormessage',\n ])\n const field = useFormFieldControl('control', local)\n let select: HTMLSelectElement | undefined\n\n // Set selection after native options exist; setting select.value before its\n // children are mounted makes browsers fall back to the first option.\n createEffect(() => {\n // Replacing option objects rebuilds native options even when value is unchanged.\n // Reapply the controlled value after that render rather than accepting the\n // browser's first enabled option as an implicit selection.\n void local.options\n if (!select) return\n setSelectedValue(select, rest.value, Boolean(rest.multiple))\n })\n onMount(() => {\n if (select && rest.value === undefined) {\n initializeDefaultSelection(select, local.defaultValue, Boolean(rest.multiple))\n }\n })\n\n return (\n <span\n data-slot=\"native-select-wrapper\"\n class={cn('relative inline-flex min-w-0', local.wrapperClass)}\n >\n <select\n ref={(element) => {\n select = element\n }}\n data-slot=\"native-select\"\n id={field?.id ?? local.id}\n aria-label={local['aria-label']}\n aria-labelledby={field?.['aria-labelledby'] ?? local['aria-labelledby']}\n aria-describedby={field?.['aria-describedby'] ?? local['aria-describedby']}\n aria-invalid={field?.['aria-invalid'] ?? local['aria-invalid']}\n aria-errormessage={field?.['aria-errormessage'] ?? local['aria-errormessage']}\n class={cn(\n 'w-full min-w-0 appearance-none rounded-md border border-input bg-transparent',\n {\n 'h-control-sm px-control-sm pr-8 text-xs': local.size === 'sm',\n 'h-control-md px-control-md pr-9 text-sm':\n local.size === 'md' || local.size === undefined,\n 'h-control-lg px-control-lg pr-9 text-sm': local.size === 'lg',\n },\n 'transition-[color,box-shadow,border-color] ease-out outline-none',\n 'focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-primary-subtle',\n 'aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive-subtle',\n 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30',\n local.class\n )}\n {...rest}\n >\n <Show when={local.options} fallback={local.children}>\n {(options) => (\n <For each={options()}>\n {(option) => (\n <option\n value={option.value}\n disabled={option.disabled}\n selected={isControlledOptionSelected(\n rest.value,\n option.value,\n Boolean(rest.multiple)\n )}\n >\n {option.label}\n </option>\n )}\n </For>\n )}\n </Show>\n </select>\n <ChevronDownIcon\n data-slot=\"native-select-icon\"\n aria-hidden=\"true\"\n class={cn(\n 'pointer-events-none absolute end-2 top-1/2 -translate-y-1/2 text-muted-foreground',\n local.size === 'sm' ? 'size-3.5' : 'size-4'\n )}\n />\n </span>\n )\n}\n"],"mappings":";;;;;;;;;AAQA,IAAMA,oBAAkBS,SAASR,eAAqB;AAwBtD,SAASa,iBACPC,QACAC,OACAC,UACA;CACA,IAAID,UAAUE,KAAAA,GAAW;CAEzB,IAAID,YAAYE,MAAMC,QAAQJ,KAAK,GAAG;EACpC,MAAMK,WAAW,IAAIC,IAAIN,MAAMO,IAAIC,MAAM,CAAC;EAC1C,KAAK,MAAMC,UAAUV,OAAOH,SAASa,OAAOJ,WAAWA,SAASK,IAAID,OAAOT,KAAK;EAChF;CACF;CAEAD,OAAOC,QAAQQ,OAAOL,MAAMC,QAAQJ,KAAK,IAAKA,MAAM,MAAM,KAAMA,KAAK;AACvE;AAEA,SAASW,2BACPX,OACAS,QACAR,UACqB;CACrB,IAAID,UAAUE,KAAAA,GAAW,OAAOA,KAAAA;CAChC,IAAID,YAAYE,MAAMC,QAAQJ,KAAK,GAAG,OAAOA,MAAMY,MAAMC,SAASL,OAAOK,IAAI,MAAMJ,MAAM;CACzF,OAAOD,OAAOL,MAAMC,QAAQJ,KAAK,IAAKA,MAAM,MAAM,KAAMA,KAAK,MAAMS;AACrE;AAEA,SAASK,2BACPf,QACAC,OACAC,UACA;CACA,IAAID,UAAUE,KAAAA,GAAW;CAEzB,MAAMa,gBACJd,YAAYE,MAAMC,QAAQJ,KAA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iD,aAAAM,UAAAxB,MAvDIjC,GAAG,gCAAgC6B,MAAM1B,YAAY,CAAC,CAAA;EAAA,OAAA8B;CAAA,EAAA,CAAA;AA2DnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation-menu.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/navigation-menu/navigation-menu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA2C,KAAK,cAAc,EAAE,KAAK,GAAG,EAAE,MAAM,UAAU,CAAA;AACjG,OAAO,KAAK,qBAAqB,MAAM,+BAA+B,CAAA;
|
|
1
|
+
{"version":3,"file":"navigation-menu.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/navigation-menu/navigation-menu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA2C,KAAK,cAAc,EAAE,KAAK,GAAG,EAAE,MAAM,UAAU,CAAA;AACjG,OAAO,KAAK,qBAAqB,MAAM,+BAA+B,CAAA;AAgBtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,OAAO,qBAAqB,CAAC,IAAI,CAAC,GAAG;IACpF,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,eAsBxD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,qBAAqB,CAAC,IAAI,CAAC,eAE1F;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,qBAAqB,CAAC,OAAO,CAAC,eAuBhG;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,qBAAqB,CAAC,OAAO,CAAC,eAgChG;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,cAAc,CAAC,OAAO,qBAAqB,CAAC,QAAQ,CAAC,eAiB7D;AAED;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,cAAc,CAAC,OAAO,qBAAqB,CAAC,IAAI,CAAC,GAAG;IACxF,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;CACnB,CAAA;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,eA+BhE;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,cAAc,CAAC,OAAO,qBAAqB,CAAC,SAAS,CAAC,eAI9D;AAED,wDAAwD;AACxD,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,cAAc,CAAC,OAAO,qBAAqB,CAAC,UAAU,CAAC,eAI/D;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,qBAAqB,CAAC,KAAK,CAAC,eAG5F"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cn } from "../../../lib/utils.js";
|
|
2
2
|
import { menuItem, menuLabel, menuSeparator, overlayMotion, overlaySurface } from "../../../lib/overlay.js";
|
|
3
|
+
import { fastIcon } from "../../../lib/fast-icon.js";
|
|
3
4
|
import { className, createComponent, effect, insert, memo, mergeProps, template } from "solid-js/web";
|
|
4
5
|
import { ChevronDown } from "lucide-solid";
|
|
5
6
|
import { children, splitProps } from "solid-js";
|
|
@@ -7,6 +8,7 @@ import * as KobalteNavigationMenu from "@kobalte/core/navigation-menu";
|
|
|
7
8
|
// src/components/ui/navigation-menu/navigation-menu.tsx
|
|
8
9
|
var _tmpl$ = /*#__PURE__*/ template(`<span class=font-medium>`);
|
|
9
10
|
var _tmpl$2 = /*#__PURE__*/ template(`<span>`);
|
|
11
|
+
var ChevronDown$1 = fastIcon(ChevronDown);
|
|
10
12
|
function NavigationMenu(props) {
|
|
11
13
|
const [local, rest] = splitProps(props, [
|
|
12
14
|
"label",
|
|
@@ -36,7 +38,7 @@ function NavigationMenuTrigger(props) {
|
|
|
36
38
|
return createComponent(KobalteNavigationMenu.Trigger, mergeProps({ get ["class"]() {
|
|
37
39
|
return cn("inline-flex items-center gap-1 rounded-md px-3 py-1.5 text-sm font-medium text-muted-foreground", "transition-colors ease-out outline-none select-none", "hover:bg-muted hover:text-foreground", "data-[expanded]:bg-muted data-[expanded]:text-foreground", "data-[highlighted]:bg-muted data-[highlighted]:text-foreground", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none", local.class);
|
|
38
40
|
} }, rest, { get children() {
|
|
39
|
-
return [memo(() => local.children), createComponent(ChevronDown, {
|
|
41
|
+
return [memo(() => local.children), createComponent(ChevronDown$1, {
|
|
40
42
|
"aria-hidden": "true",
|
|
41
43
|
"class": "size-3.5 transition-transform duration-200 ease-out [[data-expanded]_&]:rotate-180"
|
|
42
44
|
})];
|