sandboxedjs 0.1.55 → 0.1.56

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/README.md CHANGED
@@ -977,8 +977,11 @@ Honest list of what does not work:
977
977
  that `request()` talks to directly, so servers work; raw sockets do not.
978
978
  - **Python is source-built CPython/WASM.** Each program gets its own interpreter
979
979
  process worker. Pure-Python wheels install normally; native extensions must
980
- be linked or published for Emscripten. Pydantic 2's `pydantic-core` is not
981
- currently available, so use a Pydantic 1 constraint for FastAPI deployments.
980
+ be linked or published for Emscripten. The bundled wheel index includes the
981
+ ABI-matched `pydantic-core` builds required by Pydantic 2, so FastAPI resolves
982
+ against Pydantic 2 by default. Virtual environments and CPython's real pip
983
+ are not implemented; the sandbox `pip` installs into one shared site-packages
984
+ directory, so use a fresh container for dependency isolation.
982
985
  - **No real sockets.** HTTP servers work through the request proxy; raw TCP/UDP does not.
983
986
  - **No real processes.** Processes are cooperative async tasks: `kill -9` cannot interrupt a
984
987
  tight synchronous loop, and `SIGSTOP` only marks state.
package/dist/index.cjs CHANGED
@@ -17935,7 +17935,15 @@ var bundledManifest = {
17935
17935
  persistence: "memory"
17936
17936
  }
17937
17937
  };
17938
- var config = { backend: "sbx-cpython-wasm", manifest: bundledManifest };
17938
+ var bundledWheelIndex = new URL(
17939
+ (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)).includes("/src/runtime/python/") ? "../../../dist/python/wheels/" : "./python/wheels/",
17940
+ (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))
17941
+ ).href;
17942
+ var config = {
17943
+ backend: "sbx-cpython-wasm",
17944
+ manifest: bundledManifest,
17945
+ wheelIndex: bundledWheelIndex
17946
+ };
17939
17947
  function setPythonBackend(options) {
17940
17948
  if (options.wheelIndex !== void 0) config.wheelIndex = options.wheelIndex;
17941
17949
  if (options.manifest !== void 0) config.manifest = validateManifest(options.manifest);
@@ -20404,6 +20412,17 @@ environments. A package with no usable wheel is an error, never a silent skip.`,
20404
20412
  }
20405
20413
  const cache = /* @__PURE__ */ new Map();
20406
20414
  const request = async (url, timeoutMs, read) => {
20415
+ if (url.startsWith("file:")) {
20416
+ try {
20417
+ const [{ readFile }, { fileURLToPath: fileURLToPath2 }] = await Promise.all([
20418
+ nodeBuiltin("fs/promises"),
20419
+ nodeBuiltin("url")
20420
+ ]);
20421
+ return await read(new Response(await readFile(fileURLToPath2(url))));
20422
+ } catch (error) {
20423
+ throw new Error(`could not read bundled wheel asset ${url}: ${error.message}`);
20424
+ }
20425
+ }
20407
20426
  const controller = new AbortController();
20408
20427
  const timer = setTimeout(() => controller.abort(), timeoutMs);
20409
20428
  try {