@akanjs/cli 3.0.0-alpha.51 → 3.0.0-alpha.52

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 (43) hide show
  1. package/.build-stamp +1 -1
  2. package/{agent.command-nqs3bw0g.js → agent.command-tsx1nsdj.js} +6 -5
  3. package/{application.command-k2v46pxf.js → application.command-n8ex8g9h.js} +5 -4
  4. package/{applicationBuildRunner-t5v6tcrm.js → applicationBuildRunner-x8h12rp0.js} +2 -1
  5. package/buildBatch.proc.js +3 -2
  6. package/{capacitorApp-927ahhz2.js → capacitorApp-8mv9e537.js} +3 -2
  7. package/{cloud.command-7jwmxtez.js → cloud.command-eqafzn1a.js} +8 -7
  8. package/{context.command-6kn3tady.js → context.command-s7a41qjs.js} +13 -12
  9. package/{guideline.command-pjdrndqk.js → guideline.command-qrw84ttb.js} +3 -2
  10. package/incrementalBuilder.proc.js +2 -1
  11. package/{index-7w5vv8jk.js → index-4mtyaqj2.js} +2 -2
  12. package/{index-90zyjrby.js → index-681sx6nt.js} +6 -1
  13. package/{index-97cw8sg1.js → index-cc1mgv1f.js} +4 -4
  14. package/{index-zgkey4d0.js → index-ce9755av.js} +1 -1
  15. package/{index-8rr621r2.js → index-ckpwq052.js} +1 -1
  16. package/{index-k7sm38v6.js → index-dvg362vq.js} +3 -3
  17. package/{index-866yqz3y.js → index-ek4mkwxp.js} +10 -10
  18. package/{index-6bs24rb4.js → index-f0t3wjyr.js} +2 -2
  19. package/index-f39512t6.js +255 -0
  20. package/{index-5em412h5.js → index-g44fykfw.js} +1 -1
  21. package/{index-xe3ychw5.js → index-h0mnt0b0.js} +3 -3
  22. package/{index-4z05haak.js → index-kkya2ped.js} +1 -1
  23. package/{index-7etegaht.js → index-r8z20vnj.js} +5 -5
  24. package/{index-5fe016p2.js → index-ryns915y.js} +3 -3
  25. package/{index-y59x51f1.js → index-ssrz6xr1.js} +5 -5
  26. package/{index-xrdrttjb.js → index-tn46rr6w.js} +4 -4
  27. package/{index-24h5bqpj.js → index-wc19q8mb.js} +2 -2
  28. package/{index-bwt525ne.js → index-wmwcwn1f.js} +3 -3
  29. package/{index-7zd96bng.js → index-x1dbhd80.js} +2 -2
  30. package/{index-wr999y03.js → index-xj5b8c0w.js} +102 -352
  31. package/index.js +19 -18
  32. package/{library.command-7h3yezwc.js → library.command-p3jgf5h2.js} +4 -3
  33. package/{localRegistry.command-vnkc41gj.js → localRegistry.command-jewr722x.js} +7 -6
  34. package/{module.command-4g11k3xd.js → module.command-hb3xm07r.js} +6 -5
  35. package/{package.command-z7dd6vy2.js → package.command-fbpa6r4w.js} +4 -3
  36. package/package.json +2 -2
  37. package/{page.command-y996708m.js → page.command-92vrmw96.js} +4 -3
  38. package/{primitive.command-4fcn8k83.js → primitive.command-k6b9jfxr.js} +7 -6
  39. package/{quality.command-hx5af2yn.js → quality.command-89vwmjvf.js} +3 -2
  40. package/{repair.command-ysxd8pef.js → repair.command-nh9jn8rh.js} +6 -5
  41. package/{scalar.command-3chgxybs.js → scalar.command-zcsjgvax.js} +5 -4
  42. package/{workflow.command-endxfzv5.js → workflow.command-jj0cphfm.js} +10 -9
  43. package/{workspace.command-5f2nmmd5.js → workspace.command-zg8me6fg.js} +19 -18
package/.build-stamp CHANGED
@@ -1 +1 @@
1
- 49a211f2b7201bcb3973169f18e45f33badbe73a2fc7e03cc62ba92dd83be6de
1
+ 01ea8ed0ffbaa2533de87a90a0f930f8914cabb255e887095d14f13152decabd
@@ -1,15 +1,16 @@
1
1
  // @bun
