build: fix build without github

script: remove infinite loop protection
This commit is contained in:
jean-emmanuel 2025-12-27 11:36:15 +01:00
parent f2189e29ce
commit 967fb3d549
4 changed files with 2430 additions and 3906 deletions

View file

@ -1,5 +1,4 @@
var loopProtect = require('loop-protect'),
{deepCopy} = require('../utils'),
var {deepCopy} = require('../utils'),
globals
class Vm {
@ -45,13 +44,6 @@ class Vm {
this.sandbox.contentWindow.document.write('<meta http-equiv="Content-Security-Policy" content="default-src \'none\'; script-src \'unsafe-eval\';">')
this.sandbox.contentWindow.document.close()
// init infinite loop guard
loopProtect.alias = '__protect'
loopProtect.hit = function(line){
throw 'Potential infinite loop found on line ' + line + '(script interrupted).\nAdd "// noprotect" to your code to disable loop protection.'
}
this.sandbox.contentWindow.__protect = loopProtect
// global context
this.registerGlobals()
@ -139,12 +131,7 @@ class Vm {
}
}
var compiledCode = new this.safeFunctionProto(
...contextKeys, 'locals',
loopProtect('"use strict";' + contextInit + code)
.replace(/;\n(if \(__protect.*break;)\n/g, ';$1') // prevent loop protect from breaking stack linenumber
.replace(/(VAR_[0-9]+)/g, '__VARS.$1')
)
var compiledCode = new this.safeFunctionProto(...contextKeys, 'locals', code.replace(/(VAR_[0-9]+)/g, '__VARS.$1'))
return (context, locals)=>{