@akanjs/cli 3.1.1-rc.9 → 3.1.2-rc.0

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 (207) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-dyc45f5w.js +11 -0
  3. package/{CodeAgentRpcHost-9g27hmer.js → CodeAgentRpcHost-6dzfkvsc.js} +1 -1
  4. package/CodeAgentRpcListener-tcwrdvst.js +182 -0
  5. package/{CodeTui-z5vkm9ea.js → CodeTui-q55b2zrn.js} +25 -8
  6. package/TunnelShare-hdq9h1hr.js +14 -0
  7. package/agent.command-20zaqe60.js +49 -0
  8. package/akanCode.js +13 -8
  9. package/{application.command-wthg8nn9.js → application.command-nd0fshsk.js} +45 -12
  10. package/{applicationBuildRunner-t2r84sz6.js → applicationBuildRunner-s13x3zqb.js} +14 -10
  11. package/buildBatch.proc.js +7 -7
  12. package/{cloud.command-sz11hpre.js → cloud.command-8kbddsz9.js} +28 -19
  13. package/cloud.script-hgvvajm3.js +27 -0
  14. package/code.command-625bg8s8.js +345 -0
  15. package/commandManifest.json +1 -1
  16. package/{context.command-15j9b7c0.js → context.command-p6haqjay.js} +20 -18
  17. package/context.runner-rsnqnk9j.js +27 -0
  18. package/{dependencyScanner-3afj2vt1.js → dependencyScanner-78sq8m4q.js} +2 -2
  19. package/{devTui-q7k7bakd.js → devTui-evr3b35y.js} +1 -1
  20. package/{fileSys-wzzrntkw.js → fileSys-zpvt5gtf.js} +1 -1
  21. package/{guideline.command-snh85ctf.js → guideline.command-195g0h9a.js} +4 -4
  22. package/guidelines/agentRule/agentRule.instruction.md +22 -8
  23. package/guidelines/conventions/core.md +106 -0
  24. package/guidelines/conventions/rules/app.md +83 -0
  25. package/guidelines/conventions/rules/auth.md +46 -0
  26. package/guidelines/conventions/rules/config.md +60 -0
  27. package/guidelines/conventions/rules/constant.md +24 -0
  28. package/guidelines/conventions/rules/gates.md +32 -0
  29. package/guidelines/conventions/rules/layer.md +25 -0
  30. package/guidelines/conventions/rules/migration.md +27 -0
  31. package/guidelines/conventions/rules/module.md +90 -0
  32. package/guidelines/conventions/rules/page.md +56 -0
  33. package/guidelines/conventions/rules/sensitive.md +16 -0
  34. package/guidelines/conventions/rules/server.md +91 -0
  35. package/guidelines/conventions/rules/ssr.md +47 -0
  36. package/guidelines/conventions/rules/style.md +43 -0
  37. package/guidelines/conventions/rules/test.md +34 -0
  38. package/guidelines/conventions/rules/ts.md +95 -0
  39. package/guidelines/conventions/rules/tsx.md +76 -0
  40. package/guidelines/mcpRule/mcpRule.instruction.md +1 -1
  41. package/guidelines/pageRule/pageRule.instruction.md +8 -7
  42. package/guidelines/queryRule/queryRule.instruction.md +4 -0
  43. package/guidelines/runtimeRule/runtimeRule.instruction.md +35 -25
  44. package/guidelines/ssrRule/ssrRule.instruction.md +11 -10
  45. package/guidelines/transportRule/transportRule.instruction.md +5 -4
  46. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +4 -4
  47. package/incrementalBuilder.proc.js +7 -7
  48. package/{index-301pdbzz.js → index-00a7j05x.js} +7 -7
  49. package/{index-js6geqjn.js → index-0j1t1h2b.js} +3 -1
  50. package/{index-6txx6a9p.js → index-1h2jc0x3.js} +154 -88
  51. package/{index-55j120r8.js → index-1qsd8ft1.js} +65 -145
  52. package/{index-9th4gszy.js → index-2mwjshz5.js} +233 -1271
  53. package/index-2nxk8wgs.js +266 -0
  54. package/{index-j9vyj3dj.js → index-2phm56a1.js} +49 -8
  55. package/index-35j83zkd.js +61 -0
  56. package/index-4am4dvmf.js +29 -0
  57. package/index-75y7bcz4.js +28 -0
  58. package/index-7apsdr5g.js +487 -0
  59. package/{index-42j4a8zq.js → index-84h43kg6.js} +8 -6
  60. package/index-9bv479q5.js +1 -0
  61. package/{index-3wypz6xj.js → index-9zy8479y.js} +11 -5
  62. package/{index-a5dhqkdr.js → index-a1vb3x7t.js} +273 -259
  63. package/{index-52w0fvh8.js → index-bns3wcpc.js} +15 -0
  64. package/index-cjmjvg4r.js +3622 -0
  65. package/{index-pcwzkdqb.js → index-defp4gmb.js} +1 -1
  66. package/index-ewbmfarf.js +1606 -0
  67. package/index-fbewhg4g.js +590 -0
  68. package/index-fhw7yq2d.js +653 -0
  69. package/{index-wcej7g4z.js → index-g500c5j9.js} +271 -105
  70. package/{index-74tjjsnc.js → index-g841cap9.js} +33 -37
  71. package/{index-2azahjaw.js → index-gr9thy79.js} +5 -5
  72. package/{index-4pf8g7ff.js → index-h7hehkw6.js} +3 -0
  73. package/{index-xjf5j657.js → index-hm0tn7qv.js} +1001 -91
  74. package/index-j6eeh5d7.js +138 -0
  75. package/{index-31es1yev.js → index-j7hwy56s.js} +108 -7
  76. package/{index-skk9zc1x.js → index-jc2zbwra.js} +2 -2
  77. package/{index-905qdgqp.js → index-khk05tsf.js} +1 -1
  78. package/{index-5nd1wtkv.js → index-p6x5b7hr.js} +1 -1
  79. package/{index-tvehn2sp.js → index-qd7xn2bk.js} +1 -1
  80. package/{index-a58emady.js → index-qw6814m4.js} +55 -17
  81. package/index-raz588b3.js +445 -0
  82. package/{index-at7bz0xq.js → index-s4nvxpzm.js} +2 -0
  83. package/{index-bt438yxm.js → index-sp0qsr7a.js} +116 -13
  84. package/{index-xb8809yb.js → index-sveq36gh.js} +40 -43
  85. package/{index-hmt54t45.js → index-t1t9wq9a.js} +4 -4
  86. package/index-t78230d7.js +191 -0
  87. package/index-tenw3mah.js +225 -0
  88. package/{index-qfp55x1y.js → index-tgqameyb.js} +4 -4
  89. package/{index-espk51ah.js → index-tp56652m.js} +6 -6
  90. package/index-w15mg3km.js +389 -0
  91. package/{index-dy0jx9ay.js → index-wwe9rsrx.js} +14 -0
  92. package/{index-2xcc2ax5.js → index-y4kcmbt2.js} +2 -2
  93. package/index-yf9wc28h.js +52 -0
  94. package/{index-0fz95kxe.js → index-zbrwnmf1.js} +9 -7
  95. package/{index-40brg4px.js → index-zttm13c3.js} +5 -5
  96. package/index.js +24 -23
  97. package/{library.command-gycrwhf1.js → library.command-63hgt9te.js} +4 -4
  98. package/{localRegistry.command-jtd8gaes.js → localRegistry.command-g3f8k25t.js} +46 -22
  99. package/{module.command-v6hgs1bc.js → module.command-r4sa2khp.js} +7 -6
  100. package/{package.command-shzpcfph.js → package.command-96eheyvd.js} +5 -5
  101. package/package.json +2 -2
  102. package/{page.command-ptxn5kqk.js → page.command-gs6d841d.js} +4 -4
  103. package/{pipeline.command-zz31pgax.js → pipeline.command-wdfvdbfj.js} +3 -3
  104. package/{primitive.command-a1vse91z.js → primitive.command-dfsv4mpe.js} +8 -7
  105. package/{projectTypecheck-2ztky9cf.js → projectTypecheck-kqj1t6hb.js} +1 -1
  106. package/{prompter-76k56b37.js → prompter-qrwx1p17.js} +2 -2
  107. package/quality.command-webzxee2.js +78 -0
  108. package/{repair.command-cvazbz99.js → repair.command-3r3j1xre.js} +7 -6
  109. package/{routeSourceValidator-6jd0q6r6.js → routeSourceValidator-4h947v7c.js} +13 -3
  110. package/{scalar.command-0acvyp26.js → scalar.command-e8y47j6d.js} +6 -5
  111. package/skills/akan-agent/SKILL.md +43 -0
  112. package/skills/akan-code/SKILL.md +38 -11
  113. package/skills/akan-debug/SKILL.md +41 -6
  114. package/skills/akan-deps/SKILL.md +1 -2
  115. package/skills/akan-err/SKILL.md +2 -1
  116. package/skills/akan-mcp/SKILL.md +40 -0
  117. package/skills/akan-page/SKILL.md +44 -0
  118. package/skills/akan-query/SKILL.md +39 -0
  119. package/skills/akan-runtime/SKILL.md +43 -0
  120. package/skills/akan-scaffold/SKILL.md +16 -6
  121. package/skills/akan-transport/SKILL.md +40 -0
  122. package/skills/akan-validate/SKILL.md +13 -11
  123. package/{subspace.command-822qx2bx.js → subspace.command-a1sf9n5a.js} +12 -10
  124. package/templates/__scalar/__model__/__model__.constant.ts +3 -5
  125. package/templates/__scalar/__model__/__model__.dictionary.ts +6 -5
  126. package/templates/__scalar/__model__/__model__.document.ts +3 -3
  127. package/templates/app/akan.config.ts +2 -3
  128. package/templates/app/env/env.client.ts +2 -4
  129. package/templates/app/env/env.client.type.ts +2 -3
  130. package/templates/app/env/env.server.ts +2 -3
  131. package/templates/app/lib/___appName__/__appName__.dictionary.ts +1 -2
  132. package/templates/app/lib/___appName__/__appName__.service.ts +3 -3
  133. package/templates/app/lib/___appName__/__appName__.signal.ts +5 -5
  134. package/templates/app/lib/___appName__/__appName__.store.ts +4 -6
  135. package/templates/app/lib/option.ts +2 -3
  136. package/templates/app/main.ts +2 -4
  137. package/templates/app/page/_index.tsx +3 -3
  138. package/templates/app/page/_layout.tsx +13 -10
  139. package/templates/appSample/lib/__scalar/workHistory/workHistory.constant.ts +1 -5
  140. package/templates/appSample/lib/__scalar/workHistory/workHistory.dictionary.ts +1 -1
  141. package/templates/appSample/lib/_noti/noti.signal.ts +1 -1
  142. package/templates/appSample/lib/task/Task.Template.tsx +2 -1
  143. package/templates/appSample/lib/task/Task.Unit.tsx +3 -2
  144. package/templates/appSample/lib/task/Task.Util.tsx +16 -4
  145. package/templates/appSample/lib/task/task.constant.ts +1 -5
  146. package/templates/appSample/lib/task/task.dictionary.ts +2 -8
  147. package/templates/appSample/lib/task/task.document.ts +1 -1
  148. package/templates/appSample/lib/task/task.signal.ts +14 -9
  149. package/templates/appSample/page/task/_index.tsx +2 -1
  150. package/templates/appSample/page/task/new.tsx +2 -1
  151. package/templates/appSample/srvkit/guards.ts +11 -0
  152. package/templates/appSample/ui/QuantityControl.tsx +5 -9
  153. package/templates/biomeForm.ts +144 -0
  154. package/templates/crudPages/[__model__Id]/edit/page.tsx +3 -3
  155. package/templates/crudPages/[__model__Id]/page.tsx +5 -5
  156. package/templates/crudPages/new/page.tsx +4 -3
  157. package/templates/crudPages/page.tsx +3 -3
  158. package/templates/crudSinglePage/page.tsx +9 -5
  159. package/templates/libRoot/akan.config.ts +2 -3
  160. package/templates/libRoot/lib/___libName__/__libName__.dictionary.ts +1 -2
  161. package/templates/libRoot/lib/___libName__/__libName__.service.ts +5 -4
  162. package/templates/libRoot/lib/___libName__/__libName__.signal.ts +6 -5
  163. package/templates/libRoot/lib/___libName__/__libName__.store.ts +5 -6
  164. package/templates/libRoot/lib/option.ts +1 -2
  165. package/templates/module/__Model__.Template.tsx +11 -10
  166. package/templates/module/__Model__.Unit.tsx +18 -5
  167. package/templates/module/__Model__.Util.tsx +9 -7
  168. package/templates/module/__Model__.View.tsx +9 -6
  169. package/templates/module/__Model__.Zone.tsx +25 -17
  170. package/templates/module/__model__.constant.ts +8 -9
  171. package/templates/module/__model__.dictionary.ts +16 -17
  172. package/templates/module/__model__.document.ts +6 -8
  173. package/templates/module/__model__.service.ts +3 -3
  174. package/templates/module/__model__.signal.ts +11 -10
  175. package/templates/module/__model__.store.ts +3 -5
  176. package/templates/service/__model__.dictionary.ts +5 -6
  177. package/templates/service/__model__.service.ts +3 -3
  178. package/templates/service/__model__.signal.ts +5 -4
  179. package/templates/service/__model__.store.ts +3 -5
  180. package/templates/workspaceRoot/.gitignore.template +4 -0
  181. package/templates/workspaceRoot/.vscode/settings.json.template +21 -21
  182. package/templates/workspaceRoot/AGENTS.md.template +4 -10
  183. package/{tunnel.command-ycmja19q.js → tunnel.command-dcb0wg93.js} +25 -13
  184. package/{typeChecker-px49mezc.js → typeChecker-j2jdnqsr.js} +1 -1
  185. package/typecheck.proc.js +6 -1
  186. package/verify.command-yyepccbh.js +93 -0
  187. package/{workflow.command-abb1d5xy.js → workflow.command-z5pg9ay0.js} +49 -14
  188. package/workspace.command-d7x5jttw.js +290 -0
  189. package/CodeAgent-8d5qs787.js +0 -9
  190. package/CodeAgentRpcListener-7p7z5dd7.js +0 -97
  191. package/TunnelShare-qkm8zp03.js +0 -14
  192. package/agent.command-ydftceda.js +0 -25
  193. package/cloud.script-nqevg5qw.js +0 -24
  194. package/code.command-9h3yrzhe.js +0 -167
  195. package/context.runner-8gg030b0.js +0 -25
  196. package/guidelines/conventions/conventions.instruction.md +0 -617
  197. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +0 -291
  198. package/index-2mwc0g0d.js +0 -49
  199. package/index-4vgbysa0.js +0 -279
  200. package/index-7md2g9vw.js +0 -6
  201. package/index-b70zct19.js +0 -856
  202. package/index-c6eggbee.js +0 -123
  203. package/index-zzvvc845.js +0 -74
  204. package/quality.command-ah8qcakd.js +0 -1478
  205. package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +0 -69
  206. package/templates/workspaceRoot/docs/GENERATED.md.template +0 -55
  207. package/workspace.command-qm7cw29v.js +0 -521