2
2
  import {
3
3
  AgentScript
4
- } from "./index-xe3ychw5.js";
5
- import"./index-24h5bqpj.js";
6
- import"./index-5em412h5.js";
4
+ } from "./index-h0mnt0b0.js";
5
+ import"./index-wc19q8mb.js";
6
+ import"./index-g44fykfw.js";
7
7
  import"./index-j37qq1f2.js";
8
8
  import {
9
9
  Workspace,
10
10
  command
11
- } from "./index-8rr621r2.js";
12
- import"./index-90zyjrby.js";
11
+ } from "./index-ckpwq052.js";
12
+ import"./index-681sx6nt.js";
13
+ import"./index-f39512t6.js";
13
14
  import"./index-mxvakhsm.js";
14
15
  import"./index-xys926f2.js";
15
16
  import"./index-1577bej2.js";
@@ -4,8 +4,8 @@ import {
4
4
  } from "./index-0wae5ebk.js";
5
5
  import {
6
6
  ApplicationScript
7
- } from "./index-7etegaht.js";
8
- import"./index-6bs24rb4.js";
7
+ } from "./index-r8z20vnj.js";
8
+ import"./index-f0t3wjyr.js";
9
9
  import {
10
10
  getMobileTargetChoices
11
11
  } from "./index-76rn3g2c.js";
@@ -15,10 +15,11 @@ import {
15
15
  Sys,
16
16
  Workspace,
17
17
  command
18
- } from "./index-8rr621r2.js";
18
+ } from "./index-ckpwq052.js";
19
19
  import"./index-fgc8r6dj.js";
20
20
  import"./index-5vy2jzar.js";
21
- import"./index-90zyjrby.js";
21
+ import"./index-681sx6nt.js";
22
+ import"./index-f39512t6.js";
22
23
  import"./index-mxvakhsm.js";
23
24
  import"./index-1577bej2.js";
24
25
  import"./index-67546d0j.js";
@@ -4,10 +4,11 @@ import {
4
4
  CsrArtifactBuilder,
5
5
  SsrBaseArtifactBuilder,
6
6
  precompressArtifacts
7
- } from "./index-wr999y03.js";
7
+ } from "./index-xj5b8c0w.js";
8
8
  import"./index-xjd3rqzj.js";
9
9
  import"./index-qnv0aqmm.js";
10
10
  import"./index-5vy2jzar.js";
11
+ import"./index-f39512t6.js";
11
12
  import {
12
13
  Spinner
13
14
  } from "./index-mxvakhsm.js";
@@ -5,14 +5,15 @@ import {
5
5
  FontOptimizer,
6
6
  PagesBundleBuilder,
7
7
  SsrBaseArtifactBuilder
8
- } from "./index-wr999y03.js";
8
+ } from "./index-xj5b8c0w.js";
9
9
  import"./index-xjd3rqzj.js";
10
10
  import"./index-qnv0aqmm.js";
11
11
  import"./index-5vy2jzar.js";
12
12
  import {
13
13
  AppExecutor,
14
14
  WorkspaceExecutor
15
- } from "./index-90zyjrby.js";
15
+ } from "./index-681sx6nt.js";
16
+ import"./index-f39512t6.js";
16
17
  import"./index-mxvakhsm.js";
17
18
  import"./index-1577bej2.js";
18
19
  import"./index-67546d0j.js";
@@ -25,9 +25,10 @@ import {
25
25
  selectLocalDevHost,
26
26
  sortIosRunTargets,
27
27
  writeRootCapacitorConfig
28
- } from "./index-zgkey4d0.js";
28
+ } from "./index-ce9755av.js";
29
29
  import"./index-76rn3g2c.js";
30
- import"./index-90zyjrby.js";
30
+ import"./index-681sx6nt.js";
31
+ import"./index-f39512t6.js";
31
32
  import"./index-mxvakhsm.js";
32
33
  import"./index-1577bej2.js";
33
34
  import"./index-67546d0j.js";
@@ -1,22 +1,23 @@
1
1
  // @bun
2
2
  import {
3
3
  CloudScript
4
- } from "./index-y59x51f1.js";
5
- import"./index-bwt525ne.js";
6
- import"./index-7zd96bng.js";
4
+ } from "./index-ssrz6xr1.js";
5
+ import"./index-wmwcwn1f.js";
6
+ import"./index-x1dbhd80.js";
7
7
  import {
8
8
  GlobalConfig
9
9
  } from "./index-sh01r3pm.js";
10
- import"./index-7etegaht.js";
11
- import"./index-6bs24rb4.js";
10
+ import"./index-r8z20vnj.js";
11
+ import"./index-f0t3wjyr.js";
12
12
  import"./index-76rn3g2c.js";
