2021-10-14 23:51:05 +13:00
|
|
|
import vm from "vm"
|
|
|
|
import templates from "./index.js"
|
|
|
|
import { setJSRunner } from "./helpers/javascript"
|
2021-01-30 15:54:52 +13:00
|
|
|
|
|
|
|
/**
|
2021-10-14 23:51:05 +13:00
|
|
|
* ES6 entrypoint for rollup
|
2021-01-30 15:54:52 +13:00
|
|
|
*/
|
|
|
|
export const isValid = templates.isValid
|
|
|
|
export const makePropSafe = templates.makePropSafe
|
|
|
|
export const getManifest = templates.getManifest
|
2021-10-12 02:53:55 +13:00
|
|
|
export const isJSBinding = templates.isJSBinding
|
|
|
|
export const encodeJSBinding = templates.encodeJSBinding
|
|
|
|
export const decodeJSBinding = templates.decodeJSBinding
|
2021-01-30 15:54:52 +13:00
|
|
|
export const processStringSync = templates.processStringSync
|
|
|
|
export const processObjectSync = templates.processObjectSync
|
|
|
|
export const processString = templates.processString
|
|
|
|
export const processObject = templates.processObject
|
2022-01-25 07:22:59 +13:00
|
|
|
export const doesContainStrings = templates.doesContainStrings
|
2022-01-22 05:24:24 +13:00
|
|
|
export const doesContainString = templates.doesContainString
|
2022-02-04 07:26:26 +13:00
|
|
|
export const disableEscaping = templates.disableEscaping
|
2022-03-03 06:40:50 +13:00
|
|
|
export const findHBSBlocks = templates.findHBSBlocks
|
2022-07-29 07:20:53 +12:00
|
|
|
export const convertToJS = templates.convertToJS
|
2021-10-14 23:51:05 +13:00
|
|
|
|
2022-09-06 06:04:45 +12:00
|
|
|
if (process && !process.env.NO_JS) {
|
|
|
|
/**
|
|
|
|
* Use polyfilled vm to run JS scripts in a browser Env
|
|
|
|
*/
|
|
|
|
setJSRunner((js, context) => {
|
|
|
|
context = {
|
|
|
|
...context,
|
|
|
|
alert: undefined,
|
|
|
|
setInterval: undefined,
|
|
|
|
setTimeout: undefined,
|
|
|
|
}
|
|
|
|
vm.createContext(context)
|
|
|
|
return vm.runInNewContext(js, context, { timeout: 1000 })
|
|
|
|
})
|
|
|
|
}
|