@akanjs/cli 3.0.0-beta.8 → 3.0.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 (224) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-2vmp9qe0.js +9 -0
  3. package/CodeAgentRpcHost-p7h6n2hp.js +7 -0
  4. package/CodeAgentRpcListener-7p7z5dd7.js +97 -0
  5. package/CodeTui-5ed6bg2a.js +1457 -0
  6. package/README.ko.md +83 -28
  7. package/README.md +70 -27
  8. package/TunnelShare-cwh9ezsm.js +9 -0
  9. package/{agent.command-0q17pnrs.js → agent.command-gn73rhe7.js} +8 -9
  10. package/akanCode.js +102 -0
  11. package/application.command-e968t0hw.js +246 -0
  12. package/{applicationBuildRunner-kxwbssgn.js → applicationBuildRunner-64taxseg.js} +121 -77
  13. package/buildBatch.proc.js +120 -32
  14. package/cloud.command-0jm301rr.js +95 -0
  15. package/cloud.script-nemnzjpv.js +20 -0
  16. package/code.command-18kcm7hq.js +154 -0
  17. package/commandManifest.json +1 -1
  18. package/consoleToStderr-h5bryj94.js +7 -0
  19. package/context.command-trd9bn18.js +48 -0
  20. package/context.runner-y5hwh673.js +21 -0
  21. package/{dependencyScanner-shs82ynp.js → dependencyScanner-06z2dmrr.js} +2 -2
  22. package/{devTui-m1atgkc9.js → devTui-q7k7bakd.js} +122 -40
  23. package/fileSys-wzzrntkw.js +9 -0
  24. package/guideline.command-bdmdn2de.js +42 -0
  25. package/guidelines/agentRule/agentRule.instruction.md +154 -26
  26. package/guidelines/conventions/conventions.instruction.md +134 -48
  27. package/guidelines/mcpRule/mcpRule.instruction.md +7 -5
  28. package/guidelines/queryRule/queryRule.instruction.md +21 -7
  29. package/guidelines/runtimeRule/runtimeRule.instruction.md +291 -6
  30. package/guidelines/ssrRule/ssrRule.instruction.md +4 -2
  31. package/guidelines/transportRule/transportRule.instruction.md +10 -8
  32. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +20 -0
  33. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +66 -3
  34. package/incrementalBuilder.proc.js +564 -109
  35. package/index-0wpybxtr.js +2729 -0
  36. package/{index-kcxmv48c.js → index-2ahj896a.js} +45 -79
  37. package/index-2wc41k5w.js +49 -0
  38. package/index-3hx1z96c.js +87 -0
  39. package/{index-2tv3fdx4.js → index-3w94e7n3.js} +1228 -1458
  40. package/{index-hwkygn9s.js → index-48k96p55.js} +325 -36
  41. package/index-4npz05nm.js +187 -0
  42. package/{index-q0y2jq9j.js → index-52w0fvh8.js} +21 -4
  43. package/index-6he6gvfg.js +4300 -0
  44. package/index-7md2g9vw.js +6 -0
  45. package/{index-04bk599g.js → index-93j60em0.js} +10 -17
  46. package/index-94s080qm.js +266 -0
  47. package/index-9dp031by.js +12 -0
  48. package/{index-ktb5njgy.js → index-9z771ptz.js} +49 -99
  49. package/{index-y6n8nmny.js → index-abxpehf8.js} +75 -203
  50. package/{index-3d9y066c.js → index-bjwxs904.js} +9 -8
  51. package/{index-9077wzd2.js → index-by9pxkr0.js} +43 -26
  52. package/index-c6eggbee.js +123 -0
  53. package/index-d2242ksy.js +99 -0
  54. package/index-drehwpdt.js +1119 -0
  55. package/{index-92zztqy1.js → index-dy0jx9ay.js} +2 -17
  56. package/{index-ffvk10zz.js → index-f3c78nd6.js} +107 -241
  57. package/index-gbggbqcp.js +1058 -0
  58. package/{index-by5gpp8x.js → index-hj6w4ka1.js} +2 -1
  59. package/index-hsmtysz4.js +53 -0
  60. package/{index-j9yhg404.js → index-jmrn54tt.js} +4 -7
  61. package/{index-a64esmtb.js → index-kcdj1z5v.js} +523 -1022
  62. package/{index-d43r08tf.js → index-kqabytj7.js} +77 -150
  63. package/{index-vyvre9en.js → index-mbxbhay5.js} +6 -2
  64. package/{index-vxtad5bd.js → index-mgxpx3f2.js} +5 -8
  65. package/index-p6pbz9n5.js +25 -0
  66. package/{index-sj5vxr8f.js → index-p993efkq.js} +981 -897
  67. package/{index-2xp0kfkt.js → index-pmhqttv3.js} +37 -25
  68. package/index-tqm7jjcn.js +700 -0
  69. package/{index-0g7r8xz3.js → index-vpj42xwt.js} +114 -232
  70. package/index-wa5jbxj1.js +760 -0
  71. package/{index-k2j1hc4r.js → index-wprnsjms.js} +12 -12
  72. package/{index-gyd220p2.js → index-y3mphr1m.js} +554 -577
  73. package/index-yg7jhz8x.js +69 -0
  74. package/{index-h7yw2z9n.js → index-zzvvc845.js} +8 -14
  75. package/index.js +23 -22
  76. package/{library.command-qzzbj6d8.js → library.command-9h749a1x.js} +4 -5
  77. package/{localRegistry.command-vyrgg4xw.js → localRegistry.command-2bqqhxyz.js} +23 -43
  78. package/{module.command-rq5hq3ax.js → module.command-nv8nzgft.js} +8 -12
  79. package/{package.command-d9hd6v9n.js → package.command-mq4bggp6.js} +6 -7
  80. package/package.json +15 -7
  81. package/{page.command-126d56te.js → page.command-j639n707.js} +4 -5
  82. package/{primitive.command-taxd1538.js → primitive.command-kz6849th.js} +9 -23
  83. package/prompter-76k56b37.js +8 -0
  84. package/{quality.command-6gsna0a3.js → quality.command-4hyabwkb.js} +205 -377
  85. package/{recipeScanner-fpagtgc1.js → recipeScanner-4b69ybe0.js} +1 -1
  86. package/{repair.command-tq2dgy72.js → repair.command-a9awpbqr.js} +11 -35
  87. package/{routeSourceValidator-apyqw7wk.js → routeSourceValidator-7ycnfz0e.js} +0 -6
  88. package/{scalar.command-3bcmrrkv.js → scalar.command-ma4fpm9m.js} +7 -11
  89. package/skills/akan-code/SKILL.md +130 -0
  90. package/skills/akan-debug/SKILL.md +42 -0
  91. package/skills/akan-deps/SKILL.md +50 -0
  92. package/skills/akan-err/SKILL.md +39 -0
  93. package/skills/akan-module/SKILL.md +45 -0
  94. package/skills/akan-scaffold/SKILL.md +76 -0
  95. package/skills/akan-scalar/SKILL.md +52 -0
  96. package/skills/akan-service/SKILL.md +34 -0
  97. package/skills/akan-store/SKILL.md +67 -0
  98. package/skills/akan-ui/SKILL.md +63 -0
  99. package/skills/akan-validate/SKILL.md +44 -0
  100. package/{subspace.command-eddzqpx3.js → subspace.command-3k2pmrs4.js} +53 -62
  101. package/templates/__scalar/__model__/__model__.abstract.md.template +8 -0
  102. package/templates/app/page/_index.tsx +257 -258
  103. package/templates/app/page/_layout.tsx +5 -1
  104. package/templates/app/page/_overrides.tsx +12 -0
  105. package/templates/app/page/styles.css.template +316 -14
  106. package/templates/app/public/apple-touch-icon.png +0 -0
  107. package/templates/app/public/favicon.ico +0 -0
  108. package/templates/app/public/jelly/cloud.webp +0 -0
  109. package/templates/app/public/jelly/comet.webp +0 -0
  110. package/templates/app/public/jelly/moon.webp +0 -0
  111. package/templates/app/public/jelly/planet.webp +0 -0
  112. package/templates/app/public/jelly/rocket.webp +0 -0
  113. package/templates/app/public/jelly/star.webp +0 -0
  114. package/templates/app/public/jelly/sugar.webp +0 -0
  115. package/templates/app/public/logo.png +0 -0
  116. package/templates/app/ui/Recipe/index.ts +9 -0
  117. package/templates/app/ui/Recipe/jellyButton.ts +63 -0
  118. package/templates/appSample/lib/__scalar/workHistory/workHistory.abstract.ts +8 -39
  119. package/templates/appSample/lib/_noti/noti.abstract.ts +6 -29
  120. package/templates/appSample/lib/task/Task.Unit.tsx +1 -1
  121. package/templates/appSample/lib/task/Task.Util.tsx +10 -13
  122. package/templates/appSample/lib/task/Task.View.tsx +2 -2
  123. package/templates/appSample/lib/task/Task.Zone.tsx +5 -2
  124. package/templates/appSample/lib/task/task.abstract.ts +12 -32
  125. package/templates/appSample/lib/task/task.signal.spec.ts +1 -15
  126. package/templates/appSample/lib/task/task.signal.test.ts +15 -1
  127. package/templates/appSample/lib/task/task.signal.ts +10 -8
  128. package/templates/appSample/page/task/[taskId]/_index.tsx +6 -6
  129. package/templates/appSample/page/task/[taskId]/edit.tsx +5 -4
  130. package/templates/appSample/page/task/_index.tsx +4 -3
  131. package/templates/appSample/page/task/_layout.tsx +1 -1
  132. package/templates/appSample/page/task/new.tsx +5 -4
  133. package/templates/appSample/srvkit/{AuthGuard.ts → guards.ts} +7 -4
  134. package/templates/appSample/srvkit/{SessionInternalArg.ts → internalArgs.ts} +6 -4
  135. package/templates/appSample/ui/GlobalLoading.tsx +2 -1
  136. package/templates/appSample/ui/QuantityControl.tsx +3 -3
  137. package/templates/client.ts +7 -30
  138. package/templates/crudPages/[__model__Id]/edit/page.tsx +2 -1
  139. package/templates/crudPages/[__model__Id]/page.tsx +2 -1
  140. package/templates/crudPages/new/page.tsx +2 -1
  141. package/templates/crudPages/page.tsx +2 -1
  142. package/templates/crudSinglePage/page.tsx +2 -1
  143. package/templates/lib/__lib/lib.dictionary.ts +0 -2
  144. package/templates/lib/__lib/lib.document.ts +0 -2
  145. package/templates/lib/sig.ts +8 -30
  146. package/templates/localDev/docker-compose.yaml.template +3 -14
  147. package/templates/module/__model__.signal.ts +12 -4
  148. package/templates/pkgRoot/tsconfig.json.template +2 -7
  149. package/templates/server.ts +1 -3
  150. package/templates/service/__model__.abstract.md.template +8 -0
  151. package/templates/workspaceRoot/.gitignore.template +0 -1
  152. package/templates/workspaceRoot/AGENTS.md.template +6 -0
  153. package/templates/workspaceRoot/package.json.template +1 -3
  154. package/tunnel.command-xwr46b66.js +129 -0
  155. package/{typeChecker-3xgrzc2v.js → typeChecker-px49mezc.js} +1 -1
  156. package/typecheck.proc.js +1 -1
  157. package/workflow.command-t7wqe4h7.js +79 -0
  158. package/{workspace.command-06wvstgr.js → workspace.command-4derhzrh.js} +79 -109
  159. package/abstractCompactor-gmkc0z8j.js +0 -102
  160. package/application.command-18y0s485.js +0 -204
  161. package/applicationReleasePackager-4yasxwv9.js +0 -244
  162. package/capacitorApp-36rbr858.js +0 -12
  163. package/cloud.command-av97ndh6.js +0 -94
  164. package/cloud.script-cm11xjdz.js +0 -20
  165. package/context.command-5v37ef3n.js +0 -81
  166. package/devTuiView-0hc2emhe.js +0 -9
  167. package/getDirname-dr3jz1xg.js +0 -7
  168. package/guideline.command-4pz9g1rt.js +0 -360
  169. package/guidelines/agentRule/agentRule.generate.json +0 -31
  170. package/guidelines/componentRule/componentRule.generate.json +0 -31
  171. package/guidelines/conventions/conventions.generate.json +0 -25
  172. package/guidelines/cssRule/cssRule.generate.json +0 -31
  173. package/guidelines/docPageRule/docPageRule.generate.json +0 -31
  174. package/guidelines/docPageRule/docPageRule.instruction.md +0 -25
  175. package/guidelines/docSyncRule/docSyncRule.generate.json +0 -31
  176. package/guidelines/docSyncRule/docSyncRule.instruction.md +0 -25
  177. package/guidelines/enumConstant/enumConstant.generate.json +0 -31
  178. package/guidelines/enumConstant/enumConstant.instruction.md +0 -28
  179. package/guidelines/fieldRule/fieldRule.generate.json +0 -31
  180. package/guidelines/framework/framework.generate.json +0 -32
  181. package/guidelines/mcpRule/mcpRule.generate.json +0 -35
  182. package/guidelines/modelConstant/modelConstant.generate.json +0 -32
  183. package/guidelines/modelDictionary/modelDictionary.generate.json +0 -32
  184. package/guidelines/modelDocument/modelDocument.generate.json +0 -31
  185. package/guidelines/modelService/modelService.generate.json +0 -31
  186. package/guidelines/modelSignal/modelSignal.generate.json +0 -31
  187. package/guidelines/modelStore/modelStore.generate.json +0 -31
  188. package/guidelines/modelTemplate/modelTemplate.generate.json +0 -31
  189. package/guidelines/modelUnit/modelUnit.generate.json +0 -31
  190. package/guidelines/modelUtil/modelUtil.generate.json +0 -31
  191. package/guidelines/modelView/modelView.generate.json +0 -31
  192. package/guidelines/modelZone/modelZone.generate.json +0 -31
  193. package/guidelines/moduleCodegen/moduleCodegen.generate.json +0 -31
  194. package/guidelines/moduleCodegen/moduleCodegen.instruction.md +0 -28
  195. package/guidelines/moduleOverview/moduleOverview.generate.json +0 -31
  196. package/guidelines/queryRule/queryRule.generate.json +0 -31
  197. package/guidelines/recipeRule/recipeRule.generate.json +0 -31
  198. package/guidelines/runtimeRule/runtimeRule.generate.json +0 -25
  199. package/guidelines/scalarConstant/scalarConstant.generate.json +0 -32
  200. package/guidelines/scalarDictionary/scalarDictionary.generate.json +0 -32
  201. package/guidelines/scalarModule/scalarModule.generate.json +0 -31
  202. package/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -31
  203. package/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -25
  204. package/guidelines/ssrRule/ssrRule.generate.json +0 -31
  205. package/guidelines/transportRule/transportRule.generate.json +0 -31
  206. package/guidelines/utilUiUsage/utilUiUsage.generate.json +0 -31
  207. package/guidelines/utilUiUsage/utilUiUsage.instruction.md +0 -25
  208. package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +0 -24
  209. package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +0 -33
  210. package/index-47pj3aee.js +0 -76
  211. package/index-5ystnsd5.js +0 -841
  212. package/index-6wwzs1bc.js +0 -7
  213. package/index-a17x49vg.js +0 -229
  214. package/index-m0xccmmm.js +0 -228
  215. package/index-meh558jy.js +0 -65
  216. package/index-rtxxan88.js +0 -471
  217. package/index-te54x9zm.js +0 -338
  218. package/index-w8kmx1b6.js +0 -2176
  219. package/index-wt7qrtd4.js +0 -1516
  220. package/templates/__scalar/__model__/__model__.abstract.md +0 -28
  221. package/templates/module/__model__.abstract.md +0 -28
  222. package/templates/service/__model__.abstract.md +0 -28
  223. package/templates/workspaceRoot/patches/react-dom@19.2.7.patch.template +0 -62
  224. package/workflow.command-gtdnzvbz.js +0 -108
