gemi 0.240.0 → 0.242.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 (236) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/ai/index.js.map +1 -1
  3. package/dist/ai/testing/index.js +2 -2
  4. package/dist/ai/testing/index.js.map +1 -1
  5. package/dist/app/index.js +1 -1
  6. package/dist/bun/plugin.js +1 -1
  7. package/dist/bun/preload.js +1 -1
  8. package/dist/chunk-093j5rh8.js +5 -0
  9. package/dist/{chunk-j3zz8046.js.map → chunk-093j5rh8.js.map} +3 -3
  10. package/dist/{chunk-bvgcv0jx.js → chunk-0jmh2271.js} +2 -2
  11. package/dist/{chunk-bvgcv0jx.js.map → chunk-0jmh2271.js.map} +1 -1
  12. package/dist/{chunk-7azdbwdc.js → chunk-0sr3cfex.js} +2 -2
  13. package/dist/{chunk-7azdbwdc.js.map → chunk-0sr3cfex.js.map} +1 -1
  14. package/dist/{chunk-etj63p4p.js → chunk-0tsnmrf9.js} +2 -2
  15. package/dist/{chunk-etj63p4p.js.map → chunk-0tsnmrf9.js.map} +1 -1
  16. package/dist/{chunk-0xmk4jyj.js → chunk-110ecy3e.js} +2 -2
  17. package/dist/{chunk-0xmk4jyj.js.map → chunk-110ecy3e.js.map} +1 -1
  18. package/dist/{chunk-samm4h7d.js → chunk-11hmhyk5.js} +2 -2
  19. package/dist/{chunk-samm4h7d.js.map → chunk-11hmhyk5.js.map} +1 -1
  20. package/dist/{chunk-8wvh099n.js → chunk-26pfh03x.js} +3 -3
  21. package/dist/{chunk-8wvh099n.js.map → chunk-26pfh03x.js.map} +1 -1
  22. package/dist/{chunk-51mz612v.js → chunk-27f9z8yk.js} +2 -2
  23. package/dist/{chunk-51mz612v.js.map → chunk-27f9z8yk.js.map} +1 -1
  24. package/dist/{chunk-3mq0wmq7.js → chunk-2g6cmkrn.js} +3 -3
  25. package/dist/{chunk-3mq0wmq7.js.map → chunk-2g6cmkrn.js.map} +1 -1
  26. package/dist/{chunk-4mysb5ej.js → chunk-2yvzc5tq.js} +2 -2
  27. package/dist/{chunk-4mysb5ej.js.map → chunk-2yvzc5tq.js.map} +1 -1
  28. package/dist/{chunk-vk1x3rsw.js → chunk-3tpj5t10.js} +2 -2
  29. package/dist/{chunk-vk1x3rsw.js.map → chunk-3tpj5t10.js.map} +1 -1
  30. package/dist/{chunk-vqmy8jfr.js → chunk-3ywtqcxt.js} +2 -2
  31. package/dist/{chunk-vqmy8jfr.js.map → chunk-3ywtqcxt.js.map} +1 -1
  32. package/dist/{chunk-3kgp6xka.js → chunk-4f8qpzsw.js} +1 -1
  33. package/dist/{chunk-qb8pjdez.js → chunk-4y0j6c56.js} +4 -4
  34. package/dist/{chunk-qb8pjdez.js.map → chunk-4y0j6c56.js.map} +1 -1
  35. package/dist/{chunk-e4adgvd6.js → chunk-54v3y7mg.js} +3 -3
  36. package/dist/{chunk-e4adgvd6.js.map → chunk-54v3y7mg.js.map} +1 -1
  37. package/dist/{chunk-fec4qnr3.js → chunk-57n0m9fv.js} +2 -2
  38. package/dist/{chunk-fec4qnr3.js.map → chunk-57n0m9fv.js.map} +1 -1
  39. package/dist/{chunk-vvq18rrr.js → chunk-5pfbqc1c.js} +2 -2
  40. package/dist/{chunk-vvq18rrr.js.map → chunk-5pfbqc1c.js.map} +1 -1
  41. package/dist/{chunk-2g1h9ktj.js → chunk-632nqkza.js} +2 -2
  42. package/dist/{chunk-2g1h9ktj.js.map → chunk-632nqkza.js.map} +1 -1
  43. package/dist/{chunk-kabkxq5q.js → chunk-646bqwp8.js} +2 -2
  44. package/dist/{chunk-kabkxq5q.js.map → chunk-646bqwp8.js.map} +1 -1
  45. package/dist/{chunk-3qmhe96e.js → chunk-65m459jb.js} +2 -2
  46. package/dist/{chunk-3qmhe96e.js.map → chunk-65m459jb.js.map} +1 -1
  47. package/dist/{chunk-3crknzwp.js → chunk-7c48nxqb.js} +3 -3
  48. package/dist/{chunk-3crknzwp.js.map → chunk-7c48nxqb.js.map} +1 -1
  49. package/dist/{chunk-wefcda84.js → chunk-7gqq3834.js} +2 -2
  50. package/dist/{chunk-wefcda84.js.map → chunk-7gqq3834.js.map} +1 -1
  51. package/dist/{chunk-feh44g4f.js → chunk-7mxwstm2.js} +2 -2
  52. package/dist/{chunk-feh44g4f.js.map → chunk-7mxwstm2.js.map} +1 -1
  53. package/dist/{chunk-gykwq8py.js → chunk-7qt9pxm6.js} +1 -1
  54. package/dist/{chunk-c7hbdsjv.js → chunk-7ztbpqed.js} +2 -2
  55. package/dist/{chunk-3ady4k66.js.map → chunk-7ztbpqed.js.map} +1 -1
  56. package/dist/chunk-8dga75cv.js +5 -0
  57. package/dist/{chunk-by0ydsqs.js.map → chunk-8dga75cv.js.map} +1 -1
  58. package/dist/{chunk-zsmwmg8x.js → chunk-9cxs1q57.js} +2 -2
  59. package/dist/{chunk-zsmwmg8x.js.map → chunk-9cxs1q57.js.map} +1 -1
  60. package/dist/{chunk-387fpg2k.js → chunk-9xm5z33t.js} +2 -2
  61. package/dist/{chunk-387fpg2k.js.map → chunk-9xm5z33t.js.map} +1 -1
  62. package/dist/{chunk-gpngw61t.js → chunk-ac135mmf.js} +2 -2
  63. package/dist/{chunk-gpngw61t.js.map → chunk-ac135mmf.js.map} +1 -1
  64. package/dist/{chunk-z0jf5kzx.js → chunk-bbhrs7s3.js} +2 -2
  65. package/dist/{chunk-z0jf5kzx.js.map → chunk-bbhrs7s3.js.map} +1 -1
  66. package/dist/{chunk-vq1q8mgm.js → chunk-bsmy8vqs.js} +2 -2
  67. package/dist/{chunk-vq1q8mgm.js.map → chunk-bsmy8vqs.js.map} +1 -1
  68. package/dist/{chunk-t495wyhh.js → chunk-c0hxmw3a.js} +2 -2
  69. package/dist/{chunk-t495wyhh.js.map → chunk-c0hxmw3a.js.map} +1 -1
  70. package/dist/{chunk-c3c37k46.js → chunk-d39h1mrz.js} +3 -3
  71. package/dist/{chunk-c3c37k46.js.map → chunk-d39h1mrz.js.map} +1 -1
  72. package/dist/{chunk-q8pr18w6.js → chunk-daw2xr2v.js} +4 -4
  73. package/dist/{chunk-q8pr18w6.js.map → chunk-daw2xr2v.js.map} +1 -1
  74. package/dist/{chunk-3rm4v7ht.js → chunk-dfat5nmk.js} +3 -3
  75. package/dist/{chunk-3rm4v7ht.js.map → chunk-dfat5nmk.js.map} +1 -1
  76. package/dist/{chunk-9a3wbbr6.js → chunk-e0e43wvq.js} +2 -2
  77. package/dist/{chunk-9a3wbbr6.js.map → chunk-e0e43wvq.js.map} +1 -1
  78. package/dist/{chunk-re13gf4s.js → chunk-e3m0anq1.js} +3 -3
  79. package/dist/{chunk-re13gf4s.js.map → chunk-e3m0anq1.js.map} +1 -1
  80. package/dist/{chunk-rpwvwsq9.js → chunk-e4a6smfv.js} +1 -1
  81. package/dist/{chunk-4wj4bwvc.js → chunk-eb4mx34p.js} +3 -3
  82. package/dist/{chunk-4wj4bwvc.js.map → chunk-eb4mx34p.js.map} +1 -1
  83. package/dist/{chunk-qkfd84hx.js → chunk-ed64ynex.js} +2 -2
  84. package/dist/{chunk-qkfd84hx.js.map → chunk-ed64ynex.js.map} +1 -1
  85. package/dist/chunk-evx7nxad.js +10 -0
  86. package/dist/{chunk-rftxm3ny.js.map → chunk-evx7nxad.js.map} +4 -4
  87. package/dist/{chunk-z6gwn4xf.js → chunk-fb3qkmwh.js} +2 -2
  88. package/dist/{chunk-z6gwn4xf.js.map → chunk-fb3qkmwh.js.map} +1 -1
  89. package/dist/{chunk-9fgyanab.js → chunk-fjh3xaq7.js} +2 -2
  90. package/dist/{chunk-9fgyanab.js.map → chunk-fjh3xaq7.js.map} +1 -1
  91. package/dist/{chunk-kgbgj7v4.js → chunk-fs2cdxry.js} +2 -2
  92. package/dist/{chunk-kgbgj7v4.js.map → chunk-fs2cdxry.js.map} +1 -1
  93. package/dist/{chunk-bhycdjcv.js → chunk-fy4142fv.js} +2 -2
  94. package/dist/{chunk-bhycdjcv.js.map → chunk-fy4142fv.js.map} +1 -1
  95. package/dist/{chunk-342ydn4n.js → chunk-ge5m9qdt.js} +2 -2
  96. package/dist/{chunk-342ydn4n.js.map → chunk-ge5m9qdt.js.map} +1 -1
  97. package/dist/{chunk-7fh7cfjh.js → chunk-gqw25apr.js} +2 -2
  98. package/dist/{chunk-7fh7cfjh.js.map → chunk-gqw25apr.js.map} +1 -1
  99. package/dist/{chunk-wkw8afk0.js → chunk-h6dzn5j6.js} +2 -2
  100. package/dist/{chunk-wkw8afk0.js.map → chunk-h6dzn5j6.js.map} +1 -1
  101. package/dist/{chunk-x68jra5n.js → chunk-hhaxacwh.js} +2 -2
  102. package/dist/{chunk-x68jra5n.js.map → chunk-hhaxacwh.js.map} +1 -1
  103. package/dist/{chunk-a8q7ds6w.js → chunk-hvw25pe3.js} +1 -1
  104. package/dist/{chunk-6wv3k8ap.js → chunk-jr53em8y.js} +2 -2
  105. package/dist/{chunk-6wv3k8ap.js.map → chunk-jr53em8y.js.map} +1 -1
  106. package/dist/{chunk-gs8fvb6a.js → chunk-kejexfsg.js} +2 -2
  107. package/dist/{chunk-gs8fvb6a.js.map → chunk-kejexfsg.js.map} +1 -1
  108. package/dist/{chunk-rc86ewq1.js → chunk-kjz6jh54.js} +3 -3
  109. package/dist/{chunk-rc86ewq1.js.map → chunk-kjz6jh54.js.map} +1 -1
  110. package/dist/{chunk-7sxbq483.js → chunk-mjfnv2r9.js} +2 -2
  111. package/dist/{chunk-7sxbq483.js.map → chunk-mjfnv2r9.js.map} +1 -1
  112. package/dist/{chunk-7ycjs0xn.js → chunk-n537kc55.js} +2 -2
  113. package/dist/{chunk-7ycjs0xn.js.map → chunk-n537kc55.js.map} +1 -1
  114. package/dist/{chunk-8e14zcdc.js → chunk-n8cm2sw6.js} +2 -2
  115. package/dist/{chunk-8e14zcdc.js.map → chunk-n8cm2sw6.js.map} +1 -1
  116. package/dist/{chunk-13eq76tw.js → chunk-p03jdwc1.js} +2 -2
  117. package/dist/{chunk-13eq76tw.js.map → chunk-p03jdwc1.js.map} +1 -1
  118. package/dist/{chunk-aczp96k5.js → chunk-rffa9x3d.js} +2 -2
  119. package/dist/{chunk-aczp96k5.js.map → chunk-rffa9x3d.js.map} +1 -1
  120. package/dist/{chunk-1wfwqgm5.js → chunk-rwyn40p1.js} +2 -2
  121. package/dist/{chunk-1wfwqgm5.js.map → chunk-rwyn40p1.js.map} +1 -1
  122. package/dist/{chunk-gxre6wnc.js → chunk-s0azv6dd.js} +2 -2
  123. package/dist/{chunk-gxre6wnc.js.map → chunk-s0azv6dd.js.map} +1 -1
  124. package/dist/{chunk-1kjyhseb.js → chunk-sew755q5.js} +1 -1
  125. package/dist/{chunk-wgb26e02.js → chunk-sp79baph.js} +2 -2
  126. package/dist/{chunk-wgb26e02.js.map → chunk-sp79baph.js.map} +1 -1
  127. package/dist/{chunk-g9q39z7t.js → chunk-ss0gk90s.js} +2 -2
  128. package/dist/{chunk-g9q39z7t.js.map → chunk-ss0gk90s.js.map} +1 -1
  129. package/dist/{chunk-4sv5vkab.js → chunk-t4eeg7j1.js} +3 -3
  130. package/dist/{chunk-4sv5vkab.js.map → chunk-t4eeg7j1.js.map} +1 -1
  131. package/dist/{chunk-wjjxqw9b.js → chunk-t67dbfqs.js} +3 -3
  132. package/dist/{chunk-wjjxqw9b.js.map → chunk-t67dbfqs.js.map} +1 -1
  133. package/dist/{chunk-58xb0s71.js → chunk-t77xnb8k.js} +2 -2
  134. package/dist/{chunk-58xb0s71.js.map → chunk-t77xnb8k.js.map} +1 -1
  135. package/dist/{chunk-3ady4k66.js → chunk-tws22txn.js} +2 -2
  136. package/dist/{chunk-c7hbdsjv.js.map → chunk-tws22txn.js.map} +1 -1
  137. package/dist/{chunk-ccymw1ed.js → chunk-v3ddktnq.js} +3 -3
  138. package/dist/{chunk-ccymw1ed.js.map → chunk-v3ddktnq.js.map} +1 -1
  139. package/dist/chunk-vh6vc4h1.js +596 -0
  140. package/dist/{chunk-6gek696n.js.map → chunk-vh6vc4h1.js.map} +7 -6
  141. package/dist/{chunk-tvb68dqg.js → chunk-vqtzwnwr.js} +2 -2
  142. package/dist/{chunk-tvb68dqg.js.map → chunk-vqtzwnwr.js.map} +1 -1
  143. package/dist/{chunk-rreb2k19.js → chunk-wac3gv1t.js} +2 -2
  144. package/dist/{chunk-rreb2k19.js.map → chunk-wac3gv1t.js.map} +1 -1
  145. package/dist/{chunk-gjpwvet7.js → chunk-xt4ssej8.js} +2 -2
  146. package/dist/{chunk-gjpwvet7.js.map → chunk-xt4ssej8.js.map} +1 -1
  147. package/dist/{chunk-p0dgpm5r.js → chunk-xvnjahea.js} +2 -2
  148. package/dist/{chunk-p0dgpm5r.js.map → chunk-xvnjahea.js.map} +1 -1
  149. package/dist/{chunk-cjwjrk12.js → chunk-xy5evkaz.js} +1 -1
  150. package/dist/{chunk-vcmwp7pv.js → chunk-ye1kbxkx.js} +3 -3
  151. package/dist/{chunk-vcmwp7pv.js.map → chunk-ye1kbxkx.js.map} +1 -1
  152. package/dist/{chunk-ff8rtz9h.js → chunk-yqsnrp2b.js} +2 -2
  153. package/dist/{chunk-ff8rtz9h.js.map → chunk-yqsnrp2b.js.map} +1 -1
  154. package/dist/{chunk-0wa8ztk5.js → chunk-yrna0ajq.js} +3 -3
  155. package/dist/{chunk-0wa8ztk5.js.map → chunk-yrna0ajq.js.map} +1 -1
  156. package/dist/{chunk-768yza4f.js → chunk-zpnxr23b.js} +2 -2
  157. package/dist/{chunk-768yza4f.js.map → chunk-zpnxr23b.js.map} +1 -1
  158. package/dist/{chunk-agpty0p6.js → chunk-zrqqnfrs.js} +2 -2
  159. package/dist/{chunk-agpty0p6.js.map → chunk-zrqqnfrs.js.map} +1 -1
  160. package/dist/chunks/{RealtimeClient-DRVodyn1.js → RealtimeClient-Di8ozsFv.js} +2 -2
  161. package/dist/chunks/{RealtimeClient-DRVodyn1.js.map → RealtimeClient-Di8ozsFv.js.map} +1 -1
  162. package/dist/chunks/{ThemeProvider-1WtAS7dH.js → ThemeProvider-wwhaAveo.js} +28 -9
  163. package/dist/chunks/ThemeProvider-wwhaAveo.js.map +1 -0
  164. package/dist/chunks/{fetchFileRequest-CVCelZqS.js → fetchFileRequest-B3dlL_eX.js} +2 -2
  165. package/dist/chunks/{fetchFileRequest-CVCelZqS.js.map → fetchFileRequest-B3dlL_eX.js.map} +1 -1
  166. package/dist/chunks/{live-twEh9Qwt.js → live-DZBIdcg7.js} +3 -3
  167. package/dist/chunks/{live-twEh9Qwt.js.map → live-DZBIdcg7.js.map} +1 -1
  168. package/dist/chunks/{mutationExtras-CM77Ur-9.js → mutationExtras-CnzA8Ie-.js} +2 -2
  169. package/dist/chunks/{mutationExtras-CM77Ur-9.js.map → mutationExtras-CnzA8Ie-.js.map} +1 -1
  170. package/dist/chunks/{subscriptionStream-DQp1Krwi.js → subscriptionStream-DLA3izlS.js} +2 -2
  171. package/dist/chunks/{subscriptionStream-DQp1Krwi.js.map → subscriptionStream-DLA3izlS.js.map} +1 -1
  172. package/dist/client/ClientRouter.d.ts.map +1 -1
  173. package/dist/client/index.js +24 -17
  174. package/dist/client/index.js.map +1 -1
  175. package/dist/client/useNavigate.d.ts +8 -0
  176. package/dist/client/useNavigate.d.ts.map +1 -1
  177. package/dist/config/index.js +1 -1
  178. package/dist/console/run.js +2 -2
  179. package/dist/console/run.js.map +1 -1
  180. package/dist/container/index.js +2 -2
  181. package/dist/container/index.js.map +1 -1
  182. package/dist/database/index.js +2 -2
  183. package/dist/database/index.js.map +1 -1
  184. package/dist/email/index.js +2 -2
  185. package/dist/email/index.js.map +1 -1
  186. package/dist/facades/index.js +2 -2
  187. package/dist/facades/index.js.map +1 -1
  188. package/dist/foundation/index.js +2 -2
  189. package/dist/foundation/index.js.map +1 -1
  190. package/dist/http/index.js +2 -2
  191. package/dist/http/index.js.map +1 -1
  192. package/dist/i18n/dictionaryRuntime.js +2 -2
  193. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  194. package/dist/i18n/index.js +2 -2
  195. package/dist/i18n/index.js.map +1 -1
  196. package/dist/kernel/index.js +2 -2
  197. package/dist/kernel/index.js.map +1 -1
  198. package/dist/orm/index.js +2 -2
  199. package/dist/orm/index.js.map +1 -1
  200. package/dist/probe/index.js +2 -2
  201. package/dist/probe/index.js.map +1 -1
  202. package/dist/server/index.js +2 -2
  203. package/dist/server/index.js.map +1 -1
  204. package/dist/services/cron/ScheduleServiceProvider.d.ts.map +1 -1
  205. package/dist/services/file-storage/drivers/FileSystemDriver.d.ts +55 -7
  206. package/dist/services/file-storage/drivers/FileSystemDriver.d.ts.map +1 -1
  207. package/dist/services/index.js +2 -2
  208. package/dist/services/index.js.map +1 -1
  209. package/dist/services/queue/Job.d.ts +10 -0
  210. package/dist/services/queue/Job.d.ts.map +1 -1
  211. package/dist/services/queue/QueueManager.d.ts +10 -37
  212. package/dist/services/queue/QueueManager.d.ts.map +1 -1
  213. package/dist/services/queue/QueueServiceProvider.d.ts.map +1 -1
  214. package/dist/services/queue/WorkerPool.d.ts +123 -0
  215. package/dist/services/queue/WorkerPool.d.ts.map +1 -0
  216. package/dist/services/queue/config.d.ts +16 -0
  217. package/dist/services/queue/config.d.ts.map +1 -1
  218. package/dist/services/queue/work.js +2 -2
  219. package/dist/services/queue/work.js.map +1 -1
  220. package/dist/stats/route-table.js +1 -1
  221. package/dist/support/index.js +2 -2
  222. package/dist/support/index.js.map +1 -1
  223. package/dist/testing/index.js +2 -2
  224. package/dist/vitest/index.js +1 -1
  225. package/package.json +1 -1
  226. package/dist/chunk-6gek696n.js +0 -591
  227. package/dist/chunk-by0ydsqs.js +0 -5
  228. package/dist/chunk-j3zz8046.js +0 -5
  229. package/dist/chunk-rftxm3ny.js +0 -10
  230. package/dist/chunks/ThemeProvider-1WtAS7dH.js.map +0 -1
  231. /package/dist/{chunk-3kgp6xka.js.map → chunk-4f8qpzsw.js.map} +0 -0
  232. /package/dist/{chunk-gykwq8py.js.map → chunk-7qt9pxm6.js.map} +0 -0
  233. /package/dist/{chunk-rpwvwsq9.js.map → chunk-e4a6smfv.js.map} +0 -0
  234. /package/dist/{chunk-a8q7ds6w.js.map → chunk-hvw25pe3.js.map} +0 -0
  235. /package/dist/{chunk-1kjyhseb.js.map → chunk-sew755q5.js.map} +0 -0
  236. /package/dist/{chunk-cjwjrk12.js.map → chunk-xy5evkaz.js.map} +0 -0
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Whether this code runs in a `worker = true` job's thread (#1325).
3
+ *
4
+ * The thread boots the whole application, every provider included, and a
5
+ * provider that starts something long-lived at boot would start a second copy
6
+ * of it there: the cron schedule firing every job twice, or a queue loop
7
+ * claiming jobs into a thread that exists to run one at a time. Those
8
+ * providers ask this. It reads `workerData`, which only the pool sets, rather
9
+ * than `isMainThread` alone, so an application booted in some other thread —
10
+ * a test runner's, say — is not mistaken for one.
11
+ */
12
+ export declare function isJobThread(): boolean;
13
+ /**
14
+ * Where a job thread finds the application (#1318).
15
+ *
16
+ * An app's own bootstrap is used when it exists: `app/bootstrap.ts` under
17
+ * development, `dist/server/bootstrap.mjs` (which `gemi build` emits from it)
18
+ * in production. Otherwise the thread does what `gemi queue:work` does:
19
+ * `new App({ kernel })` from `app/kernel/Kernel.ts`, with `App` resolved from
20
+ * the application's own gemi, the copy its kernel extends.
21
+ */
22
+ export declare function workerEntry(env?: Record<string, string | undefined>): {
23
+ bootstrap: string | undefined;
24
+ kernel: string;
25
+ app: string;
26
+ };
27
+ /** A job that did not finish within its `workerTimeout`. */
28
+ export declare class WorkerTimeoutError extends Error {
29
+ name: string;
30
+ }
31
+ /** How many job threads a pool keeps when the config does not say. */
32
+ export declare function defaultWorkerThreads(cores?: number): number;
33
+ export type WorkerPoolOptions = {
34
+ /** At most this many threads at once. */
35
+ size: number;
36
+ /** How long a thread may take to boot the application before its job fails. */
37
+ bootTimeoutMs: number;
38
+ /** The thread's source; the application's by default. For tests. */
39
+ source?: () => string;
40
+ };
41
+ /**
42
+ * The threads `worker = true` jobs run in (#1325).
43
+ *
44
+ * Booting the application is most of what a job thread costs: a production
45
+ * bundle is several megabytes, and loading it and booting every provider took
46
+ * seconds of CPU and a few hundred megabytes for a job whose own work was half
47
+ * a second. So a thread is kept once it has booted and runs the next job too.
48
+ *
49
+ * - **Lazy.** No thread exists until a worker job runs, and the pool grows one
50
+ * thread per job waiting for one, up to `size`. Jobs beyond that wait here
51
+ * for the first free thread.
52
+ * - **One job per thread at a time**, so a CPU-bound job has its core.
53
+ * - **A thread that fails is replaced.** One that crashes, errors outside a
54
+ * job, or exits fails the job it was running — only that one — and is
55
+ * dropped; the next waiting job starts a new thread. One that cannot boot
56
+ * fails the job it was started for, so an application that cannot load
57
+ * fails its jobs (which then retry and dead-letter) rather than spinning.
58
+ * - **A job past its timeout** has its thread terminated, since a thread
59
+ * cannot be interrupted in the middle of `run`, and fails with
60
+ * `WorkerTimeoutError`.
61
+ * - **Idle threads do not hold the process open**: they are unref'd until
62
+ * they are given a job.
63
+ */
64
+ export declare class WorkerPool {
65
+ private readonly options;
66
+ private readonly slots;
67
+ private readonly waiting;
68
+ private nextId;
69
+ private closed;
70
+ /**
71
+ * Set by `retireWhenIdle`: the pool that takes this one's waiting jobs, and
72
+ * its threads end as their jobs finish.
73
+ */
74
+ private successor;
75
+ constructor(options: WorkerPoolOptions);
76
+ /** The threads alive right now, booting ones included. */
77
+ get threads(): number;
78
+ run(jobName: string, args: string, timeoutMs: number): Promise<unknown>;
79
+ /**
80
+ * Ends every thread. Jobs still running or waiting fail; the queue's own
81
+ * `drain` is what waits for them first.
82
+ */
83
+ close(): void;
84
+ /**
85
+ * Hands this pool over to `successor`: jobs waiting here, and any run
86
+ * later, go to it; idle threads end now, and busy ones once their job is
87
+ * done, so a job already running finishes rather than failing. A thread
88
+ * still booting ends too, its job going to the successor. See `adoptPool`.
89
+ */
90
+ retireWhenIdle(successor: {
91
+ run: WorkerPool["run"];
92
+ }): void;
93
+ private forward;
94
+ private pump;
95
+ private spawn;
96
+ private assign;
97
+ private idle;
98
+ /**
99
+ * Drops a thread: fails the job it holds, if any, terminates it, and lets
100
+ * the next waiting job start a replacement. Safe to call twice; `terminate`
101
+ * itself fires `close`, which lands here again.
102
+ */
103
+ private retire;
104
+ }
105
+ /**
106
+ * Hands the process's pool over when a `bun --hot` reload builds a new one.
107
+ *
108
+ * A reload re-evaluates this module and boots a new application, whose queue
109
+ * makes a new pool; the previous pool's threads hold the application as it
110
+ * was before the save, a few hundred megabytes each. A pool from another
111
+ * evaluation of this module is retired when the new one is made: its idle
112
+ * threads end at once, and a job one is running finishes on its old code. A second pool
113
+ * from the same module (two applications in one process, as tests build) is
114
+ * left alone.
115
+ */
116
+ export declare function adoptPool(pool: WorkerPool): void;
117
+ /**
118
+ * Whether the process holds a pool from before a `bun --hot` reload. The dev
119
+ * boot asks, so the stale threads are let go as soon as the new application
120
+ * is up rather than at its first worker job.
121
+ */
122
+ export declare function hasStalePool(): boolean;
123
+ //# sourceMappingURL=WorkerPool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkerPool.d.ts","sourceRoot":"","sources":["../../../services/queue/WorkerPool.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG;IAClF,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb,CAoBA;AAmDD,4DAA4D;AAC5D,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,IAAI,SAAwB;CAC7B;AAED,sEAAsE;AACtE,wBAAgB,oBAAoB,CAAC,KAAK,SAAyB,UAElE;AAmBD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,aAAa,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,UAAU;IAWT,OAAO,CAAC,QAAQ,CAAC,OAAO;IAVpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;IACzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;IACtC,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,MAAM,CAAS;IACvB;;;OAGG;IACH,OAAO,CAAC,SAAS,CAAyC;gBAE7B,OAAO,EAAE,iBAAiB;IAEvD,0DAA0D;IAC1D,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAWvE;;;OAGG;IACH,KAAK;IAUL;;;;;OAKG;IACH,cAAc,CAAC,SAAS,EAAE;QAAE,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;KAAE;IAYpD,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,IAAI;IAiBZ,OAAO,CAAC,KAAK;IAmEb,OAAO,CAAC,MAAM;IAkBd,OAAO,CAAC,IAAI;IAKZ;;;;OAIG;IACH,OAAO,CAAC,MAAM;CASf;AAkBD;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,QAIzC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,YAG3B"}
@@ -115,6 +115,22 @@ export interface QueueConfig {
115
115
  * unknown name there is dead-lettered at once.
116
116
  */
117
117
  unknownJobGrace?: number;
118
+ /**
119
+ * How many threads `worker = true` jobs run in, at most, in this process.
120
+ * Each boots its own copy of the application once, the first time a worker
121
+ * job needs it, and then runs one job at a time for as long as the process
122
+ * lives; worker jobs beyond this many wait for a free one. Default: the
123
+ * number of cores less one, between 1 and 2. Each thread holds a booted
124
+ * application in memory, so raise it with that in mind.
125
+ */
126
+ workerThreads?: number;
127
+ /**
128
+ * How long, in milliseconds, a new job thread may take to boot the
129
+ * application before the job it was started for fails and the thread is
130
+ * ended. Default two minutes. A job's own time limit is `workerTimeout` on
131
+ * the job.
132
+ */
133
+ workerBootTimeout?: number;
118
134
  /**
119
135
  * Where locks are kept: the ones unique jobs, a cron job's
120
136
  * `withoutOverlapping` and `onOneServer`, and the `Lock` facade take.
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../services/queue/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC;IAE5B;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;IAE5B,gFAAgF;IAChF,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,EACH,QAAQ,GACR,UAAU,GACV,WAAW,GACX,CAAC,CAAC,WAAW,EAAE,WAAW,KAAK,WAAW,CAAC,CAAC;IAEhD;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;;;;;;;;;;;;;;OAkBG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EACF,MAAM,GACN,QAAQ,GACR,UAAU,GACV,SAAS,GACT,CAAC,CAAC,WAAW,EAAE,WAAW,KAAK,SAAS,CAAC,CAAC;CAC/C;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAElE;AAED,wBAAgB,mBAAmB,IAAI,QAAQ,CAAC,WAAW,CAAC,CAa3D"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../services/queue/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIzD,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC;IAE5B;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;IAE5B,gFAAgF;IAChF,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,EACH,QAAQ,GACR,UAAU,GACV,WAAW,GACX,CAAC,CAAC,WAAW,EAAE,WAAW,KAAK,WAAW,CAAC,CAAC;IAEhD;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;;;;;;;;;;;;;;OAkBG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EACF,MAAM,GACN,QAAQ,GACR,UAAU,GACV,SAAS,GACT,CAAC,CAAC,WAAW,EAAE,WAAW,KAAK,SAAS,CAAC,CAAC;CAC/C;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAElE;AAED,wBAAgB,mBAAmB,IAAI,QAAQ,CAAC,WAAW,CAAC,CAe3D"}
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Qe as J,Te as A}from"../../chunk-6gek696n.js";import{Uk as V}from"../../chunk-9a3wbbr6.js";import"../../chunk-0wa8ztk5.js";import"../../chunk-6wv3k8ap.js";import"../../chunk-ccymw1ed.js";import"../../chunk-aczp96k5.js";import"../../chunk-3mq0wmq7.js";import"../../chunk-wgb26e02.js";import{Gm as Y,Jm as N,Km as Z,Lm as _,Pm as I}from"../../chunk-vqmy8jfr.js";import{Tm as x}from"../../chunk-zsmwmg8x.js";import"../../chunk-c7hbdsjv.js";import $ from"path";function X(z){if(!z.config.get("route.channels"))return null;let C=z.config.get("broadcast",{}).driver;if(!(C===void 0||C==="memory"||C instanceof V))return null;return'[gemi] Broadcasts from this worker reach no one: the broadcast driver is "memory", which delivers to the sockets of the process that emits, and a worker has none. Set `driver: "redis"` in app/config/broadcast.ts.'}class L extends Error{name="QueueWorkerRefused"}class O{kernel;stopping;keepAlive;settings;constructor(z,C={}){this.kernel=z;this.settings={..._(),...C}}async start(){if(await this.kernel.waitForBoot(),this.stopping)return;let z=this.kernel.app;if(!z.bound(J))throw new L("[gemi] `gemi queue:work` has no queue to claim from: this application does not register QueueServiceProvider.");let C=z.make(J);if(!C.durable)throw new L('[gemi] `gemi queue:work` refuses to start: the queue uses the memory driver, which keeps each job in the process that dispatched it, so a worker never sees one. Set `driver: "database"` (or another driver every process can reach) in app/config/queue.ts, or run jobs in the server and drop the worker.');C.start(),this.keepAlive=setInterval(()=>{},1073741824),console.log(`[gemi] Queue worker started: claiming up to ${C.config.concurrency} job(s) at a time.`);let E=X(z);if(E)console.warn(E)}stop(z={}){return this.stopping??=this.drain({...this.settings,...z}),this.stopping}async drain(z){let C=Date.now()+z.timeoutMs;Y();let E=this.kernel.app,F=E.resolved(J)?E.make(J):void 0;if(F)console.log(`[gemi] Shutting down: waiting for ${F.running} running job(s) (up to ${z.timeoutMs/1000}s).`),await F.drain(z.timeoutMs);let G=N()===0;if(!G){let U=C-Date.now();if(G=U>0&&await Promise.race([Z().then(()=>!0),new Promise((K)=>setTimeout(()=>K(!1),U))]),!G)console.error(`[gemi] Shutdown grace period elapsed with ${N()} held background task(s) still running; abandoning them.`)}let H=await this.kernel.shutdown({timeoutMs:z.providerTimeoutMs});clearInterval(this.keepAlive);let T=G&&(F?.running??0)===0&&H.failed.length===0&&H.timedOut.length===0;return console.log(`[gemi] Shutdown ${T?"complete":"finished with errors"}.`),T?0:1}}async function j(){let z=x();process.env.ROOT_DIR=z,process.env.APP_DIR=$.join(z,"app"),A();let C=$.join(z,"app/kernel/Kernel.ts"),{default:E}=await import(C);if(typeof E!=="function")return console.error(`[gemi] ${C} has no default export to boot the worker from.`),1;let F=new E;F.boot();let G=new O(F);I(()=>G.stop());try{await G.start()}catch(H){if(!(H instanceof L))throw H;return console.error(H.message),1}return}j().then((z)=>{if(z!==void 0)process.exit(z)},(z)=>{console.error("[gemi] The queue worker failed to start:",z),process.exit(1)});
2
+ import{Se as J,Ve as A}from"../../chunk-vh6vc4h1.js";import{Wk as V}from"../../chunk-e0e43wvq.js";import"../../chunk-yrna0ajq.js";import"../../chunk-jr53em8y.js";import"../../chunk-v3ddktnq.js";import"../../chunk-rffa9x3d.js";import"../../chunk-2g6cmkrn.js";import"../../chunk-sp79baph.js";import{Im as Y,Lm as N,Mm as Z,Nm as _,Rm as I}from"../../chunk-3ywtqcxt.js";import{Vm as x}from"../../chunk-9cxs1q57.js";import"../../chunk-7ztbpqed.js";import $ from"path";function X(z){if(!z.config.get("route.channels"))return null;let C=z.config.get("broadcast",{}).driver;if(!(C===void 0||C==="memory"||C instanceof V))return null;return'[gemi] Broadcasts from this worker reach no one: the broadcast driver is "memory", which delivers to the sockets of the process that emits, and a worker has none. Set `driver: "redis"` in app/config/broadcast.ts.'}class L extends Error{name="QueueWorkerRefused"}class O{kernel;stopping;keepAlive;settings;constructor(z,C={}){this.kernel=z;this.settings={..._(),...C}}async start(){if(await this.kernel.waitForBoot(),this.stopping)return;let z=this.kernel.app;if(!z.bound(J))throw new L("[gemi] `gemi queue:work` has no queue to claim from: this application does not register QueueServiceProvider.");let C=z.make(J);if(!C.durable)throw new L('[gemi] `gemi queue:work` refuses to start: the queue uses the memory driver, which keeps each job in the process that dispatched it, so a worker never sees one. Set `driver: "database"` (or another driver every process can reach) in app/config/queue.ts, or run jobs in the server and drop the worker.');C.start(),this.keepAlive=setInterval(()=>{},1073741824),console.log(`[gemi] Queue worker started: claiming up to ${C.config.concurrency} job(s) at a time.`);let E=X(z);if(E)console.warn(E)}stop(z={}){return this.stopping??=this.drain({...this.settings,...z}),this.stopping}async drain(z){let C=Date.now()+z.timeoutMs;Y();let E=this.kernel.app,F=E.resolved(J)?E.make(J):void 0;if(F)console.log(`[gemi] Shutting down: waiting for ${F.running} running job(s) (up to ${z.timeoutMs/1000}s).`),await F.drain(z.timeoutMs);let G=N()===0;if(!G){let U=C-Date.now();if(G=U>0&&await Promise.race([Z().then(()=>!0),new Promise((K)=>setTimeout(()=>K(!1),U))]),!G)console.error(`[gemi] Shutdown grace period elapsed with ${N()} held background task(s) still running; abandoning them.`)}let H=await this.kernel.shutdown({timeoutMs:z.providerTimeoutMs});clearInterval(this.keepAlive);let T=G&&(F?.running??0)===0&&H.failed.length===0&&H.timedOut.length===0;return console.log(`[gemi] Shutdown ${T?"complete":"finished with errors"}.`),T?0:1}}async function j(){let z=x();process.env.ROOT_DIR=z,process.env.APP_DIR=$.join(z,"app"),A();let C=$.join(z,"app/kernel/Kernel.ts"),{default:E}=await import(C);if(typeof E!=="function")return console.error(`[gemi] ${C} has no default export to boot the worker from.`),1;let F=new E;F.boot();let G=new O(F);I(()=>G.stop());try{await G.start()}catch(H){if(!(H instanceof L))throw H;return console.error(H.message),1}return}j().then((z)=>{if(z!==void 0)process.exit(z)},(z)=>{console.error("[gemi] The queue worker failed to start:",z),process.exit(1)});
3
3
 
4
- //# debugId=3ABCBF3D67B1F60A64756E2164756E21
4
+ //# debugId=AC66DA9E1BC1584D64756E2164756E21
@@ -7,6 +7,6 @@
7
7
  "import type { Application, ShutdownReport } from \"../../foundation/Application\";\nimport {\n heldWork,\n heldWorkSettled,\n markShuttingDown,\n shutdownSettings,\n type ShutdownSettings,\n} from \"../../server/shutdown\";\nimport { memoryBroadcastInWorker } from \"../broadcast/workerWarning\";\nimport { QueueManager } from \"./QueueManager\";\n\n/** The part of a `Kernel` a worker drives. */\nexport type WorkerKernel = {\n readonly app: Application;\n waitForBoot(): Promise<void>;\n shutdown(options?: { timeoutMs?: number }): Promise<ShutdownReport>;\n};\n\n/**\n * A worker that was told to start in an application it cannot claim for. The\n * message is written for the operator reading the deploy's logs.\n */\nexport class QueueWorkerRefused extends Error {\n name = \"QueueWorkerRefused\";\n}\n\n/**\n * The process `gemi queue:work` runs: the application booted as a server boots\n * it, claiming from the queue, and no `Bun.serve`. It exists so job capacity\n * can be scaled apart from request traffic, which needs a driver both kinds of\n * process can reach; see `start` for why the memory driver is refused.\n *\n * The caller marks the process as a worker (`markQueueWorker`) before the\n * kernel registers, so every claim rule that asks `claimsInThisProcess` sees a\n * process that claims, whatever `GEMI_QUEUE_CLAIM` says.\n */\nexport class QueueWorker {\n private stopping: Promise<number> | undefined;\n private keepAlive: ReturnType<typeof setInterval> | undefined;\n private readonly settings: ShutdownSettings;\n\n /**\n * `settings` default to the `GEMI_SHUTDOWN_*` variables, read here rather\n * than at the signal so a bad value is warned about while the deploy is\n * being watched, as `Server.start` does.\n */\n constructor(\n private readonly kernel: WorkerKernel,\n settings: Partial<ShutdownSettings> = {},\n ) {\n this.settings = { ...shutdownSettings(), ...settings };\n }\n\n /**\n * Boots the application and starts claiming. Rejects with\n * `QueueWorkerRefused` when the application has no queue, or its queue uses\n * the memory driver.\n *\n * Refused rather than warned about, because a memory worker can never do\n * anything: its jobs live in a `Map` in the process that dispatched them,\n * so a worker's is always empty. Left running, it looks like a healthy\n * deploy — a process up, no errors — that runs nothing, and scaling it out\n * adds no capacity. An exit the platform reports as a crash loop is a form\n * of the mistake someone will see.\n */\n async start(): Promise<void> {\n await this.kernel.waitForBoot();\n // A signal during the boot has already drained and cleared the handle\n // below. Going on would start the loop again and arm a handle nothing\n // clears, holding open a worker that has finished shutting down.\n if (this.stopping) return;\n\n const application = this.kernel.app;\n // `bound`, not `make` in a try: an application built without the queue\n // provider is a configuration to name, not an unbound-token stack trace.\n if (!application.bound(QueueManager)) {\n throw new QueueWorkerRefused(\n \"[gemi] `gemi queue:work` has no queue to claim from: this application \" +\n \"does not register QueueServiceProvider.\",\n );\n }\n const queue = application.make(QueueManager);\n if (!queue.durable) {\n throw new QueueWorkerRefused(\n \"[gemi] `gemi queue:work` refuses to start: the queue uses the memory \" +\n \"driver, which keeps each job in the process that dispatched it, so \" +\n 'a worker never sees one. Set `driver: \"database\"` (or another driver ' +\n \"every process can reach) in app/config/queue.ts, or run jobs in the \" +\n \"server and drop the worker.\",\n );\n }\n\n // Idempotent: a production boot with a durable driver has already started\n // it (`startClaimingIfServing`). Development has not, and a worker claims\n // in either.\n queue.start();\n // The queue's poll timer is unref'd, so that a script's queue does not\n // hold it open; here the queue is the process, and without a handle of its\n // own an idle worker would exit 0 as soon as it booted.\n this.keepAlive = setInterval(() => {}, 1 << 30);\n console.log(\n `[gemi] Queue worker started: claiming up to ${queue.config.concurrency} job(s) at a time.`,\n );\n const broadcastWarning = memoryBroadcastInWorker(application);\n if (broadcastWarning) console.warn(broadcastWarning);\n }\n\n /**\n * Stops claiming, waits for the running jobs, runs every provider's\n * `shutdown()`, and resolves with the exit code: 0 when no job was left\n * running and every provider finished in time, 1 otherwise. Idempotent.\n *\n * `gemi start`'s drain, with the jobs where the requests were:\n * `isShuttingDown()` turns true, which stops a durable queue claiming;\n * running jobs get `timeoutMs` (`GEMI_SHUTDOWN_TIMEOUT`), which a server\n * spends on requests; then `Application.shutdown` gets `providerTimeoutMs`,\n * and in it the queue provider waits for whatever is still running and\n * names it. The two budgets add up as they do for a server, so a worker\n * fits the same grace period. `delayMs` is not waited: it is for a load\n * balancer, and nothing routes to a worker.\n */\n stop(settings: Partial<ShutdownSettings> = {}): Promise<number> {\n this.stopping ??= this.drain({ ...this.settings, ...settings });\n return this.stopping;\n }\n\n private async drain(settings: ShutdownSettings): Promise<number> {\n const deadline = Date.now() + settings.timeoutMs;\n markShuttingDown();\n const application = this.kernel.app;\n // Resolving the manager now would build a driver only to stop it, which\n // is what a signal during the boot, before the provider resolved it, finds.\n const queue = application.resolved(QueueManager) ? application.make(QueueManager) : undefined;\n if (queue) {\n console.log(\n `[gemi] Shutting down: waiting for ${queue.running} running job(s) ` +\n `(up to ${settings.timeoutMs / 1000}s).`,\n );\n await queue.drain(settings.timeoutMs);\n }\n // Work held with `holdShutdown` (#1210) gets what is left of the same budget.\n let held = heldWork() === 0;\n if (!held) {\n const remaining = deadline - Date.now();\n held =\n remaining > 0 &&\n (await Promise.race([\n heldWorkSettled().then(() => true),\n new Promise<false>((resolve) => setTimeout(() => resolve(false), remaining)),\n ]));\n if (!held) {\n console.error(\n `[gemi] Shutdown grace period elapsed with ${heldWork()} held background task(s) still running; abandoning them.`,\n );\n }\n }\n\n const report = await this.kernel.shutdown({ timeoutMs: settings.providerTimeoutMs });\n clearInterval(this.keepAlive);\n const clean =\n held && (queue?.running ?? 0) === 0 && report.failed.length === 0 && report.timedOut.length === 0;\n console.log(`[gemi] Shutdown ${clean ? \"complete\" : \"finished with errors\"}.`);\n return clean ? 0 : 1;\n }\n}\n"
8
8
  ],
9
9
  "mappings": "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",
10
- "debugId": "3ABCBF3D67B1F60A64756E2164756E21",
10
+ "debugId": "AC66DA9E1BC1584D64756E2164756E21",
11
11
  "names": []
12
12
  }
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import"../chunk-c7hbdsjv.js";import M from"path";import{writeFileSync as Q}from"fs";var L=new Set(["FILE","REDIRECT"]);function H(j){return j.run(()=>{let x=[];for(let{group:z,view:D}of j.domains().viewGroups())for(let[G,B]of Object.entries(D.flatViewRoutes)){let C=D.routeManifest[G]??B.segments.map((K)=>K.viewPath);if(C.length===0||L.has(C.at(-1)))continue;x.push({path:G,group:z,views:C,...B.static?{static:{...B.static.layout?{layout:B.static.layout}:{},...B.static.navigation?{navigation:!0}:{}}}:{}})}return x})}var J=process.argv[2];async function U(){if(!J)throw Error("usage: route-table <out.json>");let j=M.resolve(process.cwd(),"app/kernel/Kernel.ts"),x=await import(j);if(typeof x.default!=="function")throw Error(`${j} has no default export (the Kernel subclass).`);let z=new x.default;z.boot();try{Q(J,JSON.stringify(H(z)))}finally{z.destroy()}}U().then(()=>process.exit(0),(j)=>{console.error(j?.stack??String(j)),process.exit(1)});
2
+ import"../chunk-7ztbpqed.js";import M from"path";import{writeFileSync as Q}from"fs";var L=new Set(["FILE","REDIRECT"]);function H(j){return j.run(()=>{let x=[];for(let{group:z,view:D}of j.domains().viewGroups())for(let[G,B]of Object.entries(D.flatViewRoutes)){let C=D.routeManifest[G]??B.segments.map((K)=>K.viewPath);if(C.length===0||L.has(C.at(-1)))continue;x.push({path:G,group:z,views:C,...B.static?{static:{...B.static.layout?{layout:B.static.layout}:{},...B.static.navigation?{navigation:!0}:{}}}:{}})}return x})}var J=process.argv[2];async function U(){if(!J)throw Error("usage: route-table <out.json>");let j=M.resolve(process.cwd(),"app/kernel/Kernel.ts"),x=await import(j);if(typeof x.default!=="function")throw Error(`${j} has no default export (the Kernel subclass).`);let z=new x.default;z.boot();try{Q(J,JSON.stringify(H(z)))}finally{z.destroy()}}U().then(()=>process.exit(0),(j)=>{console.error(j?.stack??String(j)),process.exit(1)});
3
3
 
