@pubinfo-pr/core 0.222.2 → 0.222.4
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/{AppSetting-Adv5Y3SE.js → AppSetting-BWVulLPM.js} +38 -38
- package/dist/{HCheckList-WAAl9RiK.js → HCheckList-Bb4GvZ2_.js} +1 -1
- package/dist/HSlideover-DoCRa4dK.js +152 -0
- package/dist/{HToggle-YLmL7R0b.js → HToggle-Bnr5k93p.js} +1 -1
- package/dist/{HeaderFullMenu-ByedDsvz.js → HeaderFullMenu--AOcAS-6.js} +72 -72
- package/dist/{HeaderThinMenu-2q2iBtTH.js → HeaderThinMenu-CRPVfGgM.js} +132 -132
- package/dist/PreferencesContent-DW9HAzpr.js +486 -0
- package/dist/{SettingBreadcrumb-C1VwfnxX.js → SettingBreadcrumb-DKCK6V-n.js} +6 -7
- package/dist/{SettingCopyright-C--oGV21.js → SettingCopyright-C5Pc0I1w.js} +4 -4
- package/dist/{SettingEnableTransition-DW2gfisN.js → SettingEnableTransition-D2FDj0oR.js} +5 -5
- package/dist/{SettingHome-VUAS3uEg.js → SettingHome-1Y1rYeQb.js} +6 -6
- package/dist/{SettingMenu-BH7XU7eF.js → SettingMenu-DWtNX8Ti.js} +8 -9
- package/dist/{SettingMode-BIyHzTKH.js → SettingMode-CZV84QeW.js} +4 -4
- package/dist/{SettingNavSearch-PfSA-_ro.js → SettingNavSearch-CrMpbXFg.js} +5 -5
- package/dist/{SettingOther-DdqNapQX.js → SettingOther-D6gGuQJw.js} +6 -6
- package/dist/{SettingPage-DS-G9-X5.js → SettingPage-DuN13bXO.js} +3 -3
- package/dist/{SettingTabbar-2yfw2vsm.js → SettingTabbar-BhJxcU35.js} +10 -11
- package/dist/{SettingThemes-Bkcywy7v.js → SettingThemes-BjkWfY1C.js} +9 -10
- package/dist/{SettingToolbar-DP7-_nPK.js → SettingToolbar-BYOxXAXL.js} +5 -5
- package/dist/{SettingTopbar-C0Ia4-If.js → SettingTopbar-CxKsnIRK.js} +8 -9
- package/dist/{SettingWidthMode-DgSWsHFq.js → SettingWidthMode-dM88qSol.js} +5 -5
- package/dist/auth-DILNNEQ8.js +1230 -0
- package/dist/{change-organization-BfnI2yEl.js → change-organization-BXl4ZC7j.js} +24 -24
- package/dist/{change-password-Bj_GWzmn.js → change-password-P4SGdvdU.js} +64 -73
- package/dist/components-C9kcavB4.js +2768 -0
- package/dist/core-CKIhF3Vi.js +270 -0
- package/dist/{core-4H5JBsa5.js → core-D2ocBD0r.js} +57 -51
- package/dist/index.js +2249 -7757
- package/dist/{not-found-DbHOY5cU.js → not-found-C-1699o2.js} +4 -5
- package/dist/{not-permission-DwERxb_u.js → not-permission-CZGJzlSF.js} +4 -5
- package/dist/profile-B3Q7hRgl.js +123 -0
- package/dist/{question-line-D7ecIumZ.js → question-line-B4oDBb2H.js} +2 -2
- package/dist/{right-DYiPS7dU.js → right-BTHgfOSp.js} +4 -4
- package/dist/style.css +1 -1
- package/package.json +7 -7
- package/dist/HSlideover-CXBJxuQo.js +0 -1695
- package/dist/PreferencesContent-CiPweszy.js +0 -701
- package/dist/auth-B65CJEOe.js +0 -4242
- package/dist/chunk-CD4vhpVs.js +0 -18
- package/dist/components-BfkDsfck.js +0 -5238
- package/dist/dist-7OjQvlya.js +0 -468
- package/dist/form-C3VHofnN.js +0 -2768
- package/dist/modal-Bl5xHbxa.js +0 -43824
- package/dist/overlayscrollbars-vue-mGyICRMi.js +0 -1460
- package/dist/profile-Dq66-Gsl.js +0 -19269
- package/dist/tree-select-B8cTcGLa.js +0 -12497
- package/dist/watchDiff-CPZFtaOC.js +0 -655
- /package/dist/{HButton-Dt6qGhhR.js → HButton-BPbXqVbA.js} +0 -0
- /package/dist/{HDivider-Ds5MMqtm.js → HDivider-BSENlYnI.js} +0 -0
- /package/dist/{HInput-BrsX9848.js → HInput-DbvnkEO7.js} +0 -0
- /package/dist/{HTooltip-DjAU-Evn.js → HTooltip-tCnNrJUE.js} +0 -0
- /package/dist/{_plugin-vue_export-helper-sUTDUeGO.js → _plugin-vue_export-helper-BBf_fmJ_.js} +0 -0
- /package/dist/{engine-oniguruma-uxNZ2DGJ.js → engine-oniguruma-Bl7ZtyDI.js} +0 -0
- /package/dist/{json-CC4oV-bd.js → json-BuUwnwNo.js} +0 -0
- /package/dist/{reload-CbuQgTlC.js → reload-DWTXo9r2.js} +0 -0
- /package/dist/{useContext-DLtu9F7E.js → useContext-mDF2-tXy.js} +0 -0
- /package/dist/{vitesse-dark-CxkWMfh6.js → vitesse-dark-j0hKJETh.js} +0 -0
- /package/dist/{vitesse-light-DY25e6F3.js → vitesse-light-BfgKNo3X.js} +0 -0
- /package/dist/{wasm-DAU6f5s5.js → wasm-tXaxAgz9.js} +0 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { createContext } from "unctx";
|
|
2
|
+
import { createPinia } from "pinia";
|
|
3
|
+
import { createApp } from "vue";
|
|
4
|
+
import { createHooks } from "hookable";
|
|
5
|
+
import { createRouter, createWebHashHistory } from "vue-router";
|
|
6
|
+
import { axiosRequestAdapter } from "@alova/adapter-axios";
|
|
7
|
+
import { createAlova } from "alova";
|
|
8
|
+
import vueHook from "alova/vue";
|
|
9
|
+
function ensureNamespace() {
|
|
10
|
+
let e = globalThis;
|
|
11
|
+
return e.__PUBINFO__ ||= {}, e.__PUBINFO__;
|
|
12
|
+
}
|
|
13
|
+
function getPubinfoNamespace() {
|
|
14
|
+
return ensureNamespace();
|
|
15
|
+
}
|
|
16
|
+
function createContext$1(t, n = {}) {
|
|
17
|
+
let r = ensureNamespace(), i = normalizeKeys(t, n.stateKey);
|
|
18
|
+
if (!r[i.contextKey]) {
|
|
19
|
+
let t = i.aliasKey ? r[i.aliasKey] : void 0;
|
|
20
|
+
r[i.contextKey] = t ?? createContext();
|
|
21
|
+
}
|
|
22
|
+
let a = r[i.contextKey];
|
|
23
|
+
i.aliasKey && (r[i.aliasKey] = a);
|
|
24
|
+
let { hydrate: o = !0, persistOnSet: s = !0 } = n, c = i.stateKey;
|
|
25
|
+
if (c && s && !a.__pubinfo_persisted) {
|
|
26
|
+
let e = a.set.bind(a), t = a.unset.bind(a);
|
|
27
|
+
a.set = (t, n) => {
|
|
28
|
+
e(t, n), t === void 0 ? clearPersistedState(c) : setPersistedState(c, t);
|
|
29
|
+
}, a.unset = () => {
|
|
30
|
+
clearPersistedState(c), t();
|
|
31
|
+
}, a.__pubinfo_persisted = !0;
|
|
32
|
+
}
|
|
33
|
+
if (o && c) {
|
|
34
|
+
let e = r[c];
|
|
35
|
+
if (e !== void 0) try {
|
|
36
|
+
a.set(e);
|
|
37
|
+
} catch {}
|
|
38
|
+
}
|
|
39
|
+
return a;
|
|
40
|
+
}
|
|
41
|
+
function setPersistedState(e, t) {
|
|
42
|
+
let n = ensureNamespace();
|
|
43
|
+
n[e] = t;
|
|
44
|
+
}
|
|
45
|
+
function getPersistedState(e) {
|
|
46
|
+
return ensureNamespace()[e];
|
|
47
|
+
}
|
|
48
|
+
function clearPersistedState(e) {
|
|
49
|
+
let t = ensureNamespace();
|
|
50
|
+
e in t && delete t[e];
|
|
51
|
+
}
|
|
52
|
+
function normalizeKeys(e, t) {
|
|
53
|
+
if (t) return {
|
|
54
|
+
contextKey: e,
|
|
55
|
+
stateKey: t
|
|
56
|
+
};
|
|
57
|
+
if (e.endsWith("Ctx")) {
|
|
58
|
+
let t = e.slice(0, -3);
|
|
59
|
+
return {
|
|
60
|
+
contextKey: e,
|
|
61
|
+
stateKey: t ? `${t}State` : void 0
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (e.endsWith("Context")) {
|
|
65
|
+
let t = e.slice(0, -7);
|
|
66
|
+
if (t) return {
|
|
67
|
+
contextKey: `${t}Ctx`,
|
|
68
|
+
stateKey: `${t}State`,
|
|
69
|
+
aliasKey: e
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
let n = e;
|
|
73
|
+
if (!n) return {
|
|
74
|
+
contextKey: e,
|
|
75
|
+
stateKey: void 0
|
|
76
|
+
};
|
|
77
|
+
let r = `${n}Ctx`;
|
|
78
|
+
return {
|
|
79
|
+
contextKey: r,
|
|
80
|
+
stateKey: `${n}State`,
|
|
81
|
+
aliasKey: r === e ? void 0 : e
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async function asyncFlatten(e) {
|
|
85
|
+
do
|
|
86
|
+
e = (await Promise.all(e)).flat(Infinity);
|
|
87
|
+
while (e.some((e) => e?.then));
|
|
88
|
+
return e;
|
|
89
|
+
}
|
|
90
|
+
var HOOKS_KEY = "__pubinfo_core_hooks__", namespace$1 = getPubinfoNamespace();
|
|
91
|
+
const hooks = namespace$1[HOOKS_KEY] || (namespace$1[HOOKS_KEY] = createHooks());
|
|
92
|
+
async function callHookAsync(e, t) {
|
|
93
|
+
return await hooks.callHookWith(async (e, t) => {
|
|
94
|
+
let n = t[0];
|
|
95
|
+
for (let t of e) n = await t(n);
|
|
96
|
+
return n;
|
|
97
|
+
}, e, [t]);
|
|
98
|
+
}
|
|
99
|
+
function callHookSync(e, t) {
|
|
100
|
+
return hooks.callHookWith((t, n) => {
|
|
101
|
+
let r = n[0];
|
|
102
|
+
if (!t.length) return r;
|
|
103
|
+
for (let n of t) {
|
|
104
|
+
let t = n(r);
|
|
105
|
+
if (t && typeof t.then == "function") throw Error(`[hooks] "${e}" 当前仅支持同步回调`);
|
|
106
|
+
t !== void 0 && (r = t);
|
|
107
|
+
}
|
|
108
|
+
return r;
|
|
109
|
+
}, e, [t]);
|
|
110
|
+
}
|
|
111
|
+
async function resolveModules(e = [], t) {
|
|
112
|
+
let n = (await asyncFlatten(e)).filter((e) => !!e);
|
|
113
|
+
for (let e of n) e.setup && await e.setup(t);
|
|
114
|
+
}
|
|
115
|
+
function extractModules(e = []) {
|
|
116
|
+
let t = {
|
|
117
|
+
pre: [],
|
|
118
|
+
post: [],
|
|
119
|
+
default: []
|
|
120
|
+
};
|
|
121
|
+
function n(e) {
|
|
122
|
+
e && (Array.isArray(e) ? e.forEach(n) : typeof e == "object" && e.name && (e.enforce === "pre" ? t.pre.push(e) : e.enforce === "post" ? t.post.push(e) : t.default.push(e)));
|
|
123
|
+
}
|
|
124
|
+
return e?.forEach(n), t;
|
|
125
|
+
}
|
|
126
|
+
function resolveHooks(e) {
|
|
127
|
+
e.forEach((e) => {
|
|
128
|
+
hooks.addHooks(e?.hooks ?? {});
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
var modules;
|
|
132
|
+
async function loadProjectModules() {
|
|
133
|
+
try {
|
|
134
|
+
modules = (await import("virtual:pubinfo-resolver")).default;
|
|
135
|
+
} catch {
|
|
136
|
+
console.warn("[PUBINFO] virtual:pubinfo-resolver not available."), modules = {};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function readProjectModules() {
|
|
140
|
+
return modules;
|
|
141
|
+
}
|
|
142
|
+
var namespace = getPubinfoNamespace();
|
|
143
|
+
namespace.iconModules = namespace.iconModules || /* @__PURE__ */ new Map();
|
|
144
|
+
var iconModuleMap = namespace.iconModules;
|
|
145
|
+
namespace.iconCache = namespace.iconCache || /* @__PURE__ */ new Map();
|
|
146
|
+
var iconCache = namespace.iconCache;
|
|
147
|
+
function getCacheKey(e, t) {
|
|
148
|
+
return `${t ?? "default"}:${e}`;
|
|
149
|
+
}
|
|
150
|
+
function getCachedIcon(e, t) {
|
|
151
|
+
return iconCache.get(getCacheKey(e, t));
|
|
152
|
+
}
|
|
153
|
+
function setCachedIcon(e, t, n) {
|
|
154
|
+
let r = getCacheKey(e, t);
|
|
155
|
+
n ? iconCache.set(r, n) : iconCache.delete(r);
|
|
156
|
+
}
|
|
157
|
+
function defineIconModule(e, t) {
|
|
158
|
+
iconModuleMap.has(e) || iconModuleMap.set(e, t);
|
|
159
|
+
}
|
|
160
|
+
function getIconModule(e) {
|
|
161
|
+
return iconModuleMap.get(e);
|
|
162
|
+
}
|
|
163
|
+
function getAllIconModules() {
|
|
164
|
+
let e = new Map(iconModuleMap), t = readProjectModules()?.icons;
|
|
165
|
+
return t && Object.keys(t).length && (e.has("local") || e.set("local", t)), e;
|
|
166
|
+
}
|
|
167
|
+
async function setupIcon(e, t) {
|
|
168
|
+
let n = getCachedIcon(e, t);
|
|
169
|
+
if (n) return n;
|
|
170
|
+
readProjectModules() || await loadProjectModules().catch(() => {});
|
|
171
|
+
let r = readProjectModules()?.icons ?? {}, i = await findFile(t ? getIconModule(t) ?? {} : {}, e);
|
|
172
|
+
if (i || (i = await findFile(r, e), i)) return setCachedIcon(e, t, i), t && setCachedIcon(e, void 0, i), i;
|
|
173
|
+
let a = getAllIconModules();
|
|
174
|
+
for (let [n, r] of a) if (n !== t && (i = await findFile(r, e), i)) return setCachedIcon(e, n === "default" ? void 0 : n, i), setCachedIcon(e, void 0, i), i;
|
|
175
|
+
}
|
|
176
|
+
async function findFile(e, t) {
|
|
177
|
+
let n = Object.entries(e).find(([e]) => e.endsWith(t));
|
|
178
|
+
if (n?.[1]) return (await n[1]()).default;
|
|
179
|
+
}
|
|
180
|
+
function selectDefaultLayout(e, t) {
|
|
181
|
+
let n = Object.entries(e ?? {});
|
|
182
|
+
if (n.length === 0) return null;
|
|
183
|
+
if (t) {
|
|
184
|
+
let e = n.find(([e]) => e.split("/").pop()?.replace(/\.vue$/, "") === t);
|
|
185
|
+
if (e) return e[1];
|
|
186
|
+
}
|
|
187
|
+
return n.length === 1 ? n[0][1] : n.find(([e]) => e.endsWith("/index.vue"))?.[1] || n[0][1];
|
|
188
|
+
}
|
|
189
|
+
function setupDefaultLayout(e) {
|
|
190
|
+
return selectDefaultLayout(readProjectModules()?.layouts, e);
|
|
191
|
+
}
|
|
192
|
+
var routeModuleMap = /* @__PURE__ */ new Map();
|
|
193
|
+
function defineRouteModule(e, t) {
|
|
194
|
+
routeModuleMap.has(e) || routeModuleMap.set(e, t);
|
|
195
|
+
}
|
|
196
|
+
function getRouteModule(e) {
|
|
197
|
+
return routeModuleMap.get(e);
|
|
198
|
+
}
|
|
199
|
+
function getAllRouteModules() {
|
|
200
|
+
return routeModuleMap;
|
|
201
|
+
}
|
|
202
|
+
function setupPage(e, t) {
|
|
203
|
+
let n = readProjectModules()?.pages ?? {}, r = findPageFile(t ? getRouteModule(t) ?? {} : {}, e);
|
|
204
|
+
if (r || (r = findPageFile(n, e), r)) return r;
|
|
205
|
+
let i = getAllRouteModules();
|
|
206
|
+
for (let [n, a] of i) if (n !== t && (r = findPageFile(a, e), r)) return r;
|
|
207
|
+
}
|
|
208
|
+
function findPageFile(e, t) {
|
|
209
|
+
return Object.entries(e).find(([e]) => e.endsWith(t))?.[1];
|
|
210
|
+
}
|
|
211
|
+
function createApp$1(e) {
|
|
212
|
+
let { app: r, router: o, setup: s, rootContainer: c = "#app", immediate: l = !0, modules: u = [], hooks: d = {} } = e;
|
|
213
|
+
async function f() {
|
|
214
|
+
await loadProjectModules();
|
|
215
|
+
let e = createApp(r), c = createPinia();
|
|
216
|
+
e.use(c);
|
|
217
|
+
let { base: l, ...f } = o, p = createRouter({
|
|
218
|
+
history: createWebHashHistory(l),
|
|
219
|
+
...f
|
|
220
|
+
}), m = {
|
|
221
|
+
app: e,
|
|
222
|
+
store: c,
|
|
223
|
+
router: p
|
|
224
|
+
}, h = extractModules(u);
|
|
225
|
+
return resolveHooks([
|
|
226
|
+
...h.pre,
|
|
227
|
+
...h.default,
|
|
228
|
+
{ hooks: d },
|
|
229
|
+
...h.post
|
|
230
|
+
]), await resolveModules(h.pre, m), await resolveModules(h.default, m), await s?.(m), await resolveModules(h.post, m), e.use(p), m;
|
|
231
|
+
}
|
|
232
|
+
return l && (async () => {
|
|
233
|
+
let { app: e, router: t } = await f();
|
|
234
|
+
await t.isReady(), e.mount(c, !0);
|
|
235
|
+
})(), f;
|
|
236
|
+
}
|
|
237
|
+
function normalizedResponded(e) {
|
|
238
|
+
return typeof e == "function" ? { onSuccess: e } : e;
|
|
239
|
+
}
|
|
240
|
+
function createRequest(e = {}) {
|
|
241
|
+
let { axios: t, beforeRequest: n, responded: r, ...i } = e, a = normalizedResponded(r);
|
|
242
|
+
return createAlova({
|
|
243
|
+
statesHook: vueHook,
|
|
244
|
+
requestAdapter: axiosRequestAdapter(t),
|
|
245
|
+
cacheFor: null,
|
|
246
|
+
timeout: 60 * 1e3,
|
|
247
|
+
...i,
|
|
248
|
+
beforeRequest: async (e) => {
|
|
249
|
+
await hooks.callHook("http:request", e), await n?.(e);
|
|
250
|
+
},
|
|
251
|
+
responded: {
|
|
252
|
+
onSuccess: async (e, t) => {
|
|
253
|
+
let n = !1, r = await hooks.callHookWith(async (e, r) => {
|
|
254
|
+
let i = r[0];
|
|
255
|
+
for (let r of e) {
|
|
256
|
+
if (n) break;
|
|
257
|
+
i = await r(i, t, () => n = !0);
|
|
258
|
+
}
|
|
259
|
+
return i;
|
|
260
|
+
}, "http:response:onSuccess", [e]);
|
|
261
|
+
return n ? r : a?.onSuccess?.(r, t, () => n = !0) ?? r;
|
|
262
|
+
},
|
|
263
|
+
onError: async (e, t) => (await hooks.callHook("http:response:onError", e, t), a?.onError?.(e, t)),
|
|
264
|
+
onComplete: async (e) => {
|
|
265
|
+
await hooks.callHook("http:response:onComplete", e), a?.onComplete?.(e);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
export { getPersistedState as _, setupPage as a, getAllIconModules as c, setupIcon as d, readProjectModules as f, createContext$1 as g, clearPersistedState as h, getAllRouteModules as i, getCachedIcon as l, callHookSync as m, createApp$1 as n, setupDefaultLayout as o, callHookAsync as p, defineRouteModule as r, defineIconModule as s, createRequest as t, setCachedIcon as u, getPubinfoNamespace as v, setPersistedState as y };
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __defProp = Object.defineProperty, __exportAll = (t, n) => {
|
|
2
|
+
let r = {};
|
|
3
|
+
for (var i in t) __defProp(r, i, {
|
|
4
|
+
get: t[i],
|
|
5
|
+
enumerable: !0
|
|
6
|
+
});
|
|
7
|
+
return n || __defProp(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
8
|
+
}, ShikiError = class extends Error {
|
|
3
9
|
constructor(e) {
|
|
4
10
|
super(e), this.name = "ShikiError";
|
|
5
11
|
}
|
|
@@ -12,7 +18,7 @@ function doClone(e) {
|
|
|
12
18
|
}
|
|
13
19
|
function cloneArray(e) {
|
|
14
20
|
let t = [];
|
|
15
|
-
for (let n = 0,
|
|
21
|
+
for (let n = 0, r = e.length; n < r; n++) t[n] = doClone(e[n]);
|
|
16
22
|
return t;
|
|
17
23
|
}
|
|
18
24
|
function cloneObj(e) {
|
|
@@ -3371,20 +3377,20 @@ function splitTokens(e, t) {
|
|
|
3371
3377
|
return t.length ? splitToken(e, t) : e;
|
|
3372
3378
|
})) : e;
|
|
3373
3379
|
}
|
|
3374
|
-
function flatTokenVariants(e,
|
|
3380
|
+
function flatTokenVariants(e, t, r, i, a = "css-vars") {
|
|
3375
3381
|
let o = {
|
|
3376
3382
|
content: e.content,
|
|
3377
3383
|
explanation: e.explanation,
|
|
3378
3384
|
offset: e.offset
|
|
3379
|
-
}, s =
|
|
3380
|
-
let i =
|
|
3381
|
-
return r +
|
|
3385
|
+
}, s = t.map((t) => getTokenStyleObject(e.variants[t])), c = new Set(s.flatMap((e) => Object.keys(e))), l = {}, u = (e, n) => {
|
|
3386
|
+
let i = n === "color" ? "" : n === "background-color" ? "-bg" : `-${n}`;
|
|
3387
|
+
return r + t[e] + (n === "color" ? "" : i);
|
|
3382
3388
|
};
|
|
3383
3389
|
return s.forEach((e, r) => {
|
|
3384
3390
|
for (let o of c) {
|
|
3385
3391
|
let c = e[o] || "inherit";
|
|
3386
3392
|
if (r === 0 && i && COLOR_KEYS.includes(o)) if (i === DEFAULT_COLOR_LIGHT_DARK && s.length > 1) {
|
|
3387
|
-
let e =
|
|
3393
|
+
let e = t.findIndex((e) => e === "light"), i = t.findIndex((e) => e === "dark");
|
|
3388
3394
|
if (e === -1 || i === -1) throw new ShikiError("When using `defaultColor: \"light-dark()\"`, you must provide both `light` and `dark` themes");
|
|
3389
3395
|
l[o] = `light-dark(${s[e][o] || "inherit"}, ${s[i][o] || "inherit"})`, a === "css-vars" && (l[u(r, o)] = c);
|
|
3390
3396
|
} else l[o] = c;
|
|
@@ -3460,57 +3466,57 @@ function getScopes(e) {
|
|
|
3460
3466
|
}
|
|
3461
3467
|
return r(e), t;
|
|
3462
3468
|
}
|
|
3463
|
-
function getGrammarStack(e,
|
|
3469
|
+
function getGrammarStack(e, t) {
|
|
3464
3470
|
if (!(e instanceof GrammarState)) throw new ShikiError("Invalid grammar state");
|
|
3465
|
-
return e.getInternalStack(
|
|
3471
|
+
return e.getInternalStack(t);
|
|
3466
3472
|
}
|
|
3467
3473
|
function transformerDecorations() {
|
|
3468
3474
|
let e = /* @__PURE__ */ new WeakMap();
|
|
3469
|
-
function
|
|
3470
|
-
if (!e.has(
|
|
3475
|
+
function t(t) {
|
|
3476
|
+
if (!e.has(t.meta)) {
|
|
3471
3477
|
let r = function(e) {
|
|
3472
3478
|
if (typeof e == "number") {
|
|
3473
|
-
if (e < 0 || e >
|
|
3479
|
+
if (e < 0 || e > t.source.length) throw new ShikiError(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);
|
|
3474
3480
|
return {
|
|
3475
3481
|
...i.indexToPos(e),
|
|
3476
3482
|
offset: e
|
|
3477
3483
|
};
|
|
3478
3484
|
} else {
|
|
3479
|
-
let
|
|
3480
|
-
if (
|
|
3485
|
+
let t = i.lines[e.line];
|
|
3486
|
+
if (t === void 0) throw new ShikiError(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${i.lines.length}`);
|
|
3481
3487
|
let r = e.character;
|
|
3482
|
-
if (r < 0 && (r =
|
|
3488
|
+
if (r < 0 && (r = t.length + r), r < 0 || r > t.length) throw new ShikiError(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);
|
|
3483
3489
|
return {
|
|
3484
3490
|
...e,
|
|
3485
3491
|
character: r,
|
|
3486
3492
|
offset: i.posToIndex(e.line, r)
|
|
3487
3493
|
};
|
|
3488
3494
|
}
|
|
3489
|
-
}, i = createPositionConverter(
|
|
3495
|
+
}, i = createPositionConverter(t.source), a = (t.options.decorations || []).map((e) => ({
|
|
3490
3496
|
...e,
|
|
3491
3497
|
start: r(e.start),
|
|
3492
3498
|
end: r(e.end)
|
|
3493
3499
|
}));
|
|
3494
|
-
verifyIntersections(a), e.set(
|
|
3500
|
+
verifyIntersections(a), e.set(t.meta, {
|
|
3495
3501
|
decorations: a,
|
|
3496
3502
|
converter: i,
|
|
3497
|
-
source:
|
|
3503
|
+
source: t.source
|
|
3498
3504
|
});
|
|
3499
3505
|
}
|
|
3500
|
-
return e.get(
|
|
3506
|
+
return e.get(t.meta);
|
|
3501
3507
|
}
|
|
3502
3508
|
return {
|
|
3503
3509
|
name: "shiki:decorations",
|
|
3504
3510
|
tokens(e) {
|
|
3505
|
-
if (this.options.decorations?.length) return splitTokens(e,
|
|
3511
|
+
if (this.options.decorations?.length) return splitTokens(e, t(this).decorations.flatMap((e) => [e.start.offset, e.end.offset]));
|
|
3506
3512
|
},
|
|
3507
3513
|
code(e) {
|
|
3508
3514
|
if (!this.options.decorations?.length) return;
|
|
3509
|
-
let r =
|
|
3515
|
+
let r = t(this), i = Array.from(e.children).filter((e) => e.type === "element" && e.tagName === "span");
|
|
3510
3516
|
if (i.length !== r.converter.lines.length) throw new ShikiError(`Number of lines in code element (${i.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);
|
|
3511
|
-
function a(e,
|
|
3517
|
+
function a(e, t, r, a) {
|
|
3512
3518
|
let o = i[e], c = "", l = -1, u = -1;
|
|
3513
|
-
if (
|
|
3519
|
+
if (t === 0 && (l = 0), r === 0 && (u = 0), r === Infinity && (u = o.children.length), l === -1 || u === -1) for (let e = 0; e < o.children.length; e++) c += stringify(o.children[e]), l === -1 && c.length === t && (l = e + 1), u === -1 && c.length === r && (u = e + 1);
|
|
3514
3520
|
if (l === -1) throw new ShikiError(`Failed to find start index for decoration ${JSON.stringify(a.start)}`);
|
|
3515
3521
|
if (u === -1) throw new ShikiError(`Failed to find end index for decoration ${JSON.stringify(a.end)}`);
|
|
3516
3522
|
let d = o.children.slice(l, u);
|
|
@@ -3552,14 +3558,14 @@ function transformerDecorations() {
|
|
|
3552
3558
|
};
|
|
3553
3559
|
}
|
|
3554
3560
|
function verifyIntersections(e) {
|
|
3555
|
-
for (let
|
|
3556
|
-
let r = e[
|
|
3561
|
+
for (let t = 0; t < e.length; t++) {
|
|
3562
|
+
let r = e[t];
|
|
3557
3563
|
if (r.start.offset > r.end.offset) throw new ShikiError(`Invalid decoration range: ${JSON.stringify(r.start)} - ${JSON.stringify(r.end)}`);
|
|
3558
|
-
for (let i =
|
|
3559
|
-
let
|
|
3564
|
+
for (let i = t + 1; i < e.length; i++) {
|
|
3565
|
+
let t = e[i], a = r.start.offset <= t.start.offset && t.start.offset < r.end.offset, o = r.start.offset < t.end.offset && t.end.offset <= r.end.offset, s = t.start.offset <= r.start.offset && r.start.offset < t.end.offset, c = t.start.offset < r.end.offset && r.end.offset <= t.end.offset;
|
|
3560
3566
|
if (a || o || s || c) {
|
|
3561
|
-
if (a && o || s && c || s && r.start.offset === r.end.offset || o &&
|
|
3562
|
-
throw new ShikiError(`Decorations ${JSON.stringify(r.start)} and ${JSON.stringify(
|
|
3567
|
+
if (a && o || s && c || s && r.start.offset === r.end.offset || o && t.start.offset === t.end.offset) continue;
|
|
3568
|
+
throw new ShikiError(`Decorations ${JSON.stringify(r.start)} and ${JSON.stringify(t.start)} intersect.`);
|
|
3563
3569
|
}
|
|
3564
3570
|
}
|
|
3565
3571
|
}
|
|
@@ -3856,27 +3862,27 @@ function dimColor(e) {
|
|
|
3856
3862
|
let n = e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);
|
|
3857
3863
|
return n ? `var(${n[1]}-dim)` : e;
|
|
3858
3864
|
}
|
|
3859
|
-
function codeToTokensBase(e,
|
|
3865
|
+
function codeToTokensBase(e, t, r = {}) {
|
|
3860
3866
|
let { theme: i = e.getLoadedThemes()[0] } = r, a = e.resolveLangAlias(r.lang || "text");
|
|
3861
|
-
if (isPlainLang(a) || isNoneTheme(i)) return splitLines(
|
|
3867
|
+
if (isPlainLang(a) || isNoneTheme(i)) return splitLines(t).map((e) => [{
|
|
3862
3868
|
content: e[0],
|
|
3863
3869
|
offset: e[1]
|
|
3864
3870
|
}]);
|
|
3865
3871
|
let { theme: o, colorMap: s } = e.setTheme(i);
|
|
3866
|
-
if (a === "ansi") return tokenizeAnsiWithTheme(o,
|
|
3872
|
+
if (a === "ansi") return tokenizeAnsiWithTheme(o, t, r);
|
|
3867
3873
|
let c = e.getLanguage(r.lang || "text");
|
|
3868
3874
|
if (r.grammarState) {
|
|
3869
3875
|
if (r.grammarState.lang !== c.name) throw new ShikiError(`Grammar state language "${r.grammarState.lang}" does not match highlight language "${c.name}"`);
|
|
3870
3876
|
if (!r.grammarState.themes.includes(o.name)) throw new ShikiError(`Grammar state themes "${r.grammarState.themes}" do not contain highlight theme "${o.name}"`);
|
|
3871
3877
|
}
|
|
3872
|
-
return tokenizeWithTheme(
|
|
3878
|
+
return tokenizeWithTheme(t, c, o, s, r);
|
|
3873
3879
|
}
|
|
3874
3880
|
function getLastGrammarState(...e) {
|
|
3875
3881
|
if (e.length === 2) return getLastGrammarStateFromMap(e[1]);
|
|
3876
|
-
let [
|
|
3882
|
+
let [t, r, i = {}] = e, { lang: a = "text", theme: o = t.getLoadedThemes()[0] } = i;
|
|
3877
3883
|
if (isPlainLang(a) || isNoneTheme(o)) throw new ShikiError("Plain language does not have grammar state");
|
|
3878
3884
|
if (a === "ansi") throw new ShikiError("ANSI language does not have grammar state");
|
|
3879
|
-
let { theme: s, colorMap: c } =
|
|
3885
|
+
let { theme: s, colorMap: c } = t.setTheme(o), l = t.getLanguage(a);
|
|
3880
3886
|
return new GrammarState(_tokenizeWithTheme(r, l, s, c, i).stateStack, l.name, s.name);
|
|
3881
3887
|
}
|
|
3882
3888
|
function tokenizeWithTheme(e, t, n, r, i) {
|
|
@@ -4034,7 +4040,7 @@ function syncThemesTokenization(...e) {
|
|
|
4034
4040
|
}
|
|
4035
4041
|
return t;
|
|
4036
4042
|
}
|
|
4037
|
-
function codeToTokens(e,
|
|
4043
|
+
function codeToTokens(e, t, r) {
|
|
4038
4044
|
let i, a, o, s, c, l;
|
|
4039
4045
|
if ("themes" in r) {
|
|
4040
4046
|
let { defaultColor: u = "light", cssVariablePrefix: d = "--shiki-", colorsRendering: f = "css-vars" } = r, m = Object.entries(r.themes).filter((e) => e[1]).map((e) => ({
|
|
@@ -4042,17 +4048,17 @@ function codeToTokens(e, n, r) {
|
|
|
4042
4048
|
theme: e[1]
|
|
4043
4049
|
})).sort((e, t) => e.color === u ? -1 : t.color === u ? 1 : 0);
|
|
4044
4050
|
if (m.length === 0) throw new ShikiError("`themes` option must not be empty");
|
|
4045
|
-
let h = codeToTokensWithThemes(e,
|
|
4051
|
+
let h = codeToTokensWithThemes(e, t, r);
|
|
4046
4052
|
if (l = getLastGrammarStateFromMap(h), u && DEFAULT_COLOR_LIGHT_DARK !== u && !m.find((e) => e.color === u)) throw new ShikiError(`\`themes\` option must contain the defaultColor key \`${u}\``);
|
|
4047
4053
|
let g = m.map((t) => e.getTheme(t.theme)), _ = m.map((e) => e.color);
|
|
4048
4054
|
o = h.map((e) => e.map((e) => flatTokenVariants(e, _, d, u, f))), l && setLastGrammarStateToMap(o, l);
|
|
4049
4055
|
let v = m.map((e) => resolveColorReplacements(e.theme, r));
|
|
4050
4056
|
a = mapThemeColors(m, g, v, d, u, "fg", f), i = mapThemeColors(m, g, v, d, u, "bg", f), s = `shiki-themes ${g.map((e) => e.name).join(" ")}`, c = u ? void 0 : [a, i].join(";");
|
|
4051
4057
|
} else if ("theme" in r) {
|
|
4052
|
-
let
|
|
4053
|
-
o = codeToTokensBase(e,
|
|
4058
|
+
let n = resolveColorReplacements(r.theme, r);
|
|
4059
|
+
o = codeToTokensBase(e, t, r);
|
|
4054
4060
|
let c = e.getTheme(r.theme);
|
|
4055
|
-
i = applyColorReplacements(c.bg,
|
|
4061
|
+
i = applyColorReplacements(c.bg, n), a = applyColorReplacements(c.fg, n), s = c.name, l = getLastGrammarStateFromMap(o);
|
|
4056
4062
|
} else throw new ShikiError("Invalid options, either `theme` or `themes` must be provided");
|
|
4057
4063
|
return {
|
|
4058
4064
|
tokens: o,
|
|
@@ -4063,14 +4069,14 @@ function codeToTokens(e, n, r) {
|
|
|
4063
4069
|
grammarState: l
|
|
4064
4070
|
};
|
|
4065
4071
|
}
|
|
4066
|
-
function mapThemeColors(e,
|
|
4072
|
+
function mapThemeColors(e, t, r, i, a, o, s) {
|
|
4067
4073
|
return e.map((c, l) => {
|
|
4068
|
-
let u = applyColorReplacements(
|
|
4074
|
+
let u = applyColorReplacements(t[l][o], r[l]) || "inherit", d = `${i + c.color}${o === "bg" ? "-bg" : ""}:${u}`;
|
|
4069
4075
|
if (l === 0 && a) {
|
|
4070
4076
|
if (a === DEFAULT_COLOR_LIGHT_DARK && e.length > 1) {
|
|
4071
4077
|
let i = e.findIndex((e) => e.color === "light"), a = e.findIndex((e) => e.color === "dark");
|
|
4072
4078
|
if (i === -1 || a === -1) throw new ShikiError("When using `defaultColor: \"light-dark()\"`, you must provide both `light` and `dark` themes");
|
|
4073
|
-
return `light-dark(${applyColorReplacements(
|
|
4079
|
+
return `light-dark(${applyColorReplacements(t[i][o], r[i]) || "inherit"}, ${applyColorReplacements(t[a][o], r[a]) || "inherit"});${d}`;
|
|
4074
4080
|
}
|
|
4075
4081
|
return u;
|
|
4076
4082
|
}
|
|
@@ -4604,12 +4610,12 @@ function makeSingletonHighlighterCore(e) {
|
|
|
4604
4610
|
}
|
|
4605
4611
|
var getSingletonHighlighterCore = /* @__PURE__ */ makeSingletonHighlighterCore(createHighlighterCore);
|
|
4606
4612
|
function createBundledHighlighter(e) {
|
|
4607
|
-
let
|
|
4613
|
+
let t = e.langs, r = e.themes, i = e.engine;
|
|
4608
4614
|
async function a(e) {
|
|
4609
4615
|
function a(r) {
|
|
4610
4616
|
if (typeof r == "string") {
|
|
4611
4617
|
if (r = e.langAlias?.[r] || r, isSpecialLang(r)) return [];
|
|
4612
|
-
let i =
|
|
4618
|
+
let i = t[r];
|
|
4613
4619
|
if (!i) throw new ShikiError(`Language \`${r}\` is not included in this bundle. You may want to load it from external source.`);
|
|
4614
4620
|
return i;
|
|
4615
4621
|
}
|
|
@@ -4618,9 +4624,9 @@ function createBundledHighlighter(e) {
|
|
|
4618
4624
|
function o(e) {
|
|
4619
4625
|
if (isSpecialTheme(e)) return "none";
|
|
4620
4626
|
if (typeof e == "string") {
|
|
4621
|
-
let
|
|
4622
|
-
if (!
|
|
4623
|
-
return
|
|
4627
|
+
let t = r[e];
|
|
4628
|
+
if (!t) throw new ShikiError(`Theme \`${e}\` is not included in this bundle. You may want to load it from external source.`);
|
|
4629
|
+
return t;
|
|
4624
4630
|
}
|
|
4625
4631
|
return e;
|
|
4626
4632
|
}
|
|
@@ -4639,7 +4645,7 @@ function createBundledHighlighter(e) {
|
|
|
4639
4645
|
return l.loadTheme(...e.map(o));
|
|
4640
4646
|
},
|
|
4641
4647
|
getBundledLanguages() {
|
|
4642
|
-
return
|
|
4648
|
+
return t;
|
|
4643
4649
|
},
|
|
4644
4650
|
getBundledThemes() {
|
|
4645
4651
|
return r;
|
|
@@ -4882,4 +4888,4 @@ function createCssVariablesTheme(e = {}) {
|
|
|
4882
4888
|
};
|
|
4883
4889
|
return r || (a.tokenColors = a.tokenColors?.map((e) => (e.settings?.fontStyle && delete e.settings.fontStyle, e))), a;
|
|
4884
4890
|
}
|
|
4885
|
-
export { ShikiError, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createBundledHighlighter, createCssVariablesTheme, createHighlighterCore, createHighlighterCoreSync, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createdBundledHighlighter, enableDeprecationWarnings, flatTokenVariants, getSingletonHighlighterCore, getTokenStyleObject, guessEmbeddedLanguages, hastToHtml, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations, warnDeprecated };
|
|
4891
|
+
export { ShikiError, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createBundledHighlighter, createCssVariablesTheme, createHighlighterCore, createHighlighterCoreSync, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createdBundledHighlighter, enableDeprecationWarnings, flatTokenVariants, getSingletonHighlighterCore, getTokenStyleObject, guessEmbeddedLanguages, hastToHtml, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, splitLines, splitToken, splitTokens, stringifyTokenStyle, __exportAll as t, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations, warnDeprecated };
|