new license file version [CI SKIP]

This commit is contained in:
2023-03-15 13:43:57 +00:00
parent d8a3063735
commit 00359d25c1
5600 changed files with 523898 additions and 2 deletions

View File

@@ -0,0 +1 @@
{"version":3,"file":"iterator.js","sources":["../../src/internal/symbol/iterator.ts"],"names":[],"mappings":";;AAAA,SAAgB,iBAAiB;IAC/B,IAAI,OAAO,MAAM,KAAK,UAAU,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;QACpD,OAAO,YAAmB,CAAC;KAC5B;IAED,OAAO,MAAM,CAAC,QAAQ,CAAC;AACzB,CAAC;AAND,8CAMC;AAEY,QAAA,QAAQ,GAAG,iBAAiB,EAAE,CAAC;AAK/B,QAAA,UAAU,GAAG,gBAAQ,CAAC"}

View File

@@ -0,0 +1 @@
{"version":3,"file":"isIterable.js","sources":["../src/util/isIterable.ts"],"names":[],"mappings":";;;;;AAAA,iDAA4C"}

View File

@@ -0,0 +1,252 @@
'use strict';
var formats = require('./formats');
var has = Object.prototype.hasOwnProperty;
var isArray = Array.isArray;
var hexTable = (function () {
var array = [];
for (var i = 0; i < 256; ++i) {
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
}
return array;
}());
var compactQueue = function compactQueue(queue) {
while (queue.length > 1) {
var item = queue.pop();
var obj = item.obj[item.prop];
if (isArray(obj)) {
var compacted = [];
for (var j = 0; j < obj.length; ++j) {
if (typeof obj[j] !== 'undefined') {
compacted.push(obj[j]);
}
}
item.obj[item.prop] = compacted;
}
}
};
var arrayToObject = function arrayToObject(source, options) {
var obj = options && options.plainObjects ? Object.create(null) : {};
for (var i = 0; i < source.length; ++i) {
if (typeof source[i] !== 'undefined') {
obj[i] = source[i];
}
}
return obj;
};
var merge = function merge(target, source, options) {
/* eslint no-param-reassign: 0 */
if (!source) {
return target;
}
if (typeof source !== 'object') {
if (isArray(target)) {
target.push(source);
} else if (target && typeof target === 'object') {
if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
target[source] = true;
}
} else {
return [target, source];
}
return target;
}
if (!target || typeof target !== 'object') {
return [target].concat(source);
}
var mergeTarget = target;
if (isArray(target) && !isArray(source)) {
mergeTarget = arrayToObject(target, options);
}
if (isArray(target) && isArray(source)) {
source.forEach(function (item, i) {
if (has.call(target, i)) {
var targetItem = target[i];
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
target[i] = merge(targetItem, item, options);
} else {
target.push(item);
}
} else {
target[i] = item;
}
});
return target;
}
return Object.keys(source).reduce(function (acc, key) {
var value = source[key];
if (has.call(acc, key)) {
acc[key] = merge(acc[key], value, options);
} else {
acc[key] = value;
}
return acc;
}, mergeTarget);
};
var assign = function assignSingleSource(target, source) {
return Object.keys(source).reduce(function (acc, key) {
acc[key] = source[key];
return acc;
}, target);
};
var decode = function (str, decoder, charset) {
var strWithoutPlus = str.replace(/\+/g, ' ');
if (charset === 'iso-8859-1') {
// unescape never throws, no try...catch needed:
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
}
// utf-8
try {
return decodeURIComponent(strWithoutPlus);
} catch (e) {
return strWithoutPlus;
}
};
var encode = function encode(str, defaultEncoder, charset, kind, format) {
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
// It has been adapted here for stricter adherence to RFC 3986
if (str.length === 0) {
return str;
}
var string = str;
if (typeof str === 'symbol') {
string = Symbol.prototype.toString.call(str);
} else if (typeof str !== 'string') {
string = String(str);
}
if (charset === 'iso-8859-1') {
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
});
}
var out = '';
for (var i = 0; i < string.length; ++i) {
var c = string.charCodeAt(i);
if (
c === 0x2D // -
|| c === 0x2E // .
|| c === 0x5F // _
|| c === 0x7E // ~
|| (c >= 0x30 && c <= 0x39) // 0-9
|| (c >= 0x41 && c <= 0x5A) // a-z
|| (c >= 0x61 && c <= 0x7A) // A-Z
|| (format === formats.RFC1738 && (c === 0x28 || c === 0x29)) // ( )
) {
out += string.charAt(i);
continue;
}
if (c < 0x80) {
out = out + hexTable[c];
continue;
}
if (c < 0x800) {
out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
continue;
}
if (c < 0xD800 || c >= 0xE000) {
out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
continue;
}
i += 1;
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
/* eslint operator-linebreak: [2, "before"] */
out += hexTable[0xF0 | (c >> 18)]
+ hexTable[0x80 | ((c >> 12) & 0x3F)]
+ hexTable[0x80 | ((c >> 6) & 0x3F)]
+ hexTable[0x80 | (c & 0x3F)];
}
return out;
};
var compact = function compact(value) {
var queue = [{ obj: { o: value }, prop: 'o' }];
var refs = [];
for (var i = 0; i < queue.length; ++i) {
var item = queue[i];
var obj = item.obj[item.prop];
var keys = Object.keys(obj);
for (var j = 0; j < keys.length; ++j) {
var key = keys[j];
var val = obj[key];
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
queue.push({ obj: obj, prop: key });
refs.push(val);
}
}
}
compactQueue(queue);
return value;
};
var isRegExp = function isRegExp(obj) {
return Object.prototype.toString.call(obj) === '[object RegExp]';
};
var isBuffer = function isBuffer(obj) {
if (!obj || typeof obj !== 'object') {
return false;
}
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
};
var combine = function combine(a, b) {
return [].concat(a, b);
};
var maybeMap = function maybeMap(val, fn) {
if (isArray(val)) {
var mapped = [];
for (var i = 0; i < val.length; i += 1) {
mapped.push(fn(val[i]));
}
return mapped;
}
return fn(val);
};
module.exports = {
arrayToObject: arrayToObject,
assign: assign,
combine: combine,
compact: compact,
decode: decode,
encode: encode,
isBuffer: isBuffer,
isRegExp: isRegExp,
maybeMap: maybeMap,
merge: merge
};