4
4
  //# debugId=05EB0087C5A2060D64756E2164756E21
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Ye as Y}from"../chunk-bhycdjcv.js";import{kl as M}from"../chunk-6wv3k8ap.js";import{um as P,wm as R}from"../chunk-3mq0wmq7.js";import"../chunk-wgb26e02.js";import{Qm as Q,Rm as U,Sm as V,Tm as W}from"../chunk-zsmwmg8x.js";import"../chunk-c7hbdsjv.js";class S{static token;async boot(){}onShutdown(x){}static inject(){if(!this.token)throw Error(`Service [${this.name}] does not declare a \`static token\`, so the container has no key to resolve it by.`);try{return R(this)}catch(x){throw Error(`Could not inject [${this.name}]. Services are constructed when the kernel boots, so `+"inject() only works from code that runs after that \u2014 a constructor default or a method "+`body, never module top level. Check that [${this.name}] is listed in \`services\` on your Kernel.`,{cause:x})}}static with(x){let f=new this;for(let[C,g]of Object.entries(x))if(g!==void 0)f[C]=g;return f}}import{readdir as z}from"fs/promises";import{join as B,parse as j}from"path";var H=[".ts",".tsx",".js",".mjs",".jsx"];function J(x={}){let f={};for(let[C,g]of Object.entries(x))f[C]=q(g);return new P(f)}async function L(x,f=new P){let C=[];try{C=await z(x)}catch(D){return f}let g=C.filter((D)=>{let{ext:v,name:F}=j(D);return H.includes(v)&&!F.startsWith(".")}).sort();for(let D of g){let{name:v}=j(D),F=await import(B(x,D));f.set(v,q(F))}return f}function q(x){if(x&&typeof x==="object"&&"default"in x)return x.default;return x}export{M as withDefaults,Q as sourceFiles,W as projectRoot,L as loadConfigFrom,V as discoverClasses,J as createConfigRepository,Y as ServiceProvider,S as Service,P as Repository,U as DiscoveryError};
2
+ import{_e as Y}from"../chunk-fy4142fv.js";import{ml as M}from"../chunk-jr53em8y.js";import{wm as P,ym as R}from"../chunk-2g6cmkrn.js";import"../chunk-sp79baph.js";import{Sm as Q,Tm as U,Um as V,Vm as W}from"../chunk-9cxs1q57.js";import"../chunk-7ztbpqed.js";class S{static token;async boot(){}onShutdown(x){}static inject(){if(!this.token)throw Error(`Service [${this.name}] does not declare a \`static token\`, so the container has no key to resolve it by.`);try{return R(this)}catch(x){throw Error(`Could not inject [${this.name}]. Services are constructed when the kernel boots, so `+"inject() only works from code that runs after that \u2014 a constructor default or a method "+`body, never module top level. Check that [${this.name}] is listed in \`services\` on your Kernel.`,{cause:x})}}static with(x){let f=new this;for(let[C,g]of Object.entries(x))if(g!==void 0)f[C]=g;return f}}import{readdir as z}from"fs/promises";import{join as B,parse as j}from"path";var H=[".ts",".tsx",".js",".mjs",".jsx"];function J(x={}){let f={};for(let[C,g]of Object.entries(x))f[C]=q(g);return new P(f)}async function L(x,f=new P){let C=[];try{C=await z(x)}catch(D){return f}let g=C.filter((D)=>{let{ext:v,name:F}=j(D);return H.includes(v)&&!F.startsWith(".")}).sort();for(let D of g){let{name:v}=j(D),F=await import(B(x,D));f.set(v,q(F))}return f}function q(x){if(x&&typeof x==="object"&&"default"in x)return x.default;return x}export{M as withDefaults,Q as sourceFiles,W as projectRoot,L as loadConfigFrom,V as discoverClasses,J as createConfigRepository,Y as ServiceProvider,S as Service,P as Repository,U as DiscoveryError};
3
3
 
