@akanjs/cli 3.0.0-beta.19 → 3.0.0-beta.20

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 (95) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-6cm97kay.js → CodeAgent-awv258wb.js} +2 -2
  3. package/{CodeTui-za4jsm41.js → CodeTui-1nqh35ez.js} +20 -22
  4. package/TunnelShare-scf4e4pd.js +9 -0
  5. package/{agent.command-e0wpbbyg.js → agent.command-1s9ag7sb.js} +8 -9
  6. package/akanCode.js +4 -4
  7. package/{application.command-8wyxqc8q.js → application.command-49hwy6va.js} +25 -56
  8. package/{applicationBuildRunner-n9gzaxd0.js → applicationBuildRunner-ybyp97pv.js} +33 -59
  9. package/{applicationReleasePackager-vpggfqgq.js → applicationReleasePackager-esnrphw8.js} +40 -60
  10. package/buildBatch.proc.js +19 -24
  11. package/{capacitorApp-q3z0qht0.js → capacitorApp-1synz4en.js} +3 -4
  12. package/{cloud.command-4zwa5dsx.js → cloud.command-d7rqtzt9.js} +16 -26
  13. package/cloud.script-bkbpcr96.js +19 -0
  14. package/{code.command-468c9d7s.js → code.command-nn48xzej.js} +22 -37
  15. package/context.command-s3mcmvpa.js +48 -0
  16. package/context.runner-k99nb5pk.js +21 -0
  17. package/{dependencyScanner-0z2h2tks.js → dependencyScanner-ye2e6pdz.js} +2 -2
  18. package/{devTui-ffjsarqa.js → devTui-q7k7bakd.js} +5 -9
  19. package/fileSys-5ngz93ga.js +9 -0
  20. package/{guideline.command-vhw13pqr.js → guideline.command-sct4qnt5.js} +4 -5
  21. package/guidelines/conventions/conventions.instruction.md +5 -1
  22. package/guidelines/mcpRule/mcpRule.instruction.md +7 -5
  23. package/incrementalBuilder.proc.js +30 -48
  24. package/{index-s5rhm04y.js → index-0bq14vr1.js} +1 -1
  25. package/{index-10dkrrww.js → index-13ffe9wp.js} +4 -4
  26. package/{index-srmay5jw.js → index-22d57v4c.js} +84 -67
  27. package/{index-53176s7j.js → index-31yr441d.js} +10 -17
  28. package/index-3hx1z96c.js +87 -0
  29. package/{index-4m929vvn.js → index-3sq321ak.js} +10 -18
  30. package/{index-bhtmj233.js → index-3t7g9e4r.js} +41 -78
  31. package/{index-q0y2jq9j.js → index-5b6tavv3.js} +6 -3
  32. package/{index-47pj3aee.js → index-5e0n4hqx.js} +11 -12
  33. package/{index-7ep8qtvp.js → index-5pc1qrbv.js} +5 -8
  34. package/{index-esk82rvk.js → index-8mna0947.js} +34 -71
  35. package/{index-sq2dzkzm.js → index-8sf7wmdr.js} +6 -6
  36. package/{index-crmeqnmf.js → index-9d9bgcx4.js} +283 -722
  37. package/{index-bwf965h6.js → index-ahemdr5n.js} +6 -6
  38. package/{index-ab0c38ea.js → index-as7xmyz8.js} +20 -20
  39. package/{index-bc88j1ry.js → index-axzjaqve.js} +94 -142
  40. package/{index-3d9y066c.js → index-bjwxs904.js} +9 -8
  41. package/{index-667w0yah.js → index-c6eggbee.js} +2 -5
  42. package/{index-a1w6934z.js → index-ddxvdd1p.js} +169 -305
  43. package/{index-92zztqy1.js → index-dy0jx9ay.js} +2 -17
  44. package/{index-22xtgmhn.js → index-dzf3r49a.js} +1 -1
  45. package/{index-89hy31kf.js → index-fgq75haa.js} +172 -287
  46. package/{index-by5gpp8x.js → index-hj6w4ka1.js} +2 -1
  47. package/{index-hwkygn9s.js → index-khpfpcsd.js} +302 -33
  48. package/{index-vqx8bdxz.js → index-mxav6j3c.js} +78 -231
  49. package/{index-2446k7b4.js → index-myhc3c1j.js} +512 -588
  50. package/{index-3jrp517k.js → index-nv5976x3.js} +45 -128
  51. package/{index-zqgj2rt2.js → index-przybvy5.js} +69 -147
  52. package/{index-n3cv0tm4.js → index-smme4r47.js} +1 -1
  53. package/{index-qdgzsnhg.js → index-w2zdcw3k.js} +110 -231
  54. package/{index-14zrtgfa.js → index-wa5jbxj1.js} +6 -39
  55. package/{index-bftkz6cp.js → index-ww4z397j.js} +198 -555
  56. package/{index-kwaq3n9n.js → index-xqjwd384.js} +4 -7
  57. package/{index-txr7dj2g.js → index-xqpzbab5.js} +106 -240
  58. package/{index-e4v6vhxq.js → index-xsjh6nzh.js} +178 -165
  59. package/{index-18zybgkc.js → index-ygn77a5w.js} +47 -99
  60. package/{index-9d6nvkz2.js → index-ztp3e73t.js} +79 -35
  61. package/index.js +23 -24
  62. package/{library.command-cqr175dy.js → library.command-1gx04jgn.js} +4 -5
  63. package/{localRegistry.command-49z55qqz.js → localRegistry.command-zndxj1q6.js} +21 -42
  64. package/{module.command-9p8mm3b0.js → module.command-3waddk95.js} +6 -7
  65. package/{package.command-wxyz909t.js → package.command-zrc7br1y.js} +5 -6
  66. package/package.json +2 -2
  67. package/{page.command-gsrsfqqs.js → page.command-vpjgardh.js} +4 -5
  68. package/{primitive.command-ns1mptje.js → primitive.command-sz84tk4t.js} +9 -20
  69. package/{prompter-1f8d9pcc.js → prompter-ptaa3nk0.js} +2 -2
  70. package/{quality.command-e76k2q9k.js → quality.command-g869hafs.js} +129 -363
  71. package/{recipeScanner-fpagtgc1.js → recipeScanner-4b69ybe0.js} +1 -1
  72. package/{repair.command-pkrsm3cw.js → repair.command-chsnjvvv.js} +11 -35
  73. package/{scalar.command-0cpt3fc8.js → scalar.command-2v21newx.js} +5 -6
  74. package/skills/akan-code/SKILL.md +12 -4
  75. package/{subspace.command-fktpwp0g.js → subspace.command-ckcbwfp1.js} +39 -58
  76. package/templates/appSample/srvkit/{AuthGuard.ts → guards.ts} +3 -3
  77. package/templates/appSample/srvkit/{SessionInternalArg.ts → internalArgs.ts} +3 -3
  78. package/templates/client.ts +7 -30
  79. package/templates/lib/__lib/lib.dictionary.ts +0 -2
  80. package/templates/lib/__lib/lib.document.ts +0 -2
  81. package/templates/lib/sig.ts +8 -30
  82. package/templates/server.ts +0 -2
  83. package/{tunnel.command-d5jy9gk8.js → tunnel.command-kd2yr4fx.js} +5 -6
  84. package/{typeChecker-3xgrzc2v.js → typeChecker-px49mezc.js} +1 -1
  85. package/typecheck.proc.js +1 -1
  86. package/workflow.command-44252cqv.js +79 -0
  87. package/{workspace.command-gv84eh1p.js → workspace.command-fqcztt5p.js} +72 -107
  88. package/TunnelShare-2j6s511d.js +0 -9
  89. package/cloud.script-fwx3vb34.js +0 -20
  90. package/context.command-dsnw0jby.js +0 -80
  91. package/context.runner-rs4rj15d.js +0 -22
  92. package/devTuiView-1q1mdgrv.js +0 -9
  93. package/getDirname-dr3jz1xg.js +0 -7
  94. package/index-6wwzs1bc.js +0 -7
  95. package/workflow.command-6tkcysmx.js +0 -105
@@ -1,10 +1,8 @@
1
1
  // @bun
2
2
  import {
3
- FileSys
4
- } from "./index-q0y2jq9j.js";
5
- import {
6
- getDirname2
7
- } from "./index-6wwzs1bc.js";
3
+ getDirname2,
4
+ FileSys2
5
+ } from "./index-5b6tavv3.js";
8
6
 
9
7
  // pkgs/@akanjs/devkit/codegenLock.ts
10
8
  import { mkdir, open, readFile, rm, stat } from "fs/promises";
@@ -191,12 +189,12 @@ import {
191
189
  fork,
192
190
  spawn as spawn2
193
191
  } from "child_process";
194
- import { readFileSync as readFileSync2 } from "fs";
192
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
195
193
  import {
196
194
  copyFile,
197
195
  cp as cpEntry,
198
196
  lstat,
199
- mkdir as mkdir3,
197
+ mkdir as mkdir2,
200
198
  readdir as readDirEntries,
201
199
  realpath,
202
200
  rm as rm3,
@@ -219,7 +217,7 @@ import chalk2 from "chalk";
219
217
 
220
218
  // pkgs/@akanjs/devkit/agentsIndex.ts
221
219
  var recipeScannerLoad = null;
222
- var loadRecipeScanner = () => recipeScannerLoad ??= import("./recipeScanner-fpagtgc1.js");
220
+ var loadRecipeScanner = () => recipeScannerLoad ??= import("./recipeScanner-4b69ybe0.js");
223
221
  var AGENT_BLOCK_START = "<!-- akan:agent:start -->";
224
222
  var AGENT_BLOCK_END = "<!-- akan:agent:end -->";
225
223
  var AGENT_VERSION_PREFIX = "<!-- akan:agent:version ";
@@ -229,7 +227,7 @@ ${block}`;
229
227
  var extractBlockVersion = (content) => content.match(/<!-- akan:agent:version ([^\s]+) -->/)?.[1] ?? null;
230
228
  var readDevkitVersion = async () => {
231
229
  const { readFile } = await import("fs/promises");
232
- const { getDirname } = await import("./getDirname-dr3jz1xg.js");
230
+ const { getDirname } = await import("./fileSys-5ngz93ga.js");
233
231
  try {
234
232
  const raw = await readFile(`${getDirname(import.meta.url)}/package.json`, "utf-8");
235
233
  return JSON.parse(raw).version ?? null;
@@ -368,32 +366,11 @@ import { archs } from "akanjs";
368
366
  // pkgs/@akanjs/devkit/akanConfig/akanConfig.ts
369
367
  var DEFAULT_BARREL_IMPORTS = ["akanjs/webkit", "akanjs/common", "akanjs/ui", "akanjs/server"];
370
368
  var DEFAULT_OPTIMIZE_IMPORTS = [
371
- "lucide-react",
372
- "date-fns",
373
- "lodash-es",
374
- "ramda",
375
- "antd",
376
- "react-bootstrap",
377
- "ahooks",
378
- "@ant-design/icons",
379
- "@headlessui/react",
380
- "@headlessui-float/react",
381
- "@heroicons/react/20/solid",
382
- "@heroicons/react/24/solid",
383
- "@heroicons/react/24/outline",
384
- "@visx/visx",
385
- "@tremor/react",
386
- "rxjs",
387
- "@mui/material",
388
- "@mui/icons-material",
389
- "recharts",
390
- "react-use",
391
- "@material-ui/core",
392
- "@material-ui/icons",
393
- "@tabler/icons-react",
394
- "mui-core",
395
- "react-icons/*"
396
- ];
369
+ "lucide-react date-fns lodash-es ramda antd react-bootstrap ahooks @ant-design/icons @headlessui/react",
370
+ "@headlessui-float/react @heroicons/react/20/solid @heroicons/react/24/solid @heroicons/react/24/outline",
371
+ "@visx/visx @tremor/react rxjs @mui/material @mui/icons-material recharts react-use @material-ui/core",
372
+ "@material-ui/icons @tabler/icons-react mui-core react-icons/*"
373
+ ].flatMap((line) => line.split(" "));
397
374
  var WORKSPACE_BARREL_FACETS = ["ui", "webkit", "common", "client", "server"];
398
375
  var DEFAULT_DOCKER_IMAGE = "oven/bun:1-slim";
399
376
  var SSR_RUNTIME_PACKAGES = ["react", "react-dom", "react-server-dom-webpack"];
@@ -405,17 +382,7 @@ var MOBILE_RUNTIME_PACKAGES = [
405
382
  "@capacitor/assets"
406
383
  ];
407
384
  var MOBILE_APP_CAPACITOR_PLUGINS = [
408
- "@capacitor/app",
409
- "@capacitor/browser",
410
- "@capacitor/camera",
411
- "@capacitor/core",
412
- "@capacitor/device",
413
- "@capacitor/geolocation",
414
- "@capacitor/haptics",
415
- "@capacitor/inappbrowser",
416
- "@capacitor/keyboard",
417
- "@capacitor/preferences",
418
- "@capacitor/push-notifications",
385
+ ..."app browser camera core device geolocation haptics inappbrowser keyboard preferences push-notifications".split(" ").map((name) => `@capacitor/${name}`),
419
386
  "capacitor-plugin-safe-area"
420
387
  ];
421
388
  var DEFAULT_AKAN_IMAGE_CONFIG = {
@@ -632,22 +599,15 @@ class AkanAppConfig {
632
599
  }
633
600
  #applyRoutes(routes = []) {
634
601
  for (const route of routes) {
635
- if (route.basePath) {
636
- const basePath = route.basePath.replace(/^\/+|\/+$/g, "");
602
+ const basePath = route.basePath ? route.basePath.replace(/^\/+|\/+$/g, "") : null;
603
+ if (basePath !== null)
637
604
  this.basePaths.add(basePath);
638
- const domains = this.subRoutes.getOrInsert(basePath, new Set);
639
- Object.keys(route.domains).forEach((branch) => void this.branches.add(branch));
640
- Object.values(route.domains).flat().forEach((domain) => {
641
- if (domain)
642
- domains.add(domain.toLowerCase().replace(/:\d+$/, ""));
643
- });
644
- } else {
645
- Object.keys(route.domains).forEach((branch) => void this.branches.add(branch));
646
- Object.values(route.domains).flat().forEach((domain) => {
647
- if (domain)
648
- this.domains.add(domain.toLowerCase().replace(/:\d+$/, ""));
649
- });
650
- }
605
+ const domains = basePath !== null ? this.subRoutes.getOrInsert(basePath, new Set) : this.domains;
606
+ for (const branch of Object.keys(route.domains))
607
+ this.branches.add(branch);
608
+ for (const domain of Object.values(route.domains).flat())
609
+ if (domain)
610
+ domains.add(domain.toLowerCase().replace(/:\d+$/, ""));
651
611
  }
652
612
  const appName = this.app.name.toLowerCase();
653
613
  const serveDomain = this.baseDevEnv.serveDomain.toLowerCase();
@@ -763,7 +723,10 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
763
723
  if (rootVersion)
764
724
  return rootVersion;
765
725
  const akanPackageJson = getAkanPackageJson();
766
- return akanPackageJson.dependencies?.[lib] ?? akanPackageJson.peerDependencies?.[lib];
726
+ const version = akanPackageJson.dependencies?.[lib] ?? akanPackageJson.peerDependencies?.[lib];
727
+ if (!version)
728
+ throw new Error(`Dependency ${lib} not found in package.json`);
729
+ return version;
767
730
  }
768
731
  #getProductionRuntimePackages() {
769
732
  return [
@@ -804,12 +767,7 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
804
767
  ...this.rootPackageJson.dependencies,
805
768
  ...this.rootPackageJson.devDependencies
806
769
  };
807
- return libs.filter((lib) => !rootDependencies[lib]).map((lib) => {
808
- const version = this.#resolveProductionDependencyVersion(lib);
809
- if (!version)
810
- throw new Error(`Dependency ${lib} not found in package.json`);
811
- return `${lib}@${version}`;
812
- });
770
+ return libs.filter((lib) => !rootDependencies[lib]).map((lib) => `${lib}@${this.#resolveProductionDependencyVersion(lib)}`);
813
771
  }
814
772
  get akanVersion() {
815
773
  return getAkanPackageJson().version;
@@ -820,12 +778,10 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
820
778
  description: this.app.name,
821
779
  version: "1.0.0",
822
780
  main: "./main.js",
823
- dependencies: Object.fromEntries([...new Set(this.#getProductionRuntimePackages())].map((lib) => {
824
- const version = this.#resolveProductionDependencyVersion(lib);
825
- if (!version)
826
- throw new Error(`Dependency ${lib} not found in package.json`);
827
- return [lib, version];
828
- })),
781
+ dependencies: Object.fromEntries([...new Set(this.#getProductionRuntimePackages())].map((lib) => [
782
+ lib,
783
+ this.#resolveProductionDependencyVersion(lib)
784
+ ])),
829
785
  ...data
830
786
  };
831
787
  }
