@moyodb/sdk 1.3.0 → 1.4.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/CONTRIBUTING.md +46 -0
- package/README.md +4 -2
- package/dist/assets/browser-worker-Bj2ErRvC.js +4 -0
- package/dist/assets/browser-worker-Bj2ErRvC.js.map +1 -0
- package/dist/assets/shared-worker-CMeTcusa.js +2 -0
- package/dist/assets/shared-worker-CMeTcusa.js.map +1 -0
- package/dist/chunks/{indexing-CKtbpaZn.js → indexing-B0duqlUs.js} +43 -117
- package/dist/chunks/indexing-B0duqlUs.js.map +1 -0
- package/dist/demo.d.ts.map +1 -1
- package/dist/engine/README.md +4 -2
- package/dist/engine/moyodb_engine.d.ts +4 -2
- package/dist/engine/moyodb_engine.js +45 -22
- package/dist/engine/moyodb_engine_bg.wasm +0 -0
- package/dist/engine/moyodb_engine_bg.wasm.d.ts +3 -2
- package/dist/engine/package.json +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/indexing.d.ts.map +1 -1
- package/dist/moyodb-sdk.js +648 -653
- package/dist/moyodb-sdk.js.map +1 -1
- package/dist/node-engine.js +30 -35
- package/dist/node-engine.js.map +1 -1
- package/dist/node.js +23 -31
- package/dist/node.js.map +1 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/worker-api.d.ts +2 -5
- package/dist/worker-api.d.ts.map +1 -1
- package/dist/worker-protocol.d.ts +7 -2
- package/dist/worker-protocol.d.ts.map +1 -1
- package/dist/worker.d.ts +2 -2
- package/dist/worker.d.ts.map +1 -1
- package/package.json +4 -3
- package/dist/assets/browser-worker-DBt51gsS.js +0 -4
- package/dist/assets/browser-worker-DBt51gsS.js.map +0 -1
- package/dist/assets/shared-worker-NdniRuEL.js +0 -2
- package/dist/assets/shared-worker-NdniRuEL.js.map +0 -1
- package/dist/chunks/indexing-CKtbpaZn.js.map +0 -1
- /package/dist/engine/snippets/{moyodb-engine-54a406e33b0fb849 → moyodb-engine-1d53039816cbc2f7}/js/opfs_shim.js +0 -0
|
@@ -143,22 +143,21 @@ function deserializeWorkerError(error) {
|
|
|
143
143
|
const deserialized = new Error(error.message);
|
|
144
144
|
deserialized.name = error.name || error.code || "Error";
|
|
145
145
|
if (error.stack) deserialized.stack = error.stack;
|
|
146
|
-
if (error.code)
|
|
147
|
-
value: error.code,
|
|
148
|
-
enumerable: true,
|
|
149
|
-
configurable: true
|
|
150
|
-
});
|
|
146
|
+
if (error.code) defineErrorCode(deserialized, error.code);
|
|
151
147
|
return deserialized;
|
|
152
148
|
}
|
|
153
149
|
function workerProtocolError(name, message, code = name) {
|
|
154
150
|
const error = new Error(message);
|
|
155
151
|
error.name = name;
|
|
152
|
+
defineErrorCode(error, code);
|
|
153
|
+
return error;
|
|
154
|
+
}
|
|
155
|
+
function defineErrorCode(error, code) {
|
|
156
156
|
Object.defineProperty(error, "code", {
|
|
157
157
|
value: code,
|
|
158
158
|
enumerable: true,
|
|
159
159
|
configurable: true
|
|
160
160
|
});
|
|
161
|
-
return error;
|
|
162
161
|
}
|
|
163
162
|
function prepareWorkerCommandPayload(command, args) {
|
|
164
163
|
if (command === "autocommit") {
|
|
@@ -263,7 +262,7 @@ function decodeWorkerCommandPayload(command, args) {
|
|
|
263
262
|
if (command === "getMany" || command === "deleteMany") {
|
|
264
263
|
const [txId, store, keys] = args;
|
|
265
264
|
if (!Array.isArray(keys)) {
|
|
266
|
-
if (!
|
|
265
|
+
if (!isPackedPayload(keys, PACKED_BINARY_LIST_V1)) throw workerProtocolError("WorkerProtocolError", "invalid packed binary-list argument");
|
|
267
266
|
return [
|
|
268
267
|
txId,
|
|
269
268
|
store,
|
|
@@ -274,11 +273,11 @@ function decodeWorkerCommandPayload(command, args) {
|
|
|
274
273
|
if (command === "putMany") {
|
|
275
274
|
const [txId, store, entries, options] = args;
|
|
276
275
|
if (!Array.isArray(entries)) {
|
|
277
|
-
if (!
|
|
276
|
+
if (!isPackedPayload(entries, PACKED_BINARY_LIST_V1)) throw workerProtocolError("WorkerProtocolError", "invalid packed putMany argument");
|
|
278
277
|
return [
|
|
279
278
|
txId,
|
|
280
279
|
store,
|
|
281
|
-
|
|
280
|
+
unpackPutManyPayload(entries, false),
|
|
282
281
|
options
|
|
283
282
|
];
|
|
284
283
|
}
|
|
@@ -286,21 +285,21 @@ function decodeWorkerCommandPayload(command, args) {
|
|
|
286
285
|
if (command === "applyBatch") {
|
|
287
286
|
const [txId, store, ops] = args;
|
|
288
287
|
if (!Array.isArray(ops)) {
|
|
289
|
-
if (!
|
|
288
|
+
if (!isPackedPayload(ops, PACKED_BATCH_OPS_V1)) throw workerProtocolError("WorkerProtocolError", "invalid packed batch argument");
|
|
290
289
|
return [
|
|
291
290
|
txId,
|
|
292
291
|
store,
|
|
293
|
-
|
|
292
|
+
unpackBatchPayload(ops, false)
|
|
294
293
|
];
|
|
295
294
|
}
|
|
296
295
|
}
|
|
297
296
|
return args;
|
|
298
297
|
}
|
|
299
298
|
function packedBinaryListBytes(value) {
|
|
300
|
-
return
|
|
299
|
+
return isPackedPayload(value, PACKED_BINARY_LIST_V1) ? value.bytes : null;
|
|
301
300
|
}
|
|
302
301
|
function packedBatchOpsBytes(value) {
|
|
303
|
-
return
|
|
302
|
+
return isPackedPayload(value, PACKED_BATCH_OPS_V1) ? value.bytes : null;
|
|
304
303
|
}
|
|
305
304
|
function unpackPackedBinaryList(bytes) {
|
|
306
305
|
return unpackBinaryList({
|
|
@@ -309,22 +308,22 @@ function unpackPackedBinaryList(bytes) {
|
|
|
309
308
|
});
|
|
310
309
|
}
|
|
311
310
|
function unpackPackedBinaryPairKeys(bytes) {
|
|
312
|
-
return
|
|
311
|
+
return unpackPutManyPayload({
|
|
313
312
|
__moyodbPacked: PACKED_BINARY_LIST_V1,
|
|
314
313
|
bytes
|
|
315
|
-
});
|
|
314
|
+
}, true);
|
|
316
315
|
}
|
|
317
316
|
function unpackPackedBatchOps(bytes) {
|
|
318
|
-
return
|
|
317
|
+
return unpackBatchPayload({
|
|
319
318
|
__moyodbPacked: PACKED_BATCH_OPS_V1,
|
|
320
319
|
bytes
|
|
321
|
-
});
|
|
320
|
+
}, false);
|
|
322
321
|
}
|
|
323
322
|
function unpackPackedBatchOpKeys(bytes) {
|
|
324
|
-
return
|
|
323
|
+
return unpackBatchPayload({
|
|
325
324
|
__moyodbPacked: PACKED_BATCH_OPS_V1,
|
|
326
325
|
bytes
|
|
327
|
-
});
|
|
326
|
+
}, true);
|
|
328
327
|
}
|
|
329
328
|
function packedOptionalValues(bytes) {
|
|
330
329
|
return {
|
|
@@ -355,13 +354,13 @@ function unpackPackedOptionalValues(bytes) {
|
|
|
355
354
|
return items;
|
|
356
355
|
}
|
|
357
356
|
function prepareWorkerResponsePayload(command, result) {
|
|
358
|
-
if ((command === "scan" || command === "scanByIndex") && (isPackedEngineScanRows(result) ||
|
|
357
|
+
if ((command === "scan" || command === "scanByIndex") && (isPackedEngineScanRows(result) || isPackedPayload(result, PACKED_SCAN_ROWS_V1))) return {
|
|
359
358
|
result,
|
|
360
359
|
transfer: collectDirectBinaryTransferable(result.bytes)
|
|
361
360
|
};
|
|
362
361
|
if (command === "scanPage") {
|
|
363
362
|
const page = result;
|
|
364
|
-
if (isRecord(page) && (isPackedEngineScanRows(page.rows) ||
|
|
363
|
+
if (isRecord(page) && (isPackedEngineScanRows(page.rows) || isPackedPayload(page.rows, PACKED_SCAN_ROWS_V1))) return {
|
|
365
364
|
result: page,
|
|
366
365
|
transfer: collectDirectBinaryTransferable(page.rows.bytes)
|
|
367
366
|
};
|
|
@@ -376,13 +375,13 @@ function prepareWorkerResponsePayload(command, result) {
|
|
|
376
375
|
};
|
|
377
376
|
}
|
|
378
377
|
}
|
|
379
|
-
if (command === "getMany" &&
|
|
378
|
+
if (command === "getMany" && isPackedPayload(result, PACKED_OPTIONAL_VALUES_V1)) return {
|
|
380
379
|
result,
|
|
381
380
|
transfer: collectDirectBinaryTransferable(result.bytes)
|
|
382
381
|
};
|
|
383
382
|
if (command === "scanByIndexPage") {
|
|
384
383
|
const page = result;
|
|
385
|
-
if (isRecord(page) &&
|
|
384
|
+
if (isRecord(page) && isPackedPayload(page.rows, PACKED_SCAN_ROWS_V1)) return {
|
|
386
385
|
result: page,
|
|
387
386
|
transfer: collectTransferablesForValue(page)
|
|
388
387
|
};
|
|
@@ -444,7 +443,7 @@ function prepareWorkerResponsePayload(command, result) {
|
|
|
444
443
|
function decodeWorkerResponsePayload(command, result) {
|
|
445
444
|
if (command === "scanPage") {
|
|
446
445
|
if (!isRecord(result) || typeof result.done !== "boolean" || typeof result.bytes !== "number" || !Number.isSafeInteger(result.bytes) || result.bytes < 4 || result.cursorId !== void 0 && (typeof result.cursorId !== "number" || !Number.isSafeInteger(result.cursorId) || result.cursorId <= 0) || (result.done ? result.cursorId !== void 0 : result.cursorId === void 0)) throw workerProtocolError("WorkerProtocolError", "invalid scan page response");
|
|
447
|
-
const rows = isPackedEngineScanRows(result.rows) ? unpackPackedScanRows(result.rows.bytes) :
|
|
446
|
+
const rows = isPackedEngineScanRows(result.rows) ? unpackPackedScanRows(result.rows.bytes) : isPackedPayload(result.rows, PACKED_SCAN_ROWS_V1) ? unpackScanRows(result.rows) : result.rows;
|
|
448
447
|
if (!Array.isArray(rows)) throw workerProtocolError("WorkerProtocolError", "invalid scan page rows");
|
|
449
448
|
let bytes = 4;
|
|
450
449
|
for (const row of rows) {
|
|
@@ -460,17 +459,17 @@ function decodeWorkerResponsePayload(command, result) {
|
|
|
460
459
|
};
|
|
461
460
|
}
|
|
462
461
|
if ((command === "scan" || command === "scanByIndex") && isPackedEngineScanRows(result)) return unpackPackedScanRows(result.bytes);
|
|
463
|
-
if (command === "getMany" &&
|
|
464
|
-
if (command === "getMany" &&
|
|
462
|
+
if (command === "getMany" && isPackedPayload(result, PACKED_NULLABLE_BINARY_LIST_V1)) return unpackNullableBinaryList(result);
|
|
463
|
+
if (command === "getMany" && isPackedPayload(result, PACKED_OPTIONAL_VALUES_V1)) return unpackPackedOptionalValues(result.bytes);
|
|
465
464
|
if (command === "getMany" && !Array.isArray(result)) throw workerProtocolError("WorkerProtocolError", "invalid packed getMany response");
|
|
466
465
|
if (command === "scanByIndexPage") {
|
|
467
|
-
if (!isRecord(result) || !Array.isArray(result.rows) && !
|
|
466
|
+
if (!isRecord(result) || !Array.isArray(result.rows) && !isPackedPayload(result.rows, PACKED_SCAN_ROWS_V1) || result.cursor !== null && !(result.cursor instanceof Uint8Array)) throw workerProtocolError("WorkerProtocolError", "invalid packed index scan page response");
|
|
468
467
|
return {
|
|
469
|
-
rows:
|
|
468
|
+
rows: isPackedPayload(result.rows, PACKED_SCAN_ROWS_V1) ? unpackScanRows(result.rows) : result.rows,
|
|
470
469
|
cursor: result.cursor
|
|
471
470
|
};
|
|
472
471
|
}
|
|
473
|
-
if ((command === "scan" || command === "scanByIndex") &&
|
|
472
|
+
if ((command === "scan" || command === "scanByIndex") && isPackedPayload(result, PACKED_SCAN_ROWS_V1)) return unpackScanRows(result);
|
|
474
473
|
if ((command === "scan" || command === "scanByIndex") && !Array.isArray(result)) throw workerProtocolError("WorkerProtocolError", "invalid packed scan response");
|
|
475
474
|
return result;
|
|
476
475
|
}
|
|
@@ -709,7 +708,7 @@ function unpackBinaryList(payload) {
|
|
|
709
708
|
if (readOffset !== bytes.byteLength) throw workerProtocolError("WorkerProtocolError", "packed binary-list payload has trailing bytes");
|
|
710
709
|
return items;
|
|
711
710
|
}
|
|
712
|
-
function
|
|
711
|
+
function unpackPutManyPayload(payload, keysOnly) {
|
|
713
712
|
const bytes = payload.bytes;
|
|
714
713
|
if (!(bytes instanceof Uint8Array) || bytes.byteLength < 4) throw workerProtocolError("WorkerProtocolError", "invalid packed putMany payload");
|
|
715
714
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
@@ -729,38 +728,13 @@ function unpackBinaryPairs(payload) {
|
|
|
729
728
|
if (keyEnd > U32_MAX || keyEnd > bytes.byteLength) throw workerProtocolError("WorkerProtocolError", "packed putMany key exceeds payload length");
|
|
730
729
|
const valueEnd = keyEnd + valueLength;
|
|
731
730
|
if (valueEnd > U32_MAX || valueEnd > bytes.byteLength) throw workerProtocolError("WorkerProtocolError", "packed putMany value exceeds payload length");
|
|
732
|
-
entries[index] =
|
|
731
|
+
if (keysOnly) entries[index] = bytes.subarray(readOffset, keyEnd);
|
|
732
|
+
else entries[index] = [bytes.subarray(readOffset, keyEnd), bytes.subarray(keyEnd, valueEnd)];
|
|
733
733
|
readOffset = valueEnd;
|
|
734
734
|
}
|
|
735
735
|
if (readOffset !== bytes.byteLength) throw workerProtocolError("WorkerProtocolError", "packed putMany payload has trailing bytes");
|
|
736
736
|
return entries;
|
|
737
737
|
}
|
|
738
|
-
function unpackBinaryPairKeys(payload) {
|
|
739
|
-
const bytes = payload.bytes;
|
|
740
|
-
if (!(bytes instanceof Uint8Array) || bytes.byteLength < 4) throw workerProtocolError("WorkerProtocolError", "invalid packed putMany payload");
|
|
741
|
-
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
742
|
-
const itemCount = view.getUint32(0, true);
|
|
743
|
-
if (itemCount % 2 !== 0) throw workerProtocolError("WorkerProtocolError", "packed putMany payload has an odd item count");
|
|
744
|
-
const payloadOffset = checkedAdd(4, checkedByteCount(itemCount, 4, "packed putMany metadata"), "packed putMany header");
|
|
745
|
-
if (payloadOffset > bytes.byteLength) throw workerProtocolError("WorkerProtocolError", "packed putMany metadata exceeds payload length");
|
|
746
|
-
const entryCount = itemCount / 2;
|
|
747
|
-
const keys = new Array(entryCount);
|
|
748
|
-
let metadataOffset = 4;
|
|
749
|
-
let readOffset = payloadOffset;
|
|
750
|
-
for (let index = 0; index < entryCount; index += 1) {
|
|
751
|
-
const keyLength = view.getUint32(metadataOffset, true);
|
|
752
|
-
const valueLength = view.getUint32(metadataOffset + 4, true);
|
|
753
|
-
metadataOffset += 8;
|
|
754
|
-
const keyEnd = readOffset + keyLength;
|
|
755
|
-
if (keyEnd > U32_MAX || keyEnd > bytes.byteLength) throw workerProtocolError("WorkerProtocolError", "packed putMany key exceeds payload length");
|
|
756
|
-
const valueEnd = keyEnd + valueLength;
|
|
757
|
-
if (valueEnd > U32_MAX || valueEnd > bytes.byteLength) throw workerProtocolError("WorkerProtocolError", "packed putMany value exceeds payload length");
|
|
758
|
-
keys[index] = bytes.subarray(readOffset, keyEnd);
|
|
759
|
-
readOffset = valueEnd;
|
|
760
|
-
}
|
|
761
|
-
if (readOffset !== bytes.byteLength) throw workerProtocolError("WorkerProtocolError", "packed putMany payload has trailing bytes");
|
|
762
|
-
return keys;
|
|
763
|
-
}
|
|
764
738
|
function packNullableBinaryList(items) {
|
|
765
739
|
const count = items.length;
|
|
766
740
|
const metadataBytes = checkedByteCount(count, 5, "packed nullable binary-list metadata");
|
|
@@ -941,7 +915,7 @@ function packBatchOps(ops) {
|
|
|
941
915
|
bytes
|
|
942
916
|
};
|
|
943
917
|
}
|
|
944
|
-
function
|
|
918
|
+
function unpackBatchPayload(payload, keysOnly) {
|
|
945
919
|
const bytes = payload.bytes;
|
|
946
920
|
if (!(bytes instanceof Uint8Array) || bytes.byteLength < 4) throw workerProtocolError("WorkerProtocolError", "invalid packed batch payload");
|
|
947
921
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
@@ -971,69 +945,22 @@ function unpackBatchOps(payload) {
|
|
|
971
945
|
if (kind !== BATCH_OP_PUT) throw workerProtocolError("WorkerProtocolError", `packed batch operation has invalid kind byte: ${kind}`);
|
|
972
946
|
const valueEnd = readOffset + valueLength;
|
|
973
947
|
if (valueEnd > U32_MAX || valueEnd > bytes.byteLength) throw workerProtocolError("WorkerProtocolError", "packed batch value exceeds payload length");
|
|
974
|
-
ops[index] = {
|
|
948
|
+
if (keysOnly) ops[index] = {
|
|
975
949
|
kind: "put",
|
|
976
|
-
key
|
|
977
|
-
value: bytes.subarray(readOffset, valueEnd)
|
|
950
|
+
key
|
|
978
951
|
};
|
|
979
|
-
|
|
980
|
-
}
|
|
981
|
-
if (readOffset !== bytes.byteLength) throw workerProtocolError("WorkerProtocolError", "packed batch payload has trailing bytes");
|
|
982
|
-
return ops;
|
|
983
|
-
}
|
|
984
|
-
function unpackBatchOpKeys(payload) {
|
|
985
|
-
const bytes = payload.bytes;
|
|
986
|
-
if (!(bytes instanceof Uint8Array) || bytes.byteLength < 4) throw workerProtocolError("WorkerProtocolError", "invalid packed batch payload");
|
|
987
|
-
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
988
|
-
const count = view.getUint32(0, true);
|
|
989
|
-
const payloadOffset = checkedAdd(4, checkedByteCount(count, 9, "packed batch metadata"), "packed batch header");
|
|
990
|
-
if (payloadOffset > bytes.byteLength) throw workerProtocolError("WorkerProtocolError", "packed batch metadata exceeds payload length");
|
|
991
|
-
const ops = new Array(count);
|
|
992
|
-
let metadataOffset = 4;
|
|
993
|
-
let readOffset = payloadOffset;
|
|
994
|
-
for (let index = 0; index < count; index += 1) {
|
|
995
|
-
const kind = view.getUint8(metadataOffset);
|
|
996
|
-
const keyLength = view.getUint32(metadataOffset + 1, true);
|
|
997
|
-
const valueLength = view.getUint32(metadataOffset + 5, true);
|
|
998
|
-
metadataOffset += 9;
|
|
999
|
-
const keyEnd = readOffset + keyLength;
|
|
1000
|
-
if (keyEnd > U32_MAX || keyEnd > bytes.byteLength) throw workerProtocolError("WorkerProtocolError", "packed batch key exceeds payload length");
|
|
1001
|
-
const key = bytes.subarray(readOffset, keyEnd);
|
|
1002
|
-
readOffset = keyEnd;
|
|
1003
|
-
if (kind === BATCH_OP_DELETE) {
|
|
1004
|
-
if (valueLength !== 0) throw workerProtocolError("WorkerProtocolError", "packed delete operation has a value payload");
|
|
1005
|
-
ops[index] = {
|
|
1006
|
-
kind: "delete",
|
|
1007
|
-
key
|
|
1008
|
-
};
|
|
1009
|
-
continue;
|
|
1010
|
-
}
|
|
1011
|
-
if (kind !== BATCH_OP_PUT) throw workerProtocolError("WorkerProtocolError", `packed batch operation has invalid kind byte: ${kind}`);
|
|
1012
|
-
const valueEnd = readOffset + valueLength;
|
|
1013
|
-
if (valueEnd > U32_MAX || valueEnd > bytes.byteLength) throw workerProtocolError("WorkerProtocolError", "packed batch value exceeds payload length");
|
|
1014
|
-
ops[index] = {
|
|
952
|
+
else ops[index] = {
|
|
1015
953
|
kind: "put",
|
|
1016
|
-
key
|
|
954
|
+
key,
|
|
955
|
+
value: bytes.subarray(readOffset, valueEnd)
|
|
1017
956
|
};
|
|
1018
957
|
readOffset = valueEnd;
|
|
1019
958
|
}
|
|
1020
959
|
if (readOffset !== bytes.byteLength) throw workerProtocolError("WorkerProtocolError", "packed batch payload has trailing bytes");
|
|
1021
960
|
return ops;
|
|
1022
961
|
}
|
|
1023
|
-
function
|
|
1024
|
-
return isRecord(value) && value.__moyodbPacked ===
|
|
1025
|
-
}
|
|
1026
|
-
function isPackedNullableBinaryList(value) {
|
|
1027
|
-
return isRecord(value) && value.__moyodbPacked === PACKED_NULLABLE_BINARY_LIST_V1 && value.bytes instanceof Uint8Array;
|
|
1028
|
-
}
|
|
1029
|
-
function isPackedScanRows(value) {
|
|
1030
|
-
return isRecord(value) && value.__moyodbPacked === PACKED_SCAN_ROWS_V1 && value.bytes instanceof Uint8Array;
|
|
1031
|
-
}
|
|
1032
|
-
function isPackedBatchOps(value) {
|
|
1033
|
-
return isRecord(value) && value.__moyodbPacked === PACKED_BATCH_OPS_V1 && value.bytes instanceof Uint8Array;
|
|
1034
|
-
}
|
|
1035
|
-
function isPackedOptionalValues(value) {
|
|
1036
|
-
return isRecord(value) && value.__moyodbPacked === PACKED_OPTIONAL_VALUES_V1 && value.bytes instanceof Uint8Array;
|
|
962
|
+
function isPackedPayload(value, tag) {
|
|
963
|
+
return isRecord(value) && value.__moyodbPacked === tag && value.bytes instanceof Uint8Array;
|
|
1037
964
|
}
|
|
1038
965
|
function checkedByteCount(count, itemBytes, what) {
|
|
1039
966
|
if (!Number.isSafeInteger(count) || count < 0) throw workerProtocolError("WorkerProtocolError", `${what} count is invalid: ${count}`);
|
|
@@ -1247,7 +1174,7 @@ function normalizeError(error) {
|
|
|
1247
1174
|
}
|
|
1248
1175
|
//#endregion
|
|
1249
1176
|
//#region src/codec.ts
|
|
1250
|
-
var encoder
|
|
1177
|
+
var encoder = new TextEncoder();
|
|
1251
1178
|
var decoder = new TextDecoder();
|
|
1252
1179
|
var jsonDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
1253
1180
|
var TYPE_NULL = 16;
|
|
@@ -1261,7 +1188,7 @@ var COMPOUND_ESCAPE_CONT = 255;
|
|
|
1261
1188
|
var COMPOUND_TERM = 0;
|
|
1262
1189
|
var F64_MASK = BigInt("0xffffffffffffffff");
|
|
1263
1190
|
function utf8Encode(value) {
|
|
1264
|
-
return encoder
|
|
1191
|
+
return encoder.encode(value);
|
|
1265
1192
|
}
|
|
1266
1193
|
function utf8Decode(bytes) {
|
|
1267
1194
|
return decoder.decode(bytes);
|
|
@@ -1403,7 +1330,6 @@ function encodeSortableNumber(value) {
|
|
|
1403
1330
|
}
|
|
1404
1331
|
//#endregion
|
|
1405
1332
|
//#region src/indexing.ts
|
|
1406
|
-
var encoder = new TextEncoder();
|
|
1407
1333
|
var fatalDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
1408
1334
|
var MISSING = Symbol("moyodb.indexing.missing");
|
|
1409
1335
|
var FNV64_OFFSET = BigInt("0xcbf29ce484222325");
|
|
@@ -1602,7 +1528,7 @@ function serializeIndexKeyPath(def) {
|
|
|
1602
1528
|
}
|
|
1603
1529
|
function makeInternalIndexStoreName(store, name) {
|
|
1604
1530
|
const candidate = `${INTERNAL_INDEX_STORE_PREFIX}${base64Url(utf8Encode(store))}:${base64Url(utf8Encode(name))}`;
|
|
1605
|
-
if (
|
|
1531
|
+
if (utf8Encode(candidate).length <= 255) return candidate;
|
|
1606
1532
|
return `${INTERNAL_INDEX_STORE_PREFIX}h:${fnv1a64Hex(utf8Encode(`${store}\u0000${name}`))}`;
|
|
1607
1533
|
}
|
|
1608
1534
|
function base64Url(bytes) {
|
|
@@ -1654,4 +1580,4 @@ function validateIndexRangeShape(range) {
|
|
|
1654
1580
|
//#endregion
|
|
1655
1581
|
export { StoreExistsError as $, prefixRange as A, packedBinaryListBytes as At, DatabaseClosedError as B, unpackPackedOptionalValues as Bt, compoundKey as C, isWorkerProtocolReadyEnvelope as Ct, indexKey as D, isWorkerProtocolResponseBatchMessage as Dt, encodeIndexScalar as E, isWorkerProtocolRequestMessage as Et, utf8Encode as F, serializeWorkerError as Ft, InvalidRangeError as G, isRecord as Gt, InjectedFailureError as H, workerProtocolError as Ht, ChangeFeedCompactedError as I, unpackPackedBatchOpKeys as It, ReadonlyTransactionError as J, KeyTooLargeError as K, ConstraintError as L, unpackPackedBatchOps as Lt, splitCompoundKey as M, packedScanRows as Mt, u64Key as N, prepareWorkerCommandPayload as Nt, jsonDecode as O, isWorkerProtocolResponseMessage as Ot, utf8Decode as P, prepareWorkerResponsePayload as Pt, StorageError as Q, CorruptionError as R, unpackPackedBinaryList as Rt, toPublicIndexDefinitions as S, isWorkerProtocolEnvelope as St, encodeCompoundKeyParts as T, isWorkerProtocolRequestBatchMessage as Tt, InternalError as U, clampTimerDelayMs as Ut, IndexNotFoundError as V, unpackPackedScanRows as Vt, InvalidOpenOptionsError as W, compareStringsByCodeUnit as Wt, ReservedStoreNameError as X, RecoveryRequiredError as Y, SerializationError as Z, indexRangeToPhysicalRange as _, decodeWorkerCommandPayload as _t, createIndexKeyExtractor as a, UnsupportedPlatformError as at, normalizeIndexDefinitions as b, isAutocommitCommand as bt, decodeIndexedDocument as c, WriteTransactionAlreadyOpenError as ct, encodeIndexMetadataValue as d, WORKER_PROTOCOL_READY as dt, StoreNameTooLongError as et, extractLogicalIndexKey as f, WORKER_PROTOCOL_REQUEST as ft, indexKeyExactRange as g, captureWorkerPayload as gt, indexDefinitionIdentity as h, WORKER_PROTOCOL_RESPONSE_BATCH as ht, compareNormalizedIndexDefinitions as i, UniqueIndexConstraintError as it, prefixSuccessor as j, packedOptionalValues as jt, jsonEncode as k, packedBatchOpsBytes as kt, encodeIndexEntryKey as l, normalizeError as lt, findIndexDefinition as m, WORKER_PROTOCOL_RESPONSE as mt, assertPublicStoreName as n, TransactionClosedError as nt, decodeIndexEntryKey as o, ValueTooLargeError as ot, extractLogicalIndexKeyFromDocument as p, WORKER_PROTOCOL_REQUEST_BATCH as pt, MoyoDbError as q, cloneNormalizedIndexDefinitions as r, TransactionConflictError as rt, decodeIndexMetadataValue as s, VersionError as st, INDEX_METADATA_STORE as t, StoreNotFoundError as tt, encodeIndexMetadataKey as u, MAX_WORKER_BATCH_BYTES as ut, indexesForStore as v, decodeWorkerResponsePayload as vt, compoundKeyRange as w, isWorkerProtocolReadyMessage as wt, serializeNormalizedIndexDefinitions as x, isWorkerCommand as xt, isInternalStoreName as y, deserializeWorkerError as yt, DatabaseBusyError as z, unpackPackedBinaryPairKeys as zt };
|
|
1656
1582
|
|
|
1657
|
-
//# sourceMappingURL=indexing-
|
|
1583
|
+
//# sourceMappingURL=indexing-B0duqlUs.js.map
|