4
- //# debugId=0722504D2BFEB23564756E2164756E21
4
+ //# debugId=4B40758CA8452E1F64756E2164756E21
@@ -6,6 +6,6 @@
6
6
  "import { readdir } from \"node:fs/promises\";\nimport { join, parse } from \"node:path\";\n\nimport { Repository } from \"./Repository\";\n\nconst CONFIG_EXTENSIONS = [\".ts\", \".tsx\", \".js\", \".mjs\", \".jsx\"];\n\n// Builds a Repository from an already-imported map of config modules. The map\n// key becomes the top-level config key, so `{ mail: mailModule }` is readable\n// as `config.get(\"mail.driver\")`. Each entry may be either the module namespace\n// (its `default` export is unwrapped) or the config object itself.\nexport function createConfigRepository(\n modules: Record<string, any> = {},\n): Repository {\n const items: Record<string, any> = {};\n\n for (const [key, mod] of Object.entries(modules)) {\n items[key] = unwrap(mod);\n }\n\n return new Repository(items);\n}\n\n// Reads every config module in an app's `app/config` directory into a\n// Repository. The file's basename is the top-level key: `app/config/mail.ts`\n// populates `mail.*`. A missing directory yields an empty Repository so apps\n// that declare no config still boot.\nexport async function loadConfigFrom(\n directory: string,\n repository = new Repository(),\n): Promise<Repository> {\n let entries: string[] = [];\n\n try {\n entries = await readdir(directory);\n } catch (err) {\n return repository;\n }\n\n const files = entries\n .filter((entry) => {\n const { ext, name } = parse(entry);\n return CONFIG_EXTENSIONS.includes(ext) && !name.startsWith(\".\");\n })\n .sort();\n\n for (const file of files) {\n const { name } = parse(file);\n const mod = await import(join(directory, file));\n repository.set(name, unwrap(mod));\n }\n\n return repository;\n}\n\nfunction unwrap(mod: any) {\n if (mod && typeof mod === \"object\" && \"default\" in mod) {\n return mod.default;\n }\n return mod;\n}\n"
