@multiplatform.one/frappe 9.17.0 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (597) hide show
  1. package/dist/cjs/auth.cjs +34 -44
  2. package/dist/cjs/auth.native.cjs +97 -0
  3. package/dist/cjs/auth.native.js +77 -82
  4. package/dist/cjs/auth.native.js.map +1 -1
  5. package/dist/cjs/call.cjs +31 -35
  6. package/dist/cjs/call.native.cjs +92 -0
  7. package/dist/cjs/call.native.js +72 -71
  8. package/dist/cjs/call.native.js.map +1 -1
  9. package/dist/cjs/collection.cjs +243 -287
  10. package/dist/cjs/collection.native.cjs +461 -0
  11. package/dist/cjs/collection.native.js +436 -499
  12. package/dist/cjs/collection.native.js.map +1 -1
  13. package/dist/cjs/common/types.cjs +9 -11
  14. package/dist/cjs/common/types.native.cjs +18 -0
  15. package/dist/cjs/common/types.native.js +9 -10
  16. package/dist/cjs/common/types.native.js.map +1 -1
  17. package/dist/cjs/connectionKey.cjs +18 -22
  18. package/dist/cjs/connectionKey.native.cjs +32 -0
  19. package/dist/cjs/connectionKey.native.js +19 -22
  20. package/dist/cjs/connectionKey.native.js.map +1 -1
  21. package/dist/cjs/core/http.cjs +404 -407
  22. package/dist/cjs/core/http.native.cjs +659 -0
  23. package/dist/cjs/core/http.native.js +611 -615
  24. package/dist/cjs/core/http.native.js.map +1 -1
  25. package/dist/cjs/core/serverMessages.cjs +48 -43
  26. package/dist/cjs/core/serverMessages.native.cjs +89 -0
  27. package/dist/cjs/core/serverMessages.native.js +69 -70
  28. package/dist/cjs/core/serverMessages.native.js.map +1 -1
  29. package/dist/cjs/core/sessionGate.cjs +94 -97
  30. package/dist/cjs/core/sessionGate.native.cjs +270 -0
  31. package/dist/cjs/core/sessionGate.native.js +220 -232
  32. package/dist/cjs/core/sessionGate.native.js.map +1 -1
  33. package/dist/cjs/core/types.cjs +37 -39
  34. package/dist/cjs/core/types.native.cjs +169 -0
  35. package/dist/cjs/core/types.native.js +129 -136
  36. package/dist/cjs/core/types.native.js.map +1 -1
  37. package/dist/cjs/core/wire.cjs +28 -30
  38. package/dist/cjs/core/wire.native.cjs +53 -0
  39. package/dist/cjs/core/wire.native.js +28 -29
  40. package/dist/cjs/core/wire.native.js.map +1 -1
  41. package/dist/cjs/db.cjs +434 -449
  42. package/dist/cjs/db.native.cjs +625 -0
  43. package/dist/cjs/db.native.js +583 -590
  44. package/dist/cjs/db.native.js.map +1 -1
  45. package/dist/cjs/devtools/FrappeDevtoolsPanel.cjs +774 -799
  46. package/dist/cjs/devtools/FrappeDevtoolsPanel.native.cjs +878 -0
  47. package/dist/cjs/devtools/FrappeDevtoolsPanel.native.js +821 -862
  48. package/dist/cjs/devtools/FrappeDevtoolsPanel.native.js.map +1 -1
  49. package/dist/cjs/devtools/index.cjs +15 -17
  50. package/dist/cjs/devtools/index.native.cjs +30 -0
  51. package/dist/cjs/devtools/index.native.js +15 -16
  52. package/dist/cjs/devtools/index.native.js.map +1 -1
  53. package/dist/cjs/devtools/plugin.cjs +22 -26
  54. package/dist/cjs/devtools/plugin.native.cjs +46 -0
  55. package/dist/cjs/devtools/plugin.native.js +27 -35
  56. package/dist/cjs/devtools/plugin.native.js.map +1 -1
  57. package/dist/cjs/devtools/theme.cjs +40 -44
  58. package/dist/cjs/devtools/theme.native.cjs +53 -0
  59. package/dist/cjs/devtools/theme.native.js +40 -43
  60. package/dist/cjs/devtools/theme.native.js.map +1 -1
  61. package/dist/cjs/doctype.cjs +493 -440
  62. package/dist/cjs/doctype.native.cjs +631 -0
  63. package/dist/cjs/doctype.native.js +587 -563
  64. package/dist/cjs/doctype.native.js.map +1 -1
  65. package/dist/cjs/file.cjs +27 -31
  66. package/dist/cjs/file.native.cjs +78 -0
  67. package/dist/cjs/file.native.js +58 -62
  68. package/dist/cjs/file.native.js.map +1 -1
  69. package/dist/cjs/fixtureDb.cjs +187 -209
  70. package/dist/cjs/fixtureDb.native.cjs +313 -0
  71. package/dist/cjs/fixtureDb.native.js +291 -300
  72. package/dist/cjs/fixtureDb.native.js.map +1 -1
  73. package/dist/cjs/fixtures.cjs +173 -192
  74. package/dist/cjs/fixtures.native.cjs +379 -0
  75. package/dist/cjs/fixtures.native.js +359 -381
  76. package/dist/cjs/fixtures.native.js.map +1 -1
  77. package/dist/cjs/frappeApp.cjs +94 -101
  78. package/dist/cjs/frappeApp.native.cjs +181 -0
  79. package/dist/cjs/frappeApp.native.js +153 -152
  80. package/dist/cjs/frappeApp.native.js.map +1 -1
  81. package/dist/cjs/frappeReact.cjs +555 -528
  82. package/dist/cjs/frappeReact.native.cjs +710 -0
  83. package/dist/cjs/frappeReact.native.js +637 -632
  84. package/dist/cjs/frappeReact.native.js.map +1 -1
  85. package/dist/cjs/index.cjs +128 -135
  86. package/dist/cjs/index.gnome.cjs +61 -63
  87. package/dist/cjs/index.gnome.native.cjs +87 -0
  88. package/dist/cjs/index.gnome.native.js +61 -62
  89. package/dist/cjs/index.gnome.native.js.map +1 -1
  90. package/dist/cjs/index.native.cjs +171 -0
  91. package/dist/cjs/index.native.js +130 -136
  92. package/dist/cjs/index.native.js.map +1 -1
  93. package/dist/cjs/optimistic.cjs +35 -39
  94. package/dist/cjs/optimistic.native.cjs +59 -0
  95. package/dist/cjs/optimistic.native.js +38 -41
  96. package/dist/cjs/optimistic.native.js.map +1 -1
  97. package/dist/cjs/pacer.cjs +170 -176
  98. package/dist/cjs/pacer.native.cjs +263 -0
  99. package/dist/cjs/pacer.native.js +234 -245
  100. package/dist/cjs/pacer.native.js.map +1 -1
  101. package/dist/cjs/plugin/index.cjs +104 -112
  102. package/dist/cjs/plugin/index.native.cjs +178 -0
  103. package/dist/cjs/plugin/index.native.js +164 -177
  104. package/dist/cjs/plugin/index.native.js.map +1 -1
  105. package/dist/cjs/realtime.cjs +581 -610
  106. package/dist/cjs/realtime.native.cjs +945 -0
  107. package/dist/cjs/realtime.native.js +918 -928
  108. package/dist/cjs/realtime.native.js.map +1 -1
  109. package/dist/cjs/serverLoaders.cjs +60 -78
  110. package/dist/cjs/serverLoaders.native.cjs +103 -0
  111. package/dist/cjs/serverLoaders.native.js +73 -95
  112. package/dist/cjs/serverLoaders.native.js.map +1 -1
  113. package/dist/cjs/sync/backfill.cjs +281 -301
  114. package/dist/cjs/sync/backfill.native.cjs +475 -0
  115. package/dist/cjs/sync/backfill.native.js +449 -465
  116. package/dist/cjs/sync/backfill.native.js.map +1 -1
  117. package/dist/cjs/sync/filters.cjs +309 -267
  118. package/dist/cjs/sync/filters.native.cjs +472 -0
  119. package/dist/cjs/sync/filters.native.js +426 -398
  120. package/dist/cjs/sync/filters.native.js.map +1 -1
  121. package/dist/cjs/sync/index.cjs +476 -496
  122. package/dist/cjs/sync/index.native.cjs +771 -0
  123. package/dist/cjs/sync/index.native.js +738 -737
  124. package/dist/cjs/sync/index.native.js.map +1 -1
  125. package/dist/cjs/sync/merge.cjs +392 -393
  126. package/dist/cjs/sync/merge.native.cjs +681 -0
  127. package/dist/cjs/sync/merge.native.js +642 -673
  128. package/dist/cjs/sync/merge.native.js.map +1 -1
  129. package/dist/cjs/sync/mutationEngine.cjs +785 -829
  130. package/dist/cjs/sync/mutationEngine.native.cjs +1190 -0
  131. package/dist/cjs/sync/mutationEngine.native.js +1162 -1216
  132. package/dist/cjs/sync/mutationEngine.native.js.map +1 -1
  133. package/dist/cjs/sync/mutationJournal.cjs +147 -149
  134. package/dist/cjs/sync/mutationJournal.native.cjs +302 -0
  135. package/dist/cjs/sync/mutationJournal.native.js +278 -269
  136. package/dist/cjs/sync/mutationJournal.native.js.map +1 -1
  137. package/dist/cjs/sync/normalizedCache.cjs +127 -134
  138. package/dist/cjs/sync/normalizedCache.native.cjs +232 -0
  139. package/dist/cjs/sync/normalizedCache.native.js +212 -212
  140. package/dist/cjs/sync/normalizedCache.native.js.map +1 -1
  141. package/dist/cjs/sync/persistence.cjs +649 -661
  142. package/dist/cjs/sync/persistence.native.cjs +996 -0
  143. package/dist/cjs/sync/persistence.native.js +967 -965
  144. package/dist/cjs/sync/persistence.native.js.map +1 -1
  145. package/dist/cjs/sync/realtime.cjs +307 -315
  146. package/dist/cjs/sync/realtime.native.cjs +486 -0
  147. package/dist/cjs/sync/realtime.native.js +465 -461
  148. package/dist/cjs/sync/realtime.native.js.map +1 -1
  149. package/dist/cjs/sync/rehydration.cjs +279 -321
  150. package/dist/cjs/sync/rehydration.native.cjs +495 -0
  151. package/dist/cjs/sync/rehydration.native.js +473 -515
  152. package/dist/cjs/sync/rehydration.native.js.map +1 -1
  153. package/dist/cjs/sync/storage.cjs +127 -129
  154. package/dist/cjs/sync/storage.native.cjs +211 -0
  155. package/dist/cjs/sync/storage.native.js +188 -184
  156. package/dist/cjs/sync/storage.native.js.map +1 -1
  157. package/dist/cjs/sync/subscriptionManager.cjs +686 -708
  158. package/dist/cjs/sync/subscriptionManager.native.cjs +1205 -0
  159. package/dist/cjs/sync/subscriptionManager.native.js +1179 -1220
  160. package/dist/cjs/sync/subscriptionManager.native.js.map +1 -1
  161. package/dist/cjs/sync/types.cjs +79 -81
  162. package/dist/cjs/sync/types.native.cjs +103 -0
  163. package/dist/cjs/sync/types.native.js +89 -90
  164. package/dist/cjs/sync/types.native.js.map +1 -1
  165. package/dist/cjs/sync/virtualPageManager.cjs +762 -806
  166. package/dist/cjs/sync/virtualPageManager.native.cjs +1097 -0
  167. package/dist/cjs/sync/virtualPageManager.native.js +1072 -1097
  168. package/dist/cjs/sync/virtualPageManager.native.js.map +1 -1
  169. package/dist/cjs/syncOptionsKey.cjs +38 -45
  170. package/dist/cjs/syncOptionsKey.native.cjs +69 -0
  171. package/dist/cjs/syncOptionsKey.native.js +51 -63
  172. package/dist/cjs/syncOptionsKey.native.js.map +1 -1
  173. package/dist/cjs/useLiveQuery.cjs +14 -18
  174. package/dist/cjs/useLiveQuery.native.cjs +26 -0
  175. package/dist/cjs/useLiveQuery.native.js +14 -17
  176. package/dist/cjs/useLiveQuery.native.js.map +1 -1
  177. package/dist/cjs/util.cjs +22 -24
  178. package/dist/cjs/util.native.cjs +40 -0
  179. package/dist/cjs/util.native.js +22 -28
  180. package/dist/cjs/util.native.js.map +1 -1
  181. package/dist/esm/auth.mjs +22 -27
  182. package/dist/esm/auth.mjs.map +1 -1
  183. package/dist/esm/auth.native.js +64 -65
  184. package/dist/esm/auth.native.js.map +1 -1
  185. package/dist/esm/call.mjs +19 -18
  186. package/dist/esm/call.mjs.map +1 -1
  187. package/dist/esm/call.native.js +59 -54
  188. package/dist/esm/call.native.js.map +1 -1
  189. package/dist/esm/collection.mjs +228 -268
  190. package/dist/esm/collection.mjs.map +1 -1
  191. package/dist/esm/collection.native.js +421 -481
  192. package/dist/esm/collection.native.js.map +1 -1
  193. package/dist/esm/common/types.mjs +0 -2
  194. package/dist/esm/common/types.native.js +0 -2
  195. package/dist/esm/connectionKey.mjs +5 -4
  196. package/dist/esm/connectionKey.mjs.map +1 -1
  197. package/dist/esm/connectionKey.native.js +6 -5
  198. package/dist/esm/connectionKey.native.js.map +1 -1
  199. package/dist/esm/core/http.mjs +383 -382
  200. package/dist/esm/core/http.mjs.map +1 -1
  201. package/dist/esm/core/http.native.js +590 -591
  202. package/dist/esm/core/http.native.js.map +1 -1
  203. package/dist/esm/core/serverMessages.mjs +34 -26
  204. package/dist/esm/core/serverMessages.mjs.map +1 -1
  205. package/dist/esm/core/serverMessages.native.js +55 -54
  206. package/dist/esm/core/serverMessages.native.js.map +1 -1
  207. package/dist/esm/core/sessionGate.mjs +79 -79
  208. package/dist/esm/core/sessionGate.mjs.map +1 -1
  209. package/dist/esm/core/sessionGate.native.js +205 -215
  210. package/dist/esm/core/sessionGate.native.js.map +1 -1
  211. package/dist/esm/core/types.mjs +23 -22
  212. package/dist/esm/core/types.mjs.map +1 -1
  213. package/dist/esm/core/types.native.js +114 -119
  214. package/dist/esm/core/types.native.js.map +1 -1
  215. package/dist/esm/core/wire.mjs +10 -9
  216. package/dist/esm/core/wire.mjs.map +1 -1
  217. package/dist/esm/core/wire.native.js +10 -9
  218. package/dist/esm/core/wire.native.js.map +1 -1
  219. package/dist/esm/db.mjs +421 -432
  220. package/dist/esm/db.mjs.map +1 -1
  221. package/dist/esm/db.native.js +570 -574
  222. package/dist/esm/db.native.js.map +1 -1
  223. package/dist/esm/devtools/FrappeDevtoolsPanel.mjs +762 -781
  224. package/dist/esm/devtools/FrappeDevtoolsPanel.mjs.map +1 -1
  225. package/dist/esm/devtools/FrappeDevtoolsPanel.native.js +808 -839
  226. package/dist/esm/devtools/FrappeDevtoolsPanel.native.js.map +1 -1
  227. package/dist/esm/devtools/index.mjs +2 -2
  228. package/dist/esm/devtools/index.native.js +2 -2
  229. package/dist/esm/devtools/plugin.mjs +10 -8
  230. package/dist/esm/devtools/plugin.mjs.map +1 -1
  231. package/dist/esm/devtools/plugin.native.js +14 -12
  232. package/dist/esm/devtools/plugin.native.js.map +1 -1
  233. package/dist/esm/devtools/theme.mjs +27 -26
  234. package/dist/esm/devtools/theme.mjs.map +1 -1
  235. package/dist/esm/devtools/theme.native.js +27 -26
  236. package/dist/esm/devtools/theme.native.js.map +1 -1
  237. package/dist/esm/doctype.mjs +473 -416
  238. package/dist/esm/doctype.mjs.map +1 -1
  239. package/dist/esm/doctype.native.js +566 -539
  240. package/dist/esm/doctype.native.js.map +1 -1
  241. package/dist/esm/file.mjs +15 -14
  242. package/dist/esm/file.mjs.map +1 -1
  243. package/dist/esm/file.native.js +45 -45
  244. package/dist/esm/file.native.js.map +1 -1
  245. package/dist/esm/fixtureDb.mjs +175 -191
  246. package/dist/esm/fixtureDb.mjs.map +1 -1
  247. package/dist/esm/fixtureDb.native.js +279 -283
  248. package/dist/esm/fixtureDb.native.js.map +1 -1
  249. package/dist/esm/fixtures.mjs +161 -175
  250. package/dist/esm/fixtures.mjs.map +1 -1
  251. package/dist/esm/fixtures.native.js +346 -364
  252. package/dist/esm/fixtures.native.js.map +1 -1
  253. package/dist/esm/frappeApp.mjs +82 -83
  254. package/dist/esm/frappeApp.mjs.map +1 -1
  255. package/dist/esm/frappeApp.native.js +141 -135
  256. package/dist/esm/frappeApp.native.js.map +1 -1
  257. package/dist/esm/frappeReact.mjs +535 -504
  258. package/dist/esm/frappeReact.mjs.map +1 -1
  259. package/dist/esm/frappeReact.native.js +615 -607
  260. package/dist/esm/frappeReact.native.js.map +1 -1
  261. package/dist/esm/index.gnome.mjs +5 -5
  262. package/dist/esm/index.gnome.native.js +5 -5
  263. package/dist/esm/index.mjs +17 -18
  264. package/dist/esm/index.native.js +17 -18
  265. package/dist/esm/optimistic.mjs +19 -19
  266. package/dist/esm/optimistic.mjs.map +1 -1
  267. package/dist/esm/optimistic.native.js +22 -22
  268. package/dist/esm/optimistic.native.js.map +1 -1
  269. package/dist/esm/pacer.mjs +156 -158
  270. package/dist/esm/pacer.mjs.map +1 -1
  271. package/dist/esm/pacer.native.js +220 -228
  272. package/dist/esm/pacer.native.js.map +1 -1
  273. package/dist/esm/plugin/index.mjs +91 -94
  274. package/dist/esm/plugin/index.mjs.map +1 -1
  275. package/dist/esm/plugin/index.native.js +151 -160
  276. package/dist/esm/plugin/index.native.js.map +1 -1
  277. package/dist/esm/realtime.mjs +569 -594
  278. package/dist/esm/realtime.mjs.map +1 -1
  279. package/dist/esm/realtime.native.js +905 -912
  280. package/dist/esm/realtime.native.js.map +1 -1
  281. package/dist/esm/serverLoaders.mjs +47 -61
  282. package/dist/esm/serverLoaders.mjs.map +1 -1
  283. package/dist/esm/serverLoaders.native.js +56 -75
  284. package/dist/esm/serverLoaders.native.js.map +1 -1
  285. package/dist/esm/sync/backfill.mjs +268 -284
  286. package/dist/esm/sync/backfill.mjs.map +1 -1
  287. package/dist/esm/sync/backfill.native.js +435 -448
  288. package/dist/esm/sync/backfill.native.js.map +1 -1
  289. package/dist/esm/sync/filters.mjs +286 -241
  290. package/dist/esm/sync/filters.mjs.map +1 -1
  291. package/dist/esm/sync/filters.native.js +403 -373
  292. package/dist/esm/sync/filters.native.js.map +1 -1
  293. package/dist/esm/sync/index.mjs +465 -479
  294. package/dist/esm/sync/index.mjs.map +1 -1
  295. package/dist/esm/sync/index.native.js +726 -720
  296. package/dist/esm/sync/index.native.js.map +1 -1
  297. package/dist/esm/sync/merge.mjs +368 -366
  298. package/dist/esm/sync/merge.mjs.map +1 -1
  299. package/dist/esm/sync/merge.native.js +618 -647
  300. package/dist/esm/sync/merge.native.js.map +1 -1
  301. package/dist/esm/sync/mutationEngine.mjs +775 -814
  302. package/dist/esm/sync/mutationEngine.mjs.map +1 -1
  303. package/dist/esm/sync/mutationEngine.native.js +1152 -1202
  304. package/dist/esm/sync/mutationEngine.native.js.map +1 -1
  305. package/dist/esm/sync/mutationJournal.mjs +135 -133
  306. package/dist/esm/sync/mutationJournal.mjs.map +1 -1
  307. package/dist/esm/sync/mutationJournal.native.js +265 -253
  308. package/dist/esm/sync/mutationJournal.native.js.map +1 -1
  309. package/dist/esm/sync/normalizedCache.mjs +115 -117
  310. package/dist/esm/sync/normalizedCache.mjs.map +1 -1
  311. package/dist/esm/sync/normalizedCache.native.js +199 -195
  312. package/dist/esm/sync/normalizedCache.native.js.map +1 -1
  313. package/dist/esm/sync/persistence.mjs +637 -645
  314. package/dist/esm/sync/persistence.mjs.map +1 -1
  315. package/dist/esm/sync/persistence.native.js +954 -949
  316. package/dist/esm/sync/persistence.native.js.map +1 -1
  317. package/dist/esm/sync/realtime.mjs +296 -298
  318. package/dist/esm/sync/realtime.mjs.map +1 -1
  319. package/dist/esm/sync/realtime.native.js +453 -444
  320. package/dist/esm/sync/realtime.native.js.map +1 -1
  321. package/dist/esm/sync/rehydration.mjs +268 -304
  322. package/dist/esm/sync/rehydration.mjs.map +1 -1
  323. package/dist/esm/sync/rehydration.native.js +461 -498
  324. package/dist/esm/sync/rehydration.native.js.map +1 -1
  325. package/dist/esm/sync/storage.mjs +115 -113
  326. package/dist/esm/sync/storage.mjs.map +1 -1
  327. package/dist/esm/sync/storage.native.js +175 -168
  328. package/dist/esm/sync/storage.native.js.map +1 -1
  329. package/dist/esm/sync/subscriptionManager.mjs +675 -691
  330. package/dist/esm/sync/subscriptionManager.mjs.map +1 -1
  331. package/dist/esm/sync/subscriptionManager.native.js +1168 -1204
  332. package/dist/esm/sync/subscriptionManager.native.js.map +1 -1
  333. package/dist/esm/sync/types.mjs +56 -55
  334. package/dist/esm/sync/types.mjs.map +1 -1
  335. package/dist/esm/sync/types.native.js +66 -65
  336. package/dist/esm/sync/types.native.js.map +1 -1
  337. package/dist/esm/sync/virtualPageManager.mjs +749 -789
  338. package/dist/esm/sync/virtualPageManager.mjs.map +1 -1
  339. package/dist/esm/sync/virtualPageManager.native.js +1058 -1080
  340. package/dist/esm/sync/virtualPageManager.native.js.map +1 -1
  341. package/dist/esm/syncOptionsKey.mjs +25 -27
  342. package/dist/esm/syncOptionsKey.mjs.map +1 -1
  343. package/dist/esm/syncOptionsKey.native.js +38 -46
  344. package/dist/esm/syncOptionsKey.native.js.map +1 -1
  345. package/dist/esm/useLiveQuery.mjs +2 -2
  346. package/dist/esm/useLiveQuery.native.js +2 -2
  347. package/dist/esm/util.mjs +9 -7
  348. package/dist/esm/util.mjs.map +1 -1
  349. package/dist/esm/util.native.js +8 -11
  350. package/dist/esm/util.native.js.map +1 -1
  351. package/dist/jsx/auth.mjs +22 -27
  352. package/dist/jsx/auth.mjs.map +1 -1
  353. package/dist/jsx/auth.native.cjs +97 -0
  354. package/dist/jsx/auth.native.js +77 -82
  355. package/dist/jsx/auth.native.js.map +1 -1
  356. package/dist/jsx/call.mjs +19 -18
  357. package/dist/jsx/call.mjs.map +1 -1
  358. package/dist/jsx/call.native.cjs +92 -0
  359. package/dist/jsx/call.native.js +72 -71
  360. package/dist/jsx/call.native.js.map +1 -1
  361. package/dist/jsx/collection.mjs +228 -268
  362. package/dist/jsx/collection.mjs.map +1 -1
  363. package/dist/jsx/collection.native.cjs +461 -0
  364. package/dist/jsx/collection.native.js +436 -499
  365. package/dist/jsx/collection.native.js.map +1 -1
  366. package/dist/jsx/common/types.mjs +0 -2
  367. package/dist/jsx/common/types.native.cjs +18 -0
  368. package/dist/jsx/common/types.native.js +9 -10
  369. package/dist/jsx/common/types.native.js.map +1 -1
  370. package/dist/jsx/connectionKey.mjs +5 -4
  371. package/dist/jsx/connectionKey.mjs.map +1 -1
  372. package/dist/jsx/connectionKey.native.cjs +32 -0
  373. package/dist/jsx/connectionKey.native.js +19 -22
  374. package/dist/jsx/connectionKey.native.js.map +1 -1
  375. package/dist/jsx/core/http.mjs +383 -382
  376. package/dist/jsx/core/http.mjs.map +1 -1
  377. package/dist/jsx/core/http.native.cjs +659 -0
  378. package/dist/jsx/core/http.native.js +611 -615
  379. package/dist/jsx/core/http.native.js.map +1 -1
  380. package/dist/jsx/core/serverMessages.mjs +34 -26
  381. package/dist/jsx/core/serverMessages.mjs.map +1 -1
  382. package/dist/jsx/core/serverMessages.native.cjs +89 -0
  383. package/dist/jsx/core/serverMessages.native.js +69 -70
  384. package/dist/jsx/core/serverMessages.native.js.map +1 -1
  385. package/dist/jsx/core/sessionGate.mjs +79 -79
  386. package/dist/jsx/core/sessionGate.mjs.map +1 -1
  387. package/dist/jsx/core/sessionGate.native.cjs +270 -0
  388. package/dist/jsx/core/sessionGate.native.js +220 -232
  389. package/dist/jsx/core/sessionGate.native.js.map +1 -1
  390. package/dist/jsx/core/types.mjs +23 -22
  391. package/dist/jsx/core/types.mjs.map +1 -1
  392. package/dist/jsx/core/types.native.cjs +169 -0
  393. package/dist/jsx/core/types.native.js +129 -136
  394. package/dist/jsx/core/types.native.js.map +1 -1
  395. package/dist/jsx/core/wire.mjs +10 -9
  396. package/dist/jsx/core/wire.mjs.map +1 -1
  397. package/dist/jsx/core/wire.native.cjs +53 -0
  398. package/dist/jsx/core/wire.native.js +28 -29
  399. package/dist/jsx/core/wire.native.js.map +1 -1
  400. package/dist/jsx/db.mjs +421 -432
  401. package/dist/jsx/db.mjs.map +1 -1
  402. package/dist/jsx/db.native.cjs +625 -0
  403. package/dist/jsx/db.native.js +583 -590
  404. package/dist/jsx/db.native.js.map +1 -1
  405. package/dist/jsx/devtools/FrappeDevtoolsPanel.mjs +762 -781
  406. package/dist/jsx/devtools/FrappeDevtoolsPanel.mjs.map +1 -1
  407. package/dist/jsx/devtools/FrappeDevtoolsPanel.native.cjs +878 -0
  408. package/dist/jsx/devtools/FrappeDevtoolsPanel.native.js +821 -862
  409. package/dist/jsx/devtools/FrappeDevtoolsPanel.native.js.map +1 -1
  410. package/dist/jsx/devtools/index.mjs +2 -2
  411. package/dist/jsx/devtools/index.native.cjs +30 -0
  412. package/dist/jsx/devtools/index.native.js +15 -16
  413. package/dist/jsx/devtools/index.native.js.map +1 -1
  414. package/dist/jsx/devtools/plugin.mjs +10 -8
  415. package/dist/jsx/devtools/plugin.mjs.map +1 -1
  416. package/dist/jsx/devtools/plugin.native.cjs +46 -0
  417. package/dist/jsx/devtools/plugin.native.js +27 -35
  418. package/dist/jsx/devtools/plugin.native.js.map +1 -1
  419. package/dist/jsx/devtools/theme.mjs +27 -26
  420. package/dist/jsx/devtools/theme.mjs.map +1 -1
  421. package/dist/jsx/devtools/theme.native.cjs +53 -0
  422. package/dist/jsx/devtools/theme.native.js +40 -43
  423. package/dist/jsx/devtools/theme.native.js.map +1 -1
  424. package/dist/jsx/doctype.mjs +473 -416
  425. package/dist/jsx/doctype.mjs.map +1 -1
  426. package/dist/jsx/doctype.native.cjs +631 -0
  427. package/dist/jsx/doctype.native.js +587 -563
  428. package/dist/jsx/doctype.native.js.map +1 -1
  429. package/dist/jsx/file.mjs +15 -14
  430. package/dist/jsx/file.mjs.map +1 -1
  431. package/dist/jsx/file.native.cjs +78 -0
  432. package/dist/jsx/file.native.js +58 -62
  433. package/dist/jsx/file.native.js.map +1 -1
  434. package/dist/jsx/fixtureDb.mjs +175 -191
  435. package/dist/jsx/fixtureDb.mjs.map +1 -1
  436. package/dist/jsx/fixtureDb.native.cjs +313 -0
  437. package/dist/jsx/fixtureDb.native.js +291 -300
  438. package/dist/jsx/fixtureDb.native.js.map +1 -1
  439. package/dist/jsx/fixtures.mjs +161 -175
  440. package/dist/jsx/fixtures.mjs.map +1 -1
  441. package/dist/jsx/fixtures.native.cjs +379 -0
  442. package/dist/jsx/fixtures.native.js +359 -381
  443. package/dist/jsx/fixtures.native.js.map +1 -1
  444. package/dist/jsx/frappeApp.mjs +82 -83
  445. package/dist/jsx/frappeApp.mjs.map +1 -1
  446. package/dist/jsx/frappeApp.native.cjs +181 -0
  447. package/dist/jsx/frappeApp.native.js +153 -152
  448. package/dist/jsx/frappeApp.native.js.map +1 -1
  449. package/dist/jsx/frappeReact.mjs +535 -504
  450. package/dist/jsx/frappeReact.mjs.map +1 -1
  451. package/dist/jsx/frappeReact.native.cjs +710 -0
  452. package/dist/jsx/frappeReact.native.js +636 -631
  453. package/dist/jsx/frappeReact.native.js.map +1 -1
  454. package/dist/jsx/index.gnome.mjs +5 -5
  455. package/dist/jsx/index.gnome.native.cjs +87 -0
  456. package/dist/jsx/index.gnome.native.js +61 -62
  457. package/dist/jsx/index.gnome.native.js.map +1 -1
  458. package/dist/jsx/index.js +17 -18
  459. package/dist/jsx/index.mjs +17 -18
  460. package/dist/jsx/index.native.cjs +171 -0
  461. package/dist/jsx/index.native.js +128 -134
  462. package/dist/jsx/index.native.js.map +1 -1
  463. package/dist/jsx/optimistic.mjs +19 -19
  464. package/dist/jsx/optimistic.mjs.map +1 -1
  465. package/dist/jsx/optimistic.native.cjs +59 -0
  466. package/dist/jsx/optimistic.native.js +38 -41
  467. package/dist/jsx/optimistic.native.js.map +1 -1
  468. package/dist/jsx/pacer.mjs +156 -158
  469. package/dist/jsx/pacer.mjs.map +1 -1
  470. package/dist/jsx/pacer.native.cjs +263 -0
  471. package/dist/jsx/pacer.native.js +234 -245
  472. package/dist/jsx/pacer.native.js.map +1 -1
  473. package/dist/jsx/plugin/index.mjs +91 -94
  474. package/dist/jsx/plugin/index.mjs.map +1 -1
  475. package/dist/jsx/plugin/index.native.cjs +178 -0
  476. package/dist/jsx/plugin/index.native.js +164 -177
  477. package/dist/jsx/plugin/index.native.js.map +1 -1
  478. package/dist/jsx/realtime.mjs +569 -594
  479. package/dist/jsx/realtime.mjs.map +1 -1
  480. package/dist/jsx/realtime.native.cjs +945 -0
  481. package/dist/jsx/realtime.native.js +918 -928
  482. package/dist/jsx/realtime.native.js.map +1 -1
  483. package/dist/jsx/serverLoaders.mjs +47 -61
  484. package/dist/jsx/serverLoaders.mjs.map +1 -1
  485. package/dist/jsx/serverLoaders.native.cjs +103 -0
  486. package/dist/jsx/serverLoaders.native.js +73 -95
  487. package/dist/jsx/serverLoaders.native.js.map +1 -1
  488. package/dist/jsx/sync/backfill.mjs +268 -284
  489. package/dist/jsx/sync/backfill.mjs.map +1 -1
  490. package/dist/jsx/sync/backfill.native.cjs +475 -0
  491. package/dist/jsx/sync/backfill.native.js +449 -465
  492. package/dist/jsx/sync/backfill.native.js.map +1 -1
  493. package/dist/jsx/sync/filters.mjs +286 -241
  494. package/dist/jsx/sync/filters.mjs.map +1 -1
  495. package/dist/jsx/sync/filters.native.cjs +472 -0
  496. package/dist/jsx/sync/filters.native.js +426 -398
  497. package/dist/jsx/sync/filters.native.js.map +1 -1
  498. package/dist/jsx/sync/index.mjs +465 -479
  499. package/dist/jsx/sync/index.mjs.map +1 -1
  500. package/dist/jsx/sync/index.native.cjs +771 -0
  501. package/dist/jsx/sync/index.native.js +738 -737
  502. package/dist/jsx/sync/index.native.js.map +1 -1
  503. package/dist/jsx/sync/merge.mjs +368 -366
  504. package/dist/jsx/sync/merge.mjs.map +1 -1
  505. package/dist/jsx/sync/merge.native.cjs +681 -0
  506. package/dist/jsx/sync/merge.native.js +642 -673
  507. package/dist/jsx/sync/merge.native.js.map +1 -1
  508. package/dist/jsx/sync/mutationEngine.mjs +775 -814
  509. package/dist/jsx/sync/mutationEngine.mjs.map +1 -1
  510. package/dist/jsx/sync/mutationEngine.native.cjs +1190 -0
  511. package/dist/jsx/sync/mutationEngine.native.js +1162 -1216
  512. package/dist/jsx/sync/mutationEngine.native.js.map +1 -1
  513. package/dist/jsx/sync/mutationJournal.mjs +135 -133
  514. package/dist/jsx/sync/mutationJournal.mjs.map +1 -1
  515. package/dist/jsx/sync/mutationJournal.native.cjs +302 -0
  516. package/dist/jsx/sync/mutationJournal.native.js +278 -269
  517. package/dist/jsx/sync/mutationJournal.native.js.map +1 -1
  518. package/dist/jsx/sync/normalizedCache.mjs +115 -117
  519. package/dist/jsx/sync/normalizedCache.mjs.map +1 -1
  520. package/dist/jsx/sync/normalizedCache.native.cjs +232 -0
  521. package/dist/jsx/sync/normalizedCache.native.js +212 -212
  522. package/dist/jsx/sync/normalizedCache.native.js.map +1 -1
  523. package/dist/jsx/sync/persistence.mjs +637 -645
  524. package/dist/jsx/sync/persistence.mjs.map +1 -1
  525. package/dist/jsx/sync/persistence.native.cjs +996 -0
  526. package/dist/jsx/sync/persistence.native.js +967 -965
  527. package/dist/jsx/sync/persistence.native.js.map +1 -1
  528. package/dist/jsx/sync/realtime.mjs +296 -298
  529. package/dist/jsx/sync/realtime.mjs.map +1 -1
  530. package/dist/jsx/sync/realtime.native.cjs +486 -0
  531. package/dist/jsx/sync/realtime.native.js +465 -461
  532. package/dist/jsx/sync/realtime.native.js.map +1 -1
  533. package/dist/jsx/sync/rehydration.mjs +268 -304
  534. package/dist/jsx/sync/rehydration.mjs.map +1 -1
  535. package/dist/jsx/sync/rehydration.native.cjs +495 -0
  536. package/dist/jsx/sync/rehydration.native.js +473 -515
  537. package/dist/jsx/sync/rehydration.native.js.map +1 -1
  538. package/dist/jsx/sync/storage.mjs +115 -113
  539. package/dist/jsx/sync/storage.mjs.map +1 -1
  540. package/dist/jsx/sync/storage.native.cjs +211 -0
  541. package/dist/jsx/sync/storage.native.js +188 -184
  542. package/dist/jsx/sync/storage.native.js.map +1 -1
  543. package/dist/jsx/sync/subscriptionManager.mjs +675 -691
  544. package/dist/jsx/sync/subscriptionManager.mjs.map +1 -1
  545. package/dist/jsx/sync/subscriptionManager.native.cjs +1205 -0
  546. package/dist/jsx/sync/subscriptionManager.native.js +1179 -1220
  547. package/dist/jsx/sync/subscriptionManager.native.js.map +1 -1
  548. package/dist/jsx/sync/types.mjs +56 -55
  549. package/dist/jsx/sync/types.mjs.map +1 -1
  550. package/dist/jsx/sync/types.native.cjs +103 -0
  551. package/dist/jsx/sync/types.native.js +89 -90
  552. package/dist/jsx/sync/types.native.js.map +1 -1
  553. package/dist/jsx/sync/virtualPageManager.mjs +749 -789
  554. package/dist/jsx/sync/virtualPageManager.mjs.map +1 -1
  555. package/dist/jsx/sync/virtualPageManager.native.cjs +1097 -0
  556. package/dist/jsx/sync/virtualPageManager.native.js +1072 -1097
  557. package/dist/jsx/sync/virtualPageManager.native.js.map +1 -1
  558. package/dist/jsx/syncOptionsKey.mjs +25 -27
  559. package/dist/jsx/syncOptionsKey.mjs.map +1 -1
  560. package/dist/jsx/syncOptionsKey.native.cjs +69 -0
  561. package/dist/jsx/syncOptionsKey.native.js +51 -63
  562. package/dist/jsx/syncOptionsKey.native.js.map +1 -1
  563. package/dist/jsx/useLiveQuery.mjs +2 -2
  564. package/dist/jsx/useLiveQuery.native.cjs +26 -0
  565. package/dist/jsx/useLiveQuery.native.js +14 -17
  566. package/dist/jsx/useLiveQuery.native.js.map +1 -1
  567. package/dist/jsx/util.mjs +9 -7
  568. package/dist/jsx/util.mjs.map +1 -1
  569. package/dist/jsx/util.native.cjs +40 -0
  570. package/dist/jsx/util.native.js +22 -28
  571. package/dist/jsx/util.native.js.map +1 -1
  572. package/package.json +10 -10
  573. package/src/devtools/FrappeDevtoolsPanel.stories.tsx +16 -16
  574. package/src/devtools/plugin.stories.tsx +4 -4
  575. package/src/useFrappeCollection.stories.tsx +14 -14
  576. package/src/useFrappeInfiniteList.stories.tsx +11 -11
  577. package/src/useFrappePendingMutations.stories.tsx +12 -12
  578. package/types/devtools/FrappeDevtoolsPanel.d.ts +2 -1
  579. package/types/devtools/FrappeDevtoolsPanel.d.ts.map +1 -1
  580. package/types/devtools/plugin.d.ts +2 -1
  581. package/types/devtools/plugin.d.ts.map +1 -1
  582. package/dist/esm/common/types.mjs.map +0 -1
  583. package/dist/esm/common/types.native.js.map +0 -1
  584. package/dist/esm/devtools/index.mjs.map +0 -1
  585. package/dist/esm/devtools/index.native.js.map +0 -1
  586. package/dist/esm/index.gnome.mjs.map +0 -1
  587. package/dist/esm/index.gnome.native.js.map +0 -1
  588. package/dist/esm/index.mjs.map +0 -1
  589. package/dist/esm/index.native.js.map +0 -1
  590. package/dist/esm/useLiveQuery.mjs.map +0 -1
  591. package/dist/esm/useLiveQuery.native.js.map +0 -1
  592. package/dist/jsx/common/types.mjs.map +0 -1
  593. package/dist/jsx/devtools/index.mjs.map +0 -1
  594. package/dist/jsx/index.gnome.mjs.map +0 -1
  595. package/dist/jsx/index.js.map +0 -1
  596. package/dist/jsx/index.mjs.map +0 -1
  597. package/dist/jsx/useLiveQuery.mjs.map +0 -1
