@akanjs/cli 3.2.0-rc.4 → 3.2.0-rc.6

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 (72) hide show
  1. package/.build-stamp +2 -2
  2. package/{CodeAgent-4a2skdph.js → CodeAgent-aq43sq64.js} +2 -2
  3. package/{CodeTui-enrzsnzc.js → CodeTui-pmychb3m.js} +1 -1
  4. package/TunnelShare-11a3fqxb.js +14 -0
  5. package/{agent.command-y22t9x1e.js → agent.command-pdmb75bk.js} +15 -15
  6. package/akanCode.js +2 -2
  7. package/{application.command-yhj5arwc.js → application.command-xwch7rww.js} +16 -16
  8. package/{applicationBuildRunner-6w1fd61b.js → applicationBuildRunner-6yjrxfqs.js} +7 -6
  9. package/buildBatch.proc.js +6 -6
  10. package/{cloud.command-bqfh4cnx.js → cloud.command-g9k7zb5s.js} +16 -16
  11. package/cloud.script-jttgtbch.js +30 -0
  12. package/{code.command-y94hwxsn.js → code.command-ceyhrgrc.js} +6 -6
  13. package/{context.command-xz65fhrn.js → context.command-n7dbh0ca.js} +16 -16
  14. package/context.runner-9d5rbt2p.js +29 -0
  15. package/{guideline.command-sn843nw6.js → guideline.command-h5dfzrng.js} +2 -2
  16. package/guidelines/agentRule/agentRule.instruction.md +4 -3
  17. package/incrementalBuilder.proc.js +4 -4
  18. package/{index-wfmpxke3.js → index-0fq1b5jp.js} +10 -2
  19. package/{index-3wen6ddy.js → index-146p5x0r.js} +3 -3
  20. package/{index-jqsj5wjb.js → index-1xfdzwrt.js} +3 -3
  21. package/{index-w15hnxmb.js → index-2b3n00gz.js} +6 -6
  22. package/{index-b9q5aw30.js → index-2m6gaatn.js} +8 -8
  23. package/{index-jxaq2evq.js → index-36dywqhv.js} +2 -2
  24. package/{index-kjmrkc45.js → index-3wvc8cfa.js} +4 -4
  25. package/{index-50mg8bsm.js → index-80yc5q5y.js} +3 -3
  26. package/{index-49y45vbj.js → index-8bh9en9m.js} +8 -8
  27. package/{index-vftjqv28.js → index-9km2h20g.js} +2 -2
  28. package/{index-qrp98bmp.js → index-bza4z89k.js} +4 -4
  29. package/{index-5hhe0rdd.js → index-df0r4008.js} +1 -1
  30. package/{index-z9b72teg.js → index-dnqznx16.js} +1 -1
  31. package/{index-ygrdw6jw.js → index-dtxntsfx.js} +1 -1
  32. package/{index-fqx74yxn.js → index-fq72hk0a.js} +2 -2
  33. package/{index-kr8dvqnr.js → index-g6ss1r1w.js} +1 -1
  34. package/{index-hkq0q73d.js → index-ggzb32a9.js} +1 -1
  35. package/{index-w88xghey.js → index-h4xv44b2.js} +7 -7
  36. package/{index-5qq6qky3.js → index-kj7vyjng.js} +8 -8
  37. package/{index-kgxhwgdk.js → index-mcdezskv.js} +2 -2
  38. package/{index-ah09graf.js → index-mtxbw4fy.js} +13 -11
  39. package/{index-jrdp7c4h.js → index-n0vev0fv.js} +2 -2
  40. package/{index-y725zb1a.js → index-p9f6dsf2.js} +70 -23
  41. package/{index-5w8amdr7.js → index-qtcm6s8p.js} +22 -8
  42. package/{index-3rff2c48.js → index-qx12c8k5.js} +1 -1
  43. package/{index-sjj3ywn5.js → index-t0a5mng5.js} +4 -4
  44. package/{index-jgj6ajnk.js → index-ttrrm805.js} +4 -4
  45. package/{index-gsty3pkx.js → index-w0nztbs0.js} +3 -3
  46. package/{index-8vxdsqra.js → index-wnxc9n5v.js} +25 -9
  47. package/{index-2rcptfyp.js → index-xzscbgx2.js} +1 -1
  48. package/{index-8jpc5fqv.js → index-y1a7dc7t.js} +1 -1
  49. package/{index-g43360sn.js → index-y9xbhs20.js} +3 -3
  50. package/{index-4mgabs8t.js → index-yp6mpazs.js} +3 -3
  51. package/{index-02b8qvww.js → index-z0r6bhqe.js} +2 -2
  52. package/index.js +23 -23
  53. package/{library.command-6eafevmj.js → library.command-4c2yjfqa.js} +3 -3
  54. package/{localRegistry.command-9tef2qsj.js → localRegistry.command-ef65g36k.js} +15 -15
  55. package/{module.command-pn1k7dfk.js → module.command-c6284z1b.js} +5 -5
  56. package/{package.command-kbg9z7re.js → package.command-3wh1hh2j.js} +4 -4
  57. package/package.json +2 -2
  58. package/{page.command-st0y2xg8.js → page.command-sx22j4yv.js} +3 -3
  59. package/{pipeline.command-76m32y7z.js → pipeline.command-8kdcgy47.js} +2 -2
  60. package/{primitive.command-ax6wg70s.js → primitive.command-4jaegn0m.js} +6 -6
  61. package/{projectTypecheck-s9hhe5sa.js → projectTypecheck-t0r9argb.js} +1 -1
  62. package/{quality.command-0gzskga8.js → quality.command-46jhrbm2.js} +4 -4
  63. package/{repair.command-g5kc3x89.js → repair.command-dj4ke29k.js} +5 -5
  64. package/{scalar.command-ck8621dy.js → scalar.command-qwvbhytf.js} +4 -4
  65. package/{subspace.command-vh6dye0v.js → subspace.command-hg0hqscf.js} +8 -8
  66. package/{tunnel.command-4mezrypt.js → tunnel.command-00v81x42.js} +7 -7
  67. package/{verify.command-f2n4bwp7.js → verify.command-sz542tvy.js} +12 -12
  68. package/{workflow.command-bx9xwgs5.js → workflow.command-0ra9304f.js} +10 -10
  69. package/{workspace.command-04qgwsst.js → workspace.command-zvnybhr6.js} +29 -29
  70. package/TunnelShare-xs5rrpf1.js +0 -14
  71. package/cloud.script-8jvfw1sh.js +0 -30
  72. package/context.runner-dpt5wjb7.js +0 -29
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  JsonFormatter
4
- } from "./index-wfmpxke3.js";
4
+ } from "./index-0fq1b5jp.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/applicationBuildReporter.ts
7
7
  import { realpathSync } from "fs";