@@ -891,22 +847,15 @@ class AkanLibConfig {
891
847
  }
892
848
  }
893
849
  //! need to refactor
894
- var increaseBuildNum = async (app) => {
895
- const appConfig = await AkanAppConfig.from(app);
896
- const akanConfigPath = path2.join(app.cwdPath, "akan.config.ts");
897
- const akanConfig = fs.readFileSync(akanConfigPath, "utf8");
898
- const akanConfigContent = akanConfig.replace(`buildNum: ${appConfig.mobile.buildNum}`, `buildNum: ${appConfig.mobile.buildNum + 1}`);
899
- fs.writeFileSync(akanConfigPath, akanConfigContent);
900
- };
901
- var decreaseBuildNum = async (app) => {
902
- const appConfig = await AkanAppConfig.from(app);
850
+ var shiftBuildNum = async (app, delta) => {
851
+ const { buildNum } = (await AkanAppConfig.from(app)).mobile;
903
852
  const akanConfigPath = path2.join(app.cwdPath, "akan.config.ts");
904
853
  const akanConfig = fs.readFileSync(akanConfigPath, "utf8");
905
- const akanConfigContent = akanConfig.replace(`buildNum: ${appConfig.mobile.buildNum}`, `buildNum: ${appConfig.mobile.buildNum - 1}`);
906
- fs.writeFileSync(akanConfigPath, akanConfigContent);
854
+ fs.writeFileSync(akanConfigPath, akanConfig.replace(`buildNum: ${buildNum}`, `buildNum: ${buildNum + delta}`));
907
855
  };
856
+ var increaseBuildNum = async (app) => await shiftBuildNum(app, 1);
857
+ var decreaseBuildNum = async (app) => await shiftBuildNum(app, -1);
908
858
  // pkgs/@akanjs/devkit/artifact/implicitRootLayout.ts
909
- import { mkdir as mkdir2 } from "fs/promises";
910
859
  import path4 from "path";
911
860
 
912
861
  // pkgs/@akanjs/devkit/transforms/asyncDefaultExportDetector.ts
@@ -923,7 +872,7 @@ class AsyncDefaultExportDetector {
923
872
  try {
924
873
  const typescript = await AsyncDefaultExportDetector.#loadTypescript();
925
874
  const source = fs2.readFileSync(path3.resolve(moduleAbsPath), "utf8");
926
- const sourceFile = typescript.createSourceFile(moduleAbsPath, source, typescript.ScriptTarget.Latest, true, AsyncDefaultExportDetector.#scriptKind(typescript, moduleAbsPath));
875
+ const sourceFile = typescript.createSourceFile(moduleAbsPath, source, typescript.ScriptTarget.Latest, true, /\.[tj]sx$/.test(moduleAbsPath) ? typescript.ScriptKind.TSX : typescript.ScriptKind.TS);
927
876
  return new AsyncDefaultExportDetector(typescript).detectInSourceFile(sourceFile);
928
877
  } catch {
929
878
  return false;
@@ -965,8 +914,7 @@ class AsyncDefaultExportDetector {
965
914
  continue;
966
915
  }
967
916
  if (ts.isExportDeclaration(statement) && statement.exportClause && ts.isNamedExports(statement.exportClause)) {
968
- const exportClause = statement.exportClause;
969
- for (const specifier of exportClause.elements) {
917
+ for (const specifier of statement.exportClause.elements) {
970
918
  if (specifier.name.text !== "default")
971
919
  continue;
972
920
  defaultIdentifier = specifier.propertyName?.text ?? specifier.name.text;
@@ -983,29 +931,25 @@ class AsyncDefaultExportDetector {
983
931
  const ts = this.#ts;
984
932
  return Boolean(node && (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) && this.#hasModifier(node, ts.SyntaxKind.AsyncKeyword));
985
933
  }
986
- static #scriptKind(typescript, moduleAbsPath) {
987
- return moduleAbsPath.endsWith(".tsx") || moduleAbsPath.endsWith(".jsx") ? typescript.ScriptKind.TSX : typescript.ScriptKind.TS;
988
- }
989
934
  }
990
935
 
991
936
  // pkgs/@akanjs/devkit/artifact/implicitRootLayout.ts
992
937
  var LAYOUT_KEY_RE = /^\.\/(.+\/)?_layout\.(tsx|ts|jsx|js)$/;
993
- async function appHasStModule(appCwdPath) {
994
- return Bun.file(path4.join(appCwdPath, "lib", "st.ts")).exists();
995
- }
996
938
  var IMPLICIT_LAYOUT_DIR = path4.join(".akan", "generated", "root-layouts");
997
939
  var IMPLICIT_DICT_DIR = path4.join(".akan", "generated", "dict");
998
940
  var IMPLICIT_OVERRIDES_DIR = path4.join(".akan", "generated", "overrides");
999
941
  var OVERRIDES_KEY_RE = /^\.\/(.+\/)?_overrides\.(tsx|ts|jsx|js)$/;
942
+ var importSpecifier = (fromAbsPath, toAbsPath) => {
943
+ const rel = path4.relative(path4.dirname(fromAbsPath), toAbsPath).split(path4.sep).join("/");
944
+ return rel.startsWith(".") ? rel : `./${rel}`;
945
+ };
1000
946
  async function writeGeneratedOverridesLayoutFile(opts) {
1001
947
  const filename = `${opts.key.replace(/^\.\//, "").replace(/[^a-zA-Z0-9]+/g, "_")}.tsx`;
1002
948
  const absPath = path4.join(path4.resolve(opts.appCwdPath), IMPLICIT_OVERRIDES_DIR, filename);
1003
- const userRel = path4.relative(path4.dirname(absPath), opts.userAbsPath).split(path4.sep).join("/");
1004
- const userSpecifier = userRel.startsWith(".") ? userRel : `./${userRel}`;
1005
949
  const source = `"use client";
1006
950
  import { UiOverrideProvider } from "akanjs/ui";
1007
951
  import { createElement, type ReactNode } from "react";
1008
- import value from ${JSON.stringify(userSpecifier)};
952
+ import value from ${JSON.stringify(importSpecifier(absPath, opts.userAbsPath))};
1009
953
 
1010
954
  export default function AkanUiOverridesLayout({ children }: { children?: ReactNode }) {
1011
955
  return createElement(UiOverrideProvider, { value }, children);
@@ -1030,9 +974,6 @@ function implicitRootLayoutAbsPath(appCwdPath, segments) {
1030
974
  const filename = segments.length ? `${segments.join("__")}__root_layout.tsx` : "__root_layout.tsx";
1031
975
  return path4.join(path4.resolve(appCwdPath), IMPLICIT_LAYOUT_DIR, filename);
1032
976
  }
1033
- function implicitDictionaryMacroAbsPath(appCwdPath) {
1034
- return path4.join(path4.resolve(appCwdPath), IMPLICIT_DICT_DIR, "useDict.ts");
1035
- }
1036
977
  function isRootBoundarySegments(segments, basePaths) {
1037
978
  const firstVisibleIndex = segments.findIndex((segment) => !/^\(.+\)$/.test(segment));
1038
979
  if (firstVisibleIndex === -1)
@@ -1058,10 +999,8 @@ function findRootBoundaries(pageKeys, appCwdPath, basePaths) {
1058
999
  segments
1059
1000
  });
1060
1001
  }
1061
- const hasExplicitRootBoundary = [...boundaries.values()].some((boundary) => boundary.segments.length === 0);
1062
- if (!hasExplicitRootBoundary && boundaries.size === 0) {
1002
+ if (boundaries.size === 0)
1063
1003
  boundaries.set("", { sourceKey: null, sourceAbsPath: null, segments: [] });
1064
- }
1065
1004
  return [...boundaries.values()].sort((a, b) => a.segments.join("/").localeCompare(b.segments.join("/")));
1066
1005
  }
1067
1006
  function hasAncestorRootBoundary(boundary, boundaries) {
@@ -1074,10 +1013,6 @@ function findExplicitRootLayoutAbsPath(pageKeys, appCwdPath) {
1074
1013
  });
1075
1014
  return rootLayoutKey ? path4.resolve(appCwdPath, "page", rootLayoutKey.replace(/^\.\//, "")) : null;
1076
1015
  }
1077
- function routePrefixForSegments(segments) {
1078
- const visible = segments.filter((segment) => !/^\(.+\)$/.test(segment));
1079
- return visible[0] ?? null;
1080
- }
1081
1016
  async function assertEnvClientConvention(appCwdPath, appName) {
1082
1017
  const envPath = path4.join(appCwdPath, "env", "env.client.ts");
1083
1018
  if (!await Bun.file(envPath).exists()) {
@@ -1085,8 +1020,7 @@ async function assertEnvClientConvention(appCwdPath, appName) {
1085
1020
  }
1086
1021
  }
1087
1022
  async function writeGeneratedDictionaryMacroFile(appCwdPath, appName) {
1088
- const absPath = implicitDictionaryMacroAbsPath(appCwdPath);
1089
- await mkdir2(path4.dirname(absPath), { recursive: true });
1023
+ const absPath = path4.join(path4.resolve(appCwdPath), IMPLICIT_DICT_DIR, "useDict.ts");
1090
1024
  await Bun.write(absPath, `import { getAllDictionary } from "@apps/${appName}/lib/dict" with { type: "macro" };
1091
1025
 
1092
1026
  export const allDictionary = getAllDictionary();
@@ -1097,14 +1031,10 @@ async function writeGeneratedRootLayoutFile(opts) {
1097
1031
  await assertEnvClientConvention(opts.appCwdPath, opts.appName);
1098
1032
  const dictMacroAbsPath = opts.includeSystemProvider ? await writeGeneratedDictionaryMacroFile(opts.appCwdPath, opts.appName) : null;
1099
1033
  const absPath = implicitRootLayoutAbsPath(opts.appCwdPath, opts.boundary.segments);
1100
- await mkdir2(path4.dirname(absPath), { recursive: true });
1101
- const dictMacroRel = dictMacroAbsPath ? path4.relative(path4.dirname(absPath), dictMacroAbsPath).split(path4.sep).join("/") : null;
1102
- const dictMacroSpecifier = dictMacroRel ? dictMacroRel.startsWith(".") ? dictMacroRel : `./${dictMacroRel}` : null;
1103
- const sourceRel = opts.boundary.sourceAbsPath ? path4.relative(path4.dirname(absPath), opts.boundary.sourceAbsPath).split(path4.sep).join("/") : null;
1104
- const sourceSpecifier = sourceRel ? sourceRel.startsWith(".") ? sourceRel : `./${sourceRel}` : null;
1034
+ const dictMacroSpecifier = dictMacroAbsPath ? importSpecifier(absPath, dictMacroAbsPath) : null;
1035
+ const sourceSpecifier = opts.boundary.sourceAbsPath ? importSpecifier(absPath, opts.boundary.sourceAbsPath) : null;
1105
1036
  const inheritedSourceAbsPath = opts.rootSourceAbsPath && opts.rootSourceAbsPath !== opts.boundary.sourceAbsPath ? opts.rootSourceAbsPath : null;
1106
- const inheritedSourceRel = inheritedSourceAbsPath ? path4.relative(path4.dirname(absPath), inheritedSourceAbsPath).split(path4.sep).join("/") : null;
1107
- const inheritedSourceSpecifier = inheritedSourceRel ? inheritedSourceRel.startsWith(".") ? inheritedSourceRel : `./${inheritedSourceRel}` : null;
1037
+ const inheritedSourceSpecifier = inheritedSourceAbsPath ? importSpecifier(absPath, inheritedSourceAbsPath) : null;
1108
1038
  const clientImport = opts.includeStInit ? `import { st } from "@apps/${opts.appName}/client";
1109
1039
  void st;
1110
1040
  ` : `import "@apps/${opts.appName}/client";
@@ -1114,7 +1044,7 @@ void st;
1114
1044
  const inheritedLayout = resolveRouteModule(inheritedModule as never, ${JSON.stringify(inheritedLabel)}).module as LayoutModule;
1115
1045
  ` : `const inheritedLayout: LayoutModule = {};
1116
1046
  `;
1117
- const prefix = routePrefixForSegments(opts.boundary.segments);
1047
+ const prefix = opts.boundary.segments.find((segment) => !/^\(.+\)$/.test(segment)) ?? null;
1118
1048
  const userLabel = opts.boundary.sourceAbsPath ? path4.relative(opts.appCwdPath, opts.boundary.sourceAbsPath) : "";
1119
1049
  const userImport = sourceSpecifier ? `import * as userModule from ${JSON.stringify(sourceSpecifier)};
1120
1050
  const userLayout = resolveRouteModule(userModule as never, ${JSON.stringify(userLabel)}).module as LayoutModule;
@@ -1132,6 +1062,19 @@ const userLayout: LayoutModule = {};
1132
1062
  ` : "";
1133
1063
  const layoutChild = isAsyncUserLayout ? "{layout}" : userLayoutElement;
1134
1064
  const layoutReturn = isAsyncUserLayout ? "layout" : userLayoutElement;
1065
+ const layoutExports = `export async function generateHead(props: PageProps) {
1066
+ if (userLayout.generateHead) return userLayout.generateHead(props);
1067
+ if (userLayout.head !== undefined) return userLayout.head;
1068
+ if (inheritedLayout.generateHead) return inheritedLayout.generateHead(props);
1069
+ return inheritedLayout.head;
1070
+ }
1071
+
1072
+ export const NotFound = userLayout.NotFound ?? inheritedLayout.NotFound;
1073
+ export const Error = userLayout.Error ?? inheritedLayout.Error;
1074
+ export const pageConfig = userLayout.pageConfig ?? inheritedLayout.pageConfig;
1075
+
1076
+ ${layoutSignature}({ children, params, searchParams }: LayoutProps) {
1077
+ ${layoutBinding} return `;
1135
1078
  const source = opts.includeSystemProvider ? `import type { LayoutModule, LayoutProps, PageProps } from "akanjs/client";
1136
1079
  import { loadFonts, resolveRouteModule } from "akanjs/client";
1137
1080
  import type { ReactNode } from "react";
@@ -1145,19 +1088,7 @@ if (defaultFonts.length > 1) throw new Error("[route-convention] only one defaul
1145
1088
  const defaultFont = defaultFonts[0];
1146
1089
  const defaultFontClassName = defaultFont ? (defaultFont.className ?? \`font-\${defaultFont.name}\`) : undefined;
1147
1090
 
1148
- export async function generateHead(props: PageProps) {
1149
- if (userLayout.generateHead) return userLayout.generateHead(props);
1150
- if (userLayout.head !== undefined) return userLayout.head;
1151
- if (inheritedLayout.generateHead) return inheritedLayout.generateHead(props);
1152
- return inheritedLayout.head;
1153
- }
1154
-
1155
- export const NotFound = userLayout.NotFound ?? inheritedLayout.NotFound;
1156
- export const Error = userLayout.Error ?? inheritedLayout.Error;
1157
- export const pageConfig = userLayout.pageConfig ?? inheritedLayout.pageConfig;
1158
-
1159
- ${layoutSignature}({ children, params, searchParams }: LayoutProps) {
1160
- ${layoutBinding} return (
1091
+ ${layoutExports}(
1161
1092
  <System.Provider
1162
1093
  of={GeneratedLayout as never}
1163
1094
  appName=${JSON.stringify(opts.appName)}
@@ -1181,19 +1112,7 @@ ${layoutBinding} return (
1181
1112
  import { resolveRouteModule } from "akanjs/client";
1182
1113
  import type { ReactNode } from "react";
1183
1114
  ${inheritedImport}${userImport}
1184
- export async function generateHead(props: PageProps) {
1185
- if (userLayout.generateHead) return userLayout.generateHead(props);
1186
- if (userLayout.head !== undefined) return userLayout.head;
1187
- if (inheritedLayout.generateHead) return inheritedLayout.generateHead(props);
1188
- return inheritedLayout.head;
1189
- }
1190
-
1191
- export const NotFound = userLayout.NotFound ?? inheritedLayout.NotFound;
1192
- export const Error = userLayout.Error ?? inheritedLayout.Error;
1193
- export const pageConfig = userLayout.pageConfig ?? inheritedLayout.pageConfig;
1194
-
1195
- ${layoutSignature}({ children, params, searchParams }: LayoutProps) {
1196
- ${layoutBinding} return ${layoutReturn};
1115
+ ${layoutExports}${layoutReturn};
1197
1116
  }
1198
1117
  `;
1199
1118
  await Bun.write(absPath, source);
@@ -1201,7 +1120,7 @@ ${layoutBinding} return ${layoutReturn};
1201
1120
  }
1202
1121
  async function resolveSsrPageEntries(opts) {
1203
1122
  const absPageDir = path4.resolve(opts.appCwdPath, "page");
1204
- const hasSt = await appHasStModule(opts.appCwdPath);
1123
+ const hasSt = await Bun.file(path4.join(opts.appCwdPath, "lib", "st.ts")).exists();
1205
1124
  const basePaths = opts.basePaths ?? [];
1206
1125
  const rootSourceAbsPath = findExplicitRootLayoutAbsPath(opts.pageKeys, opts.appCwdPath);
1207
1126
  const rootBoundaries = findRootBoundaries(opts.pageKeys, opts.appCwdPath, basePaths);
@@ -1233,9 +1152,7 @@ async function resolveSsrPageEntries(opts) {
1233
1152
  }),
1234
1153
  seedAbsPaths: [...new Set([boundary.sourceAbsPath, rootSourceAbsPath].filter((absPath) => absPath !== null))]
1235
1154
  })));
1236
- const entries = [...base, ...generated];
1237
- entries.sort((a, b) => a.key.localeCompare(b.key));
1238
- return entries;
1155
+ return [...base, ...generated].sort((a, b) => a.key.localeCompare(b.key));
1239
1156
  }
1240
1157
  async function resolveSsrPageEntriesForApp(app, pageKeys) {
1241
1158
  const config = await app.getConfig();
@@ -1295,6 +1212,14 @@ var asBiomeReport = (candidate) => {
1295
1212
  }
1296
1213
  };
1297
1214
  var BIOME_CONFIG_FILES = ["biome.json", "biome.jsonc"];
1215
+ var emptyResult = (filePath) => ({
1216
+ filePath,
1217
+ messages: [],
1218
+ errorCount: 0,
1219
+ warningCount: 0,
1220
+ fixableErrorCount: 0,
1221
+ fixableWarningCount: 0
1222
+ });
1298
1223
 
1299
1224
  class Linter {
1300
1225
  static biomeBinName = process.platform === "win32" ? "biome.exe" : "biome";
@@ -1376,14 +1301,7 @@ class Linter {
1376
1301
  if (diagnostic.severity !== "error" && diagnostic.severity !== "warning")
1377
1302
  continue;
1378
1303
  const diagnosticFilePath = this.#diagnosticFilePath(diagnostic, filePath);
1379
- const result = resultsByPath.get(diagnosticFilePath) ?? {
1380
- filePath: diagnosticFilePath,
1381
- messages: [],
1382
- errorCount: 0,
1383
- warningCount: 0,
1384
- fixableErrorCount: 0,
1385
- fixableWarningCount: 0
1386
- };
1304
+ const result = resultsByPath.get(diagnosticFilePath) ?? emptyResult(diagnosticFilePath);
1387
1305
  const message = this.#createLintMessage(diagnostic);
1388
1306
  result.messages.push(message);
1389
1307
  if (message.severity === 2)
@@ -1393,14 +1311,7 @@ class Linter {
1393
1311
  resultsByPath.set(diagnosticFilePath, result);
1394
1312
  }
1395
1313
  return [
1396
- resultsByPath.get(filePath) ?? {
1397
- filePath,
1398
- messages: [],
1399
- errorCount: 0,
1400
- warningCount: 0,
1401
- fixableErrorCount: 0,
1402
- fixableWarningCount: 0
1403
- },
1314
+ resultsByPath.get(filePath) ?? emptyResult(filePath),
1404
1315
  ...[...resultsByPath.entries()].filter(([resultPath]) => resultPath !== filePath).map(([, result]) => result)
1405
1316
  ];
1406
1317
  }
@@ -1510,12 +1421,7 @@ ${errorText}, ${warningText} found`];
1510
1421
  warningCount: acc.warningCount + result.warningCount,
1511
1422
  fixableErrorCount: acc.fixableErrorCount + result.fixableErrorCount,
1512
1423
  fixableWarningCount: acc.fixableWarningCount + result.fixableWarningCount
1513
- }), {
1514
- errorCount: 0,
1515
- warningCount: 0,
1516
- fixableErrorCount: 0,
1517
- fixableWarningCount: 0
1518
- });
1424
+ }), { errorCount: 0, warningCount: 0, fixableErrorCount: 0, fixableWarningCount: 0 });
1519
1425
  return { results, details, stats };
1520
1426
  }
1521
1427
  async hasNoLintErrors(filePath) {
@@ -1573,12 +1479,9 @@ ${errorText}, ${warningText} found`];
1573
1479
  async getProblematicRules(filePath) {
1574
1480
  const { results } = await this.lintFile(filePath);
1575
1481
  const ruleCounts = {};
1576
- results.forEach((result) => {
1577
- result.messages.forEach((message) => {
1578
- if (message.ruleId)
1579
- ruleCounts[message.ruleId] = (ruleCounts[message.ruleId] || 0) + 1;
1580
- });
1581
- });
1482
+ for (const message of results.flatMap((result) => result.messages))
1483
+ if (message.ruleId)
1484
+ ruleCounts[message.ruleId] = (ruleCounts[message.ruleId] || 0) + 1;
1582
1485
  return ruleCounts;
1583
1486
  }
1584
1487
  }
@@ -1688,10 +1591,8 @@ var isAllowedLibFacetRootFile = (filename) => libFacetRootAllowedFiles.has(filen
1688
1591
  var isScannedRootEntry = (type, name) => !name.startsWith(".") || rootAllowedDirs[type].has(name);
1689
1592
 
1690
1593
  // pkgs/@akanjs/devkit/scanInfo.ts
1691
- var databaseFileTypes = [
1692
- "constant",
1594
+ var serviceFileTypes = [
1693
1595
  "dictionary",
1694
- "document",
1695
1596
  "service",
1696
1597
  "signal",
1697
1598
  "store",
@@ -1701,6 +1602,9 @@ var databaseFileTypes = [
1701
1602
  "view",
1702
1603
  "zone"
1703
1604
  ];
1605
+ var databaseFileTypes = ["constant", "dictionary", "document", ...serviceFileTypes.slice(1)];
1606
+ var uiFileTypes = new Set(["template", "unit", "util", "view", "zone"]);
1607
+ var fileTypeOf = (filename) => databaseFileTypes.find((type) => filename.endsWith(uiFileTypes.has(type) ? `.${type[0].toUpperCase()}${type.slice(1)}.tsx` : `.${type}.ts`));
1704
1608
  var generatedRootCapacitorConfigFiles = ["capacitor.config.js", "capacitor.config.json"];
1705
1609
  var internalLibDirs = new Set(["__lib", "__scalar"]);
1706
1610
  var moduleNonUiFileTypes = {
@@ -1713,9 +1617,7 @@ var moduleUiFileTypes = {
1713
1617
  service: new Set(["Util", "Zone"]),
1714
1618
  scalar: new Set(["Template", "Unit"])
1715
1619
  };
1716
- var testFilePattern = /\.(test|spec)\.(ts|tsx)$/;
1717
- var createDependencyScanner = async (exec) => (await import("./dependencyScanner-0z2h2tks.js")).TypeScriptDependencyScanner.from(exec);
1718
- var isAllowedTestFile = (filename) => testFilePattern.test(filename);
1620
+ var createDependencyScanner = async (exec) => (await import("./dependencyScanner-ye2e6pdz.js")).TypeScriptDependencyScanner.from(exec);
1719
1621
  var getScanPath = (exec, relativePath) => path7.posix.join(`${exec.type}s`, exec.name, relativePath.split(path7.sep).join("/"));
1720
1622
  async function clearGeneratedRootCapacitorConfigs(exec) {
1721
1623
  if (exec.type !== "app")
@@ -1735,21 +1637,21 @@ async function assertScanConvention(exec, libRoot) {
1735
1637
  const allowedRootFiles = rootAllowedFiles[exec.type];
1736
1638
  const allowedRootDirs = rootAllowedDirs[exec.type];
1737
1639
  const { files, dirs } = await exec.getFilesAndDirs(".");
1738
- files.filter((filename) => !allowedRootFiles.has(filename)).forEach((filename) => {
1739
- addViolation(filename, `unsupported ${exec.type} root file`);
1740
- });
1741
- dirs.filter((dirname) => !allowedRootDirs.has(dirname)).forEach((dirname) => {
1742
- addViolation(dirname, `unsupported ${exec.type} root folder`);
1743
- });
1640
+ for (const filename of files)
1641
+ if (!allowedRootFiles.has(filename))
1642
+ addViolation(filename, `unsupported ${exec.type} root file`);
1643
+ for (const dirname of dirs)
1644
+ if (!allowedRootDirs.has(dirname))
1645
+ addViolation(dirname, `unsupported ${exec.type} root folder`);
1744
1646
  if (exec.type === "lib")
1745
1647
  for (const { relativePath, reason } of await exec.getPageConventionViolations())
1746
1648
  addViolation(relativePath, reason);
1747
- libRoot.files.filter((filename) => !isAllowedLibFacetRootFile(filename)).forEach((filename) => {
1748
- addViolation(path7.join("lib", filename), "unsupported lib facet root file");
1749
- });
1750
- libRoot.dirs.filter((dirname) => dirname.startsWith("__") && !internalLibDirs.has(dirname)).forEach((dirname) => {
1751
- addViolation(path7.join("lib", dirname), "unsupported internal lib folder");
1752
- });
1649
+ for (const filename of libRoot.files)
1650
+ if (!isAllowedLibFacetRootFile(filename))
1651
+ addViolation(path7.join("lib", filename), "unsupported lib facet root file");
1652
+ for (const dirname of libRoot.dirs)
1653
+ if (dirname.startsWith("__") && !internalLibDirs.has(dirname))
1654
+ addViolation(path7.join("lib", dirname), "unsupported internal lib folder");
1753
1655
  const databaseDirs = libRoot.dirs.filter((dirname) => !dirname.startsWith("_"));
1754
1656
  const serviceDirs = libRoot.dirs.filter((dirname) => dirname.startsWith("_") && !dirname.startsWith("__"));
1755
1657
  const scalarDirs = await exec.readdir("lib/__scalar");
@@ -1771,38 +1673,25 @@ async function validateModuleFiles(exec, violations, kind, modulePath) {
1771
1673
  violations.push(`${getScanPath(exec, path7.join(modulePath, dirname))}: unsupported module folder`);
1772
1674
  });
1773
1675
  const uiModuleName = moduleName[0].toUpperCase() + moduleName.slice(1);
1774
- files.forEach((filename) => {
1775
- const filePath = path7.join(modulePath, filename);
1776
- if (filename === "index.ts" || filename === "index.tsx" || isAllowedTestFile(filename))
1777
- return;
1676
+ for (const filename of files) {
1677
+ const scanPath = getScanPath(exec, path7.join(modulePath, filename));
1678
+ if (filename === "index.ts" || filename === "index.tsx" || /\.(test|spec)\.(ts|tsx)$/.test(filename))
1679
+ continue;
1778
1680
  if (filename === `${moduleName}.abstract.md`)
1779
- return;
1681
+ continue;
1780
1682
  const uiMatch = filename.match(/^([A-Z][A-Za-z0-9]+)\.([A-Z][A-Za-z0-9]*)\.tsx$/);
1781
- if (uiMatch) {
1782
- const fileModuleName = uiMatch[1];
1783
- const fileType = uiMatch[2];
1784
- if (fileModuleName !== uiModuleName) {
1785
- violations.push(`${getScanPath(exec, filePath)}: module name mismatch: expected '${uiModuleName}', got '${fileModuleName}'`);
1786
- }
1787
- if (!moduleUiFileTypes[kind].has(fileType)) {
1788
- violations.push(`${getScanPath(exec, filePath)}: unsupported ${kind} UI file`);
1789
- }
1790
- return;
1791
- }
1792
- const nonUiMatch = filename.match(/^([a-z][a-zA-Z0-9]*)\.([a-z][a-z0-9]*)\.ts$/);
1793
- if (nonUiMatch) {
1794
- const fileModuleName = nonUiMatch[1];
1795
- const fileType = nonUiMatch[2];
1796
- if (fileModuleName !== moduleName) {
1797
- violations.push(`${getScanPath(exec, filePath)}: module name mismatch: expected '${moduleName}', got '${fileModuleName}'`);
1798
- }
1799
- if (!moduleNonUiFileTypes[kind].has(fileType)) {
1800
- violations.push(`${getScanPath(exec, filePath)}: unsupported ${kind} file`);
1801
- }
1802
- return;
1683
+ const match = uiMatch ?? filename.match(/^([a-z][a-zA-Z0-9]*)\.([a-z][a-z0-9]*)\.ts$/);
1684
+ if (!match) {
1685
+ violations.push(`${scanPath}: unsupported module file`);
1686
+ continue;
1803
1687
  }
1804
- violations.push(`${getScanPath(exec, filePath)}: unsupported module file`);
1805
- });
1688
+ const [, fileModuleName, fileType] = match;
1689
+ const expectedName = uiMatch ? uiModuleName : moduleName;
1690
+ if (fileModuleName !== expectedName)
1691
+ violations.push(`${scanPath}: module name mismatch: expected '${expectedName}', got '${fileModuleName}'`);
1692
+ if (!(uiMatch ? moduleUiFileTypes : moduleNonUiFileTypes)[kind].has(fileType))
1693
+ violations.push(`${scanPath}: unsupported ${kind}${uiMatch ? " UI" : ""} file`);
1694
+ }
1806
1695
  }
1807
1696
 
1808
1697
  class ScanInfo {
@@ -1850,79 +1739,17 @@ class ScanInfo {
1850
1739
  } else
1851
1740
  databaseDirs.push(name);
1852
1741
  });
1742
+ const collect = async (dir, name, kind) => {
1743
+ for (const filename of await exec.readdir(dir)) {
1744
+ const type = fileTypeOf(filename);
1745
+ if (type)
1746
+ files[type][kind]?.push(name);
1747
+ }
1748
+ };
1853
1749
  await Promise.all([
1854
- ...databaseDirs.map(async (name) => {
1855
- const filenames = await exec.readdir(path7.join("lib", name));
1856
- filenames.forEach((filename) => {
1857
- if (filename.endsWith(".constant.ts"))
1858
- files.constant.databases.push(name);
1859
- else if (filename.endsWith(".dictionary.ts"))
1860
- files.dictionary.databases.push(name);
1861
- else if (filename.endsWith(".document.ts"))
1862
- files.document.databases.push(name);
1863
- else if (filename.endsWith(".service.ts"))
1864
- files.service.databases.push(name);
1865
- else if (filename.endsWith(".signal.ts"))
1866
- files.signal.databases.push(name);
1867
- else if (filename.endsWith(".store.ts"))
1868
- files.store.databases.push(name);
1869
- else if (filename.endsWith(".Template.tsx"))
1870
- files.template.databases.push(name);
1871
- else if (filename.endsWith(".Unit.tsx"))
1872
- files.unit.databases.push(name);
1873
- else if (filename.endsWith(".Util.tsx"))
1874
- files.util.databases.push(name);
1875
- else if (filename.endsWith(".View.tsx"))
1876
- files.view.databases.push(name);
1877
- else if (filename.endsWith(".Zone.tsx"))
1878
- files.zone.databases.push(name);
1879
- });
1880
- }),
1881
- ...serviceDirs.map(async (dirname) => {
1882
- const name = dirname.slice(1);
1883
- const filenames = await exec.readdir(path7.join("lib", dirname));
1884
- filenames.forEach((filename) => {
1885
- if (filename.endsWith(".dictionary.ts"))
1886
- files.dictionary.services.push(name);
1887
- else if (filename.endsWith(".service.ts"))
1888
- files.service.services.push(name);
1889
- else if (filename.endsWith(".signal.ts"))
1890
- files.signal.services.push(name);
1891
- else if (filename.endsWith(".store.ts"))
1892
- files.store.services.push(name);
1893
- else if (filename.endsWith(".Template.tsx"))
1894
- files.template.services.push(name);
1895
- else if (filename.endsWith(".Unit.tsx"))
1896
- files.unit.services.push(name);
1897
- else if (filename.endsWith(".Util.tsx"))
1898
- files.util.services.push(name);
1899
- else if (filename.endsWith(".View.tsx"))
1900
- files.view.services.push(name);
1901
- else if (filename.endsWith(".Zone.tsx"))
1902
- files.zone.services.push(name);
1903
- });
1904
- }),
1905
- ...scalarDirs.map(async (name) => {
1906
- const filenames = await exec.readdir(path7.join("lib/__scalar", name));
1907
- filenames.forEach((filename) => {
1908
- if (filename.endsWith(".constant.ts"))
1909
- files.constant.scalars.push(name);
1910
- else if (filename.endsWith(".dictionary.ts"))
1911
- files.dictionary.scalars.push(name);
1912
- else if (filename.endsWith(".document.ts"))
1913
- files.document.scalars.push(name);
1914
- else if (filename.endsWith(".Template.tsx"))
1915
- files.template.scalars.push(name);
1916
- else if (filename.endsWith(".Unit.tsx"))
1917
- files.unit.scalars.push(name);
1918
- else if (filename.endsWith(".Util.tsx"))
1919
- files.util.scalars.push(name);
1920
- else if (filename.endsWith(".View.tsx"))
1921
- files.view.scalars.push(name);
1922
- else if (filename.endsWith(".Zone.tsx"))
1923
- files.zone.scalars.push(name);
1924
- });
1925
- })
1750
+ ...databaseDirs.map((name) => collect(path7.join("lib", name), name, "databases")),
1751
+ ...serviceDirs.map((dirname) => collect(path7.join("lib", dirname), dirname.slice(1), "services")),
1752
+ ...scalarDirs.map((name) => collect(path7.join("lib/__scalar", name), name, "scalars"))
1926
1753
  ]);
1927
1754
  const routes = exec.type === "lib" ? [] : await exec.getPageKeys();
1928
1755
  const common = {
@@ -1943,31 +1770,14 @@ class ScanInfo {
1943
1770
  constructor(scanResult) {
1944
1771
  this.name = scanResult.name;
1945
1772
  this.scanResult = scanResult;
1946
- Object.entries(scanResult.files).forEach(([_key, value]) => {
1947
- const key = _key;
1948
- const { databases, services, scalars } = value;
1949
- databases.forEach((modelName) => {
1950
- const model = this.database.get(modelName) ?? new Set;
1951
- model.add(key);
1952
- this.database.set(modelName, model);
1953
- this.file[key].all.add(modelName);
1954
- this.file[key].databases.add(modelName);
1955
- });
1956
- services?.forEach((serviceName) => {
1957
- const service = this.service.get(serviceName) ?? new Set;
1958
- service.add(key);
1959
- this.service.set(serviceName, service);
1960
- this.file[key].all.add(serviceName);
1961
- this.file[key].services.add(serviceName);
1962
- });
1963
- scalars?.forEach((scalarName) => {
1964
- const scalar = this.scalar.get(scalarName) ?? new Set;
1965
- scalar.add(key);
1966
- this.scalar.set(scalarName, scalar);
1967
- this.file[key].all.add(scalarName);
1968
- this.file[key].scalars.add(scalarName);
1969
- });
1970
- });
1773
+ const modulesOf = { databases: this.database, services: this.service, scalars: this.scalar };
1774
+ for (const [key, groups] of Object.entries(scanResult.files))
1775
+ for (const kind of ["databases", "services", "scalars"])
1776
+ for (const name of groups[kind] ?? []) {
1777
+ modulesOf[kind].set(name, (modulesOf[kind].get(name) ?? new Set).add(key));
1778
+ this.file[key].all.add(name);
1779
+ this.file[key][kind].add(name);
1780
+ }
1971
1781
  }
1972
1782
  getScanResult() {
1973
1783
  return this.scanResult;
@@ -1981,6 +1791,28 @@ class ScanInfo {
1981
1791
  getScalarModules() {
1982
1792
  return [...this.scalar.keys()];
1983
1793
  }
1794
+ #sortedLibs = null;
1795
+ sortedLibs(libDeps) {
1796
+ if (this.#sortedLibs)
1797
+ return this.#sortedLibs;
1798
+ const libIndices = LibInfo.getSortedLibIndices();
1799
+ this.#sortedLibs = libDeps.sort((libNameA, libNameB) => {
1800
+ const indexA = libIndices.get(libNameA);
1801
+ const indexB = libIndices.get(libNameB);
1802
+ if (indexA === undefined || indexB === undefined)
1803
+ throw new Error(`LibInfo not found: ${libNameA} or ${libNameB}`);
1804
+ return indexA - indexB;
1805
+ });
1806
+ return this.#sortedLibs;
1807
+ }
1808
+ sortedLibInfos(libDeps) {
1809
+ return new Map(this.sortedLibs(libDeps).map((libName) => {
1810
+ const libInfo = LibInfo.libInfos.get(libName);
1811
+ if (!libInfo)
1812
+ throw new Error(`LibInfo not found: ${libName}`);
1813
+ return [libName, libInfo];
1814
+ }));
1815
+ }
1984
1816
  }
1985
1817
  var isAkanFrameworkDependency = (dep) => dep === "akanjs" || dep.startsWith("akanjs/");
1986
1818
 
@@ -2030,30 +1862,11 @@ class AppInfo extends ScanInfo {
2030
1862
  }));
2031
1863
  return [...libSet];
2032
1864
  }
2033
- #sortedLibs = null;
2034
- #getSortedLibs() {
2035
- if (this.#sortedLibs)
2036
- return this.#sortedLibs;
2037
- const libIndices = LibInfo.getSortedLibIndices();
2038
- this.#sortedLibs = this.libDeps.sort((libNameA, libNameB) => {
2039
- const indexA = libIndices.get(libNameA);
2040
- const indexB = libIndices.get(libNameB);
2041
- if (indexA === undefined || indexB === undefined)
2042
- throw new Error(`LibInfo not found: ${libNameA} or ${libNameB}`);
2043
- return indexA - indexB;
2044
- });
2045
- return this.#sortedLibs;
2046
- }
2047
1865
  getLibs() {
2048
- return this.#getSortedLibs();
1866
+ return this.sortedLibs(this.libDeps);
2049
1867
  }
2050
1868
  getLibInfos() {
2051
- return new Map(this.#getSortedLibs().map((libName) => {
2052
- const libInfo = LibInfo.libInfos.get(libName);
2053
- if (!libInfo)
2054
- throw new Error(`LibInfo not found: ${libName}`);
2055
- return [libName, libInfo];
2056
- }));
1869
+ return this.sortedLibInfos(this.libDeps);
2057
1870
  }
