@akanjs/devkit 3.2.0-rc.16 → 3.2.0-rc.18

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
@@ -121,6 +121,21 @@
121
121
  - **`internal`, `adaptor` and `plugs`** join `AkanGraphNodeKind` and `AkanGraphEdgeKind` in `akanjs/common`.
122
122
  - **`FileFacts.internals` and `FileFacts.adaptors`** in `@akanjs/language`, with `ServiceClassFact.plugs`; `AkanIndex.setFile` also reads non-test files that call `adapt` or `dangerouslyAdapt`.
123
123
 
124
+ - 882e976: The Akan Graph takes a lib's named re-export of a package class only along the chain it walks from the plug's import path, the same chain its `export *` walk follows. The forms it reads are `export { Stripe } from "stripe-sdk"`, `export { default as PayPal } from "paypal-sdk"` and `import { TossClient } from "toss-sdk"; export { TossClient as Toss }`. A plug `Stripe` imported from `@libs/shared/srvkit` follows that folder's index and the modules the index exports. It also follows a relative named re-export (`export { Wise } from "./vendors/wise"`) and an `export *` into another folder or lib (`export * from "../common/square"`, `export * from "@libs/util/srvkit"`). A re-export the chain does not reach no longer claims the plug. Examples are `libs/shared/webkit/stray.ts`, a file in a subfolder whose committed index does not export it, and `srvkit/stripe.helper.ts`, which the generated barrel skips.
125
+
126
+ A facet folder (`ui`, `webkit`, `srvkit`, `common`, `plugin`) with no index on disk is read as the barrel `akan sync` writes. The generated barrels are gitignored, so this is every facet in a Change Map. As a result, a plug gets the same id in the graph view and in the Change Map, with or without `akan sync`. The folder scans that stood in for a missing barrel are gone. The barrel rule (which files and folders, the naming rule, and Biome's sort order) now lives in `akanjs/common` as `facetBarrelOf`, `facetBarrelNamesOf`, `compareExportNames` and `barrelFacetDirs`. The facet index template, the dev server's index sync and the graph all share it, and `akan sync` writes the same bytes as before.
127
+
128
+ A package `export *` on the chain is refused only for a name that a module along the chain declares. A declaration elsewhere in the imported lib no longer blocks it. Two re-exports that name the same package through different paths (`"stripe-sdk"`, `"stripe-sdk/server"`) are one adaptor. Guards still find a named re-export anywhere in the lib, as before. A guard reached through an `export *` reads a missing facet barrel the same way, so the Change Map locates `guard:libs/util:Admin` behind `libs/shared/srvkit/util.ts: export * from "@libs/util/srvkit"` as the graph view does.
129
+
130
+ Ids that change for a saved graph or a Change Map base:
131
+
132
+ - In a Change Map, a guard reached through an `export *` in a facet folder with no index is the guard the graph view links, where it was the unlocated `guard:<lib>:<Name>`.
133
+ - A plug whose name the lib re-exports from a package only off the import's chain is the unlocated `adaptor:<lib>:<Name>`, where it was `adaptor:<that package>:<Name>`.
134
+ - A plug reached through a relative named re-export, or through an `export *` into another lib, is `adaptor:<package>:<Name>` where it could be the unlocated `adaptor:<lib>:<Name>`.
135
+ - A plug whose name two modules along the chain re-export from different packages is the unlocated `adaptor:<lib>:<Name>`, as TypeScript drops a name two `export *` share, where it was the first file's package.
136
+ - A plug a chain's sole package `export *` reaches is `adaptor:<package>:<Name>` even when the lib declares `<Name>` off the chain, where it was the unlocated `adaptor:<lib>:<Name>`.
137
+ - An owner can have several same-name adaptors. With no index in the import's facet folder, a plug of one of them follows the generated barrel. It used to take the first adaptor under the folder. Through an import path that is neither a module nor a facet folder, the plug is the unlocated `adaptor:<owner>:<Name>`, where it was the first adaptor.
138
+
124
139
  - bb40785: The Akan Graph maps `page/`. Each route file is a `route` node named by its URL pattern after the locale (`route:apps/demo:/memo/:memoId`, groups dropped as the router drops them), and each `_layout.tsx` is a `layout` node keyed by its folder (`layout:apps/demo:/(app)`, `root` for a `rootLayout()`). A `wraps` edge runs from each layout to the routes and layouts directly inside it, located at the wrapped file. A route or layout whose default export runs `.guard()` reads `guard` and links each function its guard calls that the file imports or declares: `.guard(() => signedIn())` reaches `signedIn` in `@libs/shared/webkit`, with its location and the comment above it, and a function declared in the page itself is keyed by that file (`guard:apps/demo:page/pin.tsx#isOwn`). A call to anything else (`Boolean`, akanjs's `redirect`, a package's `dayjs`) is looked through, a helper handed to a guard (`isOwn(isId(id))`) is not a guard, and an imported guard is looked up under its import path first. A layout's guard gates every route it wraps; the routes themselves do not repeat it, so a guard added to a layout marks only that layout changed in the Change Map. A route's default export, or the const it names (`const route = page()…; export default route`), is the route node itself, so the slices and actions a page uses hang off its URL. `_overrides.tsx` and the git-ignored `page/(libs)/` links are left out; a lib's own pages are its routes. A route's digest covers its whole file, so the Change Map marks an edited page changed instead of listing it as unmapped.
125
140
 
126
141
  An unscoped `get_graph` still answers a graph of up to 600 nodes whole. Past that, it first drops the routes and layouts that neither changed nor use a change, and the route-only guards they leave unlinked, before it asks for a scope; an `app` or `module` scope brings them back. Studio's first column reads "Pages & components".
@@ -215,6 +230,7 @@
215
230
  - **Git.** When git has no identity configured, as in many containers and CI images, the first commit is made as `Akan.js <noreply@akanjs.com>` instead of failing; once `user.name` and `user.email` are set, `git commit --amend --reset-author` makes it yours. In a folder another git repository tracks, the scaffold no longer runs `git init`, which made the outer repository record a gitlink instead of the files, and it commits nothing there: the new files are left for you to commit in that repository. A folder that repository ignores, as `app/` or `app/*` does, still gets its own repository and commit.
216
231
  - **`@akanjs/devkit`**: `applyTemplate` takes `dryRun` to list the files a template would write without writing them, and `WorkspaceExecutor.commit` takes an `identity` to commit under.
217
232
 
233
+ - 82d62b1: A CSR bundle and each MCP App view no longer carry the route-level boundary, which only a server render draws. The generated root layout's `LevelBoundary` export is now undefined in a CSR build, which MCP App views share, so their `import * as root` of the layout no longer keeps it. In `akan build minimal --fast` each MCP App view and the CSR `index.html` are about 0.45KB smaller raw. A server render is unchanged.
218
234
  - 1870fcd: `akan verify` adds a `fix:` line to a module file's two-parent import that names the layer barrel to import from instead, such as `import from "@apps/<app>/common"`. The lint message itself now points at the layer barrel too.
219
235
  - 5691327: `setErrorConstructor` on `FetchClient`, `HttpClient` and `WsClient`, `HttpClientOptions.ErrorCls` and `FetchClient.build`'s `Err` option are deprecated. Every dictionary's `Err` is `akanjs/common`'s `Err`, which a restored error already is, so they change nothing. They keep working. A generated `lib/sig.ts` no longer calls `fetch.setErrorConstructor(Err)`, and a generated `lib/useClient.ts` no longer passes `{ Err: pageProto.Err }`; `akan sync` rewrites both. No upgrade step is needed.
220
236
  - 7c39aea: The 82 source files at the root of `@akanjs/devkit` now sit in folders by concern:
@@ -292,6 +308,17 @@
292
308
  - b101fcf: `akan remove-application`, `remove-library`, `remove-package`, `remove-module` and `remove-scalar` no longer delete a target they picked themselves. Left out, or named but not in the workspace, the target is refused in a terminal or not, with the choices and the line to rerun, such as `` Missing app: this command deletes files and never picks its target, so rerun it as `akan remove-application <app>` (choices: pokedex). `` Before, `akan remove-application` in a one-app workspace removed `apps/<app>` without asking, and without a terminal `akan remove-scalar <name>` removed the scalar from the only app or lib. A terminal is no longer offered a select for these commands. Other commands still take the only app, or the only app or lib without a terminal, as before. A command declares this with `destructive: true` on its target.
293
309
  - 44149b1: `akan remove-module` now removes a service module named exactly, as in `akan remove-module pokedex:_billing` for `apps/pokedex/lib/_billing`. Before, no command could remove a service module: `remove-module` left out every `lib/_<name>` folder and refused one by name with `Invalid module name: _billing`. A service module left out or misnamed gets the same refusal as any target of a remove command, and its choices now list the service modules. `create-view`, `create-unit`, `create-template` and `create-crud-page` still take only a model module. A command opts in to service modules by taking `ModuleOrService` instead of `Module`.
294
310
  - 4fcf44f: A new `rename-key` workflow renames a slice key or a Filter query key everywhere it is spelled. That covers the key itself, every name derived from it (`initMemoInPublic`, `memoListInPublic`, `queryByName`) in the app and every lib, and its module dictionary entry. It is the same rename the editor extension's F2 runs, so agents get it through `plan_workflow` / `apply_workflow` and the CLI through `akan workflow plan rename-key --app <app> --module <module> --slice <key> --to <newKey>` (or `--query <key>`). The plan lists each file it will change. A use that could also be another model's is left alone, and `akan verify` then reports it.
311
+ - 9a2a8c9: The build refuses a `LevelBoundary` or `McpAppRoot` export on an app's root layout: `page/_layout.tsx`, or a grouped or base-path root layout. Akan.js defines both on the root layout it generates and reads neither from an app's layout, so such an export was silently ignored. The error names the export and the file and says why. Remove the export; it never took effect.
312
+
313
+ `akanjs/common` exports `GENERATED_ROOT_LAYOUT_EXPORTS`, the set of those names.
314
+
315
+ - 9a2a8c9: A root layout whose own route level fails after the page has started streaming now draws the route-level notice ("This page could not be loaded." with "Try again") instead of blanking the page. That covers an app's `page/_layout.tsx`, or a grouped root layout, that fails below its own `.loading()`, and a component in it that suspends and then fails.
316
+
317
+ - The generated root layout renders the boundary inside `System.Provider`, around the app's root layout. The provider stays, with the bridge that starts the router, so "Try again" refreshes the page. The notice takes the place of the whole root layout, its header and navigation included.
318
+ - Only a server render gets it. A CSR bundle renders the root layout as before, and an MCP App view does not render the root layout's body.
319
+ - A failure before the first byte is answered as before, since the server runs no error boundary. So is a redirect or not-found the root layout raises; after the first byte the boundary draws no notice for one.
320
+ - The page's markup and its `useId` values are unchanged. Its inline payload gains one wrapper.
321
+
295
322
  - 627dde4: The route JS budget stops failing deploy builds: a plain `akan build` reports an overage, `akan build --check-budget` fails on it, and CI runs that for `apps/minimal` and `apps/akan`, which now commit their `akan.budget.json`. The rc npm publish, which calls CI, skips that job, so an app's budget never holds a release.
296
323
 
297
324
  - **Report by default:** a plain `akan build`, the one a deploy runs, prints a route over its entry or with none, or an unreadable `akan.budget.json`, as a warning under the route table and passes, as `akan verify` does. `--quiet` drops the rest of the summary but still prints the warning.
@@ -316,7 +343,7 @@
316
343
  - af133d7: A route level whose server render fails after the page has started streaming now draws a notice ("This page could not be loaded.") with a "Try again" button in its own place, and the layouts above it stay. Before, the browser rethrew the error with no error boundary above it, so React unmounted the whole page (production error #441, a blank screen). That covered a page or layout below a `.loading()` that throws, and a fetch handle field that reaches no `Load.*` when the server refuses it: awaited in a component below the page, rendered as a child, or `use()`-d by a client component outside `Load.*`.
317
344
 
318
345
  - The generated root layout exports `LevelBoundary`, and server rendering puts it around every route level below that root layout, inside the level's Suspense. The notice is the one a failed level already draws in a CSR app. "Try again" calls `router.refresh()`, and the page's next payload renders the level again.
319
- - The root layout's own level and any `_overrides` level above it get no boundary: the root layout renders `System.Provider`, which starts the router, so a notice at or above it would have no router to retry with. The root level includes an app's `page/_layout.tsx`, and an error there after the first byte still blanks the page.
346
+ - The root layout's own level and any `_overrides` level above it get no boundary: the root layout renders `System.Provider`, which starts the router, so a notice at or above it would have no router to retry with. The generated root layout bounds its own content inside `System.Provider` instead.
320
347
  - A not-found or redirect raised below the route after the page started streaming renders nothing in that level's place, as the host answers it.
321
348
  - An error that fails a level before the first byte has left still gets the nearest layout's `.error()` and its status, since React's server renderer runs no error boundary. The page's markup is the same as before. Its inline payload gains the boundary's client reference and one wrapper per level, and its head gains a modulepreload for the boundary.
322
349
  - **Propagation change:** an error the server streamed now stops at the nearest route level. An error boundary an app put above a layout's `children` no longer sees it. An error thrown while the browser renders a client component carries no digest and propagates as before, so render bugs still surface.
@@ -507,6 +534,7 @@
507
534
  - Updated dependencies [0351ad4]
508
535
  - Updated dependencies [ba417c6]
509
536
  - Updated dependencies [485f707]
537
+ - Updated dependencies [882e976]
510
538
  - Updated dependencies [bb40785]
511
539
  - Updated dependencies [d2bd9b7]
512
540
  - Updated dependencies [b391491]
@@ -563,6 +591,7 @@
563
591
  - Updated dependencies [c0b84d0]
564
592
  - Updated dependencies [1f93507]
565
593
  - Updated dependencies [5d3cb3e]
594
+ - Updated dependencies [9a2a8c9]
566
595
  - Updated dependencies [9a9e1fa]
567
596
  - Updated dependencies [af133d7]
568
597
  - Updated dependencies [463fd1e]
@@ -20,6 +20,23 @@ describe("RouteSourceValidator", () => {
20
20
  expect(() => validate(source, "layout", true)).not.toThrow();
21
21
  });
22
22
 
23
+ test("refuses an export only the generated root layout defines on an app's root layout, which it would ignore", () => {
24
+ const layout = "export default function Layout({ children }) { return children; }";
25
+ for (const source of [
26
+ `${layout}\nexport const LevelBoundary = ({ children }) => children;`,
27
+ `${layout}\nexport { Boundary as LevelBoundary } from "./boundary";`,
28
+ `${layout}\nexport function McpAppRoot({ children }) { return children; }`,
29
+ ]) {
30
+ const name = source.includes("McpAppRoot") ? "McpAppRoot" : "LevelBoundary";
31
+ expect(() => validate(source, "layout", true)).toThrow(
32
+ `unsupported export "${name}" in page/_layout.tsx: ${name} belongs to the root layout Akan.js generates, which never reads one from an app's layout`,
33
+ );
34
+ expect(() => validate(source, "layout")).toThrow(
35
+ new RegExp(`unsupported export "${name}" in page/_layout\\.tsx$`),
36
+ );
37
+ }
38
+ });
39
+
23
40
  test("rejects root-layout-only exports on a nested layout and on a page", () => {
24
41
  const source = ["export default function Layout() { return null; }", "export const wsConnect = true;"].join("\n");
25
42
 
@@ -1,4 +1,4 @@
1
- import { getRouteExports } from "akanjs/common";
1
+ import { GENERATED_ROOT_LAYOUT_EXPORTS, getRouteExports } from "akanjs/common";
2
2
  import ts from "typescript";
3
3
 
4
4
  /** What the build needs out of a route module without evaluating it. */
@@ -43,6 +43,10 @@ export class RouteSourceValidator {
43
43
  const allowed = getRouteExports(kind, { rootLayout: options.rootLayout });
44
44
  const exported = new Set<string>();
45
45
  const assertExport = (name: string) => {
46
+ if (options.rootLayout && GENERATED_ROOT_LAYOUT_EXPORTS.has(name))
47
+ throw new Error(
48
+ `[route-convention] unsupported export "${name}" in ${filePath}: ${name} belongs to the root layout Akan.js generates, which never reads one from an app's layout`,
49
+ );
46
50
  if (!allowed.has(name)) {
47
51
  throw new Error(`[route-convention] unsupported export "${name}" in ${filePath}`);
48
52
  }
@@ -59,6 +59,68 @@ describe("resolveSsrPageEntries", () => {
59
59
  );
60
60
  });
61
61
 
62
+ test("bounds the System root layout's own content inside System.Provider, for a server render only", async () => {
63
+ const appRoot = await makeTempRoot();
64
+ await write(path.join(appRoot, "env", "env.client.ts"), "export const env = {};\n");
65
+ await write(
66
+ path.join(appRoot, "page", "_layout.tsx"),
67
+ "export default function Layout({ children }) { return children; }\n",
68
+ );
69
+ await write(
70
+ path.join(appRoot, "page", "(home)", "_layout.tsx"),
71
+ "export default function Layout({ children }) { return children; }\n",
72
+ );
73
+
74
+ const entries = await resolveSsrPageEntries({
75
+ appCwdPath: appRoot,
76
+ appName: "demo",
77
+ pageKeys: ["./_layout.tsx", "./(home)/_layout.tsx", "./(home)/_index.tsx"],
78
+ });
79
+
80
+ const source = await Bun.file(
81
+ entries.find((entry) => entry.key === "./__root_layout.tsx")?.moduleAbsPath ?? "",
82
+ ).text();
83
+ expect(source).toContain('import { RouteLevelBoundary } from "akanjs/webkit/RouteLevelBoundary.tsx";');
84
+ expect(source).toContain(
85
+ " const layout = <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>;\n return (\n <System.Provider",
86
+ );
87
+ expect(source).toContain(
88
+ ' >\n {process.env.AKAN_PUBLIC_RENDER_ENV === "csr" ? layout : <RouteLevelBoundary>{layout}</RouteLevelBoundary>}\n </System.Provider>',
89
+ );
90
+ expect(source.match(/<RouteLevelBoundary>/g)).toHaveLength(1);
91
+ expect(source.slice(source.indexOf("export function McpAppRoot"))).not.toContain("RouteLevelBoundary");
92
+
93
+ const nested = await Bun.file(
94
+ entries.find((entry) => entry.key === "./(home)/__root_layout.tsx")?.moduleAbsPath ?? "",
95
+ ).text();
96
+ expect(nested).not.toContain("RouteLevelBoundary");
97
+ });
98
+
99
+ test("leaves the boundary out of a CSR build, which an MCP App view's namespace import of the layout shares", async () => {
100
+ const appRoot = await makeTempRoot();
101
+ await write(path.join(appRoot, "env", "env.client.ts"), "export const env = {};\n");
102
+ await write(path.join(appRoot, "page", "_layout.tsx"), "export default ({ children }) => children;\n");
103
+ const entries = await resolveSsrPageEntries({
104
+ appCwdPath: appRoot,
105
+ appName: "demo",
106
+ pageKeys: ["./_layout.tsx", "./_index.tsx"],
107
+ });
108
+ const source = await Bun.file(
109
+ entries.find((entry) => entry.key === "./__root_layout.tsx")?.moduleAbsPath ?? "",
110
+ ).text();
111
+ const compiled = (renderEnv: "csr" | "ssr") =>
112
+ new Bun.Transpiler({
113
+ loader: "tsx",
114
+ define: { "process.env.AKAN_PUBLIC_RENDER_ENV": JSON.stringify(renderEnv) },
115
+ trimUnusedImports: true,
116
+ }).transformSync(source);
117
+
118
+ expect(compiled("csr")).toContain("export const LevelBoundary = undefined;");
119
+ expect(compiled("csr")).not.toMatch(/\bRouteLevelBoundary\b(?!\.tsx)/);
120
+ expect(compiled("ssr")).toContain("export const LevelBoundary = RouteLevelBoundary;");
121
+ expect(compiled("ssr")).toMatch(/import \{ ?RouteLevelBoundary ?\} from "akanjs\/webkit\/RouteLevelBoundary\.tsx"/);
122
+ });
123
+
62
124
  test("keeps system provider for grouped root boundaries without an ancestor root", async () => {
63
125
  const appRoot = await makeTempRoot();
64
126
  const pageRoot = path.join(appRoot, "page");
@@ -89,7 +151,7 @@ describe("resolveSsrPageEntries", () => {
89
151
  expect(generatedSource).toContain("export function McpAppRoot({ children, params, path }: McpAppRootProps) {");
90
152
  expect(generatedSource).toContain("<System.App");
91
153
  expect(generatedSource).toContain(
92
- 'export { RouteLevelBoundary as LevelBoundary } from "akanjs/webkit/RouteLevelBoundary.tsx";',
154
+ 'export const LevelBoundary = process.env.AKAN_PUBLIC_RENDER_ENV === "csr" ? undefined : RouteLevelBoundary;',
93
155
  );
94
156
  expect(generatedSource).toContain('import { allDictionary } from "../dict/useDict.ts";');
95
157
  expect(generatedSource).toContain(
@@ -174,7 +236,9 @@ describe("resolveSsrPageEntries", () => {
174
236
  expect(userSource).toContain('process.env.AKAN_PUBLIC_RENDER_ENV === "csr"');
175
237
  expect(userSource).toContain("? await UserLayout({ params, searchParams, children })");
176
238
  expect(userSource).toContain(": <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>;");
177
- expect(userSource).toContain(" {layout}\n </System.Provider>");
239
+ expect(userSource).toContain(
240
+ ' {process.env.AKAN_PUBLIC_RENDER_ENV === "csr" ? layout : <RouteLevelBoundary>{layout}</RouteLevelBoundary>}\n </System.Provider>',
241
+ );
178
242
 
179
243
  const signRoot = entries.find((entry) => entry.key === "./(sign)/__root_layout.tsx");
180
244
  const signSource = await Bun.file(signRoot?.moduleAbsPath ?? "").text();
@@ -182,7 +246,7 @@ describe("resolveSsrPageEntries", () => {
182
246
  expect(signSource).toContain("export default function GeneratedLayout(");
183
247
  expect(signSource).not.toContain("await UserLayout(");
184
248
  expect(signSource).toContain(
185
- " <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>\n </System.Provider>",
249
+ " const layout = <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>;\n",
186
250
  );
187
251
  });
188
252
 
@@ -199,8 +199,9 @@ async function writeGeneratedRootLayoutFile(opts: {
199
199
  ? await UserLayout({ params, searchParams, children })
200
200
  : ${userLayoutElement};
201
201
  `
202
- : "";
203
- const layoutChild = isAsyncUserLayout ? "{layout}" : userLayoutElement;
202
+ : opts.includeSystemProvider
203
+ ? ` const layout = ${userLayoutElement};\n`
204
+ : "";
204
205
  const layoutReturn = isAsyncUserLayout ? "layout" : userLayoutElement;
205
206
  //? Under an ancestor root boundary the route tree merges that root's head itself; merging it here would repeat it.
206
207
  const headLayouts = opts.includeSystemProvider ? "[inheritedLayout, userLayout]" : "[userLayout]";
@@ -225,12 +226,16 @@ ${layoutSignature}({ children, params, searchParams }: LayoutProps) {
225
226
  ${layoutBinding} return `;
226
227
  //? System from its file, not the barrel: a dev registry compiles every module the barrel names, and with them the
227
228
  //? optional peers (react-icons) an app drawing none of those components never installs.
229
+ //? The root level's boundary sits inside System.Provider, beside the bridge that starts the router its retry calls.
230
+ //? A CSR render has none: RenderLayer draws a failed level there, and a route control also carries a digest.
231
+ //? Its export is undefined there too, so the `import * as root` of an MCP App view, built as CSR, drops it.
228
232
  const source = opts.includeSystemProvider
229
233
  ? `import type { LayoutModule, LayoutProps, PageProps } from "akanjs/client";
230
234
  import { assertGuardOnChain, loadFonts, RouteGuards, resolveRouteModule, RouteHead } from "akanjs/client";
231
235
  import type { ReactNode } from "react";
232
236
  import { System } from "${ROOT_LAYOUT_SYSTEM.specifier}";
233
237
  import type { McpAppRootProps } from "akanjs/webkit";
238
+ import { RouteLevelBoundary } from "akanjs/webkit/RouteLevelBoundary.tsx";
234
239
  import { env } from "@apps/${opts.appName}/env/env.client";
235
240
  import { allDictionary } from ${JSON.stringify(dictMacroSpecifier)};
236
241
  ${storeImport}${inheritedImport}${userImport}
@@ -242,7 +247,7 @@ const defaultFontClassName = defaultFont ? (defaultFont.className ?? \`font-\${d
242
247
  export const theme = userLayout.theme ?? inheritedLayout.theme;
243
248
  export const viewport = userLayout.viewport ?? inheritedLayout.viewport;
244
249
  export const manifest = userLayout.manifest ?? inheritedLayout.manifest;
245
- export { RouteLevelBoundary as LevelBoundary } from "akanjs/webkit/RouteLevelBoundary.tsx";
250
+ export const LevelBoundary = process.env.AKAN_PUBLIC_RENDER_ENV === "csr" ? undefined : RouteLevelBoundary;
246
251
 
247
252
  ${layoutExports}(
248
253
  <System.Provider
@@ -260,7 +265,7 @@ ${layoutExports}(
260
265
  wsConnect={userLayout.wsConnect ?? inheritedLayout.wsConnect}
261
266
  allDictionary={process.env.AKAN_PUBLIC_RENDER_ENV === "ssr" ? allDictionary : undefined}
262
267
  >
263
- ${layoutChild}
268
+ {process.env.AKAN_PUBLIC_RENDER_ENV === "csr" ? layout : <RouteLevelBoundary>{layout}</RouteLevelBoundary>}
264
269
  </System.Provider>
265
270
  );
266
271
  }
@@ -0,0 +1,277 @@
1
+ import { describe, expect, spyOn, test } from "bun:test";
2
+ import { mkdir, readdir, symlink } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { Readable } from "node:stream";
5
+ import { act, Children, createElement, Fragment, isValidElement, type ReactElement, type ReactNode } from "react";
6
+ import { renderToReadableStream } from "react-dom/server.edge";
7
+ import { createFromNodeStream } from "react-server-dom-webpack/client.node";
8
+ import { PagesBundleBuilder } from "../frontendBuild/pagesBundleBuilder";
9
+ import { tempDirs, writeText as write } from "../test/testHelpers";
10
+ import { resolveSsrPageEntries } from "./implicitRootLayout";
11
+
12
+ Object.assign(process.env, {
13
+ AKAN_PUBLIC_APP_NAME: "demo",
14
+ AKAN_PUBLIC_REPO_NAME: "demo",
15
+ AKAN_PUBLIC_SERVE_DOMAIN: "localhost",
16
+ AKAN_PUBLIC_ENV: "testing",
17
+ AKAN_PUBLIC_OPERATION_MODE: "cloud",
18
+ });
19
+ const akanjsRoot = path.resolve(import.meta.dir, "../../../akanjs");
20
+ process.env.AKAN_RSC_WORKER_PATH = path.join(akanjsRoot, "server/rscWorker.tsx");
21
+ const { RscWorker } = await import("akanjs/server/rscWorkerHost.ts");
22
+ const { SsrFromRscRenderer } = await import("akanjs/server/ssrFromRscRenderer.tsx");
23
+ const { resetEnvCache } = await import("akanjs/base");
24
+ const { Logger } = await import("akanjs/common");
25
+ const { makePageProto, registerClientRuntime, router } = await import("akanjs/client");
26
+ //? What the app's client bundle registers in a browser; the hydrated System.Provider reads it.
27
+ const socket = { connect: () => undefined, connectOnUse: () => undefined };
28
+ registerClientRuntime({ ...makePageProto({ en: {} }), fetch: { instance: socket } } as never);
29
+
30
+ const makeTempRoot = tempDirs("akan-root-level-render-");
31
+ const boundedLayout = "<RouteLevelBoundary>{layout}</RouteLevelBoundary>";
32
+ const pageSource = 'import { page } from "akanjs/client";\nexport default page().render(() => <p>page</p>);\n';
33
+ const idsLayoutSource = `import { rootLayout } from "akanjs/client";
34
+ import { UsesId } from "../usesId";
35
+ export default rootLayout().render(({ children }) => <section id="user"><UsesId />{children}</section>);
36
+ `;
37
+ const lateLayoutSource = `import { rootLayout } from "akanjs/client";
38
+ export default rootLayout()
39
+ .loading(() => <i>root loading</i>)
40
+ .render(async () => {
41
+ await Bun.sleep(30);
42
+ throw new Error("root layout broke");
43
+ });
44
+ `;
45
+
46
+ const linkPackage = async (root: string, name: string, dir: string) => {
47
+ await mkdir(path.dirname(path.join(root, "node_modules", name)), { recursive: true });
48
+ await symlink(dir, path.join(root, "node_modules", name));
49
+ };
50
+
51
+ const writeApp = async (routes: Record<string, string>) => {
52
+ const root = await makeTempRoot();
53
+ const appDir = path.join(root, "apps/demo");
54
+ await linkPackage(root, "akanjs", akanjsRoot);
55
+ for (const name of ["react", "react-dom", "react-server-dom-webpack"])
56
+ await linkPackage(root, name, path.dirname(Bun.resolveSync(`${name}/package.json`, akanjsRoot)));
57
+ await write(
58
+ path.join(root, "tsconfig.json"),
59
+ JSON.stringify({ compilerOptions: { paths: { "@apps/*": ["./apps/*"] } } }),
60
+ );
61
+ await write(path.join(appDir, "env/env.client.ts"), "export const env = {};\n");
62
+ await write(path.join(appDir, "lib/dict.ts"), "export const getAllDictionary = () => ({});\n");
63
+ //? With lib/st.ts present the generated layout imports both, and the worker's System.Provider reads this runtime.
64
+ await write(
65
+ path.join(appDir, "lib/useClient.ts"),
66
+ 'import { makePageProto, registerClientRuntime } from "akanjs/client";\nregisterClientRuntime(makePageProto({}) as never);\n',
67
+ );
68
+ await write(path.join(appDir, "lib/st.ts"), "export {};\n");
69
+ await write(
70
+ path.join(appDir, "page/usesId.tsx"),
71
+ '"use client";\nimport { useId } from "react";\nexport const UsesId = () => <b id={useId()}>uses id</b>;\n',
72
+ );
73
+ for (const [file, source] of Object.entries(routes)) await write(path.join(appDir, "page", file), source);
74
+ return { root, appDir, pageKeys: Object.keys(routes).map((file) => `./${file}`) };
75
+ };
76
+
77
+ //? Each client reference's stub names its workspace-relative path in the error it throws when called on the server.
78
+ const clientReferenceIds = async (serverDir: string) => {
79
+ const ids = new Set<string>();
80
+ for (const file of await readdir(serverDir, { recursive: true })) {
81
+ if (!file.endsWith(".js")) continue;
82
+ const source = await Bun.file(path.join(serverDir, file)).text();
83
+ for (const [, id] of source.matchAll(/Attempted to call '[^']+' from '([^']+)' on the server/g))
84
+ if (id) ids.add(id);
85
+ }
86
+ return [...ids];
87
+ };
88
+
89
+ const ssrManifest: { moduleLoading: null; moduleMap: Record<string, unknown> } = { moduleLoading: null, moduleMap: {} };
90
+
91
+ interface Rendered {
92
+ html: string;
93
+ status: number;
94
+ payload: Uint8Array;
95
+ }
96
+
97
+ const withBuiltPages = async (
98
+ { routes, unbounded }: { routes: Record<string, string>; unbounded?: string },
99
+ run: (render: (route: string) => Promise<Rendered>) => Promise<void>,
100
+ ) => {
101
+ const { root, appDir, pageKeys } = await writeApp(routes);
102
+ const app = {
103
+ name: "demo",
104
+ cwdPath: appDir,
105
+ dist: { cwdPath: path.join(root, "dist/apps/demo") },
106
+ workspace: { workspaceRoot: root },
107
+ getConfig: async () => ({ basePaths: [], barrelImports: [], externalLibs: [] }),
108
+ getTsConfig: async () => ({ compilerOptions: { paths: { "@apps/*": ["./apps/*"] } } }),
109
+ getPublicEnv: () => ({}),
110
+ verbose: () => undefined,
111
+ };
112
+ const entries = await resolveSsrPageEntries({ appCwdPath: appDir, appName: "demo", pageKeys });
113
+ if (unbounded) {
114
+ const generated = entries.find((entry) => entry.key === `./${unbounded}/__root_layout.tsx`);
115
+ if (!generated) throw new Error(`no generated root layout for ${unbounded}`);
116
+ const source = await Bun.file(generated.moduleAbsPath).text();
117
+ expect(source).toContain(boundedLayout);
118
+ await Bun.write(generated.moduleAbsPath, source.replace(boundedLayout, "layout"));
119
+ }
120
+ const { bundlePath } = await new PagesBundleBuilder(app as never, "build", entries).build();
121
+ const ids = await clientReferenceIds(path.dirname(bundlePath));
122
+ ssrManifest.moduleMap = Object.fromEntries(
123
+ ids.map((id) => {
124
+ const file = path.resolve(root, id);
125
+ return [id, { "*": { id: file, chunks: [file, file], name: "*" } }];
126
+ }),
127
+ );
128
+ const rsc = new RscWorker({
129
+ pagesBundlePath: bundlePath,
130
+ pagesBundleBuildId: 1,
131
+ rscRuntimeClientManifest: Object.fromEntries(ids.map((id) => [id, { id, chunks: [], name: "" }])),
132
+ } as never);
133
+ try {
134
+ await rsc.ready;
135
+ await run(async (route) => {
136
+ const request = new Request(`http://localhost/en/${route}`);
137
+ const result = await rsc.renderWithMeta(request);
138
+ if (result.type !== "stream") throw new Error(`expected a rendered page, got ${result.type}`);
139
+ const [rscStream, payloadStream] = result.stream.tee();
140
+ const payload = new Response(payloadStream).arrayBuffer();
141
+ payload.catch(() => undefined);
142
+ const stream = await new SsrFromRscRenderer().render({
143
+ request,
144
+ rscStream,
145
+ ssrManifest,
146
+ lateControl: result.lateControl,
147
+ } as never);
148
+ const html = await new Response(stream).text();
149
+ return { html, status: result.status ?? 200, payload: new Uint8Array(await payload) };
150
+ });
151
+ } finally {
152
+ rsc.kill();
153
+ }
154
+ };
155
+
156
+ const bodyOf = async (payload: Uint8Array): Promise<ReactNode> => {
157
+ const html = await createFromNodeStream<ReactElement<{ children: ReactNode }>>(
158
+ Readable.from([payload]),
159
+ ssrManifest as never,
160
+ );
161
+ const body = Children.toArray(html.props.children).find(
162
+ (child): child is ReactElement<{ children: ReactNode }> => isValidElement(child) && child.type === "body",
163
+ );
164
+ return createElement(Fragment, null, body?.props.children);
165
+ };
166
+
167
+ const markupOf = async (node: ReactNode) => {
168
+ const stream = await renderToReadableStream(node, { onError: () => undefined });
169
+ await stream.allReady;
170
+ return await new Response(stream).text();
171
+ };
172
+
173
+ const hydrated = async (
174
+ payload: Uint8Array,
175
+ keptSelectors: string[],
176
+ run: (container: HTMLElement, uncaught: unknown[], recoverable: unknown[]) => void | Promise<void>,
177
+ ) => {
178
+ const markup = await markupOf(await bodyOf(payload));
179
+ const { GlobalRegistrator } = await import("@happy-dom/global-registrator");
180
+ GlobalRegistrator.register({ url: "http://localhost/en/" });
181
+ //? getEnv() caches its side, and the SSR render above ran with no window.
182
+ resetEnvCache();
183
+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
184
+ const { hydrateRoot } = await import("react-dom/client");
185
+ const container = document.createElement("div");
186
+ container.innerHTML = markup;
187
+ document.body.appendChild(container);
188
+ const uncaught: unknown[] = [];
189
+ const recoverable: unknown[] = [];
190
+ const kept = keptSelectors.map((selector) => [selector, container.querySelector(selector)] as const);
191
+ //? React's dev check tags a context with the last renderer to provide it, and Fizz rendered these in this process.
192
+ const logged = console.error;
193
+ const quiet = spyOn(console, "error").mockImplementation((...args: unknown[]) => {
194
+ if (!String(args[0]).startsWith("Detected multiple renderers concurrently")) logged(...args);
195
+ });
196
+ let root: ReturnType<typeof hydrateRoot> | undefined;
197
+ try {
198
+ const tree = await bodyOf(payload);
199
+ await act(async () => {
200
+ root = hydrateRoot(container, tree, {
201
+ onUncaughtError: (error) => void uncaught.push(error),
202
+ onCaughtError: () => undefined,
203
+ onRecoverableError: (error) => void recoverable.push(error),
204
+ });
205
+ });
206
+ await act(async () => {});
207
+ for (const [selector, node] of kept) expect(container.querySelector(selector)).toBe(node);
208
+ await run(container, uncaught, recoverable);
209
+ } finally {
210
+ await act(async () => {
211
+ root?.unmount();
212
+ });
213
+ quiet.mockRestore();
214
+ await GlobalRegistrator.unregister();
215
+ resetEnvCache();
216
+ }
217
+ };
218
+
219
+ const withLoggedErrors = async (run: () => Promise<void>) => {
220
+ const logged = spyOn(Logger.prototype, "error").mockImplementation(() => undefined);
221
+ try {
222
+ await run();
223
+ } finally {
224
+ logged.mockRestore();
225
+ }
226
+ };
227
+
228
+ describe("The generated System root layout, built and rendered", () => {
229
+ test("draws a late root failure's notice inside System.Provider, whose bridge started the router its retry calls", async () => {
230
+ const refreshes: string[] = [];
231
+ globalThis.__AKAN_RSC_REFRESH__ = async () => void refreshes.push("refresh");
232
+ try {
233
+ await withLoggedErrors(async () => {
234
+ const routes = { "(late)/_layout.tsx": lateLayoutSource, "(late)/late.tsx": pageSource };
235
+ await withBuiltPages({ routes }, async (render) => {
236
+ const late = await render("late");
237
+ expect(late.status).toBe(200);
238
+ expect(late.html).toContain('<body><!--$?--><template id="B:0"></template><i>root loading</i><!--/$-->');
239
+ expect(late.html).toContain('$RX("B:0"');
240
+
241
+ //? Only the hydrated ClientSsrBridge can start it: the server's own init ran in the worker.
242
+ expect(router.isInitialized).toBe(false);
243
+ await hydrated(late.payload, [], async (container, uncaught) => {
244
+ expect(uncaught).toEqual([]);
245
+ const notice = container.querySelector("#pageContent > [role='alert']");
246
+ expect(notice).not.toBeNull();
247
+ await act(async () => notice?.querySelector("button")?.click());
248
+ expect(refreshes).toEqual(["refresh"]);
249
+ });
250
+ });
251
+ });
252
+ } finally {
253
+ globalThis.__AKAN_RSC_REFRESH__ = undefined;
254
+ }
255
+ }, 30_000);
256
+
257
+ test("keeps the markup and useId values the template had without the boundary, and hydrates them in place", async () => {
258
+ const routes = {
259
+ "(ids)/_layout.tsx": idsLayoutSource,
260
+ "(ids)/ids.tsx": pageSource,
261
+ "(bare)/_layout.tsx": idsLayoutSource,
262
+ "(bare)/bar.tsx": pageSource,
263
+ };
264
+ await withBuiltPages({ routes, unbounded: "(bare)" }, async (render) => {
265
+ const beforeScripts = (html: string) => html.slice(html.indexOf("<body>"), html.indexOf("<script"));
266
+ const bounded = await render("ids");
267
+ const bare = beforeScripts((await render("bar")).html);
268
+ expect(beforeScripts(bounded.html)).toContain('<section id="user"><b id="_R_');
269
+ expect(beforeScripts(bounded.html).replace('data-firstpath="ids"', 'data-firstpath="bar"')).toBe(bare);
270
+
271
+ await hydrated(bounded.payload, ["#pageContent", "#user", "#user b"], (container, uncaught, recoverable) => {
272
+ expect(container.querySelector("#user b")?.id).toStartWith("_R_");
273
+ expect({ uncaught, recoverable }).toEqual({ uncaught: [], recoverable: [] });
274
+ });
275
+ });
276
+ }, 30_000);
277
+ });
@@ -1041,6 +1041,33 @@ describe("Workspace and app executor environment contracts", () => {
1041
1041
 
1042
1042
  await expect(app.getPageKeys({ refresh: true })).resolves.toEqual(["./(docs)/_layout.tsx"]);
1043
1043
  });
1044
+
1045
+ const levelBoundaryLayout = [
1046
+ "export const LevelBoundary = ({ children }) => children;",
1047
+ "export default function Layout({ children }) { return children; }",
1048
+ "",
1049
+ ].join("\n");
1050
+
1051
+ test("refuses a LevelBoundary export on the app's root layout, which the generated one would ignore", async () => {
1052
+ const app = await makeRouteValidationApp("root-level-boundary", "export default {};\n", {
1053
+ "_layout.tsx": levelBoundaryLayout,
1054
+ });
1055
+
1056
+ await expect(app.getPageKeys({ refresh: true })).rejects.toThrow(
1057
+ /unsupported export "LevelBoundary" in .*page\/_layout\.tsx: LevelBoundary belongs to the root layout Akan\.js generates, which never reads one from an app's layout/,
1058
+ );
1059
+ });
1060
+
1061
+ test("refuses a LevelBoundary export on a grouped root layout under the app's own, naming the grouped file", async () => {
1062
+ const app = await makeRouteValidationApp("nested-root-level-boundary", "export default {};\n", {
1063
+ "_layout.tsx": "export default function Layout({ children }) { return children; }\n",
1064
+ "(home)/_layout.tsx": levelBoundaryLayout,
1065
+ });
1066
+
1067
+ await expect(app.getPageKeys({ refresh: true })).rejects.toThrow(
1068
+ /unsupported export "LevelBoundary" in .*page\/\(home\)\/_layout\.tsx: LevelBoundary belongs to the root layout Akan\.js generates/,
1069
+ );
1070
+ });
1044
1071
  });
1045
1072
 
1046
1073
  test("accepts head route exports during page key discovery", async () => {
@@ -1,13 +1,9 @@
1
1
  import { mkdir, readdir, readFile, rm, stat } from "node:fs/promises";
2
2
  import path from "node:path";
3
- import { capitalize } from "akanjs/common";
3
+ import { barrelFacetDirs, capitalize, facetBarrelOf } from "akanjs/common";
4
4
  import { FileSys } from "../util/fileSys";
5
5
 
6
- const BARREL_FACETS = new Set(["common", "srvkit", "ui", "webkit", "plugin"]);
7
- const FACET_SOURCE_FILE_RE = /\.(ts|tsx)$/;
8
- const FACET_EXCLUDED_FILE_RE = /(^index\.tsx?$|\.d\.ts$|\.(test|spec)\.(ts|tsx)$|\.css$|\.scss$|\.sass$)/;
9
- const FACET_PASCAL_CASE_RE = /^[A-Z][A-Za-z0-9]*$/;
10
- const FACET_CAMEL_CASE_RE = /^[a-z][A-Za-z0-9]*$/;
6
+ const BARREL_FACETS = new Set<string>(barrelFacetDirs);
11
7
  const MODULE_UI_TYPES = ["Template", "Unit", "Util", "View", "Zone"] as const;
12
8
  const SERVICE_UI_TYPES = ["Util", "Zone"] as const;
13
9
  const SCALAR_UI_TYPES = ["Template", "Unit"] as const;
@@ -113,22 +109,11 @@ export class DevGeneratedIndexSync {
113
109
  }
114
110
 
115
111
  async #facetContent(dir: string): Promise<string | null> {
116
- const nameCasePattern = path.basename(dir) === "ui" ? FACET_PASCAL_CASE_RE : FACET_CAMEL_CASE_RE;
117
112
  const entries = await readdir(dir, { withFileTypes: true }).catch(() => null);
118
113
  if (!entries) return null;
119
- const exportNames = entries
120
- .flatMap((entry) => {
121
- const name = entry.name;
122
- if (name.startsWith(".")) return [];
123
- if (entry.isDirectory()) return nameCasePattern.test(name) ? [name] : [];
124
- if (!entry.isFile()) return [];
125
- if (!FACET_SOURCE_FILE_RE.test(name) || FACET_EXCLUDED_FILE_RE.test(name)) return [];
126
- const exportName = name.replace(FACET_SOURCE_FILE_RE, "");
127
- return nameCasePattern.test(exportName) ? [exportName] : [];
128
- })
129
- .sort(compareExportNames);
130
- if (exportNames.length === 0) return "export {};\n";
131
- return `${exportNames.map((name) => `export * from "./${name}";`).join("\n")}\n`;
114
+ const files = entries.filter((entry) => entry.isFile()).map((entry) => entry.name);
115
+ const dirs = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
116
+ return facetBarrelOf(path.basename(dir), files, dirs);
132
117
  }
133
118
 
134
119
  async #moduleContent(dir: string): Promise<string | null> {
@@ -154,22 +139,6 @@ export class DevGeneratedIndexSync {
154
139
  }
155
140
  }
156
141
 
157
- //? Biome's organizeImports order, or `akan lint` reorders the barrel: A < a < B < b, a digit before a letter, and a
158
- //? run of digits compared by its length first. The facetIndex template sorts the same way.
159
- const letterRankOf = (char: string) => char.toLowerCase().charCodeAt(0) * 2 + (char === char.toLowerCase() ? 1 : 0);
160
- const digitRunAt = (name: string, idx: number) => /^\d+/.exec(name.slice(idx))?.[0] ?? "";
161
- const compareExportNames = (a: string, b: string) => {
162
- for (let idx = 0; idx < a.length && idx < b.length; ) {
163
- const [runA, runB] = [digitRunAt(a, idx), digitRunAt(b, idx)];
164
- if (runA && runB && runA !== runB) return runA.length - runB.length || (runA < runB ? -1 : 1);
165
- if (runA && runB) idx += runA.length;
166
- else if (runA || runB) return runA ? -1 : 1;
167
- else if (a.charAt(idx) !== b.charAt(idx)) return letterRankOf(a.charAt(idx)) - letterRankOf(b.charAt(idx));
168
- else idx++;
169
- }
170
- return a.length - b.length;
171
- };
172
-
173
142
  const exists = async (file: string) =>
174
143
  stat(file)
175
144
  .then(() => true)
@@ -69,19 +69,37 @@ const buildCsr = async (indexPage: string) => {
69
69
  logger: { warn: () => undefined },
70
70
  };
71
71
  const reached: string[] = [];
72
+ const metafiles: Bun.BuildMetafile[] = [];
72
73
  const build = Bun.build;
73
- const recorded = spyOn(Bun, "build").mockImplementation((config) =>
74
- build({ ...config, plugins: [recordOptionalPeers(reached), ...(config.plugins ?? [])] }),
75
- );
74
+ const recorded = spyOn(Bun, "build").mockImplementation(async (config) => {
75
+ const result = await build({
76
+ ...config,
77
+ metafile: true,
78
+ plugins: [recordOptionalPeers(reached), ...(config.plugins ?? [])],
79
+ });
80
+ if (result.metafile) metafiles.push(result.metafile);
81
+ return result;
82
+ });
76
83
 
77
84
  try {
78
85
  await new CsrArtifactBuilder(app as never, "build").build();
79
86
  } finally {
80
87
  recorded.mockRestore();
81
88
  }
82
- return { root, reached };
89
+ return { root, reached, metafiles };
83
90
  };
84
91
 
92
+ const mcpAppPage =
93
+ 'import { page } from "akanjs/client";\nimport { Link } from "akanjs/ui";\n\nexport default page()\n .app("showHome", "Show the home link.", () => <Link href="/">home</Link>)\n .render(() => null);\n';
94
+
95
+ const bytesFrom = (metafiles: Bun.BuildMetafile[], entry: string, input: string) =>
96
+ metafiles
97
+ .flatMap((metafile) => Object.values(metafile.outputs))
98
+ .filter((output) => output.entryPoint?.endsWith(entry))
99
+ .flatMap((output) => Object.entries(output.inputs))
100
+ .filter(([file]) => file.endsWith(input))
101
+ .reduce((sum, [, { bytesInOutput }]) => sum + bytesInOutput, 0);
102
+
85
103
  describe("optional peers of akanjs", () => {
86
104
  test("the generated root layout, the _overrides.tsx wrapper and the runtime entries import none", async () => {
87
105
  const { appDir, pageKeys } = await writeApp("export default function Page() {\n return null;\n}\n");
@@ -122,11 +140,21 @@ describe("optional peers of akanjs", () => {
122
140
  });
123
141
 
124
142
  test("the MCP App view build of a page drawing akanjs/ui components imports none", async () => {
125
- const { root, reached } = await buildCsr(
126
- 'import { page } from "akanjs/client";\nimport { Link } from "akanjs/ui";\n\nexport default page()\n .app("showHome", "Show the home link.", () => <Link href="/">home</Link>)\n .render(() => null);\n',
127
- );
143
+ const { root, reached } = await buildCsr(mcpAppPage);
128
144
 
129
145
  expect(await Bun.file(path.join(root, "dist/apps/demo/mcp-apps/showHome.html")).exists()).toBe(true);
130
146
  expect(reached).toEqual([]);
131
147
  });
132
148
  });
149
+
150
+ describe("the CSR shell and the MCP App view", () => {
151
+ test("leave out the route-level boundary class, which only a server render draws, and keep RenderFailure", async () => {
152
+ const { metafiles } = await buildCsr(mcpAppPage);
153
+
154
+ for (const entry of ["generated/csr/index.html", "generated/mcp-apps/showHome.html"]) {
155
+ expect(bytesFrom(metafiles, entry, "webkit/RenderFailure.tsx")).toBeGreaterThan(0);
156
+ //? What stays of the module is its React import binding; the class alone is several hundred bytes.
157
+ expect(bytesFrom(metafiles, entry, "webkit/RouteLevelBoundary.tsx")).toBeLessThan(40);
158
+ }
159
+ });
160
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "3.2.0-rc.16",
3
+ "version": "3.2.0-rc.18",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -205,7 +205,7 @@
205
205
  "./*": "./*.ts"
206
206
  },
207
207
  "dependencies": {
208
- "@akanjs/language": "3.2.0-rc.16",
208
+ "@akanjs/language": "3.2.0-rc.18",
209
209
  "@earendil-works/pi-agent-core": "1.3.0",
210
210
  "@earendil-works/pi-ai": "1.3.0",
211
211
  "@earendil-works/pi-codemode": "1.3.0",
@@ -214,7 +214,7 @@
214
214
  "@earendil-works/pi-tui": "1.3.0",
215
215
  "@inquirer/prompts": "^8.7.3",
216
216
  "@tailwindcss/node": "^4.3.3",
217
- "akanjs": "3.2.0-rc.16",
217
+ "akanjs": "3.2.0-rc.18",
218
218
  "chalk": "^6.0.1",
219
219
  "commander": "^15.0.0",
220
220
  "dayjs": "^1.11.23",
@@ -1,6 +1,8 @@
1
1
  // The one source of the app/lib root allowlists (sync, doctor and quality scan read it); mirror a change into the
2
2
  // root AGENTS.md list.
3
3
 
4
+ import { barrelFacetDirs } from "akanjs/common";
5
+
4
6
  export type SysType = "app" | "lib";
5
7
 
6
8
  export const appRootAllowedFiles = new Set([
@@ -98,7 +100,7 @@ export const moduleTestHint =
98
100
  "a module test is named after the one module file it covers (<model>.<role>.test.ts); add a describe block to " +
99
101
  "that file's suite instead, or move a suite that drives several modules into srvkit/";
100
102
 
101
- export const barrelFacetDirs = ["ui", "webkit", "srvkit", "common", "plugin"] as const;
103
+ export { barrelFacetDirs };
102
104
 
103
105
  //* Bun resolves a folder import to `index.tsx`, `index.jsx` or `index.mts` ahead of `index.ts`, and TypeScript to
104
106
  //* `index.ts` first, so one of these beside the generated barrel typechecks every name the barrel adds and serves none.