@@ -694,47 +694,74 @@ class RouteJsBudget {
694
694
  brotliBytes: urls.reduce((total, url) => total + (sizeByUrl.get(url)?.brotli ?? 0), 0)
695
695
  })).sort((a, b) => b.brotliBytes - a.brotliBytes || RouteJsBudget.#byCodeUnit(a.routeId, b.routeId));
696
696
  }
697
+ static modeOf({ checkBudget = false, updateBudget = false, raiseBudget = false }) {
698
+ if ([checkBudget, updateBudget, raiseBudget].filter(Boolean).length > 1)
699
+ throw new Error("Pass at most one of --check-budget, --update-budget and --raise-budget.");
700
+ return checkBudget ? "enforce" : updateBudget ? "update" : raiseBudget ? "raise" : "report";
701
+ }
697
702
  static async load(filePath, source = filePath) {
698
703
  const file = Bun.file(filePath);
699
704
  if (!await file.exists())
700
705
  return null;
701
706
  return RouteJsBudget.parse(await file.text(), source);
702
707
  }
703
- static async check(sizes, { mode, budgetPath, source, environment }) {
708
+ static async check(sizes, check) {
709
+ const { mode, app, budgetPath, source, environment } = check;
704
710
  const { committed, unreadable } = await RouteJsBudget.#loadFor(mode, budgetPath, source);
705
- const budget = mode === "update" ? (committed ?? new RouteJsBudget).tightenedBy(sizes, environment) : committed;
706
- if (mode === "update" && budget)
711
+ if (mode === "enforce" && !committed)
712
+ throw new Error(`--check-budget found no ${source}: record one with \`akan build ${app} --update-budget\`.`);
713
+ const budget = mode === "raise" ? new RouteJsBudget().tightenedBy(sizes, environment) : mode === "update" ? (committed ?? new RouteJsBudget).tightenedBy(sizes, environment) : committed;
714
+ if ((mode === "update" || mode === "raise") && budget)
707
715
  await Bun.write(budgetPath, budget.stringify());
708
716
  const overages = budget?.overages(sizes) ?? [];
717
+ const unbudgeted = budget?.unbudgeted(sizes) ?? [];
709
718
  const envNote = committed?.envNote(environment) ?? "";
710
- if (overages.length && mode !== "report")
711
- throw new Error(RouteJsBudget.formatOverages(overages, source, envNote));
712
- const unbudgeted = budget?.unbudgeted(sizes).length ?? 0;
713
- if (mode === "update")
714
- return { summary: `${source} ${unreadable ? `rewritten (${unreadable})` : "updated"}` };
719
+ const target = { app, source };
720
+ const failures = [
721
+ ...overages.length && mode !== "report" ? [RouteJsBudget.formatOverages(overages, target, envNote)] : [],
722
+ ...unbudgeted.length && mode === "enforce" ? [RouteJsBudget.formatUnbudgeted(unbudgeted, target)] : []
723
+ ];
724
+ if (failures.length)
725
+ throw new Error(failures.join(`
726
+ `));
727
+ if (mode === "update" || mode === "raise")
728
+ return { summary: RouteJsBudget.#writtenSummary(check, unreadable, committed, budget) };
715
729
  if (unreadable)
716
730
  return {
717
731
  summary: `${unreadable}, not checked`,
718
732
  warnings: [
719
733
  {
720
734
  file: source,
721
- message: `${unreadable}; akan build fails on it`,
722
- fix: "correct it, or rewrite it with akan build <app> --update-budget"
735
+ message: `${unreadable}; akan build --check-budget fails on it`,
736
+ fix: `correct it, or rewrite it with akan build ${app} --update-budget`
723
737
  }
724
738
  ]
725
739
  };
726
740
  if (!budget)
727
741
  return { summary: `no ${RouteJsBudget.fileName}` };
728
- if (overages.length)
729
- return {
730
- summary: `${overages.length} route(s) over ${source}${envNote}, reported only: ${overages.map(({ routeId }) => routeId).join(", ")}`,
731
- warnings: overages.map(({ routeId, brotliBytes, limitBytes }) => ({
732
- file: source,
733
- message: `${routeId} loads ${RouteJsBudget.#bytes(brotliBytes)} bytes brotli, over its limit of ${RouteJsBudget.#bytes(limitBytes)}${envNote}; akan build fails on it`,
734
- fix: "shrink what the route loads, or raise its entry by hand in the same change"
735
- }))
736
- };
737
- return { summary: `within ${source}${envNote}${unbudgeted ? `, ${unbudgeted} route(s) without an entry` : ""}` };
742
+ const warnings = [
743
+ ...overages.map(({ routeId, brotliBytes, limitBytes }) => ({
744
+ file: source,
745
+ message: `${routeId} loads ${RouteJsBudget.#bytes(brotliBytes)} bytes brotli, over its limit of ${RouteJsBudget.#bytes(limitBytes)}${envNote}; akan build --check-budget fails on it`,
746
+ fix: `shrink what the route loads, or raise its entry with akan build ${app} --raise-budget`
747
+ })),
748
+ ...unbudgeted.map((routeId) => ({
749
+ file: source,
750
+ message: `${routeId} has no entry; akan build --check-budget fails on it`,
751
+ fix: `record it with akan build ${app} --update-budget`
752
+ }))
753
+ ];
754
+ const verdict = overages.length ? `${overages.length} route(s) over ${source}${envNote}, reported only: ${overages.map(({ routeId }) => routeId).join(", ")}` : `within ${source}${envNote}`;
755
+ const unbudgetedNote = unbudgeted.length ? `; ${unbudgeted.length} route(s) without an entry` : "";
756
+ return { summary: `${verdict}${unbudgetedNote}`, ...warnings.length ? { warnings } : {} };
757
+ }
758
+ static #writtenSummary({ mode, source }, unreadable, committed, written) {
759
+ if (unreadable)
760
+ return `${source} rewritten (${unreadable})`;
761
+ if (mode === "update")
762
+ return `${source} updated`;
763
+ const raised = [...written?.kbByRoute ?? []].filter(([routeId, kb]) => kb > (committed?.kbByRoute.get(routeId) ?? kb));
764
+ return `${source} re-recorded at each route's measured size${raised.length ? `, raised: ${raised.map(([routeId]) => routeId).join(", ")}` : ""}`;
738
765
  }
739
766
  static async#loadFor(mode, budgetPath, source) {
740
767
  try {
@@ -778,15 +805,27 @@ class RouteJsBudget {
778
805
  ...sizes.length > shown.length ? [` \u2026and ${sizes.length - shown.length} more`] : []
779
806
  ];
780
807
  }
781
- static formatOverages(overages, source, envNote = "") {
808
+ static formatOverages(overages, target, envNote = "") {
782
809
  const bytes = RouteJsBudget.#bytes;
810
+ const { source } = target;
783
811
  return [
784
812
  `${overages.length} route${overages.length === 1 ? "" : "s"} over the JS budget in ${source}${envNote}:`,
785
813
  ...overages.map(({ routeId, brotliBytes, budgetKB, limitBytes }) => ` ${routeId}: ${bytes(brotliBytes)} bytes brotli, over its limit of ${bytes(limitBytes)} (${budgetKB}KB + the larger of 1% and 4KB)`),
786
- "Shrink what the route loads. If the growth is intended, raise its entry by hand in the same change."
814
+ RouteJsBudget.#overageFix(target)
787
815
  ].join(`
788
816
  `);
789
817
  }
818
+ static formatUnbudgeted(routeIds, { app, source }) {
819
+ return [
820
+ `${routeIds.length} route${routeIds.length === 1 ? "" : "s"} with no entry in ${source}, which --check-budget checks every route against:`,
821
+ ...routeIds.map((routeId) => ` ${routeId}`),
822
+ `Record ${routeIds.length === 1 ? "it" : "them"} in the same change: \`akan build ${app} --update-budget\` adds each new route at its measured size.`
823
+ ].join(`
824
+ `);
825
+ }
826
+ static #overageFix({ app, source }) {
827
+ return `Shrink what the route loads. If the growth is intended, record it in the same change: \`akan build ${app} --raise-budget\` re-records every route at its measured size, or raise the route's entry under "${RouteJsBudget.section}" in ${source} by hand.`;
828
+ }
790
829
  static #bytes(value) {
791
830
  return value.toLocaleString("en-US");
792
831
  }
