UNPKG

unused-assets-webpack-plugin

Version:
2 lines (1 loc) 34.3 kB
"use strict";var t=require("util"),e=require("fs"),r=require("path"),n=require("events"),i=require("assert"),s=require("tty"),o=require("node:fs");function a(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var c,h,u,l,f,p,d,m,g,v,y,b={};function _(){if(c)return b;c=1;var t=r,n="win32"===process.platform,i=e,s=process.env.NODE_DEBUG&&/fs/.test(process.env.NODE_DEBUG);function o(t){return"function"==typeof t?t:function(){var t;if(s){var e=new Error;t=function(t){t&&(e.message=t.message,r(t=e))}}else t=r;return t;function r(t){if(t){if(process.throwDeprecation)throw t;if(!process.noDeprecation){var e="fs: missing callback "+(t.stack||t.message);process.traceDeprecation?console.trace(e):console.error(e)}}}}()}if(t.normalize,n)var a=/(.*?)(?:[\/\\]+|$)/g;else a=/(.*?)(?:[\/]+|$)/g;if(n)var h=/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;else h=/^[\/]*/;return b.realpathSync=function(e,r){if(e=t.resolve(e),r&&Object.prototype.hasOwnProperty.call(r,e))return r[e];var s,o,c,u,l=e,f={},p={};function d(){var t=h.exec(e);s=t[0].length,o=t[0],c=t[0],u="",n&&!p[c]&&(i.lstatSync(c),p[c]=!0)}for(d();s<e.length;){a.lastIndex=s;var m=a.exec(e);if(u=o,o+=m[0],c=u+m[1],s=a.lastIndex,!(p[c]||r&&r[c]===c)){var g;if(r&&Object.prototype.hasOwnProperty.call(r,c))g=r[c];else{var v=i.lstatSync(c);if(!v.isSymbolicLink()){p[c]=!0,r&&(r[c]=c);continue}var y=null;if(!n){var b=v.dev.toString(32)+":"+v.ino.toString(32);f.hasOwnProperty(b)&&(y=f[b])}null===y&&(i.statSync(c),y=i.readlinkSync(c)),g=t.resolve(u,y),r&&(r[c]=g),n||(f[b]=y)}e=t.resolve(g,e.slice(s)),d()}}return r&&(r[l]=e),e},b.realpath=function(e,r,s){if("function"!=typeof s&&(s=o(r),r=null),e=t.resolve(e),r&&Object.prototype.hasOwnProperty.call(r,e))return process.nextTick(s.bind(null,null,r[e]));var c,u,l,f,p=e,d={},m={};function g(){var t=h.exec(e);c=t[0].length,u=t[0],l=t[0],f="",n&&!m[l]?i.lstat(l,(function(t){if(t)return s(t);m[l]=!0,v()})):process.nextTick(v)}function v(){if(c>=e.length)return r&&(r[p]=e),s(null,e);a.lastIndex=c;var t=a.exec(e);return f=u,u+=t[0],l=f+t[1],c=a.lastIndex,m[l]||r&&r[l]===l?process.nextTick(v):r&&Object.prototype.hasOwnProperty.call(r,l)?_(r[l]):i.lstat(l,y)}function y(t,e){if(t)return s(t);if(!e.isSymbolicLink())return m[l]=!0,r&&(r[l]=l),process.nextTick(v);if(!n){var o=e.dev.toString(32)+":"+e.ino.toString(32);if(d.hasOwnProperty(o))return b(null,d[o],l)}i.stat(l,(function(t){if(t)return s(t);i.readlink(l,(function(t,e){n||(d[o]=e),b(t,e)}))}))}function b(e,n,i){if(e)return s(e);var o=t.resolve(f,n);r&&(r[i]=o),_(o)}function _(r){e=t.resolve(r,e.slice(c)),g()}g()},b}function w(){if(u)return h;u=1,h=c,c.realpath=c,c.sync=l,c.realpathSync=l,c.monkeypatch=function(){t.realpath=c,t.realpathSync=l},c.unmonkeypatch=function(){t.realpath=r,t.realpathSync=n};var t=e,r=t.realpath,n=t.realpathSync,i=process.version,s=/^v[0-5]\./.test(i),o=_();function a(t){return t&&"realpath"===t.syscall&&("ELOOP"===t.code||"ENOMEM"===t.code||"ENAMETOOLONG"===t.code)}function c(t,e,n){if(s)return r(t,e,n);"function"==typeof e&&(n=e,e=null),r(t,e,(function(r,i){a(r)?o.realpath(t,e,n):n(r,i)}))}function l(t,e){if(s)return n(t,e);try{return n(t,e)}catch(r){if(a(r))return o.realpathSync(t,e);throw r}}return h}function E(){if(f)return l;f=1,l=function(e,r){for(var n=[],i=0;i<e.length;i++){var s=r(e[i],i);t(s)?n.push.apply(n,s):n.push(s)}return n};var t=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};return l}function O(){if(g)return m;g=1;var t=E(),e=function(){if(d)return p;function t(t,n,i){t instanceof RegExp&&(t=e(t,i)),n instanceof RegExp&&(n=e(n,i));var s=r(t,n,i);return s&&{start:s[0],end:s[1],pre:i.slice(0,s[0]),body:i.slice(s[0]+t.length,s[1]),post:i.slice(s[1]+n.length)}}function e(t,e){var r=e.match(t);return r?r[0]:null}function r(t,e,r){var n,i,s,o,a,c=r.indexOf(t),h=r.indexOf(e,c+1),u=c;if(c>=0&&h>0){if(t===e)return[c,h];for(n=[],s=r.length;u>=0&&!a;)u==c?(n.push(u),c=r.indexOf(t,u+1)):1==n.length?a=[n.pop(),h]:((i=n.pop())<s&&(s=i,o=h),h=r.indexOf(e,u+1)),u=c<h&&c>=0?c:h;n.length&&(a=[s,o])}return a}return d=1,p=t,t.range=r,p}();m=function(t){if(!t)return[];"{}"===t.substr(0,2)&&(t="\\{\\}"+t.substr(2));return y(function(t){return t.split("\\\\").join(r).split("\\{").join(n).split("\\}").join(i).split("\\,").join(s).split("\\.").join(o)}(t),!0).map(c)};var r="\0SLASH"+Math.random()+"\0",n="\0OPEN"+Math.random()+"\0",i="\0CLOSE"+Math.random()+"\0",s="\0COMMA"+Math.random()+"\0",o="\0PERIOD"+Math.random()+"\0";function a(t){return parseInt(t,10)==t?parseInt(t,10):t.charCodeAt(0)}function c(t){return t.split(r).join("\\").split(n).join("{").split(i).join("}").split(s).join(",").split(o).join(".")}function h(t){if(!t)return[""];var r=[],n=e("{","}",t);if(!n)return t.split(",");var i=n.pre,s=n.body,o=n.post,a=i.split(",");a[a.length-1]+="{"+s+"}";var c=h(o);return o.length&&(a[a.length-1]+=c.shift(),a.push.apply(a,c)),r.push.apply(r,a),r}function u(t){return"{"+t+"}"}function l(t){return/^-?0\d/.test(t)}function f(t,e){return t<=e}function v(t,e){return t>=e}function y(r,n){var s=[],o=e("{","}",r);if(!o||/\$$/.test(o.pre))return[r];var c,p=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(o.body),d=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(o.body),m=p||d,g=o.body.indexOf(",")>=0;if(!m&&!g)return o.post.match(/,.*\}/)?y(r=o.pre+"{"+o.body+i+o.post):[r];if(m)c=o.body.split(/\.\./);else if(1===(c=h(o.body)).length&&1===(c=y(c[0],!1).map(u)).length)return(w=o.post.length?y(o.post,!1):[""]).map((function(t){return o.pre+c[0]+t}));var b,_=o.pre,w=o.post.length?y(o.post,!1):[""];if(m){var E=a(c[0]),O=a(c[1]),S=Math.max(c[0].length,c[1].length),k=3==c.length?Math.abs(a(c[2])):1,A=f;O<E&&(k*=-1,A=v);var x=c.some(l);b=[];for(var j=E;A(j,O);j+=k){var I;if(d)"\\"===(I=String.fromCharCode(j))&&(I="");else if(I=String(j),x){var R=S-I.length;if(R>0){var N=new Array(R+1).join("0");I=j<0?"-"+N+I.slice(1):N+I}}b.push(I)}}else b=t(c,(function(t){return y(t,!1)}));for(var L=0;L<b.length;L++)for(var T=0;T<w.length;T++){var C=_+b[L]+w[T];(!n||m||C)&&s.push(C)}return s}return m}function S(){if(y)return v;y=1,v=h,h.Minimatch=u;var t=function(){try{return require("path")}catch(t){}}()||{sep:"/"};h.sep=t.sep;var e=h.GLOBSTAR=u.GLOBSTAR={},r=O(),n={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}},i="[^/]",s=i+"*?",o="().*{}+?[]^$\\!".split("").reduce((function(t,e){return t[e]=!0,t}),{});var a=/\/+/;function c(t,e){e=e||{};var r={};return Object.keys(t).forEach((function(e){r[e]=t[e]})),Object.keys(e).forEach((function(t){r[t]=e[t]})),r}function h(t,e,r){return f(e),r||(r={}),!(!r.nocomment&&"#"===e.charAt(0))&&new u(e,r).match(t)}function u(e,r){if(!(this instanceof u))return new u(e,r);f(e),r||(r={}),e=e.trim(),r.allowWindowsEscape||"/"===t.sep||(e=e.split(t.sep).join("/")),this.options=r,this.set=[],this.pattern=e,this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.make()}function l(t,e){return e||(e=this instanceof u?this.options:{}),t=void 0===t?this.pattern:t,f(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:r(t)}h.filter=function(t,e){return e=e||{},function(r,n,i){return h(r,t,e)}},h.defaults=function(t){if(!t||"object"!=typeof t||!Object.keys(t).length)return h;var e=h,r=function(r,n,i){return e(r,n,c(t,i))};return(r.Minimatch=function(r,n){return new e.Minimatch(r,c(t,n))}).defaults=function(r){return e.defaults(c(t,r)).Minimatch},r.filter=function(r,n){return e.filter(r,c(t,n))},r.defaults=function(r){return e.defaults(c(t,r))},r.makeRe=function(r,n){return e.makeRe(r,c(t,n))},r.braceExpand=function(r,n){return e.braceExpand(r,c(t,n))},r.match=function(r,n,i){return e.match(r,n,c(t,i))},r},u.defaults=function(t){return h.defaults(t).Minimatch},u.prototype.debug=function(){},u.prototype.make=function(){var t=this.pattern,e=this.options;if(!e.nocomment&&"#"===t.charAt(0))return void(this.comment=!0);if(!t)return void(this.empty=!0);this.parseNegate();var r=this.globSet=this.braceExpand();e.debug&&(this.debug=function(){console.error.apply(console,arguments)});this.debug(this.pattern,r),r=this.globParts=r.map((function(t){return t.split(a)})),this.debug(this.pattern,r),r=r.map((function(t,e,r){return t.map(this.parse,this)}),this),this.debug(this.pattern,r),r=r.filter((function(t){return-1===t.indexOf(!1)})),this.debug(this.pattern,r),this.set=r},u.prototype.parseNegate=function(){var t=this.pattern,e=!1,r=this.options,n=0;if(r.nonegate)return;for(var i=0,s=t.length;i<s&&"!"===t.charAt(i);i++)e=!e,n++;n&&(this.pattern=t.substr(n));this.negate=e},h.braceExpand=function(t,e){return l(t,e)},u.prototype.braceExpand=l;var f=function(t){if("string"!=typeof t)throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")};u.prototype.parse=function(t,r){f(t);var a=this.options;if("**"===t){if(!a.noglobstar)return e;t="*"}if(""===t)return"";var c,h="",u=!!a.nocase,l=!1,d=[],m=[],g=!1,v=-1,y=-1,b="."===t.charAt(0)?"":a.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",_=this;function w(){if(c){switch(c){case"*":h+=s,u=!0;break;case"?":h+=i,u=!0;break;default:h+="\\"+c}_.debug("clearStateChar %j %j",c,h),c=!1}}for(var E,O=0,S=t.length;O<S&&(E=t.charAt(O));O++)if(this.debug("%s\t%s %s %j",t,O,h,E),l&&o[E])h+="\\"+E,l=!1;else switch(E){case"/":return!1;case"\\":w(),l=!0;continue;case"?":case"*":case"+":case"@":case"!":if(this.debug("%s\t%s %s %j <-- stateChar",t,O,h,E),g){this.debug(" in class"),"!"===E&&O===y+1&&(E="^"),h+=E;continue}_.debug("call clearStateChar %j",c),w(),c=E,a.noext&&w();continue;case"(":if(g){h+="(";continue}if(!c){h+="\\(";continue}d.push({type:c,start:O-1,reStart:h.length,open:n[c].open,close:n[c].close}),h+="!"===c?"(?:(?!(?:":"(?:",this.debug("plType %j %j",c,h),c=!1;continue;case")":if(g||!d.length){h+="\\)";continue}w(),u=!0;var k=d.pop();h+=k.close,"!"===k.type&&m.push(k),k.reEnd=h.length;continue;case"|":if(g||!d.length||l){h+="\\|",l=!1;continue}w(),h+="|";continue;case"[":if(w(),g){h+="\\"+E;continue}g=!0,y=O,v=h.length,h+=E;continue;case"]":if(O===y+1||!g){h+="\\"+E,l=!1;continue}var A=t.substring(y+1,O);try{RegExp("["+A+"]")}catch(t){var x=this.parse(A,p);h=h.substr(0,v)+"\\["+x[0]+"\\]",u=u||x[1],g=!1;continue}u=!0,g=!1,h+=E;continue;default:w(),l?l=!1:!o[E]||"^"===E&&g||(h+="\\"),h+=E}g&&(A=t.substr(y+1),x=this.parse(A,p),h=h.substr(0,v)+"\\["+x[0],u=u||x[1]);for(k=d.pop();k;k=d.pop()){var j=h.slice(k.reStart+k.open.length);this.debug("setting tail",h,k),j=j.replace(/((?:\\{2}){0,64})(\\?)\|/g,(function(t,e,r){return r||(r="\\"),e+e+r+"|"})),this.debug("tail=%j\n %s",j,j,k,h);var I="*"===k.type?s:"?"===k.type?i:"\\"+k.type;u=!0,h=h.slice(0,k.reStart)+I+"\\("+j}w(),l&&(h+="\\\\");var R=!1;switch(h.charAt(0)){case"[":case".":case"(":R=!0}for(var N=m.length-1;N>-1;N--){var L=m[N],T=h.slice(0,L.reStart),C=h.slice(L.reStart,L.reEnd-8),M=h.slice(L.reEnd-8,L.reEnd),D=h.slice(L.reEnd);M+=D;var G=T.split("(").length-1,$=D;for(O=0;O<G;O++)$=$.replace(/\)[+*?]?/,"");var P="";""===(D=$)&&r!==p&&(P="$"),h=T+C+D+P+M}""!==h&&u&&(h="(?=.)"+h);R&&(h=b+h);if(r===p)return[h,u];if(!u)return function(t){return t.replace(/\\(.)/g,"$1")}(t);var F=a.nocase?"i":"";try{var q=new RegExp("^"+h+"$",F)}catch(t){return new RegExp("$.")}return q._glob=t,q._src=h,q};var p={};return h.makeRe=function(t,e){return new u(t,e||{}).makeRe()},u.prototype.makeRe=function(){if(this.regexp||!1===this.regexp)return this.regexp;var t=this.set;if(!t.length)return this.regexp=!1,this.regexp;var r=this.options,n=r.noglobstar?s:r.dot?"(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?":"(?:(?!(?:\\/|^)\\.).)*?",i=r.nocase?"i":"",o=t.map((function(t){return t.map((function(t){return t===e?n:"string"==typeof t?function(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}(t):t._src})).join("\\/")})).join("|");o="^(?:"+o+")$",this.negate&&(o="^(?!"+o+").*$");try{this.regexp=new RegExp(o,i)}catch(t){this.regexp=!1}return this.regexp},h.match=function(t,e,r){var n=new u(e,r=r||{});return t=t.filter((function(t){return n.match(t)})),n.options.nonull&&!t.length&&t.push(e),t},u.prototype.match=function(e,r){if(void 0===r&&(r=this.partial),this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return""===e;if("/"===e&&r)return!0;var n=this.options;"/"!==t.sep&&(e=e.split(t.sep).join("/")),e=e.split(a),this.debug(this.pattern,"split",e);var i,s,o=this.set;for(this.debug(this.pattern,"set",o),s=e.length-1;s>=0&&!(i=e[s]);s--);for(s=0;s<o.length;s++){var c=o[s],h=e;if(n.matchBase&&1===c.length&&(h=[i]),this.matchOne(h,c,r))return!!n.flipNegate||!this.negate}return!n.flipNegate&&this.negate},u.prototype.matchOne=function(t,r,n){var i=this.options;this.debug("matchOne",{this:this,file:t,pattern:r}),this.debug("matchOne",t.length,r.length);for(var s=0,o=0,a=t.length,c=r.length;s<a&&o<c;s++,o++){this.debug("matchOne loop");var h,u=r[o],l=t[s];if(this.debug(r,u,l),!1===u)return!1;if(u===e){this.debug("GLOBSTAR",[r,u,l]);var f=s,p=o+1;if(p===c){for(this.debug("** at the end");s<a;s++)if("."===t[s]||".."===t[s]||!i.dot&&"."===t[s].charAt(0))return!1;return!0}for(;f<a;){var d=t[f];if(this.debug("\nglobstar while",t,f,r,p,d),this.matchOne(t.slice(f),r.slice(p),n))return this.debug("globstar found match!",f,a,d),!0;if("."===d||".."===d||!i.dot&&"."===d.charAt(0)){this.debug("dot detected!",t,f,r,p);break}this.debug("globstar swallow a segment, and continue"),f++}return!(!n||(this.debug("\n>>> no match, partial?",t,f,r,p),f!==a))}if("string"==typeof u?(h=l===u,this.debug("string match",u,l,h)):(h=l.match(u),this.debug("pattern match",u,l,h)),!h)return!1}if(s===a&&o===c)return!0;if(s===a)return n;if(o===c)return s===a-1&&""===t[s];throw new Error("wtf?")},v}var k,A,x={exports:{}},j={exports:{}};function I(){if(A)return x.exports;A=1;try{var t=require("util");if("function"!=typeof t.inherits)throw"";x.exports=t.inherits}catch(t){x.exports=(k||(k=1,"function"==typeof Object.create?j.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:j.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}),j.exports)}return x.exports}var R,N={exports:{}};function L(){if(R)return N.exports;function t(t){return"/"===t.charAt(0)}function e(t){var e=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/.exec(t),r=e[1]||"",n=Boolean(r&&":"!==r.charAt(1));return Boolean(e[2]||n)}return R=1,N.exports="win32"===process.platform?e:t,N.exports.posix=t,N.exports.win32=e,N.exports}var T,C,M,D,G,$={};function P(){if(T)return $;function t(t,e){return Object.prototype.hasOwnProperty.call(t,e)}T=1,$.setopts=function(r,n,o){o||(o={});if(o.matchBase&&-1===n.indexOf("/")){if(o.noglobstar)throw new Error("base matching requires globstar");n="**/"+n}r.silent=!!o.silent,r.pattern=n,r.strict=!1!==o.strict,r.realpath=!!o.realpath,r.realpathCache=o.realpathCache||Object.create(null),r.follow=!!o.follow,r.dot=!!o.dot,r.mark=!!o.mark,r.nodir=!!o.nodir,r.nodir&&(r.mark=!0);r.sync=!!o.sync,r.nounique=!!o.nounique,r.nonull=!!o.nonull,r.nosort=!!o.nosort,r.nocase=!!o.nocase,r.stat=!!o.stat,r.noprocess=!!o.noprocess,r.absolute=!!o.absolute,r.maxLength=o.maxLength||1/0,r.cache=o.cache||Object.create(null),r.statCache=o.statCache||Object.create(null),r.symlinks=o.symlinks||Object.create(null),function(t,e){t.ignore=e.ignore||[],Array.isArray(t.ignore)||(t.ignore=[t.ignore]);t.ignore.length&&(t.ignore=t.ignore.map(a))}(r,o),r.changedCwd=!1;var h=process.cwd();t(o,"cwd")?(r.cwd=e.resolve(o.cwd),r.changedCwd=r.cwd!==h):r.cwd=h;r.root=o.root||e.resolve(r.cwd,"/"),r.root=e.resolve(r.root),"win32"===process.platform&&(r.root=r.root.replace(/\\/g,"/"));r.cwdAbs=i(r.cwd)?r.cwd:c(r,r.cwd),"win32"===process.platform&&(r.cwdAbs=r.cwdAbs.replace(/\\/g,"/"));r.nomount=!!o.nomount,o.nonegate=!0,o.nocomment=!0,r.minimatch=new s(n,o),r.options=r.minimatch.options},$.ownProp=t,$.makeAbs=c,$.finish=function(t){for(var e=t.nounique,r=e?[]:Object.create(null),n=0,i=t.matches.length;n<i;n++){var s=t.matches[n];if(s&&0!==Object.keys(s).length){var a=Object.keys(s);e?r.push.apply(r,a):a.forEach((function(t){r[t]=!0}))}else if(t.nonull){var u=t.minimatch.globSet[n];e?r.push(u):r[u]=!0}}e||(r=Object.keys(r));t.nosort||(r=r.sort(o));if(t.mark){for(n=0;n<r.length;n++)r[n]=t._mark(r[n]);t.nodir&&(r=r.filter((function(e){var r=!/\/$/.test(e),n=t.cache[e]||t.cache[c(t,e)];return r&&n&&(r="DIR"!==n&&!Array.isArray(n)),r})))}t.ignore.length&&(r=r.filter((function(e){return!h(t,e)})));t.found=r},$.mark=function(t,e){var r=c(t,e),n=t.cache[r],i=e;if(n){var s="DIR"===n||Array.isArray(n),o="/"===e.slice(-1);if(s&&!o?i+="/":!s&&o&&(i=i.slice(0,-1)),i!==e){var a=c(t,i);t.statCache[a]=t.statCache[r],t.cache[a]=t.cache[r]}}return i},$.isIgnored=h,$.childrenIgnored=function(t,e){return!!t.ignore.length&&t.ignore.some((function(t){return!(!t.gmatcher||!t.gmatcher.match(e))}))};var e=r,n=S(),i=L(),s=n.Minimatch;function o(t,e){return t.localeCompare(e,"en")}function a(t){var e=null;if("/**"===t.slice(-3)){var r=t.replace(/(\/\*\*)+$/,"");e=new s(r,{dot:!0})}return{matcher:new s(t,{dot:!0}),gmatcher:e}}function c(t,r){var n=r;return n="/"===r.charAt(0)?e.join(t.root,r):i(r)||""===r?r:t.changedCwd?e.resolve(t.cwd,r):e.resolve(r),"win32"===process.platform&&(n=n.replace(/\\/g,"/")),n}function h(t,e){return!!t.ignore.length&&t.ignore.some((function(t){return t.matcher.match(e)||!(!t.gmatcher||!t.gmatcher.match(e))}))}return $}function F(){if(G)return D;return G=1,D=function t(e,r){if(e&&r)return t(e)(r);if("function"!=typeof e)throw new TypeError("need wrapper function");return Object.keys(e).forEach((function(t){n[t]=e[t]})),n;function n(){for(var t=new Array(arguments.length),r=0;r<t.length;r++)t[r]=arguments[r];var n=e.apply(this,t),i=t[t.length-1];return"function"==typeof n&&n!==i&&Object.keys(i).forEach((function(t){n[t]=i[t]})),n}},D}var q,B,Q,U,z,W={exports:{}};function Z(){if(q)return W.exports;q=1;var t=F();function e(t){var e=function(){return e.called?e.value:(e.called=!0,e.value=t.apply(this,arguments))};return e.called=!1,e}function r(t){var e=function(){if(e.called)throw new Error(e.onceError);return e.called=!0,e.value=t.apply(this,arguments)},r=t.name||"Function wrapped with `once`";return e.onceError=r+" shouldn't be called more than once",e.called=!1,e}return W.exports=t(e),W.exports.strict=t(r),e.proto=e((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return e(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return r(this)},configurable:!0})})),W.exports}function K(){if(Q)return B;Q=1;var t=F(),e=Object.create(null),r=Z();return B=t((function(t,n){return e[t]?(e[t].push(n),null):(e[t]=[n],function(t){return r((function r(){var n=e[t],i=n.length,s=function(t){for(var e=t.length,r=[],n=0;n<e;n++)r[n]=t[n];return r}(arguments);try{for(var o=0;o<i;o++)n[o].apply(null,s)}finally{n.length>i?(n.splice(0,i),process.nextTick((function(){r.apply(null,s)}))):delete e[t]}}))}(t))})),B}function H(){if(z)return U;z=1,U=_;var t=e,s=w(),o=S();o.Minimatch;var a=I(),c=n.EventEmitter,h=r,u=i,l=L(),f=function(){if(M)return C;M=1,C=d,d.GlobSync=m;var t=e,n=w(),s=S();s.Minimatch,H().Glob;var o=r,a=i,c=L(),h=P(),u=h.setopts,l=h.ownProp,f=h.childrenIgnored,p=h.isIgnored;function d(t,e){if("function"==typeof e||3===arguments.length)throw new TypeError("callback provided to sync glob\nSee: https://github.com/isaacs/node-glob/issues/167");return new m(t,e).found}function m(t,e){if(!t)throw new Error("must provide pattern");if("function"==typeof e||3===arguments.length)throw new TypeError("callback provided to sync glob\nSee: https://github.com/isaacs/node-glob/issues/167");if(!(this instanceof m))return new m(t,e);if(u(this,t,e),this.noprocess)return this;var r=this.minimatch.set.length;this.matches=new Array(r);for(var n=0;n<r;n++)this._process(this.minimatch.set[n],n,!1);this._finish()}return m.prototype._finish=function(){if(a(this instanceof m),this.realpath){var t=this;this.matches.forEach((function(e,r){var i=t.matches[r]=Object.create(null);for(var s in e)try{s=t._makeAbs(s),i[n.realpathSync(s,t.realpathCache)]=!0}catch(e){if("stat"!==e.syscall)throw e;i[t._makeAbs(s)]=!0}}))}h.finish(this)},m.prototype._process=function(t,e,r){a(this instanceof m);for(var n,i=0;"string"==typeof t[i];)i++;switch(i){case t.length:return void this._processSimple(t.join("/"),e);case 0:n=null;break;default:n=t.slice(0,i).join("/")}var o,h=t.slice(i);null===n?o=".":c(n)||c(t.join("/"))?(n&&c(n)||(n="/"+n),o=n):o=n;var u=this._makeAbs(o);f(this,o)||(h[0]===s.GLOBSTAR?this._processGlobStar(n,o,u,h,e,r):this._processReaddir(n,o,u,h,e,r))},m.prototype._processReaddir=function(t,e,r,n,i,s){var a=this._readdir(r,s);if(a){for(var c=n[0],h=!!this.minimatch.negate,u=c._glob,l=this.dot||"."===u.charAt(0),f=[],p=0;p<a.length;p++)("."!==(g=a[p]).charAt(0)||l)&&(h&&!t?!g.match(c):g.match(c))&&f.push(g);var d=f.length;if(0!==d)if(1!==n.length||this.mark||this.stat)for(n.shift(),p=0;p<d;p++){var m;g=f[p],m=t?[t,g]:[g],this._process(m.concat(n),i,s)}else{this.matches[i]||(this.matches[i]=Object.create(null));for(p=0;p<d;p++){var g=f[p];t&&(g="/"!==t.slice(-1)?t+"/"+g:t+g),"/"!==g.charAt(0)||this.nomount||(g=o.join(this.root,g)),this._emitMatch(i,g)}}}},m.prototype._emitMatch=function(t,e){if(!p(this,e)){var r=this._makeAbs(e);if(this.mark&&(e=this._mark(e)),this.absolute&&(e=r),!this.matches[t][e]){if(this.nodir){var n=this.cache[r];if("DIR"===n||Array.isArray(n))return}this.matches[t][e]=!0,this.stat&&this._stat(e)}}},m.prototype._readdirInGlobStar=function(e){if(this.follow)return this._readdir(e,!1);var r,n;try{n=t.lstatSync(e)}catch(t){if("ENOENT"===t.code)return null}var i=n&&n.isSymbolicLink();return this.symlinks[e]=i,i||!n||n.isDirectory()?r=this._readdir(e,!1):this.cache[e]="FILE",r},m.prototype._readdir=function(e,r){if(r&&!l(this.symlinks,e))return this._readdirInGlobStar(e);if(l(this.cache,e)){var n=this.cache[e];if(!n||"FILE"===n)return null;if(Array.isArray(n))return n}try{return this._readdirEntries(e,t.readdirSync(e))}catch(t){return this._readdirError(e,t),null}},m.prototype._readdirEntries=function(t,e){if(!this.mark&&!this.stat)for(var r=0;r<e.length;r++){var n=e[r];n="/"===t?t+n:t+"/"+n,this.cache[n]=!0}return this.cache[t]=e,e},m.prototype._readdirError=function(t,e){switch(e.code){case"ENOTSUP":case"ENOTDIR":var r=this._makeAbs(t);if(this.cache[r]="FILE",r===this.cwdAbs){var n=new Error(e.code+" invalid cwd "+this.cwd);throw n.path=this.cwd,n.code=e.code,n}break;case"ENOENT":case"ELOOP":case"ENAMETOOLONG":case"UNKNOWN":this.cache[this._makeAbs(t)]=!1;break;default:if(this.cache[this._makeAbs(t)]=!1,this.strict)throw e;this.silent||console.error("glob error",e)}},m.prototype._processGlobStar=function(t,e,r,n,i,s){var o=this._readdir(r,s);if(o){var a=n.slice(1),c=t?[t]:[],h=c.concat(a);this._process(h,i,!1);var u=o.length;if(!this.symlinks[r]||!s)for(var l=0;l<u;l++)if("."!==o[l].charAt(0)||this.dot){var f=c.concat(o[l],a);this._process(f,i,!0);var p=c.concat(o[l],n);this._process(p,i,!0)}}},m.prototype._processSimple=function(t,e){var r=this._stat(t);if(this.matches[e]||(this.matches[e]=Object.create(null)),r){if(t&&c(t)&&!this.nomount){var n=/[\/\\]$/.test(t);"/"===t.charAt(0)?t=o.join(this.root,t):(t=o.resolve(this.root,t),n&&(t+="/"))}"win32"===process.platform&&(t=t.replace(/\\/g,"/")),this._emitMatch(e,t)}},m.prototype._stat=function(e){var r=this._makeAbs(e),n="/"===e.slice(-1);if(e.length>this.maxLength)return!1;if(!this.stat&&l(this.cache,r)){var i=this.cache[r];if(Array.isArray(i)&&(i="DIR"),!n||"DIR"===i)return i;if(n&&"FILE"===i)return!1}var s=this.statCache[r];if(!s){var o;try{o=t.lstatSync(r)}catch(t){if(t&&("ENOENT"===t.code||"ENOTDIR"===t.code))return this.statCache[r]=!1,!1}if(o&&o.isSymbolicLink())try{s=t.statSync(r)}catch(t){s=o}else s=o}return this.statCache[r]=s,i=!0,s&&(i=s.isDirectory()?"DIR":"FILE"),this.cache[r]=this.cache[r]||i,(!n||"FILE"!==i)&&i},m.prototype._mark=function(t){return h.mark(this,t)},m.prototype._makeAbs=function(t){return h.makeAbs(this,t)},C}(),p=P(),d=p.setopts,m=p.ownProp,g=K(),v=p.childrenIgnored,y=p.isIgnored,b=Z();function _(t,e,r){if("function"==typeof e&&(r=e,e={}),e||(e={}),e.sync){if(r)throw new TypeError("callback provided to sync glob");return f(t,e)}return new O(t,e,r)}_.sync=f;var E=_.GlobSync=f.GlobSync;function O(t,e,r){if("function"==typeof e&&(r=e,e=null),e&&e.sync){if(r)throw new TypeError("callback provided to sync glob");return new E(t,e)}if(!(this instanceof O))return new O(t,e,r);d(this,t,e),this._didRealPath=!1;var n=this.minimatch.set.length;this.matches=new Array(n),"function"==typeof r&&(r=b(r),this.on("error",r),this.on("end",(function(t){r(null,t)})));var i=this;if(this._processing=0,this._emitQueue=[],this._processQueue=[],this.paused=!1,this.noprocess)return this;if(0===n)return a();for(var s=!0,o=0;o<n;o++)this._process(this.minimatch.set[o],o,!1,a);function a(){--i._processing,i._processing<=0&&(s?process.nextTick((function(){i._finish()})):i._finish())}s=!1}return _.glob=_,_.hasMagic=function(t,e){var r=function(t,e){if(null===e||"object"!=typeof e)return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}({},e);r.noprocess=!0;var n=new O(t,r).minimatch.set;if(!t)return!1;if(n.length>1)return!0;for(var i=0;i<n[0].length;i++)if("string"!=typeof n[0][i])return!0;return!1},_.Glob=O,a(O,c),O.prototype._finish=function(){if(u(this instanceof O),!this.aborted){if(this.realpath&&!this._didRealpath)return this._realpath();p.finish(this),this.emit("end",this.found)}},O.prototype._realpath=function(){if(!this._didRealpath){this._didRealpath=!0;var t=this.matches.length;if(0===t)return this._finish();for(var e=this,r=0;r<this.matches.length;r++)this._realpathSet(r,n)}function n(){0==--t&&e._finish()}},O.prototype._realpathSet=function(t,e){var r=this.matches[t];if(!r)return e();var n=Object.keys(r),i=this,o=n.length;if(0===o)return e();var a=this.matches[t]=Object.create(null);n.forEach((function(r,n){r=i._makeAbs(r),s.realpath(r,i.realpathCache,(function(n,s){n?"stat"===n.syscall?a[r]=!0:i.emit("error",n):a[s]=!0,0==--o&&(i.matches[t]=a,e())}))}))},O.prototype._mark=function(t){return p.mark(this,t)},O.prototype._makeAbs=function(t){return p.makeAbs(this,t)},O.prototype.abort=function(){this.aborted=!0,this.emit("abort")},O.prototype.pause=function(){this.paused||(this.paused=!0,this.emit("pause"))},O.prototype.resume=function(){if(this.paused){if(this.emit("resume"),this.paused=!1,this._emitQueue.length){var t=this._emitQueue.slice(0);this._emitQueue.length=0;for(var e=0;e<t.length;e++){var r=t[e];this._emitMatch(r[0],r[1])}}if(this._processQueue.length){var n=this._processQueue.slice(0);this._processQueue.length=0;for(e=0;e<n.length;e++){var i=n[e];this._processing--,this._process(i[0],i[1],i[2],i[3])}}}},O.prototype._process=function(t,e,r,n){if(u(this instanceof O),u("function"==typeof n),!this.aborted)if(this._processing++,this.paused)this._processQueue.push([t,e,r,n]);else{for(var i,s=0;"string"==typeof t[s];)s++;switch(s){case t.length:return void this._processSimple(t.join("/"),e,n);case 0:i=null;break;default:i=t.slice(0,s).join("/")}var a,c=t.slice(s);null===i?a=".":l(i)||l(t.join("/"))?(i&&l(i)||(i="/"+i),a=i):a=i;var h=this._makeAbs(a);if(v(this,a))return n();c[0]===o.GLOBSTAR?this._processGlobStar(i,a,h,c,e,r,n):this._processReaddir(i,a,h,c,e,r,n)}},O.prototype._processReaddir=function(t,e,r,n,i,s,o){var a=this;this._readdir(r,s,(function(c,h){return a._processReaddir2(t,e,r,n,i,s,h,o)}))},O.prototype._processReaddir2=function(t,e,r,n,i,s,o,a){if(!o)return a();for(var c=n[0],u=!!this.minimatch.negate,l=c._glob,f=this.dot||"."===l.charAt(0),p=[],d=0;d<o.length;d++){if("."!==(g=o[d]).charAt(0)||f)(u&&!t?!g.match(c):g.match(c))&&p.push(g)}var m=p.length;if(0===m)return a();if(1===n.length&&!this.mark&&!this.stat){this.matches[i]||(this.matches[i]=Object.create(null));for(d=0;d<m;d++){var g=p[d];t&&(g="/"!==t?t+"/"+g:t+g),"/"!==g.charAt(0)||this.nomount||(g=h.join(this.root,g)),this._emitMatch(i,g)}return a()}n.shift();for(d=0;d<m;d++){g=p[d];t&&(g="/"!==t?t+"/"+g:t+g),this._process([g].concat(n),i,s,a)}a()},O.prototype._emitMatch=function(t,e){if(!this.aborted&&!y(this,e))if(this.paused)this._emitQueue.push([t,e]);else{var r=l(e)?e:this._makeAbs(e);if(this.mark&&(e=this._mark(e)),this.absolute&&(e=r),!this.matches[t][e]){if(this.nodir){var n=this.cache[r];if("DIR"===n||Array.isArray(n))return}this.matches[t][e]=!0;var i=this.statCache[r];i&&this.emit("stat",e,i),this.emit("match",e)}}},O.prototype._readdirInGlobStar=function(e,r){if(!this.aborted){if(this.follow)return this._readdir(e,!1,r);var n=this,i=g("lstat\0"+e,(function(t,i){if(t&&"ENOENT"===t.code)return r();var s=i&&i.isSymbolicLink();n.symlinks[e]=s,s||!i||i.isDirectory()?n._readdir(e,!1,r):(n.cache[e]="FILE",r())}));i&&t.lstat(e,i)}},O.prototype._readdir=function(e,r,n){if(!this.aborted&&(n=g("readdir\0"+e+"\0"+r,n))){if(r&&!m(this.symlinks,e))return this._readdirInGlobStar(e,n);if(m(this.cache,e)){var i=this.cache[e];if(!i||"FILE"===i)return n();if(Array.isArray(i))return n(null,i)}t.readdir(e,function(t,e,r){return function(n,i){n?t._readdirError(e,n,r):t._readdirEntries(e,i,r)}}(this,e,n))}},O.prototype._readdirEntries=function(t,e,r){if(!this.aborted){if(!this.mark&&!this.stat)for(var n=0;n<e.length;n++){var i=e[n];i="/"===t?t+i:t+"/"+i,this.cache[i]=!0}return this.cache[t]=e,r(null,e)}},O.prototype._readdirError=function(t,e,r){if(!this.aborted){switch(e.code){case"ENOTSUP":case"ENOTDIR":var n=this._makeAbs(t);if(this.cache[n]="FILE",n===this.cwdAbs){var i=new Error(e.code+" invalid cwd "+this.cwd);i.path=this.cwd,i.code=e.code,this.emit("error",i),this.abort()}break;case"ENOENT":case"ELOOP":case"ENAMETOOLONG":case"UNKNOWN":this.cache[this._makeAbs(t)]=!1;break;default:this.cache[this._makeAbs(t)]=!1,this.strict&&(this.emit("error",e),this.abort()),this.silent||console.error("glob error",e)}return r()}},O.prototype._processGlobStar=function(t,e,r,n,i,s,o){var a=this;this._readdir(r,s,(function(c,h){a._processGlobStar2(t,e,r,n,i,s,h,o)}))},O.prototype._processGlobStar2=function(t,e,r,n,i,s,o,a){if(!o)return a();var c=n.slice(1),h=t?[t]:[],u=h.concat(c);this._process(u,i,!1,a);var l=this.symlinks[r],f=o.length;if(l&&s)return a();for(var p=0;p<f;p++){if("."!==o[p].charAt(0)||this.dot){var d=h.concat(o[p],c);this._process(d,i,!0,a);var m=h.concat(o[p],n);this._process(m,i,!0,a)}}a()},O.prototype._processSimple=function(t,e,r){var n=this;this._stat(t,(function(i,s){n._processSimple2(t,e,i,s,r)}))},O.prototype._processSimple2=function(t,e,r,n,i){if(this.matches[e]||(this.matches[e]=Object.create(null)),!n)return i();if(t&&l(t)&&!this.nomount){var s=/[\/\\]$/.test(t);"/"===t.charAt(0)?t=h.join(this.root,t):(t=h.resolve(this.root,t),s&&(t+="/"))}"win32"===process.platform&&(t=t.replace(/\\/g,"/")),this._emitMatch(e,t),i()},O.prototype._stat=function(e,r){var n=this._makeAbs(e),i="/"===e.slice(-1);if(e.length>this.maxLength)return r();if(!this.stat&&m(this.cache,n)){var s=this.cache[n];if(Array.isArray(s)&&(s="DIR"),!i||"DIR"===s)return r(null,s);if(i&&"FILE"===s)return r()}var o=this.statCache[n];if(void 0!==o){if(!1===o)return r(null,o);var a=o.isDirectory()?"DIR":"FILE";return i&&"FILE"===a?r():r(null,a,o)}var c=this,h=g("stat\0"+n,(function(i,s){if(s&&s.isSymbolicLink())return t.stat(n,(function(t,i){t?c._stat2(e,n,null,s,r):c._stat2(e,n,t,i,r)}));c._stat2(e,n,i,s,r)}));h&&t.lstat(n,h)},O.prototype._stat2=function(t,e,r,n,i){if(r&&("ENOENT"===r.code||"ENOTDIR"===r.code))return this.statCache[e]=!1,i();var s="/"===t.slice(-1);if(this.statCache[e]=n,"/"===e.slice(-1)&&n&&!n.isDirectory())return i(null,!1,n);var o=!0;return n&&(o=n.isDirectory()?"DIR":"FILE"),this.cache[e]=this.cache[e]||o,s&&"FILE"===o?i():i(null,o,n)},U}var J,Y={exports:{}};const V=t.promisify(H()),X=r,tt=function(){if(J)return Y.exports;J=1;let t=s,e=!("NO_COLOR"in process.env||process.argv.includes("--no-color"))&&("FORCE_COLOR"in process.env||process.argv.includes("--color")||"win32"===process.platform||t.isatty(1)&&"dumb"!==process.env.TERM||"CI"in process.env),r=(t,e,r=t)=>i=>{let s=""+i,o=s.indexOf(e,t.length);return~o?t+n(s,e,r,o)+e:t+s+e},n=(t,e,r,i)=>{let s=t.substring(0,i)+r,o=t.substring(i+e.length),a=o.indexOf(e);return~a?s+n(o,e,r,a):s+o},i=(t=e)=>({isColorSupported:t,reset:t?t=>`${t}`:String,bold:t?r("","",""):String,dim:t?r("","",""):String,italic:t?r("",""):String,underline:t?r("",""):String,inverse:t?r("",""):String,hidden:t?r("",""):String,strikethrough:t?r("",""):String,black:t?r("",""):String,red:t?r("",""):String,green:t?r("",""):String,yellow:t?r("",""):String,blue:t?r("",""):String,magenta:t?r("",""):String,cyan:t?r("",""):String,white:t?r("",""):String,gray:t?r("",""):String,bgBlack:t?r("",""):String,bgRed:t?r("",""):String,bgGreen:t?r("",""):String,bgYellow:t?r("",""):String,bgBlue:t?r("",""):String,bgMagenta:t?r("",""):String,bgCyan:t?r("",""):String,bgWhite:t?r("",""):String});return Y.exports=i(),Y.exports.createColors=i,Y.exports}(),{writeFileSync:et}=o;const rt={path:"./src",output:"./unused-files.json",exclude:[]};async function nt(t){try{return(await V(t,{nodir:!0})).map((t=>X.resolve(t)))}catch(t){console.log("getAllFiles Error:",t)}}var it=a(class{options;constructor(t){this.options=t}apply(t){t.hooks.afterEmit.tap("UnusedFilesWebpackPlugin",(async t=>{const e={...rt,...this.options},{output:r}=e,n=await async function(t,e){const{path:r}=e,n=`${r}/**/*`,i=await nt(n),s=function(t){const{fileDependencies:e}=t,r=[];return e.forEach((t=>{t.includes("node_modules")||r.push(t)})),r}(t);return i.filter((t=>!s.includes(t)))}(t,e);!function(t,e="./unused-files.json"){et(e,JSON.stringify(t,null,2),(t=>{t&&tt.red(`${e} 文件写入失败`)}))}(function(t,e){const{exclude:r}=e,n={};return t.forEach((t=>{const e=X.extname(t);r.includes(e)||(n[e]?n[e].push(t):n[e]=[t])})),n}(n,e),r)}))}});module.exports=it;