@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,489 +5,473 @@ 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 backfill_exports = {};
26
24
  __export(backfill_exports, {
27
- BackfillManager: () => BackfillManager,
28
- BackfillReason: () => BackfillReason,
29
- BackfillStrategy: () => BackfillStrategy
25
+ BackfillManager: () => BackfillManager,
26
+ BackfillReason: () => BackfillReason,
27
+ BackfillStrategy: () => BackfillStrategy
30
28
  });
31
29
  module.exports = __toCommonJS(backfill_exports);
32
30
  var import_filters = require("./filters.native.js");
33
31
  function _class_call_check(instance, Constructor) {
34
- if (!(instance instanceof Constructor)) {
35
- throw new TypeError("Cannot call a class as a function");
36
- }
32
+ if (!(instance instanceof Constructor)) {
33
+ throw new TypeError("Cannot call a class as a function");
34
+ }
37
35
  }
38
36
  function _defineProperties(target, props) {
39
- for (var i = 0; i < props.length; i++) {
40
- var descriptor = props[i];
41
- descriptor.enumerable = descriptor.enumerable || false;
42
- descriptor.configurable = true;
43
- if ("value" in descriptor) descriptor.writable = true;
44
- Object.defineProperty(target, descriptor.key, descriptor);
45
- }
37
+ for (var i = 0; i < props.length; i++) {
38
+ var descriptor = props[i];
39
+ descriptor.enumerable = descriptor.enumerable || false;
40
+ descriptor.configurable = true;
41
+ if ("value" in descriptor) descriptor.writable = true;
42
+ Object.defineProperty(target, descriptor.key, descriptor);
43
+ }
46
44
  }
47
45
  function _create_class(Constructor, protoProps, staticProps) {
48
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
49
- if (staticProps) _defineProperties(Constructor, staticProps);
50
- return Constructor;
46
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
47
+ if (staticProps) _defineProperties(Constructor, staticProps);
48
+ return Constructor;
51
49
  }
52
50
  function _define_property(obj, key, value) {
53
- if (key in obj) {
54
- Object.defineProperty(obj, key, {
55
- value,
56
- enumerable: true,
57
- configurable: true,
58
- writable: true
59
- });
60
- } else {
61
- obj[key] = value;
62
- }
63
- return obj;
51
+ if (key in obj) {
52
+ Object.defineProperty(obj, key, {
53
+ value,
54
+ enumerable: true,
55
+ configurable: true,
56
+ writable: true
57
+ });
58
+ } else {
59
+ obj[key] = value;
60
+ }
61
+ return obj;
64
62
  }
65
63
  function calculateCheckpointFromDocs(docs) {
66
- if (docs.length === 0) return void 0;
67
- var maxTimestamp = "";
68
- var maxDate = null;
69
- var _iteratorNormalCompletion = true,
70
- _didIteratorError = false,
71
- _iteratorError = void 0;
72
- try {
73
- for (var _iterator = docs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
74
- var doc = _step.value;
75
- var modified = doc.modified;
76
- if (!modified) continue;
77
- try {
78
- var date = new Date(modified);
79
- if (Number.isNaN(date.getTime())) continue;
80
- if (!maxDate || date > maxDate) {
81
- maxDate = date;
82
- maxTimestamp = modified;
83
- }
84
- } catch (unused) {
85
- if (!maxTimestamp || modified > maxTimestamp) {
86
- maxTimestamp = modified;
87
- }
88
- }
89
- }
90
- } catch (err) {
91
- _didIteratorError = true;
92
- _iteratorError = err;
93
- } finally {
94
- try {
95
- if (!_iteratorNormalCompletion && _iterator.return != null) {
96
- _iterator.return();
97
- }
98
- } finally {
99
- if (_didIteratorError) {
100
- throw _iteratorError;
101
- }
102
- }
103
- }
104
- return maxTimestamp || void 0;
64
+ if (docs.length === 0) return void 0;
65
+ var maxTimestamp = "";
66
+ var maxDate = null;
67
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
68
+ try {
69
+ for (var _iterator = docs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
70
+ var doc = _step.value;
71
+ var modified = doc.modified;
72
+ if (!modified) continue;
73
+ try {
74
+ var date = new Date(modified);
75
+ if (Number.isNaN(date.getTime())) continue;
76
+ if (!maxDate || date > maxDate) {
77
+ maxDate = date;
78
+ maxTimestamp = modified;
79
+ }
80
+ } catch (unused) {
81
+ if (!maxTimestamp || modified > maxTimestamp) {
82
+ maxTimestamp = modified;
83
+ }
84
+ }
85
+ }
86
+ } catch (err) {
87
+ _didIteratorError = true;
88
+ _iteratorError = err;
89
+ } finally {
90
+ try {
91
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
92
+ _iterator.return();
93
+ }
94
+ } finally {
95
+ if (_didIteratorError) {
96
+ throw _iteratorError;
97
+ }
98
+ }
99
+ }
100
+ return maxTimestamp || void 0;
105
101
  }