@@ -838,12 +877,20 @@ class ApplicationBuildReporter {
838
877
  Logger.rawLog(line);
839
878
  Logger.rawLog("");
840
879
  }
880
+ if (result.routeJsWarnings?.length) {
881
+ ApplicationBuildReporter.printRouteJsWarnings(result);
882
+ Logger.rawLog("");
883
+ }
841
884
  Logger.rawLog(`Route artifacts: ${result.artifactDir}`);
842
885
  Logger.rawLog(`Server output: ${result.outputDir}`);
843
886
  Logger.rawLog(`Done in ${ApplicationBuildReporter.formatDuration(result.durationMs)}`);
844
887
  if (result.environment === "local")
845
888
  Logger.rawLog(ApplicationBuildReporter.localBuildNotice);
846
889
  }
890
+ static printRouteJsWarnings({ routeJsWarnings = [] }) {
891
+ for (const { file, message, fix } of routeJsWarnings)
892
+ Logger.rawLog(`Warning: ${file}: ${message} (${fix})`);
893
+ }
847
894
  static localBuildNotice = "Built for local: the server runs without endpoint rate limits, and boots on local defaults (Redis on localhost, the first database mode) where a deployment would stop to ask. For a host others can reach, run `akan build <app> --env main` with AKAN_PUBLIC_REPO_NAME and AKAN_PUBLIC_SERVE_DOMAIN set in the shell or the workspace .env.";