13
13
  import {
14
14
  Workspace,
15
15
  command
16
- } from "./index-8rr621r2.js";
16
+ } from "./index-ckpwq052.js";
17
17
  import"./index-fgc8r6dj.js";
18
18
  import"./index-5vy2jzar.js";
19
- import"./index-90zyjrby.js";
19
+ import"./index-681sx6nt.js";
20
+ import"./index-f39512t6.js";
20
21
  import"./index-mxvakhsm.js";
21
22
  import"./index-1577bej2.js";
22
23
  import"./index-46tjzh6s.js";
@@ -1,25 +1,26 @@
1
1
  // @bun
2
2
  import {
3
3
  ContextScript
4
- } from "./index-866yqz3y.js";
5
- import"./index-5fe016p2.js";
6
- import"./index-k7sm38v6.js";
7
- import"./index-7w5vv8jk.js";
8
- import"./index-97cw8sg1.js";
9
- import"./index-xrdrttjb.js";
4
+ } from "./index-ek4mkwxp.js";
5
+ import"./index-ryns915y.js";
6
+ import"./index-dvg362vq.js";
7
+ import"./index-4mtyaqj2.js";
8
+ import"./index-cc1mgv1f.js";
9
+ import"./index-tn46rr6w.js";
10
10
  import"./index-ss469dec.js";
11
- import"./index-4z05haak.js";
12
- import"./index-zgkey4d0.js";
11
+ import"./index-kkya2ped.js";
12
+ import"./index-ce9755av.js";
13
13
  import"./index-sh01r3pm.js";
14
- import"./index-24h5bqpj.js";
15
- import"./index-5em412h5.js";
14
+ import"./index-wc19q8mb.js";
15
+ import"./index-g44fykfw.js";
16
16
  import"./index-j37qq1f2.js";
17
17
  import"./index-76rn3g2c.js";
18
18
  import {
19
19
  Workspace,
20
20
  command
21
- } from "./index-8rr621r2.js";
22
- import"./index-90zyjrby.js";
21
+ } from "./index-ckpwq052.js";
22
+ import"./index-681sx6nt.js";
23
+ import"./index-f39512t6.js";
23
24
  import"./index-mxvakhsm.js";
24
25
  import"./index-xys926f2.js";
25
26
  import"./index-1577bej2.js";
@@ -10,8 +10,9 @@ import {
10
10
  command,
11
11
  runner,
12
12
  script
13
- } from "./index-8rr621r2.js";
14
- import"./index-90zyjrby.js";
13
+ } from "./index-ckpwq052.js";
14
+ import"./index-681sx6nt.js";
15
+ import"./index-f39512t6.js";
15
16
  import"./index-mxvakhsm.js";
16
17
  import {
17
18
  getDirname
@@ -16,7 +16,8 @@ import {
16
16
  import {
17
17
  AppExecutor,
18
18
  WorkspaceExecutor
19
- } from "./index-90zyjrby.js";
19
+ } from "./index-681sx6nt.js";
20
+ import"./index-f39512t6.js";
20
21
  import"./index-mxvakhsm.js";
21
22
  import"./index-1577bej2.js";
22
23
  import"./index-67546d0j.js";
@@ -9,14 +9,14 @@ import {
9
9
  createPassedPrimitiveReport,
10
10
  generatedFilesForSync,
11
11
  scalarChangedFiles
12
- } from "./index-5em412h5.js";
12
+ } from "./index-g44fykfw.js";
13
13
  import {
14
14
  Prompter
15
15
  } from "./index-j37qq1f2.js";
16
16
  import {
17
17
  runner,
18
18
  script
19
- } from "./index-8rr621r2.js";
19
+ } from "./index-ckpwq052.js";
20
20
 
21
21
  // pkgs/@akanjs/cli/scalar/scalar.prompt.ts
22
22
  import { input } from "@inquirer/prompts";
@@ -1,4 +1,8 @@
1
1
  // @bun
2
+ import {
3
+ getRootBoundarySegments,
4
+ isRootBoundarySegments
5
+ } from "./index-f39512t6.js";
2
6
  import {
3
7
  Spinner
4
8
  } from "./index-mxvakhsm.js";
@@ -2746,7 +2750,8 @@ class AppExecutor extends SysExecutor {
2746
2750
  }
2747
2751
  if (!owner)
2748
2752
  owners.set(routeId, { absPath, fromLib });
