@qwik.dev/router 2.0.0-beta.13 → 2.0.0-beta.14
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/lib/adapters/azure-swa/vite/index.mjs +7 -7
- package/lib/adapters/bun-server/vite/index.mjs +7 -7
- package/lib/adapters/cloud-run/vite/index.mjs +7 -7
- package/lib/adapters/cloudflare-pages/vite/index.mjs +8 -8
- package/lib/adapters/deno-server/vite/index.mjs +7 -7
- package/lib/adapters/netlify-edge/vite/index.mjs +7 -7
- package/lib/adapters/node-server/vite/index.mjs +7 -7
- package/lib/adapters/shared/vite/index.mjs +8 -8
- package/lib/adapters/ssg/vite/index.mjs +7 -8
- package/lib/adapters/vercel-edge/vite/index.mjs +7 -7
- package/lib/chunks/error-handler.mjs +2 -4
- package/lib/chunks/format-error.mjs +6 -6
- package/lib/chunks/fs.mjs +6 -27
- package/lib/chunks/index.mjs +39 -31
- package/lib/chunks/mime-types.mjs +2 -3
- package/lib/chunks/routing.qwik.mjs +23 -47
- package/lib/chunks/types.qwik.mjs +2 -5
- package/lib/index.d.ts +2 -1
- package/lib/index.qwik.mjs +48 -68
- package/lib/middleware/aws-lambda/index.mjs +4 -5
- package/lib/middleware/azure-swa/index.mjs +6 -7
- package/lib/middleware/bun/index.mjs +8 -9
- package/lib/middleware/cloudflare-pages/index.mjs +5 -6
- package/lib/middleware/deno/index.mjs +7 -8
- package/lib/middleware/firebase/index.mjs +4 -5
- package/lib/middleware/netlify-edge/index.mjs +5 -6
- package/lib/middleware/node/index.mjs +15 -11
- package/lib/middleware/request-handler/index.d.ts +2 -2
- package/lib/middleware/request-handler/index.mjs +64 -79
- package/lib/middleware/vercel-edge/index.mjs +5 -6
- package/lib/service-worker/index.mjs +2 -3
- package/lib/ssg/index.mjs +3 -4
- package/lib/vite/index.d.ts +7 -1
- package/lib/vite/index.mjs +91 -68
- package/package.json +21 -39
- package/lib/adapters/azure-swa/vite/index.cjs +0 -61
- package/lib/adapters/bun-server/vite/index.cjs +0 -27
- package/lib/adapters/cloud-run/vite/index.cjs +0 -24
- package/lib/adapters/cloudflare-pages/vite/index.cjs +0 -65
- package/lib/adapters/deno-server/vite/index.cjs +0 -39
- package/lib/adapters/netlify-edge/vite/index.cjs +0 -88
- package/lib/adapters/node-server/vite/index.cjs +0 -27
- package/lib/adapters/shared/vite/index.cjs +0 -306
- package/lib/adapters/ssg/vite/index.cjs +0 -19
- package/lib/adapters/vercel-edge/vite/index.cjs +0 -81
- package/lib/chunks/error-handler.cjs +0 -58
- package/lib/chunks/format-error.cjs +0 -136
- package/lib/chunks/fs.cjs +0 -274
- package/lib/chunks/index.cjs +0 -877
- package/lib/chunks/mime-types.cjs +0 -52
- package/lib/chunks/routing.qwik.cjs +0 -452
- package/lib/chunks/types.qwik.cjs +0 -24
- package/lib/index.qwik.cjs +0 -1662
- package/lib/middleware/aws-lambda/index.cjs +0 -52
- package/lib/middleware/azure-swa/index.cjs +0 -92
- package/lib/middleware/bun/index.cjs +0 -143
- package/lib/middleware/cloudflare-pages/index.cjs +0 -96
- package/lib/middleware/deno/index.cjs +0 -130
- package/lib/middleware/firebase/index.cjs +0 -33
- package/lib/middleware/netlify-edge/index.cjs +0 -71
- package/lib/middleware/node/index.cjs +0 -219
- package/lib/middleware/request-handler/index.cjs +0 -1488
- package/lib/middleware/vercel-edge/index.cjs +0 -98
- package/lib/service-worker/index.cjs +0 -5
- package/lib/ssg/index.cjs +0 -15
- package/lib/vite/index.cjs +0 -2021
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { createAsyncComputed$, isBrowser } from
|
|
2
|
-
import { p } from
|
|
3
|
-
import { _deserialize, _UNINITIALIZED } from
|
|
4
|
-
import { R as RouteDataProp, M as MenuDataProp } from
|
|
1
|
+
import { createAsyncComputed$, isBrowser } from '@qwik.dev/core';
|
|
2
|
+
import { p } from '@qwik.dev/core/preloader';
|
|
3
|
+
import { _deserialize, _UNINITIALIZED } from '@qwik.dev/core/internal';
|
|
4
|
+
import { R as RouteDataProp, M as MenuDataProp } from './types.qwik.mjs';
|
|
5
|
+
|
|
5
6
|
const MODULE_CACHE = /* @__PURE__ */ new WeakMap();
|
|
6
7
|
const CLIENT_DATA_CACHE = /* @__PURE__ */ new Map();
|
|
7
8
|
const QACTION_KEY = "qaction";
|
|
@@ -10,6 +11,7 @@ const QFN_KEY = "qfunc";
|
|
|
10
11
|
const QDATA_KEY = "qdata";
|
|
11
12
|
const Q_ROUTE = "q:route";
|
|
12
13
|
const DEFAULT_LOADERS_SERIALIZATION_STRATEGY = globalThis.__DEFAULT_LOADERS_SERIALIZATION_STRATEGY__ || "never";
|
|
14
|
+
|
|
13
15
|
const MAX_Q_DATA_RETRY_COUNT = 3;
|
|
14
16
|
const loadClientData = async (url, element, opts, retryCount = 0) => {
|
|
15
17
|
const pagePathname = url.pathname;
|
|
@@ -115,6 +117,7 @@ const getFetchOptions = (action, noCache) => {
|
|
|
115
117
|
};
|
|
116
118
|
}
|
|
117
119
|
};
|
|
120
|
+
|
|
118
121
|
const toPath = (url) => url.pathname + url.search + url.hash;
|
|
119
122
|
const toUrl = (url, baseUrl) => new URL(url, baseUrl.href);
|
|
120
123
|
const isSameOrigin = (a, b) => a.origin === b.origin;
|
|
@@ -182,6 +185,7 @@ const createLoaderSignal = (loadersObject, loaderId, url, serializationStrategy,
|
|
|
182
185
|
}
|
|
183
186
|
);
|
|
184
187
|
};
|
|
188
|
+
|
|
185
189
|
const clientNavigate = (win, navType, fromURL, toURL, replaceState = false) => {
|
|
186
190
|
if (navType !== "popstate") {
|
|
187
191
|
const samePath = isSamePath(fromURL, toURL);
|
|
@@ -213,6 +217,7 @@ const preloadRouteBundles = (path, probability = 0.8) => {
|
|
|
213
217
|
p(path, probability);
|
|
214
218
|
}
|
|
215
219
|
};
|
|
220
|
+
|
|
216
221
|
function matchRoute(route, path) {
|
|
217
222
|
const routeIdx = startIdxSkipSlash(route);
|
|
218
223
|
const routeLength = lengthNoTrailingSlash(route);
|
|
@@ -228,24 +233,12 @@ function matchRoutePart(route, routeIdx, routeLength, path, pathIdx, pathLength)
|
|
|
228
233
|
while (routeIdx < routeLength) {
|
|
229
234
|
const routeCh = route.charCodeAt(routeIdx++);
|
|
230
235
|
const pathCh = path.charCodeAt(pathIdx++);
|
|
231
|
-
if (routeCh === 91) {
|
|
236
|
+
if (routeCh === 91 /* OPEN_BRACKET */) {
|
|
232
237
|
const isMany = isThreeDots(route, routeIdx);
|
|
233
238
|
const paramNameStart = routeIdx + (isMany ? 3 : 0);
|
|
234
|
-
const paramNameEnd = scan(
|
|
235
|
-
route,
|
|
236
|
-
paramNameStart,
|
|
237
|
-
routeLength,
|
|
238
|
-
93
|
|
239
|
-
/* CLOSE_BRACKET */
|
|
240
|
-
);
|
|
239
|
+
const paramNameEnd = scan(route, paramNameStart, routeLength, 93 /* CLOSE_BRACKET */);
|
|
241
240
|
const paramName = route.substring(paramNameStart, paramNameEnd);
|
|
242
|
-
const paramSuffixEnd = scan(
|
|
243
|
-
route,
|
|
244
|
-
paramNameEnd + 1,
|
|
245
|
-
routeLength,
|
|
246
|
-
47
|
|
247
|
-
/* SLASH */
|
|
248
|
-
);
|
|
241
|
+
const paramSuffixEnd = scan(route, paramNameEnd + 1, routeLength, 47 /* SLASH */);
|
|
249
242
|
const suffix = route.substring(paramNameEnd + 1, paramSuffixEnd);
|
|
250
243
|
routeIdx = paramNameEnd + 1;
|
|
251
244
|
const paramValueStart = pathIdx - 1;
|
|
@@ -264,7 +257,7 @@ function matchRoutePart(route, routeIdx, routeLength, path, pathIdx, pathLength)
|
|
|
264
257
|
return Object.assign(params || (params = {}), match);
|
|
265
258
|
}
|
|
266
259
|
}
|
|
267
|
-
const paramValueEnd = scan(path, paramValueStart, pathLength, 47
|
|
260
|
+
const paramValueEnd = scan(path, paramValueStart, pathLength, 47 /* SLASH */, suffix);
|
|
268
261
|
if (paramValueEnd == -1) {
|
|
269
262
|
return null;
|
|
270
263
|
}
|
|
@@ -287,21 +280,21 @@ function matchRoutePart(route, routeIdx, routeLength, path, pathIdx, pathLength)
|
|
|
287
280
|
}
|
|
288
281
|
}
|
|
289
282
|
function isRestParameter(text, idx) {
|
|
290
|
-
return text.charCodeAt(idx) === 91 && isThreeDots(text, idx + 1);
|
|
283
|
+
return text.charCodeAt(idx) === 91 /* OPEN_BRACKET */ && isThreeDots(text, idx + 1);
|
|
291
284
|
}
|
|
292
285
|
function lengthNoTrailingSlash(text) {
|
|
293
286
|
const length = text.length;
|
|
294
|
-
return length > 1 && text.charCodeAt(length - 1) === 47 ? length - 1 : length;
|
|
287
|
+
return length > 1 && text.charCodeAt(length - 1) === 47 /* SLASH */ ? length - 1 : length;
|
|
295
288
|
}
|
|
296
289
|
function allConsumed(text, idx) {
|
|
297
290
|
const length = text.length;
|
|
298
|
-
return idx >= length || idx == length - 1 && text.charCodeAt(idx) === 47
|
|
291
|
+
return idx >= length || idx == length - 1 && text.charCodeAt(idx) === 47 /* SLASH */;
|
|
299
292
|
}
|
|
300
293
|
function startIdxSkipSlash(text) {
|
|
301
|
-
return text.charCodeAt(0) === 47 ? 1 : 0;
|
|
294
|
+
return text.charCodeAt(0) === 47 /* SLASH */ ? 1 : 0;
|
|
302
295
|
}
|
|
303
296
|
function isThreeDots(text, idx) {
|
|
304
|
-
return text.charCodeAt(idx) === 46 && text.charCodeAt(idx + 1) === 46 && text.charCodeAt(idx + 2) === 46
|
|
297
|
+
return text.charCodeAt(idx) === 46 /* DOT */ && text.charCodeAt(idx + 1) === 46 /* DOT */ && text.charCodeAt(idx + 2) === 46 /* DOT */;
|
|
305
298
|
}
|
|
306
299
|
function scan(text, idx, end, ch, suffix = "") {
|
|
307
300
|
while (idx < end && text.charCodeAt(idx) !== ch) {
|
|
@@ -316,7 +309,7 @@ function scan(text, idx, end, ch, suffix = "") {
|
|
|
316
309
|
return idx - suffixLength;
|
|
317
310
|
}
|
|
318
311
|
function recursiveScan(paramName, suffix, path, pathStart, pathLength, route, routeStart, routeLength) {
|
|
319
|
-
if (path.charCodeAt(pathStart) === 47) {
|
|
312
|
+
if (path.charCodeAt(pathStart) === 47 /* SLASH */) {
|
|
320
313
|
pathStart++;
|
|
321
314
|
}
|
|
322
315
|
let pathIdx = pathLength;
|
|
@@ -346,6 +339,7 @@ function lastIndexOf(text, start, match, searchIdx, notFoundIdx) {
|
|
|
346
339
|
}
|
|
347
340
|
return idx > start ? idx : notFoundIdx;
|
|
348
341
|
}
|
|
342
|
+
|
|
349
343
|
const deepFreeze = (obj) => {
|
|
350
344
|
if (obj == null) {
|
|
351
345
|
return obj;
|
|
@@ -358,6 +352,7 @@ const deepFreeze = (obj) => {
|
|
|
358
352
|
});
|
|
359
353
|
return Object.freeze(obj);
|
|
360
354
|
};
|
|
355
|
+
|
|
361
356
|
const loadRoute = async (routes, menus, cacheModules, pathname, isInternal) => {
|
|
362
357
|
if (!Array.isArray(routes)) {
|
|
363
358
|
return null;
|
|
@@ -430,24 +425,5 @@ const getMenuLoader = (menus, pathname) => {
|
|
|
430
425
|
}
|
|
431
426
|
}
|
|
432
427
|
};
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
DEFAULT_LOADERS_SERIALIZATION_STRATEGY as D,
|
|
436
|
-
Q_ROUTE as Q,
|
|
437
|
-
isSamePath as a,
|
|
438
|
-
isSameOrigin as b,
|
|
439
|
-
createLoaderSignal as c,
|
|
440
|
-
loadRoute as d,
|
|
441
|
-
clientNavigate as e,
|
|
442
|
-
deepFreeze as f,
|
|
443
|
-
getClientNavPath as g,
|
|
444
|
-
QFN_KEY as h,
|
|
445
|
-
isPromise as i,
|
|
446
|
-
QACTION_KEY as j,
|
|
447
|
-
QDATA_KEY as k,
|
|
448
|
-
loadClientData as l,
|
|
449
|
-
QLOADER_KEY as m,
|
|
450
|
-
preloadRouteBundles as p,
|
|
451
|
-
shouldPreload as s,
|
|
452
|
-
toUrl as t
|
|
453
|
-
};
|
|
428
|
+
|
|
429
|
+
export { CLIENT_DATA_CACHE as C, DEFAULT_LOADERS_SERIALIZATION_STRATEGY as D, Q_ROUTE as Q, isSamePath as a, isSameOrigin as b, createLoaderSignal as c, loadRoute as d, clientNavigate as e, deepFreeze as f, getClientNavPath as g, QFN_KEY as h, isPromise as i, QACTION_KEY as j, QDATA_KEY as k, loadClientData as l, QLOADER_KEY as m, preloadRouteBundles as p, shouldPreload as s, toUrl as t };
|
|
@@ -18,8 +18,5 @@ var LoadedRouteProp = /* @__PURE__ */ ((LoadedRouteProp2) => {
|
|
|
18
18
|
LoadedRouteProp2[LoadedRouteProp2["RouteBundleNames"] = 4] = "RouteBundleNames";
|
|
19
19
|
return LoadedRouteProp2;
|
|
20
20
|
})(LoadedRouteProp || {});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
MenuDataProp as M,
|
|
24
|
-
RouteDataProp as R
|
|
25
|
-
};
|
|
21
|
+
|
|
22
|
+
export { LoadedRouteProp as L, MenuDataProp as M, RouteDataProp as R };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference path="./modules.d.ts" />
|
|
2
2
|
|
|
3
|
+
import type { AsyncComputedReadonlySignal } from '@qwik.dev/core/internal';
|
|
3
4
|
import { Component } from '@qwik.dev/core';
|
|
4
5
|
import { Cookie } from '@qwik.dev/router/middleware/request-handler';
|
|
5
6
|
import { CookieOptions } from '@qwik.dev/router/middleware/request-handler';
|
|
@@ -527,7 +528,7 @@ declare type LoaderOptions = {
|
|
|
527
528
|
};
|
|
528
529
|
|
|
529
530
|
/** @public */
|
|
530
|
-
export declare type LoaderSignal<TYPE> = TYPE extends () => ValueOrPromise<infer VALIDATOR> ? ReadonlySignal<ValueOrPromise<VALIDATOR>> : ReadonlySignal<TYPE>;
|
|
531
|
+
export declare type LoaderSignal<TYPE> = (TYPE extends () => ValueOrPromise<infer VALIDATOR> ? ReadonlySignal<ValueOrPromise<VALIDATOR>> : ReadonlySignal<TYPE>) & Pick<AsyncComputedReadonlySignal, 'promise' | 'loading' | 'error'>;
|
|
531
532
|
|
|
532
533
|
/** @public */
|
|
533
534
|
export declare type MenuData = [pathname: string, menuLoader: MenuModuleLoader];
|
package/lib/index.qwik.mjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { jsx, Fragment, jsxs } from
|
|
2
|
-
import { component$, useErrorBoundary, useOnWindow, $, Slot, createContextId, useContext, implicit$FirstArg, noSerialize, useVisibleTask$, useServerData, useSignal, untrack, sync$, isDev, withLocale, event$, isServer, useStyles$, useStore, isBrowser, useContextProvider, useTask$, getLocale, jsx as jsx$1, SkipRender, createElement } from
|
|
3
|
-
import { g as getClientNavPath, s as shouldPreload, p as preloadRouteBundles, l as loadClientData, i as isPromise, a as isSamePath, c as createLoaderSignal, t as toUrl, b as isSameOrigin, d as loadRoute, D as DEFAULT_LOADERS_SERIALIZATION_STRATEGY, C as CLIENT_DATA_CACHE, Q as Q_ROUTE, e as clientNavigate, f as deepFreeze, h as QFN_KEY, j as QACTION_KEY, k as QDATA_KEY } from
|
|
4
|
-
import * as qwikRouterConfig from
|
|
5
|
-
import { _getContextContainer, SerializerSymbol, _UNINITIALIZED, _getContextElement, _hasStoreEffects, _getQContainerElement, forceStoreEffects, _waitUntilRendered, _getContextEvent, _serialize, _deserialize, _resolveContextWithoutSequentialScope } from
|
|
6
|
-
import { _asyncRequestStore } from
|
|
7
|
-
import * as v from
|
|
8
|
-
import * as z from
|
|
9
|
-
|
|
10
|
-
import swRegister from
|
|
11
|
-
import { renderToStream } from
|
|
12
|
-
import
|
|
13
|
-
import
|
|
1
|
+
import { jsx, Fragment, jsxs } from '@qwik.dev/core/jsx-runtime';
|
|
2
|
+
import { component$, useErrorBoundary, useOnWindow, $, Slot, createContextId, useContext, implicit$FirstArg, noSerialize, useVisibleTask$, useServerData, useSignal, untrack, sync$, isDev, withLocale, event$, isServer, useStyles$, useStore, isBrowser, useContextProvider, useTask$, getLocale, jsx as jsx$1, SkipRender, createElement } from '@qwik.dev/core';
|
|
3
|
+
import { g as getClientNavPath, s as shouldPreload, p as preloadRouteBundles, l as loadClientData, i as isPromise, a as isSamePath, c as createLoaderSignal, t as toUrl, b as isSameOrigin, d as loadRoute, D as DEFAULT_LOADERS_SERIALIZATION_STRATEGY, C as CLIENT_DATA_CACHE, Q as Q_ROUTE, e as clientNavigate, f as deepFreeze, h as QFN_KEY, j as QACTION_KEY, k as QDATA_KEY } from './chunks/routing.qwik.mjs';
|
|
4
|
+
import * as qwikRouterConfig from '@qwik-router-config';
|
|
5
|
+
import { _getContextContainer, SerializerSymbol, _UNINITIALIZED, _getContextElement, _hasStoreEffects, _getQContainerElement, forceStoreEffects, _waitUntilRendered, _getContextEvent, _serialize, _deserialize, _resolveContextWithoutSequentialScope } from '@qwik.dev/core/internal';
|
|
6
|
+
import { _asyncRequestStore } from '@qwik.dev/router/middleware/request-handler';
|
|
7
|
+
import * as v from 'valibot';
|
|
8
|
+
import * as z from 'zod';
|
|
9
|
+
export { z } from 'zod';
|
|
10
|
+
import swRegister from '@qwik-router-sw-register';
|
|
11
|
+
import { renderToStream } from '@qwik.dev/core/server';
|
|
12
|
+
import '@qwik.dev/core/preloader';
|
|
13
|
+
import './chunks/types.qwik.mjs';
|
|
14
|
+
|
|
14
15
|
const ErrorBoundary = component$((props) => {
|
|
15
16
|
const store = useErrorBoundary();
|
|
16
17
|
useOnWindow(
|
|
@@ -24,6 +25,7 @@ const ErrorBoundary = component$((props) => {
|
|
|
24
25
|
}
|
|
25
26
|
return /* @__PURE__ */ jsx(Slot, {});
|
|
26
27
|
});
|
|
28
|
+
|
|
27
29
|
const RouteStateContext = /* @__PURE__ */ createContextId("qc-s");
|
|
28
30
|
const ContentContext = /* @__PURE__ */ createContextId("qc-c");
|
|
29
31
|
const ContentInternalContext = /* @__PURE__ */ createContextId("qc-ic");
|
|
@@ -32,6 +34,7 @@ const RouteLocationContext = /* @__PURE__ */ createContextId("qc-l");
|
|
|
32
34
|
const RouteNavigateContext = /* @__PURE__ */ createContextId("qc-n");
|
|
33
35
|
const RouteActionContext = /* @__PURE__ */ createContextId("qc-a");
|
|
34
36
|
const RoutePreventNavigateContext = /* @__PURE__ */ createContextId("qc-p");
|
|
37
|
+
|
|
35
38
|
const useContent = () => useContext(ContentContext);
|
|
36
39
|
const useDocumentHead = () => useContext(DocumentHeadContext);
|
|
37
40
|
const useLocation = () => useContext(RouteLocationContext);
|
|
@@ -48,6 +51,7 @@ const usePreventNavigateQrl = (fn) => {
|
|
|
48
51
|
const usePreventNavigate$ = implicit$FirstArg(usePreventNavigateQrl);
|
|
49
52
|
const useAction = () => useContext(RouteActionContext);
|
|
50
53
|
const useQwikRouterEnv = () => noSerialize(useServerData("qwikrouter"));
|
|
54
|
+
|
|
51
55
|
const Link = component$((props) => {
|
|
52
56
|
const nav = useNavigate();
|
|
53
57
|
const loc = useLocation();
|
|
@@ -141,6 +145,7 @@ const Link = component$((props) => {
|
|
|
141
145
|
}
|
|
142
146
|
);
|
|
143
147
|
});
|
|
148
|
+
|
|
144
149
|
const resolveHead = (endpoint, routeLocation, contentModules, locale, defaults) => withLocale(locale, () => {
|
|
145
150
|
const head = createDocumentHead(defaults);
|
|
146
151
|
const getData = ((loaderOrAction) => {
|
|
@@ -214,28 +219,29 @@ const createDocumentHead = (defaults) => ({
|
|
|
214
219
|
scripts: [...defaults?.scripts || []],
|
|
215
220
|
frontmatter: { ...defaults?.frontmatter }
|
|
216
221
|
});
|
|
222
|
+
|
|
217
223
|
function callRestoreScrollOnDocument() {
|
|
218
224
|
if (document.__q_scroll_restore__) {
|
|
219
225
|
document.__q_scroll_restore__();
|
|
220
226
|
document.__q_scroll_restore__ = void 0;
|
|
221
227
|
}
|
|
222
228
|
}
|
|
223
|
-
const restoreScroll = (type,
|
|
229
|
+
const restoreScroll = (type, toUrl, fromUrl, scroller, scrollState) => {
|
|
224
230
|
if (type === "popstate" && scrollState) {
|
|
225
231
|
scroller.scrollTo(scrollState.x, scrollState.y);
|
|
226
232
|
} else if (type === "link" || type === "form") {
|
|
227
|
-
if (!hashScroll(
|
|
233
|
+
if (!hashScroll(toUrl, fromUrl)) {
|
|
228
234
|
scroller.scrollTo(0, 0);
|
|
229
235
|
}
|
|
230
236
|
}
|
|
231
237
|
};
|
|
232
|
-
const hashScroll = (
|
|
233
|
-
const elmId =
|
|
238
|
+
const hashScroll = (toUrl, fromUrl) => {
|
|
239
|
+
const elmId = toUrl.hash.slice(1);
|
|
234
240
|
const elm = elmId && document.getElementById(elmId);
|
|
235
241
|
if (elm) {
|
|
236
242
|
elm.scrollIntoView();
|
|
237
243
|
return true;
|
|
238
|
-
} else if (!elm &&
|
|
244
|
+
} else if (!elm && toUrl.hash && isSamePath(toUrl, fromUrl)) {
|
|
239
245
|
return true;
|
|
240
246
|
}
|
|
241
247
|
return false;
|
|
@@ -257,6 +263,7 @@ const saveScrollHistory = (scrollState) => {
|
|
|
257
263
|
state._qRouterScroll = scrollState;
|
|
258
264
|
history.replaceState(state, "");
|
|
259
265
|
};
|
|
266
|
+
|
|
260
267
|
const spaInit = event$((_, el) => {
|
|
261
268
|
if (!window._qRouterSPA && !window._qRouterInitPopstate) {
|
|
262
269
|
const currentPath = location.pathname + location.search;
|
|
@@ -265,7 +272,7 @@ const spaInit = event$((_, el) => {
|
|
|
265
272
|
window.scrollTo(scrollState.x, scrollState.y);
|
|
266
273
|
}
|
|
267
274
|
};
|
|
268
|
-
const
|
|
275
|
+
const currentScrollState = () => {
|
|
269
276
|
const elm = document.documentElement;
|
|
270
277
|
return {
|
|
271
278
|
x: elm.scrollLeft,
|
|
@@ -276,7 +283,7 @@ const spaInit = event$((_, el) => {
|
|
|
276
283
|
};
|
|
277
284
|
const saveScrollState = (scrollState) => {
|
|
278
285
|
const state = history.state || {};
|
|
279
|
-
state._qRouterScroll = scrollState ||
|
|
286
|
+
state._qRouterScroll = scrollState || currentScrollState();
|
|
280
287
|
history.replaceState(state, "");
|
|
281
288
|
};
|
|
282
289
|
saveScrollState();
|
|
@@ -322,7 +329,7 @@ const spaInit = event$((_, el) => {
|
|
|
322
329
|
);
|
|
323
330
|
}
|
|
324
331
|
}
|
|
325
|
-
state._qRouterScroll = state._qRouterScroll ||
|
|
332
|
+
state._qRouterScroll = state._qRouterScroll || currentScrollState();
|
|
326
333
|
return state;
|
|
327
334
|
};
|
|
328
335
|
history.pushState = (state, title, url) => {
|
|
@@ -356,7 +363,7 @@ const spaInit = event$((_, el) => {
|
|
|
356
363
|
} else {
|
|
357
364
|
window._qRouterScrollEnabled = false;
|
|
358
365
|
clearTimeout(window._qRouterScrollDebounce);
|
|
359
|
-
saveScrollState({ ...
|
|
366
|
+
saveScrollState({ ...currentScrollState(), x: 0, y: 0 });
|
|
360
367
|
location.reload();
|
|
361
368
|
}
|
|
362
369
|
} else {
|
|
@@ -397,6 +404,7 @@ const spaInit = event$((_, el) => {
|
|
|
397
404
|
}, 0);
|
|
398
405
|
}
|
|
399
406
|
});
|
|
407
|
+
|
|
400
408
|
const startViewTransition = (params) => {
|
|
401
409
|
if (!params.update) {
|
|
402
410
|
return;
|
|
@@ -415,7 +423,9 @@ const startViewTransition = (params) => {
|
|
|
415
423
|
params.update?.();
|
|
416
424
|
}
|
|
417
425
|
};
|
|
426
|
+
|
|
418
427
|
const transitionCss = "@layer qwik{@supports selector(html:active-view-transition-type(type)){html:active-view-transition-type(qwik-navigation){:root{view-transition-name:none}}}@supports not selector(html:active-view-transition-type(type)){:root{view-transition-name:none}}}";
|
|
428
|
+
|
|
419
429
|
const QWIK_CITY_SCROLLER = "_qCityScroller";
|
|
420
430
|
const QWIK_ROUTER_SCROLLER = "_qRouterScroller";
|
|
421
431
|
const preventNav = {};
|
|
@@ -470,8 +480,8 @@ const useQwikRouter = (props) => {
|
|
|
470
480
|
}
|
|
471
481
|
loadersObject[SerializerSymbol] = (obj) => {
|
|
472
482
|
const loadersSerializationObject = {};
|
|
473
|
-
for (const [k,
|
|
474
|
-
loadersSerializationObject[k] = getSerializationStrategy(k) === "always" ?
|
|
483
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
484
|
+
loadersSerializationObject[k] = getSerializationStrategy(k) === "always" ? v : _UNINITIALIZED;
|
|
475
485
|
}
|
|
476
486
|
return loadersSerializationObject;
|
|
477
487
|
};
|
|
@@ -504,7 +514,7 @@ const useQwikRouter = (props) => {
|
|
|
504
514
|
if (!isBrowser) {
|
|
505
515
|
return;
|
|
506
516
|
}
|
|
507
|
-
preventNav.$handler$
|
|
517
|
+
preventNav.$handler$ ||= (event) => {
|
|
508
518
|
internalState.navCount++;
|
|
509
519
|
if (!preventNav.$cbs$) {
|
|
510
520
|
return;
|
|
@@ -516,8 +526,8 @@ const useQwikRouter = (props) => {
|
|
|
516
526
|
event.preventDefault();
|
|
517
527
|
event.returnValue = true;
|
|
518
528
|
}
|
|
519
|
-
}
|
|
520
|
-
(preventNav.$cbs$
|
|
529
|
+
};
|
|
530
|
+
(preventNav.$cbs$ ||= /* @__PURE__ */ new Set()).add(fn$);
|
|
521
531
|
fn$.resolve();
|
|
522
532
|
window.addEventListener("beforeunload", preventNav.$handler$);
|
|
523
533
|
return () => {
|
|
@@ -966,6 +976,7 @@ const QwikRouterMockProvider = component$((props) => {
|
|
|
966
976
|
return /* @__PURE__ */ jsx(Slot, {});
|
|
967
977
|
});
|
|
968
978
|
const QwikCityMockProvider = QwikRouterMockProvider;
|
|
979
|
+
|
|
969
980
|
const RouterOutlet = component$(() => {
|
|
970
981
|
const serverData = useServerData("containerAttributes");
|
|
971
982
|
if (!serverData) {
|
|
@@ -1007,6 +1018,7 @@ const RouterOutlet = component$(() => {
|
|
|
1007
1018
|
}
|
|
1008
1019
|
return SkipRender;
|
|
1009
1020
|
});
|
|
1021
|
+
|
|
1010
1022
|
const routeActionQrl = ((actionQrl, ...rest) => {
|
|
1011
1023
|
const { id, validators } = getValidators(rest, actionQrl);
|
|
1012
1024
|
function action() {
|
|
@@ -1425,7 +1437,9 @@ const deserializeStream = async function* (stream, ctxElm, abortSignal) {
|
|
|
1425
1437
|
reader.releaseLock();
|
|
1426
1438
|
}
|
|
1427
1439
|
};
|
|
1440
|
+
|
|
1428
1441
|
const ServiceWorkerRegister = (props) => /* @__PURE__ */ jsx("script", { type: "module", dangerouslySetInnerHTML: swRegister, nonce: props.nonce });
|
|
1442
|
+
|
|
1429
1443
|
const Form = ({ action, spaReset, reloadDocument, onSubmit$, ...rest }, key) => {
|
|
1430
1444
|
if (action) {
|
|
1431
1445
|
const isArrayApi = Array.isArray(onSubmit$);
|
|
@@ -1525,6 +1539,7 @@ const GetForm = component$(
|
|
|
1525
1539
|
);
|
|
1526
1540
|
}
|
|
1527
1541
|
);
|
|
1542
|
+
|
|
1528
1543
|
const untypedAppUrl = function appUrl(route, params, paramsPrefix = "") {
|
|
1529
1544
|
const path = route.split("/");
|
|
1530
1545
|
for (let i = 0; i < path.length; i++) {
|
|
@@ -1561,12 +1576,14 @@ function omitProps(obj, keys) {
|
|
|
1561
1576
|
}
|
|
1562
1577
|
return omittedObj;
|
|
1563
1578
|
}
|
|
1579
|
+
|
|
1564
1580
|
const createRenderer = (getOptions) => {
|
|
1565
1581
|
return ((opts) => {
|
|
1566
|
-
const { jsx
|
|
1567
|
-
return renderToStream(
|
|
1582
|
+
const { jsx, options } = getOptions(opts);
|
|
1583
|
+
return renderToStream(jsx, options);
|
|
1568
1584
|
});
|
|
1569
1585
|
};
|
|
1586
|
+
|
|
1570
1587
|
const DocumentHeadTags = component$((props) => {
|
|
1571
1588
|
let head = useDocumentHead();
|
|
1572
1589
|
if (props) {
|
|
@@ -1600,42 +1617,5 @@ const DocumentHeadTags = component$((props) => {
|
|
|
1600
1617
|
})
|
|
1601
1618
|
] });
|
|
1602
1619
|
});
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
ErrorBoundary,
|
|
1606
|
-
Form,
|
|
1607
|
-
Link,
|
|
1608
|
-
QWIK_CITY_SCROLLER,
|
|
1609
|
-
QWIK_ROUTER_SCROLLER,
|
|
1610
|
-
QwikCityMockProvider,
|
|
1611
|
-
QwikCityProvider,
|
|
1612
|
-
QwikRouterMockProvider,
|
|
1613
|
-
QwikRouterProvider,
|
|
1614
|
-
RouterOutlet,
|
|
1615
|
-
ServiceWorkerRegister,
|
|
1616
|
-
createRenderer,
|
|
1617
|
-
globalAction$,
|
|
1618
|
-
globalActionQrl,
|
|
1619
|
-
omitProps,
|
|
1620
|
-
routeAction$,
|
|
1621
|
-
routeActionQrl,
|
|
1622
|
-
routeLoader$,
|
|
1623
|
-
routeLoaderQrl,
|
|
1624
|
-
server$,
|
|
1625
|
-
serverQrl,
|
|
1626
|
-
untypedAppUrl,
|
|
1627
|
-
useContent,
|
|
1628
|
-
useDocumentHead,
|
|
1629
|
-
useLocation,
|
|
1630
|
-
useNavigate,
|
|
1631
|
-
usePreventNavigate$,
|
|
1632
|
-
usePreventNavigateQrl,
|
|
1633
|
-
useQwikRouter,
|
|
1634
|
-
valibot$,
|
|
1635
|
-
valibotQrl,
|
|
1636
|
-
validator$,
|
|
1637
|
-
validatorQrl,
|
|
1638
|
-
z2 as z,
|
|
1639
|
-
zod$,
|
|
1640
|
-
zodQrl
|
|
1641
|
-
};
|
|
1620
|
+
|
|
1621
|
+
export { DocumentHeadTags, ErrorBoundary, Form, Link, QWIK_CITY_SCROLLER, QWIK_ROUTER_SCROLLER, QwikCityMockProvider, QwikCityProvider, QwikRouterMockProvider, QwikRouterProvider, RouterOutlet, ServiceWorkerRegister, createRenderer, globalAction$, globalActionQrl, omitProps, routeAction$, routeActionQrl, routeLoader$, routeLoaderQrl, server$, serverQrl, untypedAppUrl, useContent, useDocumentHead, useLocation, useNavigate, usePreventNavigate$, usePreventNavigateQrl, useQwikRouter, valibot$, valibotQrl, validator$, validatorQrl, zod$, zodQrl };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createQwikRouter as createQwikRouter$1 } from
|
|
1
|
+
import { createQwikRouter as createQwikRouter$1 } from '@qwik.dev/router/middleware/node';
|
|
2
|
+
|
|
2
3
|
function createQwikRouter(opts) {
|
|
3
4
|
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
4
5
|
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
@@ -46,7 +47,5 @@ function createQwikRouter(opts) {
|
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
const createQwikCity = createQwikRouter;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
createQwikRouter
|
|
52
|
-
};
|
|
50
|
+
|
|
51
|
+
export { createQwikCity, createQwikRouter };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { setServerPlatform } from
|
|
2
|
-
import { requestHandler, isStaticPath, getNotFound } from
|
|
3
|
-
import { parseString } from
|
|
1
|
+
import { setServerPlatform } from '@qwik.dev/core/server';
|
|
2
|
+
import { requestHandler, isStaticPath, getNotFound } from '@qwik.dev/router/middleware/request-handler';
|
|
3
|
+
import { parseString } from 'set-cookie-parser';
|
|
4
|
+
|
|
4
5
|
function createQwikRouter(opts) {
|
|
5
6
|
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
6
7
|
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
@@ -86,7 +87,5 @@ function createQwikRouter(opts) {
|
|
|
86
87
|
return onAzureSwaRequest;
|
|
87
88
|
}
|
|
88
89
|
const createQwikCity = createQwikRouter;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
createQwikRouter
|
|
92
|
-
};
|
|
90
|
+
|
|
91
|
+
export { createQwikCity, createQwikRouter };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { setServerPlatform } from
|
|
2
|
-
import { _TextEncoderStream_polyfill, isStaticPath, getNotFound, mergeHeadersCookies, requestHandler } from
|
|
3
|
-
import { join, extname } from
|
|
4
|
-
import { M as MIME_TYPES } from
|
|
1
|
+
import { setServerPlatform } from '@qwik.dev/core/server';
|
|
2
|
+
import { _TextEncoderStream_polyfill, isStaticPath, getNotFound, mergeHeadersCookies, requestHandler } from '@qwik.dev/router/middleware/request-handler';
|
|
3
|
+
import { join, extname } from 'node:path';
|
|
4
|
+
import { M as MIME_TYPES } from '../../chunks/mime-types.mjs';
|
|
5
|
+
|
|
5
6
|
function createQwikRouter(opts) {
|
|
6
7
|
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
7
8
|
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
8
9
|
opts.qwikRouterConfig = opts.qwikCityPlan;
|
|
9
10
|
}
|
|
10
|
-
globalThis.TextEncoderStream
|
|
11
|
+
globalThis.TextEncoderStream ||= _TextEncoderStream_polyfill;
|
|
11
12
|
if (opts.manifest) {
|
|
12
13
|
setServerPlatform(opts.manifest);
|
|
13
14
|
}
|
|
@@ -136,7 +137,5 @@ function createQwikRouter(opts) {
|
|
|
136
137
|
};
|
|
137
138
|
}
|
|
138
139
|
const createQwikCity = createQwikRouter;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
createQwikRouter
|
|
142
|
-
};
|
|
140
|
+
|
|
141
|
+
export { createQwikCity, createQwikRouter };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { setServerPlatform } from
|
|
2
|
-
import { _TextEncoderStream_polyfill, isStaticPath, mergeHeadersCookies, requestHandler, getNotFound } from
|
|
1
|
+
import { setServerPlatform } from '@qwik.dev/core/server';
|
|
2
|
+
import { _TextEncoderStream_polyfill, isStaticPath, mergeHeadersCookies, requestHandler, getNotFound } from '@qwik.dev/router/middleware/request-handler';
|
|
3
|
+
|
|
3
4
|
function createQwikRouter(opts) {
|
|
4
5
|
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
5
6
|
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
@@ -90,7 +91,5 @@ function createQwikRouter(opts) {
|
|
|
90
91
|
return onCloudflarePagesFetch;
|
|
91
92
|
}
|
|
92
93
|
const createQwikCity = createQwikRouter;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
createQwikRouter
|
|
96
|
-
};
|
|
94
|
+
|
|
95
|
+
export { createQwikCity, createQwikRouter };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { setServerPlatform } from
|
|
2
|
-
import { isStaticPath, getNotFound, mergeHeadersCookies, requestHandler } from
|
|
3
|
-
import { M as MIME_TYPES } from
|
|
4
|
-
import { join, fromFileUrl, extname } from
|
|
1
|
+
import { setServerPlatform } from '@qwik.dev/core/server';
|
|
2
|
+
import { isStaticPath, getNotFound, mergeHeadersCookies, requestHandler } from '@qwik.dev/router/middleware/request-handler';
|
|
3
|
+
import { M as MIME_TYPES } from '../../chunks/mime-types.mjs';
|
|
4
|
+
import { join, fromFileUrl, extname } from 'https://deno.land/std/path/mod.ts';
|
|
5
|
+
|
|
5
6
|
function createQwikRouter(opts) {
|
|
6
7
|
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
7
8
|
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
@@ -123,7 +124,5 @@ function createQwikRouter(opts) {
|
|
|
123
124
|
};
|
|
124
125
|
}
|
|
125
126
|
const createQwikCity = createQwikRouter;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
createQwikRouter
|
|
129
|
-
};
|
|
127
|
+
|
|
128
|
+
export { createQwikCity, createQwikRouter };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createQwikRouter as createQwikRouter$1 } from
|
|
1
|
+
import { createQwikRouter as createQwikRouter$1 } from '@qwik.dev/router/middleware/node';
|
|
2
|
+
|
|
2
3
|
function createQwikRouter(opts) {
|
|
3
4
|
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
4
5
|
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
@@ -27,7 +28,5 @@ function createQwikRouter(opts) {
|
|
|
27
28
|
return qwikApp;
|
|
28
29
|
}
|
|
29
30
|
const createQwikCity = createQwikRouter;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
createQwikRouter
|
|
33
|
-
};
|
|
31
|
+
|
|
32
|
+
export { createQwikCity, createQwikRouter };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { setServerPlatform } from
|
|
2
|
-
import { isStaticPath, mergeHeadersCookies, requestHandler, getNotFound } from
|
|
1
|
+
import { setServerPlatform } from '@qwik.dev/core/server';
|
|
2
|
+
import { isStaticPath, mergeHeadersCookies, requestHandler, getNotFound } from '@qwik.dev/router/middleware/request-handler';
|
|
3
|
+
|
|
3
4
|
function createQwikRouter(opts) {
|
|
4
5
|
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
5
6
|
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
@@ -65,7 +66,5 @@ function createQwikRouter(opts) {
|
|
|
65
66
|
return onNetlifyEdgeRequest;
|
|
66
67
|
}
|
|
67
68
|
const createQwikCity = createQwikRouter;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
createQwikRouter
|
|
71
|
-
};
|
|
69
|
+
|
|
70
|
+
export { createQwikCity, createQwikRouter };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { isDev } from '@qwik.dev/core';
|
|
2
|
+
import { setServerPlatform } from '@qwik.dev/core/server';
|
|
3
|
+
import { isStaticPath, getNotFound, requestHandler } from '@qwik.dev/router/middleware/request-handler';
|
|
4
|
+
import { createReadStream } from 'node:fs';
|
|
5
|
+
import { join, basename, extname } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { M as MIME_TYPES } from '../../chunks/mime-types.mjs';
|
|
8
|
+
import { Http2ServerRequest } from 'node:http2';
|
|
9
|
+
|
|
8
10
|
function computeOrigin(req, opts) {
|
|
9
11
|
return opts?.getOrigin?.(req) ?? opts?.origin ?? process.env.ORIGIN ?? fallbackOrigin(req);
|
|
10
12
|
}
|
|
@@ -120,6 +122,7 @@ async function fromNodeHttp(url, req, res, mode, getClientConn) {
|
|
|
120
122
|
};
|
|
121
123
|
return serverRequestEv;
|
|
122
124
|
}
|
|
125
|
+
|
|
123
126
|
function createQwikRouter(opts) {
|
|
124
127
|
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
125
128
|
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
@@ -139,6 +142,9 @@ function createQwikRouter(opts) {
|
|
|
139
142
|
"server",
|
|
140
143
|
opts.getClientConn
|
|
141
144
|
);
|
|
145
|
+
if (isDev && opts.platform) {
|
|
146
|
+
Object.assign(serverRequestEv.platform, opts.platform);
|
|
147
|
+
}
|
|
142
148
|
const handled = await requestHandler(serverRequestEv, opts);
|
|
143
149
|
if (handled) {
|
|
144
150
|
const err = await handled.completion;
|
|
@@ -212,7 +218,5 @@ function createQwikRouter(opts) {
|
|
|
212
218
|
};
|
|
213
219
|
}
|
|
214
220
|
const createQwikCity = createQwikRouter;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
createQwikRouter
|
|
218
|
-
};
|
|
221
|
+
|
|
222
|
+
export { createQwikCity, createQwikRouter };
|