848
895
  static formatError(error, workspaceRoot = process.cwd()) {
849
896
  if (error instanceof AggregateError) {
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  SOURCE_EXTS,
7
7
  WatchRootResolver
8
- } from "./index-y725zb1a.js";
8
+ } from "./index-p9f6dsf2.js";
9
9
  import {
10
10
  loaderFor,
11
11
  BarrelAnalyzer,
@@ -21,12 +21,12 @@ import {
21
21
  CsrDevPaths,
22
22
  PagesEntrySourceGenerator,
23
23
  PagesBundleBuilder
24
- } from "./index-3rff2c48.js";
24
+ } from "./index-qx12c8k5.js";
25
25
  import {
26
26
  AsyncDefaultExportDetector,
27
27
  StoreBootstrap,
28
28
  resolveSsrPageEntriesForApp
29
- } from "./index-wfmpxke3.js";
29
+ } from "./index-0fq1b5jp.js";
30
30
 
31
31
  // pkgs/@akanjs/devkit/frontendBuild/autoImportSync.ts
32
32
  import { readdir, readFile, stat } from "fs/promises";
@@ -590,6 +590,7 @@ class GraphClientEntryDiscovery {
590
590
  #resolvedFileCache = new Map;
591
591
  #resolvedSpecifierCache = new Map;
592
592
  #reachableEntriesCache = new Map;
593
+ #swappedEntriesCaches = new WeakMap;
593
594
  #readFiles = new Set;
594
595
  #barrelImporters = new Map;
595
596
  #reread = new Map;
@@ -603,17 +604,27 @@ class GraphClientEntryDiscovery {
603
604
  static async create(app) {
604
605
  return new GraphClientEntryDiscovery(await app.getConfig(), await createTsconfigPackageResolver(app));
605
606
  }
606
- async discover(seeds) {
607
+ async discover(seeds, { importsAs } = {}) {
607
608
  this.#settled = this.#settled.then(() => this.#dropRenarrowed());
608
609
  await this.#settled;
609
610
  const entries = new Set;
611
+ const reachable = importsAs ? this.#swappedEntriesCache(importsAs) : this.#reachableEntriesCache;
610
612
  for (const seed of seeds) {
611
- const walk = { visiting: new Set, partial: new Set, memo: new Map };
613
+ const walk = { visiting: new Set, partial: new Set, memo: new Map, importsAs, reachable };
612
614
  for (const entry of await this.#discoverFromFile(seed, walk))
613
615
  entries.add(entry);
614
616
  }
615
617
  return Array.from(entries).sort();
616
618
  }
619
+ async resolveImport(spec, importerDir) {
620
+ const resolved = await this.#resolveSpecifier(spec, importerDir);
621
+ return resolved ? path2.resolve(resolved) : null;
622
+ }
623
+ #swappedEntriesCache(importsAs) {
624
+ const cache = this.#swappedEntriesCaches.get(importsAs) ?? new Map;
625
+ this.#swappedEntriesCaches.set(importsAs, cache);
626
+ return cache;
627
+ }
617
628
  invalidate(files) {
618
629
  if (files.length === 0)
619
630
  return;
@@ -630,6 +641,7 @@ class GraphClientEntryDiscovery {
630
641
  }
631
642
  this.#epoch += 1;
632
643
  this.#reachableEntriesCache.clear();
644
+ this.#swappedEntriesCaches = new WeakMap;
633
645
  for (const [barrel, before] of this.#analyzer.forget(files))
634
646
  if (!this.#reread.has(barrel))
635
647
  this.#reread.set(barrel, before);
@@ -734,7 +746,8 @@ class GraphClientEntryDiscovery {
734
746
  async#discoverFromFile(file, walk) {
735
747
  const epoch = this.#epoch;
736
748
  const absPath = path2.resolve(file);
737
- const cached = this.#reachableEntriesCache.get(absPath);
749
+ const importsAs = walk.importsAs?.get(absPath);
750
+ const cached = walk.reachable.get(absPath);
738
751
  if (cached)
739
752
  return new Set(cached);
740
753
  const memo = walk.memo.get(absPath);
@@ -767,7 +780,8 @@ class GraphClientEntryDiscovery {
767
780
  }
768
781
  const importerDir = path2.dirname(absPath);
769
782
  for (const imp of facts.imports) {
770
- const spec = imp.path;
783
+ const swapped = importsAs?.get(imp.path);
784
+ const spec = swapped === undefined ? imp.path : swapped;
771
785
  if (!spec)
772
786
  continue;
773
787
  if (NON_SOURCE_EXT_RE.test(spec))
@@ -786,7 +800,7 @@ class GraphClientEntryDiscovery {
786
800
  walk.visiting.delete(absPath);
787
801
  walk.memo.set(absPath, entries);
788
802
  if (epoch === this.#epoch && !walk.partial.has(absPath))
789
- this.#reachableEntriesCache.set(absPath, entries);
803
+ walk.reachable.set(absPath, entries);
790
804
  return new Set(entries);
791
805
  }
792
806
  }
@@ -3,7 +3,7 @@ import {
3
3
  AsyncDefaultExportDetector,
4
4
  StoreBootstrap,
5
5
  resolveSsrPageEntriesForApp
6
- } from "./index-wfmpxke3.js";
6
+ } from "./index-0fq1b5jp.js";
7
7
  import {
8
8
  FileSys2
9
9
  } from "./index-bns3wcpc.js";
@@ -1,12 +1,12 @@
1
1
  // @bun
2
2
  import {
3
3
  script
4
- } from "./index-hkq0q73d.js";
4
+ } from "./index-ggzb32a9.js";
5
5
  import {
6
6
  AppExecutor,
7
7
  LibExecutor,
8
8
  ModuleExecutor
9
- } from "./index-wfmpxke3.js";
9
+ } from "./index-0fq1b5jp.js";
10
10
  import {
11
11
  InteractionScaffold,
12
12
  workflowStatus,
@@ -45,10 +45,10 @@ import {
45
45
  addFieldUiPolicyForType,
46
46
  KeyRename,
47
47
  MutationScaffold
48
- } from "./index-02b8qvww.js";
48
+ } from "./index-z0r6bhqe.js";
49
49
  import {
50
50
  ModuleScript
51
- } from "./index-jgj6ajnk.js";
51
+ } from "./index-ttrrm805.js";
52
52
  import {
53
53
  plainNameProblem
54
54
  } from "./index-va90m8nd.js";
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-hkq0q73d.js";
5
+ } from "./index-ggzb32a9.js";
6
6
  import {
7
7
  ModuleExecutor
8
- } from "./index-wfmpxke3.js";
8
+ } from "./index-0fq1b5jp.js";
9
9
  import {
10
10
  sourceFile,
11
11
  moduleSourcePaths,
@@ -13,10 +13,10 @@ import {
13
13
  createPassedPrimitiveReport,
14
14
  bilingualLabelForField,
15
15
  bilingualDescriptionForField
16
- } from "./index-02b8qvww.js";
16
+ } from "./index-z0r6bhqe.js";
17
17
  import {
18
18
  PageScript
19
- } from "./index-z9b72teg.js";
19
+ } from "./index-dnqznx16.js";
20
20
  import {
21
21
  pluralizeName
22
22
  } from "./index-nz8prx9g.js";
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-hkq0q73d.js";
5
+ } from "./index-ggzb32a9.js";
6
6
  import {
7
7
  FileSys2
8
8
  } from "./index-bns3wcpc.js";