View File

@@ -0,0 +1,7 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("rxjs-compat/operators/last"));
//# sourceMappingURL=last.js.map

View File

@@ -0,0 +1,59 @@
{
"name": "parse-url",
"version": "6.0.5",
"description": "An advanced url parser supporting git urls too.",
"main": "lib/index.js",
"directories": {
"example": "example",
"test": "test"
},
"scripts": {
"test": "node test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/IonicaBizau/parse-url.git"
},
"keywords": [
"parse",
"url",
"node",
"git",
"advanced"
],
"author": "Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)",
"license": "MIT",
"bugs": {
"url": "https://github.com/IonicaBizau/parse-url/issues"
},
"homepage": "https://github.com/IonicaBizau/parse-url",
"devDependencies": {
"tester": "^1.3.1"
},
"dependencies": {
"is-ssh": "^1.3.0",
"normalize-url": "^6.1.0",
"parse-path": "^4.0.0",
"protocols": "^1.4.0"
},
"files": [
"bin/",
"app/",
"lib/",
"dist/",
"src/",
"scripts/",
"resources/",
"menu/",
"cli.js",
"index.js",
"bloggify.js",
"bloggify.json",
"bloggify/"
],
"blah": {
"description": [
"For low-level path parsing, check out [`parse-path`](https://github.com/IonicaBizau/parse-path). This very module is designed to parse urls. By default the urls are normalized."
]
}
}

View File

@@ -0,0 +1,16 @@
declare const hasYarn: {
/**
* Check if a project is using [Yarn](https://yarnpkg.com).
*
* @param cwd - Current working directory. Default: `process.cwd()`.
* @returns Whether the project uses Yarn.
*/
(cwd?: string): boolean;
// TODO: Remove this for the next major release, refactor the whole definition to:
// declare function hasYarn(cwd?: string): boolean;
// export = hasYarn;
default: typeof hasYarn;
};
export = hasYarn;

View File

@@ -0,0 +1,49 @@
import { Observable } from '../Observable';
import { MonoTypeOperatorFunction } from '../types';
/**
* Returns an Observable that emits the single item emitted by the source Observable that matches a specified
* predicate, if that Observable emits one such item. If the source Observable emits more than one such item or no
* items, notify of an IllegalArgumentException or NoSuchElementException respectively. If the source Observable
* emits items but none match the specified predicate then `undefined` is emitted.
*
* <span class="informal">Like {@link first}, but emit with error notification if there is more than one value.</span>
* ![](single.png)
*
* ## Example
* emits 'error'
* ```ts
* import { range } from 'rxjs';
* import { single } from 'rxjs/operators';
*
* const numbers = range(1,5).pipe(single());
* numbers.subscribe(x => console.log('never get called'), e => console.log('error'));
* // result
* // 'error'
* ```
*
* emits 'undefined'
* ```ts
* import { range } from 'rxjs';
* import { single } from 'rxjs/operators';
*
* const numbers = range(1,5).pipe(single(x => x === 10));
* numbers.subscribe(x => console.log(x));
* // result
* // 'undefined'
* ```
*
* @see {@link first}
* @see {@link find}
* @see {@link findIndex}
* @see {@link elementAt}
*
* @throws {EmptyError} Delivers an EmptyError to the Observer's `error`
* callback if the Observable completes before any `next` notification was sent.
* @param {Function} predicate - A predicate function to evaluate items emitted by the source Observable.
* @return {Observable<T>} An Observable that emits the single item emitted by the source Observable that matches
* the predicate or `undefined` when no items match.
*
* @method single
* @owner Observable
*/
export declare function single<T>(predicate?: (value: T, index: number, source: Observable<T>) => boolean): MonoTypeOperatorFunction<T>;

