@aceshooting/lyra-ui 9.1.1 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +597 -0
- package/custom-elements.json +1 -1
- package/dist/cli/migrate-wa.mjs +52 -0
- package/dist/cli/migration-contract.json +1 -1
- package/dist/components/agent-tools/activity-feed/activity-feed.class.js +1 -1
- package/dist/components/agent-tools/activity-feed/activity-feed.styles.js +0 -16
- package/dist/components/agent-tools/agent-eval-dashboard/agent-eval-dashboard.class.js +1 -1
- package/dist/components/agent-tools/agent-eval-dashboard/agent-eval-dashboard.styles.js +7 -5
- package/dist/components/agent-tools/agent-run/agent-run.class.js +2 -2
- package/dist/components/agent-tools/agent-run/agent-run.styles.js +0 -13
- package/dist/components/agent-tools/agent-trace/agent-trace.styles.js +7 -4
- package/dist/components/agent-tools/approval-queue/approval-queue.styles.js +7 -5
- package/dist/components/agent-tools/artifact-panel/artifact-panel.styles.js +0 -3
- package/dist/components/agent-tools/browser-frame/browser-frame.styles.js +3 -5
- package/dist/components/agent-tools/commit-card/commit-card.styles.js +0 -10
- package/dist/components/agent-tools/compare-panel/compare-panel.styles.js +11 -6
- package/dist/components/agent-tools/confirm-bar/confirm-bar.styles.js +0 -46
- package/dist/components/agent-tools/eval-dataset/eval-dataset.styles.js +0 -7
- package/dist/components/agent-tools/evaluation-run/evaluation-run.class.js +2 -2
- package/dist/components/agent-tools/prompt-studio/prompt-studio.styles.js +0 -15
- package/dist/components/agent-tools/result-card/result-card.styles.js +0 -7
- package/dist/components/agent-tools/result-card/result-field.styles.js +0 -5
- package/dist/components/agent-tools/schema-viewer/schema-viewer.styles.js +0 -3
- package/dist/components/agent-tools/span-waterfall/span-waterfall.styles.js +0 -15
- package/dist/components/agent-tools/stack-trace/stack-trace.styles.js +0 -20
- package/dist/components/agent-tools/subagent-panel/subagent-panel.class.js +2 -2
- package/dist/components/agent-tools/subagent-panel/subagent-panel.styles.js +0 -3
- package/dist/components/agent-tools/task-list/task-list.styles.js +0 -15
- package/dist/components/agent-tools/terminal/terminal.class.d.ts +11 -6
- package/dist/components/agent-tools/terminal/terminal.class.js +4 -4
- package/dist/components/agent-tools/terminal/terminal.styles.js +0 -46
- package/dist/components/agent-tools/test-results/test-results.class.js +2 -2
- package/dist/components/agent-tools/test-results/test-results.styles.js +0 -5
- package/dist/components/agent-tools/thinking-panel/thinking-panel.styles.js +0 -41
- package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.styles.js +0 -41
- package/dist/components/agent-tools/tool-call-chip/tool-call-chip.styles.js +0 -30
- package/dist/components/agent-tools/tool-param-form/tool-param-form.class.js +6 -6
- package/dist/components/agent-tools/tool-param-form/tool-param-form.styles.js +0 -5
- package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.styles.js +0 -20
- package/dist/components/agent-tools/tool-result-view/tool-result-view.styles.js +0 -4
- package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.styles.js +0 -21
- package/dist/components/agent-tools/trace-tree/trace-tree.styles.js +7 -31
- package/dist/components/charts/chart/box-plot.styles.js +0 -20
- package/dist/components/charts/chart/chart-colors.d.ts +1 -1
- package/dist/components/charts/chart/chart-colors.js +1 -1
- package/dist/components/charts/chart/chart-core-loader.d.ts +1 -0
- package/dist/components/charts/chart/chart-core-loader.js +1 -1
- package/dist/components/charts/chart/chart-feature-loader.d.ts +35 -0
- package/dist/components/charts/chart/chart-feature-loader.js +1 -1
- package/dist/components/charts/chart/chart.class.d.ts +93 -0
- package/dist/components/charts/chart/chart.class.js +3 -3
- package/dist/components/charts/chart/chart.styles.js +0 -27
- package/dist/components/charts/chart/lite-chart.class.d.ts +20 -1
- package/dist/components/charts/chart/lite-chart.class.js +4 -4
- package/dist/components/charts/chart/lite-chart.styles.js +0 -27
- package/dist/components/conversation/agent-workspace/agent-workspace.class.d.ts +20 -0
- package/dist/components/conversation/agent-workspace/agent-workspace.class.js +3 -1
- package/dist/components/conversation/agent-workspace/agent-workspace.styles.js +3 -0
- package/dist/components/conversation/audio-visualizer/audio-visualizer.styles.js +0 -7
- package/dist/components/conversation/branch-picker/branch-picker.styles.js +0 -3
- package/dist/components/conversation/chat-composer/chat-composer.styles.js +0 -51
- package/dist/components/conversation/chat-message/chat-message.styles.js +7 -35
- package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
- package/dist/components/conversation/chat-viewport/chat-viewport.styles.js +0 -33
- package/dist/components/conversation/checkpoint/checkpoint.class.js +1 -1
- package/dist/components/conversation/checkpoint/checkpoint.styles.js +0 -3
- package/dist/components/conversation/code-block/code-block-shared.d.ts +5 -2
- package/dist/components/conversation/code-block/code-block.class.js +1 -1
- package/dist/components/conversation/code-block/code-block.styles.js +4 -95
- package/dist/components/conversation/code-block/code-loader.d.ts +11 -0
- package/dist/components/conversation/code-block/code-loader.js +1 -1
- package/dist/components/conversation/code-block/shiki-types.d.ts +12 -0
- package/dist/components/conversation/code-block/shiki-types.js +1 -1
- package/dist/components/conversation/conversation-item/conversation-item.styles.js +8 -54
- package/dist/components/conversation/generation-metrics/generation-metrics.class.js +2 -2
- package/dist/components/conversation/generation-metrics/generation-metrics.styles.js +0 -17
- package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
- package/dist/components/conversation/markdown/markdown.styles.js +0 -41
- package/dist/components/conversation/message-actions/message-actions.styles.js +0 -3
- package/dist/components/conversation/message-feedback/message-feedback.styles.js +0 -35
- package/dist/components/conversation/message-parts/message-parts.class.d.ts +1 -1
- package/dist/components/conversation/message-parts/message-parts.styles.js +0 -5
- package/dist/components/conversation/model-select/model-select.class.js +3 -3
- package/dist/components/conversation/model-select/model-select.styles.js +12 -47
- package/dist/components/conversation/model-settings-panel/model-settings-panel.styles.js +0 -6
- package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +3 -0
- package/dist/components/conversation/prompt-input/prompt-input.styles.js +0 -10
- package/dist/components/conversation/push-to-talk/push-to-talk.styles.js +0 -8
- package/dist/components/conversation/selection-toolbar/selection-toolbar.styles.js +1 -11
- package/dist/components/conversation/stream-status/stream-status.styles.js +0 -16
- package/dist/components/conversation/streaming-text/streaming-text.styles.js +0 -15
- package/dist/components/conversation/suggestion-chips/suggestion-chips.styles.js +0 -5
- package/dist/components/conversation/thread-list/thread-list.styles.js +0 -23
- package/dist/components/conversation/transcript-feed/transcript-feed.class.d.ts +16 -4
- package/dist/components/conversation/transcript-feed/transcript-feed.class.js +1 -1
- package/dist/components/conversation/transcript-feed/transcript-feed.styles.js +0 -1
- package/dist/components/conversation/typing-indicator/typing-indicator.styles.js +0 -23
- package/dist/components/conversation/usage-badge/usage-badge.styles.js +0 -3
- package/dist/components/conversation/voice-picker/voice-picker.class.js +3 -3
- package/dist/components/conversation/voice-picker/voice-picker.styles.js +9 -29
- package/dist/components/conversation/widget-renderer/resolve.d.ts +2 -0
- package/dist/components/conversation/widget-renderer/resolve.js +1 -1
- package/dist/components/data/calendar/calendar.class.d.ts +15 -2
- package/dist/components/data/calendar/calendar.class.js +2 -2
- package/dist/components/data/calendar/calendar.styles.js +2 -28
- package/dist/components/data/condition-builder/condition-builder.class.d.ts +10 -6
- package/dist/components/data/condition-builder/condition-builder.class.js +2 -2
- package/dist/components/data/condition-builder/condition-builder.styles.js +0 -6
- package/dist/components/data/context-meter/context-meter.styles.js +0 -24
- package/dist/components/data/data-grid/data-grid.class.js +3 -3
- package/dist/components/data/data-grid/data-grid.styles.js +0 -22
- package/dist/components/data/document-library/document-library.class.js +2 -2
- package/dist/components/data/document-library/document-library.styles.js +0 -4
- package/dist/components/data/env-list/env-list.class.js +1 -1
- package/dist/components/data/env-list/env-list.styles.js +7 -4
- package/dist/components/data/file-tree/file-tree.class.d.ts +12 -0
- package/dist/components/data/flow-canvas/flow-canvas.styles.js +12 -19
- package/dist/components/data/flow-controls/flow-controls.class.js +2 -2
- package/dist/components/data/flow-controls/flow-controls.styles.js +3 -36
- package/dist/components/data/flow-minimap/flow-minimap.class.js +1 -1
- package/dist/components/data/flow-minimap/flow-minimap.styles.js +0 -9
- package/dist/components/data/flow-node/flow-node.styles.js +0 -23
- package/dist/components/data/flow-run-status/flow-run-status.class.js +1 -1
- package/dist/components/data/flow-run-status/flow-run-status.styles.js +0 -7
- package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +0 -7
- package/dist/components/data/graph-query-builder/graph-query-builder.class.js +1 -1
- package/dist/components/data/graph-query-builder/graph-query-builder.styles.js +0 -10
- package/dist/components/data/heatmap/heatmap-scale.d.ts +20 -0
- package/dist/components/data/heatmap/heatmap-scale.js +1 -1
- package/dist/components/data/heatmap/heatmap.class.d.ts +84 -1
- package/dist/components/data/heatmap/heatmap.class.js +2 -2
- package/dist/components/data/heatmap/heatmap.styles.js +0 -54
- package/dist/components/data/pagination/pagination.styles.js +23 -46
- package/dist/components/data/sequence-strip/sequence-strip.class.d.ts +34 -1
- package/dist/components/data/sequence-strip/sequence-strip.class.js +5 -2
- package/dist/components/data/sequence-strip/sequence-strip.styles.js +14 -20
- package/dist/components/data/sparkline/sparkline.class.js +1 -1
- package/dist/components/data/stat/stat.styles.js +0 -67
- package/dist/components/data/table/table.class.d.ts +42 -3
- package/dist/components/data/table/table.class.js +4 -4
- package/dist/components/data/table/table.styles.js +20 -91
- package/dist/components/data/timeline/timeline-item.styles.js +0 -30
- package/dist/components/data/timeline/timeline.class.d.ts +89 -1
- package/dist/components/data/timeline/timeline.class.js +2 -2
- package/dist/components/data/timeline/timeline.styles.js +111 -31
- package/dist/components/data/tree/tree-item.styles.js +1 -28
- package/dist/components/data/tree/tree.class.js +2 -2
- package/dist/components/data/tree/tree.styles.js +0 -6
- package/dist/components/data/word-cloud/word-cloud.styles.js +0 -5
- package/dist/components/forms/button/button.class.js +1 -1
- package/dist/components/forms/button/button.styles.js +0 -105
- package/dist/components/forms/checkbox/checkbox.class.d.ts +3 -0
- package/dist/components/forms/checkbox/checkbox.class.js +1 -1
- package/dist/components/forms/checkbox/checkbox.styles.js +0 -39
- package/dist/components/forms/checkbox-group/checkbox-group.class.d.ts +21 -2
- package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
- package/dist/components/forms/checkbox-group/checkbox-group.styles.js +0 -18
- package/dist/components/forms/code-editor/code-editor.styles.js +0 -30
- package/dist/components/forms/color-picker/color-picker.class.js +2 -2
- package/dist/components/forms/color-picker/color-picker.styles.js +0 -69
- package/dist/components/forms/combobox/combobox.class.js +2 -2
- package/dist/components/forms/combobox/combobox.styles.js +22 -111
- package/dist/components/forms/combobox/option.styles.js +7 -1
- package/dist/components/forms/date-picker/date-input.class.js +1 -1
- package/dist/components/forms/date-picker/date-input.styles.js +12 -67
- package/dist/components/forms/date-picker/date-picker.class.d.ts +1 -0
- package/dist/components/forms/date-picker/date-picker.class.js +22 -20
- package/dist/components/forms/date-picker/date-picker.styles.js +36 -29
- package/dist/components/forms/emoji-picker/emoji-data-loader.d.ts +6 -3
- package/dist/components/forms/emoji-picker/emoji-data-loader.js +1 -1
- package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +8 -1
- package/dist/components/forms/emoji-picker/emoji-picker.class.js +1 -1
- package/dist/components/forms/emoji-picker/emoji-picker.styles.js +3 -41
- package/dist/components/forms/icon-button/icon-button.class.js +1 -1
- package/dist/components/forms/icon-button/icon-button.styles.js +0 -16
- package/dist/components/forms/input/input.styles.js +0 -54
- package/dist/components/forms/input/number-input.styles.d.ts +4 -5
- package/dist/components/forms/input/number-input.styles.js +0 -11
- package/dist/components/forms/input/time-input-shared.d.ts +11 -0
- package/dist/components/forms/input/time-input-shared.js +1 -1
- package/dist/components/forms/input/time-input.class.d.ts +11 -2
- package/dist/components/forms/input/time-input.class.js +1 -1
- package/dist/components/forms/input/time-input.styles.js +0 -6
- package/dist/components/forms/locale-picker/locale-picker.class.js +2 -2
- package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -26
- package/dist/components/forms/otp-input/otp-input.class.js +3 -3
- package/dist/components/forms/otp-input/otp-input.styles.js +0 -16
- package/dist/components/forms/phone-input/phone-input.class.d.ts +9 -1
- package/dist/components/forms/phone-input/phone-input.class.js +2 -2
- package/dist/components/forms/phone-input/phone-input.styles.js +0 -37
- package/dist/components/forms/radio/radio-button.styles.js +1 -30
- package/dist/components/forms/radio/radio-group.styles.js +0 -4
- package/dist/components/forms/radio/radio.styles.js +0 -44
- package/dist/components/forms/rubric-form/rubric-form.styles.js +0 -5
- package/dist/components/forms/select/select.class.js +1 -1
- package/dist/components/forms/select/select.styles.js +14 -114
- package/dist/components/forms/slider/slider.styles.js +0 -55
- package/dist/components/forms/swatch-picker/swatch-picker.class.d.ts +0 -11
- package/dist/components/forms/swatch-picker/swatch-picker.class.js +2 -2
- package/dist/components/forms/swatch-picker/swatch-picker.styles.js +0 -77
- package/dist/components/forms/switch/switch.class.d.ts +3 -0
- package/dist/components/forms/switch/switch.class.js +1 -1
- package/dist/components/forms/switch/switch.styles.js +0 -37
- package/dist/components/forms/textarea/textarea.styles.js +0 -28
- package/dist/components/forms/time-range/time-range.styles.js +12 -84
- package/dist/components/forms/token-input/token-input.class.d.ts +23 -9
- package/dist/components/forms/token-input/token-input.class.js +1 -1
- package/dist/components/forms/token-input/token-input.styles.js +1 -54
- package/dist/components/layout/app-rail/app-rail-item.class.js +2 -2
- package/dist/components/layout/app-rail/app-rail-item.styles.js +0 -13
- package/dist/components/layout/app-rail/app-rail.class.d.ts +5 -0
- package/dist/components/layout/app-rail/app-rail.class.js +1 -1
- package/dist/components/layout/app-rail/app-rail.styles.js +0 -46
- package/dist/components/layout/button-group/button-group.styles.js +0 -6
- package/dist/components/layout/card/card.class.d.ts +12 -0
- package/dist/components/layout/card/card.styles.js +3 -11
- package/dist/components/layout/carousel/carousel.styles.js +0 -1
- package/dist/components/layout/command-palette/command-palette.class.d.ts +8 -0
- package/dist/components/layout/command-palette/command-palette.class.js +3 -1
- package/dist/components/layout/command-palette/command-palette.styles.js +1 -13
- package/dist/components/layout/control-group/control-group.styles.js +0 -7
- package/dist/components/layout/dashboard-grid/dashboard-grid.styles.js +6 -25
- package/dist/components/layout/details/accordion.class.d.ts +13 -0
- package/dist/components/layout/details/accordion.class.js +1 -1
- package/dist/components/layout/details/details.class.js +1 -1
- package/dist/components/layout/details/details.styles.js +0 -12
- package/dist/components/layout/dock-panel/dock-panel.styles.js +0 -45
- package/dist/components/layout/drilldown-panel/drilldown-panel.class.d.ts +2 -0
- package/dist/components/layout/drilldown-panel/drilldown-panel.class.js +2 -2
- package/dist/components/layout/drilldown-panel/drilldown-panel.styles.js +0 -4
- package/dist/components/layout/filter-bar/filter-bar.class.js +1 -1
- package/dist/components/layout/filter-bar/filter-bar.styles.js +0 -9
- package/dist/components/layout/menu/menu-item.class.d.ts +5 -0
- package/dist/components/layout/menu/menu-item.class.js +1 -1
- package/dist/components/layout/menu/menu-item.styles.js +0 -49
- package/dist/components/layout/menu/menu-label.styles.js +0 -2
- package/dist/components/layout/menu/menu.styles.js +0 -18
- package/dist/components/layout/multi-split/multi-split.styles.js +0 -63
- package/dist/components/layout/page/page.class.d.ts +4 -0
- package/dist/components/layout/page/page.class.js +1 -1
- package/dist/components/layout/reorder-list/reorder-item.styles.js +0 -4
- package/dist/components/layout/responsive-panel/responsive-panel.styles.js +0 -27
- package/dist/components/layout/scroller/scroller.styles.js +0 -20
- package/dist/components/layout/segmented/segmented.class.d.ts +7 -1
- package/dist/components/layout/segmented/segmented.class.js +1 -1
- package/dist/components/layout/segmented/segmented.styles.js +69 -37
- package/dist/components/layout/split-panel/split-panel.styles.js +1 -7
- package/dist/components/layout/stepper/stepper.class.d.ts +8 -1
- package/dist/components/layout/stepper/stepper.class.js +1 -1
- package/dist/components/layout/stepper/stepper.styles.js +140 -41
- package/dist/components/layout/tab-group/tab-group.class.d.ts +4 -1
- package/dist/components/layout/tab-group/tab-group.styles.js +9 -75
- package/dist/components/layout/tab-group/tab.styles.js +0 -2
- package/dist/components/layout/virtual-list/virtual-list.class.d.ts +4 -4
- package/dist/components/layout/virtual-list/virtual-list.class.js +1 -1
- package/dist/components/layout/virtual-list/virtual-list.styles.js +0 -68
- package/dist/components/layout/widget/widget.class.d.ts +5 -1
- package/dist/components/layout/widget/widget.class.js +1 -1
- package/dist/components/layout/widget/widget.styles.js +97 -40
- package/dist/components/media/animated-image/animated-image.class.d.ts +3 -0
- package/dist/components/media/animated-image/animated-image.class.js +1 -1
- package/dist/components/media/animated-image/animated-image.styles.js +0 -28
- package/dist/components/media/attachment-chip/attachment-chip.class.d.ts +1 -1
- package/dist/components/media/attachment-chip/attachment-chip.class.js +1 -1
- package/dist/components/media/attachment-chip/attachment-chip.styles.js +0 -31
- package/dist/components/media/attachment-trigger/attachment-trigger.class.js +3 -3
- package/dist/components/media/attachment-trigger/attachment-trigger.styles.js +0 -40
- package/dist/components/media/av-player/av-player.class.d.ts +5 -6
- package/dist/components/media/av-player/av-player.class.js +1 -1
- package/dist/components/media/av-player/av-player.styles.js +0 -45
- package/dist/components/media/avatar/avatar.styles.js +3 -16
- package/dist/components/media/file-icon/file-icon.class.d.ts +1 -2
- package/dist/components/media/file-icon/file-icon.class.js +1 -1
- package/dist/components/media/file-input/file-input.class.d.ts +12 -0
- package/dist/components/media/file-input/file-input.styles.js +3 -24
- package/dist/components/media/flag/flag.class.d.ts +20 -0
- package/dist/components/media/flag/flag.class.js +4 -2
- package/dist/components/media/flag/flag.styles.js +7 -1
- package/dist/components/media/flag/language-map.d.ts +10 -0
- package/dist/components/media/flag/language-map.js +1 -1
- package/dist/components/media/image-comparer/image-comparer.styles.js +4 -33
- package/dist/components/media/image-viewer/image-viewer.class.js +0 -2
- package/dist/components/media/image-viewer/image-viewer.styles.js +7 -27
- package/dist/components/media/lightbox/lightbox.class.js +0 -2
- package/dist/components/media/lightbox/lightbox.styles.js +0 -21
- package/dist/components/media/map/map-loader.d.ts +19 -1
- package/dist/components/media/map/map-loader.js +1 -1
- package/dist/components/media/map/map.class.d.ts +141 -1
- package/dist/components/media/map/map.class.js +15 -3
- package/dist/components/media/map/map.styles.js +20 -17
- package/dist/components/media/media-card/media-card.class.d.ts +14 -3
- package/dist/components/media/media-card/media-card.class.js +1 -1
- package/dist/components/media/media-card/media-card.styles.js +2 -28
- package/dist/components/media/pan-zoom/pan-zoom.styles.js +0 -3
- package/dist/components/media/qr-code/qr-code.class.d.ts +3 -2
- package/dist/components/media/qr-code/qr-code.class.js +2 -2
- package/dist/components/media/qr-code/qr-code.styles.js +0 -3
- package/dist/components/media/sequence-playback/sequence-playback.class.d.ts +2 -0
- package/dist/components/media/sequence-playback/sequence-playback.class.js +2 -1
- package/dist/components/media/sequence-playback/sequence-playback.styles.js +0 -19
- package/dist/components/media/video/video.class.d.ts +23 -2
- package/dist/components/media/video/video.class.js +3 -3
- package/dist/components/media/video/video.styles.js +4 -2
- package/dist/components/media/zoomable-frame/zoomable-frame.class.d.ts +3 -2
- package/dist/components/media/zoomable-frame/zoomable-frame.class.js +2 -2
- package/dist/components/media/zoomable-frame/zoomable-frame.styles.js +0 -5
- package/dist/components/overlays/alert/alert.styles.js +4 -2
- package/dist/components/overlays/badge/badge.styles.js +4 -48
- package/dist/components/overlays/badge/tag.styles.js +0 -14
- package/dist/components/overlays/callout/callout.styles.js +0 -11
- package/dist/components/overlays/chip/chip-group.styles.js +0 -18
- package/dist/components/overlays/chip/chip.styles.js +6 -69
- package/dist/components/overlays/dialog/confirm.d.ts +1 -4
- package/dist/components/overlays/dialog/confirm.js +1 -1
- package/dist/components/overlays/dialog/dialog.class.d.ts +12 -9
- package/dist/components/overlays/dialog/dialog.class.js +1 -1
- package/dist/components/overlays/dialog/dialog.styles.js +0 -43
- package/dist/components/overlays/drawer/drawer.class.d.ts +2 -2
- package/dist/components/overlays/drawer/drawer.styles.js +0 -9
- package/dist/components/overlays/empty/empty.styles.js +0 -12
- package/dist/components/overlays/kbd/kbd.styles.js +0 -8
- package/dist/components/overlays/overlay/dropdown.class.d.ts +1 -6
- package/dist/components/overlays/overlay/dropdown.class.js +2 -2
- package/dist/components/overlays/overlay/overlay.styles.js +0 -28
- package/dist/components/overlays/overlay/popover.class.d.ts +9 -1
- package/dist/components/overlays/overlay/popover.class.js +2 -2
- package/dist/components/overlays/overlay/tooltip.class.d.ts +10 -0
- package/dist/components/overlays/overlay/tooltip.class.js +1 -1
- package/dist/components/overlays/popup/popup.class.d.ts +1 -0
- package/dist/components/overlays/popup/popup.class.js +1 -1
- package/dist/components/overlays/popup/popup.styles.js +0 -15
- package/dist/components/overlays/progress/progress-ring.class.d.ts +9 -1
- package/dist/components/overlays/progress/progress-ring.class.js +3 -3
- package/dist/components/overlays/progress/progress.styles.js +0 -21
- package/dist/components/overlays/rating/rating.styles.js +0 -25
- package/dist/components/overlays/skeleton/skeleton.styles.js +0 -4
- package/dist/components/overlays/spinner/spinner.styles.js +0 -3
- package/dist/components/overlays/toast/toast-item.styles.js +3 -45
- package/dist/components/retrieval/chunk-inspector/chunk-inspector.styles.js +0 -35
- package/dist/components/retrieval/citation-badge/citation-badge.class.d.ts +2 -2
- package/dist/components/retrieval/citation-badge/citation-badge.class.js +3 -3
- package/dist/components/retrieval/citation-badge/citation-badge.styles.js +0 -20
- package/dist/components/retrieval/claim-evidence/claim-evidence.styles.js +0 -8
- package/dist/components/retrieval/community-card/community-card.class.d.ts +1 -0
- package/dist/components/retrieval/community-card/community-card.styles.js +0 -6
- package/dist/components/retrieval/embedding-explorer/embedding-explorer.styles.js +8 -12
- package/dist/components/retrieval/entity-card/entity-card.class.d.ts +4 -3
- package/dist/components/retrieval/entity-card/entity-card.class.js +1 -1
- package/dist/components/retrieval/entity-card/entity-card.styles.js +0 -12
- package/dist/components/retrieval/entity-chip/entity-chip.class.d.ts +10 -4
- package/dist/components/retrieval/entity-chip/entity-chip.class.js +3 -3
- package/dist/components/retrieval/entity-chip/entity-chip.styles.js +6 -9
- package/dist/components/retrieval/entity-dossier/entity-dossier.class.d.ts +19 -5
- package/dist/components/retrieval/graph/graph.class.d.ts +5 -0
- package/dist/components/retrieval/graph/graph.class.js +1 -1
- package/dist/components/retrieval/graph/graph.styles.js +0 -30
- package/dist/components/retrieval/graph-legend/graph-legend.styles.js +0 -3
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.styles.js +0 -25
- package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.class.d.ts +2 -0
- package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.styles.js +0 -7
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +20 -6
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +2 -2
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.styles.js +0 -16
- package/dist/components/retrieval/mind-map/mind-map.class.d.ts +5 -3
- package/dist/components/retrieval/mind-map/mind-map.class.js +1 -1
- package/dist/components/retrieval/mind-map/mind-map.styles.js +0 -2
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.d.ts +3 -2
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +1 -1
- package/dist/components/retrieval/neighbor-list/neighbor-list.styles.js +0 -30
- package/dist/components/retrieval/node-palette/node-palette.styles.js +0 -11
- package/dist/components/retrieval/path-strip/path-strip.styles.js +0 -10
- package/dist/components/retrieval/provenance-panel/provenance-panel.class.d.ts +12 -3
- package/dist/components/retrieval/provenance-panel/provenance-panel.styles.js +0 -2
- package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.d.ts +3 -2
- package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.js +2 -2
- package/dist/components/retrieval/retrieval-results/retrieval-results.styles.js +0 -28
- package/dist/components/retrieval/retrieval-search/retrieval-search.styles.js +0 -4
- package/dist/components/retrieval/retrieval-trace/retrieval-trace.styles.js +0 -2
- package/dist/components/retrieval/source-card/source-card.styles.js +0 -13
- package/dist/components/retrieval/source-list/source-list.styles.js +0 -7
- package/dist/components/retrieval/source-picker/source-picker.styles.js +0 -7
- package/dist/components/utility/copy-button/copy-button.styles.js +0 -10
- package/dist/components/utility/diff-view/diff-view.styles.js +0 -14
- package/dist/components/utility/export-button/export-button.styles.js +0 -22
- package/dist/components/utility/icon/icon.styles.js +0 -6
- package/dist/components/utility/json-viewer/json-viewer.styles.js +2 -48
- package/dist/components/utility/known-date/known-date.class.d.ts +7 -3
- package/dist/components/utility/known-date/known-date.styles.js +10 -51
- package/dist/components/utility/live-region/live-region.styles.js +0 -4
- package/dist/components/utility/mention-popover/mention-popover.styles.js +0 -25
- package/dist/components/utility/poll-status/poll-status.styles.js +0 -4
- package/dist/components/utility/random-content/random-content.class.d.ts +22 -0
- package/dist/components/utility/random-content/random-content.class.js +3 -2
- package/dist/components/utility/random-content/random-content.styles.js +6 -13
- package/dist/components/utility/tour/tour.class.d.ts +4 -2
- package/dist/components/utility/tour/tour.class.js +3 -3
- package/dist/components/utility/tour/tour.styles.js +0 -13
- package/dist/components/utility/visually-hidden/visually-hidden.styles.js +0 -5
- package/dist/components/viewers/archive-viewer/archive-viewer.class.js +1 -1
- package/dist/components/viewers/archive-viewer/archive-viewer.styles.d.ts +2 -2
- package/dist/components/viewers/archive-viewer/archive-viewer.styles.js +0 -10
- package/dist/components/viewers/csv-viewer/csv-viewer.class.js +1 -1
- package/dist/components/viewers/csv-viewer/csv-viewer.styles.js +0 -19
- package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +1 -1
- package/dist/components/viewers/dataset-viewer/dataset-viewer.styles.js +0 -15
- package/dist/components/viewers/document-compare/document-compare.styles.js +0 -3
- package/dist/components/viewers/document-preview/document-preview.styles.js +0 -25
- package/dist/components/viewers/document-viewer/document-viewer.class.d.ts +2 -1
- package/dist/components/viewers/document-viewer/document-viewer.class.js +1 -1
- package/dist/components/viewers/document-viewer/document-viewer.styles.js +0 -5
- package/dist/components/viewers/docx-viewer/docx-viewer.styles.js +0 -17
- package/dist/components/viewers/ebook-viewer/ebook-viewer.styles.js +0 -4
- package/dist/components/viewers/email-viewer/email-viewer.styles.js +0 -7
- package/dist/components/viewers/geojson-view/geojson-view.styles.js +0 -5
- package/dist/components/viewers/highlight-layer/highlight-layer.styles.js +0 -3
- package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +1 -1
- package/dist/components/viewers/notebook-viewer/notebook-viewer.styles.js +0 -38
- package/dist/components/viewers/page-rail/page-rail.class.js +1 -1
- package/dist/components/viewers/page-rail/page-rail.styles.js +0 -13
- package/dist/components/viewers/pdf-viewer/pdf-loader.d.ts +13 -2
- package/dist/components/viewers/pdf-viewer/pdf-loader.js +1 -1
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +32 -2
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +4 -4
- package/dist/components/viewers/pdf-viewer/pdf-viewer.styles.js +1 -27
- package/dist/components/viewers/pptx-viewer/pptx-viewer.styles.js +0 -3
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +1 -1
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.styles.js +0 -14
- package/dist/components/viewers/svg-viewer/svg-viewer.styles.js +0 -7
- package/dist/components/viewers/xml-viewer/xml-viewer.styles.js +2 -24
- package/dist/custom-elements-jsx.d.ts +56 -37
- package/dist/events.d.ts +43 -33
- package/dist/internal/agent-status-variants.d.ts +18 -0
- package/dist/internal/agent-status-variants.js +1 -0
- package/dist/internal/announcer.d.ts +8 -3
- package/dist/internal/announcer.js +1 -1
- package/dist/internal/autoloader-manifest.js +1 -1
- package/dist/internal/canvas-color.d.ts +16 -0
- package/dist/internal/canvas-color.js +1 -1
- package/dist/internal/catalog-picker.d.ts +0 -1
- package/dist/internal/catalog-picker.js +1 -1
- package/dist/internal/default-strings.generated.d.ts +1 -0
- package/dist/internal/default-strings.generated.js +1 -1
- package/dist/internal/dev-mode-attribute-warning.d.ts +27 -4
- package/dist/internal/dev-mode-attribute-warning.js +1 -1
- package/dist/internal/localization-runtime.js +1 -1
- package/dist/internal/localization-types.d.ts +1 -1
- package/dist/internal/localization.js +1 -1
- package/dist/internal/lyra-element.d.ts +13 -0
- package/dist/internal/lyra-element.js +1 -1
- package/dist/internal/media-controller.js +1 -1
- package/dist/internal/package-metadata.d.ts +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/scroll-overflow.d.ts +35 -13
- package/dist/internal/scroll-overflow.js +1 -1
- package/dist/internal/sizes.styles.js +0 -2
- package/dist/internal/specialist-tokens.styles.js +6 -11
- package/dist/internal/text-highlights.d.ts +4 -1
- package/dist/internal/text-highlights.js +1 -1
- package/dist/internal/tokens/palette.styles.js +0 -15
- package/dist/internal/tokens.styles.js +19 -113
- package/dist/lyra.d.ts +8 -5
- package/dist/styles/reservations.css +82 -0
- package/dist/svelte.d.ts +56 -37
- package/dist/translations/ar.js +1 -1
- package/dist/translations/de.js +1 -1
- package/dist/translations/es.js +1 -1
- package/dist/translations/fa.js +1 -1
- package/dist/translations/fr.js +1 -1
- package/dist/translations/he.js +1 -1
- package/dist/translations/ja.js +1 -1
- package/dist/translations/pt-BR.js +1 -1
- package/dist/translations/ru.js +1 -1
- package/dist/translations/zh-CN.js +1 -1
- package/dist/vue.d.ts +56 -37
- package/llms/components/lr-accordion-item.md +12 -3
- package/llms/components/lr-accordion.md +11 -2
- package/llms/components/lr-agent-eval-dashboard.md +1 -1
- package/llms/components/lr-agent-trace.md +3 -1
- package/llms/components/lr-agent-workspace.md +20 -0
- package/llms/components/lr-artifact-panel.md +10 -4
- package/llms/components/lr-attachment-chip.md +7 -4
- package/llms/components/lr-attachment-trigger.md +7 -4
- package/llms/components/lr-av-player.md +3 -1
- package/llms/components/lr-avatar.md +6 -6
- package/llms/components/lr-bar-chart.md +4 -3
- package/llms/components/lr-box-plot.md +1 -1
- package/llms/components/lr-browser-frame.md +7 -3
- package/llms/components/lr-bubble-chart.md +4 -3
- package/llms/components/lr-calendar.md +9 -2
- package/llms/components/lr-card.md +24 -0
- package/llms/components/lr-chart.md +32 -8
- package/llms/components/lr-chat-viewport.md +7 -2
- package/llms/components/lr-checkbox-group.md +13 -5
- package/llms/components/lr-checkbox.md +5 -2
- package/llms/components/lr-checkpoint.md +6 -2
- package/llms/components/lr-combobox.md +5 -2
- package/llms/components/lr-command-palette.md +4 -1
- package/llms/components/lr-confirm-bar.md +7 -3
- package/llms/components/lr-context-meter.md +12 -11
- package/llms/components/lr-conversation-item.md +7 -4
- package/llms/components/lr-details.md +11 -2
- package/llms/components/lr-dialog.md +15 -10
- package/llms/components/lr-dock-panel.md +7 -10
- package/llms/components/lr-document-preview.md +6 -1
- package/llms/components/lr-document-viewer.md +3 -2
- package/llms/components/lr-doughnut-chart.md +4 -3
- package/llms/components/lr-drawer.md +3 -3
- package/llms/components/lr-entity-card.md +3 -3
- package/llms/components/lr-entity-chip.md +1 -1
- package/llms/components/lr-entity-dossier.md +4 -1
- package/llms/components/lr-file-input.md +2 -2
- package/llms/components/lr-flag.md +20 -5
- package/llms/components/lr-heatmap.md +28 -0
- package/llms/components/lr-histogram.md +3 -1
- package/llms/components/lr-icon.md +1 -1
- package/llms/components/lr-json-schema-viewer.md +2 -1
- package/llms/components/lr-knowledge-graph-explorer.md +8 -3
- package/llms/components/lr-known-date.md +4 -2
- package/llms/components/lr-line-chart.md +4 -3
- package/llms/components/lr-lite-chart.md +16 -6
- package/llms/components/lr-map.md +72 -8
- package/llms/components/lr-markdown-core.md +3 -2
- package/llms/components/lr-media-card.md +28 -12
- package/llms/components/lr-message-parts.md +2 -1
- package/llms/components/lr-model-select.md +9 -10
- package/llms/components/lr-model-settings-panel.md +9 -9
- package/llms/components/lr-neighbor-list.md +1 -1
- package/llms/components/lr-notebook-viewer.md +6 -3
- package/llms/components/lr-option.md +5 -2
- package/llms/components/lr-pdf-viewer.md +62 -2
- package/llms/components/lr-pie-chart.md +4 -3
- package/llms/components/lr-polar-area-chart.md +4 -3
- package/llms/components/lr-popover.md +5 -0
- package/llms/components/lr-progress-ring.md +8 -1
- package/llms/components/lr-prompt-studio.md +1 -1
- package/llms/components/lr-provenance-panel.md +4 -2
- package/llms/components/lr-qr-code.md +1 -1
- package/llms/components/lr-radar-chart.md +4 -3
- package/llms/components/lr-rag-eval-dashboard.md +2 -2
- package/llms/components/lr-random-content.md +13 -0
- package/llms/components/lr-reorder-item.md +6 -1
- package/llms/components/lr-reorder-list.md +6 -1
- package/llms/components/lr-responsive-panel.md +11 -7
- package/llms/components/lr-scatter-chart.md +4 -3
- package/llms/components/lr-sequence-strip.md +16 -2
- package/llms/components/lr-slider.md +12 -5
- package/llms/components/lr-sparkline.md +1 -1
- package/llms/components/lr-suggestion-chips.md +7 -2
- package/llms/components/lr-swatch-picker.md +5 -5
- package/llms/components/lr-switch.md +5 -2
- package/llms/components/lr-table.md +30 -4
- package/llms/components/lr-terminal.md +3 -1
- package/llms/components/lr-thread-list.md +8 -8
- package/llms/components/lr-time-input.md +6 -1
- package/llms/components/lr-timeline-item.md +24 -0
- package/llms/components/lr-timeline.md +25 -1
- package/llms/components/lr-token-input.md +7 -2
- package/llms/components/lr-tool-approval-dialog.md +7 -8
- package/llms/components/lr-tool-call-chip.md +5 -1
- package/llms/components/lr-tool-param-form.md +14 -12
- package/llms/components/lr-tool-result-dialog.md +11 -9
- package/llms/components/lr-tool-result-view.md +7 -6
- package/llms/components/lr-tool-select-dialog.md +18 -16
- package/llms/components/lr-trace-tree.md +3 -1
- package/llms/components/lr-usage-badge.md +4 -1
- package/llms/components/lr-video-playlist.md +1 -1
- package/llms/components/lr-virtual-list.md +22 -14
- package/llms/components/lr-voice-picker.md +8 -5
- package/llms/components/lr-widget-renderer.md +3 -3
- package/llms/components/lr-widget.md +1 -1
- package/llms/components/lr-word-cloud.md +6 -2
- package/llms/peers.md +12 -2
- package/llms/shared.md +70 -2
- package/llms-full.txt +1143 -285
- package/package.json +17 -5
- package/vscode-css-data.json +37 -2
- package/vscode-html-data.json +401 -44
- package/web-types.json +299 -55
|
@@ -46,7 +46,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
46
46
|
part="restore-button"
|
|
47
47
|
type="button"
|
|
48
48
|
aria-label=${this.localize("checkpointRestoreWithContext",void 0,{label})}
|
|
49
|
-
aria-disabled=${this.restoring?"true":
|
|
49
|
+
aria-disabled=${this.restoring?"true":"false"}
|
|
50
50
|
@click=${this.onRestoreClick}
|
|
51
51
|
>
|
|
52
52
|
${this.restoring?html`<span class="restore-spinner" aria-hidden="true">${spinnerIcon()}</span>`:nothing}
|
|
@@ -56,9 +56,6 @@ import{css}from"lit";const styles=css`
|
|
|
56
56
|
border-color: var(--lr-color-brand);
|
|
57
57
|
color: var(--lr-color-brand);
|
|
58
58
|
}
|
|
59
|
-
/* Hover recolors the chrome only; the press additionally fills the pill, mixing its resting
|
|
60
|
-
surface toward the text color so the pressed state is a strictly stronger signal than hover
|
|
61
|
-
rather than a differently-colored one. */
|
|
62
59
|
[part='restore-button']:active:not([aria-disabled='true']) {
|
|
63
60
|
border-color: var(--lr-color-brand);
|
|
64
61
|
color: var(--lr-color-brand);
|
|
@@ -174,8 +174,11 @@ export interface CodeBlockPlainCodeOptions {
|
|
|
174
174
|
* is what `highlight-lines`/`highlights`/`activatable-lines` attach to. `.split()` consumes each
|
|
175
175
|
* newline character, so a literal `'\n'` text node is re-inserted between lines to keep the
|
|
176
176
|
* non-line-numbered case's visual output (relying on `[part='pre']`'s `white-space: pre`) identical
|
|
177
|
-
* to a single-text-node rendering
|
|
178
|
-
*
|
|
177
|
+
* to a single-text-node rendering. That text node is NOT inert in the line-numbered case, as this
|
|
178
|
+
* comment once claimed: inside a block container each whitespace run becomes its own anonymous
|
|
179
|
+
* block, which rendered a blank row between every line (a 3-line block laid out 5 rows). The
|
|
180
|
+
* container is `display: grid` (`code-block.styles.ts`), which drops whitespace-only runs instead
|
|
181
|
+
* of boxing them, so one row is painted per line in both modes. The gutter is a
|
|
179
182
|
* separate real button, leaving source text selectable in both plain and highlighted output.
|
|
180
183
|
*/
|
|
181
184
|
export declare function renderCodeBlockPlainCode(options: CodeBlockPlainCodeOptions): TemplateResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{nextId}from"../../../internal/a11y.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{loadShikiHighlighter,loadShikiLanguage,loadShikiHighlighterCore,normalizeShikiLanguage}from"./code-loader.js";import{styles}from"./code-block.styles.js";import{CodeBlockInteractionController,applyCodeBlockAriaBusy,clampCodeBlockFocusedLine,codeBlockActiveHighlightLineSet,codeBlockLineHasFocus,codeBlockLineCount,codeBlockLineHighlightSet,codeBlockNeedsHighlightResync,codeBlockPreSuppliedGrammar,codeBlockShowsSkeleton,renderCodeBlockPlainCode,renderCodeBlockShell,restoreCodeBlockLineFocus,scrollCodeBlockToAnchor,tokenizeCodeBlock}from"./code-block-shared.js";import"../../overlays/skeleton/skeleton.class.js";import{presenceTrueDefaultBooleanConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_codeBlockLineLabel,LYRA_DEFAULT_codeRegion,LYRA_DEFAULT_codeRegionWithLanguage,LYRA_DEFAULT_collapseCode,LYRA_DEFAULT_copied,LYRA_DEFAULT_copiedToClipboard,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyCode,LYRA_DEFAULT_copyFailed,LYRA_DEFAULT_expandCode}from"../../../internal/default-strings.generated.js";class LyraCodeBlock extends LyraElement{static{this.defaultStrings={...super.defaultStrings,codeBlockLineLabel:LYRA_DEFAULT_codeBlockLineLabel,codeRegion:LYRA_DEFAULT_codeRegion,codeRegionWithLanguage:LYRA_DEFAULT_codeRegionWithLanguage,collapseCode:LYRA_DEFAULT_collapseCode,copied:LYRA_DEFAULT_copied,copiedToClipboard:LYRA_DEFAULT_copiedToClipboard,copy:LYRA_DEFAULT_copy,copyCode:LYRA_DEFAULT_copyCode,copyFailed:LYRA_DEFAULT_copyFailed,expandCode:LYRA_DEFAULT_expandCode}}static{this.immutableEventDetails=Object.freeze(["lr-text-select"])}static{this.styles=[LyraElement.styles,styles]}constructor(){super(),this.code="",this.language="",this.filename="",this.accessibleLabel=null,this.collapsible=!1,this.collapsed=!1,this.copyable=!0,this.maxHeight="",this.lineNumbers=!1,this.highlightLines="",this.activatableLines=!1,this.highlights=[],this.activeHighlightId=null,this.anchorKinds=["line-range"],this.focusedLine=1,this.restoreFocusedLineAfterUpdate=!1,this.highlightedHtml=null,this.shikiReady=!1,this.justCopied=!1,this.copyFailed=!1,this.isDarkTheme=!1,this.interactions=new CodeBlockInteractionController({host:this,setFocusedLine:line=>{this.focusedLine=line},setJustCopied:value=>{this.justCopied=value},setCopyFailed:value=>{this.copyFailed=value},setDarkTheme:value=>{this.isDarkTheme=value},emitLineActivate:line=>this.emit("lr-line-activate",{line}),emitCopy:outcome=>this.emit("lr-copy",outcome),emitError:()=>this.emit("lr-error",null),emitCopyError:outcome=>this.emit("lr-copy-error",outcome),requestToggle:collapsed=>!this.emit("lr-toggle-request",{collapsed},{cancelable:!0}).defaultPrevented,emitToggle:collapsed=>this.emit("lr-toggle",{collapsed}),emitTextSelect:selection=>this.emit("lr-text-select",selection)}),this.highlightToken=0,this.defaultHighlighterLoading=!1,this.bodyId=nextId("code-block-body"),new ThemeWatcher(this,()=>this.refreshTheme())}connectedCallback(){super.connectedCallback(),this.refreshTheme(),this.ensureDefaultHighlighter(),(this.preSuppliedGrammar()||this.highlighter)&&this.syncHighlight()}ensureDefaultHighlighter(){!this.isConnected||this.highlighter!==void 0||this.defaultHighlighterLoading||(this.defaultHighlighterLoading=!0,loadShikiHighlighter().then(hl=>{this.defaultHighlighterLoading=!1,this.isConnected&&(this.highlighter=hl,this.shikiReady=!0,this.syncHighlight())}))}disconnectedCallback(){this.highlightToken++,super.disconnectedCallback(),this.interactions.disconnect(),this.highlightedHtml=null}adoptedCallback(){super.adoptedCallback(),this.interactions.disconnect()}preSuppliedGrammar(){return codeBlockPreSuppliedGrammar(this.languages,this.language)}lineHighlightSet(){return codeBlockLineHighlightSet(this.highlightLines,this.highlights,this.lineCount())}activeHighlightLineSet(){return codeBlockActiveHighlightLineSet(this.highlights,this.activeHighlightId,this.lineCount())}lineCount(){return codeBlockLineCount(this.code)}async scrollToAnchor(target){return scrollCodeBlockToAnchor(this,target)}refreshTheme(){this.interactions.refreshTheme()}willUpdate(changed){super.willUpdate(changed),this.restoreFocusedLineAfterUpdate=codeBlockLineHasFocus(this),changed.has("code")&&(this.focusedLine=clampCodeBlockFocusedLine(this.focusedLine,this.lineCount())),codeBlockNeedsHighlightResync(changed)&&(this.shikiReady||this.preSuppliedGrammar())&&this.syncHighlight()}updated(changed){super.updated(changed),applyCodeBlockAriaBusy(this,this.showsSkeleton()),this.restoreFocusedLineAfterUpdate&&(restoreCodeBlockLineFocus(this,this.focusedLine),this.restoreFocusedLineAfterUpdate=!1)}showsSkeleton(){return codeBlockShowsSkeleton(this.shikiReady,this.language,!this.preSuppliedGrammar())}syncHighlight(){const token=++this.highlightToken,lang=normalizeShikiLanguage(this.language);if(!lang){this.highlightedHtml=null;return}const languages=this.languages;if(languages?.[lang]??languages?.[this.language]){this.highlightedHtml=null,loadShikiHighlighterCore(languages).then(hl2=>{token===this.highlightToken&&this.isConnected&&(this.highlightedHtml=hl2?this.tokenize(hl2,lang):null)});return}const hl=this.highlighter;if(!hl){this.highlightedHtml=null;return}if(hl
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{nextId}from"../../../internal/a11y.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{loadShikiHighlighter,loadShikiLanguage,loadShikiHighlighterCore,normalizeShikiLanguage,shikiHasLoadedLanguage}from"./code-loader.js";import{styles}from"./code-block.styles.js";import{CodeBlockInteractionController,applyCodeBlockAriaBusy,clampCodeBlockFocusedLine,codeBlockActiveHighlightLineSet,codeBlockLineHasFocus,codeBlockLineCount,codeBlockLineHighlightSet,codeBlockNeedsHighlightResync,codeBlockPreSuppliedGrammar,codeBlockShowsSkeleton,renderCodeBlockPlainCode,renderCodeBlockShell,restoreCodeBlockLineFocus,scrollCodeBlockToAnchor,tokenizeCodeBlock}from"./code-block-shared.js";import"../../overlays/skeleton/skeleton.class.js";import{presenceTrueDefaultBooleanConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_codeBlockLineLabel,LYRA_DEFAULT_codeRegion,LYRA_DEFAULT_codeRegionWithLanguage,LYRA_DEFAULT_collapseCode,LYRA_DEFAULT_copied,LYRA_DEFAULT_copiedToClipboard,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyCode,LYRA_DEFAULT_copyFailed,LYRA_DEFAULT_expandCode}from"../../../internal/default-strings.generated.js";class LyraCodeBlock extends LyraElement{static{this.defaultStrings={...super.defaultStrings,codeBlockLineLabel:LYRA_DEFAULT_codeBlockLineLabel,codeRegion:LYRA_DEFAULT_codeRegion,codeRegionWithLanguage:LYRA_DEFAULT_codeRegionWithLanguage,collapseCode:LYRA_DEFAULT_collapseCode,copied:LYRA_DEFAULT_copied,copiedToClipboard:LYRA_DEFAULT_copiedToClipboard,copy:LYRA_DEFAULT_copy,copyCode:LYRA_DEFAULT_copyCode,copyFailed:LYRA_DEFAULT_copyFailed,expandCode:LYRA_DEFAULT_expandCode}}static{this.immutableEventDetails=Object.freeze(["lr-text-select"])}static{this.styles=[LyraElement.styles,styles]}constructor(){super(),this.code="",this.language="",this.filename="",this.accessibleLabel=null,this.collapsible=!1,this.collapsed=!1,this.copyable=!0,this.maxHeight="",this.lineNumbers=!1,this.highlightLines="",this.activatableLines=!1,this.highlights=[],this.activeHighlightId=null,this.anchorKinds=["line-range"],this.focusedLine=1,this.restoreFocusedLineAfterUpdate=!1,this.highlightedHtml=null,this.shikiReady=!1,this.justCopied=!1,this.copyFailed=!1,this.isDarkTheme=!1,this.interactions=new CodeBlockInteractionController({host:this,setFocusedLine:line=>{this.focusedLine=line},setJustCopied:value=>{this.justCopied=value},setCopyFailed:value=>{this.copyFailed=value},setDarkTheme:value=>{this.isDarkTheme=value},emitLineActivate:line=>this.emit("lr-line-activate",{line}),emitCopy:outcome=>this.emit("lr-copy",outcome),emitError:()=>this.emit("lr-error",null),emitCopyError:outcome=>this.emit("lr-copy-error",outcome),requestToggle:collapsed=>!this.emit("lr-toggle-request",{collapsed},{cancelable:!0}).defaultPrevented,emitToggle:collapsed=>this.emit("lr-toggle",{collapsed}),emitTextSelect:selection=>this.emit("lr-text-select",selection)}),this.highlightToken=0,this.defaultHighlighterLoading=!1,this.bodyId=nextId("code-block-body"),new ThemeWatcher(this,()=>this.refreshTheme())}connectedCallback(){super.connectedCallback(),this.refreshTheme(),this.ensureDefaultHighlighter(),(this.preSuppliedGrammar()||this.highlighter)&&this.syncHighlight()}ensureDefaultHighlighter(){!this.isConnected||this.highlighter!==void 0||this.defaultHighlighterLoading||(this.defaultHighlighterLoading=!0,loadShikiHighlighter().then(hl=>{this.defaultHighlighterLoading=!1,this.isConnected&&(this.highlighter=hl,this.shikiReady=!0,this.syncHighlight())}))}disconnectedCallback(){this.highlightToken++,super.disconnectedCallback(),this.interactions.disconnect(),this.highlightedHtml=null}adoptedCallback(){super.adoptedCallback(),this.interactions.disconnect()}preSuppliedGrammar(){return codeBlockPreSuppliedGrammar(this.languages,this.language)}lineHighlightSet(){return codeBlockLineHighlightSet(this.highlightLines,this.highlights,this.lineCount())}activeHighlightLineSet(){return codeBlockActiveHighlightLineSet(this.highlights,this.activeHighlightId,this.lineCount())}lineCount(){return codeBlockLineCount(this.code)}async scrollToAnchor(target){return scrollCodeBlockToAnchor(this,target)}refreshTheme(){this.interactions.refreshTheme()}willUpdate(changed){super.willUpdate(changed),this.restoreFocusedLineAfterUpdate=codeBlockLineHasFocus(this),changed.has("code")&&(this.focusedLine=clampCodeBlockFocusedLine(this.focusedLine,this.lineCount())),codeBlockNeedsHighlightResync(changed)&&(this.shikiReady||this.preSuppliedGrammar())&&this.syncHighlight()}updated(changed){super.updated(changed),applyCodeBlockAriaBusy(this,this.showsSkeleton()),this.restoreFocusedLineAfterUpdate&&(restoreCodeBlockLineFocus(this,this.focusedLine),this.restoreFocusedLineAfterUpdate=!1)}showsSkeleton(){return codeBlockShowsSkeleton(this.shikiReady,this.language,!this.preSuppliedGrammar())}syncHighlight(){const token=++this.highlightToken,lang=normalizeShikiLanguage(this.language);if(!lang){this.highlightedHtml=null;return}const languages=this.languages;if(languages?.[lang]??languages?.[this.language]){this.highlightedHtml=null,loadShikiHighlighterCore(languages).then(hl2=>{token===this.highlightToken&&this.isConnected&&(this.highlightedHtml=hl2?this.tokenize(hl2,lang):null)});return}const hl=this.highlighter;if(!hl){this.highlightedHtml=null;return}if(shikiHasLoadedLanguage(hl,lang)){this.highlightedHtml=this.tokenize(hl,lang);return}this.highlightedHtml=null,loadShikiLanguage(hl,lang).then(ok=>{token===this.highlightToken&&this.isConnected&&(this.highlightedHtml=ok?this.tokenize(hl,lang):null)})}tokenize(hl,lang){return tokenizeCodeBlock(hl,{code:this.code,lang,lineNumbers:this.lineNumbers,activatableLines:this.activatableLines,focusedLine:this.focusedLine,highlightedLines:this.lineHighlightSet(),activeLines:this.activeHighlightLineSet(),lineLabel:line=>this.localize("codeBlockLineLabel",void 0,{line:getNumberFormat(this.effectiveLocale).format(line)}),lineNumberText:line=>getNumberFormat(this.effectiveLocale).format(line)})}renderPlainCode(){return renderCodeBlockPlainCode({code:this.code,lineNumbers:this.lineNumbers,activatableLines:this.activatableLines,focusedLine:this.focusedLine,highlightedLines:this.lineHighlightSet(),activeLines:this.activeHighlightLineSet(),localize:this.localize.bind(this),lineLabel:line=>this.localize("codeBlockLineLabel",void 0,{line:getNumberFormat(this.effectiveLocale).format(line)}),lineNumberText:line=>getNumberFormat(this.effectiveLocale).format(line),onLineActivate:line=>this.interactions.onLineActivate(line),onLineKeyDown:(e,line)=>this.interactions.onLineKeyDown(e,line)})}render(){return renderCodeBlockShell({filename:this.filename,language:this.language,copyable:this.copyable,collapsible:this.collapsible,collapsed:this.collapsed,justCopied:this.justCopied,copyFailed:this.copyFailed,bodyId:this.bodyId,accessibleLabel:this.accessibleLabel,maxHeight:this.maxHeight,isDarkTheme:this.isDarkTheme,showSkeleton:this.showsSkeleton(),highlightedHtml:this.highlightedHtml,lineNumbers:this.lineNumbers,localize:this.localize.bind(this),renderPlainCode:()=>this.renderPlainCode(),onToggle:this.interactions.toggleCollapsed,onCopy:this.interactions.copy,onBodyMouseUp:this.interactions.onBodyMouseUp,onBodyClick:this.interactions.onBodyClick,onBodyKeyDown:this.interactions.onBodyKeyDown,onBodyFocusIn:this.interactions.onBodyFocusIn})}}__decorate([property()],LyraCodeBlock.prototype,"code",void 0),__decorate([property()],LyraCodeBlock.prototype,"language",void 0),__decorate([property()],LyraCodeBlock.prototype,"filename",void 0),__decorate([property({attribute:"aria-label"})],LyraCodeBlock.prototype,"accessibleLabel",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCodeBlock.prototype,"collapsible",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCodeBlock.prototype,"collapsed",void 0),__decorate([property({type:Boolean,reflect:!0,converter:trueDefaultBooleanConverter})],LyraCodeBlock.prototype,"copyable",void 0),__decorate([property({attribute:"max-height"})],LyraCodeBlock.prototype,"maxHeight",void 0),__decorate([property({type:Boolean,attribute:"line-numbers",reflect:!0})],LyraCodeBlock.prototype,"lineNumbers",void 0),__decorate([property({attribute:"highlight-lines"})],LyraCodeBlock.prototype,"highlightLines",void 0),__decorate([property({type:Boolean,attribute:"activatable-lines"})],LyraCodeBlock.prototype,"activatableLines",void 0),__decorate([property({attribute:!1})],LyraCodeBlock.prototype,"highlights",void 0),__decorate([property({attribute:"active-highlight-id"})],LyraCodeBlock.prototype,"activeHighlightId",void 0),__decorate([state()],LyraCodeBlock.prototype,"focusedLine",void 0),__decorate([property({attribute:!1})],LyraCodeBlock.prototype,"languages",void 0),__decorate([state()],LyraCodeBlock.prototype,"highlightedHtml",void 0),__decorate([state()],LyraCodeBlock.prototype,"shikiReady",void 0),__decorate([state()],LyraCodeBlock.prototype,"justCopied",void 0),__decorate([state()],LyraCodeBlock.prototype,"copyFailed",void 0),__decorate([state()],LyraCodeBlock.prototype,"isDarkTheme",void 0);export{LyraCodeBlock};
|
|
@@ -16,18 +16,10 @@ import{css}from"lit";const styles=css`
|
|
|
16
16
|
gap: var(--lr-space-xs);
|
|
17
17
|
padding: var(--lr-space-xs) var(--lr-space-s);
|
|
18
18
|
border-block-end: var(--lr-border-width-thin) solid var(--lr-color-border);
|
|
19
|
-
/* --lr-color-surface (not -brand-quiet) -- pairing
|
|
20
|
-
--lr-color-text-quiet (the toggle/copy-button color below) against
|
|
21
|
-
--lr-color-brand-quiet fails WCAG AA contrast in this token
|
|
22
|
-
palette; --lr-color-surface is the same header background
|
|
23
|
-
lr-json-viewer's own toolbar already uses with that same text
|
|
24
|
-
color. */
|
|
25
19
|
background: var(--lr-color-surface);
|
|
26
20
|
font-family: var(--lr-font);
|
|
27
21
|
}
|
|
28
22
|
[part='toggle'] {
|
|
29
|
-
/* Keep the glyph compact while giving the interactive box the shared
|
|
30
|
-
minimum target size. */
|
|
31
23
|
inline-size: var(--lr-size-1-25rem);
|
|
32
24
|
block-size: var(--lr-size-1-25rem);
|
|
33
25
|
min-inline-size: var(--lr-icon-button-size);
|
|
@@ -59,18 +51,9 @@ import{css}from"lit";const styles=css`
|
|
|
59
51
|
display: inline-flex;
|
|
60
52
|
transition: transform var(--lr-transition-fast);
|
|
61
53
|
}
|
|
62
|
-
/* Chevron points at the content: rotated (pointing down) while expanded,
|
|
63
|
-
resting (pointing right) while collapsed -- same rotation direction as
|
|
64
|
-
lr-thinking-panel's and lr-json-viewer's own toggles. */
|
|
65
54
|
:host(:not([collapsed])) [part='toggle'] .chevron {
|
|
66
55
|
transform: rotate(90deg);
|
|
67
56
|
}
|
|
68
|
-
/* RTL: the resting (collapsed) chevron mirrors to point left, the
|
|
69
|
-
conventional mirrored disclosure-triangle direction for RTL. Scoped to
|
|
70
|
-
[collapsed] specifically (rather than a plain :dir(rtl) rule) so it
|
|
71
|
-
never has to compete with the rule above for the expanded state, which
|
|
72
|
-
needs no mirroring: rotating this left-right-asymmetric glyph 90deg
|
|
73
|
-
already produces a left-right-symmetric down chevron. */
|
|
74
57
|
:host([collapsed]:dir(rtl)) [part='toggle'] .chevron {
|
|
75
58
|
transform: scaleX(-1);
|
|
76
59
|
}
|
|
@@ -94,12 +77,6 @@ import{css}from"lit";const styles=css`
|
|
|
94
77
|
white-space: nowrap;
|
|
95
78
|
padding: var(--lr-size-0-0625rem) var(--lr-size-0-4375rem);
|
|
96
79
|
border-radius: var(--lr-radius-pill);
|
|
97
|
-
/* --lr-color-brand + -brand-quiet (not -text-quiet + -surface) --
|
|
98
|
-
this pill needs to read as distinct from the [part="header"]
|
|
99
|
-
background it sits on (also -surface as of the comment above), and
|
|
100
|
-
-brand on -brand-quiet is a pairing already relied on elsewhere in
|
|
101
|
-
this library (e.g. hover states below) that passes contrast, unlike
|
|
102
|
-
-text-quiet on -brand-quiet. */
|
|
103
80
|
background: var(--lr-color-brand-quiet);
|
|
104
81
|
color: var(--lr-color-brand);
|
|
105
82
|
font-size: var(--lr-size-0-6875rem);
|
|
@@ -107,9 +84,6 @@ import{css}from"lit";const styles=css`
|
|
|
107
84
|
text-transform: uppercase;
|
|
108
85
|
letter-spacing: var(--lr-size-0-02em);
|
|
109
86
|
}
|
|
110
|
-
/* Pushed to the end of the header whether or not filename/language
|
|
111
|
-
precede it -- margin-inline-start:auto works whether this is the first
|
|
112
|
-
flex child (copyable alone) or the last of several. */
|
|
113
87
|
[part='copy-button'] {
|
|
114
88
|
flex: 0 0 auto;
|
|
115
89
|
margin-inline-start: auto;
|
|
@@ -152,8 +126,6 @@ import{css}from"lit";const styles=css`
|
|
|
152
126
|
}
|
|
153
127
|
[part='body']:focus-visible {
|
|
154
128
|
outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);
|
|
155
|
-
/* Negative (inward) so the ring isn't clipped by this element's own
|
|
156
|
-
overflow:auto -- same reasoning as lr-virtual-list's [part="base"]. */
|
|
157
129
|
outline-offset: calc(-1 * var(--lr-focus-ring-offset));
|
|
158
130
|
}
|
|
159
131
|
[part='body'] lr-skeleton {
|
|
@@ -165,49 +137,23 @@ import{css}from"lit";const styles=css`
|
|
|
165
137
|
[part='pre'] {
|
|
166
138
|
margin: 0;
|
|
167
139
|
padding: var(--lr-space-s) var(--lr-space-m);
|
|
168
|
-
/* The body owns scrolling, so this descendant's painted box must grow to the longest
|
|
169
|
-
unwrapped line instead of stopping at the body's initially visible width. The 100%
|
|
170
|
-
minimum keeps short code filling the scrollport; max-content extends the background and
|
|
171
|
-
line-state painting through the full horizontal overflow range. */
|
|
172
140
|
box-sizing: border-box;
|
|
173
141
|
inline-size: max-content;
|
|
174
142
|
min-inline-size: 100%;
|
|
175
|
-
/* Source code is read left-to-right regardless of the surrounding document
|
|
176
|
-
direction -- like every code surface (VS Code, GitHub, devtools). Without
|
|
177
|
-
this, an ancestor dir="rtl" bidi-reorders each line (a trailing ';' jumps
|
|
178
|
-
to the visual start, an opening brace wraps to its own bottom line) and
|
|
179
|
-
right-aligns the block, making valid code look syntactically broken. The
|
|
180
|
-
header (filename/language/copy/toggle) is a separate part and still mirrors.
|
|
181
|
-
isolate keeps any RTL run *inside* a string/comment from leaking out and
|
|
182
|
-
reordering the surrounding code. Matches phone-input's calling-code and
|
|
183
|
-
terminal/stack-trace's own dir="ltr" content locks. */
|
|
184
143
|
direction: ltr;
|
|
185
144
|
unicode-bidi: isolate;
|
|
186
|
-
/* A default background so the plain-fallback path still reads as a
|
|
187
|
-
proper code block -- shiki's own inline background-color (part of the
|
|
188
|
-
generated-token-colors exception documented in code-block.ts's
|
|
189
|
-
tokenize()) silently overrides this the moment highlighting succeeds,
|
|
190
|
-
since an element's own style attribute always wins over an external
|
|
191
|
-
stylesheet rule at equal or lower specificity. */
|
|
192
145
|
background: var(--lr-color-surface);
|
|
193
146
|
font-family: var(--lr-code-block-font, var(--lr-font-mono));
|
|
194
147
|
font-size: inherit;
|
|
195
148
|
line-height: var(--lr-line-height-normal);
|
|
196
149
|
white-space: pre;
|
|
197
|
-
/* Tab width, defaulting to the same value as --lr-code-editor-tab-size so the editable surface
|
|
198
|
-
and the read-only ones agree on what a literal tab looks like. The default lives here as a
|
|
199
|
-
var() fallback rather than as a :host declaration: a :host rule is re-stamped on every
|
|
200
|
-
instance and shadows any inherited value, so a page- or container-level declaration could
|
|
201
|
-
never reach it. lr-markdown/lr-markdown-core carry the same fallback for their own code-block
|
|
202
|
-
part -- they are sibling custom elements, not descendants, so no single rule covers both.
|
|
203
|
-
Never written as an inline tab-size: shiki puts its own style attribute on the highlighted
|
|
204
|
-
<pre>, and an inline declaration is the one thing a host override cannot beat. */
|
|
205
150
|
tab-size: var(--lr-code-block-tab-size, 2);
|
|
206
151
|
}
|
|
207
152
|
[part='code'] {
|
|
153
|
+
display: grid;
|
|
208
154
|
font-family: inherit;
|
|
209
155
|
}
|
|
210
|
-
[part='pre']
|
|
156
|
+
[part='pre'] .line {
|
|
211
157
|
display: block;
|
|
212
158
|
}
|
|
213
159
|
[part='pre'] .line-number {
|
|
@@ -218,30 +164,13 @@ import{css}from"lit";const styles=css`
|
|
|
218
164
|
text-align: end;
|
|
219
165
|
user-select: none;
|
|
220
166
|
}
|
|
221
|
-
/* A highlighted line, from either highlight-lines or a line-range entry in highlights --
|
|
222
|
-
stamped identically by codeBlockLineTransformer (shiki path) and renderPlainCode() (plain
|
|
223
|
-
path). See the dark-mode block below for why this needs its own !important there.
|
|
224
|
-
|
|
225
|
-
--lr-code-block-highlighted-line-bg is an inline var() fallback rather than a :host
|
|
226
|
-
declaration, for the same reason --lr-code-block-active-line-outline-color below is: a :host
|
|
227
|
-
declaration is re-stamped on every instance and would shadow any ancestor/theme-level value,
|
|
228
|
-
which is exactly what a state-styling override hook must not do. Unset, it resolves to
|
|
229
|
-
--lr-color-warning-quiet -- byte-identical to before it existed. */
|
|
230
167
|
[part='pre'] [data-highlighted] {
|
|
231
168
|
background: var(--lr-code-block-highlighted-line-bg, var(--lr-color-warning-quiet));
|
|
232
169
|
}
|
|
233
|
-
/* The active highlight (highlights entry matching activeHighlightId) gets an outline on top of
|
|
234
|
-
any background -- inset so it doesn't add to the line's own box size.
|
|
235
|
-
|
|
236
|
-
--lr-code-block-active-line-outline-color is an inline var() fallback rather than a :host
|
|
237
|
-
declaration on purpose: a :host declaration is re-stamped on every instance and would shadow
|
|
238
|
-
any ancestor/theme-level value, which is exactly what a state-styling override hook must not
|
|
239
|
-
do. Unset, it resolves to --lr-color-brand -- byte-identical to before it existed. */
|
|
240
170
|
[part='pre'] [data-active] {
|
|
241
171
|
outline: var(--lr-border-width-thin) solid var(--lr-code-block-active-line-outline-color, var(--lr-color-brand));
|
|
242
172
|
outline-offset: calc(-1 * var(--lr-border-width-thin));
|
|
243
173
|
}
|
|
244
|
-
/* The gutter alone is interactive; source remains ordinary selectable text. */
|
|
245
174
|
[part='pre'] button.line-gutter {
|
|
246
175
|
display: inline-flex;
|
|
247
176
|
align-items: center;
|
|
@@ -258,10 +187,10 @@ import{css}from"lit";const styles=css`
|
|
|
258
187
|
text-align: start;
|
|
259
188
|
cursor: pointer;
|
|
260
189
|
}
|
|
261
|
-
|
|
190
|
+
[part='pre'] button.line-gutter:hover {
|
|
262
191
|
background: var(--lr-color-brand-quiet);
|
|
263
192
|
}
|
|
264
|
-
|
|
193
|
+
[part='pre'] button.line-gutter:active {
|
|
265
194
|
background: color-mix(
|
|
266
195
|
in oklab,
|
|
267
196
|
var(--lr-color-brand-quiet),
|
|
@@ -272,26 +201,6 @@ import{css}from"lit";const styles=css`
|
|
|
272
201
|
outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);
|
|
273
202
|
outline-offset: calc(-1 * var(--lr-focus-ring-offset));
|
|
274
203
|
}
|
|
275
|
-
/*
|
|
276
|
-
* Activates shiki's "dual themes" dark variant. codeToHtml() (see
|
|
277
|
-
* tokenize() in code-block.ts) renders every token with its *light* color
|
|
278
|
-
* as a plain inline color/background-color and its *dark* color stashed in
|
|
279
|
-
* the --shiki-dark/--shiki-dark-bg custom properties shiki itself defines
|
|
280
|
-
* inline on the same elements -- shiki's own documented pattern for
|
|
281
|
-
* toggling them is exactly this: an external stylesheet rule that
|
|
282
|
-
* reassigns color/background-color from those variables. This requires
|
|
283
|
-
* !important because an inline style="..." attribute always outranks an
|
|
284
|
-
* external stylesheet at any selector specificity short of !important --
|
|
285
|
-
* there's no other way for a page-level rule to override an element's own
|
|
286
|
-
* style attribute. This is the one legitimate exception to "every color is
|
|
287
|
-
* a --lr-* token" in this file: these values come from shiki's theme
|
|
288
|
-
* data, not this library's design tokens.
|
|
289
|
-
*/
|
|
290
|
-
/* Gated on [part='body'][data-dark-theme='true'] (kept live by the shared ThemeWatcher, off the
|
|
291
|
-
component's own resolved --lr-color-text/--lr-color-surface) rather
|
|
292
|
-
than the OS-level prefers-color-scheme media query directly -- a consumer who sets
|
|
293
|
-
--lr-theme-color-* explicitly, independent of the OS's own setting, must still get the dark
|
|
294
|
-
shiki theme, matching every other --lr-color-* token's consumer-overrides-first resolution. */
|
|
295
204
|
[part='body'][data-dark-theme='true'] [part='pre'],
|
|
296
205
|
[part='body'][data-dark-theme='true'] [part='pre'] span {
|
|
297
206
|
color: var(--shiki-dark, inherit) !important;
|
|
@@ -16,6 +16,17 @@ export { loadShikiHighlighterCore } from './shiki-types.js';
|
|
|
16
16
|
* one incrementally the first time a `language` value actually requests it.
|
|
17
17
|
*/
|
|
18
18
|
export declare function loadShikiHighlighter(): Promise<ShikiHighlighter | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Safely reports whether `lang` is already loaded into `hl`, tolerating a highlighter whose
|
|
21
|
+
* `getLoadedLanguages()` itself throws -- treated the same as "not loaded", which routes the
|
|
22
|
+
* caller into the existing unhighlighted-fallback path instead of throwing out of it.
|
|
23
|
+
* `loadShikiHighlighter()`/`loadShikiHighlighterCore()` already validate a highlighter's
|
|
24
|
+
* capability *shape* at load time, so `hl` here is never missing the method outright; this
|
|
25
|
+
* additionally tolerates a shape-valid peer whose method throws only when actually called (a
|
|
26
|
+
* load-time shape check alone cannot catch that). Shared by `loadShikiLanguage()` below and
|
|
27
|
+
* `<lr-code-block>`'s own synchronous per-render check in `syncHighlight()`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function shikiHasLoadedLanguage(hl: ShikiHighlighter, lang: string): boolean;
|
|
19
30
|
/**
|
|
20
31
|
* Ensures `lang` is loaded into `hl`, loading it on demand the first time
|
|
21
32
|
* it's requested rather than bundling every possible grammar up front —
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{GREYCAT_LANGUAGE}from"./greycat-language.js";import{SHIKI_DARK_THEME,SHIKI_LIGHT_THEME,normalizeShikiLanguage}from"./shiki-types.js";import{SHIKI_DARK_THEME as SHIKI_DARK_THEME2,SHIKI_LIGHT_THEME as SHIKI_LIGHT_THEME2,SHIKI_THEMES,normalizeShikiLanguage as normalizeShikiLanguage2}from"./shiki-types.js";import{loadShikiHighlighterCore}from"./shiki-types.js";let highlighter;const unsupportedLanguages=new Set,CUSTOM_LANGUAGES={gcl:GREYCAT_LANGUAGE,greycat:GREYCAT_LANGUAGE};function loadShikiHighlighter(){return highlighter||(highlighter=import("shiki").then(mod=>mod.createHighlighter({themes:[SHIKI_LIGHT_THEME,SHIKI_DARK_THEME],langs:[]})).catch(err=>(console.warn("<lr-code-block> needs the optional peer dependency `shiki` for syntax highlighting \u2014 install it with `pnpm add shiki`. Code still renders, just unhighlighted, without it:",err),null))),highlighter}async function loadShikiLanguage(hl,lang){const normalizedLanguage=normalizeShikiLanguage(lang);if(hl
|
|
1
|
+
import{GREYCAT_LANGUAGE}from"./greycat-language.js";import{SHIKI_DARK_THEME,SHIKI_LIGHT_THEME,isShikiHighlighter,normalizeShikiLanguage}from"./shiki-types.js";import{resolveOptionalPeerCapability}from"../../../internal/optional-peer-capabilities.js";import{SHIKI_DARK_THEME as SHIKI_DARK_THEME2,SHIKI_LIGHT_THEME as SHIKI_LIGHT_THEME2,SHIKI_THEMES,normalizeShikiLanguage as normalizeShikiLanguage2}from"./shiki-types.js";import{loadShikiHighlighterCore}from"./shiki-types.js";let highlighter;const unsupportedLanguages=new Set,CUSTOM_LANGUAGES={gcl:GREYCAT_LANGUAGE,greycat:GREYCAT_LANGUAGE};function isShikiModule(candidate){return(typeof candidate=="object"||typeof candidate=="function")&&candidate!==null&&typeof candidate.createHighlighter=="function"}function loadShikiHighlighter(){return highlighter||(highlighter=import("shiki").then(async mod=>{const shikiModule=resolveOptionalPeerCapability(mod,isShikiModule);if(!shikiModule)throw new Error("Invalid optional peer `shiki`: missing `createHighlighter` capability.");const instance=await shikiModule.createHighlighter({themes:[SHIKI_LIGHT_THEME,SHIKI_DARK_THEME],langs:[]});if(!isShikiHighlighter(instance))throw new Error("Invalid optional peer `shiki`: `createHighlighter()` did not produce a usable highlighter capability.");return instance}).catch(err=>(console.warn("<lr-code-block> needs the optional peer dependency `shiki` for syntax highlighting \u2014 install it with `pnpm add shiki`. Code still renders, just unhighlighted, without it:",err),null))),highlighter}function shikiHasLoadedLanguage(hl,lang){try{return hl.getLoadedLanguages().includes(lang)}catch{return!1}}async function loadShikiLanguage(hl,lang){const normalizedLanguage=normalizeShikiLanguage(lang);if(shikiHasLoadedLanguage(hl,normalizedLanguage))return!0;if(unsupportedLanguages.has(normalizedLanguage))return!1;try{return await hl.loadLanguage(CUSTOM_LANGUAGES[normalizedLanguage]??normalizedLanguage),!0}catch{return unsupportedLanguages.add(normalizedLanguage),!1}}export{SHIKI_DARK_THEME2 as SHIKI_DARK_THEME,SHIKI_LIGHT_THEME2 as SHIKI_LIGHT_THEME,SHIKI_THEMES,loadShikiHighlighter,loadShikiHighlighterCore,loadShikiLanguage,normalizeShikiLanguage2 as normalizeShikiLanguage,shikiHasLoadedLanguage};
|
|
@@ -14,6 +14,18 @@ export interface ShikiHighlighter {
|
|
|
14
14
|
* highlighter, but is constructed from application-supplied grammars.
|
|
15
15
|
*/
|
|
16
16
|
export type ShikiHighlighterCore = ShikiHighlighter;
|
|
17
|
+
/**
|
|
18
|
+
* Narrows an unknown value (the resolved output of `shiki`'s `createHighlighter()`/
|
|
19
|
+
* `createHighlighterCore()`) to the highlighter capability Lyra actually calls. Both
|
|
20
|
+
* `loadShikiHighlighter()` (`code-loader.ts`) and `loadShikiHighlighterCore()` below validate
|
|
21
|
+
* their built instance through this before caching/returning it, so a malformed or spoofed peer
|
|
22
|
+
* fails closed at load time -- resolving `null` with the documented warning -- instead of reaching
|
|
23
|
+
* `<lr-code-block>`/`<lr-markdown>`'s render path and throwing there. Exported so a call site that
|
|
24
|
+
* receives an already-resolved highlighter from elsewhere (e.g. `syncHighlight()`'s live
|
|
25
|
+
* per-language check) can also tolerate a shape-valid peer whose method throws only when actually
|
|
26
|
+
* invoked, which a load-time shape check alone cannot catch.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isShikiHighlighter(candidate: unknown): candidate is ShikiHighlighter;
|
|
17
29
|
/** The peer-neutral shape of a pre-imported TextMate grammar module's default export. */
|
|
18
30
|
export interface ShikiLanguageInput {
|
|
19
31
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const SHIKI_LIGHT_THEME="github-light",SHIKI_DARK_THEME="github-dark",SHIKI_THEMES={light:SHIKI_LIGHT_THEME,dark:SHIKI_DARK_THEME};function normalizeShikiLanguage(lang){return lang.trim().toLowerCase().replace(/^\./,"")}const highlighterCores=new WeakMap;let highlighterCoreLoaderForTesting;function __setShikiHighlighterCoreLoaderForTesting(loader){highlighterCoreLoaderForTesting=loader}function loadShikiHighlighterCore(languages){if(highlighterCoreLoaderForTesting)return highlighterCoreLoaderForTesting(languages);let cached=highlighterCores.get(languages);return cached||(cached=Promise.all([import("shiki/core"),import("shiki/engine/oniguruma"),import("shiki/themes/github-light.mjs"),import("shiki/themes/github-dark.mjs")]).then(([{createHighlighterCore},{createOnigurumaEngine},light,dark])=>createHighlighterCore({themes:[light.default,dark.default],langs:Object.values(languages),engine:createOnigurumaEngine(import("shiki/wasm"))})).catch(err=>(console.warn("<lr-code-block>'s `languages` property failed to build a fine-grained shiki highlighter \u2014 falling back to plain unhighlighted text for the languages it covers:",err),null)),highlighterCores.set(languages,cached)),cached}export{SHIKI_DARK_THEME,SHIKI_LIGHT_THEME,SHIKI_THEMES,__setShikiHighlighterCoreLoaderForTesting,loadShikiHighlighterCore,normalizeShikiLanguage};
|
|
1
|
+
function isShikiHighlighter(candidate){return(typeof candidate=="object"||typeof candidate=="function")&&candidate!==null&&typeof candidate.getLoadedLanguages=="function"&&typeof candidate.loadLanguage=="function"&&typeof candidate.codeToHtml=="function"}const SHIKI_LIGHT_THEME="github-light",SHIKI_DARK_THEME="github-dark",SHIKI_THEMES={light:SHIKI_LIGHT_THEME,dark:SHIKI_DARK_THEME};function normalizeShikiLanguage(lang){return lang.trim().toLowerCase().replace(/^\./,"")}const highlighterCores=new WeakMap;let highlighterCoreLoaderForTesting;function __setShikiHighlighterCoreLoaderForTesting(loader){highlighterCoreLoaderForTesting=loader}function loadShikiHighlighterCore(languages){if(highlighterCoreLoaderForTesting)return highlighterCoreLoaderForTesting(languages);let cached=highlighterCores.get(languages);return cached||(cached=Promise.all([import("shiki/core"),import("shiki/engine/oniguruma"),import("shiki/themes/github-light.mjs"),import("shiki/themes/github-dark.mjs")]).then(async([{createHighlighterCore},{createOnigurumaEngine},light,dark])=>{const core=await createHighlighterCore({themes:[light.default,dark.default],langs:Object.values(languages),engine:createOnigurumaEngine(import("shiki/wasm"))});if(!isShikiHighlighter(core))throw new Error("Invalid optional peer `shiki`: `createHighlighterCore()` did not produce a usable highlighter capability.");return core}).catch(err=>(console.warn("<lr-code-block>'s `languages` property failed to build a fine-grained shiki highlighter \u2014 falling back to plain unhighlighted text for the languages it covers:",err),null)),highlighterCores.set(languages,cached)),cached}export{SHIKI_DARK_THEME,SHIKI_LIGHT_THEME,SHIKI_THEMES,__setShikiHighlighterCoreLoaderForTesting,isShikiHighlighter,loadShikiHighlighterCore,normalizeShikiLanguage};
|
|
@@ -5,12 +5,6 @@ import{css}from"lit";const styles=css`
|
|
|
5
5
|
line-height: var(--lr-line-height-1-4);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
/* [part='base'] is a plain layout wrapper (no ARIA role of its own) --
|
|
9
|
-
the interactive/selectable region is [part='select-button'] alone, kept free
|
|
10
|
-
of focusable descendants (see the class doc's nested-interactive note).
|
|
11
|
-
The row-level hover/active background treatments still live here so
|
|
12
|
-
hovering anywhere across the row -- including over the trailing
|
|
13
|
-
rename/actions controls -- highlights the whole thing as one row. */
|
|
14
8
|
[part='base'] {
|
|
15
9
|
position: relative;
|
|
16
10
|
display: flex;
|
|
@@ -31,25 +25,6 @@ import{css}from"lit";const styles=css`
|
|
|
31
25
|
pointer-events: none;
|
|
32
26
|
z-index: var(--lr-layer-content);
|
|
33
27
|
}
|
|
34
|
-
/* Density escape -- same convention as lr-empty's compact. Conversation rows render in sidebar
|
|
35
|
-
lists, so the tuned values sit behind inline var() fallbacks (rather than a :host declaration,
|
|
36
|
-
which every instance re-declares and so shadows any ancestor value) letting a list retune every
|
|
37
|
-
row at once from the outside; the fallbacks are the pre-existing values scaled down one step, so
|
|
38
|
-
an unset row renders unchanged.
|
|
39
|
-
|
|
40
|
-
MUST stay before the :host([active]) rules below: :host([compact]) [part='base'] and
|
|
41
|
-
:host([active]) [part='base'] are equal specificity, so source order alone decides which wins
|
|
42
|
-
should either ever grow a declaration the other also sets. active is the stronger statement of
|
|
43
|
-
appearance ("this is the open session"), so it goes last.
|
|
44
|
-
|
|
45
|
-
Deliberately NOT changed by compact: [part='rename-button']'s min-inline-size/min-block-size
|
|
46
|
-
(the shared --lr-icon-button-size target floor -- a density flag must never silently opt a row
|
|
47
|
-
out of it; a consumer who really wants a sub-floor row lowers that token at an ancestor),
|
|
48
|
-
[part='start']'s min sizes, and the excerpt/timestamp font sizes (already the smallest steps
|
|
49
|
-
in use here; font size is retuned through the host's inherited font-size instead). The excerpt
|
|
50
|
-
also stays visible: it is already single-line ellipsised and ?hidden-bindable per row, so it
|
|
51
|
-
costs exactly one line -- hiding content is a per-row consumer decision, not a side effect of a
|
|
52
|
-
density flag. */
|
|
53
28
|
:host([compact]) [part='base'] {
|
|
54
29
|
padding: var(--lr-conversation-item-compact-padding, var(--lr-space-xs) var(--lr-space-s));
|
|
55
30
|
gap: var(--lr-conversation-item-compact-gap, var(--lr-space-2xs));
|
|
@@ -57,28 +32,20 @@ import{css}from"lit";const styles=css`
|
|
|
57
32
|
:host(:hover) [part='base'] {
|
|
58
33
|
background: color-mix(in srgb, var(--lr-color-text) 6%, transparent);
|
|
59
34
|
}
|
|
60
|
-
/* Pressed. Note the two very different selectors here: :host(:active) is the transient
|
|
61
|
-
pointer/keyboard press, :host([active]) below is "this is the open session". The press tint is
|
|
62
|
-
the hover tint escalated to --lr-color-mix-active, mixed toward --lr-color-mix-partner (which
|
|
63
|
-
tracks the text color) so it moves in the right direction on a light and a dark surface alike.
|
|
64
|
-
[part='base'] is a plain wrapper div, but :active propagates from the pressed [part='select-button']
|
|
65
|
-
inside it up through the host, so the whole row answers a press the way it answers hover. */
|
|
66
35
|
:host(:active) [part='base'] {
|
|
67
36
|
background: color-mix(in oklab, transparent, var(--lr-color-mix-partner) var(--lr-color-mix-active));
|
|
68
37
|
}
|
|
69
|
-
/* Placed after the :hover and :active rules (equal selector specificity) so an
|
|
70
|
-
active-and-hovered row keeps the stronger active tint instead of the
|
|
71
|
-
two backgrounds visually competing. */
|
|
72
38
|
:host([active]) [part='base'] {
|
|
73
39
|
background: var(--lr-conversation-item-active-bg, var(--lr-color-brand-quiet));
|
|
74
40
|
}
|
|
41
|
+
:host([active]:active) [part='base'] {
|
|
42
|
+
background: color-mix(
|
|
43
|
+
in oklab,
|
|
44
|
+
var(--lr-conversation-item-active-bg, var(--lr-color-brand-quiet)),
|
|
45
|
+
var(--lr-color-mix-partner) var(--lr-color-mix-active)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
75
48
|
|
|
76
|
-
/* text-quiet's contrast ratio against brand-quiet lands at ~4.25:1 --
|
|
77
|
-
just under the WCAG AA 4.5:1 floor for normal-size text -- even though
|
|
78
|
-
it comfortably passes against the plain (non-active) background used
|
|
79
|
-
the rest of the time. Same class of bug already hit and fixed in
|
|
80
|
-
lr-attachment-chip's [part='size'] and lr-chat-message's
|
|
81
|
-
[part='footer']; same fix, full-strength text color once active. */
|
|
82
49
|
:host([active]) [part='excerpt'],
|
|
83
50
|
:host([active]) [part='timestamp'] {
|
|
84
51
|
color: var(--lr-conversation-item-active-color, var(--lr-color-text));
|
|
@@ -91,7 +58,7 @@ import{css}from"lit";const styles=css`
|
|
|
91
58
|
flex: 1 1 auto;
|
|
92
59
|
min-inline-size: 0;
|
|
93
60
|
cursor: pointer;
|
|
94
|
-
outline: none;
|
|
61
|
+
outline: none;
|
|
95
62
|
-webkit-tap-highlight-color: transparent;
|
|
96
63
|
}
|
|
97
64
|
[part='start'] {
|
|
@@ -117,9 +84,6 @@ import{css}from"lit";const styles=css`
|
|
|
117
84
|
flex-direction: column;
|
|
118
85
|
gap: var(--lr-size-0-125rem);
|
|
119
86
|
}
|
|
120
|
-
/* The label/excerpt/meta column's own inter-row gap collapses entirely under compact -- the three
|
|
121
|
-
lines already carry their own line-height, so the extra hairline is the first thing to go. No
|
|
122
|
-
var() hatch here: this one has no smaller step left to retune to. */
|
|
123
87
|
:host([compact]) [part='content'] {
|
|
124
88
|
gap: 0;
|
|
125
89
|
}
|
|
@@ -158,13 +122,6 @@ import{css}from"lit";const styles=css`
|
|
|
158
122
|
color: var(--lr-color-text-quiet);
|
|
159
123
|
font-size: var(--lr-font-size-sm);
|
|
160
124
|
}
|
|
161
|
-
/* Needed because of the unconditional display: block above -- an author-origin declaration
|
|
162
|
-
always beats the UA stylesheet's [hidden] { display: none }, regardless of specificity, so
|
|
163
|
-
without this the ?hidden binding on [part='excerpt'] would be a visual no-op. Same reasoning
|
|
164
|
-
as [part='actions'][hidden] below, and mirrors lr-timeline-item's identical
|
|
165
|
-
[part='timestamp'][hidden] / [part='description'][hidden] rules for its own slot-wins-over-
|
|
166
|
-
property parts. [part='meta'] doesn't need the same override -- it has no author display
|
|
167
|
-
declaration of its own, so the UA stylesheet's default [hidden] handling already applies. */
|
|
168
125
|
[part='excerpt'][hidden] {
|
|
169
126
|
display: none;
|
|
170
127
|
}
|
|
@@ -178,9 +135,6 @@ import{css}from"lit";const styles=css`
|
|
|
178
135
|
font-variant-numeric: tabular-nums;
|
|
179
136
|
}
|
|
180
137
|
|
|
181
|
-
/* A conversation-item row has real room (unlike a compact chip pill) -- the rename button gets
|
|
182
|
-
the full shared --lr-icon-button-size floor directly, no capped/split-glyph compromise
|
|
183
|
-
needed. */
|
|
184
138
|
[part='rename-button'] {
|
|
185
139
|
flex: 0 0 auto;
|
|
186
140
|
display: inline-flex;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing,svg}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteCount,finiteRange}from"../../../internal/numbers.js";import{literalSetConverter}from"../../../internal/converters.js";import{styles}from"./generation-metrics.styles.js";import{getNumberFormat,getPluralRules}from"../../../internal/intl-cache.js";import{
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing,svg}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteCount,finiteRange}from"../../../internal/numbers.js";import{literalSetConverter}from"../../../internal/converters.js";import{styles}from"./generation-metrics.styles.js";import{getNumberFormat,getPluralRules}from"../../../internal/intl-cache.js";import{LYRA_DEFAULT_elapsedMinutesSecondsTemplate,LYRA_DEFAULT_generationStatusElapsedSeconds,LYRA_DEFAULT_generationStatusThroughput,LYRA_DEFAULT_generationStatusTokenCount,LYRA_DEFAULT_generationStatusTokensCount,LYRA_DEFAULT_stopGenerating}from"../../../internal/default-strings.generated.js";function stopIcon(){return svg`
|
|
2
2
|
<svg
|
|
3
3
|
width="1em"
|
|
4
4
|
height="1em"
|
|
@@ -8,7 +8,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
8
8
|
aria-hidden="true"
|
|
9
9
|
focusable="false"
|
|
10
10
|
><rect x="6" y="6" width="12" height="12" rx="1.5"></rect></svg>
|
|
11
|
-
`}function formatElapsed(ms,locale){const totalSeconds=Math.max(0,ms)/1e3;if(totalSeconds<59.95)return{key:"generationStatusElapsedSeconds",values:{seconds:getNumberFormat(locale,{minimumFractionDigits:1,maximumFractionDigits:1}).format(Math.round(totalSeconds*10)/10)}};const wholeSeconds=Math.round(totalSeconds),minutes=Math.floor(wholeSeconds/60),seconds=wholeSeconds%60,numberFormat=getNumberFormat(locale,{maximumFractionDigits:0});return{key:"elapsedMinutesSecondsTemplate",values:{minutes:numberFormat.format(minutes),seconds:numberFormat.format(seconds)}}}function formatTokenCount(count,locale){const rounded=Math.max(0,Math.round(count));return{rounded,formatted:getNumberFormat(locale).format(rounded)}}function formatThroughput(value,locale){const clamped=Math.max(0,value),rounded=clamped<10?Math.round(clamped*10)/10:Math.round(clamped);return getNumberFormat(locale,{maximumFractionDigits:clamped<10?1:0}).format(rounded)}const showStopConverter={fromAttribute(value){return value!=="false"},toAttribute(value){return value?null:"false"}},GENERATION_METRICS_STATUS=literalSetConverter(["idle","running","complete"],"idle");class LyraGenerationMetrics extends LyraElement{static{this.defaultStrings={...super.defaultStrings,
|
|
11
|
+
`}function formatElapsed(ms,locale){const totalSeconds=Math.max(0,ms)/1e3;if(totalSeconds<59.95)return{key:"generationStatusElapsedSeconds",values:{seconds:getNumberFormat(locale,{minimumFractionDigits:1,maximumFractionDigits:1}).format(Math.round(totalSeconds*10)/10)}};const wholeSeconds=Math.round(totalSeconds),minutes=Math.floor(wholeSeconds/60),seconds=wholeSeconds%60,numberFormat=getNumberFormat(locale,{maximumFractionDigits:0});return{key:"elapsedMinutesSecondsTemplate",values:{minutes:numberFormat.format(minutes),seconds:numberFormat.format(seconds)}}}function formatTokenCount(count,locale){const rounded=Math.max(0,Math.round(count));return{rounded,formatted:getNumberFormat(locale).format(rounded)}}function formatThroughput(value,locale){const clamped=Math.max(0,value),rounded=clamped<10?Math.round(clamped*10)/10:Math.round(clamped);return getNumberFormat(locale,{maximumFractionDigits:clamped<10?1:0}).format(rounded)}const showStopConverter={fromAttribute(value){return value!=="false"},toAttribute(value){return value?null:"false"}},GENERATION_METRICS_STATUS=literalSetConverter(["idle","running","complete"],"idle");class LyraGenerationMetrics extends LyraElement{static{this.defaultStrings={...super.defaultStrings,elapsedMinutesSecondsTemplate:LYRA_DEFAULT_elapsedMinutesSecondsTemplate,generationStatusElapsedSeconds:LYRA_DEFAULT_generationStatusElapsedSeconds,generationStatusThroughput:LYRA_DEFAULT_generationStatusThroughput,generationStatusTokenCount:LYRA_DEFAULT_generationStatusTokenCount,generationStatusTokensCount:LYRA_DEFAULT_generationStatusTokensCount,stopGenerating:LYRA_DEFAULT_stopGenerating}}static{this.styles=[LyraElement.styles,styles]}get status(){return this._status}set status(next){const normalized=GENERATION_METRICS_STATUS.normalize(next),old=this._status;old!==normalized&&(this._status=normalized,this.requestUpdate("status",old))}constructor(){super(),this._status="idle",this.showStop=!0,this.elapsedMs=0,this.tickerGeneration=0,this.onStopClick=()=>{this.emit("lr-stop",null)},this.requestUpdate("status",void 0)}connectedCallback(){super.connectedCallback(),this.status==="running"&&(this.elapsedMs=this.computeElapsedMs(),this.startTicker())}disconnectedCallback(){this.stopTicker(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.stopTicker(),this.isConnected&&this.status==="running"&&this.startTicker()}willUpdate(changed){super.willUpdate(changed),changed.has("status")?this.status==="running"?(this.validStartedAt==null&&(this.fallbackStartMs=Date.now()),this.elapsedMs=this.computeElapsedMs()):this.status==="idle"&&(this.fallbackStartMs=void 0,this.elapsedMs=0):this.status==="running"&&changed.has("startedAt")&&(this.validStartedAt==null?this.fallbackStartMs=Date.now()-this.elapsedMs:this.fallbackStartMs=void 0,this.elapsedMs=this.computeElapsedMs())}updated(changed){super.updated(changed),changed.has("status")&&(this.status==="running"?this.startTicker():this.stopTicker())}startTicker(){if(this.stopTicker(),!this.isConnected||this.status!=="running")return;const ownerDocument=this.ownerDocument,ownerWindow=ownerDocument.defaultView;if(!ownerWindow)return;const generation=this.tickerGeneration,handle=ownerWindow.setInterval(()=>{this.tickTimer!==handle||this.tickTimerOwner!==ownerWindow||this.tickTimerDocument!==ownerDocument||this.tickerGeneration!==generation||!this.isConnected||this.status!=="running"||this.ownerDocument!==ownerDocument||(this.elapsedMs=this.computeElapsedMs())},1e3);this.tickTimer=handle,this.tickTimerOwner=ownerWindow,this.tickTimerDocument=ownerDocument}stopTicker(){this.tickerGeneration+=1,this.tickTimer!==void 0&&this.tickTimerOwner?.clearInterval(this.tickTimer),this.tickTimer=void 0,this.tickTimerOwner=void 0,this.tickTimerDocument=void 0}get validStartedAt(){if(!(this.startedAt==null||!Number.isFinite(this.startedAt)))return finiteRange(this.startedAt,this.startedAt,0)}computeElapsedMs(){const start=this.validStartedAt??this.fallbackStartMs;return start==null?0:Math.max(0,Date.now()-start)}get validTokenCount(){if(!(this.tokenCount==null||!Number.isFinite(this.tokenCount)))return finiteCount(Math.round(this.tokenCount))}get effectiveTokensPerSecond(){if(this.tokensPerSecond!=null&&Number.isFinite(this.tokensPerSecond))return finiteRange(this.tokensPerSecond,this.tokensPerSecond,0);const tokenCount=this.validTokenCount;if(tokenCount!==void 0){const elapsedSeconds=this.elapsedMs/1e3;if(elapsedSeconds>=1)return tokenCount/elapsedSeconds}}render(){const validTokenCount=this.validTokenCount,hasTokens=validTokenCount!==void 0,throughput=this.effectiveTokensPerSecond,hasThroughput=throughput!==void 0,locale=this.effectiveLocale,elapsed=formatElapsed(this.elapsedMs,locale),tokenCount=hasTokens?formatTokenCount(validTokenCount,locale):void 0,tokenMessageKey=tokenCount&&getPluralRules(locale).select(tokenCount.rounded)==="one"?"generationStatusTokenCount":"generationStatusTokensCount";return html`
|
|
12
12
|
<div part="base">
|
|
13
13
|
<span part="elapsed">${this.localize(elapsed.key,void 0,elapsed.values)}</span>
|
|
14
14
|
${hasTokens?html`<span part="tokens"
|
|
@@ -17,10 +17,6 @@ import{css}from"lit";const styles=css`
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
[part='elapsed'] {
|
|
20
|
-
/* Full-strength text, not the quieter --lr-color-text-quiet the rest
|
|
21
|
-
of the readout uses -- elapsed time is the one figure this component
|
|
22
|
-
always shows (tokens/throughput are optional), so it gets the higher-
|
|
23
|
-
contrast treatment to read as the primary value at a glance. */
|
|
24
20
|
color: var(--lr-color-text);
|
|
25
21
|
font-variant-numeric: tabular-nums;
|
|
26
22
|
white-space: nowrap;
|
|
@@ -32,11 +28,6 @@ import{css}from"lit";const styles=css`
|
|
|
32
28
|
overflow-wrap: anywhere;
|
|
33
29
|
}
|
|
34
30
|
|
|
35
|
-
/* Segments are joined with a middot rather than a flex gap + separate
|
|
36
|
-
separator element, so a segment that doesn't render (tokens/throughput
|
|
37
|
-
are both optional, see the class doc) never leaves a dangling
|
|
38
|
-
double-gap -- the dot only ever appears immediately before a segment
|
|
39
|
-
that's actually present. */
|
|
40
31
|
[part='tokens']::before,
|
|
41
32
|
[part='throughput']::before {
|
|
42
33
|
content: '·';
|
|
@@ -49,11 +40,6 @@ import{css}from"lit";const styles=css`
|
|
|
49
40
|
display: inline-flex;
|
|
50
41
|
align-items: center;
|
|
51
42
|
justify-content: center;
|
|
52
|
-
/* Meets the shared minimum tappable size (--lr-icon-button-size) --
|
|
53
|
-
previously shrunk below the floor (min(...) capped at 1.75rem/28px)
|
|
54
|
-
for a compact inline look, but the readout row has no width
|
|
55
|
-
constraint that requires it, so the full 40px floor applies
|
|
56
|
-
directly instead of via invisible hit-slop. */
|
|
57
43
|
min-inline-size: var(--lr-icon-button-size);
|
|
58
44
|
min-block-size: var(--lr-icon-button-size);
|
|
59
45
|
margin-inline-start: var(--lr-space-s);
|
|
@@ -73,9 +59,6 @@ import{css}from"lit";const styles=css`
|
|
|
73
59
|
border-color: var(--lr-color-brand);
|
|
74
60
|
color: var(--lr-color-brand);
|
|
75
61
|
}
|
|
76
|
-
/* Hover recolors the chrome only; the press additionally fills the disc, mixing its resting
|
|
77
|
-
surface toward the text color so the pressed state escalates the hover one instead of
|
|
78
|
-
replacing it with an unrelated color. */
|
|
79
62
|
[part='stop-button']:active {
|
|
80
63
|
border-color: var(--lr-color-brand);
|
|
81
64
|
color: var(--lr-color-brand);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import"lit";import{state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteInteger}from"../../../internal/numbers.js";import{DocumentAnchorTarget}from"../../../internal/anchor-target.js";import{buildQuoteAnchor,createTextQuoteIndex,scopeFromElement}from"../../../internal/text-quote.js";import{acquireHighlightHandle,supportsCustomHighlights}from"../../../internal/text-highlights.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{addFailedHighlightKey,applyMarkdownAriaBusy,applyMarkdownFragmentAnchor,applyMarkdownTextQuoteAnchor,beginMarkdownDepsLoad,getCachedHighlight,hitTestHighlightRanges,HIGHLIGHT_CACHE_MAX,internalLinkHrefFrom,markdownHighlightConfigChanged,markdownLanguageSetChanged,markdownMathPeerError,markdownNeedsReparse,MarkdownOwnedAnimationFrameController,MarkdownParserController,normalizeMarkdownHtmlMode,normalizeMarkdownLeadingTabs,parseMarkdownDocument,processPendingHighlights,renderMarkdownContent,renderMarkdownDocument,repaintMarkdownHighlights,resolveMarkdownDarkTheme,setCachedHighlight}from"./markdown-shared.js";import{LYRA_DEFAULT_anchorJumped,LYRA_DEFAULT_anchorJumpedToPage,LYRA_DEFAULT_anchorNotFound}from"../../../internal/default-strings.generated.js";class LyraMarkdownRuntimeElement extends LyraElement{static{this.defaultStrings={...super.defaultStrings,anchorJumped:LYRA_DEFAULT_anchorJumped,anchorJumpedToPage:LYRA_DEFAULT_anchorJumpedToPage,anchorNotFound:LYRA_DEFAULT_anchorNotFound}}}function createMarkdownVariantContext(tag,katexState){return{tag,connectedInstances:new Set,sharedParser:new MarkdownParserController,katexState}}class MarkdownRuntimeBase extends DocumentAnchorTarget(LyraMarkdownRuntimeElement){constructor(){super(),this.anchorKinds=["fragment","text-quote"],this.renderedHtml=null,this.isDarkTheme=!1,this.parser=new MarkdownParserController,this.headingTree=[],this.markdownTextScopeBuilds=0,this.resolvedHighlightRanges=[],this.mathFailureReported=!1,this.highlightCache=new Map,this.highlightToken=0,this.streamingRenderFrames=new MarkdownOwnedAnimationFrameController,this.failedHighlightKeys=new Set,this.inFlightHighlightKeys=new Set,this.handleKatexResolved=()=>{this.isConnected&&this.renderMarkdown()},this.onContentClick=event=>{const highlightId=hitTestHighlightRanges(this.resolvedHighlightRanges,event.clientX,event.clientY);if(highlightId){this.emit("lr-highlight-activate",{highlightId});return}const href=internalLinkHrefFrom(event,this.internalLinkPrefix);href!==null&&(event.preventDefault(),this.emit("lr-link-click",{href}))},new ThemeWatcher(this,()=>this.refreshTheme())}get marked(){return this.parser.get(this.deps?.marked)}refreshTheme(){this.isDarkTheme=resolveMarkdownDarkTheme(this)}connectedCallback(){super.connectedCallback(),this.markdownVariant.connectedInstances.add(this),this.refreshTheme(),beginMarkdownDepsLoad(this,resolved=>{this.deps=resolved,this.renderMarkdown()})}disconnectedCallback(){this.markdownVariant.connectedInstances.delete(this),super.disconnectedCallback(),this.highlightToken++,this.cancelStreamingRender(),this.highlightHandle?.release(),this.highlightHandle=void 0,this.textQuoteIndexCache=void 0}adoptedCallback(){super.adoptedCallback(),this.cancelStreamingRender()}firstUpdated(changed){super.firstUpdated(changed);const contentRoot=this.renderRoot.querySelector('[part="content"]');contentRoot&&this.bindTextSelection(contentRoot)}willUpdate(changed){if(super.willUpdate(changed),changed.has("math")&&(this.mathFailureReported=!1),!this.deps||!markdownNeedsReparse(changed))return;if((changed.has("content")||changed.has("streaming")||markdownHighlightConfigChanged(changed))&&this.highlightToken++,markdownHighlightConfigChanged(changed)&&(this.failedHighlightKeys.clear(),markdownLanguageSetChanged(changed)&&this.highlightCache.clear()),this.streaming){this.scheduleStreamingRender();return}this.cancelStreamingRender(),this.renderMarkdown()}cancelStreamingRender(){const handle=this.streamingRenderRaf;this.streamingRenderRaf=void 0,!this.streamingRenderFrames.cancel()&&handle!==void 0&&this.ownerDocument.defaultView?.cancelAnimationFrame(handle)}scheduleStreamingRender(){if(this.streamingRenderRaf!==void 0)return;const view=this.ownerDocument.defaultView;if(!view){this.isConnected&&this.renderMarkdown();return}const handle=this.streamingRenderFrames.request(view,()=>{this.streamingRenderRaf=void 0,this.isConnected&&this.ownerDocument.defaultView===view&&this.renderMarkdown()});handle===void 0?this.isConnected&&this.renderMarkdown():this.streamingRenderFrames.handle===handle&&(this.streamingRenderRaf=handle)}async getUpdateComplete(){const complete=await super.getUpdateComplete(),settled=this.streamingRenderFrames.settled;return settled?(await settled,super.getUpdateComplete()):complete}updated(changed){super.updated(changed),applyMarkdownAriaBusy(this,!this.deps||this.streaming);const locale=this.effectiveLocale,localeChanged=this.textQuoteLocale!==void 0&&this.textQuoteLocale!==locale;this.textQuoteLocale=locale,localeChanged&&(this.textQuoteIndexCache=void 0),changed.has("renderedHtml")&&(this.textQuoteIndexCache=void 0),(changed.has("renderedHtml")||changed.has("highlights")||changed.has("activeHighlightId")||localeChanged&&this.highlights.length>0)&&this.repaintHighlights()}renderMarkdown(){if(this.streaming){this.renderedHtml=null,this.headingTree=[];return}const deps=this.deps;if(!deps)return;const variant=this.markdownVariant,outcome=renderMarkdownDocument({tag:variant.tag,deps,htmlMode:normalizeMarkdownHtmlMode(this.htmlMode),math:this.math,parse:(marked,pendingKeys,headingTreeOut)=>this.parseMarkdown(marked,pendingKeys,headingTreeOut),onParsed:()=>this.maybeLoadKatex(),isKatexConfirmedMissing:()=>variant.katexState.isConfirmedMissing()});if(outcome.headingTree&&(this.headingTree=outcome.headingTree),outcome.status==="fallback"){this.renderedHtml=null,this.emit("lr-render-error",{error:outcome.error});return}this.renderedHtml=outcome.html,outcome.mathFailed&&this.reportMathFailure(),outcome.pendingKeys.length>0&&this.highlightCode&&!this.streaming&&this.highlightPending(outcome.pendingKeys)}maybeLoadKatex(){this.math&&this.markdownVariant.katexState.startLoad(this.handleKatexResolved)}reportMathFailure(){this.mathFailureReported||(this.mathFailureReported=!0,this.emit("lr-render-error",{error:markdownMathPeerError(this.markdownVariant.tag)}))}getCachedHighlight(key){return getCachedHighlight(this.highlightCache,key)}setCachedHighlight(key,html){return setCachedHighlight(this.highlightCache,key,html,HIGHLIGHT_CACHE_MAX)}async highlightPending(pendingKeys){const work=pendingKeys.filter(({key})=>!this.inFlightHighlightKeys.has(key));if(work.length===0)return;for(const{key}of work)this.inFlightHighlightKeys.add(key);const token=this.highlightToken,languages=this.languages,isCurrent=()=>token===this.highlightToken&&this.isConnected,tokenizeOne=async pending=>{const html=await this.tokenizePendingHighlight(pending,languages,isCurrent);!isCurrent()||html===void 0||(html===null||!this.setCachedHighlight(pending.key,html))&&addFailedHighlightKey(this.failedHighlightKeys,pending.key)};try{await processPendingHighlights(work,tokenizeOne)}finally{for(const{key}of work)this.inFlightHighlightKeys.delete(key)}this.isConnected&&this.renderMarkdown()}parseMarkdown(marked,pendingKeys,headingTreeOut){const variant=this.markdownVariant;return parseMarkdownDocument({marked,content:normalizeMarkdownLeadingTabs(this.content,finiteInteger(this.tabSize,4,1,32)),markedConfigurations:[variant.sharedParser.get(marked)?.defaults,this.marked?.defaults],gfm:this.gfm,linkTarget:this.linkTarget,headingOffset:finiteInteger(this.headingOffset,0,0,6),escapeHtmlOption:normalizeMarkdownHtmlMode(this.htmlMode)==="escape",trustedHtmlOption:normalizeMarkdownHtmlMode(this.htmlMode)==="trusted",highlightCodeOption:this.highlightCode&&!this.streaming,getCachedHighlight:key=>this.getCachedHighlight(key),failedHighlightKeys:this.failedHighlightKeys,headingAnchorsOption:this.headingAnchors,mathOption:this.math,cachedKatex:this.math?variant.katexState.getIfLoaded():null,pendingKeys,headingTreeOut})}getHeadingTree(){return[...this.headingTree]}contentRoot(){return this.renderRoot.querySelector('[part="content"]')}async applyAnchor(anchor){const root=this.contentRoot();if(!root)return!1;if(anchor.kind==="fragment")return applyMarkdownFragmentAnchor(root,anchor,this.headingTree);if(anchor.kind==="text-quote"){const index=this.markdownTextIndex(root),found=applyMarkdownTextQuoteAnchor(root,anchor,this.effectiveLocale,index);return!supportsCustomHighlights(this.ownerDocument)&&this.highlights.length>0&&this.repaintHighlights(),found}return!1}computeSelectionAnchor(range){const root=this.contentRoot();if(!root)return null;const anchor=buildQuoteAnchor(range,this.markdownTextIndex(root).scope);return!supportsCustomHighlights(this.ownerDocument)&&this.highlights.length>0&&this.scheduleAfterUpdate(()=>this.repaintHighlights()),anchor}ensureHighlightHandle(){return this.highlightHandle??=acquireHighlightHandle(this,this.ownerDocument),this.highlightHandle}markdownTextIndex(root){const locale=this.effectiveLocale,cached=this.textQuoteIndexCache;if(cached?.root===root&&cached.locale===locale&&!cached.mappingDirty)return cached.index;if(cached?.mappingDirty){const handle=this.ensureHighlightHandle();for(const tone of["accent","success","warning","danger","neutral"])handle.setRanges(tone,[]);handle.setActive(null)}const scope=scopeFromElement(root);if(this.markdownTextScopeBuilds++,cached?.root===root&&cached.locale===locale&&cached.index.rebindScope(scope))return cached.mappingDirty=!1,cached.index;const index=createTextQuoteIndex(scope,locale);return this.textQuoteIndexCache={root,locale,index,mappingDirty:!1},index}markdownTextScopeBuildCount(){return this.markdownTextScopeBuilds}markdownTextQuoteScanCount(){return this.textQuoteIndexCache?.index.scanCount??0}repaintHighlights(){this.resolvedHighlightRanges=[];const root=this.contentRoot();if(!root)return;const index=this.markdownTextIndex(root);this.resolvedHighlightRanges=repaintMarkdownHighlights({locale:this.effectiveLocale,root,handle:this.ensureHighlightHandle(),highlights:this.highlights,activeHighlightId:this.activeHighlightId,index}),!supportsCustomHighlights(this.ownerDocument)&&this.textQuoteIndexCache&&(this.textQuoteIndexCache.mappingDirty=!0)}render(){return renderMarkdownContent({content:this.content,sanitized:normalizeMarkdownHtmlMode(this.htmlMode)==="sanitize",renderedHtml:this.renderedHtml,hostAriaLabel:this.getAttribute("aria-label"),isDarkTheme:this.isDarkTheme,onClick:this.onContentClick,liveRegion:this.renderAnchorLiveRegion()})}}__decorate([state()],MarkdownRuntimeBase.prototype,"renderedHtml",void 0),__decorate([state()],MarkdownRuntimeBase.prototype,"isDarkTheme",void 0);export{MarkdownRuntimeBase,createMarkdownVariantContext};
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import"lit";import{state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteInteger}from"../../../internal/numbers.js";import{DocumentAnchorTarget}from"../../../internal/anchor-target.js";import{buildQuoteAnchor,createTextQuoteIndex,scopeFromElement}from"../../../internal/text-quote.js";import{acquireHighlightHandle,supportsCustomHighlights}from"../../../internal/text-highlights.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{addFailedHighlightKey,applyMarkdownAriaBusy,applyMarkdownFragmentAnchor,applyMarkdownTextQuoteAnchor,beginMarkdownDepsLoad,getCachedHighlight,hitTestHighlightRanges,HIGHLIGHT_CACHE_MAX,internalLinkHrefFrom,markdownHighlightConfigChanged,markdownLanguageSetChanged,markdownMathPeerError,markdownNeedsReparse,MarkdownOwnedAnimationFrameController,MarkdownParserController,normalizeMarkdownHtmlMode,normalizeMarkdownLeadingTabs,parseMarkdownDocument,processPendingHighlights,renderMarkdownContent,renderMarkdownDocument,repaintMarkdownHighlights,resolveMarkdownDarkTheme,setCachedHighlight}from"./markdown-shared.js";import{LYRA_DEFAULT_anchorJumped,LYRA_DEFAULT_anchorJumpedToPage,LYRA_DEFAULT_anchorNotFound}from"../../../internal/default-strings.generated.js";class LyraMarkdownRuntimeElement extends LyraElement{static{this.defaultStrings={...super.defaultStrings,anchorJumped:LYRA_DEFAULT_anchorJumped,anchorJumpedToPage:LYRA_DEFAULT_anchorJumpedToPage,anchorNotFound:LYRA_DEFAULT_anchorNotFound}}}function createMarkdownVariantContext(tag,katexState){return{tag,connectedInstances:new Set,sharedParser:new MarkdownParserController,katexState}}class MarkdownRuntimeBase extends DocumentAnchorTarget(LyraMarkdownRuntimeElement){constructor(){super(),this.anchorKinds=["fragment","text-quote"],this.renderedHtml=null,this.isDarkTheme=!1,this.parser=new MarkdownParserController,this.headingTree=[],this.markdownTextScopeBuilds=0,this.resolvedHighlightRanges=[],this.mathFailureReported=!1,this.highlightCache=new Map,this.highlightToken=0,this.streamingRenderFrames=new MarkdownOwnedAnimationFrameController,this.failedHighlightKeys=new Set,this.inFlightHighlightKeys=new Set,this.handleKatexResolved=()=>{this.isConnected&&this.renderMarkdown()},this.onContentClick=event=>{const highlightId=hitTestHighlightRanges(this.resolvedHighlightRanges,event.clientX,event.clientY);if(highlightId){this.emit("lr-highlight-activate",{highlightId});return}const href=internalLinkHrefFrom(event,this.internalLinkPrefix);href!==null&&(event.preventDefault(),this.emit("lr-link-click",{href}))},new ThemeWatcher(this,()=>this.refreshTheme())}get marked(){return this.parser.get(this.deps?.marked)}refreshTheme(){this.isDarkTheme=resolveMarkdownDarkTheme(this)}connectedCallback(){super.connectedCallback(),this.markdownVariant.connectedInstances.add(this),this.refreshTheme(),beginMarkdownDepsLoad(this,resolved=>{this.deps=resolved,this.renderMarkdown()})}disconnectedCallback(){this.markdownVariant.connectedInstances.delete(this),super.disconnectedCallback(),this.highlightToken++,this.cancelStreamingRender(),this.highlightHandle?.release(),this.highlightHandle=void 0,this.textQuoteIndexCache=void 0}adoptedCallback(){super.adoptedCallback(),this.cancelStreamingRender()}firstUpdated(changed){super.firstUpdated(changed);const contentRoot=this.renderRoot.querySelector('[part="content"]');contentRoot&&this.bindTextSelection(contentRoot)}willUpdate(changed){if(super.willUpdate(changed),changed.has("math")&&(this.mathFailureReported=!1),!this.deps||!markdownNeedsReparse(changed))return;if((changed.has("content")||changed.has("streaming")||markdownHighlightConfigChanged(changed))&&this.highlightToken++,markdownHighlightConfigChanged(changed)&&(this.failedHighlightKeys.clear(),markdownLanguageSetChanged(changed)&&this.highlightCache.clear()),this.streaming){this.scheduleStreamingRender();return}this.cancelStreamingRender(),this.renderMarkdown()}cancelStreamingRender(){const handle=this.streamingRenderRaf;this.streamingRenderRaf=void 0,!this.streamingRenderFrames.cancel()&&handle!==void 0&&this.ownerDocument.defaultView?.cancelAnimationFrame(handle)}scheduleStreamingRender(){if(this.streamingRenderRaf!==void 0)return;const view=this.ownerDocument.defaultView;if(!view){this.isConnected&&this.renderMarkdown();return}const handle=this.streamingRenderFrames.request(view,()=>{this.streamingRenderRaf=void 0,this.isConnected&&this.ownerDocument.defaultView===view&&this.renderMarkdown()});handle===void 0?this.isConnected&&this.renderMarkdown():this.streamingRenderFrames.handle===handle&&(this.streamingRenderRaf=handle)}async getUpdateComplete(){const complete=await super.getUpdateComplete(),settled=this.streamingRenderFrames.settled;return settled?(await settled,super.getUpdateComplete()):complete}updated(changed){super.updated(changed),applyMarkdownAriaBusy(this,!this.deps||this.streaming);const locale=this.effectiveLocale,localeChanged=this.textQuoteLocale!==void 0&&this.textQuoteLocale!==locale;this.textQuoteLocale=locale,localeChanged&&(this.textQuoteIndexCache=void 0),changed.has("renderedHtml")&&(this.textQuoteIndexCache=void 0),(changed.has("renderedHtml")||changed.has("highlights")||changed.has("activeHighlightId")||localeChanged&&this.highlights.length>0)&&this.repaintHighlights()}renderMarkdown(){if(this.streaming){this.renderedHtml=null,this.headingTree=[];return}const deps=this.deps;if(!deps)return;const variant=this.markdownVariant,outcome=renderMarkdownDocument({tag:variant.tag,deps,htmlMode:normalizeMarkdownHtmlMode(this.htmlMode),math:this.math,parse:(marked,pendingKeys,headingTreeOut)=>this.parseMarkdown(marked,pendingKeys,headingTreeOut),onParsed:()=>this.maybeLoadKatex(),isKatexConfirmedMissing:()=>variant.katexState.isConfirmedMissing()});if(outcome.headingTree&&(this.headingTree=outcome.headingTree),outcome.status==="fallback"){this.renderedHtml=null,this.emit("lr-render-error",{error:outcome.error});return}this.renderedHtml=outcome.html,outcome.mathFailed&&this.reportMathFailure(),outcome.pendingKeys.length>0&&this.highlightCode&&!this.streaming&&this.highlightPending(outcome.pendingKeys)}maybeLoadKatex(){this.math&&this.markdownVariant.katexState.startLoad(this.handleKatexResolved)}reportMathFailure(){this.mathFailureReported||(this.mathFailureReported=!0,this.emit("lr-render-error",{error:markdownMathPeerError(this.markdownVariant.tag)}))}getCachedHighlight(key){return getCachedHighlight(this.highlightCache,key)}setCachedHighlight(key,html){return setCachedHighlight(this.highlightCache,key,html,HIGHLIGHT_CACHE_MAX)}async highlightPending(pendingKeys){const work=pendingKeys.filter(({key})=>!this.inFlightHighlightKeys.has(key));if(work.length===0)return;for(const{key}of work)this.inFlightHighlightKeys.add(key);const token=this.highlightToken,languages=this.languages,isCurrent=()=>token===this.highlightToken&&this.isConnected,tokenizeOne=async pending=>{const html=await this.tokenizePendingHighlight(pending,languages,isCurrent);!isCurrent()||html===void 0||(html===null||!this.setCachedHighlight(pending.key,html))&&addFailedHighlightKey(this.failedHighlightKeys,pending.key)};try{await processPendingHighlights(work,tokenizeOne)}catch(error){console.warn("<lr-markdown>/<lr-markdown-core> failed to tokenize a pending highlight:",error)}finally{for(const{key}of work)this.inFlightHighlightKeys.delete(key)}this.isConnected&&this.renderMarkdown()}parseMarkdown(marked,pendingKeys,headingTreeOut){const variant=this.markdownVariant;return parseMarkdownDocument({marked,content:normalizeMarkdownLeadingTabs(this.content,finiteInteger(this.tabSize,4,1,32)),markedConfigurations:[variant.sharedParser.get(marked)?.defaults,this.marked?.defaults],gfm:this.gfm,linkTarget:this.linkTarget,headingOffset:finiteInteger(this.headingOffset,0,0,6),escapeHtmlOption:normalizeMarkdownHtmlMode(this.htmlMode)==="escape",trustedHtmlOption:normalizeMarkdownHtmlMode(this.htmlMode)==="trusted",highlightCodeOption:this.highlightCode&&!this.streaming,getCachedHighlight:key=>this.getCachedHighlight(key),failedHighlightKeys:this.failedHighlightKeys,headingAnchorsOption:this.headingAnchors,mathOption:this.math,cachedKatex:this.math?variant.katexState.getIfLoaded():null,pendingKeys,headingTreeOut})}getHeadingTree(){return[...this.headingTree]}contentRoot(){return this.renderRoot.querySelector('[part="content"]')}async applyAnchor(anchor){const root=this.contentRoot();if(!root)return!1;if(anchor.kind==="fragment")return applyMarkdownFragmentAnchor(root,anchor,this.headingTree);if(anchor.kind==="text-quote"){const index=this.markdownTextIndex(root),found=applyMarkdownTextQuoteAnchor(root,anchor,this.effectiveLocale,index);return!supportsCustomHighlights(this.ownerDocument)&&this.highlights.length>0&&this.repaintHighlights(),found}return!1}computeSelectionAnchor(range){const root=this.contentRoot();if(!root)return null;const anchor=buildQuoteAnchor(range,this.markdownTextIndex(root).scope);return!supportsCustomHighlights(this.ownerDocument)&&this.highlights.length>0&&this.scheduleAfterUpdate(()=>this.repaintHighlights()),anchor}ensureHighlightHandle(){return this.highlightHandle??=acquireHighlightHandle(this,this.ownerDocument),this.highlightHandle}markdownTextIndex(root){const locale=this.effectiveLocale,cached=this.textQuoteIndexCache;if(cached?.root===root&&cached.locale===locale&&!cached.mappingDirty)return cached.index;if(cached?.mappingDirty){const handle=this.ensureHighlightHandle();for(const tone of["accent","success","warning","danger","neutral"])handle.setRanges(tone,[]);handle.setActive(null)}const scope=scopeFromElement(root);if(this.markdownTextScopeBuilds++,cached?.root===root&&cached.locale===locale&&cached.index.rebindScope(scope))return cached.mappingDirty=!1,cached.index;const index=createTextQuoteIndex(scope,locale);return this.textQuoteIndexCache={root,locale,index,mappingDirty:!1},index}markdownTextScopeBuildCount(){return this.markdownTextScopeBuilds}markdownTextQuoteScanCount(){return this.textQuoteIndexCache?.index.scanCount??0}repaintHighlights(){this.resolvedHighlightRanges=[];const root=this.contentRoot();if(!root)return;const index=this.markdownTextIndex(root);this.resolvedHighlightRanges=repaintMarkdownHighlights({locale:this.effectiveLocale,root,handle:this.ensureHighlightHandle(),highlights:this.highlights,activeHighlightId:this.activeHighlightId,index}),!supportsCustomHighlights(this.ownerDocument)&&this.textQuoteIndexCache&&(this.textQuoteIndexCache.mappingDirty=!0)}render(){return renderMarkdownContent({content:this.content,sanitized:normalizeMarkdownHtmlMode(this.htmlMode)==="sanitize",renderedHtml:this.renderedHtml,hostAriaLabel:this.getAttribute("aria-label"),isDarkTheme:this.isDarkTheme,onClick:this.onContentClick,liveRegion:this.renderAnchorLiveRegion()})}}__decorate([state()],MarkdownRuntimeBase.prototype,"renderedHtml",void 0),__decorate([state()],MarkdownRuntimeBase.prototype,"isDarkTheme",void 0);export{MarkdownRuntimeBase,createMarkdownVariantContext};
|