Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@flecks/core

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flecks/core - npm Package Compare versions

Comparing version 4.0.5 to 4.1.0

build/testing.js

4

build/add-paths-to-yml.js

@@ -1,2 +0,2 @@

const {readFile, writeFile} = require('fs/promises');
const {readFile} = require('fs/promises');
const {join} = require('path');

@@ -6,2 +6,4 @@

const {writeFile} = require('../src/server/fs');
const {

@@ -8,0 +10,0 @@ FLECKS_CORE_ROOT = process.cwd(),

// eslint-disable-next-line max-classes-per-file
const {Buffer} = require('buffer');
const {dump: dumpYml, load: loadYml} = require('js-yaml');
const JsonParse = require('jsonparse');
const {Transform} = require('stream');
const {Transform, Writable} = require('stream');

@@ -48,2 +49,29 @@ exports.JsonStream = class JsonStream extends Transform {

exports.pipesink = (streamsOrStream) => {
const streams = Array.isArray(streamsOrStream) ? streamsOrStream : [streamsOrStream];
class Sink extends Writable {
constructor() {
super();
this.buffers = [];
}
// eslint-disable-next-line no-underscore-dangle
_write(chunk, encoding, done) {
this.buffers.push(chunk);
done();
}
}
const sink = new Sink();
const final = streams.reduce((output, input) => input.pipe(output));
return new Promise((resolve, reject) => {
final.pipe(sink);
final.on('error', reject);
final.on('end', () => {
resolve(Buffer.concat(sink.buffers));
});
});
};
exports.YamlStream = class YamlStream extends Transform {

@@ -50,0 +78,0 @@

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("debug"),require("lodash.get"),require("set-value")):"function"==typeof define&&define.amd?define("@flecks/core",["debug","lodash.get","set-value"],t):"object"==typeof exports?exports["@flecks/core"]=t(require("debug"),require("lodash.get"),require("set-value")):e["@flecks/core"]=t(e.debug,e["lodash.get"],e["set-value"])}(global,((e,t,s)=>{return r={740:(e,t,s)=>{function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=s[r])}return e},r.apply(this,arguments)}var{join:o}=s(72),{FLECKS_CORE_ROOT:n=process.cwd()}=process.env;e.exports=r(r({Class:s(244),compose:s(596),D:s(816),EventEmitter:s(824)},s(664)),{},{hooks:{"@flecks/core.hmr":(e,t,s)=>{e===o(n,"build","flecks.yml")&&Object.entries(s.constructor.dealiasedConfig(t)).forEach((e=>{var[t,r]=e;if(JSON.stringify(s.originalConfig[t])!==JSON.stringify(r)){for(var o=s.flecksImplementing("@flecks/core.reload"),n=0;n<o.length;++n)try{s.invokeFleck("@flecks/core.reload",o[n],t,r)}catch(e){throw new Error("'".concat(t,"' aborted reload: ").concat(e.name,": ").concat(e.message))}s.originalConfig[t]=r,s.configureFleckDefaults(t)}}))},"@flecks/web.config":async(e,t)=>({id:t.get("@flecks/core.id")})}})},244:e=>{e.exports=class{}},596:e=>{e.exports=function(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...s)=>e(t(...s))))}},816:(e,t,s)=>{const r=s(856),{VSCODE_INSPECTOR_OPTIONS:o}=process.env;e.exports=e=>{{if(o){const{formatArgs:e}=r;r.formatArgs=function(t){const{useColors:s}=this;t[0].match(/%[oO]/)&&(this.useColors=!1),e.call(this,t),this.useColors=s},r.formatters.o=void 0,r.formatters.O=void 0}const e="web"===process.env.FLECKS_CORE_BUILD_TARGET?"debug":"error";r.log=console[e].bind(console)}return r(e)}},568: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,r=o=>{if(!t.has(o)){t.add(o),s.add(o);const n=this.neighbors(o);for(let i=n.next();!0!==i.done;i=n.next()){const{value:n}=i;t.has(n)?s.has(n)&&e.push([o,n]):r(n)}}s.delete(o)},{tails:o}=this;for(let e=o.next();!0!==e.done;e=o.next())r(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=(r,o)=>{e.add(r);const n=this.neighbors(r);for(let t=n.next();!0!==t.done;t=n.next()){const{value:r}=t;e.has(r)||(o=s(r,o))}return t.set(r,o),o-1};let r=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)||(r=s(o,r))}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()}}},824: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:r,type:o,fn:n,bound:i,that:c}=e[s];r&&this.offSingleEvent(o,n),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]):n.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,r){const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++)this.onSingleEvent(o[e],t,s,r)}once(e,t,s=void 0){return this.$$on(e,t,s,!0),this}onSingleEvent(e,t,s,r){if("function"!=typeof t)throw new TypeError("EventEmitter::onSingleEvent() requires function listener");const o=((e,t,s,r)=>({fn:e,that:t,type:s,once:r,bound:t?e.bind(t):e}))(t,s,e,r);e in this.$$events||(this.$$events[e]=[]),this.$$events[e].push(o)}removeListener(...e){return this.off(...e)}}}},664:(e,t,s)=>{const{basename:r,dirname:o,extname:n,join:i}=s(72),c=s(376),h=s(672),a=s(596),l=s(816),f=s(568),u=s(108),d=l("@flecks/core/flecks"),k=d.extend("silly"),p=Symbol.for("@flecks/core.hookPriority");t.ById=Symbol.for("@flecks/core.byId"),t.ByType=Symbol.for("@flecks/core.byType");const g=e=>e.substring(0,1).toUpperCase()+e.substring(1),y=e=>e.split(/[_-]/).map(g).join(""),m=(e,t,s,r,o)=>class extends e{static get[s](){return t}static get[o](){return r}};class v{config={};$$expandedFlecksCache={};flecks={};$$gathered={};hooks={};constructor({bootstrappedConfig:e={},config:t={},flecks:s={}}={}){this.bootstrappedConfig=JSON.parse(JSON.stringify(e)),this.originalConfig=JSON.parse(JSON.stringify(t)),this.config={};const r=Object.entries(s);this.constructor.debugSilly("paths: %O",r.map((([e])=>e)));for(let e=0;e<r.length;e++){const[t,s]=r[e];this.registerFleckHooks(t,s),this.invoke("@flecks/core.registered",t,s)}this.configureFlecksDefaults(),this.constructor.debugSilly("config: %O",this.config)}configureFleckDefaults(e){this.config[e]={...this.bootstrappedConfig[e],...this.invokeFleck("@flecks/core.config",e),...this.originalConfig[e]}}configureFlecksDefaults(){const e=Object.keys(this.flecks);for(let t=0;t<e.length;t++)this.configureFleckDefaults(e[t]);[].concat([this.bootstrappedConfig,this.originalConfig].map(Object.keys)).flat().forEach((e=>{this.config[e]={...this.bootstrappedConfig[e],...this.originalConfig[e],...this.config[e]}}))}static dasherizePath(e){const t=o(e).split("/");return"."===t[0]&&t.shift(),"index"===t[t.length-1]&&t.pop(),i(t.join("-"),r(e,n(e)))}static dealiasedConfig(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>{const s=e.indexOf(":");return[-1===s?e:e.slice(0,s),t]})))}static decorate(e,{transformer:t=y}={}){return(s,r)=>e.keys().reduce(((s,o)=>{const n=t(this.dasherizePath(o));if(!s[n])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,[n]:i(s[n],r)}}),s)}async checkAndDecorateRawGathered(e,t,s){s(t,e);const r=await this.invokeComposedAsync(`${e}.decorate`,t);return s(r,`${e}.decorate`),r}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 r=t[e];s.push(r)}const r=s.findIndex((e=>"..."===e));if(-1!==r){if(-1!==s.slice(r+1).findIndex((e=>"..."===e)))throw new Error(`Illegal ordering specification: hook '${e}' has multiple ellipses.`);const t=s.slice(0,r),o=s.slice(r+1);s.splice(r,1);const n=[],i=this.flecksImplementing(e);for(let e=0;e<i.length;++e){const t=i[e];s.includes(t)||n.push(t)}const c=this.flecksHookGraph([...t,...n,...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 n=o.detectCycles();return n.length>0&&n.forEach((([t,s])=>{const r=this.fleckImplementation(t,e),{before:o=[],after:n=[]}=r?.[p]||{},i=[e];o.includes(s)&&i.push(t,"before",s),n.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),this.constructor.debug("Suspicious ordering specification for '%s': '%s' expected to run %s '%s'!",...i)})),this.$$expandedFlecksCache[e]=s.filter((t=>this.fleckImplementation(t,e))),this.constructor.debugSilly("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 r=this.fleckImplementation(e,t);r?.[p]&&(r[p].before&&r[p].before.forEach((t=>{s.addDependency(t,e)})),r[p].after&&r[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));this.debugSilly("mixins: %O",s.map((([e])=>e)));const r=new(a(...s.map((([,e])=>e)))(this))(e);return await r.gatherHooks(),await r.invokeSequentialAsync("@flecks/core.starting"),r}async gather(e,{idProperty:s="id",typeProperty:r="type",check:o=(()=>{})}={}){if(!e||"string"!=typeof e)throw new TypeError("Flecks.gather(): Expects parameter 1 (hook) to be string");const n=await this.invokeMergeAsync(e),i=await this.checkAndDecorateRawGathered(e,n,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]=m(t,o,s,e,r),[e,h[o]]}))),l={...h,...a,[t.ById]:h,[t.ByType]:a};return this.$$gathered[e]={check:o,idProperty:s,typeProperty:r,gathered:l},this.constructor.debug("gathered '%s': %O",e,Object.keys(l[t.ByType])),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,r)=>({...s,[r]:this.invokeFleck(e,r,...t)})),{}):{}}async invokeAsync(e,...t){return this.hooks[e]?this.flecksImplementing(e).reduce((async(s,r)=>({...await s,[r]:await this.invokeFleck(e,r,...t)})),{}):{}}invokeComposed(e,t,...s){return this.hooks[e]?this.expandedFlecks(e).reduce(((t,r)=>this.invokeFleck(e,r,t,...s)),t):t}async invokeComposedAsync(e,t,...s){return this.hooks[e]?this.expandedFlecks(e).reduce((async(t,r)=>this.invokeFleck(e,r,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(this.constructor.debugSilly("invokeFleck(%s, %s, ...)",e,t),!this.hooks[e])return;const r=this.hooks[e].find((({fleck:e})=>e===t));return r?r.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,r,o)=>{const n=Object.keys(s);for(let t=0;t<n.length;++t){const s=n[t];if(e[s])throw new ReferenceError(`Conflict in ${o}: '${e[s]}' implemented '${s}', followed by '${r}'`);e[s]=r}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,...r){return this.hooks[e]?this.hooks[e].reduce(((s,{fleck:o})=>t(s,this.invokeFleck(e,o,...r),o,e)),s):s}async invokeReduceAsync(e,t,s,...r){return this.hooks[e]?this.hooks[e].reduce((async(s,{fleck:o})=>t(await s,await this.invokeFleck(e,o,...r),o,e)),s):s}invokeSequential(e,...t){if(!this.hooks[e])return[];const s=[],r=this.expandedFlecks(e);for(;r.length>0;){const o=r.shift();s.push(this.invokeFleck(e,o,...t))}return s}async invokeSequentialAsync(e,...t){if(!this.hooks[e])return[];const s=[],r=this.expandedFlecks(e);for(;r.length>0;){const o=r.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(this.constructor.debugSilly("makeMiddleware(...): %s",e),!this.hooks[e])return(...e)=>e.pop()();const t=this.expandedFlecks(e);if(0===t.length)return(...e)=>e.pop()();this.constructor.debugSilly("middleware: %O",t);const s=new u(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=y}={}){return r=>Object.fromEntries(e.keys().map((o=>{const{default:n}=e(o);if(t&&"function"!=typeof n)throw new ReferenceError(`Flecks.provide(): require(${o}).default is not a function (from: ${e.id})`);return[s(this.dasherizePath(o)),t?n(r):n]})))}refresh(e,t){this.constructor.debug("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:r,idProperty:o,gathered:n,typeProperty:i}])=>{let c;if(this.fleckImplementation(e,`${s}.decorate`)?(c=await this.invokeMergeAsync(s),this.constructor.debugSilly("%s implements %s.decorate",e,s)):this.fleckImplementation(e,s)&&(c=await this.invokeFleck(s,e),this.constructor.debugSilly("%s implements %s",e,s)),c){const h=await this.checkAndDecorateRawGathered(s,c,r);this.constructor.debug("updating gathered %s from %s...",s,e),this.constructor.debugSilly("%O",h),Object.entries(h).forEach((([e,r])=>{const{[e]:{[o]:c}}=n,h=m(r,c,o,e,i);n[e]=h,n[c]=h,n[t.ById][c]=h,n[t.ByType][e]=h,this.invoke("@flecks/core.hmr.gathered.class",h,s)})),this.invoke("@flecks/core.hmr.gathered",n,s)}})))}registerFleckHooks(e,t){if(this.constructor.debugSilly("registering %s...",e),this.flecks[e]=t,t.hooks){const s=Object.keys(t.hooks);this.constructor.debugSilly("hooks for '%s': %O",e,s);for(let r=0;r<s.length;r++){const o=s[r];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]})}}}unregisterFleckHooks(e){const t=Object.keys(this.hooks);for(let s=0;s<t.length;s++){const r=t[s];if(this.hooks[r]){const t=this.hooks[r].findIndex((({fleck:t})=>t===e));-1!==t&&this.hooks[r].splice(t,1)}}}}v.debug=d,v.debugSilly=k,v.get=c,v.set=h,t.Flecks=v},108: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(),r=o=>{if(s.length>0){const t=s.shift();if(e.length+2===t.length==!o)r(o);else try{t(...e.concat(o?[o]:[]).concat(r))}catch(o){r(o)}}else t&&setTimeout((()=>t(o)),0)};r()}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))}}},72:e=>{"use strict";e.exports=require("path")},856:t=>{"use strict";t.exports=e},376:e=>{"use strict";e.exports=t},672:e=>{"use strict";e.exports=s}},o={},function e(t){var s=o[t];if(void 0!==s)return s.exports;var n=o[t]={exports:{}};return r[t](n,n.exports,e),n.exports}(740);var r,o}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("debug"),require("lodash.get"),require("set-value")):"function"==typeof define&&define.amd?define("@flecks/core",["debug","lodash.get","set-value"],t):"object"==typeof exports?exports["@flecks/core"]=t(require("debug"),require("lodash.get"),require("set-value")):e["@flecks/core"]=t(e.debug,e["lodash.get"],e["set-value"])}(global,((e,t,s)=>{return r={740:(e,t,s)=>{function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=s[r])}return e},r.apply(this,arguments)}var{join:o}=s(72),{FLECKS_CORE_ROOT:n=process.cwd()}=process.env;e.exports=r(r({Class:s(244),compose:s(596),D:s(816),EventEmitter:s(824)},s(664)),{},{hooks:{"@flecks/core.hmr":(e,t,s)=>{if(e===o(n,"build","flecks.yml")){var r=s.constructor.dealiasedConfig(t);if(JSON.stringify(Object.keys(s.originalConfig).sort())!==JSON.stringify(Object.keys(r).sort()))throw new Error("build manifest keys changed!");Object.entries(r).forEach((e=>{var[t,r]=e;if(JSON.stringify(s.originalConfig[t])!==JSON.stringify(r)){for(var o=s.flecksImplementing("@flecks/core.reload"),n=0;n<o.length;++n)try{s.invokeFleck("@flecks/core.reload",o[n],t,r)}catch(e){throw new Error("'".concat(t,"' aborted reload: ").concat(e.name,": ").concat(e.message))}s.originalConfig[t]=r,s.configureFleckDefaults(t)}}))}},"@flecks/web.config":async(e,t)=>({id:t.get("@flecks/core.id")})}})},244:e=>{e.exports=class{}},596:e=>{e.exports=function(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...s)=>e(t(...s))))}},816:(e,t,s)=>{const r=s(856),{VSCODE_INSPECTOR_OPTIONS:o}=process.env;e.exports=e=>{{if(o){const{formatArgs:e}=r;r.formatArgs=function(t){const{useColors:s}=this;t[0].match(/%[oO]/)&&(this.useColors=!1),e.call(this,t),this.useColors=s},r.formatters.o=void 0,r.formatters.O=void 0}const e="web"===process.env.FLECKS_CORE_BUILD_TARGET?"debug":"error";r.log=console[e].bind(console)}return r(e)}},568: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,r=o=>{if(!t.has(o)){t.add(o),s.add(o);const n=this.neighbors(o);for(let i=n.next();!0!==i.done;i=n.next()){const{value:n}=i;t.has(n)?s.has(n)&&e.push([o,n]):r(n)}}s.delete(o)},{tails:o}=this;for(let e=o.next();!0!==e.done;e=o.next())r(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=(r,o)=>{e.add(r);const n=this.neighbors(r);for(let t=n.next();!0!==t.done;t=n.next()){const{value:r}=t;e.has(r)||(o=s(r,o))}return t.set(r,o),o-1};let r=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)||(r=s(o,r))}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()}}},824: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:r,type:o,fn:n,bound:i,that:c}=e[s];r&&this.offSingleEvent(o,n),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]):n.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,r){const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++)this.onSingleEvent(o[e],t,s,r)}once(e,t,s=void 0){return this.$$on(e,t,s,!0),this}onSingleEvent(e,t,s,r){if("function"!=typeof t)throw new TypeError("EventEmitter::onSingleEvent() requires function listener");const o=((e,t,s,r)=>({fn:e,that:t,type:s,once:r,bound:t?e.bind(t):e}))(t,s,e,r);e in this.$$events||(this.$$events[e]=[]),this.$$events[e].push(o)}removeListener(...e){return this.off(...e)}}}},664:(e,t,s)=>{const{basename:r,dirname:o,extname:n,join:i}=s(72),c=s(376),h=s(672),a=s(596),l=s(816),f=s(568),u=s(108),d=l("@flecks/core/flecks"),k=d.extend("silly"),p=Symbol.for("@flecks/core.hookPriority");t.ById=Symbol.for("@flecks/core.byId"),t.ByType=Symbol.for("@flecks/core.byType");const g=e=>e.substring(0,1).toUpperCase()+e.substring(1),y=e=>e.split(/[_-]/).map(g).join(""),m=(e,t,s,r,o)=>class extends e{static get[s](){return t}static get[o](){return r}};class v{config={};$$expandedFlecksCache={};flecks={};$$gathered={};hooks={};constructor({bootstrappedConfig:e={},config:t={},flecks:s={}}={}){this.bootstrappedConfig=JSON.parse(JSON.stringify(e)),this.originalConfig=JSON.parse(JSON.stringify(t)),this.config={};const r=Object.entries(s);this.constructor.debugSilly("paths: %O",r.map((([e])=>e)));for(let e=0;e<r.length;e++){const[t,s]=r[e];this.registerFleckHooks(t,s),this.invoke("@flecks/core.registered",t,s)}this.configureFlecksDefaults(),this.constructor.debugSilly("config: %O",this.config)}configureFleckDefaults(e){this.config[e]={...this.bootstrappedConfig[e],...this.invokeFleck("@flecks/core.config",e),...this.originalConfig[e]}}configureFlecksDefaults(){const e=Object.keys(this.flecks);for(let t=0;t<e.length;t++)this.configureFleckDefaults(e[t]);[].concat([this.bootstrappedConfig,this.originalConfig].map(Object.keys)).flat().forEach((e=>{this.config[e]={...this.bootstrappedConfig[e],...this.originalConfig[e],...this.config[e]}}))}static dasherizePath(e){const t=o(e).split("/");return"."===t[0]&&t.shift(),"index"===t[t.length-1]&&t.pop(),i(t.join("-"),r(e,n(e)))}static dealiasedConfig(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>{const s=e.indexOf(":");return[-1===s?e:e.slice(0,s),t]})))}static decorate(e,{transformer:t=y}={}){return(s,r)=>e.keys().reduce(((s,o)=>{const n=t(this.dasherizePath(o));if(!s[n])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,[n]:i(s[n],r)}}),s)}async checkAndDecorateRawGathered(e,t,s){s(t,e);const r=await this.invokeComposedAsync(`${e}.decorate`,t);return s(r,`${e}.decorate`),r}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 r=t[e];s.push(r)}const r=s.findIndex((e=>"..."===e));if(-1!==r){if(-1!==s.slice(r+1).findIndex((e=>"..."===e)))throw new Error(`Illegal ordering specification: hook '${e}' has multiple ellipses.`);const t=s.slice(0,r),o=s.slice(r+1);s.splice(r,1);const n=[],i=this.flecksImplementing(e);for(let e=0;e<i.length;++e){const t=i[e];s.includes(t)||n.push(t)}const c=this.flecksHookGraph([...t,...n,...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 n=o.detectCycles();return n.length>0&&n.forEach((([t,s])=>{const r=this.fleckImplementation(t,e),{before:o=[],after:n=[]}=r?.[p]||{},i=[e];o.includes(s)&&i.push(t,"before",s),n.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),this.constructor.debug("Suspicious ordering specification for '%s': '%s' expected to run %s '%s'!",...i)})),this.$$expandedFlecksCache[e]=s.filter((t=>this.fleckImplementation(t,e))),this.constructor.debugSilly("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 r=this.fleckImplementation(e,t);r?.[p]&&(r[p].before&&r[p].before.forEach((t=>{s.addDependency(t,e)})),r[p].after&&r[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));this.debugSilly("mixins: %O",s.map((([e])=>e)));const r=new(a(...s.map((([,e])=>e)))(this))(e);return await r.gatherHooks(),await r.invokeSequentialAsync("@flecks/core.starting"),r}async gather(e,{idProperty:s="id",typeProperty:r="type",check:o=(()=>{})}={}){if(!e||"string"!=typeof e)throw new TypeError("Flecks.gather(): Expects parameter 1 (hook) to be string");const n=await this.invokeMergeAsync(e),i=await this.checkAndDecorateRawGathered(e,n,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]=m(t,o,s,e,r),[e,h[o]]}))),l={...h,...a,[t.ById]:h,[t.ByType]:a};return this.$$gathered[e]={check:o,idProperty:s,typeProperty:r,gathered:l},this.constructor.debug("gathered '%s': %O",e,Object.keys(l[t.ByType])),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,r)=>({...s,[r]:this.invokeFleck(e,r,...t)})),{}):{}}async invokeAsync(e,...t){return this.hooks[e]?this.flecksImplementing(e).reduce((async(s,r)=>({...await s,[r]:await this.invokeFleck(e,r,...t)})),{}):{}}invokeComposed(e,t,...s){return this.hooks[e]?this.expandedFlecks(e).reduce(((t,r)=>this.invokeFleck(e,r,t,...s)),t):t}async invokeComposedAsync(e,t,...s){return this.hooks[e]?this.expandedFlecks(e).reduce((async(t,r)=>this.invokeFleck(e,r,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(this.constructor.debugSilly("invokeFleck(%s, %s, ...)",e,t),!this.hooks[e])return;const r=this.hooks[e].find((({fleck:e})=>e===t));return r?r.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,r,o)=>{const n=Object.keys(s);for(let t=0;t<n.length;++t){const s=n[t];if(e[s])throw new ReferenceError(`Conflict in ${o}: '${e[s]}' implemented '${s}', followed by '${r}'`);e[s]=r}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,...r){return this.hooks[e]?this.hooks[e].reduce(((s,{fleck:o})=>t(s,this.invokeFleck(e,o,...r),o,e)),s):s}async invokeReduceAsync(e,t,s,...r){return this.hooks[e]?this.hooks[e].reduce((async(s,{fleck:o})=>t(await s,await this.invokeFleck(e,o,...r),o,e)),s):s}invokeSequential(e,...t){if(!this.hooks[e])return[];const s=[],r=this.expandedFlecks(e);for(;r.length>0;){const o=r.shift();s.push(this.invokeFleck(e,o,...t))}return s}async invokeSequentialAsync(e,...t){if(!this.hooks[e])return[];const s=[],r=this.expandedFlecks(e);for(;r.length>0;){const o=r.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(this.constructor.debugSilly("makeMiddleware(...): %s",e),!this.hooks[e])return(...e)=>e.pop()();const t=this.expandedFlecks(e);if(0===t.length)return(...e)=>e.pop()();this.constructor.debugSilly("middleware: %O",t);const s=new u(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=y}={}){return r=>Object.fromEntries(e.keys().map((o=>{const{default:n}=e(o);if(t&&"function"!=typeof n)throw new ReferenceError(`Flecks.provide(): require(${o}).default is not a function (from: ${e.id})`);return[s(this.dasherizePath(o)),t?n(r):n]})))}refresh(e,t){this.constructor.debug("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:r,idProperty:o,gathered:n,typeProperty:i}])=>{let c;if(this.fleckImplementation(e,`${s}.decorate`)?(c=await this.invokeMergeAsync(s),this.constructor.debugSilly("%s implements %s.decorate",e,s)):this.fleckImplementation(e,s)&&(c=await this.invokeFleck(s,e),this.constructor.debugSilly("%s implements %s",e,s)),c){const h=await this.checkAndDecorateRawGathered(s,c,r);this.constructor.debug("updating gathered %s from %s...",s,e),this.constructor.debugSilly("%O",h),Object.entries(h).forEach((([e,r])=>{const{[e]:{[o]:c}}=n,h=m(r,c,o,e,i);n[e]=h,n[c]=h,n[t.ById][c]=h,n[t.ByType][e]=h,this.invoke("@flecks/core.hmr.gathered.class",h,s)})),this.invoke("@flecks/core.hmr.gathered",n,s)}})))}registerFleckHooks(e,t){if(this.constructor.debugSilly("registering %s...",e),this.flecks[e]=t,t.hooks){const s=Object.keys(t.hooks);this.constructor.debugSilly("hooks for '%s': %O",e,s);for(let r=0;r<s.length;r++){const o=s[r];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]})}}}unregisterFleckHooks(e){const t=Object.keys(this.hooks);for(let s=0;s<t.length;s++){const r=t[s];if(this.hooks[r]){const t=this.hooks[r].findIndex((({fleck:t})=>t===e));-1!==t&&this.hooks[r].splice(t,1)}}}}v.debug=d,v.debugSilly=k,v.get=c,v.set=h,t.Flecks=v},108: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(),r=o=>{if(s.length>0){const t=s.shift();if(e.length+2===t.length==!o)r(o);else try{t(...e.concat(o?[o]:[]).concat(r))}catch(o){r(o)}}else t&&setTimeout((()=>t(o)),0)};r()}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))}}},72:e=>{"use strict";e.exports=require("path")},856:t=>{"use strict";t.exports=e},376:e=>{"use strict";e.exports=t},672:e=>{"use strict";e.exports=s}},o={},function e(t){var s=o[t];if(void 0!==s)return s.exports;var n=o[t]={exports:{}};return r[t](n,n.exports,e),n.exports}(740);var r,o}));
//# sourceMappingURL=index.js.map
{
"name": "@flecks/core",
"version": "4.0.5",
"version": "4.1.0",
"author": "cha0s",
"license": "MIT",
"scripts": {
"build": "webpack --config ./build/core.webpack.config.js --mode production",
"clean": "rm -rf dist node_modules yarn.lock",
"lint": "eslint --config ./build/core.eslint.config.js .",
"postversion": "npm run build",
"test": "webpack --config ./build/test.webpack.config.js --mode production && mocha --colors --parallel ./dist/test/*.js ./dist/test/server/*.js",
"test:watch": "webpack watch --config ./build/test.webpack.config.js --mode development & mocha --colors --parallel --watch --watch-files ./dist/test/*.js ./dist/test/server/*.js"
"build": "flecks build",
"clean": "flecks clean",
"lint": "flecks lint",
"test": "flecks test"
},

@@ -14,0 +12,0 @@ "repository": {

@@ -1,2 +0,2 @@

!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("debug"),require("glob"),require("js-yaml"),require("jsonparse")):"function"==typeof define&&define.amd?define("@flecks/core",["debug","glob","js-yaml","jsonparse"],r):"object"==typeof exports?exports["@flecks/core"]=r(require("debug"),require("glob"),require("js-yaml"),require("jsonparse")):e["@flecks/core"]=r(e.debug,e.glob,e["js-yaml"],e.jsonparse)}(global,((__WEBPACK_EXTERNAL_MODULE__856__,__WEBPACK_EXTERNAL_MODULE__488__,__WEBPACK_EXTERNAL_MODULE__380__,__WEBPACK_EXTERNAL_MODULE__728__)=>(()=>{var __webpack_modules__={24:(e,r,s)=>{function t(){return t=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var s=arguments[r];for(var t in s)Object.prototype.hasOwnProperty.call(s,t)&&(e[t]=s[t])}return e},t.apply(this,arguments)}var{dump:n,load:a}=s(380);e.exports=t(t(t({dumpYml:n,glob:s(488).glob,loadYml:a},s(968)),s(484)),s(524))},484:(e,r,s)=>{var{processCode:t,spawnWith:n}=s(524),{npm_config_user_agent:a="npm"}=process.env;r.inferPackageManager=()=>a.split("/")[0],r.build=async e=>{var s,{cwd:a,packageManager:o=r.inferPackageManager()}=e;switch(o){case"bun":s=["bun","run","build"];break;case"npm":s=["npm","run","build"];break;case"pnpm":s=["pnpm","run","build"];break;case"yarn":s=["yarn","run","build"]}return s&&t(n(s,{cwd:a}))},r.add=async e=>{var s,{dev:a,packageManager:o=r.inferPackageManager(),packages:i}=e;switch(o){case"bun":s=["bun","add",...a?["--dev"]:[],...i];break;case"npm":s=["npm","install",...a?["--save-dev"]:[],...i];break;case"pnpm":s=["pnpm","add",...a?["--save-dev"]:[],...i];break;case"yarn":s=["yarn","add",...a?["--dev"]:[],...i]}return s&&t(n(s))},r.install=async e=>{var s,{cwd:a,packageManager:o=r.inferPackageManager()}=e;switch(o){case"bun":s=["bun","install"];break;case"npm":s=["npm","install"];break;case"pnpm":s=["pnpm","install"];break;case"yarn":s=["yarn","install"]}return s&&t(n(s,{cwd:a}))},r.lockFile=function(e){switch(void 0===e&&(e=r.inferPackageManager()),e){case"bun":return"bun.lockb";case"npm":return"package-lock.json";case"pnpm":return"pnpm-lock.yaml";case"yarn":return"yarn.lock";default:return""}}},524:(__unused_webpack_module,exports,__webpack_require__)=>{var _excluded=["useFork"];function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var s=arguments[r];for(var t in s)Object.prototype.hasOwnProperty.call(s,t)&&(e[t]=s[t])}return e},_extends.apply(this,arguments)}function _objectWithoutPropertiesLoose(e,r){if(null==e)return{};var s,t,n={},a=Object.keys(e);for(t=0;t<a.length;t++)s=a[t],r.indexOf(s)>=0||(n[s]=e[s]);return n}var{fork,spawn}=__webpack_require__(368),{access,constants:{X_OK},realpath}=__webpack_require__(392),{dirname,join,sep}=__webpack_require__(72),D=__webpack_require__(816),debug=D("@flecks/core/server"),debugSilly=debug.extend("silly"),{FLECKS_CORE_ROOT=process.cwd()}=process.env;exports.binaryPath=async function(binary,root){void 0===root&&(root=FLECKS_CORE_ROOT);for(var resolved=dirname(await realpath(eval("require").resolve(join(root,"package.json")))),parts=resolved.split(sep);parts.length>0;){var path=parts.concat(join("node_modules",".bin",binary)).join(sep);try{return await access(path,X_OK),path}catch(e){parts.pop()}}throw new Error("Binary '".concat(binary,"' not found! (root: ").concat(root,")"))},exports.processCode=e=>new Promise(((r,s)=>{e.on("error",s),e.on("exit",(t=>{e.off("error",s),r(t)}))}));var children=[];exports.spawnWith=function(e,r){void 0===r&&(r={});var{useFork:s}=r,t=_objectWithoutPropertiesLoose(r,_excluded);debug("%sing: '%s'",s?"fork":"spawn",e.join(" ")),debugSilly("with options: %O",t);var n=(s?fork:spawn)(e[0],e.slice(1),_extends(_extends({stdio:"inherit"},t),{},{env:_extends(_extends({},process.env),t.env)}));return children.push(n),n.on("exit",(()=>{children.splice(children.indexOf(n),1)})),n};var killed=!1;function handleTerminationEvent(e){process.on(e,(()=>{killed||(killed=!0,children.forEach((e=>{e.kill()})),"exit"!==e&&process.exit(1))}))}handleTerminationEvent("exit"),handleTerminationEvent("SIGINT"),handleTerminationEvent("SIGTERM")},816:(e,r,s)=>{const t=s(856),{VSCODE_INSPECTOR_OPTIONS:n}=process.env;e.exports=e=>{{if(n){const{formatArgs:e}=t;t.formatArgs=function(r){const{useColors:s}=this;r[0].match(/%[oO]/)&&(this.useColors=!1),e.call(this,r),this.useColors=s},t.formatters.o=void 0,t.formatters.O=void 0}const e="web"===process.env.FLECKS_CORE_BUILD_TARGET?"debug":"error";t.log=console[e].bind(console)}return t(e)}},968:(e,r,s)=>{const{dump:t,load:n}=s(380),a=s(728),{Transform:o}=s(378);r.JsonStream=class extends o{constructor(e){super(),this.parser=new a;const r=this;this.parser.onValue=function(s){0===this.stack.length&&(r.transformed=JSON.stringify(e(s)))},this.transformed=void 0}_flush(e){this.push(this.transformed),e()}_transform(e,r,s){this.parser.write(e),s()}},r.JsonStream.PrettyPrint=class extends r.JsonStream{constructor(e,r=2){super(e);const s=this;this.parser.onValue=function(e){0===this.stack.length&&(s.transformed=JSON.stringify(e,null,r))}}},r.YamlStream=class extends o{constructor(e,r={dump:{},load:{}}){super(),this.buffers=[],this.decorator=e,this.options=r}_flush(e){const r=n(Buffer.concat(this.buffers).toString(),this.options.load);this.push(t(this.decorator(r),this.options.dump)),e()}_transform(e,r,s){this.buffers.push(e),s()}}},368:e=>{"use strict";e.exports=require("child_process")},392:e=>{"use strict";e.exports=require("fs/promises")},72:e=>{"use strict";e.exports=require("path")},378:e=>{"use strict";e.exports=require("stream")},856:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__856__},488:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__488__},380:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__380__},728:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__728__}},__webpack_module_cache__={};function __webpack_require__(e){var r=__webpack_module_cache__[e];if(void 0!==r)return r.exports;var s=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](s,s.exports,__webpack_require__),s.exports}var __webpack_exports__=__webpack_require__(24);return __webpack_exports__})()));
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("buffer"),require("debug"),require("glob"),require("js-yaml"),require("jsonparse")):"function"==typeof define&&define.amd?define("@flecks/core",["buffer","debug","glob","js-yaml","jsonparse"],r):"object"==typeof exports?exports["@flecks/core"]=r(require("buffer"),require("debug"),require("glob"),require("js-yaml"),require("jsonparse")):e["@flecks/core"]=r(e.buffer,e.debug,e.glob,e["js-yaml"],e.jsonparse)}(global,((__WEBPACK_EXTERNAL_MODULE__826__,__WEBPACK_EXTERNAL_MODULE__856__,__WEBPACK_EXTERNAL_MODULE__488__,__WEBPACK_EXTERNAL_MODULE__380__,__WEBPACK_EXTERNAL_MODULE__728__)=>(()=>{var __webpack_modules__={312:(e,r,s)=>{function t(){return t=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var s=arguments[r];for(var t in s)Object.prototype.hasOwnProperty.call(s,t)&&(e[t]=s[t])}return e},t.apply(this,arguments)}var{open:n,writeFile:a}=s(392);r.writeFile=async(e,r,s)=>{var o=t({flags:"w",mode:438},s),i=await n(e,o.flags,o.mode);await a(i,r,o),await i.sync(),await i.close()}},24:(e,r,s)=>{function t(){return t=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var s=arguments[r];for(var t in s)Object.prototype.hasOwnProperty.call(s,t)&&(e[t]=s[t])}return e},t.apply(this,arguments)}var{dump:n,load:a}=s(380);e.exports=t(t(t(t({dumpYml:n,glob:s(488).glob,loadYml:a},s(968)),s(312)),s(484)),s(524))},484:(e,r,s)=>{var{processCode:t,spawnWith:n}=s(524),{npm_config_user_agent:a="npm"}=process.env;r.inferPackageManager=()=>a.split("/")[0],r.build=async e=>{var s,{cwd:a,packageManager:o=r.inferPackageManager()}=e;switch(o){case"bun":s=["bun","run","build"];break;case"npm":s=["npm","run","build"];break;case"pnpm":s=["pnpm","run","build"];break;case"yarn":s=["yarn","run","build"]}return s&&t(n(s,{cwd:a,env:{FLECKS_CORE_ROOT:a}}))},r.add=async e=>{var s,{dev:a,packageManager:o=r.inferPackageManager(),packages:i}=e;switch(o){case"bun":s=["bun","add",...a?["--dev"]:[],...i];break;case"npm":s=["npm","install",...a?["--save-dev"]:[],...i];break;case"pnpm":s=["pnpm","add",...a?["--save-dev"]:[],...i];break;case"yarn":s=["yarn","add",...a?["--dev"]:[],...i]}return s&&t(n(s))},r.install=async e=>{var s,{cwd:a,packageManager:o=r.inferPackageManager()}=e;switch(o){case"bun":s=["bun","install"];break;case"npm":s=["npm","install"];break;case"pnpm":s=["pnpm","install"];break;case"yarn":s=["yarn","install"]}return s&&t(n(s,{cwd:a}))},r.lockFile=function(e){switch(void 0===e&&(e=r.inferPackageManager()),e){case"bun":return"bun.lockb";case"npm":return"package-lock.json";case"pnpm":return"pnpm-lock.yaml";case"yarn":return"yarn.lock";default:return""}}},524:(__unused_webpack_module,exports,__webpack_require__)=>{var _excluded=["useFork"];function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var s=arguments[r];for(var t in s)Object.prototype.hasOwnProperty.call(s,t)&&(e[t]=s[t])}return e},_extends.apply(this,arguments)}function _objectWithoutPropertiesLoose(e,r){if(null==e)return{};var s,t,n={},a=Object.keys(e);for(t=0;t<a.length;t++)s=a[t],r.indexOf(s)>=0||(n[s]=e[s]);return n}var{exec,fork,spawn}=__webpack_require__(368),{access,constants:{X_OK},realpath}=__webpack_require__(392),{dirname,join,sep}=__webpack_require__(72),D=__webpack_require__(816),debug=D("@flecks/core/server"),debugSilly=debug.extend("silly"),{FLECKS_CORE_ROOT=process.cwd()}=process.env;exports.binaryPath=async function(binary,root){void 0===root&&(root=FLECKS_CORE_ROOT);for(var resolved=dirname(await realpath(eval("require").resolve(join(root,"package.json")))),parts=resolved.split(sep);parts.length>0;){var path=parts.concat(join("node_modules",".bin",binary)).join(sep);try{return await access(path,X_OK),path}catch(e){parts.pop()}}throw new Error("Binary '".concat(binary,"' not found! (root: ").concat(root,")"))},exports.processCode=e=>new Promise(((r,s)=>{e.on("error",s),e.on("exit",(t=>{e.off("error",s),r(t)}))})),exports.run=function(e,r){var{suppressError:s=!0}=void 0===r?{}:r;return new Promise((r=>{exec(e,((e,t)=>{if(e)return s||console.error(e),void r(void 0);r(t.trim())}))}))};var children=[];exports.spawnWith=function(e,r){void 0===r&&(r={});var{useFork:s}=r,t=_objectWithoutPropertiesLoose(r,_excluded);debug("%sing: '%s'",s?"fork":"spawn",e.join(" ")),debugSilly("with options: %O",t);var n=(s?fork:spawn)(e[0],e.slice(1),_extends(_extends({stdio:"inherit"},t),{},{env:_extends(_extends({},process.env),t.env)}));return children.push(n),n.on("exit",(()=>{children.splice(children.indexOf(n),1)})),n};var killed=!1;function handleTerminationEvent(e){process.on(e,(()=>{killed||(killed=!0,children.forEach((e=>{e.kill()})),"exit"!==e&&process.exit(1))}))}handleTerminationEvent("exit"),handleTerminationEvent("SIGINT"),handleTerminationEvent("SIGTERM")},816:(e,r,s)=>{const t=s(856),{VSCODE_INSPECTOR_OPTIONS:n}=process.env;e.exports=e=>{{if(n){const{formatArgs:e}=t;t.formatArgs=function(r){const{useColors:s}=this;r[0].match(/%[oO]/)&&(this.useColors=!1),e.call(this,r),this.useColors=s},t.formatters.o=void 0,t.formatters.O=void 0}const e="web"===process.env.FLECKS_CORE_BUILD_TARGET?"debug":"error";t.log=console[e].bind(console)}return t(e)}},968:(e,r,s)=>{const{Buffer:t}=s(826),{dump:n,load:a}=s(380),o=s(728),{Transform:i,Writable:c}=s(378);r.JsonStream=class extends i{constructor(e){super(),this.parser=new o;const r=this;this.parser.onValue=function(s){0===this.stack.length&&(r.transformed=JSON.stringify(e(s)))},this.transformed=void 0}_flush(e){this.push(this.transformed),e()}_transform(e,r,s){this.parser.write(e),s()}},r.JsonStream.PrettyPrint=class extends r.JsonStream{constructor(e,r=2){super(e);const s=this;this.parser.onValue=function(e){0===this.stack.length&&(s.transformed=JSON.stringify(e,null,r))}}},r.pipesink=e=>{const r=Array.isArray(e)?e:[e],s=new class extends c{constructor(){super(),this.buffers=[]}_write(e,r,s){this.buffers.push(e),s()}},n=r.reduce(((e,r)=>r.pipe(e)));return new Promise(((e,r)=>{n.pipe(s),n.on("error",r),n.on("end",(()=>{e(t.concat(s.buffers))}))}))},r.YamlStream=class extends i{constructor(e,r={dump:{},load:{}}){super(),this.buffers=[],this.decorator=e,this.options=r}_flush(e){const r=a(t.concat(this.buffers).toString(),this.options.load);this.push(n(this.decorator(r),this.options.dump)),e()}_transform(e,r,s){this.buffers.push(e),s()}}},368:e=>{"use strict";e.exports=require("child_process")},392:e=>{"use strict";e.exports=require("fs/promises")},72:e=>{"use strict";e.exports=require("path")},378:e=>{"use strict";e.exports=require("stream")},826:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__826__},856:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__856__},488:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__488__},380:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__380__},728:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__728__}},__webpack_module_cache__={};function __webpack_require__(e){var r=__webpack_module_cache__[e];if(void 0!==r)return r.exports;var s=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](s,s.exports,__webpack_require__),s.exports}var __webpack_exports__=__webpack_require__(24);return __webpack_exports__})()));
//# sourceMappingURL=server.js.map

