@pyric/ui 0.1.0-alpha.7

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 (594) hide show
  1. package/README.md +79 -0
  2. package/dist/agents/ContextWindowUsage.d.ts +67 -0
  3. package/dist/agents/ContextWindowUsage.d.ts.map +1 -0
  4. package/dist/agents/ContextWindowUsage.js +115 -0
  5. package/dist/agents/ContextWindowUsage.js.map +1 -0
  6. package/dist/agents/EmptyState.d.ts +18 -0
  7. package/dist/agents/EmptyState.d.ts.map +1 -0
  8. package/dist/agents/EmptyState.js +11 -0
  9. package/dist/agents/EmptyState.js.map +1 -0
  10. package/dist/agents/Fold.d.ts +37 -0
  11. package/dist/agents/Fold.d.ts.map +1 -0
  12. package/dist/agents/Fold.js +18 -0
  13. package/dist/agents/Fold.js.map +1 -0
  14. package/dist/agents/Modal.d.ts +25 -0
  15. package/dist/agents/Modal.d.ts.map +1 -0
  16. package/dist/agents/Modal.js +28 -0
  17. package/dist/agents/Modal.js.map +1 -0
  18. package/dist/agents/PulsingDot.d.ts +21 -0
  19. package/dist/agents/PulsingDot.d.ts.map +1 -0
  20. package/dist/agents/PulsingDot.js +18 -0
  21. package/dist/agents/PulsingDot.js.map +1 -0
  22. package/dist/agents/index.d.ts +15 -0
  23. package/dist/agents/index.d.ts.map +1 -0
  24. package/dist/agents/index.js +15 -0
  25. package/dist/agents/index.js.map +1 -0
  26. package/dist/auth/authApi.d.ts +32 -0
  27. package/dist/auth/authApi.d.ts.map +1 -0
  28. package/dist/auth/authApi.js +27 -0
  29. package/dist/auth/authApi.js.map +1 -0
  30. package/dist/auth/claims.d.ts +27 -0
  31. package/dist/auth/claims.d.ts.map +1 -0
  32. package/dist/auth/claims.js +58 -0
  33. package/dist/auth/claims.js.map +1 -0
  34. package/dist/auth/components/AuthProviderToggles.d.ts +31 -0
  35. package/dist/auth/components/AuthProviderToggles.d.ts.map +1 -0
  36. package/dist/auth/components/AuthProviderToggles.js +48 -0
  37. package/dist/auth/components/AuthProviderToggles.js.map +1 -0
  38. package/dist/auth/components/AuthSignInHelper.d.ts +57 -0
  39. package/dist/auth/components/AuthSignInHelper.d.ts.map +1 -0
  40. package/dist/auth/components/AuthSignInHelper.js +69 -0
  41. package/dist/auth/components/AuthSignInHelper.js.map +1 -0
  42. package/dist/auth/components/AuthUserForm.d.ts +84 -0
  43. package/dist/auth/components/AuthUserForm.d.ts.map +1 -0
  44. package/dist/auth/components/AuthUserForm.js +89 -0
  45. package/dist/auth/components/AuthUserForm.js.map +1 -0
  46. package/dist/auth/components/AuthUserList.d.ts +51 -0
  47. package/dist/auth/components/AuthUserList.d.ts.map +1 -0
  48. package/dist/auth/components/AuthUserList.js +46 -0
  49. package/dist/auth/components/AuthUserList.js.map +1 -0
  50. package/dist/auth/components/ClaimsField.d.ts +22 -0
  51. package/dist/auth/components/ClaimsField.d.ts.map +1 -0
  52. package/dist/auth/components/ClaimsField.js +11 -0
  53. package/dist/auth/components/ClaimsField.js.map +1 -0
  54. package/dist/auth/components/confirmActions.d.ts +40 -0
  55. package/dist/auth/components/confirmActions.d.ts.map +1 -0
  56. package/dist/auth/components/confirmActions.js +49 -0
  57. package/dist/auth/components/confirmActions.js.map +1 -0
  58. package/dist/auth/controller.d.ts +73 -0
  59. package/dist/auth/controller.d.ts.map +1 -0
  60. package/dist/auth/controller.js +139 -0
  61. package/dist/auth/controller.js.map +1 -0
  62. package/dist/auth/hooks/index.d.ts +7 -0
  63. package/dist/auth/hooks/index.d.ts.map +1 -0
  64. package/dist/auth/hooks/index.js +7 -0
  65. package/dist/auth/hooks/index.js.map +1 -0
  66. package/dist/auth/hooks/useAuthFlowHelper.d.ts +30 -0
  67. package/dist/auth/hooks/useAuthFlowHelper.d.ts.map +1 -0
  68. package/dist/auth/hooks/useAuthFlowHelper.js +30 -0
  69. package/dist/auth/hooks/useAuthFlowHelper.js.map +1 -0
  70. package/dist/auth/hooks/useAuthProviderConfig.d.ts +37 -0
  71. package/dist/auth/hooks/useAuthProviderConfig.d.ts.map +1 -0
  72. package/dist/auth/hooks/useAuthProviderConfig.js +98 -0
  73. package/dist/auth/hooks/useAuthProviderConfig.js.map +1 -0
  74. package/dist/auth/hooks/useAuthUserEditor.d.ts +30 -0
  75. package/dist/auth/hooks/useAuthUserEditor.d.ts.map +1 -0
  76. package/dist/auth/hooks/useAuthUserEditor.js +27 -0
  77. package/dist/auth/hooks/useAuthUserEditor.js.map +1 -0
  78. package/dist/auth/hooks/useAuthUsers.d.ts +38 -0
  79. package/dist/auth/hooks/useAuthUsers.d.ts.map +1 -0
  80. package/dist/auth/hooks/useAuthUsers.js +111 -0
  81. package/dist/auth/hooks/useAuthUsers.js.map +1 -0
  82. package/dist/auth/index.d.ts +11 -0
  83. package/dist/auth/index.d.ts.map +1 -0
  84. package/dist/auth/index.js +13 -0
  85. package/dist/auth/index.js.map +1 -0
  86. package/dist/auth/providers.d.ts +11 -0
  87. package/dist/auth/providers.d.ts.map +1 -0
  88. package/dist/auth/providers.js +28 -0
  89. package/dist/auth/providers.js.map +1 -0
  90. package/dist/auth/reducers/userEditor.d.ts +55 -0
  91. package/dist/auth/reducers/userEditor.d.ts.map +1 -0
  92. package/dist/auth/reducers/userEditor.js +136 -0
  93. package/dist/auth/reducers/userEditor.js.map +1 -0
  94. package/dist/events/components/ActivityActionItems.d.ts +45 -0
  95. package/dist/events/components/ActivityActionItems.d.ts.map +1 -0
  96. package/dist/events/components/ActivityActionItems.js +68 -0
  97. package/dist/events/components/ActivityActionItems.js.map +1 -0
  98. package/dist/events/components/ActivityGrid.d.ts +65 -0
  99. package/dist/events/components/ActivityGrid.d.ts.map +1 -0
  100. package/dist/events/components/ActivityGrid.js +61 -0
  101. package/dist/events/components/ActivityGrid.js.map +1 -0
  102. package/dist/events/components/ActivityGridRow.d.ts +31 -0
  103. package/dist/events/components/ActivityGridRow.d.ts.map +1 -0
  104. package/dist/events/components/ActivityGridRow.js +23 -0
  105. package/dist/events/components/ActivityGridRow.js.map +1 -0
  106. package/dist/events/components/ProposedChangeDiff.d.ts +46 -0
  107. package/dist/events/components/ProposedChangeDiff.d.ts.map +1 -0
  108. package/dist/events/components/ProposedChangeDiff.js +60 -0
  109. package/dist/events/components/ProposedChangeDiff.js.map +1 -0
  110. package/dist/events/components/format.d.ts +11 -0
  111. package/dist/events/components/format.d.ts.map +1 -0
  112. package/dist/events/components/format.js +26 -0
  113. package/dist/events/components/format.js.map +1 -0
  114. package/dist/events/components/index.d.ts +6 -0
  115. package/dist/events/components/index.d.ts.map +1 -0
  116. package/dist/events/components/index.js +6 -0
  117. package/dist/events/components/index.js.map +1 -0
  118. package/dist/events/digest.d.ts +167 -0
  119. package/dist/events/digest.d.ts.map +1 -0
  120. package/dist/events/digest.js +426 -0
  121. package/dist/events/digest.js.map +1 -0
  122. package/dist/events/hooks/index.d.ts +3 -0
  123. package/dist/events/hooks/index.d.ts.map +1 -0
  124. package/dist/events/hooks/index.js +3 -0
  125. package/dist/events/hooks/index.js.map +1 -0
  126. package/dist/events/hooks/useActivityDigest.d.ts +27 -0
  127. package/dist/events/hooks/useActivityDigest.d.ts.map +1 -0
  128. package/dist/events/hooks/useActivityDigest.js +18 -0
  129. package/dist/events/hooks/useActivityDigest.js.map +1 -0
  130. package/dist/events/hooks/useActivityStream.d.ts +44 -0
  131. package/dist/events/hooks/useActivityStream.d.ts.map +1 -0
  132. package/dist/events/hooks/useActivityStream.js +38 -0
  133. package/dist/events/hooks/useActivityStream.js.map +1 -0
  134. package/dist/events/index.d.ts +15 -0
  135. package/dist/events/index.d.ts.map +1 -0
  136. package/dist/events/index.js +14 -0
  137. package/dist/events/index.js.map +1 -0
  138. package/dist/events/types.d.ts +160 -0
  139. package/dist/events/types.d.ts.map +1 -0
  140. package/dist/events/types.js +21 -0
  141. package/dist/events/types.js.map +1 -0
  142. package/dist/firestore/components/CollectionList.d.ts +22 -0
  143. package/dist/firestore/components/CollectionList.d.ts.map +1 -0
  144. package/dist/firestore/components/CollectionList.js +21 -0
  145. package/dist/firestore/components/CollectionList.js.map +1 -0
  146. package/dist/firestore/components/DeleteWithConfirm.d.ts +38 -0
  147. package/dist/firestore/components/DeleteWithConfirm.d.ts.map +1 -0
  148. package/dist/firestore/components/DeleteWithConfirm.js +33 -0
  149. package/dist/firestore/components/DeleteWithConfirm.js.map +1 -0
  150. package/dist/firestore/components/DocumentEditor.d.ts +47 -0
  151. package/dist/firestore/components/DocumentEditor.d.ts.map +1 -0
  152. package/dist/firestore/components/DocumentEditor.js +176 -0
  153. package/dist/firestore/components/DocumentEditor.js.map +1 -0
  154. package/dist/firestore/components/DocumentList.d.ts +60 -0
  155. package/dist/firestore/components/DocumentList.d.ts.map +1 -0
  156. package/dist/firestore/components/DocumentList.js +39 -0
  157. package/dist/firestore/components/DocumentList.js.map +1 -0
  158. package/dist/firestore/components/DocumentPreview.d.ts +68 -0
  159. package/dist/firestore/components/DocumentPreview.d.ts.map +1 -0
  160. package/dist/firestore/components/DocumentPreview.js +76 -0
  161. package/dist/firestore/components/DocumentPreview.js.map +1 -0
  162. package/dist/firestore/components/FieldRenderer.d.ts +17 -0
  163. package/dist/firestore/components/FieldRenderer.d.ts.map +1 -0
  164. package/dist/firestore/components/FieldRenderer.js +16 -0
  165. package/dist/firestore/components/FieldRenderer.js.map +1 -0
  166. package/dist/firestore/components/QueryBuilder.d.ts +25 -0
  167. package/dist/firestore/components/QueryBuilder.d.ts.map +1 -0
  168. package/dist/firestore/components/QueryBuilder.js +78 -0
  169. package/dist/firestore/components/QueryBuilder.js.map +1 -0
  170. package/dist/firestore/components/ReferencePicker.d.ts +33 -0
  171. package/dist/firestore/components/ReferencePicker.d.ts.map +1 -0
  172. package/dist/firestore/components/ReferencePicker.js +42 -0
  173. package/dist/firestore/components/ReferencePicker.js.map +1 -0
  174. package/dist/firestore/components/TreeEntry.d.ts +15 -0
  175. package/dist/firestore/components/TreeEntry.d.ts.map +1 -0
  176. package/dist/firestore/components/TreeEntry.js +23 -0
  177. package/dist/firestore/components/TreeEntry.js.map +1 -0
  178. package/dist/firestore/components/context.d.ts +18 -0
  179. package/dist/firestore/components/context.d.ts.map +1 -0
  180. package/dist/firestore/components/context.js +7 -0
  181. package/dist/firestore/components/context.js.map +1 -0
  182. package/dist/firestore/fieldEditors/array.d.ts +3 -0
  183. package/dist/firestore/fieldEditors/array.d.ts.map +1 -0
  184. package/dist/firestore/fieldEditors/array.js +16 -0
  185. package/dist/firestore/fieldEditors/array.js.map +1 -0
  186. package/dist/firestore/fieldEditors/boolean.d.ts +3 -0
  187. package/dist/firestore/fieldEditors/boolean.d.ts.map +1 -0
  188. package/dist/firestore/fieldEditors/boolean.js +13 -0
  189. package/dist/firestore/fieldEditors/boolean.js.map +1 -0
  190. package/dist/firestore/fieldEditors/bytes.d.ts +4 -0
  191. package/dist/firestore/fieldEditors/bytes.d.ts.map +1 -0
  192. package/dist/firestore/fieldEditors/bytes.js +31 -0
  193. package/dist/firestore/fieldEditors/bytes.js.map +1 -0
  194. package/dist/firestore/fieldEditors/geopoint.d.ts +4 -0
  195. package/dist/firestore/fieldEditors/geopoint.d.ts.map +1 -0
  196. package/dist/firestore/fieldEditors/geopoint.js +32 -0
  197. package/dist/firestore/fieldEditors/geopoint.js.map +1 -0
  198. package/dist/firestore/fieldEditors/map.d.ts +3 -0
  199. package/dist/firestore/fieldEditors/map.d.ts.map +1 -0
  200. package/dist/firestore/fieldEditors/map.js +19 -0
  201. package/dist/firestore/fieldEditors/map.js.map +1 -0
  202. package/dist/firestore/fieldEditors/null.d.ts +3 -0
  203. package/dist/firestore/fieldEditors/null.d.ts.map +1 -0
  204. package/dist/firestore/fieldEditors/null.js +17 -0
  205. package/dist/firestore/fieldEditors/null.js.map +1 -0
  206. package/dist/firestore/fieldEditors/number.d.ts +3 -0
  207. package/dist/firestore/fieldEditors/number.d.ts.map +1 -0
  208. package/dist/firestore/fieldEditors/number.js +24 -0
  209. package/dist/firestore/fieldEditors/number.js.map +1 -0
  210. package/dist/firestore/fieldEditors/reference.d.ts +4 -0
  211. package/dist/firestore/fieldEditors/reference.d.ts.map +1 -0
  212. package/dist/firestore/fieldEditors/reference.js +49 -0
  213. package/dist/firestore/fieldEditors/reference.js.map +1 -0
  214. package/dist/firestore/fieldEditors/registry.d.ts +16 -0
  215. package/dist/firestore/fieldEditors/registry.d.ts.map +1 -0
  216. package/dist/firestore/fieldEditors/registry.js +42 -0
  217. package/dist/firestore/fieldEditors/registry.js.map +1 -0
  218. package/dist/firestore/fieldEditors/string.d.ts +3 -0
  219. package/dist/firestore/fieldEditors/string.d.ts.map +1 -0
  220. package/dist/firestore/fieldEditors/string.js +13 -0
  221. package/dist/firestore/fieldEditors/string.js.map +1 -0
  222. package/dist/firestore/fieldEditors/timestamp.d.ts +4 -0
  223. package/dist/firestore/fieldEditors/timestamp.d.ts.map +1 -0
  224. package/dist/firestore/fieldEditors/timestamp.js +52 -0
  225. package/dist/firestore/fieldEditors/timestamp.js.map +1 -0
  226. package/dist/firestore/fieldEditors/types.d.ts +64 -0
  227. package/dist/firestore/fieldEditors/types.d.ts.map +1 -0
  228. package/dist/firestore/fieldEditors/types.js +2 -0
  229. package/dist/firestore/fieldEditors/types.js.map +1 -0
  230. package/dist/firestore/fieldEditors/vector.d.ts +29 -0
  231. package/dist/firestore/fieldEditors/vector.d.ts.map +1 -0
  232. package/dist/firestore/fieldEditors/vector.js +93 -0
  233. package/dist/firestore/fieldEditors/vector.js.map +1 -0
  234. package/dist/firestore/firestoreApi.d.ts +35 -0
  235. package/dist/firestore/firestoreApi.d.ts.map +1 -0
  236. package/dist/firestore/firestoreApi.js +28 -0
  237. package/dist/firestore/firestoreApi.js.map +1 -0
  238. package/dist/firestore/hooks/coerceError.d.ts +17 -0
  239. package/dist/firestore/hooks/coerceError.d.ts.map +1 -0
  240. package/dist/firestore/hooks/coerceError.js +41 -0
  241. package/dist/firestore/hooks/coerceError.js.map +1 -0
  242. package/dist/firestore/hooks/index.d.ts +10 -0
  243. package/dist/firestore/hooks/index.d.ts.map +1 -0
  244. package/dist/firestore/hooks/index.js +10 -0
  245. package/dist/firestore/hooks/index.js.map +1 -0
  246. package/dist/firestore/hooks/useCollectionList.d.ts +37 -0
  247. package/dist/firestore/hooks/useCollectionList.d.ts.map +1 -0
  248. package/dist/firestore/hooks/useCollectionList.js +51 -0
  249. package/dist/firestore/hooks/useCollectionList.js.map +1 -0
  250. package/dist/firestore/hooks/useDocumentEditor.d.ts +58 -0
  251. package/dist/firestore/hooks/useDocumentEditor.d.ts.map +1 -0
  252. package/dist/firestore/hooks/useDocumentEditor.js +68 -0
  253. package/dist/firestore/hooks/useDocumentEditor.js.map +1 -0
  254. package/dist/firestore/hooks/useDocumentList.d.ts +45 -0
  255. package/dist/firestore/hooks/useDocumentList.d.ts.map +1 -0
  256. package/dist/firestore/hooks/useDocumentList.js +112 -0
  257. package/dist/firestore/hooks/useDocumentList.js.map +1 -0
  258. package/dist/firestore/hooks/useDocumentSubcollections.d.ts +29 -0
  259. package/dist/firestore/hooks/useDocumentSubcollections.d.ts.map +1 -0
  260. package/dist/firestore/hooks/useDocumentSubcollections.js +48 -0
  261. package/dist/firestore/hooks/useDocumentSubcollections.js.map +1 -0
  262. package/dist/firestore/hooks/useFirestoreCollection.d.ts +14 -0
  263. package/dist/firestore/hooks/useFirestoreCollection.d.ts.map +1 -0
  264. package/dist/firestore/hooks/useFirestoreCollection.js +35 -0
  265. package/dist/firestore/hooks/useFirestoreCollection.js.map +1 -0
  266. package/dist/firestore/hooks/useFirestoreDoc.d.ts +17 -0
  267. package/dist/firestore/hooks/useFirestoreDoc.d.ts.map +1 -0
  268. package/dist/firestore/hooks/useFirestoreDoc.js +34 -0
  269. package/dist/firestore/hooks/useFirestoreDoc.js.map +1 -0
  270. package/dist/firestore/hooks/useQueryBuilder.d.ts +51 -0
  271. package/dist/firestore/hooks/useQueryBuilder.d.ts.map +1 -0
  272. package/dist/firestore/hooks/useQueryBuilder.js +110 -0
  273. package/dist/firestore/hooks/useQueryBuilder.js.map +1 -0
  274. package/dist/firestore/hooks/useRecursiveDelete.d.ts +40 -0
  275. package/dist/firestore/hooks/useRecursiveDelete.d.ts.map +1 -0
  276. package/dist/firestore/hooks/useRecursiveDelete.js +44 -0
  277. package/dist/firestore/hooks/useRecursiveDelete.js.map +1 -0
  278. package/dist/firestore/hooks/useReferencePicker.d.ts +70 -0
  279. package/dist/firestore/hooks/useReferencePicker.d.ts.map +1 -0
  280. package/dist/firestore/hooks/useReferencePicker.js +140 -0
  281. package/dist/firestore/hooks/useReferencePicker.js.map +1 -0
  282. package/dist/firestore/import/parseImport.d.ts +55 -0
  283. package/dist/firestore/import/parseImport.d.ts.map +1 -0
  284. package/dist/firestore/import/parseImport.js +101 -0
  285. package/dist/firestore/import/parseImport.js.map +1 -0
  286. package/dist/firestore/index.d.ts +20 -0
  287. package/dist/firestore/index.d.ts.map +1 -0
  288. package/dist/firestore/index.js +28 -0
  289. package/dist/firestore/index.js.map +1 -0
  290. package/dist/firestore/reducers/defaults.d.ts +10 -0
  291. package/dist/firestore/reducers/defaults.d.ts.map +1 -0
  292. package/dist/firestore/reducers/defaults.js +37 -0
  293. package/dist/firestore/reducers/defaults.js.map +1 -0
  294. package/dist/firestore/reducers/documentEditor.d.ts +23 -0
  295. package/dist/firestore/reducers/documentEditor.d.ts.map +1 -0
  296. package/dist/firestore/reducers/documentEditor.js +199 -0
  297. package/dist/firestore/reducers/documentEditor.js.map +1 -0
  298. package/dist/firestore/reducers/tree.d.ts +28 -0
  299. package/dist/firestore/reducers/tree.d.ts.map +1 -0
  300. package/dist/firestore/reducers/tree.js +129 -0
  301. package/dist/firestore/reducers/tree.js.map +1 -0
  302. package/dist/firestore/reducers/types.d.ts +112 -0
  303. package/dist/firestore/reducers/types.d.ts.map +1 -0
  304. package/dist/firestore/reducers/types.js +2 -0
  305. package/dist/firestore/reducers/types.js.map +1 -0
  306. package/dist/firestore/reducers/validation.d.ts +25 -0
  307. package/dist/firestore/reducers/validation.d.ts.map +1 -0
  308. package/dist/firestore/reducers/validation.js +121 -0
  309. package/dist/firestore/reducers/validation.js.map +1 -0
  310. package/dist/firestore/types.d.ts +77 -0
  311. package/dist/firestore/types.d.ts.map +1 -0
  312. package/dist/firestore/types.js +196 -0
  313. package/dist/firestore/types.js.map +1 -0
  314. package/dist/firestore/validation/ids.d.ts +23 -0
  315. package/dist/firestore/validation/ids.d.ts.map +1 -0
  316. package/dist/firestore/validation/ids.js +46 -0
  317. package/dist/firestore/validation/ids.js.map +1 -0
  318. package/dist/index.d.ts +2 -0
  319. package/dist/index.d.ts.map +1 -0
  320. package/dist/index.js +2 -0
  321. package/dist/index.js.map +1 -0
  322. package/dist/primitives/Badge.d.ts +28 -0
  323. package/dist/primitives/Badge.d.ts.map +1 -0
  324. package/dist/primitives/Badge.js +11 -0
  325. package/dist/primitives/Badge.js.map +1 -0
  326. package/dist/primitives/ConfirmDialog.d.ts +42 -0
  327. package/dist/primitives/ConfirmDialog.d.ts.map +1 -0
  328. package/dist/primitives/ConfirmDialog.js +61 -0
  329. package/dist/primitives/ConfirmDialog.js.map +1 -0
  330. package/dist/primitives/CopyButton.d.ts +28 -0
  331. package/dist/primitives/CopyButton.d.ts.map +1 -0
  332. package/dist/primitives/CopyButton.js +27 -0
  333. package/dist/primitives/CopyButton.js.map +1 -0
  334. package/dist/primitives/JsonView.d.ts +29 -0
  335. package/dist/primitives/JsonView.d.ts.map +1 -0
  336. package/dist/primitives/JsonView.js +56 -0
  337. package/dist/primitives/JsonView.js.map +1 -0
  338. package/dist/primitives/SegmentedControl.d.ts +37 -0
  339. package/dist/primitives/SegmentedControl.d.ts.map +1 -0
  340. package/dist/primitives/SegmentedControl.js +18 -0
  341. package/dist/primitives/SegmentedControl.js.map +1 -0
  342. package/dist/primitives/Toast.d.ts +48 -0
  343. package/dist/primitives/Toast.d.ts.map +1 -0
  344. package/dist/primitives/Toast.js +60 -0
  345. package/dist/primitives/Toast.js.map +1 -0
  346. package/dist/primitives/VirtualList.d.ts +37 -0
  347. package/dist/primitives/VirtualList.d.ts.map +1 -0
  348. package/dist/primitives/VirtualList.js +47 -0
  349. package/dist/primitives/VirtualList.js.map +1 -0
  350. package/dist/primitives/hooks/useContainerSize.d.ts +29 -0
  351. package/dist/primitives/hooks/useContainerSize.d.ts.map +1 -0
  352. package/dist/primitives/hooks/useContainerSize.js +45 -0
  353. package/dist/primitives/hooks/useContainerSize.js.map +1 -0
  354. package/dist/primitives/index.d.ts +10 -0
  355. package/dist/primitives/index.d.ts.map +1 -0
  356. package/dist/primitives/index.js +10 -0
  357. package/dist/primitives/index.js.map +1 -0
  358. package/dist/primitives/useConfirm.d.ts +34 -0
  359. package/dist/primitives/useConfirm.d.ts.map +1 -0
  360. package/dist/primitives/useConfirm.js +63 -0
  361. package/dist/primitives/useConfirm.js.map +1 -0
  362. package/dist/rtdb/components/RtdbPathBar.d.ts +31 -0
  363. package/dist/rtdb/components/RtdbPathBar.d.ts.map +1 -0
  364. package/dist/rtdb/components/RtdbPathBar.js +47 -0
  365. package/dist/rtdb/components/RtdbPathBar.js.map +1 -0
  366. package/dist/rtdb/components/RtdbTree.d.ts +38 -0
  367. package/dist/rtdb/components/RtdbTree.d.ts.map +1 -0
  368. package/dist/rtdb/components/RtdbTree.js +103 -0
  369. package/dist/rtdb/components/RtdbTree.js.map +1 -0
  370. package/dist/rtdb/editor.d.ts +25 -0
  371. package/dist/rtdb/editor.d.ts.map +1 -0
  372. package/dist/rtdb/editor.js +79 -0
  373. package/dist/rtdb/editor.js.map +1 -0
  374. package/dist/rtdb/hooks/useRtdbTree.d.ts +31 -0
  375. package/dist/rtdb/hooks/useRtdbTree.d.ts.map +1 -0
  376. package/dist/rtdb/hooks/useRtdbTree.js +49 -0
  377. package/dist/rtdb/hooks/useRtdbTree.js.map +1 -0
  378. package/dist/rtdb/index.d.ts +17 -0
  379. package/dist/rtdb/index.d.ts.map +1 -0
  380. package/dist/rtdb/index.js +21 -0
  381. package/dist/rtdb/index.js.map +1 -0
  382. package/dist/rtdb/pathInput.d.ts +28 -0
  383. package/dist/rtdb/pathInput.d.ts.map +1 -0
  384. package/dist/rtdb/pathInput.js +40 -0
  385. package/dist/rtdb/pathInput.js.map +1 -0
  386. package/dist/rtdb/reducers/tree.d.ts +86 -0
  387. package/dist/rtdb/reducers/tree.d.ts.map +1 -0
  388. package/dist/rtdb/reducers/tree.js +131 -0
  389. package/dist/rtdb/reducers/tree.js.map +1 -0
  390. package/dist/rtdb/rtdbApi.d.ts +20 -0
  391. package/dist/rtdb/rtdbApi.d.ts.map +1 -0
  392. package/dist/rtdb/rtdbApi.js +2 -0
  393. package/dist/rtdb/rtdbApi.js.map +1 -0
  394. package/dist/rtdb/values.d.ts +44 -0
  395. package/dist/rtdb/values.d.ts.map +1 -0
  396. package/dist/rtdb/values.js +143 -0
  397. package/dist/rtdb/values.js.map +1 -0
  398. package/dist/rules/components/DenialInspector.d.ts +18 -0
  399. package/dist/rules/components/DenialInspector.d.ts.map +1 -0
  400. package/dist/rules/components/DenialInspector.js +58 -0
  401. package/dist/rules/components/DenialInspector.js.map +1 -0
  402. package/dist/rules/components/format.d.ts +56 -0
  403. package/dist/rules/components/format.d.ts.map +1 -0
  404. package/dist/rules/components/format.js +137 -0
  405. package/dist/rules/components/format.js.map +1 -0
  406. package/dist/rules/components/index.d.ts +4 -0
  407. package/dist/rules/components/index.d.ts.map +1 -0
  408. package/dist/rules/components/index.js +4 -0
  409. package/dist/rules/components/index.js.map +1 -0
  410. package/dist/rules/components/scope.d.ts +10 -0
  411. package/dist/rules/components/scope.d.ts.map +1 -0
  412. package/dist/rules/components/scope.js +72 -0
  413. package/dist/rules/components/scope.js.map +1 -0
  414. package/dist/rules/hooks/index.d.ts +2 -0
  415. package/dist/rules/hooks/index.d.ts.map +1 -0
  416. package/dist/rules/hooks/index.js +2 -0
  417. package/dist/rules/hooks/index.js.map +1 -0
  418. package/dist/rules/hooks/useDenialTrace.d.ts +51 -0
  419. package/dist/rules/hooks/useDenialTrace.d.ts.map +1 -0
  420. package/dist/rules/hooks/useDenialTrace.js +58 -0
  421. package/dist/rules/hooks/useDenialTrace.js.map +1 -0
  422. package/dist/rules/index.d.ts +14 -0
  423. package/dist/rules/index.d.ts.map +1 -0
  424. package/dist/rules/index.js +13 -0
  425. package/dist/rules/index.js.map +1 -0
  426. package/dist/rules/types.d.ts +75 -0
  427. package/dist/rules/types.d.ts.map +1 -0
  428. package/dist/rules/types.js +2 -0
  429. package/dist/rules/types.js.map +1 -0
  430. package/dist/storage/collisionRename.d.ts +73 -0
  431. package/dist/storage/collisionRename.d.ts.map +1 -0
  432. package/dist/storage/collisionRename.js +113 -0
  433. package/dist/storage/collisionRename.js.map +1 -0
  434. package/dist/storage/components/DeleteSelectionWithConfirm.d.ts +68 -0
  435. package/dist/storage/components/DeleteSelectionWithConfirm.d.ts.map +1 -0
  436. package/dist/storage/components/DeleteSelectionWithConfirm.js +82 -0
  437. package/dist/storage/components/DeleteSelectionWithConfirm.js.map +1 -0
  438. package/dist/storage/components/ObjectBrowser.d.ts +75 -0
  439. package/dist/storage/components/ObjectBrowser.d.ts.map +1 -0
  440. package/dist/storage/components/ObjectBrowser.js +59 -0
  441. package/dist/storage/components/ObjectBrowser.js.map +1 -0
  442. package/dist/storage/components/ObjectInspector.d.ts +43 -0
  443. package/dist/storage/components/ObjectInspector.d.ts.map +1 -0
  444. package/dist/storage/components/ObjectInspector.js +92 -0
  445. package/dist/storage/components/ObjectInspector.js.map +1 -0
  446. package/dist/storage/components/PathBreadcrumb.d.ts +30 -0
  447. package/dist/storage/components/PathBreadcrumb.d.ts.map +1 -0
  448. package/dist/storage/components/PathBreadcrumb.js +26 -0
  449. package/dist/storage/components/PathBreadcrumb.js.map +1 -0
  450. package/dist/storage/components/UploadDropzone.d.ts +50 -0
  451. package/dist/storage/components/UploadDropzone.d.ts.map +1 -0
  452. package/dist/storage/components/UploadDropzone.js +109 -0
  453. package/dist/storage/components/UploadDropzone.js.map +1 -0
  454. package/dist/storage/folderPlaceholder.d.ts +14 -0
  455. package/dist/storage/folderPlaceholder.d.ts.map +1 -0
  456. package/dist/storage/folderPlaceholder.js +27 -0
  457. package/dist/storage/folderPlaceholder.js.map +1 -0
  458. package/dist/storage/hooks/index.d.ts +9 -0
  459. package/dist/storage/hooks/index.d.ts.map +1 -0
  460. package/dist/storage/hooks/index.js +9 -0
  461. package/dist/storage/hooks/index.js.map +1 -0
  462. package/dist/storage/hooks/useMetadataEditor.d.ts +114 -0
  463. package/dist/storage/hooks/useMetadataEditor.d.ts.map +1 -0
  464. package/dist/storage/hooks/useMetadataEditor.js +193 -0
  465. package/dist/storage/hooks/useMetadataEditor.js.map +1 -0
  466. package/dist/storage/hooks/useObjectUpload.d.ts +109 -0
  467. package/dist/storage/hooks/useObjectUpload.d.ts.map +1 -0
  468. package/dist/storage/hooks/useObjectUpload.js +134 -0
  469. package/dist/storage/hooks/useObjectUpload.js.map +1 -0
  470. package/dist/storage/hooks/usePathState.d.ts +43 -0
  471. package/dist/storage/hooks/usePathState.d.ts.map +1 -0
  472. package/dist/storage/hooks/usePathState.js +42 -0
  473. package/dist/storage/hooks/usePathState.js.map +1 -0
  474. package/dist/storage/hooks/useStorageDelete.d.ts +73 -0
  475. package/dist/storage/hooks/useStorageDelete.d.ts.map +1 -0
  476. package/dist/storage/hooks/useStorageDelete.js +114 -0
  477. package/dist/storage/hooks/useStorageDelete.js.map +1 -0
  478. package/dist/storage/hooks/useStorageList.d.ts +74 -0
  479. package/dist/storage/hooks/useStorageList.d.ts.map +1 -0
  480. package/dist/storage/hooks/useStorageList.js +167 -0
  481. package/dist/storage/hooks/useStorageList.js.map +1 -0
  482. package/dist/storage/hooks/useStorageObject.d.ts +34 -0
  483. package/dist/storage/hooks/useStorageObject.d.ts.map +1 -0
  484. package/dist/storage/hooks/useStorageObject.js +114 -0
  485. package/dist/storage/hooks/useStorageObject.js.map +1 -0
  486. package/dist/storage/hooks/useStorageRulesGate.d.ts +128 -0
  487. package/dist/storage/hooks/useStorageRulesGate.d.ts.map +1 -0
  488. package/dist/storage/hooks/useStorageRulesGate.js +158 -0
  489. package/dist/storage/hooks/useStorageRulesGate.js.map +1 -0
  490. package/dist/storage/hooks/useStorageSelection.d.ts +32 -0
  491. package/dist/storage/hooks/useStorageSelection.d.ts.map +1 -0
  492. package/dist/storage/hooks/useStorageSelection.js +55 -0
  493. package/dist/storage/hooks/useStorageSelection.js.map +1 -0
  494. package/dist/storage/index.d.ts +11 -0
  495. package/dist/storage/index.d.ts.map +1 -0
  496. package/dist/storage/index.js +17 -0
  497. package/dist/storage/index.js.map +1 -0
  498. package/dist/storage/pendingPrefixes.d.ts +73 -0
  499. package/dist/storage/pendingPrefixes.d.ts.map +1 -0
  500. package/dist/storage/pendingPrefixes.js +98 -0
  501. package/dist/storage/pendingPrefixes.js.map +1 -0
  502. package/dist/storage/previews.d.ts +51 -0
  503. package/dist/storage/previews.d.ts.map +1 -0
  504. package/dist/storage/previews.js +73 -0
  505. package/dist/storage/previews.js.map +1 -0
  506. package/dist/storage/storageApi.d.ts +30 -0
  507. package/dist/storage/storageApi.d.ts.map +1 -0
  508. package/dist/storage/storageApi.js +13 -0
  509. package/dist/storage/storageApi.js.map +1 -0
  510. package/dist/traffic/components/RuleHeatmap.d.ts +34 -0
  511. package/dist/traffic/components/RuleHeatmap.d.ts.map +1 -0
  512. package/dist/traffic/components/RuleHeatmap.js +40 -0
  513. package/dist/traffic/components/RuleHeatmap.js.map +1 -0
  514. package/dist/traffic/components/TrafficDetail.d.ts +33 -0
  515. package/dist/traffic/components/TrafficDetail.d.ts.map +1 -0
  516. package/dist/traffic/components/TrafficDetail.js +28 -0
  517. package/dist/traffic/components/TrafficDetail.js.map +1 -0
  518. package/dist/traffic/components/TrafficGroupRow.d.ts +28 -0
  519. package/dist/traffic/components/TrafficGroupRow.d.ts.map +1 -0
  520. package/dist/traffic/components/TrafficGroupRow.js +18 -0
  521. package/dist/traffic/components/TrafficGroupRow.js.map +1 -0
  522. package/dist/traffic/components/TrafficLineChart.d.ts +34 -0
  523. package/dist/traffic/components/TrafficLineChart.d.ts.map +1 -0
  524. package/dist/traffic/components/TrafficLineChart.js +49 -0
  525. package/dist/traffic/components/TrafficLineChart.js.map +1 -0
  526. package/dist/traffic/components/TrafficLog.d.ts +52 -0
  527. package/dist/traffic/components/TrafficLog.d.ts.map +1 -0
  528. package/dist/traffic/components/TrafficLog.js +34 -0
  529. package/dist/traffic/components/TrafficLog.js.map +1 -0
  530. package/dist/traffic/components/TrafficMetricCards.d.ts +26 -0
  531. package/dist/traffic/components/TrafficMetricCards.d.ts.map +1 -0
  532. package/dist/traffic/components/TrafficMetricCards.js +24 -0
  533. package/dist/traffic/components/TrafficMetricCards.js.map +1 -0
  534. package/dist/traffic/components/TrafficRow.d.ts +40 -0
  535. package/dist/traffic/components/TrafficRow.d.ts.map +1 -0
  536. package/dist/traffic/components/TrafficRow.js +27 -0
  537. package/dist/traffic/components/TrafficRow.js.map +1 -0
  538. package/dist/traffic/components/TrafficStats.d.ts +18 -0
  539. package/dist/traffic/components/TrafficStats.d.ts.map +1 -0
  540. package/dist/traffic/components/TrafficStats.js +19 -0
  541. package/dist/traffic/components/TrafficStats.js.map +1 -0
  542. package/dist/traffic/components/TrafficTimeline.d.ts +81 -0
  543. package/dist/traffic/components/TrafficTimeline.d.ts.map +1 -0
  544. package/dist/traffic/components/TrafficTimeline.js +72 -0
  545. package/dist/traffic/components/TrafficTimeline.js.map +1 -0
  546. package/dist/traffic/components/format.d.ts +13 -0
  547. package/dist/traffic/components/format.d.ts.map +1 -0
  548. package/dist/traffic/components/format.js +24 -0
  549. package/dist/traffic/components/format.js.map +1 -0
  550. package/dist/traffic/components/index.d.ts +11 -0
  551. package/dist/traffic/components/index.d.ts.map +1 -0
  552. package/dist/traffic/components/index.js +11 -0
  553. package/dist/traffic/components/index.js.map +1 -0
  554. package/dist/traffic/hooks/index.d.ts +8 -0
  555. package/dist/traffic/hooks/index.d.ts.map +1 -0
  556. package/dist/traffic/hooks/index.js +8 -0
  557. package/dist/traffic/hooks/index.js.map +1 -0
  558. package/dist/traffic/hooks/useRuleHeatmap.d.ts +33 -0
  559. package/dist/traffic/hooks/useRuleHeatmap.d.ts.map +1 -0
  560. package/dist/traffic/hooks/useRuleHeatmap.js +54 -0
  561. package/dist/traffic/hooks/useRuleHeatmap.js.map +1 -0
  562. package/dist/traffic/hooks/useTrafficBuckets.d.ts +71 -0
  563. package/dist/traffic/hooks/useTrafficBuckets.d.ts.map +1 -0
  564. package/dist/traffic/hooks/useTrafficBuckets.js +74 -0
  565. package/dist/traffic/hooks/useTrafficBuckets.js.map +1 -0
  566. package/dist/traffic/hooks/useTrafficFilter.d.ts +40 -0
  567. package/dist/traffic/hooks/useTrafficFilter.d.ts.map +1 -0
  568. package/dist/traffic/hooks/useTrafficFilter.js +33 -0
  569. package/dist/traffic/hooks/useTrafficFilter.js.map +1 -0
  570. package/dist/traffic/hooks/useTrafficGroups.d.ts +47 -0
  571. package/dist/traffic/hooks/useTrafficGroups.d.ts.map +1 -0
  572. package/dist/traffic/hooks/useTrafficGroups.js +73 -0
  573. package/dist/traffic/hooks/useTrafficGroups.js.map +1 -0
  574. package/dist/traffic/hooks/useTrafficMetrics.d.ts +66 -0
  575. package/dist/traffic/hooks/useTrafficMetrics.d.ts.map +1 -0
  576. package/dist/traffic/hooks/useTrafficMetrics.js +156 -0
  577. package/dist/traffic/hooks/useTrafficMetrics.js.map +1 -0
  578. package/dist/traffic/hooks/useTrafficMonitor.d.ts +56 -0
  579. package/dist/traffic/hooks/useTrafficMonitor.d.ts.map +1 -0
  580. package/dist/traffic/hooks/useTrafficMonitor.js +58 -0
  581. package/dist/traffic/hooks/useTrafficMonitor.js.map +1 -0
  582. package/dist/traffic/hooks/useTrafficStats.d.ts +32 -0
  583. package/dist/traffic/hooks/useTrafficStats.d.ts.map +1 -0
  584. package/dist/traffic/hooks/useTrafficStats.js +45 -0
  585. package/dist/traffic/hooks/useTrafficStats.js.map +1 -0
  586. package/dist/traffic/index.d.ts +4 -0
  587. package/dist/traffic/index.d.ts.map +1 -0
  588. package/dist/traffic/index.js +3 -0
  589. package/dist/traffic/index.js.map +1 -0
  590. package/dist/traffic/types.d.ts +72 -0
  591. package/dist/traffic/types.d.ts.map +1 -0
  592. package/dist/traffic/types.js +10 -0
  593. package/dist/traffic/types.js.map +1 -0
  594. package/package.json +116 -0
