@kasperpeulen/vitest-plugin-nextjs 0.0.0-stage → 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/README.md +249 -2
  2. package/dist/_virtual/_rolldown/runtime.js +14 -0
  3. package/dist/action-ids.d.ts +18 -0
  4. package/dist/action-ids.js +44 -0
  5. package/dist/adapter.d.ts +8 -0
  6. package/dist/adapter.js +12 -0
  7. package/dist/app-requests.d.ts +63 -0
  8. package/dist/app-requests.js +253 -0
  9. package/dist/browser-context.d.ts +24 -0
  10. package/dist/browser-context.js +157 -0
  11. package/dist/build-output.d.ts +68 -0
  12. package/dist/build-output.js +216 -0
  13. package/dist/build.d.ts +26 -0
  14. package/dist/build.js +39 -0
  15. package/dist/built-files.d.ts +9 -0
  16. package/dist/built-files.js +22 -0
  17. package/dist/cache.d.ts +44 -0
  18. package/dist/cache.js +99 -0
  19. package/dist/client-components.d.ts +3 -0
  20. package/dist/client-components.js +4 -0
  21. package/dist/client-file-key.d.ts +5 -0
  22. package/dist/client-file-key.js +5 -0
  23. package/dist/client-files.d.ts +83 -0
  24. package/dist/client-files.js +186 -0
  25. package/dist/client-graph.d.ts +94 -0
  26. package/dist/client-graph.js +266 -0
  27. package/dist/client-modules.d.ts +10 -0
  28. package/dist/client-modules.js +43 -0
  29. package/dist/client.d.ts +42 -0
  30. package/dist/client.js +263 -0
  31. package/dist/commonjs.d.ts +44 -0
  32. package/dist/commonjs.js +111 -0
  33. package/dist/compat/browser/client.d.ts +19 -0
  34. package/dist/compat/browser/client.js +13 -0
  35. package/dist/compat/build.d.ts +145 -0
  36. package/dist/compat/build.js +149 -0
  37. package/dist/compat/checks.d.ts +16 -0
  38. package/dist/compat/checks.js +148 -0
  39. package/dist/compat/patches.d.ts +13 -0
  40. package/dist/compat/patches.js +30 -0
  41. package/dist/compat/paths.d.ts +74 -0
  42. package/dist/compat/paths.js +160 -0
  43. package/dist/compat/rsc/handlers.d.ts +2 -0
  44. package/dist/compat/rsc/handlers.js +2 -0
  45. package/dist/compat/rsc/prerender.d.ts +10 -0
  46. package/dist/compat/rsc/prerender.js +9 -0
  47. package/dist/compat/server/headers.d.ts +3 -0
  48. package/dist/compat/server/headers.js +3 -0
  49. package/dist/compat/ssr/build-output.d.ts +4 -0
  50. package/dist/compat/ssr/build-output.js +3 -0
  51. package/dist/compat/ssr/cache.d.ts +6 -0
  52. package/dist/compat/ssr/cache.js +6 -0
  53. package/dist/compat/ssr/handler.d.ts +8 -0
  54. package/dist/compat/ssr/handler.js +8 -0
  55. package/dist/compat/ssr/node-server.d.ts +5 -0
  56. package/dist/compat/ssr/node-server.js +4 -0
  57. package/dist/compat/ssr/render-errors.d.ts +4 -0
  58. package/dist/compat/ssr/render-errors.js +4 -0
  59. package/dist/compat/ssr/senders.d.ts +6 -0
  60. package/dist/compat/ssr/senders.js +6 -0
  61. package/dist/compat/types.d.ts +8 -0
  62. package/dist/compat/types.js +1 -0
  63. package/dist/compile.d.ts +31 -0
  64. package/dist/compile.js +140 -0
  65. package/dist/disk.d.ts +16 -0
  66. package/dist/disk.js +13 -0
  67. package/dist/document-loads.d.ts +15 -0
  68. package/dist/document-loads.js +53 -0
  69. package/dist/document.d.ts +79 -0
  70. package/dist/document.js +328 -0
  71. package/dist/downloads.d.ts +15 -0
  72. package/dist/downloads.js +71 -0
  73. package/dist/esm-require.d.ts +11 -0
  74. package/dist/esm-require.js +32 -0
  75. package/dist/fast-crypto/index.js +1093 -0
  76. package/dist/fast-crypto.d.ts +20 -0
  77. package/dist/fast-crypto.js +151 -0
  78. package/dist/flight.d.ts +19 -0
  79. package/dist/flight.js +42 -0
  80. package/dist/form-submission.d.ts +15 -0
  81. package/dist/form-submission.js +27 -0
  82. package/dist/from-page.d.ts +5 -0
  83. package/dist/from-page.js +44 -0
  84. package/dist/globals.d.ts +1 -0
  85. package/dist/globals.js +197 -0
  86. package/dist/host-document.d.ts +26 -0
  87. package/dist/host-document.js +34 -0
  88. package/dist/index.d.ts +280 -0
  89. package/dist/index.js +281 -0
  90. package/dist/internal.d.ts +2 -0
  91. package/dist/internal.js +3 -0
  92. package/dist/leftovers.d.ts +11 -0
  93. package/dist/leftovers.js +55 -0
  94. package/dist/mode.d.ts +169 -0
  95. package/dist/mode.js +31 -0
  96. package/dist/node/LICENSES.md +3540 -0
  97. package/dist/node/assert/strict.js +29 -0
  98. package/dist/node/assert.js +3044 -0
  99. package/dist/node/buffer.js +1499 -0
  100. package/dist/node/child_process.js +45 -0
  101. package/dist/node/cluster.js +85 -0
  102. package/dist/node/console.js +96 -0
  103. package/dist/node/constants.js +495 -0
  104. package/dist/node/crypto.js +1388 -0
  105. package/dist/node/dgram.js +78 -0
  106. package/dist/node/diagnostics_channel.js +122 -0
  107. package/dist/node/dns/promises.js +129 -0
  108. package/dist/node/dns.js +137 -0
  109. package/dist/node/domain.js +43 -0
  110. package/dist/node/events.js +1155 -0
  111. package/dist/node/fs/promises.js +40 -0
  112. package/dist/node/fs.js +10375 -0
  113. package/dist/node/http.js +326 -0
  114. package/dist/node/http2.js +305 -0
  115. package/dist/node/https.js +57 -0
  116. package/dist/node/inspector/promises.js +66 -0
  117. package/dist/node/inspector.js +76 -0
  118. package/dist/node/module.js +205 -0
  119. package/dist/node/net.js +392 -0
  120. package/dist/node/os.js +259 -0
  121. package/dist/node/path/posix.js +25 -0
  122. package/dist/node/path/win32.js +25 -0
  123. package/dist/node/path.js +384 -0
  124. package/dist/node/perf_hooks.js +313 -0
  125. package/dist/node/process.js +452 -0
  126. package/dist/node/punycode.js +178 -0
  127. package/dist/node/querystring.js +934 -0
  128. package/dist/node/readline/promises.js +71 -0
  129. package/dist/node/readline.js +56 -0
  130. package/dist/node/repl.js +44 -0
  131. package/dist/node/sqlite.js +22 -0
  132. package/dist/node/stream/consumers.js +47 -0
  133. package/dist/node/stream/promises.js +6 -0
  134. package/dist/node/stream/web.js +52 -0
  135. package/dist/node/stream.js +4323 -0
  136. package/dist/node/string_decoder.js +276 -0
  137. package/dist/node/sys.js +6 -0
  138. package/dist/node/timers/promises.js +71 -0
  139. package/dist/node/timers.js +133 -0
  140. package/dist/node/tls.js +122 -0
  141. package/dist/node/trace_events.js +23 -0
  142. package/dist/node/tty.js +69 -0
  143. package/dist/node/url.js +1426 -0
  144. package/dist/node/util/types.js +1456 -0
  145. package/dist/node/util.js +4807 -0
  146. package/dist/node/v8.js +160 -0
  147. package/dist/node/vm.js +88 -0
  148. package/dist/node/wasi.js +16 -0
  149. package/dist/node/worker_threads.js +123 -0
  150. package/dist/node/zlib.js +1396 -0
  151. package/dist/node-builtins.d.ts +40 -0
  152. package/dist/node-builtins.js +74 -0
  153. package/dist/node-on-page.d.ts +46 -0
  154. package/dist/node-on-page.js +101 -0
  155. package/dist/node-platform.d.ts +36 -0
  156. package/dist/node-platform.js +152 -0
  157. package/dist/node-rendered.d.ts +21 -0
  158. package/dist/node-rendered.js +26 -0
  159. package/dist/node-server.d.ts +46 -0
  160. package/dist/node-server.js +193 -0
  161. package/dist/optimizer-cache-key.d.ts +26 -0
  162. package/dist/optimizer-cache-key.js +73 -0
  163. package/dist/own-package.d.ts +1 -0
  164. package/dist/own-package.js +6 -0
  165. package/dist/page-store.d.ts +33 -0
  166. package/dist/page-store.js +80 -0
  167. package/dist/page-timers.d.ts +22 -0
  168. package/dist/page-timers.js +47 -0
  169. package/dist/page.d.ts +112 -0
  170. package/dist/page.js +549 -0
  171. package/dist/paths.d.ts +13 -0
  172. package/dist/paths.js +47 -0
  173. package/dist/plugin.d.ts +22 -0
  174. package/dist/plugin.js +995 -0
  175. package/dist/prerender-verdict.d.ts +8 -0
  176. package/dist/prerender-verdict.js +67 -0
  177. package/dist/project/context.d.ts +546 -0
  178. package/dist/project/context.js +111 -0
  179. package/dist/project/entries.d.ts +42 -0
  180. package/dist/project/entries.js +189 -0
  181. package/dist/project/env-worker.d.ts +1 -0
  182. package/dist/project/env-worker.js +9 -0
  183. package/dist/project/env.d.ts +36 -0
  184. package/dist/project/env.js +82 -0
  185. package/dist/project/layers.d.ts +31 -0
  186. package/dist/project/layers.js +150 -0
  187. package/dist/project/loaders.d.ts +71 -0
  188. package/dist/project/loaders.js +300 -0
  189. package/dist/project/metadata.d.ts +8 -0
  190. package/dist/project/metadata.js +34 -0
  191. package/dist/project/module-exports.d.ts +29 -0
  192. package/dist/project/module-exports.js +77 -0
  193. package/dist/project/routes.d.ts +19 -0
  194. package/dist/project/routes.js +92 -0
  195. package/dist/project/routing.d.ts +46 -0
  196. package/dist/project/routing.js +280 -0
  197. package/dist/project/transform.d.ts +8 -0
  198. package/dist/project/transform.js +110 -0
  199. package/dist/project/webpack.d.ts +46 -0
  200. package/dist/project/webpack.js +160 -0
  201. package/dist/project.d.ts +264 -0
  202. package/dist/project.js +58 -0
  203. package/dist/registry-global.d.ts +5 -0
  204. package/dist/registry-global.js +5 -0
  205. package/dist/registry.d.ts +241 -0
  206. package/dist/registry.js +30 -0
  207. package/dist/route-chunks.d.ts +13 -0
  208. package/dist/route-chunks.js +32 -0
  209. package/dist/route-lookup.d.ts +34 -0
  210. package/dist/route-lookup.js +207 -0
  211. package/dist/routes-ahead-shared.d.ts +17 -0
  212. package/dist/routes-ahead-shared.js +9 -0
  213. package/dist/routes-ahead.d.ts +10 -0
  214. package/dist/routes-ahead.js +54 -0
  215. package/dist/rsc.d.ts +19 -0
  216. package/dist/rsc.js +171 -0
  217. package/dist/server-action.d.ts +9 -0
  218. package/dist/server-action.js +15 -0
  219. package/dist/server-code.d.ts +176 -0
  220. package/dist/server-code.js +357 -0
  221. package/dist/server-in-front.d.ts +37 -0
  222. package/dist/server-in-front.js +90 -0
  223. package/dist/server-layers.d.ts +22 -0
  224. package/dist/server-layers.js +33 -0
  225. package/dist/setup-browser.d.ts +1 -0
  226. package/dist/setup-browser.js +8 -0
  227. package/dist/setup-node.d.ts +1 -0
  228. package/dist/setup-node.js +6 -0
  229. package/dist/setup.d.ts +8 -0
  230. package/dist/setup.js +62 -0
  231. package/dist/speed-features.d.ts +13 -0
  232. package/dist/speed-features.js +95 -0
  233. package/dist/ssr.d.ts +70 -0
  234. package/dist/ssr.js +480 -0
  235. package/dist/static-build.d.ts +36 -0
  236. package/dist/static-build.js +92 -0
  237. package/dist/storage.d.ts +31 -0
  238. package/dist/storage.js +94 -0
  239. package/dist/styles-shared.d.ts +137 -0
  240. package/dist/styles-shared.js +124 -0
  241. package/dist/styles.d.ts +102 -0
  242. package/dist/styles.js +730 -0
  243. package/dist/stylesheet-versions.d.ts +17 -0
  244. package/dist/stylesheet-versions.js +43 -0
  245. package/dist/tester.html +10 -0
  246. package/dist/use-cache.d.ts +15 -0
  247. package/dist/use-cache.js +93 -0
  248. package/dist/vitest-version.d.ts +6 -0
  249. package/dist/vitest-version.js +12 -0
  250. package/package.json +125 -3
