@canonical/dataviews-core 0.45.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +166 -0
- package/package.json +4 -3
- package/dist/esm/lib/collection/createCollectionCoordinator.js +0 -202
- package/dist/esm/lib/collection/createCollectionCoordinator.js.map +0 -1
- package/dist/esm/lib/collection/createSaveSession.js +0 -103
- package/dist/esm/lib/collection/createSaveSession.js.map +0 -1
- package/dist/esm/lib/createIdentity.js +0 -22
- package/dist/esm/lib/createIdentity.js.map +0 -1
- package/dist/esm/lib/field/createFieldInteraction.js +0 -80
- package/dist/esm/lib/field/createFieldInteraction.js.map +0 -1
- package/dist/esm/lib/field/index.js +0 -2
- package/dist/esm/lib/field/index.js.map +0 -1
- package/dist/esm/lib/geometry/columnTemplate.js +0 -38
- package/dist/esm/lib/geometry/columnTemplate.js.map +0 -1
- package/dist/esm/lib/geometry/createPresentation.js +0 -79
- package/dist/esm/lib/geometry/createPresentation.js.map +0 -1
- package/dist/esm/lib/geometry/sizingEquals.js +0 -10
- package/dist/esm/lib/geometry/sizingEquals.js.map +0 -1
- package/dist/esm/lib/identityBrand.js +0 -3
- package/dist/esm/lib/identityBrand.js.map +0 -1
- package/dist/esm/lib/isIdentity.js +0 -15
- package/dist/esm/lib/isIdentity.js.map +0 -1
- package/dist/esm/lib/location/createLocationBinding.js +0 -214
- package/dist/esm/lib/location/createLocationBinding.js.map +0 -1
- package/dist/esm/lib/operation/createOperation.js +0 -83
- package/dist/esm/lib/operation/createOperation.js.map +0 -1
- package/dist/esm/lib/operation/index.js +0 -2
- package/dist/esm/lib/operation/index.js.map +0 -1
- package/dist/esm/lib/query/canonicalSlice.js +0 -64
- package/dist/esm/lib/query/canonicalSlice.js.map +0 -1
- package/dist/esm/lib/query/defaultWindow.js +0 -11
- package/dist/esm/lib/query/defaultWindow.js.map +0 -1
- package/dist/esm/lib/query/sliceEquals.js +0 -30
- package/dist/esm/lib/query/sliceEquals.js.map +0 -1
- package/dist/esm/lib/source/createSourceBinding.js +0 -192
- package/dist/esm/lib/source/createSourceBinding.js.map +0 -1
- package/dist/esm/lib/source/reasonOf.js +0 -11
- package/dist/esm/lib/source/reasonOf.js.map +0 -1
- package/dist/esm/lib/source/supportsSlice.js +0 -68
- package/dist/esm/lib/source/supportsSlice.js.map +0 -1
- package/dist/esm/lib/views/createIndexedDBViewStore.js +0 -513
- package/dist/esm/lib/views/createIndexedDBViewStore.js.map +0 -1
- package/dist/esm/lib/views/createProviderViews.js +0 -573
- package/dist/esm/lib/views/createProviderViews.js.map +0 -1
- package/dist/esm/lib/wire/wireGrammar.js +0 -59
- package/dist/esm/lib/wire/wireGrammar.js.map +0 -1
- package/dist/types/lib/collection/createCollectionCoordinator.d.ts +0 -115
- package/dist/types/lib/collection/createCollectionCoordinator.d.ts.map +0 -1
- package/dist/types/lib/collection/createSaveSession.d.ts +0 -64
- package/dist/types/lib/collection/createSaveSession.d.ts.map +0 -1
- package/dist/types/lib/createIdentity.d.ts +0 -20
- package/dist/types/lib/createIdentity.d.ts.map +0 -1
- package/dist/types/lib/field/createFieldInteraction.d.ts +0 -77
- package/dist/types/lib/field/createFieldInteraction.d.ts.map +0 -1
- package/dist/types/lib/field/index.d.ts +0 -3
- package/dist/types/lib/field/index.d.ts.map +0 -1
- package/dist/types/lib/geometry/columnTemplate.d.ts +0 -21
- package/dist/types/lib/geometry/columnTemplate.d.ts.map +0 -1
- package/dist/types/lib/geometry/createPresentation.d.ts +0 -32
- package/dist/types/lib/geometry/createPresentation.d.ts.map +0 -1
- package/dist/types/lib/geometry/sizingEquals.d.ts +0 -4
- package/dist/types/lib/geometry/sizingEquals.d.ts.map +0 -1
- package/dist/types/lib/identityBrand.d.ts +0 -3
- package/dist/types/lib/identityBrand.d.ts.map +0 -1
- package/dist/types/lib/isIdentity.d.ts +0 -11
- package/dist/types/lib/isIdentity.d.ts.map +0 -1
- package/dist/types/lib/location/createLocationBinding.d.ts +0 -77
- package/dist/types/lib/location/createLocationBinding.d.ts.map +0 -1
- package/dist/types/lib/operation/createOperation.d.ts +0 -62
- package/dist/types/lib/operation/createOperation.d.ts.map +0 -1
- package/dist/types/lib/operation/index.d.ts +0 -3
- package/dist/types/lib/operation/index.d.ts.map +0 -1
- package/dist/types/lib/query/canonicalSlice.d.ts +0 -17
- package/dist/types/lib/query/canonicalSlice.d.ts.map +0 -1
- package/dist/types/lib/query/defaultWindow.d.ts +0 -9
- package/dist/types/lib/query/defaultWindow.d.ts.map +0 -1
- package/dist/types/lib/query/sliceEquals.d.ts +0 -7
- package/dist/types/lib/query/sliceEquals.d.ts.map +0 -1
- package/dist/types/lib/source/createSourceBinding.d.ts +0 -66
- package/dist/types/lib/source/createSourceBinding.d.ts.map +0 -1
- package/dist/types/lib/source/reasonOf.d.ts +0 -3
- package/dist/types/lib/source/reasonOf.d.ts.map +0 -1
- package/dist/types/lib/source/supportsSlice.d.ts +0 -9
- package/dist/types/lib/source/supportsSlice.d.ts.map +0 -1
- package/dist/types/lib/views/createIndexedDBViewStore.d.ts +0 -90
- package/dist/types/lib/views/createIndexedDBViewStore.d.ts.map +0 -1
- package/dist/types/lib/views/createProviderViews.d.ts +0 -53
- package/dist/types/lib/views/createProviderViews.d.ts.map +0 -1
- package/dist/types/lib/wire/wireGrammar.d.ts +0 -31
- package/dist/types/lib/wire/wireGrammar.d.ts.map +0 -1
|
@@ -1,513 +0,0 @@
|
|
|
1
|
-
import reasonOf from "../source/reasonOf.js";
|
|
2
|
-
/** The database schema this store creates. Version 1 is the first. */
|
|
3
|
-
const DATABASE_VERSION = 1;
|
|
4
|
-
/** The saved-view record format this store reads and writes. */
|
|
5
|
-
const RECORD_VERSION = 1;
|
|
6
|
-
const VIEWS = "views";
|
|
7
|
-
const PREFERENCES = "preferences";
|
|
8
|
-
/** Preference targets: pins, and presentation by target. */
|
|
9
|
-
const PINS = "pins";
|
|
10
|
-
const targetKey = (target) => target === "default" ? "default" : `view:${target.view}`;
|
|
11
|
-
/** Whether a stored record is a saved view in the format this store reads. */
|
|
12
|
-
const isStoredView = (record) => {
|
|
13
|
-
const { v, id, name, query, presentation, revision, createdAt, updatedAt } = record;
|
|
14
|
-
return (v === RECORD_VERSION &&
|
|
15
|
-
typeof id === "string" &&
|
|
16
|
-
typeof name === "string" &&
|
|
17
|
-
typeof query === "string" &&
|
|
18
|
-
typeof revision === "number" &&
|
|
19
|
-
Number.isInteger(revision) &&
|
|
20
|
-
revision >= 1 &&
|
|
21
|
-
typeof createdAt === "string" &&
|
|
22
|
-
typeof updatedAt === "string" &&
|
|
23
|
-
(presentation === undefined ||
|
|
24
|
-
(typeof presentation === "object" &&
|
|
25
|
-
presentation !== null &&
|
|
26
|
-
!Array.isArray(presentation))));
|
|
27
|
-
};
|
|
28
|
-
/** Why a stored record cannot be read as a saved view. */
|
|
29
|
-
const unreadableReason = (record) => record.v === RECORD_VERSION
|
|
30
|
-
? "the record does not have the shape of a saved view"
|
|
31
|
-
: `record version ${String(record.v)} is not the supported version ${RECORD_VERSION}`;
|
|
32
|
-
/** A stored saved view as this viewer sees it. */
|
|
33
|
-
const viewOf = (record, pinned) => ({
|
|
34
|
-
id: record.id,
|
|
35
|
-
name: record.name,
|
|
36
|
-
query: record.query,
|
|
37
|
-
presentation: record.presentation ?? null,
|
|
38
|
-
revision: record.revision,
|
|
39
|
-
pinned,
|
|
40
|
-
createdAt: record.createdAt,
|
|
41
|
-
updatedAt: record.updatedAt,
|
|
42
|
-
});
|
|
43
|
-
const disposedError = () => new Error("the view store is disposed");
|
|
44
|
-
/**
|
|
45
|
-
* Create a local-first view store over IndexedDB, scoped at construction
|
|
46
|
-
* to one collection and one partition of one application's database.
|
|
47
|
-
*
|
|
48
|
-
* View edits are transactional: an update or removal names the revision it
|
|
49
|
-
* was made against, and a stale one is an explicit conflict rather than a
|
|
50
|
-
* silent overwrite — so two tabs editing one view conflict. Presentation
|
|
51
|
-
* preferences are stored one record per key and patched atomically, so two
|
|
52
|
-
* tabs changing different keys both keep their change. Records in a format
|
|
53
|
-
* this store does not know are reported and left untouched, so an older
|
|
54
|
-
* client never destroys a newer one's data.
|
|
55
|
-
*
|
|
56
|
-
* Storage the browser blocks, has no room in, or cannot open rejects with
|
|
57
|
-
* the platform's error as the cause; nothing falls back to memory and
|
|
58
|
-
* claims to persist. Other tabs' writes reach `subscribe` through a
|
|
59
|
-
* BroadcastChannel where the platform has one. Import it explicitly from
|
|
60
|
-
* `@canonical/dataviews-core/views`.
|
|
61
|
-
*/
|
|
62
|
-
export default function createIndexedDBViewStore(config) {
|
|
63
|
-
const scope = JSON.stringify([config.collection, config.partition]);
|
|
64
|
-
const listeners = new Set();
|
|
65
|
-
const channelName = JSON.stringify([
|
|
66
|
-
"@canonical/dataviews-core",
|
|
67
|
-
config.database,
|
|
68
|
-
scope,
|
|
69
|
-
]);
|
|
70
|
-
const channel = typeof BroadcastChannel === "undefined"
|
|
71
|
-
? null
|
|
72
|
-
: new BroadcastChannel(channelName);
|
|
73
|
-
let connection = null;
|
|
74
|
-
let disposed = false;
|
|
75
|
-
/**
|
|
76
|
-
* Call each listener in a microtask of its own, as the platform calls event
|
|
77
|
-
* listeners: one that throws is reported without stopping the others,
|
|
78
|
-
* and never turns a committed write into a rejected one.
|
|
79
|
-
*/
|
|
80
|
-
const notify = () => {
|
|
81
|
-
for (const listener of listeners) {
|
|
82
|
-
queueMicrotask(() => {
|
|
83
|
-
if (listeners.has(listener)) {
|
|
84
|
-
listener();
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
if (channel !== null) {
|
|
90
|
-
channel.onmessage = notify;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Tell this tab's listeners and every other store of this scope. A write
|
|
94
|
-
* committing after dispose has no listener here left to tell, but other
|
|
95
|
-
* tabs still hear of it.
|
|
96
|
-
*/
|
|
97
|
-
const announce = () => {
|
|
98
|
-
if (disposed) {
|
|
99
|
-
if (channel !== null) {
|
|
100
|
-
const parting = new BroadcastChannel(channelName);
|
|
101
|
-
parting.postMessage(null);
|
|
102
|
-
parting.close();
|
|
103
|
-
}
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
channel?.postMessage(null);
|
|
107
|
-
notify();
|
|
108
|
-
};
|
|
109
|
-
const open = (forget) => new Promise((resolve, reject) => {
|
|
110
|
-
const unavailable = (error) => {
|
|
111
|
-
reject(new Error(`view storage is unavailable: ${reasonOf(error)}`, {
|
|
112
|
-
cause: error,
|
|
113
|
-
}));
|
|
114
|
-
};
|
|
115
|
-
let request;
|
|
116
|
-
try {
|
|
117
|
-
request = config.indexedDB.open(config.database, DATABASE_VERSION);
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
unavailable(error);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
// The first version: an upgrade only ever starts from nothing.
|
|
124
|
-
request.onupgradeneeded = () => {
|
|
125
|
-
const database = request.result;
|
|
126
|
-
database
|
|
127
|
-
.createObjectStore(VIEWS, { keyPath: ["scope", "id"] })
|
|
128
|
-
.createIndex("scope", "scope");
|
|
129
|
-
database
|
|
130
|
-
.createObjectStore(PREFERENCES, {
|
|
131
|
-
keyPath: ["scope", "target", "key"],
|
|
132
|
-
})
|
|
133
|
-
.createIndex("target", ["scope", "target"]);
|
|
134
|
-
};
|
|
135
|
-
request.onerror = () => {
|
|
136
|
-
unavailable(request.error);
|
|
137
|
-
};
|
|
138
|
-
request.onsuccess = () => {
|
|
139
|
-
const database = request.result;
|
|
140
|
-
// Another tab upgrading or deleting the database, or the platform
|
|
141
|
-
// closing it, ends this connection; the next call opens a new one.
|
|
142
|
-
const close = () => {
|
|
143
|
-
database.close();
|
|
144
|
-
forget();
|
|
145
|
-
};
|
|
146
|
-
database.onversionchange = close;
|
|
147
|
-
database.onclose = close;
|
|
148
|
-
if (disposed) {
|
|
149
|
-
database.close();
|
|
150
|
-
reject(disposedError());
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
resolve(database);
|
|
154
|
-
};
|
|
155
|
-
});
|
|
156
|
-
const connect = () => {
|
|
157
|
-
if (disposed) {
|
|
158
|
-
return Promise.reject(disposedError());
|
|
159
|
-
}
|
|
160
|
-
if (connection === null) {
|
|
161
|
-
const opening = open(() => {
|
|
162
|
-
if (connection === opening) {
|
|
163
|
-
connection = null;
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
connection = opening;
|
|
167
|
-
// A failed open is not kept: the next call retries.
|
|
168
|
-
opening.catch(() => {
|
|
169
|
-
if (connection === opening) {
|
|
170
|
-
connection = null;
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
return connection;
|
|
175
|
-
};
|
|
176
|
-
/**
|
|
177
|
-
* Run one transaction over both stores. `work` issues its requests and
|
|
178
|
-
* returns how to read the outcome, which is read only once the
|
|
179
|
-
* transaction commits: a resolved write is a committed one, under the
|
|
180
|
-
* browser's default durability. A transaction that wrote something is
|
|
181
|
-
* announced as it commits; one that wrote nothing is not. Anything
|
|
182
|
-
* thrown aborts the transaction, which rejects.
|
|
183
|
-
*/
|
|
184
|
-
const transact = async (mode, work) => {
|
|
185
|
-
const database = await connect();
|
|
186
|
-
return new Promise((resolve, reject) => {
|
|
187
|
-
const failed = (error) => {
|
|
188
|
-
reject(new Error(`view storage failed: ${reasonOf(error)}`, {
|
|
189
|
-
cause: error,
|
|
190
|
-
}));
|
|
191
|
-
};
|
|
192
|
-
let transaction;
|
|
193
|
-
try {
|
|
194
|
-
transaction = database.transaction([VIEWS, PREFERENCES], mode);
|
|
195
|
-
}
|
|
196
|
-
catch (error) {
|
|
197
|
-
failed(error);
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
/** What aborted the transaction, when this store did. */
|
|
201
|
-
let thrown = null;
|
|
202
|
-
const abort = (error) => {
|
|
203
|
-
thrown = { error };
|
|
204
|
-
transaction.abort();
|
|
205
|
-
};
|
|
206
|
-
const step = (request, then) => {
|
|
207
|
-
request.onsuccess = () => {
|
|
208
|
-
try {
|
|
209
|
-
then(request.result);
|
|
210
|
-
}
|
|
211
|
-
catch (error) {
|
|
212
|
-
abort(error);
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
};
|
|
216
|
-
/** Whether this transaction issued a write. */
|
|
217
|
-
let wrote = false;
|
|
218
|
-
const tracked = (store) => ({
|
|
219
|
-
get(key) {
|
|
220
|
-
return store.get(key);
|
|
221
|
-
},
|
|
222
|
-
index(name) {
|
|
223
|
-
return store.index(name);
|
|
224
|
-
},
|
|
225
|
-
put(value) {
|
|
226
|
-
wrote = true;
|
|
227
|
-
return store.put(value);
|
|
228
|
-
},
|
|
229
|
-
delete(key) {
|
|
230
|
-
wrote = true;
|
|
231
|
-
return store.delete(key);
|
|
232
|
-
},
|
|
233
|
-
});
|
|
234
|
-
let outcome;
|
|
235
|
-
transaction.oncomplete = () => {
|
|
236
|
-
if (wrote) {
|
|
237
|
-
announce();
|
|
238
|
-
}
|
|
239
|
-
resolve(outcome());
|
|
240
|
-
};
|
|
241
|
-
transaction.onabort = () => {
|
|
242
|
-
failed(thrown === null ? transaction.error : thrown.error);
|
|
243
|
-
};
|
|
244
|
-
try {
|
|
245
|
-
outcome = work({
|
|
246
|
-
views: tracked(transaction.objectStore(VIEWS)),
|
|
247
|
-
preferences: tracked(transaction.objectStore(PREFERENCES)),
|
|
248
|
-
}, step);
|
|
249
|
-
}
|
|
250
|
-
catch (error) {
|
|
251
|
-
abort(error);
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
};
|
|
255
|
-
/** A read, which a store disposed meanwhile never delivers. */
|
|
256
|
-
const read = async (work) => {
|
|
257
|
-
const outcome = await transact("readonly", work);
|
|
258
|
-
if (disposed) {
|
|
259
|
-
throw disposedError();
|
|
260
|
-
}
|
|
261
|
-
return outcome;
|
|
262
|
-
};
|
|
263
|
-
/** Look one view up with its pin, then continue in the same transaction. */
|
|
264
|
-
const lookUp = ({ views, preferences }, step, id, then) => {
|
|
265
|
-
const viewRequest = views.get([scope, id]);
|
|
266
|
-
// Requests in one transaction complete in order: the view is in hand
|
|
267
|
-
// by the time the pin is.
|
|
268
|
-
step(preferences.get([scope, PINS, id]), (pin) => {
|
|
269
|
-
const record = viewRequest.result;
|
|
270
|
-
if (record === undefined) {
|
|
271
|
-
then({ status: "missing" });
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
then(isStoredView(record)
|
|
275
|
-
? { status: "found", view: viewOf(record, pin !== undefined), record }
|
|
276
|
-
: { status: "unreadable", reason: unreadableReason(record) });
|
|
277
|
-
});
|
|
278
|
-
};
|
|
279
|
-
/** Delete one view's pin and its own presentation preferences. */
|
|
280
|
-
const forgetPreferences = ({ preferences }, step, id) => {
|
|
281
|
-
preferences.delete([scope, PINS, id]);
|
|
282
|
-
step(preferences.index("target").getAllKeys([scope, targetKey({ view: id })]), (keys) => {
|
|
283
|
-
for (const key of keys) {
|
|
284
|
-
preferences.delete(key);
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
};
|
|
288
|
-
/**
|
|
289
|
-
* Pin or unpin a view that exists. Either twice is either once, and the
|
|
290
|
-
* second writes nothing.
|
|
291
|
-
*/
|
|
292
|
-
const setPin = (id, pinned) => transact("readwrite", ({ views, preferences }, step) => {
|
|
293
|
-
let exists = false;
|
|
294
|
-
const pinRequest = preferences.get([scope, PINS, id]);
|
|
295
|
-
// Requests in one transaction complete in order: the pin is in hand
|
|
296
|
-
// by the time the view is.
|
|
297
|
-
step(views.get([scope, id]), (record) => {
|
|
298
|
-
exists = record !== undefined;
|
|
299
|
-
if (!exists || (pinRequest.result !== undefined) === pinned) {
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
if (pinned) {
|
|
303
|
-
preferences.put({ scope, target: PINS, key: id, value: true });
|
|
304
|
-
}
|
|
305
|
-
else {
|
|
306
|
-
preferences.delete([scope, PINS, id]);
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
return () => ({ status: exists ? "saved" : "missing" });
|
|
310
|
-
});
|
|
311
|
-
const stamp = () => new Date().toISOString();
|
|
312
|
-
return {
|
|
313
|
-
list() {
|
|
314
|
-
return read(({ views, preferences }, step) => {
|
|
315
|
-
const viewsRequest = views.index("scope").getAll(scope);
|
|
316
|
-
let listed = { views: [], unreadable: [] };
|
|
317
|
-
step(preferences.index("target").getAll([scope, PINS]), (pins) => {
|
|
318
|
-
const pinned = new Set(pins.map((pin) => pin.key));
|
|
319
|
-
const found = [];
|
|
320
|
-
const unreadable = [];
|
|
321
|
-
for (const record of viewsRequest.result) {
|
|
322
|
-
if (isStoredView(record)) {
|
|
323
|
-
found.push(viewOf(record, pinned.has(record.id)));
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
unreadable.push({
|
|
327
|
-
id: String(record.id),
|
|
328
|
-
reason: unreadableReason(record),
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
listed = { views: found, unreadable };
|
|
333
|
-
});
|
|
334
|
-
return () => listed;
|
|
335
|
-
});
|
|
336
|
-
},
|
|
337
|
-
get(id) {
|
|
338
|
-
return read((stores, step) => {
|
|
339
|
-
let found = { status: "missing" };
|
|
340
|
-
lookUp(stores, step, id, (looked) => {
|
|
341
|
-
// The stored record stays inside the store.
|
|
342
|
-
found =
|
|
343
|
-
looked.status === "found"
|
|
344
|
-
? { status: "found", view: looked.view }
|
|
345
|
-
: looked;
|
|
346
|
-
});
|
|
347
|
-
return () => found;
|
|
348
|
-
});
|
|
349
|
-
},
|
|
350
|
-
create(draft) {
|
|
351
|
-
return transact("readwrite", (stores, step) => {
|
|
352
|
-
// Always set by the lookup before the transaction commits.
|
|
353
|
-
let written;
|
|
354
|
-
lookUp(stores, step, draft.id, (found) => {
|
|
355
|
-
if (found.status === "unreadable") {
|
|
356
|
-
written = found;
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
if (found.status === "found") {
|
|
360
|
-
const { view } = found;
|
|
361
|
-
// The same creation arriving again: an earlier attempt landed.
|
|
362
|
-
const replayed = view.revision === 1 &&
|
|
363
|
-
view.name === draft.name &&
|
|
364
|
-
view.query === draft.query &&
|
|
365
|
-
JSON.stringify(view.presentation) ===
|
|
366
|
-
JSON.stringify(draft.presentation ?? null);
|
|
367
|
-
written = { status: replayed ? "saved" : "conflict", view };
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
const now = stamp();
|
|
371
|
-
const record = {
|
|
372
|
-
scope,
|
|
373
|
-
id: draft.id,
|
|
374
|
-
v: RECORD_VERSION,
|
|
375
|
-
name: draft.name,
|
|
376
|
-
query: draft.query,
|
|
377
|
-
...(draft.presentation === undefined
|
|
378
|
-
? {}
|
|
379
|
-
: { presentation: draft.presentation }),
|
|
380
|
-
revision: 1,
|
|
381
|
-
createdAt: now,
|
|
382
|
-
updatedAt: now,
|
|
383
|
-
};
|
|
384
|
-
stores.views.put(record);
|
|
385
|
-
written = { status: "saved", view: viewOf(record, false) };
|
|
386
|
-
});
|
|
387
|
-
return () => written;
|
|
388
|
-
});
|
|
389
|
-
},
|
|
390
|
-
update({ id, revision }, changes) {
|
|
391
|
-
return transact("readwrite", (stores, step) => {
|
|
392
|
-
let written = { status: "missing" };
|
|
393
|
-
lookUp(stores, step, id, (found) => {
|
|
394
|
-
if (found.status !== "found") {
|
|
395
|
-
written = found;
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
if (found.view.revision !== revision) {
|
|
399
|
-
written = { status: "conflict", view: found.view };
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
// Fields this client does not know are carried over untouched.
|
|
403
|
-
const { presentation: _dropped, ...kept } = found.record;
|
|
404
|
-
const presentation = changes.presentation === undefined
|
|
405
|
-
? found.view.presentation
|
|
406
|
-
: changes.presentation;
|
|
407
|
-
const record = {
|
|
408
|
-
...kept,
|
|
409
|
-
name: changes.name ?? found.view.name,
|
|
410
|
-
query: changes.query ?? found.view.query,
|
|
411
|
-
...(presentation === null ? {} : { presentation }),
|
|
412
|
-
revision: revision + 1,
|
|
413
|
-
updatedAt: stamp(),
|
|
414
|
-
};
|
|
415
|
-
stores.views.put(record);
|
|
416
|
-
written = {
|
|
417
|
-
status: "saved",
|
|
418
|
-
view: viewOf(record, found.view.pinned),
|
|
419
|
-
};
|
|
420
|
-
});
|
|
421
|
-
return () => written;
|
|
422
|
-
});
|
|
423
|
-
},
|
|
424
|
-
remove({ id, revision }) {
|
|
425
|
-
return transact("readwrite", (stores, step) => {
|
|
426
|
-
let removal = {
|
|
427
|
-
status: "removed",
|
|
428
|
-
};
|
|
429
|
-
lookUp(stores, step, id, (found) => {
|
|
430
|
-
if (found.status === "unreadable") {
|
|
431
|
-
removal = found;
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
if (found.status === "found") {
|
|
435
|
-
if (found.view.revision !== revision) {
|
|
436
|
-
removal = { status: "conflict", view: found.view };
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
stores.views.delete([scope, id]);
|
|
440
|
-
forgetPreferences(stores, step, id);
|
|
441
|
-
}
|
|
442
|
-
// A view already gone was removed with its preferences.
|
|
443
|
-
});
|
|
444
|
-
return () => removal;
|
|
445
|
-
});
|
|
446
|
-
},
|
|
447
|
-
pin(id) {
|
|
448
|
-
return setPin(id, true);
|
|
449
|
-
},
|
|
450
|
-
unpin(id) {
|
|
451
|
-
return setPin(id, false);
|
|
452
|
-
},
|
|
453
|
-
readPresentation(target) {
|
|
454
|
-
return read(({ preferences }, step) => {
|
|
455
|
-
const presentation = {};
|
|
456
|
-
step(preferences.index("target").getAll([scope, targetKey(target)]), (records) => {
|
|
457
|
-
for (const record of records) {
|
|
458
|
-
presentation[record.key] = record.value;
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
return () => presentation;
|
|
462
|
-
});
|
|
463
|
-
},
|
|
464
|
-
patchPresentation(target, patch) {
|
|
465
|
-
return transact("readwrite", ({ views, preferences }, step) => {
|
|
466
|
-
const key = targetKey(target);
|
|
467
|
-
const apply = () => {
|
|
468
|
-
for (const [name, value] of Object.entries(patch)) {
|
|
469
|
-
if (value === undefined) {
|
|
470
|
-
preferences.delete([scope, key, name]);
|
|
471
|
-
}
|
|
472
|
-
else {
|
|
473
|
-
preferences.put({ scope, target: key, key: name, value });
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
if (target === "default") {
|
|
478
|
-
apply();
|
|
479
|
-
return () => ({ status: "saved" });
|
|
480
|
-
}
|
|
481
|
-
let exists = false;
|
|
482
|
-
step(views.get([scope, target.view]), (record) => {
|
|
483
|
-
exists = record !== undefined;
|
|
484
|
-
if (exists) {
|
|
485
|
-
apply();
|
|
486
|
-
}
|
|
487
|
-
});
|
|
488
|
-
return () => ({ status: exists ? "saved" : "missing" });
|
|
489
|
-
});
|
|
490
|
-
},
|
|
491
|
-
subscribe(listener) {
|
|
492
|
-
// A disposed store announces nothing, so a late listener never hears.
|
|
493
|
-
listeners.add(listener);
|
|
494
|
-
return () => {
|
|
495
|
-
listeners.delete(listener);
|
|
496
|
-
};
|
|
497
|
-
},
|
|
498
|
-
dispose() {
|
|
499
|
-
if (disposed) {
|
|
500
|
-
return;
|
|
501
|
-
}
|
|
502
|
-
disposed = true;
|
|
503
|
-
listeners.clear();
|
|
504
|
-
channel?.close();
|
|
505
|
-
const closing = connection;
|
|
506
|
-
connection = null;
|
|
507
|
-
closing?.then((database) => {
|
|
508
|
-
database.close();
|
|
509
|
-
}, () => { });
|
|
510
|
-
},
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
//# sourceMappingURL=createIndexedDBViewStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createIndexedDBViewStore.js","sourceRoot":"","sources":["../../../../src/lib/views/createIndexedDBViewStore.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AA+F7C,sEAAsE;AACtE,MAAM,gBAAgB,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