9
9
  import {
10
10
  PkgExecutor
11
- } from "./index-wfmpxke3.js";
11
+ } from "./index-0fq1b5jp.js";
12
12
  import {
13
13
  TypeScriptDependencyScanner2
14
14
  } from "./index-qd7xn2bk.js";
@@ -17,7 +17,7 @@ import {
17
17
  } from "./index-cmg5ngqa.js";
18
18
  import {
19
19
  MaintainabilityBaseline
20
- } from "./index-ygrdw6jw.js";
20
+ } from "./index-dtxntsfx.js";
21
21
  import {
22
22
  assertPackageName
23
23
  } from "./index-va90m8nd.js";
@@ -1,7 +1,9 @@
1
1
  // @bun
2
2
  import {
3
+ ROOT_LAYOUT_SYSTEM,
4
+ isImplicitRootLayoutKey,
3
5
  resolveSsrPageEntriesForApp
4
- } from "./index-wfmpxke3.js";
6
+ } from "./index-0fq1b5jp.js";
5
7
  import {
6
8
  computeRouteSeedIndex,
7
9
  saveRouteSeedIndex,
@@ -9,12 +11,12 @@ import {
9
11
  ClientEntriesBundler,
10
12
  VENDOR_SPECIFIERS,
11
13
  RouteClientBuilder
12
- } from "./index-5w8amdr7.js";
14
+ } from "./index-qtcm6s8p.js";
13
15
  import {
14
16
  SOURCE_EXTS,
15
17
  FontOptimizer,
16
18
  FontPruner
17
- } from "./index-y725zb1a.js";
19
+ } from "./index-p9f6dsf2.js";
18
20
  import {
19
21
  BarrelAnalyzer,
20
22
  createTsconfigPackageResolver,
@@ -22,7 +24,7 @@ import {
22
24
  CsrEntryFiles,
23
25
  toClientReferencePath,
24
26
  PagesBundleBuilder
25
- } from "./index-3rff2c48.js";
27
+ } from "./index-qx12c8k5.js";
26
28
  import {
27
29
  CssBlockParser
28
30
  } from "./index-62md4dwy.js";
