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