msgpackr 1.11.13 → 1.12.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/dist/index-no-eval.cjs +15 -2
- package/dist/index-no-eval.cjs.map +1 -1
- package/dist/index-no-eval.min.js +1 -1
- package/dist/index-no-eval.min.js.map +1 -1
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/node.cjs +15 -2
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +109 -2
- package/dist/test.js.map +1 -1
- package/pack.js +15 -2
- package/package.json +1 -1
package/dist/node.cjs
CHANGED
|
@@ -1362,7 +1362,13 @@ class Packr extends Unpackr {
|
|
|
1362
1362
|
hasSharedUpdate = false;
|
|
1363
1363
|
let encodingError;
|
|
1364
1364
|
try {
|
|
1365
|
-
|
|
1365
|
+
// readOnlyStructures: skip the random-access struct write path so NO new struct is
|
|
1366
|
+
// minted. randomAccessStructure stays true (the struct READ path and the struct-safe
|
|
1367
|
+
// integer boundary are preserved, so existing struct data still decodes), but objects
|
|
1368
|
+
// fall through to the normal pack()->writeObject->writeRecord path and are written as
|
|
1369
|
+
// classic shared-structure records (byte range 0x40-0x7f, disjoint from struct headers
|
|
1370
|
+
// at 0x20-0x3f) — the bounded, width-agnostic encoding used before struct mode.
|
|
1371
|
+
if (packr.randomAccessStructure && !packr.readOnlyStructures && value && typeof value === 'object') {
|
|
1366
1372
|
if (value.constructor === Object) writeStruct(value); // simple object
|
|
1367
1373
|
else if (value.constructor !== Map && !Array.isArray(value) && !extensionClasses.some(extClass => value instanceof extClass)) {
|
|
1368
1374
|
// allow user classes, if they don't need special handling (but do use toJSON if available)
|
|
@@ -1428,7 +1434,14 @@ class Packr extends Unpackr {
|
|
|
1428
1434
|
let newSharedData = prepareStructures$1(structures, packr);
|
|
1429
1435
|
if (!encodingError) { // TODO: If there is an encoding error, should make the structures as uninitialized so they get rebuilt next time
|
|
1430
1436
|
if (packr.saveStructures(newSharedData, newSharedData.isCompatible) === false) {
|
|
1431
|
-
//
|
|
1437
|
+
// The save was declined (a concurrent writer updated the shared structures,
|
|
1438
|
+
// or the store transaction did not durably commit). Our in-memory
|
|
1439
|
+
// structures + transition trie may now reference record ids that were
|
|
1440
|
+
// never persisted; re-packing as-is would re-emit the same record pointing
|
|
1441
|
+
// at an unpersisted structure (-> "Record id is not defined" on decode).
|
|
1442
|
+
// Mark structures uninitialized so the re-pack reloads durable structures
|
|
1443
|
+
// via getStructures, rebuilds the transition trie, and re-mints + re-saves.
|
|
1444
|
+
structures.uninitialized = true;
|
|
1432
1445
|
return packr.pack(value, encodeOptions)
|
|
1433
1446
|
}
|
|
1434
1447
|
packr.lastNamedStructuresLength = sharedLength;
|