@wsxjs/wsx-router 0.0.16 → 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/dist/index.js CHANGED
@@ -1,591 +1,1383 @@
1
- import { createLogger as F, autoRegister as ot, LightComponent as Y, jsx as Z, WebComponent as st } from "@wsxjs/wsx-core";
2
- const at = ":host{display:block;width:100%;height:100%}.router-outlet{width:100%;height:100%}";
3
- var yt;
4
- let wt, xt;
5
- function X(r, t, e) {
6
- return (t = kt(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
7
- }
8
- function Rt(r, t, e, n, g, C) {
9
- function S(i, c, u) {
10
- return function(s, a) {
11
- return u && u(s), i[c].call(s, a);
1
+ import { autoRegister as we, LightComponent as oe, jsx as ae, WebComponent as Re } from "@wsxjs/wsx-core";
2
+ function Ge(t) {
3
+ return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
4
+ }
5
+ var ue = { exports: {} };
6
+ function Xe(t) {
7
+ try {
8
+ return JSON.stringify(t);
9
+ } catch {
10
+ return '"[Circular]"';
11
+ }
12
+ }
13
+ var Ye = Ze;
14
+ function Ze(t, e, n) {
15
+ var r = n && n.stringify || Xe, s = 1;
16
+ if (typeof t == "object" && t !== null) {
17
+ var l = e.length + s;
18
+ if (l === 1) return t;
19
+ var m = new Array(l);
20
+ m[0] = r(t);
21
+ for (var g = 1; g < l; g++)
22
+ m[g] = r(e[g]);
23
+ return m.join(" ");
24
+ }
25
+ if (typeof t != "string")
26
+ return t;
27
+ var u = e.length;
28
+ if (u === 0) return t;
29
+ for (var i = "", p = 1 - s, v = -1, z = t && t.length || 0, x = 0; x < z; ) {
30
+ if (t.charCodeAt(x) === 37 && x + 1 < z) {
31
+ switch (v = v > -1 ? v : 0, t.charCodeAt(x + 1)) {
32
+ case 100:
33
+ // 'd'
34
+ case 102:
35
+ if (p >= u || e[p] == null) break;
36
+ v < x && (i += t.slice(v, x)), i += Number(e[p]), v = x + 2, x++;
37
+ break;
38
+ case 105:
39
+ if (p >= u || e[p] == null) break;
40
+ v < x && (i += t.slice(v, x)), i += Math.floor(Number(e[p])), v = x + 2, x++;
41
+ break;
42
+ case 79:
43
+ // 'O'
44
+ case 111:
45
+ // 'o'
46
+ case 106:
47
+ if (p >= u || e[p] === void 0) break;
48
+ v < x && (i += t.slice(v, x));
49
+ var o = typeof e[p];
50
+ if (o === "string") {
51
+ i += "'" + e[p] + "'", v = x + 2, x++;
52
+ break;
53
+ }
54
+ if (o === "function") {
55
+ i += e[p].name || "<anonymous>", v = x + 2, x++;
56
+ break;
57
+ }
58
+ i += r(e[p]), v = x + 2, x++;
59
+ break;
60
+ case 115:
61
+ if (p >= u)
62
+ break;
63
+ v < x && (i += t.slice(v, x)), i += String(e[p]), v = x + 2, x++;
64
+ break;
65
+ case 37:
66
+ v < x && (i += t.slice(v, x)), i += "%", v = x + 2, x++, p--;
67
+ break;
68
+ }
69
+ ++p;
70
+ }
71
+ ++x;
72
+ }
73
+ return v === -1 ? t : (v < z && (i += t.slice(v)), i);
74
+ }
75
+ const Le = Ye;
76
+ ue.exports = K;
77
+ const re = mt().console || {}, et = {
78
+ mapHttpRequest: ie,
79
+ mapHttpResponse: ie,
80
+ wrapRequestSerializer: fe,
81
+ wrapResponseSerializer: fe,
82
+ wrapErrorSerializer: fe,
83
+ req: ie,
84
+ res: ie,
85
+ err: _e,
86
+ errWithCause: _e
87
+ };
88
+ function Y(t, e) {
89
+ return t === "silent" ? 1 / 0 : e.levels.values[t];
90
+ }
91
+ const xe = Symbol("pino.logFuncs"), be = Symbol("pino.hierarchy"), tt = {
92
+ error: "log",
93
+ fatal: "error",
94
+ warn: "error",
95
+ info: "log",
96
+ debug: "log",
97
+ trace: "log"
98
+ };
99
+ function ke(t, e) {
100
+ const n = {
101
+ logger: e,
102
+ parent: t[be]
103
+ };
104
+ e[be] = n;
105
+ }
106
+ function nt(t, e, n) {
107
+ const r = {};
108
+ e.forEach((s) => {
109
+ r[s] = n[s] ? n[s] : re[s] || re[tt[s] || "log"] || ne;
110
+ }), t[xe] = r;
111
+ }
112
+ function rt(t, e) {
113
+ return Array.isArray(t) ? t.filter(function(r) {
114
+ return r !== "!stdSerializers.err";
115
+ }) : t === !0 ? Object.keys(e) : !1;
116
+ }
117
+ function K(t) {
118
+ t = t || {}, t.browser = t.browser || {};
119
+ const e = t.browser.transmit;
120
+ if (e && typeof e.send != "function")
121
+ throw Error("pino: transmit option must have a send function");
122
+ const n = t.browser.write || re;
123
+ t.browser.write && (t.browser.asObject = !0);
124
+ const r = t.serializers || {}, s = rt(t.browser.serialize, r);
125
+ let l = t.browser.serialize;
126
+ Array.isArray(t.browser.serialize) && t.browser.serialize.indexOf("!stdSerializers.err") > -1 && (l = !1);
127
+ const m = Object.keys(t.customLevels || {}), g = ["error", "fatal", "warn", "info", "debug", "trace"].concat(m);
128
+ typeof n == "function" && g.forEach(function(c) {
129
+ n[c] = n;
130
+ }), (t.enabled === !1 || t.browser.disabled) && (t.level = "silent");
131
+ const u = t.level || "info", i = Object.create(n);
132
+ i.log || (i.log = ne), nt(i, g, n), ke({}, i), Object.defineProperty(i, "levelVal", {
133
+ get: v
134
+ }), Object.defineProperty(i, "level", {
135
+ get: z,
136
+ set: x
137
+ });
138
+ const p = {
139
+ transmit: e,
140
+ serialize: s,
141
+ asObject: t.browser.asObject,
142
+ asObjectBindingsOnly: t.browser.asObjectBindingsOnly,
143
+ formatters: t.browser.formatters,
144
+ levels: g,
145
+ timestamp: ht(t),
146
+ messageKey: t.messageKey || "msg",
147
+ onChild: t.onChild || ne
148
+ };
149
+ i.levels = it(t), i.level = u, i.isLevelEnabled = function(c) {
150
+ return this.levels.values[c] ? this.levels.values[c] >= this.levels.values[this.level] : !1;
151
+ }, i.setMaxListeners = i.getMaxListeners = i.emit = i.addListener = i.on = i.prependListener = i.once = i.prependOnceListener = i.removeListener = i.removeAllListeners = i.listeners = i.listenerCount = i.eventNames = i.write = i.flush = ne, i.serializers = r, i._serialize = s, i._stdErrSerialize = l, i.child = function(...c) {
152
+ return o.call(this, p, ...c);
153
+ }, e && (i._logEvent = ye());
154
+ function v() {
155
+ return Y(this.level, this);
156
+ }
157
+ function z() {
158
+ return this._level;
159
+ }
160
+ function x(c) {
161
+ if (c !== "silent" && !this.levels.values[c])
162
+ throw Error("unknown level " + c);
163
+ this._level = c, Z(this, p, i, "error"), Z(this, p, i, "fatal"), Z(this, p, i, "warn"), Z(this, p, i, "info"), Z(this, p, i, "debug"), Z(this, p, i, "trace"), m.forEach((f) => {
164
+ Z(this, p, i, f);
165
+ });
166
+ }
167
+ function o(c, f, h) {
168
+ if (!f)
169
+ throw new Error("missing bindings for child Pino");
170
+ h = h || {}, s && f.serializers && (h.serializers = f.serializers);
171
+ const d = h.serializers;
172
+ if (s && d) {
173
+ var T = Object.assign({}, r, d), V = t.browser.serialize === !0 ? Object.keys(T) : s;
174
+ delete f.serializers, Ee([f], V, T, this._stdErrSerialize);
175
+ }
176
+ function A(_) {
177
+ this._childLevel = (_._childLevel | 0) + 1, this.bindings = f, T && (this.serializers = T, this._serialize = V), e && (this._logEvent = ye(
178
+ [].concat(_._logEvent.bindings, f)
179
+ ));
180
+ }
181
+ A.prototype = this;
182
+ const I = new A(this);
183
+ return ke(this, I), I.child = function(..._) {
184
+ return o.call(this, c, ..._);
185
+ }, I.level = h.level || this.level, c.onChild(I), I;
186
+ }
187
+ return i;
188
+ }
189
+ function it(t) {
190
+ const e = t.customLevels || {}, n = Object.assign({}, K.levels.values, e), r = Object.assign({}, K.levels.labels, st(e));
191
+ return {
192
+ values: n,
193
+ labels: r
194
+ };
195
+ }
196
+ function st(t) {
197
+ const e = {};
198
+ return Object.keys(t).forEach(function(n) {
199
+ e[t[n]] = n;
200
+ }), e;
201
+ }
202
+ K.levels = {
203
+ values: {
204
+ fatal: 60,
205
+ error: 50,
206
+ warn: 40,
207
+ info: 30,
208
+ debug: 20,
209
+ trace: 10
210
+ },
211
+ labels: {
212
+ 10: "trace",
213
+ 20: "debug",
214
+ 30: "info",
215
+ 40: "warn",
216
+ 50: "error",
217
+ 60: "fatal"
218
+ }
219
+ };
220
+ K.stdSerializers = et;
221
+ K.stdTimeFunctions = Object.assign({}, { nullTime: De, epochTime: Me, unixTime: ft, isoTime: dt });
222
+ function ot(t) {
223
+ const e = [];
224
+ t.bindings && e.push(t.bindings);
225
+ let n = t[be];
226
+ for (; n.parent; )
227
+ n = n.parent, n.logger.bindings && e.push(n.logger.bindings);
228
+ return e.reverse();
229
+ }
230
+ function Z(t, e, n, r) {
231
+ if (Object.defineProperty(t, r, {
232
+ value: Y(t.level, n) > Y(r, n) ? ne : n[xe][r],
233
+ writable: !0,
234
+ enumerable: !0,
235
+ configurable: !0
236
+ }), t[r] === ne) {
237
+ if (!e.transmit) return;
238
+ const l = e.transmit.level || t.level, m = Y(l, n);
239
+ if (Y(r, n) < m) return;
240
+ }
241
+ t[r] = ct(t, e, n, r);
242
+ const s = ot(t);
243
+ s.length !== 0 && (t[r] = at(s, t[r]));
244
+ }
245
+ function at(t, e) {
246
+ return function() {
247
+ return e.apply(this, [...t, ...arguments]);
248
+ };
249
+ }
250
+ function ct(t, e, n, r) {
251
+ return /* @__PURE__ */ function(s) {
252
+ return function() {
253
+ const m = e.timestamp(), g = new Array(arguments.length), u = Object.getPrototypeOf && Object.getPrototypeOf(this) === re ? re : this;
254
+ for (var i = 0; i < g.length; i++) g[i] = arguments[i];
255
+ var p = !1;
256
+ if (e.serialize && (Ee(g, this._serialize, this.serializers, this._stdErrSerialize), p = !0), e.asObject || e.formatters ? s.call(u, ...lt(this, r, g, m, e)) : s.apply(u, g), e.transmit) {
257
+ const v = e.transmit.level || t._level, z = Y(v, n), x = Y(r, n);
258
+ if (x < z) return;
259
+ ut(this, {
260
+ ts: m,
261
+ methodLevel: r,
262
+ methodValue: x,
263
+ transmitValue: n.levels.values[e.transmit.level || t._level],
264
+ send: e.transmit.send,
265
+ val: Y(t._level, n)
266
+ }, g, p);
267
+ }
268
+ };
269
+ }(t[xe][r]);
270
+ }
271
+ function lt(t, e, n, r, s) {
272
+ const {
273
+ level: l,
274
+ log: m = (v) => v
275
+ } = s.formatters || {}, g = n.slice();
276
+ let u = g[0];
277
+ const i = {};
278
+ let p = (t._childLevel | 0) + 1;
279
+ if (p < 1 && (p = 1), r && (i.time = r), l) {
280
+ const v = l(e, t.levels.values[e]);
281
+ Object.assign(i, v);
282
+ } else
283
+ i.level = t.levels.values[e];
284
+ if (s.asObjectBindingsOnly) {
285
+ if (u !== null && typeof u == "object")
286
+ for (; p-- && typeof g[0] == "object"; )
287
+ Object.assign(i, g.shift());
288
+ return [m(i), ...g];
289
+ } else {
290
+ if (u !== null && typeof u == "object") {
291
+ for (; p-- && typeof g[0] == "object"; )
292
+ Object.assign(i, g.shift());
293
+ u = g.length ? Le(g.shift(), g) : void 0;
294
+ } else typeof u == "string" && (u = Le(g.shift(), g));
295
+ return u !== void 0 && (i[s.messageKey] = u), [m(i)];
296
+ }
297
+ }
298
+ function Ee(t, e, n, r) {
299
+ for (const s in t)
300
+ if (r && t[s] instanceof Error)
301
+ t[s] = K.stdSerializers.err(t[s]);
302
+ else if (typeof t[s] == "object" && !Array.isArray(t[s]) && e)
303
+ for (const l in t[s])
304
+ e.indexOf(l) > -1 && l in n && (t[s][l] = n[l](t[s][l]));
305
+ }
306
+ function ut(t, e, n, r = !1) {
307
+ const s = e.send, l = e.ts, m = e.methodLevel, g = e.methodValue, u = e.val, i = t._logEvent.bindings;
308
+ r || Ee(
309
+ n,
310
+ t._serialize || Object.keys(t.serializers),
311
+ t.serializers,
312
+ t._stdErrSerialize === void 0 ? !0 : t._stdErrSerialize
313
+ ), t._logEvent.ts = l, t._logEvent.messages = n.filter(function(p) {
314
+ return i.indexOf(p) === -1;
315
+ }), t._logEvent.level.label = m, t._logEvent.level.value = g, s(m, t._logEvent, u), t._logEvent = ye(i);
316
+ }
317
+ function ye(t) {
318
+ return {
319
+ ts: 0,
320
+ messages: [],
321
+ bindings: t || [],
322
+ level: { label: "", value: 0 }
323
+ };
324
+ }
325
+ function _e(t) {
326
+ const e = {
327
+ type: t.constructor.name,
328
+ msg: t.message,
329
+ stack: t.stack
330
+ };
331
+ for (const n in t)
332
+ e[n] === void 0 && (e[n] = t[n]);
333
+ return e;
334
+ }
335
+ function ht(t) {
336
+ return typeof t.timestamp == "function" ? t.timestamp : t.timestamp === !1 ? De : Me;
337
+ }
338
+ function ie() {
339
+ return {};
340
+ }
341
+ function fe(t) {
342
+ return t;
343
+ }
344
+ function ne() {
345
+ }
346
+ function De() {
347
+ return !1;
348
+ }
349
+ function Me() {
350
+ return Date.now();
351
+ }
352
+ function ft() {
353
+ return Math.round(Date.now() / 1e3);
354
+ }
355
+ function dt() {
356
+ return new Date(Date.now()).toISOString();
357
+ }
358
+ function mt() {
359
+ function t(e) {
360
+ return typeof e < "u" && e;
361
+ }
362
+ try {
363
+ return typeof globalThis < "u" || Object.defineProperty(Object.prototype, "globalThis", {
364
+ get: function() {
365
+ return delete Object.prototype.globalThis, this.globalThis = this;
366
+ },
367
+ configurable: !0
368
+ }), globalThis;
369
+ } catch {
370
+ return t(self) || t(window) || t(this) || {};
371
+ }
372
+ }
373
+ ue.exports.default = K;
374
+ ue.exports.pino = K;
375
+ var gt = ue.exports;
376
+ const se = /* @__PURE__ */ Ge(gt);
377
+ function ce() {
378
+ return typeof process < "u" && process.env.NODE_ENV === "production";
379
+ }
380
+ function pt() {
381
+ var t;
382
+ return typeof process < "u" && ((t = process.versions) == null ? void 0 : t.node) !== void 0;
383
+ }
384
+ function vt() {
385
+ return typeof window < "u" && typeof document < "u";
386
+ }
387
+ const de = {
388
+ name: "WSX",
389
+ level: ce() ? "info" : "debug",
390
+ pretty: !ce()
391
+ };
392
+ function bt(t = {}) {
393
+ const { name: e, level: n, pretty: r, pinoOptions: s } = { ...de, ...t }, l = {
394
+ name: e || de.name,
395
+ level: n || de.level,
396
+ ...s
397
+ };
398
+ if (vt() && (l.browser = {
399
+ asObject: !1,
400
+ // Use console methods directly (default behavior)
401
+ write: void 0,
402
+ // Use default console write
403
+ ...(s == null ? void 0 : s.browser) || {}
404
+ // Allow override via pinoOptions
405
+ }), r && pt() && !ce())
406
+ try {
407
+ return se(
408
+ l,
409
+ se.transport({
410
+ target: "pino-pretty",
411
+ options: {
412
+ colorize: !0,
413
+ translateTime: "HH:MM:ss.l",
414
+ ignore: "pid,hostname",
415
+ singleLine: !1
416
+ }
417
+ })
418
+ );
419
+ } catch {
420
+ return console.warn("[wsx-logger] pino-pretty not available, using default formatter"), se(l);
421
+ }
422
+ return se(l);
423
+ }
424
+ class Ne {
425
+ constructor(e = {}) {
426
+ this.isProd = ce(), this.pinoLogger = bt(e);
427
+ }
428
+ debug(e, ...n) {
429
+ this.isProd || (n.length > 0 ? this.pinoLogger.debug({ args: n }, e) : this.pinoLogger.debug(e));
430
+ }
431
+ info(e, ...n) {
432
+ this.isProd ? n.length > 0 ? this.pinoLogger.info({ args: n }, e) : this.pinoLogger.info(e) : n.length > 0 ? this.pinoLogger.info({ args: n }, e) : this.pinoLogger.info(e);
433
+ }
434
+ warn(e, ...n) {
435
+ n.length > 0 ? this.pinoLogger.warn({ args: n }, e) : this.pinoLogger.warn(e);
436
+ }
437
+ error(e, ...n) {
438
+ n.length > 0 ? this.pinoLogger.error({ args: n }, e) : this.pinoLogger.error(e);
439
+ }
440
+ fatal(e, ...n) {
441
+ n.length > 0 ? this.pinoLogger.fatal({ args: n }, e) : this.pinoLogger.fatal(e);
442
+ }
443
+ trace(e, ...n) {
444
+ this.isProd || (n.length > 0 ? this.pinoLogger.trace({ args: n }, e) : this.pinoLogger.trace(e));
445
+ }
446
+ /**
447
+ * Get the underlying pino logger instance
448
+ */
449
+ getPinoLogger() {
450
+ return this.pinoLogger;
451
+ }
452
+ }
453
+ new Ne();
454
+ function he(t, e = {}) {
455
+ return new Ne({
456
+ ...e,
457
+ name: e.name || `WSX:${t}`
458
+ });
459
+ }
460
+ const yt = he("RouterUtils"), te = class te {
461
+ /**
462
+ * 设置当前路由信息(由 WsxRouter 内部调用)
463
+ * @internal
464
+ */
465
+ static _setCurrentRoute(e) {
466
+ te._currentRoute = e;
467
+ }
468
+ /**
469
+ * 编程式导航
470
+ */
471
+ static navigate(e, n = !1) {
472
+ n ? window.history.replaceState(null, "", e) : window.history.pushState(null, "", e), window.dispatchEvent(new PopStateEvent("popstate")), yt.debug(`Navigated to: ${e} (replace: ${n})`);
473
+ }
474
+ /**
475
+ * 获取当前路由信息
476
+ * 如果路由已匹配(由 WsxRouter 维护),则返回包含参数的路由信息
477
+ * 否则返回基础路由信息(参数为空对象)
478
+ */
479
+ static getCurrentRoute() {
480
+ if (te._currentRoute)
481
+ return te._currentRoute;
482
+ const e = new URL(window.location.href);
483
+ return {
484
+ path: e.pathname,
485
+ params: {},
486
+ query: Object.fromEntries(e.searchParams.entries()),
487
+ hash: e.hash.slice(1)
488
+ // 移除 # 号
12
489
  };
13
490
  }
14
- function T(i, c) {
15
- for (var u = 0; u < i.length; u++) i[u].call(c);
491
+ /**
492
+ * 解析路由路径,提取参数
493
+ */
494
+ static parseRoute(e, n) {
495
+ var r;
496
+ if (e === n)
497
+ return {
498
+ route: e,
499
+ params: {},
500
+ exact: !0
501
+ };
502
+ if (e === "*")
503
+ return {
504
+ route: e,
505
+ params: {},
506
+ exact: !1
507
+ };
508
+ if (e.includes(":")) {
509
+ const s = ((r = e.match(/:([^/]+)/g)) == null ? void 0 : r.map((u) => u.slice(1))) || [], l = e.replace(/:[^/]+/g, "([^/]+)"), m = new RegExp(`^${l}$`), g = n.match(m);
510
+ if (g && s.length > 0) {
511
+ const u = {};
512
+ return s.forEach((i, p) => {
513
+ u[i] = g[p + 1];
514
+ }), {
515
+ route: e,
516
+ params: u,
517
+ exact: !0
518
+ };
519
+ }
520
+ }
521
+ if (e.endsWith("/*")) {
522
+ const s = e.slice(0, -2);
523
+ if (n.startsWith(s))
524
+ return {
525
+ route: e,
526
+ params: {},
527
+ exact: !1
528
+ };
529
+ }
530
+ return null;
531
+ }
532
+ /**
533
+ * 构建路由路径,替换参数
534
+ */
535
+ static buildPath(e, n = {}) {
536
+ let r = e;
537
+ return Object.entries(n).forEach(([s, l]) => {
538
+ r = r.replace(`:${s}`, encodeURIComponent(l));
539
+ }), r;
540
+ }
541
+ /**
542
+ * 检查路由是否匹配当前路径
543
+ */
544
+ static isRouteActive(e, n = !1) {
545
+ const r = window.location.pathname;
546
+ return n ? r === e : e === "/" ? r === "/" : r.startsWith(e);
547
+ }
548
+ /**
549
+ * 获取路由层级
550
+ */
551
+ static getRouteDepth(e) {
552
+ return e.split("/").filter((n) => n.length > 0).length;
553
+ }
554
+ /**
555
+ * 获取父级路由
556
+ */
557
+ static getParentRoute(e) {
558
+ const n = e.split("/").filter((r) => r.length > 0);
559
+ return n.length <= 1 ? "/" : (n.pop(), "/" + n.join("/"));
560
+ }
561
+ /**
562
+ * 合并路由路径
563
+ */
564
+ static joinPaths(...e) {
565
+ return e.map((n) => n.replace(/^\/+|\/+$/g, "")).filter((n) => n.length > 0).join("/").replace(/^/, "/");
566
+ }
567
+ /**
568
+ * 检查是否为外部链接
569
+ */
570
+ static isExternalUrl(e) {
571
+ return /^https?:\/\//.test(e) || /^mailto:/.test(e) || /^tel:/.test(e);
572
+ }
573
+ /**
574
+ * 获取查询参数
575
+ */
576
+ static getQueryParam(e) {
577
+ return new URL(window.location.href).searchParams.get(e);
578
+ }
579
+ /**
580
+ * 设置查询参数
581
+ */
582
+ static setQueryParam(e, n, r = !1) {
583
+ const s = new URL(window.location.href);
584
+ s.searchParams.set(e, n);
585
+ const l = s.pathname + s.search + s.hash;
586
+ this.navigate(l, r);
587
+ }
588
+ /**
589
+ * 删除查询参数
590
+ */
591
+ static removeQueryParam(e, n = !1) {
592
+ const r = new URL(window.location.href);
593
+ r.searchParams.delete(e);
594
+ const s = r.pathname + r.search + r.hash;
595
+ this.navigate(s, n);
596
+ }
597
+ /**
598
+ * 返回上一页
599
+ */
600
+ static goBack() {
601
+ window.history.back();
602
+ }
603
+ /**
604
+ * 前进一页
605
+ */
606
+ static goForward() {
607
+ window.history.forward();
608
+ }
609
+ /**
610
+ * 替换当前页面
611
+ */
612
+ static replace(e) {
613
+ this.navigate(e, !0);
614
+ }
615
+ /**
616
+ * 获取历史记录长度
617
+ */
618
+ static getHistoryLength() {
619
+ return window.history.length;
620
+ }
621
+ /**
622
+ * 监听路由变化
623
+ *
624
+ * 只监听 route-changed 事件,该事件在 RouterUtils._setCurrentRoute() 之后触发。
625
+ * 不监听 popstate 事件,因为:
626
+ * 1. WsxRouter 已经监听 popstate 并会触发 route-changed
627
+ * 2. 同时监听两个事件会导致回调被调用两次,产生竞态条件
628
+ * 3. popstate 触发时 RouterUtils._currentRoute 可能还未更新
629
+ *
630
+ * @see RFC-0035: 路由导航竞态条件修复
631
+ */
632
+ static onRouteChange(e) {
633
+ const n = () => {
634
+ const r = this.getCurrentRoute();
635
+ e(r);
636
+ };
637
+ return document.addEventListener("route-changed", n), () => {
638
+ document.removeEventListener("route-changed", n);
639
+ };
640
+ }
641
+ };
642
+ te._currentRoute = null;
643
+ let le = te;
644
+ const $e = ":host{display:grid;width:100%}.router-outlet{width:100%}:host>wsx-view{grid-area:1 / 1}";
645
+ var qe;
646
+ let Fe, He;
647
+ function U(t, e, n) {
648
+ return (e = Ue(e)) in t ? Object.defineProperty(t, e, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = n, t;
649
+ }
650
+ function wt(t, e, n, r, s, l) {
651
+ function m(o, c, f) {
652
+ return function(h, d) {
653
+ return f && f(h), o[c].call(h, d);
654
+ };
655
+ }
656
+ function g(o, c) {
657
+ for (var f = 0; f < o.length; f++) o[f].call(c);
16
658
  return c;
17
659
  }
18
- function b(i, c, u, s) {
19
- if (typeof i != "function" && (s || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (s ? "" : " or undefined"));
20
- return i;
660
+ function u(o, c, f, h) {
661
+ if (typeof o != "function" && (h || o !== void 0)) throw new TypeError(c + " must " + (f || "be") + " a function" + (h ? "" : " or undefined"));
662
+ return o;
21
663
  }
22
- function $(i, c, u, s, a, W, L, R, D, y, m, d, p) {
23
- function w(l) {
24
- if (!p(l)) throw new TypeError("Attempted to access private element on non-instance");
664
+ function i(o, c, f, h, d, T, V, A, I, _, k, E, R) {
665
+ function j(b) {
666
+ if (!R(b)) throw new TypeError("Attempted to access private element on non-instance");
25
667
  }
26
- var h, x = c[0], k = c[3], j = !R;
27
- if (!j) {
28
- u || Array.isArray(x) || (x = [x]);
29
- var o = {}, E = [], v = a === 3 ? "get" : a === 4 || d ? "set" : "value";
30
- y ? (m || d ? o = { get: ct(function() {
31
- return k(this);
32
- }, s, "get"), set: function(l) {
33
- c[4](this, l);
34
- } } : o[v] = k, m || ct(o[v], s, a === 2 ? "" : v)) : m || (o = Object.getOwnPropertyDescriptor(i, s));
668
+ var y, C = c[0], O = c[3], P = !A;
669
+ if (!P) {
670
+ f || Array.isArray(C) || (C = [C]);
671
+ var a = {}, S = [], L = d === 3 ? "get" : d === 4 || E ? "set" : "value";
672
+ _ ? (k || E ? a = { get: je(function() {
673
+ return O(this);
674
+ }, h, "get"), set: function(b) {
675
+ c[4](this, b);
676
+ } } : a[L] = O, k || je(a[L], h, d === 2 ? "" : L)) : k || (a = Object.getOwnPropertyDescriptor(o, h));
35
677
  }
36
- for (var f = i, N = x.length - 1; N >= 0; N -= u ? 2 : 1) {
37
- var H = x[N], q = u ? x[N - 1] : void 0, K = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: s, metadata: W, addInitializer: (function(l, _) {
38
- if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
39
- b(_, "An initializer", "be", !0), L.push(_);
40
- }).bind(null, K) };
678
+ for (var w = o, q = C.length - 1; q >= 0; q -= f ? 2 : 1) {
679
+ var J = C[q], Q = f ? C[q - 1] : void 0, G = {}, D = { kind: ["field", "accessor", "method", "getter", "setter", "class"][d], name: h, metadata: T, addInitializer: (function(b, W) {
680
+ if (b.v) throw Error("attempted to call addInitializer after decoration was finished");
681
+ u(W, "An initializer", "be", !0), V.push(W);
682
+ }).bind(null, G) };
41
683
  try {
42
- if (j) (h = b(H.call(q, f, O), "class decorators", "return")) && (f = h);
684
+ if (P) (y = u(J.call(Q, w, D), "class decorators", "return")) && (w = y);
43
685
  else {
44
- var I, z;
45
- O.static = D, O.private = y, y ? a === 2 ? I = function(l) {
46
- return w(l), o.value;
47
- } : (a < 4 && (I = S(o, "get", w)), a !== 3 && (z = S(o, "set", w))) : (I = function(l) {
48
- return l[s];
49
- }, (a < 2 || a === 4) && (z = function(l, _) {
50
- l[s] = _;
686
+ var M, F;
687
+ D.static = I, D.private = _, _ ? d === 2 ? M = function(b) {
688
+ return j(b), a.value;
689
+ } : (d < 4 && (M = m(a, "get", j)), d !== 3 && (F = m(a, "set", j))) : (M = function(b) {
690
+ return b[h];
691
+ }, (d < 2 || d === 4) && (F = function(b, W) {
692
+ b[h] = W;
51
693
  }));
52
- var Q = O.access = { has: y ? p.bind() : function(l) {
53
- return s in l;
694
+ var X = D.access = { has: _ ? R.bind() : function(b) {
695
+ return h in b;
54
696
  } };
55
- if (I && (Q.get = I), z && (Q.set = z), f = H.call(q, d ? { get: o.get, set: o.set } : o[v], O), d) {
56
- if (typeof f == "object" && f) (h = b(f.get, "accessor.get")) && (o.get = h), (h = b(f.set, "accessor.set")) && (o.set = h), (h = b(f.init, "accessor.init")) && E.push(h);
57
- else if (f !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
58
- } else b(f, (m ? "field" : "method") + " decorators", "return") && (m ? E.push(f) : o[v] = f);
697
+ if (M && (X.get = M), F && (X.set = F), w = J.call(Q, E ? { get: a.get, set: a.set } : a[L], D), E) {
698
+ if (typeof w == "object" && w) (y = u(w.get, "accessor.get")) && (a.get = y), (y = u(w.set, "accessor.set")) && (a.set = y), (y = u(w.init, "accessor.init")) && S.push(y);
699
+ else if (w !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
700
+ } else u(w, (k ? "field" : "method") + " decorators", "return") && (k ? S.push(w) : a[L] = w);
59
701
  }
60
702
  } finally {
61
- K.v = !0;
703
+ G.v = !0;
62
704
  }
63
705
  }
64
- return (m || d) && R.push(function(l, _) {
65
- for (var V = E.length - 1; V >= 0; V--) _ = E[V].call(l, _);
66
- return _;
67
- }), m || j || (y ? d ? R.push(S(o, "get"), S(o, "set")) : R.push(a === 2 ? o[v] : S.call.bind(o[v])) : Object.defineProperty(i, s, o)), f;
68
- }
69
- function P(i, c) {
70
- return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
71
- }
72
- if (arguments.length >= 6) var U = C[Symbol.metadata || Symbol.for("Symbol.metadata")];
73
- var A = Object.create(U ?? null), G = function(i, c, u, s) {
74
- var a, W, L = [], R = function(v) {
75
- return $t(v) === i;
76
- }, D = /* @__PURE__ */ new Map();
77
- function y(v) {
78
- v && L.push(T.bind(null, v));
706
+ return (k || E) && A.push(function(b, W) {
707
+ for (var H = S.length - 1; H >= 0; H--) W = S[H].call(b, W);
708
+ return W;
709
+ }), k || P || (_ ? E ? A.push(m(a, "get"), m(a, "set")) : A.push(d === 2 ? a[L] : m.call.bind(a[L])) : Object.defineProperty(o, h, a)), w;
710
+ }
711
+ function p(o, c) {
712
+ return Object.defineProperty(o, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
713
+ }
714
+ if (arguments.length >= 6) var v = l[Symbol.metadata || Symbol.for("Symbol.metadata")];
715
+ var z = Object.create(v ?? null), x = function(o, c, f, h) {
716
+ var d, T, V = [], A = function(L) {
717
+ return Et(L) === o;
718
+ }, I = /* @__PURE__ */ new Map();
719
+ function _(L) {
720
+ L && V.push(g.bind(null, L));
79
721
  }
80
- for (var m = 0; m < c.length; m++) {
81
- var d = c[m];
82
- if (Array.isArray(d)) {
83
- var p = d[1], w = d[2], h = d.length > 3, x = 16 & p, k = !!(8 & p), j = (p &= 7) == 0, o = w + "/" + k;
84
- if (!j && !h) {
85
- var E = D.get(o);
86
- if (E === !0 || E === 3 && p !== 4 || E === 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: " + w);
87
- D.set(o, !(p > 2) || p);
722
+ for (var k = 0; k < c.length; k++) {
723
+ var E = c[k];
724
+ if (Array.isArray(E)) {
725
+ var R = E[1], j = E[2], y = E.length > 3, C = 16 & R, O = !!(8 & R), P = (R &= 7) == 0, a = j + "/" + O;
726
+ if (!P && !y) {
727
+ var S = I.get(a);
728
+ if (S === !0 || S === 3 && R !== 4 || S === 4 && R !== 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: " + j);
729
+ I.set(a, !(R > 2) || R);
88
730
  }
89
- $(k ? i : i.prototype, d, x, h ? "#" + w : kt(w), p, s, k ? W = W || [] : a = a || [], L, k, h, j, p === 1, k && h ? R : u);
731
+ i(O ? o : o.prototype, E, C, y ? "#" + j : Ue(j), R, h, O ? T = T || [] : d = d || [], V, O, y, P, R === 1, O && y ? A : f);
90
732
  }
91
733
  }
92
- return y(a), y(W), L;
93
- }(r, t, g, A);
94
- return e.length || P(r, A), { e: G, get c() {
95
- var i = [];
96
- return e.length && [P($(r, [e], n, r.name, 5, A, i), A), T.bind(null, i, r)];
734
+ return _(d), _(T), V;
735
+ }(t, e, s, z);
736
+ return n.length || p(t, z), { e: x, get c() {
737
+ var o = [];
738
+ return n.length && [p(i(t, [n], r, t.name, 5, z, o), z), g.bind(null, o, t)];
97
739
  } };
98
740
  }
99
- function kt(r) {
100
- var t = jt(r, "string");
101
- return typeof t == "symbol" ? t : t + "";
741
+ function Ue(t) {
742
+ var e = xt(t, "string");
743
+ return typeof e == "symbol" ? e : e + "";
102
744
  }
103
- function jt(r, t) {
104
- if (typeof r != "object" || !r) return r;
105
- var e = r[Symbol.toPrimitive];
106
- if (e !== void 0) {
107
- var n = e.call(r, t);
108
- if (typeof n != "object") return n;
745
+ function xt(t, e) {
746
+ if (typeof t != "object" || !t) return t;
747
+ var n = t[Symbol.toPrimitive];
748
+ if (n !== void 0) {
749
+ var r = n.call(t, e);
750
+ if (typeof r != "object") return r;
109
751
  throw new TypeError("@@toPrimitive must return a primitive value.");
110
752
  }
111
- return String(r);
753
+ return String(t);
112
754
  }
113
- function ct(r, t, e) {
114
- typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
755
+ function je(t, e, n) {
756
+ typeof e == "symbol" && (e = (e = e.description) ? "[" + e + "]" : "");
115
757
  try {
116
- Object.defineProperty(r, "name", { configurable: !0, value: e ? e + " " + t : t });
758
+ Object.defineProperty(t, "name", { configurable: !0, value: n ? n + " " + e : e });
117
759
  } catch {
118
760
  }
119
- return r;
761
+ return t;
120
762
  }
121
- function $t(r) {
122
- if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
123
- return r;
763
+ function Et(t) {
764
+ if (Object(t) !== t) throw TypeError("right-hand side of 'in' should be an object, got " + (t !== null ? typeof t : "null"));
765
+ return t;
124
766
  }
125
- const J = F("WsxRouter");
126
- xt = [ot({
767
+ const $ = he("WsxRouter");
768
+ He = [we({
127
769
  tagName: "wsx-router"
128
770
  })];
129
- let At;
130
- class Wt extends Y {
771
+ let Rt;
772
+ class Lt extends oe {
131
773
  constructor() {
132
774
  super({
133
- styles: at,
775
+ styles: $e,
134
776
  styleName: "wsx-router"
135
- }), X(this, "_autoStyles", at), X(this, "views", /* @__PURE__ */ new Map()), X(this, "currentView", null), X(this, "handleRouteChange", () => {
136
- const t = window.location.pathname;
137
- J.debug(`Route changed to: ${t}`), this.currentView && (this.currentView.style.display = "none", J.debug("Hiding previous view"));
138
- const e = this.matchRoute(t);
139
- if (e) {
140
- e.style.display = "block", this.currentView = e, J.debug(`Showing view for route: ${e.getAttribute("route")}`);
141
- const n = this.extractParams(e.getAttribute("route") || "/", t);
142
- n && e.setAttribute("params", JSON.stringify(n));
143
- } else
144
- J.warn(`No view found for path: ${t}`);
145
- this.dispatchEvent(new CustomEvent("route-changed", {
146
- detail: {
147
- path: t,
148
- view: e
149
- },
150
- bubbles: !0,
151
- composed: !0
152
- }));
153
- }), X(this, "interceptLinks", (t) => {
154
- const e = t.target.closest("a");
155
- if (!e) return;
156
- const n = e.getAttribute("href");
157
- !n || n.startsWith("http") || n.startsWith("#") || (t.preventDefault(), this.navigate(n));
777
+ }), U(this, "_autoStyles", $e), U(this, "views", /* @__PURE__ */ new Map()), U(this, "currentView", null), U(this, "currentPath", ""), U(this, "isHandlingRoute", !1), U(this, "compiledRoutes", /* @__PURE__ */ new Map()), U(this, "matchCache", /* @__PURE__ */ new Map()), U(this, "enableViewTransitions", !0), U(this, "scrollRestoration", "manual"), U(this, "handleRouteChange", () => {
778
+ if (this.isHandlingRoute) {
779
+ $.debug("Route change already in progress, skipping");
780
+ return;
781
+ }
782
+ this.views.size === 0 && (this.collectViews(), $.debug(`WsxRouter re-collected views: ${this.views.size}`)), this.isHandlingRoute = !0;
783
+ try {
784
+ const e = window.location.pathname;
785
+ $.debug(`WsxRouter: Route changed to: ${e}`);
786
+ const n = new CustomEvent("before-navigate", {
787
+ detail: {
788
+ to: e,
789
+ from: this.currentPath
790
+ },
791
+ bubbles: !0,
792
+ cancelable: !0
793
+ });
794
+ if (!this.dispatchEvent(n)) {
795
+ $.debug(`Navigation to ${e} was cancelled`);
796
+ return;
797
+ }
798
+ this.performNavigation(e);
799
+ } finally {
800
+ requestAnimationFrame(() => {
801
+ this.isHandlingRoute = !1;
802
+ });
803
+ }
804
+ }), U(this, "interceptLinks", (e) => {
805
+ const n = e.target.closest("a");
806
+ if (!n) return;
807
+ const r = n.getAttribute("href");
808
+ !r || r.startsWith("http") || r.startsWith("#") || (e.preventDefault(), this.navigate(r));
158
809
  });
159
810
  }
160
811
  render() {
161
- return /* @__PURE__ */ Z("div", { class: "router-outlet" });
812
+ return /* @__PURE__ */ ae("div", { class: "router-outlet" });
813
+ }
814
+ onRendered() {
815
+ this.views.size === 0 && (this.collectViews(), $.debug("WsxRouter collected views in onRendered:", this.views.size)), this.views.size > 0 && !this.currentView && requestAnimationFrame(() => {
816
+ this.handleRouteChange();
817
+ });
162
818
  }
163
819
  onConnected() {
164
- J.debug("WsxRouter connected to DOM"), this.collectViews(), J.debug("WsxRouter collected views:", this.views.size), window.addEventListener("popstate", this.handleRouteChange), this.addEventListener("click", this.interceptLinks), this.handleRouteChange();
820
+ $.debug("WsxRouter connected to DOM"), "scrollRestoration" in history && (history.scrollRestoration = this.scrollRestoration), window.addEventListener("popstate", this.handleRouteChange), this.addEventListener("click", this.interceptLinks), requestAnimationFrame(() => {
821
+ this.views.size === 0 && (this.collectViews(), $.debug(`WsxRouter collected views in onConnected: ${this.views.size}`)), requestAnimationFrame(() => {
822
+ $.debug(`WsxRouter handling initial route: ${window.location.pathname}`), this.handleRouteChange();
823
+ });
824
+ });
165
825
  }
166
826
  onDisconnected() {
167
827
  window.removeEventListener("popstate", this.handleRouteChange);
168
828
  }
169
829
  collectViews() {
170
- const t = Array.from(this.children).filter((e) => e.tagName.toLowerCase() === "wsx-view");
171
- J.debug("WsxRouter found views:", t.length), t.forEach((e) => {
172
- const n = e.getAttribute("route") || "/";
173
- this.views.set(n, e), e.style.display = "none", J.debug(`WsxRouter hiding view for route: ${n}`);
830
+ const e = Array.from(this.children).filter((n) => n.tagName.toLowerCase() === "wsx-view");
831
+ $.debug(`WsxRouter found ${e.length} views`), this.views.clear(), this.compiledRoutes.clear(), this.matchCache.clear(), e.forEach((n) => {
832
+ const r = n.getAttribute("route") || "/";
833
+ if (this.views.set(r, n), $.debug(`WsxRouter registered route: ${r}`), r.includes(":")) {
834
+ const s = r.replace(/:[^/]+/g, "([^/]+)"), l = new RegExp(`^${s}$`);
835
+ this.compiledRoutes.set(r, l), $.debug(`WsxRouter compiled regex for route: ${r} -> ${l}`);
836
+ }
837
+ n.style.display = "none";
174
838
  });
175
839
  }
176
- matchRoute(t) {
177
- if (this.views.has(t))
178
- return this.views.get(t);
179
- for (const [e, n] of this.views)
180
- if (e.includes(":")) {
181
- const g = e.replace(/:[^/]+/g, "([^/]+)");
182
- if (new RegExp(`^${g}$`).test(t))
183
- return n;
840
+ /**
841
+ * RFC 0033: 执行导航(带 View Transitions 支持)
842
+ */
843
+ performNavigation(e) {
844
+ const n = () => {
845
+ const r = this.matchRoute(e);
846
+ if (r) {
847
+ r.style.display = "block", r.style.visibility = "visible";
848
+ const s = r.getAttribute("route") || "/";
849
+ $.debug(`Showing view for route: ${s}`);
850
+ for (const [p, v] of this.views)
851
+ v !== r && (v.style.display = "none", v.style.visibility = "");
852
+ this.currentView = r;
853
+ const l = this.extractParams(s, e);
854
+ $.debug(`Extracted params for route ${s} and path ${e}:`, l), l && requestAnimationFrame(() => {
855
+ r.setAttribute("params", JSON.stringify(l)), $.debug(`Set params attribute on view: ${JSON.stringify(l)}`);
856
+ });
857
+ const m = window.location.href || `${window.location.pathname}${window.location.search}${window.location.hash}`, g = new URL(m, window.location.origin || "http://localhost"), u = {
858
+ path: e,
859
+ params: l || {},
860
+ query: Object.fromEntries(g.searchParams.entries()),
861
+ hash: g.hash.slice(1)
862
+ };
863
+ le._setCurrentRoute(u), $.debug("Updated RouterUtils._currentRoute:", u);
864
+ const i = new CustomEvent("route-changed", {
865
+ detail: u,
866
+ bubbles: !0
867
+ });
868
+ document.dispatchEvent(i);
869
+ } else {
870
+ for (const [u, i] of this.views)
871
+ i.style.display = "none";
872
+ this.currentView = null, $.warn(`No view found for path: ${e}`);
873
+ const s = window.location.href || `${window.location.pathname}${window.location.search}${window.location.hash}`, l = new URL(s, window.location.origin || "http://localhost"), m = {
874
+ path: e,
875
+ params: {},
876
+ query: Object.fromEntries(l.searchParams.entries()),
877
+ hash: l.hash.slice(1)
878
+ };
879
+ le._setCurrentRoute(m);
880
+ const g = new CustomEvent("route-changed", {
881
+ detail: m,
882
+ bubbles: !0
883
+ });
884
+ document.dispatchEvent(g);
885
+ }
886
+ this.handleScrollRestoration(e), this.dispatchEvent(new CustomEvent("after-navigate", {
887
+ detail: {
888
+ to: e,
889
+ from: this.currentPath
890
+ },
891
+ bubbles: !0
892
+ })), this.currentPath = e;
893
+ };
894
+ this.enableViewTransitions && "startViewTransition" in document ? document.startViewTransition(n) : n();
895
+ }
896
+ /**
897
+ * RFC 0033: 滚动恢复处理
898
+ */
899
+ handleScrollRestoration(e) {
900
+ this.scrollRestoration === "manual" && (this.isBackNavigation() || (window.scrollTo(0, 0), $.debug("Scrolled to top for forward navigation")));
901
+ }
902
+ /**
903
+ * RFC 0033: 检测是否是后退导航
904
+ */
905
+ isBackNavigation() {
906
+ var e;
907
+ return "navigation" in performance && performance.navigation ? performance.navigation.type === 2 : ((e = window.history.state) == null ? void 0 : e.navigationType) === "back";
908
+ }
909
+ matchRoute(e) {
910
+ if ($.warn(`matchRoute called for path: ${e}, views count: ${this.views.size}`), this.matchCache.has(e)) {
911
+ const r = this.matchCache.get(e);
912
+ return $.warn(`matchRoute: found in cache, route: ${r}`), this.views.get(r) || null;
913
+ }
914
+ if (this.views.has(e))
915
+ return this.matchCache.set(e, e), $.warn(`matchRoute: exact match found for ${e}`), this.views.get(e);
916
+ $.warn(`matchRoute: checking parameter routes, compiledRoutes count: ${this.compiledRoutes.size}`);
917
+ for (const [r, s] of this.views)
918
+ if (r.includes(":")) {
919
+ const l = this.compiledRoutes.get(r);
920
+ if (l) {
921
+ const m = l.test(e);
922
+ if ($.warn(`matchRoute: testing route ${r} against ${e}, matches: ${m}`), m)
923
+ return this.matchCache.set(e, r), $.warn(`matchRoute: parameter match found, route: ${r}, path: ${e}`), s;
924
+ } else
925
+ $.warn(`matchRoute: route ${r} has ':' but no compiled regex found`);
184
926
  }
185
- return this.views.get("*") || null;
186
- }
187
- extractParams(t, e) {
188
- var b;
189
- if (!t.includes(":")) return null;
190
- const n = ((b = t.match(/:([^/]+)/g)) == null ? void 0 : b.map(($) => $.slice(1))) || [], g = t.replace(/:[^/]+/g, "([^/]+)"), C = new RegExp(`^${g}$`), S = e.match(C);
191
- if (!S || !n.length) return null;
192
- const T = {};
193
- return n.forEach(($, P) => {
194
- T[$] = S[P + 1];
195
- }), T;
927
+ const n = this.views.get("*") || null;
928
+ return n ? (this.matchCache.set(e, "*"), $.warn(`matchRoute: wildcard match found for ${e}`)) : $.warn(`matchRoute: no match found for ${e}, no wildcard view available`), n;
929
+ }
930
+ extractParams(e, n) {
931
+ var u;
932
+ if (!e.includes(":")) return null;
933
+ const r = ((u = e.match(/:([^/]+)/g)) == null ? void 0 : u.map((i) => i.slice(1))) || [], s = e.replace(/:[^/]+/g, "([^/]+)"), l = new RegExp(`^${s}$`), m = n.match(l);
934
+ if (!m || !r.length) return null;
935
+ const g = {};
936
+ return r.forEach((i, p) => {
937
+ g[i] = m[p + 1];
938
+ }), g;
939
+ }
940
+ /**
941
+ * RFC 0032: 清除匹配缓存
942
+ * 当路由配置变更时调用,确保使用最新的路由规则
943
+ */
944
+ clearMatchCache() {
945
+ this.matchCache.clear(), $.debug("WsxRouter cleared match cache");
946
+ }
947
+ /**
948
+ * RFC 0033: 配置 View Transitions
949
+ */
950
+ setViewTransitions(e) {
951
+ this.enableViewTransitions = e, $.debug(`View Transitions ${e ? "enabled" : "disabled"}`);
952
+ }
953
+ /**
954
+ * RFC 0033: 配置 Scroll Restoration
955
+ */
956
+ setScrollRestoration(e) {
957
+ this.scrollRestoration = e, "scrollRestoration" in history && (history.scrollRestoration = e), $.debug(`Scroll Restoration set to ${e}`);
196
958
  }
197
959
  /**
198
960
  * 编程式导航 - 使用原生 History API
199
961
  */
200
- navigate(t) {
201
- window.history.pushState(null, "", t), this.handleRouteChange();
202
- }
203
- }
204
- yt = Wt;
205
- [At, wt] = Rt(yt, [], xt, 0, void 0, Y).c;
206
- wt();
207
- const lt = ":host{display:block;width:100%;height:100%}.route-view{width:100%;height:100%;position:relative}:host([loading]) .route-view{opacity:.5;transition:opacity .3s ease}:host([error]) .route-view{border:1px solid var(--error-color, #ff0000);padding:1rem}.route-view.entering{animation:fadeIn .3s ease-out}.route-view.leaving{animation:fadeOut .3s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}";
208
- var tt, et;
209
- let ut, Et, ht;
210
- function B(r, t, e) {
211
- return (t = _t(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
212
- }
213
- function Lt(r, t, e, n, g, C) {
214
- function S(i, c, u) {
215
- return function(s, a) {
216
- return u && u(s), i[c].call(s, a);
962
+ navigate(e) {
963
+ window.history.pushState(null, "", e), this.handleRouteChange();
964
+ }
965
+ }
966
+ qe = Lt;
967
+ [Rt, Fe] = wt(qe, [], He, 0, void 0, oe).c;
968
+ Fe();
969
+ const Ce = ":host{display:block;width:100%;height:100%}.route-view{width:100%;height:100%;position:relative}:host([loading]) .route-view{opacity:.5;transition:opacity .3s ease}:host([error]) .route-view{border:1px solid var(--error-color, #ff0000);padding:1rem}.route-view.entering{animation:fadeIn .3s ease-out}.route-view.leaving{animation:fadeOut .3s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}";
970
+ var me, ge;
971
+ let Oe, Be, Se;
972
+ function ee(t, e, n) {
973
+ return (e = Ke(e)) in t ? Object.defineProperty(t, e, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = n, t;
974
+ }
975
+ function kt(t, e, n, r, s, l) {
976
+ function m(o, c, f) {
977
+ return function(h, d) {
978
+ return f && f(h), o[c].call(h, d);
217
979
  };
218
980
  }
219
- function T(i, c) {
220
- for (var u = 0; u < i.length; u++) i[u].call(c);
981
+ function g(o, c) {
982
+ for (var f = 0; f < o.length; f++) o[f].call(c);
221
983
  return c;
222
984
  }
223
- function b(i, c, u, s) {
224
- if (typeof i != "function" && (s || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (s ? "" : " or undefined"));
225
- return i;
985
+ function u(o, c, f, h) {
986
+ if (typeof o != "function" && (h || o !== void 0)) throw new TypeError(c + " must " + (f || "be") + " a function" + (h ? "" : " or undefined"));
987
+ return o;
226
988
  }
227
- function $(i, c, u, s, a, W, L, R, D, y, m, d, p) {
228
- function w(l) {
229
- if (!p(l)) throw new TypeError("Attempted to access private element on non-instance");
989
+ function i(o, c, f, h, d, T, V, A, I, _, k, E, R) {
990
+ function j(b) {
991
+ if (!R(b)) throw new TypeError("Attempted to access private element on non-instance");
230
992
  }
231
- var h, x = c[0], k = c[3], j = !R;
232
- if (!j) {
233
- u || Array.isArray(x) || (x = [x]);
234
- var o = {}, E = [], v = a === 3 ? "get" : a === 4 || d ? "set" : "value";
235
- y ? (m || d ? o = { get: ft(function() {
236
- return k(this);
237
- }, s, "get"), set: function(l) {
238
- c[4](this, l);
239
- } } : o[v] = k, m || ft(o[v], s, a === 2 ? "" : v)) : m || (o = Object.getOwnPropertyDescriptor(i, s));
993
+ var y, C = c[0], O = c[3], P = !A;
994
+ if (!P) {
995
+ f || Array.isArray(C) || (C = [C]);
996
+ var a = {}, S = [], L = d === 3 ? "get" : d === 4 || E ? "set" : "value";
997
+ _ ? (k || E ? a = { get: We(function() {
998
+ return O(this);
999
+ }, h, "get"), set: function(b) {
1000
+ c[4](this, b);
1001
+ } } : a[L] = O, k || We(a[L], h, d === 2 ? "" : L)) : k || (a = Object.getOwnPropertyDescriptor(o, h));
240
1002
  }
241
- for (var f = i, N = x.length - 1; N >= 0; N -= u ? 2 : 1) {
242
- var H = x[N], q = u ? x[N - 1] : void 0, K = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: s, metadata: W, addInitializer: (function(l, _) {
243
- if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
244
- b(_, "An initializer", "be", !0), L.push(_);
245
- }).bind(null, K) };
1003
+ for (var w = o, q = C.length - 1; q >= 0; q -= f ? 2 : 1) {
1004
+ var J = C[q], Q = f ? C[q - 1] : void 0, G = {}, D = { kind: ["field", "accessor", "method", "getter", "setter", "class"][d], name: h, metadata: T, addInitializer: (function(b, W) {
1005
+ if (b.v) throw Error("attempted to call addInitializer after decoration was finished");
1006
+ u(W, "An initializer", "be", !0), V.push(W);
1007
+ }).bind(null, G) };
246
1008
  try {
247
- if (j) (h = b(H.call(q, f, O), "class decorators", "return")) && (f = h);
1009
+ if (P) (y = u(J.call(Q, w, D), "class decorators", "return")) && (w = y);
248
1010
  else {
249
- var I, z;
250
- O.static = D, O.private = y, y ? a === 2 ? I = function(l) {
251
- return w(l), o.value;
252
- } : (a < 4 && (I = S(o, "get", w)), a !== 3 && (z = S(o, "set", w))) : (I = function(l) {
253
- return l[s];
254
- }, (a < 2 || a === 4) && (z = function(l, _) {
255
- l[s] = _;
1011
+ var M, F;
1012
+ D.static = I, D.private = _, _ ? d === 2 ? M = function(b) {
1013
+ return j(b), a.value;
1014
+ } : (d < 4 && (M = m(a, "get", j)), d !== 3 && (F = m(a, "set", j))) : (M = function(b) {
1015
+ return b[h];
1016
+ }, (d < 2 || d === 4) && (F = function(b, W) {
1017
+ b[h] = W;
256
1018
  }));
257
- var Q = O.access = { has: y ? p.bind() : function(l) {
258
- return s in l;
1019
+ var X = D.access = { has: _ ? R.bind() : function(b) {
1020
+ return h in b;
259
1021
  } };
260
- if (I && (Q.get = I), z && (Q.set = z), f = H.call(q, d ? { get: o.get, set: o.set } : o[v], O), d) {
261
- if (typeof f == "object" && f) (h = b(f.get, "accessor.get")) && (o.get = h), (h = b(f.set, "accessor.set")) && (o.set = h), (h = b(f.init, "accessor.init")) && E.push(h);
262
- else if (f !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
263
- } else b(f, (m ? "field" : "method") + " decorators", "return") && (m ? E.push(f) : o[v] = f);
1022
+ if (M && (X.get = M), F && (X.set = F), w = J.call(Q, E ? { get: a.get, set: a.set } : a[L], D), E) {
1023
+ if (typeof w == "object" && w) (y = u(w.get, "accessor.get")) && (a.get = y), (y = u(w.set, "accessor.set")) && (a.set = y), (y = u(w.init, "accessor.init")) && S.push(y);
1024
+ else if (w !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
1025
+ } else u(w, (k ? "field" : "method") + " decorators", "return") && (k ? S.push(w) : a[L] = w);
264
1026
  }
265
1027
  } finally {
266
- K.v = !0;
1028
+ G.v = !0;
267
1029
  }
268
1030
  }
269
- return (m || d) && R.push(function(l, _) {
270
- for (var V = E.length - 1; V >= 0; V--) _ = E[V].call(l, _);
271
- return _;
272
- }), m || j || (y ? d ? R.push(S(o, "get"), S(o, "set")) : R.push(a === 2 ? o[v] : S.call.bind(o[v])) : Object.defineProperty(i, s, o)), f;
273
- }
274
- function P(i, c) {
275
- return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
276
- }
277
- if (arguments.length >= 6) var U = C[Symbol.metadata || Symbol.for("Symbol.metadata")];
278
- var A = Object.create(U ?? null), G = function(i, c, u, s) {
279
- var a, W, L = [], R = function(v) {
280
- return It(v) === i;
281
- }, D = /* @__PURE__ */ new Map();
282
- function y(v) {
283
- v && L.push(T.bind(null, v));
1031
+ return (k || E) && A.push(function(b, W) {
1032
+ for (var H = S.length - 1; H >= 0; H--) W = S[H].call(b, W);
1033
+ return W;
1034
+ }), k || P || (_ ? E ? A.push(m(a, "get"), m(a, "set")) : A.push(d === 2 ? a[L] : m.call.bind(a[L])) : Object.defineProperty(o, h, a)), w;
1035
+ }
1036
+ function p(o, c) {
1037
+ return Object.defineProperty(o, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
1038
+ }
1039
+ if (arguments.length >= 6) var v = l[Symbol.metadata || Symbol.for("Symbol.metadata")];
1040
+ var z = Object.create(v ?? null), x = function(o, c, f, h) {
1041
+ var d, T, V = [], A = function(L) {
1042
+ return $t(L) === o;
1043
+ }, I = /* @__PURE__ */ new Map();
1044
+ function _(L) {
1045
+ L && V.push(g.bind(null, L));
284
1046
  }
285
- for (var m = 0; m < c.length; m++) {
286
- var d = c[m];
287
- if (Array.isArray(d)) {
288
- var p = d[1], w = d[2], h = d.length > 3, x = 16 & p, k = !!(8 & p), j = (p &= 7) == 0, o = w + "/" + k;
289
- if (!j && !h) {
290
- var E = D.get(o);
291
- if (E === !0 || E === 3 && p !== 4 || E === 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: " + w);
292
- D.set(o, !(p > 2) || p);
1047
+ for (var k = 0; k < c.length; k++) {
1048
+ var E = c[k];
1049
+ if (Array.isArray(E)) {
1050
+ var R = E[1], j = E[2], y = E.length > 3, C = 16 & R, O = !!(8 & R), P = (R &= 7) == 0, a = j + "/" + O;
1051
+ if (!P && !y) {
1052
+ var S = I.get(a);
1053
+ if (S === !0 || S === 3 && R !== 4 || S === 4 && R !== 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: " + j);
1054
+ I.set(a, !(R > 2) || R);
293
1055
  }
294
- $(k ? i : i.prototype, d, x, h ? "#" + w : _t(w), p, s, k ? W = W || [] : a = a || [], L, k, h, j, p === 1, k && h ? R : u);
1056
+ i(O ? o : o.prototype, E, C, y ? "#" + j : Ke(j), R, h, O ? T = T || [] : d = d || [], V, O, y, P, R === 1, O && y ? A : f);
295
1057
  }
296
1058
  }
297
- return y(a), y(W), L;
298
- }(r, t, g, A);
299
- return e.length || P(r, A), { e: G, get c() {
300
- var i = [];
301
- return e.length && [P($(r, [e], n, r.name, 5, A, i), A), T.bind(null, i, r)];
1059
+ return _(d), _(T), V;
1060
+ }(t, e, s, z);
1061
+ return n.length || p(t, z), { e: x, get c() {
1062
+ var o = [];
1063
+ return n.length && [p(i(t, [n], r, t.name, 5, z, o), z), g.bind(null, o, t)];
302
1064
  } };
303
1065
  }
304
- function _t(r) {
305
- var t = Ot(r, "string");
306
- return typeof t == "symbol" ? t : t + "";
1066
+ function Ke(t) {
1067
+ var e = _t(t, "string");
1068
+ return typeof e == "symbol" ? e : e + "";
307
1069
  }
308
- function Ot(r, t) {
309
- if (typeof r != "object" || !r) return r;
310
- var e = r[Symbol.toPrimitive];
311
- if (e !== void 0) {
312
- var n = e.call(r, t);
313
- if (typeof n != "object") return n;
1070
+ function _t(t, e) {
1071
+ if (typeof t != "object" || !t) return t;
1072
+ var n = t[Symbol.toPrimitive];
1073
+ if (n !== void 0) {
1074
+ var r = n.call(t, e);
1075
+ if (typeof r != "object") return r;
314
1076
  throw new TypeError("@@toPrimitive must return a primitive value.");
315
1077
  }
316
- return (t === "string" ? String : Number)(r);
1078
+ return (e === "string" ? String : Number)(t);
317
1079
  }
318
- function ft(r, t, e) {
319
- typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
1080
+ function We(t, e, n) {
1081
+ typeof e == "symbol" && (e = (e = e.description) ? "[" + e + "]" : "");
320
1082
  try {
321
- Object.defineProperty(r, "name", { configurable: !0, value: e ? e + " " + t : t });
1083
+ Object.defineProperty(t, "name", { configurable: !0, value: n ? n + " " + e : e });
322
1084
  } catch {
323
1085
  }
324
- return r;
1086
+ return t;
325
1087
  }
326
- function It(r) {
327
- if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
328
- return r;
1088
+ function $t(t) {
1089
+ if (Object(t) !== t) throw TypeError("right-hand side of 'in' should be an object, got " + (t !== null ? typeof t : "null"));
1090
+ return t;
329
1091
  }
330
- function Tt(r) {
331
- return r;
1092
+ function jt(t) {
1093
+ return t;
332
1094
  }
333
- const rt = F("WsxView");
334
- Et = [ot({
1095
+ const N = he("WsxView");
1096
+ Be = [we({
335
1097
  tagName: "wsx-view"
336
1098
  })];
337
- let dt;
338
- new (ht = (et = class extends Y {
1099
+ let ze;
1100
+ new (Se = (ge = class extends oe {
1101
+ // 防止重复加载的标志
339
1102
  constructor() {
340
1103
  super({
341
- styles: lt,
1104
+ styles: Ce,
342
1105
  styleName: "wsx-view"
343
- }), B(this, "_autoStyles", lt), B(this, "component", null), B(this, "params", {}), B(this, "componentInstance", null);
1106
+ }), ee(this, "_autoStyles", Ce), ee(this, "component", null), ee(this, "params", {}), ee(this, "componentInstance", null), ee(this, "isLoading", !1);
344
1107
  }
345
1108
  render() {
346
- return /* @__PURE__ */ Z("div", { class: "route-view" });
1109
+ return /* @__PURE__ */ ae("div", { class: "route-view" });
347
1110
  }
348
1111
  onConnected() {
349
- const t = this.getAttribute("component");
350
- t && !this.componentInstance && this.loadComponent(t);
1112
+ requestAnimationFrame(() => {
1113
+ if (!this.connected || this.isLoading || this.componentInstance)
1114
+ return;
1115
+ const e = this.getAttribute("component");
1116
+ e && this.loadComponent(e);
1117
+ });
351
1118
  }
352
- onAttributeChanged(t, e, n) {
353
- if (t === "component" && n && !this.componentInstance)
354
- this.loadComponent(n);
355
- else if (t === "params" && this.componentInstance)
356
- try {
357
- this.params = JSON.parse(n), Object.entries(this.params).forEach(([g, C]) => {
358
- this.componentInstance.setAttribute(g, C);
1119
+ onAttributeChanged(e, n, r) {
1120
+ if (this.connected) {
1121
+ if (e === "component" && r && !this.componentInstance && !this.isLoading)
1122
+ requestAnimationFrame(() => {
1123
+ this.connected && !this.componentInstance && !this.isLoading && this.loadComponent(r);
359
1124
  });
360
- } catch (g) {
361
- rt.error("Failed to parse params:", g);
362
- }
1125
+ else if (e === "params" && this.componentInstance)
1126
+ try {
1127
+ this.params = JSON.parse(r), N.debug("WsxView: params attribute changed, setting on component:", this.params), Object.entries(this.params).forEach(([s, l]) => {
1128
+ this.componentInstance.setAttribute(s, l);
1129
+ }), N.debug(`WsxView: params set on component ${this.componentInstance.tagName}`);
1130
+ } catch (s) {
1131
+ N.warn("Failed to parse params:", s);
1132
+ }
1133
+ }
363
1134
  }
364
- async loadComponent(t) {
365
- if (this.componentInstance && (this.componentInstance.remove(), this.componentInstance = null), !customElements.get(t)) {
366
- rt.warn(`Component ${t} not found in customElements registry`);
1135
+ async loadComponent(e) {
1136
+ if (!this.connected || this.isLoading || this.componentInstance) {
1137
+ N.debug(`Skipping loadComponent for ${e}: connected=${this.connected}, isLoading=${this.isLoading}, hasInstance=${!!this.componentInstance}`);
367
1138
  return;
368
1139
  }
369
- this.componentInstance = document.createElement(t), Object.keys(this.params).length > 0 && Object.entries(this.params).forEach(([g, C]) => {
370
- this.componentInstance.setAttribute(g, C);
371
- });
372
- const n = this.querySelector(".route-view");
373
- n ? n.appendChild(this.componentInstance) : rt.error("Route view container not found");
1140
+ N.debug(`WsxView: Loading component ${e}`), this.isLoading = !0;
1141
+ try {
1142
+ const n = this.componentInstance;
1143
+ if (n && (n.remove(), this.componentInstance = null), !customElements.get(e)) {
1144
+ N.warn(`Component ${e} not found in customElements registry`), this.isLoading = !1;
1145
+ return;
1146
+ }
1147
+ N.warn(`WsxView: Creating instance of ${e}`), this.componentInstance = document.createElement(e), Object.keys(this.params).length > 0 && (N.warn(`WsxView: Setting initial params on ${e}:`, this.params), Object.entries(this.params).forEach(([l, m]) => {
1148
+ this.componentInstance.setAttribute(l, m);
1149
+ }));
1150
+ const s = this.querySelector(".route-view");
1151
+ if (s) {
1152
+ if (N.warn(`WsxView: Appending ${e} to container`), !customElements.get(e)) {
1153
+ N.error(`WsxView: Component ${e} is not registered in customElements registry!`), this.isLoading = !1, this.componentInstance = null;
1154
+ return;
1155
+ }
1156
+ s.appendChild(this.componentInstance), N.warn(`WsxView: Component ${e} appended successfully, waiting for connectedCallback...`), setTimeout(() => {
1157
+ this.componentInstance && this.componentInstance.isConnected ? N.warn(`WsxView: Component ${e} is now connected to DOM`) : N.error(`WsxView: Component ${e} was not connected to DOM!`);
1158
+ }, 0);
1159
+ } else
1160
+ N.error("WsxView: Route view container not found"), this.componentInstance = null;
1161
+ } catch (n) {
1162
+ N.warn(`Error loading component ${e}:`, n), this.componentInstance = null;
1163
+ } finally {
1164
+ this.isLoading = !1, N.warn(`WsxView: loadComponent for ${e} completed, isLoading=${this.isLoading}`);
1165
+ }
374
1166
  }
375
1167
  onDisconnected() {
376
1168
  this.componentInstance && (this.componentInstance.remove(), this.componentInstance = null);
377
1169
  }
378
- }, [dt, ut] = Lt(et, [], Et, 0, void 0, Y).c, et), tt = class extends Tt {
1170
+ }, [ze, Oe] = kt(ge, [], Be, 0, void 0, oe).c, ge), me = class extends jt {
379
1171
  constructor() {
380
- super(dt), B(this, "observedAttributes", ["route", "component", "params"]), ut();
381
- }
382
- }, B(tt, ht, void 0), tt)();
383
- const Pt = ':host{display:inline-block;min-width:fit-content;min-height:fit-content;width:auto;height:auto}.wsx-link{color:var(--link-color, #007bff);text-decoration:var(--link-decoration, underline);cursor:pointer;transition:color .2s ease;display:inline-block;min-height:1.2em;line-height:1.2}.wsx-link:hover{color:var(--link-hover-color, #0056b3);text-decoration:var(--link-hover-decoration, underline)}.wsx-link:focus{outline:2px solid var(--link-focus-color, #007bff);outline-offset:2px}.wsx-link.active{color:var(--link-active-color, #6c757d);font-weight:var(--link-active-weight, bold)}:host([disabled]) .wsx-link{color:var(--link-disabled-color, #6c757d);cursor:not-allowed;pointer-events:none}:host([external]) .wsx-link:after{content:"↗";font-size:.8em;margin-left:.2em;opacity:.7}:host([variant="button"]) .wsx-link{background-color:var(--button-bg, #007bff);color:var(--button-color, white);padding:.5rem 1rem;border-radius:.25rem;text-decoration:none;display:inline-block}:host([variant="button"]) .wsx-link:hover{background-color:var(--button-hover-bg, #0056b3);color:var(--button-hover-color, white)}:host([variant="tab"]) .wsx-link{padding:.5rem 1rem;border-bottom:2px solid transparent;text-decoration:none}:host([variant="tab"]) .wsx-link.active{border-bottom-color:var(--tab-active-border, #007bff)}';
384
- var nt, it;
385
- let pt, St, vt;
386
- function M(r, t, e) {
387
- return (t = Ct(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
388
- }
389
- function Dt(r, t, e, n, g, C) {
390
- function S(i, c, u) {
391
- return function(s, a) {
392
- return u && u(s), i[c].call(s, a);
1172
+ super(ze), ee(this, "observedAttributes", ["route", "component", "params"]), Oe();
1173
+ }
1174
+ }, ee(me, Se, void 0), me)();
1175
+ const Ct = ':host{display:inline-block;min-width:fit-content;min-height:fit-content;width:auto;height:auto}.wsx-link{color:var(--link-color, #007bff);text-decoration:var(--link-decoration, underline);cursor:pointer;transition:color .2s ease;display:inline-block;min-height:1.2em;line-height:1.2}.wsx-link:hover{color:var(--link-hover-color, #0056b3);text-decoration:var(--link-hover-decoration, underline)}.wsx-link:focus{outline:2px solid var(--link-focus-color, var(--focus-color, #dc2626));outline-offset:2px}.wsx-link.active{color:var(--link-active-color, #6c757d);font-weight:var(--link-active-weight, bold)}:host([disabled]) .wsx-link{color:var(--link-disabled-color, #6c757d);cursor:not-allowed;pointer-events:none}:host([external]) .wsx-link:after{content:"↗";font-size:.8em;margin-left:.2em;opacity:.7}:host([variant="button"]) .wsx-link{background-color:var(--button-bg, #007bff);color:var(--button-color, white);padding:.5rem 1rem;border-radius:.25rem;text-decoration:none;display:inline-block}:host([variant="button"]) .wsx-link:hover{background-color:var(--button-hover-bg, #0056b3);color:var(--button-hover-color, white)}:host([variant="tab"]) .wsx-link{padding:.5rem 1rem;border-bottom:2px solid transparent;text-decoration:none}:host([variant="tab"]) .wsx-link.active{border-bottom-color:var(--tab-active-border, #007bff)}';
1176
+ var pe, ve;
1177
+ let Ae, Je, Te;
1178
+ function B(t, e, n) {
1179
+ return (e = Qe(e)) in t ? Object.defineProperty(t, e, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = n, t;
1180
+ }
1181
+ function Ot(t, e, n, r, s, l) {
1182
+ function m(o, c, f) {
1183
+ return function(h, d) {
1184
+ return f && f(h), o[c].call(h, d);
393
1185
  };
394
1186
  }
395
- function T(i, c) {
396
- for (var u = 0; u < i.length; u++) i[u].call(c);
1187
+ function g(o, c) {
1188
+ for (var f = 0; f < o.length; f++) o[f].call(c);
397
1189
  return c;
398
1190
  }
399
- function b(i, c, u, s) {
400
- if (typeof i != "function" && (s || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (s ? "" : " or undefined"));
401
- return i;
1191
+ function u(o, c, f, h) {
1192
+ if (typeof o != "function" && (h || o !== void 0)) throw new TypeError(c + " must " + (f || "be") + " a function" + (h ? "" : " or undefined"));
1193
+ return o;
402
1194
  }
403
- function $(i, c, u, s, a, W, L, R, D, y, m, d, p) {
404
- function w(l) {
405
- if (!p(l)) throw new TypeError("Attempted to access private element on non-instance");
1195
+ function i(o, c, f, h, d, T, V, A, I, _, k, E, R) {
1196
+ function j(b) {
1197
+ if (!R(b)) throw new TypeError("Attempted to access private element on non-instance");
406
1198
  }
407
- var h, x = c[0], k = c[3], j = !R;
408
- if (!j) {
409
- u || Array.isArray(x) || (x = [x]);
410
- var o = {}, E = [], v = a === 3 ? "get" : a === 4 || d ? "set" : "value";
411
- y ? (m || d ? o = { get: mt(function() {
412
- return k(this);
413
- }, s, "get"), set: function(l) {
414
- c[4](this, l);
415
- } } : o[v] = k, m || mt(o[v], s, a === 2 ? "" : v)) : m || (o = Object.getOwnPropertyDescriptor(i, s));
1199
+ var y, C = c[0], O = c[3], P = !A;
1200
+ if (!P) {
1201
+ f || Array.isArray(C) || (C = [C]);
1202
+ var a = {}, S = [], L = d === 3 ? "get" : d === 4 || E ? "set" : "value";
1203
+ _ ? (k || E ? a = { get: Ve(function() {
1204
+ return O(this);
1205
+ }, h, "get"), set: function(b) {
1206
+ c[4](this, b);
1207
+ } } : a[L] = O, k || Ve(a[L], h, d === 2 ? "" : L)) : k || (a = Object.getOwnPropertyDescriptor(o, h));
416
1208
  }
417
- for (var f = i, N = x.length - 1; N >= 0; N -= u ? 2 : 1) {
418
- var H = x[N], q = u ? x[N - 1] : void 0, K = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: s, metadata: W, addInitializer: (function(l, _) {
419
- if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
420
- b(_, "An initializer", "be", !0), L.push(_);
421
- }).bind(null, K) };
1209
+ for (var w = o, q = C.length - 1; q >= 0; q -= f ? 2 : 1) {
1210
+ var J = C[q], Q = f ? C[q - 1] : void 0, G = {}, D = { kind: ["field", "accessor", "method", "getter", "setter", "class"][d], name: h, metadata: T, addInitializer: (function(b, W) {
1211
+ if (b.v) throw Error("attempted to call addInitializer after decoration was finished");
1212
+ u(W, "An initializer", "be", !0), V.push(W);
1213
+ }).bind(null, G) };
422
1214
  try {
423
- if (j) (h = b(H.call(q, f, O), "class decorators", "return")) && (f = h);
1215
+ if (P) (y = u(J.call(Q, w, D), "class decorators", "return")) && (w = y);
424
1216
  else {
425
- var I, z;
426
- O.static = D, O.private = y, y ? a === 2 ? I = function(l) {
427
- return w(l), o.value;
428
- } : (a < 4 && (I = S(o, "get", w)), a !== 3 && (z = S(o, "set", w))) : (I = function(l) {
429
- return l[s];
430
- }, (a < 2 || a === 4) && (z = function(l, _) {
431
- l[s] = _;
1217
+ var M, F;
1218
+ D.static = I, D.private = _, _ ? d === 2 ? M = function(b) {
1219
+ return j(b), a.value;
1220
+ } : (d < 4 && (M = m(a, "get", j)), d !== 3 && (F = m(a, "set", j))) : (M = function(b) {
1221
+ return b[h];
1222
+ }, (d < 2 || d === 4) && (F = function(b, W) {
1223
+ b[h] = W;
432
1224
  }));
433
- var Q = O.access = { has: y ? p.bind() : function(l) {
434
- return s in l;
1225
+ var X = D.access = { has: _ ? R.bind() : function(b) {
1226
+ return h in b;
435
1227
  } };
436
- if (I && (Q.get = I), z && (Q.set = z), f = H.call(q, d ? { get: o.get, set: o.set } : o[v], O), d) {
437
- if (typeof f == "object" && f) (h = b(f.get, "accessor.get")) && (o.get = h), (h = b(f.set, "accessor.set")) && (o.set = h), (h = b(f.init, "accessor.init")) && E.push(h);
438
- else if (f !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
439
- } else b(f, (m ? "field" : "method") + " decorators", "return") && (m ? E.push(f) : o[v] = f);
1228
+ if (M && (X.get = M), F && (X.set = F), w = J.call(Q, E ? { get: a.get, set: a.set } : a[L], D), E) {
1229
+ if (typeof w == "object" && w) (y = u(w.get, "accessor.get")) && (a.get = y), (y = u(w.set, "accessor.set")) && (a.set = y), (y = u(w.init, "accessor.init")) && S.push(y);
1230
+ else if (w !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
1231
+ } else u(w, (k ? "field" : "method") + " decorators", "return") && (k ? S.push(w) : a[L] = w);
440
1232
  }
441
1233
  } finally {
442
- K.v = !0;
1234
+ G.v = !0;
443
1235
  }
444
1236
  }
445
- return (m || d) && R.push(function(l, _) {
446
- for (var V = E.length - 1; V >= 0; V--) _ = E[V].call(l, _);
447
- return _;
448
- }), m || j || (y ? d ? R.push(S(o, "get"), S(o, "set")) : R.push(a === 2 ? o[v] : S.call.bind(o[v])) : Object.defineProperty(i, s, o)), f;
449
- }
450
- function P(i, c) {
451
- return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
452
- }
453
- if (arguments.length >= 6) var U = C[Symbol.metadata || Symbol.for("Symbol.metadata")];
454
- var A = Object.create(U ?? null), G = function(i, c, u, s) {
455
- var a, W, L = [], R = function(v) {
456
- return zt(v) === i;
457
- }, D = /* @__PURE__ */ new Map();
458
- function y(v) {
459
- v && L.push(T.bind(null, v));
1237
+ return (k || E) && A.push(function(b, W) {
1238
+ for (var H = S.length - 1; H >= 0; H--) W = S[H].call(b, W);
1239
+ return W;
1240
+ }), k || P || (_ ? E ? A.push(m(a, "get"), m(a, "set")) : A.push(d === 2 ? a[L] : m.call.bind(a[L])) : Object.defineProperty(o, h, a)), w;
1241
+ }
1242
+ function p(o, c) {
1243
+ return Object.defineProperty(o, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
1244
+ }
1245
+ if (arguments.length >= 6) var v = l[Symbol.metadata || Symbol.for("Symbol.metadata")];
1246
+ var z = Object.create(v ?? null), x = function(o, c, f, h) {
1247
+ var d, T, V = [], A = function(L) {
1248
+ return Wt(L) === o;
1249
+ }, I = /* @__PURE__ */ new Map();
1250
+ function _(L) {
1251
+ L && V.push(g.bind(null, L));
460
1252
  }
461
- for (var m = 0; m < c.length; m++) {
462
- var d = c[m];
463
- if (Array.isArray(d)) {
464
- var p = d[1], w = d[2], h = d.length > 3, x = 16 & p, k = !!(8 & p), j = (p &= 7) == 0, o = w + "/" + k;
465
- if (!j && !h) {
466
- var E = D.get(o);
467
- if (E === !0 || E === 3 && p !== 4 || E === 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: " + w);
468
- D.set(o, !(p > 2) || p);
1253
+ for (var k = 0; k < c.length; k++) {
1254
+ var E = c[k];
1255
+ if (Array.isArray(E)) {
1256
+ var R = E[1], j = E[2], y = E.length > 3, C = 16 & R, O = !!(8 & R), P = (R &= 7) == 0, a = j + "/" + O;
1257
+ if (!P && !y) {
1258
+ var S = I.get(a);
1259
+ if (S === !0 || S === 3 && R !== 4 || S === 4 && R !== 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: " + j);
1260
+ I.set(a, !(R > 2) || R);
469
1261
  }
470
- $(k ? i : i.prototype, d, x, h ? "#" + w : Ct(w), p, s, k ? W = W || [] : a = a || [], L, k, h, j, p === 1, k && h ? R : u);
1262
+ i(O ? o : o.prototype, E, C, y ? "#" + j : Qe(j), R, h, O ? T = T || [] : d = d || [], V, O, y, P, R === 1, O && y ? A : f);
471
1263
  }
472
1264
  }
473
- return y(a), y(W), L;
474
- }(r, t, g, A);
475
- return e.length || P(r, A), { e: G, get c() {
476
- var i = [];
477
- return e.length && [P($(r, [e], n, r.name, 5, A, i), A), T.bind(null, i, r)];
1265
+ return _(d), _(T), V;
1266
+ }(t, e, s, z);
1267
+ return n.length || p(t, z), { e: x, get c() {
1268
+ var o = [];
1269
+ return n.length && [p(i(t, [n], r, t.name, 5, z, o), z), g.bind(null, o, t)];
478
1270
  } };
479
1271
  }
480
- function Ct(r) {
481
- var t = Nt(r, "string");
482
- return typeof t == "symbol" ? t : t + "";
1272
+ function Qe(t) {
1273
+ var e = St(t, "string");
1274
+ return typeof e == "symbol" ? e : e + "";
483
1275
  }
484
- function Nt(r, t) {
485
- if (typeof r != "object" || !r) return r;
486
- var e = r[Symbol.toPrimitive];
487
- if (e !== void 0) {
488
- var n = e.call(r, t);
489
- if (typeof n != "object") return n;
1276
+ function St(t, e) {
1277
+ if (typeof t != "object" || !t) return t;
1278
+ var n = t[Symbol.toPrimitive];
1279
+ if (n !== void 0) {
1280
+ var r = n.call(t, e);
1281
+ if (typeof r != "object") return r;
490
1282
  throw new TypeError("@@toPrimitive must return a primitive value.");
491
1283
  }
492
- return (t === "string" ? String : Number)(r);
1284
+ return (e === "string" ? String : Number)(t);
493
1285
  }
494
- function mt(r, t, e) {
495
- typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
1286
+ function Ve(t, e, n) {
1287
+ typeof e == "symbol" && (e = (e = e.description) ? "[" + e + "]" : "");
496
1288
  try {
497
- Object.defineProperty(r, "name", { configurable: !0, value: e ? e + " " + t : t });
1289
+ Object.defineProperty(t, "name", { configurable: !0, value: n ? n + " " + e : e });
498
1290
  } catch {
499
1291
  }
500
- return r;
1292
+ return t;
501
1293
  }
502
- function zt(r) {
503
- if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
504
- return r;
1294
+ function Wt(t) {
1295
+ if (Object(t) !== t) throw TypeError("right-hand side of 'in' should be an object, got " + (t !== null ? typeof t : "null"));
1296
+ return t;
505
1297
  }
506
- function Ut(r) {
507
- return r;
1298
+ function zt(t) {
1299
+ return t;
508
1300
  }
509
- const gt = F("WsxLink");
510
- St = [ot({
1301
+ const Ie = he("WsxLink");
1302
+ Je = [we({
511
1303
  tagName: "wsx-link"
512
1304
  })];
513
- let bt;
514
- new (vt = (it = class extends st {
1305
+ let Pe;
1306
+ new (Te = (ve = class extends Re {
515
1307
  constructor() {
516
- super(), M(this, "_autoStyles", Pt), M(this, "to", void 0), M(this, "replace", void 0), M(this, "activeClass", void 0), M(this, "exact", void 0), M(this, "handleClick", ($) => {
517
- if ($.preventDefault(), !this.to) {
518
- gt.warn("No 'to' attribute specified");
1308
+ super(), B(this, "_autoStyles", Ct), B(this, "to", void 0), B(this, "replace", void 0), B(this, "activeClass", void 0), B(this, "exact", void 0), B(this, "handleClick", (i) => {
1309
+ if (i.preventDefault(), !this.to) {
1310
+ Ie.warn("No 'to' attribute specified");
519
1311
  return;
520
1312
  }
521
1313
  if (this.isExternalLink(this.to)) {
522
1314
  window.open(this.to, "_blank");
523
1315
  return;
524
1316
  }
525
- this.replace ? window.history.replaceState(null, "", this.to) : window.history.pushState(null, "", this.to), window.dispatchEvent(new PopStateEvent("popstate")), gt.debug(`Navigated to: ${this.to}`);
526
- }), M(this, "updateActiveState", () => {
527
- var A;
528
- const $ = window.location.pathname, P = this.exact ? $ === this.to : $.startsWith(this.to) && this.to !== "/", U = (A = this.shadowRoot) == null ? void 0 : A.querySelector("a");
529
- U && (P ? (U.classList.add(this.activeClass), this.setAttribute("active", "")) : (U.classList.remove(this.activeClass), this.removeAttribute("active")));
1317
+ this.replace ? window.history.replaceState(null, "", this.to) : window.history.pushState(null, "", this.to), window.dispatchEvent(new PopStateEvent("popstate")), Ie.debug(`Navigated to: ${this.to}`);
1318
+ }), B(this, "updateActiveState", () => {
1319
+ var z;
1320
+ const i = window.location.pathname, p = this.exact ? i === this.to : i.startsWith(this.to) && this.to !== "/", v = (z = this.shadowRoot) == null ? void 0 : z.querySelector("a");
1321
+ v && (p ? (v.classList.add(this.activeClass), this.setAttribute("active", "")) : (v.classList.remove(this.activeClass), this.removeAttribute("active")));
530
1322
  });
531
- const [t, e] = this.useState("to", "");
1323
+ const [e, n] = this.useState("to", "");
532
1324
  Object.defineProperty(this, "to", {
533
- get: t,
534
- set: e,
1325
+ get: e,
1326
+ set: n,
535
1327
  enumerable: !0,
536
1328
  configurable: !0
537
1329
  });
538
- const [n, g] = this.useState("replace", !1);
1330
+ const [r, s] = this.useState("replace", !1);
539
1331
  Object.defineProperty(this, "replace", {
540
- get: n,
541
- set: g,
1332
+ get: r,
1333
+ set: s,
542
1334
  enumerable: !0,
543
1335
  configurable: !0
544
1336
  });
545
- const [C, S] = this.useState("activeClass", "active");
1337
+ const [l, m] = this.useState("activeClass", "active");
546
1338
  Object.defineProperty(this, "activeClass", {
547
- get: C,
548
- set: S,
1339
+ get: l,
1340
+ set: m,
549
1341
  enumerable: !0,
550
1342
  configurable: !0
551
1343
  });
552
- const [T, b] = this.useState("exact", !1);
1344
+ const [g, u] = this.useState("exact", !1);
553
1345
  Object.defineProperty(this, "exact", {
554
- get: T,
555
- set: b,
1346
+ get: g,
1347
+ set: u,
556
1348
  enumerable: !0,
557
1349
  configurable: !0
558
1350
  });
559
1351
  }
560
1352
  render() {
561
- return /* @__PURE__ */ Z("a", { href: this.to, class: "wsx-link", onClick: this.handleClick, part: "link" }, /* @__PURE__ */ Z("slot", null));
1353
+ return /* @__PURE__ */ ae("a", { href: this.to, class: "wsx-link", onClick: this.handleClick, part: "link" }, /* @__PURE__ */ ae("slot", null));
562
1354
  }
563
1355
  onConnected() {
564
1356
  this.to = this.getAttribute("to") || "", this.replace = this.hasAttribute("replace"), this.activeClass = this.getAttribute("active-class") || "active", this.exact = this.hasAttribute("exact");
565
- const t = this.shadowRoot.querySelector(".wsx-link");
566
- t && (t.href = this.to), window.addEventListener("popstate", this.updateActiveState), document.addEventListener("route-changed", this.updateActiveState), this.updateActiveState();
1357
+ const e = this.shadowRoot.querySelector(".wsx-link");
1358
+ e && (e.href = this.to), window.addEventListener("popstate", this.updateActiveState), document.addEventListener("route-changed", this.updateActiveState), this.updateActiveState();
567
1359
  }
568
1360
  onDisconnected() {
569
1361
  window.removeEventListener("popstate", this.updateActiveState), document.removeEventListener("route-changed", this.updateActiveState);
570
1362
  }
571
- onAttributeChanged(t, e, n) {
572
- switch (t) {
1363
+ onAttributeChanged(e, n, r) {
1364
+ switch (e) {
573
1365
  case "to":
574
- this.to = n || "", this.updateActiveState();
1366
+ this.to = r || "", this.updateActiveState();
575
1367
  break;
576
1368
  case "replace":
577
- this.replace = n !== null && n !== "false";
1369
+ this.replace = r !== null && r !== "false";
578
1370
  break;
579
1371
  case "active-class":
580
- this.activeClass = n || "active", this.updateActiveState();
1372
+ this.activeClass = r || "active", this.updateActiveState();
581
1373
  break;
582
1374
  case "exact":
583
- this.exact = n !== null && n !== "false", this.updateActiveState();
1375
+ this.exact = r !== null && r !== "false", this.updateActiveState();
584
1376
  break;
585
1377
  }
586
1378
  }
587
- isExternalLink(t) {
588
- return t.startsWith("http://") || t.startsWith("https://") || t.startsWith("mailto:") || t.startsWith("tel:");
1379
+ isExternalLink(e) {
1380
+ return e.startsWith("http://") || e.startsWith("https://") || e.startsWith("mailto:") || e.startsWith("tel:");
589
1381
  }
590
1382
  /**
591
1383
  * 编程式导航
@@ -596,179 +1388,14 @@ new (vt = (it = class extends st {
596
1388
  cancelable: !0
597
1389
  }));
598
1390
  }
599
- }, [bt, pt] = Dt(it, [], St, 0, void 0, st).c, it), nt = class extends Ut {
1391
+ }, [Pe, Ae] = Ot(ve, [], Je, 0, void 0, Re).c, ve), pe = class extends zt {
600
1392
  constructor() {
601
- super(bt), M(this, "observedAttributes", ["to", "replace", "active-class", "exact"]), pt();
602
- }
603
- }, M(nt, vt, void 0), nt)();
604
- const Vt = F("RouterUtils");
605
- class Kt {
606
- /**
607
- * 编程式导航
608
- */
609
- static navigate(t, e = !1) {
610
- e ? window.history.replaceState(null, "", t) : window.history.pushState(null, "", t), window.dispatchEvent(new PopStateEvent("popstate")), Vt.debug(`Navigated to: ${t} (replace: ${e})`);
611
- }
612
- /**
613
- * 获取当前路由信息
614
- */
615
- static getCurrentRoute() {
616
- const t = new URL(window.location.href);
617
- return {
618
- path: t.pathname,
619
- params: {},
620
- // 需要路由匹配后才能确定
621
- query: Object.fromEntries(t.searchParams.entries()),
622
- hash: t.hash.slice(1)
623
- // 移除 # 号
624
- };
625
- }
626
- /**
627
- * 解析路由路径,提取参数
628
- */
629
- static parseRoute(t, e) {
630
- var n;
631
- if (t === e)
632
- return {
633
- route: t,
634
- params: {},
635
- exact: !0
636
- };
637
- if (t === "*")
638
- return {
639
- route: t,
640
- params: {},
641
- exact: !1
642
- };
643
- if (t.includes(":")) {
644
- const g = ((n = t.match(/:([^/]+)/g)) == null ? void 0 : n.map((b) => b.slice(1))) || [], C = t.replace(/:[^/]+/g, "([^/]+)"), S = new RegExp(`^${C}$`), T = e.match(S);
645
- if (T && g.length > 0) {
646
- const b = {};
647
- return g.forEach(($, P) => {
648
- b[$] = T[P + 1];
649
- }), {
650
- route: t,
651
- params: b,
652
- exact: !0
653
- };
654
- }
655
- }
656
- if (t.endsWith("/*")) {
657
- const g = t.slice(0, -2);
658
- if (e.startsWith(g))
659
- return {
660
- route: t,
661
- params: {},
662
- exact: !1
663
- };
664
- }
665
- return null;
1393
+ super(Pe), B(this, "observedAttributes", ["to", "replace", "active-class", "exact"]), Ae();
666
1394
  }
667
- /**
668
- * 构建路由路径,替换参数
669
- */
670
- static buildPath(t, e = {}) {
671
- let n = t;
672
- return Object.entries(e).forEach(([g, C]) => {
673
- n = n.replace(`:${g}`, encodeURIComponent(C));
674
- }), n;
675
- }
676
- /**
677
- * 检查路由是否匹配当前路径
678
- */
679
- static isRouteActive(t, e = !1) {
680
- const n = window.location.pathname;
681
- return e ? n === t : t === "/" ? n === "/" : n.startsWith(t);
682
- }
683
- /**
684
- * 获取路由层级
685
- */
686
- static getRouteDepth(t) {
687
- return t.split("/").filter((e) => e.length > 0).length;
688
- }
689
- /**
690
- * 获取父级路由
691
- */
692
- static getParentRoute(t) {
693
- const e = t.split("/").filter((n) => n.length > 0);
694
- return e.length <= 1 ? "/" : (e.pop(), "/" + e.join("/"));
695
- }
696
- /**
697
- * 合并路由路径
698
- */
699
- static joinPaths(...t) {
700
- return t.map((e) => e.replace(/^\/+|\/+$/g, "")).filter((e) => e.length > 0).join("/").replace(/^/, "/");
701
- }
702
- /**
703
- * 检查是否为外部链接
704
- */
705
- static isExternalUrl(t) {
706
- return /^https?:\/\//.test(t) || /^mailto:/.test(t) || /^tel:/.test(t);
707
- }
708
- /**
709
- * 获取查询参数
710
- */
711
- static getQueryParam(t) {
712
- return new URL(window.location.href).searchParams.get(t);
713
- }
714
- /**
715
- * 设置查询参数
716
- */
717
- static setQueryParam(t, e, n = !1) {
718
- const g = new URL(window.location.href);
719
- g.searchParams.set(t, e);
720
- const C = g.pathname + g.search + g.hash;
721
- this.navigate(C, n);
722
- }
723
- /**
724
- * 删除查询参数
725
- */
726
- static removeQueryParam(t, e = !1) {
727
- const n = new URL(window.location.href);
728
- n.searchParams.delete(t);
729
- const g = n.pathname + n.search + n.hash;
730
- this.navigate(g, e);
731
- }
732
- /**
733
- * 返回上一页
734
- */
735
- static goBack() {
736
- window.history.back();
737
- }
738
- /**
739
- * 前进一页
740
- */
741
- static goForward() {
742
- window.history.forward();
743
- }
744
- /**
745
- * 替换当前页面
746
- */
747
- static replace(t) {
748
- this.navigate(t, !0);
749
- }
750
- /**
751
- * 获取历史记录长度
752
- */
753
- static getHistoryLength() {
754
- return window.history.length;
755
- }
756
- /**
757
- * 监听路由变化
758
- */
759
- static onRouteChange(t) {
760
- const e = () => {
761
- const n = this.getCurrentRoute();
762
- t(n);
763
- };
764
- return window.addEventListener("popstate", e), document.addEventListener("route-changed", e), () => {
765
- window.removeEventListener("popstate", e), document.removeEventListener("route-changed", e);
766
- };
767
- }
768
- }
1395
+ }, B(pe, Te, void 0), pe)();
769
1396
  export {
770
- Kt as RouterUtils,
771
- bt as WsxLink,
772
- At as WsxRouter,
773
- dt as WsxView
1397
+ le as RouterUtils,
1398
+ Pe as WsxLink,
1399
+ Rt as WsxRouter,
1400
+ ze as WsxView
774
1401
  };