{"version":3,"sources":["jsdelivr-header.js","/npm/fis3-deploy-gfe-script-place@1.0.5/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,aAUA,OAAO,QAAU,SAAS,EAAS,EAAU,EAAO,GAEhD,IAAI,EAAyB,EAAQ,yBAA0B,EAE3D,EAAkB,mKAEtB,EAAS,SAAQ,SAAS,GACtB,GAAI,EAAK,UAA0C,iBAAvB,EAAK,aAA4B,CACzD,IAAI,EAAU,EAAK,aAGf,IAAgB,EAAQ,QAAQ,WAAa,EAAQ,QAAQ,aAAe,EAAQ,QAAQ,WAAa,EAAQ,QAAQ,aAAe,EAAQ,QAAQ,WAAa,EAAQ,QAAQ,UAGzL,GAAI,mBAAmB,KAAK,EAAK,OAAS,EAAa,CAEnD,IAGI,EAAiB,GAGrB,EAAU,EAAQ,QAAQ,GAAiB,SAAS,GAEhD,OADA,EAAe,KAAK,GACb,EAEX,IAII,EADA,EACU,EAAQ,QAAQ,0BAA2B,EAAe,KAAK,QAAU,UAEzE,EAAQ,QAAQ,wBAAyB,EAAe,KAAK,QAAU,UAGrF,EAAK,WAAW,EACpB,CAEJ,CACJ,IAEA,GACJ","file":"/npm/fis3-deploy-gfe-script-place@1.0.5/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/fis3-deploy-gfe-script-place@1.0.5/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\r\n\r\n/**\r\n * 控制所有script标签的存放位置\r\n * @param  {Object}   options  插件配置\r\n * @param  {Object}   modified 修改了的文件列表（对应watch功能）\r\n * @param  {Object}   total    所有文件列表\r\n * @param  {Function} next     调用下一个插件\r\n * @return {undefined}\r\n */\r\nmodule.exports = function(options, modified, total, next) {\r\n    //js位置，默认插入到body结束标签之前\r\n    var insertBodyEndTagBefore = options.insertBodyEndTagBefore || true;\r\n    //script标签的正则表达式\r\n    var scriptTagRegExp = /(<script[^>]*>((?!<\\s*\\/script\\s*>)[\\s\\S])*<\\s*\\/script\\s*>)|(<\\!--\\[if\\s)(((?!<\\!\\[endif\\]-->)[\\s\\S])*)<script(((?!<\\!\\[endif\\]-->)[\\s\\S])*)(<\\!\\[endif\\]-->)/gi;\r\n\r\n    modified.forEach(function(file) {\r\n        if (file.isText() || typeof(file.getContent()) === 'string') {\r\n            var content = file.getContent();\r\n\r\n            //包含html基本结构的入口文件\r\n            var isEntryFile = (~content.indexOf('/html') || ~content.indexOf('/HTML')) && (~content.indexOf('/head') || ~content.indexOf('/HEAD')) && (~content.indexOf('/body') || ~content.indexOf('/BODY'));\r\n\r\n            //html入口文件\r\n            if (/\\.(html|ftl|tpl)/.test(file.rExt) && isEntryFile) {\r\n                //inbottom script标签数组\r\n                var inbottomScriptTagArray = [];\r\n\r\n                //script标签数组\r\n                var scriptTagArray = [];\r\n\r\n                //将script标签缓存到数组中，并将其替换为空串\r\n                content = content.replace(scriptTagRegExp, function(scriptTag) {\r\n                    scriptTagArray.push(scriptTag);\r\n                    return '';\r\n\r\n                });\r\n\r\n                //script标签位置替换\r\n                if (insertBodyEndTagBefore) {\r\n                    content = content.replace(/(<\\/body>\\s*<\\/html>)/gi, scriptTagArray.join('\\r\\n') + '\\r\\n$1');\r\n                } else {\r\n                    content = content.replace(/(<\\/head>\\s*<body>)/gi, scriptTagArray.join('\\r\\n') + '\\r\\n$1');\r\n                }\r\n\r\n                file.setContent(content);\r\n            }\r\n\r\n        }\r\n    });\r\n\r\n    next();\r\n};\r\n"]}