sandboxedjs 0.1.83 → 0.1.85

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.
Binary file
@@ -18,9 +18,9 @@
18
18
  "artifacts": {
19
19
  "moduleUrl": "./python.js",
20
20
  "hashes": {
21
- "python.js": "sha256-f15ddd5fe1dd1185aaf8d87be4822942bd5f985b05fd1f70fe2e74e060c86ab2",
22
- "python.wasm": "sha256-9483f54309bb44181ae8a2c7f415c1cf6ada4d2fe45f23bceb25deb51e008be2",
23
- "python.data": "sha256-416479344ec1a72841a3e0f978bb4b5f212ae03b9256d78b3f3d71bdb5d3082a",
21
+ "python.js": "sha256-ec01d17c48c14a6d442bb06e3351570fe3e0d8bfc857ba2c469e6fe58cbe0860",
22
+ "python.wasm": "sha256-f6d74973d23afb6401481343eee0190d3617a472c5bd36ed204785b13dcb8ce6",
23
+ "python.data": "sha256-69671e9d5e40b71da03fe8e8f9afc97f4563f6f9cadfcad06e8391963b247912",
24
24
  "python.worker.js": "sha256-63bb1df52c4e3a95eae7b2d77c98554188fcc5925e72628ea0c34d5c573977a5"
25
25
  }
26
26
  },
@@ -2951,6 +2951,7 @@ var MemoryStat = class {
2951
2951
  }
2952
2952
  };
2953
2953
  var encoder2 = new TextEncoder();
2954
+ var appendCapacity = /* @__PURE__ */ new WeakMap();
2954
2955
  var MemoryVolume = class {
2955
2956
  entries = /* @__PURE__ */ new Map();
2956
2957
  nextIno = 2;
@@ -2985,10 +2986,23 @@ var MemoryVolume = class {
2985
2986
  const current = this.entries.get(key);
2986
2987
  if (!current) return this.writeFileSync(key, bytes);
2987
2988
  if (current.kind !== "file") throw new VolumeError(current.kind === "directory" ? "EISDIR" : "EINVAL", "open", key);
2988
- const next = new Uint8Array(current.data.length + bytes.length);
2989
- next.set(current.data);
2990
- next.set(bytes, current.data.length);
2991
- current.data = next;
2989
+ const length = current.data.length;
2990
+ const needed = length + bytes.length;
2991
+ const backing = current.data.buffer;
2992
+ const ownsTail = current.data.byteOffset === 0 && backing instanceof ArrayBuffer && backing.byteLength >= needed && appendCapacity.get(current) === backing;
2993
+ if (ownsTail) {
2994
+ const grown = new Uint8Array(backing, 0, needed);
2995
+ grown.set(bytes, length);
2996
+ current.data = grown;
2997
+ } else {
2998
+ const capacity = Math.max(needed, length * 2, 64 * 1024);
2999
+ const buffer = new ArrayBuffer(capacity);
3000
+ const grown = new Uint8Array(buffer, 0, needed);
3001
+ grown.set(current.data);
3002
+ grown.set(bytes, length);
3003
+ current.data = grown;
3004
+ appendCapacity.set(current, buffer);
3005
+ }
2992
3006
  this.touchChanged(current, true);
2993
3007
  }
2994
3008
  readdirSync(path) {