@@ -5,17 +5,17 @@ import {
5
5
  AkanAppConfig,
6
6
  Executor,
7
7
  WorkspaceExecutor
8
- } from "./index-wcej7g4z.js";
8
+ } from "./index-g500c5j9.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-xb8809yb.js";
15
+ } from "./index-sveq36gh.js";
16
16
  import {
17
17
  ExitCodeError
18
- } from "./index-3wypz6xj.js";
18
+ } from "./index-9zy8479y.js";
19
19
 
20
20
  // pkgs/@akanjs/devkit/mobile/desktopBin.ts
21
21
  import { chmod, mkdir, rename, rm, writeFile } from "fs/promises";
@@ -558,7 +558,8 @@ Set-Content -LiteralPath $env:AKAN_SIGNER_OUT -Value $subject -Encoding UTF8`;
558
558
  `)[0] ?? ""}` };
559
559
  }
560
560
  static async#subjectOf(run, archive, tmp, exe) {
561
- await run(["tar.exe", "-xzf", archive, "-C", tmp, exe]);
561
+ const tar = path4.join(process.env.SystemRoot ?? "C:\\Windows", "System32", "tar.exe");
562
+ await run([tar, "-xzf", archive, "-C", tmp, exe]);
562
563
  const extracted = path4.join(tmp, exe);
563
564
  if (!await Bun.file(extracted).exists())
564
565
  return { signer: null, unread: `the archive holds no ${exe}` };
@@ -706,7 +707,7 @@ class NativeAppLine {
706
707
  // pkgs/@akanjs/devkit/mobile/nativeConfig.ts
707
708
  import { readFileSync } from "fs";
708
709
  import path6 from "path";
709
- import { trimSlashes } from "akanjs/common";
710
+ import { LocalePath, trimSlashes } from "akanjs/common";
710
711
 
711
712
  // pkgs/@akanjs/devkit/mobile/usageDescriptions.ts
712
713
  import { capitalize } from "akanjs/common";
@@ -740,6 +741,40 @@ class NativeConfig {
740
741
  "secure-storage",
741
742
  "haptics"
742
743
  ];
744
+ static defaultCsp = {
745
+ "default-src": ["'self'"],
746
+ "script-src": ["'self'", "'wasm-unsafe-eval'"],
747
+ "style-src": ["'self'", "'unsafe-inline'", "https:"],
748
+ "img-src": ["'self'", "blob:", "data:", "https:"],
749
+ "media-src": ["'self'", "blob:", "data:", "https:"],
750
+ "font-src": ["'self'", "data:", "https:"],
751
+ "connect-src": ["'self'", "blob:", "data:", "https:", "wss:"],
752
+ "worker-src": ["'self'", "blob:"],
753
+ "frame-src": ["'self'", "https:"],
754
+ "object-src": ["'none'"],
755
+ "base-uri": ["'self'"],
756
+ "form-action": ["'self'"]
757
+ };
758
+ static #fetchDirectives = [
759
+ "child-src",
760
+ "connect-src",
761
+ "fenced-frame-src",
762
+ "font-src",
763
+ "frame-src",
764
+ "img-src",
765
+ "manifest-src",
766
+ "media-src",
767
+ "object-src",
768
+ "prefetch-src",
769
+ "script-src",
770
+ "script-src-elem",
771
+ "script-src-attr",
772
+ "style-src",
773
+ "style-src-elem",
774
+ "style-src-attr",
775
+ "worker-src"
776
+ ];
777
+ static defaultOpenUrls = ["https://*:*", "mailto:*", "tel:*"];
743
778
  static builtinContributions = {
744
779
  camera: {
745
780
  permission: "camera",
@@ -774,11 +809,13 @@ class NativeConfig {
774
809
  webDir,
775
810
  contributions,
776
811
  locales,
812
+ i18n,
777
813
  env,
778
814
  platform,
779
815
  desktopServer,
780
816
  nativePlugins = [],
781
- desktopBin
817
+ desktopBin,
818
+ publicEnv = {}
782
819
  }) {
783
820
  const warnings = [];
784
821
  const applied = (target.permissions ?? []).flatMap((permission) => {
@@ -844,6 +881,8 @@ class NativeConfig {
844
881
  backgroundColorDark: typeof background === "string" ? undefined : background?.dark,
845
882
  devtools: target.devtools ? true : undefined
846
883
  });
884
+ const csp = NativeConfig.#csp(target, NativeConfig.#plainOrigins(publicEnv, env, !!desktopServer));
885
+ const openUrls = target.openUrls ?? NativeConfig.defaultOpenUrls;
847
886
  const config = {
848
887
  app: {
849
888
  id: resolveAppId(target.appId, platform),
@@ -858,11 +897,12 @@ class NativeConfig {
858
897
  {
859
898
  identifier: "app",
860
899
  description: `The plugins ${target.appName} ships, each with its default permissions`,
861
- permissions: pluginIds.map((id) => `${id}:default`)
900
+ permissions: pluginIds.map((id) => id === "opener" && !openUrls.includes("*") ? { identifier: "opener:default", allow: openUrls.map((url) => ({ url })) } : `${id}:default`)
862
901
  }
863
902
  ],
903
+ ...csp ? { security: { csp } } : {},
864
904
  ...Object.keys(usageDescriptions).length ? { usageDescriptions } : {},
865
- ...target.deepLinks?.schemes?.length || target.deepLinks?.domains?.length ? { deepLinks: NativeConfig.#deepLinks(target, locales) } : {},
905
+ ...target.deepLinks?.schemes?.length || target.deepLinks?.domains?.length ? { deepLinks: NativeConfig.#deepLinks(target, locales, i18n) } : {},
866
906
  ...native ? { native } : {},
867
907
  ...updates ? { updates } : {},
868
908
  ...pushAndroid ? {
@@ -884,6 +924,56 @@ class NativeConfig {
884
924
  };
885
925
  return { config, warnings };
886
926
  }
927
+ static #csp({ name, csp: setting }, plainOrigins) {
928
+ if (setting === false)
929
+ return;
930
+ if (typeof setting === "string") {
931
+ if (!setting.trim())
932
+ throw new Error(`Native target '${name}': csp "" is no policy; write \`csp: false\` to ship the page without one.`);
933
+ return setting;
934
+ }
935
+ const policy = Object.fromEntries(Object.entries(NativeConfig.defaultCsp).map(([directive, sources]) => [directive, [...sources]]));
936
+ const add = (directive, sources) => {
937
+ const list = policy[directive] ?? [];
938
+ policy[directive] = [...new Set([...list.filter((source) => source !== "'none'"), ...sources])];
939
+ };
940
+ add("connect-src", [...plainOrigins, ...plainOrigins.map((origin) => origin.replace(/^http/, "ws"))]);
941
+ add("img-src", plainOrigins);
942
+ add("media-src", plainOrigins);
943
+ const asked = new Map;
944
+ for (const [key, sources] of Object.entries(setting ?? {})) {
945
+ const directive = key.toLowerCase();
946
+ const list = typeof sources === "string" ? sources.split(/\s+/).filter(Boolean) : sources;
947
+ asked.set(directive, [...asked.get(directive) ?? [], ...list]);
948
+ }
949
+ const everywhere = asked.get("default-src") ?? [];
950
+ asked.delete("default-src");
951
+ if (everywhere.length) {
952
+ for (const directive of Object.keys(policy))
953
+ if (directive === "default-src" || directive !== "object-src" && NativeConfig.#fetchDirectives.includes(directive))
954
+ add(directive, everywhere);
955
+ }
956
+ const variant = /^(script|style)-src-(elem|attr)$/;
957
+ for (const [directive, sources] of [...asked].sort(([a], [b]) => Number(variant.test(a)) - Number(variant.test(b)))) {
958
+ const from = variant.test(directive) ? directive.replace(/-(elem|attr)$/, "") : NativeConfig.#fetchDirectives.includes(directive) ? "default-src" : null;
959
+ policy[directive] ??= [...from ? policy[from] ?? [] : []];
960
+ add(directive, sources);
961
+ }
962
+ return policy;
963
+ }
964
+ static #plainOrigins(publicEnv, env, carried) {
965
+ const origins = new Set;
966
+ const pinned = publicEnv.AKAN_PUBLIC_SERVER_URL;
967
+ if (pinned && URL.canParse(pinned) && new URL(pinned).protocol === "http:")
968
+ origins.add(new URL(pinned).origin);
969
+ const environment = publicEnv.AKAN_PUBLIC_ENV ?? env ?? "debug";
970
+ const mode = publicEnv.AKAN_PUBLIC_OPERATION_MODE ?? (environment === "local" ? "local" : "cloud");
971
+ if (mode === "local")
972
+ origins.add("http://localhost:*");
973
+ if (carried)
974
+ origins.add("http://127.0.0.1:*");
975
+ return [...origins];
976
+ }
887
977
  static #icon(icon, abs) {
