@arborium/arborium 2.11.0 → 2.12.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/arborium.js CHANGED
@@ -1,4 +1,158 @@
1
- const x = "2.11.0", $ = [
1
+ const L = [
2
+ [/^#!.*\bpython[23]?\b/, "python"],
3
+ [/^#!.*\bnode\b/, "javascript"],
4
+ [/^#!.*\bdeno\b/, "typescript"],
5
+ [/^#!.*\bbun\b/, "typescript"],
6
+ [/^#!.*\bruby\b/, "ruby"],
7
+ [/^#!.*\bperl\b/, "perl"],
8
+ [/^#!.*\bphp\b/, "php"],
9
+ [/^#!.*\bbash\b/, "bash"],
10
+ [/^#!.*\bzsh\b/, "zsh"],
11
+ [/^#!.*\bsh\b/, "bash"],
12
+ [/^#!.*\blua\b/, "lua"],
13
+ [/^#!.*\bawk\b/, "awk"]
14
+ ], $ = [
15
+ // Rust - distinctive keywords
16
+ [/\b(fn|impl|trait|pub\s+fn|let\s+mut|&mut|->)\b/, "rust"],
17
+ // Go - distinctive keywords
18
+ [/\b(func|package\s+\w+|import\s+\(|go\s+func|chan\s+\w+)\b/, "go"],
19
+ // Python - distinctive patterns
20
+ [/\b(def\s+\w+\s*\(|import\s+\w+|from\s+\w+\s+import|class\s+\w+:)\b/, "python"],
21
+ // TypeScript - distinctive type annotations
22
+ [/:\s*(string|number|boolean|void)\b|\binterface\s+\w+\s*\{/, "typescript"],
23
+ // JavaScript - distinctive patterns (after TS check)
24
+ [/\b(const|let|var)\s+\w+\s*=|function\s+\w+\s*\(|=>\s*\{/, "javascript"],
25
+ // Ruby - distinctive keywords
26
+ [/\b(def\s+\w+|end\b|do\s*\|.*\||puts\s+|require\s+['"])\b/, "ruby"],
27
+ // Java - distinctive patterns
28
+ [/\b(public\s+class|private\s+\w+|System\.out\.println)\b/, "java"],
29
+ // C++ - distinctive patterns
30
+ [/\b(#include\s*<|std::|template\s*<|nullptr|cout\s*<<)\b/, "cpp"],
31
+ // C - distinctive patterns (after C++ check)
32
+ [/\b(#include\s*[<"]|printf\s*\(|int\s+main\s*\(|void\s+\w+\s*\()\b/, "c"],
33
+ // C# - distinctive patterns
34
+ [/\b(namespace\s+\w+|using\s+System|public\s+static\s+void)\b/, "c-sharp"],
35
+ // PHP - distinctive patterns
36
+ [/<\?php|\$\w+\s*=/, "php"],
37
+ // Swift - distinctive patterns
38
+ [/\b(func\s+\w+|var\s+\w+:\s*\w+|let\s+\w+:\s*\w+|@objc)\b/, "swift"],
39
+ // Kotlin - distinctive patterns
40
+ [/\b(fun\s+\w+|val\s+\w+|var\s+\w+:|data\s+class)\b/, "kotlin"],
41
+ // Scala - distinctive patterns
42
+ [/\b(def\s+\w+|val\s+\w+|var\s+\w+|object\s+\w+|case\s+class)\b/, "scala"],
43
+ // Haskell - distinctive patterns
44
+ [/\b(module\s+\w+|import\s+qualified|data\s+\w+\s*=|::\s*\w+\s*->)\b/, "haskell"],
45
+ // Elixir - distinctive patterns
46
+ [/\b(defmodule\s+\w+|def\s+\w+|defp\s+\w+|\|>)\b/, "elixir"],
47
+ // Lua - distinctive patterns
48
+ [/\b(local\s+\w+\s*=|function\s+\w+\.\w+|require\s*\()\b/, "lua"],
49
+ // SQL - distinctive patterns
50
+ [/\b(SELECT\s+.*\s+FROM|INSERT\s+INTO|CREATE\s+TABLE|ALTER\s+TABLE)\b/i, "sql"],
51
+ // Shell/Bash - distinctive patterns
52
+ [/\b(if\s+\[\s*|then\b|fi\b|echo\s+["']|export\s+\w+=)\b/, "bash"],
53
+ // YAML - distinctive patterns
54
+ [/^\s*[\w-]+:\s*[\w\-"'[{]|^---\s*$/, "yaml"],
55
+ // JSON - distinctive patterns
56
+ [/^\s*\{[\s\S]*"[\w-]+":\s*/, "json"],
57
+ // TOML - distinctive patterns
58
+ [/^\s*\[[\w.-]+\]\s*$|^\s*\w+\s*=\s*["'\d\[]/, "toml"],
59
+ // HTML - distinctive patterns
60
+ [/<(!DOCTYPE|html|head|body|div|span|p|a\s)/i, "html"],
61
+ // CSS - distinctive patterns
62
+ [/^\s*[\w.#@][\w\s,#.:>+~-]*\{[^}]*\}|@media\s|@import\s/, "css"],
63
+ // Markdown - distinctive patterns
64
+ [/^#{1,6}\s+\w|^\s*[-*+]\s+\w|^\s*\d+\.\s+\w|```\w*\n/, "markdown"],
65
+ // XML - distinctive patterns
66
+ [/<\?xml|<[\w:-]+\s+xmlns/, "xml"],
67
+ // Dockerfile
68
+ [/^FROM\s+\w+|^RUN\s+|^COPY\s+|^ENTRYPOINT\s+/m, "dockerfile"],
69
+ // Nginx config
70
+ [/\b(server\s*\{|location\s+[\/~]|proxy_pass\s+)\b/, "nginx"],
71
+ // Zig
72
+ [/\b(pub\s+fn|const\s+\w+\s*=|@import\(|comptime)\b/, "zig"]
73
+ ];
74
+ function M(e) {
75
+ const t = e.split(`
76
+ `)[0];
77
+ for (const [a, s] of L)
78
+ if (a.test(t))
79
+ return s;
80
+ for (const [a, s] of $)
81
+ if (a.test(e))
82
+ return s;
83
+ return null;
84
+ }
85
+ function R(e) {
86
+ const t = e.match(/\blanguage-(\w+)\b/);
87
+ if (t) return t[1];
88
+ const a = e.match(/\blang-(\w+)\b/);
89
+ if (a) return a[1];
90
+ const s = /* @__PURE__ */ new Set([
91
+ "rust",
92
+ "javascript",
93
+ "typescript",
94
+ "python",
95
+ "ruby",
96
+ "go",
97
+ "java",
98
+ "c",
99
+ "cpp",
100
+ "csharp",
101
+ "php",
102
+ "swift",
103
+ "kotlin",
104
+ "scala",
105
+ "haskell",
106
+ "elixir",
107
+ "lua",
108
+ "sql",
109
+ "bash",
110
+ "shell",
111
+ "yaml",
112
+ "json",
113
+ "toml",
114
+ "html",
115
+ "css",
116
+ "xml",
117
+ "markdown",
118
+ "dockerfile",
119
+ "nginx",
120
+ "zig",
121
+ "text",
122
+ "plaintext",
123
+ "console",
124
+ "sh"
125
+ ]);
126
+ for (const n of e.split(/\s+/))
127
+ if (s.has(n.toLowerCase()))
128
+ return n.toLowerCase();
129
+ return null;
130
+ }
131
+ function H(e) {
132
+ const t = {
133
+ js: "javascript",
134
+ ts: "typescript",
135
+ py: "python",
136
+ rb: "ruby",
137
+ rs: "rust",
138
+ sh: "bash",
139
+ shell: "bash",
140
+ yml: "yaml",
141
+ cs: "c-sharp",
142
+ csharp: "c-sharp",
143
+ "c++": "cpp",
144
+ "c#": "c-sharp",
145
+ "f#": "fsharp",
146
+ dockerfile: "dockerfile",
147
+ docker: "dockerfile",
148
+ makefile: "make",
149
+ plaintext: "text",
150
+ plain: "text",
151
+ txt: "text"
152
+ }, a = e.toLowerCase();
153
+ return t[a] || a;
154
+ }
155
+ const _ = "2.12.1", U = [
2
156
  "ada",
3
157
  "agda",
4
158
  "asciidoc",
@@ -101,7 +255,7 @@ const x = "2.11.0", $ = [
101
255
  "yuri",
102
256
  "zig",
103
257
  "zsh"
104
- ], R = [
258
+ ], F = [
105
259
  {
106
260
  name: "attribute",
107
261
  tag: "at"
@@ -435,15 +589,15 @@ const x = "2.11.0", $ = [
435
589
  tag: "cb"
436
590
  }
437
591
  ];
438
- function L(e) {
592
+ function E(e) {
439
593
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
440
594
  }
441
- const y = {
595
+ const T = {
442
596
  manual: !1,
443
597
  theme: "one-dark",
444
598
  selector: "pre code",
445
599
  cdn: "jsdelivr",
446
- version: x,
600
+ version: _,
447
601
  // Precise version from manifest
448
602
  pluginsUrl: "",
449
603
  // Empty means use bundled manifest
@@ -455,68 +609,68 @@ const y = {
455
609
  ),
456
610
  resolveWasm: ({ baseUrl: e, path: t }) => fetch(`${e}/${t}`)
457
611
  };
458
- let p = null, m = null, g = { ...y };
459
- const h = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), k = new Set($);
460
- let c = null, u = null;
461
- async function _(e) {
612
+ let p = null, m = null, g = { ...T };
613
+ const y = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), d = new Set(U);
614
+ let l = null, u = null;
615
+ async function k(e) {
462
616
  if (e.pluginsUrl)
463
617
  return u || (u = (async () => {
464
618
  console.debug(`[arborium] Loading local plugins manifest from: ${e.pluginsUrl}`);
465
619
  const t = await fetch(e.pluginsUrl);
466
620
  if (!t.ok)
467
621
  throw new Error(`Failed to load plugins.json: ${t.status}`);
468
- c = await t.json(), console.debug(`[arborium] Loaded local manifest with ${c?.entries.length} entries`);
622
+ l = await t.json(), console.debug(`[arborium] Loaded local manifest with ${l?.entries.length} entries`);
469
623
  })(), u);
470
624
  }
471
- function U(e, t) {
472
- if (c) {
473
- const r = c.entries.find((o) => o.language === e);
625
+ function P(e, t) {
626
+ if (l) {
627
+ const r = l.entries.find((o) => o.language === e);
474
628
  if (r)
475
629
  return r.local_js.substring(0, r.local_js.lastIndexOf("/"));
476
630
  }
477
- const n = t.cdn, s = t.version;
478
- let a;
479
- return n === "jsdelivr" ? a = "https://cdn.jsdelivr.net/npm" : n === "unpkg" ? a = "https://unpkg.com" : a = n, `${a}/@arborium/${e}@${s}`;
631
+ const a = t.cdn, s = t.version;
632
+ let n;
633
+ return a === "jsdelivr" ? n = "https://cdn.jsdelivr.net/npm" : a === "unpkg" ? n = "https://unpkg.com" : n = a, `${n}/@arborium/${e}@${s}`;
480
634
  }
481
- async function v(e, t) {
482
- const n = h.get(e);
483
- if (n)
484
- return console.debug(`[arborium] Grammar '${e}' found in cache`), n;
485
- const s = b.get(e);
635
+ async function j(e, t) {
636
+ const a = y.get(e);
637
+ if (a)
638
+ return console.debug(`[arborium] Grammar '${e}' found in cache`), a;
639
+ const s = h.get(e);
486
640
  if (s)
487
641
  return console.debug(`[arborium] Grammar '${e}' already loading, waiting...`), s;
488
- const a = E(e, t);
489
- b.set(e, a);
642
+ const n = q(e, t);
643
+ h.set(e, n);
490
644
  try {
491
- return await a;
645
+ return await n;
492
646
  } finally {
493
- b.delete(e);
647
+ h.delete(e);
494
648
  }
495
649
  }
496
- async function E(e, t) {
497
- if (await _(t), !k.has(e) && !c?.entries.some((n) => n.language === e))
650
+ async function q(e, t) {
651
+ if (await k(t), !d.has(e) && !l?.entries.some((a) => a.language === e))
498
652
  return console.debug(`[arborium] Grammar '${e}' not available`), null;
499
653
  try {
500
- const n = U(e, t), s = t.resolveJs === y.resolveJs ? ` from ${n}/grammar.js` : "";
654
+ const a = P(e, t), s = t.resolveJs === T.resolveJs ? ` from ${a}/grammar.js` : "";
501
655
  console.debug(`[arborium] Loading grammar '${e}'${s}`);
502
- const a = await t.resolveJs({
656
+ const n = await t.resolveJs({
503
657
  language: e,
504
- baseUrl: n,
658
+ baseUrl: a,
505
659
  path: "grammar.js"
506
- }), r = await t.resolveWasm({ language: e, baseUrl: n, path: "grammar_bg.wasm" });
507
- await a.default({ module_or_path: r });
508
- const o = a.language_id();
660
+ }), r = await t.resolveWasm({ language: e, baseUrl: a, path: "grammar_bg.wasm" });
661
+ await n.default({ module_or_path: r });
662
+ const o = n.language_id();
509
663
  o !== e && console.warn(`[arborium] Language ID mismatch: expected '${e}', got '${o}'`);
510
- const j = a.injection_languages(), w = {
664
+ const x = n.injection_languages(), v = {
511
665
  languageId: e,
512
- injectionLanguages: j,
513
- module: a,
666
+ injectionLanguages: x,
667
+ module: n,
514
668
  // UTF-8 parsing for Rust host
515
- parseUtf8: (d) => {
516
- const l = a.create_session();
669
+ parseUtf8: (f) => {
670
+ const c = n.create_session();
517
671
  try {
518
- a.set_text(l, d);
519
- const i = a.parse(l);
672
+ n.set_text(c, f);
673
+ const i = n.parse(c);
520
674
  return {
521
675
  spans: i.spans || [],
522
676
  injections: i.injections || []
@@ -524,15 +678,15 @@ async function E(e, t) {
524
678
  } catch (i) {
525
679
  return console.error("[arborium] Parse error:", i), { spans: [], injections: [] };
526
680
  } finally {
527
- a.free_session(l);
681
+ n.free_session(c);
528
682
  }
529
683
  },
530
684
  // UTF-16 parsing for JavaScript public API
531
- parseUtf16: (d) => {
532
- const l = a.create_session();
685
+ parseUtf16: (f) => {
686
+ const c = n.create_session();
533
687
  try {
534
- a.set_text(l, d);
535
- const i = a.parse_utf16(l);
688
+ n.set_text(c, f);
689
+ const i = n.parse_utf16(c);
536
690
  return {
537
691
  spans: i.spans || [],
538
692
  injections: i.injections || []
@@ -540,95 +694,95 @@ async function E(e, t) {
540
694
  } catch (i) {
541
695
  return console.error("[arborium] Parse error:", i), { spans: [], injections: [] };
542
696
  } finally {
543
- a.free_session(l);
697
+ n.free_session(c);
544
698
  }
545
699
  }
546
700
  };
547
- return h.set(e, w), console.debug(`[arborium] Grammar '${e}' loaded successfully`), w;
548
- } catch (n) {
549
- return console.error(`[arborium] Failed to load grammar '${e}':`, n), null;
701
+ return y.set(e, v), console.debug(`[arborium] Grammar '${e}' loaded successfully`), v;
702
+ } catch (a) {
703
+ return console.error(`[arborium] Failed to load grammar '${e}':`, a), null;
550
704
  }
551
705
  }
552
- const f = /* @__PURE__ */ new Map();
553
- let P = 1;
554
- function q(e) {
706
+ const w = /* @__PURE__ */ new Map();
707
+ let C = 1;
708
+ function I(e) {
555
709
  window.arboriumHost = {
556
710
  /** Check if a language is available (sync) */
557
711
  isLanguageAvailable(t) {
558
- return k.has(t) || h.has(t);
712
+ return d.has(t) || y.has(t);
559
713
  },
560
714
  /** Load a grammar and return a handle (async) */
561
715
  async loadGrammar(t) {
562
- const n = await v(t, e);
563
- if (!n) return 0;
564
- for (const [a, r] of f)
565
- if (r === n) return a;
566
- const s = P++;
567
- return f.set(s, n), s;
716
+ const a = await j(t, e);
717
+ if (!a) return 0;
718
+ for (const [n, r] of w)
719
+ if (r === a) return n;
720
+ const s = C++;
721
+ return w.set(s, a), s;
568
722
  },
569
723
  /** Parse text using a grammar handle (sync) - returns UTF-8 offsets for Rust host */
570
- parse(t, n) {
571
- const s = f.get(t);
572
- return s ? s.parseUtf8(n) : { spans: [], injections: [] };
724
+ parse(t, a) {
725
+ const s = w.get(t);
726
+ return s ? s.parseUtf8(a) : { spans: [], injections: [] };
573
727
  }
574
728
  };
575
729
  }
576
- function C(e) {
730
+ function S(e) {
577
731
  if (e.hostUrl)
578
732
  return e.hostUrl;
579
- const t = e.cdn, n = e.version;
733
+ const t = e.cdn, a = e.version;
580
734
  let s;
581
735
  t === "jsdelivr" ? s = "https://cdn.jsdelivr.net/npm" : t === "unpkg" ? s = "https://unpkg.com" : s = t;
582
- const a = n === "latest" ? "" : `@${n}`;
583
- return `${s}/@arborium/arborium${a}/dist`;
736
+ const n = a === "latest" ? "" : `@${a}`;
737
+ return `${s}/@arborium/arborium${n}/dist`;
584
738
  }
585
- async function I(e) {
739
+ async function A(e) {
586
740
  return p || m || (m = (async () => {
587
- q(e);
588
- const t = C(e), n = `${t}/arborium_host.js`, s = `${t}/arborium_host_bg.wasm`;
589
- console.debug(`[arborium] Loading host from ${n}`);
741
+ I(e);
742
+ const t = S(e), a = `${t}/arborium_host.js`, s = `${t}/arborium_host_bg.wasm`;
743
+ console.debug(`[arborium] Loading host from ${a}`);
590
744
  try {
591
- const a = await import(
745
+ const n = await import(
592
746
  /* @vite-ignore */
593
- n
747
+ a
594
748
  );
595
- return await a.default(s), p = {
596
- highlight: a.highlight,
597
- isLanguageAvailable: a.isLanguageAvailable
749
+ return await n.default(s), p = {
750
+ highlight: n.highlight,
751
+ isLanguageAvailable: n.isLanguageAvailable
598
752
  }, console.debug("[arborium] Host loaded successfully"), p;
599
- } catch (a) {
600
- return console.error("[arborium] Failed to load host:", a), null;
753
+ } catch (n) {
754
+ return console.error("[arborium] Failed to load host:", n), null;
601
755
  }
602
756
  })(), m);
603
757
  }
604
- async function S(e, t, n) {
605
- const s = T(n), a = await I(s);
606
- if (a)
758
+ async function G(e, t, a) {
759
+ const s = b(a), n = await A(s);
760
+ if (n)
607
761
  try {
608
- return a.highlight(e, t);
762
+ return n.highlight(e, t);
609
763
  } catch (r) {
610
764
  console.error("[arborium] Host highlight failed:", r);
611
765
  }
612
- return L(t);
766
+ return E(t);
613
767
  }
614
- async function A(e, t) {
615
- const n = T(t), s = await v(e, n);
768
+ async function z(e, t) {
769
+ const a = b(t), s = await j(e, a);
616
770
  if (!s) return null;
617
- const { module: a } = s;
771
+ const { module: n } = s;
618
772
  return {
619
773
  languageId: () => s.languageId,
620
774
  injectionLanguages: () => s.injectionLanguages,
621
- highlight: async (r) => S(e, r, t),
775
+ highlight: async (r) => G(e, r, t),
622
776
  // Public API returns UTF-16 offsets for JavaScript compatibility
623
777
  parse: (r) => s.parseUtf16(r),
624
778
  createSession: () => {
625
- const r = a.create_session();
779
+ const r = n.create_session();
626
780
  return {
627
- setText: (o) => a.set_text(r, o),
781
+ setText: (o) => n.set_text(r, o),
628
782
  // Session.parse() returns UTF-16 offsets for JavaScript compatibility
629
783
  parse: () => {
630
784
  try {
631
- const o = a.parse_utf16(r);
785
+ const o = n.parse_utf16(r);
632
786
  return {
633
787
  spans: o.spans || [],
634
788
  injections: o.injections || []
@@ -637,184 +791,40 @@ async function A(e, t) {
637
791
  return console.error("[arborium] Session parse error:", o), { spans: [], injections: [] };
638
792
  }
639
793
  },
640
- cancel: () => a.cancel(r),
641
- free: () => a.free_session(r)
794
+ cancel: () => n.cancel(r),
795
+ free: () => n.free_session(r)
642
796
  };
643
797
  },
644
798
  dispose: () => {
645
799
  }
646
800
  };
647
801
  }
648
- function T(e) {
802
+ function b(e) {
649
803
  return e ? { ...g, ...e } : { ...g };
650
804
  }
651
- function H(e) {
805
+ function N(e) {
652
806
  g = { ...g, ...e };
653
807
  }
654
- const G = [
655
- [/^#!.*\bpython[23]?\b/, "python"],
656
- [/^#!.*\bnode\b/, "javascript"],
657
- [/^#!.*\bdeno\b/, "typescript"],
658
- [/^#!.*\bbun\b/, "typescript"],
659
- [/^#!.*\bruby\b/, "ruby"],
660
- [/^#!.*\bperl\b/, "perl"],
661
- [/^#!.*\bphp\b/, "php"],
662
- [/^#!.*\bbash\b/, "bash"],
663
- [/^#!.*\bzsh\b/, "zsh"],
664
- [/^#!.*\bsh\b/, "bash"],
665
- [/^#!.*\blua\b/, "lua"],
666
- [/^#!.*\bawk\b/, "awk"]
667
- ], M = [
668
- // Rust - distinctive keywords
669
- [/\b(fn|impl|trait|pub\s+fn|let\s+mut|&mut|->)\b/, "rust"],
670
- // Go - distinctive keywords
671
- [/\b(func|package\s+\w+|import\s+\(|go\s+func|chan\s+\w+)\b/, "go"],
672
- // Python - distinctive patterns
673
- [/\b(def\s+\w+\s*\(|import\s+\w+|from\s+\w+\s+import|class\s+\w+:)\b/, "python"],
674
- // TypeScript - distinctive type annotations
675
- [/:\s*(string|number|boolean|void)\b|\binterface\s+\w+\s*\{/, "typescript"],
676
- // JavaScript - distinctive patterns (after TS check)
677
- [/\b(const|let|var)\s+\w+\s*=|function\s+\w+\s*\(|=>\s*\{/, "javascript"],
678
- // Ruby - distinctive keywords
679
- [/\b(def\s+\w+|end\b|do\s*\|.*\||puts\s+|require\s+['"])\b/, "ruby"],
680
- // Java - distinctive patterns
681
- [/\b(public\s+class|private\s+\w+|System\.out\.println)\b/, "java"],
682
- // C++ - distinctive patterns
683
- [/\b(#include\s*<|std::|template\s*<|nullptr|cout\s*<<)\b/, "cpp"],
684
- // C - distinctive patterns (after C++ check)
685
- [/\b(#include\s*[<"]|printf\s*\(|int\s+main\s*\(|void\s+\w+\s*\()\b/, "c"],
686
- // C# - distinctive patterns
687
- [/\b(namespace\s+\w+|using\s+System|public\s+static\s+void)\b/, "c-sharp"],
688
- // PHP - distinctive patterns
689
- [/<\?php|\$\w+\s*=/, "php"],
690
- // Swift - distinctive patterns
691
- [/\b(func\s+\w+|var\s+\w+:\s*\w+|let\s+\w+:\s*\w+|@objc)\b/, "swift"],
692
- // Kotlin - distinctive patterns
693
- [/\b(fun\s+\w+|val\s+\w+|var\s+\w+:|data\s+class)\b/, "kotlin"],
694
- // Scala - distinctive patterns
695
- [/\b(def\s+\w+|val\s+\w+|var\s+\w+|object\s+\w+|case\s+class)\b/, "scala"],
696
- // Haskell - distinctive patterns
697
- [/\b(module\s+\w+|import\s+qualified|data\s+\w+\s*=|::\s*\w+\s*->)\b/, "haskell"],
698
- // Elixir - distinctive patterns
699
- [/\b(defmodule\s+\w+|def\s+\w+|defp\s+\w+|\|>)\b/, "elixir"],
700
- // Lua - distinctive patterns
701
- [/\b(local\s+\w+\s*=|function\s+\w+\.\w+|require\s*\()\b/, "lua"],
702
- // SQL - distinctive patterns
703
- [/\b(SELECT\s+.*\s+FROM|INSERT\s+INTO|CREATE\s+TABLE|ALTER\s+TABLE)\b/i, "sql"],
704
- // Shell/Bash - distinctive patterns
705
- [/\b(if\s+\[\s*|then\b|fi\b|echo\s+["']|export\s+\w+=)\b/, "bash"],
706
- // YAML - distinctive patterns
707
- [/^\s*[\w-]+:\s*[\w\-"'[{]|^---\s*$/, "yaml"],
708
- // JSON - distinctive patterns
709
- [/^\s*\{[\s\S]*"[\w-]+":\s*/, "json"],
710
- // TOML - distinctive patterns
711
- [/^\s*\[[\w.-]+\]\s*$|^\s*\w+\s*=\s*["'\d\[]/, "toml"],
712
- // HTML - distinctive patterns
713
- [/<(!DOCTYPE|html|head|body|div|span|p|a\s)/i, "html"],
714
- // CSS - distinctive patterns
715
- [/^\s*[\w.#@][\w\s,#.:>+~-]*\{[^}]*\}|@media\s|@import\s/, "css"],
716
- // Markdown - distinctive patterns
717
- [/^#{1,6}\s+\w|^\s*[-*+]\s+\w|^\s*\d+\.\s+\w|```\w*\n/, "markdown"],
718
- // XML - distinctive patterns
719
- [/<\?xml|<[\w:-]+\s+xmlns/, "xml"],
720
- // Dockerfile
721
- [/^FROM\s+\w+|^RUN\s+|^COPY\s+|^ENTRYPOINT\s+/m, "dockerfile"],
722
- // Nginx config
723
- [/\b(server\s*\{|location\s+[\/~]|proxy_pass\s+)\b/, "nginx"],
724
- // Zig
725
- [/\b(pub\s+fn|const\s+\w+\s*=|@import\(|comptime)\b/, "zig"]
726
- ];
727
- function F(e) {
728
- const t = e.split(`
729
- `)[0];
730
- for (const [n, s] of G)
731
- if (n.test(t))
732
- return s;
733
- for (const [n, s] of M)
734
- if (n.test(e))
735
- return s;
736
- return null;
737
- }
738
- function z(e) {
739
- const t = e.match(/\blanguage-(\w+)\b/);
740
- if (t) return t[1];
741
- const n = e.match(/\blang-(\w+)\b/);
742
- if (n) return n[1];
743
- const s = /* @__PURE__ */ new Set([
744
- "rust",
745
- "javascript",
746
- "typescript",
747
- "python",
748
- "ruby",
749
- "go",
750
- "java",
751
- "c",
752
- "cpp",
753
- "csharp",
754
- "php",
755
- "swift",
756
- "kotlin",
757
- "scala",
758
- "haskell",
759
- "elixir",
760
- "lua",
761
- "sql",
762
- "bash",
763
- "shell",
764
- "yaml",
765
- "json",
766
- "toml",
767
- "html",
768
- "css",
769
- "xml",
770
- "markdown",
771
- "dockerfile",
772
- "nginx",
773
- "zig",
774
- "text",
775
- "plaintext",
776
- "console",
777
- "sh"
778
- ]);
779
- for (const a of e.split(/\s+/))
780
- if (s.has(a.toLowerCase()))
781
- return a.toLowerCase();
782
- return null;
808
+ async function O(e, t) {
809
+ const a = b(t);
810
+ return await k(a), d.has(e) || (l?.entries.some((s) => s.language === e) ?? !1);
783
811
  }
784
- function N(e) {
785
- const t = {
786
- js: "javascript",
787
- ts: "typescript",
788
- py: "python",
789
- rb: "ruby",
790
- rs: "rust",
791
- sh: "bash",
792
- shell: "bash",
793
- yml: "yaml",
794
- cs: "c-sharp",
795
- csharp: "c-sharp",
796
- "c++": "cpp",
797
- "c#": "c-sharp",
798
- "f#": "fsharp",
799
- dockerfile: "dockerfile",
800
- docker: "dockerfile",
801
- makefile: "make",
802
- plaintext: "text",
803
- plain: "text",
804
- txt: "text"
805
- }, n = e.toLowerCase();
806
- return t[n] || n;
812
+ async function B(e) {
813
+ const t = b(e);
814
+ return await k(t), l ? l.entries.map((a) => a.language) : Array.from(d);
807
815
  }
808
816
  export {
809
- $ as availableLanguages,
810
- F as detectLanguage,
811
- z as extractLanguageFromClass,
812
- T as getConfig,
813
- S as highlight,
814
- R as highlights,
815
- A as loadGrammar,
816
- N as normalizeLanguage,
817
- x as pluginVersion,
818
- H as setConfig
817
+ U as availableLanguages,
818
+ M as detectLanguage,
819
+ R as extractLanguageFromClass,
820
+ B as getAvailableLanguages,
821
+ b as getConfig,
822
+ G as highlight,
823
+ F as highlights,
824
+ O as isLanguageAvailable,
825
+ z as loadGrammar,
826
+ H as normalizeLanguage,
827
+ _ as pluginVersion,
828
+ N as setConfig
819
829
  };
820
830
  //# sourceMappingURL=arborium.js.map