7
7
  ],
8
8
  "mappings": ";2RAiCO,CAAe,JAAQ,EAOrB,OAMD,AAAI,EAAkB,EAmB5B,UAAU,CAAC,EAEkD,QAmBtD,OAAS,EAKX,CACH,GAAI,CAAC,KAAK,MACR,MAAU,MACR,YAAY,KAAK,0FACnB,EAGF,GAAI,CACF,OAAO,EAAI,IAAuB,EAClC,MAAO,EAAO,CACd,MAAU,MACR,qBAAqB,KAAK,6DACxB,+FACA,6CAA6C,KAAK,kDAEpD,CAAE,OAAM,CACV,SAoBG,KAAuB,CAAoB,EAA0B,CAC1E,IAAM,EAAW,IAAI,KACrB,QAAY,EAAK,KAAU,OAAO,QAAQ,CAAS,EACjD,GAAI,IAAU,OAAW,EAAS,GAAO,EAE3C,OAAO,EAEX,CCtIA,kBAAS,oBACT,eAAS,WAAM,aAIf,IAAM,EAAoB,CAAC,MAAO,OAAQ,MAAO,OAAQ,MAAM,EAMxD,SAAS,CAAsB,CACpC,EAA+B,CAAC,EACpB,CACZ,IAAM,EAA6B,CAAC,EAEpC,QAAY,EAAK,KAAQ,OAAO,QAAQ,CAAO,EAC7C,EAAM,GAAO,EAAO,CAAG,EAGzB,OAAO,IAAI,EAAW,CAAK,EAO7B,eAAsB,CAAc,CAClC,EACA,EAAa,IAAI,EACI,CACrB,IAAI,EAAoB,CAAC,EAEzB,GAAI,CACF,EAAU,MAAM,EAAQ,CAAS,EACjC,MAAO,EAAK,CACZ,OAAO,EAGT,IAAM,EAAQ,EACX,OAAO,CAAC,IAAU,CACjB,IAAQ,MAAK,QAAS,EAAM,CAAK,EACjC,OAAO,EAAkB,SAAS,CAAG,GAAK,CAAC,EAAK,WAAW,GAAG,EAC/D,EACA,KAAK,EAER,QAAW,KAAQ,EAAO,CACxB,IAAQ,QAAS,EAAM,CAAI,EACrB,EAAM,MAAa,SAAK,EAAW,CAAI,GAC7C,EAAW,IAAI,EAAM,EAAO,CAAG,CAAC,EAGlC,OAAO,EAGT,SAAS,CAAM,CAAC,EAAU,CACxB,GAAI,GAAO,OAAO,IAAQ,UAAY,YAAa,EACjD,OAAO,EAAI,QAEb,OAAO",
