From 57926ba788ff04c8bd300e4ef4c203dabec607ce Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Sat, 1 Feb 2020 02:40:39 +0800 Subject: [PATCH] feat: move ployfill to @ms/ployfill Signed-off-by: MiaoWoo --- src/main/resources/core/ployfill.js | 47 +++++++++++++++-------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/main/resources/core/ployfill.js b/src/main/resources/core/ployfill.js index 2ae3719..b51f017 100644 --- a/src/main/resources/core/ployfill.js +++ b/src/main/resources/core/ployfill.js @@ -1,22 +1,25 @@ -(function(root, logger) { - // Init Global Value - global.root = root; - global.logger = logger; - // Init Global Function - global.noop = global.engineDisable = function() { }; - global.engineLoad = load; - global.load = load = function __PreventGlobalLoadFunction__() { - throw new Error('Internal engine system not allow use `load` function!'); - }; - // Init console and require - global.XMLHttpRequest = undefined; - global.console = engineLoad(global.root + '/core/console.js')(logger); - global.require = engineLoad(global.root + '/core/require.js')(root); - // String contains ployfill - String.prototype.contains = function(searchString, position) { - return String.prototype.indexOf.call(this, searchString, position) > -1; - }; - // ES6 Map Symbol ployfill - require('es6-map/implement'); - require('es6-symbol/implement'); -}); +( + /** + * @param {string} root + * @param {any} logger + */ + function(root, logger) { + // Init Global Value + global.root = root; + global.logger = logger; + // Init Global Function + global.noop = global.engineDisable = function() { }; + global.engineLoad = load; + global.load = load = function __PreventGlobalLoadFunction__() { + throw new Error('Internal engine system not allow use `load` function!'); + } + global.NashornEngineStartTime = new Date().getTime() + // Init console and require + global.setGlobal = function(key, value) { + global[key] = value; + } + global.console = engineLoad(global.root + '/core/console.js')(logger); + global.require = engineLoad(global.root + '/core/require.js')(root); + require('@ms/ployfill') + } +);