@seedprotocol/sdk 0.7.8-next.1071.g2a141c1 → 0.7.8

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 (211) hide show
  1. package/dist/{ClientManager-Bv15o3Oz.js → ClientManager-B1r_8P5Z.js} +37 -40
  2. package/dist/ClientManager-B1r_8P5Z.js.map +1 -0
  3. package/dist/{Item-tX3kpbj4.js → Item-CjTEShfk.js} +384 -399
  4. package/dist/Item-CjTEShfk.js.map +1 -0
  5. package/dist/{ModelProperty-N-3gBfu5.js → ModelProperty-C3749Wjq.js} +36 -36
  6. package/dist/{ModelProperty-N-3gBfu5.js.map → ModelProperty-C3749Wjq.js.map} +1 -1
  7. package/dist/{Schema-CY3OxwKS.js → Schema-CX9CTtho.js} +35 -35
  8. package/dist/{Schema-CY3OxwKS.js.map → Schema-CX9CTtho.js.map} +1 -1
  9. package/dist/{SchemaValidationService-BR2ABK2r.js → SchemaValidationService-T5mqnY8q.js} +6 -6
  10. package/dist/{SchemaValidationService-BR2ABK2r.js.map → SchemaValidationService-T5mqnY8q.js.map} +1 -1
  11. package/dist/{backfillMetadataPropertyIds-vc_1RoDT.js → backfillMetadataPropertyIds-DWWkh-Ex.js} +3 -3
  12. package/dist/{backfillMetadataPropertyIds-vc_1RoDT.js.map → backfillMetadataPropertyIds-DWWkh-Ex.js.map} +1 -1
  13. package/dist/{tabEvents-BuorBItJ.js → changeFeed-DcsZ7deG.js} +369 -10
  14. package/dist/changeFeed-DcsZ7deG.js.map +1 -0
  15. package/dist/{configurePlatform-D-Pj9gTx.js → configurePlatform-AWild9o4.js} +2 -2
  16. package/dist/{configurePlatform-D-Pj9gTx.js.map → configurePlatform-AWild9o4.js.map} +1 -1
  17. package/dist/db/drizzle/0022_add_read_indexes.sql +5 -0
  18. package/dist/db/drizzle/0023_add_entity_changes.sql +48 -0
  19. package/dist/db/drizzle/meta/0022_snapshot.json +1585 -0
  20. package/dist/db/drizzle/meta/0023_snapshot.json +1645 -0
  21. package/dist/db/drizzle/meta/_journal.json +14 -0
  22. package/dist/{detachRowsBeforeDelete-sK1ye2W6.js → detachRowsBeforeDelete-Bo_pky-R.js} +2 -2
  23. package/dist/{detachRowsBeforeDelete-sK1ye2W6.js.map → detachRowsBeforeDelete-Bo_pky-R.js.map} +1 -1
  24. package/dist/dist/{ClientManager-Bv15o3Oz.d.ts → ClientManager-B1r_8P5Z.d.ts} +1 -1
  25. package/dist/dist/ClientManager-B1r_8P5Z.d.ts.map +1 -0
  26. package/dist/dist/{Item-tX3kpbj4.d.ts → Item-CjTEShfk.d.ts} +3 -2
  27. package/dist/dist/Item-CjTEShfk.d.ts.map +1 -0
  28. package/dist/dist/{ModelProperty-N-3gBfu5.d.ts → ModelProperty-C3749Wjq.d.ts} +1 -1
  29. package/dist/dist/{ModelProperty-N-3gBfu5.d.ts.map → ModelProperty-C3749Wjq.d.ts.map} +1 -1
  30. package/dist/dist/{Schema-CY3OxwKS.d.ts → Schema-CX9CTtho.d.ts} +2 -2
  31. package/dist/dist/{Schema-CY3OxwKS.d.ts.map → Schema-CX9CTtho.d.ts.map} +1 -1
  32. package/dist/dist/{SchemaValidationService-BR2ABK2r.d.ts → SchemaValidationService-T5mqnY8q.d.ts} +1 -1
  33. package/dist/dist/{SchemaValidationService-BR2ABK2r.d.ts.map → SchemaValidationService-T5mqnY8q.d.ts.map} +1 -1
  34. package/dist/dist/{backfillMetadataPropertyIds-vc_1RoDT.d.ts → backfillMetadataPropertyIds-DWWkh-Ex.d.ts} +1 -1
  35. package/dist/dist/backfillMetadataPropertyIds-DWWkh-Ex.d.ts.map +1 -0
  36. package/dist/dist/{tabEvents-BuorBItJ.d.ts → changeFeed-DcsZ7deG.d.ts} +101 -36
  37. package/dist/dist/changeFeed-DcsZ7deG.d.ts.map +1 -0
  38. package/dist/dist/{configurePlatform-D-Pj9gTx.d.ts → configurePlatform-AWild9o4.d.ts} +1 -1
  39. package/dist/dist/configurePlatform-AWild9o4.d.ts.map +1 -0
  40. package/dist/dist/{detachRowsBeforeDelete-sK1ye2W6.d.ts → detachRowsBeforeDelete-Bo_pky-R.d.ts} +1 -1
  41. package/dist/dist/detachRowsBeforeDelete-Bo_pky-R.d.ts.map +1 -0
  42. package/dist/dist/{eas-BSQxj7gN.d.ts → eas--9vtNkma.d.ts} +1 -1
  43. package/dist/dist/eas--9vtNkma.d.ts.map +1 -0
  44. package/dist/dist/{errors-a4Tj6hly.d.ts → errors-rIWK7gwJ.d.ts} +1 -1
  45. package/dist/dist/{errors-a4Tj6hly.d.ts.map → errors-rIWK7gwJ.d.ts.map} +1 -1
  46. package/dist/dist/{getItem-Ctps9gSs.d.ts → getItem-5j22EWWE.d.ts} +1 -1
  47. package/dist/dist/getItem-5j22EWWE.d.ts.map +1 -0
  48. package/dist/dist/{getPublishPayload-C2g5pPD2.d.ts → getPublishPayload-BGl2SaGK.d.ts} +1 -1
  49. package/dist/dist/{getPublishPayload-C2g5pPD2.d.ts.map → getPublishPayload-BGl2SaGK.d.ts.map} +1 -1
  50. package/dist/dist/{getPublishUploads-CaJHy3SL.d.ts → getPublishUploads-DVsDx6Xf.d.ts} +1 -1
  51. package/dist/dist/{getPublishUploads-CaJHy3SL.d.ts.map → getPublishUploads-DVsDx6Xf.d.ts.map} +1 -1
  52. package/dist/dist/{index-s73wD_LC.d.ts → index-C0SetTd1.d.ts} +1190 -1065
  53. package/dist/dist/index-C0SetTd1.d.ts.map +1 -0
  54. package/dist/dist/{index-BgEwcREa.d.ts → index-CJK3F_MK.d.ts} +13 -13
  55. package/dist/dist/index-CJK3F_MK.d.ts.map +1 -0
  56. package/dist/dist/{index-B6hPWSM4.d.ts → index-CZQrNqvq.d.ts} +130 -13
  57. package/dist/dist/{index-B6hPWSM4.d.ts.map → index-CZQrNqvq.d.ts.map} +1 -1
  58. package/dist/dist/{index-bOwhhJJL.d.ts → index-Dp4uyZYx.d.ts} +5 -5
  59. package/dist/dist/index-Dp4uyZYx.d.ts.map +1 -0
  60. package/dist/dist/{index.browser-C7iZp7mx.d.ts → index.browser-Ll71Y_Dl.d.ts} +391 -39
  61. package/dist/dist/{index.browser-C7iZp7mx.d.ts.map → index.browser-Ll71Y_Dl.d.ts.map} +1 -1
  62. package/dist/dist/{index.node-MPVTJR2J.d.ts → index.node-CgltN0cC.d.ts} +517 -49
  63. package/dist/dist/{index.node-MPVTJR2J.d.ts.map → index.node-CgltN0cC.d.ts.map} +1 -1
  64. package/dist/dist/modelPropertyRecordSchemas-C_lYTzMr.d.ts +7 -0
  65. package/dist/dist/modelPropertyRecordSchemas-C_lYTzMr.d.ts.map +1 -0
  66. package/dist/dist/platform.browser.d.ts +2 -2
  67. package/dist/dist/platform.node.d.ts +2 -2
  68. package/dist/dist/{property-mP9mOZ2L.d.ts → property-pcDxNEpy.d.ts} +3 -3
  69. package/dist/dist/property-pcDxNEpy.d.ts.map +1 -0
  70. package/dist/dist/{propertyValidationRules-DwzrYA7c.d.ts → propertyValidationRules-BEjN0f3-.d.ts} +6 -1
  71. package/dist/dist/propertyValidationRules-BEjN0f3-.d.ts.map +1 -0
  72. package/dist/dist/{publishDraftGraph-BzYVblZZ.d.ts → publishDraftGraph-I5yKe1Xz.d.ts} +1 -1
  73. package/dist/dist/{publishDraftGraph-BzYVblZZ.d.ts.map → publishDraftGraph-I5yKe1Xz.d.ts.map} +1 -1
  74. package/dist/dist/{resetAmbiguousLegacyItemData-B_IUQA09.d.ts → resetAmbiguousLegacyItemData-0Tin9-JK.d.ts} +1 -1
  75. package/dist/dist/resetAmbiguousLegacyItemData-0Tin9-JK.d.ts.map +1 -0
  76. package/dist/dist/{resolveModelForSyncedSeed-H-4tmU6l.d.ts → resolveModelForSyncedSeed-C5KXn6ex.d.ts} +1 -1
  77. package/dist/dist/resolveModelForSyncedSeed-C5KXn6ex.d.ts.map +1 -0
  78. package/dist/dist/{syncDbWithEas-y5VF623G.d.ts → syncDbWithEas-b4fESZ7C.d.ts} +1 -1
  79. package/dist/dist/syncDbWithEas-b4fESZ7C.d.ts.map +1 -0
  80. package/dist/dist/{tolerantWebAccess-DoI7QYT-.d.ts → tolerantWebAccess-CIpS7RLk.d.ts} +1 -1
  81. package/dist/dist/{tolerantWebAccess-DoI7QYT-.d.ts.map → tolerantWebAccess-CIpS7RLk.d.ts.map} +1 -1
  82. package/dist/dist/{updateSeedRevokedAt-BIzkbsUd.d.ts → updateSeedRevokedAt-CR4zwn-6.d.ts} +1 -1
  83. package/dist/dist/updateSeedRevokedAt-CR4zwn-6.d.ts.map +1 -0
  84. package/dist/{eas-BSQxj7gN.js → eas--9vtNkma.js} +3 -3
  85. package/dist/{eas-BSQxj7gN.js.map → eas--9vtNkma.js.map} +1 -1
  86. package/dist/{errors-a4Tj6hly.js → errors-rIWK7gwJ.js} +35 -35
  87. package/dist/{errors-a4Tj6hly.js.map → errors-rIWK7gwJ.js.map} +1 -1
  88. package/dist/{getItem-Ctps9gSs.js → getItem-5j22EWWE.js} +5 -5
  89. package/dist/{getItem-Ctps9gSs.js.map → getItem-5j22EWWE.js.map} +1 -1
  90. package/dist/{getPublishPayload-C2g5pPD2.js → getPublishPayload-BGl2SaGK.js} +14 -14
  91. package/dist/{getPublishPayload-C2g5pPD2.js.map → getPublishPayload-BGl2SaGK.js.map} +1 -1
  92. package/dist/{getPublishUploads-CaJHy3SL.js → getPublishUploads-DVsDx6Xf.js} +7 -7
  93. package/dist/{getPublishUploads-CaJHy3SL.js.map → getPublishUploads-DVsDx6Xf.js.map} +1 -1
  94. package/dist/{index-s73wD_LC.js → index-C0SetTd1.js} +52 -13
  95. package/dist/index-C0SetTd1.js.map +1 -0
  96. package/dist/{index-BgEwcREa.js → index-CJK3F_MK.js} +8 -8
  97. package/dist/index-CJK3F_MK.js.map +1 -0
  98. package/dist/{index-B6hPWSM4.js → index-CZQrNqvq.js} +3 -2
  99. package/dist/index-CZQrNqvq.js.map +1 -0
  100. package/dist/{index-bOwhhJJL.js → index-Dp4uyZYx.js} +8 -8
  101. package/dist/index-Dp4uyZYx.js.map +1 -0
  102. package/dist/{index.browser-C7iZp7mx.js → index.browser-Ll71Y_Dl.js} +243 -18
  103. package/dist/index.browser-Ll71Y_Dl.js.map +1 -0
  104. package/dist/{index.node-MPVTJR2J.js → index.node-CgltN0cC.js} +50 -15
  105. package/dist/index.node-CgltN0cC.js.map +1 -0
  106. package/dist/main.js +23 -30
  107. package/dist/main.js.map +1 -1
  108. package/dist/modelPropertyRecordSchemas-C_lYTzMr.js +94 -0
  109. package/dist/modelPropertyRecordSchemas-C_lYTzMr.js.map +1 -0
  110. package/dist/node.js +11 -11
  111. package/dist/platform.browser.js +5 -5
  112. package/dist/platform.node.js +4 -4
  113. package/dist/{property-mP9mOZ2L.js → property-pcDxNEpy.js} +7 -7
  114. package/dist/{property-mP9mOZ2L.js.map → property-pcDxNEpy.js.map} +1 -1
  115. package/dist/propertyValidationRules-BEjN0f3-.js +73 -0
  116. package/dist/propertyValidationRules-BEjN0f3-.js.map +1 -0
  117. package/dist/{publishDraftGraph-BzYVblZZ.js → publishDraftGraph-I5yKe1Xz.js} +6 -6
  118. package/dist/{publishDraftGraph-BzYVblZZ.js.map → publishDraftGraph-I5yKe1Xz.js.map} +1 -1
  119. package/dist/{resetAmbiguousLegacyItemData-B_IUQA09.js → resetAmbiguousLegacyItemData-0Tin9-JK.js} +2 -2
  120. package/dist/{resetAmbiguousLegacyItemData-B_IUQA09.js.map → resetAmbiguousLegacyItemData-0Tin9-JK.js.map} +1 -1
  121. package/dist/{resolveModelForSyncedSeed-H-4tmU6l.js → resolveModelForSyncedSeed-C5KXn6ex.js} +2 -2
  122. package/dist/{resolveModelForSyncedSeed-H-4tmU6l.js.map → resolveModelForSyncedSeed-C5KXn6ex.js.map} +1 -1
  123. package/dist/seedSchema/EntityChangeSchema.ts +28 -0
  124. package/dist/seedSchema/MetadataSchema.ts +12 -4
  125. package/dist/seedSchema/SeedSchema.ts +9 -3
  126. package/dist/seedSchema/VersionSchema.ts +9 -4
  127. package/dist/seedSchema/index.ts +1 -0
  128. package/dist/src/Item/Item.d.ts +2 -1
  129. package/dist/src/Item/Item.d.ts.map +1 -1
  130. package/dist/src/Item/service/actors/loadOrCreateItem.d.ts.map +1 -1
  131. package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
  132. package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts.map +1 -1
  133. package/dist/src/ItemProperty/service/actors/modelPropertyRecordSchemas.d.ts +21 -0
  134. package/dist/src/ItemProperty/service/actors/modelPropertyRecordSchemas.d.ts.map +1 -0
  135. package/dist/src/browser/db/Db.d.ts +2 -2
  136. package/dist/src/browser/db/Db.d.ts.map +1 -1
  137. package/dist/src/browser/db/changeFeed.d.ts +77 -0
  138. package/dist/src/browser/db/changeFeed.d.ts.map +1 -0
  139. package/dist/src/browser/db/drizzleFiles.d.ts +4 -2
  140. package/dist/src/browser/db/drizzleFiles.d.ts.map +1 -1
  141. package/dist/src/db/write/applyArweaveL1TransactionIdLocal.d.ts.map +1 -1
  142. package/dist/src/db/write/claimUnpublishedDrafts.d.ts.map +1 -1
  143. package/dist/src/db/write/createMetadata.d.ts.map +1 -1
  144. package/dist/src/db/write/createSeed.d.ts.map +1 -1
  145. package/dist/src/db/write/createVersion.d.ts.map +1 -1
  146. package/dist/src/db/write/restoreDataItemIdsOverwrittenByL1.d.ts.map +1 -1
  147. package/dist/src/db/write/saveMetadata.d.ts.map +1 -1
  148. package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
  149. package/dist/src/db/write/updateSeedRevokedAt.d.ts.map +1 -1
  150. package/dist/src/db/write/updateSeedUid.d.ts.map +1 -1
  151. package/dist/src/db/write/updateVersionUid.d.ts.map +1 -1
  152. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  153. package/dist/src/helpers/propertyValidationRules.d.ts +8 -0
  154. package/dist/src/helpers/propertyValidationRules.d.ts.map +1 -1
  155. package/dist/src/helpers/timing.d.ts +36 -0
  156. package/dist/src/helpers/timing.d.ts.map +1 -1
  157. package/dist/src/index.d.ts +2 -0
  158. package/dist/src/index.d.ts.map +1 -1
  159. package/dist/src/node/db/singleConnectionTransactions.d.ts +6 -0
  160. package/dist/src/node/db/singleConnectionTransactions.d.ts.map +1 -1
  161. package/dist/src/outbox/itemAppliers.d.ts.map +1 -1
  162. package/dist/src/outbox/outbox.d.ts +2 -0
  163. package/dist/src/outbox/outbox.d.ts.map +1 -1
  164. package/dist/src/outbox/pendingValues.d.ts.map +1 -1
  165. package/dist/src/seedSchema/EntityChangeSchema.d.ts +126 -0
  166. package/dist/src/seedSchema/EntityChangeSchema.d.ts.map +1 -0
  167. package/dist/src/seedSchema/MetadataSchema.d.ts +4 -4
  168. package/dist/src/seedSchema/MetadataSchema.d.ts.map +1 -1
  169. package/dist/src/seedSchema/SeedSchema.d.ts +4 -4
  170. package/dist/src/seedSchema/SeedSchema.d.ts.map +1 -1
  171. package/dist/src/seedSchema/VersionSchema.d.ts +4 -4
  172. package/dist/src/seedSchema/VersionSchema.d.ts.map +1 -1
  173. package/dist/src/seedSchema/index.d.ts +1 -0
  174. package/dist/src/seedSchema/index.d.ts.map +1 -1
  175. package/dist/{syncDbWithEas-y5VF623G.js → syncDbWithEas-b4fESZ7C.js} +17 -23
  176. package/dist/syncDbWithEas-b4fESZ7C.js.map +1 -0
  177. package/dist/{tolerantWebAccess-DoI7QYT-.js → tolerantWebAccess-CIpS7RLk.js} +6 -6
  178. package/dist/{tolerantWebAccess-DoI7QYT-.js.map → tolerantWebAccess-CIpS7RLk.js.map} +1 -1
  179. package/dist/{updateSeedRevokedAt-BIzkbsUd.js → updateSeedRevokedAt-CR4zwn-6.js} +5 -6
  180. package/dist/updateSeedRevokedAt-CR4zwn-6.js.map +1 -0
  181. package/package.json +6 -6
  182. package/dist/ClientManager-Bv15o3Oz.js.map +0 -1
  183. package/dist/Item-tX3kpbj4.js.map +0 -1
  184. package/dist/dist/ClientManager-Bv15o3Oz.d.ts.map +0 -1
  185. package/dist/dist/Item-tX3kpbj4.d.ts.map +0 -1
  186. package/dist/dist/backfillMetadataPropertyIds-vc_1RoDT.d.ts.map +0 -1
  187. package/dist/dist/configurePlatform-D-Pj9gTx.d.ts.map +0 -1
  188. package/dist/dist/detachRowsBeforeDelete-sK1ye2W6.d.ts.map +0 -1
  189. package/dist/dist/eas-BSQxj7gN.d.ts.map +0 -1
  190. package/dist/dist/getItem-Ctps9gSs.d.ts.map +0 -1
  191. package/dist/dist/index-BgEwcREa.d.ts.map +0 -1
  192. package/dist/dist/index-bOwhhJJL.d.ts.map +0 -1
  193. package/dist/dist/index-s73wD_LC.d.ts.map +0 -1
  194. package/dist/dist/property-mP9mOZ2L.d.ts.map +0 -1
  195. package/dist/dist/propertyValidationRules-DwzrYA7c.d.ts.map +0 -1
  196. package/dist/dist/resetAmbiguousLegacyItemData-B_IUQA09.d.ts.map +0 -1
  197. package/dist/dist/resolveModelForSyncedSeed-H-4tmU6l.d.ts.map +0 -1
  198. package/dist/dist/syncDbWithEas-y5VF623G.d.ts.map +0 -1
  199. package/dist/dist/tabEvents-BuorBItJ.d.ts.map +0 -1
  200. package/dist/dist/updateSeedRevokedAt-BIzkbsUd.d.ts.map +0 -1
  201. package/dist/index-B6hPWSM4.js.map +0 -1
  202. package/dist/index-BgEwcREa.js.map +0 -1
  203. package/dist/index-bOwhhJJL.js.map +0 -1
  204. package/dist/index-s73wD_LC.js.map +0 -1
  205. package/dist/index.browser-C7iZp7mx.js.map +0 -1
  206. package/dist/index.node-MPVTJR2J.js.map +0 -1
  207. package/dist/propertyValidationRules-DwzrYA7c.js +0 -51
  208. package/dist/propertyValidationRules-DwzrYA7c.js.map +0 -1
  209. package/dist/syncDbWithEas-y5VF623G.js.map +0 -1
  210. package/dist/tabEvents-BuorBItJ.js.map +0 -1
  211. package/dist/updateSeedRevokedAt-BIzkbsUd.js.map +0 -1
