fundus 0.0.2 → 0.0.4

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 (303) hide show
  1. package/README.md +73 -0
  2. package/build/client/_app/immutable/assets/0.DLhIsYA_.css.br +0 -0
  3. package/build/client/_app/immutable/assets/0.DLhIsYA_.css.gz +0 -0
  4. package/build/client/_app/immutable/assets/2.ohi-TClG.css +1 -0
  5. package/build/client/_app/immutable/assets/2.ohi-TClG.css.br +0 -0
  6. package/build/client/_app/immutable/assets/2.ohi-TClG.css.gz +0 -0
  7. package/build/client/_app/immutable/assets/3.JwgtcTEd.css +1 -0
  8. package/build/client/_app/immutable/assets/3.JwgtcTEd.css.br +0 -0
  9. package/build/client/_app/immutable/assets/3.JwgtcTEd.css.gz +0 -0
  10. package/build/client/_app/immutable/assets/4.p004hmEN.css +1 -0
  11. package/build/client/_app/immutable/assets/4.p004hmEN.css.br +0 -0
  12. package/build/client/_app/immutable/assets/4.p004hmEN.css.gz +0 -0
  13. package/build/client/_app/immutable/assets/ConfirmDialog.BdKlitwi.css +1 -0
  14. package/build/client/_app/immutable/assets/ConfirmDialog.BdKlitwi.css.br +0 -0
  15. package/build/client/_app/immutable/assets/ConfirmDialog.BdKlitwi.css.gz +0 -0
  16. package/build/client/_app/immutable/assets/LibraryContextMenu.CMefGNE2.css +1 -0
  17. package/build/client/_app/immutable/assets/LibraryContextMenu.CMefGNE2.css.br +0 -0
  18. package/build/client/_app/immutable/assets/LibraryContextMenu.CMefGNE2.css.gz +0 -0
  19. package/build/client/_app/immutable/chunks/Bjy-W4x2.js.br +0 -0
  20. package/build/client/_app/immutable/chunks/Bjy-W4x2.js.gz +0 -0
  21. package/build/client/_app/immutable/chunks/CNRz3sSw.js.br +0 -0
  22. package/build/client/_app/immutable/chunks/CNRz3sSw.js.gz +0 -0
  23. package/build/client/_app/immutable/chunks/CO4RBJfa.js.br +0 -0
  24. package/build/client/_app/immutable/chunks/CO4RBJfa.js.gz +0 -0
  25. package/build/client/_app/immutable/chunks/DOpBpjxS.js +108 -0
  26. package/build/client/_app/immutable/chunks/DOpBpjxS.js.br +0 -0
  27. package/build/client/_app/immutable/chunks/DOpBpjxS.js.gz +0 -0
  28. package/{dist/editor/_app/immutable/chunks/BfPE5wdt.js → build/client/_app/immutable/chunks/DVEQFclp.js} +1 -1
  29. package/build/client/_app/immutable/chunks/DVEQFclp.js.br +1 -0
  30. package/build/client/_app/immutable/chunks/DVEQFclp.js.gz +0 -0
  31. package/{dist/editor/_app/immutable/chunks/DjvOiDmq.js → build/client/_app/immutable/chunks/DiFoWL2c.js} +1 -1
  32. package/build/client/_app/immutable/chunks/DiFoWL2c.js.br +0 -0
  33. package/build/client/_app/immutable/chunks/DiFoWL2c.js.gz +0 -0
  34. package/build/client/_app/immutable/chunks/DkADHpZF.js +1 -0
  35. package/build/client/_app/immutable/chunks/DkADHpZF.js.br +0 -0
  36. package/build/client/_app/immutable/chunks/DkADHpZF.js.gz +0 -0
  37. package/build/client/_app/immutable/chunks/xihTtKlq.js.br +1 -0
  38. package/build/client/_app/immutable/chunks/xihTtKlq.js.gz +0 -0
  39. package/{dist/editor/_app/immutable/entry/app.BkqbfI8n.js → build/client/_app/immutable/entry/app.CKgtYXQb.js} +2 -2
  40. package/build/client/_app/immutable/entry/app.CKgtYXQb.js.br +0 -0
  41. package/build/client/_app/immutable/entry/app.CKgtYXQb.js.gz +0 -0
  42. package/build/client/_app/immutable/entry/start.CYZu5qE1.js +1 -0
  43. package/build/client/_app/immutable/entry/start.CYZu5qE1.js.br +0 -0
  44. package/build/client/_app/immutable/entry/start.CYZu5qE1.js.gz +0 -0
  45. package/{dist/editor/_app/immutable/nodes/0.xdMI5GEU.js → build/client/_app/immutable/nodes/0.I_1SApYQ.js} +1 -1
  46. package/build/client/_app/immutable/nodes/0.I_1SApYQ.js.br +0 -0
  47. package/build/client/_app/immutable/nodes/0.I_1SApYQ.js.gz +0 -0
  48. package/{dist/editor/_app/immutable/nodes/1.D9p2tfoJ.js → build/client/_app/immutable/nodes/1.v6eUTnWq.js} +1 -1
  49. package/build/client/_app/immutable/nodes/1.v6eUTnWq.js.br +2 -0
  50. package/build/client/_app/immutable/nodes/1.v6eUTnWq.js.gz +0 -0
  51. package/build/client/_app/immutable/nodes/2.DoA7Dfl-.js +3 -0
  52. package/build/client/_app/immutable/nodes/2.DoA7Dfl-.js.br +0 -0
  53. package/build/client/_app/immutable/nodes/2.DoA7Dfl-.js.gz +0 -0
  54. package/build/client/_app/immutable/nodes/3.C-DO70Bs.js +1 -0
  55. package/build/client/_app/immutable/nodes/3.C-DO70Bs.js.br +0 -0
  56. package/build/client/_app/immutable/nodes/3.C-DO70Bs.js.gz +0 -0
  57. package/build/client/_app/immutable/nodes/4.CALOuSyz.js +2 -0
  58. package/build/client/_app/immutable/nodes/4.CALOuSyz.js.br +0 -0
  59. package/build/client/_app/immutable/nodes/4.CALOuSyz.js.gz +0 -0
  60. package/build/client/_app/version.json +1 -0
  61. package/build/client/_app/version.json.br +0 -0
  62. package/build/client/_app/version.json.gz +0 -0
  63. package/build/env.js +100 -0
  64. package/build/env.js.map +1 -0
  65. package/build/handler.js +22 -0
  66. package/build/handler.js.map +1 -0
  67. package/build/index.js +145 -0
  68. package/build/index.js.map +1 -0
  69. package/build/server/chunks/chunks/context.js-BUZqFfWG.js +429 -0
  70. package/build/server/chunks/chunks/context.js-BUZqFfWG.js.map +1 -0
  71. package/build/server/chunks/chunks/core.js-xfrkaQpS.js +458 -0
  72. package/build/server/chunks/chunks/core.js-xfrkaQpS.js.map +1 -0
  73. package/build/server/chunks/chunks/env.js-l0sNRNKZ.js +2 -0
  74. package/build/server/chunks/chunks/env.js-l0sNRNKZ.js.map +1 -0
  75. package/build/server/chunks/chunks/exports.js-C0rwMMtk.js +152 -0
  76. package/build/server/chunks/chunks/exports.js-C0rwMMtk.js.map +1 -0
  77. package/build/server/chunks/chunks/folder-path.js-ytx9ucgg.js +64 -0
  78. package/build/server/chunks/chunks/folder-path.js-ytx9ucgg.js.map +1 -0
  79. package/build/server/chunks/chunks/http.js-DvopzwKh.js +100 -0
  80. package/build/server/chunks/chunks/http.js-DvopzwKh.js.map +1 -0
  81. package/build/server/chunks/chunks/internal.js-DGo2jPcg.js +5753 -0
  82. package/build/server/chunks/chunks/internal.js-DGo2jPcg.js.map +1 -0
  83. package/build/server/chunks/chunks/internal2.js-BlXt2rfE.js +22 -0
  84. package/build/server/chunks/chunks/internal2.js-BlXt2rfE.js.map +1 -0
  85. package/{dist/operations-DYM-5KVl.js → build/server/chunks/chunks/library-store.js-ZLudCJlT.js} +463 -492
  86. package/build/server/chunks/chunks/library-store.js-ZLudCJlT.js.map +1 -0
  87. package/build/server/chunks/chunks/manifest-appearance.js-DTk355LQ.js +146 -0
  88. package/build/server/chunks/chunks/manifest-appearance.js-DTk355LQ.js.map +1 -0
  89. package/build/server/chunks/chunks/routing.js-y-tryuip.js +213 -0
  90. package/build/server/chunks/chunks/routing.js-y-tryuip.js.map +1 -0
  91. package/build/server/chunks/chunks/shared.js-B1gC9MiJ.js +255 -0
  92. package/build/server/chunks/chunks/shared.js-B1gC9MiJ.js.map +1 -0
  93. package/build/server/chunks/chunks/utils.js-DnEJ3UjO.js +1048 -0
  94. package/build/server/chunks/chunks/utils.js-DnEJ3UjO.js.map +1 -0
  95. package/build/server/chunks/entries/endpoints/api/_...path_/_server.ts.js-Cq5gXVQT.js +27 -0
  96. package/build/server/chunks/entries/endpoints/api/_...path_/_server.ts.js-Cq5gXVQT.js.map +1 -0
  97. package/build/server/chunks/entries/endpoints/api/assets/_id_/_server.ts.js-RXbedi8q.js +24 -0
  98. package/build/server/chunks/entries/endpoints/api/assets/_id_/_server.ts.js-RXbedi8q.js.map +1 -0
  99. package/build/server/chunks/entries/endpoints/api/assets/_server.ts.js-D7Qae9vU.js +45 -0
  100. package/build/server/chunks/entries/endpoints/api/assets/_server.ts.js-D7Qae9vU.js.map +1 -0
  101. package/build/server/chunks/entries/endpoints/api/assets/delete/_server.ts.js-DtO20kgB.js +31 -0
  102. package/build/server/chunks/entries/endpoints/api/assets/delete/_server.ts.js-DtO20kgB.js.map +1 -0
  103. package/build/server/chunks/entries/endpoints/api/assets/move/_server.ts.js-BUebPbd5.js +31 -0
  104. package/build/server/chunks/entries/endpoints/api/assets/move/_server.ts.js-BUebPbd5.js.map +1 -0
  105. package/build/server/chunks/entries/endpoints/api/folders/_path_/_server.ts.js-BjT2qPMT.js +38 -0
  106. package/build/server/chunks/entries/endpoints/api/folders/_path_/_server.ts.js-BjT2qPMT.js.map +1 -0
  107. package/build/server/chunks/entries/endpoints/api/folders/_server.ts.js-DYRLsoT7.js +31 -0
  108. package/build/server/chunks/entries/endpoints/api/folders/_server.ts.js-DYRLsoT7.js.map +1 -0
  109. package/build/server/chunks/entries/endpoints/api/manifests/_name_/_server.ts.js-BbN2fGNN.js +24 -0
  110. package/build/server/chunks/entries/endpoints/api/manifests/_name_/_server.ts.js-BbN2fGNN.js.map +1 -0
  111. package/build/server/chunks/entries/endpoints/api/manifests/_server.ts.js-b_MKZ41b.js +31 -0
  112. package/build/server/chunks/entries/endpoints/api/manifests/_server.ts.js-b_MKZ41b.js.map +1 -0
  113. package/build/server/chunks/entries/endpoints/api/state/_server.ts.js-evEfMpvn.js +24 -0
  114. package/build/server/chunks/entries/endpoints/api/state/_server.ts.js-evEfMpvn.js.map +1 -0
  115. package/build/server/chunks/entries/endpoints/files/_...path_/_server.ts.js-C04XE_1w.js +27 -0
  116. package/build/server/chunks/entries/endpoints/files/_...path_/_server.ts.js-C04XE_1w.js.map +1 -0
  117. package/build/server/chunks/entries/endpoints/files/proxy/_...path_/_server.ts.js-DB8TdoEv.js +24 -0
  118. package/build/server/chunks/entries/endpoints/files/proxy/_...path_/_server.ts.js-DB8TdoEv.js.map +1 -0
  119. package/build/server/chunks/entries/endpoints/files/raw/_...path_/_server.ts.js-BrpaijZO.js +24 -0
  120. package/build/server/chunks/entries/endpoints/files/raw/_...path_/_server.ts.js-BrpaijZO.js.map +1 -0
  121. package/build/server/chunks/entries/hooks.server.js-BJJwZW_I.js +23 -0
  122. package/build/server/chunks/entries/hooks.server.js-BJJwZW_I.js.map +1 -0
  123. package/build/server/chunks/handler-DnbS2t1B.js +1475 -0
  124. package/build/server/chunks/handler-DnbS2t1B.js.map +1 -0
  125. package/build/server/chunks/index.js-g77q3Boj.js +3789 -0
  126. package/build/server/chunks/index.js-g77q3Boj.js.map +1 -0
  127. package/build/server/chunks/manifest.js-qmEXbstS.js +149 -0
  128. package/build/server/chunks/manifest.js-qmEXbstS.js.map +1 -0
  129. package/build/server/chunks/nodes/0.js-Bk6IZ-vD.js +11 -0
  130. package/build/server/chunks/nodes/0.js-Bk6IZ-vD.js.map +1 -0
  131. package/build/server/chunks/nodes/1.js-H-qwo4GJ.js +7 -0
  132. package/build/server/chunks/nodes/1.js-H-qwo4GJ.js.map +1 -0
  133. package/build/server/chunks/nodes/2.js-DRpXVLwp.js +7 -0
  134. package/build/server/chunks/nodes/2.js-DRpXVLwp.js.map +1 -0
  135. package/build/server/chunks/nodes/3.js-CDEzNFeU.js +7 -0
  136. package/build/server/chunks/nodes/3.js-CDEzNFeU.js.map +1 -0
  137. package/build/server/chunks/nodes/4.js-BKL7LSSm.js +7 -0
  138. package/build/server/chunks/nodes/4.js-BKL7LSSm.js.map +1 -0
  139. package/build/shims.js +33 -0
  140. package/build/shims.js.map +1 -0
  141. package/dist/cli.d.ts +2 -1
  142. package/dist/cli.js +116 -1336
  143. package/dist/config.d.ts +3 -2
  144. package/dist/config.js +2 -2
  145. package/dist/core/api-types.d.ts +141 -0
  146. package/dist/core/api-types.js +1 -0
  147. package/dist/core/asset-id.d.ts +28 -0
  148. package/dist/core/asset-id.js +59 -0
  149. package/dist/core/asset-reference.d.ts +23 -0
  150. package/dist/core/asset-reference.js +15 -0
  151. package/dist/core/canonicalize.d.ts +9 -0
  152. package/dist/core/canonicalize.js +36 -0
  153. package/dist/core/chroma-key.d.ts +30 -0
  154. package/dist/core/chroma-key.js +55 -0
  155. package/dist/core/config.d.ts +35 -0
  156. package/dist/core/config.js +4 -0
  157. package/dist/core/folder-path.d.ts +19 -0
  158. package/dist/core/folder-path.js +86 -0
  159. package/dist/core/index.d.ts +33 -499
  160. package/dist/core/index.js +17 -962
  161. package/dist/core/ingest.d.ts +24 -0
  162. package/dist/core/ingest.js +42 -0
  163. package/dist/core/library.d.ts +54 -0
  164. package/dist/core/library.js +138 -0
  165. package/dist/core/manifest-appearance.d.ts +35 -0
  166. package/dist/core/manifest-appearance.js +123 -0
  167. package/dist/core/manifest-entry.d.ts +104 -0
  168. package/dist/core/manifest-entry.js +1 -0
  169. package/dist/core/manifest-membership.d.ts +56 -0
  170. package/dist/core/manifest-membership.js +54 -0
  171. package/dist/core/plugins/audio.d.ts +26 -0
  172. package/dist/core/plugins/audio.js +44 -0
  173. package/dist/core/plugins/chroma-key-video.d.ts +29 -0
  174. package/dist/core/plugins/chroma-key-video.js +69 -0
  175. package/dist/core/plugins/contract.d.ts +35 -0
  176. package/dist/core/plugins/contract.js +1 -0
  177. package/dist/core/plugins/image.d.ts +30 -0
  178. package/dist/core/plugins/image.js +45 -0
  179. package/dist/core/plugins/registry.d.ts +16 -0
  180. package/dist/core/plugins/registry.js +52 -0
  181. package/dist/core/plugins/slice.d.ts +22 -0
  182. package/dist/core/plugins/slice.js +60 -0
  183. package/dist/core/plugins/video.d.ts +45 -0
  184. package/dist/core/plugins/video.js +77 -0
  185. package/dist/core/reference-graph.d.ts +41 -0
  186. package/dist/core/reference-graph.js +138 -0
  187. package/dist/core/slice-data.d.ts +61 -0
  188. package/dist/core/slice-data.js +49 -0
  189. package/dist/runtime/chroma-key-gl.d.ts +40 -22
  190. package/dist/runtime/chroma-key-gl.js +189 -183
  191. package/dist/runtime/components/ChromaKeyVideo.svelte +3 -3
  192. package/dist/runtime/components/ChromaKeyVideo.svelte.d.ts +21 -0
  193. package/dist/runtime/components/Image.svelte +1 -1
  194. package/dist/runtime/components/Image.svelte.d.ts +9 -0
  195. package/dist/runtime/components/Slice.svelte +1 -1
  196. package/dist/runtime/components/Slice.svelte.d.ts +19 -0
  197. package/dist/runtime/components/SliceCanvas.svelte +3 -3
  198. package/dist/runtime/components/SliceCanvas.svelte.d.ts +10 -0
  199. package/dist/runtime/components/SliceDom.svelte +3 -3
  200. package/dist/runtime/components/SliceDom.svelte.d.ts +10 -0
  201. package/dist/runtime/components/Video.svelte +2 -2
  202. package/dist/runtime/components/Video.svelte.d.ts +18 -0
  203. package/dist/runtime/geometry.d.ts +55 -35
  204. package/dist/runtime/geometry.js +186 -191
  205. package/dist/runtime/index.d.ts +9 -9
  206. package/dist/runtime/index.js +9 -9
  207. package/dist/runtime/kind-handlers.d.ts +33 -30
  208. package/dist/runtime/kind-handlers.js +85 -67
  209. package/dist/runtime/manifest.d.ts +53 -47
  210. package/dist/runtime/manifest.js +133 -113
  211. package/dist/runtime/observe-border-box-size.d.ts +1 -4
  212. package/dist/runtime/observe-border-box-size.js +9 -10
  213. package/dist/runtime/preload-registry.d.ts +22 -8
  214. package/dist/runtime/preload-registry.js +65 -62
  215. package/dist/server/build.d.ts +8 -0
  216. package/dist/server/build.js +25 -0
  217. package/dist/server/check.d.ts +24 -0
  218. package/dist/server/check.js +199 -0
  219. package/dist/server/cli-commands.d.ts +25 -0
  220. package/dist/server/cli-commands.js +1178 -0
  221. package/dist/server/cli-init.d.ts +3 -0
  222. package/dist/server/cli-init.js +53 -0
  223. package/dist/server/cli-io.d.ts +46 -0
  224. package/dist/server/cli-io.js +105 -0
  225. package/dist/server/codegen.d.ts +58 -0
  226. package/dist/server/codegen.js +185 -0
  227. package/dist/server/config-loader.d.ts +35 -0
  228. package/dist/server/config-loader.js +79 -0
  229. package/dist/server/context.d.ts +8 -0
  230. package/dist/server/context.js +19 -0
  231. package/dist/server/folder-filesystem.d.ts +7 -0
  232. package/dist/server/folder-filesystem.js +39 -0
  233. package/dist/server/http.d.ts +12 -0
  234. package/dist/server/http.js +100 -0
  235. package/dist/server/index.d.ts +17 -0
  236. package/dist/server/index.js +9 -0
  237. package/dist/server/job-hash.d.ts +10 -0
  238. package/dist/server/job-hash.js +23 -0
  239. package/dist/server/library-store.d.ts +82 -0
  240. package/dist/server/library-store.js +763 -0
  241. package/dist/server/operations.d.ts +87 -0
  242. package/dist/server/operations.js +427 -0
  243. package/dist/server/plugins/audio.d.ts +8 -0
  244. package/dist/server/plugins/audio.js +41 -0
  245. package/dist/server/plugins/chroma-key-video.d.ts +9 -0
  246. package/dist/server/plugins/chroma-key-video.js +40 -0
  247. package/dist/server/plugins/config.d.ts +13 -0
  248. package/dist/server/plugins/config.js +32 -0
  249. package/dist/server/plugins/contract.d.ts +114 -0
  250. package/dist/server/plugins/contract.js +16 -0
  251. package/dist/server/plugins/image.d.ts +9 -0
  252. package/dist/server/plugins/image.js +43 -0
  253. package/dist/server/plugins/slice.d.ts +15 -0
  254. package/dist/server/plugins/slice.js +76 -0
  255. package/dist/server/plugins/video.d.ts +7 -0
  256. package/dist/server/plugins/video.js +54 -0
  257. package/dist/server/plugins.d.ts +23 -0
  258. package/dist/server/plugins.js +35 -0
  259. package/dist/server/processing/audio-processing.d.ts +17 -0
  260. package/dist/server/processing/audio-processing.js +46 -0
  261. package/dist/server/processing/ffmpeg.d.ts +9 -0
  262. package/dist/server/processing/ffmpeg.js +50 -0
  263. package/dist/server/processing/image-processing.d.ts +16 -0
  264. package/dist/server/processing/image-processing.js +26 -0
  265. package/dist/server/processing/media-probe.d.ts +15 -0
  266. package/dist/server/processing/media-probe.js +27 -0
  267. package/dist/server/processing/processor.d.ts +50 -0
  268. package/dist/server/processing/processor.js +158 -0
  269. package/dist/server/processing/video-processing.d.ts +35 -0
  270. package/dist/server/processing/video-processing.js +87 -0
  271. package/dist/server/server.d.ts +13 -0
  272. package/dist/server/server.js +57 -0
  273. package/dist/server/start.d.ts +13 -0
  274. package/dist/server/start.js +80 -0
  275. package/package.json +31 -16
  276. package/dist/build-CZYFLLvl.js +0 -191
  277. package/dist/core/image-Dqmz8FXS.js +0 -54
  278. package/dist/core/reference-graph-CjuHbLDw.d.ts +0 -280
  279. package/dist/core/testing.d.ts +0 -27
  280. package/dist/core/testing.js +0 -80
  281. package/dist/editor/200.html +0 -37
  282. package/dist/editor/_app/immutable/assets/2.DIbbW7U1.css +0 -1
  283. package/dist/editor/_app/immutable/assets/3.C-9vFQ9A.css +0 -1
  284. package/dist/editor/_app/immutable/assets/4.BS8ElpOV.css +0 -1
  285. package/dist/editor/_app/immutable/assets/ConfirmDialog.CHEISE-L.css +0 -1
  286. package/dist/editor/_app/immutable/assets/LibraryContextMenu.CDjCmdV-.css +0 -1
  287. package/dist/editor/_app/immutable/chunks/Cx6qtxJg.js +0 -1
  288. package/dist/editor/_app/immutable/chunks/DjdrdRzT.js +0 -1
  289. package/dist/editor/_app/immutable/chunks/n7mvYc42.js +0 -5
  290. package/dist/editor/_app/immutable/entry/start.C8HHOLly.js +0 -1
  291. package/dist/editor/_app/immutable/nodes/2.BrA0Hyzu.js +0 -3
  292. package/dist/editor/_app/immutable/nodes/3.WO7tZH_d.js +0 -104
  293. package/dist/editor/_app/immutable/nodes/4.DQtx17aW.js +0 -2
  294. package/dist/editor/_app/version.json +0 -1
  295. package/dist/index.d.ts +0 -370
  296. package/dist/index.js +0 -4
  297. package/dist/start-Bhnqt9Dc.js +0 -279
  298. package/dist/start-D2IXOrni.js +0 -2
  299. /package/{dist/editor → build/client}/_app/immutable/assets/0.DLhIsYA_.css +0 -0
  300. /package/{dist/editor → build/client}/_app/immutable/chunks/Bjy-W4x2.js +0 -0
  301. /package/{dist/editor → build/client}/_app/immutable/chunks/CNRz3sSw.js +0 -0
  302. /package/{dist/editor → build/client}/_app/immutable/chunks/CO4RBJfa.js +0 -0
  303. /package/{dist/editor → build/client}/_app/immutable/chunks/xihTtKlq.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
