@atme-lab/ui-kit 0.1.23 → 0.1.24
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/components/primitives/Term/Term.d.ts +1 -2
- package/dist/index.cjs10.js +1 -1
- package/dist/index.cjs11.js +1 -1
- package/dist/index.cjs12.js +1 -1
- package/dist/index.cjs13.js +1 -1
- package/dist/index.cjs14.js +1 -1
- package/dist/index.cjs15.js +1 -1
- package/dist/index.cjs16.js +1 -1
- package/dist/index.cjs18.js +1 -1
- package/dist/index.cjs19.js +1 -1
- package/dist/index.cjs20.js +1 -1
- package/dist/index.cjs21.js +1 -1
- package/dist/index.cjs22.js +1 -1
- package/dist/index.cjs23.js +1 -1
- package/dist/index.cjs24.js +1 -1
- package/dist/index.cjs24.js.map +1 -1
- package/dist/index.cjs25.js +1 -1
- package/dist/index.cjs27.js +1 -1
- package/dist/index.cjs28.js +1 -1
- package/dist/index.cjs29.js +1 -1
- package/dist/index.cjs30.js +1 -1
- package/dist/index.cjs31.js +1 -1
- package/dist/index.cjs387.js +1 -1
- package/dist/index.cjs41.js +1 -1
- package/dist/index.cjs413.js +1 -1
- package/dist/index.cjs414.js +1 -1
- package/dist/index.cjs415.js +1 -1
- package/dist/index.cjs416.js +1 -1
- package/dist/index.cjs42.js +1 -1
- package/dist/index.cjs430.js +1 -1
- package/dist/index.cjs432.js +1 -1
- package/dist/index.cjs435.js +1 -1
- package/dist/index.cjs44.js +1 -1
- package/dist/index.cjs445.js +6 -1
- package/dist/index.cjs445.js.map +1 -1
- package/dist/index.cjs446.js +6 -1
- package/dist/index.cjs446.js.map +1 -1
- package/dist/index.cjs447.js +6 -1
- package/dist/index.cjs447.js.map +1 -1
- package/dist/index.cjs448.js +6 -1
- package/dist/index.cjs448.js.map +1 -1
- package/dist/index.cjs449.js +1 -1
- package/dist/index.cjs449.js.map +1 -1
- package/dist/index.cjs45.js +1 -1
- package/dist/index.cjs450.js +1 -1
- package/dist/index.cjs450.js.map +1 -1
- package/dist/index.cjs451.js +1 -6
- package/dist/index.cjs451.js.map +1 -1
- package/dist/index.cjs452.js +1 -6
- package/dist/index.cjs452.js.map +1 -1
- package/dist/index.cjs453.js +1 -6
- package/dist/index.cjs453.js.map +1 -1
- package/dist/index.cjs454.js +1 -6
- package/dist/index.cjs454.js.map +1 -1
- package/dist/index.cjs46.js +1 -1
- package/dist/index.cjs46.js.map +1 -1
- package/dist/index.cjs47.js +1 -1
- package/dist/index.cjs48.js +1 -1
- package/dist/index.cjs49.js +1 -1
- package/dist/index.cjs50.js +1 -1
- package/dist/index.cjs51.js +1 -1
- package/dist/index.cjs51.js.map +1 -1
- package/dist/index.cjs52.js +1 -1
- package/dist/index.cjs53.js +1 -1
- package/dist/index.cjs54.js +1 -1
- package/dist/index.cjs54.js.map +1 -1
- package/dist/index.cjs55.js +1 -1
- package/dist/index.cjs56.js +1 -1
- package/dist/index.cjs56.js.map +1 -1
- package/dist/index.cjs57.js +1 -1
- package/dist/index.cjs57.js.map +1 -1
- package/dist/index.cjs58.js +1 -1
- package/dist/index.cjs59.js +1 -1
- package/dist/index.cjs59.js.map +1 -1
- package/dist/index.cjs60.js +1 -1
- package/dist/index.cjs61.js +1 -1
- package/dist/index.cjs61.js.map +1 -1
- package/dist/index.cjs62.js +1 -1
- package/dist/index.cjs62.js.map +1 -1
- package/dist/index.cjs63.js +1 -1
- package/dist/index.cjs64.js +1 -1
- package/dist/index.cjs64.js.map +1 -1
- package/dist/index.cjs65.js +1 -1
- package/dist/index.cjs65.js.map +1 -1
- package/dist/index.cjs66.js +1 -1
- package/dist/index.cjs66.js.map +1 -1
- package/dist/index.cjs67.js +1 -1
- package/dist/index.cjs67.js.map +1 -1
- package/dist/index.cjs69.js +1 -1
- package/dist/index.cjs70.js +1 -1
- package/dist/index.cjs71.js +1 -1
- package/dist/index.cjs72.js +1 -1
- package/dist/index.cjs74.js +1 -1
- package/dist/index.cjs75.js +1 -1
- package/dist/index.cjs76.js +1 -1
- package/dist/index.cjs76.js.map +1 -1
- package/dist/index.cjs77.js +1 -1
- package/dist/index.cjs77.js.map +1 -1
- package/dist/index.cjs80.js +1 -1
- package/dist/index.cjs80.js.map +1 -1
- package/dist/index.cjs81.js +1 -1
- package/dist/index.cjs81.js.map +1 -1
- package/dist/index.cjs82.js +1 -2
- package/dist/index.cjs82.js.map +1 -1
- package/dist/index.cjs83.js +2 -1
- package/dist/index.cjs83.js.map +1 -1
- package/dist/index.cjs84.js +1 -1
- package/dist/index.cjs84.js.map +1 -1
- package/dist/index.cjs85.js +1 -1
- package/dist/index.cjs85.js.map +1 -1
- package/dist/index.cjs86.js +1 -1
- package/dist/index.cjs86.js.map +1 -1
- package/dist/index.cjs9.js +1 -1
- package/dist/index.esm10.js +2 -2
- package/dist/index.esm11.js +1 -1
- package/dist/index.esm12.js +3 -3
- package/dist/index.esm13.js +1 -1
- package/dist/index.esm14.js +1 -1
- package/dist/index.esm15.js +1 -1
- package/dist/index.esm16.js +1 -1
- package/dist/index.esm18.js +1 -1
- package/dist/index.esm19.js +1 -1
- package/dist/index.esm20.js +1 -1
- package/dist/index.esm21.js +2 -2
- package/dist/index.esm22.js +2 -2
- package/dist/index.esm23.js +1 -1
- package/dist/index.esm24.js +8 -69
- package/dist/index.esm24.js.map +1 -1
- package/dist/index.esm25.js +2 -2
- package/dist/index.esm27.js +1 -1
- package/dist/index.esm28.js +1 -1
- package/dist/index.esm29.js +2 -2
- package/dist/index.esm30.js +1 -1
- package/dist/index.esm31.js +3 -3
- package/dist/index.esm387.js +1 -1
- package/dist/index.esm41.js +1 -1
- package/dist/index.esm413.js +1 -1
- package/dist/index.esm414.js +1 -1
- package/dist/index.esm415.js +1 -1
- package/dist/index.esm416.js +1 -1
- package/dist/index.esm42.js +1 -1
- package/dist/index.esm430.js +1 -1
- package/dist/index.esm432.js +6 -6
- package/dist/index.esm435.js +1 -1
- package/dist/index.esm44.js +32 -40
- package/dist/index.esm44.js.map +1 -1
- package/dist/index.esm445.js +21 -6
- package/dist/index.esm445.js.map +1 -1
- package/dist/index.esm446.js +9 -10
- package/dist/index.esm446.js.map +1 -1
- package/dist/index.esm447.js +38 -7
- package/dist/index.esm447.js.map +1 -1
- package/dist/index.esm448.js +18 -4
- package/dist/index.esm448.js.map +1 -1
- package/dist/index.esm449.js +5 -84
- package/dist/index.esm449.js.map +1 -1
- package/dist/index.esm45.js +11 -47
- package/dist/index.esm450.js +9 -37
- package/dist/index.esm450.js.map +1 -1
- package/dist/index.esm451.js +7 -21
- package/dist/index.esm451.js.map +1 -1
- package/dist/index.esm452.js +4 -9
- package/dist/index.esm452.js.map +1 -1
- package/dist/index.esm453.js +85 -38
- package/dist/index.esm453.js.map +1 -1
- package/dist/index.esm454.js +38 -18
- package/dist/index.esm454.js.map +1 -1
- package/dist/index.esm46.js +30 -11
- package/dist/index.esm46.js.map +1 -1
- package/dist/index.esm47.js +27 -40
- package/dist/index.esm47.js.map +1 -1
- package/dist/index.esm48.js +5 -4
- package/dist/index.esm48.js.map +1 -1
- package/dist/index.esm49.js +2 -6
- package/dist/index.esm49.js.map +1 -1
- package/dist/index.esm50.js +2 -9
- package/dist/index.esm50.js.map +1 -1
- package/dist/index.esm51.js +65 -28
- package/dist/index.esm51.js.map +1 -1
- package/dist/index.esm52.js +29 -2
- package/dist/index.esm52.js.map +1 -1
- package/dist/index.esm53.js +9 -2
- package/dist/index.esm53.js.map +1 -1
- package/dist/index.esm54.js +5 -88
- package/dist/index.esm54.js.map +1 -1
- package/dist/index.esm55.js +47 -35
- package/dist/index.esm55.js.map +1 -1
- package/dist/index.esm56.js +11 -127
- package/dist/index.esm56.js.map +1 -1
- package/dist/index.esm57.js +88 -29
- package/dist/index.esm57.js.map +1 -1
- package/dist/index.esm58.js +34 -64
- package/dist/index.esm58.js.map +1 -1
- package/dist/index.esm59.js +127 -41
- package/dist/index.esm59.js.map +1 -1
- package/dist/index.esm60.js +8 -10
- package/dist/index.esm60.js.map +1 -1
- package/dist/index.esm61.js +28 -17
- package/dist/index.esm61.js.map +1 -1
- package/dist/index.esm62.js +41 -16
- package/dist/index.esm62.js.map +1 -1
- package/dist/index.esm63.js +6 -15
- package/dist/index.esm63.js.map +1 -1
- package/dist/index.esm64.js +8 -96
- package/dist/index.esm64.js.map +1 -1
- package/dist/index.esm65.js +7 -7
- package/dist/index.esm65.js.map +1 -1
- package/dist/index.esm66.js +16 -9
- package/dist/index.esm66.js.map +1 -1
- package/dist/index.esm67.js +97 -7
- package/dist/index.esm67.js.map +1 -1
- package/dist/index.esm69.js +42 -39
- package/dist/index.esm69.js.map +1 -1
- package/dist/index.esm70.js +40 -32
- package/dist/index.esm70.js.map +1 -1
- package/dist/index.esm71.js +36 -8
- package/dist/index.esm71.js.map +1 -1
- package/dist/index.esm72.js +39 -32
- package/dist/index.esm72.js.map +1 -1
- package/dist/index.esm74.js +6 -36
- package/dist/index.esm74.js.map +1 -1
- package/dist/index.esm75.js +8 -10
- package/dist/index.esm75.js.map +1 -1
- package/dist/index.esm76.js +17 -30
- package/dist/index.esm76.js.map +1 -1
- package/dist/index.esm77.js +16 -9
- package/dist/index.esm77.js.map +1 -1
- package/dist/index.esm80.js +4 -55
- package/dist/index.esm80.js.map +1 -1
- package/dist/index.esm81.js +55 -257
- package/dist/index.esm81.js.map +1 -1
- package/dist/index.esm82.js +208 -1637
- package/dist/index.esm82.js.map +1 -1
- package/dist/index.esm83.js +1685 -1413
- package/dist/index.esm83.js.map +1 -1
- package/dist/index.esm84.js +1286 -260
- package/dist/index.esm84.js.map +1 -1
- package/dist/index.esm85.js +387 -5
- package/dist/index.esm85.js.map +1 -1
- package/dist/index.esm86.js +5 -3
- package/dist/index.esm86.js.map +1 -1
- package/dist/index.esm9.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/ui-kit.css +1 -1
- package/package.json +1 -1
package/dist/index.esm82.js
CHANGED
|
@@ -1,1690 +1,261 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { ShikiError as k } from "./index.esm85.js";
|
|
6
|
-
import { FontStyle as L, INITIAL as U, EncodedTokenMetadata as re, Registry as _e, Theme as Le } from "./index.esm89.js";
|
|
7
|
-
import { toHtml as ve } from "./index.esm90.js";
|
|
8
|
-
function D(n, t) {
|
|
9
|
-
const e = typeof n == "string" ? {} : { ...n.colorReplacements }, s = typeof n == "string" ? n : n.name;
|
|
10
|
-
for (const [r, o] of Object.entries((t == null ? void 0 : t.colorReplacements) || {}))
|
|
11
|
-
typeof o == "string" ? e[r] = o : r === s && Object.assign(e, o);
|
|
12
|
-
return e;
|
|
13
|
-
}
|
|
14
|
-
function E(n, t) {
|
|
15
|
-
return n && ((t == null ? void 0 : t[n == null ? void 0 : n.toLowerCase()]) || n);
|
|
16
|
-
}
|
|
17
|
-
function Ce(n) {
|
|
18
|
-
return Array.isArray(n) ? n : [n];
|
|
19
|
-
}
|
|
20
|
-
async function he(n) {
|
|
21
|
-
return Promise.resolve(typeof n == "function" ? n() : n).then((t) => t.default || t);
|
|
22
|
-
}
|
|
23
|
-
function Q(n) {
|
|
24
|
-
return !n || ["plaintext", "txt", "text", "plain"].includes(n);
|
|
25
|
-
}
|
|
26
|
-
function ue(n) {
|
|
27
|
-
return n === "ansi" || Q(n);
|
|
28
|
-
}
|
|
29
|
-
function X(n) {
|
|
30
|
-
return n === "none";
|
|
31
|
-
}
|
|
32
|
-
function ge(n) {
|
|
33
|
-
return X(n);
|
|
34
|
-
}
|
|
35
|
-
function de(n, t) {
|
|
36
|
-
var s;
|
|
37
|
-
if (!t)
|
|
38
|
-
return n;
|
|
39
|
-
n.properties || (n.properties = {}), (s = n.properties).class || (s.class = []), typeof n.properties.class == "string" && (n.properties.class = n.properties.class.split(/\s+/g)), Array.isArray(n.properties.class) || (n.properties.class = []);
|
|
40
|
-
const e = Array.isArray(t) ? t : t.split(/\s+/g);
|
|
41
|
-
for (const r of e)
|
|
42
|
-
r && !n.properties.class.includes(r) && n.properties.class.push(r);
|
|
43
|
-
return n;
|
|
44
|
-
}
|
|
45
|
-
function V(n, t = !1) {
|
|
46
|
-
var o;
|
|
47
|
-
if (n.length === 0)
|
|
48
|
-
return [["", 0]];
|
|
49
|
-
const e = n.split(/(\r?\n)/g);
|
|
50
|
-
let s = 0;
|
|
51
|
-
const r = [];
|
|
52
|
-
for (let a = 0; a < e.length; a += 2) {
|
|
53
|
-
const i = t ? e[a] + (e[a + 1] || "") : e[a];
|
|
54
|
-
r.push([i, s]), s += e[a].length, s += ((o = e[a + 1]) == null ? void 0 : o.length) || 0;
|
|
55
|
-
}
|
|
56
|
-
return r;
|
|
57
|
-
}
|
|
58
|
-
function xe(n) {
|
|
59
|
-
const t = V(n, !0).map(([r]) => r);
|
|
60
|
-
function e(r) {
|
|
61
|
-
if (r === n.length)
|
|
62
|
-
return {
|
|
63
|
-
line: t.length - 1,
|
|
64
|
-
character: t[t.length - 1].length
|
|
65
|
-
};
|
|
66
|
-
let o = r, a = 0;
|
|
67
|
-
for (const i of t) {
|
|
68
|
-
if (o < i.length)
|
|
69
|
-
break;
|
|
70
|
-
o -= i.length, a++;
|
|
71
|
-
}
|
|
72
|
-
return { line: a, character: o };
|
|
73
|
-
}
|
|
74
|
-
function s(r, o) {
|
|
75
|
-
let a = 0;
|
|
76
|
-
for (let i = 0; i < r; i++)
|
|
77
|
-
a += t[i].length;
|
|
78
|
-
return a += o, a;
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
lines: t,
|
|
82
|
-
indexToPos: e,
|
|
83
|
-
posToIndex: s
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
function yt(n, t, e) {
|
|
87
|
-
const s = /* @__PURE__ */ new Set();
|
|
88
|
-
for (const o of n.matchAll(/:?lang=["']([^"']+)["']/g)) {
|
|
89
|
-
const a = o[1].toLowerCase().trim();
|
|
90
|
-
a && s.add(a);
|
|
91
|
-
}
|
|
92
|
-
for (const o of n.matchAll(/(?:```|~~~)([\w-]+)/g)) {
|
|
93
|
-
const a = o[1].toLowerCase().trim();
|
|
94
|
-
a && s.add(a);
|
|
95
|
-
}
|
|
96
|
-
for (const o of n.matchAll(/\\begin\{([\w-]+)\}/g)) {
|
|
97
|
-
const a = o[1].toLowerCase().trim();
|
|
98
|
-
a && s.add(a);
|
|
99
|
-
}
|
|
100
|
-
for (const o of n.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)) {
|
|
101
|
-
const a = o[1].toLowerCase().trim(), i = a.includes("/") ? a.split("/").pop() : a;
|
|
102
|
-
i && s.add(i);
|
|
103
|
-
}
|
|
104
|
-
if (!e)
|
|
105
|
-
return Array.from(s);
|
|
106
|
-
const r = e.getBundledLanguages();
|
|
107
|
-
return Array.from(s).filter((o) => o && r[o]);
|
|
108
|
-
}
|
|
109
|
-
const Z = "light-dark()", $e = ["color", "background-color"];
|
|
110
|
-
function Ne(n, t) {
|
|
111
|
-
let e = 0;
|
|
112
|
-
const s = [];
|
|
113
|
-
for (const r of t)
|
|
114
|
-
r > e && s.push({
|
|
115
|
-
...n,
|
|
116
|
-
content: n.content.slice(e, r),
|
|
117
|
-
offset: n.offset + e
|
|
118
|
-
}), e = r;
|
|
119
|
-
return e < n.content.length && s.push({
|
|
120
|
-
...n,
|
|
121
|
-
content: n.content.slice(e),
|
|
122
|
-
offset: n.offset + e
|
|
123
|
-
}), s;
|
|
124
|
-
}
|
|
125
|
-
function Ie(n, t) {
|
|
126
|
-
const e = Array.from(t instanceof Set ? t : new Set(t)).sort((s, r) => s - r);
|
|
127
|
-
return e.length ? n.map((s) => s.flatMap((r) => {
|
|
128
|
-
const o = e.filter((a) => r.offset < a && a < r.offset + r.content.length).map((a) => a - r.offset).sort((a, i) => a - i);
|
|
129
|
-
return o.length ? Ne(r, o) : r;
|
|
130
|
-
})) : n;
|
|
131
|
-
}
|
|
132
|
-
function Ee(n, t, e, s, r = "css-vars") {
|
|
133
|
-
const o = {
|
|
134
|
-
content: n.content,
|
|
135
|
-
explanation: n.explanation,
|
|
136
|
-
offset: n.offset
|
|
137
|
-
}, a = t.map((u) => W(n.variants[u])), i = new Set(a.flatMap((u) => Object.keys(u))), l = {}, c = (u, f) => {
|
|
138
|
-
const h = f === "color" ? "" : f === "background-color" ? "-bg" : `-${f}`;
|
|
139
|
-
return e + t[u] + (f === "color" ? "" : h);
|
|
140
|
-
};
|
|
141
|
-
return a.forEach((u, f) => {
|
|
142
|
-
for (const h of i) {
|
|
143
|
-
const d = u[h] || "inherit";
|
|
144
|
-
if (f === 0 && s && $e.includes(h))
|
|
145
|
-
if (s === Z && a.length > 1) {
|
|
146
|
-
const m = t.findIndex((b) => b === "light"), y = t.findIndex((b) => b === "dark");
|
|
147
|
-
if (m === -1 || y === -1)
|
|
148
|
-
throw new k('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');
|
|
149
|
-
const T = a[m][h] || "inherit", p = a[y][h] || "inherit";
|
|
150
|
-
l[h] = `light-dark(${T}, ${p})`, r === "css-vars" && (l[c(f, h)] = d);
|
|
151
|
-
} else
|
|
152
|
-
l[h] = d;
|
|
153
|
-
else
|
|
154
|
-
r === "css-vars" && (l[c(f, h)] = d);
|
|
155
|
-
}
|
|
156
|
-
}), o.htmlStyle = l, o;
|
|
157
|
-
}
|
|
158
|
-
function W(n) {
|
|
159
|
-
const t = {};
|
|
160
|
-
if (n.color && (t.color = n.color), n.bgColor && (t["background-color"] = n.bgColor), n.fontStyle) {
|
|
161
|
-
n.fontStyle & L.Italic && (t["font-style"] = "italic"), n.fontStyle & L.Bold && (t["font-weight"] = "bold");
|
|
162
|
-
const e = [];
|
|
163
|
-
n.fontStyle & L.Underline && e.push("underline"), n.fontStyle & L.Strikethrough && e.push("line-through"), e.length && (t["text-decoration"] = e.join(" "));
|
|
2
|
+
class B extends Error {
|
|
3
|
+
constructor(t) {
|
|
4
|
+
super(t), this.name = "ShikiError";
|
|
164
5
|
}
|
|
165
|
-
return t;
|
|
166
6
|
}
|
|
167
|
-
function
|
|
168
|
-
return
|
|
7
|
+
function H() {
|
|
8
|
+
return 2147483648;
|
|
169
9
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
me.set(n, t);
|
|
10
|
+
function v() {
|
|
11
|
+
return typeof performance < "u" ? performance.now() : Date.now();
|
|
173
12
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
* Theme to Stack mapping
|
|
181
|
-
*/
|
|
182
|
-
v(this, "_stacks", {});
|
|
183
|
-
v(this, "lang");
|
|
184
|
-
if (t.length === 2) {
|
|
185
|
-
const [e, s] = t;
|
|
186
|
-
this.lang = s, this._stacks = e;
|
|
187
|
-
} else {
|
|
188
|
-
const [e, s, r] = t;
|
|
189
|
-
this.lang = s, this._stacks = { [r]: e };
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
get themes() {
|
|
193
|
-
return Object.keys(this._stacks);
|
|
194
|
-
}
|
|
195
|
-
get theme() {
|
|
196
|
-
return this.themes[0];
|
|
197
|
-
}
|
|
198
|
-
get _stack() {
|
|
199
|
-
return this._stacks[this.theme];
|
|
13
|
+
const I = (r, t) => r + (t - r % t) % t;
|
|
14
|
+
async function W(r) {
|
|
15
|
+
let t, n;
|
|
16
|
+
const e = {};
|
|
17
|
+
function l(f) {
|
|
18
|
+
n = f, e.HEAPU8 = new Uint8Array(f), e.HEAPU32 = new Uint32Array(f);
|
|
200
19
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
*/
|
|
204
|
-
static initial(t, e) {
|
|
205
|
-
return new F(
|
|
206
|
-
Object.fromEntries(Ce(e).map((s) => [s, U])),
|
|
207
|
-
t
|
|
208
|
-
);
|
|
20
|
+
function h(f, c, S) {
|
|
21
|
+
e.HEAPU8.copyWithin(f, c, c + S);
|
|
209
22
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return this._stacks[t];
|
|
216
|
-
}
|
|
217
|
-
getScopes(t = this.theme) {
|
|
218
|
-
return Ae(this._stacks[t]);
|
|
219
|
-
}
|
|
220
|
-
toJSON() {
|
|
221
|
-
return {
|
|
222
|
-
lang: this.lang,
|
|
223
|
-
theme: this.theme,
|
|
224
|
-
themes: this.themes,
|
|
225
|
-
scopes: this.getScopes()
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
function Ae(n) {
|
|
230
|
-
const t = [], e = /* @__PURE__ */ new Set();
|
|
231
|
-
function s(r) {
|
|
232
|
-
var a;
|
|
233
|
-
if (e.has(r))
|
|
234
|
-
return;
|
|
235
|
-
e.add(r);
|
|
236
|
-
const o = (a = r == null ? void 0 : r.nameScopesList) == null ? void 0 : a.scopeName;
|
|
237
|
-
o && t.push(o), r.parent && s(r.parent);
|
|
23
|
+
function o(f) {
|
|
24
|
+
try {
|
|
25
|
+
return t.grow(f - n.byteLength + 65535 >>> 16), l(t.buffer), 1;
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
238
28
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (typeof a == "number") {
|
|
252
|
-
if (a < 0 || a > e.source.length)
|
|
253
|
-
throw new k(`Invalid decoration offset: ${a}. Code length: ${e.source.length}`);
|
|
254
|
-
return {
|
|
255
|
-
...r.indexToPos(a),
|
|
256
|
-
offset: a
|
|
257
|
-
};
|
|
258
|
-
} else {
|
|
259
|
-
const i = r.lines[a.line];
|
|
260
|
-
if (i === void 0)
|
|
261
|
-
throw new k(`Invalid decoration position ${JSON.stringify(a)}. Lines length: ${r.lines.length}`);
|
|
262
|
-
let l = a.character;
|
|
263
|
-
if (l < 0 && (l = i.length + l), l < 0 || l > i.length)
|
|
264
|
-
throw new k(`Invalid decoration position ${JSON.stringify(a)}. Line ${a.line} length: ${i.length}`);
|
|
265
|
-
return {
|
|
266
|
-
...a,
|
|
267
|
-
character: l,
|
|
268
|
-
offset: r.posToIndex(a.line, l)
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
const r = xe(e.source), o = (e.options.decorations || []).map((a) => ({
|
|
273
|
-
...a,
|
|
274
|
-
start: s(a.start),
|
|
275
|
-
end: s(a.end)
|
|
276
|
-
}));
|
|
277
|
-
Oe(o), n.set(e.meta, {
|
|
278
|
-
decorations: o,
|
|
279
|
-
converter: r,
|
|
280
|
-
source: e.source
|
|
281
|
-
});
|
|
29
|
+
function s(f) {
|
|
30
|
+
const c = e.HEAPU8.length;
|
|
31
|
+
f = f >>> 0;
|
|
32
|
+
const S = H();
|
|
33
|
+
if (f > S)
|
|
34
|
+
return !1;
|
|
35
|
+
for (let A = 1; A <= 4; A *= 2) {
|
|
36
|
+
let m = c * (1 + 0.2 / A);
|
|
37
|
+
m = Math.min(m, f + 100663296);
|
|
38
|
+
const _ = Math.min(S, I(Math.max(f, m), 65536));
|
|
39
|
+
if (o(_))
|
|
40
|
+
return !0;
|
|
282
41
|
}
|
|
283
|
-
return
|
|
42
|
+
return !1;
|
|
284
43
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const s = t(this), r = Array.from(e.children).filter((f) => f.type === "element" && f.tagName === "span");
|
|
299
|
-
if (r.length !== s.converter.lines.length)
|
|
300
|
-
throw new k(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${s.converter.lines.length}). Failed to apply decorations.`);
|
|
301
|
-
function o(f, h, d, m) {
|
|
302
|
-
const y = r[f];
|
|
303
|
-
let T = "", p = -1, b = -1;
|
|
304
|
-
if (h === 0 && (p = 0), d === 0 && (b = 0), d === Number.POSITIVE_INFINITY && (b = y.children.length), p === -1 || b === -1)
|
|
305
|
-
for (let S = 0; S < y.children.length; S++)
|
|
306
|
-
T += pe(y.children[S]), p === -1 && T.length === h && (p = S + 1), b === -1 && T.length === d && (b = S + 1);
|
|
307
|
-
if (p === -1)
|
|
308
|
-
throw new k(`Failed to find start index for decoration ${JSON.stringify(m.start)}`);
|
|
309
|
-
if (b === -1)
|
|
310
|
-
throw new k(`Failed to find end index for decoration ${JSON.stringify(m.end)}`);
|
|
311
|
-
const g = y.children.slice(p, b);
|
|
312
|
-
if (!m.alwaysWrap && g.length === y.children.length)
|
|
313
|
-
i(y, m, "line");
|
|
314
|
-
else if (!m.alwaysWrap && g.length === 1 && g[0].type === "element")
|
|
315
|
-
i(g[0], m, "token");
|
|
316
|
-
else {
|
|
317
|
-
const S = {
|
|
318
|
-
type: "element",
|
|
319
|
-
tagName: "span",
|
|
320
|
-
properties: {},
|
|
321
|
-
children: g
|
|
322
|
-
};
|
|
323
|
-
i(S, m, "wrapper"), y.children.splice(p, g.length, S);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
function a(f, h) {
|
|
327
|
-
r[f] = i(r[f], h, "line");
|
|
328
|
-
}
|
|
329
|
-
function i(f, h, d) {
|
|
330
|
-
var T;
|
|
331
|
-
const m = h.properties || {}, y = h.transform || ((p) => p);
|
|
332
|
-
return f.tagName = h.tagName || "span", f.properties = {
|
|
333
|
-
...f.properties,
|
|
334
|
-
...m,
|
|
335
|
-
class: f.properties.class
|
|
336
|
-
}, (T = h.properties) != null && T.class && de(f, h.properties.class), f = y(f, d) || f, f;
|
|
44
|
+
const i = typeof TextDecoder < "u" ? new TextDecoder("utf8") : void 0;
|
|
45
|
+
function a(f, c, S = 1024) {
|
|
46
|
+
const A = c + S;
|
|
47
|
+
let m = c;
|
|
48
|
+
for (; f[m] && !(m >= A); ) ++m;
|
|
49
|
+
if (m - c > 16 && f.buffer && i)
|
|
50
|
+
return i.decode(f.subarray(c, m));
|
|
51
|
+
let _ = "";
|
|
52
|
+
for (; c < m; ) {
|
|
53
|
+
let p = f[c++];
|
|
54
|
+
if (!(p & 128)) {
|
|
55
|
+
_ += String.fromCharCode(p);
|
|
56
|
+
continue;
|
|
337
57
|
}
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
o(h.line, h.character, d.character, f);
|
|
343
|
-
else if (h.line < d.line) {
|
|
344
|
-
o(h.line, h.character, Number.POSITIVE_INFINITY, f);
|
|
345
|
-
for (let m = h.line + 1; m < d.line; m++)
|
|
346
|
-
l.unshift(() => a(m, f));
|
|
347
|
-
o(d.line, 0, d.character, f);
|
|
348
|
-
}
|
|
58
|
+
const b = f[c++] & 63;
|
|
59
|
+
if ((p & 224) === 192) {
|
|
60
|
+
_ += String.fromCharCode((p & 31) << 6 | b);
|
|
61
|
+
continue;
|
|
349
62
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
const e = n[t];
|
|
357
|
-
if (e.start.offset > e.end.offset)
|
|
358
|
-
throw new k(`Invalid decoration range: ${JSON.stringify(e.start)} - ${JSON.stringify(e.end)}`);
|
|
359
|
-
for (let s = t + 1; s < n.length; s++) {
|
|
360
|
-
const r = n[s], o = e.start.offset <= r.start.offset && r.start.offset < e.end.offset, a = e.start.offset < r.end.offset && r.end.offset <= e.end.offset, i = r.start.offset <= e.start.offset && e.start.offset < r.end.offset, l = r.start.offset < e.end.offset && e.end.offset <= r.end.offset;
|
|
361
|
-
if (o || a || i || l) {
|
|
362
|
-
if (o && a || i && l || i && e.start.offset === e.end.offset || a && r.start.offset === r.end.offset)
|
|
363
|
-
continue;
|
|
364
|
-
throw new k(`Decorations ${JSON.stringify(e.start)} and ${JSON.stringify(r.start)} intersect.`);
|
|
63
|
+
const C = f[c++] & 63;
|
|
64
|
+
if ((p & 240) === 224 ? p = (p & 15) << 12 | b << 6 | C : p = (p & 7) << 18 | b << 12 | C << 6 | f[c++] & 63, p < 65536)
|
|
65
|
+
_ += String.fromCharCode(p);
|
|
66
|
+
else {
|
|
67
|
+
const E = p - 65536;
|
|
68
|
+
_ += String.fromCharCode(55296 | E >> 10, 56320 | E & 1023);
|
|
365
69
|
}
|
|
366
70
|
}
|
|
71
|
+
return _;
|
|
367
72
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
return n.type === "text" ? n.value : n.type === "element" ? n.children.map(pe).join("") : "";
|
|
371
|
-
}
|
|
372
|
-
const je = [
|
|
373
|
-
/* @__PURE__ */ Me()
|
|
374
|
-
];
|
|
375
|
-
function H(n) {
|
|
376
|
-
const t = Fe(n.transformers || []);
|
|
377
|
-
return [
|
|
378
|
-
...t.pre,
|
|
379
|
-
...t.normal,
|
|
380
|
-
...t.post,
|
|
381
|
-
...je
|
|
382
|
-
];
|
|
383
|
-
}
|
|
384
|
-
function Fe(n) {
|
|
385
|
-
const t = [], e = [], s = [];
|
|
386
|
-
for (const r of n)
|
|
387
|
-
switch (r.enforce) {
|
|
388
|
-
case "pre":
|
|
389
|
-
t.push(r);
|
|
390
|
-
break;
|
|
391
|
-
case "post":
|
|
392
|
-
e.push(r);
|
|
393
|
-
break;
|
|
394
|
-
default:
|
|
395
|
-
s.push(r);
|
|
396
|
-
}
|
|
397
|
-
return { pre: t, post: e, normal: s };
|
|
398
|
-
}
|
|
399
|
-
var A = [
|
|
400
|
-
"black",
|
|
401
|
-
"red",
|
|
402
|
-
"green",
|
|
403
|
-
"yellow",
|
|
404
|
-
"blue",
|
|
405
|
-
"magenta",
|
|
406
|
-
"cyan",
|
|
407
|
-
"white",
|
|
408
|
-
"brightBlack",
|
|
409
|
-
"brightRed",
|
|
410
|
-
"brightGreen",
|
|
411
|
-
"brightYellow",
|
|
412
|
-
"brightBlue",
|
|
413
|
-
"brightMagenta",
|
|
414
|
-
"brightCyan",
|
|
415
|
-
"brightWhite"
|
|
416
|
-
], K = {
|
|
417
|
-
1: "bold",
|
|
418
|
-
2: "dim",
|
|
419
|
-
3: "italic",
|
|
420
|
-
4: "underline",
|
|
421
|
-
7: "reverse",
|
|
422
|
-
8: "hidden",
|
|
423
|
-
9: "strikethrough"
|
|
424
|
-
};
|
|
425
|
-
function Ge(n, t) {
|
|
426
|
-
const e = n.indexOf("\x1B", t);
|
|
427
|
-
if (e !== -1 && n[e + 1] === "[") {
|
|
428
|
-
const s = n.indexOf("m", e);
|
|
429
|
-
if (s !== -1)
|
|
430
|
-
return {
|
|
431
|
-
sequence: n.substring(e + 2, s).split(";"),
|
|
432
|
-
startPosition: e,
|
|
433
|
-
position: s + 1
|
|
434
|
-
};
|
|
73
|
+
function w(f, c) {
|
|
74
|
+
return f ? a(e.HEAPU8, f, c) : "";
|
|
435
75
|
}
|
|
436
|
-
|
|
437
|
-
|
|
76
|
+
const u = {
|
|
77
|
+
emscripten_get_now: v,
|
|
78
|
+
emscripten_memcpy_big: h,
|
|
79
|
+
emscripten_resize_heap: s,
|
|
80
|
+
fd_write: () => 0
|
|
438
81
|
};
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
type: "rgb",
|
|
446
|
-
rgb: e
|
|
447
|
-
};
|
|
448
|
-
} else if (t === "5") {
|
|
449
|
-
const e = n.shift();
|
|
450
|
-
if (e)
|
|
451
|
-
return { type: "table", index: Number(e) };
|
|
82
|
+
async function y() {
|
|
83
|
+
const c = await r({
|
|
84
|
+
env: u,
|
|
85
|
+
wasi_snapshot_preview1: u
|
|
86
|
+
});
|
|
87
|
+
t = c.memory, l(t.buffer), Object.assign(e, c), e.UTF8ToString = w;
|
|
452
88
|
}
|
|
89
|
+
return await y(), e;
|
|
453
90
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
if (!e)
|
|
459
|
-
continue;
|
|
460
|
-
const s = Number.parseInt(e);
|
|
461
|
-
if (!Number.isNaN(s))
|
|
462
|
-
if (s === 0)
|
|
463
|
-
t.push({ type: "resetAll" });
|
|
464
|
-
else if (s <= 9)
|
|
465
|
-
K[s] && t.push({
|
|
466
|
-
type: "setDecoration",
|
|
467
|
-
value: K[s]
|
|
468
|
-
});
|
|
469
|
-
else if (s <= 29) {
|
|
470
|
-
const r = K[s - 20];
|
|
471
|
-
r && (t.push({
|
|
472
|
-
type: "resetDecoration",
|
|
473
|
-
value: r
|
|
474
|
-
}), r === "dim" && t.push({
|
|
475
|
-
type: "resetDecoration",
|
|
476
|
-
value: "bold"
|
|
477
|
-
}));
|
|
478
|
-
} else if (s <= 37)
|
|
479
|
-
t.push({
|
|
480
|
-
type: "setForegroundColor",
|
|
481
|
-
value: { type: "named", name: A[s - 30] }
|
|
482
|
-
});
|
|
483
|
-
else if (s === 38) {
|
|
484
|
-
const r = oe(n);
|
|
485
|
-
r && t.push({
|
|
486
|
-
type: "setForegroundColor",
|
|
487
|
-
value: r
|
|
488
|
-
});
|
|
489
|
-
} else if (s === 39)
|
|
490
|
-
t.push({
|
|
491
|
-
type: "resetForegroundColor"
|
|
492
|
-
});
|
|
493
|
-
else if (s <= 47)
|
|
494
|
-
t.push({
|
|
495
|
-
type: "setBackgroundColor",
|
|
496
|
-
value: { type: "named", name: A[s - 40] }
|
|
497
|
-
});
|
|
498
|
-
else if (s === 48) {
|
|
499
|
-
const r = oe(n);
|
|
500
|
-
r && t.push({
|
|
501
|
-
type: "setBackgroundColor",
|
|
502
|
-
value: r
|
|
503
|
-
});
|
|
504
|
-
} else s === 49 ? t.push({
|
|
505
|
-
type: "resetBackgroundColor"
|
|
506
|
-
}) : s === 53 ? t.push({
|
|
507
|
-
type: "setDecoration",
|
|
508
|
-
value: "overline"
|
|
509
|
-
}) : s === 55 ? t.push({
|
|
510
|
-
type: "resetDecoration",
|
|
511
|
-
value: "overline"
|
|
512
|
-
}) : s >= 90 && s <= 97 ? t.push({
|
|
513
|
-
type: "setForegroundColor",
|
|
514
|
-
value: { type: "named", name: A[s - 90 + 8] }
|
|
515
|
-
}) : s >= 100 && s <= 107 && t.push({
|
|
516
|
-
type: "setBackgroundColor",
|
|
517
|
-
value: { type: "named", name: A[s - 100 + 8] }
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
return t;
|
|
91
|
+
var x = Object.defineProperty, V = (r, t, n) => t in r ? x(r, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[t] = n, g = (r, t, n) => V(r, typeof t != "symbol" ? t + "" : t, n);
|
|
92
|
+
let d = null;
|
|
93
|
+
function D(r) {
|
|
94
|
+
throw new B(r.UTF8ToString(r.getLastOnigError()));
|
|
521
95
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
96
|
+
class T {
|
|
97
|
+
constructor(t) {
|
|
98
|
+
g(this, "utf16Length"), g(this, "utf8Length"), g(this, "utf16Value"), g(this, "utf8Value"), g(this, "utf16OffsetToUtf8"), g(this, "utf8OffsetToUtf16");
|
|
99
|
+
const n = t.length, e = T._utf8ByteLength(t), l = e !== n, h = l ? new Uint32Array(n + 1) : null;
|
|
100
|
+
l && (h[n] = e);
|
|
101
|
+
const o = l ? new Uint32Array(e + 1) : null;
|
|
102
|
+
l && (o[e] = n);
|
|
103
|
+
const s = new Uint8Array(e);
|
|
104
|
+
let i = 0;
|
|
105
|
+
for (let a = 0; a < n; a++) {
|
|
106
|
+
const w = t.charCodeAt(a);
|
|
107
|
+
let u = w, y = !1;
|
|
108
|
+
if (w >= 55296 && w <= 56319 && a + 1 < n) {
|
|
109
|
+
const f = t.charCodeAt(a + 1);
|
|
110
|
+
f >= 56320 && f <= 57343 && (u = (w - 55296 << 10) + 65536 | f - 56320, y = !0);
|
|
111
|
+
}
|
|
112
|
+
l && (h[a] = i, y && (h[a + 1] = i), u <= 127 ? o[i + 0] = a : u <= 2047 ? (o[i + 0] = a, o[i + 1] = a) : u <= 65535 ? (o[i + 0] = a, o[i + 1] = a, o[i + 2] = a) : (o[i + 0] = a, o[i + 1] = a, o[i + 2] = a, o[i + 3] = a)), u <= 127 ? s[i++] = u : u <= 2047 ? (s[i++] = 192 | (u & 1984) >>> 6, s[i++] = 128 | (u & 63) >>> 0) : u <= 65535 ? (s[i++] = 224 | (u & 61440) >>> 12, s[i++] = 128 | (u & 4032) >>> 6, s[i++] = 128 | (u & 63) >>> 0) : (s[i++] = 240 | (u & 1835008) >>> 18, s[i++] = 128 | (u & 258048) >>> 12, s[i++] = 128 | (u & 4032) >>> 6, s[i++] = 128 | (u & 63) >>> 0), y && a++;
|
|
113
|
+
}
|
|
114
|
+
this.utf16Length = n, this.utf8Length = e, this.utf16Value = t, this.utf8Value = s, this.utf16OffsetToUtf8 = h, this.utf8OffsetToUtf16 = o;
|
|
115
|
+
}
|
|
116
|
+
static _utf8ByteLength(t) {
|
|
117
|
+
let n = 0;
|
|
118
|
+
for (let e = 0, l = t.length; e < l; e++) {
|
|
119
|
+
const h = t.charCodeAt(e);
|
|
120
|
+
let o = h, s = !1;
|
|
121
|
+
if (h >= 55296 && h <= 56319 && e + 1 < l) {
|
|
122
|
+
const i = t.charCodeAt(e + 1);
|
|
123
|
+
i >= 56320 && i <= 57343 && (o = (h - 55296 << 10) + 65536 | i - 56320, s = !0);
|
|
124
|
+
}
|
|
125
|
+
o <= 127 ? n += 1 : o <= 2047 ? n += 2 : o <= 65535 ? n += 3 : n += 4, s && e++;
|
|
545
126
|
}
|
|
546
|
-
|
|
547
|
-
}
|
|
548
|
-
var We = {
|
|
549
|
-
black: "#000000",
|
|
550
|
-
red: "#bb0000",
|
|
551
|
-
green: "#00bb00",
|
|
552
|
-
yellow: "#bbbb00",
|
|
553
|
-
blue: "#0000bb",
|
|
554
|
-
magenta: "#ff00ff",
|
|
555
|
-
cyan: "#00bbbb",
|
|
556
|
-
white: "#eeeeee",
|
|
557
|
-
brightBlack: "#555555",
|
|
558
|
-
brightRed: "#ff5555",
|
|
559
|
-
brightGreen: "#00ff00",
|
|
560
|
-
brightYellow: "#ffff55",
|
|
561
|
-
brightBlue: "#5555ff",
|
|
562
|
-
brightMagenta: "#ff55ff",
|
|
563
|
-
brightCyan: "#55ffff",
|
|
564
|
-
brightWhite: "#ffffff"
|
|
565
|
-
};
|
|
566
|
-
function He(n = We) {
|
|
567
|
-
function t(i) {
|
|
568
|
-
return n[i];
|
|
569
|
-
}
|
|
570
|
-
function e(i) {
|
|
571
|
-
return `#${i.map((l) => Math.max(0, Math.min(l, 255)).toString(16).padStart(2, "0")).join("")}`;
|
|
572
|
-
}
|
|
573
|
-
let s;
|
|
574
|
-
function r() {
|
|
575
|
-
if (s)
|
|
576
|
-
return s;
|
|
577
|
-
s = [];
|
|
578
|
-
for (let c = 0; c < A.length; c++)
|
|
579
|
-
s.push(t(A[c]));
|
|
580
|
-
let i = [0, 95, 135, 175, 215, 255];
|
|
581
|
-
for (let c = 0; c < 6; c++)
|
|
582
|
-
for (let u = 0; u < 6; u++)
|
|
583
|
-
for (let f = 0; f < 6; f++)
|
|
584
|
-
s.push(e([i[c], i[u], i[f]]));
|
|
585
|
-
let l = 8;
|
|
586
|
-
for (let c = 0; c < 24; c++, l += 10)
|
|
587
|
-
s.push(e([l, l, l]));
|
|
588
|
-
return s;
|
|
589
|
-
}
|
|
590
|
-
function o(i) {
|
|
591
|
-
return r()[i];
|
|
127
|
+
return n;
|
|
592
128
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
return t(i.name);
|
|
597
|
-
case "rgb":
|
|
598
|
-
return e(i.rgb);
|
|
599
|
-
case "table":
|
|
600
|
-
return o(i.index);
|
|
601
|
-
}
|
|
129
|
+
createString(t) {
|
|
130
|
+
const n = t.omalloc(this.utf8Length);
|
|
131
|
+
return t.HEAPU8.set(this.utf8Value, n), n;
|
|
602
132
|
}
|
|
603
|
-
return {
|
|
604
|
-
value: a
|
|
605
|
-
};
|
|
606
|
-
}
|
|
607
|
-
const Pe = {
|
|
608
|
-
black: "#000000",
|
|
609
|
-
red: "#cd3131",
|
|
610
|
-
green: "#0DBC79",
|
|
611
|
-
yellow: "#E5E510",
|
|
612
|
-
blue: "#2472C8",
|
|
613
|
-
magenta: "#BC3FBC",
|
|
614
|
-
cyan: "#11A8CD",
|
|
615
|
-
white: "#E5E5E5",
|
|
616
|
-
brightBlack: "#666666",
|
|
617
|
-
brightRed: "#F14C4C",
|
|
618
|
-
brightGreen: "#23D18B",
|
|
619
|
-
brightYellow: "#F5F543",
|
|
620
|
-
brightBlue: "#3B8EEA",
|
|
621
|
-
brightMagenta: "#D670D6",
|
|
622
|
-
brightCyan: "#29B8DB",
|
|
623
|
-
brightWhite: "#FFFFFF"
|
|
624
|
-
};
|
|
625
|
-
function ze(n, t, e) {
|
|
626
|
-
const s = D(n, e), r = V(t), o = Object.fromEntries(
|
|
627
|
-
A.map((l) => {
|
|
628
|
-
var f;
|
|
629
|
-
const c = `terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`, u = (f = n.colors) == null ? void 0 : f[c];
|
|
630
|
-
return [l, u || Pe[l]];
|
|
631
|
-
})
|
|
632
|
-
), a = He(o), i = De();
|
|
633
|
-
return r.map(
|
|
634
|
-
(l) => i.parse(l[0]).map((c) => {
|
|
635
|
-
let u, f;
|
|
636
|
-
c.decorations.has("reverse") ? (u = c.background ? a.value(c.background) : n.bg, f = c.foreground ? a.value(c.foreground) : n.fg) : (u = c.foreground ? a.value(c.foreground) : n.fg, f = c.background ? a.value(c.background) : void 0), u = E(u, s), f = E(f, s), c.decorations.has("dim") && (u = Ve(u));
|
|
637
|
-
let h = L.None;
|
|
638
|
-
return c.decorations.has("bold") && (h |= L.Bold), c.decorations.has("italic") && (h |= L.Italic), c.decorations.has("underline") && (h |= L.Underline), c.decorations.has("strikethrough") && (h |= L.Strikethrough), {
|
|
639
|
-
content: c.value,
|
|
640
|
-
offset: l[1],
|
|
641
|
-
// TODO: more accurate offset? might need to fork ansi-sequence-parser
|
|
642
|
-
color: u,
|
|
643
|
-
bgColor: f,
|
|
644
|
-
fontStyle: h
|
|
645
|
-
};
|
|
646
|
-
})
|
|
647
|
-
);
|
|
648
133
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
} else {
|
|
657
|
-
if (s.length === 6)
|
|
658
|
-
return `#${s}80`;
|
|
659
|
-
if (s.length === 4) {
|
|
660
|
-
const r = s[0], o = s[1], a = s[2], i = s[3], l = Math.round(Number.parseInt(`${i}${i}`, 16) / 2).toString(16).padStart(2, "0");
|
|
661
|
-
return `#${r}${r}${o}${o}${a}${a}${l}`;
|
|
662
|
-
} else if (s.length === 3) {
|
|
663
|
-
const r = s[0], o = s[1], a = s[2];
|
|
664
|
-
return `#${r}${r}${o}${o}${a}${a}80`;
|
|
665
|
-
}
|
|
666
|
-
}
|
|
134
|
+
const L = class U {
|
|
135
|
+
constructor(t) {
|
|
136
|
+
if (g(this, "id", ++U.LAST_ID), g(this, "_onigBinding"), g(this, "content"), g(this, "utf16Length"), g(this, "utf8Length"), g(this, "utf16OffsetToUtf8"), g(this, "utf8OffsetToUtf16"), g(this, "ptr"), !d)
|
|
137
|
+
throw new B("Must invoke loadWasm first.");
|
|
138
|
+
this._onigBinding = d, this.content = t;
|
|
139
|
+
const n = new T(t);
|
|
140
|
+
this.utf16Length = n.utf16Length, this.utf8Length = n.utf8Length, this.utf16OffsetToUtf8 = n.utf16OffsetToUtf8, this.utf8OffsetToUtf16 = n.utf8OffsetToUtf16, this.utf8Length < 1e4 && !U._sharedPtrInUse ? (U._sharedPtr || (U._sharedPtr = d.omalloc(1e4)), U._sharedPtrInUse = !0, d.HEAPU8.set(n.utf8Value, U._sharedPtr), this.ptr = U._sharedPtr) : this.ptr = n.createString(d);
|
|
667
141
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
}
|
|
671
|
-
function ee(n, t, e = {}) {
|
|
672
|
-
const {
|
|
673
|
-
theme: s = n.getLoadedThemes()[0]
|
|
674
|
-
} = e, r = n.resolveLangAlias(e.lang || "text");
|
|
675
|
-
if (Q(r) || X(s))
|
|
676
|
-
return V(t).map((l) => [{ content: l[0], offset: l[1] }]);
|
|
677
|
-
const { theme: o, colorMap: a } = n.setTheme(s);
|
|
678
|
-
if (r === "ansi")
|
|
679
|
-
return ze(o, t, e);
|
|
680
|
-
const i = n.getLanguage(e.lang || "text");
|
|
681
|
-
if (e.grammarState) {
|
|
682
|
-
if (e.grammarState.lang !== i.name)
|
|
683
|
-
throw new k(`Grammar state language "${e.grammarState.lang}" does not match highlight language "${i.name}"`);
|
|
684
|
-
if (!e.grammarState.themes.includes(o.name))
|
|
685
|
-
throw new k(`Grammar state themes "${e.grammarState.themes}" do not contain highlight theme "${o.name}"`);
|
|
142
|
+
convertUtf8OffsetToUtf16(t) {
|
|
143
|
+
return this.utf8OffsetToUtf16 ? t < 0 ? 0 : t > this.utf8Length ? this.utf16Length : this.utf8OffsetToUtf16[t] : t;
|
|
686
144
|
}
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
function Je(...n) {
|
|
690
|
-
if (n.length === 2)
|
|
691
|
-
return R(n[1]);
|
|
692
|
-
const [t, e, s = {}] = n, {
|
|
693
|
-
lang: r = "text",
|
|
694
|
-
theme: o = t.getLoadedThemes()[0]
|
|
695
|
-
} = s;
|
|
696
|
-
if (Q(r) || X(o))
|
|
697
|
-
throw new k("Plain language does not have grammar state");
|
|
698
|
-
if (r === "ansi")
|
|
699
|
-
throw new k("ANSI language does not have grammar state");
|
|
700
|
-
const { theme: a, colorMap: i } = t.setTheme(o), l = t.getLanguage(r);
|
|
701
|
-
return new F(
|
|
702
|
-
te(e, l, a, i, s).stateStack,
|
|
703
|
-
l.name,
|
|
704
|
-
a.name
|
|
705
|
-
);
|
|
706
|
-
}
|
|
707
|
-
function Ye(n, t, e, s, r) {
|
|
708
|
-
const o = te(n, t, e, s, r), a = new F(
|
|
709
|
-
o.stateStack,
|
|
710
|
-
t.name,
|
|
711
|
-
e.name
|
|
712
|
-
);
|
|
713
|
-
return J(o.tokens, a), o.tokens;
|
|
714
|
-
}
|
|
715
|
-
function te(n, t, e, s, r) {
|
|
716
|
-
const o = D(e, r), {
|
|
717
|
-
tokenizeMaxLineLength: a = 0,
|
|
718
|
-
tokenizeTimeLimit: i = 500
|
|
719
|
-
} = r, l = V(n);
|
|
720
|
-
let c = r.grammarState ? Be(r.grammarState, e.name) ?? U : r.grammarContextCode != null ? te(
|
|
721
|
-
r.grammarContextCode,
|
|
722
|
-
t,
|
|
723
|
-
e,
|
|
724
|
-
s,
|
|
725
|
-
{
|
|
726
|
-
...r,
|
|
727
|
-
grammarState: void 0,
|
|
728
|
-
grammarContextCode: void 0
|
|
729
|
-
}
|
|
730
|
-
).stateStack : U, u = [];
|
|
731
|
-
const f = [];
|
|
732
|
-
for (let h = 0, d = l.length; h < d; h++) {
|
|
733
|
-
const [m, y] = l[h];
|
|
734
|
-
if (m === "") {
|
|
735
|
-
u = [], f.push([]);
|
|
736
|
-
continue;
|
|
737
|
-
}
|
|
738
|
-
if (a > 0 && m.length >= a) {
|
|
739
|
-
u = [], f.push([{
|
|
740
|
-
content: m,
|
|
741
|
-
offset: y,
|
|
742
|
-
color: "",
|
|
743
|
-
fontStyle: 0
|
|
744
|
-
}]);
|
|
745
|
-
continue;
|
|
746
|
-
}
|
|
747
|
-
let T, p, b;
|
|
748
|
-
r.includeExplanation && (T = t.tokenizeLine(m, c, i), p = T.tokens, b = 0);
|
|
749
|
-
const g = t.tokenizeLine2(m, c, i), S = g.tokens.length / 2;
|
|
750
|
-
for (let _ = 0; _ < S; _++) {
|
|
751
|
-
const C = g.tokens[2 * _], w = _ + 1 < S ? g.tokens[2 * _ + 2] : m.length;
|
|
752
|
-
if (C === w)
|
|
753
|
-
continue;
|
|
754
|
-
const N = g.tokens[2 * _ + 1], x = E(
|
|
755
|
-
s[re.getForeground(N)],
|
|
756
|
-
o
|
|
757
|
-
), I = re.getFontStyle(N), B = {
|
|
758
|
-
content: m.substring(C, w),
|
|
759
|
-
offset: y + C,
|
|
760
|
-
color: x,
|
|
761
|
-
fontStyle: I
|
|
762
|
-
};
|
|
763
|
-
if (r.includeExplanation) {
|
|
764
|
-
const M = [];
|
|
765
|
-
if (r.includeExplanation !== "scopeName")
|
|
766
|
-
for (const $ of e.settings) {
|
|
767
|
-
let O;
|
|
768
|
-
switch (typeof $.scope) {
|
|
769
|
-
case "string":
|
|
770
|
-
O = $.scope.split(/,/).map((Y) => Y.trim());
|
|
771
|
-
break;
|
|
772
|
-
case "object":
|
|
773
|
-
O = $.scope;
|
|
774
|
-
break;
|
|
775
|
-
default:
|
|
776
|
-
continue;
|
|
777
|
-
}
|
|
778
|
-
M.push({
|
|
779
|
-
settings: $,
|
|
780
|
-
selectors: O.map((Y) => Y.split(/ /))
|
|
781
|
-
});
|
|
782
|
-
}
|
|
783
|
-
B.explanation = [];
|
|
784
|
-
let se = 0;
|
|
785
|
-
for (; C + se < w; ) {
|
|
786
|
-
const $ = p[b], O = m.substring(
|
|
787
|
-
$.startIndex,
|
|
788
|
-
$.endIndex
|
|
789
|
-
);
|
|
790
|
-
se += O.length, B.explanation.push({
|
|
791
|
-
content: O,
|
|
792
|
-
scopes: r.includeExplanation === "scopeName" ? Ke(
|
|
793
|
-
$.scopes
|
|
794
|
-
) : Ue(
|
|
795
|
-
M,
|
|
796
|
-
$.scopes
|
|
797
|
-
)
|
|
798
|
-
}), b += 1;
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
u.push(B);
|
|
802
|
-
}
|
|
803
|
-
f.push(u), u = [], c = g.ruleStack;
|
|
145
|
+
convertUtf16OffsetToUtf8(t) {
|
|
146
|
+
return this.utf16OffsetToUtf8 ? t < 0 ? 0 : t > this.utf16Length ? this.utf8Length : this.utf16OffsetToUtf8[t] : t;
|
|
804
147
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
stateStack: c
|
|
808
|
-
};
|
|
809
|
-
}
|
|
810
|
-
function Ke(n) {
|
|
811
|
-
return n.map((t) => ({ scopeName: t }));
|
|
812
|
-
}
|
|
813
|
-
function Ue(n, t) {
|
|
814
|
-
const e = [];
|
|
815
|
-
for (let s = 0, r = t.length; s < r; s++) {
|
|
816
|
-
const o = t[s];
|
|
817
|
-
e[s] = {
|
|
818
|
-
scopeName: o,
|
|
819
|
-
themeMatches: Qe(n, o, t.slice(0, s))
|
|
820
|
-
};
|
|
148
|
+
dispose() {
|
|
149
|
+
this.ptr === U._sharedPtr ? U._sharedPtrInUse = !1 : this._onigBinding.ofree(this.ptr);
|
|
821
150
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
}
|
|
845
|
-
function ye(n, t, e) {
|
|
846
|
-
const s = Object.entries(e.themes).filter((l) => l[1]).map((l) => ({ color: l[0], theme: l[1] })), r = s.map((l) => {
|
|
847
|
-
const c = ee(n, t, {
|
|
848
|
-
...e,
|
|
849
|
-
theme: l.theme
|
|
850
|
-
}), u = R(c), f = typeof l.theme == "string" ? l.theme : l.theme.name;
|
|
851
|
-
return {
|
|
852
|
-
tokens: c,
|
|
853
|
-
state: u,
|
|
854
|
-
theme: f
|
|
855
|
-
};
|
|
856
|
-
}), o = Xe(
|
|
857
|
-
...r.map((l) => l.tokens)
|
|
858
|
-
), a = o[0].map(
|
|
859
|
-
(l, c) => l.map((u, f) => {
|
|
860
|
-
const h = {
|
|
861
|
-
content: u.content,
|
|
862
|
-
variants: {},
|
|
863
|
-
offset: u.offset
|
|
864
|
-
};
|
|
865
|
-
return "includeExplanation" in e && e.includeExplanation && (h.explanation = u.explanation), o.forEach((d, m) => {
|
|
866
|
-
const {
|
|
867
|
-
content: y,
|
|
868
|
-
explanation: T,
|
|
869
|
-
offset: p,
|
|
870
|
-
...b
|
|
871
|
-
} = d[c][f];
|
|
872
|
-
h.variants[s[m].color] = b;
|
|
873
|
-
}), h;
|
|
874
|
-
})
|
|
875
|
-
), i = r[0].state ? new F(
|
|
876
|
-
Object.fromEntries(r.map((l) => {
|
|
877
|
-
var c;
|
|
878
|
-
return [l.theme, (c = l.state) == null ? void 0 : c.getInternalStack(l.theme)];
|
|
879
|
-
})),
|
|
880
|
-
r[0].state.lang
|
|
881
|
-
) : void 0;
|
|
882
|
-
return i && J(a, i), a;
|
|
883
|
-
}
|
|
884
|
-
function Xe(...n) {
|
|
885
|
-
const t = n.map(() => []), e = n.length;
|
|
886
|
-
for (let s = 0; s < n[0].length; s++) {
|
|
887
|
-
const r = n.map((l) => l[s]), o = t.map(() => []);
|
|
888
|
-
t.forEach((l, c) => l.push(o[c]));
|
|
889
|
-
const a = r.map(() => 0), i = r.map((l) => l[0]);
|
|
890
|
-
for (; i.every((l) => l); ) {
|
|
891
|
-
const l = Math.min(...i.map((c) => c.content.length));
|
|
892
|
-
for (let c = 0; c < e; c++) {
|
|
893
|
-
const u = i[c];
|
|
894
|
-
u.content.length === l ? (o[c].push(u), a[c] += 1, i[c] = r[c][a[c]]) : (o[c].push({
|
|
895
|
-
...u,
|
|
896
|
-
content: u.content.slice(0, l)
|
|
897
|
-
}), i[c] = {
|
|
898
|
-
...u,
|
|
899
|
-
content: u.content.slice(l),
|
|
900
|
-
offset: u.offset + l
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
}
|
|
151
|
+
};
|
|
152
|
+
g(L, "LAST_ID", 0);
|
|
153
|
+
g(L, "_sharedPtr", 0);
|
|
154
|
+
g(L, "_sharedPtrInUse", !1);
|
|
155
|
+
let M = L;
|
|
156
|
+
class N {
|
|
157
|
+
constructor(t) {
|
|
158
|
+
if (g(this, "_onigBinding"), g(this, "_ptr"), !d)
|
|
159
|
+
throw new B("Must invoke loadWasm first.");
|
|
160
|
+
const n = [], e = [];
|
|
161
|
+
for (let s = 0, i = t.length; s < i; s++) {
|
|
162
|
+
const a = new T(t[s]);
|
|
163
|
+
n[s] = a.createString(d), e[s] = a.utf8Length;
|
|
164
|
+
}
|
|
165
|
+
const l = d.omalloc(4 * t.length);
|
|
166
|
+
d.HEAPU32.set(n, l / 4);
|
|
167
|
+
const h = d.omalloc(4 * t.length);
|
|
168
|
+
d.HEAPU32.set(e, h / 4);
|
|
169
|
+
const o = d.createOnigScanner(l, h, t.length);
|
|
170
|
+
for (let s = 0, i = t.length; s < i; s++)
|
|
171
|
+
d.ofree(n[s]);
|
|
172
|
+
d.ofree(h), d.ofree(l), o === 0 && D(d), this._onigBinding = d, this._ptr = o;
|
|
904
173
|
}
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
o = ee(
|
|
931
|
-
n,
|
|
932
|
-
t,
|
|
933
|
-
e
|
|
934
|
-
);
|
|
935
|
-
const u = n.getTheme(e.theme);
|
|
936
|
-
s = E(u.bg, c), r = E(u.fg, c), a = u.name, l = R(o);
|
|
937
|
-
} else
|
|
938
|
-
throw new k("Invalid options, either `theme` or `themes` must be provided");
|
|
939
|
-
return {
|
|
940
|
-
tokens: o,
|
|
941
|
-
fg: r,
|
|
942
|
-
bg: s,
|
|
943
|
-
themeName: a,
|
|
944
|
-
rootStyle: i,
|
|
945
|
-
grammarState: l
|
|
946
|
-
};
|
|
947
|
-
}
|
|
948
|
-
function ie(n, t, e, s, r, o, a) {
|
|
949
|
-
return n.map((i, l) => {
|
|
950
|
-
const c = E(t[l][o], e[l]) || "inherit", u = `${s + i.color}${o === "bg" ? "-bg" : ""}:${c}`;
|
|
951
|
-
if (l === 0 && r) {
|
|
952
|
-
if (r === Z && n.length > 1) {
|
|
953
|
-
const f = n.findIndex((y) => y.color === "light"), h = n.findIndex((y) => y.color === "dark");
|
|
954
|
-
if (f === -1 || h === -1)
|
|
955
|
-
throw new k('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');
|
|
956
|
-
const d = E(t[f][o], e[f]) || "inherit", m = E(t[h][o], e[h]) || "inherit";
|
|
957
|
-
return `light-dark(${d}, ${m});${u}`;
|
|
958
|
-
}
|
|
959
|
-
return c;
|
|
960
|
-
}
|
|
961
|
-
return a === "css-vars" ? u : null;
|
|
962
|
-
}).filter((i) => !!i).join(";");
|
|
963
|
-
}
|
|
964
|
-
function z(n, t, e, s = {
|
|
965
|
-
meta: {},
|
|
966
|
-
options: e,
|
|
967
|
-
codeToHast: (r, o) => z(n, r, o),
|
|
968
|
-
codeToTokens: (r, o) => P(n, r, o)
|
|
969
|
-
}) {
|
|
970
|
-
var m, y;
|
|
971
|
-
let r = t;
|
|
972
|
-
for (const T of H(e))
|
|
973
|
-
r = ((m = T.preprocess) == null ? void 0 : m.call(s, r, e)) || r;
|
|
974
|
-
let {
|
|
975
|
-
tokens: o,
|
|
976
|
-
fg: a,
|
|
977
|
-
bg: i,
|
|
978
|
-
themeName: l,
|
|
979
|
-
rootStyle: c,
|
|
980
|
-
grammarState: u
|
|
981
|
-
} = P(n, r, e);
|
|
982
|
-
const {
|
|
983
|
-
mergeWhitespaces: f = !0,
|
|
984
|
-
mergeSameStyleTokens: h = !1
|
|
985
|
-
} = e;
|
|
986
|
-
f === !0 ? o = et(o) : f === "never" && (o = tt(o)), h && (o = nt(o));
|
|
987
|
-
const d = {
|
|
988
|
-
...s,
|
|
989
|
-
get source() {
|
|
990
|
-
return r;
|
|
991
|
-
}
|
|
992
|
-
};
|
|
993
|
-
for (const T of H(e))
|
|
994
|
-
o = ((y = T.tokens) == null ? void 0 : y.call(d, o)) || o;
|
|
995
|
-
return Ze(
|
|
996
|
-
o,
|
|
997
|
-
{
|
|
998
|
-
...e,
|
|
999
|
-
fg: a,
|
|
1000
|
-
bg: i,
|
|
1001
|
-
themeName: l,
|
|
1002
|
-
rootStyle: e.rootStyle === !1 ? !1 : e.rootStyle ?? c
|
|
1003
|
-
},
|
|
1004
|
-
d,
|
|
1005
|
-
u
|
|
1006
|
-
);
|
|
1007
|
-
}
|
|
1008
|
-
function Ze(n, t, e, s = R(n)) {
|
|
1009
|
-
var y, T, p, b;
|
|
1010
|
-
const r = H(t), o = [], a = {
|
|
1011
|
-
type: "root",
|
|
1012
|
-
children: []
|
|
1013
|
-
}, {
|
|
1014
|
-
structure: i = "classic",
|
|
1015
|
-
tabindex: l = "0"
|
|
1016
|
-
} = t, c = {
|
|
1017
|
-
class: `shiki ${t.themeName || ""}`
|
|
1018
|
-
};
|
|
1019
|
-
t.rootStyle !== !1 && (t.rootStyle != null ? c.style = t.rootStyle : c.style = `background-color:${t.bg};color:${t.fg}`), l !== !1 && l != null && (c.tabindex = l.toString());
|
|
1020
|
-
for (const [g, S] of Object.entries(t.meta || {}))
|
|
1021
|
-
g.startsWith("_") || (c[g] = S);
|
|
1022
|
-
let u = {
|
|
1023
|
-
type: "element",
|
|
1024
|
-
tagName: "pre",
|
|
1025
|
-
properties: c,
|
|
1026
|
-
children: [],
|
|
1027
|
-
data: t.data
|
|
1028
|
-
}, f = {
|
|
1029
|
-
type: "element",
|
|
1030
|
-
tagName: "code",
|
|
1031
|
-
properties: {},
|
|
1032
|
-
children: o
|
|
1033
|
-
};
|
|
1034
|
-
const h = [], d = {
|
|
1035
|
-
...e,
|
|
1036
|
-
structure: i,
|
|
1037
|
-
addClassToHast: de,
|
|
1038
|
-
get source() {
|
|
1039
|
-
return e.source;
|
|
1040
|
-
},
|
|
1041
|
-
get tokens() {
|
|
1042
|
-
return n;
|
|
1043
|
-
},
|
|
1044
|
-
get options() {
|
|
1045
|
-
return t;
|
|
1046
|
-
},
|
|
1047
|
-
get root() {
|
|
1048
|
-
return a;
|
|
1049
|
-
},
|
|
1050
|
-
get pre() {
|
|
1051
|
-
return u;
|
|
1052
|
-
},
|
|
1053
|
-
get code() {
|
|
1054
|
-
return f;
|
|
1055
|
-
},
|
|
1056
|
-
get lines() {
|
|
1057
|
-
return h;
|
|
1058
|
-
}
|
|
1059
|
-
};
|
|
1060
|
-
if (n.forEach((g, S) => {
|
|
1061
|
-
var w, N;
|
|
1062
|
-
S && (i === "inline" ? a.children.push({ type: "element", tagName: "br", properties: {}, children: [] }) : i === "classic" && o.push({ type: "text", value: `
|
|
1063
|
-
` }));
|
|
1064
|
-
let _ = {
|
|
1065
|
-
type: "element",
|
|
1066
|
-
tagName: "span",
|
|
1067
|
-
properties: { class: "line" },
|
|
1068
|
-
children: []
|
|
1069
|
-
}, C = 0;
|
|
1070
|
-
for (const x of g) {
|
|
1071
|
-
let I = {
|
|
1072
|
-
type: "element",
|
|
1073
|
-
tagName: "span",
|
|
1074
|
-
properties: {
|
|
1075
|
-
...x.htmlAttrs
|
|
1076
|
-
},
|
|
1077
|
-
children: [{ type: "text", value: x.content }]
|
|
174
|
+
dispose() {
|
|
175
|
+
this._onigBinding.freeOnigScanner(this._ptr);
|
|
176
|
+
}
|
|
177
|
+
findNextMatchSync(t, n, e) {
|
|
178
|
+
let l = 0;
|
|
179
|
+
if (typeof e == "number" && (l = e), typeof t == "string") {
|
|
180
|
+
t = new M(t);
|
|
181
|
+
const h = this._findNextMatchSync(t, n, !1, l);
|
|
182
|
+
return t.dispose(), h;
|
|
183
|
+
}
|
|
184
|
+
return this._findNextMatchSync(t, n, !1, l);
|
|
185
|
+
}
|
|
186
|
+
_findNextMatchSync(t, n, e, l) {
|
|
187
|
+
const h = this._onigBinding, o = h.findNextOnigScannerMatch(this._ptr, t.id, t.ptr, t.utf8Length, t.convertUtf16OffsetToUtf8(n), l);
|
|
188
|
+
if (o === 0)
|
|
189
|
+
return null;
|
|
190
|
+
const s = h.HEAPU32;
|
|
191
|
+
let i = o / 4;
|
|
192
|
+
const a = s[i++], w = s[i++], u = [];
|
|
193
|
+
for (let y = 0; y < w; y++) {
|
|
194
|
+
const f = t.convertUtf8OffsetToUtf16(s[i++]), c = t.convertUtf8OffsetToUtf16(s[i++]);
|
|
195
|
+
u[y] = {
|
|
196
|
+
start: f,
|
|
197
|
+
end: c,
|
|
198
|
+
length: c - f
|
|
1078
199
|
};
|
|
1079
|
-
const B = q(x.htmlStyle || W(x));
|
|
1080
|
-
B && (I.properties.style = B);
|
|
1081
|
-
for (const M of r)
|
|
1082
|
-
I = ((w = M == null ? void 0 : M.span) == null ? void 0 : w.call(d, I, S + 1, C, _, x)) || I;
|
|
1083
|
-
i === "inline" ? a.children.push(I) : i === "classic" && _.children.push(I), C += x.content.length;
|
|
1084
200
|
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
h.push(_), o.push(_);
|
|
1089
|
-
} else i === "inline" && h.push(_);
|
|
1090
|
-
}), i === "classic") {
|
|
1091
|
-
for (const g of r)
|
|
1092
|
-
f = ((y = g == null ? void 0 : g.code) == null ? void 0 : y.call(d, f)) || f;
|
|
1093
|
-
u.children.push(f);
|
|
1094
|
-
for (const g of r)
|
|
1095
|
-
u = ((T = g == null ? void 0 : g.pre) == null ? void 0 : T.call(d, u)) || u;
|
|
1096
|
-
a.children.push(u);
|
|
1097
|
-
} else if (i === "inline") {
|
|
1098
|
-
const g = [];
|
|
1099
|
-
let S = {
|
|
1100
|
-
type: "element",
|
|
1101
|
-
tagName: "span",
|
|
1102
|
-
properties: { class: "line" },
|
|
1103
|
-
children: []
|
|
1104
|
-
};
|
|
1105
|
-
for (const w of a.children)
|
|
1106
|
-
w.type === "element" && w.tagName === "br" ? (g.push(S), S = {
|
|
1107
|
-
type: "element",
|
|
1108
|
-
tagName: "span",
|
|
1109
|
-
properties: { class: "line" },
|
|
1110
|
-
children: []
|
|
1111
|
-
}) : (w.type === "element" || w.type === "text") && S.children.push(w);
|
|
1112
|
-
g.push(S);
|
|
1113
|
-
let C = {
|
|
1114
|
-
type: "element",
|
|
1115
|
-
tagName: "code",
|
|
1116
|
-
properties: {},
|
|
1117
|
-
children: g
|
|
201
|
+
return {
|
|
202
|
+
index: a,
|
|
203
|
+
captureIndices: u
|
|
1118
204
|
};
|
|
1119
|
-
for (const w of r)
|
|
1120
|
-
C = ((p = w == null ? void 0 : w.code) == null ? void 0 : p.call(d, C)) || C;
|
|
1121
|
-
a.children = [];
|
|
1122
|
-
for (let w = 0; w < C.children.length; w++) {
|
|
1123
|
-
w > 0 && a.children.push({ type: "element", tagName: "br", properties: {}, children: [] });
|
|
1124
|
-
const N = C.children[w];
|
|
1125
|
-
N.type === "element" && a.children.push(...N.children);
|
|
1126
|
-
}
|
|
1127
205
|
}
|
|
1128
|
-
let m = a;
|
|
1129
|
-
for (const g of r)
|
|
1130
|
-
m = ((b = g == null ? void 0 : g.root) == null ? void 0 : b.call(d, m)) || m;
|
|
1131
|
-
return s && J(m, s), m;
|
|
1132
206
|
}
|
|
1133
|
-
function
|
|
1134
|
-
return
|
|
1135
|
-
const e = [];
|
|
1136
|
-
let s = "", r;
|
|
1137
|
-
return t.forEach((o, a) => {
|
|
1138
|
-
const l = !(o.fontStyle && (o.fontStyle & L.Underline || o.fontStyle & L.Strikethrough));
|
|
1139
|
-
l && o.content.match(/^\s+$/) && t[a + 1] ? (r === void 0 && (r = o.offset), s += o.content) : s ? (l ? e.push({
|
|
1140
|
-
...o,
|
|
1141
|
-
offset: r,
|
|
1142
|
-
content: s + o.content
|
|
1143
|
-
}) : e.push(
|
|
1144
|
-
{
|
|
1145
|
-
content: s,
|
|
1146
|
-
offset: r
|
|
1147
|
-
},
|
|
1148
|
-
o
|
|
1149
|
-
), r = void 0, s = "") : e.push(o);
|
|
1150
|
-
}), e;
|
|
1151
|
-
});
|
|
207
|
+
function F(r) {
|
|
208
|
+
return typeof r.instantiator == "function";
|
|
1152
209
|
}
|
|
1153
|
-
function
|
|
1154
|
-
return
|
|
1155
|
-
if (e.content.match(/^\s+$/))
|
|
1156
|
-
return e;
|
|
1157
|
-
const s = e.content.match(/^(\s*)(.*?)(\s*)$/);
|
|
1158
|
-
if (!s)
|
|
1159
|
-
return e;
|
|
1160
|
-
const [, r, o, a] = s;
|
|
1161
|
-
if (!r && !a)
|
|
1162
|
-
return e;
|
|
1163
|
-
const i = [{
|
|
1164
|
-
...e,
|
|
1165
|
-
offset: e.offset + r.length,
|
|
1166
|
-
content: o
|
|
1167
|
-
}];
|
|
1168
|
-
return r && i.unshift({
|
|
1169
|
-
content: r,
|
|
1170
|
-
offset: e.offset
|
|
1171
|
-
}), a && i.push({
|
|
1172
|
-
content: a,
|
|
1173
|
-
offset: e.offset + r.length + o.length
|
|
1174
|
-
}), i;
|
|
1175
|
-
}));
|
|
210
|
+
function R(r) {
|
|
211
|
+
return typeof r.default == "function";
|
|
1176
212
|
}
|
|
1177
|
-
function
|
|
1178
|
-
return
|
|
1179
|
-
const e = [];
|
|
1180
|
-
for (const s of t) {
|
|
1181
|
-
if (e.length === 0) {
|
|
1182
|
-
e.push({ ...s });
|
|
1183
|
-
continue;
|
|
1184
|
-
}
|
|
1185
|
-
const r = e[e.length - 1], o = q(r.htmlStyle || W(r)), a = q(s.htmlStyle || W(s)), i = r.fontStyle && (r.fontStyle & L.Underline || r.fontStyle & L.Strikethrough), l = s.fontStyle && (s.fontStyle & L.Underline || s.fontStyle & L.Strikethrough);
|
|
1186
|
-
!i && !l && o === a ? r.content += s.content : e.push({ ...s });
|
|
1187
|
-
}
|
|
1188
|
-
return e;
|
|
1189
|
-
});
|
|
213
|
+
function k(r) {
|
|
214
|
+
return typeof r.data < "u";
|
|
1190
215
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
var o;
|
|
1194
|
-
const s = {
|
|
1195
|
-
meta: {},
|
|
1196
|
-
options: e,
|
|
1197
|
-
codeToHast: (a, i) => z(n, a, i),
|
|
1198
|
-
codeToTokens: (a, i) => P(n, a, i)
|
|
1199
|
-
};
|
|
1200
|
-
let r = st(z(n, t, e, s));
|
|
1201
|
-
for (const a of H(e))
|
|
1202
|
-
r = ((o = a.postprocess) == null ? void 0 : o.call(s, r, e)) || r;
|
|
1203
|
-
return r;
|
|
1204
|
-
}
|
|
1205
|
-
const le = { light: "#333333", dark: "#bbbbbb" }, ce = { light: "#fffffe", dark: "#1e1e1e" }, fe = "__shiki_resolved";
|
|
1206
|
-
function ne(n) {
|
|
1207
|
-
var i, l, c, u, f;
|
|
1208
|
-
if (n != null && n[fe])
|
|
1209
|
-
return n;
|
|
1210
|
-
const t = {
|
|
1211
|
-
...n
|
|
1212
|
-
};
|
|
1213
|
-
t.tokenColors && !t.settings && (t.settings = t.tokenColors, delete t.tokenColors), t.type || (t.type = "dark"), t.colorReplacements = { ...t.colorReplacements }, t.settings || (t.settings = []);
|
|
1214
|
-
let { bg: e, fg: s } = t;
|
|
1215
|
-
if (!e || !s) {
|
|
1216
|
-
const h = t.settings ? t.settings.find((d) => !d.name && !d.scope) : void 0;
|
|
1217
|
-
(i = h == null ? void 0 : h.settings) != null && i.foreground && (s = h.settings.foreground), (l = h == null ? void 0 : h.settings) != null && l.background && (e = h.settings.background), !s && ((c = t == null ? void 0 : t.colors) != null && c["editor.foreground"]) && (s = t.colors["editor.foreground"]), !e && ((u = t == null ? void 0 : t.colors) != null && u["editor.background"]) && (e = t.colors["editor.background"]), s || (s = t.type === "light" ? le.light : le.dark), e || (e = t.type === "light" ? ce.light : ce.dark), t.fg = s, t.bg = e;
|
|
1218
|
-
}
|
|
1219
|
-
t.settings[0] && t.settings[0].settings && !t.settings[0].scope || t.settings.unshift({
|
|
1220
|
-
settings: {
|
|
1221
|
-
foreground: t.fg,
|
|
1222
|
-
background: t.bg
|
|
1223
|
-
}
|
|
1224
|
-
});
|
|
1225
|
-
let r = 0;
|
|
1226
|
-
const o = /* @__PURE__ */ new Map();
|
|
1227
|
-
function a(h) {
|
|
1228
|
-
var m;
|
|
1229
|
-
if (o.has(h))
|
|
1230
|
-
return o.get(h);
|
|
1231
|
-
r += 1;
|
|
1232
|
-
const d = `#${r.toString(16).padStart(8, "0").toLowerCase()}`;
|
|
1233
|
-
return (m = t.colorReplacements) != null && m[`#${d}`] ? a(h) : (o.set(h, d), d);
|
|
1234
|
-
}
|
|
1235
|
-
t.settings = t.settings.map((h) => {
|
|
1236
|
-
var T, p;
|
|
1237
|
-
const d = ((T = h.settings) == null ? void 0 : T.foreground) && !h.settings.foreground.startsWith("#"), m = ((p = h.settings) == null ? void 0 : p.background) && !h.settings.background.startsWith("#");
|
|
1238
|
-
if (!d && !m)
|
|
1239
|
-
return h;
|
|
1240
|
-
const y = {
|
|
1241
|
-
...h,
|
|
1242
|
-
settings: {
|
|
1243
|
-
...h.settings
|
|
1244
|
-
}
|
|
1245
|
-
};
|
|
1246
|
-
if (d) {
|
|
1247
|
-
const b = a(h.settings.foreground);
|
|
1248
|
-
t.colorReplacements[b] = h.settings.foreground, y.settings.foreground = b;
|
|
1249
|
-
}
|
|
1250
|
-
if (m) {
|
|
1251
|
-
const b = a(h.settings.background);
|
|
1252
|
-
t.colorReplacements[b] = h.settings.background, y.settings.background = b;
|
|
1253
|
-
}
|
|
1254
|
-
return y;
|
|
1255
|
-
});
|
|
1256
|
-
for (const h of Object.keys(t.colors || {}))
|
|
1257
|
-
if ((h === "editor.foreground" || h === "editor.background" || h.startsWith("terminal.ansi")) && !((f = t.colors[h]) != null && f.startsWith("#"))) {
|
|
1258
|
-
const d = a(t.colors[h]);
|
|
1259
|
-
t.colorReplacements[d] = t.colors[h], t.colors[h] = d;
|
|
1260
|
-
}
|
|
1261
|
-
return Object.defineProperty(t, fe, {
|
|
1262
|
-
enumerable: !1,
|
|
1263
|
-
writable: !1,
|
|
1264
|
-
value: !0
|
|
1265
|
-
}), t;
|
|
1266
|
-
}
|
|
1267
|
-
async function be(n) {
|
|
1268
|
-
return Array.from(new Set((await Promise.all(
|
|
1269
|
-
n.filter((t) => !ue(t)).map(async (t) => await he(t).then((e) => Array.isArray(e) ? e : [e]))
|
|
1270
|
-
)).flat()));
|
|
1271
|
-
}
|
|
1272
|
-
async function Se(n) {
|
|
1273
|
-
return (await Promise.all(
|
|
1274
|
-
n.map(
|
|
1275
|
-
async (e) => ge(e) ? null : ne(await he(e))
|
|
1276
|
-
)
|
|
1277
|
-
)).filter((e) => !!e);
|
|
1278
|
-
}
|
|
1279
|
-
let ot = 3;
|
|
1280
|
-
function at(n, t = 3) {
|
|
1281
|
-
t > ot || console.trace(`[SHIKI DEPRECATE]: ${n}`);
|
|
1282
|
-
}
|
|
1283
|
-
class j extends Error {
|
|
1284
|
-
constructor(t) {
|
|
1285
|
-
super(t), this.name = "ShikiError";
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
function Te(n, t) {
|
|
1289
|
-
if (!t)
|
|
1290
|
-
return n;
|
|
1291
|
-
if (t[n]) {
|
|
1292
|
-
const e = /* @__PURE__ */ new Set([n]);
|
|
1293
|
-
for (; t[n]; ) {
|
|
1294
|
-
if (n = t[n], e.has(n))
|
|
1295
|
-
throw new j(`Circular alias \`${Array.from(e).join(" -> ")} -> ${n}\``);
|
|
1296
|
-
e.add(n);
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
return n;
|
|
216
|
+
function j(r) {
|
|
217
|
+
return typeof Response < "u" && r instanceof Response;
|
|
1300
218
|
}
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
v(this, "_resolvedThemes", /* @__PURE__ */ new Map());
|
|
1305
|
-
v(this, "_resolvedGrammars", /* @__PURE__ */ new Map());
|
|
1306
|
-
v(this, "_langMap", /* @__PURE__ */ new Map());
|
|
1307
|
-
v(this, "_langGraph", /* @__PURE__ */ new Map());
|
|
1308
|
-
v(this, "_textmateThemeCache", /* @__PURE__ */ new WeakMap());
|
|
1309
|
-
v(this, "_loadedThemesCache", null);
|
|
1310
|
-
v(this, "_loadedLanguagesCache", null);
|
|
1311
|
-
this._resolver = e, this._themes = s, this._langs = r, this._alias = o, this._themes.map((a) => this.loadTheme(a)), this.loadLanguages(this._langs);
|
|
1312
|
-
}
|
|
1313
|
-
getTheme(e) {
|
|
1314
|
-
return typeof e == "string" ? this._resolvedThemes.get(e) : this.loadTheme(e);
|
|
1315
|
-
}
|
|
1316
|
-
loadTheme(e) {
|
|
1317
|
-
const s = ne(e);
|
|
1318
|
-
return s.name && (this._resolvedThemes.set(s.name, s), this._loadedThemesCache = null), s;
|
|
1319
|
-
}
|
|
1320
|
-
getLoadedThemes() {
|
|
1321
|
-
return this._loadedThemesCache || (this._loadedThemesCache = [...this._resolvedThemes.keys()]), this._loadedThemesCache;
|
|
1322
|
-
}
|
|
1323
|
-
// Override and re-implement this method to cache the textmate themes as `TextMateTheme.createFromRawTheme`
|
|
1324
|
-
// is expensive. Themes can switch often especially for dual-theme support.
|
|
1325
|
-
//
|
|
1326
|
-
// The parent class also accepts `colorMap` as the second parameter, but since we don't use that,
|
|
1327
|
-
// we omit here so it's easier to cache the themes.
|
|
1328
|
-
setTheme(e) {
|
|
1329
|
-
let s = this._textmateThemeCache.get(e);
|
|
1330
|
-
s || (s = Le.createFromRawTheme(e), this._textmateThemeCache.set(e, s)), this._syncRegistry.setTheme(s);
|
|
1331
|
-
}
|
|
1332
|
-
getGrammar(e) {
|
|
1333
|
-
return e = Te(e, this._alias), this._resolvedGrammars.get(e);
|
|
1334
|
-
}
|
|
1335
|
-
loadLanguage(e) {
|
|
1336
|
-
var a, i, l, c;
|
|
1337
|
-
if (this.getGrammar(e.name))
|
|
1338
|
-
return;
|
|
1339
|
-
const s = new Set(
|
|
1340
|
-
[...this._langMap.values()].filter((u) => {
|
|
1341
|
-
var f;
|
|
1342
|
-
return (f = u.embeddedLangsLazy) == null ? void 0 : f.includes(e.name);
|
|
1343
|
-
})
|
|
1344
|
-
);
|
|
1345
|
-
this._resolver.addLanguage(e);
|
|
1346
|
-
const r = {
|
|
1347
|
-
balancedBracketSelectors: e.balancedBracketSelectors || ["*"],
|
|
1348
|
-
unbalancedBracketSelectors: e.unbalancedBracketSelectors || []
|
|
1349
|
-
};
|
|
1350
|
-
this._syncRegistry._rawGrammars.set(e.scopeName, e);
|
|
1351
|
-
const o = this.loadGrammarWithConfiguration(e.scopeName, 1, r);
|
|
1352
|
-
if (o.name = e.name, this._resolvedGrammars.set(e.name, o), e.aliases && e.aliases.forEach((u) => {
|
|
1353
|
-
this._alias[u] = e.name;
|
|
1354
|
-
}), this._loadedLanguagesCache = null, s.size)
|
|
1355
|
-
for (const u of s)
|
|
1356
|
-
this._resolvedGrammars.delete(u.name), this._loadedLanguagesCache = null, (i = (a = this._syncRegistry) == null ? void 0 : a._injectionGrammars) == null || i.delete(u.scopeName), (c = (l = this._syncRegistry) == null ? void 0 : l._grammars) == null || c.delete(u.scopeName), this.loadLanguage(this._langMap.get(u.name));
|
|
1357
|
-
}
|
|
1358
|
-
dispose() {
|
|
1359
|
-
super.dispose(), this._resolvedThemes.clear(), this._resolvedGrammars.clear(), this._langMap.clear(), this._langGraph.clear(), this._loadedThemesCache = null;
|
|
1360
|
-
}
|
|
1361
|
-
loadLanguages(e) {
|
|
1362
|
-
for (const o of e)
|
|
1363
|
-
this.resolveEmbeddedLanguages(o);
|
|
1364
|
-
const s = Array.from(this._langGraph.entries()), r = s.filter(([o, a]) => !a);
|
|
1365
|
-
if (r.length) {
|
|
1366
|
-
const o = s.filter(([a, i]) => {
|
|
1367
|
-
if (!i)
|
|
1368
|
-
return !1;
|
|
1369
|
-
const l = i.embeddedLanguages || i.embeddedLangs;
|
|
1370
|
-
return l == null ? void 0 : l.some((c) => r.map(([u]) => u).includes(c));
|
|
1371
|
-
}).filter((a) => !r.includes(a));
|
|
1372
|
-
throw new j(`Missing languages ${r.map(([a]) => `\`${a}\``).join(", ")}, required by ${o.map(([a]) => `\`${a}\``).join(", ")}`);
|
|
1373
|
-
}
|
|
1374
|
-
for (const [o, a] of s)
|
|
1375
|
-
this._resolver.addLanguage(a);
|
|
1376
|
-
for (const [o, a] of s)
|
|
1377
|
-
this.loadLanguage(a);
|
|
1378
|
-
}
|
|
1379
|
-
getLoadedLanguages() {
|
|
1380
|
-
return this._loadedLanguagesCache || (this._loadedLanguagesCache = [
|
|
1381
|
-
.../* @__PURE__ */ new Set([...this._resolvedGrammars.keys(), ...Object.keys(this._alias)])
|
|
1382
|
-
]), this._loadedLanguagesCache;
|
|
1383
|
-
}
|
|
1384
|
-
resolveEmbeddedLanguages(e) {
|
|
1385
|
-
this._langMap.set(e.name, e), this._langGraph.set(e.name, e);
|
|
1386
|
-
const s = e.embeddedLanguages ?? e.embeddedLangs;
|
|
1387
|
-
if (s)
|
|
1388
|
-
for (const r of s)
|
|
1389
|
-
this._langGraph.set(r, this._langMap.get(r));
|
|
1390
|
-
}
|
|
219
|
+
function z(r) {
|
|
220
|
+
var t;
|
|
221
|
+
return typeof ArrayBuffer < "u" && (r instanceof ArrayBuffer || ArrayBuffer.isView(r)) || typeof Buffer < "u" && ((t = Buffer.isBuffer) == null ? void 0 : t.call(Buffer, r)) || typeof SharedArrayBuffer < "u" && r instanceof SharedArrayBuffer || typeof Uint32Array < "u" && r instanceof Uint32Array;
|
|
1391
222
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
createOnigString: (s) => t.createString(s)
|
|
1401
|
-
}, e.forEach((s) => this.addLanguage(s));
|
|
1402
|
-
}
|
|
1403
|
-
get onigLib() {
|
|
1404
|
-
return this._onigLib;
|
|
1405
|
-
}
|
|
1406
|
-
getLangRegistration(t) {
|
|
1407
|
-
return this._langs.get(t);
|
|
1408
|
-
}
|
|
1409
|
-
loadGrammar(t) {
|
|
1410
|
-
return this._scopeToLang.get(t);
|
|
1411
|
-
}
|
|
1412
|
-
addLanguage(t) {
|
|
1413
|
-
this._langs.set(t.name, t), t.aliases && t.aliases.forEach((e) => {
|
|
1414
|
-
this._langs.set(e, t);
|
|
1415
|
-
}), this._scopeToLang.set(t.scopeName, t), t.injectTo && t.injectTo.forEach((e) => {
|
|
1416
|
-
this._injections.get(e) || this._injections.set(e, []), this._injections.get(e).push(t.scopeName);
|
|
223
|
+
let P;
|
|
224
|
+
function G(r) {
|
|
225
|
+
if (P)
|
|
226
|
+
return P;
|
|
227
|
+
async function t() {
|
|
228
|
+
d = await W(async (n) => {
|
|
229
|
+
let e = r;
|
|
230
|
+
return e = await e, typeof e == "function" && (e = await e(n)), typeof e == "function" && (e = await e(n)), F(e) ? e = await e.instantiator(n) : R(e) ? e = await e.default(n) : (k(e) && (e = e.data), j(e) ? typeof WebAssembly.instantiateStreaming == "function" ? e = await $(e)(n) : e = await J(e)(n) : z(e) ? e = await O(e)(n) : e instanceof WebAssembly.Module ? e = await O(e)(n) : "default" in e && e.default instanceof WebAssembly.Module && (e = await O(e.default)(n))), "instance" in e && (e = e.instance), "exports" in e && (e = e.exports), e;
|
|
1417
231
|
});
|
|
1418
232
|
}
|
|
1419
|
-
|
|
1420
|
-
const e = t.split(".");
|
|
1421
|
-
let s = [];
|
|
1422
|
-
for (let r = 1; r <= e.length; r++) {
|
|
1423
|
-
const o = e.slice(0, r).join(".");
|
|
1424
|
-
s = [...s, ...this._injections.get(o) || []];
|
|
1425
|
-
}
|
|
1426
|
-
return s;
|
|
1427
|
-
}
|
|
233
|
+
return P = t(), P;
|
|
1428
234
|
}
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
G += 1, n.warnings !== !1 && G >= 10 && G % 10 === 0 && console.warn(`[Shiki] ${G} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);
|
|
1432
|
-
let t = !1;
|
|
1433
|
-
if (!n.engine)
|
|
1434
|
-
throw new j("`engine` option is required for synchronous mode");
|
|
1435
|
-
const e = (n.langs || []).flat(1), s = (n.themes || []).flat(1).map(ne), r = new lt(n.engine, e), o = new it(r, s, e, n.langAlias);
|
|
1436
|
-
let a;
|
|
1437
|
-
function i(g) {
|
|
1438
|
-
return Te(g, n.langAlias);
|
|
1439
|
-
}
|
|
1440
|
-
function l(g) {
|
|
1441
|
-
p();
|
|
1442
|
-
const S = o.getGrammar(typeof g == "string" ? g : g.name);
|
|
1443
|
-
if (!S)
|
|
1444
|
-
throw new j(`Language \`${g}\` not found, you may need to load it first`);
|
|
1445
|
-
return S;
|
|
1446
|
-
}
|
|
1447
|
-
function c(g) {
|
|
1448
|
-
if (g === "none")
|
|
1449
|
-
return { bg: "", fg: "", name: "none", settings: [], type: "dark" };
|
|
1450
|
-
p();
|
|
1451
|
-
const S = o.getTheme(g);
|
|
1452
|
-
if (!S)
|
|
1453
|
-
throw new j(`Theme \`${g}\` not found, you may need to load it first`);
|
|
1454
|
-
return S;
|
|
1455
|
-
}
|
|
1456
|
-
function u(g) {
|
|
1457
|
-
p();
|
|
1458
|
-
const S = c(g);
|
|
1459
|
-
a !== g && (o.setTheme(S), a = g);
|
|
1460
|
-
const _ = o.getColorMap();
|
|
1461
|
-
return {
|
|
1462
|
-
theme: S,
|
|
1463
|
-
colorMap: _
|
|
1464
|
-
};
|
|
1465
|
-
}
|
|
1466
|
-
function f() {
|
|
1467
|
-
return p(), o.getLoadedThemes();
|
|
1468
|
-
}
|
|
1469
|
-
function h() {
|
|
1470
|
-
return p(), o.getLoadedLanguages();
|
|
1471
|
-
}
|
|
1472
|
-
function d(...g) {
|
|
1473
|
-
p(), o.loadLanguages(g.flat(1));
|
|
1474
|
-
}
|
|
1475
|
-
async function m(...g) {
|
|
1476
|
-
return d(await be(g));
|
|
1477
|
-
}
|
|
1478
|
-
function y(...g) {
|
|
1479
|
-
p();
|
|
1480
|
-
for (const S of g.flat(1))
|
|
1481
|
-
o.loadTheme(S);
|
|
1482
|
-
}
|
|
1483
|
-
async function T(...g) {
|
|
1484
|
-
return p(), y(await Se(g));
|
|
1485
|
-
}
|
|
1486
|
-
function p() {
|
|
1487
|
-
if (t)
|
|
1488
|
-
throw new j("Shiki instance has been disposed");
|
|
1489
|
-
}
|
|
1490
|
-
function b() {
|
|
1491
|
-
t || (t = !0, o.dispose(), G -= 1);
|
|
1492
|
-
}
|
|
1493
|
-
return {
|
|
1494
|
-
setTheme: u,
|
|
1495
|
-
getTheme: c,
|
|
1496
|
-
getLanguage: l,
|
|
1497
|
-
getLoadedThemes: f,
|
|
1498
|
-
getLoadedLanguages: h,
|
|
1499
|
-
resolveLangAlias: i,
|
|
1500
|
-
loadLanguage: m,
|
|
1501
|
-
loadLanguageSync: d,
|
|
1502
|
-
loadTheme: T,
|
|
1503
|
-
loadThemeSync: y,
|
|
1504
|
-
dispose: b,
|
|
1505
|
-
[Symbol.dispose]: b
|
|
1506
|
-
};
|
|
235
|
+
function O(r) {
|
|
236
|
+
return (t) => WebAssembly.instantiate(r, t);
|
|
1507
237
|
}
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
const [
|
|
1511
|
-
t,
|
|
1512
|
-
e,
|
|
1513
|
-
s
|
|
1514
|
-
] = await Promise.all([
|
|
1515
|
-
Se(n.themes || []),
|
|
1516
|
-
be(n.langs || []),
|
|
1517
|
-
n.engine
|
|
1518
|
-
]);
|
|
1519
|
-
return ct({
|
|
1520
|
-
...n,
|
|
1521
|
-
themes: t,
|
|
1522
|
-
langs: e,
|
|
1523
|
-
engine: s
|
|
1524
|
-
});
|
|
238
|
+
function $(r) {
|
|
239
|
+
return (t) => WebAssembly.instantiateStreaming(r, t);
|
|
1525
240
|
}
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
codeToTokensBase: (e, s) => ee(t, e, s),
|
|
1531
|
-
codeToTokensWithThemes: (e, s) => ye(t, e, s),
|
|
1532
|
-
codeToTokens: (e, s) => P(t, e, s),
|
|
1533
|
-
codeToHast: (e, s) => z(t, e, s),
|
|
1534
|
-
codeToHtml: (e, s) => rt(t, e, s),
|
|
1535
|
-
getBundledLanguages: () => ({}),
|
|
1536
|
-
getBundledThemes: () => ({}),
|
|
1537
|
-
...t,
|
|
1538
|
-
getInternalContext: () => t
|
|
241
|
+
function J(r) {
|
|
242
|
+
return async (t) => {
|
|
243
|
+
const n = await r.arrayBuffer();
|
|
244
|
+
return WebAssembly.instantiate(n, t);
|
|
1539
245
|
};
|
|
1540
246
|
}
|
|
1541
|
-
function
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
var h;
|
|
1546
|
-
if (typeof f == "string") {
|
|
1547
|
-
if (f = ((h = o.langAlias) == null ? void 0 : h[f]) || f, ue(f))
|
|
1548
|
-
return [];
|
|
1549
|
-
const d = t[f];
|
|
1550
|
-
if (!d)
|
|
1551
|
-
throw new k(`Language \`${f}\` is not included in this bundle. You may want to load it from external source.`);
|
|
1552
|
-
return d;
|
|
1553
|
-
}
|
|
1554
|
-
return f;
|
|
1555
|
-
}
|
|
1556
|
-
function i(f) {
|
|
1557
|
-
if (ge(f))
|
|
1558
|
-
return "none";
|
|
1559
|
-
if (typeof f == "string") {
|
|
1560
|
-
const h = e[f];
|
|
1561
|
-
if (!h)
|
|
1562
|
-
throw new k(`Theme \`${f}\` is not included in this bundle. You may want to load it from external source.`);
|
|
1563
|
-
return h;
|
|
1564
|
-
}
|
|
1565
|
-
return f;
|
|
1566
|
-
}
|
|
1567
|
-
const l = (o.themes ?? []).map((f) => i(f)), c = (o.langs ?? []).map((f) => a(f)), u = await ht({
|
|
1568
|
-
engine: o.engine ?? s(),
|
|
1569
|
-
...o,
|
|
1570
|
-
themes: l,
|
|
1571
|
-
langs: c
|
|
1572
|
-
});
|
|
1573
|
-
return {
|
|
1574
|
-
...u,
|
|
1575
|
-
loadLanguage(...f) {
|
|
1576
|
-
return u.loadLanguage(...f.map(a));
|
|
1577
|
-
},
|
|
1578
|
-
loadTheme(...f) {
|
|
1579
|
-
return u.loadTheme(...f.map(i));
|
|
1580
|
-
},
|
|
1581
|
-
getBundledLanguages() {
|
|
1582
|
-
return t;
|
|
1583
|
-
},
|
|
1584
|
-
getBundledThemes() {
|
|
1585
|
-
return e;
|
|
1586
|
-
}
|
|
1587
|
-
};
|
|
1588
|
-
}
|
|
1589
|
-
return r;
|
|
1590
|
-
}
|
|
1591
|
-
function ut(n) {
|
|
1592
|
-
let t;
|
|
1593
|
-
async function e(s = {}) {
|
|
1594
|
-
if (t) {
|
|
1595
|
-
const r = await t;
|
|
1596
|
-
return await Promise.all([
|
|
1597
|
-
r.loadTheme(...s.themes || []),
|
|
1598
|
-
r.loadLanguage(...s.langs || [])
|
|
1599
|
-
]), r;
|
|
1600
|
-
} else {
|
|
1601
|
-
t = n({
|
|
1602
|
-
...s,
|
|
1603
|
-
themes: [],
|
|
1604
|
-
langs: []
|
|
1605
|
-
});
|
|
1606
|
-
const r = await t;
|
|
1607
|
-
return await Promise.all([
|
|
1608
|
-
r.loadTheme(...s.themes || []),
|
|
1609
|
-
r.loadLanguage(...s.langs || [])
|
|
1610
|
-
]), r;
|
|
1611
|
-
}
|
|
1612
|
-
}
|
|
1613
|
-
return e;
|
|
1614
|
-
}
|
|
1615
|
-
function St(n, t) {
|
|
1616
|
-
const e = ut(n);
|
|
1617
|
-
async function s(r, o) {
|
|
1618
|
-
var l;
|
|
1619
|
-
const a = await e({
|
|
1620
|
-
langs: [o.lang],
|
|
1621
|
-
themes: "theme" in o ? [o.theme] : Object.values(o.themes)
|
|
1622
|
-
}), i = await ((l = t == null ? void 0 : t.guessEmbeddedLanguages) == null ? void 0 : l.call(t, r, o.lang, a));
|
|
1623
|
-
return i && await a.loadLanguage(...i), a;
|
|
1624
|
-
}
|
|
1625
|
-
return {
|
|
1626
|
-
getSingletonHighlighter(r) {
|
|
1627
|
-
return e(r);
|
|
1628
|
-
},
|
|
1629
|
-
async codeToHtml(r, o) {
|
|
1630
|
-
return (await s(r, o)).codeToHtml(r, o);
|
|
1631
|
-
},
|
|
1632
|
-
async codeToHast(r, o) {
|
|
1633
|
-
return (await s(r, o)).codeToHast(r, o);
|
|
1634
|
-
},
|
|
1635
|
-
async codeToTokens(r, o) {
|
|
1636
|
-
return (await s(r, o)).codeToTokens(r, o);
|
|
1637
|
-
},
|
|
1638
|
-
async codeToTokensBase(r, o) {
|
|
1639
|
-
return (await s(r, o)).codeToTokensBase(r, o);
|
|
1640
|
-
},
|
|
1641
|
-
async codeToTokensWithThemes(r, o) {
|
|
1642
|
-
return (await s(r, o)).codeToTokensWithThemes(r, o);
|
|
247
|
+
async function K(r) {
|
|
248
|
+
return r && await G(r), {
|
|
249
|
+
createScanner(t) {
|
|
250
|
+
return new N(t.map((n) => typeof n == "string" ? n : n.source));
|
|
1643
251
|
},
|
|
1644
|
-
|
|
1645
|
-
return
|
|
1646
|
-
langs: [o.lang],
|
|
1647
|
-
themes: [o.theme]
|
|
1648
|
-
})).getLastGrammarState(r, o);
|
|
252
|
+
createString(t) {
|
|
253
|
+
return new M(t);
|
|
1649
254
|
}
|
|
1650
255
|
};
|
|
1651
256
|
}
|
|
1652
257
|
export {
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
E as applyColorReplacements,
|
|
1656
|
-
z as codeToHast,
|
|
1657
|
-
rt as codeToHtml,
|
|
1658
|
-
P as codeToTokens,
|
|
1659
|
-
ee as codeToTokensBase,
|
|
1660
|
-
ye as codeToTokensWithThemes,
|
|
1661
|
-
bt as createBundledHighlighter,
|
|
1662
|
-
ht as createHighlighterCore,
|
|
1663
|
-
xe as createPositionConverter,
|
|
1664
|
-
ft as createShikiInternal,
|
|
1665
|
-
ct as createShikiInternalSync,
|
|
1666
|
-
St as createSingletonShorthands,
|
|
1667
|
-
Ee as flatTokenVariants,
|
|
1668
|
-
W as getTokenStyleObject,
|
|
1669
|
-
yt as guessEmbeddedLanguages,
|
|
1670
|
-
st as hastToHtml,
|
|
1671
|
-
X as isNoneTheme,
|
|
1672
|
-
Q as isPlainLang,
|
|
1673
|
-
ue as isSpecialLang,
|
|
1674
|
-
ge as isSpecialTheme,
|
|
1675
|
-
ut as makeSingletonHighlighter,
|
|
1676
|
-
he as normalizeGetter,
|
|
1677
|
-
ne as normalizeTheme,
|
|
1678
|
-
D as resolveColorReplacements,
|
|
1679
|
-
V as splitLines,
|
|
1680
|
-
Ne as splitToken,
|
|
1681
|
-
Ie as splitTokens,
|
|
1682
|
-
q as stringifyTokenStyle,
|
|
1683
|
-
Ce as toArray,
|
|
1684
|
-
ze as tokenizeAnsiWithTheme,
|
|
1685
|
-
Ye as tokenizeWithTheme,
|
|
1686
|
-
Ze as tokensToHast,
|
|
1687
|
-
Me as transformerDecorations,
|
|
1688
|
-
at as warnDeprecated
|
|
258
|
+
K as createOnigurumaEngine,
|
|
259
|
+
G as loadWasm
|
|
1689
260
|
};
|
|
1690
261
|
//# sourceMappingURL=index.esm82.js.map
|