@arborium/arborium 2.5.0 → 2.6.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.
Files changed (42) hide show
  1. package/dist/arborium.d.ts +1 -1
  2. package/dist/arborium.iife.js +2 -2
  3. package/dist/arborium.iife.js.map +1 -1
  4. package/dist/arborium.js +160 -155
  5. package/dist/arborium.js.map +1 -1
  6. package/dist/arborium_host.js +9 -9
  7. package/dist/arborium_host_bg.wasm +0 -0
  8. package/dist/loader.d.ts +4 -4
  9. package/dist/plugins-manifest.d.ts +1 -1
  10. package/dist/themes/alabaster.css +0 -34
  11. package/dist/themes/ayu-dark.css +0 -34
  12. package/dist/themes/ayu-light.css +0 -34
  13. package/dist/themes/catppuccin-frappe.css +0 -34
  14. package/dist/themes/catppuccin-latte.css +0 -34
  15. package/dist/themes/catppuccin-macchiato.css +0 -34
  16. package/dist/themes/catppuccin-mocha.css +0 -34
  17. package/dist/themes/cobalt2.css +0 -35
  18. package/dist/themes/dayfox.css +0 -34
  19. package/dist/themes/desert256.css +0 -50
  20. package/dist/themes/dracula.css +0 -34
  21. package/dist/themes/ef-melissa-dark.css +0 -35
  22. package/dist/themes/github-dark.css +0 -34
  23. package/dist/themes/github-light.css +0 -34
  24. package/dist/themes/gruvbox-dark.css +0 -34
  25. package/dist/themes/gruvbox-light.css +0 -34
  26. package/dist/themes/kanagawa-dragon.css +0 -34
  27. package/dist/themes/light-owl.css +0 -54
  28. package/dist/themes/lucius-light.css +0 -35
  29. package/dist/themes/melange-dark.css +0 -35
  30. package/dist/themes/melange-light.css +0 -35
  31. package/dist/themes/monokai.css +0 -34
  32. package/dist/themes/nord.css +0 -34
  33. package/dist/themes/one-dark.css +0 -34
  34. package/dist/themes/rose-pine-moon.css +0 -35
  35. package/dist/themes/rustdoc-ayu.css +0 -34
  36. package/dist/themes/rustdoc-dark.css +0 -34
  37. package/dist/themes/rustdoc-light.css +0 -34
  38. package/dist/themes/solarized-dark.css +0 -35
  39. package/dist/themes/solarized-light.css +0 -35
  40. package/dist/themes/tokyo-night.css +0 -34
  41. package/dist/themes/zenburn.css +0 -34
  42. package/package.json +1 -1