View File

@@ -0,0 +1,64 @@
{
"name": "human-signals",
"version": "1.1.1",
"main": "build/src/main.js",
"files": [
"build/src",
"!~"
],
"scripts": {
"test": "gulp test"
},
"husky": {
"hooks": {
"pre-push": "gulp check --full"
}
},
"description": "Human-friendly process signals",
"keywords": [
"signal",
"signals",
"handlers",
"error-handling",
"errors",
"interrupts",
"sigterm",
"sigint",
"irq",
"process",
"exit",
"exit-code",
"status",
"operating-system",
"es6",
"javascript",
"linux",
"macos",
"windows",
"nodejs"
],
"license": "Apache-2.0",
"homepage": "https://git.io/JeluP",
"repository": "ehmicky/human-signals",
"bugs": {
"url": "https://github.com/ehmicky/human-signals/issues"
},
"author": "ehmicky <ehmicky@gmail.com> (https://github.com/ehmicky)",
"directories": {
"lib": "src",
"test": "test"
},
"dependencies": {},
"devDependencies": {
"@ehmicky/dev-tasks": "^0.30.48",
"ajv": "^6.10.2",
"ava": "^2.4.0",
"fast-deep-equal": "^2.0.1",
"gulp": "^4.0.2",
"husky": "^3.0.9",
"test-each": "^1.7.2"
},
"engines": {
"node": ">=8.12.0"
}
}

View File

@@ -0,0 +1,7 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("rxjs-compat/operators/shareReplay"));
//# sourceMappingURL=shareReplay.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("rxjs-compat/add/operator/publishLast");
//# sourceMappingURL=publishLast.js.map

View File