@@ -0,0 +1,33 @@
1
+ import "./globals.js";
2
+ import { createEnvironmentRunner, environmentModule } from "@kasperpeulen/vitest-plugin-rsc/internal/utils";
3
+ //#region src/server-layers.ts
4
+ /**
5
+ * The rsc layer: Server Components, Server Actions, route handlers and the
6
+ * Flight encoder, see rsc.ts. The document's own module graph.
7
+ */
8
+ function rscLayer() {
9
+ return import("./rsc.js");
10
+ }
11
+ let loading;
12
+ let loaded;
13
+ /**
14
+ * The ssr layer: Next's request handler and HTML renderer, see ssr.ts, with
15
+ * the rsc layer, which a request needs too. It starts to load the first time
16
+ * something asks for it: a request that the server handles, or the entry of
17
+ * the server's API as it evaluates. The server in front of the app needs
18
+ * neither layer: see server-in-front.ts. A build fetches the layer's file
19
+ * when its runner asks for it: see built-layers.ts.
20
+ */
21
+ function ssrLayer() {
22
+ if (!loading) {
23
+ loading = Promise.all([rscLayer(), createEnvironmentRunner("next_ssr").import(environmentModule("next_ssr", "@kasperpeulen/vitest-plugin-nextjs/ssr"))]).then(([, layer]) => loaded = layer);
24
+ loading.catch(() => {});
25
+ }
26
+ return loading;
27
+ }
28
+ /** The ssr layer once it has loaded: until then there is nothing of it to settle or reset. */
29
+ function loadedSsrLayer() {
30
+ return loaded;
31
+ }
32
+ //#endregion
33
+ export { loadedSsrLayer, rscLayer, ssrLayer };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,8 @@
1
+ import { findOnEveryChange } from "./speed-features.js";
2
+ import { setUpTestFiles } from "./setup.js";
3
+ import { page, server } from "vitest/browser";
4
+ //#region src/setup-browser.ts
5
+ await setUpTestFiles(server.config.setupFiles);
6
+ findOnEveryChange(page.getByText(""));
7
+ //#endregion
8
+ export {};
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,6 @@
1
+ import { setUpTestFiles } from "./setup.js";
2
+ import { inject } from "vitest";
3
+ //#region src/setup-node.ts
4
+ await setUpTestFiles(inject("vitest-plugin-rsc:setup-files"));
5
+ //#endregion
6
+ export {};
@@ -0,0 +1,8 @@
1
+ //#region src/setup.d.ts
2
+ /**
3
+ * The hooks of every test file, whose setup files are `setupFiles`, as the
4
+ * config of the run has them. Resolves once the ssr layer has loaded.
5
+ */
6
+ declare function setUpTestFiles(setupFiles: readonly string[]): Promise<void>;
7
+ //#endregion
8
+ export { setUpTestFiles };
package/dist/setup.js ADDED
@@ -0,0 +1,62 @@
1
+ import { registry } from "./registry.js";
2
+ import { pollOnEveryChange } from "./speed-features.js";
3
+ import { ssrLayer } from "./server-layers.js";
4
+ import { forgetClientFiles, linkStylesheetsOf, loadedAsClientFile } from "./client-graph.js";
5
+ import { leaveKeptAppWithPage, noRouter } from "./page.js";
6
+ import { keepHostDocument } from "./host-document.js";
7
+ import { cleanup, newBrowserContext } from "./index.js";
8
+ import { routesAheadEvent } from "./routes-ahead-shared.js";
9
+ import { askDevServer, forgetHeardVersions } from "@kasperpeulen/vitest-plugin-rsc/internal/utils";
10
+ import { afterAll, afterEach, beforeAll, beforeEach, expect, vi } from "vitest";
11
+ import "virtual:vitest-plugin-rsc/next-fast-crypto";
12
+ //#region src/setup.ts
13
+ /**
14
+ * The hooks of every test file, whose setup files are `setupFiles`, as the
15
+ * config of the run has them. Resolves once the ssr layer has loaded.
16
+ */
17
+ async function setUpTestFiles(setupFiles) {
18
+ forgetClientFiles();
19
+ forgetHeardVersions();
20
+ let nodeFiles = [...setupFiles];
21
+ registry.nodeFiles = () => nodeFiles;
22
+ let clientFile = false;
23
+ let keptDocument;
24
+ beforeAll(async ({}, suite) => {
25
+ nodeFiles = [...setupFiles, suite.file.filepath];
26
+ clientFile = loadedAsClientFile(suite.file.filepath);
27
+ if (clientFile) keptDocument = keepHostDocument((url) => reportError(noRouter(url)));
28
+ await linkStylesheetsOf(nodeFiles);
29
+ compileRoutesAhead(suite.file.filepath);
30
+ }, 0);
31
+ afterAll(async () => {
32
+ try {
33
+ await leaveKeptAppWithPage("the end of the test file");
34
+ } finally {
35
+ keptDocument?.();
36
+ }
37
+ });
38
+ await ssrLayer();
39
+ afterEach(() => cleanup());
40
+ beforeEach(async () => {
41
+ await (clientFile ? cleanup() : newBrowserContext());
42
+ await linkStylesheetsOf(nodeFiles);
43
+ });
44
+ pollOnEveryChange(expect, () => vi.isFakeTimers());
45
+ }
46
+ function compileRoutesAhead(testFile) {
47
+ const tell = (news) => {
48
+ askDevServer(routesAheadEvent, news).catch(() => {});
49
+ };
50
+ tell({ testFile });
51
+ const opened = /* @__PURE__ */ new Set();
52
+ registry.routeOpened = (entry) => {
53
+ if (opened.has(entry)) return;
54
+ opened.add(entry);
55
+ tell({
56
+ testFile,
57
+ opened: entry
58
+ });
59
+ };
60
+ }
61
+ //#endregion
62
+ export { setUpTestFiles };
@@ -0,0 +1,13 @@
1
+ import { SpeedFeature } from "./mode.js";
2
+
3
+ //#region src/speed-features.d.ts
4
+ /** Whether a speed feature is on in the page. */
5
+ declare function speedFeature(feature: SpeedFeature): boolean;
6
+ /** With `watchDom`, has `locator` (a Locator of `vitest/browser`) look on every change of the document. */
7
+ declare function findOnEveryChange(locator: object): void;
8
+ /** With `watchDom`, has `expect.poll()`, and so `expect.element()`, look again on the next change of the document. */
9
+ declare function pollOnEveryChange(expect: {
10
+ poll?: unknown;
11
+ }, fakeTimers: () => boolean): void;
12
+ //#endregion
13
+ export { findOnEveryChange, pollOnEveryChange, speedFeature };
@@ -0,0 +1,95 @@
1
+ import { registry } from "./registry.js";
2
+ //#region src/speed-features.ts
3
+ /** Whether a speed feature is on in the page. */
4
+ function speedFeature(feature) {
5
+ return registry.speedFeatures?.[feature] === true;
6
+ }
7
+ const findInterval = 5;
8
+ const setTimeout = globalThis.setTimeout;
9
+ const clearTimeout = globalThis.clearTimeout;
10
+ const changeEvents = [
11
+ "input",
12
+ "change",
13
+ "focusin",
14
+ "focusout",
15
+ "load",
16
+ "error",
17
+ "transitionend",
18
+ "animationend"
19
+ ];
20
+ const observed = {
21
+ subtree: true,
22
+ childList: true,
23
+ attributes: true,
24
+ characterData: true
25
+ };
26
+ /**
27
+ * Resolves on the next change of the document from now on: a mutation of the
28
+ * DOM, one of `changeEvents`, or `findInterval` for what changes without
29
+ * either, like a value that a script sets.
30
+ */
31
+ function nextChange() {
32
+ return new Promise((resolve) => {
33
+ const done = () => {
34
+ observer.disconnect();
35
+ clearTimeout(timer);
36
+ for (const type of changeEvents) document.removeEventListener(type, done, true);
37
+ resolve();
38
+ };
39
+ const observer = new MutationObserver(done);
40
+ observer.observe(document, observed);
41
+ for (const type of changeEvents) document.addEventListener(type, done, true);
42
+ const timer = setTimeout(done, findInterval);
43
+ });
44
+ }
45
+ const onEveryChange = Symbol.for("vitest-plugin-rsc:find-on-every-change");
46
+ /** With `watchDom`, has `locator` (a Locator of `vitest/browser`) look on every change of the document. */
47
+ function findOnEveryChange(locator) {
48
+ if (!speedFeature("watchDom")) return;
49
+ let proto = Object.getPrototypeOf(locator);
50
+ while (proto && !Object.prototype.hasOwnProperty.call(proto, "findElement")) proto = Object.getPrototypeOf(proto);
51
+ if (!proto || typeof proto.findElement !== "function" || onEveryChange in proto.findElement) return;
52
+ const vitests = proto.findElement;
53
+ const vitest = () => globalThis.__vitest_browser_runner__;
54
+ async function find(options = {}) {
55
+ const strict = options.strict ?? true;
56
+ const timeout = options.timeout ?? vitest()?.runner?._deadline?.derive() ?? 6e4;
57
+ const start = performance.now();
58
+ for (;;) {
59
+ const elements = this.elements();
60
+ if (elements.length === 1 || elements.length > 1 && !strict) return elements[0];
61
+ if (elements.length > 1 || performance.now() - start >= timeout) return vitests.call(this, {
62
+ ...options,
63
+ timeout: 0
64
+ });
65
+ await nextChange();
66
+ }
67
+ }
68
+ proto.findElement = Object.assign(find, { [onEveryChange]: true });
69
+ }
70
+ const pollsOnEveryChange = Symbol.for("vitest-plugin-rsc:poll-on-every-change");
71
+ /** With `watchDom`, has `expect.poll()`, and so `expect.element()`, look again on the next change of the document. */
72
+ function pollOnEveryChange(expect, fakeTimers) {
73
+ if (!speedFeature("watchDom")) return;
74
+ const vitests = expect.poll;
75
+ if (typeof vitests !== "function" || pollsOnEveryChange in vitests) return;
76
+ function poll(fn, options) {
77
+ if (options?.interval !== void 0 || fakeTimers()) return vitests.call(this, fn, options);
78
+ let changed;
79
+ async function polled(...args) {
80
+ if (changed) await changed;
81
+ try {
82
+ return await fn.apply(this, args);
83
+ } finally {
84
+ changed = nextChange();
85
+ }
86
+ }
87
+ return vitests.call(this, polled, {
88
+ ...options,
89
+ interval: 0
90
+ });
91
+ }
92
+ expect.poll = Object.assign(poll, { [pollsOnEveryChange]: true });
93
+ }
94
+ //#endregion
95
+ export { findOnEveryChange, pollOnEveryChange, speedFeature };
package/dist/ssr.d.ts ADDED
@@ -0,0 +1,70 @@
1
+ import { Opened, ServerRequest } from "./registry.js";
2
+ import { resetCaches } from "./cache.js";
3
+
4
+ //#region src/ssr.d.ts
5
+ declare namespace ssr_d_exports {
6
+ export { HandleOptions, ShellErrorAnswer, handleRequest, resetCaches, settleRequests, shellErrorAnswer };
7
+ }
8
+ type HandleOptions = {
9
+ /**
10
+ * For a request the server makes to itself while it handles one, which
11
+ * cannot wait for that one to finish.
12
+ */
13
+ nested?: boolean;
14
+ /**
15
+ * What a request gets that the server has nothing for: no route, and no
16
+ * redirect or rewrite, after the middleware has let it through. The
17
+ * not-found page of the app, or with `"pass"` no response: a deployment
18
+ * looks for a file then, which here is the network's to answer.
19
+ */
20
+ unrouted?: "not-found" | "pass";
21
+ /**
22
+ * What the request opens, in place of what `renderServer()` opened: the
23
+ * route of a node of its own, for this request only, or with `null`
24
+ * nothing.
25
+ */
26
+ opened?: Opened | null;
27
+ /**
28
+ * Whether the request loads a page into the document, which starts the
29
+ * files of its route as the server renders it: see `preloadRoute()` of the
30
+ * registry.
31
+ */
32
+ pageLoad?: boolean;
33
+ };
34
+ /** The Next.js server of this app. Without a response only with `unrouted: "pass"`. */
35
+ declare function handleRequest(request: ServerRequest, options?: HandleOptions & {
36
+ unrouted?: "not-found";
37
+ }): Promise<Response>;
38
+ declare function handleRequest(request: ServerRequest, options: HandleOptions): Promise<Response | undefined>;
39
+ /** How the server answers the document of a page whose render failed: see `shellErrorAnswer()`. */
40
+ type ShellErrorAnswer = {
41
+ status: number;
42
+ location?: string;
43
+ };
44
+ /**
45
+ * How Next's server answers the document of a page when an error fails the
46
+ * render of its HTML before any of it is out, by the digest of the error, as
47
+ * Next's renderer does in the `catch` of `renderToStream()` (app-render.js):
48
+ * the status of a `notFound()`, `forbidden()` or `unauthorized()`, the 307 or
49
+ * 308 of a `redirect()` and where it goes, without the app's `basePath`, and
50
+ * 500 for any other error. For a page that the server renders no HTML of: see
51
+ * `renderFailureOf()` in page.ts.
52
+ */
53
+ declare function shellErrorAnswer(digest: string): ShellErrorAnswer;
54
+ /**
55
+ * Ends the requests the server is still handling, when a page is left.
56
+ *
57
+ * A request that has its answer is writing the body: a short wait, then a
58
+ * stop. A test can end while a page streams, on data that will never come.
59
+ *
60
+ * A request that has no answer yet runs code of the app, like a Server Action
61
+ * or a route handler, and nothing can stop that. So it is waited for, and
62
+ * then for the body it writes. So is what requests do after their response,
63
+ * like `after()`. What comes next is not to run while any of that still reads
64
+ * or sets the stores of a request, which would be the ones of the requests
65
+ * that come next. A request that is sent in the meantime waits for all of
66
+ * that, and is dropped: it is one of the page that was left.
67
+ */
68
+ declare function settleRequests(): Promise<void>;
69
+ //#endregion
70
+ export { HandleOptions, ShellErrorAnswer, handleRequest, resetCaches, settleRequests, shellErrorAnswer, ssr_d_exports };