9
- "debugId": "0722504D2BFEB23564756E2164756E21",
9
+ "debugId": "4B40758CA8452E1F64756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -1,8 +1,8 @@
1
- import { $ as toVariantKey, B as ProgressManager, Ct as Subject, G as RealtimeContext, J as liveModule, N as I18nProvider, P as ServerDataContext, c as ClientRouterContext, et as applyParams, i as RouteTransitionProvider, nt as QueryManagerContext, r as m, rt as QueryManagerProvider, t as ThemeProvider } from "../chunks/ThemeProvider-1WtAS7dH.js";
1
+ import { $ as toVariantKey, B as ProgressManager, Ct as Subject, G as RealtimeContext, J as liveModule, N as I18nProvider, P as ServerDataContext, c as ClientRouterContext, et as applyParams, i as RouteTransitionProvider, nt as QueryManagerContext, r as m, rt as QueryManagerProvider, t as ThemeProvider } from "../chunks/ThemeProvider-wwhaAveo.js";
2
2
  import { r as RouteStateProvider } from "../chunks/useParams-BN3XXfmG.js";
3
3
  import "../chunks/urlpattern-polyfill-Cc7YrzJf.js";
4
4
  import { t as channelKey } from "../chunks/channelKey-CIhHpX6x.js";
5
- import { t as followLive } from "../chunks/live-twEh9Qwt.js";
5
+ import { t as followLive } from "../chunks/live-DZBIdcg7.js";
6
6
  import { Suspense, createElement, useContext, useMemo, useRef, useState } from "react";
