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