gemi 0.130.0 → 0.131.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 (216) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/ai/index.js.map +1 -1
  3. package/dist/app/App.d.ts +9 -0
  4. package/dist/app/App.d.ts.map +1 -1
  5. package/dist/app/index.js +1 -1
  6. package/dist/bin/gemi.js +182 -128
  7. package/dist/bin/gemi.js.map +7 -6
  8. package/dist/bun/plugin.js +1 -1
  9. package/dist/bun/preload.js +1 -1
  10. package/dist/{chunk-t7gvgz20.js → chunk-0g5f8ymy.js} +2 -2
  11. package/dist/{chunk-t7gvgz20.js.map → chunk-0g5f8ymy.js.map} +1 -1
  12. package/dist/{chunk-peng31np.js → chunk-0q68t71d.js} +3 -3
  13. package/dist/{chunk-peng31np.js.map → chunk-0q68t71d.js.map} +1 -1
  14. package/dist/{chunk-vc5kpxdk.js → chunk-2senwsdq.js} +2 -2
  15. package/dist/{chunk-vc5kpxdk.js.map → chunk-2senwsdq.js.map} +1 -1
  16. package/dist/{chunk-2869cbhd.js → chunk-2tda49mv.js} +3 -3
  17. package/dist/{chunk-2869cbhd.js.map → chunk-2tda49mv.js.map} +1 -1
  18. package/dist/{chunk-1z311hyj.js → chunk-2x0n3ze1.js} +2 -2
  19. package/dist/{chunk-1z311hyj.js.map → chunk-2x0n3ze1.js.map} +1 -1
  20. package/dist/{chunk-cp84b0ev.js → chunk-35zw2s61.js} +3 -3
  21. package/dist/{chunk-cp84b0ev.js.map → chunk-35zw2s61.js.map} +1 -1
  22. package/dist/{chunk-7ynnce4b.js → chunk-3wnczt5w.js} +3 -3
  23. package/dist/{chunk-7ynnce4b.js.map → chunk-3wnczt5w.js.map} +3 -3
  24. package/dist/{chunk-v09w6pr2.js → chunk-3xy41vc0.js} +3 -3
  25. package/dist/{chunk-v09w6pr2.js.map → chunk-3xy41vc0.js.map} +1 -1
  26. package/dist/{chunk-fezaxj28.js → chunk-47eav3ex.js} +2 -2
  27. package/dist/{chunk-fezaxj28.js.map → chunk-47eav3ex.js.map} +1 -1
  28. package/dist/{chunk-ww86zqbw.js → chunk-4gmhx2ba.js} +2 -2
  29. package/dist/{chunk-ww86zqbw.js.map → chunk-4gmhx2ba.js.map} +1 -1
  30. package/dist/{chunk-k10vbrjx.js → chunk-4wda9teq.js} +3 -3
  31. package/dist/{chunk-k10vbrjx.js.map → chunk-4wda9teq.js.map} +1 -1
  32. package/dist/{chunk-ja41ts8v.js → chunk-4z0rt6ws.js} +2 -2
  33. package/dist/{chunk-ja41ts8v.js.map → chunk-4z0rt6ws.js.map} +1 -1
  34. package/dist/{chunk-xtqhagxz.js → chunk-539w9yt3.js} +2 -2
  35. package/dist/{chunk-xtqhagxz.js.map → chunk-539w9yt3.js.map} +1 -1
  36. package/dist/{chunk-9122838b.js → chunk-58mg4rpd.js} +2 -2
  37. package/dist/{chunk-9122838b.js.map → chunk-58mg4rpd.js.map} +1 -1
  38. package/dist/{chunk-0m2fyw7g.js → chunk-63xekerg.js} +2 -2
  39. package/dist/{chunk-0m2fyw7g.js.map → chunk-63xekerg.js.map} +1 -1
  40. package/dist/{chunk-qv8sj2z3.js → chunk-65fq5a9d.js} +2 -2
  41. package/dist/{chunk-qv8sj2z3.js.map → chunk-65fq5a9d.js.map} +1 -1
  42. package/dist/{chunk-bg5qb9hm.js → chunk-65s63bdh.js} +2 -2
  43. package/dist/{chunk-bg5qb9hm.js.map → chunk-65s63bdh.js.map} +1 -1
  44. package/dist/chunk-77ymcf7q.js +4 -0
  45. package/dist/chunk-77ymcf7q.js.map +10 -0
  46. package/dist/{chunk-wn437678.js → chunk-7j48ymk1.js} +2 -2
  47. package/dist/{chunk-wn437678.js.map → chunk-7j48ymk1.js.map} +1 -1
  48. package/dist/{chunk-dak8txaw.js → chunk-7n0zn5h4.js} +2 -2
  49. package/dist/{chunk-dak8txaw.js.map → chunk-7n0zn5h4.js.map} +1 -1
  50. package/dist/{chunk-p528pvmm.js → chunk-822p54vc.js} +2 -2
  51. package/dist/{chunk-p528pvmm.js.map → chunk-822p54vc.js.map} +1 -1
  52. package/dist/{chunk-qjmcn5m5.js → chunk-838cdh6v.js} +2 -2
  53. package/dist/{chunk-qjmcn5m5.js.map → chunk-838cdh6v.js.map} +1 -1
  54. package/dist/{chunk-h55c9bdf.js → chunk-8fvt7kys.js} +1 -1
  55. package/dist/{chunk-xtnbcbkf.js → chunk-aprjvzrz.js} +2 -2
  56. package/dist/{chunk-nvfhx9d1.js.map → chunk-aprjvzrz.js.map} +1 -1
  57. package/dist/{chunk-sh39q44t.js → chunk-asmszzkp.js} +3 -3
  58. package/dist/{chunk-sh39q44t.js.map → chunk-asmszzkp.js.map} +1 -1
  59. package/dist/{chunk-nvfhx9d1.js → chunk-ayjfs5mm.js} +2 -2
  60. package/dist/{chunk-xtnbcbkf.js.map → chunk-ayjfs5mm.js.map} +1 -1
  61. package/dist/{chunk-kmcnfk2s.js → chunk-b00z33zg.js} +1 -1
  62. package/dist/{chunk-pgddb43b.js → chunk-c1gq2ttb.js} +2 -2
  63. package/dist/{chunk-pgddb43b.js.map → chunk-c1gq2ttb.js.map} +1 -1
  64. package/dist/{chunk-0vxwrc4t.js → chunk-cggywjzz.js} +2 -2
  65. package/dist/{chunk-0vxwrc4t.js.map → chunk-cggywjzz.js.map} +1 -1
  66. package/dist/{chunk-n1t4ea9g.js → chunk-d5g1caxb.js} +3 -3
  67. package/dist/{chunk-n1t4ea9g.js.map → chunk-d5g1caxb.js.map} +1 -1
  68. package/dist/{chunk-f8ce6e9c.js → chunk-dp2yz8bj.js} +2 -2
  69. package/dist/{chunk-f8ce6e9c.js.map → chunk-dp2yz8bj.js.map} +1 -1
  70. package/dist/{chunk-43vjbd6n.js → chunk-dxm5gxqk.js} +1 -1
  71. package/dist/{chunk-9701fx4z.js → chunk-dz76qhx8.js} +2 -2
  72. package/dist/{chunk-9701fx4z.js.map → chunk-dz76qhx8.js.map} +1 -1
  73. package/dist/{chunk-fv53h1q2.js → chunk-e1fhy2h5.js} +2 -2
  74. package/dist/{chunk-fv53h1q2.js.map → chunk-e1fhy2h5.js.map} +1 -1
  75. package/dist/{chunk-1yttk239.js → chunk-e4ay1vg9.js} +2 -2
  76. package/dist/{chunk-1yttk239.js.map → chunk-e4ay1vg9.js.map} +1 -1
  77. package/dist/{chunk-5nkvpc0a.js → chunk-f21v4n2v.js} +1 -1
  78. package/dist/{chunk-wv3nnq8c.js → chunk-fgtr9cds.js} +3 -3
  79. package/dist/{chunk-wv3nnq8c.js.map → chunk-fgtr9cds.js.map} +1 -1
  80. package/dist/chunk-fx7r6pdf.js +122 -0
  81. package/dist/{chunk-0ryswty9.js.map → chunk-fx7r6pdf.js.map} +9 -8
  82. package/dist/{chunk-nh9ewam0.js → chunk-fxm8fqh9.js} +1 -1
  83. package/dist/{chunk-tn3y2qkj.js → chunk-fzs7g6mc.js} +2 -2
  84. package/dist/{chunk-tn3y2qkj.js.map → chunk-fzs7g6mc.js.map} +1 -1
  85. package/dist/{chunk-1rq53cb0.js → chunk-gnaxedwh.js} +2 -2
  86. package/dist/{chunk-1rq53cb0.js.map → chunk-gnaxedwh.js.map} +1 -1
  87. package/dist/{chunk-njaxnv6c.js → chunk-h0xye69a.js} +2 -2
  88. package/dist/{chunk-njaxnv6c.js.map → chunk-h0xye69a.js.map} +1 -1
  89. package/dist/{chunk-ty5sp1ym.js → chunk-hdgbh8hn.js} +2 -2
  90. package/dist/{chunk-ty5sp1ym.js.map → chunk-hdgbh8hn.js.map} +1 -1
  91. package/dist/{chunk-jcps2gpp.js → chunk-hnf11jhc.js} +2 -2
  92. package/dist/{chunk-jcps2gpp.js.map → chunk-hnf11jhc.js.map} +1 -1
  93. package/dist/{chunk-vjpby5sf.js → chunk-hr8annr1.js} +3 -3
  94. package/dist/{chunk-vjpby5sf.js.map → chunk-hr8annr1.js.map} +1 -1
  95. package/dist/{chunk-k107vw69.js → chunk-j1wc4afr.js} +2 -2
  96. package/dist/{chunk-k107vw69.js.map → chunk-j1wc4afr.js.map} +1 -1
  97. package/dist/{chunk-2z1gd231.js → chunk-j4y0sjdc.js} +2 -2
  98. package/dist/{chunk-2z1gd231.js.map → chunk-j4y0sjdc.js.map} +1 -1
  99. package/dist/{chunk-er5ed5pg.js → chunk-jbd723h1.js} +3 -3
  100. package/dist/{chunk-er5ed5pg.js.map → chunk-jbd723h1.js.map} +1 -1
  101. package/dist/{chunk-5ym464xx.js → chunk-jd1afbrs.js} +4 -4
  102. package/dist/{chunk-5ym464xx.js.map → chunk-jd1afbrs.js.map} +1 -1
  103. package/dist/{chunk-xhm5wgfe.js → chunk-jxmc33m9.js} +2 -2
  104. package/dist/{chunk-xhm5wgfe.js.map → chunk-jxmc33m9.js.map} +1 -1
  105. package/dist/{chunk-pxsq9841.js → chunk-jxvec7jc.js} +2 -2
  106. package/dist/{chunk-pxsq9841.js.map → chunk-jxvec7jc.js.map} +1 -1
  107. package/dist/chunk-mvka90rq.js +5 -0
  108. package/dist/{chunk-pqn9j5s8.js.map → chunk-mvka90rq.js.map} +1 -1
  109. package/dist/{chunk-mc8mxx2a.js → chunk-mym7egdq.js} +2 -2
  110. package/dist/{chunk-mc8mxx2a.js.map → chunk-mym7egdq.js.map} +1 -1
  111. package/dist/{chunk-np73p641.js → chunk-mz73066c.js} +2 -2
  112. package/dist/{chunk-np73p641.js.map → chunk-mz73066c.js.map} +1 -1
  113. package/dist/{chunk-3dyd4z06.js → chunk-n7sbwpce.js} +2 -2
  114. package/dist/{chunk-3dyd4z06.js.map → chunk-n7sbwpce.js.map} +1 -1
  115. package/dist/{chunk-gpdsxwkt.js → chunk-p320fd3g.js} +2 -2
  116. package/dist/{chunk-gpdsxwkt.js.map → chunk-p320fd3g.js.map} +1 -1
  117. package/dist/{chunk-nwzsgzvy.js → chunk-p462p2xe.js} +2 -2
  118. package/dist/{chunk-nwzsgzvy.js.map → chunk-p462p2xe.js.map} +1 -1
  119. package/dist/{chunk-2bmk0fzm.js → chunk-p642ja42.js} +3 -3
  120. package/dist/{chunk-2bmk0fzm.js.map → chunk-p642ja42.js.map} +1 -1
  121. package/dist/{chunk-jj1ppnnk.js → chunk-p6b0cyf8.js} +2 -2
  122. package/dist/{chunk-jj1ppnnk.js.map → chunk-p6b0cyf8.js.map} +1 -1
  123. package/dist/{chunk-8jqve5dr.js → chunk-pahr13xg.js} +2 -2
  124. package/dist/{chunk-8jqve5dr.js.map → chunk-pahr13xg.js.map} +1 -1
  125. package/dist/{chunk-wf3qe12c.js → chunk-pzb3agv9.js} +2 -2
  126. package/dist/{chunk-wf3qe12c.js.map → chunk-pzb3agv9.js.map} +1 -1
  127. package/dist/{chunk-87rtxv9n.js → chunk-qspam5cf.js} +2 -2
  128. package/dist/{chunk-87rtxv9n.js.map → chunk-qspam5cf.js.map} +1 -1
  129. package/dist/{chunk-n4dk0dc9.js → chunk-qz89m7ss.js} +2 -2
  130. package/dist/{chunk-n4dk0dc9.js.map → chunk-qz89m7ss.js.map} +1 -1
  131. package/dist/{chunk-gzaaspe7.js → chunk-rjyw1thg.js} +2 -2
  132. package/dist/{chunk-gzaaspe7.js.map → chunk-rjyw1thg.js.map} +1 -1
  133. package/dist/{chunk-2epj17ac.js → chunk-t227jn4b.js} +2 -2
  134. package/dist/{chunk-2epj17ac.js.map → chunk-t227jn4b.js.map} +1 -1
  135. package/dist/{chunk-x92g4x4w.js → chunk-v5esvs66.js} +2 -2
  136. package/dist/{chunk-x92g4x4w.js.map → chunk-v5esvs66.js.map} +1 -1
  137. package/dist/{chunk-4yp84g2y.js → chunk-w26cw41m.js} +2 -2
  138. package/dist/{chunk-4yp84g2y.js.map → chunk-w26cw41m.js.map} +1 -1
  139. package/dist/{chunk-03wc6em7.js → chunk-x07rp3fc.js} +1 -1
  140. package/dist/{chunk-7321qjgb.js → chunk-x4yq0c9v.js} +3 -3
  141. package/dist/{chunk-7321qjgb.js.map → chunk-x4yq0c9v.js.map} +1 -1
  142. package/dist/{chunk-5bk7767a.js → chunk-xhvknqvn.js} +2 -2
  143. package/dist/{chunk-5bk7767a.js.map → chunk-xhvknqvn.js.map} +1 -1
  144. package/dist/{chunk-1gdzajwb.js → chunk-xjs72pb0.js} +2 -2
  145. package/dist/{chunk-1gdzajwb.js.map → chunk-xjs72pb0.js.map} +1 -1
  146. package/dist/{chunk-13agap7z.js → chunk-y14weak4.js} +4 -4
  147. package/dist/{chunk-13agap7z.js.map → chunk-y14weak4.js.map} +3 -3
  148. package/dist/{chunk-pgh7gsag.js → chunk-z1gjgr1c.js} +2 -2
  149. package/dist/{chunk-pgh7gsag.js.map → chunk-z1gjgr1c.js.map} +1 -1
  150. package/dist/{chunk-jm1f9cas.js → chunk-zc5962gh.js} +2 -2
  151. package/dist/{chunk-jm1f9cas.js.map → chunk-zc5962gh.js.map} +1 -1
  152. package/dist/{chunk-b7wmssj5.js → chunk-zzgt759n.js} +2 -2
  153. package/dist/{chunk-b7wmssj5.js.map → chunk-zzgt759n.js.map} +1 -1
  154. package/dist/config/index.js +1 -1
  155. package/dist/console/run.js +2 -2
  156. package/dist/console/run.js.map +1 -1
  157. package/dist/container/index.js +2 -2
  158. package/dist/container/index.js.map +1 -1
  159. package/dist/database/index.js +2 -2
  160. package/dist/database/index.js.map +1 -1
  161. package/dist/email/index.js +2 -2
  162. package/dist/email/index.js.map +1 -1
  163. package/dist/facades/index.js +2 -2
  164. package/dist/facades/index.js.map +1 -1
  165. package/dist/foundation/index.js +2 -2
  166. package/dist/foundation/index.js.map +1 -1
  167. package/dist/http/ViewRouter.d.ts +17 -0
  168. package/dist/http/ViewRouter.d.ts.map +1 -1
  169. package/dist/http/index.js +2 -2
  170. package/dist/http/index.js.map +1 -1
  171. package/dist/i18n/dictionaryRuntime.js +2 -2
  172. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  173. package/dist/i18n/index.js +2 -2
  174. package/dist/i18n/index.js.map +1 -1
  175. package/dist/kernel/index.js +2 -2
  176. package/dist/kernel/index.js.map +1 -1
  177. package/dist/orm/index.js +2 -2
  178. package/dist/orm/index.js.map +1 -1
  179. package/dist/server/httpDev.d.ts.map +1 -1
  180. package/dist/server/httpProd.d.ts.map +1 -1
  181. package/dist/server/index.js +2 -2
  182. package/dist/server/index.js.map +1 -1
  183. package/dist/services/index.d.ts +1 -0
  184. package/dist/services/index.d.ts.map +1 -1
  185. package/dist/services/index.js +3 -3
  186. package/dist/services/index.js.map +2 -2
  187. package/dist/services/queue/work.js +2 -2
  188. package/dist/services/queue/work.js.map +1 -1
  189. package/dist/services/router/DomainResolver.d.ts +12 -0
  190. package/dist/services/router/DomainResolver.d.ts.map +1 -1
  191. package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
  192. package/dist/services/router/config.d.ts +21 -5
  193. package/dist/services/router/config.d.ts.map +1 -1
  194. package/dist/services/router/documentScript.d.ts +46 -0
  195. package/dist/services/router/documentScript.d.ts.map +1 -0
  196. package/dist/services/router/staticDocument.d.ts +11 -1
  197. package/dist/services/router/staticDocument.d.ts.map +1 -1
  198. package/dist/stats/route-table.js +1 -1
  199. package/dist/support/index.js +2 -2
  200. package/dist/support/index.js.map +1 -1
  201. package/dist/testing/index.js +4 -2
  202. package/dist/testing/index.js.map +1 -1
  203. package/dist/testing/staticDocument.d.ts +8 -2
  204. package/dist/testing/staticDocument.d.ts.map +1 -1
  205. package/dist/vitest/index.js +1 -1
  206. package/package.json +1 -1
  207. package/dist/chunk-0ryswty9.js +0 -120
  208. package/dist/chunk-bnp6wpzd.js +0 -4
  209. package/dist/chunk-bnp6wpzd.js.map +0 -10
  210. package/dist/chunk-pqn9j5s8.js +0 -5
  211. /package/dist/{chunk-h55c9bdf.js.map → chunk-8fvt7kys.js.map} +0 -0
  212. /package/dist/{chunk-kmcnfk2s.js.map → chunk-b00z33zg.js.map} +0 -0
  213. /package/dist/{chunk-43vjbd6n.js.map → chunk-dxm5gxqk.js.map} +0 -0
  214. /package/dist/{chunk-5nkvpc0a.js.map → chunk-f21v4n2v.js.map} +0 -0
  215. /package/dist/{chunk-nh9ewam0.js.map → chunk-fxm8fqh9.js.map} +0 -0
  216. /package/dist/{chunk-03wc6em7.js.map → chunk-x07rp3fc.js.map} +0 -0