@@ -5,27 +5,23 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
12
  };
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
21
  };
22
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
- value: true
24
- }), mod);
22
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
23
  var sync_exports = {};
26
- __export(sync_exports, {
27
- SyncModule: () => SyncModule
28
- });
24
+ __export(sync_exports, { SyncModule: () => SyncModule });
29
25
  module.exports = __toCommonJS(sync_exports);
30
26
  var import_platform = require("@multiplatform.one/platform");
31
27
  var import_mutationEngine = require("./mutationEngine.native.js");
@@ -37,736 +33,741 @@ var import_rehydration = require("./rehydration.native.js");
37
33
  var import_subscriptionManager = require("./subscriptionManager.native.js");
38
34
  var import_types = require("./types.native.js");
39
35
  function _class_call_check(instance, Constructor) {
40
- if (!(instance instanceof Constructor)) {
41
- throw new TypeError("Cannot call a class as a function");
42
- }
36
+ if (!(instance instanceof Constructor)) {
37
+ throw new TypeError("Cannot call a class as a function");
38
+ }
43
39
  }
44
40
  function _defineProperties(target, props) {
45
- for (var i = 0; i < props.length; i++) {
46
- var descriptor = props[i];
47
- descriptor.enumerable = descriptor.enumerable || false;
48
- descriptor.configurable = true;
49
- if ("value" in descriptor) descriptor.writable = true;
50
- Object.defineProperty(target, descriptor.key, descriptor);
51
- }
41
+ for (var i = 0; i < props.length; i++) {
42
+ var descriptor = props[i];
43
+ descriptor.enumerable = descriptor.enumerable || false;
44
+ descriptor.configurable = true;
45
+ if ("value" in descriptor) descriptor.writable = true;
46
+ Object.defineProperty(target, descriptor.key, descriptor);
47
+ }
52
48
  }
