@lostgradient/cinder 0.17.0 → 0.19.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/components.json +3 -2
  3. package/dist/cli/index.js +2 -2
  4. package/dist/cli/types.d.ts +1 -0
  5. package/dist/components/approval-card/index.js +105 -37
  6. package/dist/components/code-block/index.js +103 -36
  7. package/dist/components/combobox/combobox.schema.js +14 -1
  8. package/dist/components/combobox/combobox.svelte.d.ts +12 -12
  9. package/dist/components/combobox/combobox.types.d.ts +11 -5
  10. package/dist/components/combobox/index.js +94 -16
  11. package/dist/components/event-stream-viewer/index.js +3 -2
  12. package/dist/components/invocation-rule-builder/index.js +3602 -380
  13. package/dist/components/invocation-rule-builder/invocation-rule-builder.css +14 -0
  14. package/dist/components/json-editor/index.js +86 -18
  15. package/dist/components/json-editor/json-editor-enhancement.d.ts +7 -0
  16. package/dist/components/json-editor/json-editor-enhancement.js +201 -0
  17. package/dist/components/json-editor/json-editor.css +68 -0
  18. package/dist/components/json-editor/json-editor.schema.js +5 -1
  19. package/dist/components/json-editor/json-editor.types.d.ts +2 -0
  20. package/dist/components/run-step-timeline/index.js +3 -2
  21. package/dist/components/status-dot/index.js +3 -2
  22. package/dist/highlighters/shiki/default.d.ts +5 -0
  23. package/dist/highlighters/shiki/default.js +278 -0
  24. package/dist/highlighters/shiki/index.d.ts +9 -2
  25. package/dist/highlighters/shiki/index.js +72 -35
  26. package/dist/index.js +608 -356
  27. package/dist/server/components/approval-card/index.js +2 -2
  28. package/dist/server/components/combobox/index.js +5 -3
  29. package/dist/server/components/event-stream-viewer/index.js +2 -2
  30. package/dist/server/components/invocation-rule-builder/index.js +15 -2
  31. package/dist/server/components/json-editor/index.js +1 -1
  32. package/dist/server/components/json-editor/json-editor-enhancement.js +150 -0
  33. package/dist/server/components/run-step-timeline/index.js +2 -2
  34. package/dist/server/components/status-dot/index.js +2 -2
  35. package/dist/server/highlighters/shiki/default.js +39 -0
  36. package/dist/server/highlighters/shiki/index.js +7 -131
  37. package/dist/server/index.js +10 -9
  38. package/dist/server/{index.server-npxtkwjp.js → index.server-0gg1njz4.js} +3 -2
  39. package/dist/server/{index.server-j87v28yy.js → index.server-0hjcds3y.js} +35 -18
  40. package/dist/server/{index.server-9vqfmhez.js → index.server-20km2ga0.js} +1 -1
  41. package/dist/server/{index.server-qxneqxf8.js → index.server-62593nnh.js} +1 -1
  42. package/dist/server/{index.server-m8ya4p7w.js → index.server-8grn4zd3.js} +74 -14
  43. package/dist/server/index.server-c9gtmre4.js +178 -0
  44. package/dist/server/{index.server-tez36va4.js → index.server-kvn6cj65.js} +1 -1
  45. package/dist/server/{index.server-93vt8ktj.js → index.server-v73af5rk.js} +18 -2
  46. package/dist/server/{index.server-qke3ekjt.js → index.server-ww54rv4y.js} +1 -1
  47. package/dist/server/index.server-x4a15jpm.js +9 -0
  48. package/dist/utilities/json-highlight.d.ts +2 -0
  49. package/package.json +19 -1
  50. package/src/components/code-block/code-block-default-highlighter.ts +2 -2
  51. package/src/components/combobox/combobox.schema.json +13 -0
  52. package/src/components/combobox/combobox.schema.ts +13 -0
  53. package/src/components/combobox/combobox.svelte +100 -14
  54. package/src/components/combobox/combobox.types.ts +11 -5
  55. package/src/components/invocation-rule-builder/invocation-rule-builder.css +14 -0
  56. package/src/components/invocation-rule-builder/invocation-rule-builder.examples.json +1 -1
  57. package/src/components/invocation-rule-builder/invocation-rule-builder.svelte +30 -16
  58. package/src/components/json-editor/json-editor-enhancement.ts +48 -0
  59. package/src/components/json-editor/json-editor.css +68 -0
  60. package/src/components/json-editor/json-editor.examples.json +2 -2
  61. package/src/components/json-editor/json-editor.schema.json +4 -0
  62. package/src/components/json-editor/json-editor.schema.ts +5 -0
  63. package/src/components/json-editor/json-editor.svelte +80 -20
  64. package/src/components/json-editor/json-editor.types.ts +2 -0
  65. package/src/components/status-dot/status-dot.svelte +6 -1
  66. package/src/highlighters/shiki/default.ts +46 -0
  67. package/src/highlighters/shiki/index.ts +101 -32
  68. package/src/utilities/json-highlight.ts +5 -0
