@aceshooting/lyra-ui 9.1.1 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +785 -0
- package/custom-elements.json +1 -1
- package/design-tokens.json +13 -0
- package/dist/cli/migrate-wa.mjs +216 -1
- 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.class.d.ts +27 -0
- package/dist/components/charts/chart/box-plot.class.js +14 -4
- package/dist/components/charts/chart/box-plot.styles.js +28 -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 +120 -0
- package/dist/components/charts/chart/chart.class.js +16 -6
- package/dist/components/charts/chart/chart.styles.js +28 -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 +117 -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.d.ts +71 -3
- package/dist/components/forms/combobox/combobox.class.js +5 -3
- package/dist/components/forms/combobox/combobox.styles.js +31 -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 +47 -0
- package/dist/components/forms/date-picker/date-picker.class.js +36 -22
- package/dist/components/forms/date-picker/date-picker.styles.js +82 -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 +23 -1
- 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 +178 -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 +32 -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 +28 -4
- 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 +72 -40
- 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 +20 -113
- package/dist/lyra.d.ts +9 -6
- package/dist/styles/reservations.css +82 -0
- package/dist/svelte.d.ts +72 -40
- 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 +72 -40
- 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 +8 -6
- package/llms/components/lr-box-plot.md +15 -4
- package/llms/components/lr-browser-frame.md +7 -3
- package/llms/components/lr-bubble-chart.md +8 -6
- package/llms/components/lr-calendar.md +9 -2
- package/llms/components/lr-card.md +24 -0
- package/llms/components/lr-chart.md +45 -11
- 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 +47 -8
- 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-date-input.md +22 -2
- package/llms/components/lr-date-picker.md +23 -3
- package/llms/components/lr-details.md +11 -2
- package/llms/components/lr-dialog.md +16 -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 +8 -6
- 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 +30 -8
- package/llms/components/lr-heatmap.md +46 -0
- package/llms/components/lr-histogram.md +7 -4
- 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 +8 -6
- package/llms/components/lr-lite-chart.md +16 -6
- package/llms/components/lr-map.md +91 -10
- 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 +46 -7
- package/llms/components/lr-pdf-viewer.md +62 -2
- package/llms/components/lr-pie-chart.md +8 -6
- package/llms/components/lr-polar-area-chart.md +8 -6
- package/llms/components/lr-popover.md +25 -1
- 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 +8 -6
- 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 +8 -6
- 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/tokens.md +15 -1
- package/llms-full.txt +1335 -306
- package/package.json +17 -5
- package/vscode-css-data.json +93 -2
- package/vscode-html-data.json +513 -59
- package/web-types.json +457 -72
|
@@ -2,14 +2,9 @@ import{css}from"lit";const styles=css`
|
|
|
2
2
|
:host {
|
|
3
3
|
display: inline-block;
|
|
4
4
|
max-inline-size: 100%;
|
|
5
|
-
/* Consumer-tunable cap so one oversized image/video can't blow out a
|
|
6
|
-
chat bubble -- same naming/contract as lr-document-preview's
|
|
7
|
-
identical --lr-document-preview-max-height. Width already caps at
|
|
8
|
-
100% of whatever the host message body allows. */
|
|
9
5
|
--_lr-media-card-max-height: var(--lr-size-20rem);
|
|
10
6
|
}
|
|
11
7
|
|
|
12
|
-
/* -- base: shared chrome for every kind's root element (button/div/a/span) */
|
|
13
8
|
[part="base"] {
|
|
14
9
|
display: block;
|
|
15
10
|
box-sizing: border-box;
|
|
@@ -22,11 +17,10 @@ import{css}from"lit";const styles=css`
|
|
|
22
17
|
color: var(--lr-color-text);
|
|
23
18
|
text-decoration: none;
|
|
24
19
|
}
|
|
25
|
-
/* Reset native button/anchor chrome only where "base" is actually one of
|
|
26
|
-
those (image and file-with-a-safe-link cases) -- a plain div/span never
|
|
27
|
-
had any to begin with, so this is harmless there too. */
|
|
28
20
|
button[part="base"],
|
|
29
21
|
a[part="base"] {
|
|
22
|
+
min-inline-size: var(--lr-size-1-5rem);
|
|
23
|
+
min-block-size: var(--lr-size-1-5rem);
|
|
30
24
|
cursor: pointer;
|
|
31
25
|
padding: 0;
|
|
32
26
|
-webkit-tap-highlight-color: transparent;
|
|
@@ -37,10 +31,6 @@ import{css}from"lit";const styles=css`
|
|
|
37
31
|
a[part="base"]:hover {
|
|
38
32
|
border-color: var(--lr-color-brand);
|
|
39
33
|
}
|
|
40
|
-
/* Pressed deepens both the border the hover rule tints and the card's own fill, so the whole-card
|
|
41
|
-
button reads as depressed rather than merely pointed at. Under frame="plain" the later,
|
|
42
|
-
higher-specificity chrome reset still wins -- that mode is opting out of card chrome entirely,
|
|
43
|
-
pressed included. */
|
|
44
34
|
button[part="base"]:active,
|
|
45
35
|
a[part="base"]:active {
|
|
46
36
|
border-color: var(
|
|
@@ -64,10 +54,6 @@ import{css}from"lit";const styles=css`
|
|
|
64
54
|
outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);
|
|
65
55
|
outline-offset: var(--lr-focus-ring-offset);
|
|
66
56
|
}
|
|
67
|
-
/* Chrome escape hatch for a dense list/feed of cards -- the library-wide
|
|
68
|
-
:host([frame='plain']) [part='base'] reset. Image/video kinds already render [part='base']
|
|
69
|
-
with zero padding (see the button[part='base'] rule above), so this only visibly changes
|
|
70
|
-
padding for the file-chip fallback's span/a[part='base']. */
|
|
71
57
|
:host([frame="plain"]) [part="base"] {
|
|
72
58
|
padding: 0;
|
|
73
59
|
border: 0;
|
|
@@ -75,7 +61,6 @@ import{css}from"lit";const styles=css`
|
|
|
75
61
|
background: transparent;
|
|
76
62
|
}
|
|
77
63
|
|
|
78
|
-
/* -- image / video media ------------------------------------------- */
|
|
79
64
|
img[part="media"] {
|
|
80
65
|
display: block;
|
|
81
66
|
max-inline-size: 100%;
|
|
@@ -94,9 +79,6 @@ import{css}from"lit";const styles=css`
|
|
|
94
79
|
);
|
|
95
80
|
}
|
|
96
81
|
|
|
97
|
-
/* -- video: base is a plain non-interactive wrapper around the video
|
|
98
|
-
plus its own separate open-button -- see the class doc for why video
|
|
99
|
-
doesn't reuse the whole-card-button pattern image/file use. */
|
|
100
82
|
div[part="base"] {
|
|
101
83
|
position: relative;
|
|
102
84
|
display: inline-block;
|
|
@@ -108,10 +90,6 @@ import{css}from"lit";const styles=css`
|
|
|
108
90
|
display: inline-flex;
|
|
109
91
|
align-items: center;
|
|
110
92
|
justify-content: center;
|
|
111
|
-
/* Meets the shared minimum tappable size (--lr-icon-button-size) --
|
|
112
|
-
previously capped at 2rem/32px for a compact overlay look, but this
|
|
113
|
-
button floats over the video's own generous canvas (absolutely
|
|
114
|
-
positioned in a corner), which has ample room for the full floor. */
|
|
115
93
|
min-inline-size: var(--lr-icon-button-size);
|
|
116
94
|
min-block-size: var(--lr-icon-button-size);
|
|
117
95
|
padding: 0;
|
|
@@ -126,8 +104,6 @@ import{css}from"lit";const styles=css`
|
|
|
126
104
|
[part="open-button"]:hover {
|
|
127
105
|
background: var(--lr-color-surface);
|
|
128
106
|
}
|
|
129
|
-
/* Hover only finishes opacifying the translucent scrim, which leaves it with nowhere further to
|
|
130
|
-
go; pressed mixes that now-solid surface toward --lr-color-mix-partner instead. */
|
|
131
107
|
[part="open-button"]:active {
|
|
132
108
|
background: color-mix(
|
|
133
109
|
in oklab,
|
|
@@ -143,8 +119,6 @@ import{css}from"lit";const styles=css`
|
|
|
143
119
|
display: block;
|
|
144
120
|
}
|
|
145
121
|
|
|
146
|
-
/* -- file-chip fallback (kind="file", or an image/video src that failed
|
|
147
|
-
the safe-URL check) ------------------------------------------------ */
|
|
148
122
|
span[part="base"],
|
|
149
123
|
a[part="base"] {
|
|
150
124
|
display: inline-flex;
|
|
@@ -21,7 +21,6 @@ import{css}from"lit";const styles=css`
|
|
|
21
21
|
outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);
|
|
22
22
|
outline-offset: var(--lr-focus-ring-offset);
|
|
23
23
|
}
|
|
24
|
-
/* no-pressed-state: the viewport is a focusable scroll surface, not an activation target. */
|
|
25
24
|
[part='viewport']:hover {
|
|
26
25
|
border-color: var(--lr-color-brand);
|
|
27
26
|
}
|
|
@@ -32,8 +31,6 @@ import{css}from"lit";const styles=css`
|
|
|
32
31
|
min-block-size: 100%;
|
|
33
32
|
inline-size: max-content;
|
|
34
33
|
block-size: max-content;
|
|
35
|
-
/* CSS zoom participates in layout, so scaled content expands the scrollable footprint instead
|
|
36
|
-
of painting into an unreachable area outside transform-based scroll geometry. */
|
|
37
34
|
zoom: var(--lr-pan-zoom-zoom, 1);
|
|
38
35
|
}
|
|
39
36
|
[part='content'] ::slotted(*) {
|
|
@@ -98,8 +98,9 @@ export declare class LyraQrCode extends LyraElement {
|
|
|
98
98
|
get errorCorrection(): LyraQrCodeErrorCorrection;
|
|
99
99
|
set errorCorrection(value: LyraQrCodeErrorCorrection);
|
|
100
100
|
/** The stable canvas used for QR paint. The same node remains reachable across empty, loading,
|
|
101
|
-
* ready, error, reconnect, and redraw transitions.
|
|
102
|
-
|
|
101
|
+
* ready, error, reconnect, and redraw transitions. Readonly: an explicit `get` (rather than
|
|
102
|
+
* `@query`) so the generated manifest marks it non-assignable. */
|
|
103
|
+
get canvas(): HTMLCanvasElement;
|
|
103
104
|
private loadState;
|
|
104
105
|
private errorAnnouncementSink?;
|
|
105
106
|
private statusAnnouncementSink?;
|
|
@@ -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}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{resolveBoundedCanvasAllocation}from"../../../internal/canvas.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteRange}from"../../../internal/numbers.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{loadQrCodeCached}from"./qr-code-loader.js";import{styles}from"./qr-code.styles.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LYRA_DEFAULT_loading,LYRA_DEFAULT_noData,LYRA_DEFAULT_qrCodeGenerationFailed,LYRA_DEFAULT_qrCodeMissingLibrary}from"../../../internal/default-strings.generated.js";const DEFAULT_SIZE=128,MIN_SIZE=1,MAX_SIZE=2048,QR_BACKING_SCALE=2,MAX_CANVAS_DIMENSION=4096,MAX_CANVAS_PIXELS=8388608,MAX_QR_MODULE_COUNT=177,DEFAULT_RADIUS=0,MIN_RADIUS=0,MAX_RADIUS=.5,DEFAULT_IMAGE_COVERAGE=.5,DEFAULT_IMAGE_PADDING=0,DEFAULT_ERROR_CORRECTION="H",ERROR_CORRECTION_LEVELS=new Set(["L","M","Q","H"]),FALLBACK_FILL="#000000",FALLBACK_BACKGROUND="transparent";function isObjectLike(value){return(typeof value=="object"||typeof value=="function")&&value!==null}function normalizeQrModules(result){if(!isObjectLike(result))throw new TypeError("QR result must be an object.");const modules=result.modules;if(!isObjectLike(modules))throw new TypeError("QR result has no module matrix.");const size=modules.size,get=modules.get;if(!Number.isSafeInteger(size)||size<1||size>MAX_QR_MODULE_COUNT)throw new TypeError("QR module count is invalid.");if(typeof get!="function")throw new TypeError("QR module reader is invalid.");const moduleCount=size,bits=new Uint8Array(moduleCount*moduleCount);for(let row=0;row<moduleCount;row++)for(let col=0;col<moduleCount;col++){const value=Reflect.apply(get,modules,[row,col]);if(value!==0&&value!==1&&value!==!1&&value!==!0)throw new TypeError("QR module value is invalid.");bits[row*moduleCount+col]=value===1||value===!0?1:0}return Object.freeze({size:moduleCount,get(row,col){return!Number.isInteger(row)||!Number.isInteger(col)||row<0||col<0||row>=moduleCount||col>=moduleCount?0:bits[row*moduleCount+col]===1?1:0}})}function normalizeErrorCorrection(value){const upper=value.toUpperCase();return ERROR_CORRECTION_LEVELS.has(upper)?upper:DEFAULT_ERROR_CORRECTION}const errorCorrectionConverter={fromAttribute(value){return value===null?DEFAULT_ERROR_CORRECTION:normalizeErrorCorrection(value)}},warnedInvalidColors=new Set;function warnInvalidColor(value){warnedInvalidColors.has(value)||(warnedInvalidColors.add(value),console.warn(`<lr-qr-code> could not parse "${value}" as a CSS color; falling back to the default.`))}function resolveQrColor(value,fallbackHex,ctx){for(const sentinel of["rgb(1, 2, 3)","rgb(4, 5, 6)"]){ctx.fillStyle=sentinel;const sentinelNormalized=ctx.fillStyle;if(ctx.fillStyle=value,ctx.fillStyle!==sentinelNormalized)return value}return warnInvalidColor(value),fallbackHex}class LyraQrCode extends LyraElement{static{this.defaultStrings={...super.defaultStrings,loading:LYRA_DEFAULT_loading,noData:LYRA_DEFAULT_noData,qrCodeGenerationFailed:LYRA_DEFAULT_qrCodeGenerationFailed,qrCodeMissingLibrary:LYRA_DEFAULT_qrCodeMissingLibrary}}static{this.styles=[LyraElement.styles,styles]}static preload(){return loadQrCodeCached().then(api=>api!==null)}get size(){return this._size}set size(value){const oldValue=this._size;this._size=finiteRange(value,DEFAULT_SIZE,MIN_SIZE,MAX_SIZE),this.requestUpdate("size",oldValue)}get radius(){return this._radius}set radius(value){const oldValue=this._radius;this._radius=finiteRange(value,DEFAULT_RADIUS,MIN_RADIUS,MAX_RADIUS),this.requestUpdate("radius",oldValue)}get errorCorrection(){return this._errorCorrection}set errorCorrection(value){const oldValue=this._errorCorrection;this._errorCorrection=normalizeErrorCorrection(value),this.requestUpdate("errorCorrection",oldValue)}constructor(){super(),this.value="",this.label="",this.fill="",this.background="",this.image=null,this.imageBackground=null,this.imageCoverage=null,this.imagePadding=null,this._size=DEFAULT_SIZE,this._radius=DEFAULT_RADIUS,this._errorCorrection=DEFAULT_ERROR_CORRECTION,this.loadState={kind:"empty"},this.pendingLoadingAnnouncement=!1,this.visible=!0,this.loadLibrary=loadQrCodeCached,this.generation=0;try{this.accessibilityInternals=this.attachInternals()}catch{this.accessibilityInternals=void 0}this.syncSemanticOwner(),new ThemeWatcher(this,()=>this.refreshTheme())}connectedCallback(){this.value&&this.loadState.kind==="empty"?this.transitionTo({kind:"loading"}):this.setAttribute("aria-busy",this.loadState.kind==="loading"?"true":"false"),super.connectedCallback(),this.syncAnnouncementSinks();const IntersectionObserverCtor=this.ownerDocument.defaultView?.IntersectionObserver;IntersectionObserverCtor?(this.intersectionObserver=new IntersectionObserverCtor(entries=>{const wasVisible=this.visible;this.visible=entries[0]?.isIntersecting??!0,this.visible&&!wasVisible&&this.draw()}),this.intersectionObserver.observe(this)):this.visible||(this.visible=!0,this.draw()),this.hasUpdated&&this.value&&(this.loadState.kind==="loading"||this.image&&this.loadState.kind==="ready"&&!this.loadState.image)&&this.generate()}disconnectedCallback(){this.generation++,this.pendingLoadingAnnouncement=!1,this.releaseAnnouncementSinks(),super.disconnectedCallback(),this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0}adoptedCallback(){super.adoptedCallback(),this.releaseAnnouncementSinks(),this.syncAnnouncementSinks()}syncAnnouncementSinks(){this.isConnected&&(this.errorAnnouncementSink?.element.ownerDocument===this.ownerDocument&&this.statusAnnouncementSink?.element.ownerDocument===this.ownerDocument||(this.releaseAnnouncementSinks(),this.errorAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this}),this.statusAnnouncementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this})))}releaseAnnouncementSinks(){this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=void 0,this.statusAnnouncementSink?.release(),this.statusAnnouncementSink=void 0}transitionTo(next){const announcesLoading=next.kind==="loading"&&this.loadState.kind!=="loading"&&this.hasUpdated&&this.isConnected;this.loadState=next,this.setAttribute("aria-busy",next.kind==="loading"?"true":"false"),this.syncSemanticOwner(),announcesLoading&&(this.pendingLoadingAnnouncement=!0)}syncSemanticOwner(){const semantic=this.loadState.kind==="loading"||this.loadState.kind==="ready";this.accessibilityInternals&&(this.accessibilityInternals.role=semantic?"img":null,this.accessibilityInternals.ariaLabel=semantic?this.label||this.value:null)}updated(changed){if(super.updated(changed),this.syncSemanticOwner(),this.pendingLoadingAnnouncement&&(this.pendingLoadingAnnouncement=!1,this.statusAnnouncementSink?.announce(this.localize("loading"))),changed.has("value")||changed.has("errorCorrection")||changed.has("image")||!this.hasUpdated){this.scheduleAfterUpdate(()=>{this.generate()});return}this.loadState.kind==="ready"&&(changed.has("size")||changed.has("radius")||changed.has("fill")||changed.has("background")||changed.has("imageBackground")||changed.has("imageCoverage")||changed.has("imagePadding")||changed.has("loadState"))&&this.draw()}willUpdate(changed){super.willUpdate(changed),(changed.has("value")||changed.has("errorCorrection")||changed.has("image"))&&this.transitionTo(this.value?{kind:"loading"}:{kind:"empty"})}generate(){this.generateCurrentValue()}async generateCurrentValue(){const generation=++this.generation;if(!this.value){this.transitionTo({kind:"empty"});return}this.transitionTo({kind:"loading"});try{const api=await this.loadLibrary();if(generation!==this.generation||!this.isConnected)return;if(!api){const message=this.localize("qrCodeMissingLibrary");this.transitionTo({kind:"error",message}),this.errorAnnouncementSink?.announce(message);return}const imageSource=safeMediaSrc(this.image),result=api.create(this.value,{errorCorrectionLevel:imageSource?"H":this.errorCorrection}),modules=normalizeQrModules(result);if(generation!==this.generation)return;if(this.transitionTo({kind:"ready",modules}),imageSource){const image=await this.loadEmbeddedImage(imageSource);if(generation!==this.generation||!this.isConnected||!image)return;this.transitionTo({kind:"ready",modules,image})}}catch{if(generation!==this.generation||!this.isConnected)return;const message=this.localize("qrCodeGenerationFailed");this.transitionTo({kind:"error",message}),this.errorAnnouncementSink?.announce(message)}}async loadEmbeddedImage(src){const ImageCtor=this.ownerDocument.defaultView?.Image;if(!ImageCtor)return;const image=new ImageCtor;return image.decoding="async",await new Promise(resolve=>{image.addEventListener("load",()=>resolve(!0),{once:!0}),image.addEventListener("error",()=>resolve(!1),{once:!0}),image.src=src})&&image.naturalWidth>0&&image.naturalHeight>0?image:void 0}refreshTheme(){this.draw()}fillColor(ctx){const computed=this.ownerDocument.defaultView?.getComputedStyle(this),raw=this.fill.trim()||computed?.color?.trim()||FALLBACK_FILL;return resolveQrColor(raw,FALLBACK_FILL,ctx)}backgroundColor(ctx){const computed=this.ownerDocument.defaultView?.getComputedStyle(this),raw=this.background.trim()||computed?.backgroundColor?.trim()||FALLBACK_BACKGROUND;return resolveQrColor(raw,FALLBACK_BACKGROUND,ctx)}draw(){if(this.loadState.kind!=="ready"||!this.visible)return;const canvas=this.canvas;if(!canvas)return;const{modules}=this.loadState,size=this.size,allocation=LyraQrCode.canvasAllocation(size);canvas.width=allocation.pixelWidth,canvas.height=allocation.pixelHeight,canvas.style.width=`${size}px`,canvas.style.height=`${size}px`;const ctx=canvas.getContext("2d");if(!ctx)return;ctx.scale(allocation.scaleX,allocation.scaleY);const background=this.backgroundColor(ctx),fill=this.fillColor(ctx);ctx.fillStyle=background,ctx.fillRect(0,0,size,size);const moduleCount=modules.size,moduleSize=size/moduleCount,radiusPx=this.radius*moduleSize,canRoundRect=typeof ctx.roundRect=="function";ctx.fillStyle=fill;for(let row=0;row<moduleCount;row++)for(let col=0;col<moduleCount;col++){if(!modules.get(row,col))continue;const x=col*moduleSize,y=row*moduleSize;this.radius>0&&canRoundRect?(ctx.beginPath(),ctx.roundRect(x,y,moduleSize,moduleSize,radiusPx),ctx.fill()):ctx.fillRect(x,y,moduleSize,moduleSize)}this.loadState.image&&this.drawEmbeddedImage(ctx,this.loadState.image,size)}static canvasAllocation(cssSize){return resolveBoundedCanvasAllocation({cssWidth:cssSize,cssHeight:cssSize,desiredScale:QR_BACKING_SCALE,maxDimension:MAX_CANVAS_DIMENSION,maxPixels:MAX_CANVAS_PIXELS})}drawEmbeddedImage(ctx,image,size){const coverage=finiteRange(this.imageCoverage??DEFAULT_IMAGE_COVERAGE,DEFAULT_IMAGE_COVERAGE,0,1),boxSize=size*coverage;if(boxSize<=0)return;const padding=finiteRange(this.imagePadding??DEFAULT_IMAGE_PADDING,DEFAULT_IMAGE_PADDING,0,boxSize/2),contentSize=boxSize-padding*2,boxStart=(size-boxSize)/2;if(this.imageBackground?.trim()&&(ctx.fillStyle=resolveQrColor(this.imageBackground.trim(),this.backgroundColor(ctx),ctx),ctx.fillRect(boxStart,boxStart,boxSize,boxSize)),contentSize<=0)return;const scale=Math.min(contentSize/image.naturalWidth,contentSize/image.naturalHeight),width=image.naturalWidth*scale,height=image.naturalHeight*scale;ctx.drawImage(image,(size-width)/2,(size-height)/2,width,height)}accessibleName(){return this.getAttribute("aria-label")??(this.label||this.value)}renderBody(){switch(this.loadState.kind){case"empty":return html`<div part="empty">${this.localize("noData")}</div>`;case"loading":return html`<div part="loading">${this.localize("loading")}</div>`;case"error":return html`<div part="error">${this.loadState.message}</div>`;case"ready":return nothing}}render(){const ready=this.loadState.kind==="ready",fallbackSemantics=!this.accessibilityInternals&&ready;return html`<div part="base qr-code" style=${styleMap({inlineSize:`${this.size}px`,blockSize:`${this.size}px`})}>
|
|
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}from"lit";import{property,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{resolveBoundedCanvasAllocation}from"../../../internal/canvas.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteRange}from"../../../internal/numbers.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{loadQrCodeCached}from"./qr-code-loader.js";import{styles}from"./qr-code.styles.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LYRA_DEFAULT_loading,LYRA_DEFAULT_noData,LYRA_DEFAULT_qrCodeGenerationFailed,LYRA_DEFAULT_qrCodeMissingLibrary}from"../../../internal/default-strings.generated.js";const DEFAULT_SIZE=128,MIN_SIZE=1,MAX_SIZE=2048,QR_BACKING_SCALE=2,MAX_CANVAS_DIMENSION=4096,MAX_CANVAS_PIXELS=8388608,MAX_QR_MODULE_COUNT=177,DEFAULT_RADIUS=0,MIN_RADIUS=0,MAX_RADIUS=.5,DEFAULT_IMAGE_COVERAGE=.5,DEFAULT_IMAGE_PADDING=0,DEFAULT_ERROR_CORRECTION="H",ERROR_CORRECTION_LEVELS=new Set(["L","M","Q","H"]),FALLBACK_FILL="#000000",FALLBACK_BACKGROUND="transparent";function isObjectLike(value){return(typeof value=="object"||typeof value=="function")&&value!==null}function normalizeQrModules(result){if(!isObjectLike(result))throw new TypeError("QR result must be an object.");const modules=result.modules;if(!isObjectLike(modules))throw new TypeError("QR result has no module matrix.");const size=modules.size,get=modules.get;if(!Number.isSafeInteger(size)||size<1||size>MAX_QR_MODULE_COUNT)throw new TypeError("QR module count is invalid.");if(typeof get!="function")throw new TypeError("QR module reader is invalid.");const moduleCount=size,bits=new Uint8Array(moduleCount*moduleCount);for(let row=0;row<moduleCount;row++)for(let col=0;col<moduleCount;col++){const value=Reflect.apply(get,modules,[row,col]);if(value!==0&&value!==1&&value!==!1&&value!==!0)throw new TypeError("QR module value is invalid.");bits[row*moduleCount+col]=value===1||value===!0?1:0}return Object.freeze({size:moduleCount,get(row,col){return!Number.isInteger(row)||!Number.isInteger(col)||row<0||col<0||row>=moduleCount||col>=moduleCount?0:bits[row*moduleCount+col]===1?1:0}})}function normalizeErrorCorrection(value){const upper=value.toUpperCase();return ERROR_CORRECTION_LEVELS.has(upper)?upper:DEFAULT_ERROR_CORRECTION}const errorCorrectionConverter={fromAttribute(value){return value===null?DEFAULT_ERROR_CORRECTION:normalizeErrorCorrection(value)}},warnedInvalidColors=new Set;function warnInvalidColor(value){warnedInvalidColors.has(value)||(warnedInvalidColors.add(value),console.warn(`<lr-qr-code> could not parse "${value}" as a CSS color; falling back to the default.`))}function resolveQrColor(value,fallbackHex,ctx){for(const sentinel of["rgb(1, 2, 3)","rgb(4, 5, 6)"]){ctx.fillStyle=sentinel;const sentinelNormalized=ctx.fillStyle;if(ctx.fillStyle=value,ctx.fillStyle!==sentinelNormalized)return value}return warnInvalidColor(value),fallbackHex}class LyraQrCode extends LyraElement{static{this.defaultStrings={...super.defaultStrings,loading:LYRA_DEFAULT_loading,noData:LYRA_DEFAULT_noData,qrCodeGenerationFailed:LYRA_DEFAULT_qrCodeGenerationFailed,qrCodeMissingLibrary:LYRA_DEFAULT_qrCodeMissingLibrary}}static{this.styles=[LyraElement.styles,styles]}static preload(){return loadQrCodeCached().then(api=>api!==null)}get size(){return this._size}set size(value){const oldValue=this._size;this._size=finiteRange(value,DEFAULT_SIZE,MIN_SIZE,MAX_SIZE),this.requestUpdate("size",oldValue)}get radius(){return this._radius}set radius(value){const oldValue=this._radius;this._radius=finiteRange(value,DEFAULT_RADIUS,MIN_RADIUS,MAX_RADIUS),this.requestUpdate("radius",oldValue)}get errorCorrection(){return this._errorCorrection}set errorCorrection(value){const oldValue=this._errorCorrection;this._errorCorrection=normalizeErrorCorrection(value),this.requestUpdate("errorCorrection",oldValue)}get canvas(){return this.renderRoot?.querySelector("canvas")}constructor(){super(),this.value="",this.label="",this.fill="",this.background="",this.image=null,this.imageBackground=null,this.imageCoverage=null,this.imagePadding=null,this._size=DEFAULT_SIZE,this._radius=DEFAULT_RADIUS,this._errorCorrection=DEFAULT_ERROR_CORRECTION,this.loadState={kind:"empty"},this.pendingLoadingAnnouncement=!1,this.visible=!0,this.loadLibrary=loadQrCodeCached,this.generation=0;try{this.accessibilityInternals=this.attachInternals()}catch{this.accessibilityInternals=void 0}this.syncSemanticOwner(),new ThemeWatcher(this,()=>this.refreshTheme())}connectedCallback(){this.value&&this.loadState.kind==="empty"?this.transitionTo({kind:"loading"}):this.setAttribute("aria-busy",this.loadState.kind==="loading"?"true":"false"),super.connectedCallback(),this.syncAnnouncementSinks();const IntersectionObserverCtor=this.ownerDocument.defaultView?.IntersectionObserver;IntersectionObserverCtor?(this.intersectionObserver=new IntersectionObserverCtor(entries=>{const wasVisible=this.visible;this.visible=entries[0]?.isIntersecting??!0,this.visible&&!wasVisible&&this.draw()}),this.intersectionObserver.observe(this)):this.visible||(this.visible=!0,this.draw()),this.hasUpdated&&this.value&&(this.loadState.kind==="loading"||this.image&&this.loadState.kind==="ready"&&!this.loadState.image)&&this.generate()}disconnectedCallback(){this.generation++,this.pendingLoadingAnnouncement=!1,this.releaseAnnouncementSinks(),super.disconnectedCallback(),this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0}adoptedCallback(){super.adoptedCallback(),this.releaseAnnouncementSinks(),this.syncAnnouncementSinks()}syncAnnouncementSinks(){this.isConnected&&(this.errorAnnouncementSink?.element.ownerDocument===this.ownerDocument&&this.statusAnnouncementSink?.element.ownerDocument===this.ownerDocument||(this.releaseAnnouncementSinks(),this.errorAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this}),this.statusAnnouncementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this})))}releaseAnnouncementSinks(){this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=void 0,this.statusAnnouncementSink?.release(),this.statusAnnouncementSink=void 0}transitionTo(next){const announcesLoading=next.kind==="loading"&&this.loadState.kind!=="loading"&&this.hasUpdated&&this.isConnected;this.loadState=next,this.setAttribute("aria-busy",next.kind==="loading"?"true":"false"),this.syncSemanticOwner(),announcesLoading&&(this.pendingLoadingAnnouncement=!0)}syncSemanticOwner(){const semantic=this.loadState.kind==="loading"||this.loadState.kind==="ready";this.accessibilityInternals&&(this.accessibilityInternals.role=semantic?"img":null,this.accessibilityInternals.ariaLabel=semantic?this.label||this.value:null)}updated(changed){if(super.updated(changed),this.syncSemanticOwner(),this.pendingLoadingAnnouncement&&(this.pendingLoadingAnnouncement=!1,this.statusAnnouncementSink?.announce(this.localize("loading"))),changed.has("value")||changed.has("errorCorrection")||changed.has("image")||!this.hasUpdated){this.scheduleAfterUpdate(()=>{this.generate()});return}this.loadState.kind==="ready"&&(changed.has("size")||changed.has("radius")||changed.has("fill")||changed.has("background")||changed.has("imageBackground")||changed.has("imageCoverage")||changed.has("imagePadding")||changed.has("loadState"))&&this.draw()}willUpdate(changed){super.willUpdate(changed),(changed.has("value")||changed.has("errorCorrection")||changed.has("image"))&&this.transitionTo(this.value?{kind:"loading"}:{kind:"empty"})}generate(){this.generateCurrentValue()}async generateCurrentValue(){const generation=++this.generation;if(!this.value){this.transitionTo({kind:"empty"});return}this.transitionTo({kind:"loading"});try{const api=await this.loadLibrary();if(generation!==this.generation||!this.isConnected)return;if(!api){const message=this.localize("qrCodeMissingLibrary");this.transitionTo({kind:"error",message}),this.errorAnnouncementSink?.announce(message);return}const imageSource=safeMediaSrc(this.image),result=api.create(this.value,{errorCorrectionLevel:imageSource?"H":this.errorCorrection}),modules=normalizeQrModules(result);if(generation!==this.generation)return;if(this.transitionTo({kind:"ready",modules}),imageSource){const image=await this.loadEmbeddedImage(imageSource);if(generation!==this.generation||!this.isConnected||!image)return;this.transitionTo({kind:"ready",modules,image})}}catch{if(generation!==this.generation||!this.isConnected)return;const message=this.localize("qrCodeGenerationFailed");this.transitionTo({kind:"error",message}),this.errorAnnouncementSink?.announce(message)}}async loadEmbeddedImage(src){const ImageCtor=this.ownerDocument.defaultView?.Image;if(!ImageCtor)return;const image=new ImageCtor;return image.decoding="async",await new Promise(resolve=>{image.addEventListener("load",()=>resolve(!0),{once:!0}),image.addEventListener("error",()=>resolve(!1),{once:!0}),image.src=src})&&image.naturalWidth>0&&image.naturalHeight>0?image:void 0}refreshTheme(){this.draw()}fillColor(ctx){const computed=this.ownerDocument.defaultView?.getComputedStyle(this),raw=this.fill.trim()||computed?.color?.trim()||FALLBACK_FILL;return resolveQrColor(raw,FALLBACK_FILL,ctx)}backgroundColor(ctx){const computed=this.ownerDocument.defaultView?.getComputedStyle(this),raw=this.background.trim()||computed?.backgroundColor?.trim()||FALLBACK_BACKGROUND;return resolveQrColor(raw,FALLBACK_BACKGROUND,ctx)}draw(){if(this.loadState.kind!=="ready"||!this.visible)return;const canvas=this.canvas;if(!canvas)return;const{modules}=this.loadState,size=this.size,allocation=LyraQrCode.canvasAllocation(size);canvas.width=allocation.pixelWidth,canvas.height=allocation.pixelHeight,canvas.style.width=`${size}px`,canvas.style.height=`${size}px`;const ctx=canvas.getContext("2d");if(!ctx)return;ctx.scale(allocation.scaleX,allocation.scaleY);const background=this.backgroundColor(ctx),fill=this.fillColor(ctx);ctx.fillStyle=background,ctx.fillRect(0,0,size,size);const moduleCount=modules.size,moduleSize=size/moduleCount,radiusPx=this.radius*moduleSize,canRoundRect=typeof ctx.roundRect=="function";ctx.fillStyle=fill;for(let row=0;row<moduleCount;row++)for(let col=0;col<moduleCount;col++){if(!modules.get(row,col))continue;const x=col*moduleSize,y=row*moduleSize;this.radius>0&&canRoundRect?(ctx.beginPath(),ctx.roundRect(x,y,moduleSize,moduleSize,radiusPx),ctx.fill()):ctx.fillRect(x,y,moduleSize,moduleSize)}this.loadState.image&&this.drawEmbeddedImage(ctx,this.loadState.image,size)}static canvasAllocation(cssSize){return resolveBoundedCanvasAllocation({cssWidth:cssSize,cssHeight:cssSize,desiredScale:QR_BACKING_SCALE,maxDimension:MAX_CANVAS_DIMENSION,maxPixels:MAX_CANVAS_PIXELS})}drawEmbeddedImage(ctx,image,size){const coverage=finiteRange(this.imageCoverage??DEFAULT_IMAGE_COVERAGE,DEFAULT_IMAGE_COVERAGE,0,1),boxSize=size*coverage;if(boxSize<=0)return;const padding=finiteRange(this.imagePadding??DEFAULT_IMAGE_PADDING,DEFAULT_IMAGE_PADDING,0,boxSize/2),contentSize=boxSize-padding*2,boxStart=(size-boxSize)/2;if(this.imageBackground?.trim()&&(ctx.fillStyle=resolveQrColor(this.imageBackground.trim(),this.backgroundColor(ctx),ctx),ctx.fillRect(boxStart,boxStart,boxSize,boxSize)),contentSize<=0)return;const scale=Math.min(contentSize/image.naturalWidth,contentSize/image.naturalHeight),width=image.naturalWidth*scale,height=image.naturalHeight*scale;ctx.drawImage(image,(size-width)/2,(size-height)/2,width,height)}accessibleName(){return this.getAttribute("aria-label")??(this.label||this.value)}renderBody(){switch(this.loadState.kind){case"empty":return html`<div part="empty">${this.localize("noData")}</div>`;case"loading":return html`<div part="loading">${this.localize("loading")}</div>`;case"error":return html`<div part="error">${this.loadState.message}</div>`;case"ready":return nothing}}render(){const ready=this.loadState.kind==="ready",fallbackSemantics=!this.accessibilityInternals&&ready;return html`<div part="base qr-code" style=${styleMap({inlineSize:`${this.size}px`,blockSize:`${this.size}px`})}>
|
|
2
2
|
<canvas
|
|
3
3
|
part="canvas"
|
|
4
4
|
?hidden=${!ready}
|
|
@@ -7,4 +7,4 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
7
7
|
aria-label=${fallbackSemantics?this.accessibleName():nothing}
|
|
8
8
|
></canvas>
|
|
9
9
|
${this.renderBody()}
|
|
10
|
-
</div>`}}__decorate([property()],LyraQrCode.prototype,"value",void 0),__decorate([property()],LyraQrCode.prototype,"label",void 0),__decorate([property()],LyraQrCode.prototype,"fill",void 0),__decorate([property()],LyraQrCode.prototype,"background",void 0),__decorate([property()],LyraQrCode.prototype,"image",void 0),__decorate([property({attribute:"image-background"})],LyraQrCode.prototype,"imageBackground",void 0),__decorate([property({type:Number,attribute:"image-coverage"})],LyraQrCode.prototype,"imageCoverage",void 0),__decorate([property({type:Number,attribute:"image-padding"})],LyraQrCode.prototype,"imagePadding",void 0),__decorate([property({type:Number})],LyraQrCode.prototype,"size",null),__decorate([property({type:Number})],LyraQrCode.prototype,"radius",null),__decorate([property({attribute:"error-correction",converter:errorCorrectionConverter})],LyraQrCode.prototype,"errorCorrection",null),__decorate([
|
|
10
|
+
</div>`}}__decorate([property()],LyraQrCode.prototype,"value",void 0),__decorate([property()],LyraQrCode.prototype,"label",void 0),__decorate([property()],LyraQrCode.prototype,"fill",void 0),__decorate([property()],LyraQrCode.prototype,"background",void 0),__decorate([property()],LyraQrCode.prototype,"image",void 0),__decorate([property({attribute:"image-background"})],LyraQrCode.prototype,"imageBackground",void 0),__decorate([property({type:Number,attribute:"image-coverage"})],LyraQrCode.prototype,"imageCoverage",void 0),__decorate([property({type:Number,attribute:"image-padding"})],LyraQrCode.prototype,"imagePadding",void 0),__decorate([property({type:Number})],LyraQrCode.prototype,"size",null),__decorate([property({type:Number})],LyraQrCode.prototype,"radius",null),__decorate([property({attribute:"error-correction",converter:errorCorrectionConverter})],LyraQrCode.prototype,"errorCorrection",null),__decorate([state()],LyraQrCode.prototype,"loadState",void 0),__decorate([state()],LyraQrCode.prototype,"visible",void 0);export{LyraQrCode};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import{css}from"lit";const styles=css`
|
|
2
2
|
:host {
|
|
3
3
|
display: inline-flex;
|
|
4
|
-
/* Canvas paint resolves these computed host styles live. The optional
|
|
5
|
-
aliases deliberately have no token defaults: inherited color and a
|
|
6
|
-
transparent host background are the mirrored renderer defaults. */
|
|
7
4
|
color: var(--lr-qr-code-fill, inherit);
|
|
8
5
|
background-color: var(--lr-qr-code-background, initial);
|
|
9
6
|
}
|
|
@@ -106,6 +106,8 @@ export declare class LyraSequencePlayback extends LyraElement<LyraSequencePlayba
|
|
|
106
106
|
click(): void;
|
|
107
107
|
private onControlFocus;
|
|
108
108
|
private onControlBlur;
|
|
109
|
+
private keyboardStepDelta;
|
|
110
|
+
private onSliderKeyDown;
|
|
109
111
|
render(): TemplateResult;
|
|
110
112
|
}
|
|
111
113
|
declare global {
|
|
@@ -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}from"lit";import{property,query}from"lit/decorators.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{LyraElement}from"../../../internal/lyra-element.js";import{playIcon,pauseIcon}from"../../../internal/icons.js";import{finiteCount,finiteDuration,MAX_TIMEOUT_MS}from"../../../internal/numbers.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{styles}from"./sequence-playback.styles.js";import{presenceTrueDefaultBooleanConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_pause,LYRA_DEFAULT_play,LYRA_DEFAULT_playbackPosition,LYRA_DEFAULT_playbackStepPosition}from"../../../internal/default-strings.generated.js";const MIN_INTERVAL_MS=16,warnedInvalidIntervals=new Set;function warnInvalidInterval(value,normalized){if(warnedInvalidIntervals.has(value))return;warnedInvalidIntervals.add(value);const reason=Number.isFinite(value)?value<MIN_INTERVAL_MS?`below the ${MIN_INTERVAL_MS}ms floor`:`above the ${MAX_TIMEOUT_MS}ms ceiling`:"non-finite";console.warn(`<lr-sequence-playback> interval-ms (${value}) is ${reason}; clamping to ${normalized}ms.`)}class LyraSequencePlayback extends LyraElement{constructor(){super(...arguments),this.itemCount=0,this.currentIndex=0,this.intervalMs=900,this.loop=!0,this.hidden=!1,this._playing=!1,this.running=!1,this.onControlFocus=event=>{relayNativeEvent(this,event)},this.onControlBlur=event=>{relayNativeEvent(this,event)}}static{this.defaultStrings={...super.defaultStrings,pause:LYRA_DEFAULT_pause,play:LYRA_DEFAULT_play,playbackPosition:LYRA_DEFAULT_playbackPosition,playbackStepPosition:LYRA_DEFAULT_playbackStepPosition}}static{this.styles=[LyraElement.styles,styles]}static{this.properties={playing:{type:Boolean,reflect:!0,noAccessor:!0},loop:{type:Boolean,converter:trueDefaultBooleanConverter}}}get playing(){return this._playing}set playing(next){if(next&&this.hasUpdated&&finiteCount(this.itemCount)<=1){this.hasAttribute("playing")&&this.removeAttribute("playing");return}const old=this._playing,requested=!!next;requested!==old&&(this._playing=requested,this.requestUpdate("playing",old),requested?this.startIfPossible():this.stopRunning())}startIfPossible(){this.running||!this._playing||finiteCount(this.itemCount)<=1||(this.running=!0,this.emit("lr-play"),this.running&&this._playing&&this.scheduleTick())}stopRunning(){this.clearTimer(),this.running&&(this.running=!1,this.emit("lr-pause"))}rejectInvalidPlayingRequest(){if(!this._playing)return;const old=this._playing;this._playing=!1,this.stopRunning(),this.requestUpdate("playing",old)}get maxIndex(){return Math.max(0,finiteCount(this.itemCount)-1)}disconnectedCallback(){this.pause(),this.clearTimer(),super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed),changed.has("hidden")&&this.hidden&&this.pause();const itemCount=finiteCount(this.itemCount),currentIndex=finiteCount(this.currentIndex);itemCount!==this.itemCount&&(this.itemCount=itemCount),currentIndex!==this.currentIndex&&(this.currentIndex=currentIndex),(changed.has("itemCount")||changed.has("playing"))&&(this.itemCount<=1?this.rejectInvalidPlayingRequest():this.startIfPossible(),this.currentIndex>this.maxIndex&&(this.currentIndex=this.maxIndex))}play(){this.playing||finiteCount(this.itemCount)<=1||(this.playing=!0)}pause(){this.playing&&(this.playing=!1)}toggle(){this.playing=!this.playing}scheduleTick(){const rawDelay=this.intervalMs,delay=finiteDuration(rawDelay,MIN_INTERVAL_MS,MIN_INTERVAL_MS);delay!==rawDelay&&warnInvalidInterval(rawDelay,delay);const timerWindow=this.ownerDocument.defaultView;if(!timerWindow)return;const id=timerWindow.setTimeout(()=>{this.timer!==id||this.timerWindow!==timerWindow||(this.tick(),this.running&&this.playing&&this.timer===id&&this.timerWindow===timerWindow&&this.scheduleTick())},delay);this.timer=id,this.timerWindow=timerWindow}clearTimer(){this.timer!==void 0&&this.timerWindow?.clearTimeout(this.timer),this.timer=void 0,this.timerWindow=void 0}tick(){const itemCount=finiteCount(this.itemCount),next=finiteCount(this.currentIndex)+1;next>=itemCount?this.loop?this.setIndex(0):(this.setIndex(itemCount-1),this.pause()):this.setIndex(next)}setIndex(i){this.currentIndex=finiteCount(i,0,this.maxIndex),this.emit("lr-sequence-step",{currentIndex:this.currentIndex})}next(){const currentIndex=finiteCount(this.currentIndex);currentIndex+1<finiteCount(this.itemCount)&&this.setIndex(currentIndex+1)}previous(){const currentIndex=finiteCount(this.currentIndex);currentIndex>0&&this.setIndex(currentIndex-1)}goTo(currentIndex){this.pause(),this.setIndex(finiteCount(currentIndex,0,this.maxIndex))}focus(options){this.playButton?.focus(options)}blur(){this.playButton?.blur()}click(){this.playButton?.click()}render(){const maxIndex=this.maxIndex,currentIndex=finiteCount(this.currentIndex,0,maxIndex),disabled=finiteCount(this.itemCount)<=1;return html`
|
|
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}from"lit";import{property,query}from"lit/decorators.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{LyraElement}from"../../../internal/lyra-element.js";import{playIcon,pauseIcon}from"../../../internal/icons.js";import{finiteCount,finiteDuration,MAX_TIMEOUT_MS}from"../../../internal/numbers.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{styles}from"./sequence-playback.styles.js";import{presenceTrueDefaultBooleanConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_pause,LYRA_DEFAULT_play,LYRA_DEFAULT_playbackPosition,LYRA_DEFAULT_playbackStepPosition}from"../../../internal/default-strings.generated.js";const MIN_INTERVAL_MS=16,warnedInvalidIntervals=new Set;function warnInvalidInterval(value,normalized){if(warnedInvalidIntervals.has(value))return;warnedInvalidIntervals.add(value);const reason=Number.isFinite(value)?value<MIN_INTERVAL_MS?`below the ${MIN_INTERVAL_MS}ms floor`:`above the ${MAX_TIMEOUT_MS}ms ceiling`:"non-finite";console.warn(`<lr-sequence-playback> interval-ms (${value}) is ${reason}; clamping to ${normalized}ms.`)}class LyraSequencePlayback extends LyraElement{constructor(){super(...arguments),this.itemCount=0,this.currentIndex=0,this.intervalMs=900,this.loop=!0,this.hidden=!1,this._playing=!1,this.running=!1,this.onControlFocus=event=>{relayNativeEvent(this,event)},this.onControlBlur=event=>{relayNativeEvent(this,event)},this.onSliderKeyDown=event=>{const delta=this.keyboardStepDelta(event.key);delta!==void 0&&(event.preventDefault(),this.goTo(finiteCount(this.currentIndex,0,this.maxIndex)+delta))}}static{this.defaultStrings={...super.defaultStrings,pause:LYRA_DEFAULT_pause,play:LYRA_DEFAULT_play,playbackPosition:LYRA_DEFAULT_playbackPosition,playbackStepPosition:LYRA_DEFAULT_playbackStepPosition}}static{this.styles=[LyraElement.styles,styles]}static{this.properties={playing:{type:Boolean,reflect:!0,noAccessor:!0},loop:{type:Boolean,converter:trueDefaultBooleanConverter}}}get playing(){return this._playing}set playing(next){if(next&&this.hasUpdated&&finiteCount(this.itemCount)<=1){this.hasAttribute("playing")&&this.removeAttribute("playing");return}const old=this._playing,requested=!!next;requested!==old&&(this._playing=requested,this.requestUpdate("playing",old),requested?this.startIfPossible():this.stopRunning())}startIfPossible(){this.running||!this._playing||finiteCount(this.itemCount)<=1||(this.running=!0,this.emit("lr-play"),this.running&&this._playing&&this.scheduleTick())}stopRunning(){this.clearTimer(),this.running&&(this.running=!1,this.emit("lr-pause"))}rejectInvalidPlayingRequest(){if(!this._playing)return;const old=this._playing;this._playing=!1,this.stopRunning(),this.requestUpdate("playing",old)}get maxIndex(){return Math.max(0,finiteCount(this.itemCount)-1)}disconnectedCallback(){this.pause(),this.clearTimer(),super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed),changed.has("hidden")&&this.hidden&&this.pause();const itemCount=finiteCount(this.itemCount),currentIndex=finiteCount(this.currentIndex);itemCount!==this.itemCount&&(this.itemCount=itemCount),currentIndex!==this.currentIndex&&(this.currentIndex=currentIndex),(changed.has("itemCount")||changed.has("playing"))&&(this.itemCount<=1?this.rejectInvalidPlayingRequest():this.startIfPossible(),this.currentIndex>this.maxIndex&&(this.currentIndex=this.maxIndex))}play(){this.playing||finiteCount(this.itemCount)<=1||(this.playing=!0)}pause(){this.playing&&(this.playing=!1)}toggle(){this.playing=!this.playing}scheduleTick(){const rawDelay=this.intervalMs,delay=finiteDuration(rawDelay,MIN_INTERVAL_MS,MIN_INTERVAL_MS);delay!==rawDelay&&warnInvalidInterval(rawDelay,delay);const timerWindow=this.ownerDocument.defaultView;if(!timerWindow)return;const id=timerWindow.setTimeout(()=>{this.timer!==id||this.timerWindow!==timerWindow||(this.tick(),this.running&&this.playing&&this.timer===id&&this.timerWindow===timerWindow&&this.scheduleTick())},delay);this.timer=id,this.timerWindow=timerWindow}clearTimer(){this.timer!==void 0&&this.timerWindow?.clearTimeout(this.timer),this.timer=void 0,this.timerWindow=void 0}tick(){const itemCount=finiteCount(this.itemCount),next=finiteCount(this.currentIndex)+1;next>=itemCount?this.loop?this.setIndex(0):(this.setIndex(itemCount-1),this.pause()):this.setIndex(next)}setIndex(i){this.currentIndex=finiteCount(i,0,this.maxIndex),this.emit("lr-sequence-step",{currentIndex:this.currentIndex})}next(){const currentIndex=finiteCount(this.currentIndex);currentIndex+1<finiteCount(this.itemCount)&&this.setIndex(currentIndex+1)}previous(){const currentIndex=finiteCount(this.currentIndex);currentIndex>0&&this.setIndex(currentIndex-1)}goTo(currentIndex){this.pause(),this.setIndex(finiteCount(currentIndex,0,this.maxIndex))}focus(options){this.playButton?.focus(options)}blur(){this.playButton?.blur()}click(){this.playButton?.click()}keyboardStepDelta(key){const rtl=this.effectiveDirection==="rtl";if(key==="ArrowLeft")return rtl?1:-1;if(key==="ArrowRight")return rtl?-1:1}render(){const maxIndex=this.maxIndex,currentIndex=finiteCount(this.currentIndex,0,maxIndex),disabled=finiteCount(this.itemCount)<=1;return html`
|
|
2
2
|
<div part="base">
|
|
3
3
|
<button
|
|
4
4
|
part="play-button"
|
|
@@ -21,6 +21,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
21
21
|
aria-valuetext=${this.localize("playbackStepPosition",void 0,{index:getNumberFormat(this.effectiveLocale).format(currentIndex+1),total:getNumberFormat(this.effectiveLocale).format(finiteCount(this.itemCount))})}
|
|
22
22
|
?disabled=${disabled}
|
|
23
23
|
@input=${e=>this.goTo(Number(e.target.value)-1)}
|
|
24
|
+
@keydown=${this.onSliderKeyDown}
|
|
24
25
|
@focus=${this.onControlFocus}
|
|
25
26
|
@blur=${this.onControlBlur}
|
|
26
27
|
/>
|
|
@@ -3,10 +3,6 @@ import{css}from"lit";const styles=css`
|
|
|
3
3
|
display: inline-flex;
|
|
4
4
|
align-items: center;
|
|
5
5
|
gap: var(--lr-space-s);
|
|
6
|
-
/* Derived from --lr-icon-button-size (0.35 * 2.5rem = 0.875rem, the
|
|
7
|
-
prior bare literal) so the rendered play/pause SVG icon (icons render
|
|
8
|
-
at width/height: 1em, so this font-size directly controls its pixel
|
|
9
|
-
size) tracks the button's own token instead of drifting from it. */
|
|
10
6
|
--_lr-sequence-playback-icon-size: calc(var(--lr-icon-button-size) * 0.35);
|
|
11
7
|
}
|
|
12
8
|
[part="base"] {
|
|
@@ -15,11 +11,6 @@ import{css}from"lit";const styles=css`
|
|
|
15
11
|
gap: var(--lr-space-s);
|
|
16
12
|
}
|
|
17
13
|
[part="play-button"] {
|
|
18
|
-
/* Already exactly the shared floor (2.5rem/40px) via inline-size/block-size for
|
|
19
|
-
this circular button's own shape -- min-inline-size/min-block-size are added
|
|
20
|
-
alongside (not swapped in) at the same value, so the floor is explicit and this
|
|
21
|
-
resolves through the shared token like every other icon-button in the library,
|
|
22
|
-
without disturbing the fixed circle. */
|
|
23
14
|
inline-size: var(--lr-icon-button-size);
|
|
24
15
|
block-size: var(--lr-icon-button-size);
|
|
25
16
|
min-inline-size: var(--lr-icon-button-size);
|
|
@@ -66,16 +57,6 @@ import{css}from"lit";const styles=css`
|
|
|
66
57
|
accent-color: var(--lr-color-brand);
|
|
67
58
|
cursor: pointer;
|
|
68
59
|
}
|
|
69
|
-
/* :where() zeroes the wrapped selectors' specificity contribution, leaving only :hover itself
|
|
70
|
-
-- (0,1,0) total, functionally identical selection to \`[part='slider']:hover:not(:disabled)\`
|
|
71
|
-
((0,3,0)) but now losing (on the pseudo-element tiebreak) to a consumer's own
|
|
72
|
-
\`::part(slider):hover\` override ((0,1,1)) without that consumer needing !important. Same
|
|
73
|
-
fix as \`<lr-attachment-trigger>\`'s \`.trigger-button\` hover rule. */
|
|
74
|
-
/* The visible ink on a native range input is drawn by the UA from accent-color, not from
|
|
75
|
-
background -- so the interaction states move accent-color. (The old filter: brightness() bought
|
|
76
|
-
the same visual by multiplying every channel of the whole subtree; it did nothing to a pure
|
|
77
|
-
white or pure black accent, and it dimmed/lit the input's own focus ring along with the
|
|
78
|
-
track.) */
|
|
79
60
|
:where([part="slider"]):hover:where(:not(:disabled)) {
|
|
80
61
|
accent-color: color-mix(
|
|
81
62
|
in oklab,
|
|
@@ -53,8 +53,9 @@ export interface LyraVideoEventMap {
|
|
|
53
53
|
* @event {Event} pause - Relayed native video event; non-bubbling, non-composed, and non-cancelable.
|
|
54
54
|
* @event {Event} play - Relayed native video event; non-bubbling, non-composed, and non-cancelable.
|
|
55
55
|
* @event {Event} timeupdate - Relayed native video event; non-bubbling, non-composed, and
|
|
56
|
-
* non-cancelable. Scrubbing the
|
|
57
|
-
*
|
|
56
|
+
* non-cancelable. Scrubbing the custom timeline, or calling `seek()`, also dispatches this
|
|
57
|
+
* event immediately and exactly once -- the corresponding native follow-up event is not
|
|
58
|
+
* separately relayed.
|
|
58
59
|
* @event {Event} volumechange - Relayed native video event; non-bubbling, non-composed, and
|
|
59
60
|
* non-cancelable.
|
|
60
61
|
* @event {FocusEvent} focus - Relayed once from the internal play/pause control as a bubbling,
|
|
@@ -135,6 +136,13 @@ export declare class LyraVideo extends LyraElement<LyraVideoEventMap> {
|
|
|
135
136
|
private thumbnailPosition;
|
|
136
137
|
private wrapperEl?;
|
|
137
138
|
private readonly mediaController;
|
|
139
|
+
/** One-shot guards against this component's own imperative native mutation echoing back through
|
|
140
|
+
* `onNativeMediaEvent()` as if it were an externally-caused change. Each flag is armed
|
|
141
|
+
* immediately before the imperative native write that will trigger the corresponding queued
|
|
142
|
+
* native event, and consumed (cleared) by the first arrival of that event afterward -- shared
|
|
143
|
+
* shape for both the seek() timeupdate dedup and the autoplay-muted volumechange suppression
|
|
144
|
+
* below, rather than two independently-invented flags. */
|
|
145
|
+
private readonly pendingNativeEcho;
|
|
138
146
|
private thumbnailGeneration;
|
|
139
147
|
private thumbnailAbort?;
|
|
140
148
|
private intersectionObserver?;
|
|
@@ -159,6 +167,11 @@ export declare class LyraVideo extends LyraElement<LyraVideoEventMap> {
|
|
|
159
167
|
disconnectedCallback(): void;
|
|
160
168
|
protected willUpdate(changed: PropertyValues): void;
|
|
161
169
|
private mediaRef;
|
|
170
|
+
/** Forces the native element muted while `autoplayMuted` is the sole reason (the authored
|
|
171
|
+
* `muted` property stays whatever it already was) -- without letting the native
|
|
172
|
+
* 'volumechange' this triggers overwrite that authored property. See
|
|
173
|
+
* `onNativeMediaEvent()`'s 'volumechange' case, guarded by `pendingNativeEcho.muted`. */
|
|
174
|
+
private forceAutoplayMuted;
|
|
162
175
|
private sourceSignature;
|
|
163
176
|
private syncSources;
|
|
164
177
|
private onSourceSlotChange;
|
|
@@ -174,8 +187,16 @@ export declare class LyraVideo extends LyraElement<LyraVideoEventMap> {
|
|
|
174
187
|
load(): void;
|
|
175
188
|
/** Seeks to a finite time, clamped to the known duration. */
|
|
176
189
|
seek(time: number): void;
|
|
190
|
+
private dispatchHostTimeupdate;
|
|
177
191
|
/** Sets a finite native playback-rate multiplier. */
|
|
178
192
|
setPlaybackRate(rate: number): void;
|
|
193
|
+
/** `[data-control="rate"]`'s `<option>` values -- `PLAYBACK_RATES`, plus the current
|
|
194
|
+
* `playbackRate` spliced in (numerically sorted) when it isn't already one of them. Mirrors
|
|
195
|
+
* av-player's `rateOptions()`: a native `<select>` shows its first option whenever none
|
|
196
|
+
* carries `selected`, so a `playbackRate` reached outside the fixed preset list (e.g. a native
|
|
197
|
+
* `ratechange` from a platform media key or a picture-in-picture window) would otherwise
|
|
198
|
+
* silently misreport the real rate. */
|
|
199
|
+
private rateSelectOptions;
|
|
179
200
|
/** Sets finite volume in the inclusive zero-to-one range. */
|
|
180
201
|
setVolume(volume: number): void;
|
|
181
202
|
/** Toggles the live native muted state. */
|
|
@@ -1,8 +1,8 @@
|
|
|
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}from"lit";import{property,query,state}from"lit/decorators.js";import{ref}from"lit/directives/ref.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{hostAriaLabel,srOnly}from"../../../internal/a11y.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{MAX_NATIVE_PLAYBACK_RATE,MIN_NATIVE_PLAYBACK_RATE,NativeMediaController,canExitFullscreen,canRequestFullscreen,canRequestPictureInPicture,safeNativeMediaSource}from"../../../internal/media-controller.js";import{finiteRange}from"../../../internal/numbers.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{readResponseText,resolveOwnerFetchTarget}from"../../../internal/resource-loader.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{styles}from"./video.styles.js";import{LYRA_DEFAULT_avPlayerPosition,LYRA_DEFAULT_pause,LYRA_DEFAULT_play,LYRA_DEFAULT_playbackPosition,LYRA_DEFAULT_videoCaptions,LYRA_DEFAULT_videoCaptionsOff,LYRA_DEFAULT_videoEnterFullscreen,LYRA_DEFAULT_videoExitFullscreen,LYRA_DEFAULT_videoExitPictureInPicture,LYRA_DEFAULT_videoMute,LYRA_DEFAULT_videoPictureInPicture,LYRA_DEFAULT_videoPlaybackSpeed,LYRA_DEFAULT_videoPlayerLabel,LYRA_DEFAULT_videoUnmute,LYRA_DEFAULT_videoVolume}from"../../../internal/default-strings.generated.js";const MAX_THUMBNAIL_BYTES=256*1024,MAX_THUMBNAIL_CUES=2e3,PLAYBACK_RATES=[.5,.75,1,1.25,1.5,2];function safeControls(value){return value==="none"||value==="full"?value:"standard"}function safePreload(value){return value==="auto"||value==="none"?value:"metadata"}function parseVttTime(source){const parts=source.trim().split(":").map(Number);if(parts.length<2||parts.length>3||parts.some(part=>!Number.isFinite(part)))return null;const seconds=parts.length===3?parts[0]*3600+parts[1]*60+parts[2]:parts[0]*60+parts[1];return seconds>=0?seconds:null}function parseThumbnailUrl(source,baseUrl,URLCtor){const trimmed=source.trim();if(!trimmed)return null;try{const resolved=new URLCtor(trimmed,baseUrl),sprite=/^#xywh=(\d+),(\d+),(\d+),(\d+)$/u.exec(resolved.hash);resolved.hash="";const src=safeMediaSrc(resolved.href,URLCtor);if(!src)return null;if(!sprite)return{src};const[x,y,width,height]=sprite.slice(1).map(Number);return!Number.isFinite(x)||!Number.isFinite(y)||!Number.isFinite(width)||!Number.isFinite(height)||width<=0||height<=0?null:{src,x,y,width,height}}catch{return null}}function parseThumbnailVtt(source,sourceUrl,URLCtor){const cues=[],normalized=source.replace(/^\uFEFF/u,"").replaceAll(`\r
|
|
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}from"lit";import{property,query,state}from"lit/decorators.js";import{ref}from"lit/directives/ref.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{hostAriaLabel,srOnly}from"../../../internal/a11y.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{MAX_NATIVE_PLAYBACK_RATE,MIN_NATIVE_PLAYBACK_RATE,NATIVE_MEDIA_RELAY_EVENTS,NativeMediaController,canExitFullscreen,canRequestFullscreen,canRequestPictureInPicture,safeNativeMediaSource}from"../../../internal/media-controller.js";import{finiteRange}from"../../../internal/numbers.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{readResponseText,resolveOwnerFetchTarget}from"../../../internal/resource-loader.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{styles}from"./video.styles.js";import{LYRA_DEFAULT_avPlayerPosition,LYRA_DEFAULT_pause,LYRA_DEFAULT_play,LYRA_DEFAULT_playbackPosition,LYRA_DEFAULT_videoCaptions,LYRA_DEFAULT_videoCaptionsOff,LYRA_DEFAULT_videoEnterFullscreen,LYRA_DEFAULT_videoExitFullscreen,LYRA_DEFAULT_videoExitPictureInPicture,LYRA_DEFAULT_videoMute,LYRA_DEFAULT_videoPictureInPicture,LYRA_DEFAULT_videoPlaybackSpeed,LYRA_DEFAULT_videoPlayerLabel,LYRA_DEFAULT_videoUnmute,LYRA_DEFAULT_videoVolume}from"../../../internal/default-strings.generated.js";const MAX_THUMBNAIL_BYTES=256*1024,MAX_THUMBNAIL_CUES=2e3,PLAYBACK_RATES=[.5,.75,1,1.25,1.5,2];function safeControls(value){return value==="none"||value==="full"?value:"standard"}function safePreload(value){return value==="auto"||value==="none"?value:"metadata"}function parseVttTime(source){const parts=source.trim().split(":").map(Number);if(parts.length<2||parts.length>3||parts.some(part=>!Number.isFinite(part)))return null;const seconds=parts.length===3?parts[0]*3600+parts[1]*60+parts[2]:parts[0]*60+parts[1];return seconds>=0?seconds:null}function parseThumbnailUrl(source,baseUrl,URLCtor){const trimmed=source.trim();if(!trimmed)return null;try{const resolved=new URLCtor(trimmed,baseUrl),sprite=/^#xywh=(\d+),(\d+),(\d+),(\d+)$/u.exec(resolved.hash);resolved.hash="";const src=safeMediaSrc(resolved.href,URLCtor);if(!src)return null;if(!sprite)return{src};const[x,y,width,height]=sprite.slice(1).map(Number);return!Number.isFinite(x)||!Number.isFinite(y)||!Number.isFinite(width)||!Number.isFinite(height)||width<=0||height<=0?null:{src,x,y,width,height}}catch{return null}}function parseThumbnailVtt(source,sourceUrl,URLCtor){const cues=[],normalized=source.replace(/^\uFEFF/u,"").replaceAll(`\r
|
|
2
2
|
`,`
|
|
3
3
|
`).replaceAll("\r",`
|
|
4
4
|
`);for(const block of normalized.split(/\n{2,}/u)){if(cues.length>=MAX_THUMBNAIL_CUES)break;const lines=block.split(`
|
|
5
|
-
`).map(line=>line.trim()).filter(Boolean),timingIndex=lines.findIndex(line=>line.includes("-->"));if(timingIndex<0||!lines[timingIndex+1])continue;const match=/^(\S+)\s+-->\s+(\S+)/u.exec(lines[timingIndex]);if(!match)continue;const start=parseVttTime(match[1]),end=parseVttTime(match[2]),thumbnail=parseThumbnailUrl(lines[timingIndex+1],sourceUrl,URLCtor);start===null||end===null||end<=start||!thumbnail||cues.push({start,end,...thumbnail})}return cues}function textTracks(media){const result=[];if(!media)return result;for(let index=0;index<media.textTracks.length;index+=1){const track=media.textTracks[index];track&&result.push(track)}return result}function formatTime(seconds,locale){const total=Math.floor(finiteRange(seconds,0,0)),hours=Math.floor(total/3600),minutes=Math.floor(total%3600/60),remaining=total%60,regular=getNumberFormat(locale,{maximumFractionDigits:0,useGrouping:!1}),padded=getNumberFormat(locale,{maximumFractionDigits:0,minimumIntegerDigits:2,useGrouping:!1});return hours>0?`${regular.format(hours)}:${padded.format(minutes)}:${padded.format(remaining)}`:`${regular.format(minutes)}:${padded.format(remaining)}`}function unsupportedPromise(host,message){const DOMExceptionConstructor=host.ownerDocument.defaultView?.DOMException??DOMException;return Promise.reject(new DOMExceptionConstructor(message,"NotSupportedError"))}class LyraVideo extends LyraElement{constructor(){super(...arguments),this.autoplay=!1,this.autoplayMuted=!1,this.autoplayOnVisible=!1,this.controls="standard",this.currentTime=0,this.duration=0,this.iconLibrary="system",this.loop=!1,this.muted=!1,this.playing=!1,this.poster="",this.preload="metadata",this.src="",this.thumbnails="",this.title="",this.volume=1,this.playbackRate=1,this.posterVisible=!0,this.captionText="",this.captionTracks=[],this.fullscreen=!1,this.pictureInPicture=!1,this.thumbnailCues=[],this.thumbnailPosition=50,this.mediaController=new NativeMediaController(this,{onEvent:event=>this.onNativeMediaEvent(event)}),this.thumbnailGeneration=0,this.visibilityPaused=!1,this.captionListeners=[],this.onControlFocus=event=>{relayNativeEvent(this,event)},this.onControlBlur=event=>{relayNativeEvent(this,event)},this.mediaRef=element=>{const video=element?.localName==="video"?element:void 0;this.mediaController.attach(video),video&&(this.mediaController.volume=finiteRange(this.volume,1,0,1),this.mediaController.muted=this.muted||this.autoplayMuted,this.mediaController.playbackRate=this.playbackRate)},this.onSourceSlotChange=()=>this.syncSources(),this.onTimelineInput=event=>{const input=event.currentTarget;this.seek(Number(input.value))},this.onVolumeInput=event=>{this.setVolume(Number(event.currentTarget.value))},this.onRateChange=event=>{this.setPlaybackRate(Number(event.currentTarget.value))},this.onPosterPlay=()=>{this.play().catch(()=>{})},this.onFullscreenButton=()=>{(this.fullscreen?this.exitFullscreen():this.requestFullscreen()).catch(()=>{})},this.onFullscreenChange=()=>{this.fullscreen=this.ownerDocument.fullscreenElement===this.wrapperEl},this.onPictureInPictureChange=()=>{const documentRef=this.ownerDocument;this.pictureInPicture=documentRef.pictureInPictureElement===this.videoEl},this.togglePictureInPicture=()=>{const video=this.videoEl,documentRef=this.ownerDocument;if(!video||!canRequestPictureInPicture(video))return;(documentRef.pictureInPictureElement===video?documentRef.exitPictureInPicture?.():video.requestPictureInPicture().then(()=>{}))?.catch(()=>{})},this.onCaptionChange=event=>{const selected=Number(event.currentTarget.value);this.captionTracks.forEach(({track},index)=>{track.mode=index===selected?"hidden":"disabled"}),this.syncActiveCaption()},this.onTimelinePointerMove=event=>{const rect=event.currentTarget.getBoundingClientRect();if(rect.width<=0||this.duration<=0){this.activeThumbnail=void 0;return}const ratio=finiteRange((event.clientX-rect.left)/rect.width,0,0,1),time=ratio*this.duration;this.activeThumbnail=this.thumbnailCues.find(cue=>time>=cue.start&&time<cue.end),this.thumbnailPosition=ratio*100},this.onTimelinePointerLeave=()=>{this.activeThumbnail=void 0}}static{this.defaultStrings={...super.defaultStrings,avPlayerPosition:LYRA_DEFAULT_avPlayerPosition,pause:LYRA_DEFAULT_pause,play:LYRA_DEFAULT_play,playbackPosition:LYRA_DEFAULT_playbackPosition,videoCaptions:LYRA_DEFAULT_videoCaptions,videoCaptionsOff:LYRA_DEFAULT_videoCaptionsOff,videoEnterFullscreen:LYRA_DEFAULT_videoEnterFullscreen,videoExitFullscreen:LYRA_DEFAULT_videoExitFullscreen,videoExitPictureInPicture:LYRA_DEFAULT_videoExitPictureInPicture,videoMute:LYRA_DEFAULT_videoMute,videoPictureInPicture:LYRA_DEFAULT_videoPictureInPicture,videoPlaybackSpeed:LYRA_DEFAULT_videoPlaybackSpeed,videoPlayerLabel:LYRA_DEFAULT_videoPlayerLabel,videoUnmute:LYRA_DEFAULT_videoUnmute,videoVolume:LYRA_DEFAULT_videoVolume}}static{this.styles=[LyraElement.styles,styles,srOnly]}static get observedAttributes(){return[...new Set([...super.observedAttributes,"currenttime","current-time"])]}attributeChangedCallback(name,oldValue,newValue){if(name==="currenttime"||name==="current-time"){oldValue!==newValue&&(this.currentTime=finiteRange(Number(newValue??0),0,0));return}super.attributeChangedCallback(name,oldValue,newValue)}get videoEl(){const media=this.mediaController.element;return media?.localName==="video"?media:void 0}get playControl(){return this.renderRoot.querySelector('[part="poster-play-button"], [data-control="play"]')}focus(options){this.playControl?.focus(options)}blur(){this.playControl?.blur()}click(){this.playControl?.click()}connectedCallback(){super.connectedCallback(),this.mediaController.reconnect(),this.ownerDocument.addEventListener("fullscreenchange",this.onFullscreenChange),this.ownerDocument.addEventListener("enterpictureinpicture",this.onPictureInPictureChange,!0),this.ownerDocument.addEventListener("leavepictureinpicture",this.onPictureInPictureChange,!0),this.hasUpdated&&(this.scheduleAfterUpdate(()=>this.bindCaptionTracks(),"video-caption-reconnect"),this.scheduleAfterUpdate(()=>this.configureVisibilityObserver(),"video-visibility-reconnect"),this.thumbnails&&this.scheduleAfterUpdate(()=>{this.loadThumbnails()},"video-thumbnails-reconnect"))}firstUpdated(changed){super.firstUpdated(changed),this.syncSources(),this.configureVisibilityObserver(),this.loadThumbnails()}disconnectedCallback(){this.mediaController.disconnect(),this.thumbnailGeneration+=1,this.thumbnailAbort?.abort(),this.thumbnailAbort=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.unbindCaptionTracks(),this.captionTracks.length&&(this.captionTracks=[]),this.captionText&&(this.captionText=""),this.activeThumbnail&&(this.activeThumbnail=void 0),this.playing&&(this.playing=!1),this.fullscreen&&(this.fullscreen=!1),this.pictureInPicture&&(this.pictureInPicture=!1),this.ownerDocument.removeEventListener("fullscreenchange",this.onFullscreenChange),this.ownerDocument.removeEventListener("enterpictureinpicture",this.onPictureInPictureChange,!0),this.ownerDocument.removeEventListener("leavepictureinpicture",this.onPictureInPictureChange,!0),super.disconnectedCallback()}willUpdate(changed){if(super.willUpdate(changed),changed.has("controls")&&(this.controls=safeControls(this.controls)),changed.has("preload")&&(this.preload=safePreload(this.preload)),changed.has("volume")){const next=finiteRange(this.volume,this.mediaController.volume,0,1);Object.is(next,this.volume)||(this.volume=next),this.mediaController.volume=next}if(changed.has("muted")&&(this.mediaController.muted=this.muted),changed.has("autoplayMuted")&&this.autoplayMuted&&(this.mediaController.muted=!0),changed.has("currentTime")){const max=this.mediaController.duration>0?this.mediaController.duration:Number.POSITIVE_INFINITY,next=finiteRange(this.currentTime,0,0,max);Object.is(next,this.currentTime)||(this.currentTime=next),this.mediaController.currentTime=next}if(changed.has("duration")){const next=finiteRange(this.duration,0,0);Object.is(next,this.duration)||(this.duration=next)}changed.has("src")&&(this.visibilityPaused=!1,this.posterVisible=!0,this.hasUpdated&&(this.playing=!1,this.duration=0,this.currentTime=0,this.scheduleAfterUpdate(()=>this.syncSources(),"video-sources"))),changed.has("thumbnails")&&this.hasUpdated&&this.scheduleAfterUpdate(()=>{this.loadThumbnails()},"video-thumbnails"),changed.has("autoplayOnVisible")&&this.hasUpdated&&this.scheduleAfterUpdate(()=>this.configureVisibilityObserver(),"video-visibility")}sourceSignature(){const nodes=[...this.children].filter(child=>child.localName==="source"||child.localName==="track").map(child=>({tag:child.localName,src:child.getAttribute("src"),type:child.getAttribute("type"),media:child.getAttribute("media"),kind:child.getAttribute("kind"),srclang:child.getAttribute("srclang"),label:child.getAttribute("label"),default:child.hasAttribute("default")}));return JSON.stringify({src:this.src,nodes})}syncSources(force=!1){if(!this.videoEl)return;const signature=this.sourceSignature();!force&&signature===this.lastSourceSignature||(this.lastSourceSignature=signature,this.visibilityPaused=!1,this.unbindCaptionTracks(),this.captionTracks.length&&(this.captionTracks=[]),this.captionText&&(this.captionText=""),this.mediaController.setSources({src:this.src,nodes:this.children}),this.mediaController.currentTime=this.currentTime)}getVideoElement(){return this.videoEl}getState(){const video=this.videoEl;return{playing:!!(video&&!video.paused&&!video.ended),currentTime:this.mediaController.currentTime,duration:this.mediaController.duration,volume:this.mediaController.volume,muted:this.mediaController.muted,playbackRate:this.mediaController.playbackRate}}play(){return this.mediaController.play()}pause(){this.visibilityPaused=!1,this.mediaController.pause()}load(){this.visibilityPaused=!1,this.currentTime=0,this.syncSources(!0)}seek(time){const max=this.mediaController.duration>0?this.mediaController.duration:Number.POSITIVE_INFINITY,next=finiteRange(time,0,0,max);this.mediaController.currentTime=next,this.currentTime=this.mediaController.currentTime;const EventConstructor=this.ownerDocument.defaultView?.Event??Event;this.dispatchEvent(new EventConstructor("timeupdate"))}setPlaybackRate(rate){const next=finiteRange(rate,1,MIN_NATIVE_PLAYBACK_RATE,MAX_NATIVE_PLAYBACK_RATE);this.playbackRate=next,this.mediaController.playbackRate=next}setVolume(volume){const next=finiteRange(volume,this.mediaController.volume,0,1);this.volume=next,this.mediaController.volume=next}toggleMute(){const next=!this.mediaController.muted;this.muted=next,this.mediaController.muted=next}togglePlay(){this.videoEl?.paused??!0?this.play().catch(()=>{}):this.pause()}requestFullscreen(){return canRequestFullscreen(this.wrapperEl)?this.wrapperEl.requestFullscreen():unsupportedPromise(this,"Fullscreen is unavailable for this video.")}exitFullscreen(){return canExitFullscreen(this.ownerDocument)?this.ownerDocument.exitFullscreen():unsupportedPromise(this,"Fullscreen exit is unavailable for this video.")}onNativeMediaEvent(event){if(this.videoEl)switch(event.type){case"loadedmetadata":case"durationchange":this.duration=this.mediaController.duration,this.currentTime=this.mediaController.currentTime,this.bindCaptionTracks();break;case"play":this.playing=!0,this.posterVisible=!1;break;case"pause":case"ended":this.playing=!1;break;case"error":this.playing=!1,this.duration=0,this.currentTime=0;break;case"timeupdate":case"seeked":this.currentTime=this.mediaController.currentTime;break;case"volumechange":this.volume=this.mediaController.volume,this.muted=this.mediaController.muted;break;case"ratechange":this.playbackRate=this.mediaController.playbackRate;break}}canRenderFullscreen(){return typeof this.ownerDocument.defaultView?.HTMLElement.prototype.requestFullscreen=="function"&&this.ownerDocument.fullscreenEnabled!==!1}canRenderPictureInPicture(){const ownerWindow=this.ownerDocument.defaultView,documentRef=this.ownerDocument;return this.controls==="full"&&typeof ownerWindow?.HTMLVideoElement.prototype.requestPictureInPicture=="function"&&documentRef.pictureInPictureEnabled!==!1}pauseForVisibility(){this.visibilityPaused=!0,this.mediaController.pause()}configureVisibilityObserver(){const visibilityOwnedPause=this.visibilityPaused;this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0;const ownerWindow=this.ownerDocument.defaultView,IntersectionObserverCtor=ownerWindow?.IntersectionObserver;if(!this.autoplayOnVisible||!IntersectionObserverCtor){visibilityOwnedPause&&(this.visibilityPaused=!1,this.mediaController.play().catch(()=>{}));return}this.visibilityPaused=visibilityOwnedPause;let observer;observer=new IntersectionObserverCtor(entries=>{if(!observer||!this.isConnected||this.intersectionObserver!==observer||this.ownerDocument.defaultView!==ownerWindow)return;const visible=entries[0]?.isIntersecting??!0,video=this.videoEl;if(video){if(!visible){video.paused||this.pauseForVisibility();return}this.visibilityPaused&&(this.visibilityPaused=!1,this.mediaController.play().catch(()=>{}))}}),this.intersectionObserver=observer,observer.observe(this)}unbindCaptionTracks(){for(const{track,listener}of this.captionListeners)track.removeEventListener("cuechange",listener);this.captionListeners=[]}bindCaptionTracks(){this.unbindCaptionTracks();const selectable=textTracks(this.videoEl).filter(track=>track.kind==="captions"||track.kind==="subtitles");for(const track of selectable)track.mode==="showing"&&(track.mode="hidden");this.captionTracks=selectable.map(track=>({track,label:track.label||track.language||this.localize("videoCaptions"),language:track.language}));for(const track of selectable){const listener=()=>this.syncActiveCaption();track.addEventListener("cuechange",listener),this.captionListeners.push({track,listener})}this.syncActiveCaption()}syncActiveCaption(){const lines=[];for(const{track}of this.captionTracks)if(!(track.mode!=="hidden"||!track.activeCues))for(let index=0;index<track.activeCues.length;index+=1){const cue=track.activeCues[index];cue&&typeof cue.text=="string"&&lines.push(cue.text)}this.captionText=lines.join(`
|
|
5
|
+
`).map(line=>line.trim()).filter(Boolean),timingIndex=lines.findIndex(line=>line.includes("-->"));if(timingIndex<0||!lines[timingIndex+1])continue;const match=/^(\S+)\s+-->\s+(\S+)/u.exec(lines[timingIndex]);if(!match)continue;const start=parseVttTime(match[1]),end=parseVttTime(match[2]),thumbnail=parseThumbnailUrl(lines[timingIndex+1],sourceUrl,URLCtor);start===null||end===null||end<=start||!thumbnail||cues.push({start,end,...thumbnail})}return cues}function textTracks(media){const result=[];if(!media)return result;for(let index=0;index<media.textTracks.length;index+=1){const track=media.textTracks[index];track&&result.push(track)}return result}function formatTime(seconds,locale){const total=Math.floor(finiteRange(seconds,0,0)),hours=Math.floor(total/3600),minutes=Math.floor(total%3600/60),remaining=total%60,regular=getNumberFormat(locale,{maximumFractionDigits:0,useGrouping:!1}),padded=getNumberFormat(locale,{maximumFractionDigits:0,minimumIntegerDigits:2,useGrouping:!1});return hours>0?`${regular.format(hours)}:${padded.format(minutes)}:${padded.format(remaining)}`:`${regular.format(minutes)}:${padded.format(remaining)}`}function unsupportedPromise(host,message){const DOMExceptionConstructor=host.ownerDocument.defaultView?.DOMException??DOMException;return Promise.reject(new DOMExceptionConstructor(message,"NotSupportedError"))}class LyraVideo extends LyraElement{constructor(){super(...arguments),this.autoplay=!1,this.autoplayMuted=!1,this.autoplayOnVisible=!1,this.controls="standard",this.currentTime=0,this.duration=0,this.iconLibrary="system",this.loop=!1,this.muted=!1,this.playing=!1,this.poster="",this.preload="metadata",this.src="",this.thumbnails="",this.title="",this.volume=1,this.playbackRate=1,this.posterVisible=!0,this.captionText="",this.captionTracks=[],this.fullscreen=!1,this.pictureInPicture=!1,this.thumbnailCues=[],this.thumbnailPosition=50,this.mediaController=new NativeMediaController(this,{relayEvents:NATIVE_MEDIA_RELAY_EVENTS.filter(type=>type!=="timeupdate"),onEvent:event=>this.onNativeMediaEvent(event)}),this.pendingNativeEcho={timeupdate:!1,muted:!1},this.thumbnailGeneration=0,this.visibilityPaused=!1,this.captionListeners=[],this.onControlFocus=event=>{relayNativeEvent(this,event)},this.onControlBlur=event=>{relayNativeEvent(this,event)},this.mediaRef=element=>{const video=element?.localName==="video"?element:void 0;this.mediaController.attach(video),video&&(this.mediaController.volume=finiteRange(this.volume,1,0,1),this.autoplayMuted&&!this.muted?this.forceAutoplayMuted():this.mediaController.muted=this.muted,this.mediaController.playbackRate=this.playbackRate)},this.onSourceSlotChange=()=>this.syncSources(),this.onTimelineInput=event=>{const input=event.currentTarget;this.seek(Number(input.value))},this.onVolumeInput=event=>{this.setVolume(Number(event.currentTarget.value))},this.onRateChange=event=>{this.setPlaybackRate(Number(event.currentTarget.value))},this.onPosterPlay=()=>{this.play().catch(()=>{})},this.onFullscreenButton=()=>{(this.fullscreen?this.exitFullscreen():this.requestFullscreen()).catch(()=>{})},this.onFullscreenChange=()=>{this.fullscreen=this.ownerDocument.fullscreenElement===this.wrapperEl},this.onPictureInPictureChange=()=>{const documentRef=this.ownerDocument;this.pictureInPicture=documentRef.pictureInPictureElement===this.videoEl},this.togglePictureInPicture=()=>{const video=this.videoEl,documentRef=this.ownerDocument;if(!video||!canRequestPictureInPicture(video))return;(documentRef.pictureInPictureElement===video?documentRef.exitPictureInPicture?.():video.requestPictureInPicture().then(()=>{}))?.catch(()=>{})},this.onCaptionChange=event=>{const selected=Number(event.currentTarget.value);this.captionTracks.forEach(({track},index)=>{track.mode=index===selected?"hidden":"disabled"}),this.syncActiveCaption()},this.onTimelinePointerMove=event=>{const rect=event.currentTarget.getBoundingClientRect();if(rect.width<=0||this.duration<=0){this.activeThumbnail=void 0;return}const ratio=finiteRange((event.clientX-rect.left)/rect.width,0,0,1),time=ratio*this.duration;this.activeThumbnail=this.thumbnailCues.find(cue=>time>=cue.start&&time<cue.end),this.thumbnailPosition=ratio*100},this.onTimelinePointerLeave=()=>{this.activeThumbnail=void 0}}static{this.defaultStrings={...super.defaultStrings,avPlayerPosition:LYRA_DEFAULT_avPlayerPosition,pause:LYRA_DEFAULT_pause,play:LYRA_DEFAULT_play,playbackPosition:LYRA_DEFAULT_playbackPosition,videoCaptions:LYRA_DEFAULT_videoCaptions,videoCaptionsOff:LYRA_DEFAULT_videoCaptionsOff,videoEnterFullscreen:LYRA_DEFAULT_videoEnterFullscreen,videoExitFullscreen:LYRA_DEFAULT_videoExitFullscreen,videoExitPictureInPicture:LYRA_DEFAULT_videoExitPictureInPicture,videoMute:LYRA_DEFAULT_videoMute,videoPictureInPicture:LYRA_DEFAULT_videoPictureInPicture,videoPlaybackSpeed:LYRA_DEFAULT_videoPlaybackSpeed,videoPlayerLabel:LYRA_DEFAULT_videoPlayerLabel,videoUnmute:LYRA_DEFAULT_videoUnmute,videoVolume:LYRA_DEFAULT_videoVolume}}static{this.styles=[LyraElement.styles,styles,srOnly]}static get observedAttributes(){return[...new Set([...super.observedAttributes,"currenttime","current-time"])]}attributeChangedCallback(name,oldValue,newValue){if(name==="currenttime"||name==="current-time"){oldValue!==newValue&&(this.currentTime=finiteRange(Number(newValue??0),0,0));return}super.attributeChangedCallback(name,oldValue,newValue)}get videoEl(){const media=this.mediaController.element;return media?.localName==="video"?media:void 0}get playControl(){return this.renderRoot.querySelector('[part="poster-play-button"], [data-control="play"]')}focus(options){this.playControl?.focus(options)}blur(){this.playControl?.blur()}click(){this.playControl?.click()}connectedCallback(){super.connectedCallback(),this.mediaController.reconnect(),this.ownerDocument.addEventListener("fullscreenchange",this.onFullscreenChange),this.ownerDocument.addEventListener("enterpictureinpicture",this.onPictureInPictureChange,!0),this.ownerDocument.addEventListener("leavepictureinpicture",this.onPictureInPictureChange,!0),this.hasUpdated&&(this.scheduleAfterUpdate(()=>this.bindCaptionTracks(),"video-caption-reconnect"),this.scheduleAfterUpdate(()=>this.configureVisibilityObserver(),"video-visibility-reconnect"),this.thumbnails&&this.scheduleAfterUpdate(()=>{this.loadThumbnails()},"video-thumbnails-reconnect"))}firstUpdated(changed){super.firstUpdated(changed),this.syncSources(),this.configureVisibilityObserver(),this.loadThumbnails()}disconnectedCallback(){this.mediaController.disconnect(),this.thumbnailGeneration+=1,this.thumbnailAbort?.abort(),this.thumbnailAbort=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.unbindCaptionTracks(),this.captionTracks.length&&(this.captionTracks=[]),this.captionText&&(this.captionText=""),this.activeThumbnail&&(this.activeThumbnail=void 0),this.playing&&(this.playing=!1),this.fullscreen&&(this.fullscreen=!1),this.pictureInPicture&&(this.pictureInPicture=!1),this.ownerDocument.removeEventListener("fullscreenchange",this.onFullscreenChange),this.ownerDocument.removeEventListener("enterpictureinpicture",this.onPictureInPictureChange,!0),this.ownerDocument.removeEventListener("leavepictureinpicture",this.onPictureInPictureChange,!0),super.disconnectedCallback()}willUpdate(changed){if(super.willUpdate(changed),changed.has("controls")&&(this.controls=safeControls(this.controls)),changed.has("preload")&&(this.preload=safePreload(this.preload)),changed.has("volume")){const next=finiteRange(this.volume,this.mediaController.volume,0,1);Object.is(next,this.volume)||(this.volume=next),this.mediaController.volume=next}if(changed.has("muted")&&(this.mediaController.muted=this.muted),changed.has("autoplayMuted")&&this.autoplayMuted&&this.forceAutoplayMuted(),changed.has("currentTime")){const max=this.mediaController.duration>0?this.mediaController.duration:Number.POSITIVE_INFINITY,next=finiteRange(this.currentTime,0,0,max);Object.is(next,this.currentTime)||(this.currentTime=next),this.mediaController.currentTime=next}if(changed.has("duration")){const next=finiteRange(this.duration,0,0);Object.is(next,this.duration)||(this.duration=next)}changed.has("src")&&(this.visibilityPaused=!1,this.posterVisible=!0,this.hasUpdated&&(this.playing=!1,this.duration=0,this.currentTime=0,this.scheduleAfterUpdate(()=>this.syncSources(),"video-sources"))),changed.has("thumbnails")&&this.hasUpdated&&this.scheduleAfterUpdate(()=>{this.loadThumbnails()},"video-thumbnails"),changed.has("autoplayOnVisible")&&this.hasUpdated&&this.scheduleAfterUpdate(()=>this.configureVisibilityObserver(),"video-visibility")}forceAutoplayMuted(){this.pendingNativeEcho.muted=!0,this.mediaController.muted=!0}sourceSignature(){const nodes=[...this.children].filter(child=>child.localName==="source"||child.localName==="track").map(child=>({tag:child.localName,src:child.getAttribute("src"),type:child.getAttribute("type"),media:child.getAttribute("media"),kind:child.getAttribute("kind"),srclang:child.getAttribute("srclang"),label:child.getAttribute("label"),default:child.hasAttribute("default")}));return JSON.stringify({src:this.src,nodes})}syncSources(force=!1){if(!this.videoEl)return;const signature=this.sourceSignature();!force&&signature===this.lastSourceSignature||(this.lastSourceSignature=signature,this.visibilityPaused=!1,this.unbindCaptionTracks(),this.captionTracks.length&&(this.captionTracks=[]),this.captionText&&(this.captionText=""),this.mediaController.setSources({src:this.src,nodes:this.children}),this.mediaController.currentTime=this.currentTime)}getVideoElement(){return this.videoEl}getState(){const video=this.videoEl;return{playing:!!(video&&!video.paused&&!video.ended),currentTime:this.mediaController.currentTime,duration:this.mediaController.duration,volume:this.mediaController.volume,muted:this.mediaController.muted,playbackRate:this.mediaController.playbackRate}}play(){return this.mediaController.play()}pause(){this.visibilityPaused=!1,this.mediaController.pause()}load(){this.visibilityPaused=!1,this.currentTime=0,this.syncSources(!0)}seek(time){const max=this.mediaController.duration>0?this.mediaController.duration:Number.POSITIVE_INFINITY,next=finiteRange(time,0,0,max);this.mediaController.currentTime=next,this.currentTime=this.mediaController.currentTime,this.pendingNativeEcho.timeupdate=!0,this.dispatchHostTimeupdate()}dispatchHostTimeupdate(){const EventConstructor=this.ownerDocument.defaultView?.Event??Event;this.dispatchEvent(new EventConstructor("timeupdate"))}setPlaybackRate(rate){const next=finiteRange(rate,1,MIN_NATIVE_PLAYBACK_RATE,MAX_NATIVE_PLAYBACK_RATE);this.playbackRate=next,this.mediaController.playbackRate=next}rateSelectOptions(){const rates=PLAYBACK_RATES;return rates.includes(this.playbackRate)?rates:[...rates,this.playbackRate].sort((a,b)=>a-b)}setVolume(volume){const next=finiteRange(volume,this.mediaController.volume,0,1);this.volume=next,this.mediaController.volume=next}toggleMute(){const next=!this.mediaController.muted;this.muted=next,this.mediaController.muted=next}togglePlay(){this.videoEl?.paused??!0?this.play().catch(()=>{}):this.pause()}requestFullscreen(){return canRequestFullscreen(this.wrapperEl)?this.wrapperEl.requestFullscreen():unsupportedPromise(this,"Fullscreen is unavailable for this video.")}exitFullscreen(){return canExitFullscreen(this.ownerDocument)?this.ownerDocument.exitFullscreen():unsupportedPromise(this,"Fullscreen exit is unavailable for this video.")}onNativeMediaEvent(event){if(this.videoEl)switch(event.type){case"loadedmetadata":case"durationchange":this.duration=this.mediaController.duration,this.currentTime=this.mediaController.currentTime,this.bindCaptionTracks();break;case"play":this.playing=!0,this.posterVisible=!1;break;case"pause":case"ended":this.playing=!1;break;case"error":this.playing=!1,this.duration=0,this.currentTime=0;break;case"timeupdate":this.currentTime=this.mediaController.currentTime,this.pendingNativeEcho.timeupdate?this.pendingNativeEcho.timeupdate=!1:this.dispatchHostTimeupdate();break;case"seeked":this.currentTime=this.mediaController.currentTime,this.pendingNativeEcho.timeupdate=!1;break;case"volumechange":this.volume=this.mediaController.volume,this.pendingNativeEcho.muted?this.pendingNativeEcho.muted=!1:this.muted=this.mediaController.muted;break;case"ratechange":this.playbackRate=this.mediaController.playbackRate;break}}canRenderFullscreen(){return typeof this.ownerDocument.defaultView?.HTMLElement.prototype.requestFullscreen=="function"&&this.ownerDocument.fullscreenEnabled!==!1}canRenderPictureInPicture(){const ownerWindow=this.ownerDocument.defaultView,documentRef=this.ownerDocument;return this.controls==="full"&&typeof ownerWindow?.HTMLVideoElement.prototype.requestPictureInPicture=="function"&&documentRef.pictureInPictureEnabled!==!1}pauseForVisibility(){this.visibilityPaused=!0,this.mediaController.pause()}configureVisibilityObserver(){const visibilityOwnedPause=this.visibilityPaused;this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0;const ownerWindow=this.ownerDocument.defaultView,IntersectionObserverCtor=ownerWindow?.IntersectionObserver;if(!this.autoplayOnVisible||!IntersectionObserverCtor){visibilityOwnedPause&&(this.visibilityPaused=!1,this.mediaController.play().catch(()=>{}));return}this.visibilityPaused=visibilityOwnedPause;let observer;observer=new IntersectionObserverCtor(entries=>{if(!observer||!this.isConnected||this.intersectionObserver!==observer||this.ownerDocument.defaultView!==ownerWindow)return;const visible=entries[0]?.isIntersecting??!0,video=this.videoEl;if(video){if(!visible){video.paused||this.pauseForVisibility();return}this.visibilityPaused&&(this.visibilityPaused=!1,this.mediaController.play().catch(()=>{}))}}),this.intersectionObserver=observer,observer.observe(this)}unbindCaptionTracks(){for(const{track,listener}of this.captionListeners)track.removeEventListener("cuechange",listener);this.captionListeners=[]}bindCaptionTracks(){this.unbindCaptionTracks();const selectable=textTracks(this.videoEl).filter(track=>track.kind==="captions"||track.kind==="subtitles");for(const track of selectable)track.mode==="showing"&&(track.mode="hidden");this.captionTracks=selectable.map(track=>({track,label:track.label||track.language||this.localize("videoCaptions"),language:track.language}));for(const track of selectable){const listener=()=>this.syncActiveCaption();track.addEventListener("cuechange",listener),this.captionListeners.push({track,listener})}this.syncActiveCaption()}syncActiveCaption(){const lines=[];for(const{track}of this.captionTracks)if(!(track.mode!=="hidden"||!track.activeCues))for(let index=0;index<track.activeCues.length;index+=1){const cue=track.activeCues[index];cue&&typeof cue.text=="string"&&lines.push(cue.text)}this.captionText=lines.join(`
|
|
6
6
|
`)}async loadThumbnails(){const generation=++this.thumbnailGeneration;this.thumbnailAbort?.abort(),this.thumbnailAbort=void 0,this.thumbnailCues.length&&(this.thumbnailCues=[]),this.activeThumbnail&&(this.activeThumbnail=void 0);const fetchTarget=resolveOwnerFetchTarget(this,this.thumbnails),AbortControllerCtor=fetchTarget?.view.AbortController;if(!fetchTarget||!AbortControllerCtor)return;const controller=new AbortControllerCtor;this.thumbnailAbort=controller;try{const response=await fetchTarget.view.fetch(fetchTarget.url,{signal:controller.signal});if(generation!==this.thumbnailGeneration||!this.isConnected||this.ownerDocument.defaultView!==fetchTarget.view||!response.ok)return;const text=await readResponseText(response,MAX_THUMBNAIL_BYTES);if(generation!==this.thumbnailGeneration||!this.isConnected||this.ownerDocument.defaultView!==fetchTarget.view)return;this.thumbnailCues=parseThumbnailVtt(text,fetchTarget.url,fetchTarget.view.URL)}catch{if(generation!==this.thumbnailGeneration||!this.isConnected)return;this.thumbnailCues=[],this.activeThumbnail=void 0}finally{generation===this.thumbnailGeneration&&(this.thumbnailAbort=void 0)}}renderIcon(name,path){return html`<lr-icon library=${this.iconLibrary} name=${name} aria-hidden="true">
|
|
7
7
|
<path d=${path}></path>
|
|
8
8
|
</lr-icon>`}renderDecorativeIconLayer(content){return html`<span class="control-icon-layer" aria-hidden="true" inert>${content}</span>`}renderPlaySlots(){return html`
|
|
@@ -123,7 +123,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
123
123
|
aria-label=${this.localize("videoPlaybackSpeed")}
|
|
124
124
|
@change=${this.onRateChange}
|
|
125
125
|
>
|
|
126
|
-
${
|
|
126
|
+
${this.rateSelectOptions().map(rate=>html`
|
|
127
127
|
<option value=${String(rate)} ?selected=${rate===this.playbackRate}>
|
|
128
128
|
${getNumberFormat(this.effectiveLocale,{maximumFractionDigits:2}).format(rate)}×
|
|
129
129
|
</option>
|
|
@@ -60,6 +60,10 @@ import{css}from"lit";const styles=css`
|
|
|
60
60
|
color: var(--controls-color, var(--lr-color-on-strong-overlay));
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
.icon-button-stack[hidden] {
|
|
64
|
+
display: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
63
67
|
.icon-button-stack > button,
|
|
64
68
|
.icon-button-stack > .control-icon-layer {
|
|
65
69
|
grid-area: 1 / 1;
|
|
@@ -256,8 +260,6 @@ import{css}from"lit";const styles=css`
|
|
|
256
260
|
min-block-size: var(--lr-icon-button-size);
|
|
257
261
|
display: flex;
|
|
258
262
|
align-items: center;
|
|
259
|
-
/* Elapsed time is a physical media axis, rather than reading-direction navigation: native
|
|
260
|
-
ArrowRight therefore advances and ArrowLeft rewinds in both LTR and RTL. */
|
|
261
263
|
direction: ltr;
|
|
262
264
|
}
|
|
263
265
|
|
|
@@ -81,8 +81,9 @@ export declare class LyraZoomableFrame extends LyraElement<LyraZoomableFrameEven
|
|
|
81
81
|
* a localized purpose title; a property-only value names the iframe. An explicitly empty host
|
|
82
82
|
* name is preserved as an empty iframe title instead of being replaced through truthiness. */
|
|
83
83
|
accessibleLabel: string | null;
|
|
84
|
-
/** The internal iframe
|
|
85
|
-
|
|
84
|
+
/** The internal iframe; replaced whenever navigation policy changes. An explicit `get` (rather
|
|
85
|
+
* than `@query`) so the generated manifest marks it readonly, not merely by convention. */
|
|
86
|
+
get iframe(): HTMLIFrameElement | undefined;
|
|
86
87
|
private cachedZoomLevelsSource;
|
|
87
88
|
private cachedZoomLevels;
|
|
88
89
|
/** Focus the internal iframe when interaction is enabled and a live frame is connected. */
|
|
@@ -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}from"lit";import{property,query}from"lit/decorators.js";import{keyed}from"lit/directives/keyed.js";import{LyraElement}from"../../../internal/lyra-element.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{finiteRange}from"../../../internal/numbers.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{safeDownloadHref}from"../../../internal/safe-url.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{styles}from"./zoomable-frame.styles.js";import{LYRA_DEFAULT_zoomControls,LYRA_DEFAULT_zoomIn,LYRA_DEFAULT_zoomOut,LYRA_DEFAULT_zoomableFrameLabel}from"../../../internal/default-strings.generated.js";const DEFAULT_ZOOM_LEVELS="25% 50% 75% 100% 125% 150% 175% 200%",DEFAULT_IFRAME_SANDBOX="allow-same-origin",DEFAULT_ZOOM_LEVEL_VALUES=[.25,.5,.75,1,1.25,1.5,1.75,2],MIN_ZOOM=.01,MAX_ZOOM=1e3,MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS=16384,MAX_ZOOM_LEVEL_TOKENS=256,SANDBOX_TOKENS=new Set(["allow-downloads","allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-storage-access-by-user-activation","allow-top-navigation","allow-top-navigation-by-user-activation","allow-top-navigation-to-custom-protocols"]),REFERRER_POLICIES=new Set(["no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"]),THEME_ATTRIBUTES=["data-lr-theme","data-theme","data-color-scheme"];function isLyraThemeClass(value){return value==="lr-light"||value==="lr-dark"||value.startsWith("lr-theme-")||value.startsWith("lr-brand-")||value.startsWith("lr-palette-")}function safeZoomableFrameSrc(value){return typeof value=="string"&&value.trim().toLowerCase()==="about:blank"?value.trim():safeDownloadHref(value)}function safeZoomableFrameSandbox(value){if(typeof value!="string")return"";const tokens=[...new Set(value.toLowerCase().split(/\s+/).filter(token=>SANDBOX_TOKENS.has(token)))];return tokens.includes("allow-scripts")&&tokens.includes("allow-same-origin")?tokens.filter(token=>token!=="allow-same-origin").join(" "):tokens.join(" ")}function safeLoading(value){return value==="lazy"?"lazy":"eager"}function safeReferrerPolicy(value){return value===""||value==null?null:typeof value=="string"&&REFERRER_POLICIES.has(value)?value:"no-referrer"}function parseZoomLevels(value){if(typeof value!="string")return DEFAULT_ZOOM_LEVEL_VALUES;const source=value.slice(0,MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS),finalTokenContinues=value.length>MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS&&/\S/u.test(source.at(-1)??"")&&/\S/u.test(value[MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS]??""),tokenPattern=/\S+/g,unique=new Set;let tokenCount=0,match;for(;tokenCount<MAX_ZOOM_LEVEL_TOKENS&&(match=tokenPattern.exec(source))!==null&&!(finalTokenContinues&&tokenPattern.lastIndex===source.length);){tokenCount+=1;const token=match[0],percent=token.endsWith("%"),parsed=Number(percent?token.slice(0,-1):token),level=percent?parsed/100:parsed;Number.isFinite(level)&&level>=MIN_ZOOM&&level<=MAX_ZOOM&&unique.add(level)}return unique.size===0?DEFAULT_ZOOM_LEVEL_VALUES:Object.freeze([...unique].sort((left,right)=>left-right))}class LyraZoomableFrame extends LyraElement{static{this.defaultStrings={...super.defaultStrings,zoomControls:LYRA_DEFAULT_zoomControls,zoomIn:LYRA_DEFAULT_zoomIn,zoomOut:LYRA_DEFAULT_zoomOut,zoomableFrameLabel:LYRA_DEFAULT_zoomableFrameLabel}}static{this.styles=[LyraElement.styles,styles]}focus(options){const frame=this.iframe;if(!frame||!this.isConnected||this.withoutInteraction||frame.inert)return;const previous=this.ownerDocument.activeElement,wasFocused=this.frameOwnsFocus(frame);frame.focus(options),!wasFocused&&this.frameOwnsFocus(frame)&&this.emitHostFocus(void 0,previous)}blur(){const frame=this.iframe;!frame||!this.frameOwnsFocus(frame)||(frame.blur(),this.frameOwnsFocus(frame)||this.emitHostBlur(void 0,this.ownerDocument.activeElement))}click(){this.isConnected&&!this.withoutInteraction&&!this.iframe?.inert&&this.iframe?.click()}frameIsActive(frame=this.iframe){return!!(frame&&this.isConnected&&(this.shadowRoot?.activeElement===frame||this.ownerDocument.activeElement===this))}frameOwnsFocus(frame=this.iframe){return!!(frame&&!frame.inert&&!this.withoutInteraction&&this.frameIsActive(frame))}setFrameFocused(focused){this.toggleAttribute("data-frame-focused",focused)}dispatchHostFocusEvent(type,source,relatedTarget=null){const view=this.ownerDocument.defaultView;if(!view)return;const nativeSource=new view.FocusEvent(type,{relatedTarget:source?.relatedTarget??relatedTarget,view,detail:source?.detail??0});relayNativeEvent(this,nativeSource)}emitHostFocus(source,relatedTarget=null){this.hasEmittedFocus||(this.hasEmittedFocus=!0,this.setFrameFocused(!0),this.dispatchHostFocusEvent("focus",source,relatedTarget))}emitHostBlur(source,relatedTarget=null){this.hasEmittedFocus&&(this.hasEmittedFocus=!1,this.setFrameFocused(!1),this.dispatchHostFocusEvent("blur",source,relatedTarget))}resetFocusBoundaryDocument(){this.focusBoundaryDocument?.removeEventListener("keydown",this.onFocusBoundaryKeyDown,!0),this.focusBoundaryDocument?.removeEventListener("pointerdown",this.scheduleFrameFocusReconciliation,!0),this.focusBoundaryDocument=void 0}bindFocusBoundaryDocument(){let target=null;try{target=this.contentDocument}catch{}!target||target===this.focusBoundaryDocument||(this.resetFocusBoundaryDocument(),this.focusBoundaryDocument=target,target.addEventListener("keydown",this.onFocusBoundaryKeyDown,!0),target.addEventListener("pointerdown",this.scheduleFrameFocusReconciliation,!0))}constructor(){super(),this.src="",this.srcdoc="",this.allowfullscreen=!1,this.loading="eager",this.referrerpolicy="",this.sandbox=DEFAULT_IFRAME_SANDBOX,this.zoom=1,this.zoomLevels=DEFAULT_ZOOM_LEVELS,this.withoutControls=!1,this.withoutInteraction=!1,this.withThemeSync=!1,this.accessibleLabel=null,this.cachedZoomLevelsSource=Symbol("uncached zoom levels"),this.cachedZoomLevels=DEFAULT_ZOOM_LEVEL_VALUES,this.hasEmittedFocus=!1,this.onFrameFocus=event=>{event.stopPropagation(),this.frameOwnsFocus(event.currentTarget)&&this.emitHostFocus(event)},this.onFrameBlur=event=>{event.stopPropagation(),!this.frameOwnsFocus(event.currentTarget)&&this.emitHostBlur(event)},this.focusReconciliationGeneration=0,this.scheduleFrameFocusReconciliation=()=>{const view=this.ownerDocument.defaultView;if(!view)return;const generation=++this.focusReconciliationGeneration;view.setTimeout(()=>{generation!==this.focusReconciliationGeneration||!this.isConnected||(this.frameOwnsFocus()?this.emitHostFocus():this.emitHostBlur(void 0,this.ownerDocument.activeElement))},0)},this.onFocusBoundaryKeyDown=event=>{event.key==="Tab"&&this.scheduleFrameFocusReconciliation()},this.navigationGeneration=0,this.needsReconnectFrame=!1,this.syncedThemeClasses=new Set,this.syncedThemeProperties=new Set,this.onControlsKeyDown=event=>{event.altKey||event.ctrlKey||event.metaKey||(event.key==="+"||event.key==="="?(event.preventDefault(),this.zoomIn()):(event.key==="-"||event.key==="_")&&(event.preventDefault(),this.zoomOut()))},new ThemeWatcher(this,()=>this.syncTheme())}connectedCallback(){super.connectedCallback(),this.ownerDocument.addEventListener("focusin",this.scheduleFrameFocusReconciliation,!0),this.ownerDocument.addEventListener("focusout",this.scheduleFrameFocusReconciliation,!0),this.ownerDocument.addEventListener("keydown",this.onFocusBoundaryKeyDown,!0),this.ownerDocument.defaultView?.addEventListener("focus",this.scheduleFrameFocusReconciliation),this.ownerDocument.defaultView?.addEventListener("blur",this.scheduleFrameFocusReconciliation);const Observer=this.ownerDocument.defaultView?.MutationObserver;Observer&&(this.lyraThemeObserver?.disconnect(),this.lyraThemeObserver=new Observer(()=>this.syncTheme()),this.lyraThemeObserver.observe(this.ownerDocument.documentElement,{attributes:!0,attributeFilter:["data-lr-theme"]})),this.needsReconnectFrame&&(this.needsReconnectFrame=!1,this.requestUpdate())}disconnectedCallback(){this.focusReconciliationGeneration++,this.ownerDocument.removeEventListener("focusin",this.scheduleFrameFocusReconciliation,!0),this.ownerDocument.removeEventListener("focusout",this.scheduleFrameFocusReconciliation,!0),this.ownerDocument.removeEventListener("keydown",this.onFocusBoundaryKeyDown,!0),this.ownerDocument.defaultView?.removeEventListener("focus",this.scheduleFrameFocusReconciliation),this.ownerDocument.defaultView?.removeEventListener("blur",this.scheduleFrameFocusReconciliation),this.navigationGeneration++,this.needsReconnectFrame=!0,this.hasEmittedFocus=!1,this.setFrameFocused(!1),this.resetFocusBoundaryDocument(),this.lyraThemeObserver?.disconnect(),this.lyraThemeObserver=void 0,this.resetThemeSyncState(),super.disconnectedCallback()}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),name==="srcdoc"&&oldValue===null!=(value===null)&&(this.navigationGeneration++,this.requestUpdate())}willUpdate(changed){if(super.willUpdate(changed),changed.has("src")||changed.has("srcdoc")||changed.has("allowfullscreen")||changed.has("loading")||changed.has("referrerpolicy")||changed.has("sandbox")){const frame=this.iframe,wasFocused=this.frameIsActive(frame);frame?.blur(),wasFocused&&!this.frameIsActive(frame)&&this.emitHostBlur(void 0,this.ownerDocument.activeElement),this.setFrameFocused(!1),this.resetFocusBoundaryDocument(),this.navigationGeneration++}if(changed.has("withoutInteraction")&&this.withoutInteraction){const frame=this.iframe,wasFocused=this.frameIsActive(frame);frame?.blur(),wasFocused&&this.emitHostBlur(void 0,this.ownerDocument.activeElement),this.setFrameFocused(!1)}}updated(changed){super.updated(changed),changed.has("withThemeSync")&&(this.withThemeSync?this.syncTheme():this.restoreTheme())}get contentWindow(){return this.isConnected?this.iframe?.contentWindow??null:null}get contentDocument(){if(!this.isConnected)return null;try{return this.iframe?.contentDocument??null}catch{return null}}get safeZoom(){return finiteRange(this.zoom,1,MIN_ZOOM,MAX_ZOOM)}get availableZoomLevels(){const source=this.zoomLevels;return source===this.cachedZoomLevelsSource?this.cachedZoomLevels:(this.cachedZoomLevelsSource=source,this.cachedZoomLevels=parseZoomLevels(source),this.cachedZoomLevels)}get hasInlineDocument(){return this.hasAttribute("srcdoc")||typeof this.srcdoc=="string"&&this.srcdoc!==""}get hasNavigation(){return this.hasInlineDocument||safeZoomableFrameSrc(this.src)!==null}navigationSignature(){const inline=this.hasInlineDocument;return JSON.stringify([inline,inline?this.srcdoc:safeZoomableFrameSrc(this.src),this.allowfullscreen,safeLoading(this.loading),safeReferrerPolicy(this.referrerpolicy),safeZoomableFrameSandbox(this.sandbox)])}zoomIn(){const current=this.safeZoom,next=this.availableZoomLevels.find(level=>level>current);next!==void 0&&(this.zoom=next)}zoomOut(){const current=this.safeZoom,levels=this.availableZoomLevels;for(let index=levels.length-1;index>=0;index--){const previous=levels[index];if(previous!==void 0&&previous<current){this.zoom=previous;return}}}isZoomInDisabled(){return!this.availableZoomLevels.some(level=>level>this.safeZoom)}isZoomOutDisabled(){return!this.availableZoomLevels.some(level=>level<this.safeZoom)}dispatchFrameEvent(type){const EventConstructor=this.ownerDocument.defaultView?.Event??Event;type==="load"?this.dispatchEvent(new EventConstructor("load",{bubbles:!1,composed:!1})):this.dispatchEvent(new EventConstructor("error",{bubbles:!1,composed:!1}))}onFrameEvent(type,source,generation,navigationSignature){source.stopPropagation(),!(!this.isConnected||!this.hasNavigation||generation!==this.navigationGeneration||navigationSignature!==this.navigationSignature()||source.currentTarget!==this.iframe)&&(type==="load"&&(this.bindFocusBoundaryDocument(),this.syncTheme()),this.dispatchFrameEvent(type))}syncTheme(){if(!this.withThemeSync||!this.isConnected)return;const target=this.contentDocument?.documentElement,source=this.ownerDocument.documentElement;if(!(!target||!source))try{const state=this.themeStateFor(target),nextClasses=new Set([...source.classList].filter(isLyraThemeClass));for(const className of this.syncedThemeClasses)nextClasses.has(className)||this.setSyncedThemeClass(state,className,!1);for(const className of nextClasses)this.setSyncedThemeClass(state,className,!0);this.syncedThemeClasses=nextClasses;for(const attribute of THEME_ATTRIBUTES){const value=source.getAttribute(attribute);this.setSyncedThemeAttribute(state,attribute,value)}const computed=this.ownerDocument.defaultView?.getComputedStyle(this);if(!computed)return;const nextProperties=new Set;for(let index=0;index<computed.length;index++){const property2=computed.item(index);property2.startsWith("--lr-theme-")&&(this.setSyncedThemeProperty(state,property2,computed.getPropertyValue(property2)),nextProperties.add(property2))}for(const property2 of this.syncedThemeProperties)nextProperties.has(property2)||this.setSyncedThemeProperty(state,property2,null);this.syncedThemeProperties=nextProperties,this.setSyncedThemeProperty(state,"color-scheme",computed.colorScheme)}catch{}}themeStateFor(target){if(this.themeSyncState?.target===target)return this.themeSyncState;this.resetThemeSyncState();const state={target,classes:new Map,attributes:new Map,properties:new Map};return this.themeSyncState=state,state}setSyncedThemeClass(state,className,present){let mutation=state.classes.get(className);mutation||(mutation={original:state.target.classList.contains(className),applied:state.target.classList.contains(className)},state.classes.set(className,mutation)),state.target.classList.toggle(className,present),mutation.applied=state.target.classList.contains(className)}setSyncedThemeAttribute(state,attribute,value){let mutation=state.attributes.get(attribute);if(!mutation){const original=state.target.getAttribute(attribute);mutation={original,applied:original},state.attributes.set(attribute,mutation)}value===null?state.target.removeAttribute(attribute):state.target.setAttribute(attribute,value),mutation.applied=state.target.getAttribute(attribute)}setSyncedThemeProperty(state,property2,value){let mutation=state.properties.get(property2);mutation||(mutation={original:state.target.style.getPropertyValue(property2),originalPriority:state.target.style.getPropertyPriority(property2),applied:state.target.style.getPropertyValue(property2),appliedPriority:state.target.style.getPropertyPriority(property2)},state.properties.set(property2,mutation)),value===null?state.target.style.removeProperty(property2):state.target.style.setProperty(property2,value),mutation.applied=state.target.style.getPropertyValue(property2),mutation.appliedPriority=state.target.style.getPropertyPriority(property2)}restoreTheme(){const state=this.themeSyncState;if(state)try{if(this.contentDocument?.documentElement!==state.target)return;for(const[className,mutation]of state.classes)state.target.classList.contains(className)===mutation.applied&&state.target.classList.toggle(className,mutation.original);for(const[attribute,mutation]of state.attributes)state.target.getAttribute(attribute)===mutation.applied&&(mutation.original===null?state.target.removeAttribute(attribute):state.target.setAttribute(attribute,mutation.original));for(const[property2,mutation]of state.properties)state.target.style.getPropertyValue(property2)!==mutation.applied||state.target.style.getPropertyPriority(property2)!==mutation.appliedPriority||(mutation.original?state.target.style.setProperty(property2,mutation.original,mutation.originalPriority):state.target.style.removeProperty(property2))}catch{}finally{this.resetThemeSyncState()}}resetThemeSyncState(){this.themeSyncState=void 0,this.syncedThemeClasses.clear(),this.syncedThemeProperties.clear()}renderControls(){return this.withoutControls?nothing:html`<div
|
|
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}from"lit";import{property}from"lit/decorators.js";import{keyed}from"lit/directives/keyed.js";import{LyraElement}from"../../../internal/lyra-element.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{finiteRange}from"../../../internal/numbers.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{safeDownloadHref}from"../../../internal/safe-url.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{styles}from"./zoomable-frame.styles.js";import{LYRA_DEFAULT_zoomControls,LYRA_DEFAULT_zoomIn,LYRA_DEFAULT_zoomOut,LYRA_DEFAULT_zoomableFrameLabel}from"../../../internal/default-strings.generated.js";const DEFAULT_ZOOM_LEVELS="25% 50% 75% 100% 125% 150% 175% 200%",DEFAULT_IFRAME_SANDBOX="allow-same-origin",DEFAULT_ZOOM_LEVEL_VALUES=[.25,.5,.75,1,1.25,1.5,1.75,2],MIN_ZOOM=.01,MAX_ZOOM=1e3,MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS=16384,MAX_ZOOM_LEVEL_TOKENS=256,SANDBOX_TOKENS=new Set(["allow-downloads","allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-storage-access-by-user-activation","allow-top-navigation","allow-top-navigation-by-user-activation","allow-top-navigation-to-custom-protocols"]),REFERRER_POLICIES=new Set(["no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"]),THEME_ATTRIBUTES=["data-lr-theme","data-theme","data-color-scheme"];function isLyraThemeClass(value){return value==="lr-light"||value==="lr-dark"||value.startsWith("lr-theme-")||value.startsWith("lr-brand-")||value.startsWith("lr-palette-")}function safeZoomableFrameSrc(value){return typeof value=="string"&&value.trim().toLowerCase()==="about:blank"?value.trim():safeDownloadHref(value)}function safeZoomableFrameSandbox(value){if(typeof value!="string")return"";const tokens=[...new Set(value.toLowerCase().split(/\s+/).filter(token=>SANDBOX_TOKENS.has(token)))];return tokens.includes("allow-scripts")&&tokens.includes("allow-same-origin")?tokens.filter(token=>token!=="allow-same-origin").join(" "):tokens.join(" ")}function safeLoading(value){return value==="lazy"?"lazy":"eager"}function safeReferrerPolicy(value){return value===""||value==null?null:typeof value=="string"&&REFERRER_POLICIES.has(value)?value:"no-referrer"}function parseZoomLevels(value){if(typeof value!="string")return DEFAULT_ZOOM_LEVEL_VALUES;const source=value.slice(0,MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS),finalTokenContinues=value.length>MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS&&/\S/u.test(source.at(-1)??"")&&/\S/u.test(value[MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS]??""),tokenPattern=/\S+/g,unique=new Set;let tokenCount=0,match;for(;tokenCount<MAX_ZOOM_LEVEL_TOKENS&&(match=tokenPattern.exec(source))!==null&&!(finalTokenContinues&&tokenPattern.lastIndex===source.length);){tokenCount+=1;const token=match[0],percent=token.endsWith("%"),parsed=Number(percent?token.slice(0,-1):token),level=percent?parsed/100:parsed;Number.isFinite(level)&&level>=MIN_ZOOM&&level<=MAX_ZOOM&&unique.add(level)}return unique.size===0?DEFAULT_ZOOM_LEVEL_VALUES:Object.freeze([...unique].sort((left,right)=>left-right))}class LyraZoomableFrame extends LyraElement{static{this.defaultStrings={...super.defaultStrings,zoomControls:LYRA_DEFAULT_zoomControls,zoomIn:LYRA_DEFAULT_zoomIn,zoomOut:LYRA_DEFAULT_zoomOut,zoomableFrameLabel:LYRA_DEFAULT_zoomableFrameLabel}}static{this.styles=[LyraElement.styles,styles]}get iframe(){return this.renderRoot?.querySelector("iframe")??void 0}focus(options){const frame=this.iframe;if(!frame||!this.isConnected||this.withoutInteraction||frame.inert)return;const previous=this.ownerDocument.activeElement,wasFocused=this.frameOwnsFocus(frame);frame.focus(options),!wasFocused&&this.frameOwnsFocus(frame)&&this.emitHostFocus(void 0,previous)}blur(){const frame=this.iframe;!frame||!this.frameOwnsFocus(frame)||(frame.blur(),this.frameOwnsFocus(frame)||this.emitHostBlur(void 0,this.ownerDocument.activeElement))}click(){this.isConnected&&!this.withoutInteraction&&!this.iframe?.inert&&this.iframe?.click()}frameIsActive(frame=this.iframe){return!!(frame&&this.isConnected&&(this.shadowRoot?.activeElement===frame||this.ownerDocument.activeElement===this))}frameOwnsFocus(frame=this.iframe){return!!(frame&&!frame.inert&&!this.withoutInteraction&&this.frameIsActive(frame))}setFrameFocused(focused){this.toggleAttribute("data-frame-focused",focused)}dispatchHostFocusEvent(type,source,relatedTarget=null){const view=this.ownerDocument.defaultView;if(!view)return;const nativeSource=new view.FocusEvent(type,{relatedTarget:source?.relatedTarget??relatedTarget,view,detail:source?.detail??0});relayNativeEvent(this,nativeSource)}emitHostFocus(source,relatedTarget=null){this.hasEmittedFocus||(this.hasEmittedFocus=!0,this.setFrameFocused(!0),this.dispatchHostFocusEvent("focus",source,relatedTarget))}emitHostBlur(source,relatedTarget=null){this.hasEmittedFocus&&(this.hasEmittedFocus=!1,this.setFrameFocused(!1),this.dispatchHostFocusEvent("blur",source,relatedTarget))}resetFocusBoundaryDocument(){this.focusBoundaryDocument?.removeEventListener("keydown",this.onFocusBoundaryKeyDown,!0),this.focusBoundaryDocument?.removeEventListener("pointerdown",this.scheduleFrameFocusReconciliation,!0),this.focusBoundaryDocument=void 0}bindFocusBoundaryDocument(){let target=null;try{target=this.contentDocument}catch{}!target||target===this.focusBoundaryDocument||(this.resetFocusBoundaryDocument(),this.focusBoundaryDocument=target,target.addEventListener("keydown",this.onFocusBoundaryKeyDown,!0),target.addEventListener("pointerdown",this.scheduleFrameFocusReconciliation,!0))}constructor(){super(),this.src="",this.srcdoc="",this.allowfullscreen=!1,this.loading="eager",this.referrerpolicy="",this.sandbox=DEFAULT_IFRAME_SANDBOX,this.zoom=1,this.zoomLevels=DEFAULT_ZOOM_LEVELS,this.withoutControls=!1,this.withoutInteraction=!1,this.withThemeSync=!1,this.accessibleLabel=null,this.cachedZoomLevelsSource=Symbol("uncached zoom levels"),this.cachedZoomLevels=DEFAULT_ZOOM_LEVEL_VALUES,this.hasEmittedFocus=!1,this.onFrameFocus=event=>{event.stopPropagation(),this.frameOwnsFocus(event.currentTarget)&&this.emitHostFocus(event)},this.onFrameBlur=event=>{event.stopPropagation(),!this.frameOwnsFocus(event.currentTarget)&&this.emitHostBlur(event)},this.focusReconciliationGeneration=0,this.scheduleFrameFocusReconciliation=()=>{const view=this.ownerDocument.defaultView;if(!view)return;const generation=++this.focusReconciliationGeneration;view.setTimeout(()=>{generation!==this.focusReconciliationGeneration||!this.isConnected||(this.frameOwnsFocus()?this.emitHostFocus():this.emitHostBlur(void 0,this.ownerDocument.activeElement))},0)},this.onFocusBoundaryKeyDown=event=>{event.key==="Tab"&&this.scheduleFrameFocusReconciliation()},this.navigationGeneration=0,this.needsReconnectFrame=!1,this.syncedThemeClasses=new Set,this.syncedThemeProperties=new Set,this.onControlsKeyDown=event=>{event.altKey||event.ctrlKey||event.metaKey||(event.key==="+"||event.key==="="?(event.preventDefault(),this.zoomIn()):(event.key==="-"||event.key==="_")&&(event.preventDefault(),this.zoomOut()))},new ThemeWatcher(this,()=>this.syncTheme())}connectedCallback(){super.connectedCallback(),this.ownerDocument.addEventListener("focusin",this.scheduleFrameFocusReconciliation,!0),this.ownerDocument.addEventListener("focusout",this.scheduleFrameFocusReconciliation,!0),this.ownerDocument.addEventListener("keydown",this.onFocusBoundaryKeyDown,!0),this.ownerDocument.defaultView?.addEventListener("focus",this.scheduleFrameFocusReconciliation),this.ownerDocument.defaultView?.addEventListener("blur",this.scheduleFrameFocusReconciliation);const Observer=this.ownerDocument.defaultView?.MutationObserver;Observer&&(this.lyraThemeObserver?.disconnect(),this.lyraThemeObserver=new Observer(()=>this.syncTheme()),this.lyraThemeObserver.observe(this.ownerDocument.documentElement,{attributes:!0,attributeFilter:["data-lr-theme"]})),this.needsReconnectFrame&&(this.needsReconnectFrame=!1,this.requestUpdate())}disconnectedCallback(){this.focusReconciliationGeneration++,this.ownerDocument.removeEventListener("focusin",this.scheduleFrameFocusReconciliation,!0),this.ownerDocument.removeEventListener("focusout",this.scheduleFrameFocusReconciliation,!0),this.ownerDocument.removeEventListener("keydown",this.onFocusBoundaryKeyDown,!0),this.ownerDocument.defaultView?.removeEventListener("focus",this.scheduleFrameFocusReconciliation),this.ownerDocument.defaultView?.removeEventListener("blur",this.scheduleFrameFocusReconciliation),this.navigationGeneration++,this.needsReconnectFrame=!0,this.hasEmittedFocus=!1,this.setFrameFocused(!1),this.resetFocusBoundaryDocument(),this.lyraThemeObserver?.disconnect(),this.lyraThemeObserver=void 0,this.resetThemeSyncState(),super.disconnectedCallback()}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),name==="srcdoc"&&oldValue===null!=(value===null)&&(this.navigationGeneration++,this.requestUpdate())}willUpdate(changed){if(super.willUpdate(changed),changed.has("src")||changed.has("srcdoc")||changed.has("allowfullscreen")||changed.has("loading")||changed.has("referrerpolicy")||changed.has("sandbox")){const frame=this.iframe,wasFocused=this.frameIsActive(frame);frame?.blur(),wasFocused&&!this.frameIsActive(frame)&&this.emitHostBlur(void 0,this.ownerDocument.activeElement),this.setFrameFocused(!1),this.resetFocusBoundaryDocument(),this.navigationGeneration++}if(changed.has("withoutInteraction")&&this.withoutInteraction){const frame=this.iframe,wasFocused=this.frameIsActive(frame);frame?.blur(),wasFocused&&this.emitHostBlur(void 0,this.ownerDocument.activeElement),this.setFrameFocused(!1)}}updated(changed){super.updated(changed),changed.has("withThemeSync")&&(this.withThemeSync?this.syncTheme():this.restoreTheme())}get contentWindow(){return this.isConnected?this.iframe?.contentWindow??null:null}get contentDocument(){if(!this.isConnected)return null;try{return this.iframe?.contentDocument??null}catch{return null}}get safeZoom(){return finiteRange(this.zoom,1,MIN_ZOOM,MAX_ZOOM)}get availableZoomLevels(){const source=this.zoomLevels;return source===this.cachedZoomLevelsSource?this.cachedZoomLevels:(this.cachedZoomLevelsSource=source,this.cachedZoomLevels=parseZoomLevels(source),this.cachedZoomLevels)}get hasInlineDocument(){return this.hasAttribute("srcdoc")||typeof this.srcdoc=="string"&&this.srcdoc!==""}get hasNavigation(){return this.hasInlineDocument||safeZoomableFrameSrc(this.src)!==null}navigationSignature(){const inline=this.hasInlineDocument;return JSON.stringify([inline,inline?this.srcdoc:safeZoomableFrameSrc(this.src),this.allowfullscreen,safeLoading(this.loading),safeReferrerPolicy(this.referrerpolicy),safeZoomableFrameSandbox(this.sandbox)])}zoomIn(){const current=this.safeZoom,next=this.availableZoomLevels.find(level=>level>current);next!==void 0&&(this.zoom=next)}zoomOut(){const current=this.safeZoom,levels=this.availableZoomLevels;for(let index=levels.length-1;index>=0;index--){const previous=levels[index];if(previous!==void 0&&previous<current){this.zoom=previous;return}}}isZoomInDisabled(){return!this.availableZoomLevels.some(level=>level>this.safeZoom)}isZoomOutDisabled(){return!this.availableZoomLevels.some(level=>level<this.safeZoom)}dispatchFrameEvent(type){const EventConstructor=this.ownerDocument.defaultView?.Event??Event;type==="load"?this.dispatchEvent(new EventConstructor("load",{bubbles:!1,composed:!1})):this.dispatchEvent(new EventConstructor("error",{bubbles:!1,composed:!1}))}onFrameEvent(type,source,generation,navigationSignature){source.stopPropagation(),!(!this.isConnected||!this.hasNavigation||generation!==this.navigationGeneration||navigationSignature!==this.navigationSignature()||source.currentTarget!==this.iframe)&&(type==="load"&&(this.bindFocusBoundaryDocument(),this.syncTheme()),this.dispatchFrameEvent(type))}syncTheme(){if(!this.withThemeSync||!this.isConnected)return;const target=this.contentDocument?.documentElement,source=this.ownerDocument.documentElement;if(!(!target||!source))try{const state=this.themeStateFor(target),nextClasses=new Set([...source.classList].filter(isLyraThemeClass));for(const className of this.syncedThemeClasses)nextClasses.has(className)||this.setSyncedThemeClass(state,className,!1);for(const className of nextClasses)this.setSyncedThemeClass(state,className,!0);this.syncedThemeClasses=nextClasses;for(const attribute of THEME_ATTRIBUTES){const value=source.getAttribute(attribute);this.setSyncedThemeAttribute(state,attribute,value)}const computed=this.ownerDocument.defaultView?.getComputedStyle(this);if(!computed)return;const nextProperties=new Set;for(let index=0;index<computed.length;index++){const property2=computed.item(index);property2.startsWith("--lr-theme-")&&(this.setSyncedThemeProperty(state,property2,computed.getPropertyValue(property2)),nextProperties.add(property2))}for(const property2 of this.syncedThemeProperties)nextProperties.has(property2)||this.setSyncedThemeProperty(state,property2,null);this.syncedThemeProperties=nextProperties,this.setSyncedThemeProperty(state,"color-scheme",computed.colorScheme)}catch{}}themeStateFor(target){if(this.themeSyncState?.target===target)return this.themeSyncState;this.resetThemeSyncState();const state={target,classes:new Map,attributes:new Map,properties:new Map};return this.themeSyncState=state,state}setSyncedThemeClass(state,className,present){let mutation=state.classes.get(className);mutation||(mutation={original:state.target.classList.contains(className),applied:state.target.classList.contains(className)},state.classes.set(className,mutation)),state.target.classList.toggle(className,present),mutation.applied=state.target.classList.contains(className)}setSyncedThemeAttribute(state,attribute,value){let mutation=state.attributes.get(attribute);if(!mutation){const original=state.target.getAttribute(attribute);mutation={original,applied:original},state.attributes.set(attribute,mutation)}value===null?state.target.removeAttribute(attribute):state.target.setAttribute(attribute,value),mutation.applied=state.target.getAttribute(attribute)}setSyncedThemeProperty(state,property2,value){let mutation=state.properties.get(property2);mutation||(mutation={original:state.target.style.getPropertyValue(property2),originalPriority:state.target.style.getPropertyPriority(property2),applied:state.target.style.getPropertyValue(property2),appliedPriority:state.target.style.getPropertyPriority(property2)},state.properties.set(property2,mutation)),value===null?state.target.style.removeProperty(property2):state.target.style.setProperty(property2,value),mutation.applied=state.target.style.getPropertyValue(property2),mutation.appliedPriority=state.target.style.getPropertyPriority(property2)}restoreTheme(){const state=this.themeSyncState;if(state)try{if(this.contentDocument?.documentElement!==state.target)return;for(const[className,mutation]of state.classes)state.target.classList.contains(className)===mutation.applied&&state.target.classList.toggle(className,mutation.original);for(const[attribute,mutation]of state.attributes)state.target.getAttribute(attribute)===mutation.applied&&(mutation.original===null?state.target.removeAttribute(attribute):state.target.setAttribute(attribute,mutation.original));for(const[property2,mutation]of state.properties)state.target.style.getPropertyValue(property2)!==mutation.applied||state.target.style.getPropertyPriority(property2)!==mutation.appliedPriority||(mutation.original?state.target.style.setProperty(property2,mutation.original,mutation.originalPriority):state.target.style.removeProperty(property2))}catch{}finally{this.resetThemeSyncState()}}resetThemeSyncState(){this.themeSyncState=void 0,this.syncedThemeClasses.clear(),this.syncedThemeProperties.clear()}renderControls(){return this.withoutControls?nothing:html`<div
|
|
2
2
|
part="controls"
|
|
3
3
|
role="toolbar"
|
|
4
4
|
aria-label=${this.localize("zoomControls")}
|
|
@@ -35,4 +35,4 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
35
35
|
@focusin=${this.onFrameFocus}
|
|
36
36
|
@focusout=${this.onFrameBlur}
|
|
37
37
|
@pointerdown=${this.scheduleFrameFocusReconciliation}
|
|
38
|
-
></iframe>`;return html`${keyed(generation,frame)}${this.renderControls()}`}}__decorate([property()],LyraZoomableFrame.prototype,"src",void 0),__decorate([property()],LyraZoomableFrame.prototype,"srcdoc",void 0),__decorate([property({type:Boolean})],LyraZoomableFrame.prototype,"allowfullscreen",void 0),__decorate([property()],LyraZoomableFrame.prototype,"loading",void 0),__decorate([property()],LyraZoomableFrame.prototype,"referrerpolicy",void 0),__decorate([property()],LyraZoomableFrame.prototype,"sandbox",void 0),__decorate([property({type:Number,reflect:!0})],LyraZoomableFrame.prototype,"zoom",void 0),__decorate([property({attribute:"zoom-levels"})],LyraZoomableFrame.prototype,"zoomLevels",void 0),__decorate([property({type:Boolean,attribute:"without-controls",reflect:!0})],LyraZoomableFrame.prototype,"withoutControls",void 0),__decorate([property({type:Boolean,attribute:"without-interaction",reflect:!0})],LyraZoomableFrame.prototype,"withoutInteraction",void 0),__decorate([property({type:Boolean,attribute:"with-theme-sync",reflect:!0})],LyraZoomableFrame.prototype,"withThemeSync",void 0),__decorate([property({attribute:"aria-label"})],LyraZoomableFrame.prototype,"accessibleLabel",void 0)
|
|
38
|
+
></iframe>`;return html`${keyed(generation,frame)}${this.renderControls()}`}}__decorate([property()],LyraZoomableFrame.prototype,"src",void 0),__decorate([property()],LyraZoomableFrame.prototype,"srcdoc",void 0),__decorate([property({type:Boolean})],LyraZoomableFrame.prototype,"allowfullscreen",void 0),__decorate([property()],LyraZoomableFrame.prototype,"loading",void 0),__decorate([property()],LyraZoomableFrame.prototype,"referrerpolicy",void 0),__decorate([property()],LyraZoomableFrame.prototype,"sandbox",void 0),__decorate([property({type:Number,reflect:!0})],LyraZoomableFrame.prototype,"zoom",void 0),__decorate([property({attribute:"zoom-levels"})],LyraZoomableFrame.prototype,"zoomLevels",void 0),__decorate([property({type:Boolean,attribute:"without-controls",reflect:!0})],LyraZoomableFrame.prototype,"withoutControls",void 0),__decorate([property({type:Boolean,attribute:"without-interaction",reflect:!0})],LyraZoomableFrame.prototype,"withoutInteraction",void 0),__decorate([property({type:Boolean,attribute:"with-theme-sync",reflect:!0})],LyraZoomableFrame.prototype,"withThemeSync",void 0),__decorate([property({attribute:"aria-label"})],LyraZoomableFrame.prototype,"accessibleLabel",void 0);export{LyraZoomableFrame};
|