@qwik.dev/router 2.0.0-beta.10 → 2.0.0-beta.11
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.cjs +2 -2
- package/lib/adapters/azure-swa/vite/index.mjs +73 -69
- package/lib/adapters/bun-server/vite/index.cjs +2 -2
- package/lib/adapters/bun-server/vite/index.mjs +77 -73
- package/lib/adapters/cloud-run/vite/index.cjs +2 -2
- package/lib/adapters/cloud-run/vite/index.mjs +104 -100
- package/lib/adapters/cloudflare-pages/vite/{index-DwovcBp3.js → index-Bg_9YkM5.js} +1 -1
- package/lib/adapters/cloudflare-pages/vite/{index-C455V8_A.cjs → index-C1aDmh1S.cjs} +1 -1
- package/lib/adapters/cloudflare-pages/vite/index-CHT9Y93A.js +254 -0
- package/lib/adapters/cloudflare-pages/vite/{index-DKcVHRBy.cjs → index-Ck7KvpK1.cjs} +1 -1
- package/lib/adapters/cloudflare-pages/vite/{index-D3HITboM.js → index-Cp1cjAds.js} +1 -1
- package/lib/adapters/cloudflare-pages/vite/index-D9RL9dvJ.cjs +5 -0
- package/lib/adapters/cloudflare-pages/vite/index.cjs +1 -1
- package/lib/adapters/cloudflare-pages/vite/index.mjs +1 -1
- package/lib/adapters/deno-server/vite/index.cjs +2 -2
- package/lib/adapters/deno-server/vite/index.mjs +81 -77
- package/lib/adapters/netlify-edge/vite/index.cjs +3 -3
- package/lib/adapters/netlify-edge/vite/index.mjs +119 -115
- package/lib/adapters/node-server/vite/index.cjs +2 -2
- package/lib/adapters/node-server/vite/index.mjs +78 -74
- package/lib/adapters/shared/vite/index.cjs +2 -2
- package/lib/adapters/shared/vite/index.mjs +108 -104
- package/lib/adapters/ssg/vite/index.cjs +2 -2
- package/lib/adapters/ssg/vite/index.mjs +100 -96
- package/lib/adapters/vercel-edge/vite/index.cjs +2 -2
- package/lib/adapters/vercel-edge/vite/index.mjs +114 -110
- package/lib/index.qwik.cjs +39 -33
- package/lib/index.qwik.mjs +39 -33
- package/lib/middleware/request-handler/index.cjs +8 -8
- package/lib/middleware/request-handler/index.mjs +598 -587
- package/lib/vite/index.cjs +17 -17
- package/lib/vite/index.d.ts +3 -3
- package/lib/vite/index.mjs +242 -230
- package/package.json +4 -4
- package/lib/adapters/cloudflare-pages/vite/index-BIeHg2Cj.cjs +0 -5
- package/lib/adapters/cloudflare-pages/vite/index-bogwy7wh.js +0 -250
package/lib/index.qwik.mjs
CHANGED
|
@@ -57,7 +57,9 @@ const loadClientData = async (url, element, opts, retryCount = 0) => {
|
|
|
57
57
|
const redirectedURL = new URL(rsp.url);
|
|
58
58
|
const isQData = redirectedURL.pathname.endsWith("/q-data.json");
|
|
59
59
|
if (!isQData || redirectedURL.origin !== location.origin) {
|
|
60
|
-
|
|
60
|
+
if (!opts?.isPrefetch) {
|
|
61
|
+
location.href = redirectedURL.href;
|
|
62
|
+
}
|
|
61
63
|
return;
|
|
62
64
|
}
|
|
63
65
|
}
|
|
@@ -358,23 +360,31 @@ const resolveHead = (endpoint, routeLocation, contentModules, locale, defaults)
|
|
|
358
360
|
}
|
|
359
361
|
return data;
|
|
360
362
|
};
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
resolveValue: getData,
|
|
365
|
-
...routeLocation
|
|
366
|
-
};
|
|
367
|
-
for (let i = contentModules.length - 1; i >= 0; i--) {
|
|
368
|
-
const contentModuleHead = contentModules[i] && contentModules[i].head;
|
|
363
|
+
const fns = [];
|
|
364
|
+
for (const contentModule of contentModules) {
|
|
365
|
+
const contentModuleHead = contentModule?.head;
|
|
369
366
|
if (contentModuleHead) {
|
|
370
367
|
if (typeof contentModuleHead === "function") {
|
|
371
|
-
|
|
368
|
+
fns.unshift(contentModuleHead);
|
|
372
369
|
} else if (typeof contentModuleHead === "object") {
|
|
373
370
|
resolveDocumentHead(head, contentModuleHead);
|
|
374
371
|
}
|
|
375
372
|
}
|
|
376
373
|
}
|
|
377
|
-
|
|
374
|
+
if (fns.length) {
|
|
375
|
+
const headProps = {
|
|
376
|
+
head,
|
|
377
|
+
withLocale: (fn) => withLocale(locale, fn),
|
|
378
|
+
resolveValue: getData,
|
|
379
|
+
...routeLocation
|
|
380
|
+
};
|
|
381
|
+
withLocale(locale, () => {
|
|
382
|
+
for (const fn of fns) {
|
|
383
|
+
resolveDocumentHead(head, fn(headProps));
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
return head;
|
|
378
388
|
};
|
|
379
389
|
const resolveDocumentHead = (resolvedHead, updatedHead) => {
|
|
380
390
|
if (typeof updatedHead.title === "string") {
|
|
@@ -554,7 +564,7 @@ const deepFreeze = (obj) => {
|
|
|
554
564
|
});
|
|
555
565
|
return Object.freeze(obj);
|
|
556
566
|
};
|
|
557
|
-
const loadRoute = async (routes, menus, cacheModules, pathname) => {
|
|
567
|
+
const loadRoute = async (routes, menus, cacheModules, pathname, isInternal) => {
|
|
558
568
|
if (!Array.isArray(routes)) {
|
|
559
569
|
return null;
|
|
560
570
|
}
|
|
@@ -571,9 +581,11 @@ const loadRoute = async (routes, menus, cacheModules, pathname) => {
|
|
|
571
581
|
loaders.forEach((moduleLoader, i) => {
|
|
572
582
|
loadModule(moduleLoader, pendingLoads, (routeModule) => modules[i] = routeModule, cacheModules);
|
|
573
583
|
});
|
|
574
|
-
const menuLoader = getMenuLoader(menus, pathname);
|
|
575
584
|
let menu = void 0;
|
|
576
|
-
|
|
585
|
+
{
|
|
586
|
+
const menuLoader = getMenuLoader(menus, pathname);
|
|
587
|
+
loadModule(menuLoader, pendingLoads, (menuModule) => menu = menuModule?.default, cacheModules);
|
|
588
|
+
}
|
|
577
589
|
if (pendingLoads.length > 0) {
|
|
578
590
|
await Promise.all(pendingLoads);
|
|
579
591
|
}
|
|
@@ -610,7 +622,7 @@ const loadModule = (moduleLoader, pendingLoads, moduleSetter, cacheModules) => {
|
|
|
610
622
|
const getMenuLoader = (menus, pathname) => {
|
|
611
623
|
if (menus) {
|
|
612
624
|
pathname = pathname.endsWith("/") ? pathname : pathname + "/";
|
|
613
|
-
const menu = menus.find((m) => m[MenuDataProp.Pathname] === pathname || pathname.startsWith(m[MenuDataProp.Pathname]
|
|
625
|
+
const menu = menus.find((m) => m[MenuDataProp.Pathname] === pathname || pathname.startsWith(m[MenuDataProp.Pathname]));
|
|
614
626
|
if (menu) {
|
|
615
627
|
return menu[MenuDataProp.MenuLoader];
|
|
616
628
|
}
|
|
@@ -837,6 +849,7 @@ const startViewTransition = (params) => {
|
|
|
837
849
|
params.update?.();
|
|
838
850
|
}
|
|
839
851
|
};
|
|
852
|
+
const transitionCss = "@layer qwik {\n @supports selector(html:active-view-transition-type(type)) {\n html:active-view-transition-type(qwik-navigation) {\n :root {\n view-transition-name: none;\n }\n }\n }\n @supports not selector(html:active-view-transition-type(type)) {\n :root {\n view-transition-name: none;\n }\n }\n}\n";
|
|
840
853
|
const QWIK_CITY_SCROLLER = "_qCityScroller";
|
|
841
854
|
const QWIK_ROUTER_SCROLLER = "_qRouterScroller";
|
|
842
855
|
const preventNav = {};
|
|
@@ -844,18 +857,7 @@ const internalState = {
|
|
|
844
857
|
navCount: 0
|
|
845
858
|
};
|
|
846
859
|
const useQwikRouter = (props) => {
|
|
847
|
-
useStyles$(
|
|
848
|
-
@layer qwik {
|
|
849
|
-
@supports selector(html:active-view-transition-type(type)) {
|
|
850
|
-
html:active-view-transition-type(qwik-navigation) {
|
|
851
|
-
:root{view-transition-name:none}
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
@supports not selector(html:active-view-transition-type(type)) {
|
|
855
|
-
:root{view-transition-name:none}
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
`);
|
|
860
|
+
useStyles$(transitionCss);
|
|
859
861
|
const env = useQwikRouterEnv();
|
|
860
862
|
if (!env?.params) {
|
|
861
863
|
throw new Error(`Missing Qwik Router Env Data for help visit https://github.com/QwikDev/qwik/issues/6237`);
|
|
@@ -1409,6 +1411,7 @@ const RouterOutlet = component$(() => {
|
|
|
1409
1411
|
return SkipRender;
|
|
1410
1412
|
});
|
|
1411
1413
|
var store;
|
|
1414
|
+
// @__NO_SIDE_EFFECTS__
|
|
1412
1415
|
function getGlobalConfig(config2) {
|
|
1413
1416
|
return {
|
|
1414
1417
|
lang: config2?.lang ?? store?.lang,
|
|
@@ -1417,6 +1420,7 @@ function getGlobalConfig(config2) {
|
|
|
1417
1420
|
abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
|
|
1418
1421
|
};
|
|
1419
1422
|
}
|
|
1423
|
+
// @__NO_SIDE_EFFECTS__
|
|
1420
1424
|
function getDotPath(issue) {
|
|
1421
1425
|
if (issue.path) {
|
|
1422
1426
|
let key = "";
|
|
@@ -1435,11 +1439,12 @@ function getDotPath(issue) {
|
|
|
1435
1439
|
}
|
|
1436
1440
|
return null;
|
|
1437
1441
|
}
|
|
1442
|
+
// @__NO_SIDE_EFFECTS__
|
|
1438
1443
|
function flatten(issues) {
|
|
1439
1444
|
const flatErrors = {};
|
|
1440
1445
|
for (const issue of issues) {
|
|
1441
1446
|
if (issue.path) {
|
|
1442
|
-
const dotPath = getDotPath(issue);
|
|
1447
|
+
const dotPath = /* @__PURE__ */ getDotPath(issue);
|
|
1443
1448
|
if (dotPath) {
|
|
1444
1449
|
if (!flatErrors.nested) {
|
|
1445
1450
|
flatErrors.nested = {};
|
|
@@ -1466,10 +1471,11 @@ function flatten(issues) {
|
|
|
1466
1471
|
}
|
|
1467
1472
|
return flatErrors;
|
|
1468
1473
|
}
|
|
1474
|
+
// @__NO_SIDE_EFFECTS__
|
|
1469
1475
|
async function safeParseAsync(schema, input, config2) {
|
|
1470
|
-
const dataset = await schema
|
|
1471
|
-
{
|
|
1472
|
-
getGlobalConfig(config2)
|
|
1476
|
+
const dataset = await schema["~run"](
|
|
1477
|
+
{ value: input },
|
|
1478
|
+
/* @__PURE__ */ getGlobalConfig(config2)
|
|
1473
1479
|
);
|
|
1474
1480
|
return {
|
|
1475
1481
|
typed: dataset.typed,
|
|
@@ -1645,7 +1651,7 @@ const valibotQrl = (qrl) => {
|
|
|
1645
1651
|
async validate(ev, inputData) {
|
|
1646
1652
|
const schema = await qrl.resolve().then((obj) => typeof obj === "function" ? obj(ev) : obj);
|
|
1647
1653
|
const data = inputData ?? await ev.parseBody();
|
|
1648
|
-
const result = await safeParseAsync(schema, data);
|
|
1654
|
+
const result = await /* @__PURE__ */ safeParseAsync(schema, data);
|
|
1649
1655
|
if (result.success) {
|
|
1650
1656
|
return {
|
|
1651
1657
|
success: true,
|
|
@@ -1659,7 +1665,7 @@ const valibotQrl = (qrl) => {
|
|
|
1659
1665
|
success: false,
|
|
1660
1666
|
status: 400,
|
|
1661
1667
|
error: {
|
|
1662
|
-
formErrors: flatten(result.issues).root ?? [],
|
|
1668
|
+
formErrors: (/* @__PURE__ */ flatten(result.issues)).root ?? [],
|
|
1663
1669
|
fieldErrors: flattenValibotIssues(result.issues)
|
|
1664
1670
|
}
|
|
1665
1671
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";var De=Object.create;var
|
|
1
|
+
"use strict";var De=Object.create;var te=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Qe=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty;var ze=(e,n,r,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Fe(n))!Ee.call(e,i)&&i!==r&&te(e,i,{get:()=>n[i],enumerable:!(t=Se(n,i))||t.enumerable});return e};var ie=(e,n,r)=>(r=e!=null?De(Qe(e)):{},ze(n||!e||!e.__esModule?te(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("@qwik.dev/core/internal");require("@qwik.dev/core");const b=require("@qwik.dev/router/middleware/request-handler"),oe=new WeakMap,ae="qaction",J="qloaders",je="qfunc",se="qdata",Ge="q:route";function Be(e,n){const r=de(e),t=ce(e),i=de(n),o=ce(n);return pe(e,r,t,n,i,o)}function pe(e,n,r,t,i,o){if(t.startsWith("/build/"))return null;let a=null;for(;n<r;){const c=e.charCodeAt(n++),s=t.charCodeAt(i++);if(c===91){const l=Re(e,n),f=n+(l?3:0),u=G(e,f,r,93),m=e.substring(f,u),p=G(e,u+1,r,47),g=e.substring(u+1,p);n=u+1;const w=i-1;if(l){const R=Ke(m,g,t,w,o,e,n+g.length+1,r);if(R)return Object.assign(a||(a={}),R)}const A=G(t,w,o,47,g);if(A==-1)return null;const x=t.substring(w,A);if(!l&&!g&&!x)return null;i=A,(a||(a={}))[m]=decodeURIComponent(x)}else if(c!==s&&!(isNaN(s)&&ve(e,n)))return null}return le(e,n)&&le(t,i)?a||{}:null}function ve(e,n){return e.charCodeAt(n)===91&&Re(e,n+1)}function ce(e){const n=e.length;return n>1&&e.charCodeAt(n-1)===47?n-1:n}function le(e,n){const r=e.length;return n>=r||n==r-1&&e.charCodeAt(n)===47}function de(e){return e.charCodeAt(0)===47?1:0}function Re(e,n){return e.charCodeAt(n)===46&&e.charCodeAt(n+1)===46&&e.charCodeAt(n+2)===46}function G(e,n,r,t,i=""){for(;n<r&&e.charCodeAt(n)!==t;)n++;const o=i.length;for(let a=0;a<o;a++)if(e.charCodeAt(n-o+a)!==i.charCodeAt(a))return-1;return n-o}function Ke(e,n,r,t,i,o,a,c){r.charCodeAt(t)===47&&t++;let s=i;const l=n+"/";for(;s>=t;){const f=pe(o,a,c,r,s,i);if(f){let m=r.substring(t,Math.min(s,i));return m.endsWith(l)&&(m=m.substring(0,m.length-l.length)),f[e]=decodeURIComponent(m),f}const u=Je(r,t,l,s,t-1)+l.length;if(s===u)break;s=u}return null}function Je(e,n,r,t,i){let o=e.lastIndexOf(r,t);return o==t-r.length&&(o=e.lastIndexOf(r,t-r.length-1)),o>n?o:i}var $=(e=>(e[e.RouteName=0]="RouteName",e[e.Loaders=1]="Loaders",e[e.OriginalPathname=2]="OriginalPathname",e[e.RouteBundleNames=3]="RouteBundleNames",e))($||{}),D=(e=>(e[e.Pathname=0]="Pathname",e[e.MenuLoader=1]="MenuLoader",e))(D||{}),U=(e=>(e[e.RouteName=0]="RouteName",e[e.Params=1]="Params",e[e.Mods=2]="Mods",e[e.Menu=3]="Menu",e[e.RouteBundleNames=4]="RouteBundleNames",e))(U||{});const be=e=>e==null?e:(Object.getOwnPropertyNames(e).forEach(n=>{const r=e[n];r&&typeof r=="object"&&!Object.isFrozen(r)&&be(r)}),Object.freeze(e)),Ye=async(e,n,r,t,i)=>{if(!Array.isArray(e))return null;for(const o of e){const a=o[$.RouteName],c=Be(a,t);if(!c)continue;const s=o[$.Loaders],l=o[$.RouteBundleNames],f=new Array(s.length),u=[];s.forEach((p,g)=>{fe(p,u,w=>f[g]=w,r)});let m;if(!i){const p=Ve(n,t);fe(p,u,g=>m=g?.default,r)}return u.length>0&&await Promise.all(u),[a,c,f,be(m),l]}return null},fe=(e,n,r,t)=>{if(typeof e=="function"){const i=oe.get(e);if(i)r(i);else{const o=e();typeof o.then=="function"?n.push(o.then(a=>{t!==!1&&oe.set(e,a),r(a)})):o&&r(o)}}},Ve=(e,n)=>{if(e){n=n.endsWith("/")?n:n+"/";const r=e.find(t=>t[D.Pathname]===n||n.startsWith(t[D.Pathname]));if(r)return r[D.MenuLoader]}};var Y=(e=>(e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.Processing=102]="Processing",e[e.Ok=200]="Ok",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultiStatus=207]="MultiStatus",e[e.AlreadyReported=208]="AlreadyReported",e[e.ImUsed=226]="ImUsed",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.UseProxy=305]="UseProxy",e[e.SwitchProxy=306]="SwitchProxy",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.LengthRequired=411]="LengthRequired",e[e.PreconditionFailed=412]="PreconditionFailed",e[e.PayloadTooLarge=413]="PayloadTooLarge",e[e.UriTooLong=414]="UriTooLong",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.RangeNotSatisfiable=416]="RangeNotSatisfiable",e[e.ExpectationFailed=417]="ExpectationFailed",e[e.IAmATeapot=418]="IAmATeapot",e[e.MisdirectedRequest=421]="MisdirectedRequest",e[e.UnprocessableEntity=422]="UnprocessableEntity",e[e.Locked=423]="Locked",e[e.FailedDependency=424]="FailedDependency",e[e.UpgradeRequired=426]="UpgradeRequired",e[e.PreconditionRequired=428]="PreconditionRequired",e[e.TooManyRequests=429]="TooManyRequests",e[e.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",e[e.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout",e[e.HttpVersionNotSupported=505]="HttpVersionNotSupported",e[e.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",e[e.InsufficientStorage=507]="InsufficientStorage",e[e.LoopDetected=508]="LoopDetected",e[e.NotExtended=510]="NotExtended",e[e.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired",e))(Y||{});const Xe=e=>e&&typeof e.then=="function";function Ze(e){const n=[];return e==="day"?e=3600*24:e==="week"?e=3600*24*7:e==="month"?e=3600*24*30:e==="year"?e=3600*24*365:e==="private"?e={private:!0,noCache:!0}:e==="immutable"?e={public:!0,immutable:!0,maxAge:3600*24*365}:e==="no-cache"&&(e={noCache:!0}),typeof e=="number"&&(e={maxAge:e,sMaxAge:e}),e.immutable&&n.push("immutable"),e.maxAge&&n.push(`max-age=${e.maxAge}`),e.sMaxAge&&n.push(`s-maxage=${e.sMaxAge}`),e.noStore&&n.push("no-store"),e.noCache&&n.push("no-cache"),e.private&&n.push("private"),e.public&&n.push("public"),e.staleWhileRevalidate&&n.push(`stale-while-revalidate=${e.staleWhileRevalidate}`),e.staleIfError&&n.push(`stale-if-error=${e.staleIfError}`),n.join(", ")}const He={lax:"Lax",Lax:"Lax",None:"None",none:"None",strict:"Strict",Strict:"Strict"},en={seconds:1,minutes:60,hours:3600,days:3600*24,weeks:3600*24*7},ue=(e,n,r)=>{const t=[`${e}=${n}`];typeof r.domain=="string"&&t.push(`Domain=${r.domain}`),typeof r.maxAge=="number"?t.push(`Max-Age=${r.maxAge}`):Array.isArray(r.maxAge)?t.push(`Max-Age=${r.maxAge[0]*en[r.maxAge[1]]}`):typeof r.expires=="number"||typeof r.expires=="string"?t.push(`Expires=${r.expires}`):r.expires instanceof Date&&t.push(`Expires=${r.expires.toUTCString()}`),r.httpOnly&&t.push("HttpOnly"),typeof r.path=="string"&&t.push(`Path=${r.path}`);const i=rn(r.sameSite);return i&&t.push(`SameSite=${i}`),r.secure&&t.push("Secure"),t.join("; ")};function he(e){try{return decodeURIComponent(e)}catch{return e}}const nn=e=>{const n={};if(typeof e=="string"&&e!==""){const r=e.split(";");for(const t of r){const i=t.indexOf("=");i!==-1&&(n[he(t.slice(0,i).trim())]=he(t.slice(i+1).trim()))}}return n};function rn(e){if(e===!0)return"Strict";if(e===!1)return"None";if(e)return He[e]}const I=Symbol("request-cookies"),W=Symbol("response-cookies"),N=Symbol("live-cookies");class tn{[I];[W]={};[N]={};appendCounter=0;constructor(n){this[I]=nn(n),this[N]={...this[I]}}get(n,r=!0){const t=this[r?N:I][n];return t?{value:t,json(){return JSON.parse(t)},number(){return Number(t)}}:null}getAll(n=!0){return Object.keys(this[n?N:I]).reduce((r,t)=>(r[t]=this.get(t),r),{})}has(n,r=!0){return!!this[r?N:I][n]}set(n,r,t={}){this[N][n]=typeof r=="string"?r:JSON.stringify(r);const i=typeof r=="string"?r:encodeURIComponent(JSON.stringify(r));this[W][n]=ue(n,i,t)}append(n,r,t={}){this[N][n]=typeof r=="string"?r:JSON.stringify(r);const i=typeof r=="string"?r:encodeURIComponent(JSON.stringify(r));this[W][++this.appendCounter]=ue(n,i,t)}delete(n,r){this.set(n,"deleted",{...r,maxAge:0}),this[N][n]=null}headers(){return Object.values(this[W])}}const on=(e,n)=>{const r=n.headers();if(r.length>0){const t=new Headers(e);for(const i of r)t.append("Set-Cookie",i);return t}return e};function S(e,n){let r="Server Error";return n!=null&&(typeof n.message=="string"?r=n.message:r=String(n)),"<html>"+Ae(e,r)+"</html>"}function Ae(e,n){typeof e!="number"&&(e=500),typeof n=="string"?n=sn(n):n="";const r=typeof n=="string"?"600px":"300px",t=e>=500?ln:cn;return`
|
|
2
2
|
<head>
|
|
3
3
|
<meta charset="utf-8">
|
|
4
4
|
<meta http-equiv="Status" content="${e}">
|
|
5
|
-
<title>${e} ${
|
|
5
|
+
<title>${e} ${n}</title>
|
|
6
6
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
7
7
|
<style>
|
|
8
8
|
body { color: ${t}; background-color: #fafafa; padding: 30px; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif; }
|
|
9
|
-
p { max-width: ${
|
|
9
|
+
p { max-width: ${r}; margin: 60px auto 30px auto; background: white; border-radius: 4px; box-shadow: 0px 0px 50px -20px ${t}; overflow: hidden; }
|
|
10
10
|
strong { display: inline-block; padding: 15px; background: ${t}; color: white; }
|
|
11
11
|
span { display: inline-block; padding: 15px; }
|
|
12
12
|
</style>
|
|
13
13
|
</head>
|
|
14
|
-
<body><p><strong>${e}</strong> <span>${
|
|
15
|
-
`}const
|
|
16
|
-
Make sure your <form> has method="POST" attribute, like this: <form method="POST">`),t==="POST"){const a=
|
|
17
|
-
`))}
|
|
18
|
-
The request origin "${t}" does not match the server origin "${i}".`)}}function
|
|
14
|
+
<body><p><strong>${e}</strong> <span>${n}</span></p></body>
|
|
15
|
+
`}const an=/[&<>]/g,sn=e=>e.replace(an,n=>{switch(n){case"&":return"&";case"<":return"<";case">":return">";default:return""}}),cn="#006ce9",ln="#713fc2";let F;import("node:async_hooks").then(e=>{const n=e.AsyncLocalStorage;F=new n,globalThis.qcAsyncRequestStore=F}).catch(e=>{console.warn("AsyncLocalStorage not available, continuing without it. This might impact concurrent server calls.",e)});function dn(e,n,r,t,i="/"){let o;const a=new Promise(s=>o=s),c=un(e,n,r,i,o);return{response:a,requestEv:c,completion:F?F.run(c,me,c,t,o):me(c,t,o)}}async function me(e,n,r){try{(a=>new URL(a.pathname+a.search,a))(e.originalUrl)}catch{const a="Resource Not Found";e.status(404);const c=S(404,a);return e.html(404,c),new b.ServerError(404,a)}let t=1;async function i(){try{await e.next()}catch(o){if(o instanceof b.RedirectMessage)await e.getWritableStream().close();else if(o instanceof b.RewriteMessage){if(t>50)throw new Error("Infinite rewrite loop");t+=1;const a=new URL(e.url);a.pathname=o.pathname;const{loadedRoute:c,requestHandlers:s}=await n(a);return e.resetRoute(c,s,a),await i()}else if(o instanceof b.ServerError){if(!e.headersSent){const a=o.status,c=e.request.headers.get("Accept");if(c&&!c.includes("text/html"))e.headers.set("Content-Type","application/qwik-json"),e.send(a,await M._serialize([o.data]));else{const s=S(o.status,o.data);e.html(a,s)}}}else if(!(o instanceof b.AbortMessage)){if(L(e)!=="dev")try{e.headersSent||(e.headers.set("content-type","text/html; charset=utf-8"),e.cacheControl({noCache:!0}),e.status(500));const a=e.getWritableStream();if(!a.locked){const c=a.getWriter();await c.write(z.encode(S(500,"Internal Server Error"))),await c.close()}}catch{console.error("Unable to render error page")}return o}}}try{return await i()}finally{e.isDirty()||r(null)}}function V(e){const n=e.endsWith(P);if(n){const r=e.length-P.length+(globalThis.__NO_TRAILING_SLASH__?0:1);e=e.slice(0,r),e===""&&(e="/")}return{pathname:e,isInternal:n}}const H="@isQData",P="/q-data.json",_e=Symbol("RequestEvLoaders"),Te=Symbol("RequestEvMode"),Me=Symbol("RequestEvRoute"),Ne=Symbol("RequestEvLoaderSerializationStrategyMap"),xe="@routeName",E="@actionId",Ce="@actionFormData",fn="@nonce",Ie="@rewrite",X="@serverTiming",ee="qData";function un(e,n,r,t,i){const{request:o,platform:a,env:c}=e,s=new Map,l=new tn(o.headers.get("cookie")),f=new Headers,u=new URL(o.url),{pathname:m,isInternal:p}=V(u.pathname);p&&(u.pathname=m,s.set(H,!0));let g=-1,w=null,A,x=e.locale,R=200;const qe=async()=>{for(g++;g<r.length;){const d=r[g],h=d(_);Xe(h)&&await h,g++}},ke=(d,h,y=u)=>{n=d,r=h,u.pathname=y.pathname,u.search=y.search,g=-1},C=()=>{if(w!==null)throw new Error("Response already sent")},k=(d,h)=>{if(C(),typeof d=="number"){R=d;const T=_.getWritableStream().getWriter();T.write(typeof h=="string"?z.encode(h):h),T.close()}else if(R=d.status,d.headers.forEach((y,T)=>{T.toLowerCase()!=="set-cookie"&&f.append(T,y)}),d.headers.getSetCookie().forEach(y=>{const T=y.indexOf("=");if(T===-1)return;const We=y.slice(0,T).trim(),$e=y.slice(T+1).trim();l.set(We,$e)}),d.body){const y=_.getWritableStream();d.body.pipeTo(y)}else _.getWritableStream().getWriter().close();return re()},re=()=>(g=B,new b.AbortMessage),O={},_={[_e]:O,[Ne]:new Map,[Te]:e.mode,get[Me](){return n},cookie:l,headers:f,env:c,method:o.method,signal:o.signal,originalUrl:new URL(u),get params(){return n?.[U.Params]??{}},get pathname(){return u.pathname},platform:a,get query(){return u.searchParams},request:o,url:u,basePathname:t,sharedMap:s,get headersSent(){return w!==null},get exited(){return g>=B},get clientConn(){return e.getClientConn()},next:qe,resetRoute:ke,exit:re,cacheControl:(d,h="Cache-Control")=>{C(),f.set(h,Ze(d))},resolveValue:(async d=>{const h=d.__id;if(d.__brand==="server_loader"){if(!(h in O))throw new Error("You can not get the returned data of a loader that has not been executed for this request.");if(O[h]===M._UNINITIALIZED){const y=L(_)==="dev";await Le(d,O,_,y)}}return O[h]}),status:d=>typeof d=="number"?(C(),R=d,d):R,locale:d=>(typeof d=="string"&&(x=d),x||""),error:(d,h)=>(R=d,f.delete("Cache-Control"),new b.ServerError(d,h)),redirect:(d,h)=>{if(C(),R=d,h){if(/([^:])\/{2,}/.test(h)){const y=h.replace(/([^:])\/{2,}/g,"$1/");console.warn(`Redirect URL ${h} is invalid, fixing to ${y}`),h=y}f.set("Location",h)}return f.delete("Cache-Control"),d>301&&f.set("Cache-Control","no-store"),g=B,new b.RedirectMessage},rewrite:d=>{if(C(),d.startsWith("http"))throw new Error("Rewrite does not support absolute urls");return s.set(Ie,!0),new b.RewriteMessage(d.replace(/\/+/g,"/"))},defer:d=>typeof d=="function"?d:()=>d,fail:(d,h)=>(C(),R=d,f.delete("Cache-Control"),{failed:!0,...h}),text:(d,h)=>(f.set("Content-Type","text/plain; charset=utf-8"),k(d,h)),html:(d,h)=>(f.set("Content-Type","text/html; charset=utf-8"),k(d,h)),parseBody:async()=>A!==void 0?A:A=mn(_,s),json:(d,h)=>(f.set("Content-Type","application/json; charset=utf-8"),k(d,JSON.stringify(h))),send:k,isDirty:()=>w!==null,getWritableStream:()=>{if(w===null){if(e.mode==="dev"){const d=s.get(X);d&&f.set("Server-Timing",d.map(([h,y])=>`${h};dur=${y}`).join(","))}w=e.getWritableStream(R,f,l,i,_)}return w}};return Object.freeze(_)}function q(e){return e[_e]}function Pe(e){return e[Ne]}function hn(e){return e[Me]}function L(e){return e[Te]}const B=Number.MAX_SAFE_INTEGER,mn=async({request:e,method:n,query:r},t)=>{const i=e.headers.get("content-type")?.split(/[;,]/,1)[0].trim()??"";if(i==="application/x-www-form-urlencoded"||i==="multipart/form-data"){const o=await e.formData();return t.set(Ce,o),gn(o)}else{if(i==="application/json")return await e.json();if(i==="application/qwik-json"){if(n==="GET"&&r.has(se)){const o=r.get(se);if(o)try{return M._deserialize(decodeURIComponent(o))}catch{}}return M._deserialize(await e.text())}}},gn=e=>[...e.entries()].reduce((r,[t,i])=>(t.split(".").reduce((o,a,c,s)=>{if(a.endsWith("[]")){const l=a.slice(0,-2);return o[l]=o[l]||[],o[l]=[...o[l],i]}return c<s.length-1?o[a]=o[a]||(Number.isNaN(+s[c+1])?{}:[]):o[a]=i},r),r),{});function yn(e){const{params:n,request:r,status:t,locale:i,originalUrl:o}=e,a={};r.headers.forEach((x,R)=>a[R]=x);const c=e.sharedMap.get(E),s=e.sharedMap.get(Ce),l=e.sharedMap.get(xe),f=e.sharedMap.get(fn),u=e.request.headers,m=new URL(o.pathname+o.search,o),p=u.get("X-Forwarded-Host"),g=u.get("X-Forwarded-Proto");p&&(m.port="",m.host=p),g&&(m.protocol=g);const w=q(e),A=Pe(e);return{url:m.href,requestHeaders:a,locale:i(),nonce:f,containerAttributes:{[Ge]:l},qwikrouter:{routeName:l,ev:e,params:{...n},loadedRoute:hn(e),response:{status:t(),loaders:w,loadersSerializationStrategy:A,action:c,formData:s}}}}const wn=(e,n,r,t,i,o)=>{const a=[],c=[],s=[],l=!!(n&&Mn(n[U.Mods]));if(o&&s.push(In),e&&ge(a,c,s,e,l,r),n){const f=n[U.RouteName];t&&(r==="POST"||r==="PUT"||r==="PATCH"||r==="DELETE")&&(t==="lax-proto"?s.unshift(Nn):s.unshift(xn)),l&&((r==="POST"||r==="GET")&&s.push(An),s.push(_n),o&&s.push(Pn));const u=n[U.Mods];ge(a,c,s,u,l,r),l&&(s.push(m=>{m.sharedMap.set(xe,f)}),s.push(pn(c)),s.push(Rn(a)),s.push(i))}return s},ge=(e,n,r,t,i,o)=>{for(const a of t){typeof a.onRequest=="function"?r.push(a.onRequest):Array.isArray(a.onRequest)&&r.push(...a.onRequest);let c;switch(o){case"GET":{c=a.onGet;break}case"POST":{c=a.onPost;break}case"PUT":{c=a.onPut;break}case"PATCH":{c=a.onPatch;break}case"DELETE":{c=a.onDelete;break}case"OPTIONS":{c=a.onOptions;break}case"HEAD":{c=a.onHead;break}}if(typeof c=="function"?r.push(c):Array.isArray(c)&&r.push(...c),i)for(const s of Object.values(a))typeof s=="function"&&(s.__brand==="server_loader"?e.push(s):s.__brand==="server_action"&&n.push(s))}};function pn(e){return async n=>{const r=n;if(r.headersSent){r.exit();return}const{method:t}=r,i=q(r),o=L(r)==="dev";if(o&&t==="GET"&&r.query.has(ae)&&console.warn(`Seems like you are submitting a Qwik Action via GET request. Qwik Actions should be submitted via POST request.
|
|
16
|
+
Make sure your <form> has method="POST" attribute, like this: <form method="POST">`),t==="POST"){const a=r.query.get(ae);if(a){const c=globalThis._qwikActionsMap,s=e.find(l=>l.__id===a)??c?.get(a);if(s){r.sharedMap.set(E,a);const l=await r.parseBody();if(!l||typeof l!="object")throw new Error(`Expected request data for the action id ${a} to be an object`);const f=await Oe(r,s.__validators,l,o);if(!f.success)i[a]=r.fail(f.status??500,f.error);else{const u=o?await j(r,s.__qrl.getHash(),()=>s.__qrl.call(r,f.data,r)):await s.__qrl.call(r,f.data,r);o&&Q(u,s.__qrl),i[a]=u}}}}}}function Rn(e){return async n=>{const r=n;if(r.headersSent){r.exit();return}const t=q(r),i=L(r)==="dev";if(e.length>0){let o=[];if(r.query.has(J)){const c=r.query.getAll(J);for(const s of e)c.includes(s.__id)?o.push(s):t[s.__id]=M._UNINITIALIZED}else o=e;const a=o.map(c=>Le(c,t,r,i));await Promise.all(a)}}}async function Le(e,n,r,t){const i=e.__id;return n[i]=Oe(r,e.__validators,void 0,t).then(a=>a.success?t?j(r,e.__qrl.getHash(),()=>e.__qrl.call(r,r)):e.__qrl.call(r,r):r.fail(a.status??500,a.error)).then(a=>(typeof a=="function"?n[i]=a():(t&&Q(a,e.__qrl),n[i]=a),a)),Pe(r).set(i,e.__serializationStrategy),n[i]}async function Oe(e,n,r,t){let i={success:!0,data:r};if(n)for(const o of n)if(t?i=await j(e,"validator$",()=>o.validate(e,r)):i=await o.validate(e,r),i.success)r=i.data;else return i;return i}function bn(e){return e?typeof e=="object"&&Symbol.asyncIterator in e:!1}async function An(e){const n=e.query.get(je);if(n&&e.request.headers.get("X-QRL")===n&&e.request.headers.get("Content-Type")==="application/qwik-json"){e.exit();const r=L(e)==="dev",t=await e.parseBody();if(Array.isArray(t)){const[i,...o]=t;if(Tn(i)&&i.getHash()===n){let a;try{r?a=await j(e,`server_${i.getSymbol()}`,()=>i.apply(e,o)):a=await i.apply(e,o)}catch(c){throw c instanceof b.ServerError?e.error(c.status,c.data):e.error(500,"Invalid request")}if(bn(a)){e.headers.set("Content-Type","text/qwik-json-stream");const s=e.getWritableStream().getWriter();for await(const l of a){r&&Q(l,i);const f=await M._serialize([l]);if(e.signal.aborted)break;await s.write(z.encode(`${f}
|
|
17
|
+
`))}s.close()}else{Q(a,i),e.headers.set("Content-Type","application/qwik-json");const c=await M._serialize([a]);e.send(200,c)}return}}throw e.error(500,"Invalid request")}}function _n(e){const{basePathname:n,originalUrl:r,sharedMap:t}=e,{pathname:i,search:o}=r;if(!t.has(H)&&i!==n&&!i.endsWith(".html")){if(globalThis.__NO_TRAILING_SLASH__){if(i.endsWith("/"))throw e.redirect(Y.MovedPermanently,i.slice(0,i.length-1)+o)}else if(!i.endsWith("/"))throw e.redirect(Y.MovedPermanently,i+"/"+o)}}function Q(e,n){try{M._verifySerializable(e,void 0)}catch(r){throw r instanceof Error&&n.dev&&(r.loc=n.dev),r}}const Tn=e=>typeof e=="function"&&typeof e.getSymbol=="function";function Mn(e){const n=e[e.length-1];return n&&typeof n.default=="function"}function Z(e){e=new URL(e),e.pathname.endsWith(P)&&(e.pathname=e.pathname.slice(0,-P.length)),globalThis.__NO_TRAILING_SLASH__?e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)):e.pathname.endsWith("/")||(e.pathname+="/");const n=e.search.slice(1).replaceAll(/&?q(action|data|func|loaders)=[^&]+/g,"");return`${e.pathname}${n?`?${n}`:""}${e.hash}`}const z=new TextEncoder;function Nn(e){Ue(e,"lax-proto")}function xn(e){Ue(e)}function Ue(e,n){if(On(e.request.headers,"application/x-www-form-urlencoded","multipart/form-data","text/plain")){const t=e.request.headers.get("origin"),i=e.url.origin;let o=t!==i;if(o&&n&&t?.replace(/^http(s)?/g,"")===i.replace(/^http(s)?/g,"")&&(o=!1),o)throw e.error(403,`CSRF check failed. Cross-site ${e.method} form submissions are forbidden.
|
|
18
|
+
The request origin "${t}" does not match the server origin "${i}".`)}}function Cn(e){return async n=>{if(n.headersSent||n.sharedMap.has(H))return;n.request.headers.forEach((f,u)=>f);const t=n.headers;t.has("Content-Type")||t.set("Content-Type","text/html; charset=utf-8");const{readable:i,writable:o}=new TextEncoderStream,a=n.getWritableStream(),c=i.pipeTo(a,{preventClose:!0}),s=o.getWriter(),l=n.status();try{const f=L(n)==="static",u=yn(n),m=await e({base:n.basePathname+"build/",stream:s,serverData:u,containerAttributes:{"q:render":f?"static":"",...u.containerAttributes}}),p={loaders:q(n),action:n.sharedMap.get(E),status:l!==200?l:200,href:Z(n.url)};typeof m.html=="string"&&await s.write(m.html),n.sharedMap.set(ee,p)}finally{await s.ready,await s.close(),await c}await a.close()}}async function In(e){try{await e.next()}catch(i){if(!(i instanceof b.RedirectMessage))throw i}if(e.headersSent)return;const n=e.status(),r=e.headers.get("Location");if(n>=301&&n<=308&&r){const i=Ln(r);if(i){e.headers.set("Location",i),e.getWritableStream().close();return}else e.status(200),e.headers.delete("Location")}}async function Pn(e){if(await e.next(),e.headersSent||e.exited)return;const n=e.status(),r=e.headers.get("Location");e.request.headers.forEach((l,f)=>l),e.headers.set("Content-Type","application/json; charset=utf-8");let t=q(e);const i=e.query.getAll(J),o=i.length>0;if(o){const l={};for(const f of i){const u=t[f];l[f]=u}t=l}const a=o?{loaders:t,status:n!==200?n:200,href:Z(e.url)}:{loaders:t,action:e.sharedMap.get(E),status:n!==200?n:200,href:Z(e.url),redirect:r??void 0,isRewrite:e.sharedMap.get(Ie)},c=e.getWritableStream().getWriter(),s=await M._serialize([a]);c.write(z.encode(s)),e.sharedMap.set(ee,a),c.close()}function Ln(e){if(e.startsWith("/")){if(!e.includes(P)){const n=new URL(e,"http://localhost");return(n.pathname.endsWith("/")?n.pathname.slice(0,-1):n.pathname)+P+n.search}return e}else return}function ye(){return typeof performance<"u"?performance.now():0}async function j(e,n,r){const t=ye();try{return await r()}finally{const i=ye()-t;let o=e.sharedMap.get(X);o||e.sharedMap.set(X,o=[]),o.push([n,i])}}function On(e,...n){const r=e.get("content-type")?.split(/;/,1)[0].trim()??"";return n.includes(r)}let v;async function Un(e,n){const{render:r,checkOrigin:t}=n;let{qwikRouterConfig:i}=n;if(i||(v||(v=await import("@qwik-router-config")),i=v),!i)throw new Error("qwikRouterConfig is required.");const{pathname:o,isInternal:a}=V(e.url.pathname),c=await we(i,o,e.request.method,t??!0,r,a);if(c){const[s,l]=c;return dn(e,s,l,async u=>{const{pathname:m}=V(u.pathname),p=await we(i,m,e.request.method,t??!0,r,a);if(p){const[g,w]=p;return{loadedRoute:g,requestHandlers:w}}else return{loadedRoute:null,requestHandlers:[]}},i.basePathname)}return null}async function we(e,n,r,t,i,o){const{routes:a,serverPlugins:c,menus:s,cacheModules:l}=e,f=await Ye(a,s,l,n,o),u=wn(c,f,r,t,Cn(i),o);return u.length>0?[f,u]:null}const qn=["__QWIK_ROUTER_NOT_FOUND_ARRAY__"];function kn(e){for(const[n,r]of qn)if(e.startsWith(n))return r;return Ae(404,"Resource Not Found")}const K=new Set(["__QWIK_ROUTER_STATIC_PATHS_ARRAY__"]);function Wn(e,n){if(e.toUpperCase()!=="GET")return!1;const r=n.pathname;if(r.startsWith("/"+(globalThis.__QWIK_BUILD_DIR__||"build")+"/")||r.startsWith("/"+(globalThis.__QWIK_ASSETS_DIR__||"assets")+"/")||K.has(r))return!0;if(r.endsWith("/q-data.json")){const t=r.replace(/\/q-data.json$/,"");if(K.has(t+"/")||K.has(t))return!0}return!1}class $n extends Error{constructor(n,r){super(typeof r=="string"?r:void 0),this.status=n,this.data=r}}class ne{}class Dn extends ne{}class Sn extends ne{constructor(n){super(),this.pathname=n}}class Fn{#e=null;#n=new TextEncoder;#r=new TransformStream({transform:(n,r)=>{n=String(n);let t="";for(let i=0;i<n.length;i++){const o=n[i],a=o.charCodeAt(0);if(this.#e!==null){const c=this.#e;if(this.#e=null,56320<=a&&a<=57343){t+=c+o;continue}t+="�"}if(55296<=a&&a<=56319){this.#e=o;continue}if(56320<=a&&a<=57343){t+="�";continue}t+=o}t&&r.enqueue(this.#n.encode(t))},flush:n=>{this.#e!==null&&n.enqueue(new Uint8Array([239,191,189]))}});get encoding(){return this.#n.encoding}get readable(){return this.#r.readable}get writable(){return this.#r.writable}get[Symbol.toStringTag](){return"TextEncoderStream"}}exports.AbortMessage=ne;exports.RedirectMessage=Dn;exports.RequestEvShareQData=ee;exports.RewriteMessage=Sn;exports.ServerError=$n;exports._TextEncoderStream_polyfill=Fn;exports.getErrorHtml=S;exports.getNotFound=kn;exports.isStaticPath=Wn;exports.mergeHeadersCookies=on;exports.requestHandler=Un;
|