@qwik.dev/router 2.0.0-beta.34 → 2.0.0-beta.36
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.mjs +16 -10
- package/lib/chunks/use-functions.qwik.mjs +0 -3
- package/lib/chunks/worker-thread.qwik.mjs +18 -6
- package/lib/index.d.ts +4 -3
- package/lib/index.qwik.mjs +11 -5
- package/lib/middleware/node/index.mjs +110 -18
- package/lib/middleware/request-handler/index.mjs +18 -6
- package/lib/vite/index.mjs +14 -2
- package/package.json +3 -3
|
@@ -227,16 +227,22 @@ function viteAdapter(opts) {
|
|
|
227
227
|
`if (args.includes('--quiet')) ssgOpts.log = 'quiet';`,
|
|
228
228
|
`if (args.includes('--debug')) ssgOpts.log = 'debug';`,
|
|
229
229
|
``,
|
|
230
|
-
|
|
231
|
-
`
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
`
|
|
235
|
-
`
|
|
236
|
-
`
|
|
237
|
-
`
|
|
238
|
-
`
|
|
239
|
-
`
|
|
230
|
+
// Fire-and-forget instead of top-level await. On the worker/edge SSR target Vite
|
|
231
|
+
// inlines dynamic imports, and Rollup then reads the inlined `./system` namespace
|
|
232
|
+
// before it is initialized across a top-level await. See rollup/rollup#4166.
|
|
233
|
+
// runSsg/startWorker keep the process alive (worker handles) and call process.exit.
|
|
234
|
+
`const ssgRun = isMainThread`,
|
|
235
|
+
` ? runSsg({`,
|
|
236
|
+
` render,`,
|
|
237
|
+
` qwikRouterConfig,`,
|
|
238
|
+
` workerFilePath: new URL(import.meta.url).href,`,
|
|
239
|
+
` ...ssgOpts,`,
|
|
240
|
+
` })`,
|
|
241
|
+
` : startWorker({ render, qwikRouterConfig });`,
|
|
242
|
+
`ssgRun.catch((err) => {`,
|
|
243
|
+
` console.error(err);`,
|
|
244
|
+
` process.exit(1);`,
|
|
245
|
+
`});`
|
|
240
246
|
].join("\n");
|
|
241
247
|
},
|
|
242
248
|
buildStart() {
|
|
@@ -16,9 +16,6 @@ const useDocumentHead = () => useContext(DocumentHeadContext);
|
|
|
16
16
|
const useLocation = () => useContext(RouteLocationContext);
|
|
17
17
|
const useNavigate = () => useContext(RouteNavigateContext);
|
|
18
18
|
const usePreventNavigateQrl = (fn) => {
|
|
19
|
-
if (!__EXPERIMENTAL__.preventNavigate) {
|
|
20
|
-
throw new Error('usePreventNavigate$ is experimental and must be enabled with `experimental: ["preventNavigate"]` in the `qwikVite` plugin.');
|
|
21
|
-
}
|
|
22
19
|
const registerPreventNav = useContext(RoutePreventNavigateContext);
|
|
23
20
|
useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
24
21
|
const fn2 = _captures[0], registerPreventNav2 = _captures[1];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parentPort } from 'node:worker_threads';
|
|
2
|
-
import { isDev, _UNINITIALIZED, _deserialize, _verifySerializable, _serialize } from '@qwik.dev/core/internal';
|
|
2
|
+
import { isDev, _UNINITIALIZED, _deserialize, _verifySerializable, _serialize, _getAsyncLocalStorage } from '@qwik.dev/core/internal';
|
|
3
3
|
import { withLocale, inlinedQrl } from '@qwik.dev/core';
|
|
4
4
|
import { A as AbortMessage$1 } from './redirect-handler.mjs';
|
|
5
5
|
import { isServer } from '@qwik.dev/core/build';
|
|
@@ -1616,8 +1616,11 @@ The request origin "${inputOrigin}" does not match the server origin "${origin}"
|
|
|
1616
1616
|
});
|
|
1617
1617
|
pipeSource = readable.pipeThrough(capture);
|
|
1618
1618
|
}
|
|
1619
|
+
let pipeError;
|
|
1619
1620
|
const pipe = pipeSource.pipeTo(writableStream, {
|
|
1620
1621
|
preventClose: true
|
|
1622
|
+
}).catch((error) => {
|
|
1623
|
+
pipeError = error;
|
|
1621
1624
|
});
|
|
1622
1625
|
const stream = writable.getWriter();
|
|
1623
1626
|
const status = requestEv.status();
|
|
@@ -1627,6 +1630,9 @@ The request origin "${inputOrigin}" does not match the server origin "${origin}"
|
|
|
1627
1630
|
const result = await render({
|
|
1628
1631
|
base: requestEv.basePathname + "build/",
|
|
1629
1632
|
stream,
|
|
1633
|
+
streaming: isStatic ? {
|
|
1634
|
+
outOfOrder: false
|
|
1635
|
+
} : void 0,
|
|
1630
1636
|
serverData,
|
|
1631
1637
|
containerAttributes: {
|
|
1632
1638
|
["q:render"]: isStatic ? "static" : "",
|
|
@@ -1648,6 +1654,9 @@ The request origin "${inputOrigin}" does not match the server origin "${origin}"
|
|
|
1648
1654
|
await stream.close();
|
|
1649
1655
|
await pipe;
|
|
1650
1656
|
}
|
|
1657
|
+
if (pipeError) {
|
|
1658
|
+
throw pipeError;
|
|
1659
|
+
}
|
|
1651
1660
|
if (eTagCacheKey && cacheChunks && cacheChunks.length > 0) {
|
|
1652
1661
|
const totalLength = cacheChunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
1653
1662
|
const combined = new Uint8Array(totalLength);
|
|
@@ -1803,6 +1812,7 @@ function getQwikRouterServerDataWithDeps(deps, requestEv) {
|
|
|
1803
1812
|
return {
|
|
1804
1813
|
url: reconstructedUrl.href,
|
|
1805
1814
|
requestHeaders,
|
|
1815
|
+
renderMode: deps.getRequestMode(requestEv),
|
|
1806
1816
|
locale: locale(),
|
|
1807
1817
|
nonce,
|
|
1808
1818
|
containerAttributes: {
|
|
@@ -1836,6 +1846,7 @@ const responsePageDeps = {
|
|
|
1836
1846
|
RequestRouteName,
|
|
1837
1847
|
getRequestLoaders,
|
|
1838
1848
|
getRequestLoaderSerializationStrategyMap,
|
|
1849
|
+
getRequestMode,
|
|
1839
1850
|
getRequestRoute
|
|
1840
1851
|
};
|
|
1841
1852
|
function getQwikRouterServerData(...args) {
|
|
@@ -2103,11 +2114,12 @@ function createRequestEvent(...args) {
|
|
|
2103
2114
|
|
|
2104
2115
|
let _asyncRequestStore;
|
|
2105
2116
|
if (isServer) {
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2117
|
+
const AsyncLocalStorage = _getAsyncLocalStorage();
|
|
2118
|
+
if (AsyncLocalStorage) {
|
|
2119
|
+
_asyncRequestStore = new AsyncLocalStorage();
|
|
2120
|
+
} else {
|
|
2121
|
+
console.warn("\n=====================\n Qwik Router Warning:\n AsyncLocalStorage is not available, continuing without it.\n This impacts concurrent async server calls, where they lose access to the ServerRequestEv object.\n=====================\n\n");
|
|
2122
|
+
}
|
|
2111
2123
|
}
|
|
2112
2124
|
|
|
2113
2125
|
const ESCAPE_HTML = /[&<>]/g;
|
package/lib/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { QRLEventHandlerMulti } from '@qwik.dev/core';
|
|
|
13
13
|
import { QwikIntrinsicElements } from '@qwik.dev/core';
|
|
14
14
|
import { QwikJSX } from '@qwik.dev/core';
|
|
15
15
|
import { Render } from '@qwik.dev/core/server';
|
|
16
|
-
import {
|
|
16
|
+
import { RenderToStreamOptions } from '@qwik.dev/core/server';
|
|
17
17
|
import { RequestEvent } from '@qwik.dev/router/middleware/request-handler';
|
|
18
18
|
import { RequestEventAction } from '@qwik.dev/router/middleware/request-handler';
|
|
19
19
|
import { RequestEventBase } from '@qwik.dev/router/middleware/request-handler';
|
|
@@ -754,12 +754,12 @@ export declare interface QwikRouterProps {
|
|
|
754
754
|
export declare const QwikRouterProvider: Component<QwikRouterProps>;
|
|
755
755
|
|
|
756
756
|
/** @public */
|
|
757
|
-
export declare type RendererOptions = Omit<
|
|
757
|
+
export declare type RendererOptions = Omit<RenderToStreamOptions, 'serverData'> & {
|
|
758
758
|
serverData: ServerData;
|
|
759
759
|
};
|
|
760
760
|
|
|
761
761
|
/** @public */
|
|
762
|
-
export declare type RendererOutputOptions = Omit<
|
|
762
|
+
export declare type RendererOutputOptions = Omit<RenderToStreamOptions, 'serverData'> & {
|
|
763
763
|
serverData: ServerData & {
|
|
764
764
|
documentHead?: DocumentHeadValue;
|
|
765
765
|
} & Record<string, unknown>;
|
|
@@ -911,6 +911,7 @@ declare interface ServerConfig {
|
|
|
911
911
|
export declare type ServerData = {
|
|
912
912
|
url: string;
|
|
913
913
|
requestHeaders: Record<string, string>;
|
|
914
|
+
renderMode: 'static' | 'server';
|
|
914
915
|
locale: string | undefined;
|
|
915
916
|
nonce: string | undefined;
|
|
916
917
|
containerAttributes: Record<string, string> & {
|
package/lib/index.qwik.mjs
CHANGED
|
@@ -26,6 +26,7 @@ const ErrorBoundary = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((p
|
|
|
26
26
|
return /* @__PURE__ */ _jsxSorted(Slot, null, null, null, 3, "bA_1");
|
|
27
27
|
}, "ErrorBoundary_component_pOa6vjtC7ik"));
|
|
28
28
|
|
|
29
|
+
const __vite_import_meta_env__ = {};
|
|
29
30
|
const Link = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
30
31
|
const nav = useNavigate();
|
|
31
32
|
const loc = useLocation();
|
|
@@ -117,7 +118,7 @@ const Link = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
117
118
|
handler?.(event, anchorRef2.value);
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
|
-
const isProdOrTest = !isDev ||
|
|
121
|
+
const isProdOrTest = !isDev || __vite_import_meta_env__?.TEST;
|
|
121
122
|
if (isProdOrTest && anchorRef2.value) {
|
|
122
123
|
if (prefetchBundleProp2 === "visible" || // deprecated prop below, remove in favor of prefetchBundle
|
|
123
124
|
prefetchProp2 === "js" || prefetchProp2 === true) {
|
|
@@ -413,9 +414,6 @@ const useQwikRouter = (props) => {
|
|
|
413
414
|
}
|
|
414
415
|
const serverHead = useServerData("documentHead");
|
|
415
416
|
const manifestHash = useServerData("containerAttributes")?.["q:manifest-hash"];
|
|
416
|
-
if (env.ev.originalUrl.pathname !== env.ev.url.pathname && !__EXPERIMENTAL__.enableRequestRewrite) {
|
|
417
|
-
throw new Error(`enableRequestRewrite is an experimental feature and is not enabled. Please enable the feature flag by adding \`experimental: ["enableRequestRewrite"]\` to your qwikVite plugin options.`);
|
|
418
|
-
}
|
|
419
417
|
const url = new URL(urlEnv);
|
|
420
418
|
const routeLocationTarget = {
|
|
421
419
|
url,
|
|
@@ -1655,7 +1653,15 @@ function omitProps(obj, keys) {
|
|
|
1655
1653
|
const createRenderer = (getOptions) => {
|
|
1656
1654
|
return (opts) => {
|
|
1657
1655
|
const { jsx, options } = getOptions(opts);
|
|
1658
|
-
|
|
1656
|
+
const isStatic = opts.serverData.renderMode === "static";
|
|
1657
|
+
const renderOptions = isStatic ? {
|
|
1658
|
+
...options,
|
|
1659
|
+
streaming: {
|
|
1660
|
+
...options.streaming,
|
|
1661
|
+
outOfOrder: false
|
|
1662
|
+
}
|
|
1663
|
+
} : options;
|
|
1664
|
+
return renderToStream(jsx, renderOptions);
|
|
1659
1665
|
};
|
|
1660
1666
|
};
|
|
1661
1667
|
|
|
@@ -18,12 +18,15 @@ function fallbackOrigin(req) {
|
|
|
18
18
|
function computeOrigin(req, opts) {
|
|
19
19
|
return opts?.getOrigin?.(req) ?? opts?.origin ?? process.env.ORIGIN ?? fallbackOrigin(req);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
function isClientAbortWriteError(error) {
|
|
22
|
+
if (!(error instanceof Error)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const code = error.code;
|
|
26
|
+
if (code === "EPIPE" || code === "ECONNRESET" || code === "ERR_STREAM_DESTROYED" || code === "ERR_STREAM_WRITE_AFTER_END") {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
27
30
|
}
|
|
28
31
|
const invalidHeadersPattern = /^:(method|scheme|authority|path)$/i;
|
|
29
32
|
function normalizeUrl(url, base) {
|
|
@@ -34,38 +37,75 @@ function getUrl(req, origin) {
|
|
|
34
37
|
}
|
|
35
38
|
function createNodeResponseSink(res) {
|
|
36
39
|
let closed = res.closed || res.destroyed;
|
|
40
|
+
let responseError;
|
|
41
|
+
let resolveClosed;
|
|
37
42
|
const closedPromise = closed ? Promise.resolve() : new Promise((resolve) => {
|
|
43
|
+
resolveClosed = resolve;
|
|
38
44
|
res.once("close", () => {
|
|
39
45
|
closed = true;
|
|
40
46
|
resolve();
|
|
41
47
|
});
|
|
42
48
|
});
|
|
49
|
+
res.on("error", (error) => {
|
|
50
|
+
if (responseError === void 0) {
|
|
51
|
+
responseError = error;
|
|
52
|
+
}
|
|
53
|
+
if (!closed) {
|
|
54
|
+
closed = true;
|
|
55
|
+
resolveClosed();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const shouldPropagateResponseError = () => responseError !== void 0 && !isClientAbortWriteError(responseError);
|
|
43
59
|
const write = (chunk) => {
|
|
44
60
|
if (closed || res.closed || res.destroyed) {
|
|
61
|
+
if (shouldPropagateResponseError()) {
|
|
62
|
+
return Promise.reject(responseError);
|
|
63
|
+
}
|
|
45
64
|
return;
|
|
46
65
|
}
|
|
47
66
|
return new Promise((resolve, reject) => {
|
|
48
67
|
let settled = false;
|
|
68
|
+
let onDrain;
|
|
69
|
+
const cleanupDrain = () => {
|
|
70
|
+
if (onDrain) {
|
|
71
|
+
res.off("drain", onDrain);
|
|
72
|
+
onDrain = void 0;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
49
75
|
const finish = () => {
|
|
50
76
|
if (settled) {
|
|
51
77
|
return;
|
|
52
78
|
}
|
|
53
79
|
settled = true;
|
|
80
|
+
cleanupDrain();
|
|
54
81
|
setImmediate(resolve);
|
|
55
82
|
};
|
|
83
|
+
const finishClosed = () => {
|
|
84
|
+
closed = true;
|
|
85
|
+
finish();
|
|
86
|
+
};
|
|
56
87
|
const fail = (error) => {
|
|
57
88
|
if (settled) {
|
|
58
89
|
return;
|
|
59
90
|
}
|
|
60
91
|
settled = true;
|
|
92
|
+
closed = true;
|
|
93
|
+
cleanupDrain();
|
|
61
94
|
reject(error);
|
|
62
95
|
};
|
|
63
|
-
closedPromise.then(
|
|
96
|
+
closedPromise.then(() => {
|
|
97
|
+
if (shouldPropagateResponseError()) {
|
|
98
|
+
fail(responseError);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
finish();
|
|
102
|
+
});
|
|
103
|
+
let ok;
|
|
64
104
|
try {
|
|
65
|
-
res.write(chunk, (error) => {
|
|
105
|
+
ok = res.write(chunk, (error) => {
|
|
66
106
|
if (error) {
|
|
67
|
-
if (
|
|
68
|
-
|
|
107
|
+
if (isClientAbortWriteError(error)) {
|
|
108
|
+
finishClosed();
|
|
69
109
|
return;
|
|
70
110
|
}
|
|
71
111
|
fail(error);
|
|
@@ -74,22 +114,69 @@ function createNodeResponseSink(res) {
|
|
|
74
114
|
finish();
|
|
75
115
|
});
|
|
76
116
|
} catch (error) {
|
|
77
|
-
if (
|
|
78
|
-
|
|
117
|
+
if (isClientAbortWriteError(error)) {
|
|
118
|
+
finishClosed();
|
|
79
119
|
return;
|
|
80
120
|
}
|
|
81
121
|
fail(error);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (settled) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (ok) {
|
|
128
|
+
finish();
|
|
129
|
+
} else {
|
|
130
|
+
onDrain = () => {
|
|
131
|
+
onDrain = void 0;
|
|
132
|
+
finish();
|
|
133
|
+
};
|
|
134
|
+
res.once("drain", onDrain);
|
|
82
135
|
}
|
|
83
136
|
});
|
|
84
137
|
};
|
|
85
138
|
const close = () => {
|
|
86
139
|
if (closed || res.closed || res.destroyed) {
|
|
140
|
+
if (shouldPropagateResponseError()) {
|
|
141
|
+
return Promise.reject(responseError);
|
|
142
|
+
}
|
|
87
143
|
return;
|
|
88
144
|
}
|
|
89
|
-
return new Promise((resolve) => {
|
|
90
|
-
|
|
145
|
+
return new Promise((resolve, reject) => {
|
|
146
|
+
let settled = false;
|
|
147
|
+
const finish = () => {
|
|
148
|
+
if (settled) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
settled = true;
|
|
152
|
+
closed = true;
|
|
91
153
|
resolve();
|
|
154
|
+
};
|
|
155
|
+
const fail = (error) => {
|
|
156
|
+
if (settled) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
settled = true;
|
|
160
|
+
closed = true;
|
|
161
|
+
reject(error);
|
|
162
|
+
};
|
|
163
|
+
closedPromise.then(() => {
|
|
164
|
+
if (shouldPropagateResponseError()) {
|
|
165
|
+
fail(responseError);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
finish();
|
|
92
169
|
});
|
|
170
|
+
res.once("finish", finish);
|
|
171
|
+
try {
|
|
172
|
+
res.end();
|
|
173
|
+
} catch (error) {
|
|
174
|
+
if (isClientAbortWriteError(error)) {
|
|
175
|
+
finish();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
fail(error);
|
|
179
|
+
}
|
|
93
180
|
});
|
|
94
181
|
};
|
|
95
182
|
return {
|
|
@@ -123,6 +210,9 @@ async function fromNodeHttp(url, req, res, mode, getClientConn) {
|
|
|
123
210
|
};
|
|
124
211
|
const body = req.method === "HEAD" || req.method === "GET" ? void 0 : getRequestBody();
|
|
125
212
|
const controller = new AbortController();
|
|
213
|
+
const abort = () => {
|
|
214
|
+
controller.abort();
|
|
215
|
+
};
|
|
126
216
|
const options = {
|
|
127
217
|
method: req.method,
|
|
128
218
|
headers: requestHeaders,
|
|
@@ -130,9 +220,10 @@ async function fromNodeHttp(url, req, res, mode, getClientConn) {
|
|
|
130
220
|
signal: controller.signal,
|
|
131
221
|
duplex: "half"
|
|
132
222
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
223
|
+
req.on("aborted", abort);
|
|
224
|
+
req.on("error", abort);
|
|
225
|
+
res.on("close", abort);
|
|
226
|
+
res.on("error", abort);
|
|
136
227
|
const serverRequestEv = {
|
|
137
228
|
mode,
|
|
138
229
|
url,
|
|
@@ -142,7 +233,7 @@ async function fromNodeHttp(url, req, res, mode, getClientConn) {
|
|
|
142
233
|
return process.env[key];
|
|
143
234
|
}
|
|
144
235
|
},
|
|
145
|
-
getWritableStream: (status, headers, cookies) => {
|
|
236
|
+
getWritableStream: (status, headers, cookies, resolve) => {
|
|
146
237
|
res.statusCode = status;
|
|
147
238
|
const sink = createNodeResponseSink(res);
|
|
148
239
|
try {
|
|
@@ -159,6 +250,7 @@ async function fromNodeHttp(url, req, res, mode, getClientConn) {
|
|
|
159
250
|
} catch (err) {
|
|
160
251
|
console.error(err);
|
|
161
252
|
}
|
|
253
|
+
resolve(true);
|
|
162
254
|
return new WritableStream({
|
|
163
255
|
write(chunk) {
|
|
164
256
|
return sink.write(chunk);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Q as Q_ROUTE, m as resolveRouteConfig, n as QLOADER_KEY, h as QFN_KEY, j as QACTION_KEY, o as isPromise, k as QDATA_KEY, b as loadRoute } from '../../chunks/routing.qwik.mjs';
|
|
2
|
-
import { isDev, _UNINITIALIZED, _deserialize, _verifySerializable, _serialize } from '@qwik.dev/core/internal';
|
|
2
|
+
import { isDev, _UNINITIALIZED, _deserialize, _verifySerializable, _serialize, _getAsyncLocalStorage } from '@qwik.dev/core/internal';
|
|
3
3
|
import { inlinedQrl } from '@qwik.dev/core';
|
|
4
4
|
import { R as RedirectMessage, A as AbortMessage } from '../../chunks/redirect-handler.mjs';
|
|
5
5
|
import { isServer } from '@qwik.dev/core/build';
|
|
@@ -603,6 +603,7 @@ function getQwikRouterServerDataWithDeps(deps, requestEv) {
|
|
|
603
603
|
return {
|
|
604
604
|
url: reconstructedUrl.href,
|
|
605
605
|
requestHeaders,
|
|
606
|
+
renderMode: deps.getRequestMode(requestEv),
|
|
606
607
|
locale: locale(),
|
|
607
608
|
nonce,
|
|
608
609
|
containerAttributes: {
|
|
@@ -636,6 +637,7 @@ const responsePageDeps = {
|
|
|
636
637
|
RequestRouteName,
|
|
637
638
|
getRequestLoaders,
|
|
638
639
|
getRequestLoaderSerializationStrategyMap,
|
|
640
|
+
getRequestMode,
|
|
639
641
|
getRequestRoute
|
|
640
642
|
};
|
|
641
643
|
function getQwikRouterServerData(...args) {
|
|
@@ -1079,8 +1081,11 @@ The request origin "${inputOrigin}" does not match the server origin "${origin}"
|
|
|
1079
1081
|
});
|
|
1080
1082
|
pipeSource = readable.pipeThrough(capture);
|
|
1081
1083
|
}
|
|
1084
|
+
let pipeError;
|
|
1082
1085
|
const pipe = pipeSource.pipeTo(writableStream, {
|
|
1083
1086
|
preventClose: true
|
|
1087
|
+
}).catch((error) => {
|
|
1088
|
+
pipeError = error;
|
|
1084
1089
|
});
|
|
1085
1090
|
const stream = writable.getWriter();
|
|
1086
1091
|
const status = requestEv.status();
|
|
@@ -1090,6 +1095,9 @@ The request origin "${inputOrigin}" does not match the server origin "${origin}"
|
|
|
1090
1095
|
const result = await render({
|
|
1091
1096
|
base: requestEv.basePathname + "build/",
|
|
1092
1097
|
stream,
|
|
1098
|
+
streaming: isStatic ? {
|
|
1099
|
+
outOfOrder: false
|
|
1100
|
+
} : void 0,
|
|
1093
1101
|
serverData,
|
|
1094
1102
|
containerAttributes: {
|
|
1095
1103
|
["q:render"]: isStatic ? "static" : "",
|
|
@@ -1111,6 +1119,9 @@ The request origin "${inputOrigin}" does not match the server origin "${origin}"
|
|
|
1111
1119
|
await stream.close();
|
|
1112
1120
|
await pipe;
|
|
1113
1121
|
}
|
|
1122
|
+
if (pipeError) {
|
|
1123
|
+
throw pipeError;
|
|
1124
|
+
}
|
|
1114
1125
|
if (eTagCacheKey && cacheChunks && cacheChunks.length > 0) {
|
|
1115
1126
|
const totalLength = cacheChunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
1116
1127
|
const combined = new Uint8Array(totalLength);
|
|
@@ -1291,11 +1302,12 @@ const { renderQwikMiddleware, resolveRequestHandlers} = requestHandlers;
|
|
|
1291
1302
|
|
|
1292
1303
|
let _asyncRequestStore;
|
|
1293
1304
|
if (isServer) {
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1305
|
+
const AsyncLocalStorage = _getAsyncLocalStorage();
|
|
1306
|
+
if (AsyncLocalStorage) {
|
|
1307
|
+
_asyncRequestStore = new AsyncLocalStorage();
|
|
1308
|
+
} else {
|
|
1309
|
+
console.warn("\n=====================\n Qwik Router Warning:\n AsyncLocalStorage is not available, continuing without it.\n This impacts concurrent async server calls, where they lose access to the ServerRequestEv object.\n=====================\n\n");
|
|
1310
|
+
}
|
|
1299
1311
|
}
|
|
1300
1312
|
|
|
1301
1313
|
function createCacheControl(cacheControl) {
|
package/lib/vite/index.mjs
CHANGED
|
@@ -2275,7 +2275,11 @@ class HtmlTransformPatcher {
|
|
|
2275
2275
|
}
|
|
2276
2276
|
}
|
|
2277
2277
|
async handleEnd(chunk, encoding, callback) {
|
|
2278
|
-
if (typeof
|
|
2278
|
+
if (typeof chunk === "function") {
|
|
2279
|
+
callback = chunk;
|
|
2280
|
+
chunk = void 0;
|
|
2281
|
+
encoding = void 0;
|
|
2282
|
+
} else if (typeof encoding === "function") {
|
|
2279
2283
|
callback = encoding;
|
|
2280
2284
|
encoding = void 0;
|
|
2281
2285
|
}
|
|
@@ -2293,7 +2297,15 @@ function wrapResponseForHtmlTransform(request, response, server) {
|
|
|
2293
2297
|
}
|
|
2294
2298
|
|
|
2295
2299
|
const makeRouterDevMiddleware = (server, ctx) => async (req, res, next) => {
|
|
2296
|
-
|
|
2300
|
+
let mod;
|
|
2301
|
+
try {
|
|
2302
|
+
mod = await server.ssrLoadModule("src/entry.ssr");
|
|
2303
|
+
} catch (e) {
|
|
2304
|
+
if (e instanceof Error) {
|
|
2305
|
+
server.ssrFixStacktrace(e);
|
|
2306
|
+
}
|
|
2307
|
+
return next();
|
|
2308
|
+
}
|
|
2297
2309
|
if (!mod.default) {
|
|
2298
2310
|
console.error("No default export found in src/entry.ssr");
|
|
2299
2311
|
return next();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qwik.dev/router",
|
|
3
3
|
"description": "The router for Qwik.",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.36",
|
|
5
5
|
"bugs": "https://github.com/QwikDev/qwik/issues",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@azure/functions": "3.5.1",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"tsm": "2.3.0",
|
|
41
41
|
"typescript": "5.9.3",
|
|
42
42
|
"uvu": "0.5.6",
|
|
43
|
-
"@qwik.dev/core": "2.0.0-beta.
|
|
43
|
+
"@qwik.dev/core": "2.0.0-beta.36"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
"main": "./lib/index.qwik.mjs",
|
|
170
170
|
"peerDependencies": {
|
|
171
171
|
"vite": ">=6 <9",
|
|
172
|
-
"@qwik.dev/core": "^2.0.0-beta.
|
|
172
|
+
"@qwik.dev/core": "^2.0.0-beta.36"
|
|
173
173
|
},
|
|
174
174
|
"publishConfig": {
|
|
175
175
|
"access": "public"
|