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