@@ -98,7 +100,7 @@ class AllRoutesBuilder {
98
100
  };
99
101
  #knownSet = new Set;
100
102
  #routeIds = [];
101
- #entriesByRoute = new Map;
103
+ #ssrEntriesByRoute = new Map;
102
104
  #externalsByChunkUrl = {};
103
105
  #discovery = null;
104
106
  constructor(app, command = "start") {
@@ -111,14 +113,16 @@ class AllRoutesBuilder {
111
113
  const pageEntries = await resolveSsrPageEntriesForApp(this.#app, pageKeys);
112
114
  const seedIndex = computeRouteSeedIndex(pageEntries);
113
115
  this.#app.verbose(`[build-all] discovered ${seedIndex.entries.length} routes`);
114
- this.#discovery = await GraphClientEntryDiscovery.create(this.#app);
116
+ const discovery = await GraphClientEntryDiscovery.create(this.#app);
117
+ this.#discovery = discovery;
118
+ const importsAs = await this.#ssrImportsAs(discovery, pageEntries);
115
119
  const allEntries = new Set;
116
120
  for (const entry of seedIndex.entries) {
117
121
  const seeds = Array.from(new Set([...seedIndex.globalLayoutFiles, ...entry.seeds]));
118
- const routeEntries = await this.#discovery.discover(seeds);
122
+ const routeEntries = await discovery.discover(seeds);
119
123
  for (const discovered of routeEntries)
120
124
  allEntries.add(discovered);
121
- this.#entriesByRoute.set(entry.routeId, routeEntries);
125
+ this.#ssrEntriesByRoute.set(entry.routeId, await discovery.discover(seeds, { importsAs }));
122
126
  this.#routeIds.push(entry.routeId);
123
127
  }
124
128
  this.#app.verbose(`[build-all] ${allEntries.size} client entries across ${this.#routeIds.length} routes`);
@@ -134,10 +138,22 @@ class AllRoutesBuilder {
134
138
  this.#app.verbose(`[build-all] wrote ${manifestPath} routes=${this.#routeIds.length} entries=${this.#merged.knownEntries.length}`);
135
139
  return { manifest, manifestPath, seedIndex };
136
140
  }
141
+ async#ssrImportsAs(discovery, pageEntries) {
142
+ const { specifier, ssrShell, importsNoSsrPageRenders } = ROOT_LAYOUT_SYSTEM;
143
+ const importsAs = new Map;
144
+ const toShell = new Map([[specifier, ssrShell]]);
145
+ for (const { key, moduleAbsPath } of pageEntries)
146
+ if (isImplicitRootLayoutKey(key))
147
+ importsAs.set(path.resolve(moduleAbsPath), toShell);
148
+ const system = await discovery.resolveImport(specifier, this.#app.cwdPath);
149
+ if (system)
150
+ importsAs.set(system, new Map(importsNoSsrPageRenders.map((spec) => [spec, null])));
151
+ return importsAs;
152
+ }
137
153
  async writeModulePreloads(runtimeChunks) {
138
154
  const preloads = new RouteModulePreloads({
139
155
  runtimeChunks,
140
- entriesByRoute: this.#entriesByRoute,
156
+ entriesByRoute: this.#ssrEntriesByRoute,
141
157
  clientManifest: this.#merged.clientManifest,
142
158
  externalsByChunkUrl: this.#externalsByChunkUrl,
143
159
  workspaceRoot: this.#app.workspace.workspaceRoot
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  GlobalConfig,
4
4
  CloudApi
5
- } from "./index-vftjqv28.js";
5
+ } from "./index-9km2h20g.js";
6
6
 
7
7
  // pkgs/@akanjs/cli/tunnel/TunnelShare.ts
8
8
  import { TunnelAgent } from "akanjs/server/tunnel";
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  AppInfo
4
- } from "./index-wfmpxke3.js";
4
+ } from "./index-0fq1b5jp.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/slicePlanner.ts
7
7
  class SlicePlanner {
@@ -5,17 +5,17 @@ import {
5
5
  AkanAppConfig,
6
6
  Executor,
7
7
  WorkspaceExecutor
8
- } from "./index-wfmpxke3.js";
8
+ } from "./index-0fq1b5jp.js";
9
9
  import {
10
10
  resolveAppId,
11
11
  targetHtmlFilename
12
12
  } from "./index-m9jj544v.js";
13
13
  import {
14
14
  CsrArtifactBuilder
15
- } from "./index-jxaq2evq.js";
15
+ } from "./index-36dywqhv.js";
16
16
  import {
17
17
  ExitCodeError
18
- } from "./index-hkq0q73d.js";
18
+ } from "./index-ggzb32a9.js";
19
19
 
20
20
  // pkgs/@akanjs/devkit/mobile/desktopBin.ts
21
21
  import { chmod, mkdir, rename, rm, writeFile } from "fs/promises";
@@ -1,17 +1,17 @@
1
1
  // @bun
2
2
  import {
3
3
  AkanContextAnalyzer
4
- } from "./index-fqx74yxn.js";
4
+ } from "./index-fq72hk0a.js";
5
5
  import {
6
6
  writeWorkflowRunArtifact,
7
7
  generatedFilePathsForTarget,
8
8
  writeGeneratedSyncState,
9
9
  createRepairReport,
10
10
  renderRepairReport
11
- } from "./index-02b8qvww.js";
11
+ } from "./index-z0r6bhqe.js";
12
12
  import {
13
13
  runner
14
- } from "./index-hkq0q73d.js";
14
+ } from "./index-ggzb32a9.js";
15
15
  import {
16
16
  isWorkflowSysName,
17
17
  isWorkflowModuleName
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  AppExecutor,
4
4
  LibExecutor
5
- } from "./index-wfmpxke3.js";
5
+ } from "./index-0fq1b5jp.js";
6
6
  import {
7
7
  createAst,
8
8
  AkanIndex
@@ -13,7 +13,7 @@ import {
13
13
  } from "./index-va90m8nd.js";
14
14
  import {
15
15
  camelToKebabCase
16
- } from "./index-hkq0q73d.js";
16
+ } from "./index-ggzb32a9.js";
17
17
 
