@multiplatform.one/frappe 9.16.1 → 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 +636 -631
- 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 +128 -134
- 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 mutationEngine_exports = {};
|
|
26
|
-
__export(mutationEngine_exports, {
|
|
27
|
-
MutationEngine: () => MutationEngine
|
|
28
|
-
});
|
|
24
|
+
__export(mutationEngine_exports, { MutationEngine: () => MutationEngine });
|
|
29
25
|
module.exports = __toCommonJS(mutationEngine_exports);
|
|
30
26
|
var import_pacer = require("@tanstack/pacer");
|
|
31
27
|
var import_filters = require("./filters.native.js");
|
|
@@ -33,1214 +29,1164 @@ var import_merge = require("./merge.native.js");
|
|
|
33
29
|
var import_types = require("./types.native.js");
|
|
34
30
|
var import_types2 = require("./types.native.js");
|
|
35
31
|
function _class_call_check(instance, Constructor) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
if (!(instance instanceof Constructor)) {
|
|
33
|
+
throw new TypeError("Cannot call a class as a function");
|
|
34
|
+
}
|
|
39
35
|
}
|
|
40
36
|
function _defineProperties(target, props) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
for (var i = 0; i < props.length; i++) {
|
|
38
|
+
var descriptor = props[i];
|
|
39
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
40
|
+
descriptor.configurable = true;
|
|
41
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
42
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
43
|
+
}
|
|
48
44
|
}
|
|
49
45
|
function _create_class(Constructor, protoProps, staticProps) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
47
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
48
|
+
return Constructor;
|
|
53
49
|
}
|
|
54
50
|
function _define_property(obj, key, value) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
function _instanceof(left, right) {
|
|
68
|
-
"@swc/helpers - instanceof";
|
|
69
|
-
|
|
70
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
71
|
-
return !!right[Symbol.hasInstance](left);
|
|
72
|
-
} else {
|
|
73
|
-
return left instanceof right;
|
|
74
|
-
}
|
|
51
|
+
if (key in obj) {
|
|
52
|
+
Object.defineProperty(obj, key, {
|
|
53
|
+
value,
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
obj[key] = value;
|
|
60
|
+
}
|
|
61
|
+
return obj;
|
|
75
62
|
}
|
|
76
63
|
function toJournalError(err) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var message = err === null || err === void 0 ? void 0 : err.message;
|
|
81
|
-
return {
|
|
82
|
-
message: message !== null && message !== void 0 ? message : String(err)
|
|
83
|
-
};
|
|
64
|
+
if (err instanceof Error) return { message: err.message };
|
|
65
|
+
var message = err === null || err === void 0 ? void 0 : err.message;
|
|
66
|
+
return { message: message !== null && message !== void 0 ? message : String(err) };
|
|
84
67
|
}
|
|
85
|
-
var MutationEngine = /* @__PURE__ */
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
}
|
|
1205
|
-
} finally {
|
|
1206
|
-
if (_didIteratorError) {
|
|
1207
|
-
throw _iteratorError;
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
return {
|
|
1212
|
-
defaultStrategy: import_merge.MergeStrategy.ServerWins,
|
|
1213
|
-
doctypes
|
|
1214
|
-
};
|
|
1215
|
-
})
|
|
1216
|
-
}, {
|
|
1217
|
-
/** Gets temporary to real name mapping. */
|
|
1218
|
-
key: "getTemporaryIdToRealNameMap",
|
|
1219
|
-
value: function getTemporaryIdToRealNameMap() {
|
|
1220
|
-
return this.temporaryIdToRealNameMap;
|
|
1221
|
-
}
|
|
1222
|
-
}, {
|
|
1223
|
-
/** Clears all temporary mappings. */
|
|
1224
|
-
key: "clearTemporaryMappings",
|
|
1225
|
-
value: function clearTemporaryMappings() {
|
|
1226
|
-
this.temporaryIdToRealNameMap.clear();
|
|
1227
|
-
this.globalOptimisticDocIds.clear();
|
|
1228
|
-
}
|
|
1229
|
-
}, {
|
|
1230
|
-
/**
|
|
1231
|
-
* Disposes of resources.
|
|
1232
|
-
*/
|
|
1233
|
-
key: "dispose",
|
|
1234
|
-
value: function dispose() {
|
|
1235
|
-
this.batchDebouncer.cancel();
|
|
1236
|
-
this.pendingBatch = [];
|
|
1237
|
-
this.clearTemporaryMappings();
|
|
1238
|
-
}
|
|
1239
|
-
}]);
|
|
1240
|
-
return MutationEngine2;
|
|
1241
|
-
}();
|
|
68
|
+
var MutationEngine = /* @__PURE__ */ (function() {
|
|
69
|
+
"use strict";
|
|
70
|
+
function MutationEngine2(db, realtime, normalizedCache, mutationJournal, subscriptionManager, rehydrationManager) {
|
|
71
|
+
var _this = this;
|
|
72
|
+
var options = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : {};
|
|
73
|
+
_class_call_check(this, MutationEngine2);
|
|
74
|
+
var _options_batchDelay;
|
|
75
|
+
_define_property(this, "temporaryIdToRealNameMap", /* @__PURE__ */ new Map());
|
|
76
|
+
_define_property(this, "globalOptimisticDocIds", /* @__PURE__ */ new Map());
|
|
77
|
+
_define_property(this, "pendingBatch", []);
|
|
78
|
+
_define_property(this, "batchDebouncer", void 0);
|
|
79
|
+
_define_property(this, "db", void 0);
|
|
80
|
+
_define_property(this, "realtime", void 0);
|
|
81
|
+
_define_property(this, "normalizedCache", void 0);
|
|
82
|
+
_define_property(this, "mutationJournal", void 0);
|
|
83
|
+
_define_property(this, "subscriptionManager", void 0);
|
|
84
|
+
_define_property(this, "rehydrationManager", void 0);
|
|
85
|
+
_define_property(this, "options", void 0);
|
|
86
|
+
this.db = db;
|
|
87
|
+
this.realtime = realtime;
|
|
88
|
+
this.normalizedCache = normalizedCache;
|
|
89
|
+
this.mutationJournal = mutationJournal;
|
|
90
|
+
this.subscriptionManager = subscriptionManager;
|
|
91
|
+
this.rehydrationManager = rehydrationManager;
|
|
92
|
+
this.options = options;
|
|
93
|
+
var batchDelay = (_options_batchDelay = options.batchDelay) !== null && _options_batchDelay !== void 0 ? _options_batchDelay : 100;
|
|
94
|
+
this.batchDebouncer = new import_pacer.Debouncer(function() {
|
|
95
|
+
return _this.flushBatch();
|
|
96
|
+
}, { wait: batchDelay });
|
|
97
|
+
}
|
|
98
|
+
_create_class(MutationEngine2, [
|
|
99
|
+
{
|
|
100
|
+
key: "queueForBatch",
|
|
101
|
+
value: (
|
|
102
|
+
/**
|
|
103
|
+
* Queue a mutation for batch processing.
|
|
104
|
+
* Returns a promise that resolves when the batch is processed.
|
|
105
|
+
*/
|
|
106
|
+
function queueForBatch(mutation) {
|
|
107
|
+
var _this = this;
|
|
108
|
+
return new Promise(function(resolve, reject) {
|
|
109
|
+
var _this_options_batchMaxSize;
|
|
110
|
+
_this.pendingBatch.push({
|
|
111
|
+
mutation,
|
|
112
|
+
resolve,
|
|
113
|
+
reject
|
|
114
|
+
});
|
|
115
|
+
var maxSize = (_this_options_batchMaxSize = _this.options.batchMaxSize) !== null && _this_options_batchMaxSize !== void 0 ? _this_options_batchMaxSize : 50;
|
|
116
|
+
if (_this.pendingBatch.length >= maxSize) {
|
|
117
|
+
_this.flushBatch();
|
|
118
|
+
} else {
|
|
119
|
+
_this.batchDebouncer.maybeExecute();
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
})
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
key: "flushBatch",
|
|
126
|
+
value: (
|
|
127
|
+
/**
|
|
128
|
+
* Flush pending mutations as a batch.
|
|
129
|
+
*/
|
|
130
|
+
async function flushBatch() {
|
|
131
|
+
if (this.pendingBatch.length === 0) return;
|
|
132
|
+
var batch = [...this.pendingBatch];
|
|
133
|
+
this.pendingBatch = [];
|
|
134
|
+
try {
|
|
135
|
+
var _this_options_batchAtomic;
|
|
136
|
+
var batchMutations = batch.map(function(param) {
|
|
137
|
+
var { mutation: mutation2 } = param;
|
|
138
|
+
var operationMap = {
|
|
139
|
+
[import_types2.Operation.Create]: "create",
|
|
140
|
+
[import_types2.Operation.Update]: "update",
|
|
141
|
+
[import_types2.Operation.Delete]: "delete"
|
|
142
|
+
};
|
|
143
|
+
return {
|
|
144
|
+
type: operationMap[mutation2.operation],
|
|
145
|
+
doctype: mutation2.doc.doctype,
|
|
146
|
+
name: mutation2.doc.name,
|
|
147
|
+
data: mutation2.operation === import_types2.Operation.Delete ? void 0 : mutation2.doc
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
var results = await this.db.batchMutations({
|
|
151
|
+
mutations: batchMutations,
|
|
152
|
+
atomic: (_this_options_batchAtomic = this.options.batchAtomic) !== null && _this_options_batchAtomic !== void 0 ? _this_options_batchAtomic : false
|
|
153
|
+
});
|
|
154
|
+
for (var i = 0; i < batch.length; i++) {
|
|
155
|
+
var { mutation, resolve, reject } = batch[i];
|
|
156
|
+
var result = results[i];
|
|
157
|
+
if (result.success) {
|
|
158
|
+
this.mutationJournal.confirm(mutation.mutationId);
|
|
159
|
+
if (result.data) {
|
|
160
|
+
this.normalizedCache.upsert(result.data);
|
|
161
|
+
if (mutation.operation === import_types2.Operation.Create) {
|
|
162
|
+
var _mutation_temporaryName;
|
|
163
|
+
var temporaryName = (_mutation_temporaryName = mutation.temporaryName) !== null && _mutation_temporaryName !== void 0 ? _mutation_temporaryName : mutation.doc.name;
|
|
164
|
+
if (temporaryName && result.data.name && temporaryName !== result.data.name) {
|
|
165
|
+
this.handleTemporaryToRealMapping(mutation.doc.doctype, temporaryName, result.data.name);
|
|
166
|
+
this.rehydrationManager.registerTempIdMapping(temporaryName, result.data.name);
|
|
167
|
+
} else if (temporaryName) {
|
|
168
|
+
var _this_globalOptimisticDocIds_get;
|
|
169
|
+
(_this_globalOptimisticDocIds_get = this.globalOptimisticDocIds.get(mutation.doc.doctype)) === null || _this_globalOptimisticDocIds_get === void 0 ? void 0 : _this_globalOptimisticDocIds_get.delete(temporaryName);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (this.options.onMutationSuccess) {
|
|
174
|
+
this.options.onMutationSuccess(mutation);
|
|
175
|
+
}
|
|
176
|
+
resolve(result.data);
|
|
177
|
+
} else {
|
|
178
|
+
var error = new Error(result.error || "Batch mutation failed");
|
|
179
|
+
this.mutationJournal.fail(mutation.mutationId, toJournalError(error));
|
|
180
|
+
reject(error);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
} catch (err) {
|
|
184
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
185
|
+
try {
|
|
186
|
+
for (var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
187
|
+
var { mutation: mutation1, reject: reject1 } = _step.value;
|
|
188
|
+
this.mutationJournal.fail(mutation1.mutationId, toJournalError(err));
|
|
189
|
+
reject1(err);
|
|
190
|
+
}
|
|
191
|
+
} catch (err2) {
|
|
192
|
+
_didIteratorError = true;
|
|
193
|
+
_iteratorError = err2;
|
|
194
|
+
} finally {
|
|
195
|
+
try {
|
|
196
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
197
|
+
_iterator.return();
|
|
198
|
+
}
|
|
199
|
+
} finally {
|
|
200
|
+
if (_didIteratorError) {
|
|
201
|
+
throw _iteratorError;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
key: "forceBatchFlush",
|
|
210
|
+
value: (
|
|
211
|
+
/**
|
|
212
|
+
* Force flush any pending batched mutations.
|
|
213
|
+
*/
|
|
214
|
+
async function forceBatchFlush() {
|
|
215
|
+
this.batchDebouncer.cancel();
|
|
216
|
+
await this.flushBatch();
|
|
217
|
+
})
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
key: "mutate",
|
|
221
|
+
value: async function mutate(mutation) {
|
|
222
|
+
var _mutation_temporaryName;
|
|
223
|
+
if (this.options.onMutationStart) this.options.onMutationStart(mutation);
|
|
224
|
+
var { doc } = mutation;
|
|
225
|
+
if ((mutation.operation === import_types2.Operation.Update || mutation.operation === import_types2.Operation.Delete) && !doc.name) {
|
|
226
|
+
throw new Error("docname is required for update/delete operations");
|
|
227
|
+
}
|
|
228
|
+
var version = mutation.version;
|
|
229
|
+
var cachedDoc = void 0;
|
|
230
|
+
if (doc.name) {
|
|
231
|
+
cachedDoc = this.normalizedCache.get({
|
|
232
|
+
doctype: doc.doctype,
|
|
233
|
+
name: doc.name
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
if (version === void 0 && doc.name) {
|
|
237
|
+
var _this_options_versionFields;
|
|
238
|
+
var versionField = ((_this_options_versionFields = this.options.versionFields) === null || _this_options_versionFields === void 0 ? void 0 : _this_options_versionFields[doc.doctype]) || this.options.versionField || "modified";
|
|
239
|
+
var cachedVersion = cachedDoc ? cachedDoc[versionField] : void 0;
|
|
240
|
+
if (typeof cachedVersion === "string") version = cachedVersion;
|
|
241
|
+
}
|
|
242
|
+
if (mutation.operation === import_types2.Operation.Update && doc.name) {
|
|
243
|
+
var _this_options_onStoreChange, _this_options;
|
|
244
|
+
await this.handleOptimisticUpdate(mutation, cachedDoc);
|
|
245
|
+
(_this_options_onStoreChange = (_this_options = this.options).onStoreChange) === null || _this_options_onStoreChange === void 0 ? void 0 : _this_options_onStoreChange.call(_this_options);
|
|
246
|
+
}
|
|
247
|
+
if (mutation.operation === import_types2.Operation.Create) {
|
|
248
|
+
var _this_options_onStoreChange1, _this_options1;
|
|
249
|
+
await this.handleOptimisticCreate(mutation);
|
|
250
|
+
(_this_options_onStoreChange1 = (_this_options1 = this.options).onStoreChange) === null || _this_options_onStoreChange1 === void 0 ? void 0 : _this_options_onStoreChange1.call(_this_options1);
|
|
251
|
+
}
|
|
252
|
+
if (version === void 0 && doc.name && (mutation.operation === import_types2.Operation.Update || mutation.operation === import_types2.Operation.Delete) && !cachedDoc) {
|
|
253
|
+
try {
|
|
254
|
+
var _this_options_versionFields1;
|
|
255
|
+
cachedDoc = await this.db.getDoc(doc.doctype, doc.name);
|
|
256
|
+
var versionField1 = ((_this_options_versionFields1 = this.options.versionFields) === null || _this_options_versionFields1 === void 0 ? void 0 : _this_options_versionFields1[doc.doctype]) || this.options.versionField || "modified";
|
|
257
|
+
var cachedVersion1 = cachedDoc ? cachedDoc[versionField1] : void 0;
|
|
258
|
+
if (typeof cachedVersion1 === "string") version = cachedVersion1;
|
|
259
|
+
this.normalizedCache.upsert(cachedDoc);
|
|
260
|
+
} catch (err) {
|
|
261
|
+
if (this.options.onTrace) {
|
|
262
|
+
this.options.onTrace({
|
|
263
|
+
event: "version-fetch-failed",
|
|
264
|
+
details: {
|
|
265
|
+
doctype: doc.doctype,
|
|
266
|
+
name: doc.name,
|
|
267
|
+
error: err
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
var values = mutation.operation === import_types2.Operation.Delete ? void 0 : mutation.operation === import_types2.Operation.Create ? mutation.doc : mutation.doc;
|
|
274
|
+
this.mutationJournal.add(mutation.mutationId, {
|
|
275
|
+
doctype: doc.doctype,
|
|
276
|
+
docname: mutation.operation === import_types2.Operation.Create ? (_mutation_temporaryName = mutation.temporaryName) !== null && _mutation_temporaryName !== void 0 ? _mutation_temporaryName : doc.name : doc.name,
|
|
277
|
+
values,
|
|
278
|
+
operation: mutation.operation,
|
|
279
|
+
version,
|
|
280
|
+
status: import_types2.Status.Pending,
|
|
281
|
+
snapshot: doc.name ? cachedDoc : void 0
|
|
282
|
+
});
|
|
283
|
+
if (mutation.operation === import_types2.Operation.Delete && doc.name) {
|
|
284
|
+
var _this_options_onStoreChange2, _this_options2;
|
|
285
|
+
this.applyOptimisticDelete(doc.doctype, doc.name);
|
|
286
|
+
(_this_options_onStoreChange2 = (_this_options2 = this.options).onStoreChange) === null || _this_options_onStoreChange2 === void 0 ? void 0 : _this_options_onStoreChange2.call(_this_options2);
|
|
287
|
+
}
|
|
288
|
+
if (this.options.enableBatching && !mutation.execute) {
|
|
289
|
+
try {
|
|
290
|
+
await this.queueForBatch(mutation);
|
|
291
|
+
if (mutation.operation === import_types2.Operation.Create) {
|
|
292
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
293
|
+
try {
|
|
294
|
+
for (var _iterator = this.subscriptionManager.getAllSubscriptions().values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
295
|
+
var subscription = _step.value;
|
|
296
|
+
if (subscription.query.doctype === mutation.doc.doctype) {
|
|
297
|
+
this.rehydrationManager.scheduleRehydration(subscription, import_types2.RehydrationReason.Create);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
} catch (err) {
|
|
301
|
+
_didIteratorError = true;
|
|
302
|
+
_iteratorError = err;
|
|
303
|
+
} finally {
|
|
304
|
+
try {
|
|
305
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
306
|
+
_iterator.return();
|
|
307
|
+
}
|
|
308
|
+
} finally {
|
|
309
|
+
if (_didIteratorError) {
|
|
310
|
+
throw _iteratorError;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
} catch (err) {
|
|
316
|
+
await this.handleMutationError(mutation, err);
|
|
317
|
+
throw err;
|
|
318
|
+
}
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
try {
|
|
322
|
+
var _this_realtime;
|
|
323
|
+
if (mutation.operation === import_types2.Operation.Create) {
|
|
324
|
+
await this.handleServerCreate(mutation);
|
|
325
|
+
} else if (mutation.operation === import_types2.Operation.Update && doc.name) {
|
|
326
|
+
await this.handleServerUpdate(mutation, version);
|
|
327
|
+
} else if (mutation.operation === import_types2.Operation.Delete && doc.name) {
|
|
328
|
+
await this.handleServerDelete(mutation, version);
|
|
329
|
+
}
|
|
330
|
+
this.mutationJournal.confirm(mutation.mutationId);
|
|
331
|
+
if (this.options.onMutationSuccess) {
|
|
332
|
+
this.options.onMutationSuccess(mutation);
|
|
333
|
+
}
|
|
334
|
+
if (mutation.operation === import_types2.Operation.Create) {
|
|
335
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
336
|
+
try {
|
|
337
|
+
for (var _iterator1 = this.subscriptionManager.getAllSubscriptions().values()[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
338
|
+
var subscription1 = _step1.value;
|
|
339
|
+
if (subscription1.query.doctype === mutation.doc.doctype) {
|
|
340
|
+
this.rehydrationManager.scheduleRehydration(subscription1, import_types2.RehydrationReason.Create);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
} catch (err) {
|
|
344
|
+
_didIteratorError1 = true;
|
|
345
|
+
_iteratorError1 = err;
|
|
346
|
+
} finally {
|
|
347
|
+
try {
|
|
348
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
349
|
+
_iterator1.return();
|
|
350
|
+
}
|
|
351
|
+
} finally {
|
|
352
|
+
if (_didIteratorError1) {
|
|
353
|
+
throw _iteratorError1;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (!((_this_realtime = this.realtime) === null || _this_realtime === void 0 ? void 0 : _this_realtime.isHealthy())) {
|
|
359
|
+
await this.refetchAffectedDocs(mutation);
|
|
360
|
+
}
|
|
361
|
+
} catch (err) {
|
|
362
|
+
await this.handleMutationError(mutation, err);
|
|
363
|
+
throw err;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
key: "handleOptimisticUpdate",
|
|
369
|
+
value: async function handleOptimisticUpdate(mutation, cachedDoc) {
|
|
370
|
+
var doc = cachedDoc ? {
|
|
371
|
+
...cachedDoc,
|
|
372
|
+
...mutation.doc
|
|
373
|
+
} : mutation.doc;
|
|
374
|
+
this.normalizedCache.upsert(doc);
|
|
375
|
+
if (this.options.onOptimisticApply) {
|
|
376
|
+
this.options.onOptimisticApply({
|
|
377
|
+
doctype: mutation.doc.doctype,
|
|
378
|
+
name: mutation.doc.name,
|
|
379
|
+
operation: mutation.operation
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
this.subscriptionManager.updateSubscriptionMembership(doc);
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
key: "handleOptimisticCreate",
|
|
387
|
+
value: async function handleOptimisticCreate(mutation) {
|
|
388
|
+
var temporaryName = mutation.doc.name || `tmp_${cryptoRandomId()}`;
|
|
389
|
+
mutation.temporaryName = temporaryName;
|
|
390
|
+
var optimisticDoc = {
|
|
391
|
+
...mutation.doc,
|
|
392
|
+
name: temporaryName
|
|
393
|
+
};
|
|
394
|
+
this.normalizedCache.upsert(optimisticDoc);
|
|
395
|
+
if (!this.globalOptimisticDocIds.has(mutation.doc.doctype)) {
|
|
396
|
+
this.globalOptimisticDocIds.set(mutation.doc.doctype, /* @__PURE__ */ new Set());
|
|
397
|
+
}
|
|
398
|
+
var globalDocIds = this.globalOptimisticDocIds.get(mutation.doc.doctype);
|
|
399
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
400
|
+
try {
|
|
401
|
+
for (var _iterator = this.subscriptionManager.getAllSubscriptions().values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
402
|
+
var subscription = _step.value;
|
|
403
|
+
if (subscription.query.doctype !== mutation.doc.doctype) continue;
|
|
404
|
+
var matches = (0, import_filters.matchesFilters)(optimisticDoc, subscription.query.filters);
|
|
405
|
+
if (!matches) continue;
|
|
406
|
+
if (globalDocIds.has(temporaryName)) {
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
if (subscription.query.orderBy && typeof subscription.query.limit === "number" && subscription.query.limit > 0 && subscription.docIds.length > 0) {
|
|
410
|
+
var placement = this.determineOptimisticPlacement(subscription, optimisticDoc);
|
|
411
|
+
switch (placement) {
|
|
412
|
+
case import_types2.PlacementType.Before:
|
|
413
|
+
if (subscription.metadata) {
|
|
414
|
+
subscription.metadata.itemsBeforePage = (subscription.metadata.itemsBeforePage || 0) + 1;
|
|
415
|
+
}
|
|
416
|
+
continue;
|
|
417
|
+
case import_types2.PlacementType.After:
|
|
418
|
+
if (subscription.metadata) {
|
|
419
|
+
subscription.metadata.itemsAfterPage = (subscription.metadata.itemsAfterPage || 0) + 1;
|
|
420
|
+
}
|
|
421
|
+
continue;
|
|
422
|
+
case import_types2.PlacementType.Unknown:
|
|
423
|
+
subscription.pendingRehydration = import_types2.PendingRehydrationType.FullRefresh;
|
|
424
|
+
this.rehydrationManager.scheduleRehydration(subscription, import_types2.RehydrationReason.Uncertain);
|
|
425
|
+
break;
|
|
426
|
+
case import_types2.PlacementType.Within: break;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
if (!subscription.docIds.includes(temporaryName)) {
|
|
430
|
+
this.subscriptionManager.insertDocumentIntoSubscription(subscription, optimisticDoc);
|
|
431
|
+
globalDocIds.add(temporaryName);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
} catch (err) {
|
|
435
|
+
_didIteratorError = true;
|
|
436
|
+
_iteratorError = err;
|
|
437
|
+
} finally {
|
|
438
|
+
try {
|
|
439
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
440
|
+
_iterator.return();
|
|
441
|
+
}
|
|
442
|
+
} finally {
|
|
443
|
+
if (_didIteratorError) {
|
|
444
|
+
throw _iteratorError;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
key: "handleServerCreate",
|
|
452
|
+
value: async function handleServerCreate(mutation) {
|
|
453
|
+
var _mutation_temporaryName;
|
|
454
|
+
var created = mutation.execute ? await mutation.execute() : await this.db.createDoc({
|
|
455
|
+
...mutation.doc,
|
|
456
|
+
client_mutation_id: mutation.mutationId
|
|
457
|
+
});
|
|
458
|
+
var realName = created === null || created === void 0 ? void 0 : created.name;
|
|
459
|
+
var temporaryName = (_mutation_temporaryName = mutation.temporaryName) !== null && _mutation_temporaryName !== void 0 ? _mutation_temporaryName : mutation.doc.name;
|
|
460
|
+
if (realName) {
|
|
461
|
+
this.normalizedCache.upsert({
|
|
462
|
+
...created,
|
|
463
|
+
doctype: created.doctype || mutation.doc.doctype
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
if (realName && temporaryName && realName !== temporaryName) {
|
|
467
|
+
this.handleTemporaryToRealMapping(mutation.doc.doctype, temporaryName, realName);
|
|
468
|
+
this.rehydrationManager.registerTempIdMapping(temporaryName, realName);
|
|
469
|
+
} else if (temporaryName) {
|
|
470
|
+
var globalDocs = this.globalOptimisticDocIds.get(mutation.doc.doctype);
|
|
471
|
+
if (globalDocs) {
|
|
472
|
+
globalDocs.delete(temporaryName);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
key: "handleServerUpdate",
|
|
479
|
+
value: async function handleServerUpdate(mutation, _version) {
|
|
480
|
+
if (mutation.execute) {
|
|
481
|
+
var updated = await mutation.execute();
|
|
482
|
+
if (updated === null || updated === void 0 ? void 0 : updated.name) {
|
|
483
|
+
this.normalizedCache.upsert({
|
|
484
|
+
...updated,
|
|
485
|
+
doctype: updated.doctype || mutation.doc.doctype
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
await this.db.updateDoc(mutation.doc);
|
|
491
|
+
}
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
key: "applyOptimisticDelete",
|
|
495
|
+
value: (
|
|
496
|
+
/**
|
|
497
|
+
* Applies the local side of a delete: cache eviction, subscription
|
|
498
|
+
* membership removal, and gap-filling rehydration. Runs before the server
|
|
499
|
+
* call (mutate() body) so the row disappears immediately; the journal
|
|
500
|
+
* snapshot restores it if the server rejects.
|
|
501
|
+
*/
|
|
502
|
+
function applyOptimisticDelete(doctype, name) {
|
|
503
|
+
var affected = [...this.subscriptionManager.getAllSubscriptions().values()].filter(function(subscription2) {
|
|
504
|
+
return subscription2.query.doctype === doctype && subscription2.docIds.includes(name);
|
|
505
|
+
});
|
|
506
|
+
this.normalizedCache.remove({
|
|
507
|
+
doctype,
|
|
508
|
+
name
|
|
509
|
+
});
|
|
510
|
+
this.subscriptionManager.removeFromAllSubscriptions(doctype, name);
|
|
511
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
512
|
+
try {
|
|
513
|
+
for (var _iterator = affected[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
514
|
+
var subscription = _step.value;
|
|
515
|
+
this.rehydrationManager.scheduleRehydration(subscription, import_types2.RehydrationReason.Delete);
|
|
516
|
+
}
|
|
517
|
+
} catch (err) {
|
|
518
|
+
_didIteratorError = true;
|
|
519
|
+
_iteratorError = err;
|
|
520
|
+
} finally {
|
|
521
|
+
try {
|
|
522
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
523
|
+
_iterator.return();
|
|
524
|
+
}
|
|
525
|
+
} finally {
|
|
526
|
+
if (_didIteratorError) {
|
|
527
|
+
throw _iteratorError;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
})
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
key: "handleServerDelete",
|
|
535
|
+
value: async function handleServerDelete(mutation, _version) {
|
|
536
|
+
if (mutation.execute) {
|
|
537
|
+
await mutation.execute();
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
await this.db.deleteDoc(mutation.doc);
|
|
541
|
+
}
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
key: "handleTemporaryToRealMapping",
|
|
545
|
+
value: function handleTemporaryToRealMapping(doctype, temporaryName, realName) {
|
|
546
|
+
this.temporaryIdToRealNameMap.set(temporaryName, realName);
|
|
547
|
+
var globalDocs = this.globalOptimisticDocIds.get(doctype);
|
|
548
|
+
if (globalDocs) {
|
|
549
|
+
globalDocs.delete(temporaryName);
|
|
550
|
+
}
|
|
551
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
552
|
+
try {
|
|
553
|
+
for (var _iterator = this.subscriptionManager.getAllSubscriptions().values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
554
|
+
var subscription = _step.value;
|
|
555
|
+
if (subscription.query.doctype !== doctype) continue;
|
|
556
|
+
if (!subscription.docIds.includes(temporaryName)) continue;
|
|
557
|
+
subscription.docIds = subscription.docIds.includes(realName) ? subscription.docIds.filter(function(id) {
|
|
558
|
+
return id !== temporaryName;
|
|
559
|
+
}) : subscription.docIds.map(function(id) {
|
|
560
|
+
return id === temporaryName ? realName : id;
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
} catch (err) {
|
|
564
|
+
_didIteratorError = true;
|
|
565
|
+
_iteratorError = err;
|
|
566
|
+
} finally {
|
|
567
|
+
try {
|
|
568
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
569
|
+
_iterator.return();
|
|
570
|
+
}
|
|
571
|
+
} finally {
|
|
572
|
+
if (_didIteratorError) {
|
|
573
|
+
throw _iteratorError;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
this.normalizedCache.remove({
|
|
578
|
+
doctype,
|
|
579
|
+
name: temporaryName
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
key: "refetchAffectedDocs",
|
|
585
|
+
value: async function refetchAffectedDocs(mutation) {
|
|
586
|
+
var _mutation_affected;
|
|
587
|
+
var targets = [];
|
|
588
|
+
var docname = mutation.doc.name;
|
|
589
|
+
var doctype = mutation.doc.doctype;
|
|
590
|
+
var realName = docname && this.temporaryIdToRealNameMap.get(docname) || docname;
|
|
591
|
+
if (realName && mutation.operation === import_types2.Operation.Update) {
|
|
592
|
+
targets.push({
|
|
593
|
+
doctype,
|
|
594
|
+
name: realName
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
if ((_mutation_affected = mutation.affected) === null || _mutation_affected === void 0 ? void 0 : _mutation_affected.length) targets.push(...mutation.affected);
|
|
598
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
599
|
+
try {
|
|
600
|
+
for (var _iterator = targets[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
601
|
+
var target = _step.value;
|
|
602
|
+
var fresh = await this.db.getDoc(target.doctype, target.name);
|
|
603
|
+
this.normalizedCache.upsert(fresh);
|
|
604
|
+
}
|
|
605
|
+
} catch (err) {
|
|
606
|
+
_didIteratorError = true;
|
|
607
|
+
_iteratorError = err;
|
|
608
|
+
} finally {
|
|
609
|
+
try {
|
|
610
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
611
|
+
_iterator.return();
|
|
612
|
+
}
|
|
613
|
+
} finally {
|
|
614
|
+
if (_didIteratorError) {
|
|
615
|
+
throw _iteratorError;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
key: "handleMutationError",
|
|
623
|
+
value: async function handleMutationError(mutation, err) {
|
|
624
|
+
if (this.options.onMutationError) this.options.onMutationError({
|
|
625
|
+
mutation,
|
|
626
|
+
err
|
|
627
|
+
});
|
|
628
|
+
this.mutationJournal.fail(mutation.mutationId, toJournalError(err));
|
|
629
|
+
var entry = this.mutationJournal.get(mutation.mutationId);
|
|
630
|
+
var isOffline = typeof navigator !== "undefined" && navigator.onLine === false;
|
|
631
|
+
if (!isOffline) {
|
|
632
|
+
await this.rollbackOptimisticState(mutation, entry);
|
|
633
|
+
}
|
|
634
|
+
var errorWithStatus = err;
|
|
635
|
+
var docname = mutation.doc.name;
|
|
636
|
+
if (errorWithStatus && (errorWithStatus.status === 409 || errorWithStatus.status === 412) && docname) {
|
|
637
|
+
await this.handleConflict(mutation, entry);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
key: "rollbackOptimisticState",
|
|
643
|
+
value: (
|
|
644
|
+
/**
|
|
645
|
+
* Rolls back optimistic state when a mutation fails.
|
|
646
|
+
* Handles all operation types: create, update, and delete.
|
|
647
|
+
*/
|
|
648
|
+
async function rollbackOptimisticState(mutation, entry) {
|
|
649
|
+
var doctype = mutation.doc.doctype;
|
|
650
|
+
var docname = mutation.doc.name;
|
|
651
|
+
switch (mutation.operation) {
|
|
652
|
+
case import_types2.Operation.Create:
|
|
653
|
+
await this.handleFailedCreate(mutation);
|
|
654
|
+
break;
|
|
655
|
+
case import_types2.Operation.Update:
|
|
656
|
+
if ((entry === null || entry === void 0 ? void 0 : entry.snapshot) && docname) {
|
|
657
|
+
this.normalizedCache.upsert(entry.snapshot, { replace: true });
|
|
658
|
+
this.subscriptionManager.updateSubscriptionMembership(entry.snapshot);
|
|
659
|
+
}
|
|
660
|
+
break;
|
|
661
|
+
case import_types2.Operation.Delete:
|
|
662
|
+
if ((entry === null || entry === void 0 ? void 0 : entry.snapshot) && docname) {
|
|
663
|
+
this.normalizedCache.upsert(entry.snapshot, { replace: true });
|
|
664
|
+
var restoredDoc = entry.snapshot;
|
|
665
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
666
|
+
try {
|
|
667
|
+
for (var _iterator = this.subscriptionManager.getAllSubscriptions().values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
668
|
+
var subscription = _step.value;
|
|
669
|
+
if (subscription.query.doctype !== doctype) continue;
|
|
670
|
+
var matches = (0, import_filters.matchesFilters)(restoredDoc, subscription.query.filters);
|
|
671
|
+
if (matches && !subscription.docIds.includes(docname)) {
|
|
672
|
+
this.subscriptionManager.insertDocumentIntoSubscription(subscription, restoredDoc);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
} catch (err) {
|
|
676
|
+
_didIteratorError = true;
|
|
677
|
+
_iteratorError = err;
|
|
678
|
+
} finally {
|
|
679
|
+
try {
|
|
680
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
681
|
+
_iterator.return();
|
|
682
|
+
}
|
|
683
|
+
} finally {
|
|
684
|
+
if (_didIteratorError) {
|
|
685
|
+
throw _iteratorError;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
break;
|
|
691
|
+
}
|
|
692
|
+
})
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
key: "handleFailedCreate",
|
|
696
|
+
value: async function handleFailedCreate(mutation) {
|
|
697
|
+
var _mutation_temporaryName;
|
|
698
|
+
var temporaryName = mutation.operation === import_types2.Operation.Create ? (_mutation_temporaryName = mutation.temporaryName) !== null && _mutation_temporaryName !== void 0 ? _mutation_temporaryName : mutation.doc.name : mutation.doc.name;
|
|
699
|
+
var doctype = mutation.doc.doctype;
|
|
700
|
+
if (temporaryName) {
|
|
701
|
+
var globalDocs = this.globalOptimisticDocIds.get(doctype);
|
|
702
|
+
if (globalDocs) {
|
|
703
|
+
globalDocs.delete(temporaryName);
|
|
704
|
+
}
|
|
705
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
706
|
+
try {
|
|
707
|
+
for (var _iterator = this.subscriptionManager.getAllSubscriptions().values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
708
|
+
var subscription = _step.value;
|
|
709
|
+
if (subscription.query.doctype !== doctype) continue;
|
|
710
|
+
subscription.docIds = subscription.docIds.filter(function(id) {
|
|
711
|
+
return id !== temporaryName;
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
} catch (err) {
|
|
715
|
+
_didIteratorError = true;
|
|
716
|
+
_iteratorError = err;
|
|
717
|
+
} finally {
|
|
718
|
+
try {
|
|
719
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
720
|
+
_iterator.return();
|
|
721
|
+
}
|
|
722
|
+
} finally {
|
|
723
|
+
if (_didIteratorError) {
|
|
724
|
+
throw _iteratorError;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
this.normalizedCache.remove({
|
|
729
|
+
doctype,
|
|
730
|
+
name: temporaryName
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
key: "handleConflict",
|
|
737
|
+
value: async function handleConflict(mutation, entry) {
|
|
738
|
+
var doctype = mutation.doc.doctype;
|
|
739
|
+
var docname = mutation.doc.name;
|
|
740
|
+
if (!docname) return;
|
|
741
|
+
try {
|
|
742
|
+
var _ref;
|
|
743
|
+
var latest = await this.db.getDoc(doctype, docname);
|
|
744
|
+
var base = entry === null || entry === void 0 ? void 0 : entry.snapshot;
|
|
745
|
+
var clientPartial = (_ref = mutation.operation === import_types2.Operation.Delete ? void 0 : mutation.doc) !== null && _ref !== void 0 ? _ref : {};
|
|
746
|
+
var fullClient = base ? {
|
|
747
|
+
...base,
|
|
748
|
+
...clientPartial,
|
|
749
|
+
doctype,
|
|
750
|
+
name: docname
|
|
751
|
+
} : {
|
|
752
|
+
...clientPartial,
|
|
753
|
+
doctype,
|
|
754
|
+
name: docname
|
|
755
|
+
};
|
|
756
|
+
var mergeConfig = this.buildMergeConfig();
|
|
757
|
+
var nonOverlap = (0, import_merge.merge)(base, fullClient, latest, mergeConfig, doctype);
|
|
758
|
+
if (!nonOverlap.hasConflicts) {
|
|
759
|
+
var _this_options_versionFields;
|
|
760
|
+
var versionField = ((_this_options_versionFields = this.options.versionFields) === null || _this_options_versionFields === void 0 ? void 0 : _this_options_versionFields[doctype]) || this.options.versionField || "modified";
|
|
761
|
+
if (nonOverlap.merged) {
|
|
762
|
+
var newId = cryptoRandomId();
|
|
763
|
+
await this.db.updateDoc({
|
|
764
|
+
...nonOverlap.merged,
|
|
765
|
+
client_mutation_id: newId,
|
|
766
|
+
base_modified: latest[versionField] || void 0
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
var refreshed = await this.db.getDoc(doctype, docname);
|
|
770
|
+
this.normalizedCache.upsert(refreshed);
|
|
771
|
+
this.mutationJournal.confirm(mutation.mutationId);
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
this.normalizedCache.upsert(latest);
|
|
775
|
+
} catch (unused) {}
|
|
776
|
+
if (this.options.onConflict) this.options.onConflict({
|
|
777
|
+
doctype,
|
|
778
|
+
name: docname
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
key: "determineOptimisticPlacement",
|
|
784
|
+
value: (
|
|
785
|
+
/**
|
|
786
|
+
* Determines optimal placement for an optimistic item based on sort fields.
|
|
787
|
+
* Supports multi-column sorting with proper tie-breaking.
|
|
788
|
+
*
|
|
789
|
+
* @param subscription - The subscription to check placement against
|
|
790
|
+
* @param candidate - The document to place
|
|
791
|
+
* @returns Placement relative to current page:
|
|
792
|
+
* - 'before': Item belongs on a previous page
|
|
793
|
+
* - 'within': Item belongs on the current page
|
|
794
|
+
* - 'after': Item belongs on a later page
|
|
795
|
+
* - 'unknown': Cannot determine placement (needs full refresh)
|
|
796
|
+
*
|
|
797
|
+
* @remarks
|
|
798
|
+
* Uses page boundaries when available for O(1) placement checks.
|
|
799
|
+
* Falls back to comparing against first/last items in current page.
|
|
800
|
+
* Supports multi-field sorting with tie-breaking.
|
|
801
|
+
*/
|
|
802
|
+
function determineOptimisticPlacement(subscription, candidate) {
|
|
803
|
+
var _subscription_boundaries, _subscription_boundaries1;
|
|
804
|
+
var docIds = subscription.docIds;
|
|
805
|
+
if (!docIds.length) return import_types2.PlacementType.Unknown;
|
|
806
|
+
if (((_subscription_boundaries = subscription.boundaries) === null || _subscription_boundaries === void 0 ? void 0 : _subscription_boundaries.firstItem) && ((_subscription_boundaries1 = subscription.boundaries) === null || _subscription_boundaries1 === void 0 ? void 0 : _subscription_boundaries1.lastItem)) {
|
|
807
|
+
return this.determinePlacementWithBoundaries(subscription.boundaries, candidate, subscription.query.orderBy);
|
|
808
|
+
}
|
|
809
|
+
var order = subscription.query.orderBy;
|
|
810
|
+
if (!order) return import_types2.PlacementType.Unknown;
|
|
811
|
+
var doctype = subscription.query.doctype;
|
|
812
|
+
var first = this.normalizedCache.get({
|
|
813
|
+
doctype,
|
|
814
|
+
name: docIds[0]
|
|
815
|
+
});
|
|
816
|
+
var last = this.normalizedCache.get({
|
|
817
|
+
doctype,
|
|
818
|
+
name: docIds[docIds.length - 1]
|
|
819
|
+
});
|
|
820
|
+
if (!first || !last) return import_types2.PlacementType.Unknown;
|
|
821
|
+
var sortFields = this.parseSortFields(order);
|
|
822
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
823
|
+
try {
|
|
824
|
+
for (var _iterator = sortFields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
825
|
+
var { field, isAsc } = _step.value;
|
|
826
|
+
var candidateValue = candidate[field];
|
|
827
|
+
var firstValue = first[field];
|
|
828
|
+
var lastValue = last[field];
|
|
829
|
+
if (candidateValue == null || firstValue == null || lastValue == null) {
|
|
830
|
+
continue;
|
|
831
|
+
}
|
|
832
|
+
if (isAsc) {
|
|
833
|
+
if (candidateValue < firstValue) return import_types2.PlacementType.Before;
|
|
834
|
+
if (candidateValue > lastValue) return import_types2.PlacementType.After;
|
|
835
|
+
} else {
|
|
836
|
+
if (candidateValue > firstValue) return import_types2.PlacementType.Before;
|
|
837
|
+
if (candidateValue < lastValue) return import_types2.PlacementType.After;
|
|
838
|
+
}
|
|
839
|
+
if (candidateValue !== firstValue && candidateValue !== lastValue) {
|
|
840
|
+
return import_types2.PlacementType.Within;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
} catch (err) {
|
|
844
|
+
_didIteratorError = true;
|
|
845
|
+
_iteratorError = err;
|
|
846
|
+
} finally {
|
|
847
|
+
try {
|
|
848
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
849
|
+
_iterator.return();
|
|
850
|
+
}
|
|
851
|
+
} finally {
|
|
852
|
+
if (_didIteratorError) {
|
|
853
|
+
throw _iteratorError;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
return import_types2.PlacementType.Within;
|
|
858
|
+
})
|
|
859
|
+
},
|
|
860
|
+
{
|
|
861
|
+
key: "determinePlacementWithBoundaries",
|
|
862
|
+
value: (function determinePlacementWithBoundaries(boundaries, candidate, orderBy) {
|
|
863
|
+
if (!boundaries.firstItem || !boundaries.lastItem) return import_types2.PlacementType.Unknown;
|
|
864
|
+
var sortFields = this.parseSortFields(orderBy);
|
|
865
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
866
|
+
try {
|
|
867
|
+
for (var _iterator = sortFields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
868
|
+
var { field, isAsc } = _step.value;
|
|
869
|
+
var candidateValue = candidate[field];
|
|
870
|
+
var firstValue = boundaries.firstItem[field];
|
|
871
|
+
var lastValue = boundaries.lastItem[field];
|
|
872
|
+
if (candidateValue == null || firstValue == null || lastValue == null) {
|
|
873
|
+
continue;
|
|
874
|
+
}
|
|
875
|
+
if (isAsc) {
|
|
876
|
+
if (candidateValue < firstValue) return import_types2.PlacementType.Before;
|
|
877
|
+
if (candidateValue > lastValue) return import_types2.PlacementType.After;
|
|
878
|
+
} else {
|
|
879
|
+
if (candidateValue > firstValue) return import_types2.PlacementType.Before;
|
|
880
|
+
if (candidateValue < lastValue) return import_types2.PlacementType.After;
|
|
881
|
+
}
|
|
882
|
+
if (candidateValue !== firstValue && candidateValue !== lastValue) {
|
|
883
|
+
return import_types2.PlacementType.Within;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
} catch (err) {
|
|
887
|
+
_didIteratorError = true;
|
|
888
|
+
_iteratorError = err;
|
|
889
|
+
} finally {
|
|
890
|
+
try {
|
|
891
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
892
|
+
_iterator.return();
|
|
893
|
+
}
|
|
894
|
+
} finally {
|
|
895
|
+
if (_didIteratorError) {
|
|
896
|
+
throw _iteratorError;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
return import_types2.PlacementType.Within;
|
|
901
|
+
})
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
key: "parseSortFields",
|
|
905
|
+
value: function parseSortFields(orderBy) {
|
|
906
|
+
if (!orderBy) return [{
|
|
907
|
+
field: "name",
|
|
908
|
+
isAsc: true
|
|
909
|
+
}];
|
|
910
|
+
var orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];
|
|
911
|
+
var sortFields = orderByArray.map(function(ob) {
|
|
912
|
+
return {
|
|
913
|
+
field: ob.field,
|
|
914
|
+
isAsc: ob.order !== import_types.Order.Desc
|
|
915
|
+
};
|
|
916
|
+
});
|
|
917
|
+
var hasNameField = sortFields.some(function(sf) {
|
|
918
|
+
return sf.field === "name";
|
|
919
|
+
});
|
|
920
|
+
if (!hasNameField) {
|
|
921
|
+
sortFields.push({
|
|
922
|
+
field: "name",
|
|
923
|
+
isAsc: true
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
return sortFields;
|
|
927
|
+
}
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
key: "replayPending",
|
|
931
|
+
value: (
|
|
932
|
+
/**
|
|
933
|
+
* Replays pending mutations with simplified error handling and rate limiting.
|
|
934
|
+
*
|
|
935
|
+
* Since HTTP client now handles retries automatically for transient errors,
|
|
936
|
+
* we only need to handle:
|
|
937
|
+
* - Success → confirm and remove from journal
|
|
938
|
+
* - Conflict (409/412) → attempt merge resolution, then retry
|
|
939
|
+
* - Auth (401/403) → notify user, keep in journal for later retry
|
|
940
|
+
* - Permanent (4xx validation) → fail and remove from journal
|
|
941
|
+
* - Failed (exhausted retries) → keep in journal but notify
|
|
942
|
+
*
|
|
943
|
+
* The replay path uses plain CRUD without optimistic writes,
|
|
944
|
+
* since optimistic state is already reflected in the cache.
|
|
945
|
+
*
|
|
946
|
+
* Rate limiting is applied to prevent hammering the server when replaying
|
|
947
|
+
* large numbers of queued mutations after coming back online.
|
|
948
|
+
*/
|
|
949
|
+
async function replayPending() {
|
|
950
|
+
var _this = this;
|
|
951
|
+
var _this_options_replayRateLimit;
|
|
952
|
+
var anyFailed = false;
|
|
953
|
+
if (this.options.onReplayStart) this.options.onReplayStart();
|
|
954
|
+
var pendingMutations = this.mutationJournal.listPending();
|
|
955
|
+
if (pendingMutations.length === 0) {
|
|
956
|
+
if (this.options.onReplayComplete) {
|
|
957
|
+
this.options.onReplayComplete({ anyFailed: false });
|
|
958
|
+
}
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
var rateLimit = (_this_options_replayRateLimit = this.options.replayRateLimit) !== null && _this_options_replayRateLimit !== void 0 ? _this_options_replayRateLimit : 10;
|
|
962
|
+
var processMutation = async function processMutation2(mutation2) {
|
|
963
|
+
var { id, entry } = mutation2;
|
|
964
|
+
if (_this.options.onRetry) {
|
|
965
|
+
_this.options.onRetry({
|
|
966
|
+
id,
|
|
967
|
+
operation: entry.operation
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
try {
|
|
971
|
+
if (entry.operation === import_types2.Operation.Create) {
|
|
972
|
+
var created = await _this.db.createDoc({
|
|
973
|
+
...entry.values,
|
|
974
|
+
client_mutation_id: id,
|
|
975
|
+
doctype: entry.doctype,
|
|
976
|
+
name: entry.docname || cryptoRandomId()
|
|
977
|
+
});
|
|
978
|
+
if (created === null || created === void 0 ? void 0 : created.name) {
|
|
979
|
+
_this.normalizedCache.upsert({
|
|
980
|
+
...created,
|
|
981
|
+
doctype: created.doctype || entry.doctype
|
|
982
|
+
});
|
|
983
|
+
if (entry.docname && created.name !== entry.docname) {
|
|
984
|
+
_this.handleTemporaryToRealMapping(entry.doctype, entry.docname, created.name);
|
|
985
|
+
_this.rehydrationManager.registerTempIdMapping(entry.docname, created.name);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
} else if (entry.operation === import_types2.Operation.Update && entry.docname) {
|
|
989
|
+
await _this.db.updateDoc({
|
|
990
|
+
...entry.values,
|
|
991
|
+
client_mutation_id: id,
|
|
992
|
+
base_modified: entry.version,
|
|
993
|
+
doctype: entry.doctype,
|
|
994
|
+
name: entry.docname
|
|
995
|
+
});
|
|
996
|
+
} else if (entry.operation === import_types2.Operation.Delete && entry.docname) {
|
|
997
|
+
await _this.db.deleteDoc({
|
|
998
|
+
doctype: entry.doctype,
|
|
999
|
+
name: entry.docname,
|
|
1000
|
+
client_mutation_id: id
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
_this.mutationJournal.confirm(id);
|
|
1004
|
+
} catch (err) {
|
|
1005
|
+
var errorClass = _this.classifyError(err);
|
|
1006
|
+
anyFailed = true;
|
|
1007
|
+
if (errorClass === "conflict") {
|
|
1008
|
+
if (_this.options.onConflict) {
|
|
1009
|
+
_this.options.onConflict({
|
|
1010
|
+
doctype: entry.doctype,
|
|
1011
|
+
name: entry.docname
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
} else if (errorClass === "auth") {} else if (errorClass === "permanent") {
|
|
1015
|
+
_this.mutationJournal.fail(id, toJournalError(err));
|
|
1016
|
+
_this.notifyMutationError(id, entry, err);
|
|
1017
|
+
} else if (errorClass === "failed") {
|
|
1018
|
+
_this.mutationJournal.fail(id, toJournalError(err));
|
|
1019
|
+
_this.notifyMutationError(id, entry, err);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
var delayMs = Math.ceil(1e3 / rateLimit);
|
|
1024
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1025
|
+
try {
|
|
1026
|
+
for (var _iterator = pendingMutations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
1027
|
+
var mutation = _step.value;
|
|
1028
|
+
await processMutation(mutation);
|
|
1029
|
+
if (pendingMutations.indexOf(mutation) < pendingMutations.length - 1) {
|
|
1030
|
+
await new Promise(function(resolve) {
|
|
1031
|
+
return setTimeout(resolve, delayMs);
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
} catch (err) {
|
|
1036
|
+
_didIteratorError = true;
|
|
1037
|
+
_iteratorError = err;
|
|
1038
|
+
} finally {
|
|
1039
|
+
try {
|
|
1040
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1041
|
+
_iterator.return();
|
|
1042
|
+
}
|
|
1043
|
+
} finally {
|
|
1044
|
+
if (_didIteratorError) {
|
|
1045
|
+
throw _iteratorError;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
if (this.options.onReplayComplete) {
|
|
1050
|
+
this.options.onReplayComplete({ anyFailed });
|
|
1051
|
+
}
|
|
1052
|
+
})
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
key: "classifyError",
|
|
1056
|
+
value: (
|
|
1057
|
+
/**
|
|
1058
|
+
* Classifies errors for journal management.
|
|
1059
|
+
*/
|
|
1060
|
+
function classifyError(err) {
|
|
1061
|
+
var _errorWithStatus_response;
|
|
1062
|
+
var errorWithStatus = err;
|
|
1063
|
+
var status = (errorWithStatus === null || errorWithStatus === void 0 ? void 0 : errorWithStatus.status) || (errorWithStatus === null || errorWithStatus === void 0 ? void 0 : (_errorWithStatus_response = errorWithStatus.response) === null || _errorWithStatus_response === void 0 ? void 0 : _errorWithStatus_response.status);
|
|
1064
|
+
if (status === 409 || status === 412) return "conflict";
|
|
1065
|
+
if (status === 401 || status === 403) return "auth";
|
|
1066
|
+
if (status && status >= 400 && status < 500) return "permanent";
|
|
1067
|
+
return "failed";
|
|
1068
|
+
})
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
key: "notifyMutationError",
|
|
1072
|
+
value: (
|
|
1073
|
+
/**
|
|
1074
|
+
* Helper to notify about mutation errors with proper typing
|
|
1075
|
+
*/
|
|
1076
|
+
function notifyMutationError(id, entry, err) {
|
|
1077
|
+
if (!this.options.onMutationError) return;
|
|
1078
|
+
var mutation;
|
|
1079
|
+
if (entry.operation === import_types2.Operation.Create) {
|
|
1080
|
+
var doc = entry.values || {
|
|
1081
|
+
doctype: entry.doctype,
|
|
1082
|
+
name: entry.docname
|
|
1083
|
+
};
|
|
1084
|
+
mutation = {
|
|
1085
|
+
mutationId: id,
|
|
1086
|
+
operation: import_types2.Operation.Create,
|
|
1087
|
+
doc,
|
|
1088
|
+
version: entry.version,
|
|
1089
|
+
affected: []
|
|
1090
|
+
};
|
|
1091
|
+
} else if (entry.operation === import_types2.Operation.Update) {
|
|
1092
|
+
mutation = {
|
|
1093
|
+
mutationId: id,
|
|
1094
|
+
operation: import_types2.Operation.Update,
|
|
1095
|
+
doc: {
|
|
1096
|
+
...entry.values,
|
|
1097
|
+
doctype: entry.doctype,
|
|
1098
|
+
name: entry.docname
|
|
1099
|
+
},
|
|
1100
|
+
version: entry.version,
|
|
1101
|
+
affected: []
|
|
1102
|
+
};
|
|
1103
|
+
} else {
|
|
1104
|
+
mutation = {
|
|
1105
|
+
mutationId: id,
|
|
1106
|
+
operation: import_types2.Operation.Delete,
|
|
1107
|
+
doc: {
|
|
1108
|
+
doctype: entry.doctype,
|
|
1109
|
+
name: entry.docname
|
|
1110
|
+
},
|
|
1111
|
+
version: entry.version,
|
|
1112
|
+
affected: []
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
this.options.onMutationError({
|
|
1116
|
+
mutation,
|
|
1117
|
+
err
|
|
1118
|
+
});
|
|
1119
|
+
})
|
|
1120
|
+
},
|
|
1121
|
+
{
|
|
1122
|
+
key: "buildMergeConfig",
|
|
1123
|
+
value: (
|
|
1124
|
+
/**
|
|
1125
|
+
* Converts SyncOptions.fieldMergeConfig into the MergeConfig format
|
|
1126
|
+
* expected by the merge() function.
|
|
1127
|
+
*/
|
|
1128
|
+
function buildMergeConfig() {
|
|
1129
|
+
var fmc = this.options.fieldMergeConfig;
|
|
1130
|
+
if (!fmc) return void 0;
|
|
1131
|
+
var doctypes = {};
|
|
1132
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1133
|
+
try {
|
|
1134
|
+
for (var _iterator = Object.entries(fmc)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
1135
|
+
var [dt, fields] = _step.value;
|
|
1136
|
+
doctypes[dt] = { fields };
|
|
1137
|
+
}
|
|
1138
|
+
} catch (err) {
|
|
1139
|
+
_didIteratorError = true;
|
|
1140
|
+
_iteratorError = err;
|
|
1141
|
+
} finally {
|
|
1142
|
+
try {
|
|
1143
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1144
|
+
_iterator.return();
|
|
1145
|
+
}
|
|
1146
|
+
} finally {
|
|
1147
|
+
if (_didIteratorError) {
|
|
1148
|
+
throw _iteratorError;
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
return {
|
|
1153
|
+
defaultStrategy: import_merge.MergeStrategy.ServerWins,
|
|
1154
|
+
doctypes
|
|
1155
|
+
};
|
|
1156
|
+
})
|
|
1157
|
+
},
|
|
1158
|
+
{
|
|
1159
|
+
/** Gets temporary to real name mapping. */
|
|
1160
|
+
key: "getTemporaryIdToRealNameMap",
|
|
1161
|
+
value: function getTemporaryIdToRealNameMap() {
|
|
1162
|
+
return this.temporaryIdToRealNameMap;
|
|
1163
|
+
}
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
/** Clears all temporary mappings. */
|
|
1167
|
+
key: "clearTemporaryMappings",
|
|
1168
|
+
value: function clearTemporaryMappings() {
|
|
1169
|
+
this.temporaryIdToRealNameMap.clear();
|
|
1170
|
+
this.globalOptimisticDocIds.clear();
|
|
1171
|
+
}
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
/**
|
|
1175
|
+
* Disposes of resources.
|
|
1176
|
+
*/
|
|
1177
|
+
key: "dispose",
|
|
1178
|
+
value: function dispose() {
|
|
1179
|
+
this.batchDebouncer.cancel();
|
|
1180
|
+
this.pendingBatch = [];
|
|
1181
|
+
this.clearTemporaryMappings();
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
]);
|
|
1185
|
+
return MutationEngine2;
|
|
1186
|
+
})();
|
|
1242
1187
|
function cryptoRandomId() {
|
|
1243
|
-
|
|
1244
|
-
|
|
1188
|
+
if (typeof crypto !== "undefined" && "randomUUID" in crypto) return crypto.randomUUID();
|
|
1189
|
+
return Math.random().toString(36).slice(2);
|
|
1245
1190
|
}
|
|
1191
|
+
|
|
1246
1192
|
//# sourceMappingURL=mutationEngine.native.js.map
|