@@ -0,0 +1,281 @@
'use strict';
/**
* `rawlist` type prompt
*/
var _ = {
uniq: require('lodash/uniq'),
isString: require('lodash/isString'),
isNumber: require('lodash/isNumber'),
findIndex: require('lodash/findIndex'),
};
var chalk = require('chalk');
var { map, takeUntil } = require('rxjs/operators');
var Base = require('./base');
var Separator = require('../objects/separator');
var observe = require('../utils/events');
var Paginator = require('../utils/paginator');
class ExpandPrompt extends Base {
constructor(questions, rl, answers) {
super(questions, rl, answers);
if (!this.opt.choices) {
this.throwParamError('choices');
}
this.validateChoices(this.opt.choices);
// Add the default `help` (/expand) option
this.opt.choices.push({
key: 'h',
name: 'Help, list all options',
value: 'help',
});
this.opt.validate = (choice) => {
if (choice == null) {
return 'Please enter a valid command';
}
return choice !== 'help';
};
// Setup the default string (capitalize the default key)
this.opt.default = this.generateChoicesString(this.opt.choices, this.opt.default);
this.paginator = new Paginator(this.screen);
}
/**
* Start the Inquiry session
* @param {Function} cb Callback when prompt is done
* @return {this}
*/
_run(cb) {
this.done = cb;
// Save user answer and update prompt to show selected option.
var events = observe(this.rl);
var validation = this.handleSubmitEvents(
events.line.pipe(map(this.getCurrentValue.bind(this)))
);
validation.success.forEach(this.onSubmit.bind(this));
validation.error.forEach(this.onError.bind(this));
this.keypressObs = events.keypress
.pipe(takeUntil(validation.success))
.forEach(this.onKeypress.bind(this));
// Init the prompt
this.render();
return this;
}
/**
* Render the prompt to screen
* @return {ExpandPrompt} self
*/
render(error, hint) {
var message = this.getQuestion();
var bottomContent = '';
if (this.status === 'answered') {
message += chalk.cyan(this.answer);
} else if (this.status === 'expanded') {
var choicesStr = renderChoices(this.opt.choices, this.selectedKey);
message += this.paginator.paginate(choicesStr, this.selectedKey, this.opt.pageSize);
message += '\n Answer: ';
}
message += this.rl.line;
if (error) {
bottomContent = chalk.red('>> ') + error;
}
if (hint) {
bottomContent = chalk.cyan('>> ') + hint;
}
this.screen.render(message, bottomContent);
}
getCurrentValue(input) {
if (!input) {
input = this.rawDefault;
}
var selected = this.opt.choices.where({ key: input.toLowerCase().trim() })[0];
if (!selected) {
return null;
}
return selected.value;
}
/**
* Generate the prompt choices string
* @return {String} Choices string
*/
getChoices() {
var output = '';
this.opt.choices.forEach((choice) => {
output += '\n ';
if (choice.type === 'separator') {
output += ' ' + choice;
return;
}
var choiceStr = choice.key + ') ' + choice.name;
if (this.selectedKey === choice.key) {
choiceStr = chalk.cyan(choiceStr);
}
output += choiceStr;
});
return output;
}
onError(state) {
if (state.value === 'help') {
this.selectedKey = '';
this.status = 'expanded';
this.render();
return;
}
this.render(state.isValid);
}
/**
* When user press `enter` key
*/
onSubmit(state) {
this.status = 'answered';
var choice = this.opt.choices.where({ value: state.value })[0];
this.answer = choice.short || choice.name;
// Re-render prompt
this.render();
this.screen.done();
this.done(state.value);
}
/**
* When user press a key
*/
onKeypress() {
this.selectedKey = this.rl.line.toLowerCase();
var selected = this.opt.choices.where({ key: this.selectedKey })[0];
if (this.status === 'expanded') {
this.render();
} else {
this.render(null, selected ? selected.name : null);
}
}
/**
* Validate the choices
* @param {Array} choices
*/
validateChoices(choices) {
var formatError;
var errors = [];
var keymap = {};
choices.filter(Separator.exclude).forEach((choice) => {
if (!choice.key || choice.key.length !== 1) {
formatError = true;
}
if (keymap[choice.key]) {
errors.push(choice.key);
}
keymap[choice.key] = true;
choice.key = String(choice.key).toLowerCase();
});
if (formatError) {
throw new Error(
'Format error: `key` param must be a single letter and is required.'
);
}
if (keymap.h) {
throw new Error(
'Reserved key error: `key` param cannot be `h` - this value is reserved.'
);
}
if (errors.length) {
throw new Error(
'Duplicate key error: `key` param must be unique. Duplicates: ' +
_.uniq(errors).join(', ')
);
}
}
/**
* Generate a string out of the choices keys
* @param {Array} choices
* @param {Number|String} default - the choice index or name to capitalize
* @return {String} The rendered choices key string
*/
generateChoicesString(choices, defaultChoice) {
var defIndex = choices.realLength - 1;
if (_.isNumber(defaultChoice) && this.opt.choices.getChoice(defaultChoice)) {
defIndex = defaultChoice;
} else if (_.isString(defaultChoice)) {
let index = _.findIndex(
choices.realChoices,
({ value }) => value === defaultChoice
);
defIndex = index === -1 ? defIndex : index;
}
var defStr = this.opt.choices.pluck('key');
this.rawDefault = defStr[defIndex];
defStr[defIndex] = String(defStr[defIndex]).toUpperCase();
return defStr.join('');
}
}
/**
* Function for rendering checkbox choices
* @param {String} pointer Selected key
* @return {String} Rendered content
*/
function renderChoices(choices, pointer) {
var output = '';
choices.forEach((choice) => {
output += '\n ';
if (choice.type === 'separator') {
output += ' ' + choice;
return;
}
var choiceStr = choice.key + ') ' + choice.name;
if (pointer === choice.key) {
choiceStr = chalk.cyan(choiceStr);
}
output += choiceStr;
});
return output;
}
module.exports = ExpandPrompt;

View File

@@ -0,0 +1 @@
module.exports={A:{A:{"2":"J E F G A B BC"},B:{"1":"Y Z a b c d f g h i j k l m n o p q r s D t","2":"C K L H M N O","66":"P Q R S T U V W X"},C:{"2":"0 1 2 3 4 5 6 7 8 9 CC tB I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB DC EC"},D:{"1":"Y Z a b c d f g h i j k l m n o p q r s D t xB yB FC","2":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB","66":"pB P Q R S T U V W X"},E:{"2":"I u J E F G A B C K L H GC zB HC IC JC KC 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC"},F:{"1":"nB oB pB P Q R wB S T U V W X Y Z a b c d","2":"0 1 2 3 4 5 6 7 8 9 G B C H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB OC PC QC RC qB 9B SC rB","66":"dB eB fB gB hB iB jB kB e lB mB"},G:{"2":"F zB TC AC UC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B"},H:{"2":"nC"},I:{"2":"tB I D oC pC qC rC AC sC tC"},J:{"2":"E A"},K:{"2":"A B C e qB 9B rB"},L:{"2":"D"},M:{"2":"D"},N:{"2":"A B"},O:{"2":"uC"},P:{"2":"I vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"2":"1B"},R:{"2":"8C"},S:{"2":"9C"}},B:7,C:"Web Serial API"};

View File

