@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
@@ -0,0 +1,191 @@
1
+ // @bun
2
+ import {
3
+ GlobalConfig,
4
+ CloudApi
5
+ } from "./index-gr9thy79.js";
6
+
7
+ // pkgs/@akanjs/cli/tunnel/TunnelShare.ts
8
+ import { TunnelAgent } from "akanjs/server/tunnel";
9
+
10
+ // pkgs/@akanjs/cli/tunnel/TunnelGate.ts
11
+ var devRoutePrefixes = [
12
+ "/_akan/devtools",
13
+ "/_akan/signal",
14
+ "/_akan/constant",
15
+ "/_akan/deps",
16
+ "/_akan/dictionary",
17
+ "/_akan/hmr",
18
+ "/_akan/app",
19
+ "/_akan/ops"
20
+ ];
21
+ var handshakeHeaders = new Set([
22
+ "upgrade",
23
+ "connection",
24
+ "sec-websocket-key",
25
+ "sec-websocket-version",
26
+ "sec-websocket-extensions",
27
+ "sec-websocket-accept",
28
+ "sec-websocket-protocol"
29
+ ]);
30
+ var relayableCloseCode = (code) => code >= 3000 && code <= 4999 || code >= 1000 && code <= 1014 && ![1004, 1005, 1006].includes(code) ? code : 1001;
31
+
32
+ class TunnelGate {
33
+ static isDevRoute(pathname) {
34
+ let decoded;
35
+ try {
36
+ decoded = decodeURIComponent(pathname);
37
+ } catch {
38
+ return true;
39
+ }
40
+ const route = decoded.replace(/\/{2,}/g, "/").toLowerCase();
41
+ return route.endsWith(".map") || devRoutePrefixes.some((prefix) => route === prefix || route.startsWith(`${prefix}/`));
42
+ }
43
+ #target;
44
+ #server;
45
+ origin;
46
+ constructor(target) {
47
+ this.#target = target.replace(/\/$/, "");
48
+ this.#server = Bun.serve({
49
+ hostname: "127.0.0.1",
50
+ port: 0,
51
+ idleTimeout: 0,
52
+ fetch: (req, server) => this.#handle(req, server),
53
+ error: () => new Response("The local app did not answer", { status: 502 }),
54
+ websocket: {
55
+ idleTimeout: 0,
56
+ open: (ws) => {
57
+ ws.data.client = ws;
58
+ for (const message of ws.data.pending.splice(0))
59
+ ws.send(message);
60
+ if (ws.data.closed)
61
+ ws.close(relayableCloseCode(ws.data.closed.code), ws.data.closed.reason);
62
+ },
63
+ message: (ws, message) => {
64
+ if (ws.data.upstream.readyState === WebSocket.OPEN)
65
+ ws.data.upstream.send(message);
66
+ },
67
+ close: (ws, code, reason) => ws.data.upstream.close(relayableCloseCode(code), reason),
68
+ data: {}
69
+ }
70
+ });
71
+ this.origin = `http://127.0.0.1:${this.#server.port}`;
72
+ }
73
+ stop() {
74
+ this.#server.stop(true);
75
+ }
76
+ async#handle(req, server) {
77
+ const url = new URL(req.url);
78
+ if (TunnelGate.isDevRoute(url.pathname))
79
+ return new Response("Not Found", { status: 404 });
80
+ const target = `${this.#target}${url.pathname}${url.search}`;
81
+ if (req.headers.get("upgrade")?.toLowerCase() === "websocket")
82
+ return await this.#upgrade(req, server, target);
83
+ const headers = new Headers(req.headers);
84
+ headers.delete("x-akan-debug");
85
+ return await fetch(target, {
86
+ method: req.method,
87
+ headers,
88
+ body: req.body,
89
+ redirect: "manual",
90
+ decompress: false,
91
+ duplex: "half"
92
+ });
93
+ }
94
+ async#upgrade(req, server, target) {
95
+ const protocols = (req.headers.get("sec-websocket-protocol") ?? "").split(",").map((one) => one.trim()).filter(Boolean);
96
+ const headers = {};
97
+ for (const [name, value] of req.headers)
98
+ if (!handshakeHeaders.has(name) && name !== "x-akan-debug")
99
+ headers[name] = value;
100
+ const upstream = new WebSocket(target.replace(/^http/, "ws"), {
101
+ headers,
102
+ ...protocols.length ? { protocols } : {}
103
+ });
104
+ upstream.binaryType = "arraybuffer";
105
+ const opened = await new Promise((resolve) => {
106
+ upstream.onopen = () => resolve(true);
107
+ upstream.onerror = () => resolve(false);
108
+ upstream.onclose = () => resolve(false);
109
+ });
110
+ if (!opened)
111
+ return new Response("The local app refused the websocket", { status: 502 });
112
+ const data = { upstream, client: null, pending: [], closed: null };
113
+ upstream.onmessage = (event) => {
114
+ if (data.client)
115
+ data.client.send(event.data);
116
+ else
117
+ data.pending.push(event.data);
118
+ };
119
+ upstream.onclose = (event) => {
120
+ data.closed = { code: event.code, reason: event.reason };
121
+ data.client?.close(relayableCloseCode(event.code), event.reason);
122
+ };
123
+ upstream.onerror = () => {
124
+ data.closed = { code: 1011, reason: "local app websocket error" };
125
+ data.client?.close(1011, data.closed.reason);
126
+ };
127
+ const upgraded = server.upgrade(req, {
128
+ data,
129
+ ...upstream.protocol ? { headers: { "Sec-WebSocket-Protocol": upstream.protocol } } : {}
130
+ });
131
+ if (upgraded)
132
+ return;
133
+ upstream.close();
134
+ return new Response("WebSocket upgrade failed", { status: 500 });
135
+ }
136
+ }
137
+
138
+ // pkgs/@akanjs/cli/tunnel/TunnelShare.ts
139
+ class TunnelShare2 {
140
+ #api;
141
+ #agent;
142
+ #gate;
143
+ grant;
144
+ #closed = false;
145
+ constructor(api, agent, grant, gate) {
146
+ this.#api = api;
147
+ this.#agent = agent;
148
+ this.grant = grant;
149
+ this.#gate = gate;
150
+ }
151
+ static async open(app, { workspace, host, port, ttlMinutes, devRoutes = false, onLost }) {
152
+ const api = await CloudApi.fromHost(workspace, await GlobalConfig.hostFor(workspace, host));
153
+ const grant = await api.requestTunnel({ name: app.name, ...ttlMinutes ? { ttlMinutes } : {} });
154
+ const appOrigin = `http://localhost:${port ?? await app.getDevPort()}`;
155
+ const gate = devRoutes ? null : new TunnelGate(appOrigin);
156
+ const agent = new TunnelAgent({
157
+ gatewayUrl: grant.gatewayUrl,
158
+ token: grant.token,
159
+ hostnames: [grant.hostname],
160
+ origin: gate?.origin ?? appOrigin,
161
+ name: app.name,
162
+ ...onLost ? { onLost } : {}
163
+ });
164
+ try {
165
+ await agent.start();
166
+ } catch (error) {
167
+ gate?.stop();
168
+ throw error;
169
+ }
170
+ return new TunnelShare2(api, agent, grant, gate);
171
+ }
172
+ static exposureNotice(appName, devRoutes) {
173
+ const reach = `Anyone with this URL reaches ${appName} on this machine, without signing in.`;
174
+ return devRoutes ? `${reach} --dev-routes also hands them devtools, the HMR socket and source maps.` : `${reach} Devtools, the HMR socket and source maps stay local; \`akan tunnel --dev-routes\` shares them too.`;
175
+ }
176
+ get url() {
177
+ return this.grant.url;
178
+ }
179
+ async close() {
180
+ if (this.#closed)
181
+ return;
182
+ this.#closed = true;
183
+ await this.#agent.stop("cli exited");
184
+ this.#gate?.stop();
185
+ try {
186
+ await this.#api.revokeTunnel(this.grant.code);
187
+ } catch {}
188
+ }
189
+ }
190
+
191
+ export { TunnelShare2 };
@@ -0,0 +1,225 @@
1
+ // @bun
2
+ // pkgs/@akanjs/devkit/preview/PreviewChrome.ts
3
+ import { existsSync } from "fs";
4
+ import { homedir } from "os";
5
+ import path from "path";
6
+
7
+ class PreviewChrome2 {
8
+ static pathEnvKey = "BUN_CHROME_PATH";
9
+ static backendEnvKey = "AKAN_CODE_WEBVIEW_BACKEND";
10
+ static executables = [
11
+ "chromium",
12
+ "chromium-browser",
13
+ "google-chrome-stable",
14
+ "google-chrome",
15
+ "brave-browser",
16
+ "microsoft-edge",
17
+ "chrome"
18
+ ];
19
+ static appBundles = [
20
+ "Google Chrome.app/Contents/MacOS/Google Chrome",
21
+ "Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
22
+ "Chromium.app/Contents/MacOS/Chromium",
23
+ "Brave Browser.app/Contents/MacOS/Brave Browser",
24
+ "Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
25
+ ];
26
+ static get backend() {
27
+ const declared = process.env[PreviewChrome2.backendEnvKey];
28
+ if (declared === "webkit" || declared === "chrome")
29
+ return declared;
30
+ return process.platform === "darwin" ? "webkit" : "chrome";
31
+ }
32
+ static executable() {
33
+ const declared = process.env[PreviewChrome2.pathEnvKey];
34
+ if (declared)
35
+ return declared;
36
+ for (const name of PreviewChrome2.executables) {
37
+ const found = Bun.which(name);
38
+ if (found)
39
+ return found;
40
+ }
41
+ if (process.platform !== "darwin")
42
+ return;
43
+ for (const root of ["/Applications", path.join(homedir(), "Applications")])
44
+ for (const bundle of PreviewChrome2.appBundles) {
45
+ const candidate = path.join(root, bundle);
46
+ if (existsSync(candidate))
47
+ return candidate;
48
+ }
49
+ return;
50
+ }
51
+ static get available() {
52
+ return PreviewChrome2.isAvailable();
53
+ }
54
+ static isAvailable(engine = PreviewChrome2.backend) {
55
+ return engine === "webkit" ? process.platform === "darwin" : !!PreviewChrome2.executable();
56
+ }
57
+ static backendOption(engine = PreviewChrome2.backend) {
58
+ if (engine === "webkit")
59
+ return "webkit";
60
+ const argv = ["--disable-dev-shm-usage"];
61
+ if (process.getuid?.() === 0)
62
+ argv.push("--no-sandbox");
63
+ return { type: "chrome", argv };
64
+ }
65
+ static dockerRuns = [
66
+ "apt-get update && apt-get install -y --no-install-recommends chromium fonts-liberation fonts-noto-color-emoji fonts-noto-cjk && rm -rf /var/lib/apt/lists/*"
67
+ ];
68
+ static unavailableReason(engine = PreviewChrome2.backend) {
69
+ if (PreviewChrome2.isAvailable(engine))
70
+ return;
71
+ if (engine === "webkit")
72
+ return `The webkit WebView backend exists only on macOS. Set ${PreviewChrome2.backendEnvKey}=chrome and install a browser.`;
73
+ return [
74
+ "The page preview needs a browser and this machine has none on PATH.",
75
+ `Install one (${PreviewChrome2.dockerRuns[0]}) or point ${PreviewChrome2.pathEnvKey} at an existing Chrome.`
76
+ ].join(" ");
77
+ }
78
+ }
79
+
80
+ // pkgs/@akanjs/devkit/preview/PreviewView.ts
81
+ class PreviewView2 {
82
+ static get available() {
83
+ return PreviewView2.isAvailable();
84
+ }
85
+ static isAvailable(engine = PreviewChrome2.backend) {
86
+ return typeof Bun.WebView === "function" && PreviewChrome2.isAvailable(engine);
87
+ }
88
+ static unavailableReason(engine = PreviewChrome2.backend) {
89
+ if (typeof Bun.WebView !== "function")
90
+ return "This Bun build has no WebView, so the page preview is off.";
91
+ return PreviewChrome2.unavailableReason(engine);
92
+ }
93
+ static async probe(url, {
94
+ screenshot = false,
95
+ width = 1280,
96
+ height = 800,
97
+ engine = PreviewChrome2.backend,
98
+ timeoutMs = 30000,
99
+ settleMs = 0
100
+ } = {}) {
101
+ const logs = [];
102
+ const deadline = Date.now() + timeoutMs;
103
+ const within = (work, what) => PreviewView2.#within(work, deadline, `${what} ${url}`);
104
+ const view = PreviewView2.#open({ width, height, engine, onConsole: (line) => logs.push(line) });
105
+ try {
106
+ let page = await PreviewView2.#load(view, url, settleMs, within);
107
+ if (page.empty) {
108
+ logs.length = 0;
109
+ page = await PreviewView2.#load(view, url, settleMs, within);
110
+ }
111
+ const result = {
112
+ url,
113
+ finalUrl: page.href,
114
+ status: page.status ?? await PreviewView2.#statusOf(page.href, deadline),
115
+ title: page.title,
116
+ text: page.text,
117
+ consoleErrors: logs.filter((line) => line.startsWith("error")),
118
+ consoleWarnings: logs.filter((line) => line.startsWith("warn")),
119
+ pageErrors: page.pageErrors,
120
+ domFindings: page.domFindings
121
+ };
122
+ if (screenshot)
123
+ result.screenshot = await within(view.screenshot({ encoding: "base64" }), "screenshotting");
124
+ return result;
125
+ } finally {
126
+ await view.close();
127
+ }
128
+ }
129
+ static async#load(view, url, settleMs, within) {
130
+ await within(view.navigate(url), "loading");
131
+ if (settleMs > 0)
132
+ await Bun.sleep(settleMs);
133
+ const read = await within(view.evaluate(readPageExpression), "reading");
134
+ return {
135
+ href: typeof read?.href === "string" ? read.href : url,
136
+ title: typeof read?.title === "string" ? read.title : "",
137
+ text: typeof read?.text === "string" ? read.text : "",
138
+ status: typeof read?.status === "number" && read.status > 0 ? read.status : null,
139
+ empty: read?.empty === true,
140
+ pageErrors: PreviewView2.#strings(read?.pageErrors),
141
+ domFindings: PreviewView2.#strings(read?.domFindings)
142
+ };
143
+ }
144
+ static async#statusOf(href, deadline) {
145
+ const left = Math.max(1, deadline - Date.now());
146
+ const response = await fetch(href, { redirect: "manual", signal: AbortSignal.timeout(left) }).catch(() => null);
147
+ return response?.status ?? null;
148
+ }
149
+ static async#within(work, deadline, what) {
150
+ let timer;
151
+ const expired = new Promise((_, reject) => {
152
+ timer = setTimeout(() => reject(new Error(`Timed out ${what}; the dev server may be rebuilding or stuck.`)), Math.max(0, deadline - Date.now()));
153
+ });
154
+ try {
155
+ return await Promise.race([work, expired]);
156
+ } finally {
157
+ clearTimeout(timer);
158
+ }
159
+ }
160
+ static #open({
161
+ width,
162
+ height,
163
+ engine,
164
+ onConsole
165
+ }) {
166
+ const Ctor = Bun.WebView;
167
+ return new Ctor({
168
+ width,
169
+ height,
170
+ dataStore: "ephemeral",
171
+ backend: PreviewChrome2.backendOption(engine),
172
+ console: (type, ...args) => onConsole(`${type} ${PreviewView2.formatConsole(args)}`)
173
+ });
174
+ }
175
+ static formatConsole(args) {
176
+ const [first, ...rest] = args;
177
+ const head = typeof first === "string" ? first.replace(/%[sdifoOc]/g, (token) => {
178
+ if (!rest.length)
179
+ return token;
180
+ const value = rest.shift();
181
+ return token === "%c" ? "" : String(value);
182
+ }) : String(first);
183
+ return [head, ...rest.map(String)].join(" ").replace(/\n(\s*\n)+/g, `
184
+ `).slice(0, 1500);
185
+ }
186
+ static #strings(value) {
187
+ return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
188
+ }
189
+ }
190
+ var readPageExpression = `(() => {
191
+ const pageErrors = [];
192
+ const domFindings = [];
193
+ const body = document.body;
194
+ const rendered = body ? Array.from(body.children).filter((el) => !["SCRIPT", "STYLE", "TEMPLATE", "LINK", "NOSCRIPT"].includes(el.tagName) && !el.classList.contains("__akan_hmr_overlay")) : [];
195
+ const empty = !rendered.length && !(body && body.innerText && body.innerText.trim());
196
+ if (empty) pageErrors.push("The page body rendered empty.");
197
+ if (self.__AKAN_HMR_SYSTEM_PAGE__) pageErrors.push("The server could not render this page and answered with its error page: " + (body ? body.innerText.trim().replace(/\\s+/g, " ").slice(0, 400) : ""));
198
+ const overlay = document.querySelector('.__akan_hmr_overlay[data-status="error"]');
199
+ if (overlay) pageErrors.push("The dev build failed: " + overlay.textContent.trim().slice(0, 400));
200
+ const all = Array.from(document.querySelectorAll("body *"));
201
+ const viewportWidth = document.documentElement.clientWidth;
202
+ const pageWidth = document.documentElement.scrollWidth;
203
+ if (pageWidth > viewportWidth + 8) {
204
+ const wide = all.find((el) => el.getBoundingClientRect().right > viewportWidth + 8);
205
+ domFindings.push("The page is " + pageWidth + "px wide in a " + viewportWidth + "px viewport" + (wide ? ", first wider element: " + (wide.tagName.toLowerCase() + "." + (typeof wide.className === "string" ? wide.className : "")).slice(0, 120) : "") + ".");
206
+ }
207
+ const invisibleText = all.filter((el) => {
208
+ if (!el.textContent || !el.textContent.trim()) return false;
209
+ const style = getComputedStyle(el);
210
+ return style.color === style.backgroundColor && style.backgroundColor !== "rgba(0, 0, 0, 0)";
211
+ });
212
+ if (invisibleText.length) domFindings.push(invisibleText.length + " element(s) render text in the same colour as their background.");
213
+ const unresolved = all.filter((el) => /(^|\\s)(bg|text|border)-(base-100|base-content|primary-content|error)(\\s|$)/.test(typeof el.className === "string" ? el.className : ""));
214
+ if (unresolved.length) domFindings.push(unresolved.length + " element(s) use a dropped daisyUI colour slot that renders no CSS.");
215
+ const navigation = performance.getEntriesByType("navigation")[0];
216
+ const status = navigation && typeof navigation.responseStatus === "number" ? navigation.responseStatus : null;
217
+ const text = body ? body.innerText.trim().replace(/\\s+/g, " ").slice(0, 600) : "";
218
+ return { href: location.href, title: document.title, text, status, empty, pageErrors, domFindings };
219
+ })()`;
220
+
221
+ // pkgs/@akanjs/devkit/stripAnsi.ts
222
+ var ansi = new RegExp(`${String.fromCharCode(27)}(?:[@-Z\\\\-_]|\\[[\\s\\S]*?[@-~])`, "g");
223
+ var stripAnsi = (text) => text.replace(ansi, "");
224
+
225
+ export { PreviewChrome2, PreviewView2, stripAnsi };
@@ -1,16 +1,16 @@
1
1
  // @bun
