@pracht/adapter-static 0.1.4 → 0.2.1

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/dist/index.d.mts CHANGED
@@ -35,6 +35,11 @@ declare function createStaticServerEntryModule(options?: StaticAdapterOptions):
35
35
  * anything that needs a server: `render: "ssr"` / `"isg"` routes, SPA
36
36
  * loaders, request middleware, API routes, and network-exposed capabilities.
37
37
  * SSG loaders run at build time; static SPA routes are loaderless.
38
+ *
39
+ * The `notFound` page may use `hydration: "islands"` or `"none"` to keep the
40
+ * client router out of `404.html`, at the cost of the page knowing which URL
41
+ * was requested. Configuring `fallback` requires full hydration there, because
42
+ * that document is built from the not-found page's serialized route state.
38
43
  */
39
44
  declare function staticAdapter(options?: StaticAdapterOptions): PrachtAdapter;
40
45
  //#endregion
package/dist/index.mjs CHANGED
@@ -42,6 +42,17 @@ function createStaticServerEntryModule(options = {}) {
42
42
  "// convention). Returns null when the app declares none.",
43
43
  "export async function renderStaticNotFoundHtml() {",
44
44
  " if (!resolvedApp.notFound) return null;",
45
+ " // Work the page registers with `waitUntil()` finishes before the build",
46
+ " // moves on; each task arrives guarded, so none of them reject.",
47
+ " const backgroundWork = [];",
48
+ " try {",
49
+ " return await renderNotFoundDocument((task) => backgroundWork.push(task));",
50
+ " } finally {",
51
+ " while (backgroundWork.length > 0) await Promise.allSettled(backgroundWork.splice(0));",
52
+ " }",
53
+ "}",
54
+ "",
55
+ "async function renderNotFoundDocument(waitUntil) {",
45
56
  " let renderError;",
46
57
  " const response = await handlePrachtRequest({",
47
58
  " app: staticNotFoundApp,",
@@ -53,7 +64,12 @@ function createStaticServerEntryModule(options = {}) {
53
64
  " cssManifest,",
54
65
  " cssContentManifest,",
55
66
  " jsManifest,",
56
- " onRouteError: (error) => {",
67
+ " waitUntil,",
68
+ " onRouteError: (error, requestPath, context) => {",
69
+ " if (context?.phase === \"waitUntil\") {",
70
+ " console.error(`[pracht] waitUntil error at ${requestPath}:`, error);",
71
+ " return;",
72
+ " }",
57
73
  " renderError = error;",
58
74
  " },",
59
75
  " });",
@@ -112,6 +128,11 @@ function createStaticServerEntryModule(options = {}) {
112
128
  * anything that needs a server: `render: "ssr"` / `"isg"` routes, SPA
113
129
  * loaders, request middleware, API routes, and network-exposed capabilities.
114
130
  * SSG loaders run at build time; static SPA routes are loaderless.
131
+ *
132
+ * The `notFound` page may use `hydration: "islands"` or `"none"` to keep the
133
+ * client router out of `404.html`, at the cost of the page knowing which URL
134
+ * was requested. Configuring `fallback` requires full hydration there, because
135
+ * that document is built from the not-found page's serialized route state.
115
136
  */
116
137
  function staticAdapter(options = {}) {
117
138
  assertValidStaticAdapterOptions(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pracht/adapter-static",
3
- "version": "0.1.4",
3
+ "version": "0.2.1",
4
4
  "description": "Static-export adapter for Pracht: prerender every route and deploy dist/client to any static host with zero server.",
5
5
  "keywords": [
6
6
  "pracht",
@@ -39,8 +39,8 @@
39
39
  "provenance": true
40
40
  },
41
41
  "dependencies": {
42
- "@pracht/adapter-node": "0.4.4",
43
- "@pracht/core": "0.18.0"
42
+ "@pracht/adapter-node": "^0.5.1",
43
+ "@pracht/core": "^0.20.0"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "tsdown"