sandboxedjs 0.1.15 → 0.1.16
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 +25 -13
- package/dist/index.cjs +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/dist/integrations/server.cjs +24 -0
- package/dist/integrations/server.cjs.map +1 -0
- package/dist/integrations/server.d.cts +2 -0
- package/dist/integrations/server.d.ts +2 -0
- package/dist/integrations/server.js +3 -0
- package/dist/integrations/server.js.map +1 -0
- package/dist/integrations/vite.cjs +22 -0
- package/dist/integrations/vite.cjs.map +1 -0
- package/dist/integrations/vite.d.cts +1 -0
- package/dist/integrations/vite.d.ts +1 -0
- package/dist/integrations/vite.js +3 -0
- package/dist/integrations/vite.js.map +1 -0
- package/package.json +12 -2
package/dist/index.d.cts
CHANGED
|
@@ -1494,6 +1494,17 @@ interface ContainerOptions {
|
|
|
1494
1494
|
pod?: Nodepod;
|
|
1495
1495
|
/** Python runtime settings; a browser host uses this to locate the wasm. */
|
|
1496
1496
|
python?: PythonOptions;
|
|
1497
|
+
/**
|
|
1498
|
+
* Forwarded to Nodepod when this package boots it in a browser. `swUrl`
|
|
1499
|
+
* points at the service worker if you serve it somewhere other than
|
|
1500
|
+
* `/__sw__.js`; `serviceWorker: false` skips registration entirely, which
|
|
1501
|
+
* also disables preview iframes.
|
|
1502
|
+
*/
|
|
1503
|
+
browser?: {
|
|
1504
|
+
swUrl?: string;
|
|
1505
|
+
serviceWorker?: boolean;
|
|
1506
|
+
watermark?: boolean;
|
|
1507
|
+
};
|
|
1497
1508
|
}
|
|
1498
1509
|
interface ExecOptions {
|
|
1499
1510
|
cwd?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1494,6 +1494,17 @@ interface ContainerOptions {
|
|
|
1494
1494
|
pod?: Nodepod;
|
|
1495
1495
|
/** Python runtime settings; a browser host uses this to locate the wasm. */
|
|
1496
1496
|
python?: PythonOptions;
|
|
1497
|
+
/**
|
|
1498
|
+
* Forwarded to Nodepod when this package boots it in a browser. `swUrl`
|
|
1499
|
+
* points at the service worker if you serve it somewhere other than
|
|
1500
|
+
* `/__sw__.js`; `serviceWorker: false` skips registration entirely, which
|
|
1501
|
+
* also disables preview iframes.
|
|
1502
|
+
*/
|
|
1503
|
+
browser?: {
|
|
1504
|
+
swUrl?: string;
|
|
1505
|
+
serviceWorker?: boolean;
|
|
1506
|
+
watermark?: boolean;
|
|
1507
|
+
};
|
|
1497
1508
|
}
|
|
1498
1509
|
interface ExecOptions {
|
|
1499
1510
|
cwd?: string;
|
package/dist/index.js
CHANGED
|
@@ -23888,8 +23888,8 @@ var Container = class _Container {
|
|
|
23888
23888
|
// ── boot ──────────────────────────────────────────────────────────────────
|
|
23889
23889
|
static async create(opts = {}) {
|
|
23890
23890
|
if (opts.python) configurePython(opts.python);
|
|
23891
|
-
if (!opts.pod) await installEsbuildRuntime();
|
|
23892
|
-
const pod = opts.pod ?? await bootHeadlessPod(opts);
|
|
23891
|
+
if (!opts.pod && isNodeRuntime()) await installEsbuildRuntime();
|
|
23892
|
+
const pod = opts.pod ?? (isNodeRuntime() ? await bootHeadlessPod(opts) : await bootBrowserPod(opts));
|
|
23893
23893
|
const kernel = new Kernel({
|
|
23894
23894
|
pod,
|
|
23895
23895
|
hostname: opts.hostname ?? "sandbox",
|
|
@@ -24311,6 +24311,18 @@ function normalizeHeaders(headers) {
|
|
|
24311
24311
|
async function createContainer(opts = {}) {
|
|
24312
24312
|
return Container.create(opts);
|
|
24313
24313
|
}
|
|
24314
|
+
function isNodeRuntime() {
|
|
24315
|
+
return typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
24316
|
+
}
|
|
24317
|
+
async function bootBrowserPod(opts) {
|
|
24318
|
+
const { Nodepod } = await import('@scelar/nodepod');
|
|
24319
|
+
return Nodepod.boot({
|
|
24320
|
+
env: opts.env ?? {},
|
|
24321
|
+
workdir: opts.cwd ?? "/",
|
|
24322
|
+
...opts.browser ?? {},
|
|
24323
|
+
...opts.onServerReady ? { onServerReady: opts.onServerReady } : {}
|
|
24324
|
+
});
|
|
24325
|
+
}
|
|
24314
24326
|
async function bootHeadlessPod(opts) {
|
|
24315
24327
|
const { Nodepod } = await nodeOnlyModule(
|
|
24316
24328
|
"@scelar/nodepod/headless"
|