2749
- const isRootLayout = parsed.kind === "layout" && parsed.moduleSegments.at(-1) === "_layout";
2753
+ const layoutSegments = getRootBoundarySegments(key);
2754
+ const isRootLayout = layoutSegments !== null && isRootBoundarySegments(layoutSegments, akanConfig2.basePaths);
2750
2755
  const routeSource = await Bun.file(absPath).text();
2751
2756
  const validator = await AppExecutor.#getRouteSourceValidator();
2752
2757
  if (parsed.kind === "overrides")
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  ModuleScript
4
- } from "./index-xrdrttjb.js";
4
+ } from "./index-tn46rr6w.js";
5
5
  import {
6
6
  addFieldUiPolicyForType,
7
7
  coerceFieldDefault,
@@ -34,15 +34,15 @@ import {
34
34
  sourceFile,
35
35
  validationCommandsForTarget,
36
36
  viaBuilderParameterName
37
- } from "./index-5em412h5.js";
37
+ } from "./index-g44fykfw.js";
38
38
  import {
39
39
  script
40
- } from "./index-8rr621r2.js";
40
+ } from "./index-ckpwq052.js";
41
41
  import {
42
42
  AppExecutor,
43
43
  LibExecutor,
44
44
  ModuleExecutor
45
- } from "./index-90zyjrby.js";
45
+ } from "./index-681sx6nt.js";
46
46
 
47
47
  // pkgs/@akanjs/cli/primitive/primitive.script.ts
48
48
  import { capitalize } from "akanjs/common";
@@ -5,7 +5,7 @@ import {
5
5
  } from "./index-76rn3g2c.js";
6
6
  import {
7
7
  CommandExecutionError
8
- } from "./index-90zyjrby.js";
8
+ } from "./index-681sx6nt.js";
9
9
 
10
10
  // pkgs/@akanjs/devkit/capacitorApp.ts
11
11
  import { cp, mkdir, readFile, rm, writeFile } from "fs/promises";
@@ -6,7 +6,7 @@ import {
6
6
  ModuleExecutor,
7
7
  PkgExecutor,
8
8
  WorkspaceExecutor
9
- } from "./index-90zyjrby.js";
9
+ } from "./index-681sx6nt.js";
10
10
  import {
11
11
  getDirname
12
12
  } from "./index-1577bej2.js";
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  AkanContextAnalyzer
4
- } from "./index-24h5bqpj.js";
4
+ } from "./index-wc19q8mb.js";
5
5
  import {
6
6
  WorkflowExecutor,
7
7
  compactWorkflowInputs,
@@ -23,10 +23,10 @@ import {
23
23
  workflowCommandsForPlan,
24
24
  workflowPlanApproval,
25
25
  writeWorkflowRunArtifact
26
- } from "./index-5em412h5.js";
26
+ } from "./index-g44fykfw.js";
27
27
  import {
28
28
  runner
29
- } from "./index-8rr621r2.js";
29
+ } from "./index-ckpwq052.js";
30
30
 
31
31
  // pkgs/@akanjs/cli/workflow/workflow.runner.ts
32
32
  import { mkdir, readFile, writeFile } from "fs/promises";
@@ -1,22 +1,22 @@
1
1
  // @bun
2
2
  import {
3
3
  RepairRunner
4
- } from "./index-5fe016p2.js";
4
+ } from "./index-ryns915y.js";
5
5
  import {
6
6
  WorkflowRunner
7
- } from "./index-k7sm38v6.js";
7
+ } from "./index-dvg362vq.js";
8
8
  import {
9
9
  ScalarScript
10
- } from "./index-7w5vv8jk.js";
10
+ } from "./index-4mtyaqj2.js";
11
11
  import {
12
12
  PrimitiveScript
13
- } from "./index-97cw8sg1.js";
13
+ } from "./index-cc1mgv1f.js";
14
14
  import {
15
15
  ModuleScript
16
- } from "./index-xrdrttjb.js";
16
+ } from "./index-tn46rr6w.js";
17
17
  import {
18
18
  isPlaceholderAppId
19
- } from "./index-zgkey4d0.js";
19
+ } from "./index-ce9755av.js";
20
20
  import {
21
21
  AkanContextAnalyzer,
22
22
  akanMcpInstallConfigPaths,
@@ -27,14 +27,14 @@ import {
27
27
  renderDoctorText,
28
28
  resourceList,
29
29
  upsertCodexMcpServerBlock
30
- } from "./index-24h5bqpj.js";
30
+ } from "./index-wc19q8mb.js";
31
31
  import {
32
32
  buildAkanModuleContextIndex,
33
33
  createWorkflowBaselineSummary,
34
34
  createWorkflowStepRegistry,
35
35
  jsonText,
36
36
  toolingRolloutGate
37
- } from "./index-5em412h5.js";
37
+ } from "./index-g44fykfw.js";
38
38
  import {
39
39
  Prompter
40
40
  } from "./index-j37qq1f2.js";