@@ -3,19 +3,55 @@ export {};
3
3
  </script>
4
4
 
5
5
  <script lang="ts">
6
+ import { tick } from 'svelte';
6
7
  import { composeDescribedBy } from '../../_internal/field-control.ts';
7
8
  import { classNames } from '../../utilities/class-names.ts';
8
- let { id, value, label, description, error, rows = 8, showValidFeedback = true, onValueChange, class: className, autofocus = false, 'aria-describedby': consumerDescribedBy, 'aria-invalid': consumerInvalid, ...rest } = $props();
9
+ let { id, value, label, description, error, rows = 8, showValidFeedback = true, highlight = false, onValueChange, class: className, autofocus = false, wrap, onscroll: consumerOnScroll, 'aria-describedby': consumerDescribedBy, 'aria-invalid': consumerInvalid, ...rest } = $props();
9
10
  let draftValue = $state(value);
10
11
  let previousValue = value;
11
12
  let textareaNode = $state();
12
13
  let resetSyncTimeout;
14
+ let highlightedHtml = $state(null);
15
+ let lintPosition = $state(null);
16
+ let highlightNode = $state();
13
17
  $effect(() => {
14
18
  if (value === previousValue)
15
19
  return;
16
20
  previousValue = value;
17
21
  draftValue = value;
18
22
  });