2058
1871
  }
2059
1872
 
@@ -2093,38 +1906,18 @@ class LibInfo extends ScanInfo {
2093
1906
  getScanResult() {
2094
1907
  return this.scanResult;
2095
1908
  }
2096
- #sortedLibs = null;
2097
- #getSortedLibs() {
2098
- if (this.#sortedLibs)
2099
- return this.#sortedLibs;
2100
- const libs = LibInfo.getSortedLibIndices();
2101
- this.#sortedLibs = this.scanResult.libDeps.sort((libNameA, libNameB) => {
2102
- const indexA = libs.get(libNameA);
2103
- const indexB = libs.get(libNameB);
2104
- if (indexA === undefined || indexB === undefined)
2105
- throw new Error(`LibInfo not found: ${libNameA} or ${libNameB}`);
2106
- return indexA - indexB;
2107
- });
2108
- return this.#sortedLibs;
2109
- }
2110
1909
  getLibs() {
2111
- return this.#getSortedLibs();
1910
+ return this.sortedLibs(this.scanResult.libDeps);
2112
1911
  }
2113
1912
  getLibInfo(libName) {
2114
1913
  if (!this.getScanResult().libDeps.includes(libName))
2115
1914
  return;
2116
- const libSet = new Set(this.#getSortedLibs());
2117
- if (!libSet.has(libName))
1915
+ if (!this.getLibs().includes(libName))
2118
1916
  throw new Error(`LibInfo is invalid: ${libName}`);
2119
1917
  return LibInfo.libInfos.get(libName);
2120
1918
  }
2121
1919
  getLibInfos() {
2122
- return new Map(this.#getSortedLibs().map((libName) => {
2123
- const libInfo = LibInfo.libInfos.get(libName);
2124
- if (!libInfo)
2125
- throw new Error(`LibInfo not found: ${libName}`);
2126
- return [libName, libInfo];
2127
- }));
1920
+ return this.sortedLibInfos(this.scanResult.libDeps);
2128
1921
  }
