@mdbase-dev/sdk 0.2.61 → 0.2.62
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.js +180 -52
- package/dist/browser/mdbase-sdk.js +190 -61
- package/dist/browser/mdbase-sdk.min.js +49 -49
- package/dist/cbor.js +2 -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
|
@@ -234,7 +234,7 @@ var MdbaseSDK = (() => {
|
|
|
234
234
|
}
|
|
235
235
|
function toHex(b) {
|
|
236
236
|
let s = "";
|
|
237
|
-
for (const x of b) s += x
|
|
237
|
+
for (const x of b) s += hexBytes[x];
|
|
238
238
|
return s;
|
|
239
239
|
}
|
|
240
240
|
function fromHex(s) {
|
|
@@ -248,7 +248,7 @@ var MdbaseSDK = (() => {
|
|
|
248
248
|
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
249
249
|
return true;
|
|
250
250
|
}
|
|
251
|
-
var Float64, MAX_DEPTH, CborError, U64_MAX, I64_MIN, textEncoder, textDecoder, Writer, Reader;
|
|
251
|
+
var Float64, MAX_DEPTH, CborError, U64_MAX, I64_MIN, textEncoder, textDecoder, Writer, Reader, hexBytes;
|
|
252
252
|
var init_cbor = __esm({
|
|
253
253
|
"src/cbor.ts"() {
|
|
254
254
|
"use strict";
|
|
@@ -495,6 +495,7 @@ var MdbaseSDK = (() => {
|
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
};
|
|
498
|
+
hexBytes = Array.from({ length: 256 }, (_, n) => n.toString(16).padStart(2, "0"));
|
|
498
499
|
}
|
|
499
500
|
});
|
|
500
501
|
|
|
@@ -4996,8 +4997,11 @@ var MdbaseSDK = (() => {
|
|
|
4996
4997
|
});
|
|
4997
4998
|
|
|
4998
4999
|
// src/records/session.ts
|
|
4999
|
-
function
|
|
5000
|
-
|
|
5000
|
+
function matches(record5, key3, value2) {
|
|
5001
|
+
if (key3 === null) return value2 === record5.body;
|
|
5002
|
+
const actual = fieldOf(record5.frontmatter, key3);
|
|
5003
|
+
if (actual === void 0 || value2 === void 0) return actual === value2;
|
|
5004
|
+
return equal(toValue(actual), toValue(toPlain(value2)));
|
|
5001
5005
|
}
|
|
5002
5006
|
function equal(a, b) {
|
|
5003
5007
|
const x = encode(a), y = encode(b);
|
|
@@ -5046,6 +5050,7 @@ var MdbaseSDK = (() => {
|
|
|
5046
5050
|
init_errors();
|
|
5047
5051
|
init_session();
|
|
5048
5052
|
init_values();
|
|
5053
|
+
init_plain();
|
|
5049
5054
|
init_witness();
|
|
5050
5055
|
RecordSessionImpl = class {
|
|
5051
5056
|
constructor(client, record5, reserve) {
|
|
@@ -5054,7 +5059,7 @@ var MdbaseSDK = (() => {
|
|
|
5054
5059
|
complete(record5);
|
|
5055
5060
|
this.base = copy(record5);
|
|
5056
5061
|
this.body = record5.body;
|
|
5057
|
-
this.state = isProtected(record5) ? "conflict" :
|
|
5062
|
+
this.state = isProtected(record5) ? "conflict" : this.restState;
|
|
5058
5063
|
this.publish();
|
|
5059
5064
|
}
|
|
5060
5065
|
client;
|
|
@@ -5064,6 +5069,8 @@ var MdbaseSDK = (() => {
|
|
|
5064
5069
|
patch = /* @__PURE__ */ new Map();
|
|
5065
5070
|
remote = null;
|
|
5066
5071
|
captured = null;
|
|
5072
|
+
pendingEdits = /* @__PURE__ */ new Map();
|
|
5073
|
+
driveGeneration = 0;
|
|
5067
5074
|
lastReceipt = null;
|
|
5068
5075
|
state;
|
|
5069
5076
|
why = null;
|
|
@@ -5104,6 +5111,24 @@ var MdbaseSDK = (() => {
|
|
|
5104
5111
|
recovery: { ...hint, receipt: null, write: null }
|
|
5105
5112
|
};
|
|
5106
5113
|
}
|
|
5114
|
+
if (!this.active && !hint && this.base.state.state === "pending" && !this.pendingEdits.size) {
|
|
5115
|
+
const edits = /* @__PURE__ */ new Map();
|
|
5116
|
+
for (const { ops, receipt: receipt4 } of await this.client.pendingWrites({ signal })) {
|
|
5117
|
+
for (const op2 of ops) {
|
|
5118
|
+
if (op2.kind !== "update" || op2.id !== this.id) continue;
|
|
5119
|
+
const mutation2 = receipt4.mutation;
|
|
5120
|
+
if (op2.body !== void 0 || op2.bodyEdits?.length) {
|
|
5121
|
+
const body = op2.body ?? receipt4.records?.find((record5) => record5.id === this.id)?.body ?? this.base.body;
|
|
5122
|
+
edits.set(null, { mutation: mutation2, value: body });
|
|
5123
|
+
}
|
|
5124
|
+
for (const [key3, value2] of Object.entries(op2.patch ?? {}))
|
|
5125
|
+
edits.set(key3, { mutation: mutation2, value: toValue(value2) });
|
|
5126
|
+
for (const key3 of op2.unset ?? []) edits.set(key3, { mutation: mutation2, value: void 0 });
|
|
5127
|
+
}
|
|
5128
|
+
}
|
|
5129
|
+
this.charge(this.body, this.patch, this.base, this.remote, this.lastReceipt, this.captured, edits);
|
|
5130
|
+
this.pendingEdits = edits;
|
|
5131
|
+
}
|
|
5107
5132
|
signal?.throwIfAborted();
|
|
5108
5133
|
if (this.captured) {
|
|
5109
5134
|
this.state = "recovery";
|
|
@@ -5121,8 +5146,11 @@ var MdbaseSDK = (() => {
|
|
|
5121
5146
|
get dirty() {
|
|
5122
5147
|
return this.body !== this.base.body || this.patch.size > 0;
|
|
5123
5148
|
}
|
|
5149
|
+
get restState() {
|
|
5150
|
+
return !this.pendingEdits.size && confirmed(this.base) ? "saved" : "saved_on_device";
|
|
5151
|
+
}
|
|
5124
5152
|
get retained() {
|
|
5125
|
-
return this.dirty || this.captured !== null || !confirmed(this.base);
|
|
5153
|
+
return this.dirty || this.captured !== null || this.pendingEdits.size > 0 || !confirmed(this.base);
|
|
5126
5154
|
}
|
|
5127
5155
|
getSnapshot = () => this.snapshot;
|
|
5128
5156
|
subscribe = (listener) => {
|
|
@@ -5172,13 +5200,13 @@ var MdbaseSDK = (() => {
|
|
|
5172
5200
|
};
|
|
5173
5201
|
edited() {
|
|
5174
5202
|
if (!this.captured && this.state !== "conflict" && this.state !== "deleted") {
|
|
5175
|
-
this.state = this.dirty ? "unsaved" :
|
|
5203
|
+
this.state = this.dirty ? "unsaved" : this.restState;
|
|
5176
5204
|
this.why = null;
|
|
5177
5205
|
}
|
|
5178
5206
|
this.publish();
|
|
5179
5207
|
this.schedule();
|
|
5180
5208
|
}
|
|
5181
|
-
charge(body = this.body, patch = this.patch, base = this.base, remote = this.remote, receipt4 = this.lastReceipt, captured = this.captured) {
|
|
5209
|
+
charge(body = this.body, patch = this.patch, base = this.base, remote = this.remote, receipt4 = this.lastReceipt, captured = this.captured, pendingEdits = this.pendingEdits) {
|
|
5182
5210
|
let bytes10 = retainedBytes(base) + textBytes(body) + encode(new Map([...patch].map(([k, v]) => [k, v ?? null]))).byteLength * 2;
|
|
5183
5211
|
if (remote) bytes10 += retainedBytes(remote);
|
|
5184
5212
|
if (captured)
|
|
@@ -5187,6 +5215,8 @@ var MdbaseSDK = (() => {
|
|
|
5187
5215
|
[...captured.patch].map(([k, v]) => [k, v ?? null])
|
|
5188
5216
|
)
|
|
5189
5217
|
).byteLength * 2;
|
|
5218
|
+
for (const [key3, edit] of pendingEdits)
|
|
5219
|
+
bytes10 += encode([key3, edit.mutation, edit.value ?? null]).byteLength * 2;
|
|
5190
5220
|
if (receipt4) bytes10 += retainedBytes(receipt4);
|
|
5191
5221
|
this.reserve(bytes10);
|
|
5192
5222
|
}
|
|
@@ -5237,6 +5267,73 @@ var MdbaseSDK = (() => {
|
|
|
5237
5267
|
complete(record5, this.id);
|
|
5238
5268
|
return record5;
|
|
5239
5269
|
}
|
|
5270
|
+
/** The projection can change after either a refusal or a successful write
|
|
5271
|
+
* followed by a peer edit. Only the original MID distinguishes them. */
|
|
5272
|
+
async readWithReceipts(signal) {
|
|
5273
|
+
const receipts = /* @__PURE__ */ new Map();
|
|
5274
|
+
for (; ; ) {
|
|
5275
|
+
const current3 = await this.read(signal);
|
|
5276
|
+
if (this.captured) return { current: current3, receipts };
|
|
5277
|
+
const count = receipts.size;
|
|
5278
|
+
for (const [key3, { mutation: mutation2, value: value2 }] of this.pendingEdits) {
|
|
5279
|
+
const present2 = matches(current3, key3, value2);
|
|
5280
|
+
if (!confirmed(current3) && present2) continue;
|
|
5281
|
+
if (!receipts.has(mutation2)) {
|
|
5282
|
+
const receipt5 = await this.client.receipt(mutation2, { signal });
|
|
5283
|
+
signal.throwIfAborted();
|
|
5284
|
+
if (receipt5.mutation !== mutation2)
|
|
5285
|
+
throw refusal("outcome_unknown", "native receipt changed identity", "mutation_identity_mismatch");
|
|
5286
|
+
receipts.set(mutation2, receipt5);
|
|
5287
|
+
}
|
|
5288
|
+
const receipt4 = receipts.get(mutation2);
|
|
5289
|
+
if (receipt4.state === "unknown" || receipt4.state === "pending" && !present2)
|
|
5290
|
+
throw refusal("outcome_unknown", "the projection does not qualify this device write yet", "unqualified_readback");
|
|
5291
|
+
}
|
|
5292
|
+
if (receipts.size === count) return { current: current3, receipts };
|
|
5293
|
+
}
|
|
5294
|
+
}
|
|
5295
|
+
/** Restore only a refused write's missing edits. Newer typing and field
|
|
5296
|
+
* edits win, including an explicit unset; unrelated remote fields survive. */
|
|
5297
|
+
reconcilePending(current3, receipts) {
|
|
5298
|
+
if (!receipts.size) return;
|
|
5299
|
+
const remaining = new Map(this.pendingEdits);
|
|
5300
|
+
const patch = new Map(this.patch);
|
|
5301
|
+
const bodyEdited = this.body !== this.base.body;
|
|
5302
|
+
let body = bodyEdited ? this.body : current3.body;
|
|
5303
|
+
let rolledBack = false;
|
|
5304
|
+
for (const [key3, { mutation: mutation2, value: value2 }] of this.pendingEdits) {
|
|
5305
|
+
const receipt4 = receipts.get(mutation2);
|
|
5306
|
+
if (!receipt4 || receipt4.state === "pending" || receipt4.state === "unknown") continue;
|
|
5307
|
+
remaining.delete(key3);
|
|
5308
|
+
if (receipt4.state !== "rejected" && receipt4.status !== "conflicted" || matches(current3, key3, value2)) continue;
|
|
5309
|
+
rolledBack = true;
|
|
5310
|
+
if (key3 === null) {
|
|
5311
|
+
if (!bodyEdited) body = value2;
|
|
5312
|
+
} else if (!patch.has(key3)) {
|
|
5313
|
+
patch.set(key3, value2);
|
|
5314
|
+
}
|
|
5315
|
+
}
|
|
5316
|
+
const last = this.lastReceipt && (receipts.get(this.lastReceipt.mutation) ?? this.lastReceipt);
|
|
5317
|
+
if (rolledBack) {
|
|
5318
|
+
for (const [key3, value2] of patch) {
|
|
5319
|
+
if (matches(current3, key3, value2)) patch.delete(key3);
|
|
5320
|
+
}
|
|
5321
|
+
const differs = body !== current3.body || patch.size > 0;
|
|
5322
|
+
this.charge(body, patch, current3, differs ? current3 : null, last, this.captured, remaining);
|
|
5323
|
+
this.base = copy(current3);
|
|
5324
|
+
this.remote = differs ? copy(current3) : null;
|
|
5325
|
+
this.body = body;
|
|
5326
|
+
this.patch = patch;
|
|
5327
|
+
if (differs) {
|
|
5328
|
+
this.state = "conflict";
|
|
5329
|
+
this.why = refusal("conflict", "a device write was refused at head", "record_session_conflict").toProblem();
|
|
5330
|
+
}
|
|
5331
|
+
} else {
|
|
5332
|
+
this.charge(this.body, this.patch, this.base, this.remote, last, this.captured, remaining);
|
|
5333
|
+
}
|
|
5334
|
+
this.pendingEdits = remaining;
|
|
5335
|
+
this.lastReceipt = last;
|
|
5336
|
+
}
|
|
5240
5337
|
/** Native change notifications are hints only; hydrate the same UUID. */
|
|
5241
5338
|
refresh = () => {
|
|
5242
5339
|
if (!this.active) return Promise.resolve();
|
|
@@ -5248,20 +5345,26 @@ var MdbaseSDK = (() => {
|
|
|
5248
5345
|
this.refreshRunning = (async () => {
|
|
5249
5346
|
do {
|
|
5250
5347
|
this.refreshAgain = false;
|
|
5348
|
+
const generation = this.driveGeneration;
|
|
5251
5349
|
try {
|
|
5252
|
-
const current3 = await this.
|
|
5350
|
+
const { current: current3, receipts } = await this.readWithReceipts(signal);
|
|
5351
|
+
if (generation !== this.driveGeneration) {
|
|
5352
|
+
this.refreshAgain = true;
|
|
5353
|
+
continue;
|
|
5354
|
+
}
|
|
5253
5355
|
if (this.captured || this.running) {
|
|
5254
5356
|
if (this.captured && !this.running)
|
|
5255
5357
|
void this.start(false, {}).catch(() => {
|
|
5256
5358
|
});
|
|
5257
5359
|
continue;
|
|
5258
5360
|
}
|
|
5361
|
+
this.reconcilePending(current3, receipts);
|
|
5259
5362
|
this.charge(this.body, this.patch, this.base, current3);
|
|
5260
5363
|
if (!this.dirty) {
|
|
5261
5364
|
this.base = copy(current3);
|
|
5262
5365
|
this.body = current3.body;
|
|
5263
5366
|
this.remote = null;
|
|
5264
|
-
this.state = isProtected(current3) ? "conflict" :
|
|
5367
|
+
this.state = isProtected(current3) ? "conflict" : this.restState;
|
|
5265
5368
|
this.why = null;
|
|
5266
5369
|
} else if (current3.revision !== this.base.revision || isProtected(current3)) {
|
|
5267
5370
|
this.remote = copy(current3);
|
|
@@ -5275,6 +5378,10 @@ var MdbaseSDK = (() => {
|
|
|
5275
5378
|
this.publish();
|
|
5276
5379
|
} catch (error5) {
|
|
5277
5380
|
if (signal.aborted) return;
|
|
5381
|
+
if (generation !== this.driveGeneration || this.running) {
|
|
5382
|
+
this.refreshAgain = !this.running;
|
|
5383
|
+
continue;
|
|
5384
|
+
}
|
|
5278
5385
|
this.why = problem2(error5);
|
|
5279
5386
|
this.state = this.why.code === "not_found" ? "deleted" : this.captured ? "recovery" : "error";
|
|
5280
5387
|
this.publish();
|
|
@@ -5315,8 +5422,12 @@ var MdbaseSDK = (() => {
|
|
|
5315
5422
|
until: Date.now() + duration,
|
|
5316
5423
|
margin: Math.min(2e3, Math.floor(duration / 4))
|
|
5317
5424
|
};
|
|
5318
|
-
const drive = () =>
|
|
5425
|
+
const drive = () => {
|
|
5426
|
+
this.driveGeneration++;
|
|
5427
|
+
return this.drive(signal, budget, write);
|
|
5428
|
+
};
|
|
5319
5429
|
const run2 = (prior ? prior.then(drive, drive) : drive()).finally(() => {
|
|
5430
|
+
this.driveGeneration++;
|
|
5320
5431
|
limit.clear();
|
|
5321
5432
|
if (this.running !== run2) return;
|
|
5322
5433
|
this.running = null;
|
|
@@ -5336,12 +5447,13 @@ var MdbaseSDK = (() => {
|
|
|
5336
5447
|
continue;
|
|
5337
5448
|
}
|
|
5338
5449
|
if (!submit)
|
|
5339
|
-
return
|
|
5450
|
+
return this.restState === "saved" ? { ok: true, record: copy(this.base) } : {
|
|
5340
5451
|
ok: true,
|
|
5341
5452
|
record: copy(this.base),
|
|
5342
5453
|
saved: "on_device"
|
|
5343
5454
|
};
|
|
5344
|
-
const current3 = await this.
|
|
5455
|
+
const { current: current3, receipts } = await this.readWithReceipts(signal);
|
|
5456
|
+
this.reconcilePending(current3, receipts);
|
|
5345
5457
|
if (isProtected(current3)) {
|
|
5346
5458
|
this.charge(this.body, this.patch, this.base, current3);
|
|
5347
5459
|
this.remote = copy(current3);
|
|
@@ -5362,10 +5474,10 @@ var MdbaseSDK = (() => {
|
|
|
5362
5474
|
this.base = copy(current3);
|
|
5363
5475
|
this.body = current3.body;
|
|
5364
5476
|
this.remote = null;
|
|
5365
|
-
this.state =
|
|
5477
|
+
this.state = this.restState;
|
|
5366
5478
|
this.why = null;
|
|
5367
5479
|
this.publish();
|
|
5368
|
-
return
|
|
5480
|
+
return this.restState === "saved" ? { ok: true, record: copy(current3) } : { ok: true, record: copy(current3), saved: "on_device" };
|
|
5369
5481
|
}
|
|
5370
5482
|
if (current3.revision !== this.base.revision || this.state === "conflict") {
|
|
5371
5483
|
this.charge(this.body, this.patch, this.base, current3);
|
|
@@ -5501,14 +5613,23 @@ var MdbaseSDK = (() => {
|
|
|
5501
5613
|
}
|
|
5502
5614
|
const current3 = await this.read(signal);
|
|
5503
5615
|
const kept = receipt4.state === "pending";
|
|
5504
|
-
|
|
5616
|
+
const edits = new Map(this.pendingEdits);
|
|
5617
|
+
const submitted = new Map(captured.patch);
|
|
5618
|
+
if (captured.body !== this.base.body) submitted.set(null, captured.body);
|
|
5619
|
+
for (const [key3, value2] of submitted) {
|
|
5620
|
+
if (kept) edits.set(key3, { mutation: receipt4.mutation, value: value2 });
|
|
5621
|
+
else edits.delete(key3);
|
|
5622
|
+
}
|
|
5623
|
+
if (kept ? isProtected(current3) || [...submitted].some(([key3, value2]) => !matches(current3, key3, value2)) : !confirmed(current3))
|
|
5505
5624
|
throw refusal(
|
|
5506
5625
|
"outcome_unknown",
|
|
5507
|
-
"
|
|
5626
|
+
"record readback does not qualify the native receipt",
|
|
5508
5627
|
"unqualified_readback"
|
|
5509
5628
|
);
|
|
5510
|
-
this.charge(this.body, this.patch, current3, null);
|
|
5511
5629
|
const sameBody = this.body === captured.body;
|
|
5630
|
+
const conflict2 = !kept && !sameBody && current3.body !== captured.body && current3.body !== this.body;
|
|
5631
|
+
this.charge(this.body, this.patch, current3, conflict2 ? current3 : null, receipt4, null, edits);
|
|
5632
|
+
this.pendingEdits = edits;
|
|
5512
5633
|
for (const [key3, value2] of captured.patch) {
|
|
5513
5634
|
const latest = this.patch.get(key3);
|
|
5514
5635
|
if (this.patch.has(key3) && (value2 === void 0 ? latest === void 0 : latest !== void 0 && equal(value2, latest)))
|
|
@@ -5517,8 +5638,10 @@ var MdbaseSDK = (() => {
|
|
|
5517
5638
|
this.base = copy(current3);
|
|
5518
5639
|
if (sameBody) this.body = current3.body;
|
|
5519
5640
|
this.captured = null;
|
|
5520
|
-
this.remote = null;
|
|
5521
|
-
|
|
5641
|
+
this.remote = conflict2 ? copy(current3) : null;
|
|
5642
|
+
if (conflict2)
|
|
5643
|
+
throw refusal("conflict", "record body changed while saving an earlier draft", "record_session_conflict");
|
|
5644
|
+
this.state = this.dirty ? "unsaved" : this.restState;
|
|
5522
5645
|
this.why = null;
|
|
5523
5646
|
this.publish();
|
|
5524
5647
|
}
|
|
@@ -5537,7 +5660,7 @@ var MdbaseSDK = (() => {
|
|
|
5537
5660
|
"a confirmed unprotected native record is required for resolution",
|
|
5538
5661
|
"native_protection_resolution_required"
|
|
5539
5662
|
);
|
|
5540
|
-
const body = "body" in choice ? choice.body : choice.keep === "theirs" ? remote.body : this.body;
|
|
5663
|
+
const body = "body" in choice ? choice.body : choice.keep === "theirs" || this.body === this.base.body ? remote.body : this.body;
|
|
5541
5664
|
const patch = "keep" in choice && choice.keep === "theirs" ? /* @__PURE__ */ new Map() : this.patch;
|
|
5542
5665
|
this.charge(body, patch, remote, null);
|
|
5543
5666
|
this.base = copy(remote);
|
|
@@ -9137,9 +9260,9 @@ var MdbaseSDK = (() => {
|
|
|
9137
9260
|
this.check(request3.signal);
|
|
9138
9261
|
this.checkReadSession(records2.session);
|
|
9139
9262
|
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) } :
|
|
9263
|
+
const matches2 = records2.people.filter((row3) => row3.identities.some((claim) => sameIdentity(claim, account)));
|
|
9264
|
+
const match = matches2[0];
|
|
9265
|
+
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
9266
|
return { account, me, people: records2.people, invalid: records2.invalid.map(({ claims: _, ...row3 }) => row3), ...members === void 0 ? {} : { members } };
|
|
9144
9267
|
}
|
|
9145
9268
|
async records(options) {
|
|
@@ -9951,7 +10074,7 @@ var MdbaseSDK = (() => {
|
|
|
9951
10074
|
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
10075
|
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
10076
|
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
|
|
10077
|
+
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
10078
|
// Setup would leave something already in the collection invalid; the API
|
|
9956
10079
|
// problem's message names the cause and the definition's path.
|
|
9957
10080
|
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 +25123,7 @@ ${end.comment}` : end.comment;
|
|
|
25000
25123
|
field(uuidBytes(binding2.application_id)),
|
|
25001
25124
|
field(uuidBytes(binding2.authorization_id)),
|
|
25002
25125
|
field(new TextEncoder().encode(binding2.application_declaration_id)),
|
|
25003
|
-
field(
|
|
25126
|
+
field(hexBytes2(binding2.application_manifest_digest)),
|
|
25004
25127
|
field(uuidBytes(binding2.application_installation_id)),
|
|
25005
25128
|
...keys2.map(field),
|
|
25006
25129
|
field(new TextEncoder().encode(binding2.flow)),
|
|
@@ -25074,9 +25197,9 @@ ${end.comment}` : end.comment;
|
|
|
25074
25197
|
throw new Error("Invalid UUID value.");
|
|
25075
25198
|
}
|
|
25076
25199
|
const compact = value2.replaceAll("-", "");
|
|
25077
|
-
return
|
|
25200
|
+
return hexBytes2(compact);
|
|
25078
25201
|
}
|
|
25079
|
-
function
|
|
25202
|
+
function hexBytes2(value2) {
|
|
25080
25203
|
if (!/^[0-9a-f]+$/u.test(value2) || value2.length % 2 !== 0) {
|
|
25081
25204
|
throw new Error("Invalid hexadecimal value.");
|
|
25082
25205
|
}
|
|
@@ -29946,9 +30069,9 @@ ${end.comment}` : end.comment;
|
|
|
29946
30069
|
}
|
|
29947
30070
|
});
|
|
29948
30071
|
}
|
|
29949
|
-
column(st, i) {
|
|
30072
|
+
column(st, i, tag) {
|
|
29950
30073
|
const capi = this.sqlite3.capi;
|
|
29951
|
-
switch (
|
|
30074
|
+
switch (tag) {
|
|
29952
30075
|
case SQLITE_NULL:
|
|
29953
30076
|
return { kind: "Null" };
|
|
29954
30077
|
case SQLITE_INTEGER: {
|
|
@@ -30002,9 +30125,9 @@ ${end.comment}` : end.comment;
|
|
|
30002
30125
|
while (st.step()) {
|
|
30003
30126
|
if (limits && ++rows2 > limits.maxRows) throw new IndexError("Full", "index reply row budget exceeded");
|
|
30004
30127
|
for (let c = 0; c < columns; c++) {
|
|
30128
|
+
if (limits && ++valueCount > limits.maxValues) throw new IndexError("Full", "index reply value budget exceeded");
|
|
30129
|
+
const tag = capi.sqlite3_column_type(st.pointer, c);
|
|
30005
30130
|
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
30131
|
if (tag === SQLITE_TEXT || tag === SQLITE_BLOB) {
|
|
30009
30132
|
addBytes(5);
|
|
30010
30133
|
addBytes(capi.sqlite3_column_bytes(st.pointer, c));
|
|
@@ -30012,7 +30135,7 @@ ${end.comment}` : end.comment;
|
|
|
30012
30135
|
else if (tag === SQLITE_NULL) addBytes(1);
|
|
30013
30136
|
else throw new IndexError("Other", "unknown SQLite value type");
|
|
30014
30137
|
}
|
|
30015
|
-
values.push(this.column(st, c));
|
|
30138
|
+
values.push(this.column(st, c, tag));
|
|
30016
30139
|
}
|
|
30017
30140
|
}
|
|
30018
30141
|
out.push({
|
|
@@ -30248,33 +30371,46 @@ ${end.comment}` : end.comment;
|
|
|
30248
30371
|
}
|
|
30249
30372
|
};
|
|
30250
30373
|
Writer2 = class {
|
|
30251
|
-
|
|
30374
|
+
bytes = new Uint8Array(128);
|
|
30375
|
+
view = new DataView(this.bytes.buffer);
|
|
30252
30376
|
length = 0;
|
|
30253
30377
|
values = 0;
|
|
30254
30378
|
constructor(op2) {
|
|
30255
30379
|
this.put(MAGIC);
|
|
30256
30380
|
this.byte(op2);
|
|
30257
30381
|
}
|
|
30382
|
+
reserve(size2) {
|
|
30383
|
+
const start = this.length;
|
|
30384
|
+
const end = start + size2;
|
|
30385
|
+
if (end > APP_INDEX_LIMITS.maxBytes) throw full();
|
|
30386
|
+
if (end > this.bytes.length) {
|
|
30387
|
+
const capacity = Math.min(APP_INDEX_LIMITS.maxBytes, Math.max(end, this.bytes.length * 2));
|
|
30388
|
+
const next = new Uint8Array(capacity);
|
|
30389
|
+
next.set(this.bytes.subarray(0, start));
|
|
30390
|
+
this.bytes = next;
|
|
30391
|
+
this.view = new DataView(next.buffer);
|
|
30392
|
+
}
|
|
30393
|
+
this.length = end;
|
|
30394
|
+
return start;
|
|
30395
|
+
}
|
|
30258
30396
|
put(b) {
|
|
30259
|
-
|
|
30260
|
-
this.
|
|
30261
|
-
this.parts.push(b);
|
|
30397
|
+
const at = this.reserve(b.length);
|
|
30398
|
+
this.bytes.set(b, at);
|
|
30262
30399
|
}
|
|
30263
30400
|
byte(n) {
|
|
30264
|
-
this.
|
|
30401
|
+
const at = this.reserve(1);
|
|
30402
|
+
this.bytes[at] = n;
|
|
30265
30403
|
}
|
|
30266
30404
|
u32(n) {
|
|
30267
30405
|
if (!Number.isSafeInteger(n) || n < 0 || n > 4294967295) throw invalid7();
|
|
30268
|
-
const
|
|
30269
|
-
|
|
30270
|
-
this.put(b);
|
|
30406
|
+
const at = this.reserve(4);
|
|
30407
|
+
this.view.setUint32(at, n, true);
|
|
30271
30408
|
}
|
|
30272
30409
|
int(n, signed) {
|
|
30273
30410
|
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);
|
|
30411
|
+
const at = this.reserve(8);
|
|
30412
|
+
if (signed) this.view.setBigInt64(at, n, true);
|
|
30413
|
+
else this.view.setBigUint64(at, n, true);
|
|
30278
30414
|
}
|
|
30279
30415
|
data(b) {
|
|
30280
30416
|
this.u32(b.length);
|
|
@@ -30293,9 +30429,8 @@ ${end.comment}` : end.comment;
|
|
|
30293
30429
|
case "Real": {
|
|
30294
30430
|
if (!Number.isFinite(v.value)) throw invalid7();
|
|
30295
30431
|
this.byte(2);
|
|
30296
|
-
const
|
|
30297
|
-
|
|
30298
|
-
this.put(b);
|
|
30432
|
+
const at = this.reserve(8);
|
|
30433
|
+
this.view.setFloat64(at, v.value, true);
|
|
30299
30434
|
return;
|
|
30300
30435
|
}
|
|
30301
30436
|
case "Text":
|
|
@@ -30311,13 +30446,7 @@ ${end.comment}` : end.comment;
|
|
|
30311
30446
|
}
|
|
30312
30447
|
}
|
|
30313
30448
|
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;
|
|
30449
|
+
return this.bytes.slice(0, this.length);
|
|
30321
30450
|
}
|
|
30322
30451
|
};
|
|
30323
30452
|
AppBinaryIndexHost = class {
|
|
@@ -33867,7 +33996,7 @@ ${end.comment}` : end.comment;
|
|
|
33867
33996
|
conflicts.push({
|
|
33868
33997
|
target: r.target,
|
|
33869
33998
|
...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.`
|
|
33999
|
+
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
34000
|
});
|
|
33872
34001
|
break;
|
|
33873
34002
|
}
|
|
@@ -33944,7 +34073,7 @@ ${end.comment}` : end.comment;
|
|
|
33944
34073
|
name2 = (target2) => (target2.split("/").pop() ?? target2).replace(/\.(md|ya?ml|json)$/i, "");
|
|
33945
34074
|
plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
33946
34075
|
setting = (path) => (path.split("/").filter(Boolean).pop() ?? path).replace(/[_-]+/g, " ");
|
|
33947
|
-
UNRESOLVED = "This collection is missing
|
|
34076
|
+
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
34077
|
}
|
|
33949
34078
|
});
|
|
33950
34079
|
|
|
@@ -51079,12 +51208,12 @@ ${end.comment}` : end.comment;
|
|
|
51079
51208
|
// src/application/asset-pins.json
|
|
51080
51209
|
var asset_pins_default = {
|
|
51081
51210
|
runtime: {
|
|
51082
|
-
sha256: "
|
|
51083
|
-
bytes:
|
|
51084
|
-
maxBytes:
|
|
51211
|
+
sha256: "a27b57d4cb9c978725922af25928bb4242eb9580fa502815ea75993bbe92fe20",
|
|
51212
|
+
bytes: 4135951,
|
|
51213
|
+
maxBytes: 4135951,
|
|
51085
51214
|
source: {
|
|
51086
51215
|
repository: "mdbase-dev/mdbase-connect",
|
|
51087
|
-
commit: "
|
|
51216
|
+
commit: "7ed4e0b55a8c1becfc10ddbea55d794543ca1e15"
|
|
51088
51217
|
}
|
|
51089
51218
|
},
|
|
51090
51219
|
sqlite: {
|