23
+ $effect(() => {
24
+ if (!highlight || externalError) {
25
+ highlightedHtml = null;
26
+ lintPosition = null;
27
+ return;
28
+ }
29
+ const pendingValue = draftValue;
30
+ let cancelled = false;
31
+ void import('@lostgradient/cinder/json-editor/enhancement')
32
+ .then(({ enhanceJson }) => {
33
+ if (cancelled)
34
+ return;
35
+ const result = enhanceJson(pendingValue, parseIsValid);
36
+ highlightedHtml = result.html;
37
+ lintPosition = result.lint?.position ?? null;
38
+ void tick().then(() => {
39
+ if (!cancelled && highlightNode && textareaNode) {
40
+ highlightNode.scrollTop = textareaNode.scrollTop;
41
+ highlightNode.scrollLeft = textareaNode.scrollLeft;
42
+ }
43
+ });
44
+ })
45
+ .catch(() => {
46
+ if (!cancelled) {
47
+ highlightedHtml = null;
48
+ lintPosition = null;
49
+ }
50
+ });
51
+ return () => {
52
+ cancelled = true;
53
+ };
54
+ });
19
55
  function syncDraftAfterFormReset() {
20
56
  if (resetSyncTimeout !== undefined)
21
57
  clearTimeout(resetSyncTimeout);
@@ -63,6 +99,7 @@ const feedbackText = $derived(externalError ??
63
99
  const feedbackId = $derived(feedbackText ? `${id}-feedback` : undefined);
64
100
  const describedBy = $derived(composeDescribedBy(descriptionId, feedbackId, consumerDescribedBy));
65
101
  const ariaInvalid = $derived(feedbackIsError ? 'true' : normalizedConsumerInvalid);
102
+ const hasHighlightOverlay = $derived(highlight && highlightedHtml !== null);
66
103
  </script>
67
104
 
68
105
  <div class={classNames('cinder-json-editor', className)}>
@@ -70,25 +107,48 @@ const ariaInvalid = $derived(feedbackIsError ? 'true' : normalizedConsumerInvali
70
107
  {#if description}
71
108
  <p id={descriptionId} class="cinder-json-editor__description">{description}</p>
72
109
  {/if}
73
- <textarea
74
- bind:this={textareaNode}
75
- {...rest}
76
- {id}
77
- {rows}
78
- {autofocus}
79
- value={draftValue}
80
- spellcheck="false"
81
- class="cinder-json-editor__textarea"
82
- aria-describedby={describedBy}
83
- aria-invalid={ariaInvalid}
84
- oninput={(event) => {
85
- draftValue = event.currentTarget.value;
86
- onValueChange?.(draftValue);
87
- }}
88
- {@attach (element) => {
89
- if (autofocus) element.focus();
90
- }}
91
- ></textarea>
110
+ <div
111
+ class={classNames(
112
+ 'cinder-json-editor__input',
113
+ hasHighlightOverlay && 'cinder-json-editor__input--highlighted',
114
+ wrap === 'off' && 'cinder-json-editor__input--nowrap',
115
+ )}
116
+ data-cinder-json-lint-position={lintPosition ?? undefined}
117
+ >
118
+ {#if hasHighlightOverlay}
119
+ <pre
120
+ bind:this={highlightNode}
121
+ class="cinder-json-editor__highlight"
122
+ aria-hidden="true">{@html highlightedHtml}</pre>
123
+ {/if}
124
+ <textarea
125
+ bind:this={textareaNode}
126
+ {...rest}
127
+ {id}
128
+ {rows}
129
+ {wrap}
130
+ {autofocus}
131
+ value={draftValue}
132
+ spellcheck="false"
133
+ class="cinder-json-editor__textarea"
134
+ aria-describedby={describedBy}
135
+ aria-invalid={ariaInvalid}
136
+ oninput={(event) => {
137
+ draftValue = event.currentTarget.value;
138
+ onValueChange?.(draftValue);
139
+ }}
140
+ onscroll={(event) => {
141
+ const textarea = event.currentTarget;
142
+ if (!highlightNode) return;
143
+ highlightNode.scrollTop = textarea.scrollTop;
144
+ highlightNode.scrollLeft = textarea.scrollLeft;
145
+ consumerOnScroll?.(event);
146
+ }}
147
+ {@attach (element) => {
148
+ if (autofocus) element.focus();
149
+ }}
150
+ ></textarea>
151
+ </div>
92
152
  {#if feedbackText}
93
153
  <p
94
154
  id={feedbackId}
@@ -22,6 +22,8 @@ export type JsonEditorProps = Omit<
22
22
  required?: boolean;
23
23
  /** Whether valid JSON should render an announced success message. Defaults to true. */
24
24
  showValidFeedback?: boolean;
25
+ /** Enables a lazy syntax-highlighted view with inline parse-error annotation. Defaults to false. */
26
+ highlight?: boolean;
25
27
  /** Called with the proposed JSON source whenever the user edits the textarea. */
26
28
  onValueChange?: (value: string) => void;
27
29
  /** Extra class names merged onto the field wrapper. */
@@ -31,6 +31,11 @@ const hasVisibleLabel = $derived(showLabel && normalizedLabel !== undefined);
31
31
  const resolvedAriaLabel = $derived(normalizedAriaLabel ?? normalizedLabel ?? resolvedStatus);
32
32
  const visibleLabelIsLiveDuplicate = $derived(resolvedLive && normalizedLabel !== undefined && resolvedAriaLabel !== normalizedLabel);
33
33
  const needsHiddenLiveLabel = $derived(resolvedLive && (!hasVisibleLabel || visibleLabelIsLiveDuplicate));
34
+ // A live region with its visible label suppressed still needs an author name
35
+ // so role-based queries and assistive technology can identify the status.
36
+ const liveAriaLabel = $derived(!hasVisibleLabel && (normalizedLabel !== undefined || normalizedAriaLabel !== undefined)
37
+ ? resolvedAriaLabel
38
+ : undefined);
34
39
  </script>
35
40
 
36
41
  <!--
@@ -52,7 +57,7 @@ const needsHiddenLiveLabel = $derived(resolvedLive && (!hasVisibleLabel || visib
52
57
  role={resolvedLive ? 'status' : 'img'}
53
58
  aria-live={resolvedLive ? 'polite' : undefined}
54
59
  aria-atomic={resolvedLive ? 'true' : undefined}
55
- aria-label={resolvedLive ? undefined : resolvedAriaLabel}
60
+ aria-label={resolvedLive ? liveAriaLabel : resolvedAriaLabel}
56
61
  >
57
62
  <span class="cinder-status-dot__indicator" aria-hidden="true"></span>
58
63
  {#if hasVisibleLabel}
@@ -0,0 +1,46 @@
1
+ import {
2
+ createRetryingLoaderCache,
3
+ shikiHighlighter as createShikiHighlighter,
4
+ createShikiModule,
5
+ type ShikiHighlighterOptions,
6
+ } from './index.ts';
7
+
8
+ export { createRetryingLoaderCache };
9
+ export type { ShikiHighlighterOptions };
10
+
11
+ type ShikiModule = Awaited<ReturnType<typeof createShikiModule>>;
12
+ let sharedDefaultModuleLoader: (() => Promise<ShikiModule>) | undefined;
13
+
14
+ function getDefaultModuleLoader(): () => Promise<ShikiModule> {
15
+ sharedDefaultModuleLoader ??= createRetryingLoaderCache(async () => {
16
+ const [{ bundledLanguages }, { bundledThemes }] = await Promise.all([
17
+ import('shiki/langs'),
18
+ import('shiki/themes'),
19
+ ]);
20
+ return createShikiModule(bundledLanguages, bundledThemes, false);
21
+ });
22
+ return sharedDefaultModuleLoader;
23
+ }
24
+
25
+ /** The bundled adapter with the complete Shiki language and theme registries. */
26
+ export function shikiHighlighter(
27
+ options: ShikiHighlighterOptions = {},
28
+ moduleLoader?: Parameters<typeof createShikiHighlighter>[1],
29
+ ): ReturnType<typeof createShikiHighlighter> {
30
+ const loadModule =
31
+ moduleLoader ??
32
+ (options.languageLoaders === undefined && options.themeLoaders === undefined
33
+ ? getDefaultModuleLoader()
34
+ : async () => {
35
+ const [{ bundledLanguages }, { bundledThemes }] = await Promise.all([
36
+ import('shiki/langs'),
37
+ import('shiki/themes'),
38
+ ]);
39
+ return createShikiModule(
40
+ options.languageLoaders ?? bundledLanguages,
41
+ options.themeLoaders ?? bundledThemes,
42
+ options.languageLoaders !== undefined,
43
+ );
44
+ });
45
+ return createShikiHighlighter(options, loadModule);
46
+ }
@@ -108,6 +108,10 @@ export type ShikiHighlighterOptions = {
108
108
  * first-render flash for those languages).
109
109
  */
110
110
  langs?: ReadonlyArray<string>;
111
+ /** Curated Shiki language loader map for the `/highlighters/shiki/curated` entrypoint. */
112
+ languageLoaders?: Readonly<Record<string, DynamicImportLanguageRegistration>>;
113
+ /** Curated Shiki theme loader map for the `/highlighters/shiki/curated` entrypoint. */
114
+ themeLoaders?: Readonly<Record<string, DynamicImportThemeRegistration>>;
111
115
  };
112
116
 
113
117
  const DEFAULT_THEME: { light: string; dark: string } = {
@@ -146,8 +150,8 @@ function plaintextBlock(code: string): string {
146
150
  * here are keyed by a `lang`/theme name string that is only known to be a
147
151
  * member of that union after a runtime `Object.hasOwn` check.
148
152
  */
149
- type BundledLanguages = Record<string, DynamicImportLanguageRegistration>;
150
- type BundledThemes = Record<string, DynamicImportThemeRegistration>;
153
+ type BundledLanguages = Readonly<Record<string, DynamicImportLanguageRegistration>>;
154
+ type BundledThemes = Readonly<Record<string, DynamicImportThemeRegistration>>;
151
155
 
152
156
  type ShikiModule = {
153
157
  highlighter: HighlighterCore;
@@ -162,6 +166,8 @@ type ShikiModule = {
162
166
  * their own `shiki/core` import.
163
167
  */
164
168
  guessEmbeddedLanguages: (code: string, lang: string) => string[];
169
+ /** Whether aliases should be discovered from curated grammar metadata. */
170
+ resolveLanguageAliases: boolean;
165
171
  };
166
172
 
167
173
  type ShikiModuleLoader = () => Promise<ShikiModule>;
@@ -206,11 +212,12 @@ async function loadGuessedEmbeddedLanguages(
206
212
  shiki: ShikiModule,
207
213
  code: string,
208
214
  lang: string,
215
+ resolvedLanguageAliases: Map<string, string | undefined>,
209
216
  ): Promise<void> {
210
217
  for (const guessed of shiki.guessEmbeddedLanguages(code, lang)) {
211
- if (!Object.hasOwn(shiki.bundledLanguages, guessed)) continue;
212
218
  try {
213
- await ensureLanguageLoaded(shiki, guessed);
219
+ const languageKey = await resolveLanguageKey(shiki, guessed, resolvedLanguageAliases);
220
+ if (languageKey !== undefined) await ensureLanguageLoaded(shiki, languageKey);
214
221
  } catch {
215
222
  // Best-effort — an embedded grammar that fails to load only costs
216
223
  // that nested region its highlighting, not the whole block.
@@ -218,6 +225,41 @@ async function loadGuessedEmbeddedLanguages(
218
225
  }
219
226
  }
220
227
 
228
+ async function resolveLanguageKey(
229
+ shiki: ShikiModule,
230
+ normalizedLang: string,
231
+ resolvedLanguageAliases: Map<string, string | undefined>,
232
+ ): Promise<string | undefined> {
233
+ let languageKey: string | undefined = Object.hasOwn(shiki.bundledLanguages, normalizedLang)
234
+ ? normalizedLang
235
+ : resolvedLanguageAliases.get(normalizedLang);
236
+ if (
237
+ languageKey === undefined &&
238
+ shiki.resolveLanguageAliases &&
239
+ !resolvedLanguageAliases.has(normalizedLang)
240
+ ) {
241
+ let loaderFailed = false;
242
+ for (const [candidate, loader] of Object.entries(shiki.bundledLanguages)) {
243
+ try {
244
+ const module = await loader();
245
+ const registrations = module.default;
246
+ if (registrations.some((registration) => registration.aliases?.includes(normalizedLang))) {
247
+ languageKey = candidate;
248
+ break;
249
+ }
250
+ } catch {
251
+ loaderFailed = true;
252
+ }
253
+ }
254
+ if (!loaderFailed || languageKey !== undefined) {
255
+ resolvedLanguageAliases.set(normalizedLang, languageKey);
256
+ }
257
+ }
258
+ return languageKey !== undefined && Object.hasOwn(shiki.bundledLanguages, languageKey)
259
+ ? languageKey
260
+ : undefined;
261
+ }
262
+
221
263
  /**
222
264
  * The `HighlighterCore` (and its Oniguruma/WASM engine) is expensive to
223
265
  * build and safe to share: language and theme registries only grow, so
@@ -229,27 +271,52 @@ async function loadGuessedEmbeddedLanguages(
229
271
  * entirely (see `shikiHighlighter`'s second parameter).
230
272
  */
231
273
  let sharedShikiModule: (() => Promise<ShikiModule>) | undefined;
274
+ const sharedCuratedModules = new WeakMap<object, WeakMap<object, () => Promise<ShikiModule>>>();
275
+ const EMPTY_LOADERS: Readonly<Record<string, never>> = {};
232
276
 
233
- function getSharedShikiModule(): Promise<ShikiModule> {
234
- sharedShikiModule ??= createRetryingLoaderCache(async (): Promise<ShikiModule> => {
235
- const [{ createOnigurumaEngine }, coreModule, langsModule, themesModule] = await Promise.all([
236
- import('@shikijs/engine-oniguruma'),
237
- import('shiki/core'),
238
- import('shiki/langs'),
239
- import('shiki/themes'),
240
- ]);
241
- const highlighter = await coreModule.createHighlighterCore({
242
- themes: [],
243
- langs: [],
244
- engine: createOnigurumaEngine(import('shiki/wasm')),
245
- });
246
- return {
247
- highlighter,
248
- bundledLanguages: langsModule.bundledLanguages,
249
- bundledThemes: themesModule.bundledThemes,
250
- guessEmbeddedLanguages: coreModule.guessEmbeddedLanguages,
251
- };
277
+ export async function createShikiModule(
278
+ languageLoaders?: Readonly<Record<string, DynamicImportLanguageRegistration>>,
279
+ themeLoaders?: Readonly<Record<string, DynamicImportThemeRegistration>>,
280
+ resolveLanguageAliases = true,
281
+ ): Promise<ShikiModule> {
282
+ const [{ createOnigurumaEngine }, coreModule] = await Promise.all([
283
+ import('@shikijs/engine-oniguruma'),
284
+ import('shiki/core'),
285
+ ]);
286
+ const highlighter = await coreModule.createHighlighterCore({
287
+ themes: [],
288
+ langs: [],
289
+ engine: createOnigurumaEngine(import('shiki/wasm')),
252
290
  });
291
+ return {
292
+ highlighter,
293
+ bundledLanguages: languageLoaders ?? {},
294
+ bundledThemes: themeLoaders ?? {},
295
+ guessEmbeddedLanguages: coreModule.guessEmbeddedLanguages,
296
+ resolveLanguageAliases,
297
+ };
298
+ }
299
+
300
+ function getSharedShikiModule(
301
+ languageLoaders?: Readonly<Record<string, DynamicImportLanguageRegistration>>,
302
+ themeLoaders?: Readonly<Record<string, DynamicImportThemeRegistration>>,
303
+ ): Promise<ShikiModule> {
304
+ if (languageLoaders !== undefined || themeLoaders !== undefined) {
305
+ const languageKey = languageLoaders ?? EMPTY_LOADERS;
306
+ const themeKey = themeLoaders ?? EMPTY_LOADERS;
307
+ let themes = sharedCuratedModules.get(languageKey);
308
+ if (themes === undefined) {
309
+ themes = new WeakMap();
310
+ sharedCuratedModules.set(languageKey, themes);
311
+ }
312
+ let loader = themes.get(themeKey);
313
+ if (loader === undefined) {
314
+ loader = createRetryingLoaderCache(() => createShikiModule(languageLoaders, themeLoaders));
315
+ themes.set(themeKey, loader);
316
+ }
317
+ return loader();
318
+ }
319
+ sharedShikiModule ??= createRetryingLoaderCache(() => createShikiModule());
253
320
  return sharedShikiModule();
254
321
  }
255
322
 
@@ -262,8 +329,9 @@ export function shikiHighlighter(
262
329
  options: ShikiHighlighterOptions = {},
263
330
  moduleLoader?: ShikiModuleLoader,
264
331
  ): Highlighter {
265
- const { theme = DEFAULT_THEME, langs } = options;
332
+ const { theme = DEFAULT_THEME, langs, languageLoaders, themeLoaders } = options;
266
333
  const warnedLanguages = new Set<string>();
334
+ const resolvedLanguageAliases = new Map<string, string | undefined>();
267
335
 
268
336
  // Resolve Shiki lazily on the first highlight call. The cache wrapper
269
337
  // de-duplicates concurrent loads and evicts rejected promises so a
@@ -272,7 +340,7 @@ export function shikiHighlighter(
272
340
  const loadShiki = createRetryingLoaderCache(
273
341
  moduleLoader ??
274
342
  (async (): Promise<ShikiModule> => {
275
- const shikiModule = await getSharedShikiModule();
343
+ const shikiModule = await getSharedShikiModule(languageLoaders, themeLoaders);
276
344
 
277
345
  // Optional preload — if the consumer named specific languages, load
278
346
  // the configured theme once and each named language, so Shiki
@@ -319,11 +387,12 @@ export function shikiHighlighter(
319
387
  return plaintextBlock(code);
320
388
  }
321
389
 
322
- // Shiki's `bundledLanguages` table already exposes both canonical names
323
- // and aliases as top-level keys (`typescript` AND `ts`, `javascript` AND
324
- // `js`, etc.), so a single hasOwn check accepts whatever Shiki accepts
325
- // natively without us inventing additional aliases.
326
- if (!Object.hasOwn(shiki.bundledLanguages, normalizedLang)) {
390
+ // The full Shiki registry exposes aliases as top-level keys, while a
391
+ // curated registry usually exposes only canonical ids. Resolve aliases
392
+ // from each grammar's own metadata so curated consumers retain the
393
+ // complete Shiki alias contract without maintaining a partial list here.
394
+ const languageKey = await resolveLanguageKey(shiki, normalizedLang, resolvedLanguageAliases);
395
+ if (languageKey === undefined || !Object.hasOwn(shiki.bundledLanguages, languageKey)) {
327
396
  if (!warnedLanguages.has(normalizedLang)) {
328
397
  warnedLanguages.add(normalizedLang);
329
398
  console.warn(
@@ -334,9 +403,9 @@ export function shikiHighlighter(
334
403
  }
335
404
 
336
405
  try {
337
- await ensureLanguageLoaded(shiki, normalizedLang);
406
+ await ensureLanguageLoaded(shiki, languageKey);
338
407
  await ensureThemesLoaded(shiki, theme);
339
- await loadGuessedEmbeddedLanguages(shiki, code, normalizedLang);
408
+ await loadGuessedEmbeddedLanguages(shiki, code, normalizedLang, resolvedLanguageAliases);
340
409
  const html = shiki.highlighter.codeToHtml(code, {
341
410
  lang: normalizedLang,
342
411
  ...buildThemeOption(theme),
@@ -179,3 +179,8 @@ export function highlightJson(value: string): string {
179
179
  }
180
180
  return tokenize(value);
181
181
  }
182
+
183
+ /** Highlight source that has already been validated by the caller. */
184
+ export function highlightJsonValidated(value: string): string {
185
+ return tokenize(value);
186
+ }