@@ -0,0 +1,246 @@
1
+ // @bun
2
+ import {
3
+ App,
4
+ Apps,
5
+ Sys,
6
+ Exec,
7
+ Workspace,
8
+ command
9
+ } from "./index-vpj42xwt.js";
10
+ import"./index-52w0fvh8.js";
11
+ import"./index-3w94e7n3.js";
12
+ import {
13
+ getMobileTargetChoices
14
+ } from "./index-gbggbqcp.js";
15
+ import"./index-48k96p55.js";
16
+ import"./index-mgxpx3f2.js";
17
+ import {
18
+ ApplicationScript
19
+ } from "./index-p993efkq.js";
20
+ import"./index-7md2g9vw.js";
21
+ import"./index-jmrn54tt.js";
22
+
23
+ // pkgs/@akanjs/cli/application/application.command.ts
24
+ var mobileTargetOption = {
25
+ desc: "native target name (a key of native.targets) or all",
26
+ ask: "Select native target",
27
+ enum: async ({ app }) => await getMobileTargetChoices(app)
28
+ };
29
+ var deviceOption = {
30
+ desc: "simulator, emulator or device to run on: its id or name (e.g. 'iPhone 17' or 'Pixel_10')",
31
+ default: ""
32
+ };
33
+ var teamOption = { flag: "T", desc: "Apple team id the signing is narrowed to", default: "" };
34
+ var devEnvs = ["local", "debug", "develop", "main"];
35
+ var buildEnvOption = { enum: devEnvs, desc: "backend environment", default: "debug" };
36
+ var startEnvOption = {
37
+ enum: devEnvs,
38
+ desc: "backend environment of a --release build; a dev build follows `akan start`, which keeps its own",
39
+ default: "local"
40
+ };
41
+ var releaseEnvOption = {
42
+ enum: ["debug", "develop", "main", "local"],
43
+ desc: "backend environment",
44
+ default: "main"
45
+ };
46
+
47
+ class ApplicationCommand extends command("application", [ApplicationScript], ({ public: target }) => ({
48
+ createApplication: target({ desc: "Create a new application in the workspace" }).arg("appName", String, { desc: "name of application" }).option("start", Boolean, { desc: "start application", default: false }).with(Workspace).exec(async function(appName, start, workspace) {
49
+ await this.applicationScript.createApplication(appName.toLowerCase().replace(/ /g, "-"), workspace, { start });
50
+ }),
51
+ removeApplication: target({ desc: "Remove an application from the workspace" }).with(App).exec(async function(app) {
52
+ await this.applicationScript.removeApplication(app);
53
+ }),
54
+ planSlice: target({ desc: "List the exact files an app needs to live in a workspace of its own" }).with(App).option("format", String, { desc: "output format", default: "text", enum: ["text", "json"] }).exec(async function(app, format) {
55
+ await this.applicationScript.planSlice(app, format);
56
+ }),
57
+ sync: target({ desc: "Sync dependencies and configuration for an app or library" }).with(Sys).exec(async function(sys) {
58
+ await this.applicationScript.sync(sys);
59
+ }),
60
+ script: target({ desc: "Run a custom script in the application" }).with(App).arg("filename", String, { desc: "name of script", nullable: true }).exec(async function(app, filename) {
61
+ await this.applicationScript.script(app, filename);
62
+ }),
63
+ console: target({ desc: "Open an interactive server console for the application" }).with(App).exec(async function(app) {
64
+ await this.applicationScript.console(app);
65
+ }),
66
+ logs: target({ desc: "Tail the running application's logs, filtered (attaches to akan-control.sock)" }).with(App).option("level", String, { desc: "minimum level: trace, verbose, debug, info, warn, error", nullable: true }).option("grep", String, { desc: "substring the message must contain", nullable: true }).option("endpoint", String, {
67
+ desc: "endpoint glob(s), comma-separated: mutation:*, query:userList",
68
+ nullable: true
69
+ }).option("trace", String, { desc: "one request's traceId", nullable: true }).option("child", String, { desc: "replica index(es), comma-separated", nullable: true }).option("role", String, {
70
+ flag: "R",
71
+ desc: "process role(s): gateway, federation, batch, all, rsc-worker",
72
+ nullable: true
73
+ }).option("origin", String, { desc: "call origin(s): http, websocket, mcp, internal, page", nullable: true }).option("since", String, {
74
+ desc: "only records newer than this: a duration ago in ms, s, m, h or d (30s, 5m, 2h), or an epoch-ms timestamp",
75
+ nullable: true
76
+ }).option("replay", Number, { flag: "n", desc: "records to replay from the buffer before following", default: 0 }).option("json", Boolean, { desc: "print NDJSON records instead of rendered lines", default: false }).option("follow", Boolean, { desc: "keep streaming; pass --follow false for history only", default: true }).option("runtimeDir", String, {
77
+ flag: "d",
78
+ desc: "runtime dir holding akan-control.sock (default: local/apps/<app>/runtime)",
79
+ nullable: true
80
+ }).exec(async function(app, level, grep, endpoint, trace, child, role, origin, since, replay, json, follow, runtimeDir) {
81
+ await this.applicationScript.logs(app, {
82
+ level,
83
+ grep,
84
+ endpoint,
85
+ trace,
86
+ child,
87
+ role,
88
+ origin,
89
+ since,
90
+ replay,
91
+ json,
92
+ follow,
93
+ runtimeDir
94
+ });
95
+ }),
96
+ build: target({ short: true, desc: "Build the application for production (frontend + backend)" }).with(App).option("write", Boolean, { desc: "write code generation", default: true }).option("fast", Boolean, { desc: "fast build", default: false }).option("quiet", Boolean, { desc: "hide build progress output", default: false }).exec(async function(app, write, fast, quiet) {
97
+ await this.applicationScript.build(app, { write, fast, quiet });
98
+ }),
99
+ typecheck: target({ short: true, desc: "Typecheck the application" }).with(App).option("write", Boolean, { desc: "write code generation", default: true }).option("clean", Boolean, { desc: "clear typecheck cache before running", default: false }).option("incremental", Boolean, { desc: "reuse TypeScript incremental cache", default: true }).exec(async function(app, write, clean, incremental) {
100
+ await this.applicationScript.typecheck(app, { write, clean, incremental });
101
+ }),
102
+ test: target({ desc: "Prepare and test an app, library, or package" }).with(Exec).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(exec, write) {
103
+ await this.applicationScript.test(exec, { write });
104
+ }),
105
+ buildIos: target({ short: true, desc: "Build the iOS app on the native runtime" }).with(App).option("target", String, mobileTargetOption).option("env", String, buildEnvOption).option("debug", Boolean, { desc: "debug build instead of release", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(app, target, env, debug, write) {
106
+ await this.applicationScript.buildIos(app, { target, env, profile: debug ? "debug" : "release", write });
107
+ }),
108
+ buildAndroid: target({ short: true, desc: "Build the Android app (apk) on the native runtime" }).with(App).option("target", String, mobileTargetOption).option("env", String, buildEnvOption).option("debug", Boolean, { desc: "debug build instead of release", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(app, target, env, debug, write) {
109
+ await this.applicationScript.buildAndroid(app, { target, env, profile: debug ? "debug" : "release", write });
110
+ }),
111
+ buildDesktop: target({ short: true, desc: "Build the desktop app for this computer (macOS, Windows or Linux)" }).with(App).option("target", String, mobileTargetOption).option("env", String, buildEnvOption).option("debug", Boolean, { desc: "debug build instead of release", default: false }).option("installer", Boolean, {
112
+ desc: "also what a person downloads: a Windows setup program (NSIS, /S for silent), a macOS dmg, a Linux AppImage",
113
+ default: false
114
+ }).option("arch", String, {
115
+ desc: "the CPU the app runs on, arm64 or x64 of this OS (default this computer's); a macOS app is arm64 only",
116
+ enum: ["arm64", "x64"],
117
+ nullable: true
118
+ }).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(app, target, env, debug, installer, arch, write) {
119
+ await this.applicationScript.buildDesktop(app, {
120
+ target,
121
+ env,
122
+ profile: debug ? "debug" : "release",
123
+ installer,
124
+ write,
125
+ ...arch ? { arch } : {}
126
+ });
127
+ }),
128
+ start: target({ short: true, desc: "Start development server(s) (frontend SSR + backend)" }).with(Apps).option("plain", Boolean, { desc: "print prefixed lines instead of the full-screen view", default: false }).option("kill", Boolean, { flag: "k", desc: "free the dev ports first, whoever is holding them", default: false }).option("concurrency", Number, {
129
+ desc: "apps to boot at a time (default: what this machine's memory and cores allow)",
130
+ nullable: true
131
+ }).option("dbup", Boolean, { desc: "start the local database first", default: true }).option("open", Boolean, { desc: "open web browser?", default: false }).option("share", Boolean, { desc: "also share each app on a public URL through an akan tunnel", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(apps, plain, kill, concurrency, dbup, open, share, write) {
132
+ await this.applicationScript.start(apps, { plain, kill, concurrency, dbup, open, share, write });
133
+ }),
134
+ startIos: target({ short: true, desc: "Run the iOS app in a simulator or on an iPhone, following `akan start`" }).with(App).option("target", String, mobileTargetOption).option("env", String, startEnvOption).option("release", Boolean, { desc: "run a release build of its own bundle instead", default: false }).option("device", String, deviceOption).option("team", String, teamOption).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(app, target, env, release, device, team, write) {
135
+ await this.applicationScript.startIos(app, {
136
+ target,
137
+ env,
138
+ operation: release ? "release" : "local",
139
+ device: device || undefined,
140
+ teamId: team || undefined,
141
+ write
142
+ });
143
+ }),
144
+ startAndroid: target({
145
+ short: true,
146
+ desc: "Run the Android app in an emulator or on a device, following `akan start`"
147
+ }).with(App).option("target", String, mobileTargetOption).option("env", String, startEnvOption).option("release", Boolean, { desc: "run a release build of its own bundle instead", default: false }).option("device", String, deviceOption).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(app, target, env, release, device, write) {
148
+ await this.applicationScript.startAndroid(app, {
149
+ target,
150
+ env,
151
+ operation: release ? "release" : "local",
152
+ device: device || undefined,
153
+ write
154
+ });
155
+ }),
156
+ startDesktop: target({
157
+ short: true,
158
+ desc: "Run the desktop app on this computer (macOS, Windows or Linux), following `akan start`"
159
+ }).with(App).option("target", String, mobileTargetOption).option("env", String, startEnvOption).option("release", Boolean, { desc: "run a release build of its own bundle instead", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(app, target, env, release, write) {
160
+ await this.applicationScript.startDesktop(app, {
161
+ target,
162
+ env,
163
+ operation: release ? "release" : "local",
164
+ write
165
+ });
166
+ }),
167
+ releaseIos: target({ desc: "Build and sign the iOS app for the App Store (.ipa)" }).with(App).option("target", String, mobileTargetOption).option("env", String, releaseEnvOption).option("team", String, teamOption).option("adHoc", Boolean, { desc: "sign with an ad-hoc profile instead of app-store", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).option("allowLocalRelease", Boolean, { flag: "l", desc: "allow release with --env local", default: false }).exec(async function(app, target, env, team, adHoc, write, allowLocalRelease) {
168
+ await this.applicationScript.releaseIos(app, {
169
+ target,
170
+ env,
171
+ teamId: team || undefined,
172
+ adHoc,
173
+ write,
174
+ allowLocalRelease
175
+ });
176
+ }),
177
+ releaseAndroid: target({ desc: "Build and sign the Android app for the Play Store (aab, or apk)" }).with(App).option("assembleType", String, { enum: ["aab", "apk"], default: "aab" }).option("target", String, mobileTargetOption).option("env", String, releaseEnvOption).option("write", Boolean, { desc: "write code generation", default: true }).option("allowLocalRelease", Boolean, { flag: "l", desc: "allow release with --env local", default: false }).exec(async function(app, assembleType, target, env, write, allowLocalRelease) {
178
+ await this.applicationScript.releaseAndroid(app, assembleType, {
179
+ target,
180
+ env,
181
+ write,
182
+ allowLocalRelease
183
+ });
184
+ }),
185
+ packUpdate: target({
186
+ desc: "Pack an unsigned over-the-air update of the mobile web bundle, for the signer to publish"
187
+ }).with(App).option("platform", String, { enum: ["ios", "android"], desc: "the app it updates" }).option("target", String, mobileTargetOption).option("env", String, releaseEnvOption).option("out", String, {
188
+ desc: "output folder (default: .akan/native/<target>/updates/<platform>)",
189
+ nullable: true
190
+ }).option("against", String, {
191
+ desc: "bundle.json of the store build it must run in; fails when it needs a new one",
192
+ nullable: true
193
+ }).option("write", Boolean, { desc: "write code generation", default: true }).option("allowLocalRelease", Boolean, { flag: "l", desc: "allow packing with --env local", default: false }).exec(async function(app, platform, target, env, out, against, write, allowLocalRelease) {
194
+ await this.applicationScript.packUpdate(app, platform, {
195
+ target,
196
+ env,
197
+ out: out ?? undefined,
198
+ against: against ?? undefined,
199
+ write,
200
+ allowLocalRelease
201
+ });
202
+ }),
203
+ updateKeygen: target({ desc: "Make (once) the key an app's update releases are signed with; print its public key" }).with(App).option("platform", String, {
204
+ enum: ["desktop", "android", "ios"],
205
+ default: "desktop",
206
+ desc: "the platform whose app id the key signs for (an appId may differ per platform)"
207
+ }).option("target", String, mobileTargetOption).exec(async function(app, platform, target) {
208
+ await this.applicationScript.updateKeygen(app, platform, { target });
209
+ }),
210
+ publishUpdate: target({ desc: "Build and sign an update release installed apps take (desktop, android or ios)" }).with(App).option("platform", String, {
211
+ enum: ["desktop", "android", "ios"],
212
+ default: "desktop",
213
+ desc: "desktop is this computer's OS and CPU; android and ios publish the web bundle"
214
+ }).option("target", String, mobileTargetOption).option("env", String, releaseEnvOption).option("channel", String, {
215
+ desc: "the manifest to publish to (default: the target's updates.channel, else --env)",
216
+ nullable: true
217
+ }).option("write", Boolean, { desc: "write code generation", default: true }).option("allowLocalRelease", Boolean, { flag: "l", desc: "allow release with --env local", default: false }).exec(async function(app, platform, target, env, channel, write, allowLocalRelease) {
218
+ await this.applicationScript.publishUpdate(app, platform, {
219
+ target,
220
+ env,
221
+ ...channel ? { channel } : {},
222
+ write,
223
+ allowLocalRelease
224
+ });
225
+ }),
226
+ dbup: target({ desc: "Start local database services for a database mode" }).with(Workspace).option("mode", String, {
227
+ desc: "database mode; left out, every mode the workspace's apps declare",
228
+ enum: ["single", "multiple", "cluster"],
229
+ nullable: true
230
+ }).exec(async function(workspace, mode) {
231
+ await this.applicationScript.dbupDeclared(workspace, mode);
232
+ }),
233
+ dbExport: target({ desc: "Write every model table of an app to one NDJSON file each" }).with(App).option("dir", String, { desc: "directory under the workspace to write", default: "local/transfer" }).exec(async function(app, dir) {
234
+ await this.applicationScript.transferDatabase(app, "export", dir);
235
+ }),
236
+ dbImport: target({ desc: "Read files db-export wrote into an app's database, in the mode the shell names" }).with(App).option("dir", String, { desc: "directory under the workspace to read", default: "local/transfer" }).exec(async function(app, dir) {
237
+ await this.applicationScript.transferDatabase(app, "import", dir);
238
+ }),
239
+ dbdown: target({ desc: "Stop local database services" }).with(Workspace).exec(async function(workspace) {
240
+ await this.applicationScript.dbdown(workspace);
241
+ })
242
+ })) {
243
+ }
244
+ export {
245
+ ApplicationCommand
246
+ };
@@ -1,22 +1,55 @@
1
1
  // @bun
2
2
  import {
3
3
  Spinner
4
- } from "./index-2tv3fdx4.js";
4
+ } from "./index-3w94e7n3.js";
5
+ import"./index-6he6gvfg.js";
5
6
  import {
6
7
  AllRoutesBuilder,
7
8
  CsrArtifactBuilder,
8
9
  FontPruner,
9
10
  precompressArtifacts,
10
11
  SsrBaseArtifactBuilder
11
- } from "./index-a64esmtb.js";
12
- import"./index-w8kmx1b6.js";
13
- import"./index-q0y2jq9j.js";
14
- import"./index-hwkygn9s.js";
12
+ } from "./index-kcdj1z5v.js";
13
+ import"./index-52w0fvh8.js";
15
14
  import"./index-n68jx79w.js";
