@carlonicora/nextjs-jsonapi 6.13.1 → 6.14.1
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/{BlockNoteEditor-VXMDSQAA.mjs → BlockNoteEditor-I3J6YYXK.mjs} +10 -10
- package/dist/{BlockNoteEditor-UBVEUFNR.js → BlockNoteEditor-UIAX72XW.js} +25 -25
- package/dist/{BlockNoteEditor-UBVEUFNR.js.map → BlockNoteEditor-UIAX72XW.js.map} +1 -1
- package/dist/{BlockNoteViewer-2XYASA5Y.js → BlockNoteViewer-APBOPT4B.js} +8 -8
- package/dist/{BlockNoteViewer-2XYASA5Y.js.map → BlockNoteViewer-APBOPT4B.js.map} +1 -1
- package/dist/{BlockNoteViewer-NBW2H6LC.mjs → BlockNoteViewer-HIUAJQRI.mjs} +7 -7
- package/dist/JsonApiRequest-G4J2WTSU.js +26 -0
- package/dist/{JsonApiRequest-WISJZSDE.js.map → JsonApiRequest-G4J2WTSU.js.map} +1 -1
- package/dist/{JsonApiRequest-F6TMJ42G.mjs → JsonApiRequest-IKKHWCPB.mjs} +2 -2
- package/dist/billing/index.js +497 -497
- package/dist/billing/index.mjs +9 -9
- package/dist/{chunk-7DBJTNSU.mjs → chunk-4RPGFQBA.mjs} +2 -2
- package/dist/{chunk-BZ5J2FIV.js → chunk-4XLDBOSE.js} +11 -11
- package/dist/{chunk-BZ5J2FIV.js.map → chunk-4XLDBOSE.js.map} +1 -1
- package/dist/{chunk-27LQDGNP.mjs → chunk-4ZJIUTIV.mjs} +6 -1
- package/dist/chunk-4ZJIUTIV.mjs.map +1 -0
- package/dist/{chunk-PXDUJ47N.js → chunk-6RCZ64BQ.js} +18 -18
- package/dist/{chunk-PXDUJ47N.js.map → chunk-6RCZ64BQ.js.map} +1 -1
- package/dist/{chunk-7JZHPMGW.mjs → chunk-A3RB47X4.mjs} +44 -20
- package/dist/chunk-A3RB47X4.mjs.map +1 -0
- package/dist/{chunk-DOCIFE6A.mjs → chunk-AUD6ZLBB.mjs} +3 -3
- package/dist/{chunk-GB6DBFYY.js → chunk-DGN3PR2F.js} +3 -3
- package/dist/{chunk-GB6DBFYY.js.map → chunk-DGN3PR2F.js.map} +1 -1
- package/dist/{chunk-7ZHTPFFT.js → chunk-DJXSCARG.js} +15 -15
- package/dist/{chunk-7ZHTPFFT.js.map → chunk-DJXSCARG.js.map} +1 -1
- package/dist/{chunk-QKNGZDSQ.js → chunk-GM4VZTWL.js} +2 -2
- package/dist/{chunk-QKNGZDSQ.js.map → chunk-GM4VZTWL.js.map} +1 -1
- package/dist/{chunk-47BBY5KA.mjs → chunk-HAW5PNJG.mjs} +4 -4
- package/dist/{chunk-YRKIFYOE.mjs → chunk-KTGKW72G.mjs} +27 -8
- package/dist/chunk-KTGKW72G.mjs.map +1 -0
- package/dist/{chunk-PV4Z5W6V.js → chunk-KV4N7DEG.js} +19 -19
- package/dist/{chunk-PV4Z5W6V.js.map → chunk-KV4N7DEG.js.map} +1 -1
- package/dist/{chunk-ZLTOUZN2.mjs → chunk-M3N7LPHX.mjs} +4 -4
- package/dist/{chunk-DGWOVYEC.mjs → chunk-MQ7TXALH.mjs} +2 -2
- package/dist/{chunk-W62MHDWM.js → chunk-N5ZE2Z6I.js} +58 -34
- package/dist/chunk-N5ZE2Z6I.js.map +1 -0
- package/dist/{chunk-2SV4SS6N.js → chunk-OQQ7CZWT.js} +12 -12
- package/dist/{chunk-2SV4SS6N.js.map → chunk-OQQ7CZWT.js.map} +1 -1
- package/dist/{chunk-JJMMT24D.mjs → chunk-OUEYZOLB.mjs} +2 -2
- package/dist/{chunk-XXP3TQHF.mjs → chunk-OY65RYD3.mjs} +2 -2
- package/dist/{chunk-MOGEGWXW.js → chunk-PMESKNKL.js} +868 -868
- package/dist/{chunk-MOGEGWXW.js.map → chunk-PMESKNKL.js.map} +1 -1
- package/dist/{chunk-B6JGKDP2.js → chunk-QGVVF77L.js} +48 -29
- package/dist/chunk-QGVVF77L.js.map +1 -0
- package/dist/{chunk-BH6JWIKI.mjs → chunk-QIEF7HIL.mjs} +2 -2
- package/dist/{chunk-P445QGOC.mjs → chunk-RFKSJIQB.mjs} +7 -7
- package/dist/{chunk-PYRZCKC2.js → chunk-RT7XFGIN.js} +1141 -1137
- package/dist/chunk-RT7XFGIN.js.map +1 -0
- package/dist/{chunk-N4RZZKL5.mjs → chunk-RYY7USSW.mjs} +19 -15
- package/dist/chunk-RYY7USSW.mjs.map +1 -0
- package/dist/{chunk-6JUCIWDC.mjs → chunk-UOTHRJD2.mjs} +2 -2
- package/dist/{chunk-KMW7UNL2.js → chunk-WCEYT3GG.js} +8 -8
- package/dist/{chunk-KMW7UNL2.js.map → chunk-WCEYT3GG.js.map} +1 -1
- package/dist/{chunk-MHB36MYE.js → chunk-WUNSG3IN.js} +7 -2
- package/dist/chunk-WUNSG3IN.js.map +1 -0
- package/dist/{chunk-Z4POQWFG.js → chunk-ZYSNJKOP.js} +4 -4
- package/dist/{chunk-Z4POQWFG.js.map → chunk-ZYSNJKOP.js.map} +1 -1
- package/dist/client/index.js +10 -10
- package/dist/client/index.mjs +9 -9
- package/dist/components/index.js +10 -10
- package/dist/components/index.mjs +9 -9
- package/dist/contexts/index.js +10 -10
- package/dist/contexts/index.mjs +9 -9
- package/dist/core/index.js +7 -7
- package/dist/core/index.mjs +6 -6
- package/dist/email-automations/index.js +99 -99
- package/dist/email-automations/index.mjs +9 -9
- package/dist/features/analytics/index.js +126 -126
- package/dist/features/analytics/index.mjs +9 -9
- package/dist/features/analytics/server.js +10 -10
- package/dist/features/analytics/server.mjs +8 -8
- package/dist/features/blog/index.js +156 -156
- package/dist/features/blog/index.mjs +9 -9
- package/dist/features/blog/server.js +28 -28
- package/dist/features/blog/server.mjs +7 -7
- package/dist/features/help/index.js +43 -43
- package/dist/features/help/index.mjs +9 -9
- package/dist/features/tokenusage/index.js +132 -132
- package/dist/features/tokenusage/index.mjs +9 -9
- package/dist/index.js +8 -8
- package/dist/index.mjs +7 -7
- package/dist/{lifecycle-LKGPRBS7.mjs → lifecycle-KI3PCJSE.mjs} +3 -3
- package/dist/lifecycle-TO65I7TO.js +23 -0
- package/dist/{lifecycle-4GUOTB46.js.map → lifecycle-TO65I7TO.js.map} +1 -1
- package/dist/local-transport-4YDJ6FQG.js +15 -0
- package/dist/{local-transport-7H3SPZSA.js.map → local-transport-4YDJ6FQG.js.map} +1 -1
- package/dist/local-transport-C7YTA4I7.mjs +15 -0
- package/dist/offline/index.d.mts +160 -4
- package/dist/offline/index.d.ts +160 -4
- package/dist/offline/index.js +210 -163
- package/dist/offline/index.js.map +1 -1
- package/dist/offline/index.mjs +76 -29
- package/dist/offline/index.mjs.map +1 -1
- package/dist/request-66FGJIHB.mjs +10 -0
- package/dist/request-6W6UGKJV.js +10 -0
- package/dist/{request-KTBV6HHH.js.map → request-6W6UGKJV.js.map} +1 -1
- package/dist/server/index.js +9 -9
- package/dist/server/index.mjs +8 -8
- package/dist/write-through-BAPS24GL.js +15 -0
- package/dist/{write-through-FDQ7N4YI.js.map → write-through-BAPS24GL.js.map} +1 -1
- package/dist/write-through-IWQKXYHE.mjs +15 -0
- package/package.json +1 -1
- package/src/hooks/__tests__/usePageTracker.spec.tsx +61 -0
- package/src/hooks/usePageTracker.ts +17 -7
- package/src/offline/__tests__/generic-answers.spec.ts +146 -3
- package/src/offline/__tests__/local-transport.spec.ts +15 -1
- package/src/offline/__tests__/offline-fixtures.ts +29 -2
- package/src/offline/__tests__/write-through.spec.ts +27 -1
- package/src/offline/config.ts +9 -0
- package/src/offline/generic-answers.ts +44 -17
- package/src/offline/index.ts +2 -0
- package/src/offline/local-transport.ts +5 -3
- package/src/offline/sync/__tests__/runtime.spec.ts +30 -1
- package/src/offline/sync/__tests__/sync-fixtures.ts +22 -0
- package/src/offline/sync/__tests__/sync-root.spec.ts +184 -1
- package/src/offline/sync/known-roots.ts +29 -7
- package/src/offline/sync/runtime.ts +3 -2
- package/src/offline/sync/sync-root.ts +70 -19
- package/src/offline/types.ts +39 -1
- package/src/offline/write-through.ts +6 -3
- package/dist/JsonApiRequest-WISJZSDE.js +0 -26
- package/dist/chunk-27LQDGNP.mjs.map +0 -1
- package/dist/chunk-7JZHPMGW.mjs.map +0 -1
- package/dist/chunk-B6JGKDP2.js.map +0 -1
- package/dist/chunk-MHB36MYE.js.map +0 -1
- package/dist/chunk-N4RZZKL5.mjs.map +0 -1
- package/dist/chunk-PYRZCKC2.js.map +0 -1
- package/dist/chunk-W62MHDWM.js.map +0 -1
- package/dist/chunk-YRKIFYOE.mjs.map +0 -1
- package/dist/lifecycle-4GUOTB46.js +0 -23
- package/dist/local-transport-7H3SPZSA.js +0 -15
- package/dist/local-transport-QYFKA6AN.mjs +0 -15
- package/dist/request-KTBV6HHH.js +0 -10
- package/dist/request-SQOUNWZ4.mjs +0 -10
- package/dist/write-through-FDQ7N4YI.js +0 -15
- package/dist/write-through-R25VQMH6.mjs +0 -15
- /package/dist/{BlockNoteEditor-VXMDSQAA.mjs.map → BlockNoteEditor-I3J6YYXK.mjs.map} +0 -0
- /package/dist/{BlockNoteViewer-NBW2H6LC.mjs.map → BlockNoteViewer-HIUAJQRI.mjs.map} +0 -0
- /package/dist/{JsonApiRequest-F6TMJ42G.mjs.map → JsonApiRequest-IKKHWCPB.mjs.map} +0 -0
- /package/dist/{chunk-7DBJTNSU.mjs.map → chunk-4RPGFQBA.mjs.map} +0 -0
- /package/dist/{chunk-DOCIFE6A.mjs.map → chunk-AUD6ZLBB.mjs.map} +0 -0
- /package/dist/{chunk-47BBY5KA.mjs.map → chunk-HAW5PNJG.mjs.map} +0 -0
- /package/dist/{chunk-ZLTOUZN2.mjs.map → chunk-M3N7LPHX.mjs.map} +0 -0
- /package/dist/{chunk-DGWOVYEC.mjs.map → chunk-MQ7TXALH.mjs.map} +0 -0
- /package/dist/{chunk-JJMMT24D.mjs.map → chunk-OUEYZOLB.mjs.map} +0 -0
- /package/dist/{chunk-XXP3TQHF.mjs.map → chunk-OY65RYD3.mjs.map} +0 -0
- /package/dist/{chunk-BH6JWIKI.mjs.map → chunk-QIEF7HIL.mjs.map} +0 -0
- /package/dist/{chunk-P445QGOC.mjs.map → chunk-RFKSJIQB.mjs.map} +0 -0
- /package/dist/{chunk-6JUCIWDC.mjs.map → chunk-UOTHRJD2.mjs.map} +0 -0
- /package/dist/{lifecycle-LKGPRBS7.mjs.map → lifecycle-KI3PCJSE.mjs.map} +0 -0
- /package/dist/{local-transport-QYFKA6AN.mjs.map → local-transport-C7YTA4I7.mjs.map} +0 -0
- /package/dist/{request-SQOUNWZ4.mjs.map → request-66FGJIHB.mjs.map} +0 -0
- /package/dist/{write-through-R25VQMH6.mjs.map → write-through-IWQKXYHE.mjs.map} +0 -0
package/dist/offline/index.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var _chunkB6JGKDP2js = require('../chunk-B6JGKDP2.js');
|
|
11
10
|
|
|
11
|
+
var _chunkQGVVF77Ljs = require('../chunk-QGVVF77L.js');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -19,8 +19,8 @@ var _chunkB6JGKDP2js = require('../chunk-B6JGKDP2.js');
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var _chunkPXDUJ47Njs = require('../chunk-PXDUJ47N.js');
|
|
23
22
|
|
|
23
|
+
var _chunk6RCZ64BQjs = require('../chunk-6RCZ64BQ.js');
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
@@ -40,24 +40,24 @@ var _chunkPXDUJ47Njs = require('../chunk-PXDUJ47N.js');
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
var _chunkW62MHDWMjs = require('../chunk-W62MHDWM.js');
|
|
44
43
|
|
|
44
|
+
var _chunkN5ZE2Z6Ijs = require('../chunk-N5ZE2Z6I.js');
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
var _chunkGB6DBFYYjs = require('../chunk-GB6DBFYY.js');
|
|
48
47
|
|
|
48
|
+
var _chunkDGN3PR2Fjs = require('../chunk-DGN3PR2F.js');
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
var _chunkBZ5J2FIVjs = require('../chunk-BZ5J2FIV.js');
|
|
55
|
-
require('../chunk-PV4Z5W6V.js');
|
|
56
54
|
|
|
57
55
|
|
|
58
|
-
var
|
|
56
|
+
var _chunk4XLDBOSEjs = require('../chunk-4XLDBOSE.js');
|
|
57
|
+
require('../chunk-KV4N7DEG.js');
|
|
59
58
|
|
|
60
59
|
|
|
60
|
+
var _chunkWCEYT3GGjs = require('../chunk-WCEYT3GG.js');
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
|
|
@@ -86,12 +86,15 @@ var _chunkKMW7UNL2js = require('../chunk-KMW7UNL2.js');
|
|
|
86
86
|
|
|
87
87
|
|
|
88
88
|
|
|
89
|
-
var _chunkMHB36MYEjs = require('../chunk-MHB36MYE.js');
|
|
90
89
|
|
|
91
90
|
|
|
92
91
|
|
|
92
|
+
var _chunkWUNSG3INjs = require('../chunk-WUNSG3IN.js');
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
var _chunkGM4VZTWLjs = require('../chunk-GM4VZTWL.js');
|
|
95
98
|
|
|
96
99
|
|
|
97
100
|
var _chunkLXKSUWAVjs = require('../chunk-LXKSUWAV.js');
|
|
@@ -101,24 +104,24 @@ var _chunk7QVYU63Ejs = require('../chunk-7QVYU63E.js');
|
|
|
101
104
|
|
|
102
105
|
// src/offline/configure.ts
|
|
103
106
|
function configureOffline2(config) {
|
|
104
|
-
|
|
105
|
-
(userId) => Promise.resolve().then(() => _interopRequireWildcard(require("../lifecycle-
|
|
107
|
+
_chunkWUNSG3INjs.setDefaultDeviceStoreOpener.call(void 0,
|
|
108
|
+
(userId) => Promise.resolve().then(() => _interopRequireWildcard(require("../lifecycle-TO65I7TO.js"))).then((lifecycle) => lifecycle.openDeviceStore(userId))
|
|
106
109
|
);
|
|
107
|
-
|
|
110
|
+
_chunkWUNSG3INjs.configureOffline.call(void 0, config);
|
|
108
111
|
}
|
|
109
112
|
_chunk7QVYU63Ejs.__name.call(void 0, configureOffline2, "configureOffline");
|
|
110
113
|
|
|
111
114
|
// src/offline/sync/session-refresh.ts
|
|
112
115
|
var _cookiesnext = require('cookies-next');
|
|
113
116
|
function currentLocale() {
|
|
114
|
-
if (typeof window === "undefined") return
|
|
117
|
+
if (typeof window === "undefined") return _chunk4XLDBOSEjs.getI18nDefaultLocale.call(void 0, );
|
|
115
118
|
const first = window.location.pathname.split("/").filter(Boolean)[0];
|
|
116
|
-
return first &&
|
|
119
|
+
return first && _chunk4XLDBOSEjs.getI18nSupportedLocales.call(void 0, ).includes(first) ? first : _chunk4XLDBOSEjs.getI18nDefaultLocale.call(void 0, );
|
|
117
120
|
}
|
|
118
121
|
_chunk7QVYU63Ejs.__name.call(void 0, currentLocale, "currentLocale");
|
|
119
122
|
async function refreshSession() {
|
|
120
123
|
try {
|
|
121
|
-
await fetch(
|
|
124
|
+
await fetch(_chunkWUNSG3INjs.getOfflineConfig.call(void 0, ).shellPath(currentLocale()), { cache: "no-store", credentials: "same-origin" });
|
|
122
125
|
} catch (e) {
|
|
123
126
|
return "unreachable";
|
|
124
127
|
}
|
|
@@ -134,12 +137,12 @@ var SyncInterruptedError = class extends Error {
|
|
|
134
137
|
}
|
|
135
138
|
};
|
|
136
139
|
function assertStillOnline() {
|
|
137
|
-
if (!
|
|
140
|
+
if (!_chunkWUNSG3INjs.canReachApi.call(void 0, )) throw new SyncInterruptedError("The connection dropped during the sync");
|
|
138
141
|
}
|
|
139
142
|
_chunk7QVYU63Ejs.__name.call(void 0, assertStillOnline, "assertStillOnline");
|
|
140
143
|
var isSkippable = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (status) => status === 403 || status === 404, "isSkippable");
|
|
141
144
|
async function fetchResources(module, endpoint, skipped, included) {
|
|
142
|
-
const response = await
|
|
145
|
+
const response = await _chunkGM4VZTWLjs.JsonApiGet.call(void 0, { classKey: module, endpoint, language: currentLocale() });
|
|
143
146
|
assertStillOnline();
|
|
144
147
|
if (!response.ok) {
|
|
145
148
|
if (isSkippable(response.response)) {
|
|
@@ -156,9 +159,9 @@ async function fetchResources(module, endpoint, skipped, included) {
|
|
|
156
159
|
_chunk7QVYU63Ejs.__name.call(void 0, fetchResources, "fetchResources");
|
|
157
160
|
async function imagesOfRoot(store, rootId) {
|
|
158
161
|
const images = [];
|
|
159
|
-
for (const typeConfig of
|
|
162
|
+
for (const typeConfig of _chunkWUNSG3INjs.getOfflineConfig.call(void 0, ).types) {
|
|
160
163
|
for (const record of await store.listRecords({ type: typeConfig.module.name, rootId })) {
|
|
161
|
-
const url =
|
|
164
|
+
const url = _chunk6RCZ64BQjs.imageUrlOf.call(void 0, record.resource);
|
|
162
165
|
if (url) images.push({ type: record.type, id: record.id, url });
|
|
163
166
|
}
|
|
164
167
|
}
|
|
@@ -170,21 +173,22 @@ async function removeRootIfIdle(store, rootId) {
|
|
|
170
173
|
const images = await imagesOfRoot(store, rootId);
|
|
171
174
|
await store.removeRoot(rootId);
|
|
172
175
|
for (const image of images) {
|
|
173
|
-
if (!await store.getRecord(image.type, image.id)) await
|
|
176
|
+
if (!await store.getRecord(image.type, image.id)) await _chunk6RCZ64BQjs.removeArtworkImage.call(void 0, image.url);
|
|
174
177
|
}
|
|
175
178
|
}
|
|
176
179
|
_chunk7QVYU63Ejs.__name.call(void 0, removeRootIfIdle, "removeRootIfIdle");
|
|
177
|
-
async function syncRoot(rootId) {
|
|
178
|
-
const config =
|
|
179
|
-
const
|
|
180
|
+
async function syncRoot(rootId, kind) {
|
|
181
|
+
const config = _chunkWUNSG3INjs.getOfflineConfig.call(void 0, );
|
|
182
|
+
const rootKind = _nullishCoalesce(kind, () => ( _chunkWUNSG3INjs.rootKinds.call(void 0, config)[0]));
|
|
183
|
+
const store = await _chunkWUNSG3INjs.getOfflineStore.call(void 0, );
|
|
180
184
|
const previous = await store.getSyncState(rootId);
|
|
181
|
-
const syncEndpoint = new (0,
|
|
182
|
-
endpoint:
|
|
185
|
+
const syncEndpoint = new (0, _chunk4XLDBOSEjs.EndpointCreator)({
|
|
186
|
+
endpoint: rootKind.module,
|
|
183
187
|
id: rootId,
|
|
184
|
-
childEndpoint:
|
|
188
|
+
childEndpoint: _chunk4XLDBOSEjs.ROOT_SYNC_ENDPOINT
|
|
185
189
|
}).generate();
|
|
186
|
-
const syncResponse = await
|
|
187
|
-
classKey:
|
|
190
|
+
const syncResponse = await _chunkGM4VZTWLjs.JsonApiGet.call(void 0, {
|
|
191
|
+
classKey: _nullishCoalesce(rootKind.syncModule, () => ( _chunk4XLDBOSEjs.Modules.RootSync)),
|
|
188
192
|
endpoint: syncEndpoint,
|
|
189
193
|
language: currentLocale()
|
|
190
194
|
});
|
|
@@ -203,25 +207,25 @@ async function syncRoot(rootId) {
|
|
|
203
207
|
locked: true,
|
|
204
208
|
lockedFrom: _nullishCoalesce(sync.lockedFrom, () => ( null))
|
|
205
209
|
});
|
|
206
|
-
await
|
|
210
|
+
await _chunkQGVVF77Ljs.refreshLockedRoots.call(void 0, );
|
|
207
211
|
return;
|
|
208
212
|
}
|
|
209
213
|
const typeNames = new Set(config.types.map((typeConfig) => typeConfig.module.name));
|
|
210
214
|
const entries = sync.entries.filter((entry) => typeNames.has(entry.type));
|
|
211
|
-
const entryUpdatedAt = new Map(entries.map((entry) => [
|
|
215
|
+
const entryUpdatedAt = new Map(entries.map((entry) => [_chunkQGVVF77Ljs.recordKeyOf.call(void 0, entry.type, entry.id), entry.updatedAt]));
|
|
212
216
|
const since = previous.serverTime;
|
|
213
217
|
const inWindow = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (entry) => !since || entry.updatedAt.getTime() > since.getTime(), "inWindow");
|
|
214
218
|
const stored = /* @__PURE__ */ new Map();
|
|
215
219
|
for (const typeConfig of config.types) {
|
|
216
220
|
for (const record of await store.listRecords({ type: typeConfig.module.name, rootId })) {
|
|
217
|
-
stored.set(
|
|
221
|
+
stored.set(_chunkQGVVF77Ljs.recordKeyOf.call(void 0, record.type, record.id), record);
|
|
218
222
|
}
|
|
219
223
|
}
|
|
220
224
|
const previouslySkipped = new Map(
|
|
221
|
-
(await store.skippedRecords(rootId)).map((record) => [
|
|
225
|
+
(await store.skippedRecords(rootId)).map((record) => [_chunkQGVVF77Ljs.recordKeyOf.call(void 0, record.type, record.id), record.updatedAt])
|
|
222
226
|
);
|
|
223
227
|
const isStale = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (entry) => {
|
|
224
|
-
const key =
|
|
228
|
+
const key = _chunkQGVVF77Ljs.recordKeyOf.call(void 0, entry.type, entry.id);
|
|
225
229
|
const record = stored.get(key);
|
|
226
230
|
if (record && record.updatedAt !== null) return false;
|
|
227
231
|
const skippedAt = previouslySkipped.get(key);
|
|
@@ -231,12 +235,28 @@ async function syncRoot(rootId) {
|
|
|
231
235
|
const skipped = [];
|
|
232
236
|
const fetched = [];
|
|
233
237
|
const included = [];
|
|
234
|
-
|
|
238
|
+
const rootTypeName = rootKind.module.name;
|
|
239
|
+
const orderedTypes = [
|
|
240
|
+
...config.types.filter((typeConfig) => typeConfig.module.name === rootTypeName),
|
|
241
|
+
...config.types.filter((typeConfig) => typeConfig.module.name !== rootTypeName)
|
|
242
|
+
];
|
|
243
|
+
const rootResource = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
244
|
+
const fresh = fetched.find((resource) => _optionalChain([resource, 'optionalAccess', _5 => _5.type]) === rootTypeName && _optionalChain([resource, 'optionalAccess', _6 => _6.id]) === rootId);
|
|
245
|
+
if (fresh) return fresh;
|
|
246
|
+
const storedRoot = await store.getRecord(rootTypeName, rootId);
|
|
247
|
+
if (storedRoot) return storedRoot.resource;
|
|
248
|
+
throw new Error(`[offline] ${rootTypeName} ${rootId}: the root record is needed to build the type endpoints`);
|
|
249
|
+
}, "rootResource");
|
|
250
|
+
for (const typeConfig of orderedTypes) {
|
|
235
251
|
const changedOfType = changed.filter((entry) => entry.type === typeConfig.module.name);
|
|
236
252
|
if (changedOfType.length === 0) continue;
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
253
|
+
const typeEndpoint = _optionalChain([rootKind, 'access', _7 => _7.typeEndpoints, 'optionalAccess', _8 => _8.find, 'call', _9 => _9((candidate) => candidate.module.name === typeConfig.module.name)]);
|
|
254
|
+
if (typeEndpoint) {
|
|
255
|
+
const endpoint = typeEndpoint.endpoint({ id: rootId, resource: await rootResource() });
|
|
256
|
+
fetched.push(...await fetchResources(typeConfig.module, endpoint, skipped, included));
|
|
257
|
+
} else if (typeConfig.fetch === "root-list") {
|
|
258
|
+
const endpoint = new (0, _chunk4XLDBOSEjs.EndpointCreator)({
|
|
259
|
+
endpoint: rootKind.module,
|
|
240
260
|
id: rootId,
|
|
241
261
|
childEndpoint: typeConfig.module
|
|
242
262
|
}).addAdditionalParam("fetchAll", "true");
|
|
@@ -250,45 +270,45 @@ async function syncRoot(rootId) {
|
|
|
250
270
|
for (const link of sync.links) {
|
|
251
271
|
if (link.kind !== linkKind || link.fromType !== typeConfig.module.name || !changedIds.has(link.fromId))
|
|
252
272
|
continue;
|
|
253
|
-
targets.set(
|
|
273
|
+
targets.set(_chunkQGVVF77Ljs.recordKeyOf.call(void 0, link.toType, link.toId), { type: link.toType, id: link.toId });
|
|
254
274
|
}
|
|
255
275
|
for (const target of targets.values()) {
|
|
256
276
|
const resources = await fetchResources(typeConfig.module, endpoint(rootId, target), skipped, included);
|
|
257
277
|
fetched.push(
|
|
258
|
-
...resources.filter((resource) => _optionalChain([resource, 'optionalAccess',
|
|
278
|
+
...resources.filter((resource) => _optionalChain([resource, 'optionalAccess', _10 => _10.type]) === typeConfig.module.name && changedIds.has(resource.id))
|
|
259
279
|
);
|
|
260
280
|
}
|
|
261
281
|
} else {
|
|
262
282
|
for (const entry of changedOfType) {
|
|
263
|
-
const endpoint = new (0,
|
|
283
|
+
const endpoint = new (0, _chunk4XLDBOSEjs.EndpointCreator)({ endpoint: typeConfig.module, id: entry.id }).generate();
|
|
264
284
|
fetched.push(...await fetchResources(typeConfig.module, endpoint, skipped, included));
|
|
265
285
|
}
|
|
266
286
|
}
|
|
267
287
|
}
|
|
268
|
-
const fetchedKeys = new Set(fetched.map((resource) =>
|
|
288
|
+
const fetchedKeys = new Set(fetched.map((resource) => _chunkQGVVF77Ljs.recordKeyOf.call(void 0, _optionalChain([resource, 'optionalAccess', _11 => _11.type]), _optionalChain([resource, 'optionalAccess', _12 => _12.id]))));
|
|
269
289
|
const previousImageUrls = /* @__PURE__ */ new Map();
|
|
270
290
|
const removedImageUrls = [];
|
|
271
291
|
await store.transaction(async (tx) => {
|
|
272
|
-
const waiting =
|
|
292
|
+
const waiting = _chunkQGVVF77Ljs.waitingRecordKeys.call(void 0, await tx.queue(), typeNames);
|
|
273
293
|
for (const typeConfig of config.types) {
|
|
274
294
|
for (const record of await tx.listRecords({ type: typeConfig.module.name, rootId })) {
|
|
275
|
-
const key =
|
|
295
|
+
const key = _chunkQGVVF77Ljs.recordKeyOf.call(void 0, record.type, record.id);
|
|
276
296
|
if (waiting.has(key)) {
|
|
277
297
|
if (record.updatedAt !== null) await tx.putRecord({ ...record, updatedAt: null });
|
|
278
298
|
continue;
|
|
279
299
|
}
|
|
280
300
|
if (entryUpdatedAt.has(key)) continue;
|
|
281
301
|
await tx.removeRecordFromRoot(record.type, record.id, rootId);
|
|
282
|
-
const url =
|
|
302
|
+
const url = _chunk6RCZ64BQjs.imageUrlOf.call(void 0, record.resource);
|
|
283
303
|
if (url && !await tx.getRecord(record.type, record.id)) removedImageUrls.push(url);
|
|
284
304
|
}
|
|
285
305
|
}
|
|
286
306
|
for (const resource of fetched) {
|
|
287
|
-
const key =
|
|
307
|
+
const key = _chunkQGVVF77Ljs.recordKeyOf.call(void 0, _optionalChain([resource, 'optionalAccess', _13 => _13.type]), _optionalChain([resource, 'optionalAccess', _14 => _14.id]));
|
|
288
308
|
if (!entryUpdatedAt.has(key)) continue;
|
|
289
309
|
if (waiting.has(key)) continue;
|
|
290
310
|
const existing = await tx.getRecord(resource.type, resource.id);
|
|
291
|
-
const previousUrl =
|
|
311
|
+
const previousUrl = _chunk6RCZ64BQjs.imageUrlOf.call(void 0, _optionalChain([existing, 'optionalAccess', _15 => _15.resource]));
|
|
292
312
|
if (previousUrl) previousImageUrls.set(key, previousUrl);
|
|
293
313
|
await tx.putRecord({
|
|
294
314
|
type: resource.type,
|
|
@@ -301,7 +321,7 @@ async function syncRoot(rootId) {
|
|
|
301
321
|
});
|
|
302
322
|
}
|
|
303
323
|
for (const resource of included) {
|
|
304
|
-
if (!_optionalChain([resource, 'optionalAccess',
|
|
324
|
+
if (!_optionalChain([resource, 'optionalAccess', _16 => _16.type]) || !_optionalChain([resource, 'optionalAccess', _17 => _17.id]) || typeNames.has(resource.type)) continue;
|
|
305
325
|
await tx.putRecord({
|
|
306
326
|
type: resource.type,
|
|
307
327
|
id: resource.id,
|
|
@@ -313,9 +333,9 @@ async function syncRoot(rootId) {
|
|
|
313
333
|
});
|
|
314
334
|
}
|
|
315
335
|
const skippedRecords = [];
|
|
316
|
-
const changedKeys = new Set(changed.map((entry) =>
|
|
336
|
+
const changedKeys = new Set(changed.map((entry) => _chunkQGVVF77Ljs.recordKeyOf.call(void 0, entry.type, entry.id)));
|
|
317
337
|
for (const entry of entries) {
|
|
318
|
-
const key =
|
|
338
|
+
const key = _chunkQGVVF77Ljs.recordKeyOf.call(void 0, entry.type, entry.id);
|
|
319
339
|
if (waiting.has(key) || fetchedKeys.has(key)) continue;
|
|
320
340
|
if (changedKeys.has(key)) skippedRecords.push({ type: entry.type, id: entry.id, updatedAt: entry.updatedAt });
|
|
321
341
|
else {
|
|
@@ -334,56 +354,82 @@ async function syncRoot(rootId) {
|
|
|
334
354
|
if (skipped.length > 0) {
|
|
335
355
|
console.warn(`[offline] root record ${rootId}: skipped records the GM cannot read:`, skipped.join(", "));
|
|
336
356
|
}
|
|
337
|
-
for (const url of removedImageUrls) await
|
|
357
|
+
for (const url of removedImageUrls) await _chunk6RCZ64BQjs.removeArtworkImage.call(void 0, url);
|
|
338
358
|
for (const typeConfig of config.types) {
|
|
339
359
|
for (const record of await store.listRecords({ type: typeConfig.module.name, rootId })) {
|
|
340
|
-
const url =
|
|
341
|
-
if (url) await
|
|
360
|
+
const url = _chunk6RCZ64BQjs.imageUrlOf.call(void 0, record.resource);
|
|
361
|
+
if (url) await _chunk6RCZ64BQjs.cacheArtworkImage.call(void 0, url, previousImageUrls.get(_chunkQGVVF77Ljs.recordKeyOf.call(void 0, record.type, record.id)));
|
|
342
362
|
}
|
|
343
363
|
}
|
|
344
|
-
await
|
|
364
|
+
await _chunkQGVVF77Ljs.refreshLockedRoots.call(void 0, );
|
|
345
365
|
}
|
|
346
366
|
_chunk7QVYU63Ejs.__name.call(void 0, syncRoot, "syncRoot");
|
|
347
367
|
async function syncAll() {
|
|
348
|
-
if (!
|
|
349
|
-
const config =
|
|
350
|
-
if (!config.getUserId() || !
|
|
351
|
-
|
|
368
|
+
if (!_chunkWUNSG3INjs.isOfflineConfigured.call(void 0, )) return;
|
|
369
|
+
const config = _chunkWUNSG3INjs.getOfflineConfig.call(void 0, );
|
|
370
|
+
if (!config.getUserId() || !_chunkWUNSG3INjs.canReachApi.call(void 0, )) return;
|
|
371
|
+
const [primaryKind, ...extraKinds] = _chunkWUNSG3INjs.rootKinds.call(void 0, config);
|
|
372
|
+
let primaryRoots;
|
|
352
373
|
try {
|
|
353
|
-
|
|
374
|
+
primaryRoots = await primaryKind.listSyncRoots();
|
|
354
375
|
} catch (error) {
|
|
355
376
|
console.warn("[offline] could not list the root records to sync", error);
|
|
356
377
|
return;
|
|
357
378
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
379
|
+
const work = primaryRoots.map((rootId) => ({
|
|
380
|
+
rootId,
|
|
381
|
+
kind: primaryKind
|
|
382
|
+
}));
|
|
383
|
+
const extraRoots = [];
|
|
384
|
+
const unlistedKinds = [];
|
|
385
|
+
for (const kind of extraKinds) {
|
|
386
|
+
try {
|
|
387
|
+
const ids = await kind.listSyncRoots();
|
|
388
|
+
extraRoots.push(...ids);
|
|
389
|
+
work.push(...ids.map((rootId) => ({ rootId, kind })));
|
|
390
|
+
} catch (error) {
|
|
391
|
+
console.warn(`[offline] could not list the ${kind.module.name} root records to sync`, error);
|
|
392
|
+
unlistedKinds.push(kind);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (!_chunkWUNSG3INjs.canReachApi.call(void 0, )) return;
|
|
396
|
+
const kept = new Set(work.map((item) => item.rootId));
|
|
397
|
+
if (unlistedKinds.length > 0) {
|
|
398
|
+
const store = await _chunkWUNSG3INjs.getOfflineStore.call(void 0, );
|
|
399
|
+
for (const kind of unlistedKinds) {
|
|
400
|
+
for (const record of await store.listRecords({ type: kind.module.name })) {
|
|
401
|
+
kept.add(record.id);
|
|
402
|
+
extraRoots.push(record.id);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
_chunkQGVVF77Ljs.rememberSyncRoots.call(void 0, [...kept], extraRoots);
|
|
407
|
+
const total = work.length;
|
|
408
|
+
_chunkWUNSG3INjs.setOfflineState.call(void 0, { syncProgress: { done: 0, total } });
|
|
362
409
|
try {
|
|
363
410
|
let done = 0;
|
|
364
|
-
for (const rootId of
|
|
411
|
+
for (const { rootId, kind } of work) {
|
|
365
412
|
try {
|
|
366
|
-
await syncRoot(rootId);
|
|
413
|
+
await syncRoot(rootId, kind);
|
|
367
414
|
} catch (error) {
|
|
368
415
|
console.warn(`[offline] sync of root record ${rootId} failed`, error);
|
|
369
|
-
if (!
|
|
416
|
+
if (!_chunkWUNSG3INjs.canReachApi.call(void 0, )) return;
|
|
370
417
|
} finally {
|
|
371
418
|
done += 1;
|
|
372
|
-
|
|
419
|
+
_chunkWUNSG3INjs.setOfflineState.call(void 0, { syncProgress: { done, total } });
|
|
373
420
|
}
|
|
374
421
|
}
|
|
375
422
|
const finishedAt = Date.now();
|
|
376
423
|
const userId = config.getUserId();
|
|
377
|
-
if (userId)
|
|
378
|
-
|
|
379
|
-
const store = await
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
if (!rootSet.has(rootId)) await removeRootIfIdle(store, rootId);
|
|
424
|
+
if (userId) _chunkWUNSG3INjs.writeOfflineLastSync.call(void 0, userId, finishedAt);
|
|
425
|
+
_chunkWUNSG3INjs.setOfflineState.call(void 0, { lastSyncedAt: finishedAt, rootCount: primaryRoots.length });
|
|
426
|
+
const store = await _chunkWUNSG3INjs.getOfflineStore.call(void 0, );
|
|
427
|
+
for (const rootId of await _chunkQGVVF77Ljs.knownRootIds.call(void 0, store)) {
|
|
428
|
+
if (!kept.has(rootId)) await removeRootIfIdle(store, rootId);
|
|
383
429
|
}
|
|
384
|
-
await
|
|
430
|
+
await _chunkQGVVF77Ljs.refreshLockedRoots.call(void 0, );
|
|
385
431
|
} finally {
|
|
386
|
-
|
|
432
|
+
_chunkWUNSG3INjs.setOfflineState.call(void 0, { syncProgress: null });
|
|
387
433
|
}
|
|
388
434
|
}
|
|
389
435
|
_chunk7QVYU63Ejs.__name.call(void 0, syncAll, "syncAll");
|
|
@@ -402,13 +448,13 @@ function subscribe(listener) {
|
|
|
402
448
|
_chunk7QVYU63Ejs.__name.call(void 0, subscribe, "subscribe");
|
|
403
449
|
async function refreshOfflineCounts(store) {
|
|
404
450
|
if (!store) {
|
|
405
|
-
if (!
|
|
406
|
-
store = await
|
|
451
|
+
if (!_chunkWUNSG3INjs.isOfflineConfigured.call(void 0, ) || !_chunkWUNSG3INjs.getOfflineConfig.call(void 0, ).getUserId()) return;
|
|
452
|
+
store = await _chunkWUNSG3INjs.getOfflineStore.call(void 0, );
|
|
407
453
|
}
|
|
408
454
|
const entries = await store.queue();
|
|
409
455
|
_conflicts = await store.conflicts();
|
|
410
456
|
for (const listener of [..._listeners]) listener();
|
|
411
|
-
|
|
457
|
+
_chunkWUNSG3INjs.setOfflineState.call(void 0, {
|
|
412
458
|
pending: entries.filter((entry) => entry.status !== "conflict").length,
|
|
413
459
|
conflicts: _conflicts.length
|
|
414
460
|
});
|
|
@@ -424,16 +470,16 @@ function useConflicts() {
|
|
|
424
470
|
_chunk7QVYU63Ejs.__name.call(void 0, useConflicts, "useConflicts");
|
|
425
471
|
|
|
426
472
|
// src/offline/sync/drain-queue.ts
|
|
427
|
-
var syncedTypeNames = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => new Set(
|
|
473
|
+
var syncedTypeNames = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => new Set(_chunkWUNSG3INjs.getOfflineConfig.call(void 0, ).types.map((typeConfig) => typeConfig.module.name)), "syncedTypeNames");
|
|
428
474
|
function withoutServerOwnedFields(body) {
|
|
429
|
-
const data = _optionalChain([body, 'optionalAccess',
|
|
475
|
+
const data = _optionalChain([body, 'optionalAccess', _18 => _18.data]);
|
|
430
476
|
if (!data) return body;
|
|
431
477
|
const owned = new Map(
|
|
432
|
-
|
|
478
|
+
_chunkWUNSG3INjs.getOfflineConfig.call(void 0, ).types.map((typeConfig) => [typeConfig.module.name, typeConfig.serverOwnedFields])
|
|
433
479
|
);
|
|
434
480
|
const strip = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (resource) => {
|
|
435
|
-
const fields = _nullishCoalesce(owned.get(_optionalChain([resource, 'optionalAccess',
|
|
436
|
-
if (!_optionalChain([resource, 'optionalAccess',
|
|
481
|
+
const fields = _nullishCoalesce(owned.get(_optionalChain([resource, 'optionalAccess', _19 => _19.type])), () => ( []));
|
|
482
|
+
if (!_optionalChain([resource, 'optionalAccess', _20 => _20.attributes]) || fields.length === 0) return resource;
|
|
437
483
|
const attributes = { ...resource.attributes };
|
|
438
484
|
for (const field of fields) delete attributes[field];
|
|
439
485
|
return { ...resource, attributes };
|
|
@@ -452,7 +498,7 @@ function toChange(entry) {
|
|
|
452
498
|
}
|
|
453
499
|
_chunk7QVYU63Ejs.__name.call(void 0, toChange, "toChange");
|
|
454
500
|
function mergedResource(current, merged) {
|
|
455
|
-
if (!merged || !_optionalChain([current, 'optionalAccess',
|
|
501
|
+
if (!merged || !_optionalChain([current, 'optionalAccess', _21 => _21.type])) return void 0;
|
|
456
502
|
return { ...current, attributes: { ..._nullishCoalesce(current.attributes, () => ( {})), ...merged } };
|
|
457
503
|
}
|
|
458
504
|
_chunk7QVYU63Ejs.__name.call(void 0, mergedResource, "mergedResource");
|
|
@@ -461,27 +507,27 @@ function newPackageId() {
|
|
|
461
507
|
}
|
|
462
508
|
_chunk7QVYU63Ejs.__name.call(void 0, newPackageId, "newPackageId");
|
|
463
509
|
function packageIdFor(entries) {
|
|
464
|
-
return _nullishCoalesce(_optionalChain([entries, 'access',
|
|
510
|
+
return _nullishCoalesce(_optionalChain([entries, 'access', _22 => _22.find, 'call', _23 => _23((entry) => entry.packageId), 'optionalAccess', _24 => _24.packageId]), () => ( newPackageId()));
|
|
465
511
|
}
|
|
466
512
|
_chunk7QVYU63Ejs.__name.call(void 0, packageIdFor, "packageIdFor");
|
|
467
513
|
async function entriesToSend(store) {
|
|
468
514
|
const all = await store.queue();
|
|
469
515
|
const typeNames = syncedTypeNames();
|
|
470
|
-
const blocked =
|
|
516
|
+
const blocked = _chunkQGVVF77Ljs.waitingRecordKeys.call(void 0,
|
|
471
517
|
all.filter((entry) => entry.status === "conflict"),
|
|
472
518
|
typeNames
|
|
473
519
|
);
|
|
474
|
-
const lockedIds = new Set(
|
|
520
|
+
const lockedIds = new Set(_chunkWUNSG3INjs.getOfflineState.call(void 0, ).lockedRootIds);
|
|
475
521
|
const lockedByRoot = /* @__PURE__ */ new Map();
|
|
476
522
|
const now = /* @__PURE__ */ new Date();
|
|
477
523
|
const result = [];
|
|
478
524
|
for (const entry of all) {
|
|
479
525
|
if (entry.status !== "pending" && entry.status !== "sending") continue;
|
|
480
|
-
if (
|
|
526
|
+
if (_chunkQGVVF77Ljs.recordKeysOfEntry.call(void 0, entry, typeNames).some((key) => blocked.has(key))) continue;
|
|
481
527
|
if (!lockedByRoot.has(entry.rootId)) {
|
|
482
528
|
lockedByRoot.set(
|
|
483
529
|
entry.rootId,
|
|
484
|
-
lockedIds.has(entry.rootId) ||
|
|
530
|
+
lockedIds.has(entry.rootId) || _chunk6RCZ64BQjs.isRootLocked.call(void 0, await store.getSyncState(entry.rootId), now)
|
|
485
531
|
);
|
|
486
532
|
}
|
|
487
533
|
if (lockedByRoot.get(entry.rootId)) continue;
|
|
@@ -494,8 +540,8 @@ async function applyResult(store, entry, result) {
|
|
|
494
540
|
if (result.status === "applied") {
|
|
495
541
|
await store.removeQueueEntry(entry.seq);
|
|
496
542
|
const typeNames = syncedTypeNames();
|
|
497
|
-
const stillWaiting =
|
|
498
|
-
for (const key of
|
|
543
|
+
const stillWaiting = _chunkQGVVF77Ljs.waitingRecordKeys.call(void 0, await store.queue(), typeNames);
|
|
544
|
+
for (const key of _chunkQGVVF77Ljs.recordKeysOfEntry.call(void 0, entry, typeNames)) {
|
|
499
545
|
if (stillWaiting.has(key)) continue;
|
|
500
546
|
const separator = key.indexOf(":");
|
|
501
547
|
const record = await store.getRecord(key.slice(0, separator), key.slice(separator + 1));
|
|
@@ -504,12 +550,12 @@ async function applyResult(store, entry, result) {
|
|
|
504
550
|
}
|
|
505
551
|
}
|
|
506
552
|
if (result.response) {
|
|
507
|
-
await
|
|
553
|
+
await _chunkQGVVF77Ljs.writeThrough.call(void 0,
|
|
508
554
|
{ method: entry.method, url: entry.path },
|
|
509
555
|
{ ok: true, status: 200, statusText: "OK", data: result.response }
|
|
510
556
|
);
|
|
511
557
|
} else if (entry.method === "DELETE") {
|
|
512
|
-
await
|
|
558
|
+
await _chunkQGVVF77Ljs.writeThrough.call(void 0,
|
|
513
559
|
{ method: entry.method, url: entry.path },
|
|
514
560
|
{ ok: true, status: 204, statusText: "OK", data: void 0 }
|
|
515
561
|
);
|
|
@@ -539,14 +585,14 @@ async function applyResult(store, entry, result) {
|
|
|
539
585
|
_chunk7QVYU63Ejs.__name.call(void 0, applyResult, "applyResult");
|
|
540
586
|
async function drain() {
|
|
541
587
|
const outcome = { applied: 0, conflicts: 0, stoppedForLogin: false };
|
|
542
|
-
if (!
|
|
543
|
-
const store = await
|
|
588
|
+
if (!_chunkWUNSG3INjs.isOfflineConfigured.call(void 0, ) || !_chunkWUNSG3INjs.getOfflineConfig.call(void 0, ).getUserId()) return outcome;
|
|
589
|
+
const store = await _chunkWUNSG3INjs.getOfflineStore.call(void 0, );
|
|
544
590
|
const entries = await entriesToSend(store);
|
|
545
591
|
if (entries.length === 0) return outcome;
|
|
546
592
|
const session = await refreshSession();
|
|
547
593
|
if (session === "unreachable") return outcome;
|
|
548
594
|
if (session === "expired") return { ...outcome, stoppedForLogin: true };
|
|
549
|
-
|
|
595
|
+
_chunkWUNSG3INjs.setOfflineState.call(void 0, { draining: true });
|
|
550
596
|
const handled = /* @__PURE__ */ new Set();
|
|
551
597
|
try {
|
|
552
598
|
const packageId = packageIdFor(entries);
|
|
@@ -555,12 +601,12 @@ async function drain() {
|
|
|
555
601
|
packageId
|
|
556
602
|
);
|
|
557
603
|
for (const entry of entries) await store.setQueueStatus(entry.seq, "sending");
|
|
558
|
-
const endpoint = new (0,
|
|
559
|
-
const release =
|
|
604
|
+
const endpoint = new (0, _chunk4XLDBOSEjs.EndpointCreator)({ endpoint: _chunk4XLDBOSEjs.Modules.OfflineChangeSet }).generate();
|
|
605
|
+
const release = _chunkWUNSG3INjs.allowWhileReconnecting.call(void 0, _chunkGM4VZTWLjs.buildUrl.call(void 0, endpoint));
|
|
560
606
|
let response;
|
|
561
607
|
try {
|
|
562
|
-
response = await
|
|
563
|
-
classKey:
|
|
608
|
+
response = await _chunkGM4VZTWLjs.JsonApiPost.call(void 0, {
|
|
609
|
+
classKey: _chunk4XLDBOSEjs.Modules.OfflineChangeSet,
|
|
564
610
|
endpoint,
|
|
565
611
|
body: { id: packageId, changes: entries.map(toChange) },
|
|
566
612
|
language: currentLocale()
|
|
@@ -593,7 +639,7 @@ async function drain() {
|
|
|
593
639
|
for (const entry of entries) {
|
|
594
640
|
if (!handled.has(entry.seq)) await store.setQueueStatus(entry.seq, "pending");
|
|
595
641
|
}
|
|
596
|
-
|
|
642
|
+
_chunkWUNSG3INjs.setOfflineState.call(void 0, { draining: false });
|
|
597
643
|
await refreshOfflineCounts(store);
|
|
598
644
|
}
|
|
599
645
|
}
|
|
@@ -611,7 +657,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, drainQueue, "drainQueue");
|
|
|
611
657
|
|
|
612
658
|
// src/offline/sync/conflicts.ts
|
|
613
659
|
function updatedAtOf(resource) {
|
|
614
|
-
const value = _optionalChain([resource, 'optionalAccess',
|
|
660
|
+
const value = _optionalChain([resource, 'optionalAccess', _25 => _25.attributes, 'optionalAccess', _26 => _26.updatedAt]);
|
|
615
661
|
if (!value) return null;
|
|
616
662
|
const date = new Date(value);
|
|
617
663
|
return Number.isNaN(date.getTime()) ? null : date;
|
|
@@ -621,10 +667,10 @@ async function applyChoicesToRecord(store, conflict, choices, mergedBody) {
|
|
|
621
667
|
if (!conflict.recordType || !conflict.recordId) return;
|
|
622
668
|
const record = await store.getRecord(conflict.recordType, conflict.recordId);
|
|
623
669
|
if (!record) return;
|
|
624
|
-
const attributes = { ..._nullishCoalesce(_optionalChain([record, 'access',
|
|
625
|
-
const relationships = { ..._nullishCoalesce(_optionalChain([record, 'access',
|
|
670
|
+
const attributes = { ..._nullishCoalesce(_optionalChain([record, 'access', _27 => _27.resource, 'optionalAccess', _28 => _28.attributes]), () => ( {})) };
|
|
671
|
+
const relationships = { ..._nullishCoalesce(_optionalChain([record, 'access', _29 => _29.resource, 'optionalAccess', _30 => _30.relationships]), () => ( {})) };
|
|
626
672
|
for (const [field, choice] of Object.entries(choices)) {
|
|
627
|
-
const source = choice === "theirs" ? conflict.theirs : choice === "merged" ? _optionalChain([mergedBody, 'optionalAccess',
|
|
673
|
+
const source = choice === "theirs" ? conflict.theirs : choice === "merged" ? _optionalChain([mergedBody, 'optionalAccess', _31 => _31.data]) : void 0;
|
|
628
674
|
if (!source) continue;
|
|
629
675
|
if (source.attributes && field in source.attributes) attributes[field] = source.attributes[field];
|
|
630
676
|
else if (source.relationships && field in source.relationships) relationships[field] = source.relationships[field];
|
|
@@ -642,20 +688,20 @@ async function rootIdOf(store, conflict, entry) {
|
|
|
642
688
|
}
|
|
643
689
|
_chunk7QVYU63Ejs.__name.call(void 0, rootIdOf, "rootIdOf");
|
|
644
690
|
function collectionPath(recordType) {
|
|
645
|
-
const module = _optionalChain([
|
|
646
|
-
return new (0,
|
|
691
|
+
const module = _optionalChain([_chunkWUNSG3INjs.getOfflineConfig.call(void 0, ), 'access', _32 => _32.types, 'access', _33 => _33.find, 'call', _34 => _34((typeConfig) => typeConfig.module.name === recordType), 'optionalAccess', _35 => _35.module]);
|
|
692
|
+
return new (0, _chunk4XLDBOSEjs.EndpointCreator)({ endpoint: _nullishCoalesce(module, () => ( recordType)) }).generate();
|
|
647
693
|
}
|
|
648
694
|
_chunk7QVYU63Ejs.__name.call(void 0, collectionPath, "collectionPath");
|
|
649
695
|
async function requeueOriginal(store, conflict, entry, fallbackMethod, resolution) {
|
|
650
|
-
const method = _nullishCoalesce(_optionalChain([entry, 'optionalAccess',
|
|
651
|
-
const body = method === "DELETE" ? void 0 : _nullishCoalesce(_nullishCoalesce(_optionalChain([entry, 'optionalAccess',
|
|
696
|
+
const method = _nullishCoalesce(_optionalChain([entry, 'optionalAccess', _36 => _36.method]), () => ( fallbackMethod));
|
|
697
|
+
const body = method === "DELETE" ? void 0 : _nullishCoalesce(_nullishCoalesce(_optionalChain([entry, 'optionalAccess', _37 => _37.body]), () => ( conflict.mine)), () => ( void 0));
|
|
652
698
|
await store.enqueue({
|
|
653
699
|
rootId: await rootIdOf(store, conflict, entry),
|
|
654
700
|
method,
|
|
655
|
-
path: _nullishCoalesce(_optionalChain([entry, 'optionalAccess',
|
|
701
|
+
path: _nullishCoalesce(_optionalChain([entry, 'optionalAccess', _38 => _38.path]), () => ( new (0, _chunk4XLDBOSEjs.EndpointCreator)({ endpoint: collectionPath(conflict.recordType), id: conflict.recordId }).generate())),
|
|
656
702
|
...body !== void 0 ? { body } : {},
|
|
657
|
-
recordType: _nullishCoalesce(_optionalChain([entry, 'optionalAccess',
|
|
658
|
-
recordId: _nullishCoalesce(_optionalChain([entry, 'optionalAccess',
|
|
703
|
+
recordType: _nullishCoalesce(_optionalChain([entry, 'optionalAccess', _39 => _39.recordType]), () => ( conflict.recordType)),
|
|
704
|
+
recordId: _nullishCoalesce(_optionalChain([entry, 'optionalAccess', _40 => _40.recordId]), () => ( conflict.recordId)),
|
|
659
705
|
base: entry ? entry.base : _nullishCoalesce(conflict.base, () => ( null)),
|
|
660
706
|
// QueueEntry["resolution"] is the store's copy of OfflineChange["resolution"].
|
|
661
707
|
resolution
|
|
@@ -704,7 +750,7 @@ async function resolve(store, conflict, choice) {
|
|
|
704
750
|
}
|
|
705
751
|
case "restore": {
|
|
706
752
|
if (!conflict.recordType) throw new Error(`[offline] conflict ${conflict.id} has no record to restore`);
|
|
707
|
-
const body = _nullishCoalesce(conflict.mine, () => ( _optionalChain([entry, 'optionalAccess',
|
|
753
|
+
const body = _nullishCoalesce(conflict.mine, () => ( _optionalChain([entry, 'optionalAccess', _41 => _41.body])));
|
|
708
754
|
const rootId = await rootIdOf(store, conflict, entry);
|
|
709
755
|
await store.enqueue({
|
|
710
756
|
rootId,
|
|
@@ -719,7 +765,7 @@ async function resolve(store, conflict, choice) {
|
|
|
719
765
|
if (conflict.recordId) {
|
|
720
766
|
const record = await store.getRecord(conflict.recordType, conflict.recordId);
|
|
721
767
|
if (record) await store.putRecord({ ...record, base: null, localOnly: true });
|
|
722
|
-
else if (_optionalChain([body, 'optionalAccess',
|
|
768
|
+
else if (_optionalChain([body, 'optionalAccess', _42 => _42.data]))
|
|
723
769
|
await store.putRecord({
|
|
724
770
|
type: conflict.recordType,
|
|
725
771
|
id: conflict.recordId,
|
|
@@ -754,12 +800,12 @@ async function resolve(store, conflict, choice) {
|
|
|
754
800
|
}
|
|
755
801
|
_chunk7QVYU63Ejs.__name.call(void 0, resolve, "resolve");
|
|
756
802
|
async function resolveConflict(id, choice) {
|
|
757
|
-
const store = await
|
|
803
|
+
const store = await _chunkWUNSG3INjs.getOfflineStore.call(void 0, );
|
|
758
804
|
const conflict = (await store.conflicts()).find((candidate) => candidate.id === id);
|
|
759
805
|
if (!conflict) throw new Error(`[offline] no conflict ${id}`);
|
|
760
806
|
await store.transaction((tx) => resolve(tx, conflict, choice));
|
|
761
807
|
await refreshOfflineCounts(store);
|
|
762
|
-
if (
|
|
808
|
+
if (_chunkWUNSG3INjs.getOfflineState.call(void 0, ).online) {
|
|
763
809
|
drainQueue().catch((error) => console.warn("[offline] sending the resolved change failed", error));
|
|
764
810
|
}
|
|
765
811
|
}
|
|
@@ -770,16 +816,16 @@ _chunk7QVYU63Ejs.__name.call(void 0, resolveConflict, "resolveConflict");
|
|
|
770
816
|
var LOCK_CHECK_INTERVAL_MS = 6e4;
|
|
771
817
|
var PROBE_INTERVAL_MS = 3e4;
|
|
772
818
|
async function probeApi() {
|
|
773
|
-
const config =
|
|
774
|
-
const store = await
|
|
775
|
-
const [rootId] = await
|
|
776
|
-
const endpoint = rootId ? new (0,
|
|
777
|
-
const response = await
|
|
819
|
+
const config = _chunkWUNSG3INjs.getOfflineConfig.call(void 0, );
|
|
820
|
+
const store = await _chunkWUNSG3INjs.getOfflineStore.call(void 0, );
|
|
821
|
+
const [rootId] = await _chunkQGVVF77Ljs.knownPrimaryRootIds.call(void 0, store);
|
|
822
|
+
const endpoint = rootId ? new (0, _chunk4XLDBOSEjs.EndpointCreator)({ endpoint: config.rootModule, id: rootId, childEndpoint: _chunk4XLDBOSEjs.ROOT_SYNC_ENDPOINT }) : new (0, _chunk4XLDBOSEjs.EndpointCreator)({ endpoint: config.rootModule }).addAdditionalParam("page[size]", "1");
|
|
823
|
+
const response = await _chunkWCEYT3GGjs.directFetch.call(void 0, {
|
|
778
824
|
method: "GET",
|
|
779
|
-
url:
|
|
825
|
+
url: _chunkGM4VZTWLjs.buildUrl.call(void 0, endpoint.generate()),
|
|
780
826
|
token: await _chunkLXKSUWAVjs.getClientToken.call(void 0, ),
|
|
781
827
|
language: currentLocale(),
|
|
782
|
-
additionalHeaders: { [
|
|
828
|
+
additionalHeaders: { [_chunkWUNSG3INjs.OFFLINE_REPLAY_HEADER]: "1" }
|
|
783
829
|
});
|
|
784
830
|
return !response.networkError;
|
|
785
831
|
}
|
|
@@ -824,7 +870,7 @@ async function signInExpired() {
|
|
|
824
870
|
}
|
|
825
871
|
_chunk7QVYU63Ejs.__name.call(void 0, signInExpired, "signInExpired");
|
|
826
872
|
var warnUnlessUnavailable = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (message) => (error) => {
|
|
827
|
-
if (!(error instanceof
|
|
873
|
+
if (!(error instanceof _chunkWUNSG3INjs.OfflineUnavailableError)) console.warn(message, error);
|
|
828
874
|
}, "warnUnlessUnavailable");
|
|
829
875
|
var _runningRuntimes = /* @__PURE__ */ new Set();
|
|
830
876
|
function stopOfflineRuntime() {
|
|
@@ -832,17 +878,17 @@ function stopOfflineRuntime() {
|
|
|
832
878
|
}
|
|
833
879
|
_chunk7QVYU63Ejs.__name.call(void 0, stopOfflineRuntime, "stopOfflineRuntime");
|
|
834
880
|
function startOfflineRuntime() {
|
|
835
|
-
|
|
836
|
-
if (!
|
|
881
|
+
_chunkWUNSG3INjs.refreshOfflineDeviceState.call(void 0, );
|
|
882
|
+
if (!_chunkWUNSG3INjs.isOfflineConfigured.call(void 0, )) return () => {
|
|
837
883
|
};
|
|
838
|
-
const config =
|
|
884
|
+
const config = _chunkWUNSG3INjs.getOfflineConfig.call(void 0, );
|
|
839
885
|
let running;
|
|
840
886
|
let goingOnlineAfterSync = false;
|
|
841
887
|
const run = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (reconnect) => {
|
|
842
888
|
if (!running) {
|
|
843
889
|
running = (async () => {
|
|
844
890
|
let succeeded = false;
|
|
845
|
-
if (reconnect)
|
|
891
|
+
if (reconnect) _chunkWUNSG3INjs.setReconnecting.call(void 0, true);
|
|
846
892
|
try {
|
|
847
893
|
const drained = await drainQueue();
|
|
848
894
|
if (drained.stoppedForLogin) {
|
|
@@ -850,19 +896,19 @@ function startOfflineRuntime() {
|
|
|
850
896
|
return;
|
|
851
897
|
}
|
|
852
898
|
writeReloadMarker(null);
|
|
853
|
-
if (reconnect ? !
|
|
899
|
+
if (reconnect ? !_chunkWUNSG3INjs.isReconnecting.call(void 0, ) : !_chunkWUNSG3INjs.getOfflineState.call(void 0, ).online) return;
|
|
854
900
|
await syncAll();
|
|
855
|
-
succeeded = reconnect &&
|
|
901
|
+
succeeded = reconnect && _chunkWUNSG3INjs.isReconnecting.call(void 0, );
|
|
856
902
|
} catch (error) {
|
|
857
903
|
warnUnlessUnavailable("[offline] background sync failed")(error);
|
|
858
904
|
} finally {
|
|
859
|
-
if (reconnect)
|
|
905
|
+
if (reconnect) _chunkWUNSG3INjs.setReconnecting.call(void 0, false);
|
|
860
906
|
running = void 0;
|
|
861
907
|
if (succeeded) {
|
|
862
908
|
goingOnlineAfterSync = true;
|
|
863
|
-
|
|
909
|
+
_chunkWUNSG3INjs.setOfflineState.call(void 0, { online: true });
|
|
864
910
|
goingOnlineAfterSync = false;
|
|
865
|
-
if (
|
|
911
|
+
if (_chunkWUNSG3INjs.getOfflineState.call(void 0, ).pending > 0) {
|
|
866
912
|
drainQueue().catch(warnUnlessUnavailable("[offline] sending the waiting changes failed"));
|
|
867
913
|
}
|
|
868
914
|
}
|
|
@@ -874,7 +920,7 @@ function startOfflineRuntime() {
|
|
|
874
920
|
const runOnline = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => run(false), "runOnline");
|
|
875
921
|
let probing = false;
|
|
876
922
|
const probe = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
877
|
-
if (probing || running ||
|
|
923
|
+
if (probing || running || _chunkWUNSG3INjs.getOfflineState.call(void 0, ).online) return;
|
|
878
924
|
if (typeof navigator !== "undefined" && navigator.onLine === false) return;
|
|
879
925
|
probing = true;
|
|
880
926
|
try {
|
|
@@ -887,8 +933,8 @@ function startOfflineRuntime() {
|
|
|
887
933
|
}, "probe");
|
|
888
934
|
const onBrowserOnline = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => void probe(), "onBrowserOnline");
|
|
889
935
|
if (typeof window !== "undefined") window.addEventListener("online", onBrowserOnline);
|
|
890
|
-
let wasOnline =
|
|
891
|
-
const unsubscribe =
|
|
936
|
+
let wasOnline = _chunkWUNSG3INjs.getOfflineState.call(void 0, ).online;
|
|
937
|
+
const unsubscribe = _chunkWUNSG3INjs.subscribeOfflineState.call(void 0, (state) => {
|
|
892
938
|
if (!state.available) {
|
|
893
939
|
stop();
|
|
894
940
|
return;
|
|
@@ -896,15 +942,15 @@ function startOfflineRuntime() {
|
|
|
896
942
|
if (state.online && !wasOnline && !goingOnlineAfterSync) void runOnline();
|
|
897
943
|
wasOnline = state.online;
|
|
898
944
|
});
|
|
899
|
-
void
|
|
945
|
+
void _chunkQGVVF77Ljs.refreshLockedRoots.call(void 0, ).catch(warnUnlessUnavailable("[offline] lock check failed"));
|
|
900
946
|
void refreshOfflineCounts().catch(warnUnlessUnavailable("[offline] reading the queue failed"));
|
|
901
|
-
if (
|
|
947
|
+
if (_chunkWUNSG3INjs.getOfflineState.call(void 0, ).online) void runOnline();
|
|
902
948
|
const syncTimer = setInterval(() => {
|
|
903
|
-
if (
|
|
949
|
+
if (_chunkWUNSG3INjs.getOfflineState.call(void 0, ).online) void runOnline();
|
|
904
950
|
}, config.syncIntervalMs);
|
|
905
951
|
const probeTimer = setInterval(() => void probe(), PROBE_INTERVAL_MS);
|
|
906
952
|
const lockTimer = setInterval(() => {
|
|
907
|
-
void
|
|
953
|
+
void _chunkQGVVF77Ljs.refreshLockedRoots.call(void 0, ).catch(warnUnlessUnavailable("[offline] lock check failed"));
|
|
908
954
|
}, LOCK_CHECK_INTERVAL_MS);
|
|
909
955
|
const stop = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
910
956
|
_runningRuntimes.delete(stop);
|
|
@@ -921,69 +967,69 @@ _chunk7QVYU63Ejs.__name.call(void 0, startOfflineRuntime, "startOfflineRuntime")
|
|
|
921
967
|
|
|
922
968
|
// src/offline/logout.ts
|
|
923
969
|
async function prepareOfflineLogout() {
|
|
924
|
-
if (!
|
|
925
|
-
if (!
|
|
926
|
-
const store = await
|
|
970
|
+
if (!_chunkWUNSG3INjs.isOfflineConfigured.call(void 0, )) return { pending: 0 };
|
|
971
|
+
if (!_chunkWUNSG3INjs.getOfflineConfig.call(void 0, ).getUserId()) return { pending: 0 };
|
|
972
|
+
const store = await _chunkWUNSG3INjs.getOfflineStore.call(void 0, );
|
|
927
973
|
const entries = await store.queue();
|
|
928
974
|
return { pending: entries.length };
|
|
929
975
|
}
|
|
930
976
|
_chunk7QVYU63Ejs.__name.call(void 0, prepareOfflineLogout, "prepareOfflineLogout");
|
|
931
977
|
async function finishOfflineLogout(userId) {
|
|
932
978
|
stopOfflineRuntime();
|
|
933
|
-
|
|
934
|
-
const { deleteDeviceStore: deleteDeviceStore2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("../lifecycle-
|
|
979
|
+
_chunkWUNSG3INjs.blockOfflineStore.call(void 0, userId);
|
|
980
|
+
const { deleteDeviceStore: deleteDeviceStore2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("../lifecycle-TO65I7TO.js")));
|
|
935
981
|
await deleteDeviceStore2(userId);
|
|
936
|
-
await
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
982
|
+
await _chunk6RCZ64BQjs.deleteImagesCaches.call(void 0, );
|
|
983
|
+
_chunkWUNSG3INjs.setOfflineEnabledOnDevice.call(void 0, userId, false);
|
|
984
|
+
_chunkWUNSG3INjs.writeOfflineLastSync.call(void 0, userId, null);
|
|
985
|
+
_chunkWUNSG3INjs.setOfflineState.call(void 0, { enabled: false, syncProgress: null, lastSyncedAt: null, rootCount: null });
|
|
940
986
|
}
|
|
941
987
|
_chunk7QVYU63Ejs.__name.call(void 0, finishOfflineLogout, "finishOfflineLogout");
|
|
942
988
|
|
|
943
989
|
// src/offline/device-switch.ts
|
|
944
990
|
function signedInUserId() {
|
|
945
|
-
const userId =
|
|
991
|
+
const userId = _chunkWUNSG3INjs.getOfflineConfig.call(void 0, ).getUserId();
|
|
946
992
|
if (!userId) throw new Error("No signed-in user");
|
|
947
993
|
return userId;
|
|
948
994
|
}
|
|
949
995
|
_chunk7QVYU63Ejs.__name.call(void 0, signedInUserId, "signedInUserId");
|
|
950
996
|
async function turnOnOffline() {
|
|
951
997
|
const userId = signedInUserId();
|
|
952
|
-
|
|
953
|
-
|
|
998
|
+
_chunkWUNSG3INjs.setOfflineEnabledOnDevice.call(void 0, userId, true);
|
|
999
|
+
_chunkWUNSG3INjs.setOfflineState.call(void 0, { enabled: true });
|
|
954
1000
|
try {
|
|
955
|
-
await _optionalChain([navigator, 'access',
|
|
1001
|
+
await _optionalChain([navigator, 'access', _43 => _43.storage, 'optionalAccess', _44 => _44.persist, 'optionalCall', _45 => _45()]);
|
|
956
1002
|
} catch (e4) {
|
|
957
1003
|
}
|
|
958
1004
|
}
|
|
959
1005
|
_chunk7QVYU63Ejs.__name.call(void 0, turnOnOffline, "turnOnOffline");
|
|
960
1006
|
async function turnOffOffline() {
|
|
961
1007
|
const userId = signedInUserId();
|
|
962
|
-
if (
|
|
1008
|
+
if (_chunkWUNSG3INjs.isOfflineAvailable.call(void 0, )) {
|
|
963
1009
|
let pending = 0;
|
|
964
1010
|
try {
|
|
965
|
-
const store = await
|
|
1011
|
+
const store = await _chunkWUNSG3INjs.getOfflineStore.call(void 0, );
|
|
966
1012
|
pending = (await store.queue()).length;
|
|
967
1013
|
} catch (e5) {
|
|
968
|
-
const { hasUnsentChanges: hasUnsentChanges2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("../lifecycle-
|
|
1014
|
+
const { hasUnsentChanges: hasUnsentChanges2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("../lifecycle-TO65I7TO.js")));
|
|
969
1015
|
if (await hasUnsentChanges2(userId).catch(() => false)) pending = 1;
|
|
970
1016
|
}
|
|
971
1017
|
if (pending > 0) return { turnedOff: false, pending };
|
|
972
1018
|
}
|
|
973
|
-
|
|
974
|
-
if (
|
|
1019
|
+
_chunkWUNSG3INjs.setOfflineEnabledOnDevice.call(void 0, userId, false);
|
|
1020
|
+
if (_chunkWUNSG3INjs.isOfflineAvailable.call(void 0, )) {
|
|
975
1021
|
stopOfflineRuntime();
|
|
976
1022
|
try {
|
|
977
|
-
const { deleteDeviceStore: deleteDeviceStore2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("../lifecycle-
|
|
1023
|
+
const { deleteDeviceStore: deleteDeviceStore2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("../lifecycle-TO65I7TO.js")));
|
|
978
1024
|
await deleteDeviceStore2(userId);
|
|
979
|
-
await
|
|
1025
|
+
await _chunk6RCZ64BQjs.deleteImagesCaches.call(void 0, );
|
|
980
1026
|
} catch (error) {
|
|
981
1027
|
console.warn("[offline] the device copy could not be deleted", error);
|
|
982
1028
|
}
|
|
983
|
-
|
|
1029
|
+
_chunkWUNSG3INjs.forgetOfflineStore.call(void 0, userId);
|
|
984
1030
|
}
|
|
985
|
-
|
|
986
|
-
|
|
1031
|
+
_chunkWUNSG3INjs.writeOfflineLastSync.call(void 0, userId, null);
|
|
1032
|
+
_chunkWUNSG3INjs.setOfflineState.call(void 0, { enabled: false, syncProgress: null, lastSyncedAt: null, rootCount: null });
|
|
987
1033
|
return { turnedOff: true };
|
|
988
1034
|
}
|
|
989
1035
|
_chunk7QVYU63Ejs.__name.call(void 0, turnOffOffline, "turnOffOffline");
|
|
@@ -1048,5 +1094,6 @@ _chunk7QVYU63Ejs.__name.call(void 0, turnOffOffline, "turnOffOffline");
|
|
|
1048
1094
|
|
|
1049
1095
|
|
|
1050
1096
|
|
|
1051
|
-
|
|
1097
|
+
|
|
1098
|
+
exports.DEFAULT_DEVICE_WORKER_URL = _chunkWUNSG3INjs.DEFAULT_DEVICE_WORKER_URL; exports.DEFAULT_SQLITE_MODULE_URL = _chunkWUNSG3INjs.DEFAULT_SQLITE_MODULE_URL; exports.DEVICE_WORKER_FILE = _chunkWUNSG3INjs.DEVICE_WORKER_FILE; exports.DeviceStoreUnavailableError = _chunkWUNSG3INjs.DeviceStoreUnavailableError; exports.NeedsConnectionError = _chunkWUNSG3INjs.NeedsConnectionError; exports.OFFLINE_REPLAY_HEADER = _chunkWUNSG3INjs.OFFLINE_REPLAY_HEADER; exports.OFFLINE_SQLITE_FILES = _chunkWUNSG3INjs.OFFLINE_SQLITE_FILES; exports.OfflineUnavailableError = _chunkWUNSG3INjs.OfflineUnavailableError; exports.RootSync = _chunk4XLDBOSEjs.RootSync; exports.SERVER_DEFAULT_ORDER_BY = _chunkN5ZE2Z6Ijs.SERVER_DEFAULT_ORDER_BY; exports.configureOffline = configureOffline2; exports.deleteDeviceStore = _chunk6RCZ64BQjs.deleteDeviceStore; exports.drainQueue = drainQueue; exports.errorAnswer = _chunkN5ZE2Z6Ijs.errorAnswer; exports.finishOfflineLogout = finishOfflineLogout; exports.forgetOfflineStore = _chunkWUNSG3INjs.forgetOfflineStore; exports.getOfflineConfig = _chunkWUNSG3INjs.getOfflineConfig; exports.getOfflineState = _chunkWUNSG3INjs.getOfflineState; exports.getOfflineStore = _chunkWUNSG3INjs.getOfflineStore; exports.hasUnsentChanges = _chunk6RCZ64BQjs.hasUnsentChanges; exports.includedFor = _chunkN5ZE2Z6Ijs.includedFor; exports.isOfflineAvailable = _chunkWUNSG3INjs.isOfflineAvailable; exports.isOfflineConfigured = _chunkWUNSG3INjs.isOfflineConfigured; exports.isOfflineEnabledOnDevice = _chunkWUNSG3INjs.isOfflineEnabledOnDevice; exports.isRootLocked = _chunk6RCZ64BQjs.isRootLocked; exports.linkKindFor = _chunkN5ZE2Z6Ijs.linkKindFor; exports.linkKindsOf = _chunkN5ZE2Z6Ijs.linkKindsOf; exports.linksOfKind = _chunkN5ZE2Z6Ijs.linksOfKind; exports.listAnswer = _chunkN5ZE2Z6Ijs.listAnswer; exports.localTransport = _chunkN5ZE2Z6Ijs.localTransport; exports.matchPattern = _chunkN5ZE2Z6Ijs.matchPattern; exports.matchRoute = _chunkN5ZE2Z6Ijs.matchRoute; exports.mergeResource = _chunkN5ZE2Z6Ijs.mergeResource; exports.needsConnectionAnswer = _chunkN5ZE2Z6Ijs.needsConnectionAnswer; exports.notFoundAnswer = _chunkN5ZE2Z6Ijs.notFoundAnswer; exports.onUserSignedIn = _chunk6RCZ64BQjs.onUserSignedIn; exports.openDeviceStore = _chunk6RCZ64BQjs.openDeviceStore; exports.openMemoryDeviceStore = _chunk6RCZ64BQjs.openMemoryDeviceStore; exports.orderRecords = _chunkN5ZE2Z6Ijs.orderRecords; exports.orderedListAnswer = _chunkN5ZE2Z6Ijs.orderedListAnswer; exports.patternToString = _chunkWUNSG3INjs.patternToString; exports.prepareOfflineLogout = prepareOfflineLogout; exports.refreshOfflineDeviceState = _chunkWUNSG3INjs.refreshOfflineDeviceState; exports.resolveConflict = resolveConflict; exports.resourceFromDocument = _chunkN5ZE2Z6Ijs.resourceFromDocument; exports.resourceListAnswer = _chunkN5ZE2Z6Ijs.resourceListAnswer; exports.searchRecords = _chunkN5ZE2Z6Ijs.searchRecords; exports.setDeviceStoreOpener = _chunkWUNSG3INjs.setDeviceStoreOpener; exports.setOfflineState = _chunkWUNSG3INjs.setOfflineState; exports.singleAnswer = _chunkN5ZE2Z6Ijs.singleAnswer; exports.startOfflineRuntime = startOfflineRuntime; exports.stopOfflineRuntime = stopOfflineRuntime; exports.subscribeOfflineState = _chunkWUNSG3INjs.subscribeOfflineState; exports.syncAll = syncAll; exports.syncRoot = syncRoot; exports.turnOffOffline = turnOffOffline; exports.turnOnOffline = turnOnOffline; exports.useConflicts = useConflicts; exports.useNeedsConnection = _chunkDGN3PR2Fjs.useNeedsConnection; exports.useOfflineState = _chunkDGN3PR2Fjs.useOfflineState; exports.writeThrough = _chunkQGVVF77Ljs.writeThrough;
|
|
1052
1099
|
//# sourceMappingURL=index.js.map
|