akanjs 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
@@ -266,6 +266,21 @@
266
266
  - **`internal`, `adaptor` and `plugs`** join `AkanGraphNodeKind` and `AkanGraphEdgeKind` in `akanjs/common`.
267
267
  - **`FileFacts.internals` and `FileFacts.adaptors`** in `@akanjs/language`, with `ServiceClassFact.plugs`; `AkanIndex.setFile` also reads non-test files that call `adapt` or `dangerouslyAdapt`.
268
268
 
269
+ - 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.
270
+
271
+ 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.
272
+
273
+ 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.
274
+
275
+ Ids that change for a saved graph or a Change Map base:
276
+
277
+ - 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>`.
278
+ - 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>`.
279
+ - 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>`.
280
+ - 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.
281
+ - 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>`.
282
+ - 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.
283
+
269
284
  - 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.
270
285
 
271
286
  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".
@@ -551,6 +566,10 @@
551
566
 
552
567
  Development keeps the message as the digest. Redirects and not-found answers keep their digests and behave as before, and a layout's `.error()` view still gets `AKAN_RENDER_ERROR`. A typed `Err` thrown after the page has started streaming now gets an id as well, rather than its dictionary key; nothing in the framework read the key from the digest.
553
568
 
569
+ - 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.
570
+
571
+ `akanjs/common` exports `GENERATED_ROOT_LAYOUT_EXPORTS`, the set of those names.
572
+
554
573
  - 9a9e1fa: A server page from `akan build` now preloads its client modules from `<head>`, so a cold load stops waiting on chains of imports.
555
574
 
556
575
  - **What is preloaded:** the rsc client and the chunks it imports, the chunks every client reference row (`I` row) in the shell's flight names, and the importmap vendors those chunks import, each with its own chunks. A client URL that only the page's own text carries is never preloaded. Before, only the rsc client and the locale dictionary were preloaded. The browser found the rest one import level at a time, after the document finished.
