@aerogel/plugin-local-first 0.1.0 → 0.1.1-next.26f3c2c807213724de7500a899a6712abae430ad
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/aerogel-plugin-local-first.d.ts +27 -13
- package/dist/aerogel-plugin-local-first.js +745 -651
- package/dist/aerogel-plugin-local-first.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AccountLoggedIn.vue +3 -1
- package/src/components/AccountModal.vue +25 -5
- package/src/index.ts +12 -6
- package/src/jobs/Backup.ts +21 -0
- package/src/jobs/Sync.test.ts +22 -26
- package/src/jobs/Sync.ts +147 -40
- package/src/jobs/mixins/LoadsChildren.ts +41 -42
- package/src/jobs/mixins/TracksLocalModels.ts +2 -4
- package/src/lib/inference.ts +37 -0
- package/src/lib/mirroring.ts +73 -38
- package/src/services/Cloud.state.ts +5 -0
- package/src/services/Cloud.ts +57 -15
- package/src/testing/mocks/documents-cache.ts +25 -0
- package/src/testing/setup.ts +17 -1
- package/src/services/DocumentsCache.ts +0 -39
|
@@ -1,92 +1,84 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { Solid as
|
|
7
|
-
import { SolidModel as J, SolidContainsRelation as
|
|
8
|
-
import { getTrackedModels as
|
|
9
|
-
import { watchEffect as
|
|
10
|
-
import { bootModels as
|
|
11
|
-
import { MalformedSolidDocumentError as
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
async isFresh(e, t) {
|
|
18
|
-
const n = await this.cache.get(e), i = typeof t != "number" ? t.getTime() : t;
|
|
19
|
-
return !!(n != null && n.modifiedAt) && n.modifiedAt >= i;
|
|
20
|
-
}
|
|
21
|
-
async remember(e, t) {
|
|
22
|
-
await this.cache.set(e, {
|
|
23
|
-
modifiedAt: typeof t != "number" ? t.getTime() : t
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
async forget(e) {
|
|
27
|
-
await this.cache.delete(e);
|
|
28
|
-
}
|
|
29
|
-
async clear() {
|
|
30
|
-
await this.cache.clear();
|
|
31
|
-
}
|
|
32
|
-
async boot() {
|
|
33
|
-
D.on("auth:logout", async () => {
|
|
34
|
-
await this.cache.clear(), this.cache.close();
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const P = we(Nt), de = /* @__PURE__ */ new WeakMap();
|
|
39
|
-
function fe(o) {
|
|
40
|
-
return ut(
|
|
41
|
-
k(o).map((s) => {
|
|
1
|
+
var it = Object.defineProperty;
|
|
2
|
+
var rt = (o, s, e) => s in o ? it(o, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[s] = e;
|
|
3
|
+
var M = (o, s, e) => rt(o, typeof s != "symbol" ? s + "" : s, e);
|
|
4
|
+
import { App as Y, Job as be, Errors as ne, defineServiceState as at, replaceExisting as $e, translateWithDefault as v, Events as R, dispatch as ce, appNamespace as lt, Modal as Oe, Markdown as E, Link as me, Button as q, UI as de, Storage as ct, defineSettings as dt, useEvent as ut, SettingsModal as Te, ProgressBar as ht, AdvancedOptions as ft, Checkbox as ue, EditableContent as mt, DropdownMenu as gt, bootServices as pt } from "@aerogel/core";
|
|
5
|
+
import { isInstanceOf as z, arrayFilter as yt, required as U, facade as Pe, after as se, arrayRemove as wt, urlRoute as qe, tap as _e, urlResolveDirectory as Mt, objectWithout as bt, requireUrlParentDirectory as O, fail as We, arrayFrom as Ct, map as A, arrayChunk as vt, mixed as Ne, objectMap as St, round as $t, arrayWithout as Dt, toString as Rt, Semaphore as kt, isArray as Lt, isTesting as De, hasLocationQueryParameter as Re, parseBoolean as ke, getLocationQueryParameter as Le } from "@noeldemartin/utils";
|
|
6
|
+
import { Solid as b, SolidLogin as At, SolidAvatar as Je } from "@aerogel/plugin-solid";
|
|
7
|
+
import { SolidModel as J, SolidContainsRelation as Ut, SolidIsContainedByRelation as Et, SolidACLAuthorization as It, SolidDocument as zt, Metadata as Ot, Operation as Tt, SolidContainer as Q, isContainerClass as j, isContainer as I, Tombstone as x, PropertyOperation as oe, DocumentsCache as Pt, isSolidModel as qt } from "soukai-solid";
|
|
8
|
+
import { getTrackedModels as Ce, trackModelsCollection as ie, ignoreModelsCollection as _t, trackModels as Wt } from "@aerogel/plugin-soukai";
|
|
9
|
+
import { watchEffect as Nt, markRaw as _, createElementBlock as C, openBlock as f, createElementVNode as m, defineComponent as B, createBlock as D, unref as u, withCtx as S, createVNode as h, createTextVNode as X, toDisplayString as $, createCommentVNode as W, useTemplateRef as Jt, ref as xt, computed as ee, normalizeClass as xe } from "vue";
|
|
10
|
+
import { bootModels as jt, requireEngine as je, DocumentNotFound as Bt, InvalidModelAttributes as Vt, requireBootedModel as Ft, getBootedModels as Ht } from "soukai";
|
|
11
|
+
import { MalformedSolidDocumentError as Kt } from "@noeldemartin/solid-utils";
|
|
12
|
+
const he = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
function ge(o) {
|
|
14
|
+
return yt(
|
|
15
|
+
T(o).map((s) => {
|
|
42
16
|
const e = o.instance().requireRelation(s).relatedClass;
|
|
43
|
-
return
|
|
17
|
+
return j(e) ? !1 : e;
|
|
44
18
|
})
|
|
45
19
|
);
|
|
46
20
|
}
|
|
47
|
-
function
|
|
48
|
-
return
|
|
21
|
+
function T(o) {
|
|
22
|
+
return he.has(o) || he.set(
|
|
49
23
|
o,
|
|
50
|
-
o.relations.filter((s) => J.reservedRelations.includes(s) ? !1 : o.instance().requireRelation(s) instanceof
|
|
51
|
-
),
|
|
24
|
+
o.relations.filter((s) => J.reservedRelations.includes(s) ? !1 : o.instance().requireRelation(s) instanceof Ut)
|
|
25
|
+
), he.get(o) ?? [];
|
|
52
26
|
}
|
|
53
|
-
function
|
|
54
|
-
return
|
|
27
|
+
function Be(o) {
|
|
28
|
+
return T(o.static()).reduce(
|
|
55
29
|
(e, t) => e.concat(o.getRelationModels(t) ?? []),
|
|
56
30
|
[]
|
|
57
31
|
);
|
|
58
32
|
}
|
|
59
|
-
function
|
|
33
|
+
function Ae(o) {
|
|
60
34
|
const s = /* @__PURE__ */ new Set(), e = o.instance();
|
|
61
35
|
s.add(o);
|
|
62
36
|
for (const t of o.relations)
|
|
63
37
|
o.reservedRelations.includes(t) || s.add(e.requireRelation(t).relatedClass);
|
|
64
38
|
return [...s.values()];
|
|
65
39
|
}
|
|
66
|
-
function
|
|
40
|
+
function N(o) {
|
|
67
41
|
return o.getRelatedModels().filter(
|
|
68
|
-
(s) => !
|
|
42
|
+
(s) => !z(s, It) && !z(s, zt) && !z(s, Ot) && !z(s, Tt) && s.static() !== Q
|
|
69
43
|
);
|
|
70
44
|
}
|
|
71
|
-
function
|
|
45
|
+
function Ve(o) {
|
|
72
46
|
if (o.isDirty())
|
|
73
47
|
return !0;
|
|
74
|
-
if (!(o instanceof
|
|
48
|
+
if (!(o instanceof Q))
|
|
75
49
|
return !1;
|
|
76
50
|
const s = (e) => {
|
|
77
51
|
var t;
|
|
78
|
-
return (t = o.getRelationModels(e)) == null ? void 0 : t.some((n) =>
|
|
52
|
+
return (t = o.getRelationModels(e)) == null ? void 0 : t.some((n) => Ve(n));
|
|
79
53
|
};
|
|
80
|
-
return
|
|
54
|
+
return T(o.static()).some(s);
|
|
55
|
+
}
|
|
56
|
+
async function pe(o, s) {
|
|
57
|
+
const e = ["authorizations", "metadata", "operations", "tombstone"];
|
|
58
|
+
let t;
|
|
59
|
+
do {
|
|
60
|
+
t = !1;
|
|
61
|
+
const n = N(o);
|
|
62
|
+
for (const i of n)
|
|
63
|
+
for (const a of i.static("relations"))
|
|
64
|
+
if (!(e.includes(a) || i.isRelationLoaded(a) || i.getRelation(a) instanceof Et))
|
|
65
|
+
try {
|
|
66
|
+
await i.loadRelation(a), t = !0;
|
|
67
|
+
} catch (l) {
|
|
68
|
+
if (!s)
|
|
69
|
+
throw l;
|
|
70
|
+
s(l);
|
|
71
|
+
}
|
|
72
|
+
} while (t);
|
|
81
73
|
}
|
|
82
|
-
const
|
|
83
|
-
class
|
|
74
|
+
const Yt = U(() => Y.service("$cloud"));
|
|
75
|
+
class Qt {
|
|
84
76
|
constructor() {
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
M(this, "models", /* @__PURE__ */ new Set());
|
|
78
|
+
M(this, "promises", []);
|
|
87
79
|
}
|
|
88
80
|
push(s) {
|
|
89
|
-
this.models.add(s), this.syncAfter(
|
|
81
|
+
this.models.add(s), this.syncAfter(se({ seconds: 1 }));
|
|
90
82
|
}
|
|
91
83
|
clear(s) {
|
|
92
84
|
if (!s) {
|
|
@@ -98,39 +90,47 @@ class jt {
|
|
|
98
90
|
}
|
|
99
91
|
async syncAfter(s) {
|
|
100
92
|
const e = typeof s == "function" ? s() : s;
|
|
101
|
-
return this.promises.push(e), e.then(() =>
|
|
93
|
+
return this.promises.push(e), e.then(() => wt(this.promises, e)), this.promises.length === 1 && this.schedule(), e;
|
|
102
94
|
}
|
|
103
95
|
schedule() {
|
|
104
|
-
Promise.all(this.promises).then(() =>
|
|
96
|
+
Promise.all(this.promises).then(() => se()).then(() => {
|
|
105
97
|
if (this.promises.length !== 0) {
|
|
106
98
|
this.schedule();
|
|
107
99
|
return;
|
|
108
100
|
}
|
|
109
101
|
const s = this.consume();
|
|
110
|
-
s.length !== 0 &&
|
|
102
|
+
s.length !== 0 && Yt.syncIfOnline(s);
|
|
111
103
|
});
|
|
112
104
|
}
|
|
113
105
|
consume() {
|
|
114
106
|
const s = [], e = /* @__PURE__ */ new Set();
|
|
115
107
|
for (const t of this.models)
|
|
116
|
-
|
|
108
|
+
I(t) && (this.models.delete(t), Be(t).forEach((n) => e.add(n)), s.push(t));
|
|
117
109
|
for (const t of this.models)
|
|
118
110
|
this.models.delete(t), !e.has(t) && s.push(t);
|
|
119
111
|
return s;
|
|
120
112
|
}
|
|
121
113
|
}
|
|
122
|
-
const
|
|
123
|
-
function
|
|
114
|
+
const re = Pe(Qt), g = U(() => Y.service("$cloud")), Fe = /* @__PURE__ */ new WeakMap(), ve = /* @__PURE__ */ new WeakMap(), fe = /* @__PURE__ */ new WeakMap();
|
|
115
|
+
function He(o, s) {
|
|
116
|
+
if (s ?? (s = /* @__PURE__ */ new Set()), !s.has(o)) {
|
|
117
|
+
s.add(o);
|
|
118
|
+
for (const e of o.relations)
|
|
119
|
+
He(o.instance().requireRelation(e).relatedClass, s);
|
|
120
|
+
}
|
|
121
|
+
return s;
|
|
122
|
+
}
|
|
123
|
+
function Zt(o) {
|
|
124
124
|
const s = o.getRelatedModels().concat([o]);
|
|
125
125
|
for (const e of s)
|
|
126
126
|
e.cleanDirty(!0);
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
const s =
|
|
128
|
+
function Gt(o) {
|
|
129
|
+
const s = N(o).concat([o]);
|
|
130
130
|
for (const e of s) {
|
|
131
131
|
if (!e.operations || e.operations.length === 0)
|
|
132
132
|
continue;
|
|
133
|
-
const t = (e.operations ?? []).filter((n) => !(n instanceof
|
|
133
|
+
const t = (e.operations ?? []).filter((n) => !(n instanceof oe) || !e.ignoreRdfPropertyHistory(n.property, !0));
|
|
134
134
|
if (!t.some((n) => !n.isInception(e))) {
|
|
135
135
|
e.setRelationModels("operations", []);
|
|
136
136
|
continue;
|
|
@@ -144,147 +144,163 @@ async function Ue(o) {
|
|
|
144
144
|
...g.localModelUpdates,
|
|
145
145
|
[o.url]: 1
|
|
146
146
|
}
|
|
147
|
-
}),
|
|
147
|
+
}), an(o.static()) && await ye(o.static(), O(o.url)), g.autoPush && g.ready && !g.syncing && re.push(o);
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
function Xt(o, s) {
|
|
150
|
+
var n;
|
|
151
|
+
const e = L(Q), t = (n = g.registeredModels.find(
|
|
152
|
+
({ modelClass: i }) => i === o.static()
|
|
153
|
+
)) == null ? void 0 : n.path;
|
|
154
|
+
return new e({
|
|
155
|
+
url: te(Qe(o, s).static(), t)
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
async function ye(o, s) {
|
|
150
159
|
var e, t;
|
|
151
160
|
(e = g.modelCollections[o.modelName]) != null && e.includes(s) || (g.setState("modelCollections", {
|
|
152
161
|
...g.modelCollections,
|
|
153
162
|
[o.modelName]: (g.modelCollections[o.modelName] ?? []).concat(s)
|
|
154
|
-
}), (t = g.modelCollections[o.modelName]) != null && t.includes(o.collection) || (o.collection = s), await
|
|
163
|
+
}), (t = g.modelCollections[o.modelName]) != null && t.includes(o.collection) || (o.collection = s), await ie(o, s));
|
|
155
164
|
}
|
|
156
|
-
async function
|
|
157
|
-
if (
|
|
165
|
+
async function Ee(o) {
|
|
166
|
+
if (en(o))
|
|
158
167
|
return;
|
|
159
168
|
const s = g.localModelUpdates[o.url] ?? 0;
|
|
160
169
|
g.setState({
|
|
161
|
-
localModelUpdates: o.isSoftDeleted() ?
|
|
170
|
+
localModelUpdates: o.isSoftDeleted() ? bt(g.localModelUpdates, o.url) : {
|
|
162
171
|
...g.localModelUpdates,
|
|
163
172
|
[o.url]: s + 1
|
|
164
173
|
}
|
|
165
|
-
}), await
|
|
174
|
+
}), await g.getDocumentsCache().forget(
|
|
175
|
+
O(o.requireDocumentUrl()),
|
|
176
|
+
o.requireDocumentUrl()
|
|
177
|
+
), g.autoPush && g.ready && !g.syncing && re.push(o);
|
|
166
178
|
}
|
|
167
|
-
function
|
|
179
|
+
function we(o, s) {
|
|
168
180
|
const e = {}, t = Array.from(o);
|
|
169
181
|
for (const [n, i] of Object.entries(g.localModelUpdates)) {
|
|
170
|
-
const
|
|
171
|
-
(o.has(n) || t.some((r) => r.endsWith("/") && n.startsWith(r))) && !(s != null && s.has(
|
|
182
|
+
const a = qe(n);
|
|
183
|
+
(o.has(n) || t.some((r) => r.endsWith("/") && n.startsWith(r))) && !(s != null && s.has(a)) || (e[n] = i);
|
|
172
184
|
}
|
|
173
185
|
g.setState({ localModelUpdates: e });
|
|
174
186
|
}
|
|
175
|
-
function
|
|
176
|
-
const e =
|
|
177
|
-
|
|
178
|
-
for (const n of k(o.static()))
|
|
179
|
-
e.add(o.requireRelation(n).relatedClass);
|
|
180
|
-
const t = [...e.values()].map(
|
|
181
|
-
(n) => [n, z(n)]
|
|
187
|
+
function Ke(o, s = {}) {
|
|
188
|
+
const e = Array.from(new Set(N(o).map((t) => t.static()))).map(
|
|
189
|
+
(t) => [t, L(t)]
|
|
182
190
|
);
|
|
183
|
-
return
|
|
184
|
-
|
|
191
|
+
return _e(o.clone({ constructors: e }), (t) => {
|
|
192
|
+
Gt(t), s.clean && Zt(t);
|
|
185
193
|
});
|
|
186
194
|
}
|
|
187
|
-
function
|
|
188
|
-
|
|
189
|
-
if (s.add(o.static()), o instanceof W)
|
|
190
|
-
for (const t of k(o.static()))
|
|
191
|
-
s.add(o.requireRelation(t).relatedClass);
|
|
192
|
-
const e = [...s.values()].map(
|
|
193
|
-
(t) => [t, tn(t)]
|
|
194
|
-
);
|
|
195
|
-
return o.clone({ constructors: e });
|
|
195
|
+
function Ye(o) {
|
|
196
|
+
return o.clone({ constructors: H(o) });
|
|
196
197
|
}
|
|
197
198
|
async function Ie(o, s, e) {
|
|
198
|
-
const t =
|
|
199
|
-
return s.concat(
|
|
199
|
+
const t = L(x), n = s.map((l) => l.url), i = o.filter((l) => !n.includes(l.url)).map((l) => l.requireDocumentUrl()).filter((l) => !e.has(l)), a = await t.all({ $in: i });
|
|
200
|
+
return s.concat(a);
|
|
200
201
|
}
|
|
201
|
-
function
|
|
202
|
+
function en(o) {
|
|
202
203
|
return !o.getDocumentModels().flatMap(
|
|
203
204
|
(t) => {
|
|
204
205
|
var n;
|
|
205
206
|
return ((n = t.operations) == null ? void 0 : n.map((i) => [t, i])) ?? [];
|
|
206
207
|
}
|
|
207
208
|
).some(([t, n]) => {
|
|
208
|
-
var i,
|
|
209
|
-
return n.date.getTime() !== ((
|
|
209
|
+
var i, a;
|
|
210
|
+
return n.date.getTime() !== ((a = (i = t.metadata) == null ? void 0 : i.updatedAt) == null ? void 0 : a.getTime()) ? !1 : n instanceof oe ? !t.ignoreRdfPropertyHistory(n.property, !0) : !0;
|
|
210
211
|
});
|
|
211
212
|
}
|
|
212
|
-
function
|
|
213
|
-
|
|
213
|
+
function H(o) {
|
|
214
|
+
const s = o.static();
|
|
215
|
+
if (!fe.has(s)) {
|
|
216
|
+
const e = Array.from(He(s)).map((t) => Ze(t) ? [t, cn(t)] : [t, L(t)]).map(([t, n]) => [
|
|
217
|
+
[t, n],
|
|
218
|
+
[n, t]
|
|
219
|
+
]).flat();
|
|
220
|
+
for (const t of e)
|
|
221
|
+
fe.set(t[0], e);
|
|
222
|
+
}
|
|
223
|
+
return U(fe.get(s));
|
|
224
|
+
}
|
|
225
|
+
function Qe(o, s) {
|
|
226
|
+
return s.get(o.url) ?? Ye(o);
|
|
214
227
|
}
|
|
215
|
-
function
|
|
216
|
-
return [...g.registeredModels].map(({ modelClass: o }) =>
|
|
228
|
+
function Me() {
|
|
229
|
+
return [...g.registeredModels].map(({ modelClass: o }) => Ce(o, { includeSoftDeleted: !0 })).flat();
|
|
217
230
|
}
|
|
218
|
-
function
|
|
231
|
+
function tn() {
|
|
219
232
|
return g.schemaMigrations;
|
|
220
233
|
}
|
|
221
|
-
function
|
|
234
|
+
function nn() {
|
|
222
235
|
g.schemaMigrations.clear();
|
|
223
236
|
}
|
|
224
237
|
function ze(o) {
|
|
225
238
|
return g.schemaMigrations.get(o);
|
|
226
239
|
}
|
|
227
|
-
function
|
|
228
|
-
return
|
|
240
|
+
function L(o) {
|
|
241
|
+
return Fe.get(o) ?? ln(o);
|
|
229
242
|
}
|
|
230
|
-
function
|
|
231
|
-
const e =
|
|
243
|
+
function te(o, s) {
|
|
244
|
+
const e = b.requireUser().storageUrls[0], t = j(o) && T(o).map((n) => {
|
|
232
245
|
const i = o.instance().requireRelation(n).relatedClass;
|
|
233
|
-
return
|
|
246
|
+
return j(i) ? null : i;
|
|
234
247
|
}).filter(Boolean)[0];
|
|
235
|
-
return s ?? (s = `/${(t || o).modelName.toLowerCase()}s/`),
|
|
248
|
+
return s ?? (s = `/${(t || o).modelName.toLowerCase()}s/`), Mt((s.startsWith("/") ? e.slice(0, -1) : e) + s);
|
|
236
249
|
}
|
|
237
|
-
function
|
|
238
|
-
return s.get(o.url) ??
|
|
250
|
+
function sn(o, s) {
|
|
251
|
+
return s.get(o.url) ?? Ke(o);
|
|
239
252
|
}
|
|
240
|
-
function
|
|
253
|
+
function on(o) {
|
|
241
254
|
for (const { modelClass: s } of g.registeredModels)
|
|
242
|
-
if (
|
|
255
|
+
if (Ce(s).some((t) => t.url === o.url))
|
|
243
256
|
return !0;
|
|
244
257
|
return !1;
|
|
245
258
|
}
|
|
246
|
-
function
|
|
247
|
-
return
|
|
259
|
+
function K(o) {
|
|
260
|
+
return Ze(o.static());
|
|
248
261
|
}
|
|
249
|
-
function
|
|
250
|
-
return
|
|
262
|
+
function Ze(o) {
|
|
263
|
+
return ve.has(o);
|
|
264
|
+
}
|
|
265
|
+
function rn(o) {
|
|
266
|
+
return !K(o);
|
|
251
267
|
}
|
|
252
|
-
function
|
|
268
|
+
function an(o) {
|
|
253
269
|
return g.registeredModels.some(({ modelClass: s }) => s === o);
|
|
254
270
|
}
|
|
255
|
-
function
|
|
271
|
+
function ln(o) {
|
|
256
272
|
var n;
|
|
257
|
-
const s = o, e = (i,
|
|
258
|
-
i.timestamps = s.timestamps, i.history = s.history,
|
|
273
|
+
const s = o, e = (i, a) => {
|
|
274
|
+
i.timestamps = s.timestamps, i.history = s.history, a(), i.timestamps = [], i.history = !1;
|
|
259
275
|
}, t = (n = class extends s {
|
|
260
|
-
initialize(i,
|
|
261
|
-
e(this._proxy.static(), () => super.initialize(i,
|
|
276
|
+
initialize(i, a) {
|
|
277
|
+
e(this._proxy.static(), () => super.initialize(i, a));
|
|
262
278
|
}
|
|
263
279
|
initializeRelations() {
|
|
264
280
|
super.initializeRelations();
|
|
265
281
|
for (const i of Object.values(this._relations))
|
|
266
|
-
i
|
|
282
|
+
i.relatedClass = L(i.relatedClass);
|
|
267
283
|
}
|
|
268
284
|
fixMalformedAttributes() {
|
|
269
285
|
e(this.static(), () => super.fixMalformedAttributes());
|
|
270
286
|
}
|
|
271
|
-
},
|
|
272
|
-
return
|
|
287
|
+
}, M(n, "timestamps", !1), M(n, "history", !1), n);
|
|
288
|
+
return s.on("schema-updated", async (i) => {
|
|
273
289
|
await t.updateSchema({
|
|
274
290
|
...i,
|
|
275
291
|
timestamps: !1,
|
|
276
292
|
history: !1
|
|
277
293
|
});
|
|
278
|
-
}),
|
|
294
|
+
}), o.ensureBooted(), jt({ [`Remote${o.modelName}`]: t }), Y.service("$cloud") && g.getEngine() && t.setEngine(g.requireEngine()), Fe.set(s, t), ve.set(t, s), t;
|
|
279
295
|
}
|
|
280
|
-
function
|
|
281
|
-
return
|
|
296
|
+
function cn(o) {
|
|
297
|
+
return ve.get(o) ?? We(`Couldn't find local class for ${o.modelName}`);
|
|
282
298
|
}
|
|
283
|
-
class
|
|
299
|
+
class dn extends be {
|
|
284
300
|
constructor() {
|
|
285
301
|
super(...arguments);
|
|
286
|
-
|
|
287
|
-
|
|
302
|
+
M(this, "urlMigrations", []);
|
|
303
|
+
M(this, "collectionMigrations", []);
|
|
288
304
|
}
|
|
289
305
|
migrateUrl(e, t, n) {
|
|
290
306
|
this.urlMigrations.push({
|
|
@@ -301,18 +317,23 @@ class nn extends ye {
|
|
|
301
317
|
});
|
|
302
318
|
}
|
|
303
319
|
async run() {
|
|
304
|
-
const e =
|
|
305
|
-
for (const
|
|
306
|
-
const
|
|
307
|
-
for (const [l,
|
|
308
|
-
const
|
|
309
|
-
await e.create(
|
|
320
|
+
const e = je(), t = await e.getCollections(), n = /* @__PURE__ */ new Set();
|
|
321
|
+
for (const i of t) {
|
|
322
|
+
const a = await e.readMany(i);
|
|
323
|
+
for (const [l, r] of Object.entries(a)) {
|
|
324
|
+
const c = this.replaceUrl(l);
|
|
325
|
+
await e.create(O(c), this.replaceDocumentUrls(r), c), await e.delete(i, l);
|
|
310
326
|
}
|
|
311
327
|
}
|
|
312
|
-
for (const { modelClass:
|
|
313
|
-
|
|
314
|
-
for (const { modelClass:
|
|
315
|
-
|
|
328
|
+
for (const { modelClass: i, remote: a } of this.urlMigrations)
|
|
329
|
+
ie(i, O(a), { refresh: !1 });
|
|
330
|
+
for (const { modelClass: i, local: a, remote: l } of this.collectionMigrations) {
|
|
331
|
+
const r = Object.assign({}, b.collections), c = (b.collections[i.modelName] ?? []).filter(
|
|
332
|
+
(d) => !a.startsWith(d)
|
|
333
|
+
);
|
|
334
|
+
_t(i, a), ie(i, l, { refresh: !1 }), b.collections = r, t.filter((d) => a.startsWith(d)).forEach((d) => n.add(d)), c.length > 0 ? r[i.modelName] = c : delete r[i.modelName];
|
|
335
|
+
}
|
|
336
|
+
await e.dropCollections(Array.from(n));
|
|
316
337
|
}
|
|
317
338
|
replaceDocumentUrls(e) {
|
|
318
339
|
for (const [t, n] of Object.entries(e)) {
|
|
@@ -334,137 +355,131 @@ class nn extends ye {
|
|
|
334
355
|
return e;
|
|
335
356
|
}
|
|
336
357
|
}
|
|
337
|
-
function
|
|
358
|
+
function un(o) {
|
|
338
359
|
const s = {};
|
|
339
360
|
return async () => ("value" in s || (s.value = await o()), s.value);
|
|
340
361
|
}
|
|
341
|
-
class
|
|
362
|
+
class Ge {
|
|
342
363
|
async loadContainedModels(s, e = {}) {
|
|
343
|
-
if (
|
|
344
|
-
const
|
|
345
|
-
for (const
|
|
346
|
-
const
|
|
347
|
-
|
|
364
|
+
if (rn(s)) {
|
|
365
|
+
const d = [];
|
|
366
|
+
for (const y of T(s.static())) {
|
|
367
|
+
const p = await s.loadRelationIfUnloaded(y) ?? [];
|
|
368
|
+
d.push(...Ct(p));
|
|
348
369
|
}
|
|
349
|
-
return
|
|
370
|
+
return d;
|
|
350
371
|
}
|
|
351
|
-
const t = {}, n = [], i =
|
|
352
|
-
documentUrl:
|
|
372
|
+
const t = {}, n = [], i = A(s.documents, "url"), a = vt(s.resourceUrls, 10), l = a.flat().map((d) => ({
|
|
373
|
+
documentUrl: d,
|
|
353
374
|
completed: !1
|
|
354
|
-
})), r =
|
|
355
|
-
e.status && (e.status.children =
|
|
356
|
-
for (const
|
|
375
|
+
})), r = A(l, "documentUrl");
|
|
376
|
+
e.status && (e.status.children = l);
|
|
377
|
+
for (const d of a)
|
|
357
378
|
await Promise.all(
|
|
358
|
-
|
|
359
|
-
var
|
|
360
|
-
const { children:
|
|
379
|
+
d.map(async (y) => {
|
|
380
|
+
var Se;
|
|
381
|
+
const { children: p, tombstones: P } = await this.loadDocumentChildren(
|
|
361
382
|
s,
|
|
362
|
-
|
|
383
|
+
y,
|
|
363
384
|
i,
|
|
364
385
|
e.onDocumentError,
|
|
365
386
|
e.onDocumentRead
|
|
366
387
|
);
|
|
367
|
-
n.push(...
|
|
368
|
-
for (const [
|
|
369
|
-
(t[
|
|
370
|
-
|
|
388
|
+
n.push(...P);
|
|
389
|
+
for (const [le, ot] of Object.entries(p))
|
|
390
|
+
(t[le] ?? (t[le] = [])).push(...ot);
|
|
391
|
+
y.endsWith("/") || (U(r.get(y)).completed = !0, await ((Se = e.onDocumentLoaded) == null ? void 0 : Se.call(e)));
|
|
371
392
|
})
|
|
372
393
|
);
|
|
373
|
-
for (const [
|
|
374
|
-
s.setRelationModels(
|
|
394
|
+
for (const [d, y] of Object.entries(t))
|
|
395
|
+
s.setRelationModels(d, y);
|
|
375
396
|
const c = e.ignoreTombstones ? Object.values(t).flat() : Object.values(t).flat().concat(n);
|
|
376
|
-
return e.status && (e.status.children = c.map((
|
|
377
|
-
}
|
|
378
|
-
async
|
|
379
|
-
var a;
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
async loadDocumentChildrenFromLocal(s, e) {
|
|
387
|
-
var n, i;
|
|
388
|
-
const t = {};
|
|
389
|
-
for (const l of k(s.static())) {
|
|
390
|
-
const a = s.requireRelation(l);
|
|
391
|
-
if (a.loaded) {
|
|
392
|
-
t[l] = a.getLoadedModels();
|
|
397
|
+
return e.status && (e.status.children = c.map((d) => U(r.get(d.requireDocumentUrl())))), c;
|
|
398
|
+
}
|
|
399
|
+
async loadContainedDocuments(s, e = {}) {
|
|
400
|
+
var i, a, l;
|
|
401
|
+
if (!K(s))
|
|
402
|
+
throw Error("Cannot get contained models from local model");
|
|
403
|
+
const t = {}, n = s.requireEngine();
|
|
404
|
+
for (let r = 0; r < s.resourceUrls.length; r++) {
|
|
405
|
+
const c = s.resourceUrls[r];
|
|
406
|
+
if (!c || c.endsWith("/"))
|
|
393
407
|
continue;
|
|
394
|
-
|
|
395
|
-
const
|
|
396
|
-
|
|
408
|
+
t[c] = await n.readOne(s.url, c);
|
|
409
|
+
const d = (a = (i = e.status) == null ? void 0 : i.children) == null ? void 0 : a[r];
|
|
410
|
+
d && (d.completed = !0), await ((l = e.onDocumentLoaded) == null ? void 0 : l.call(e));
|
|
397
411
|
}
|
|
398
412
|
return t;
|
|
399
413
|
}
|
|
414
|
+
async loadDocumentChildren(s, e, t, n, i) {
|
|
415
|
+
return this.loadDocumentChildrenFromRemote(s, e, n, i);
|
|
416
|
+
}
|
|
400
417
|
async loadDocumentChildrenFromRemote(s, e, t, n) {
|
|
401
|
-
const i = {},
|
|
418
|
+
const i = {}, a = [], l = un(async () => {
|
|
402
419
|
try {
|
|
403
|
-
const r = s.documents.find((
|
|
420
|
+
const r = s.documents.find((y) => y.url === e), c = await s.requireEngine().readOne(O(e), e), d = await x.createManyFromEngineDocuments({
|
|
404
421
|
[e]: c
|
|
405
422
|
});
|
|
406
|
-
return
|
|
423
|
+
return a.push(...d), r && (n == null || n(r)), c;
|
|
407
424
|
} catch (r) {
|
|
408
|
-
if (
|
|
425
|
+
if (z(r, Bt))
|
|
409
426
|
return null;
|
|
410
427
|
if (!t)
|
|
411
428
|
throw r;
|
|
412
429
|
return t(r), null;
|
|
413
430
|
}
|
|
414
431
|
});
|
|
415
|
-
for (const r of
|
|
432
|
+
for (const r of T(s.static())) {
|
|
416
433
|
const c = s.requireRelation(r);
|
|
417
434
|
if (c.loaded) {
|
|
418
435
|
i[r] = c.getLoadedModels();
|
|
419
436
|
continue;
|
|
420
437
|
}
|
|
421
|
-
const
|
|
422
|
-
if (
|
|
438
|
+
const d = await l();
|
|
439
|
+
if (d)
|
|
423
440
|
try {
|
|
424
|
-
const
|
|
425
|
-
[e]:
|
|
441
|
+
const y = await c.relatedClass.createManyFromEngineDocuments({
|
|
442
|
+
[e]: d
|
|
426
443
|
});
|
|
427
|
-
i[r] =
|
|
428
|
-
} catch (
|
|
444
|
+
i[r] = y;
|
|
445
|
+
} catch (y) {
|
|
429
446
|
if (!t)
|
|
430
|
-
throw
|
|
431
|
-
t(
|
|
447
|
+
throw y;
|
|
448
|
+
t(y);
|
|
432
449
|
}
|
|
433
450
|
}
|
|
434
|
-
return { children: i, tombstones:
|
|
451
|
+
return { children: i, tombstones: a };
|
|
435
452
|
}
|
|
436
453
|
}
|
|
437
|
-
const
|
|
438
|
-
class
|
|
454
|
+
const V = /* @__PURE__ */ new WeakMap();
|
|
455
|
+
class Xe {
|
|
439
456
|
async loadTypeIndex(s = {}) {
|
|
440
|
-
const e =
|
|
441
|
-
return (s.fresh || !
|
|
457
|
+
const e = b.requireUser();
|
|
458
|
+
return (s.fresh || !V.has(e)) && V.set(e, await b.findPrivateTypeIndex({ fresh: s.fresh })), s.create && !V.get(e) && V.set(e, await b.findOrCreatePrivateTypeIndex()), V.get(e) ?? null;
|
|
442
459
|
}
|
|
443
460
|
}
|
|
444
|
-
class
|
|
461
|
+
class et {
|
|
445
462
|
async indexLocalModels(s) {
|
|
446
463
|
for (const e of s)
|
|
447
464
|
await this.addLocalModel(e);
|
|
448
465
|
}
|
|
449
466
|
async addLocalModel(s) {
|
|
450
467
|
if (!this.localModels.hasKey(s.url)) {
|
|
451
|
-
this.localModels.add(s);
|
|
452
|
-
for (const e of
|
|
453
|
-
await s.loadRelationIfUnloaded(e);
|
|
454
|
-
for (const e of ne(s))
|
|
468
|
+
this.localModels.add(s), await pe(s);
|
|
469
|
+
for (const e of N(s))
|
|
455
470
|
await this.addLocalModel(e);
|
|
456
471
|
}
|
|
457
472
|
}
|
|
458
473
|
}
|
|
459
|
-
const
|
|
460
|
-
class
|
|
474
|
+
const hn = be;
|
|
475
|
+
class ae extends Ne(hn, [Ge, Xe, et]) {
|
|
461
476
|
constructor() {
|
|
462
477
|
super();
|
|
463
|
-
|
|
464
|
-
this.localModels =
|
|
478
|
+
M(this, "_models");
|
|
479
|
+
this.localModels = A([], "url");
|
|
465
480
|
}
|
|
466
481
|
static restore(e) {
|
|
467
|
-
return
|
|
482
|
+
return _e(new ae(), (t) => {
|
|
468
483
|
t.status = e;
|
|
469
484
|
});
|
|
470
485
|
}
|
|
@@ -473,11 +488,11 @@ class ie extends _e(on, [Ve, Fe, He]) {
|
|
|
473
488
|
}
|
|
474
489
|
set models(e) {
|
|
475
490
|
if (!e) {
|
|
476
|
-
delete this._models, this.localModels =
|
|
491
|
+
delete this._models, this.localModels = A([], "url");
|
|
477
492
|
return;
|
|
478
493
|
}
|
|
479
|
-
const t =
|
|
480
|
-
this._models = e, this.localModels =
|
|
494
|
+
const t = St(this.status.children ?? [], "modelUrl");
|
|
495
|
+
this._models = e, this.localModels = A([], "url"), this.status.children = e.map(
|
|
481
496
|
(n) => t[n.url] ?? {
|
|
482
497
|
modelUrl: n.url,
|
|
483
498
|
completed: !1
|
|
@@ -490,22 +505,22 @@ class ie extends _e(on, [Ve, Fe, He]) {
|
|
|
490
505
|
await this.indexLocalModels(this.models);
|
|
491
506
|
const e = this.status.children ?? [], t = await this.loadTypeIndex();
|
|
492
507
|
for (const n of e) {
|
|
493
|
-
const i = this.models.find(({ url:
|
|
508
|
+
const i = this.models.find(({ url: a }) => n.modelUrl === a);
|
|
494
509
|
!i || n.completed || (await this.migrateRegisteredModel(i, n, t), await this.updateProgress(() => n.completed = !0));
|
|
495
510
|
}
|
|
496
|
-
for (const [n, i] of
|
|
511
|
+
for (const [n, i] of tn())
|
|
497
512
|
await n.updateSchema(i);
|
|
498
|
-
|
|
513
|
+
nn();
|
|
499
514
|
}
|
|
500
515
|
async migrateRegisteredModel(e, t, n) {
|
|
501
|
-
if (await this.migrate(e, t), !
|
|
516
|
+
if (await this.migrate(e, t), !I(e))
|
|
502
517
|
return;
|
|
503
|
-
const i =
|
|
504
|
-
!n || !
|
|
518
|
+
const i = ge(e.static()), a = n == null ? void 0 : n.registrations.find(({ instanceContainer: l }) => l === e.url);
|
|
519
|
+
!n || !a || i.length === 0 || (a.setAttribute(
|
|
505
520
|
"forClass",
|
|
506
|
-
i.map((
|
|
521
|
+
i.map((l) => {
|
|
507
522
|
var r;
|
|
508
|
-
return ((r = ze(
|
|
523
|
+
return ((r = ze(l)) == null ? void 0 : r.rdfsClasses) ?? l.rdfsClass;
|
|
509
524
|
}).flat()
|
|
510
525
|
), await n.save());
|
|
511
526
|
}
|
|
@@ -514,16 +529,16 @@ class ie extends _e(on, [Ve, Fe, He]) {
|
|
|
514
529
|
const n = ze(e.static());
|
|
515
530
|
if (!n)
|
|
516
531
|
return;
|
|
517
|
-
const i = await
|
|
532
|
+
const i = await L(e.static()).find(e.url), a = await (i == null ? void 0 : i.migrateSchema(n));
|
|
518
533
|
await e.migrateSchema(n, {
|
|
519
|
-
mintOperationUrl: (
|
|
534
|
+
mintOperationUrl: (l) => {
|
|
520
535
|
var r, c;
|
|
521
|
-
return (c = (r =
|
|
536
|
+
return (c = (r = a == null ? void 0 : a.operations) == null ? void 0 : r.find((d) => !z(l, oe) || !z(d, oe) ? !1 : l.property === d.property && l.date.getTime() === d.date.getTime())) == null ? void 0 : c.url;
|
|
522
537
|
}
|
|
523
538
|
});
|
|
524
539
|
}
|
|
525
540
|
async migrateChildren(e, t) {
|
|
526
|
-
if (!
|
|
541
|
+
if (!I(e))
|
|
527
542
|
return;
|
|
528
543
|
const n = await this.loadContainedModels(e, { ignoreTombstones: !0 });
|
|
529
544
|
t.children ?? (t.children = n.map((i) => ({
|
|
@@ -531,39 +546,39 @@ class ie extends _e(on, [Ve, Fe, He]) {
|
|
|
531
546
|
completed: !1
|
|
532
547
|
})));
|
|
533
548
|
for (const i of t.children) {
|
|
534
|
-
const
|
|
535
|
-
!
|
|
549
|
+
const a = n.find(({ url: l }) => i.modelUrl === l);
|
|
550
|
+
!a || i.completed || (await this.migrate(a, i), await this.updateProgress(() => i.completed = !0));
|
|
536
551
|
}
|
|
537
552
|
}
|
|
538
553
|
}
|
|
539
|
-
const
|
|
540
|
-
function
|
|
554
|
+
const F = U(() => Y.service("$cloud")), fn = be;
|
|
555
|
+
function mn(o) {
|
|
541
556
|
return !!o && "root" in o;
|
|
542
557
|
}
|
|
543
|
-
class
|
|
558
|
+
class gn extends Ne(fn, [Ge, Xe, et]) {
|
|
544
559
|
constructor(e) {
|
|
545
560
|
super();
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
this.documentsWithErrors = /* @__PURE__ */ new Set(), this.models = e, this.rootLocalModels = [], this.localModels =
|
|
561
|
+
M(this, "documentsWithErrors");
|
|
562
|
+
M(this, "models");
|
|
563
|
+
M(this, "dirtyRemoteModels");
|
|
564
|
+
M(this, "rootLocalModels");
|
|
565
|
+
M(this, "tombstones");
|
|
566
|
+
M(this, "syncedModelUrls");
|
|
567
|
+
M(this, "documentsModifiedAt");
|
|
568
|
+
M(this, "screenLock", null);
|
|
569
|
+
M(this, "localModels");
|
|
570
|
+
this.documentsWithErrors = /* @__PURE__ */ new Set(), this.models = e, this.rootLocalModels = [], this.localModels = A([], "url"), this.tombstones = A([], "resourceUrl"), this.syncedModelUrls = /* @__PURE__ */ new Set(), this.documentsModifiedAt = {};
|
|
556
571
|
}
|
|
557
572
|
async run() {
|
|
558
|
-
const e =
|
|
559
|
-
const r = (
|
|
573
|
+
const e = b.requireAuthenticator().engine, t = (i, { headers: a }, l) => {
|
|
574
|
+
const r = (a == null ? void 0 : a.get("last-modified")) ?? l;
|
|
560
575
|
!r || i.endsWith("/") || (this.documentsModifiedAt[i] = new Date(r));
|
|
561
576
|
}, n = e.listeners.add({
|
|
562
|
-
onDocumentRead: (i,
|
|
563
|
-
onDocumentUpdated: (i,
|
|
577
|
+
onDocumentRead: (i, a) => t(i, a),
|
|
578
|
+
onDocumentUpdated: (i, a) => t(i, a, /* @__PURE__ */ new Date())
|
|
564
579
|
});
|
|
565
580
|
try {
|
|
566
|
-
this.lockScreen(), this.rootLocalModels = this.models ??
|
|
581
|
+
this.lockScreen(), this.rootLocalModels = this.models ?? Me(), e.setConfig({ cachesDocuments: !0, persistentCache: F.getDocumentsCache() }), await this.indexLocalModels(this.rootLocalModels), await this.pullChanges(), await this.pushChanges(), e.clearCache(), e.setConfig({ cachesDocuments: !1, persistentCache: void 0 });
|
|
567
582
|
} finally {
|
|
568
583
|
this.releaseScreen(), n();
|
|
569
584
|
}
|
|
@@ -573,10 +588,10 @@ class cn extends _e(an, [Ve, Fe, He]) {
|
|
|
573
588
|
if (e.wakeLock)
|
|
574
589
|
try {
|
|
575
590
|
this.screenLock = e.wakeLock.request("screen").catch((t) => {
|
|
576
|
-
|
|
591
|
+
ne.reportDevelopmentError(t, "Could not request screen wake lock");
|
|
577
592
|
});
|
|
578
593
|
} catch (t) {
|
|
579
|
-
|
|
594
|
+
ne.reportDevelopmentError(t, "Could not request screen wake lock");
|
|
580
595
|
}
|
|
581
596
|
}
|
|
582
597
|
releaseScreen() {
|
|
@@ -590,28 +605,29 @@ class cn extends _e(an, [Ve, Fe, He]) {
|
|
|
590
605
|
};
|
|
591
606
|
}
|
|
592
607
|
calculateCurrentProgress(e) {
|
|
593
|
-
return e ?? (e = this.status),
|
|
608
|
+
return e ?? (e = this.status), mn(e) ? $t(
|
|
594
609
|
this.calculateCurrentProgress(e.children[0]) * 0.9 + this.calculateCurrentProgress(e.children[1]) * 0.1,
|
|
595
610
|
2
|
|
596
611
|
) : super.calculateCurrentProgress(e);
|
|
597
612
|
}
|
|
598
613
|
async pullChanges() {
|
|
599
|
-
const e = this.models ? await this.fetchRemoteModelsForLocal(this.models) : await this.fetchRemoteModels(), t =
|
|
614
|
+
const e = this.models ? await this.fetchRemoteModelsForLocal(this.models) : await this.fetchRemoteModels(), t = A(e, (n) => n instanceof x ? n.resourceUrl : n.url);
|
|
600
615
|
this.dirtyRemoteModels = await this.synchronizeModels(t), await this.updateProgress((n) => n.children[0].completed = !0);
|
|
601
616
|
}
|
|
602
617
|
async pushChanges() {
|
|
603
618
|
const e = this.dirtyRemoteModels ?? [], t = this.status.children[1].children = e.map(() => ({ completed: !1 }));
|
|
604
|
-
for (let
|
|
605
|
-
const
|
|
606
|
-
if (
|
|
607
|
-
|
|
619
|
+
for (let i = 0; i < e.length; i++) {
|
|
620
|
+
const a = e[i], l = t[i];
|
|
621
|
+
if (a.isSoftDeleted()) {
|
|
622
|
+
a.enableHistory(), a.enableTombstone(), await a.forceDelete(), await this.updateProgress(() => l.completed = !0);
|
|
608
623
|
return;
|
|
609
624
|
}
|
|
610
|
-
await this.
|
|
625
|
+
await this.saveModelAndRelated(a, l), await this.updateTypeRegistrations(a), await this.updateProgress(() => l.completed = !0);
|
|
611
626
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
627
|
+
const n = F.getDocumentsCache();
|
|
628
|
+
for (const [i, a] of Object.entries(this.documentsModifiedAt))
|
|
629
|
+
await n.remember(O(i), i, a);
|
|
630
|
+
we(this.syncedModelUrls, this.documentsWithErrors), await this.updateProgress((i) => i.children[1].completed = !0);
|
|
615
631
|
}
|
|
616
632
|
async fetchRemoteModels() {
|
|
617
633
|
const e = this.status.children[0], t = await this.loadTypeIndex({ fresh: !0 });
|
|
@@ -619,90 +635,127 @@ class cn extends _e(an, [Ve, Fe, He]) {
|
|
|
619
635
|
return [];
|
|
620
636
|
const n = [], i = this.getTypeRegistrations(t);
|
|
621
637
|
e.children = i.map(() => ({ completed: !1 }));
|
|
622
|
-
for (let
|
|
638
|
+
for (let a = 0; a < i.length; a++)
|
|
623
639
|
await this.ignoringDocumentErrors(async () => {
|
|
624
|
-
var
|
|
625
|
-
const { registration:
|
|
626
|
-
if (
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
)
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
});
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
await me(r.modelClass, a.instanceContainer), n.push(...await c.from(a.instanceContainer).all()), await this.updateProgress(() => {
|
|
640
|
-
var p;
|
|
641
|
-
return A((p = e.children) == null ? void 0 : p[l]).completed = !0;
|
|
642
|
-
});
|
|
640
|
+
var p;
|
|
641
|
+
const l = U((p = e.children) == null ? void 0 : p[a]), { registration: r, registeredModel: c } = U(i[a]), d = L(c.modelClass);
|
|
642
|
+
if (!r.instanceContainer)
|
|
643
|
+
return;
|
|
644
|
+
if (j(d)) {
|
|
645
|
+
await ye(
|
|
646
|
+
c.modelClass,
|
|
647
|
+
O(r.instanceContainer)
|
|
648
|
+
);
|
|
649
|
+
const P = await d.find(r.instanceContainer);
|
|
650
|
+
P && (await this.loadChildren(P, l), n.push(P)), await this.updateProgress(() => l.completed = !0);
|
|
651
|
+
return;
|
|
643
652
|
}
|
|
653
|
+
const y = await this.fetchRemoteModelsFromContainer(
|
|
654
|
+
l,
|
|
655
|
+
c.modelClass,
|
|
656
|
+
d,
|
|
657
|
+
r.instanceContainer
|
|
658
|
+
);
|
|
659
|
+
n.push(...y), await this.updateProgress(() => l.completed = !0);
|
|
644
660
|
});
|
|
661
|
+
for (const a of n)
|
|
662
|
+
await pe(a, (l) => this.handleDocumentError(l));
|
|
645
663
|
return Ie(this.rootLocalModels, n, this.documentsWithErrors);
|
|
646
664
|
}
|
|
665
|
+
async fetchRemoteModelsFromContainer(e, t, n, i) {
|
|
666
|
+
var c;
|
|
667
|
+
const a = await L(Q).find(i);
|
|
668
|
+
if (!a)
|
|
669
|
+
return [];
|
|
670
|
+
e.children = a.resourceUrls.map(() => ({ completed: !1 }));
|
|
671
|
+
const l = await this.loadContainedDocuments(a, {
|
|
672
|
+
status: e,
|
|
673
|
+
onDocumentError: (d) => this.handleDocumentError(d),
|
|
674
|
+
onDocumentRead: (d) => {
|
|
675
|
+
d.url.endsWith("/") || !d.updatedAt || d.url in this.documentsModifiedAt || (this.documentsModifiedAt[d.url] = d.updatedAt);
|
|
676
|
+
},
|
|
677
|
+
onDocumentLoaded: async () => {
|
|
678
|
+
this.assertNotCancelled(), await this.updateProgress();
|
|
679
|
+
}
|
|
680
|
+
}), r = await n.createManyFromEngineDocuments(l);
|
|
681
|
+
r.length > 0 && await ye(t, i);
|
|
682
|
+
for (let d = 0; d < a.resourceUrls.length; d++) {
|
|
683
|
+
const y = a.resourceUrls[d];
|
|
684
|
+
if (!(y != null && y.endsWith("/")))
|
|
685
|
+
continue;
|
|
686
|
+
const p = await this.fetchRemoteModelsFromContainer(
|
|
687
|
+
U((c = e.children) == null ? void 0 : c[d]),
|
|
688
|
+
t,
|
|
689
|
+
n,
|
|
690
|
+
y
|
|
691
|
+
);
|
|
692
|
+
r.push(...p), await this.updateProgress(() => e.completed = !0);
|
|
693
|
+
}
|
|
694
|
+
return r;
|
|
695
|
+
}
|
|
647
696
|
async fetchRemoteModelsForLocal(e) {
|
|
648
697
|
const t = [], n = this.status.children[0].children = e.map(() => ({ completed: !1 }));
|
|
649
698
|
for (let i = 0; i < e.length; i++)
|
|
650
699
|
await this.ignoringDocumentErrors(async () => {
|
|
651
|
-
const
|
|
700
|
+
const a = e[i], l = n[i], r = await L(a.static()).find(a.url);
|
|
652
701
|
if (!r) {
|
|
653
|
-
await this.updateProgress(() =>
|
|
702
|
+
await this.updateProgress(() => l.completed = !0);
|
|
654
703
|
return;
|
|
655
704
|
}
|
|
656
|
-
|
|
705
|
+
I(r) && await this.loadChildren(r, l), t.push(r), await this.updateProgress(() => l.completed = !0);
|
|
657
706
|
});
|
|
707
|
+
for (const i of t)
|
|
708
|
+
await pe(i, (a) => this.handleDocumentError(a));
|
|
658
709
|
return Ie(e, t, this.documentsWithErrors);
|
|
659
710
|
}
|
|
660
711
|
getTypeRegistrations(e) {
|
|
661
|
-
const t = /* @__PURE__ */ new Set(), n = [...
|
|
662
|
-
const r =
|
|
712
|
+
const t = /* @__PURE__ */ new Set(), n = [...F.registeredModels].map(({ modelClass: l }) => {
|
|
713
|
+
const r = j(l) ? ge(l) : [];
|
|
663
714
|
return {
|
|
664
|
-
modelClass:
|
|
665
|
-
rdfsClasses: r.length > 0 ? r.map((c) => c.rdfsClasses).flat() :
|
|
715
|
+
modelClass: l,
|
|
716
|
+
rdfsClasses: r.length > 0 ? r.map((c) => c.rdfsClasses).flat() : l.rdfsClasses
|
|
666
717
|
};
|
|
667
|
-
}), i = e.registrations.map((
|
|
718
|
+
}), i = e.registrations.map((l) => {
|
|
668
719
|
const r = n.find(
|
|
669
|
-
({ rdfsClasses: c }) => !!
|
|
720
|
+
({ rdfsClasses: c }) => !!l.instanceContainer && c.some((d) => l.forClass.includes(d))
|
|
670
721
|
);
|
|
671
|
-
return !r || !
|
|
672
|
-
}).filter((
|
|
673
|
-
return i.filter(({ registration:
|
|
722
|
+
return !r || !l.instanceContainer || t.has(l.instanceContainer) ? null : (t.add(l.instanceContainer), { registration: l, registeredModel: r });
|
|
723
|
+
}).filter((l) => !!l), a = i.map(({ registration: l }) => l.instanceContainer);
|
|
724
|
+
return i.filter(({ registration: l }) => !a.some(
|
|
674
725
|
(r) => {
|
|
675
726
|
var c;
|
|
676
|
-
return r && r !==
|
|
727
|
+
return r && r !== l.instanceContainer && ((c = l.instanceContainer) == null ? void 0 : c.startsWith(r));
|
|
677
728
|
}
|
|
678
729
|
));
|
|
679
730
|
}
|
|
680
731
|
async updateTypeRegistrations(e) {
|
|
681
|
-
if (!
|
|
732
|
+
if (!on(e))
|
|
682
733
|
return;
|
|
683
|
-
const t =
|
|
684
|
-
if (
|
|
734
|
+
const t = I(e) ? e : Xt(e, this.localModels), n = I(e) ? ge(e.static()) : [e.static()];
|
|
735
|
+
if (n.length === 0)
|
|
685
736
|
return;
|
|
686
|
-
const
|
|
687
|
-
|
|
737
|
+
const i = await this.loadTypeIndex({ create: !0 });
|
|
738
|
+
i.registrations.some(
|
|
739
|
+
(a) => a.instanceContainer && e.url.startsWith(a.instanceContainer)
|
|
740
|
+
) || await t.register(i, n);
|
|
688
741
|
}
|
|
689
742
|
async loadChildren(e, t) {
|
|
690
|
-
var i,
|
|
691
|
-
if (this.assertNotCancelled(), !
|
|
743
|
+
var i, a;
|
|
744
|
+
if (this.assertNotCancelled(), !I(e))
|
|
692
745
|
return;
|
|
693
746
|
const n = await this.loadContainedModels(e, {
|
|
694
747
|
status: t,
|
|
695
|
-
onDocumentError: (
|
|
696
|
-
onDocumentRead: (
|
|
697
|
-
|
|
748
|
+
onDocumentError: (l) => this.handleDocumentError(l),
|
|
749
|
+
onDocumentRead: (l) => {
|
|
750
|
+
l.url.endsWith("/") || !l.updatedAt || l.url in this.documentsModifiedAt || (this.documentsModifiedAt[l.url] = l.updatedAt);
|
|
698
751
|
},
|
|
699
752
|
onDocumentLoaded: async () => {
|
|
700
753
|
this.assertNotCancelled(), await this.updateProgress();
|
|
701
754
|
}
|
|
702
755
|
});
|
|
703
|
-
for (let
|
|
704
|
-
const r = n[
|
|
705
|
-
if (r instanceof
|
|
756
|
+
for (let l = 0; l < n.length; l++) {
|
|
757
|
+
const r = n[l];
|
|
758
|
+
if (r instanceof x) {
|
|
706
759
|
this.tombstones.add(r);
|
|
707
760
|
continue;
|
|
708
761
|
}
|
|
@@ -710,9 +763,9 @@ class cn extends _e(an, [Ve, Fe, He]) {
|
|
|
710
763
|
await this.deleteChild(e, r);
|
|
711
764
|
continue;
|
|
712
765
|
}
|
|
713
|
-
await this.loadChildren(r, (i = t == null ? void 0 : t.children) == null ? void 0 : i[
|
|
766
|
+
await this.loadChildren(r, (i = t == null ? void 0 : t.children) == null ? void 0 : i[l]), (a = t == null ? void 0 : t.children) != null && a[l] && await this.updateProgress(() => {
|
|
714
767
|
var c;
|
|
715
|
-
return
|
|
768
|
+
return U((c = t.children) == null ? void 0 : c[l]).completed = !0;
|
|
716
769
|
});
|
|
717
770
|
}
|
|
718
771
|
}
|
|
@@ -721,7 +774,7 @@ class cn extends _e(an, [Ve, Fe, He]) {
|
|
|
721
774
|
const i = e.requireRelation(n);
|
|
722
775
|
if (i.related) {
|
|
723
776
|
if (Array.isArray(i.related)) {
|
|
724
|
-
i.related = i.related.filter((
|
|
777
|
+
i.related = i.related.filter((a) => a !== t);
|
|
725
778
|
continue;
|
|
726
779
|
}
|
|
727
780
|
if (i.related === t) {
|
|
@@ -732,94 +785,109 @@ class cn extends _e(an, [Ve, Fe, He]) {
|
|
|
732
785
|
}
|
|
733
786
|
await t.forceDelete();
|
|
734
787
|
}
|
|
735
|
-
async
|
|
736
|
-
if (this.assertNotCancelled(),
|
|
788
|
+
async saveModelAndRelated(e, t, n) {
|
|
789
|
+
if (this.assertNotCancelled(), n ?? (n = /* @__PURE__ */ new Set()), n.has(e))
|
|
790
|
+
return;
|
|
791
|
+
if (n.add(e), K(e) && e.isSoftDeleted()) {
|
|
737
792
|
e.enableHistory(), e.enableTombstone(), await e.forceDelete();
|
|
738
793
|
return;
|
|
739
794
|
}
|
|
740
|
-
if (this.documentsWithErrors.has(e.requireDocumentUrl()))
|
|
741
|
-
return;
|
|
742
|
-
const n = e.isDirty();
|
|
743
|
-
if (await e.save(), (n || Q(e)) && this.syncedModelUrls.add(e.url), !U(e)) {
|
|
744
|
-
if (Q(e)) {
|
|
745
|
-
const a = e.requireDocumentUrl(), r = this.documentsModifiedAt[a];
|
|
746
|
-
r && (await P.remember(a, r), delete this.documentsModifiedAt[a]);
|
|
747
|
-
}
|
|
795
|
+
if (e.getDocumentUrl() && this.documentsWithErrors.has(e.requireDocumentUrl()))
|
|
748
796
|
return;
|
|
797
|
+
const i = e.isDirty();
|
|
798
|
+
if (await e.save(), (i || K(e)) && this.syncedModelUrls.add(e.url), K(e)) {
|
|
799
|
+
const r = e.requireDocumentUrl(), c = this.documentsModifiedAt[r];
|
|
800
|
+
c && (await F.getDocumentsCache().remember(
|
|
801
|
+
O(r),
|
|
802
|
+
r,
|
|
803
|
+
c
|
|
804
|
+
), delete this.documentsModifiedAt[r]);
|
|
749
805
|
}
|
|
750
|
-
const
|
|
806
|
+
const a = Dt(N(e), e), l = t ? a.map(() => ({ completed: !1 })) : [];
|
|
751
807
|
t && (t.children = l);
|
|
752
|
-
for (let
|
|
753
|
-
const
|
|
754
|
-
await this.
|
|
808
|
+
for (let r = 0; r < a.length; r++) {
|
|
809
|
+
const c = a[r], d = l[r];
|
|
810
|
+
await this.saveModelAndRelated(c, d, n), d && await this.updateProgress(() => d.completed = !0);
|
|
755
811
|
}
|
|
756
812
|
}
|
|
757
813
|
async synchronizeModels(e) {
|
|
758
814
|
const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
759
|
-
for (const
|
|
760
|
-
if (
|
|
761
|
-
const r = this.localModels.get(
|
|
815
|
+
for (const a of e.items()) {
|
|
816
|
+
if (a instanceof x) {
|
|
817
|
+
const r = this.localModels.get(a.resourceUrl);
|
|
762
818
|
r && (await r.forceDelete(), n.add(r));
|
|
763
819
|
continue;
|
|
764
820
|
}
|
|
765
|
-
const
|
|
766
|
-
|
|
821
|
+
const l = Qe(a, this.localModels);
|
|
822
|
+
l.exists() || this.syncedModelUrls.add(l.url), await this.loadChildren(l), await J.synchronize(l, a, {
|
|
823
|
+
constructors: H(l)
|
|
824
|
+
}), await this.reconcileInconsistencies(l, a), await this.saveModelAndRelated(l), await this.addLocalModel(l), this.rootLocalModels.includes(l) || this.rootLocalModels.push(l), t.add(l.url);
|
|
767
825
|
}
|
|
768
|
-
for (const
|
|
769
|
-
if (n.has(
|
|
826
|
+
for (const a of this.rootLocalModels) {
|
|
827
|
+
if (n.has(a) || t.has(a.url))
|
|
770
828
|
continue;
|
|
771
|
-
await this.loadChildren(
|
|
772
|
-
const
|
|
773
|
-
await J.synchronize(
|
|
829
|
+
await this.loadChildren(a);
|
|
830
|
+
const l = sn(a, e);
|
|
831
|
+
await J.synchronize(a, l, {
|
|
832
|
+
constructors: H(a)
|
|
833
|
+
}), e.add(l);
|
|
774
834
|
}
|
|
775
835
|
const i = [];
|
|
776
|
-
for (const
|
|
777
|
-
if (
|
|
778
|
-
i.push(
|
|
836
|
+
for (const a of e.getItems()) {
|
|
837
|
+
if (Ve(a)) {
|
|
838
|
+
i.push(a);
|
|
779
839
|
continue;
|
|
780
840
|
}
|
|
781
|
-
await this.rememberModelDocuments(
|
|
841
|
+
await this.rememberModelDocuments(a);
|
|
782
842
|
}
|
|
783
843
|
return i;
|
|
784
844
|
}
|
|
785
845
|
async reconcileInconsistencies(e, t, n) {
|
|
786
846
|
e.rebuildAttributesFromHistory(), e.setAttributes(t.getAttributes(!0)), n ?? (n = /* @__PURE__ */ new Set()), n.add(e);
|
|
787
|
-
for (const
|
|
847
|
+
for (const a of T(e.static()))
|
|
788
848
|
await this.synchronizeContainerDocuments(
|
|
789
|
-
e.requireRelation(
|
|
790
|
-
t.requireRelation(
|
|
849
|
+
e.requireRelation(a),
|
|
850
|
+
t.requireRelation(a)
|
|
791
851
|
);
|
|
792
|
-
const i =
|
|
793
|
-
for (const
|
|
794
|
-
n.has(
|
|
795
|
-
|
|
796
|
-
i.require(
|
|
852
|
+
const i = A(N(t), "url");
|
|
853
|
+
for (const a of N(e))
|
|
854
|
+
n.has(a) || !a.isRelationLoaded("operations") || !i.hasKey(a.url) || await this.reconcileInconsistencies(
|
|
855
|
+
a,
|
|
856
|
+
i.require(a.url),
|
|
797
857
|
n
|
|
798
858
|
);
|
|
799
|
-
e.isDirty() && await J.synchronize(e, t
|
|
859
|
+
e.isDirty() && await J.synchronize(e, t, {
|
|
860
|
+
constructors: H(e)
|
|
861
|
+
});
|
|
800
862
|
}
|
|
801
863
|
async synchronizeContainerDocuments(e, t) {
|
|
802
|
-
const n =
|
|
803
|
-
for (const r of l) {
|
|
804
|
-
const c = n.require(r), h = Ce(c);
|
|
805
|
-
t.addRelated(h), i.add(h);
|
|
806
|
-
}
|
|
864
|
+
const n = A(e.related ?? [], "url"), i = A(t.related ?? [], "url"), a = n.getKeys().filter((r) => !i.hasKey(r) && !i.hasKey(encodeURI(r))), l = i.getKeys().filter((r) => !n.hasKey(r) && !n.hasKey(encodeURI(r)));
|
|
807
865
|
for (const r of a) {
|
|
808
|
-
const c =
|
|
809
|
-
|
|
866
|
+
const c = n.require(r), d = Ke(c);
|
|
867
|
+
t.addRelated(d), i.add(d);
|
|
868
|
+
}
|
|
869
|
+
for (const r of l) {
|
|
870
|
+
const c = i.require(r), d = Ye(c);
|
|
871
|
+
e.addRelated(d), n.add(d), this.syncedModelUrls.add(d.url);
|
|
810
872
|
}
|
|
811
873
|
for (const r of n.items()) {
|
|
812
874
|
const c = i.require(r.url);
|
|
813
|
-
await J.synchronize(r, c
|
|
875
|
+
await J.synchronize(r, c, {
|
|
876
|
+
constructors: H(r)
|
|
877
|
+
}), await this.saveModelAndRelated(r);
|
|
814
878
|
}
|
|
815
879
|
}
|
|
816
880
|
async rememberModelDocuments(e) {
|
|
817
|
-
if (!
|
|
881
|
+
if (!I(e)) {
|
|
818
882
|
const n = e.requireDocumentUrl(), i = this.documentsModifiedAt[n];
|
|
819
|
-
i && (await
|
|
883
|
+
i && (await F.getDocumentsCache().remember(
|
|
884
|
+
O(n),
|
|
885
|
+
n,
|
|
886
|
+
i
|
|
887
|
+
), delete this.documentsModifiedAt[n]);
|
|
820
888
|
return;
|
|
821
889
|
}
|
|
822
|
-
const t =
|
|
890
|
+
const t = T(e.static()).map((n) => e.getRelationModels(n) ?? []).flat();
|
|
823
891
|
for (const n of t)
|
|
824
892
|
await this.rememberModelDocuments(n);
|
|
825
893
|
}
|
|
@@ -831,25 +899,26 @@ class cn extends _e(an, [Ve, Fe, He]) {
|
|
|
831
899
|
}
|
|
832
900
|
}
|
|
833
901
|
handleDocumentError(e) {
|
|
834
|
-
if (
|
|
902
|
+
if (z(e, Kt)) {
|
|
835
903
|
console.warn(e.message), e.documentUrl && this.documentsWithErrors.add(e.documentUrl);
|
|
836
904
|
return;
|
|
837
905
|
}
|
|
838
|
-
if (
|
|
906
|
+
if (z(e, Vt)) {
|
|
839
907
|
console.warn(e.message);
|
|
840
|
-
const t = e.attributes[
|
|
908
|
+
const t = e.attributes[Ft(e.modelName).primaryKey], n = t && qe(Rt(t));
|
|
841
909
|
n && this.documentsWithErrors.add(n);
|
|
842
910
|
return;
|
|
843
911
|
}
|
|
844
912
|
throw e;
|
|
845
913
|
}
|
|
846
914
|
}
|
|
847
|
-
const
|
|
915
|
+
const w = {
|
|
848
916
|
Disconnected: "disconnected",
|
|
917
|
+
Offline: "offline",
|
|
849
918
|
Online: "online",
|
|
850
919
|
Syncing: "syncing",
|
|
851
920
|
Migrating: "migrating"
|
|
852
|
-
},
|
|
921
|
+
}, tt = { manualSetup: !1 }, pn = at({
|
|
853
922
|
name: "cloud",
|
|
854
923
|
persist: [
|
|
855
924
|
"localModelUpdates",
|
|
@@ -871,12 +940,13 @@ const v = {
|
|
|
871
940
|
pollingEnabled: !0,
|
|
872
941
|
pollingMinutes: 10,
|
|
873
942
|
ready: !1,
|
|
943
|
+
manualSetup: tt.manualSetup,
|
|
874
944
|
registeredModels: [],
|
|
875
945
|
schemaMigrations: /* @__PURE__ */ new Map(),
|
|
876
946
|
setupDismissed: !1,
|
|
877
947
|
setupOngoing: !1,
|
|
878
948
|
startupSync: !0,
|
|
879
|
-
status:
|
|
949
|
+
status: w.Disconnected,
|
|
880
950
|
syncError: null,
|
|
881
951
|
syncJob: null
|
|
882
952
|
}),
|
|
@@ -885,7 +955,7 @@ const v = {
|
|
|
885
955
|
return $e(o, { migrationJob: (s = o.migrationJob) == null ? void 0 : s.serialize() });
|
|
886
956
|
},
|
|
887
957
|
restore: (o) => $e(o, {
|
|
888
|
-
migrationJob: o.migrationJob &&
|
|
958
|
+
migrationJob: o.migrationJob && ae.restore(o.migrationJob)
|
|
889
959
|
}),
|
|
890
960
|
watch: {
|
|
891
961
|
migrationJob(o) {
|
|
@@ -893,10 +963,11 @@ const v = {
|
|
|
893
963
|
}
|
|
894
964
|
},
|
|
895
965
|
computed: {
|
|
896
|
-
disconnected: ({ status: o }) => o ===
|
|
897
|
-
online: ({ status: o }) => o ===
|
|
898
|
-
|
|
899
|
-
|
|
966
|
+
disconnected: ({ status: o }) => o === w.Disconnected,
|
|
967
|
+
online: ({ status: o }) => o === w.Online,
|
|
968
|
+
offline: ({ status: o }) => o === w.Offline,
|
|
969
|
+
syncing: ({ status: o }) => o === w.Syncing,
|
|
970
|
+
migrating: ({ status: o }) => o === w.Migrating,
|
|
900
971
|
localChanges({ localModelUpdates: o }) {
|
|
901
972
|
return Object.values(o).reduce((s, e) => s + e, 0);
|
|
902
973
|
},
|
|
@@ -907,33 +978,34 @@ const v = {
|
|
|
907
978
|
return !!o;
|
|
908
979
|
},
|
|
909
980
|
migrationDisabledReason({ status: o, ready: s }) {
|
|
910
|
-
return
|
|
981
|
+
return b.isLoggedIn() ? s ? o === w.Syncing || o === w.Migrating ? v(
|
|
911
982
|
"cloud.migrationNotSyncing",
|
|
912
983
|
"Wait for syncing to finish before starting the migration"
|
|
913
|
-
) : this.online ? null :
|
|
984
|
+
) : this.online ? null : v(
|
|
914
985
|
"cloud.migrationNotOnline",
|
|
915
986
|
"You need to be online in order to start the migration"
|
|
916
|
-
) :
|
|
987
|
+
) : v(
|
|
917
988
|
"cloud.migrationNotReady",
|
|
918
989
|
"You need to backup your data before starting the migration"
|
|
919
|
-
) :
|
|
990
|
+
) : v(
|
|
920
991
|
"cloud.migrationNotLoggedIn",
|
|
921
992
|
"You need to reconnect before starting the migration"
|
|
922
993
|
);
|
|
923
994
|
}
|
|
924
995
|
}
|
|
925
996
|
});
|
|
926
|
-
class
|
|
997
|
+
class yn extends pn {
|
|
927
998
|
constructor() {
|
|
928
999
|
super(...arguments);
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
1000
|
+
M(this, "asyncLock", new kt());
|
|
1001
|
+
M(this, "engine", null);
|
|
1002
|
+
M(this, "pollingInterval", null);
|
|
1003
|
+
M(this, "documentsCache", null);
|
|
932
1004
|
}
|
|
933
1005
|
async whenReady(e) {
|
|
934
1006
|
return this.ready ? e() : new Promise((t) => {
|
|
935
1007
|
const n = () => t(e());
|
|
936
|
-
|
|
1008
|
+
R.once("cloud:ready", n);
|
|
937
1009
|
});
|
|
938
1010
|
}
|
|
939
1011
|
async setup(e) {
|
|
@@ -944,6 +1016,12 @@ class un extends dn {
|
|
|
944
1016
|
this.setupOngoing = !1;
|
|
945
1017
|
}
|
|
946
1018
|
}
|
|
1019
|
+
getEngine() {
|
|
1020
|
+
return this.engine;
|
|
1021
|
+
}
|
|
1022
|
+
requireEngine() {
|
|
1023
|
+
return this.engine ?? We("Could not get required Engine");
|
|
1024
|
+
}
|
|
947
1025
|
dismissSetup() {
|
|
948
1026
|
this.setupDismissed = !0;
|
|
949
1027
|
}
|
|
@@ -957,32 +1035,32 @@ class un extends dn {
|
|
|
957
1035
|
this.online && await this.sync(e);
|
|
958
1036
|
}
|
|
959
1037
|
async sync(e = {}) {
|
|
960
|
-
const t =
|
|
961
|
-
!
|
|
1038
|
+
const t = Lt(e) ? { models: e } : e instanceof J ? { model: e } : e;
|
|
1039
|
+
!b.isLoggedIn() || !this.ready || !this.online || await this.asyncLock.run(async () => {
|
|
962
1040
|
let n = t.model ? [t.model] : t.models;
|
|
963
1041
|
const i = Date.now();
|
|
964
|
-
this.syncError = null, this.status =
|
|
1042
|
+
this.syncError = null, this.status = w.Syncing, re.clear(n);
|
|
965
1043
|
try {
|
|
966
|
-
await
|
|
967
|
-
const
|
|
968
|
-
let
|
|
1044
|
+
await R.emit("cloud:sync-started", n), t.refreshUserProfile && await b.refreshUserProfile();
|
|
1045
|
+
const a = t.syncDirty ?? !0;
|
|
1046
|
+
let l = 0;
|
|
969
1047
|
do {
|
|
970
|
-
if (this.syncJob = new
|
|
1048
|
+
if (this.syncJob = new gn(n), this.syncJob.listeners.add(t), await ce(this.syncJob), this.syncJob.cancelled)
|
|
971
1049
|
return;
|
|
972
|
-
|
|
1050
|
+
l++, n = this.getDirtyLocalModels().filter(
|
|
973
1051
|
(r) => {
|
|
974
1052
|
var c;
|
|
975
1053
|
return !((c = this.syncJob) != null && c.documentsWithErrors.has(r.requireDocumentUrl()));
|
|
976
1054
|
}
|
|
977
1055
|
);
|
|
978
|
-
} while (
|
|
979
|
-
|
|
980
|
-
} catch (
|
|
981
|
-
if (
|
|
982
|
-
throw
|
|
983
|
-
this.syncJob = null, this.syncError =
|
|
1056
|
+
} while (a && n.length > 0 && l < 3);
|
|
1057
|
+
De("unit") || await se({ milliseconds: Math.max(500, 1e3 - (Date.now() - i)) }), this.syncJob = null;
|
|
1058
|
+
} catch (a) {
|
|
1059
|
+
if (De())
|
|
1060
|
+
throw a;
|
|
1061
|
+
this.syncJob = null, this.syncError = a, await ne.report(a, v("cloud.syncFailed", "Sync failed"));
|
|
984
1062
|
} finally {
|
|
985
|
-
this.status =
|
|
1063
|
+
this.status = w.Online, await R.emit("cloud:sync-completed", n);
|
|
986
1064
|
}
|
|
987
1065
|
});
|
|
988
1066
|
}
|
|
@@ -990,23 +1068,23 @@ class un extends dn {
|
|
|
990
1068
|
return this.schemaMigrations.size > 0;
|
|
991
1069
|
}
|
|
992
1070
|
async migrate(e) {
|
|
993
|
-
if (!this.online || !
|
|
1071
|
+
if (!this.online || !b.isLoggedIn() || !this.ready)
|
|
994
1072
|
throw new Error("Data cannot be migrated at the moment");
|
|
995
1073
|
this.shouldMigrate() && await this.asyncLock.run(async () => {
|
|
996
|
-
var
|
|
997
|
-
this.status =
|
|
998
|
-
const t = Date.now(), n = [], i = (
|
|
999
|
-
|
|
1074
|
+
var a;
|
|
1075
|
+
this.status = w.Migrating, this.migrationJob ?? (this.migrationJob = new ae());
|
|
1076
|
+
const t = Date.now(), n = [], i = (a = this.migrationJob).models ?? (a.models = Me());
|
|
1077
|
+
re.clear(i);
|
|
1000
1078
|
try {
|
|
1001
|
-
if (e && n.push(this.migrationJob.listeners.add(e)), await
|
|
1002
|
-
await
|
|
1079
|
+
if (e && n.push(this.migrationJob.listeners.add(e)), await R.emit("cloud:migration-started", i), await ce(this.migrationJob), this.migrationJob.cancelled) {
|
|
1080
|
+
await R.emit("cloud:migration-cancelled", i);
|
|
1003
1081
|
return;
|
|
1004
1082
|
}
|
|
1005
|
-
this.migrationJob = null, this.migrationDismissed = !1, this.migrationPostponed = !1, await
|
|
1006
|
-
} catch (
|
|
1007
|
-
await
|
|
1083
|
+
this.migrationJob = null, this.migrationDismissed = !1, this.migrationPostponed = !1, await se({ milliseconds: Math.max(0, 1e3 - (Date.now() - t)) }), await R.emit("cloud:migration-completed", i);
|
|
1084
|
+
} catch (l) {
|
|
1085
|
+
await ne.report(l, v("cloud.migrationFailed", "Migration failed"));
|
|
1008
1086
|
} finally {
|
|
1009
|
-
this.status =
|
|
1087
|
+
this.status = w.Online, n.forEach((l) => l == null ? void 0 : l());
|
|
1010
1088
|
}
|
|
1011
1089
|
});
|
|
1012
1090
|
}
|
|
@@ -1014,22 +1092,22 @@ class un extends dn {
|
|
|
1014
1092
|
if (this.registeredModels.find((i) => e === i.modelClass))
|
|
1015
1093
|
return;
|
|
1016
1094
|
const n = this.engine;
|
|
1017
|
-
n &&
|
|
1095
|
+
n && Ae(e).forEach((i) => L(i).setEngine(n)), this.whenReady(() => {
|
|
1018
1096
|
const [i] = this.modelCollections[e.modelName] ?? [];
|
|
1019
|
-
e.useSoftDeletes(!0), e.collection = i ??
|
|
1020
|
-
}), await
|
|
1097
|
+
e.useSoftDeletes(!0), e.collection = i ?? te(e, t.path);
|
|
1098
|
+
}), await Wt(e, {
|
|
1021
1099
|
created: (i) => this.ready && Ue(i),
|
|
1022
|
-
updated: (i) => this.ready &&
|
|
1023
|
-
deleted: (i) => this.ready &&
|
|
1024
|
-
}),
|
|
1025
|
-
const
|
|
1026
|
-
|
|
1100
|
+
updated: (i) => this.ready && Ee(i),
|
|
1101
|
+
deleted: (i) => this.ready && we(/* @__PURE__ */ new Set([i.url ?? i.getDeletedPrimaryKey()]))
|
|
1102
|
+
}), j(e) && T(e).forEach((i) => {
|
|
1103
|
+
const a = e.instance().requireRelation(i).relatedClass;
|
|
1104
|
+
a.on("created", (l) => this.ready && Ue(l)), a.on("updated", (l) => this.ready && Ee(l)), a.on(
|
|
1027
1105
|
"deleted",
|
|
1028
|
-
(
|
|
1106
|
+
(l) => this.ready && we(/* @__PURE__ */ new Set([l.url ?? l.getDeletedPrimaryKey()]))
|
|
1029
1107
|
);
|
|
1030
1108
|
}), this.registeredModels.push({ modelClass: e, path: t.path });
|
|
1031
1109
|
for (const i of this.modelCollections[e.modelName] ?? [])
|
|
1032
|
-
await
|
|
1110
|
+
await ie(e, i);
|
|
1033
1111
|
}
|
|
1034
1112
|
registerSchemaMigration(e, t) {
|
|
1035
1113
|
this.schemaMigrations.set(e, t);
|
|
@@ -1037,63 +1115,65 @@ class un extends dn {
|
|
|
1037
1115
|
requireRemoteCollection(e) {
|
|
1038
1116
|
for (const t of this.registeredModels)
|
|
1039
1117
|
if (e === t.modelClass)
|
|
1040
|
-
return
|
|
1118
|
+
return te(t.modelClass, t.path);
|
|
1041
1119
|
throw new Error(`Failed resolving remote collection for '${e.modelName}' model`);
|
|
1042
1120
|
}
|
|
1121
|
+
getDocumentsCache() {
|
|
1122
|
+
return this.documentsCache || (this.documentsCache = new Pt(lt(), je())), this.documentsCache;
|
|
1123
|
+
}
|
|
1043
1124
|
async boot() {
|
|
1044
|
-
await
|
|
1125
|
+
await b.booted, b.isLoggedIn() && this.login(b.authenticator), R.on("auth:login", ({ authenticator: e }) => this.login(e)), R.on("auth:logout", () => this.logout()), R.once("application-ready", () => this.onApplicationReady()), R.once("application-mounted", () => this.onApplicationMounted()), Nt(() => {
|
|
1045
1126
|
if (this.pollingInterval && clearInterval(this.pollingInterval), !this.pollingEnabled || this.migrationJob) {
|
|
1046
1127
|
this.pollingInterval = null;
|
|
1047
1128
|
return;
|
|
1048
1129
|
}
|
|
1049
1130
|
this.pollingInterval = setInterval(() => this.sync(), this.pollingMinutes * 60 * 1e3);
|
|
1050
|
-
}), await this.bustDocumentsCache(), await this.registerModels();
|
|
1131
|
+
}), this.watchNetworkStatus(), await this.bustDocumentsCache(), await this.registerModels();
|
|
1051
1132
|
}
|
|
1052
1133
|
getDirtyLocalModels() {
|
|
1053
1134
|
const e = Object.keys(this.localModelUpdates), t = [];
|
|
1054
1135
|
for (const { modelClass: n } of this.registeredModels)
|
|
1055
|
-
for (const i of
|
|
1136
|
+
for (const i of Ce(n, { includeSoftDeleted: !0 }))
|
|
1056
1137
|
t.push(...this.getModelsIn(e, i));
|
|
1057
1138
|
return t;
|
|
1058
1139
|
}
|
|
1059
1140
|
getModelsIn(e, t) {
|
|
1060
1141
|
const n = [];
|
|
1061
|
-
return e.includes(t.url) && n.push(t),
|
|
1062
|
-
...
|
|
1142
|
+
return e.includes(t.url) && n.push(t), I(t) && n.push(
|
|
1143
|
+
...Be(t).map((i) => this.getModelsIn(e, i)).flat()
|
|
1063
1144
|
), n;
|
|
1064
1145
|
}
|
|
1065
|
-
requireEngine() {
|
|
1066
|
-
return this.engine ?? Oe("Could not get required Engine");
|
|
1067
|
-
}
|
|
1068
1146
|
async setReady(e) {
|
|
1069
|
-
this.ready || !e || (await
|
|
1147
|
+
this.ready || !e || (await R.emit("cloud:ready"), this.ready = !0);
|
|
1070
1148
|
}
|
|
1071
1149
|
async backup(e) {
|
|
1072
|
-
await
|
|
1073
|
-
const t = new
|
|
1150
|
+
await R.emit("cloud:backup-started"), e ?? (e = /* @__PURE__ */ new WeakMap());
|
|
1151
|
+
const t = new dn();
|
|
1074
1152
|
for (const { modelClass: n, path: i } of this.registeredModels) {
|
|
1075
|
-
if (!x(n))
|
|
1076
|
-
continue;
|
|
1077
1153
|
for (const [r, c] of Object.entries(e.get(n) ?? {}))
|
|
1078
1154
|
t.migrateUrl(n, r, c);
|
|
1079
|
-
const
|
|
1080
|
-
n.collection =
|
|
1155
|
+
const a = n.collection, l = te(n, i);
|
|
1156
|
+
n.collection = l, t.migrateCollection(n, a, l);
|
|
1081
1157
|
}
|
|
1082
|
-
await
|
|
1158
|
+
await ce(t), await R.emit("cloud:backup-completed");
|
|
1083
1159
|
}
|
|
1084
1160
|
async onApplicationReady() {
|
|
1085
|
-
this.ready || !
|
|
1161
|
+
this.ready || !b.isLoggedIn() || await this.setReady(!Me().some((e) => e.url.startsWith("solid://")));
|
|
1086
1162
|
}
|
|
1087
1163
|
async onApplicationMounted() {
|
|
1164
|
+
if (b.isLoggedIn() && !this.ready && !this.manualSetup) {
|
|
1165
|
+
await this.setup();
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1088
1168
|
this.syncOnStartup() && await this.sync();
|
|
1089
1169
|
}
|
|
1090
1170
|
login(e) {
|
|
1091
|
-
const t = [...this.registeredModels].map(({ modelClass: n }) =>
|
|
1092
|
-
this.status =
|
|
1171
|
+
const t = [...this.registeredModels].map(({ modelClass: n }) => Ae(n)).flat().concat([x]);
|
|
1172
|
+
this.status = w.Online, this.engine = e.engine, L(Q).setEngine(this.engine);
|
|
1093
1173
|
for (const n of t)
|
|
1094
|
-
|
|
1174
|
+
L(n).setEngine(this.engine);
|
|
1095
1175
|
}
|
|
1096
|
-
logout() {
|
|
1176
|
+
async logout() {
|
|
1097
1177
|
this.setState({
|
|
1098
1178
|
autoPush: !0,
|
|
1099
1179
|
localModelUpdates: {},
|
|
@@ -1108,48 +1188,55 @@ class un extends dn {
|
|
|
1108
1188
|
setupDismissed: !1,
|
|
1109
1189
|
setupOngoing: !1,
|
|
1110
1190
|
startupSync: !0,
|
|
1111
|
-
status:
|
|
1191
|
+
status: w.Disconnected,
|
|
1112
1192
|
syncError: null,
|
|
1113
1193
|
syncJob: null
|
|
1194
|
+
}), await this.getDocumentsCache().clear();
|
|
1195
|
+
}
|
|
1196
|
+
watchNetworkStatus() {
|
|
1197
|
+
globalThis.addEventListener("online", () => {
|
|
1198
|
+
this.status === w.Offline && (this.status = w.Online);
|
|
1199
|
+
}), globalThis.addEventListener("offline", () => {
|
|
1200
|
+
this.status === w.Online && (this.status = w.Offline);
|
|
1114
1201
|
});
|
|
1115
1202
|
}
|
|
1116
1203
|
syncOnStartup() {
|
|
1117
|
-
return
|
|
1204
|
+
return Re("startupSync") ? ke(Le("startupSync")) : this.migrationJob ? !1 : this.startupSync;
|
|
1118
1205
|
}
|
|
1119
1206
|
async bustDocumentsCache() {
|
|
1120
|
-
!
|
|
1207
|
+
!Re("bustDocumentsCache") || !ke(Le("bustDocumentsCache")) || await this.getDocumentsCache().clear();
|
|
1121
1208
|
}
|
|
1122
1209
|
async registerModels() {
|
|
1123
|
-
const e =
|
|
1210
|
+
const e = Ht();
|
|
1124
1211
|
for (const t of e.values())
|
|
1125
|
-
!
|
|
1212
|
+
!qt(t) || !t.cloud || await this.register(t, typeof t.cloud == "boolean" ? {} : t.cloud);
|
|
1126
1213
|
}
|
|
1127
1214
|
}
|
|
1128
|
-
const
|
|
1215
|
+
const k = Pe(yn), wn = {
|
|
1129
1216
|
viewBox: "0 0 20 20",
|
|
1130
1217
|
width: "1.2em",
|
|
1131
1218
|
height: "1.2em"
|
|
1132
1219
|
};
|
|
1133
|
-
function
|
|
1134
|
-
return f(),
|
|
1220
|
+
function Mn(o, s) {
|
|
1221
|
+
return f(), C("svg", wn, s[0] || (s[0] = [
|
|
1135
1222
|
m("path", {
|
|
1136
1223
|
fill: "currentColor",
|
|
1137
1224
|
d: "m6 2l2-2h4l2 2h4v2H2V2zM3 6h14l-1 14H4zm5 2v10h1V8zm3 0v10h1V8z"
|
|
1138
1225
|
}, null, -1)
|
|
1139
1226
|
]));
|
|
1140
1227
|
}
|
|
1141
|
-
const
|
|
1228
|
+
const bn = _({ name: "zondicons-trash", render: Mn }), nt = /* @__PURE__ */ B({
|
|
1142
1229
|
__name: "AccountLoginModal",
|
|
1143
1230
|
setup(o) {
|
|
1144
|
-
return (s, e) => (f(),
|
|
1231
|
+
return (s, e) => (f(), D(u(Oe), {
|
|
1145
1232
|
title: s.$td("cloud.logIn.title", "Connect account")
|
|
1146
1233
|
}, {
|
|
1147
|
-
default:
|
|
1148
|
-
u(
|
|
1234
|
+
default: S(() => [
|
|
1235
|
+
h(u(E), {
|
|
1149
1236
|
"lang-key": "cloud.logIn.info",
|
|
1150
1237
|
"lang-default": "Log in to your [Solid account](https://solidproject.org) to keep data safe across devices."
|
|
1151
1238
|
}),
|
|
1152
|
-
u(
|
|
1239
|
+
h(u(me), {
|
|
1153
1240
|
class: "text-sm",
|
|
1154
1241
|
onClick: e[0] || (e[0] = (t) => s.$ui.alert(
|
|
1155
1242
|
s.$td("cloud.logIn.learnMore", "What is Solid?"),
|
|
@@ -1163,12 +1250,12 @@ In any case, Focus works 100% offline and you can connect your Solid POD later o
|
|
|
1163
1250
|
)
|
|
1164
1251
|
))
|
|
1165
1252
|
}, {
|
|
1166
|
-
default:
|
|
1167
|
-
|
|
1253
|
+
default: S(() => [
|
|
1254
|
+
X($(s.$td("cloud.logIn.learnMore", "What is Solid?")), 1)
|
|
1168
1255
|
]),
|
|
1169
1256
|
_: 1
|
|
1170
1257
|
}),
|
|
1171
|
-
u(
|
|
1258
|
+
h(u(At), {
|
|
1172
1259
|
"no-loading": "",
|
|
1173
1260
|
class: "mt-4"
|
|
1174
1261
|
})
|
|
@@ -1176,324 +1263,331 @@ In any case, Focus works 100% offline and you can connect your Solid POD later o
|
|
|
1176
1263
|
_: 1
|
|
1177
1264
|
}, 8, ["title"]));
|
|
1178
1265
|
}
|
|
1179
|
-
}),
|
|
1266
|
+
}), Cn = {
|
|
1180
1267
|
key: 0,
|
|
1181
1268
|
class: "mt-4"
|
|
1182
|
-
},
|
|
1269
|
+
}, vn = { class: "text-base font-semibold" }, Sn = { class: "ml-1" }, $n = /* @__PURE__ */ B({
|
|
1183
1270
|
__name: "PurgeData",
|
|
1184
1271
|
setup(o) {
|
|
1185
1272
|
async function s() {
|
|
1186
|
-
await
|
|
1187
|
-
|
|
1188
|
-
|
|
1273
|
+
await de.confirm(
|
|
1274
|
+
v("settings.purgeConfirmTitle", "Delete everything?"),
|
|
1275
|
+
v(
|
|
1189
1276
|
"settings.purgeConfirmMessage",
|
|
1190
1277
|
"If you proceed, all your data will be deleted forever. If you want to save it before wiping this device, you can [connect to your Solid account](#action:connect) first."
|
|
1191
1278
|
),
|
|
1192
1279
|
{
|
|
1193
1280
|
acceptVariant: "danger",
|
|
1194
|
-
acceptText:
|
|
1195
|
-
actions: { connect: () =>
|
|
1281
|
+
acceptText: v("settings.purgeConfirmAccept", "Purge data"),
|
|
1282
|
+
actions: { connect: () => de.modal(nt) }
|
|
1196
1283
|
}
|
|
1197
|
-
) && (await
|
|
1284
|
+
) && (await de.closeAllModals(), await ct.purge());
|
|
1198
1285
|
}
|
|
1199
|
-
return (e, t) => e.$solid.hasLoggedIn() ?
|
|
1286
|
+
return (e, t) => e.$solid.hasLoggedIn() ? W("", !0) : (f(), C("details", Cn, [
|
|
1200
1287
|
m("summary", null, [
|
|
1201
|
-
m("span",
|
|
1288
|
+
m("span", vn, $(e.$td("settings.dangerZone", "Danger zone")), 1)
|
|
1202
1289
|
]),
|
|
1203
|
-
u(
|
|
1290
|
+
h(u(q), {
|
|
1204
1291
|
variant: "danger",
|
|
1205
1292
|
class: "mt-4",
|
|
1206
1293
|
onClick: t[0] || (t[0] = (n) => s())
|
|
1207
1294
|
}, {
|
|
1208
|
-
default:
|
|
1209
|
-
u(
|
|
1210
|
-
m("span",
|
|
1295
|
+
default: S(() => [
|
|
1296
|
+
h(u(bn), { class: "size-4" }),
|
|
1297
|
+
m("span", Sn, $(e.$td("settings.purge", "Purge data")), 1)
|
|
1211
1298
|
]),
|
|
1212
1299
|
_: 1
|
|
1213
1300
|
})
|
|
1214
1301
|
]));
|
|
1215
1302
|
}
|
|
1216
|
-
}),
|
|
1303
|
+
}), Dn = dt([
|
|
1217
1304
|
{
|
|
1218
1305
|
priority: 0,
|
|
1219
|
-
component:
|
|
1306
|
+
component: $n
|
|
1220
1307
|
}
|
|
1221
|
-
]),
|
|
1308
|
+
]), Rn = {
|
|
1222
1309
|
viewBox: "0 0 20 20",
|
|
1223
1310
|
width: "1.2em",
|
|
1224
1311
|
height: "1.2em"
|
|
1225
1312
|
};
|
|
1226
|
-
function
|
|
1227
|
-
return f(),
|
|
1313
|
+
function kn(o, s) {
|
|
1314
|
+
return f(), C("svg", Rn, s[0] || (s[0] = [
|
|
1228
1315
|
m("path", {
|
|
1229
1316
|
fill: "currentColor",
|
|
1230
1317
|
d: "M2.93 17.07A10 10 0 1 1 17.07 2.93A10 10 0 0 1 2.93 17.07m12.73-1.41A8 8 0 1 0 4.34 4.34a8 8 0 0 0 11.32 11.32M6.7 9.29L9 11.6l4.3-4.3l1.4 1.42L9 14.4l-3.7-3.7l1.4-1.42z"
|
|
1231
1318
|
}, null, -1)
|
|
1232
1319
|
]));
|
|
1233
1320
|
}
|
|
1234
|
-
const
|
|
1321
|
+
const Ln = _({ name: "zondicons-checkmark-outline", render: kn }), An = {
|
|
1235
1322
|
viewBox: "0 0 24 24",
|
|
1236
1323
|
width: "1.2em",
|
|
1237
1324
|
height: "1.2em"
|
|
1238
1325
|
};
|
|
1239
|
-
function
|
|
1240
|
-
return f(),
|
|
1326
|
+
function Un(o, s) {
|
|
1327
|
+
return f(), C("svg", An, s[0] || (s[0] = [
|
|
1241
1328
|
m("path", {
|
|
1242
1329
|
fill: "currentColor",
|
|
1243
1330
|
d: "M19.35 10.04A7.49 7.49 0 0 0 12 4C9.11 4 6.6 5.64 5.35 8.04A5.994 5.994 0 0 0 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5c0-2.64-2.05-4.78-4.65-4.96M14 13v4h-4v-4H7l5-5l5 5z"
|
|
1244
1331
|
}, null, -1)
|
|
1245
1332
|
]));
|
|
1246
1333
|
}
|
|
1247
|
-
const
|
|
1334
|
+
const En = _({ name: "ic-sharp-cloud-upload", render: Un }), In = {
|
|
1248
1335
|
viewBox: "0 0 20 20",
|
|
1249
1336
|
width: "1.2em",
|
|
1250
1337
|
height: "1.2em"
|
|
1251
1338
|
};
|
|
1252
|
-
function
|
|
1253
|
-
return f(),
|
|
1339
|
+
function zn(o, s) {
|
|
1340
|
+
return f(), C("svg", In, s[0] || (s[0] = [
|
|
1254
1341
|
m("path", {
|
|
1255
1342
|
fill: "currentColor",
|
|
1256
1343
|
d: "M3.94 6.5L2.22 3.64l1.42-1.42L6.5 3.94c.52-.3 1.1-.54 1.7-.7L9 0h2l.8 3.24c.6.16 1.18.4 1.7.7l2.86-1.72l1.42 1.42l-1.72 2.86c.3.52.54 1.1.7 1.7L20 9v2l-3.24.8c-.16.6-.4 1.18-.7 1.7l1.72 2.86l-1.42 1.42l-2.86-1.72c-.52.3-1.1.54-1.7.7L11 20H9l-.8-3.24c-.6-.16-1.18-.4-1.7-.7l-2.86 1.72l-1.42-1.42l1.72-2.86c-.3-.52-.54-1.1-.7-1.7L0 11V9l3.24-.8c.16-.6.4-1.18.7-1.7M10 13a3 3 0 1 0 0-6a3 3 0 0 0 0 6"
|
|
1257
1344
|
}, null, -1)
|
|
1258
1345
|
]));
|
|
1259
1346
|
}
|
|
1260
|
-
const
|
|
1347
|
+
const st = _({ name: "zondicons-cog", render: zn }), On = {
|
|
1261
1348
|
viewBox: "0 0 24 24",
|
|
1262
1349
|
width: "1.2em",
|
|
1263
1350
|
height: "1.2em"
|
|
1264
1351
|
};
|
|
1265
|
-
function
|
|
1266
|
-
return f(),
|
|
1352
|
+
function Tn(o, s) {
|
|
1353
|
+
return f(), C("svg", On, s[0] || (s[0] = [
|
|
1267
1354
|
m("path", {
|
|
1268
1355
|
fill: "currentColor",
|
|
1269
1356
|
d: "M5 21q-.825 0-1.412-.587T3 19V5q0-.825.588-1.412T5 3h6q.425 0 .713.288T12 4t-.288.713T11 5H5v14h6q.425 0 .713.288T12 20t-.288.713T11 21zm12.175-8H10q-.425 0-.712-.288T9 12t.288-.712T10 11h7.175L15.3 9.125q-.275-.275-.275-.675t.275-.7t.7-.313t.725.288L20.3 11.3q.3.3.3.7t-.3.7l-3.575 3.575q-.3.3-.712.288t-.713-.313q-.275-.3-.262-.712t.287-.688z"
|
|
1270
1357
|
}, null, -1)
|
|
1271
1358
|
]));
|
|
1272
1359
|
}
|
|
1273
|
-
const
|
|
1360
|
+
const Pn = _({ name: "material-symbols-logout-rounded", render: Tn }), qn = {
|
|
1274
1361
|
viewBox: "0 0 20 20",
|
|
1275
1362
|
width: "1.2em",
|
|
1276
1363
|
height: "1.2em"
|
|
1277
1364
|
};
|
|
1278
|
-
function
|
|
1279
|
-
return f(),
|
|
1365
|
+
function _n(o, s) {
|
|
1366
|
+
return f(), C("svg", qn, s[0] || (s[0] = [
|
|
1280
1367
|
m("path", {
|
|
1281
1368
|
fill: "currentColor",
|
|
1282
1369
|
d: "M10 3v2a5 5 0 0 0-3.54 8.54l-1.41 1.41A7 7 0 0 1 10 3m4.95 2.05A7 7 0 0 1 10 17v-2a5 5 0 0 0 3.54-8.54zM10 20l-4-4l4-4zm0-12V0l4 4z"
|
|
1283
1370
|
}, null, -1)
|
|
1284
1371
|
]));
|
|
1285
1372
|
}
|
|
1286
|
-
const
|
|
1373
|
+
const Z = _({ name: "zondicons-refresh", render: _n }), Wn = {
|
|
1287
1374
|
viewBox: "0 0 24 24",
|
|
1288
1375
|
width: "1.2em",
|
|
1289
1376
|
height: "1.2em"
|
|
1290
1377
|
};
|
|
1291
|
-
function
|
|
1292
|
-
return f(),
|
|
1378
|
+
function Nn(o, s) {
|
|
1379
|
+
return f(), C("svg", Wn, s[0] || (s[0] = [
|
|
1293
1380
|
m("path", {
|
|
1294
1381
|
fill: "currentColor",
|
|
1295
1382
|
d: "M6 6h12v12H6z"
|
|
1296
1383
|
}, null, -1)
|
|
1297
1384
|
]));
|
|
1298
1385
|
}
|
|
1299
|
-
const
|
|
1386
|
+
const Jn = _({ name: "ic-baseline-stop", render: Nn }), xn = {
|
|
1300
1387
|
viewBox: "0 0 512 512",
|
|
1301
1388
|
width: "1.2em",
|
|
1302
1389
|
height: "1.2em"
|
|
1303
1390
|
};
|
|
1304
|
-
function
|
|
1305
|
-
return f(),
|
|
1391
|
+
function jn(o, s) {
|
|
1392
|
+
return f(), C("svg", xn, s[0] || (s[0] = [
|
|
1306
1393
|
m("path", {
|
|
1307
1394
|
fill: "currentColor",
|
|
1308
1395
|
d: "M449.07 399.08L278.64 82.58c-12.08-22.44-44.26-22.44-56.35 0L51.87 399.08A32 32 0 0 0 80 446.25h340.89a32 32 0 0 0 28.18-47.17m-198.6-1.83a20 20 0 1 1 20-20a20 20 0 0 1-20 20m21.72-201.15l-5.74 122a16 16 0 0 1-32 0l-5.74-121.95a21.73 21.73 0 0 1 21.5-22.69h.21a21.74 21.74 0 0 1 21.73 22.7Z"
|
|
1309
1396
|
}, null, -1)
|
|
1310
1397
|
]));
|
|
1311
1398
|
}
|
|
1312
|
-
const
|
|
1399
|
+
const G = _({ name: "ion-warning", render: jn }), Bn = { class: "relative flex items-center rounded-md bg-gray-100 p-4 pr-12" }, Vn = { class: "flex flex-col overflow-hidden" }, Fn = { class: "font-semibold" }, Hn = { class: "px-2" }, Kn = {
|
|
1313
1400
|
key: 0,
|
|
1314
1401
|
class: "mt-4 flex items-center gap-2"
|
|
1315
|
-
},
|
|
1402
|
+
}, Yn = { class: "flex w-full flex-col" }, Qn = {
|
|
1316
1403
|
key: 1,
|
|
1317
1404
|
class: "mt-4 flex items-center gap-2"
|
|
1318
|
-
},
|
|
1405
|
+
}, Zn = {
|
|
1319
1406
|
key: 2,
|
|
1320
1407
|
class: "mt-4 flex items-center gap-2"
|
|
1321
|
-
},
|
|
1408
|
+
}, Gn = {
|
|
1322
1409
|
key: 3,
|
|
1323
1410
|
class: "mt-4 flex items-center gap-2"
|
|
1324
|
-
},
|
|
1411
|
+
}, Xn = {
|
|
1325
1412
|
key: 4,
|
|
1326
1413
|
class: "mt-4 flex items-center gap-2"
|
|
1327
|
-
},
|
|
1414
|
+
}, es = {
|
|
1328
1415
|
key: 5,
|
|
1329
1416
|
class: "mt-4 flex items-center gap-2"
|
|
1330
|
-
},
|
|
1417
|
+
}, ts = {
|
|
1331
1418
|
key: 6,
|
|
1332
1419
|
class: "mt-4 flex items-center gap-2"
|
|
1333
|
-
},
|
|
1420
|
+
}, ns = { class: "flex flex-col gap-2" }, ss = { class: "flex items-center" }, os = { "aria-hidden": "true" }, is = {
|
|
1334
1421
|
key: 0,
|
|
1335
1422
|
"aria-hidden": "true"
|
|
1336
|
-
},
|
|
1423
|
+
}, rs = {
|
|
1337
1424
|
key: 0,
|
|
1338
1425
|
class: "mt-4 flex flex-row-reverse justify-start gap-2"
|
|
1339
|
-
},
|
|
1426
|
+
}, as = /* @__PURE__ */ B({
|
|
1340
1427
|
__name: "AccountModal",
|
|
1341
1428
|
setup(o) {
|
|
1342
|
-
const s =
|
|
1429
|
+
const s = Jt("$modalRef"), e = xt(!1), t = v("cloud.advanced.polling", "Synchronize every {minutes} minutes", {
|
|
1343
1430
|
minutes: "%%separator%%"
|
|
1344
|
-
}).split("%%separator%%"), n =
|
|
1431
|
+
}).split("%%separator%%"), n = ee(() => b.error ?? k.syncError), i = ee(() => {
|
|
1345
1432
|
if (n.value)
|
|
1346
|
-
return typeof n.value == "string" ? n.value :
|
|
1347
|
-
}),
|
|
1348
|
-
async function
|
|
1349
|
-
|
|
1433
|
+
return typeof n.value == "string" ? n.value : v("cloud.info.error", "There has been an error connecting.");
|
|
1434
|
+
}), a = ee(() => n.value && typeof n.value != "string");
|
|
1435
|
+
async function l() {
|
|
1436
|
+
k.syncJob && (e.value = !0, await Promise.race([k.syncJob.cancel(), k.syncJob.completed]), e.value = !1);
|
|
1350
1437
|
}
|
|
1351
|
-
return
|
|
1438
|
+
return ut("auth:logout", () => {
|
|
1352
1439
|
var r;
|
|
1353
1440
|
return (r = s.value) == null ? void 0 : r.close();
|
|
1354
|
-
}), (r, c) => (f(),
|
|
1441
|
+
}), (r, c) => (f(), D(u(Oe), {
|
|
1355
1442
|
ref: "$modalRef",
|
|
1356
1443
|
"title-hidden": "",
|
|
1357
1444
|
"close-hidden": "",
|
|
1358
1445
|
title: r.$td("account.title", "Account")
|
|
1359
1446
|
}, {
|
|
1360
|
-
default:
|
|
1361
|
-
var
|
|
1447
|
+
default: S(() => {
|
|
1448
|
+
var d, y;
|
|
1362
1449
|
return [
|
|
1363
|
-
m("div",
|
|
1364
|
-
u(
|
|
1365
|
-
m("div",
|
|
1366
|
-
m("span",
|
|
1367
|
-
u(
|
|
1368
|
-
href: (
|
|
1450
|
+
m("div", Bn, [
|
|
1451
|
+
h(u(Je), { class: "mr-2 size-16 shrink-0" }),
|
|
1452
|
+
m("div", Vn, [
|
|
1453
|
+
m("span", Fn, $(((d = r.$solid.user) == null ? void 0 : d.name) ?? r.$td("user.anonymous", "Anonymous")), 1),
|
|
1454
|
+
h(u(me), {
|
|
1455
|
+
href: (y = r.$solid.user) == null ? void 0 : y.webId,
|
|
1369
1456
|
class: "mt-0.5 truncate text-sm font-light text-gray-500"
|
|
1370
1457
|
}, {
|
|
1371
|
-
default:
|
|
1372
|
-
var
|
|
1458
|
+
default: S(() => {
|
|
1459
|
+
var p;
|
|
1373
1460
|
return [
|
|
1374
|
-
|
|
1461
|
+
X($((p = r.$solid.user) == null ? void 0 : p.webId), 1)
|
|
1375
1462
|
];
|
|
1376
1463
|
}),
|
|
1377
1464
|
_: 1
|
|
1378
1465
|
}, 8, ["href"])
|
|
1379
1466
|
]),
|
|
1380
|
-
u(
|
|
1467
|
+
h(u(q), {
|
|
1381
1468
|
size: "icon",
|
|
1382
1469
|
variant: "ghost",
|
|
1383
1470
|
class: "absolute top-1 right-1 hover:bg-gray-200",
|
|
1384
1471
|
"aria-label": r.$td("user.settings", "Settings"),
|
|
1385
1472
|
title: r.$td("user.settings", "Settings"),
|
|
1386
|
-
onClick: c[0] || (c[0] = (
|
|
1473
|
+
onClick: c[0] || (c[0] = (p) => r.$ui.modal(u(Te)))
|
|
1387
1474
|
}, {
|
|
1388
|
-
default:
|
|
1389
|
-
u(
|
|
1475
|
+
default: S(() => [
|
|
1476
|
+
h(u(st), { class: "size-5" })
|
|
1390
1477
|
]),
|
|
1391
1478
|
_: 1
|
|
1392
1479
|
}, 8, ["aria-label", "title"])
|
|
1393
1480
|
]),
|
|
1394
|
-
m("div",
|
|
1395
|
-
r.$cloud.syncing ? (f(),
|
|
1396
|
-
u(
|
|
1397
|
-
m("div",
|
|
1398
|
-
u(
|
|
1481
|
+
m("div", Hn, [
|
|
1482
|
+
r.$cloud.syncing ? (f(), C("div", Kn, [
|
|
1483
|
+
h(u(Z), { class: "mt-0.5 size-6 shrink-0 animate-spin self-start text-green-500" }),
|
|
1484
|
+
m("div", Yn, [
|
|
1485
|
+
h(u(E), {
|
|
1399
1486
|
"lang-key": "cloud.info.syncing",
|
|
1400
1487
|
"lang-default": "Synchronizing..."
|
|
1401
1488
|
}),
|
|
1402
|
-
r.$cloud.syncJob ? (f(),
|
|
1489
|
+
r.$cloud.syncJob ? (f(), D(u(ht), {
|
|
1403
1490
|
key: 0,
|
|
1404
1491
|
job: r.$cloud.syncJob,
|
|
1405
1492
|
"filled-class": "bg-green-500"
|
|
1406
|
-
}, null, 8, ["job"])) :
|
|
1493
|
+
}, null, 8, ["job"])) : W("", !0)
|
|
1407
1494
|
])
|
|
1408
|
-
])) : r.$solid.loginOngoing ? (f(),
|
|
1409
|
-
u(
|
|
1410
|
-
u(
|
|
1495
|
+
])) : r.$solid.loginOngoing ? (f(), C("div", Qn, [
|
|
1496
|
+
h(u(Z), { class: "mt-0.5 size-6 shrink-0 animate-spin self-start text-green-500" }),
|
|
1497
|
+
h(u(E), {
|
|
1411
1498
|
"lang-key": "cloud.info.reconnecting",
|
|
1412
1499
|
"lang-default": "Reconnecting..."
|
|
1413
1500
|
})
|
|
1414
|
-
])) : n.value ? (f(),
|
|
1415
|
-
u(
|
|
1501
|
+
])) : n.value ? (f(), C("div", Zn, [
|
|
1502
|
+
h(u(G), { class: "mt-0.5 size-6 shrink-0 self-start text-red-500" }),
|
|
1416
1503
|
m("div", null, [
|
|
1417
|
-
u(
|
|
1418
|
-
|
|
1504
|
+
h(u(E), { text: i.value }, null, 8, ["text"]),
|
|
1505
|
+
a.value ? (f(), D(u(me), {
|
|
1419
1506
|
key: 0,
|
|
1420
1507
|
class: "text-sm text-red-700 opacity-50 hover:opacity-75 focus-visible:opacity-75",
|
|
1421
|
-
onClick: c[1] || (c[1] = (
|
|
1508
|
+
onClick: c[1] || (c[1] = (p) => r.$errors.inspect(n.value))
|
|
1422
1509
|
}, {
|
|
1423
|
-
default:
|
|
1424
|
-
|
|
1510
|
+
default: S(() => [
|
|
1511
|
+
X($(r.$td("errors.viewDetails", "View details")), 1)
|
|
1425
1512
|
]),
|
|
1426
1513
|
_: 1
|
|
1427
|
-
})) :
|
|
1514
|
+
})) : W("", !0)
|
|
1428
1515
|
])
|
|
1429
|
-
])) : r.$cloud.ready ? r.$cloud.dirty ? (f(),
|
|
1430
|
-
u(
|
|
1431
|
-
u(
|
|
1516
|
+
])) : r.$cloud.ready ? r.$cloud.dirty ? (f(), C("div", Xn, [
|
|
1517
|
+
h(u(G), { class: "mt-0.5 size-6 shrink-0 self-start text-yellow-500" }),
|
|
1518
|
+
h(u(E), {
|
|
1432
1519
|
"lang-key": "cloud.info.changes",
|
|
1433
1520
|
"lang-default": "Everything is up to date. | There is one local change. | There are {n} local changes.",
|
|
1434
1521
|
"lang-params": r.$cloud.localChanges
|
|
1435
1522
|
}, null, 8, ["lang-params"])
|
|
1436
|
-
])) : r.$cloud.online ? (f(),
|
|
1437
|
-
u(
|
|
1438
|
-
|
|
1523
|
+
])) : r.$cloud.online || r.$cloud.offline ? (f(), C("div", es, [
|
|
1524
|
+
h(u(Ln), {
|
|
1525
|
+
class: xe(["mt-0.5 size-6 shrink-0 self-start", { "text-green-500": r.$cloud.online, "text-gray-700": r.$cloud.offline }])
|
|
1526
|
+
}, null, 8, ["class"]),
|
|
1527
|
+
r.$cloud.online ? (f(), D(u(E), {
|
|
1528
|
+
key: 0,
|
|
1439
1529
|
"lang-key": "cloud.info.changes",
|
|
1440
1530
|
"lang-default": "Everything is up to date.",
|
|
1441
1531
|
"lang-params": 0
|
|
1442
|
-
})
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1532
|
+
})) : (f(), D(u(E), {
|
|
1533
|
+
key: 1,
|
|
1534
|
+
"lang-key": "cloud.info.offline",
|
|
1535
|
+
"lang-default": "Everything is up to date, but you're currently offline."
|
|
1536
|
+
}))
|
|
1537
|
+
])) : (f(), C("div", ts, [
|
|
1538
|
+
h(u(G), { class: "mt-0.5 size-6 shrink-0 self-start text-yellow-500" }),
|
|
1539
|
+
h(u(E), {
|
|
1446
1540
|
"lang-key": "cloud.info.disconnected",
|
|
1447
1541
|
"lang-default": "You are disconnected from your Solid account, all the changes you make will remain in your device."
|
|
1448
1542
|
})
|
|
1449
|
-
])) : (f(),
|
|
1450
|
-
u(
|
|
1451
|
-
u(
|
|
1543
|
+
])) : (f(), C("div", Gn, [
|
|
1544
|
+
h(u(G), { class: "mt-0.5 size-6 shrink-0 self-start text-yellow-500" }),
|
|
1545
|
+
h(u(E), {
|
|
1452
1546
|
"lang-key": "cloud.info.setup",
|
|
1453
1547
|
"lang-default": "Your data is not backed up yet."
|
|
1454
1548
|
})
|
|
1455
1549
|
])),
|
|
1456
|
-
u(
|
|
1457
|
-
default:
|
|
1458
|
-
m("ul",
|
|
1550
|
+
h(u(ft), { class: "mt-2" }, {
|
|
1551
|
+
default: S(() => [
|
|
1552
|
+
m("ul", ns, [
|
|
1459
1553
|
m("li", null, [
|
|
1460
|
-
u(
|
|
1554
|
+
h(u(ue), {
|
|
1461
1555
|
modelValue: r.$solid.autoReconnect,
|
|
1462
|
-
"onUpdate:modelValue": c[2] || (c[2] = (
|
|
1556
|
+
"onUpdate:modelValue": c[2] || (c[2] = (p) => r.$solid.autoReconnect = p),
|
|
1463
1557
|
"label-class": "text-base",
|
|
1464
1558
|
label: r.$td("cloud.advanced.reconnect", "Reconnect on startup")
|
|
1465
1559
|
}, null, 8, ["modelValue", "label"])
|
|
1466
1560
|
]),
|
|
1467
1561
|
m("li", null, [
|
|
1468
|
-
u(
|
|
1562
|
+
h(u(ue), {
|
|
1469
1563
|
modelValue: r.$cloud.startupSync,
|
|
1470
|
-
"onUpdate:modelValue": c[3] || (c[3] = (
|
|
1564
|
+
"onUpdate:modelValue": c[3] || (c[3] = (p) => r.$cloud.startupSync = p),
|
|
1471
1565
|
"label-class": "text-base",
|
|
1472
1566
|
label: r.$td("cloud.advanced.startupSync", "Synchronize on startup")
|
|
1473
1567
|
}, null, 8, ["modelValue", "label"])
|
|
1474
1568
|
]),
|
|
1475
1569
|
m("li", null, [
|
|
1476
|
-
u(
|
|
1570
|
+
h(u(ue), {
|
|
1477
1571
|
modelValue: r.$cloud.pollingEnabled,
|
|
1478
|
-
"onUpdate:modelValue": c[5] || (c[5] = (
|
|
1572
|
+
"onUpdate:modelValue": c[5] || (c[5] = (p) => r.$cloud.pollingEnabled = p),
|
|
1479
1573
|
"label-class": "text-base"
|
|
1480
1574
|
}, {
|
|
1481
|
-
default:
|
|
1482
|
-
m("div",
|
|
1483
|
-
m("span",
|
|
1484
|
-
u(
|
|
1575
|
+
default: S(() => [
|
|
1576
|
+
m("div", ss, [
|
|
1577
|
+
m("span", os, $(u(t)[0]), 1),
|
|
1578
|
+
h(u(mt), {
|
|
1485
1579
|
type: "number",
|
|
1486
1580
|
text: `${r.$cloud.pollingMinutes}`,
|
|
1487
1581
|
"aria-label": r.$td("cloud.advanced.pollingMinutes", "Synchronization interval (in minutes)"),
|
|
1488
1582
|
class: "focus-within:border-primary-600 mx-1 -mb-px border-b",
|
|
1489
|
-
onUpdate: c[4] || (c[4] = (
|
|
1583
|
+
onUpdate: c[4] || (c[4] = (p) => r.$cloud.pollingMinutes = p)
|
|
1490
1584
|
}, {
|
|
1491
|
-
default:
|
|
1492
|
-
|
|
1585
|
+
default: S(() => [
|
|
1586
|
+
X($(r.$cloud.pollingMinutes), 1)
|
|
1493
1587
|
]),
|
|
1494
1588
|
_: 1
|
|
1495
1589
|
}, 8, ["text", "aria-label"]),
|
|
1496
|
-
|
|
1590
|
+
u(t).length > 1 ? (f(), C("span", is, $(u(t)[1]), 1)) : W("", !0)
|
|
1497
1591
|
])
|
|
1498
1592
|
]),
|
|
1499
1593
|
_: 1
|
|
@@ -1504,57 +1598,58 @@ const H = O({ name: "ion-warning", render: On }), _n = { class: "relative flex i
|
|
|
1504
1598
|
_: 1
|
|
1505
1599
|
})
|
|
1506
1600
|
]),
|
|
1507
|
-
r.$solid.loginOngoing ?
|
|
1508
|
-
r.$cloud.syncing ? (f(),
|
|
1601
|
+
r.$solid.loginOngoing ? W("", !0) : (f(), C("div", rs, [
|
|
1602
|
+
r.$cloud.syncing ? (f(), D(u(q), {
|
|
1509
1603
|
key: 0,
|
|
1510
1604
|
variant: "secondary",
|
|
1511
1605
|
disabled: e.value,
|
|
1512
|
-
onClick: c[6] || (c[6] = (
|
|
1606
|
+
onClick: c[6] || (c[6] = (p) => l())
|
|
1513
1607
|
}, {
|
|
1514
|
-
default:
|
|
1515
|
-
u(
|
|
1516
|
-
m("span", null,
|
|
1608
|
+
default: S(() => [
|
|
1609
|
+
h(u(Jn), { class: "size-5" }),
|
|
1610
|
+
m("span", null, $(e.value ? r.$td("cloud.stopping", "Stopping...") : r.$td("cloud.stop", "Stop synchronization")), 1)
|
|
1517
1611
|
]),
|
|
1518
1612
|
_: 1
|
|
1519
|
-
}, 8, ["disabled"])) : r.$solid.isLoggedIn() ? r.$cloud.ready ? (f(),
|
|
1613
|
+
}, 8, ["disabled"])) : r.$solid.isLoggedIn() ? r.$cloud.ready ? (f(), D(u(q), {
|
|
1520
1614
|
key: 2,
|
|
1521
|
-
|
|
1615
|
+
disabled: r.$cloud.offline,
|
|
1616
|
+
onClick: c[8] || (c[8] = (p) => r.$cloud.sync({ refreshUserProfile: !0 }))
|
|
1522
1617
|
}, {
|
|
1523
|
-
default:
|
|
1524
|
-
u(
|
|
1525
|
-
m("span", null,
|
|
1618
|
+
default: S(() => [
|
|
1619
|
+
h(u(Z), { class: "size-5" }),
|
|
1620
|
+
m("span", null, $(r.$td("cloud.sync", "Synchronize")), 1)
|
|
1526
1621
|
]),
|
|
1527
1622
|
_: 1
|
|
1528
|
-
})) : (f(),
|
|
1623
|
+
}, 8, ["disabled"])) : (f(), D(u(q), {
|
|
1529
1624
|
key: 3,
|
|
1530
|
-
onClick: c[9] || (c[9] = (
|
|
1531
|
-
var
|
|
1532
|
-
return r.$cloud.setupDismissed = !1, (
|
|
1625
|
+
onClick: c[9] || (c[9] = (p) => {
|
|
1626
|
+
var P;
|
|
1627
|
+
return r.$cloud.setupDismissed = !1, (P = s.value) == null || P.close(), r.$cloud.manualSetup || r.$cloud.setup();
|
|
1533
1628
|
})
|
|
1534
1629
|
}, {
|
|
1535
|
-
default:
|
|
1536
|
-
u(
|
|
1537
|
-
m("span", null,
|
|
1630
|
+
default: S(() => [
|
|
1631
|
+
h(u(En), { class: "size-5" }),
|
|
1632
|
+
m("span", null, $(r.$td("cloud.setup.submit", "Back up now")), 1)
|
|
1538
1633
|
]),
|
|
1539
1634
|
_: 1
|
|
1540
|
-
})) : (f(),
|
|
1635
|
+
})) : (f(), D(u(q), {
|
|
1541
1636
|
key: 1,
|
|
1542
|
-
onClick: c[7] || (c[7] = (
|
|
1637
|
+
onClick: c[7] || (c[7] = (p) => r.$solid.reconnect({ force: !0 }))
|
|
1543
1638
|
}, {
|
|
1544
|
-
default:
|
|
1545
|
-
u(
|
|
1546
|
-
m("span", null,
|
|
1639
|
+
default: S(() => [
|
|
1640
|
+
h(u(Z), { class: "size-5" }),
|
|
1641
|
+
m("span", null, $(r.$td("cloud.reconnect", "Reconnect")), 1)
|
|
1547
1642
|
]),
|
|
1548
1643
|
_: 1
|
|
1549
1644
|
})),
|
|
1550
|
-
r.$cloud.syncing ?
|
|
1645
|
+
r.$cloud.syncing ? W("", !0) : (f(), D(u(q), {
|
|
1551
1646
|
key: 4,
|
|
1552
1647
|
variant: "secondary",
|
|
1553
|
-
onClick: c[10] || (c[10] = (
|
|
1648
|
+
onClick: c[10] || (c[10] = (p) => r.$solid.logout())
|
|
1554
1649
|
}, {
|
|
1555
|
-
default:
|
|
1556
|
-
u(
|
|
1557
|
-
m("span", null,
|
|
1650
|
+
default: S(() => [
|
|
1651
|
+
h(u(Pn), { class: "size-5" }),
|
|
1652
|
+
m("span", null, $(r.$cloud.ready ? r.$td("cloud.logOut", "Log out") : r.$td("cloud.disconnect", "Disconnect")), 1)
|
|
1558
1653
|
]),
|
|
1559
1654
|
_: 1
|
|
1560
1655
|
}))
|
|
@@ -1564,78 +1659,80 @@ const H = O({ name: "ion-warning", render: On }), _n = { class: "relative flex i
|
|
|
1564
1659
|
_: 1
|
|
1565
1660
|
}, 8, ["title"]));
|
|
1566
1661
|
}
|
|
1567
|
-
}),
|
|
1662
|
+
}), ls = { class: "relative size-12" }, cs = ["aria-label", "title"], ds = {
|
|
1568
1663
|
key: 0,
|
|
1569
1664
|
class: "absolute -inset-1 animate-spin rounded-full border-2 border-[currentColor_transparent] text-green-500"
|
|
1570
|
-
},
|
|
1665
|
+
}, us = { class: "sr-only" }, hs = /* @__PURE__ */ B({
|
|
1571
1666
|
__name: "AccountLoggedIn",
|
|
1572
1667
|
setup(o) {
|
|
1573
|
-
const s =
|
|
1668
|
+
const s = ee(() => k.syncing || b.loginOngoing ? {
|
|
1574
1669
|
loading: !0,
|
|
1575
1670
|
classes: "bg-green-500 sr-only",
|
|
1576
1671
|
message: e() ?? ""
|
|
1577
|
-
} :
|
|
1672
|
+
} : b.error || k.syncError ? {
|
|
1578
1673
|
classes: "bg-red-500",
|
|
1579
|
-
message:
|
|
1580
|
-
} : !
|
|
1674
|
+
message: v("account.error", "There has been an error connecting with your account.")
|
|
1675
|
+
} : !b.isLoggedIn() || k.dirty || !k.ready ? {
|
|
1581
1676
|
classes: "bg-yellow-500",
|
|
1582
|
-
message:
|
|
1677
|
+
message: v(
|
|
1583
1678
|
"account.dirty",
|
|
1584
1679
|
"There are local changes that haven't been synchronized yet."
|
|
1585
1680
|
)
|
|
1586
1681
|
} : {
|
|
1587
|
-
classes: "bg-green-500",
|
|
1682
|
+
classes: k.status === w.Online ? "bg-green-500" : "bg-gray-500",
|
|
1588
1683
|
message: e() ?? ""
|
|
1589
1684
|
});
|
|
1590
1685
|
function e() {
|
|
1591
|
-
switch (
|
|
1592
|
-
case
|
|
1593
|
-
return
|
|
1594
|
-
case
|
|
1595
|
-
return
|
|
1596
|
-
case
|
|
1597
|
-
return
|
|
1598
|
-
case
|
|
1599
|
-
return
|
|
1686
|
+
switch (k.status) {
|
|
1687
|
+
case w.Syncing:
|
|
1688
|
+
return v("cloud.status.syncing", "Synchronization in progress");
|
|
1689
|
+
case w.Migrating:
|
|
1690
|
+
return v("cloud.status.migrating", "Migration in progress");
|
|
1691
|
+
case w.Online:
|
|
1692
|
+
return v("cloud.status.online", "Online");
|
|
1693
|
+
case w.Offline:
|
|
1694
|
+
return v("cloud.status.offline", "Offline");
|
|
1695
|
+
case w.Disconnected:
|
|
1696
|
+
return v("cloud.status.disconnected", "Disconnected");
|
|
1600
1697
|
}
|
|
1601
1698
|
}
|
|
1602
|
-
return (t, n) => (f(),
|
|
1699
|
+
return (t, n) => (f(), C("div", ls, [
|
|
1603
1700
|
m("button", {
|
|
1604
1701
|
class: "clickable focus-visible:outline-primary-600 flex size-full rounded-full focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",
|
|
1605
1702
|
type: "button",
|
|
1606
1703
|
"aria-label": t.$td("account.open", "Open account"),
|
|
1607
1704
|
title: t.$td("account.open", "Open account"),
|
|
1608
|
-
onClick: n[0] || (n[0] = (i) => t.$ui.modal(
|
|
1705
|
+
onClick: n[0] || (n[0] = (i) => t.$ui.modal(as))
|
|
1609
1706
|
}, [
|
|
1610
|
-
u(
|
|
1611
|
-
s.value.loading ? (f(),
|
|
1612
|
-
], 8,
|
|
1707
|
+
h(u(Je), { class: "size-full" }),
|
|
1708
|
+
s.value.loading ? (f(), C("div", ds)) : W("", !0)
|
|
1709
|
+
], 8, cs),
|
|
1613
1710
|
m("div", {
|
|
1614
|
-
class:
|
|
1711
|
+
class: xe(["pointer-events-none absolute right-0 bottom-0 size-3 rounded-full border-2 border-white", s.value.classes])
|
|
1615
1712
|
}, [
|
|
1616
|
-
m("span",
|
|
1713
|
+
m("span", us, $(s.value.message), 1)
|
|
1617
1714
|
], 2)
|
|
1618
1715
|
]));
|
|
1619
1716
|
}
|
|
1620
|
-
}),
|
|
1717
|
+
}), fs = /* @__PURE__ */ B({
|
|
1621
1718
|
__name: "AccountLoggedOut",
|
|
1622
1719
|
setup(o) {
|
|
1623
|
-
return (s, e) => (f(),
|
|
1720
|
+
return (s, e) => (f(), D(u(gt), {
|
|
1624
1721
|
align: "start",
|
|
1625
1722
|
options: [
|
|
1626
|
-
{ label: s.$td("user.logIn", "Connect account"), click: () => s.$ui.modal(
|
|
1627
|
-
{ label: s.$td("user.settings", "Settings"), click: () => s.$ui.modal(
|
|
1723
|
+
{ label: s.$td("user.logIn", "Connect account"), click: () => s.$ui.modal(nt) },
|
|
1724
|
+
{ label: s.$td("user.settings", "Settings"), click: () => s.$ui.modal(u(Te)) }
|
|
1628
1725
|
]
|
|
1629
1726
|
}, {
|
|
1630
|
-
default:
|
|
1631
|
-
u(
|
|
1727
|
+
default: S(() => [
|
|
1728
|
+
h(u(q), {
|
|
1632
1729
|
size: "icon",
|
|
1633
1730
|
variant: "ghost",
|
|
1634
1731
|
"aria-label": s.$td("user.menu", "Configuration"),
|
|
1635
1732
|
title: s.$td("user.menu", "Configuration")
|
|
1636
1733
|
}, {
|
|
1637
|
-
default:
|
|
1638
|
-
u(
|
|
1734
|
+
default: S(() => [
|
|
1735
|
+
h(u(st), { class: "size-5" })
|
|
1639
1736
|
]),
|
|
1640
1737
|
_: 1
|
|
1641
1738
|
}, 8, ["aria-label", "title"])
|
|
@@ -1643,31 +1740,28 @@ const H = O({ name: "ion-warning", render: On }), _n = { class: "relative flex i
|
|
|
1643
1740
|
_: 1
|
|
1644
1741
|
}, 8, ["options"]));
|
|
1645
1742
|
}
|
|
1646
|
-
}),
|
|
1743
|
+
}), Ds = /* @__PURE__ */ B({
|
|
1647
1744
|
__name: "Account",
|
|
1648
1745
|
setup(o) {
|
|
1649
|
-
return (s, e) => s.$solid.hasLoggedIn() ? (f(),
|
|
1746
|
+
return (s, e) => s.$solid.hasLoggedIn() ? (f(), D(hs, { key: 0 })) : (f(), D(fs, { key: 1 }));
|
|
1650
1747
|
}
|
|
1651
|
-
}),
|
|
1652
|
-
function
|
|
1748
|
+
}), ms = { $cloud: k };
|
|
1749
|
+
function Rs(o = {}) {
|
|
1653
1750
|
return {
|
|
1654
1751
|
name: "@aerogel/local-first",
|
|
1655
|
-
async install(
|
|
1656
|
-
|
|
1657
|
-
...ls,
|
|
1658
|
-
$_documentsCache: P
|
|
1659
|
-
});
|
|
1752
|
+
async install(s) {
|
|
1753
|
+
Dn.forEach((e) => Y.addSetting(e)), typeof o.manualSetup == "boolean" && (tt.manualSetup = o.manualSetup, k.manualSetup = o.manualSetup), await pt(s, ms);
|
|
1660
1754
|
}
|
|
1661
1755
|
};
|
|
1662
1756
|
}
|
|
1663
1757
|
export {
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1758
|
+
Ds as Account,
|
|
1759
|
+
hs as AccountLoggedIn,
|
|
1760
|
+
fs as AccountLoggedOut,
|
|
1761
|
+
nt as AccountLoginModal,
|
|
1762
|
+
as as AccountModal,
|
|
1763
|
+
k as Cloud,
|
|
1764
|
+
yn as CloudService,
|
|
1765
|
+
Rs as default
|
|
1672
1766
|
};
|
|
1673
1767
|
//# sourceMappingURL=aerogel-plugin-local-first.js.map
|