@@ -0,0 +1,31 @@
declare let global: any;
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
declare var WorkerGlobalScope: any;
// CommonJS / Node have global context exposed as "global" variable.
// We don't want to include the whole node.d.ts this this compilation unit so we'll just fake
// the global "global" var for now.
const __window = typeof window !== 'undefined' && window;
const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
self instanceof WorkerGlobalScope && self;
const __global = typeof global !== 'undefined' && global;
const _root: any = __window || __global || __self;
// Workaround Closure Compiler restriction: The body of a goog.module cannot use throw.
// This is needed when used with angular/tsickle which inserts a goog.module statement.
// Wrap in IIFE
(function () {
if (!_root) {
throw new Error('RxJS could not find any global context (window, self, global)');
}
})();
export { _root as root };

View File

@@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).uuidVersion=t()}(this,(function(){"use strict";var e=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;return function(t){if(!function(t){return"string"==typeof t&&e.test(t)}(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}}));

View File

@@ -0,0 +1 @@
export * from 'rxjs-compat/observable/ConnectableObservable';

View File

@@ -0,0 +1 @@
{"version":3,"file":"subscribeToIterable.js","sources":["../src/util/subscribeToIterable.ts"],"names":[],"mappings":";;;;;AAAA,0DAAqD"}

View File

@@ -0,0 +1 @@
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0.00768,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0.00768,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0.00512,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0.00256,"44":0,"45":0,"46":0,"47":0.00256,"48":0,"49":0,"50":0.00256,"51":0,"52":0.00512,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0.00256,"65":0,"66":0.00256,"67":0,"68":0.00256,"69":0,"70":0,"71":0,"72":0.00256,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0.00256,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0.00256,"92":0,"93":0.00256,"94":0.00256,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0.00512,"101":0.00256,"102":0.01024,"103":0.00256,"104":0.00512,"105":0.03071,"106":0.00768,"107":0.02047,"108":0.3557,"109":0.24311,"110":0.01791,"111":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0.01024,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0.00256,"51":0,"52":0,"53":0,"54":0.00256,"55":0,"56":0.00512,"57":0,"58":0,"59":0.00256,"60":0,"61":0,"62":0,"63":0,"64":0.00512,"65":0.00256,"66":0,"67":0,"68":0,"69":0,"70":0.00256,"71":0,"72":0.00512,"73":0,"74":0.00512,"75":0.00256,"76":0,"77":0.00256,"78":0.00256,"79":0.00512,"80":0.00256,"81":0.00768,"83":0.00256,"84":0,"85":0.00256,"86":0.00512,"87":0.00768,"88":0.00256,"89":0.00512,"90":0.00256,"91":0.00256,"92":0.0128,"93":0.00768,"94":0.00768,"95":0.01024,"96":0.00512,"97":0.00256,"98":0.00256,"99":0.00768,"100":0.00512,"101":0.00512,"102":0.00512,"103":0.02815,"104":0.01535,"105":0.01791,"106":0.01791,"107":0.0563,"108":1.49702,"109":1.41001,"110":0.00256,"111":0,"112":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0.00256,"21":0,"22":0,"23":0,"24":0.00256,"25":0,"26":0,"27":0.00256,"28":0.00768,"29":0,"30":0,"31":0,"32":0.00256,"33":0.0128,"34":0,"35":0,"36":0,"37":0.0128,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0.00512,"48":0,"49":0,"50":0.00256,"51":0.00256,"52":0,"53":0,"54":0.00256,"55":0.00256,"56":0,"57":0.01535,"58":0.02047,"60":0.05374,"62":0,"63":0.1996,"64":0.08701,"65":0.0435,"66":0.21496,"67":0.01791,"68":0,"69":0,"70":0,"71":0,"72":0.00256,"73":0.01024,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0.00256,"93":0.01024,"94":0.14075,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0.01791},B:{"12":0.00768,"13":0.00256,"14":0.00256,"15":0.00256,"16":0.00256,"17":0,"18":0.0128,"79":0,"80":0,"81":0,"83":0,"84":0.00256,"85":0,"86":0,"87":0,"88":0,"89":0.00256,"90":0.00256,"91":0,"92":0.00512,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0.00256,"101":0,"102":0,"103":0.00256,"104":0.00256,"105":0.00256,"106":0.00256,"107":0.01535,"108":0.23287,"109":0.19448},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0.00256,"12":0,"13":0,"14":0.00256,"15":0,_:"0","3.1":0,"3.2":0,"5.1":0.01024,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0,"12.1":0,"13.1":0.00512,"14.1":0.00768,"15.1":0,"15.2-15.3":0.00256,"15.4":0.00256,"15.5":0.00512,"15.6":0.02303,"16.0":0.00256,"16.1":0.01535,"16.2":0.0128,"16.3":0},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00135,"5.0-5.1":0.00135,"6.0-6.1":0.00135,"7.0-7.1":0.01547,"8.1-8.4":0.00067,"9.0-9.2":0.00269,"9.3":0.03835,"10.0-10.2":0,"10.3":0.06391,"11.0-11.2":0.00269,"11.3-11.4":0.00538,"12.0-12.1":0.00875,"12.2-12.5":0.63978,"13.0-13.1":0.02422,"13.2":0.00942,"13.3":0.03027,"13.4-13.7":0.05718,"14.0-14.4":0.37068,"14.5-14.8":0.41172,"15.0-15.1":0.26304,"15.2-15.3":0.35655,"15.4":0.24488,"15.5":0.34983,"15.6":0.47428,"16.0":0.61287,"16.1":1.03871,"16.2":1.02391,"16.3":0.07064},P:{"4":0.11505,"5.0-5.4":0.01046,"6.2-6.4":0,"7.2-7.4":0.11505,"8.2":0,"9.2":0.11505,"10.1":0,"11.1-11.2":0.03138,"12.0":0,"13.0":0.02092,"14.0":0.07321,"15.0":0.04184,"16.0":0.06275,"17.0":0.0523,"18.0":0.11505,"19.0":0.74259},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0.00756,"4.2-4.3":0.00945,"4.4":0,"4.4.3-4.4.4":0.22881},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0,"9":0,"10":0,"11":0.0435,"5.5":0},J:{"7":0,"10":0.00744},N:{"10":0,"11":0},S:{"2.5":0.40926},R:{_:"0"},M:{"0":0.26788},Q:{"13.1":0},O:{"0":0.63249},H:{"0":16.49154},L:{"0":63.30675}};