@@ -0,0 +1,193 @@
1
+ import { useCallback, useMemo, useReducer, useRef, useState } from 'react';
2
+ import { ref as refFn, updateMetadata, } from 'pyric/storage';
3
+ import { normalizeStoragePath } from './usePathState.js';
4
+ /** Re-validate the k/v rows: empty keys and duplicate keys error. */
5
+ function validateCustom(custom) {
6
+ const counts = new Map();
7
+ for (const entry of custom) {
8
+ counts.set(entry.key, (counts.get(entry.key) ?? 0) + 1);
9
+ }
10
+ let errorCount = 0;
11
+ const next = custom.map((entry) => {
12
+ let error;
13
+ if (entry.key.trim() === '')
14
+ error = 'Key is required';
15
+ else if ((counts.get(entry.key) ?? 0) > 1)
16
+ error = 'Duplicate key';
17
+ if (error)
18
+ errorCount++;
19
+ if (error === entry.error)
20
+ return entry;
21
+ return { ...entry, error };
22
+ });
23
+ return { custom: next, errorCount };
24
+ }
25
+ function applyDraft(state, mutate) {
26
+ const mutated = mutate(state.draft);
27
+ const { custom, errorCount } = validateCustom(mutated.custom);
28
+ return { ...state, draft: { ...mutated, custom }, errorCount };
29
+ }
30
+ /** Pure reducer — exported (with {@link initMetadataEditorState}) so
31
+ * the edit state is testable without React, mirroring the document
32
+ * editor's reducer/hook split. */
33
+ export function metadataEditorReducer(state, action) {
34
+ switch (action.type) {
35
+ case 'setContentType':
36
+ return applyDraft(state, (d) => ({ ...d, contentType: action.value }));
37
+ case 'setCacheControl':
38
+ return applyDraft(state, (d) => ({ ...d, cacheControl: action.value }));
39
+ case 'setCustomKey':
40
+ return applyDraft(state, (d) => ({
41
+ ...d,
42
+ custom: d.custom.map((e) => (e.id === action.id ? { ...e, key: action.key } : e)),
43
+ }));
44
+ case 'setCustomValue':
45
+ return applyDraft(state, (d) => ({
46
+ ...d,
47
+ custom: d.custom.map((e) => e.id === action.id ? { ...e, value: action.value } : e),
48
+ }));
49
+ case 'addCustomEntry':
50
+ return applyDraft(state, (d) => ({
51
+ ...d,
52
+ custom: [
53
+ ...d.custom,
54
+ { id: crypto.randomUUID(), key: action.key ?? '', value: action.value ?? '' },
55
+ ],
56
+ }));
57
+ case 'removeCustomEntry':
58
+ return applyDraft(state, (d) => ({
59
+ ...d,
60
+ custom: d.custom.filter((e) => e.id !== action.id),
61
+ }));
62
+ case 'reset':
63
+ return {
64
+ draft: state.initial,
65
+ initial: state.initial,
66
+ errorCount: validateCustom(state.initial.custom).errorCount,
67
+ };
68
+ case 'commit':
69
+ return { ...state, initial: state.draft };
70
+ }
71
+ }
72
+ /** Build the edit state from the metadata a `getMetadata` /
73
+ * `useStorageObject` read returned. */
74
+ export function initMetadataEditorState(initial) {
75
+ const draft = {
76
+ contentType: initial?.contentType ?? '',
77
+ cacheControl: initial?.cacheControl ?? '',
78
+ custom: Object.entries(initial?.customMetadata ?? {}).map(([key, value]) => ({
79
+ id: crypto.randomUUID(),
80
+ key,
81
+ value,
82
+ })),
83
+ };
84
+ const { custom, errorCount } = validateCustom(draft.custom);
85
+ // One shared object: `isDirty` is `draft !== initial` by reference.
86
+ const validated = { ...draft, custom };
87
+ return { draft: validated, initial: validated, errorCount };
88
+ }
89
+ /**
90
+ * Headless metadata editor — the `useDocumentEditor` reducer pattern
91
+ * over `updateMetadata`: a pure reducer owns the draft (contentType,
92
+ * cacheControl, customMetadata k/v rows with stable ids +
93
+ * empty/duplicate-key validation); the hook adds named dispatch
94
+ * helpers and the save half.
95
+ */
96
+ export function useMetadataEditor(storage, path, options = {}) {
97
+ // Computed once — the reducer owns the live draft from here on
98
+ // (same `useRef` seed as `useDocumentEditor`).
99
+ const initialRef = useRef(null);
100
+ if (initialRef.current == null) {
101
+ initialRef.current = initMetadataEditorState(options.initial);
102
+ }
103
+ const [state, dispatch] = useReducer(metadataEditorReducer, initialRef.current);
104
+ const [isSaving, setIsSaving] = useState(false);
105
+ const [saveError, setSaveError] = useState(undefined);
106
+ // Stale-run protection for overlapping saves (generation token,
107
+ // house style).
108
+ const generationRef = useRef(0);
109
+ const setContentType = useCallback((value) => dispatch({ type: 'setContentType', value }), []);
110
+ const setCacheControl = useCallback((value) => dispatch({ type: 'setCacheControl', value }), []);
111
+ const setCustomKey = useCallback((id, key) => dispatch({ type: 'setCustomKey', id, key }), []);
112
+ const setCustomValue = useCallback((id, value) => dispatch({ type: 'setCustomValue', id, value }), []);
113
+ const addCustomEntry = useCallback((key, value) => dispatch({ type: 'addCustomEntry', key, value }), []);
114
+ const removeCustomEntry = useCallback((id) => dispatch({ type: 'removeCustomEntry', id }), []);
115
+ const reset = useCallback(() => dispatch({ type: 'reset' }), []);
116
+ const { draft, initial, errorCount } = state;
117
+ const toPatch = useCallback(() => {
118
+ return {
119
+ contentType: draft.contentType.trim() === '' ? undefined : draft.contentType,
120
+ cacheControl: draft.cacheControl.trim() === '' ? undefined : draft.cacheControl,
121
+ customMetadata: Object.fromEntries(draft.custom.filter((e) => e.key.trim() !== '').map((e) => [e.key, e.value])),
122
+ };
123
+ }, [draft]);
124
+ const save = useCallback(async () => {
125
+ const myGen = ++generationRef.current;
126
+ if (storage == null || path == null) {
127
+ setSaveError(new Error('useMetadataEditor: storage or path is null'));
128
+ return undefined;
129
+ }
130
+ if (errorCount > 0) {
131
+ setSaveError(new Error('useMetadataEditor: draft has validation errors'));
132
+ return undefined;
133
+ }
134
+ setSaveError(undefined);
135
+ setIsSaving(true);
136
+ try {
137
+ const next = await updateMetadata(refFn(storage, normalizeStoragePath(path)), toPatch());
138
+ if (myGen === generationRef.current) {
139
+ dispatch({ type: 'commit' });
140
+ }
141
+ return next;
142
+ }
143
+ catch (e) {
144
+ if (myGen === generationRef.current) {
145
+ setSaveError(e instanceof Error ? e : new Error(String(e)));
146
+ }
147
+ return undefined;
148
+ }
149
+ finally {
150
+ if (myGen === generationRef.current)
151
+ setIsSaving(false);
152
+ }
153
+ }, [storage, path, errorCount, toPatch]);
154
+ const isDirty = draft !== initial;
155
+ const isValid = errorCount === 0;
156
+ return useMemo(() => ({
157
+ contentType: draft.contentType,
158
+ cacheControl: draft.cacheControl,
159
+ custom: draft.custom,
160
+ isValid,
161
+ isDirty,
162
+ errorCount,
163
+ dispatch,
164
+ setContentType,
165
+ setCacheControl,
166
+ setCustomKey,
167
+ setCustomValue,
168
+ addCustomEntry,
169
+ removeCustomEntry,
170
+ reset,
171
+ toPatch,
172
+ save,
173
+ isSaving,
174
+ saveError,
175
+ }), [
176
+ draft,
177
+ isValid,
178
+ isDirty,
179
+ errorCount,
180
+ setContentType,
181
+ setCacheControl,
182
+ setCustomKey,
183
+ setCustomValue,
184
+ addCustomEntry,
185
+ removeCustomEntry,
186
+ reset,
187
+ toPatch,
188
+ save,
189
+ isSaving,
190
+ saveError,
191
+ ]);
192
+ }
193
+ //# sourceMappingURL=useMetadataEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMetadataEditor.js","sourceRoot":"","sources":["../../../src/storage/hooks/useMetadataEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,EACL,GAAG,IAAI,KAAK,EACZ,cAAc,GAIf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAqCzD,qEAAqE;AACrE,SAAS,cAAc,CAAC,MAA6B;IAInD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,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,aAAa,CAAC,OAAO;gBAAE,WAAW,CAAC,KAAK,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;IAEzC,MAAM,OAAO,GAAG,KAAK,KAAK,OAAO,CAAC;IAClC,MAAM,OAAO,GAAG,UAAU,KAAK,CAAC,CAAC;IAEjC,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO;QACP,OAAO;QACP,UAAU;QACV,QAAQ;QACR,cAAc;QACd,eAAe;QACf,YAAY;QACZ,cAAc;QACd,cAAc;QACd,iBAAiB;QACjB,KAAK;QACL,OAAO;QACP,IAAI;QACJ,QAAQ;QACR,SAAS;KACV,CAAC,EACF;QACE,KAAK;QACL,OAAO;QACP,OAAO;QACP,UAAU;QACV,cAAc;QACd,eAAe;QACf,YAAY;QACZ,cAAc;QACd,cAAc;QACd,iBAAiB;QACjB,KAAK;QACL,OAAO;QACP,IAAI;QACJ,QAAQ;QACR,SAAS;KACV,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,109 @@
1
+ import type { FirebaseStorage, FullMetadata, SettableMetadata } from 'pyric/storage';
2
+ import type { UseStorageListResult } from './useStorageList.js';
3
+ export type UploadTaskStatus = 'running' | 'success' | 'error';
4
+ /**
5
+ * One file's upload, TASK-SHAPED for resumable forward-compat: the
6
+ * byte counters and the `onProgress` callback are in the type NOW so
7
+ * a future `uploadBytesResumable`-backed implementation emits real
8
+ * intermediate snapshots without a breaking change. Today
9
+ * (`pyric/storage` has no resumable uploads — COMPAT) a task
10
+ * completes in one tick: `onProgress` fires once at 0 bytes and once
11
+ * at `totalBytes`.
12
+ */
13
+ export interface UploadTask {
14
+ /** Stable id — key task rows on this, not on `fullPath` (two
15
+ * uploads can target the same path). */
16
+ id: string;
17
+ /** Bucket-rooted destination path. */
18
+ fullPath: string;
19
+ status: UploadTaskStatus;
20
+ bytesTransferred: number;
21
+ totalBytes: number;
22
+ /** Populated on `'success'`. */
23
+ metadata?: FullMetadata;
24
+ /** Populated on `'error'` — a typed `StorageError` from the
25
+ * sandbox (`.code` is `storage/<code>`, e.g.
26
+ * `storage/unauthorized` for a rules-denied write) or whatever
27
+ * the prod backend threw. */
28
+ error?: Error;
29
+ }
30
+ /** Explicit-path upload input. `path` is relative to the hook's
31
+ * `path` option (the destination folder). */
32
+ export interface UploadEntry {
33
+ path: string;
34
+ data: Blob | Uint8Array | ArrayBuffer;
35
+ metadata?: SettableMetadata;
36
+ }
37
+ /**
38
+ * `upload()` accepts plain `File`s (destination = the file's
39
+ * `webkitRelativePath` when present — folder drops keep their
40
+ * structure — else its `name`) or explicit {@link UploadEntry}s.
41
+ */
42
+ export type UploadInput = File | UploadEntry;
43
+ export interface UseObjectUploadOptions {
44
+ /** Destination folder, bucket-rooted. Default `''` (root). Wire to
45
+ * `usePathState().path` so uploads land in the browsed folder. */
46
+ path?: string;
47
+ /**
48
+ * Optimistic seam from `useStorageList`: each upload inserts its
49
+ * path immediately and rolls back via `removeItem` on failure.
50
+ * Caveat: rolling back an upload that was OVERWRITING an existing
51
+ * object drops that object's row locally (the seam can't tell an
52
+ * optimistic row from a listed one) — `refresh()` restores server
53
+ * truth.
54
+ */
55
+ list?: Pick<UseStorageListResult, 'insertItem' | 'removeItem'>;
56
+ /** Task-shaped progress callback (see {@link UploadTask}). */
57
+ onProgress?: (task: UploadTask) => void;
58
+ /** Fired once per task reaching `'success'`. */
59
+ onComplete?: (task: UploadTask) => void;
60
+ /** Fired once per task reaching `'error'`. */
61
+ onError?: (task: UploadTask) => void;
62
+ }
63
+ export interface UseObjectUploadResult {
64
+ /** Every task started by this hook instance, oldest first. */
65
+ tasks: UploadTask[];
66
+ /** `true` while any task is `'running'`. */
67
+ isUploading: boolean;
68
+ /**
69
+ * Upload one or many files. Tasks run concurrently; the promise
70
+ * resolves with the settled tasks once ALL finish and never
71
+ * rejects — per-file failures land on `task.error` (and
72
+ * `onError`), so one bad file doesn't mask the others.
73
+ */
74
+ upload: (input: UploadInput | UploadInput[]) => Promise<UploadTask[]>;
75
+ /**
76
+ * Create an empty folder under the hook's `path`: writes the GCS
77
+ * placeholder convention — a zero-byte object named `<path>/`
78
+ * (trailing slash). `listAll` hides the placeholder from `items`
79
+ * at every level (it only surfaces as a prefix), so the folder
80
+ * appears in the browser with no phantom file inside.
81
+ *
82
+ * Sandbox-only today: the JS-SDK-shaped `ref()` normalizes the
83
+ * trailing slash away, so the placeholder is written through a
84
+ * structural value-object reference the sandbox accepts; prod
85
+ * targets reject it (the `pyric/storage` follow-up is a
86
+ * first-class placeholder API routing prod through the REST
87
+ * `name=<path>/` upload). Throws the underlying error after
88
+ * rolling back the optimistic prefix insert.
89
+ *
90
+ * ALTERNATIVE: when the store must stay free of placeholder
91
+ * objects (Pyric Studio's choice), use the client-side
92
+ * pending-prefix mechanism instead — see `pendingPrefixes.ts`
93
+ * for the reducer and the recorded tradeoff.
94
+ */
95
+ createFolder: (name: string) => Promise<void>;
96
+ /** Drop settled (`success`/`error`) tasks from `tasks`. */
97
+ clearCompleted: () => void;
98
+ }
99
+ /**
100
+ * Multi-file upload over the package's single Storage handle prop.
101
+ * Headless: returns task state; render it however you like (the
102
+ * `<UploadDropzone>` component is one producer of `upload()` calls).
103
+ *
104
+ * Optimistic-with-rollback: with the `list` seam wired, each upload's
105
+ * row appears in `useStorageList` immediately and disappears again if
106
+ * the write fails (typed `StorageError` on `task.error`).
107
+ */
108
+ export declare function useObjectUpload(storage: FirebaseStorage | null | undefined, options?: UseObjectUploadOptions): UseObjectUploadResult;
109
+ //# sourceMappingURL=useObjectUpload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useObjectUpload.d.ts","sourceRoot":"","sources":["../../../src/storage/hooks/useObjectUpload.ts"],"names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AW,qBAAqB;IACpC,8DAA8D;IAC9D,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,4CAA4C;IAC5C,WAAW,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,EAAE,KAAK,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IACtE;;;;;;;;;;;;;;;;;;;OAmBG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,2DAA2D;IAC3D,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B;AAwBD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,EAC3C,OAAO,GAAE,sBAA2B,GACnC,qBAAqB,CAsHvB"}
@@ -0,0 +1,134 @@
1
+ import { useCallback, useRef, useState } from 'react';
2
+ import { folderPlaceholderRef } from '../folderPlaceholder.js';
3
+ import { useStorageApi } from '../storageApi.js';
4
+ import { normalizeStoragePath } from './usePathState.js';
5
+ function joinPath(base, child) {
6
+ if (base === '')
7
+ return child;
8
+ if (child === '')
9
+ return base;
10
+ return `${base}/${child}`;
11
+ }
12
+ function sizeOf(data) {
13
+ if (data instanceof Blob)
14
+ return data.size;
15
+ return data.byteLength;
16
+ }
17
+ function toEntry(input) {
18
+ if (input instanceof Blob) {
19
+ // File (the only Blob subtype `UploadInput` admits). Folder
20
+ // drops carry `webkitRelativePath`; plain picks carry `name`.
21
+ const file = input;
22
+ const rel = file.webkitRelativePath;
23
+ return { path: rel || file.name, data: file };
24
+ }
25
+ return input;
26
+ }
27
+ /**
28
+ * Multi-file upload over the package's single Storage handle prop.
29
+ * Headless: returns task state; render it however you like (the
30
+ * `<UploadDropzone>` component is one producer of `upload()` calls).
31
+ *
32
+ * Optimistic-with-rollback: with the `list` seam wired, each upload's
33
+ * row appears in `useStorageList` immediately and disappears again if
34
+ * the write fails (typed `StorageError` on `task.error`).
35
+ */
36
+ export function useObjectUpload(storage, options = {}) {
37
+ // Injected backend (in-process `pyric/storage` by default, the
38
+ // SharedWorker client bundle in Studio served mode) — uploads follow
39
+ // the same seam the browse hooks read through. The worker leg caps a
40
+ // payload at 8 MiB (base64 `storage.putBytes`); in-process writes are
41
+ // uncapped. An over-cap file fails as a normal per-file task error.
42
+ const { ref: refFn, uploadBytes } = useStorageApi();
43
+ const base = normalizeStoragePath(options.path ?? '');
44
+ const [tasks, setTasks] = useState([]);
45
+ // Latest-value refs so `upload`/`createFolder` stay referentially
46
+ // stable across option changes (same pattern as the house hooks'
47
+ // generation tokens — the callbacks read current options at call
48
+ // time).
49
+ const optionsRef = useRef(options);
50
+ optionsRef.current = options;
51
+ const patchTask = useCallback((next) => {
52
+ setTasks((prev) => prev.map((t) => (t.id === next.id ? next : t)));
53
+ }, []);
54
+ const upload = useCallback(async (input) => {
55
+ if (storage == null) {
56
+ throw new Error('useObjectUpload: storage handle is null');
57
+ }
58
+ const inputs = Array.isArray(input) ? input : [input];
59
+ const started = inputs.map((raw) => {
60
+ const entry = toEntry(raw);
61
+ const task = {
62
+ id: crypto.randomUUID(),
63
+ fullPath: joinPath(base, normalizeStoragePath(entry.path)),
64
+ status: 'running',
65
+ bytesTransferred: 0,
66
+ totalBytes: sizeOf(entry.data),
67
+ };
68
+ return { task, entry };
69
+ });
70
+ setTasks((prev) => [...prev, ...started.map((s) => s.task)]);
71
+ for (const { task } of started) {
72
+ optionsRef.current.list?.insertItem(task.fullPath);
73
+ optionsRef.current.onProgress?.(task);
74
+ }
75
+ return Promise.all(started.map(async ({ task, entry }) => {
76
+ try {
77
+ const result = await uploadBytes(refFn(storage, task.fullPath), entry.data, entry.metadata);
78
+ const done = {
79
+ ...task,
80
+ status: 'success',
81
+ bytesTransferred: task.totalBytes,
82
+ metadata: result.metadata,
83
+ };
84
+ patchTask(done);
85
+ optionsRef.current.onProgress?.(done);
86
+ optionsRef.current.onComplete?.(done);
87
+ return done;
88
+ }
89
+ catch (e) {
90
+ const failed = {
91
+ ...task,
92
+ status: 'error',
93
+ error: e instanceof Error ? e : new Error(String(e)),
94
+ };
95
+ // Roll the optimistic row back before surfacing.
96
+ optionsRef.current.list?.removeItem(task.fullPath);
97
+ patchTask(failed);
98
+ optionsRef.current.onError?.(failed);
99
+ return failed;
100
+ }
101
+ }));
102
+ }, [storage, base, patchTask, refFn, uploadBytes]);
103
+ const createFolder = useCallback(async (name) => {
104
+ if (storage == null) {
105
+ throw new Error('useObjectUpload: storage handle is null');
106
+ }
107
+ const folderPath = joinPath(base, normalizeStoragePath(name));
108
+ if (folderPath === '') {
109
+ throw new Error('createFolder: folder name is empty');
110
+ }
111
+ // Trailing slash → the seam inserts a prefix, not an item.
112
+ optionsRef.current.list?.insertItem(`${folderPath}/`);
113
+ try {
114
+ await uploadBytes(folderPlaceholderRef(storage, folderPath), new Blob([]),
115
+ // Matches the emulator UI's placeholder content type.
116
+ { contentType: 'text/plain' });
117
+ }
118
+ catch (e) {
119
+ optionsRef.current.list?.removeItem(folderPath);
120
+ throw e;
121
+ }
122
+ }, [storage, base, uploadBytes]);
123
+ const clearCompleted = useCallback(() => {
124
+ setTasks((prev) => prev.filter((t) => t.status === 'running'));
125
+ }, []);
126
+ return {
127
+ tasks,
128
+ isUploading: tasks.some((t) => t.status === 'running'),
129
+ upload,
130
+ createFolder,
131
+ clearCompleted,
132
+ };
133
+ }
134
+ //# sourceMappingURL=useObjectUpload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useObjectUpload.js","sourceRoot":"","sources":["../../../src/storage/hooks/useObjectUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAMtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oBAA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,GAAG,EAAE;QACtC,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC;IACjE,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,KAAK;QACL,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC;QACtD,MAAM;QACN,YAAY;QACZ,cAAc;KACf,CAAC;AACJ,CAAC"}
@@ -0,0 +1,43 @@
1
+ /** Strip leading/trailing slashes and collapse repeats — mirrors
2
+ * `pyric/storage`'s reference normalization so `usePathState` and
3
+ * `useStorageList` always agree on what a path is. */
4
+ export declare function normalizeStoragePath(path: string): string;
5
+ export interface UsePathStateOptions {
6
+ /**
7
+ * Controlled value. When provided, the hook derives everything
8
+ * from it and navigation calls only fire `onPathChange` — the
9
+ * owner owns the state (e.g. a router binding `?path=`).
10
+ */
11
+ path?: string;
12
+ /** Fired with the normalized next path on every navigation. Called
13
+ * in both modes. */
14
+ onPathChange?: (path: string) => void;
15
+ /** Uncontrolled initial value. Default `''` (bucket root). */
16
+ defaultPath?: string;
17
+ }
18
+ export interface UsePathStateResult {
19
+ /** Current normalized path. `''` is the bucket root. */
20
+ path: string;
21
+ /** Path split into segments. `[]` at root. */
22
+ segments: string[];
23
+ /** Jump to an absolute path (normalized). */
24
+ setPath: (path: string) => void;
25
+ /** Descend into a child folder — accepts a bare name (`'sub'`) or
26
+ * an absolute path (`'docs/sub'`, e.g. a prefix's `fullPath`). */
27
+ enter: (nameOrPath: string) => void;
28
+ /** Ascend one level. No-op at root. */
29
+ up: () => void;
30
+ /**
31
+ * Jump to the ancestor ending at `segments[index]` — the breadcrumb
32
+ * click. `navigateToIndex(-1)` (or any negative) is the root.
33
+ */
34
+ navigateToIndex: (index: number) => void;
35
+ }
36
+ /**
37
+ * Path navigation state for the storage browser. Controlled when
38
+ * `path` is provided (the owner re-renders with the next value),
39
+ * uncontrolled otherwise — standard React value/defaultValue
40
+ * semantics. All emitted paths are normalized (`normalizeStoragePath`).
41
+ */
42
+ export declare function usePathState(options?: UsePathStateOptions): UsePathStateResult;
43
+ //# sourceMappingURL=usePathState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePathState.d.ts","sourceRoot":"","sources":["../../../src/storage/hooks/usePathState.ts"],"names":[],"mappings":"AAEA;;uDAEuD;AACvD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;yBACqB;IACrB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,6CAA6C;IAC7C,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC;uEACmE;IACnE,KAAK,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,uCAAuC;IACvC,EAAE,EAAE,MAAM,IAAI,CAAC;IACf;;;OAGG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,OAAO,GAAE,mBAAwB,GAChC,kBAAkB,CA2CpB"}
@@ -0,0 +1,42 @@
1
+ import { useCallback, useMemo, useState } from 'react';
2
+ /** Strip leading/trailing slashes and collapse repeats — mirrors
3
+ * `pyric/storage`'s reference normalization so `usePathState` and
4
+ * `useStorageList` always agree on what a path is. */
5
+ export function normalizeStoragePath(path) {
6
+ return path.split('/').filter(Boolean).join('/');
7
+ }
8
+ /**
9
+ * Path navigation state for the storage browser. Controlled when
10
+ * `path` is provided (the owner re-renders with the next value),
11
+ * uncontrolled otherwise — standard React value/defaultValue
12
+ * semantics. All emitted paths are normalized (`normalizeStoragePath`).
13
+ */
14
+ export function usePathState(options = {}) {
15
+ const { path: controlled, onPathChange, defaultPath = '' } = options;
16
+ const isControlled = controlled !== undefined;
17
+ const [internal, setInternal] = useState(() => normalizeStoragePath(defaultPath));
18
+ const path = isControlled ? normalizeStoragePath(controlled) : internal;
19
+ const setPath = useCallback((next) => {
20
+ const normalized = normalizeStoragePath(next);
21
+ if (!isControlled)
22
+ setInternal(normalized);
23
+ onPathChange?.(normalized);
24
+ }, [isControlled, onPathChange]);
25
+ const segments = useMemo(() => (path === '' ? [] : path.split('/')), [path]);
26
+ const enter = useCallback((nameOrPath) => {
27
+ const target = normalizeStoragePath(nameOrPath);
28
+ // An absolute descendant path (a prefix ref's fullPath) is used
29
+ // as-is; a bare name appends to the current path.
30
+ setPath(target.includes('/') || path === '' ? target : `${path}/${target}`);
31
+ }, [path, setPath]);
32
+ const up = useCallback(() => {
33
+ if (segments.length === 0)
34
+ return;
35
+ setPath(segments.slice(0, -1).join('/'));
36
+ }, [segments, setPath]);
37
+ const navigateToIndex = useCallback((index) => {
38
+ setPath(index < 0 ? '' : segments.slice(0, index + 1).join('/'));
39
+ }, [segments, setPath]);
40
+ return { path, segments, setPath, enter, up, navigateToIndex };
41
+ }
42
+ //# sourceMappingURL=usePathState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePathState.js","sourceRoot":"","sources":["../../../src/storage/hooks/usePathState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEvD;;uDAEuD;AACvD,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C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CAAC,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,MAAM,EAAE,CAAC,CAAC;IAC9E,CAAC,EACD,CAAC,IAAI,EAAE,OAAO,CAAC,CAChB,CAAC;IAEF,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE;QAC1B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IAExB,MAAM,eAAe,GAAG,WAAW,CACjC,CAAC,KAAa,EAAE,EAAE;QAChB,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACnE,CAAC,EACD,CAAC,QAAQ,EAAE,OAAO,CAAC,CACpB,CAAC;IAEF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,eAAe,EAAE,CAAC;AACjE,CAAC"}
@@ -0,0 +1,73 @@
1
+ import { type FirebaseStorage, type StorageReference } from 'pyric/storage';
2
+ import type { StorageSelectionEntry } from './useStorageSelection.js';
3
+ import type { UseStorageListResult } from './useStorageList.js';
4
+ export interface StorageDeleteProgress {
5
+ /** Objects deleted so far in this folder walk. */
6
+ deletedCount: number;
7
+ /** True for the final emission. */
8
+ done: boolean;
9
+ }
10
+ /**
11
+ * Recursive folder delete implementation — the same injection seam
12
+ * as the Firestore half's `RecursiveDeleteImpl`. Unlike Firestore
13
+ * (where tree-walking needs sandbox introspection or a Cloud
14
+ * Function), the public storage surface CAN walk a prefix, so the
15
+ * package ships {@link createListAllDeleteImpl} as the default;
16
+ * inject your own for server-driven deletes.
17
+ */
18
+ export interface StorageRecursiveDeleteImpl {
19
+ start: (target: StorageReference) => AsyncIterableIterator<StorageDeleteProgress>;
20
+ }
21
+ /**
22
+ * The default, `listAll`-driven impl: walks the prefix tree,
23
+ * `deleteObject`s every item (yielding progress per object), then
24
+ * sweeps each visited folder's `<path>/` placeholder so emptied
25
+ * create-folder folders disappear too (`listAll` hides placeholders,
26
+ * so the walk alone would leave ghost folders). Placeholder sweeps
27
+ * are best-effort — `deletedCount` counts listed objects only.
28
+ */
29
+ export declare function createListAllDeleteImpl(): StorageRecursiveDeleteImpl;
30
+ /** One entry's failure in a bulk run. `error` is the typed
31
+ * `StorageError` (`.code` e.g. `storage/unauthorized`). */
32
+ export interface StorageDeleteFailure {
33
+ fullPath: string;
34
+ error: Error;
35
+ }
36
+ export interface StorageDeleteOutcome {
37
+ /** fullPaths of entries fully deleted. */
38
+ deleted: string[];
39
+ failed: StorageDeleteFailure[];
40
+ }
41
+ export interface UseStorageDeleteOptions {
42
+ /** Folder-walk implementation. Default {@link createListAllDeleteImpl}. */
43
+ impl?: StorageRecursiveDeleteImpl;
44
+ /**
45
+ * Optimistic seam from `useStorageList`: entries vanish from the
46
+ * local list immediately and roll back (object → item, folder →
47
+ * trailing-slash prefix insert) on failure.
48
+ */
49
+ list?: Pick<UseStorageListResult, 'insertItem' | 'removeItem'>;
50
+ }
51
+ export interface UseStorageDeleteResult {
52
+ /**
53
+ * Delete a mixed object/folder selection (objects via
54
+ * `deleteObject`, folders via the recursive impl), sequentially in
55
+ * selection order. Resolves with the outcome and never rejects —
56
+ * per-entry failures land in `outcome.failed` (and `error` keeps
57
+ * the first one for simple renders).
58
+ */
59
+ deleteEntries: (entries: StorageSelectionEntry[]) => Promise<StorageDeleteOutcome>;
60
+ /** Objects deleted in the current/last run (folder walks included). */
61
+ progress: number;
62
+ isRunning: boolean;
63
+ /** First failure of the current/last run. Cleared on the next call. */
64
+ error: Error | undefined;
65
+ }
66
+ /**
67
+ * Drive bulk + recursive deletes from a React component — the
68
+ * storage counterpart of `useRecursiveDelete` (same progress /
69
+ * isRunning / error shape, same stale-run generation token), bulk
70
+ * because storage selections are flat multi-row affairs.
71
+ */
72
+ export declare function useStorageDelete(storage: FirebaseStorage | null | undefined, options?: UseStorageDeleteOptions): UseStorageDeleteResult;
73
+ //# sourceMappingURL=useStorageDelete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStorageDelete.d.ts","sourceRoot":"","sources":["../../../src/storage/hooks/useStorageDelete.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,MAAM,WAAW,qBAAqB;IACpC,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,CACL,MAAM,EAAE,gBAAgB,KACrB,qBAAqB,CAAC,qBAAqB,CAAC,CAAC;CACnD;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,IAAI,0BAA0B,CA6BpE;AAED;4DAC4D;AAC5D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,0CAA0C;IAC1C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,oBAAoB,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,uBAAuB;IACtC,2EAA2E;IAC3E,IAAI,CAAC,EAAE,0BAA0B,CAAC;IAClC;;;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