sandboxedjs 0.2.20 → 0.2.22
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.cjs +22 -6
- package/dist/index.js +22 -6
- package/dist/worker-entry.js +23971 -2501
- package/docs/to_implement/agent.md +261 -0
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -6,6 +6,7 @@ var pako = require('pako');
|
|
|
6
6
|
var sha256 = require('@noble/hashes/sha256');
|
|
7
7
|
var acorn = require('acorn');
|
|
8
8
|
var jsx = require('acorn-jsx');
|
|
9
|
+
var sucrase = require('sucrase');
|
|
9
10
|
var index_js = require('buffer/index.js');
|
|
10
11
|
var sha512 = require('@noble/hashes/sha512');
|
|
11
12
|
var sha1 = require('@noble/hashes/sha1');
|
|
@@ -19260,8 +19261,6 @@ ${lines[index]}`;
|
|
|
19260
19261
|
}
|
|
19261
19262
|
return out;
|
|
19262
19263
|
}
|
|
19263
|
-
|
|
19264
|
-
// src/node/node.ts
|
|
19265
19264
|
var NODE_VERSION = "v22.12.0";
|
|
19266
19265
|
new TextEncoder();
|
|
19267
19266
|
var tempCounter = 0;
|
|
@@ -19635,7 +19634,7 @@ ${prelude}${preloadRequires(preloads)}${source}
|
|
|
19635
19634
|
}
|
|
19636
19635
|
function resolveScript(ctx, operand) {
|
|
19637
19636
|
const base2 = ctx.path(operand);
|
|
19638
|
-
const candidates2 = [base2, `${base2}.js`, `${base2}.mjs`, `${base2}.cjs`, `${base2}.json`];
|
|
19637
|
+
const candidates2 = [base2, `${base2}.js`, `${base2}.mjs`, `${base2}.cjs`, `${base2}.ts`, `${base2}.tsx`, `${base2}.json`];
|
|
19639
19638
|
for (const candidate of candidates2) {
|
|
19640
19639
|
try {
|
|
19641
19640
|
const st = ctx.vfs.stat(candidate, { cred: ctx.cred });
|
|
@@ -19653,7 +19652,7 @@ function resolveScript(ctx, operand) {
|
|
|
19653
19652
|
} catch {
|
|
19654
19653
|
}
|
|
19655
19654
|
}
|
|
19656
|
-
for (const index of ["index.js", "index.mjs", "index.cjs"]) {
|
|
19655
|
+
for (const index of ["index.js", "index.mjs", "index.cjs", "index.ts", "index.tsx"]) {
|
|
19657
19656
|
const path = join(candidate, index);
|
|
19658
19657
|
if (ctx.vfs.lexists(path)) return ctx.vfs.realpath(path, ctx.cred);
|
|
19659
19658
|
}
|
|
@@ -19770,6 +19769,13 @@ function checkSyntax(ctx, script) {
|
|
|
19770
19769
|
let source = ctx.vfs.readText(script, ctx.cred);
|
|
19771
19770
|
if (source.startsWith("#!")) source = `//${source.slice(2)}`;
|
|
19772
19771
|
try {
|
|
19772
|
+
if (script.endsWith(".ts") || script.endsWith(".tsx")) {
|
|
19773
|
+
source = sucrase.transform(source, {
|
|
19774
|
+
transforms: script.endsWith(".tsx") ? ["typescript", "jsx"] : ["typescript"],
|
|
19775
|
+
filePath: script,
|
|
19776
|
+
production: true
|
|
19777
|
+
}).code;
|
|
19778
|
+
}
|
|
19773
19779
|
const esm = script.endsWith(".mjs") || !script.endsWith(".cjs") && looksLikeEsm(source);
|
|
19774
19780
|
const transformed = esm ? transformEsm(source, script) : null;
|
|
19775
19781
|
new AsyncFunction("exports", "require", "module", "__filename", "__dirname", transformed?.code ?? source);
|
|
@@ -21103,7 +21109,7 @@ var wheels_default = {
|
|
|
21103
21109
|
|
|
21104
21110
|
// package.json
|
|
21105
21111
|
var package_default = {
|
|
21106
|
-
version: "0.2.
|
|
21112
|
+
version: "0.2.22"};
|
|
21107
21113
|
|
|
21108
21114
|
// src/python/extension-abi.ts
|
|
21109
21115
|
var EXTENSION_ABI = {
|
|
@@ -30005,7 +30011,7 @@ function applyEdits2(source, edits) {
|
|
|
30005
30011
|
function isNode4(value) {
|
|
30006
30012
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
30007
30013
|
}
|
|
30008
|
-
var EXTENSIONS = [".js", ".mjs", ".cjs", ".json", ".node"];
|
|
30014
|
+
var EXTENSIONS = [".js", ".mjs", ".cjs", ".json", ".node", ".ts", ".tsx"];
|
|
30009
30015
|
var PREFIX_ONLY_BUILTINS = /* @__PURE__ */ new Set(["test", "test/reporters", "sea", "sqlite"]);
|
|
30010
30016
|
var CONDITION_SETS = {
|
|
30011
30017
|
import: [["node", "import", "module", "default"], ["node", "require", "default"], ["default"]],
|
|
@@ -30179,6 +30185,13 @@ var CommonJsEngine = class {
|
|
|
30179
30185
|
}
|
|
30180
30186
|
evaluate(module, source) {
|
|
30181
30187
|
if (source.startsWith("#!")) source = source.replace(/^#![^\n]*(?:\n|$)/, "");
|
|
30188
|
+
if (isTypeScript(module.filename)) {
|
|
30189
|
+
source = sucrase.transform(source, {
|
|
30190
|
+
transforms: module.filename.endsWith(".tsx") ? ["typescript", "jsx"] : ["typescript"],
|
|
30191
|
+
filePath: module.filename,
|
|
30192
|
+
production: true
|
|
30193
|
+
}).code;
|
|
30194
|
+
}
|
|
30182
30195
|
const transformed = transformEsm(source, module.filename);
|
|
30183
30196
|
const esmBody = transformed?.code ?? source;
|
|
30184
30197
|
const body = transformAsyncContext(esmBody, module.filename) ?? esmBody;
|
|
@@ -30441,6 +30454,9 @@ Require stack:
|
|
|
30441
30454
|
return error;
|
|
30442
30455
|
}
|
|
30443
30456
|
};
|
|
30457
|
+
function isTypeScript(filename) {
|
|
30458
|
+
return filename.endsWith(".ts") || filename.endsWith(".tsx");
|
|
30459
|
+
}
|
|
30444
30460
|
var namespaces = /* @__PURE__ */ new WeakMap();
|
|
30445
30461
|
function namespaceOf(exports) {
|
|
30446
30462
|
if (exports === null || typeof exports !== "object" && typeof exports !== "function") {
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Inflate as Inflate$1, Deflate as Deflate$1, inflateRaw, ungzip, gzip as
|
|
|
2
2
|
import { sha256, sha224 } from '@noble/hashes/sha256';
|
|
3
3
|
import { Parser as Parser$1, parse as parse$1 } from 'acorn';
|
|
4
4
|
import jsx from 'acorn-jsx';
|
|
5
|
+
import { transform } from 'sucrase';
|
|
5
6
|
import { Buffer as Buffer$1 } from 'buffer/index.js';
|
|
6
7
|
import { sha512, sha384 } from '@noble/hashes/sha512';
|
|
7
8
|
import { sha1 } from '@noble/hashes/sha1';
|
|
@@ -19243,8 +19244,6 @@ ${lines[index]}`;
|
|
|
19243
19244
|
}
|
|
19244
19245
|
return out;
|
|
19245
19246
|
}
|
|
19246
|
-
|
|
19247
|
-
// src/node/node.ts
|
|
19248
19247
|
var NODE_VERSION = "v22.12.0";
|
|
19249
19248
|
new TextEncoder();
|
|
19250
19249
|
var tempCounter = 0;
|
|
@@ -19618,7 +19617,7 @@ ${prelude}${preloadRequires(preloads)}${source}
|
|
|
19618
19617
|
}
|
|
19619
19618
|
function resolveScript(ctx, operand) {
|
|
19620
19619
|
const base2 = ctx.path(operand);
|
|
19621
|
-
const candidates2 = [base2, `${base2}.js`, `${base2}.mjs`, `${base2}.cjs`, `${base2}.json`];
|
|
19620
|
+
const candidates2 = [base2, `${base2}.js`, `${base2}.mjs`, `${base2}.cjs`, `${base2}.ts`, `${base2}.tsx`, `${base2}.json`];
|
|
19622
19621
|
for (const candidate of candidates2) {
|
|
19623
19622
|
try {
|
|
19624
19623
|
const st = ctx.vfs.stat(candidate, { cred: ctx.cred });
|
|
@@ -19636,7 +19635,7 @@ function resolveScript(ctx, operand) {
|
|
|
19636
19635
|
} catch {
|
|
19637
19636
|
}
|
|
19638
19637
|
}
|
|
19639
|
-
for (const index of ["index.js", "index.mjs", "index.cjs"]) {
|
|
19638
|
+
for (const index of ["index.js", "index.mjs", "index.cjs", "index.ts", "index.tsx"]) {
|
|
19640
19639
|
const path = join(candidate, index);
|
|
19641
19640
|
if (ctx.vfs.lexists(path)) return ctx.vfs.realpath(path, ctx.cred);
|
|
19642
19641
|
}
|
|
@@ -19753,6 +19752,13 @@ function checkSyntax(ctx, script) {
|
|
|
19753
19752
|
let source = ctx.vfs.readText(script, ctx.cred);
|
|
19754
19753
|
if (source.startsWith("#!")) source = `//${source.slice(2)}`;
|
|
19755
19754
|
try {
|
|
19755
|
+
if (script.endsWith(".ts") || script.endsWith(".tsx")) {
|
|
19756
|
+
source = transform(source, {
|
|
19757
|
+
transforms: script.endsWith(".tsx") ? ["typescript", "jsx"] : ["typescript"],
|
|
19758
|
+
filePath: script,
|
|
19759
|
+
production: true
|
|
19760
|
+
}).code;
|
|
19761
|
+
}
|
|
19756
19762
|
const esm = script.endsWith(".mjs") || !script.endsWith(".cjs") && looksLikeEsm(source);
|
|
19757
19763
|
const transformed = esm ? transformEsm(source, script) : null;
|
|
19758
19764
|
new AsyncFunction("exports", "require", "module", "__filename", "__dirname", transformed?.code ?? source);
|
|
@@ -21086,7 +21092,7 @@ var wheels_default = {
|
|
|
21086
21092
|
|
|
21087
21093
|
// package.json
|
|
21088
21094
|
var package_default = {
|
|
21089
|
-
version: "0.2.
|
|
21095
|
+
version: "0.2.22"};
|
|
21090
21096
|
|
|
21091
21097
|
// src/python/extension-abi.ts
|
|
21092
21098
|
var EXTENSION_ABI = {
|
|
@@ -29988,7 +29994,7 @@ function applyEdits2(source, edits) {
|
|
|
29988
29994
|
function isNode4(value) {
|
|
29989
29995
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
29990
29996
|
}
|
|
29991
|
-
var EXTENSIONS = [".js", ".mjs", ".cjs", ".json", ".node"];
|
|
29997
|
+
var EXTENSIONS = [".js", ".mjs", ".cjs", ".json", ".node", ".ts", ".tsx"];
|
|
29992
29998
|
var PREFIX_ONLY_BUILTINS = /* @__PURE__ */ new Set(["test", "test/reporters", "sea", "sqlite"]);
|
|
29993
29999
|
var CONDITION_SETS = {
|
|
29994
30000
|
import: [["node", "import", "module", "default"], ["node", "require", "default"], ["default"]],
|
|
@@ -30162,6 +30168,13 @@ var CommonJsEngine = class {
|
|
|
30162
30168
|
}
|
|
30163
30169
|
evaluate(module, source) {
|
|
30164
30170
|
if (source.startsWith("#!")) source = source.replace(/^#![^\n]*(?:\n|$)/, "");
|
|
30171
|
+
if (isTypeScript(module.filename)) {
|
|
30172
|
+
source = transform(source, {
|
|
30173
|
+
transforms: module.filename.endsWith(".tsx") ? ["typescript", "jsx"] : ["typescript"],
|
|
30174
|
+
filePath: module.filename,
|
|
30175
|
+
production: true
|
|
30176
|
+
}).code;
|
|
30177
|
+
}
|
|
30165
30178
|
const transformed = transformEsm(source, module.filename);
|
|
30166
30179
|
const esmBody = transformed?.code ?? source;
|
|
30167
30180
|
const body = transformAsyncContext(esmBody, module.filename) ?? esmBody;
|
|
@@ -30424,6 +30437,9 @@ Require stack:
|
|
|
30424
30437
|
return error;
|
|
30425
30438
|
}
|
|
30426
30439
|
};
|
|
30440
|
+
function isTypeScript(filename) {
|
|
30441
|
+
return filename.endsWith(".ts") || filename.endsWith(".tsx");
|
|
30442
|
+
}
|
|
30427
30443
|
var namespaces = /* @__PURE__ */ new WeakMap();
|
|
30428
30444
|
function namespaceOf(exports) {
|
|
30429
30445
|
if (exports === null || typeof exports !== "object" && typeof exports !== "function") {
|