@wsxjs/wsx-router 0.0.24 → 0.0.26
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.cjs +1 -1
- package/dist/index.js +587 -721
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,277 +1,143 @@
|
|
|
1
|
-
import { autoRegister as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
r.exports ? r.exports = t() : e.log = t();
|
|
10
|
-
})(We, function() {
|
|
11
|
-
var e = function() {
|
|
12
|
-
}, t = "undefined", n = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), g = [
|
|
13
|
-
"trace",
|
|
14
|
-
"debug",
|
|
15
|
-
"info",
|
|
16
|
-
"warn",
|
|
17
|
-
"error"
|
|
18
|
-
], p = {}, f = null;
|
|
19
|
-
function _(o, c) {
|
|
20
|
-
var i = o[c];
|
|
21
|
-
if (typeof i.bind == "function")
|
|
22
|
-
return i.bind(o);
|
|
23
|
-
try {
|
|
24
|
-
return Function.prototype.bind.call(i, o);
|
|
25
|
-
} catch {
|
|
26
|
-
return function() {
|
|
27
|
-
return Function.prototype.apply.apply(i, [o, arguments]);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function y() {
|
|
32
|
-
console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
|
|
33
|
-
}
|
|
34
|
-
function T(o) {
|
|
35
|
-
return o === "debug" && (o = "log"), typeof console === t ? !1 : o === "trace" && n ? y : console[o] !== void 0 ? _(console, o) : console.log !== void 0 ? _(console, "log") : e;
|
|
36
|
-
}
|
|
37
|
-
function O() {
|
|
38
|
-
for (var o = this.getLevel(), c = 0; c < g.length; c++) {
|
|
39
|
-
var i = g[c];
|
|
40
|
-
this[i] = c < o ? e : this.methodFactory(i, o, this.name);
|
|
41
|
-
}
|
|
42
|
-
if (this.log = this.debug, typeof console === t && o < this.levels.SILENT)
|
|
43
|
-
return "No console available for logging";
|
|
44
|
-
}
|
|
45
|
-
function V(o) {
|
|
46
|
-
return function() {
|
|
47
|
-
typeof console !== t && (O.call(this), this[o].apply(this, arguments));
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function M(o, c, i) {
|
|
51
|
-
return T(o) || V.apply(this, arguments);
|
|
52
|
-
}
|
|
53
|
-
function H(o, c) {
|
|
54
|
-
var i = this, u, A, k, L = "loglevel";
|
|
55
|
-
typeof o == "string" ? L += ":" + o : typeof o == "symbol" && (L = void 0);
|
|
56
|
-
function P(h) {
|
|
57
|
-
var l = (g[h] || "silent").toUpperCase();
|
|
58
|
-
if (!(typeof window === t || !L)) {
|
|
59
|
-
try {
|
|
60
|
-
window.localStorage[L] = l;
|
|
61
|
-
return;
|
|
62
|
-
} catch {
|
|
63
|
-
}
|
|
64
|
-
try {
|
|
65
|
-
window.document.cookie = encodeURIComponent(L) + "=" + l + ";";
|
|
66
|
-
} catch {
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function C() {
|
|
71
|
-
var h;
|
|
72
|
-
if (!(typeof window === t || !L)) {
|
|
73
|
-
try {
|
|
74
|
-
h = window.localStorage[L];
|
|
75
|
-
} catch {
|
|
76
|
-
}
|
|
77
|
-
if (typeof h === t)
|
|
78
|
-
try {
|
|
79
|
-
var l = window.document.cookie, x = encodeURIComponent(L), $ = l.indexOf(x + "=");
|
|
80
|
-
$ !== -1 && (h = /^([^;]+)/.exec(
|
|
81
|
-
l.slice($ + x.length + 1)
|
|
82
|
-
)[1]);
|
|
83
|
-
} catch {
|
|
84
|
-
}
|
|
85
|
-
return i.levels[h] === void 0 && (h = void 0), h;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function R() {
|
|
89
|
-
if (!(typeof window === t || !L)) {
|
|
90
|
-
try {
|
|
91
|
-
window.localStorage.removeItem(L);
|
|
92
|
-
} catch {
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
window.document.cookie = encodeURIComponent(L) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
|
96
|
-
} catch {
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function v(h) {
|
|
101
|
-
var l = h;
|
|
102
|
-
if (typeof l == "string" && i.levels[l.toUpperCase()] !== void 0 && (l = i.levels[l.toUpperCase()]), typeof l == "number" && l >= 0 && l <= i.levels.SILENT)
|
|
103
|
-
return l;
|
|
104
|
-
throw new TypeError("log.setLevel() called with invalid level: " + h);
|
|
105
|
-
}
|
|
106
|
-
i.name = o, i.levels = {
|
|
107
|
-
TRACE: 0,
|
|
108
|
-
DEBUG: 1,
|
|
109
|
-
INFO: 2,
|
|
110
|
-
WARN: 3,
|
|
111
|
-
ERROR: 4,
|
|
112
|
-
SILENT: 5
|
|
113
|
-
}, i.methodFactory = c || M, i.getLevel = function() {
|
|
114
|
-
return k ?? A ?? u;
|
|
115
|
-
}, i.setLevel = function(h, l) {
|
|
116
|
-
return k = v(h), l !== !1 && P(k), O.call(i);
|
|
117
|
-
}, i.setDefaultLevel = function(h) {
|
|
118
|
-
A = v(h), C() || i.setLevel(h, !1);
|
|
119
|
-
}, i.resetLevel = function() {
|
|
120
|
-
k = null, R(), O.call(i);
|
|
121
|
-
}, i.enableAll = function(h) {
|
|
122
|
-
i.setLevel(i.levels.TRACE, h);
|
|
123
|
-
}, i.disableAll = function(h) {
|
|
124
|
-
i.setLevel(i.levels.SILENT, h);
|
|
125
|
-
}, i.rebuild = function() {
|
|
126
|
-
if (f !== i && (u = v(f.getLevel())), O.call(i), f === i)
|
|
127
|
-
for (var h in p)
|
|
128
|
-
p[h].rebuild();
|
|
129
|
-
}, u = v(
|
|
130
|
-
f ? f.getLevel() : "WARN"
|
|
131
|
-
);
|
|
132
|
-
var m = C();
|
|
133
|
-
m != null && (k = v(m)), O.call(i);
|
|
134
|
-
}
|
|
135
|
-
f = new H(), f.getLogger = function(c) {
|
|
136
|
-
if (typeof c != "symbol" && typeof c != "string" || c === "")
|
|
137
|
-
throw new TypeError("You must supply a name when creating a logger.");
|
|
138
|
-
var i = p[c];
|
|
139
|
-
return i || (i = p[c] = new H(
|
|
140
|
-
c,
|
|
141
|
-
f.methodFactory
|
|
142
|
-
)), i;
|
|
143
|
-
};
|
|
144
|
-
var s = typeof window !== t ? window.log : void 0;
|
|
145
|
-
return f.noConflict = function() {
|
|
146
|
-
return typeof window !== t && window.log === f && (window.log = s), f;
|
|
147
|
-
}, f.getLoggers = function() {
|
|
148
|
-
return p;
|
|
149
|
-
}, f.default = f, f;
|
|
150
|
-
});
|
|
151
|
-
})(we);
|
|
152
|
-
var Te = we.exports;
|
|
153
|
-
const Oe = /* @__PURE__ */ Ae(Te), ye = {
|
|
154
|
-
trace: "trace",
|
|
155
|
-
debug: "debug",
|
|
156
|
-
info: "info",
|
|
157
|
-
warn: "warn",
|
|
158
|
-
error: "error",
|
|
159
|
-
silent: "silent"
|
|
160
|
-
}, je = {
|
|
161
|
-
0: "trace",
|
|
162
|
-
1: "debug",
|
|
163
|
-
2: "info",
|
|
164
|
-
3: "warn",
|
|
165
|
-
4: "error",
|
|
166
|
-
5: "silent"
|
|
1
|
+
import { autoRegister as ct, LightComponent as nt, jsx as tt, WebComponent as lt } from "@wsxjs/wsx-core";
|
|
2
|
+
const it = {
|
|
3
|
+
trace: 0,
|
|
4
|
+
debug: 1,
|
|
5
|
+
info: 2,
|
|
6
|
+
warn: 3,
|
|
7
|
+
error: 4,
|
|
8
|
+
silent: 5
|
|
167
9
|
};
|
|
168
|
-
function
|
|
169
|
-
var r,
|
|
10
|
+
function at() {
|
|
11
|
+
var r, t;
|
|
170
12
|
if (typeof process < "u")
|
|
171
13
|
return process.env.NODE_ENV === "production" || process.env.MODE === "production";
|
|
172
14
|
try {
|
|
173
|
-
const
|
|
174
|
-
if ((
|
|
175
|
-
const n =
|
|
15
|
+
const e = globalThis;
|
|
16
|
+
if ((t = (r = e.import) == null ? void 0 : r.meta) != null && t.env) {
|
|
17
|
+
const n = e.import.meta.env;
|
|
176
18
|
return n.MODE === "production" || n.PROD === !0;
|
|
177
19
|
}
|
|
178
20
|
} catch {
|
|
179
21
|
}
|
|
180
22
|
return !1;
|
|
181
23
|
}
|
|
182
|
-
const
|
|
24
|
+
const ut = {
|
|
183
25
|
name: "WSX",
|
|
184
|
-
level:
|
|
185
|
-
pretty: !
|
|
26
|
+
level: at() ? "info" : "debug",
|
|
27
|
+
pretty: !at()
|
|
186
28
|
};
|
|
187
|
-
function
|
|
188
|
-
|
|
189
|
-
return g.setLevel(ye[p]), g;
|
|
29
|
+
function G(r, t) {
|
|
30
|
+
return r ? `[${r}] ${t}` : t;
|
|
190
31
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
32
|
+
class Wt {
|
|
33
|
+
constructor(t, e) {
|
|
34
|
+
this.name = t, this.level = e, this.levelValue = it[e], this.isProd = at();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Check if a log level should be logged
|
|
38
|
+
*/
|
|
39
|
+
shouldLog(t) {
|
|
40
|
+
return this.level === "silent" ? !1 : it[t] >= this.levelValue;
|
|
41
|
+
}
|
|
42
|
+
trace(t, ...e) {
|
|
43
|
+
if (!this.isProd || this.shouldLog("trace")) {
|
|
44
|
+
const n = G(this.name, t);
|
|
45
|
+
e.length > 0 ? console.debug(n, ...e) : console.debug(n);
|
|
46
|
+
}
|
|
197
47
|
}
|
|
198
|
-
debug(
|
|
48
|
+
debug(t, ...e) {
|
|
199
49
|
if (!this.isProd || this.shouldLog("debug")) {
|
|
200
|
-
const n =
|
|
201
|
-
|
|
50
|
+
const n = G(this.name, t);
|
|
51
|
+
e.length > 0 ? console.debug(n, ...e) : console.debug(n);
|
|
202
52
|
}
|
|
203
53
|
}
|
|
204
|
-
info(
|
|
54
|
+
info(t, ...e) {
|
|
205
55
|
if (this.shouldLog("info")) {
|
|
206
|
-
const n =
|
|
207
|
-
|
|
56
|
+
const n = G(this.name, t);
|
|
57
|
+
e.length > 0 ? console.info(n, ...e) : console.info(n);
|
|
208
58
|
}
|
|
209
59
|
}
|
|
210
|
-
warn(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const n = X(this.name, e);
|
|
216
|
-
t.length > 0 ? this.logInstance.error(n, ...t) : this.logInstance.error(n);
|
|
217
|
-
}
|
|
218
|
-
fatal(e, ...t) {
|
|
219
|
-
const n = X(this.name, e);
|
|
220
|
-
t.length > 0 ? this.logInstance.error(`[FATAL] ${n}`, ...t) : this.logInstance.error(`[FATAL] ${n}`);
|
|
60
|
+
warn(t, ...e) {
|
|
61
|
+
if (this.shouldLog("warn")) {
|
|
62
|
+
const n = G(this.name, t);
|
|
63
|
+
e.length > 0 ? console.warn(n, ...e) : console.warn(n);
|
|
64
|
+
}
|
|
221
65
|
}
|
|
222
|
-
|
|
223
|
-
if (
|
|
224
|
-
const n =
|
|
225
|
-
|
|
66
|
+
error(t, ...e) {
|
|
67
|
+
if (this.shouldLog("error")) {
|
|
68
|
+
const n = G(this.name, t);
|
|
69
|
+
e.length > 0 ? console.error(n, ...e) : console.error(n);
|
|
226
70
|
}
|
|
227
71
|
}
|
|
228
72
|
/**
|
|
229
|
-
*
|
|
73
|
+
* Set the log level dynamically
|
|
230
74
|
*/
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
return t.indexOf(e) >= n;
|
|
75
|
+
setLevel(t) {
|
|
76
|
+
this.level = t, this.levelValue = it[t];
|
|
234
77
|
}
|
|
235
78
|
/**
|
|
236
|
-
* Get the
|
|
79
|
+
* Get the current log level
|
|
237
80
|
*/
|
|
238
|
-
|
|
239
|
-
return this.
|
|
81
|
+
getLevel() {
|
|
82
|
+
return this.level;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
class wt {
|
|
86
|
+
constructor(t = {}) {
|
|
87
|
+
this.name = t.name || ut.name, this.currentLevel = t.level || ut.level, this.nativeLogger = new Wt(this.name, this.currentLevel);
|
|
88
|
+
}
|
|
89
|
+
debug(t, ...e) {
|
|
90
|
+
this.nativeLogger.debug(t, ...e);
|
|
91
|
+
}
|
|
92
|
+
info(t, ...e) {
|
|
93
|
+
this.nativeLogger.info(t, ...e);
|
|
94
|
+
}
|
|
95
|
+
warn(t, ...e) {
|
|
96
|
+
this.nativeLogger.warn(t, ...e);
|
|
97
|
+
}
|
|
98
|
+
error(t, ...e) {
|
|
99
|
+
this.nativeLogger.error(t, ...e);
|
|
100
|
+
}
|
|
101
|
+
fatal(t, ...e) {
|
|
102
|
+
const n = G(this.name, `[FATAL] ${t}`);
|
|
103
|
+
e.length > 0 ? console.error(n, ...e) : console.error(n);
|
|
104
|
+
}
|
|
105
|
+
trace(t, ...e) {
|
|
106
|
+
this.nativeLogger.trace(t, ...e);
|
|
240
107
|
}
|
|
241
108
|
/**
|
|
242
109
|
* Set the log level dynamically
|
|
243
110
|
*/
|
|
244
|
-
setLevel(
|
|
245
|
-
this.currentLevel =
|
|
111
|
+
setLevel(t) {
|
|
112
|
+
this.currentLevel = t, this.nativeLogger.setLevel(t);
|
|
246
113
|
}
|
|
247
114
|
/**
|
|
248
115
|
* Get the current log level
|
|
249
116
|
*/
|
|
250
117
|
getLevel() {
|
|
251
|
-
|
|
252
|
-
return je[e] || this.currentLevel;
|
|
118
|
+
return this.nativeLogger.getLevel();
|
|
253
119
|
}
|
|
254
120
|
}
|
|
255
|
-
new
|
|
256
|
-
function
|
|
257
|
-
return new
|
|
258
|
-
...
|
|
259
|
-
name:
|
|
121
|
+
new wt();
|
|
122
|
+
function rt(r, t = {}) {
|
|
123
|
+
return new wt({
|
|
124
|
+
...t,
|
|
125
|
+
name: t.name || `WSX:${r}`
|
|
260
126
|
});
|
|
261
127
|
}
|
|
262
|
-
const
|
|
128
|
+
const jt = rt("RouterUtils"), J = class J {
|
|
263
129
|
/**
|
|
264
130
|
* 设置当前路由信息(由 WsxRouter 内部调用)
|
|
265
131
|
* @internal
|
|
266
132
|
*/
|
|
267
|
-
static _setCurrentRoute(
|
|
268
|
-
|
|
133
|
+
static _setCurrentRoute(t) {
|
|
134
|
+
J._currentRoute = t;
|
|
269
135
|
}
|
|
270
136
|
/**
|
|
271
137
|
* 编程式导航
|
|
272
138
|
*/
|
|
273
|
-
static navigate(
|
|
274
|
-
|
|
139
|
+
static navigate(t, e = !1) {
|
|
140
|
+
e ? window.history.replaceState(null, "", t) : window.history.pushState(null, "", t), window.dispatchEvent(new PopStateEvent("popstate")), jt.debug(`Navigated to: ${t} (replace: ${e})`);
|
|
275
141
|
}
|
|
276
142
|
/**
|
|
277
143
|
* 获取当前路由信息
|
|
@@ -279,52 +145,52 @@ const Me = ie("RouterUtils"), Y = class Y {
|
|
|
279
145
|
* 否则返回基础路由信息(参数为空对象)
|
|
280
146
|
*/
|
|
281
147
|
static getCurrentRoute() {
|
|
282
|
-
if (
|
|
283
|
-
return
|
|
284
|
-
const
|
|
148
|
+
if (J._currentRoute)
|
|
149
|
+
return J._currentRoute;
|
|
150
|
+
const t = new URL(window.location.href);
|
|
285
151
|
return {
|
|
286
|
-
path:
|
|
152
|
+
path: t.pathname,
|
|
287
153
|
params: {},
|
|
288
|
-
query: Object.fromEntries(
|
|
289
|
-
hash:
|
|
154
|
+
query: Object.fromEntries(t.searchParams.entries()),
|
|
155
|
+
hash: t.hash.slice(1)
|
|
290
156
|
// 移除 # 号
|
|
291
157
|
};
|
|
292
158
|
}
|
|
293
159
|
/**
|
|
294
160
|
* 解析路由路径,提取参数
|
|
295
161
|
*/
|
|
296
|
-
static parseRoute(
|
|
162
|
+
static parseRoute(t, e) {
|
|
297
163
|
var n;
|
|
298
|
-
if (
|
|
164
|
+
if (t === e)
|
|
299
165
|
return {
|
|
300
|
-
route:
|
|
166
|
+
route: t,
|
|
301
167
|
params: {},
|
|
302
168
|
exact: !0
|
|
303
169
|
};
|
|
304
|
-
if (
|
|
170
|
+
if (t === "*")
|
|
305
171
|
return {
|
|
306
|
-
route:
|
|
172
|
+
route: t,
|
|
307
173
|
params: {},
|
|
308
174
|
exact: !1
|
|
309
175
|
};
|
|
310
|
-
if (
|
|
311
|
-
const
|
|
312
|
-
if (
|
|
313
|
-
const
|
|
314
|
-
return
|
|
315
|
-
|
|
176
|
+
if (t.includes(":")) {
|
|
177
|
+
const f = ((n = t.match(/:([^/]+)/g)) == null ? void 0 : n.map((b) => b.slice(1))) || [], v = t.replace(/:[^/]+/g, "([^/]+)"), y = new RegExp(`^${v}$`), k = e.match(y);
|
|
178
|
+
if (k && f.length > 0) {
|
|
179
|
+
const b = {};
|
|
180
|
+
return f.forEach((j, z) => {
|
|
181
|
+
b[j] = k[z + 1];
|
|
316
182
|
}), {
|
|
317
|
-
route:
|
|
318
|
-
params:
|
|
183
|
+
route: t,
|
|
184
|
+
params: b,
|
|
319
185
|
exact: !0
|
|
320
186
|
};
|
|
321
187
|
}
|
|
322
188
|
}
|
|
323
|
-
if (
|
|
324
|
-
const
|
|
325
|
-
if (
|
|
189
|
+
if (t.endsWith("/*")) {
|
|
190
|
+
const f = t.slice(0, -2);
|
|
191
|
+
if (e.startsWith(f))
|
|
326
192
|
return {
|
|
327
|
-
route:
|
|
193
|
+
route: t,
|
|
328
194
|
params: {},
|
|
329
195
|
exact: !1
|
|
330
196
|
};
|
|
@@ -334,67 +200,67 @@ const Me = ie("RouterUtils"), Y = class Y {
|
|
|
334
200
|
/**
|
|
335
201
|
* 构建路由路径,替换参数
|
|
336
202
|
*/
|
|
337
|
-
static buildPath(
|
|
338
|
-
let n =
|
|
339
|
-
return Object.entries(
|
|
340
|
-
n = n.replace(`:${
|
|
203
|
+
static buildPath(t, e = {}) {
|
|
204
|
+
let n = t;
|
|
205
|
+
return Object.entries(e).forEach(([f, v]) => {
|
|
206
|
+
n = n.replace(`:${f}`, encodeURIComponent(v));
|
|
341
207
|
}), n;
|
|
342
208
|
}
|
|
343
209
|
/**
|
|
344
210
|
* 检查路由是否匹配当前路径
|
|
345
211
|
*/
|
|
346
|
-
static isRouteActive(
|
|
212
|
+
static isRouteActive(t, e = !1) {
|
|
347
213
|
const n = window.location.pathname;
|
|
348
|
-
return
|
|
214
|
+
return e ? n === t : t === "/" ? n === "/" : n.startsWith(t);
|
|
349
215
|
}
|
|
350
216
|
/**
|
|
351
217
|
* 获取路由层级
|
|
352
218
|
*/
|
|
353
|
-
static getRouteDepth(
|
|
354
|
-
return
|
|
219
|
+
static getRouteDepth(t) {
|
|
220
|
+
return t.split("/").filter((e) => e.length > 0).length;
|
|
355
221
|
}
|
|
356
222
|
/**
|
|
357
223
|
* 获取父级路由
|
|
358
224
|
*/
|
|
359
|
-
static getParentRoute(
|
|
360
|
-
const
|
|
361
|
-
return
|
|
225
|
+
static getParentRoute(t) {
|
|
226
|
+
const e = t.split("/").filter((n) => n.length > 0);
|
|
227
|
+
return e.length <= 1 ? "/" : (e.pop(), "/" + e.join("/"));
|
|
362
228
|
}
|
|
363
229
|
/**
|
|
364
230
|
* 合并路由路径
|
|
365
231
|
*/
|
|
366
|
-
static joinPaths(...
|
|
367
|
-
return
|
|
232
|
+
static joinPaths(...t) {
|
|
233
|
+
return t.map((e) => e.replace(/^\/+|\/+$/g, "")).filter((e) => e.length > 0).join("/").replace(/^/, "/");
|
|
368
234
|
}
|
|
369
235
|
/**
|
|
370
236
|
* 检查是否为外部链接
|
|
371
237
|
*/
|
|
372
|
-
static isExternalUrl(
|
|
373
|
-
return /^https?:\/\//.test(
|
|
238
|
+
static isExternalUrl(t) {
|
|
239
|
+
return /^https?:\/\//.test(t) || /^mailto:/.test(t) || /^tel:/.test(t);
|
|
374
240
|
}
|
|
375
241
|
/**
|
|
376
242
|
* 获取查询参数
|
|
377
243
|
*/
|
|
378
|
-
static getQueryParam(
|
|
379
|
-
return new URL(window.location.href).searchParams.get(
|
|
244
|
+
static getQueryParam(t) {
|
|
245
|
+
return new URL(window.location.href).searchParams.get(t);
|
|
380
246
|
}
|
|
381
247
|
/**
|
|
382
248
|
* 设置查询参数
|
|
383
249
|
*/
|
|
384
|
-
static setQueryParam(
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
const
|
|
388
|
-
this.navigate(
|
|
250
|
+
static setQueryParam(t, e, n = !1) {
|
|
251
|
+
const f = new URL(window.location.href);
|
|
252
|
+
f.searchParams.set(t, e);
|
|
253
|
+
const v = f.pathname + f.search + f.hash;
|
|
254
|
+
this.navigate(v, n);
|
|
389
255
|
}
|
|
390
256
|
/**
|
|
391
257
|
* 删除查询参数
|
|
392
258
|
*/
|
|
393
|
-
static removeQueryParam(
|
|
259
|
+
static removeQueryParam(t, e = !1) {
|
|
394
260
|
const n = new URL(window.location.href);
|
|
395
|
-
n.searchParams.delete(
|
|
396
|
-
const
|
|
397
|
-
this.navigate(
|
|
261
|
+
n.searchParams.delete(t);
|
|
262
|
+
const f = n.pathname + n.search + n.hash;
|
|
263
|
+
this.navigate(f, e);
|
|
398
264
|
}
|
|
399
265
|
/**
|
|
400
266
|
* 返回上一页
|
|
@@ -411,8 +277,8 @@ const Me = ie("RouterUtils"), Y = class Y {
|
|
|
411
277
|
/**
|
|
412
278
|
* 替换当前页面
|
|
413
279
|
*/
|
|
414
|
-
static replace(
|
|
415
|
-
this.navigate(
|
|
280
|
+
static replace(t) {
|
|
281
|
+
this.navigate(t, !0);
|
|
416
282
|
}
|
|
417
283
|
/**
|
|
418
284
|
* 获取历史记录长度
|
|
@@ -431,488 +297,488 @@ const Me = ie("RouterUtils"), Y = class Y {
|
|
|
431
297
|
*
|
|
432
298
|
* @see RFC-0035: 路由导航竞态条件修复
|
|
433
299
|
*/
|
|
434
|
-
static onRouteChange(
|
|
435
|
-
const
|
|
300
|
+
static onRouteChange(t) {
|
|
301
|
+
const e = () => {
|
|
436
302
|
const n = this.getCurrentRoute();
|
|
437
|
-
|
|
303
|
+
t(n);
|
|
438
304
|
};
|
|
439
|
-
return document.addEventListener("route-changed",
|
|
440
|
-
document.removeEventListener("route-changed",
|
|
305
|
+
return document.addEventListener("route-changed", e), () => {
|
|
306
|
+
document.removeEventListener("route-changed", e);
|
|
441
307
|
};
|
|
442
308
|
}
|
|
443
309
|
};
|
|
444
|
-
|
|
445
|
-
let
|
|
446
|
-
const
|
|
447
|
-
var
|
|
448
|
-
let
|
|
449
|
-
function
|
|
450
|
-
return (
|
|
310
|
+
J._currentRoute = null;
|
|
311
|
+
let et = J;
|
|
312
|
+
const ht = ":host{display:grid;width:100%}.router-outlet{width:100%}:host>wsx-view{grid-area:1 / 1}";
|
|
313
|
+
var yt;
|
|
314
|
+
let Rt, xt;
|
|
315
|
+
function U(r, t, e) {
|
|
316
|
+
return (t = $t(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
|
|
451
317
|
}
|
|
452
|
-
function
|
|
453
|
-
function
|
|
454
|
-
return function(
|
|
455
|
-
return
|
|
318
|
+
function At(r, t, e, n, f, v) {
|
|
319
|
+
function y(i, c, u) {
|
|
320
|
+
return function(s, a) {
|
|
321
|
+
return u && u(s), i[c].call(s, a);
|
|
456
322
|
};
|
|
457
323
|
}
|
|
458
|
-
function
|
|
459
|
-
for (var
|
|
460
|
-
return
|
|
324
|
+
function k(i, c) {
|
|
325
|
+
for (var u = 0; u < i.length; u++) i[u].call(c);
|
|
326
|
+
return c;
|
|
461
327
|
}
|
|
462
|
-
function
|
|
463
|
-
if (typeof
|
|
464
|
-
return
|
|
328
|
+
function b(i, c, u, s) {
|
|
329
|
+
if (typeof i != "function" && (s || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (s ? "" : " or undefined"));
|
|
330
|
+
return i;
|
|
465
331
|
}
|
|
466
|
-
function
|
|
467
|
-
function
|
|
468
|
-
if (!m(
|
|
332
|
+
function j(i, c, u, s, a, A, O, S, D, x, w, g, m) {
|
|
333
|
+
function $(l) {
|
|
334
|
+
if (!m(l)) throw new TypeError("Attempted to access private element on non-instance");
|
|
469
335
|
}
|
|
470
|
-
var
|
|
336
|
+
var h, C = c[0], E = c[3], W = !S;
|
|
471
337
|
if (!W) {
|
|
472
|
-
|
|
473
|
-
var
|
|
474
|
-
|
|
475
|
-
return
|
|
476
|
-
},
|
|
477
|
-
|
|
478
|
-
} } :
|
|
338
|
+
u || Array.isArray(C) || (C = [C]);
|
|
339
|
+
var o = {}, L = [], p = a === 3 ? "get" : a === 4 || g ? "set" : "value";
|
|
340
|
+
x ? (w || g ? o = { get: dt(function() {
|
|
341
|
+
return E(this);
|
|
342
|
+
}, s, "get"), set: function(l) {
|
|
343
|
+
c[4](this, l);
|
|
344
|
+
} } : o[p] = E, w || dt(o[p], s, a === 2 ? "" : p)) : w || (o = Object.getOwnPropertyDescriptor(i, s));
|
|
479
345
|
}
|
|
480
|
-
for (var
|
|
481
|
-
var B =
|
|
482
|
-
if (
|
|
483
|
-
|
|
346
|
+
for (var d = i, P = C.length - 1; P >= 0; P -= u ? 2 : 1) {
|
|
347
|
+
var B = C[P], F = u ? C[P - 1] : void 0, K = {}, T = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: s, metadata: A, addInitializer: (function(l, _) {
|
|
348
|
+
if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
349
|
+
b(_, "An initializer", "be", !0), O.push(_);
|
|
484
350
|
}).bind(null, K) };
|
|
485
351
|
try {
|
|
486
|
-
if (W) (
|
|
352
|
+
if (W) (h = b(B.call(F, d, T), "class decorators", "return")) && (d = h);
|
|
487
353
|
else {
|
|
488
|
-
var
|
|
489
|
-
|
|
490
|
-
return
|
|
491
|
-
} : (
|
|
492
|
-
return
|
|
493
|
-
}, (
|
|
494
|
-
|
|
354
|
+
var I, M;
|
|
355
|
+
T.static = D, T.private = x, x ? a === 2 ? I = function(l) {
|
|
356
|
+
return $(l), o.value;
|
|
357
|
+
} : (a < 4 && (I = y(o, "get", $)), a !== 3 && (M = y(o, "set", $))) : (I = function(l) {
|
|
358
|
+
return l[s];
|
|
359
|
+
}, (a < 2 || a === 4) && (M = function(l, _) {
|
|
360
|
+
l[s] = _;
|
|
495
361
|
}));
|
|
496
|
-
var
|
|
497
|
-
return
|
|
362
|
+
var Q = T.access = { has: x ? m.bind() : function(l) {
|
|
363
|
+
return s in l;
|
|
498
364
|
} };
|
|
499
|
-
if (
|
|
500
|
-
if (typeof
|
|
501
|
-
else if (
|
|
502
|
-
} else
|
|
365
|
+
if (I && (Q.get = I), M && (Q.set = M), d = B.call(F, g ? { get: o.get, set: o.set } : o[p], T), g) {
|
|
366
|
+
if (typeof d == "object" && d) (h = b(d.get, "accessor.get")) && (o.get = h), (h = b(d.set, "accessor.set")) && (o.set = h), (h = b(d.init, "accessor.init")) && L.push(h);
|
|
367
|
+
else if (d !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
368
|
+
} else b(d, (w ? "field" : "method") + " decorators", "return") && (w ? L.push(d) : o[p] = d);
|
|
503
369
|
}
|
|
504
370
|
} finally {
|
|
505
371
|
K.v = !0;
|
|
506
372
|
}
|
|
507
373
|
}
|
|
508
|
-
return (
|
|
509
|
-
for (var N =
|
|
510
|
-
return
|
|
511
|
-
}),
|
|
512
|
-
}
|
|
513
|
-
function
|
|
514
|
-
return Object.defineProperty(
|
|
515
|
-
}
|
|
516
|
-
if (arguments.length >= 6) var
|
|
517
|
-
var
|
|
518
|
-
var
|
|
519
|
-
return
|
|
520
|
-
},
|
|
521
|
-
function
|
|
522
|
-
|
|
374
|
+
return (w || g) && S.push(function(l, _) {
|
|
375
|
+
for (var N = L.length - 1; N >= 0; N--) _ = L[N].call(l, _);
|
|
376
|
+
return _;
|
|
377
|
+
}), w || W || (x ? g ? S.push(y(o, "get"), y(o, "set")) : S.push(a === 2 ? o[p] : y.call.bind(o[p])) : Object.defineProperty(i, s, o)), d;
|
|
378
|
+
}
|
|
379
|
+
function z(i, c) {
|
|
380
|
+
return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
|
|
381
|
+
}
|
|
382
|
+
if (arguments.length >= 6) var q = v[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
383
|
+
var V = Object.create(q ?? null), Y = function(i, c, u, s) {
|
|
384
|
+
var a, A, O = [], S = function(p) {
|
|
385
|
+
return Tt(p) === i;
|
|
386
|
+
}, D = /* @__PURE__ */ new Map();
|
|
387
|
+
function x(p) {
|
|
388
|
+
p && O.push(k.bind(null, p));
|
|
523
389
|
}
|
|
524
|
-
for (var
|
|
525
|
-
var
|
|
526
|
-
if (Array.isArray(
|
|
527
|
-
var m =
|
|
528
|
-
if (!W && !
|
|
529
|
-
var
|
|
530
|
-
if (
|
|
531
|
-
|
|
390
|
+
for (var w = 0; w < c.length; w++) {
|
|
391
|
+
var g = c[w];
|
|
392
|
+
if (Array.isArray(g)) {
|
|
393
|
+
var m = g[1], $ = g[2], h = g.length > 3, C = 16 & m, E = !!(8 & m), W = (m &= 7) == 0, o = $ + "/" + E;
|
|
394
|
+
if (!W && !h) {
|
|
395
|
+
var L = D.get(o);
|
|
396
|
+
if (L === !0 || L === 3 && m !== 4 || L === 4 && m !== 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: " + $);
|
|
397
|
+
D.set(o, !(m > 2) || m);
|
|
532
398
|
}
|
|
533
|
-
|
|
399
|
+
j(E ? i : i.prototype, g, C, h ? "#" + $ : $t($), m, s, E ? A = A || [] : a = a || [], O, E, h, W, m === 1, E && h ? S : u);
|
|
534
400
|
}
|
|
535
401
|
}
|
|
536
|
-
return
|
|
537
|
-
}(r,
|
|
538
|
-
return
|
|
539
|
-
var
|
|
540
|
-
return
|
|
402
|
+
return x(a), x(A), O;
|
|
403
|
+
}(r, t, f, V);
|
|
404
|
+
return e.length || z(r, V), { e: Y, get c() {
|
|
405
|
+
var i = [];
|
|
406
|
+
return e.length && [z(j(r, [e], n, r.name, 5, V, i), V), k.bind(null, i, r)];
|
|
541
407
|
} };
|
|
542
408
|
}
|
|
543
|
-
function
|
|
544
|
-
var
|
|
545
|
-
return typeof
|
|
409
|
+
function $t(r) {
|
|
410
|
+
var t = Ot(r, "string");
|
|
411
|
+
return typeof t == "symbol" ? t : t + "";
|
|
546
412
|
}
|
|
547
|
-
function
|
|
413
|
+
function Ot(r, t) {
|
|
548
414
|
if (typeof r != "object" || !r) return r;
|
|
549
|
-
var
|
|
550
|
-
if (
|
|
551
|
-
var n =
|
|
415
|
+
var e = r[Symbol.toPrimitive];
|
|
416
|
+
if (e !== void 0) {
|
|
417
|
+
var n = e.call(r, t);
|
|
552
418
|
if (typeof n != "object") return n;
|
|
553
419
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
554
420
|
}
|
|
555
421
|
return String(r);
|
|
556
422
|
}
|
|
557
|
-
function
|
|
558
|
-
typeof
|
|
423
|
+
function dt(r, t, e) {
|
|
424
|
+
typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
|
|
559
425
|
try {
|
|
560
|
-
Object.defineProperty(r, "name", { configurable: !0, value:
|
|
426
|
+
Object.defineProperty(r, "name", { configurable: !0, value: e ? e + " " + t : t });
|
|
561
427
|
} catch {
|
|
562
428
|
}
|
|
563
429
|
return r;
|
|
564
430
|
}
|
|
565
|
-
function
|
|
431
|
+
function Tt(r) {
|
|
566
432
|
if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
|
|
567
433
|
return r;
|
|
568
434
|
}
|
|
569
|
-
const
|
|
570
|
-
|
|
435
|
+
const R = rt("WsxRouter");
|
|
436
|
+
xt = [ct({
|
|
571
437
|
tagName: "wsx-router"
|
|
572
438
|
})];
|
|
573
|
-
let
|
|
574
|
-
class
|
|
439
|
+
let It;
|
|
440
|
+
class Vt extends nt {
|
|
575
441
|
constructor() {
|
|
576
442
|
super({
|
|
577
|
-
styles:
|
|
443
|
+
styles: ht,
|
|
578
444
|
styleName: "wsx-router"
|
|
579
|
-
}),
|
|
445
|
+
}), U(this, "_autoStyles", ht), 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", () => {
|
|
580
446
|
if (this.isHandlingRoute) {
|
|
581
|
-
|
|
447
|
+
R.debug("Route change already in progress, skipping");
|
|
582
448
|
return;
|
|
583
449
|
}
|
|
584
|
-
this.views.size === 0 && (this.collectViews(),
|
|
450
|
+
this.views.size === 0 && (this.collectViews(), R.debug(`WsxRouter re-collected views: ${this.views.size}`)), this.isHandlingRoute = !0;
|
|
585
451
|
try {
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
const
|
|
452
|
+
const t = window.location.pathname;
|
|
453
|
+
R.debug(`WsxRouter: Route changed to: ${t}`);
|
|
454
|
+
const e = new CustomEvent("before-navigate", {
|
|
589
455
|
detail: {
|
|
590
|
-
to:
|
|
456
|
+
to: t,
|
|
591
457
|
from: this.currentPath
|
|
592
458
|
},
|
|
593
459
|
bubbles: !0,
|
|
594
460
|
cancelable: !0
|
|
595
461
|
});
|
|
596
|
-
if (!this.dispatchEvent(
|
|
597
|
-
|
|
462
|
+
if (!this.dispatchEvent(e)) {
|
|
463
|
+
R.debug(`Navigation to ${t} was cancelled`);
|
|
598
464
|
return;
|
|
599
465
|
}
|
|
600
|
-
this.performNavigation(
|
|
466
|
+
this.performNavigation(t);
|
|
601
467
|
} finally {
|
|
602
468
|
requestAnimationFrame(() => {
|
|
603
469
|
this.isHandlingRoute = !1;
|
|
604
470
|
});
|
|
605
471
|
}
|
|
606
|
-
}),
|
|
607
|
-
const
|
|
608
|
-
if (!
|
|
609
|
-
const n =
|
|
610
|
-
!n || n.startsWith("http") || n.startsWith("#") || (
|
|
472
|
+
}), U(this, "interceptLinks", (t) => {
|
|
473
|
+
const e = t.target.closest("a");
|
|
474
|
+
if (!e) return;
|
|
475
|
+
const n = e.getAttribute("href");
|
|
476
|
+
!n || n.startsWith("http") || n.startsWith("#") || (t.preventDefault(), this.navigate(n));
|
|
611
477
|
});
|
|
612
478
|
}
|
|
613
479
|
render() {
|
|
614
|
-
return /* @__PURE__ */
|
|
480
|
+
return /* @__PURE__ */ tt("div", { class: "router-outlet" });
|
|
615
481
|
}
|
|
616
482
|
onRendered() {
|
|
617
|
-
var
|
|
618
|
-
(
|
|
483
|
+
var t;
|
|
484
|
+
(t = super.onRendered) == null || t.call(this), this.views.size === 0 && (this.collectViews(), R.debug("WsxRouter collected views in onRendered:", this.views.size)), this.views.size > 0 && !this.currentView && requestAnimationFrame(() => {
|
|
619
485
|
this.handleRouteChange();
|
|
620
486
|
});
|
|
621
487
|
}
|
|
622
488
|
onConnected() {
|
|
623
|
-
var
|
|
624
|
-
(
|
|
625
|
-
this.views.size === 0 && (this.collectViews(),
|
|
626
|
-
|
|
489
|
+
var t;
|
|
490
|
+
(t = super.onConnected) == null || t.call(this), R.debug("WsxRouter connected to DOM"), "scrollRestoration" in history && (history.scrollRestoration = this.scrollRestoration), window.addEventListener("popstate", this.handleRouteChange), this.addEventListener("click", this.interceptLinks), requestAnimationFrame(() => {
|
|
491
|
+
this.views.size === 0 && (this.collectViews(), R.debug(`WsxRouter collected views in onConnected: ${this.views.size}`)), requestAnimationFrame(() => {
|
|
492
|
+
R.debug(`WsxRouter handling initial route: ${window.location.pathname}`), this.handleRouteChange();
|
|
627
493
|
});
|
|
628
494
|
});
|
|
629
495
|
}
|
|
630
496
|
onDisconnected() {
|
|
631
|
-
var
|
|
632
|
-
(
|
|
497
|
+
var t;
|
|
498
|
+
(t = super.onDisconnected) == null || t.call(this), window.removeEventListener("popstate", this.handleRouteChange);
|
|
633
499
|
}
|
|
634
500
|
collectViews() {
|
|
635
|
-
const
|
|
636
|
-
|
|
637
|
-
const n =
|
|
638
|
-
if (this.views.set(n,
|
|
639
|
-
const
|
|
640
|
-
this.compiledRoutes.set(n,
|
|
501
|
+
const t = Array.from(this.children).filter((e) => e.tagName.toLowerCase() === "wsx-view");
|
|
502
|
+
R.debug(`WsxRouter found ${t.length} views`), this.views.clear(), this.compiledRoutes.clear(), this.matchCache.clear(), t.forEach((e) => {
|
|
503
|
+
const n = e.getAttribute("route") || "/";
|
|
504
|
+
if (this.views.set(n, e), R.debug(`WsxRouter registered route: ${n}`), n.includes(":")) {
|
|
505
|
+
const f = n.replace(/:[^/]+/g, "([^/]+)"), v = new RegExp(`^${f}$`);
|
|
506
|
+
this.compiledRoutes.set(n, v), R.debug(`WsxRouter compiled regex for route: ${n} -> ${v}`);
|
|
641
507
|
}
|
|
642
|
-
|
|
508
|
+
e.style.display = "none";
|
|
643
509
|
});
|
|
644
510
|
}
|
|
645
511
|
/**
|
|
646
512
|
* RFC 0033: 执行导航(带 View Transitions 支持)
|
|
647
513
|
*/
|
|
648
|
-
performNavigation(
|
|
649
|
-
const
|
|
650
|
-
const n = this.matchRoute(
|
|
514
|
+
performNavigation(t) {
|
|
515
|
+
const e = () => {
|
|
516
|
+
const n = this.matchRoute(t);
|
|
651
517
|
if (n) {
|
|
652
518
|
n.style.display = "block", n.style.visibility = "visible";
|
|
653
|
-
const
|
|
654
|
-
|
|
655
|
-
for (const [
|
|
656
|
-
|
|
519
|
+
const f = n.getAttribute("route") || "/";
|
|
520
|
+
R.debug(`Showing view for route: ${f}`);
|
|
521
|
+
for (const [z, q] of this.views)
|
|
522
|
+
q !== n && (q.style.display = "none", q.style.visibility = "");
|
|
657
523
|
this.currentView = n;
|
|
658
|
-
const
|
|
659
|
-
|
|
660
|
-
n.setAttribute("params", JSON.stringify(
|
|
524
|
+
const v = this.extractParams(f, t);
|
|
525
|
+
R.debug(`Extracted params for route ${f} and path ${t}:`, v), v && requestAnimationFrame(() => {
|
|
526
|
+
n.setAttribute("params", JSON.stringify(v)), R.debug(`Set params attribute on view: ${JSON.stringify(v)}`);
|
|
661
527
|
});
|
|
662
|
-
const
|
|
663
|
-
path:
|
|
664
|
-
params:
|
|
665
|
-
query: Object.fromEntries(
|
|
666
|
-
hash:
|
|
528
|
+
const y = window.location.href || `${window.location.pathname}${window.location.search}${window.location.hash}`, k = new URL(y, window.location.origin || "http://localhost"), b = {
|
|
529
|
+
path: t,
|
|
530
|
+
params: v || {},
|
|
531
|
+
query: Object.fromEntries(k.searchParams.entries()),
|
|
532
|
+
hash: k.hash.slice(1)
|
|
667
533
|
};
|
|
668
|
-
|
|
669
|
-
const
|
|
670
|
-
detail:
|
|
534
|
+
et._setCurrentRoute(b), R.debug("Updated RouterUtils._currentRoute:", b);
|
|
535
|
+
const j = new CustomEvent("route-changed", {
|
|
536
|
+
detail: b,
|
|
671
537
|
bubbles: !0
|
|
672
538
|
});
|
|
673
|
-
document.dispatchEvent(
|
|
539
|
+
document.dispatchEvent(j);
|
|
674
540
|
} else {
|
|
675
|
-
for (const [
|
|
676
|
-
|
|
677
|
-
this.currentView = null,
|
|
678
|
-
const
|
|
679
|
-
path:
|
|
541
|
+
for (const [b, j] of this.views)
|
|
542
|
+
j.style.display = "none";
|
|
543
|
+
this.currentView = null, R.warn(`No view found for path: ${t}`);
|
|
544
|
+
const f = window.location.href || `${window.location.pathname}${window.location.search}${window.location.hash}`, v = new URL(f, window.location.origin || "http://localhost"), y = {
|
|
545
|
+
path: t,
|
|
680
546
|
params: {},
|
|
681
|
-
query: Object.fromEntries(
|
|
682
|
-
hash:
|
|
547
|
+
query: Object.fromEntries(v.searchParams.entries()),
|
|
548
|
+
hash: v.hash.slice(1)
|
|
683
549
|
};
|
|
684
|
-
|
|
685
|
-
const
|
|
686
|
-
detail:
|
|
550
|
+
et._setCurrentRoute(y);
|
|
551
|
+
const k = new CustomEvent("route-changed", {
|
|
552
|
+
detail: y,
|
|
687
553
|
bubbles: !0
|
|
688
554
|
});
|
|
689
|
-
document.dispatchEvent(
|
|
555
|
+
document.dispatchEvent(k);
|
|
690
556
|
}
|
|
691
|
-
this.handleScrollRestoration(
|
|
557
|
+
this.handleScrollRestoration(t), this.dispatchEvent(new CustomEvent("after-navigate", {
|
|
692
558
|
detail: {
|
|
693
|
-
to:
|
|
559
|
+
to: t,
|
|
694
560
|
from: this.currentPath
|
|
695
561
|
},
|
|
696
562
|
bubbles: !0
|
|
697
|
-
})), this.currentPath =
|
|
563
|
+
})), this.currentPath = t;
|
|
698
564
|
};
|
|
699
|
-
this.enableViewTransitions && "startViewTransition" in document ? document.startViewTransition(
|
|
565
|
+
this.enableViewTransitions && "startViewTransition" in document ? document.startViewTransition(e) : e();
|
|
700
566
|
}
|
|
701
567
|
/**
|
|
702
568
|
* RFC 0033: 滚动恢复处理
|
|
703
569
|
*/
|
|
704
|
-
handleScrollRestoration(
|
|
705
|
-
this.scrollRestoration === "manual" && (this.isBackNavigation() || (window.scrollTo(0, 0),
|
|
570
|
+
handleScrollRestoration(t) {
|
|
571
|
+
this.scrollRestoration === "manual" && (this.isBackNavigation() || (window.scrollTo(0, 0), R.debug("Scrolled to top for forward navigation")));
|
|
706
572
|
}
|
|
707
573
|
/**
|
|
708
574
|
* RFC 0033: 检测是否是后退导航
|
|
709
575
|
*/
|
|
710
576
|
isBackNavigation() {
|
|
711
|
-
var
|
|
712
|
-
return "navigation" in performance && performance.navigation ? performance.navigation.type === 2 : ((
|
|
577
|
+
var t;
|
|
578
|
+
return "navigation" in performance && performance.navigation ? performance.navigation.type === 2 : ((t = window.history.state) == null ? void 0 : t.navigationType) === "back";
|
|
713
579
|
}
|
|
714
|
-
matchRoute(
|
|
715
|
-
if (
|
|
716
|
-
const n = this.matchCache.get(
|
|
717
|
-
return
|
|
580
|
+
matchRoute(t) {
|
|
581
|
+
if (R.warn(`matchRoute called for path: ${t}, views count: ${this.views.size}`), this.matchCache.has(t)) {
|
|
582
|
+
const n = this.matchCache.get(t);
|
|
583
|
+
return R.warn(`matchRoute: found in cache, route: ${n}`), this.views.get(n) || null;
|
|
718
584
|
}
|
|
719
|
-
if (this.views.has(
|
|
720
|
-
return this.matchCache.set(
|
|
721
|
-
for (const [n,
|
|
585
|
+
if (this.views.has(t))
|
|
586
|
+
return this.matchCache.set(t, t), R.warn(`matchRoute: exact match found for ${t}`), this.views.get(t);
|
|
587
|
+
for (const [n, f] of this.views)
|
|
722
588
|
if (n.endsWith("/*")) {
|
|
723
|
-
const
|
|
724
|
-
if (
|
|
725
|
-
return this.matchCache.set(
|
|
589
|
+
const v = n.slice(0, -2);
|
|
590
|
+
if (t.startsWith(v))
|
|
591
|
+
return this.matchCache.set(t, n), R.warn(`matchRoute: prefix match found, route: ${n}, path: ${t}`), f;
|
|
726
592
|
}
|
|
727
|
-
|
|
728
|
-
for (const [n,
|
|
593
|
+
R.warn(`matchRoute: checking parameter routes, compiledRoutes count: ${this.compiledRoutes.size}`);
|
|
594
|
+
for (const [n, f] of this.views)
|
|
729
595
|
if (n.includes(":")) {
|
|
730
|
-
const
|
|
731
|
-
if (
|
|
732
|
-
const
|
|
733
|
-
if (
|
|
734
|
-
return this.matchCache.set(
|
|
596
|
+
const v = this.compiledRoutes.get(n);
|
|
597
|
+
if (v) {
|
|
598
|
+
const y = v.test(t);
|
|
599
|
+
if (R.warn(`matchRoute: testing route ${n} against ${t}, matches: ${y}`), y)
|
|
600
|
+
return this.matchCache.set(t, n), R.warn(`matchRoute: parameter match found, route: ${n}, path: ${t}`), f;
|
|
735
601
|
} else
|
|
736
|
-
|
|
602
|
+
R.warn(`matchRoute: route ${n} has ':' but no compiled regex found`);
|
|
737
603
|
}
|
|
738
|
-
const
|
|
739
|
-
return
|
|
740
|
-
}
|
|
741
|
-
extractParams(
|
|
742
|
-
var
|
|
743
|
-
if (!
|
|
744
|
-
const n = ((
|
|
745
|
-
if (!
|
|
746
|
-
const
|
|
747
|
-
return n.forEach((
|
|
748
|
-
|
|
749
|
-
}),
|
|
604
|
+
const e = this.views.get("*") || null;
|
|
605
|
+
return e ? (this.matchCache.set(t, "*"), R.warn(`matchRoute: wildcard match found for ${t}`)) : R.warn(`matchRoute: no match found for ${t}, no wildcard view available`), e;
|
|
606
|
+
}
|
|
607
|
+
extractParams(t, e) {
|
|
608
|
+
var b;
|
|
609
|
+
if (!t.includes(":")) return null;
|
|
610
|
+
const n = ((b = t.match(/:([^/]+)/g)) == null ? void 0 : b.map((j) => j.slice(1))) || [], f = t.replace(/:[^/]+/g, "([^/]+)"), v = new RegExp(`^${f}$`), y = e.match(v);
|
|
611
|
+
if (!y || !n.length) return null;
|
|
612
|
+
const k = {};
|
|
613
|
+
return n.forEach((j, z) => {
|
|
614
|
+
k[j] = y[z + 1];
|
|
615
|
+
}), k;
|
|
750
616
|
}
|
|
751
617
|
/**
|
|
752
618
|
* RFC 0032: 清除匹配缓存
|
|
753
619
|
* 当路由配置变更时调用,确保使用最新的路由规则
|
|
754
620
|
*/
|
|
755
621
|
clearMatchCache() {
|
|
756
|
-
this.matchCache.clear(),
|
|
622
|
+
this.matchCache.clear(), R.debug("WsxRouter cleared match cache");
|
|
757
623
|
}
|
|
758
624
|
/**
|
|
759
625
|
* RFC 0033: 配置 View Transitions
|
|
760
626
|
*/
|
|
761
|
-
setViewTransitions(
|
|
762
|
-
this.enableViewTransitions =
|
|
627
|
+
setViewTransitions(t) {
|
|
628
|
+
this.enableViewTransitions = t, R.debug(`View Transitions ${t ? "enabled" : "disabled"}`);
|
|
763
629
|
}
|
|
764
630
|
/**
|
|
765
631
|
* RFC 0033: 配置 Scroll Restoration
|
|
766
632
|
*/
|
|
767
|
-
setScrollRestoration(
|
|
768
|
-
this.scrollRestoration =
|
|
633
|
+
setScrollRestoration(t) {
|
|
634
|
+
this.scrollRestoration = t, "scrollRestoration" in history && (history.scrollRestoration = t), R.debug(`Scroll Restoration set to ${t}`);
|
|
769
635
|
}
|
|
770
636
|
/**
|
|
771
637
|
* 编程式导航 - 使用原生 History API
|
|
772
638
|
*/
|
|
773
|
-
navigate(
|
|
774
|
-
window.history.pushState(null, "",
|
|
639
|
+
navigate(t) {
|
|
640
|
+
window.history.pushState(null, "", t), this.handleRouteChange();
|
|
775
641
|
}
|
|
776
642
|
}
|
|
777
|
-
|
|
778
|
-
[
|
|
779
|
-
|
|
780
|
-
const
|
|
781
|
-
var
|
|
782
|
-
let
|
|
783
|
-
function Z(r,
|
|
784
|
-
return (
|
|
643
|
+
yt = Vt;
|
|
644
|
+
[It, Rt] = At(yt, [], xt, 0, void 0, nt).c;
|
|
645
|
+
Rt();
|
|
646
|
+
const Dt = ":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}}";
|
|
647
|
+
var Ct;
|
|
648
|
+
let Et, Lt;
|
|
649
|
+
function Z(r, t, e) {
|
|
650
|
+
return (t = _t(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
|
|
785
651
|
}
|
|
786
|
-
function
|
|
787
|
-
function
|
|
788
|
-
return function(
|
|
789
|
-
return
|
|
652
|
+
function Pt(r, t, e, n, f, v) {
|
|
653
|
+
function y(i, c, u) {
|
|
654
|
+
return function(s, a) {
|
|
655
|
+
return u && u(s), i[c].call(s, a);
|
|
790
656
|
};
|
|
791
657
|
}
|
|
792
|
-
function
|
|
793
|
-
for (var
|
|
794
|
-
return
|
|
658
|
+
function k(i, c) {
|
|
659
|
+
for (var u = 0; u < i.length; u++) i[u].call(c);
|
|
660
|
+
return c;
|
|
795
661
|
}
|
|
796
|
-
function
|
|
797
|
-
if (typeof
|
|
798
|
-
return
|
|
662
|
+
function b(i, c, u, s) {
|
|
663
|
+
if (typeof i != "function" && (s || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (s ? "" : " or undefined"));
|
|
664
|
+
return i;
|
|
799
665
|
}
|
|
800
|
-
function
|
|
801
|
-
function
|
|
802
|
-
if (!m(
|
|
666
|
+
function j(i, c, u, s, a, A, O, S, D, x, w, g, m) {
|
|
667
|
+
function $(l) {
|
|
668
|
+
if (!m(l)) throw new TypeError("Attempted to access private element on non-instance");
|
|
803
669
|
}
|
|
804
|
-
var
|
|
670
|
+
var h, C = c[0], E = c[3], W = !S;
|
|
805
671
|
if (!W) {
|
|
806
|
-
|
|
807
|
-
var
|
|
808
|
-
|
|
809
|
-
return
|
|
810
|
-
},
|
|
811
|
-
|
|
812
|
-
} } :
|
|
672
|
+
u || Array.isArray(C) || (C = [C]);
|
|
673
|
+
var o = {}, L = [], p = a === 3 ? "get" : a === 4 || g ? "set" : "value";
|
|
674
|
+
x ? (w || g ? o = { get: ft(function() {
|
|
675
|
+
return E(this);
|
|
676
|
+
}, s, "get"), set: function(l) {
|
|
677
|
+
c[4](this, l);
|
|
678
|
+
} } : o[p] = E, w || ft(o[p], s, a === 2 ? "" : p)) : w || (o = Object.getOwnPropertyDescriptor(i, s));
|
|
813
679
|
}
|
|
814
|
-
for (var
|
|
815
|
-
var B =
|
|
816
|
-
if (
|
|
817
|
-
|
|
680
|
+
for (var d = i, P = C.length - 1; P >= 0; P -= u ? 2 : 1) {
|
|
681
|
+
var B = C[P], F = u ? C[P - 1] : void 0, K = {}, T = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: s, metadata: A, addInitializer: (function(l, _) {
|
|
682
|
+
if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
683
|
+
b(_, "An initializer", "be", !0), O.push(_);
|
|
818
684
|
}).bind(null, K) };
|
|
819
685
|
try {
|
|
820
|
-
if (W) (
|
|
686
|
+
if (W) (h = b(B.call(F, d, T), "class decorators", "return")) && (d = h);
|
|
821
687
|
else {
|
|
822
|
-
var
|
|
823
|
-
|
|
824
|
-
return
|
|
825
|
-
} : (
|
|
826
|
-
return
|
|
827
|
-
}, (
|
|
828
|
-
|
|
688
|
+
var I, M;
|
|
689
|
+
T.static = D, T.private = x, x ? a === 2 ? I = function(l) {
|
|
690
|
+
return $(l), o.value;
|
|
691
|
+
} : (a < 4 && (I = y(o, "get", $)), a !== 3 && (M = y(o, "set", $))) : (I = function(l) {
|
|
692
|
+
return l[s];
|
|
693
|
+
}, (a < 2 || a === 4) && (M = function(l, _) {
|
|
694
|
+
l[s] = _;
|
|
829
695
|
}));
|
|
830
|
-
var
|
|
831
|
-
return
|
|
696
|
+
var Q = T.access = { has: x ? m.bind() : function(l) {
|
|
697
|
+
return s in l;
|
|
832
698
|
} };
|
|
833
|
-
if (
|
|
834
|
-
if (typeof
|
|
835
|
-
else if (
|
|
836
|
-
} else
|
|
699
|
+
if (I && (Q.get = I), M && (Q.set = M), d = B.call(F, g ? { get: o.get, set: o.set } : o[p], T), g) {
|
|
700
|
+
if (typeof d == "object" && d) (h = b(d.get, "accessor.get")) && (o.get = h), (h = b(d.set, "accessor.set")) && (o.set = h), (h = b(d.init, "accessor.init")) && L.push(h);
|
|
701
|
+
else if (d !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
702
|
+
} else b(d, (w ? "field" : "method") + " decorators", "return") && (w ? L.push(d) : o[p] = d);
|
|
837
703
|
}
|
|
838
704
|
} finally {
|
|
839
705
|
K.v = !0;
|
|
840
706
|
}
|
|
841
707
|
}
|
|
842
|
-
return (
|
|
843
|
-
for (var N =
|
|
844
|
-
return
|
|
845
|
-
}),
|
|
846
|
-
}
|
|
847
|
-
function
|
|
848
|
-
return Object.defineProperty(
|
|
849
|
-
}
|
|
850
|
-
if (arguments.length >= 6) var
|
|
851
|
-
var
|
|
852
|
-
var
|
|
853
|
-
return
|
|
854
|
-
},
|
|
855
|
-
function
|
|
856
|
-
|
|
708
|
+
return (w || g) && S.push(function(l, _) {
|
|
709
|
+
for (var N = L.length - 1; N >= 0; N--) _ = L[N].call(l, _);
|
|
710
|
+
return _;
|
|
711
|
+
}), w || W || (x ? g ? S.push(y(o, "get"), y(o, "set")) : S.push(a === 2 ? o[p] : y.call.bind(o[p])) : Object.defineProperty(i, s, o)), d;
|
|
712
|
+
}
|
|
713
|
+
function z(i, c) {
|
|
714
|
+
return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
|
|
715
|
+
}
|
|
716
|
+
if (arguments.length >= 6) var q = v[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
717
|
+
var V = Object.create(q ?? null), Y = function(i, c, u, s) {
|
|
718
|
+
var a, A, O = [], S = function(p) {
|
|
719
|
+
return zt(p) === i;
|
|
720
|
+
}, D = /* @__PURE__ */ new Map();
|
|
721
|
+
function x(p) {
|
|
722
|
+
p && O.push(k.bind(null, p));
|
|
857
723
|
}
|
|
858
|
-
for (var
|
|
859
|
-
var
|
|
860
|
-
if (Array.isArray(
|
|
861
|
-
var m =
|
|
862
|
-
if (!W && !
|
|
863
|
-
var
|
|
864
|
-
if (
|
|
865
|
-
|
|
724
|
+
for (var w = 0; w < c.length; w++) {
|
|
725
|
+
var g = c[w];
|
|
726
|
+
if (Array.isArray(g)) {
|
|
727
|
+
var m = g[1], $ = g[2], h = g.length > 3, C = 16 & m, E = !!(8 & m), W = (m &= 7) == 0, o = $ + "/" + E;
|
|
728
|
+
if (!W && !h) {
|
|
729
|
+
var L = D.get(o);
|
|
730
|
+
if (L === !0 || L === 3 && m !== 4 || L === 4 && m !== 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: " + $);
|
|
731
|
+
D.set(o, !(m > 2) || m);
|
|
866
732
|
}
|
|
867
|
-
|
|
733
|
+
j(E ? i : i.prototype, g, C, h ? "#" + $ : _t($), m, s, E ? A = A || [] : a = a || [], O, E, h, W, m === 1, E && h ? S : u);
|
|
868
734
|
}
|
|
869
735
|
}
|
|
870
|
-
return
|
|
871
|
-
}(r,
|
|
872
|
-
return
|
|
873
|
-
var
|
|
874
|
-
return
|
|
736
|
+
return x(a), x(A), O;
|
|
737
|
+
}(r, t, f, V);
|
|
738
|
+
return e.length || z(r, V), { e: Y, get c() {
|
|
739
|
+
var i = [];
|
|
740
|
+
return e.length && [z(j(r, [e], n, r.name, 5, V, i), V), k.bind(null, i, r)];
|
|
875
741
|
} };
|
|
876
742
|
}
|
|
877
|
-
function
|
|
878
|
-
var
|
|
879
|
-
return typeof
|
|
743
|
+
function _t(r) {
|
|
744
|
+
var t = Mt(r, "string");
|
|
745
|
+
return typeof t == "symbol" ? t : t + "";
|
|
880
746
|
}
|
|
881
|
-
function
|
|
747
|
+
function Mt(r, t) {
|
|
882
748
|
if (typeof r != "object" || !r) return r;
|
|
883
|
-
var
|
|
884
|
-
if (
|
|
885
|
-
var n =
|
|
749
|
+
var e = r[Symbol.toPrimitive];
|
|
750
|
+
if (e !== void 0) {
|
|
751
|
+
var n = e.call(r, t);
|
|
886
752
|
if (typeof n != "object") return n;
|
|
887
753
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
888
754
|
}
|
|
889
755
|
return String(r);
|
|
890
756
|
}
|
|
891
|
-
function
|
|
892
|
-
typeof
|
|
757
|
+
function ft(r, t, e) {
|
|
758
|
+
typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
|
|
893
759
|
try {
|
|
894
|
-
Object.defineProperty(r, "name", { configurable: !0, value:
|
|
760
|
+
Object.defineProperty(r, "name", { configurable: !0, value: e ? e + " " + t : t });
|
|
895
761
|
} catch {
|
|
896
762
|
}
|
|
897
763
|
return r;
|
|
898
764
|
}
|
|
899
|
-
function
|
|
765
|
+
function zt(r) {
|
|
900
766
|
if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
|
|
901
767
|
return r;
|
|
902
768
|
}
|
|
903
|
-
const
|
|
904
|
-
|
|
769
|
+
const H = rt("WsxView");
|
|
770
|
+
Lt = [ct({
|
|
905
771
|
tagName: "wsx-view"
|
|
906
772
|
})];
|
|
907
|
-
let
|
|
908
|
-
class
|
|
773
|
+
let qt;
|
|
774
|
+
class Nt extends nt {
|
|
909
775
|
constructor() {
|
|
910
|
-
super(), Z(this, "_autoStyles",
|
|
911
|
-
let
|
|
776
|
+
super(), Z(this, "_autoStyles", Dt), Z(this, "_component", ""), Z(this, "params", void 0), Z(this, "componentInstance", null), Z(this, "isLoading", !1);
|
|
777
|
+
let t = this.reactive({});
|
|
912
778
|
Object.defineProperty(this, "params", {
|
|
913
|
-
get: () =>
|
|
914
|
-
set: (
|
|
915
|
-
|
|
779
|
+
get: () => t,
|
|
780
|
+
set: (e) => {
|
|
781
|
+
t = e !== null && typeof e < "u" && (Array.isArray(e) || typeof e == "object") ? this.reactive(e) : e, this.scheduleRerender();
|
|
916
782
|
},
|
|
917
783
|
enumerable: !0,
|
|
918
784
|
configurable: !0
|
|
@@ -921,218 +787,218 @@ class Ke extends re {
|
|
|
921
787
|
get component() {
|
|
922
788
|
return this._component;
|
|
923
789
|
}
|
|
924
|
-
set component(
|
|
925
|
-
this._component =
|
|
790
|
+
set component(t) {
|
|
791
|
+
this._component = t || "", this._component && requestAnimationFrame(() => {
|
|
926
792
|
this.connected && !this.componentInstance && !this.isLoading && this.loadComponent(this._component || "");
|
|
927
793
|
});
|
|
928
794
|
}
|
|
929
795
|
// 防止重复加载的标志
|
|
930
796
|
render() {
|
|
931
|
-
return /* @__PURE__ */
|
|
797
|
+
return /* @__PURE__ */ tt("div", { class: "route-view" });
|
|
932
798
|
}
|
|
933
799
|
onConnected() {
|
|
934
|
-
var
|
|
935
|
-
(
|
|
800
|
+
var t;
|
|
801
|
+
(t = super.onConnected) == null || t.call(this), requestAnimationFrame(() => {
|
|
936
802
|
!this.connected || this.isLoading || this.componentInstance || this.component && this.loadComponent(this.component);
|
|
937
803
|
});
|
|
938
804
|
}
|
|
939
|
-
async loadComponent(
|
|
805
|
+
async loadComponent(t) {
|
|
940
806
|
if (!(!this.connected || this.isLoading || this.componentInstance)) {
|
|
941
807
|
this.isLoading = !0;
|
|
942
808
|
try {
|
|
943
|
-
const
|
|
944
|
-
if (
|
|
945
|
-
|
|
809
|
+
const e = this.componentInstance;
|
|
810
|
+
if (e && (e.remove(), this.componentInstance = null), !customElements.get(t)) {
|
|
811
|
+
H.warn(`Component ${t} not found in customElements registry`), this.isLoading = !1;
|
|
946
812
|
return;
|
|
947
813
|
}
|
|
948
|
-
|
|
949
|
-
this.componentInstance.setAttribute(
|
|
814
|
+
H.warn(`WsxView: Creating instance of ${t}`), this.componentInstance = document.createElement(t), Object.keys(this.params).length > 0 && (H.warn(`WsxView: Setting initial params on ${t}:`, this.params), Object.entries(this.params).forEach(([v, y]) => {
|
|
815
|
+
this.componentInstance.setAttribute(v, y);
|
|
950
816
|
}));
|
|
951
|
-
const
|
|
952
|
-
if (
|
|
953
|
-
if (
|
|
954
|
-
|
|
817
|
+
const f = this.querySelector(".route-view");
|
|
818
|
+
if (f) {
|
|
819
|
+
if (H.warn(`WsxView: Appending ${t} to container`), !customElements.get(t)) {
|
|
820
|
+
H.error(`WsxView: Component ${t} is not registered in customElements registry!`), this.isLoading = !1, this.componentInstance = null;
|
|
955
821
|
return;
|
|
956
822
|
}
|
|
957
|
-
|
|
958
|
-
this.componentInstance && this.componentInstance.isConnected ?
|
|
823
|
+
f.appendChild(this.componentInstance), H.warn(`WsxView: Component ${t} appended successfully, waiting for connectedCallback...`), setTimeout(() => {
|
|
824
|
+
this.componentInstance && this.componentInstance.isConnected ? H.warn(`WsxView: Component ${t} is now connected to DOM`) : H.error(`WsxView: Component ${t} was not connected to DOM!`);
|
|
959
825
|
}, 0);
|
|
960
826
|
} else
|
|
961
|
-
|
|
962
|
-
} catch (
|
|
963
|
-
|
|
827
|
+
H.error("WsxView: Route view container not found"), this.componentInstance = null;
|
|
828
|
+
} catch (e) {
|
|
829
|
+
H.warn(`Error loading component ${t}:`, e), this.componentInstance = null;
|
|
964
830
|
} finally {
|
|
965
|
-
this.isLoading = !1,
|
|
831
|
+
this.isLoading = !1, H.warn(`WsxView: loadComponent for ${t} completed, isLoading=${this.isLoading}`);
|
|
966
832
|
}
|
|
967
833
|
}
|
|
968
834
|
}
|
|
969
835
|
onDisconnected() {
|
|
970
|
-
var
|
|
971
|
-
(
|
|
836
|
+
var t;
|
|
837
|
+
(t = super.onDisconnected) == null || t.call(this), this.componentInstance && (this.componentInstance.remove(), this.componentInstance = null);
|
|
972
838
|
}
|
|
973
839
|
}
|
|
974
|
-
|
|
975
|
-
[
|
|
976
|
-
|
|
977
|
-
const
|
|
978
|
-
var
|
|
979
|
-
let
|
|
980
|
-
function
|
|
981
|
-
return (
|
|
840
|
+
Ct = Nt;
|
|
841
|
+
[qt, Et] = Pt(Ct, [], Lt, 0, void 0, nt).c;
|
|
842
|
+
Et();
|
|
843
|
+
const Ut = ':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)}';
|
|
844
|
+
var ot, st;
|
|
845
|
+
let gt, kt, mt;
|
|
846
|
+
function X(r, t, e) {
|
|
847
|
+
return (t = St(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
|
|
982
848
|
}
|
|
983
|
-
function
|
|
984
|
-
function
|
|
985
|
-
return function(
|
|
986
|
-
return
|
|
849
|
+
function Ht(r, t, e, n, f, v) {
|
|
850
|
+
function y(i, c, u) {
|
|
851
|
+
return function(s, a) {
|
|
852
|
+
return u && u(s), i[c].call(s, a);
|
|
987
853
|
};
|
|
988
854
|
}
|
|
989
|
-
function
|
|
990
|
-
for (var
|
|
991
|
-
return
|
|
855
|
+
function k(i, c) {
|
|
856
|
+
for (var u = 0; u < i.length; u++) i[u].call(c);
|
|
857
|
+
return c;
|
|
992
858
|
}
|
|
993
|
-
function
|
|
994
|
-
if (typeof
|
|
995
|
-
return
|
|
859
|
+
function b(i, c, u, s) {
|
|
860
|
+
if (typeof i != "function" && (s || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (s ? "" : " or undefined"));
|
|
861
|
+
return i;
|
|
996
862
|
}
|
|
997
|
-
function
|
|
998
|
-
function
|
|
999
|
-
if (!m(
|
|
863
|
+
function j(i, c, u, s, a, A, O, S, D, x, w, g, m) {
|
|
864
|
+
function $(l) {
|
|
865
|
+
if (!m(l)) throw new TypeError("Attempted to access private element on non-instance");
|
|
1000
866
|
}
|
|
1001
|
-
var
|
|
867
|
+
var h, C = c[0], E = c[3], W = !S;
|
|
1002
868
|
if (!W) {
|
|
1003
|
-
|
|
1004
|
-
var
|
|
1005
|
-
|
|
1006
|
-
return
|
|
1007
|
-
},
|
|
1008
|
-
|
|
1009
|
-
} } :
|
|
869
|
+
u || Array.isArray(C) || (C = [C]);
|
|
870
|
+
var o = {}, L = [], p = a === 3 ? "get" : a === 4 || g ? "set" : "value";
|
|
871
|
+
x ? (w || g ? o = { get: pt(function() {
|
|
872
|
+
return E(this);
|
|
873
|
+
}, s, "get"), set: function(l) {
|
|
874
|
+
c[4](this, l);
|
|
875
|
+
} } : o[p] = E, w || pt(o[p], s, a === 2 ? "" : p)) : w || (o = Object.getOwnPropertyDescriptor(i, s));
|
|
1010
876
|
}
|
|
1011
|
-
for (var
|
|
1012
|
-
var B =
|
|
1013
|
-
if (
|
|
1014
|
-
|
|
877
|
+
for (var d = i, P = C.length - 1; P >= 0; P -= u ? 2 : 1) {
|
|
878
|
+
var B = C[P], F = u ? C[P - 1] : void 0, K = {}, T = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: s, metadata: A, addInitializer: (function(l, _) {
|
|
879
|
+
if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
880
|
+
b(_, "An initializer", "be", !0), O.push(_);
|
|
1015
881
|
}).bind(null, K) };
|
|
1016
882
|
try {
|
|
1017
|
-
if (W) (
|
|
883
|
+
if (W) (h = b(B.call(F, d, T), "class decorators", "return")) && (d = h);
|
|
1018
884
|
else {
|
|
1019
|
-
var
|
|
1020
|
-
|
|
1021
|
-
return
|
|
1022
|
-
} : (
|
|
1023
|
-
return
|
|
1024
|
-
}, (
|
|
1025
|
-
|
|
885
|
+
var I, M;
|
|
886
|
+
T.static = D, T.private = x, x ? a === 2 ? I = function(l) {
|
|
887
|
+
return $(l), o.value;
|
|
888
|
+
} : (a < 4 && (I = y(o, "get", $)), a !== 3 && (M = y(o, "set", $))) : (I = function(l) {
|
|
889
|
+
return l[s];
|
|
890
|
+
}, (a < 2 || a === 4) && (M = function(l, _) {
|
|
891
|
+
l[s] = _;
|
|
1026
892
|
}));
|
|
1027
|
-
var
|
|
1028
|
-
return
|
|
893
|
+
var Q = T.access = { has: x ? m.bind() : function(l) {
|
|
894
|
+
return s in l;
|
|
1029
895
|
} };
|
|
1030
|
-
if (
|
|
1031
|
-
if (typeof
|
|
1032
|
-
else if (
|
|
1033
|
-
} else
|
|
896
|
+
if (I && (Q.get = I), M && (Q.set = M), d = B.call(F, g ? { get: o.get, set: o.set } : o[p], T), g) {
|
|
897
|
+
if (typeof d == "object" && d) (h = b(d.get, "accessor.get")) && (o.get = h), (h = b(d.set, "accessor.set")) && (o.set = h), (h = b(d.init, "accessor.init")) && L.push(h);
|
|
898
|
+
else if (d !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
899
|
+
} else b(d, (w ? "field" : "method") + " decorators", "return") && (w ? L.push(d) : o[p] = d);
|
|
1034
900
|
}
|
|
1035
901
|
} finally {
|
|
1036
902
|
K.v = !0;
|
|
1037
903
|
}
|
|
1038
904
|
}
|
|
1039
|
-
return (
|
|
1040
|
-
for (var N =
|
|
1041
|
-
return
|
|
1042
|
-
}),
|
|
1043
|
-
}
|
|
1044
|
-
function
|
|
1045
|
-
return Object.defineProperty(
|
|
1046
|
-
}
|
|
1047
|
-
if (arguments.length >= 6) var
|
|
1048
|
-
var
|
|
1049
|
-
var
|
|
1050
|
-
return
|
|
1051
|
-
},
|
|
1052
|
-
function
|
|
1053
|
-
|
|
905
|
+
return (w || g) && S.push(function(l, _) {
|
|
906
|
+
for (var N = L.length - 1; N >= 0; N--) _ = L[N].call(l, _);
|
|
907
|
+
return _;
|
|
908
|
+
}), w || W || (x ? g ? S.push(y(o, "get"), y(o, "set")) : S.push(a === 2 ? o[p] : y.call.bind(o[p])) : Object.defineProperty(i, s, o)), d;
|
|
909
|
+
}
|
|
910
|
+
function z(i, c) {
|
|
911
|
+
return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
|
|
912
|
+
}
|
|
913
|
+
if (arguments.length >= 6) var q = v[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
914
|
+
var V = Object.create(q ?? null), Y = function(i, c, u, s) {
|
|
915
|
+
var a, A, O = [], S = function(p) {
|
|
916
|
+
return Ft(p) === i;
|
|
917
|
+
}, D = /* @__PURE__ */ new Map();
|
|
918
|
+
function x(p) {
|
|
919
|
+
p && O.push(k.bind(null, p));
|
|
1054
920
|
}
|
|
1055
|
-
for (var
|
|
1056
|
-
var
|
|
1057
|
-
if (Array.isArray(
|
|
1058
|
-
var m =
|
|
1059
|
-
if (!W && !
|
|
1060
|
-
var
|
|
1061
|
-
if (
|
|
1062
|
-
|
|
921
|
+
for (var w = 0; w < c.length; w++) {
|
|
922
|
+
var g = c[w];
|
|
923
|
+
if (Array.isArray(g)) {
|
|
924
|
+
var m = g[1], $ = g[2], h = g.length > 3, C = 16 & m, E = !!(8 & m), W = (m &= 7) == 0, o = $ + "/" + E;
|
|
925
|
+
if (!W && !h) {
|
|
926
|
+
var L = D.get(o);
|
|
927
|
+
if (L === !0 || L === 3 && m !== 4 || L === 4 && m !== 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: " + $);
|
|
928
|
+
D.set(o, !(m > 2) || m);
|
|
1063
929
|
}
|
|
1064
|
-
|
|
930
|
+
j(E ? i : i.prototype, g, C, h ? "#" + $ : St($), m, s, E ? A = A || [] : a = a || [], O, E, h, W, m === 1, E && h ? S : u);
|
|
1065
931
|
}
|
|
1066
932
|
}
|
|
1067
|
-
return
|
|
1068
|
-
}(r,
|
|
1069
|
-
return
|
|
1070
|
-
var
|
|
1071
|
-
return
|
|
933
|
+
return x(a), x(A), O;
|
|
934
|
+
}(r, t, f, V);
|
|
935
|
+
return e.length || z(r, V), { e: Y, get c() {
|
|
936
|
+
var i = [];
|
|
937
|
+
return e.length && [z(j(r, [e], n, r.name, 5, V, i), V), k.bind(null, i, r)];
|
|
1072
938
|
} };
|
|
1073
939
|
}
|
|
1074
|
-
function
|
|
1075
|
-
var
|
|
1076
|
-
return typeof
|
|
940
|
+
function St(r) {
|
|
941
|
+
var t = Bt(r, "string");
|
|
942
|
+
return typeof t == "symbol" ? t : t + "";
|
|
1077
943
|
}
|
|
1078
|
-
function
|
|
944
|
+
function Bt(r, t) {
|
|
1079
945
|
if (typeof r != "object" || !r) return r;
|
|
1080
|
-
var
|
|
1081
|
-
if (
|
|
1082
|
-
var n =
|
|
946
|
+
var e = r[Symbol.toPrimitive];
|
|
947
|
+
if (e !== void 0) {
|
|
948
|
+
var n = e.call(r, t);
|
|
1083
949
|
if (typeof n != "object") return n;
|
|
1084
950
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1085
951
|
}
|
|
1086
|
-
return (
|
|
952
|
+
return (t === "string" ? String : Number)(r);
|
|
1087
953
|
}
|
|
1088
|
-
function
|
|
1089
|
-
typeof
|
|
954
|
+
function pt(r, t, e) {
|
|
955
|
+
typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
|
|
1090
956
|
try {
|
|
1091
|
-
Object.defineProperty(r, "name", { configurable: !0, value:
|
|
957
|
+
Object.defineProperty(r, "name", { configurable: !0, value: e ? e + " " + t : t });
|
|
1092
958
|
} catch {
|
|
1093
959
|
}
|
|
1094
960
|
return r;
|
|
1095
961
|
}
|
|
1096
|
-
function
|
|
962
|
+
function Ft(r) {
|
|
1097
963
|
if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
|
|
1098
964
|
return r;
|
|
1099
965
|
}
|
|
1100
|
-
function
|
|
966
|
+
function Kt(r) {
|
|
1101
967
|
return r;
|
|
1102
968
|
}
|
|
1103
|
-
const
|
|
1104
|
-
|
|
969
|
+
const vt = rt("WsxLink");
|
|
970
|
+
kt = [ct({
|
|
1105
971
|
tagName: "wsx-link"
|
|
1106
972
|
})];
|
|
1107
|
-
let
|
|
1108
|
-
new (
|
|
973
|
+
let bt;
|
|
974
|
+
new (mt = (st = class extends lt {
|
|
1109
975
|
constructor() {
|
|
1110
|
-
super(),
|
|
1111
|
-
if (
|
|
1112
|
-
|
|
976
|
+
super(), X(this, "_autoStyles", Ut), X(this, "to", void 0), X(this, "activeClass", void 0), X(this, "handleClick", (v) => {
|
|
977
|
+
if (v.preventDefault(), !this.to) {
|
|
978
|
+
vt.warn("No 'to' attribute specified");
|
|
1113
979
|
return;
|
|
1114
980
|
}
|
|
1115
981
|
if (this.isExternalLink(this.to)) {
|
|
1116
982
|
window.open(this.to, "_blank");
|
|
1117
983
|
return;
|
|
1118
984
|
}
|
|
1119
|
-
this.replace ? window.history.replaceState(null, "", this.to) : window.history.pushState(null, "", this.to), window.dispatchEvent(new PopStateEvent("popstate")),
|
|
1120
|
-
}),
|
|
1121
|
-
var
|
|
1122
|
-
const
|
|
1123
|
-
|
|
985
|
+
this.replace ? window.history.replaceState(null, "", this.to) : window.history.pushState(null, "", this.to), window.dispatchEvent(new PopStateEvent("popstate")), vt.debug(`Navigated to: ${this.to}`);
|
|
986
|
+
}), X(this, "updateActiveState", () => {
|
|
987
|
+
var b;
|
|
988
|
+
const v = window.location.pathname, y = this.exact ? v === this.to : v.startsWith(this.to) && this.to !== "/", k = (b = this.shadowRoot) == null ? void 0 : b.querySelector("a");
|
|
989
|
+
k && (y ? (k.classList.add(this.activeClass), this.setAttribute("active", "")) : (k.classList.remove(this.activeClass), this.removeAttribute("active")));
|
|
1124
990
|
});
|
|
1125
|
-
const [
|
|
991
|
+
const [t, e] = this.useState("to", "");
|
|
1126
992
|
Object.defineProperty(this, "to", {
|
|
1127
|
-
get:
|
|
1128
|
-
set:
|
|
993
|
+
get: t,
|
|
994
|
+
set: e,
|
|
1129
995
|
enumerable: !0,
|
|
1130
996
|
configurable: !0
|
|
1131
997
|
});
|
|
1132
|
-
const [n,
|
|
998
|
+
const [n, f] = this.useState("activeClass", "active");
|
|
1133
999
|
Object.defineProperty(this, "activeClass", {
|
|
1134
1000
|
get: n,
|
|
1135
|
-
set:
|
|
1001
|
+
set: f,
|
|
1136
1002
|
enumerable: !0,
|
|
1137
1003
|
configurable: !0
|
|
1138
1004
|
});
|
|
@@ -1144,20 +1010,20 @@ new (ge = (se = class extends le {
|
|
|
1144
1010
|
return this.hasAttribute("exact");
|
|
1145
1011
|
}
|
|
1146
1012
|
render() {
|
|
1147
|
-
return /* @__PURE__ */
|
|
1013
|
+
return /* @__PURE__ */ tt("a", { href: this.to, class: "wsx-link", onClick: this.handleClick, part: "link" }, /* @__PURE__ */ tt("slot", null));
|
|
1148
1014
|
}
|
|
1149
1015
|
onConnected() {
|
|
1150
|
-
var
|
|
1151
|
-
(
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1016
|
+
var e;
|
|
1017
|
+
(e = super.onConnected) == null || e.call(this), this.to = this.to || "", this.activeClass = this.activeClass || "active";
|
|
1018
|
+
const t = this.shadowRoot.querySelector(".wsx-link");
|
|
1019
|
+
t && (t.href = this.to), window.addEventListener("popstate", this.updateActiveState), document.addEventListener("route-changed", this.updateActiveState), this.updateActiveState();
|
|
1154
1020
|
}
|
|
1155
1021
|
onDisconnected() {
|
|
1156
|
-
var
|
|
1157
|
-
(
|
|
1022
|
+
var t;
|
|
1023
|
+
(t = super.onDisconnected) == null || t.call(this), window.removeEventListener("popstate", this.updateActiveState), document.removeEventListener("route-changed", this.updateActiveState);
|
|
1158
1024
|
}
|
|
1159
|
-
onAttributeChanged(
|
|
1160
|
-
switch (
|
|
1025
|
+
onAttributeChanged(t, e, n) {
|
|
1026
|
+
switch (t) {
|
|
1161
1027
|
case "to":
|
|
1162
1028
|
this.to = n || "", this.updateActiveState();
|
|
1163
1029
|
break;
|
|
@@ -1172,8 +1038,8 @@ new (ge = (se = class extends le {
|
|
|
1172
1038
|
break;
|
|
1173
1039
|
}
|
|
1174
1040
|
}
|
|
1175
|
-
isExternalLink(
|
|
1176
|
-
return
|
|
1041
|
+
isExternalLink(t) {
|
|
1042
|
+
return t.startsWith("http://") || t.startsWith("https://") || t.startsWith("mailto:") || t.startsWith("tel:");
|
|
1177
1043
|
}
|
|
1178
1044
|
/**
|
|
1179
1045
|
* 编程式导航
|
|
@@ -1184,14 +1050,14 @@ new (ge = (se = class extends le {
|
|
|
1184
1050
|
cancelable: !0
|
|
1185
1051
|
}));
|
|
1186
1052
|
}
|
|
1187
|
-
}, [
|
|
1053
|
+
}, [bt, gt] = Ht(st, [], kt, 0, void 0, lt).c, st), ot = class extends Kt {
|
|
1188
1054
|
constructor() {
|
|
1189
|
-
super(
|
|
1055
|
+
super(bt), X(this, "observedAttributes", ["to", "replace", "active-class", "exact"]), gt();
|
|
1190
1056
|
}
|
|
1191
|
-
},
|
|
1057
|
+
}, X(ot, mt, void 0), ot)();
|
|
1192
1058
|
export {
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1059
|
+
et as RouterUtils,
|
|
1060
|
+
bt as WsxLink,
|
|
1061
|
+
It as WsxRouter,
|
|
1062
|
+
qt as WsxView
|
|
1197
1063
|
};
|