sandboxedjs 0.1.77 → 0.1.80

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,
@@ -30258,6 +30311,10 @@ function createCoreModules(options) {
30258
30311
  arch: "x64",
30259
30312
  version: "v22.12.0",
30260
30313
  versions: { ...import_browser.default.versions, node: "22.12.0" },
30314
+ binding: (name) => {
30315
+ if (name === "constants") return { fs: { ...fs.constants } };
30316
+ throw new Error(`No such module: ${name}`);
30317
+ },
30261
30318
  pid: 100,
30262
30319
  ppid: 1,
30263
30320
  title: "node",
@@ -30357,6 +30414,14 @@ function createCoreModules(options) {
30357
30414
  processObject.stdin = stdin;
30358
30415
  Reflect.deleteProperty(processObject, "browser");
30359
30416
  const fs = createFsModule(volume, () => cwd, options.stdinPath, defer);
30417
+ processObject.loadEnvFile = (path2 = ".env") => {
30418
+ const parsed = parseEnv(fs.readFileSync(path2, "utf8"));
30419
+ for (const [key, value] of Object.entries(parsed)) {
30420
+ if (!Object.prototype.hasOwnProperty.call(processObject.env, key)) {
30421
+ Object.defineProperty(processObject.env, key, { value, writable: true, enumerable: true, configurable: true });
30422
+ }
30423
+ }
30424
+ };
30360
30425
  const path = createPathModule(() => cwd);
30361
30426
  const consoleObject = new Console(stdoutWrite, stderrWrite);
30362
30427
  const os = createOsModule();
@@ -30556,7 +30621,7 @@ function createFsModule(volume, cwd, stdinPath, defer = queueMicrotask) {
30556
30621
  if (stdinPath) fds.set(0, { path: stdinPath, position: 0, flags: "r" });
30557
30622
  const abs = (value) => {
30558
30623
  if (typeof value === "number") return requiredFd(fds, value).path;
30559
- if (value instanceof URL) value = value.pathname;
30624
+ if (value instanceof URL) value = decodeURIComponent(value.pathname);
30560
30625
  if (Buffer2.isBuffer(value) || value instanceof Uint8Array) value = new TextDecoder().decode(value);
30561
30626
  if (typeof value !== "string") throw new TypeError("path must be a string, Buffer, or URL");
30562
30627
  return value.startsWith("/") ? clean(value) : resolve(cwd(), value);
@@ -30614,6 +30679,9 @@ function createFsModule(volume, cwd, stdinPath, defer = queueMicrotask) {
30614
30679
  O_EXCL: 128,
30615
30680
  O_TRUNC: 512,
30616
30681
  O_APPEND: 1024,
30682
+ O_NOCTTY: 256,
30683
+ O_SYNC: 1052672,
30684
+ O_NOFOLLOW: 131072,
30617
30685
  COPYFILE_EXCL: 1
30618
30686
  },
30619
30687
  Dirent,