bit-ship
Version:
Bit-Ship CLI is tool that analyses your code and generates a custom environment for your needs You can use if to local development, CI/CD or even production.
722 lines (614 loc) • 1.78 MB
JavaScript
import { readFile as readFile$1 } from 'fs/promises';
import require$$0$2 from 'buffer';
import * as require$$0$1 from 'fs';
import require$$0__default, { promises, existsSync, readFileSync } from 'fs';
import require$$0$3 from 'url';
import require$$0$4 from 'util';
import require$$0$5, { resolve, dirname, relative, join } from 'path';
import require$$0$7 from 'events';
import require$$0$6 from 'stream';
import require$$2$1 from 'os';
import http, { createServer } from 'node:http';
import https from 'node:https';
import { EventEmitter } from 'node:events';
import require$$1$1 from 'https';
import require$$2$2, { request } from 'http';
import require$$3 from 'net';
import require$$4 from 'tls';
import require$$1, { randomBytes } from 'crypto';
import require$$0$8 from 'zlib';
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __awaiter$1(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator$1(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
const m=Symbol.for("__confbox_fmt__"),k$1=/^(\s+)/,v$1=/(\s+)$/;function x(e,t={}){const n=t.indent===void 0&&t.preserveIndentation!==false&&e.slice(0,t?.sampleSize||1024),i=t.preserveWhitespace===false?void 0:{start:k$1.exec(e)?.[0]||"",end:v$1.exec(e)?.[0]||""};return {sample:n,whiteSpace:i}}function N$1(e,t,n){!t||typeof t!="object"||Object.defineProperty(t,m,{enumerable:false,configurable:true,writable:true,value:x(e,n)});}
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function oe(e){return typeof e>"u"||e===null}function We(e){return typeof e=="object"&&e!==null}function $e(e){return Array.isArray(e)?e:oe(e)?[]:[e]}function Qe(e,n){var i,l,r,u;if(n)for(u=Object.keys(n),i=0,l=u.length;i<l;i+=1)r=u[i],e[r]=n[r];return e}function Ve(e,n){var i="",l;for(l=0;l<n;l+=1)i+=e;return i}function Xe(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Ze=oe,ze=We,Je=$e,en=Ve,nn=Xe,rn=Qe,y={isNothing:Ze,isObject:ze,toArray:Je,repeat:en,isNegativeZero:nn,extend:rn};function ue(e,n){var i="",l=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(i+='in "'+e.mark.name+'" '),i+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!n&&e.mark.snippet&&(i+=`
`+e.mark.snippet),l+" "+i):l}function M(e,n){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=n,this.message=ue(this,false),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||"";}M.prototype=Object.create(Error.prototype),M.prototype.constructor=M,M.prototype.toString=function(n){return this.name+": "+ue(this,n)};var w=M;function $(e,n,i,l,r){var u="",o="",f=Math.floor(r/2)-1;return l-n>f&&(u=" ... ",n=l-f+u.length),i-l>f&&(o=" ...",i=l+f-o.length),{str:u+e.slice(n,i).replace(/\t/g,"\u2192")+o,pos:l-n+u.length}}function Q(e,n){return y.repeat(" ",n-e.length)+e}function ln(e,n){if(n=Object.create(n||null),!e.buffer)return null;n.maxLength||(n.maxLength=79),typeof n.indent!="number"&&(n.indent=1),typeof n.linesBefore!="number"&&(n.linesBefore=3),typeof n.linesAfter!="number"&&(n.linesAfter=2);for(var i=/\r?\n|\r|\0/g,l=[0],r=[],u,o=-1;u=i.exec(e.buffer);)r.push(u.index),l.push(u.index+u[0].length),e.position<=u.index&&o<0&&(o=l.length-2);o<0&&(o=l.length-1);var f="",c,a,t=Math.min(e.line+n.linesAfter,r.length).toString().length,p=n.maxLength-(n.indent+t+3);for(c=1;c<=n.linesBefore&&!(o-c<0);c++)a=$(e.buffer,l[o-c],r[o-c],e.position-(l[o]-l[o-c]),p),f=y.repeat(" ",n.indent)+Q((e.line-c+1).toString(),t)+" | "+a.str+`
`+f;for(a=$(e.buffer,l[o],r[o],e.position,p),f+=y.repeat(" ",n.indent)+Q((e.line+1).toString(),t)+" | "+a.str+`
`,f+=y.repeat("-",n.indent+t+3+a.pos)+`^
`,c=1;c<=n.linesAfter&&!(o+c>=r.length);c++)a=$(e.buffer,l[o+c],r[o+c],e.position-(l[o]-l[o+c]),p),f+=y.repeat(" ",n.indent)+Q((e.line+c+1).toString(),t)+" | "+a.str+`
`;return f.replace(/\n$/,"")}var on=ln,un=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],fn=["scalar","sequence","mapping"];function cn(e){var n={};return e!==null&&Object.keys(e).forEach(function(i){e[i].forEach(function(l){n[String(l)]=i;});}),n}function an(e,n){if(n=n||{},Object.keys(n).forEach(function(i){if(un.indexOf(i)===-1)throw new w('Unknown option "'+i+'" is met in definition of "'+e+'" YAML type.')}),this.options=n,this.tag=e,this.kind=n.kind||null,this.resolve=n.resolve||function(){return true},this.construct=n.construct||function(i){return i},this.instanceOf=n.instanceOf||null,this.predicate=n.predicate||null,this.represent=n.represent||null,this.representName=n.representName||null,this.defaultStyle=n.defaultStyle||null,this.multi=n.multi||false,this.styleAliases=cn(n.styleAliases||null),fn.indexOf(this.kind)===-1)throw new w('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var C=an;function fe(e,n){var i=[];return e[n].forEach(function(l){var r=i.length;i.forEach(function(u,o){u.tag===l.tag&&u.kind===l.kind&&u.multi===l.multi&&(r=o);}),i[r]=l;}),i}function pn(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},n,i;function l(r){r.multi?(e.multi[r.kind].push(r),e.multi.fallback.push(r)):e[r.kind][r.tag]=e.fallback[r.tag]=r;}for(n=0,i=arguments.length;n<i;n+=1)arguments[n].forEach(l);return e}function V(e){return this.extend(e)}V.prototype.extend=function(n){var i=[],l=[];if(n instanceof C)l.push(n);else if(Array.isArray(n))l=l.concat(n);else if(n&&(Array.isArray(n.implicit)||Array.isArray(n.explicit)))n.implicit&&(i=i.concat(n.implicit)),n.explicit&&(l=l.concat(n.explicit));else throw new w("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");i.forEach(function(u){if(!(u instanceof C))throw new w("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(u.loadKind&&u.loadKind!=="scalar")throw new w("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(u.multi)throw new w("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),l.forEach(function(u){if(!(u instanceof C))throw new w("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var r=Object.create(V.prototype);return r.implicit=(this.implicit||[]).concat(i),r.explicit=(this.explicit||[]).concat(l),r.compiledImplicit=fe(r,"implicit"),r.compiledExplicit=fe(r,"explicit"),r.compiledTypeMap=pn(r.compiledImplicit,r.compiledExplicit),r};var tn=V,hn=new C("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),dn=new C("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),sn=new C("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),xn=new tn({explicit:[hn,dn,sn]});function mn(e){if(e===null)return true;var n=e.length;return n===1&&e==="~"||n===4&&(e==="null"||e==="Null"||e==="NULL")}function gn(){return null}function An(e){return e===null}var vn=new C("tag:yaml.org,2002:null",{kind:"scalar",resolve:mn,construct:gn,predicate:An,represent:{canonical:function(){return "~"},lowercase:function(){return "null"},uppercase:function(){return "NULL"},camelcase:function(){return "Null"},empty:function(){return ""}},defaultStyle:"lowercase"});function yn(e){if(e===null)return false;var n=e.length;return n===4&&(e==="true"||e==="True"||e==="TRUE")||n===5&&(e==="false"||e==="False"||e==="FALSE")}function Cn(e){return e==="true"||e==="True"||e==="TRUE"}function _n(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var wn=new C("tag:yaml.org,2002:bool",{kind:"scalar",resolve:yn,construct:Cn,predicate:_n,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function bn(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Fn(e){return 48<=e&&e<=55}function Sn(e){return 48<=e&&e<=57}function En(e){if(e===null)return false;var n=e.length,i=0,l=false,r;if(!n)return false;if(r=e[i],(r==="-"||r==="+")&&(r=e[++i]),r==="0"){if(i+1===n)return true;if(r=e[++i],r==="b"){for(i++;i<n;i++)if(r=e[i],r!=="_"){if(r!=="0"&&r!=="1")return false;l=true;}return l&&r!=="_"}if(r==="x"){for(i++;i<n;i++)if(r=e[i],r!=="_"){if(!bn(e.charCodeAt(i)))return false;l=true;}return l&&r!=="_"}if(r==="o"){for(i++;i<n;i++)if(r=e[i],r!=="_"){if(!Fn(e.charCodeAt(i)))return false;l=true;}return l&&r!=="_"}}if(r==="_")return false;for(;i<n;i++)if(r=e[i],r!=="_"){if(!Sn(e.charCodeAt(i)))return false;l=true;}return !(!l||r==="_")}function Tn(e){var n=e,i=1,l;if(n.indexOf("_")!==-1&&(n=n.replace(/_/g,"")),l=n[0],(l==="-"||l==="+")&&(l==="-"&&(i=-1),n=n.slice(1),l=n[0]),n==="0")return 0;if(l==="0"){if(n[1]==="b")return i*parseInt(n.slice(2),2);if(n[1]==="x")return i*parseInt(n.slice(2),16);if(n[1]==="o")return i*parseInt(n.slice(2),8)}return i*parseInt(n,10)}function On(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!y.isNegativeZero(e)}var In=new C("tag:yaml.org,2002:int",{kind:"scalar",resolve:En,construct:Tn,predicate:On,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),kn=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Ln(e){return !(e===null||!kn.test(e)||e[e.length-1]==="_")}function Nn(e){var n,i;return n=e.replace(/_/g,"").toLowerCase(),i=n[0]==="-"?-1:1,"+-".indexOf(n[0])>=0&&(n=n.slice(1)),n===".inf"?i===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:n===".nan"?NaN:i*parseFloat(n,10)}var Rn=/^[-+]?[0-9]+e/;function Dn(e,n){var i;if(isNaN(e))switch(n){case "lowercase":return ".nan";case "uppercase":return ".NAN";case "camelcase":return ".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(n){case "lowercase":return ".inf";case "uppercase":return ".INF";case "camelcase":return ".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(n){case "lowercase":return "-.inf";case "uppercase":return "-.INF";case "camelcase":return "-.Inf"}else if(y.isNegativeZero(e))return "-0.0";return i=e.toString(10),Rn.test(i)?i.replace("e",".e"):i}function Mn(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||y.isNegativeZero(e))}var Yn=new C("tag:yaml.org,2002:float",{kind:"scalar",resolve:Ln,construct:Nn,predicate:Mn,represent:Dn,defaultStyle:"lowercase"}),Bn=xn.extend({implicit:[vn,wn,In,Yn]}),Pn=Bn,ce=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),ae=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function jn(e){return e===null?false:ce.exec(e)!==null||ae.exec(e)!==null}function Hn(e){var n,i,l,r,u,o,f,c=0,a=null,t,p,d;if(n=ce.exec(e),n===null&&(n=ae.exec(e)),n===null)throw new Error("Date resolve error");if(i=+n[1],l=+n[2]-1,r=+n[3],!n[4])return new Date(Date.UTC(i,l,r));if(u=+n[4],o=+n[5],f=+n[6],n[7]){for(c=n[7].slice(0,3);c.length<3;)c+="0";c=+c;}return n[9]&&(t=+n[10],p=+(n[11]||0),a=(t*60+p)*6e4,n[9]==="-"&&(a=-a)),d=new Date(Date.UTC(i,l,r,u,o,f,c)),a&&d.setTime(d.getTime()-a),d}function Un(e){return e.toISOString()}var Kn=new C("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:jn,construct:Hn,instanceOf:Date,represent:Un});function qn(e){return e==="<<"||e===null}var Gn=new C("tag:yaml.org,2002:merge",{kind:"scalar",resolve:qn}),X=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
\r`;function Wn(e){if(e===null)return false;var n,i,l=0,r=e.length,u=X;for(i=0;i<r;i++)if(n=u.indexOf(e.charAt(i)),!(n>64)){if(n<0)return false;l+=6;}return l%8===0}function $n(e){var n,i,l=e.replace(/[\r\n=]/g,""),r=l.length,u=X,o=0,f=[];for(n=0;n<r;n++)n%4===0&&n&&(f.push(o>>16&255),f.push(o>>8&255),f.push(o&255)),o=o<<6|u.indexOf(l.charAt(n));return i=r%4*6,i===0?(f.push(o>>16&255),f.push(o>>8&255),f.push(o&255)):i===18?(f.push(o>>10&255),f.push(o>>2&255)):i===12&&f.push(o>>4&255),new Uint8Array(f)}function Qn(e){var n="",i=0,l,r,u=e.length,o=X;for(l=0;l<u;l++)l%3===0&&l&&(n+=o[i>>18&63],n+=o[i>>12&63],n+=o[i>>6&63],n+=o[i&63]),i=(i<<8)+e[l];return r=u%3,r===0?(n+=o[i>>18&63],n+=o[i>>12&63],n+=o[i>>6&63],n+=o[i&63]):r===2?(n+=o[i>>10&63],n+=o[i>>4&63],n+=o[i<<2&63],n+=o[64]):r===1&&(n+=o[i>>2&63],n+=o[i<<4&63],n+=o[64],n+=o[64]),n}function Vn(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var Xn=new C("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Wn,construct:$n,predicate:Vn,represent:Qn}),Zn=Object.prototype.hasOwnProperty,zn=Object.prototype.toString;function Jn(e){if(e===null)return true;var n=[],i,l,r,u,o,f=e;for(i=0,l=f.length;i<l;i+=1){if(r=f[i],o=false,zn.call(r)!=="[object Object]")return false;for(u in r)if(Zn.call(r,u))if(!o)o=true;else return false;if(!o)return false;if(n.indexOf(u)===-1)n.push(u);else return false}return true}function ei(e){return e!==null?e:[]}var ni=new C("tag:yaml.org,2002:omap",{kind:"sequence",resolve:Jn,construct:ei}),ii=Object.prototype.toString;function ri(e){if(e===null)return true;var n,i,l,r,u,o=e;for(u=new Array(o.length),n=0,i=o.length;n<i;n+=1){if(l=o[n],ii.call(l)!=="[object Object]"||(r=Object.keys(l),r.length!==1))return false;u[n]=[r[0],l[r[0]]];}return true}function li(e){if(e===null)return [];var n,i,l,r,u,o=e;for(u=new Array(o.length),n=0,i=o.length;n<i;n+=1)l=o[n],r=Object.keys(l),u[n]=[r[0],l[r[0]]];return u}var oi=new C("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:ri,construct:li}),ui=Object.prototype.hasOwnProperty;function fi(e){if(e===null)return true;var n,i=e;for(n in i)if(ui.call(i,n)&&i[n]!==null)return false;return true}function ci(e){return e!==null?e:{}}var ai=new C("tag:yaml.org,2002:set",{kind:"mapping",resolve:fi,construct:ci}),pe=Pn.extend({implicit:[Kn,Gn],explicit:[Xn,ni,oi,ai]}),T=Object.prototype.hasOwnProperty,H=1,te=2,he=3,U=4,Z=1,pi=2,de=3,ti=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,hi=/[\x85\u2028\u2029]/,di=/[,\[\]\{\}]/,se=/^(?:!|!!|![a-z\-]+!)$/i,xe=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function me(e){return Object.prototype.toString.call(e)}function S(e){return e===10||e===13}function I(e){return e===9||e===32}function b(e){return e===9||e===32||e===10||e===13}function k(e){return e===44||e===91||e===93||e===123||e===125}function si(e){var n;return 48<=e&&e<=57?e-48:(n=e|32,97<=n&&n<=102?n-97+10:-1)}function xi(e){return e===120?2:e===117?4:e===85?8:0}function mi(e){return 48<=e&&e<=57?e-48:-1}function ge(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
`:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function gi(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}for(var Ae=new Array(256),ve=new Array(256),L=0;L<256;L++)Ae[L]=ge(L)?1:0,ve[L]=ge(L);function Ai(e,n){this.input=e,this.filename=n.filename||null,this.schema=n.schema||pe,this.onWarning=n.onWarning||null,this.legacy=n.legacy||false,this.json=n.json||false,this.listener=n.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[];}function ye(e,n){var i={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return i.snippet=on(i),new w(n,i)}function h(e,n){throw ye(e,n)}function K(e,n){e.onWarning&&e.onWarning.call(null,ye(e,n));}var Ce={YAML:function(n,i,l){var r,u,o;n.version!==null&&h(n,"duplication of %YAML directive"),l.length!==1&&h(n,"YAML directive accepts exactly one argument"),r=/^([0-9]+)\.([0-9]+)$/.exec(l[0]),r===null&&h(n,"ill-formed argument of the YAML directive"),u=parseInt(r[1],10),o=parseInt(r[2],10),u!==1&&h(n,"unacceptable YAML version of the document"),n.version=l[0],n.checkLineBreaks=o<2,o!==1&&o!==2&&K(n,"unsupported YAML version of the document");},TAG:function(n,i,l){var r,u;l.length!==2&&h(n,"TAG directive accepts exactly two arguments"),r=l[0],u=l[1],se.test(r)||h(n,"ill-formed tag handle (first argument) of the TAG directive"),T.call(n.tagMap,r)&&h(n,'there is a previously declared suffix for "'+r+'" tag handle'),xe.test(u)||h(n,"ill-formed tag prefix (second argument) of the TAG directive");try{u=decodeURIComponent(u);}catch{h(n,"tag prefix is malformed: "+u);}n.tagMap[r]=u;}};function O(e,n,i,l){var r,u,o,f;if(n<i){if(f=e.input.slice(n,i),l)for(r=0,u=f.length;r<u;r+=1)o=f.charCodeAt(r),o===9||32<=o&&o<=1114111||h(e,"expected valid JSON character");else ti.test(f)&&h(e,"the stream contains non-printable characters");e.result+=f;}}function _e(e,n,i,l){var r,u,o,f;for(y.isObject(i)||h(e,"cannot merge mappings; the provided source object is unacceptable"),r=Object.keys(i),o=0,f=r.length;o<f;o+=1)u=r[o],T.call(n,u)||(n[u]=i[u],l[u]=true);}function N(e,n,i,l,r,u,o,f,c){var a,t;if(Array.isArray(r))for(r=Array.prototype.slice.call(r),a=0,t=r.length;a<t;a+=1)Array.isArray(r[a])&&h(e,"nested arrays are not supported inside keys"),typeof r=="object"&&me(r[a])==="[object Object]"&&(r[a]="[object Object]");if(typeof r=="object"&&me(r)==="[object Object]"&&(r="[object Object]"),r=String(r),n===null&&(n={}),l==="tag:yaml.org,2002:merge")if(Array.isArray(u))for(a=0,t=u.length;a<t;a+=1)_e(e,n,u[a],i);else _e(e,n,u,i);else !e.json&&!T.call(i,r)&&T.call(n,r)&&(e.line=o||e.line,e.lineStart=f||e.lineStart,e.position=c||e.position,h(e,"duplicated mapping key")),r==="__proto__"?Object.defineProperty(n,r,{configurable:true,enumerable:true,writable:true,value:u}):n[r]=u,delete i[r];return n}function z(e){var n;n=e.input.charCodeAt(e.position),n===10?e.position++:n===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):h(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1;}function v(e,n,i){for(var l=0,r=e.input.charCodeAt(e.position);r!==0;){for(;I(r);)r===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),r=e.input.charCodeAt(++e.position);if(n&&r===35)do r=e.input.charCodeAt(++e.position);while(r!==10&&r!==13&&r!==0);if(S(r))for(z(e),r=e.input.charCodeAt(e.position),l++,e.lineIndent=0;r===32;)e.lineIndent++,r=e.input.charCodeAt(++e.position);else break}return i!==-1&&l!==0&&e.lineIndent<i&&K(e,"deficient indentation"),l}function q(e){var n=e.position,i;return i=e.input.charCodeAt(n),!!((i===45||i===46)&&i===e.input.charCodeAt(n+1)&&i===e.input.charCodeAt(n+2)&&(n+=3,i=e.input.charCodeAt(n),i===0||b(i)))}function J(e,n){n===1?e.result+=" ":n>1&&(e.result+=y.repeat(`
`,n-1));}function vi(e,n,i){var l,r,u,o,f,c,a,t,p=e.kind,d=e.result,s;if(s=e.input.charCodeAt(e.position),b(s)||k(s)||s===35||s===38||s===42||s===33||s===124||s===62||s===39||s===34||s===37||s===64||s===96||(s===63||s===45)&&(r=e.input.charCodeAt(e.position+1),b(r)||i&&k(r)))return false;for(e.kind="scalar",e.result="",u=o=e.position,f=false;s!==0;){if(s===58){if(r=e.input.charCodeAt(e.position+1),b(r)||i&&k(r))break}else if(s===35){if(l=e.input.charCodeAt(e.position-1),b(l))break}else {if(e.position===e.lineStart&&q(e)||i&&k(s))break;if(S(s))if(c=e.line,a=e.lineStart,t=e.lineIndent,v(e,false,-1),e.lineIndent>=n){f=true,s=e.input.charCodeAt(e.position);continue}else {e.position=o,e.line=c,e.lineStart=a,e.lineIndent=t;break}}f&&(O(e,u,o,false),J(e,e.line-c),u=o=e.position,f=false),I(s)||(o=e.position+1),s=e.input.charCodeAt(++e.position);}return O(e,u,o,false),e.result?true:(e.kind=p,e.result=d,false)}function yi(e,n){var i,l,r;if(i=e.input.charCodeAt(e.position),i!==39)return false;for(e.kind="scalar",e.result="",e.position++,l=r=e.position;(i=e.input.charCodeAt(e.position))!==0;)if(i===39)if(O(e,l,e.position,true),i=e.input.charCodeAt(++e.position),i===39)l=e.position,e.position++,r=e.position;else return true;else S(i)?(O(e,l,r,true),J(e,v(e,false,n)),l=r=e.position):e.position===e.lineStart&&q(e)?h(e,"unexpected end of the document within a single quoted scalar"):(e.position++,r=e.position);h(e,"unexpected end of the stream within a single quoted scalar");}function Ci(e,n){var i,l,r,u,o,f;if(f=e.input.charCodeAt(e.position),f!==34)return false;for(e.kind="scalar",e.result="",e.position++,i=l=e.position;(f=e.input.charCodeAt(e.position))!==0;){if(f===34)return O(e,i,e.position,true),e.position++,true;if(f===92){if(O(e,i,e.position,true),f=e.input.charCodeAt(++e.position),S(f))v(e,false,n);else if(f<256&&Ae[f])e.result+=ve[f],e.position++;else if((o=xi(f))>0){for(r=o,u=0;r>0;r--)f=e.input.charCodeAt(++e.position),(o=si(f))>=0?u=(u<<4)+o:h(e,"expected hexadecimal character");e.result+=gi(u),e.position++;}else h(e,"unknown escape sequence");i=l=e.position;}else S(f)?(O(e,i,l,true),J(e,v(e,false,n)),i=l=e.position):e.position===e.lineStart&&q(e)?h(e,"unexpected end of the document within a double quoted scalar"):(e.position++,l=e.position);}h(e,"unexpected end of the stream within a double quoted scalar");}function _i(e,n){var i=true,l,r,u,o=e.tag,f,c=e.anchor,a,t,p,d,s,x=Object.create(null),g,A,F,m;if(m=e.input.charCodeAt(e.position),m===91)t=93,s=false,f=[];else if(m===123)t=125,s=true,f={};else return false;for(e.anchor!==null&&(e.anchorMap[e.anchor]=f),m=e.input.charCodeAt(++e.position);m!==0;){if(v(e,true,n),m=e.input.charCodeAt(e.position),m===t)return e.position++,e.tag=o,e.anchor=c,e.kind=s?"mapping":"sequence",e.result=f,true;i?m===44&&h(e,"expected the node content, but found ','"):h(e,"missed comma between flow collection entries"),A=g=F=null,p=d=false,m===63&&(a=e.input.charCodeAt(e.position+1),b(a)&&(p=d=true,e.position++,v(e,true,n))),l=e.line,r=e.lineStart,u=e.position,R(e,n,H,false,true),A=e.tag,g=e.result,v(e,true,n),m=e.input.charCodeAt(e.position),(d||e.line===l)&&m===58&&(p=true,m=e.input.charCodeAt(++e.position),v(e,true,n),R(e,n,H,false,true),F=e.result),s?N(e,f,x,A,g,F,l,r,u):p?f.push(N(e,null,x,A,g,F,l,r,u)):f.push(g),v(e,true,n),m=e.input.charCodeAt(e.position),m===44?(i=true,m=e.input.charCodeAt(++e.position)):i=false;}h(e,"unexpected end of the stream within a flow collection");}function wi(e,n){var i,l,r=Z,u=false,o=false,f=n,c=0,a=false,t,p;if(p=e.input.charCodeAt(e.position),p===124)l=false;else if(p===62)l=true;else return false;for(e.kind="scalar",e.result="";p!==0;)if(p=e.input.charCodeAt(++e.position),p===43||p===45)Z===r?r=p===43?de:pi:h(e,"repeat of a chomping mode identifier");else if((t=mi(p))>=0)t===0?h(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):o?h(e,"repeat of an indentation width identifier"):(f=n+t-1,o=true);else break;if(I(p)){do p=e.input.charCodeAt(++e.position);while(I(p));if(p===35)do p=e.input.charCodeAt(++e.position);while(!S(p)&&p!==0)}for(;p!==0;){for(z(e),e.lineIndent=0,p=e.input.charCodeAt(e.position);(!o||e.lineIndent<f)&&p===32;)e.lineIndent++,p=e.input.charCodeAt(++e.position);if(!o&&e.lineIndent>f&&(f=e.lineIndent),S(p)){c++;continue}if(e.lineIndent<f){r===de?e.result+=y.repeat(`
`,u?1+c:c):r===Z&&u&&(e.result+=`
`);break}for(l?I(p)?(a=true,e.result+=y.repeat(`
`,u?1+c:c)):a?(a=false,e.result+=y.repeat(`
`,c+1)):c===0?u&&(e.result+=" "):e.result+=y.repeat(`
`,c):e.result+=y.repeat(`
`,u?1+c:c),u=true,o=true,c=0,i=e.position;!S(p)&&p!==0;)p=e.input.charCodeAt(++e.position);O(e,i,e.position,false);}return true}function we(e,n){var i,l=e.tag,r=e.anchor,u=[],o,f=false,c;if(e.firstTabInLine!==-1)return false;for(e.anchor!==null&&(e.anchorMap[e.anchor]=u),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,h(e,"tab characters must not be used in indentation")),!(c!==45||(o=e.input.charCodeAt(e.position+1),!b(o))));){if(f=true,e.position++,v(e,true,-1)&&e.lineIndent<=n){u.push(null),c=e.input.charCodeAt(e.position);continue}if(i=e.line,R(e,n,he,false,true),u.push(e.result),v(e,true,-1),c=e.input.charCodeAt(e.position),(e.line===i||e.lineIndent>n)&&c!==0)h(e,"bad indentation of a sequence entry");else if(e.lineIndent<n)break}return f?(e.tag=l,e.anchor=r,e.kind="sequence",e.result=u,true):false}function bi(e,n,i){var l,r,u,o,f,c,a=e.tag,t=e.anchor,p={},d=Object.create(null),s=null,x=null,g=null,A=false,F=false,m;if(e.firstTabInLine!==-1)return false;for(e.anchor!==null&&(e.anchorMap[e.anchor]=p),m=e.input.charCodeAt(e.position);m!==0;){if(!A&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,h(e,"tab characters must not be used in indentation")),l=e.input.charCodeAt(e.position+1),u=e.line,(m===63||m===58)&&b(l))m===63?(A&&(N(e,p,d,s,x,null,o,f,c),s=x=g=null),F=true,A=true,r=true):A?(A=false,r=true):h(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,m=l;else {if(o=e.line,f=e.lineStart,c=e.position,!R(e,i,te,false,true))break;if(e.line===u){for(m=e.input.charCodeAt(e.position);I(m);)m=e.input.charCodeAt(++e.position);if(m===58)m=e.input.charCodeAt(++e.position),b(m)||h(e,"a whitespace character is expected after the key-value separator within a block mapping"),A&&(N(e,p,d,s,x,null,o,f,c),s=x=g=null),F=true,A=false,r=false,s=e.tag,x=e.result;else if(F)h(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=a,e.anchor=t,true}else if(F)h(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=a,e.anchor=t,true}if((e.line===u||e.lineIndent>n)&&(A&&(o=e.line,f=e.lineStart,c=e.position),R(e,n,U,true,r)&&(A?x=e.result:g=e.result),A||(N(e,p,d,s,x,g,o,f,c),s=x=g=null),v(e,true,-1),m=e.input.charCodeAt(e.position)),(e.line===u||e.lineIndent>n)&&m!==0)h(e,"bad indentation of a mapping entry");else if(e.lineIndent<n)break}return A&&N(e,p,d,s,x,null,o,f,c),F&&(e.tag=a,e.anchor=t,e.kind="mapping",e.result=p),F}function Fi(e){var n,i=false,l=false,r,u,o;if(o=e.input.charCodeAt(e.position),o!==33)return false;if(e.tag!==null&&h(e,"duplication of a tag property"),o=e.input.charCodeAt(++e.position),o===60?(i=true,o=e.input.charCodeAt(++e.position)):o===33?(l=true,r="!!",o=e.input.charCodeAt(++e.position)):r="!",n=e.position,i){do o=e.input.charCodeAt(++e.position);while(o!==0&&o!==62);e.position<e.length?(u=e.input.slice(n,e.position),o=e.input.charCodeAt(++e.position)):h(e,"unexpected end of the stream within a verbatim tag");}else {for(;o!==0&&!b(o);)o===33&&(l?h(e,"tag suffix cannot contain exclamation marks"):(r=e.input.slice(n-1,e.position+1),se.test(r)||h(e,"named tag handle cannot contain such characters"),l=true,n=e.position+1)),o=e.input.charCodeAt(++e.position);u=e.input.slice(n,e.position),di.test(u)&&h(e,"tag suffix cannot contain flow indicator characters");}u&&!xe.test(u)&&h(e,"tag name cannot contain such characters: "+u);try{u=decodeURIComponent(u);}catch{h(e,"tag name is malformed: "+u);}return i?e.tag=u:T.call(e.tagMap,r)?e.tag=e.tagMap[r]+u:r==="!"?e.tag="!"+u:r==="!!"?e.tag="tag:yaml.org,2002:"+u:h(e,'undeclared tag handle "'+r+'"'),true}function Si(e){var n,i;if(i=e.input.charCodeAt(e.position),i!==38)return false;for(e.anchor!==null&&h(e,"duplication of an anchor property"),i=e.input.charCodeAt(++e.position),n=e.position;i!==0&&!b(i)&&!k(i);)i=e.input.charCodeAt(++e.position);return e.position===n&&h(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(n,e.position),true}function Ei(e){var n,i,l;if(l=e.input.charCodeAt(e.position),l!==42)return false;for(l=e.input.charCodeAt(++e.position),n=e.position;l!==0&&!b(l)&&!k(l);)l=e.input.charCodeAt(++e.position);return e.position===n&&h(e,"name of an alias node must contain at least one character"),i=e.input.slice(n,e.position),T.call(e.anchorMap,i)||h(e,'unidentified alias "'+i+'"'),e.result=e.anchorMap[i],v(e,true,-1),true}function R(e,n,i,l,r){var u,o,f,c=1,a=false,t=false,p,d,s,x,g,A;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,u=o=f=U===i||he===i,l&&v(e,true,-1)&&(a=true,e.lineIndent>n?c=1:e.lineIndent===n?c=0:e.lineIndent<n&&(c=-1)),c===1)for(;Fi(e)||Si(e);)v(e,true,-1)?(a=true,f=u,e.lineIndent>n?c=1:e.lineIndent===n?c=0:e.lineIndent<n&&(c=-1)):f=false;if(f&&(f=a||r),(c===1||U===i)&&(H===i||te===i?g=n:g=n+1,A=e.position-e.lineStart,c===1?f&&(we(e,A)||bi(e,A,g))||_i(e,g)?t=true:(o&&wi(e,g)||yi(e,g)||Ci(e,g)?t=true:Ei(e)?(t=true,(e.tag!==null||e.anchor!==null)&&h(e,"alias node should not have any properties")):vi(e,g,H===i)&&(t=true,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(t=f&&we(e,A))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&h(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),p=0,d=e.implicitTypes.length;p<d;p+=1)if(x=e.implicitTypes[p],x.resolve(e.result)){e.result=x.construct(e.result),e.tag=x.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(T.call(e.typeMap[e.kind||"fallback"],e.tag))x=e.typeMap[e.kind||"fallback"][e.tag];else for(x=null,s=e.typeMap.multi[e.kind||"fallback"],p=0,d=s.length;p<d;p+=1)if(e.tag.slice(0,s[p].tag.length)===s[p].tag){x=s[p];break}x||h(e,"unknown tag !<"+e.tag+">"),e.result!==null&&x.kind!==e.kind&&h(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+x.kind+'", not "'+e.kind+'"'),x.resolve(e.result,e.tag)?(e.result=x.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):h(e,"cannot resolve a node with !<"+e.tag+"> explicit tag");}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||t}function Ti(e){var n=e.position,i,l,r,u=false,o;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(o=e.input.charCodeAt(e.position))!==0&&(v(e,true,-1),o=e.input.charCodeAt(e.position),!(e.lineIndent>0||o!==37));){for(u=true,o=e.input.charCodeAt(++e.position),i=e.position;o!==0&&!b(o);)o=e.input.charCodeAt(++e.position);for(l=e.input.slice(i,e.position),r=[],l.length<1&&h(e,"directive name must not be less than one character in length");o!==0;){for(;I(o);)o=e.input.charCodeAt(++e.position);if(o===35){do o=e.input.charCodeAt(++e.position);while(o!==0&&!S(o));break}if(S(o))break;for(i=e.position;o!==0&&!b(o);)o=e.input.charCodeAt(++e.position);r.push(e.input.slice(i,e.position));}o!==0&&z(e),T.call(Ce,l)?Ce[l](e,l,r):K(e,'unknown document directive "'+l+'"');}if(v(e,true,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,v(e,true,-1)):u&&h(e,"directives end mark is expected"),R(e,e.lineIndent-1,U,false,true),v(e,true,-1),e.checkLineBreaks&&hi.test(e.input.slice(n,e.position))&&K(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&q(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,v(e,true,-1));return}if(e.position<e.length-1)h(e,"end of the stream or a document separator is expected");else return}function be(e,n){e=String(e),n=n||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var i=new Ai(e,n),l=e.indexOf("\0");for(l!==-1&&(i.position=l,h(i,"null byte is not allowed in input")),i.input+="\0";i.input.charCodeAt(i.position)===32;)i.lineIndent+=1,i.position+=1;for(;i.position<i.length-1;)Ti(i);return i.documents}function Ii(e,n){var i=be(e,n);if(i.length!==0){if(i.length===1)return i[0];throw new w("expected a single document in the stream, but found more")}}var Li=Ii,Ni={load:Li};var mr=Ni.load;function Ar(e,n){const i=mr(e,n);return N$1(e,i,n),i}
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
var isomorphicGit = {};
var lib$5;
var hasRequiredLib$5;
function requireLib$5 () {
if (hasRequiredLib$5) return lib$5;
hasRequiredLib$5 = 1;
var AsyncLock = function (opts) {
opts = opts || {};
this.Promise = opts.Promise || Promise;
// format: {key : [fn, fn]}
// queues[key] = null indicates no job running for key
this.queues = Object.create(null);
// lock is reentrant for same domain
this.domainReentrant = opts.domainReentrant || false;
if (this.domainReentrant) {
if (typeof process === 'undefined' || typeof process.domain === 'undefined') {
throw new Error(
'Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, ' +
'use a NodeJS version that still implements Domain, or install a browser polyfill.');
}
// domain of current running func {key : fn}
this.domains = Object.create(null);
}
this.timeout = opts.timeout || AsyncLock.DEFAULT_TIMEOUT;
this.maxOccupationTime = opts.maxOccupationTime || AsyncLock.DEFAULT_MAX_OCCUPATION_TIME;
this.maxExecutionTime = opts.maxExecutionTime || AsyncLock.DEFAULT_MAX_EXECUTION_TIME;
if (opts.maxPending === Infinity || (Number.isInteger(opts.maxPending) && opts.maxPending >= 0)) {
this.maxPending = opts.maxPending;
} else {
this.maxPending = AsyncLock.DEFAULT_MAX_PENDING;
}
};
AsyncLock.DEFAULT_TIMEOUT = 0; //Never
AsyncLock.DEFAULT_MAX_OCCUPATION_TIME = 0; //Never
AsyncLock.DEFAULT_MAX_EXECUTION_TIME = 0; //Never
AsyncLock.DEFAULT_MAX_PENDING = 1000;
/**
* Acquire Locks
*
* @param {String|Array} key resource key or keys to lock
* @param {function} fn async function
* @param {function} cb callback function, otherwise will return a promise
* @param {Object} opts options
*/
AsyncLock.prototype.acquire = function (key, fn, cb, opts) {
if (Array.isArray(key)) {
return this._acquireBatch(key, fn, cb, opts);
}
if (typeof (fn) !== 'function') {
throw new Error('You must pass a function to execute');
}
// faux-deferred promise using new Promise() (as Promise.defer is deprecated)
var deferredResolve = null;
var deferredReject = null;
var deferred = null;
if (typeof (cb) !== 'function') {
opts = cb;
cb = null;
// will return a promise
deferred = new this.Promise(function(resolve, reject) {
deferredResolve = resolve;
deferredReject = reject;
});
}
opts = opts || {};
var resolved = false;
var timer = null;
var occupationTimer = null;
var executionTimer = null;
var self = this;
var done = function (locked, err, ret) {
if (occupationTimer) {
clearTimeout(occupationTimer);
occupationTimer = null;
}
if (executionTimer) {
clearTimeout(executionTimer);
executionTimer = null;
}
if (locked) {
if (!!self.queues[key] && self.queues[key].length === 0) {
delete self.queues[key];
}
if (self.domainReentrant) {
delete self.domains[key];
}
}
if (!resolved) {
if (!deferred) {
if (typeof (cb) === 'function') {
cb(err, ret);
}
}
else {
//promise mode
if (err) {
deferredReject(err);
}
else {
deferredResolve(ret);
}
}
resolved = true;
}
if (locked) {
//run next func
if (!!self.queues[key] && self.queues[key].length > 0) {
self.queues[key].shift()();
}
}
};
var exec = function (locked) {
if (resolved) { // may due to timed out
return done(locked);
}
if (timer) {
clearTimeout(timer);
timer = null;
}
if (self.domainReentrant && locked) {
self.domains[key] = process.domain;
}
var maxExecutionTime = opts.maxExecutionTime || self.maxExecutionTime;
if (maxExecutionTime) {
executionTimer = setTimeout(function () {
if (!!self.queues[key]) {
done(locked, new Error('Maximum execution time is exceeded ' + key));
}
}, maxExecutionTime);
}
// Callback mode
if (fn.length === 1) {
var called = false;
try {
fn(function (err, ret) {
if (!called) {
called = true;
done(locked, err, ret);
}
});
} catch (err) {
// catching error thrown in user function fn
if (!called) {
called = true;
done(locked, err);
}
}
}
else {
// Promise mode
self._promiseTry(function () {
return fn();
})
.then(function(ret){
done(locked, undefined, ret);
}, function(error){
done(locked, error);
});
}
};
if (self.domainReentrant && !!process.domain) {
exec = process.domain.bind(exec);
}
var maxPending = opts.maxPending || self.maxPending;
if (!self.queues[key]) {
self.queues[key] = [];
exec(true);
}
else if (self.domainReentrant && !!process.domain && process.domain === self.domains[key]) {
// If code is in the same domain of current running task, run it directly
// Since lock is re-enterable
exec(false);
}
else if (self.queues[key].length >= maxPending) {
done(false, new Error('Too many pending tasks in queue ' + key));
}
else {
var taskFn = function () {
exec(true);
};
if (opts.skipQueue) {
self.queues[key].unshift(taskFn);
} else {
self.queues[key].push(taskFn);
}
var timeout = opts.timeout || self.timeout;
if (timeout) {
timer = setTimeout(function () {
timer = null;
done(false, new Error('async-lock timed out in queue ' + key));
}, timeout);
}
}
var maxOccupationTime = opts.maxOccupationTime || self.maxOccupationTime;
if (maxOccupationTime) {
occupationTimer = setTimeout(function () {
if (!!self.queues[key]) {
done(false, new Error('Maximum occupation time is exceeded in queue ' + key));
}
}, maxOccupationTime);
}
if (deferred) {
return deferred;
}
};
/*
* Below is how this function works:
*
* Equivalent code:
* self.acquire(key1, function(cb){
* self.acquire(key2, function(cb){
* self.acquire(key3, fn, cb);
* }, cb);
* }, cb);
*
* Equivalent code:
* var fn3 = getFn(key3, fn);
* var fn2 = getFn(key2, fn3);
* var fn1 = getFn(key1, fn2);
* fn1(cb);
*/
AsyncLock.prototype._acquireBatch = function (keys, fn, cb, opts) {
if (typeof (cb) !== 'function') {
opts = cb;
cb = null;
}
var self = this;
var getFn = function (key, fn) {
return function (cb) {
self.acquire(key, fn, cb, opts);
};
};
var fnx = keys.reduceRight(function (prev, key) {
return getFn(key, prev);
}, fn);
if (typeof (cb) === 'function') {
fnx(cb);
}
else {
return new this.Promise(function (resolve, reject) {
// check for promise mode in case keys is empty array
if (fnx.length === 1) {
fnx(function (err, ret) {
if (err) {
reject(err);
}
else {
resolve(ret);
}
});
} else {
resolve(fnx());
}
});
}
};
/*
* Whether there is any running or pending asyncFunc
*
* @param {String} key
*/
AsyncLock.prototype.isBusy = function (key) {
if (!key) {
return Object.keys(this.queues).length > 0;
}
else {
return !!this.queues[key];
}
};
/**
* Promise.try() implementation to become independent of Q-specific methods
*/
AsyncLock.prototype._promiseTry = function(fn) {
try {
return this.Promise.resolve(fn());
} catch (e) {
return this.Promise.reject(e);
}
};
lib$5 = AsyncLock;
return lib$5;
}
var asyncLock;
var hasRequiredAsyncLock;
function requireAsyncLock () {
if (hasRequiredAsyncLock) return asyncLock;
hasRequiredAsyncLock = 1;
asyncLock = requireLib$5();
return asyncLock;
}
var inherits = {exports: {}};
var inherits_browser = {exports: {}};
var hasRequiredInherits_browser;
function requireInherits_browser () {
if (hasRequiredInherits_browser) return inherits_browser.exports;
hasRequiredInherits_browser = 1;
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
inherits_browser.exports = function inherits(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
}
};
} else {
// old school shim for old browsers
inherits_browser.exports = function inherits(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor;
var TempCtor = function () {};
TempCtor.prototype = superCtor.prototype;
ctor.prototype = new TempCtor();
ctor.prototype.constructor = ctor;
}
};
}
return inherits_browser.exports;
}
var hasRequiredInherits;
function requireInherits () {
if (hasRequiredInherits) return inherits.exports;
hasRequiredInherits = 1;
try {
var util = require('util');
/* istanbul ignore next */
if (typeof util.inherits !== 'function') throw '';
inherits.exports = util.inherits;
} catch (e) {
/* istanbul ignore next */
inherits.exports = requireInherits_browser();
}
return inherits.exports;
}
var safeBuffer = {exports: {}};
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
var hasRequiredSafeBuffer;
function requireSafeBuffer () {
if (hasRequiredSafeBuffer) return safeBuffer.exports;
hasRequiredSafeBuffer = 1;
(function (module, exports) {
/* eslint-disable node/no-deprecated-api */
var buffer = require$$0$2;
var Buffer = buffer.Buffer;
// alternative to using Object.keys for old browsers
function copyProps (src, dst) {
for (var key in src) {
dst[key] = src[key];
}
}
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
module.exports = buffer;
} else {
// Copy properties from require('buffer')
copyProps(buffer, exports);
exports.Buffer = SafeBuffer;
}
function SafeBuffer (arg, encodingOrOffset, length) {
return Buffer(arg, encodingOrOffset, length)
}
SafeBuffer.prototype = Object.create(Buffer.prototype);
// Copy static methods from Buffer
copyProps(Buffer, SafeBuffer);
SafeBuffer.from = function (arg, encodingOrOffset, length) {
if (typeof arg === 'number') {
throw new TypeError('Argument must not be a number')
}
return Buffer(arg, encodingOrOffset, length)
};
SafeBuffer.alloc = function (size, fill, encoding) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
var buf = Buffer(size);
if (fill !== undefined) {
if (typeof encoding === 'string') {
buf.fill(fill, encoding);
} else {
buf.fill(fill);
}
} else {
buf.fill(0);
}
return buf
};
SafeBuffer.allocUnsafe = function (size) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
return Buffer(size)
};
SafeBuffer.allocUnsafeSlow = function (size) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
return buffer.SlowBuffer(size)
};
} (safeBuffer, safeBuffer.exports));
return safeBuffer.exports;
}
var isarray;
var hasRequiredIsarray;
function requireIsarray () {
if (hasRequiredIsarray) return isarray;
hasRequiredIsarray = 1;
var toString = {}.toString;
isarray = Array.isArray || function (arr) {
return toString.call(arr) == '[object Array]';
};
return isarray;
}
var type;
var hasRequiredType;
function requireType () {
if (hasRequiredType) return type;
hasRequiredType = 1;
/** @type {import('./type')} */
type = TypeError;
return type;
}
var esObjectAtoms;
var hasRequiredEsObjectAtoms;
function requireEsObjectAtoms () {
if (hasRequiredEsObjectAtoms) return esObjectAtoms;
hasRequiredEsObjectAtoms = 1;
/** @type {import('.')} */
esObjectAtoms = Object;
return esObjectAtoms;
}
var esErrors;
var hasRequiredEsErrors;
function requireEsErrors () {
if (hasRequiredEsErrors) return esErrors;
hasRequiredEsErrors = 1;
/** @type {import('.')} */
esErrors = Error;
return esErrors;
}
var _eval;
var hasRequired_eval;
function require_eval () {
if (hasRequired_eval) return _eval;
hasRequired_eval = 1;
/** @type {import('./eval')} */
_eval = EvalError;
return _eval;
}
var range;
var hasRequiredRange;
function requireRange () {
if (hasRequiredRange) return range;
hasRequiredRange = 1;
/** @type {import('./range')} */
range = RangeError;
return range;
}
var ref$1;
var hasRequiredRef$1;
function requireRef$1 () {
if (hasRequiredRef$1) return ref$1;
hasRequiredRef$1 = 1;
/** @type {import('./ref')} */
ref$1 = ReferenceError;
return ref$1;
}
var syntax;
var hasRequiredSyntax;
function requireSyntax () {
if (hasRequiredSyntax) return syntax;
hasRequiredSyntax = 1;
/** @type {import('./syntax')} */
syntax = SyntaxError;
return syntax;
}
var uri$1;
var hasRequiredUri$1;
function requireUri$1 () {
if (hasRequiredUri$1) return uri$1;
hasRequiredUri$1 = 1;
/** @type {import('./uri')} */
uri$1 = URIError;
return uri$1;
}
var abs;
var hasRequiredAbs;
function requireAbs () {
if (hasRequiredAbs) return abs;
hasRequiredAbs = 1;
/** @type {import('./abs')} */
abs = Math.abs;
return abs;
}
var floor;
var hasRequiredFloor;
function requireFloor () {
if (hasRequiredFloor) return floor;
hasRequiredFloor = 1;
/** @type {import('./floor')} */
floor = Math.floor;
return floor;
}
var max;
var hasRequiredMax;
function requireMax () {
if (hasRequiredMax) return max