2021-10-14 12:51:05 +02:00
|
|
|
const { VM } = require("vm2")
|
|
|
|
const templates = require("./index.js")
|
|
|
|
const { setJSRunner } = require("./helpers/javascript")
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CJS entrypoint for rollup
|
|
|
|
*/
|
|
|
|
module.exports.isValid = templates.isValid
|
|
|
|
module.exports.makePropSafe = templates.makePropSafe
|
|
|
|
module.exports.getManifest = templates.getManifest
|
|
|
|
module.exports.isJSBinding = templates.isJSBinding
|
|
|
|
module.exports.encodeJSBinding = templates.encodeJSBinding
|
|
|
|
module.exports.decodeJSBinding = templates.decodeJSBinding
|
|
|
|
module.exports.processStringSync = templates.processStringSync
|
|
|
|
module.exports.processObjectSync = templates.processObjectSync
|
|
|
|
module.exports.processString = templates.processString
|
|
|
|
module.exports.processObject = templates.processObject
|
2022-01-24 19:22:59 +01:00
|
|
|
module.exports.doesContainStrings = templates.doesContainStrings
|
2022-01-21 17:24:24 +01:00
|
|
|
module.exports.doesContainString = templates.doesContainString
|
2022-02-03 19:26:26 +01:00
|
|
|
module.exports.disableEscaping = templates.disableEscaping
|
2022-03-02 18:40:50 +01:00
|
|
|
module.exports.findHBSBlocks = templates.findHBSBlocks
|
2021-10-14 12:51:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Use vm2 to run JS scripts in a node env
|
|
|
|
*/
|
|
|
|
setJSRunner((js, context) => {
|
|
|
|
const vm = new VM({
|
|
|
|
sandbox: context,
|
|
|
|
timeout: 1000
|
|
|
|
})
|
|
|
|
return vm.run(js)
|
2022-02-03 19:26:26 +01:00
|
|
|
})
|