2021-10-14 12:51:05 +02:00
|
|
|
import vm from "vm"
|
|
|
|
import templates from "./index.js"
|
|
|
|
import { setJSRunner } from "./helpers/javascript"
|
2021-01-30 03:54:52 +01:00
|
|
|
|
|
|
|
/**
|
2021-10-14 12:51:05 +02:00
|
|
|
* ES6 entrypoint for rollup
|
2021-01-30 03:54:52 +01:00
|
|
|
*/
|
|
|
|
export const isValid = templates.isValid
|
|
|
|
export const makePropSafe = templates.makePropSafe
|
|
|
|
export const getManifest = templates.getManifest
|
2021-10-11 15:53:55 +02:00
|
|
|
export const isJSBinding = templates.isJSBinding
|
|
|
|
export const encodeJSBinding = templates.encodeJSBinding
|
|
|
|
export const decodeJSBinding = templates.decodeJSBinding
|
2021-01-30 03:54:52 +01:00
|
|
|
export const processStringSync = templates.processStringSync
|
|
|
|
export const processObjectSync = templates.processObjectSync
|
|
|
|
export const processString = templates.processString
|
|
|
|
export const processObject = templates.processObject
|
2022-01-24 19:22:59 +01:00
|
|
|
export const doesContainStrings = templates.doesContainStrings
|
2022-01-21 17:24:24 +01:00
|
|
|
export const doesContainString = templates.doesContainString
|
2021-10-14 12:51:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Use polyfilled vm to run JS scripts in a browser Env
|
|
|
|
*/
|
|
|
|
setJSRunner((js, context) => {
|
2021-10-14 13:02:34 +02:00
|
|
|
context = {
|
|
|
|
...context,
|
|
|
|
alert: undefined,
|
|
|
|
setInterval: undefined,
|
|
|
|
setTimeout: undefined,
|
|
|
|
}
|
2021-10-14 12:51:05 +02:00
|
|
|
vm.createContext(context)
|
|
|
|
return vm.runInNewContext(js, context, { timeout: 1000 })
|
|
|
|
})
|