package/dist/arborium.js CHANGED
@@ -1,4 +1,4 @@
1
- const x = "2.5.0", $ = [
1
+ const L = "2.6.1", _ = [
2
2
  "ada",
3
3
  "agda",
4
4
  "asciidoc",
@@ -71,6 +71,7 @@ const x = "2.5.0", $ = [
71
71
  "scala",
72
72
  "scheme",
73
73
  "scss",
74
+ "solidity",
74
75
  "sparql",
75
76
  "sql",
76
77
  "ssh-config",
@@ -97,7 +98,7 @@ const x = "2.5.0", $ = [
97
98
  "yuri",
98
99
  "zig",
99
100
  "zsh"
100
- ], R = [
101
+ ], M = [
101
102
  {
102
103
  name: "attribute",
103
104
  tag: "at"
@@ -432,21 +433,21 @@ const x = "2.5.0", $ = [
432
433
  parentTag: "co"
433
434
  }
434
435
  ];
435
- function y(t, e) {
436
- const a = [...e].sort((r, i) => r.start - i.start);
437
- let n = "", s = 0;
438
- for (const r of a) {
439
- if (r.start < s) continue;
440
- r.start > s && (n += f(t.slice(s, r.start)));
441
- const i = L(r.capture), c = f(t.slice(r.start, r.end));
442
- i ? n += `<a-${i}>${c}</a-${i}>` : n += c, s = r.end;
436
+ function y(t, a) {
437
+ const r = [...a].sort((n, o) => n.start - o.start);
438
+ let e = "", s = 0;
439
+ for (const n of r) {
440
+ if (n.start < s) continue;
441
+ n.start > s && (e += u(t.slice(s, n.start)));
442
+ const o = U(n.capture), i = u(t.slice(n.start, n.end));
443
+ o ? e += `<a-${o}>${i}</a-${o}>` : e += i, s = n.end;
443
444
  }
444
- return s < t.length && (n += f(t.slice(s))), n;
445
+ return s < t.length && (e += u(t.slice(s))), e;
445
446
  }
446
- function L(t) {
447
+ function U(t) {
447
448
  return t.startsWith("keyword") || t === "include" || t === "conditional" ? "k" : t.startsWith("function") || t.startsWith("method") ? "f" : t.startsWith("string") || t === "character" ? "s" : t.startsWith("comment") ? "c" : t.startsWith("type") ? "t" : t.startsWith("variable") ? "v" : t.startsWith("number") || t === "float" ? "n" : t.startsWith("operator") ? "o" : t.startsWith("punctuation") ? "p" : t.startsWith("tag") ? "tg" : t.startsWith("attribute") ? "at" : null;
448
449
  }
449
- function f(t) {
450
+ function u(t) {
450
451
  return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
451
452
  }
452
453
  const v = {
@@ -454,184 +455,187 @@ const v = {
454
455
  theme: "one-dark",
455
456
  selector: "pre code",
456
457
  cdn: "jsdelivr",
457
- version: x,
458
+ version: L,
458
459
  // Precise version from manifest
459
460
  pluginsUrl: "",
460
461
  // Empty means use bundled manifest
461
462
  hostUrl: "",
462
463
  // Empty means use CDN based on version
463
- resolveJs: ({ baseUrl: t, path: e }) => import(
464
+ resolveJs: ({ baseUrl: t, path: a }) => import(
464
465
  /* @vite-ignore */
465
- `${t}/${e}`
466
+ `${t}/${a}`
466
467
  ),
467
- resolveWasm: ({ baseUrl: t, path: e }) => fetch(`${t}/${e}`)
468
+ resolveWasm: ({ baseUrl: t, path: a }) => fetch(`${t}/${a}`)
468
469
  };
469
- let p = null, m = null, o = { ...v };
470
- const h = /* @__PURE__ */ new Map(), T = new Set($);
471
- let l = null, u = null;
472
- async function _() {
473
- if (o.pluginsUrl)
474
- return u || (u = (async () => {
475
- console.debug(`[arborium] Loading local plugins manifest from: ${o.pluginsUrl}`);
476
- const t = await fetch(o.pluginsUrl);
477
- if (!t.ok)
478
- throw new Error(`Failed to load plugins.json: ${t.status}`);
479
- l = await t.json(), console.debug(`[arborium] Loaded local manifest with ${l?.entries.length} entries`);
480
- })(), u);
470
+ let p = null, g = null, d = { ...v };
471
+ const h = /* @__PURE__ */ new Map(), T = new Set(_);
472
+ let l = null, m = null;
473
+ async function E(t) {
474
+ if (t.pluginsUrl)
475
+ return m || (m = (async () => {
476
+ console.debug(`[arborium] Loading local plugins manifest from: ${t.pluginsUrl}`);
477
+ const a = await fetch(t.pluginsUrl);
478
+ if (!a.ok)
479
+ throw new Error(`Failed to load plugins.json: ${a.status}`);
480
+ l = await a.json(), console.debug(`[arborium] Loaded local manifest with ${l?.entries.length} entries`);
481
+ })(), m);
481
482
  }
482
- function U(t) {
483
+ function W(t, a) {
483
484
  if (l) {
484
- const s = l.entries.find((r) => r.language === t);
485
- if (s)
486
- return s.local_js.substring(0, s.local_js.lastIndexOf("/"));
485
+ const n = l.entries.find((o) => o.language === t);
486
+ if (n)
487
+ return n.local_js.substring(0, n.local_js.lastIndexOf("/"));
487
488
  }
488
- const e = o.cdn, a = o.version;
489
- let n;
490
- return e === "jsdelivr" ? n = "https://cdn.jsdelivr.net/npm" : e === "unpkg" ? n = "https://unpkg.com" : n = e, `${n}/@arborium/${t}@${a}`;
489
+ const r = a.cdn, e = a.version;
490
+ let s;
491
+ return r === "jsdelivr" ? s = "https://cdn.jsdelivr.net/npm" : r === "unpkg" ? s = "https://unpkg.com" : s = r, `${s}/@arborium/${t}@${e}`;
491
492
  }
492
- async function w(t) {
493
- const e = h.get(t);
494
- if (e)
495
- return console.debug(`[arborium] Grammar '${t}' found in cache`), e;
496
- if (await _(), !T.has(t) && !l?.entries.some((a) => a.language === t))
493
+ async function w(t, a) {
494
+ const r = h.get(t);
495
+ if (r)
496
+ return console.debug(`[arborium] Grammar '${t}' found in cache`), r;
497
+ if (await E(a), !T.has(t) && !l?.entries.some((e) => e.language === t))
497
498
  return console.debug(`[arborium] Grammar '${t}' not available`), null;
498
499
  try {
499
- const a = U(t), n = o.resolveJs === v.resolveJs ? ` from ${a}/grammar.js` : "";
500
- console.debug(`[arborium] Loading grammar '${t}'${n}`);
501
- const s = await o.resolveJs({ language: t, baseUrl: a, path: "grammar.js" }), r = await o.resolveWasm({ language: t, baseUrl: a, path: "grammar_bg.wasm" });
502
- await s.default({ module_or_path: r });
503
- const i = s.language_id();
500
+ const e = W(t, a), s = a.resolveJs === v.resolveJs ? ` from ${e}/grammar.js` : "";
501
+ console.debug(`[arborium] Loading grammar '${t}'${s}`);
502
+ const n = await a.resolveJs({ language: t, baseUrl: e, path: "grammar.js" }), o = await a.resolveWasm({ language: t, baseUrl: e, path: "grammar_bg.wasm" });
503
+ await n.default({ module_or_path: o });
504
+ const i = n.language_id();
504
505
  i !== t && console.warn(`[arborium] Language ID mismatch: expected '${t}', got '${i}'`);
505
- const c = s.injection_languages(), k = {
506
+ const x = n.injection_languages(), k = {
506
507
  languageId: t,
507
- injectionLanguages: c,
508
- module: s,
509
- parse: (j) => {
510
- const d = s.create_session();
508
+ injectionLanguages: x,
509
+ module: n,
510
+ parse: ($) => {
511
+ const b = n.create_session();
511
512
  try {
512
- s.set_text(d, j);
513
- const g = s.parse(d);
513
+ n.set_text(b, $);
514
+ const c = n.parse(b);
514
515
  return {
515
- spans: g.spans || [],
516
- injections: g.injections || []
516
+ spans: c.spans || [],
517
+ injections: c.injections || []
517
518
  };
518
- } catch (g) {
519
- return console.error("[arborium] Parse error:", g), { spans: [], injections: [] };
519
+ } catch (c) {
520
+ return console.error("[arborium] Parse error:", c), { spans: [], injections: [] };
520
521
  } finally {
521
- s.free_session(d);
522
+ n.free_session(b);
522
523
  }
523
524
  }
524
525
  };
525
526
  return h.set(t, k), console.debug(`[arborium] Grammar '${t}' loaded successfully`), k;
526
- } catch (a) {
527
- return console.error(`[arborium] Failed to load grammar '${t}':`, a), null;
527
+ } catch (e) {
528
+ return console.error(`[arborium] Failed to load grammar '${t}':`, e), null;
528
529
  }
529
530
  }
530
- const b = /* @__PURE__ */ new Map();
531
- let E = 1;
532
- function W() {
531
+ const f = /* @__PURE__ */ new Map();
532
+ let C = 1;
533
+ function S(t) {
533
534
  window.arboriumHost = {
534
535
  /** Check if a language is available (sync) */
535
- isLanguageAvailable(t) {
536
- return T.has(t) || h.has(t);
536
+ isLanguageAvailable(a) {
537
+ return T.has(a) || h.has(a);
537
538
  },
538
539
  /** Load a grammar and return a handle (async) */
539
- async loadGrammar(t) {
540
- const e = await w(t);
541
- if (!e) return 0;
542
- for (const [n, s] of b)
543
- if (s === e) return n;
544
- const a = E++;
545
- return b.set(a, e), a;
540
+ async loadGrammar(a) {
541
+ const r = await w(a, t);
542
+ if (!r) return 0;
543
+ for (const [s, n] of f)
544
+ if (n === r) return s;
545
+ const e = C++;
546
+ return f.set(e, r), e;
546
547
  },
547
548
  /** Parse text using a grammar handle (sync) */
548
- parse(t, e) {
549
- const a = b.get(t);
550
- return a ? a.parse(e) : { spans: [], injections: [] };
549
+ parse(a, r) {
550
+ const e = f.get(a);
551
+ return e ? e.parse(r) : { spans: [], injections: [] };
551
552
  }
552
553
  };
553
554
  }
554
- function S() {
555
- if (o.hostUrl)
556
- return o.hostUrl;
557
- const t = o.cdn, e = o.version;
558
- let a;
559
- t === "jsdelivr" ? a = "https://cdn.jsdelivr.net/npm" : t === "unpkg" ? a = "https://unpkg.com" : a = t;
560
- const n = e === "latest" ? "" : `@${e}`;
561
- return `${a}/@arborium/arborium${n}/dist`;
555
+ function q(t) {
556
+ if (t.hostUrl)
557
+ return t.hostUrl;
558
+ const a = t.cdn, r = t.version;
559
+ let e;
560
+ a === "jsdelivr" ? e = "https://cdn.jsdelivr.net/npm" : a === "unpkg" ? e = "https://unpkg.com" : e = a;
561
+ const s = r === "latest" ? "" : `@${r}`;
562
+ return `${e}/@arborium/arborium${s}/dist`;
562
563
  }
563
- async function q() {
564
- return p || m || (m = (async () => {
565
- W();
566
- const t = S(), e = `${t}/arborium_host.js`, a = `${t}/arborium_host_bg.wasm`;
567
- console.debug(`[arborium] Loading host from ${e}`);
564
+ async function I(t) {
565
+ return p || g || (g = (async () => {
566
+ S(t);
567
+ const a = q(t), r = `${a}/arborium_host.js`, e = `${a}/arborium_host_bg.wasm`;
568
+ console.debug(`[arborium] Loading host from ${r}`);
568
569
  try {
569
- const n = await import(
570
+ const s = await import(
570
571
  /* @vite-ignore */
571
- e
572
+ r
572
573
  );
573
- return await n.default(a), p = {
574
- highlight: n.highlight,
575
- isLanguageAvailable: n.isLanguageAvailable
574
+ return await s.default(e), p = {
575
+ highlight: s.highlight,
576
+ isLanguageAvailable: s.isLanguageAvailable
576
577
  }, console.debug("[arborium] Host loaded successfully"), p;
577
- } catch (n) {
578
- return console.error("[arborium] Failed to load host:", n), null;
578
+ } catch (s) {
579
+ return console.error("[arborium] Failed to load host:", s), null;
579
580
  }
580
- })(), m);
581
+ })(), g);
581
582
  }
582
- async function H(t, e, a) {
583
- const n = await q();
584
- if (n)
583
+ async function P(t, a, r) {
584
+ const e = j(r), s = await I(e);
585
+ if (s)
585
586
  try {
586
- return n.highlight(t, e);
587
+ return s.highlight(t, a);
587
588
  } catch (i) {
588
589
  console.warn("Host highlight failed, falling back to JS:", i);
589
590
  }
590
- const s = await w(t);
591
- if (!s)
592
- return f(e);
593
- const r = s.parse(e);
594
- return y(e, r.spans);
591
+ const n = await w(t, e);
592
+ if (!n)
593
+ return u(a);
594
+ const o = n.parse(a);
595
+ return y(a, o.spans);
595
596
  }
596
- async function M(t, e) {
597
- const a = await w(t);
598
- if (!a) return null;
599
- const { module: n } = a;
597
+ async function A(t, a) {
598
+ const r = j(a), e = await w(t, r);
599
+ if (!e) return null;
600
+ const { module: s } = e;
600
601
  return {
601
- languageId: () => a.languageId,
602
- injectionLanguages: () => a.injectionLanguages,
603
- highlight: async (s) => {
604
- const r = a.parse(s);
605
- return y(s, r.spans);
602
+ languageId: () => e.languageId,
603
+ injectionLanguages: () => e.injectionLanguages,
604
+ highlight: async (n) => {
605
+ const o = e.parse(n);
606
+ return y(n, o.spans);
606
607
  },
607
- parse: (s) => a.parse(s),
608
+ parse: (n) => e.parse(n),
608
609
  createSession: () => {
609
- const s = n.create_session();
610
+ const n = s.create_session();
610
611
  return {
611
- setText: (r) => n.set_text(s, r),
612
+ setText: (o) => s.set_text(n, o),
612
613
  parse: () => {
613
614
  try {
614
- const r = n.parse(s);
615
+ const o = s.parse(n);
615
616
  return {
616
- spans: r.spans || [],
617
- injections: r.injections || []
617
+ spans: o.spans || [],
618
+ injections: o.injections || []
618
619
  };
619
- } catch (r) {
620
- return console.error("[arborium] Session parse error:", r), { spans: [], injections: [] };
620
+ } catch (o) {
621
+ return console.error("[arborium] Session parse error:", o), { spans: [], injections: [] };
621
622
  }
622
623
  },
623
- cancel: () => n.cancel(s),
624
- free: () => n.free_session(s)
624
+ cancel: () => s.cancel(n),
625
+ free: () => s.free_session(n)
625
626
  };
626
627
  },
627
628
  dispose: () => {
628
629
  }
629
630
  };
630
631
  }
631
- function P(t) {
632
- return t ? { ...o, ...t } : { ...o };
632
+ function j(t) {
633
+ return t ? { ...d, ...t } : { ...d };
634
+ }
635
+ function G(t) {
636
+ d = { ...d, ...t };
633
637
  }
634
- const C = [
638
+ const R = [
635
639
  [/^#!.*\bpython[23]?\b/, "python"],
636
640
  [/^#!.*\bnode\b/, "javascript"],
637
641
  [/^#!.*\bdeno\b/, "typescript"],
@@ -644,7 +648,7 @@ const C = [
644
648
  [/^#!.*\bsh\b/, "bash"],
645
649
  [/^#!.*\blua\b/, "lua"],
646
650
  [/^#!.*\bawk\b/, "awk"]
647
- ], I = [
651
+ ], H = [
648
652
  // Rust - distinctive keywords
649
653
  [/\b(fn|impl|trait|pub\s+fn|let\s+mut|&mut|->)\b/, "rust"],
650
654
  // Go - distinctive keywords
@@ -704,23 +708,23 @@ const C = [
704
708
  // Zig
705
709
  [/\b(pub\s+fn|const\s+\w+\s*=|@import\(|comptime)\b/, "zig"]
706
710
  ];
707
- function A(t) {
708
- const e = t.split(`
711
+ function F(t) {
712
+ const a = t.split(`
709
713
  `)[0];
710
- for (const [a, n] of C)
711
- if (a.test(e))
712
- return n;
713
- for (const [a, n] of I)
714
- if (a.test(t))
715
- return n;
714
+ for (const [r, e] of R)
715
+ if (r.test(a))
716
+ return e;
717
+ for (const [r, e] of H)
718
+ if (r.test(t))
719
+ return e;
716
720
  return null;
717
721
  }
718
- function G(t) {
719
- const e = t.match(/\blanguage-(\w+)\b/);
720
- if (e) return e[1];
721
- const a = t.match(/\blang-(\w+)\b/);
722
+ function O(t) {
723
+ const a = t.match(/\blanguage-(\w+)\b/);
722
724
  if (a) return a[1];
723
- const n = /* @__PURE__ */ new Set([
725
+ const r = t.match(/\blang-(\w+)\b/);
726
+ if (r) return r[1];
727
+ const e = /* @__PURE__ */ new Set([
724
728
  "rust",
725
729
  "javascript",
726
730
  "typescript",
@@ -757,12 +761,12 @@ function G(t) {
757
761
  "sh"
758
762
  ]);
759
763
  for (const s of t.split(/\s+/))
760
- if (n.has(s.toLowerCase()))
764
+ if (e.has(s.toLowerCase()))
761
765
  return s.toLowerCase();
762
766
  return null;
763
767
  }
764
- function F(t) {
765
- const e = {
768
+ function z(t) {
769
+ const a = {
766
770
  js: "javascript",
767
771
  ts: "typescript",
768
772
  py: "python",
@@ -782,19 +786,20 @@ function F(t) {
782
786
  plaintext: "text",
783
787
  plain: "text",
784
788
  txt: "text"
785
- }, a = t.toLowerCase();
786
- return e[a] || a;
789
+ }, r = t.toLowerCase();
790
+ return a[r] || r;
787
791
  }
788
792
  export {
789
- $ as availableLanguages,
790
- A as detectLanguage,
791
- G as extractLanguageFromClass,
792
- P as getConfig,
793
- H as highlight,
794
- R as highlights,
795
- M as loadGrammar,
796
- F as normalizeLanguage,
797
- x as pluginVersion,
793
+ _ as availableLanguages,
794
+ F as detectLanguage,
795
+ O as extractLanguageFromClass,
796
+ j as getConfig,
797
+ P as highlight,
798
+ M as highlights,
799
+ A as loadGrammar,
800
+ z as normalizeLanguage,
801
+ L as pluginVersion,
802
+ G as setConfig,
798
803
  y as spansToHtml
799
804
  };
800
805
  //# sourceMappingURL=arborium.js.map