package/dist/bin/gemi.js CHANGED
@@ -4006,7 +4006,7 @@ var require_util = __commonJS((exports) => {
4006
4006
  return path3;
4007
4007
  }
4008
4008
  exports.normalize = normalize;
4009
- function join2(aRoot, aPath) {
4009
+ function join4(aRoot, aPath) {
4010
4010
  if (aRoot === "") {
4011
4011
  aRoot = ".";
4012
4012
  }
@@ -4038,11 +4038,11 @@ var require_util = __commonJS((exports) => {
4038
4038
  }
4039
4039
  return joined;
4040
4040
  }
4041
- exports.join = join2;
4041
+ exports.join = join4;
4042
4042
  exports.isAbsolute = function(aPath) {
4043
4043
  return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
4044
4044
  };
4045
- function relative(aRoot, aPath) {
4045
+ function relative2(aRoot, aPath) {
4046
4046
  if (aRoot === "") {
4047
4047
  aRoot = ".";
4048
4048
  }
@@ -4061,7 +4061,7 @@ var require_util = __commonJS((exports) => {
4061
4061
  }
4062
4062
  return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
4063
4063
  }
4064
- exports.relative = relative;
4064
+ exports.relative = relative2;
4065
4065
  var supportsNullProto = function() {
4066
4066
  var obj = Object.create(null);
4067
4067
  return !("__proto__" in obj);
@@ -4211,7 +4211,7 @@ var require_util = __commonJS((exports) => {
4211
4211
  parsed.path = parsed.path.substring(0, index + 1);
4212
4212
  }
4213
4213
  }
4214
- sourceURL = join2(urlGenerate(parsed), sourceURL);
4214
+ sourceURL = join4(urlGenerate(parsed), sourceURL);
4215
4215
  }
4216
4216
  return normalize(sourceURL);
4217
4217
  }
@@ -36727,7 +36727,7 @@ var init_generate = __esm(() => {
36727
36727
 
36728
36728
  // bin/gemi.ts
36729
36729
  import path10 from "path";
36730
- import { existsSync as existsSync10 } from "fs";
36730
+ import { existsSync as existsSync11 } from "fs";
36731
36731
  import { mkdtemp, rm } from "fs/promises";
36732
36732
  import { tmpdir as tmpdir2 } from "os";
36733
36733
 
@@ -36798,6 +36798,9 @@ class App {
36798
36798
  sockets() {
36799
36799
  return this.kernel.sockets.call(this.kernel);
36800
36800
  }
36801
+ applyTrustedClientIp(req) {
36802
+ this.kernel.domains().resolver?.applyClientIp(req);
36803
+ }
36801
36804
  getRouteManifest() {
36802
36805
  return this.kernel.viewRoutes().routeManifest;
36803
36806
  }
@@ -36818,6 +36821,7 @@ class App {
36818
36821
  async fetch(req) {
36819
36822
  const url = new URL(req.url);
36820
36823
  return this.kernel.run.call(this.kernel, async () => {
36824
+ this.applyTrustedClientIp(req);
36821
36825
  const gated = this.globallyGated.has(req);
36822
36826
  const outcome = gated ? null : await this.kernel.globalMiddleware(req);
36823
36827
  const carried = gated ? this.globallyGated.get(req) : outcome.carried;
@@ -36873,13 +36877,97 @@ async function loadApp() {
36873
36877
  return new App({ kernel: Kernel });
36874
36878
  }
36875
36879
 
36880
+ // services/router/documentScript.ts
36881
+ import { existsSync as existsSync2, readFileSync } from "fs";
36882
+ import { join as join3 } from "path";
36883
+
36884
+ // support/discover.ts
36885
+ import { existsSync, readdirSync } from "fs";
36886
+ import { join as join2, relative } from "path";
36887
+ function sourceFiles(dir, ignore = []) {
36888
+ const out = [];
36889
+ const ignored = (path2) => {
36890
+ const rel = relative(dir, path2).split("\\").join("/");
36891
+ return ignore.some((pattern) => rel === pattern || rel.startsWith(`${pattern}/`));
36892
+ };
36893
+ const walk = (current) => {
36894
+ for (const entry of readdirSync(current, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
36895
+ const path2 = join2(current, entry.name);
36896
+ if (ignored(path2))
36897
+ continue;
36898
+ if (entry.isDirectory()) {
36899
+ if (entry.name.startsWith(".") || entry.name === "node_modules")
36900
+ continue;
36901
+ if (existsSync(join2(path2, "package.json")))
36902
+ continue;
36903
+ walk(path2);
36904
+ continue;
36905
+ }
36906
+ if (!entry.name.endsWith(".ts") && !entry.name.endsWith(".tsx"))
36907
+ continue;
36908
+ if (entry.name.endsWith(".d.ts"))
36909
+ continue;
36910
+ if (/\.(test|test-d|spec|bench)\.tsx?$/.test(entry.name))
36911
+ continue;
36912
+ out.push(path2);
36913
+ }
36914
+ };
36915
+ if (!existsSync(dir))
36916
+ return out;
36917
+ walk(dir);
36918
+ return out;
36919
+ }
36920
+
36921
+ // services/router/documentScript.ts
36922
+ var DOCUMENT_SCRIPT_SUFFIX = ".script";
36923
+ var DOCUMENT_SCRIPTS_MANIFEST = "document-scripts.json";
36924
+ var NAME = /^[A-Za-z0-9_-]+(\/[A-Za-z0-9_-]+)*$/;
36925
+ async function bundleDocumentScript(file) {
36926
+ const result = await Bun.build({
36927
+ entrypoints: [file],
36928
+ target: "browser",
36929
+ format: "iife",
36930
+ minify: true,
36931
+ throw: false
36932
+ });
36933
+ if (!result.success || !result.outputs[0]) {
36934
+ const logs = result.logs.map((log) => String(log)).join(`
36935
+ `);
36936
+ throw new Error(`The document script ${file} does not bundle.
36937
+ ${logs}`);
36938
+ }
36939
+ const source = (await result.outputs[0].text()).trim();
36940
+ if (/<\/script|<!--/i.test(source)) {
36941
+ throw new Error(`The document script ${file} contains "</script" or "<!--", which would end the inline <script> it is put in. Write it "<\\/script" or build the string from parts.`);
36942
+ }
36943
+ return source;
36944
+ }
36945
+ async function bundleDocumentScripts(appDir) {
36946
+ const views = join3(appDir, "views");
36947
+ const scripts = {};
36948
+ if (!existsSync2(views))
36949
+ return scripts;
36950
+ const glob = new Bun.Glob(`**/*${DOCUMENT_SCRIPT_SUFFIX}.{ts,js}`);
36951
+ const files = [...glob.scanSync({ cwd: views })].sort();
36952
+ for (const file of files) {
36953
+ if (file.split("/").includes("node_modules"))
36954
+ continue;
36955
+ const name = file.replace(/\.script\.[tj]s$/, "");
36956
+ if (!NAME.test(name) || name in scripts)
36957
+ continue;
36958
+ scripts[name] = await bundleDocumentScript(join3(views, file));
36959
+ }
36960
+ return scripts;
36961
+ }
36962
+ var bundledInProduction = new Map;
36963
+
36876
36964
  // bin/migrate/index.ts
36877
36965
  import path2 from "path";
36878
36966
  import {
36879
- existsSync,
36967
+ existsSync as existsSync3,
36880
36968
  mkdirSync,
36881
- readFileSync,
36882
- readdirSync,
36969
+ readFileSync as readFileSync2,
36970
+ readdirSync as readdirSync2,
36883
36971
  rmSync,
36884
36972
  statSync,
36885
36973
  writeFileSync
@@ -37750,7 +37838,7 @@ var GEMI_MODULES = [
37750
37838
  async function runMigrate(options) {
37751
37839
  const { rootDir, dryRun = false } = options;
37752
37840
  const appDir = path2.join(rootDir, "app");
37753
- if (!existsSync(appDir)) {
37841
+ if (!existsSync3(appDir)) {
37754
37842
  console.error(`No app/ directory found in ${rootDir}. Nothing to migrate.`);
37755
37843
  process.exitCode = 1;
37756
37844
  return;
@@ -37761,9 +37849,9 @@ async function runMigrate(options) {
37761
37849
  const slices = new Map;
37762
37850
  const migratedFiles = [];
37763
37851
  const carriedProviders = [];
37764
- const onOldLayout = existsSync(providersDir);
37852
+ const onOldLayout = existsSync3(providersDir);
37765
37853
  if (onOldLayout) {
37766
- for (const entry of readdirSync(providersDir).sort()) {
37854
+ for (const entry of readdirSync2(providersDir).sort()) {
37767
37855
  if (!/\.tsx?$/.test(entry))
37768
37856
  continue;
37769
37857
  const file = path2.join(providersDir, entry);
@@ -37787,7 +37875,7 @@ async function runMigrate(options) {
37787
37875
  for (const [configKey, inputs] of slices) {
37788
37876
  const emitted = buildConfigFile(configKey, inputs, { rootDir, appDir, aliasPrefix }, notes);
37789
37877
  const configFile = path2.join(appDir, "config", `${configKey}.ts`);
37790
- if (existsSync(configFile)) {
37878
+ if (existsSync3(configFile)) {
37791
37879
  notes.push({
37792
37880
  file: rel(rootDir, configFile),
37793
37881
  message: `already exists \u2014 left untouched. The ${inputs.length === 1 ? "provider" : "providers"} it would ` + `have been generated from ${inputs.length === 1 ? "is" : "are"} left in place too, so nothing is ` + `lost; fold them together by hand and delete the provider.`
@@ -37801,7 +37889,7 @@ async function runMigrate(options) {
37801
37889
  }
37802
37890
  changes.push({ file: configFile, contents: emitted.contents });
37803
37891
  for (const extracted of emitted.extractedFiles) {
37804
- if (existsSync(extracted.file)) {
37892
+ if (existsSync3(extracted.file)) {
37805
37893
  notes.push({
37806
37894
  file: rel(rootDir, extracted.file),
37807
37895
  message: "already exists \u2014 left untouched, review it by hand"
@@ -37813,7 +37901,7 @@ async function runMigrate(options) {
37813
37901
  }
37814
37902
  const kernelFile = path2.join(appDir, "kernel", "Kernel.ts");
37815
37903
  if (onOldLayout) {
37816
- if (existsSync(kernelFile)) {
37904
+ if (existsSync3(kernelFile)) {
37817
37905
  changes.push({
37818
37906
  file: kernelFile,
37819
37907
  contents: buildKernel(kernelFile, [...slices.keys()], carriedProviders, rootDir, notes)
@@ -37826,7 +37914,7 @@ async function runMigrate(options) {
37826
37914
  }
37827
37915
  }
37828
37916
  const appProviderFile = path2.join(appDir, "providers", "AppServiceProvider.ts");
37829
- if (onOldLayout && !existsSync(appProviderFile)) {
37917
+ if (onOldLayout && !existsSync3(appProviderFile)) {
37830
37918
  changes.push({ file: appProviderFile, contents: APP_SERVICE_PROVIDER });
37831
37919
  }
37832
37920
  for (const file of migratedFiles)
@@ -37835,7 +37923,7 @@ async function runMigrate(options) {
37835
37923
  for (const file of walk(appDir)) {
37836
37924
  if (touched.has(file))
37837
37925
  continue;
37838
- const source = readFileSync(file, "utf8");
37926
+ const source = readFileSync2(file, "utf8");
37839
37927
  let rewritten = rewriteReferences(source, rel(rootDir, file), notes);
37840
37928
  rewritten = annotateRetiredFields(rewritten, file, rootDir, notes);
37841
37929
  if (rewritten !== source)
@@ -37855,7 +37943,7 @@ async function runMigrate(options) {
37855
37943
  continue;
37856
37944
  swept.add(file);
37857
37945
  const index = pending.get(file);
37858
- const before = index === undefined ? readFileSync(file, "utf8") : changes[index].contents;
37946
+ const before = index === undefined ? readFileSync2(file, "utf8") : changes[index].contents;
37859
37947
  const after = annotateOrmPortHazards(before, rel(rootDir, file), notes);
37860
37948
  if (after === before)
37861
37949
  continue;
@@ -37877,21 +37965,21 @@ async function runMigrate(options) {
37877
37965
  rmSync(change.file, { force: true });
37878
37966
  continue;
37879
37967
  }
37880
- const verb = existsSync(change.file) ? "update" : "create";
37968
+ const verb = existsSync3(change.file) ? "update" : "create";
37881
37969
  console.log(` ${verb.padStart(6)} ${label}`);
37882
37970
  if (dryRun)
37883
37971
  continue;
37884
37972
  mkdirSync(path2.dirname(change.file), { recursive: true });
37885
37973
  writeFileSync(change.file, change.contents);
37886
37974
  }
37887
- if (!dryRun && existsSync(providersDir) && readdirSync(providersDir).length === 0) {
37975
+ if (!dryRun && existsSync3(providersDir) && readdirSync2(providersDir).length === 0) {
37888
37976
  rmSync(providersDir, { recursive: true, force: true });
37889
37977
  }
37890
37978
  report(notes, dryRun);
37891
37979
  }
37892
37980
  function readProvider(file, rootDir, notes) {
37893
37981
  const label = rel(rootDir, file);
37894
- const source = rewriteReferences(readFileSync(file, "utf8"), label, notes, {
37982
+ const source = rewriteReferences(readFileSync2(file, "utf8"), label, notes, {
37895
37983
  keepProviders: true
37896
37984
  });
37897
37985
  const imports = parseImports(source);
@@ -38099,7 +38187,7 @@ function reindent(text, width, shift) {
38099
38187
  `);
38100
38188
  }
38101
38189
  function buildKernel(file, configKeys, carriedProviders, rootDir, notes) {
38102
- const source = readFileSync(file, "utf8");
38190
+ const source = readFileSync2(file, "utf8");
38103
38191
  const imports = parseImports(source);
38104
38192
  const kernelClass = findClasses(source).find((cls) => cls.isDefaultExport);
38105
38193
  const providerLocals = new Map;
@@ -38368,19 +38456,19 @@ function moduleSpecifier(ctx, dir, name) {
38368
38456
  return `${ctx.aliasPrefix}${dir}/${name}`;
38369
38457
  const from = path2.join(ctx.appDir, "config");
38370
38458
  const to = path2.join(ctx.rootDir, dir, name);
38371
- const relative = path2.relative(from, to).split(path2.sep).join("/");
38372
- return relative.startsWith(".") ? relative : `./${relative}`;
38459
+ const relative2 = path2.relative(from, to).split(path2.sep).join("/");
38460
+ return relative2.startsWith(".") ? relative2 : `./${relative2}`;
38373
38461
  }
38374
38462
  function detectAliasPrefix(appDir) {
38375
38463
  for (const file of walk(appDir)) {
38376
- const source = readFileSync(file, "utf8");
38464
+ const source = readFileSync2(file, "utf8");
38377
38465
  if (/from\s+["']@\/app\//.test(source))
38378
38466
  return "@/";
38379
38467
  }
38380
38468
  return null;
38381
38469
  }
38382
38470
  function* walk(dir) {
38383
- for (const entry of readdirSync(dir).sort()) {
38471
+ for (const entry of readdirSync2(dir).sort()) {
38384
38472
  if (entry === "node_modules" || entry === "dist" || entry.startsWith("."))
38385
38473
  continue;
38386
38474
  const full = path2.join(dir, entry);
@@ -38580,13 +38668,13 @@ function gemiPlugin() {
38580
38668
  }
38581
38669
 
38582
38670
  // config/load.ts
38583
- import { existsSync as existsSync2 } from "fs";
38584
- import { join as join2 } from "path";
38671
+ import { existsSync as existsSync4 } from "fs";
38672
+ import { join as join4 } from "path";
38585
38673
  var CONFIG_FILES = ["gemi.config.ts", "gemi.config.js", "gemi.config.mjs"];
38586
38674
  async function loadGemiConfig(rootDir = process.cwd()) {
38587
38675
  for (const name of CONFIG_FILES) {
38588
- const path3 = join2(rootDir, name);
38589
- if (existsSync2(path3)) {
38676
+ const path3 = join4(rootDir, name);
38677
+ if (existsSync4(path3)) {
38590
38678
  const mod = await import(path3);
38591
38679
  return mod.default ?? mod;
38592
38680
  }
@@ -38613,8 +38701,8 @@ for (let i = 0;i < chars.length; i++) {
38613
38701
  intToChar[i] = c;
38614
38702
  charToInt[c] = i;
38615
38703
  }
38616
- function encodeInteger(builder, num, relative) {
38617
- let delta = num - relative;
38704
+ function encodeInteger(builder, num, relative2) {
38705
+ let delta = num - relative2;
38618
38706
  delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
38619
38707
  do {
38620
38708
  let clamped = delta & 31;
@@ -40054,7 +40142,7 @@ function walk2(node, visit) {
40054
40142
 
40055
40143
  // vite/assetBasePlugin.ts
40056
40144
  import { mkdir, writeFile } from "fs/promises";
40057
- import { dirname, join as join3 } from "path";
40145
+ import { dirname, join as join5 } from "path";
40058
40146
 
40059
40147
  // config/assetBase.ts
40060
40148
  var DEFAULT_ASSET_BASE = "/";
@@ -40087,7 +40175,7 @@ function gemiAssetBasePlugin(assetBase) {
40087
40175
  if (!resolved || resolved.command !== "build" || resolved.build.ssr || !options.dir) {
40088
40176
  return;
40089
40177
  }
40090
- const file = join3(options.dir, ASSET_BASE_RECORD);
40178
+ const file = join5(options.dir, ASSET_BASE_RECORD);
40091
40179
  await mkdir(dirname(file), { recursive: true });
40092
40180
  await writeFile(file, `${JSON.stringify({ assetBase: documentBase(resolved.base) })}
40093
40181
  `);
@@ -40100,7 +40188,7 @@ function documentBase(base) {
40100
40188
 
40101
40189
  // vite/islandPlugin.ts
40102
40190
  import { realpathSync } from "fs";
40103
- import { relative, sep } from "path";
40191
+ import { relative as relative2, sep } from "path";
40104
40192
 
40105
40193
  // internal/islandRuntime.ts
40106
40194
  var ISLAND_RUNTIME_ID = "virtual:gemi-island-runtime";
@@ -40194,7 +40282,7 @@ function gemiIslandPlugin() {
40194
40282
  if (!resolved || resolved.external)
40195
40283
  continue;
40196
40284
  const file = realPath(resolved.id.split("?")[0]);
40197
- const key = relative(root, file).split(sep).join("/");
40285
+ const key = relative2(root, file).split(sep).join("/");
40198
40286
  if (key.startsWith(".."))
40199
40287
  continue;
40200
40288
  const name = `__gemi_island_${imports.length}`;
@@ -40274,7 +40362,7 @@ var vite_default = gemi;
40274
40362
 
40275
40363
  // vite/previousAssets.ts
40276
40364
  import { copyFile, lstat, mkdir as mkdir2, readdir, readFile, stat, writeFile as writeFile2 } from "fs/promises";
40277
- import { dirname as dirname2, isAbsolute, join as join4, relative as relative2, resolve, sep as sep2 } from "path";
40365
+ import { dirname as dirname2, isAbsolute, join as join6, relative as relative3, resolve, sep as sep2 } from "path";
40278
40366
  var PREVIOUS_ASSETS_RECORD = ".vite/previous-assets.json";
40279
40367
  var DEFAULT_RETAINED_RELEASES = 2;
40280
40368
  var DEFAULT_RETAINED_MAX_AGE_SECONDS = 7 * 24 * 60 * 60;
@@ -40285,7 +40373,7 @@ function resolvePreviousAssets(configured, rootDir, env = process.env.GEMI_PREVI
40285
40373
  return;
40286
40374
  }
40287
40375
  const config = typeof configured === "object" ? configured : {};
40288
- const from = fromEnv || config.from || join4("dist", "client");
40376
+ const from = fromEnv || config.from || join6("dist", "client");
40289
40377
  const releases = config.releases ?? DEFAULT_RETAINED_RELEASES;
40290
40378
  const maxAge = config.maxAge ?? DEFAULT_RETAINED_MAX_AGE_SECONDS;
40291
40379
  if (!Number.isInteger(releases) || releases < 0) {
@@ -40302,8 +40390,8 @@ function resolvePreviousAssets(configured, rootDir, env = process.env.GEMI_PREVI
40302
40390
  }
40303
40391
  async function stagePreviousAssets(options, stagingDir, now = new Date) {
40304
40392
  const { from } = options;
40305
- if (!await isDirectory(join4(from, ASSETS_DIR))) {
40306
- console.log(`No previous assets at ${join4(from, ASSETS_DIR)}; nothing to carry over.`);
40393
+ if (!await isDirectory(join6(from, ASSETS_DIR))) {
40394
+ console.log(`No previous assets at ${join6(from, ASSETS_DIR)}; nothing to carry over.`);
40307
40395
  return [];
40308
40396
  }
40309
40397
  const carried = await readRecord(from);
@@ -40323,7 +40411,7 @@ async function stagePreviousAssets(options, stagingDir, now = new Date) {
40323
40411
  if (!source || !await isFile(source)) {
40324
40412
  continue;
40325
40413
  }
40326
- const target = join4(stagingDir, file);
40414
+ const target = join6(stagingDir, file);
40327
40415
  await mkdir2(dirname2(target), { recursive: true });
40328
40416
  await copyFile(source, target);
40329
40417
  await copySiblings(source, target);
@@ -40347,8 +40435,8 @@ async function restorePreviousAssets(stagingDir, clientDir, releases) {
40347
40435
  continue;
40348
40436
  }
40349
40437
  await mkdir2(dirname2(target), { recursive: true });
40350
- await copyFile(join4(stagingDir, file), target);
40351
- await copySiblings(join4(stagingDir, file), target);
40438
+ await copyFile(join6(stagingDir, file), target);
40439
+ await copySiblings(join6(stagingDir, file), target);
40352
40440
  files.push(file);
40353
40441
  paths.push(file);
40354
40442
  }
@@ -40357,7 +40445,7 @@ async function restorePreviousAssets(stagingDir, clientDir, releases) {
40357
40445
  count += files.length;
40358
40446
  }
40359
40447
  }
40360
- const recordPath = join4(clientDir, PREVIOUS_ASSETS_RECORD);
40448
+ const recordPath = join6(clientDir, PREVIOUS_ASSETS_RECORD);
40361
40449
  await mkdir2(dirname2(recordPath), { recursive: true });
40362
40450
  await writeFile2(recordPath, `${JSON.stringify({ releases: record }, null, 2)}
40363
40451
  `);
@@ -40378,7 +40466,7 @@ async function copySiblings(source, target) {
40378
40466
  async function readRecord(clientDir) {
40379
40467
  let raw;
40380
40468
  try {
40381
- raw = await readFile(join4(clientDir, PREVIOUS_ASSETS_RECORD), "utf8");
40469
+ raw = await readFile(join6(clientDir, PREVIOUS_ASSETS_RECORD), "utf8");
40382
40470
  } catch (error) {
40383
40471
  if (error?.code === "ENOENT") {
40384
40472
  return [];
@@ -40393,7 +40481,7 @@ async function readRecord(clientDir) {
40393
40481
  }
40394
40482
  async function listFiles(root, dir) {
40395
40483
  const files = [];
40396
- const entries = (await readdir(join4(root, dir), { withFileTypes: true })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
40484
+ const entries = (await readdir(join6(root, dir), { withFileTypes: true })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
40397
40485
  for (const entry of entries) {
40398
40486
  const path3 = `${dir}/${entry.name}`;
40399
40487
  if (entry.isDirectory()) {
@@ -40409,7 +40497,7 @@ function isCarriable(file) {
40409
40497
  }
40410
40498
  function inside(root, file) {
40411
40499
  const path3 = resolve(root, file);
40412
- const rel2 = relative2(root, path3);
40500
+ const rel2 = relative3(root, path3);
40413
40501
  return rel2 && !rel2.startsWith("..") && !isAbsolute(rel2) && rel2.split(sep2)[0] === ASSETS_DIR ? path3 : null;
40414
40502
  }
40415
40503
  async function isDirectory(path3) {
@@ -40438,7 +40526,7 @@ async function exists(path3) {
40438
40526
  // vite/precompressAssets.ts
40439
40527
  import { mkdir as mkdir3, readFile as readFile2, stat as stat2, writeFile as writeFile3 } from "fs/promises";
40440
40528
  import { availableParallelism } from "os";
40441
- import { dirname as dirname3, join as join5 } from "path";
40529
+ import { dirname as dirname3, join as join7 } from "path";
40442
40530
  import { promisify } from "util";
40443
40531
  import { brotliCompress, constants, gzip } from "zlib";
40444
40532
  var STATIC_ASSETS_RECORD = ".vite/static-assets.json";
@@ -40493,7 +40581,7 @@ async function precompressAssets(clientDir, files, options = {}) {
40493
40581
  if (!isPrecompressible(file)) {
40494
40582
  return;
40495
40583
  }
40496
- const path3 = join5(clientDir, file);
40584
+ const path3 = join7(clientDir, file);
40497
40585
  const size = await fileSize(path3);
40498
40586
  if (size === null || size < minBytes) {
40499
40587
  return;
@@ -40537,7 +40625,7 @@ async function precompressAssets(clientDir, files, options = {}) {
40537
40625
  return { record, stats };
40538
40626
  }
40539
40627
  async function writeStaticAssetsRecord(clientDir, record) {
40540
- const path3 = join5(clientDir, STATIC_ASSETS_RECORD);
40628
+ const path3 = join7(clientDir, STATIC_ASSETS_RECORD);
40541
40629
  await mkdir3(dirname3(path3), { recursive: true });
40542
40630
  const files = Object.fromEntries(Object.entries(record.files).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
40543
40631
  await writeFile3(path3, `${JSON.stringify({ files }, null, 2)}
@@ -40563,45 +40651,6 @@ var {
40563
40651
  // bin/check-models.ts
40564
40652
  import { statSync as statSync2 } from "fs";
40565
40653
  import { relative as relative4, resolve as resolve2 } from "path";
40566
-
40567
- // support/discover.ts
40568
- import { existsSync as existsSync3, readdirSync as readdirSync2 } from "fs";
40569
- import { join as join6, relative as relative3 } from "path";
40570
- function sourceFiles(dir, ignore = []) {
40571
- const out = [];
40572
- const ignored = (path3) => {
40573
- const rel2 = relative3(dir, path3).split("\\").join("/");
40574
- return ignore.some((pattern) => rel2 === pattern || rel2.startsWith(`${pattern}/`));
40575
- };
40576
- const walk3 = (current) => {
40577
- for (const entry of readdirSync2(current, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
40578
- const path3 = join6(current, entry.name);
40579
- if (ignored(path3))
40580
- continue;
40581
- if (entry.isDirectory()) {
40582
- if (entry.name.startsWith(".") || entry.name === "node_modules")
40583
- continue;
40584
- if (existsSync3(join6(path3, "package.json")))
40585
- continue;
40586
- walk3(path3);
40587
- continue;
40588
- }
40589
- if (!entry.name.endsWith(".ts") && !entry.name.endsWith(".tsx"))
40590
- continue;
40591
- if (entry.name.endsWith(".d.ts"))
40592
- continue;
40593
- if (/\.(test|test-d|spec|bench)\.tsx?$/.test(entry.name))
40594
- continue;
40595
- out.push(path3);
40596
- }
40597
- };
40598
- if (!existsSync3(dir))
40599
- return out;
40600
- walk3(dir);
40601
- return out;
40602
- }
40603
-
40604
- // bin/check-models.ts
40605
40654
  function modelFiles(dir, ignore = []) {
40606
40655
  return sourceFiles(dir, ignore);
40607
40656
  }
@@ -40777,8 +40826,8 @@ function indent(message) {
40777
40826
 
40778
40827
  // bin/ide/generateApiManifest.ts
40779
40828
  var import_recast2 = __toESM(require_main2(), 1);
40780
- import { join as join7 } from "path";
40781
- import { existsSync as existsSync4 } from "fs";
40829
+ import { join as join8 } from "path";
40830
+ import { existsSync as existsSync5 } from "fs";
40782
40831
 
40783
40832
  // utils/toCamelCase.ts
40784
40833
  function toCamelCase(input) {
@@ -40829,7 +40878,7 @@ class ApiManifestGenerator {
40829
40878
  rootRouterBody;
40830
40879
  routerBodyCache = new Map;
40831
40880
  controllerCache = new Map;
40832
- manifestCacheDir = join7(ROOT, ".gemi/cache/api-routes-manifest");
40881
+ manifestCacheDir = join8(ROOT, ".gemi/cache/api-routes-manifest");
40833
40882
  async writeManifest(cacheFilePath) {
40834
40883
  const manifest = {};
40835
40884
  for (const [routeName, method] of this.routes.entries()) {
@@ -40861,7 +40910,7 @@ class ApiManifestGenerator {
40861
40910
  if (path4.startsWith("@/app")) {
40862
40911
  return path4.replace("@", "") + ".ts";
40863
40912
  }
40864
- return join7(parentPath, path4) + ".ts";
40913
+ return join8(parentPath, path4) + ".ts";
40865
40914
  }
40866
40915
  isFileShouldBeParsed(path4) {
40867
40916
  return path4.includes("app/http/router") || path4.includes("app/http/controllers");
@@ -40909,7 +40958,7 @@ class ApiManifestGenerator {
40909
40958
  if (normalizedPath.startsWith("/app/http/controllers")) {
40910
40959
  for (const specifier of node.specifiers) {
40911
40960
  const name = specifier.type === "ImportDefaultSpecifier" ? specifier.local.name : specifier.imported.name;
40912
- await this.parseControllerFile(await this.parseFile(join7(ROOT, normalizedPath)), name, normalizedPath);
40961
+ await this.parseControllerFile(await this.parseFile(join8(ROOT, normalizedPath)), name, normalizedPath);
40913
40962
  }
40914
40963
  }
40915
40964
  if (normalizedPath.startsWith("/app/http/routes")) {
@@ -41013,7 +41062,7 @@ class ApiManifestGenerator {
41013
41062
  }
41014
41063
  async parse(cacheFilePath, filePath, isRoot = true, name = "") {
41015
41064
  console.log({ ROOT, filePath });
41016
- const file = await this.parseFile(join7(ROOT, filePath));
41065
+ const file = await this.parseFile(join8(ROOT, filePath));
41017
41066
  for (const body of file.program.body) {
41018
41067
  if (!this.isNodeShouldBeParsed(body))
41019
41068
  continue;
@@ -41049,8 +41098,8 @@ class ApiManifestGenerator {
41049
41098
  }
41050
41099
  async run(filePath) {
41051
41100
  const cacheId = generateGitDiffId();
41052
- const cacheFilePath = join7(this.manifestCacheDir, `${cacheId}.json`);
41053
- if (existsSync4(cacheFilePath)) {
41101
+ const cacheFilePath = join8(this.manifestCacheDir, `${cacheId}.json`);
41102
+ if (existsSync5(cacheFilePath)) {
41054
41103
  console.log(await Bun.file(cacheFilePath).text());
41055
41104
  } else {
41056
41105
  await this.parse(cacheFilePath, filePath, true);
@@ -41059,7 +41108,7 @@ class ApiManifestGenerator {
41059
41108
  }
41060
41109
 
41061
41110
  // bin/version.ts
41062
- import { existsSync as existsSync5, readFileSync as readFileSync2 } from "fs";
41111
+ import { existsSync as existsSync6, readFileSync as readFileSync3 } from "fs";
41063
41112
  import path4 from "path";
41064
41113
  var VERSION_RE = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
41065
41114
  function parseVersion(version) {
@@ -41117,7 +41166,7 @@ function findGemiPackageDir(rootDir) {
41117
41166
  let dir = path4.resolve(rootDir);
41118
41167
  while (true) {
41119
41168
  const candidate = path4.join(dir, "node_modules", "gemi");
41120
- if (existsSync5(path4.join(candidate, "package.json")))
41169
+ if (existsSync6(path4.join(candidate, "package.json")))
41121
41170
  return candidate;
41122
41171
  const parent = path4.dirname(dir);
41123
41172
  if (parent === dir)
@@ -41130,7 +41179,7 @@ function readInstalledVersion(rootDir) {
41130
41179
  if (!packageDir)
41131
41180
  return null;
41132
41181
  try {
41133
- const manifest = JSON.parse(readFileSync2(path4.join(packageDir, "package.json"), "utf8"));
41182
+ const manifest = JSON.parse(readFileSync3(path4.join(packageDir, "package.json"), "utf8"));
41134
41183
  return typeof manifest?.version === "string" ? manifest.version : null;
41135
41184
  } catch {
41136
41185
  return null;
@@ -41226,16 +41275,16 @@ function reportUpdate(options, log = console.log) {
41226
41275
  }
41227
41276
 
41228
41277
  // bin/upgrade.ts
41229
- import { existsSync as existsSync7, readFileSync as readFileSync4 } from "fs";
41278
+ import { existsSync as existsSync8, readFileSync as readFileSync5 } from "fs";
41230
41279
  import path6 from "path";
41231
41280
 
41232
41281
  // bin/install-skill.ts
41233
41282
  import { createHash as createHash2 } from "crypto";
41234
41283
  import {
41235
41284
  cpSync,
41236
- existsSync as existsSync6,
41285
+ existsSync as existsSync7,
41237
41286
  mkdirSync as mkdirSync2,
41238
- readFileSync as readFileSync3,
41287
+ readFileSync as readFileSync4,
41239
41288
  readdirSync as readdirSync3,
41240
41289
  renameSync,
41241
41290
  rmSync as rmSync2,
@@ -41253,7 +41302,7 @@ function lockPath(rootDir) {
41253
41302
  return path5.join(rootDir, ".agents", ".skill-lock.json");
41254
41303
  }
41255
41304
  function isSkillInstalled(rootDir) {
41256
- return existsSync6(path5.join(skillTargetDir(rootDir), "SKILL.md"));
41305
+ return existsSync7(path5.join(skillTargetDir(rootDir), "SKILL.md"));
41257
41306
  }
41258
41307
  function hashDirectory(dir) {
41259
41308
  const hash = createHash2("sha1");
@@ -41267,7 +41316,7 @@ function hashDirectory(dir) {
41267
41316
  } else if (entry.isFile()) {
41268
41317
  hash.update(relative5);
41269
41318
  hash.update("\x00");
41270
- hash.update(readFileSync3(full));
41319
+ hash.update(readFileSync4(full));
41271
41320
  hash.update("\x00");
41272
41321
  }
41273
41322
  }
@@ -41278,10 +41327,10 @@ function hashDirectory(dir) {
41278
41327
  function readLock(rootDir) {
41279
41328
  const empty = { version: 3, skills: {} };
41280
41329
  const file = lockPath(rootDir);
41281
- if (!existsSync6(file))
41330
+ if (!existsSync7(file))
41282
41331
  return empty;
41283
41332
  try {
41284
- const parsed = JSON.parse(readFileSync3(file, "utf8"));
41333
+ const parsed = JSON.parse(readFileSync4(file, "utf8"));
41285
41334
  if (!parsed || typeof parsed !== "object")
41286
41335
  return empty;
41287
41336
  return {
@@ -41300,10 +41349,10 @@ function writeLock(rootDir, lock) {
41300
41349
  }
41301
41350
  function quarantineUnreadableLock(rootDir) {
41302
41351
  const file = lockPath(rootDir);
41303
- if (!existsSync6(file))
41352
+ if (!existsSync7(file))
41304
41353
  return null;
41305
41354
  try {
41306
- const parsed = JSON.parse(readFileSync3(file, "utf8"));
41355
+ const parsed = JSON.parse(readFileSync4(file, "utf8"));
41307
41356
  if (parsed && typeof parsed === "object")
41308
41357
  return null;
41309
41358
  } catch {}
@@ -41337,14 +41386,14 @@ function install(options) {
41337
41386
  return 1;
41338
41387
  }
41339
41388
  const source = skillSourceDir(packageDir);
41340
- if (!existsSync6(path5.join(source, "SKILL.md"))) {
41389
+ if (!existsSync7(path5.join(source, "SKILL.md"))) {
41341
41390
  error(`The installed gemi does not ship the \`${SKILL_NAME}\` skill (looked in ` + `${source}). It was added in a later release \u2014 run \`gemi upgrade\` first.`);
41342
41391
  return 1;
41343
41392
  }
41344
41393
  const target = skillTargetDir(rootDir);
41345
41394
  const lock = readLock(rootDir);
41346
41395
  const recorded = lock.skills[SKILL_NAME];
41347
- const existing = existsSync6(target) ? hashDirectory(target) : null;
41396
+ const existing = existsSync7(target) ? hashDirectory(target) : null;
41348
41397
  if (existing !== null && !force) {
41349
41398
  if (!recorded) {
41350
41399
  error(`${path5.relative(rootDir, target) || target} already exists and was not ` + `installed by \`gemi install-skill\`. Re-run with --force to replace it.`);
@@ -41402,7 +41451,7 @@ function detectPackageManager(rootDir) {
41402
41451
  let dir = path6.resolve(rootDir);
41403
41452
  while (true) {
41404
41453
  for (const [manager, files] of LOCKFILES) {
41405
- if (files.some((file) => existsSync7(path6.join(dir, file))))
41454
+ if (files.some((file) => existsSync8(path6.join(dir, file))))
41406
41455
  return manager;
41407
41456
  }
41408
41457
  const parent = path6.dirname(dir);
@@ -41413,10 +41462,10 @@ function detectPackageManager(rootDir) {
41413
41462
  }
41414
41463
  function dependencyKind(dir) {
41415
41464
  const manifestPath = path6.join(dir, "package.json");
41416
- if (!existsSync7(manifestPath))
41465
+ if (!existsSync8(manifestPath))
41417
41466
  return null;
41418
41467
  try {
41419
- const manifest = JSON.parse(readFileSync4(manifestPath, "utf8"));
41468
+ const manifest = JSON.parse(readFileSync5(manifestPath, "utf8"));
41420
41469
  if (manifest?.dependencies?.gemi)
41421
41470
  return "dependencies";
41422
41471
  if (manifest?.devDependencies?.gemi)
@@ -41442,7 +41491,7 @@ function findDeclaringDir(rootDir) {
41442
41491
  }
41443
41492
  function isWorkspaceRoot(dir) {
41444
41493
  try {
41445
- const manifest = JSON.parse(readFileSync4(path6.join(dir, "package.json"), "utf8"));
41494
+ const manifest = JSON.parse(readFileSync5(path6.join(dir, "package.json"), "utf8"));
41446
41495
  return manifest?.workspaces !== undefined;
41447
41496
  } catch {
41448
41497
  return false;
@@ -41574,12 +41623,12 @@ function exitCodeOf(proc) {
41574
41623
 
41575
41624
  // stats/run.ts
41576
41625
  import path7 from "path";
41577
- import { existsSync as existsSync9, mkdtempSync, readFileSync as readFileSync6, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "fs";
41626
+ import { existsSync as existsSync10, mkdtempSync, readFileSync as readFileSync7, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "fs";
41578
41627
  import { tmpdir } from "os";
41579
41628
 
41580
41629
  // stats/bundleStats.ts
41581
- import { existsSync as existsSync8, readFileSync as readFileSync5, statSync as statSync3 } from "fs";
41582
- import { join as join8 } from "path";
41630
+ import { existsSync as existsSync9, readFileSync as readFileSync6, statSync as statSync3 } from "fs";
41631
+ import { join as join9 } from "path";
41583
41632
  import { brotliCompressSync, constants as constants3, gzipSync } from "zlib";
41584
41633
 
41585
41634
  // internal/staticNavigationRuntime.ts
@@ -41606,7 +41655,7 @@ function routeKey(entry) {
41606
41655
  }
41607
41656
  function bundleStats(options) {
41608
41657
  const { clientDir } = options;
41609
- const manifest = options.manifest ?? JSON.parse(readFileSync5(join8(clientDir, ".vite/manifest.json"), "utf8"));
41658
+ const manifest = options.manifest ?? JSON.parse(readFileSync6(join9(clientDir, ".vite/manifest.json"), "utf8"));
41610
41659
  const sizes = new Map;
41611
41660
  const size = (file) => {
41612
41661
  let known = sizes.get(file);
@@ -41735,10 +41784,10 @@ function isJs(file) {
41735
41784
  return /\.m?js$/.test(file);
41736
41785
  }
41737
41786
  function measure(clientDir, file) {
41738
- const path7 = join8(clientDir, file);
41739
- const sibling = (ext) => existsSync8(path7 + ext) ? statSync3(path7 + ext).size : null;
41787
+ const path7 = join9(clientDir, file);
41788
+ const sibling = (ext) => existsSync9(path7 + ext) ? statSync3(path7 + ext).size : null;
41740
41789
  let buffer;
41741
- const read = () => buffer ??= readFileSync5(path7);
41790
+ const read = () => buffer ??= readFileSync6(path7);
41742
41791
  return {
41743
41792
  raw: statSync3(path7).size,
41744
41793
  gzip: sibling(".gz") ?? gzipSync(read(), { level: 9 }).length,
@@ -41855,7 +41904,7 @@ async function runStats(options) {
41855
41904
  const log = options.log ?? console.log;
41856
41905
  const error = options.error ?? console.error;
41857
41906
  const clientDir = path7.join(options.rootDir, "dist", "client");
41858
- if (!existsSync9(path7.join(clientDir, ".vite/manifest.json"))) {
41907
+ if (!existsSync10(path7.join(clientDir, ".vite/manifest.json"))) {
41859
41908
  error(`No client build in ${clientDir}. Run \`gemi build\` first.`);
41860
41909
  return 1;
41861
41910
  }
@@ -41876,7 +41925,7 @@ ${table.message}`);
41876
41925
  `);
41877
41926
  }
41878
41927
  if (options.markdown) {
41879
- const base = options.base && existsSync9(options.base) ? JSON.parse(readFileSync6(options.base, "utf8")) : null;
41928
+ const base = options.base && existsSync10(options.base) ? JSON.parse(readFileSync7(options.base, "utf8")) : null;
41880
41929
  writeFileSync3(options.markdown, `${markdownReport(stats, base, budgets)}
41881
41930
  `);
41882
41931
  }
@@ -41921,13 +41970,13 @@ async function loadRouteTable(rootDir, preloadArgs, options = {}) {
41921
41970
  if (timedOut) {
41922
41971
  return { ok: false, message: `reading the route table took over ${timeoutMs / 1000}s.` };
41923
41972
  }
41924
- if (code !== 0 || !existsSync9(out)) {
41973
+ if (code !== 0 || !existsSync10(out)) {
41925
41974
  return {
41926
41975
  ok: false,
41927
41976
  message: stderr.trim() || `the route table process exited with ${code}.`
41928
41977
  };
41929
41978
  }
41930
- return { ok: true, routes: JSON.parse(readFileSync6(out, "utf8")) };
41979
+ return { ok: true, routes: JSON.parse(readFileSync7(out, "utf8")) };
41931
41980
  } finally {
41932
41981
  rmSync3(dir, { recursive: true, force: true });
41933
41982
  }
@@ -41936,7 +41985,7 @@ async function loadRouteTable(rootDir, preloadArgs, options = {}) {
41936
41985
  // bin/gemi.ts
41937
41986
  function appPreloadArgs(appDir) {
41938
41987
  const preloadPath = path10.join(appDir, "preload.ts");
41939
- return existsSync10(preloadPath) ? ["--preload", preloadPath] : [];
41988
+ return existsSync11(preloadPath) ? ["--preload", preloadPath] : [];
41940
41989
  }
41941
41990
  program.command("dev").action(async () => {
41942
41991
  console.log("Starting dev server...");
@@ -42057,6 +42106,11 @@ withStatsOptions(program.command("build").option("--stats", "After building, pri
42057
42106
  console.error(message);
42058
42107
  process.exit(1);
42059
42108
  }
42109
+ const documentScripts = await bundleDocumentScripts(appDir);
42110
+ await Bun.write(path10.join(rootDir, "dist", "server", DOCUMENT_SCRIPTS_MANIFEST), JSON.stringify(documentScripts));
42111
+ if (Object.keys(documentScripts).length > 0) {
42112
+ console.log(`Bundled ${Object.keys(documentScripts).length} document script(s).`);
42113
+ }
42060
42114
  if (options.stats || options.json || options.markdown) {
42061
42115
  console.log("");
42062
42116
  process.exit(await printStats(rootDir, options));
@@ -42194,5 +42248,5 @@ program.command("app:route-manifest").action(async () => {
42194
42248
  });
42195
42249
  program.parse();
42196
42250
 
42197
- //# debugId=03530C1B32FDF39064756E2164756E21
42251
+ //# debugId=217A9B3D9A15D57264756E2164756E21
42198
42252
  //# sourceMappingURL=gemi.js.map