@foliwake/next 0.3.0 → 0.5.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,51 @@ minor release may break; breaking changes are marked **BREAKING**.
7
7
 
8
8
  Entries are written from the changesets of each pull request (`.changeset/`, CONTRIBUTING.md), newest first.
9
9
 
10
+ ## 0.5.0
11
+
12
+ ### Patch Changes
13
+
14
+ - fa06260: The `homepage` of every package is its page on the public SDK documentation site,
15
+ `https://sdk.foliwake.dev/reference/packages/<name>`. No API change.
16
+ - Updated dependencies [fa06260]
17
+ - @foliwake/blocks-contract@0.5.0
18
+ - @foliwake/react@0.5.0
19
+ - @foliwake/server@0.5.0
20
+
21
+ ## 0.4.0
22
+
23
+ ### Minor Changes
24
+
25
+ - 70af3e5: **BREAKING**: the old forms are removed; only the current ones remain.
26
+
27
+ - The kit's only specifier is `@foliwake/block-kit`. The import map of a code release no longer maps
28
+ `foliwake`; `LEGACY_KIT_SPECIFIER` and `KIT_SPECIFIERS` are removed from `@foliwake/blocks-contract/import-map`
29
+ (use `KIT_SPECIFIER`). `@foliwake/site-check` refuses a bare `foliwake` import, preload hints follow only
30
+ `@foliwake/block-kit`, and new projects map only `@foliwake/block-kit` (jsconfig, Storybook).
31
+ - `@foliwake/block-kit/block-kit-1.js` (the kit of blocks contract 1) is removed, with its `exports` entry;
32
+ `@foliwake/site-check` no longer treats `_foliwake/block-kit-1.js` as an engine file, and the Storybook
33
+ starter no longer aliases relative `_foliwake/` imports.
34
+ - An origin answer without `X-Code-Release` is an error (`FoliwakePageError` `invalid`), not a body shown
35
+ without blocks. `codeRelease` of `PageEnvelope` and `FoliwakePageData` is `CodeReleaseId` (never null),
36
+ and the client error code `NO_CODE_RELEASE` is removed.
37
+ - A `foliwake.remote.json` with any `version` other than 2 is refused with one "unsupported version" error.
38
+
39
+ Added (not breaking): `defineBlock(name, setup, { autoReady: false })` in `@foliwake/block-kit`. The kit then
40
+ sends `ready` only when the block sends it (`ctx.emit('ready', …)`), so a setup that cannot run leaves the root
41
+ without `ready`. The default (`autoReady: true`) is unchanged: after a setup that did not send `ready`, the kit
42
+ sends it.
43
+
44
+ ### Patch Changes
45
+
46
+ - 1cc3743: Documentation: the READMEs name the kit's specifier `@foliwake/block-kit` everywhere, link to sibling
47
+ packages instead of guides that are not public, and say which features need the Foliwake CLI, which is not
48
+ public yet. The `@foliwake/next` README shows how to write the cached read yourself. The starters' loader comment names HTML contract 2. No API change.
49
+ - Updated dependencies [1cc3743]
50
+ - Updated dependencies [70af3e5]
51
+ - @foliwake/blocks-contract@0.4.0
52
+ - @foliwake/react@0.4.0
53
+ - @foliwake/server@0.4.0
54
+
10
55
  ## 0.3.0
11
56
 
12
57
  ### Minor Changes
package/README.md CHANGED
@@ -197,18 +197,37 @@ async function LessonBody({ params }: { params: Params }) {
197
197
  }
198
198
  ```
199
199
 
200
- `<FoliwakeImportMap>` renders the page's import map: blocks import the engine's block-kit as `foliwake`, and
201
- the map points that name at the kit of the page's own code release, scoped to the release's code path
200
+ `<FoliwakeImportMap>` renders the page's import map: blocks import the block kit as `@foliwake/block-kit`,
201
+ and the map points that name at the kit of the page's own code release, scoped to the release's code path
202
202
  (`<FoliwakeServerPage>` renders it for you). `@foliwake/client` adds the same map when it is missing. A map
203
203
  that arrives after the document's first module load (a client navigation to a page of another code release)
204
204
  is honoured only by browsers with multiple import maps (Chrome 133+); module hints are therefore `preload
