@qwik.dev/router 2.0.0-beta.29 → 2.0.0-beta.30
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/shared/vite/index.d.ts +1 -1
- package/lib/adapters/shared/vite/index.mjs +32 -3
- package/lib/chunks/deepFreeze.qwik.mjs +18 -0
- package/lib/chunks/http-error.qwik.mjs +14 -6
- package/lib/chunks/redirect-handler.mjs +6 -0
- package/lib/chunks/routing.qwik.mjs +52 -41
- package/lib/chunks/system.mjs +13 -8
- package/lib/chunks/worker-thread.qwik.mjs +2572 -0
- package/lib/index.qwik.mjs +70 -32
- package/lib/middleware/bun/index.mjs +3 -3
- package/lib/middleware/cloudflare-pages/index.mjs +3 -3
- package/lib/middleware/deno/index.mjs +3 -3
- package/lib/middleware/netlify-edge/index.mjs +3 -3
- package/lib/middleware/request-handler/index.d.ts +4 -15
- package/lib/middleware/request-handler/index.mjs +1190 -1049
- package/lib/middleware/vercel-edge/index.mjs +3 -3
- package/lib/ssg/index.d.ts +2 -2
- package/lib/ssg/index.mjs +32 -23
- package/lib/vite/index.mjs +162 -2
- package/package.json +4 -4
- package/lib/chunks/worker-thread.mjs +0 -271
package/lib/index.qwik.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { componentQrl, inlinedQrl, useErrorBoundary, useOnWindow, _captures, _jsxSorted, Slot, useSignal, untrack, _qrlSync, useVisibleTaskQrl, isDev, _jsxSplit, _getConstProps, _getVarProps, eventQrl, isServer, useStylesQrl, useServerData, useStore, useContextProvider, useTaskQrl, isBrowser, getLocale, noSerialize, useContext, SkipRender, implicit$FirstArg, withLocale, _wrapProp, createElement } from '@qwik.dev/core';
|
|
1
|
+
import { componentQrl, inlinedQrl, useErrorBoundary, useOnWindow, _captures, _jsxSorted, Slot, useSignal, untrack, _qrlSync, useVisibleTaskQrl, isDev, _jsxSplit, _getConstProps, _getVarProps, eventQrl, isServer, useStylesQrl, useServerData, useStore, useContextProvider, useTaskQrl, isBrowser, getLocale, noSerialize, useContext, SkipRender, implicit$FirstArg, withLocale, _wrapProp, _restProps, _fnSignal, createElement } from '@qwik.dev/core';
|
|
2
2
|
import { Fragment } from '@qwik.dev/core/jsx-runtime';
|
|
3
|
-
import { g as getClientNavPath, s as shouldPreload, p as preloadRouteBundles, l as loadClientData, i as isSamePath, c as createLoaderSignal, a as createDocumentHead, D as DEFAULT_LOADERS_SERIALIZATION_STRATEGY, t as toUrl, b as isSameOrigin, d as loadRoute, r as resolveHead, C as CLIENT_DATA_CACHE, Q as Q_ROUTE,
|
|
3
|
+
import { g as getClientNavPath, s as shouldPreload, p as preloadRouteBundles, l as loadClientData, i as isSamePath, c as createLoaderSignal, a as createDocumentHead, D as DEFAULT_LOADERS_SERIALIZATION_STRATEGY, t as toUrl, b as isSameOrigin, d as clientNavigate, e as loadRoute, r as resolveHead, C as CLIENT_DATA_CACHE, Q as Q_ROUTE, f as toPath, h as QFN_KEY, j as QACTION_KEY, k as QDATA_KEY } from './chunks/routing.qwik.mjs';
|
|
4
4
|
import { u as useNavigate, a as useLocation, b as useQwikRouterEnv, C as ContentContext, c as ContentInternalContext, D as DocumentHeadContext, H as HttpStatusContext, R as RouteLocationContext, d as RouteNavigateContext, e as RouteStateContext, f as RouteActionContext, g as RoutePreventNavigateContext, h as useAction, i as useDocumentHead } from './chunks/use-functions.qwik.mjs';
|
|
5
5
|
export { j as useContent, k as useHttpStatus, l as usePreventNavigate$, m as usePreventNavigateQrl } from './chunks/use-functions.qwik.mjs';
|
|
6
6
|
import * as qwikRouterConfig from '@qwik-router-config';
|
|
@@ -356,7 +356,7 @@ const useQwikRouter = (props) => {
|
|
|
356
356
|
if (!isServer) {
|
|
357
357
|
throw new Error("useQwikRouter can only run during SSR on the server. If you are seeing this, it means you are re-rendering the root of your application. Fix that or use the <QwikRouterProvider> component around the root of your application.");
|
|
358
358
|
}
|
|
359
|
-
useStylesQrl(/* @__PURE__ */ inlinedQrl(transitionCss, "
|
|
359
|
+
useStylesQrl(/* @__PURE__ */ inlinedQrl(transitionCss, "qwik_view_transition_css_inline_vNfd9raIMI0"));
|
|
360
360
|
const env = useQwikRouterEnv();
|
|
361
361
|
if (!env?.params) {
|
|
362
362
|
throw new Error(`Missing Qwik Router Env Data for help visit https://github.com/QwikDev/qwik/issues/6237`);
|
|
@@ -452,8 +452,18 @@ const useQwikRouter = (props) => {
|
|
|
452
452
|
}
|
|
453
453
|
};
|
|
454
454
|
}, "useQwikRouter_registerPreventNav_69B0DK0eZJc");
|
|
455
|
+
const getScroller = /* @__PURE__ */ inlinedQrl(() => {
|
|
456
|
+
let scroller = document.getElementById(QWIK_ROUTER_SCROLLER);
|
|
457
|
+
if (!scroller) {
|
|
458
|
+
scroller = document.getElementById(QWIK_CITY_SCROLLER);
|
|
459
|
+
if (scroller && isDev) {
|
|
460
|
+
console.warn(`Please update your scroller ID to "${QWIK_ROUTER_SCROLLER}" as "${QWIK_CITY_SCROLLER}" is deprecated and will be removed in V3`);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return scroller ?? document.documentElement;
|
|
464
|
+
}, "useQwikRouter_getScroller_0UhDFwlxeFQ");
|
|
455
465
|
const goto = /* @__PURE__ */ inlinedQrl(async (path, opt) => {
|
|
456
|
-
const actionState2 = _captures[0],
|
|
466
|
+
const actionState2 = _captures[0], getScroller2 = _captures[1], navResolver2 = _captures[2], routeInternal2 = _captures[3], routeLocation2 = _captures[4];
|
|
457
467
|
const { type = "link", forceReload = path === void 0, replaceState = false, scroll = true } = typeof opt === "object" ? opt : {
|
|
458
468
|
forceReload: opt
|
|
459
469
|
};
|
|
@@ -494,16 +504,7 @@ const useQwikRouter = (props) => {
|
|
|
494
504
|
if (type === "link" && dest.href !== location.href) {
|
|
495
505
|
history.pushState(null, "", dest);
|
|
496
506
|
}
|
|
497
|
-
|
|
498
|
-
if (!scroller) {
|
|
499
|
-
scroller = document.getElementById(QWIK_CITY_SCROLLER);
|
|
500
|
-
if (scroller && isDev) {
|
|
501
|
-
console.warn(`Please update your scroller ID to "${QWIK_ROUTER_SCROLLER}" as "${QWIK_CITY_SCROLLER}" is deprecated and will be removed in V3`);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
if (!scroller) {
|
|
505
|
-
scroller = document.documentElement;
|
|
506
|
-
}
|
|
507
|
+
const scroller = await getScroller2();
|
|
507
508
|
restoreScroll(type, dest, new URL(location.href), scroller, getScrollHistory());
|
|
508
509
|
if (type === "popstate") {
|
|
509
510
|
window._qRouterScrollEnabled = true;
|
|
@@ -516,12 +517,23 @@ const useQwikRouter = (props) => {
|
|
|
516
517
|
}
|
|
517
518
|
return;
|
|
518
519
|
}
|
|
520
|
+
let historyUpdated = false;
|
|
521
|
+
if (isBrowser && type === "link" && !forceReload) {
|
|
522
|
+
const scroller = await getScroller2();
|
|
523
|
+
window._qRouterScrollEnabled = false;
|
|
524
|
+
clearTimeout(window._qRouterScrollDebounce);
|
|
525
|
+
const scrollState = currentScrollState(scroller);
|
|
526
|
+
saveScrollHistory(scrollState);
|
|
527
|
+
clientNavigate(window, type, new URL(location.href), dest, replaceState);
|
|
528
|
+
historyUpdated = true;
|
|
529
|
+
}
|
|
519
530
|
routeInternal2.value = {
|
|
520
531
|
type,
|
|
521
532
|
dest,
|
|
522
533
|
forceReload,
|
|
523
534
|
replaceState,
|
|
524
|
-
scroll
|
|
535
|
+
scroll,
|
|
536
|
+
historyUpdated
|
|
525
537
|
};
|
|
526
538
|
if (isBrowser) {
|
|
527
539
|
loadClientData(dest);
|
|
@@ -534,6 +546,7 @@ const useQwikRouter = (props) => {
|
|
|
534
546
|
});
|
|
535
547
|
}, "useQwikRouter_goto_8j8Vrz2yUIM", [
|
|
536
548
|
actionState,
|
|
549
|
+
getScroller,
|
|
537
550
|
navResolver,
|
|
538
551
|
routeInternal,
|
|
539
552
|
routeLocation
|
|
@@ -548,7 +561,7 @@ const useQwikRouter = (props) => {
|
|
|
548
561
|
useContextProvider(RouteActionContext, actionState);
|
|
549
562
|
useContextProvider(RoutePreventNavigateContext, registerPreventNav);
|
|
550
563
|
useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
|
|
551
|
-
const actionState2 = _captures[0], content2 = _captures[1], contentInternal2 = _captures[2], documentHead2 = _captures[3], env2 = _captures[4],
|
|
564
|
+
const actionState2 = _captures[0], content2 = _captures[1], contentInternal2 = _captures[2], documentHead2 = _captures[3], env2 = _captures[4], getScroller2 = _captures[5], goto2 = _captures[6], httpStatus2 = _captures[7], loaderState2 = _captures[8], loadersObject2 = _captures[9], navResolver2 = _captures[10], props2 = _captures[11], routeInternal2 = _captures[12], routeLocation2 = _captures[13], routeLocationTarget2 = _captures[14], serverHead2 = _captures[15];
|
|
552
565
|
async function run() {
|
|
553
566
|
const navigation = track(routeInternal2);
|
|
554
567
|
const action = track(actionState2);
|
|
@@ -665,7 +678,7 @@ const useQwikRouter = (props) => {
|
|
|
665
678
|
if (navType === "popstate") {
|
|
666
679
|
scrollState = getScrollHistory();
|
|
667
680
|
}
|
|
668
|
-
const scroller =
|
|
681
|
+
const scroller = await getScroller2();
|
|
669
682
|
if (navigation.scroll && (!navigation.forceReload || !isSamePath(trackUrl, prevUrl)) && (navType === "link" || navType === "popstate") || navType === "form" && !isSamePath(trackUrl, prevUrl)) {
|
|
670
683
|
document.__q_scroll_restore__ = () => restoreScroll(navType, trackUrl, prevUrl, scroller, scrollState);
|
|
671
684
|
}
|
|
@@ -789,11 +802,21 @@ const useQwikRouter = (props) => {
|
|
|
789
802
|
if (navType !== "popstate") {
|
|
790
803
|
window._qRouterScrollEnabled = false;
|
|
791
804
|
clearTimeout(window._qRouterScrollDebounce);
|
|
792
|
-
|
|
793
|
-
|
|
805
|
+
if (!navigation.historyUpdated) {
|
|
806
|
+
const scrollState2 = currentScrollState(scroller);
|
|
807
|
+
saveScrollHistory(scrollState2);
|
|
808
|
+
}
|
|
794
809
|
}
|
|
795
810
|
const navigate = () => {
|
|
796
|
-
|
|
811
|
+
if (navigation.historyUpdated) {
|
|
812
|
+
const currentPath = location.pathname + location.search + location.hash;
|
|
813
|
+
const nextPath = toPath(trackUrl);
|
|
814
|
+
if (currentPath !== nextPath) {
|
|
815
|
+
history.replaceState(history.state, "", nextPath);
|
|
816
|
+
}
|
|
817
|
+
} else {
|
|
818
|
+
clientNavigate(window, navType, prevUrl, trackUrl, replaceState);
|
|
819
|
+
}
|
|
797
820
|
contentInternal2.trigger();
|
|
798
821
|
return _waitUntilRendered(container2);
|
|
799
822
|
};
|
|
@@ -850,6 +873,7 @@ const useQwikRouter = (props) => {
|
|
|
850
873
|
contentInternal,
|
|
851
874
|
documentHead,
|
|
852
875
|
env,
|
|
876
|
+
getScroller,
|
|
853
877
|
goto,
|
|
854
878
|
httpStatus,
|
|
855
879
|
loaderState,
|
|
@@ -1195,17 +1219,17 @@ Action.run() can only be called on the browser, for example when a user clicks a
|
|
|
1195
1219
|
id: id2,
|
|
1196
1220
|
resolve: noSerialize(resolve)
|
|
1197
1221
|
};
|
|
1198
|
-
}).then((
|
|
1222
|
+
}).then((_rawProps) => {
|
|
1199
1223
|
state2.isRunning = false;
|
|
1200
|
-
state2.status = status;
|
|
1201
|
-
state2.value = result;
|
|
1224
|
+
state2.status = _rawProps.status;
|
|
1225
|
+
state2.value = _rawProps.result;
|
|
1202
1226
|
if (form) {
|
|
1203
1227
|
if (form.getAttribute("data-spa-reset") === "true") {
|
|
1204
1228
|
form.reset();
|
|
1205
1229
|
}
|
|
1206
1230
|
const detail = {
|
|
1207
|
-
status,
|
|
1208
|
-
value: result
|
|
1231
|
+
status: _rawProps.status,
|
|
1232
|
+
value: _rawProps.result
|
|
1209
1233
|
};
|
|
1210
1234
|
form.dispatchEvent(new CustomEvent("submitcompleted", {
|
|
1211
1235
|
bubbles: false,
|
|
@@ -1215,8 +1239,8 @@ Action.run() can only be called on the browser, for example when a user clicks a
|
|
|
1215
1239
|
}));
|
|
1216
1240
|
}
|
|
1217
1241
|
return {
|
|
1218
|
-
status,
|
|
1219
|
-
value: result
|
|
1242
|
+
status: _rawProps.status,
|
|
1243
|
+
value: _rawProps.result
|
|
1220
1244
|
};
|
|
1221
1245
|
});
|
|
1222
1246
|
}, "routeActionQrl_action_submit_YuS5bpdQ360", [
|
|
@@ -1422,17 +1446,31 @@ const ServiceWorkerRegister = (props) => /* @__PURE__ */ _jsxSorted("script", {
|
|
|
1422
1446
|
dangerouslySetInnerHTML: swRegister
|
|
1423
1447
|
}, null, 3, "1x_0");
|
|
1424
1448
|
|
|
1425
|
-
const
|
|
1449
|
+
const _hf0 = (p0) => !p0.reloadDocument;
|
|
1450
|
+
const _hf0_str = "!p0.reloadDocument";
|
|
1451
|
+
const _hf1 = (p0) => p0.spaReset ? "true" : void 0;
|
|
1452
|
+
const _hf1_str = 'p0.spaReset?"true":undefined';
|
|
1453
|
+
const GetForm = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((_rawProps) => {
|
|
1454
|
+
const rest = _restProps(_rawProps, [
|
|
1455
|
+
"action",
|
|
1456
|
+
"spaReset",
|
|
1457
|
+
"reloadDocument",
|
|
1458
|
+
"onSubmit$"
|
|
1459
|
+
]);
|
|
1426
1460
|
const nav = useNavigate();
|
|
1427
1461
|
return /* @__PURE__ */ _jsxSplit("form", {
|
|
1428
1462
|
action: "get",
|
|
1429
|
-
"preventdefault:submit":
|
|
1430
|
-
|
|
1463
|
+
"preventdefault:submit": _fnSignal(_hf0, [
|
|
1464
|
+
_rawProps
|
|
1465
|
+
], _hf0_str),
|
|
1466
|
+
"data-spa-reset": _fnSignal(_hf1, [
|
|
1467
|
+
_rawProps
|
|
1468
|
+
], _hf1_str),
|
|
1431
1469
|
..._getVarProps(rest),
|
|
1432
1470
|
..._getConstProps(rest),
|
|
1433
1471
|
"q-e:submit": [
|
|
1434
|
-
...Array.isArray(onSubmit$) ? onSubmit$ : [
|
|
1435
|
-
onSubmit$
|
|
1472
|
+
...Array.isArray(_rawProps.onSubmit$) ? _rawProps.onSubmit$ : [
|
|
1473
|
+
_rawProps.onSubmit$
|
|
1436
1474
|
],
|
|
1437
1475
|
/* @__PURE__ */ inlinedQrl(async (_evt, form) => {
|
|
1438
1476
|
const nav2 = _captures[0];
|
|
@@ -53,9 +53,9 @@ function createQwikRouter(opts) {
|
|
|
53
53
|
};
|
|
54
54
|
const handledResponse = await requestHandler(serverRequestEv, opts);
|
|
55
55
|
if (handledResponse) {
|
|
56
|
-
handledResponse.completion.then((
|
|
57
|
-
if (
|
|
58
|
-
console.error(
|
|
56
|
+
handledResponse.completion.then((completion) => {
|
|
57
|
+
if (completion) {
|
|
58
|
+
console.error(completion);
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
const response = await handledResponse.response;
|
|
@@ -63,9 +63,9 @@ function createQwikRouter(opts) {
|
|
|
63
63
|
};
|
|
64
64
|
const handledResponse = await requestHandler(serverRequestEv, opts);
|
|
65
65
|
if (handledResponse) {
|
|
66
|
-
handledResponse.completion.then((
|
|
67
|
-
if (
|
|
68
|
-
console.error(
|
|
66
|
+
handledResponse.completion.then((completion) => {
|
|
67
|
+
if (completion) {
|
|
68
|
+
console.error(completion);
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
const response = await handledResponse.response;
|
|
@@ -51,9 +51,9 @@ function createQwikRouter(opts) {
|
|
|
51
51
|
};
|
|
52
52
|
const handledResponse = await requestHandler(serverRequestEv, opts);
|
|
53
53
|
if (handledResponse) {
|
|
54
|
-
handledResponse.completion.then((
|
|
55
|
-
if (
|
|
56
|
-
console.error(
|
|
54
|
+
handledResponse.completion.then((completion) => {
|
|
55
|
+
if (completion) {
|
|
56
|
+
console.error(completion);
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
const response = await handledResponse.response;
|
|
@@ -41,9 +41,9 @@ function createQwikRouter(opts) {
|
|
|
41
41
|
};
|
|
42
42
|
const handledResponse = await requestHandler(serverRequestEv, opts);
|
|
43
43
|
if (handledResponse) {
|
|
44
|
-
handledResponse.completion.then((
|
|
45
|
-
if (
|
|
46
|
-
console.error(
|
|
44
|
+
handledResponse.completion.then((completion) => {
|
|
45
|
+
if (completion) {
|
|
46
|
+
console.error(completion);
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
const response = await handledResponse.response;
|
|
@@ -7,7 +7,6 @@ import type { Loader as Loader_2 } from '@qwik.dev/router';
|
|
|
7
7
|
import type { QwikCityPlan } from '@qwik.dev/router';
|
|
8
8
|
import type { QwikIntrinsicElements } from '@qwik.dev/core';
|
|
9
9
|
import type { QwikRouterConfig } from '@qwik.dev/router';
|
|
10
|
-
import { RedirectMessage as RedirectMessage_2 } from '@qwik.dev/router/middleware/request-handler';
|
|
11
10
|
import type { Render } from '@qwik.dev/core/server';
|
|
12
11
|
import type { RenderOptions } from '@qwik.dev/core/server';
|
|
13
12
|
import { RequestEvent as RequestEvent_2 } from '@qwik.dev/router/middleware/request-handler';
|
|
@@ -383,22 +382,12 @@ declare type PageModule = RouteModule & {
|
|
|
383
382
|
/** @public */
|
|
384
383
|
declare type PathParams = Record<string, string>;
|
|
385
384
|
|
|
385
|
+
declare type QwikRouterCompletion = Error | undefined | object;
|
|
386
|
+
|
|
386
387
|
declare interface QwikRouterRun<T> {
|
|
387
|
-
/**
|
|
388
|
-
* The response to the request, if any. If there is no response, there might have been an error,
|
|
389
|
-
* or the request was aborted.
|
|
390
|
-
*/
|
|
391
388
|
response: Promise<T | null>;
|
|
392
389
|
requestEv: RequestEvent_2;
|
|
393
|
-
|
|
394
|
-
* Promise for the completion of the request.
|
|
395
|
-
*
|
|
396
|
-
* If it returns a RedirectMessage, it means the request must be redirected.
|
|
397
|
-
*
|
|
398
|
-
* If it returns an Error, it means there was an error, and if possible, the response already
|
|
399
|
-
* includes the error. The error is informational only.
|
|
400
|
-
*/
|
|
401
|
-
completion: Promise<RedirectMessage_2 | Error | undefined>;
|
|
390
|
+
completion: Promise<QwikRouterCompletion>;
|
|
402
391
|
}
|
|
403
392
|
|
|
404
393
|
/**
|
|
@@ -762,7 +751,7 @@ export declare interface ServerRequestEvent<T = unknown> {
|
|
|
762
751
|
export declare type ServerRequestMode = 'static' | 'server';
|
|
763
752
|
|
|
764
753
|
/** @public */
|
|
765
|
-
export declare type ServerResponseHandler<T = any> = (status: number, headers: Headers, cookies: Cookie, resolve: (response: T) => void, requestEv:
|
|
754
|
+
export declare type ServerResponseHandler<T = any> = (status: number, headers: Headers, cookies: Cookie, resolve: (response: T) => void, requestEv: RequestEvent) => WritableStream<Uint8Array>;
|
|
766
755
|
|
|
767
756
|
/** @public */
|
|
768
757
|
declare interface StaticGenerate {
|