16
15
 
17
16
  // pkgs/@akanjs/devkit/applicationBuildRunner.ts
18
17
  import { mkdir, rm } from "fs/promises";
18
+ import path2 from "path";
19
+
20
+ // pkgs/@akanjs/devkit/transforms/serverEnvPlugin.ts
21
+ import { existsSync, realpathSync } from "fs";
19
22
  import path from "path";
23
+ var escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
24
+ var createServerEnvPlugin = ({ envDir, environment, environments }) => {
25
+ const others = [...new Set(environments)].filter((name) => name !== environment);
26
+ const dirs = new Set([path.resolve(envDir), existsSync(envDir) ? realpathSync.native(envDir) : envDir]);
27
+ const names = others.map(escapeRegExp).join("|");
28
+ const filter = new RegExp(`^(?:${[...dirs].map(escapeRegExp).join("|")})[\\\\/]env\\.server\\.(?:${names})\\.ts$`);
29
+ return {
30
+ name: "akan-server-env",
31
+ setup(build) {
32
+ if (!others.length)
33
+ return;
34
+ build.onLoad({ filter }, async (args) => {
35
+ const name = path.basename(args.path, ".ts").slice("env.server.".length);
36
+ const { exports } = new Bun.Transpiler({ loader: "ts" }).scan(await Bun.file(args.path).text());
37
+ const message = `env/env.server.${name}.ts is not in this build: \`akan build\` bundles the server env of AKAN_PUBLIC_ENV=${environment} alone, the environment its image runs. To run ${name}, build for it: AKAN_PUBLIC_ENV=${name} in the workspace's .env, which outranks the shell, or --env ${name} on a desktop or mobile build.`;
38
+ return {
39
+ loader: "js",
40
+ contents: [
41
+ `const refuse = () => { throw new Error(${JSON.stringify(message)}); };`,
42
+ "const unbuilt = new Proxy({}, { get: refuse, has: refuse, ownKeys: refuse, getOwnPropertyDescriptor: refuse });",
43
+ `export { ${exports.map((exported) => `unbuilt as ${JSON.stringify(exported)}`).join(", ")} };`
44
+ ].join(`
45
+ `)
46
+ };
47
+ });
48
+ }
49
+ };
50
+ };
51
+
52
+ // pkgs/@akanjs/devkit/applicationBuildRunner.ts
20
53
  var BUILD_PHASE_EMOJIS = {
21
54
  prepare: "\uD83E\uDDF9",
22
55
  typecheck: "\uD83D\uDD0E",
@@ -51,54 +84,52 @@ class ApplicationBuildRunner {
51
84
  #app;
52
85
  #fast;
53
86
  #reporter;
87
+ #environment;
88
+ #spinner;
54
89
  #startedAt = Date.now();
55
90
  #phases = [];
56
- constructor(app, { fast = false, reporter } = {}) {
91
+ constructor(app, { fast = false, reporter, environment } = {}) {
57
92
  this.#app = app;
58
93
  this.#fast = fast;
59
94
  this.#reporter = reporter;
95
+ this.#environment = environment;
60
96
  }
61
97
  async build({ spinner = false } = {}) {
62
- const phaseOptions = { spinner };
98
+ this.#spinner = spinner;
63
99
  const { web, assets } = await this.#app.getConfig();
64
- await this.#runPhase("prepare", "Preparing output directory", () => this.#app.prepareCommand("build"), undefined, {
65
- spinner
66
- });
100
+ await this.#runPhase("prepare", "Preparing output directory", () => this.#app.prepareCommand("build"));
67
101
  if (!this.#fast)
68
- await this.#runPhase("typecheck", "Typechecking", () => this.typecheck(), undefined, phaseOptions);
69
- await this.#runPhase("backend", "Compiling backend", () => this.#buildBackend(), (result) => `${result.entrypoints} entrypoints, ${result.outputs} outputs`, phaseOptions);
70
- await this.#runPhase("ssr", "Building SSR route artifacts", async () => web.ssr ? await this.#buildSsr() : null, (result) => result ? `${result.allRoutes.manifest.routeIds.length} routes, ${result.allRoutes.manifest.knownEntries.length} entries` : web.ssr ? "skipped" : "disabled by akan.config.ts web.ssr", phaseOptions);
71
- await this.#runPhase("csr", "Building CSR assets", async () => web.csr ? await this.#buildCsr() : null, (result) => result?.outputDir ?? (web.csr ? "skipped" : "disabled by akan.config.ts web.csr"), phaseOptions);
72
- await this.#runPhase("assets", "Trimming unread static assets", async () => assets.pruneFonts ? await new FontPruner(this.#app, assets).prune() : null, (result) => result ? `${result.removed.length} font file(s) dropped, ${ApplicationBuildRunner.formatBytes(result.freedBytes)} freed; ${result.kept.length} kept` : "disabled by akan.config.ts assets.pruneFonts", phaseOptions);
73
- await this.#runPhase("compress", "Compressing static assets", () => precompressArtifacts(this.#app), (result) => result.files > 0 ? `${result.files} files, ${ApplicationBuildRunner.formatBytes(result.inputBytes)} -> gzip ${ApplicationBuildRunner.formatBytes(result.outputBytes)} / br ${ApplicationBuildRunner.formatBytes(result.brotliBytes)}` : "no files", phaseOptions);
74
- await this.#runPhase("metadata", "Writing production metadata", () => this.#buildAppMeta(), undefined, {
75
- spinner
76
- });
102
+ await this.#runPhase("typecheck", "Typechecking", () => this.typecheck());
103
+ await this.#runPhase("backend", "Compiling backend", () => this.#buildBackend(), (result) => `${result.entrypoints} entrypoints, ${result.outputs} outputs`);
104
+ await this.#runPhase("ssr", "Building SSR route artifacts", async () => web.ssr ? await this.#buildSsr() : null, (result) => result ? `${result.allRoutes.manifest.routeIds.length} routes, ${result.allRoutes.manifest.knownEntries.length} entries` : web.ssr ? "skipped" : "disabled by akan.config.ts web.ssr");
105
+ await this.#runPhase("csr", "Building CSR assets", async () => web.csr ? await new CsrArtifactBuilder(this.#app, "build").build() : null, (result) => result?.outputDir ?? (web.csr ? "skipped" : "disabled by akan.config.ts web.csr"));
106
+ await this.#runPhase("assets", "Trimming unread static assets", async () => assets.pruneFonts ? await new FontPruner(this.#app, assets).prune() : null, (result) => result ? `${result.removed.length} font file(s) dropped, ${ApplicationBuildRunner.formatBytes(result.freedBytes)} freed; ${result.kept.length} kept` : "disabled by akan.config.ts assets.pruneFonts");
107
+ await this.#runPhase("compress", "Compressing static assets", () => precompressArtifacts(this.#app), (result) => result.files > 0 ? `${result.files} files, ${ApplicationBuildRunner.formatBytes(result.inputBytes)} -> gzip ${ApplicationBuildRunner.formatBytes(result.outputBytes)} / br ${ApplicationBuildRunner.formatBytes(result.brotliBytes)}` : "no files");
108
+ await this.#runPhase("metadata", "Writing production metadata", () => this.buildAppMeta());
77
109
  return {
78
110
  phases: this.#phases,
79
111
  durationMs: Date.now() - this.#startedAt,
80
112
  outputDir: this.#app.dist.cwdPath,
81
- artifactDir: path.join(this.#app.dist.cwdPath, ".akan/artifact")
113
+ artifactDir: path2.join(this.#app.dist.cwdPath, ".akan/artifact")
82
114
  };
83
115
  }
84
116
  async typecheck(options = {}) {
85
117
  const { clean = false, incremental = true } = options;
86
118
  await this.#app.getPageKeys({ refresh: true });
87
- const { typecheckDir, tsconfigPath } = await this.#writeTypecheckTsconfig({ incremental });
119
+ const { typecheckDir, tsconfigPath } = await this.#writeTypecheckTsconfig(incremental);
88
120
  if (clean)
89
- await rm(path.join(typecheckDir, "tsconfig.tsbuildinfo"), { force: true });
121
+ await rm(path2.join(typecheckDir, "tsconfig.tsbuildinfo"), { force: true });
90
122
  await this.#checkProjectInChildProcess(tsconfigPath);
91
123
  }
92
- async#runPhase(id, label, task, summarize, options = {}) {
124
+ async#runPhase(id, label, task, summarize) {
93
125
  this.#reporter?.phaseStart?.({ id, label });
94
126
  const phaseStartedAt = Date.now();
95
- const spinner = options.spinner ? new Spinner(label, { prefix: `${BUILD_PHASE_EMOJIS[id]} ${id}` }).start() : undefined;
127
+ const spinner = this.#spinner ? new Spinner(label, { prefix: `${BUILD_PHASE_EMOJIS[id]} ${id}` }).start() : undefined;
96
128
  try {
97
129
  const result = await task();
98
130
  const phase = { id, label, durationMs: Date.now() - phaseStartedAt, summary: summarize?.(result) };
99
131
  this.#phases.push(phase);
100
- const summary = phase.summary ? `: ${phase.summary}` : "";
101
- spinner?.succeed(`${label}${summary}`);
132
+ spinner?.succeed(`${label}${phase.summary ? `: ${phase.summary}` : ""}`);
102
133
  this.#reporter?.phaseDone?.(phase);
103
134
  return result;
104
135
  } catch (error) {
@@ -107,63 +138,85 @@ class ApplicationBuildRunner {
107
138
  throw error;
108
139
  }
109
140
  }
110
- async#buildAppMeta() {
141
+ async buildAppMeta() {
111
142
  const akanConfig = await this.#app.getConfig();
143
+ const dockerfile = akanConfig.dockerfileFor(this.#environment ?? akanConfig.baseDevEnv.env);
112
144
  await Promise.all([
113
145
  this.#app.dist.writeJson("package.json", akanConfig.getProductionPackageJson()),
114
- this.#app.dist.writeFile(`${this.#app.dist.cwdPath}/Dockerfile`, akanConfig.dockerfile)
146
+ this.#app.dist.writeFile(`${this.#app.dist.cwdPath}/Dockerfile`, dockerfile),
147
+ this.#app.dist.writeJson("akan.build.json", {
148
+ buildId: await this.#resolveBuildId(),
149
+ akanVersion: akanConfig.akanVersion,
150
+ builtAt: new Date().toISOString()
151
+ })
115
152
  ]);
116
153
  }
154
+ async#resolveBuildId() {
155
+ const fromEnv = process.env.AKAN_BUILD_ID?.trim();
156
+ if (fromEnv)
157
+ return fromEnv;
158
+ const root = this.#app.workspace.workspaceRoot;
159
+ const sha = Bun.spawnSync(["git", "rev-parse", "--short=12", "HEAD"], { cwd: root, stderr: "ignore" });
160
+ if (sha.exitCode !== 0)
161
+ return null;
162
+ const dirty = Bun.spawnSync(["git", "status", "--porcelain", "--untracked-files=no"], {
163
+ cwd: root,
164
+ stderr: "ignore"
165
+ });
166
+ const suffix = dirty.exitCode === 0 && dirty.stdout.toString().trim() ? "-dirty" : "";
167
+ return `${sha.stdout.toString().trim()}${suffix}`;
168
+ }
117
169
  async#buildBackend() {