2129
1922
  }
2130
1923
 
@@ -2143,12 +1936,7 @@ class PkgInfo {
2143
1936
  const pathSplitLength = path.split("/").length;
2144
1937
  return workspacePathOf(tsconfig.compilerOptions.paths?.[path]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
2145
1938
  }).filter((pkg) => pkg !== exec.name);
2146
- const pkgScanResult = {
2147
- name: exec.name,
2148
- pkgDeps,
2149
- dependencies: [...npmDepSet]
2150
- };
2151
- return pkgScanResult;
1939
+ return { name: exec.name, pkgDeps, dependencies: [...npmDepSet] };
2152
1940
  }
2153
1941
  static #pkgInfos = new Map;
2154
1942
  static async fromExecutor(exec, options = {}) {
@@ -2186,17 +1974,9 @@ class WorkspaceInfo {
2186
1974
  return existingWorkspaceInfo;
2187
1975
  const [appNames, libNames, pkgNames] = await Promise.all([exec.getApps(), exec.getLibs(), exec.getPkgs()]);
2188
1976
  const [appInfos, libInfos, pkgInfos] = await Promise.all([
2189
- Promise.all(appNames.map(async (appName) => {
2190
- const app = AppExecutor.from(exec, appName);
2191
- return await app.scan();
2192
- })),
2193
- Promise.all(libNames.map(async (libName) => {
2194
- const lib = LibExecutor.from(exec, libName);
2195
- return await lib.scan();
2196
- })),
2197
- Promise.all(pkgNames.map(async (pkgName) => {
2198
- return await PkgExecutor.from(exec, pkgName).scan();
2199
- }))
1977
+ Promise.all(appNames.map(async (appName) => await AppExecutor.from(exec, appName).scan())),
1978
+ Promise.all(libNames.map(async (libName) => await LibExecutor.from(exec, libName).scan())),
1979
+ Promise.all(pkgNames.map(async (pkgName) => await PkgExecutor.from(exec, pkgName).scan()))
2200
1980
  ]);
2201
1981
  const workspaceInfo = new WorkspaceInfo(new Map(appInfos.map((app) => [app.exec.name, app])), new Map(libInfos.map((lib) => [lib.exec.name, lib])), new Map(pkgInfos.map((pkg) => [pkg.exec.name, pkg])));
2202
1982
  WorkspaceInfo.#workspaceInfos.set(exec.name, workspaceInfo);
@@ -2205,39 +1985,7 @@ class WorkspaceInfo {
2205
1985
  }
2206
1986
 
2207
1987
  // pkgs/@akanjs/devkit/executors.ts
2208
- var staticTemplateFileExtensions = new Set([
2209
- ".avif",
2210
- ".bmp",
2211
- ".cjs",
2212
- ".css",
2213
- ".eot",
2214
- ".gif",
2215
- ".html",
2216
- ".ico",
2217
- ".jpeg",
2218
- ".jpg",
2219
- ".js",
2220
- ".json",
2221
- ".map",
2222
- ".md",
2223
- ".mjs",
2224
- ".mp3",
2225
- ".mp4",
2226
- ".ogg",
2227
- ".otf",
2228
- ".pdf",
2229
- ".png",
2230
- ".svg",
2231
- ".ttf",
2232
- ".txt",
2233
- ".wasm",
2234
- ".wav",
2235
- ".webm",
2236
- ".webp",
2237
- ".woff",
2238
- ".woff2",
2239
- ".xml"
2240
- ]);
1988
+ var staticTemplateFileExtensions = new Set(".avif .bmp .cjs .css .eot .gif .html .ico .jpeg .jpg .js .json .map .md .mjs .mp3 .mp4 .ogg .otf .pdf .png .svg".split(" ").concat(".ttf .txt .wasm .wav .webm .webp .woff .woff2 .xml".split(" ")));
2241
1989
  var plainCommandArgPattern = process.platform === "win32" ? /^[\w@%+=:,./\\-]+$/ : /^[\w@%+=:,./-]+$/;
2242
1990
  var formatCommandArg = (value) => plainCommandArgPattern.test(value) ? value : JSON.stringify(value);
2243
1991
  var formatCommandForDisplay = (command, args = []) => [command, ...args].map(formatCommandArg).join(" ");
@@ -2313,6 +2061,10 @@ var parseEnvFile = (envPath) => {
2313
2061
  }
2314
2062
  return env;
2315
2063
  };
2064
+ var withCapitalizedDict = (dict = {}) => ({
2065
+ ...dict,
2066
+ ...Object.fromEntries(Object.entries(dict).map(([key, value]) => [capitalize(key), capitalize(value)]))
2067
+ });
2316
2068
 
2317
2069
  class Executor {
2318
2070
  static verbose = false;
@@ -2339,144 +2091,51 @@ class Executor {
2339
2091
  #stderr(data) {
2340
2092
  Logger2.raw(chalk2.red(data.toString()));
2341
2093
  }
2342
- exec(command, options = {}) {
2343
- const cwd = options.cwd?.toString() ?? this.cwdPath;
2344
- const proc = exec(command, { cwd: this.cwdPath, ...options });
2094
+ #settle(proc, target, { onClose = false, keepLogs = false, redStderr = false } = {}) {
2345
2095
  let stdout = "";
2346
2096
  let stderr = "";
2347
2097
  proc.stdout?.on("data", (data) => {
2348
2098
  stdout += data.toString();
2099
+ if (keepLogs)
2100
+ this.logs.push(data.toString());
2349
2101
  this.#stdout(data);
2350
2102
  });
2351
2103
  proc.stderr?.on("data", (data) => {
2352
2104
  stderr += data.toString();
2353
- this.#stdout(data);
2105
+ if (keepLogs)
2106
+ this.logs.push(data.toString());
2107
+ if (redStderr)
2108
+ this.#stderr(data);
2109
+ else
2110
+ this.#stdout(data);
2354
2111
  });
2355
2112
  return new Promise((resolve, reject) => {
2356
- proc.on("error", (error) => {
2357
- reject(new CommandExecutionError({
2358
- command,
2359
- cwd,
2360
- code: null,
2361
- signal: null,
2362
- stdout,
2363
- stderr,
2364
- cause: error
2365
- }));
2366
- });
2367
- proc.on("exit", (code, signal) => {
2368
- if (code || signal)
2369
- reject(new CommandExecutionError({
2370
- command,
2371
- cwd,
2372
- code,
2373
- signal,
2374
- stdout,
2375
- stderr
2376
- }));
2113
+ proc.on("error", (cause) => reject(new CommandExecutionError({ ...target, code: null, signal: null, stdout, stderr, cause })));
2114
+ proc.on(onClose ? "close" : "exit", (code, signal) => {
2115
+ if ((onClose ? code !== 0 : code) || signal)
2116
+ reject(new CommandExecutionError({ ...target, code, signal, stdout, stderr }));
2377
2117
  else
2378
- resolve({ code, signal });
2118
+ resolve({ code, signal, stdout });
2379
2119
  });
2380
2120
  });
2381
2121
  }
2122
+ exec(command, options = {}) {
2123
+ const target = { command, cwd: options.cwd?.toString() ?? this.cwdPath };
2124
+ const proc = exec(command, { cwd: this.cwdPath, ...options });
2125
+ return this.#settle(proc, target).then(({ code, signal }) => ({ code, signal }));
2126
+ }
2382
2127
  spawn(command, args = [], options = {}) {
2383
- const cwd = options.cwd?.toString() ?? this.cwdPath;
2384
- const proc = spawn2(command, args, {
2385
- cwd: this.cwdPath,
2386
- ...options
2387
- });
2388
- let stdout = "";
2389
- let stderr = "";
2390
- proc.stdout?.on("data", (data) => {
2391
- stdout += data.toString();
2392
- this.logs.push(data.toString());
2393
- this.#stdout(data);
2394
- });
2395
- proc.stderr?.on("data", (data) => {
2396
- stderr += data.toString();
2397
- this.logs.push(data.toString());
2398
- this.#stdout(data);
2399
- });
2400
- return new Promise((resolve, reject) => {
2401
- proc.on("error", (error) => {
2402
- reject(new CommandExecutionError({
2403
- command,
2404
- args,
2405
- cwd,
2406
- code: null,
2407
- signal: null,
2408
- stdout,
2409
- stderr,
2410
- cause: error
2411
- }));
2412
- });
2413
- proc.on("close", (code, signal) => {
2414
- if (code !== 0 || signal)
2415
- reject(new CommandExecutionError({
2416
- command,
2417
- args,
2418
- cwd,
2419
- code,
2420
- signal,
2421
- stdout,
2422
- stderr
2423
- }));
2424
- else
2425
- resolve(stdout);
2426
- });
2427
- });
2128
+ const target = { command, args, cwd: options.cwd?.toString() ?? this.cwdPath };
2129
+ const proc = spawn2(command, args, { cwd: this.cwdPath, ...options });
2130
+ return this.#settle(proc, target, { onClose: true, keepLogs: true }).then(({ stdout }) => stdout);
2428
2131
  }
2429
2132
  spawnSync(command, args = [], options = {}) {
2430
- const proc = spawn2(command, args, {
2431
- cwd: this.cwdPath,
2432
- ...options
2433
- });
2434
- return proc;
2133
+ return spawn2(command, args, { cwd: this.cwdPath, ...options });
2435
2134
  }
2436
2135
  fork(modulePath, args = [], options = {}) {
2437
- const cwd = options.cwd?.toString() ?? this.cwdPath;
2438
- const proc = fork(modulePath, args, {
2439
- cwd: this.cwdPath,
2440
- ...options
2441
- });
2442
- let stdout = "";
2443
- let stderr = "";
2444
- proc.stdout?.on("data", (data) => {
2445
- stdout += data.toString();
2446
- this.#stdout(data);
2447
- });
2448
- proc.stderr?.on("data", (data) => {
2449
- stderr += data.toString();
2450
- this.#stderr(data);
2451
- });
2452
- return new Promise((resolve, reject) => {
2453
- proc.on("error", (error) => {
2454
- reject(new CommandExecutionError({
2455
- command: modulePath,
2456
- args,
2457
- cwd,
2458
- code: null,
2459
- signal: null,
2460
- stdout,
2461
- stderr,
2462
- cause: error
2463
- }));
2464
- });
2465
- proc.on("exit", (code, signal) => {
2466
- if (code || signal)
2467
- reject(new CommandExecutionError({
2468
- command: modulePath,
2469
- args,
2470
- cwd,
2471
- code,
2472
- signal,
2473
- stdout,
2474
- stderr
2475
- }));
2476
- else
2477
- resolve({ code, signal });
2478
- });
2479
- });
2136
+ const target = { command: modulePath, args, cwd: options.cwd?.toString() ?? this.cwdPath };
2137
+ const proc = fork(modulePath, args, { cwd: this.cwdPath, ...options });
2138
+ return this.#settle(proc, target, { redStderr: true }).then(({ code, signal }) => ({ code, signal }));
2480
2139
  }
2481
2140
  getPath(filePath) {
2482
2141
  if (path8.isAbsolute(filePath))
@@ -2500,8 +2159,8 @@ class Executor {
2500
2159
  }
2501
2160
  async mkdir(dirPath) {
2502
2161
  const writePath = this.getPath(dirPath);
2503
- if (!await FileSys.dirExists(writePath))
2504
- await mkdir3(writePath, { recursive: true });
2162
+ if (!await FileSys2.dirExists(writePath))
2163
+ await mkdir2(writePath, { recursive: true });
2505
2164
  this.logger.verbose(`Make directory ${writePath}`);
2506
2165
  return this;
2507
2166
  }
@@ -2520,27 +2179,25 @@ class Executor {
2520
2179
  }
2521
2180
  async getFilesAndDirs(dirPath) {
2522
2181
  const fullDirPath = this.getPath(dirPath);
2523
- const fileGlob = new Bun.Glob("*");
2524
- const files = Array.from(fileGlob.scanSync({ cwd: fullDirPath, onlyFiles: true }));
2525
- const dirGlob = new Bun.Glob("*");
2526
- const allEntries = Array.from(dirGlob.scanSync({ cwd: fullDirPath, onlyFiles: false }));
2182
+ const glob = new Bun.Glob("*");
2183
+ const files = Array.from(glob.scanSync({ cwd: fullDirPath, onlyFiles: true }));
2184
+ const allEntries = Array.from(glob.scanSync({ cwd: fullDirPath, onlyFiles: false }));
2527
2185
  const dirs = allEntries.filter((entry) => !files.includes(entry));
2528
2186
  return { files, dirs };
2529
2187
  }
2530
2188
  async exists(filePath) {
2531
- const readPath = this.getPath(filePath);
2532
- return await FileSys.exists(readPath);
2189
+ return await FileSys2.exists(this.getPath(filePath));
2533
2190
  }
2534
2191
  async remove(filePath) {
2535
2192
  const readPath = this.getPath(filePath);
2536
- if (await FileSys.fileExists(readPath))
2537
- await FileSys.delete(readPath);
2193
+ if (await FileSys2.fileExists(readPath))
2194
+ await FileSys2.delete(readPath);
2538
2195
  this.logger.verbose(`Remove file ${readPath}`);
2539
2196
  return this;
2540
2197
  }
2541
2198
  async removeDir(dirPath) {
2542
2199
  const readPath = path8.join(this.getPath(dirPath), ".");
2543
- if (await FileSys.entryExists(readPath))
2200
+ if (await FileSys2.entryExists(readPath))
2544
2201
  await rm3(readPath, { recursive: true, force: true });
2545
2202
  this.logger.verbose(`Remove directory ${readPath}`);
2546
2203
  return this;
@@ -2548,22 +2205,22 @@ class Executor {
2548
2205
  async writeFile(filePath, content, { overwrite = true, silent = false } = {}) {
2549
2206
  const writePath = this.getPath(filePath);
2550
2207
  const dir = path8.dirname(writePath);
2551
- if (!await FileSys.dirExists(dir))
2552
- await mkdir3(dir, { recursive: true });
2208
+ if (!await FileSys2.dirExists(dir))
2209
+ await mkdir2(dir, { recursive: true });
2553
2210
  let contentStr = typeof content === "string" ? content : `${JSON.stringify(content, null, 2)}
2554
2211
  `;
2555
- if (await FileSys.fileExists(writePath)) {
2556
- const currentContent = await FileSys.readText(writePath);
2212
+ if (await FileSys2.fileExists(writePath)) {
2213
+ const currentContent = await FileSys2.readText(writePath);
2557
2214
  if (currentContent === contentStr || !overwrite) {
2558
2215
  this.logger.verbose(`File ${writePath} is unchanged`);
2559
2216
  contentStr = currentContent;
2560
2217
  } else {
2561
- await FileSys.writeText(writePath, contentStr);
2218
+ await FileSys2.writeText(writePath, contentStr);
2562
2219
  if (Logger2.isVerbose())
2563
2220
  this.logger.rawLog(chalk2.yellow(`File Update: ${filePath}`));
2564
2221
  }
2565
2222
  } else {
2566
- await FileSys.writeText(writePath, contentStr);
2223
+ await FileSys2.writeText(writePath, contentStr);
2567
2224
  if (!silent)
2568
2225
  this.logger.rawLog(chalk2.green(`File Create: ${filePath}`));
2569
2226
  }
@@ -2578,21 +2235,19 @@ class Executor {
2578
2235
  return { filePath, content };
2579
2236
  }
2580
2237
  async readFile(filePath) {
2581
- const readPath = this.getPath(filePath);
2582
- return await FileSys.readText(readPath);
2238
+ return await FileSys2.readText(this.getPath(filePath));
2583
2239
  }
2584
2240
  async readJson(filePath) {
2585
- const readPath = this.getPath(filePath);
2586
- return await FileSys.readJson(readPath);
2241
+ return await FileSys2.readJson(this.getPath(filePath));
2587
2242
  }
2588
2243
  async cp(srcPath, destPath, { dereference = false } = {}) {
2589
2244
  const src = this.getPath(srcPath);
2590
2245
  const dest = this.getPath(destPath);
2591
- if (!await FileSys.exists(src))
2246
+ if (!await FileSys2.exists(src))
2592
2247
  return;
2593
2248
  const isDirectory = (await stat2(src)).isDirectory();
2594
- if (!await FileSys.exists(dest) && isDirectory)
2595
- await mkdir3(dest, { recursive: true });
2249
+ if (!await FileSys2.exists(dest) && isDirectory)
2250
+ await mkdir2(dest, { recursive: true });
2596
2251
  if (dereference || process.platform === "win32")
2597
2252
  await cpEntry(src, dest, { recursive: isDirectory, dereference: true, force: true });
2598
2253
  else
@@ -2617,19 +2272,10 @@ class Executor {
2617
2272
  async getTsConfig(pathname = "tsconfig.json", { refresh } = {}) {
2618
2273
  if (this.#tsconfig && !refresh)
2619
2274
  return this.#tsconfig;
2620
- const tsconfig = await this.readJson(pathname);
2275
+ let tsconfig = await this.readJson(pathname);
2621
2276
  if (tsconfig.extends) {
2622
- const extendsTsconfig = await this.getTsConfig(tsconfig.extends);
2623
- const result = {
2624
- ...extendsTsconfig,
2625
- ...tsconfig,
2626
- compilerOptions: {
2627
- ...extendsTsconfig.compilerOptions,
2628
- ...tsconfig.compilerOptions
2629
- }
2630
- };
2631
- this.#tsconfig = result;
2632
- return result;
2277
+ const base = await this.getTsConfig(tsconfig.extends, { refresh });
2278
+ tsconfig = { ...base, ...tsconfig, compilerOptions: { ...base.compilerOptions, ...tsconfig.compilerOptions } };
2633
2279
  }
2634
2280
  this.#tsconfig = tsconfig;
2635
2281
  return tsconfig;
@@ -2665,6 +2311,7 @@ class Executor {
2665
2311
  scanInfo,
2666
2312
  overwrite = true
2667
2313
  }, dict = {}, options = {}) {
2314
+ const convertPath = (target) => Object.entries(dict).reduce((converted, [key, value]) => converted.replace(new RegExp(`__${key}__`, "g"), value), target);
2668
2315
  if (targetPath.endsWith(".ts") || targetPath.endsWith(".tsx")) {
2669
2316
  const getContent = await import(templatePath);
2670
2317
  const result = await getContent.default(scanInfo ?? null, dict, options);
@@ -2672,24 +2319,21 @@ class Executor {
2672
2319
  return null;
2673
2320
  const filename = typeof result === "object" ? result.filename : path8.basename(targetPath).replace(".js", ".ts");
2674
2321
  const content = typeof result === "object" ? result.content : result;
2675
- const dirname = path8.dirname(targetPath);
2676
- const convertedTargetPath = Object.entries(dict).reduce((path, [key, value]) => path.replace(new RegExp(`__${key}__`, "g"), value), `${dirname}/${filename}`);
2322
+ const convertedTargetPath = convertPath(`${path8.dirname(targetPath)}/${filename}`);
2677
2323
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
2678
2324
  return this.writeFile(convertedTargetPath, content, { overwrite });
2679
2325
  } else if (targetPath.endsWith(".template")) {
2680
- const content = await FileSys.readText(templatePath);
2681
- const convertedTargetPath = Object.entries(dict).reduce((path, [key, value]) => path.replace(new RegExp(`__${key}__`, "g"), value), targetPath.slice(0, -9));
2326
+ const content = await FileSys2.readText(templatePath);
2327
+ const convertedTargetPath = convertPath(targetPath.slice(0, -9));
2682
2328
  const convertedContent = Object.entries(dict).reduce((data, [key, value]) => data.replace(new RegExp(`<%= ${key} %>`, "g"), value), content);
2683
2329
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
2684
- return this.writeFile(convertedTargetPath, convertedContent, {
2685
- overwrite
2686
- });
2330
+ return this.writeFile(convertedTargetPath, convertedContent, { overwrite });
2687
2331
  } else if (staticTemplateFileExtensions.has(path8.extname(targetPath).toLowerCase())) {
2688
- const convertedTargetPath = Object.entries(dict).reduce((path, [key, value]) => path.replace(new RegExp(`__${key}__`, "g"), value), targetPath);
2332
+ const convertedTargetPath = convertPath(targetPath);
2689
2333
  const writePath = this.getPath(convertedTargetPath);
2690
2334
  const dirname = path8.dirname(writePath);
2691
- if (!await FileSys.dirExists(dirname))
2692
- await mkdir3(dirname, { recursive: true });
2335
+ if (!await FileSys2.dirExists(dirname))
2336
+ await mkdir2(dirname, { recursive: true });
2693
2337
  await copyFile(templatePath, writePath);
2694
2338
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
2695
2339
  return { filePath: writePath, content: "" };
@@ -2706,12 +2350,10 @@ class Executor {
2706
2350
  }) {
2707
2351
  const templateRoot = await this.#resolveTemplateRoot();
2708
2352
  const templatePath = `${templateRoot}${template ? `/${template}` : ""}`;
2709
- const prefixTemplatePath = templatePath;
2710
- if ((await stat2(prefixTemplatePath)).isFile()) {
2711
- const filename = path8.basename(prefixTemplatePath);
2353
+ if ((await stat2(templatePath)).isFile()) {
2712
2354
  const fileContent = await this.#applyTemplateFile({
2713
- templatePath: prefixTemplatePath,
2714
- targetPath: path8.join(basePath, filename),
2355
+ templatePath,
2356
+ targetPath: path8.join(basePath, path8.basename(templatePath)),
2715
2357
  scanInfo,
2716
2358
  overwrite
2717
2359
  }, dict, options);
@@ -2747,17 +2389,13 @@ class Executor {
2747
2389
  path8.resolve(getDirname2(import.meta.url), "../cli/templates")
2748
2390
  ];
2749
2391
  for (const candidate of candidates) {
2750
- if (await FileSys.dirExists(candidate))
2392
+ if (await FileSys2.dirExists(candidate))
2751
2393
  return candidate;
2752
2394
  }
2753
2395
  return candidates[0];
2754
2396
  }
2755
2397
  async applyTemplate(options) {
2756
- const dict = {
2757
- ...options.dict ?? {},
2758
- ...Object.fromEntries(Object.entries(options.dict ?? {}).map(([key, value]) => [capitalize(key), capitalize(value)]))
2759
- };
2760
- const fileContents = await this._applyTemplate({ ...options, dict });
2398
+ const fileContents = await this._applyTemplate({ ...options, dict: withCapitalizedDict(options.dict) });
2761
2399
  await this.#formatAppliedTemplate(fileContents);
2762
2400
  return fileContents;
2763
2401
  }
@@ -2774,7 +2412,7 @@ class Executor {
2774
2412
  }
2775
2413
  }
2776
2414
  async getTypeChecker() {
2777
- const { TypeChecker } = await import("./typeChecker-3xgrzc2v.js");
2415
+ const { TypeChecker } = await import("./typeChecker-px49mezc.js");
2778
2416
  this.typeChecker ??= new TypeChecker(this);
2779
2417
  return this.typeChecker;
2780
2418
  }
@@ -2852,12 +2490,11 @@ class WorkspaceExecutor extends Executor {
2852
2490
  this.workspaceRoot = workspaceRoot;
2853
2491
  this.repoName = repoName;
2854
2492
  }
2855
- static #execs = new Map;
2856
2493
  static fromRoot({
2857
2494
  workspaceRoot = process.cwd(),
2858
2495
  repoName = resolveRepoName(workspaceRoot)
2859
2496
  } = {}) {
2860
- return WorkspaceExecutor.#execs.get(repoName) ?? new WorkspaceExecutor({ workspaceRoot, repoName });
2497
+ return new WorkspaceExecutor({ workspaceRoot, repoName });
2861
2498
  }
2862
2499
  static getBaseDevEnv(envPath) {
2863
2500
  const sourceEnv = envPath ? { ...process.env, ...parseEnvFile(envPath) } : process.env;
@@ -2896,13 +2533,9 @@ class WorkspaceExecutor extends Executor {
2896
2533
  return await WorkspaceInfo.fromExecutor(this);
2897
2534
  }
2898
2535
  async getApps() {
2899
- if (!await FileSys.dirExists(`${this.workspaceRoot}/apps`))
2900
- return [];
2901
2536
  return await this.#getDirHasFile(`${this.workspaceRoot}/apps`, "akan.config.ts");
2902
2537
  }
2903
2538
  async getLibs() {
2904
- if (!await FileSys.dirExists(`${this.workspaceRoot}/libs`))
2905
- return [];
2906
2539
  return await this.#getDirHasFile(`${this.workspaceRoot}/libs`, "akan.config.ts");
2907
2540
  }
2908
2541
  async getSyss() {
@@ -2910,8 +2543,6 @@ class WorkspaceExecutor extends Executor {
2910
2543
  return [appNames, libNames];
2911
2544
  }
2912
2545
  async getPkgs() {
2913
- if (!await FileSys.dirExists(`${this.workspaceRoot}/pkgs`))
2914
- return [];
2915
2546
  return await this.#getDirHasFile(`${this.workspaceRoot}/pkgs`, "package.json");
2916
2547
  }
2917
2548
  async getExecs() {
@@ -2976,6 +2607,8 @@ class WorkspaceExecutor extends Executor {
2976
2607
  return stdout.split("\x00").filter((file) => !!file).sort();
2977
2608
  }
2978
2609
  async#getDirHasFile(basePath, targetFilename) {
2610
+ if (!await FileSys2.dirExists(basePath))
2611
+ return [];
2979
2612
  const AVOID_DIRS = ["node_modules", "dist", "public", "webkit"];
2980
2613
  const getDirs = async (dirname, maxDepth = 3, results = [], prefix = "") => {
2981
2614
  const dirs = await this.readdir(dirname);
@@ -2983,8 +2616,8 @@ class WorkspaceExecutor extends Executor {
2983
2616
  if (AVOID_DIRS.includes(dir))
2984
2617
  return;
2985
2618
  const dirPath = path8.join(dirname, dir);
2986
- if (await FileSys.dirExists(dirPath)) {
2987
- const hasTargetFile = await FileSys.fileExists(path8.join(dirPath, targetFilename));
2619
+ if (await FileSys2.dirExists(dirPath)) {
2620
+ const hasTargetFile = await FileSys2.fileExists(path8.join(dirPath, targetFilename));
2988
2621
  if (hasTargetFile)
2989
2622
  results.push(`${prefix}${dir}`);
2990
2623
  if (maxDepth > 0)
@@ -2993,39 +2626,25 @@ class WorkspaceExecutor extends Executor {
2993
2626
  }));
2994
2627
  return results;
2995
2628
  };
2996
- return await getDirs(basePath);
2629
+ return (await getDirs(basePath)).sort((a, b) => a.localeCompare(b));
2997
2630
  }
2998
- async getScalarConstantFiles() {
2631
+ async#fromEverySys(read) {
2999
2632
  const [appNames, libNames] = await this.getSyss();
3000
- const scalarConstantExampleFiles = [
3001
- ...(await Promise.all(appNames.map((appName) => AppExecutor.from(this, appName).getScalarConstantFiles()))).flat(),
3002
- ...(await Promise.all(libNames.map((libName) => LibExecutor.from(this, libName).getScalarConstantFiles()))).flat()
3003
- ];
3004
- return scalarConstantExampleFiles;
2633
+ const fromApps = await Promise.all(appNames.map((appName) => read(AppExecutor.from(this, appName))));
2634
+ const fromLibs = await Promise.all(libNames.map((libName) => read(LibExecutor.from(this, libName))));
2635
+ return [...fromApps.flat(), ...fromLibs.flat()];
2636
+ }
2637
+ async getScalarConstantFiles() {
2638
+ return await this.#fromEverySys((sys) => sys.getScalarConstantFiles());
3005
2639
  }
3006
2640
  async getConstantFiles() {
3007
- const [appNames, libNames] = await this.getSyss();
3008
- const moduleConstantExampleFiles = [
3009
- ...(await Promise.all(appNames.map((appName) => AppExecutor.from(this, appName).getConstantFiles()))).flat(),
3010
- ...(await Promise.all(libNames.map((libName) => LibExecutor.from(this, libName).getConstantFiles()))).flat()
3011
- ];
3012
- return moduleConstantExampleFiles;
2641
+ return await this.#fromEverySys((sys) => sys.getConstantFiles());
3013
2642
  }
3014
2643
  async getDictionaryFiles() {
3015
- const [appNames, libNames] = await this.getSyss();
3016
- const moduleDictionaryExampleFiles = [
3017
- ...(await Promise.all(appNames.map((appName) => AppExecutor.from(this, appName).getDictionaryFiles()))).flat(),
3018
- ...(await Promise.all(libNames.map((libName) => LibExecutor.from(this, libName).getDictionaryFiles()))).flat()
3019
- ];
3020
- return moduleDictionaryExampleFiles;
2644
+ return await this.#fromEverySys((sys) => sys.getDictionaryFiles());
3021
2645
  }
3022
2646
  async getViewFiles() {
3023
- const [appNames, libNames] = await this.getSyss();
3024
- const viewExampleFiles = [
3025
- ...(await Promise.all(appNames.map((appName) => AppExecutor.from(this, appName).getViewsSourceCode()))).flat(),
3026
- ...(await Promise.all(libNames.map((libName) => LibExecutor.from(this, libName).getViewsSourceCode()))).flat()
3027
- ];
3028
- return viewExampleFiles;
2647
+ return await this.#fromEverySys((sys) => sys.getViewsSourceCode());
3029
2648
  }
3030
2649
  }
3031
2650
  var scanFacetDirs = ["ui", "webkit", "srvkit", "common", "plugin"];
@@ -3089,24 +2708,11 @@ class SysExecutor extends Executor {
3089
2708
  scanInfo,
3090
2709
  options: { exec: this, facet }
3091
2710
  })),
3092
- ...scanInfo.getDatabaseModules().map((model) => this._applyTemplate({
3093
- basePath: `lib/${model}`,
3094
- template: "moduleRoot",
3095
- scanInfo,
3096
- dict: { model, Model: capitalize(model) }
3097
- })),
3098
- ...scanInfo.getServiceModules().map((model) => this._applyTemplate({
3099
- basePath: `lib/_${model}`,
3100
- template: "moduleRoot",
3101
- scanInfo,
3102
- dict: { model, Model: capitalize(model) }
3103
- })),
3104
- ...scanInfo.getScalarModules().map((model) => this._applyTemplate({
3105
- basePath: `lib/__scalar/${model}`,
3106
- template: "moduleRoot",
3107
- scanInfo,
3108
- dict: { model, Model: capitalize(model) }
3109
- }))
2711
+ ...[
2712
+ ...scanInfo.getDatabaseModules().map((model) => [model, `lib/${model}`]),
2713
+ ...scanInfo.getServiceModules().map((model) => [model, `lib/_${model}`]),
2714
+ ...scanInfo.getScalarModules().map((model) => [model, `lib/__scalar/${model}`])
2715
+ ].map(([model, basePath]) => this._applyTemplate({ basePath, template: "moduleRoot", scanInfo, dict: { model, Model: capitalize(model) } }))
3110
2716
  ];
3111
2717
  }
3112
2718
  async scan({
@@ -3173,40 +2779,38 @@ class SysExecutor extends Executor {
3173
2779
  return { filePath, content };
3174
2780
  }
3175
2781
  async getDatabaseModules() {
3176
- const databaseModules = (await this.readdir("lib")).filter((name) => !name.startsWith("_") && !name.startsWith("__") && !name.endsWith(".ts")).filter((name) => Bun.file(`${this.cwdPath}/lib/${name}/${name}.constant.ts`).exists());
3177
- return databaseModules;
2782
+ return (await this.readdir("lib")).filter((name) => !name.startsWith("_") && !name.endsWith(".ts")).filter((name) => existsSync2(`${this.cwdPath}/lib/${name}/${name}.constant.ts`));
3178
2783
  }
3179
2784
  async getServiceModules() {
3180
- const serviceModules = (await this.readdir("lib")).filter((name) => name.startsWith("_") && !name.startsWith("__")).filter((name) => Bun.file(`${this.cwdPath}/lib/${name}/${name}.service.ts`).exists());
3181
- return serviceModules;
2785
+ return (await this.readdir("lib")).filter((name) => name.startsWith("_") && !name.startsWith("__")).filter((name) => existsSync2(`${this.cwdPath}/lib/${name}/${name.slice(1)}.service.ts`));
3182
2786
  }
3183
2787
  async getScalarModules() {
3184
- const scalarModules = (await this.readdir("lib/__scalar")).filter((name) => !name.startsWith("_")).filter((name) => Bun.file(`${this.cwdPath}/lib/__scalar/${name}/${name}.constant.ts`).exists());
3185
- return scalarModules;
2788
+ return (await this.readdir("lib/__scalar")).filter((name) => !name.startsWith("_")).filter((name) => existsSync2(`${this.cwdPath}/lib/__scalar/${name}/${name}.constant.ts`));
2789
+ }
2790
+ async#getComponentModules(role) {
2791
+ return (await this.readdir("lib")).filter((name) => !name.startsWith("_") && !name.endsWith(".ts")).filter((name) => existsSync2(`${this.cwdPath}/lib/${name}/${capitalize(name)}.${role}.tsx`));
2792
+ }
2793
+ async#getComponentSources(role) {
2794
+ const modules = await this.#getComponentModules(role);
2795
+ return Promise.all(modules.map((name) => this.getLocalFile(`lib/${name}/${capitalize(name)}.${role}.tsx`)));
3186
2796
  }
3187
2797
  async getViewComponents() {
3188
- const viewComponents = (await this.readdir("lib")).filter((name) => !name.startsWith("_") && !name.startsWith("__") && !name.endsWith(".ts")).filter((name) => Bun.file(`${this.cwdPath}/lib/${name}/${capitalize(name)}.View.tsx`).exists());
3189
- return viewComponents;
2798
+ return await this.#getComponentModules("View");
3190
2799
  }
3191
2800
  async getUnitComponents() {
3192
- const unitComponents = (await this.readdir("lib")).filter((name) => !name.startsWith("_") && !name.startsWith("__") && !name.endsWith(".ts")).filter((name) => Bun.file(`${this.cwdPath}/lib/${name}/${capitalize(name)}.Unit.tsx`).exists());
3193
- return unitComponents;
2801
+ return await this.#getComponentModules("Unit");
3194
2802
  }
3195
2803
  async getTemplateComponents() {
3196
- const templateComponents = (await this.readdir("lib")).filter((name) => !name.startsWith("_") && !name.startsWith("__") && !name.endsWith(".ts")).filter((name) => Bun.file(`${this.cwdPath}/lib/${name}/${capitalize(name)}.Template.tsx`).exists());
3197
- return templateComponents;
2804
+ return await this.#getComponentModules("Template");
3198
2805
  }
3199
2806
  async getViewsSourceCode() {
3200
- const viewComponents = await this.getViewComponents();
3201
- return Promise.all(viewComponents.map((viewComponent) => this.getLocalFile(`lib/${viewComponent}/${capitalize(viewComponent)}.View.tsx`)));
2807
+ return await this.#getComponentSources("View");
3202
2808
  }
3203
2809
  async getUnitsSourceCode() {
3204
- const unitComponents = await this.getUnitComponents();
3205
- return Promise.all(unitComponents.map((unitComponent) => this.getLocalFile(`lib/${unitComponent}/${capitalize(unitComponent)}.Unit.tsx`)));
2810
+ return await this.#getComponentSources("Unit");
3206
2811
  }
3207
2812
  async getTemplatesSourceCode() {
3208
- const templateComponents = await this.getTemplateComponents();
3209
- return Promise.all(templateComponents.map((templateComponent) => this.getLocalFile(`lib/${templateComponent}/${capitalize(templateComponent)}.Template.tsx`)));
2813
+ return await this.#getComponentSources("Template");
3210
2814
  }
3211
2815
  async getScalarConstantFiles() {
3212
2816
  const scalarModules = await this.getScalarModules();
@@ -3214,7 +2818,7 @@ class SysExecutor extends Executor {
3214
2818
  }
3215
2819
  async getScalarDictionaryFiles() {
3216
2820
  const scalarModules = await this.getScalarModules();
3217
- return Promise.all(scalarModules.map((scalarModule) => this.getLocalFile(`lib/${scalarModule}/${scalarModule}.dictionary.ts`)));
2821
+ return Promise.all(scalarModules.map((scalarModule) => this.getLocalFile(`lib/__scalar/${scalarModule}/${scalarModule}.dictionary.ts`)));
3218
2822
  }
3219
2823
  async getConstantFiles() {
3220
2824
  const modules = await this.getModules();
@@ -3236,16 +2840,8 @@ class SysExecutor extends Executor {
3236
2840
  return Promise.all(modules.map((module) => this.getLocalFile(`lib/${module}/${module}.dictionary.ts`)));
3237
2841
  }
3238
2842
  async applyTemplate(options) {
3239
- const dict = {
3240
- ...options.dict ?? {},
3241
- ...Object.fromEntries(Object.entries(options.dict ?? {}).map(([key, value]) => [capitalize(key), capitalize(value)]))
3242
- };
3243
2843
  const scanInfo = await this.scan();
3244
- const fileContents = await this._applyTemplate({
3245
- ...options,
3246
- scanInfo,
3247
- dict
3248
- });
2844
+ const fileContents = await this._applyTemplate({ ...options, scanInfo, dict: withCapitalizedDict(options.dict) });
3249
2845
  await this.scan();
3250
2846
  return fileContents;
3251
2847
  }
@@ -3263,15 +2859,8 @@ class AppExecutor extends SysExecutor {
3263
2859
  super({ workspace, name, type: "app" });
3264
2860
  this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/apps/${name}`);
3265
2861
  }
3266
- static #execs = new Map;
3267
2862
  static from(executor, name) {
3268
- const exec = AppExecutor.#execs.get(name);
3269
- if (exec)
3270
- return exec;
3271
- else if (executor instanceof WorkspaceExecutor)
3272
- return new AppExecutor({ workspace: executor, name });
3273
- else
3274
- return new AppExecutor({ workspace: executor.workspace, name });
2863
+ return new AppExecutor({ workspace: executor instanceof WorkspaceExecutor ? executor : executor.workspace, name });
3275
2864
  }
3276
2865
  getEnv() {
3277
2866
  return WorkspaceExecutor.getBaseDevEnv().env;
@@ -3287,10 +2876,8 @@ class AppExecutor extends SysExecutor {
3287
2876
  return basePort + appIndex + portOffset;
3288
2877
  }
3289
2878
  getCommandEnv(env = {}) {
3290
- const basePort = 8282;
3291
- const portOffset = WorkspaceExecutor.getBaseDevEnv().portOffset;
3292
- const PORT = (basePort + portOffset).toString();
3293
- const AKAN_PUBLIC_SERVER_PORT = portOffset ? (8282 + portOffset).toString() : undefined;
2879
+ const { portOffset } = WorkspaceExecutor.getBaseDevEnv();
2880
+ const PORT = (8282 + portOffset).toString();
3294
2881
  return {
3295
2882
  ...process.env,
3296
2883
  AKAN_PUBLIC_APP_NAME: this.name,
@@ -3298,7 +2885,7 @@ class AppExecutor extends SysExecutor {
3298
2885
  NODE_NO_WARNINGS: "1",
3299
2886
  PORT,
3300
2887
  AKAN_PUBLIC_CLIENT_PORT: PORT,
3301
- ...AKAN_PUBLIC_SERVER_PORT ? { AKAN_PUBLIC_SERVER_PORT } : {},
2888
+ ...portOffset ? { AKAN_PUBLIC_SERVER_PORT: PORT } : {},
3302
2889
  ...env
3303
2890
  };
3304
2891
  }
@@ -3355,16 +2942,7 @@ class AppExecutor extends SysExecutor {
3355
2942
  if (this.#publicEnv)
3356
2943
  return this.#publicEnv;
3357
2944
  const searchPatterns = [...patterns, "AKAN_PUBLIC_*"];
3358
- const regexes = searchPatterns.map((pattern) => {
3359
- let body = "";
3360
- for (const ch of pattern) {
3361
- if (ch === "*")
3362
- body += ".*";
3363
- else
3364
- body += ch.replace(/[.+^${}()|[\]\\?]/g, "\\$&");
3365
- }
3366
- return new RegExp(`^${body}$`);
3367
- });
2945
+ const regexes = searchPatterns.map((pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.+^${}()|[\]\\?]/g, "\\$&")).join(".*")}$`));
3368
2946
  const publicEnv = {};
3369
2947
  for (const [k, v] of Object.entries(process.env)) {
3370
2948
  if (typeof v !== "string")
@@ -3396,7 +2974,7 @@ class AppExecutor extends SysExecutor {
3396
2974
  const pageRoots = await this.getPageRoots();
3397
2975
  const libKeyPrefixes = pageRoots.map((root) => root.keyPrefix).filter(Boolean);
3398
2976
  for (const root of pageRoots) {
3399
- if (!await FileSys.dirExists(root.dir))
2977
+ if (!await FileSys2.dirExists(root.dir))
3400
2978
  continue;
3401
2979
  for await (const rel of glob.scan({
3402
2980
  cwd: root.dir,
@@ -3473,7 +3051,7 @@ class AppExecutor extends SysExecutor {
3473
3051
  const entries = await readDirEntries(libsDir).catch(() => []);
3474
3052
  for (const entry of entries.sort()) {
3475
3053
  const dir = `${libsDir}/${entry}`;
3476
- if (!await FileSys.dirExists(dir))
3054
+ if (!await FileSys2.dirExists(dir))
3477
3055
  continue;
3478
3056
  roots.push({ dir, realDir: await realpath(dir), keyPrefix: `${parent}${AppExecutor.#pageLibsDir}/${entry}/` });
3479
3057
  }
@@ -3515,7 +3093,7 @@ class AppExecutor extends SysExecutor {
3515
3093
  async#resolvePageLibs(syncPageLibs, libDeps) {
3516
3094
  if (!syncPageLibs)
3517
3095
  return [];
3518
- const hasPageDir = async (lib) => await FileSys.dirExists(`${this.workspace.workspaceRoot}/libs/${lib}/page`);
3096
+ const hasPageDir = async (lib) => await FileSys2.dirExists(`${this.workspace.workspaceRoot}/libs/${lib}/page`);
3519
3097
  if (syncPageLibs === true) {
3520
3098
  const libs = [];
3521
3099
  for (const lib of libDeps)
@@ -3555,7 +3133,7 @@ class AppExecutor extends SysExecutor {
3555
3133
  } catch (error) {
3556
3134
  if (!isWindows)
3557
3135
  throw error;
3558
- await mkdir3(linkPath, { recursive: true });
3136
+ await mkdir2(linkPath, { recursive: true });
3559
3137
  await cpEntry(targetPath, linkPath, { recursive: true, dereference: true, force: true });
3560
3138
  }
3561
3139
  }
@@ -3587,14 +3165,14 @@ class AppExecutor extends SysExecutor {
3587
3165
  appPath: this.cwdPath,
3588
3166
  executor: this,
3589
3167
  getPath: (rel) => this.getPath(rel),
3590
- fileExists: (rel) => FileSys.fileExists(this.getPath(rel)),
3168
+ fileExists: (rel) => FileSys2.fileExists(this.getPath(rel)),
3591
3169
  readFile: (rel) => this.readFile(rel),
3592
3170
  writeFile: async (rel, content, opts) => {
3593
3171
  await this.writeFile(rel, content, opts);
3594
3172
  },
3595
3173
  readEnvClient: async () => {
3596
3174
  const envClientPath = path8.join(this.cwdPath, "env", "env.client.ts");
3597
- if (!await FileSys.fileExists(envClientPath))
3175
+ if (!await FileSys2.fileExists(envClientPath))
3598
3176
  return null;
3599
3177
  try {
3600
3178
  const envUrl = pathToFileURL(envClientPath);
@@ -3650,15 +3228,8 @@ class LibExecutor extends SysExecutor {
3650
3228
  super({ workspace, name, type: "lib" });
3651
3229
  this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/libs/${name}`);
3652
3230
  }
3653
- static #execs = new Map;
3654
3231
  static from(executor, name) {
3655
- const exec = LibExecutor.#execs.get(name);
3656
- if (exec)
3657
- return exec;
3658
- else if (executor instanceof WorkspaceExecutor)
3659
- return new LibExecutor({ workspace: executor, name });
3660
- else
3661
- return new LibExecutor({ workspace: executor.workspace, name });
3232
+ return new LibExecutor({ workspace: executor instanceof WorkspaceExecutor ? executor : executor.workspace, name });
3662
3233
  }
3663
3234
  #akanConfig = null;
3664
3235
  async getConfig({ refresh } = {}) {
@@ -3681,9 +3252,7 @@ class PkgExecutor extends Executor {
3681
3252
  this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/pkgs/${name}`);
3682
3253
  }
3683
3254
  static from(executor, name) {
3684
- if (executor instanceof WorkspaceExecutor)
3685
- return new PkgExecutor({ workspace: executor, name });
3686
- return new PkgExecutor({ workspace: executor.workspace, name });
3255
+ return new PkgExecutor({ workspace: executor instanceof WorkspaceExecutor ? executor : executor.workspace, name });
3687
3256
  }
3688
3257
  #scanInfo = null;
3689
3258
  async scan({ refresh } = {}) {
@@ -3729,16 +3298,8 @@ class PkgExecutor extends Executor {
3729
3298
  }
3730
3299
  if (missingDeps.length > 0)
3731
3300
  throw new Error(`Missing dependency versions in root package.json: ${missingDeps.join(", ")}`);
3732
- const toDependencyEntries = (names) => names.map((dep) => {
3733
- const version = dependencyVersions.get(dep);
3734
- if (!version)
3735
- throw new Error(`Missing dependency versions in root package.json: ${dep}`);
3736
- return [dep, version];
3737
- });
3738
- return {
3739
- dependencies: Object.fromEntries(toDependencyEntries(dependencyNames)),
3740
- devDependencies: Object.fromEntries(toDependencyEntries(devDependencyNames))
3741
- };
3301
+ const toDependencyMap = (names) => Object.fromEntries(names.map((dep) => [dep, dependencyVersions.get(dep)]));
3302
+ return { dependencies: toDependencyMap(dependencyNames), devDependencies: toDependencyMap(devDependencyNames) };
3742
3303
  }
3743
3304
  async updatePackageJsonDependencies(dependencies = [], devDependencies = []) {
3744
3305
  const [rootPackageJson, pkgJson] = await Promise.all([this.workspace.getPackageJson(), this.getPackageJson()]);