205
- as="script"`, never `modulepreload`, which would resolve `foliwake` before the map is there. With the CSP
205
+ as="script"`, never `modulepreload`, which would resolve the kit's specifier before the map is there. With the CSP
206
206
  strategy `nonce`, pass the request's nonce to `<FoliwakeServerPage nonce>` / `<FoliwakeImportMap nonce>` and to
207
207
  `<FoliwakePage nonce>` (the map the client adds on a navigation).
208
208
 
209
209
  Unlike `<FoliwakeServerPage>`, `readPage` does not call `notFound()`: it throws `FoliwakePageError` (with
210
210
  `kind` `not_found`, `not_allowed`, `invalid`, …) for you to handle.
211
211
 
212
+ ### Write the cached read yourself
213
+
214
+ If Next does not compile the packaged cache (an unusual setup), write the cached live read in your app and
215
+ pass it to `<FoliwakeServerPage read={readLiveEnvelope}>`:
216
+
217
+ ```ts
218
+ // lib/foliwake.ts
219
+ import { cacheLife, cacheTag } from 'next/cache';
220
+ import { foliwakeConfig, foliwakeTags, originClient, readEnvelope } from '@foliwake/next';
221
+
222
+ export async function readLiveEnvelope(path: string) {
223
+ 'use cache';
224
+ cacheLife({ stale: 300, revalidate: 300, expire: 86400 });
225
+ cacheTag(...foliwakeTags('live', path));
226
+ const config = foliwakeConfig();
227
+ return readEnvelope(config, originClient(), config.site, 'live', path);
228
+ }
229
+ ```
230
+
212
231
  ## Compatibility
213
232
 
214
233
  | | |
@@ -216,7 +235,7 @@ Unlike `<FoliwakeServerPage>`, `readPage` does not call `notFound()`: it throws
216
235
  | Next.js | 16.2 or newer, below 17 (peer `>=16.2.0 <17`; tested with 16.2.12), App Router with `cacheComponents: true` |
217
236
  | React | 19.2 or newer (tested with 19.3.0) |
218
237
  | Node.js | 22.22 or newer |
219
- | Foliwake origin | sends `X-Code-Release` with `.plain.html` (plain/2); an older origin gives pages without blocks |
238
+ | Foliwake origin | plain/2: `X-Code-Release` with every `.plain.html` (a body without it is refused) |
220
239
  | Config | `foliwake.remote.json` version 2 |
221
240
 
222
241
  Changes per version, breaking ones marked: `CHANGELOG.md` in the package
@@ -226,7 +245,7 @@ Changes per version, breaking ones marked: `CHANGELOG.md` in the package
226
245
 
227
246
  - `withFoliwake` adds `@foliwake/next` to `transpilePackages`: Next compiles `'use cache'` only in code it
228
247
  transpiles. If you do not use `withFoliwake`, add it yourself, or write the cached read in your app and pass
229
- it as `read` (the guide shows how).
248
+ it as `read` (see "Write the cached read yourself" above).
230
249
  - Under partial prerendering the status line is sent with the static shell, so a not-found page answers HTTP
231
250
  200 with the not-found content.
232
251
  - The server modules import `server-only`, which throws when imported outside React Server Components. In unit
@@ -238,11 +257,12 @@ Changes per version, breaking ones marked: `CHANGELOG.md` in the package
238
257
  without reading `components.json`, so blocks without a stylesheet produce 404 links. See the
239
258
  `@foliwake/react` notes for the workaround with `page.preload`.
240
259
 
