@johnhenry/andbox 0.0.6 → 0.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnhenry/andbox",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "description": "Sandboxed JavaScript runtime with Worker isolation, RPC, import maps, and timeouts",
6
6
  "main": "./src/index.mjs",
@@ -167,10 +167,12 @@ self.onmessage = async ({ data: msg }) => {
167
167
  case 'evaluate': {
168
168
  const fwdConsole = makeForwardingConsole(msg.id);
169
169
  try {
170
- // Wrap in async function for top-level await
170
+ // Wrap in async function for top-level await. The newlines before and
171
+ // after the user code matter: without the trailing one, code ending in
172
+ // a // line comment swallows the closing brace (andbox#23).
171
173
  const asyncFn = new Function(
172
174
  'sandboxImport', 'host', 'console',
173
- \`return (async () => { \${msg.code} })();\`
175
+ \`return (async () => {\\n\${msg.code}\\n})();\`
174
176
  );
175
177
  const result = await asyncFn(sandboxImport, host, fwdConsole);
176
178
  self.postMessage({ type: 'result', id: msg.id, success: true, value: serialize(result) });