@@ -20,3 +20,10 @@ /* eslint-disable global-require */

}
Object.entries(flecks.constructor.dealiasedConfig(config))
const dealiasedConfig = flecks.constructor.dealiasedConfig(config);
if (
JSON.stringify(Object.keys(flecks.originalConfig).sort())
!== JSON.stringify(Object.keys(dealiasedConfig).sort())
) {
throw new Error('build manifest keys changed!');
}
Object.entries(dealiasedConfig)
.forEach(([fleck, value]) => {

@@ -23,0 +30,0 @@ if (JSON.stringify(flecks.originalConfig[fleck]) !== JSON.stringify(value)) {

@@ -10,4 +10,5 @@ /* eslint-disable global-require */

...require('../../build/stream'),
...require('./fs'),
...require('./package-manager'),
...require('./process'),
};

@@ -28,3 +28,3 @@ const {processCode, spawnWith} = require('./process');

}
return args && processCode(spawnWith(args, {cwd}));
return args && processCode(spawnWith(args, {cwd, env: {FLECKS_CORE_ROOT: cwd}}));
};

@@ -31,0 +31,0 @@

@@ -1,2 +0,2 @@

const {fork, spawn} = require('child_process');
const {exec, fork, spawn} = require('child_process');
const {

@@ -44,2 +44,18 @@ access,

exports.run = (cmd, {suppressError = true} = {}) => (
new Promise((resolve) => {
exec(cmd, (error, stdout) => {
if (error) {
if (!suppressError) {
// eslint-disable-next-line no-console
console.error(error);
}
resolve(undefined);
return;
}
resolve(stdout.trim());
});
})
);
const children = [];

@@ -46,0 +62,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc