@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.
- package/dist/cjs/auth.cjs +34 -44
- package/dist/cjs/auth.native.cjs +97 -0
- package/dist/cjs/auth.native.js +77 -82
- package/dist/cjs/auth.native.js.map +1 -1
- package/dist/cjs/call.cjs +31 -35
- package/dist/cjs/call.native.cjs +92 -0
- package/dist/cjs/call.native.js +72 -71
- package/dist/cjs/call.native.js.map +1 -1
- package/dist/cjs/collection.cjs +243 -287
- package/dist/cjs/collection.native.cjs +461 -0
- package/dist/cjs/collection.native.js +436 -499
- package/dist/cjs/collection.native.js.map +1 -1
- package/dist/cjs/common/types.cjs +9 -11
- package/dist/cjs/common/types.native.cjs +18 -0
- package/dist/cjs/common/types.native.js +9 -10
- package/dist/cjs/common/types.native.js.map +1 -1
- package/dist/cjs/connectionKey.cjs +18 -22
- package/dist/cjs/connectionKey.native.cjs +32 -0
- package/dist/cjs/connectionKey.native.js +19 -22
- package/dist/cjs/connectionKey.native.js.map +1 -1
- package/dist/cjs/core/http.cjs +404 -407
- package/dist/cjs/core/http.native.cjs +659 -0
- package/dist/cjs/core/http.native.js +611 -615
- package/dist/cjs/core/http.native.js.map +1 -1
- package/dist/cjs/core/serverMessages.cjs +48 -43
- package/dist/cjs/core/serverMessages.native.cjs +89 -0
- package/dist/cjs/core/serverMessages.native.js +69 -70
- package/dist/cjs/core/serverMessages.native.js.map +1 -1
- package/dist/cjs/core/sessionGate.cjs +94 -97
- package/dist/cjs/core/sessionGate.native.cjs +270 -0
- package/dist/cjs/core/sessionGate.native.js +220 -232
- package/dist/cjs/core/sessionGate.native.js.map +1 -1
- package/dist/cjs/core/types.cjs +37 -39
- package/dist/cjs/core/types.native.cjs +169 -0
- package/dist/cjs/core/types.native.js +129 -136
- package/dist/cjs/core/types.native.js.map +1 -1
- package/dist/cjs/core/wire.cjs +28 -30
- package/dist/cjs/core/wire.native.cjs +53 -0
- package/dist/cjs/core/wire.native.js +28 -29
- package/dist/cjs/core/wire.native.js.map +1 -1
- package/dist/cjs/db.cjs +434 -449
- package/dist/cjs/db.native.cjs +625 -0
- package/dist/cjs/db.native.js +583 -590
- package/dist/cjs/db.native.js.map +1 -1
- package/dist/cjs/devtools/FrappeDevtoolsPanel.cjs +774 -799
- package/dist/cjs/devtools/FrappeDevtoolsPanel.native.cjs +878 -0
- package/dist/cjs/devtools/FrappeDevtoolsPanel.native.js +821 -862
- package/dist/cjs/devtools/FrappeDevtoolsPanel.native.js.map +1 -1
- package/dist/cjs/devtools/index.cjs +15 -17
- package/dist/cjs/devtools/index.native.cjs +30 -0
- package/dist/cjs/devtools/index.native.js +15 -16
- package/dist/cjs/devtools/index.native.js.map +1 -1
- package/dist/cjs/devtools/plugin.cjs +22 -26
- package/dist/cjs/devtools/plugin.native.cjs +46 -0
- package/dist/cjs/devtools/plugin.native.js +27 -35
- package/dist/cjs/devtools/plugin.native.js.map +1 -1
- package/dist/cjs/devtools/theme.cjs +40 -44
- package/dist/cjs/devtools/theme.native.cjs +53 -0
- package/dist/cjs/devtools/theme.native.js +40 -43
- package/dist/cjs/devtools/theme.native.js.map +1 -1
- package/dist/cjs/doctype.cjs +493 -440
- package/dist/cjs/doctype.native.cjs +631 -0
- package/dist/cjs/doctype.native.js +587 -563
- package/dist/cjs/doctype.native.js.map +1 -1
- package/dist/cjs/file.cjs +27 -31
- package/dist/cjs/file.native.cjs +78 -0
- package/dist/cjs/file.native.js +58 -62
- package/dist/cjs/file.native.js.map +1 -1
- package/dist/cjs/fixtureDb.cjs +187 -209
- package/dist/cjs/fixtureDb.native.cjs +313 -0
- package/dist/cjs/fixtureDb.native.js +291 -300
- package/dist/cjs/fixtureDb.native.js.map +1 -1
- package/dist/cjs/fixtures.cjs +173 -192
- package/dist/cjs/fixtures.native.cjs +379 -0
- package/dist/cjs/fixtures.native.js +359 -381
- package/dist/cjs/fixtures.native.js.map +1 -1
- package/dist/cjs/frappeApp.cjs +94 -101
- package/dist/cjs/frappeApp.native.cjs +181 -0
- package/dist/cjs/frappeApp.native.js +153 -152
- package/dist/cjs/frappeApp.native.js.map +1 -1
- package/dist/cjs/frappeReact.cjs +555 -528
- package/dist/cjs/frappeReact.native.cjs +710 -0
- package/dist/cjs/frappeReact.native.js +637 -632
- package/dist/cjs/frappeReact.native.js.map +1 -1
- package/dist/cjs/index.cjs +128 -135
- package/dist/cjs/index.gnome.cjs +61 -63
- package/dist/cjs/index.gnome.native.cjs +87 -0
- package/dist/cjs/index.gnome.native.js +61 -62
- package/dist/cjs/index.gnome.native.js.map +1 -1
- package/dist/cjs/index.native.cjs +171 -0
- package/dist/cjs/index.native.js +130 -136
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/optimistic.cjs +35 -39
- package/dist/cjs/optimistic.native.cjs +59 -0
- package/dist/cjs/optimistic.native.js +38 -41
- package/dist/cjs/optimistic.native.js.map +1 -1
- package/dist/cjs/pacer.cjs +170 -176
- package/dist/cjs/pacer.native.cjs +263 -0
- package/dist/cjs/pacer.native.js +234 -245
- package/dist/cjs/pacer.native.js.map +1 -1
- package/dist/cjs/plugin/index.cjs +104 -112
- package/dist/cjs/plugin/index.native.cjs +178 -0
- package/dist/cjs/plugin/index.native.js +164 -177
- package/dist/cjs/plugin/index.native.js.map +1 -1
- package/dist/cjs/realtime.cjs +581 -610
- package/dist/cjs/realtime.native.cjs +945 -0
- package/dist/cjs/realtime.native.js +918 -928
- package/dist/cjs/realtime.native.js.map +1 -1
- package/dist/cjs/serverLoaders.cjs +60 -78
- package/dist/cjs/serverLoaders.native.cjs +103 -0
- package/dist/cjs/serverLoaders.native.js +73 -95
- package/dist/cjs/serverLoaders.native.js.map +1 -1
- package/dist/cjs/sync/backfill.cjs +281 -301
- package/dist/cjs/sync/backfill.native.cjs +475 -0
- package/dist/cjs/sync/backfill.native.js +449 -465
- package/dist/cjs/sync/backfill.native.js.map +1 -1
- package/dist/cjs/sync/filters.cjs +309 -267
- package/dist/cjs/sync/filters.native.cjs +472 -0
- package/dist/cjs/sync/filters.native.js +426 -398
- package/dist/cjs/sync/filters.native.js.map +1 -1
- package/dist/cjs/sync/index.cjs +476 -496
- package/dist/cjs/sync/index.native.cjs +771 -0
- package/dist/cjs/sync/index.native.js +738 -737
- package/dist/cjs/sync/index.native.js.map +1 -1
- package/dist/cjs/sync/merge.cjs +392 -393
- package/dist/cjs/sync/merge.native.cjs +681 -0
- package/dist/cjs/sync/merge.native.js +642 -673
- package/dist/cjs/sync/merge.native.js.map +1 -1
- package/dist/cjs/sync/mutationEngine.cjs +785 -829
- package/dist/cjs/sync/mutationEngine.native.cjs +1190 -0
- package/dist/cjs/sync/mutationEngine.native.js +1162 -1216
- package/dist/cjs/sync/mutationEngine.native.js.map +1 -1
- package/dist/cjs/sync/mutationJournal.cjs +147 -149
- package/dist/cjs/sync/mutationJournal.native.cjs +302 -0
- package/dist/cjs/sync/mutationJournal.native.js +278 -269
- package/dist/cjs/sync/mutationJournal.native.js.map +1 -1
- package/dist/cjs/sync/normalizedCache.cjs +127 -134
- package/dist/cjs/sync/normalizedCache.native.cjs +232 -0
- package/dist/cjs/sync/normalizedCache.native.js +212 -212
- package/dist/cjs/sync/normalizedCache.native.js.map +1 -1
- package/dist/cjs/sync/persistence.cjs +649 -661
- package/dist/cjs/sync/persistence.native.cjs +996 -0
- package/dist/cjs/sync/persistence.native.js +967 -965
- package/dist/cjs/sync/persistence.native.js.map +1 -1
- package/dist/cjs/sync/realtime.cjs +307 -315
- package/dist/cjs/sync/realtime.native.cjs +486 -0
- package/dist/cjs/sync/realtime.native.js +465 -461
- package/dist/cjs/sync/realtime.native.js.map +1 -1
- package/dist/cjs/sync/rehydration.cjs +279 -321
- package/dist/cjs/sync/rehydration.native.cjs +495 -0
- package/dist/cjs/sync/rehydration.native.js +473 -515
- package/dist/cjs/sync/rehydration.native.js.map +1 -1
- package/dist/cjs/sync/storage.cjs +127 -129
- package/dist/cjs/sync/storage.native.cjs +211 -0
- package/dist/cjs/sync/storage.native.js +188 -184
- package/dist/cjs/sync/storage.native.js.map +1 -1
- package/dist/cjs/sync/subscriptionManager.cjs +686 -708
- package/dist/cjs/sync/subscriptionManager.native.cjs +1205 -0
- package/dist/cjs/sync/subscriptionManager.native.js +1179 -1220
- package/dist/cjs/sync/subscriptionManager.native.js.map +1 -1
- package/dist/cjs/sync/types.cjs +79 -81
- package/dist/cjs/sync/types.native.cjs +103 -0
- package/dist/cjs/sync/types.native.js +89 -90
- package/dist/cjs/sync/types.native.js.map +1 -1
- package/dist/cjs/sync/virtualPageManager.cjs +762 -806
- package/dist/cjs/sync/virtualPageManager.native.cjs +1097 -0
- package/dist/cjs/sync/virtualPageManager.native.js +1072 -1097
- package/dist/cjs/sync/virtualPageManager.native.js.map +1 -1
- package/dist/cjs/syncOptionsKey.cjs +38 -45
- package/dist/cjs/syncOptionsKey.native.cjs +69 -0
- package/dist/cjs/syncOptionsKey.native.js +51 -63
- package/dist/cjs/syncOptionsKey.native.js.map +1 -1
- package/dist/cjs/useLiveQuery.cjs +14 -18
- package/dist/cjs/useLiveQuery.native.cjs +26 -0
- package/dist/cjs/useLiveQuery.native.js +14 -17
- package/dist/cjs/useLiveQuery.native.js.map +1 -1
- package/dist/cjs/util.cjs +22 -24
- package/dist/cjs/util.native.cjs +40 -0
- package/dist/cjs/util.native.js +22 -28
- package/dist/cjs/util.native.js.map +1 -1
- package/dist/esm/auth.mjs +22 -27
- package/dist/esm/auth.mjs.map +1 -1
- package/dist/esm/auth.native.js +64 -65
- package/dist/esm/auth.native.js.map +1 -1
- package/dist/esm/call.mjs +19 -18
- package/dist/esm/call.mjs.map +1 -1
- package/dist/esm/call.native.js +59 -54
- package/dist/esm/call.native.js.map +1 -1
- package/dist/esm/collection.mjs +228 -268
- package/dist/esm/collection.mjs.map +1 -1
- package/dist/esm/collection.native.js +421 -481
- package/dist/esm/collection.native.js.map +1 -1
- package/dist/esm/common/types.mjs +0 -2
- package/dist/esm/common/types.native.js +0 -2
- package/dist/esm/connectionKey.mjs +5 -4
- package/dist/esm/connectionKey.mjs.map +1 -1
- package/dist/esm/connectionKey.native.js +6 -5
- package/dist/esm/connectionKey.native.js.map +1 -1
- package/dist/esm/core/http.mjs +383 -382
- package/dist/esm/core/http.mjs.map +1 -1
- package/dist/esm/core/http.native.js +590 -591
- package/dist/esm/core/http.native.js.map +1 -1
- package/dist/esm/core/serverMessages.mjs +34 -26
- package/dist/esm/core/serverMessages.mjs.map +1 -1
- package/dist/esm/core/serverMessages.native.js +55 -54
- package/dist/esm/core/serverMessages.native.js.map +1 -1
- package/dist/esm/core/sessionGate.mjs +79 -79
- package/dist/esm/core/sessionGate.mjs.map +1 -1
- package/dist/esm/core/sessionGate.native.js +205 -215
- package/dist/esm/core/sessionGate.native.js.map +1 -1
- package/dist/esm/core/types.mjs +23 -22
- package/dist/esm/core/types.mjs.map +1 -1
- package/dist/esm/core/types.native.js +114 -119
- package/dist/esm/core/types.native.js.map +1 -1
- package/dist/esm/core/wire.mjs +10 -9
- package/dist/esm/core/wire.mjs.map +1 -1
- package/dist/esm/core/wire.native.js +10 -9
- package/dist/esm/core/wire.native.js.map +1 -1
- package/dist/esm/db.mjs +421 -432
- package/dist/esm/db.mjs.map +1 -1
- package/dist/esm/db.native.js +570 -574
- package/dist/esm/db.native.js.map +1 -1
- package/dist/esm/devtools/FrappeDevtoolsPanel.mjs +762 -781
- package/dist/esm/devtools/FrappeDevtoolsPanel.mjs.map +1 -1
- package/dist/esm/devtools/FrappeDevtoolsPanel.native.js +808 -839
- package/dist/esm/devtools/FrappeDevtoolsPanel.native.js.map +1 -1
- package/dist/esm/devtools/index.mjs +2 -2
- package/dist/esm/devtools/index.native.js +2 -2
- package/dist/esm/devtools/plugin.mjs +10 -8
- package/dist/esm/devtools/plugin.mjs.map +1 -1
- package/dist/esm/devtools/plugin.native.js +14 -12
- package/dist/esm/devtools/plugin.native.js.map +1 -1
- package/dist/esm/devtools/theme.mjs +27 -26
- package/dist/esm/devtools/theme.mjs.map +1 -1
- package/dist/esm/devtools/theme.native.js +27 -26
- package/dist/esm/devtools/theme.native.js.map +1 -1
- package/dist/esm/doctype.mjs +473 -416
- package/dist/esm/doctype.mjs.map +1 -1
- package/dist/esm/doctype.native.js +566 -539
- package/dist/esm/doctype.native.js.map +1 -1
- package/dist/esm/file.mjs +15 -14
- package/dist/esm/file.mjs.map +1 -1
- package/dist/esm/file.native.js +45 -45
- package/dist/esm/file.native.js.map +1 -1
- package/dist/esm/fixtureDb.mjs +175 -191
- package/dist/esm/fixtureDb.mjs.map +1 -1
- package/dist/esm/fixtureDb.native.js +279 -283
- package/dist/esm/fixtureDb.native.js.map +1 -1
- package/dist/esm/fixtures.mjs +161 -175
- package/dist/esm/fixtures.mjs.map +1 -1
- package/dist/esm/fixtures.native.js +346 -364
- package/dist/esm/fixtures.native.js.map +1 -1
- package/dist/esm/frappeApp.mjs +82 -83
- package/dist/esm/frappeApp.mjs.map +1 -1
- package/dist/esm/frappeApp.native.js +141 -135
- package/dist/esm/frappeApp.native.js.map +1 -1
- package/dist/esm/frappeReact.mjs +535 -504
- package/dist/esm/frappeReact.mjs.map +1 -1
- package/dist/esm/frappeReact.native.js +615 -607
- package/dist/esm/frappeReact.native.js.map +1 -1
- package/dist/esm/index.gnome.mjs +5 -5
- package/dist/esm/index.gnome.native.js +5 -5
- package/dist/esm/index.mjs +17 -18
- package/dist/esm/index.native.js +17 -18
- package/dist/esm/optimistic.mjs +19 -19
- package/dist/esm/optimistic.mjs.map +1 -1
- package/dist/esm/optimistic.native.js +22 -22
- package/dist/esm/optimistic.native.js.map +1 -1
- package/dist/esm/pacer.mjs +156 -158
- package/dist/esm/pacer.mjs.map +1 -1
- package/dist/esm/pacer.native.js +220 -228
- package/dist/esm/pacer.native.js.map +1 -1
- package/dist/esm/plugin/index.mjs +91 -94
- package/dist/esm/plugin/index.mjs.map +1 -1
- package/dist/esm/plugin/index.native.js +151 -160
- package/dist/esm/plugin/index.native.js.map +1 -1
- package/dist/esm/realtime.mjs +569 -594
- package/dist/esm/realtime.mjs.map +1 -1
- package/dist/esm/realtime.native.js +905 -912
- package/dist/esm/realtime.native.js.map +1 -1
- package/dist/esm/serverLoaders.mjs +47 -61
- package/dist/esm/serverLoaders.mjs.map +1 -1
- package/dist/esm/serverLoaders.native.js +56 -75
- package/dist/esm/serverLoaders.native.js.map +1 -1
- package/dist/esm/sync/backfill.mjs +268 -284
- package/dist/esm/sync/backfill.mjs.map +1 -1
- package/dist/esm/sync/backfill.native.js +435 -448
- package/dist/esm/sync/backfill.native.js.map +1 -1
- package/dist/esm/sync/filters.mjs +286 -241
- package/dist/esm/sync/filters.mjs.map +1 -1
- package/dist/esm/sync/filters.native.js +403 -373
- package/dist/esm/sync/filters.native.js.map +1 -1
- package/dist/esm/sync/index.mjs +465 -479
- package/dist/esm/sync/index.mjs.map +1 -1
- package/dist/esm/sync/index.native.js +726 -720
- package/dist/esm/sync/index.native.js.map +1 -1
- package/dist/esm/sync/merge.mjs +368 -366
- package/dist/esm/sync/merge.mjs.map +1 -1
- package/dist/esm/sync/merge.native.js +618 -647
- package/dist/esm/sync/merge.native.js.map +1 -1
- package/dist/esm/sync/mutationEngine.mjs +775 -814
- package/dist/esm/sync/mutationEngine.mjs.map +1 -1
- package/dist/esm/sync/mutationEngine.native.js +1152 -1202
- package/dist/esm/sync/mutationEngine.native.js.map +1 -1
- package/dist/esm/sync/mutationJournal.mjs +135 -133
- package/dist/esm/sync/mutationJournal.mjs.map +1 -1
- package/dist/esm/sync/mutationJournal.native.js +265 -253
- package/dist/esm/sync/mutationJournal.native.js.map +1 -1
- package/dist/esm/sync/normalizedCache.mjs +115 -117
- package/dist/esm/sync/normalizedCache.mjs.map +1 -1
- package/dist/esm/sync/normalizedCache.native.js +199 -195
- package/dist/esm/sync/normalizedCache.native.js.map +1 -1
- package/dist/esm/sync/persistence.mjs +637 -645
- package/dist/esm/sync/persistence.mjs.map +1 -1
- package/dist/esm/sync/persistence.native.js +954 -949
- package/dist/esm/sync/persistence.native.js.map +1 -1
- package/dist/esm/sync/realtime.mjs +296 -298
- package/dist/esm/sync/realtime.mjs.map +1 -1
- package/dist/esm/sync/realtime.native.js +453 -444
- package/dist/esm/sync/realtime.native.js.map +1 -1
- package/dist/esm/sync/rehydration.mjs +268 -304
- package/dist/esm/sync/rehydration.mjs.map +1 -1
- package/dist/esm/sync/rehydration.native.js +461 -498
- package/dist/esm/sync/rehydration.native.js.map +1 -1
- package/dist/esm/sync/storage.mjs +115 -113
- package/dist/esm/sync/storage.mjs.map +1 -1
- package/dist/esm/sync/storage.native.js +175 -168
- package/dist/esm/sync/storage.native.js.map +1 -1
- package/dist/esm/sync/subscriptionManager.mjs +675 -691
- package/dist/esm/sync/subscriptionManager.mjs.map +1 -1
- package/dist/esm/sync/subscriptionManager.native.js +1168 -1204
- package/dist/esm/sync/subscriptionManager.native.js.map +1 -1
- package/dist/esm/sync/types.mjs +56 -55
- package/dist/esm/sync/types.mjs.map +1 -1
- package/dist/esm/sync/types.native.js +66 -65
- package/dist/esm/sync/types.native.js.map +1 -1
- package/dist/esm/sync/virtualPageManager.mjs +749 -789
- package/dist/esm/sync/virtualPageManager.mjs.map +1 -1
- package/dist/esm/sync/virtualPageManager.native.js +1058 -1080
- package/dist/esm/sync/virtualPageManager.native.js.map +1 -1
- package/dist/esm/syncOptionsKey.mjs +25 -27
- package/dist/esm/syncOptionsKey.mjs.map +1 -1
- package/dist/esm/syncOptionsKey.native.js +38 -46
- package/dist/esm/syncOptionsKey.native.js.map +1 -1
- package/dist/esm/useLiveQuery.mjs +2 -2
- package/dist/esm/useLiveQuery.native.js +2 -2
- package/dist/esm/util.mjs +9 -7
- package/dist/esm/util.mjs.map +1 -1
- package/dist/esm/util.native.js +8 -11
- package/dist/esm/util.native.js.map +1 -1
- package/dist/jsx/auth.mjs +22 -27
- package/dist/jsx/auth.mjs.map +1 -1
- package/dist/jsx/auth.native.cjs +97 -0
- package/dist/jsx/auth.native.js +77 -82
- package/dist/jsx/auth.native.js.map +1 -1
- package/dist/jsx/call.mjs +19 -18
- package/dist/jsx/call.mjs.map +1 -1
- package/dist/jsx/call.native.cjs +92 -0
- package/dist/jsx/call.native.js +72 -71
- package/dist/jsx/call.native.js.map +1 -1
- package/dist/jsx/collection.mjs +228 -268
- package/dist/jsx/collection.mjs.map +1 -1
- package/dist/jsx/collection.native.cjs +461 -0
- package/dist/jsx/collection.native.js +436 -499
- package/dist/jsx/collection.native.js.map +1 -1
- package/dist/jsx/common/types.mjs +0 -2
- package/dist/jsx/common/types.native.cjs +18 -0
- package/dist/jsx/common/types.native.js +9 -10
- package/dist/jsx/common/types.native.js.map +1 -1
- package/dist/jsx/connectionKey.mjs +5 -4
- package/dist/jsx/connectionKey.mjs.map +1 -1
- package/dist/jsx/connectionKey.native.cjs +32 -0
- package/dist/jsx/connectionKey.native.js +19 -22
- package/dist/jsx/connectionKey.native.js.map +1 -1
- package/dist/jsx/core/http.mjs +383 -382
- package/dist/jsx/core/http.mjs.map +1 -1
- package/dist/jsx/core/http.native.cjs +659 -0
- package/dist/jsx/core/http.native.js +611 -615
- package/dist/jsx/core/http.native.js.map +1 -1
- package/dist/jsx/core/serverMessages.mjs +34 -26
- package/dist/jsx/core/serverMessages.mjs.map +1 -1
- package/dist/jsx/core/serverMessages.native.cjs +89 -0
- package/dist/jsx/core/serverMessages.native.js +69 -70
- package/dist/jsx/core/serverMessages.native.js.map +1 -1
- package/dist/jsx/core/sessionGate.mjs +79 -79
- package/dist/jsx/core/sessionGate.mjs.map +1 -1
- package/dist/jsx/core/sessionGate.native.cjs +270 -0
- package/dist/jsx/core/sessionGate.native.js +220 -232
- package/dist/jsx/core/sessionGate.native.js.map +1 -1
- package/dist/jsx/core/types.mjs +23 -22
- package/dist/jsx/core/types.mjs.map +1 -1
- package/dist/jsx/core/types.native.cjs +169 -0
- package/dist/jsx/core/types.native.js +129 -136
- package/dist/jsx/core/types.native.js.map +1 -1
- package/dist/jsx/core/wire.mjs +10 -9
- package/dist/jsx/core/wire.mjs.map +1 -1
- package/dist/jsx/core/wire.native.cjs +53 -0
- package/dist/jsx/core/wire.native.js +28 -29
- package/dist/jsx/core/wire.native.js.map +1 -1
- package/dist/jsx/db.mjs +421 -432
- package/dist/jsx/db.mjs.map +1 -1
- package/dist/jsx/db.native.cjs +625 -0
- package/dist/jsx/db.native.js +583 -590
- package/dist/jsx/db.native.js.map +1 -1
- package/dist/jsx/devtools/FrappeDevtoolsPanel.mjs +762 -781
- package/dist/jsx/devtools/FrappeDevtoolsPanel.mjs.map +1 -1
- package/dist/jsx/devtools/FrappeDevtoolsPanel.native.cjs +878 -0
- package/dist/jsx/devtools/FrappeDevtoolsPanel.native.js +821 -862
- package/dist/jsx/devtools/FrappeDevtoolsPanel.native.js.map +1 -1
- package/dist/jsx/devtools/index.mjs +2 -2
- package/dist/jsx/devtools/index.native.cjs +30 -0
- package/dist/jsx/devtools/index.native.js +15 -16
- package/dist/jsx/devtools/index.native.js.map +1 -1
- package/dist/jsx/devtools/plugin.mjs +10 -8
- package/dist/jsx/devtools/plugin.mjs.map +1 -1
- package/dist/jsx/devtools/plugin.native.cjs +46 -0
- package/dist/jsx/devtools/plugin.native.js +27 -35
- package/dist/jsx/devtools/plugin.native.js.map +1 -1
- package/dist/jsx/devtools/theme.mjs +27 -26
- package/dist/jsx/devtools/theme.mjs.map +1 -1
- package/dist/jsx/devtools/theme.native.cjs +53 -0
- package/dist/jsx/devtools/theme.native.js +40 -43
- package/dist/jsx/devtools/theme.native.js.map +1 -1
- package/dist/jsx/doctype.mjs +473 -416
- package/dist/jsx/doctype.mjs.map +1 -1
- package/dist/jsx/doctype.native.cjs +631 -0
- package/dist/jsx/doctype.native.js +587 -563
- package/dist/jsx/doctype.native.js.map +1 -1
- package/dist/jsx/file.mjs +15 -14
- package/dist/jsx/file.mjs.map +1 -1
- package/dist/jsx/file.native.cjs +78 -0
- package/dist/jsx/file.native.js +58 -62
- package/dist/jsx/file.native.js.map +1 -1
- package/dist/jsx/fixtureDb.mjs +175 -191
- package/dist/jsx/fixtureDb.mjs.map +1 -1
- package/dist/jsx/fixtureDb.native.cjs +313 -0
- package/dist/jsx/fixtureDb.native.js +291 -300
- package/dist/jsx/fixtureDb.native.js.map +1 -1
- package/dist/jsx/fixtures.mjs +161 -175
- package/dist/jsx/fixtures.mjs.map +1 -1
- package/dist/jsx/fixtures.native.cjs +379 -0
- package/dist/jsx/fixtures.native.js +359 -381
- package/dist/jsx/fixtures.native.js.map +1 -1
- package/dist/jsx/frappeApp.mjs +82 -83
- package/dist/jsx/frappeApp.mjs.map +1 -1
- package/dist/jsx/frappeApp.native.cjs +181 -0
- package/dist/jsx/frappeApp.native.js +153 -152
- package/dist/jsx/frappeApp.native.js.map +1 -1
- package/dist/jsx/frappeReact.mjs +535 -504
- package/dist/jsx/frappeReact.mjs.map +1 -1
- package/dist/jsx/frappeReact.native.cjs +710 -0
- package/dist/jsx/frappeReact.native.js +636 -631
- package/dist/jsx/frappeReact.native.js.map +1 -1
- package/dist/jsx/index.gnome.mjs +5 -5
- package/dist/jsx/index.gnome.native.cjs +87 -0
- package/dist/jsx/index.gnome.native.js +61 -62
- package/dist/jsx/index.gnome.native.js.map +1 -1
- package/dist/jsx/index.js +17 -18
- package/dist/jsx/index.mjs +17 -18
- package/dist/jsx/index.native.cjs +171 -0
- package/dist/jsx/index.native.js +128 -134
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/optimistic.mjs +19 -19
- package/dist/jsx/optimistic.mjs.map +1 -1
- package/dist/jsx/optimistic.native.cjs +59 -0
- package/dist/jsx/optimistic.native.js +38 -41
- package/dist/jsx/optimistic.native.js.map +1 -1
- package/dist/jsx/pacer.mjs +156 -158
- package/dist/jsx/pacer.mjs.map +1 -1
- package/dist/jsx/pacer.native.cjs +263 -0
- package/dist/jsx/pacer.native.js +234 -245
- package/dist/jsx/pacer.native.js.map +1 -1
- package/dist/jsx/plugin/index.mjs +91 -94
- package/dist/jsx/plugin/index.mjs.map +1 -1
- package/dist/jsx/plugin/index.native.cjs +178 -0
- package/dist/jsx/plugin/index.native.js +164 -177
- package/dist/jsx/plugin/index.native.js.map +1 -1
- package/dist/jsx/realtime.mjs +569 -594
- package/dist/jsx/realtime.mjs.map +1 -1
- package/dist/jsx/realtime.native.cjs +945 -0
- package/dist/jsx/realtime.native.js +918 -928
- package/dist/jsx/realtime.native.js.map +1 -1
- package/dist/jsx/serverLoaders.mjs +47 -61
- package/dist/jsx/serverLoaders.mjs.map +1 -1
- package/dist/jsx/serverLoaders.native.cjs +103 -0
- package/dist/jsx/serverLoaders.native.js +73 -95
- package/dist/jsx/serverLoaders.native.js.map +1 -1
- package/dist/jsx/sync/backfill.mjs +268 -284
- package/dist/jsx/sync/backfill.mjs.map +1 -1
- package/dist/jsx/sync/backfill.native.cjs +475 -0
- package/dist/jsx/sync/backfill.native.js +449 -465
- package/dist/jsx/sync/backfill.native.js.map +1 -1
- package/dist/jsx/sync/filters.mjs +286 -241
- package/dist/jsx/sync/filters.mjs.map +1 -1
- package/dist/jsx/sync/filters.native.cjs +472 -0
- package/dist/jsx/sync/filters.native.js +426 -398
- package/dist/jsx/sync/filters.native.js.map +1 -1
- package/dist/jsx/sync/index.mjs +465 -479
- package/dist/jsx/sync/index.mjs.map +1 -1
- package/dist/jsx/sync/index.native.cjs +771 -0
- package/dist/jsx/sync/index.native.js +738 -737
- package/dist/jsx/sync/index.native.js.map +1 -1
- package/dist/jsx/sync/merge.mjs +368 -366
- package/dist/jsx/sync/merge.mjs.map +1 -1
- package/dist/jsx/sync/merge.native.cjs +681 -0
- package/dist/jsx/sync/merge.native.js +642 -673
- package/dist/jsx/sync/merge.native.js.map +1 -1
- package/dist/jsx/sync/mutationEngine.mjs +775 -814
- package/dist/jsx/sync/mutationEngine.mjs.map +1 -1
- package/dist/jsx/sync/mutationEngine.native.cjs +1190 -0
- package/dist/jsx/sync/mutationEngine.native.js +1162 -1216
- package/dist/jsx/sync/mutationEngine.native.js.map +1 -1
- package/dist/jsx/sync/mutationJournal.mjs +135 -133
- package/dist/jsx/sync/mutationJournal.mjs.map +1 -1
- package/dist/jsx/sync/mutationJournal.native.cjs +302 -0
- package/dist/jsx/sync/mutationJournal.native.js +278 -269
- package/dist/jsx/sync/mutationJournal.native.js.map +1 -1
- package/dist/jsx/sync/normalizedCache.mjs +115 -117
- package/dist/jsx/sync/normalizedCache.mjs.map +1 -1
- package/dist/jsx/sync/normalizedCache.native.cjs +232 -0
- package/dist/jsx/sync/normalizedCache.native.js +212 -212
- package/dist/jsx/sync/normalizedCache.native.js.map +1 -1
- package/dist/jsx/sync/persistence.mjs +637 -645
- package/dist/jsx/sync/persistence.mjs.map +1 -1
- package/dist/jsx/sync/persistence.native.cjs +996 -0
- package/dist/jsx/sync/persistence.native.js +967 -965
- package/dist/jsx/sync/persistence.native.js.map +1 -1
- package/dist/jsx/sync/realtime.mjs +296 -298
- package/dist/jsx/sync/realtime.mjs.map +1 -1
- package/dist/jsx/sync/realtime.native.cjs +486 -0
- package/dist/jsx/sync/realtime.native.js +465 -461
- package/dist/jsx/sync/realtime.native.js.map +1 -1
- package/dist/jsx/sync/rehydration.mjs +268 -304
- package/dist/jsx/sync/rehydration.mjs.map +1 -1
- package/dist/jsx/sync/rehydration.native.cjs +495 -0
- package/dist/jsx/sync/rehydration.native.js +473 -515
- package/dist/jsx/sync/rehydration.native.js.map +1 -1
- package/dist/jsx/sync/storage.mjs +115 -113
- package/dist/jsx/sync/storage.mjs.map +1 -1
- package/dist/jsx/sync/storage.native.cjs +211 -0
- package/dist/jsx/sync/storage.native.js +188 -184
- package/dist/jsx/sync/storage.native.js.map +1 -1
- package/dist/jsx/sync/subscriptionManager.mjs +675 -691
- package/dist/jsx/sync/subscriptionManager.mjs.map +1 -1
- package/dist/jsx/sync/subscriptionManager.native.cjs +1205 -0
- package/dist/jsx/sync/subscriptionManager.native.js +1179 -1220
- package/dist/jsx/sync/subscriptionManager.native.js.map +1 -1
- package/dist/jsx/sync/types.mjs +56 -55
- package/dist/jsx/sync/types.mjs.map +1 -1
- package/dist/jsx/sync/types.native.cjs +103 -0
- package/dist/jsx/sync/types.native.js +89 -90
- package/dist/jsx/sync/types.native.js.map +1 -1
- package/dist/jsx/sync/virtualPageManager.mjs +749 -789
- package/dist/jsx/sync/virtualPageManager.mjs.map +1 -1
- package/dist/jsx/sync/virtualPageManager.native.cjs +1097 -0
- package/dist/jsx/sync/virtualPageManager.native.js +1072 -1097
- package/dist/jsx/sync/virtualPageManager.native.js.map +1 -1
- package/dist/jsx/syncOptionsKey.mjs +25 -27
- package/dist/jsx/syncOptionsKey.mjs.map +1 -1
- package/dist/jsx/syncOptionsKey.native.cjs +69 -0
- package/dist/jsx/syncOptionsKey.native.js +51 -63
- package/dist/jsx/syncOptionsKey.native.js.map +1 -1
- package/dist/jsx/useLiveQuery.mjs +2 -2
- package/dist/jsx/useLiveQuery.native.cjs +26 -0
- package/dist/jsx/useLiveQuery.native.js +14 -17
- package/dist/jsx/useLiveQuery.native.js.map +1 -1
- package/dist/jsx/util.mjs +9 -7
- package/dist/jsx/util.mjs.map +1 -1
- package/dist/jsx/util.native.cjs +40 -0
- package/dist/jsx/util.native.js +22 -28
- package/dist/jsx/util.native.js.map +1 -1
- package/package.json +10 -10
- package/src/devtools/FrappeDevtoolsPanel.stories.tsx +16 -16
- package/src/devtools/plugin.stories.tsx +4 -4
- package/src/useFrappeCollection.stories.tsx +14 -14
- package/src/useFrappeInfiniteList.stories.tsx +11 -11
- package/src/useFrappePendingMutations.stories.tsx +12 -12
- package/types/devtools/FrappeDevtoolsPanel.d.ts +2 -1
- package/types/devtools/FrappeDevtoolsPanel.d.ts.map +1 -1
- package/types/devtools/plugin.d.ts +2 -1
- package/types/devtools/plugin.d.ts.map +1 -1
- package/dist/esm/common/types.mjs.map +0 -1
- package/dist/esm/common/types.native.js.map +0 -1
- package/dist/esm/devtools/index.mjs.map +0 -1
- package/dist/esm/devtools/index.native.js.map +0 -1
- package/dist/esm/index.gnome.mjs.map +0 -1
- package/dist/esm/index.gnome.native.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/useLiveQuery.mjs.map +0 -1
- package/dist/esm/useLiveQuery.native.js.map +0 -1
- package/dist/jsx/common/types.mjs.map +0 -1
- package/dist/jsx/devtools/index.mjs.map +0 -1
- package/dist/jsx/index.gnome.mjs.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
- package/dist/jsx/useLiveQuery.mjs.map +0 -1
|
@@ -5,1244 +5,1203 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 subscriptionManager_exports = {};
|
|
26
|
-
__export(subscriptionManager_exports, {
|
|
27
|
-
SubscriptionManager: () => SubscriptionManager
|
|
28
|
-
});
|
|
24
|
+
__export(subscriptionManager_exports, { SubscriptionManager: () => SubscriptionManager });
|
|
29
25
|
module.exports = __toCommonJS(subscriptionManager_exports);
|
|
30
26
|
var import_backfill = require("./backfill.native.js");
|
|
31
27
|
var import_filters = require("./filters.native.js");
|
|
32
28
|
var import_types = require("./types.native.js");
|
|
33
29
|
var import_virtualPageManager = require("./virtualPageManager.native.js");
|
|
34
30
|
function _class_call_check(instance, Constructor) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
if (!(instance instanceof Constructor)) {
|
|
32
|
+
throw new TypeError("Cannot call a class as a function");
|
|
33
|
+
}
|
|
38
34
|
}
|
|
39
35
|
function _defineProperties(target, props) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
for (var i = 0; i < props.length; i++) {
|
|
37
|
+
var descriptor = props[i];
|
|
38
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
39
|
+
descriptor.configurable = true;
|
|
40
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
41
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
42
|
+
}
|
|
47
43
|
}
|
|
48
44
|
function _create_class(Constructor, protoProps, staticProps) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
46
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
47
|
+
return Constructor;
|
|
52
48
|
}
|
|
53
49
|
function _define_property(obj, key, value) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
function _type_of(obj) {
|
|
67
|
-
"@swc/helpers - typeof";
|
|
68
|
-
|
|
69
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
50
|
+
if (key in obj) {
|
|
51
|
+
Object.defineProperty(obj, key, {
|
|
52
|
+
value,
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
obj[key] = value;
|
|
59
|
+
}
|
|
60
|
+
return obj;
|
|
70
61
|
}
|
|
71
62
|
var _this_options_pageSize;
|
|
72
|
-
var SubscriptionManager = /* @__PURE__ */
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
_didIteratorError2 = true;
|
|
1210
|
-
_iteratorError2 = err;
|
|
1211
|
-
} finally {
|
|
1212
|
-
try {
|
|
1213
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
1214
|
-
_iterator2.return();
|
|
1215
|
-
}
|
|
1216
|
-
} finally {
|
|
1217
|
-
if (_didIteratorError2) {
|
|
1218
|
-
throw _iteratorError2;
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
} catch (err) {
|
|
1225
|
-
_didIteratorError = true;
|
|
1226
|
-
_iteratorError = err;
|
|
1227
|
-
} finally {
|
|
1228
|
-
try {
|
|
1229
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1230
|
-
_iterator.return();
|
|
1231
|
-
}
|
|
1232
|
-
} finally {
|
|
1233
|
-
if (_didIteratorError) {
|
|
1234
|
-
throw _iteratorError;
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
}]);
|
|
1240
|
-
return SubscriptionManager2;
|
|
1241
|
-
}();
|
|
63
|
+
var SubscriptionManager = /* @__PURE__ */ (function() {
|
|
64
|
+
"use strict";
|
|
65
|
+
function SubscriptionManager2(db, normalizedCache) {
|
|
66
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
67
|
+
_class_call_check(this, SubscriptionManager2);
|
|
68
|
+
_define_property(this, "refreshes", /* @__PURE__ */ new Map());
|
|
69
|
+
_define_property(this, "subscriptions", /* @__PURE__ */ new Map());
|
|
70
|
+
_define_property(this, "virtualPageManager", void 0);
|
|
71
|
+
_define_property(this, "backfillManager", void 0);
|
|
72
|
+
_define_property(this, "queryKeyToSubId", /* @__PURE__ */ new Map());
|
|
73
|
+
_define_property(this, "subRefCounts", /* @__PURE__ */ new Map());
|
|
74
|
+
_define_property(this, "restoredByQueryKey", /* @__PURE__ */ new Map());
|
|
75
|
+
_define_property(this, "restoredAt", /* @__PURE__ */ new Map());
|
|
76
|
+
_define_property(this, "db", void 0);
|
|
77
|
+
_define_property(this, "normalizedCache", void 0);
|
|
78
|
+
_define_property(this, "options", void 0);
|
|
79
|
+
this.db = db;
|
|
80
|
+
this.normalizedCache = normalizedCache;
|
|
81
|
+
this.options = options;
|
|
82
|
+
this.virtualPageManager = new import_virtualPageManager.VirtualPageManager(this.normalizedCache, this.db, { batchSize: this.options.batchSize });
|
|
83
|
+
this.backfillManager = new import_backfill.BackfillManager(this.db, this.normalizedCache, {
|
|
84
|
+
pageSize: this.options.pageSize,
|
|
85
|
+
maxPages: this.options.backfillMaxPages
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
_create_class(SubscriptionManager2, [
|
|
89
|
+
{
|
|
90
|
+
key: "subscribe",
|
|
91
|
+
value: async function subscribe(query) {
|
|
92
|
+
var queryKey = JSON.stringify(query);
|
|
93
|
+
var existingId = this.queryKeyToSubId.get(queryKey);
|
|
94
|
+
if (existingId && this.subscriptions.has(existingId)) {
|
|
95
|
+
this.subRefCounts.set(existingId, (this.subRefCounts.get(existingId) || 1) + 1);
|
|
96
|
+
var rows = this.getDocsForSubscription(existingId);
|
|
97
|
+
var checkpoint = this.subscriptions.get(existingId).checkpoint;
|
|
98
|
+
return {
|
|
99
|
+
subscriptionId: existingId,
|
|
100
|
+
rows,
|
|
101
|
+
checkpoint
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
var adopted = this.adoptRestoredSubscription(queryKey, query);
|
|
105
|
+
if (adopted) return adopted;
|
|
106
|
+
var subscriptionId = cryptoRandomId();
|
|
107
|
+
var { rows: rows1, cursor, checkpoint: checkpoint1 } = await this.fetchInitialRows(query);
|
|
108
|
+
this.seedRows(query, rows1);
|
|
109
|
+
var subscription = {
|
|
110
|
+
id: subscriptionId,
|
|
111
|
+
query,
|
|
112
|
+
checkpoint: checkpoint1,
|
|
113
|
+
cursor,
|
|
114
|
+
docIds: rows1.map(function(row) {
|
|
115
|
+
return row.name;
|
|
116
|
+
}),
|
|
117
|
+
tombstones: /* @__PURE__ */ new Map()
|
|
118
|
+
};
|
|
119
|
+
if (rows1.length > 0) {
|
|
120
|
+
var _query_limitStart, _query_limit;
|
|
121
|
+
subscription.boundaries = {
|
|
122
|
+
firstItem: rows1[0],
|
|
123
|
+
lastItem: rows1[rows1.length - 1],
|
|
124
|
+
offset: (_query_limitStart = query.limitStart) !== null && _query_limitStart !== void 0 ? _query_limitStart : 0,
|
|
125
|
+
pageSize: (_query_limit = query.limit) !== null && _query_limit !== void 0 ? _query_limit : import_types.defaultPageLength
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
subscription.metadata = {
|
|
129
|
+
itemsBeforePage: 0,
|
|
130
|
+
itemsAfterPage: 0
|
|
131
|
+
};
|
|
132
|
+
this.subscriptions.set(subscriptionId, subscription);
|
|
133
|
+
this.queryKeyToSubId.set(queryKey, subscriptionId);
|
|
134
|
+
this.subRefCounts.set(subscriptionId, 1);
|
|
135
|
+
if (query.progressive) {
|
|
136
|
+
this.virtualPageManager.registerSubscription(subscriptionId, subscription, subscription.docIds, cursor);
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
subscriptionId,
|
|
140
|
+
rows: rows1,
|
|
141
|
+
checkpoint: checkpoint1
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
key: "refreshSubscriptions",
|
|
147
|
+
value: async function refreshSubscriptions() {
|
|
148
|
+
var _this = this;
|
|
149
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
150
|
+
var subscriptions = [...this.subscriptions.values()].filter(function(subscription) {
|
|
151
|
+
var _this_subRefCounts_get;
|
|
152
|
+
return ((_this_subRefCounts_get = _this.subRefCounts.get(subscription.id)) !== null && _this_subRefCounts_get !== void 0 ? _this_subRefCounts_get : 0) > 0 && (!options.doctypes || options.doctypes.includes(subscription.query.doctype));
|
|
153
|
+
});
|
|
154
|
+
return Promise.all(subscriptions.map(function(subscription) {
|
|
155
|
+
return _this.refreshSubscription(subscription);
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
key: "refreshSubscription",
|
|
161
|
+
value: function refreshSubscription(subscription) {
|
|
162
|
+
var _this = this;
|
|
163
|
+
var subscriptionId = subscription.id;
|
|
164
|
+
if (subscription.query.progressive) {
|
|
165
|
+
return Promise.resolve({
|
|
166
|
+
subscriptionId,
|
|
167
|
+
ok: false,
|
|
168
|
+
error: new Error("Snapshot refresh does not support progressive subscriptions")
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
var existing = this.refreshes.get(subscriptionId);
|
|
172
|
+
if (existing) {
|
|
173
|
+
existing.requested = true;
|
|
174
|
+
return existing.promise;
|
|
175
|
+
}
|
|
176
|
+
var state = {
|
|
177
|
+
requested: false,
|
|
178
|
+
promise: Promise.resolve({
|
|
179
|
+
subscriptionId,
|
|
180
|
+
ok: false
|
|
181
|
+
})
|
|
182
|
+
};
|
|
183
|
+
var active = function active2() {
|
|
184
|
+
var _this_subRefCounts_get;
|
|
185
|
+
return _this.refreshes.get(subscriptionId) === state && _this.subscriptions.get(subscriptionId) === subscription && ((_this_subRefCounts_get = _this.subRefCounts.get(subscriptionId)) !== null && _this_subRefCounts_get !== void 0 ? _this_subRefCounts_get : 0) > 0;
|
|
186
|
+
};
|
|
187
|
+
state.promise = Promise.resolve().then(async function() {
|
|
188
|
+
try {
|
|
189
|
+
while (true) {
|
|
190
|
+
state.requested = false;
|
|
191
|
+
try {
|
|
192
|
+
var _subscription_query_limitStart, _subscription_query_limit;
|
|
193
|
+
var { rows, cursor, checkpoint } = await _this.fetchInitialRows(subscription.query);
|
|
194
|
+
if (!active()) {
|
|
195
|
+
return {
|
|
196
|
+
subscriptionId,
|
|
197
|
+
ok: false,
|
|
198
|
+
error: new Error("Subscription is no longer active")
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
if (state.requested) continue;
|
|
202
|
+
_this.seedRows(subscription.query, rows);
|
|
203
|
+
subscription.docIds = rows.map(function(row) {
|
|
204
|
+
return row.name;
|
|
205
|
+
});
|
|
206
|
+
subscription.cursor = cursor;
|
|
207
|
+
subscription.checkpoint = checkpoint;
|
|
208
|
+
subscription.boundaries = rows.length ? {
|
|
209
|
+
firstItem: rows[0],
|
|
210
|
+
lastItem: rows[rows.length - 1],
|
|
211
|
+
offset: (_subscription_query_limitStart = subscription.query.limitStart) !== null && _subscription_query_limitStart !== void 0 ? _subscription_query_limitStart : 0,
|
|
212
|
+
pageSize: (_subscription_query_limit = subscription.query.limit) !== null && _subscription_query_limit !== void 0 ? _subscription_query_limit : import_types.defaultPageLength
|
|
213
|
+
} : void 0;
|
|
214
|
+
subscription.metadata = {
|
|
215
|
+
itemsBeforePage: 0,
|
|
216
|
+
itemsAfterPage: 0
|
|
217
|
+
};
|
|
218
|
+
subscription.stale = false;
|
|
219
|
+
return {
|
|
220
|
+
subscriptionId,
|
|
221
|
+
ok: true
|
|
222
|
+
};
|
|
223
|
+
} catch (error) {
|
|
224
|
+
if (active() && state.requested) continue;
|
|
225
|
+
if (active()) subscription.stale = true;
|
|
226
|
+
return {
|
|
227
|
+
subscriptionId,
|
|
228
|
+
ok: false,
|
|
229
|
+
error
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
} finally {
|
|
234
|
+
if (_this.refreshes.get(subscriptionId) === state) _this.refreshes.delete(subscriptionId);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
this.refreshes.set(subscriptionId, state);
|
|
238
|
+
return state.promise;
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
key: "fetchInitialRows",
|
|
243
|
+
value: (
|
|
244
|
+
/**
|
|
245
|
+
* Performs the initial subscription fetch (single doc via getDoc, lists via
|
|
246
|
+
* getDocList) and computes the CDC checkpoint
|
|
247
|
+
* as the max `modified` across returned rows. Shared by fresh subscribes
|
|
248
|
+
* and adopted-subscription refreshes so both have identical semantics.
|
|
249
|
+
*/
|
|
250
|
+
async function fetchInitialRows(query) {
|
|
251
|
+
var _query_fields;
|
|
252
|
+
var queryFields = ((_query_fields = query.fields) === null || _query_fields === void 0 ? void 0 : _query_fields.length) ? Array.from(/* @__PURE__ */ new Set([
|
|
253
|
+
...query.fields,
|
|
254
|
+
"modified",
|
|
255
|
+
"name"
|
|
256
|
+
])) : void 0;
|
|
257
|
+
var rows = [];
|
|
258
|
+
var cursor;
|
|
259
|
+
var singleName = (0, import_filters.extractSingleName)(query.filters);
|
|
260
|
+
if (singleName) {
|
|
261
|
+
try {
|
|
262
|
+
var document = await this.db.getDoc(query.doctype, singleName);
|
|
263
|
+
rows = document ? [document] : [];
|
|
264
|
+
} catch (error) {
|
|
265
|
+
var errorWithStatus = error;
|
|
266
|
+
if ((errorWithStatus === null || errorWithStatus === void 0 ? void 0 : errorWithStatus.status) === 404) {
|
|
267
|
+
rows = [];
|
|
268
|
+
} else {
|
|
269
|
+
throw error;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
var _query_limit;
|
|
274
|
+
var listOptions = {
|
|
275
|
+
fields: queryFields,
|
|
276
|
+
filters: query.filters,
|
|
277
|
+
orderBy: query.orderBy
|
|
278
|
+
};
|
|
279
|
+
listOptions.limit = (_query_limit = query.limit) !== null && _query_limit !== void 0 ? _query_limit : import_types.defaultPageLength;
|
|
280
|
+
if (query.limitStart != null) listOptions.limitStart = query.limitStart;
|
|
281
|
+
if (this.options.useCursorPagination) listOptions.cursor = void 0;
|
|
282
|
+
var response = await this.db.getDocList(query.doctype, listOptions);
|
|
283
|
+
if (typeof response === "object" && response !== null && "data" in response) {
|
|
284
|
+
rows = response.data;
|
|
285
|
+
cursor = response.cursor;
|
|
286
|
+
} else {
|
|
287
|
+
rows = response;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
var checkpoint = void 0;
|
|
291
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
292
|
+
try {
|
|
293
|
+
for (var _iterator = rows[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
294
|
+
var row = _step.value;
|
|
295
|
+
if (!row.modified) continue;
|
|
296
|
+
if (!checkpoint || row.modified > checkpoint) checkpoint = row.modified;
|
|
297
|
+
}
|
|
298
|
+
} catch (err) {
|
|
299
|
+
_didIteratorError = true;
|
|
300
|
+
_iteratorError = err;
|
|
301
|
+
} finally {
|
|
302
|
+
try {
|
|
303
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
304
|
+
_iterator.return();
|
|
305
|
+
}
|
|
306
|
+
} finally {
|
|
307
|
+
if (_didIteratorError) {
|
|
308
|
+
throw _iteratorError;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return {
|
|
313
|
+
rows,
|
|
314
|
+
cursor,
|
|
315
|
+
checkpoint
|
|
316
|
+
};
|
|
317
|
+
})
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
key: "seedRows",
|
|
321
|
+
value: function seedRows(query, rows) {
|
|
322
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
323
|
+
try {
|
|
324
|
+
for (var _iterator = rows[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
325
|
+
var row = _step.value;
|
|
326
|
+
if (!row.doctype) row.doctype = query.doctype;
|
|
327
|
+
this.normalizedCache.upsert(row);
|
|
328
|
+
}
|
|
329
|
+
} catch (err) {
|
|
330
|
+
_didIteratorError = true;
|
|
331
|
+
_iteratorError = err;
|
|
332
|
+
} finally {
|
|
333
|
+
try {
|
|
334
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
335
|
+
_iterator.return();
|
|
336
|
+
}
|
|
337
|
+
} finally {
|
|
338
|
+
if (_didIteratorError) {
|
|
339
|
+
throw _iteratorError;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
key: "adoptRestoredSubscription",
|
|
347
|
+
value: (
|
|
348
|
+
/**
|
|
349
|
+
* Re-adopts a subscription restored from a persisted snapshot when an
|
|
350
|
+
* identical query subscribes: the cached membership renders immediately and
|
|
351
|
+
* a background refresh re-seeds from the network. Progressive queries are
|
|
352
|
+
* excluded — their VirtualPageManager state is not persisted, so they take
|
|
353
|
+
* the fresh-subscribe path.
|
|
354
|
+
*/
|
|
355
|
+
function adoptRestoredSubscription(queryKey, query) {
|
|
356
|
+
if (query.progressive) return void 0;
|
|
357
|
+
var restoredId = this.restoredByQueryKey.get(queryKey);
|
|
358
|
+
if (!restoredId) return void 0;
|
|
359
|
+
var subscription = this.subscriptions.get(restoredId);
|
|
360
|
+
this.restoredByQueryKey.delete(queryKey);
|
|
361
|
+
this.restoredAt.delete(restoredId);
|
|
362
|
+
if (!subscription) return void 0;
|
|
363
|
+
this.queryKeyToSubId.set(queryKey, restoredId);
|
|
364
|
+
this.subRefCounts.set(restoredId, 1);
|
|
365
|
+
var refresh = this.refreshSubscription(subscription);
|
|
366
|
+
var rows = this.getDocsForSubscription(restoredId);
|
|
367
|
+
return {
|
|
368
|
+
subscriptionId: restoredId,
|
|
369
|
+
rows,
|
|
370
|
+
checkpoint: subscription.checkpoint,
|
|
371
|
+
refresh
|
|
372
|
+
};
|
|
373
|
+
})
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
/**
|
|
377
|
+
* Registers a subscription restored from a persisted snapshot. Restored
|
|
378
|
+
* subscriptions are dormant: they hold the persisted query, CDC checkpoint,
|
|
379
|
+
* and membership for cache-first re-adoption, but are skipped by backfill
|
|
380
|
+
* fan-out until adopted. Duplicate snapshot entries for the same query
|
|
381
|
+
* (accumulated by pre-GC versions) collapse last-wins.
|
|
382
|
+
*/
|
|
383
|
+
key: "restoreSubscription",
|
|
384
|
+
value: function restoreSubscription(snapshotSub) {
|
|
385
|
+
var _snapshotSub_query;
|
|
386
|
+
if (!(snapshotSub === null || snapshotSub === void 0 ? void 0 : snapshotSub.id) || !((_snapshotSub_query = snapshotSub.query) === null || _snapshotSub_query === void 0 ? void 0 : _snapshotSub_query.doctype)) return;
|
|
387
|
+
if (this.subscriptions.has(snapshotSub.id)) return;
|
|
388
|
+
var queryKey = JSON.stringify(snapshotSub.query);
|
|
389
|
+
var activeId = this.queryKeyToSubId.get(queryKey);
|
|
390
|
+
if (activeId && this.subscriptions.has(activeId)) return;
|
|
391
|
+
var previousId = this.restoredByQueryKey.get(queryKey);
|
|
392
|
+
if (previousId) {
|
|
393
|
+
this.subscriptions.delete(previousId);
|
|
394
|
+
this.restoredAt.delete(previousId);
|
|
395
|
+
}
|
|
396
|
+
var subscription = {
|
|
397
|
+
id: snapshotSub.id,
|
|
398
|
+
query: snapshotSub.query,
|
|
399
|
+
checkpoint: snapshotSub.checkpoint,
|
|
400
|
+
cursor: snapshotSub.cursor,
|
|
401
|
+
docIds: Array.isArray(snapshotSub.docIds) ? snapshotSub.docIds : [],
|
|
402
|
+
tombstones: /* @__PURE__ */ new Map(),
|
|
403
|
+
metadata: {
|
|
404
|
+
itemsBeforePage: 0,
|
|
405
|
+
itemsAfterPage: 0
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
this.subscriptions.set(subscription.id, subscription);
|
|
409
|
+
this.restoredByQueryKey.set(queryKey, subscription.id);
|
|
410
|
+
this.restoredAt.set(subscription.id, Date.now());
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
/** True when the subscription came from a snapshot and is not yet adopted. */
|
|
415
|
+
key: "isRestoredSubscription",
|
|
416
|
+
value: function isRestoredSubscription(subscriptionId) {
|
|
417
|
+
return this.restoredAt.has(subscriptionId);
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
/**
|
|
422
|
+
* Drops restored subscriptions that no query re-adopted within
|
|
423
|
+
* `restoredSubscriptionTTL` (default 30 minutes). Called before every
|
|
424
|
+
* persistence snapshot so expired entries also leave the snapshot.
|
|
425
|
+
*/
|
|
426
|
+
key: "gcRestoredSubscriptions",
|
|
427
|
+
value: function gcRestoredSubscriptions() {
|
|
428
|
+
var now = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Date.now();
|
|
429
|
+
var _this_options_restoredSubscriptionTTL;
|
|
430
|
+
var ttl = (_this_options_restoredSubscriptionTTL = this.options.restoredSubscriptionTTL) !== null && _this_options_restoredSubscriptionTTL !== void 0 ? _this_options_restoredSubscriptionTTL : 30 * 60 * 1e3;
|
|
431
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
432
|
+
try {
|
|
433
|
+
for (var _iterator = this.restoredAt[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
434
|
+
var [subscriptionId, restoredAtMs] = _step.value;
|
|
435
|
+
if (now - restoredAtMs <= ttl) continue;
|
|
436
|
+
this.restoredAt.delete(subscriptionId);
|
|
437
|
+
this.subscriptions.delete(subscriptionId);
|
|
438
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
439
|
+
try {
|
|
440
|
+
for (var _iterator1 = this.restoredByQueryKey[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
441
|
+
var [key, id] = _step1.value;
|
|
442
|
+
if (id === subscriptionId) {
|
|
443
|
+
this.restoredByQueryKey.delete(key);
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
} catch (err) {
|
|
448
|
+
_didIteratorError1 = true;
|
|
449
|
+
_iteratorError1 = err;
|
|
450
|
+
} finally {
|
|
451
|
+
try {
|
|
452
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
453
|
+
_iterator1.return();
|
|
454
|
+
}
|
|
455
|
+
} finally {
|
|
456
|
+
if (_didIteratorError1) {
|
|
457
|
+
throw _iteratorError1;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
} catch (err) {
|
|
463
|
+
_didIteratorError = true;
|
|
464
|
+
_iteratorError = err;
|
|
465
|
+
} finally {
|
|
466
|
+
try {
|
|
467
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
468
|
+
_iterator.return();
|
|
469
|
+
}
|
|
470
|
+
} finally {
|
|
471
|
+
if (_didIteratorError) {
|
|
472
|
+
throw _iteratorError;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
/**
|
|
480
|
+
* Removes a subscription by id. Cached docs remain until evicted by
|
|
481
|
+
* realtime/backfill or explicit resets. This keeps other subs fast if they
|
|
482
|
+
* share the same doctypes.
|
|
483
|
+
*
|
|
484
|
+
* With persistence enabled (`persistKey`), the released subscription is
|
|
485
|
+
* detached into the restored pool instead of deleted: its query,
|
|
486
|
+
* checkpoint, and membership stay in the snapshot so a remount (or a
|
|
487
|
+
* cold offline reload) can re-adopt it cache-first. Detached subscriptions
|
|
488
|
+
* are excluded from backfill and GC'd after `restoredSubscriptionTTL`.
|
|
489
|
+
*/
|
|
490
|
+
key: "unsubscribe",
|
|
491
|
+
value: function unsubscribe(subscriptionId) {
|
|
492
|
+
var refCount = (this.subRefCounts.get(subscriptionId) || 1) - 1;
|
|
493
|
+
if (refCount > 0) {
|
|
494
|
+
this.subRefCounts.set(subscriptionId, refCount);
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
this.refreshes.delete(subscriptionId);
|
|
498
|
+
this.subRefCounts.delete(subscriptionId);
|
|
499
|
+
var queryKey;
|
|
500
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
501
|
+
try {
|
|
502
|
+
for (var _iterator = this.queryKeyToSubId[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
503
|
+
var [key, id] = _step.value;
|
|
504
|
+
if (id === subscriptionId) {
|
|
505
|
+
queryKey = key;
|
|
506
|
+
this.queryKeyToSubId.delete(key);
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
} catch (err) {
|
|
511
|
+
_didIteratorError = true;
|
|
512
|
+
_iteratorError = err;
|
|
513
|
+
} finally {
|
|
514
|
+
try {
|
|
515
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
516
|
+
_iterator.return();
|
|
517
|
+
}
|
|
518
|
+
} finally {
|
|
519
|
+
if (_didIteratorError) {
|
|
520
|
+
throw _iteratorError;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
var subscription = this.subscriptions.get(subscriptionId);
|
|
525
|
+
if (this.options.persistKey && subscription && queryKey && !subscription.query.progressive && !this.restoredByQueryKey.has(queryKey)) {
|
|
526
|
+
this.restoredByQueryKey.set(queryKey, subscriptionId);
|
|
527
|
+
this.restoredAt.set(subscriptionId, Date.now());
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
this.subscriptions.delete(subscriptionId);
|
|
531
|
+
}
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
/** Returns subscription metadata by id. */
|
|
535
|
+
key: "getSubscription",
|
|
536
|
+
value: function getSubscription(id) {
|
|
537
|
+
return this.subscriptions.get(id);
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
/**
|
|
542
|
+
* Returns current rows for a subscription from the cache.
|
|
543
|
+
* Note: This is local-only; authoritative refresh happens via backfill/realtime.
|
|
544
|
+
*/
|
|
545
|
+
key: "getDocsForSubscription",
|
|
546
|
+
value: function getDocsForSubscription(id) {
|
|
547
|
+
var virtualSub = this.virtualPageManager.getSubscription(id);
|
|
548
|
+
if (virtualSub) {
|
|
549
|
+
var docIds = virtualSub.getProgressiveCache().docIds.filter(function(id2) {
|
|
550
|
+
return id2 !== "";
|
|
551
|
+
});
|
|
552
|
+
var out = [];
|
|
553
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
554
|
+
try {
|
|
555
|
+
for (var _iterator = docIds[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
556
|
+
var name = _step.value;
|
|
557
|
+
var document = this.normalizedCache.get({
|
|
558
|
+
doctype: virtualSub.query.doctype,
|
|
559
|
+
name
|
|
560
|
+
});
|
|
561
|
+
if (document) out.push(document);
|
|
562
|
+
}
|
|
563
|
+
} catch (err) {
|
|
564
|
+
_didIteratorError = true;
|
|
565
|
+
_iteratorError = err;
|
|
566
|
+
} finally {
|
|
567
|
+
try {
|
|
568
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
569
|
+
_iterator.return();
|
|
570
|
+
}
|
|
571
|
+
} finally {
|
|
572
|
+
if (_didIteratorError) {
|
|
573
|
+
throw _iteratorError;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
return out;
|
|
578
|
+
}
|
|
579
|
+
var subscription = this.subscriptions.get(id);
|
|
580
|
+
if (!subscription) return [];
|
|
581
|
+
var out1 = [];
|
|
582
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
583
|
+
try {
|
|
584
|
+
for (var _iterator1 = subscription.docIds[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
585
|
+
var name1 = _step1.value;
|
|
586
|
+
var document1 = this.normalizedCache.get({
|
|
587
|
+
doctype: subscription.query.doctype,
|
|
588
|
+
name: name1
|
|
589
|
+
});
|
|
590
|
+
if (document1) out1.push(document1);
|
|
591
|
+
}
|
|
592
|
+
} catch (err) {
|
|
593
|
+
_didIteratorError1 = true;
|
|
594
|
+
_iteratorError1 = err;
|
|
595
|
+
} finally {
|
|
596
|
+
try {
|
|
597
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
598
|
+
_iterator1.return();
|
|
599
|
+
}
|
|
600
|
+
} finally {
|
|
601
|
+
if (_didIteratorError1) {
|
|
602
|
+
throw _iteratorError1;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
return out1;
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
key: "getPage",
|
|
611
|
+
value: (
|
|
612
|
+
/**
|
|
613
|
+
* Get a specific page of documents using virtual pagination
|
|
614
|
+
*/
|
|
615
|
+
async function getPage(subscriptionId, page) {
|
|
616
|
+
return this.virtualPageManager.getPage(subscriptionId, page);
|
|
617
|
+
})
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
key: "getNextBatch",
|
|
621
|
+
value: (
|
|
622
|
+
/**
|
|
623
|
+
* Get documents after a cursor (for infinite scroll)
|
|
624
|
+
*/
|
|
625
|
+
async function getNextBatch(subscriptionId, cursorDocId, limit) {
|
|
626
|
+
return this.virtualPageManager.getNextBatch(subscriptionId, cursorDocId, limit);
|
|
627
|
+
})
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
/**
|
|
631
|
+
* Get page information
|
|
632
|
+
*/
|
|
633
|
+
key: "getPageInfo",
|
|
634
|
+
value: function getPageInfo(subscriptionId) {
|
|
635
|
+
return this.virtualPageManager.getPageInfo(subscriptionId);
|
|
636
|
+
}
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
key: "backfill",
|
|
640
|
+
value: (
|
|
641
|
+
/**
|
|
642
|
+
* Reconciles local state by fetching changes since stored cursors.
|
|
643
|
+
*
|
|
644
|
+
* Scopes
|
|
645
|
+
* - all: iterate all subscriptions
|
|
646
|
+
* - subscriptions: selected subscription ids
|
|
647
|
+
* - doctypes: all subscriptions matching any of these doctypes
|
|
648
|
+
* - docs: refetch specific documents (authority refresh)
|
|
649
|
+
*/
|
|
650
|
+
async function backfill(args) {
|
|
651
|
+
if (args.scope === import_types.BackfillScope.All) {
|
|
652
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
653
|
+
try {
|
|
654
|
+
for (var _iterator = this.subscriptions.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
655
|
+
var subscription = _step.value;
|
|
656
|
+
if (this.restoredAt.has(subscription.id)) continue;
|
|
657
|
+
await this.backfillSub(subscription, args.pageSize);
|
|
658
|
+
}
|
|
659
|
+
} catch (err) {
|
|
660
|
+
_didIteratorError = true;
|
|
661
|
+
_iteratorError = err;
|
|
662
|
+
} finally {
|
|
663
|
+
try {
|
|
664
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
665
|
+
_iterator.return();
|
|
666
|
+
}
|
|
667
|
+
} finally {
|
|
668
|
+
if (_didIteratorError) {
|
|
669
|
+
throw _iteratorError;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
if (args.scope === import_types.BackfillScope.Subscriptions) {
|
|
676
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
677
|
+
try {
|
|
678
|
+
for (var _iterator1 = (args.subscriptions || [])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
679
|
+
var subscriptionId = _step1.value;
|
|
680
|
+
var subscription1 = this.subscriptions.get(subscriptionId);
|
|
681
|
+
if (subscription1) await this.backfillSub(subscription1, args.pageSize);
|
|
682
|
+
}
|
|
683
|
+
} catch (err) {
|
|
684
|
+
_didIteratorError1 = true;
|
|
685
|
+
_iteratorError1 = err;
|
|
686
|
+
} finally {
|
|
687
|
+
try {
|
|
688
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
689
|
+
_iterator1.return();
|
|
690
|
+
}
|
|
691
|
+
} finally {
|
|
692
|
+
if (_didIteratorError1) {
|
|
693
|
+
throw _iteratorError1;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
if (args.scope === import_types.BackfillScope.Doctypes) {
|
|
700
|
+
var set = new Set(args.doctypes || []);
|
|
701
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
702
|
+
try {
|
|
703
|
+
for (var _iterator2 = this.subscriptions.values()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
704
|
+
var subscription2 = _step2.value;
|
|
705
|
+
if (this.restoredAt.has(subscription2.id)) continue;
|
|
706
|
+
if (set.has(subscription2.query.doctype)) await this.backfillSub(subscription2, args.pageSize);
|
|
707
|
+
}
|
|
708
|
+
} catch (err) {
|
|
709
|
+
_didIteratorError2 = true;
|
|
710
|
+
_iteratorError2 = err;
|
|
711
|
+
} finally {
|
|
712
|
+
try {
|
|
713
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
714
|
+
_iterator2.return();
|
|
715
|
+
}
|
|
716
|
+
} finally {
|
|
717
|
+
if (_didIteratorError2) {
|
|
718
|
+
throw _iteratorError2;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
if (args.scope === import_types.BackfillScope.Docs) {
|
|
725
|
+
var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
|
|
726
|
+
try {
|
|
727
|
+
for (var _iterator3 = (args.docs || [])[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
728
|
+
var docTarget = _step3.value;
|
|
729
|
+
var document = await this.db.getDoc(docTarget.doctype, docTarget.name);
|
|
730
|
+
this.normalizedCache.upsert(document);
|
|
731
|
+
}
|
|
732
|
+
} catch (err) {
|
|
733
|
+
_didIteratorError3 = true;
|
|
734
|
+
_iteratorError3 = err;
|
|
735
|
+
} finally {
|
|
736
|
+
try {
|
|
737
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
738
|
+
_iterator3.return();
|
|
739
|
+
}
|
|
740
|
+
} finally {
|
|
741
|
+
if (_didIteratorError3) {
|
|
742
|
+
throw _iteratorError3;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
})
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
key: "backfillSub",
|
|
751
|
+
value: (
|
|
752
|
+
/**
|
|
753
|
+
* Backfills one subscription using CDC checkpoint and updates membership.
|
|
754
|
+
*
|
|
755
|
+
* Algorithm
|
|
756
|
+
* - Query backfill using checkpoint for CDC (Change Data Capture),
|
|
757
|
+
* draining follow-up pages while the server reports has_more (bounded)
|
|
758
|
+
* so reconnect catch-up is complete rather than one page deep
|
|
759
|
+
* - Upsert each row to cache
|
|
760
|
+
* - For each row: test client-side filters; add/remove membership accordingly
|
|
761
|
+
* - Track tombstones for deleted documents
|
|
762
|
+
* - Advance checkpoint to response checkpoint
|
|
763
|
+
* - If no filters were specified, derive membership directly from returned rows
|
|
764
|
+
*/
|
|
765
|
+
async function backfillSub(subscription) {
|
|
766
|
+
var pageSize = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : (_this_options_pageSize = this.options.pageSize) !== null && _this_options_pageSize !== void 0 ? _this_options_pageSize : 200;
|
|
767
|
+
var _this_options_backfillMaxPages;
|
|
768
|
+
var maxPages = (_this_options_backfillMaxPages = this.options.backfillMaxPages) !== null && _this_options_backfillMaxPages !== void 0 ? _this_options_backfillMaxPages : 20;
|
|
769
|
+
var rows = [];
|
|
770
|
+
var deleted = [];
|
|
771
|
+
for (var page = 0; page < maxPages; page++) {
|
|
772
|
+
var _ref;
|
|
773
|
+
var _response_deleted;
|
|
774
|
+
var response = await this.db.backfill({
|
|
775
|
+
doctype: subscription.query.doctype,
|
|
776
|
+
fields: subscription.query.fields,
|
|
777
|
+
filters: subscription.query.filters,
|
|
778
|
+
modifiedAfter: subscription.checkpoint,
|
|
779
|
+
limit: pageSize
|
|
780
|
+
});
|
|
781
|
+
if (Array.isArray(response.deleted)) {
|
|
782
|
+
deleted.push(...response.deleted);
|
|
783
|
+
}
|
|
784
|
+
rows.push(...response.rows);
|
|
785
|
+
if (response.checkpoint) subscription.checkpoint = response.checkpoint;
|
|
786
|
+
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;
|
|
787
|
+
if (!response.has_more || !response.checkpoint || !madeProgress) break;
|
|
788
|
+
}
|
|
789
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
790
|
+
try {
|
|
791
|
+
var _this, _loop = function() {
|
|
792
|
+
var deletedRef = _step.value;
|
|
793
|
+
if (!(deletedRef === null || deletedRef === void 0 ? void 0 : deletedRef.name)) return "continue";
|
|
794
|
+
var deletedDoctype = deletedRef.doctype || subscription.query.doctype;
|
|
795
|
+
if (deletedDoctype === subscription.query.doctype && subscription.tombstones) {
|
|
796
|
+
subscription.tombstones.set(deletedRef.name, Date.now());
|
|
797
|
+
}
|
|
798
|
+
_this.normalizedCache.remove({
|
|
799
|
+
doctype: deletedDoctype,
|
|
800
|
+
name: deletedRef.name
|
|
801
|
+
});
|
|
802
|
+
if (deletedDoctype === subscription.query.doctype) subscription.docIds = subscription.docIds.filter(function(currentName) {
|
|
803
|
+
return currentName !== deletedRef.name;
|
|
804
|
+
});
|
|
805
|
+
};
|
|
806
|
+
for (var _iterator = deleted[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _this = this, _loop();
|
|
807
|
+
} catch (err) {
|
|
808
|
+
_didIteratorError = true;
|
|
809
|
+
_iteratorError = err;
|
|
810
|
+
} finally {
|
|
811
|
+
try {
|
|
812
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
813
|
+
_iterator.return();
|
|
814
|
+
}
|
|
815
|
+
} finally {
|
|
816
|
+
if (_didIteratorError) {
|
|
817
|
+
throw _iteratorError;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
822
|
+
try {
|
|
823
|
+
var _this1, _loop1 = function() {
|
|
824
|
+
var row = _step1.value;
|
|
825
|
+
if (!row.doctype) row.doctype = subscription.query.doctype;
|
|
826
|
+
_this1.normalizedCache.upsert(row);
|
|
827
|
+
var name = row.name;
|
|
828
|
+
if (!name) return "continue";
|
|
829
|
+
var match = (0, import_filters.matchesFilters)(row, subscription.query.filters);
|
|
830
|
+
if (match && !subscription.docIds.includes(name)) subscription.docIds.push(name);
|
|
831
|
+
if (!match) subscription.docIds = subscription.docIds.filter(function(currentName) {
|
|
832
|
+
return currentName !== name;
|
|
833
|
+
});
|
|
834
|
+
};
|
|
835
|
+
for (var _iterator1 = rows[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) _this1 = this, _loop1();
|
|
836
|
+
} catch (err) {
|
|
837
|
+
_didIteratorError1 = true;
|
|
838
|
+
_iteratorError1 = err;
|
|
839
|
+
} finally {
|
|
840
|
+
try {
|
|
841
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
842
|
+
_iterator1.return();
|
|
843
|
+
}
|
|
844
|
+
} finally {
|
|
845
|
+
if (_didIteratorError1) {
|
|
846
|
+
throw _iteratorError1;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
if (rows.length && !subscription.query.filters) subscription.docIds = rows.map(function(row) {
|
|
851
|
+
return row.name;
|
|
852
|
+
});
|
|
853
|
+
if (subscription.docIds.length > 0) {
|
|
854
|
+
var firstDoc = this.normalizedCache.get({
|
|
855
|
+
doctype: subscription.query.doctype,
|
|
856
|
+
name: subscription.docIds[0]
|
|
857
|
+
});
|
|
858
|
+
var lastDoc = this.normalizedCache.get({
|
|
859
|
+
doctype: subscription.query.doctype,
|
|
860
|
+
name: subscription.docIds[subscription.docIds.length - 1]
|
|
861
|
+
});
|
|
862
|
+
if (firstDoc && lastDoc) {
|
|
863
|
+
var _subscription_boundaries, _subscription_boundaries1;
|
|
864
|
+
subscription.boundaries = {
|
|
865
|
+
firstItem: firstDoc,
|
|
866
|
+
lastItem: lastDoc,
|
|
867
|
+
offset: ((_subscription_boundaries = subscription.boundaries) === null || _subscription_boundaries === void 0 ? void 0 : _subscription_boundaries.offset) || 0,
|
|
868
|
+
pageSize: ((_subscription_boundaries1 = subscription.boundaries) === null || _subscription_boundaries1 === void 0 ? void 0 : _subscription_boundaries1.pageSize) || subscription.query.limit || 20
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
this.resortSubscriptionDocIds(subscription);
|
|
873
|
+
this.cleanupTombstones(subscription.id);
|
|
874
|
+
subscription.stale = false;
|
|
875
|
+
if (this.options.onBackfill) this.options.onBackfill({
|
|
876
|
+
doctype: subscription.query.doctype,
|
|
877
|
+
fetched: rows.length,
|
|
878
|
+
checkpoint: subscription.checkpoint
|
|
879
|
+
});
|
|
880
|
+
})
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
key: "resortSubscriptionDocIds",
|
|
884
|
+
value: function resortSubscriptionDocIds(subscription) {
|
|
885
|
+
var _this = this;
|
|
886
|
+
var { orderBy, doctype } = subscription.query;
|
|
887
|
+
if (!orderBy) return;
|
|
888
|
+
var orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];
|
|
889
|
+
subscription.docIds.sort(function(firstId, secondId) {
|
|
890
|
+
var firstDoc = _this.normalizedCache.get({
|
|
891
|
+
doctype,
|
|
892
|
+
name: firstId
|
|
893
|
+
});
|
|
894
|
+
var secondDoc = _this.normalizedCache.get({
|
|
895
|
+
doctype,
|
|
896
|
+
name: secondId
|
|
897
|
+
});
|
|
898
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
899
|
+
try {
|
|
900
|
+
for (var _iterator = orderByArray[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
901
|
+
var orderByField = _step.value;
|
|
902
|
+
var field = orderByField.field;
|
|
903
|
+
var ascending = orderByField.order !== import_types.Order.Desc;
|
|
904
|
+
var firstValue = firstDoc === null || firstDoc === void 0 ? void 0 : firstDoc[field];
|
|
905
|
+
var secondValue = secondDoc === null || secondDoc === void 0 ? void 0 : secondDoc[field];
|
|
906
|
+
var firstIsNullish = firstValue === null || firstValue === void 0;
|
|
907
|
+
var secondIsNullish = secondValue === null || secondValue === void 0;
|
|
908
|
+
if (firstIsNullish && !secondIsNullish) return ascending ? -1 : 1;
|
|
909
|
+
if (secondIsNullish && !firstIsNullish) return ascending ? 1 : -1;
|
|
910
|
+
if (firstIsNullish && secondIsNullish) continue;
|
|
911
|
+
if (firstIsNullish || secondIsNullish) continue;
|
|
912
|
+
if (firstValue < secondValue) return ascending ? -1 : 1;
|
|
913
|
+
if (firstValue > secondValue) return ascending ? 1 : -1;
|
|
914
|
+
}
|
|
915
|
+
} catch (err) {
|
|
916
|
+
_didIteratorError = true;
|
|
917
|
+
_iteratorError = err;
|
|
918
|
+
} finally {
|
|
919
|
+
try {
|
|
920
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
921
|
+
_iterator.return();
|
|
922
|
+
}
|
|
923
|
+
} finally {
|
|
924
|
+
if (_didIteratorError) {
|
|
925
|
+
throw _iteratorError;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
return firstId < secondId ? -1 : firstId > secondId ? 1 : 0;
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
},
|
|
933
|
+
{
|
|
934
|
+
key: "updateSubscriptionMembership",
|
|
935
|
+
value: function updateSubscriptionMembership(doc) {
|
|
936
|
+
var subscriptionsNeedingRehydration = [];
|
|
937
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
938
|
+
try {
|
|
939
|
+
for (var _iterator = this.subscriptions.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
940
|
+
var subscription = _step.value;
|
|
941
|
+
if (this.restoredAt.has(subscription.id)) continue;
|
|
942
|
+
if (subscription.query.doctype !== doc.doctype) continue;
|
|
943
|
+
var match = (0, import_filters.matchesFilters)(doc, subscription.query.filters);
|
|
944
|
+
var isExisting = subscription.docIds.includes(doc.name);
|
|
945
|
+
if (match && !isExisting) {
|
|
946
|
+
subscriptionsNeedingRehydration.push(subscription);
|
|
947
|
+
this.virtualPageManager.handleRemoteCreate(subscription.id, doc);
|
|
948
|
+
} else if (isExisting) {
|
|
949
|
+
if (!match) {
|
|
950
|
+
subscription.docIds = subscription.docIds.filter(function(docId) {
|
|
951
|
+
return docId !== doc.name;
|
|
952
|
+
});
|
|
953
|
+
this.virtualPageManager.handleRemoteDelete(subscription.id, doc.name);
|
|
954
|
+
} else {
|
|
955
|
+
this.virtualPageManager.handleRemoteUpdate(subscription.id, doc);
|
|
956
|
+
}
|
|
957
|
+
this.resortSubscriptionDocIds(subscription);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
} catch (err) {
|
|
961
|
+
_didIteratorError = true;
|
|
962
|
+
_iteratorError = err;
|
|
963
|
+
} finally {
|
|
964
|
+
try {
|
|
965
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
966
|
+
_iterator.return();
|
|
967
|
+
}
|
|
968
|
+
} finally {
|
|
969
|
+
if (_didIteratorError) {
|
|
970
|
+
throw _iteratorError;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
return subscriptionsNeedingRehydration;
|
|
975
|
+
}
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
/**
|
|
979
|
+
* Removes a document from all subscription memberships.
|
|
980
|
+
* Returns subscriptions that had the document removed (for potential backfill).
|
|
981
|
+
*/
|
|
982
|
+
key: "removeFromAllSubscriptions",
|
|
983
|
+
value: function removeFromAllSubscriptions(doctype, name) {
|
|
984
|
+
var affectedSubscriptions = [];
|
|
985
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
986
|
+
try {
|
|
987
|
+
for (var _iterator = this.subscriptions.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
988
|
+
var subscription = _step.value;
|
|
989
|
+
if (subscription.query.doctype !== doctype) continue;
|
|
990
|
+
var hadDocument = subscription.docIds.includes(name);
|
|
991
|
+
if (hadDocument) {
|
|
992
|
+
subscription.docIds = subscription.docIds.filter(function(docId) {
|
|
993
|
+
return docId !== name;
|
|
994
|
+
});
|
|
995
|
+
this.virtualPageManager.handleRemoteDelete(subscription.id, name);
|
|
996
|
+
affectedSubscriptions.push(subscription);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
} catch (err) {
|
|
1000
|
+
_didIteratorError = true;
|
|
1001
|
+
_iteratorError = err;
|
|
1002
|
+
} finally {
|
|
1003
|
+
try {
|
|
1004
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1005
|
+
_iterator.return();
|
|
1006
|
+
}
|
|
1007
|
+
} finally {
|
|
1008
|
+
if (_didIteratorError) {
|
|
1009
|
+
throw _iteratorError;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return affectedSubscriptions;
|
|
1014
|
+
}
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
/** Gets all active subscriptions. */
|
|
1018
|
+
key: "getAllSubscriptions",
|
|
1019
|
+
value: function getAllSubscriptions() {
|
|
1020
|
+
return this.subscriptions;
|
|
1021
|
+
}
|
|
1022
|
+
},
|
|
1023
|
+
{
|
|
1024
|
+
key: "getVirtualPageManager",
|
|
1025
|
+
value: function getVirtualPageManager() {
|
|
1026
|
+
return this.virtualPageManager;
|
|
1027
|
+
}
|
|
1028
|
+
},
|
|
1029
|
+
{
|
|
1030
|
+
key: "insertDocumentIntoSubscription",
|
|
1031
|
+
value: function insertDocumentIntoSubscription(subscription, doc) {
|
|
1032
|
+
if (subscription.docIds.includes(doc.name)) return;
|
|
1033
|
+
if (!subscription.query.orderBy || subscription.docIds.length === 0) {
|
|
1034
|
+
return subscription.docIds.push(doc.name);
|
|
1035
|
+
}
|
|
1036
|
+
var insertIndex = this.findInsertionIndex(subscription, doc);
|
|
1037
|
+
subscription.docIds.splice(insertIndex, 0, doc.name);
|
|
1038
|
+
}
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
key: "findInsertionIndex",
|
|
1042
|
+
value: function findInsertionIndex(subscription, doc) {
|
|
1043
|
+
var { docIds, query } = subscription;
|
|
1044
|
+
var orderByArray = Array.isArray(query.orderBy) ? query.orderBy : [query.orderBy];
|
|
1045
|
+
var left = 0;
|
|
1046
|
+
var right = docIds.length - 1;
|
|
1047
|
+
while (left <= right) {
|
|
1048
|
+
var mid = Math.floor((left + right) / 2);
|
|
1049
|
+
var midDoc = this.normalizedCache.get({
|
|
1050
|
+
doctype: query.doctype,
|
|
1051
|
+
name: docIds[mid]
|
|
1052
|
+
});
|
|
1053
|
+
if (!midDoc) {
|
|
1054
|
+
return docIds.length;
|
|
1055
|
+
}
|
|
1056
|
+
var comparison = this.compareDocuments(doc, midDoc, orderByArray);
|
|
1057
|
+
if (comparison <= 0) {
|
|
1058
|
+
right = mid - 1;
|
|
1059
|
+
} else {
|
|
1060
|
+
left = mid + 1;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
return left;
|
|
1064
|
+
}
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
key: "compareDocuments",
|
|
1068
|
+
value: function compareDocuments(doc1, doc2, orderByArray) {
|
|
1069
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1070
|
+
try {
|
|
1071
|
+
for (var _iterator = orderByArray[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
1072
|
+
var { field, order } = _step.value;
|
|
1073
|
+
var value1 = doc1[field];
|
|
1074
|
+
var value2 = doc2[field];
|
|
1075
|
+
var isAsc = order !== import_types.Order.Desc;
|
|
1076
|
+
var isNull1 = value1 == null;
|
|
1077
|
+
var isNull2 = value2 == null;
|
|
1078
|
+
if (isNull1 && !isNull2) return isAsc ? -1 : 1;
|
|
1079
|
+
if (!isNull1 && isNull2) return isAsc ? 1 : -1;
|
|
1080
|
+
if (isNull1 && isNull2) continue;
|
|
1081
|
+
if (value1 < value2) return isAsc ? -1 : 1;
|
|
1082
|
+
if (value1 > value2) return isAsc ? 1 : -1;
|
|
1083
|
+
}
|
|
1084
|
+
} catch (err) {
|
|
1085
|
+
_didIteratorError = true;
|
|
1086
|
+
_iteratorError = err;
|
|
1087
|
+
} finally {
|
|
1088
|
+
try {
|
|
1089
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1090
|
+
_iterator.return();
|
|
1091
|
+
}
|
|
1092
|
+
} finally {
|
|
1093
|
+
if (_didIteratorError) {
|
|
1094
|
+
throw _iteratorError;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
var name1 = doc1.name || "";
|
|
1099
|
+
var name2 = doc2.name || "";
|
|
1100
|
+
return name1 < name2 ? -1 : name1 > name2 ? 1 : 0;
|
|
1101
|
+
}
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
key: "clear",
|
|
1105
|
+
value: function clear() {
|
|
1106
|
+
this.refreshes.clear();
|
|
1107
|
+
this.subscriptions.clear();
|
|
1108
|
+
this.queryKeyToSubId.clear();
|
|
1109
|
+
this.subRefCounts.clear();
|
|
1110
|
+
this.restoredByQueryKey.clear();
|
|
1111
|
+
this.restoredAt.clear();
|
|
1112
|
+
}
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
/**
|
|
1116
|
+
* Cleans up expired tombstones based on age and count limits.
|
|
1117
|
+
* Should be called periodically or after backfill operations.
|
|
1118
|
+
*/
|
|
1119
|
+
key: "cleanupTombstones",
|
|
1120
|
+
value: function cleanupTombstones(subscriptionId) {
|
|
1121
|
+
var _this_options_tombstoneMaxAge, _this_options_tombstoneMaxCount;
|
|
1122
|
+
var maxAge = (_this_options_tombstoneMaxAge = this.options.tombstoneMaxAge) !== null && _this_options_tombstoneMaxAge !== void 0 ? _this_options_tombstoneMaxAge : 30 * 60 * 1e3;
|
|
1123
|
+
var maxCount = (_this_options_tombstoneMaxCount = this.options.tombstoneMaxCount) !== null && _this_options_tombstoneMaxCount !== void 0 ? _this_options_tombstoneMaxCount : 1e3;
|
|
1124
|
+
var now = Date.now();
|
|
1125
|
+
var subscriptionsToClean = subscriptionId ? [this.subscriptions.get(subscriptionId)].filter(Boolean) : [...this.subscriptions.values()];
|
|
1126
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1127
|
+
try {
|
|
1128
|
+
for (var _iterator = subscriptionsToClean[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
1129
|
+
var subscription = _step.value;
|
|
1130
|
+
if (!(subscription === null || subscription === void 0 ? void 0 : subscription.tombstones) || subscription.tombstones.size === 0) continue;
|
|
1131
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
1132
|
+
try {
|
|
1133
|
+
for (var _iterator1 = subscription.tombstones[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
1134
|
+
var [name, timestamp] = _step1.value;
|
|
1135
|
+
if (now - timestamp > maxAge) {
|
|
1136
|
+
subscription.tombstones.delete(name);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
} catch (err) {
|
|
1140
|
+
_didIteratorError1 = true;
|
|
1141
|
+
_iteratorError1 = err;
|
|
1142
|
+
} finally {
|
|
1143
|
+
try {
|
|
1144
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1145
|
+
_iterator1.return();
|
|
1146
|
+
}
|
|
1147
|
+
} finally {
|
|
1148
|
+
if (_didIteratorError1) {
|
|
1149
|
+
throw _iteratorError1;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
if (subscription.tombstones.size > maxCount) {
|
|
1154
|
+
var entries = [...subscription.tombstones.entries()];
|
|
1155
|
+
entries.sort(function(a, b) {
|
|
1156
|
+
return a[1] - b[1];
|
|
1157
|
+
});
|
|
1158
|
+
var toRemove = entries.slice(0, subscription.tombstones.size - maxCount);
|
|
1159
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
1160
|
+
try {
|
|
1161
|
+
for (var _iterator2 = toRemove[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
1162
|
+
var [name1] = _step2.value;
|
|
1163
|
+
subscription.tombstones.delete(name1);
|
|
1164
|
+
}
|
|
1165
|
+
} catch (err) {
|
|
1166
|
+
_didIteratorError2 = true;
|
|
1167
|
+
_iteratorError2 = err;
|
|
1168
|
+
} finally {
|
|
1169
|
+
try {
|
|
1170
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
1171
|
+
_iterator2.return();
|
|
1172
|
+
}
|
|
1173
|
+
} finally {
|
|
1174
|
+
if (_didIteratorError2) {
|
|
1175
|
+
throw _iteratorError2;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
} catch (err) {
|
|
1182
|
+
_didIteratorError = true;
|
|
1183
|
+
_iteratorError = err;
|
|
1184
|
+
} finally {
|
|
1185
|
+
try {
|
|
1186
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1187
|
+
_iterator.return();
|
|
1188
|
+
}
|
|
1189
|
+
} finally {
|
|
1190
|
+
if (_didIteratorError) {
|
|
1191
|
+
throw _iteratorError;
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
]);
|
|
1198
|
+
return SubscriptionManager2;
|
|
1199
|
+
})();
|
|
1242
1200
|
function cryptoRandomId() {
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1201
|
+
if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
|
|
1202
|
+
return crypto.randomUUID();
|
|
1203
|
+
}
|
|
1204
|
+
return Math.random().toString(36).slice(2);
|
|
1247
1205
|
}
|
|
1206
|
+
|
|
1248
1207
|
//# sourceMappingURL=subscriptionManager.native.js.map
|