@wsxjs/wsx-press 0.0.18
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/LICENSE +21 -0
- package/dist/client.cjs +1 -0
- package/dist/client.js +1256 -0
- package/dist/index-ChO3PMD5.js +461 -0
- package/dist/index-uNJnOC7n.cjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +8 -0
- package/dist/node.cjs +47 -0
- package/dist/node.js +1708 -0
- package/package.json +90 -0
- package/src/client/components/DocLayout.css +49 -0
- package/src/client/components/DocLayout.wsx +92 -0
- package/src/client/components/DocPage.css +56 -0
- package/src/client/components/DocPage.wsx +480 -0
- package/src/client/components/DocSearch.css +113 -0
- package/src/client/components/DocSearch.wsx +328 -0
- package/src/client/components/DocSidebar.css +97 -0
- package/src/client/components/DocSidebar.wsx +173 -0
- package/src/client/components/DocTOC.css +105 -0
- package/src/client/components/DocTOC.wsx +262 -0
- package/src/client/index.ts +32 -0
- package/src/client/styles/code.css +242 -0
- package/src/client/styles/index.css +12 -0
- package/src/client/styles/reset.css +116 -0
- package/src/client/styles/theme.css +171 -0
- package/src/client/styles/typography.css +239 -0
- package/src/index.ts +26 -0
- package/src/node/index.ts +16 -0
- package/src/node/metadata.ts +113 -0
- package/src/node/plugin.ts +223 -0
- package/src/node/search.ts +53 -0
- package/src/node/toc.ts +148 -0
- package/src/node/typedoc.ts +96 -0
- package/src/types/wsx.d.ts +11 -0
- package/src/types.test.ts +118 -0
- package/src/types.ts +150 -0
package/dist/client.js
ADDED
|
@@ -0,0 +1,1256 @@
|
|
|
1
|
+
import { autoRegister as se, LightComponent as X, jsx as w } from "@wsxjs/wsx-core";
|
|
2
|
+
import { L as ae } from "./index-ChO3PMD5.js";
|
|
3
|
+
import "@wsxjs/wsx-marked-components";
|
|
4
|
+
import { RouterUtils as re } from "@wsxjs/wsx-router";
|
|
5
|
+
import { DocumentLoadError as ie } from "./index.js";
|
|
6
|
+
import le from "fuse.js";
|
|
7
|
+
const ue = ".wsx-doc-page{display:flex;flex-direction:column;min-height:100%}.doc-page{flex:1;padding:var(--doc-page-padding-y, 1rem) var(--doc-page-padding-x, 2rem);max-width:1200px;margin:0 auto;width:100%}.doc-loading,.doc-empty{text-align:center;padding:3rem;color:var(--wsx-press-text-secondary, #666)}.doc-error{padding:2rem;background:var(--wsx-press-error-bg, #fee);border:1px solid var(--wsx-press-error-border, #fcc);border-radius:4px;color:var(--wsx-press-error-text, #c33)}.doc-error h2{margin-top:0;color:var(--wsx-press-error-title, #a00)}.doc-header{margin-bottom:2rem;padding-bottom:1rem;border-bottom:1px solid var(--wsx-press-border, #ddd)}.doc-title{margin:0 0 .5rem;font-size:2rem;font-weight:600;color:var(--wsx-press-text-primary, #333)}.doc-description{margin:0;color:var(--wsx-press-text-secondary, #666);font-size:1.1rem}.doc-content{line-height:1.6}";
|
|
8
|
+
var we;
|
|
9
|
+
let Ce, Se;
|
|
10
|
+
function G(t, e, r) {
|
|
11
|
+
return (e = De(e)) in t ? Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = r, t;
|
|
12
|
+
}
|
|
13
|
+
function Ue(t, e, r, s, f, I) {
|
|
14
|
+
function g(i, c, u) {
|
|
15
|
+
return function(n, a) {
|
|
16
|
+
return u && u(n), i[c].call(n, a);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function x(i, c) {
|
|
20
|
+
for (var u = 0; u < i.length; u++) i[u].call(c);
|
|
21
|
+
return c;
|
|
22
|
+
}
|
|
23
|
+
function v(i, c, u, n) {
|
|
24
|
+
if (typeof i != "function" && (n || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (n ? "" : " or undefined"));
|
|
25
|
+
return i;
|
|
26
|
+
}
|
|
27
|
+
function M(i, c, u, n, a, L, k, T, z, C, y, m, p) {
|
|
28
|
+
function S(l) {
|
|
29
|
+
if (!p(l)) throw new TypeError("Attempted to access private element on non-instance");
|
|
30
|
+
}
|
|
31
|
+
var d, D = c[0], E = c[3], j = !T;
|
|
32
|
+
if (!j) {
|
|
33
|
+
u || Array.isArray(D) || (D = [D]);
|
|
34
|
+
var o = {}, _ = [], b = a === 3 ? "get" : a === 4 || m ? "set" : "value";
|
|
35
|
+
C ? (y || m ? o = { get: de(function() {
|
|
36
|
+
return E(this);
|
|
37
|
+
}, n, "get"), set: function(l) {
|
|
38
|
+
c[4](this, l);
|
|
39
|
+
} } : o[b] = E, y || de(o[b], n, a === 2 ? "" : b)) : y || (o = Object.getOwnPropertyDescriptor(i, n));
|
|
40
|
+
}
|
|
41
|
+
for (var h = i, q = D.length - 1; q >= 0; q -= u ? 2 : 1) {
|
|
42
|
+
var H = D[q], K = u ? D[q - 1] : void 0, B = {}, R = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: n, metadata: L, addInitializer: (function(l, O) {
|
|
43
|
+
if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
44
|
+
v(O, "An initializer", "be", !0), k.push(O);
|
|
45
|
+
}).bind(null, B) };
|
|
46
|
+
try {
|
|
47
|
+
if (j) (d = v(H.call(K, h, R), "class decorators", "return")) && (h = d);
|
|
48
|
+
else {
|
|
49
|
+
var A, F;
|
|
50
|
+
R.static = z, R.private = C, C ? a === 2 ? A = function(l) {
|
|
51
|
+
return S(l), o.value;
|
|
52
|
+
} : (a < 4 && (A = g(o, "get", S)), a !== 3 && (F = g(o, "set", S))) : (A = function(l) {
|
|
53
|
+
return l[n];
|
|
54
|
+
}, (a < 2 || a === 4) && (F = function(l, O) {
|
|
55
|
+
l[n] = O;
|
|
56
|
+
}));
|
|
57
|
+
var W = R.access = { has: C ? p.bind() : function(l) {
|
|
58
|
+
return n in l;
|
|
59
|
+
} };
|
|
60
|
+
if (A && (W.get = A), F && (W.set = F), h = H.call(K, m ? { get: o.get, set: o.set } : o[b], R), m) {
|
|
61
|
+
if (typeof h == "object" && h) (d = v(h.get, "accessor.get")) && (o.get = d), (d = v(h.set, "accessor.set")) && (o.set = d), (d = v(h.init, "accessor.init")) && _.push(d);
|
|
62
|
+
else if (h !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
63
|
+
} else v(h, (y ? "field" : "method") + " decorators", "return") && (y ? _.push(h) : o[b] = h);
|
|
64
|
+
}
|
|
65
|
+
} finally {
|
|
66
|
+
B.v = !0;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return (y || m) && T.push(function(l, O) {
|
|
70
|
+
for (var N = _.length - 1; N >= 0; N--) O = _[N].call(l, O);
|
|
71
|
+
return O;
|
|
72
|
+
}), y || j || (C ? m ? T.push(g(o, "get"), g(o, "set")) : T.push(a === 2 ? o[b] : g.call.bind(o[b])) : Object.defineProperty(i, n, o)), h;
|
|
73
|
+
}
|
|
74
|
+
function $(i, c) {
|
|
75
|
+
return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
|
|
76
|
+
}
|
|
77
|
+
if (arguments.length >= 6) var U = I[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
78
|
+
var P = Object.create(U ?? null), Z = function(i, c, u, n) {
|
|
79
|
+
var a, L, k = [], T = function(b) {
|
|
80
|
+
return Ke(b) === i;
|
|
81
|
+
}, z = /* @__PURE__ */ new Map();
|
|
82
|
+
function C(b) {
|
|
83
|
+
b && k.push(x.bind(null, b));
|
|
84
|
+
}
|
|
85
|
+
for (var y = 0; y < c.length; y++) {
|
|
86
|
+
var m = c[y];
|
|
87
|
+
if (Array.isArray(m)) {
|
|
88
|
+
var p = m[1], S = m[2], d = m.length > 3, D = 16 & p, E = !!(8 & p), j = (p &= 7) == 0, o = S + "/" + E;
|
|
89
|
+
if (!j && !d) {
|
|
90
|
+
var _ = z.get(o);
|
|
91
|
+
if (_ === !0 || _ === 3 && p !== 4 || _ === 4 && p !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + S);
|
|
92
|
+
z.set(o, !(p > 2) || p);
|
|
93
|
+
}
|
|
94
|
+
M(E ? i : i.prototype, m, D, d ? "#" + S : De(S), p, n, E ? L = L || [] : a = a || [], k, E, d, j, p === 1, E && d ? T : u);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return C(a), C(L), k;
|
|
98
|
+
}(t, e, f, P);
|
|
99
|
+
return r.length || $(t, P), { e: Z, get c() {
|
|
100
|
+
var i = [];
|
|
101
|
+
return r.length && [$(M(t, [r], s, t.name, 5, P, i), P), x.bind(null, i, t)];
|
|
102
|
+
} };
|
|
103
|
+
}
|
|
104
|
+
function De(t) {
|
|
105
|
+
var e = He(t, "string");
|
|
106
|
+
return typeof e == "symbol" ? e : e + "";
|
|
107
|
+
}
|
|
108
|
+
function He(t, e) {
|
|
109
|
+
if (typeof t != "object" || !t) return t;
|
|
110
|
+
var r = t[Symbol.toPrimitive];
|
|
111
|
+
if (r !== void 0) {
|
|
112
|
+
var s = r.call(t, e);
|
|
113
|
+
if (typeof s != "object") return s;
|
|
114
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
115
|
+
}
|
|
116
|
+
return String(t);
|
|
117
|
+
}
|
|
118
|
+
function de(t, e, r) {
|
|
119
|
+
typeof e == "symbol" && (e = (e = e.description) ? "[" + e + "]" : "");
|
|
120
|
+
try {
|
|
121
|
+
Object.defineProperty(t, "name", { configurable: !0, value: r ? r + " " + e : e });
|
|
122
|
+
} catch {
|
|
123
|
+
}
|
|
124
|
+
return t;
|
|
125
|
+
}
|
|
126
|
+
function Ke(t) {
|
|
127
|
+
if (Object(t) !== t) throw TypeError("right-hand side of 'in' should be an object, got " + (t !== null ? typeof t : "null"));
|
|
128
|
+
return t;
|
|
129
|
+
}
|
|
130
|
+
const J = ae("DocPage"), Y = {
|
|
131
|
+
data: null,
|
|
132
|
+
promise: null
|
|
133
|
+
};
|
|
134
|
+
async function Ee(t, e = {}, r = 1e4) {
|
|
135
|
+
var g;
|
|
136
|
+
const s = new AbortController(), f = setTimeout(() => s.abort(), r);
|
|
137
|
+
let I;
|
|
138
|
+
if (e.signal) {
|
|
139
|
+
const x = new AbortController();
|
|
140
|
+
e.signal.aborted ? x.abort() : e.signal.addEventListener("abort", () => {
|
|
141
|
+
x.abort();
|
|
142
|
+
}), s.signal.addEventListener("abort", () => {
|
|
143
|
+
x.abort();
|
|
144
|
+
}), I = x.signal;
|
|
145
|
+
} else
|
|
146
|
+
I = s.signal;
|
|
147
|
+
try {
|
|
148
|
+
const x = await fetch(t, {
|
|
149
|
+
...e,
|
|
150
|
+
signal: I
|
|
151
|
+
});
|
|
152
|
+
return clearTimeout(f), x;
|
|
153
|
+
} catch (x) {
|
|
154
|
+
if (clearTimeout(f), x instanceof Error && x.name === "AbortError") {
|
|
155
|
+
const v = s.signal.aborted;
|
|
156
|
+
throw ((g = e.signal) == null ? void 0 : g.aborted) ? new Error("Request was cancelled") : v ? new Error(`Request timeout after ${r}ms`) : new Error("Request was aborted");
|
|
157
|
+
}
|
|
158
|
+
throw x;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async function Be() {
|
|
162
|
+
return Y.data ? Y.data : (Y.promise || (Y.promise = (async () => {
|
|
163
|
+
try {
|
|
164
|
+
const t = await Ee("/.wsx-press/docs-meta.json", {}, 5e3);
|
|
165
|
+
if (!t.ok)
|
|
166
|
+
throw new Error(`Failed to load metadata: ${t.statusText}`);
|
|
167
|
+
const e = await t.json();
|
|
168
|
+
return Y.data = e, Y.promise = null, e;
|
|
169
|
+
} catch (t) {
|
|
170
|
+
throw Y.promise = null, t;
|
|
171
|
+
}
|
|
172
|
+
})()), Y.promise);
|
|
173
|
+
}
|
|
174
|
+
Se = [se({
|
|
175
|
+
tagName: "wsx-doc-page"
|
|
176
|
+
})];
|
|
177
|
+
let We;
|
|
178
|
+
class Ye extends X {
|
|
179
|
+
constructor() {
|
|
180
|
+
super({
|
|
181
|
+
styles: ue,
|
|
182
|
+
styleName: "wsx-doc-page"
|
|
183
|
+
}), G(this, "_autoStyles", ue), G(this, "loadingState", void 0), G(this, "markdown", void 0), G(this, "metadata", void 0), G(this, "error", void 0), G(this, "currentLoadingPath", null), G(this, "routeChangeUnsubscribe", null), G(this, "loadingAbortController", null), G(this, "isLoading", !1), G(this, "visibilityChangeHandler", null), J.debug("DocPage initialized");
|
|
184
|
+
const [e, r] = this.useState("loadingState", "idle");
|
|
185
|
+
Object.defineProperty(this, "loadingState", {
|
|
186
|
+
get: e,
|
|
187
|
+
set: r,
|
|
188
|
+
enumerable: !0,
|
|
189
|
+
configurable: !0
|
|
190
|
+
});
|
|
191
|
+
const [s, f] = this.useState("markdown", "");
|
|
192
|
+
Object.defineProperty(this, "markdown", {
|
|
193
|
+
get: s,
|
|
194
|
+
set: f,
|
|
195
|
+
enumerable: !0,
|
|
196
|
+
configurable: !0
|
|
197
|
+
});
|
|
198
|
+
const [I, g] = this.useState("metadata", null);
|
|
199
|
+
Object.defineProperty(this, "metadata", {
|
|
200
|
+
get: I,
|
|
201
|
+
set: g,
|
|
202
|
+
enumerable: !0,
|
|
203
|
+
configurable: !0
|
|
204
|
+
});
|
|
205
|
+
const [x, v] = this.useState("error", null);
|
|
206
|
+
Object.defineProperty(this, "error", {
|
|
207
|
+
get: x,
|
|
208
|
+
set: v,
|
|
209
|
+
enumerable: !0,
|
|
210
|
+
configurable: !0
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
onConnected() {
|
|
214
|
+
this.routeChangeUnsubscribe = re.onRouteChange(() => {
|
|
215
|
+
this.cancelLoading(), this.loadDocument();
|
|
216
|
+
}), this.visibilityChangeHandler = () => {
|
|
217
|
+
document.hidden ? this.cancelLoading() : this.loadingState === "loading" && this.currentLoadingPath && (J.debug("Tab became visible, reloading document"), this.loadDocument());
|
|
218
|
+
}, document.addEventListener("visibilitychange", this.visibilityChangeHandler), requestAnimationFrame(() => {
|
|
219
|
+
requestAnimationFrame(() => {
|
|
220
|
+
this.loadDocument();
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
onDisconnected() {
|
|
225
|
+
this.routeChangeUnsubscribe && (this.routeChangeUnsubscribe(), this.routeChangeUnsubscribe = null), this.visibilityChangeHandler && (document.removeEventListener("visibilitychange", this.visibilityChangeHandler), this.visibilityChangeHandler = null), this.cancelLoading();
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* 取消正在进行的加载请求
|
|
229
|
+
*/
|
|
230
|
+
cancelLoading() {
|
|
231
|
+
this.loadingAbortController && (this.loadingAbortController.abort(), this.loadingAbortController = null), this.isLoading = !1, this.loadingState === "loading" && (this.loadingState = "idle"), this.currentLoadingPath = null;
|
|
232
|
+
}
|
|
233
|
+
onAttributeChanged(e, r, s) {
|
|
234
|
+
e === "params" && this.loadDocument();
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* 创建带超时的 fetch 请求(实例方法)
|
|
238
|
+
*/
|
|
239
|
+
async fetchWithTimeout(e, r = {}, s = 1e4) {
|
|
240
|
+
return Ee(e, r, s);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* 从 RouterUtils 获取当前路由参数并加载文档
|
|
244
|
+
*/
|
|
245
|
+
async loadDocument() {
|
|
246
|
+
this.cancelLoading();
|
|
247
|
+
try {
|
|
248
|
+
this.loadingAbortController = new AbortController();
|
|
249
|
+
const e = re.getCurrentRoute(), r = e.params;
|
|
250
|
+
if (!r.category || !r.page) {
|
|
251
|
+
if (J.warn("Missing route parameters:", {
|
|
252
|
+
params: r,
|
|
253
|
+
routeInfo: e
|
|
254
|
+
}), Object.keys(r).length === 0) {
|
|
255
|
+
J.debug("Route params not yet initialized, keeping idle state"), this.loadingState = "idle";
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
this.loadingState = "error", this.error = new ie("Missing route parameters: category and page are required", "INVALID_PARAMS");
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const s = `${r.category}/${r.page}`;
|
|
262
|
+
this.currentLoadingPath = s, this.isLoading = !0, this.loadingState = "loading", this.markdown = "", this.error = null, this.metadata = null;
|
|
263
|
+
const f = await Be();
|
|
264
|
+
if (this.currentLoadingPath !== s || this.loadingAbortController.signal.aborted) {
|
|
265
|
+
J.debug(`Document switched after metadata, ignoring result for ${s}`), this.isLoading = !1, this.loadingState = "idle";
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const I = f[s];
|
|
269
|
+
if (!I) {
|
|
270
|
+
if (this.currentLoadingPath !== s || this.loadingAbortController.signal.aborted) {
|
|
271
|
+
this.isLoading = !1, this.loadingState = "idle";
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
this.loadingState = "error", this.error = new ie(`Document not found: ${s}`, "NOT_FOUND"), this.isLoading = !1;
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
this.metadata = I;
|
|
278
|
+
const g = `/docs/${s}.md`, x = await this.fetchWithTimeout(g, {
|
|
279
|
+
signal: this.loadingAbortController.signal
|
|
280
|
+
}, 1e4);
|
|
281
|
+
if (this.currentLoadingPath !== s || this.loadingAbortController.signal.aborted) {
|
|
282
|
+
J.debug(`Document switched during fetch, ignoring result for ${s}`), this.isLoading = !1, this.loadingState = "idle";
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (!x.ok) {
|
|
286
|
+
x.status === 404 ? (this.loadingState = "error", this.error = new ie(`Document file not found: ${g}`, "NOT_FOUND")) : (this.loadingState = "error", this.error = new ie(`Failed to load document: ${x.statusText}`, "NETWORK_ERROR", {
|
|
287
|
+
status: x.status
|
|
288
|
+
})), this.isLoading = !1;
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const v = await x.text();
|
|
292
|
+
if (this.currentLoadingPath !== s || this.loadingAbortController.signal.aborted) {
|
|
293
|
+
J.debug(`Document switched after fetch, ignoring result for ${s}`), this.isLoading = !1, this.loadingState = "idle";
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
this.markdown = v, this.loadingState = "success", this.isLoading = !1, requestAnimationFrame(() => {
|
|
297
|
+
requestAnimationFrame(() => {
|
|
298
|
+
this.connected && this.scheduleRerender();
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
} catch (e) {
|
|
302
|
+
if (this.isLoading = !1, e instanceof Error && e.name === "AbortError") {
|
|
303
|
+
J.debug("Document loading was cancelled"), this.currentLoadingPath && (this.loadingState = "idle", this.currentLoadingPath = null);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (!this.currentLoadingPath) {
|
|
307
|
+
this.loadingState = "error", this.error = new ie(`Failed to load document: ${e instanceof Error ? e.message : String(e)}`, "NETWORK_ERROR", e), J.error("Failed to load document (no current path):", e);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const r = this.currentLoadingPath;
|
|
311
|
+
if (this.currentLoadingPath !== r) {
|
|
312
|
+
this.loadingState = "idle";
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
this.loadingState = "error", this.error = new ie(`Failed to load document: ${e instanceof Error ? e.message : String(e)}`, "NETWORK_ERROR", e), J.error("Failed to load document", e), requestAnimationFrame(() => {
|
|
316
|
+
requestAnimationFrame(() => {
|
|
317
|
+
this.connected && this.scheduleRerender();
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
render() {
|
|
323
|
+
var e, r;
|
|
324
|
+
return this.loadingState === "loading" ? /* @__PURE__ */ w("div", { class: "doc-page" }, /* @__PURE__ */ w("div", { class: "doc-loading" }, "加载文档中...")) : this.loadingState === "error" ? /* @__PURE__ */ w("div", { class: "doc-page" }, /* @__PURE__ */ w("div", { class: "doc-error" }, /* @__PURE__ */ w("h2", null, "加载失败"), /* @__PURE__ */ w("p", null, ((e = this.error) == null ? void 0 : e.message) || "未知错误"), ((r = this.error) == null ? void 0 : r.code) === "NOT_FOUND" && /* @__PURE__ */ w("p", null, "文档不存在,请检查路径是否正确。"))) : this.loadingState === "success" && this.markdown ? /* @__PURE__ */ w("div", { class: "doc-page" }, this.metadata && /* @__PURE__ */ w("div", { class: "doc-header" }, /* @__PURE__ */ w("h1", { class: "doc-title" }, this.metadata.title), this.metadata.description && /* @__PURE__ */ w("p", { class: "doc-description" }, this.metadata.description)), /* @__PURE__ */ w("div", { class: "doc-content" }, /* @__PURE__ */ w("wsx-markdown", { markdown: this.markdown }))) : /* @__PURE__ */ w("div", { class: "doc-page" }, /* @__PURE__ */ w("div", { class: "doc-empty" }, "请选择文档"));
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
we = Ye;
|
|
328
|
+
[We, Ce] = Ue(we, [], Se, 0, void 0, X).c;
|
|
329
|
+
Ce();
|
|
330
|
+
const he = ".wsx-doc-search{position:relative;width:100%;max-width:600px}.search-input-wrapper{position:relative}.search-input{width:100%;padding:.75rem 1rem;font-size:1rem;border:1px solid var(--wsx-press-border, #ddd);border-radius:4px;outline:none;transition:border-color .2s}.search-input:focus{border-color:var(--wsx-press-primary, #007bff);box-shadow:0 0 0 3px var(--wsx-press-primary-alpha, rgba(0, 123, 255, .1))}.search-loading{position:absolute;right:1rem;top:50%;transform:translateY(-50%);color:var(--wsx-press-text-secondary, #666);font-size:.875rem}.search-results{position:absolute;top:100%;left:0;right:0;margin-top:.5rem;background:var(--wsx-press-bg, #fff);border:1px solid var(--wsx-press-border, #ddd);border-radius:4px;box-shadow:0 4px 6px #0000001a;max-height:400px;overflow-y:auto;z-index:1000}.search-result{padding:1rem;border-bottom:1px solid var(--wsx-press-border-light, #f0f0f0);cursor:pointer;transition:background-color .2s}.search-result:last-child{border-bottom:none}.search-result:hover,.search-result.selected{background-color:var(--wsx-press-hover-bg, #f5f5f5)}.result-title{font-weight:600;color:var(--wsx-press-text-primary, #333);margin-bottom:.25rem}.result-title mark{background-color:var(--wsx-press-highlight-bg, #ffeb3b);color:var(--wsx-press-highlight-text, #000);padding:0 2px;border-radius:2px}.result-category{font-size:.875rem;color:var(--wsx-press-text-secondary, #666);margin-bottom:.5rem}.result-snippet{font-size:.875rem;color:var(--wsx-press-text-secondary, #666);line-height:1.4}.result-snippet mark{background-color:var(--wsx-press-highlight-bg, #ffeb3b);color:var(--wsx-press-highlight-text, #000);padding:0 2px;border-radius:2px}.search-no-results{position:absolute;top:100%;left:0;right:0;margin-top:.5rem;padding:1rem;background:var(--wsx-press-bg, #fff);border:1px solid var(--wsx-press-border, #ddd);border-radius:4px;box-shadow:0 4px 6px #0000001a;text-align:center;color:var(--wsx-press-text-secondary, #666);z-index:1000}";
|
|
331
|
+
var _e;
|
|
332
|
+
let Oe, Ie;
|
|
333
|
+
function Q(t, e, r) {
|
|
334
|
+
return (e = Te(e)) in t ? Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = r, t;
|
|
335
|
+
}
|
|
336
|
+
function Ge(t, e, r, s, f, I) {
|
|
337
|
+
function g(i, c, u) {
|
|
338
|
+
return function(n, a) {
|
|
339
|
+
return u && u(n), i[c].call(n, a);
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function x(i, c) {
|
|
343
|
+
for (var u = 0; u < i.length; u++) i[u].call(c);
|
|
344
|
+
return c;
|
|
345
|
+
}
|
|
346
|
+
function v(i, c, u, n) {
|
|
347
|
+
if (typeof i != "function" && (n || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (n ? "" : " or undefined"));
|
|
348
|
+
return i;
|
|
349
|
+
}
|
|
350
|
+
function M(i, c, u, n, a, L, k, T, z, C, y, m, p) {
|
|
351
|
+
function S(l) {
|
|
352
|
+
if (!p(l)) throw new TypeError("Attempted to access private element on non-instance");
|
|
353
|
+
}
|
|
354
|
+
var d, D = c[0], E = c[3], j = !T;
|
|
355
|
+
if (!j) {
|
|
356
|
+
u || Array.isArray(D) || (D = [D]);
|
|
357
|
+
var o = {}, _ = [], b = a === 3 ? "get" : a === 4 || m ? "set" : "value";
|
|
358
|
+
C ? (y || m ? o = { get: fe(function() {
|
|
359
|
+
return E(this);
|
|
360
|
+
}, n, "get"), set: function(l) {
|
|
361
|
+
c[4](this, l);
|
|
362
|
+
} } : o[b] = E, y || fe(o[b], n, a === 2 ? "" : b)) : y || (o = Object.getOwnPropertyDescriptor(i, n));
|
|
363
|
+
}
|
|
364
|
+
for (var h = i, q = D.length - 1; q >= 0; q -= u ? 2 : 1) {
|
|
365
|
+
var H = D[q], K = u ? D[q - 1] : void 0, B = {}, R = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: n, metadata: L, addInitializer: (function(l, O) {
|
|
366
|
+
if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
367
|
+
v(O, "An initializer", "be", !0), k.push(O);
|
|
368
|
+
}).bind(null, B) };
|
|
369
|
+
try {
|
|
370
|
+
if (j) (d = v(H.call(K, h, R), "class decorators", "return")) && (h = d);
|
|
371
|
+
else {
|
|
372
|
+
var A, F;
|
|
373
|
+
R.static = z, R.private = C, C ? a === 2 ? A = function(l) {
|
|
374
|
+
return S(l), o.value;
|
|
375
|
+
} : (a < 4 && (A = g(o, "get", S)), a !== 3 && (F = g(o, "set", S))) : (A = function(l) {
|
|
376
|
+
return l[n];
|
|
377
|
+
}, (a < 2 || a === 4) && (F = function(l, O) {
|
|
378
|
+
l[n] = O;
|
|
379
|
+
}));
|
|
380
|
+
var W = R.access = { has: C ? p.bind() : function(l) {
|
|
381
|
+
return n in l;
|
|
382
|
+
} };
|
|
383
|
+
if (A && (W.get = A), F && (W.set = F), h = H.call(K, m ? { get: o.get, set: o.set } : o[b], R), m) {
|
|
384
|
+
if (typeof h == "object" && h) (d = v(h.get, "accessor.get")) && (o.get = d), (d = v(h.set, "accessor.set")) && (o.set = d), (d = v(h.init, "accessor.init")) && _.push(d);
|
|
385
|
+
else if (h !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
386
|
+
} else v(h, (y ? "field" : "method") + " decorators", "return") && (y ? _.push(h) : o[b] = h);
|
|
387
|
+
}
|
|
388
|
+
} finally {
|
|
389
|
+
B.v = !0;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return (y || m) && T.push(function(l, O) {
|
|
393
|
+
for (var N = _.length - 1; N >= 0; N--) O = _[N].call(l, O);
|
|
394
|
+
return O;
|
|
395
|
+
}), y || j || (C ? m ? T.push(g(o, "get"), g(o, "set")) : T.push(a === 2 ? o[b] : g.call.bind(o[b])) : Object.defineProperty(i, n, o)), h;
|
|
396
|
+
}
|
|
397
|
+
function $(i, c) {
|
|
398
|
+
return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
|
|
399
|
+
}
|
|
400
|
+
if (arguments.length >= 6) var U = I[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
401
|
+
var P = Object.create(U ?? null), Z = function(i, c, u, n) {
|
|
402
|
+
var a, L, k = [], T = function(b) {
|
|
403
|
+
return Qe(b) === i;
|
|
404
|
+
}, z = /* @__PURE__ */ new Map();
|
|
405
|
+
function C(b) {
|
|
406
|
+
b && k.push(x.bind(null, b));
|
|
407
|
+
}
|
|
408
|
+
for (var y = 0; y < c.length; y++) {
|
|
409
|
+
var m = c[y];
|
|
410
|
+
if (Array.isArray(m)) {
|
|
411
|
+
var p = m[1], S = m[2], d = m.length > 3, D = 16 & p, E = !!(8 & p), j = (p &= 7) == 0, o = S + "/" + E;
|
|
412
|
+
if (!j && !d) {
|
|
413
|
+
var _ = z.get(o);
|
|
414
|
+
if (_ === !0 || _ === 3 && p !== 4 || _ === 4 && p !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + S);
|
|
415
|
+
z.set(o, !(p > 2) || p);
|
|
416
|
+
}
|
|
417
|
+
M(E ? i : i.prototype, m, D, d ? "#" + S : Te(S), p, n, E ? L = L || [] : a = a || [], k, E, d, j, p === 1, E && d ? T : u);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return C(a), C(L), k;
|
|
421
|
+
}(t, e, f, P);
|
|
422
|
+
return r.length || $(t, P), { e: Z, get c() {
|
|
423
|
+
var i = [];
|
|
424
|
+
return r.length && [$(M(t, [r], s, t.name, 5, P, i), P), x.bind(null, i, t)];
|
|
425
|
+
} };
|
|
426
|
+
}
|
|
427
|
+
function Te(t) {
|
|
428
|
+
var e = Je(t, "string");
|
|
429
|
+
return typeof e == "symbol" ? e : e + "";
|
|
430
|
+
}
|
|
431
|
+
function Je(t, e) {
|
|
432
|
+
if (typeof t != "object" || !t) return t;
|
|
433
|
+
var r = t[Symbol.toPrimitive];
|
|
434
|
+
if (r !== void 0) {
|
|
435
|
+
var s = r.call(t, e);
|
|
436
|
+
if (typeof s != "object") return s;
|
|
437
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
438
|
+
}
|
|
439
|
+
return String(t);
|
|
440
|
+
}
|
|
441
|
+
function fe(t, e, r) {
|
|
442
|
+
typeof e == "symbol" && (e = (e = e.description) ? "[" + e + "]" : "");
|
|
443
|
+
try {
|
|
444
|
+
Object.defineProperty(t, "name", { configurable: !0, value: r ? r + " " + e : e });
|
|
445
|
+
} catch {
|
|
446
|
+
}
|
|
447
|
+
return t;
|
|
448
|
+
}
|
|
449
|
+
function Qe(t) {
|
|
450
|
+
if (Object(t) !== t) throw TypeError("right-hand side of 'in' should be an object, got " + (t !== null ? typeof t : "null"));
|
|
451
|
+
return t;
|
|
452
|
+
}
|
|
453
|
+
const ce = ae("DocSearch"), V = {
|
|
454
|
+
data: null,
|
|
455
|
+
promise: null
|
|
456
|
+
};
|
|
457
|
+
async function ge() {
|
|
458
|
+
return V.data ? V.data : (V.promise || (V.promise = (async () => {
|
|
459
|
+
try {
|
|
460
|
+
const t = await fetch("/.wsx-press/search-index.json");
|
|
461
|
+
if (!t.ok)
|
|
462
|
+
throw new Error(`Failed to load search index: ${t.statusText}`);
|
|
463
|
+
const e = await t.json();
|
|
464
|
+
return V.data = e, V.promise = null, e;
|
|
465
|
+
} catch (t) {
|
|
466
|
+
throw V.promise = null, t;
|
|
467
|
+
}
|
|
468
|
+
})()), V.promise);
|
|
469
|
+
}
|
|
470
|
+
Ie = [se({
|
|
471
|
+
tagName: "wsx-doc-search"
|
|
472
|
+
})];
|
|
473
|
+
let Xe;
|
|
474
|
+
class Ze extends X {
|
|
475
|
+
constructor() {
|
|
476
|
+
super({
|
|
477
|
+
styles: he,
|
|
478
|
+
styleName: "wsx-doc-search"
|
|
479
|
+
}), Q(this, "_autoStyles", he), Q(this, "query", void 0), Q(this, "results", void 0), Q(this, "isOpen", void 0), Q(this, "isLoading", void 0), Q(this, "selectedIndex", void 0), Q(this, "fuse", null), Q(this, "searchTimeout", null), Q(this, "handleInput", ($) => {
|
|
480
|
+
const U = $.target;
|
|
481
|
+
if (this.query = U.value, this.searchTimeout !== null && clearTimeout(this.searchTimeout), !this.query.trim()) {
|
|
482
|
+
this.results = [], this.selectedIndex = -1, this.isOpen = !1;
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
this.searchTimeout = window.setTimeout(() => {
|
|
486
|
+
this.performSearch();
|
|
487
|
+
}, 300);
|
|
488
|
+
}), Q(this, "handleKeyDown", ($) => {
|
|
489
|
+
if (!(!this.isOpen || this.results.length === 0))
|
|
490
|
+
switch ($.key) {
|
|
491
|
+
case "ArrowDown":
|
|
492
|
+
$.preventDefault(), this.selectedIndex = Math.min(this.selectedIndex + 1, this.results.length - 1);
|
|
493
|
+
break;
|
|
494
|
+
case "ArrowUp":
|
|
495
|
+
$.preventDefault(), this.selectedIndex = Math.max(this.selectedIndex - 1, -1);
|
|
496
|
+
break;
|
|
497
|
+
case "Enter":
|
|
498
|
+
$.preventDefault(), this.selectedIndex >= 0 && this.selectedIndex < this.results.length ? this.selectResult(this.results[this.selectedIndex]) : this.results.length > 0 && this.selectResult(this.results[0]);
|
|
499
|
+
break;
|
|
500
|
+
case "Escape":
|
|
501
|
+
$.preventDefault(), this.isOpen = !1, this.query = "", this.results = [], this.selectedIndex = -1;
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
}), ce.info("DocSearch initialized");
|
|
505
|
+
const [e, r] = this.useState("query", "");
|
|
506
|
+
Object.defineProperty(this, "query", {
|
|
507
|
+
get: e,
|
|
508
|
+
set: r,
|
|
509
|
+
enumerable: !0,
|
|
510
|
+
configurable: !0
|
|
511
|
+
});
|
|
512
|
+
let s = this.reactive([]);
|
|
513
|
+
Object.defineProperty(this, "results", {
|
|
514
|
+
get: () => s,
|
|
515
|
+
set: ($) => {
|
|
516
|
+
s = $ !== null && typeof $ < "u" && (Array.isArray($) || typeof $ == "object") ? this.reactive($) : $, this.scheduleRerender();
|
|
517
|
+
},
|
|
518
|
+
enumerable: !0,
|
|
519
|
+
configurable: !0
|
|
520
|
+
});
|
|
521
|
+
const [f, I] = this.useState("isOpen", !1);
|
|
522
|
+
Object.defineProperty(this, "isOpen", {
|
|
523
|
+
get: f,
|
|
524
|
+
set: I,
|
|
525
|
+
enumerable: !0,
|
|
526
|
+
configurable: !0
|
|
527
|
+
});
|
|
528
|
+
const [g, x] = this.useState("isLoading", !1);
|
|
529
|
+
Object.defineProperty(this, "isLoading", {
|
|
530
|
+
get: g,
|
|
531
|
+
set: x,
|
|
532
|
+
enumerable: !0,
|
|
533
|
+
configurable: !0
|
|
534
|
+
});
|
|
535
|
+
const [v, M] = this.useState("selectedIndex", -1);
|
|
536
|
+
Object.defineProperty(this, "selectedIndex", {
|
|
537
|
+
get: v,
|
|
538
|
+
set: M,
|
|
539
|
+
enumerable: !0,
|
|
540
|
+
configurable: !0
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
async onConnected() {
|
|
544
|
+
try {
|
|
545
|
+
const e = await ge();
|
|
546
|
+
this.fuse = new le(e.documents, e.options);
|
|
547
|
+
} catch (e) {
|
|
548
|
+
ce.error("Failed to load search index", e);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* 执行搜索
|
|
553
|
+
*/
|
|
554
|
+
async performSearch() {
|
|
555
|
+
if (!this.fuse)
|
|
556
|
+
try {
|
|
557
|
+
this.isLoading = !0;
|
|
558
|
+
const r = await ge();
|
|
559
|
+
this.fuse = new le(r.documents, r.options);
|
|
560
|
+
} catch (r) {
|
|
561
|
+
ce.error("Failed to load search index", r), this.isLoading = !1;
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
if (this.isLoading = !1, !this.query.trim()) {
|
|
565
|
+
this.results = [], this.isOpen = !1;
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
const e = this.fuse.search(this.query.trim());
|
|
569
|
+
this.results = e, this.isOpen = this.query.trim().length > 0, this.selectedIndex = -1;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* 选择搜索结果
|
|
573
|
+
*/
|
|
574
|
+
selectResult(e) {
|
|
575
|
+
const r = new CustomEvent("doc-search-select", {
|
|
576
|
+
detail: {
|
|
577
|
+
route: e.item.route
|
|
578
|
+
},
|
|
579
|
+
bubbles: !0
|
|
580
|
+
});
|
|
581
|
+
this.dispatchEvent(r), this.isOpen = !1, this.query = "", this.results = [], this.selectedIndex = -1;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* 高亮匹配文本,返回 JSX 元素数组
|
|
585
|
+
*/
|
|
586
|
+
highlightTextNodes(e, r) {
|
|
587
|
+
if (!r || r.length === 0)
|
|
588
|
+
return [e];
|
|
589
|
+
const s = [];
|
|
590
|
+
for (const x of r)
|
|
591
|
+
x.indices && s.push(...x.indices);
|
|
592
|
+
s.sort((x, v) => x[0] - v[0]);
|
|
593
|
+
const f = [];
|
|
594
|
+
for (const [x, v] of s)
|
|
595
|
+
f.length === 0 || f[f.length - 1][1] < x ? f.push([x, v + 1]) : f[f.length - 1][1] = Math.max(f[f.length - 1][1], v + 1);
|
|
596
|
+
const I = [];
|
|
597
|
+
let g = 0;
|
|
598
|
+
for (const [x, v] of f) {
|
|
599
|
+
x > g && I.push(e.substring(g, x));
|
|
600
|
+
const M = document.createElement("mark");
|
|
601
|
+
M.textContent = e.substring(x, v), I.push(M), g = v;
|
|
602
|
+
}
|
|
603
|
+
return g < e.length && I.push(e.substring(g)), I;
|
|
604
|
+
}
|
|
605
|
+
render() {
|
|
606
|
+
return /* @__PURE__ */ w("div", { class: "doc-search" }, /* @__PURE__ */ w("div", { class: "search-input-wrapper" }, /* @__PURE__ */ w("input", { type: "text", class: "search-input", placeholder: "搜索文档...", value: this.query, onInput: this.handleInput, onKeyDown: this.handleKeyDown, onFocus: () => {
|
|
607
|
+
this.results.length > 0 && (this.isOpen = !0);
|
|
608
|
+
}, "data-wsx-key": "DocSearch-input-text-1-1" }), this.isLoading && /* @__PURE__ */ w("div", { class: "search-loading" }, "加载中...")), this.isOpen && this.results.length > 0 && /* @__PURE__ */ w("div", { class: "search-results" }, this.results.map((e, r) => {
|
|
609
|
+
var g, x;
|
|
610
|
+
const s = r === this.selectedIndex, f = (g = e.matches) == null ? void 0 : g.find((v) => v.key === "title"), I = (x = e.matches) == null ? void 0 : x.find((v) => v.key === "content");
|
|
611
|
+
return /* @__PURE__ */ w("div", { key: e.item.id, class: `search-result ${s ? "selected" : ""}`, onClick: () => this.selectResult(e), onMouseEnter: () => {
|
|
612
|
+
this.selectedIndex = r;
|
|
613
|
+
} }, /* @__PURE__ */ w("div", { class: "result-title" }, f ? this.highlightTextNodes(e.item.title, [f]) : e.item.title), /* @__PURE__ */ w("div", { class: "result-category" }, e.item.category), I && /* @__PURE__ */ w("div", { class: "result-snippet" }, this.highlightTextNodes(e.item.content.substring(0, 100), [I])));
|
|
614
|
+
})), this.isOpen && this.query.trim() && this.results.length === 0 && !this.isLoading && /* @__PURE__ */ w("div", { class: "search-no-results" }, "未找到匹配的文档"));
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
_e = Ze;
|
|
618
|
+
[Xe, Oe] = Ge(_e, [], Ie, 0, void 0, X).c;
|
|
619
|
+
Oe();
|
|
620
|
+
const me = "wsx-doc-layout{display:flex;flex-direction:row;width:100%;min-height:calc(100vh - var(--nav-height, 70px))}.doc-layout{display:flex;flex-direction:row;width:100%;max-width:1600px;margin:0 auto;gap:0}.doc-layout-sidebar{flex-shrink:0}.doc-layout-main{flex:1;min-width:0;padding:var(--doc-layout-main-padding-y, 1.5rem) var(--doc-layout-main-padding-x, 2rem);max-width:100%}.doc-layout-toc{flex-shrink:0}@media (max-width: 1280px){.doc-layout-toc{display:none}}@media (max-width: 1024px){.doc-layout-sidebar{display:none}.doc-layout-main{padding:var(--doc-layout-main-padding-y, 1.5rem)}}";
|
|
621
|
+
var je;
|
|
622
|
+
let $e, Le;
|
|
623
|
+
function ne(t, e, r) {
|
|
624
|
+
return (e = ke(e)) in t ? Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = r, t;
|
|
625
|
+
}
|
|
626
|
+
function Ve(t, e, r, s, f, I) {
|
|
627
|
+
function g(i, c, u) {
|
|
628
|
+
return function(n, a) {
|
|
629
|
+
return u && u(n), i[c].call(n, a);
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
function x(i, c) {
|
|
633
|
+
for (var u = 0; u < i.length; u++) i[u].call(c);
|
|
634
|
+
return c;
|
|
635
|
+
}
|
|
636
|
+
function v(i, c, u, n) {
|
|
637
|
+
if (typeof i != "function" && (n || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (n ? "" : " or undefined"));
|
|
638
|
+
return i;
|
|
639
|
+
}
|
|
640
|
+
function M(i, c, u, n, a, L, k, T, z, C, y, m, p) {
|
|
641
|
+
function S(l) {
|
|
642
|
+
if (!p(l)) throw new TypeError("Attempted to access private element on non-instance");
|
|
643
|
+
}
|
|
644
|
+
var d, D = c[0], E = c[3], j = !T;
|
|
645
|
+
if (!j) {
|
|
646
|
+
u || Array.isArray(D) || (D = [D]);
|
|
647
|
+
var o = {}, _ = [], b = a === 3 ? "get" : a === 4 || m ? "set" : "value";
|
|
648
|
+
C ? (y || m ? o = { get: pe(function() {
|
|
649
|
+
return E(this);
|
|
650
|
+
}, n, "get"), set: function(l) {
|
|
651
|
+
c[4](this, l);
|
|
652
|
+
} } : o[b] = E, y || pe(o[b], n, a === 2 ? "" : b)) : y || (o = Object.getOwnPropertyDescriptor(i, n));
|
|
653
|
+
}
|
|
654
|
+
for (var h = i, q = D.length - 1; q >= 0; q -= u ? 2 : 1) {
|
|
655
|
+
var H = D[q], K = u ? D[q - 1] : void 0, B = {}, R = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: n, metadata: L, addInitializer: (function(l, O) {
|
|
656
|
+
if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
657
|
+
v(O, "An initializer", "be", !0), k.push(O);
|
|
658
|
+
}).bind(null, B) };
|
|
659
|
+
try {
|
|
660
|
+
if (j) (d = v(H.call(K, h, R), "class decorators", "return")) && (h = d);
|
|
661
|
+
else {
|
|
662
|
+
var A, F;
|
|
663
|
+
R.static = z, R.private = C, C ? a === 2 ? A = function(l) {
|
|
664
|
+
return S(l), o.value;
|
|
665
|
+
} : (a < 4 && (A = g(o, "get", S)), a !== 3 && (F = g(o, "set", S))) : (A = function(l) {
|
|
666
|
+
return l[n];
|
|
667
|
+
}, (a < 2 || a === 4) && (F = function(l, O) {
|
|
668
|
+
l[n] = O;
|
|
669
|
+
}));
|
|
670
|
+
var W = R.access = { has: C ? p.bind() : function(l) {
|
|
671
|
+
return n in l;
|
|
672
|
+
} };
|
|
673
|
+
if (A && (W.get = A), F && (W.set = F), h = H.call(K, m ? { get: o.get, set: o.set } : o[b], R), m) {
|
|
674
|
+
if (typeof h == "object" && h) (d = v(h.get, "accessor.get")) && (o.get = d), (d = v(h.set, "accessor.set")) && (o.set = d), (d = v(h.init, "accessor.init")) && _.push(d);
|
|
675
|
+
else if (h !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
676
|
+
} else v(h, (y ? "field" : "method") + " decorators", "return") && (y ? _.push(h) : o[b] = h);
|
|
677
|
+
}
|
|
678
|
+
} finally {
|
|
679
|
+
B.v = !0;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
return (y || m) && T.push(function(l, O) {
|
|
683
|
+
for (var N = _.length - 1; N >= 0; N--) O = _[N].call(l, O);
|
|
684
|
+
return O;
|
|
685
|
+
}), y || j || (C ? m ? T.push(g(o, "get"), g(o, "set")) : T.push(a === 2 ? o[b] : g.call.bind(o[b])) : Object.defineProperty(i, n, o)), h;
|
|
686
|
+
}
|
|
687
|
+
function $(i, c) {
|
|
688
|
+
return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
|
|
689
|
+
}
|
|
690
|
+
if (arguments.length >= 6) var U = I[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
691
|
+
var P = Object.create(U ?? null), Z = function(i, c, u, n) {
|
|
692
|
+
var a, L, k = [], T = function(b) {
|
|
693
|
+
return tt(b) === i;
|
|
694
|
+
}, z = /* @__PURE__ */ new Map();
|
|
695
|
+
function C(b) {
|
|
696
|
+
b && k.push(x.bind(null, b));
|
|
697
|
+
}
|
|
698
|
+
for (var y = 0; y < c.length; y++) {
|
|
699
|
+
var m = c[y];
|
|
700
|
+
if (Array.isArray(m)) {
|
|
701
|
+
var p = m[1], S = m[2], d = m.length > 3, D = 16 & p, E = !!(8 & p), j = (p &= 7) == 0, o = S + "/" + E;
|
|
702
|
+
if (!j && !d) {
|
|
703
|
+
var _ = z.get(o);
|
|
704
|
+
if (_ === !0 || _ === 3 && p !== 4 || _ === 4 && p !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + S);
|
|
705
|
+
z.set(o, !(p > 2) || p);
|
|
706
|
+
}
|
|
707
|
+
M(E ? i : i.prototype, m, D, d ? "#" + S : ke(S), p, n, E ? L = L || [] : a = a || [], k, E, d, j, p === 1, E && d ? T : u);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
return C(a), C(L), k;
|
|
711
|
+
}(t, e, f, P);
|
|
712
|
+
return r.length || $(t, P), { e: Z, get c() {
|
|
713
|
+
var i = [];
|
|
714
|
+
return r.length && [$(M(t, [r], s, t.name, 5, P, i), P), x.bind(null, i, t)];
|
|
715
|
+
} };
|
|
716
|
+
}
|
|
717
|
+
function ke(t) {
|
|
718
|
+
var e = et(t, "string");
|
|
719
|
+
return typeof e == "symbol" ? e : e + "";
|
|
720
|
+
}
|
|
721
|
+
function et(t, e) {
|
|
722
|
+
if (typeof t != "object" || !t) return t;
|
|
723
|
+
var r = t[Symbol.toPrimitive];
|
|
724
|
+
if (r !== void 0) {
|
|
725
|
+
var s = r.call(t, e);
|
|
726
|
+
if (typeof s != "object") return s;
|
|
727
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
728
|
+
}
|
|
729
|
+
return String(t);
|
|
730
|
+
}
|
|
731
|
+
function pe(t, e, r) {
|
|
732
|
+
typeof e == "symbol" && (e = (e = e.description) ? "[" + e + "]" : "");
|
|
733
|
+
try {
|
|
734
|
+
Object.defineProperty(t, "name", { configurable: !0, value: r ? r + " " + e : e });
|
|
735
|
+
} catch {
|
|
736
|
+
}
|
|
737
|
+
return t;
|
|
738
|
+
}
|
|
739
|
+
function tt(t) {
|
|
740
|
+
if (Object(t) !== t) throw TypeError("right-hand side of 'in' should be an object, got " + (t !== null ? typeof t : "null"));
|
|
741
|
+
return t;
|
|
742
|
+
}
|
|
743
|
+
Le = [se({
|
|
744
|
+
tagName: "wsx-doc-layout"
|
|
745
|
+
})];
|
|
746
|
+
let rt;
|
|
747
|
+
class it extends X {
|
|
748
|
+
constructor() {
|
|
749
|
+
super({
|
|
750
|
+
styles: me,
|
|
751
|
+
styleName: "wsx-doc-layout"
|
|
752
|
+
}), ne(this, "_autoStyles", me), ne(this, "sidebarInstance", null), ne(this, "docPageInstance", null), ne(this, "tocInstance", null);
|
|
753
|
+
}
|
|
754
|
+
onConnected() {
|
|
755
|
+
requestAnimationFrame(() => {
|
|
756
|
+
if (this.connected) {
|
|
757
|
+
const e = this.querySelector(".doc-layout-sidebar");
|
|
758
|
+
e && !this.sidebarInstance && (this.sidebarInstance = document.createElement("wsx-doc-sidebar"), e.appendChild(this.sidebarInstance));
|
|
759
|
+
const r = this.querySelector(".doc-layout-main");
|
|
760
|
+
r && !this.docPageInstance && (this.docPageInstance = document.createElement("wsx-doc-page"), r.appendChild(this.docPageInstance));
|
|
761
|
+
const s = this.querySelector(".doc-layout-toc");
|
|
762
|
+
s && !this.tocInstance && (this.tocInstance = document.createElement("wsx-doc-toc"), s.appendChild(this.tocInstance));
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
onDisconnected() {
|
|
767
|
+
this.sidebarInstance && (this.sidebarInstance.remove(), this.sidebarInstance = null), this.docPageInstance && (this.docPageInstance.remove(), this.docPageInstance = null), this.tocInstance && (this.tocInstance.remove(), this.tocInstance = null);
|
|
768
|
+
}
|
|
769
|
+
render() {
|
|
770
|
+
return /* @__PURE__ */ w("div", { class: "doc-layout" }, /* @__PURE__ */ w("aside", { class: "doc-layout-sidebar" }), /* @__PURE__ */ w("main", { class: "doc-layout-main" }), /* @__PURE__ */ w("aside", { class: "doc-layout-toc" }));
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
je = it;
|
|
774
|
+
[rt, $e] = Ve(je, [], Le, 0, void 0, X).c;
|
|
775
|
+
$e();
|
|
776
|
+
const be = "wsx-doc-sidebar{display:flex;flex-direction:column;width:280px;min-width:280px;height:100%;background:var(--wsx-press-sidebar-bg, #f9fafb);border-right:1px solid var(--wsx-press-border, #e5e7eb);overflow-y:auto;position:sticky;top:70px;max-height:calc(100vh - 70px)}.doc-sidebar{display:flex;flex-direction:column;width:100%;height:100%}.doc-sidebar-loading,.doc-sidebar-empty{padding:2rem;text-align:center;color:var(--wsx-press-text-secondary, #6b7280)}.doc-sidebar-nav{padding:1.5rem 0}.doc-sidebar-category{margin-bottom:2rem}.doc-sidebar-category:last-child{margin-bottom:0}.doc-sidebar-category-title{font-size:.875rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:var(--wsx-press-text-secondary, #6b7280);padding:.5rem 1.5rem;margin:0 0 .5rem}.doc-sidebar-list{list-style:none;margin:0;padding:0}.doc-sidebar-item{margin:0}.doc-sidebar-link{display:block;padding:.5rem 1.5rem;color:var(--wsx-press-text-primary, #111827);text-decoration:none;font-size:.875rem;line-height:1.5;transition:all .2s ease;border-left:3px solid transparent}.doc-sidebar-link:hover{background:var(--wsx-press-sidebar-hover-bg, #f3f4f6);color:var(--wsx-press-text-primary, #111827)}.doc-sidebar-link.active{background:var(--wsx-press-sidebar-active-bg, #eff6ff);color:var(--wsx-press-sidebar-active-color, #2563eb);border-left-color:var(--wsx-press-sidebar-active-color, #2563eb);font-weight:500}@media (max-width: 1024px){wsx-doc-sidebar{width:240px;min-width:240px}}@media (max-width: 768px){wsx-doc-sidebar{display:none}}";
|
|
777
|
+
var Re;
|
|
778
|
+
let Ae, Pe;
|
|
779
|
+
function oe(t, e, r) {
|
|
780
|
+
return (e = ze(e)) in t ? Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = r, t;
|
|
781
|
+
}
|
|
782
|
+
function ot(t, e, r, s, f, I) {
|
|
783
|
+
function g(i, c, u) {
|
|
784
|
+
return function(n, a) {
|
|
785
|
+
return u && u(n), i[c].call(n, a);
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
function x(i, c) {
|
|
789
|
+
for (var u = 0; u < i.length; u++) i[u].call(c);
|
|
790
|
+
return c;
|
|
791
|
+
}
|
|
792
|
+
function v(i, c, u, n) {
|
|
793
|
+
if (typeof i != "function" && (n || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (n ? "" : " or undefined"));
|
|
794
|
+
return i;
|
|
795
|
+
}
|
|
796
|
+
function M(i, c, u, n, a, L, k, T, z, C, y, m, p) {
|
|
797
|
+
function S(l) {
|
|
798
|
+
if (!p(l)) throw new TypeError("Attempted to access private element on non-instance");
|
|
799
|
+
}
|
|
800
|
+
var d, D = c[0], E = c[3], j = !T;
|
|
801
|
+
if (!j) {
|
|
802
|
+
u || Array.isArray(D) || (D = [D]);
|
|
803
|
+
var o = {}, _ = [], b = a === 3 ? "get" : a === 4 || m ? "set" : "value";
|
|
804
|
+
C ? (y || m ? o = { get: ye(function() {
|
|
805
|
+
return E(this);
|
|
806
|
+
}, n, "get"), set: function(l) {
|
|
807
|
+
c[4](this, l);
|
|
808
|
+
} } : o[b] = E, y || ye(o[b], n, a === 2 ? "" : b)) : y || (o = Object.getOwnPropertyDescriptor(i, n));
|
|
809
|
+
}
|
|
810
|
+
for (var h = i, q = D.length - 1; q >= 0; q -= u ? 2 : 1) {
|
|
811
|
+
var H = D[q], K = u ? D[q - 1] : void 0, B = {}, R = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: n, metadata: L, addInitializer: (function(l, O) {
|
|
812
|
+
if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
813
|
+
v(O, "An initializer", "be", !0), k.push(O);
|
|
814
|
+
}).bind(null, B) };
|
|
815
|
+
try {
|
|
816
|
+
if (j) (d = v(H.call(K, h, R), "class decorators", "return")) && (h = d);
|
|
817
|
+
else {
|
|
818
|
+
var A, F;
|
|
819
|
+
R.static = z, R.private = C, C ? a === 2 ? A = function(l) {
|
|
820
|
+
return S(l), o.value;
|
|
821
|
+
} : (a < 4 && (A = g(o, "get", S)), a !== 3 && (F = g(o, "set", S))) : (A = function(l) {
|
|
822
|
+
return l[n];
|
|
823
|
+
}, (a < 2 || a === 4) && (F = function(l, O) {
|
|
824
|
+
l[n] = O;
|
|
825
|
+
}));
|
|
826
|
+
var W = R.access = { has: C ? p.bind() : function(l) {
|
|
827
|
+
return n in l;
|
|
828
|
+
} };
|
|
829
|
+
if (A && (W.get = A), F && (W.set = F), h = H.call(K, m ? { get: o.get, set: o.set } : o[b], R), m) {
|
|
830
|
+
if (typeof h == "object" && h) (d = v(h.get, "accessor.get")) && (o.get = d), (d = v(h.set, "accessor.set")) && (o.set = d), (d = v(h.init, "accessor.init")) && _.push(d);
|
|
831
|
+
else if (h !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
832
|
+
} else v(h, (y ? "field" : "method") + " decorators", "return") && (y ? _.push(h) : o[b] = h);
|
|
833
|
+
}
|
|
834
|
+
} finally {
|
|
835
|
+
B.v = !0;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
return (y || m) && T.push(function(l, O) {
|
|
839
|
+
for (var N = _.length - 1; N >= 0; N--) O = _[N].call(l, O);
|
|
840
|
+
return O;
|
|
841
|
+
}), y || j || (C ? m ? T.push(g(o, "get"), g(o, "set")) : T.push(a === 2 ? o[b] : g.call.bind(o[b])) : Object.defineProperty(i, n, o)), h;
|
|
842
|
+
}
|
|
843
|
+
function $(i, c) {
|
|
844
|
+
return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
|
|
845
|
+
}
|
|
846
|
+
if (arguments.length >= 6) var U = I[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
847
|
+
var P = Object.create(U ?? null), Z = function(i, c, u, n) {
|
|
848
|
+
var a, L, k = [], T = function(b) {
|
|
849
|
+
return nt(b) === i;
|
|
850
|
+
}, z = /* @__PURE__ */ new Map();
|
|
851
|
+
function C(b) {
|
|
852
|
+
b && k.push(x.bind(null, b));
|
|
853
|
+
}
|
|
854
|
+
for (var y = 0; y < c.length; y++) {
|
|
855
|
+
var m = c[y];
|
|
856
|
+
if (Array.isArray(m)) {
|
|
857
|
+
var p = m[1], S = m[2], d = m.length > 3, D = 16 & p, E = !!(8 & p), j = (p &= 7) == 0, o = S + "/" + E;
|
|
858
|
+
if (!j && !d) {
|
|
859
|
+
var _ = z.get(o);
|
|
860
|
+
if (_ === !0 || _ === 3 && p !== 4 || _ === 4 && p !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + S);
|
|
861
|
+
z.set(o, !(p > 2) || p);
|
|
862
|
+
}
|
|
863
|
+
M(E ? i : i.prototype, m, D, d ? "#" + S : ze(S), p, n, E ? L = L || [] : a = a || [], k, E, d, j, p === 1, E && d ? T : u);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
return C(a), C(L), k;
|
|
867
|
+
}(t, e, f, P);
|
|
868
|
+
return r.length || $(t, P), { e: Z, get c() {
|
|
869
|
+
var i = [];
|
|
870
|
+
return r.length && [$(M(t, [r], s, t.name, 5, P, i), P), x.bind(null, i, t)];
|
|
871
|
+
} };
|
|
872
|
+
}
|
|
873
|
+
function ze(t) {
|
|
874
|
+
var e = st(t, "string");
|
|
875
|
+
return typeof e == "symbol" ? e : e + "";
|
|
876
|
+
}
|
|
877
|
+
function st(t, e) {
|
|
878
|
+
if (typeof t != "object" || !t) return t;
|
|
879
|
+
var r = t[Symbol.toPrimitive];
|
|
880
|
+
if (r !== void 0) {
|
|
881
|
+
var s = r.call(t, e);
|
|
882
|
+
if (typeof s != "object") return s;
|
|
883
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
884
|
+
}
|
|
885
|
+
return String(t);
|
|
886
|
+
}
|
|
887
|
+
function ye(t, e, r) {
|
|
888
|
+
typeof e == "symbol" && (e = (e = e.description) ? "[" + e + "]" : "");
|
|
889
|
+
try {
|
|
890
|
+
Object.defineProperty(t, "name", { configurable: !0, value: r ? r + " " + e : e });
|
|
891
|
+
} catch {
|
|
892
|
+
}
|
|
893
|
+
return t;
|
|
894
|
+
}
|
|
895
|
+
function nt(t) {
|
|
896
|
+
if (Object(t) !== t) throw TypeError("right-hand side of 'in' should be an object, got " + (t !== null ? typeof t : "null"));
|
|
897
|
+
return t;
|
|
898
|
+
}
|
|
899
|
+
const at = ae("DocSidebar");
|
|
900
|
+
Pe = [se({
|
|
901
|
+
tagName: "wsx-doc-sidebar"
|
|
902
|
+
})];
|
|
903
|
+
let ct;
|
|
904
|
+
class lt extends X {
|
|
905
|
+
constructor() {
|
|
906
|
+
super({
|
|
907
|
+
styles: be,
|
|
908
|
+
styleName: "wsx-doc-sidebar"
|
|
909
|
+
}), oe(this, "_autoStyles", be), oe(this, "metadata", void 0), oe(this, "currentRoute", void 0), oe(this, "isLoading", void 0), oe(this, "routeChangeUnsubscribe", null), oe(this, "handleDocClick", (g, x) => {
|
|
910
|
+
x.preventDefault(), re.navigate(g);
|
|
911
|
+
});
|
|
912
|
+
let e = this.reactive({});
|
|
913
|
+
Object.defineProperty(this, "metadata", {
|
|
914
|
+
get: () => e,
|
|
915
|
+
set: (g) => {
|
|
916
|
+
e = g !== null && typeof g < "u" && (Array.isArray(g) || typeof g == "object") ? this.reactive(g) : g, this.scheduleRerender();
|
|
917
|
+
},
|
|
918
|
+
enumerable: !0,
|
|
919
|
+
configurable: !0
|
|
920
|
+
});
|
|
921
|
+
const [r, s] = this.useState("currentRoute", "");
|
|
922
|
+
Object.defineProperty(this, "currentRoute", {
|
|
923
|
+
get: r,
|
|
924
|
+
set: s,
|
|
925
|
+
enumerable: !0,
|
|
926
|
+
configurable: !0
|
|
927
|
+
});
|
|
928
|
+
const [f, I] = this.useState("isLoading", !0);
|
|
929
|
+
Object.defineProperty(this, "isLoading", {
|
|
930
|
+
get: f,
|
|
931
|
+
set: I,
|
|
932
|
+
enumerable: !0,
|
|
933
|
+
configurable: !0
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
async onConnected() {
|
|
937
|
+
await this.loadMetadata(), this.routeChangeUnsubscribe = re.onRouteChange(() => {
|
|
938
|
+
this.updateCurrentRoute();
|
|
939
|
+
}), this.updateCurrentRoute();
|
|
940
|
+
}
|
|
941
|
+
onDisconnected() {
|
|
942
|
+
this.routeChangeUnsubscribe && (this.routeChangeUnsubscribe(), this.routeChangeUnsubscribe = null);
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* 加载文档元数据
|
|
946
|
+
*/
|
|
947
|
+
async loadMetadata() {
|
|
948
|
+
try {
|
|
949
|
+
if (this.isLoading = !0, Y.data)
|
|
950
|
+
this.metadata = Y.data;
|
|
951
|
+
else {
|
|
952
|
+
const e = await fetch("/.wsx-press/docs-meta.json");
|
|
953
|
+
e.ok && (this.metadata = await e.json());
|
|
954
|
+
}
|
|
955
|
+
} catch (e) {
|
|
956
|
+
at.error("Failed to load metadata", e);
|
|
957
|
+
} finally {
|
|
958
|
+
this.isLoading = !1;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* 更新当前路由
|
|
963
|
+
*/
|
|
964
|
+
updateCurrentRoute() {
|
|
965
|
+
const e = re.getCurrentRoute();
|
|
966
|
+
this.currentRoute = e.path;
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* 按分类组织文档
|
|
970
|
+
*/
|
|
971
|
+
organizeByCategory() {
|
|
972
|
+
const e = {};
|
|
973
|
+
return Object.values(this.metadata).forEach((s) => {
|
|
974
|
+
const f = s.category || "other";
|
|
975
|
+
e[f] || (e[f] = []), e[f].push(s);
|
|
976
|
+
}), Object.keys(e).sort().forEach((s) => {
|
|
977
|
+
e[s].sort((f, I) => f.title.localeCompare(I.title));
|
|
978
|
+
}), e;
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* 检查文档是否为当前文档
|
|
982
|
+
*/
|
|
983
|
+
isCurrentDoc(e) {
|
|
984
|
+
return this.currentRoute === e;
|
|
985
|
+
}
|
|
986
|
+
render() {
|
|
987
|
+
if (this.isLoading)
|
|
988
|
+
return /* @__PURE__ */ w("aside", { class: "doc-sidebar" }, /* @__PURE__ */ w("div", { class: "doc-sidebar-loading" }, "加载中..."));
|
|
989
|
+
const e = this.organizeByCategory(), r = Object.keys(e);
|
|
990
|
+
return r.length === 0 ? /* @__PURE__ */ w("aside", { class: "doc-sidebar" }, /* @__PURE__ */ w("div", { class: "doc-sidebar-empty" }, "暂无文档")) : /* @__PURE__ */ w("aside", { class: "doc-sidebar" }, /* @__PURE__ */ w("nav", { class: "doc-sidebar-nav" }, r.map((s) => /* @__PURE__ */ w("div", { key: s, class: "doc-sidebar-category" }, /* @__PURE__ */ w("h3", { class: "doc-sidebar-category-title" }, s), /* @__PURE__ */ w("ul", { class: "doc-sidebar-list" }, e[s].map((f) => /* @__PURE__ */ w("li", { key: f.route, class: "doc-sidebar-item" }, /* @__PURE__ */ w("a", { href: f.route, class: `doc-sidebar-link ${this.isCurrentDoc(f.route) ? "active" : ""}`, onClick: (I) => this.handleDocClick(f.route, I) }, f.title))))))));
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
Re = lt;
|
|
994
|
+
[ct, Ae] = ot(Re, [], Pe, 0, void 0, X).c;
|
|
995
|
+
Ae();
|
|
996
|
+
const ve = "wsx-doc-toc{display:flex;flex-direction:column;width:240px;min-width:240px;height:100%;overflow-y:auto;position:sticky;top:70px;max-height:calc(100vh - 70px)}.doc-toc{display:flex;flex-direction:column;width:100%;padding:1.5rem 1rem}.doc-toc-empty{padding:1rem;text-align:center;color:var(--wsx-press-text-secondary, #6b7280);font-size:.875rem}.doc-toc-title{font-size:.875rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:var(--wsx-press-text-secondary, #6b7280);margin:0 0 1rem;padding:0}.doc-toc-nav{width:100%}.doc-toc-list{list-style:none;margin:0;padding:0}.doc-toc-sublist{margin-top:.25rem;padding-left:1rem}.doc-toc-item{margin:0;line-height:1.6}.doc-toc-item-level-1{margin-bottom:.5rem}.doc-toc-item-level-2{margin-bottom:.375rem;font-size:.875rem}.doc-toc-item-level-3{margin-bottom:.25rem;font-size:.8125rem}.doc-toc-item-level-4,.doc-toc-item-level-5,.doc-toc-item-level-6{margin-bottom:.25rem;font-size:.75rem}.doc-toc-link{display:block;color:var(--wsx-press-text-secondary, #6b7280);text-decoration:none;transition:color .2s ease;border-left:2px solid transparent;padding:.25rem 0 .25rem .5rem;margin-left:-.5rem}.doc-toc-link:hover{color:var(--wsx-press-text-primary, #111827)}.doc-toc-link.active{color:var(--wsx-press-toc-active-color, #2563eb);border-left-color:var(--wsx-press-toc-active-color, #2563eb);font-weight:500}@media (max-width: 1280px){wsx-doc-toc{display:none}}";
|
|
997
|
+
var qe;
|
|
998
|
+
let Fe, Me;
|
|
999
|
+
function te(t, e, r) {
|
|
1000
|
+
return (e = Ne(e)) in t ? Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = r, t;
|
|
1001
|
+
}
|
|
1002
|
+
function ut(t, e, r, s, f, I) {
|
|
1003
|
+
function g(i, c, u) {
|
|
1004
|
+
return function(n, a) {
|
|
1005
|
+
return u && u(n), i[c].call(n, a);
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
function x(i, c) {
|
|
1009
|
+
for (var u = 0; u < i.length; u++) i[u].call(c);
|
|
1010
|
+
return c;
|
|
1011
|
+
}
|
|
1012
|
+
function v(i, c, u, n) {
|
|
1013
|
+
if (typeof i != "function" && (n || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (n ? "" : " or undefined"));
|
|
1014
|
+
return i;
|
|
1015
|
+
}
|
|
1016
|
+
function M(i, c, u, n, a, L, k, T, z, C, y, m, p) {
|
|
1017
|
+
function S(l) {
|
|
1018
|
+
if (!p(l)) throw new TypeError("Attempted to access private element on non-instance");
|
|
1019
|
+
}
|
|
1020
|
+
var d, D = c[0], E = c[3], j = !T;
|
|
1021
|
+
if (!j) {
|
|
1022
|
+
u || Array.isArray(D) || (D = [D]);
|
|
1023
|
+
var o = {}, _ = [], b = a === 3 ? "get" : a === 4 || m ? "set" : "value";
|
|
1024
|
+
C ? (y || m ? o = { get: xe(function() {
|
|
1025
|
+
return E(this);
|
|
1026
|
+
}, n, "get"), set: function(l) {
|
|
1027
|
+
c[4](this, l);
|
|
1028
|
+
} } : o[b] = E, y || xe(o[b], n, a === 2 ? "" : b)) : y || (o = Object.getOwnPropertyDescriptor(i, n));
|
|
1029
|
+
}
|
|
1030
|
+
for (var h = i, q = D.length - 1; q >= 0; q -= u ? 2 : 1) {
|
|
1031
|
+
var H = D[q], K = u ? D[q - 1] : void 0, B = {}, R = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: n, metadata: L, addInitializer: (function(l, O) {
|
|
1032
|
+
if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
1033
|
+
v(O, "An initializer", "be", !0), k.push(O);
|
|
1034
|
+
}).bind(null, B) };
|
|
1035
|
+
try {
|
|
1036
|
+
if (j) (d = v(H.call(K, h, R), "class decorators", "return")) && (h = d);
|
|
1037
|
+
else {
|
|
1038
|
+
var A, F;
|
|
1039
|
+
R.static = z, R.private = C, C ? a === 2 ? A = function(l) {
|
|
1040
|
+
return S(l), o.value;
|
|
1041
|
+
} : (a < 4 && (A = g(o, "get", S)), a !== 3 && (F = g(o, "set", S))) : (A = function(l) {
|
|
1042
|
+
return l[n];
|
|
1043
|
+
}, (a < 2 || a === 4) && (F = function(l, O) {
|
|
1044
|
+
l[n] = O;
|
|
1045
|
+
}));
|
|
1046
|
+
var W = R.access = { has: C ? p.bind() : function(l) {
|
|
1047
|
+
return n in l;
|
|
1048
|
+
} };
|
|
1049
|
+
if (A && (W.get = A), F && (W.set = F), h = H.call(K, m ? { get: o.get, set: o.set } : o[b], R), m) {
|
|
1050
|
+
if (typeof h == "object" && h) (d = v(h.get, "accessor.get")) && (o.get = d), (d = v(h.set, "accessor.set")) && (o.set = d), (d = v(h.init, "accessor.init")) && _.push(d);
|
|
1051
|
+
else if (h !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
1052
|
+
} else v(h, (y ? "field" : "method") + " decorators", "return") && (y ? _.push(h) : o[b] = h);
|
|
1053
|
+
}
|
|
1054
|
+
} finally {
|
|
1055
|
+
B.v = !0;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
return (y || m) && T.push(function(l, O) {
|
|
1059
|
+
for (var N = _.length - 1; N >= 0; N--) O = _[N].call(l, O);
|
|
1060
|
+
return O;
|
|
1061
|
+
}), y || j || (C ? m ? T.push(g(o, "get"), g(o, "set")) : T.push(a === 2 ? o[b] : g.call.bind(o[b])) : Object.defineProperty(i, n, o)), h;
|
|
1062
|
+
}
|
|
1063
|
+
function $(i, c) {
|
|
1064
|
+
return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
|
|
1065
|
+
}
|
|
1066
|
+
if (arguments.length >= 6) var U = I[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
1067
|
+
var P = Object.create(U ?? null), Z = function(i, c, u, n) {
|
|
1068
|
+
var a, L, k = [], T = function(b) {
|
|
1069
|
+
return ht(b) === i;
|
|
1070
|
+
}, z = /* @__PURE__ */ new Map();
|
|
1071
|
+
function C(b) {
|
|
1072
|
+
b && k.push(x.bind(null, b));
|
|
1073
|
+
}
|
|
1074
|
+
for (var y = 0; y < c.length; y++) {
|
|
1075
|
+
var m = c[y];
|
|
1076
|
+
if (Array.isArray(m)) {
|
|
1077
|
+
var p = m[1], S = m[2], d = m.length > 3, D = 16 & p, E = !!(8 & p), j = (p &= 7) == 0, o = S + "/" + E;
|
|
1078
|
+
if (!j && !d) {
|
|
1079
|
+
var _ = z.get(o);
|
|
1080
|
+
if (_ === !0 || _ === 3 && p !== 4 || _ === 4 && p !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + S);
|
|
1081
|
+
z.set(o, !(p > 2) || p);
|
|
1082
|
+
}
|
|
1083
|
+
M(E ? i : i.prototype, m, D, d ? "#" + S : Ne(S), p, n, E ? L = L || [] : a = a || [], k, E, d, j, p === 1, E && d ? T : u);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
return C(a), C(L), k;
|
|
1087
|
+
}(t, e, f, P);
|
|
1088
|
+
return r.length || $(t, P), { e: Z, get c() {
|
|
1089
|
+
var i = [];
|
|
1090
|
+
return r.length && [$(M(t, [r], s, t.name, 5, P, i), P), x.bind(null, i, t)];
|
|
1091
|
+
} };
|
|
1092
|
+
}
|
|
1093
|
+
function Ne(t) {
|
|
1094
|
+
var e = dt(t, "string");
|
|
1095
|
+
return typeof e == "symbol" ? e : e + "";
|
|
1096
|
+
}
|
|
1097
|
+
function dt(t, e) {
|
|
1098
|
+
if (typeof t != "object" || !t) return t;
|
|
1099
|
+
var r = t[Symbol.toPrimitive];
|
|
1100
|
+
if (r !== void 0) {
|
|
1101
|
+
var s = r.call(t, e);
|
|
1102
|
+
if (typeof s != "object") return s;
|
|
1103
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1104
|
+
}
|
|
1105
|
+
return String(t);
|
|
1106
|
+
}
|
|
1107
|
+
function xe(t, e, r) {
|
|
1108
|
+
typeof e == "symbol" && (e = (e = e.description) ? "[" + e + "]" : "");
|
|
1109
|
+
try {
|
|
1110
|
+
Object.defineProperty(t, "name", { configurable: !0, value: r ? r + " " + e : e });
|
|
1111
|
+
} catch {
|
|
1112
|
+
}
|
|
1113
|
+
return t;
|
|
1114
|
+
}
|
|
1115
|
+
function ht(t) {
|
|
1116
|
+
if (Object(t) !== t) throw TypeError("right-hand side of 'in' should be an object, got " + (t !== null ? typeof t : "null"));
|
|
1117
|
+
return t;
|
|
1118
|
+
}
|
|
1119
|
+
const ft = ae("DocTOC"), ee = {
|
|
1120
|
+
data: null,
|
|
1121
|
+
promise: null
|
|
1122
|
+
};
|
|
1123
|
+
async function gt() {
|
|
1124
|
+
return ee.data ? ee.data : (ee.promise || (ee.promise = (async () => {
|
|
1125
|
+
try {
|
|
1126
|
+
const t = await fetch("/.wsx-press/docs-toc.json");
|
|
1127
|
+
if (!t.ok)
|
|
1128
|
+
throw new Error(`Failed to load TOC data: ${t.statusText}`);
|
|
1129
|
+
const e = await t.json();
|
|
1130
|
+
return ee.data = e, ee.promise = null, e;
|
|
1131
|
+
} catch (t) {
|
|
1132
|
+
throw ee.promise = null, t;
|
|
1133
|
+
}
|
|
1134
|
+
})()), ee.promise);
|
|
1135
|
+
}
|
|
1136
|
+
Me = [se({
|
|
1137
|
+
tagName: "wsx-doc-toc"
|
|
1138
|
+
})];
|
|
1139
|
+
let mt;
|
|
1140
|
+
class pt extends X {
|
|
1141
|
+
constructor() {
|
|
1142
|
+
super({
|
|
1143
|
+
styles: ve,
|
|
1144
|
+
styleName: "wsx-doc-toc"
|
|
1145
|
+
}), te(this, "_autoStyles", ve), te(this, "items", void 0), te(this, "activeId", void 0), te(this, "observer", null), te(this, "headingElements", /* @__PURE__ */ new Map()), te(this, "routeChangeUnsubscribe", null), te(this, "handleTOCClick", (f, I) => {
|
|
1146
|
+
I.preventDefault();
|
|
1147
|
+
const g = this.headingElements.get(f);
|
|
1148
|
+
g && (g.scrollIntoView({
|
|
1149
|
+
behavior: "smooth",
|
|
1150
|
+
block: "start"
|
|
1151
|
+
}), window.history.replaceState(null, "", `#${f}`));
|
|
1152
|
+
});
|
|
1153
|
+
let e = this.reactive([]);
|
|
1154
|
+
Object.defineProperty(this, "items", {
|
|
1155
|
+
get: () => e,
|
|
1156
|
+
set: (f) => {
|
|
1157
|
+
e = f !== null && typeof f < "u" && (Array.isArray(f) || typeof f == "object") ? this.reactive(f) : f, this.scheduleRerender();
|
|
1158
|
+
},
|
|
1159
|
+
enumerable: !0,
|
|
1160
|
+
configurable: !0
|
|
1161
|
+
});
|
|
1162
|
+
const [r, s] = this.useState("activeId", "");
|
|
1163
|
+
Object.defineProperty(this, "activeId", {
|
|
1164
|
+
get: r,
|
|
1165
|
+
set: s,
|
|
1166
|
+
enumerable: !0,
|
|
1167
|
+
configurable: !0
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
async onConnected() {
|
|
1171
|
+
await this.loadTOC(), this.routeChangeUnsubscribe = re.onRouteChange(() => {
|
|
1172
|
+
this.loadTOC();
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
onDisconnected() {
|
|
1176
|
+
this.observer && (this.observer.disconnect(), this.observer = null), this.routeChangeUnsubscribe && (this.routeChangeUnsubscribe(), this.routeChangeUnsubscribe = null);
|
|
1177
|
+
}
|
|
1178
|
+
/**
|
|
1179
|
+
* 加载当前文档的 TOC 数据
|
|
1180
|
+
*/
|
|
1181
|
+
async loadTOC() {
|
|
1182
|
+
try {
|
|
1183
|
+
const r = re.getCurrentRoute().params;
|
|
1184
|
+
if (!r.category || !r.page) {
|
|
1185
|
+
this.items = [];
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
const s = `${r.category}/${r.page}`, f = await gt();
|
|
1189
|
+
this.items = f[s] || [], requestAnimationFrame(() => {
|
|
1190
|
+
this.setupHeadingIds(), this.setupScrollObserver();
|
|
1191
|
+
});
|
|
1192
|
+
} catch (e) {
|
|
1193
|
+
ft.error("Failed to load TOC", e), this.items = [];
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
/**
|
|
1197
|
+
* 为文档中的标题元素设置 ID
|
|
1198
|
+
*/
|
|
1199
|
+
setupHeadingIds() {
|
|
1200
|
+
const e = document.querySelector(".doc-content");
|
|
1201
|
+
if (!e)
|
|
1202
|
+
return;
|
|
1203
|
+
const r = e.querySelectorAll("h1, h2, h3, h4, h5, h6, wsx-marked-heading");
|
|
1204
|
+
this.headingElements.clear(), r.forEach((s) => {
|
|
1205
|
+
var g;
|
|
1206
|
+
const f = ((g = s.textContent) == null ? void 0 : g.trim()) || "";
|
|
1207
|
+
if (!f) return;
|
|
1208
|
+
const I = this.generateId(f);
|
|
1209
|
+
s instanceof HTMLElement && (s.id = I, this.headingElements.set(I, s));
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1213
|
+
* 生成锚点 ID
|
|
1214
|
+
*/
|
|
1215
|
+
generateId(e) {
|
|
1216
|
+
return e.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").trim();
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* 设置滚动观察器,高亮当前可见的标题
|
|
1220
|
+
*/
|
|
1221
|
+
setupScrollObserver() {
|
|
1222
|
+
"IntersectionObserver" in window && (this.observer = new IntersectionObserver((e) => {
|
|
1223
|
+
const r = e.filter((s) => s.isIntersecting);
|
|
1224
|
+
r.length > 0 && (r.sort((s, f) => {
|
|
1225
|
+
const I = s.boundingClientRect.top, g = f.boundingClientRect.top;
|
|
1226
|
+
return Math.abs(I) - Math.abs(g);
|
|
1227
|
+
}), this.activeId = r[0].target.id);
|
|
1228
|
+
}, {
|
|
1229
|
+
rootMargin: "-100px 0px -80% 0px",
|
|
1230
|
+
threshold: 0
|
|
1231
|
+
}), this.headingElements.forEach((e) => {
|
|
1232
|
+
var r;
|
|
1233
|
+
(r = this.observer) == null || r.observe(e);
|
|
1234
|
+
}));
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* 渲染 TOC 项
|
|
1238
|
+
*/
|
|
1239
|
+
renderTOCItem(e) {
|
|
1240
|
+
const r = this.activeId === e.id, s = e.children.length > 0;
|
|
1241
|
+
return /* @__PURE__ */ w("li", { class: `doc-toc-item doc-toc-item-level-${e.level}` }, /* @__PURE__ */ w("a", { href: `#${e.id}`, class: `doc-toc-link ${r ? "active" : ""}`, onClick: (f) => this.handleTOCClick(e.id, f) }, e.text), s && /* @__PURE__ */ w("ul", { class: "doc-toc-list doc-toc-sublist" }, e.children.map((f) => this.renderTOCItem(f))));
|
|
1242
|
+
}
|
|
1243
|
+
render() {
|
|
1244
|
+
return this.items.length === 0 ? /* @__PURE__ */ w("aside", { class: "doc-toc" }, /* @__PURE__ */ w("div", { class: "doc-toc-empty" }, "暂无目录")) : /* @__PURE__ */ w("aside", { class: "doc-toc" }, /* @__PURE__ */ w("h3", { class: "doc-toc-title" }, "目录"), /* @__PURE__ */ w("nav", { class: "doc-toc-nav" }, /* @__PURE__ */ w("ul", { class: "doc-toc-list" }, this.items.map((e) => this.renderTOCItem(e)))));
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
qe = pt;
|
|
1248
|
+
[mt, Fe] = ut(qe, [], Me, 0, void 0, X).c;
|
|
1249
|
+
Fe();
|
|
1250
|
+
export {
|
|
1251
|
+
rt as DocLayout,
|
|
1252
|
+
We as DocPage,
|
|
1253
|
+
Xe as DocSearch,
|
|
1254
|
+
ct as DocSidebar,
|
|
1255
|
+
mt as DocTOC
|
|
1256
|
+
};
|