@@ -1,12 +1,13 @@
1
- import { a as appendOutboxOpAndWait, w as waitForPendingOutboxOps, b as waitForOutboxOp, c as appendOutboxOp, g as getOutboxOps, o as outboxOpResult } from './Item-tX3kpbj4.js';
2
- export { O as OUTBOX_DEFER_MS, d as OUTBOX_MAX_ATTEMPTS, e as OUTBOX_PRUNE_AFTER_MS, f as OUTBOX_PRUNE_FAILED_AFTER_MS, h as OUTBOX_RETRY_DELAYS_MS, i as OutboxOpDeferredError, j as OutboxOpFailedError, k as OutboxOpRejectedError, l as OutboxOpRetryableError, m as appendOutboxOps, n as drainOutbox, p as getPendingSetValue, q as outboxOpValue, r as pruneOutbox, s as registerOutboxApplier, t as startOutbox } from './Item-tX3kpbj4.js';
3
- import { d as deleteFiles, s as startItemOutbox, t as throwItemWriteError, m as markPropertyConflictsResolved } from './ClientManager-Bv15o3Oz.js';
4
- export { R as RelationTargetError, a as applyCreateItem, b as applyDelete, c as applyItemStorageValue, e as applyStorageValue, g as getItemConflicts, f as getPropertyConflict } from './ClientManager-Bv15o3Oz.js';
1
+ import { a as appendOutboxOpAndWait, w as waitForPendingOutboxOps, b as waitForOutboxOp, c as appendOutboxOp, g as getOutboxOps, o as outboxOpResult } from './Item-CjTEShfk.js';
2
+ export { O as OUTBOX_DEFER_MS, d as OUTBOX_MAX_ATTEMPTS, e as OUTBOX_PRUNE_AFTER_MS, f as OUTBOX_PRUNE_FAILED_AFTER_MS, h as OUTBOX_RETRY_DELAYS_MS, i as OutboxOpDeferredError, j as OutboxOpFailedError, k as OutboxOpRejectedError, l as OutboxOpRetryableError, m as appendOutboxOps, n as drainOutbox, p as getPendingSetValue, q as outboxOpValue, r as pruneOutbox, s as registerOutboxApplier, t as startOutbox } from './Item-CjTEShfk.js';
3
+ import { d as deleteFiles, s as startItemOutbox, t as throwItemWriteError, m as markPropertyConflictsResolved } from './ClientManager-B1r_8P5Z.js';
4
+ export { R as RelationTargetError, a as applyCreateItem, b as applyDelete, c as applyItemStorageValue, e as applyStorageValue, g as getItemConflicts, f as getPropertyConflict } from './ClientManager-B1r_8P5Z.js';
5
+ import './changeFeed-DcsZ7deG.js';
5
6
  import 'debug';