18
18
  // pkgs/@akanjs/devkit/workflow/artifacts.ts
19
19
  import { capitalize as capitalize2 } from "akanjs/common";
package/index.js CHANGED
@@ -4,9 +4,9 @@ import {
4
4
  getTargetMetas,
5
5
  getTargetCommandNames,
6
6
  runCommands
7
- } from "./index-hkq0q73d.js";
7
+ } from "./index-ggzb32a9.js";
8
8
  import"./index-bns3wcpc.js";
9
- import"./index-wfmpxke3.js";
9
+ import"./index-0fq1b5jp.js";
10
10
 
11
11
  // pkgs/@akanjs/cli/bunVersionGuard.ts
12
12
  class BunVersionGuard {
@@ -22,27 +22,27 @@ import path from "path";
22
22
 
23
23
  // pkgs/@akanjs/cli/commandModules.ts
24
24
  var commandModules = {
25
- workspace: async () => (await import("./workspace.command-04qgwsst.js")).WorkspaceCommand,
26
- agent: async () => (await import("./agent.command-y22t9x1e.js")).AgentCommand,
27
- code: async () => (await import("./code.command-y94hwxsn.js")).CodeCommand,
28
- application: async () => (await import("./application.command-yhj5arwc.js")).ApplicationCommand,
29
- library: async () => (await import("./library.command-6eafevmj.js")).LibraryCommand,
30
- localRegistry: async () => (await import("./localRegistry.command-9tef2qsj.js")).LocalRegistryCommand,
31
- package: async () => (await import("./package.command-kbg9z7re.js")).PackageCommand,
32
- module: async () => (await import("./module.command-pn1k7dfk.js")).ModuleCommand,
33
- page: async () => (await import("./page.command-st0y2xg8.js")).PageCommand,
34
- context: async () => (await import("./context.command-xz65fhrn.js")).ContextCommand,
35
- cloud: async () => (await import("./cloud.command-bqfh4cnx.js")).CloudCommand,
36
- subspace: async () => (await import("./subspace.command-vh6dye0v.js")).SubspaceCommand,
37
- guideline: async () => (await import("./guideline.command-sn843nw6.js")).GuidelineCommand,
38
- scalar: async () => (await import("./scalar.command-ck8621dy.js")).ScalarCommand,
39
- primitive: async () => (await import("./primitive.command-ax6wg70s.js")).PrimitiveCommand,
40
- quality: async () => (await import("./quality.command-0gzskga8.js")).QualityCommand,
41
- verify: async () => (await import("./verify.command-f2n4bwp7.js")).VerifyCommand,
42
- repair: async () => (await import("./repair.command-g5kc3x89.js")).RepairCommand,
43
- workflow: async () => (await import("./workflow.command-bx9xwgs5.js")).WorkflowCommand,
44
- pipeline: async () => (await import("./pipeline.command-76m32y7z.js")).PipelineCommand,
45
- tunnel: async () => (await import("./tunnel.command-4mezrypt.js")).TunnelCommand
25
+ workspace: async () => (await import("./workspace.command-zvnybhr6.js")).WorkspaceCommand,
26
+ agent: async () => (await import("./agent.command-pdmb75bk.js")).AgentCommand,
27
+ code: async () => (await import("./code.command-ceyhrgrc.js")).CodeCommand,
28
+ application: async () => (await import("./application.command-xwch7rww.js")).ApplicationCommand,
29
+ library: async () => (await import("./library.command-4c2yjfqa.js")).LibraryCommand,
30
+ localRegistry: async () => (await import("./localRegistry.command-ef65g36k.js")).LocalRegistryCommand,
31
+ package: async () => (await import("./package.command-3wh1hh2j.js")).PackageCommand,
32
+ module: async () => (await import("./module.command-c6284z1b.js")).ModuleCommand,
33
+ page: async () => (await import("./page.command-sx22j4yv.js")).PageCommand,
34
+ context: async () => (await import("./context.command-n7dbh0ca.js")).ContextCommand,
35
+ cloud: async () => (await import("./cloud.command-g9k7zb5s.js")).CloudCommand,
36
+ subspace: async () => (await import("./subspace.command-hg0hqscf.js")).SubspaceCommand,
37
+ guideline: async () => (await import("./guideline.command-h5dfzrng.js")).GuidelineCommand,
38
+ scalar: async () => (await import("./scalar.command-qwvbhytf.js")).ScalarCommand,
39
+ primitive: async () => (await import("./primitive.command-4jaegn0m.js")).PrimitiveCommand,
40
+ quality: async () => (await import("./quality.command-46jhrbm2.js")).QualityCommand,
41
+ verify: async () => (await import("./verify.command-sz542tvy.js")).VerifyCommand,
42
+ repair: async () => (await import("./repair.command-dj4ke29k.js")).RepairCommand,
43
+ workflow: async () => (await import("./workflow.command-0ra9304f.js")).WorkflowCommand,
44
+ pipeline: async () => (await import("./pipeline.command-8kdcgy47.js")).PipelineCommand,
45
+ tunnel: async () => (await import("./tunnel.command-00v81x42.js")).TunnelCommand
46
46
  };
47
47
  var commandModuleIds = Object.keys(commandModules);
48
48
 
@@ -3,12 +3,12 @@ import {
3
3
  Lib,
4
4
  Workspace,
5
5
  command
6
- } from "./index-hkq0q73d.js";
6
+ } from "./index-ggzb32a9.js";
7
7
  import"./index-bns3wcpc.js";