106
102
  var log = console;
107
- var BackfillReason = /* @__PURE__ */function (BackfillReason2) {
108
- BackfillReason2["DeleteGap"] = "delete-gap";
109
- BackfillReason2["Initial"] = "initial";
110
- BackfillReason2["Pagination"] = "pagination";
111
- BackfillReason2["Periodic"] = "periodic";
112
- BackfillReason2["Recovery"] = "recovery";
113
- BackfillReason2["Rehydration"] = "rehydration";
114
- BackfillReason2["RemoteCreate"] = "remote-create";
115
- BackfillReason2["RemoteUpdate"] = "remote-update";
116
- return BackfillReason2;
117
- }({});
118
- var BackfillStrategy = /* @__PURE__ */function (BackfillStrategy2) {
119
- BackfillStrategy2["CursorFetch"] = "cursor-fetch";
120
- BackfillStrategy2["FullRefresh"] = "full-refresh";
121
- BackfillStrategy2["GapFill"] = "gap-fill";
122
- BackfillStrategy2["Incremental"] = "incremental";
123
- BackfillStrategy2["PageOnly"] = "page-only";
124
- return BackfillStrategy2;
125
- }({});
126
- var BackfillManager = /* @__PURE__ */function () {
127
- "use strict";
103
+ var BackfillReason = /* @__PURE__ */ (function(BackfillReason2) {
104
+ BackfillReason2["DeleteGap"] = "delete-gap";
105
+ BackfillReason2["Initial"] = "initial";
106
+ BackfillReason2["Pagination"] = "pagination";
107
+ BackfillReason2["Periodic"] = "periodic";
108
+ BackfillReason2["Recovery"] = "recovery";
109
+ BackfillReason2["Rehydration"] = "rehydration";
110
+ BackfillReason2["RemoteCreate"] = "remote-create";
111
+ BackfillReason2["RemoteUpdate"] = "remote-update";
112
+ return BackfillReason2;
113
+ })({});
114
+ var BackfillStrategy = /* @__PURE__ */ (function(BackfillStrategy2) {
115
+ BackfillStrategy2["CursorFetch"] = "cursor-fetch";
116
+ BackfillStrategy2["FullRefresh"] = "full-refresh";
117
+ BackfillStrategy2["GapFill"] = "gap-fill";
118
+ BackfillStrategy2["Incremental"] = "incremental";
119
+ BackfillStrategy2["PageOnly"] = "page-only";
120
+ return BackfillStrategy2;
121
+ })({});
122
+ var BackfillManager = /* @__PURE__ */ (function() {
123
+ "use strict";
124
+ function BackfillManager2(db, normalizedCache) {
125
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
126
+ _class_call_check(this, BackfillManager2);
127
+ _define_property(this, "activeBackfills", /* @__PURE__ */ new Map());
128
+ _define_property(this, "backfillQueue", /* @__PURE__ */ new Map());
129
+ _define_property(this, "db", void 0);
130
+ _define_property(this, "normalizedCache", void 0);
131
+ _define_property(this, "options", void 0);
132
+ this.db = db;
133
+ this.normalizedCache = normalizedCache;
134
+ this.options = options;
135
+ }
136
+ _create_class(BackfillManager2, [
137
+ {
138
+ key: "backfill",
139
+ value: async function backfill(subscription, reason) {
140
+ var subscriptionId = subscription.id;
141
+ if (this.activeBackfills.has(subscriptionId)) {
142
+ this.queueBackfill(subscriptionId, reason);
143
+ return this.activeBackfills.get(subscriptionId);
144
+ }
145
+ var backfillPromise = this.performBackfill(subscription, reason);
146
+ this.activeBackfills.set(subscriptionId, backfillPromise);
147
+ var backfillSucceeded = false;
148
+ try {
149
+ await backfillPromise;
150
+ backfillSucceeded = true;
151
+ } catch (err) {
152
+ log.error(err);
153
+ } finally {
154
+ this.activeBackfills.delete(subscriptionId);
155
+ if (backfillSucceeded) {
156
+ var queued = this.backfillQueue.get(subscriptionId);
157
+ if (queued && queued.length > 0) {
158
+ var _$reason = queued.shift();
159
+ if (queued.length === 0) this.backfillQueue.delete(subscriptionId);
160
+ if (_$reason) this.backfill(subscription, _$reason).catch(log.error);
161
+ }
162
+ } else {
163
+ this.backfillQueue.delete(subscriptionId);
164
+ }
165
+ }
166
+ }
167
+ },
168
+ {
169
+ key: "backfillOne",
170
+ value: (
171
+ /**
172
+ * Backfill one item to fill a gap
173
+ */
174
+ async function backfillOne(subscription) {
175
+ if (!subscription.getProgressiveCache().hasMore) {
176
+ return null;
177
+ }
178
+ try {
179
+ var docs = await this.fetchWithCursor(subscription, 1);
180
+ if (docs.length > 0) {
181
+ var doc = docs[0];
182
+ subscription.processDocuments([doc], this.normalizedCache, { calculateCheckpoint: false });
183
+ return doc;
184
+ }
185
+ subscription.updateProgressiveCache({ hasMore: false });
186
+ return null;
187
+ } catch (error) {
188
+ console.error("Failed to backfill one item:", error);
189
+ return null;
190
+ }
191
+ })
192
+ },
193
+ {
194
+ key: "rehydrateCurrentPage",
195
+ value: (
196
+ /**
197
+ * Rehydrate current page
198
+ */
199
+ async function rehydrateCurrentPage(subscription) {
200
+ var pageSize = subscription.viewWindow.pageSize;
201
+ var currentPage = subscription.viewWindow.currentPage;
202
+ var start = (currentPage - 1) * pageSize;
203
+ try {
204
+ var response = await this.db.getDocList(subscription.query.doctype, {
205
+ fields: subscription.query.fields,
206
+ filters: subscription.query.filters,
207
+ orderBy: subscription.query.orderBy,
208
+ limitStart: start,
209
+ limit: pageSize
210
+ });
211
+ var newDocIds = response.map(function(doc2) {
212
+ return doc2.name;
213
+ });
214
+ var currentDocIds = subscription.getProgressiveCache().docIds;
215
+ var updatedDocIds = [...currentDocIds];
216
+ updatedDocIds.splice(start, pageSize, ...newDocIds);
217
+ subscription.updateProgressiveCache({ docIds: updatedDocIds });
218
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
219
+ try {
220
+ for (var _iterator = response[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
221
+ var doc = _step.value;
222
+ this.normalizedCache.upsert(doc);
223
+ }
224
+ } catch (err) {
225
+ _didIteratorError = true;
226
+ _iteratorError = err;
227
+ } finally {
228
+ try {
229
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
230
+ _iterator.return();
231
+ }
232
+ } finally {
233
+ if (_didIteratorError) {
234
+ throw _iteratorError;
235
+ }
236
+ }
237
+ }
238
+ subscription.needsRehydration = false;
239
+ } catch (error) {
240
+ console.error("Failed to rehydrate current page:", error);
241
+ throw error;
242
+ }
243
+ })
244
+ },
245
+ {
246
+ key: "performBackfill",
247
+ value: async function performBackfill(subscription, reason) {
248
+ var strategy = this.determineStrategy(subscription, reason);
249
+ switch (strategy) {
250
+ case "full-refresh":
251
+ await this.fullRefresh(subscription);
252
+ break;
253
+ case "incremental":
254
+ await this.incrementalBackfill(subscription);
255
+ break;
256
+ case "page-only":
257
+ await this.pageBackfill(subscription);
258
+ break;
259
+ case "gap-fill":
260
+ await this.gapBackfill(subscription);
261
+ break;
262
+ case "cursor-fetch":
263
+ await this.cursorFetch(subscription);
264
+ break;
265
+ }
266
+ }
267
+ },
268
+ {
269
+ key: "determineStrategy",
270
+ value: function determineStrategy(subscription, reason) {
271
+ switch (reason) {
272
+ case "initial": return "full-refresh";
273
+ case "pagination": return subscription.getProgressiveCache().nextCursor ? "cursor-fetch" : "incremental";
274
+ case "delete-gap": return "gap-fill";
275
+ case "remote-create":
276
+ case "remote-update":
277
+ case "rehydration": return "page-only";
278
+ case "periodic": return subscription.checkpoint ? "incremental" : "full-refresh";
279
+ case "recovery": return subscription.checkpoint ? "incremental" : "full-refresh";
280
+ default: return "incremental";
281
+ }
282
+ }
283
+ },
284
+ {
285
+ key: "fullRefresh",
286
+ value: async function fullRefresh(subscription) {
287
+ var batchSize = this.options.batchSize || this.options.pageSize || 100;
288
+ var response = await this.db.getDocList(subscription.query.doctype, {
289
+ fields: subscription.query.fields,
290
+ filters: subscription.query.filters,
291
+ orderBy: subscription.query.orderBy,
292
+ limit: batchSize,
293
+ limitStart: 0
294
+ });
295
+ subscription.processDocuments(response, this.normalizedCache);
296
+ subscription.updateProgressiveCache({ hasMore: response.length === batchSize });
297
+ }
298
+ },
299
+ {
300
+ key: "incrementalBackfill",
301
+ value: async function incrementalBackfill(subscription) {
302
+ if (!subscription.checkpoint) {
303
+ return this.fullRefresh(subscription);
304
+ }
305
+ try {
306
+ var _this_options_maxPages;
307
+ var maxPages = (_this_options_maxPages = this.options.maxPages) !== null && _this_options_maxPages !== void 0 ? _this_options_maxPages : 20;
308
+ for (var page = 0; page < maxPages; page++) {
309
+ var _response_checkpoint, _ref;
310
+ var _response_deleted;
311
+ var response = await this.db.backfill({
312
+ doctype: subscription.query.doctype,
313
+ fields: subscription.query.fields,
314
+ filters: subscription.query.filters,
315
+ modifiedAfter: subscription.checkpoint,
316
+ limit: this.options.pageSize || 200
317
+ });
318
+ if ("deleted" in response && Array.isArray(response.deleted)) {
319
+ var deletedDocIds = response.deleted.filter(function(deletion) {
320
+ return deletion === null || deletion === void 0 ? void 0 : deletion.name;
321
+ }).map(function(deletion) {
322
+ return deletion.name;
323
+ });
324
+ if (deletedDocIds.length > 0) {
325
+ subscription.removeDocuments(deletedDocIds, this.normalizedCache);
326
+ }
327
+ }
328
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
329
+ try {
330
+ for (var _iterator = response.rows[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
331
+ var doc = _step.value;
332
+ var exists = subscription.getProgressiveCache().docIds.includes(doc.name);
333
+ var matches = (0, import_filters.matchesFilters)(doc, subscription.query.filters);
334
+ if (exists && !matches) {
335
+ subscription.removeDocuments([doc.name], this.normalizedCache);
336
+ } else if (!exists && matches) {
337
+ subscription.needsRehydration = true;
338
+ } else if (exists) {
339
+ this.normalizedCache.upsert(doc);
340
+ }
341
+ }
342
+ } catch (err) {
343
+ _didIteratorError = true;
344
+ _iteratorError = err;
345
+ } finally {
346
+ try {
347
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
348
+ _iterator.return();
349
+ }
350
+ } finally {
351
+ if (_didIteratorError) {
352
+ throw _iteratorError;
353
+ }
354
+ }
355
+ }
356
+ subscription.checkpoint = (_response_checkpoint = response.checkpoint) !== null && _response_checkpoint !== void 0 ? _response_checkpoint : calculateCheckpointFromDocs(response.rows);
357
+ var madeProgress = response.rows.length > 0 || ((_ref = (_response_deleted = response.deleted) === null || _response_deleted === void 0 ? void 0 : _response_deleted.length) !== null && _ref !== void 0 ? _ref : 0) > 0;
358
+ if (!response.has_more || !response.checkpoint || !madeProgress) break;
359
+ }
360
+ } catch (error) {
361
+ console.error("Incremental backfill failed:", error);
362
+ await this.fullRefresh(subscription);
363
+ }
364
+ }
365
+ },
366
+ {
367
+ key: "pageBackfill",
368
+ value: async function pageBackfill(subscription) {
369
+ var pageSize = subscription.viewWindow.pageSize;
370
+ var currentPage = subscription.viewWindow.currentPage;
371
+ var start = (currentPage - 1) * pageSize;
372
+ var response = await this.db.getDocList(subscription.query.doctype, {
373
+ fields: subscription.query.fields,
374
+ filters: subscription.query.filters,
375
+ orderBy: subscription.query.orderBy,
376
+ limitStart: start,
377
+ limit: pageSize
378
+ });
379
+ var newDocIds = response.map(function(doc2) {
380
+ return doc2.name;
381
+ });
382
+ var currentDocIds = subscription.getProgressiveCache().docIds;
383
+ var updatedDocIds = [...currentDocIds];
384
+ updatedDocIds.splice(start, pageSize, ...newDocIds);
385
+ subscription.updateProgressiveCache({ docIds: updatedDocIds });
386
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
387
+ try {
388
+ for (var _iterator = response[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
389
+ var doc = _step.value;
390
+ this.normalizedCache.upsert(doc);
391
+ }
392
+ } catch (err) {
393
+ _didIteratorError = true;
394
+ _iteratorError = err;
395
+ } finally {
396
+ try {
397
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
398
+ _iterator.return();
399
+ }
400
+ } finally {
401
+ if (_didIteratorError) {
402
+ throw _iteratorError;
403
+ }
404
+ }
405
+ }
406
+ subscription.needsRehydration = false;
407
+ }
408
+ },
409
+ {
410
+ key: "gapBackfill",
411
+ value: async function gapBackfill(subscription) {
412
+ await this.backfillOne(subscription);
413
+ subscription.pendingBackfill = false;
414
+ }
415
+ },
416
+ {
417
+ key: "cursorFetch",
418
+ value: async function cursorFetch(subscription) {
419
+ if (!subscription.getProgressiveCache().hasMore) return;
420
+ var batchSize = this.options.batchSize || this.options.pageSize || 100;
421
+ var docs = await this.fetchWithCursor(subscription, batchSize);
422
+ subscription.updateProgressiveCache({
423
+ docIds: [...subscription.getProgressiveCache().docIds, ...docs.map(function(doc2) {
424
+ return doc2.name;
425
+ })],
426
+ nextCursor: docs.length > 0 ? docs[docs.length - 1].name : subscription.getProgressiveCache().nextCursor,
427
+ hasMore: docs.length === batchSize
428
+ });
429
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
430
+ try {
431
+ for (var _iterator = docs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
432
+ var doc = _step.value;
433
+ this.normalizedCache.upsert(doc);
434
+ }
435
+ } catch (err) {
436
+ _didIteratorError = true;
437
+ _iteratorError = err;
438
+ } finally {
439
+ try {
440
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
441
+ _iterator.return();
442
+ }
443
+ } finally {
444
+ if (_didIteratorError) {
445
+ throw _iteratorError;
446
+ }
447
+ }
448
+ }
449
+ }
450
+ },
451
+ {
452
+ key: "fetchWithCursor",
453
+ value: async function fetchWithCursor(subscription, limit) {
454
+ return this.db.getDocList(subscription.query.doctype, {
455
+ fields: subscription.query.fields,
456
+ filters: subscription.query.filters,
457
+ orderBy: subscription.query.orderBy,
458
+ cursor: subscription.getProgressiveCache().nextCursor,
459
+ limit
460
+ });
461
+ }
462
+ },
463
+ {
464
+ key: "queueBackfill",
465
+ value: function queueBackfill(subscriptionId, reason) {
466
+ if (!this.backfillQueue.has(subscriptionId)) {
467
+ this.backfillQueue.set(subscriptionId, []);
468
+ }
469
+ var queue = this.backfillQueue.get(subscriptionId);
470
+ if (!queue.includes(reason)) queue.push(reason);
471
+ }
472
+ }
473
+ ]);
474
+ return BackfillManager2;
475
+ })();
128
476
 