6
- import 'xstate';
7
- import './index-s73wD_LC.js';
7
+ import './index-C0SetTd1.js';
8
8
  import '@seedprotocol/arweave';
9
9
  import '@seedprotocol/eas';
10
+ import 'xstate';
10
11
  import 'pluralize';
11
12
  import '@sinclair/typebox';
12
13
  import 'drizzle-orm/sqlite-core';
@@ -19,10 +20,9 @@ import '@noble/hashes/sha3';
19
20
  import '@noble/hashes/utils';
20
21
  import 'lodash-es';
21
22
  import 'rxjs';
22
- import './tabEvents-BuorBItJ.js';
23
23
  import './model-oHA3YhOd.js';
24
24
 
25
25
 
26
26
 
27
27
  export { appendOutboxOp, appendOutboxOpAndWait, deleteFiles, getOutboxOps, markPropertyConflictsResolved, outboxOpResult, startItemOutbox, throwItemWriteError, waitForOutboxOp, waitForPendingOutboxOps };
28
- //# sourceMappingURL=index-BgEwcREa.js.map
28
+ //# sourceMappingURL=index-CJK3F_MK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-CJK3F_MK.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { m as metadata, h as appState, j as arweaveL1FinalizeJobs, k as config, l as easSyncProcesses, o as htmlEmbeddedImageCoPublish, p as modelRelations, q as modelSchemas, r as modelUids, s as models, t as modelsRelations, u as pendingWrites, v as properties, w as propertiesRelations, x as propertyUidRelations, y as propertyUids, z as publishProcesses, A as schemas, B as seeds, C as uploadProcesses, E as versions } from './index-s73wD_LC.js';
1
+ import { m as metadata, h as appState, j as arweaveL1FinalizeJobs, k as config, l as easSyncProcesses, o as entityChanges, p as htmlEmbeddedImageCoPublish, q as modelRelations, r as modelSchemas, s as modelUids, t as models, u as modelsRelations, v as pendingWrites, w as properties, x as propertiesRelations, y as propertyUidRelations, z as propertyUids, A as publishProcesses, B as schemas, C as seeds, E as uploadProcesses, F as versions } from './index-C0SetTd1.js';
2
2
 
