sandboxedjs 0.1.77 → 0.1.78

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.js CHANGED
@@ -19051,6 +19051,49 @@ var NOTHING = [];
19051
19051
  var PROPERTY = ["property", "key"];
19052
19052
  var LABEL = ["label"];
19053
19053
 
19054
+ // src/node/env.ts
19055
+ function parseEnv(text2) {
19056
+ if (typeof text2 !== "string") {
19057
+ throw Object.assign(new TypeError('The "content" argument must be of type string'), { code: "ERR_INVALID_ARG_TYPE" });
19058
+ }
19059
+ const out = {};
19060
+ const lines = text2.split(/\r?\n/);
19061
+ for (let index = 0; index < lines.length; index++) {
19062
+ const raw = lines[index];
19063
+ const match2 = /^[ \t]*(?:export[ \t]+)?([^=#]+?)[ \t]*=[ \t]*(.*)$/.exec(raw);
19064
+ if (!match2) continue;
19065
+ const name = match2[1];
19066
+ let value = match2[2];
19067
+ const quote3 = value[0];
19068
+ if (quote3 === '"' || quote3 === "'" || quote3 === "`") {
19069
+ const start2 = index;
19070
+ const original = value;
19071
+ value = value.slice(1);
19072
+ while (true) {
19073
+ const end = value.indexOf(quote3);
19074
+ if (end >= 0) {
19075
+ value = value.slice(0, end);
19076
+ break;
19077
+ }
19078
+ if (++index >= lines.length) {
19079
+ index = start2;
19080
+ value = original;
19081
+ break;
19082
+ }
19083
+ value += `
19084
+ ${lines[index]}`;
19085
+ }
19086
+ if (quote3 === '"') value = value.replace(/\\n/g, "\n");
19087
+ } else {
19088
+ const comment = value.indexOf("#");
19089
+ if (comment >= 0) value = value.slice(0, comment);
19090
+ value = value.trim();
19091
+ }
19092
+ Object.defineProperty(out, name, { value, writable: true, enumerable: true, configurable: true });
19093
+ }
19094
+ return out;
19095
+ }
19096
+
19054
19097
  // src/node/node.ts
19055
19098
  var NODE_VERSION = "v22.12.0";
19056
19099
  new TextEncoder();
@@ -19317,7 +19360,7 @@ The filesystem a script sees is the container's filesystem.`,
19317
19360
  `);
19318
19361
  return 9;
19319
19362
  }
19320
- Object.assign(loaded, parseEnvFile(text2));
19363
+ Object.assign(loaded, parseEnv(text2));
19321
19364
  }
19322
19365
  env2 = { ...loaded, ...ctx.env };
19323
19366
  }
@@ -19554,27 +19597,6 @@ var VALUE_FLAGS = /* @__PURE__ */ new Set([
19554
19597
  "--report-dir",
19555
19598
  "--report-filename"
19556
19599
  ]);
19557
- function parseEnvFile(text2) {
19558
- const out = {};
19559
- for (const raw of text2.split(/\r?\n/)) {
19560
- const line = raw.trim();
19561
- if (!line || line.startsWith("#")) continue;
19562
- const match2 = /^(?:export\s+)?([A-Za-z_][A-Za-z0-9_.-]*)\s*=\s*(.*)$/.exec(line);
19563
- if (!match2) continue;
19564
- let value = match2[2];
19565
- const quote3 = value[0];
19566
- if ((quote3 === '"' || quote3 === "'" || quote3 === "`") && value.length >= 2 && value.endsWith(quote3)) {
19567
- value = value.slice(1, -1);
19568
- if (quote3 === '"') value = value.replace(/\\n/g, "\n");
19569
- } else {
19570
- const comment = value.indexOf(" #");
19571
- if (comment >= 0) value = value.slice(0, comment);
19572
- value = value.trim();
19573
- }
19574
- out[match2[1]] = value;
19575
- }
19576
- return out;
19577
- }
19578
19600
  var AsyncFunction = Object.getPrototypeOf(async function() {
19579
19601
  }).constructor;
19580
19602
  function checkSyntax(ctx, script) {
@@ -20198,7 +20220,7 @@ var wheels_default = {
20198
20220
 
20199
20221
  // package.json
20200
20222
  var package_default = {
20201
- version: "0.1.77"};
20223
+ version: "0.1.78"};
20202
20224
 
20203
20225
  // src/python/config.ts
20204
20226
  function runtimeModuleUrl() {
@@ -26314,6 +26336,9 @@ function render(value, depth, seen, options) {
26314
26336
  if (value instanceof Date) return Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString();
26315
26337
  if (value instanceof RegExp) return String(value);
26316
26338
  if (Buffer2.isBuffer(value)) return renderBuffer(value);
26339
+ if (value instanceof DataView) {
26340
+ return `DataView { byteLength: ${value.byteLength}, byteOffset: ${value.byteOffset} }`;
26341
+ }
26317
26342
  if (ArrayBuffer.isView(value)) return renderTypedArray(value);
26318
26343
  seen.add(object);
26319
26344
  try {
@@ -26375,7 +26400,13 @@ function renderBuffer(value) {
26375
26400
  }
26376
26401
  function renderTypedArray(value) {
26377
26402
  const name = value.constructor?.name ?? "TypedArray";
26378
- const items = [...value].slice(0, MAX_ARRAY);
26403
+ const items = [];
26404
+ const indexed = value;
26405
+ for (let i = 0; i < Math.min(value.length, MAX_ARRAY); i++) {
26406
+ const item = indexed[i];
26407
+ items.push(typeof item === "bigint" ? `${item}n` : String(item));
26408
+ }
26409
+ if (value.length > MAX_ARRAY) items.push(`... ${value.length - MAX_ARRAY} more items`);
26379
26410
  return `${name}(${value.length}) [ ${items.join(", ")} ]`;
26380
26411
  }
26381
26412
  function prefixed(name, size, parts) {
@@ -26631,6 +26662,7 @@ var legacy = {
26631
26662
  };
26632
26663
  inspect.custom = customInspect;
26633
26664
  var utilModule = {
26665
+ parseEnv,
26634
26666
  format,
26635
26667
  formatWithOptions,
26636
26668
  inspect,
@@ -29235,6 +29267,14 @@ function createCoreModules(options) {
29235
29267
  processObject.stdin = stdin;
29236
29268
  Reflect.deleteProperty(processObject, "browser");
29237
29269
  const fs = createFsModule(volume, () => cwd, options.stdinPath, defer);
29270
+ processObject.loadEnvFile = (path2 = ".env") => {
29271
+ const parsed = parseEnv(fs.readFileSync(path2, "utf8"));
29272
+ for (const [key, value] of Object.entries(parsed)) {
29273
+ if (!Object.prototype.hasOwnProperty.call(processObject.env, key)) {
29274
+ Object.defineProperty(processObject.env, key, { value, writable: true, enumerable: true, configurable: true });
29275
+ }
29276
+ }
29277
+ };
29238
29278
  const path = createPathModule(() => cwd);
29239
29279
  const consoleObject = new Console(stdoutWrite, stderrWrite);
29240
29280
  const os = createOsModule();