sibujs 3.3.1 → 3.3.2
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/browser.cjs +21 -15
- package/dist/browser.js +5 -5
- package/dist/build.cjs +48 -20
- package/dist/build.js +13 -13
- package/dist/cdn.global.js +7 -7
- package/dist/{chunk-IKLYI3RF.js → chunk-2ARSB7NG.js} +36 -13
- package/dist/{chunk-TEFZT5PJ.js → chunk-4NJEAPLI.js} +1 -1
- package/dist/{chunk-F7FXQ3QS.js → chunk-5VH3GIDX.js} +1 -1
- package/dist/{chunk-RYMOSG5B.js → chunk-62V653X2.js} +16 -21
- package/dist/{chunk-XH2RTYEQ.js → chunk-655B7MMR.js} +3 -3
- package/dist/{chunk-37BUKSLH.js → chunk-6TCOWMGY.js} +1 -1
- package/dist/{chunk-6LTFHJQG.js → chunk-A7CZH3GN.js} +3 -3
- package/dist/{chunk-ULLTNDRA.js → chunk-AEOLHSSQ.js} +3 -3
- package/dist/chunk-CCSJMTRN.js +15 -0
- package/dist/{chunk-R3QEDXFS.js → chunk-EX77FXTT.js} +1 -1
- package/dist/{chunk-ZUVLC7TM.js → chunk-FJIRS3FM.js} +1 -1
- package/dist/{chunk-Z37APKBV.js → chunk-FJO2ZL4Q.js} +4 -4
- package/dist/{chunk-WW6DAGGR.js → chunk-G6N3LMO2.js} +1 -1
- package/dist/{chunk-WL7BIR6O.js → chunk-IQJ36UTJ.js} +1 -1
- package/dist/{chunk-WZG2SZOT.js → chunk-JCQG2I2G.js} +1 -1
- package/dist/{chunk-MHBCEJQO.js → chunk-N5TQVEKE.js} +2 -2
- package/dist/{chunk-4UUMSLSL.js → chunk-P7C7SEJV.js} +4 -4
- package/dist/{chunk-VOVVTOEA.js → chunk-Q46YIQYW.js} +2 -2
- package/dist/{chunk-NHKQKKZU.js → chunk-QCFBIVIQ.js} +1 -1
- package/dist/{chunk-SLMFA3ZZ.js → chunk-RLTFJYDN.js} +2 -2
- package/dist/{chunk-GOJMFRBL.js → chunk-S3NFJO6L.js} +20 -14
- package/dist/{chunk-AMIKDMLP.js → chunk-YUBEOWII.js} +5 -5
- package/dist/{chunk-M5KBNOSJ.js → chunk-YUR5SX7F.js} +2 -2
- package/dist/{chunk-LU2MQXQQ.js → chunk-ZEUP4TUD.js} +2 -2
- package/dist/data.cjs +21 -15
- package/dist/data.js +7 -7
- package/dist/devtools.cjs +21 -15
- package/dist/devtools.js +5 -5
- package/dist/ecosystem.cjs +21 -15
- package/dist/ecosystem.js +8 -8
- package/dist/extras.cjs +32 -31
- package/dist/extras.js +22 -22
- package/dist/index.cjs +50 -20
- package/dist/index.d.cts +20 -7
- package/dist/index.d.ts +20 -7
- package/dist/index.js +17 -13
- package/dist/motion.cjs +1 -1
- package/dist/motion.js +3 -3
- package/dist/patterns.cjs +21 -15
- package/dist/patterns.js +6 -6
- package/dist/performance.cjs +21 -15
- package/dist/performance.js +6 -6
- package/dist/plugins.cjs +110 -103
- package/dist/plugins.js +95 -94
- package/dist/{ssr-6D67RAVB.js → ssr-2PPULEK2.js} +2 -2
- package/dist/ssr.cjs +21 -15
- package/dist/ssr.js +9 -9
- package/dist/testing.cjs +21 -15
- package/dist/testing.js +3 -3
- package/dist/ui.cjs +36 -34
- package/dist/ui.js +8 -8
- package/dist/widgets.cjs +21 -15
- package/dist/widgets.js +7 -7
- package/package.json +1 -1
- package/dist/chunk-YT6HQ6AM.js +0 -14
package/dist/plugins.cjs
CHANGED
|
@@ -140,6 +140,25 @@ var init_sanitize = __esm({
|
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
// src/core/ssr-context.ts
|
|
143
|
+
function detectSSRShared() {
|
|
144
|
+
let detected = null;
|
|
145
|
+
try {
|
|
146
|
+
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
147
|
+
let mod = null;
|
|
148
|
+
const getBuiltin = process.getBuiltinModule;
|
|
149
|
+
if (typeof getBuiltin === "function") {
|
|
150
|
+
mod = getBuiltin("node:async_hooks");
|
|
151
|
+
} else {
|
|
152
|
+
const req = Function("return typeof require==='function'?require:null")();
|
|
153
|
+
if (req) mod = req("node:async_hooks");
|
|
154
|
+
}
|
|
155
|
+
if (mod) detected = new mod.AsyncLocalStorage();
|
|
156
|
+
}
|
|
157
|
+
} catch {
|
|
158
|
+
detected = null;
|
|
159
|
+
}
|
|
160
|
+
return { als: detected, fallbackStore: { ssr: false, suspenseIdCounter: 0 } };
|
|
161
|
+
}
|
|
143
162
|
function getSSRStore() {
|
|
144
163
|
if (als) {
|
|
145
164
|
const s2 = als.getStore();
|
|
@@ -150,27 +169,14 @@ function getSSRStore() {
|
|
|
150
169
|
function isSSR() {
|
|
151
170
|
return getSSRStore().ssr;
|
|
152
171
|
}
|
|
153
|
-
var als, fallbackStore;
|
|
172
|
+
var SSR_KEY, _shared, als, fallbackStore;
|
|
154
173
|
var init_ssr_context = __esm({
|
|
155
174
|
"src/core/ssr-context.ts"() {
|
|
156
175
|
"use strict";
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const getBuiltin = process.getBuiltinModule;
|
|
162
|
-
if (typeof getBuiltin === "function") {
|
|
163
|
-
mod = getBuiltin("node:async_hooks");
|
|
164
|
-
} else {
|
|
165
|
-
const req = Function("return typeof require==='function'?require:null")();
|
|
166
|
-
if (req) mod = req("node:async_hooks");
|
|
167
|
-
}
|
|
168
|
-
if (mod) als = new mod.AsyncLocalStorage();
|
|
169
|
-
}
|
|
170
|
-
} catch {
|
|
171
|
-
als = null;
|
|
172
|
-
}
|
|
173
|
-
fallbackStore = { ssr: false, suspenseIdCounter: 0 };
|
|
176
|
+
SSR_KEY = /* @__PURE__ */ Symbol.for("sibujs.ssr.v1");
|
|
177
|
+
_shared = globalThis[SSR_KEY] ?? (globalThis[SSR_KEY] = detectSSRShared());
|
|
178
|
+
als = _shared.als;
|
|
179
|
+
fallbackStore = _shared.fallbackStore;
|
|
174
180
|
}
|
|
175
181
|
});
|
|
176
182
|
|
|
@@ -1222,7 +1228,7 @@ function forEachSubscriber(signal2, visit) {
|
|
|
1222
1228
|
|
|
1223
1229
|
// src/reactivity/track.ts
|
|
1224
1230
|
var _isDev3 = isDev();
|
|
1225
|
-
var _runtimeVersion =
|
|
1231
|
+
var _runtimeVersion = true ? "3.3.2" : "dev";
|
|
1226
1232
|
var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
|
|
1227
1233
|
function resolveReactiveApi() {
|
|
1228
1234
|
const g2 = globalThis;
|
|
@@ -2900,7 +2906,8 @@ var NavigationFailureError = class extends Error {
|
|
|
2900
2906
|
};
|
|
2901
2907
|
}
|
|
2902
2908
|
};
|
|
2903
|
-
var
|
|
2909
|
+
var ROUTER_KEY = /* @__PURE__ */ Symbol.for("sibujs.router.v1");
|
|
2910
|
+
var _routerRef = globalThis[ROUTER_KEY] ?? (globalThis[ROUTER_KEY] = { current: null });
|
|
2904
2911
|
function normalizeRoutes(routes) {
|
|
2905
2912
|
return routes.map((route2) => {
|
|
2906
2913
|
const normalizedChildren = route2.children && route2.children.length > 0 ? normalizeRoutes(route2.children) : route2.children;
|
|
@@ -2920,8 +2927,8 @@ function normalizeRoutes(routes) {
|
|
|
2920
2927
|
});
|
|
2921
2928
|
}
|
|
2922
2929
|
function createRouter(routesOrOptions, options = {}) {
|
|
2923
|
-
if (
|
|
2924
|
-
|
|
2930
|
+
if (_routerRef.current) {
|
|
2931
|
+
_routerRef.current.destroy();
|
|
2925
2932
|
}
|
|
2926
2933
|
let routes;
|
|
2927
2934
|
if (Array.isArray(routesOrOptions)) {
|
|
@@ -2930,69 +2937,69 @@ function createRouter(routesOrOptions, options = {}) {
|
|
|
2930
2937
|
options = routesOrOptions;
|
|
2931
2938
|
routes = [];
|
|
2932
2939
|
}
|
|
2933
|
-
|
|
2940
|
+
_routerRef.current = new SibuRouter(routes, options);
|
|
2934
2941
|
ensureRouterPagehide();
|
|
2935
|
-
return
|
|
2942
|
+
return _routerRef.current;
|
|
2936
2943
|
}
|
|
2937
2944
|
function setRoutes(routes) {
|
|
2938
|
-
if (!
|
|
2939
|
-
|
|
2945
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
2946
|
+
_routerRef.current.updateRoutes(normalizeRoutes(routes));
|
|
2940
2947
|
}
|
|
2941
2948
|
function route() {
|
|
2942
|
-
if (!
|
|
2943
|
-
return
|
|
2949
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
2950
|
+
return _routerRef.current.currentRoute;
|
|
2944
2951
|
}
|
|
2945
2952
|
function router() {
|
|
2946
|
-
if (!
|
|
2953
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
2947
2954
|
return {
|
|
2948
|
-
currentRoute:
|
|
2949
|
-
isReady:
|
|
2950
|
-
isNavigating:
|
|
2951
|
-
push: (to) =>
|
|
2952
|
-
replace: (to) =>
|
|
2953
|
-
go: (delta) =>
|
|
2954
|
-
back: () =>
|
|
2955
|
-
forward: () =>
|
|
2956
|
-
beforeEach: (guard) =>
|
|
2957
|
-
beforeResolve: (guard) =>
|
|
2958
|
-
afterEach: (hook) =>
|
|
2955
|
+
currentRoute: _routerRef.current.currentRoute,
|
|
2956
|
+
isReady: _routerRef.current.isReady,
|
|
2957
|
+
isNavigating: _routerRef.current.isNavigating,
|
|
2958
|
+
push: (to) => _routerRef.current?.push(to),
|
|
2959
|
+
replace: (to) => _routerRef.current?.replace(to),
|
|
2960
|
+
go: (delta) => _routerRef.current?.go(delta),
|
|
2961
|
+
back: () => _routerRef.current?.back(),
|
|
2962
|
+
forward: () => _routerRef.current?.forward(),
|
|
2963
|
+
beforeEach: (guard) => _routerRef.current?.beforeEach(guard),
|
|
2964
|
+
beforeResolve: (guard) => _routerRef.current?.beforeResolve(guard),
|
|
2965
|
+
afterEach: (hook) => _routerRef.current?.afterEach(hook)
|
|
2959
2966
|
};
|
|
2960
2967
|
}
|
|
2961
2968
|
function navigate(to, options) {
|
|
2962
|
-
if (!
|
|
2963
|
-
return
|
|
2969
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
2970
|
+
return _routerRef.current.navigate(to, options);
|
|
2964
2971
|
}
|
|
2965
2972
|
function push(to) {
|
|
2966
|
-
if (!
|
|
2967
|
-
return
|
|
2973
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
2974
|
+
return _routerRef.current.push(to);
|
|
2968
2975
|
}
|
|
2969
2976
|
function replace(to) {
|
|
2970
|
-
if (!
|
|
2971
|
-
return
|
|
2977
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
2978
|
+
return _routerRef.current.replace(to);
|
|
2972
2979
|
}
|
|
2973
2980
|
function go(delta) {
|
|
2974
|
-
if (!
|
|
2975
|
-
|
|
2981
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
2982
|
+
_routerRef.current.go(delta);
|
|
2976
2983
|
}
|
|
2977
2984
|
function back() {
|
|
2978
|
-
if (!
|
|
2979
|
-
|
|
2985
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
2986
|
+
_routerRef.current.back();
|
|
2980
2987
|
}
|
|
2981
2988
|
function forward() {
|
|
2982
|
-
if (!
|
|
2983
|
-
|
|
2989
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
2990
|
+
_routerRef.current.forward();
|
|
2984
2991
|
}
|
|
2985
2992
|
function beforeEach(guard) {
|
|
2986
|
-
if (!
|
|
2987
|
-
return
|
|
2993
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
2994
|
+
return _routerRef.current.beforeEach(guard);
|
|
2988
2995
|
}
|
|
2989
2996
|
function beforeResolve(guard) {
|
|
2990
|
-
if (!
|
|
2991
|
-
return
|
|
2997
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
2998
|
+
return _routerRef.current.beforeResolve(guard);
|
|
2992
2999
|
}
|
|
2993
3000
|
function afterEach(hook) {
|
|
2994
|
-
if (!
|
|
2995
|
-
return
|
|
3001
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
3002
|
+
return _routerRef.current.afterEach(hook);
|
|
2996
3003
|
}
|
|
2997
3004
|
var routeCleanups = [];
|
|
2998
3005
|
function Route() {
|
|
@@ -3066,8 +3073,8 @@ function Route() {
|
|
|
3066
3073
|
retryButton.className = "route-error-retry";
|
|
3067
3074
|
retryButton.type = "button";
|
|
3068
3075
|
const onRetryClick = () => {
|
|
3069
|
-
if (
|
|
3070
|
-
|
|
3076
|
+
if (_routerRef.current) {
|
|
3077
|
+
_routerRef.current.clearErrorCache();
|
|
3071
3078
|
update();
|
|
3072
3079
|
}
|
|
3073
3080
|
};
|
|
@@ -3079,11 +3086,11 @@ function Route() {
|
|
|
3079
3086
|
anchor.parentNode.insertBefore(errorNode, anchor.nextSibling);
|
|
3080
3087
|
};
|
|
3081
3088
|
const update = async () => {
|
|
3082
|
-
if (!
|
|
3089
|
+
if (!_routerRef.current) return;
|
|
3083
3090
|
const seq = ++navSeq;
|
|
3084
|
-
const route2 =
|
|
3091
|
+
const route2 = _routerRef.current.currentRoute;
|
|
3085
3092
|
try {
|
|
3086
|
-
const match =
|
|
3093
|
+
const match = _routerRef.current["matcher"].match(route2.path);
|
|
3087
3094
|
if (!match) {
|
|
3088
3095
|
currentTopRoute = null;
|
|
3089
3096
|
cleanupNodes();
|
|
@@ -3096,7 +3103,7 @@ function Route() {
|
|
|
3096
3103
|
if ("redirect" in routeDef) {
|
|
3097
3104
|
const redirectPath = typeof routeDef.redirect === "function" ? routeDef.redirect(route2) : routeDef.redirect;
|
|
3098
3105
|
queueMicrotask(() => {
|
|
3099
|
-
|
|
3106
|
+
_routerRef.current?.navigate(redirectPath).catch((err) => {
|
|
3100
3107
|
if (typeof console !== "undefined") console.error("[router] redirect failed:", err);
|
|
3101
3108
|
});
|
|
3102
3109
|
});
|
|
@@ -3108,7 +3115,7 @@ function Route() {
|
|
|
3108
3115
|
if (isAsync) {
|
|
3109
3116
|
showLoading();
|
|
3110
3117
|
}
|
|
3111
|
-
const component = await
|
|
3118
|
+
const component = await _routerRef.current.loadComponent(routeDef, route2.path);
|
|
3112
3119
|
if (seq !== navSeq) return;
|
|
3113
3120
|
const node = component();
|
|
3114
3121
|
if (node && anchor.parentNode) {
|
|
@@ -3149,11 +3156,11 @@ function Route() {
|
|
|
3149
3156
|
return anchor;
|
|
3150
3157
|
}
|
|
3151
3158
|
function KeepAliveRoute(options) {
|
|
3152
|
-
if (!
|
|
3159
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
3153
3160
|
const anchor = document.createComment("keep-alive-route");
|
|
3154
3161
|
const cache = /* @__PURE__ */ new Map();
|
|
3155
3162
|
const lruOrder = [];
|
|
3156
|
-
const routerOpts =
|
|
3163
|
+
const routerOpts = _routerRef.current["options"];
|
|
3157
3164
|
const keepAliveOpt = routerOpts.keepAlive;
|
|
3158
3165
|
const maxCache = options?.max ?? (typeof keepAliveOpt === "number" ? keepAliveOpt : 20);
|
|
3159
3166
|
const includeNames = options?.include ?? (Array.isArray(keepAliveOpt) ? keepAliveOpt : void 0);
|
|
@@ -3163,19 +3170,19 @@ function KeepAliveRoute(options) {
|
|
|
3163
3170
|
let isUpdating = false;
|
|
3164
3171
|
let pendingUpdate = false;
|
|
3165
3172
|
const update = async () => {
|
|
3166
|
-
if (!
|
|
3173
|
+
if (!_routerRef.current) return;
|
|
3167
3174
|
if (isUpdating) {
|
|
3168
3175
|
pendingUpdate = true;
|
|
3169
3176
|
return;
|
|
3170
3177
|
}
|
|
3171
|
-
const route2 =
|
|
3172
|
-
const match =
|
|
3178
|
+
const route2 = _routerRef.current.currentRoute;
|
|
3179
|
+
const match = _routerRef.current["matcher"].match(route2.path);
|
|
3173
3180
|
if (!match) return;
|
|
3174
3181
|
const { route: routeDef } = match;
|
|
3175
3182
|
if ("redirect" in routeDef) {
|
|
3176
3183
|
const redirectPath = typeof routeDef.redirect === "function" ? routeDef.redirect(route2) : routeDef.redirect;
|
|
3177
3184
|
queueMicrotask(() => {
|
|
3178
|
-
|
|
3185
|
+
_routerRef.current?.navigate(redirectPath).catch((err) => {
|
|
3179
3186
|
if (typeof console !== "undefined") console.error("[router] redirect failed:", err);
|
|
3180
3187
|
});
|
|
3181
3188
|
});
|
|
@@ -3208,9 +3215,9 @@ function KeepAliveRoute(options) {
|
|
|
3208
3215
|
}
|
|
3209
3216
|
lruOrder.push(cacheKey);
|
|
3210
3217
|
} else {
|
|
3211
|
-
const component = await
|
|
3218
|
+
const component = await _routerRef.current.loadComponent(routeDef, route2.path);
|
|
3212
3219
|
const node = component();
|
|
3213
|
-
if (!node || route2.path !==
|
|
3220
|
+
if (!node || route2.path !== _routerRef.current.currentRoute.path) {
|
|
3214
3221
|
isUpdating = false;
|
|
3215
3222
|
return;
|
|
3216
3223
|
}
|
|
@@ -3269,11 +3276,11 @@ function KeepAliveRoute(options) {
|
|
|
3269
3276
|
return anchor;
|
|
3270
3277
|
}
|
|
3271
3278
|
function RouterLink(props) {
|
|
3272
|
-
if (!
|
|
3279
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
3273
3280
|
const { to, replace: replace2 = false, activeClass, exactActiveClass, nodes, target, rel, class: classAttr, ...attrs } = props;
|
|
3274
3281
|
const baseClass = typeof classAttr === "string" ? classAttr : "";
|
|
3275
|
-
const routeGetter =
|
|
3276
|
-
const rawHref =
|
|
3282
|
+
const routeGetter = _routerRef.current.routeGetter;
|
|
3283
|
+
const rawHref = _routerRef.current["resolvePath"](to);
|
|
3277
3284
|
const href = isSafeNavigationTarget(rawHref) ? rawHref : "#";
|
|
3278
3285
|
const hrefPath = href.split("?")[0].split("#")[0];
|
|
3279
3286
|
const link2 = document.createElement("a");
|
|
@@ -3288,7 +3295,7 @@ function RouterLink(props) {
|
|
|
3288
3295
|
} else if (rel) {
|
|
3289
3296
|
link2.rel = rel;
|
|
3290
3297
|
}
|
|
3291
|
-
const options =
|
|
3298
|
+
const options = _routerRef.current["options"];
|
|
3292
3299
|
const effectCleanup = effect(() => {
|
|
3293
3300
|
const route2 = routeGetter();
|
|
3294
3301
|
const isActive = route2.path.startsWith(hrefPath);
|
|
@@ -3338,7 +3345,7 @@ function RouterLink(props) {
|
|
|
3338
3345
|
return;
|
|
3339
3346
|
}
|
|
3340
3347
|
e.preventDefault();
|
|
3341
|
-
|
|
3348
|
+
_routerRef.current?.navigate(to, { replace: replace2 }).catch((err) => {
|
|
3342
3349
|
if (typeof console !== "undefined") console.error("[router] link navigate failed:", err);
|
|
3343
3350
|
});
|
|
3344
3351
|
};
|
|
@@ -3424,35 +3431,35 @@ function lazy(importFn) {
|
|
|
3424
3431
|
return importFn;
|
|
3425
3432
|
}
|
|
3426
3433
|
async function preloadRoute(to) {
|
|
3427
|
-
if (!
|
|
3428
|
-
const path2 =
|
|
3429
|
-
const match =
|
|
3434
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
3435
|
+
const path2 = _routerRef.current["resolvePath"](to);
|
|
3436
|
+
const match = _routerRef.current["matcher"].match(path2.split("?")[0].split("#")[0]);
|
|
3430
3437
|
if (match && "component" in match.route) {
|
|
3431
3438
|
try {
|
|
3432
|
-
await
|
|
3439
|
+
await _routerRef.current.loadComponent(match.route, path2);
|
|
3433
3440
|
} catch (error) {
|
|
3434
3441
|
console.warn("[Router] Preload failed:", error);
|
|
3435
3442
|
}
|
|
3436
3443
|
}
|
|
3437
3444
|
}
|
|
3438
3445
|
function hasRoute(name) {
|
|
3439
|
-
if (!
|
|
3440
|
-
return
|
|
3446
|
+
if (!_routerRef.current) return false;
|
|
3447
|
+
return _routerRef.current["matcher"].findByName(name) !== null;
|
|
3441
3448
|
}
|
|
3442
3449
|
function getRouteInfo(name) {
|
|
3443
|
-
if (!
|
|
3444
|
-
return
|
|
3450
|
+
if (!_routerRef.current) return null;
|
|
3451
|
+
return _routerRef.current["matcher"].findByName(name);
|
|
3445
3452
|
}
|
|
3446
3453
|
function buildURL(to) {
|
|
3447
|
-
if (!
|
|
3448
|
-
return
|
|
3454
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
3455
|
+
return _routerRef.current["resolvePath"](to);
|
|
3449
3456
|
}
|
|
3450
3457
|
function destroyRouter() {
|
|
3451
3458
|
for (const fn of routeCleanups) fn();
|
|
3452
3459
|
routeCleanups.length = 0;
|
|
3453
|
-
if (
|
|
3454
|
-
|
|
3455
|
-
|
|
3460
|
+
if (_routerRef.current) {
|
|
3461
|
+
_routerRef.current.destroy();
|
|
3462
|
+
_routerRef.current = null;
|
|
3456
3463
|
}
|
|
3457
3464
|
}
|
|
3458
3465
|
var _routerPagehideHandler = null;
|
|
@@ -3485,9 +3492,9 @@ function Outlet() {
|
|
|
3485
3492
|
currentChild = null;
|
|
3486
3493
|
};
|
|
3487
3494
|
const update = async () => {
|
|
3488
|
-
if (!
|
|
3495
|
+
if (!_routerRef.current) return;
|
|
3489
3496
|
const seq = ++navSeq;
|
|
3490
|
-
const route2 =
|
|
3497
|
+
const route2 = _routerRef.current.currentRoute;
|
|
3491
3498
|
if (route2.matched.length < 2) {
|
|
3492
3499
|
clearCurrent();
|
|
3493
3500
|
return;
|
|
@@ -3500,7 +3507,7 @@ function Outlet() {
|
|
|
3500
3507
|
if (childRoute === currentChild && currentNode) return;
|
|
3501
3508
|
try {
|
|
3502
3509
|
const cacheKey = `${route2.path}\0${childRoute.path}`;
|
|
3503
|
-
const component = await
|
|
3510
|
+
const component = await _routerRef.current.loadComponent(childRoute, cacheKey);
|
|
3504
3511
|
if (seq !== navSeq) return;
|
|
3505
3512
|
const node = component();
|
|
3506
3513
|
if (node && anchor.parentNode) {
|
|
@@ -3531,16 +3538,16 @@ function Outlet() {
|
|
|
3531
3538
|
return anchor;
|
|
3532
3539
|
}
|
|
3533
3540
|
function addRoute(route2, parentPath) {
|
|
3534
|
-
if (!
|
|
3535
|
-
|
|
3541
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
3542
|
+
_routerRef.current.addRoute(route2, parentPath);
|
|
3536
3543
|
}
|
|
3537
3544
|
function removeRoute(path2) {
|
|
3538
|
-
if (!
|
|
3539
|
-
|
|
3545
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
3546
|
+
_routerRef.current.removeRoute(path2);
|
|
3540
3547
|
}
|
|
3541
3548
|
function routerState() {
|
|
3542
|
-
if (!
|
|
3543
|
-
const router2 =
|
|
3549
|
+
if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
|
|
3550
|
+
const router2 = _routerRef.current;
|
|
3544
3551
|
return {
|
|
3545
3552
|
currentPath: () => router2.currentRoute.path,
|
|
3546
3553
|
params: () => router2.currentRoute.params,
|
|
@@ -3554,12 +3561,12 @@ function routerState() {
|
|
|
3554
3561
|
var routerPlugins = [];
|
|
3555
3562
|
function routerPlugin(plugin2) {
|
|
3556
3563
|
routerPlugins.push(plugin2);
|
|
3557
|
-
if (
|
|
3564
|
+
if (_routerRef.current?.isReady && plugin2.onReady) {
|
|
3558
3565
|
plugin2.onReady();
|
|
3559
3566
|
}
|
|
3560
3567
|
let removeGuard = null;
|
|
3561
|
-
if (
|
|
3562
|
-
removeGuard =
|
|
3568
|
+
if (_routerRef.current && plugin2.onNavigate) {
|
|
3569
|
+
removeGuard = _routerRef.current.afterEach((to, from) => {
|
|
3563
3570
|
plugin2.onNavigate?.(to, from);
|
|
3564
3571
|
});
|
|
3565
3572
|
}
|