@@ -45,10 +45,10 @@ import {
45
45
  CommandContainer,
46
46
  runner,
47
47
  script
48
- } from "./index-8rr621r2.js";
48
+ } from "./index-ckpwq052.js";
49
49
  import {
50
50
  AppExecutor
51
- } from "./index-90zyjrby.js";
51
+ } from "./index-681sx6nt.js";
52
52
 
53
53
  // pkgs/@akanjs/cli/context/context.script.ts
54
54
  import { Logger } from "akanjs/common";
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-8rr621r2.js";
5
+ } from "./index-ckpwq052.js";
6
6
  import {
7
7
  LibExecutor
8
- } from "./index-90zyjrby.js";
8
+ } from "./index-681sx6nt.js";
9
9
 
10
10
  // pkgs/@akanjs/cli/semver.ts
11
11
  var stripRangeOperator = (version) => version.replace(/^[\s^~>=<v]+/, "").trim();
@@ -0,0 +1,255 @@
1
+ // @bun
2
+ // pkgs/@akanjs/devkit/artifact/implicitRootLayout.ts
3
+ import { mkdir } from "fs/promises";
4
+ import path from "path";
5
+ var LAYOUT_KEY_RE = /^\.\/(.+\/)?_layout\.(tsx|ts|jsx|js)$/;
6
+ async function appHasStModule(appCwdPath) {
7
+ return Bun.file(path.join(appCwdPath, "lib", "st.ts")).exists();
8
+ }
9
+ var IMPLICIT_LAYOUT_DIR = path.join(".akan", "generated", "root-layouts");
10
+ var IMPLICIT_DICT_DIR = path.join(".akan", "generated", "dict");
11
+ var IMPLICIT_OVERRIDES_DIR = path.join(".akan", "generated", "overrides");
12
+ var OVERRIDES_KEY_RE = /^\.\/(.+\/)?_overrides\.(tsx|ts|jsx|js)$/;
13
+ async function writeGeneratedOverridesLayoutFile(opts) {
14
+ const filename = `${opts.key.replace(/^\.\//, "").replace(/[^a-zA-Z0-9]+/g, "_")}.tsx`;
15
+ const absPath = path.join(path.resolve(opts.appCwdPath), IMPLICIT_OVERRIDES_DIR, filename);
16
+ const userRel = path.relative(path.dirname(absPath), opts.userAbsPath).split(path.sep).join("/");
17
+ const userSpecifier = userRel.startsWith(".") ? userRel : `./${userRel}`;
18
+ const source = `"use client";
19
+ import { UiOverrideProvider } from "akanjs/ui";
20
+ import { createElement, type ReactNode } from "react";
21
+ import value from ${JSON.stringify(userSpecifier)};
22
+
23
+ export default function AkanUiOverridesLayout({ children }: { children?: ReactNode }) {
24
+ return createElement(UiOverrideProvider, { value }, children);
25
+ }
26
+ `;
27
+ await Bun.write(absPath, source);
28
+ return absPath;
29
+ }
30
+ function getRootBoundarySegments(key) {
31
+ const match = LAYOUT_KEY_RE.exec(key);
32
+ if (!match)
33
+ return null;
34
+ const prefix = match[1]?.replace(/\/$/, "");
35
+ if (!prefix)
36
+ return [];
37
+ return prefix.split("/").filter(Boolean);
38
+ }
39
+ function implicitRootLayoutKey(segments) {
40
+ return `./${[...segments, "__root_layout"].join("/")}.tsx`;
41
+ }
42
+ function implicitRootLayoutAbsPath(appCwdPath, segments) {
43
+ const filename = segments.length ? `${segments.join("__")}__root_layout.tsx` : "__root_layout.tsx";
44
+ return path.join(path.resolve(appCwdPath), IMPLICIT_LAYOUT_DIR, filename);
45
+ }
46
+ function implicitDictionaryMacroAbsPath(appCwdPath) {
47
+ return path.join(path.resolve(appCwdPath), IMPLICIT_DICT_DIR, "useDict.ts");
48
+ }
49
+ function isRootBoundarySegments(segments, basePaths) {
50
+ const firstVisibleIndex = segments.findIndex((segment) => !/^\(.+\)$/.test(segment));
51
+ if (firstVisibleIndex === -1)
52
+ return segments.length <= 1;
53
+ if (segments.slice(firstVisibleIndex + 1).some((segment) => /^\(.+\)$/.test(segment)))
54
+ return false;
55
+ const visible = segments.slice(firstVisibleIndex);
56
+ const allowedBasePaths = new Set([...basePaths].map((basePath) => basePath.trim()).filter(Boolean));
57
+ return visible.length === 1 && (firstVisibleIndex > 0 || allowedBasePaths.has(visible[0] ?? ""));
58
+ }
59
+ function findRootBoundaries(pageKeys, appCwdPath, basePaths) {
60
+ const boundaries = new Map;
61
+ for (const key of pageKeys) {
62
+ const segments = getRootBoundarySegments(key);
63
+ if (!segments)
64
+ continue;
65
+ if (!isRootBoundarySegments(segments, basePaths))
66
+ continue;
67
+ const id = segments.join("/");
68
+ boundaries.set(id, {
69
+ sourceKey: key,
70
+ sourceAbsPath: path.resolve(appCwdPath, "page", key.replace(/^\.\//, "")),
71
+ segments
72
+ });
73
+ }
74
+ const hasExplicitRootBoundary = [...boundaries.values()].some((boundary) => boundary.segments.length === 0);
75
+ if (!hasExplicitRootBoundary && boundaries.size === 0) {
76
+ boundaries.set("", { sourceKey: null, sourceAbsPath: null, segments: [] });
77
+ }
78
+ return [...boundaries.values()].sort((a, b) => a.segments.join("/").localeCompare(b.segments.join("/")));
79
+ }
80
+ function hasAncestorRootBoundary(boundary, boundaries) {
81
+ return boundaries.some((candidate) => candidate !== boundary && candidate.segments.length < boundary.segments.length && candidate.segments.every((segment, index) => boundary.segments[index] === segment));
82
+ }
83
+ function findExplicitRootLayoutAbsPath(pageKeys, appCwdPath) {
84
+ const rootLayoutKey = pageKeys.find((key) => {
85
+ const segments = getRootBoundarySegments(key);
86
+ return segments !== null && segments.length === 0;
87
+ });
88
+ return rootLayoutKey ? path.resolve(appCwdPath, "page", rootLayoutKey.replace(/^\.\//, "")) : null;
89
+ }
90
+ function routePrefixForSegments(segments) {
91
+ const visible = segments.filter((segment) => !/^\(.+\)$/.test(segment));
92
+ return visible[0] ?? null;
93
+ }
94
+ async function assertEnvClientConvention(appCwdPath, appName) {
95
+ const envPath = path.join(appCwdPath, "env", "env.client.ts");
96
+ if (!await Bun.file(envPath).exists()) {
97
+ throw new Error(`[route-convention] app "${appName}" must provide env/env.client.ts exporting "env" for generated System.Provider`);
98
+ }
99
+ }
100
+ async function writeGeneratedDictionaryMacroFile(appCwdPath, appName) {
101
+ const absPath = implicitDictionaryMacroAbsPath(appCwdPath);
102
+ await mkdir(path.dirname(absPath), { recursive: true });
103
+ await Bun.write(absPath, `import { getAllDictionary } from "@apps/${appName}/lib/dict" with { type: "macro" };
104
+
105
+ export const allDictionary = getAllDictionary();
106
+ `);
107
+ return absPath;
108
+ }
109
+ async function writeGeneratedRootLayoutFile(opts) {
110
+ await assertEnvClientConvention(opts.appCwdPath, opts.appName);
111
+ const dictMacroAbsPath = opts.includeSystemProvider ? await writeGeneratedDictionaryMacroFile(opts.appCwdPath, opts.appName) : null;
112
+ const absPath = implicitRootLayoutAbsPath(opts.appCwdPath, opts.boundary.segments);
113
+ await mkdir(path.dirname(absPath), { recursive: true });
114
+ const dictMacroRel = dictMacroAbsPath ? path.relative(path.dirname(absPath), dictMacroAbsPath).split(path.sep).join("/") : null;
115
+ const dictMacroSpecifier = dictMacroRel ? dictMacroRel.startsWith(".") ? dictMacroRel : `./${dictMacroRel}` : null;
116
+ const sourceRel = opts.boundary.sourceAbsPath ? path.relative(path.dirname(absPath), opts.boundary.sourceAbsPath).split(path.sep).join("/") : null;
117
+ const sourceSpecifier = sourceRel ? sourceRel.startsWith(".") ? sourceRel : `./${sourceRel}` : null;
118
+ const inheritedSourceAbsPath = opts.rootSourceAbsPath && opts.rootSourceAbsPath !== opts.boundary.sourceAbsPath ? opts.rootSourceAbsPath : null;
119
+ const inheritedSourceRel = inheritedSourceAbsPath ? path.relative(path.dirname(absPath), inheritedSourceAbsPath).split(path.sep).join("/") : null;
120
+ const inheritedSourceSpecifier = inheritedSourceRel ? inheritedSourceRel.startsWith(".") ? inheritedSourceRel : `./${inheritedSourceRel}` : null;
121
+ const clientImport = opts.includeStInit ? `import { st } from "@apps/${opts.appName}/client";
122
+ void st;
123
+ ` : `import "@apps/${opts.appName}/client";
124
+ `;
125
+ const inheritedImport = inheritedSourceSpecifier ? `import * as inheritedLayout from ${JSON.stringify(inheritedSourceSpecifier)};
126
+ ` : `const inheritedLayout = {};
127
+ `;
128
+ const prefix = routePrefixForSegments(opts.boundary.segments);
129
+ const userImport = sourceSpecifier ? `import UserLayout, * as userLayout from ${JSON.stringify(sourceSpecifier)};
130
+ ` : `const UserLayout = ({ children }) => children;
131
+ const userLayout = {};
132
+ `;
133
+ const source = opts.includeSystemProvider ? `import type { LayoutProps, PageProps } from "akanjs/client";
134
+ import { loadFonts } from "akanjs/client";
135
+ import { System } from "akanjs/ui";
136
+ import { env } from "@apps/${opts.appName}/env/env.client";
137
+ import { allDictionary } from ${JSON.stringify(dictMacroSpecifier)};
138
+ ${clientImport}${inheritedImport}${userImport}
139
+ const userFonts = userLayout.fonts ?? inheritedLayout.fonts ?? [];
140
+ const defaultFonts = userFonts.filter((font) => font.default);
141
+ if (defaultFonts.length > 1) throw new Error("[route-convention] only one default font is allowed per root layout");
142
+ const defaultFont = defaultFonts[0];
143
+ const defaultFontClassName = defaultFont ? (defaultFont.className ?? \`font-\${defaultFont.name}\`) : undefined;
144
+
145
+ export async function generateHead(props: PageProps) {
146
+ if (userLayout.generateHead) return userLayout.generateHead(props);
147
+ if (userLayout.head !== undefined) return userLayout.head;
148
+ if (inheritedLayout.generateHead) return inheritedLayout.generateHead(props);
149
+ return inheritedLayout.head;
150
+ }
151
+
152
+ export async function generateMetadata(props: PageProps) {
153
+ if (userLayout.generateMetadata) return userLayout.generateMetadata(props);
154
+ if (userLayout.metadata !== undefined) return userLayout.metadata;
155
+ if (inheritedLayout.generateMetadata) return inheritedLayout.generateMetadata(props);
156
+ return inheritedLayout.metadata;
157
+ }
158
+
159
+ export const NotFound = userLayout.NotFound ?? inheritedLayout.NotFound;
160
+ export const Error = userLayout.Error ?? inheritedLayout.Error;
161
+ export const pageConfig = userLayout.pageConfig ?? inheritedLayout.pageConfig;
162
+
163
+ export default function GeneratedLayout({ children, params, searchParams }: LayoutProps) {
164
+ return (
165
+ <System.Provider
166
+ of={GeneratedLayout as never}
167
+ appName=${JSON.stringify(opts.appName)}
168
+ ${prefix ? `prefix=${JSON.stringify(prefix)}
169
+ ` : ""}params={params}
170
+ manifest={userLayout.manifest ?? inheritedLayout.manifest}
171
+ env={env}
172
+ theme={userLayout.theme ?? inheritedLayout.theme}
173
+ fonts={loadFonts(userFonts)}
174
+ className={defaultFontClassName}
175
+ gaTrackingId={userLayout.gaTrackingId ?? inheritedLayout.gaTrackingId}
176
+ layoutStyle={userLayout.layoutStyle ?? inheritedLayout.layoutStyle}
177
+ reconnect={userLayout.reconnect ?? inheritedLayout.reconnect ?? false}
178
+ wsConnect={userLayout.wsConnect ?? inheritedLayout.wsConnect ?? true}
179
+ allDictionary={process.env.AKAN_PUBLIC_RENDER_ENV === "ssr" ? allDictionary : undefined}
180
+ >
181
+ <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>
182
+ </System.Provider>
183
+ );
184
+ }
185
+ ` : `import type { LayoutProps, PageProps } from "akanjs/client";
186
+ ${inheritedImport}${userImport}
187
+ export async function generateHead(props: PageProps) {
188
+ if (userLayout.generateHead) return userLayout.generateHead(props);
189
+ if (userLayout.head !== undefined) return userLayout.head;
190
+ if (inheritedLayout.generateHead) return inheritedLayout.generateHead(props);
191
+ return inheritedLayout.head;
192
+ }
193
+
194
+ export async function generateMetadata(props: PageProps) {
195
+ if (userLayout.generateMetadata) return userLayout.generateMetadata(props);
196
+ if (userLayout.metadata !== undefined) return userLayout.metadata;
197
+ if (inheritedLayout.generateMetadata) return inheritedLayout.generateMetadata(props);
198
+ return inheritedLayout.metadata;
199
+ }
200
+
201
+ export const NotFound = userLayout.NotFound ?? inheritedLayout.NotFound;
202
+ export const Error = userLayout.Error ?? inheritedLayout.Error;
203
+ export const pageConfig = userLayout.pageConfig ?? inheritedLayout.pageConfig;
204
+
205
+ export default function GeneratedLayout({ children, params, searchParams }: LayoutProps) {
206
+ return <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>;
207
+ }
208
+ `;
209
+ await Bun.write(absPath, source);
210
+ return absPath;
211
+ }
212
+ async function resolveSsrPageEntries(opts) {
213
+ const absPageDir = path.resolve(opts.appCwdPath, "page");
214
+ const hasSt = await appHasStModule(opts.appCwdPath);
215
+ const basePaths = opts.basePaths ?? [];
216
+ const rootSourceAbsPath = findExplicitRootLayoutAbsPath(opts.pageKeys, opts.appCwdPath);
217
+ const rootBoundaries = findRootBoundaries(opts.pageKeys, opts.appCwdPath, basePaths);
218
+ const rootLayoutKeys = new Set(opts.pageKeys.filter((key) => {
219
+ const segments = getRootBoundarySegments(key);
220
+ return segments !== null && isRootBoundarySegments(segments, basePaths);
221
+ }));
222
+ const base = await Promise.all(opts.pageKeys.filter((key) => !rootLayoutKeys.has(key)).map(async (key) => {
223
+ const userAbsPath = path.resolve(absPageDir, key);
224
+ if (OVERRIDES_KEY_RE.test(key)) {
225
+ const moduleAbsPath = await writeGeneratedOverridesLayoutFile({
226
+ appCwdPath: opts.appCwdPath,
227
+ key,
228
+ userAbsPath
229
+ });
230
+ return { key, moduleAbsPath, seedAbsPaths: [userAbsPath] };
231
+ }
232
+ return { key, moduleAbsPath: userAbsPath };
233
+ }));
234
+ const generated = await Promise.all(rootBoundaries.map(async (boundary) => ({
235
+ key: implicitRootLayoutKey(boundary.segments),
236
+ moduleAbsPath: await writeGeneratedRootLayoutFile({
237
+ appCwdPath: opts.appCwdPath,
238
+ appName: opts.appName,
239
+ boundary,
240
+ rootSourceAbsPath,
241
+ includeStInit: hasSt && boundary.segments.length === 0,
242
+ includeSystemProvider: !hasAncestorRootBoundary(boundary, rootBoundaries)
243
+ }),
244
+ seedAbsPaths: [...new Set([boundary.sourceAbsPath, rootSourceAbsPath].filter((absPath) => absPath !== null))]
245
+ })));
246
+ const entries = [...base, ...generated];
247
+ entries.sort((a, b) => a.key.localeCompare(b.key));
248
+ return entries;
249
+ }
250
+ async function resolveSsrPageEntriesForApp(app, pageKeys) {
251
+ const config = await app.getConfig();
252
+ return resolveSsrPageEntries({ appCwdPath: app.cwdPath, appName: app.name, pageKeys, basePaths: config.basePaths });
253
+ }
254
+
255
+ export { getRootBoundarySegments, isRootBoundarySegments, resolveSsrPageEntriesForApp };
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  AppExecutor,
4
4
  LibExecutor
5
- } from "./index-90zyjrby.js";
5
+ } from "./index-681sx6nt.js";
6
6
 
7
7
  // pkgs/@akanjs/devkit/workflow/utils.ts
8
8
  var jsonText = (value, { trailingNewline = true } = {}) => `${JSON.stringify(value, null, 2)}${trailingNewline ? `