Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ Since parsing and executing are separated, execution with SandboxJS can be somet
npm install @nyariv/sandboxjs
```

UMD build:

```javascript
<script src="https://unpkg.com/@nyariv/sandboxjs@latest/dist/Sandbox.umd.min.js"></script>
<script type="application/javascript">
/* for the following examples, Sandbox === window.SandboxJS */
const Sandbox = window.SandboxJS;
console.log(window.SandboxJS);
</script>
```

## Usage

The following is the bare minimum of code for using SandboxJS. This assumes safe whilelisted defaults.
Expand Down Expand Up @@ -65,7 +76,7 @@ console.log(scopeB); // {b: 2}
console.log(scopeC); // {c: 3, d: 5, b: 6}
```

You can set your own whilelisted prototypes and global properties like so (`alert` and `Node` are added to whitelist in the following code):
You can set your own whitelisted prototypes and global properties like so (`alert` and `Node` are added to whitelist in the following code):

```javascript
const prototypeWhitelist = Sandbox.SAFE_PROTOTYPES;
Expand Down
21 changes: 21 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,25 @@ export default [
filesize()
]
},
{
input: 'src/Sandbox.ts',
output: {
file: 'dist/Sandbox.umd.min.js',
format: 'umd',
name: 'SandboxJS',
sourcemap: true,
},
plugins: [
typescript({
declaration: true,
declarationDir: './',
}),
resolve({ extensions }),
terser({
keep_fnames: /SandboxFunction/,
maxWorkers: 4,
}),
filesize(),
],
},
]