sandboxedjs 0.1.76 → 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.
@@ -22211,6 +22211,49 @@ function installReadableFrom(streamModule5) {
22211
22211
  streamModule5.Readable.from = createReadableFrom(streamModule5.Readable);
22212
22212
  }
22213
22213
 
22214
+ // src/node/env.ts
22215
+ function parseEnv(text) {
22216
+ if (typeof text !== "string") {
22217
+ throw Object.assign(new TypeError('The "content" argument must be of type string'), { code: "ERR_INVALID_ARG_TYPE" });
22218
+ }
22219
+ const out = {};
22220
+ const lines = text.split(/\r?\n/);
22221
+ for (let index = 0; index < lines.length; index++) {
22222
+ const raw = lines[index];
22223
+ const match2 = /^[ \t]*(?:export[ \t]+)?([^=#]+?)[ \t]*=[ \t]*(.*)$/.exec(raw);
22224
+ if (!match2) continue;
22225
+ const name = match2[1];
22226
+ let value = match2[2];
22227
+ const quote2 = value[0];
22228
+ if (quote2 === '"' || quote2 === "'" || quote2 === "`") {
22229
+ const start = index;
22230
+ const original = value;
22231
+ value = value.slice(1);
22232
+ while (true) {
22233
+ const end = value.indexOf(quote2);
22234
+ if (end >= 0) {
22235
+ value = value.slice(0, end);
22236
+ break;
22237
+ }
22238
+ if (++index >= lines.length) {
22239
+ index = start;
22240
+ value = original;
22241
+ break;
22242
+ }
22243
+ value += `
22244
+ ${lines[index]}`;
22245
+ }
22246
+ if (quote2 === '"') value = value.replace(/\\n/g, "\n");
22247
+ } else {
22248
+ const comment = value.indexOf("#");
22249
+ if (comment >= 0) value = value.slice(0, comment);
22250
+ value = value.trim();
22251
+ }
22252
+ Object.defineProperty(out, name, { value, writable: true, enumerable: true, configurable: true });
22253
+ }
22254
+ return out;
22255
+ }
22256
+
22214
22257
  // src/node/util-module.ts
22215
22258
  var customInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
22216
22259
  var promisifyCustom = /* @__PURE__ */ Symbol.for("nodejs.util.promisify.custom");
@@ -22248,6 +22291,9 @@ function render(value, depth, seen, options) {
22248
22291
  if (value instanceof Date) return Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString();
22249
22292
  if (value instanceof RegExp) return String(value);
22250
22293
  if (Buffer2.isBuffer(value)) return renderBuffer(value);
22294
+ if (value instanceof DataView) {
22295
+ return `DataView { byteLength: ${value.byteLength}, byteOffset: ${value.byteOffset} }`;
22296
+ }
22251
22297
  if (ArrayBuffer.isView(value)) return renderTypedArray(value);
22252
22298
  seen.add(object);
22253
22299
  try {
@@ -22309,7 +22355,13 @@ function renderBuffer(value) {
22309
22355
  }
22310
22356
  function renderTypedArray(value) {
22311
22357
  const name = value.constructor?.name ?? "TypedArray";
22312
- const items = [...value].slice(0, MAX_ARRAY);
22358
+ const items = [];
22359
+ const indexed = value;
22360
+ for (let i = 0; i < Math.min(value.length, MAX_ARRAY); i++) {
22361
+ const item = indexed[i];
22362
+ items.push(typeof item === "bigint" ? `${item}n` : String(item));
22363
+ }
22364
+ if (value.length > MAX_ARRAY) items.push(`... ${value.length - MAX_ARRAY} more items`);
22313
22365
  return `${name}(${value.length}) [ ${items.join(", ")} ]`;
22314
22366
  }
22315
22367
  function prefixed(name, size, parts) {
@@ -22565,6 +22617,7 @@ var legacy = {
22565
22617
  };
22566
22618
  inspect.custom = customInspect;
22567
22619
  var utilModule = {
22620
+ parseEnv,
22568
22621
  format,
22569
22622
  formatWithOptions,
22570
22623
  inspect,
@@ -30357,6 +30410,14 @@ function createCoreModules(options) {
30357
30410
  processObject.stdin = stdin;
30358
30411
  Reflect.deleteProperty(processObject, "browser");
30359
30412
  const fs = createFsModule(volume, () => cwd, options.stdinPath, defer);
30413
+ processObject.loadEnvFile = (path2 = ".env") => {
30414
+ const parsed = parseEnv(fs.readFileSync(path2, "utf8"));
30415
+ for (const [key, value] of Object.entries(parsed)) {
30416
+ if (!Object.prototype.hasOwnProperty.call(processObject.env, key)) {
30417
+ Object.defineProperty(processObject.env, key, { value, writable: true, enumerable: true, configurable: true });
30418
+ }
30419
+ }
30420
+ };
30360
30421
  const path = createPathModule(() => cwd);
30361
30422
  const consoleObject = new Console(stdoutWrite, stderrWrite);
30362
30423
  const os = createOsModule();