UNPKG

5.21 kBJavaScriptView Raw
1var N=Object.create,b=Object.defineProperty,T=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty,q=Object.getOwnPropertyNames,E=Object.getOwnPropertyDescriptor;var I=e=>b(e,"__esModule",{value:!0});var L=(e,t,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of q(t))!U.call(e,n)&&n!=="default"&&b(e,n,{get:()=>t[n],enumerable:!(s=E(t,n))||s.enumerable});return e},_=e=>L(I(b(e!=null?N(T(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var $=_(require("path")),J=_(require("fs")),d=_(require("module"));var O=_(require("events")),c=_(require("fs")),f=_(require("path"));function x(e){let t;return e?(t=e.toIterable)?t.call(e):e:[]}var W=Symbol.for("#__initor__"),X=Symbol.for("#__inited__"),Y=Symbol.for("#type"),Z=Symbol.for("#__listeners__");function F(e,t=null){let s={},n=/\$\$\d+\$\$/,o=function(a){return s[a]||(s[a]=t?t(a):{})},m=function(a,r){if(typeof r=="string"){if(r[0]=="$"&&n.test(r))return o(r)}else if(typeof a=="string"&&a[0]=="$"&&n.test(a)){let l=o(a);return Object.assign(l,r),l}return r};return JSON.parse(e,m)}function M(e,t){var s,n,o,m;let u={},a={added:[],changed:[],removed:[],all:[],urls:{}};if(e.assets)for(let r=0,l=x(e.assets),p=l.length;r<p;r++){let i=l[r],h=i.originalPath||i.path;u[h]=i,i.url&&((s=t.urls)[n=i.url]||(s[n]=i))}for(let r=0,l=x(t.assets||[]),p=l.length;r<p;r++){let i=l[r],h=i.originalPath||i.path,g=u[h];i.url&&e.urls&&(e.urls[i.url]=i),g?(g.hash!=i.hash&&(g.invalidated=Date.now(),g.replacedBy=i,i.replaces=g,a.changed.push(i),a.all.push(i),g==e.main&&(a.main=i)),o=u[h],delete u[h]):(a.added.push(i),a.all.push(i))}for(let r=0,l=Object.keys(u),p=l.length,i,h;r<p;r++)i=l[r],h=u[i],h.removed=Date.now(),a.all.push(h);for(let r=0,l=x(a.all),p=l.length;r<p;r++){let i=l[r];(a[m=i.type]||(a[m]=[])).push(i)}return a.removed=Object.values(u),t.changes=a,t}var j=Symbol.for("#__initor__"),D=Symbol.for("#__inited__"),H=Symbol.for("#refresh"),R=Symbol.for("#__init__"),S=Symbol.for("#manifest"),v=Symbol.for("#absPath"),w=Symbol.for("#raw"),z=Symbol.for("#watch"),A=Symbol(),B=class{constructor(t){this[S]=t}get absPath(){return this[v]||(this[v]=this[S].resolve(this))}get name(){return f.default.basename(this.path)}get body(){return this.readSync()}readSync(){return c.default.readFileSync(this.absPath,"utf-8")}pipe(t){return c.default.createReadStream(this.absPath).pipe(t)}toString(){return this.url||this.absPath}},y=class extends O.EventEmitter{static[R](){return this.prototype[j]=A,this}constructor(t={}){var s;super();s=this,this.options=t,this.data={},this.path=t.path,this.refs={},s.reviver=function(n){return new B(s)},s.init(t.data),this[j]===A&&this[D]&&this[D]()}get srcdir(){return f.default.resolve(f.default.dirname(this.path),this.data.srcdir)}get outdir(){return f.default.resolve(f.default.dirname(this.path),this.data.outdir)}get changes(){return this.data.changes||{}}get inputs(){return this.data.inputs}get outputs(){return this.data.outputs}get assets(){return this.data.assets}get urls(){return this.data.urls||{}}get main(){return this.data.main}get cwd(){return process.cwd()}get raw(){return this.data[w]}resolve(t){return t._=="input"?f.default.resolve(this.srcdir||this.cwd,t.path):t._=="output"?f.default.resolve(this.outdir,t.path):f.default.resolve(this.cwd,t.path||t)}resolveAssetPath(t){return f.default.resolve(this.outdir,t)}read(t){return c.default.readFileSync(this.resolve(t),"utf-8")}loadFromFile(t){return c.default.existsSync(t)?c.default.readFileSync(t,"utf-8"):"{}"}init(t=null){return(t||this.path)&&this.update(t),this}update(t){if(t==null&&(this.path?t=this.loadFromFile(this.path):console.warn("cannot update manifest without path")),typeof t=="string"){let s=t;t=F(t,this.reviver),t[w]=s}return this.data=M(this.data||{},t),this.data.changes.all.length&&this.emit("change",this.diff,this),this.data.changes.main&&this.emit("change:main",this.data.main,this),this.data.changes}serializeForBrowser(){return this.data[w]}[H](t){return!0}watch(){var t=this;if(this[z]!=!0?(this[z]=!0,!0):!1)return t.path&&!process.env.IMBA_HMR&&c.default.watch(this.path,function(s,n){let o=c.default.existsSync(t.path),m=o&&c.default.statSync(t.path);o&&t.update()})}on(t,s){return this.watch(),super.on(...arguments)}};y[R]();var C=class{static for(t){return new Proxy({},new this(t))}constructor(t){this.getter=t}get target(){return this.getter()}get(t,s){return this.target[s]}set(t,s,n){return this.target[s]=n,!0}},it=C.for(function(){return globalThis[S]});var V=Symbol.for("#manifest"),{_resolveFilename:k}=d.Module,P=null;function G(e,t,s){let n=$.default.extname(e),o=$.default.basename(e),m=d.Module._extensions[n];return d.Module._extensions[n]=function(u,a){d.Module._extensions[n]=m;let r=t.readSync(),l="//# sourceMappingURL="+t.name+".map",p="//# sourceMappingURL="+s+".map";return r=r.replace(l,p),u._compile(r,a)},e}d.Module._resolveFilename=function(e,t){if(!P&&J.default.existsSync(e+".manifest")){P=globalThis[V]=new y({path:e+".manifest"});let n=P.main;if(n){let o=n.source.absPath;return G(o,n,e),o}}return k.apply(d.Module,arguments)};if(require.main==module){let e=__filename.replace(".loader.js",".js");e!=__filename&&require(e)}