wj-elements 0.7.7 → 0.8.0
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/animations.js +28 -51
- package/dist/animations.js.map +1 -1
- package/dist/base-path.js +19 -31
- package/dist/base-path.js.map +1 -1
- package/dist/custom-elements.json +11504 -11499
- package/dist/dark.css +1 -302
- package/dist/date.js +16 -36
- package/dist/date.js.map +1 -1
- package/dist/element-utils.js +20 -81
- package/dist/element-utils.js.map +1 -1
- package/dist/event.js +49 -165
- package/dist/event.js.map +1 -1
- package/dist/form-associated-element-BjeJn7j8.js +101 -0
- package/dist/{form-associated-element-DEQ4y-jn.js.map → form-associated-element-BjeJn7j8.js.map} +1 -1
- package/dist/icon-DmsqtDpL.js +102 -0
- package/dist/{icon-CReYMzAK.js.map → icon-DmsqtDpL.js.map} +1 -1
- package/dist/light.css +1 -731
- package/dist/localize.js +36 -111
- package/dist/localize.js.map +1 -1
- package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +3 -2
- package/dist/permissions.js +14 -41
- package/dist/permissions.js.map +1 -1
- package/dist/popup.element-CbkhthPP.js +806 -0
- package/dist/{popup.element-CwXvVFK7.js.map → popup.element-CbkhthPP.js.map} +1 -1
- package/dist/router-links-CNsJ-elb.js +105 -0
- package/dist/{router-links-wjqCnncc.js.map → router-links-CNsJ-elb.js.map} +1 -1
- package/dist/skeleton.css +1 -197
- package/dist/styles.css +1 -866
- package/dist/universal-service.js +48 -109
- package/dist/universal-service.js.map +1 -1
- package/dist/utils.js +11 -18
- package/dist/utils.js.map +1 -1
- package/dist/web-types.json +760 -760
- package/dist/wje-accordion-item.js +33 -106
- package/dist/wje-accordion-item.js.map +1 -1
- package/dist/wje-accordion.js +19 -84
- package/dist/wje-accordion.js.map +1 -1
- package/dist/wje-animation.js +37 -4258
- package/dist/wje-animation.js.map +1 -1
- package/dist/wje-aside.js +9 -34
- package/dist/wje-aside.js.map +1 -1
- package/dist/wje-avatar.js +36 -126
- package/dist/wje-avatar.js.map +1 -1
- package/dist/wje-badge.js +10 -52
- package/dist/wje-badge.js.map +1 -1
- package/dist/wje-breadcrumb.js +205 -672
- package/dist/wje-breadcrumb.js.map +1 -1
- package/dist/wje-breadcrumbs.js +177 -633
- package/dist/wje-breadcrumbs.js.map +1 -1
- package/dist/wje-button-group.js +48 -153
- package/dist/wje-button-group.js.map +1 -1
- package/dist/wje-button.js +92 -413
- package/dist/wje-button.js.map +1 -1
- package/dist/wje-card-content.js +7 -30
- package/dist/wje-card-content.js.map +1 -1
- package/dist/wje-card-controls.js +7 -30
- package/dist/wje-card-controls.js.map +1 -1
- package/dist/wje-card-header.js +7 -30
- package/dist/wje-card-header.js.map +1 -1
- package/dist/wje-card-subtitle.js +7 -34
- package/dist/wje-card-subtitle.js.map +1 -1
- package/dist/wje-card-title.js +7 -34
- package/dist/wje-card-title.js.map +1 -1
- package/dist/wje-card.js +15 -71
- package/dist/wje-card.js.map +1 -1
- package/dist/wje-carousel-item.js +12 -56
- package/dist/wje-carousel-item.js.map +1 -1
- package/dist/wje-carousel.js +154 -509
- package/dist/wje-carousel.js.map +1 -1
- package/dist/wje-checkbox.js +50 -227
- package/dist/wje-checkbox.js.map +1 -1
- package/dist/wje-chip.js +43 -160
- package/dist/wje-chip.js.map +1 -1
- package/dist/wje-col.js +7 -20
- package/dist/wje-col.js.map +1 -1
- package/dist/wje-color-picker.js +445 -1464
- package/dist/wje-color-picker.js.map +1 -1
- package/dist/wje-container.js +9 -35
- package/dist/wje-container.js.map +1 -1
- package/dist/wje-copy-button.js +64 -204
- package/dist/wje-copy-button.js.map +1 -1
- package/dist/wje-dialog.js +85 -553
- package/dist/wje-dialog.js.map +1 -1
- package/dist/wje-divider.js +7 -34
- package/dist/wje-divider.js.map +1 -1
- package/dist/wje-dropdown.js +78 -305
- package/dist/wje-dropdown.js.map +1 -1
- package/dist/wje-element.js +191 -700
- package/dist/wje-element.js.map +1 -1
- package/dist/wje-file-upload-item.js +51 -156
- package/dist/wje-file-upload-item.js.map +1 -1
- package/dist/wje-file-upload.js +181 -619
- package/dist/wje-file-upload.js.map +1 -1
- package/dist/wje-footer.js +7 -31
- package/dist/wje-footer.js.map +1 -1
- package/dist/wje-form.js +7 -32
- package/dist/wje-form.js.map +1 -1
- package/dist/wje-format-digital.js +26 -118
- package/dist/wje-format-digital.js.map +1 -1
- package/dist/wje-grid.js +7 -33
- package/dist/wje-grid.js.map +1 -1
- package/dist/wje-header.js +9 -35
- package/dist/wje-header.js.map +1 -1
- package/dist/wje-icon-library.js +12 -18
- package/dist/wje-icon-library.js.map +1 -1
- package/dist/wje-icon-picker.js +65 -320
- package/dist/wje-icon-picker.js.map +1 -1
- package/dist/wje-icon.js +1 -1
- package/dist/wje-img-comparer.js +37 -114
- package/dist/wje-img-comparer.js.map +1 -1
- package/dist/wje-img.js +50 -198
- package/dist/wje-img.js.map +1 -1
- package/dist/wje-infinite-scroll.js +94 -346
- package/dist/wje-infinite-scroll.js.map +1 -1
- package/dist/wje-input-file.js +23 -84
- package/dist/wje-input-file.js.map +1 -1
- package/dist/wje-input.js +78 -392
- package/dist/wje-input.js.map +1 -1
- package/dist/wje-item.js +11 -64
- package/dist/wje-item.js.map +1 -1
- package/dist/wje-kanban.js +124 -401
- package/dist/wje-kanban.js.map +1 -1
- package/dist/wje-label.js +9 -32
- package/dist/wje-label.js.map +1 -1
- package/dist/wje-level-indicator.js +38 -157
- package/dist/wje-level-indicator.js.map +1 -1
- package/dist/wje-list.js +10 -40
- package/dist/wje-list.js.map +1 -1
- package/dist/wje-main.js +7 -31
- package/dist/wje-main.js.map +1 -1
- package/dist/wje-masonry.js +66 -211
- package/dist/wje-masonry.js.map +1 -1
- package/dist/wje-master.js +45 -161
- package/dist/wje-master.js.map +1 -1
- package/dist/wje-menu-button.js +10 -38
- package/dist/wje-menu-button.js.map +1 -1
- package/dist/wje-menu-item.js +127 -577
- package/dist/wje-menu-item.js.map +1 -1
- package/dist/wje-menu-label.js +9 -35
- package/dist/wje-menu-label.js.map +1 -1
- package/dist/wje-menu.js +14 -49
- package/dist/wje-menu.js.map +1 -1
- package/dist/wje-option.js +48 -279
- package/dist/wje-option.js.map +1 -1
- package/dist/wje-options.js +130 -384
- package/dist/wje-options.js.map +1 -1
- package/dist/wje-orgchart-group.js +16 -52
- package/dist/wje-orgchart-group.js.map +1 -1
- package/dist/wje-orgchart-item.js +24 -93
- package/dist/wje-orgchart-item.js.map +1 -1
- package/dist/wje-orgchart.js +18 -68
- package/dist/wje-orgchart.js.map +1 -1
- package/dist/wje-pagination.js +113 -397
- package/dist/wje-pagination.js.map +1 -1
- package/dist/wje-popup.js +3 -3
- package/dist/wje-popup.js.map +1 -1
- package/dist/wje-progress-bar.js +53 -205
- package/dist/wje-progress-bar.js.map +1 -1
- package/dist/wje-qr-code.js +398 -2980
- package/dist/wje-qr-code.js.map +1 -1
- package/dist/wje-radio-group.js +52 -190
- package/dist/wje-radio-group.js.map +1 -1
- package/dist/wje-radio.js +24 -118
- package/dist/wje-radio.js.map +1 -1
- package/dist/wje-rate.js +62 -266
- package/dist/wje-rate.js.map +1 -1
- package/dist/wje-relative-time.js +24 -99
- package/dist/wje-relative-time.js.map +1 -1
- package/dist/wje-reorder-dropzone.js +9 -31
- package/dist/wje-reorder-dropzone.js.map +1 -1
- package/dist/wje-reorder-handle.js +67 -204
- package/dist/wje-reorder-handle.js.map +1 -1
- package/dist/wje-reorder-item.js +14 -44
- package/dist/wje-reorder-item.js.map +1 -1
- package/dist/wje-reorder.js +61 -246
- package/dist/wje-reorder.js.map +1 -1
- package/dist/wje-route.js +6 -24
- package/dist/wje-route.js.map +1 -1
- package/dist/wje-router-link.js +11 -39
- package/dist/wje-router-link.js.map +1 -1
- package/dist/wje-router-outlet.js +76 -172
- package/dist/wje-router-outlet.js.map +1 -1
- package/dist/wje-routerx.js +537 -1331
- package/dist/wje-routerx.js.map +1 -1
- package/dist/wje-row.js +9 -31
- package/dist/wje-row.js.map +1 -1
- package/dist/wje-select.js +326 -1152
- package/dist/wje-select.js.map +1 -1
- package/dist/wje-slider.js +44 -225
- package/dist/wje-slider.js.map +1 -1
- package/dist/wje-sliding-container.js +295 -1319
- package/dist/wje-sliding-container.js.map +1 -1
- package/dist/wje-split-view.js +35 -121
- package/dist/wje-split-view.js.map +1 -1
- package/dist/wje-status.js +14 -45
- package/dist/wje-status.js.map +1 -1
- package/dist/wje-step.js +9 -32
- package/dist/wje-step.js.map +1 -1
- package/dist/wje-stepper.js +109 -357
- package/dist/wje-stepper.js.map +1 -1
- package/dist/wje-store.js +67 -360
- package/dist/wje-store.js.map +1 -1
- package/dist/wje-tab-group.js +85 -314
- package/dist/wje-tab-group.js.map +1 -1
- package/dist/wje-tab-panel.js +7 -28
- package/dist/wje-tab-panel.js.map +1 -1
- package/dist/wje-tab.js +21 -198
- package/dist/wje-tab.js.map +1 -1
- package/dist/wje-textarea.js +64 -264
- package/dist/wje-textarea.js.map +1 -1
- package/dist/wje-thumbnail.js +10 -51
- package/dist/wje-thumbnail.js.map +1 -1
- package/dist/wje-toast.js +127 -632
- package/dist/wje-toast.js.map +1 -1
- package/dist/wje-toggle.js +52 -177
- package/dist/wje-toggle.js.map +1 -1
- package/dist/wje-toolbar-action.js +128 -456
- package/dist/wje-toolbar-action.js.map +1 -1
- package/dist/wje-toolbar.js +75 -270
- package/dist/wje-toolbar.js.map +1 -1
- package/dist/wje-tooltip.js +50 -161
- package/dist/wje-tooltip.js.map +1 -1
- package/dist/wje-tree-item.js +70 -301
- package/dist/wje-tree-item.js.map +1 -1
- package/dist/wje-tree.js +145 -489
- package/dist/wje-tree.js.map +1 -1
- package/dist/wje-visually-hidden.js +7 -34
- package/dist/wje-visually-hidden.js.map +1 -1
- package/package.json +3 -2
- package/dist/form-associated-element-DEQ4y-jn.js +0 -245
- package/dist/icon-CReYMzAK.js +0 -245
- package/dist/popup.element-CwXvVFK7.js +0 -2133
- package/dist/router-links-wjqCnncc.js +0 -156
package/dist/wje-routerx.js
CHANGED
|
@@ -7,1445 +7,651 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7
7
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
8
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
9
9
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
10
|
-
var
|
|
11
|
-
import { r as
|
|
12
|
-
import
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const level = currentLevel();
|
|
73
|
-
matches[level] = matches[level] || [];
|
|
74
|
-
matches[level].push(route);
|
|
75
|
-
}
|
|
76
|
-
function currentLevel() {
|
|
77
|
-
return ancestors.join(".");
|
|
78
|
-
}
|
|
79
|
-
return pop();
|
|
80
|
-
}
|
|
81
|
-
function arrayDsl(routes) {
|
|
82
|
-
const result = [];
|
|
83
|
-
routes.forEach(({ name, children, ...options }) => {
|
|
84
|
-
if (typeof options.path !== "string") {
|
|
85
|
-
const parts = name.split(".");
|
|
86
|
-
options.path = parts[parts.length - 1];
|
|
87
|
-
}
|
|
88
|
-
result.push({
|
|
89
|
-
name,
|
|
90
|
-
path: options.path,
|
|
91
|
-
options,
|
|
92
|
-
routes: children ? arrayDsl(children) : []
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
return result;
|
|
96
|
-
}
|
|
97
|
-
const paramInjectMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?+*]?)/g;
|
|
98
|
-
const specialParamChars = /[+*?]$/g;
|
|
99
|
-
const queryMatcher = /\?(.+)/;
|
|
100
|
-
const _compiledPatterns = {};
|
|
101
|
-
function compilePattern(pattern, compiler) {
|
|
102
|
-
if (!(pattern in _compiledPatterns)) {
|
|
103
|
-
_compiledPatterns[pattern] = compiler(pattern);
|
|
104
|
-
}
|
|
105
|
-
return _compiledPatterns[pattern];
|
|
106
|
-
}
|
|
107
|
-
function extractParamNames(pattern, compiler) {
|
|
108
|
-
return compilePattern(pattern, compiler).paramNames;
|
|
109
|
-
}
|
|
110
|
-
function extractParams(pattern, path, compiler) {
|
|
111
|
-
const cp = compilePattern(pattern, compiler);
|
|
112
|
-
const matcher = cp.matcher;
|
|
113
|
-
const paramNames = cp.paramNames;
|
|
114
|
-
const match = path.match(matcher);
|
|
115
|
-
if (!match) {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
const params = {};
|
|
119
|
-
paramNames.forEach(function(paramName, index) {
|
|
120
|
-
params[paramName] = match[index + 1] && decodeURIComponent(match[index + 1]);
|
|
121
|
-
});
|
|
122
|
-
return params;
|
|
123
|
-
}
|
|
124
|
-
function injectParams(pattern, params) {
|
|
125
|
-
params = params || {};
|
|
126
|
-
return pattern.replace(paramInjectMatcher, function(match, param) {
|
|
127
|
-
const paramName = param.replace(specialParamChars, "");
|
|
128
|
-
const lastChar = param.slice(-1);
|
|
129
|
-
if (lastChar === "?" || lastChar === "*") {
|
|
130
|
-
if (params[paramName] == null) {
|
|
131
|
-
return "";
|
|
132
|
-
}
|
|
133
|
-
} else {
|
|
134
|
-
invariant(
|
|
135
|
-
params[paramName] != null,
|
|
136
|
-
"Missing '%s' parameter for path '%s'",
|
|
137
|
-
paramName,
|
|
138
|
-
pattern
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
let paramValue = encodeURIComponent(params[paramName]);
|
|
142
|
-
if (lastChar === "*" || lastChar === "+") {
|
|
143
|
-
paramValue = paramValue.replace("%2F", "/");
|
|
144
|
-
}
|
|
145
|
-
return paramValue;
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
function extractQuery(qs2, path) {
|
|
149
|
-
const match = path.match(queryMatcher);
|
|
150
|
-
return match && qs2.parse(match[1]);
|
|
151
|
-
}
|
|
152
|
-
function withQuery(qs2, path, query) {
|
|
153
|
-
const queryString = qs2.stringify(query, { indices: false });
|
|
154
|
-
if (queryString) {
|
|
155
|
-
return withoutQuery(path) + "?" + queryString;
|
|
156
|
-
}
|
|
157
|
-
return path;
|
|
158
|
-
}
|
|
159
|
-
function withoutQuery(path) {
|
|
160
|
-
return path.replace(queryMatcher, "");
|
|
161
|
-
}
|
|
162
|
-
function bindEvent(el, type, fn) {
|
|
163
|
-
el.addEventListener(type, fn);
|
|
164
|
-
return fn;
|
|
165
|
-
}
|
|
166
|
-
function unbindEvent(el, type, fn) {
|
|
167
|
-
el.removeEventListener(type, fn);
|
|
168
|
-
return fn;
|
|
169
|
-
}
|
|
170
|
-
class History {
|
|
10
|
+
var _t;
|
|
11
|
+
import { r as t } from "./router-links-CNsJ-elb.js";
|
|
12
|
+
import e from "./wje-element.js";
|
|
13
|
+
const n = Array.isArray, r = Object.keys, o = (t2) => t2 ? n(t2) ? t2.slice(0) : i({}, t2) : t2, s = (t2, e2) => {
|
|
14
|
+
const n2 = r(t2);
|
|
15
|
+
return n2.length === r(e2).length && n2.every((n3) => e2[n3] === t2[n3]);
|
|
16
|
+
}, i = Object.assign;
|
|
17
|
+
function a(t2, e2, ...n2) {
|
|
18
|
+
if (!t2) {
|
|
19
|
+
let t3 = 0;
|
|
20
|
+
throw new Error("Invariant Violation: " + e2.replace(/%s/g, () => n2[t3++]));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function c(t2) {
|
|
24
|
+
let e2 = [];
|
|
25
|
+
const n2 = {}, r2 = {};
|
|
26
|
+
function o2() {
|
|
27
|
+
return n2[s2()] || [];
|
|
28
|
+
}
|
|
29
|
+
function s2() {
|
|
30
|
+
return e2.join(".");
|
|
31
|
+
}
|
|
32
|
+
return t2(function(t3, i2, c2) {
|
|
33
|
+
let h2;
|
|
34
|
+
if (a(!r2[t3], 'Route names must be unique, but route "%s" is declared multiple times', t3), r2[t3] = true, 1 === arguments.length && (i2 = {}), 2 === arguments.length && "function" == typeof i2 && (c2 = i2, i2 = {}), "string" != typeof i2.path) {
|
|
35
|
+
const e3 = t3.split(".");
|
|
36
|
+
i2.path = e3[e3.length - 1];
|
|
37
|
+
}
|
|
38
|
+
c2 && (e2 = e2.concat(t3), c2(), h2 = o2(), e2.splice(-1)), (function(t4) {
|
|
39
|
+
const e3 = s2();
|
|
40
|
+
n2[e3] = n2[e3] || [], n2[e3].push(t4);
|
|
41
|
+
})({ name: t3, path: i2.path, routes: h2 || [], options: i2 });
|
|
42
|
+
}), o2();
|
|
43
|
+
}
|
|
44
|
+
function h(t2) {
|
|
45
|
+
const e2 = [];
|
|
46
|
+
return t2.forEach(({ name: t3, children: n2, ...r2 }) => {
|
|
47
|
+
if ("string" != typeof r2.path) {
|
|
48
|
+
const e3 = t3.split(".");
|
|
49
|
+
r2.path = e3[e3.length - 1];
|
|
50
|
+
}
|
|
51
|
+
e2.push({ name: t3, path: r2.path, options: r2, routes: n2 ? h(n2) : [] });
|
|
52
|
+
}), e2;
|
|
53
|
+
}
|
|
54
|
+
const u = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?+*]?)/g, l = /[+*?]$/g, p = /\?(.+)/, f = {};
|
|
55
|
+
function m(t2, e2) {
|
|
56
|
+
return t2 in f || (f[t2] = e2(t2)), f[t2];
|
|
57
|
+
}
|
|
58
|
+
function d(t2, e2) {
|
|
59
|
+
const n2 = e2.match(p);
|
|
60
|
+
return n2 && t2.parse(n2[1]);
|
|
61
|
+
}
|
|
62
|
+
function g(t2) {
|
|
63
|
+
return t2.replace(p, "");
|
|
64
|
+
}
|
|
65
|
+
function y(t2, e2, n2) {
|
|
66
|
+
return t2.addEventListener(e2, n2), n2;
|
|
67
|
+
}
|
|
68
|
+
function w(t2, e2, n2) {
|
|
69
|
+
return t2.removeEventListener(e2, n2), n2;
|
|
70
|
+
}
|
|
71
|
+
class b {
|
|
171
72
|
constructor() {
|
|
172
|
-
this.handlers = [];
|
|
173
|
-
this.checkUrl = this.checkUrl.bind(this);
|
|
174
|
-
this.location = window.location;
|
|
175
|
-
this.history = window.history;
|
|
73
|
+
this.handlers = [], this.checkUrl = this.checkUrl.bind(this), this.location = window.location, this.history = window.history;
|
|
176
74
|
}
|
|
177
|
-
// Set up all inheritable **Backbone.History** properties and methods.
|
|
178
|
-
// Are we at the app root?
|
|
179
75
|
atRoot() {
|
|
180
76
|
return this.location.pathname.replace(/[^\/]$/, "$&/") === this.root;
|
|
181
77
|
}
|
|
182
|
-
// Gets the true hash value. Cannot use location.hash directly due to bug
|
|
183
|
-
// in Firefox where location.hash will always be decoded.
|
|
184
78
|
getHash() {
|
|
185
|
-
const
|
|
186
|
-
return
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
fragment = this.getHash();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return fragment.replace(routeStripper, "");
|
|
201
|
-
}
|
|
202
|
-
// Start the hash change handling, returning `true` if the current URL matches
|
|
203
|
-
// an existing route, and `false` otherwise.
|
|
204
|
-
start(options) {
|
|
79
|
+
const t2 = this.location.href.match(/#(.*)$/);
|
|
80
|
+
return t2 ? t2[1] : "";
|
|
81
|
+
}
|
|
82
|
+
getFragment(t2, e2) {
|
|
83
|
+
if (null == t2) if (this._hasPushState || !this._wantsHashChange || e2) {
|
|
84
|
+
t2 = decodeURI(this.location.pathname + this.location.search);
|
|
85
|
+
const e3 = this.root.replace(R, "");
|
|
86
|
+
t2.indexOf(e3) || (t2 = t2.slice(e3.length));
|
|
87
|
+
} else t2 = this.getHash();
|
|
88
|
+
return t2.replace(v, "");
|
|
89
|
+
}
|
|
90
|
+
start(t2) {
|
|
205
91
|
this.started = true;
|
|
206
|
-
const
|
|
207
|
-
this.location =
|
|
208
|
-
|
|
209
|
-
this.root =
|
|
210
|
-
|
|
211
|
-
this.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
bindEvent(window, this._hasPushState ? "popstate" : "hashchange", this.checkUrl);
|
|
215
|
-
this.fragment = fragment;
|
|
216
|
-
const loc = this.location;
|
|
217
|
-
if (this._wantsHashChange && _wantsPushState) {
|
|
218
|
-
if (!this._hasPushState && !this.atRoot()) {
|
|
219
|
-
this.fragment = this.getFragment(null, true);
|
|
220
|
-
this.location.replace(`${this.root}#${this.fragment}`);
|
|
221
|
-
return true;
|
|
222
|
-
} else if (this._hasPushState && this.atRoot() && loc.hash) {
|
|
223
|
-
this.fragment = this.getHash().replace(routeStripper, "");
|
|
224
|
-
this.history.replaceState({}, document.title, this.root + this.fragment);
|
|
225
|
-
}
|
|
92
|
+
const e2 = !!t2.pushState;
|
|
93
|
+
this.location = t2.location || this.location, this.history = t2.history || this.history, this.root = t2.root, this._wantsHashChange = false !== t2.hashChange, this._hasPushState = e2;
|
|
94
|
+
const n2 = this.getFragment();
|
|
95
|
+
this.root = `/${this.root}/`.replace(E, "/"), y(window, this._hasPushState ? "popstate" : "hashchange", this.checkUrl), this.fragment = n2;
|
|
96
|
+
const r2 = this.location;
|
|
97
|
+
if (this._wantsHashChange && e2) {
|
|
98
|
+
if (!this._hasPushState && !this.atRoot()) return this.fragment = this.getFragment(null, true), this.location.replace(`${this.root}#${this.fragment}`), true;
|
|
99
|
+
this._hasPushState && this.atRoot() && r2.hash && (this.fragment = this.getHash().replace(v, ""), this.history.replaceState({}, document.title, this.root + this.fragment));
|
|
226
100
|
}
|
|
227
|
-
if (!
|
|
101
|
+
if (!t2.silent) return this.loadUrl();
|
|
228
102
|
}
|
|
229
|
-
// Disable Backbone.history, perhaps temporarily. Not useful in a real app,
|
|
230
|
-
// but possibly useful for unit testing Routers.
|
|
231
103
|
stop() {
|
|
232
|
-
|
|
233
|
-
this.started = false;
|
|
104
|
+
w(window, this._hasPushState ? "popstate" : "hashchange", this.checkUrl), this.started = false;
|
|
234
105
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
route(route, callback) {
|
|
238
|
-
this.handlers.unshift({ route, callback });
|
|
106
|
+
route(t2, e2) {
|
|
107
|
+
this.handlers.unshift({ route: t2, callback: e2 });
|
|
239
108
|
}
|
|
240
|
-
// Checks the current URL to see if it has changed, and if it has,
|
|
241
|
-
// calls `loadUrl`.
|
|
242
109
|
checkUrl() {
|
|
243
|
-
|
|
244
|
-
if (current === this.fragment) return false;
|
|
110
|
+
if (this.getFragment() === this.fragment) return false;
|
|
245
111
|
this.loadUrl();
|
|
246
112
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
loadUrl(fragment) {
|
|
251
|
-
fragment = this.fragment = this.getFragment(fragment);
|
|
252
|
-
return this.handlers.some((handler) => {
|
|
253
|
-
if (handler.route.test(fragment)) {
|
|
254
|
-
handler.callback(fragment);
|
|
255
|
-
return true;
|
|
256
|
-
}
|
|
113
|
+
loadUrl(t2) {
|
|
114
|
+
return t2 = this.fragment = this.getFragment(t2), this.handlers.some((e2) => {
|
|
115
|
+
if (e2.route.test(t2)) return e2.callback(t2), true;
|
|
257
116
|
});
|
|
258
117
|
}
|
|
259
|
-
|
|
260
|
-
// 'replace' option is passed. You are responsible for properly URL-encoding
|
|
261
|
-
// the fragment in advance.
|
|
262
|
-
//
|
|
263
|
-
// The options object can contain `trigger: true` if you wish to have the
|
|
264
|
-
// route callback be fired (not usually desirable), or `replace: true`, if
|
|
265
|
-
// you wish to modify the current URL without adding an entry to the history.
|
|
266
|
-
update(fragment, options) {
|
|
118
|
+
update(t2, e2) {
|
|
267
119
|
if (!this.started) return false;
|
|
268
|
-
|
|
269
|
-
let
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
this._updateHash(this.location, fragment, options.replace);
|
|
278
|
-
} else {
|
|
279
|
-
return this.location.assign(url);
|
|
280
|
-
}
|
|
281
|
-
if (options.trigger) return this.loadUrl(fragment);
|
|
282
|
-
}
|
|
283
|
-
// Update the hash location, either replacing the current entry, or adding
|
|
284
|
-
// a new one to the browser history.
|
|
285
|
-
_updateHash(location, fragment, replace) {
|
|
286
|
-
if (replace) {
|
|
287
|
-
const href = location.href.replace(/(javascript:|#).*$/, "");
|
|
288
|
-
location.replace(`${href}#${fragment}`);
|
|
289
|
-
} else {
|
|
290
|
-
location.hash = `#${fragment}`;
|
|
120
|
+
e2 && true !== e2 || (e2 = { trigger: !!e2 });
|
|
121
|
+
let n2 = this.root + (t2 = this.getFragment(t2 || ""));
|
|
122
|
+
if (t2 = t2.replace($, ""), this.fragment !== t2) {
|
|
123
|
+
if (this.fragment = t2, "" === t2 && "/" !== n2 && (n2 = n2.slice(0, -1)), this._hasPushState) this.history[e2.replace ? "replaceState" : "pushState"]({}, document.title, n2);
|
|
124
|
+
else {
|
|
125
|
+
if (!this._wantsHashChange) return this.location.assign(n2);
|
|
126
|
+
this._updateHash(this.location, t2, e2.replace);
|
|
127
|
+
}
|
|
128
|
+
return e2.trigger ? this.loadUrl(t2) : void 0;
|
|
291
129
|
}
|
|
292
130
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
131
|
+
_updateHash(t2, e2, n2) {
|
|
132
|
+
if (n2) {
|
|
133
|
+
const n3 = t2.href.replace(/(javascript:|#).*$/, "");
|
|
134
|
+
t2.replace(`${n3}#${e2}`);
|
|
135
|
+
} else t2.hash = `#${e2}`;
|
|
136
|
+
}
|
|
137
|
+
onChange(t2) {
|
|
138
|
+
this.route(/^(.*?)$/, t2);
|
|
297
139
|
}
|
|
298
140
|
}
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* @param {BrowserLocationOptions} options
|
|
306
|
-
*/
|
|
307
|
-
constructor(options = {}) {
|
|
308
|
-
this.path = options.path || "";
|
|
309
|
-
this.options = extend(
|
|
310
|
-
{
|
|
311
|
-
pushState: false,
|
|
312
|
-
root: "/"
|
|
313
|
-
},
|
|
314
|
-
options
|
|
315
|
-
);
|
|
316
|
-
this.history = new History();
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Get the current URL
|
|
320
|
-
*/
|
|
141
|
+
const v = /^[#\/]|\s+$/g, E = /^\/+|\/+$/g, R = /\/$/, $ = /#.*$/;
|
|
142
|
+
class T {
|
|
143
|
+
constructor(t2 = {}) {
|
|
144
|
+
this.path = t2.path || "", this.options = i({ pushState: false, root: "/" }, t2), this.history = new b();
|
|
145
|
+
}
|
|
321
146
|
getURL() {
|
|
322
147
|
return this.path;
|
|
323
148
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
* back to the router. Add a new entry in browser's history.
|
|
327
|
-
*/
|
|
328
|
-
setURL(path, options = {}) {
|
|
329
|
-
if (this.path !== path) {
|
|
330
|
-
this.path = path;
|
|
331
|
-
this.history.update(path, extend({ trigger: true }, options));
|
|
332
|
-
}
|
|
149
|
+
setURL(t2, e2 = {}) {
|
|
150
|
+
this.path !== t2 && (this.path = t2, this.history.update(t2, i({ trigger: true }, e2)));
|
|
333
151
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
* back to the router. Replace the latest entry in broser's history.
|
|
337
|
-
*/
|
|
338
|
-
replaceURL(path, options = {}) {
|
|
339
|
-
if (this.path !== path) {
|
|
340
|
-
this.path = path;
|
|
341
|
-
this.history.update(path, extend({ trigger: true, replace: true }, options));
|
|
342
|
-
}
|
|
152
|
+
replaceURL(t2, e2 = {}) {
|
|
153
|
+
this.path !== t2 && (this.path = t2, this.history.update(t2, i({ trigger: true, replace: true }, e2)));
|
|
343
154
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
* @param {(url: string) => void} callback
|
|
347
|
-
*/
|
|
348
|
-
onChange(callback) {
|
|
349
|
-
this.callback = callback;
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Given a path, generate a URL appending root
|
|
353
|
-
* if pushState is used and # if hash state is used
|
|
354
|
-
*/
|
|
355
|
-
formatURL(path) {
|
|
356
|
-
const { root, pushState } = this.options;
|
|
357
|
-
if (pushState) {
|
|
358
|
-
let rootURL = root;
|
|
359
|
-
if (path !== "") {
|
|
360
|
-
rootURL = rootURL.replace(/\/$/, "");
|
|
361
|
-
}
|
|
362
|
-
return rootURL + path;
|
|
363
|
-
} else {
|
|
364
|
-
if (path[0] === "/") {
|
|
365
|
-
path = path.substr(1);
|
|
366
|
-
}
|
|
367
|
-
return `#${path}`;
|
|
368
|
-
}
|
|
155
|
+
onChange(t2) {
|
|
156
|
+
this.callback = t2;
|
|
369
157
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
* - LocationBar expects all .update() calls to be called without root
|
|
376
|
-
* - this method is public so that we could dispatch URLs without root in router
|
|
377
|
-
*/
|
|
378
|
-
removeRoot(url) {
|
|
379
|
-
const { root, pushState } = this.options;
|
|
380
|
-
if (pushState && root && root !== "/") {
|
|
381
|
-
return url.replace(root, "");
|
|
382
|
-
} else {
|
|
383
|
-
return url;
|
|
158
|
+
formatURL(t2) {
|
|
159
|
+
const { root: e2, pushState: n2 } = this.options;
|
|
160
|
+
if (n2) {
|
|
161
|
+
let n3 = e2;
|
|
162
|
+
return "" !== t2 && (n3 = n3.replace(/\/$/, "")), n3 + t2;
|
|
384
163
|
}
|
|
164
|
+
return "/" === t2[0] && (t2 = t2.substr(1)), `#${t2}`;
|
|
165
|
+
}
|
|
166
|
+
removeRoot(t2) {
|
|
167
|
+
const { root: e2, pushState: n2 } = this.options;
|
|
168
|
+
return n2 && e2 && "/" !== e2 ? t2.replace(e2, "") : t2;
|
|
385
169
|
}
|
|
386
|
-
/**
|
|
387
|
-
* Stop listening to URL changes and link clicks
|
|
388
|
-
*/
|
|
389
170
|
destroy() {
|
|
390
171
|
this.history.stop();
|
|
391
172
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
because we dont' want to kick off routing right away, the router
|
|
395
|
-
does that later by manually calling this handleURL method with the
|
|
396
|
-
url it reads of the location. But it's important this is called
|
|
397
|
-
first by Backbone, because we wanna set a correct this.path value
|
|
398
|
-
|
|
399
|
-
@private
|
|
400
|
-
*/
|
|
401
|
-
handleURL(url) {
|
|
402
|
-
this.path = url;
|
|
403
|
-
if (this.callback) {
|
|
404
|
-
this.callback(url);
|
|
405
|
-
}
|
|
173
|
+
handleURL(t2) {
|
|
174
|
+
this.path = t2, this.callback && this.callback(t2);
|
|
406
175
|
}
|
|
407
|
-
start(
|
|
408
|
-
this.path =
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
});
|
|
412
|
-
this.history.start(this.options);
|
|
176
|
+
start(t2) {
|
|
177
|
+
this.path = t2, this.history.onChange((t3) => {
|
|
178
|
+
this.handleURL(`/${t3 || ""}`);
|
|
179
|
+
}), this.history.start(this.options);
|
|
413
180
|
}
|
|
414
181
|
}
|
|
415
|
-
class
|
|
182
|
+
class U {
|
|
416
183
|
constructor() {
|
|
417
184
|
this.path = "";
|
|
418
185
|
}
|
|
419
186
|
getURL() {
|
|
420
187
|
return this.path;
|
|
421
188
|
}
|
|
422
|
-
setURL(
|
|
423
|
-
|
|
424
|
-
this.path = path;
|
|
425
|
-
this.handleURL(this.getURL(), options);
|
|
426
|
-
}
|
|
189
|
+
setURL(t2, e2) {
|
|
190
|
+
this.path !== t2 && (this.path = t2, this.handleURL(this.getURL(), e2));
|
|
427
191
|
}
|
|
428
|
-
replaceURL(
|
|
429
|
-
|
|
430
|
-
this.setURL(path, options);
|
|
431
|
-
}
|
|
192
|
+
replaceURL(t2, e2) {
|
|
193
|
+
this.path !== t2 && this.setURL(t2, e2);
|
|
432
194
|
}
|
|
433
|
-
onChange(
|
|
434
|
-
this.callback =
|
|
195
|
+
onChange(t2) {
|
|
196
|
+
this.callback = t2;
|
|
435
197
|
}
|
|
436
|
-
handleURL(
|
|
437
|
-
this.path =
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
this.callback(url);
|
|
441
|
-
}
|
|
198
|
+
handleURL(t2, e2) {
|
|
199
|
+
this.path = t2;
|
|
200
|
+
const n2 = false !== (e2 == null ? void 0 : e2.trigger);
|
|
201
|
+
this.callback && n2 && this.callback(t2);
|
|
442
202
|
}
|
|
443
|
-
removeRoot(
|
|
444
|
-
return
|
|
203
|
+
removeRoot(t2) {
|
|
204
|
+
return t2;
|
|
445
205
|
}
|
|
446
|
-
formatURL(
|
|
447
|
-
return
|
|
206
|
+
formatURL(t2) {
|
|
207
|
+
return t2;
|
|
448
208
|
}
|
|
449
|
-
start(
|
|
450
|
-
this.path =
|
|
209
|
+
start(t2) {
|
|
210
|
+
this.path = t2;
|
|
451
211
|
}
|
|
452
212
|
}
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
m.error && m.error(transition2, err);
|
|
213
|
+
const k = "TransitionRedirected", L = "TransitionCancelled";
|
|
214
|
+
function C(t2, e2, n2) {
|
|
215
|
+
t2.middleware.forEach((t3) => {
|
|
216
|
+
t3.error && t3.error(e2, n2);
|
|
458
217
|
});
|
|
459
218
|
}
|
|
460
|
-
function
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
const match = options.match;
|
|
467
|
-
const routes = match.routes;
|
|
468
|
-
const params = match.params;
|
|
469
|
-
const pathname = match.pathname;
|
|
470
|
-
const query = match.query;
|
|
471
|
-
const id = options.id;
|
|
472
|
-
const startTime = Date.now();
|
|
473
|
-
log("---");
|
|
474
|
-
log("Transition #" + id, "to", path);
|
|
475
|
-
log(
|
|
476
|
-
"Transition #" + id,
|
|
477
|
-
"routes:",
|
|
478
|
-
routes.map((r) => r.name)
|
|
479
|
-
);
|
|
480
|
-
log("Transition #" + id, "params:", params);
|
|
481
|
-
log("Transition #" + id, "query:", query);
|
|
482
|
-
let resolve2, reject;
|
|
483
|
-
const promise = new Promise(function(res, rej) {
|
|
484
|
-
resolve2 = res;
|
|
485
|
-
reject = rej;
|
|
219
|
+
function j(t2) {
|
|
220
|
+
const e2 = (t2 = t2 || {}).router, n2 = e2.log, r2 = e2.logError, s2 = t2.path, i2 = t2.match, c2 = i2.routes, h2 = i2.params, u2 = i2.pathname, l2 = i2.query, p2 = t2.id, f2 = Date.now();
|
|
221
|
+
let m2, d2;
|
|
222
|
+
n2("---"), n2("Transition #" + p2, "to", s2), n2("Transition #" + p2, "routes:", c2.map((t3) => t3.name)), n2("Transition #" + p2, "params:", h2), n2("Transition #" + p2, "query:", l2);
|
|
223
|
+
const g2 = new Promise(function(t3, e3) {
|
|
224
|
+
m2 = t3, d2 = e3;
|
|
486
225
|
});
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
}).catch(function(
|
|
490
|
-
|
|
491
|
-
log("Transition #" + id, "FAILED");
|
|
492
|
-
logError(err);
|
|
493
|
-
}
|
|
226
|
+
g2.then(function() {
|
|
227
|
+
n2("Transition #" + p2, "completed in", Date.now() - f2 + "ms");
|
|
228
|
+
}).catch(function(t3) {
|
|
229
|
+
t3.type !== k && t3.type !== L && (n2("Transition #" + p2, "FAILED"), r2(t3));
|
|
494
230
|
});
|
|
495
|
-
let
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
return router2.transitionTo(path);
|
|
515
|
-
},
|
|
516
|
-
cancel: function(err) {
|
|
517
|
-
if (router2.state.activeTransition !== transition2) {
|
|
518
|
-
return;
|
|
519
|
-
}
|
|
520
|
-
if (transition2.isCancelled) {
|
|
521
|
-
return;
|
|
522
|
-
}
|
|
523
|
-
router2.state.activeTransition = null;
|
|
524
|
-
transition2.isCancelled = true;
|
|
525
|
-
cancelled = true;
|
|
526
|
-
if (!err) {
|
|
527
|
-
err = new Error(TRANSITION_CANCELLED);
|
|
528
|
-
err.type = TRANSITION_CANCELLED;
|
|
529
|
-
}
|
|
530
|
-
if (err.type === TRANSITION_CANCELLED) {
|
|
531
|
-
log("Transition #" + id, "cancelled");
|
|
532
|
-
}
|
|
533
|
-
if (err.type === TRANSITION_REDIRECTED) {
|
|
534
|
-
log("Transition #" + id, "redirected");
|
|
535
|
-
}
|
|
536
|
-
router2.middleware.forEach((m) => {
|
|
537
|
-
m.cancel && m.cancel(transition2, err);
|
|
538
|
-
});
|
|
539
|
-
reject(err);
|
|
540
|
-
},
|
|
541
|
-
followRedirects: function() {
|
|
542
|
-
return promise.catch(function(reason) {
|
|
543
|
-
if (router2.state.activeTransition) {
|
|
544
|
-
return router2.state.activeTransition.followRedirects();
|
|
545
|
-
}
|
|
546
|
-
return Promise.reject(reason);
|
|
547
|
-
});
|
|
548
|
-
},
|
|
549
|
-
then: promise.then.bind(promise),
|
|
550
|
-
catch: promise.catch.bind(promise)
|
|
551
|
-
};
|
|
552
|
-
router2.middleware.forEach((m) => {
|
|
553
|
-
m.before && m.before(transition2);
|
|
554
|
-
});
|
|
555
|
-
function callNext(i, prevResult) {
|
|
556
|
-
let middleware;
|
|
557
|
-
let middlewareName;
|
|
558
|
-
if (cancelled) {
|
|
559
|
-
return;
|
|
560
|
-
}
|
|
561
|
-
if (i < router2.middleware.length) {
|
|
562
|
-
middleware = router2.middleware[i];
|
|
563
|
-
middlewareName = middleware.name || "anonymous";
|
|
564
|
-
log("Transition #" + id, "resolving middleware:", middlewareName);
|
|
565
|
-
let middlewarePromise;
|
|
231
|
+
let y2 = false;
|
|
232
|
+
const w2 = { id: p2, prev: { routes: o(e2.state.routes) || [], path: e2.state.path || "", pathname: e2.state.pathname || "", params: o(e2.state.params) || {}, query: o(e2.state.query) || {} }, routes: o(c2), path: s2, pathname: u2, params: o(h2), query: o(l2), redirectTo: function(...t3) {
|
|
233
|
+
return e2.transitionTo(...t3);
|
|
234
|
+
}, retry: function() {
|
|
235
|
+
return e2.transitionTo(s2);
|
|
236
|
+
}, cancel: function(t3) {
|
|
237
|
+
e2.state.activeTransition === w2 && (w2.isCancelled || (e2.state.activeTransition = null, w2.isCancelled = true, y2 = true, t3 || ((t3 = new Error(L)).type = L), t3.type === L && n2("Transition #" + p2, "cancelled"), t3.type === k && n2("Transition #" + p2, "redirected"), e2.middleware.forEach((e3) => {
|
|
238
|
+
e3.cancel && e3.cancel(w2, t3);
|
|
239
|
+
}), d2(t3)));
|
|
240
|
+
}, followRedirects: function() {
|
|
241
|
+
return g2.catch(function(t3) {
|
|
242
|
+
return e2.state.activeTransition ? e2.state.activeTransition.followRedirects() : Promise.reject(t3);
|
|
243
|
+
});
|
|
244
|
+
}, then: g2.then.bind(g2), catch: g2.catch.bind(g2) };
|
|
245
|
+
function b2(t3, r3) {
|
|
246
|
+
let o2, i3;
|
|
247
|
+
if (!y2) if (t3 < e2.middleware.length) {
|
|
248
|
+
let s3;
|
|
249
|
+
o2 = e2.middleware[t3], i3 = o2.name || "anonymous", n2("Transition #" + p2, "resolving middleware:", i3);
|
|
566
250
|
try {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
"Middleware %s returned a transition which resulted in a deadlock",
|
|
571
|
-
middlewareName
|
|
572
|
-
);
|
|
573
|
-
} catch (err) {
|
|
574
|
-
router2.state.activeTransition = null;
|
|
575
|
-
runError(router2, transition2, err);
|
|
576
|
-
return reject(err);
|
|
251
|
+
s3 = o2.resolve ? o2.resolve(w2, r3) : r3, a(w2 !== s3, "Middleware %s returned a transition which resulted in a deadlock", i3);
|
|
252
|
+
} catch (t4) {
|
|
253
|
+
return e2.state.activeTransition = null, C(e2, w2, t4), d2(t4);
|
|
577
254
|
}
|
|
578
|
-
Promise.resolve(
|
|
579
|
-
|
|
580
|
-
}).catch(function(
|
|
581
|
-
|
|
582
|
-
router2.state.activeTransition = null;
|
|
583
|
-
runError(router2, transition2, err);
|
|
584
|
-
reject(err);
|
|
585
|
-
});
|
|
586
|
-
} else {
|
|
587
|
-
router2.state = {
|
|
588
|
-
activeTransition: null,
|
|
589
|
-
routes,
|
|
590
|
-
path,
|
|
591
|
-
pathname,
|
|
592
|
-
params,
|
|
593
|
-
query
|
|
594
|
-
};
|
|
595
|
-
router2.middleware.forEach((m) => {
|
|
596
|
-
m.done && m.done(transition2);
|
|
255
|
+
Promise.resolve(s3).then(function(e3) {
|
|
256
|
+
b2(t3 + 1, e3);
|
|
257
|
+
}).catch(function(t4) {
|
|
258
|
+
n2("Transition #" + p2, "resolving middleware:", i3, "FAILED"), e2.state.activeTransition = null, C(e2, w2, t4), d2(t4);
|
|
597
259
|
});
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
260
|
+
} else e2.state = { activeTransition: null, routes: c2, path: s2, pathname: u2, params: h2, query: l2 }, e2.middleware.forEach((t4) => {
|
|
261
|
+
t4.done && t4.done(w2);
|
|
262
|
+
}), m2();
|
|
263
|
+
}
|
|
264
|
+
return e2.middleware.forEach((t3) => {
|
|
265
|
+
t3.before && t3.before(w2);
|
|
266
|
+
}), t2.noop ? m2() : Promise.resolve().then(() => b2(0)), t2.noop && (w2.noop = true), w2;
|
|
267
|
+
}
|
|
268
|
+
function S(t2, e2) {
|
|
269
|
+
const n2 = (function(t3, e3, n3) {
|
|
270
|
+
return y(t3, e3, function(t4) {
|
|
271
|
+
const e4 = t4.target.closest("a");
|
|
272
|
+
e4 && n3(t4, e4);
|
|
273
|
+
});
|
|
274
|
+
})(t2, "click", function(t3, n3) {
|
|
275
|
+
(function(t4, e3) {
|
|
276
|
+
if (1 !== (function(t5) {
|
|
277
|
+
return t5 = t5 || window.event, null === t5.which ? t5.button : t5.which;
|
|
278
|
+
})(t4)) return;
|
|
279
|
+
if (t4.metaKey || t4.ctrlKey || t4.shiftKey) return;
|
|
280
|
+
if (t4.defaultPrevented) return;
|
|
281
|
+
if (e3.target) return;
|
|
282
|
+
if (null !== e3.getAttribute("data-bypass")) return;
|
|
283
|
+
const n4 = e3.getAttribute("href");
|
|
284
|
+
if (!n4 || 0 === n4.length) return;
|
|
285
|
+
if (/^(#|https{0,1}:\/\/|mailto|javascript:)/i.test(n4)) return;
|
|
286
|
+
return true;
|
|
287
|
+
})(t3, n3) && e2(t3, n3);
|
|
614
288
|
});
|
|
615
|
-
return function
|
|
616
|
-
|
|
289
|
+
return function() {
|
|
290
|
+
w(t2, "click", n2);
|
|
617
291
|
};
|
|
618
292
|
}
|
|
619
|
-
function
|
|
620
|
-
|
|
621
|
-
const el2 = e.target.closest("a");
|
|
622
|
-
if (el2) {
|
|
623
|
-
fn(e, el2);
|
|
624
|
-
}
|
|
293
|
+
function O(t2, e2, n2) {
|
|
294
|
+
true !== n2 && (t2[e2] = "function" == typeof n2 ? n2 : () => {
|
|
625
295
|
});
|
|
626
296
|
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
const
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
const
|
|
648
|
-
|
|
649
|
-
return querystring.split("&").reduce((acc, pair) => {
|
|
650
|
-
const parts = pair.split("=");
|
|
651
|
-
acc[parts[0]] = decodeURIComponent(parts[1]);
|
|
652
|
-
return acc;
|
|
653
|
-
}, {});
|
|
654
|
-
},
|
|
655
|
-
stringify(params) {
|
|
656
|
-
return Object.keys(params).reduce((acc, key) => {
|
|
657
|
-
if (params[key] !== void 0) {
|
|
658
|
-
acc.push(key + "=" + encodeURIComponent(params[key]));
|
|
659
|
-
}
|
|
660
|
-
return acc;
|
|
661
|
-
}, []).join("&");
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
function parse(input, loose) {
|
|
665
|
-
if (input instanceof RegExp) return { keys: false, pattern: input };
|
|
666
|
-
var c, o, tmp, ext, keys2 = [], pattern = "", arr = input.split("/");
|
|
667
|
-
arr[0] || arr.shift();
|
|
668
|
-
while (tmp = arr.shift()) {
|
|
669
|
-
c = tmp[0];
|
|
670
|
-
if (c === "*") {
|
|
671
|
-
keys2.push(c);
|
|
672
|
-
pattern += tmp[1] === "?" ? "(?:/(.*))?" : "/(.*)";
|
|
673
|
-
} else if (c === ":") {
|
|
674
|
-
o = tmp.indexOf("?", 1);
|
|
675
|
-
ext = tmp.indexOf(".", 1);
|
|
676
|
-
keys2.push(tmp.substring(1, !!~o ? o : !!~ext ? ext : tmp.length));
|
|
677
|
-
pattern += !!~o && !~ext ? "(?:/([^/]+?))?" : "/([^/]+?)";
|
|
678
|
-
if (!!~ext) pattern += (!!~o ? "?" : "") + "\\" + tmp.substring(ext);
|
|
679
|
-
} else {
|
|
680
|
-
pattern += "/" + tmp;
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
return {
|
|
684
|
-
keys: keys2,
|
|
685
|
-
pattern: new RegExp("^" + pattern + "/?$", "i")
|
|
686
|
-
};
|
|
687
|
-
}
|
|
688
|
-
const splatRegex = /:(\w+)\*/;
|
|
689
|
-
function patternCompiler(pattern) {
|
|
690
|
-
const splatMatch = splatRegex.exec(pattern);
|
|
691
|
-
const normalizedPattern = splatMatch ? pattern.replace(splatRegex, "*") : pattern;
|
|
692
|
-
const { pattern: matcher, keys: keys2 } = parse(normalizedPattern);
|
|
693
|
-
const paramNames = splatMatch ? keys2.map((key) => key === "*" ? splatMatch[1] : key) : keys2;
|
|
694
|
-
return {
|
|
695
|
-
matcher,
|
|
696
|
-
paramNames
|
|
697
|
-
};
|
|
698
|
-
}
|
|
699
|
-
function createLocation(options) {
|
|
700
|
-
const location = options.location;
|
|
701
|
-
if (typeof location !== "string") {
|
|
702
|
-
return location;
|
|
703
|
-
}
|
|
704
|
-
if (location === "browser") {
|
|
705
|
-
const { pushState, root } = options;
|
|
706
|
-
return new BrowserLocation({ pushState, root });
|
|
707
|
-
} else if (location === "memory") {
|
|
708
|
-
return new MemoryLocation();
|
|
709
|
-
} else {
|
|
710
|
-
throw new Error("Location can be `browser`, `memory` or a custom implementation");
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
let Router$1 = class Router {
|
|
714
|
-
/**
|
|
715
|
-
* @param {RouterOptions} [options]
|
|
716
|
-
*/
|
|
717
|
-
constructor(options = {}) {
|
|
718
|
-
this.nextId = 1;
|
|
719
|
-
this.state = {};
|
|
720
|
-
this.middleware = [];
|
|
721
|
-
this.options = extend(
|
|
722
|
-
{
|
|
723
|
-
location: "browser",
|
|
724
|
-
logError: true,
|
|
725
|
-
qs,
|
|
726
|
-
patternCompiler
|
|
727
|
-
},
|
|
728
|
-
options
|
|
729
|
-
);
|
|
730
|
-
defineLogger(this, "log", this.options.log);
|
|
731
|
-
defineLogger(this, "logError", this.options.logError);
|
|
732
|
-
if (options.routes) {
|
|
733
|
-
this.map(options.routes);
|
|
734
|
-
}
|
|
735
|
-
this.location = createLocation(this.options);
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* Add a middleware
|
|
739
|
-
* @param {((transition: Transition) => void) | RouterMiddleware} middleware
|
|
740
|
-
* @param {object} [options]
|
|
741
|
-
* @param {number} [options.at] position to insert the middleware
|
|
742
|
-
* @return {Router}
|
|
743
|
-
* @api public
|
|
744
|
-
*/
|
|
745
|
-
use(middleware, options = {}) {
|
|
746
|
-
const m = typeof middleware === "function" ? { resolve: middleware } : middleware;
|
|
747
|
-
typeof options.at === "number" ? this.middleware.splice(options.at, 0, m) : this.middleware.push(m);
|
|
748
|
-
m.create && m.create(this);
|
|
749
|
-
return this;
|
|
750
|
-
}
|
|
751
|
-
/**
|
|
752
|
-
* Add the route map
|
|
753
|
-
* @param {routeCallback | RouteDef[]} routes
|
|
754
|
-
* @return {Router}
|
|
755
|
-
* @api public
|
|
756
|
-
*/
|
|
757
|
-
map(routes) {
|
|
758
|
-
this.routes = Array.isArray(routes) ? arrayDsl(routes) : functionDsl(routes);
|
|
759
|
-
const matchers = this.matchers = [];
|
|
760
|
-
const dupes = {};
|
|
761
|
-
const abstracts = {};
|
|
762
|
-
eachBranch({ routes: this.routes }, [], (routes2) => {
|
|
763
|
-
let path = routes2.reduce(
|
|
764
|
-
(memo, r) => (
|
|
765
|
-
// and keep resetting the trailing slash
|
|
766
|
-
(r.path[0] === "/" ? r.path : `${memo}/${r.path}`).replace(/\/$/, "")
|
|
767
|
-
),
|
|
768
|
-
""
|
|
769
|
-
);
|
|
770
|
-
if (path === "") {
|
|
771
|
-
path = "/";
|
|
772
|
-
}
|
|
773
|
-
const lastRoute = routes2[routes2.length - 1];
|
|
774
|
-
if (lastRoute.options.abstract) {
|
|
775
|
-
abstracts[path] = lastRoute.name;
|
|
776
|
-
return;
|
|
777
|
-
}
|
|
778
|
-
if (lastRoute.path === "") {
|
|
779
|
-
let matcher;
|
|
780
|
-
matchers.some((m) => {
|
|
781
|
-
if (m.path === path) {
|
|
782
|
-
matcher = m;
|
|
783
|
-
return true;
|
|
784
|
-
}
|
|
785
|
-
});
|
|
786
|
-
if (matcher) {
|
|
787
|
-
matcher.routes = routes2;
|
|
788
|
-
} else if (abstracts[path]) {
|
|
789
|
-
matchers.push({
|
|
790
|
-
routes: routes2,
|
|
791
|
-
name: abstracts[path],
|
|
792
|
-
path
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
matchers.push({
|
|
797
|
-
routes: routes2,
|
|
798
|
-
name: lastRoute.name,
|
|
799
|
-
path
|
|
800
|
-
});
|
|
801
|
-
if (dupes[path] && lastRoute.path !== "") {
|
|
802
|
-
throw new Error(
|
|
803
|
-
`Routes ${dupes[path]} and ${lastRoute.name} have the same url path '${path}'`
|
|
804
|
-
);
|
|
297
|
+
const q = { parse: (t2) => t2.split("&").reduce((t3, e2) => {
|
|
298
|
+
const n2 = e2.split("=");
|
|
299
|
+
return t3[n2[0]] = decodeURIComponent(n2[1]), t3;
|
|
300
|
+
}, {}), stringify: (t2) => Object.keys(t2).reduce((e2, n2) => (void 0 !== t2[n2] && e2.push(n2 + "=" + encodeURIComponent(t2[n2])), e2), []).join("&") };
|
|
301
|
+
const x = /:(\w+)\*/;
|
|
302
|
+
function P(t2) {
|
|
303
|
+
const e2 = x.exec(t2), n2 = e2 ? t2.replace(x, "*") : t2, { pattern: r2, keys: o2 } = (function(t3) {
|
|
304
|
+
if (t3 instanceof RegExp) return { keys: false, pattern: t3 };
|
|
305
|
+
var e3, n3, r3, o3, s2 = [], i2 = "", a2 = t3.split("/");
|
|
306
|
+
for (a2[0] || a2.shift(); r3 = a2.shift(); ) "*" === (e3 = r3[0]) ? (s2.push(e3), i2 += "?" === r3[1] ? "(?:/(.*))?" : "/(.*)") : ":" === e3 ? (n3 = r3.indexOf("?", 1), o3 = r3.indexOf(".", 1), s2.push(r3.substring(1, ~n3 ? n3 : ~o3 ? o3 : r3.length)), i2 += ~n3 && !~o3 ? "(?:/([^/]+?))?" : "/([^/]+?)", ~o3 && (i2 += (~n3 ? "?" : "") + "\\" + r3.substring(o3))) : i2 += "/" + r3;
|
|
307
|
+
return { keys: s2, pattern: new RegExp("^" + i2 + "/?$", "i") };
|
|
308
|
+
})(n2);
|
|
309
|
+
return { matcher: r2, paramNames: e2 ? o2.map((t3) => "*" === t3 ? e2[1] : t3) : o2 };
|
|
310
|
+
}
|
|
311
|
+
let A = class {
|
|
312
|
+
constructor(t2 = {}) {
|
|
313
|
+
this.nextId = 1, this.state = {}, this.middleware = [], this.options = i({ location: "browser", logError: true, qs: q, patternCompiler: P }, t2), O(this, "log", this.options.log), O(this, "logError", this.options.logError), t2.routes && this.map(t2.routes), this.location = (function(t3) {
|
|
314
|
+
const e2 = t3.location;
|
|
315
|
+
if ("string" != typeof e2) return e2;
|
|
316
|
+
if ("browser" === e2) {
|
|
317
|
+
const { pushState: e3, root: n2 } = t3;
|
|
318
|
+
return new T({ pushState: e3, root: n2 });
|
|
805
319
|
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
320
|
+
if ("memory" === e2) return new U();
|
|
321
|
+
throw new Error("Location can be `browser`, `memory` or a custom implementation");
|
|
322
|
+
})(this.options);
|
|
323
|
+
}
|
|
324
|
+
use(t2, e2 = {}) {
|
|
325
|
+
const n2 = "function" == typeof t2 ? { resolve: t2 } : t2;
|
|
326
|
+
return "number" == typeof e2.at ? this.middleware.splice(e2.at, 0, n2) : this.middleware.push(n2), n2.create && n2.create(this), this;
|
|
327
|
+
}
|
|
328
|
+
map(t2) {
|
|
329
|
+
this.routes = Array.isArray(t2) ? h(t2) : c(t2);
|
|
330
|
+
const e2 = this.matchers = [], n2 = {}, r2 = {};
|
|
331
|
+
return (function t3(e3, n3, r3) {
|
|
332
|
+
e3.routes.forEach((e4) => {
|
|
333
|
+
r3(n3.concat(e4)), e4.routes.length && t3(e4, n3.concat(e4), r3);
|
|
814
334
|
});
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
const location = this.location;
|
|
827
|
-
location.start(path);
|
|
828
|
-
location.onChange((url) => {
|
|
829
|
-
const previousUrl = this.state.path;
|
|
830
|
-
this.dispatch(url).catch((err) => {
|
|
831
|
-
if (err && err.type === TRANSITION_CANCELLED) {
|
|
832
|
-
this.location.replaceURL(previousUrl, { trigger: false });
|
|
335
|
+
})({ routes: this.routes }, [], (t3) => {
|
|
336
|
+
let o2 = t3.reduce((t4, e3) => ("/" === e3.path[0] ? e3.path : `${t4}/${e3.path}`).replace(/\/$/, ""), "");
|
|
337
|
+
"" === o2 && (o2 = "/");
|
|
338
|
+
const s2 = t3[t3.length - 1];
|
|
339
|
+
if (s2.options.abstract) r2[o2] = s2.name;
|
|
340
|
+
else {
|
|
341
|
+
if ("" === s2.path) {
|
|
342
|
+
let n3;
|
|
343
|
+
e2.some((t4) => {
|
|
344
|
+
if (t4.path === o2) return n3 = t4, true;
|
|
345
|
+
}), n3 ? n3.routes = t3 : r2[o2] && e2.push({ routes: t3, name: r2[o2], path: o2 });
|
|
833
346
|
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
});
|
|
837
|
-
return this.dispatch(location.getURL());
|
|
838
|
-
}
|
|
839
|
-
/**
|
|
840
|
-
* Transition to a different route. Passe in url or a route name followed by params and query
|
|
841
|
-
* @param {String} name url or route name
|
|
842
|
-
* @param {Object} [params] Optional
|
|
843
|
-
* @param {Object} [query] Optional
|
|
844
|
-
* @return {Transition} transition
|
|
845
|
-
*
|
|
846
|
-
* @api public
|
|
847
|
-
*/
|
|
848
|
-
transitionTo(name, params, query) {
|
|
849
|
-
if (this.state.activeTransition) {
|
|
850
|
-
return this.replaceWith(name, params, query);
|
|
851
|
-
}
|
|
852
|
-
return this.doTransition("setURL", name, params, query);
|
|
853
|
-
}
|
|
854
|
-
/**
|
|
855
|
-
* Like transitionTo, but doesn't leave an entry in the browser's history,
|
|
856
|
-
* so clicking back will skip this route
|
|
857
|
-
* @param {String} name url or route name followed by params and query
|
|
858
|
-
* @param {Record<string, any>} [params]
|
|
859
|
-
* @param {Record<string, any>} [query]
|
|
860
|
-
* @return {Transition} transition
|
|
861
|
-
*
|
|
862
|
-
* @api public
|
|
863
|
-
*/
|
|
864
|
-
replaceWith(name, params, query) {
|
|
865
|
-
return this.doTransition("replaceURL", name, params, query);
|
|
866
|
-
}
|
|
867
|
-
/**
|
|
868
|
-
* Create an href
|
|
869
|
-
* @param {String} name target route name
|
|
870
|
-
* @param {Object} [params]
|
|
871
|
-
* @param {Object} [query]
|
|
872
|
-
* @return {String} href
|
|
873
|
-
*
|
|
874
|
-
* @api public
|
|
875
|
-
*/
|
|
876
|
-
generate(name, params, query) {
|
|
877
|
-
let matcher;
|
|
878
|
-
query = query || {};
|
|
879
|
-
this.matchers.forEach((m) => {
|
|
880
|
-
if (m.name === name) {
|
|
881
|
-
matcher = m;
|
|
347
|
+
if (e2.push({ routes: t3, name: s2.name, path: o2 }), n2[o2] && "" !== s2.path) throw new Error(`Routes ${n2[o2]} and ${s2.name} have the same url path '${o2}'`);
|
|
348
|
+
n2[o2] = s2.name;
|
|
882
349
|
}
|
|
883
|
-
});
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
350
|
+
}), this;
|
|
351
|
+
}
|
|
352
|
+
listen(t2) {
|
|
353
|
+
const e2 = this.location;
|
|
354
|
+
return e2.start(t2), e2.onChange((t3) => {
|
|
355
|
+
const e3 = this.state.path;
|
|
356
|
+
this.dispatch(t3).catch((t4) => (t4 && t4.type === L && this.location.replaceURL(e3, { trigger: false }), t4));
|
|
357
|
+
}), this.dispatch(e2.getURL());
|
|
358
|
+
}
|
|
359
|
+
transitionTo(t2, e2, n2) {
|
|
360
|
+
return this.state.activeTransition ? this.replaceWith(t2, e2, n2) : this.doTransition("setURL", t2, e2, n2);
|
|
361
|
+
}
|
|
362
|
+
replaceWith(t2, e2, n2) {
|
|
363
|
+
return this.doTransition("replaceURL", t2, e2, n2);
|
|
364
|
+
}
|
|
365
|
+
generate(t2, e2, n2) {
|
|
366
|
+
let r2;
|
|
367
|
+
if (n2 = n2 || {}, this.matchers.forEach((e3) => {
|
|
368
|
+
e3.name === t2 && (r2 = e3);
|
|
369
|
+
}), !r2) throw new Error(`No route is named ${t2}`);
|
|
370
|
+
const o2 = (function(t3, e3, n3) {
|
|
371
|
+
const r3 = t3.stringify(n3, { indices: false });
|
|
372
|
+
return r3 ? g(e3) + "?" + r3 : e3;
|
|
373
|
+
})(this.options.qs, (function(t3, e3) {
|
|
374
|
+
return e3 = e3 || {}, t3.replace(u, function(n3, r3) {
|
|
375
|
+
const o3 = r3.replace(l, ""), s2 = r3.slice(-1);
|
|
376
|
+
if ("?" === s2 || "*" === s2) {
|
|
377
|
+
if (null == e3[o3]) return "";
|
|
378
|
+
} else a(null != e3[o3], "Missing '%s' parameter for path '%s'", o3, t3);
|
|
379
|
+
let i2 = encodeURIComponent(e3[o3]);
|
|
380
|
+
return "*" !== s2 && "+" !== s2 || (i2 = i2.replace("%2F", "/")), i2;
|
|
381
|
+
});
|
|
382
|
+
})(r2.path, e2), n2);
|
|
383
|
+
return this.location.formatURL(o2);
|
|
889
384
|
}
|
|
890
|
-
/**
|
|
891
|
-
* Stop listening to URL changes
|
|
892
|
-
* @api public
|
|
893
|
-
*/
|
|
894
385
|
destroy() {
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
}
|
|
898
|
-
if (this.state.activeTransition) {
|
|
899
|
-
this.state.activeTransition.cancel();
|
|
900
|
-
}
|
|
901
|
-
this.state = {};
|
|
902
|
-
this.middleware.forEach((m) => {
|
|
903
|
-
m.destroy && m.destroy(this);
|
|
386
|
+
this.location && this.location.destroy && this.location.destroy(), this.state.activeTransition && this.state.activeTransition.cancel(), this.state = {}, this.middleware.forEach((t2) => {
|
|
387
|
+
t2.destroy && t2.destroy(this);
|
|
904
388
|
});
|
|
905
389
|
}
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
return
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
if (
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
* Match the path against the routes
|
|
955
|
-
* @param {String} path
|
|
956
|
-
* @return {Object} the list of matching routes and params
|
|
957
|
-
*
|
|
958
|
-
* @api private
|
|
959
|
-
*/
|
|
960
|
-
match(path) {
|
|
961
|
-
path = (path || "").replace(/\/$/, "") || "/";
|
|
962
|
-
let params;
|
|
963
|
-
let routes = [];
|
|
964
|
-
const pathWithoutQuery = withoutQuery(path);
|
|
965
|
-
const { qs: qs2, patternCompiler: patternCompiler2 } = this.options;
|
|
966
|
-
this.matchers.some((matcher) => {
|
|
967
|
-
params = extractParams(matcher.path, pathWithoutQuery, patternCompiler2);
|
|
968
|
-
if (params) {
|
|
969
|
-
routes = matcher.routes;
|
|
970
|
-
return true;
|
|
971
|
-
}
|
|
972
|
-
});
|
|
973
|
-
return {
|
|
974
|
-
routes: routes.map(descriptor),
|
|
975
|
-
params: params || {},
|
|
976
|
-
pathname: pathWithoutQuery,
|
|
977
|
-
query: extractQuery(qs2, path) || {}
|
|
978
|
-
};
|
|
979
|
-
function descriptor(route) {
|
|
980
|
-
return {
|
|
981
|
-
name: route.name,
|
|
982
|
-
path: route.path,
|
|
983
|
-
params: pick(params, extractParamNames(route.path, patternCompiler2)),
|
|
984
|
-
options: clone(route.options)
|
|
985
|
-
};
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
/**
|
|
989
|
-
*
|
|
990
|
-
* @param {string} path
|
|
991
|
-
* @returns {Transition}
|
|
992
|
-
*/
|
|
993
|
-
dispatch(path) {
|
|
994
|
-
const match = this.match(path);
|
|
995
|
-
const query = match.query;
|
|
996
|
-
const pathname = match.pathname;
|
|
997
|
-
const activeTransition = this.state.activeTransition;
|
|
998
|
-
if (activeTransition && activeTransition.pathname === pathname && isEqual$1(activeTransition.query, query)) {
|
|
999
|
-
return activeTransition;
|
|
1000
|
-
}
|
|
1001
|
-
if (activeTransition) {
|
|
1002
|
-
const err = new Error(TRANSITION_REDIRECTED);
|
|
1003
|
-
err.type = TRANSITION_REDIRECTED;
|
|
1004
|
-
err.nextPath = path;
|
|
1005
|
-
activeTransition.cancel(err);
|
|
1006
|
-
}
|
|
1007
|
-
if (!activeTransition) {
|
|
1008
|
-
if (this.state.pathname === pathname && isEqual$1(this.state.query, query)) {
|
|
1009
|
-
return transition({
|
|
1010
|
-
id: this.nextId++,
|
|
1011
|
-
path,
|
|
1012
|
-
match,
|
|
1013
|
-
noop: true,
|
|
1014
|
-
router: this
|
|
1015
|
-
});
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
const t = transition({
|
|
1019
|
-
id: this.nextId++,
|
|
1020
|
-
path,
|
|
1021
|
-
match,
|
|
1022
|
-
router: this
|
|
1023
|
-
});
|
|
1024
|
-
this.state.activeTransition = t;
|
|
1025
|
-
return t;
|
|
1026
|
-
}
|
|
1027
|
-
log(...args) {
|
|
1028
|
-
console.info(...args);
|
|
1029
|
-
}
|
|
1030
|
-
logError(...args) {
|
|
1031
|
-
console.error(...args);
|
|
390
|
+
isActive(t2, e2, n2, o2) {
|
|
391
|
+
const s2 = this.state.routes || [], i2 = this.state.params, a2 = this.state.query;
|
|
392
|
+
let c2 = s2.some((e3) => e3.name === t2) && (!o2 || s2[s2.length - 1].name === t2);
|
|
393
|
+
return c2 = c2 && (!e2 || r(e2).every((t3) => i2[t3] === e2[t3])), c2 = c2 && (!n2 || r(n2).every((t3) => a2[t3] === n2[t3])), c2;
|
|
394
|
+
}
|
|
395
|
+
doTransition(t2, e2, n2, r2) {
|
|
396
|
+
const o2 = this.location.getURL();
|
|
397
|
+
let s2 = e2;
|
|
398
|
+
"/" !== s2[0] && (s2 = this.generate(e2, n2, r2), s2 = s2.replace(/^#/, "/")), this.options.pushState && (s2 = this.location.removeRoot(s2));
|
|
399
|
+
const i2 = this.dispatch(s2);
|
|
400
|
+
return i2.catch((t3) => (t3 && t3.type === L && this.location.replaceURL(o2, { trigger: false }), t3)), this.location[t2](s2, { trigger: false }), i2;
|
|
401
|
+
}
|
|
402
|
+
match(t2) {
|
|
403
|
+
let e2;
|
|
404
|
+
t2 = (t2 || "").replace(/\/$/, "") || "/";
|
|
405
|
+
let n2 = [];
|
|
406
|
+
const r2 = g(t2), { qs: s2, patternCompiler: i2 } = this.options;
|
|
407
|
+
return this.matchers.some((t3) => {
|
|
408
|
+
if (e2 = (function(t4, e3, n3) {
|
|
409
|
+
const r3 = m(t4, n3), o2 = r3.matcher, s3 = r3.paramNames, i3 = e3.match(o2);
|
|
410
|
+
if (!i3) return null;
|
|
411
|
+
const a2 = {};
|
|
412
|
+
return s3.forEach(function(t5, e4) {
|
|
413
|
+
a2[t5] = i3[e4 + 1] && decodeURIComponent(i3[e4 + 1]);
|
|
414
|
+
}), a2;
|
|
415
|
+
})(t3.path, r2, i2), e2) return n2 = t3.routes, true;
|
|
416
|
+
}), { routes: n2.map(function(t3) {
|
|
417
|
+
return { name: t3.name, path: t3.path, params: (n3 = e2, s3 = t3.path, a2 = i2, r3 = m(s3, a2).paramNames, r3.reduce((t4, e3) => void 0 === n3[e3] ? t4 : ((t5, e4, n4) => (t5[e4] = n4, t5))(t4, e3, n3[e3]), {})), options: o(t3.options) };
|
|
418
|
+
var n3, r3;
|
|
419
|
+
var s3, a2;
|
|
420
|
+
}), params: e2 || {}, pathname: r2, query: d(s2, t2) || {} };
|
|
421
|
+
}
|
|
422
|
+
dispatch(t2) {
|
|
423
|
+
const e2 = this.match(t2), n2 = e2.query, r2 = e2.pathname, o2 = this.state.activeTransition;
|
|
424
|
+
if (o2 && o2.pathname === r2 && s(o2.query, n2)) return o2;
|
|
425
|
+
if (o2) {
|
|
426
|
+
const e3 = new Error(k);
|
|
427
|
+
e3.type = k, e3.nextPath = t2, o2.cancel(e3);
|
|
428
|
+
}
|
|
429
|
+
if (!o2 && this.state.pathname === r2 && s(this.state.query, n2)) return j({ id: this.nextId++, path: t2, match: e2, noop: true, router: this });
|
|
430
|
+
const i2 = j({ id: this.nextId++, path: t2, match: e2, router: this });
|
|
431
|
+
return this.state.activeTransition = i2, i2;
|
|
432
|
+
}
|
|
433
|
+
log(...t2) {
|
|
434
|
+
console.info(...t2);
|
|
435
|
+
}
|
|
436
|
+
logError(...t2) {
|
|
437
|
+
console.error(...t2);
|
|
1032
438
|
}
|
|
1033
439
|
};
|
|
1034
|
-
function
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
function
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
}
|
|
1073
|
-
function destroy() {
|
|
1074
|
-
router = null;
|
|
1075
|
-
routeElMap = /* @__PURE__ */ Object.create(null);
|
|
1076
|
-
routeComponentMap = /* @__PURE__ */ Object.create(null);
|
|
1077
|
-
routePropertiesMap = /* @__PURE__ */ Object.create(null);
|
|
1078
|
-
rootOutletEl = null;
|
|
1079
|
-
}
|
|
1080
|
-
function isEqual(obj1, obj2) {
|
|
1081
|
-
const keys1 = Object.keys(obj1);
|
|
1082
|
-
return keys1.length === Object.keys(obj2).length && keys1.every((key) => obj2[key] === obj1[key]);
|
|
1083
|
-
}
|
|
1084
|
-
function getOutlet(el) {
|
|
1085
|
-
const renderRoot = el.shadowRoot || el;
|
|
1086
|
-
return renderRoot.querySelector(el.constructor.outlet || "router-outlet");
|
|
1087
|
-
}
|
|
1088
|
-
function resolveRootOutlet() {
|
|
1089
|
-
if (rootOutletEl) return rootOutletEl;
|
|
1090
|
-
if (!rootOutlet) return document.body;
|
|
1091
|
-
rootOutletEl = typeof rootOutlet === "string" ? document.querySelector(rootOutlet) : rootOutlet;
|
|
1092
|
-
if (!rootOutletEl) {
|
|
1093
|
-
throw new Error(`slick-router(wc): Invalid outlet option ${rootOutlet}`);
|
|
1094
|
-
}
|
|
1095
|
-
return rootOutletEl;
|
|
1096
|
-
}
|
|
1097
|
-
function getParentEl(transition2, parentIndex) {
|
|
1098
|
-
let parent = transition2.routes[parentIndex];
|
|
1099
|
-
while (parent) {
|
|
1100
|
-
if (parent.options.component) {
|
|
1101
|
-
return routeElMap[parent.name];
|
|
1102
|
-
}
|
|
1103
|
-
parent = transition2.routes[--parentIndex];
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
function getChangingIndex(prevRoutes, currentRoutes) {
|
|
1107
|
-
let index, prev, current;
|
|
1108
|
-
const count = Math.max(prevRoutes.length, currentRoutes.length);
|
|
1109
|
-
for (index = 0; index < count; index++) {
|
|
1110
|
-
prev = prevRoutes[index];
|
|
1111
|
-
current = currentRoutes[index];
|
|
1112
|
-
if (!(prev && current) || prev.name !== current.name || !isEqual(prev.params, current.params)) {
|
|
1113
|
-
break;
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
return index;
|
|
1117
|
-
}
|
|
1118
|
-
function runPropertyHookMethod(transition2, routes, method) {
|
|
1119
|
-
for (let i = 0; i < routes.length; i++) {
|
|
1120
|
-
const { route } = routes[i];
|
|
1121
|
-
const propertiesData = routePropertiesMap[route.name];
|
|
1122
|
-
for (const { hooks, set } of Object.values(propertiesData)) {
|
|
1123
|
-
hooks.forEach((hook) => {
|
|
1124
|
-
if (typeof hook[method] === "function") {
|
|
1125
|
-
hook[method](transition2, set);
|
|
1126
|
-
}
|
|
1127
|
-
});
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
async function runLifeCycle(transition2, routes, prefix, suffix) {
|
|
1132
|
-
for (let i = 0; i < routes.length; i++) {
|
|
1133
|
-
let result;
|
|
1134
|
-
const { route, el } = routes[i];
|
|
1135
|
-
const routeMethod = route.options[`${prefix}${suffix}`];
|
|
1136
|
-
if (typeof routeMethod === "function") {
|
|
1137
|
-
result = await routeMethod(transition2);
|
|
1138
|
-
if (result === false) {
|
|
1139
|
-
transition2.cancel();
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
if (transition2.isCancelled) break;
|
|
1143
|
-
const elMethod = el && el[`${prefix}Route${suffix}`];
|
|
1144
|
-
if (typeof elMethod === "function") {
|
|
1145
|
-
result = await elMethod.call(el, transition2);
|
|
1146
|
-
if (result === false) {
|
|
1147
|
-
transition2.cancel();
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
if (transition2.isCancelled) break;
|
|
440
|
+
function _(t2, e2, n2) {
|
|
441
|
+
t2.preventDefault(), n2.transitionTo(n2.location.removeRoot(e2.getAttribute("href")));
|
|
442
|
+
}
|
|
443
|
+
const I = Promise.resolve();
|
|
444
|
+
let F, H, D, M = /* @__PURE__ */ Object.create(null), N = /* @__PURE__ */ Object.create(null), W = /* @__PURE__ */ Object.create(null);
|
|
445
|
+
function z(t2, e2) {
|
|
446
|
+
let n2 = t2;
|
|
447
|
+
return void 0 !== n2 && ("number" === e2 ? n2 = (function(t3) {
|
|
448
|
+
const e3 = parseFloat(t3);
|
|
449
|
+
return t3 == e3 ? e3 : t3;
|
|
450
|
+
})(t2) : "function" == typeof e2 && (n2 = e2(t2))), n2;
|
|
451
|
+
}
|
|
452
|
+
function K(t2, e2) {
|
|
453
|
+
const n2 = Object.keys(t2);
|
|
454
|
+
return n2.length === Object.keys(e2).length && n2.every((n3) => e2[n3] === t2[n3]);
|
|
455
|
+
}
|
|
456
|
+
function B(t2) {
|
|
457
|
+
return (t2.shadowRoot || t2).querySelector(t2.constructor.outlet || "router-outlet");
|
|
458
|
+
}
|
|
459
|
+
function Z() {
|
|
460
|
+
if (D) return D;
|
|
461
|
+
if (!H) return document.body;
|
|
462
|
+
if (D = "string" == typeof H ? document.querySelector(H) : H, !D) throw new Error(`slick-router(wc): Invalid outlet option ${H}`);
|
|
463
|
+
return D;
|
|
464
|
+
}
|
|
465
|
+
function J(t2, e2) {
|
|
466
|
+
let n2 = t2.routes[e2];
|
|
467
|
+
for (; n2; ) {
|
|
468
|
+
if (n2.options.component) return M[n2.name];
|
|
469
|
+
n2 = t2.routes[--e2];
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
function V(t2, e2, n2) {
|
|
473
|
+
for (let r2 = 0; r2 < e2.length; r2++) {
|
|
474
|
+
const { route: o2 } = e2[r2], s2 = W[o2.name];
|
|
475
|
+
for (const { hooks: e3, set: r3 } of Object.values(s2)) e3.forEach((e4) => {
|
|
476
|
+
"function" == typeof e4[n2] && e4[n2](t2, r3);
|
|
477
|
+
});
|
|
1151
478
|
}
|
|
1152
479
|
}
|
|
1153
|
-
function
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
if (typeof hook.init === "function") {
|
|
1186
|
-
hook.init(set);
|
|
1187
|
-
}
|
|
480
|
+
async function G(t2, e2, n2, r2) {
|
|
481
|
+
for (let o2 = 0; o2 < e2.length; o2++) {
|
|
482
|
+
let s2;
|
|
483
|
+
const { route: i2, el: a2 } = e2[o2], c2 = i2.options[`${n2}${r2}`];
|
|
484
|
+
if ("function" == typeof c2 && (s2 = await c2(t2), false === s2 && t2.cancel()), t2.isCancelled) break;
|
|
485
|
+
const h2 = a2 && a2[`${n2}Route${r2}`];
|
|
486
|
+
if ("function" == typeof h2 && (s2 = await h2.call(a2, t2), false === s2 && t2.cancel()), t2.isCancelled) break;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
function Q(t2) {
|
|
490
|
+
return t2 && t2.__esModule ? t2.default : t2;
|
|
491
|
+
}
|
|
492
|
+
function X(t2) {
|
|
493
|
+
return t2 && "object" == typeof t2 ? t2 : /* @__PURE__ */ (function(t3) {
|
|
494
|
+
return { init(e2) {
|
|
495
|
+
e2(t3);
|
|
496
|
+
} };
|
|
497
|
+
})(t2);
|
|
498
|
+
}
|
|
499
|
+
function Y(t2) {
|
|
500
|
+
let e2 = W[t2.name];
|
|
501
|
+
if (!e2) {
|
|
502
|
+
e2 = W[t2.name] = /* @__PURE__ */ Object.create(null);
|
|
503
|
+
const n2 = t2.options.properties;
|
|
504
|
+
if (n2) for (const [r2, o2] of Object.entries(n2)) {
|
|
505
|
+
const n3 = Array.isArray(o2) ? o2.map(X) : [X(o2)], s2 = (o3, s3) => {
|
|
506
|
+
const i2 = e2[r2], a2 = z(o3, s3);
|
|
507
|
+
if (i2.value === a2) return;
|
|
508
|
+
i2.value = a2;
|
|
509
|
+
const c2 = M[t2.name];
|
|
510
|
+
c2 && (c2[r2] = a2), n3.forEach((t3) => {
|
|
511
|
+
"function" == typeof t3.update && t3.update(a2, c2);
|
|
1188
512
|
});
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
}
|
|
1193
|
-
async function resolveRoutes(routes) {
|
|
1194
|
-
const result = [];
|
|
1195
|
-
for (const route of routes) {
|
|
1196
|
-
let el = route.options.reuse ? routeElMap[route.name] : void 0;
|
|
1197
|
-
let Component = route.options.component;
|
|
1198
|
-
if (!el && Component) {
|
|
1199
|
-
if (typeof Component === "function" && !(Component.prototype instanceof HTMLElement)) {
|
|
1200
|
-
Component = routeComponentMap[route.name] || (routeComponentMap[route.name] = resolveModule(await Component(route)));
|
|
1201
|
-
}
|
|
1202
|
-
el = typeof Component === "string" ? document.createElement(Component) : new Component();
|
|
1203
|
-
routeElMap[route.name] = el;
|
|
1204
|
-
el.$router = router;
|
|
513
|
+
};
|
|
514
|
+
e2[r2] = { hooks: n3, set: s2 }, n3.forEach((t3) => {
|
|
515
|
+
"function" == typeof t3.init && t3.init(s2);
|
|
516
|
+
});
|
|
1205
517
|
}
|
|
1206
|
-
initProperties(route);
|
|
1207
|
-
result.push({ el, route });
|
|
1208
518
|
}
|
|
1209
|
-
return result;
|
|
1210
519
|
}
|
|
1211
|
-
function
|
|
1212
|
-
const
|
|
1213
|
-
Object.entries(
|
|
1214
|
-
|
|
520
|
+
function tt(t2, e2) {
|
|
521
|
+
const n2 = W[e2.name];
|
|
522
|
+
Object.entries(n2).forEach(([e3, { value: n3 }]) => {
|
|
523
|
+
t2[e3] = n3;
|
|
1215
524
|
});
|
|
1216
525
|
}
|
|
1217
|
-
const
|
|
1218
|
-
const
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
526
|
+
const et = /* @__PURE__ */ new WeakSet(), nt = /* @__PURE__ */ new WeakMap();
|
|
527
|
+
const rt = { create: function(t2) {
|
|
528
|
+
F = t2, H = t2.options.outlet;
|
|
529
|
+
}, destroy: function() {
|
|
530
|
+
F = null, M = /* @__PURE__ */ Object.create(null), N = /* @__PURE__ */ Object.create(null), W = /* @__PURE__ */ Object.create(null), D = null;
|
|
531
|
+
}, resolve: async function(t2) {
|
|
532
|
+
const e2 = t2.prev.routes, n2 = (function(t3, e3) {
|
|
533
|
+
let n3, r3, o3;
|
|
534
|
+
const s2 = Math.max(t3.length, e3.length);
|
|
535
|
+
for (n3 = 0; n3 < s2 && (r3 = t3[n3], o3 = e3[n3], r3 && o3 && r3.name === o3.name && K(r3.params, o3.params)); n3++) ;
|
|
536
|
+
return n3;
|
|
537
|
+
})(e2, t2.routes), r2 = [];
|
|
538
|
+
for (let t3 = e2.length - 1; t3 >= n2; t3--) {
|
|
539
|
+
const n3 = e2[t3];
|
|
540
|
+
r2.push({ el: M[n3.name], route: n3 });
|
|
541
|
+
}
|
|
542
|
+
if (await G(t2, r2, "before", "Leave"), t2.isCancelled) return;
|
|
543
|
+
const o2 = await (async function(t3) {
|
|
544
|
+
const e3 = [];
|
|
545
|
+
for (const n3 of t3) {
|
|
546
|
+
let t4 = n3.options.reuse ? M[n3.name] : void 0, r3 = n3.options.component;
|
|
547
|
+
!t4 && r3 && ("function" != typeof r3 || r3.prototype instanceof HTMLElement || (r3 = N[n3.name] || (N[n3.name] = Q(await r3(n3)))), t4 = "string" == typeof r3 ? document.createElement(r3) : new r3(), M[n3.name] = t4, t4.$router = F), Y(n3), e3.push({ el: t4, route: n3 });
|
|
548
|
+
}
|
|
549
|
+
return e3;
|
|
550
|
+
})(t2.routes.slice(n2));
|
|
551
|
+
await G(t2, o2, "before", "Enter"), t2.isCancelled || (V(t2, o2, "enter"), await (async function(t3, e3, n3) {
|
|
552
|
+
const { path: r3, pathname: o3, routes: s2, params: i2, query: a2 } = t3, c2 = { path: r3, pathname: o3, routes: s2, params: i2, query: a2 };
|
|
553
|
+
for (let e4 = 0; e4 < n3; e4++) {
|
|
554
|
+
const n4 = t3.routes[e4], r4 = M[n4.name];
|
|
555
|
+
r4 && (r4.$route = c2, tt(r4, n4));
|
|
556
|
+
}
|
|
557
|
+
for (let r4 = 0; r4 < e3.length; r4++) {
|
|
558
|
+
const { el: o4, route: s3 } = e3[r4];
|
|
559
|
+
if (o4) {
|
|
560
|
+
const e4 = J(t3, n3 + r4 - 1), i3 = e4 ? B(e4) : Z();
|
|
561
|
+
if (i3) {
|
|
562
|
+
const t4 = nt.get(i3) || i3.firstElementChild;
|
|
563
|
+
t4 && (i3.removeChild(t4), et.add(t4)), o4.$route = c2, tt(o4, s3), i3.appendChild(o4), nt.set(i3, o4), await (o4.updateComplete || I);
|
|
1240
564
|
}
|
|
1241
|
-
el.$route = routeState;
|
|
1242
|
-
applyProperties(el, route);
|
|
1243
|
-
outletEl.appendChild(el);
|
|
1244
|
-
outletCurrentEl.set(outletEl, el);
|
|
1245
|
-
await (el.updateComplete || resolved);
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
function updateDOMTree(activated, deactivated) {
|
|
1251
|
-
let parentElRemoved;
|
|
1252
|
-
for (let routeIndex = deactivated.length - 1; routeIndex >= 0; routeIndex--) {
|
|
1253
|
-
const { route, el } = deactivated[routeIndex];
|
|
1254
|
-
if (!activated.some(({ route: activeRoute }) => activeRoute.name === route.name)) {
|
|
1255
|
-
if (el) {
|
|
1256
|
-
if (!parentElRemoved && !removedEls.has(el)) el.remove();
|
|
1257
|
-
parentElRemoved = true;
|
|
1258
565
|
}
|
|
1259
|
-
routeElMap[route.name] = void 0;
|
|
1260
566
|
}
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
function
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
};
|
|
1293
|
-
class Router2 extends Router$1 {
|
|
1294
|
-
constructor(options) {
|
|
1295
|
-
super(options);
|
|
1296
|
-
this.use(wc);
|
|
1297
|
-
this.use(routerLinks);
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
let eventPrefix;
|
|
1301
|
-
function trigger(name, detail) {
|
|
1302
|
-
window.dispatchEvent(new CustomEvent(`${eventPrefix}${name}`, { detail }));
|
|
1303
|
-
}
|
|
1304
|
-
const events = {
|
|
1305
|
-
create: function(router2) {
|
|
1306
|
-
eventPrefix = router2.options.eventPrefix || "router-";
|
|
1307
|
-
},
|
|
1308
|
-
before: function(transition2) {
|
|
1309
|
-
trigger("before:transition", { transition: transition2 });
|
|
1310
|
-
},
|
|
1311
|
-
done: function(transition2) {
|
|
1312
|
-
trigger("transition", { transition: transition2 });
|
|
1313
|
-
},
|
|
1314
|
-
cancel: function(transition2, error) {
|
|
1315
|
-
if (error.type !== "TransitionRedirected") {
|
|
1316
|
-
trigger("abort", { transition: transition2, error });
|
|
1317
|
-
}
|
|
1318
|
-
},
|
|
1319
|
-
error: function(transition2, error) {
|
|
1320
|
-
trigger("abort", { transition: transition2, error });
|
|
1321
|
-
trigger("error", { transition: transition2, error });
|
|
1322
|
-
}
|
|
1323
|
-
};
|
|
1324
|
-
class Routerx extends WJElement {
|
|
1325
|
-
/**
|
|
1326
|
-
* Creates an instance of Routerx.
|
|
1327
|
-
* @class
|
|
1328
|
-
*/
|
|
567
|
+
})(t2, o2, n2), (function(t3, e3) {
|
|
568
|
+
let n3;
|
|
569
|
+
for (let r3 = e3.length - 1; r3 >= 0; r3--) {
|
|
570
|
+
const { route: o3, el: s2 } = e3[r3];
|
|
571
|
+
t3.some(({ route: t4 }) => t4.name === o3.name) || (s2 && (n3 || et.has(s2) || s2.remove(), n3 = true), M[o3.name] = void 0);
|
|
572
|
+
}
|
|
573
|
+
})(o2, r2), t2.activated = o2, t2.deactivated = r2);
|
|
574
|
+
}, done: function(t2) {
|
|
575
|
+
V(t2, t2.deactivated, "leave"), G(t2, t2.deactivated, "after", "Leave"), G(t2, t2.activated, "after", "Enter");
|
|
576
|
+
} };
|
|
577
|
+
class ot extends A {
|
|
578
|
+
constructor(e2) {
|
|
579
|
+
super(e2), this.use(rt), this.use(t);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
let st;
|
|
583
|
+
function it(t2, e2) {
|
|
584
|
+
window.dispatchEvent(new CustomEvent(`${st}${t2}`, { detail: e2 }));
|
|
585
|
+
}
|
|
586
|
+
const at = { create: function(t2) {
|
|
587
|
+
st = t2.options.eventPrefix || "router-";
|
|
588
|
+
}, before: function(t2) {
|
|
589
|
+
it("before:transition", { transition: t2 });
|
|
590
|
+
}, done: function(t2) {
|
|
591
|
+
it("transition", { transition: t2 });
|
|
592
|
+
}, cancel: function(t2, e2) {
|
|
593
|
+
"TransitionRedirected" !== e2.type && it("abort", { transition: t2, error: e2 });
|
|
594
|
+
}, error: function(t2, e2) {
|
|
595
|
+
it("abort", { transition: t2, error: e2 }), it("error", { transition: t2, error: e2 });
|
|
596
|
+
} };
|
|
597
|
+
class ct extends e {
|
|
1329
598
|
constructor() {
|
|
1330
599
|
super();
|
|
1331
|
-
__privateAdd(this,
|
|
600
|
+
__privateAdd(this, _t);
|
|
1332
601
|
__publicField(this, "className", "Routerx");
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
...transition2.routes.filter((obj) => "breadcrumb" in obj.options).map((b, i) => {
|
|
1340
|
-
var _a, _b;
|
|
1341
|
-
return {
|
|
1342
|
-
name: b.options.breadcrumbPath || b.name,
|
|
1343
|
-
text: b.options.breadcrumb instanceof Function ? (_b = (_a = b.options).breadcrumb) == null ? void 0 : _b.call(_a, transition2) : b.options.breadcrumb,
|
|
1344
|
-
params: { ...b.params, ...transition2.params },
|
|
1345
|
-
path: this.router.generate(b.name, { ...b.params, ...transition2.params })
|
|
1346
|
-
};
|
|
1347
|
-
})
|
|
1348
|
-
];
|
|
1349
|
-
transition2.breadcrumbs = breadcrumb;
|
|
602
|
+
__publicField(this, "setBreadcrumb", (t2) => {
|
|
603
|
+
let e2 = [...t2.routes.filter((t3) => "breadcrumb" in t3.options).map((e3, n2) => {
|
|
604
|
+
var _a, _b;
|
|
605
|
+
return { name: e3.options.breadcrumbPath || e3.name, text: e3.options.breadcrumb instanceof Function ? (_b = (_a = e3.options).breadcrumb) == null ? void 0 : _b.call(_a, t2) : e3.options.breadcrumb, params: { ...e3.params, ...t2.params }, path: this.router.generate(e3.name, { ...e3.params, ...t2.params }) };
|
|
606
|
+
})];
|
|
607
|
+
t2.breadcrumbs = e2;
|
|
1350
608
|
});
|
|
1351
|
-
|
|
1352
|
-
* Resets the scroll position.
|
|
1353
|
-
* @param {object} transition The transition object.
|
|
1354
|
-
*/
|
|
1355
|
-
__publicField(this, "resetScrollPosition", (transition2) => {
|
|
609
|
+
__publicField(this, "resetScrollPosition", (t2) => {
|
|
1356
610
|
window.scrollTo(0, 0);
|
|
1357
611
|
});
|
|
1358
612
|
}
|
|
1359
|
-
set routes(
|
|
1360
|
-
__privateSet(this,
|
|
613
|
+
set routes(t2) {
|
|
614
|
+
__privateSet(this, _t, t2);
|
|
1361
615
|
}
|
|
1362
616
|
get routes() {
|
|
1363
617
|
return this.parseElement(this.rootElement).root;
|
|
1364
618
|
}
|
|
1365
619
|
get rootElement() {
|
|
1366
|
-
const
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
return htmlDocument.querySelector("wje-router");
|
|
1370
|
-
}
|
|
1371
|
-
/**
|
|
1372
|
-
* Returns the list of attributes to observe for changes.
|
|
1373
|
-
* @static
|
|
1374
|
-
* @returns {Array<string>}
|
|
1375
|
-
*/
|
|
620
|
+
const t2 = this.outerHTML;
|
|
621
|
+
return new DOMParser().parseFromString(t2, "text/html").querySelector("wje-router");
|
|
622
|
+
}
|
|
1376
623
|
static get observedAttributes() {
|
|
1377
624
|
return [];
|
|
1378
625
|
}
|
|
1379
|
-
/**
|
|
1380
|
-
* Sets up the attributes for the component.
|
|
1381
|
-
*/
|
|
1382
626
|
setupAttributes() {
|
|
1383
627
|
this.isShadowRoot = "open";
|
|
1384
628
|
}
|
|
1385
|
-
/**
|
|
1386
|
-
* Sets up the router after the component is drawn.
|
|
1387
|
-
*/
|
|
1388
629
|
beforeDraw() {
|
|
1389
|
-
this.router = new
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
this.router.listen();
|
|
1401
|
-
this.unbindIntercept = interceptLinks(this.router);
|
|
1402
|
-
}
|
|
1403
|
-
/**
|
|
1404
|
-
* Parses an element and returns an object representation.
|
|
1405
|
-
* @param {Element} element The element to parse.
|
|
1406
|
-
* @returns {object} The object representation of the element.
|
|
1407
|
-
*/
|
|
1408
|
-
parseElement(element) {
|
|
1409
|
-
const obj = {};
|
|
1410
|
-
const attributes = element.attributes;
|
|
1411
|
-
for (let i = 0; i < attributes.length; i++) {
|
|
1412
|
-
const attributeName = attributes[i].name;
|
|
1413
|
-
const attributeValue = attributes[i].value;
|
|
1414
|
-
if (attributeName === "component" && attributeValue.indexOf(".js") > -1) {
|
|
1415
|
-
obj.component = () => import(
|
|
1416
|
-
/* @vite-ignore */
|
|
1417
|
-
attributeValue
|
|
1418
|
-
);
|
|
1419
|
-
} else {
|
|
1420
|
-
if (attributeName !== "shadow") {
|
|
1421
|
-
const camelCase = attributeName.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
1422
|
-
obj[camelCase] = attributeValue;
|
|
1423
|
-
}
|
|
630
|
+
this.router = new ot({ outlet: this.outlet || "wje-router-outlet", log: false, logError: false, root: this.root || "/", pushState: true }), this.router.map(this.routes), this.router.use(this.setBreadcrumb), this.router.use(at), this.router.use(this.resetScrollPosition), this.router.listen(), this.unbindIntercept = (function(t2, e2 = document, n2 = _) {
|
|
631
|
+
return S(e2, (e3, r2) => n2(e3, r2, t2));
|
|
632
|
+
})(this.router);
|
|
633
|
+
}
|
|
634
|
+
parseElement(t2) {
|
|
635
|
+
const e2 = {}, n2 = t2.attributes;
|
|
636
|
+
for (let t3 = 0; t3 < n2.length; t3++) {
|
|
637
|
+
const r3 = n2[t3].name, o2 = n2[t3].value;
|
|
638
|
+
if ("component" === r3 && o2.indexOf(".js") > -1) e2.component = () => import(o2);
|
|
639
|
+
else if ("shadow" !== r3) {
|
|
640
|
+
e2[r3.replace(/-([a-z])/g, (t4) => t4[1].toUpperCase())] = o2;
|
|
1424
641
|
}
|
|
1425
642
|
}
|
|
1426
|
-
const
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
});
|
|
1431
|
-
if (children.length > 0 && element.tagName === "WJE-ROUTE") {
|
|
1432
|
-
obj.children = children;
|
|
1433
|
-
} else {
|
|
1434
|
-
obj.root = children;
|
|
1435
|
-
}
|
|
1436
|
-
return obj;
|
|
643
|
+
const r2 = [];
|
|
644
|
+
return Array.from(t2.children).forEach((t3) => {
|
|
645
|
+
r2.push(this.parseElement(t3));
|
|
646
|
+
}), r2.length > 0 && "WJE-ROUTE" === t2.tagName ? e2.children = r2 : e2.root = r2, e2;
|
|
1437
647
|
}
|
|
1438
|
-
/**
|
|
1439
|
-
* Cleans up before the component is disconnected.
|
|
1440
|
-
*/
|
|
1441
648
|
beforeDisconnect() {
|
|
1442
|
-
this.unbindIntercept();
|
|
1443
|
-
this.router.destroy();
|
|
649
|
+
this.unbindIntercept(), this.router.destroy();
|
|
1444
650
|
}
|
|
1445
651
|
}
|
|
1446
|
-
|
|
1447
|
-
|
|
652
|
+
_t = new WeakMap();
|
|
653
|
+
ct.define("wje-router", ct);
|
|
1448
654
|
export {
|
|
1449
|
-
|
|
655
|
+
ct as default
|
|
1450
656
|
};
|
|
1451
657
|
//# sourceMappingURL=wje-routerx.js.map
|