vue-syntax-highlighter 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
- var Ze = Object.defineProperty;
2
- var et = (e, t, n) => t in e ? Ze(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var M = (e, t, n) => et(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { shallowReactive as tt, getCurrentInstance as Be, shallowRef as F, computed as x, watch as k, defineComponent as Ce, inject as de, ref as we, watchEffect as nt, onMounted as Le, onBeforeUnmount as Ae, h as A, provide as it, toValue as R } from "vue";
5
- import { a as rt, n as Te, b as ot, f as at, r as st, c as De } from "./chunks/source-DxBCRqJY.js";
6
- import { T as lt } from "./chunks/types-DTo8JPWw.js";
7
- import { i as ct, d as ut } from "./chunks/define-theme-Bul1KkHG.js";
8
- import ge from "./themes/vsh-light.js";
9
- const ht = 100, gt = 8 * 1024 * 1024, He = /* @__PURE__ */ new WeakMap();
1
+ var et = Object.defineProperty;
2
+ var tt = (e, t, n) => t in e ? et(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var M = (e, t, n) => tt(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { shallowReactive as nt, getCurrentInstance as Be, shallowRef as F, computed as x, watch as k, defineComponent as Ce, inject as fe, ref as xe, watchEffect as it, onMounted as Le, onBeforeUnmount as Ae, h as A, provide as rt, toValue as R } from "vue";
5
+ import { a as ot, b as ge, n as De, d as at, f as st, r as lt, c as Ve } from "./chunks/source-BSZ04z5-.js";
6
+ import { T as ct } from "./chunks/types-DTo8JPWw.js";
7
+ import { i as ut, d as ht } from "./chunks/define-theme-Bul1KkHG.js";
8
+ import de from "./themes/vsh-light.js";
9
+ const gt = 100, dt = 8 * 1024 * 1024, He = /* @__PURE__ */ new WeakMap();
10
10
  let Ne = 1;
11
- function dt(e) {
11
+ function ft(e) {
12
12
  const t = He.get(e);
13
13
  if (t !== void 0) return t;
14
14
  const n = Ne;
@@ -23,7 +23,7 @@ function D(e, t = /* @__PURE__ */ new WeakSet()) {
23
23
  if (n === "number") return Number.isFinite(e) ? String(e) : `#number:${String(e)}`;
24
24
  if (n === "bigint") return `#bigint:${String(e)}`;
25
25
  if (n === "symbol") return `#symbol:${String(e.description ?? "")}`;
26
- if (n === "function") return `#function:${dt(e)}`;
26
+ if (n === "function") return `#function:${ft(e)}`;
27
27
  const i = e;
28
28
  if (t.has(i)) return "#circular";
29
29
  t.add(i);
@@ -42,7 +42,7 @@ function D(e, t = /* @__PURE__ */ new WeakSet()) {
42
42
  t.delete(i);
43
43
  }
44
44
  }
45
- function ft(e) {
45
+ function mt(e) {
46
46
  const t = e.options ?? {};
47
47
  return `v1:${D([
48
48
  e.engineId,
@@ -51,7 +51,7 @@ function ft(e) {
51
51
  t
52
52
  ])}`;
53
53
  }
54
- class mt {
54
+ class vt {
55
55
  constructor(t = {}) {
56
56
  M(this, "entries", /* @__PURE__ */ new Map());
57
57
  M(this, "inflight", /* @__PURE__ */ new Map());
@@ -59,7 +59,7 @@ class mt {
59
59
  M(this, "maxChars");
60
60
  M(this, "chars", 0);
61
61
  M(this, "epoch", 0);
62
- this.capacity = Oe(t.capacity, ht), this.maxChars = Oe(t.maxChars, gt);
62
+ this.capacity = Oe(t.capacity, gt), this.maxChars = Oe(t.maxChars, dt);
63
63
  }
64
64
  get size() {
65
65
  return this.entries.size;
@@ -76,7 +76,7 @@ class mt {
76
76
  return this.entries.delete(t), this.entries.set(t, n), n.result;
77
77
  }
78
78
  set(t, n) {
79
- const i = rt(n);
79
+ const i = ot(n);
80
80
  if (this.capacity === 0 || this.maxChars === 0 || i > this.maxChars) {
81
81
  this.delete(t);
82
82
  return;
@@ -97,7 +97,7 @@ class mt {
97
97
  const s = this.inflight.get(t);
98
98
  if (s) return s;
99
99
  const o = n();
100
- if (vt(o)) {
100
+ if (yt(o)) {
101
101
  const r = this.epoch, l = o.then(
102
102
  (d) => (r === this.epoch && (this.inflight.delete(t), this.set(t, d)), d),
103
103
  (d) => {
@@ -119,47 +119,47 @@ class mt {
119
119
  function Oe(e, t) {
120
120
  return e === void 0 || !Number.isFinite(e) ? t : Math.max(0, Math.floor(e));
121
121
  }
122
- function vt(e) {
122
+ function yt(e) {
123
123
  return typeof e == "object" && e !== null && typeof e.then == "function";
124
124
  }
125
- const yt = "[vue-syntax-highlighter]", pt = /* @__PURE__ */ new Set();
126
- function bt(e) {
125
+ const pt = "[vue-syntax-highlighter]", bt = /* @__PURE__ */ new Set();
126
+ function St(e) {
127
127
  return /* @__PURE__ */ new Set();
128
128
  }
129
- function St() {
129
+ function wt() {
130
130
  const e = globalThis.__VSH_DEV_OVERRIDE__;
131
131
  return typeof e == "boolean" ? e : !1;
132
132
  }
133
- function w(e, t, n = pt) {
134
- St() && (n.has(e) || (n.add(e), console.warn(`${yt} ${t}`)));
133
+ function w(e, t, n = bt) {
134
+ wt() && (n.has(e) || (n.add(e), console.warn(`${pt} ${t}`)));
135
135
  }
136
- const Ve = ["shiki", "highlightjs", "lowlight", "prism"], wt = {
136
+ const qe = ["shiki", "highlightjs", "lowlight", "prism"], xt = {
137
137
  shiki: "shiki",
138
138
  highlightjs: "lowlight highlight.js",
139
139
  lowlight: "lowlight highlight.js",
140
140
  prism: "refractor"
141
141
  };
142
- function xt(e) {
143
- return Ve.includes(e);
142
+ function zt(e) {
143
+ return qe.includes(e);
144
144
  }
145
- function qe(e, t) {
146
- const n = wt[e] ?? e, i = t instanceof Error ? ` ${t.message}` : "";
145
+ function We(e, t) {
146
+ const n = xt[e] ?? e, i = t instanceof Error ? ` ${t.message}` : "";
147
147
  return new Error(
148
148
  `[vue-syntax-highlighter] The "${e}" engine is unavailable. Install it with \`npm install ${n}\` and import its adapter before use.${i}`
149
149
  );
150
150
  }
151
- function We(e) {
151
+ function Ge(e) {
152
152
  if (!e || typeof e != "object") return !1;
153
153
  const t = e;
154
154
  return typeof t.id == "string" && t.id.length > 0 && typeof t.highlight == "function";
155
155
  }
156
- function xe(e, t = "engine") {
157
- if (!We(e))
156
+ function ze(e, t = "engine") {
157
+ if (!Ge(e))
158
158
  throw new TypeError(
159
159
  `[vue-syntax-highlighter] Invalid ${t}: expected an object with a non-empty "id" and a "highlight" function.`
160
160
  );
161
161
  }
162
- async function zt(e) {
162
+ async function $t(e) {
163
163
  try {
164
164
  switch (e) {
165
165
  case "shiki":
@@ -172,10 +172,10 @@ async function zt(e) {
172
172
  return await (await import("./engines/prism.js")).createPrismEngine();
173
173
  }
174
174
  } catch (t) {
175
- throw qe(e, t);
175
+ throw We(e, t);
176
176
  }
177
177
  }
178
- class $t {
178
+ class Et {
179
179
  constructor(t = {}, n) {
180
180
  M(this, "registry");
181
181
  M(this, "warningSet");
@@ -189,17 +189,17 @@ class $t {
189
189
  throw new Error("[vue-syntax-highlighter] This engine scope has been disposed.");
190
190
  const n = t ?? "shiki";
191
191
  if (typeof n != "string")
192
- return xe(n), n;
192
+ return ze(n), n;
193
193
  const i = this.instances.get(n);
194
194
  if (i) return i;
195
195
  const s = this.loads.get(n);
196
196
  if (s) return s;
197
197
  const o = this.registry[n];
198
198
  if (o && typeof o != "function")
199
- return xe(o, `engine "${n}"`), this.instances.set(n, o), o;
200
- if (!o && !xt(n))
199
+ return ze(o, `engine "${n}"`), this.instances.set(n, o), o;
200
+ if (!o && !zt(n))
201
201
  throw new Error(
202
- `[vue-syntax-highlighter] Unknown engine "${n}". Use one of ${Ve.join(", ")} or register a custom engine in the plugin/provider "engines" option.`
202
+ `[vue-syntax-highlighter] Unknown engine "${n}". Use one of ${qe.join(", ")} or register a custom engine in the plugin/provider "engines" option.`
203
203
  );
204
204
  const r = this.load(n, o);
205
205
  return this.loads.set(n, r), r;
@@ -225,8 +225,8 @@ class $t {
225
225
  }
226
226
  async load(t, n) {
227
227
  try {
228
- const i = n ? await n() : await zt(t);
229
- if (xe(i, `engine "${t}"`), this.disposed)
228
+ const i = n ? await n() : await $t(t);
229
+ if (ze(i, `engine "${t}"`), this.disposed)
230
230
  throw i.dispose?.(), new Error("[vue-syntax-highlighter] This engine scope has been disposed.");
231
231
  return this.instances.set(t, i), i;
232
232
  } catch (i) {
@@ -235,30 +235,30 @@ class $t {
235
235
  const s = i instanceof Error ? i.message : String(i);
236
236
  throw new Error(`[vue-syntax-highlighter] Custom engine "${t}" failed to load: ${s}`);
237
237
  }
238
- throw qe(t, i);
238
+ throw We(t, i);
239
239
  } finally {
240
240
  this.loads.delete(t);
241
241
  }
242
242
  }
243
243
  }
244
- function ze(e, t, n) {
244
+ function $e(e, t, n) {
245
245
  if (e.cacheKey)
246
246
  try {
247
247
  const i = e.cacheKey(t, n);
248
248
  if (typeof i == "string" && i.length > 0) return i;
249
249
  } catch {
250
250
  }
251
- return ft({
251
+ return mt({
252
252
  engineId: e.id,
253
253
  language: t.language,
254
254
  code: t.code,
255
255
  options: n
256
256
  });
257
257
  }
258
- const Pe = ge, Kt = ge.name, Me = Object.freeze({
259
- [ge.name]: ge
258
+ const Pe = de, Xt = de.name, Me = Object.freeze({
259
+ [de.name]: de
260
260
  });
261
- function $e(e, t = {}, n = "theme") {
261
+ function Ee(e, t = {}, n = "theme") {
262
262
  if (typeof e == "string") {
263
263
  const i = t[e] ?? Me[e];
264
264
  if (!i) {
@@ -269,15 +269,15 @@ function $e(e, t = {}, n = "theme") {
269
269
  }
270
270
  return i;
271
271
  }
272
- return ct(e) ? e : ut(e);
272
+ return ut(e) ? e : ht(e);
273
273
  }
274
274
  function je(e = {}) {
275
275
  const t = e.registry ?? {};
276
276
  let n, i;
277
277
  if (e.themes)
278
- n = $e(e.themes.light, t, "light theme"), i = $e(e.themes.dark, t, "dark theme");
278
+ n = Ee(e.themes.light, t, "light theme"), i = Ee(e.themes.dark, t, "dark theme");
279
279
  else if (e.theme !== void 0) {
280
- const r = $e(e.theme, t);
280
+ const r = Ee(e.theme, t);
281
281
  n = r, i = r;
282
282
  } else e.fallback ? (n = e.fallback.light, i = e.fallback.dark) : (n = Pe, i = Pe);
283
283
  const s = e.colorScheme ?? e.fallback?.mode ?? (e.themes ? "auto" : "light"), o = n.name === i.name ? n.name : `${n.name}/${i.name}`;
@@ -295,19 +295,19 @@ function Re(e, t) {
295
295
  [`--vsh-${t}-selection`]: e.colors.selection
296
296
  };
297
297
  e.colors.fontFamily && (n[`--vsh-${t}-font-family`] = e.colors.fontFamily);
298
- for (const i of lt) {
298
+ for (const i of ct) {
299
299
  const s = e.tokens[i];
300
300
  n[`--vsh-${t}-token-${i}-color`] = s?.color ?? e.colors.foreground, s?.fontStyle && (n[`--vsh-${t}-token-${i}-font-style`] = s.fontStyle), s?.fontWeight && (n[`--vsh-${t}-token-${i}-font-weight`] = s.fontWeight), s?.textDecoration && (n[`--vsh-${t}-token-${i}-text-decoration`] = s.textDecoration);
301
301
  }
302
302
  return n;
303
303
  }
304
- function Et(e) {
304
+ function Tt(e) {
305
305
  return {
306
306
  ...Re(e.light, "light"),
307
307
  ...Re(e.dark, "dark")
308
308
  };
309
309
  }
310
- function Tt(e) {
310
+ function Mt(e) {
311
311
  return {
312
312
  "data-vsh-scheme": e.mode,
313
313
  "data-vsh-theme": e.scopeName,
@@ -315,27 +315,27 @@ function Tt(e) {
315
315
  "data-vsh-theme-dark": e.dark.name
316
316
  };
317
317
  }
318
- let Mt = 1;
318
+ let kt = 1;
319
319
  const V = /* @__PURE__ */ Symbol(
320
320
  "vue-syntax-highlighter-context"
321
321
  );
322
- function kt(e, t) {
322
+ function Ct(e, t) {
323
323
  return { ...e ?? {}, ...t ?? {} };
324
324
  }
325
- function Ct(e) {
325
+ function Lt(e) {
326
326
  if (e) {
327
327
  if (typeof e != "object" || Array.isArray(e))
328
328
  throw new TypeError('[vue-syntax-highlighter] "engines" must be an object of engine loaders.');
329
329
  for (const [t, n] of Object.entries(e))
330
- if (typeof n != "function" && !We(n))
330
+ if (typeof n != "function" && !Ge(n))
331
331
  throw new TypeError(
332
332
  `[vue-syntax-highlighter] Invalid engine registration "${t}". Expected an engine object or a loader function.`
333
333
  );
334
334
  }
335
335
  }
336
336
  function J(e = {}, t, n = !1) {
337
- Ct(e.engines);
338
- const i = t?.warningSet ?? bt();
337
+ Lt(e.engines);
338
+ const i = t?.warningSet ?? St();
339
339
  let s = e.colorScheme;
340
340
  s !== void 0 && !["auto", "light", "dark"].includes(s) && (w(
341
341
  "context-color-scheme",
@@ -343,24 +343,24 @@ function J(e = {}, t, n = !1) {
343
343
  i
344
344
  ), s = void 0);
345
345
  let o, r = !1;
346
- e.cache ? o = e.cache : t && e.cacheCapacity === void 0 && e.cacheMaxChars === void 0 ? o = t.cache : (o = new mt({
346
+ e.cache ? o = e.cache : t && e.cacheCapacity === void 0 && e.cacheMaxChars === void 0 ? o = t.cache : (o = new vt({
347
347
  capacity: e.cacheCapacity,
348
348
  maxChars: e.cacheMaxChars
349
349
  }), r = !0);
350
- const l = kt(t?.engines, e.engines), d = {
350
+ const l = Ct(t?.engines, e.engines), d = {
351
351
  ...Me,
352
352
  ...t?.themeRegistry ?? {},
353
353
  ...e.themeRegistry ?? {}
354
354
  }, $ = new AbortController();
355
- return tt({
356
- id: Mt++,
355
+ return nt({
356
+ id: kt++,
357
357
  parent: t,
358
358
  engines: l,
359
359
  themeRegistry: d,
360
360
  languages: [.../* @__PURE__ */ new Set([...t?.languages ?? [], ...e.languages ?? []])],
361
361
  cache: o,
362
362
  cacheOwned: r,
363
- engineManager: new $t(l, i),
363
+ engineManager: new Et(l, i),
364
364
  abortController: $,
365
365
  abortSignal: $.signal,
366
366
  warningSet: i,
@@ -376,14 +376,14 @@ function J(e = {}, t, n = !1) {
376
376
  ...e.virtualizeAfter !== void 0 ? { virtualizeAfter: e.virtualizeAfter } : {}
377
377
  });
378
378
  }
379
- let Ee;
380
- function Lt() {
381
- return Ee ?? (Ee = J({}, void 0, !1)), Ee;
379
+ let Te;
380
+ function At() {
381
+ return Te ?? (Te = J({}, void 0, !1)), Te;
382
382
  }
383
383
  const _e = /* @__PURE__ */ new WeakMap();
384
- function fe() {
384
+ function me() {
385
385
  const e = Be()?.appContext;
386
- if (!e) return Lt();
386
+ if (!e) return At();
387
387
  let t = _e.get(e);
388
388
  return t || (t = J({}, void 0, !1), _e.set(e, t)), t;
389
389
  }
@@ -393,7 +393,7 @@ const oe = Object.freeze({
393
393
  virtualized: !1,
394
394
  virtualizeAfter: 2e3
395
395
  });
396
- function At(e) {
396
+ function Ht(e) {
397
397
  let t, n, i, s, o = e;
398
398
  for (; o; )
399
399
  t === void 0 && o.defer !== void 0 && (t = o.defer), n === void 0 && o.rootMargin !== void 0 && (n = o.rootMargin), i === void 0 && o.virtualized !== void 0 && (i = o.virtualized), s === void 0 && o.virtualizeAfter !== void 0 && (s = o.virtualizeAfter), o = o.parent;
@@ -415,7 +415,7 @@ function ue(e, t) {
415
415
  }
416
416
  return { choice: "shiki", manager: e.engineManager };
417
417
  }
418
- function Ht(e, t) {
418
+ function Nt(e, t) {
419
419
  const n = t.theme === void 0 && t.themes === void 0;
420
420
  let i = t.theme, s = t.themes, o = t.colorScheme;
421
421
  if (n) {
@@ -470,20 +470,20 @@ async function ke(e) {
470
470
  function he(e) {
471
471
  e.disposed || (e.disposed = !0, e.abortController.abort(), e.engineManager.dispose(), e.cacheOwned && e.cache.clear());
472
472
  }
473
- function Ge(e) {
473
+ function Ke(e) {
474
474
  const t = F(void 0), n = F(void 0), i = F(void 0), s = F(!0);
475
475
  let o = 0, r = !1, l = !1, d, $ = !1;
476
476
  const { context: v } = e;
477
477
  function q() {
478
478
  const c = e.getInput();
479
- return { ...c, code: Te(c.code) };
479
+ return { ...c, code: De(c.code) };
480
480
  }
481
481
  function y(c, h) {
482
482
  return t.value = c, n.value = c.lines, i.value = void 0, s.value = !1, d = h, e.onResult?.(c), c;
483
483
  }
484
484
  function O(c, h) {
485
485
  if (r || h !== o) return;
486
- const g = Nt(c);
486
+ const g = Ot(c);
487
487
  i.value = g, s.value = !1, w(
488
488
  `highlight:${g.name}:${g.message}`,
489
489
  g.message,
@@ -491,9 +491,9 @@ function Ge(e) {
491
491
  ), e.onError?.(g);
492
492
  }
493
493
  function H(c, h) {
494
- ot(c);
495
- const g = at(c);
496
- if (st(g) !== h)
494
+ at(c);
495
+ const g = st(c);
496
+ if (lt(g) !== h)
497
497
  throw new TypeError(
498
498
  "[vue-syntax-highlighter] Highlight engine returned tokens that do not reproduce the source text."
499
499
  );
@@ -501,7 +501,7 @@ function Ge(e) {
501
501
  }
502
502
  async function Q(c, h, g, z) {
503
503
  if (r || g !== o) return;
504
- const m = ze(
504
+ const m = $e(
505
505
  c,
506
506
  { code: h.code, language: h.language },
507
507
  h.engineOptions
@@ -549,7 +549,7 @@ function Ge(e) {
549
549
  code: c.code,
550
550
  language: c.language,
551
551
  signal: v.abortSignal
552
- }, p = ze(g, m, c.engineOptions);
552
+ }, p = $e(g, m, c.engineOptions);
553
553
  if (p === d && t.value) return !0;
554
554
  try {
555
555
  const b = v.cache.request(p, () => {
@@ -590,7 +590,7 @@ function Ge(e) {
590
590
  async function te(c) {
591
591
  if (r)
592
592
  throw new Error("[vue-syntax-highlighter] This highlighter scope has been disposed.");
593
- const h = q(), g = Te(c.code), z = c.language ?? h.language, m = ue(v, h.engine), p = await m.manager.resolve(m.choice), b = ze(
593
+ const h = q(), g = ge(c.code), z = c.language ?? h.language, m = ue(v, h.engine), p = await m.manager.resolve(m.choice), b = $e(
594
594
  p,
595
595
  { code: g, language: z },
596
596
  h.engineOptions
@@ -603,7 +603,7 @@ function Ge(e) {
603
603
  return B(T) ? T.then((ne) => H(ne, g)) : H(T, g);
604
604
  });
605
605
  }
606
- function ve() {
606
+ function ye() {
607
607
  if ($ || r || !l) return;
608
608
  $ = !0, (typeof queueMicrotask == "function" ? queueMicrotask : (h) => {
609
609
  Promise.resolve().then(h);
@@ -611,7 +611,7 @@ function Ge(e) {
611
611
  $ = !1, !r && l && P(!1);
612
612
  });
613
613
  }
614
- function ye() {
614
+ function pe() {
615
615
  r = !0, $ = !1, o += 1, s.value = !1;
616
616
  }
617
617
  return {
@@ -624,20 +624,20 @@ function Ge(e) {
624
624
  start: ee,
625
625
  refresh: W,
626
626
  highlight: te,
627
- schedule: ve,
628
- dispose: ye,
627
+ schedule: ye,
628
+ dispose: pe,
629
629
  disposed: () => r
630
630
  };
631
631
  }
632
632
  function B(e) {
633
633
  return typeof e == "object" && e !== null && typeof e.then == "function";
634
634
  }
635
- function Nt(e) {
635
+ function Ot(e) {
636
636
  return e instanceof Error ? e : new Error(
637
637
  `[vue-syntax-highlighter] Highlighting failed: ${typeof e == "string" ? e : String(e)}`
638
638
  );
639
639
  }
640
- const Ot = {
640
+ const Pt = {
641
641
  code: { type: String, default: "" },
642
642
  language: { type: String, default: "text" },
643
643
  engine: { type: [String, Object], default: void 0 },
@@ -690,7 +690,7 @@ const Ot = {
690
690
  function se(e, t, n = 1) {
691
691
  return e === void 0 || !Number.isFinite(e) ? t : Math.max(n, Math.floor(e));
692
692
  }
693
- function Pt(e) {
693
+ function jt(e) {
694
694
  if (!Array.isArray(e)) return [];
695
695
  const t = [];
696
696
  for (const n of e) {
@@ -702,14 +702,14 @@ function Pt(e) {
702
702
  }
703
703
  return Object.freeze(t);
704
704
  }
705
- function Ke(e) {
705
+ function Xe(e) {
706
706
  const t = (e ?? "").trim().replace(/^language-/i, "");
707
707
  return t ? t.toLowerCase() : "text";
708
708
  }
709
- function jt(e) {
709
+ function It(e) {
710
710
  return `language-${e.replace(/[^a-z0-9_+#-]+/g, "-").replace(/^-+|-+$/g, "") || "text"}`;
711
711
  }
712
- function It(e, t, n) {
712
+ function Rt(e, t, n) {
713
713
  e.showLineNumbers !== null && e.showLineNumbers !== void 0 && w("prop-showLineNumbers", ae.showLineNumbers, t), e.wrapLines !== null && e.wrapLines !== void 0 && w("prop-wrapLines", ae.wrapLines, t), e.customStyle !== void 0 && w("prop-customStyle", ae.customStyle, t), e.codeTagProps !== void 0 && w("prop-codeTagProps", ae.codeTagProps, t);
714
714
  let i = e.colorScheme;
715
715
  i !== void 0 && !["auto", "light", "dark"].includes(i) && (w(
@@ -717,19 +717,19 @@ function It(e, t, n) {
717
717
  `Unknown colorScheme "${String(i)}". Expected "auto", "light", or "dark".`,
718
718
  t
719
719
  ), i = void 0);
720
- const s = e.lineNumbers !== null && e.lineNumbers !== void 0 ? !!e.lineNumbers : !!e.showLineNumbers, o = e.wrap !== null && e.wrap !== void 0 ? !!e.wrap : !!e.wrapLines, r = Ke(e.language), l = e.virtualized === "auto" || e.virtualized === !0 ? e.virtualized : e.virtualized === !1 ? !1 : n?.virtualized ?? !1;
720
+ const s = e.lineNumbers !== null && e.lineNumbers !== void 0 ? !!e.lineNumbers : !!e.showLineNumbers, o = e.wrap !== null && e.wrap !== void 0 ? !!e.wrap : !!e.wrapLines, r = Xe(e.language), l = e.virtualized === "auto" || e.virtualized === !0 ? e.virtualized : e.virtualized === !1 ? !1 : n?.virtualized ?? !1;
721
721
  return {
722
- code: typeof e.code == "string" ? e.code : "",
722
+ code: ge(typeof e.code == "string" ? e.code : ""),
723
723
  language: r,
724
- languageClass: jt(r),
724
+ languageClass: It(r),
725
725
  engine: e.engine ?? void 0,
726
726
  engineOptions: e.engineOptions ?? {},
727
727
  theme: e.theme,
728
728
  themes: e.themes,
729
729
  colorScheme: i,
730
730
  lineNumbers: s,
731
- startLine: se(e.startLine, 1),
732
- highlightLines: Pt(e.highlightLines),
731
+ startLine: se(e.startLine, 1, 0),
732
+ highlightLines: jt(e.highlightLines),
733
733
  wrap: o,
734
734
  virtualized: l,
735
735
  virtualizeAfter: se(
@@ -752,7 +752,7 @@ function It(e, t, n) {
752
752
  codeTagProps: e.codeTagProps
753
753
  };
754
754
  }
755
- function Rt(e) {
755
+ function _t(e) {
756
756
  const t = Math.max(0, Math.trunc(e.lineCount)), n = Math.max(1, e.lineHeight), i = Math.max(0, Math.trunc(e.overscan)), s = Math.max(0, e.viewportHeight), o = Math.max(1, Math.ceil(s / n) + 1), r = Math.min(t, o + i * 2);
757
757
  if (t === 0)
758
758
  return {
@@ -773,10 +773,10 @@ function Rt(e) {
773
773
  visibleCount: o
774
774
  };
775
775
  }
776
- function _t(e) {
777
- return e.virtualized === !1 ? { active: !1, reason: "disabled" } : e.virtualized === "auto" && e.lineCount <= e.threshold ? { active: !1, reason: "threshold" } : Ft(e.height, e.maxHeight) ? e.wrap ? { active: !1, reason: "wrap" } : { active: !0 } : { active: !1, reason: "height" };
776
+ function Ft(e) {
777
+ return e.virtualized === !1 ? { active: !1, reason: "disabled" } : e.virtualized === "auto" && e.lineCount <= e.threshold ? { active: !1, reason: "threshold" } : Ut(e.height, e.maxHeight) ? e.wrap ? { active: !1, reason: "wrap" } : { active: !0 } : { active: !1, reason: "height" };
778
778
  }
779
- function Ft(e, t) {
779
+ function Ut(e, t) {
780
780
  return Fe(e) || Fe(t);
781
781
  }
782
782
  function Fe(e) {
@@ -801,9 +801,9 @@ function Ue(e) {
801
801
  if (e !== void 0)
802
802
  return typeof e == "number" ? `${e}px` : e;
803
803
  }
804
- function Xe(e, t) {
804
+ function Ye(e, t) {
805
805
  const n = F(je()), i = x(() => {
806
- const r = Ht(e, t());
806
+ const r = Nt(e, t());
807
807
  return {
808
808
  ...r.theme !== void 0 ? { theme: r.theme } : {},
809
809
  ...r.themes !== void 0 ? { themes: r.themes } : {},
@@ -826,34 +826,34 @@ function Xe(e, t) {
826
826
  },
827
827
  { immediate: !0 }
828
828
  );
829
- const s = x(() => Et(n.value)), o = x(() => Tt(n.value));
829
+ const s = x(() => Tt(n.value)), o = x(() => Mt(n.value));
830
830
  return { theme: n, variables: s, attributes: o, selection: i };
831
831
  }
832
832
  function le(e, t) {
833
833
  return t === void 0 ? e : [e, t];
834
834
  }
835
- function Ut(e, t = 400) {
835
+ function Bt(e, t = 400) {
836
836
  if (typeof e == "number" && Number.isFinite(e)) return e;
837
837
  if (typeof e != "string") return t;
838
838
  const n = /^(\d+(?:\.\d+)?)px$/.exec(e.trim());
839
839
  return n ? Number(n[1]) : t;
840
840
  }
841
- const Ye = Ce({
841
+ const Je = Ce({
842
842
  name: "SyntaxHighlighter",
843
843
  inheritAttrs: !1,
844
- props: Ot,
844
+ props: Pt,
845
845
  emits: {
846
846
  highlighted: (e, t) => !0,
847
847
  error: (e) => !0
848
848
  },
849
849
  setup(e, { attrs: t, slots: n, emit: i, expose: s }) {
850
- const o = de(V, null) ?? fe(), r = x(
851
- () => It(
850
+ const o = fe(V, null) ?? me(), r = x(
851
+ () => Rt(
852
852
  e,
853
853
  o.warningSet,
854
- At(o)
854
+ Ht(o)
855
855
  )
856
- ), l = Xe(o, () => ({
856
+ ), l = Ye(o, () => ({
857
857
  theme: r.value.theme,
858
858
  themes: r.value.themes,
859
859
  colorScheme: r.value.colorScheme
@@ -867,8 +867,8 @@ const Ye = Ce({
867
867
  }), $ = x(
868
868
  () => e.theme !== void 0 || e.themes !== void 0 || e.colorScheme !== void 0
869
869
  ), v = x(() => $.value || !d.value), q = x(
870
- () => De(r.value.code, r.value.language)
871
- ), y = Ge({
870
+ () => Ve(r.value.code, r.value.language)
871
+ ), y = Ke({
872
872
  context: o,
873
873
  getInput: () => {
874
874
  const a = r.value;
@@ -889,9 +889,9 @@ const Ye = Ce({
889
889
  });
890
890
  },
891
891
  onError: (a) => i("error", a)
892
- }), O = we(!1), H = we(0), Q = we(0), C = F(), Z = F(), P = x(() => y.result.value?.lines ?? q.value.lines), ee = x(() => {
892
+ }), O = xe(!1), H = xe(0), Q = xe(0), C = F(), Z = F(), P = x(() => y.result.value?.lines ?? q.value.lines), ee = x(() => {
893
893
  const a = r.value;
894
- return _t({
894
+ return Ft({
895
895
  virtualized: a.virtualized,
896
896
  lineCount: P.value.length,
897
897
  threshold: a.virtualizeAfter,
@@ -900,7 +900,7 @@ const Ye = Ce({
900
900
  maxHeight: a.maxHeight
901
901
  });
902
902
  }), W = x(() => ee.value.active);
903
- nt(() => {
903
+ it(() => {
904
904
  if (!O.value || r.value.virtualized === !1) return;
905
905
  const a = ee.value;
906
906
  if (a.active || a.reason === "threshold" || a.reason === "disabled")
@@ -913,22 +913,22 @@ const Ye = Ce({
913
913
  );
914
914
  });
915
915
  const te = x(() => {
916
- const a = r.value, u = Ut(a.height ?? a.maxHeight);
917
- return Rt({
916
+ const a = r.value, u = Bt(a.height ?? a.maxHeight);
917
+ return _t({
918
918
  scrollTop: H.value,
919
919
  viewportHeight: Q.value || u,
920
920
  lineHeight: a.lineHeight,
921
921
  overscan: a.overscan,
922
922
  lineCount: P.value.length
923
923
  });
924
- }), ve = x(() => {
924
+ }), ye = x(() => {
925
925
  const a = P.value;
926
926
  if (!W.value)
927
927
  return a.map((E, S) => ({ line: E, index: S }));
928
928
  const u = te.value;
929
929
  return a.slice(u.start, u.end).map((E, S) => ({ line: E, index: u.start + S }));
930
930
  });
931
- function ye(a) {
931
+ function pe(a) {
932
932
  for (const u of r.value.highlightLines) {
933
933
  if (typeof u == "number") {
934
934
  if (u === a) return !0;
@@ -959,7 +959,7 @@ const Ye = Ce({
959
959
  return n.token ? n.token({ ...L, renderToken: j }) ?? j() : j();
960
960
  }
961
961
  function h(a, u, E) {
962
- const S = r.value, L = S.startLine + u, j = ye(L), I = { line: a, lineNumber: L, index: u, highlighted: j }, _ = S.lineProps?.(I) ?? {}, { class: G, style: K, ...pe } = _, X = () => a.tokens.map(
962
+ const S = r.value, L = S.startLine + u, j = pe(L), I = { line: a, lineNumber: L, index: u, highlighted: j }, _ = S.lineProps?.(I) ?? {}, { class: G, style: K, ...be } = _, X = () => a.tokens.map(
963
963
  (N, Y) => c(N, Y, a, L)
964
964
  ), U = () => {
965
965
  if (!S.lineNumbers) return null;
@@ -973,16 +973,16 @@ const Ye = Ce({
973
973
  ...I,
974
974
  tokens: a.tokens,
975
975
  renderTokens: X
976
- }, re = n.line?.(ie) ?? X(), Se = E ? [{ height: `${S.lineHeight}px`, lineHeight: `${S.lineHeight}px` }, K] : K;
976
+ }, re = n.line?.(ie) ?? X(), we = E ? [{ height: `${S.lineHeight}px`, lineHeight: `${S.lineHeight}px` }, K] : K;
977
977
  return A(
978
978
  "span",
979
979
  {
980
- ...pe,
980
+ ...be,
981
981
  class: le(
982
982
  ["vsh-line", j && "vsh-line-highlighted"],
983
983
  G
984
984
  ),
985
- style: Se,
985
+ style: we,
986
986
  "data-line": L
987
987
  },
988
988
  [U(), A("span", { class: "vsh-line-content" }, re)]
@@ -1036,9 +1036,9 @@ const Ye = Ce({
1036
1036
  () => y.schedule()
1037
1037
  ), y.attemptInitialSync();
1038
1038
  function ne() {
1039
- return Te(r.value.code);
1039
+ return De(e.code);
1040
1040
  }
1041
- async function Je() {
1041
+ async function Qe() {
1042
1042
  const a = ne();
1043
1043
  try {
1044
1044
  return typeof navigator > "u" || !navigator.clipboard?.writeText ? !1 : (await navigator.clipboard.writeText(a), !0);
@@ -1049,13 +1049,13 @@ const Ye = Ce({
1049
1049
  return s({
1050
1050
  refresh: () => y.refresh(),
1051
1051
  highlight: (a) => y.highlight(a),
1052
- copy: Je,
1052
+ copy: Qe,
1053
1053
  getCopyPayload: ne
1054
1054
  }), () => {
1055
1055
  const a = r.value, u = y.busy.value, E = y.error.value, S = W.value, L = te.value, { class: j, style: I, ..._ } = t, G = Math.max(
1056
1056
  3,
1057
1057
  String(a.startLine + Math.max(0, P.value.length - 1)).length
1058
- ), K = a.lineNumbers ? { "--vsh-gutter-width": `${G + 0.25}ch` } : void 0, pe = v.value ? [
1058
+ ), K = a.lineNumbers ? { "--vsh-gutter-width": `${G + 0.25}ch` } : void 0, be = v.value ? [
1059
1059
  l.variables.value,
1060
1060
  K,
1061
1061
  a.customStyle,
@@ -1065,11 +1065,11 @@ const Ye = Ce({
1065
1065
  ...v.value ? l.attributes.value : {},
1066
1066
  "data-language": a.language,
1067
1067
  class: le(["vsh", a.wrap && "vsh-wrap"], j),
1068
- style: pe,
1068
+ style: be,
1069
1069
  ref: z
1070
- }, U = {}, ie = Ue(a.height), be = Ue(a.maxHeight);
1071
- ie && (U.height = ie), be && (U.maxHeight = be), S && (U.overflow = "auto");
1072
- const re = typeof _["aria-label"] == "string" ? _["aria-label"] : void 0, Se = A(
1070
+ }, U = {}, ie = Ue(a.height), Se = Ue(a.maxHeight);
1071
+ ie && (U.height = ie), Se && (U.maxHeight = Se), S && (U.overflow = "auto");
1072
+ const re = typeof _["aria-label"] == "string" ? _["aria-label"] : void 0, we = A(
1073
1073
  a.preTag,
1074
1074
  {
1075
1075
  class: "vsh-pre",
@@ -1098,8 +1098,8 @@ const Ye = Ce({
1098
1098
  style: { height: `${L.topPadding}px` }
1099
1099
  })
1100
1100
  ] : [],
1101
- ...ve.value.map(
1102
- ({ line: Y, index: Qe }) => h(Y, Qe, S)
1101
+ ...ye.value.map(
1102
+ ({ line: Y, index: Ze }) => h(Y, Ze, S)
1103
1103
  ),
1104
1104
  ...S ? [
1105
1105
  A("div", {
@@ -1119,12 +1119,12 @@ const Ye = Ce({
1119
1119
  language: a.language,
1120
1120
  error: E ?? null
1121
1121
  })
1122
- ), n.error && E && N.push(n.error({ error: E, language: a.language })), N.push(Se), n.footer && N.push(
1122
+ ), n.error && E && N.push(n.error({ error: E, language: a.language })), N.push(we), n.footer && N.push(
1123
1123
  n.footer({ language: a.language, theme: l.theme.value })
1124
1124
  ), A("div", X, N);
1125
1125
  };
1126
1126
  }
1127
- }), Xt = Ce({
1127
+ }), Yt = Ce({
1128
1128
  name: "SyntaxHighlighterProvider",
1129
1129
  props: {
1130
1130
  engine: { type: [String, Object], default: void 0 },
@@ -1149,7 +1149,7 @@ const Ye = Ce({
1149
1149
  virtualizeAfter: { type: Number, default: void 0 }
1150
1150
  },
1151
1151
  setup(e, { slots: t }) {
1152
- const n = de(V, null) ?? fe(), i = J(
1152
+ const n = fe(V, null) ?? me(), i = J(
1153
1153
  {
1154
1154
  ...e.engine !== void 0 ? { engine: e.engine } : {},
1155
1155
  ...e.engines !== void 0 ? { engines: e.engines } : {},
@@ -1169,8 +1169,8 @@ const Ye = Ce({
1169
1169
  n,
1170
1170
  !0
1171
1171
  );
1172
- it(V, i);
1173
- const s = Xe(i, () => ({
1172
+ rt(V, i);
1173
+ const s = Ye(i, () => ({
1174
1174
  theme: e.theme,
1175
1175
  themes: e.themes,
1176
1176
  colorScheme: Ie(e.colorScheme) ? e.colorScheme : void 0
@@ -1242,7 +1242,7 @@ const Ye = Ce({
1242
1242
  t.default?.()
1243
1243
  );
1244
1244
  }
1245
- }), ce = /* @__PURE__ */ new WeakMap(), Yt = {
1245
+ }), ce = /* @__PURE__ */ new WeakMap(), Jt = {
1246
1246
  name: "vue-syntax-highlighter",
1247
1247
  install(e, t = {}) {
1248
1248
  const n = ce.get(e);
@@ -1254,7 +1254,7 @@ const Ye = Ce({
1254
1254
  const r = o instanceof Error ? o.message : String(o), l = /* @__PURE__ */ new Set();
1255
1255
  w("plugin-options", `${r} Falling back to defaults.`, l), i = J({}, void 0, !1);
1256
1256
  }
1257
- ce.set(e, i), e.provide(V, i), e.component(t.componentName ?? "SyntaxHighlighter", Ye);
1257
+ ce.set(e, i), e.provide(V, i), e.component(t.componentName ?? "SyntaxHighlighter", Je);
1258
1258
  const s = e.onUnmount;
1259
1259
  if (typeof s == "function")
1260
1260
  s.call(e, () => {
@@ -1269,16 +1269,16 @@ const Ye = Ce({
1269
1269
  ke(i);
1270
1270
  }
1271
1271
  };
1272
- function Jt(e) {
1273
- const t = e.context ?? de(V, null) ?? fe(), n = Be(), i = x(() => Ke(R(e.language))), s = Ge({
1272
+ function Qt(e) {
1273
+ const t = e.context ?? fe(V, null) ?? me(), n = Be(), i = x(() => Xe(R(e.language))), s = Ke({
1274
1274
  context: t,
1275
1275
  getInput: () => ({
1276
- code: R(e.code) ?? "",
1276
+ code: ge(R(e.code) ?? ""),
1277
1277
  language: i.value,
1278
1278
  engine: R(e.engine),
1279
1279
  engineOptions: R(e.engineOptions)
1280
1280
  })
1281
- }), o = x(() => s.lines.value ? s.lines.value : De(R(e.code) ?? "", i.value).lines);
1281
+ }), o = x(() => s.lines.value ? s.lines.value : Ve(ge(R(e.code) ?? ""), i.value).lines);
1282
1282
  s.attemptInitialSync();
1283
1283
  const r = k(
1284
1284
  () => [
@@ -1307,18 +1307,18 @@ function Jt(e) {
1307
1307
  controller: s
1308
1308
  };
1309
1309
  }
1310
- function me(e, t) {
1310
+ function ve(e, t) {
1311
1311
  return Ce({
1312
1312
  name: e,
1313
1313
  inheritAttrs: !1,
1314
1314
  setup(n, { attrs: i, slots: s }) {
1315
- const o = de(V, null) ?? fe();
1315
+ const o = fe(V, null) ?? me();
1316
1316
  return w(
1317
1317
  `alias:${e}`,
1318
1318
  `The "${e}" component alias is deprecated. Use SyntaxHighlighter with engine="${t}" instead.`,
1319
1319
  o.warningSet
1320
1320
  ), () => {
1321
- const r = Ye, l = {
1321
+ const r = Je, l = {
1322
1322
  ...i,
1323
1323
  engine: i.engine ?? t
1324
1324
  };
@@ -1327,29 +1327,29 @@ function me(e, t) {
1327
1327
  }
1328
1328
  });
1329
1329
  }
1330
- const Qt = me("Light", "highlightjs"), Zt = me("LightAsync", "highlightjs"), en = me("PrismLight", "prism"), tn = me("PrismAsync", "prism");
1330
+ const Zt = ve("Light", "highlightjs"), en = ve("LightAsync", "highlightjs"), tn = ve("PrismLight", "prism"), nn = ve("PrismAsync", "prism");
1331
1331
  export {
1332
- Ve as BUILTIN_ENGINE_IDS,
1332
+ qe as BUILTIN_ENGINE_IDS,
1333
1333
  Me as BUILTIN_THEME_REGISTRY,
1334
1334
  Pe as DEFAULT_THEME,
1335
- Kt as DEFAULT_THEME_NAME,
1336
- $t as EngineManager,
1335
+ Xt as DEFAULT_THEME_NAME,
1336
+ Et as EngineManager,
1337
1337
  V as HIGHLIGHTER_CONTEXT,
1338
- Qt as Light,
1339
- Zt as LightAsync,
1340
- tn as PrismAsync,
1341
- en as PrismLight,
1342
- mt as ResultCache,
1343
- Ye as SyntaxHighlighter,
1344
- Xt as SyntaxHighlighterProvider,
1345
- Yt as VueSyntaxHighlighter,
1346
- ft as buildCacheKey,
1338
+ Zt as Light,
1339
+ en as LightAsync,
1340
+ nn as PrismAsync,
1341
+ tn as PrismLight,
1342
+ vt as ResultCache,
1343
+ Je as SyntaxHighlighter,
1344
+ Yt as SyntaxHighlighterProvider,
1345
+ Jt as VueSyntaxHighlighter,
1346
+ mt as buildCacheKey,
1347
1347
  J as createHighlighterContext,
1348
- Yt as default,
1349
- ut as defineTheme,
1348
+ Jt as default,
1349
+ ht as defineTheme,
1350
1350
  Ie as isColorScheme,
1351
- We as isHighlightEngine,
1351
+ Ge as isHighlightEngine,
1352
1352
  D as stableStringify,
1353
- Jt as useSyntaxHighlighter
1353
+ Qt as useSyntaxHighlighter
1354
1354
  };
1355
1355
  //# sourceMappingURL=index.js.map