package/build/index.js ADDED
@@ -0,0 +1,145 @@
1
+ import http from 'node:http';
2
+ import fs__default from 'node:fs';
3
+ import process from 'node:process';
4
+ import { p as polka, h as handler, f as format_listening_address } from './server/chunks/handler-DnbS2t1B.js';
5
+ import { env, timeout_env } from './env.js';
6
+ import { rm } from 'node:fs/promises';
7
+ import './shims.js';
8
+ import 'node:buffer';
9
+ import 'node:crypto';
10
+ import 'node:path';
11
+ import 'node:timers';
12
+ import 'node:querystring';
13
+ import 'node:stream';
14
+ import './server/chunks/chunks/shared.js-B1gC9MiJ.js';
15
+ import './server/chunks/chunks/internal.js-DGo2jPcg.js';
16
+ import './server/chunks/chunks/utils.js-DnEJ3UjO.js';
17
+ import './server/chunks/index.js-g77q3Boj.js';
18
+ import './server/chunks/chunks/internal2.js-BlXt2rfE.js';
19
+ import './server/chunks/chunks/exports.js-C0rwMMtk.js';
20
+ import './server/chunks/chunks/routing.js-y-tryuip.js';
21
+ import './server/chunks/manifest.js-qmEXbstS.js';
22
+ import 'node:url';
23
+
24
+ const path = env('SOCKET_PATH', false);
25
+ const host = env('HOST', '0.0.0.0');
26
+ const port = env('PORT', !path && '3000');
27
+
28
+ const shutdown_timeout = parseInt(env('SHUTDOWN_TIMEOUT', '30'));
29
+ const idle_timeout = parseInt(env('IDLE_TIMEOUT', '0'));
30
+ const listen_pid = parseInt(env('LISTEN_PID', '0'));
31
+ const listen_fds = parseInt(env('LISTEN_FDS', '0'));
32
+ // https://www.freedesktop.org/software/systemd/man/latest/sd_listen_fds.html
33
+ const SD_LISTEN_FDS_START = 3;
34
+
35
+ if (listen_pid !== 0 && listen_pid !== process.pid) {
36
+ throw new Error(`received LISTEN_PID ${listen_pid} but current process id is ${process.pid}`);
37
+ }
38
+ if (listen_fds > 1) {
39
+ throw new Error(
40
+ `only one socket is allowed for socket activation, but LISTEN_FDS was set to ${listen_fds}`
41
+ );
42
+ }
43
+
44
+ const socket_activation = listen_pid === process.pid && listen_fds === 1;
45
+
46
+ let requests = 0;
47
+ /** @type {NodeJS.Timeout | void} */
48
+ let shutdown_timeout_id;
49
+ /** @type {NodeJS.Timeout | void} */
50
+ let idle_timeout_id;
51
+
52
+ // Initialize the HTTP server here so that we can set properties before starting to listen.
53
+ // Otherwise, polka delays creating the server until listen() is called. Settings these
54
+ // properties after the server has started listening could lead to race conditions.
55
+ const httpServer = http.createServer();
56
+
57
+ const keep_alive_timeout = timeout_env('KEEP_ALIVE_TIMEOUT');
58
+ if (keep_alive_timeout !== undefined) {
59
+ // Convert the keep-alive timeout from seconds to milliseconds (the unit Node.js expects).
60
+ httpServer.keepAliveTimeout = keep_alive_timeout * 1000;
61
+ }
62
+
63
+ const headers_timeout = timeout_env('HEADERS_TIMEOUT');
64
+ if (headers_timeout !== undefined) {
65
+ // Convert the headers timeout from seconds to milliseconds (the unit Node.js expects).
66
+ httpServer.headersTimeout = headers_timeout * 1000;
67
+ }
68
+
69
+ const server = polka({ server: httpServer }).use(handler);
70
+
71
+ if (socket_activation) {
72
+ server.listen({ fd: SD_LISTEN_FDS_START }, () => {
73
+ console.log(`Listening on file descriptor ${SD_LISTEN_FDS_START}`);
74
+ });
75
+ } else {
76
+ if (path) {
77
+ try {
78
+ if (fs__default.statSync(path).size === 0) {
79
+ await rm(path);
80
+ }
81
+ } catch {
82
+ // ignore
83
+ }
84
+ }
85
+
86
+ server.listen({ path, host, port }, () => {
87
+ console.log(`Listening on ${format_listening_address(path, host, port, httpServer.address())}`);
88
+ });
89
+ }
90
+
91
+ /** @param {'SIGINT' | 'SIGTERM' | 'IDLE'} reason */
92
+ function graceful_shutdown(reason) {
93
+ if (shutdown_timeout_id) return;
94
+
95
+ // If a connection was opened with a keep-alive header close() will wait for the connection to
96
+ // time out rather than close it even if it is not handling any requests, so call this first
97
+ httpServer.closeIdleConnections();
98
+
99
+ httpServer.close((error) => {
100
+ // occurs if the server is already closed
101
+ if (error) return;
102
+
103
+ if (shutdown_timeout_id) {
104
+ clearTimeout(shutdown_timeout_id);
105
+ }
106
+ if (idle_timeout_id) {
107
+ clearTimeout(idle_timeout_id);
108
+ }
109
+
110
+ // @ts-expect-error custom events cannot be typed
111
+ process.emit('sveltekit:shutdown', reason);
112
+ });
113
+
114
+ shutdown_timeout_id = setTimeout(() => httpServer.closeAllConnections(), shutdown_timeout * 1000);
115
+ }
116
+
117
+ httpServer.on(
118
+ 'request',
119
+ /** @param {import('node:http').IncomingMessage} req */
120
+ (req) => {
121
+ requests++;
122
+
123
+ if (socket_activation && idle_timeout_id) {
124
+ idle_timeout_id = clearTimeout(idle_timeout_id);
125
+ }
126
+
127
+ req.on('close', () => {
128
+ requests--;
129
+
130
+ if (shutdown_timeout_id) {
131
+ // close connections as soon as they become idle, so they don't accept new requests
132
+ httpServer.closeIdleConnections();
133
+ }
134
+ if (requests === 0 && socket_activation && idle_timeout) {
135
+ idle_timeout_id = setTimeout(() => graceful_shutdown('IDLE'), idle_timeout * 1000);
136
+ }
137
+ });
138
+ }
139
+ );
140
+
141
+ process.on('SIGTERM', graceful_shutdown);
142
+ process.on('SIGINT', graceful_shutdown);
143
+
144
+ export { host, path, port, server };
145
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../.svelte-kit/adapter-node/entries/index.js"],"sourcesContent":["import http from 'node:http';\nimport fs__default from 'node:fs';\nimport process from 'node:process';\nimport { handler } from './handler.js';\nimport { env, timeout_env } from './env.js';\nimport { p as polka } from './chunks/vendor.js';\nimport { rm } from 'node:fs/promises';\nimport { format_listening_address } from './utils.js';\n\nconst path = env('SOCKET_PATH', false);\nconst host = env('HOST', '0.0.0.0');\nconst port = env('PORT', !path && '3000');\n\nconst shutdown_timeout = parseInt(env('SHUTDOWN_TIMEOUT', '30'));\nconst idle_timeout = parseInt(env('IDLE_TIMEOUT', '0'));\nconst listen_pid = parseInt(env('LISTEN_PID', '0'));\nconst listen_fds = parseInt(env('LISTEN_FDS', '0'));\n// https://www.freedesktop.org/software/systemd/man/latest/sd_listen_fds.html\nconst SD_LISTEN_FDS_START = 3;\n\nif (listen_pid !== 0 && listen_pid !== process.pid) {\n\tthrow new Error(`received LISTEN_PID ${listen_pid} but current process id is ${process.pid}`);\n}\nif (listen_fds > 1) {\n\tthrow new Error(\n\t\t`only one socket is allowed for socket activation, but LISTEN_FDS was set to ${listen_fds}`\n\t);\n}\n\nconst socket_activation = listen_pid === process.pid && listen_fds === 1;\n\nlet requests = 0;\n/** @type {NodeJS.Timeout | void} */\nlet shutdown_timeout_id;\n/** @type {NodeJS.Timeout | void} */\nlet idle_timeout_id;\n\n// Initialize the HTTP server here so that we can set properties before starting to listen.\n// Otherwise, polka delays creating the server until listen() is called. Settings these\n// properties after the server has started listening could lead to race conditions.\nconst httpServer = http.createServer();\n\nconst keep_alive_timeout = timeout_env('KEEP_ALIVE_TIMEOUT');\nif (keep_alive_timeout !== undefined) {\n\t// Convert the keep-alive timeout from seconds to milliseconds (the unit Node.js expects).\n\thttpServer.keepAliveTimeout = keep_alive_timeout * 1000;\n}\n\nconst headers_timeout = timeout_env('HEADERS_TIMEOUT');\nif (headers_timeout !== undefined) {\n\t// Convert the headers timeout from seconds to milliseconds (the unit Node.js expects).\n\thttpServer.headersTimeout = headers_timeout * 1000;\n}\n\nconst server = polka({ server: httpServer }).use(handler);\n\nif (socket_activation) {\n\tserver.listen({ fd: SD_LISTEN_FDS_START }, () => {\n\t\tconsole.log(`Listening on file descriptor ${SD_LISTEN_FDS_START}`);\n\t});\n} else {\n\tif (path) {\n\t\ttry {\n\t\t\tif (fs__default.statSync(path).size === 0) {\n\t\t\t\tawait rm(path);\n\t\t\t}\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\t}\n\n\tserver.listen({ path, host, port }, () => {\n\t\tconsole.log(`Listening on ${format_listening_address(path, host, port, httpServer.address())}`);\n\t});\n}\n\n/** @param {'SIGINT' | 'SIGTERM' | 'IDLE'} reason */\nfunction graceful_shutdown(reason) {\n\tif (shutdown_timeout_id) return;\n\n\t// If a connection was opened with a keep-alive header close() will wait for the connection to\n\t// time out rather than close it even if it is not handling any requests, so call this first\n\thttpServer.closeIdleConnections();\n\n\thttpServer.close((error) => {\n\t\t// occurs if the server is already closed\n\t\tif (error) return;\n\n\t\tif (shutdown_timeout_id) {\n\t\t\tclearTimeout(shutdown_timeout_id);\n\t\t}\n\t\tif (idle_timeout_id) {\n\t\t\tclearTimeout(idle_timeout_id);\n\t\t}\n\n\t\t// @ts-expect-error custom events cannot be typed\n\t\tprocess.emit('sveltekit:shutdown', reason);\n\t});\n\n\tshutdown_timeout_id = setTimeout(() => httpServer.closeAllConnections(), shutdown_timeout * 1000);\n}\n\nhttpServer.on(\n\t'request',\n\t/** @param {import('node:http').IncomingMessage} req */\n\t(req) => {\n\t\trequests++;\n\n\t\tif (socket_activation && idle_timeout_id) {\n\t\t\tidle_timeout_id = clearTimeout(idle_timeout_id);\n\t\t}\n\n\t\treq.on('close', () => {\n\t\t\trequests--;\n\n\t\t\tif (shutdown_timeout_id) {\n\t\t\t\t// close connections as soon as they become idle, so they don't accept new requests\n\t\t\t\thttpServer.closeIdleConnections();\n\t\t\t}\n\t\t\tif (requests === 0 && socket_activation && idle_timeout) {\n\t\t\t\tidle_timeout_id = setTimeout(() => graceful_shutdown('IDLE'), idle_timeout * 1000);\n\t\t\t}\n\t\t});\n\t}\n);\n\nprocess.on('SIGTERM', graceful_shutdown);\nprocess.on('SIGINT', graceful_shutdown);\n\nexport { host, path, port, server };\n"],"names":[],"mappings":"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"}
@@ -0,0 +1,429 @@
1
+ import './core.js-xfrkaQpS.js';
2
+ import { r as rawFileNameOfPath, f as folderOfRawPath } from './folder-path.js-ytx9ucgg.js';
3
+ import { s as serverPluginsByType, i as isRecord, L as LibraryStore, a as serverPluginForType, p as processAssets, g as generateManifestModules, c as collectAllReferences, d as descriptorsByType, b as computeLibraryMembership, e as allDeliveredAssetIds, f as compareCodeUnits, r as readCurrentProxy, h as encodeRelativePathForUrl } from './library-store.js-ZLudCJlT.js';
4
+ import { isAbsolute, resolve, join } from 'node:path';
5
+ import { existsSync } from 'node:fs';
6
+ import { createJiti } from 'jiti';
7
+
8
+ //#region src/lib/server/config-loader.ts
9
+ /**
10
+ * Loads and resolves the host's `fundus.config.ts` through jiti, validates
11
+ * the shape, resolves all paths to
12
+ * absolute, and merges the built-in plugin preset defaults under the host's.
13
+ */
14
+ function requiredString(config, key) {
15
+ const value = config[key];
16
+ if (typeof value !== "string" || value.length === 0) throw new Error(`fundus.config: "${key}" must be a non-empty string.`);
17
+ return value;
18
+ }
19
+ function resolvePath(projectRoot, value) {
20
+ return resolve(projectRoot, value);
21
+ }
22
+ function configDefinitionsFor(registry) {
23
+ const byNamespace = /* @__PURE__ */ new Map();
24
+ for (const plugin of Object.values(registry)) for (const definition of plugin.configDefinitions) {
25
+ const existing = byNamespace.get(definition.namespace);
26
+ if (existing && existing !== definition) throw new Error(`Plugins provide conflicting config definitions for "plugins.${definition.namespace}".`);
27
+ byNamespace.set(definition.namespace, definition);
28
+ }
29
+ return [...byNamespace.values()];
30
+ }
31
+ /** Pure resolution step (testable without a config file on disk). */
32
+ function resolveConfig(projectRoot, value, registry = serverPluginsByType) {
33
+ if (!isRecord(value)) throw new Error("fundus.config must default-export a configuration object.");
34
+ const proxyBasePath = requiredString(value, "proxyBasePath");
35
+ if (!proxyBasePath.endsWith("/")) throw new Error("fundus.config: \"proxyBasePath\" must end with \"/\".");
36
+ const plugins = value.plugins === void 0 ? {} : value.plugins;
37
+ if (!isRecord(plugins)) throw new Error("fundus.config: \"plugins\" must be an object.");
38
+ const resolvedPlugins = {};
39
+ for (const definition of configDefinitionsFor(registry)) resolvedPlugins[definition.namespace] = definition.resolve({
40
+ projectRoot,
41
+ value: plugins[definition.namespace]
42
+ });
43
+ return {
44
+ rawDir: resolvePath(projectRoot, requiredString(value, "rawDir")),
45
+ proxyDir: resolvePath(projectRoot, requiredString(value, "proxyDir")),
46
+ library: resolvePath(projectRoot, requiredString(value, "library")),
47
+ manifestsDir: resolvePath(projectRoot, requiredString(value, "manifestsDir")),
48
+ proxyBasePath,
49
+ plugins: resolvedPlugins
50
+ };
51
+ }
52
+ /** Load `fundus.config.ts` from the host project root. */
53
+ async function loadConfig(projectRoot) {
54
+ const root = resolve(projectRoot);
55
+ const configPath = resolve(root, "fundus.config.ts");
56
+ if (!existsSync(configPath)) throw new Error(`No fundus.config.ts found in ${root}.`);
57
+ let module;
58
+ try {
59
+ module = await createJiti(import.meta.url, { interopDefault: false }).import(configPath);
60
+ } catch (cause) {
61
+ throw new Error(`Cannot load fundus.config.ts: ${cause instanceof Error ? cause.message : String(cause)}`);
62
+ }
63
+ return resolveConfig(root, isRecord(module) && "default" in module ? module.default : module);
64
+ }
65
+ //#endregion
66
+ //#region src/lib/server/operations.ts
67
+ /**
68
+ * The one operations layer: builds the state payload and runs
69
+ * every mutation through the autosave chain — write library → process affected
70
+ * assets → regenerate codegen → return fresh state. Both the REST server
71
+ * and the CLI consume this class, so every
72
+ * operation has exactly one implementation and there is no other save path.
73
+ */
74
+ /**
75
+ * The CLI's `--parameters` merge semantics (M7): a SHALLOW merge at the top
76
+ * level onto the current parameters — a nested object value replaces the whole
77
+ * current object under that key, a top-level `null` clears an optional field,
78
+ * and an asset reference is set with the normal `{"$asset": "<id>"}` marker.
79
+ * The merged result still passes the owning plugin's full validation.
80
+ */
81
+ function mergeParameterPatch(currentParameters, patch) {
82
+ if (typeof patch !== "object" || patch === null || Array.isArray(patch)) throw new Error("The parameter patch must be a JSON object, e.g. {\"preset\": \"default\"}.");
83
+ const merged = typeof currentParameters === "object" && currentParameters !== null && !Array.isArray(currentParameters) ? { ...currentParameters } : {};
84
+ for (const [key, value] of Object.entries(patch)) if (value === null) delete merged[key];
85
+ else merged[key] = value;
86
+ return merged;
87
+ }
88
+ var FundusOperations = class {
89
+ #config;
90
+ #registry;
91
+ #store;
92
+ constructor(config, registry = serverPluginsByType) {
93
+ this.#config = config;
94
+ this.#registry = registry;
95
+ this.#store = new LibraryStore(config, registry);
96
+ }
97
+ get config() {
98
+ return this.#config;
99
+ }
100
+ get store() {
101
+ return this.#store;
102
+ }
103
+ /** Read-only state snapshot (no processing). */
104
+ async state() {
105
+ return this.#buildState(await this.#store.read(), []);
106
+ }
107
+ /**
108
+ * Ingest an upload: store the raw file + record, then let the owning
109
+ * plugin's optional `seedIngestParameters` derive better starting
110
+ * parameters from the stored raw file (slices: insets from the image
111
+ * dimensions, pixel ratio from the file name — the schema default can't
112
+ * know either). The CLI additionally applies a parameter patch and/or an
113
+ * explicit membership set in the same operation; a failing application
114
+ * rolls the whole ingest back, so a failed ingest leaves nothing behind.
115
+ */
116
+ async ingest(options) {
117
+ let library = await this.#store.ingest(options);
118
+ try {
119
+ const plugin = serverPluginForType(options.type, this.#registry);
120
+ if (plugin.seedIngestParameters) {
121
+ const record = library.assets[options.id];
122
+ const seeded = await plugin.seedIngestParameters({
123
+ rawPath: join(this.#config.rawDir, record.raw),
124
+ rawFileName: rawFileNameOfPath(record.raw),
125
+ parameters: plugin.descriptor.validateParameters(record.parameters),
126
+ config: this.#config
127
+ });
128
+ if (seeded !== void 0) library = await this.#store.updateParameters(options.id, seeded);
129
+ }
130
+ if (options.parametersPatch !== void 0 || options.manifests !== void 0) library = await this.#applyAssetChanges(library, options.id, {
131
+ parametersPatch: options.parametersPatch,
132
+ manifests: options.manifests
133
+ });
134
+ } catch (cause) {
135
+ await this.#store.deleteAsset(options.id);
136
+ throw cause;
137
+ }
138
+ return this.#afterMutation(library);
139
+ }
140
+ /** Apply a PATCH body: parameters and/or manifests and/or a rename — in that order. */
141
+ async patchAsset(id, body) {
142
+ let library = await this.#store.read();
143
+ this.#requireAsset(library, id);
144
+ if (body.parameters !== void 0) library = await this.#store.updateParameters(id, body.parameters);
145
+ if (body.manifests !== void 0) {
146
+ if (!Array.isArray(body.manifests) || body.manifests.some((name) => typeof name !== "string")) throw new Error("\"manifests\" must be an array of manifest names.");
147
+ library = await this.#store.setManifests(id, body.manifests);
148
+ }
149
+ if (body.renameTo !== void 0) {
150
+ if (typeof body.renameTo !== "string") throw new Error("\"renameTo\" must be a string.");
151
+ library = await this.#store.renameAsset(id, body.renameTo);
152
+ }
153
+ if (body.folder !== void 0) {
154
+ if (typeof body.folder !== "string") throw new Error("\"folder\" must be a string.");
155
+ library = await this.#store.moveAsset(body.renameTo ?? id, body.folder);
156
+ }
157
+ return this.#afterMutation(library);
158
+ }
159
+ async moveAsset(id, folder) {
160
+ return this.#afterMutation(await this.#store.moveAsset(id, folder));
161
+ }
162
+ /** Move a selected asset set as one editor action and roll back on any failure. */
163
+ async moveAssets(assetIds, folder) {
164
+ const uniqueIds = [...new Set(assetIds)];
165
+ if (uniqueIds.length === 0) throw new Error("At least one asset id is required.");
166
+ const originalFolders = /* @__PURE__ */ new Map();
167
+ const library = await this.#store.read();
168
+ for (const id of uniqueIds) {
169
+ this.#requireAsset(library, id);
170
+ originalFolders.set(id, folderOfRawPath(library.assets[id].raw));
171
+ }
172
+ const movedIds = [];
173
+ try {
174
+ let updated = library;
175
+ for (const id of uniqueIds) {
176
+ if (originalFolders.get(id) === folder) continue;
177
+ updated = await this.#store.moveAsset(id, folder);
178
+ movedIds.push(id);
179
+ }
180
+ return this.#afterMutation(updated);
181
+ } catch (cause) {
182
+ for (const id of movedIds.reverse()) await this.#store.moveAsset(id, originalFolders.get(id) ?? "");
183
+ throw cause;
184
+ }
185
+ }
186
+ async createFolder(path) {
187
+ return this.#afterMutation(await this.#store.createFolder(path));
188
+ }
189
+ async renameFolder(path, newName) {
190
+ return this.#afterMutation(await this.#store.renameFolder(path, newName));
191
+ }
192
+ async moveFolder(path, parent) {
193
+ return this.#afterMutation(await this.#store.moveFolder(path, parent));
194
+ }
195
+ async deleteFolder(path) {
196
+ const result = await this.#store.deleteFolder(path);
197
+ return this.#afterMutation(result.library);
198
+ }
199
+ /**
200
+ * CLI-facing asset update (M7): shallow-merge a parameter patch and/or
201
+ * replace the explicit manifest membership — validating the *result* before
202
+ * anything is persisted, so a change that would leave the library invalid
203
+ * (dangling or cyclic reference, unknown manifest, invalid parameters) is
204
+ * rejected with nothing written. The REST `patchAsset` keeps the editor's
205
+ * lenient replace semantics.
206
+ */
207
+ async setAsset(id, changes) {
208
+ const library = await this.#store.read();
209
+ this.#requireAsset(library, id);
210
+ return this.#afterMutation(await this.#applyAssetChanges(library, id, changes));
211
+ }
212
+ /**
213
+ * CLI-facing rename (M7): rejects a rename that would break references —
214
+ * a referrer keeps pointing at the old id, so renaming a referenced asset
215
+ * introduces dangling-reference errors. Update the referrers first.
216
+ */
217
+ async renameAsset(id, newId) {
218
+ const library = await this.#store.read();
219
+ this.#requireAsset(library, id);
220
+ if (newId !== id && !Object.hasOwn(library.assets, newId)) {
221
+ const candidate = structuredClone(library);
222
+ candidate.assets[newId] = candidate.assets[id];
223
+ delete candidate.assets[id];
224
+ await this.#assertNoIntroducedIssues(library, candidate);
225
+ }
226
+ return this.#afterMutation(await this.#store.renameAsset(id, newId));
227
+ }
228
+ /**
229
+ * Delete an asset: the record, its raw file, and its proxies. With
230
+ * `failOnIntroducedIssues` (the CLI), a delete that would break references
231
+ * (the asset is a reference target) is rejected before anything —
232
+ * including the raw file — is removed; the REST route stays lenient.
233
+ */
234
+ async deleteAsset(id, options) {
235
+ if (options?.failOnIntroducedIssues) {
236
+ const library = await this.#store.read();
237
+ this.#requireAsset(library, id);
238
+ const candidate = structuredClone(library);
239
+ delete candidate.assets[id];
240
+ await this.#assertNoIntroducedIssues(library, candidate);
241
+ }
242
+ return this.#afterMutation(await this.#store.deleteAsset(id));
243
+ }
244
+ /** Delete a selected asset set as one lenient editor mutation. */
245
+ async deleteAssets(assetIds) {
246
+ const uniqueIds = [...new Set(assetIds)];
247
+ if (uniqueIds.length === 0) throw new Error("At least one asset id is required.");
248
+ return this.#afterMutation(await this.#store.deleteAssets(uniqueIds));
249
+ }
250
+ async createManifest(name) {
251
+ return this.#afterMutation(await this.#store.createManifest(name));
252
+ }
253
+ async setManifestAppearance(name, appearance) {
254
+ return this.#afterMutation(await this.#store.setManifestAppearance(name, appearance));
255
+ }
256
+ /** Apply a PATCH body: appearance fields and/or a rename — in that order. */
257
+ async patchManifest(name, body) {
258
+ let library = await this.#store.setManifestAppearance(name, {
259
+ color: body.color,
260
+ emoji: body.emoji
261
+ });
262
+ if (body.renameTo !== void 0) {
263
+ if (typeof body.renameTo !== "string") throw new Error("\"renameTo\" must be a string.");
264
+ library = await this.#store.renameManifest(name, body.renameTo);
265
+ }
266
+ return this.#afterMutation(library);
267
+ }
268
+ /**
269
+ * Rename a manifest: rewrites every asset's membership and replaces the
270
+ * generated module (the old one is pruned as a stray). Host code importing
271
+ * the module must be updated by hand — both the file name and the exported
272
+ * const change with the manifest name.
273
+ */
274
+ async renameManifest(name, newName) {
275
+ return this.#afterMutation(await this.#store.renameManifest(name, newName));
276
+ }
277
+ async deleteManifest(name) {
278
+ return this.#afterMutation(await this.#store.deleteManifest(name));
279
+ }
280
+ /** The autosave chain tail: process + regenerate, then report fresh state. */
281
+ async #afterMutation(library) {
282
+ const pipelineIssues = [];
283
+ const issues = await this.#store.validate(library);
284
+ if (issues.length === 0) try {
285
+ const report = await processAssets(this.#config, library, this.#registry);
286
+ await generateManifestModules(this.#config, library, report.proxies, this.#registry);
287
+ } catch (cause) {
288
+ pipelineIssues.push({ message: `Processing failed: ${cause instanceof Error ? cause.message : String(cause)}` });
289
+ }
290
+ return this.#buildState(library, pipelineIssues, issues);
291
+ }
292
+ async #buildState(library, extraIssues, precomputedIssues) {
293
+ const issues = [...precomputedIssues ?? await this.#store.validate(library), ...extraIssues];
294
+ const referencesByAsset = collectAllReferences(library, descriptorsByType(this.#registry));
295
+ const membershipByManifest = computeLibraryMembership(library, referencesByAsset);
296
+ const delivered = allDeliveredAssetIds(membershipByManifest);
297
+ const passiveManifestsByAsset = /* @__PURE__ */ new Map();
298
+ for (const manifestName of Object.keys(library.manifests).sort(compareCodeUnits)) for (const passiveMember of membershipByManifest[manifestName].passiveMembers) {
299
+ const passiveManifests = passiveManifestsByAsset.get(passiveMember.assetId) ?? [];
300
+ passiveManifests.push({
301
+ manifest: manifestName,
302
+ via: passiveMember.via
303
+ });
304
+ passiveManifestsByAsset.set(passiveMember.assetId, passiveManifests);
305
+ }
306
+ const incomingByAsset = /* @__PURE__ */ new Map();
307
+ for (const [referrerId, references] of Object.entries(referencesByAsset)) for (const reference of references) {
308
+ const incoming = incomingByAsset.get(reference.assetId) ?? [];
309
+ incoming.push({
310
+ field: reference.field,
311
+ assetId: referrerId
312
+ });
313
+ incomingByAsset.set(reference.assetId, incoming);
314
+ }
315
+ const assets = [];
316
+ for (const assetId of Object.keys(library.assets).sort(compareCodeUnits)) {
317
+ const record = library.assets[assetId];
318
+ const warnings = [];
319
+ for (const issue of issues) if (issue.assetId === assetId) warnings.push(issue.message);
320
+ if (record.manifests.length === 0 && !delivered.has(assetId)) warnings.push("In no manifest and not referenced by any delivered asset — nothing is processed or generated for it.");
321
+ let proxy = null;
322
+ if (delivered.has(assetId)) try {
323
+ const currentProxy = await readCurrentProxy(assetId, record, this.#config, this.#registry);
324
+ if (currentProxy) proxy = {
325
+ url: `/files/proxy/${encodeRelativePathForUrl(currentProxy.relativePath)}`,
326
+ upToDate: true,
327
+ ...currentProxy
328
+ };
329
+ else warnings.push("Proxy is stale or missing — it will be (re)processed on the next save.");
330
+ } catch (cause) {
331
+ warnings.push(cause instanceof Error ? cause.message : String(cause));
332
+ }
333
+ assets.push({
334
+ id: assetId,
335
+ type: record.type,
336
+ raw: record.raw,
337
+ folder: folderOfRawPath(record.raw),
338
+ rawUrl: `/files/raw/${encodeRelativePathForUrl(record.raw)}`,
339
+ rawHash: record.rawHash,
340
+ parameters: record.parameters,
341
+ manifests: record.manifests,
342
+ passiveManifests: passiveManifestsByAsset.get(assetId) ?? [],
343
+ proxy,
344
+ warnings,
345
+ references: {
346
+ outgoing: referencesByAsset[assetId].map((reference) => ({
347
+ field: reference.field,
348
+ assetId: reference.assetId
349
+ })),
350
+ incoming: incomingByAsset.get(assetId) ?? []
351
+ }
352
+ });
353
+ }
354
+ const proxySizeByAssetId = new Map(assets.filter((asset) => asset.proxy).map((asset) => [asset.id, asset.proxy?.fileSize ?? 0]));
355
+ const manifestMemberships = {};
356
+ const manifestDeliveredBytes = {};
357
+ for (const manifestName of Object.keys(library.manifests).sort(compareCodeUnits)) {
358
+ const membership = membershipByManifest[manifestName];
359
+ manifestMemberships[manifestName] = {
360
+ explicitMemberIds: membership.explicitMemberIds,
361
+ passiveMembers: membership.passiveMembers
362
+ };
363
+ let deliveredBytes = 0;
364
+ for (const deliveredAssetId of membership.deliveredAssetIds) deliveredBytes += proxySizeByAssetId.get(deliveredAssetId) ?? 0;
365
+ manifestDeliveredBytes[manifestName] = deliveredBytes;
366
+ }
367
+ const presetNames = {};
368
+ for (const [type, plugin] of Object.entries(this.#registry)) presetNames[type] = Object.keys(plugin.presets(this.#config)).sort();
369
+ return {
370
+ library,
371
+ assets,
372
+ issues,
373
+ presetNames,
374
+ manifestMemberships,
375
+ manifestDeliveredBytes
376
+ };
377
+ }
378
+ #requireAsset(library, id) {
379
+ if (!Object.hasOwn(library.assets, id)) throw new Error(`Unknown asset "${id}".`);
380
+ }
381
+ /**
382
+ * Apply a CLI asset change to the store, validating the resulting library
383
+ * on an in-memory candidate first — nothing is persisted when the change
384
+ * would introduce validation issues. Pre-existing issues never block an
385
+ * unrelated mutation (only *introduced* issues are rejected).
386
+ */
387
+ async #applyAssetChanges(library, id, changes) {
388
+ const candidate = structuredClone(library);
389
+ const candidateRecord = candidate.assets[id];
390
+ if (changes.parametersPatch !== void 0) candidateRecord.parameters = serverPluginForType(candidateRecord.type, this.#registry).descriptor.validateParameters(mergeParameterPatch(candidateRecord.parameters, changes.parametersPatch));
391
+ if (changes.manifests !== void 0) candidateRecord.manifests = [...new Set(changes.manifests)].sort();
392
+ await this.#assertNoIntroducedIssues(library, candidate);
393
+ let updated = library;
394
+ if (changes.parametersPatch !== void 0) updated = await this.#store.updateParameters(id, candidateRecord.parameters);
395
+ if (changes.manifests !== void 0) updated = await this.#store.setManifests(id, changes.manifests);
396
+ return updated;
397
+ }
398
+ /** Reject a candidate library that has validation issues the current one lacks. */
399
+ async #assertNoIntroducedIssues(library, candidate) {
400
+ const existingIssueKeys = new Set((await this.#store.validate(library)).map((issue) => `${issue.assetId ?? ""}|${issue.message}`));
401
+ const introduced = (await this.#store.validate(candidate)).filter((issue) => !existingIssueKeys.has(`${issue.assetId ?? ""}|${issue.message}`));
402
+ if (introduced.length > 0) {
403
+ const lines = introduced.map((issue) => ` - ${issue.assetId ? `[${issue.assetId}] ` : ""}${issue.message}`);
404
+ throw new Error(`Rejected — the change would leave the library invalid (nothing was written):\n${lines.join("\n")}`);
405
+ }
406
+ }
407
+ };
408
+ //#endregion
409
+ //#region src/lib/server/context.ts
410
+ var context;
411
+ function initializeFundusContext() {
412
+ context ??= createFundusContext();
413
+ return context;
414
+ }
415
+ function getFundusContext() {
416
+ return initializeFundusContext();
417
+ }
418
+ async function createFundusContext() {
419
+ const projectRoot = process.env.FUNDUS_PROJECT_ROOT;
420
+ if (!projectRoot || !isAbsolute(projectRoot)) throw new Error("FUNDUS_PROJECT_ROOT must be set to an absolute host project directory.");
421
+ const config = await loadConfig(projectRoot);
422
+ return {
423
+ config,
424
+ operations: new FundusOperations(config)
425
+ };
426
+ }
427
+
428
+ export { getFundusContext as g, initializeFundusContext as i };
429
+ //# sourceMappingURL=context.js-BUZqFfWG.js.map