8
- import"./index-wfmpxke3.js";
8
+ import"./index-0fq1b5jp.js";
9
9
  import {
10
10
  LibraryScript
11
- } from "./index-jrdp7c4h.js";
11
+ } from "./index-n0vev0fv.js";
12
12
 
13
13
  // pkgs/@akanjs/cli/library/library.command.ts
14
14
  class LibraryCommand extends command("library", [LibraryScript], ({ public: target }) => ({
@@ -4,41 +4,41 @@ import {
4
4
  runner,
5
5
  script,
6
6
  command
7
- } from "./index-hkq0q73d.js";
7
+ } from "./index-ggzb32a9.js";
8
8
  import"./index-bns3wcpc.js";
9
9
  import {
10
10
  parseEnvFile,
11
11
  PkgExecutor
12
- } from "./index-wfmpxke3.js";
12
+ } from "./index-0fq1b5jp.js";
13
13
  import {
14
14
  npmRegistryFromEnv,
15
15
  warnIgnoredNpmRegistry,
16
16
  getNpmRegistryUrl
17
17
  } from "./index-ny2k80mv.js";
18
- import"./index-y725zb1a.js";
19
- import"./index-g43360sn.js";
20
- import"./index-5hhe0rdd.js";
18
+ import"./index-p9f6dsf2.js";
19
+ import"./index-y9xbhs20.js";
20
+ import"./index-df0r4008.js";
21
21
  import"./index-m9jj544v.js";
22
- import"./index-3rff2c48.js";
23
- import"./index-jxaq2evq.js";
24
- import"./index-jrdp7c4h.js";
25
- import"./index-5qq6qky3.js";
22
+ import"./index-qx12c8k5.js";
23
+ import"./index-36dywqhv.js";
24
+ import"./index-n0vev0fv.js";
25
+ import"./index-kj7vyjng.js";
26
26
  import"./index-b4qq3rq0.js";
27
27
  import {
28
28
  ApplicationScript
29
- } from "./index-ah09graf.js";
30
- import"./index-vftjqv28.js";
29
+ } from "./index-mtxbw4fy.js";
30
+ import"./index-9km2h20g.js";
31
31
  import {
32
32
  CloudRunner
33
- } from "./index-kjmrkc45.js";
33
+ } from "./index-3wvc8cfa.js";
34
34
  import"./index-qd7xn2bk.js";
35
35
  import"./index-9p260r4e.js";
36
36
  import"./index-cmg5ngqa.js";
37
- import"./index-ygrdw6jw.js";
37
+ import"./index-dtxntsfx.js";
38
38
  import {
39
39
  PackageScript
40
- } from "./index-gsty3pkx.js";
41
- import"./index-8jpc5fqv.js";
40
+ } from "./index-w0nztbs0.js";
41
+ import"./index-y1a7dc7t.js";
42
42
  import"./index-9bv479q5.js";
43
43
 
44
44
  // pkgs/@akanjs/cli/localRegistry/localRegistry.runner.ts