@mdbase-dev/sdk 0.2.61 → 0.2.63
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/app-storage/app-binary-index.js +31 -23
- package/dist/app-storage/app-binary-index.js.map +1 -1
- package/dist/app-storage/sqlite-index.js +6 -6
- package/dist/app-storage/sqlite-index.js.map +1 -1
- package/dist/application/asset-pins.json +4 -4
- package/dist/application/setup.js +10 -6
- package/dist/application/setup.js.map +1 -1
- package/dist/application/worker-host.js +6 -0
- package/dist/application/worker-host.js.map +1 -1
- package/dist/application/worker.js +189 -52
- package/dist/browser/mdbase-sdk.js +197 -61
- package/dist/browser/mdbase-sdk.min.js +49 -49
- package/dist/cbor.js +11 -1
- package/dist/cbor.js.map +1 -1
- package/dist/describe-error.js +1 -1
- package/dist/describe-error.js.map +1 -1
- package/dist/native/provenance.json +5 -5
- package/dist/native/runtime.wasm +0 -0
- package/dist/records/session.d.ts +10 -1
- package/dist/records/session.js +167 -23
- package/dist/records/session.js.map +1 -1
- package/package.json +1 -1
|
@@ -140,6 +140,7 @@ var MdbaseSDK = (() => {
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
function encodeText(w, s) {
|
|
143
|
+
if (s.length < 24 && !/[^\x00-\x7f]/u.test(s)) return w.shortAscii(s);
|
|
143
144
|
if (!isWellFormed(s)) throw new CborError("utf8", "text is not well-formed UTF-16");
|
|
144
145
|
const b = textEncoder.encode(s);
|
|
145
146
|
try {
|
|
@@ -234,7 +235,7 @@ var MdbaseSDK = (() => {
|
|
|
234
235
|
}
|
|
235
236
|
function toHex(b) {
|
|
236
237
|
let s = "";
|
|
237
|
-
for (const x of b) s += x
|
|
238
|
+
for (const x of b) s += hexBytes[x];
|
|
238
239
|
return s;
|
|
239
240
|
}
|
|
240
241
|
function fromHex(s) {
|
|
@@ -248,7 +249,7 @@ var MdbaseSDK = (() => {
|
|
|
248
249
|
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
249
250
|
return true;
|
|
250
251
|
}
|
|
251
|
-
var Float64, MAX_DEPTH, CborError, U64_MAX, I64_MIN, textEncoder, textDecoder, Writer, Reader;
|
|
252
|
+
var Float64, MAX_DEPTH, CborError, U64_MAX, I64_MIN, textEncoder, textDecoder, Writer, Reader, hexBytes;
|
|
252
253
|
var init_cbor = __esm({
|
|
253
254
|
"src/cbor.ts"() {
|
|
254
255
|
"use strict";
|
|
@@ -304,6 +305,12 @@ var MdbaseSDK = (() => {
|
|
|
304
305
|
this.buf.set(b, this.len);
|
|
305
306
|
this.len += b.length;
|
|
306
307
|
}
|
|
308
|
+
/** For short ASCII text, the UTF-8 length fits in the initial CBOR byte. */
|
|
309
|
+
shortAscii(s) {
|
|
310
|
+
this.ensure(1 + s.length);
|
|
311
|
+
this.buf[this.len++] = 96 | s.length;
|
|
312
|
+
for (let i = 0; i < s.length; i++) this.buf[this.len++] = s.charCodeAt(i);
|
|
313
|
+
}
|
|
307
314
|
head(major, arg) {
|
|
308
315
|
const m2 = major << 5;
|
|
309
316
|
if (typeof arg === "number" && arg < 24) {
|
|
@@ -495,6 +502,7 @@ var MdbaseSDK = (() => {
|
|
|
495
502
|
}
|
|
496
503
|
}
|
|
497
504
|
};
|
|
505
|
+
hexBytes = Array.from({ length: 256 }, (_, n) => n.toString(16).padStart(2, "0"));
|
|
498
506
|
}
|
|
499
507
|
});
|
|
500
508
|
|
|
@@ -4996,8 +5004,11 @@ var MdbaseSDK = (() => {
|
|
|
4996
5004
|
});
|
|
4997
5005
|
|
|
4998
5006
|
// src/records/session.ts
|
|
4999
|
-
function
|
|
5000
|
-
|
|
5007
|
+
function matches(record5, key3, value2) {
|
|
5008
|
+
if (key3 === null) return value2 === record5.body;
|
|
5009
|
+
const actual = fieldOf(record5.frontmatter, key3);
|
|
5010
|
+
if (actual === void 0 || value2 === void 0) return actual === value2;
|
|
5011
|
+
return equal(toValue(actual), toValue(toPlain(value2)));
|
|
5001
5012
|
}
|
|
5002
5013
|
function equal(a, b) {
|
|
5003
5014
|
const x = encode(a), y = encode(b);
|
|
@@ -5046,6 +5057,7 @@ var MdbaseSDK = (() => {
|
|
|
5046
5057
|
init_errors();
|
|
5047
5058
|
init_session();
|
|
5048
5059
|
init_values();
|
|
5060
|
+
init_plain();
|
|
5049
5061
|
init_witness();
|
|
5050
5062
|
RecordSessionImpl = class {
|
|
5051
5063
|
constructor(client, record5, reserve) {
|
|
@@ -5054,7 +5066,7 @@ var MdbaseSDK = (() => {
|
|
|
5054
5066
|
complete(record5);
|
|
5055
5067
|
this.base = copy(record5);
|
|
5056
5068
|
this.body = record5.body;
|
|
5057
|
-
this.state = isProtected(record5) ? "conflict" :
|
|
5069
|
+
this.state = isProtected(record5) ? "conflict" : this.restState;
|
|
5058
5070
|
this.publish();
|
|
5059
5071
|
}
|
|
5060
5072
|
client;
|
|
@@ -5064,6 +5076,8 @@ var MdbaseSDK = (() => {
|
|
|
5064
5076
|
patch = /* @__PURE__ */ new Map();
|
|
5065
5077
|
remote = null;
|
|
5066
5078
|
captured = null;
|
|
5079
|
+
pendingEdits = /* @__PURE__ */ new Map();
|
|
5080
|
+
driveGeneration = 0;
|
|
5067
5081
|
lastReceipt = null;
|
|
5068
5082
|
state;
|
|
5069
5083
|
why = null;
|
|
@@ -5104,6 +5118,24 @@ var MdbaseSDK = (() => {
|
|
|
5104
5118
|
recovery: { ...hint, receipt: null, write: null }
|
|
5105
5119
|
};
|
|
5106
5120
|
}
|
|
5121
|
+
if (!this.active && !hint && this.base.state.state === "pending" && !this.pendingEdits.size) {
|
|
5122
|
+
const edits = /* @__PURE__ */ new Map();
|
|
5123
|
+
for (const { ops, receipt: receipt4 } of await this.client.pendingWrites({ signal })) {
|
|
5124
|
+
for (const op2 of ops) {
|
|
5125
|
+
if (op2.kind !== "update" || op2.id !== this.id) continue;
|
|
5126
|
+
const mutation2 = receipt4.mutation;
|
|
5127
|
+
if (op2.body !== void 0 || op2.bodyEdits?.length) {
|
|
5128
|
+
const body = op2.body ?? receipt4.records?.find((record5) => record5.id === this.id)?.body ?? this.base.body;
|
|
5129
|
+
edits.set(null, { mutation: mutation2, value: body });
|
|
5130
|
+
}
|
|
5131
|
+
for (const [key3, value2] of Object.entries(op2.patch ?? {}))
|
|
5132
|
+
edits.set(key3, { mutation: mutation2, value: toValue(value2) });
|
|
5133
|
+
for (const key3 of op2.unset ?? []) edits.set(key3, { mutation: mutation2, value: void 0 });
|
|
5134
|
+
}
|
|
5135
|
+
}
|
|
5136
|
+
this.charge(this.body, this.patch, this.base, this.remote, this.lastReceipt, this.captured, edits);
|
|
5137
|
+
this.pendingEdits = edits;
|
|
5138
|
+
}
|
|
5107
5139
|
signal?.throwIfAborted();
|
|
5108
5140
|
if (this.captured) {
|
|
5109
5141
|
this.state = "recovery";
|
|
@@ -5121,8 +5153,11 @@ var MdbaseSDK = (() => {
|
|
|
5121
5153
|
get dirty() {
|
|
5122
5154
|
return this.body !== this.base.body || this.patch.size > 0;
|
|
5123
5155
|
}
|
|
5156
|
+
get restState() {
|
|
5157
|
+
return !this.pendingEdits.size && confirmed(this.base) ? "saved" : "saved_on_device";
|
|
5158
|
+
}
|
|
5124
5159
|
get retained() {
|
|
5125
|
-
return this.dirty || this.captured !== null || !confirmed(this.base);
|
|
5160
|
+
return this.dirty || this.captured !== null || this.pendingEdits.size > 0 || !confirmed(this.base);
|
|
5126
5161
|
}
|
|
5127
5162
|
getSnapshot = () => this.snapshot;
|
|
5128
5163
|
subscribe = (listener) => {
|
|
@@ -5172,13 +5207,13 @@ var MdbaseSDK = (() => {
|
|
|
5172
5207
|
};
|
|
5173
5208
|
edited() {
|
|
5174
5209
|
if (!this.captured && this.state !== "conflict" && this.state !== "deleted") {
|
|
5175
|
-
this.state = this.dirty ? "unsaved" :
|
|
5210
|
+
this.state = this.dirty ? "unsaved" : this.restState;
|
|
5176
5211
|
this.why = null;
|
|
5177
5212
|
}
|
|
5178
5213
|
this.publish();
|
|
5179
5214
|
this.schedule();
|
|
5180
5215
|
}
|
|
5181
|
-
charge(body = this.body, patch = this.patch, base = this.base, remote = this.remote, receipt4 = this.lastReceipt, captured = this.captured) {
|
|
5216
|
+
charge(body = this.body, patch = this.patch, base = this.base, remote = this.remote, receipt4 = this.lastReceipt, captured = this.captured, pendingEdits = this.pendingEdits) {
|
|
5182
5217
|
let bytes10 = retainedBytes(base) + textBytes(body) + encode(new Map([...patch].map(([k, v]) => [k, v ?? null]))).byteLength * 2;
|
|
5183
5218
|
if (remote) bytes10 += retainedBytes(remote);
|
|
5184
5219
|
if (captured)
|
|
@@ -5187,6 +5222,8 @@ var MdbaseSDK = (() => {
|
|
|
5187
5222
|
[...captured.patch].map(([k, v]) => [k, v ?? null])
|
|
5188
5223
|
)
|
|
5189
5224
|
).byteLength * 2;
|
|
5225
|
+
for (const [key3, edit] of pendingEdits)
|
|
5226
|
+
bytes10 += encode([key3, edit.mutation, edit.value ?? null]).byteLength * 2;
|
|
5190
5227
|
if (receipt4) bytes10 += retainedBytes(receipt4);
|
|
5191
5228
|
this.reserve(bytes10);
|
|
5192
5229
|
}
|
|
@@ -5237,6 +5274,73 @@ var MdbaseSDK = (() => {
|
|
|
5237
5274
|
complete(record5, this.id);
|
|
5238
5275
|
return record5;
|
|
5239
5276
|
}
|
|
5277
|
+
/** The projection can change after either a refusal or a successful write
|
|
5278
|
+
* followed by a peer edit. Only the original MID distinguishes them. */
|
|
5279
|
+
async readWithReceipts(signal) {
|
|
5280
|
+
const receipts = /* @__PURE__ */ new Map();
|
|
5281
|
+
for (; ; ) {
|
|
5282
|
+
const current3 = await this.read(signal);
|
|
5283
|
+
if (this.captured) return { current: current3, receipts };
|
|
5284
|
+
const count = receipts.size;
|
|
5285
|
+
for (const [key3, { mutation: mutation2, value: value2 }] of this.pendingEdits) {
|
|
5286
|
+
const present2 = matches(current3, key3, value2);
|
|
5287
|
+
if (!confirmed(current3) && present2) continue;
|
|
5288
|
+
if (!receipts.has(mutation2)) {
|
|
5289
|
+
const receipt5 = await this.client.receipt(mutation2, { signal });
|
|
5290
|
+
signal.throwIfAborted();
|
|
5291
|
+
if (receipt5.mutation !== mutation2)
|
|
5292
|
+
throw refusal("outcome_unknown", "native receipt changed identity", "mutation_identity_mismatch");
|
|
5293
|
+
receipts.set(mutation2, receipt5);
|
|
5294
|
+
}
|
|
5295
|
+
const receipt4 = receipts.get(mutation2);
|
|
5296
|
+
if (receipt4.state === "unknown" || receipt4.state === "pending" && !present2)
|
|
5297
|
+
throw refusal("outcome_unknown", "the projection does not qualify this device write yet", "unqualified_readback");
|
|
5298
|
+
}
|
|
5299
|
+
if (receipts.size === count) return { current: current3, receipts };
|
|
5300
|
+
}
|
|
5301
|
+
}
|
|
5302
|
+
/** Restore only a refused write's missing edits. Newer typing and field
|
|
5303
|
+
* edits win, including an explicit unset; unrelated remote fields survive. */
|
|
5304
|
+
reconcilePending(current3, receipts) {
|
|
5305
|
+
if (!receipts.size) return;
|
|
5306
|
+
const remaining = new Map(this.pendingEdits);
|
|
5307
|
+
const patch = new Map(this.patch);
|
|
5308
|
+
const bodyEdited = this.body !== this.base.body;
|
|
5309
|
+
let body = bodyEdited ? this.body : current3.body;
|
|
5310
|
+
let rolledBack = false;
|
|
5311
|
+
for (const [key3, { mutation: mutation2, value: value2 }] of this.pendingEdits) {
|
|
5312
|
+
const receipt4 = receipts.get(mutation2);
|
|
5313
|
+
if (!receipt4 || receipt4.state === "pending" || receipt4.state === "unknown") continue;
|
|
5314
|
+
remaining.delete(key3);
|
|
5315
|
+
if (receipt4.state !== "rejected" && receipt4.status !== "conflicted" || matches(current3, key3, value2)) continue;
|
|
5316
|
+
rolledBack = true;
|
|
5317
|
+
if (key3 === null) {
|
|
5318
|
+
if (!bodyEdited) body = value2;
|
|
5319
|
+
} else if (!patch.has(key3)) {
|
|
5320
|
+
patch.set(key3, value2);
|
|
5321
|
+
}
|
|
5322
|
+
}
|
|
5323
|
+
const last = this.lastReceipt && (receipts.get(this.lastReceipt.mutation) ?? this.lastReceipt);
|
|
5324
|
+
if (rolledBack) {
|
|
5325
|
+
for (const [key3, value2] of patch) {
|
|
5326
|
+
if (matches(current3, key3, value2)) patch.delete(key3);
|
|
5327
|
+
}
|
|
5328
|
+
const differs = body !== current3.body || patch.size > 0;
|
|
5329
|
+
this.charge(body, patch, current3, differs ? current3 : null, last, this.captured, remaining);
|
|
5330
|
+
this.base = copy(current3);
|
|
5331
|
+
this.remote = differs ? copy(current3) : null;
|
|
5332
|
+
this.body = body;
|
|
5333
|
+
this.patch = patch;
|
|
5334
|
+
if (differs) {
|
|
5335
|
+
this.state = "conflict";
|
|
5336
|
+
this.why = refusal("conflict", "a device write was refused at head", "record_session_conflict").toProblem();
|
|
5337
|
+
}
|
|
5338
|
+
} else {
|
|
5339
|
+
this.charge(this.body, this.patch, this.base, this.remote, last, this.captured, remaining);
|
|
5340
|
+
}
|
|
5341
|
+
this.pendingEdits = remaining;
|
|
5342
|
+
this.lastReceipt = last;
|
|
5343
|
+
}
|
|
5240
5344
|
/** Native change notifications are hints only; hydrate the same UUID. */
|
|
5241
5345
|
refresh = () => {
|
|
5242
5346
|
if (!this.active) return Promise.resolve();
|
|
@@ -5248,20 +5352,26 @@ var MdbaseSDK = (() => {
|
|
|
5248
5352
|
this.refreshRunning = (async () => {
|
|
5249
5353
|
do {
|
|
5250
5354
|
this.refreshAgain = false;
|
|
5355
|
+
const generation = this.driveGeneration;
|
|
5251
5356
|
try {
|
|
5252
|
-
const current3 = await this.
|
|
5357
|
+
const { current: current3, receipts } = await this.readWithReceipts(signal);
|
|
5358
|
+
if (generation !== this.driveGeneration) {
|
|
5359
|
+
this.refreshAgain = true;
|
|
5360
|
+
continue;
|
|
5361
|
+
}
|
|
5253
5362
|
if (this.captured || this.running) {
|
|
5254
5363
|
if (this.captured && !this.running)
|
|
5255
5364
|
void this.start(false, {}).catch(() => {
|
|
5256
5365
|
});
|
|
5257
5366
|
continue;
|
|
5258
5367
|
}
|
|
5368
|
+
this.reconcilePending(current3, receipts);
|
|
5259
5369
|
this.charge(this.body, this.patch, this.base, current3);
|
|
5260
5370
|
if (!this.dirty) {
|
|
5261
5371
|
this.base = copy(current3);
|
|
5262
5372
|
this.body = current3.body;
|
|
5263
5373
|
this.remote = null;
|
|
5264
|
-
this.state = isProtected(current3) ? "conflict" :
|
|
5374
|
+
this.state = isProtected(current3) ? "conflict" : this.restState;
|
|
5265
5375
|
this.why = null;
|
|
5266
5376
|
} else if (current3.revision !== this.base.revision || isProtected(current3)) {
|
|
5267
5377
|
this.remote = copy(current3);
|
|
@@ -5275,6 +5385,10 @@ var MdbaseSDK = (() => {
|
|
|
5275
5385
|
this.publish();
|
|
5276
5386
|
} catch (error5) {
|
|
5277
5387
|
if (signal.aborted) return;
|
|
5388
|
+
if (generation !== this.driveGeneration || this.running) {
|
|
5389
|
+
this.refreshAgain = !this.running;
|
|
5390
|
+
continue;
|
|
5391
|
+
}
|
|
5278
5392
|
this.why = problem2(error5);
|
|
5279
5393
|
this.state = this.why.code === "not_found" ? "deleted" : this.captured ? "recovery" : "error";
|
|
5280
5394
|
this.publish();
|
|
@@ -5315,8 +5429,12 @@ var MdbaseSDK = (() => {
|
|
|
5315
5429
|
until: Date.now() + duration,
|
|
5316
5430
|
margin: Math.min(2e3, Math.floor(duration / 4))
|
|
5317
5431
|
};
|
|
5318
|
-
const drive = () =>
|
|
5432
|
+
const drive = () => {
|
|
5433
|
+
this.driveGeneration++;
|
|
5434
|
+
return this.drive(signal, budget, write);
|
|
5435
|
+
};
|
|
5319
5436
|
const run2 = (prior ? prior.then(drive, drive) : drive()).finally(() => {
|
|
5437
|
+
this.driveGeneration++;
|
|
5320
5438
|
limit.clear();
|
|
5321
5439
|
if (this.running !== run2) return;
|
|
5322
5440
|
this.running = null;
|
|
@@ -5336,12 +5454,13 @@ var MdbaseSDK = (() => {
|
|
|
5336
5454
|
continue;
|
|
5337
5455
|
}
|
|
5338
5456
|
if (!submit)
|
|
5339
|
-
return
|
|
5457
|
+
return this.restState === "saved" ? { ok: true, record: copy(this.base) } : {
|
|
5340
5458
|
ok: true,
|
|
5341
5459
|
record: copy(this.base),
|
|
5342
5460
|
saved: "on_device"
|
|
5343
5461
|
};
|
|
5344
|
-
const current3 = await this.
|
|
5462
|
+
const { current: current3, receipts } = await this.readWithReceipts(signal);
|
|
5463
|
+
this.reconcilePending(current3, receipts);
|
|
5345
5464
|
if (isProtected(current3)) {
|
|
5346
5465
|
this.charge(this.body, this.patch, this.base, current3);
|
|
5347
5466
|
this.remote = copy(current3);
|
|
@@ -5362,10 +5481,10 @@ var MdbaseSDK = (() => {
|
|
|
5362
5481
|
this.base = copy(current3);
|
|
5363
5482
|
this.body = current3.body;
|
|
5364
5483
|
this.remote = null;
|
|
5365
|
-
this.state =
|
|
5484
|
+
this.state = this.restState;
|
|
5366
5485
|
this.why = null;
|
|
5367
5486
|
this.publish();
|
|
5368
|
-
return
|
|
5487
|
+
return this.restState === "saved" ? { ok: true, record: copy(current3) } : { ok: true, record: copy(current3), saved: "on_device" };
|
|
5369
5488
|
}
|
|
5370
5489
|
if (current3.revision !== this.base.revision || this.state === "conflict") {
|
|
5371
5490
|
this.charge(this.body, this.patch, this.base, current3);
|
|
@@ -5501,14 +5620,23 @@ var MdbaseSDK = (() => {
|
|
|
5501
5620
|
}
|
|
5502
5621
|
const current3 = await this.read(signal);
|
|
5503
5622
|
const kept = receipt4.state === "pending";
|
|
5504
|
-
|
|
5623
|
+
const edits = new Map(this.pendingEdits);
|
|
5624
|
+
const submitted = new Map(captured.patch);
|
|
5625
|
+
if (captured.body !== this.base.body) submitted.set(null, captured.body);
|
|
5626
|
+
for (const [key3, value2] of submitted) {
|
|
5627
|
+
if (kept) edits.set(key3, { mutation: receipt4.mutation, value: value2 });
|
|
5628
|
+
else edits.delete(key3);
|
|
5629
|
+
}
|
|
5630
|
+
if (kept ? isProtected(current3) || [...submitted].some(([key3, value2]) => !matches(current3, key3, value2)) : !confirmed(current3))
|
|
5505
5631
|
throw refusal(
|
|
5506
5632
|
"outcome_unknown",
|
|
5507
|
-
"
|
|
5633
|
+
"record readback does not qualify the native receipt",
|
|
5508
5634
|
"unqualified_readback"
|
|
5509
5635
|
);
|
|
5510
|
-
this.charge(this.body, this.patch, current3, null);
|
|
5511
5636
|
const sameBody = this.body === captured.body;
|
|
5637
|
+
const conflict2 = !kept && !sameBody && current3.body !== captured.body && current3.body !== this.body;
|
|
5638
|
+
this.charge(this.body, this.patch, current3, conflict2 ? current3 : null, receipt4, null, edits);
|
|
5639
|
+
this.pendingEdits = edits;
|
|
5512
5640
|
for (const [key3, value2] of captured.patch) {
|
|
5513
5641
|
const latest = this.patch.get(key3);
|
|
5514
5642
|
if (this.patch.has(key3) && (value2 === void 0 ? latest === void 0 : latest !== void 0 && equal(value2, latest)))
|
|
@@ -5517,8 +5645,10 @@ var MdbaseSDK = (() => {
|
|
|
5517
5645
|
this.base = copy(current3);
|
|
5518
5646
|
if (sameBody) this.body = current3.body;
|
|
5519
5647
|
this.captured = null;
|
|
5520
|
-
this.remote = null;
|
|
5521
|
-
|
|
5648
|
+
this.remote = conflict2 ? copy(current3) : null;
|
|
5649
|
+
if (conflict2)
|
|
5650
|
+
throw refusal("conflict", "record body changed while saving an earlier draft", "record_session_conflict");
|
|
5651
|
+
this.state = this.dirty ? "unsaved" : this.restState;
|
|
5522
5652
|
this.why = null;
|
|
5523
5653
|
this.publish();
|
|
5524
5654
|
}
|
|
@@ -5537,7 +5667,7 @@ var MdbaseSDK = (() => {
|
|
|
5537
5667
|
"a confirmed unprotected native record is required for resolution",
|
|
5538
5668
|
"native_protection_resolution_required"
|
|
5539
5669
|
);
|
|
5540
|
-
const body = "body" in choice ? choice.body : choice.keep === "theirs" ? remote.body : this.body;
|
|
5670
|
+
const body = "body" in choice ? choice.body : choice.keep === "theirs" || this.body === this.base.body ? remote.body : this.body;
|
|
5541
5671
|
const patch = "keep" in choice && choice.keep === "theirs" ? /* @__PURE__ */ new Map() : this.patch;
|
|
5542
5672
|
this.charge(body, patch, remote, null);
|
|
5543
5673
|
this.base = copy(remote);
|
|
@@ -9137,9 +9267,9 @@ var MdbaseSDK = (() => {
|
|
|
9137
9267
|
this.check(request3.signal);
|
|
9138
9268
|
this.checkReadSession(records2.session);
|
|
9139
9269
|
const invalid8 = records2.invalid.filter((row3) => row3.claims.some((claim) => sameIdentity(claim, account)));
|
|
9140
|
-
const
|
|
9141
|
-
const match =
|
|
9142
|
-
const me = invalid8.length ? { status: "invalid", paths: invalid8.map((row3) => row3.path) } :
|
|
9270
|
+
const matches2 = records2.people.filter((row3) => row3.identities.some((claim) => sameIdentity(claim, account)));
|
|
9271
|
+
const match = matches2[0];
|
|
9272
|
+
const me = invalid8.length ? { status: "invalid", paths: invalid8.map((row3) => row3.path) } : matches2.length > 1 ? { status: "ambiguous", paths: matches2.map((row3) => row3.path) } : match ? { status: "linked", person: match } : { status: "unlinked" };
|
|
9143
9273
|
return { account, me, people: records2.people, invalid: records2.invalid.map(({ claims: _, ...row3 }) => row3), ...members === void 0 ? {} : { members } };
|
|
9144
9274
|
}
|
|
9145
9275
|
async records(options) {
|
|
@@ -9951,7 +10081,7 @@ var MdbaseSDK = (() => {
|
|
|
9951
10081
|
configuration_unsupported: ["This app can't set up this collection", "This app's setup isn't supported by this version of mdbase. Contact the app's developer.", "contact_support", "warning"],
|
|
9952
10082
|
setup_forbidden: ["You can't set up this collection", "Your access to this collection doesn't allow setting it up. Ask its owner to open it in this app first.", "choose_collection", "warning"],
|
|
9953
10083
|
setup_conflict: ["Setup needs your decision", "Some things in this collection differ from what this app needs. Review them to continue.", "set_up", "warning", false, "Review setup"],
|
|
9954
|
-
setup_unresolved: ["Setup can't finish", "This collection is missing
|
|
10084
|
+
setup_unresolved: ["Setup can't finish", "This collection is missing a note format this app needs. Add or update a note type that supports that format, then try setup again.", "retry", "warning"],
|
|
9955
10085
|
// Setup would leave something already in the collection invalid; the API
|
|
9956
10086
|
// problem's message names the cause and the definition's path.
|
|
9957
10087
|
collection_setup_conflict: ["Collection setup conflicts", "Setting up this app would conflict with definitions already in this collection, so nothing was changed. A note type may have been renamed or customised and still use an older definition. Update or remove it, then try again.", "retry", "warning"],
|
|
@@ -25000,7 +25130,7 @@ ${end.comment}` : end.comment;
|
|
|
25000
25130
|
field(uuidBytes(binding2.application_id)),
|
|
25001
25131
|
field(uuidBytes(binding2.authorization_id)),
|
|
25002
25132
|
field(new TextEncoder().encode(binding2.application_declaration_id)),
|
|
25003
|
-
field(
|
|
25133
|
+
field(hexBytes2(binding2.application_manifest_digest)),
|
|
25004
25134
|
field(uuidBytes(binding2.application_installation_id)),
|
|
25005
25135
|
...keys2.map(field),
|
|
25006
25136
|
field(new TextEncoder().encode(binding2.flow)),
|
|
@@ -25074,9 +25204,9 @@ ${end.comment}` : end.comment;
|
|
|
25074
25204
|
throw new Error("Invalid UUID value.");
|
|
25075
25205
|
}
|
|
25076
25206
|
const compact = value2.replaceAll("-", "");
|
|
25077
|
-
return
|
|
25207
|
+
return hexBytes2(compact);
|
|
25078
25208
|
}
|
|
25079
|
-
function
|
|
25209
|
+
function hexBytes2(value2) {
|
|
25080
25210
|
if (!/^[0-9a-f]+$/u.test(value2) || value2.length % 2 !== 0) {
|
|
25081
25211
|
throw new Error("Invalid hexadecimal value.");
|
|
25082
25212
|
}
|
|
@@ -29946,9 +30076,9 @@ ${end.comment}` : end.comment;
|
|
|
29946
30076
|
}
|
|
29947
30077
|
});
|
|
29948
30078
|
}
|
|
29949
|
-
column(st, i) {
|
|
30079
|
+
column(st, i, tag) {
|
|
29950
30080
|
const capi = this.sqlite3.capi;
|
|
29951
|
-
switch (
|
|
30081
|
+
switch (tag) {
|
|
29952
30082
|
case SQLITE_NULL:
|
|
29953
30083
|
return { kind: "Null" };
|
|
29954
30084
|
case SQLITE_INTEGER: {
|
|
@@ -30002,9 +30132,9 @@ ${end.comment}` : end.comment;
|
|
|
30002
30132
|
while (st.step()) {
|
|
30003
30133
|
if (limits && ++rows2 > limits.maxRows) throw new IndexError("Full", "index reply row budget exceeded");
|
|
30004
30134
|
for (let c = 0; c < columns; c++) {
|
|
30135
|
+
if (limits && ++valueCount > limits.maxValues) throw new IndexError("Full", "index reply value budget exceeded");
|
|
30136
|
+
const tag = capi.sqlite3_column_type(st.pointer, c);
|
|
30005
30137
|
if (limits) {
|
|
30006
|
-
if (++valueCount > limits.maxValues) throw new IndexError("Full", "index reply value budget exceeded");
|
|
30007
|
-
const tag = capi.sqlite3_column_type(st.pointer, c);
|
|
30008
30138
|
if (tag === SQLITE_TEXT || tag === SQLITE_BLOB) {
|
|
30009
30139
|
addBytes(5);
|
|
30010
30140
|
addBytes(capi.sqlite3_column_bytes(st.pointer, c));
|
|
@@ -30012,7 +30142,7 @@ ${end.comment}` : end.comment;
|
|
|
30012
30142
|
else if (tag === SQLITE_NULL) addBytes(1);
|
|
30013
30143
|
else throw new IndexError("Other", "unknown SQLite value type");
|
|
30014
30144
|
}
|
|
30015
|
-
values.push(this.column(st, c));
|
|
30145
|
+
values.push(this.column(st, c, tag));
|
|
30016
30146
|
}
|
|
30017
30147
|
}
|
|
30018
30148
|
out.push({
|
|
@@ -30248,33 +30378,46 @@ ${end.comment}` : end.comment;
|
|
|
30248
30378
|
}
|
|
30249
30379
|
};
|
|
30250
30380
|
Writer2 = class {
|
|
30251
|
-
|
|
30381
|
+
bytes = new Uint8Array(128);
|
|
30382
|
+
view = new DataView(this.bytes.buffer);
|
|
30252
30383
|
length = 0;
|
|
30253
30384
|
values = 0;
|
|
30254
30385
|
constructor(op2) {
|
|
30255
30386
|
this.put(MAGIC);
|
|
30256
30387
|
this.byte(op2);
|
|
30257
30388
|
}
|
|
30389
|
+
reserve(size2) {
|
|
30390
|
+
const start = this.length;
|
|
30391
|
+
const end = start + size2;
|
|
30392
|
+
if (end > APP_INDEX_LIMITS.maxBytes) throw full();
|
|
30393
|
+
if (end > this.bytes.length) {
|
|
30394
|
+
const capacity = Math.min(APP_INDEX_LIMITS.maxBytes, Math.max(end, this.bytes.length * 2));
|
|
30395
|
+
const next = new Uint8Array(capacity);
|
|
30396
|
+
next.set(this.bytes.subarray(0, start));
|
|
30397
|
+
this.bytes = next;
|
|
30398
|
+
this.view = new DataView(next.buffer);
|
|
30399
|
+
}
|
|
30400
|
+
this.length = end;
|
|
30401
|
+
return start;
|
|
30402
|
+
}
|
|
30258
30403
|
put(b) {
|
|
30259
|
-
|
|
30260
|
-
this.
|
|
30261
|
-
this.parts.push(b);
|
|
30404
|
+
const at = this.reserve(b.length);
|
|
30405
|
+
this.bytes.set(b, at);
|
|
30262
30406
|
}
|
|
30263
30407
|
byte(n) {
|
|
30264
|
-
this.
|
|
30408
|
+
const at = this.reserve(1);
|
|
30409
|
+
this.bytes[at] = n;
|
|
30265
30410
|
}
|
|
30266
30411
|
u32(n) {
|
|
30267
30412
|
if (!Number.isSafeInteger(n) || n < 0 || n > 4294967295) throw invalid7();
|
|
30268
|
-
const
|
|
30269
|
-
|
|
30270
|
-
this.put(b);
|
|
30413
|
+
const at = this.reserve(4);
|
|
30414
|
+
this.view.setUint32(at, n, true);
|
|
30271
30415
|
}
|
|
30272
30416
|
int(n, signed) {
|
|
30273
30417
|
if (typeof n !== "bigint" || n < (signed ? I64_MIN2 : 0n) || n > (signed ? I64_MAX : U64_MAX2)) throw invalid7();
|
|
30274
|
-
const
|
|
30275
|
-
if (signed)
|
|
30276
|
-
else
|
|
30277
|
-
this.put(b);
|
|
30418
|
+
const at = this.reserve(8);
|
|
30419
|
+
if (signed) this.view.setBigInt64(at, n, true);
|
|
30420
|
+
else this.view.setBigUint64(at, n, true);
|
|
30278
30421
|
}
|
|
30279
30422
|
data(b) {
|
|
30280
30423
|
this.u32(b.length);
|
|
@@ -30293,9 +30436,8 @@ ${end.comment}` : end.comment;
|
|
|
30293
30436
|
case "Real": {
|
|
30294
30437
|
if (!Number.isFinite(v.value)) throw invalid7();
|
|
30295
30438
|
this.byte(2);
|
|
30296
|
-
const
|
|
30297
|
-
|
|
30298
|
-
this.put(b);
|
|
30439
|
+
const at = this.reserve(8);
|
|
30440
|
+
this.view.setFloat64(at, v.value, true);
|
|
30299
30441
|
return;
|
|
30300
30442
|
}
|
|
30301
30443
|
case "Text":
|
|
@@ -30311,13 +30453,7 @@ ${end.comment}` : end.comment;
|
|
|
30311
30453
|
}
|
|
30312
30454
|
}
|
|
30313
30455
|
done() {
|
|
30314
|
-
|
|
30315
|
-
let at = 0;
|
|
30316
|
-
for (const part of this.parts) {
|
|
30317
|
-
out.set(part, at);
|
|
30318
|
-
at += part.length;
|
|
30319
|
-
}
|
|
30320
|
-
return out;
|
|
30456
|
+
return this.bytes.slice(0, this.length);
|
|
30321
30457
|
}
|
|
30322
30458
|
};
|
|
30323
30459
|
AppBinaryIndexHost = class {
|
|
@@ -33867,7 +34003,7 @@ ${end.comment}` : end.comment;
|
|
|
33867
34003
|
conflicts.push({
|
|
33868
34004
|
target: r.target,
|
|
33869
34005
|
...canAdopt ? { adoptable: { digest: r.currentDigest } } : {},
|
|
33870
|
-
message: canAdopt && seed ? `Your ${thing.bare} has changes that can't be combined with the version this app needs. You can replace it with this app's version.` : canAdopt && r.installed ? `${The} was changed after this app set it up. You can replace it with this app's version.` : canAdopt ? `This collection already has a ${thing.bare} that differs from the one this app needs. You can replace it with this app's version.` : r.installed ? `${The} was changed after this app set it up, so it can't be updated automatically.` : `${The} can't be set up automatically.`
|
|
34006
|
+
message: seed && r.kind === "type" && !r.installed ? `The existing note type at "${r.target}" differs from the one this app needs. ${canAdopt ? "You can replace it with this app's version." : "Change the existing type to support this app, or rename it and update the notes that use it. Then run setup again."}` : canAdopt && seed ? `Your ${thing.bare} has changes that can't be combined with the version this app needs. You can replace it with this app's version.` : canAdopt && r.installed ? `${The} was changed after this app set it up. You can replace it with this app's version.` : canAdopt ? `This collection already has a ${thing.bare} that differs from the one this app needs. You can replace it with this app's version.` : r.installed ? `${The} was changed after this app set it up, so it can't be updated automatically.` : `${The} can't be set up automatically.`
|
|
33871
34007
|
});
|
|
33872
34008
|
break;
|
|
33873
34009
|
}
|
|
@@ -33944,7 +34080,7 @@ ${end.comment}` : end.comment;
|
|
|
33944
34080
|
name2 = (target2) => (target2.split("/").pop() ?? target2).replace(/\.(md|ya?ml|json)$/i, "");
|
|
33945
34081
|
plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
33946
34082
|
setting = (path) => (path.split("/").filter(Boolean).pop() ?? path).replace(/[_-]+/g, " ");
|
|
33947
|
-
UNRESOLVED = "This collection is missing
|
|
34083
|
+
UNRESOLVED = "This collection is missing a note format this app needs. Add or update a note type that supports that format, then try setup again.";
|
|
33948
34084
|
}
|
|
33949
34085
|
});
|
|
33950
34086
|
|
|
@@ -51079,12 +51215,12 @@ ${end.comment}` : end.comment;
|
|
|
51079
51215
|
// src/application/asset-pins.json
|
|
51080
51216
|
var asset_pins_default = {
|
|
51081
51217
|
runtime: {
|
|
51082
|
-
sha256: "
|
|
51083
|
-
bytes:
|
|
51084
|
-
maxBytes:
|
|
51218
|
+
sha256: "d5452814d656c9611d0be04a934278d88ca8c83d3e823353f9842811a63a4795",
|
|
51219
|
+
bytes: 4141990,
|
|
51220
|
+
maxBytes: 4141990,
|
|
51085
51221
|
source: {
|
|
51086
51222
|
repository: "mdbase-dev/mdbase-connect",
|
|
51087
|
-
commit: "
|
|
51223
|
+
commit: "1f9c2965a3e7198eb2a2ed0c409dde5dfdef11fc"
|
|
51088
51224
|
}
|
|
51089
51225
|
},
|
|
51090
51226
|
sqlite: {
|