View File

@@ -0,0 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isArray = (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();
//# sourceMappingURL=isArray.js.map

View File

@@ -0,0 +1,382 @@
import { assertNotStrictEqual, } from './typings/common-types.js';
import { isPromise } from './utils/is-promise.js';
import { applyMiddleware, commandMiddlewareFactory, } from './middleware.js';
import { parseCommand } from './parse-command.js';
import { isYargsInstance, } from './yargs-factory.js';
import whichModule from './utils/which-module.js';
const DEFAULT_MARKER = /(^\*)|(^\$0)/;
export function command(yargs, usage, validation, globalMiddleware = [], shim) {
const self = {};
let handlers = {};
let aliasMap = {};
let defaultCommand;
self.addHandler = function addHandler(cmd, description, builder, handler, commandMiddleware, deprecated) {
let aliases = [];
const middlewares = commandMiddlewareFactory(commandMiddleware);
handler = handler || (() => { });
if (Array.isArray(cmd)) {
if (isCommandAndAliases(cmd)) {
[cmd, ...aliases] = cmd;
}
else {
for (const command of cmd) {
self.addHandler(command);
}
}
}
else if (isCommandHandlerDefinition(cmd)) {
let command = Array.isArray(cmd.command) || typeof cmd.command === 'string'
? cmd.command
: moduleName(cmd);
if (cmd.aliases)
command = [].concat(command).concat(cmd.aliases);
self.addHandler(command, extractDesc(cmd), cmd.builder, cmd.handler, cmd.middlewares, cmd.deprecated);
return;
}
else if (isCommandBuilderDefinition(builder)) {
self.addHandler([cmd].concat(aliases), description, builder.builder, builder.handler, builder.middlewares, builder.deprecated);
return;
}
if (typeof cmd === 'string') {
const parsedCommand = parseCommand(cmd);
aliases = aliases.map(alias => parseCommand(alias).cmd);
let isDefault = false;
const parsedAliases = [parsedCommand.cmd].concat(aliases).filter(c => {
if (DEFAULT_MARKER.test(c)) {
isDefault = true;
return false;
}
return true;
});
if (parsedAliases.length === 0 && isDefault)
parsedAliases.push('$0');
if (isDefault) {
parsedCommand.cmd = parsedAliases[0];
aliases = parsedAliases.slice(1);
cmd = cmd.replace(DEFAULT_MARKER, parsedCommand.cmd);
}
aliases.forEach(alias => {
aliasMap[alias] = parsedCommand.cmd;
});
if (description !== false) {
usage.command(cmd, description, isDefault, aliases, deprecated);
}
handlers[parsedCommand.cmd] = {
original: cmd,
description,
handler,
builder: builder || {},
middlewares,
deprecated,
demanded: parsedCommand.demanded,
optional: parsedCommand.optional,
};
if (isDefault)
defaultCommand = handlers[parsedCommand.cmd];
}
};
self.addDirectory = function addDirectory(dir, context, req, callerFile, opts) {
opts = opts || {};
if (typeof opts.recurse !== 'boolean')
opts.recurse = false;
if (!Array.isArray(opts.extensions))
opts.extensions = ['js'];
const parentVisit = typeof opts.visit === 'function' ? opts.visit : (o) => o;
opts.visit = function visit(obj, joined, filename) {
const visited = parentVisit(obj, joined, filename);
if (visited) {
if (~context.files.indexOf(joined))
return visited;
context.files.push(joined);
self.addHandler(visited);
}
return visited;
};
shim.requireDirectory({ require: req, filename: callerFile }, dir, opts);
};
function moduleName(obj) {
const mod = whichModule(obj);
if (!mod)
throw new Error(`No command name given for module: ${shim.inspect(obj)}`);
return commandFromFilename(mod.filename);
}
function commandFromFilename(filename) {
return shim.path.basename(filename, shim.path.extname(filename));
}
function extractDesc({ describe, description, desc, }) {
for (const test of [describe, description, desc]) {
if (typeof test === 'string' || test === false)
return test;
assertNotStrictEqual(test, true, shim);
}
return false;
}
self.getCommands = () => Object.keys(handlers).concat(Object.keys(aliasMap));
self.getCommandHandlers = () => handlers;
self.hasDefaultCommand = () => !!defaultCommand;
self.runCommand = function runCommand(command, yargs, parsed, commandIndex) {
let aliases = parsed.aliases;
const commandHandler = handlers[command] || handlers[aliasMap[command]] || defaultCommand;
const currentContext = yargs.getContext();
let numFiles = currentContext.files.length;
const parentCommands = currentContext.commands.slice();
let innerArgv = parsed.argv;
let positionalMap = {};
if (command) {
currentContext.commands.push(command);
currentContext.fullCommands.push(commandHandler.original);
}
const builder = commandHandler.builder;
if (isCommandBuilderCallback(builder)) {
const builderOutput = builder(yargs.reset(parsed.aliases));
const innerYargs = isYargsInstance(builderOutput) ? builderOutput : yargs;
if (shouldUpdateUsage(innerYargs)) {
innerYargs
.getUsageInstance()
.usage(usageFromParentCommandsCommandHandler(parentCommands, commandHandler), commandHandler.description);
}
innerArgv = innerYargs._parseArgs(null, null, true, commandIndex);
aliases = innerYargs.parsed.aliases;
}
else if (isCommandBuilderOptionDefinitions(builder)) {
const innerYargs = yargs.reset(parsed.aliases);
if (shouldUpdateUsage(innerYargs)) {
innerYargs
.getUsageInstance()
.usage(usageFromParentCommandsCommandHandler(parentCommands, commandHandler), commandHandler.description);
}
Object.keys(commandHandler.builder).forEach(key => {
innerYargs.option(key, builder[key]);
});
innerArgv = innerYargs._parseArgs(null, null, true, commandIndex);
aliases = innerYargs.parsed.aliases;
}
if (!yargs._hasOutput()) {
positionalMap = populatePositionals(commandHandler, innerArgv, currentContext);
}
const middlewares = globalMiddleware
.slice(0)
.concat(commandHandler.middlewares);
applyMiddleware(innerArgv, yargs, middlewares, true);
if (!yargs._hasOutput()) {
yargs._runValidation(innerArgv, aliases, positionalMap, yargs.parsed.error, !command);
}
if (commandHandler.handler && !yargs._hasOutput()) {
yargs._setHasOutput();
const populateDoubleDash = !!yargs.getOptions().configuration['populate--'];
yargs._postProcess(innerArgv, populateDoubleDash);
innerArgv = applyMiddleware(innerArgv, yargs, middlewares, false);
let handlerResult;
if (isPromise(innerArgv)) {
handlerResult = innerArgv.then(argv => commandHandler.handler(argv));
}
else {
handlerResult = commandHandler.handler(innerArgv);
}
const handlerFinishCommand = yargs.getHandlerFinishCommand();
if (isPromise(handlerResult)) {
yargs.getUsageInstance().cacheHelpMessage();
handlerResult
.then(value => {
if (handlerFinishCommand) {
handlerFinishCommand(value);
}
})
.catch(error => {
try {
yargs.getUsageInstance().fail(null, error);
}
catch (err) {
}
})
.then(() => {
yargs.getUsageInstance().clearCachedHelpMessage();
});
}
else {
if (handlerFinishCommand) {
handlerFinishCommand(handlerResult);
}
}
}
if (command) {
currentContext.commands.pop();
currentContext.fullCommands.pop();
}
numFiles = currentContext.files.length - numFiles;
if (numFiles > 0)
currentContext.files.splice(numFiles * -1, numFiles);
return innerArgv;
};
function shouldUpdateUsage(yargs) {
return (!yargs.getUsageInstance().getUsageDisabled() &&
yargs.getUsageInstance().getUsage().length === 0);
}
function usageFromParentCommandsCommandHandler(parentCommands, commandHandler) {
const c = DEFAULT_MARKER.test(commandHandler.original)
? commandHandler.original.replace(DEFAULT_MARKER, '').trim()
: commandHandler.original;
const pc = parentCommands.filter(c => {
return !DEFAULT_MARKER.test(c);
});
pc.push(c);
return `$0 ${pc.join(' ')}`;
}
self.runDefaultBuilderOn = function (yargs) {
assertNotStrictEqual(defaultCommand, undefined, shim);
if (shouldUpdateUsage(yargs)) {
const commandString = DEFAULT_MARKER.test(defaultCommand.original)
? defaultCommand.original
: defaultCommand.original.replace(/^[^[\]<>]*/, '$0 ');
yargs.getUsageInstance().usage(commandString, defaultCommand.description);
}
const builder = defaultCommand.builder;
if (isCommandBuilderCallback(builder)) {
builder(yargs);
}
else if (!isCommandBuilderDefinition(builder)) {
Object.keys(builder).forEach(key => {
yargs.option(key, builder[key]);
});
}
};
function populatePositionals(commandHandler, argv, context) {
argv._ = argv._.slice(context.commands.length);
const demanded = commandHandler.demanded.slice(0);
const optional = commandHandler.optional.slice(0);
const positionalMap = {};
validation.positionalCount(demanded.length, argv._.length);
while (demanded.length) {
const demand = demanded.shift();
populatePositional(demand, argv, positionalMap);
}
while (optional.length) {
const maybe = optional.shift();
populatePositional(maybe, argv, positionalMap);
}
argv._ = context.commands.concat(argv._.map(a => '' + a));
postProcessPositionals(argv, positionalMap, self.cmdToParseOptions(commandHandler.original));
return positionalMap;
}
function populatePositional(positional, argv, positionalMap) {
const cmd = positional.cmd[0];
if (positional.variadic) {
positionalMap[cmd] = argv._.splice(0).map(String);
}
else {
if (argv._.length)
positionalMap[cmd] = [String(argv._.shift())];
}
}
function postProcessPositionals(argv, positionalMap, parseOptions) {
const options = Object.assign({}, yargs.getOptions());
options.default = Object.assign(parseOptions.default, options.default);
for (const key of Object.keys(parseOptions.alias)) {
options.alias[key] = (options.alias[key] || []).concat(parseOptions.alias[key]);
}
options.array = options.array.concat(parseOptions.array);
options.config = {};
const unparsed = [];
Object.keys(positionalMap).forEach(key => {
positionalMap[key].map(value => {
if (options.configuration['unknown-options-as-args'])
options.key[key] = true;
unparsed.push(`--${key}`);
unparsed.push(value);
});
});
if (!unparsed.length)
return;
const config = Object.assign({}, options.configuration, {
'populate--': true,
});
const parsed = shim.Parser.detailed(unparsed, Object.assign({}, options, {
configuration: config,
}));
if (parsed.error) {
yargs.getUsageInstance().fail(parsed.error.message, parsed.error);
}
else {
const positionalKeys = Object.keys(positionalMap);
Object.keys(positionalMap).forEach(key => {
positionalKeys.push(...parsed.aliases[key]);
});
Object.keys(parsed.argv).forEach(key => {
if (positionalKeys.indexOf(key) !== -1) {
if (!positionalMap[key])
positionalMap[key] = parsed.argv[key];
argv[key] = parsed.argv[key];
}
});
}
}
self.cmdToParseOptions = function (cmdString) {
const parseOptions = {
array: [],
default: {},
alias: {},
demand: {},
};
const parsed = parseCommand(cmdString);
parsed.demanded.forEach(d => {
const [cmd, ...aliases] = d.cmd;
if (d.variadic) {
parseOptions.array.push(cmd);
parseOptions.default[cmd] = [];
}
parseOptions.alias[cmd] = aliases;
parseOptions.demand[cmd] = true;
});
parsed.optional.forEach(o => {
const [cmd, ...aliases] = o.cmd;
if (o.variadic) {
parseOptions.array.push(cmd);
parseOptions.default[cmd] = [];
}
parseOptions.alias[cmd] = aliases;
});
return parseOptions;
};
self.reset = () => {
handlers = {};
aliasMap = {};
defaultCommand = undefined;
return self;
};
const frozens = [];
self.freeze = () => {
frozens.push({
handlers,
aliasMap,
defaultCommand,
});
};
self.unfreeze = () => {
const frozen = frozens.pop();
assertNotStrictEqual(frozen, undefined, shim);
({ handlers, aliasMap, defaultCommand } = frozen);
};
return self;
}
export function isCommandBuilderDefinition(builder) {
return (typeof builder === 'object' &&
!!builder.builder &&
typeof builder.handler === 'function');
}
function isCommandAndAliases(cmd) {
if (cmd.every(c => typeof c === 'string')) {
return true;
}
else {
return false;
}
}
export function isCommandBuilderCallback(builder) {
return typeof builder === 'function';
}
function isCommandBuilderOptionDefinitions(builder) {
return typeof builder === 'object';
}
export function isCommandHandlerDefinition(cmd) {
return typeof cmd === 'object' && !Array.isArray(cmd);
}