53
49
  function _create_class(Constructor, protoProps, staticProps) {
54
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
55
- if (staticProps) _defineProperties(Constructor, staticProps);
56
- return Constructor;
50
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
51
+ if (staticProps) _defineProperties(Constructor, staticProps);
52
+ return Constructor;
57
53
  }
58
54
  function _define_property(obj, key, value) {
59
- if (key in obj) {
60
- Object.defineProperty(obj, key, {
61
- value,
62
- enumerable: true,
63
- configurable: true,
64
- writable: true
65
- });
66
- } else {
67
- obj[key] = value;
68
- }
69
- return obj;
55
+ if (key in obj) {
56
+ Object.defineProperty(obj, key, {
57
+ value,
58
+ enumerable: true,
59
+ configurable: true,
60
+ writable: true
61
+ });
62
+ } else {
63
+ obj[key] = value;
64
+ }
65
+ return obj;
70
66
  }
71
67
  function getBrowserJournalStorage() {
72
- if (typeof window === "undefined" || typeof document === "undefined") return void 0;
73
- try {
74
- var storage = window.localStorage;
75
- return typeof (storage === null || storage === void 0 ? void 0 : storage.getItem) === "function" && typeof storage.setItem === "function" ? storage : void 0;
76
- } catch (unused) {
77
- return void 0;
78
- }
68
+ if (typeof window === "undefined" || typeof document === "undefined") return void 0;
69
+ try {
70
+ var storage = window.localStorage;
71
+ return typeof (storage === null || storage === void 0 ? void 0 : storage.getItem) === "function" && typeof storage.setItem === "function" ? storage : void 0;
72
+ } catch (unused) {
73
+ return void 0;
74
+ }
79
75
  }