7
7
  import { jsx } from "react/jsx-runtime";
8
8
  import { hydrateRoot } from "react-dom/client";
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{ua as B,va as D}from"../chunk-3crknzwp.js";import"../chunk-342ydn4n.js";import"../chunk-fec4qnr3.js";import{Pa as J}from"../chunk-rreb2k19.js";import"../chunk-7fh7cfjh.js";import"../chunk-c7hbdsjv.js";function N(){return{name:"gemi-custom-request",enforce:"pre",async transform(G,H){let j=H.split("?",1)[0];if(j.includes("/node_modules/")||!B.test(j))return null;return{code:await D(G),map:null}}}}export{N as gemiRequestPlugin,J as gemiIslandPlugin};
2
+ import{ua as B,va as D}from"../chunk-7c48nxqb.js";import"../chunk-ge5m9qdt.js";import"../chunk-57n0m9fv.js";import{Pa as J}from"../chunk-wac3gv1t.js";import"../chunk-gqw25apr.js";import"../chunk-7ztbpqed.js";function N(){return{name:"gemi-custom-request",enforce:"pre",async transform(G,H){let j=H.split("?",1)[0];if(j.includes("/node_modules/")||!B.test(j))return null;return{code:await D(G),map:null}}}}export{N as gemiRequestPlugin,J as gemiIslandPlugin};
3
3
 
4
4
  //# debugId=54630B516034F10064756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemi",
3
- "version": "0.240.0",
3
+ "version": "0.242.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "Enes Tufekci <enes@gemijs.dev>",