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