@bman654/clodex 2.6.0 → 2.6.2
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 +33 -11
- 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.2",
|
|
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);
|
|
@@ -17043,7 +17061,7 @@ function collectPristineFacts(args) {
|
|
|
17043
17061
|
}
|
|
17044
17062
|
|
|
17045
17063
|
// src/patch-transforms.ts
|
|
17046
|
-
var PATCH_TRANSFORMS_VERSION =
|
|
17064
|
+
var PATCH_TRANSFORMS_VERSION = 7;
|
|
17047
17065
|
var NATIVE_EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
|
|
17048
17066
|
var BASE_EFFORT_LEVELS = ["low", "medium", "high"];
|
|
17049
17067
|
function projectNativeEffort(effort) {
|
|
@@ -17222,14 +17240,18 @@ function applyClodexPatches(source, config) {
|
|
|
17222
17240
|
// old adhoc-patch ASCII-only constraint no longer applies.)
|
|
17223
17241
|
(a) => "{value:" + q(a) + ",label:" + q(a.charAt(0).toUpperCase() + a.slice(1)) + ",description:" + q(displayFor(a, ALIAS_TO_ID[a])) + "}"
|
|
17224
17242
|
).join(",");
|
|
17225
|
-
const
|
|
17243
|
+
const injectInto = (options) => missing.length ? "[" + entries + "].forEach(function(_o){if(!" + options + ".some(function(_i){return _i.value===_o.value}))" + options + ".push(_o)});" : "";
|
|
17244
|
+
const pickerSite = "PATCH 5: model picker options";
|
|
17245
|
+
const modelSelections = [...js.matchAll(/\(([\w$]+)==="opus"\|\|\1==="sonnet"\)/g)];
|
|
17226
17246
|
if (ALIASES.length === 0) {
|
|
17227
|
-
log12("SKIP",
|
|
17247
|
+
log12("SKIP", pickerSite, "no aliases configured");
|
|
17248
|
+
} else if (modelSelections.length !== 1) {
|
|
17249
|
+
log12("FAIL", pickerSite, "model selection appears " + modelSelections.length + " times (expected 1)");
|
|
17228
17250
|
} else {
|
|
17229
17251
|
applyOnce(
|
|
17230
|
-
|
|
17231
|
-
|
|
17232
|
-
(m) => m +
|
|
17252
|
+
pickerSite,
|
|
17253
|
+
/\(([\w$]+)==="opus"\|\|\1==="sonnet"\)[^;{}]*\?\[\1,([\w$]+)\]:\[\2\];for\(let ([\w$]+) of [\w$]+\)[\w$]+\(([\w$]+),\3,[\w$]+\);/,
|
|
17254
|
+
(m, _selected, _requested, _item, options) => m + injectInto(options),
|
|
17233
17255
|
{ required: false, noopIsSkip: true }
|
|
17234
17256
|
);
|
|
17235
17257
|
}
|