129
- function BackfillManager2(db, normalizedCache) {
130
- var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
131
- _class_call_check(this, BackfillManager2);
132
- _define_property(this, "activeBackfills", /* @__PURE__ */new Map());
133
- _define_property(this, "backfillQueue", /* @__PURE__ */new Map());
134
- _define_property(this, "db", void 0);
135
- _define_property(this, "normalizedCache", void 0);
136
- _define_property(this, "options", void 0);
137
- this.db = db;
138
- this.normalizedCache = normalizedCache;
139
- this.options = options;
140
- }
141
- _create_class(BackfillManager2, [{
142
- key: "backfill",
143
- value: async function backfill(subscription, reason) {
144
- var subscriptionId = subscription.id;
145
- if (this.activeBackfills.has(subscriptionId)) {
146
- this.queueBackfill(subscriptionId, reason);
147
- return this.activeBackfills.get(subscriptionId);
148
- }
149
- var backfillPromise = this.performBackfill(subscription, reason);
150
- this.activeBackfills.set(subscriptionId, backfillPromise);
151
- var backfillSucceeded = false;
152
- try {
153
- await backfillPromise;
154
- backfillSucceeded = true;
155
- } catch (err) {
156
- log.error(err);
157
- } finally {
158
- this.activeBackfills.delete(subscriptionId);
159
- if (backfillSucceeded) {
160
- var queued = this.backfillQueue.get(subscriptionId);
161
- if (queued && queued.length > 0) {
162
- var _$reason = queued.shift();
163
- if (queued.length === 0) this.backfillQueue.delete(subscriptionId);
164
- if (_$reason) this.backfill(subscription, _$reason).catch(log.error);
165
- }
166
- } else {
167
- this.backfillQueue.delete(subscriptionId);
168
- }
169
- }
170
- }
171
- }, {
172
- key: "backfillOne",
173
- value: (
174
- /**
175
- * Backfill one item to fill a gap
176
- */
177
- async function backfillOne(subscription) {
178
- if (!subscription.getProgressiveCache().hasMore) {
179
- return null;
180
- }
181
- try {
182
- var docs = await this.fetchWithCursor(subscription, 1);
183
- if (docs.length > 0) {
184
- var doc = docs[0];
185
- subscription.processDocuments([doc], this.normalizedCache, {
186
- calculateCheckpoint: false
187
- });
188
- return doc;
189
- }
190
- subscription.updateProgressiveCache({
191
- hasMore: false
192
- });
193
- return null;
194
- } catch (error) {
195
- console.error("Failed to backfill one item:", error);
196
- return null;
197
- }
198
- })
199
- }, {
200
- key: "rehydrateCurrentPage",
201
- value: (
202
- /**
203
- * Rehydrate current page
204
- */
205
- async function rehydrateCurrentPage(subscription) {
206
- var pageSize = subscription.viewWindow.pageSize;
207
- var currentPage = subscription.viewWindow.currentPage;
208
- var start = (currentPage - 1) * pageSize;
209
- try {
210
- var response = await this.db.getDocList(subscription.query.doctype, {
211
- fields: subscription.query.fields,
212
- filters: subscription.query.filters,
213
- orderBy: subscription.query.orderBy,
214
- limitStart: start,
215
- limit: pageSize
216
- });
217
- var newDocIds = response.map(function (doc2) {
218
- return doc2.name;
219
- });
220
- var currentDocIds = subscription.getProgressiveCache().docIds;
221
- var updatedDocIds = [...currentDocIds];
222
- updatedDocIds.splice(start, pageSize, ...newDocIds);
223
- subscription.updateProgressiveCache({
224
- docIds: updatedDocIds
225
- });
226
- var _iteratorNormalCompletion = true,
227
- _didIteratorError = false,
228
- _iteratorError = void 0;
229
- try {
230
- for (var _iterator = response[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
231
- var doc = _step.value;
232
- this.normalizedCache.upsert(doc);
233
- }
234
- } catch (err) {
235
- _didIteratorError = true;
236
- _iteratorError = err;
237
- } finally {
238
- try {
239
- if (!_iteratorNormalCompletion && _iterator.return != null) {
240
- _iterator.return();
241
- }
242
- } finally {
243
- if (_didIteratorError) {
244
- throw _iteratorError;
245
- }
246
- }
247
- }
248
- subscription.needsRehydration = false;
249
- } catch (error) {
250
- console.error("Failed to rehydrate current page:", error);
251
- throw error;
252
- }
253
- })
254
- }, {
255
- key: "performBackfill",
256
- value: async function performBackfill(subscription, reason) {
257
- var strategy = this.determineStrategy(subscription, reason);
258
- switch (strategy) {
259
- case "full-refresh":
260
- await this.fullRefresh(subscription);
261
- break;
262
- case "incremental":
263
- await this.incrementalBackfill(subscription);
264
- break;
265
- case "page-only":
266
- await this.pageBackfill(subscription);
267
- break;
268
- case "gap-fill":
269
- await this.gapBackfill(subscription);
270
- break;
271
- case "cursor-fetch":
272
- await this.cursorFetch(subscription);
273
- break;
274
- }
275
- }
276
- }, {
277
- key: "determineStrategy",
278
- value: function determineStrategy(subscription, reason) {
279
- switch (reason) {
280
- case "initial":
281
- return "full-refresh";
282
- case "pagination":
283
- return subscription.getProgressiveCache().nextCursor ? "cursor-fetch" : "incremental";
284
- case "delete-gap":
285
- return "gap-fill";
286
- case "remote-create":
287
- case "remote-update":
288
- case "rehydration":
289
- return "page-only";
290
- case "periodic":
291
- return subscription.checkpoint ? "incremental" : "full-refresh";
292
- case "recovery":
293
- return subscription.checkpoint ? "incremental" : "full-refresh";
294
- default:
295
- return "incremental";
296
- }
297
- }
298
- }, {
299
- key: "fullRefresh",
300
- value: async function fullRefresh(subscription) {
301
- var batchSize = this.options.batchSize || this.options.pageSize || 100;
302
- var response = await this.db.getDocList(subscription.query.doctype, {
303
- fields: subscription.query.fields,
304
- filters: subscription.query.filters,
305
- orderBy: subscription.query.orderBy,
306
- limit: batchSize,
307
- limitStart: 0
308
- });
309
- subscription.processDocuments(response, this.normalizedCache);
310
- subscription.updateProgressiveCache({
311
- hasMore: response.length === batchSize
312
- });
313
- }
314
- }, {
315
- key: "incrementalBackfill",
316
- value: async function incrementalBackfill(subscription) {
317
- if (!subscription.checkpoint) {
318
- return this.fullRefresh(subscription);
319
- }
320
- try {
321
- var _this_options_maxPages;
322
- var maxPages = (_this_options_maxPages = this.options.maxPages) !== null && _this_options_maxPages !== void 0 ? _this_options_maxPages : 20;
323
- for (var page = 0; page < maxPages; page++) {
324
- var _response_checkpoint, _ref;
325
- var _response_deleted;
326
- var response = await this.db.backfill({
327
- doctype: subscription.query.doctype,
328
- fields: subscription.query.fields,
329
- filters: subscription.query.filters,
330
- modifiedAfter: subscription.checkpoint,
331
- limit: this.options.pageSize || 200
332
- });
333
- if ("deleted" in response && Array.isArray(response.deleted)) {
334
- var deletedDocIds = response.deleted.filter(function (deletion) {
335
- return deletion === null || deletion === void 0 ? void 0 : deletion.name;
336
- }).map(function (deletion) {
337
- return deletion.name;
338
- });
339
- if (deletedDocIds.length > 0) {
340
- subscription.removeDocuments(deletedDocIds, this.normalizedCache);
341
- }
342
- }
343
- var _iteratorNormalCompletion = true,
344
- _didIteratorError = false,
345
- _iteratorError = void 0;
346
- try {
347
- for (var _iterator = response.rows[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
348
- var doc = _step.value;
349
- var exists = subscription.getProgressiveCache().docIds.includes(doc.name);
350
- var matches = (0, import_filters.matchesFilters)(doc, subscription.query.filters);
351
- if (exists && !matches) {
352
- subscription.removeDocuments([doc.name], this.normalizedCache);
353
- } else if (!exists && matches) {
354
- subscription.needsRehydration = true;
355
- } else if (exists) {
356
- this.normalizedCache.upsert(doc);
357
- }
358
- }
359
- } catch (err) {
360
- _didIteratorError = true;
361
- _iteratorError = err;
362
- } finally {
363
- try {
364
- if (!_iteratorNormalCompletion && _iterator.return != null) {
365
- _iterator.return();
366
- }
367
- } finally {
368
- if (_didIteratorError) {
369
- throw _iteratorError;
370
- }
371
- }
372
- }
373
- subscription.checkpoint = (_response_checkpoint = response.checkpoint) !== null && _response_checkpoint !== void 0 ? _response_checkpoint : calculateCheckpointFromDocs(response.rows);
374
- var madeProgress = response.rows.length > 0 || ((_ref = (_response_deleted = response.deleted) === null || _response_deleted === void 0 ? void 0 : _response_deleted.length) !== null && _ref !== void 0 ? _ref : 0) > 0;
375
- if (!response.has_more || !response.checkpoint || !madeProgress) break;
376
- }
377
- } catch (error) {
378
- console.error("Incremental backfill failed:", error);
379
- await this.fullRefresh(subscription);
380
- }
381
- }
382
- }, {
383
- key: "pageBackfill",
384
- value: async function pageBackfill(subscription) {
385
- var pageSize = subscription.viewWindow.pageSize;
386
- var currentPage = subscription.viewWindow.currentPage;
387
- var start = (currentPage - 1) * pageSize;
388
- var response = await this.db.getDocList(subscription.query.doctype, {
389
- fields: subscription.query.fields,
390
- filters: subscription.query.filters,
391
- orderBy: subscription.query.orderBy,
392
- limitStart: start,
393
- limit: pageSize
394
- });
395
- var newDocIds = response.map(function (doc2) {
396
- return doc2.name;
397
- });
398
- var currentDocIds = subscription.getProgressiveCache().docIds;
399
- var updatedDocIds = [...currentDocIds];
400
- updatedDocIds.splice(start, pageSize, ...newDocIds);
401
- subscription.updateProgressiveCache({
402
- docIds: updatedDocIds
403
- });
404
- var _iteratorNormalCompletion = true,
405
- _didIteratorError = false,
406
- _iteratorError = void 0;
407
- try {
408
- for (var _iterator = response[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
409
- var doc = _step.value;
410
- this.normalizedCache.upsert(doc);
411
- }
412
- } catch (err) {
413
- _didIteratorError = true;
414
- _iteratorError = err;
415
- } finally {
416
- try {
417
- if (!_iteratorNormalCompletion && _iterator.return != null) {
418
- _iterator.return();
419
- }
420
- } finally {
421
- if (_didIteratorError) {
422
- throw _iteratorError;
423
- }
424
- }
425
- }
426
- subscription.needsRehydration = false;
427
- }
428
- }, {
429
- key: "gapBackfill",
430
- value: async function gapBackfill(subscription) {
431
- await this.backfillOne(subscription);
432
- subscription.pendingBackfill = false;
433
- }
434
- }, {
435
- key: "cursorFetch",
436
- value: async function cursorFetch(subscription) {
437
- if (!subscription.getProgressiveCache().hasMore) return;
438
- var batchSize = this.options.batchSize || this.options.pageSize || 100;
439
- var docs = await this.fetchWithCursor(subscription, batchSize);
440
- subscription.updateProgressiveCache({
441
- docIds: [...subscription.getProgressiveCache().docIds, ...docs.map(function (doc2) {
442
- return doc2.name;
443
- })],
444
- nextCursor: docs.length > 0 ? docs[docs.length - 1].name : subscription.getProgressiveCache().nextCursor,
445
- hasMore: docs.length === batchSize
446
- });
447
- var _iteratorNormalCompletion = true,
448
- _didIteratorError = false,
449
- _iteratorError = void 0;
450
- try {
451
- for (var _iterator = docs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
452
- var doc = _step.value;
453
- this.normalizedCache.upsert(doc);
454
- }
455
- } catch (err) {
456
- _didIteratorError = true;
457
- _iteratorError = err;
458
- } finally {
459
- try {
460
- if (!_iteratorNormalCompletion && _iterator.return != null) {
461
- _iterator.return();
462
- }
463
- } finally {
464
- if (_didIteratorError) {
465
- throw _iteratorError;
466
- }
467
- }
468
- }
469
- }
470
- }, {
471
- key: "fetchWithCursor",
472
- value: async function fetchWithCursor(subscription, limit) {
473
- return this.db.getDocList(subscription.query.doctype, {
474
- fields: subscription.query.fields,
475
- filters: subscription.query.filters,
476
- orderBy: subscription.query.orderBy,
477
- cursor: subscription.getProgressiveCache().nextCursor,
478
- limit
479
- });
480
- }
481
- }, {
482
- key: "queueBackfill",
483
- value: function queueBackfill(subscriptionId, reason) {
484
- if (!this.backfillQueue.has(subscriptionId)) {
485
- this.backfillQueue.set(subscriptionId, []);
486
- }
487
- var queue = this.backfillQueue.get(subscriptionId);
488
- if (!queue.includes(reason)) queue.push(reason);
489
- }
490
- }]);
491
- return BackfillManager2;
492
- }();
493
477
  //# sourceMappingURL=backfill.native.js.map