@flecks/core
Advanced tools
Comparing version 3.1.3 to 3.1.4
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("debug"),require("lodash.get"),require("lodash.set")):"function"==typeof define&&define.amd?define("@flecks/core",["debug","lodash.get","lodash.set"],t):"object"==typeof exports?exports["@flecks/core"]=t(require("debug"),require("lodash.get"),require("lodash.set")):e["@flecks/core"]=t(e.debug,e["lodash.get"],e["lodash.set"])}(global,((e,t,s)=>(()=>{var o={305:e=>{e.exports=class{}},269:e=>{e.exports=function(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...s)=>e(t(...s))))}},157:(e,t,s)=>{const o=s(999),{VSCODE_INSPECTOR_OPTIONS:n}=process.env;e.exports=e=>{{if(n){const{formatArgs:e}=o;o.formatArgs=function(t){const{useColors:s}=this;t[0].match(/%[oO]/)&&(this.useColors=!1),e.call(this,t),this.useColors=s},o.formatters.o=void 0,o.formatters.O=void 0}const e="web"===process.env.FLECKS_CORE_BUILD_TARGET?"debug":"error";o.log=console[e].bind(console)}return o(e)}},817:e=>{e.exports=class{arcs=new Map;addDependency(e,t){this.ensureTail(e),this.ensureTail(t).add(e)}detectCycles(){const e=[],t=new Set,s=new Set,o=n=>{if(!t.has(n)){t.add(n),s.add(n);const r=this.neighbors(n);for(let i=r.next();!0!==i.done;i=r.next()){const{value:r}=i;t.has(r)?s.has(r)&&e.push([n,r]):o(r)}}s.delete(n)},{tails:n}=this;for(let e=n.next();!0!==e.done;e=n.next())o(e.value);return e}ensureTail(e){return this.arcs.has(e)||this.arcs.set(e,new Set),this.arcs.get(e)}neighbors(e){return this.arcs.get(e).values()}sort(){const e=new Set,t=new Map,s=(o,n)=>{e.add(o);const r=this.neighbors(o);for(let t=r.next();!0!==t.done;t=r.next()){const{value:o}=t;e.has(o)||(n=s(o,n))}return t.set(o,n),n-1};let o=this.arcs.size-1;const{tails:n}=this;for(let t=n.next();!0!==t.done;t=n.next()){const{value:n}=t;e.has(n)||(o=s(n,o))}return Array.from(t.entries()).sort((([,e],[,t])=>e-t)).map((([e])=>e))}removeDependency(e,t){this.arcs.has(t)&&this.arcs.get(t).delete(e)}get tails(){return this.arcs.keys()}}},848:e=>{e.exports=function(e){return class extends e{constructor(...e){super(...e),this.$$events=Object.create(null)}addListener(e,t,s){return this.on(e,t,s)}emit(e,...t){const s=this.$$events[e];s&&s.length>0&&this.emitToListeners(s,t)}emitToListeners(e,t){for(let s=0;s<e.length;++s){const{once:o,type:n,fn:r,bound:i,that:c}=e[s];o&&this.offSingleEvent(n,r),0===t.length?i():1===t.length?i(t[0]):2===t.length?i(t[0],t[1]):3===t.length?i(t[0],t[1],t[2]):4===t.length?i(t[0],t[1],t[2],t[3]):5===t.length?i(t[0],t[1],t[2],t[3],t[4]):r.apply(c,t)}}off(e,t){const s=Array.isArray(e)?e:[e];for(let e=0;e<s.length;e++)this.offSingleEvent(s[e],t);return this}offSingleEvent(e,t){"function"==typeof t?e in this.$$events&&(this.$$events[e]=this.$$events[e].filter((e=>e.fn!==t))):e in this.$$events&&(this.$$events[e]=[])}on(e,t,s=void 0){return this.$$on(e,t,s,!1),this}$$on(e,t,s,o){const n=Array.isArray(e)?e:[e];for(let e=0;e<n.length;e++)this.onSingleEvent(n[e],t,s,o)}once(e,t,s=void 0){return this.$$on(e,t,s,!0),this}onSingleEvent(e,t,s,o){if("function"!=typeof t)throw new TypeError("EventEmitter::onSingleEvent() requires function listener");const n=((e,t,s,o)=>({fn:e,that:t,type:s,once:o,bound:t?e.bind(t):e}))(t,s,e,o);e in this.$$events||(this.$$events[e]=[]),this.$$events[e].push(n)}removeListener(...e){return this.off(...e)}}}},278:(e,t,s)=>{const{basename:o,dirname:n,extname:r,join:i}=s(17),c=s(46),h=s(591),l=s(269),a=s(157),f=s(817),d=s(736),u=a("@flecks/core/flecks"),k=u.extend("silly"),p=Symbol.for("@flecks/core.hookPriority");t.So=Symbol.for("@flecks/core.byId"),t.Rn=Symbol.for("@flecks/core.byType");const g=e=>e.substring(0,1).toUpperCase()+e.substring(1),m=e=>e.split(/[_-]/).map(g).join(""),y=new Map,v=(e,t,s,o,n)=>class extends e{static get[s](){return t}static get[n](){return o}};t.MH=class{config={};$$expandedFlecksCache={};flecks={};hooks={};constructor({config:e={},flecks:t={}}={}){const s=Object.fromEntries(Object.keys(t).map((e=>[e,{}])));this.config={...s,...e};const o=Object.entries(t);k("paths: %O",o.map((([e])=>e)));for(let e=0;e<o.length;e++){const[t,s]=o[e];this.registerFleckHooks(t,s),this.invoke("@flecks/core.registered",t,s)}this.configureFlecksDefaults(),k("config: %O",this.config)}configureFleckDefaults(e){this.config[e]={...this.invokeFleck("@flecks/core.config",e),...this.config[e]}}configureFlecksDefaults(){const e=this.flecksImplementing("@flecks/core.config");for(let t=0;t<e.length;t++)this.configureFleckDefaults(e[t])}static dasherizePath(e){const t=n(e).split("/");return"."===t[0]&&t.shift(),"index"===t[t.length-1]&&t.pop(),i(t.join("-"),o(e,r(e)))}static decorate(e,{transformer:t=m}={}){return(s,o)=>e.keys().reduce(((s,n)=>{const r=t(this.dasherizePath(n));if(!s[r])return s;const{default:i}=e(n);if("function"!=typeof i)throw new ReferenceError(`Flecks.decorate(): require(${n}).default is not a function (from: ${e.id})`);return{...s,[r]:i(s[r],o)}}),s)}checkAndDecorateRawGathered(e,t,s){s(t,e);const o=this.invokeComposed(`${e}.decorate`,t);return s(o,`${e}.decorate`),o}destroy(){this.config={},this.hooks={},this.flecks={}}expandedFlecks(e){if(this.$$expandedFlecksCache[e])return[...this.$$expandedFlecksCache[e]];const t=this.lookupFlecks(e);let s=[];for(let e=0;e<t.length;++e){const o=t[e];s.push(o)}const o=s.findIndex((e=>"..."===e));if(-1!==o){if(-1!==s.slice(o+1).findIndex((e=>"..."===e)))throw new Error(`Illegal ordering specification: hook '${e}' has multiple ellipses.`);const t=s.slice(0,o),n=s.slice(o+1);s.splice(o,1);const r=[],i=this.flecksImplementing(e);for(let e=0;e<i.length;++e){const t=i[e];s.includes(t)||r.push(t)}const c=this.flecksHookGraph([...t,...r,...n],e),h=c.detectCycles();if(h.length>0)throw new Error(`Illegal ordering specification: hook '${e}' has positioning cycles: ${h.map((([e,t])=>`${e} <-> ${t}`)).join(", ")}`);s=[...t,...c.sort().filter((e=>!s.includes(e))),...n]}const n=this.flecksHookGraph(s,e);s.forEach(((e,t)=>{t<s.length-1&&n.addDependency(s[t+1],e)}));const r=n.detectCycles();return r.length>0&&r.forEach((([t,s])=>{const o=this.fleckImplementation(t,e),{before:n=[],after:r=[]}=o?.[p]||{},i=[e];n.includes(s)&&i.push(t,"before",s),r.includes(s)&&i.push(t,"after",s);const c=this.fleckImplementation(s,e),{before:h=[],after:l=[]}=c?.[p]||{};h.includes(t)&&i.push(s,"before",t),l.includes(t)&&i.push(s,"after",t),u("Suspicious ordering specification for '%s': '%s' expected to run %s '%s'!",...i)})),this.$$expandedFlecksCache[e]=s.filter((t=>this.fleckImplementation(t,e))),k("cached hook expansion for '%s': %O",e,s),[...this.$$expandedFlecksCache[e]]}fleck(e){return this.flecks[e]}fleckImplementation(e,t){if(!this.hooks[t])return;const s=this.hooks[t]?.find((({fleck:t})=>e===t));return s?s.fn:void 0}flecksImplementing(e){return this.hooks[e]?.map((({fleck:e})=>e))||[]}flecksHookGraph(e,t){const s=new f;return e.forEach((e=>{s.ensureTail(e);const o=this.fleckImplementation(e,t);o?.[p]&&(o[p].before&&o[p].before.forEach((t=>{s.addDependency(t,e)})),o[p].after&&o[p].after.forEach((t=>{s.addDependency(e,t)})))})),this.invoke("@flecks/core.priority",s,t),s}static from(e){const{flecks:t}=e,s=Object.entries(t).map((([e,{mixin:t}])=>[e,t])).filter((([,e])=>e));return k("mixins: %O",s.map((([e])=>e))),new(l(...s.map((([,e])=>e)))(this))(e)}gather(e,{idProperty:s="id",typeProperty:o="type",check:n=(()=>{})}={}){if(!e||"string"!=typeof e)throw new TypeError("Flecks.gather(): Expects parameter 1 (hook) to be string");const r=this.invokeMerge(e),i=this.checkAndDecorateRawGathered(e,r,n);let c=1;const h={},l=Object.fromEntries(Object.entries(i).sort((([e],[t])=>e<t?-1:1)).map((([e,t])=>{const n=c++;return h[n]=v(t,n,s,e,o),[e,h[n]]}))),a={...h,...l,[t.So]:h,[t.Rn]:l};return y.set(e,{check:n,idProperty:s,typeProperty:o,gathered:a}),u("gathered '%s': %O",e,Object.keys(a[t.Rn])),a}get(e,t){return c(this.config,e,t)}interpolate(e){return e.replace(/\[(.*?)\]/g,(e=>this.get(e)))}invoke(e,...t){return this.hooks[e]?this.flecksImplementing(e).reduce(((s,o)=>({...s,[o]:this.invokeFleck(e,o,...t)})),{}):{}}async invokeAsync(e,...t){return this.hooks[e]?this.flecksImplementing(e).reduce((async(s,o)=>({...await s,[o]:await this.invokeFleck(e,o,...t)})),{}):{}}invokeComposed(e,t,...s){return this.hooks[e]?this.expandedFlecks(e).reduce(((t,o)=>this.invokeFleck(e,o,t,...s)),t):t}async invokeComposedAsync(e,t,...s){return this.hooks[e]?this.expandedFlecks(e).reduce((async(t,o)=>this.invokeFleck(e,o,await t,...s)),t):t}invokeFlat(e,...t){return this.hooks[e]?this.hooks[e].map((({fleck:s})=>this.invokeFleck(e,s,...t))):[]}invokeFleck(e,t,...s){if(k("invokeFleck(%s, %s, ...)",e,t),!this.hooks[e])return;const o=this.hooks[e].find((({fleck:e})=>e===t));return o?o.fn(...s.concat(this)):void 0}static $$invokeMerge(e,t){return{...e,...t}}invokeMerge(e,...t){return this.invokeReduce(e,this.constructor.$$invokeMerge,{},...t)}async invokeMergeAsync(e,...t){return this.invokeReduceAsync(e,this.constructor.$$invokeMerge,{},...t)}static $$invokeMergeUnique(){const e={};return(t,s,o,n)=>{const r=Object.keys(s);for(let t=0;t<r.length;++t){const s=r[t];if(e[s])throw new ReferenceError(`Conflict in ${n}: '${e[s]}' implemented '${s}', followed by '${o}'`);e[s]=o}return{...t,...s}}}invokeMergeUnique(e,...t){return this.invokeReduce(e,this.constructor.$$invokeMergeUnique(),{},...t)}async invokeMergeUniqueAsync(e,...t){return this.invokeReduceAsync(e,this.constructor.$$invokeMergeUnique(),{},...t)}invokeReduce(e,t,s,...o){return this.hooks[e]?this.hooks[e].reduce(((s,{fleck:n})=>t(s,this.invokeFleck(e,n,...o),n,e)),s):s}async invokeReduceAsync(e,t,s,...o){return this.hooks[e]?this.hooks[e].reduce((async(s,{fleck:n})=>t(await s,await this.invokeFleck(e,n,...o),n,e)),s):s}invokeSequential(e,...t){if(!this.hooks[e])return[];const s=[],o=this.expandedFlecks(e);for(;o.length>0;){const n=o.shift();s.push(this.invokeFleck(e,n,...t))}return s}async invokeSequentialAsync(e,...t){if(!this.hooks[e])return[];const s=[],o=this.expandedFlecks(e);for(;o.length>0;){const n=o.shift();s.push(await this.invokeFleck(e,n,...t))}return s}lookupFlecks(e){const t=e.indexOf(".");return-1===t?["..."]:this.get([e.slice(0,t),e.slice(t+1)],["..."])}makeMiddleware(e){if(k("makeMiddleware(...): %s",e),!this.hooks[e])return(...e)=>e.pop()();const t=this.expandedFlecks(e);if(0===t.length)return(...e)=>e.pop()();k("middleware: %O",t);const s=new d(t.map((t=>this.invokeFleck(e,t))));return s.dispatch.bind(s)}static priority(e,t={}){const s={};return t.after&&(s.after=Array.isArray(t.after)?t.after:[t.after]),t.before&&(s.before=Array.isArray(t.before)?t.before:[t.before]),e[p]=s,e}static provide(e,{invoke:t=!0,transformer:s=m}={}){return o=>Object.fromEntries(e.keys().map((n=>{const{default:r}=e(n);if(t&&"function"!=typeof r)throw new ReferenceError(`Flecks.provide(): require(${n}).default is not a function (from: ${e.id})`);return[s(this.dasherizePath(n)),t?r(o):r]})))}refresh(e,t){u("refreshing %s...",e),this.unregisterFleckHooks(e),this.registerFleckHooks(e,t),this.configureFleckDefaults(e),this.refreshGathered(e)}refreshGathered(e){const s=y.entries();for(let o=s.next();!0!==o.done;o=s.next()){const{value:[s,{check:n,idProperty:r,gathered:i,typeProperty:c}]}=o;let h;if(this.fleckImplementation(e,`${s}.decorate`)?(h=this.invokeMerge(s),k("%s implements %s.decorate",e,s)):this.fleckImplementation(e,s)&&(h=this.invokeFleck(s,e),k("%s implements %s",e,s)),h){const o=this.checkAndDecorateRawGathered(s,h,n);u("updating gathered %s from %s... %O",s,e,o),Object.entries(o).forEach((([e,o])=>{const{[e]:{[r]:n}}=i,h=v(o,n,r,e,c);i[e]=h,i[n]=h,i[t.So][n]=h,i[t.Rn][e]=h,this.invoke("@flecks/core.hmr.gathered.class",h,s)})),this.invoke("@flecks/core.hmr.gathered",i,s)}}}registerFleckHooks(e,t){if(k("registering %s...",e),this.flecks[e]=t,t.hooks){const s=Object.keys(t.hooks);k("hooks for '%s': %O",e,s);for(let o=0;o<s.length;o++){const n=s[o];this.hooks[n]||(this.hooks[n]=[]),this.hooks[n].push({fleck:e,fn:t.hooks[n]})}}}set(e,t){return h(this.config,e,t)}unregisterFleckHooks(e){const t=Object.keys(this.hooks);for(let s=0;s<t.length;s++){const o=t[s];if(this.hooks[o]){const t=this.hooks[o].findIndex((({fleck:t})=>t===e));-1!==t&&this.hooks[o].splice(t,1)}}}},t.MH.get=c,t.MH.set=h},736:e=>{e.exports=class{constructor(e=[]){this.middleware=[];for(let t=0;t<e.length;++t)this.middleware.push(this.constructor.check(e[t]))}static check(e){if("function"!=typeof e){if(void 0!==e.then)throw new TypeError("middleware expected a function, looks like a promise");throw new TypeError("middleware expected a function")}return e}dispatch(...e){const t=e.pop(),s=this.middleware.concat(),o=n=>{if(s.length>0){const t=s.shift();if(e.length+2===t.length==!n)o(n);else try{t(...e.concat(n?[n]:[]).concat(o))}catch(n){o(n)}}else t&&setTimeout((()=>t(n)),0)};o()}promise(...e){return new Promise(((t,s)=>{this.dispatch(...e.concat((e=>{e?s(e):t()})))}))}use(e){this.middleware.push(this.constructor.check(e))}}},17:e=>{"use strict";e.exports=require("path")},999:t=>{"use strict";t.exports=e},46:e=>{"use strict";e.exports=t},591:e=>{"use strict";e.exports=s}},n={};function r(e){var t=n[e];if(void 0!==t)return t.exports;var s=n[e]={exports:{}};return o[e](s,s.exports,r),s.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{"use strict";r.r(i),r.d(i,{ById:()=>a.So,ByType:()=>a.Rn,Class:()=>t.a,D:()=>c.a,EventEmitter:()=>l.a,Flecks:()=>a.MH,compose:()=>o.a,hooks:()=>f});var e=r(305),t=r.n(e),s=r(269),o=r.n(s),n=r(157),c=r.n(n),h=r(848),l=r.n(h),a=r(278),f={"@flecks/web.config":async(e,t)=>({id:t.get("@flecks/core.id")})}})(),i})())); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("debug"),require("lodash.get"),require("lodash.set")):"function"==typeof define&&define.amd?define("@flecks/core",["debug","lodash.get","lodash.set"],t):"object"==typeof exports?exports["@flecks/core"]=t(require("debug"),require("lodash.get"),require("lodash.set")):e["@flecks/core"]=t(e.debug,e["lodash.get"],e["lodash.set"])}(global,((e,t,s)=>(()=>{var n={305:e=>{e.exports=class{}},269:e=>{e.exports=function(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...s)=>e(t(...s))))}},157:(e,t,s)=>{const n=s(999),{VSCODE_INSPECTOR_OPTIONS:o}=process.env;e.exports=e=>{{if(o){const{formatArgs:e}=n;n.formatArgs=function(t){const{useColors:s}=this;t[0].match(/%[oO]/)&&(this.useColors=!1),e.call(this,t),this.useColors=s},n.formatters.o=void 0,n.formatters.O=void 0}const e="web"===process.env.FLECKS_CORE_BUILD_TARGET?"debug":"error";n.log=console[e].bind(console)}return n(e)}},817:e=>{e.exports=class{arcs=new Map;addDependency(e,t){this.ensureTail(e),this.ensureTail(t).add(e)}detectCycles(){const e=[],t=new Set,s=new Set,n=o=>{if(!t.has(o)){t.add(o),s.add(o);const r=this.neighbors(o);for(let i=r.next();!0!==i.done;i=r.next()){const{value:r}=i;t.has(r)?s.has(r)&&e.push([o,r]):n(r)}}s.delete(o)},{tails:o}=this;for(let e=o.next();!0!==e.done;e=o.next())n(e.value);return e}ensureTail(e){return this.arcs.has(e)||this.arcs.set(e,new Set),this.arcs.get(e)}neighbors(e){return this.arcs.get(e).values()}sort(){const e=new Set,t=new Map,s=(n,o)=>{e.add(n);const r=this.neighbors(n);for(let t=r.next();!0!==t.done;t=r.next()){const{value:n}=t;e.has(n)||(o=s(n,o))}return t.set(n,o),o-1};let n=this.arcs.size-1;const{tails:o}=this;for(let t=o.next();!0!==t.done;t=o.next()){const{value:o}=t;e.has(o)||(n=s(o,n))}return Array.from(t.entries()).sort((([,e],[,t])=>e-t)).map((([e])=>e))}removeDependency(e,t){this.arcs.has(t)&&this.arcs.get(t).delete(e)}get tails(){return this.arcs.keys()}}},848:e=>{e.exports=function(e){return class extends e{constructor(...e){super(...e),this.$$events=Object.create(null)}addListener(e,t,s){return this.on(e,t,s)}emit(e,...t){const s=this.$$events[e];s&&s.length>0&&this.emitToListeners(s,t)}emitToListeners(e,t){for(let s=0;s<e.length;++s){const{once:n,type:o,fn:r,bound:i,that:c}=e[s];n&&this.offSingleEvent(o,r),0===t.length?i():1===t.length?i(t[0]):2===t.length?i(t[0],t[1]):3===t.length?i(t[0],t[1],t[2]):4===t.length?i(t[0],t[1],t[2],t[3]):5===t.length?i(t[0],t[1],t[2],t[3],t[4]):r.apply(c,t)}}off(e,t){const s=Array.isArray(e)?e:[e];for(let e=0;e<s.length;e++)this.offSingleEvent(s[e],t);return this}offSingleEvent(e,t){"function"==typeof t?e in this.$$events&&(this.$$events[e]=this.$$events[e].filter((e=>e.fn!==t))):e in this.$$events&&(this.$$events[e]=[])}on(e,t,s=void 0){return this.$$on(e,t,s,!1),this}$$on(e,t,s,n){const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++)this.onSingleEvent(o[e],t,s,n)}once(e,t,s=void 0){return this.$$on(e,t,s,!0),this}onSingleEvent(e,t,s,n){if("function"!=typeof t)throw new TypeError("EventEmitter::onSingleEvent() requires function listener");const o=((e,t,s,n)=>({fn:e,that:t,type:s,once:n,bound:t?e.bind(t):e}))(t,s,e,n);e in this.$$events||(this.$$events[e]=[]),this.$$events[e].push(o)}removeListener(...e){return this.off(...e)}}}},278:(e,t,s)=>{const{basename:n,dirname:o,extname:r,join:i}=s(17),c=s(46),h=s(591),a=s(269),l=s(157),f=s(817),d=s(736),u=l("@flecks/core/flecks"),k=u.extend("silly"),p=Symbol.for("@flecks/core.hookPriority");t.So=Symbol.for("@flecks/core.byId"),t.Rn=Symbol.for("@flecks/core.byType");const g=e=>e.substring(0,1).toUpperCase()+e.substring(1),m=e=>e.split(/[_-]/).map(g).join(""),y=(e,t,s,n,o)=>class extends e{static get[s](){return t}static get[o](){return n}};t.MH=class{config={};$$expandedFlecksCache={};flecks={};$$gathered={};hooks={};constructor({config:e={},flecks:t={}}={}){const s=Object.fromEntries(Object.keys(t).map((e=>[e,{}])));this.config={...s,...e};const n=Object.entries(t);k("paths: %O",n.map((([e])=>e)));for(let e=0;e<n.length;e++){const[t,s]=n[e];this.registerFleckHooks(t,s),this.invoke("@flecks/core.registered",t,s)}this.configureFlecksDefaults(),k("config: %O",this.config)}configureFleckDefaults(e){this.config[e]={...this.invokeFleck("@flecks/core.config",e),...this.config[e]}}configureFlecksDefaults(){const e=this.flecksImplementing("@flecks/core.config");for(let t=0;t<e.length;t++)this.configureFleckDefaults(e[t])}static dasherizePath(e){const t=o(e).split("/");return"."===t[0]&&t.shift(),"index"===t[t.length-1]&&t.pop(),i(t.join("-"),n(e,r(e)))}static decorate(e,{transformer:t=m}={}){return(s,n)=>e.keys().reduce(((s,o)=>{const r=t(this.dasherizePath(o));if(!s[r])return s;const{default:i}=e(o);if("function"!=typeof i)throw new ReferenceError(`Flecks.decorate(): require(${o}).default is not a function (from: ${e.id})`);return{...s,[r]:i(s[r],n)}}),s)}async checkAndDecorateRawGathered(e,t,s){s(t,e);const n=await this.invokeComposedAsync(`${e}.decorate`,t);return s(n,`${e}.decorate`),n}destroy(){this.$$expandedFlecksCache={},this.config={},this.$$gathered={},this.hooks={},this.flecks={}}expandedFlecks(e){if(this.$$expandedFlecksCache[e])return[...this.$$expandedFlecksCache[e]];const t=this.lookupFlecks(e);let s=[];for(let e=0;e<t.length;++e){const n=t[e];s.push(n)}const n=s.findIndex((e=>"..."===e));if(-1!==n){if(-1!==s.slice(n+1).findIndex((e=>"..."===e)))throw new Error(`Illegal ordering specification: hook '${e}' has multiple ellipses.`);const t=s.slice(0,n),o=s.slice(n+1);s.splice(n,1);const r=[],i=this.flecksImplementing(e);for(let e=0;e<i.length;++e){const t=i[e];s.includes(t)||r.push(t)}const c=this.flecksHookGraph([...t,...r,...o],e),h=c.detectCycles();if(h.length>0)throw new Error(`Illegal ordering specification: hook '${e}' has positioning cycles: ${h.map((([e,t])=>`${e} <-> ${t}`)).join(", ")}`);s=[...t,...c.sort().filter((e=>!s.includes(e))),...o]}const o=this.flecksHookGraph(s,e);s.forEach(((e,t)=>{t<s.length-1&&o.addDependency(s[t+1],e)}));const r=o.detectCycles();return r.length>0&&r.forEach((([t,s])=>{const n=this.fleckImplementation(t,e),{before:o=[],after:r=[]}=n?.[p]||{},i=[e];o.includes(s)&&i.push(t,"before",s),r.includes(s)&&i.push(t,"after",s);const c=this.fleckImplementation(s,e),{before:h=[],after:a=[]}=c?.[p]||{};h.includes(t)&&i.push(s,"before",t),a.includes(t)&&i.push(s,"after",t),u("Suspicious ordering specification for '%s': '%s' expected to run %s '%s'!",...i)})),this.$$expandedFlecksCache[e]=s.filter((t=>this.fleckImplementation(t,e))),k("cached hook expansion for '%s': %O",e,s),[...this.$$expandedFlecksCache[e]]}fleck(e){return this.flecks[e]}fleckImplementation(e,t){if(!this.hooks[t])return;const s=this.hooks[t]?.find((({fleck:t})=>e===t));return s?s.fn:void 0}flecksImplementing(e){return this.hooks[e]?.map((({fleck:e})=>e))||[]}flecksHookGraph(e,t){const s=new f;return e.forEach((e=>{s.ensureTail(e);const n=this.fleckImplementation(e,t);n?.[p]&&(n[p].before&&n[p].before.forEach((t=>{s.addDependency(t,e)})),n[p].after&&n[p].after.forEach((t=>{s.addDependency(e,t)})))})),this.invoke("@flecks/core.priority",s,t),s}static async from(e){const{flecks:t}=e,s=Object.entries(t).map((([e,{mixin:t}])=>[e,t])).filter((([,e])=>e));k("mixins: %O",s.map((([e])=>e)));const n=new(a(...s.map((([,e])=>e)))(this))(e);return await n.gatherHooks(),await n.invokeSequentialAsync("@flecks/core.starting"),n}async gather(e,{idProperty:s="id",typeProperty:n="type",check:o=(()=>{})}={}){if(!e||"string"!=typeof e)throw new TypeError("Flecks.gather(): Expects parameter 1 (hook) to be string");const r=await this.invokeMergeAsync(e),i=await this.checkAndDecorateRawGathered(e,r,o);let c=1;const h={},a=Object.fromEntries(Object.entries(i).sort((([e],[t])=>e<t?-1:1)).map((([e,t])=>{const o=c++;return h[o]=y(t,o,s,e,n),[e,h[o]]}))),l={...h,...a,[t.So]:h,[t.Rn]:a};return this.$$gathered[e]={check:o,idProperty:s,typeProperty:n,gathered:l},u("gathered '%s': %O",e,Object.keys(l[t.Rn])),l}gathered(e){return this.$$gathered[e]?.gathered}async gatherHooks(){const e=await this.invokeAsync("@flecks/core.gathered");await Promise.all(Object.entries(e).map((([e,t])=>Promise.all(Object.entries(t).map((([t,s])=>this.gather(`${e}.${t}`,s)))))))}get(e,t){return c(this.config,e,t)}interpolate(e){return e.replace(/\[(.*?)\]/g,(e=>this.get(e)))}invoke(e,...t){return this.hooks[e]?this.flecksImplementing(e).reduce(((s,n)=>({...s,[n]:this.invokeFleck(e,n,...t)})),{}):{}}async invokeAsync(e,...t){return this.hooks[e]?this.flecksImplementing(e).reduce((async(s,n)=>({...await s,[n]:await this.invokeFleck(e,n,...t)})),{}):{}}invokeComposed(e,t,...s){return this.hooks[e]?this.expandedFlecks(e).reduce(((t,n)=>this.invokeFleck(e,n,t,...s)),t):t}async invokeComposedAsync(e,t,...s){return this.hooks[e]?this.expandedFlecks(e).reduce((async(t,n)=>this.invokeFleck(e,n,await t,...s)),t):t}invokeFlat(e,...t){return this.hooks[e]?this.hooks[e].map((({fleck:s})=>this.invokeFleck(e,s,...t))):[]}invokeFleck(e,t,...s){if(k("invokeFleck(%s, %s, ...)",e,t),!this.hooks[e])return;const n=this.hooks[e].find((({fleck:e})=>e===t));return n?n.fn(...s.concat(this)):void 0}static $$invokeMerge(e,t){return{...e,...t}}invokeMerge(e,...t){return this.invokeReduce(e,this.constructor.$$invokeMerge,{},...t)}async invokeMergeAsync(e,...t){return this.invokeReduceAsync(e,this.constructor.$$invokeMerge,{},...t)}static $$invokeMergeUnique(){const e={};return(t,s,n,o)=>{const r=Object.keys(s);for(let t=0;t<r.length;++t){const s=r[t];if(e[s])throw new ReferenceError(`Conflict in ${o}: '${e[s]}' implemented '${s}', followed by '${n}'`);e[s]=n}return{...t,...s}}}invokeMergeUnique(e,...t){return this.invokeReduce(e,this.constructor.$$invokeMergeUnique(),{},...t)}async invokeMergeUniqueAsync(e,...t){return this.invokeReduceAsync(e,this.constructor.$$invokeMergeUnique(),{},...t)}invokeReduce(e,t,s,...n){return this.hooks[e]?this.hooks[e].reduce(((s,{fleck:o})=>t(s,this.invokeFleck(e,o,...n),o,e)),s):s}async invokeReduceAsync(e,t,s,...n){return this.hooks[e]?this.hooks[e].reduce((async(s,{fleck:o})=>t(await s,await this.invokeFleck(e,o,...n),o,e)),s):s}invokeSequential(e,...t){if(!this.hooks[e])return[];const s=[],n=this.expandedFlecks(e);for(;n.length>0;){const o=n.shift();s.push(this.invokeFleck(e,o,...t))}return s}async invokeSequentialAsync(e,...t){if(!this.hooks[e])return[];const s=[],n=this.expandedFlecks(e);for(;n.length>0;){const o=n.shift();s.push(await this.invokeFleck(e,o,...t))}return s}lookupFlecks(e){const t=e.indexOf(".");return-1===t?["..."]:this.get([e.slice(0,t),e.slice(t+1)],["..."])}makeMiddleware(e){if(k("makeMiddleware(...): %s",e),!this.hooks[e])return(...e)=>e.pop()();const t=this.expandedFlecks(e);if(0===t.length)return(...e)=>e.pop()();k("middleware: %O",t);const s=new d(t.map((t=>this.invokeFleck(e,t))));return s.dispatch.bind(s)}static priority(e,t={}){const s={};return t.after&&(s.after=Array.isArray(t.after)?t.after:[t.after]),t.before&&(s.before=Array.isArray(t.before)?t.before:[t.before]),e[p]=s,e}static provide(e,{invoke:t=!0,transformer:s=m}={}){return n=>Object.fromEntries(e.keys().map((o=>{const{default:r}=e(o);if(t&&"function"!=typeof r)throw new ReferenceError(`Flecks.provide(): require(${o}).default is not a function (from: ${e.id})`);return[s(this.dasherizePath(o)),t?r(n):r]})))}refresh(e,t){u("refreshing %s...",e),this.unregisterFleckHooks(e),this.registerFleckHooks(e,t),this.configureFleckDefaults(e),this.refreshGathered(e)}async refreshGathered(e){await Promise.all(Object.entries(this.$$gathered).map((async([s,{check:n,idProperty:o,gathered:r,typeProperty:i}])=>{let c;if(this.fleckImplementation(e,`${s}.decorate`)?(c=await this.invokeMergeAsync(s),k("%s implements %s.decorate",e,s)):this.fleckImplementation(e,s)&&(c=await this.invokeFleck(s,e),k("%s implements %s",e,s)),c){const h=await this.checkAndDecorateRawGathered(s,c,n);u("updating gathered %s from %s...",s,e),k("%O",h),Object.entries(h).forEach((([e,n])=>{const{[e]:{[o]:c}}=r,h=y(n,c,o,e,i);r[e]=h,r[c]=h,r[t.So][c]=h,r[t.Rn][e]=h,this.invoke("@flecks/core.hmr.gathered.class",h,s)})),this.invoke("@flecks/core.hmr.gathered",r,s)}})))}registerFleckHooks(e,t){if(k("registering %s...",e),this.flecks[e]=t,t.hooks){const s=Object.keys(t.hooks);k("hooks for '%s': %O",e,s);for(let n=0;n<s.length;n++){const o=s[n];if(this.hooks[o]||(this.hooks[o]=[]),"function"!=typeof t.hooks[o])throw new TypeError(`Hook implementation must be a function! ('${e}' implementing '${o}')`);this.hooks[o].push({fleck:e,fn:t.hooks[o]})}}}set(e,t){return h(this.config,e,t)}unregisterFleckHooks(e){const t=Object.keys(this.hooks);for(let s=0;s<t.length;s++){const n=t[s];if(this.hooks[n]){const t=this.hooks[n].findIndex((({fleck:t})=>t===e));-1!==t&&this.hooks[n].splice(t,1)}}}},t.MH.get=c,t.MH.set=h},736:e=>{e.exports=class{constructor(e=[]){this.middleware=[];for(let t=0;t<e.length;++t)this.middleware.push(this.constructor.check(e[t]))}static check(e){if("function"!=typeof e){if(void 0!==e.then)throw new TypeError("middleware expected a function, looks like a promise");throw new TypeError("middleware expected a function")}return e}dispatch(...e){const t=e.pop(),s=this.middleware.concat(),n=o=>{if(s.length>0){const t=s.shift();if(e.length+2===t.length==!o)n(o);else try{t(...e.concat(o?[o]:[]).concat(n))}catch(o){n(o)}}else t&&setTimeout((()=>t(o)),0)};n()}promise(...e){return new Promise(((t,s)=>{this.dispatch(...e.concat((e=>{e?s(e):t()})))}))}use(e){this.middleware.push(this.constructor.check(e))}}},17:e=>{"use strict";e.exports=require("path")},999:t=>{"use strict";t.exports=e},46:e=>{"use strict";e.exports=t},591:e=>{"use strict";e.exports=s}},o={};function r(e){var t=o[e];if(void 0!==t)return t.exports;var s=o[e]={exports:{}};return n[e](s,s.exports,r),s.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{"use strict";r.r(i),r.d(i,{ById:()=>l.So,ByType:()=>l.Rn,Class:()=>t.a,D:()=>c.a,EventEmitter:()=>a.a,Flecks:()=>l.MH,compose:()=>n.a,hooks:()=>f});var e=r(305),t=r.n(e),s=r(269),n=r.n(s),o=r(157),c=r.n(o),h=r(848),a=r.n(h),l=r(278),f={"@flecks/web.config":async(e,t)=>({id:t.get("@flecks/core.id")})}})(),i})())); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@flecks/core", | ||
"version": "3.1.3", | ||
"version": "3.1.4", | ||
"author": "cha0s", | ||
@@ -22,9 +22,4 @@ "license": "MIT", | ||
"files": [ | ||
"build", | ||
"index.js", | ||
"index.js.map", | ||
"server.js", | ||
"server.js.map", | ||
"src", | ||
"test" | ||
"server.js" | ||
], | ||
@@ -61,3 +56,3 @@ "dependencies": { | ||
"globals": "^13.23.0", | ||
"mocha": "^8.3.2", | ||
"mocha": "^7.0.0", | ||
"rimraf": "^3.0.2", | ||
@@ -69,2 +64,2 @@ "source-map-loader": "4.0.1", | ||
} | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
5
2
20347
4
67