@@ -561,7 +580,7 @@
561
580
  - 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.*`.
562
581
 
563
582
  - 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.
564
- - 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.
583
+ - 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.
565
584
  - 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.
566
585
  - 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.
567
586
  - **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.
@@ -0,0 +1,38 @@
1
+ export const barrelFacetDirs = ["ui", "webkit", "srvkit", "common", "plugin"] as const;
2
+
3
+ const sourceFilePattern = /\.(ts|tsx)$/;
4
+ const excludedFilePattern = /(^index\.tsx?$|\.d\.ts$|\.(test|spec)\.(ts|tsx)$|\.css$|\.scss$|\.sass$)/;
5
+
6
+ const pascalCasePattern = /^[A-Z][A-Za-z0-9]*$/;
7
+ const camelCasePattern = /^[a-z][A-Za-z0-9]*$/;
8
+
9
+ const letterRankOf = (char: string) => char.toLowerCase().charCodeAt(0) * 2 + (char === char.toLowerCase() ? 1 : 0);
10
+ const digitRunAt = (name: string, idx: number) => /^\d+/.exec(name.slice(idx))?.[0] ?? "";
11
+ export const compareExportNames = (a: string, b: string) => {
12
+ for (let idx = 0; idx < a.length && idx < b.length; ) {
13
+ const [runA, runB] = [digitRunAt(a, idx), digitRunAt(b, idx)];
14
+ if (runA && runB && runA !== runB) return runA.length - runB.length || (runA < runB ? -1 : 1);
15
+ if (runA && runB) idx += runA.length;
16
+ else if (runA || runB) return runA ? -1 : 1;
17
+ else if (a.charAt(idx) !== b.charAt(idx)) return letterRankOf(a.charAt(idx)) - letterRankOf(b.charAt(idx));
18
+ else idx++;
19
+ }
20
+ return a.length - b.length;
21
+ };
22
+
23
+ export const facetBarrelNamesOf = (facet: string, files: string[], dirs: string[]) => {
24
+ const nameCasePattern = facet === "ui" ? pascalCasePattern : camelCasePattern;
25
+ return [
26
+ ...files
27
+ .filter((file) => sourceFilePattern.test(file) && !excludedFilePattern.test(file))
28
+ .map((file) => file.replace(sourceFilePattern, "")),
29
+ ...dirs.filter((dir) => !dir.startsWith(".")),
30
+ ]
31
+ .filter((name) => nameCasePattern.test(name))
32
+ .sort(compareExportNames);
33
+ };
34
+
35
+ export const facetBarrelOf = (facet: string, files: string[], dirs: string[]) => {
36
+ const names = facetBarrelNamesOf(facet, files, dirs);
37
+ return names.length ? `${names.map((name) => `export * from "./${name}";`).join("\n")}\n` : "export {};\n";
38
+ };
package/common/index.ts CHANGED
@@ -98,6 +98,7 @@ export {
98
98
  export { type CookieEntry, CookieJar, type CookieRead } from "./cookieJar";
99
99
  export { Err, type ErrConstructor, type ErrPayload, type ErrRestoreOption } from "./err";
100
100
  export { EventStream, type EventStreamOptions } from "./eventStream";
101
+ export { barrelFacetDirs, compareExportNames, facetBarrelNamesOf, facetBarrelOf } from "./facetBarrel";
101
102
  export { FailureCode } from "./failureCode";
102
103
  export {
103
104
  type FileUploadCapability,
@@ -223,6 +224,7 @@ export { round } from "./round";
223
224
  export {
224
225
  assertUniqueRoutePatterns,
225
226
  compareRouteSpecificity,
227
+ GENERATED_ROOT_LAYOUT_EXPORTS,
226
228
  getPageSourceFileViolation,
227
229
  getRouteExports,
228
230
  isRouteSourceFile,
@@ -19,6 +19,8 @@ export const PAGE_ROUTE_EXPORTS: ReadonlySet<string> = new Set([
19
19
  "guard",
20
20
  ]);
21
21
  export const LAYOUT_ROUTE_EXPORTS: ReadonlySet<string> = new Set([...PAGE_ROUTE_EXPORTS, "NotFound", "Error"]);
22
+ /** Root-layout exports the generated root layout defines itself: it reads none of them from an app's root layout. */
23
+ export const GENERATED_ROOT_LAYOUT_EXPORTS: ReadonlySet<string> = new Set(["McpAppRoot", "LevelBoundary"]);
22
24
  export const ROOT_LAYOUT_ROUTE_EXPORTS: ReadonlySet<string> = new Set([
23
25
  ...LAYOUT_ROUTE_EXPORTS,
24
26
  "fonts",
@@ -28,8 +30,7 @@ export const ROOT_LAYOUT_ROUTE_EXPORTS: ReadonlySet<string> = new Set([
28
30
  "wsConnect",
29
31
  "layoutStyle",
30
32
  "viewport",
31
- "McpAppRoot",
32
- "LevelBoundary",
33
+ ...GENERATED_ROOT_LAYOUT_EXPORTS,
33
34
  ]);
34
35
  /** Root-layout exports that are plain config rather than components, so a PascalCase check cannot allow them. */
35
36
  export const RESERVED_ROUTE_CONFIG_EXPORTS: ReadonlySet<string> = new Set(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akanjs",
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": {
@@ -0,0 +1,4 @@
1
+ export declare const barrelFacetDirs: readonly ["ui", "webkit", "srvkit", "common", "plugin"];
2
+ export declare const compareExportNames: (a: string, b: string) => number;
3
+ export declare const facetBarrelNamesOf: (facet: string, files: string[], dirs: string[]) => string[];
4
+ export declare const facetBarrelOf: (facet: string, files: string[], dirs: string[]) => string;
@@ -17,6 +17,7 @@ export { type CodeAgentAnswer, type CodeAgentApprovalRequest, type CodeAgentComm
17
17
  export { type CookieEntry, CookieJar, type CookieRead } from "./cookieJar.d.ts";
18
18
  export { Err, type ErrConstructor, type ErrPayload, type ErrRestoreOption } from "./err.d.ts";
19
19
  export { EventStream, type EventStreamOptions } from "./eventStream.d.ts";
20
+ export { barrelFacetDirs, compareExportNames, facetBarrelNamesOf, facetBarrelOf } from "./facetBarrel.d.ts";
20
21
  export { FailureCode } from "./failureCode.d.ts";
21
22
  export { type FileUploadCapability, fileUploadContract, resolveFileUploadCapability, } from "./fileUpload.d.ts";
22
23
  export { formatNumber } from "./formatNumber.d.ts";
@@ -59,7 +60,7 @@ export { hostFromRequest, isJsonContentType, originFromRequest } from "./request
59
60
  export { type RestartPolicy, RestartSchedule } from "./restartSchedule.d.ts";
60
61
  export { RestClient, type RestClientOptions, type RestRequestOptions } from "./restClient.d.ts";
61
62
  export { round } from "./round.d.ts";
62
- export { assertUniqueRoutePatterns, compareRouteSpecificity, getPageSourceFileViolation, getRouteExports, isRouteSourceFile, LAYOUT_ROUTE_EXPORTS, matchRoutePattern, normalizeRoutePattern, PAGE_ROUTE_EXPORTS, type ParsedRouteModuleKey, parseRouteModuleKey, RESERVED_ROUTE_CONFIG_EXPORTS, ROOT_LAYOUT_ROUTE_EXPORTS, type RouteModuleKind, routeSegmentToPatternPart, routeSegmentToTreePath, tryParseRouteModuleKey, type ValidatePageSourceFileOptions, type ValidateSubRoutePageKeyOptions, validatePageSourceFile, validateSubRoutePageKey, } from "./routeConvention.d.ts";
63
+ export { assertUniqueRoutePatterns, compareRouteSpecificity, GENERATED_ROOT_LAYOUT_EXPORTS, getPageSourceFileViolation, getRouteExports, isRouteSourceFile, LAYOUT_ROUTE_EXPORTS, matchRoutePattern, normalizeRoutePattern, PAGE_ROUTE_EXPORTS, type ParsedRouteModuleKey, parseRouteModuleKey, RESERVED_ROUTE_CONFIG_EXPORTS, ROOT_LAYOUT_ROUTE_EXPORTS, type RouteModuleKind, routeSegmentToPatternPart, routeSegmentToTreePath, tryParseRouteModuleKey, type ValidatePageSourceFileOptions, type ValidateSubRoutePageKeyOptions, validatePageSourceFile, validateSubRoutePageKey, } from "./routeConvention.d.ts";
63
64
  export { type SessionCookieDuplicate, SessionCookies } from "./sessionCookies.d.ts";
64
65
  export { sleep } from "./sleep.d.ts";
65
66
  export { getBasePathFromPathname, parseBasePaths, parseSubRouteHosts, resolveSubRouteHosts } from "./subRoute.d.ts";
@@ -1,6 +1,8 @@
1
1
  export type RouteModuleKind = "page" | "layout" | "overrides";
2
2
  export declare const PAGE_ROUTE_EXPORTS: ReadonlySet<string>;
3
3
  export declare const LAYOUT_ROUTE_EXPORTS: ReadonlySet<string>;
4
+ /** Root-layout exports the generated root layout defines itself: it reads none of them from an app's root layout. */
5
+ export declare const GENERATED_ROOT_LAYOUT_EXPORTS: ReadonlySet<string>;
4
6
  export declare const ROOT_LAYOUT_ROUTE_EXPORTS: ReadonlySet<string>;
5
7
  /** Root-layout exports that are plain config rather than components, so a PascalCase check cannot allow them. */
6
8
  export declare const RESERVED_ROUTE_CONFIG_EXPORTS: ReadonlySet<string>;