2
2
  import {
3
3
  jsonText
4
- } from "./index-xjf5j657.js";
4
+ } from "./index-hm0tn7qv.js";
5
5
  import {
6
6
  akanMcpInstallTargets
7
- } from "./index-31es1yev.js";
7
+ } from "./index-j7hwy56s.js";
8
8
  import {
9
9
  script
10
- } from "./index-3wypz6xj.js";
10
+ } from "./index-9zy8479y.js";
11
11
  import {
12
12
  ContextRunner2
13
- } from "./index-a58emady.js";
13
+ } from "./index-qw6814m4.js";
14
14
 
15
15
  // pkgs/@akanjs/cli/context/context.script.ts
16
16
  import { Logger } from "akanjs/common";
@@ -1,29 +1,29 @@
1
1
  // @bun
2
2
  import {
3
3
  FileSys2
4
- } from "./index-52w0fvh8.js";
4
+ } from "./index-bns3wcpc.js";
5
5
  import {
6
6
  SOURCE_EXTS,
7
7
  WatchRootResolver
8
- } from "./index-5nd1wtkv.js";
8
+ } from "./index-p6x5b7hr.js";
9
9
  import {
10
- bundleDefine,
11
- CsrEntryFiles,
12
10
  loaderFor,
13
11
  BarrelAnalyzer,
14
12
  createBarrelImportsPlugin,
15
13
  createTsconfigPackageResolver,
16
14
  rewriteBarrelImports,
15
+ bundleDefine,
16
+ CsrEntryFiles,
17
17
  toClientReferencePath,
18
18
  scanUseClientExports,
19
19
  CsrDevPaths,
20
20
  PagesEntrySourceGenerator,
21
21
  PagesBundleBuilder
22
- } from "./index-0fz95kxe.js";
22
+ } from "./index-zbrwnmf1.js";
23
23
  import {
24
24
  AsyncDefaultExportDetector,
25
25
  resolveSsrPageEntriesForApp
26
- } from "./index-wcej7g4z.js";
26
+ } from "./index-g500c5j9.js";
27
27
 
28
28
  // pkgs/@akanjs/devkit/frontendBuild/autoImportSync.ts
29
29
  import { readdir, readFile, stat } from "fs/promises";