@dotvoid/stacked-router 1.0.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/README.md +594 -0
- package/dist/components/DefaultLayout.d.ts +4 -0
- package/dist/components/DefaultLayout.d.ts.map +1 -0
- package/dist/components/ErrorBoundary.d.ts +22 -0
- package/dist/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/components/ErrorResolver.d.ts +9 -0
- package/dist/components/ErrorResolver.d.ts.map +1 -0
- package/dist/components/Link.d.ts +29 -0
- package/dist/components/Link.d.ts.map +1 -0
- package/dist/components/Slots.d.ts +14 -0
- package/dist/components/Slots.d.ts.map +1 -0
- package/dist/components/StackedView.d.ts +6 -0
- package/dist/components/StackedView.d.ts.map +1 -0
- package/dist/components/StackedViewGroup.d.ts +6 -0
- package/dist/components/StackedViewGroup.d.ts.map +1 -0
- package/dist/components/VoidViews.d.ts +6 -0
- package/dist/components/VoidViews.d.ts.map +1 -0
- package/dist/contexts/RouterContext.d.ts +27 -0
- package/dist/contexts/RouterContext.d.ts.map +1 -0
- package/dist/contexts/RouterProvider.d.ts +11 -0
- package/dist/contexts/RouterProvider.d.ts.map +1 -0
- package/dist/contexts/SlotContext.d.ts +6 -0
- package/dist/contexts/SlotContext.d.ts.map +1 -0
- package/dist/contexts/SlotProvider.d.ts +4 -0
- package/dist/contexts/SlotProvider.d.ts.map +1 -0
- package/dist/contexts/ViewContext.d.ts +17 -0
- package/dist/contexts/ViewContext.d.ts.map +1 -0
- package/dist/contexts/ViewProvider.d.ts +10 -0
- package/dist/contexts/ViewProvider.d.ts.map +1 -0
- package/dist/hooks/useHref.d.ts +14 -0
- package/dist/hooks/useHref.d.ts.map +1 -0
- package/dist/hooks/useNavigate.d.ts +19 -0
- package/dist/hooks/useNavigate.d.ts.map +1 -0
- package/dist/hooks/useOpenViews.d.ts +25 -0
- package/dist/hooks/useOpenViews.d.ts.map +1 -0
- package/dist/hooks/usePrevious.d.ts +2 -0
- package/dist/hooks/usePrevious.d.ts.map +1 -0
- package/dist/hooks/useRouter.d.ts +2 -0
- package/dist/hooks/useRouter.d.ts.map +1 -0
- package/dist/hooks/useView.d.ts +2 -0
- package/dist/hooks/useView.d.ts.map +1 -0
- package/dist/hooks/useViewStack.d.ts +18 -0
- package/dist/hooks/useViewStack.d.ts.map +1 -0
- package/dist/index.es.js +1112 -0
- package/dist/index.umd.js +22 -0
- package/dist/lib/RouterRegistry.d.ts +57 -0
- package/dist/lib/RouterRegistry.d.ts.map +1 -0
- package/dist/lib/allocation.d.ts +23 -0
- package/dist/lib/allocation.d.ts.map +1 -0
- package/dist/lib/events.d.ts +4 -0
- package/dist/lib/events.d.ts.map +1 -0
- package/dist/lib/history.d.ts +34 -0
- package/dist/lib/history.d.ts.map +1 -0
- package/dist/lib/href.d.ts +23 -0
- package/dist/lib/href.d.ts.map +1 -0
- package/dist/lib/mapRoutes.d.ts +6 -0
- package/dist/lib/mapRoutes.d.ts.map +1 -0
- package/dist/lib/viewsAreEqual.d.ts +8 -0
- package/dist/lib/viewsAreEqual.d.ts.map +1 -0
- package/dist/main.d.ts +13 -0
- package/dist/main.d.ts.map +1 -0
- package/package.json +63 -0
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,1112 @@
|
|
|
1
|
+
import Oe, { createContext as X, useMemo as j, useState as C, useEffect as P, useContext as I, useRef as le, useCallback as ae, Component as Ve } from "react";
|
|
2
|
+
var W = { exports: {} }, V = {};
|
|
3
|
+
/**
|
|
4
|
+
* @license React
|
|
5
|
+
* react-jsx-runtime.production.js
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the MIT license found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/
|
|
12
|
+
var ie;
|
|
13
|
+
function Ae() {
|
|
14
|
+
if (ie) return V;
|
|
15
|
+
ie = 1;
|
|
16
|
+
var t = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
17
|
+
function n(r, o, s) {
|
|
18
|
+
var i = null;
|
|
19
|
+
if (s !== void 0 && (i = "" + s), o.key !== void 0 && (i = "" + o.key), "key" in o) {
|
|
20
|
+
s = {};
|
|
21
|
+
for (var c in o)
|
|
22
|
+
c !== "key" && (s[c] = o[c]);
|
|
23
|
+
} else s = o;
|
|
24
|
+
return o = s.ref, {
|
|
25
|
+
$$typeof: t,
|
|
26
|
+
type: r,
|
|
27
|
+
key: i,
|
|
28
|
+
ref: o !== void 0 ? o : null,
|
|
29
|
+
props: s
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return V.Fragment = e, V.jsx = n, V.jsxs = n, V;
|
|
33
|
+
}
|
|
34
|
+
var A = {};
|
|
35
|
+
/**
|
|
36
|
+
* @license React
|
|
37
|
+
* react-jsx-runtime.development.js
|
|
38
|
+
*
|
|
39
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
40
|
+
*
|
|
41
|
+
* This source code is licensed under the MIT license found in the
|
|
42
|
+
* LICENSE file in the root directory of this source tree.
|
|
43
|
+
*/
|
|
44
|
+
var ce;
|
|
45
|
+
function Ce() {
|
|
46
|
+
return ce || (ce = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
47
|
+
function t(a) {
|
|
48
|
+
if (a == null) return null;
|
|
49
|
+
if (typeof a == "function")
|
|
50
|
+
return a.$$typeof === _e ? null : a.displayName || a.name || null;
|
|
51
|
+
if (typeof a == "string") return a;
|
|
52
|
+
switch (a) {
|
|
53
|
+
case y:
|
|
54
|
+
return "Fragment";
|
|
55
|
+
case S:
|
|
56
|
+
return "Profiler";
|
|
57
|
+
case v:
|
|
58
|
+
return "StrictMode";
|
|
59
|
+
case be:
|
|
60
|
+
return "Suspense";
|
|
61
|
+
case Se:
|
|
62
|
+
return "SuspenseList";
|
|
63
|
+
case Pe:
|
|
64
|
+
return "Activity";
|
|
65
|
+
}
|
|
66
|
+
if (typeof a == "object")
|
|
67
|
+
switch (typeof a.tag == "number" && console.error(
|
|
68
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
|
+
), a.$$typeof) {
|
|
70
|
+
case x:
|
|
71
|
+
return "Portal";
|
|
72
|
+
case Ee:
|
|
73
|
+
return (a.displayName || "Context") + ".Provider";
|
|
74
|
+
case N:
|
|
75
|
+
return (a._context.displayName || "Context") + ".Consumer";
|
|
76
|
+
case Re:
|
|
77
|
+
var d = a.render;
|
|
78
|
+
return a = a.displayName, a || (a = d.displayName || d.name || "", a = a !== "" ? "ForwardRef(" + a + ")" : "ForwardRef"), a;
|
|
79
|
+
case ke:
|
|
80
|
+
return d = a.displayName || null, d !== null ? d : t(a.type) || "Memo";
|
|
81
|
+
case Z:
|
|
82
|
+
d = a._payload, a = a._init;
|
|
83
|
+
try {
|
|
84
|
+
return t(a(d));
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
function e(a) {
|
|
91
|
+
return "" + a;
|
|
92
|
+
}
|
|
93
|
+
function n(a) {
|
|
94
|
+
try {
|
|
95
|
+
e(a);
|
|
96
|
+
var d = !1;
|
|
97
|
+
} catch {
|
|
98
|
+
d = !0;
|
|
99
|
+
}
|
|
100
|
+
if (d) {
|
|
101
|
+
d = console;
|
|
102
|
+
var m = d.error, E = typeof Symbol == "function" && Symbol.toStringTag && a[Symbol.toStringTag] || a.constructor.name || "Object";
|
|
103
|
+
return m.call(
|
|
104
|
+
d,
|
|
105
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
|
+
E
|
|
107
|
+
), e(a);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function r(a) {
|
|
111
|
+
if (a === y) return "<>";
|
|
112
|
+
if (typeof a == "object" && a !== null && a.$$typeof === Z)
|
|
113
|
+
return "<...>";
|
|
114
|
+
try {
|
|
115
|
+
var d = t(a);
|
|
116
|
+
return d ? "<" + d + ">" : "<...>";
|
|
117
|
+
} catch {
|
|
118
|
+
return "<...>";
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function o() {
|
|
122
|
+
var a = D.A;
|
|
123
|
+
return a === null ? null : a.getOwner();
|
|
124
|
+
}
|
|
125
|
+
function s() {
|
|
126
|
+
return Error("react-stack-top-frame");
|
|
127
|
+
}
|
|
128
|
+
function i(a) {
|
|
129
|
+
if (ee.call(a, "key")) {
|
|
130
|
+
var d = Object.getOwnPropertyDescriptor(a, "key").get;
|
|
131
|
+
if (d && d.isReactWarning) return !1;
|
|
132
|
+
}
|
|
133
|
+
return a.key !== void 0;
|
|
134
|
+
}
|
|
135
|
+
function c(a, d) {
|
|
136
|
+
function m() {
|
|
137
|
+
te || (te = !0, console.error(
|
|
138
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
139
|
+
d
|
|
140
|
+
));
|
|
141
|
+
}
|
|
142
|
+
m.isReactWarning = !0, Object.defineProperty(a, "key", {
|
|
143
|
+
get: m,
|
|
144
|
+
configurable: !0
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function u() {
|
|
148
|
+
var a = t(this.type);
|
|
149
|
+
return re[a] || (re[a] = !0, console.error(
|
|
150
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
151
|
+
)), a = this.props.ref, a !== void 0 ? a : null;
|
|
152
|
+
}
|
|
153
|
+
function l(a, d, m, E, k, b, Y, z) {
|
|
154
|
+
return m = b.ref, a = {
|
|
155
|
+
$$typeof: h,
|
|
156
|
+
type: a,
|
|
157
|
+
key: d,
|
|
158
|
+
props: b,
|
|
159
|
+
_owner: k
|
|
160
|
+
}, (m !== void 0 ? m : null) !== null ? Object.defineProperty(a, "ref", {
|
|
161
|
+
enumerable: !1,
|
|
162
|
+
get: u
|
|
163
|
+
}) : Object.defineProperty(a, "ref", { enumerable: !1, value: null }), a._store = {}, Object.defineProperty(a._store, "validated", {
|
|
164
|
+
configurable: !1,
|
|
165
|
+
enumerable: !1,
|
|
166
|
+
writable: !0,
|
|
167
|
+
value: 0
|
|
168
|
+
}), Object.defineProperty(a, "_debugInfo", {
|
|
169
|
+
configurable: !1,
|
|
170
|
+
enumerable: !1,
|
|
171
|
+
writable: !0,
|
|
172
|
+
value: null
|
|
173
|
+
}), Object.defineProperty(a, "_debugStack", {
|
|
174
|
+
configurable: !1,
|
|
175
|
+
enumerable: !1,
|
|
176
|
+
writable: !0,
|
|
177
|
+
value: Y
|
|
178
|
+
}), Object.defineProperty(a, "_debugTask", {
|
|
179
|
+
configurable: !1,
|
|
180
|
+
enumerable: !1,
|
|
181
|
+
writable: !0,
|
|
182
|
+
value: z
|
|
183
|
+
}), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
|
|
184
|
+
}
|
|
185
|
+
function p(a, d, m, E, k, b, Y, z) {
|
|
186
|
+
var R = d.children;
|
|
187
|
+
if (R !== void 0)
|
|
188
|
+
if (E)
|
|
189
|
+
if (je(R)) {
|
|
190
|
+
for (E = 0; E < R.length; E++)
|
|
191
|
+
w(R[E]);
|
|
192
|
+
Object.freeze && Object.freeze(R);
|
|
193
|
+
} else
|
|
194
|
+
console.error(
|
|
195
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
196
|
+
);
|
|
197
|
+
else w(R);
|
|
198
|
+
if (ee.call(d, "key")) {
|
|
199
|
+
R = t(a);
|
|
200
|
+
var _ = Object.keys(d).filter(function(Te) {
|
|
201
|
+
return Te !== "key";
|
|
202
|
+
});
|
|
203
|
+
E = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", se[R + E] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
204
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
205
|
+
let props = %s;
|
|
206
|
+
<%s {...props} />
|
|
207
|
+
React keys must be passed directly to JSX without using spread:
|
|
208
|
+
let props = %s;
|
|
209
|
+
<%s key={someKey} {...props} />`,
|
|
210
|
+
E,
|
|
211
|
+
R,
|
|
212
|
+
_,
|
|
213
|
+
R
|
|
214
|
+
), se[R + E] = !0);
|
|
215
|
+
}
|
|
216
|
+
if (R = null, m !== void 0 && (n(m), R = "" + m), i(d) && (n(d.key), R = "" + d.key), "key" in d) {
|
|
217
|
+
m = {};
|
|
218
|
+
for (var B in d)
|
|
219
|
+
B !== "key" && (m[B] = d[B]);
|
|
220
|
+
} else m = d;
|
|
221
|
+
return R && c(
|
|
222
|
+
m,
|
|
223
|
+
typeof a == "function" ? a.displayName || a.name || "Unknown" : a
|
|
224
|
+
), l(
|
|
225
|
+
a,
|
|
226
|
+
R,
|
|
227
|
+
b,
|
|
228
|
+
k,
|
|
229
|
+
o(),
|
|
230
|
+
m,
|
|
231
|
+
Y,
|
|
232
|
+
z
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
function w(a) {
|
|
236
|
+
typeof a == "object" && a !== null && a.$$typeof === h && a._store && (a._store.validated = 1);
|
|
237
|
+
}
|
|
238
|
+
var g = Oe, h = Symbol.for("react.transitional.element"), x = Symbol.for("react.portal"), y = Symbol.for("react.fragment"), v = Symbol.for("react.strict_mode"), S = Symbol.for("react.profiler"), N = Symbol.for("react.consumer"), Ee = Symbol.for("react.context"), Re = Symbol.for("react.forward_ref"), be = Symbol.for("react.suspense"), Se = Symbol.for("react.suspense_list"), ke = Symbol.for("react.memo"), Z = Symbol.for("react.lazy"), Pe = Symbol.for("react.activity"), _e = Symbol.for("react.client.reference"), D = g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, ee = Object.prototype.hasOwnProperty, je = Array.isArray, M = console.createTask ? console.createTask : function() {
|
|
239
|
+
return null;
|
|
240
|
+
};
|
|
241
|
+
g = {
|
|
242
|
+
react_stack_bottom_frame: function(a) {
|
|
243
|
+
return a();
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
var te, re = {}, ne = g.react_stack_bottom_frame.bind(
|
|
247
|
+
g,
|
|
248
|
+
s
|
|
249
|
+
)(), oe = M(r(s)), se = {};
|
|
250
|
+
A.Fragment = y, A.jsx = function(a, d, m, E, k) {
|
|
251
|
+
var b = 1e4 > D.recentlyCreatedOwnerStacks++;
|
|
252
|
+
return p(
|
|
253
|
+
a,
|
|
254
|
+
d,
|
|
255
|
+
m,
|
|
256
|
+
!1,
|
|
257
|
+
E,
|
|
258
|
+
k,
|
|
259
|
+
b ? Error("react-stack-top-frame") : ne,
|
|
260
|
+
b ? M(r(a)) : oe
|
|
261
|
+
);
|
|
262
|
+
}, A.jsxs = function(a, d, m, E, k) {
|
|
263
|
+
var b = 1e4 > D.recentlyCreatedOwnerStacks++;
|
|
264
|
+
return p(
|
|
265
|
+
a,
|
|
266
|
+
d,
|
|
267
|
+
m,
|
|
268
|
+
!0,
|
|
269
|
+
E,
|
|
270
|
+
k,
|
|
271
|
+
b ? Error("react-stack-top-frame") : ne,
|
|
272
|
+
b ? M(r(a)) : oe
|
|
273
|
+
);
|
|
274
|
+
};
|
|
275
|
+
})()), A;
|
|
276
|
+
}
|
|
277
|
+
var ue;
|
|
278
|
+
function Le() {
|
|
279
|
+
return ue || (ue = 1, process.env.NODE_ENV === "production" ? W.exports = Ae() : W.exports = Ce()), W.exports;
|
|
280
|
+
}
|
|
281
|
+
var f = Le();
|
|
282
|
+
const fe = X({
|
|
283
|
+
trigger: "init",
|
|
284
|
+
state: {
|
|
285
|
+
id: "",
|
|
286
|
+
views: []
|
|
287
|
+
},
|
|
288
|
+
navigate: () => {
|
|
289
|
+
},
|
|
290
|
+
close: () => {
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
function $(t, ...e) {
|
|
294
|
+
t && t.addEventListener && t.addEventListener(...e);
|
|
295
|
+
}
|
|
296
|
+
function F(t, ...e) {
|
|
297
|
+
t && t.removeEventListener && t.removeEventListener(...e);
|
|
298
|
+
}
|
|
299
|
+
function de(t, e) {
|
|
300
|
+
window.dispatchEvent(
|
|
301
|
+
new CustomEvent(t, { detail: e })
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
function K(t = "", e = {}) {
|
|
305
|
+
const n = new URL(t, "http://dummy.base"), r = {
|
|
306
|
+
...Object.fromEntries(n.searchParams.entries()),
|
|
307
|
+
...e
|
|
308
|
+
}, o = new URLSearchParams(
|
|
309
|
+
Object.entries(r).map(([u, l]) => [u, String(l)])
|
|
310
|
+
).toString(), i = t.startsWith("http://") || t.startsWith("https://") ? n.origin + n.pathname : n.pathname, c = i.endsWith("/") && i.length > 1 ? i.slice(0, -1) : i;
|
|
311
|
+
return {
|
|
312
|
+
url: o ? `${c}?${o}` : c,
|
|
313
|
+
path: n.pathname,
|
|
314
|
+
queryParams: r
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function Ne(t) {
|
|
318
|
+
const e = {};
|
|
319
|
+
for (const [n, r] of new URLSearchParams(t))
|
|
320
|
+
r === "true" ? e[n] = !0 : r === "false" ? e[n] = !1 : We(r) ? e[n] = r.includes(".") ? parseFloat(r) : parseInt(r, 10) : e[n] = r;
|
|
321
|
+
return e;
|
|
322
|
+
}
|
|
323
|
+
function We(t) {
|
|
324
|
+
return isNaN(+t) ? !1 : parseInt(t).toString() === t || parseFloat(t).toString() === t;
|
|
325
|
+
}
|
|
326
|
+
const Ue = (t) => {
|
|
327
|
+
try {
|
|
328
|
+
return new URL(t, window.location.origin).origin !== window.location.origin;
|
|
329
|
+
} catch {
|
|
330
|
+
return !1;
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
function L() {
|
|
334
|
+
const { state: t, length: e } = window.history, { href: n } = window.location;
|
|
335
|
+
return {
|
|
336
|
+
state: Ye(t) ? t : Fe(n),
|
|
337
|
+
length: e
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
function H(t, e) {
|
|
341
|
+
history.pushState(e, "", t), de("pushstate", e);
|
|
342
|
+
}
|
|
343
|
+
function T(t, e) {
|
|
344
|
+
history.replaceState(e, "", t), de("replacestate", e);
|
|
345
|
+
}
|
|
346
|
+
function $e(t) {
|
|
347
|
+
const { id: e, views: n } = L().state;
|
|
348
|
+
if (e === t)
|
|
349
|
+
return;
|
|
350
|
+
const r = n.find((o) => o.id === t);
|
|
351
|
+
r && T(r.url, {
|
|
352
|
+
id: r.id,
|
|
353
|
+
views: n
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
function Fe(t) {
|
|
357
|
+
const e = crypto.randomUUID(), n = new URL(t), r = {
|
|
358
|
+
id: e,
|
|
359
|
+
views: [{
|
|
360
|
+
id: e,
|
|
361
|
+
url: t,
|
|
362
|
+
queryParams: Ne(n.search),
|
|
363
|
+
props: {}
|
|
364
|
+
}]
|
|
365
|
+
};
|
|
366
|
+
return T(t, r), r;
|
|
367
|
+
}
|
|
368
|
+
function Ie(t, e) {
|
|
369
|
+
const { state: n } = L(), r = { ...n };
|
|
370
|
+
let o = -1;
|
|
371
|
+
for (let s = 0; s < r.views.length; s++)
|
|
372
|
+
if (r.views[s].id === t) {
|
|
373
|
+
pe(r.views[s].queryParams, e) || (r.views[s].queryParams = e, o = s);
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
376
|
+
if (o > -1) {
|
|
377
|
+
const s = new URL(window.location.href);
|
|
378
|
+
s.search = new URLSearchParams(
|
|
379
|
+
Object.entries(e).map(([i, c]) => [i, String(c)])
|
|
380
|
+
).toString(), r.views[o].url = s.toString(), T(s.toString(), r);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function qe(t, e) {
|
|
384
|
+
const { state: n } = L(), r = { ...n };
|
|
385
|
+
let o = -1;
|
|
386
|
+
for (let s = 0; s < r.views.length; s++)
|
|
387
|
+
if (r.views[s].id === t) {
|
|
388
|
+
pe(r.views[s].props, e) || (r.views[s].props = e, o = s);
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
o > -1 && T(window.location.href, r);
|
|
392
|
+
}
|
|
393
|
+
function De(t, e) {
|
|
394
|
+
const n = [...e.views].filter((o) => o.id !== t), r = { ...e, views: n };
|
|
395
|
+
T(n.at(-1)?.url ?? "", r);
|
|
396
|
+
}
|
|
397
|
+
function Me(t, e, n, r, o, s) {
|
|
398
|
+
const i = [...o.views], c = crypto.randomUUID(), u = t.getFullPath(n), l = new URL(u, window.location.origin);
|
|
399
|
+
Object.entries(r).forEach(([v, S]) => {
|
|
400
|
+
l.searchParams.set(v, String(S));
|
|
401
|
+
});
|
|
402
|
+
const p = l.toString(), w = t.getViewComponentByPath(l.pathname), g = w?.params || {}, h = i.find((v) => p === v.url);
|
|
403
|
+
if (s.target !== "_top" && !s.append && h?.id === o.id)
|
|
404
|
+
return;
|
|
405
|
+
if (!s.append) {
|
|
406
|
+
if (s.target === "_top") {
|
|
407
|
+
const v = h || {
|
|
408
|
+
id: c,
|
|
409
|
+
url: p,
|
|
410
|
+
meta: w?.meta ?? void 0,
|
|
411
|
+
params: g,
|
|
412
|
+
queryParams: r,
|
|
413
|
+
props: s.props,
|
|
414
|
+
target: s?.target,
|
|
415
|
+
layout: s?.layout
|
|
416
|
+
};
|
|
417
|
+
H(p, {
|
|
418
|
+
id: v.id,
|
|
419
|
+
views: [v]
|
|
420
|
+
});
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
if (!s.append && h) {
|
|
424
|
+
T(p, {
|
|
425
|
+
id: h.id,
|
|
426
|
+
views: i
|
|
427
|
+
});
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
if (s.append || s.target === "_void") {
|
|
432
|
+
i.push({
|
|
433
|
+
id: c,
|
|
434
|
+
url: p,
|
|
435
|
+
meta: w?.meta ?? void 0,
|
|
436
|
+
params: g,
|
|
437
|
+
queryParams: r,
|
|
438
|
+
props: s.props,
|
|
439
|
+
target: s?.target,
|
|
440
|
+
layout: s?.layout
|
|
441
|
+
}), H(p, {
|
|
442
|
+
id: c,
|
|
443
|
+
views: i
|
|
444
|
+
});
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
const x = i.findIndex((v) => v.id === e), y = i.slice(0, x + 1);
|
|
448
|
+
y.push({
|
|
449
|
+
id: c,
|
|
450
|
+
url: p,
|
|
451
|
+
meta: w?.meta ?? void 0,
|
|
452
|
+
params: g,
|
|
453
|
+
queryParams: r,
|
|
454
|
+
props: s.props,
|
|
455
|
+
target: s?.target,
|
|
456
|
+
layout: s?.layout
|
|
457
|
+
}), H(p, {
|
|
458
|
+
id: c,
|
|
459
|
+
views: y
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
function Ye(t) {
|
|
463
|
+
return !t || typeof t != "object" ? !1 : "id" in t && "views" in t && Array.isArray(t.views);
|
|
464
|
+
}
|
|
465
|
+
function pe(t, e) {
|
|
466
|
+
if (typeof t != typeof e)
|
|
467
|
+
return !1;
|
|
468
|
+
if (typeof t > "u" || typeof e > "u")
|
|
469
|
+
return !0;
|
|
470
|
+
if (Object.keys(t).length !== Object.keys(e).length)
|
|
471
|
+
return !1;
|
|
472
|
+
for (const n in t)
|
|
473
|
+
if (!(n in e) || t[n] !== e[n] || typeof t[n] != typeof e[n])
|
|
474
|
+
return !1;
|
|
475
|
+
return !0;
|
|
476
|
+
}
|
|
477
|
+
class ze {
|
|
478
|
+
#e = "/";
|
|
479
|
+
#r = {};
|
|
480
|
+
#o = {};
|
|
481
|
+
#t = {};
|
|
482
|
+
constructor(e, n) {
|
|
483
|
+
this.#e = n ? this.#s(n) : "/", this.#o = e.layouts || {}, this.#t = e.errors || {}, this.registerRoutes(e.routes);
|
|
484
|
+
}
|
|
485
|
+
registerRoutes(e, n = !1) {
|
|
486
|
+
e.forEach((r) => {
|
|
487
|
+
const o = [], s = r.path.replace(/\[([^\]]+)\]/g, (c, u) => (o.push(u), "([^/]+)")), i = new RegExp(`^${s}$`);
|
|
488
|
+
if (!r.component || !(r.component instanceof Function) || r.path[0] !== "/") {
|
|
489
|
+
if (n)
|
|
490
|
+
throw new Error(`Invalid component for route ${r.path || "undefined path"}`);
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
this.#r[r.path] = {
|
|
494
|
+
component: r.component,
|
|
495
|
+
pattern: i,
|
|
496
|
+
paramKeys: o,
|
|
497
|
+
originalPath: r.path,
|
|
498
|
+
layouts: r.layouts?.length ? r.layouts.map((c) => ({ component: c })) : this.#a(r.path),
|
|
499
|
+
// Path found routes
|
|
500
|
+
meta: r.meta || { breakpoints: [] }
|
|
501
|
+
};
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
#s(e) {
|
|
505
|
+
return e.startsWith("/") || (e = "/" + e), e.length > 1 && e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
506
|
+
}
|
|
507
|
+
#n(e) {
|
|
508
|
+
return this.#e === "/" ? e : e.startsWith(this.#e) ? e.slice(this.#e.length) || "/" : e;
|
|
509
|
+
}
|
|
510
|
+
getViewComponentByPath(e) {
|
|
511
|
+
const n = this.#n(e), r = n.length > 1 && n.at(-1) === "/" ? n.substring(0, n.length - 1) : n;
|
|
512
|
+
for (const o in this.#r) {
|
|
513
|
+
const s = this.#r[o], i = r.match(s.pattern);
|
|
514
|
+
if (i) {
|
|
515
|
+
const c = Object.fromEntries(
|
|
516
|
+
s.paramKeys.map((u, l) => [u, i[l + 1]])
|
|
517
|
+
);
|
|
518
|
+
return {
|
|
519
|
+
Component: s.component,
|
|
520
|
+
Layouts: s.layouts,
|
|
521
|
+
params: c,
|
|
522
|
+
meta: s.meta
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return null;
|
|
527
|
+
}
|
|
528
|
+
getErrorComponentByPath(e) {
|
|
529
|
+
const n = this.#n(e), r = n.length > 1 && n.at(-1) === "/" ? n.substring(0, n.length - 1) : n;
|
|
530
|
+
if (this.#t[r])
|
|
531
|
+
return this.#t[r];
|
|
532
|
+
const o = r.split("/").filter(Boolean);
|
|
533
|
+
for (let s = o.length; s >= 1; s--) {
|
|
534
|
+
const i = "/" + o.slice(0, s).join("/");
|
|
535
|
+
if (this.#t[i])
|
|
536
|
+
return this.#t[i];
|
|
537
|
+
}
|
|
538
|
+
return this.#t["/"] ? this.#t["/"] : (console.log("No error component found"), null);
|
|
539
|
+
}
|
|
540
|
+
get basePath() {
|
|
541
|
+
return this.#e;
|
|
542
|
+
}
|
|
543
|
+
getFullPath(e) {
|
|
544
|
+
return this.#e === "/" ? e : e === "/" ? this.#e : e.startsWith(this.#e) ? e : this.#e + e;
|
|
545
|
+
}
|
|
546
|
+
getPathFromUrl(e) {
|
|
547
|
+
try {
|
|
548
|
+
let r = new URL(e).pathname;
|
|
549
|
+
return r = this.#n(r), r.length > 1 && r.endsWith("/") && (r = r.slice(0, -1)), r;
|
|
550
|
+
} catch {
|
|
551
|
+
return this.#n(e);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
getAllViewComponents() {
|
|
555
|
+
return Object.values(this.#r).map((e) => ({
|
|
556
|
+
Component: e.component,
|
|
557
|
+
Layouts: e.layouts,
|
|
558
|
+
meta: e.meta
|
|
559
|
+
}));
|
|
560
|
+
}
|
|
561
|
+
#a(e) {
|
|
562
|
+
const n = [], r = ["/", ...e.match(/[^/]+/g) || []];
|
|
563
|
+
let o = r[0];
|
|
564
|
+
for (let s = 0; s < r.length; s++) {
|
|
565
|
+
const i = [];
|
|
566
|
+
for (const c in this.#o) {
|
|
567
|
+
const [u, l] = c.split("#");
|
|
568
|
+
u === o && i.push({
|
|
569
|
+
key: l,
|
|
570
|
+
component: this.#o[c]
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
n.push(...i), o += r[s + 1];
|
|
574
|
+
}
|
|
575
|
+
return n;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
function et({ basePath: t, config: e, external: n = [], children: r }) {
|
|
579
|
+
const o = j(() => new ze(e, t), [e, t]), [s, i] = C(U("load", o));
|
|
580
|
+
return P(() => {
|
|
581
|
+
for (const c of n ?? [])
|
|
582
|
+
import(c.url).then((u) => {
|
|
583
|
+
if (!Array.isArray(u.routes))
|
|
584
|
+
throw new Error(`Invalid routes in ${c.url}`);
|
|
585
|
+
o.registerRoutes(u.routes, !0);
|
|
586
|
+
}).catch((u) => {
|
|
587
|
+
console.error(u.message);
|
|
588
|
+
});
|
|
589
|
+
}, [n, o]), P(() => {
|
|
590
|
+
t && t !== "/" && window.location.pathname === "/" && window.history.replaceState(null, "", t);
|
|
591
|
+
}, [t]), P(() => {
|
|
592
|
+
const c = () => i(U("popstate", o)), u = () => i(U("pushstate", o)), l = () => i(U("replacestate", o));
|
|
593
|
+
return $(window, "popstate", c), $(window, "pushstate", u), $(window, "replacestate", l), () => {
|
|
594
|
+
F(window, "popstate", c), F(window, "pushstate", u), F(window, "replacestate", l);
|
|
595
|
+
};
|
|
596
|
+
}, [o]), /* @__PURE__ */ f.jsx(fe.Provider, { value: { clientRouter: o, ...s }, children: r });
|
|
597
|
+
}
|
|
598
|
+
function U(t, e) {
|
|
599
|
+
const { state: n, length: r } = L(), { hash: o, host: s, hostname: i, href: c, origin: u, pathname: l, port: p, protocol: w, search: g } = window.location;
|
|
600
|
+
return {
|
|
601
|
+
trigger: t,
|
|
602
|
+
state: n,
|
|
603
|
+
length: r,
|
|
604
|
+
hash: o,
|
|
605
|
+
host: s,
|
|
606
|
+
hostname: i,
|
|
607
|
+
href: c,
|
|
608
|
+
origin: u,
|
|
609
|
+
pathname: l,
|
|
610
|
+
port: p,
|
|
611
|
+
protocol: w,
|
|
612
|
+
search: g,
|
|
613
|
+
navigate: (h, x, y, v) => {
|
|
614
|
+
Me(e, h, x, y, n, v);
|
|
615
|
+
},
|
|
616
|
+
close: (h) => {
|
|
617
|
+
De(h, n);
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
function O() {
|
|
622
|
+
const t = I(fe);
|
|
623
|
+
if (t === void 0)
|
|
624
|
+
throw new Error("useRouter must be used within a RouterProvider");
|
|
625
|
+
return t;
|
|
626
|
+
}
|
|
627
|
+
function Be(t, e) {
|
|
628
|
+
if (!t || !e)
|
|
629
|
+
return t === e;
|
|
630
|
+
if (t.length !== e.length)
|
|
631
|
+
return !1;
|
|
632
|
+
for (let n = 0; n < t.length; n++) {
|
|
633
|
+
const r = t[n], o = e[n];
|
|
634
|
+
if (r.id !== o.id || r.url !== o.url || r.layout !== o.layout || r.target !== o.target || !J(r.params, o.params) || !J(r.queryParams, o.queryParams) || !J(r.props, o.props) || r.meta !== o.meta && (!r.meta || !o.meta || r.meta.type !== o.meta.type))
|
|
635
|
+
return !1;
|
|
636
|
+
}
|
|
637
|
+
return !0;
|
|
638
|
+
}
|
|
639
|
+
function J(t, e) {
|
|
640
|
+
if (t === e)
|
|
641
|
+
return !0;
|
|
642
|
+
if (!t || !e)
|
|
643
|
+
return !1;
|
|
644
|
+
const n = Object.keys(t), r = Object.keys(e);
|
|
645
|
+
if (n.length !== r.length)
|
|
646
|
+
return !1;
|
|
647
|
+
for (const o of n)
|
|
648
|
+
if (t[o] !== e[o])
|
|
649
|
+
return !1;
|
|
650
|
+
return !0;
|
|
651
|
+
}
|
|
652
|
+
function he() {
|
|
653
|
+
const { state: t, clientRouter: e } = O() || {}, n = le(void 0), r = !Be(n.current, t.views);
|
|
654
|
+
return j(() => {
|
|
655
|
+
const s = [], i = [];
|
|
656
|
+
return t.views.forEach((c) => {
|
|
657
|
+
const u = new URL(c.url, "http://dummy.base"), l = e?.getViewComponentByPath(u.pathname), p = c.params || l?.params || {}, w = c.meta || l?.meta, g = {
|
|
658
|
+
view: c,
|
|
659
|
+
meta: w,
|
|
660
|
+
Component: l?.Component,
|
|
661
|
+
Layouts: l?.Layouts,
|
|
662
|
+
params: p
|
|
663
|
+
};
|
|
664
|
+
c.target === "_void" ? i.push(g) : s.push(g);
|
|
665
|
+
}), n.current = t.views, {
|
|
666
|
+
viewStack: s,
|
|
667
|
+
voidViews: i
|
|
668
|
+
};
|
|
669
|
+
}, [r, e]);
|
|
670
|
+
}
|
|
671
|
+
const me = X({
|
|
672
|
+
viewId: "",
|
|
673
|
+
isActive: !1,
|
|
674
|
+
width: 0,
|
|
675
|
+
queryParams: {},
|
|
676
|
+
setQueryParams: () => {
|
|
677
|
+
},
|
|
678
|
+
setProps: () => {
|
|
679
|
+
},
|
|
680
|
+
queryParam: () => {
|
|
681
|
+
},
|
|
682
|
+
close: () => {
|
|
683
|
+
},
|
|
684
|
+
state: { id: "", views: [] }
|
|
685
|
+
});
|
|
686
|
+
function we({
|
|
687
|
+
id: t,
|
|
688
|
+
width: e,
|
|
689
|
+
layout: n,
|
|
690
|
+
children: r,
|
|
691
|
+
params: o,
|
|
692
|
+
queryParams: s,
|
|
693
|
+
props: i
|
|
694
|
+
}) {
|
|
695
|
+
const { state: c, close: u } = O(), [l, p] = C(t === c.id), [w, g] = C(i || {});
|
|
696
|
+
return P(() => {
|
|
697
|
+
p(t === c.id);
|
|
698
|
+
}, [c.id, t]), /* @__PURE__ */ f.jsx(me.Provider, { value: {
|
|
699
|
+
viewId: t,
|
|
700
|
+
isActive: l,
|
|
701
|
+
width: e,
|
|
702
|
+
params: o,
|
|
703
|
+
queryParams: s,
|
|
704
|
+
props: w,
|
|
705
|
+
layout: n,
|
|
706
|
+
state: c,
|
|
707
|
+
setProps: (h, x) => {
|
|
708
|
+
const y = x ? h || {} : { ...i, ...h };
|
|
709
|
+
for (const v in y)
|
|
710
|
+
y[v] === void 0 && delete y[v];
|
|
711
|
+
g(y), qe(t, y);
|
|
712
|
+
},
|
|
713
|
+
setQueryParams: (h, x) => {
|
|
714
|
+
const y = x !== !0 ? { ...i || {} } : {};
|
|
715
|
+
let v = !1;
|
|
716
|
+
for (const S in h) {
|
|
717
|
+
const N = h[S];
|
|
718
|
+
typeof N < "u" ? (y[S] = N, v = !0) : Object.prototype.hasOwnProperty.call(y, S) && (delete y[S], v = !0);
|
|
719
|
+
}
|
|
720
|
+
(v || x === !0) && Ie(t, y);
|
|
721
|
+
},
|
|
722
|
+
queryParam: (h) => i?.[h],
|
|
723
|
+
close: () => {
|
|
724
|
+
u(t);
|
|
725
|
+
}
|
|
726
|
+
}, children: r });
|
|
727
|
+
}
|
|
728
|
+
function He(t, e) {
|
|
729
|
+
const n = e.filter((o) => o.view.target !== "_void").map((o) => ({
|
|
730
|
+
id: o.view.id,
|
|
731
|
+
breakpoints: o.meta?.breakpoints || []
|
|
732
|
+
})), r = Je(t, n);
|
|
733
|
+
return e.map(({ view: o }) => ({
|
|
734
|
+
id: o.id,
|
|
735
|
+
vw: r.find((s) => s.id === o.id)?.vw || 0
|
|
736
|
+
}));
|
|
737
|
+
}
|
|
738
|
+
function Je(t, e) {
|
|
739
|
+
if (e.length === 0)
|
|
740
|
+
return [];
|
|
741
|
+
const r = e.map((i) => ({
|
|
742
|
+
id: i.id,
|
|
743
|
+
minVw: Ge(i, t)
|
|
744
|
+
})), o = r.reduce(
|
|
745
|
+
(i, c) => i + c.minVw,
|
|
746
|
+
0
|
|
747
|
+
);
|
|
748
|
+
if (o >= 100)
|
|
749
|
+
return r.map((i) => ({
|
|
750
|
+
id: i.id,
|
|
751
|
+
vw: i.minVw
|
|
752
|
+
}));
|
|
753
|
+
const s = 100 - o;
|
|
754
|
+
return r.map((i) => {
|
|
755
|
+
const c = i.minVw / o, u = s * c;
|
|
756
|
+
return {
|
|
757
|
+
id: i.id,
|
|
758
|
+
vw: Number((i.minVw + u).toFixed(0))
|
|
759
|
+
// Round to 0 decimal places
|
|
760
|
+
};
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
function Ge(t, e) {
|
|
764
|
+
const r = [...t.breakpoints].sort((o, s) => s.breakpoint - o.breakpoint).find((o) => e >= o.breakpoint);
|
|
765
|
+
return r ? r.minVw : 100;
|
|
766
|
+
}
|
|
767
|
+
function ge({ children: t }) {
|
|
768
|
+
return /* @__PURE__ */ f.jsx(f.Fragment, { children: t });
|
|
769
|
+
}
|
|
770
|
+
const Q = X({
|
|
771
|
+
setSlot: () => {
|
|
772
|
+
},
|
|
773
|
+
getSlots: () => ({})
|
|
774
|
+
});
|
|
775
|
+
function ye({ children: t }) {
|
|
776
|
+
const [e, n] = C({}), r = ae((s, i, c) => {
|
|
777
|
+
n((u) => ({
|
|
778
|
+
...u,
|
|
779
|
+
[s]: {
|
|
780
|
+
...u[s],
|
|
781
|
+
[i]: c
|
|
782
|
+
}
|
|
783
|
+
}));
|
|
784
|
+
}, []), o = ae((s) => e[s] || {}, [e]);
|
|
785
|
+
return /* @__PURE__ */ f.jsx(Q.Provider, { value: { setSlot: r, getSlots: o }, children: t });
|
|
786
|
+
}
|
|
787
|
+
function Xe({
|
|
788
|
+
viewUrl: t,
|
|
789
|
+
error: e,
|
|
790
|
+
errorCode: n,
|
|
791
|
+
errorInfo: r,
|
|
792
|
+
reset: o
|
|
793
|
+
}) {
|
|
794
|
+
const { clientRouter: s } = O(), i = s?.getErrorComponentByPath(
|
|
795
|
+
s?.getPathFromUrl(t) ?? "/"
|
|
796
|
+
);
|
|
797
|
+
return i ? /* @__PURE__ */ f.jsx(
|
|
798
|
+
i,
|
|
799
|
+
{
|
|
800
|
+
error: e,
|
|
801
|
+
errorCode: n ?? 0,
|
|
802
|
+
errorInfo: r,
|
|
803
|
+
reset: o
|
|
804
|
+
}
|
|
805
|
+
) : /* @__PURE__ */ f.jsxs("div", { style: {
|
|
806
|
+
margin: "10px",
|
|
807
|
+
border: "2px solid #ff6b6b",
|
|
808
|
+
borderRadius: "8px",
|
|
809
|
+
backgroundColor: "#fff5f5",
|
|
810
|
+
width: "100%",
|
|
811
|
+
display: "flex",
|
|
812
|
+
flexDirection: "column",
|
|
813
|
+
alignItems: "center",
|
|
814
|
+
padding: "20px"
|
|
815
|
+
}, children: [
|
|
816
|
+
/* @__PURE__ */ f.jsx("h1", { style: { color: "#c92a2a", marginBottom: "10px", fontWeight: "bold" }, children: "Unhandled error" }),
|
|
817
|
+
/* @__PURE__ */ f.jsx("p", { style: { marginBottom: "15px", textAlign: "center" }, children: e.message }),
|
|
818
|
+
/* @__PURE__ */ f.jsxs("details", { style: { marginBottom: "15px", width: "100%" }, children: [
|
|
819
|
+
/* @__PURE__ */ f.jsx("summary", { style: { cursor: "pointer", marginBottom: "10px", textAlign: "center" }, children: "Technical details" }),
|
|
820
|
+
/* @__PURE__ */ f.jsxs("div", { style: {
|
|
821
|
+
backgroundColor: "#f8f9fa",
|
|
822
|
+
padding: "10px",
|
|
823
|
+
borderRadius: "4px",
|
|
824
|
+
overflow: "auto",
|
|
825
|
+
maxHeight: "200px"
|
|
826
|
+
}, children: [
|
|
827
|
+
/* @__PURE__ */ f.jsx("h4", { style: { margin: "0 0 10px 0", fontSize: "14px" }, children: "Stack Trace:" }),
|
|
828
|
+
/* @__PURE__ */ f.jsx("pre", { style: { fontSize: "12px", margin: 0, whiteSpace: "pre-wrap" }, children: e.stack }),
|
|
829
|
+
r?.componentStack && /* @__PURE__ */ f.jsxs(f.Fragment, { children: [
|
|
830
|
+
/* @__PURE__ */ f.jsx("h4", { style: { margin: "15px 0 10px 0", fontSize: "14px" }, children: "Component Stack:" }),
|
|
831
|
+
/* @__PURE__ */ f.jsx("pre", { style: { fontSize: "12px", margin: 0, whiteSpace: "pre-wrap" }, children: r.componentStack })
|
|
832
|
+
] })
|
|
833
|
+
] })
|
|
834
|
+
] }),
|
|
835
|
+
/* @__PURE__ */ f.jsx(
|
|
836
|
+
"button",
|
|
837
|
+
{
|
|
838
|
+
onClick: o,
|
|
839
|
+
style: {
|
|
840
|
+
backgroundColor: "#228be6",
|
|
841
|
+
color: "white",
|
|
842
|
+
border: "none",
|
|
843
|
+
padding: "8px 16px",
|
|
844
|
+
borderRadius: "4px",
|
|
845
|
+
cursor: "pointer"
|
|
846
|
+
},
|
|
847
|
+
children: "Try again"
|
|
848
|
+
}
|
|
849
|
+
)
|
|
850
|
+
] });
|
|
851
|
+
}
|
|
852
|
+
class G extends Ve {
|
|
853
|
+
constructor(e) {
|
|
854
|
+
super(e), this.state = {
|
|
855
|
+
hasError: !!e.error,
|
|
856
|
+
errorCode: e.errorCode,
|
|
857
|
+
error: e.error
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
static getDerivedStateFromError(e) {
|
|
861
|
+
return { hasError: !0, error: e };
|
|
862
|
+
}
|
|
863
|
+
componentDidCatch(e, n) {
|
|
864
|
+
console.error(`Error in view ${this.props.viewUrl}:`, e, n), this.setState({ errorInfo: n });
|
|
865
|
+
}
|
|
866
|
+
reset = () => {
|
|
867
|
+
this.setState({ hasError: !1, error: void 0, errorInfo: void 0 });
|
|
868
|
+
};
|
|
869
|
+
render() {
|
|
870
|
+
return !this.state.hasError || !this.state.error ? this.props.children : /* @__PURE__ */ f.jsx(
|
|
871
|
+
Xe,
|
|
872
|
+
{
|
|
873
|
+
viewUrl: this.props.viewUrl,
|
|
874
|
+
error: this.state.error,
|
|
875
|
+
errorCode: this.state.errorCode,
|
|
876
|
+
errorInfo: this.state.errorInfo,
|
|
877
|
+
reset: this.reset
|
|
878
|
+
}
|
|
879
|
+
);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
function tt({
|
|
883
|
+
className: t,
|
|
884
|
+
style: e = {}
|
|
885
|
+
}) {
|
|
886
|
+
const { viewStack: n } = he(), [r, o] = C(window.innerWidth);
|
|
887
|
+
P(() => {
|
|
888
|
+
const u = () => o(window.innerWidth);
|
|
889
|
+
return window.addEventListener("resize", u), () => window.removeEventListener("resize", u);
|
|
890
|
+
}, []);
|
|
891
|
+
const s = j(() => He(r, n), [r, n]), i = j(() => {
|
|
892
|
+
let u = 0, l = 0;
|
|
893
|
+
for (let p = n.length - 1; p >= 0; p--)
|
|
894
|
+
if (u += s[p]?.vw || 0, u > 100) {
|
|
895
|
+
l = p + 1;
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
898
|
+
return n.slice(l);
|
|
899
|
+
}, [s, n]), c = j(() => {
|
|
900
|
+
const u = n.length - i.length;
|
|
901
|
+
return i.map((l, p) => s[p + u].vw);
|
|
902
|
+
}, [s, n.length, i]);
|
|
903
|
+
return /* @__PURE__ */ f.jsx(
|
|
904
|
+
Ke,
|
|
905
|
+
{
|
|
906
|
+
views: i,
|
|
907
|
+
widths: c,
|
|
908
|
+
style: e,
|
|
909
|
+
className: t
|
|
910
|
+
}
|
|
911
|
+
);
|
|
912
|
+
}
|
|
913
|
+
function Ke({
|
|
914
|
+
views: t,
|
|
915
|
+
widths: e,
|
|
916
|
+
className: n,
|
|
917
|
+
style: r = {}
|
|
918
|
+
}) {
|
|
919
|
+
return /* @__PURE__ */ f.jsx(ye, { children: /* @__PURE__ */ f.jsx("div", { className: n, style: r, children: t.map(({ view: o, params: s, Layouts: i, Component: c }, u) => {
|
|
920
|
+
if (!c)
|
|
921
|
+
return /* @__PURE__ */ f.jsx(
|
|
922
|
+
G,
|
|
923
|
+
{
|
|
924
|
+
viewUrl: o.url,
|
|
925
|
+
errorCode: 404,
|
|
926
|
+
error: new Error("Not found")
|
|
927
|
+
},
|
|
928
|
+
o.id
|
|
929
|
+
);
|
|
930
|
+
const l = i?.length ? i.filter((p) => p.key === o.layout) : [{ component: ge }];
|
|
931
|
+
return /* @__PURE__ */ f.jsx(G, { viewUrl: o.url || "/", children: /* @__PURE__ */ f.jsx(
|
|
932
|
+
we,
|
|
933
|
+
{
|
|
934
|
+
id: o.id,
|
|
935
|
+
width: e[u],
|
|
936
|
+
params: s,
|
|
937
|
+
queryParams: o.queryParams,
|
|
938
|
+
props: o.props,
|
|
939
|
+
children: ve(l, c, s)
|
|
940
|
+
},
|
|
941
|
+
o.id
|
|
942
|
+
) }, o.id);
|
|
943
|
+
}) }) });
|
|
944
|
+
}
|
|
945
|
+
function ve(t, e, n) {
|
|
946
|
+
if (t.length === 0)
|
|
947
|
+
return /* @__PURE__ */ f.jsx(e, { ...n || {} });
|
|
948
|
+
const [r, ...o] = t, s = r.component;
|
|
949
|
+
return /* @__PURE__ */ f.jsx(s, { children: ve(o, e, n) }, r.key);
|
|
950
|
+
}
|
|
951
|
+
function rt({ className: t, style: e = {} }) {
|
|
952
|
+
const { voidViews: n } = he();
|
|
953
|
+
return /* @__PURE__ */ f.jsx(
|
|
954
|
+
Qe,
|
|
955
|
+
{
|
|
956
|
+
views: n,
|
|
957
|
+
style: e,
|
|
958
|
+
className: t
|
|
959
|
+
}
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
function Qe({ views: t, className: e, style: n = {} }) {
|
|
963
|
+
return /* @__PURE__ */ f.jsx(ye, { children: /* @__PURE__ */ f.jsx("div", { className: e, style: n, children: t.map(({ view: r, params: o, Layouts: s, Component: i }) => {
|
|
964
|
+
const c = s?.length ? s.filter((u) => u.key === r.layout) : [{ component: ge }];
|
|
965
|
+
return /* @__PURE__ */ f.jsx(G, { viewUrl: r.url || "/", children: /* @__PURE__ */ f.jsx(
|
|
966
|
+
we,
|
|
967
|
+
{
|
|
968
|
+
id: r.id,
|
|
969
|
+
width: 0,
|
|
970
|
+
params: o,
|
|
971
|
+
queryParams: r.queryParams,
|
|
972
|
+
props: r.props,
|
|
973
|
+
layout: r.layout,
|
|
974
|
+
children: xe(c, i, o)
|
|
975
|
+
},
|
|
976
|
+
r.id
|
|
977
|
+
) }, r.id);
|
|
978
|
+
}) }) });
|
|
979
|
+
}
|
|
980
|
+
function xe(t, e, n) {
|
|
981
|
+
if (t.length === 0)
|
|
982
|
+
return e ? /* @__PURE__ */ f.jsx(e, { ...n || {} }) : null;
|
|
983
|
+
const [r, ...o] = t, s = r.component;
|
|
984
|
+
return /* @__PURE__ */ f.jsx(s, { children: xe(o, e, n) }, r.key);
|
|
985
|
+
}
|
|
986
|
+
function q() {
|
|
987
|
+
const t = I(me);
|
|
988
|
+
if (t === void 0)
|
|
989
|
+
throw new Error("useView must be used within a ViewProvider");
|
|
990
|
+
return t;
|
|
991
|
+
}
|
|
992
|
+
function nt({ children: t, style: e = {}, className: n }) {
|
|
993
|
+
const { viewId: r } = q(), o = le(null);
|
|
994
|
+
return P(() => {
|
|
995
|
+
if (!o.current)
|
|
996
|
+
return;
|
|
997
|
+
const s = () => {
|
|
998
|
+
$e(r);
|
|
999
|
+
}, i = o.current;
|
|
1000
|
+
return $(i, "click", s), () => F(i, "click", s);
|
|
1001
|
+
}, [r, o]), /* @__PURE__ */ f.jsx("div", { ref: o, style: e, className: n, children: t });
|
|
1002
|
+
}
|
|
1003
|
+
function ot({
|
|
1004
|
+
href: t,
|
|
1005
|
+
query: e = {},
|
|
1006
|
+
children: n,
|
|
1007
|
+
className: r,
|
|
1008
|
+
target: o = "_self",
|
|
1009
|
+
onClick: s,
|
|
1010
|
+
props: i,
|
|
1011
|
+
layout: c
|
|
1012
|
+
}) {
|
|
1013
|
+
const { navigate: u } = O(), { url: l, queryParams: p } = K(t, e), { viewId: w } = q(), g = (x) => {
|
|
1014
|
+
s && (s(x), x.isDefaultPrevented()) || l.startsWith("https://") || l.startsWith("http://") || o === "_blank" || x.metaKey || x.ctrlKey || (x.preventDefault(), u(w, l, p, {
|
|
1015
|
+
append: x.shiftKey,
|
|
1016
|
+
target: o,
|
|
1017
|
+
props: i,
|
|
1018
|
+
layout: c
|
|
1019
|
+
}));
|
|
1020
|
+
}, h = Ue(l) ? "noopener noreferrer" : void 0;
|
|
1021
|
+
return /* @__PURE__ */ f.jsx("a", { rel: h, href: l, onClick: g, className: r, target: o, children: n });
|
|
1022
|
+
}
|
|
1023
|
+
function st({ slot: t }) {
|
|
1024
|
+
const { viewId: e } = q(), { getSlots: n } = I(Q), r = n(e);
|
|
1025
|
+
return /* @__PURE__ */ f.jsx(f.Fragment, { children: r[t] });
|
|
1026
|
+
}
|
|
1027
|
+
function at({ slot: t, children: e }) {
|
|
1028
|
+
const { viewId: n } = q(), { setSlot: r } = I(Q);
|
|
1029
|
+
return P(() => (r(n, t, e), () => r(n, t, null)), [n, t, e, r]), null;
|
|
1030
|
+
}
|
|
1031
|
+
function it() {
|
|
1032
|
+
const { navigate: t } = O();
|
|
1033
|
+
return (e, n) => {
|
|
1034
|
+
const { state: r } = L(), { url: o, queryParams: s } = K(e);
|
|
1035
|
+
t(r.id || "", o, s, {
|
|
1036
|
+
append: !1,
|
|
1037
|
+
target: n?.target || "_self",
|
|
1038
|
+
props: n?.props,
|
|
1039
|
+
layout: n?.layout
|
|
1040
|
+
});
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
function ct(t) {
|
|
1044
|
+
const { url: e } = K(t);
|
|
1045
|
+
return e;
|
|
1046
|
+
}
|
|
1047
|
+
function ut(t, e) {
|
|
1048
|
+
const { state: n } = O();
|
|
1049
|
+
return j(() => {
|
|
1050
|
+
const o = [];
|
|
1051
|
+
return n.views.forEach((s) => {
|
|
1052
|
+
if (s.meta?.type === t) {
|
|
1053
|
+
if (e) {
|
|
1054
|
+
const i = s.params || {};
|
|
1055
|
+
if (!Object.entries(e).every(([u, l]) => i[u] === l))
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
o.push({
|
|
1059
|
+
id: s.id,
|
|
1060
|
+
url: s.url,
|
|
1061
|
+
params: s.params,
|
|
1062
|
+
queryParams: s.queryParams,
|
|
1063
|
+
props: s.props,
|
|
1064
|
+
layout: s.layout,
|
|
1065
|
+
target: s.target,
|
|
1066
|
+
isActive: s.id === n.id
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
}), o;
|
|
1070
|
+
}, [n.views, n.id, t, e]);
|
|
1071
|
+
}
|
|
1072
|
+
function lt(t, e = "") {
|
|
1073
|
+
const n = [], r = {}, o = {};
|
|
1074
|
+
return Object.entries(t).forEach(([s, i]) => {
|
|
1075
|
+
let c = s.replace(e, "").replace(/\.tsx$/, "").replace(/\/index$/, "").replace(/([A-Z])/g, (p) => `/${p.toLowerCase()}`).replace(/\/\//g, "/").toLowerCase() || "/";
|
|
1076
|
+
c === "" || c === "index" ? c = "/" : c && !c.startsWith("/") && (c = "/" + c);
|
|
1077
|
+
const u = c.match(/^(.*)\/(_error)$/);
|
|
1078
|
+
if (u) {
|
|
1079
|
+
const [, p] = u, w = p || "/";
|
|
1080
|
+
o[w] = i.default;
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
const l = c.match(/^(.*)\/(_layout(?:\.([^/]+))?)$/);
|
|
1084
|
+
if (l) {
|
|
1085
|
+
const [, p, , w] = l, g = p || "/";
|
|
1086
|
+
if (w) {
|
|
1087
|
+
const h = `${g}#${w}`;
|
|
1088
|
+
r[h] = i.default;
|
|
1089
|
+
} else
|
|
1090
|
+
r[g] = i.default;
|
|
1091
|
+
} else c.includes("/_") || n.push({
|
|
1092
|
+
path: c,
|
|
1093
|
+
component: i.default,
|
|
1094
|
+
// @ts-expect-error meta is not defined
|
|
1095
|
+
meta: i.default?.meta || { breakpoints: [] }
|
|
1096
|
+
});
|
|
1097
|
+
}), { routes: n, layouts: r, errors: o };
|
|
1098
|
+
}
|
|
1099
|
+
export {
|
|
1100
|
+
at as Fill,
|
|
1101
|
+
ot as Link,
|
|
1102
|
+
st as Outlet,
|
|
1103
|
+
et as RouterProvider,
|
|
1104
|
+
nt as StackedView,
|
|
1105
|
+
tt as StackedViewGroup,
|
|
1106
|
+
rt as VoidViews,
|
|
1107
|
+
lt as mapRoutes,
|
|
1108
|
+
ct as useHref,
|
|
1109
|
+
it as useNavigate,
|
|
1110
|
+
ut as useOpenViews,
|
|
1111
|
+
q as useView
|
|
1112
|
+
};
|