@aptoma/folio-tools 1.1.0 → 2.0.0
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 +2 -2
- package/test-vm.js +22 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aptoma/folio-tools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Build tooling and dev server for Aptoma DrEdition print folio renderers",
|
|
5
5
|
"license": "Unlicensed",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"joi": "^17.6.0",
|
|
39
39
|
"node-fetch": "^2.6.7",
|
|
40
40
|
"nodemon": "^2.0.15",
|
|
41
|
-
"
|
|
41
|
+
"isolated-vm": "^6.0.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^25.3.0",
|
package/test-vm.js
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
sandbox: {self: null}
|
|
7
|
-
});
|
|
4
|
+
const ivm = require('isolated-vm');
|
|
5
|
+
const isolate = new ivm.Isolate({memoryLimit: 128});
|
|
8
6
|
const file = require('fs').readFileSync('./files/index.js').toString();
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
|
|
8
|
+
(async () => {
|
|
9
|
+
const context = await isolate.createContext();
|
|
10
|
+
try {
|
|
11
|
+
await context.global.set('self', null);
|
|
12
|
+
const script = await isolate.compileScript(wrapCJS(file));
|
|
13
|
+
await script.run(context);
|
|
14
|
+
} finally {
|
|
15
|
+
context.release();
|
|
16
|
+
}
|
|
17
|
+
})().catch(console.error);
|
|
18
|
+
|
|
19
|
+
function wrapCJS(code) {
|
|
20
|
+
return `(function() {
|
|
21
|
+
var module = { exports: {} };
|
|
22
|
+
var exports = module.exports;
|
|
23
|
+
${code}
|
|
24
|
+
globalThis.__moduleExports = module.exports;
|
|
25
|
+
})();`;
|
|
26
|
+
}
|