118
- const akanConfig = await this.#app.getConfig();
119
- const backendExternals = [
120
- ...new Set([...akanConfig.externalLibs, ...SSR_RENDER_EXTERNALS, ...AKAN_OPTIONAL_BACKEND_EXTERNALS])
121
- ];
122
- const { web } = akanConfig;
170
+ const { externalLibs, web, baseDevEnv, branches } = await this.#app.getConfig();
123
171
  const backendEntryPoints = [`${this.#app.cwdPath}/main.ts`, `${this.#app.cwdPath}/server.ts`];
124
172
  for (const entrypoint of backendEntryPoints) {
125
173
  if (!await Bun.file(entrypoint).exists())
126
174
  throw new Error(`Backend entrypoint not found: ${entrypoint}`);
127
175
  }
128
- const backendResult = await this.#buildOrThrow("backend", {
129
- entrypoints: backendEntryPoints,
176
+ const sharedConfig = {
130
177
  outdir: this.#app.dist.cwdPath,
131
178
  target: "bun",
132
179
  minify: AKAN_BACKEND_MINIFY,
133
180
  naming: { entry: "[name].[ext]", chunk: "chunk-[hash].[ext]" },
134
- define: { "process.env.NODE_ENV": JSON.stringify("production") },
135
- plugins: backendExternals.length > 0 ? [this.#createExternalSpecifiersPlugin(backendExternals)] : []
181
+ define: { "process.env.NODE_ENV": JSON.stringify("production") }
182
+ };
183
+ const serverEnvPlugin = createServerEnvPlugin({
184
+ envDir: path2.join(this.#app.cwdPath, "env"),
185
+ environment: this.#environment ?? baseDevEnv.env,
186
+ environments: ["local", "testing", ...branches]
136
187
  });
188
+ const backendConfig = {
189
+ ...sharedConfig,
190
+ plugins: [this.#createExternalSpecifiersPlugin(externalLibs), serverEnvPlugin]
191
+ };
192
+ const [mainResult, serverResult] = [
193
+ await this.#buildOrThrow("backend", { ...backendConfig, entrypoints: [backendEntryPoints[0]] }),
194
+ await this.#buildOrThrow("backend", { ...backendConfig, entrypoints: [backendEntryPoints[1]], splitting: true })
195
+ ];
137
196
  const rscWorkerResult = web.ssr ? await this.#buildOrThrow("rsc-worker", {
197
+ ...backendConfig,
138
198
  entrypoints: [this.#resolveRscWorkerBuildEntry()],
139
- outdir: this.#app.dist.cwdPath,
140
- target: "bun",
141
- minify: AKAN_BACKEND_MINIFY,
142
- naming: { entry: "[name].[ext]", chunk: "chunk-[hash].[ext]" },
143
- conditions: ["react-server"],
144
- define: { "process.env.NODE_ENV": JSON.stringify("production") },
145
- plugins: backendExternals.length > 0 ? [this.#createExternalSpecifiersPlugin(backendExternals)] : []
199
+ conditions: ["react-server"]
146
200
  }) : null;
147
201
  const consoleRuntimeResult = await this.#buildOrThrow("console-runtime", {
202
+ ...sharedConfig,
148
203
  entrypoints: [this.#resolveConsoleRuntimeBuildEntry()],
149
- outdir: this.#app.dist.cwdPath,
150
- target: "bun",
151
- minify: AKAN_BACKEND_MINIFY,
152
- naming: { entry: "console-runtime.[ext]", chunk: "chunk-[hash].[ext]" },
153
- define: { "process.env.NODE_ENV": JSON.stringify("production") }
204
+ naming: { entry: "console-runtime.[ext]", chunk: "chunk-[hash].[ext]" }
154
205
  });
155
206
  await this.#writeConsoleShim();
207
+ const results = [mainResult, serverResult, rscWorkerResult, consoleRuntimeResult];
156
208
  return {
157
209
  entrypoints: backendEntryPoints.length + (rscWorkerResult ? 2 : 1),
158
- outputs: backendResult.outputs.length + (rscWorkerResult?.outputs.length ?? 0) + consoleRuntimeResult.outputs.length + 1
210
+ outputs: results.reduce((sum, result) => sum + (result?.outputs.length ?? 0), 1)
159
211
  };
160
212
  }
161
213
  async#writeConsoleShim() {
162
- await Bun.write(path.join(this.#app.dist.cwdPath, "console.js"), `import { cnst, db, dict, option, server, sig, srv } from "./server.js";
163
- import { assertAkanConsoleAllowed, startAkanConsole } from "./console-runtime.js";
214
+ await Bun.write(path2.join(this.#app.dist.cwdPath, "console.js"), `process.env.AKAN_COMMAND_TYPE = "console";
215
+ const { cnst, db, dict, option, server, sig, srv } = await import("./server.js");
216
+ const { assertAkanConsoleAllowed, startAkanConsole } = await import("./console-runtime.js");
164
217
 
165
218
  const run = async () => {
166
- assertAkanConsoleAllowed(server.env);
219
+ assertAkanConsoleAllowed();
167
220
  await server.start({ listen: false, web: false });
168
221
  try {
169
222
  await startAkanConsole(server, { globals: { cnst, db, dict, option, sig, srv } });
@@ -182,19 +235,16 @@ void run().catch((error) => {
182
235
  try {
183
236
  return Bun.resolveSync("akanjs/server/rsc-worker", import.meta.dir);
184
237
  } catch {
185
- return path.join(this.#app.workspace.workspaceRoot, "pkgs/akanjs/server/rscWorker.tsx");
238
+ return path2.join(this.#app.workspace.workspaceRoot, "pkgs/akanjs/server/rscWorker.tsx");
186
239
  }
187
240
  }
188
241
  #resolveConsoleRuntimeBuildEntry() {
189
242
  try {
190
- return path.join(path.dirname(Bun.resolveSync("akanjs/server", import.meta.dir)), "console.ts");
243
+ return path2.join(path2.dirname(Bun.resolveSync("akanjs/server", import.meta.dir)), "console.ts");
191
244
  } catch {
192
- return path.join(this.#app.workspace.workspaceRoot, "pkgs/akanjs/server/console.ts");
245
+ return path2.join(this.#app.workspace.workspaceRoot, "pkgs/akanjs/server/console.ts");
193
246
  }
194
247
  }
195
- async#buildCsr() {
196
- return await new CsrArtifactBuilder(this.#app, "build").build();
197
- }
198
248
  async#buildSsr() {
199
249
  const pageKeys = await this.#app.getPageKeys();
200
250
  if (pageKeys.length === 0) {
@@ -205,11 +255,11 @@ void run().catch((error) => {
205
255
  const allRoutes = await new AllRoutesBuilder(this.#app, base.artifact, "build").build();
206
256
  return { base, allRoutes };
207
257
  }
208
- async#writeTypecheckTsconfig({ incremental = true } = {}) {
209
- const typecheckDir = path.join(this.#app.cwdPath, ".akan", "typecheck");
258
+ async#writeTypecheckTsconfig(incremental) {
259
+ const typecheckDir = path2.join(this.#app.cwdPath, ".akan", "typecheck");
210
260
  await mkdir(typecheckDir, { recursive: true });
211
261
  const libPageIncludes = (await this.#app.getPageRoots()).filter((root) => root.keyPrefix).flatMap((root) => {
212
- const rel = path.relative(typecheckDir, root.realDir).split(path.sep).join("/");
262
+ const rel = path2.relative(typecheckDir, root.realDir).split(path2.sep).join("/");
213
263
  return [`${rel}/**/*.ts`, `${rel}/**/*.tsx`];
214
264
  });
215
265
  const tsconfig = {
@@ -230,7 +280,7 @@ void run().catch((error) => {
230
280
  ],
231
281
  references: []
232
282
  };
233
- const tsconfigPath = path.join(typecheckDir, "tsconfig.json");
283
+ const tsconfigPath = path2.join(typecheckDir, "tsconfig.json");
234
284
  await Bun.write(tsconfigPath, `${JSON.stringify(tsconfig, null, 2)}
235
285
  `);
236
286
  return { typecheckDir, tsconfigPath };
@@ -256,10 +306,10 @@ void run().catch((error) => {
256
306
  }
257
307
  async#resolveTypecheckWorkerEntry() {
258
308
  const candidates = [
259
- path.join(this.#app.workspace.workspaceRoot, "pkgs/@akanjs/devkit/typecheck/typecheck.proc.ts"),
260
- path.join(this.#app.workspace.workspaceRoot, "node_modules/@akanjs/devkit/typecheck/typecheck.proc.ts"),
261
- path.join(import.meta.dir, "typecheck.proc.js"),
262
- path.join(import.meta.dir, "typecheck.proc.ts")
309
+ path2.join(this.#app.workspace.workspaceRoot, "pkgs/@akanjs/devkit/typecheck/typecheck.proc.ts"),
310
+ path2.join(this.#app.workspace.workspaceRoot, "node_modules/@akanjs/devkit/typecheck/typecheck.proc.ts"),
311
+ path2.join(import.meta.dir, "typecheck.proc.js"),
312
+ path2.join(import.meta.dir, "typecheck.proc.ts")
263
313
  ];
264
314
  for (const candidate of candidates)
265
315
  if (await Bun.file(candidate).exists())
@@ -272,9 +322,9 @@ void run().catch((error) => {
272
322
  throw new AggregateError(result.logs, `[${label}] Bun.build failed`);
273
323
  return result;
274
324
  }
275
- #createExternalSpecifiersPlugin(specifiers) {
276
- const uniqueSpecifiers = [...new Set(specifiers)];
277
- const escaped = uniqueSpecifiers.map((specifier) => specifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
325
+ #createExternalSpecifiersPlugin(externalLibs) {
326
+ const specifiers = new Set([...externalLibs, ...SSR_RENDER_EXTERNALS, ...AKAN_OPTIONAL_BACKEND_EXTERNALS]);
327
+ const escaped = [...specifiers].map((specifier) => specifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
278
328
  const filter = new RegExp(`^(${escaped.join("|")})(?:/.*)?$`);
279
329
  return {
280
330
  name: "akan-backend-externalize-specifiers",
@@ -283,13 +333,7 @@ void run().catch((error) => {
283
333
  }
284
334
  };
285
335
  }
286
- static formatBytes(bytes) {
287
- if (bytes < 1024)
288
- return `${bytes}B`;
289
- if (bytes < 1024 * 1024)
290
- return `${(bytes / 1024).toFixed(1)}KB`;
291
- return `${(bytes / 1024 / 1024).toFixed(1)}MB`;
292
- }
336
+ static formatBytes = FontPruner.formatBytes;
293
337
  }
294
338
  export {
295
339
  ApplicationBuildRunner