80
76
  var idleCatchUpState = Object.freeze({
81
- refreshing: false,
82
- stale: false,
83
- error: null
77
+ refreshing: false,
78
+ stale: false,
79
+ error: null
84
80
  });
85
- var SyncModule = /* @__PURE__ */function () {
86
- "use strict";
81
+ var SyncModule = /* @__PURE__ */ (function() {
82
+ "use strict";
83
+ function SyncModule2(db, realtime) {
84
+ var _this = this;
85
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
86
+ _class_call_check(this, SyncModule2);
87
+ _define_property(this, "normalizedCache", void 0);
88
+ _define_property(this, "mutationJournal", void 0);
89
+ _define_property(this, "storeListeners", /* @__PURE__ */ new Set());
90
+ _define_property(this, "realtimeEventListeners", /* @__PURE__ */ new Set());
91
+ _define_property(this, "subscriptionManager", void 0);
92
+ _define_property(this, "mutationEngine", void 0);
93
+ _define_property(this, "realtimeHandler", void 0);
94
+ _define_property(this, "persistenceManager", void 0);
95
+ _define_property(this, "rehydrationManager", void 0);
96
+ _define_property(this, "cleanupFocus", void 0);
97
+ _define_property(this, "cleanupFocusReplay", void 0);
98
+ _define_property(this, "cleanupOnlineBackfill", void 0);
99
+ _define_property(this, "cleanupOnlineReplay", void 0);
100
+ _define_property(this, "cdcIntervalHandle", void 0);
101
+ _define_property(this, "db", void 0);
102
+ _define_property(this, "realtime", void 0);
103
+ _define_property(this, "options", void 0);
104
+ _define_property(this, "catchUpState", idleCatchUpState);
105
+ _define_property(this, "catchUpEpoch", 0);
106
+ _define_property(this, "disposed", false);
107
+ _define_property(this, "catchUpRun", void 0);
108
+ this.db = db;
109
+ this.realtime = realtime;
110
+ this.options = options;
111
+ this.normalizedCache = new import_normalizedCache.NormalizedCache({ maxSize: this.options.maxCacheSize });
112
+ this.mutationJournal = new import_mutationJournal.MutationJournal({
113
+ ttl: this.options.mutationTTL,
114
+ enableAutoCleanup: true,
115
+ storage: getBrowserJournalStorage()
116
+ });
117
+ this.subscriptionManager = new import_subscriptionManager.SubscriptionManager(this.db, this.normalizedCache, this.options);
118
+ this.rehydrationManager = new import_rehydration.RehydrationManager(this.db, this.normalizedCache, this.subscriptionManager, this.mutationJournal, function() {
119
+ return _this.emit();
120
+ });
121
+ this.mutationEngine = new import_mutationEngine.MutationEngine(this.db, this.realtime, this.normalizedCache, this.mutationJournal, this.subscriptionManager, this.rehydrationManager, {
122
+ ...this.options,
123
+ onStoreChange: function onStoreChange() {
124
+ return _this.emit();
125
+ }
126
+ });
127
+ var realtimeOptions = {
128
+ ...this.options,
129
+ onResetCache: function onResetCache() {
130
+ return _this.resetCache();
131
+ },
132
+ onBackfillAll: function onBackfillAll() {
133
+ void _this.catchUp();
134
+ },
135
+ onStoreChange: function onStoreChange() {
136
+ return _this.emit();
137
+ },
138
+ onRealtimeEvent: function onRealtimeEvent(event) {
139
+ var _this_options_onRealtimeEvent, _this_options;
140
+ (_this_options_onRealtimeEvent = (_this_options = _this.options).onRealtimeEvent) === null || _this_options_onRealtimeEvent === void 0 ? void 0 : _this_options_onRealtimeEvent.call(_this_options, event);
141
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
142
+ try {
143
+ for (var _iterator = _this.realtimeEventListeners[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
144
+ var listener = _step.value;
145
+ listener(event);
146
+ }
147
+ } catch (err) {
148
+ _didIteratorError = true;
149
+ _iteratorError = err;
150
+ } finally {
151
+ try {
152
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
153
+ _iterator.return();
154
+ }
155
+ } finally {
156
+ if (_didIteratorError) {
157
+ throw _iteratorError;
158
+ }
159
+ }
160
+ }
161
+ }
162
+ };
163
+ this.realtimeHandler = new import_realtime.RealtimeHandler(this.db, this.realtime, this.normalizedCache, this.subscriptionManager, this.rehydrationManager, realtimeOptions);
164
+ this.persistenceManager = new import_persistence.PersistenceManager(this.normalizedCache, this.mutationJournal, this.subscriptionManager, this.mutationEngine, realtimeOptions);
165
+ this.setupWindowEvents();
166
+ }
167
+ _create_class(SyncModule2, [
168
+ {
169
+ key: "setupWindowEvents",
170
+ value: (
171
+ /**
172
+ * Sets up lifecycle event listeners for sync triggers.
173
+ * Stores cleanup functions returned by each subscription.
174
+ */
175
+ function setupWindowEvents() {
176
+ var _this = this;
177
+ this.cleanupFocus = (0, import_platform.onAppFocus)(function() {
178
+ void _this.catchUp();
179
+ });
180
+ this.cleanupFocusReplay = (0, import_platform.onAppFocus)(function() {
181
+ if (_this.mutationJournal.listPending().length > 0) void _this.replayPending();
182
+ });
183
+ this.cleanupOnlineBackfill = (0, import_platform.onOnline)(function() {
184
+ void _this.catchUp();
185
+ });
186
+ this.cleanupOnlineReplay = (0, import_platform.onOnline)(function() {
187
+ return _this.replayPending();
188
+ });
189
+ if (this.options.cdcInterval && this.options.cdcInterval > 0) {
190
+ this.cdcIntervalHandle = setInterval(function() {
191
+ void _this.catchUp();
192
+ }, this.options.cdcInterval);
193
+ }
194
+ })
195
+ },
196
+ {
197
+ key: "subscribe",
198
+ value: (
199
+ /**
200
+ * Creates a subscription, seeds cache with initial rows, and stores a backfill checkpoint.
201
+ *
202
+ * With persistence enabled, a query matching a subscription restored from
203
+ * the snapshot is re-adopted cache-first: the returned rows come from the
204
+ * restored cache and a background network refresh follows (`result.refresh`).
205
+ * If that refresh fails (offline), the cached membership keeps serving and
206
+ * the subscription is marked stale until the next successful backfill.
207
+ */
208
+ async function subscribe(query) {
209
+ var _this = this;
210
+ if (this.options.catchUpStrategy === "snapshot" && query.progressive) {
211
+ throw new Error("Snapshot catch-up does not support progressive subscriptions");
212
+ }
213
+ await this.persistenceManager.whenReady();
214
+ var result = await this.subscriptionManager.subscribe(query);
215
+ this.realtimeHandler.watchDoctype(query.doctype);
216
+ this.emit();
217
+ if (result.refresh) void result.refresh.then(function() {
218
+ return _this.emit();
219
+ });
220
+ return result;
221
+ })
222
+ },
223
+ {
224
+ /**
225
+ * Removes a subscription by id.
226
+ */
227
+ key: "unsubscribe",
228
+ value: function unsubscribe(subscriptionId) {
229
+ var subscription = this.subscriptionManager.getSubscription(subscriptionId);
230
+ this.subscriptionManager.unsubscribe(subscriptionId);
231
+ if (subscription) this.realtimeHandler.unwatchDoctype(subscription.query.doctype);
232
+ this.emit();
233
+ }
234
+ },
235
+ {
236
+ key: "mutate",
237
+ value: async function mutate(mutation) {
238
+ try {
239
+ await this.mutationEngine.mutate(mutation);
240
+ } catch (err) {
241
+ this.emit();
242
+ throw err;
243
+ }
244
+ this.persistenceManager.broadcastMutation(mutation);
245
+ this.emit();
246
+ }
247
+ },
248
+ {
249
+ /**
250
+ * The name the server assigned a document this module created under
251
+ * `temporaryName`, once the create is acknowledged. Undefined while it is
252
+ * pending, or when the server kept the name it was given.
253
+ */
254
+ key: "createdName",
255
+ value: function createdName(temporaryName) {
256
+ return this.rehydrationManager.resolveTempId(temporaryName);
257
+ }
258
+ },
259
+ {
260
+ key: "refreshSubscriptions",
261
+ value: (
262
+ /** Refresh active query snapshots in place. Failures retain the last committed data. */
263
+ async function refreshSubscriptions(options) {
264
+ var epoch = this.catchUpEpoch;
265
+ await this.persistenceManager.whenReady();
266
+ if (this.disposed || epoch !== this.catchUpEpoch) return [];
267
+ var results = await this.subscriptionManager.refreshSubscriptions(options);
268
+ if (!this.disposed && epoch === this.catchUpEpoch) this.emit();
269
+ return results;
270
+ })
271
+ },
272
+ {
273
+ key: "getCatchUpState",
274
+ value: function getCatchUpState() {
275
+ return this.catchUpState;
276
+ }
277
+ },
278
+ {
279
+ key: "publishCatchUp",
280
+ value: function publishCatchUp(state) {
281
+ this.catchUpState = Object.freeze(state);
282
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
283
+ try {
284
+ for (var _iterator = this.storeListeners[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
285
+ var listener = _step.value;
286
+ listener();
287
+ }
288
+ } catch (err) {
289
+ _didIteratorError = true;
290
+ _iteratorError = err;
291
+ } finally {
292
+ try {
293
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
294
+ _iterator.return();
295
+ }
296
+ } finally {
297
+ if (_didIteratorError) {
298
+ throw _iteratorError;
299
+ }
300
+ }
301
+ }
302
+ }
303
+ },
304
+ {
305
+ /** Observes lifecycle/retry failures in state; explicit backfill still rejects. */
306
+ key: "catchUp",
307
+ value: function catchUp() {
308
+ var _this = this;
309
+ if (this.disposed) return Promise.resolve(this.catchUpState);
310
+ if (this.catchUpRun) {
311
+ if (this.catchUpRun.attempt === 0) this.catchUpRun.trailing = true;
312
+ return this.catchUpRun.promise;
313
+ }
314
+ var epoch = this.catchUpEpoch;
315
+ var run = {
316
+ trailing: false,
317
+ attempt: 0,
318
+ promise: Promise.resolve(this.catchUpState)
319
+ };
320
+ this.catchUpRun = run;
321
+ run.promise = Promise.resolve().then(async function() {
322
+ var error = null;
323
+ var active = function active2() {
324
+ return !_this.disposed && _this.catchUpEpoch === epoch;
325
+ };
326
+ do {
327
+ if (!active()) return _this.catchUpState;
328
+ run.trailing = false;
329
+ error = null;
330
+ try {
331
+ if (_this.options.catchUpStrategy === "snapshot") {
332
+ var results = await _this.refreshSubscriptions();
333
+ var failures = results.filter(function(result) {
334
+ return !result.ok && _this.subscriptionManager.getSubscription(result.subscriptionId) && !_this.subscriptionManager.isRestoredSubscription(result.subscriptionId);
335
+ });
336
+ if (failures.length) error = new AggregateError(failures.map(function(failure) {
337
+ return failure.error;
338
+ }), "Some subscriptions could not refresh. Showing previous data.");
339
+ } else {
340
+ await _this.backfill({ scope: import_types.BackfillScope.All });
341
+ }
342
+ } catch (caught) {
343
+ error = caught;
344
+ }
345
+ } while (active() && run.trailing && run.attempt++ === 0);
346
+ if (active()) {
347
+ _this.catchUpRun = void 0;
348
+ _this.publishCatchUp({
349
+ refreshing: false,
350
+ stale: error !== null,
351
+ error
352
+ });
353
+ }
354
+ return _this.catchUpState;
355
+ });
356
+ this.publishCatchUp({
357
+ ...this.catchUpState,
358
+ refreshing: true
359
+ });
360
+ return run.promise;
361
+ }
362
+ },
363
+ {
364
+ key: "backfill",
365
+ value: (
366
+ /**
367
+ * Reconciles local state by fetching changes since stored cursors.
368
+ */
369
+ async function backfill(args) {
370
+ var epoch = this.catchUpEpoch;
371
+ await this.subscriptionManager.backfill(args);
372
+ if (!this.disposed && epoch === this.catchUpEpoch) this.emit();
373
+ })
374
+ },
375
+ {
376
+ key: "replayPending",
377
+ value: (
378
+ /**
379
+ * Replays pending mutations with error handling.
380
+ */
381
+ async function replayPending() {
382
+ await this.mutationEngine.replayPending();
383
+ this.emit();
384
+ })
385
+ },
386
+ {
387
+ /**
388
+ * Public read of the mutation ledger: journal entries still awaiting the
389
+ * server (`Status.Pending`) or rejected by it (`Status.Failed`), ordered
390
+ * by submission sequence. Confirmed entries are dropped from the journal
391
+ * and never appear here. Read inside a `subscribeStore` callback for a
392
+ * reactive pending/error surface (see `useFrappePendingMutations`).
393
+ */
394
+ key: "getMutationEntries",
395
+ value: function getMutationEntries(doctype) {
396
+ var entries = [];
397
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
398
+ try {
399
+ for (var _iterator = this.mutationJournal.listPending()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
400
+ var { id, entry } = _step.value;
401
+ var _entry_createdAt, _entry_retryCount, _entry_error_message;
402
+ if (doctype && entry.doctype !== doctype) continue;
403
+ entries.push({
404
+ id,
405
+ operation: entry.operation,
406
+ doctype: entry.doctype,
407
+ docname: entry.docname,
408
+ status: entry.status,
409
+ createdAt: (_entry_createdAt = entry.createdAt) !== null && _entry_createdAt !== void 0 ? _entry_createdAt : 0,
410
+ retryCount: (_entry_retryCount = entry.retryCount) !== null && _entry_retryCount !== void 0 ? _entry_retryCount : 0,
411
+ error: entry.error ? (_entry_error_message = entry.error.message) !== null && _entry_error_message !== void 0 ? _entry_error_message : String(entry.error) : void 0
412
+ });
413
+ }
414
+ } catch (err) {
415
+ _didIteratorError = true;
416
+ _iteratorError = err;
417
+ } finally {
418
+ try {
419
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
420
+ _iterator.return();
421
+ }
422
+ } finally {
423
+ if (_didIteratorError) {
424
+ throw _iteratorError;
425
+ }
426
+ }
427
+ }
428
+ return entries;
429
+ }
430
+ },
431
+ {
432
+ /**
433
+ * Drops a failed (or still-pending) ledger entry without retrying it —
434
+ * the "dismiss" half of the rejected-write contract. The optimistic
435
+ * rollback already ran when the mutation failed; this only clears the
436
+ * error affordance.
437
+ */
438
+ key: "dismissMutation",
439
+ value: function dismissMutation(id) {
440
+ this.mutationJournal.remove(id);
441
+ this.emit();
442
+ }
443
+ },
444
+ {
445
+ /** Reads a single document from the local cache. */
446
+ key: "getDocFromCache",
447
+ value: function getDocFromCache(doctype, name) {
448
+ return this.normalizedCache.get({
449
+ doctype,
450
+ name
451
+ });
452
+ }
453
+ },
454
+ {
455
+ /** Returns subscription metadata by id. */
456
+ key: "getSubscription",
457
+ value: function getSubscription(id) {
458
+ return this.subscriptionManager.getSubscription(id);
459
+ }
460
+ },
461
+ {
462
+ /**
463
+ * Returns current rows for a subscription from the cache.
464
+ */
465
+ key: "getDocsForSubscription",
466
+ value: function getDocsForSubscription(id) {
467
+ return this.subscriptionManager.getDocsForSubscription(id);
468
+ }
469
+ },
470
+ {
471
+ key: "getPage",
472
+ value: (
473
+ /**
474
+ * Get a specific page of documents using virtual pagination.
475
+ * Requires the subscription to have been created with `progressive: true`.
476
+ */
477
+ async function getPage(subscriptionId, page) {
478
+ var result = await this.subscriptionManager.getPage(subscriptionId, page);
479
+ this.emit();
480
+ return result;
481
+ })
482
+ },
483
+ {
484
+ key: "getNextBatch",
485
+ value: (
486
+ /**
487
+ * Get the next batch of documents after a cursor for infinite scroll.
488
+ * Requires the subscription to have been created with `progressive: true`.
489
+ */
490
+ async function getNextBatch(subscriptionId, cursorDocId, limit) {
491
+ var result = await this.subscriptionManager.getNextBatch(subscriptionId, cursorDocId, limit);
492
+ this.emit();
493
+ return result;
494
+ })
495
+ },
496
+ {
497
+ /**
498
+ * Get page information for a subscription.
499
+ */
500
+ key: "getPageInfo",
501
+ value: function getPageInfo(subscriptionId) {
502
+ return this.subscriptionManager.getPageInfo(subscriptionId);
503
+ }
504
+ },
505
+ {
506
+ key: "refetchDocs",
507
+ value: (
508
+ /** Refetches authoritative copies for specific documents and updates cache. */
509
+ async function refetchDocs(docs) {
510
+ await this.subscriptionManager.backfill({
511
+ scope: import_types.BackfillScope.Docs,
512
+ docs
513
+ });
514
+ this.emit();
515
+ })
516
+ },
517
+ {
518
+ /** Adds a store listener; returns an unsubscribe function. */
519
+ key: "subscribeStore",
520
+ value: function subscribeStore(listener) {
521
+ var _this = this;
522
+ this.storeListeners.add(listener);
523
+ return function() {
524
+ _this.storeListeners.delete(listener);
525
+ };
526
+ }
527
+ },
528
+ {
529
+ /**
530
+ * Registers a listener for raw realtime events (doc_update, list_update,
531
+ * doc_deleted, connected, …). Useful for consumers that manage their own
532
+ * fetching (e.g. server-side paginated tables) but still want live
533
+ * invalidation hints. Returns an unsubscribe function.
534
+ */
535
+ key: "subscribeRealtimeEvents",
536
+ value: function subscribeRealtimeEvents(listener) {
537
+ var _this = this;
538
+ this.realtimeEventListeners.add(listener);
539
+ return function() {
540
+ _this.realtimeEventListeners.delete(listener);
541
+ };
542
+ }
543
+ },
544
+ {
545
+ /**
546
+ * Joins the realtime doctype room without creating a data subscription
547
+ * (refcounted). Pair with `unwatchDoctype` on cleanup. Used by consumers
548
+ * that fetch their own data but need the doctype's realtime hints.
549
+ */
550
+ key: "watchDoctype",
551
+ value: function watchDoctype(doctype) {
552
+ this.realtimeHandler.watchDoctype(doctype);
553
+ }
554
+ },
555
+ {
556
+ /** Releases one `watchDoctype` reference. */
557
+ key: "unwatchDoctype",
558
+ value: function unwatchDoctype(doctype) {
559
+ this.realtimeHandler.unwatchDoctype(doctype);
560
+ }
561
+ },
562
+ {
563
+ /**
564
+ * Live socket connection snapshot. `connected` is the state right now;
565
+ * `everConnected` distinguishes "reconnecting" from "realtime never up"
566
+ * (fixture mode, SSR, or no realtime module). Store listeners are
567
+ * notified on every flip, so read this inside a `subscribeStore` callback
568
+ * for a reactive indicator.
569
+ */
570
+ key: "getConnectionState",
571
+ value: function getConnectionState() {
572
+ return this.realtimeHandler.getConnectionState();
573
+ }
574
+ },
575
+ {
576
+ key: "emit",
577
+ value: (
578
+ /** Notifies listeners, schedules persistence, and broadcasts cross-tab changes. */
579
+ function emit() {
580
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
581
+ try {
582
+ for (var _iterator = this.storeListeners[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
583
+ var listener = _step.value;
584
+ listener();
585
+ }
586
+ } catch (err) {
587
+ _didIteratorError = true;
588
+ _iteratorError = err;
589
+ } finally {
590
+ try {
591
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
592
+ _iterator.return();
593
+ }
594
+ } finally {
595
+ if (_didIteratorError) {
596
+ throw _iteratorError;
597
+ }
598
+ }
599
+ }
600
+ this.persistenceManager.scheduleSave();
601
+ this.persistenceManager.broadcastChange();
602
+ })
603
+ },
604
+ {
605
+ /** Clears subscriptions, cache, journal, and temp id mappings. */
606
+ key: "resetCache",
607
+ value: function resetCache() {
608
+ this.catchUpEpoch++;
609
+ this.catchUpRun = void 0;
610
+ this.catchUpState = idleCatchUpState;
611
+ this.realtimeHandler.unwatchAll();
612
+ this.subscriptionManager.clear();
613
+ this.normalizedCache.clear();
614
+ this.mutationJournal.clear();
615
+ this.mutationEngine.clearTemporaryMappings();
616
+ this.emit();
617
+ }
618
+ },
619
+ {
620
+ key: "dispose",
621
+ value: (
622
+ /** Cleanup and dispose of resources */
623
+ async function dispose() {
624
+ var _this_cleanupFocus, _this, _this_cleanupFocusReplay, _this1, _this_cleanupOnlineBackfill, _this2, _this_cleanupOnlineReplay, _this3;
625
+ this.disposed = true;
626
+ this.storeListeners.clear();
627
+ this.realtimeEventListeners.clear();
628
+ this.resetCache();
629
+ this.mutationJournal.dispose();
630
+ this.mutationEngine.dispose();
631
+ this.realtimeHandler.dispose();
632
+ this.persistenceManager.destroy();
633
+ this.rehydrationManager.clear();
634
+ (_this_cleanupFocus = (_this = this).cleanupFocus) === null || _this_cleanupFocus === void 0 ? void 0 : _this_cleanupFocus.call(_this);
635
+ (_this_cleanupFocusReplay = (_this1 = this).cleanupFocusReplay) === null || _this_cleanupFocusReplay === void 0 ? void 0 : _this_cleanupFocusReplay.call(_this1);
636
+ (_this_cleanupOnlineBackfill = (_this2 = this).cleanupOnlineBackfill) === null || _this_cleanupOnlineBackfill === void 0 ? void 0 : _this_cleanupOnlineBackfill.call(_this2);
637
+ (_this_cleanupOnlineReplay = (_this3 = this).cleanupOnlineReplay) === null || _this_cleanupOnlineReplay === void 0 ? void 0 : _this_cleanupOnlineReplay.call(_this3);
638
+ this.cleanupFocus = void 0;
639
+ this.cleanupFocusReplay = void 0;
640
+ this.cleanupOnlineBackfill = void 0;
641
+ this.cleanupOnlineReplay = void 0;
642
+ if (this.cdcIntervalHandle) {
643
+ clearInterval(this.cdcIntervalHandle);
644
+ this.cdcIntervalHandle = void 0;
645
+ }
646
+ })
647
+ },
648
+ {
649
+ /**
650
+ * Returns a snapshot of internal state for devtools inspection.
651
+ * Prefixed with __ to signal internal/debug use only.
652
+ */
653
+ key: "__debug",
654
+ value: function __debug() {
655
+ var allSubs = this.subscriptionManager.getAllSubscriptions();
656
+ var vpm = this.subscriptionManager.getVirtualPageManager();
657
+ var subscriptions = [];
658
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
659
+ try {
660
+ for (var _iterator = allSubs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
661
+ var [, sub] = _step.value;
662
+ var _ref;
663
+ var _sub_tombstones;
664
+ var virtualSub = vpm.getSubscription(sub.id);
665
+ var pageInfo = vpm.getPageInfo(sub.id);
666
+ var islands = vpm.getPageIslands(sub.id);
667
+ var debugSub = {
668
+ id: sub.id,
669
+ query: sub.query,
670
+ docCount: sub.docIds.length,
671
+ tombstoneCount: (_ref = (_sub_tombstones = sub.tombstones) === null || _sub_tombstones === void 0 ? void 0 : _sub_tombstones.size) !== null && _ref !== void 0 ? _ref : 0,
672
+ checkpoint: sub.checkpoint,
673
+ cursor: sub.cursor,
674
+ stale: sub.stale,
675
+ restored: this.subscriptionManager.isRestoredSubscription(sub.id),
676
+ pageInfo
677
+ };
678
+ if (virtualSub) {
679
+ var _pc_lastFetchedAt;
680
+ var pc = virtualSub.getProgressiveCache();
681
+ debugSub.progressiveCache = {
682
+ docIds: pc.docIds,
683
+ nextCursor: pc.nextCursor,
684
+ hasMore: pc.hasMore,
685
+ totalCount: pc.totalCount,
686
+ lastFetchedAt: (_pc_lastFetchedAt = pc.lastFetchedAt) === null || _pc_lastFetchedAt === void 0 ? void 0 : _pc_lastFetchedAt.toISOString(),
687
+ islands
688
+ };
689
+ }
690
+ subscriptions.push(debugSub);
691
+ }
692
+ } catch (err) {
693
+ _didIteratorError = true;
694
+ _iteratorError = err;
695
+ } finally {
696
+ try {
697
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
698
+ _iterator.return();
699
+ }
700
+ } finally {
701
+ if (_didIteratorError) {
702
+ throw _iteratorError;
703
+ }
704
+ }
705
+ }
706
+ var cacheStats = this.normalizedCache.getStats();
707
+ var allEntries = this.mutationJournal.getAllEntries();
708
+ var pending = [];
709
+ var confirmed = [];
710
+ var failed = [];
711
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
712
+ try {
713
+ for (var _iterator1 = allEntries[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
714
+ var { id, entry } = _step1.value;
715
+ var _entry_createdAt, _entry_retryCount, _entry_error_message;
716
+ var debugEntry = {
717
+ id,
718
+ operation: entry.operation,
719
+ doctype: entry.doctype,
720
+ docname: entry.docname,
721
+ status: entry.status,
722
+ createdAt: (_entry_createdAt = entry.createdAt) !== null && _entry_createdAt !== void 0 ? _entry_createdAt : 0,
723
+ retryCount: (_entry_retryCount = entry.retryCount) !== null && _entry_retryCount !== void 0 ? _entry_retryCount : 0,
724
+ error: entry.error ? (_entry_error_message = entry.error.message) !== null && _entry_error_message !== void 0 ? _entry_error_message : String(entry.error) : void 0
725
+ };
726
+ if (entry.status === import_types.Status.Pending) pending.push(debugEntry);
727
+ else if (entry.status === import_types.Status.Confirmed) confirmed.push(debugEntry);
728
+ else if (entry.status === import_types.Status.Failed) failed.push(debugEntry);
729
+ }
730
+ } catch (err) {
731
+ _didIteratorError1 = true;
732
+ _iteratorError1 = err;
733
+ } finally {
734
+ try {
735
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
736
+ _iterator1.return();
737
+ }
738
+ } finally {
739
+ if (_didIteratorError1) {
740
+ throw _iteratorError1;
741
+ }
742
+ }
743
+ }
744
+ return {
745
+ subscriptions,
746
+ normalizedCache: cacheStats,
747
+ mutationJournal: {
748
+ pending,
749
+ confirmed,
750
+ failed
751
+ },
752
+ connection: {
753
+ socketConnected: this.realtimeHandler.getIsConnected(),
754
+ isLeader: this.persistenceManager.getIsLeader(),
755
+ isOnline: typeof navigator === "undefined" || navigator.onLine !== false
756
+ }
757
+ };
758
+ }
759
+ },
760
+ {
761
+ /**
762
+ * Checks if this tab is the leader for multi-tab coordination.
763
+ */
764
+ key: "isLeader",
765
+ value: function isLeader() {
766
+ return this.persistenceManager.getIsLeader();
767
+ }
768
+ }
769
+ ]);
770
+ return SyncModule2;
771
+ })();
87
772
 