888
978
  return typeof icon === "string" ? abs(icon) : { ...icon, image: abs(icon.image) };
889
979
  }
@@ -930,9 +1020,11 @@ class NativeConfig {
930
1020
  static #merged(contributed, own) {
931
1021
  return Object.assign({}, ...contributed, own);
932
1022
  }
933
- static #deepLinks(target, locales) {
1023
+ static #deepLinks(target, locales, i18n = { defaultLocale: "" }) {
934
1024
  const basePath = target.basePath ? trimSlashes(target.basePath) : "";
935
- const pathPrefixes = basePath ? locales.map((locale) => `/${locale}/${basePath}`) : undefined;
1025
+ const pathPrefixes = basePath ? [
1026
+ ...new Set(locales.flatMap((locale) => [LocalePath.join(locale, `/${basePath}`, i18n), `/${locale}/${basePath}`]))
1027
+ ] : undefined;
936
1028
  return {
937
1029
  ...target.deepLinks?.schemes?.length ? { schemes: target.deepLinks.schemes } : {},
938
1030
  ...target.deepLinks?.domains?.length ? { domains: target.deepLinks.domains.map((host) => pathPrefixes ? { host, pathPrefixes } : host) } : {}
@@ -993,7 +1085,8 @@ class NativePublicEnv {
993
1085
  "AKAN_PUBLIC_WS_PREFIX",
994
1086
  "AKAN_PUBLIC_RENDER_ENV",
995
1087
  "AKAN_PUBLIC_DEFAULT_LOCALE",
996
- "AKAN_PUBLIC_LOCALES"
1088
+ "AKAN_PUBLIC_LOCALES",
1089
+ "AKAN_PUBLIC_LOCALE_PREFIX"
997
1090
  ];
998
1091
  static #keyPattern = /^AKAN_PUBLIC_[A-Z0-9_]{1,128}$/;
999
1092
  static #secretWords = ["SECRET", "TOKEN", "PASSWORD", "PRIVATE", "CREDENTIAL"];
@@ -1016,6 +1109,8 @@ class NativePublicEnv {
1016
1109
  return [`${key} names a ${word.toLowerCase()}, which a page bundle must not carry`];
1017
1110
  if (typeof value !== "string")
1018
1111
  return [`${key} is not a string`];
1112
+ if (/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/.test(value))
1113
+ return [`${key} holds a private key`];
1019
1114
  if (/[\u0000-\u001f\u007f]/.test(value))
1020
1115
  return [`${key} holds a control character`];
1021
1116
  return [];
@@ -1036,6 +1131,11 @@ class NativePublicEnv {
1036
1131
  return null;
1037
1132
  return NativePublicEnv.of(await file.json());
1038
1133
  }
1134
+ static async inlined(app) {
1135
+ const file = Bun.file(CsrArtifactBuilder.publicEnvPath(app));
1136
+ const env = await file.exists() ? await file.json() : process.env;
1137
+ return Object.fromEntries(Object.entries(env).flatMap(([key, value]) => key.startsWith("AKAN_PUBLIC_") && typeof value === "string" ? [[key, value]] : []));
1138
+ }
1039
1139
  static async recordedIn(bundleFile) {
1040
1140
  const file = Bun.file(bundleFile);
1041
1141
  if (!await file.exists())
@@ -1288,10 +1388,11 @@ class NativeApp {
1288
1388
  stageBin = true,
1289
1389
  arch
1290
1390
  }) {
1291
- const [appConfig, plugins, nativePlugins] = await Promise.all([
1391
+ const [appConfig, plugins, nativePlugins, publicEnv] = await Promise.all([
1292
1392
  this.app.getConfig(),
1293
1393
  this.app.collectPlugins(),
1294
- NativePluginFolders.of(this.app)
1394
+ NativePluginFolders.of(this.app),
1395
+ NativePublicEnv.inlined(this.app)
1295
1396
  ]);
1296
1397
  const desktop = platform === "macos" || platform === "windows" || platform === "linux";
1297
1398
  const carried = desktop && stageBin ? await new DesktopBin(this.app, appConfig).stage(this.binDir, arch) : [];
@@ -1301,9 +1402,11 @@ class NativeApp {
1301
1402
  webDir: this.web.dir,
1302
1403
  contributions: plugins.flatMap((plugin) => plugin.native ? [plugin.native] : []),
1303
1404
  locales: appConfig.i18n.locales,
1405
+ i18n: appConfig.i18n,
1304
1406
  env: this.env,
1305
1407
  platform,
1306
1408
  nativePlugins,
1409
+ publicEnv,
1307
1410
  ...server ? { desktopServer: server } : {},
1308
1411
  ...carried.length ? { desktopBin: this.binDir } : {}
1309
1412
  });
@@ -1,17 +1,18 @@
1
1
  // @bun
2
2
  import {
3
3
  resolveSsrPageEntriesForApp
4
- } from "./index-wcej7g4z.js";
4
+ } from "./index-g500c5j9.js";
5
5
  import {
6
+ createBarrelImportsPlugin,
6
7
  bundleDefine,
7
8
  CsrEntryFiles,
8
9
  PagesEntrySourceGenerator,
9
10
  PagesBundleBuilder
10
- } from "./index-0fz95kxe.js";
11
+ } from "./index-zbrwnmf1.js";
11
12
 
12
13
  // pkgs/@akanjs/devkit/frontendBuild/csrArtifactBuilder.ts
13
14
  import { mkdir as mkdir2, rm as rm2, unlink as unlink2 } from "fs/promises";
14
- import path5 from "path";
15
+ import path4 from "path";
15
16
 
16
17
  // pkgs/@akanjs/devkit/transforms/browserDirnamePlugin.ts
17
18
  import path from "path";
@@ -113,12 +114,11 @@ class SideEffectImportOrder {
113
114
 
114
115
  // pkgs/@akanjs/devkit/frontendBuild/mcpAppViewBuilder.ts
115
116
  import { mkdir, readdir, rename, rm, unlink } from "fs/promises";
116
- import path4 from "path";
117
+ import path3 from "path";
117
118
  import { parseRouteModuleKey } from "akanjs/common";
118
119
 
119
120
  // pkgs/@akanjs/devkit/transforms/mcpAppPageTrimmer.ts
120
121
  import { realpathSync } from "fs";
121
- import path3 from "path";
122
122
  import ts3 from "typescript";
123
123
 
124
124
  // pkgs/@akanjs/devkit/transforms/pureLazyMarker.ts
@@ -143,7 +143,7 @@ class PureLazyMarker {
143
143
  static mark(source, filePath) {
144
144
  if (!source.includes("lazy("))
145
145
  return source;
146
- const kind = filePath.endsWith(".tsx") ? ts2.ScriptKind.TSX : ts2.ScriptKind.TS;
146
+ const kind = /\.[jt]sx$/.test(filePath) ? ts2.ScriptKind.TSX : ts2.ScriptKind.TS;
147
147
  const sourceFile = ts2.createSourceFile(filePath, source, ts2.ScriptTarget.Latest, true, kind);
148
148
  const starts = [];
149
149
  const visit = (node) => {
@@ -160,20 +160,9 @@ class PureLazyMarker {
160
160
  // pkgs/@akanjs/devkit/transforms/mcpAppPageTrimmer.ts
161
161
  class McpAppPageTrimmer {
162
162
  static #unused = new Set(["render", "head", "loading", "guard"]);
163
- static plugin(pagePaths) {
164
- return {
165
- name: "akan-mcp-app-page",
166
- setup(build) {
167
- if (!pagePaths.length)
168
- return;
169
- const loadedPaths = new Set(pagePaths.flatMap((pagePath) => [pagePath, McpAppPageTrimmer.#realPathOf(pagePath)]));
170
- const filter = new RegExp(`^(?:${[...loadedPaths].map((pagePath) => RegExp.escape(pagePath)).join("|")})$`);
171
- build.onLoad({ filter }, async (args) => ({
172
- contents: PureLazyMarker.mark(McpAppPageTrimmer.trim(await Bun.file(args.path).text(), args.path), args.path),
173
- loader: path3.extname(args.path).slice(1)
174
- }));
175
- }
176
- };
163
+ static pipe(pagePaths) {
164
+ const loadedPaths = new Set(pagePaths.flatMap((pagePath) => [pagePath, McpAppPageTrimmer.#realPathOf(pagePath)]));
165
+ return (source, { path: filePath }) => PureLazyMarker.mark(loadedPaths.has(filePath) ? McpAppPageTrimmer.trim(source, filePath) : source, filePath);
177
166
  }
178
167
  static trim(source, filePath) {
179
168
  const sourceFile = ts3.createSourceFile(filePath, source, ts3.ScriptTarget.Latest, true, ts3.ScriptKind.TSX);
@@ -223,7 +212,7 @@ class McpAppViewBuilder {
223
212
  this.#command = command;
224
213
  }
225
214
  get outputDir() {
226
- return this.#command === "build" ? path4.join(this.#app.dist.cwdPath, McpAppViewBuilder.dirName) : path4.join(this.#app.cwdPath, ".akan", "artifact", McpAppViewBuilder.dirName);
215
+ return this.#command === "build" ? path3.join(this.#app.dist.cwdPath, McpAppViewBuilder.dirName) : path3.join(this.#app.cwdPath, ".akan", "artifact", McpAppViewBuilder.dirName);
227
216
  }
228
217
  async build(pageEntries, { basePaths, cssAssets, options }) {
229
218
  const views = await McpAppViewBuilder.discover(pageEntries, basePaths);
@@ -233,18 +222,22 @@ class McpAppViewBuilder {
233
222
  }
234
223
  const stagingDir = `${this.outputDir}.next`;
235
224
  await rm(stagingDir, { recursive: true, force: true });
236
- const generatedDir = path4.join(this.#app.cwdPath, ".akan", "generated", McpAppViewBuilder.dirName);
225
+ const generatedDir = path3.join(this.#app.cwdPath, ".akan", "generated", McpAppViewBuilder.dirName);
237
226
  await rm(generatedDir, { recursive: true, force: true });
238
227
  await mkdir(generatedDir, { recursive: true });
239
228
  const files = Object.fromEntries(views.flatMap((view) => [
240
- [path4.join(generatedDir, `${view.name}.html`), McpAppViewBuilder.htmlOf(view)],
241
- [path4.join(generatedDir, `${view.name}.view.tsx`), McpAppViewBuilder.entryOf(view, generatedDir)]
229
+ [path3.join(generatedDir, `${view.name}.html`), McpAppViewBuilder.htmlOf(view)],
230
+ [path3.join(generatedDir, `${view.name}.view.tsx`), McpAppViewBuilder.entryOf(view, generatedDir)]
242
231
  ]));
243
232
  const pagePaths = [...new Set(views.map((view) => view.page.moduleAbsPath))];
244
233
  const result = await Bun.build({
245
234
  ...options,
246
- plugins: [...options.plugins, McpAppPageTrimmer.plugin(pagePaths), PureLazyMarker.plugin()],
247
- entrypoints: views.map((view) => path4.join(generatedDir, `${view.name}.html`)),
235
+ plugins: [
236
+ ...options.plugins,
237
+ await CsrArtifactBuilder.barrelImportsPlugin(this.#app, McpAppPageTrimmer.pipe(pagePaths)),
238
+ PureLazyMarker.plugin()
239
+ ],
240
+ entrypoints: views.map((view) => path3.join(generatedDir, `${view.name}.html`)),
248
241
  files,
249
242
  root: generatedDir,
250
243
  outdir: stagingDir
@@ -264,17 +257,17 @@ ${logs}` : ""}`);
264
257
  const names = new Set(views.map((view) => `${view.name}.html`));
265
258
  await mkdir(this.outputDir, { recursive: true });
266
259
  for (const name of names)
267
- await rename(path4.join(stagingDir, name), path4.join(this.outputDir, name));
260
+ await rename(path3.join(stagingDir, name), path3.join(this.outputDir, name));
268
261
  for (const name of await readdir(this.outputDir))
269
262
  if (!names.has(name))
270
- await rm(path4.join(this.outputDir, name), { recursive: true, force: true });
263
+ await rm(path3.join(this.outputDir, name), { recursive: true, force: true });
271
264
  const strays = await readdir(stagingDir);
272
265
  if (strays.length)
273
266
  this.#app.logger.warn(`[mcp-app-build] ${strays.join(", ")} reached no view; a view loads nothing beside its own file`);
274
267
  await rm(stagingDir, { recursive: true, force: true });
275
268
  }
276
269
  static async discover(pageEntries, basePaths) {
277
- const { RouteSourceValidator } = await import("./routeSourceValidator-6jd0q6r6.js");
270
+ const { RouteSourceValidator } = await import("./routeSourceValidator-4h947v7c.js");
278
271
  const roots = pageEntries.filter((entry) => parseRouteModuleKey(entry.key).isInternalRootLayout);
279
272
  const overrides = pageEntries.filter((entry) => parseRouteModuleKey(entry.key).kind === "overrides");
280
273
  const layoutNodes = new Set(pageEntries.flatMap((entry) => {
@@ -326,7 +319,7 @@ ${logs}` : ""}`);
326
319
  }
327
320
  static entryOf(view, fromDir) {
328
321
  const specifier = (absPath) => {
329
- const relative = path4.relative(fromDir, absPath).split(path4.sep).join("/");
322
+ const relative = path3.relative(fromDir, absPath).split(path3.sep).join("/");
330
323
  return JSON.stringify(relative.startsWith(".") ? relative : `./${relative}`);
331
324
  };
332
325
  const importsOf = (entries, name) => entries.map((entry, idx) => `import ${name}${idx} from ${specifier(entry.moduleAbsPath)};
@@ -365,11 +358,11 @@ ${importsOf(view.rootOverrides, "rootOverride")}${importsOf(view.overrides, "ove
365
358
  return null;
366
359
  }
367
360
  async#inline(view, dir, cssAsset) {
368
- const htmlPath = path4.join(dir, `${view.name}.html`);
361
+ const htmlPath = path3.join(dir, `${view.name}.html`);
369
362
  let html = await Bun.file(htmlPath).text();
370
363
  if (cssAsset) {
371
- const artifactDir = path4.join(this.#command === "build" ? this.#app.dist.cwdPath : this.#app.cwdPath, ".akan", "artifact");
372
- const css = await Bun.file(path4.join(artifactDir, cssAsset.cssRelPath)).text();
364
+ const artifactDir = path3.join(this.#command === "build" ? this.#app.dist.cwdPath : this.#app.cwdPath, ".akan", "artifact");
365
+ const css = await Bun.file(path3.join(artifactDir, cssAsset.cssRelPath)).text();
373
366
  html = CsrArtifactBuilder.injectBeforeHeadEnd(html, CsrArtifactBuilder.createInlineStyle(css));
374
367
  } else
375
368
  this.#app.logger.warn(`[mcp-app-build] no compiled stylesheet for ${view.name}; its view ships without CSS`);
@@ -419,6 +412,7 @@ class CsrArtifactBuilder {
419
412
  const options = CsrArtifactBuilder.bundleOptions(this.#app, this.#command, akanConfig.optimizeImports);
420
413
  const result = await Bun.build({
421
414
  ...options,
415
+ plugins: [...options.plugins, await CsrArtifactBuilder.barrelImportsPlugin(this.#app)],
422
416
  entrypoints: htmlBasePaths.map((basePath) => this.#generatedPath(CsrArtifactBuilder.htmlFilename(basePath))),
423
417
  files: generatedFiles,
424
418
  root: this.#generatedDir,
@@ -465,8 +459,11 @@ ${logs}` : ""}`);
465
459
  plugins: [PagesBundleBuilder.createCssStubPlugin(), createBrowserDirnamePlugin(), SideEffectImportOrder.plugin()]
466
460
  };
467
461
  }
462
+ static async barrelImportsPlugin(app, pipeAfter) {
463
+ return await createBarrelImportsPlugin(app, { barrels: ["akanjs/ui"], pipeAfter });
464
+ }
468
465
  static publicEnvPath(app) {
469
- return path5.join(app.dist.cwdPath, ".akan", "artifact", "csr-public-env.json");
466
+ return path4.join(app.dist.cwdPath, ".akan", "artifact", "csr-public-env.json");
470
467
  }
471
468
  static async writePublicEnv(app, define) {
472
469
  const prefix = "process.env.";
@@ -484,20 +481,20 @@ ${logs}` : ""}`);
484
481
  return CsrEntryFiles.entryFilename(basePath);
485
482
  }
486
483
  static basePathOfHtml(htmlPath) {
487
- const name = path5.basename(htmlPath, ".html");
484
+ const name = path4.basename(htmlPath, ".html");
488
485
  return name === "index" ? "" : name;
489
486
  }
490
487
  get #outputDir() {
491
- return path5.join(this.#command === "build" ? this.#app.dist.cwdPath : this.#app.cwdPath, this.#command === "build" ? "csr" : ".akan/artifact/csr");
488
+ return path4.join(this.#command === "build" ? this.#app.dist.cwdPath : this.#app.cwdPath, this.#command === "build" ? "csr" : ".akan/artifact/csr");
492
489
  }
493
490
  get #generatedDir() {
494
- return path5.join(this.#app.cwdPath, ".akan/generated/csr");
491
+ return path4.join(this.#app.cwdPath, ".akan/generated/csr");
495
492
  }
496
493
  get #artifactDir() {
497
- return path5.join(this.#command === "build" ? this.#app.dist.cwdPath : this.#app.cwdPath, ".akan/artifact");
494
+ return path4.join(this.#command === "build" ? this.#app.dist.cwdPath : this.#app.cwdPath, ".akan/artifact");
498
495
  }
499
496
  #generatedPath(filename) {
500
- return path5.join(this.#generatedDir, filename);
497
+ return path4.join(this.#generatedDir, filename);
501
498
  }
502
499
  async#createEntryFile(basePath, pageEntries) {
503
500
  return [
@@ -530,7 +527,7 @@ void bootCsr(pages);
530
527
  async#loadCssAssets() {
531
528
  if (this.#cssAssets)
532
529
  return this.#cssAssets;
533
- const artifactFile = Bun.file(path5.join(this.#artifactDir, "base-artifact.json"));
530
+ const artifactFile = Bun.file(path4.join(this.#artifactDir, "base-artifact.json"));
534
531
  if (!await artifactFile.exists())
535
532
  return {};
536
533
  const artifact = await artifactFile.json();
@@ -545,7 +542,7 @@ void bootCsr(pages);
545
542
  const basePath = CsrArtifactBuilder.basePathOfHtml(htmlPath);
546
543
  const cssAsset = cssAssets[basePath];
547
544
  if (!cssAsset) {
548
- this.#app.logger.warn(`[csr-build] base-artifact.json has no compiled stylesheet for ${basePath || "root"}; ${path5.basename(htmlPath)} ships without CSS`);
545
+ this.#app.logger.warn(`[csr-build] base-artifact.json has no compiled stylesheet for ${basePath || "root"}; ${path4.basename(htmlPath)} ships without CSS`);
549
546
  }
550
547
  const inlined = await this.#inlineHtmlAssets(await htmlFile.text(), htmlPath, cssAsset);
551
548
  for (const filePath of inlined.jsFiles)
@@ -566,7 +563,7 @@ ${remainingAssets.join(`
566
563
  async#inlineHtmlAssets(html, htmlPath, cssAsset) {
567
564
  let next = html;
568
565
  if (cssAsset) {
569
- const css = await Bun.file(path5.join(this.#artifactDir, cssAsset.cssRelPath)).text();
566
+ const css = await Bun.file(path4.join(this.#artifactDir, cssAsset.cssRelPath)).text();
570
567
  next = CsrArtifactBuilder.injectBeforeHeadEnd(next, CsrArtifactBuilder.createInlineStyle(css));
571
568
  }
572
569
  const jsFiles = [];
@@ -636,7 +633,7 @@ ${CsrArtifactBuilder.escapeInlineScript(await loadScript(src))}
636
633
  throw new Error(`[csr-build] cannot inline external script: ${src}`);
637
634
  }
638
635
  const normalized = src.startsWith("/") ? src.slice(1) : src;
639
- return path5.resolve(path5.dirname(htmlPath), normalized);
636
+ return path4.resolve(path4.dirname(htmlPath), normalized);
640
637
  }
641
638
  }
642
639
 
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-3wypz6xj.js";
5
+ } from "./index-9zy8479y.js";
6
6
  import {
7
7
  ModuleExecutor
8
- } from "./index-wcej7g4z.js";
8
+ } from "./index-g500c5j9.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-xjf5j657.js";
16
+ } from "./index-hm0tn7qv.js";
17
17
  import {
18
18
  PageScript
19
- } from "./index-905qdgqp.js";
19
+ } from "./index-khk05tsf.js";
20
20
  import {
21
21
  pluralizeName
22
22
  } from "./index-nz8prx9g.js";