@aceshooting/lyra-ui 2.0.0 → 2.1.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/README.md +87 -14
- package/custom-elements.json +11555 -5539
- package/dist/components/app-rail/app-rail-item.d.ts +30 -0
- package/dist/components/app-rail/app-rail-item.js +68 -0
- package/dist/components/app-rail/app-rail-item.styles.d.ts +1 -0
- package/dist/components/app-rail/app-rail-item.styles.js +65 -0
- package/dist/components/app-rail/app-rail.d.ts +21 -24
- package/dist/components/app-rail/app-rail.js +68 -132
- package/dist/components/app-rail/app-rail.styles.js +5 -2
- package/dist/components/attachment-chip/attachment-chip.d.ts +38 -11
- package/dist/components/attachment-chip/attachment-chip.js +73 -29
- package/dist/components/attachment-trigger/attachment-trigger.d.ts +13 -0
- package/dist/components/attachment-trigger/attachment-trigger.js +13 -1
- package/dist/components/attachment-trigger/attachment-trigger.styles.js +28 -6
- package/dist/components/chart/bar-chart.js +2 -18
- package/dist/components/chart/box-plot.d.ts +25 -1
- package/dist/components/chart/box-plot.js +136 -6
- package/dist/components/chart/box-plot.styles.js +13 -0
- package/dist/components/chart/bubble-chart.js +2 -18
- package/dist/components/chart/chart.d.ts +54 -10
- package/dist/components/chart/chart.js +182 -39
- package/dist/components/chart/doughnut-chart.js +2 -18
- package/dist/components/chart/histogram-bin.d.ts +5 -2
- package/dist/components/chart/histogram-bin.js +12 -4
- package/dist/components/chart/histogram.js +8 -16
- package/dist/components/chart/line-chart.js +2 -18
- package/dist/components/chart/lite-chart.d.ts +80 -3
- package/dist/components/chart/lite-chart.js +250 -53
- package/dist/components/chart/pie-chart.js +2 -18
- package/dist/components/chart/polar-area-chart.js +2 -18
- package/dist/components/chart/radar-chart.js +2 -18
- package/dist/components/chart/scatter-chart.js +2 -18
- package/dist/components/chat-composer/chat-composer.d.ts +42 -1
- package/dist/components/chat-composer/chat-composer.js +84 -3
- package/dist/components/chat-composer/chat-composer.styles.js +11 -1
- package/dist/components/chat-message/chat-message.d.ts +32 -4
- package/dist/components/chat-message/chat-message.js +57 -17
- package/dist/components/checkbox/checkbox.d.ts +66 -8
- package/dist/components/checkbox/checkbox.js +173 -50
- package/dist/components/checkbox/checkbox.styles.js +9 -2
- package/dist/components/chip/chip-group.js +8 -2
- package/dist/components/chip/chip.js +9 -2
- package/dist/components/citation-badge/citation-badge.js +21 -3
- package/dist/components/code-block/code-block.d.ts +38 -0
- package/dist/components/code-block/code-block.js +72 -7
- package/dist/components/code-block/code-loader.d.ts +44 -1
- package/dist/components/code-block/code-loader.js +63 -0
- package/dist/components/combobox/combobox.d.ts +46 -5
- package/dist/components/combobox/combobox.js +175 -35
- package/dist/components/combobox/combobox.styles.js +3 -3
- package/dist/components/context-meter/context-meter.js +17 -8
- package/dist/components/context-meter/context-meter.styles.js +0 -6
- package/dist/components/conversation-item/conversation-item.d.ts +13 -16
- package/dist/components/conversation-item/conversation-item.js +29 -20
- package/dist/components/date-picker/calendar-core.d.ts +24 -0
- package/dist/components/date-picker/calendar-core.js +51 -4
- package/dist/components/date-picker/date-input.d.ts +77 -10
- package/dist/components/date-picker/date-input.js +278 -73
- package/dist/components/date-picker/date-picker.d.ts +28 -4
- package/dist/components/date-picker/date-picker.js +95 -37
- package/dist/components/dialog/confirm.js +3 -6
- package/dist/components/dialog/dialog.d.ts +75 -31
- package/dist/components/dialog/dialog.js +147 -131
- package/dist/components/dialog/dialog.styles.js +46 -2
- package/dist/components/dock-panel/dock-panel.d.ts +8 -0
- package/dist/components/dock-panel/dock-panel.js +15 -1
- package/dist/components/dock-panel/dock-panel.styles.js +15 -1
- package/dist/components/document-preview/document-preview.d.ts +15 -7
- package/dist/components/document-preview/document-preview.js +29 -13
- package/dist/components/empty/empty.d.ts +1 -2
- package/dist/components/empty/empty.js +18 -12
- package/dist/components/empty/empty.styles.js +0 -3
- package/dist/components/export-button/export-button.d.ts +12 -0
- package/dist/components/export-button/export-button.js +33 -5
- package/dist/components/export-button/export-button.styles.js +5 -1
- package/dist/components/file-input/accept.js +2 -0
- package/dist/components/file-input/file-input.d.ts +10 -1
- package/dist/components/file-input/file-input.js +36 -5
- package/dist/components/flag/flag.d.ts +1 -1
- package/dist/components/flag/flag.js +15 -1
- package/dist/components/flag/flag.styles.js +1 -1
- package/dist/components/flag/language-map.d.ts +4 -1
- package/dist/components/flag/language-map.js +6 -3
- package/dist/components/gauge/gauge.d.ts +10 -1
- package/dist/components/gauge/gauge.js +28 -9
- package/dist/components/generation-status/generation-status.d.ts +13 -5
- package/dist/components/generation-status/generation-status.js +59 -5
- package/dist/components/graph/graph.d.ts +37 -3
- package/dist/components/graph/graph.js +132 -20
- package/dist/components/heatmap/calendar-grid.d.ts +15 -6
- package/dist/components/heatmap/calendar-grid.js +17 -6
- package/dist/components/heatmap/heatmap-scale.d.ts +5 -1
- package/dist/components/heatmap/heatmap-scale.js +8 -2
- package/dist/components/heatmap/heatmap.d.ts +166 -25
- package/dist/components/heatmap/heatmap.js +372 -89
- package/dist/components/json-viewer/json-viewer.d.ts +22 -5
- package/dist/components/json-viewer/json-viewer.js +115 -37
- package/dist/components/json-viewer/json-viewer.styles.js +2 -1
- package/dist/components/kbd/kbd.js +24 -7
- package/dist/components/live-region/live-region.d.ts +10 -1
- package/dist/components/live-region/live-region.js +42 -6
- package/dist/components/map/map.d.ts +24 -1
- package/dist/components/map/map.js +89 -24
- package/dist/components/markdown/markdown-loader.d.ts +24 -0
- package/dist/components/markdown/markdown-loader.js +35 -1
- package/dist/components/markdown/markdown.d.ts +46 -8
- package/dist/components/markdown/markdown.js +136 -31
- package/dist/components/markdown/markdown.styles.js +7 -1
- package/dist/components/media-card/media-card.d.ts +25 -17
- package/dist/components/media-card/media-card.js +43 -65
- package/dist/components/mention-popover/mention-popover.d.ts +4 -1
- package/dist/components/mention-popover/mention-popover.js +23 -5
- package/dist/components/menu/menu-item.d.ts +32 -3
- package/dist/components/menu/menu-item.js +94 -7
- package/dist/components/menu/menu-item.styles.js +8 -0
- package/dist/components/menu/menu.d.ts +25 -1
- package/dist/components/menu/menu.js +99 -3
- package/dist/components/menu/menu.styles.js +3 -2
- package/dist/components/model-select/model-select.d.ts +48 -3
- package/dist/components/model-select/model-select.js +120 -22
- package/dist/components/model-select/model-select.styles.js +17 -3
- package/dist/components/model-settings-panel/model-settings-panel.d.ts +25 -1
- package/dist/components/model-settings-panel/model-settings-panel.js +65 -1
- package/dist/components/playback/playback.d.ts +6 -2
- package/dist/components/playback/playback.js +72 -29
- package/dist/components/playback/playback.styles.js +6 -1
- package/dist/components/responsive-panel/responsive-panel.d.ts +29 -16
- package/dist/components/responsive-panel/responsive-panel.js +130 -132
- package/dist/components/responsive-panel/responsive-panel.styles.js +1 -1
- package/dist/components/result-card/result-card.d.ts +8 -2
- package/dist/components/result-card/result-card.js +9 -3
- package/dist/components/result-card/result-card.styles.js +0 -1
- package/dist/components/select/select.d.ts +59 -20
- package/dist/components/select/select.js +125 -43
- package/dist/components/skeleton/skeleton.d.ts +3 -0
- package/dist/components/skeleton/skeleton.js +7 -1
- package/dist/components/skeleton/skeleton.styles.js +5 -4
- package/dist/components/slider/slider.d.ts +57 -5
- package/dist/components/slider/slider.js +195 -80
- package/dist/components/source-card/source-card.d.ts +17 -5
- package/dist/components/source-card/source-card.js +55 -8
- package/dist/components/source-card/source-card.styles.js +1 -1
- package/dist/components/source-list/source-list.js +9 -1
- package/dist/components/sparkline/sparkline.js +34 -10
- package/dist/components/split/split.d.ts +141 -14
- package/dist/components/split/split.js +357 -52
- package/dist/components/split/split.styles.js +18 -1
- package/dist/components/stat/stat.d.ts +10 -4
- package/dist/components/stat/stat.js +46 -11
- package/dist/components/stream-status/stream-status.d.ts +27 -11
- package/dist/components/stream-status/stream-status.js +95 -13
- package/dist/components/streaming-text/streaming-text.d.ts +9 -3
- package/dist/components/streaming-text/streaming-text.js +25 -10
- package/dist/components/streaming-text/streaming-text.styles.js +3 -2
- package/dist/components/switch/switch.d.ts +52 -7
- package/dist/components/switch/switch.js +111 -40
- package/dist/components/switch/switch.styles.js +1 -1
- package/dist/components/table/table.d.ts +18 -3
- package/dist/components/table/table.js +88 -20
- package/dist/components/tabs/tabs.d.ts +23 -0
- package/dist/components/tabs/tabs.js +76 -12
- package/dist/components/tabs/tabs.styles.js +11 -0
- package/dist/components/thinking-panel/thinking-panel.d.ts +3 -1
- package/dist/components/thinking-panel/thinking-panel.js +34 -9
- package/dist/components/thinking-panel/thinking-panel.styles.js +6 -0
- package/dist/components/time-range/time-range.d.ts +59 -2
- package/dist/components/time-range/time-range.js +163 -67
- package/dist/components/toast/toast-item.d.ts +12 -3
- package/dist/components/toast/toast-item.js +90 -53
- package/dist/components/toast/toast-item.styles.js +59 -28
- package/dist/components/toast/toast.js +17 -5
- package/dist/components/toast/toaster.js +10 -1
- package/dist/components/tool-approval-dialog/tool-approval-dialog.d.ts +11 -10
- package/dist/components/tool-approval-dialog/tool-approval-dialog.js +50 -124
- package/dist/components/tool-approval-dialog/tool-approval-dialog.styles.js +1 -1
- package/dist/components/tool-call-chip/tool-call-chip.d.ts +18 -2
- package/dist/components/tool-call-chip/tool-call-chip.js +86 -25
- package/dist/components/tool-param-form/tool-param-form.d.ts +89 -28
- package/dist/components/tool-param-form/tool-param-form.js +350 -106
- package/dist/components/tool-result-dialog/tool-result-dialog.d.ts +27 -7
- package/dist/components/tool-result-dialog/tool-result-dialog.js +80 -115
- package/dist/components/tool-result-dialog/tool-result-dialog.styles.js +1 -1
- package/dist/components/tool-result-view/registry.d.ts +0 -8
- package/dist/components/tool-result-view/registry.js +7 -2
- package/dist/components/tool-result-view/tool-result-view.d.ts +6 -3
- package/dist/components/tool-result-view/tool-result-view.js +18 -4
- package/dist/components/tool-select-dialog/tool-select-dialog.d.ts +11 -11
- package/dist/components/tool-select-dialog/tool-select-dialog.js +44 -133
- package/dist/components/tool-select-dialog/tool-select-dialog.styles.js +13 -4
- package/dist/components/tree/tree-node.d.ts +4 -1
- package/dist/components/tree/tree-node.js +4 -1
- package/dist/components/tree/tree.d.ts +17 -8
- package/dist/components/tree/tree.js +21 -20
- package/dist/components/typing-indicator/typing-indicator.d.ts +12 -2
- package/dist/components/typing-indicator/typing-indicator.js +16 -4
- package/dist/components/typing-indicator/typing-indicator.styles.js +2 -2
- package/dist/components/virtual-list/virtual-list.d.ts +56 -19
- package/dist/components/virtual-list/virtual-list.js +184 -38
- package/dist/components/virtual-list/virtual-list.styles.js +12 -0
- package/dist/components/widget/widget.d.ts +5 -4
- package/dist/components/widget/widget.js +54 -120
- package/dist/components/widget/widget.styles.js +8 -2
- package/dist/components/word-cloud/word-cloud-layout.d.ts +7 -0
- package/dist/components/word-cloud/word-cloud-layout.js +20 -6
- package/dist/components/word-cloud/word-cloud.d.ts +22 -2
- package/dist/components/word-cloud/word-cloud.js +45 -6
- package/dist/components/word-cloud/word-cloud.styles.js +13 -1
- package/dist/internal/anchored-validity.d.ts +1 -0
- package/dist/internal/anchored-validity.js +86 -0
- package/dist/internal/form-associated.d.ts +7 -0
- package/dist/internal/form-associated.js +43 -4
- package/dist/internal/numbers.d.ts +12 -0
- package/dist/internal/numbers.js +26 -0
- package/dist/internal/overlay-manager.d.ts +51 -0
- package/dist/internal/overlay-manager.js +523 -0
- package/dist/internal/positioner.js +27 -3
- package/dist/internal/safe-url.d.ts +12 -0
- package/dist/internal/safe-url.js +41 -0
- package/dist/internal/tokens.styles.js +17 -11
- package/dist/lyra.d.ts +5 -2
- package/dist/lyra.js +3 -1
- package/llms-full.txt +970 -426
- package/llms.txt +5 -4
- package/package.json +19 -2
|
@@ -11,7 +11,7 @@ import { LyraElement } from '../../internal/lyra-element.js';
|
|
|
11
11
|
import { defineElement } from '../../internal/prefix.js';
|
|
12
12
|
import { nextId } from '../../internal/a11y.js';
|
|
13
13
|
import { chevronIcon } from '../../internal/icons.js';
|
|
14
|
-
import { loadShikiHighlighter, loadShikiLanguage, SHIKI_THEMES } from './code-loader.js';
|
|
14
|
+
import { loadShikiHighlighter, loadShikiLanguage, loadShikiHighlighterCore, SHIKI_THEMES, } from './code-loader.js';
|
|
15
15
|
import { styles } from './code-block.styles.js';
|
|
16
16
|
import '../skeleton/skeleton.js';
|
|
17
17
|
/** How long the copy button's confirmation state lasts before reverting. */
|
|
@@ -58,11 +58,35 @@ const partTransformer = {
|
|
|
58
58
|
* is already a perfectly readable placeholder for it, so a second
|
|
59
59
|
* loading-chrome state would add complexity for little practical benefit.
|
|
60
60
|
*
|
|
61
|
+
* `languages` is an additive, opt-in escape hatch from that default path for
|
|
62
|
+
* a consumer whose language set is fixed and known ahead of time: a map of
|
|
63
|
+
* language id to an already-imported shiki grammar module (e.g. `import bash
|
|
64
|
+
* from 'shiki/langs/bash.mjs'`). When `language` matches a key in `languages`,
|
|
65
|
+
* this component seeds a fine-grained `createHighlighterCore()` highlighter
|
|
66
|
+
* with *only* the pre-supplied grammars (see `code-loader.ts`'s
|
|
67
|
+
* `loadShikiHighlighterCore()`) instead of waiting on `loadShikiHighlighter()`
|
|
68
|
+
* and its dynamic per-language `loadLanguage()` import. The payoff isn't
|
|
69
|
+
* runtime cost — the default dynamic-import path is already well-optimized
|
|
70
|
+
* for that — it's *build output*: shiki's main entry point bundles a dynamic
|
|
71
|
+
* `import()` per bundled language (~200 of them) because a bundler can't
|
|
72
|
+
* statically narrow which of those a `loadLanguage(lang: string)` call might
|
|
73
|
+
* request at runtime, so it conservatively emits a build-output chunk for
|
|
74
|
+
* every one of them. `shiki/core`'s fine-grained API has no such table — a
|
|
75
|
+
* bundler only ever sees the exact grammar modules `languages` itself
|
|
76
|
+
* `import`s, so a consumer who pins its full language set this way trades a
|
|
77
|
+
* hand-maintained list for a build output scoped to just those languages
|
|
78
|
+
* instead of shiki's entire bundled set. A language requested but absent
|
|
79
|
+
* from `languages` still falls back to the ordinary dynamic-import path
|
|
80
|
+
* unchanged, so this is a partial opt-in, not a replacement for it.
|
|
81
|
+
*
|
|
61
82
|
* @customElement lyra-code-block
|
|
62
83
|
* @event lyra-copy - The copy button was activated. `detail: { text }` is
|
|
63
84
|
* always the raw `code` value (never the highlighted HTML), and always
|
|
64
85
|
* fires regardless of whether the actual OS clipboard write succeeded —
|
|
65
86
|
* same convention as `<lyra-json-viewer>`'s own copy button.
|
|
87
|
+
* @event lyra-toggle - The collapse/expand header button was activated.
|
|
88
|
+
* `detail: { collapsed }` — same event name and shape convention as
|
|
89
|
+
* `<lyra-thinking-panel>`'s own `lyra-toggle`.
|
|
66
90
|
* @csspart base - The outer container.
|
|
67
91
|
* @csspart header - The row above the code (filename/language/copy/toggle),
|
|
68
92
|
* present whenever there's anything to put in it.
|
|
@@ -127,6 +151,7 @@ export class LyraCodeBlock extends LyraElement {
|
|
|
127
151
|
};
|
|
128
152
|
this.toggleCollapsed = () => {
|
|
129
153
|
this.collapsed = !this.collapsed;
|
|
154
|
+
this.emit('lyra-toggle', { collapsed: this.collapsed });
|
|
130
155
|
};
|
|
131
156
|
}
|
|
132
157
|
static { this.styles = [LyraElement.styles, styles]; }
|
|
@@ -142,27 +167,65 @@ export class LyraCodeBlock extends LyraElement {
|
|
|
142
167
|
super.disconnectedCallback();
|
|
143
168
|
clearTimeout(this.copyTimeoutId);
|
|
144
169
|
}
|
|
170
|
+
// The `languages` entry for the *current* `language`, if any -- shared by
|
|
171
|
+
// `willUpdate()`/`updated()`/`render()`/`syncHighlight()` so they all agree
|
|
172
|
+
// on whether this render is taking the fine-grained `languages` path or
|
|
173
|
+
// the default `loadShikiHighlighter()` one.
|
|
174
|
+
preSuppliedGrammar() {
|
|
175
|
+
return this.languages?.[this.language];
|
|
176
|
+
}
|
|
145
177
|
// Mutating `highlightedHtml` here (rather than in `updated()`) absorbs the
|
|
146
178
|
// synchronous case -- language already loaded, see `syncHighlight()` --
|
|
147
179
|
// into this same update cycle instead of scheduling a second one, Lit's
|
|
148
180
|
// documented pattern for deriving one reactive property from a change to
|
|
149
181
|
// others (same approach <lyra-markdown>'s `willUpdate` takes).
|
|
150
182
|
willUpdate(changed) {
|
|
151
|
-
if (
|
|
183
|
+
if (!(changed.has('code') || changed.has('language') || changed.has('languages')))
|
|
184
|
+
return;
|
|
185
|
+
// The default path still waits on `shikiReady` (the shared
|
|
186
|
+
// `loadShikiHighlighter()` singleton), same as always. A `language`
|
|
187
|
+
// covered by `languages` doesn't need that singleton at all, so it can
|
|
188
|
+
// sync as soon as the relevant property actually changes, instead of
|
|
189
|
+
// waiting on an unrelated (and, for a `languages`-only consumer,
|
|
190
|
+
// possibly never-needed) full-bundle load to finish first.
|
|
191
|
+
if (this.shikiReady || this.preSuppliedGrammar()) {
|
|
152
192
|
this.syncHighlight();
|
|
153
193
|
}
|
|
154
194
|
}
|
|
155
195
|
updated() {
|
|
156
|
-
const showingSkeleton = !this.shikiReady && !!this.language;
|
|
196
|
+
const showingSkeleton = !this.shikiReady && !!this.language && !this.preSuppliedGrammar();
|
|
157
197
|
if (showingSkeleton)
|
|
158
198
|
this.setAttribute('aria-busy', 'true');
|
|
159
199
|
else
|
|
160
200
|
this.removeAttribute('aria-busy');
|
|
161
201
|
}
|
|
162
202
|
syncHighlight() {
|
|
163
|
-
|
|
203
|
+
// Bumped unconditionally -- on *every* call, not just the async branch
|
|
204
|
+
// below -- so that a call landing on the synchronous already-loaded
|
|
205
|
+
// branch still invalidates any earlier in-flight load from a previous
|
|
206
|
+
// call. Without this, a load kicked off by an older call can resolve
|
|
207
|
+
// after a newer call has already rendered correct synchronous output,
|
|
208
|
+
// and overwrite it with stale tokenization.
|
|
209
|
+
const token = ++this.highlightToken;
|
|
164
210
|
const lang = this.language;
|
|
165
|
-
if (!
|
|
211
|
+
if (!lang) {
|
|
212
|
+
this.highlightedHtml = null;
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const languages = this.languages;
|
|
216
|
+
if (languages?.[lang]) {
|
|
217
|
+
// Fine-grained opt-in path -- entirely separate from `this.highlighter`
|
|
218
|
+
// below, see `loadShikiHighlighterCore()`'s doc comment for why.
|
|
219
|
+
this.highlightedHtml = null;
|
|
220
|
+
void loadShikiHighlighterCore(languages).then((hl) => {
|
|
221
|
+
if (token !== this.highlightToken)
|
|
222
|
+
return; // superseded by a newer code/language/languages change
|
|
223
|
+
this.highlightedHtml = hl ? this.tokenize(hl, lang) : null;
|
|
224
|
+
});
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const hl = this.highlighter;
|
|
228
|
+
if (!hl) {
|
|
166
229
|
this.highlightedHtml = null;
|
|
167
230
|
return;
|
|
168
231
|
}
|
|
@@ -174,7 +237,6 @@ export class LyraCodeBlock extends LyraElement {
|
|
|
174
237
|
// meantime rather than leaving a *previous* code/language value's stale
|
|
175
238
|
// highlighted markup on screen while this one loads.
|
|
176
239
|
this.highlightedHtml = null;
|
|
177
|
-
const token = ++this.highlightToken;
|
|
178
240
|
void loadShikiLanguage(hl, lang).then((ok) => {
|
|
179
241
|
if (token !== this.highlightToken)
|
|
180
242
|
return; // superseded by a newer code/language change
|
|
@@ -259,7 +321,7 @@ export class LyraCodeBlock extends LyraElement {
|
|
|
259
321
|
// small piece of a larger document.
|
|
260
322
|
render() {
|
|
261
323
|
const hasHeader = !!this.filename || !!this.language || this.copyable || this.collapsible;
|
|
262
|
-
const showSkeleton = !this.shikiReady && !!this.language;
|
|
324
|
+
const showSkeleton = !this.shikiReady && !!this.language && !this.preSuppliedGrammar();
|
|
263
325
|
const bodyHidden = this.collapsible && this.collapsed;
|
|
264
326
|
const bodyLabel = this.filename || (this.language ? `${this.language} code` : 'Code');
|
|
265
327
|
return html `
|
|
@@ -305,6 +367,9 @@ __decorate([
|
|
|
305
367
|
__decorate([
|
|
306
368
|
property({ attribute: 'max-height' })
|
|
307
369
|
], LyraCodeBlock.prototype, "maxHeight", void 0);
|
|
370
|
+
__decorate([
|
|
371
|
+
property({ attribute: false })
|
|
372
|
+
], LyraCodeBlock.prototype, "languages", void 0);
|
|
308
373
|
__decorate([
|
|
309
374
|
state()
|
|
310
375
|
], LyraCodeBlock.prototype, "highlightedHtml", void 0);
|
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import type { Highlighter, BundledTheme } from 'shiki';
|
|
1
|
+
import type { Highlighter, BundledTheme, HighlighterCore, LanguageInput } from 'shiki';
|
|
2
2
|
/** Re-exported under a component-scoped name so importers don't need their
|
|
3
3
|
* own `import type { Highlighter } from 'shiki'`. */
|
|
4
4
|
export type ShikiHighlighter = Highlighter;
|
|
5
|
+
/** Re-exported under a component-scoped name — see `loadShikiHighlighterCore()`
|
|
6
|
+
* below. Structurally similar to `ShikiHighlighter` (both are
|
|
7
|
+
* `HighlighterGeneric<...>` instances providing `codeToHtml()` etc.) but
|
|
8
|
+
* typed with no bundled-language/theme keys of its own (`never`, since
|
|
9
|
+
* `createHighlighterCore()` has no built-in bundle to know about), which is
|
|
10
|
+
* why it's a distinct exported type rather than reusing `ShikiHighlighter`. */
|
|
11
|
+
export type ShikiHighlighterCore = HighlighterCore;
|
|
12
|
+
/** Re-exported under a component-scoped name — the shape of one pre-imported
|
|
13
|
+
* shiki grammar module's default export (e.g. `import bash from
|
|
14
|
+
* 'shiki/langs/bash.mjs'`), and what `<lyra-code-block>`'s `languages`
|
|
15
|
+
* property maps language ids to. See `loadShikiHighlighterCore()` below. */
|
|
16
|
+
export type ShikiLanguageInput = LanguageInput;
|
|
5
17
|
/**
|
|
6
18
|
* The two bundled themes every highlighter instance is seeded with, so a
|
|
7
19
|
* single `codeToHtml()` call can emit a light *and* dark rendering at once
|
|
@@ -42,3 +54,34 @@ export declare function loadShikiHighlighter(): Promise<ShikiHighlighter | null>
|
|
|
42
54
|
* succeed on every future render.
|
|
43
55
|
*/
|
|
44
56
|
export declare function loadShikiLanguage(hl: ShikiHighlighter, lang: string): Promise<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Builds (and caches — see `highlighterCores` above) a fine-grained
|
|
59
|
+
* `HighlighterCore` seeded with `SHIKI_THEMES` and *only* the grammars in
|
|
60
|
+
* `languages`, via shiki's own "fine-grained bundle" recipe:
|
|
61
|
+
* `createHighlighterCore()` (`shiki/core`) plus an explicit oniguruma engine
|
|
62
|
+
* (`shiki/engine/oniguruma` + the `shiki/wasm` binary) instead of
|
|
63
|
+
* `loadShikiHighlighter()`'s `createHighlighter()` (plain `shiki`).
|
|
64
|
+
*
|
|
65
|
+
* The point isn't runtime cost — `loadShikiHighlighter()`'s per-language
|
|
66
|
+
* `loadLanguage()` dynamic import is already well-optimized for that (see its
|
|
67
|
+
* doc comment). It's *build output*: `shiki`'s main entry point (what
|
|
68
|
+
* `loadShikiHighlighter()` imports) bundles a lookup table of dynamic
|
|
69
|
+
* `import()` calls, one per shiki-supported language (~200 of them), because
|
|
70
|
+
* `loadLanguage(lang: string)` resolves that string against the table at
|
|
71
|
+
* runtime — a bundler can't statically narrow which of those ~200 entries a
|
|
72
|
+
* given app will ever actually request, so it conservatively emits a
|
|
73
|
+
* build-output chunk for every one of them. `shiki/core` has no such
|
|
74
|
+
* table — a bundler only ever sees the exact grammar modules a caller
|
|
75
|
+
* `import`s for `languages` itself, so a consumer with a known, fixed
|
|
76
|
+
* language set gets a build output scoped to just those languages instead of
|
|
77
|
+
* shiki's full bundled set.
|
|
78
|
+
*
|
|
79
|
+
* This is *only* ever consulted for languages present in `languages` — see
|
|
80
|
+
* `<lyra-code-block>`'s `syncHighlight()`. A language absent from it still
|
|
81
|
+
* falls back to the ordinary `loadShikiHighlighter()` + `loadShikiLanguage()`
|
|
82
|
+
* dynamic-import path entirely unchanged, so a caller can pin its own known
|
|
83
|
+
* set while still letting an unexpected language through. Resolves to `null`
|
|
84
|
+
* (with a one-time `console.warn`, same convention as `loadShikiHighlighter()`)
|
|
85
|
+
* if building the fine-grained highlighter fails for any reason.
|
|
86
|
+
*/
|
|
87
|
+
export declare function loadShikiHighlighterCore(languages: Record<string, ShikiLanguageInput>): Promise<ShikiHighlighterCore | null>;
|
|
@@ -77,3 +77,66 @@ export async function loadShikiLanguage(hl, lang) {
|
|
|
77
77
|
return false;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
/** One cached `ShikiHighlighterCore` promise per distinct `languages` object
|
|
81
|
+
* a caller has passed in — keyed by object identity (not content), so a
|
|
82
|
+
* consumer that keeps passing the *same* `languages` map reference (the
|
|
83
|
+
* normal case: a module-level constant, not a fresh object literal on every
|
|
84
|
+
* render) only ever builds one highlighter for it, same "the highlighter
|
|
85
|
+
* itself is the expensive part" rationale as `loadShikiHighlighter()`'s
|
|
86
|
+
* single cached instance above. A `WeakMap` lets an abandoned `languages`
|
|
87
|
+
* object (and its highlighter) be garbage-collected once nothing else
|
|
88
|
+
* references it. */
|
|
89
|
+
const highlighterCores = new WeakMap();
|
|
90
|
+
/**
|
|
91
|
+
* Builds (and caches — see `highlighterCores` above) a fine-grained
|
|
92
|
+
* `HighlighterCore` seeded with `SHIKI_THEMES` and *only* the grammars in
|
|
93
|
+
* `languages`, via shiki's own "fine-grained bundle" recipe:
|
|
94
|
+
* `createHighlighterCore()` (`shiki/core`) plus an explicit oniguruma engine
|
|
95
|
+
* (`shiki/engine/oniguruma` + the `shiki/wasm` binary) instead of
|
|
96
|
+
* `loadShikiHighlighter()`'s `createHighlighter()` (plain `shiki`).
|
|
97
|
+
*
|
|
98
|
+
* The point isn't runtime cost — `loadShikiHighlighter()`'s per-language
|
|
99
|
+
* `loadLanguage()` dynamic import is already well-optimized for that (see its
|
|
100
|
+
* doc comment). It's *build output*: `shiki`'s main entry point (what
|
|
101
|
+
* `loadShikiHighlighter()` imports) bundles a lookup table of dynamic
|
|
102
|
+
* `import()` calls, one per shiki-supported language (~200 of them), because
|
|
103
|
+
* `loadLanguage(lang: string)` resolves that string against the table at
|
|
104
|
+
* runtime — a bundler can't statically narrow which of those ~200 entries a
|
|
105
|
+
* given app will ever actually request, so it conservatively emits a
|
|
106
|
+
* build-output chunk for every one of them. `shiki/core` has no such
|
|
107
|
+
* table — a bundler only ever sees the exact grammar modules a caller
|
|
108
|
+
* `import`s for `languages` itself, so a consumer with a known, fixed
|
|
109
|
+
* language set gets a build output scoped to just those languages instead of
|
|
110
|
+
* shiki's full bundled set.
|
|
111
|
+
*
|
|
112
|
+
* This is *only* ever consulted for languages present in `languages` — see
|
|
113
|
+
* `<lyra-code-block>`'s `syncHighlight()`. A language absent from it still
|
|
114
|
+
* falls back to the ordinary `loadShikiHighlighter()` + `loadShikiLanguage()`
|
|
115
|
+
* dynamic-import path entirely unchanged, so a caller can pin its own known
|
|
116
|
+
* set while still letting an unexpected language through. Resolves to `null`
|
|
117
|
+
* (with a one-time `console.warn`, same convention as `loadShikiHighlighter()`)
|
|
118
|
+
* if building the fine-grained highlighter fails for any reason.
|
|
119
|
+
*/
|
|
120
|
+
export function loadShikiHighlighterCore(languages) {
|
|
121
|
+
let cached = highlighterCores.get(languages);
|
|
122
|
+
if (!cached) {
|
|
123
|
+
cached = Promise.all([
|
|
124
|
+
import('shiki/core'),
|
|
125
|
+
import('shiki/engine/oniguruma'),
|
|
126
|
+
import('shiki/themes/github-light.mjs'),
|
|
127
|
+
import('shiki/themes/github-dark.mjs'),
|
|
128
|
+
])
|
|
129
|
+
.then(([{ createHighlighterCore }, { createOnigurumaEngine }, light, dark]) => createHighlighterCore({
|
|
130
|
+
themes: [light.default, dark.default],
|
|
131
|
+
langs: Object.values(languages),
|
|
132
|
+
engine: createOnigurumaEngine(import('shiki/wasm')),
|
|
133
|
+
}))
|
|
134
|
+
.catch((err) => {
|
|
135
|
+
console.warn("<lyra-code-block>'s `languages` property failed to build a fine-grained shiki highlighter — " +
|
|
136
|
+
'falling back to plain unhighlighted text for the languages it covers:', err);
|
|
137
|
+
return null;
|
|
138
|
+
});
|
|
139
|
+
highlighterCores.set(languages, cached);
|
|
140
|
+
}
|
|
141
|
+
return cached;
|
|
142
|
+
}
|
|
@@ -24,8 +24,11 @@ export type ComboboxSource = (query: string) => Promise<ComboboxSourceRow[]>;
|
|
|
24
24
|
* @slot label - Custom label content.
|
|
25
25
|
* @slot hint - Custom hint content.
|
|
26
26
|
* @slot error - Custom error content.
|
|
27
|
-
* @event change - The selection changed.
|
|
28
|
-
*
|
|
27
|
+
* @event {Event} change - The selection changed through user interaction. A bubbling,
|
|
28
|
+
* composed, non-cancelable Event.
|
|
29
|
+
* @event {InputEvent | Event} input - The user typed in the filter or changed the selection. Text
|
|
30
|
+
* edits expose the original InputEvent; selection changes emit a bubbling,
|
|
31
|
+
* composed, non-cancelable Event.
|
|
29
32
|
* @event lyra-show - The listbox opened.
|
|
30
33
|
* @event lyra-hide - The listbox closed.
|
|
31
34
|
* @event lyra-clear - The value was cleared.
|
|
@@ -51,6 +54,21 @@ export declare class LyraCombobox extends LyraElement {
|
|
|
51
54
|
static formAssociated: boolean;
|
|
52
55
|
static styles: import("lit").CSSResultGroup[];
|
|
53
56
|
static properties: {
|
|
57
|
+
multiple: {
|
|
58
|
+
type: BooleanConstructor;
|
|
59
|
+
reflect: boolean;
|
|
60
|
+
noAccessor: boolean;
|
|
61
|
+
};
|
|
62
|
+
disabled: {
|
|
63
|
+
type: BooleanConstructor;
|
|
64
|
+
reflect: boolean;
|
|
65
|
+
noAccessor: boolean;
|
|
66
|
+
};
|
|
67
|
+
required: {
|
|
68
|
+
type: BooleanConstructor;
|
|
69
|
+
reflect: boolean;
|
|
70
|
+
noAccessor: boolean;
|
|
71
|
+
};
|
|
54
72
|
value: {
|
|
55
73
|
noAccessor: boolean;
|
|
56
74
|
};
|
|
@@ -59,10 +77,7 @@ export declare class LyraCombobox extends LyraElement {
|
|
|
59
77
|
noAccessor: boolean;
|
|
60
78
|
};
|
|
61
79
|
};
|
|
62
|
-
multiple: boolean;
|
|
63
80
|
placeholder: string;
|
|
64
|
-
disabled: boolean;
|
|
65
|
-
required: boolean;
|
|
66
81
|
label: string;
|
|
67
82
|
hint: string;
|
|
68
83
|
errorText: string;
|
|
@@ -70,6 +85,10 @@ export declare class LyraCombobox extends LyraElement {
|
|
|
70
85
|
withClear: boolean;
|
|
71
86
|
maxOptionsVisible: number;
|
|
72
87
|
emptyText: string;
|
|
88
|
+
/** Status copy shown in the listbox while a `source` fetch is in flight. */
|
|
89
|
+
loadingText: string;
|
|
90
|
+
/** Status copy shown when `maxRender` caps the row list; `{n}` is replaced with the hidden count. */
|
|
91
|
+
overflowText: string;
|
|
73
92
|
filter: OptionFilter | null;
|
|
74
93
|
source: ComboboxSource | null;
|
|
75
94
|
maxRender: number;
|
|
@@ -84,23 +103,40 @@ export declare class LyraCombobox extends LyraElement {
|
|
|
84
103
|
private asyncRows;
|
|
85
104
|
private sourceTimer?;
|
|
86
105
|
private sourceToken;
|
|
106
|
+
private _sourceWarmed;
|
|
87
107
|
private _selectedLabelCache;
|
|
88
108
|
private _rowsByValue;
|
|
89
109
|
private internals;
|
|
110
|
+
private validityController;
|
|
90
111
|
private _fieldsetDisabled;
|
|
91
112
|
private listId;
|
|
92
113
|
private inputId;
|
|
93
114
|
private cleanup?;
|
|
94
115
|
private _isFirstUpdate;
|
|
95
116
|
private _selected;
|
|
117
|
+
private _multiple;
|
|
118
|
+
private _disabled;
|
|
119
|
+
private _required;
|
|
96
120
|
private _defaultSelected;
|
|
97
121
|
private _defaultCaptured;
|
|
122
|
+
private _restoredStateActive;
|
|
98
123
|
private _name;
|
|
99
124
|
constructor();
|
|
125
|
+
get form(): HTMLFormElement | null;
|
|
126
|
+
get labels(): NodeList;
|
|
127
|
+
get validity(): ValidityState;
|
|
128
|
+
get validationMessage(): string;
|
|
129
|
+
get willValidate(): boolean;
|
|
100
130
|
connectedCallback(): void;
|
|
101
131
|
protected willUpdate(): void;
|
|
102
132
|
get name(): string;
|
|
103
133
|
set name(next: string);
|
|
134
|
+
get multiple(): boolean;
|
|
135
|
+
set multiple(next: boolean);
|
|
136
|
+
get disabled(): boolean;
|
|
137
|
+
set disabled(next: boolean);
|
|
138
|
+
get required(): boolean;
|
|
139
|
+
set required(next: boolean);
|
|
104
140
|
/** The selected value(s): a string in single mode, a string[] in `multiple` mode. */
|
|
105
141
|
get value(): string | string[];
|
|
106
142
|
set value(next: string | string[]);
|
|
@@ -111,6 +147,7 @@ export declare class LyraCombobox extends LyraElement {
|
|
|
111
147
|
* own `disabled` IDL property/attribute is never mutated by a fieldset. */
|
|
112
148
|
get effectiveDisabled(): boolean;
|
|
113
149
|
formResetCallback(): void;
|
|
150
|
+
formStateRestoreCallback(state: string | File | FormData | null, _mode?: 'restore' | 'autocomplete'): void;
|
|
114
151
|
/**
|
|
115
152
|
* Called by the browser when an ancestor `<fieldset disabled>` toggles.
|
|
116
153
|
* Tracked separately from the consumer's own `disabled` (see
|
|
@@ -135,6 +172,10 @@ export declare class LyraCombobox extends LyraElement {
|
|
|
135
172
|
private hide;
|
|
136
173
|
private onDocPointer;
|
|
137
174
|
protected updated(changed: PropertyValues): void;
|
|
175
|
+
/** Dispatches the platform-style value-event pair used by non-text user
|
|
176
|
+
* interactions. Text editing keeps and exposes the original InputEvent
|
|
177
|
+
* from the shadow input so its data/inputType metadata is not lost. */
|
|
178
|
+
private emitValueEvents;
|
|
138
179
|
private pickRow;
|
|
139
180
|
private removeValue;
|
|
140
181
|
private clear;
|