88
- function SyncModule2(db, realtime) {
89
- var _this = this;
90
- var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
91
- _class_call_check(this, SyncModule2);
92
- _define_property(this, "normalizedCache", void 0);
93
- _define_property(this, "mutationJournal", void 0);
94
- _define_property(this, "storeListeners", /* @__PURE__ */new Set());
95
- _define_property(this, "realtimeEventListeners", /* @__PURE__ */new Set());
96
- _define_property(this, "subscriptionManager", void 0);
97
- _define_property(this, "mutationEngine", void 0);
98
- _define_property(this, "realtimeHandler", void 0);
99
- _define_property(this, "persistenceManager", void 0);
100
- _define_property(this, "rehydrationManager", void 0);
101
- _define_property(this, "cleanupFocus", void 0);
102
- _define_property(this, "cleanupFocusReplay", void 0);
103
- _define_property(this, "cleanupOnlineBackfill", void 0);
104
- _define_property(this, "cleanupOnlineReplay", void 0);
105
- _define_property(this, "cdcIntervalHandle", void 0);
106
- _define_property(this, "db", void 0);
107
- _define_property(this, "realtime", void 0);
108
- _define_property(this, "options", void 0);
109
- _define_property(this, "catchUpState", idleCatchUpState);
110
- _define_property(this, "catchUpEpoch", 0);
111
- _define_property(this, "disposed", false);
112
- _define_property(this, "catchUpRun", void 0);
113
- this.db = db;
114
- this.realtime = realtime;
115
- this.options = options;
116
- this.normalizedCache = new import_normalizedCache.NormalizedCache({
117
- maxSize: this.options.maxCacheSize
118
- });
119
- this.mutationJournal = new import_mutationJournal.MutationJournal({
120
- ttl: this.options.mutationTTL,
121
- enableAutoCleanup: true,
122
- storage: getBrowserJournalStorage()
123
- });
124
- this.subscriptionManager = new import_subscriptionManager.SubscriptionManager(this.db, this.normalizedCache, this.options);
125
- this.rehydrationManager = new import_rehydration.RehydrationManager(this.db, this.normalizedCache, this.subscriptionManager, this.mutationJournal, function () {
126
- return _this.emit();
127
- });
128
- this.mutationEngine = new import_mutationEngine.MutationEngine(this.db, this.realtime, this.normalizedCache, this.mutationJournal, this.subscriptionManager, this.rehydrationManager, {
129
- ...this.options,
130
- // Bridge engine-internal optimistic applies to store listeners so
131
- // pending state paints BEFORE the server round trip. Without this,
132
- // subscribeStore consumers only re-read after the ack (mutate()'s
133
- // trailing emit) and the in-memory optimism was invisible to them.
134
- onStoreChange: function onStoreChange() {
135
- return _this.emit();
136
- }
137
- });
138
- var realtimeOptions = {
139
- ...this.options,
140
- onResetCache: function onResetCache() {
141
- return _this.resetCache();
142
- },
143
- onBackfillAll: function onBackfillAll() {
144
- void _this.catchUp();
145
- },
146
- // Realtime reconciliation mutates cache/membership outside the public
147
- // mutate/backfill entry points — bridge those changes to store listeners.
148
- onStoreChange: function onStoreChange() {
149
- return _this.emit();
150
- },
151
- onRealtimeEvent: function onRealtimeEvent(event) {
152
- var _this_options_onRealtimeEvent, _this_options;
153
- (_this_options_onRealtimeEvent = (_this_options = _this.options).onRealtimeEvent) === null || _this_options_onRealtimeEvent === void 0 ? void 0 : _this_options_onRealtimeEvent.call(_this_options, event);
154
- var _iteratorNormalCompletion = true,
155
- _didIteratorError = false,
156
- _iteratorError = void 0;
157
- try {
158
- for (var _iterator = _this.realtimeEventListeners[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
159
- var listener = _step.value;
160
- listener(event);
161
- }
162
- } catch (err) {
163
- _didIteratorError = true;
164
- _iteratorError = err;
165
- } finally {
166
- try {
167
- if (!_iteratorNormalCompletion && _iterator.return != null) {
168
- _iterator.return();
169
- }
170
- } finally {
171
- if (_didIteratorError) {
172
- throw _iteratorError;
173
- }
174
- }
175
- }
176
- }
177
- };
178
- this.realtimeHandler = new import_realtime.RealtimeHandler(this.db, this.realtime, this.normalizedCache, this.subscriptionManager, this.rehydrationManager, realtimeOptions);
179
- this.persistenceManager = new import_persistence.PersistenceManager(this.normalizedCache, this.mutationJournal, this.subscriptionManager, this.mutationEngine, realtimeOptions);
180
- this.setupWindowEvents();
181
- }
182
- _create_class(SyncModule2, [{
183
- key: "setupWindowEvents",
184
- value: (
185
- /**
186
- * Sets up lifecycle event listeners for sync triggers.
187
- * Stores cleanup functions returned by each subscription.
188
- */
189
- function setupWindowEvents() {
190
- var _this = this;
191
- this.cleanupFocus = (0, import_platform.onAppFocus)(function () {
192
- void _this.catchUp();
193
- });
194
- this.cleanupFocusReplay = (0, import_platform.onAppFocus)(function () {
195
- if (_this.mutationJournal.listPending().length > 0) void _this.replayPending();
196
- });
197
- this.cleanupOnlineBackfill = (0, import_platform.onOnline)(function () {
198
- void _this.catchUp();
199
- });
200
- this.cleanupOnlineReplay = (0, import_platform.onOnline)(function () {
201
- return _this.replayPending();
202
- });
203
- if (this.options.cdcInterval && this.options.cdcInterval > 0) {
204
- this.cdcIntervalHandle = setInterval(function () {
205
- void _this.catchUp();
206
- }, this.options.cdcInterval);
207
- }
208
- })
209
- }, {
210
- key: "subscribe",
211
- value: (
212
- /**
213
- * Creates a subscription, seeds cache with initial rows, and stores a backfill checkpoint.
214
- *
215
- * With persistence enabled, a query matching a subscription restored from
216
- * the snapshot is re-adopted cache-first: the returned rows come from the
217
- * restored cache and a background network refresh follows (`result.refresh`).
218
- * If that refresh fails (offline), the cached membership keeps serving and
219
- * the subscription is marked stale until the next successful backfill.
220
- */
221
- async function subscribe(query) {
222
- var _this = this;
223
- if (this.options.catchUpStrategy === "snapshot" && query.progressive) {
224
- throw new Error("Snapshot catch-up does not support progressive subscriptions");
225
- }
226
- await this.persistenceManager.whenReady();
227
- var result = await this.subscriptionManager.subscribe(query);
228
- this.realtimeHandler.watchDoctype(query.doctype);
229
- this.emit();
230
- if (result.refresh) void result.refresh.then(function () {
231
- return _this.emit();
232
- });
233
- return result;
234
- })
235
- }, {
236
- /**
237
- * Removes a subscription by id.
238
- */
239
- key: "unsubscribe",
240
- value: function unsubscribe(subscriptionId) {
241
- var subscription = this.subscriptionManager.getSubscription(subscriptionId);
242
- this.subscriptionManager.unsubscribe(subscriptionId);
243
- if (subscription) this.realtimeHandler.unwatchDoctype(subscription.query.doctype);
244
- this.emit();
245
- }
246
- }, {
247
- key: "mutate",
248
- value: async function mutate(mutation) {
249
- try {
250
- await this.mutationEngine.mutate(mutation);
251
- } catch (err) {
252
- this.emit();
253
- throw err;
254
- }
255
- this.persistenceManager.broadcastMutation(mutation);
256
- this.emit();
257
- }
258
- }, {
259
- /**
260
- * The name the server assigned a document this module created under
261
- * `temporaryName`, once the create is acknowledged. Undefined while it is
262
- * pending, or when the server kept the name it was given.
263
- */
264
- key: "createdName",
265
- value: function createdName(temporaryName) {
266
- return this.rehydrationManager.resolveTempId(temporaryName);
267
- }
268
- }, {
269
- key: "refreshSubscriptions",
270
- value: (/** Refresh active query snapshots in place. Failures retain the last committed data. */
271
- async function refreshSubscriptions(options) {
272
- var epoch = this.catchUpEpoch;
273
- await this.persistenceManager.whenReady();
274
- if (this.disposed || epoch !== this.catchUpEpoch) return [];
275
- var results = await this.subscriptionManager.refreshSubscriptions(options);
276
- if (!this.disposed && epoch === this.catchUpEpoch) this.emit();
277
- return results;
278
- })
279
- }, {
280
- key: "getCatchUpState",
281
- value: function getCatchUpState() {
282
- return this.catchUpState;
283
- }
284
- }, {
285
- key: "publishCatchUp",
286
- value: function publishCatchUp(state) {
287
- this.catchUpState = Object.freeze(state);
288
- var _iteratorNormalCompletion = true,
289
- _didIteratorError = false,
290
- _iteratorError = void 0;
291
- try {
292
- for (var _iterator = this.storeListeners[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
293
- var listener = _step.value;
294
- listener();
295
- }
296
- } catch (err) {
297
- _didIteratorError = true;
298
- _iteratorError = err;
299
- } finally {
300
- try {
301
- if (!_iteratorNormalCompletion && _iterator.return != null) {
302
- _iterator.return();
303
- }
304
- } finally {
305
- if (_didIteratorError) {
306
- throw _iteratorError;
307
- }
308
- }
309
- }
310
- }
311
- }, {
312
- /** Observes lifecycle/retry failures in state; explicit backfill still rejects. */
313
- key: "catchUp",
314
- value: function catchUp() {
315
- var _this = this;
316
- if (this.disposed) return Promise.resolve(this.catchUpState);
317
- if (this.catchUpRun) {
318
- if (this.catchUpRun.attempt === 0) this.catchUpRun.trailing = true;
319
- return this.catchUpRun.promise;
320
- }
321
- var epoch = this.catchUpEpoch;
322
- var run = {
323
- trailing: false,
324
- attempt: 0,
325
- promise: Promise.resolve(this.catchUpState)
326
- };
327
- this.catchUpRun = run;
328
- run.promise = Promise.resolve().then(async function () {
329
- var error = null;
330
- var active = function active2() {
331
- return !_this.disposed && _this.catchUpEpoch === epoch;
332
- };
333
- do {
334
- if (!active()) return _this.catchUpState;
335
- run.trailing = false;
336
- error = null;
337
- try {
338
- if (_this.options.catchUpStrategy === "snapshot") {
339
- var results = await _this.refreshSubscriptions();
340
- var failures = results.filter(function (result) {
341
- return !result.ok && _this.subscriptionManager.getSubscription(result.subscriptionId) && !_this.subscriptionManager.isRestoredSubscription(result.subscriptionId);
342
- });
343
- if (failures.length) error = new AggregateError(failures.map(function (failure) {
344
- return failure.error;
345
- }), "Some subscriptions could not refresh. Showing previous data.");
346
- } else {
347
- await _this.backfill({
348
- scope: import_types.BackfillScope.All
349
- });
350
- }
351
- } catch (caught) {
352
- error = caught;
353
- }
354
- } while (
355
- // Bound a burst to one trailing read, including triggers during that read.
356
- active() && run.trailing && run.attempt++ === 0);
357
- if (active()) {
358
- _this.catchUpRun = void 0;
359
- _this.publishCatchUp({
360
- refreshing: false,
361
- stale: error !== null,
362
- error
363
- });
364
- }
365
- return _this.catchUpState;
366
- });
367
- this.publishCatchUp({
368
- ...this.catchUpState,
369
- refreshing: true
370
- });
371
- return run.promise;
372
- }
373
- }, {
374
- key: "backfill",
375
- value: (
376
- /**
377
- * Reconciles local state by fetching changes since stored cursors.
378
- */
379
- async function backfill(args) {
380
- var epoch = this.catchUpEpoch;
381
- await this.subscriptionManager.backfill(args);
382
- if (!this.disposed && epoch === this.catchUpEpoch) this.emit();
383
- })
384
- }, {
385
- key: "replayPending",
386
- value: (
387
- /**
388
- * Replays pending mutations with error handling.
389
- */
390
- async function replayPending() {
391
- await this.mutationEngine.replayPending();
392
- this.emit();
393
- })
394
- }, {
395
- /**
396
- * Public read of the mutation ledger: journal entries still awaiting the
397
- * server (`Status.Pending`) or rejected by it (`Status.Failed`), ordered
398
- * by submission sequence. Confirmed entries are dropped from the journal
399
- * and never appear here. Read inside a `subscribeStore` callback for a
400
- * reactive pending/error surface (see `useFrappePendingMutations`).
401
- */
402
- key: "getMutationEntries",
403
- value: function getMutationEntries(doctype) {
404
- var entries = [];
405
- var _iteratorNormalCompletion = true,
406
- _didIteratorError = false,
407
- _iteratorError = void 0;
408
- try {
409
- for (var _iterator = this.mutationJournal.listPending()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
410
- var {
411
- id,
412
- entry
413
- } = _step.value;
414
- var _entry_createdAt, _entry_retryCount, _entry_error_message;
415
- if (doctype && entry.doctype !== doctype) continue;
416
- entries.push({
417
- id,
418
- operation: entry.operation,
419
- doctype: entry.doctype,
420
- docname: entry.docname,
421
- status: entry.status,
422
- createdAt: (_entry_createdAt = entry.createdAt) !== null && _entry_createdAt !== void 0 ? _entry_createdAt : 0,
423
- retryCount: (_entry_retryCount = entry.retryCount) !== null && _entry_retryCount !== void 0 ? _entry_retryCount : 0,
424
- error: entry.error ? (_entry_error_message = entry.error.message) !== null && _entry_error_message !== void 0 ? _entry_error_message : String(entry.error) : void 0
425
- });
426
- }
427
- } catch (err) {
428
- _didIteratorError = true;
429
- _iteratorError = err;
430
- } finally {
431
- try {
432
- if (!_iteratorNormalCompletion && _iterator.return != null) {
433
- _iterator.return();
434
- }
435
- } finally {
436
- if (_didIteratorError) {
437
- throw _iteratorError;
438
- }
439
- }
440
- }
441
- return entries;
442
- }
443
- }, {
444
- /**
445
- * Drops a failed (or still-pending) ledger entry without retrying it —
446
- * the "dismiss" half of the rejected-write contract. The optimistic
447
- * rollback already ran when the mutation failed; this only clears the
448
- * error affordance.
449
- */
450
- key: "dismissMutation",
451
- value: function dismissMutation(id) {
452
- this.mutationJournal.remove(id);
453
- this.emit();
454
- }
455
- }, {
456
- /** Reads a single document from the local cache. */
457
- key: "getDocFromCache",
458
- value: function getDocFromCache(doctype, name) {
459
- return this.normalizedCache.get({
460
- doctype,
461
- name
462
- });
463
- }
464
- }, {
465
- /** Returns subscription metadata by id. */
466
- key: "getSubscription",
467
- value: function getSubscription(id) {
468
- return this.subscriptionManager.getSubscription(id);
469
- }
470
- }, {
471
- /**
472
- * Returns current rows for a subscription from the cache.
473
- */
474
- key: "getDocsForSubscription",
475
- value: function getDocsForSubscription(id) {
476
- return this.subscriptionManager.getDocsForSubscription(id);
477
- }
478
- }, {
479
- key: "getPage",
480
- value: (
481
- /**
482
- * Get a specific page of documents using virtual pagination.
483
- * Requires the subscription to have been created with `progressive: true`.
484
- */
485
- async function getPage(subscriptionId, page) {
486
- var result = await this.subscriptionManager.getPage(subscriptionId, page);
487
- this.emit();
488
- return result;
489
- })
490
- }, {
491
- key: "getNextBatch",
492
- value: (
493
- /**
494
- * Get the next batch of documents after a cursor for infinite scroll.
495
- * Requires the subscription to have been created with `progressive: true`.
496
- */
497
- async function getNextBatch(subscriptionId, cursorDocId, limit) {
498
- var result = await this.subscriptionManager.getNextBatch(subscriptionId, cursorDocId, limit);
499
- this.emit();
500
- return result;
501
- })
502
- }, {
503
- /**
504
- * Get page information for a subscription.
505
- */
506
- key: "getPageInfo",
507
- value: function getPageInfo(subscriptionId) {
508
- return this.subscriptionManager.getPageInfo(subscriptionId);
509
- }
510
- }, {
511
- key: "refetchDocs",
512
- value: (/** Refetches authoritative copies for specific documents and updates cache. */
513
- async function refetchDocs(docs) {
514
- await this.subscriptionManager.backfill({
515
- scope: import_types.BackfillScope.Docs,
516
- docs
517
- });
518
- this.emit();
519
- })
520
- }, {
521
- /** Adds a store listener; returns an unsubscribe function. */
522
- key: "subscribeStore",
523
- value: function subscribeStore(listener) {
524
- var _this = this;
525
- this.storeListeners.add(listener);
526
- return function () {
527
- _this.storeListeners.delete(listener);
528
- };
529
- }
530
- }, {
531
- /**
532
- * Registers a listener for raw realtime events (doc_update, list_update,
533
- * doc_deleted, connected, …). Useful for consumers that manage their own
534
- * fetching (e.g. server-side paginated tables) but still want live
535
- * invalidation hints. Returns an unsubscribe function.
536
- */
537
- key: "subscribeRealtimeEvents",
538
- value: function subscribeRealtimeEvents(listener) {
539
- var _this = this;
540
- this.realtimeEventListeners.add(listener);
541
- return function () {
542
- _this.realtimeEventListeners.delete(listener);
543
- };
544
- }
545
- }, {
546
- /**
547
- * Joins the realtime doctype room without creating a data subscription
548
- * (refcounted). Pair with `unwatchDoctype` on cleanup. Used by consumers
549
- * that fetch their own data but need the doctype's realtime hints.
550
- */
551
- key: "watchDoctype",
552
- value: function watchDoctype(doctype) {
553
- this.realtimeHandler.watchDoctype(doctype);
554
- }
555
- }, {
556
- /** Releases one `watchDoctype` reference. */
557
- key: "unwatchDoctype",
558
- value: function unwatchDoctype(doctype) {
559
- this.realtimeHandler.unwatchDoctype(doctype);
560
- }
561
- }, {
562
- /**
563
- * Live socket connection snapshot. `connected` is the state right now;
564
- * `everConnected` distinguishes "reconnecting" from "realtime never up"
565
- * (fixture mode, SSR, or no realtime module). Store listeners are
566
- * notified on every flip, so read this inside a `subscribeStore` callback
567
- * for a reactive indicator.
568
- */
569
- key: "getConnectionState",
570
- value: function getConnectionState() {
571
- return this.realtimeHandler.getConnectionState();
572
- }
573
- }, {
574
- key: "emit",
575
- value: (/** Notifies listeners, schedules persistence, and broadcasts cross-tab changes. */
576
- function emit() {
577
- var _iteratorNormalCompletion = true,
578
- _didIteratorError = false,
579
- _iteratorError = void 0;
580
- try {
581
- for (var _iterator = this.storeListeners[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
582
- var listener = _step.value;
583
- listener();
584
- }
585
- } catch (err) {
586
- _didIteratorError = true;
587
- _iteratorError = err;
588
- } finally {
589
- try {
590
- if (!_iteratorNormalCompletion && _iterator.return != null) {
591
- _iterator.return();
592
- }
593
- } finally {
594
- if (_didIteratorError) {
595
- throw _iteratorError;
596
- }
597
- }
598
- }
599
- this.persistenceManager.scheduleSave();
600
- this.persistenceManager.broadcastChange();
601
- })
602
- }, {
603
- /** Clears subscriptions, cache, journal, and temp id mappings. */
604
- key: "resetCache",
605
- value: function resetCache() {
606
- this.catchUpEpoch++;
607
- this.catchUpRun = void 0;
608
- this.catchUpState = idleCatchUpState;
609
- this.realtimeHandler.unwatchAll();
610
- this.subscriptionManager.clear();
611
- this.normalizedCache.clear();
612
- this.mutationJournal.clear();
613
- this.mutationEngine.clearTemporaryMappings();
614
- this.emit();
615
- }
616
- }, {
617
- key: "dispose",
618
- value: (/** Cleanup and dispose of resources */
619
- async function dispose() {
620
- var _this_cleanupFocus, _this, _this_cleanupFocusReplay, _this1, _this_cleanupOnlineBackfill, _this2, _this_cleanupOnlineReplay, _this3;
621
- this.disposed = true;
622
- this.storeListeners.clear();
623
- this.realtimeEventListeners.clear();
624
- this.resetCache();
625
- this.mutationJournal.dispose();
626
- this.mutationEngine.dispose();
627
- this.realtimeHandler.dispose();
628
- this.persistenceManager.destroy();
629
- this.rehydrationManager.clear();
630
- (_this_cleanupFocus = (_this = this).cleanupFocus) === null || _this_cleanupFocus === void 0 ? void 0 : _this_cleanupFocus.call(_this);
631
- (_this_cleanupFocusReplay = (_this1 = this).cleanupFocusReplay) === null || _this_cleanupFocusReplay === void 0 ? void 0 : _this_cleanupFocusReplay.call(_this1);
632
- (_this_cleanupOnlineBackfill = (_this2 = this).cleanupOnlineBackfill) === null || _this_cleanupOnlineBackfill === void 0 ? void 0 : _this_cleanupOnlineBackfill.call(_this2);
633
- (_this_cleanupOnlineReplay = (_this3 = this).cleanupOnlineReplay) === null || _this_cleanupOnlineReplay === void 0 ? void 0 : _this_cleanupOnlineReplay.call(_this3);
634
- this.cleanupFocus = void 0;
635
- this.cleanupFocusReplay = void 0;
636
- this.cleanupOnlineBackfill = void 0;
637
- this.cleanupOnlineReplay = void 0;
638
- if (this.cdcIntervalHandle) {
639
- clearInterval(this.cdcIntervalHandle);
640
- this.cdcIntervalHandle = void 0;
641
- }
642
- })
643
- }, {
644
- /**
645
- * Returns a snapshot of internal state for devtools inspection.
646
- * Prefixed with __ to signal internal/debug use only.
647
- */
648
- key: "__debug",
649
- value: function __debug() {
650
- var allSubs = this.subscriptionManager.getAllSubscriptions();
651
- var vpm = this.subscriptionManager.getVirtualPageManager();
652
- var subscriptions = [];
653
- var _iteratorNormalCompletion = true,
654
- _didIteratorError = false,
655
- _iteratorError = void 0;
656
- try {
657
- for (var _iterator = allSubs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
658
- var [, sub] = _step.value;
659
- var _ref;
660
- var _sub_tombstones;
661
- var virtualSub = vpm.getSubscription(sub.id);
662
- var pageInfo = vpm.getPageInfo(sub.id);
663
- var islands = vpm.getPageIslands(sub.id);
664
- var debugSub = {
665
- id: sub.id,
666
- query: sub.query,
667
- docCount: sub.docIds.length,
668
- tombstoneCount: (_ref = (_sub_tombstones = sub.tombstones) === null || _sub_tombstones === void 0 ? void 0 : _sub_tombstones.size) !== null && _ref !== void 0 ? _ref : 0,
669
- checkpoint: sub.checkpoint,
670
- cursor: sub.cursor,
671
- stale: sub.stale,
672
- restored: this.subscriptionManager.isRestoredSubscription(sub.id),
673
- pageInfo
674
- };
675
- if (virtualSub) {
676
- var _pc_lastFetchedAt;
677
- var pc = virtualSub.getProgressiveCache();
678
- debugSub.progressiveCache = {
679
- docIds: pc.docIds,
680
- nextCursor: pc.nextCursor,
681
- hasMore: pc.hasMore,
682
- totalCount: pc.totalCount,
683
- lastFetchedAt: (_pc_lastFetchedAt = pc.lastFetchedAt) === null || _pc_lastFetchedAt === void 0 ? void 0 : _pc_lastFetchedAt.toISOString(),
684
- islands
685
- };
686
- }
687
- subscriptions.push(debugSub);
688
- }
689
- } catch (err) {
690
- _didIteratorError = true;
691
- _iteratorError = err;
692
- } finally {
693
- try {
694
- if (!_iteratorNormalCompletion && _iterator.return != null) {
695
- _iterator.return();
696
- }
697
- } finally {
698
- if (_didIteratorError) {
699
- throw _iteratorError;
700
- }
701
- }
702
- }
703
- var cacheStats = this.normalizedCache.getStats();
704
- var allEntries = this.mutationJournal.getAllEntries();
705
- var pending = [];
706
- var confirmed = [];
707
- var failed = [];
708
- var _iteratorNormalCompletion1 = true,
709
- _didIteratorError1 = false,
710
- _iteratorError1 = void 0;
711
- try {
712
- for (var _iterator1 = allEntries[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
713
- var {
714
- id,
715
- entry
716
- } = _step1.value;
717
- var _entry_createdAt, _entry_retryCount, _entry_error_message;
718
- var debugEntry = {
719
- id,
720
- operation: entry.operation,
721
- doctype: entry.doctype,
722
- docname: entry.docname,
723
- status: entry.status,
724
- createdAt: (_entry_createdAt = entry.createdAt) !== null && _entry_createdAt !== void 0 ? _entry_createdAt : 0,
725
- retryCount: (_entry_retryCount = entry.retryCount) !== null && _entry_retryCount !== void 0 ? _entry_retryCount : 0,
726
- error: entry.error ? (_entry_error_message = entry.error.message) !== null && _entry_error_message !== void 0 ? _entry_error_message : String(entry.error) : void 0
727
- };
728
- if (entry.status === import_types.Status.Pending) pending.push(debugEntry);else if (entry.status === import_types.Status.Confirmed) confirmed.push(debugEntry);else if (entry.status === import_types.Status.Failed) failed.push(debugEntry);
729
- }
730
- } catch (err) {
731
- _didIteratorError1 = true;
732
- _iteratorError1 = err;
733
- } finally {
734
- try {
735
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
736
- _iterator1.return();
737
- }
738
- } finally {
739
- if (_didIteratorError1) {
740
- throw _iteratorError1;
741
- }
742
- }
743
- }
744
- return {
745
- subscriptions,
746
- normalizedCache: cacheStats,
747
- mutationJournal: {
748
- pending,
749
- confirmed,
750
- failed
751
- },
752
- connection: {
753
- socketConnected: this.realtimeHandler.getIsConnected(),
754
- isLeader: this.persistenceManager.getIsLeader(),
755
- // React Native has navigator but no onLine (undefined) — treat
756
- // anything other than an explicit false as online.
757
- isOnline: typeof navigator === "undefined" || navigator.onLine !== false
758
- }
759
- };
760
- }
761
- }, {
762
- /**
763
- * Checks if this tab is the leader for multi-tab coordination.
764
- */
765
- key: "isLeader",
766
- value: function isLeader() {
767
- return this.persistenceManager.getIsLeader();
768
- }
769
- }]);
770
- return SyncModule2;
771
- }();
772
773
  //# sourceMappingURL=index.native.js.map