@bman654/clodex 2.6.0 → 2.6.1
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/cli.js +23 -5
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -374,7 +374,7 @@ import { join } from "path";
|
|
|
374
374
|
// package.json
|
|
375
375
|
var package_default = {
|
|
376
376
|
name: "@bman654/clodex",
|
|
377
|
-
version: "2.6.
|
|
377
|
+
version: "2.6.1",
|
|
378
378
|
publishConfig: {
|
|
379
379
|
access: "public"
|
|
380
380
|
},
|
|
@@ -16822,21 +16822,36 @@ function parseBunModuleNamesAtUnchecked(fd, offsetsAt) {
|
|
|
16822
16822
|
}
|
|
16823
16823
|
return { names, entryPointId, offsets: nameOffsets };
|
|
16824
16824
|
}
|
|
16825
|
-
function
|
|
16825
|
+
function findStandIn(fd, fileSize, marker) {
|
|
16826
16826
|
const needle = Buffer.from(marker);
|
|
16827
16827
|
const chunkBytes = 8 * 1024 * 1024;
|
|
16828
|
+
const offsets = [];
|
|
16828
16829
|
let carry = Buffer.alloc(0);
|
|
16829
16830
|
for (let position = 0; position < fileSize; ) {
|
|
16830
16831
|
const length = Math.min(chunkBytes, fileSize - position);
|
|
16831
16832
|
const chunk = readAt(fd, length, position);
|
|
16832
16833
|
if (!chunk) throw new Error("could not re-read the candidate to verify the entry-module name");
|
|
16833
16834
|
const window = carry.length > 0 ? Buffer.concat([carry, chunk]) : chunk;
|
|
16834
|
-
|
|
16835
|
-
|
|
16835
|
+
const windowAt = position - carry.length;
|
|
16836
|
+
for (let at = window.indexOf(needle); at >= 0; at = window.indexOf(needle, at + 1)) {
|
|
16837
|
+
offsets.push(windowAt + at);
|
|
16836
16838
|
}
|
|
16837
16839
|
carry = Buffer.from(window.subarray(Math.max(0, window.length - (needle.length - 1))));
|
|
16838
16840
|
position += length;
|
|
16839
16841
|
}
|
|
16842
|
+
return offsets;
|
|
16843
|
+
}
|
|
16844
|
+
function restoreEveryStandIn(fd, fileSize, shim) {
|
|
16845
|
+
const moduleNameCopies = () => findStandIn(fd, fileSize, shim.marker).filter((offset) => isModuleNameAt(fd, offset, shim.marker));
|
|
16846
|
+
const found = moduleNameCopies();
|
|
16847
|
+
for (const offset of found) writeNameBytes(fd, shim.original, offset);
|
|
16848
|
+
if (found.length > 0 && moduleNameCopies().length > 0) {
|
|
16849
|
+
throw new Error(`the entry-module stand-in ${shim.marker} survived restoration`);
|
|
16850
|
+
}
|
|
16851
|
+
}
|
|
16852
|
+
function isModuleNameAt(fd, offset, marker) {
|
|
16853
|
+
const after = readAt(fd, 1, offset + Buffer.byteLength(marker));
|
|
16854
|
+
return after !== null && after[0] === 0;
|
|
16840
16855
|
}
|
|
16841
16856
|
function writeNameBytes(fd, name, offset) {
|
|
16842
16857
|
const bytes = Buffer.from(name);
|
|
@@ -16861,6 +16876,9 @@ function shimEntryModuleName(path) {
|
|
|
16861
16876
|
const offset = parsed.offsets[parsed.entryPointId];
|
|
16862
16877
|
const marker = entryModuleShimName(Buffer.byteLength(original));
|
|
16863
16878
|
if (marker === null) return null;
|
|
16879
|
+
if (findStandIn(fd, statSync4(path).size, marker).some((offset2) => isModuleNameAt(fd, offset2, marker))) {
|
|
16880
|
+
return null;
|
|
16881
|
+
}
|
|
16864
16882
|
writeNameBytes(fd, marker, offset);
|
|
16865
16883
|
return { offset, original, marker };
|
|
16866
16884
|
} finally {
|
|
@@ -16879,7 +16897,7 @@ function restoreEntryModuleName(path, shim, { resign }) {
|
|
|
16879
16897
|
);
|
|
16880
16898
|
}
|
|
16881
16899
|
writeNameBytes(fd, shim.original, offset);
|
|
16882
|
-
|
|
16900
|
+
restoreEveryStandIn(fd, statSync4(path).size, shim);
|
|
16883
16901
|
machO = resign && isMachO(fd);
|
|
16884
16902
|
} finally {
|
|
16885
16903
|
closeSync4(fd);
|