3
3
  var schema = /*#__PURE__*/Object.freeze({
4
4
  __proto__: null,
@@ -6,6 +6,7 @@ var schema = /*#__PURE__*/Object.freeze({
6
6
  arweaveL1FinalizeJobs: arweaveL1FinalizeJobs,
7
7
  config: config,
8
8
  easSyncProcesses: easSyncProcesses,
9
+ entityChanges: entityChanges,
9
10
  htmlEmbeddedImageCoPublish: htmlEmbeddedImageCoPublish,
10
11
  metadata: metadata,
11
12
  modelRelations: modelRelations,
@@ -26,4 +27,4 @@ var schema = /*#__PURE__*/Object.freeze({
26
27
  });
27
28
 
28
29
  export { schema as s };
29
- //# sourceMappingURL=index-B6hPWSM4.js.map
30
+ //# sourceMappingURL=index-CZQrNqvq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-CZQrNqvq.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,19 +1,19 @@
1
- export { M as Model, T as TModelSchema, a as TModelValues } from './errors-a4Tj6hly.js';
2
- import { M as ModelPropertyDataTypes } from './index-s73wD_LC.js';
3
- export { D as DEFAULT_TEXT_MAX_LENGTH, P as Property, T as THtmlEmbeddedDataUriPolicy, a as TProperty, b as TPropertyConstructor, c as TPropertyDataType, d as TPropertyDefs, e as TStorageType, f as TValidationRules, i as isDataType, n as normalizeDataType, g as normalizePropertyRecordSchema } from './index-s73wD_LC.js';
4
- export { getPropertySchema } from './property-mP9mOZ2L.js';
1
+ export { M as Model, T as TModelSchema, a as TModelValues } from './errors-rIWK7gwJ.js';
2
+ import { M as ModelPropertyDataTypes } from './index-C0SetTd1.js';
3
+ export { D as DEFAULT_TEXT_MAX_LENGTH, P as Property, T as THtmlEmbeddedDataUriPolicy, a as TProperty, b as TPropertyConstructor, c as TPropertyDataType, d as TPropertyDefs, e as TStorageType, f as TValidationRules, i as isDataType, n as normalizeDataType, g as normalizePropertyRecordSchema } from './index-C0SetTd1.js';
4
+ export { getPropertySchema } from './property-pcDxNEpy.js';
5
5
  import 'xstate';
6
6
  import 'drizzle-orm';
7
7
  import 'debug';
8
- import './Item-tX3kpbj4.js';
8
+ import './Item-CjTEShfk.js';
9
+ import './changeFeed-DcsZ7deG.js';
9
10
  import 'pluralize';
10
11
  import 'rxjs';
11
12
  import 'lodash-es';
12
13
  import '@seedprotocol/eas';
13
- import './tabEvents-BuorBItJ.js';
14
14
  import '@seedprotocol/arweave';
15
15
  import './model-oHA3YhOd.js';
16
- import './ClientManager-Bv15o3Oz.js';
16
+ import './ClientManager-B1r_8P5Z.js';
17
17
  import '@noble/hashes/sha3';
18
18
  import '@noble/hashes/utils';
19
19
  import '@seedprotocol/query';
@@ -26,4 +26,4 @@ import '@noble/hashes/sha256';
26
26
 
27
27
 
28
28
  export { ModelPropertyDataTypes };
29
- //# sourceMappingURL=index-bOwhhJJL.js.map
29
+ //# sourceMappingURL=index-Dp4uyZYx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Dp4uyZYx.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
- import { B as BasePathResolver } from './configurePlatform-D-Pj9gTx.js';
2
- import { a as withDbTabLock, n as notifyFilesWrittenOutsideCache, c as createSessionObjectUrl, b as withSeedDbLock } from './tabEvents-BuorBItJ.js';
3
- import { F as BaseDb, h as appState, aC as contentSha256TagMatches, N as BaseFileManager, aq as withSqliteBusyRetry } from './index-s73wD_LC.js';
1
+ import { B as BasePathResolver } from './configurePlatform-AWild9o4.js';
2
+ import { d as withDbTabLock, n as notifyFilesWrittenOutsideCache, f as createSessionObjectUrl, g as withSeedDbLock, h as countDbStatements, s as startChangeFeed, j as countLiveQueryRuns } from './changeFeed-DcsZ7deG.js';
3
+ import { G as BaseDb, h as appState, aE as contentSha256TagMatches, Q as BaseFileManager, aT as withSqliteBusyRetry } from './index-C0SetTd1.js';
4
4
  import { eq, sql } from 'drizzle-orm';
5
5
  import { M as MIME_TO_EXTENSION } from './mimeTypes-C9r76DCH.js';
6
6
  import debug from 'debug';
@@ -8,9 +8,9 @@ import { F as FileSystemLockedError, D as DatabaseNotPersistentError } from './e
8
8
  import { drizzle } from 'drizzle-orm/sqlite-proxy';
9
9
  import { sha256 } from '@noble/hashes/sha256';
10
10
  import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils';
11
- import { s as schema } from './index-B6hPWSM4.js';
11
+ import { s as schema } from './index-CZQrNqvq.js';
12
12
  import { SQLocalDrizzle } from 'sqlocal/drizzle';
13
- import { Observable, distinctUntilChanged } from 'rxjs';
13
+ import { throwError, Observable, distinctUntilChanged, finalize, share, ReplaySubject } from 'rxjs';
14
14
  import { BaseArweaveClient, fetchTransactionStatusAcrossGateways, getPreferredArweaveReadBaseUrls, fetchArweaveRawFromBaseUrl, GET_TRANSACTION_TAGS } from '@seedprotocol/arweave';
15
15
  import { GraphQLClient } from 'graphql-request';
16
16
  import Arweave from 'arweave';
@@ -1448,9 +1448,9 @@ class BrowserFileManager {
1448
1448
  }
1449
1449
  async initializeFileSystem(_workingDir) {
1450
1450
  const zenfs = await this.getFs();
1451
- const { TolerantWebAccess, TolerantWebAccessFS } = await import('./tolerantWebAccess-DoI7QYT-.js');
1452
- const _mod_0 = await import('./tabEvents-BuorBItJ.js');
1453
- const _ns_0 = _mod_0.k;
1451
+ const { TolerantWebAccess, TolerantWebAccessFS } = await import('./tolerantWebAccess-CIpS7RLk.js');
1452
+ const _mod_0 = await import('./changeFeed-DcsZ7deG.js');
1453
+ const _ns_0 = _mod_0.H;
1454
1454
  const { queueFilesChangedNotice } = _ns_0;
1455
1455
  const { configureSingle } = zenfs;
1456
1456
  const configureRoot = async () => {
@@ -1518,7 +1518,7 @@ class BrowserFileManager {
1518
1518
  }
1519
1519
  async invalidateNow(filePaths) {
1520
1520
  const { mounts } = await this.getFs();
1521
- const { TolerantWebAccessFS } = await import('./tolerantWebAccess-DoI7QYT-.js');
1521
+ const { TolerantWebAccessFS } = await import('./tolerantWebAccess-CIpS7RLk.js');
1522
1522
  const mounted = mounts.get('/');
1523
1523
  if (!(mounted instanceof TolerantWebAccessFS))
1524
1524
  return;
@@ -2286,6 +2286,59 @@ const migrationSql_0020_add_pending_writes = `CREATE TABLE \`pending_writes\` (
2286
2286
  CREATE UNIQUE INDEX \`pending_writes_op_id_unique\` ON \`pending_writes\` (\`op_id\`);--> statement-breakpoint
2287
2287
  CREATE INDEX \`pending_writes_drain_order\` ON \`pending_writes\` (\`status\`,\`seed_local_id\`,\`property_name\`,\`created_at\`);`;
2288
2288
  const migrationSql_0021_add_pending_write_error_name = `ALTER TABLE \`pending_writes\` ADD \`error_name\` text;`;
2289
+ const migrationSql_0022_add_read_indexes = `CREATE INDEX \`metadata_seed_local_id_property_name_idx\` ON \`metadata\` (\`seed_local_id\`,\`property_name\`);--> statement-breakpoint
2290
+ CREATE INDEX \`metadata_seed_uid_idx\` ON \`metadata\` (\`seed_uid\`);--> statement-breakpoint
2291
+ CREATE INDEX \`seeds_uid_idx\` ON \`seeds\` (\`uid\`);--> statement-breakpoint
2292
+ CREATE INDEX \`seeds_type_idx\` ON \`seeds\` (\`type\`);--> statement-breakpoint
2293
+ CREATE INDEX \`versions_seed_local_id_idx\` ON \`versions\` (\`seed_local_id\`);`;
2294
+ const migrationSql_0023_add_entity_changes = `CREATE TABLE \`entity_changes\` (
2295
+ \`seq\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
2296
+ \`tbl\` text NOT NULL,
2297
+ \`seed_local_id\` text,
2298
+ \`seed_uid\` text,
2299
+ \`property_name\` text,
2300
+ \`at\` integer NOT NULL
2301
+ );
2302
+ --> statement-breakpoint
2303
+ CREATE INDEX \`entity_changes_at\` ON \`entity_changes\` (\`at\`);--> statement-breakpoint
2304
+ CREATE TRIGGER \`entity_changes_seeds_insert\` AFTER INSERT ON \`seeds\` BEGIN
2305
+ INSERT INTO \`entity_changes\` (\`tbl\`, \`seed_local_id\`, \`seed_uid\`, \`at\`) VALUES ('seeds', NEW.\`local_id\`, NEW.\`uid\`, CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER));
2306
+ END;
2307
+ --> statement-breakpoint
2308
+ CREATE TRIGGER \`entity_changes_seeds_update\` AFTER UPDATE ON \`seeds\` BEGIN
2309
+ INSERT INTO \`entity_changes\` (\`tbl\`, \`seed_local_id\`, \`seed_uid\`, \`at\`) VALUES ('seeds', NEW.\`local_id\`, NEW.\`uid\`, CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER));
2310
+ INSERT INTO \`entity_changes\` (\`tbl\`, \`seed_local_id\`, \`seed_uid\`, \`at\`) SELECT 'seeds', OLD.\`local_id\`, OLD.\`uid\`, CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER) WHERE OLD.\`local_id\` IS NOT NEW.\`local_id\` OR OLD.\`uid\` IS NOT NEW.\`uid\`;
2311
+ END;
2312
+ --> statement-breakpoint
2313
+ CREATE TRIGGER \`entity_changes_seeds_delete\` AFTER DELETE ON \`seeds\` BEGIN
2314
+ INSERT INTO \`entity_changes\` (\`tbl\`, \`seed_local_id\`, \`seed_uid\`, \`at\`) VALUES ('seeds', OLD.\`local_id\`, OLD.\`uid\`, CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER));
2315
+ END;
2316
+ --> statement-breakpoint
2317
+ CREATE TRIGGER \`entity_changes_versions_insert\` AFTER INSERT ON \`versions\` BEGIN
2318
+ INSERT INTO \`entity_changes\` (\`tbl\`, \`seed_local_id\`, \`seed_uid\`, \`at\`) VALUES ('versions', NEW.\`seed_local_id\`, NEW.\`seed_uid\`, CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER));
2319
+ END;
2320
+ --> statement-breakpoint
2321
+ CREATE TRIGGER \`entity_changes_versions_update\` AFTER UPDATE ON \`versions\` BEGIN
2322
+ INSERT INTO \`entity_changes\` (\`tbl\`, \`seed_local_id\`, \`seed_uid\`, \`at\`) VALUES ('versions', NEW.\`seed_local_id\`, NEW.\`seed_uid\`, CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER));
2323
+ INSERT INTO \`entity_changes\` (\`tbl\`, \`seed_local_id\`, \`seed_uid\`, \`at\`) SELECT 'versions', OLD.\`seed_local_id\`, OLD.\`seed_uid\`, CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER) WHERE OLD.\`seed_local_id\` IS NOT NEW.\`seed_local_id\` OR OLD.\`seed_uid\` IS NOT NEW.\`seed_uid\`;
2324
+ END;
2325
+ --> statement-breakpoint
2326
+ CREATE TRIGGER \`entity_changes_versions_delete\` AFTER DELETE ON \`versions\` BEGIN
2327
+ INSERT INTO \`entity_changes\` (\`tbl\`, \`seed_local_id\`, \`seed_uid\`, \`at\`) VALUES ('versions', OLD.\`seed_local_id\`, OLD.\`seed_uid\`, CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER));
2328
+ END;
2329
+ --> statement-breakpoint
2330
+ CREATE TRIGGER \`entity_changes_metadata_insert\` AFTER INSERT ON \`metadata\` BEGIN
2331
+ INSERT INTO \`entity_changes\` (\`tbl\`, \`seed_local_id\`, \`seed_uid\`, \`property_name\`, \`at\`) VALUES ('metadata', NEW.\`seed_local_id\`, NEW.\`seed_uid\`, NEW.\`property_name\`, CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER));
2332
+ END;
2333
+ --> statement-breakpoint
2334
+ CREATE TRIGGER \`entity_changes_metadata_update\` AFTER UPDATE ON \`metadata\` BEGIN
2335
+ INSERT INTO \`entity_changes\` (\`tbl\`, \`seed_local_id\`, \`seed_uid\`, \`property_name\`, \`at\`) VALUES ('metadata', NEW.\`seed_local_id\`, NEW.\`seed_uid\`, NEW.\`property_name\`, CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER));
2336
+ INSERT INTO \`entity_changes\` (\`tbl\`, \`seed_local_id\`, \`seed_uid\`, \`property_name\`, \`at\`) SELECT 'metadata', OLD.\`seed_local_id\`, OLD.\`seed_uid\`, OLD.\`property_name\`, CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER) WHERE OLD.\`seed_local_id\` IS NOT NEW.\`seed_local_id\` OR OLD.\`seed_uid\` IS NOT NEW.\`seed_uid\` OR OLD.\`property_name\` IS NOT NEW.\`property_name\`;
2337
+ END;
2338
+ --> statement-breakpoint
2339
+ CREATE TRIGGER \`entity_changes_metadata_delete\` AFTER DELETE ON \`metadata\` BEGIN
2340
+ INSERT INTO \`entity_changes\` (\`tbl\`, \`seed_local_id\`, \`seed_uid\`, \`property_name\`, \`at\`) VALUES ('metadata', OLD.\`seed_local_id\`, OLD.\`seed_uid\`, OLD.\`property_name\`, CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER));
2341
+ END;`;
2289
2342
  // Journal JSON file
2290
2343
  const journalJson = `{
2291
2344
  "version": "7",
@@ -2444,6 +2497,20 @@ const journalJson = `{
2444
2497
  "when": 1792414753260,
2445
2498
  "tag": "0021_add_pending_write_error_name",
2446
2499
  "breakpoints": true
2500
+ },
2501
+ {
2502
+ "idx": 22,
2503
+ "version": "6",
2504
+ "when": 1792453791787,
2505
+ "tag": "0022_add_read_indexes",
2506
+ "breakpoints": true
2507
+ },
2508
+ {
2509
+ "idx": 23,
2510
+ "version": "6",
2511
+ "when": 1792455641631,
2512
+ "tag": "0023_add_entity_changes",
2513
+ "breakpoints": true
2447
2514
  }
2448
2515
  ]
2449
2516
  }`;
@@ -2452,8 +2519,8 @@ const journalJson = `{
2452
2519
  const snapshotJson = `{
2453
2520
  "version": "6",
2454
2521
  "dialect": "sqlite",
2455
- "id": "c33040d2-3fd4-4a1a-a55b-2cd5fc622377",
2456
- "prevId": "3cf4e0c7-569e-4f14-bb99-56cef0694448",
2522
+ "id": "7767667b-3cf0-4630-b1ff-02913f2f35ad",
2523
+ "prevId": "781ce7c2-f397-4df2-a32c-9267c4a4163d",
2457
2524
  "tables": {
2458
2525
  "appState": {
2459
2526
  "name": "appState",
@@ -2728,6 +2795,66 @@ const snapshotJson = `{
2728
2795
  "uniqueConstraints": {},
2729
2796
  "checkConstraints": {}
2730
2797
  },
2798
+ "entity_changes": {
2799
+ "name": "entity_changes",
2800
+ "columns": {
2801
+ "seq": {
2802
+ "name": "seq",
2803
+ "type": "integer",
2804
+ "primaryKey": true,
2805
+ "notNull": true,
2806
+ "autoincrement": true
2807
+ },
2808
+ "tbl": {
2809
+ "name": "tbl",
2810
+ "type": "text",
2811
+ "primaryKey": false,
2812
+ "notNull": true,
2813
+ "autoincrement": false
2814
+ },
2815
+ "seed_local_id": {
2816
+ "name": "seed_local_id",
2817
+ "type": "text",
2818
+ "primaryKey": false,
2819
+ "notNull": false,
2820
+ "autoincrement": false
2821
+ },
2822
+ "seed_uid": {
2823
+ "name": "seed_uid",
2824
+ "type": "text",
2825
+ "primaryKey": false,
2826
+ "notNull": false,
2827
+ "autoincrement": false
2828
+ },
2829
+ "property_name": {
2830
+ "name": "property_name",
2831
+ "type": "text",
2832
+ "primaryKey": false,
2833
+ "notNull": false,
2834
+ "autoincrement": false
2835
+ },
2836
+ "at": {
2837
+ "name": "at",
2838
+ "type": "integer",
2839
+ "primaryKey": false,
2840
+ "notNull": true,
2841
+ "autoincrement": false
2842
+ }
2843
+ },
2844
+ "indexes": {
2845
+ "entity_changes_at": {
2846
+ "name": "entity_changes_at",
2847
+ "columns": [
2848
+ "at"
2849
+ ],
2850
+ "isUnique": false
2851
+ }
2852
+ },
2853
+ "foreignKeys": {},
2854
+ "compositePrimaryKeys": {},
2855
+ "uniqueConstraints": {},
2856
+ "checkConstraints": {}
2857
+ },
2731
2858
  "html_embedded_image_co_publish": {
2732
2859
  "name": "html_embedded_image_co_publish",
2733
2860
  "columns": {
@@ -2983,6 +3110,21 @@ const snapshotJson = `{
2983
3110
  "local_id"
2984
3111
  ],
2985
3112
  "isUnique": true
3113
+ },
3114
+ "metadata_seed_local_id_property_name_idx": {
3115
+ "name": "metadata_seed_local_id_property_name_idx",
3116
+ "columns": [
3117
+ "seed_local_id",
3118
+ "property_name"
3119
+ ],
3120
+ "isUnique": false
3121
+ },
3122
+ "metadata_seed_uid_idx": {
3123
+ "name": "metadata_seed_uid_idx",
3124
+ "columns": [
3125
+ "seed_uid"
3126
+ ],
3127
+ "isUnique": false
2986
3128
  }
2987
3129
  },
2988
3130
  "foreignKeys": {
@@ -3818,6 +3960,20 @@ const snapshotJson = `{
3818
3960
  "local_id"
3819
3961
  ],
3820
3962
  "isUnique": true
3963
+ },
3964
+ "seeds_uid_idx": {
3965
+ "name": "seeds_uid_idx",
3966
+ "columns": [
3967
+ "uid"
3968
+ ],
3969
+ "isUnique": false
3970
+ },
3971
+ "seeds_type_idx": {
3972
+ "name": "seeds_type_idx",
3973
+ "columns": [
3974
+ "type"
3975
+ ],
3976
+ "isUnique": false
3821
3977
  }
3822
3978
  },
3823
3979
  "foreignKeys": {},
@@ -3979,6 +4135,13 @@ const snapshotJson = `{
3979
4135
  "local_id"
3980
4136
  ],
3981
4137
  "isUnique": true
4138
+ },
4139
+ "versions_seed_local_id_idx": {
4140
+ "name": "versions_seed_local_id_idx",
4141
+ "columns": [
4142
+ "seed_local_id"
4143
+ ],
4144
+ "isUnique": false
3982
4145
  }
3983
4146
  },
3984
4147
  "foreignKeys": {},
@@ -4024,6 +4187,8 @@ var drizzleFiles = /*#__PURE__*/Object.freeze({
4024
4187
  migrationSql_0019_add_derived_from_uid_to_metadata: migrationSql_0019_add_derived_from_uid_to_metadata,
4025
4188
  migrationSql_0020_add_pending_writes: migrationSql_0020_add_pending_writes,
4026
4189
  migrationSql_0021_add_pending_write_error_name: migrationSql_0021_add_pending_write_error_name,
4190
+ migrationSql_0022_add_read_indexes: migrationSql_0022_add_read_indexes,
4191
+ migrationSql_0023_add_entity_changes: migrationSql_0023_add_entity_changes,
4027
4192
  snapshotJson: snapshotJson
4028
4193
  });
4029
4194
 
@@ -4178,6 +4343,10 @@ function installModuleWorkerBlobWrap(onWorkerFailed) {
4178
4343
 
4179
4344
  const logger$1 = debug('seedSdk:browser:db:Db');
4180
4345
  class BrowserDb {
4346
+ constructor() {
4347
+ /** Live queries by SQL + params while they have subscribers; see liveQuery. */
4348
+ this.sharedLiveQueries = new Map();
4349
+ }
4181
4350
  getAppDb() {
4182
4351
  return this.appDb;
4183
4352
  }
@@ -4229,9 +4398,11 @@ class BrowserDb {
4229
4398
  reactive: true,
4230
4399
  }));
4231
4400
  const { batchDriver } = sqlocalDrizzle;
4232
- const driver = withSqliteBusyRetry(sqlocalDrizzle.driver);
4401
+ const driver = countDbStatements(withSqliteBusyRetry(sqlocalDrizzle.driver));
4233
4402
  // Store SQLocalDrizzle instance for reactive queries
4234
4403
  this.sqlocalInstance = sqlocalDrizzle;
4404
+ // Shared live queries still open belong to the previous instance; new calls start fresh.
4405
+ this.sharedLiveQueries.clear();
4235
4406
  // Create db instance but do NOT set this.appDb yet. restoreFromDb (and other
4236
4407
  // callers of getAppDb()) must not see the db until migrations have completed,
4237
4408
  // otherwise they may query tables (e.g. publish_processes) that don't exist yet.
@@ -4247,11 +4418,17 @@ class BrowserDb {
4247
4418
  }
4248
4419
  await this.runMigrations(db);
4249
4420
  this.appDb = db;
4250
- const { backfillMetadataPropertyIds } = await import('./backfillMetadataPropertyIds-vc_1RoDT.js');
4421
+ const { backfillMetadataPropertyIds } = await import('./backfillMetadataPropertyIds-DWWkh-Ex.js');
4251
4422
  await backfillMetadataPropertyIds();
4252
4423
  // One-time: clear item data whose model can't be determined (seeds.model_file_id, migration 0015)
4253
- const { resetAmbiguousLegacyItemData } = await import('./resetAmbiguousLegacyItemData-B_IUQA09.js');
4424
+ const { resetAmbiguousLegacyItemData } = await import('./resetAmbiguousLegacyItemData-0Tin9-JK.js');
4254
4425
  await resetAmbiguousLegacyItemData();
4426
+ // Loaded Items and ItemProperties hear about row changes through it (ADR 0020). Started
4427
+ // after the fixups above, so their log rows aren't dispatched.
4428
+ await startChangeFeed(db, {
4429
+ liveQuery: (query) => this.liveQuery(query),
4430
+ sql: ((...args) => sqlocalDrizzle.sql(...args)),
4431
+ });
4255
4432
  })(), workerFailed);
4256
4433
  return this.appDb;
4257
4434
  }
@@ -4465,12 +4642,27 @@ class BrowserDb {
4465
4642
  if (!this.sqlocalInstance.reactiveQuery) {
4466
4643
  throw new Error('Reactive queries not enabled. Initialize SQLocalDrizzle with reactive: true.');
4467
4644
  }
4645
+ // Resolve an SQL tag function here, with the same tag SQLocal uses, so the statement's SQL and
4646
+ // params are known before any query runs and identical live queries can share one.
4647
+ let statement;
4648
+ try {
4649
+ statement = typeof query === 'function' ? query(sqlTag) : query;
4650
+ }
4651
+ catch (error) {
4652
+ return throwError(() => error);
4653
+ }
4654
+ const key = liveQueryKey(statement);
4655
+ const existing = key ? this.sharedLiveQueries.get(key) : undefined;
4656
+ if (existing)
4657
+ return existing;
4468
4658
  const baseObservable = new Observable((subscriber) => {
4469
4659
  // Setup errors (bad SQL, a closed database) go to the subscriber like query errors, so
4470
4660
  // callers see them as an error notification rather than only in the console.
4471
4661
  let subscription;
4662
+ const countRun = countLiveQueryRuns();
4472
4663
  try {
4473
- subscription = this.sqlocalInstance.reactiveQuery(query).subscribe((data) => {
4664
+ subscription = this.sqlocalInstance.reactiveQuery(statement).subscribe((data) => {
4665
+ countRun();
4474
4666
  subscriber.next(data);
4475
4667
  }, (err) => {
4476
4668
  logger$1('[BaseDb.liveQuery] SQLocal reactiveQuery error:', err);
@@ -4489,10 +4681,43 @@ class BrowserDb {
4489
4681
  // Compare stable JSON snapshots via keySelector. SQLocal may reuse one array reference
4490
4682
  // and mutate rows in place; comparing (prev, curr) on the same reference makes
4491
4683
  // JSON.stringify(prev) === JSON.stringify(curr) after mutation and suppresses emissions.
4492
- return baseObservable.pipe(distinctUntilChanged((a, b) => a === b, (x) => JSON.stringify(x)));
4684
+ const distinct = baseObservable.pipe(distinctUntilChanged((a, b) => a === b, (x) => JSON.stringify(x)));
4685
+ if (!key)
4686
+ return distinct;
4687
+ // Every caller with the same SQL and params gets this observable: one SQLocal reactiveQuery
4688
+ // (one run per table change) however many subscribe. A late subscriber gets the last rows at
4689
+ // once. When the last subscriber leaves, the reactiveQuery closes and the entry is dropped,
4690
+ // so the next call starts a fresh query.
4691
+ const shared = distinct.pipe(finalize(() => {
4692
+ if (this.sharedLiveQueries.get(key) === shared)
4693
+ this.sharedLiveQueries.delete(key);
4694
+ }), share({ connector: () => new ReplaySubject(1) }));
4695
+ this.sharedLiveQueries.set(key, shared);
4696
+ return shared;
4697
+ }
4698
+ }
4699
+ /** SQLocal's own SQL tag (sqlocal/dist/lib/sql-tag.js), which the package does not export. */
4700
+ function sqlTag(queryTemplate, ...params) {
4701
+ return { sql: queryTemplate.join('?'), params };
4702
+ }
4703
+ /**
4704
+ * Identifies a live query by its SQL and bound params. Undefined (not shared) for a Drizzle query
4705
+ * builder, whose row mapping depends on its select object and not only on the SQL text, and when
4706
+ * the params can't be serialized.
4707
+ */
4708
+ function liveQueryKey(statement) {
4709
+ if (typeof statement?.getSQL === 'function')
4710
+ return undefined;
4711
+ try {
4712
+ const { sql, params } = statement ?? {};
4713
+ if (typeof sql !== 'string')
4714
+ return undefined;
4715
+ return JSON.stringify([sql, params ?? []]);
4716
+ }
4717
+ catch {
4718
+ return undefined;
4493
4719
  }
4494
4720
  }
4495
- BaseDb.configure(new BrowserDb());
4496
4721
 
4497
4722
  const logger = debug("seedSdk:browser:ArweaveClient");
4498
4723
  // Cached Arweave instance (keyed by gateway so setHost / protocol changes apply)
@@ -4724,4 +4949,4 @@ function resolveFilesDir(filesDir) {
4724
4949
  }
4725
4950
 
4726
4951
  export { createPlatformServices as c, isSkippableOpfsEntryError as i, resolveFilesDir as r };
4727
- //# sourceMappingURL=index.browser-C7iZp7mx.js.map
4952
+ //# sourceMappingURL=index.browser-Ll71Y_Dl.js.map