@aphexcms/cms-core 9.10.0 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/dist/api/assets.d.ts +62 -7
  2. package/dist/api/assets.d.ts.map +1 -1
  3. package/dist/api/assets.js +116 -9
  4. package/dist/api/client.d.ts +1 -1
  5. package/dist/api/client.d.ts.map +1 -1
  6. package/dist/api/client.js +39 -9
  7. package/dist/api/limits.d.ts +55 -0
  8. package/dist/api/limits.d.ts.map +1 -0
  9. package/dist/api/limits.js +58 -0
  10. package/dist/api/schemas/assets.d.ts +94 -4
  11. package/dist/api/schemas/assets.d.ts.map +1 -1
  12. package/dist/api/schemas/assets.js +82 -5
  13. package/dist/api/types.d.ts +25 -0
  14. package/dist/api/types.d.ts.map +1 -1
  15. package/dist/api/upload-timeout.d.ts +17 -0
  16. package/dist/api/upload-timeout.d.ts.map +1 -0
  17. package/dist/api/upload-timeout.js +35 -0
  18. package/dist/api/upload.d.ts +42 -0
  19. package/dist/api/upload.d.ts.map +1 -0
  20. package/dist/api/upload.js +144 -0
  21. package/dist/components/AdminApp.svelte +130 -26
  22. package/dist/components/AdminApp.svelte.d.ts.map +1 -1
  23. package/dist/components/admin/AssetBrowserModal.svelte +4 -3
  24. package/dist/components/admin/AssetBrowserModal.svelte.d.ts +2 -1
  25. package/dist/components/admin/AssetBrowserModal.svelte.d.ts.map +1 -1
  26. package/dist/components/admin/MediaBrowser.svelte +1859 -281
  27. package/dist/components/admin/MediaBrowser.svelte.d.ts +21 -1
  28. package/dist/components/admin/MediaBrowser.svelte.d.ts.map +1 -1
  29. package/dist/components/admin/fields/ArrayField.svelte +21 -10
  30. package/dist/components/admin/fields/ArrayField.svelte.d.ts.map +1 -1
  31. package/dist/components/admin/fields/FileField.svelte +9 -2
  32. package/dist/components/admin/fields/FileField.svelte.d.ts.map +1 -1
  33. package/dist/components/admin/fields/ImageField.svelte +47 -12
  34. package/dist/components/admin/fields/ImageField.svelte.d.ts.map +1 -1
  35. package/dist/config.d.ts.map +1 -1
  36. package/dist/config.js +14 -0
  37. package/dist/db/interfaces/asset.d.ts +114 -5
  38. package/dist/db/interfaces/asset.d.ts.map +1 -1
  39. package/dist/db/interfaces/document.d.ts +98 -3
  40. package/dist/db/interfaces/document.d.ts.map +1 -1
  41. package/dist/hooks.d.ts.map +1 -1
  42. package/dist/hooks.js +2 -1
  43. package/dist/image/Image.svelte +72 -0
  44. package/dist/image/Image.svelte.d.ts +40 -0
  45. package/dist/image/Image.svelte.d.ts.map +1 -0
  46. package/dist/image/index.d.ts +3 -0
  47. package/dist/image/index.d.ts.map +1 -0
  48. package/dist/image/index.js +11 -0
  49. package/dist/image/types.d.ts +28 -0
  50. package/dist/image/types.d.ts.map +1 -0
  51. package/dist/image/types.js +1 -0
  52. package/dist/images/generate.d.ts +55 -0
  53. package/dist/images/generate.d.ts.map +1 -0
  54. package/dist/images/generate.js +243 -0
  55. package/dist/images/index.d.ts +2 -0
  56. package/dist/images/index.d.ts.map +1 -0
  57. package/dist/images/index.js +7 -0
  58. package/dist/images/variants.d.ts +82 -0
  59. package/dist/images/variants.d.ts.map +1 -0
  60. package/dist/images/variants.js +124 -0
  61. package/dist/jobs/asset-reference-jobs.d.ts +49 -0
  62. package/dist/jobs/asset-reference-jobs.d.ts.map +1 -0
  63. package/dist/jobs/asset-reference-jobs.js +74 -0
  64. package/dist/jobs/run-batch.d.ts.map +1 -1
  65. package/dist/jobs/run-batch.js +5 -0
  66. package/dist/lib/api/assets.d.ts +62 -7
  67. package/dist/lib/api/assets.d.ts.map +1 -1
  68. package/dist/lib/api/assets.js +116 -9
  69. package/dist/lib/api/assets.js.map +1 -1
  70. package/dist/lib/api/client.d.ts +1 -1
  71. package/dist/lib/api/client.d.ts.map +1 -1
  72. package/dist/lib/api/client.js +39 -9
  73. package/dist/lib/api/client.js.map +1 -1
  74. package/dist/lib/api/limits.d.ts +55 -0
  75. package/dist/lib/api/limits.d.ts.map +1 -0
  76. package/dist/lib/api/limits.js +59 -0
  77. package/dist/lib/api/limits.js.map +1 -0
  78. package/dist/lib/api/schemas/assets.d.ts +94 -4
  79. package/dist/lib/api/schemas/assets.d.ts.map +1 -1
  80. package/dist/lib/api/schemas/assets.js +82 -5
  81. package/dist/lib/api/schemas/assets.js.map +1 -1
  82. package/dist/lib/api/types.d.ts +25 -0
  83. package/dist/lib/api/types.d.ts.map +1 -1
  84. package/dist/lib/api/upload-timeout.d.ts +17 -0
  85. package/dist/lib/api/upload-timeout.d.ts.map +1 -0
  86. package/dist/lib/api/upload-timeout.js +36 -0
  87. package/dist/lib/api/upload-timeout.js.map +1 -0
  88. package/dist/lib/api/upload.d.ts +42 -0
  89. package/dist/lib/api/upload.d.ts.map +1 -0
  90. package/dist/lib/api/upload.js +145 -0
  91. package/dist/lib/api/upload.js.map +1 -0
  92. package/dist/lib/config.d.ts.map +1 -1
  93. package/dist/lib/config.js +14 -0
  94. package/dist/lib/config.js.map +1 -1
  95. package/dist/lib/db/interfaces/asset.d.ts +114 -5
  96. package/dist/lib/db/interfaces/asset.d.ts.map +1 -1
  97. package/dist/lib/db/interfaces/document.d.ts +98 -3
  98. package/dist/lib/db/interfaces/document.d.ts.map +1 -1
  99. package/dist/lib/hooks.d.ts.map +1 -1
  100. package/dist/lib/hooks.js +2 -1
  101. package/dist/lib/hooks.js.map +1 -1
  102. package/dist/lib/image/index.d.ts +3 -0
  103. package/dist/lib/image/index.d.ts.map +1 -0
  104. package/dist/lib/image/index.js +12 -0
  105. package/dist/lib/image/index.js.map +1 -0
  106. package/dist/lib/image/types.d.ts +28 -0
  107. package/dist/lib/image/types.d.ts.map +1 -0
  108. package/dist/lib/image/types.js +2 -0
  109. package/dist/lib/image/types.js.map +1 -0
  110. package/dist/lib/images/generate.d.ts +55 -0
  111. package/dist/lib/images/generate.d.ts.map +1 -0
  112. package/dist/lib/images/generate.js +244 -0
  113. package/dist/lib/images/generate.js.map +1 -0
  114. package/dist/lib/images/index.d.ts +2 -0
  115. package/dist/lib/images/index.d.ts.map +1 -0
  116. package/dist/lib/images/index.js +8 -0
  117. package/dist/lib/images/index.js.map +1 -0
  118. package/dist/lib/images/variants.d.ts +82 -0
  119. package/dist/lib/images/variants.d.ts.map +1 -0
  120. package/dist/lib/images/variants.js +125 -0
  121. package/dist/lib/images/variants.js.map +1 -0
  122. package/dist/lib/jobs/asset-reference-jobs.d.ts +49 -0
  123. package/dist/lib/jobs/asset-reference-jobs.d.ts.map +1 -0
  124. package/dist/lib/jobs/asset-reference-jobs.js +75 -0
  125. package/dist/lib/jobs/asset-reference-jobs.js.map +1 -0
  126. package/dist/lib/jobs/run-batch.d.ts.map +1 -1
  127. package/dist/lib/jobs/run-batch.js +5 -0
  128. package/dist/lib/jobs/run-batch.js.map +1 -1
  129. package/dist/lib/local-api/collection-api.d.ts +19 -2
  130. package/dist/lib/local-api/collection-api.d.ts.map +1 -1
  131. package/dist/lib/local-api/collection-api.js +65 -17
  132. package/dist/lib/local-api/collection-api.js.map +1 -1
  133. package/dist/lib/preview/assets.d.ts +19 -0
  134. package/dist/lib/preview/assets.d.ts.map +1 -1
  135. package/dist/lib/preview/assets.js +6 -0
  136. package/dist/lib/preview/assets.js.map +1 -1
  137. package/dist/lib/routes/assets-cdn.d.ts +19 -0
  138. package/dist/lib/routes/assets-cdn.d.ts.map +1 -1
  139. package/dist/lib/routes/assets-cdn.js +295 -17
  140. package/dist/lib/routes/assets-cdn.js.map +1 -1
  141. package/dist/lib/server/api/index.d.ts.map +1 -1
  142. package/dist/lib/server/api/index.js +87 -8
  143. package/dist/lib/server/api/index.js.map +1 -1
  144. package/dist/lib/server/api/routes/assets-bulk.d.ts.map +1 -1
  145. package/dist/lib/server/api/routes/assets-bulk.js +36 -7
  146. package/dist/lib/server/api/routes/assets-bulk.js.map +1 -1
  147. package/dist/lib/server/api/routes/assets-by-id.d.ts.map +1 -1
  148. package/dist/lib/server/api/routes/assets-by-id.js +32 -15
  149. package/dist/lib/server/api/routes/assets-by-id.js.map +1 -1
  150. package/dist/lib/server/api/routes/assets-direct-upload.d.ts +4 -0
  151. package/dist/lib/server/api/routes/assets-direct-upload.d.ts.map +1 -0
  152. package/dist/lib/server/api/routes/assets-direct-upload.js +164 -0
  153. package/dist/lib/server/api/routes/assets-direct-upload.js.map +1 -0
  154. package/dist/lib/server/api/routes/assets-poster.d.ts +4 -0
  155. package/dist/lib/server/api/routes/assets-poster.d.ts.map +1 -0
  156. package/dist/lib/server/api/routes/assets-poster.js +120 -0
  157. package/dist/lib/server/api/routes/assets-poster.js.map +1 -0
  158. package/dist/lib/server/api/routes/assets-references.d.ts.map +1 -1
  159. package/dist/lib/server/api/routes/assets-references.js +64 -5
  160. package/dist/lib/server/api/routes/assets-references.js.map +1 -1
  161. package/dist/lib/server/api/routes/assets.d.ts.map +1 -1
  162. package/dist/lib/server/api/routes/assets.js +116 -12
  163. package/dist/lib/server/api/routes/assets.js.map +1 -1
  164. package/dist/lib/server/api/routes/clear-asset-references.d.ts +18 -0
  165. package/dist/lib/server/api/routes/clear-asset-references.d.ts.map +1 -0
  166. package/dist/lib/server/api/routes/clear-asset-references.js +32 -0
  167. package/dist/lib/server/api/routes/clear-asset-references.js.map +1 -0
  168. package/dist/lib/server/api/routes/documents.d.ts.map +1 -1
  169. package/dist/lib/server/api/routes/documents.js +27 -1
  170. package/dist/lib/server/api/routes/documents.js.map +1 -1
  171. package/dist/lib/server/index.d.ts +2 -0
  172. package/dist/lib/server/index.d.ts.map +1 -1
  173. package/dist/lib/server/index.js +4 -0
  174. package/dist/lib/server/index.js.map +1 -1
  175. package/dist/lib/services/asset-references-service.d.ts +93 -0
  176. package/dist/lib/services/asset-references-service.d.ts.map +1 -0
  177. package/dist/lib/services/asset-references-service.js +198 -0
  178. package/dist/lib/services/asset-references-service.js.map +1 -0
  179. package/dist/lib/services/asset-service.d.ts +115 -14
  180. package/dist/lib/services/asset-service.d.ts.map +1 -1
  181. package/dist/lib/services/asset-service.js +312 -31
  182. package/dist/lib/services/asset-service.js.map +1 -1
  183. package/dist/lib/services/references-service.d.ts +19 -15
  184. package/dist/lib/services/references-service.d.ts.map +1 -1
  185. package/dist/lib/services/references-service.js +59 -31
  186. package/dist/lib/services/references-service.js.map +1 -1
  187. package/dist/lib/services/version-service.d.ts +10 -1
  188. package/dist/lib/services/version-service.d.ts.map +1 -1
  189. package/dist/lib/services/version-service.js +26 -4
  190. package/dist/lib/services/version-service.js.map +1 -1
  191. package/dist/lib/storage/adapters/local-storage-adapter.d.ts +38 -0
  192. package/dist/lib/storage/adapters/local-storage-adapter.d.ts.map +1 -1
  193. package/dist/lib/storage/adapters/local-storage-adapter.js +86 -19
  194. package/dist/lib/storage/adapters/local-storage-adapter.js.map +1 -1
  195. package/dist/lib/storage/index.d.ts +1 -0
  196. package/dist/lib/storage/index.d.ts.map +1 -1
  197. package/dist/lib/storage/index.js +2 -0
  198. package/dist/lib/storage/index.js.map +1 -1
  199. package/dist/lib/storage/interfaces/storage.d.ts +135 -5
  200. package/dist/lib/storage/interfaces/storage.d.ts.map +1 -1
  201. package/dist/lib/storage/keys.d.ts +96 -0
  202. package/dist/lib/storage/keys.d.ts.map +1 -0
  203. package/dist/lib/storage/keys.js +160 -0
  204. package/dist/lib/storage/keys.js.map +1 -0
  205. package/dist/lib/types/asset.d.ts +92 -12
  206. package/dist/lib/types/asset.d.ts.map +1 -1
  207. package/dist/lib/types/capabilities.d.ts +11 -0
  208. package/dist/lib/types/capabilities.d.ts.map +1 -1
  209. package/dist/lib/types/capabilities.js +20 -6
  210. package/dist/lib/types/capabilities.js.map +1 -1
  211. package/dist/lib/types/config.d.ts +127 -0
  212. package/dist/lib/types/config.d.ts.map +1 -1
  213. package/dist/lib/utils/asset-reference-walk.d.ts +44 -0
  214. package/dist/lib/utils/asset-reference-walk.d.ts.map +1 -0
  215. package/dist/lib/utils/asset-reference-walk.js +144 -0
  216. package/dist/lib/utils/asset-reference-walk.js.map +1 -0
  217. package/dist/lib/utils/image-url.d.ts +61 -26
  218. package/dist/lib/utils/image-url.d.ts.map +1 -1
  219. package/dist/lib/utils/image-url.js +143 -26
  220. package/dist/lib/utils/image-url.js.map +1 -1
  221. package/dist/lib/utils/video-metadata.d.ts +39 -0
  222. package/dist/lib/utils/video-metadata.d.ts.map +1 -0
  223. package/dist/lib/utils/video-metadata.js +161 -0
  224. package/dist/lib/utils/video-metadata.js.map +1 -0
  225. package/dist/local-api/collection-api.d.ts +19 -2
  226. package/dist/local-api/collection-api.d.ts.map +1 -1
  227. package/dist/local-api/collection-api.js +65 -17
  228. package/dist/preview/assets.d.ts +19 -0
  229. package/dist/preview/assets.d.ts.map +1 -1
  230. package/dist/preview/assets.js +6 -0
  231. package/dist/routes/assets-cdn.d.ts +19 -0
  232. package/dist/routes/assets-cdn.d.ts.map +1 -1
  233. package/dist/routes/assets-cdn.js +295 -17
  234. package/dist/server/api/index.d.ts.map +1 -1
  235. package/dist/server/api/index.js +87 -8
  236. package/dist/server/api/routes/assets-bulk.d.ts.map +1 -1
  237. package/dist/server/api/routes/assets-bulk.js +36 -7
  238. package/dist/server/api/routes/assets-by-id.d.ts.map +1 -1
  239. package/dist/server/api/routes/assets-by-id.js +32 -15
  240. package/dist/server/api/routes/assets-direct-upload.d.ts +4 -0
  241. package/dist/server/api/routes/assets-direct-upload.d.ts.map +1 -0
  242. package/dist/server/api/routes/assets-direct-upload.js +163 -0
  243. package/dist/server/api/routes/assets-poster.d.ts +4 -0
  244. package/dist/server/api/routes/assets-poster.d.ts.map +1 -0
  245. package/dist/server/api/routes/assets-poster.js +119 -0
  246. package/dist/server/api/routes/assets-references.d.ts.map +1 -1
  247. package/dist/server/api/routes/assets-references.js +64 -5
  248. package/dist/server/api/routes/assets.d.ts.map +1 -1
  249. package/dist/server/api/routes/assets.js +116 -12
  250. package/dist/server/api/routes/clear-asset-references.d.ts +18 -0
  251. package/dist/server/api/routes/clear-asset-references.d.ts.map +1 -0
  252. package/dist/server/api/routes/clear-asset-references.js +31 -0
  253. package/dist/server/api/routes/documents.d.ts.map +1 -1
  254. package/dist/server/api/routes/documents.js +27 -1
  255. package/dist/server/index.d.ts +2 -0
  256. package/dist/server/index.d.ts.map +1 -1
  257. package/dist/server/index.js +4 -0
  258. package/dist/services/asset-references-service.d.ts +93 -0
  259. package/dist/services/asset-references-service.d.ts.map +1 -0
  260. package/dist/services/asset-references-service.js +197 -0
  261. package/dist/services/asset-service.d.ts +115 -14
  262. package/dist/services/asset-service.d.ts.map +1 -1
  263. package/dist/services/asset-service.js +312 -31
  264. package/dist/services/references-service.d.ts +19 -15
  265. package/dist/services/references-service.d.ts.map +1 -1
  266. package/dist/services/references-service.js +59 -31
  267. package/dist/services/version-service.d.ts +10 -1
  268. package/dist/services/version-service.d.ts.map +1 -1
  269. package/dist/services/version-service.js +26 -4
  270. package/dist/storage/adapters/local-storage-adapter.d.ts +38 -0
  271. package/dist/storage/adapters/local-storage-adapter.d.ts.map +1 -1
  272. package/dist/storage/adapters/local-storage-adapter.js +86 -19
  273. package/dist/storage/index.d.ts +1 -0
  274. package/dist/storage/index.d.ts.map +1 -1
  275. package/dist/storage/index.js +2 -0
  276. package/dist/storage/interfaces/storage.d.ts +135 -5
  277. package/dist/storage/interfaces/storage.d.ts.map +1 -1
  278. package/dist/storage/keys.d.ts +96 -0
  279. package/dist/storage/keys.d.ts.map +1 -0
  280. package/dist/storage/keys.js +159 -0
  281. package/dist/types/asset.d.ts +92 -12
  282. package/dist/types/asset.d.ts.map +1 -1
  283. package/dist/types/capabilities.d.ts +11 -0
  284. package/dist/types/capabilities.d.ts.map +1 -1
  285. package/dist/types/capabilities.js +20 -6
  286. package/dist/types/config.d.ts +127 -0
  287. package/dist/types/config.d.ts.map +1 -1
  288. package/dist/utils/asset-reference-walk.d.ts +44 -0
  289. package/dist/utils/asset-reference-walk.d.ts.map +1 -0
  290. package/dist/utils/asset-reference-walk.js +143 -0
  291. package/dist/utils/image-url.d.ts +61 -26
  292. package/dist/utils/image-url.d.ts.map +1 -1
  293. package/dist/utils/image-url.js +143 -26
  294. package/dist/utils/video-metadata.d.ts +39 -0
  295. package/dist/utils/video-metadata.d.ts.map +1 -0
  296. package/dist/utils/video-metadata.js +160 -0
  297. package/package.json +6 -1
