@adea-ai/ui 0.151.11 → 0.151.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NOTICE +3 -2
- package/dist/components/composites/about-dialog/about-dialog.d.ts.map +1 -1
- package/dist/components/composites/about-dialog/about-dialog.js +27 -48
- package/dist/components/composites/about-dialog/about-dialog.js.map +1 -1
- package/dist/components/composites/account-menu/account-menu.d.ts +2 -2
- package/dist/components/composites/account-menu/account-menu.d.ts.map +1 -1
- package/dist/components/composites/account-menu/account-menu.js +4 -22
- 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 +2 -4
- package/dist/components/composites/action-button/action-button.js.map +1 -1
- package/dist/components/composites/appearance-editor/accent-swatch-groups.d.ts +1 -10
- package/dist/components/composites/appearance-editor/accent-swatch-groups.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/accent-swatch-groups.js +2 -1
- package/dist/components/composites/appearance-editor/accent-swatch-groups.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 +3 -2
- 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 +1 -0
- 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 +28 -53
- 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 +7 -47
- package/dist/components/composites/appearance-editor/font-settings-group.js.map +1 -1
- package/dist/components/composites/appearance-editor/index.d.ts +1 -0
- package/dist/components/composites/appearance-editor/index.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/index.js +2 -1
- package/dist/components/composites/catalog-browser/catalog-browser.d.ts.map +1 -1
- package/dist/components/composites/catalog-browser/catalog-browser.js +8 -11
- package/dist/components/composites/catalog-browser/catalog-browser.js.map +1 -1
- package/dist/components/composites/chain-of-thought/chain-of-thought.d.ts +5 -4
- 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 +5 -12
- package/dist/components/composites/chain-of-thought/chain-of-thought.js.map +1 -1
- package/dist/components/composites/chat/chat.d.ts +2 -2
- package/dist/components/composites/chat/chat.d.ts.map +1 -1
- package/dist/components/composites/chat/chat.js.map +1 -1
- package/dist/components/composites/checkpoint/checkpoint-model.js +1 -1
- package/dist/components/composites/checkpoint/checkpoint-model.js.map +1 -1
- package/dist/components/composites/checkpoint/checkpoint.js +3 -3
- package/dist/components/composites/checkpoint/checkpoint.js.map +1 -1
- package/dist/components/composites/confirmation/confirmation-model.d.ts +3 -12
- package/dist/components/composites/confirmation/confirmation-model.d.ts.map +1 -1
- package/dist/components/composites/confirmation/confirmation-model.js +5 -17
- package/dist/components/composites/confirmation/confirmation-model.js.map +1 -1
- package/dist/components/composites/confirmation/confirmation.js +1 -1
- package/dist/components/composites/confirmation/confirmation.js.map +1 -1
- package/dist/components/composites/context/context-model.js +1 -1
- package/dist/components/composites/context/context-model.js.map +1 -1
- package/dist/components/composites/file-tree/build-file-tree.d.ts +5 -12
- package/dist/components/composites/file-tree/build-file-tree.d.ts.map +1 -1
- package/dist/components/composites/file-tree/build-file-tree.js +26 -30
- package/dist/components/composites/file-tree/build-file-tree.js.map +1 -1
- package/dist/components/composites/file-tree/file-tree.d.ts +2 -2
- package/dist/components/composites/file-tree/file-tree.d.ts.map +1 -1
- package/dist/components/composites/file-tree/file-tree.js +4 -30
- package/dist/components/composites/file-tree/file-tree.js.map +1 -1
- package/dist/components/composites/file-tree/index.d.ts +2 -1
- package/dist/components/composites/file-tree/index.d.ts.map +1 -1
- package/dist/components/composites/file-tree/index.js +2 -1
- package/dist/components/composites/help-center/help-center.d.ts.map +1 -1
- package/dist/components/composites/help-center/help-center.js +9 -20
- package/dist/components/composites/help-center/help-center.js.map +1 -1
- package/dist/components/composites/icon-picker/icon-picker.d.ts.map +1 -1
- package/dist/components/composites/icon-picker/icon-picker.js +7 -11
- package/dist/components/composites/icon-picker/icon-picker.js.map +1 -1
- package/dist/components/composites/inline-citation/citation.d.ts.map +1 -1
- package/dist/components/composites/inline-citation/citation.js +2 -1
- package/dist/components/composites/inline-citation/citation.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 +2 -1
- package/dist/components/composites/inline-citation/inline-citation.js.map +1 -1
- package/dist/components/composites/message-scroller/message-scroller.d.ts +4 -5
- package/dist/components/composites/message-scroller/message-scroller.d.ts.map +1 -1
- package/dist/components/composites/message-scroller/message-scroller.js +19 -13
- package/dist/components/composites/message-scroller/message-scroller.js.map +1 -1
- package/dist/components/composites/message-scroller/scroll-anchor.d.ts +4 -3
- package/dist/components/composites/message-scroller/scroll-anchor.d.ts.map +1 -1
- package/dist/components/composites/message-scroller/scroll-anchor.js +5 -3
- package/dist/components/composites/message-scroller/scroll-anchor.js.map +1 -1
- package/dist/components/composites/model-selector/model-selector.d.ts.map +1 -1
- package/dist/components/composites/model-selector/model-selector.js +1 -1
- package/dist/components/composites/model-selector/model-selector.js.map +1 -1
- package/dist/components/composites/model-selector/models.js +1 -1
- package/dist/components/composites/model-selector/models.js.map +1 -1
- package/dist/components/composites/plan/plan.d.ts.map +1 -1
- package/dist/components/composites/plan/plan.js +2 -3
- package/dist/components/composites/plan/plan.js.map +1 -1
- package/dist/components/composites/queue/queue.d.ts +2 -2
- package/dist/components/composites/queue/queue.d.ts.map +1 -1
- package/dist/components/composites/queue/queue.js +57 -64
- package/dist/components/composites/queue/queue.js.map +1 -1
- package/dist/components/composites/reasoning/index.js +3 -1
- package/dist/components/composites/reasoning/reasoning.d.ts +2 -3
- package/dist/components/composites/reasoning/reasoning.d.ts.map +1 -1
- package/dist/components/composites/reasoning/reasoning.js +5 -20
- package/dist/components/composites/reasoning/reasoning.js.map +1 -1
- package/dist/components/composites/settings/settings-layout.d.ts.map +1 -1
- package/dist/components/composites/settings/settings-layout.js +3 -2
- package/dist/components/composites/settings/settings-layout.js.map +1 -1
- package/dist/components/composites/settings/settings-navigation.d.ts.map +1 -1
- package/dist/components/composites/settings/settings-navigation.js +1 -1
- package/dist/components/composites/settings/settings-navigation.js.map +1 -1
- package/dist/components/composites/sources/index.js +2 -1
- package/dist/components/composites/sources/source.d.ts +3 -8
- package/dist/components/composites/sources/source.d.ts.map +1 -1
- package/dist/components/composites/sources/source.js +5 -30
- package/dist/components/composites/sources/source.js.map +1 -1
- package/dist/components/composites/sources/sources.js +2 -1
- 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 +3 -12
- package/dist/components/composites/stack-trace/stack-trace.js.map +1 -1
- package/dist/components/composites/subagent/subagent.d.ts +3 -1
- package/dist/components/composites/subagent/subagent.d.ts.map +1 -1
- package/dist/components/composites/subagent/subagent.js +5 -17
- package/dist/components/composites/subagent/subagent.js.map +1 -1
- package/dist/components/composites/suggestion/suggestion.d.ts.map +1 -1
- package/dist/components/composites/suggestion/suggestion.js +3 -2
- package/dist/components/composites/suggestion/suggestion.js.map +1 -1
- package/dist/components/composites/task/task.d.ts +2 -3
- package/dist/components/composites/task/task.d.ts.map +1 -1
- package/dist/components/composites/task/task.js +49 -109
- package/dist/components/composites/task/task.js.map +1 -1
- package/dist/components/composites/terminal/terminal-model.d.ts +1 -2
- package/dist/components/composites/terminal/terminal-model.d.ts.map +1 -1
- package/dist/components/composites/terminal/terminal-model.js +7 -1
- package/dist/components/composites/terminal/terminal-model.js.map +1 -1
- package/dist/components/composites/terminal/terminal.d.ts.map +1 -1
- package/dist/components/composites/terminal/terminal.js +3 -12
- 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 +3 -12
- package/dist/components/composites/test-results/test-results.js.map +1 -1
- package/dist/components/composites/tool/tool.d.ts +0 -1
- package/dist/components/composites/tool/tool.d.ts.map +1 -1
- package/dist/components/composites/tool/tool.js +47 -41
- package/dist/components/composites/tool/tool.js.map +1 -1
- package/dist/components/composites/tree/tree-navigation.d.ts +6 -2
- package/dist/components/composites/tree/tree-navigation.d.ts.map +1 -1
- package/dist/components/composites/tree/tree-navigation.js +18 -1
- package/dist/components/composites/tree/tree-navigation.js.map +1 -1
- package/dist/components/composites/tree/tree.d.ts +6 -0
- package/dist/components/composites/tree/tree.d.ts.map +1 -1
- package/dist/components/composites/tree/tree.js +30 -4
- package/dist/components/composites/tree/tree.js.map +1 -1
- package/dist/components/composites/update-dialog/channel-control.d.ts.map +1 -1
- package/dist/components/composites/update-dialog/channel-control.js +7 -8
- package/dist/components/composites/update-dialog/channel-control.js.map +1 -1
- package/dist/components/composites/update-dialog/update-dialog.d.ts +2 -26
- package/dist/components/composites/update-dialog/update-dialog.d.ts.map +1 -1
- package/dist/components/composites/update-dialog/update-dialog.js +47 -125
- package/dist/components/composites/update-dialog/update-dialog.js.map +1 -1
- package/dist/components/composites/update-dialog/update-model.d.ts +65 -0
- package/dist/components/composites/update-dialog/update-model.d.ts.map +1 -0
- package/dist/components/composites/update-dialog/update-model.js +75 -0
- package/dist/components/composites/update-dialog/update-model.js.map +1 -0
- 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 +3 -16
- 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 +10 -14
- package/dist/components/composites/workspace-switcher/workspace-switcher.js.map +1 -1
- package/dist/components/conversation/busy-send-button.d.ts +3 -5
- package/dist/components/conversation/busy-send-button.d.ts.map +1 -1
- package/dist/components/conversation/busy-send-button.js +4 -15
- package/dist/components/conversation/busy-send-button.js.map +1 -1
- package/dist/components/conversation/chat-composer.d.ts +1 -1
- package/dist/components/conversation/chat-composer.d.ts.map +1 -1
- package/dist/components/conversation/chat-composer.js +1 -1
- package/dist/components/conversation/chat-composer.js.map +1 -1
- package/dist/components/conversation/composer-core.d.ts +35 -0
- package/dist/components/conversation/composer-core.d.ts.map +1 -0
- package/dist/components/conversation/composer-core.js +68 -0
- package/dist/components/conversation/composer-core.js.map +1 -0
- package/dist/components/conversation/composer-menu.d.ts +1 -1
- package/dist/components/conversation/composer-menu.d.ts.map +1 -1
- package/dist/components/conversation/composer-menu.js.map +1 -1
- package/dist/components/conversation/conversation-pane.d.ts +4 -1
- package/dist/components/conversation/conversation-pane.d.ts.map +1 -1
- package/dist/components/conversation/conversation-pane.js +4 -0
- package/dist/components/conversation/conversation-pane.js.map +1 -1
- package/dist/components/conversation/conversation-surface.d.ts +9 -6
- package/dist/components/conversation/conversation-surface.d.ts.map +1 -1
- package/dist/components/conversation/conversation-surface.js +7 -5
- package/dist/components/conversation/conversation-surface.js.map +1 -1
- package/dist/components/conversation/ime-guard.d.ts +1 -0
- package/dist/components/conversation/ime-guard.d.ts.map +1 -1
- package/dist/components/conversation/ime-guard.js +5 -0
- package/dist/components/conversation/ime-guard.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 +16 -50
- package/dist/components/conversation/internal/chat-composer-shell.js.map +1 -1
- package/dist/components/conversation/message-composer.d.ts +1 -3
- package/dist/components/conversation/message-composer.d.ts.map +1 -1
- package/dist/components/conversation/message-composer.js +15 -32
- package/dist/components/conversation/message-composer.js.map +1 -1
- package/dist/components/conversation/message-row.d.ts +10 -11
- package/dist/components/conversation/message-row.d.ts.map +1 -1
- package/dist/components/conversation/message-row.js +24 -49
- package/dist/components/conversation/message-row.js.map +1 -1
- package/dist/components/conversation/paste-token-editor.d.ts.map +1 -1
- package/dist/components/conversation/paste-token-editor.js +7 -17
- package/dist/components/conversation/paste-token-editor.js.map +1 -1
- package/dist/components/conversation/paste-tokens.d.ts +10 -1
- package/dist/components/conversation/paste-tokens.d.ts.map +1 -1
- package/dist/components/conversation/paste-tokens.js +26 -2
- package/dist/components/conversation/paste-tokens.js.map +1 -1
- package/dist/components/conversation/scroll-follow-core.d.ts +30 -79
- package/dist/components/conversation/scroll-follow-core.d.ts.map +1 -1
- package/dist/components/conversation/scroll-follow-core.js +65 -54
- package/dist/components/conversation/scroll-follow-core.js.map +1 -1
- package/dist/components/conversation/scroll-follow.d.ts +5 -1
- package/dist/components/conversation/scroll-follow.d.ts.map +1 -1
- package/dist/components/conversation/scroll-follow.js +27 -91
- package/dist/components/conversation/scroll-follow.js.map +1 -1
- package/dist/components/conversation/thread-panel.d.ts +0 -2
- package/dist/components/conversation/thread-panel.d.ts.map +1 -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 +4 -16
- package/dist/components/conversation/transcript-composition.js.map +1 -1
- package/dist/components/conversation/transcript-folding.d.ts +0 -1
- package/dist/components/conversation/transcript-folding.d.ts.map +1 -1
- package/dist/components/conversation/transcript-folding.js +1 -1
- package/dist/components/conversation/transcript-folding.js.map +1 -1
- package/dist/components/conversation/transcript-grouping.d.ts +8 -0
- package/dist/components/conversation/transcript-grouping.d.ts.map +1 -1
- package/dist/components/conversation/transcript-grouping.js +17 -3
- package/dist/components/conversation/transcript-grouping.js.map +1 -1
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.d.ts +12 -0
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.d.ts.map +1 -1
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.js +53 -17
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.js.map +1 -1
- package/dist/components/layout/contextual-sidebar/index.d.ts +1 -1
- package/dist/components/layout/contextual-sidebar/index.d.ts.map +1 -1
- package/dist/components/layout/contextual-sidebar/mobile-contextual-sidebar.js +1 -1
- package/dist/components/layout/contextual-sidebar/mobile-contextual-sidebar.js.map +1 -1
- package/dist/components/layout/floating-preview/index.js +2 -2
- package/dist/components/layout/floating-preview/model.d.ts +21 -55
- package/dist/components/layout/floating-preview/model.d.ts.map +1 -1
- package/dist/components/layout/floating-preview/model.js +33 -88
- package/dist/components/layout/floating-preview/model.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 +11 -5
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js.map +1 -1
- package/dist/components/layout/shell-top-bar/shell-top-bar.d.ts +18 -22
- package/dist/components/layout/shell-top-bar/shell-top-bar.d.ts.map +1 -1
- package/dist/components/layout/shell-top-bar/shell-top-bar.js +4 -2
- package/dist/components/layout/shell-top-bar/shell-top-bar.js.map +1 -1
- package/dist/components/layout/side-rail/side-rail-context.d.ts +0 -1
- package/dist/components/layout/side-rail/side-rail-context.d.ts.map +1 -1
- package/dist/components/layout/side-rail/side-rail-context.js +2 -8
- package/dist/components/layout/side-rail/side-rail-context.js.map +1 -1
- package/dist/components/layout/side-rail/side-rail.d.ts +0 -9
- package/dist/components/layout/side-rail/side-rail.d.ts.map +1 -1
- package/dist/components/layout/side-rail/side-rail.js +148 -128
- package/dist/components/layout/side-rail/side-rail.js.map +1 -1
- package/dist/components/layout/sidebar-nav/index.d.ts +2 -1
- package/dist/components/layout/sidebar-nav/index.d.ts.map +1 -1
- package/dist/components/layout/sidebar-nav/index.js +2 -1
- package/dist/components/layout/sidebar-nav/sidebar-nav-classes.d.ts +10 -0
- package/dist/components/layout/sidebar-nav/sidebar-nav-classes.d.ts.map +1 -0
- package/dist/components/layout/sidebar-nav/sidebar-nav-classes.js +18 -0
- package/dist/components/layout/sidebar-nav/sidebar-nav-classes.js.map +1 -0
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.d.ts +1 -1
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.d.ts.map +1 -1
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.js.map +1 -1
- package/dist/components/layout/sidebar-nav/sidebar-nav.d.ts +5 -9
- package/dist/components/layout/sidebar-nav/sidebar-nav.d.ts.map +1 -1
- package/dist/components/layout/sidebar-nav/sidebar-nav.js +5 -23
- package/dist/components/layout/sidebar-nav/sidebar-nav.js.map +1 -1
- package/dist/components/layout/split-layout/geometry.d.ts.map +1 -1
- package/dist/components/layout/split-layout/geometry.js +2 -2
- package/dist/components/layout/split-layout/geometry.js.map +1 -1
- package/dist/components/layout/split-layout/index.js +2 -2
- package/dist/components/layout/split-layout/model.d.ts.map +1 -1
- package/dist/components/layout/split-layout/model.js +4 -4
- package/dist/components/layout/split-layout/model.js.map +1 -1
- package/dist/components/layout/split-layout/resize-controller-core-retry.d.ts +5 -0
- package/dist/components/layout/split-layout/resize-controller-core-retry.d.ts.map +1 -1
- package/dist/components/layout/split-layout/resize-controller-core-retry.js +17 -10
- package/dist/components/layout/split-layout/resize-controller-core-retry.js.map +1 -1
- package/dist/components/layout/split-layout/resize-controller-core.d.ts +5 -0
- package/dist/components/layout/split-layout/resize-controller-core.d.ts.map +1 -1
- package/dist/components/layout/split-layout/resize-controller-core.js +17 -10
- package/dist/components/layout/split-layout/resize-controller-core.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 +54 -47
- package/dist/components/layout/split-layout/split-layout.js.map +1 -1
- package/dist/components/layout/split-layout/tree.d.ts +2 -0
- package/dist/components/layout/split-layout/tree.d.ts.map +1 -1
- package/dist/components/layout/split-layout/tree.js +5 -1
- package/dist/components/layout/split-layout/tree.js.map +1 -1
- package/dist/components/layout/top-bar/top-bar.d.ts +2 -9
- package/dist/components/layout/top-bar/top-bar.d.ts.map +1 -1
- package/dist/components/layout/top-bar/top-bar.js +4 -8
- package/dist/components/layout/top-bar/top-bar.js.map +1 -1
- package/dist/components/layout/top-bar/window-chrome.d.ts +13 -0
- package/dist/components/layout/top-bar/window-chrome.d.ts.map +1 -0
- package/dist/components/layout/top-bar/window-chrome.js +12 -0
- package/dist/components/layout/top-bar/window-chrome.js.map +1 -0
- package/dist/components/motion/presence.d.ts +1 -1
- package/dist/components/motion/presence.d.ts.map +1 -1
- package/dist/components/motion/presence.js +1 -4
- package/dist/components/motion/presence.js.map +1 -1
- package/dist/components/theme/appearance-panel.d.ts +3 -1
- package/dist/components/theme/appearance-panel.d.ts.map +1 -1
- package/dist/components/theme/appearance-panel.js +17 -9
- package/dist/components/theme/appearance-panel.js.map +1 -1
- package/dist/components/theme/index.d.ts +1 -1
- package/dist/components/theme/index.d.ts.map +1 -1
- package/dist/components/theme/index.js +5 -4
- package/dist/components/theme/lazy.d.ts +31 -5
- package/dist/components/theme/lazy.d.ts.map +1 -1
- package/dist/components/theme/lazy.js +39 -6
- package/dist/components/theme/lazy.js.map +1 -0
- package/dist/components/theme/script-projection.d.ts +17 -0
- package/dist/components/theme/script-projection.d.ts.map +1 -0
- package/dist/components/theme/script-projection.js +17 -0
- package/dist/components/theme/script-projection.js.map +1 -0
- package/dist/components/theme/script.js +3 -1
- package/dist/components/theme/theme-api.d.ts +14 -0
- package/dist/components/theme/theme-api.d.ts.map +1 -0
- package/dist/components/theme/theme-catalogue-source.d.ts.map +1 -1
- package/dist/components/theme/theme-catalogue-source.js +3 -2
- package/dist/components/theme/theme-catalogue-source.js.map +1 -1
- package/dist/components/theme/theme-document.d.ts +112 -10
- package/dist/components/theme/theme-document.d.ts.map +1 -1
- package/dist/components/theme/{theme-document-core.js → theme-document.js} +20 -10
- package/dist/components/theme/theme-document.js.map +1 -0
- package/dist/components/theme/theme-mode-toggle.d.ts +1 -1
- package/dist/components/theme/theme-mode-toggle.d.ts.map +1 -1
- package/dist/components/theme/theme-mode-toggle.js.map +1 -1
- package/dist/components/theme/theme-persistence.d.ts +6 -5
- package/dist/components/theme/theme-persistence.d.ts.map +1 -1
- package/dist/components/theme/theme-persistence.js +48 -80
- package/dist/components/theme/theme-persistence.js.map +1 -1
- package/dist/components/theme/theme-picker.d.ts +1 -1
- package/dist/components/theme/theme-picker.d.ts.map +1 -1
- package/dist/components/theme/theme-picker.js.map +1 -1
- package/dist/components/theme/theme-provider-value.d.ts +16 -16
- package/dist/components/theme/theme-provider-value.d.ts.map +1 -1
- package/dist/components/theme/theme-provider-value.js +33 -42
- package/dist/components/theme/theme-provider-value.js.map +1 -1
- package/dist/components/theme/theme-provider.d.ts +3 -9
- package/dist/components/theme/theme-provider.d.ts.map +1 -1
- package/dist/components/theme/theme-provider.js +8 -7
- package/dist/components/theme/theme-provider.js.map +1 -1
- package/dist/components/theme/theme-script.d.ts +24 -25
- package/dist/components/theme/theme-script.d.ts.map +1 -1
- package/dist/components/theme/theme-script.js +45 -39
- package/dist/components/theme/theme-script.js.map +1 -1
- package/dist/components/theme/theme-state.d.ts +241 -9
- package/dist/components/theme/theme-state.d.ts.map +1 -1
- package/dist/components/theme/{theme-state-core.js → theme-state.js} +10 -11
- package/dist/components/theme/theme-state.js.map +1 -0
- package/dist/components/theme/theme-toggle.d.ts +1 -1
- package/dist/components/theme/theme-toggle.d.ts.map +1 -1
- package/dist/components/theme/theme-toggle.js.map +1 -1
- package/dist/components/theme/token-projection-options.d.ts +3 -0
- package/dist/components/theme/token-projection-options.d.ts.map +1 -0
- package/dist/components/theme/token-projection-options.js +9 -0
- package/dist/components/theme/token-projection-options.js.map +1 -0
- package/dist/components/theme/token-projection.d.ts +22 -0
- package/dist/components/theme/token-projection.d.ts.map +1 -0
- package/dist/components/theme/token-projection.js +1 -0
- package/dist/components/ui/alert-dialog/alert-dialog.d.ts +7 -5
- package/dist/components/ui/alert-dialog/alert-dialog.d.ts.map +1 -1
- package/dist/components/ui/alert-dialog/alert-dialog.js +40 -36
- package/dist/components/ui/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/ui/attachment/attachment.d.ts.map +1 -1
- package/dist/components/ui/attachment/attachment.js +5 -16
- package/dist/components/ui/attachment/attachment.js.map +1 -1
- package/dist/components/ui/avatar/avatar.d.ts.map +1 -1
- package/dist/components/ui/avatar/avatar.js +5 -2
- package/dist/components/ui/avatar/avatar.js.map +1 -1
- package/dist/components/ui/board/board.d.ts +0 -3
- package/dist/components/ui/board/board.d.ts.map +1 -1
- package/dist/components/ui/board/board.js +3 -6
- package/dist/components/ui/board/board.js.map +1 -1
- package/dist/components/ui/button-group/button-group.d.ts +1 -1
- package/dist/components/ui/button-group/button-group.d.ts.map +1 -1
- package/dist/components/ui/button-group/button-group.js.map +1 -1
- package/dist/components/ui/chart/chart.d.ts +0 -3
- package/dist/components/ui/chart/chart.d.ts.map +1 -1
- package/dist/components/ui/chart/chart.js.map +1 -1
- package/dist/components/ui/code-block/code-block.d.ts +0 -2
- package/dist/components/ui/code-block/code-block.d.ts.map +1 -1
- package/dist/components/ui/code-block/code-block.js +8 -24
- package/dist/components/ui/code-block/code-block.js.map +1 -1
- package/dist/components/ui/command/command.d.ts.map +1 -1
- package/dist/components/ui/command/command.js +56 -48
- package/dist/components/ui/command/command.js.map +1 -1
- package/dist/components/ui/context-menu/context-menu.d.ts +8 -30
- package/dist/components/ui/context-menu/context-menu.d.ts.map +1 -1
- package/dist/components/ui/context-menu/context-menu.js +13 -121
- package/dist/components/ui/context-menu/context-menu.js.map +1 -1
- package/dist/components/ui/dialog/dialog-layer.d.ts +46 -0
- package/dist/components/ui/dialog/dialog-layer.d.ts.map +1 -0
- package/dist/components/ui/dialog/dialog-layer.js +169 -0
- package/dist/components/ui/dialog/dialog-layer.js.map +1 -0
- package/dist/components/ui/dialog/dialog.d.ts +20 -26
- package/dist/components/ui/dialog/dialog.d.ts.map +1 -1
- package/dist/components/ui/dialog/dialog.js +69 -187
- package/dist/components/ui/dialog/dialog.js.map +1 -1
- package/dist/components/ui/drawer/drawer.d.ts.map +1 -1
- package/dist/components/ui/drawer/drawer.js +5 -8
- package/dist/components/ui/drawer/drawer.js.map +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu.d.ts +39 -53
- package/dist/components/ui/dropdown-menu/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu.js +135 -191
- package/dist/components/ui/dropdown-menu/dropdown-menu.js.map +1 -1
- package/dist/components/ui/dropdown-menu/menu-parts.d.ts +46 -0
- package/dist/components/ui/dropdown-menu/menu-parts.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu/menu-parts.js +176 -0
- package/dist/components/ui/dropdown-menu/menu-parts.js.map +1 -0
- package/dist/components/ui/field/field.js.map +1 -1
- package/dist/components/ui/field/number-field.js.map +1 -1
- package/dist/components/ui/hover-card/hover-card.d.ts +1 -2
- package/dist/components/ui/hover-card/hover-card.d.ts.map +1 -1
- package/dist/components/ui/hover-card/hover-card.js +4 -21
- package/dist/components/ui/hover-card/hover-card.js.map +1 -1
- package/dist/components/ui/menubar/menubar.d.ts +19 -33
- package/dist/components/ui/menubar/menubar.d.ts.map +1 -1
- package/dist/components/ui/menubar/menubar.js +21 -116
- package/dist/components/ui/menubar/menubar.js.map +1 -1
- package/dist/components/ui/message/index.js +2 -1
- package/dist/components/ui/message/message.d.ts +0 -1
- package/dist/components/ui/message/message.d.ts.map +1 -1
- package/dist/components/ui/message/message.js.map +1 -1
- package/dist/components/ui/message/parse-message-text.d.ts +20 -2
- package/dist/components/ui/message/parse-message-text.d.ts.map +1 -1
- package/dist/components/ui/message/parse-message-text.js +94 -28
- package/dist/components/ui/message/parse-message-text.js.map +1 -1
- package/dist/components/ui/modal-dialog/modal-dialog.d.ts +5 -12
- package/dist/components/ui/modal-dialog/modal-dialog.d.ts.map +1 -1
- package/dist/components/ui/modal-dialog/modal-dialog.js +61 -77
- package/dist/components/ui/modal-dialog/modal-dialog.js.map +1 -1
- package/dist/components/ui/navigation-menu/navigation-menu.d.ts +0 -1
- package/dist/components/ui/navigation-menu/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/ui/popover/popover.d.ts +1 -3
- package/dist/components/ui/popover/popover.d.ts.map +1 -1
- package/dist/components/ui/popover/popover.js +1 -22
- package/dist/components/ui/popover/popover.js.map +1 -1
- package/dist/components/ui/resizable/resizable.d.ts.map +1 -1
- package/dist/components/ui/resizable/resizable.js +12 -6
- package/dist/components/ui/resizable/resizable.js.map +1 -1
- package/dist/components/ui/sheet/sheet.d.ts +4 -6
- package/dist/components/ui/sheet/sheet.d.ts.map +1 -1
- package/dist/components/ui/sheet/sheet.js +31 -32
- package/dist/components/ui/sheet/sheet.js.map +1 -1
- package/dist/components/ui/text-link/index.d.ts.map +1 -1
- package/dist/components/ui/toggle-group/toggle-group.d.ts +1 -1
- package/dist/components/ui/toggle-group/toggle-group.d.ts.map +1 -1
- package/dist/components/ui/toggle-group/toggle-group.js +2 -7
- package/dist/components/ui/toggle-group/toggle-group.js.map +1 -1
- package/dist/components/ui/tooltip/tooltip.d.ts +17 -1
- package/dist/components/ui/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/ui/tooltip/tooltip.js +40 -20
- package/dist/components/ui/tooltip/tooltip.js.map +1 -1
- package/dist/components/ui/trace/index.d.ts +1 -1
- package/dist/components/ui/trace/index.d.ts.map +1 -1
- package/dist/components/ui/trace/index.js +1 -1
- package/dist/components/ui/trace/trace.d.ts +44 -3
- package/dist/components/ui/trace/trace.d.ts.map +1 -1
- package/dist/components/ui/trace/trace.js +87 -15
- package/dist/components/ui/trace/trace.js.map +1 -1
- package/dist/index.js +34 -28
- package/dist/lib/accent-presets.d.ts +7 -4
- package/dist/lib/accent-presets.d.ts.map +1 -1
- package/dist/lib/accent-presets.js +10 -5
- package/dist/lib/accent-presets.js.map +1 -1
- package/dist/lib/accent-roles.d.ts +20 -1
- package/dist/lib/accent-roles.d.ts.map +1 -1
- package/dist/lib/accent-roles.js +34 -26
- package/dist/lib/accent-roles.js.map +1 -1
- package/dist/lib/appearance-font-settings.d.ts.map +1 -1
- package/dist/lib/appearance-font-settings.js +4 -4
- package/dist/lib/appearance-font-settings.js.map +1 -1
- package/dist/lib/async-action.d.ts +42 -0
- package/dist/lib/async-action.d.ts.map +1 -0
- package/dist/lib/async-action.js +61 -0
- package/dist/lib/async-action.js.map +1 -0
- package/dist/lib/breakpoints.d.ts +8 -0
- package/dist/lib/breakpoints.d.ts.map +1 -0
- package/dist/lib/breakpoints.js +11 -0
- package/dist/lib/breakpoints.js.map +1 -0
- package/dist/lib/bytes.d.ts +8 -0
- package/dist/lib/bytes.d.ts.map +1 -0
- package/dist/lib/bytes.js +20 -0
- package/dist/lib/bytes.js.map +1 -0
- package/dist/lib/clipboard.d.ts +13 -0
- package/dist/lib/clipboard.d.ts.map +1 -1
- package/dist/lib/clipboard.js +32 -1
- package/dist/lib/clipboard.js.map +1 -1
- package/dist/lib/events.d.ts +14 -0
- package/dist/lib/events.d.ts.map +1 -0
- package/dist/lib/events.js +16 -0
- package/dist/lib/events.js.map +1 -0
- package/dist/lib/external-link.d.ts +19 -0
- package/dist/lib/external-link.d.ts.map +1 -0
- package/dist/lib/external-link.js +27 -0
- package/dist/lib/external-link.js.map +1 -0
- package/dist/lib/font-catalog.d.ts +3 -6
- package/dist/lib/font-catalog.d.ts.map +1 -1
- package/dist/lib/font-catalog.js +16 -12
- package/dist/lib/font-catalog.js.map +1 -1
- package/dist/lib/font-zoom.d.ts +4 -4
- package/dist/lib/font-zoom.d.ts.map +1 -1
- package/dist/lib/font-zoom.js +9 -12
- package/dist/lib/font-zoom.js.map +1 -1
- package/dist/lib/overlay.d.ts +29 -1
- package/dist/lib/overlay.d.ts.map +1 -1
- package/dist/lib/overlay.js +32 -16
- package/dist/lib/overlay.js.map +1 -1
- package/dist/lib/preference-store.d.ts +13 -3
- package/dist/lib/preference-store.d.ts.map +1 -1
- package/dist/lib/preference-store.js +27 -37
- package/dist/lib/preference-store.js.map +1 -1
- package/dist/lib/resize-separator.d.ts +15 -0
- package/dist/lib/resize-separator.d.ts.map +1 -0
- package/dist/lib/resize-separator.js +23 -0
- package/dist/lib/resize-separator.js.map +1 -0
- package/dist/lib/safe-script.d.ts +19 -1
- package/dist/lib/safe-script.d.ts.map +1 -1
- package/dist/lib/safe-script.js +19 -1
- package/dist/lib/safe-script.js.map +1 -1
- package/dist/lib/scroll-geometry.d.ts +33 -0
- package/dist/lib/scroll-geometry.d.ts.map +1 -0
- package/dist/lib/scroll-geometry.js +48 -0
- package/dist/lib/scroll-geometry.js.map +1 -0
- package/dist/lib/text.d.ts +13 -0
- package/dist/lib/text.d.ts.map +1 -0
- package/dist/lib/text.js +30 -0
- package/dist/lib/text.js.map +1 -0
- package/dist/lib/theme-accents.d.ts +2 -0
- package/dist/lib/theme-accents.d.ts.map +1 -1
- package/dist/lib/theme-accents.js +2 -2
- package/dist/lib/theme-accents.js.map +1 -1
- package/dist/lib/theme-catalogue.d.ts.map +1 -1
- package/dist/lib/theme-catalogue.js +3 -4
- package/dist/lib/theme-catalogue.js.map +1 -1
- package/dist/lib/theme-css.d.ts +14 -1
- package/dist/lib/theme-css.d.ts.map +1 -1
- package/dist/lib/theme-css.js +25 -48
- package/dist/lib/theme-css.js.map +1 -1
- package/dist/lib/theme-defaults.d.ts +33 -5
- package/dist/lib/theme-defaults.d.ts.map +1 -1
- package/dist/lib/theme-defaults.generated.d.ts +1 -1
- package/dist/lib/theme-defaults.generated.d.ts.map +1 -1
- package/dist/lib/theme-defaults.generated.js.map +1 -1
- package/dist/lib/theme-defaults.js +59 -3
- package/dist/lib/theme-defaults.js.map +1 -1
- package/dist/lib/theme-engine-light.d.ts +6 -0
- package/dist/lib/theme-engine-light.d.ts.map +1 -1
- package/dist/lib/theme-engine-light.js +71 -57
- package/dist/lib/theme-engine-light.js.map +1 -1
- package/dist/lib/theme-engine.d.ts +20 -22
- package/dist/lib/theme-engine.d.ts.map +1 -1
- package/dist/lib/theme-engine.js +19 -6
- package/dist/lib/theme-engine.js.map +1 -1
- package/dist/lib/theme-records.d.ts +3 -3
- package/dist/lib/theme-records.d.ts.map +1 -1
- package/dist/lib/theme-records.js +20 -59
- package/dist/lib/theme-records.js.map +1 -1
- package/dist/lib/theme-types.d.ts +174 -0
- package/dist/lib/theme-types.d.ts.map +1 -0
- package/dist/lib/theme-types.js +105 -0
- package/dist/lib/theme-types.js.map +1 -0
- package/dist/lib/themes.d.ts +4 -159
- package/dist/lib/themes.d.ts.map +1 -1
- package/dist/lib/themes.js +14 -33
- package/dist/lib/themes.js.map +1 -1
- package/dist/lib/tokens.d.ts.map +1 -1
- package/dist/lib/tokens.js +0 -1
- package/dist/lib/tokens.js.map +1 -1
- package/dist/lib/url.d.ts +9 -0
- package/dist/lib/url.d.ts.map +1 -0
- package/dist/lib/url.js +24 -0
- package/dist/lib/url.js.map +1 -0
- package/dist/lib/version-notes.d.ts.map +1 -1
- package/dist/lib/version-notes.js +3 -10
- package/dist/lib/version-notes.js.map +1 -1
- package/dist/r/about-dialog.json +2 -1
- package/dist/r/action-button.json +2 -1
- package/dist/r/alert-dialog.json +1 -0
- package/dist/r/appearance-editor.json +1 -1
- package/dist/r/checkpoint.json +0 -2
- package/dist/r/code-block.json +1 -0
- package/dist/r/confirmation.json +0 -1
- package/dist/r/context-menu.json +2 -2
- package/dist/r/context.json +0 -1
- package/dist/r/conversation.json +6 -5
- package/dist/r/dialog.json +5 -0
- package/dist/r/drawer.json +0 -1
- package/dist/r/dropdown-menu.json +5 -0
- package/dist/r/lib.json +51 -1
- package/dist/r/menubar.json +2 -2
- package/dist/r/model-selector.json +0 -1
- package/dist/r/reasoning.json +2 -1
- package/dist/r/registry.json +120 -46
- package/dist/r/shell-top-bar.json +1 -0
- package/dist/r/sidebar-nav.json +5 -0
- package/dist/r/sources.json +2 -2
- package/dist/r/src/components/composites/about-dialog/about-dialog.tsx +22 -42
- package/dist/r/src/components/composites/account-menu/account-menu.tsx +9 -35
- package/dist/r/src/components/composites/action-button/action-button.tsx +5 -7
- package/dist/r/src/components/composites/appearance-editor/accent-swatch-groups.tsx +3 -11
- package/dist/r/src/components/composites/appearance-editor/appearance-choices.tsx +8 -5
- package/dist/r/src/components/composites/appearance-editor/appearance-editor.tsx +8 -6
- package/dist/r/src/components/composites/appearance-editor/appearance-rows.tsx +30 -82
- package/dist/r/src/components/composites/appearance-editor/font-settings-group.tsx +11 -77
- package/dist/r/src/components/composites/appearance-editor/index.ts +1 -0
- package/dist/r/src/components/composites/catalog-browser/catalog-browser.tsx +9 -13
- package/dist/r/src/components/composites/chain-of-thought/chain-of-thought.tsx +16 -18
- package/dist/r/src/components/composites/chat/chat.tsx +2 -2
- package/dist/r/src/components/composites/checkpoint/checkpoint-model.ts +3 -3
- package/dist/r/src/components/composites/checkpoint/checkpoint.tsx +3 -3
- package/dist/r/src/components/composites/confirmation/confirmation-model.ts +9 -17
- package/dist/r/src/components/composites/confirmation/confirmation.tsx +2 -2
- package/dist/r/src/components/composites/context/context-model.ts +1 -1
- package/dist/r/src/components/composites/file-tree/build-file-tree.ts +21 -39
- package/dist/r/src/components/composites/file-tree/file-tree.tsx +5 -58
- package/dist/r/src/components/composites/file-tree/index.ts +1 -1
- package/dist/r/src/components/composites/help-center/help-center.tsx +8 -21
- package/dist/r/src/components/composites/icon-picker/icon-picker.tsx +10 -11
- package/dist/r/src/components/composites/inline-citation/citation.ts +2 -1
- package/dist/r/src/components/composites/inline-citation/inline-citation.tsx +3 -2
- package/dist/r/src/components/composites/message-scroller/message-scroller.tsx +30 -30
- package/dist/r/src/components/composites/message-scroller/scroll-anchor.ts +5 -5
- package/dist/r/src/components/composites/model-selector/model-selector.tsx +3 -2
- package/dist/r/src/components/composites/model-selector/models.ts +1 -1
- package/dist/r/src/components/composites/plan/plan.tsx +1 -4
- package/dist/r/src/components/composites/queue/queue.tsx +8 -11
- package/dist/r/src/components/composites/reasoning/reasoning.tsx +5 -23
- package/dist/r/src/components/composites/settings/settings-layout.tsx +3 -2
- package/dist/r/src/components/composites/settings/settings-navigation.tsx +4 -1
- package/dist/r/src/components/composites/sources/source.ts +7 -53
- package/dist/r/src/components/composites/stack-trace/stack-trace.tsx +3 -12
- package/dist/r/src/components/composites/subagent/subagent.tsx +7 -17
- package/dist/r/src/components/composites/suggestion/suggestion.tsx +4 -3
- package/dist/r/src/components/composites/task/task.tsx +21 -64
- package/dist/r/src/components/composites/terminal/terminal-model.ts +4 -4
- package/dist/r/src/components/composites/terminal/terminal.tsx +3 -12
- package/dist/r/src/components/composites/test-results/test-results.tsx +3 -12
- package/dist/r/src/components/composites/tool/tool.tsx +34 -40
- package/dist/r/src/components/composites/tree/tree-navigation.ts +22 -2
- package/dist/r/src/components/composites/tree/tree.tsx +47 -3
- package/dist/r/src/components/composites/update-dialog/channel-control.tsx +10 -14
- package/dist/r/src/components/composites/update-dialog/update-dialog.tsx +66 -200
- package/dist/r/src/components/composites/update-dialog/update-model.ts +137 -0
- package/dist/r/src/components/composites/workspace-mark/workspace-mark.tsx +1 -1
- package/dist/r/src/components/composites/workspace-switcher/workspace-reorder-dialog.tsx +1 -18
- package/dist/r/src/components/composites/workspace-switcher/workspace-switcher.tsx +16 -19
- package/dist/r/src/components/conversation/busy-send-button.tsx +7 -34
- package/dist/r/src/components/conversation/chat-composer.tsx +1 -1
- package/dist/r/src/components/conversation/composer-core.ts +76 -0
- package/dist/r/src/components/conversation/composer-menu.tsx +1 -1
- package/dist/r/src/components/conversation/conversation-pane.tsx +4 -1
- package/dist/r/src/components/conversation/conversation-surface.tsx +23 -10
- package/dist/r/src/components/conversation/ime-guard.ts +6 -0
- package/dist/r/src/components/conversation/internal/chat-composer-shell.tsx +24 -65
- package/dist/r/src/components/conversation/message-composer.tsx +24 -54
- package/dist/r/src/components/conversation/message-row.tsx +33 -47
- package/dist/r/src/components/conversation/paste-token-editor.tsx +13 -16
- package/dist/r/src/components/conversation/paste-tokens.ts +36 -1
- package/dist/r/src/components/conversation/scroll-follow-core.ts +66 -137
- package/dist/r/src/components/conversation/scroll-follow.ts +26 -67
- package/dist/r/src/components/conversation/thread-panel.tsx +2 -4
- package/dist/r/src/components/conversation/transcript-composition.tsx +9 -33
- package/dist/r/src/components/conversation/transcript-folding.ts +2 -2
- package/dist/r/src/components/conversation/transcript-grouping.ts +18 -3
- package/dist/r/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +80 -22
- package/dist/r/src/components/layout/contextual-sidebar/index.ts +1 -0
- package/dist/r/src/components/layout/contextual-sidebar/mobile-contextual-sidebar.tsx +1 -1
- package/dist/r/src/components/layout/floating-preview/model.ts +57 -195
- package/dist/r/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +6 -12
- package/dist/r/src/components/layout/shell-top-bar/shell-top-bar.tsx +47 -54
- package/dist/r/src/components/layout/side-rail/side-rail-context.ts +1 -11
- package/dist/r/src/components/layout/side-rail/side-rail.tsx +95 -107
- package/dist/r/src/components/layout/sidebar-nav/index.ts +1 -2
- package/dist/r/src/components/layout/sidebar-nav/sidebar-nav-classes.ts +15 -0
- package/dist/r/src/components/layout/sidebar-nav/sidebar-nav-resize-handle.tsx +1 -4
- package/dist/r/src/components/layout/sidebar-nav/sidebar-nav.tsx +9 -27
- package/dist/r/src/components/layout/split-layout/geometry.ts +2 -9
- package/dist/r/src/components/layout/split-layout/model.ts +3 -6
- package/dist/r/src/components/layout/split-layout/resize-controller-core-retry.tsx +12 -6
- package/dist/r/src/components/layout/split-layout/resize-controller-core.tsx +12 -6
- package/dist/r/src/components/layout/split-layout/split-layout.tsx +46 -61
- package/dist/r/src/components/layout/split-layout/tree.ts +5 -0
- package/dist/r/src/components/layout/top-bar/top-bar.tsx +16 -38
- package/dist/r/src/components/layout/top-bar/window-chrome.ts +23 -0
- package/dist/r/src/components/motion/presence.tsx +1 -3
- package/dist/r/src/components/theme/appearance-panel.tsx +28 -19
- package/dist/r/src/components/theme/index.ts +1 -22
- package/dist/r/src/components/theme/lazy.ts +36 -26
- package/dist/r/src/components/theme/script-projection.ts +40 -0
- package/dist/r/src/components/theme/theme-api.ts +30 -0
- package/dist/r/src/components/theme/theme-catalogue-source.ts +3 -2
- package/dist/r/src/components/theme/theme-document.ts +248 -23
- package/dist/r/src/components/theme/theme-mode-toggle.tsx +1 -1
- package/dist/r/src/components/theme/theme-persistence.ts +74 -130
- package/dist/r/src/components/theme/theme-picker.tsx +2 -2
- package/dist/r/src/components/theme/theme-provider-value.ts +64 -69
- package/dist/r/src/components/theme/theme-provider.tsx +5 -24
- package/dist/r/src/components/theme/theme-script.ts +100 -47
- package/dist/r/src/components/theme/theme-state.ts +350 -10
- package/dist/r/src/components/theme/theme-toggle.tsx +1 -1
- package/dist/r/src/components/theme/token-projection-options.ts +14 -0
- package/dist/r/src/components/theme/token-projection.ts +37 -0
- package/dist/r/src/components/ui/alert-dialog/alert-dialog.tsx +43 -43
- package/dist/r/src/components/ui/attachment/attachment.tsx +4 -17
- package/dist/r/src/components/ui/avatar/avatar.tsx +3 -2
- package/dist/r/src/components/ui/board/board.tsx +4 -10
- package/dist/r/src/components/ui/button-group/button-group.tsx +1 -1
- package/dist/r/src/components/ui/chart/chart.tsx +0 -3
- package/dist/r/src/components/ui/code-block/code-block.tsx +7 -26
- package/dist/r/src/components/ui/command/command.tsx +43 -39
- package/dist/r/src/components/ui/context-menu/context-menu.tsx +18 -168
- package/dist/r/src/components/ui/dialog/dialog-layer.tsx +266 -0
- package/dist/r/src/components/ui/dialog/dialog.tsx +77 -271
- package/dist/r/src/components/ui/drawer/drawer.tsx +5 -23
- package/dist/r/src/components/ui/dropdown-menu/dropdown-menu.tsx +204 -226
- package/dist/r/src/components/ui/dropdown-menu/menu-parts.tsx +220 -0
- package/dist/r/src/components/ui/field/field.tsx +1 -1
- package/dist/r/src/components/ui/field/number-field.tsx +1 -1
- package/dist/r/src/components/ui/hover-card/hover-card.tsx +4 -11
- package/dist/r/src/components/ui/menubar/menubar.tsx +36 -169
- package/dist/r/src/components/ui/message/message.tsx +0 -1
- package/dist/r/src/components/ui/message/parse-message-text.ts +80 -32
- package/dist/r/src/components/ui/modal-dialog/modal-dialog.tsx +9 -39
- package/dist/r/src/components/ui/navigation-menu/navigation-menu.tsx +0 -1
- package/dist/r/src/components/ui/popover/popover.tsx +5 -11
- package/dist/r/src/components/ui/resizable/resizable.tsx +6 -16
- package/dist/r/src/components/ui/sheet/sheet.tsx +30 -42
- package/dist/r/src/components/ui/text-link/index.ts +0 -1
- package/dist/r/src/components/ui/toggle-group/toggle-group.tsx +3 -11
- package/dist/r/src/components/ui/tooltip/tooltip.tsx +47 -26
- package/dist/r/src/components/ui/trace/index.ts +7 -0
- package/dist/r/src/components/ui/trace/trace.tsx +100 -9
- package/dist/r/src/lib/accent-presets.ts +12 -8
- package/dist/r/src/lib/accent-roles.ts +43 -29
- package/dist/r/src/lib/appearance-font-settings.ts +5 -5
- package/dist/r/src/lib/async-action.ts +72 -0
- package/dist/r/src/lib/breakpoints.ts +7 -0
- package/dist/r/src/lib/bytes.ts +20 -0
- package/dist/r/src/lib/clipboard.ts +43 -0
- package/dist/r/src/lib/events.ts +17 -0
- package/dist/r/src/lib/external-link.ts +42 -0
- package/dist/r/src/lib/font-catalog.ts +4 -6
- package/dist/r/src/lib/font-zoom.ts +9 -14
- package/dist/r/src/lib/overlay.ts +55 -18
- package/dist/r/src/lib/preference-store.ts +36 -34
- package/dist/r/src/lib/resize-separator.ts +36 -0
- package/dist/r/src/lib/safe-script.ts +19 -1
- package/dist/r/src/lib/scroll-geometry.ts +69 -0
- package/dist/r/src/lib/text.ts +49 -0
- package/dist/r/src/lib/theme-accents.ts +1 -1
- package/dist/r/src/lib/theme-catalogue.ts +3 -4
- package/dist/r/src/lib/theme-css.ts +33 -54
- package/dist/r/src/lib/theme-defaults.generated.ts +1 -1
- package/dist/r/src/lib/theme-defaults.ts +55 -7
- package/dist/r/src/lib/theme-engine-light.ts +88 -72
- package/dist/r/src/lib/theme-engine.ts +29 -33
- package/dist/r/src/lib/theme-records.ts +33 -69
- package/dist/r/src/lib/theme-types.ts +199 -0
- package/dist/r/src/lib/themes.ts +33 -196
- package/dist/r/src/lib/tokens.ts +0 -1
- package/dist/r/src/lib/url.ts +25 -0
- package/dist/r/src/lib/version-notes.ts +3 -9
- package/dist/r/src/styles/theme-variants.css +32 -32
- package/dist/r/src/styles/theme.css +17 -13
- package/dist/r/subagent.json +0 -2
- package/dist/r/suggestion.json +0 -1
- package/dist/r/theming.json +21 -21
- package/dist/r/top-bar.json +5 -0
- package/dist/r/trace.json +1 -0
- package/dist/r/update-dialog.json +5 -0
- package/package.json +22 -8
- package/registry.json +120 -46
- package/src/components/composites/about-dialog/about-dialog.tsx +22 -42
- package/src/components/composites/account-menu/account-menu.tsx +9 -35
- package/src/components/composites/action-button/action-button.tsx +5 -7
- package/src/components/composites/appearance-editor/accent-swatch-groups.tsx +3 -11
- package/src/components/composites/appearance-editor/appearance-choices.tsx +8 -5
- package/src/components/composites/appearance-editor/appearance-editor.tsx +8 -6
- package/src/components/composites/appearance-editor/appearance-rows.tsx +30 -82
- package/src/components/composites/appearance-editor/font-settings-group.tsx +11 -77
- package/src/components/composites/appearance-editor/index.ts +1 -0
- package/src/components/composites/catalog-browser/catalog-browser.tsx +9 -13
- package/src/components/composites/chain-of-thought/chain-of-thought.tsx +16 -18
- package/src/components/composites/chat/chat.tsx +2 -2
- package/src/components/composites/checkpoint/checkpoint-model.ts +3 -3
- package/src/components/composites/checkpoint/checkpoint.tsx +3 -3
- package/src/components/composites/confirmation/confirmation-model.ts +9 -17
- package/src/components/composites/confirmation/confirmation.tsx +2 -2
- package/src/components/composites/context/context-model.ts +1 -1
- package/src/components/composites/file-tree/build-file-tree.ts +21 -39
- package/src/components/composites/file-tree/file-tree.tsx +5 -58
- package/src/components/composites/file-tree/index.ts +1 -1
- package/src/components/composites/help-center/help-center.tsx +8 -21
- package/src/components/composites/icon-picker/icon-picker.tsx +10 -11
- package/src/components/composites/inline-citation/citation.ts +2 -1
- package/src/components/composites/inline-citation/inline-citation.tsx +3 -2
- package/src/components/composites/message-scroller/message-scroller.tsx +30 -30
- package/src/components/composites/message-scroller/scroll-anchor.ts +5 -5
- package/src/components/composites/model-selector/model-selector.tsx +3 -2
- package/src/components/composites/model-selector/models.ts +1 -1
- package/src/components/composites/plan/plan.tsx +1 -4
- package/src/components/composites/queue/queue.tsx +8 -11
- package/src/components/composites/reasoning/reasoning.tsx +5 -23
- package/src/components/composites/settings/settings-layout.tsx +3 -2
- package/src/components/composites/settings/settings-navigation.tsx +4 -1
- package/src/components/composites/sources/source.ts +7 -53
- package/src/components/composites/stack-trace/stack-trace.tsx +3 -12
- package/src/components/composites/subagent/subagent.tsx +7 -17
- package/src/components/composites/suggestion/suggestion.tsx +4 -3
- package/src/components/composites/task/task.tsx +21 -64
- package/src/components/composites/terminal/terminal-model.ts +4 -4
- package/src/components/composites/terminal/terminal.tsx +3 -12
- package/src/components/composites/test-results/test-results.tsx +3 -12
- package/src/components/composites/tool/tool.tsx +34 -40
- package/src/components/composites/tree/tree-navigation.ts +22 -2
- package/src/components/composites/tree/tree.tsx +47 -3
- package/src/components/composites/update-dialog/channel-control.tsx +10 -14
- package/src/components/composites/update-dialog/update-dialog.tsx +66 -200
- package/src/components/composites/update-dialog/update-model.ts +137 -0
- package/src/components/composites/workspace-mark/workspace-mark.tsx +1 -1
- package/src/components/composites/workspace-switcher/workspace-reorder-dialog.tsx +1 -18
- package/src/components/composites/workspace-switcher/workspace-switcher.tsx +16 -19
- package/src/components/conversation/busy-send-button.tsx +7 -34
- package/src/components/conversation/chat-composer.tsx +1 -1
- package/src/components/conversation/composer-core.ts +76 -0
- package/src/components/conversation/composer-menu.tsx +1 -1
- package/src/components/conversation/conversation-pane.tsx +4 -1
- package/src/components/conversation/conversation-surface.tsx +23 -10
- package/src/components/conversation/ime-guard.ts +6 -0
- package/src/components/conversation/internal/chat-composer-shell.tsx +24 -65
- package/src/components/conversation/message-composer.tsx +24 -54
- package/src/components/conversation/message-row.tsx +33 -47
- package/src/components/conversation/paste-token-editor.tsx +13 -16
- package/src/components/conversation/paste-tokens.ts +36 -1
- package/src/components/conversation/scroll-follow-core.ts +66 -137
- package/src/components/conversation/scroll-follow.ts +26 -67
- package/src/components/conversation/thread-panel.tsx +2 -4
- package/src/components/conversation/transcript-composition.tsx +9 -33
- package/src/components/conversation/transcript-folding.ts +2 -2
- package/src/components/conversation/transcript-grouping.ts +18 -3
- package/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +80 -22
- package/src/components/layout/contextual-sidebar/index.ts +1 -0
- package/src/components/layout/contextual-sidebar/mobile-contextual-sidebar.tsx +1 -1
- package/src/components/layout/floating-preview/model.ts +57 -195
- package/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +6 -12
- package/src/components/layout/shell-top-bar/shell-top-bar.tsx +47 -54
- package/src/components/layout/side-rail/side-rail-context.ts +1 -11
- package/src/components/layout/side-rail/side-rail.tsx +95 -107
- package/src/components/layout/sidebar-nav/index.ts +1 -2
- package/src/components/layout/sidebar-nav/sidebar-nav-classes.ts +15 -0
- package/src/components/layout/sidebar-nav/sidebar-nav-resize-handle.tsx +1 -4
- package/src/components/layout/sidebar-nav/sidebar-nav.tsx +9 -27
- package/src/components/layout/split-layout/geometry.ts +2 -9
- package/src/components/layout/split-layout/model.ts +3 -6
- package/src/components/layout/split-layout/resize-controller-core-retry.tsx +12 -6
- package/src/components/layout/split-layout/resize-controller-core.tsx +12 -6
- package/src/components/layout/split-layout/split-layout.tsx +46 -61
- package/src/components/layout/split-layout/tree.ts +5 -0
- package/src/components/layout/top-bar/top-bar.tsx +16 -38
- package/src/components/layout/top-bar/window-chrome.ts +23 -0
- package/src/components/motion/presence.tsx +1 -3
- package/src/components/theme/appearance-panel.tsx +28 -19
- package/src/components/theme/index.ts +1 -22
- package/src/components/theme/lazy.ts +36 -26
- package/src/components/theme/script-projection.ts +40 -0
- package/src/components/theme/theme-api.ts +30 -0
- package/src/components/theme/theme-catalogue-source.ts +3 -2
- package/src/components/theme/theme-document.ts +248 -23
- package/src/components/theme/theme-mode-toggle.tsx +1 -1
- package/src/components/theme/theme-persistence.ts +74 -130
- package/src/components/theme/theme-picker.tsx +2 -2
- package/src/components/theme/theme-provider-value.ts +64 -69
- package/src/components/theme/theme-provider.tsx +5 -24
- package/src/components/theme/theme-script.ts +100 -47
- package/src/components/theme/theme-state.ts +350 -10
- package/src/components/theme/theme-toggle.tsx +1 -1
- package/src/components/theme/token-projection-options.ts +14 -0
- package/src/components/theme/token-projection.ts +37 -0
- package/src/components/ui/alert-dialog/alert-dialog.tsx +43 -43
- package/src/components/ui/attachment/attachment.tsx +4 -17
- package/src/components/ui/avatar/avatar.tsx +3 -2
- package/src/components/ui/board/board.tsx +4 -10
- package/src/components/ui/button-group/button-group.tsx +1 -1
- package/src/components/ui/chart/chart.tsx +0 -3
- package/src/components/ui/code-block/code-block.tsx +7 -26
- package/src/components/ui/command/command.tsx +43 -39
- package/src/components/ui/context-menu/context-menu.tsx +18 -168
- package/src/components/ui/dialog/dialog-layer.tsx +266 -0
- package/src/components/ui/dialog/dialog.tsx +77 -271
- package/src/components/ui/drawer/drawer.tsx +5 -23
- package/src/components/ui/dropdown-menu/dropdown-menu.tsx +204 -226
- package/src/components/ui/dropdown-menu/menu-parts.tsx +220 -0
- package/src/components/ui/field/field.tsx +1 -1
- package/src/components/ui/field/number-field.tsx +1 -1
- package/src/components/ui/hover-card/hover-card.tsx +4 -11
- package/src/components/ui/menubar/menubar.tsx +36 -169
- package/src/components/ui/message/message.tsx +0 -1
- package/src/components/ui/message/parse-message-text.ts +80 -32
- package/src/components/ui/modal-dialog/modal-dialog.tsx +9 -39
- package/src/components/ui/navigation-menu/navigation-menu.tsx +0 -1
- package/src/components/ui/popover/popover.tsx +5 -11
- package/src/components/ui/resizable/resizable.tsx +6 -16
- package/src/components/ui/sheet/sheet.tsx +30 -42
- package/src/components/ui/text-link/index.ts +0 -1
- package/src/components/ui/toggle-group/toggle-group.tsx +3 -11
- package/src/components/ui/tooltip/tooltip.tsx +47 -26
- package/src/components/ui/trace/index.ts +7 -0
- package/src/components/ui/trace/trace.tsx +100 -9
- package/src/lib/accent-presets.ts +12 -8
- package/src/lib/accent-roles.ts +43 -29
- package/src/lib/appearance-font-settings.ts +5 -5
- package/src/lib/async-action.ts +72 -0
- package/src/lib/breakpoints.ts +7 -0
- package/src/lib/bytes.ts +20 -0
- package/src/lib/clipboard.ts +43 -0
- package/src/lib/events.ts +17 -0
- package/src/lib/external-link.ts +42 -0
- package/src/lib/font-catalog.ts +4 -6
- package/src/lib/font-zoom.ts +9 -14
- package/src/lib/overlay.ts +55 -18
- package/src/lib/preference-store.ts +36 -34
- package/src/lib/resize-separator.ts +36 -0
- package/src/lib/safe-script.ts +19 -1
- package/src/lib/scroll-geometry.ts +69 -0
- package/src/lib/text.ts +49 -0
- package/src/lib/theme-accents.ts +1 -1
- package/src/lib/theme-catalogue.ts +3 -4
- package/src/lib/theme-css.ts +33 -54
- package/src/lib/theme-defaults.generated.ts +1 -1
- package/src/lib/theme-defaults.ts +55 -7
- package/src/lib/theme-engine-light.ts +88 -72
- package/src/lib/theme-engine.ts +29 -33
- package/src/lib/theme-records.ts +33 -69
- package/src/lib/theme-types.ts +199 -0
- package/src/lib/themes.ts +33 -196
- package/src/lib/tokens.ts +0 -1
- package/src/lib/url.ts +25 -0
- package/src/lib/version-notes.ts +3 -9
- package/src/styles/theme-variants.css +32 -32
- package/src/styles/theme.css +17 -13
- package/dist/components/conversation/paste-preview.d.ts +0 -11
- package/dist/components/conversation/paste-preview.d.ts.map +0 -1
- package/dist/components/conversation/paste-preview.js +0 -27
- package/dist/components/conversation/paste-preview.js.map +0 -1
- package/dist/components/theme/theme-document-core.d.ts +0 -123
- package/dist/components/theme/theme-document-core.d.ts.map +0 -1
- package/dist/components/theme/theme-document-core.js.map +0 -1
- package/dist/components/theme/theme-provider-core.d.ts +0 -19
- package/dist/components/theme/theme-provider-core.d.ts.map +0 -1
- package/dist/components/theme/theme-provider-core.js +0 -27
- package/dist/components/theme/theme-provider-core.js.map +0 -1
- package/dist/components/theme/theme-provider-lazy.d.ts +0 -28
- package/dist/components/theme/theme-provider-lazy.d.ts.map +0 -1
- package/dist/components/theme/theme-provider-lazy.js +0 -35
- package/dist/components/theme/theme-provider-lazy.js.map +0 -1
- package/dist/components/theme/theme-state-core.d.ts +0 -248
- package/dist/components/theme/theme-state-core.d.ts.map +0 -1
- package/dist/components/theme/theme-state-core.js.map +0 -1
- package/dist/r/src/components/conversation/paste-preview.ts +0 -35
- package/dist/r/src/components/theme/theme-document-core.ts +0 -262
- package/dist/r/src/components/theme/theme-provider-core.tsx +0 -40
- package/dist/r/src/components/theme/theme-provider-lazy.tsx +0 -34
- package/dist/r/src/components/theme/theme-state-core.ts +0 -364
- package/src/components/conversation/paste-preview.ts +0 -35
- package/src/components/theme/theme-document-core.ts +0 -262
- package/src/components/theme/theme-provider-core.tsx +0 -40
- package/src/components/theme/theme-provider-lazy.tsx +0 -34
- package/src/components/theme/theme-state-core.ts +0 -364
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accent-roles.js","names":["parseCanonicalColor","canonicalContrastRatio"],"sources":["../../src/lib/accent-roles.ts"],"sourcesContent":["/*\n * Copyright (c) 2026 Wing\n * SPDX-License-Identifier: MIT\n *\n * The colour helpers, the contrast gate and the custom-accent grammar are\n * substantially translated from Zeron's `Color` and `AccentRoles`\n * (https://github.com/zeronsh/zeron), as Adea's accepted port of them in\n * `packages/ui/src/components/appearance.ts` expresses it. Extracted here so the\n * shared provider and Adea run one implementation; `@adea-ai/themes` owns the\n * colour engine (parsing, contrast, repair, the preset values and their roles).\n * See NOTICE.\n */\n\nimport {\n ACCENTS,\n accentRoles,\n accentValue,\n primarySubtleCss,\n type AccentPreset,\n type AccentRoles as CatalogueAccentRoles,\n} from '@adea-ai/themes'\nimport {\n contrastRatio as canonicalContrastRatio,\n oklchToHex,\n parseColor as parseCanonicalColor,\n repairContrast,\n type Oklch,\n} from '@adea-ai/themes/oklch'\nimport type { ThemeAppearance } from './themes'\n\n/**\n * Accent colour maths and the roles an accent paints.\n *\n * Three questions live here, and none of them touches the document or a signal:\n *\n * - **What colour is this?** `parseColor`, `colorToHex`, `contrastRatio` and\n * `ensureContrast` are the hex helpers a host needs around an accent (an\n * imported theme's colours, a colour field). Hex is the host preference format;\n * the catalogue's colour engine does the maths.\n * - **Is this accent readable on this surface?** The *contrast floor*. A preset is\n * curated, so the catalogue already measured it against its own themes and the\n * floor is the identity for it; a custom `#rrggbb` is anyone's choice, so it is\n * raised until it clears the floor and can never ship unreadable. A host that\n * imports themes (whose backgrounds the catalogue never saw) turns the floor on\n * for presets too.\n * - **Which custom properties does an accent own?** `AccentRoles`, written on\n * `<html>` by the provider and onto one element by {@link paintAccentRoles}.\n */\n\n/* Hex is the host preference format; the shared Themes package owns colour maths. */\n\nexport type RgbColor = Readonly<{ r: number; g: number; b: number; a: number }>\n\nconst HEX = /^#([0-9a-fA-F]+)$/\n\n/** Parse a hex colour (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`). `undefined` for anything else. */\nexport function parseColor(value: string): RgbColor | undefined {\n const match = HEX.exec(value.trim())\n const digits = match?.[1]\n if (!digits) return undefined\n if (digits.length === 3 || digits.length === 4) {\n // Each nibble is doubled: `#abc` is `#aabbcc`.\n const [r, g, b, a] = [...digits].map((digit) => Number.parseInt(digit + digit, 16))\n return { r: r!, g: g!, b: b!, a: a ?? 255 }\n }\n if (digits.length === 6 || digits.length === 8) {\n const byte = (index: number) => Number.parseInt(digits.slice(index, index + 2), 16)\n return { r: byte(0), g: byte(2), b: byte(4), a: digits.length === 8 ? byte(6) : 255 }\n }\n return undefined\n}\n\nfunction toHexByte(value: number): string {\n return value.toString(16).padStart(2, '0')\n}\n\n/** `#rrggbb`, or `#rrggbbaa` when the colour is not opaque. */\nexport function colorToHex(color: RgbColor): string {\n const opaque = `#${toHexByte(color.r)}${toHexByte(color.g)}${toHexByte(color.b)}`\n return color.a === 255 ? opaque : `${opaque}${toHexByte(color.a)}`\n}\n\nfunction blendOver(foreground: RgbColor, background: RgbColor): RgbColor {\n const alpha = foreground.a / 255\n const blend = (front: number, back: number) => Math.round(front * alpha + back * (1 - alpha))\n return {\n r: blend(foreground.r, background.r),\n g: blend(foreground.g, background.g),\n b: blend(foreground.b, background.b),\n a: 255,\n }\n}\n\nfunction toCanonicalColor(color: RgbColor): Oklch | undefined {\n return parseCanonicalColor(colorToHex({ ...color, a: 255 }))\n}\n\n/** WCAG contrast ratio between two colours. Alpha composites over the background first. */\nexport function contrastRatio(\n foreground: RgbColor | string,\n background: RgbColor | string\n): number {\n const front = typeof foreground === 'string' ? parseColor(foreground) : foreground\n const back = typeof background === 'string' ? parseColor(background) : background\n if (!front || !back) return 0\n const opaqueFront = front.a === 255 ? front : blendOver(front, back)\n const foregroundColor = toCanonicalColor(opaqueFront)\n const backgroundColor = toCanonicalColor(back)\n if (!foregroundColor || !backgroundColor) return 0\n return canonicalContrastRatio(foregroundColor, backgroundColor)\n}\n\nconst WHITE: RgbColor = { r: 255, g: 255, b: 255, a: 255 }\nconst WHITE_OKLCH: Oklch = { l: 1, c: 0, h: 0 }\n\n/**\n * The nearest colour to `source` that reaches `minimum` against `canvas`, as hex.\n *\n * The catalogue's `repairContrast` is asked for a little more than the floor, in\n * 0.001 steps up to 0.05, because the result is rounded to 8-bit hex and the\n * rounded colour is what is measured: asking for exactly the floor can land a hair\n * under it after rounding. If nothing in that range survives the rounding, white or\n * black stands in, whichever clears the floor.\n */\nfunction repairedHex(source: Oklch, canvas: Oklch, minimum: number): string {\n for (let margin = 0; margin <= 0.05; margin = Number((margin + 0.001).toFixed(3))) {\n const repaired = repairContrast(source, canvas, minimum + margin)\n if (!repaired.satisfied) continue\n const hex = oklchToHex(repaired.color)\n const rounded = parseCanonicalColor(hex)\n if (rounded && canonicalContrastRatio(rounded, canvas) >= minimum) return hex\n }\n return canonicalContrastRatio(WHITE_OKLCH, canvas) >= minimum ? '#ffffff' : '#000000'\n}\n\n/** Preserve the host hex shape while delegating contrast repair to the catalogue. */\nexport function ensureContrast(color: RgbColor, background: RgbColor, minimum: number): RgbColor {\n if (contrastRatio(color, background) >= minimum) return color\n\n const renderedColor = color.a === 255 ? color : blendOver(color, background)\n const source = toCanonicalColor(renderedColor)\n const canvas = toCanonicalColor(background)\n if (!source || !canvas) return color\n return parseColor(repairedHex(source, canvas, minimum))!\n}\n\n/** The contrast an accent is held to against its surface unless the host sets another. */\nexport const DEFAULT_ACCENT_CONTRAST_FLOOR = 3\n\n/**\n * Normalise a custom accent against a surface: unparseable input is rejected\n * (`undefined`), and any accepted colour is raised to `minimum` so an accent can\n * never ship unreadable. Accepts every CSS hex length; for the stored grammar use\n * {@link normalizeCustomAccent}.\n */\nexport function normalizeAccentValue(\n value: string,\n background: string,\n minimum: number = DEFAULT_ACCENT_CONTRAST_FLOOR\n): string | undefined {\n const parsed = parseColor(value)\n if (!parsed) return undefined\n const backdrop = parseColor(background) ?? WHITE\n return colorToHex(ensureContrast(parsed, backdrop, minimum))\n}\n\n/**\n * The stored form of a custom accent: `#rrggbb`, six digits, opaque, lower case.\n *\n * Deliberately narrower than {@link parseColor}. A stored accent is compared,\n * deduplicated and used as an attribute, so it has one spelling; a host that\n * accepts `#abc` in a field expands it before storing. Anything else — a name, an\n * `rgb()`, a short or alpha form, a non-string — is not an accent and returns\n * `undefined`.\n */\nexport function normalizeCustomAccent(value: unknown): string | undefined {\n return typeof value === 'string' && /^#[0-9a-fA-F]{6}$/.test(value)\n ? value.toLowerCase()\n : undefined\n}\n\n/** Whether a selection's accent is the custom `#rrggbb` form (any letter case). */\nexport function isCustomAccent(value: unknown): boolean {\n return normalizeCustomAccent(value) !== undefined\n}\n\n/**\n * The roles an accent paints, as CSS values: the catalogue's `AccentRoles`, so the\n * provider, the generated stylesheet and a host's own paint cannot disagree about\n * what a role is. `primarySubtle` is an expression over `var(--primary)`; the\n * document writer never sets it (see {@link accentOverrideVariables}), an element\n * paint must.\n */\nexport type AccentRoles = CatalogueAccentRoles\n\n/** What an accent resolves against: the surface it sits on and the theme it sits in. */\nexport type AccentTarget = {\n /** The theme, or only its appearance. A theme gives the tint its measured strength. */\n target: Parameters<typeof accentRoles>[1]\n /** The surface the accent must read on. Without it nothing can be measured or repaired. */\n background: string | undefined\n /**\n * The contrast to hold the accent to against `background`. Absent, a preset is\n * painted verbatim and a custom colour is held to {@link DEFAULT_ACCENT_CONTRAST_FLOOR}.\n */\n floor?: number\n /**\n * The accents the selected theme pair carries (`ansi-blue`…), for an id that is\n * neither a preset nor a colour.\n */\n themeAccents?: readonly AccentPreset[]\n}\n\nfunction appearanceOf(target: AccentTarget['target']): ThemeAppearance {\n return typeof target === 'string' ? target : target.appearance\n}\n\n/**\n * `value` raised to `floor` against `background` as hex, or `value` itself when it\n * already clears the floor, is not a colour, or there is no surface to measure it on.\n *\n * Returning the argument itself is what makes the floor the identity for a preset\n * that already reads: the caller compares and keeps the catalogue's own roles.\n */\nfunction gateColor(value: string, background: string | undefined, floor: number): string {\n const source = parseCanonicalColor(value)\n const canvas = background ? parseCanonicalColor(background) : undefined\n if (!source || !canvas) return value\n if (canonicalContrastRatio(source, canvas) >= floor) return value\n return repairedHex(source, canvas, floor)\n}\n\n/**\n * The roles for a preset (or a custom colour made into one), held to the floor.\n *\n * A preset that clears the floor keeps the catalogue's roles untouched. One that\n * does not is repaired to the nearest passing colour and the whole role set is\n * rebuilt from the repaired value, so the label, hover and ring follow it instead\n * of describing a colour that is no longer on screen.\n */\nexport function accentRolesForPreset(\n preset: AccentPreset,\n context: AccentTarget\n): AccentRoles | undefined {\n const appearance = appearanceOf(context.target)\n const requested = accentValue(preset, appearance)\n if (!parseCanonicalColor(requested)) return undefined\n\n const floor = context.floor\n if (floor === undefined) return accentRoles(preset, context.target)\n\n const gated = gateColor(requested, context.background, floor)\n if (gated === requested) return accentRoles(preset, context.target)\n\n const roles = accentRoles({ ...preset, light: gated, dark: gated }, context.target)\n // The tint's strength is measured against the primary it will sit over, and the\n // repaired primary is not one the theme's own measurement saw.\n return { ...roles, primarySubtle: primarySubtleCss(context.target, '--primary', [gated]) }\n}\n\n/**\n * Resolve an accent selection to its roles, or `undefined` when it overrides nothing.\n *\n * `undefined` is \"use the theme's own primary\": the literal `theme`, an id that is\n * neither a preset, an offered theme accent nor a colour, and a colour that does not\n * parse. A host that wants one of those to mean something else decides before\n * asking (Adea's codec maps a stored `theme` to its default preset when it reads).\n */\nexport function resolveAccentRoles(accent: string, context: AccentTarget): AccentRoles | undefined {\n if (accent === 'theme') return undefined\n\n const custom = normalizeCustomAccent(accent)\n if (custom) {\n const floor = context.floor ?? DEFAULT_ACCENT_CONTRAST_FLOOR\n return accentRolesForPreset(\n { id: 'custom', label: 'Custom', description: '', light: custom, dark: custom },\n { ...context, floor }\n )\n }\n\n const preset =\n ACCENTS.find((candidate) => candidate.id === accent) ??\n context.themeAccents?.find((candidate) => candidate.id === accent)\n return preset ? accentRolesForPreset(preset, context) : undefined\n}\n\n/**\n * The custom properties an accent override owns on `<html>`.\n *\n * `--primary-subtle` is deliberately not among them. It is a `color-mix()` over\n * `var(--primary)`, so on the same element it follows an accent by itself, and its\n * strength is the theme's, measured to keep body text at 4.5:1 on the tint.\n * Writing one here would replace that measurement with the argument's.\n */\nexport function accentOverrideVariables(roles: AccentRoles): Record<string, string> {\n return {\n '--primary': roles.primary,\n '--primary-foreground': roles.primaryForeground,\n '--primary-hover': roles.primaryHover,\n '--ring': roles.ring,\n }\n}\n\n/** The custom properties {@link paintAccentRoles} writes and clears. */\nexport const ACCENT_PAINT_PROPERTIES = [\n '--primary',\n '--primary-foreground',\n '--primary-hover',\n '--primary-subtle',\n '--ring',\n] as const\n\n/**\n * Scope an accent to one element and its descendants.\n *\n * Unlike the document, an element must write `--primary-subtle` too. A custom\n * property that uses `var()` is resolved where it is declared, so the tint inherited\n * from `<html>` is already a mix over *`<html>`'s* primary and an element that only\n * overrides `--primary` would keep the old tint. Declared here, the same expression\n * resolves against this element's primary.\n *\n * `undefined` clears every property, and the element inherits the document's accent\n * again.\n */\nexport function paintAccentRoles(\n element: { style: Pick<CSSStyleDeclaration, 'setProperty' | 'removeProperty'> },\n roles: AccentRoles | undefined\n): void {\n if (!roles) {\n for (const property of ACCENT_PAINT_PROPERTIES) element.style.removeProperty(property)\n return\n }\n element.style.setProperty('--primary', roles.primary)\n element.style.setProperty('--primary-foreground', roles.primaryForeground)\n element.style.setProperty('--primary-hover', roles.primaryHover)\n element.style.setProperty('--primary-subtle', roles.primarySubtle)\n element.style.setProperty('--ring', roles.ring)\n}\n"],"mappings":";;;AAqDA,IAAM,MAAM;;AAGZ,SAAgB,WAAW,OAAqC;CAE9D,MAAM,SADQ,IAAI,KAAK,MAAM,KAAK,CACnB,CAAA,GAAQ;CACvB,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,IAAI,OAAO,WAAW,KAAK,OAAO,WAAW,GAAG;EAE9C,MAAM,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,KAAK,UAAU,OAAO,SAAS,QAAQ,OAAO,EAAE,CAAC;EAClF,OAAO;GAAK;GAAO;GAAO;GAAI,GAAG,KAAK;EAAI;CAC5C;CACA,IAAI,OAAO,WAAW,KAAK,OAAO,WAAW,GAAG;EAC9C,MAAM,QAAQ,UAAkB,OAAO,SAAS,OAAO,MAAM,OAAO,QAAQ,CAAC,GAAG,EAAE;EAClF,OAAO;GAAE,GAAG,KAAK,CAAC;GAAG,GAAG,KAAK,CAAC;GAAG,GAAG,KAAK,CAAC;GAAG,GAAG,OAAO,WAAW,IAAI,KAAK,CAAC,IAAI;EAAI;CACtF;AAEF;AAEA,SAAS,UAAU,OAAuB;CACxC,OAAO,MAAM,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;AAC3C;;AAGA,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zB,UAAU,MAAM;CAClB;AACF;;AAGA,IAAa,0BAA0B;CACrC;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;AAcA,SAAgB,iBACd,SACA,OACM;CACN,IAAI,CAAC,OAAO;EACV,KAAK,MAAM,YAAY,yBAAyB,QAAQ,MAAM,eAAe,QAAQ;EACrF;CACF;CACA,QAAQ,MAAM,YAAY,aAAa,MAAM,OAAO;CACpD,QAAQ,MAAM,YAAY,wBAAwB,MAAM,iBAAiB;CACzE,QAAQ,MAAM,YAAY,mBAAmB,MAAM,YAAY;CAC/D,QAAQ,MAAM,YAAY,oBAAoB,MAAM,aAAa;CACjE,QAAQ,MAAM,YAAY,UAAU,MAAM,IAAI;AAChD"}
|
|
1
|
+
{"version":3,"file":"accent-roles.js","names":["parseCanonicalColor","canonicalContrastRatio","getAccent"],"sources":["../../src/lib/accent-roles.ts"],"sourcesContent":["/*\n * Copyright (c) 2026 Wing\n * SPDX-License-Identifier: MIT\n *\n * The colour helpers, the contrast gate and the custom-accent grammar are\n * substantially translated from Zeron's `Color` and `AccentRoles`\n * (https://github.com/zeronsh/zeron), as Adea's accepted port of them in\n * `packages/ui/src/components/appearance.ts` expresses it. Extracted here so the\n * shared provider and Adea run one implementation; `@adea-ai/themes` owns the\n * colour engine (parsing, contrast, repair, the preset values and their roles).\n * See NOTICE.\n */\n\nimport {\n accentRoles,\n accentValue,\n primarySubtleCss,\n type AccentPreset,\n type AccentRoles as CatalogueAccentRoles,\n} from '@adea-ai/themes'\nimport {\n contrastRatio as canonicalContrastRatio,\n oklchToHex,\n parseColor as parseCanonicalColor,\n repairContrast,\n type Oklch,\n} from '@adea-ai/themes/oklch'\nimport { getAccent } from './accent-presets'\nimport { isThemeAccentId } from './theme-accents'\nimport { THEME_DEFAULT_ID } from './theme-defaults'\nimport type { ThemeAppearance } from './theme-types'\n\n/**\n * Accent colour maths and the roles an accent paints.\n *\n * Three questions live here, and none of them touches the document or a signal:\n *\n * - **What colour is this?** `parseColor`, `colorToHex`, `contrastRatio` and\n * `ensureContrast` are the hex helpers a host needs around an accent (an\n * imported theme's colours, a colour field). Hex is the host preference format;\n * the catalogue's colour engine does the maths.\n * - **Is this accent readable on this surface?** The *contrast floor*. A preset is\n * curated, so the catalogue already measured it against its own themes and the\n * floor is the identity for it; a custom `#rrggbb` is anyone's choice, so it is\n * raised until it clears the floor and can never ship unreadable. A host that\n * imports themes (whose backgrounds the catalogue never saw) turns the floor on\n * for presets too.\n * - **Which custom properties does an accent own?** `AccentRoles`, written on\n * `<html>` by the provider and onto one element by {@link paintAccentRoles}.\n */\n\nexport type RgbColor = Readonly<{ r: number; g: number; b: number; a: number }>\n\nconst HEX = /^#([0-9a-fA-F]+)$/\n\n/** Parse a hex colour (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`). `undefined` for anything else. */\nexport function parseColor(value: string): RgbColor | undefined {\n const match = HEX.exec(value.trim())\n const digits = match?.[1]\n if (!digits) return undefined\n if (digits.length === 3 || digits.length === 4) {\n const [r, g, b, a] = [...digits].map((digit) => Number.parseInt(digit + digit, 16))\n return { r: r!, g: g!, b: b!, a: a ?? 255 }\n }\n if (digits.length === 6 || digits.length === 8) {\n const byte = (index: number) => Number.parseInt(digits.slice(index, index + 2), 16)\n return { r: byte(0), g: byte(2), b: byte(4), a: digits.length === 8 ? byte(6) : 255 }\n }\n return undefined\n}\n\nfunction toHexByte(value: number): string {\n return value.toString(16).padStart(2, '0')\n}\n\n/** `#rrggbb`, or `#rrggbbaa` when the colour is not opaque. */\nexport function colorToHex(color: RgbColor): string {\n const opaque = `#${toHexByte(color.r)}${toHexByte(color.g)}${toHexByte(color.b)}`\n return color.a === 255 ? opaque : `${opaque}${toHexByte(color.a)}`\n}\n\nfunction blendOver(foreground: RgbColor, background: RgbColor): RgbColor {\n const alpha = foreground.a / 255\n const blend = (front: number, back: number) => Math.round(front * alpha + back * (1 - alpha))\n return {\n r: blend(foreground.r, background.r),\n g: blend(foreground.g, background.g),\n b: blend(foreground.b, background.b),\n a: 255,\n }\n}\n\nfunction toCanonicalColor(color: RgbColor): Oklch | undefined {\n return parseCanonicalColor(colorToHex({ ...color, a: 255 }))\n}\n\n/** WCAG contrast ratio between two colours. Alpha composites over the background first. */\nexport function contrastRatio(\n foreground: RgbColor | string,\n background: RgbColor | string\n): number {\n const front = typeof foreground === 'string' ? parseColor(foreground) : foreground\n const back = typeof background === 'string' ? parseColor(background) : background\n if (!front || !back) return 0\n const opaqueFront = front.a === 255 ? front : blendOver(front, back)\n const foregroundColor = toCanonicalColor(opaqueFront)\n const backgroundColor = toCanonicalColor(back)\n if (!foregroundColor || !backgroundColor) return 0\n return canonicalContrastRatio(foregroundColor, backgroundColor)\n}\n\nconst WHITE: RgbColor = { r: 255, g: 255, b: 255, a: 255 }\nconst WHITE_OKLCH: Oklch = { l: 1, c: 0, h: 0 }\n\n/**\n * The nearest colour to `source` that reaches `minimum` against `canvas`, as hex.\n *\n * The catalogue's `repairContrast` is asked for a little more than the floor, in\n * 0.001 steps up to 0.05, because the result is rounded to 8-bit hex and the\n * rounded colour is what is measured: asking for exactly the floor can land a hair\n * under it after rounding. If nothing in that range survives the rounding, white or\n * black stands in, whichever clears the floor.\n */\nfunction repairedHex(source: Oklch, canvas: Oklch, minimum: number): string {\n for (let margin = 0; margin <= 0.05; margin = Number((margin + 0.001).toFixed(3))) {\n const repaired = repairContrast(source, canvas, minimum + margin)\n if (!repaired.satisfied) continue\n const hex = oklchToHex(repaired.color)\n const rounded = parseCanonicalColor(hex)\n if (rounded && canonicalContrastRatio(rounded, canvas) >= minimum) return hex\n }\n return canonicalContrastRatio(WHITE_OKLCH, canvas) >= minimum ? '#ffffff' : '#000000'\n}\n\n/** Preserve the host hex shape while delegating contrast repair to the catalogue. */\nexport function ensureContrast(color: RgbColor, background: RgbColor, minimum: number): RgbColor {\n if (contrastRatio(color, background) >= minimum) return color\n\n const renderedColor = color.a === 255 ? color : blendOver(color, background)\n const source = toCanonicalColor(renderedColor)\n const canvas = toCanonicalColor(background)\n if (!source || !canvas) return color\n return parseColor(repairedHex(source, canvas, minimum))!\n}\n\n/** The contrast an accent is held to against its surface unless the host sets another. */\nexport const DEFAULT_ACCENT_CONTRAST_FLOOR = 3\n\n/**\n * Normalise a custom accent against a surface: unparseable input is rejected\n * (`undefined`), and any accepted colour is raised to `minimum` so an accent can\n * never ship unreadable. Accepts every CSS hex length; for the stored grammar use\n * {@link normalizeCustomAccent}.\n */\nexport function normalizeAccentValue(\n value: string,\n background: string,\n minimum: number = DEFAULT_ACCENT_CONTRAST_FLOOR\n): string | undefined {\n const parsed = parseColor(value)\n if (!parsed) return undefined\n const backdrop = parseColor(background) ?? WHITE\n return colorToHex(ensureContrast(parsed, backdrop, minimum))\n}\n\n/**\n * The stored form of a custom accent: `#rrggbb`, six digits, opaque, lower case.\n *\n * Deliberately narrower than {@link parseColor}. A stored accent is compared,\n * deduplicated and used as an attribute, so it has one spelling; a host that\n * accepts `#abc` in a field expands it before storing. Anything else — a name, an\n * `rgb()`, a short or alpha form, a non-string — is not an accent and returns\n * `undefined`.\n */\nexport function normalizeCustomAccent(value: unknown): string | undefined {\n return typeof value === 'string' && CUSTOM_ACCENT_PATTERN.test(value)\n ? value.toLowerCase()\n : undefined\n}\n\n/** The stored grammar of a custom accent, for code that cannot call {@link normalizeCustomAccent}. */\nexport const CUSTOM_ACCENT_PATTERN = /^#[0-9a-fA-F]{6}$/\n\n/** Whether a selection's accent is the custom `#rrggbb` form (any letter case). */\nexport function isCustomAccent(value: unknown): boolean {\n return normalizeCustomAccent(value) !== undefined\n}\n\n/**\n * A stored accent selection in its one spelling, or `undefined` when it is none of\n * the four kinds: `theme`, a preset id, a theme-derived slot (`ansi-blue`, kept\n * whenever it names a slot, because the next pair may offer it), or a custom colour.\n * Readability is settled when an accent is painted, never when it is read.\n */\nexport function normalizeAccentSelection(value: unknown): string | undefined {\n if (typeof value !== 'string') return undefined\n if (value === THEME_DEFAULT_ID || getAccent(value) || isThemeAccentId(value)) return value\n return normalizeCustomAccent(value)\n}\n\n/**\n * The roles an accent paints, as CSS values: the catalogue's `AccentRoles`, so the\n * provider, the generated stylesheet and a host's own paint cannot disagree about\n * what a role is. `primarySubtle` is an expression over `var(--primary)`; the\n * document writer never sets it (see {@link accentOverrideVariables}), an element\n * paint must.\n */\nexport type AccentRoles = CatalogueAccentRoles\n\n/** What an accent resolves against: the surface it sits on and the theme it sits in. */\nexport type AccentTarget = {\n /** The theme, or only its appearance. A theme gives the tint its measured strength. */\n target: Parameters<typeof accentRoles>[1]\n /** The surface the accent must read on. Without it nothing can be measured or repaired. */\n background: string | undefined\n /**\n * The contrast to hold the accent to against `background`. Absent, a preset is\n * painted verbatim and a custom colour is held to {@link DEFAULT_ACCENT_CONTRAST_FLOOR}.\n */\n floor?: number\n /**\n * The accents the selected theme pair carries (`ansi-blue`…), for an id that is\n * neither a preset nor a colour.\n */\n themeAccents?: readonly AccentPreset[]\n}\n\nfunction appearanceOf(target: AccentTarget['target']): ThemeAppearance {\n return typeof target === 'string' ? target : target.appearance\n}\n\n/**\n * `value` raised to `floor` against `background` as hex, or `value` itself when it\n * already clears the floor, is not a colour, or there is no surface to measure it on.\n *\n * Returning the argument itself is what makes the floor the identity for a preset\n * that already reads: the caller compares and keeps the catalogue's own roles.\n */\nfunction gateColor(value: string, background: string | undefined, floor: number): string {\n const source = parseCanonicalColor(value)\n const canvas = background ? parseCanonicalColor(background) : undefined\n if (!source || !canvas) return value\n if (canonicalContrastRatio(source, canvas) >= floor) return value\n return repairedHex(source, canvas, floor)\n}\n\n/**\n * The roles for a preset (or a custom colour made into one), held to the floor.\n *\n * A preset that clears the floor keeps the catalogue's roles untouched. One that\n * does not is repaired to the nearest passing colour and the whole role set is\n * rebuilt from the repaired value, so the label, hover and ring follow it instead\n * of describing a colour that is no longer on screen.\n */\nexport function accentRolesForPreset(\n preset: AccentPreset,\n context: AccentTarget\n): AccentRoles | undefined {\n const appearance = appearanceOf(context.target)\n const requested = accentValue(preset, appearance)\n if (!parseCanonicalColor(requested)) return undefined\n\n const floor = context.floor\n if (floor === undefined) return accentRoles(preset, context.target)\n\n const gated = gateColor(requested, context.background, floor)\n if (gated === requested) return accentRoles(preset, context.target)\n\n const roles = accentRoles({ ...preset, light: gated, dark: gated }, context.target)\n // The tint's strength is measured against the primary it will sit over, and the\n // repaired primary is not one the theme's own measurement saw.\n return { ...roles, primarySubtle: primarySubtleCss(context.target, '--primary', [gated]) }\n}\n\n/**\n * Resolve an accent selection to its roles, or `undefined` when it overrides nothing.\n *\n * `undefined` is \"use the theme's own primary\": the literal `theme`, an id that is\n * neither a preset, an offered theme accent nor a colour, and a colour that does not\n * parse. A host that wants one of those to mean something else decides before\n * asking (Adea's codec maps a stored `theme` to its default preset when it reads).\n */\nexport function resolveAccentRoles(accent: string, context: AccentTarget): AccentRoles | undefined {\n if (accent === THEME_DEFAULT_ID) return undefined\n\n const custom = normalizeCustomAccent(accent)\n if (custom) {\n const floor = context.floor ?? DEFAULT_ACCENT_CONTRAST_FLOOR\n return accentRolesForPreset(\n { id: 'custom', label: 'Custom', description: '', light: custom, dark: custom },\n { ...context, floor }\n )\n }\n\n const preset =\n getAccent(accent) ?? context.themeAccents?.find((candidate) => candidate.id === accent)\n return preset ? accentRolesForPreset(preset, context) : undefined\n}\n\n/** The custom property each accent role paints, in the order they are written. */\nconst ACCENT_ROLE_PROPERTIES = {\n primary: '--primary',\n primaryForeground: '--primary-foreground',\n primaryHover: '--primary-hover',\n primarySubtle: '--primary-subtle',\n ring: '--ring',\n} as const satisfies Record<keyof AccentRoles, string>\n\ntype AccentPaintProperty = (typeof ACCENT_ROLE_PROPERTIES)[keyof AccentRoles]\n\n/**\n * The custom properties an accent override owns on `<html>`.\n *\n * `--primary-subtle` is deliberately not among them. It is a `color-mix()` over\n * `var(--primary)`, so on the same element it follows an accent by itself, and its\n * strength is the theme's, measured to keep body text at 4.5:1 on the tint.\n * Writing one here would replace that measurement with the argument's.\n */\nexport function accentOverrideVariables(roles: AccentRoles): Record<string, string> {\n const properties: Record<string, string> = {}\n for (const [role, property] of Object.entries(ACCENT_ROLE_PROPERTIES)) {\n if (role !== 'primarySubtle') properties[property] = roles[role as keyof AccentRoles]\n }\n return properties\n}\n\n/** The custom properties {@link paintAccentRoles} writes and clears. */\nexport const ACCENT_PAINT_PROPERTIES: readonly AccentPaintProperty[] = Object.freeze(\n Object.values(ACCENT_ROLE_PROPERTIES)\n)\n\n/**\n * Scope an accent to one element and its descendants.\n *\n * Unlike the document, an element must write `--primary-subtle` too. A custom\n * property that uses `var()` is resolved where it is declared, so the tint inherited\n * from `<html>` is already a mix over *`<html>`'s* primary and an element that only\n * overrides `--primary` would keep the old tint. Declared here, the same expression\n * resolves against this element's primary.\n *\n * `undefined` clears every property, and the element inherits the document's accent\n * again.\n */\nexport function paintAccentRoles(\n element: { style: Pick<CSSStyleDeclaration, 'setProperty' | 'removeProperty'> },\n roles: AccentRoles | undefined\n): void {\n for (const [role, property] of Object.entries(ACCENT_ROLE_PROPERTIES)) {\n if (roles) element.style.setProperty(property, roles[role as keyof AccentRoles])\n else element.style.removeProperty(property)\n }\n}\n"],"mappings":";;;;;;AAqDA,IAAM,MAAM;;AAGZ,SAAgB,WAAW,OAAqC;CAE9D,MAAM,SADQ,IAAI,KAAK,MAAM,KAAK,CACnB,CAAA,GAAQ;CACvB,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,IAAI,OAAO,WAAW,KAAK,OAAO,WAAW,GAAG;EAC9C,MAAM,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,KAAK,UAAU,OAAO,SAAS,QAAQ,OAAO,EAAE,CAAC;EAClF,OAAO;GAAK;GAAO;GAAO;GAAI,GAAG,KAAK;EAAI;CAC5C;CACA,IAAI,OAAO,WAAW,KAAK,OAAO,WAAW,GAAG;EAC9C,MAAM,QAAQ,UAAkB,OAAO,SAAS,OAAO,MAAM,OAAO,QAAQ,CAAC,GAAG,EAAE;EAClF,OAAO;GAAE,GAAG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V,MAAM,QAAQ,QAAQ,SAAA;EACtB,OAAO,qBACL;GAAE,IAAI;GAAU,OAAO;GAAU,aAAa;GAAI,OAAO;GAAQ,MAAM;EAAO,GAC9E;GAAE,GAAG;GAAS;EAAM,CACtB;CACF;CAEA,MAAM,SACJE,YAAU,MAAM,KAAK,QAAQ,cAAc,MAAM,cAAc,UAAU,OAAO,MAAM;CACxF,OAAO,SAAS,qBAAqB,QAAQ,OAAO,IAAI,KAAA;AAC1D;;AAGA,IAAM,yBAAyB;CAC7B,SAAS;CACT,mBAAmB;CACnB,cAAc;CACd,eAAe;CACf,MAAM;AACR;;;;;;;;;AAYA,SAAgB,wBAAwB,OAA4C;CAClF,MAAM,aAAqC,CAAC;CAC5C,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,sBAAsB,GAClE,IAAI,SAAS,iBAAiB,WAAW,YAAY,MAAM;CAE7D,OAAO;AACT;;AAGA,IAAa,0BAA0D,OAAO,OAC5E,OAAO,OAAO,sBAAsB,CACtC;;;;;;;;;;;;;AAcA,SAAgB,iBACd,SACA,OACM;CACN,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,sBAAsB,GAClE,IAAI,OAAO,QAAQ,MAAM,YAAY,UAAU,MAAM,KAA0B;MAC1E,QAAQ,MAAM,eAAe,QAAQ;AAE9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appearance-font-settings.d.ts","sourceRoot":"","sources":["../../src/lib/appearance-font-settings.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"appearance-font-settings.d.ts","sourceRoot":"","sources":["../../src/lib/appearance-font-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAGjF,eAAO,MAAM,2BAA2B,YAAI,IAAI,EAAE,SAAS,EAAE,MAAM,CAAU,CAAA;AAE7E,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,2B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og.js";
|
|
1
|
+
import { DEFAULT_FONT_ID, fontOptions } from "./font-catalog.js";
|
|
2
2
|
import { safeScriptStringLiteral } from "./safe-script.js";
|
|
3
3
|
// src/lib/appearance-font-settings.ts
|
|
4
4
|
var APPEARANCE_EDITOR_FONT_AXES = [
|
|
@@ -11,15 +11,15 @@ var APPEARANCE_EDITOR_FONT_SIZE_MAX = 32;
|
|
|
11
11
|
/** New preferences use the platform face in each text role. */
|
|
12
12
|
var DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS = Object.freeze({
|
|
13
13
|
ui: Object.freeze({
|
|
14
|
-
family:
|
|
14
|
+
family: DEFAULT_FONT_ID,
|
|
15
15
|
size: 14
|
|
16
16
|
}),
|
|
17
17
|
content: Object.freeze({
|
|
18
|
-
family:
|
|
18
|
+
family: DEFAULT_FONT_ID,
|
|
19
19
|
size: 14
|
|
20
20
|
}),
|
|
21
21
|
code: Object.freeze({
|
|
22
|
-
family:
|
|
22
|
+
family: DEFAULT_FONT_ID,
|
|
23
23
|
size: 12
|
|
24
24
|
})
|
|
25
25
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appearance-font-settings.js","names":[],"sources":["../../src/lib/appearance-font-settings.ts"],"sourcesContent":["import { fontOptions, type FontOption } from '#lib/font-catalog'\nimport { safeScriptStringLiteral } from '#lib/safe-script'\n\nexport const APPEARANCE_EDITOR_FONT_AXES = ['ui', 'content', 'code'] as const\n\nexport type AppearanceEditorFontAxis = (typeof APPEARANCE_EDITOR_FONT_AXES)[number]\nexport type AppearanceEditorFontFamilyId = FontOption['id']\n\nexport type AppearanceEditorFontSetting = Readonly<{\n /** A stable id from the shared font catalogue, never a CSS family string. */\n family: AppearanceEditorFontFamilyId\n /** A pixel size, normalized to the supported range. */\n size: number\n}>\n\n/** The host-owned choices edited by the shared appearance composition. */\nexport type AppearanceEditorFontSettings = Readonly<\n Record<AppearanceEditorFontAxis, AppearanceEditorFontSetting>\n>\n\nexport const APPEARANCE_EDITOR_FONT_SIZE_MIN = 10\nexport const APPEARANCE_EDITOR_FONT_SIZE_MAX = 32\n\n/** New preferences use the platform face in each text role. */\nexport const DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS: AppearanceEditorFontSettings = Object.freeze({\n ui: Object.freeze({ family: 'system', size: 14 }),\n content: Object.freeze({ family: 'system', size: 14 }),\n code: Object.freeze({ family: 'system', size: 12 }),\n})\n\nexport type NormalizedAppearanceEditorFontSettings = Readonly<{\n settings: AppearanceEditorFontSettings\n /** Axes whose persisted family or size was unavailable or outside its limits. */\n recoveredAxes: readonly AppearanceEditorFontAxis[]\n}>\n\nconst fontProjectionById = Object.freeze(\n Object.fromEntries(\n fontOptions.map((option) => [\n option.id,\n {\n familyVariables: option.familyVariables,\n uiTracking: option.uiTracking,\n uiWordSpacing: option.uiWordSpacing,\n },\n ])\n ) as Record<\n AppearanceEditorFontFamilyId,\n Pick<FontOption, 'familyVariables' | 'uiTracking' | 'uiWordSpacing'>\n >\n)\nconst fontAxisProjection = Object.freeze({\n ui: Object.freeze({\n familyAttribute: 'data-ui-font',\n familyProperty: '--font-ui',\n sizeProperty: '--font-ui-size',\n scaleProperty: '--font-ui-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.ui.size,\n }),\n content: Object.freeze({\n familyAttribute: 'data-content-font',\n familyProperty: '--font-content',\n sizeProperty: '--font-content-size',\n scaleProperty: '--font-content-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.content.size,\n }),\n code: Object.freeze({\n familyAttribute: 'data-code-font',\n familyProperty: '--font-code',\n sizeProperty: '--font-code-size',\n scaleProperty: '--font-code-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.code.size,\n }),\n})\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction hasOwn(value: Record<string, unknown>, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(value, key)\n}\n\nfunction normalizeFamily(value: unknown): AppearanceEditorFontFamilyId | undefined {\n return typeof value === 'string' && hasOwn(fontProjectionById, value)\n ? (value as AppearanceEditorFontFamilyId)\n : undefined\n}\n\nfunction clampFontSize(value: number): number {\n return Math.min(\n APPEARANCE_EDITOR_FONT_SIZE_MAX,\n Math.max(APPEARANCE_EDITOR_FONT_SIZE_MIN, Math.round(value))\n )\n}\n\n/** Normalize a single number-input value; invalid edits return the current size. */\nexport function normalizeAppearanceEditorFontSize(value: unknown, fallback: number): number {\n const parsed =\n typeof value === 'number'\n ? value\n : typeof value === 'string' && value.trim() !== ''\n ? Number(value)\n : Number.NaN\n return Number.isFinite(parsed) ? clampFontSize(parsed) : clampFontSize(fallback)\n}\n\n/**\n * Recover persisted font choices against the shared font catalogue.\n *\n * `legacyUiFamily` lets a host migrate its previous single font field into the\n * UI axis. Content and code remain on the new System defaults during that\n * migration. Missing settings are ordinary defaults; an unknown saved id or an\n * invalid size is reported through `recoveredAxes` for the host's notice.\n */\nexport function normalizeAppearanceEditorFontSettings(\n value: unknown,\n legacyUiFamily?: unknown\n): NormalizedAppearanceEditorFontSettings {\n const source = isRecord(value) ? value : undefined\n const malformedRoot = value !== undefined && value !== null && source === undefined\n const recovered = new Set<AppearanceEditorFontAxis>()\n const settings = {} as Record<AppearanceEditorFontAxis, AppearanceEditorFontSetting>\n\n for (const axis of APPEARANCE_EDITOR_FONT_AXES) {\n const axisPresent = source ? hasOwn(source, axis) : false\n const axisValue = source?.[axis]\n const axisSource = isRecord(axisValue) ? axisValue : undefined\n const fallback = DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS[axis]\n\n if (malformedRoot || (axisPresent && axisSource === undefined)) recovered.add(axis)\n\n const hasFamily = axisSource ? hasOwn(axisSource, 'family') : false\n const familyInput = hasFamily\n ? axisSource?.['family']\n : axis === 'ui' && legacyUiFamily !== undefined\n ? legacyUiFamily\n : undefined\n const family = normalizeFamily(familyInput) ?? fallback.family\n if (\n (hasFamily || (axis === 'ui' && legacyUiFamily !== undefined)) &&\n !normalizeFamily(familyInput)\n ) {\n recovered.add(axis)\n }\n\n const hasSize = axisSource ? hasOwn(axisSource, 'size') : false\n const sizeInput = axisSource?.['size']\n const size = hasSize\n ? normalizeAppearanceEditorFontSize(sizeInput, fallback.size)\n : fallback.size\n if (\n hasSize &&\n (typeof sizeInput !== 'number' || !Number.isFinite(sizeInput) || sizeInput !== size)\n ) {\n recovered.add(axis)\n }\n\n settings[axis] = Object.freeze({ family, size })\n }\n\n return Object.freeze({\n settings: Object.freeze(settings),\n recoveredAxes: Object.freeze(APPEARANCE_EDITOR_FONT_AXES.filter((axis) => recovered.has(axis))),\n })\n}\n\n/**\n * Project normalized font preferences onto a document root.\n *\n * This is shared by `ThemeProvider` and hosts that own their own appearance\n * persistence, so UI/content/code use the same catalogue ids, theme tokens,\n * sizes, and projected CSS variables. The marker activates the optional role\n * stylesheet and survives CSS import reordering.\n */\nexport function applyAppearanceFontSettings(\n root: Pick<HTMLElement, 'removeAttribute' | 'setAttribute' | 'style'>,\n value: unknown\n): NormalizedAppearanceEditorFontSettings {\n const normalized = normalizeAppearanceEditorFontSettings(value)\n const { settings } = normalized\n\n root.removeAttribute('data-font')\n root.setAttribute('data-font-settings', '')\n for (const axis of APPEARANCE_EDITOR_FONT_AXES) {\n const projection = fontAxisProjection[axis]\n const setting = settings[axis]\n const option = fontProjectionById[setting.family]\n if (setting.family === 'system') root.removeAttribute(projection.familyAttribute)\n else root.setAttribute(projection.familyAttribute, setting.family)\n root.style.setProperty(projection.familyProperty, `var(${option.familyVariables[axis]})`)\n root.style.setProperty(projection.sizeProperty, String(setting.size) + 'px')\n root.style.setProperty(projection.scaleProperty, String(setting.size / projection.defaultSize))\n if (axis === 'ui') {\n root.style.setProperty('--ui-tracking', option.uiTracking)\n root.style.setProperty('--ui-word-spacing', option.uiWordSpacing)\n }\n }\n\n return normalized\n}\n\n/**\n * Generate a safe inline prepaint script for a host-owned appearance record.\n *\n * The stored object is read from `localStorage[storageKey].fonts`. A legacy\n * top-level `font` family migrates into UI only; content/code use the shared\n * defaults. The script applies the same catalogue whitelist, limits, attributes,\n * and CSS properties as `applyAppearanceFontSettings` before styles paint. When\n * `persistedVersion` is supplied, only a record with that exact top-level version\n * is used; absent or mismatched records receive the System defaults.\n */\nexport function fontSettingsBootstrapScript(storageKey: string, persistedVersion?: number): string {\n if (persistedVersion !== undefined && !Number.isSafeInteger(persistedVersion)) {\n throw new RangeError('persistedVersion must be a safe integer')\n }\n const axisConfig = JSON.stringify(fontAxisProjection)\n const fontProjection = JSON.stringify(fontProjectionById)\n const fontIds = `[${fontOptions.map((option) => safeScriptStringLiteral(option.id)).join(',')}]`\n const persistedVersionGuard =\n persistedVersion === undefined\n ? ''\n : `&&parsed.version===Number(${safeScriptStringLiteral(String(persistedVersion))})`\n\n return `(function(){var r=document.documentElement;var axes=JSON.parse(${safeScriptStringLiteral(axisConfig)});var projection=JSON.parse(${safeScriptStringLiteral(fontProjection)});var ids=${fontIds};var has=function(v,k){return Object.prototype.hasOwnProperty.call(v,k)};var record=function(v){return typeof v==='object'&&v!==null&&!Array.isArray(v)};var p={};try{var raw=localStorage.getItem(${safeScriptStringLiteral(storageKey)});var parsed=raw?JSON.parse(raw):{};if(record(parsed)${persistedVersionGuard})p=parsed;}catch(e){}var saved=record(p.fonts)?p.fonts:{};var valid=function(v,d){return ids.indexOf(v)!==-1?v:d};var size=function(v,d){var n=typeof v==='number'?v:typeof v==='string'&&v.trim()!==''?Number(v):NaN;return Number.isFinite(n)?Math.min(${APPEARANCE_EDITOR_FONT_SIZE_MAX},Math.max(${APPEARANCE_EDITOR_FONT_SIZE_MIN},Math.round(n))):d};r.setAttribute('data-font-settings','');for(var axis in axes){if(!has(axes,axis))continue;var spec=axes[axis];var candidate=saved[axis];var value=record(candidate)?candidate:{};var legacyUi=axis==='ui'&&!has(value,'family');var family=legacyUi?valid(p.font,'system'):valid(value.family,'system');var font=projection[family];if(family==='system')r.removeAttribute(spec.familyAttribute);else r.setAttribute(spec.familyAttribute,family);r.style.setProperty(spec.familyProperty,'var('+font.familyVariables[axis]+')');var px=size(value.size,spec.defaultSize);r.style.setProperty(spec.sizeProperty,px+'px');r.style.setProperty(spec.scaleProperty,String(px/spec.defaultSize));if(axis==='ui'){r.style.setProperty('--ui-tracking',font.uiTracking);r.style.setProperty('--ui-word-spacing',font.uiWordSpacing);}}r.removeAttribute('data-font');})();`\n}\n"],"mappings":";;;AAGA,IAAa,8BAA8B;CAAC;CAAM;CAAW;AAAM;AAiBnE,IAAa,kCAAkC;AAC/C,IAAa,kCAAkC;;AAG/C,IAAa,0CAAwE,OAAO,OAAO;CACjG,IAAI,OAAO,OAAO;EAAE,QAAQ;EAAU,MAAM;CAAG,CAAC;CAChD,SAAS,OAAO,OAAO;EAAE,QAAQ;EAAU,MAAM;CAAG,CAAC;CACrD,MAAM,OAAO,OAAO;EAAE,QAAQ;EAAU,MAAM;CAAG,CAAC;AACpD,CAAC;AAQD,IAAM,qBAAqB,OAAO,OAChC,OAAO,YACL,YAAY,KAAK,WAAW,CAC1B,OAAO,IACP;CACE,iBAAiB,OAAO;CACxB,YAAY,OAAO;CACnB,eAAe,OAAO;AACxB,CACF,CAAC,CACH,CAIF;AACA,IAAM,qBAAqB,OAAO,OAAO;CACvC,IAAI,OAAO,OAAO;EAChB,iBAAiB;EACjB,gBAAgB;EAChB,cAAc;EACd,eAAe;EACf,aAAa,wCAAwC,GAAG;CAC1D,CAAC;CACD,SAAS,OAAO,OAAO;EACrB,iBAAiB;EACjB,gBAAgB;EAChB,cAAc;EACd,eAAe;EACf,aAAa,wCAAwC,QAAQ;CAC/D,CAAC;CACD,MAAM,OAAO,OAAO;EAClB,iBAAiB;EACjB,gBAAgB;EAChB,cAAc;EACd,eAAe;EACf,aAAa,wCAAwC,KAAK;CAC5D,CAAC;AACH,CAAC;AAED,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CA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;AAYA,SAAgB,4BAA4B,YAAoB,kBAAmC;CACjG,IAAI,qBAAqB,KAAA,KAAa,CAAC,OAAO,cAAc,gBAAgB,GAC1E,MAAM,IAAI,WAAW,yCAAyC;CAEhE,MAAM,aAAa,KAAK,UAAU,kBAAkB;CACpD,MAAM,iBAAiB,KAAK,UAAU,kBAAkB;CACxD,MAAM,UAAU,IAAI,YAAY,KAAK,WAAW,wBAAwB,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;CAC9F,MAAM,wBACJ,qBAAqB,KAAA,IACjB,KACA,6BAA6B,wBAAwB,OAAO,gBAAgB,CAAC,EAAE;CAErF,OAAO,kEAAkE,wBAAwB,UAAU,EAAE,8BAA8B,wBAAwB,cAAc,EAAE,YAAY,QAAQ,qMAAqM,wBAAwB,UAAU,EAAE,uDAAuD,sBAAsB;AAC/f"}
|
|
1
|
+
{"version":3,"file":"appearance-font-settings.js","names":[],"sources":["../../src/lib/appearance-font-settings.ts"],"sourcesContent":["import { DEFAULT_FONT_ID, fontOptions, type FontOption } from '#lib/font-catalog'\nimport { safeScriptStringLiteral } from '#lib/safe-script'\n\nexport const APPEARANCE_EDITOR_FONT_AXES = ['ui', 'content', 'code'] as const\n\nexport type AppearanceEditorFontAxis = (typeof APPEARANCE_EDITOR_FONT_AXES)[number]\nexport type AppearanceEditorFontFamilyId = FontOption['id']\n\nexport type AppearanceEditorFontSetting = Readonly<{\n /** A stable id from the shared font catalogue, never a CSS family string. */\n family: AppearanceEditorFontFamilyId\n /** A pixel size, normalized to the supported range. */\n size: number\n}>\n\n/** The host-owned choices edited by the shared appearance composition. */\nexport type AppearanceEditorFontSettings = Readonly<\n Record<AppearanceEditorFontAxis, AppearanceEditorFontSetting>\n>\n\nexport const APPEARANCE_EDITOR_FONT_SIZE_MIN = 10\nexport const APPEARANCE_EDITOR_FONT_SIZE_MAX = 32\n\n/** New preferences use the platform face in each text role. */\nexport const DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS: AppearanceEditorFontSettings = Object.freeze({\n ui: Object.freeze({ family: DEFAULT_FONT_ID, size: 14 }),\n content: Object.freeze({ family: DEFAULT_FONT_ID, size: 14 }),\n code: Object.freeze({ family: DEFAULT_FONT_ID, size: 12 }),\n})\n\nexport type NormalizedAppearanceEditorFontSettings = Readonly<{\n settings: AppearanceEditorFontSettings\n /** Axes whose persisted family or size was unavailable or outside its limits. */\n recoveredAxes: readonly AppearanceEditorFontAxis[]\n}>\n\nconst fontProjectionById = Object.freeze(\n Object.fromEntries(\n fontOptions.map((option) => [\n option.id,\n {\n familyVariables: option.familyVariables,\n uiTracking: option.uiTracking,\n uiWordSpacing: option.uiWordSpacing,\n },\n ])\n ) as Record<\n AppearanceEditorFontFamilyId,\n Pick<FontOption, 'familyVariables' | 'uiTracking' | 'uiWordSpacing'>\n >\n)\nconst fontAxisProjection = Object.freeze({\n ui: Object.freeze({\n familyAttribute: 'data-ui-font',\n familyProperty: '--font-ui',\n sizeProperty: '--font-ui-size',\n scaleProperty: '--font-ui-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.ui.size,\n }),\n content: Object.freeze({\n familyAttribute: 'data-content-font',\n familyProperty: '--font-content',\n sizeProperty: '--font-content-size',\n scaleProperty: '--font-content-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.content.size,\n }),\n code: Object.freeze({\n familyAttribute: 'data-code-font',\n familyProperty: '--font-code',\n sizeProperty: '--font-code-size',\n scaleProperty: '--font-code-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.code.size,\n }),\n})\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction hasOwn(value: Record<string, unknown>, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(value, key)\n}\n\nfunction normalizeFamily(value: unknown): AppearanceEditorFontFamilyId | undefined {\n return typeof value === 'string' && hasOwn(fontProjectionById, value)\n ? (value as AppearanceEditorFontFamilyId)\n : undefined\n}\n\nfunction clampFontSize(value: number): number {\n return Math.min(\n APPEARANCE_EDITOR_FONT_SIZE_MAX,\n Math.max(APPEARANCE_EDITOR_FONT_SIZE_MIN, Math.round(value))\n )\n}\n\n/** Normalize a single number-input value; invalid edits return the current size. */\nexport function normalizeAppearanceEditorFontSize(value: unknown, fallback: number): number {\n const parsed =\n typeof value === 'number'\n ? value\n : typeof value === 'string' && value.trim() !== ''\n ? Number(value)\n : Number.NaN\n return Number.isFinite(parsed) ? clampFontSize(parsed) : clampFontSize(fallback)\n}\n\n/**\n * Recover persisted font choices against the shared font catalogue.\n *\n * `legacyUiFamily` lets a host migrate its previous single font field into the\n * UI axis. Content and code remain on the new System defaults during that\n * migration. Missing settings are ordinary defaults; an unknown saved id or an\n * invalid size is reported through `recoveredAxes` for the host's notice.\n */\nexport function normalizeAppearanceEditorFontSettings(\n value: unknown,\n legacyUiFamily?: unknown\n): NormalizedAppearanceEditorFontSettings {\n const source = isRecord(value) ? value : undefined\n const malformedRoot = value !== undefined && value !== null && source === undefined\n const recovered = new Set<AppearanceEditorFontAxis>()\n const settings = {} as Record<AppearanceEditorFontAxis, AppearanceEditorFontSetting>\n\n for (const axis of APPEARANCE_EDITOR_FONT_AXES) {\n const axisPresent = source ? hasOwn(source, axis) : false\n const axisValue = source?.[axis]\n const axisSource = isRecord(axisValue) ? axisValue : undefined\n const fallback = DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS[axis]\n\n if (malformedRoot || (axisPresent && axisSource === undefined)) recovered.add(axis)\n\n const hasFamily = axisSource ? hasOwn(axisSource, 'family') : false\n const familyInput = hasFamily\n ? axisSource?.['family']\n : axis === 'ui' && legacyUiFamily !== undefined\n ? legacyUiFamily\n : undefined\n const family = normalizeFamily(familyInput) ?? fallback.family\n if (\n (hasFamily || (axis === 'ui' && legacyUiFamily !== undefined)) &&\n !normalizeFamily(familyInput)\n ) {\n recovered.add(axis)\n }\n\n const hasSize = axisSource ? hasOwn(axisSource, 'size') : false\n const sizeInput = axisSource?.['size']\n const size = hasSize\n ? normalizeAppearanceEditorFontSize(sizeInput, fallback.size)\n : fallback.size\n if (\n hasSize &&\n (typeof sizeInput !== 'number' || !Number.isFinite(sizeInput) || sizeInput !== size)\n ) {\n recovered.add(axis)\n }\n\n settings[axis] = Object.freeze({ family, size })\n }\n\n return Object.freeze({\n settings: Object.freeze(settings),\n recoveredAxes: Object.freeze(APPEARANCE_EDITOR_FONT_AXES.filter((axis) => recovered.has(axis))),\n })\n}\n\n/**\n * Project normalized font preferences onto a document root.\n *\n * This is shared by `ThemeProvider` and hosts that own their own appearance\n * persistence, so UI/content/code use the same catalogue ids, theme tokens,\n * sizes, and projected CSS variables. The marker activates the optional role\n * stylesheet and survives CSS import reordering.\n */\nexport function applyAppearanceFontSettings(\n root: Pick<HTMLElement, 'removeAttribute' | 'setAttribute' | 'style'>,\n value: unknown\n): NormalizedAppearanceEditorFontSettings {\n const normalized = normalizeAppearanceEditorFontSettings(value)\n const { settings } = normalized\n\n root.removeAttribute('data-font')\n root.setAttribute('data-font-settings', '')\n for (const axis of APPEARANCE_EDITOR_FONT_AXES) {\n const projection = fontAxisProjection[axis]\n const setting = settings[axis]\n const option = fontProjectionById[setting.family]\n if (setting.family === DEFAULT_FONT_ID) root.removeAttribute(projection.familyAttribute)\n else root.setAttribute(projection.familyAttribute, setting.family)\n root.style.setProperty(projection.familyProperty, `var(${option.familyVariables[axis]})`)\n root.style.setProperty(projection.sizeProperty, String(setting.size) + 'px')\n root.style.setProperty(projection.scaleProperty, String(setting.size / projection.defaultSize))\n if (axis === 'ui') {\n root.style.setProperty('--ui-tracking', option.uiTracking)\n root.style.setProperty('--ui-word-spacing', option.uiWordSpacing)\n }\n }\n\n return normalized\n}\n\n/**\n * Generate a safe inline prepaint script for a host-owned appearance record.\n *\n * The stored object is read from `localStorage[storageKey].fonts`. A legacy\n * top-level `font` family migrates into UI only; content/code use the shared\n * defaults. The script applies the same catalogue whitelist, limits, attributes,\n * and CSS properties as `applyAppearanceFontSettings` before styles paint. When\n * `persistedVersion` is supplied, only a record with that exact top-level version\n * is used; absent or mismatched records receive the System defaults.\n */\nexport function fontSettingsBootstrapScript(storageKey: string, persistedVersion?: number): string {\n if (persistedVersion !== undefined && !Number.isSafeInteger(persistedVersion)) {\n throw new RangeError('persistedVersion must be a safe integer')\n }\n const axisConfig = JSON.stringify(fontAxisProjection)\n const fontProjection = JSON.stringify(fontProjectionById)\n const fontIds = `[${fontOptions.map((option) => safeScriptStringLiteral(option.id)).join(',')}]`\n const persistedVersionGuard =\n persistedVersion === undefined\n ? ''\n : `&&parsed.version===Number(${safeScriptStringLiteral(String(persistedVersion))})`\n\n return `(function(){var r=document.documentElement;var axes=JSON.parse(${safeScriptStringLiteral(axisConfig)});var projection=JSON.parse(${safeScriptStringLiteral(fontProjection)});var ids=${fontIds};var has=function(v,k){return Object.prototype.hasOwnProperty.call(v,k)};var record=function(v){return typeof v==='object'&&v!==null&&!Array.isArray(v)};var p={};try{var raw=localStorage.getItem(${safeScriptStringLiteral(storageKey)});var parsed=raw?JSON.parse(raw):{};if(record(parsed)${persistedVersionGuard})p=parsed;}catch(e){}var saved=record(p.fonts)?p.fonts:{};var valid=function(v,d){return ids.indexOf(v)!==-1?v:d};var size=function(v,d){var n=typeof v==='number'?v:typeof v==='string'&&v.trim()!==''?Number(v):NaN;return Number.isFinite(n)?Math.min(${APPEARANCE_EDITOR_FONT_SIZE_MAX},Math.max(${APPEARANCE_EDITOR_FONT_SIZE_MIN},Math.round(n))):d};r.setAttribute('data-font-settings','');for(var axis in axes){if(!has(axes,axis))continue;var spec=axes[axis];var candidate=saved[axis];var value=record(candidate)?candidate:{};var legacyUi=axis==='ui'&&!has(value,'family');var family=legacyUi?valid(p.font,'system'):valid(value.family,'system');var font=projection[family];if(family==='system')r.removeAttribute(spec.familyAttribute);else r.setAttribute(spec.familyAttribute,family);r.style.setProperty(spec.familyProperty,'var('+font.familyVariables[axis]+')');var px=size(value.size,spec.defaultSize);r.style.setProperty(spec.sizeProperty,px+'px');r.style.setProperty(spec.scaleProperty,String(px/spec.defaultSize));if(axis==='ui'){r.style.setProperty('--ui-tracking',font.uiTracking);r.style.setProperty('--ui-word-spacing',font.uiWordSpacing);}}r.removeAttribute('data-font');})();`\n}\n"],"mappings":";;;AAGA,IAAa,8BAA8B;CAAC;CAAM;CAAW;AAAM;AAiBnE,IAAa,kCAAkC;AAC/C,IAAa,kCAAkC;;AAG/C,IAAa,0CAAwE,OAAO,OAAO;CACjG,IAAI,OAAO,OAAO;EAAE,QAAQ;EAAiB,MAAM;CAAG,CAAC;CACvD,SAAS,OAAO,OAAO;EAAE,QAAQ;EAAiB,MAAM;CAAG,CAAC;CAC5D,MAAM,OAAO,OAAO;EAAE,QAAQ;EAAiB,MAAM;CAAG,CAAC;AAC3D,CAAC;AAQD,IAAM,qBAAqB,OAAO,OAChC,OAAO,YACL,YAAY,KAAK,WAAW,CAC1B,OAAO,IACP;CACE,iBAAiB,OAAO;CACxB,YAAY,OAAO;CACnB,eAAe,OAAO;AACxB,CACF,CAAC,CACH,CAIF;AACA,IAAM,qBAAqB,OAAO,OAAO;CACvC,IAAI,OAAO,OAAO;EAChB,iBAAiB;EACjB,gBAAgB;EAChB,cAAc;EACd,eAAe;EACf,aAAa,wCAAwC,GAAG;CAC1D,CAAC;CACD,SAAS,OAAO,OAAO;EACrB,iBAAiB;EACjB,gBAAgB;EAChB,cAAc;EACd,eAAe;EACf,aAAa,wCAAwC,QAAQ;CAC/D,CAAC;CACD,MAAM,OAAO,OAAO;EAClB,iBAAiB;EACjB,gBAAgB;EAChB,cAAc;EACd,eAAe;EACf,aAAa,wCAAwC,KAAK;CAC5D,CAAC;AACH,CAAC;AAED,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,OAAO,OAAgC,KAAsB;CACpE,OAAO,OAAO,U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,cAAc,gBAAgB,GAC1E,MAAM,IAAI,WAAW,yCAAyC;CAEhE,MAAM,aAAa,KAAK,UAAU,kBAAkB;CACpD,MAAM,iBAAiB,KAAK,UAAU,kBAAkB;CACxD,MAAM,UAAU,IAAI,YAAY,KAAK,WAAW,wBAAwB,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;CAC9F,MAAM,wBACJ,qBAAqB,KAAA,IACjB,KACA,6BAA6B,wBAAwB,OAAO,gBAAgB,CAAC,EAAE;CAErF,OAAO,kEAAkE,wBAAwB,UAAU,EAAE,8BAA8B,wBAAwB,cAAc,EAAE,YAAY,QAAQ,qMAAqM,wBAAwB,UAAU,EAAE,uDAAuD,sBAAsB;AAC/f"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type Accessor } from 'solid-js';
|
|
2
|
+
/** A host handler's outcome as data: a rejection carries a message fit to show. */
|
|
3
|
+
export type SettledAction = {
|
|
4
|
+
ok: true;
|
|
5
|
+
} | {
|
|
6
|
+
ok: false;
|
|
7
|
+
message: string;
|
|
8
|
+
};
|
|
9
|
+
/** How much of a rejection's own message is shown; the host usually knows why it failed. */
|
|
10
|
+
export declare const ERROR_TEXT_LIMIT = 200;
|
|
11
|
+
/**
|
|
12
|
+
* Runs a host handler that may be synchronous, asynchronous or throw, and reports
|
|
13
|
+
* the outcome as data. An `Error`'s message is shown (bounded); any other rejection
|
|
14
|
+
* gets `fallback`, never "[object Object]".
|
|
15
|
+
*/
|
|
16
|
+
export declare function settleAction(handler: (() => void | Promise<void>) | undefined, fallback?: string): Promise<SettledAction>;
|
|
17
|
+
export type LatestOutcome<T> = {
|
|
18
|
+
status: 'done';
|
|
19
|
+
value: T;
|
|
20
|
+
} | {
|
|
21
|
+
status: 'failed';
|
|
22
|
+
error: unknown;
|
|
23
|
+
}
|
|
24
|
+
/** A newer run started, `invalidate` was called, or the owner was disposed. */
|
|
25
|
+
| {
|
|
26
|
+
status: 'stale';
|
|
27
|
+
};
|
|
28
|
+
export type LatestAction = {
|
|
29
|
+
/** True while the newest run is in flight. */
|
|
30
|
+
pending: Accessor<boolean>;
|
|
31
|
+
run<T>(task: () => T | Promise<T>): Promise<LatestOutcome<T>>;
|
|
32
|
+
/** Makes every run in flight stale, e.g. when the surface it reports to closes. */
|
|
33
|
+
invalidate(): void;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* An async action whose result only counts while it is the newest one. A reader
|
|
37
|
+
* who picks a second file, or opens a second link, before the first finishes must
|
|
38
|
+
* not have the first one's late answer land on top; nor may an answer land after
|
|
39
|
+
* the component that asked has gone.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createLatestAction(): LatestAction;
|
|
42
|
+
//# sourceMappingURL=async-action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-action.d.ts","sourceRoot":"","sources":["../../src/lib/async-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AAG3E,mFAAmF;AACnF,MAAM,MAAM,aAAa,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAEzE,4FAA4F;AAC5F,eAAO,MAAM,gBAAgB,MAAM,CAAA;AAEnC;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,EACjD,QAAQ,SAAK,GACZ,OAAO,CAAC,aAAa,CAAC,CAQxB;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,IACvB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAC5B;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE;AACtC,+EAA+E;GAC7E;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAA;AAEvB,MAAM,MAAM,YAAY,GAAG;IACzB,8CAA8C;IAC9C,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC1B,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;IAC7D,mFAAmF;IACnF,UAAU,IAAI,IAAI,CAAA;CACnB,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,YAAY,CAwBjD"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { boundText } from "./text.js";
|
|
2
|
+
import { createSignal, getOwner, onCleanup } from "solid-js";
|
|
3
|
+
// src/lib/async-action.ts
|
|
4
|
+
/** How much of a rejection's own message is shown; the host usually knows why it failed. */
|
|
5
|
+
var ERROR_TEXT_LIMIT = 200;
|
|
6
|
+
/**
|
|
7
|
+
* Runs a host handler that may be synchronous, asynchronous or throw, and reports
|
|
8
|
+
* the outcome as data. An `Error`'s message is shown (bounded); any other rejection
|
|
9
|
+
* gets `fallback`, never "[object Object]".
|
|
10
|
+
*/
|
|
11
|
+
async function settleAction(handler, fallback = "") {
|
|
12
|
+
try {
|
|
13
|
+
await handler?.();
|
|
14
|
+
return { ok: true };
|
|
15
|
+
} catch (error) {
|
|
16
|
+
return {
|
|
17
|
+
ok: false,
|
|
18
|
+
message: (error instanceof Error ? boundText(error.message, 200) : "") || fallback
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* An async action whose result only counts while it is the newest one. A reader
|
|
24
|
+
* who picks a second file, or opens a second link, before the first finishes must
|
|
25
|
+
* not have the first one's late answer land on top; nor may an answer land after
|
|
26
|
+
* the component that asked has gone.
|
|
27
|
+
*/
|
|
28
|
+
function createLatestAction() {
|
|
29
|
+
let epoch = 0;
|
|
30
|
+
const [pending, setPending] = createSignal(false);
|
|
31
|
+
const invalidate = () => {
|
|
32
|
+
epoch += 1;
|
|
33
|
+
setPending(false);
|
|
34
|
+
};
|
|
35
|
+
if (getOwner()) onCleanup(invalidate);
|
|
36
|
+
return {
|
|
37
|
+
pending,
|
|
38
|
+
invalidate,
|
|
39
|
+
async run(task) {
|
|
40
|
+
const owner = ++epoch;
|
|
41
|
+
setPending(true);
|
|
42
|
+
try {
|
|
43
|
+
const value = await task();
|
|
44
|
+
return owner === epoch ? {
|
|
45
|
+
status: "done",
|
|
46
|
+
value
|
|
47
|
+
} : { status: "stale" };
|
|
48
|
+
} catch (error) {
|
|
49
|
+
return owner === epoch ? {
|
|
50
|
+
status: "failed",
|
|
51
|
+
error
|
|
52
|
+
} : { status: "stale" };
|
|
53
|
+
} finally {
|
|
54
|
+
if (owner === epoch) setPending(false);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export { ERROR_TEXT_LIMIT, createLatestAction, settleAction };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=async-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-action.js","names":[],"sources":["../../src/lib/async-action.ts"],"sourcesContent":["import { createSignal, getOwner, onCleanup, type Accessor } from 'solid-js'\nimport { boundText } from './text'\n\n/** A host handler's outcome as data: a rejection carries a message fit to show. */\nexport type SettledAction = { ok: true } | { ok: false; message: string }\n\n/** How much of a rejection's own message is shown; the host usually knows why it failed. */\nexport const ERROR_TEXT_LIMIT = 200\n\n/**\n * Runs a host handler that may be synchronous, asynchronous or throw, and reports\n * the outcome as data. An `Error`'s message is shown (bounded); any other rejection\n * gets `fallback`, never \"[object Object]\".\n */\nexport async function settleAction(\n handler: (() => void | Promise<void>) | undefined,\n fallback = ''\n): Promise<SettledAction> {\n try {\n await handler?.()\n return { ok: true }\n } catch (error) {\n const message = error instanceof Error ? boundText(error.message, ERROR_TEXT_LIMIT) : ''\n return { ok: false, message: message || fallback }\n }\n}\n\nexport type LatestOutcome<T> =\n | { status: 'done'; value: T }\n | { status: 'failed'; error: unknown }\n /** A newer run started, `invalidate` was called, or the owner was disposed. */\n | { status: 'stale' }\n\nexport type LatestAction = {\n /** True while the newest run is in flight. */\n pending: Accessor<boolean>\n run<T>(task: () => T | Promise<T>): Promise<LatestOutcome<T>>\n /** Makes every run in flight stale, e.g. when the surface it reports to closes. */\n invalidate(): void\n}\n\n/**\n * An async action whose result only counts while it is the newest one. A reader\n * who picks a second file, or opens a second link, before the first finishes must\n * not have the first one's late answer land on top; nor may an answer land after\n * the component that asked has gone.\n */\nexport function createLatestAction(): LatestAction {\n let epoch = 0\n const [pending, setPending] = createSignal(false)\n const invalidate = () => {\n epoch += 1\n setPending(false)\n }\n if (getOwner()) onCleanup(invalidate)\n return {\n pending,\n invalidate,\n async run<T>(task: () => T | Promise<T>): Promise<LatestOutcome<T>> {\n const owner = ++epoch\n setPending(true)\n try {\n const value = await task()\n return owner === epoch ? { status: 'done', value } : { status: 'stale' }\n } catch (error) {\n return owner === epoch ? { status: 'failed', error } : { status: 'stale' }\n } finally {\n if (owner === epoch) setPending(false)\n }\n },\n }\n}\n"],"mappings":";;;;AAOA,IAAa,mBAAmB;;;;;;AAOhC,eAAsB,aACpB,SACA,WAAW,IACa;CACxB,IAAI;EACF,MAAM,UAAU;EAChB,OAAO,EAAE,IAAI,KAAK;CACpB,SAAS,OAAO;EAEd,OAAO;GAAE,IAAI;GAAO,UADJ,iBAAiB,QAAQ,UAAU,MAAM,SAAA,GAAyB,IAAI,OAC9C;EAAS;CACnD;AACF;;;;;;;AAsBA,SAAgB,qBAAmC;CACjD,IAAI,QAAQ;CACZ,MAAM,CAAC,SAAS,cAAc,aAAa,KAAK;CAChD,MAAM,mBAAmB;EACvB,SAAS;EACT,WAAW,KAAK;CAClB;CACA,IAAI,SAAS,GAAG,UAAU,UAAU;CACpC,OAAO;EACL;EACA;EACA,MAAM,IAAO,MAAuD;GAClE,MAAM,QAAQ,EAAE;GAChB,WAAW,IAAI;GACf,IAAI;IACF,MAAM,QAAQ,MAAM,KAAK;IACzB,OAAO,UAAU,QAAQ;KAAE,QAAQ;KAAQ;IAAM,IAAI,EAAE,QAAQ,QAAQ;GACzE,SAAS,OAAO;IACd,OAAO,UAAU,QAAQ;KAAE,QAAQ;KAAU;IAAM,IAAI,EAAE,QAAQ,QAAQ;GAC3E,UAAU;IACR,IAAI,UAAU,OAAO,WAAW,KAAK;GACvC;EACF;CACF;AACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The viewport width at which a window gains its side columns: Tailwind's `md`
|
|
3
|
+
* breakpoint (`--breakpoint-md`, which `theme.css` leaves at Tailwind's 48rem).
|
|
4
|
+
* A component that switches layout in script reads it here, so its media query
|
|
5
|
+
* flips at the same width as the `md:` classes beside it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MD_BREAKPOINT = "48rem";
|
|
8
|
+
//# sourceMappingURL=breakpoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../src/lib/breakpoints.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,aAAa,UAAU,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/lib/breakpoints.ts
|
|
2
|
+
/**
|
|
3
|
+
* The viewport width at which a window gains its side columns: Tailwind's `md`
|
|
4
|
+
* breakpoint (`--breakpoint-md`, which `theme.css` leaves at Tailwind's 48rem).
|
|
5
|
+
* A component that switches layout in script reads it here, so its media query
|
|
6
|
+
* flips at the same width as the `md:` classes beside it.
|
|
7
|
+
*/
|
|
8
|
+
var MD_BREAKPOINT = "48rem";
|
|
9
|
+
export { MD_BREAKPOINT };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=breakpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breakpoints.js","names":[],"sources":["../../src/lib/breakpoints.ts"],"sourcesContent":["/**\n * The viewport width at which a window gains its side columns: Tailwind's `md`\n * breakpoint (`--breakpoint-md`, which `theme.css` leaves at Tailwind's 48rem).\n * A component that switches layout in script reads it here, so its media query\n * flips at the same width as the `md:` classes beside it.\n */\nexport const MD_BREAKPOINT = '48rem'\n"],"mappings":";;;;;;;AAMA,IAAa,gBAAgB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bytes as a size a reader sees: whole bytes below 1 KiB, then the largest unit
|
|
3
|
+
* in `units` whose *shown* figure stays under 1024. The shown figure, not the raw
|
|
4
|
+
* value, decides the unit, so 1023.96 KiB reads "1 MB" rather than "1024 KB".
|
|
5
|
+
* `figure` is how a caller writes the number; the units are its own spelling.
|
|
6
|
+
*/
|
|
7
|
+
export declare function formatByteSize(bytes: number, units: readonly string[], figure: (amount: number) => string): string;
|
|
8
|
+
//# sourceMappingURL=bytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/lib/bytes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GACjC,MAAM,CASR"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/lib/bytes.ts
|
|
2
|
+
/**
|
|
3
|
+
* Bytes as a size a reader sees: whole bytes below 1 KiB, then the largest unit
|
|
4
|
+
* in `units` whose *shown* figure stays under 1024. The shown figure, not the raw
|
|
5
|
+
* value, decides the unit, so 1023.96 KiB reads "1 MB" rather than "1024 KB".
|
|
6
|
+
* `figure` is how a caller writes the number; the units are its own spelling.
|
|
7
|
+
*/
|
|
8
|
+
function formatByteSize(bytes, units, figure) {
|
|
9
|
+
if (Math.round(bytes) < 1024) return `${Math.round(bytes)} B`;
|
|
10
|
+
let value = bytes / 1024;
|
|
11
|
+
let unit = 0;
|
|
12
|
+
while (Number(figure(value)) >= 1024 && unit < units.length - 1) {
|
|
13
|
+
value /= 1024;
|
|
14
|
+
unit += 1;
|
|
15
|
+
}
|
|
16
|
+
return `${figure(value)} ${units[unit]}`;
|
|
17
|
+
}
|
|
18
|
+
export { formatByteSize };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.js","names":[],"sources":["../../src/lib/bytes.ts"],"sourcesContent":["/**\n * Bytes as a size a reader sees: whole bytes below 1 KiB, then the largest unit\n * in `units` whose *shown* figure stays under 1024. The shown figure, not the raw\n * value, decides the unit, so 1023.96 KiB reads \"1 MB\" rather than \"1024 KB\".\n * `figure` is how a caller writes the number; the units are its own spelling.\n */\nexport function formatByteSize(\n bytes: number,\n units: readonly string[],\n figure: (amount: number) => string\n): string {\n if (Math.round(bytes) < 1024) return `${Math.round(bytes)} B`\n let value = bytes / 1024\n let unit = 0\n while (Number(figure(value)) >= 1024 && unit < units.length - 1) {\n value /= 1024\n unit += 1\n }\n return `${figure(value)} ${units[unit]}`\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,eACd,OACA,OACA,QACQ;CACR,IAAI,KAAK,MAAM,KAAK,IAAI,MAAM,OAAO,GAAG,KAAK,MAAM,KAAK,EAAE;CAC1D,IAAI,QAAQ,QAAQ;CACpB,IAAI,OAAO;CACX,OAAO,OAAO,OAAO,KAAK,CAAC,KAAK,QAAQ,OAAO,MAAM,SAAS,GAAG;EAC/D,SAAS;EACT,QAAQ;CACV;CACA,OAAO,GAAG,OAAO,KAAK,EAAE,GAAG,MAAM;AACnC"}
|
package/dist/lib/clipboard.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
import { type Accessor } from 'solid-js';
|
|
1
2
|
/** Writes text with the async Clipboard API, falling back for older WebViews. */
|
|
2
3
|
export declare function writeClipboardText(value: string): Promise<void>;
|
|
4
|
+
/** How long a control shows its "Copied" state after a successful copy. */
|
|
5
|
+
export declare const COPIED_FEEDBACK_MS = 1500;
|
|
6
|
+
export type CopyFeedback = {
|
|
7
|
+
/** True for {@link COPIED_FEEDBACK_MS} after the latest copy succeeded. */
|
|
8
|
+
copied: Accessor<boolean>;
|
|
9
|
+
/** True after the latest copy failed, until the next attempt. */
|
|
10
|
+
failed: Accessor<boolean>;
|
|
11
|
+
/** Copies `text` and resolves to whether the clipboard accepted it. */
|
|
12
|
+
copy(text: string): Promise<boolean>;
|
|
13
|
+
};
|
|
14
|
+
/** A copy control's state: the attempt, its outcome, and a "Copied" that resets itself. */
|
|
15
|
+
export declare function createCopyFeedback(): CopyFeedback;
|
|
3
16
|
//# sourceMappingURL=clipboard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../src/lib/clipboard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../src/lib/clipboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AAI3E,iFAAiF;AACjF,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqCrE;AAED,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB,OAAO,CAAA;AAEtC,MAAM,MAAM,YAAY,GAAG;IACzB,2EAA2E;IAC3E,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IACzB,iEAAiE;IACjE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IACzB,uEAAuE;IACvE,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACrC,CAAA;AAED,2FAA2F;AAC3F,wBAAgB,kBAAkB,IAAI,YAAY,CA0BjD"}
|
package/dist/lib/clipboard.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createSignal, getOwner, onCleanup } from "solid-js";
|
|
1
2
|
// src/lib/clipboard.ts
|
|
2
3
|
var CLIPBOARD_UNAVAILABLE = "Clipboard is unavailable in this WebView";
|
|
3
4
|
/** Writes text with the async Clipboard API, falling back for older WebViews. */
|
|
@@ -29,6 +30,36 @@ async function writeClipboardText(value) {
|
|
|
29
30
|
}
|
|
30
31
|
if (!copied) throw new Error(CLIPBOARD_UNAVAILABLE);
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
/** How long a control shows its "Copied" state after a successful copy. */
|
|
34
|
+
var COPIED_FEEDBACK_MS = 1500;
|
|
35
|
+
/** A copy control's state: the attempt, its outcome, and a "Copied" that resets itself. */
|
|
36
|
+
function createCopyFeedback() {
|
|
37
|
+
const [copied, setCopied] = createSignal(false);
|
|
38
|
+
const [failed, setFailed] = createSignal(false);
|
|
39
|
+
let timer;
|
|
40
|
+
const clear = () => {
|
|
41
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
42
|
+
timer = void 0;
|
|
43
|
+
};
|
|
44
|
+
if (getOwner()) onCleanup(clear);
|
|
45
|
+
return {
|
|
46
|
+
copied,
|
|
47
|
+
failed,
|
|
48
|
+
async copy(text) {
|
|
49
|
+
let ok = true;
|
|
50
|
+
try {
|
|
51
|
+
await writeClipboardText(text);
|
|
52
|
+
} catch {
|
|
53
|
+
ok = false;
|
|
54
|
+
}
|
|
55
|
+
clear();
|
|
56
|
+
setCopied(ok);
|
|
57
|
+
setFailed(!ok);
|
|
58
|
+
if (ok) timer = setTimeout(() => setCopied(false), COPIED_FEEDBACK_MS);
|
|
59
|
+
return ok;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export { COPIED_FEEDBACK_MS, createCopyFeedback, writeClipboardText };
|
|
33
64
|
|
|
34
65
|
//# sourceMappingURL=clipboard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard.js","names":[],"sources":["../../src/lib/clipboard.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"clipboard.js","names":[],"sources":["../../src/lib/clipboard.ts"],"sourcesContent":["import { createSignal, getOwner, onCleanup, type Accessor } from 'solid-js'\n\nconst CLIPBOARD_UNAVAILABLE = 'Clipboard is unavailable in this WebView'\n\n/** Writes text with the async Clipboard API, falling back for older WebViews. */\nexport async function writeClipboardText(value: string): Promise<void> {\n if (typeof navigator !== 'undefined' && typeof navigator.clipboard?.writeText === 'function') {\n await navigator.clipboard.writeText(value)\n return\n }\n\n if (typeof document === 'undefined' || !document.body) {\n throw new Error(CLIPBOARD_UNAVAILABLE)\n }\n\n const previousFocus = document.activeElement\n const textarea = document.createElement('textarea')\n textarea.value = value\n textarea.setAttribute('readonly', '')\n textarea.setAttribute('aria-hidden', 'true')\n textarea.tabIndex = -1\n textarea.style.position = 'fixed'\n textarea.style.opacity = '0'\n document.body.appendChild(textarea)\n\n let copied = false\n try {\n textarea.focus({ preventScroll: true })\n textarea.select()\n copied = typeof document.execCommand === 'function' && document.execCommand('copy')\n } finally {\n textarea.remove()\n if (previousFocus instanceof HTMLElement && previousFocus.isConnected) {\n try {\n previousFocus.focus({ preventScroll: true })\n } catch {\n // A host may revoke focus during the copy; preserve the clipboard outcome.\n }\n }\n }\n\n if (!copied) throw new Error(CLIPBOARD_UNAVAILABLE)\n}\n\n/** How long a control shows its \"Copied\" state after a successful copy. */\nexport const COPIED_FEEDBACK_MS = 1500\n\nexport type CopyFeedback = {\n /** True for {@link COPIED_FEEDBACK_MS} after the latest copy succeeded. */\n copied: Accessor<boolean>\n /** True after the latest copy failed, until the next attempt. */\n failed: Accessor<boolean>\n /** Copies `text` and resolves to whether the clipboard accepted it. */\n copy(text: string): Promise<boolean>\n}\n\n/** A copy control's state: the attempt, its outcome, and a \"Copied\" that resets itself. */\nexport function createCopyFeedback(): CopyFeedback {\n const [copied, setCopied] = createSignal(false)\n const [failed, setFailed] = createSignal(false)\n let timer: ReturnType<typeof setTimeout> | undefined\n const clear = () => {\n if (timer !== undefined) clearTimeout(timer)\n timer = undefined\n }\n if (getOwner()) onCleanup(clear)\n return {\n copied,\n failed,\n async copy(text) {\n let ok = true\n try {\n await writeClipboardText(text)\n } catch {\n ok = false\n }\n clear()\n setCopied(ok)\n setFailed(!ok)\n if (ok) timer = setTimeout(() => setCopied(false), COPIED_FEEDBACK_MS)\n return ok\n },\n }\n}\n"],"mappings":";;AAEA,IAAM,wBAAwB;;AAG9B,eAAsB,mBAAmB,OAA8B;CACrE,IAAI,OAAO,cAAc,eAAe,OAAO,UAAU,WAAW,cAAc,YAAY;EAC5F,MAAM,UAAU,UAAU,UAAU,KAAK;EACzC;CACF;CAEA,IAAI,OAAO,aAAa,eAAe,CAAC,SAAS,MAC/C,MAAM,IAAI,MAAM,qBAAqB;CAGvC,MAAM,gBAAgB,SAAS;CAC/B,MAAM,WAAW,SAAS,cAAc,UAAU;CAClD,SAAS,QAAQ;CACjB,SAAS,aAAa,YAAY,EAAE;CACpC,SAAS,aAAa,eAAe,MAAM;CAC3C,SAAS,WAAW;CACpB,SAAS,MAAM,WAAW;CAC1B,SAAS,MAAM,UAAU;CACzB,SAAS,KAAK,YAAY,QAAQ;CAElC,IAAI,SAAS;CACb,IAAI;EACF,SAAS,MAAM,EAAE,eAAe,KAAK,CAAC;EACtC,SAAS,OAAO;EAChB,SAAS,OAAO,SAAS,gBAAgB,cAAc,SAAS,YAAY,MAAM;CACpF,UAAU;EACR,SAAS,OAAO;EAChB,IAAI,yBAAyB,eAAe,cAAc,aACxD,IAAI;GACF,cAAc,MAAM,EAAE,eAAe,KAAK,CAAC;EAC7C,QAAQ,CAER;CAEJ;CAEA,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,qBAAqB;AACpD;;AAGA,IAAa,qBAAqB;;AAYlC,SAAgB,qBAAmC;CACjD,MAAM,CAAC,QAAQ,aAAa,aAAa,KAAK;CAC9C,MAAM,CAAC,QAAQ,aAAa,aAAa,KAAK;CAC9C,IAAI;CACJ,MAAM,cAAc;EAClB,IAAI,UAAU,KAAA,GAAW,aAAa,KAAK;EAC3C,QAAQ,KAAA;CACV;CACA,IAAI,SAAS,GAAG,UAAU,KAAK;CAC/B,OAAO;EACL;EACA;EACA,MAAM,KAAK,MAAM;GACf,IAAI,KAAK;GACT,IAAI;IACF,MAAM,mBAAmB,IAAI;GAC/B,QAAQ;IACN,KAAK;GACP;GACA,MAAM;GACN,UAAU,EAAE;GACZ,UAAU,CAAC,EAAE;GACb,IAAI,IAAI,QAAQ,iBAAiB,UAAU,KAAK,GAAG,kBAAkB;GACrE,OAAO;EACT;CACF;AACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JSX } from 'solid-js';
|
|
2
|
+
/**
|
|
3
|
+
* Calls a Solid event-handler prop the way Solid itself would: a plain function
|
|
4
|
+
* receives the event, a bound `[handler, data]` tuple receives the data first.
|
|
5
|
+
*
|
|
6
|
+
* A component that wraps a forwarded `onKeyDown` (or any other handler) with its
|
|
7
|
+
* own behaviour needs this, because Solid only unpacks the tuple form when it
|
|
8
|
+
* attaches the prop to an element itself.
|
|
9
|
+
*/
|
|
10
|
+
export declare function callHandler<T, E extends Event>(handler: JSX.EventHandlerUnion<T, E> | undefined, event: E & {
|
|
11
|
+
currentTarget: T;
|
|
12
|
+
target: Element;
|
|
13
|
+
}): void;
|
|
14
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/lib/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAEnC;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,KAAK,EAC5C,OAAO,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,EAChD,KAAK,EAAE,CAAC,GAAG;IAAE,aAAa,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC/C,IAAI,CAGN"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/lib/events.ts
|
|
2
|
+
/**
|
|
3
|
+
* Calls a Solid event-handler prop the way Solid itself would: a plain function
|
|
4
|
+
* receives the event, a bound `[handler, data]` tuple receives the data first.
|
|
5
|
+
*
|
|
6
|
+
* A component that wraps a forwarded `onKeyDown` (or any other handler) with its
|
|
7
|
+
* own behaviour needs this, because Solid only unpacks the tuple form when it
|
|
8
|
+
* attaches the prop to an element itself.
|
|
9
|
+
*/
|
|
10
|
+
function callHandler(handler, event) {
|
|
11
|
+
if (typeof handler === "function") handler(event);
|
|
12
|
+
else if (Array.isArray(handler)) handler[0](handler[1], event);
|
|
13
|
+
}
|
|
14
|
+
export { callHandler };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","names":[],"sources":["../../src/lib/events.ts"],"sourcesContent":["import type { JSX } from 'solid-js'\n\n/**\n * Calls a Solid event-handler prop the way Solid itself would: a plain function\n * receives the event, a bound `[handler, data]` tuple receives the data first.\n *\n * A component that wraps a forwarded `onKeyDown` (or any other handler) with its\n * own behaviour needs this, because Solid only unpacks the tuple form when it\n * attaches the prop to an element itself.\n */\nexport function callHandler<T, E extends Event>(\n handler: JSX.EventHandlerUnion<T, E> | undefined,\n event: E & { currentTarget: T; target: Element }\n): void {\n if (typeof handler === 'function') handler(event)\n else if (Array.isArray(handler)) handler[0](handler[1], event)\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,YACd,SACA,OACM;CACN,IAAI,OAAO,YAAY,YAAY,QAAQ,KAAK;MAC3C,IAAI,MAAM,QAAQ,OAAO,GAAG,QAAQ,EAAE,CAAC,QAAQ,IAAI,KAAK;AAC/D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Accessor } from 'solid-js';
|
|
2
|
+
export type ExternalLinkOpener = {
|
|
3
|
+
/** The failure sentence while the newest open has failed, otherwise empty. */
|
|
4
|
+
error: Accessor<string>;
|
|
5
|
+
/**
|
|
6
|
+
* A link's click handler. With a host `open` the browser navigation is replaced
|
|
7
|
+
* by it (a desktop shell opens the system browser); without one the anchor's
|
|
8
|
+
* own `href` and `target` do the work.
|
|
9
|
+
*/
|
|
10
|
+
onClick(url: string): (event: MouseEvent) => void;
|
|
11
|
+
/** Forgets the error and any open in flight, e.g. when the surface closes. */
|
|
12
|
+
reset(): void;
|
|
13
|
+
};
|
|
14
|
+
/** Opens an anchor's address through the host when the host supplies a way to. */
|
|
15
|
+
export declare function createExternalLinkOpener(options: {
|
|
16
|
+
open: () => ((url: string) => Promise<void>) | undefined;
|
|
17
|
+
failure: string;
|
|
18
|
+
}): ExternalLinkOpener;
|
|
19
|
+
//# sourceMappingURL=external-link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-link.d.ts","sourceRoot":"","sources":["../../src/lib/external-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AAGtD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,8EAA8E;IAC9E,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IACvB;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IACjD,8EAA8E;IAC9E,KAAK,IAAI,IAAI,CAAA;CACd,CAAA;AAED,kFAAkF;AAClF,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,IAAI,EAAE,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAA;IACxD,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,kBAAkB,CAqBrB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createLatestAction } from "./async-action.js";
|
|
2
|
+
import { createSignal } from "solid-js";
|
|
3
|
+
// src/lib/external-link.ts
|
|
4
|
+
/** Opens an anchor's address through the host when the host supplies a way to. */
|
|
5
|
+
function createExternalLinkOpener(options) {
|
|
6
|
+
const action = createLatestAction();
|
|
7
|
+
const [error, setError] = createSignal("");
|
|
8
|
+
return {
|
|
9
|
+
error,
|
|
10
|
+
reset() {
|
|
11
|
+
action.invalidate();
|
|
12
|
+
setError("");
|
|
13
|
+
},
|
|
14
|
+
onClick: (url) => (event) => {
|
|
15
|
+
const open = options.open();
|
|
16
|
+
if (!open) return;
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
setError("");
|
|
19
|
+
action.run(() => open(url)).then((outcome) => {
|
|
20
|
+
if (outcome.status === "failed") setError(options.failure);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export { createExternalLinkOpener };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=external-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-link.js","names":[],"sources":["../../src/lib/external-link.ts"],"sourcesContent":["import { createSignal, type Accessor } from 'solid-js'\nimport { createLatestAction } from './async-action'\n\nexport type ExternalLinkOpener = {\n /** The failure sentence while the newest open has failed, otherwise empty. */\n error: Accessor<string>\n /**\n * A link's click handler. With a host `open` the browser navigation is replaced\n * by it (a desktop shell opens the system browser); without one the anchor's\n * own `href` and `target` do the work.\n */\n onClick(url: string): (event: MouseEvent) => void\n /** Forgets the error and any open in flight, e.g. when the surface closes. */\n reset(): void\n}\n\n/** Opens an anchor's address through the host when the host supplies a way to. */\nexport function createExternalLinkOpener(options: {\n open: () => ((url: string) => Promise<void>) | undefined\n failure: string\n}): ExternalLinkOpener {\n const action = createLatestAction()\n const [error, setError] = createSignal('')\n return {\n error,\n reset() {\n action.invalidate()\n setError('')\n },\n onClick: (url) => (event) => {\n const open = options.open()\n if (!open) return\n event.preventDefault()\n setError('')\n void action\n .run(() => open(url))\n .then((outcome) => {\n if (outcome.status === 'failed') setError(options.failure)\n })\n },\n }\n}\n"],"mappings":";;;;AAiBA,SAAgB,yBAAyB,SAGlB;CACrB,MAAM,SAAS,mBAAmB;CAClC,MAAM,CAAC,OAAO,YAAY,aAAa,EAAE;CACzC,OAAO;EACL;EACA,QAAQ;GACN,OAAO,WAAW;GAClB,SAAS,EAAE;EACb;EACA,UAAU,SAAS,UAAU;GAC3B,MAAM,OAAO,QAAQ,KAAK;GAC1B,IAAI,CAAC,MAAM;GACX,MAAM,eAAe;GACrB,SAAS,EAAE;GACX,OACG,UAAU,KAAK,GAAG,CAAC,CAAC,CACpB,MAAM,YAAY;IACjB,IAAI,QAAQ,WAAW,UAAU,SAAS,QAAQ,OAAO;GAC3D,CAAC;EACL;CACF;AACF"}
|