@rpcbase/router 0.112.0 → 0.114.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/index.js +935 -779
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,820 +1,976 @@
|
|
|
1
|
-
import { Link as Link$1,
|
|
2
|
-
import { c } from "react/compiler-runtime";
|
|
3
|
-
import { createContext, forwardRef, useContext, useEffect, useRef } from "react";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { UNSAFE_DataRouterContext, matchRoutes, Link as Link$1, useLocation, useNavigate } from "react-router";
|
|
5
2
|
export * from "react-router";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { createContext, useContext, useRef, forwardRef, useEffect } from "react";
|
|
6
|
+
const ROUTE_MODULE_IMPORTER_HANDLE = "__rpcbaseRouteModuleImporter";
|
|
7
|
+
const ROUTE_PREFETCH_DATA_HANDLE = "prefetchData";
|
|
8
|
+
const isHandleObject = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
9
|
+
const getRouteModuleImporterFromHandle = (handle) => {
|
|
10
|
+
if (!isHandleObject(handle)) return null;
|
|
11
|
+
const importer = handle[ROUTE_MODULE_IMPORTER_HANDLE];
|
|
12
|
+
return typeof importer === "function" ? importer : null;
|
|
14
13
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const getRoutePrefetchDataFromHandle = (handle, key = ROUTE_PREFETCH_DATA_HANDLE) => {
|
|
15
|
+
if (!isHandleObject(handle)) return void 0;
|
|
16
|
+
const value = handle[key];
|
|
17
|
+
return typeof value === "boolean" ? value : void 0;
|
|
19
18
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
const mergeRouteHandle = (handle, {
|
|
20
|
+
importer,
|
|
21
|
+
prefetchData,
|
|
22
|
+
prefetchDataKey = ROUTE_PREFETCH_DATA_HANDLE
|
|
23
|
+
}) => {
|
|
24
|
+
const nextHandle = isHandleObject(handle) ? {
|
|
25
|
+
...handle
|
|
26
|
+
} : {};
|
|
27
|
+
if (importer) {
|
|
28
|
+
nextHandle[ROUTE_MODULE_IMPORTER_HANDLE] = importer;
|
|
29
|
+
}
|
|
30
|
+
if (typeof prefetchData === "boolean") {
|
|
31
|
+
nextHandle[prefetchDataKey] = prefetchData;
|
|
32
|
+
}
|
|
33
|
+
return nextHandle;
|
|
25
34
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
prefetchData: noop
|
|
34
|
-
});
|
|
35
|
-
var normalizeHref = (href) => {
|
|
36
|
-
if (typeof window === "undefined") return null;
|
|
37
|
-
try {
|
|
38
|
-
const url = new URL(href, window.location.origin);
|
|
39
|
-
if (url.origin !== window.location.origin) return null;
|
|
40
|
-
return {
|
|
41
|
-
pathWithSearch: `${url.pathname}${url.search}`,
|
|
42
|
-
pathname: url.pathname,
|
|
43
|
-
search: url.search,
|
|
44
|
-
hash: url.hash
|
|
45
|
-
};
|
|
46
|
-
} catch {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
35
|
+
const noop = async () => {
|
|
36
|
+
};
|
|
37
|
+
const DEFAULT_PREFETCH_API = {
|
|
38
|
+
defaultPrefetch: "none",
|
|
39
|
+
prefetch: noop,
|
|
40
|
+
prefetchCode: noop,
|
|
41
|
+
prefetchData: noop
|
|
49
42
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
const RoutePrefetchContext = createContext(DEFAULT_PREFETCH_API);
|
|
44
|
+
const normalizeHref = (href) => {
|
|
45
|
+
if (typeof window === "undefined") return null;
|
|
46
|
+
try {
|
|
47
|
+
const url = new URL(href, window.location.origin);
|
|
48
|
+
if (url.origin !== window.location.origin) return null;
|
|
49
|
+
return {
|
|
50
|
+
pathWithSearch: `${url.pathname}${url.search}`,
|
|
51
|
+
pathname: url.pathname,
|
|
52
|
+
search: url.search,
|
|
53
|
+
hash: url.hash
|
|
54
|
+
};
|
|
55
|
+
} catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
54
58
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
const pruneDataCache = (cache, now) => {
|
|
60
|
+
cache.forEach((value, key) => {
|
|
61
|
+
if (value.expiresAt <= now) {
|
|
62
|
+
cache.delete(key);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
60
65
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
t4 = /* @__PURE__ */ new Map();
|
|
71
|
-
$[0] = t4;
|
|
72
|
-
} else t4 = $[0];
|
|
73
|
-
const routeModuleCacheRef = useRef(t4);
|
|
74
|
-
let t5;
|
|
75
|
-
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
76
|
-
t5 = /* @__PURE__ */ new Map();
|
|
77
|
-
$[1] = t5;
|
|
78
|
-
} else t5 = $[1];
|
|
79
|
-
const routeDataCacheRef = useRef(t5);
|
|
80
|
-
let t6;
|
|
81
|
-
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
82
|
-
t6 = async (route) => {
|
|
83
|
-
const routeId = route.id;
|
|
84
|
-
if (!routeId) return null;
|
|
85
|
-
const cached = routeModuleCacheRef.current.get(routeId);
|
|
86
|
-
if (cached) return cached;
|
|
87
|
-
const lazyRouteLoader = typeof route.lazy === "function" ? route.lazy : null;
|
|
88
|
-
const routeModuleImporter = getRouteModuleImporterFromHandle(route.handle);
|
|
89
|
-
if (!lazyRouteLoader && !routeModuleImporter) return null;
|
|
90
|
-
const prefetchPromise = Promise.resolve(lazyRouteLoader ? lazyRouteLoader() : routeModuleImporter()).then(_temp$2).catch((error) => {
|
|
91
|
-
routeModuleCacheRef.current.delete(routeId);
|
|
92
|
-
throw error;
|
|
93
|
-
});
|
|
94
|
-
routeModuleCacheRef.current.set(routeId, prefetchPromise);
|
|
95
|
-
return prefetchPromise;
|
|
96
|
-
};
|
|
97
|
-
$[2] = t6;
|
|
98
|
-
} else t6 = $[2];
|
|
99
|
-
const prefetchRouteModule = t6;
|
|
100
|
-
let t7;
|
|
101
|
-
if ($[3] !== dataPrefetchTtlMs) {
|
|
102
|
-
t7 = async (router, route_0, href) => {
|
|
103
|
-
const routeId_0 = route_0.id;
|
|
104
|
-
if (!routeId_0) return;
|
|
105
|
-
const now = Date.now();
|
|
106
|
-
pruneDataCache(routeDataCacheRef.current, now);
|
|
107
|
-
const cacheKey = `${routeId_0}|${href}`;
|
|
108
|
-
const cached_0 = routeDataCacheRef.current.get(cacheKey);
|
|
109
|
-
if (cached_0 && cached_0.expiresAt > now) {
|
|
110
|
-
await cached_0.promise;
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
let hasLoader = typeof route_0.loader === "function";
|
|
114
|
-
if (!hasLoader) hasLoader = typeof (await prefetchRouteModule(route_0).catch(_temp2$1))?.loader === "function";
|
|
115
|
-
if (!hasLoader) return;
|
|
116
|
-
const fetcherKey = `rb:prefetch:${routeId_0}:${href}`;
|
|
117
|
-
const prefetchPromise_0 = Promise.resolve(router.fetch(fetcherKey, routeId_0, href)).catch((error_0) => {
|
|
118
|
-
routeDataCacheRef.current.delete(cacheKey);
|
|
119
|
-
throw error_0;
|
|
120
|
-
}).finally(() => {
|
|
121
|
-
try {
|
|
122
|
-
router.deleteFetcher(fetcherKey);
|
|
123
|
-
} catch {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
const ttl = Math.max(1, dataPrefetchTtlMs);
|
|
128
|
-
routeDataCacheRef.current.set(cacheKey, {
|
|
129
|
-
expiresAt: now + ttl,
|
|
130
|
-
promise: prefetchPromise_0
|
|
131
|
-
});
|
|
132
|
-
await prefetchPromise_0;
|
|
133
|
-
};
|
|
134
|
-
$[3] = dataPrefetchTtlMs;
|
|
135
|
-
$[4] = t7;
|
|
136
|
-
} else t7 = $[4];
|
|
137
|
-
const prefetchRouteData = t7;
|
|
138
|
-
let t8;
|
|
139
|
-
if ($[5] !== dataPrefetchHandleKey || $[6] !== dataRouterContext?.router || $[7] !== prefetchRouteData) {
|
|
140
|
-
t8 = async (href_0, opts) => {
|
|
141
|
-
const normalized = normalizeHref(href_0);
|
|
142
|
-
if (!normalized) return;
|
|
143
|
-
const currentPathWithSearch = typeof window === "undefined" ? "" : `${window.location.pathname}${window.location.search}`;
|
|
144
|
-
if (normalized.pathWithSearch === currentPathWithSearch) return;
|
|
145
|
-
const router_0 = dataRouterContext?.router;
|
|
146
|
-
if (!router_0) return;
|
|
147
|
-
const matches = matchRoutes(router_0.routes, {
|
|
148
|
-
pathname: normalized.pathname,
|
|
149
|
-
search: normalized.search,
|
|
150
|
-
hash: normalized.hash
|
|
151
|
-
}, router_0.basename);
|
|
152
|
-
if (!matches || matches.length === 0) return;
|
|
153
|
-
const matchedRoutes = matches.map(_temp3);
|
|
154
|
-
if (opts?.prefetchCode !== false) await Promise.all(matchedRoutes.map(async (route_1) => {
|
|
155
|
-
try {
|
|
156
|
-
await prefetchRouteModule(route_1);
|
|
157
|
-
} catch {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
}));
|
|
161
|
-
await Promise.all(matchedRoutes.map(async (route_2) => {
|
|
162
|
-
if (!resolveDataPrefetchFlag(route_2, opts?.prefetchData, dataPrefetchHandleKey)) return;
|
|
163
|
-
try {
|
|
164
|
-
await prefetchRouteData(router_0, route_2, normalized.pathWithSearch);
|
|
165
|
-
} catch {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
}));
|
|
169
|
-
};
|
|
170
|
-
$[5] = dataPrefetchHandleKey;
|
|
171
|
-
$[6] = dataRouterContext?.router;
|
|
172
|
-
$[7] = prefetchRouteData;
|
|
173
|
-
$[8] = t8;
|
|
174
|
-
} else t8 = $[8];
|
|
175
|
-
const prefetch = t8;
|
|
176
|
-
let t10;
|
|
177
|
-
let t9;
|
|
178
|
-
if ($[9] !== prefetch) {
|
|
179
|
-
t9 = async (href_1) => prefetch(href_1, {
|
|
180
|
-
prefetchCode: true,
|
|
181
|
-
prefetchData: false
|
|
182
|
-
});
|
|
183
|
-
t10 = async (href_2) => prefetch(href_2, {
|
|
184
|
-
prefetchCode: false,
|
|
185
|
-
prefetchData: true
|
|
186
|
-
});
|
|
187
|
-
$[9] = prefetch;
|
|
188
|
-
$[10] = t10;
|
|
189
|
-
$[11] = t9;
|
|
190
|
-
} else {
|
|
191
|
-
t10 = $[10];
|
|
192
|
-
t9 = $[11];
|
|
193
|
-
}
|
|
194
|
-
let t11;
|
|
195
|
-
if ($[12] !== defaultPrefetch || $[13] !== prefetch || $[14] !== t10 || $[15] !== t9) {
|
|
196
|
-
t11 = {
|
|
197
|
-
defaultPrefetch,
|
|
198
|
-
prefetch,
|
|
199
|
-
prefetchCode: t9,
|
|
200
|
-
prefetchData: t10
|
|
201
|
-
};
|
|
202
|
-
$[12] = defaultPrefetch;
|
|
203
|
-
$[13] = prefetch;
|
|
204
|
-
$[14] = t10;
|
|
205
|
-
$[15] = t9;
|
|
206
|
-
$[16] = t11;
|
|
207
|
-
} else t11 = $[16];
|
|
208
|
-
let t12;
|
|
209
|
-
if ($[17] !== children || $[18] !== t11) {
|
|
210
|
-
t12 = /* @__PURE__ */ jsx(RoutePrefetchContext.Provider, {
|
|
211
|
-
value: t11,
|
|
212
|
-
children
|
|
213
|
-
});
|
|
214
|
-
$[17] = children;
|
|
215
|
-
$[18] = t11;
|
|
216
|
-
$[19] = t12;
|
|
217
|
-
} else t12 = $[19];
|
|
218
|
-
return t12;
|
|
66
|
+
const resolveDataPrefetchFlag = (route, explicitPrefetchData, dataPrefetchHandleKey) => {
|
|
67
|
+
if (typeof explicitPrefetchData === "boolean") {
|
|
68
|
+
return explicitPrefetchData;
|
|
69
|
+
}
|
|
70
|
+
const routeHandlePrefetchData = getRoutePrefetchDataFromHandle(route.handle, dataPrefetchHandleKey);
|
|
71
|
+
if (typeof routeHandlePrefetchData === "boolean") {
|
|
72
|
+
return routeHandlePrefetchData;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
219
75
|
};
|
|
220
|
-
|
|
221
|
-
|
|
76
|
+
const RoutePrefetchProvider = (t0) => {
|
|
77
|
+
const $ = c(20);
|
|
78
|
+
const {
|
|
79
|
+
children,
|
|
80
|
+
defaultPrefetch: t1,
|
|
81
|
+
dataPrefetchTtlMs: t2,
|
|
82
|
+
dataPrefetchHandleKey: t3
|
|
83
|
+
} = t0;
|
|
84
|
+
const defaultPrefetch = t1 === void 0 ? "intent" : t1;
|
|
85
|
+
const dataPrefetchTtlMs = t2 === void 0 ? 3e4 : t2;
|
|
86
|
+
const dataPrefetchHandleKey = t3 === void 0 ? ROUTE_PREFETCH_DATA_HANDLE : t3;
|
|
87
|
+
const dataRouterContext = useContext(UNSAFE_DataRouterContext);
|
|
88
|
+
let t4;
|
|
89
|
+
if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
90
|
+
t4 = /* @__PURE__ */ new Map();
|
|
91
|
+
$[0] = t4;
|
|
92
|
+
} else {
|
|
93
|
+
t4 = $[0];
|
|
94
|
+
}
|
|
95
|
+
const routeModuleCacheRef = useRef(t4);
|
|
96
|
+
let t5;
|
|
97
|
+
if ($[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
98
|
+
t5 = /* @__PURE__ */ new Map();
|
|
99
|
+
$[1] = t5;
|
|
100
|
+
} else {
|
|
101
|
+
t5 = $[1];
|
|
102
|
+
}
|
|
103
|
+
const routeDataCacheRef = useRef(t5);
|
|
104
|
+
let t6;
|
|
105
|
+
if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
106
|
+
t6 = async (route) => {
|
|
107
|
+
const routeId = route.id;
|
|
108
|
+
if (!routeId) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
const cached = routeModuleCacheRef.current.get(routeId);
|
|
112
|
+
if (cached) {
|
|
113
|
+
return cached;
|
|
114
|
+
}
|
|
115
|
+
const lazyRouteLoader = typeof route.lazy === "function" ? route.lazy : null;
|
|
116
|
+
const routeModuleImporter = getRouteModuleImporterFromHandle(route.handle);
|
|
117
|
+
if (!lazyRouteLoader && !routeModuleImporter) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
const prefetchPromise = Promise.resolve(lazyRouteLoader ? lazyRouteLoader() : routeModuleImporter()).then(_temp$2).catch((error) => {
|
|
121
|
+
routeModuleCacheRef.current.delete(routeId);
|
|
122
|
+
throw error;
|
|
123
|
+
});
|
|
124
|
+
routeModuleCacheRef.current.set(routeId, prefetchPromise);
|
|
125
|
+
return prefetchPromise;
|
|
126
|
+
};
|
|
127
|
+
$[2] = t6;
|
|
128
|
+
} else {
|
|
129
|
+
t6 = $[2];
|
|
130
|
+
}
|
|
131
|
+
const prefetchRouteModule = t6;
|
|
132
|
+
let t7;
|
|
133
|
+
if ($[3] !== dataPrefetchTtlMs) {
|
|
134
|
+
t7 = async (router, route_0, href) => {
|
|
135
|
+
const routeId_0 = route_0.id;
|
|
136
|
+
if (!routeId_0) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const now = Date.now();
|
|
140
|
+
pruneDataCache(routeDataCacheRef.current, now);
|
|
141
|
+
const cacheKey = `${routeId_0}|${href}`;
|
|
142
|
+
const cached_0 = routeDataCacheRef.current.get(cacheKey);
|
|
143
|
+
if (cached_0 && cached_0.expiresAt > now) {
|
|
144
|
+
await cached_0.promise;
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
let hasLoader = typeof route_0.loader === "function";
|
|
148
|
+
if (!hasLoader) {
|
|
149
|
+
const loadedRouteModule = await prefetchRouteModule(route_0).catch(_temp2$1);
|
|
150
|
+
hasLoader = typeof loadedRouteModule?.loader === "function";
|
|
151
|
+
}
|
|
152
|
+
if (!hasLoader) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const fetcherKey = `rb:prefetch:${routeId_0}:${href}`;
|
|
156
|
+
const prefetchPromise_0 = Promise.resolve(router.fetch(fetcherKey, routeId_0, href)).catch((error_0) => {
|
|
157
|
+
routeDataCacheRef.current.delete(cacheKey);
|
|
158
|
+
throw error_0;
|
|
159
|
+
}).finally(() => {
|
|
160
|
+
try {
|
|
161
|
+
router.deleteFetcher(fetcherKey);
|
|
162
|
+
} catch {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
const ttl = Math.max(1, dataPrefetchTtlMs);
|
|
167
|
+
routeDataCacheRef.current.set(cacheKey, {
|
|
168
|
+
expiresAt: now + ttl,
|
|
169
|
+
promise: prefetchPromise_0
|
|
170
|
+
});
|
|
171
|
+
await prefetchPromise_0;
|
|
172
|
+
};
|
|
173
|
+
$[3] = dataPrefetchTtlMs;
|
|
174
|
+
$[4] = t7;
|
|
175
|
+
} else {
|
|
176
|
+
t7 = $[4];
|
|
177
|
+
}
|
|
178
|
+
const prefetchRouteData = t7;
|
|
179
|
+
let t8;
|
|
180
|
+
if ($[5] !== dataPrefetchHandleKey || $[6] !== dataRouterContext?.router || $[7] !== prefetchRouteData) {
|
|
181
|
+
t8 = async (href_0, opts) => {
|
|
182
|
+
const normalized = normalizeHref(href_0);
|
|
183
|
+
if (!normalized) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const currentPathWithSearch = typeof window === "undefined" ? "" : `${window.location.pathname}${window.location.search}`;
|
|
187
|
+
if (normalized.pathWithSearch === currentPathWithSearch) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const router_0 = dataRouterContext?.router;
|
|
191
|
+
if (!router_0) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const matches = matchRoutes(router_0.routes, {
|
|
195
|
+
pathname: normalized.pathname,
|
|
196
|
+
search: normalized.search,
|
|
197
|
+
hash: normalized.hash
|
|
198
|
+
}, router_0.basename);
|
|
199
|
+
if (!matches || matches.length === 0) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const matchedRoutes = matches.map(_temp3);
|
|
203
|
+
if (opts?.prefetchCode !== false) {
|
|
204
|
+
await Promise.all(matchedRoutes.map(async (route_1) => {
|
|
205
|
+
try {
|
|
206
|
+
await prefetchRouteModule(route_1);
|
|
207
|
+
} catch {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
await Promise.all(matchedRoutes.map(async (route_2) => {
|
|
213
|
+
if (!resolveDataPrefetchFlag(route_2, opts?.prefetchData, dataPrefetchHandleKey)) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
try {
|
|
217
|
+
await prefetchRouteData(router_0, route_2, normalized.pathWithSearch);
|
|
218
|
+
} catch {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
}));
|
|
222
|
+
};
|
|
223
|
+
$[5] = dataPrefetchHandleKey;
|
|
224
|
+
$[6] = dataRouterContext?.router;
|
|
225
|
+
$[7] = prefetchRouteData;
|
|
226
|
+
$[8] = t8;
|
|
227
|
+
} else {
|
|
228
|
+
t8 = $[8];
|
|
229
|
+
}
|
|
230
|
+
const prefetch = t8;
|
|
231
|
+
let t10;
|
|
232
|
+
let t9;
|
|
233
|
+
if ($[9] !== prefetch) {
|
|
234
|
+
t9 = async (href_1) => prefetch(href_1, {
|
|
235
|
+
prefetchCode: true,
|
|
236
|
+
prefetchData: false
|
|
237
|
+
});
|
|
238
|
+
t10 = async (href_2) => prefetch(href_2, {
|
|
239
|
+
prefetchCode: false,
|
|
240
|
+
prefetchData: true
|
|
241
|
+
});
|
|
242
|
+
$[9] = prefetch;
|
|
243
|
+
$[10] = t10;
|
|
244
|
+
$[11] = t9;
|
|
245
|
+
} else {
|
|
246
|
+
t10 = $[10];
|
|
247
|
+
t9 = $[11];
|
|
248
|
+
}
|
|
249
|
+
let t11;
|
|
250
|
+
if ($[12] !== defaultPrefetch || $[13] !== prefetch || $[14] !== t10 || $[15] !== t9) {
|
|
251
|
+
t11 = {
|
|
252
|
+
defaultPrefetch,
|
|
253
|
+
prefetch,
|
|
254
|
+
prefetchCode: t9,
|
|
255
|
+
prefetchData: t10
|
|
256
|
+
};
|
|
257
|
+
$[12] = defaultPrefetch;
|
|
258
|
+
$[13] = prefetch;
|
|
259
|
+
$[14] = t10;
|
|
260
|
+
$[15] = t9;
|
|
261
|
+
$[16] = t11;
|
|
262
|
+
} else {
|
|
263
|
+
t11 = $[16];
|
|
264
|
+
}
|
|
265
|
+
let t12;
|
|
266
|
+
if ($[17] !== children || $[18] !== t11) {
|
|
267
|
+
t12 = /* @__PURE__ */ jsx(RoutePrefetchContext.Provider, { value: t11, children });
|
|
268
|
+
$[17] = children;
|
|
269
|
+
$[18] = t11;
|
|
270
|
+
$[19] = t12;
|
|
271
|
+
} else {
|
|
272
|
+
t12 = $[19];
|
|
273
|
+
}
|
|
274
|
+
return t12;
|
|
275
|
+
};
|
|
276
|
+
const useRoutePrefetch = () => {
|
|
277
|
+
return useContext(RoutePrefetchContext);
|
|
222
278
|
};
|
|
223
279
|
function _temp$2(module) {
|
|
224
|
-
|
|
225
|
-
|
|
280
|
+
if (!module || typeof module !== "object") {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
return module;
|
|
226
284
|
}
|
|
227
285
|
function _temp2$1() {
|
|
228
|
-
|
|
286
|
+
return null;
|
|
229
287
|
}
|
|
230
288
|
function _temp3(match) {
|
|
231
|
-
|
|
289
|
+
return match.route;
|
|
232
290
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
ref.current = value;
|
|
291
|
+
const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
292
|
+
const assignRef = (ref, value) => {
|
|
293
|
+
if (!ref) return;
|
|
294
|
+
if (typeof ref === "function") {
|
|
295
|
+
ref(value);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
ref.current = value;
|
|
243
299
|
};
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
300
|
+
const composeEventHandlers = (theirHandler, ourHandler) => {
|
|
301
|
+
return (event) => {
|
|
302
|
+
theirHandler?.(event);
|
|
303
|
+
if (!event.defaultPrevented) {
|
|
304
|
+
ourHandler();
|
|
305
|
+
}
|
|
306
|
+
};
|
|
249
307
|
};
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
308
|
+
const shouldPrefetchLink = ({
|
|
309
|
+
prefetch,
|
|
310
|
+
reloadDocument,
|
|
311
|
+
target,
|
|
312
|
+
to
|
|
313
|
+
}) => {
|
|
314
|
+
if (prefetch === "none") return false;
|
|
315
|
+
if (reloadDocument) return false;
|
|
316
|
+
if (typeof target === "string" && target !== "_self") return false;
|
|
317
|
+
if (typeof to === "string" && ABSOLUTE_URL_REGEX.test(to)) return false;
|
|
318
|
+
return true;
|
|
256
319
|
};
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
320
|
+
const usePrefetchLink = (prefetchData) => {
|
|
321
|
+
const $ = c(5);
|
|
322
|
+
const localRef = useRef(null);
|
|
323
|
+
const {
|
|
324
|
+
prefetch
|
|
325
|
+
} = useRoutePrefetch();
|
|
326
|
+
let t0;
|
|
327
|
+
let t1;
|
|
328
|
+
if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
329
|
+
t0 = (node) => {
|
|
330
|
+
localRef.current = node;
|
|
331
|
+
};
|
|
332
|
+
t1 = () => localRef.current;
|
|
333
|
+
$[0] = t0;
|
|
334
|
+
$[1] = t1;
|
|
335
|
+
} else {
|
|
336
|
+
t0 = $[0];
|
|
337
|
+
t1 = $[1];
|
|
338
|
+
}
|
|
339
|
+
let t2;
|
|
340
|
+
if ($[2] !== prefetch || $[3] !== prefetchData) {
|
|
341
|
+
t2 = {
|
|
342
|
+
anchorRef: t0,
|
|
343
|
+
getAnchorElement: t1,
|
|
344
|
+
prefetchHref: () => {
|
|
345
|
+
const href = localRef.current?.getAttribute("href");
|
|
346
|
+
if (!href) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
prefetch(href, {
|
|
350
|
+
prefetchData
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
$[2] = prefetch;
|
|
355
|
+
$[3] = prefetchData;
|
|
356
|
+
$[4] = t2;
|
|
357
|
+
} else {
|
|
358
|
+
t2 = $[4];
|
|
359
|
+
}
|
|
360
|
+
return t2;
|
|
290
361
|
};
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
362
|
+
const Link = forwardRef((t0, forwardedRef) => {
|
|
363
|
+
const $ = c(54);
|
|
364
|
+
let onFocus;
|
|
365
|
+
let onMouseEnter;
|
|
366
|
+
let onTouchStart;
|
|
367
|
+
let prefetchData;
|
|
368
|
+
let prefetchProp;
|
|
369
|
+
let props;
|
|
370
|
+
let reloadDocument;
|
|
371
|
+
let target;
|
|
372
|
+
let to;
|
|
373
|
+
if ($[0] !== t0) {
|
|
374
|
+
({
|
|
375
|
+
prefetch: prefetchProp,
|
|
376
|
+
prefetchData,
|
|
377
|
+
onMouseEnter,
|
|
378
|
+
onFocus,
|
|
379
|
+
onTouchStart,
|
|
380
|
+
reloadDocument,
|
|
381
|
+
target,
|
|
382
|
+
to,
|
|
383
|
+
...props
|
|
384
|
+
} = t0);
|
|
385
|
+
$[0] = t0;
|
|
386
|
+
$[1] = onFocus;
|
|
387
|
+
$[2] = onMouseEnter;
|
|
388
|
+
$[3] = onTouchStart;
|
|
389
|
+
$[4] = prefetchData;
|
|
390
|
+
$[5] = prefetchProp;
|
|
391
|
+
$[6] = props;
|
|
392
|
+
$[7] = reloadDocument;
|
|
393
|
+
$[8] = target;
|
|
394
|
+
$[9] = to;
|
|
395
|
+
} else {
|
|
396
|
+
onFocus = $[1];
|
|
397
|
+
onMouseEnter = $[2];
|
|
398
|
+
onTouchStart = $[3];
|
|
399
|
+
prefetchData = $[4];
|
|
400
|
+
prefetchProp = $[5];
|
|
401
|
+
props = $[6];
|
|
402
|
+
reloadDocument = $[7];
|
|
403
|
+
target = $[8];
|
|
404
|
+
to = $[9];
|
|
405
|
+
}
|
|
406
|
+
const {
|
|
407
|
+
defaultPrefetch
|
|
408
|
+
} = useRoutePrefetch();
|
|
409
|
+
const prefetchBehavior = prefetchProp ?? defaultPrefetch;
|
|
410
|
+
const viewportPrefetchedRef = useRef(false);
|
|
411
|
+
const {
|
|
412
|
+
anchorRef,
|
|
413
|
+
prefetchHref,
|
|
414
|
+
getAnchorElement
|
|
415
|
+
} = usePrefetchLink(prefetchData);
|
|
416
|
+
let t1;
|
|
417
|
+
if ($[10] !== prefetchBehavior || $[11] !== reloadDocument || $[12] !== target || $[13] !== to) {
|
|
418
|
+
t1 = shouldPrefetchLink({
|
|
419
|
+
prefetch: prefetchBehavior,
|
|
420
|
+
reloadDocument,
|
|
421
|
+
target,
|
|
422
|
+
to
|
|
423
|
+
});
|
|
424
|
+
$[10] = prefetchBehavior;
|
|
425
|
+
$[11] = reloadDocument;
|
|
426
|
+
$[12] = target;
|
|
427
|
+
$[13] = to;
|
|
428
|
+
$[14] = t1;
|
|
429
|
+
} else {
|
|
430
|
+
t1 = $[14];
|
|
431
|
+
}
|
|
432
|
+
const canPrefetch = t1;
|
|
433
|
+
let t2;
|
|
434
|
+
if ($[15] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
435
|
+
t2 = () => {
|
|
436
|
+
viewportPrefetchedRef.current = false;
|
|
437
|
+
};
|
|
438
|
+
$[15] = t2;
|
|
439
|
+
} else {
|
|
440
|
+
t2 = $[15];
|
|
441
|
+
}
|
|
442
|
+
let t3;
|
|
443
|
+
if ($[16] !== to) {
|
|
444
|
+
t3 = [to];
|
|
445
|
+
$[16] = to;
|
|
446
|
+
$[17] = t3;
|
|
447
|
+
} else {
|
|
448
|
+
t3 = $[17];
|
|
449
|
+
}
|
|
450
|
+
useEffect(t2, t3);
|
|
451
|
+
let t4;
|
|
452
|
+
let t5;
|
|
453
|
+
if ($[18] !== canPrefetch || $[19] !== prefetchBehavior || $[20] !== prefetchHref) {
|
|
454
|
+
t4 = () => {
|
|
455
|
+
if (!canPrefetch || prefetchBehavior !== "render") {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
prefetchHref();
|
|
459
|
+
};
|
|
460
|
+
t5 = [canPrefetch, prefetchBehavior, prefetchHref];
|
|
461
|
+
$[18] = canPrefetch;
|
|
462
|
+
$[19] = prefetchBehavior;
|
|
463
|
+
$[20] = prefetchHref;
|
|
464
|
+
$[21] = t4;
|
|
465
|
+
$[22] = t5;
|
|
466
|
+
} else {
|
|
467
|
+
t4 = $[21];
|
|
468
|
+
t5 = $[22];
|
|
469
|
+
}
|
|
470
|
+
useEffect(t4, t5);
|
|
471
|
+
let t6;
|
|
472
|
+
let t7;
|
|
473
|
+
if ($[23] !== canPrefetch || $[24] !== getAnchorElement || $[25] !== prefetchBehavior || $[26] !== prefetchHref) {
|
|
474
|
+
t6 = () => {
|
|
475
|
+
if (!canPrefetch || prefetchBehavior !== "viewport") {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
const element = getAnchorElement();
|
|
479
|
+
if (!element || typeof IntersectionObserver === "undefined") {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
const observer = new IntersectionObserver((entries) => {
|
|
483
|
+
const isVisible = entries.some(_temp$1);
|
|
484
|
+
if (!isVisible || viewportPrefetchedRef.current) {
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
viewportPrefetchedRef.current = true;
|
|
488
|
+
prefetchHref();
|
|
489
|
+
}, {
|
|
490
|
+
threshold: 0.5
|
|
491
|
+
});
|
|
492
|
+
observer.observe(element);
|
|
493
|
+
return () => {
|
|
494
|
+
observer.disconnect();
|
|
495
|
+
};
|
|
496
|
+
};
|
|
497
|
+
t7 = [canPrefetch, prefetchBehavior, prefetchHref, getAnchorElement];
|
|
498
|
+
$[23] = canPrefetch;
|
|
499
|
+
$[24] = getAnchorElement;
|
|
500
|
+
$[25] = prefetchBehavior;
|
|
501
|
+
$[26] = prefetchHref;
|
|
502
|
+
$[27] = t6;
|
|
503
|
+
$[28] = t7;
|
|
504
|
+
} else {
|
|
505
|
+
t6 = $[27];
|
|
506
|
+
t7 = $[28];
|
|
507
|
+
}
|
|
508
|
+
useEffect(t6, t7);
|
|
509
|
+
let t8;
|
|
510
|
+
if ($[29] !== canPrefetch || $[30] !== prefetchBehavior || $[31] !== prefetchHref) {
|
|
511
|
+
t8 = () => {
|
|
512
|
+
if (!canPrefetch || prefetchBehavior !== "intent") {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
prefetchHref();
|
|
516
|
+
};
|
|
517
|
+
$[29] = canPrefetch;
|
|
518
|
+
$[30] = prefetchBehavior;
|
|
519
|
+
$[31] = prefetchHref;
|
|
520
|
+
$[32] = t8;
|
|
521
|
+
} else {
|
|
522
|
+
t8 = $[32];
|
|
523
|
+
}
|
|
524
|
+
const handleIntentPrefetch = t8;
|
|
525
|
+
let t9;
|
|
526
|
+
if ($[33] !== handleIntentPrefetch || $[34] !== onMouseEnter) {
|
|
527
|
+
t9 = composeEventHandlers(onMouseEnter, handleIntentPrefetch);
|
|
528
|
+
$[33] = handleIntentPrefetch;
|
|
529
|
+
$[34] = onMouseEnter;
|
|
530
|
+
$[35] = t9;
|
|
531
|
+
} else {
|
|
532
|
+
t9 = $[35];
|
|
533
|
+
}
|
|
534
|
+
let t10;
|
|
535
|
+
if ($[36] !== handleIntentPrefetch || $[37] !== onFocus) {
|
|
536
|
+
t10 = composeEventHandlers(onFocus, handleIntentPrefetch);
|
|
537
|
+
$[36] = handleIntentPrefetch;
|
|
538
|
+
$[37] = onFocus;
|
|
539
|
+
$[38] = t10;
|
|
540
|
+
} else {
|
|
541
|
+
t10 = $[38];
|
|
542
|
+
}
|
|
543
|
+
let t11;
|
|
544
|
+
if ($[39] !== handleIntentPrefetch || $[40] !== onTouchStart) {
|
|
545
|
+
t11 = composeEventHandlers(onTouchStart, handleIntentPrefetch);
|
|
546
|
+
$[39] = handleIntentPrefetch;
|
|
547
|
+
$[40] = onTouchStart;
|
|
548
|
+
$[41] = t11;
|
|
549
|
+
} else {
|
|
550
|
+
t11 = $[41];
|
|
551
|
+
}
|
|
552
|
+
let t12;
|
|
553
|
+
if ($[42] !== anchorRef || $[43] !== forwardedRef) {
|
|
554
|
+
t12 = (node) => {
|
|
555
|
+
assignRef(forwardedRef, node);
|
|
556
|
+
assignRef(anchorRef, node);
|
|
557
|
+
};
|
|
558
|
+
$[42] = anchorRef;
|
|
559
|
+
$[43] = forwardedRef;
|
|
560
|
+
$[44] = t12;
|
|
561
|
+
} else {
|
|
562
|
+
t12 = $[44];
|
|
563
|
+
}
|
|
564
|
+
let t13;
|
|
565
|
+
if ($[45] !== props || $[46] !== reloadDocument || $[47] !== t10 || $[48] !== t11 || $[49] !== t12 || $[50] !== t9 || $[51] !== target || $[52] !== to) {
|
|
566
|
+
t13 = /* @__PURE__ */ jsx(Link$1, { ...props, to, target, reloadDocument, prefetch: "none", onMouseEnter: t9, onFocus: t10, onTouchStart: t11, ref: t12 });
|
|
567
|
+
$[45] = props;
|
|
568
|
+
$[46] = reloadDocument;
|
|
569
|
+
$[47] = t10;
|
|
570
|
+
$[48] = t11;
|
|
571
|
+
$[49] = t12;
|
|
572
|
+
$[50] = t9;
|
|
573
|
+
$[51] = target;
|
|
574
|
+
$[52] = to;
|
|
575
|
+
$[53] = t13;
|
|
576
|
+
} else {
|
|
577
|
+
t13 = $[53];
|
|
578
|
+
}
|
|
579
|
+
return t13;
|
|
481
580
|
});
|
|
482
581
|
Link.displayName = "Link";
|
|
483
582
|
function _temp$1(entry) {
|
|
484
|
-
|
|
583
|
+
return entry.isIntersecting;
|
|
485
584
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
585
|
+
const memoizeImporter = (importer) => {
|
|
586
|
+
let promise = null;
|
|
587
|
+
return async () => {
|
|
588
|
+
if (!promise) {
|
|
589
|
+
promise = importer().catch((error) => {
|
|
590
|
+
promise = null;
|
|
591
|
+
throw error;
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
return promise;
|
|
595
|
+
};
|
|
497
596
|
};
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
597
|
+
const lazyRoute = (importer, opts) => {
|
|
598
|
+
const loadModule = memoizeImporter(importer);
|
|
599
|
+
return {
|
|
600
|
+
lazy: async () => {
|
|
601
|
+
const module = await loadModule();
|
|
602
|
+
const lazyRouteModule = {
|
|
603
|
+
Component: module.default
|
|
604
|
+
};
|
|
605
|
+
if (typeof module.loader === "function") {
|
|
606
|
+
lazyRouteModule.loader = module.loader;
|
|
607
|
+
}
|
|
608
|
+
return lazyRouteModule;
|
|
609
|
+
},
|
|
610
|
+
handle: mergeRouteHandle(opts?.handle, {
|
|
611
|
+
importer: loadModule,
|
|
612
|
+
prefetchData: opts?.prefetchData,
|
|
613
|
+
prefetchDataKey: opts?.prefetchDataKey
|
|
614
|
+
})
|
|
615
|
+
};
|
|
513
616
|
};
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
617
|
+
const useApplyMeta = (t0) => {
|
|
618
|
+
const $ = c(12);
|
|
619
|
+
let t1;
|
|
620
|
+
if ($[0] !== t0) {
|
|
621
|
+
t1 = t0 === void 0 ? {} : t0;
|
|
622
|
+
$[0] = t0;
|
|
623
|
+
$[1] = t1;
|
|
624
|
+
} else {
|
|
625
|
+
t1 = $[1];
|
|
626
|
+
}
|
|
627
|
+
const {
|
|
628
|
+
defaultTitle: t2,
|
|
629
|
+
defaultMeta: t3,
|
|
630
|
+
pagesMeta: t4
|
|
631
|
+
} = t1;
|
|
632
|
+
const defaultTitle = t2 === void 0 ? "" : t2;
|
|
633
|
+
let t5;
|
|
634
|
+
if ($[2] !== t3) {
|
|
635
|
+
t5 = t3 === void 0 ? [] : t3;
|
|
636
|
+
$[2] = t3;
|
|
637
|
+
$[3] = t5;
|
|
638
|
+
} else {
|
|
639
|
+
t5 = $[3];
|
|
640
|
+
}
|
|
641
|
+
const defaultMeta = t5;
|
|
642
|
+
let t6;
|
|
643
|
+
if ($[4] !== t4) {
|
|
644
|
+
t6 = t4 === void 0 ? {} : t4;
|
|
645
|
+
$[4] = t4;
|
|
646
|
+
$[5] = t6;
|
|
647
|
+
} else {
|
|
648
|
+
t6 = $[5];
|
|
649
|
+
}
|
|
650
|
+
const pagesMeta = t6;
|
|
651
|
+
const location = useLocation();
|
|
652
|
+
let t7;
|
|
653
|
+
let t8;
|
|
654
|
+
if ($[6] !== defaultMeta || $[7] !== defaultTitle || $[8] !== location.pathname || $[9] !== pagesMeta) {
|
|
655
|
+
t7 = () => {
|
|
656
|
+
const loadMeta = async () => {
|
|
657
|
+
let pageMeta = pagesMeta[location.pathname];
|
|
658
|
+
if (!pageMeta) {
|
|
659
|
+
pageMeta = {
|
|
660
|
+
title: defaultTitle,
|
|
661
|
+
meta: defaultMeta
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
document.title = pageMeta.title;
|
|
665
|
+
document.querySelectorAll("[data-react-meta]").forEach(_temp);
|
|
666
|
+
pageMeta.meta.forEach(_temp2);
|
|
667
|
+
const canonicalUrl = `${window.location.origin}${location.pathname}`;
|
|
668
|
+
const existingCanonical = document.querySelector('link[rel="canonical"]');
|
|
669
|
+
if (existingCanonical) {
|
|
670
|
+
existingCanonical.remove();
|
|
671
|
+
}
|
|
672
|
+
const canonicalLink = document.createElement("link");
|
|
673
|
+
canonicalLink.setAttribute("rel", "canonical");
|
|
674
|
+
canonicalLink.setAttribute("href", canonicalUrl);
|
|
675
|
+
canonicalLink.setAttribute("data-react-meta", "true");
|
|
676
|
+
document.head.appendChild(canonicalLink);
|
|
677
|
+
};
|
|
678
|
+
loadMeta();
|
|
679
|
+
};
|
|
680
|
+
t8 = [location.pathname, defaultTitle, defaultMeta, pagesMeta];
|
|
681
|
+
$[6] = defaultMeta;
|
|
682
|
+
$[7] = defaultTitle;
|
|
683
|
+
$[8] = location.pathname;
|
|
684
|
+
$[9] = pagesMeta;
|
|
685
|
+
$[10] = t7;
|
|
686
|
+
$[11] = t8;
|
|
687
|
+
} else {
|
|
688
|
+
t7 = $[10];
|
|
689
|
+
t8 = $[11];
|
|
690
|
+
}
|
|
691
|
+
useEffect(t7, t8);
|
|
582
692
|
};
|
|
583
693
|
function _temp(tag) {
|
|
584
|
-
|
|
694
|
+
return tag.remove();
|
|
585
695
|
}
|
|
586
696
|
function _temp2(meta) {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
697
|
+
const metaElement = document.createElement("meta");
|
|
698
|
+
metaElement.setAttribute("data-react-meta", "true");
|
|
699
|
+
Object.entries(meta).forEach((t0) => {
|
|
700
|
+
const [key, value] = t0;
|
|
701
|
+
if (value) {
|
|
702
|
+
metaElement.setAttribute(key, value.toString());
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
document.head.appendChild(metaElement);
|
|
594
706
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
707
|
+
const NAVIGATION_GUARDS_STORE_KEY = "__rpcbaseNavigationGuardsStore";
|
|
708
|
+
const getNavigationGuardsStore = () => {
|
|
709
|
+
const globalAny = globalThis;
|
|
710
|
+
const existing = globalAny[NAVIGATION_GUARDS_STORE_KEY];
|
|
711
|
+
if (existing) {
|
|
712
|
+
return existing;
|
|
713
|
+
}
|
|
714
|
+
const created = {
|
|
715
|
+
guards: /* @__PURE__ */ new Map(),
|
|
716
|
+
listeners: /* @__PURE__ */ new Set()
|
|
717
|
+
};
|
|
718
|
+
globalAny[NAVIGATION_GUARDS_STORE_KEY] = created;
|
|
719
|
+
return created;
|
|
720
|
+
};
|
|
721
|
+
const notify = () => {
|
|
722
|
+
getNavigationGuardsStore().listeners.forEach((listener) => {
|
|
723
|
+
listener();
|
|
724
|
+
});
|
|
608
725
|
};
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
726
|
+
const isSameGuard = (a, b) => a.id === b.id && a.enabled === b.enabled && a.priority === b.priority && a.message === b.message && a.blockOnSearch === b.blockOnSearch && a.shouldBlockNavigation === b.shouldBlockNavigation && a.shouldBlockUnload === b.shouldBlockUnload;
|
|
727
|
+
const upsertNavigationGuard = (guard) => {
|
|
728
|
+
const guards = getNavigationGuardsStore().guards;
|
|
729
|
+
const prev = guards.get(guard.id);
|
|
730
|
+
if (prev && isSameGuard(prev, guard)) {
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
guards.set(guard.id, guard);
|
|
734
|
+
notify();
|
|
613
735
|
};
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
notify();
|
|
736
|
+
const removeNavigationGuard = (id) => {
|
|
737
|
+
const guards = getNavigationGuardsStore().guards;
|
|
738
|
+
const didDelete = guards.delete(id);
|
|
739
|
+
if (didDelete) {
|
|
740
|
+
notify();
|
|
741
|
+
}
|
|
621
742
|
};
|
|
622
|
-
|
|
623
|
-
|
|
743
|
+
const getNavigationGuards = () => Array.from(getNavigationGuardsStore().guards.values());
|
|
744
|
+
const subscribeNavigationGuards = (listener) => {
|
|
745
|
+
const listeners = getNavigationGuardsStore().listeners;
|
|
746
|
+
listeners.add(listener);
|
|
747
|
+
return () => {
|
|
748
|
+
listeners.delete(listener);
|
|
749
|
+
};
|
|
624
750
|
};
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
751
|
+
const useRegisterNavigationGuard = (guard) => {
|
|
752
|
+
const latestGuardRef = useRef(guard);
|
|
753
|
+
latestGuardRef.current = guard;
|
|
754
|
+
const lastIdRef = useRef(null);
|
|
755
|
+
useEffect(() => {
|
|
756
|
+
const lastId = lastIdRef.current;
|
|
757
|
+
if (lastId && lastId !== guard.id) {
|
|
758
|
+
removeNavigationGuard(lastId);
|
|
759
|
+
}
|
|
760
|
+
lastIdRef.current = guard.id;
|
|
761
|
+
if (!guard.enabled) {
|
|
762
|
+
removeNavigationGuard(guard.id);
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
upsertNavigationGuard(latestGuardRef.current);
|
|
766
|
+
return () => {
|
|
767
|
+
removeNavigationGuard(guard.id);
|
|
768
|
+
};
|
|
769
|
+
}, [guard.id, guard.enabled, guard.message, guard.priority, guard.blockOnSearch, guard.shouldBlockNavigation, guard.shouldBlockUnload]);
|
|
632
770
|
};
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
771
|
+
const useQueryOverlay = (t0) => {
|
|
772
|
+
const $ = c(21);
|
|
773
|
+
const {
|
|
774
|
+
param,
|
|
775
|
+
parse
|
|
776
|
+
} = t0;
|
|
777
|
+
const location = useLocation();
|
|
778
|
+
const navigate = useNavigate();
|
|
779
|
+
let t1;
|
|
780
|
+
if ($[0] !== location.hash || $[1] !== location.pathname || $[2] !== location.search || $[3] !== param) {
|
|
781
|
+
t1 = (nextValue) => {
|
|
782
|
+
const searchParams = new URLSearchParams(location.search);
|
|
783
|
+
if (nextValue === null) {
|
|
784
|
+
searchParams.delete(param);
|
|
785
|
+
} else {
|
|
786
|
+
searchParams.set(param, nextValue);
|
|
787
|
+
}
|
|
788
|
+
const nextSearch = searchParams.toString();
|
|
789
|
+
return `${location.pathname}${nextSearch ? `?${nextSearch}` : ""}${location.hash}`;
|
|
790
|
+
};
|
|
791
|
+
$[0] = location.hash;
|
|
792
|
+
$[1] = location.pathname;
|
|
793
|
+
$[2] = location.search;
|
|
794
|
+
$[3] = param;
|
|
795
|
+
$[4] = t1;
|
|
796
|
+
} else {
|
|
797
|
+
t1 = $[4];
|
|
798
|
+
}
|
|
799
|
+
const buildHref = t1;
|
|
800
|
+
let t2;
|
|
801
|
+
if ($[5] !== location.search || $[6] !== param || $[7] !== parse) {
|
|
802
|
+
t2 = parse(new URLSearchParams(location.search).get(param));
|
|
803
|
+
$[5] = location.search;
|
|
804
|
+
$[6] = param;
|
|
805
|
+
$[7] = parse;
|
|
806
|
+
$[8] = t2;
|
|
807
|
+
} else {
|
|
808
|
+
t2 = $[8];
|
|
809
|
+
}
|
|
810
|
+
const value = t2;
|
|
811
|
+
let t3;
|
|
812
|
+
if ($[9] !== buildHref || $[10] !== navigate) {
|
|
813
|
+
t3 = (nextValue_0) => {
|
|
814
|
+
navigate(buildHref(nextValue_0), {
|
|
815
|
+
replace: true
|
|
816
|
+
});
|
|
817
|
+
};
|
|
818
|
+
$[9] = buildHref;
|
|
819
|
+
$[10] = navigate;
|
|
820
|
+
$[11] = t3;
|
|
821
|
+
} else {
|
|
822
|
+
t3 = $[11];
|
|
823
|
+
}
|
|
824
|
+
const openOverlay = t3;
|
|
825
|
+
let t4;
|
|
826
|
+
if ($[12] !== buildHref || $[13] !== navigate) {
|
|
827
|
+
t4 = () => {
|
|
828
|
+
navigate(buildHref(null), {
|
|
829
|
+
replace: true
|
|
830
|
+
});
|
|
831
|
+
};
|
|
832
|
+
$[12] = buildHref;
|
|
833
|
+
$[13] = navigate;
|
|
834
|
+
$[14] = t4;
|
|
835
|
+
} else {
|
|
836
|
+
t4 = $[14];
|
|
837
|
+
}
|
|
838
|
+
const closeOverlay = t4;
|
|
839
|
+
const t5 = value !== null;
|
|
840
|
+
let t6;
|
|
841
|
+
if ($[15] !== buildHref || $[16] !== closeOverlay || $[17] !== openOverlay || $[18] !== t5 || $[19] !== value) {
|
|
842
|
+
t6 = {
|
|
843
|
+
value,
|
|
844
|
+
isOpen: t5,
|
|
845
|
+
buildHref,
|
|
846
|
+
openOverlay,
|
|
847
|
+
closeOverlay
|
|
848
|
+
};
|
|
849
|
+
$[15] = buildHref;
|
|
850
|
+
$[16] = closeOverlay;
|
|
851
|
+
$[17] = openOverlay;
|
|
852
|
+
$[18] = t5;
|
|
853
|
+
$[19] = value;
|
|
854
|
+
$[20] = t6;
|
|
855
|
+
} else {
|
|
856
|
+
t6 = $[20];
|
|
857
|
+
}
|
|
858
|
+
return t6;
|
|
658
859
|
};
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
const location = useLocation();
|
|
665
|
-
const navigate = useNavigate();
|
|
666
|
-
let t1;
|
|
667
|
-
if ($[0] !== location.hash || $[1] !== location.pathname || $[2] !== location.search || $[3] !== param) {
|
|
668
|
-
t1 = (nextValue) => {
|
|
669
|
-
const searchParams = new URLSearchParams(location.search);
|
|
670
|
-
if (nextValue === null) searchParams.delete(param);
|
|
671
|
-
else searchParams.set(param, nextValue);
|
|
672
|
-
const nextSearch = searchParams.toString();
|
|
673
|
-
return `${location.pathname}${nextSearch ? `?${nextSearch}` : ""}${location.hash}`;
|
|
674
|
-
};
|
|
675
|
-
$[0] = location.hash;
|
|
676
|
-
$[1] = location.pathname;
|
|
677
|
-
$[2] = location.search;
|
|
678
|
-
$[3] = param;
|
|
679
|
-
$[4] = t1;
|
|
680
|
-
} else t1 = $[4];
|
|
681
|
-
const buildHref = t1;
|
|
682
|
-
let t2;
|
|
683
|
-
if ($[5] !== location.search || $[6] !== param || $[7] !== parse) {
|
|
684
|
-
t2 = parse(new URLSearchParams(location.search).get(param));
|
|
685
|
-
$[5] = location.search;
|
|
686
|
-
$[6] = param;
|
|
687
|
-
$[7] = parse;
|
|
688
|
-
$[8] = t2;
|
|
689
|
-
} else t2 = $[8];
|
|
690
|
-
const value = t2;
|
|
691
|
-
let t3;
|
|
692
|
-
if ($[9] !== buildHref || $[10] !== navigate) {
|
|
693
|
-
t3 = (nextValue_0) => {
|
|
694
|
-
navigate(buildHref(nextValue_0), { replace: true });
|
|
695
|
-
};
|
|
696
|
-
$[9] = buildHref;
|
|
697
|
-
$[10] = navigate;
|
|
698
|
-
$[11] = t3;
|
|
699
|
-
} else t3 = $[11];
|
|
700
|
-
const openOverlay = t3;
|
|
701
|
-
let t4;
|
|
702
|
-
if ($[12] !== buildHref || $[13] !== navigate) {
|
|
703
|
-
t4 = () => {
|
|
704
|
-
navigate(buildHref(null), { replace: true });
|
|
705
|
-
};
|
|
706
|
-
$[12] = buildHref;
|
|
707
|
-
$[13] = navigate;
|
|
708
|
-
$[14] = t4;
|
|
709
|
-
} else t4 = $[14];
|
|
710
|
-
const closeOverlay = t4;
|
|
711
|
-
const t5 = value !== null;
|
|
712
|
-
let t6;
|
|
713
|
-
if ($[15] !== buildHref || $[16] !== closeOverlay || $[17] !== openOverlay || $[18] !== t5 || $[19] !== value) {
|
|
714
|
-
t6 = {
|
|
715
|
-
value,
|
|
716
|
-
isOpen: t5,
|
|
717
|
-
buildHref,
|
|
718
|
-
openOverlay,
|
|
719
|
-
closeOverlay
|
|
720
|
-
};
|
|
721
|
-
$[15] = buildHref;
|
|
722
|
-
$[16] = closeOverlay;
|
|
723
|
-
$[17] = openOverlay;
|
|
724
|
-
$[18] = t5;
|
|
725
|
-
$[19] = value;
|
|
726
|
-
$[20] = t6;
|
|
727
|
-
} else t6 = $[20];
|
|
728
|
-
return t6;
|
|
860
|
+
const normalizeKey = (key) => key.toLowerCase();
|
|
861
|
+
const defaultIsTypingTarget = (target) => {
|
|
862
|
+
const element = target;
|
|
863
|
+
const tagName = element?.tagName;
|
|
864
|
+
return element?.isContentEditable === true || tagName === "INPUT" || tagName === "TEXTAREA" || tagName === "SELECT";
|
|
729
865
|
};
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
866
|
+
const matchesShortcutKeyDown = (event, shortcut) => {
|
|
867
|
+
if (normalizeKey(event.key) !== normalizeKey(shortcut.key)) return false;
|
|
868
|
+
if (typeof shortcut.mod === "boolean") {
|
|
869
|
+
const hasMod = event.metaKey || event.ctrlKey;
|
|
870
|
+
if (hasMod !== shortcut.mod) return false;
|
|
871
|
+
}
|
|
872
|
+
if (typeof shortcut.ctrl === "boolean" && event.ctrlKey !== shortcut.ctrl) return false;
|
|
873
|
+
if (typeof shortcut.meta === "boolean" && event.metaKey !== shortcut.meta) return false;
|
|
874
|
+
if (typeof shortcut.alt === "boolean" && event.altKey !== shortcut.alt) return false;
|
|
875
|
+
if (typeof shortcut.shift === "boolean" && event.shiftKey !== shortcut.shift) return false;
|
|
876
|
+
return true;
|
|
737
877
|
};
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
if ((event.metaKey || event.ctrlKey) !== shortcut.mod) return false;
|
|
742
|
-
}
|
|
743
|
-
if (typeof shortcut.ctrl === "boolean" && event.ctrlKey !== shortcut.ctrl) return false;
|
|
744
|
-
if (typeof shortcut.meta === "boolean" && event.metaKey !== shortcut.meta) return false;
|
|
745
|
-
if (typeof shortcut.alt === "boolean" && event.altKey !== shortcut.alt) return false;
|
|
746
|
-
if (typeof shortcut.shift === "boolean" && event.shiftKey !== shortcut.shift) return false;
|
|
747
|
-
return true;
|
|
878
|
+
const callMaybeAsync = (fn, href) => {
|
|
879
|
+
if (!fn) return;
|
|
880
|
+
void Promise.resolve(fn(href));
|
|
748
881
|
};
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
882
|
+
const useShortcutPrefetchNavigate = ({
|
|
883
|
+
shortcut,
|
|
884
|
+
getHref,
|
|
885
|
+
prefetch,
|
|
886
|
+
navigate,
|
|
887
|
+
trigger = "keyup",
|
|
888
|
+
enabled = true,
|
|
889
|
+
preventDefault = true,
|
|
890
|
+
ignoreTypingTarget = true,
|
|
891
|
+
isTypingTarget = defaultIsTypingTarget
|
|
892
|
+
}) => {
|
|
893
|
+
const routerNavigate = useNavigate();
|
|
894
|
+
const shortcutRef = useRef(shortcut);
|
|
895
|
+
const getHrefRef = useRef(getHref);
|
|
896
|
+
const prefetchRef = useRef(prefetch);
|
|
897
|
+
const navigateRef = useRef(navigate ?? routerNavigate);
|
|
898
|
+
const triggerRef = useRef(trigger);
|
|
899
|
+
const enabledRef = useRef(enabled);
|
|
900
|
+
const preventDefaultRef = useRef(preventDefault);
|
|
901
|
+
const ignoreTypingTargetRef = useRef(ignoreTypingTarget);
|
|
902
|
+
const isTypingTargetRef = useRef(isTypingTarget);
|
|
903
|
+
const waitingForShortcutKeyUpRef = useRef(false);
|
|
904
|
+
shortcutRef.current = shortcut;
|
|
905
|
+
getHrefRef.current = getHref;
|
|
906
|
+
prefetchRef.current = prefetch;
|
|
907
|
+
navigateRef.current = navigate ?? routerNavigate;
|
|
908
|
+
triggerRef.current = trigger;
|
|
909
|
+
enabledRef.current = enabled;
|
|
910
|
+
preventDefaultRef.current = preventDefault;
|
|
911
|
+
ignoreTypingTargetRef.current = ignoreTypingTarget;
|
|
912
|
+
isTypingTargetRef.current = isTypingTarget;
|
|
913
|
+
if (!enabled || trigger !== "keyup") {
|
|
914
|
+
waitingForShortcutKeyUpRef.current = false;
|
|
915
|
+
}
|
|
916
|
+
useEffect(() => {
|
|
917
|
+
if (typeof window === "undefined") return;
|
|
918
|
+
const onKeyDown = (event) => {
|
|
919
|
+
if (!enabledRef.current) return;
|
|
920
|
+
if (ignoreTypingTargetRef.current && isTypingTargetRef.current(event.target)) return;
|
|
921
|
+
if (event.repeat) return;
|
|
922
|
+
if (!matchesShortcutKeyDown(event, shortcutRef.current)) return;
|
|
923
|
+
if (preventDefaultRef.current) {
|
|
924
|
+
event.preventDefault();
|
|
925
|
+
}
|
|
926
|
+
const href = getHrefRef.current();
|
|
927
|
+
if (!href) return;
|
|
928
|
+
callMaybeAsync(prefetchRef.current, href);
|
|
929
|
+
if (triggerRef.current === "keydown") {
|
|
930
|
+
callMaybeAsync(navigateRef.current, href);
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
waitingForShortcutKeyUpRef.current = true;
|
|
934
|
+
};
|
|
935
|
+
const onKeyUp = (event_0) => {
|
|
936
|
+
if (!enabledRef.current) return;
|
|
937
|
+
if (triggerRef.current !== "keyup") return;
|
|
938
|
+
if (!waitingForShortcutKeyUpRef.current) return;
|
|
939
|
+
if (normalizeKey(event_0.key) !== normalizeKey(shortcutRef.current.key)) return;
|
|
940
|
+
waitingForShortcutKeyUpRef.current = false;
|
|
941
|
+
if (ignoreTypingTargetRef.current && isTypingTargetRef.current(event_0.target)) return;
|
|
942
|
+
if (preventDefaultRef.current) {
|
|
943
|
+
event_0.preventDefault();
|
|
944
|
+
}
|
|
945
|
+
const href_0 = getHrefRef.current();
|
|
946
|
+
if (!href_0) return;
|
|
947
|
+
callMaybeAsync(navigateRef.current, href_0);
|
|
948
|
+
};
|
|
949
|
+
const onBlur = () => {
|
|
950
|
+
waitingForShortcutKeyUpRef.current = false;
|
|
951
|
+
};
|
|
952
|
+
window.addEventListener("keydown", onKeyDown);
|
|
953
|
+
window.addEventListener("keyup", onKeyUp);
|
|
954
|
+
window.addEventListener("blur", onBlur);
|
|
955
|
+
return () => {
|
|
956
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
957
|
+
window.removeEventListener("keyup", onKeyUp);
|
|
958
|
+
window.removeEventListener("blur", onBlur);
|
|
959
|
+
};
|
|
960
|
+
}, []);
|
|
752
961
|
};
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
getHrefRef.current = getHref;
|
|
767
|
-
prefetchRef.current = prefetch;
|
|
768
|
-
navigateRef.current = navigate ?? routerNavigate;
|
|
769
|
-
triggerRef.current = trigger;
|
|
770
|
-
enabledRef.current = enabled;
|
|
771
|
-
preventDefaultRef.current = preventDefault;
|
|
772
|
-
ignoreTypingTargetRef.current = ignoreTypingTarget;
|
|
773
|
-
isTypingTargetRef.current = isTypingTarget;
|
|
774
|
-
if (!enabled || trigger !== "keyup") waitingForShortcutKeyUpRef.current = false;
|
|
775
|
-
useEffect(() => {
|
|
776
|
-
if (typeof window === "undefined") return;
|
|
777
|
-
const onKeyDown = (event) => {
|
|
778
|
-
if (!enabledRef.current) return;
|
|
779
|
-
if (ignoreTypingTargetRef.current && isTypingTargetRef.current(event.target)) return;
|
|
780
|
-
if (event.repeat) return;
|
|
781
|
-
if (!matchesShortcutKeyDown(event, shortcutRef.current)) return;
|
|
782
|
-
if (preventDefaultRef.current) event.preventDefault();
|
|
783
|
-
const href = getHrefRef.current();
|
|
784
|
-
if (!href) return;
|
|
785
|
-
callMaybeAsync(prefetchRef.current, href);
|
|
786
|
-
if (triggerRef.current === "keydown") {
|
|
787
|
-
callMaybeAsync(navigateRef.current, href);
|
|
788
|
-
return;
|
|
789
|
-
}
|
|
790
|
-
waitingForShortcutKeyUpRef.current = true;
|
|
791
|
-
};
|
|
792
|
-
const onKeyUp = (event_0) => {
|
|
793
|
-
if (!enabledRef.current) return;
|
|
794
|
-
if (triggerRef.current !== "keyup") return;
|
|
795
|
-
if (!waitingForShortcutKeyUpRef.current) return;
|
|
796
|
-
if (normalizeKey(event_0.key) !== normalizeKey(shortcutRef.current.key)) return;
|
|
797
|
-
waitingForShortcutKeyUpRef.current = false;
|
|
798
|
-
if (ignoreTypingTargetRef.current && isTypingTargetRef.current(event_0.target)) return;
|
|
799
|
-
if (preventDefaultRef.current) event_0.preventDefault();
|
|
800
|
-
const href_0 = getHrefRef.current();
|
|
801
|
-
if (!href_0) return;
|
|
802
|
-
callMaybeAsync(navigateRef.current, href_0);
|
|
803
|
-
};
|
|
804
|
-
const onBlur = () => {
|
|
805
|
-
waitingForShortcutKeyUpRef.current = false;
|
|
806
|
-
};
|
|
807
|
-
window.addEventListener("keydown", onKeyDown);
|
|
808
|
-
window.addEventListener("keyup", onKeyUp);
|
|
809
|
-
window.addEventListener("blur", onBlur);
|
|
810
|
-
return () => {
|
|
811
|
-
window.removeEventListener("keydown", onKeyDown);
|
|
812
|
-
window.removeEventListener("keyup", onKeyUp);
|
|
813
|
-
window.removeEventListener("blur", onBlur);
|
|
814
|
-
};
|
|
815
|
-
}, []);
|
|
962
|
+
export {
|
|
963
|
+
Link,
|
|
964
|
+
RoutePrefetchProvider,
|
|
965
|
+
getNavigationGuards,
|
|
966
|
+
lazyRoute,
|
|
967
|
+
removeNavigationGuard,
|
|
968
|
+
subscribeNavigationGuards,
|
|
969
|
+
upsertNavigationGuard,
|
|
970
|
+
useApplyMeta,
|
|
971
|
+
useQueryOverlay,
|
|
972
|
+
useRegisterNavigationGuard,
|
|
973
|
+
useRoutePrefetch,
|
|
974
|
+
useShortcutPrefetchNavigate
|
|
816
975
|
};
|
|
817
|
-
//#
|
|
818
|
-
export { Link, RoutePrefetchProvider, getNavigationGuards, lazyRoute, removeNavigationGuard, subscribeNavigationGuards, upsertNavigationGuard, useApplyMeta, useQueryOverlay, useRegisterNavigationGuard, useRoutePrefetch, useShortcutPrefetchNavigate };
|
|
819
|
-
|
|
820
|
-
//# sourceMappingURL=index.js.map
|
|
976
|
+
//# sourceMappingURL=index.js.map
|