241
- ## Guides
260
+ ## See also
242
261
 
243
- - [Embed Foliwake pages in a React or Next app](https://docs.foliwake.dev/guide/embed-in-react): the whole
244
- setup step by step, the config keys, caching and troubleshooting.
245
- - [Roll out frontend code](https://docs.foliwake.dev/guide/code-rollout)
262
+ - [`@foliwake/server`](https://www.npmjs.com/package/@foliwake/server): every key of `foliwake.remote.json`,
263
+ the proxies and the body check.
264
+ - [`@foliwake/react`](https://www.npmjs.com/package/@foliwake/react): `<FoliwakePage>`, the host and events.
265
+ - [`@foliwake/client`](https://www.npmjs.com/package/@foliwake/client): the browser lifecycle under both.
246
266
 
247
267
  License: Apache-2.0.
248
268
 
@@ -260,7 +280,7 @@ License: Apache-2.0.
260
280
 
261
281
  #### `emitPreloadHints()`
262
282
 
263
- Emits the page's hints into the document head (React DOM resource APIs; deduplicated by React). Modules are hinted as `preload as="script"` (the bytes, fetched in parallel), not `modulepreload`: a module preloaded before the page's import map is in the document fails to resolve `foliwake` for good, and in a Next app the hints reach &lt;head&gt; before the map (which renders with the page, and on a client navigation arrives later).
283
+ Emits the page's hints into the document head (React DOM resource APIs; deduplicated by React). Modules are hinted as `preload as="script"` (the bytes, fetched in parallel), not `modulepreload`: a module preloaded before the page's import map is in the document fails to resolve the kit's specifier for good, and in a Next app the hints reach &lt;head&gt; before the map (which renders with the page, and on a client navigation arrives later).
264
284
 
265
285
  ```ts
266
286
  function emitPreloadHints(page: FoliwakePageData): void
@@ -280,7 +300,7 @@ function foliwakeConfig(): FoliwakeAppConfig
280
300
 
281
301
  #### `FoliwakeImportMap()`
282
302
 
283
- The import map of the page's code release (`foliwake` → its block-kit, scoped to the release's code path), as an element to render before the page's blocks load; null for a page without a code release. Browsers honour a map that arrives after the document's first module load (client navigation, a second release) only with multiple import maps (Chrome 133+); `@foliwake/client` adds the same map when it is missing.
303
+ The import map of the page's code release (`@foliwake/block-kit` → its block-kit, scoped to the release's code path), as an element to render before the page's blocks load; null for a page without a code release. Browsers honour a map that arrives after the document's first module load (client navigation, a second release) only with multiple import maps (Chrome 133+); `@foliwake/client` adds the same map when it is missing.
284
304
 
285
305
  ```ts
286
306
  function FoliwakeImportMap({ page, nonce }: {
package/dist/page.d.ts CHANGED
@@ -16,8 +16,9 @@ export declare function readPage(path: string, opts?: ReadPageOptions): Promise<
16
16
  /**
17
17
  * Emits the page's hints into the document head (React DOM resource APIs; deduplicated by React). Modules are
18
18
  * hinted as `preload as="script"` (the bytes, fetched in parallel), not `modulepreload`: a module preloaded
19
- * before the page's import map is in the document fails to resolve `foliwake` for good, and in a Next app the
20
- * hints reach <head> before the map (which renders with the page, and on a client navigation arrives later).
19
+ * before the page's import map is in the document fails to resolve the kit's specifier for good, and in a Next
20
+ * app the hints reach <head> before the map (which renders with the page, and on a client navigation arrives
21
+ * later).
21
22
  */
22
23
  export declare function emitPreloadHints(page: FoliwakePageData): void;
23
24
  /** Props of `<FoliwakeServerPage>`. */
@@ -41,10 +42,10 @@ export interface FoliwakeServerPageProps {
41
42
  render: (page: FoliwakePageData) => ReactNode;
42
43
  }
43
44
  /**
44
- * The import map of the page's code release (`foliwake` → its block-kit, scoped to the release's code path), as
45
- * an element to render before the page's blocks load; null for a page without a code release. Browsers honour a
46
- * map that arrives after the document's first module load (client navigation, a second release) only with
47
- * multiple import maps (Chrome 133+); `@foliwake/client` adds the same map when it is missing.
45
+ * The import map of the page's code release (`@foliwake/block-kit` → its block-kit, scoped to the release's code
46
+ * path), as an element to render before the page's blocks load; null for a page without a code release.
47
+ * Browsers honour a map that arrives after the document's first module load (client navigation, a second
48
+ * release) only with multiple import maps (Chrome 133+); `@foliwake/client` adds the same map when it is missing.
48
49
  */
49
50
  export declare function FoliwakeImportMap({ page, nonce }: {
50
51
  page: FoliwakePageData;
package/dist/page.js CHANGED
@@ -31,8 +31,9 @@ export async function readPage(path, opts = {}) {
31
31
  /**
32
32
  * Emits the page's hints into the document head (React DOM resource APIs; deduplicated by React). Modules are
33
33
  * hinted as `preload as="script"` (the bytes, fetched in parallel), not `modulepreload`: a module preloaded
34
- * before the page's import map is in the document fails to resolve `foliwake` for good, and in a Next app the
35
- * hints reach <head> before the map (which renders with the page, and on a client navigation arrives later).
34
+ * before the page's import map is in the document fails to resolve the kit's specifier for good, and in a Next
35
+ * app the hints reach <head> before the map (which renders with the page, and on a client navigation arrives
36
+ * later).
36
37
  */
37
38
  export function emitPreloadHints(page) {
38
39
  for (const hint of page.preload) {
@@ -43,10 +44,10 @@ export function emitPreloadHints(page) {
43
44
  }
44
45
  }
45
46
  /**
46
- * The import map of the page's code release (`foliwake` → its block-kit, scoped to the release's code path), as
47
- * an element to render before the page's blocks load; null for a page without a code release. Browsers honour a
48
- * map that arrives after the document's first module load (client navigation, a second release) only with
49
- * multiple import maps (Chrome 133+); `@foliwake/client` adds the same map when it is missing.
47
+ * The import map of the page's code release (`@foliwake/block-kit` → its block-kit, scoped to the release's code
48
+ * path), as an element to render before the page's blocks load; null for a page without a code release.
49
+ * Browsers honour a map that arrives after the document's first module load (client navigation, a second
50
+ * release) only with multiple import maps (Chrome 133+); `@foliwake/client` adds the same map when it is missing.
50
51
  */
51
52
  export function FoliwakeImportMap({ page, nonce }) {
52
53
  const text = pageImportMap(page);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foliwake/next",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Next.js App Router adapter for Foliwake pages: withFoliwake, cached envelope read, <FoliwakeServerPage>, preview pages, code and media route handlers, CSP header.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -10,7 +10,7 @@
10
10
  "url": "git+https://github.com/foliwake/foliwake-js.git",
11
11
  "directory": "packages/next"
12
12
  },
13
- "homepage": "https://docs.foliwake.dev/reference/packages/next",
13
+ "homepage": "https://sdk.foliwake.dev/reference/packages/next",
14
14
  "bugs": {
15
15
  "url": "https://github.com/foliwake/foliwake-js/issues"
16
16
  },
@@ -61,9 +61,9 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "server-only": "0.0.1",
64
- "@foliwake/blocks-contract": "0.3.0",
65
- "@foliwake/react": "0.3.0",
66
- "@foliwake/server": "0.3.0"
64
+ "@foliwake/blocks-contract": "0.5.0",
65
+ "@foliwake/react": "0.5.0",
66
+ "@foliwake/server": "0.5.0"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "next": ">=16.2.0 <17",