@@ -1 +1 @@
1
- {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../src/lib/api/schemas/assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;iBAuBT,CAAC;AAEhB,eAAO,MAAM,oBAAoB;;;;;iBAK/B,CAAC;AAIH,eAAO,MAAM,eAAe;;;;;;;;;;;;;iBAS1B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAW7B,CAAC;AAIH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;iBAG3B,CAAC;AAIH,eAAO,MAAM,kBAAkB;;;;;iBAK7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;iBAG9B,CAAC;AAIH,eAAO,MAAM,mBAAmB;;iBAE9B,CAAC;AAIH,eAAO,MAAM,uBAAuB;;iBAElC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;iBAMnC,CAAC;AAIH,eAAO,MAAM,0BAA0B;;;;;;;;;;;iBAMrC,CAAC;AAIH,eAAO,MAAM,2BAA2B;;iBAEtC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;iBAGvC,CAAC;AAIH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAC9D,MAAM,MAAM,kBAAkB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AK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACpE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAC9E,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEpF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AACtF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAExF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC5E,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -28,16 +28,46 @@ export const assetReferenceSchema = z.object({
28
28
  documentId: z.string(),
29
29
  type: z.string(),
30
30
  title: z.string(),
31
- status: z.string().nullable()
31
+ status: z.string().nullable(),
32
+ /**
33
+ * Where in the document the asset is used (`coverImage`,
34
+ * `content[13].images[0]`). Annotated from the asset-reference index, so it is
35
+ * absent when the index has no row — the reference itself is still authoritative.
36
+ */
37
+ fieldPaths: z.array(z.string()).optional()
32
38
  });
33
39
  // ---------- GET /assets (list) ----------
34
40
  export const listAssetsQuery = z.object({
35
41
  assetType: z.enum(['image', 'file']).optional(),
36
42
  mimeType: z.string().optional(),
43
+ /**
44
+ * Coarse media kind, resolved against `mimeType` in SQL. A separate axis from
45
+ * `assetType` ('image' | 'file'), which records how the upload pipeline treated
46
+ * the file rather than what the editor is hunting for — hence `svg` being its
47
+ * own bucket rather than an image.
48
+ */
49
+ category: z.enum(['image', 'svg', 'video', 'audio', 'document']).optional(),
50
+ /** Matches filename, title, alt and description. Case-insensitive. */
37
51
  search: z.string().optional(),
52
+ /**
53
+ * Whether the asset is referenced by any document, answered from the
54
+ * asset-reference index as an indexed EXISTS. Impossible to offer before that
55
+ * index existed: references were resolved by scanning every document's JSON,
56
+ * so a *filter* cost assets x documents.
57
+ */
58
+ usage: z.enum(['in-use', 'unused']).optional(),
38
59
  includeSystem: z
39
60
  .union([z.boolean(), z.enum(['true', 'false']).transform((value) => value === 'true')])
40
61
  .optional(),
62
+ /**
63
+ * Ordering, applied in SQL over the whole collection.
64
+ *
65
+ * It has to be a query parameter: the admin used to sort the loaded page in
66
+ * the browser, which meant "Name: A–Z" on page 2 of 300 assets alphabetised
67
+ * those 30 rows and nothing else. The result looked sorted and wasn't, which
68
+ * is the failure mode that never gets reported as a bug.
69
+ */
70
+ sort: z.enum(['newest', 'oldest', 'name-asc', 'name-desc']).optional(),
41
71
  limit: z.coerce.number().int().min(1).max(500).optional(),
42
72
  offset: z.coerce.number().int().min(0).optional()
43
73
  });
@@ -59,11 +89,24 @@ export const getAssetResponse = z.object({
59
89
  data: assetSchema
60
90
  });
61
91
  // ---------- PATCH /assets/[id] ----------
92
+ /**
93
+ * Metadata patch. Every field is a tri-state: omitted leaves the column alone,
94
+ * `null` clears it, a string sets it.
95
+ *
96
+ * `.nullable()` is the load-bearing part. Without it an emptied input could only
97
+ * be sent as `undefined`, which `JSON.stringify` drops from the body entirely —
98
+ * so metadata could be added but never removed.
99
+ */
62
100
  export const updateAssetRequest = z.object({
63
- title: z.string().optional(),
64
- description: z.string().optional(),
65
- alt: z.string().optional(),
66
- creditLine: z.string().optional()
101
+ /**
102
+ * Display filename. Not nullable — an asset always has a name, so there is no
103
+ * "clear it" state; omit the field to leave it alone.
104
+ */
105
+ originalFilename: z.string().trim().min(1).max(255).optional(),
106
+ title: z.string().nullable().optional(),
107
+ description: z.string().nullable().optional(),
108
+ alt: z.string().nullable().optional(),
109
+ creditLine: z.string().nullable().optional()
67
110
  });
68
111
  export const updateAssetResponse = z.object({
69
112
  success: z.literal(true),
@@ -100,3 +143,37 @@ export const assetReferenceCountsResponse = z.object({
100
143
  success: z.literal(true),
101
144
  data: z.record(z.string(), z.number())
102
145
  });
146
+ /**
147
+ * Ask for a URL the browser can upload directly to.
148
+ *
149
+ * Deliberately carries no key or path. The server mints the asset id and
150
+ * derives the destination from it, because a caller-supplied key would let
151
+ * anyone holding `asset.upload` write anywhere in the bucket — including over
152
+ * an existing asset's original.
153
+ */
154
+ export const createUploadUrlRequest = z.object({
155
+ filename: z.string().trim().min(1).max(255),
156
+ mimeType: z.string().trim().min(1).max(255),
157
+ /**
158
+ * Declared up front so an oversized upload is refused before a write grant
159
+ * is issued at all. It is a claim, not proof — the size is verified against
160
+ * the stored object on confirm.
161
+ */
162
+ size: z.number().int().positive(),
163
+ /** Where the asset is being used, for privacy resolution. */
164
+ schemaType: z.string().trim().max(255).optional(),
165
+ fieldPath: z.string().trim().max(255).optional()
166
+ });
167
+ /**
168
+ * Report that a direct upload finished, so the asset row can be created.
169
+ *
170
+ * Only the id is trusted. Everything describing the object — that it exists,
171
+ * how large it is — is read back from storage, never taken from the client.
172
+ */
173
+ export const confirmUploadRequest = z.object({
174
+ assetId: z.string().uuid(),
175
+ title: z.string().trim().max(255).optional(),
176
+ description: z.string().trim().max(2000).optional(),
177
+ alt: z.string().trim().max(1000).optional(),
178
+ creditLine: z.string().trim().max(255).optional()
179
+ });
@@ -13,6 +13,31 @@ export interface ApiResponse<T> {
13
13
  error?: string;
14
14
  message?: string;
15
15
  pagination?: PaginationMeta;
16
+ /**
17
+ * Server-side limits the client should respect, reported by endpoints whose
18
+ * clients need to pre-check against them. Present on `GET /assets` so the
19
+ * media browser can refuse an oversized file without hardcoding a size that
20
+ * drifts from whatever the server actually enforces.
21
+ */
22
+ limits?: {
23
+ maxUploadBytes?: number;
24
+ /** Whether the browser may upload straight to storage. */
25
+ directUpload?: boolean;
26
+ };
27
+ /**
28
+ * The resolved image pipeline, or null when it's off.
29
+ *
30
+ * Reported so the media browser can address a small derivative instead of
31
+ * the original. `configHash` comes from the server rather than being
32
+ * recomputed here: it is the server that decides which files exist, and a
33
+ * client that derived a different hash would request URLs that quietly fall
34
+ * back to the original — the exact bug this exists to fix, but silent.
35
+ */
36
+ images?: {
37
+ widths: number[];
38
+ quality: number;
39
+ configHash: string;
40
+ } | null;
16
41
  meta?: {
17
42
  count: number;
18
43
  limit: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/api/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG5D,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;CACrB;AAGD,MAAM,WAAW,WAAW,CAAC,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,UAAU,CAAC,EAAE,cAAc,CAAC;IAE5B,IAAI,CAAC,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,C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AAC;IACpC,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC;AAGD,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAGD,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAGD,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * How long to wait on a request carrying a file body.
3
+ *
4
+ * Its own module because both transports need it — the XHR upload path and the
5
+ * fetch client — and a second copy of a heuristic is a second thing to get
6
+ * wrong. No imports, so neither pays for it.
7
+ *
8
+ * Derived from the payload rather than configured. A timeout encodes no
9
+ * decision the way a size limit does: its only job is to stop a hung request
10
+ * spinning forever. Exposing it as a setting invites an inconsistent pair —
11
+ * raise `upload.maxFileSize` to 100MB, leave the timeout at the JSON default,
12
+ * and every large upload fails in a way that reads as a server rejection.
13
+ * Deriving it means raising the size limit adjusts the deadline for free.
14
+ */
15
+ export declare function uploadTimeoutForBytes(bytes: number): number;
16
+ export declare function uploadTimeoutFor(body: FormData): number;
17
+ //# sourceMappingURL=upload-timeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload-timeout.d.ts","sourceRoot":"","sources":["../../src/lib/api/upload-timeout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAWH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAOvD"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * How long to wait on a request carrying a file body.
3
+ *
4
+ * Its own module because both transports need it — the XHR upload path and the
5
+ * fetch client — and a second copy of a heuristic is a second thing to get
6
+ * wrong. No imports, so neither pays for it.
7
+ *
8
+ * Derived from the payload rather than configured. A timeout encodes no
9
+ * decision the way a size limit does: its only job is to stop a hung request
10
+ * spinning forever. Exposing it as a setting invites an inconsistent pair —
11
+ * raise `upload.maxFileSize` to 100MB, leave the timeout at the JSON default,
12
+ * and every large upload fails in a way that reads as a server rejection.
13
+ * Deriving it means raising the size limit adjusts the deadline for free.
14
+ */
15
+ /**
16
+ * Assumed floor throughput, deliberately pessimistic — a phone on a bad
17
+ * connection, not an office line. Too generous costs a slow failure on a
18
+ * genuinely dead request; too tight kills uploads that were succeeding.
19
+ */
20
+ const UPLOAD_ASSUMED_BYTES_PER_SECOND = 64 * 1024; // ~0.5 Mbps
21
+ const UPLOAD_TIMEOUT_FLOOR = 30_000;
22
+ const UPLOAD_TIMEOUT_CEILING = 15 * 60 * 1000;
23
+ export function uploadTimeoutForBytes(bytes) {
24
+ const transfer = (bytes / UPLOAD_ASSUMED_BYTES_PER_SECOND) * 1000;
25
+ return Math.min(UPLOAD_TIMEOUT_CEILING, Math.max(UPLOAD_TIMEOUT_FLOOR, transfer));
26
+ }
27
+ export function uploadTimeoutFor(body) {
28
+ let bytes = 0;
29
+ for (const value of body.values()) {
30
+ // `File` extends `Blob`; checking Blob also covers a raw Blob part.
31
+ if (typeof Blob !== 'undefined' && value instanceof Blob)
32
+ bytes += value.size;
33
+ }
34
+ return uploadTimeoutForBytes(bytes);
35
+ }
@@ -0,0 +1,42 @@
1
+ import type { ApiResponse } from './types.js';
2
+ /**
3
+ * Uploads, on XMLHttpRequest rather than fetch.
4
+ *
5
+ * Not nostalgia: `fetch` has no upload progress event. Request body streams are
6
+ * the standards-track answer and are still neither broadly supported nor usable
7
+ * with a plain `FormData`, so XHR remains the only way to report how far a
8
+ * multi-megabyte upload has actually got. Everything else here exists to make
9
+ * that swap invisible — same `ApiResponse`, same `ApiError`, same defensive
10
+ * parsing — so callers can't tell which transport ran.
11
+ */
12
+ export interface UploadOptions {
13
+ /** Called with 0–100 as the body is sent. Never called after completion. */
14
+ onProgress?: (percent: number) => void;
15
+ /** Aborts the upload. The promise rejects with an `ApiError` of status 0. */
16
+ signal?: AbortSignal;
17
+ /** Milliseconds of inactivity before giving up. */
18
+ timeoutMs?: number;
19
+ }
20
+ /**
21
+ * POST a FormData body with progress reporting.
22
+ *
23
+ * Resolves with the parsed body on success and rejects with `ApiError`
24
+ * otherwise, matching `ApiClient` exactly.
25
+ */
26
+ /**
27
+ * PUT a file straight to object storage, reporting progress.
28
+ *
29
+ * Distinct from {@link uploadFormData} in two ways that matter:
30
+ *
31
+ * - **No credentials.** The target is a third-party origin and the URL already
32
+ * carries its own signature. Sending cookies would leak the session to the
33
+ * storage provider and trip CORS besides.
34
+ * - **Raw body, not FormData.** The signature covers the object bytes; wrapping
35
+ * them in multipart framing would store the framing.
36
+ *
37
+ * A failure here is very often missing bucket CORS rather than a broken file,
38
+ * and the browser deliberately hides the distinction — so the error says so.
39
+ */
40
+ export declare function putToStorage(url: string, file: File | Blob, headers?: Record<string, string>, options?: UploadOptions): Promise<void>;
41
+ export declare function uploadFormData<T>(url: string, body: FormData, options?: UploadOptions): Promise<ApiResponse<T>>;
42
+ //# sourceMappingURL=upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/lib/api/upload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;;GASG;AAEH,MAAM,WAAW,aAAa;IAC7B,4EAA4E;IAC5E,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,6EAA6E;IAC7E,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAC3B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,IAAI,GAAG,IAAI,EACjB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACpC,OAAO,GAAE,aAAkB,GACzB,OAAO,CAAC,IAAI,CAAC,CA+Df;AAED,wBAAgB,cAAc,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,QAAQ,EACd,OAAO,GAAE,aAAkB,GACzB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAuFzB"}
@@ -0,0 +1,144 @@
1
+ import { ApiError } from './client.js';
2
+ /**
3
+ * POST a FormData body with progress reporting.
4
+ *
5
+ * Resolves with the parsed body on success and rejects with `ApiError`
6
+ * otherwise, matching `ApiClient` exactly.
7
+ */
8
+ /**
9
+ * PUT a file straight to object storage, reporting progress.
10
+ *
11
+ * Distinct from {@link uploadFormData} in two ways that matter:
12
+ *
13
+ * - **No credentials.** The target is a third-party origin and the URL already
14
+ * carries its own signature. Sending cookies would leak the session to the
15
+ * storage provider and trip CORS besides.
16
+ * - **Raw body, not FormData.** The signature covers the object bytes; wrapping
17
+ * them in multipart framing would store the framing.
18
+ *
19
+ * A failure here is very often missing bucket CORS rather than a broken file,
20
+ * and the browser deliberately hides the distinction — so the error says so.
21
+ */
22
+ export function putToStorage(url, file, headers = {}, options = {}) {
23
+ const { onProgress, signal, timeoutMs } = options;
24
+ return new Promise((resolve, reject) => {
25
+ if (signal?.aborted) {
26
+ reject(new ApiError(0, null, 'Upload cancelled'));
27
+ return;
28
+ }
29
+ const xhr = new XMLHttpRequest();
30
+ xhr.open('PUT', url, true);
31
+ xhr.withCredentials = false;
32
+ for (const [name, value] of Object.entries(headers))
33
+ xhr.setRequestHeader(name, value);
34
+ if (timeoutMs)
35
+ xhr.timeout = timeoutMs;
36
+ if (onProgress) {
37
+ xhr.upload.addEventListener('progress', (event) => {
38
+ if (event.lengthComputable && event.total > 0) {
39
+ onProgress(Math.min(100, Math.round((event.loaded / event.total) * 100)));
40
+ }
41
+ });
42
+ }
43
+ const onAbort = () => xhr.abort();
44
+ signal?.addEventListener('abort', onAbort, { once: true });
45
+ const cleanup = () => signal?.removeEventListener('abort', onAbort);
46
+ xhr.addEventListener('load', () => {
47
+ cleanup();
48
+ if (xhr.status >= 200 && xhr.status < 300) {
49
+ resolve();
50
+ return;
51
+ }
52
+ reject(new ApiError(xhr.status, null, `Storage rejected the upload (${xhr.status})`));
53
+ });
54
+ xhr.addEventListener('error', () => {
55
+ cleanup();
56
+ // A cross-origin PUT blocked by CORS surfaces here as a bare network
57
+ // error with no detail, by design. Naming the likely cause is the only
58
+ // way an operator finds it, since the browser console message is the
59
+ // only other clue and nobody reads it from a toast.
60
+ reject(new ApiError(0, null, 'Could not reach storage. The bucket may not allow PUT from this origin (CORS).'));
61
+ });
62
+ xhr.addEventListener('timeout', () => {
63
+ cleanup();
64
+ reject(new ApiError(0, null, 'Upload timed out'));
65
+ });
66
+ xhr.addEventListener('abort', () => {
67
+ cleanup();
68
+ reject(new ApiError(0, null, 'Upload cancelled'));
69
+ });
70
+ xhr.send(file);
71
+ });
72
+ }
73
+ export function uploadFormData(url, body, options = {}) {
74
+ const { onProgress, signal, timeoutMs } = options;
75
+ return new Promise((resolve, reject) => {
76
+ if (signal?.aborted) {
77
+ reject(new ApiError(0, null, 'Upload cancelled'));
78
+ return;
79
+ }
80
+ const xhr = new XMLHttpRequest();
81
+ xhr.open('POST', url, true);
82
+ // Deliberately not setting Content-Type: the browser must add the
83
+ // multipart boundary, and setting it by hand produces a body the server
84
+ // cannot parse.
85
+ xhr.withCredentials = true;
86
+ if (timeoutMs)
87
+ xhr.timeout = timeoutMs;
88
+ if (onProgress) {
89
+ xhr.upload.addEventListener('progress', (event) => {
90
+ // `lengthComputable` is false when the size isn't known up front;
91
+ // reporting a fabricated percentage would be worse than none.
92
+ if (event.lengthComputable && event.total > 0) {
93
+ onProgress(Math.min(100, Math.round((event.loaded / event.total) * 100)));
94
+ }
95
+ });
96
+ }
97
+ const onAbort = () => xhr.abort();
98
+ signal?.addEventListener('abort', onAbort, { once: true });
99
+ const cleanup = () => signal?.removeEventListener('abort', onAbort);
100
+ xhr.addEventListener('load', () => {
101
+ cleanup();
102
+ // Parse defensively, for the same reason the fetch client does: a
103
+ // proxy or serverless platform can reject the request before it
104
+ // reaches the app and answer with HTML, and parsing first would throw
105
+ // a syntax error that buries the real status.
106
+ let data = null;
107
+ try {
108
+ data = JSON.parse(xhr.responseText);
109
+ }
110
+ catch {
111
+ // Left null; handled below.
112
+ }
113
+ const ok = xhr.status >= 200 && xhr.status < 300;
114
+ if (!ok) {
115
+ reject(new ApiError(xhr.status, data, data?.message || data?.error || `Upload failed (${xhr.status})`));
116
+ return;
117
+ }
118
+ if (!data) {
119
+ reject(new ApiError(xhr.status, null, 'Malformed response from server'));
120
+ return;
121
+ }
122
+ if (!data.success) {
123
+ reject(new ApiError(xhr.status, data, data.message || data.error));
124
+ return;
125
+ }
126
+ resolve(data);
127
+ });
128
+ xhr.addEventListener('error', () => {
129
+ cleanup();
130
+ // XHR reports network failures with no detail at all, by design —
131
+ // exposing more would leak cross-origin information.
132
+ reject(new ApiError(0, null, 'Network error during upload'));
133
+ });
134
+ xhr.addEventListener('timeout', () => {
135
+ cleanup();
136
+ reject(new ApiError(0, null, 'Upload timed out'));
137
+ });
138
+ xhr.addEventListener('abort', () => {
139
+ cleanup();
140
+ reject(new ApiError(0, null, 'Upload cancelled'));
141
+ });
142
+ xhr.send(body);
143
+ });
144
+ }
@@ -444,6 +444,20 @@
444
444
  const COLLAPSED_WIDTH = 60;
445
445
  const TYPES_WIDTH = 350;
446
446
  const DOCS_WIDTH = 350;
447
+ const VERSION_PANEL_WIDTH = 280;
448
+
449
+ /**
450
+ * Width actually available to the panes, measured from the pane container.
451
+ *
452
+ * Not `window.innerWidth`: the app sidebar sits outside this container and is
453
+ * itself collapsible, so the window is wider than the panes ever get. Feeding
454
+ * the window width to the collapse math below made it believe there was
455
+ * ~260px more room than existed, so the panels never collapsed and the editor
456
+ * was squeezed instead. Measuring is also stable — the container is `flex-1`
457
+ * off the sidebar, so its width doesn't depend on the panes inside it.
458
+ */
459
+ let contentWidth = $state(0);
460
+
447
461
  let layoutConfig = $derived.by(() => {
448
462
  const totalEditors = (currentView === 'editor' ? 1 : 0) + (editorStack.length > 0 ? 1 : 0);
449
463
 
@@ -475,37 +489,69 @@
475
489
  let typesExpanded = typesActive || totalEditors < 2;
476
490
  let docsExpanded = docsActive || totalEditors < 2;
477
491
 
492
+ // Everything competing with the editor for horizontal space. The version
493
+ // panel is a sibling of the editor inside this container, so it has to be
494
+ // subtracted too — leaving it out is what let a 280px panel open on top of
495
+ // an editor that was already at its minimum.
496
+ const available = (contentWidth || windowWidth) - (showVersionPanel ? VERSION_PANEL_WIDTH : 0);
497
+
478
498
  let panelsWidth =
479
499
  (typesExpanded ? TYPES_WIDTH : COLLAPSED_WIDTH) +
480
500
  (hasDocs ? (docsExpanded ? DOCS_WIDTH : COLLAPSED_WIDTH) : 0);
481
- let editorSpace = windowWidth - panelsWidth;
501
+ let editorSpace = available - panelsWidth;
482
502
  let maxEditors = Math.floor(editorSpace / MIN_EDITOR_WIDTH);
483
503
 
484
- // Single editor: collapse panels only if editor doesn't fit.
485
- // Skip if user explicitly clicked a collapsed strip to expand it.
486
- if (totalEditors === 1 && !typesActive && !docsActive) {
487
- if (maxEditors < 1 && hasDocs) {
488
- docsExpanded = false;
489
- panelsWidth = TYPES_WIDTH + COLLAPSED_WIDTH;
490
- editorSpace = windowWidth - panelsWidth;
491
- maxEditors = Math.floor(editorSpace / MIN_EDITOR_WIDTH);
492
- }
504
+ // Reclaim space for the editor by collapsing the list panels, shallowest
505
+ // last: docs first, then types. Panes are depth-ordered and the deepest
506
+ // one has priority, so an open editor is never the thing that gives way —
507
+ // a list panel losing 290px is recoverable in one click, an editor
508
+ // squeezed under its minimum is unusable.
509
+ //
510
+ // A panel the user explicitly expanded (by clicking its collapsed strip) is
511
+ // never collapsed — an explicit click has to take effect. Collapsing it
512
+ // back in the same derivation is indistinguishable from the click doing
513
+ // nothing. If the editor then has no room, it becomes a strip instead and
514
+ // one click swaps them back; every pane stays reachable.
515
+ const reclaim = (collapseTypes: boolean, collapseDocs: boolean) => {
516
+ if (maxEditors >= 1) return;
517
+ if (collapseDocs && hasDocs) docsExpanded = false;
518
+ if (collapseTypes) typesExpanded = false;
519
+ panelsWidth =
520
+ (typesExpanded ? TYPES_WIDTH : COLLAPSED_WIDTH) +
521
+ (hasDocs ? (docsExpanded ? DOCS_WIDTH : COLLAPSED_WIDTH) : 0);
522
+ editorSpace = available - panelsWidth;
523
+ maxEditors = Math.floor(editorSpace / MIN_EDITOR_WIDTH);
524
+ };
525
+
526
+ if (totalEditors >= 1) {
527
+ reclaim(false, !docsActive); // docs, unless the user just opened it
528
+ reclaim(!typesActive, false); // types, unless the user just opened it
493
529
 
494
- if (maxEditors < 1) {
495
- typesExpanded = false;
496
- panelsWidth = COLLAPSED_WIDTH + (hasDocs ? COLLAPSED_WIDTH : 0);
497
- editorSpace = windowWidth - panelsWidth;
498
- maxEditors = Math.floor(editorSpace / MIN_EDITOR_WIDTH);
530
+ // Neither list was explicitly opened, so there is no click to honour —
531
+ // collapse them regardless rather than leave the editor unusable.
532
+ if (!typesActive && !docsActive) {
533
+ reclaim(false, true);
534
+ reclaim(true, false);
499
535
  }
500
536
  }
501
537
 
538
+ // MIN_EDITOR_WIDTH is what the editor *wants*, not a floor it must clear to
539
+ // be shown. If the lists couldn't be collapsed any further (the user
540
+ // explicitly opened one), the editor simply takes what's left — a narrow
541
+ // editor still beats a 60px strip sitting next to unused space.
502
542
  if (maxEditors < 1) maxEditors = 1;
503
543
 
504
- // Build expanded editor indices, prioritizing active + most recent
505
- let expandedIndices: number[] = [validActiveIndex];
544
+ // Build expanded editor indices, prioritizing active + most recent.
545
+ // A negative `validActiveIndex` means a *list* panel holds focus (-1 types,
546
+ // -2 docs), not an editor. Seeding the array with it left no editor in the
547
+ // expanded set at all, so clicking the document list collapsed the open
548
+ // editor to a 60px strip. Focus and space priority are separate concerns:
549
+ // fall back to the deepest editor so one is always expanded.
550
+ const primaryIndex = validActiveIndex >= 0 ? validActiveIndex : totalEditors - 1;
551
+ let expandedIndices: number[] = [primaryIndex];
506
552
  if (maxEditors > 1) {
507
553
  for (let i = totalEditors - 1; i >= 0 && expandedIndices.length < maxEditors; i--) {
508
- if (i !== validActiveIndex) expandedIndices.push(i);
554
+ if (i !== primaryIndex) expandedIndices.push(i);
509
555
  }
510
556
  }
511
557
 
@@ -522,6 +568,11 @@
522
568
  };
523
569
  });
524
570
 
571
+ // Pane widths: both lists are fixed (350px expanded, 60px collapsed) and never
572
+ // flex. Only the editor absorbs leftover width — it is the one pane that reads
573
+ // better wide, whereas a list stretched across 700px is mostly whitespace. With
574
+ // no document open the lists simply sit at their natural width and the space to
575
+ // the right stays empty.
525
576
  let typesPanel = $derived.by(() => {
526
577
  // Focus/presentation mode hides the types sidebar so the editor takes full width.
527
578
  if (focusModeOn || presentationModeOn) return 'hidden';
@@ -609,6 +660,23 @@
609
660
  fetchOrganizations();
610
661
  });
611
662
 
663
+ /**
664
+ * A URL naming an asset should land on the media area.
665
+ *
666
+ * One-shot, on the initial URL only. Reacting to the param on every change
667
+ * would drag the user back to media whenever they navigated away with an
668
+ * `assetId` still in the query — and the param stays until the detail panel
669
+ * is closed, so that is the common case, not the edge one.
670
+ */
671
+ let appliedInitialAssetId = false;
672
+ $effect(() => {
673
+ if (appliedInitialAssetId) return;
674
+ appliedInitialAssetId = true;
675
+ if (page.url.searchParams.get('assetId') && activeTab.value !== 'media') {
676
+ handleTabChange('media');
677
+ }
678
+ });
679
+
612
680
  // Watch URL params for bookmarkable navigation
613
681
  $effect(() => {
614
682
  const url = page.url;
@@ -684,12 +752,22 @@
684
752
  }
685
753
  }
686
754
 
687
- // Restore version history panel from URL
688
- if (historyParam === '1' && !showVersionPanel) {
689
- showVersionPanel = true;
690
- versionPanelDocId = stackParam
755
+ // Restore version history panel from URL.
756
+ //
757
+ // Retarget on every navigation, not only when the panel is closed. The
758
+ // `history=1` param survives switching documents, so a panel opened on
759
+ // document A stayed pinned to A while the editor moved to B — the version
760
+ // list was wrong and Restore would have written to the document the user
761
+ // was no longer looking at. Any preview of A's content is dropped too.
762
+ if (historyParam === '1') {
763
+ const targetDocId = stackParam
691
764
  ? (editorStack[editorStack.length - 1]?.documentId ?? docId)
692
765
  : docId;
766
+ if (!showVersionPanel || versionPanelDocId !== targetDocId) {
767
+ showVersionPanel = true;
768
+ versionPanelDocId = targetDocId;
769
+ versionPreviewData = null;
770
+ }
693
771
  } else if (!historyParam && showVersionPanel) {
694
772
  showVersionPanel = false;
695
773
  versionPanelDocId = null;
@@ -904,6 +982,21 @@
904
982
  activeEditorIndex = 1;
905
983
  }
906
984
 
985
+ /**
986
+ * Mirror the open asset into `?assetId=`, so a media item is linkable.
987
+ *
988
+ * `replaceState`, because browsing a media library is not navigation —
989
+ * clicking through twenty thumbnails would otherwise bury the page the user
990
+ * arrived from under twenty history entries.
991
+ */
992
+ async function syncAssetIdParam(assetId: string | null) {
993
+ const params = new SvelteURLSearchParams(page.url.searchParams);
994
+ if (params.get('assetId') === (assetId ?? null)) return;
995
+ if (assetId) params.set('assetId', assetId);
996
+ else params.delete('assetId');
997
+ await goto(`/admin?${params.toString()}`, { replaceState: true, noScroll: true });
998
+ }
999
+
907
1000
  // Back button on the stacked panel — pop one level. If the stack
908
1001
  // becomes empty, the panel closes entirely.
909
1002
  async function handleStackedEditorBack() {
@@ -1178,7 +1271,10 @@
1178
1271
  <Tabs.Root value={activeTab.value} onValueChange={handleTabChange} class="h-full">
1179
1272
  <Tabs.Content value="structure" class="h-full overflow-hidden">
1180
1273
  {#key `${currentView}-${selectedDocumentType}`}
1181
- <div class={windowWidth < 620 ? 'h-full w-full' : 'flex h-full w-full overflow-hidden'}>
1274
+ <div
1275
+ bind:clientWidth={contentWidth}
1276
+ class={windowWidth < 620 ? 'h-full w-full' : 'flex h-full w-full overflow-hidden'}
1277
+ >
1182
1278
  {#if schemaError}
1183
1279
  <div class="bg-destructive/5 flex flex-1 items-center justify-center p-8">
1184
1280
  <div class="w-full max-w-2xl">
@@ -1874,10 +1970,14 @@
1874
1970
  {/if}
1875
1971
  {/if}
1876
1972
 
1877
- <!-- Version History Panel -->
1973
+ <!-- Version History Panel. Below 620px there is no room for a 280px
1974
+ column beside the editor — it left ~95px for the fields — so it
1975
+ becomes a full-screen sheet, dismissed with its own close button. -->
1878
1976
  {#if showVersionPanel && versionPanelDocId}
1879
1977
  <div
1880
- class="border-rule h-full w-[280px] shrink-0 overflow-y-auto border-l transition-all duration-200"
1978
+ class={windowWidth < 620
1979
+ ? 'bg-background fixed inset-0 z-50 overflow-y-auto'
1980
+ : 'border-rule h-full w-[280px] shrink-0 overflow-y-auto border-l transition-all duration-200'}
1881
1981
  >
1882
1982
  <DocumentVersionPanel
1883
1983
  bind:this={versionPanelRef}
@@ -1949,7 +2049,11 @@
1949
2049
  {/if}
1950
2050
 
1951
2051
  <Tabs.Content value="media" class="m-0 h-full p-0">
1952
- <MediaBrowser active={activeTab.value === 'media'} />
2052
+ <MediaBrowser
2053
+ active={activeTab.value === 'media'}
2054
+ assetId={page.url.searchParams.get('assetId')}
2055
+ onAssetOpen={syncAssetIdParam}
2056
+ />
1953
2057
  </Tabs.Content>
1954
2058
 
1955
2059
  <!-- Plugin admin tools — each rendered as its own top-level area. -->