From 546c02fe889a881d7acf831b7f4b17267774720f Mon Sep 17 00:00:00 2001 From: coderiaser Date: Wed, 23 Oct 2024 14:28:16 +0300 Subject: [PATCH] chore: @putout/bundle: v3.17.0 --- ChangeLog | 7 + bundle/putout.js | 159021 ++++++++++++++++++++-------------------- bundle/putout.min.js | 2 +- package.json | 2 +- 4 files changed, 80870 insertions(+), 78162 deletions(-) diff --git a/ChangeLog b/ChangeLog index af76fcb..c3d4649 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024.10.23, v3.17.0 + +feature: +- f6d60ed @putout/bundle: hermes-parser v0.25.0 +- 0c2fe4d @putout/bundle: @rollup/plugin-replace v6.0.1 +- 909b454 @putout/bundle: @rollup/plugin-commonjs v28.0.1 + 2024.08.24, v3.16.1 feature: diff --git a/bundle/putout.js b/bundle/putout.js index 7530115..577e7c8 100644 --- a/bundle/putout.js +++ b/bundle/putout.js @@ -1,9 +1,5 @@ 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; -} - function getAugmentedNamespace(n) { if (n.__esModule) return n; var f = n.default; @@ -178,15 +174,15 @@ var versions = {}; var release$1 = {}; var config = {}; -function noop$4() {} +function noop() {} -var on = noop$4; -var addListener = noop$4; -var once$a = noop$4; -var off = noop$4; -var removeListener = noop$4; -var removeAllListeners = noop$4; -var emit = noop$4; +var on = noop; +var addListener = noop; +var once$1 = noop; +var off = noop; +var removeListener = noop; +var removeAllListeners = noop; +var emit = noop; function binding(name) { throw new Error('process.binding is not supported'); @@ -241,7 +237,7 @@ var browser$1$1 = { versions: versions, on: on, addListener: addListener, - once: once$a, + once: once$1, off: off, removeListener: removeListener, removeAllListeners: removeAllListeners, @@ -261,7 +257,7 @@ var lookup = []; var revLookup = []; var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array; var inited = false; -function init$2 () { +function init () { inited = true; var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; for (var i = 0, len = code.length; i < len; ++i) { @@ -275,7 +271,7 @@ function init$2 () { function toByteArray (b64) { if (!inited) { - init$2(); + init(); } var i, j, l, tmp, placeHolders, arr; var len = b64.length; @@ -334,7 +330,7 @@ function encodeChunk (uint8, start, end) { function fromByteArray (uint8) { if (!inited) { - init$2(); + init(); } var tmp; var len = uint8.length; @@ -454,7 +450,7 @@ function write (buffer, value, offset, isLE, mLen, nBytes) { var toString = {}.toString; -var isArray$g = Array.isArray || function (arr) { +var isArray$1 = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; @@ -738,7 +734,7 @@ function fromObject (that, obj) { return fromArrayLike(that, obj) } - if (obj.type === 'Buffer' && isArray$g(obj.data)) { + if (obj.type === 'Buffer' && isArray$1(obj.data)) { return fromArrayLike(that, obj.data) } } @@ -803,7 +799,7 @@ Buffer.isEncoding = function isEncoding (encoding) { }; Buffer.concat = function concat (list, length) { - if (!isArray$g(list)) { + if (!isArray$1(list)) { throw new TypeError('"list" argument must be an Array of Buffers') } @@ -2338,7 +2334,7 @@ function cpus() { return []; } -function type$1() { +function type() { return 'Browser'; } @@ -2386,7 +2382,7 @@ var _polyfillNode_os = { networkInterfaces:networkInterfaces, getNetworkInterfaces: getNetworkInterfaces, release: release, - type: type$1, + type: type, cpus: cpus, totalmem: totalmem, freemem: freemem, @@ -2414,15 +2410,15 @@ var _polyfillNode_os$1 = /*#__PURE__*/Object.freeze({ tmpDir: tmpDir, tmpdir: tmpdir, totalmem: totalmem, - type: type$1, + type: type, uptime: uptime }); var require$$4 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_os$1); -var inherits$1; +var inherits; if (typeof Object.create === 'function'){ - inherits$1 = function inherits(ctor, superCtor) { + inherits = function inherits(ctor, superCtor) { // implementation from standard node.js 'util' module ctor.super_ = superCtor; ctor.prototype = Object.create(superCtor.prototype, { @@ -2435,7 +2431,7 @@ if (typeof Object.create === 'function'){ }); }; } else { - inherits$1 = function inherits(ctor, superCtor) { + inherits = function inherits(ctor, superCtor) { ctor.super_ = superCtor; var TempCtor = function () {}; TempCtor.prototype = superCtor.prototype; @@ -2443,7 +2439,6 @@ if (typeof Object.create === 'function'){ ctor.prototype.constructor = ctor; }; } -var inherits$2 = inherits$1; var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function getOwnPropertyDescriptors(obj) { @@ -2457,7 +2452,7 @@ var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || var formatRegExp = /%[sdj%]/g; function format(f) { - if (!isString$c(f)) { + if (!isString(f)) { var objects = []; for (var i = 0; i < arguments.length; i++) { objects.push(inspect(arguments[i])); @@ -2485,7 +2480,7 @@ function format(f) { } }); for (var x = args[i]; i < len; x = args[++i]) { - if (isNull$1(x) || !isObject$6(x)) { + if (isNull(x) || !isObject(x)) { str += ' ' + x; } else { str += ' ' + inspect(x); @@ -2644,13 +2639,13 @@ function formatValue(ctx, value, recurseTimes) { // Check that value is an object with an inspect function on it if (ctx.customInspect && value && - isFunction$5(value.inspect) && + isFunction(value.inspect) && // Filter out the util module, it's inspect function is special value.inspect !== inspect && // Also filter out any prototype objects using the circular check. !(value.constructor && value.constructor.prototype === value)) { var ret = value.inspect(recurseTimes, ctx); - if (!isString$c(ret)) { + if (!isString(ret)) { ret = formatValue(ctx, ret, recurseTimes); } return ret; @@ -2679,11 +2674,11 @@ function formatValue(ctx, value, recurseTimes) { // Some type of object without properties can be shortcutted. if (keys.length === 0) { - if (isFunction$5(value)) { + if (isFunction(value)) { var name = value.name ? ': ' + value.name : ''; return ctx.stylize('[Function' + name + ']', 'special'); } - if (isRegExp$1(value)) { + if (isRegExp(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); } if (isDate(value)) { @@ -2697,19 +2692,19 @@ function formatValue(ctx, value, recurseTimes) { var base = '', array = false, braces = ['{', '}']; // Make Array say that they are Array - if (isArray$f(value)) { + if (isArray(value)) { array = true; braces = ['[', ']']; } // Make functions say that they are functions - if (isFunction$5(value)) { + if (isFunction(value)) { var n = value.name ? ': ' + value.name : ''; base = ' [Function' + n + ']'; } // Make RegExps say that they are RegExps - if (isRegExp$1(value)) { + if (isRegExp(value)) { base = ' ' + RegExp.prototype.toString.call(value); } @@ -2728,7 +2723,7 @@ function formatValue(ctx, value, recurseTimes) { } if (recurseTimes < 0) { - if (isRegExp$1(value)) { + if (isRegExp(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); } else { return ctx.stylize('[Object]', 'special'); @@ -2755,18 +2750,18 @@ function formatValue(ctx, value, recurseTimes) { function formatPrimitive(ctx, value) { if (isUndefined(value)) return ctx.stylize('undefined', 'undefined'); - if (isString$c(value)) { + if (isString(value)) { var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') .replace(/'/g, "\\'") .replace(/\\"/g, '"') + '\''; return ctx.stylize(simple, 'string'); } - if (isNumber$3(value)) + if (isNumber(value)) return ctx.stylize('' + value, 'number'); if (isBoolean(value)) return ctx.stylize('' + value, 'boolean'); // For some reason typeof null is "object", so special case here. - if (isNull$1(value)) + if (isNull(value)) return ctx.stylize('null', 'null'); } @@ -2815,7 +2810,7 @@ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { } if (!str) { if (ctx.seen.indexOf(desc.value) < 0) { - if (isNull$1(recurseTimes)) { + if (isNull(recurseTimes)) { str = formatValue(ctx, desc.value, null); } else { str = formatValue(ctx, desc.value, recurseTimes - 1); @@ -2876,7 +2871,7 @@ function reduceToSingleString(output, base, braces) { // NOTE: These type checking functions intentionally don't use `instanceof` // because it is fragile and can be easily faked with `Object.create()`. -function isArray$f(ar) { +function isArray(ar) { return Array.isArray(ar); } @@ -2884,7 +2879,7 @@ function isBoolean(arg) { return typeof arg === 'boolean'; } -function isNull$1(arg) { +function isNull(arg) { return arg === null; } @@ -2892,11 +2887,11 @@ function isNullOrUndefined(arg) { return arg == null; } -function isNumber$3(arg) { +function isNumber(arg) { return typeof arg === 'number'; } -function isString$c(arg) { +function isString(arg) { return typeof arg === 'string'; } @@ -2908,28 +2903,28 @@ function isUndefined(arg) { return arg === void 0; } -function isRegExp$1(re) { - return isObject$6(re) && objectToString$1(re) === '[object RegExp]'; +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; } -function isObject$6(arg) { +function isObject(arg) { return typeof arg === 'object' && arg !== null; } function isDate(d) { - return isObject$6(d) && objectToString$1(d) === '[object Date]'; + return isObject(d) && objectToString(d) === '[object Date]'; } function isError(e) { - return isObject$6(e) && - (objectToString$1(e) === '[object Error]' || e instanceof Error); + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); } -function isFunction$5(arg) { +function isFunction(arg) { return typeof arg === 'function'; } -function isPrimitive$1(arg) { +function isPrimitive(arg) { return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || @@ -2942,7 +2937,7 @@ function isBuffer(maybeBuf) { return Array.isArray(maybeBuf); } -function objectToString$1(o) { +function objectToString(o) { return Object.prototype.toString.call(o); } @@ -2966,13 +2961,13 @@ function timestamp() { // log is just a thin wrapper to console.log that prepends a timestamp -function log$6() { +function log$1() { console.log('%s - %s', timestamp(), format.apply(null, arguments)); } function _extend(origin, add) { // Don't do anything if add isn't an object - if (!add || !isObject$6(add)) return origin; + if (!add || !isObject(add)) return origin; var keys = Object.keys(add); var i = keys.length; @@ -3091,24 +3086,24 @@ function callbackify(original) { } var _polyfillNode_util = { - inherits: inherits$2, + inherits: inherits, _extend: _extend, - log: log$6, + log: log$1, isBuffer: isBuffer, - isPrimitive: isPrimitive$1, - isFunction: isFunction$5, + isPrimitive: isPrimitive, + isFunction: isFunction, isError: isError, isDate: isDate, - isObject: isObject$6, - isRegExp: isRegExp$1, + isObject: isObject, + isRegExp: isRegExp, isUndefined: isUndefined, isSymbol: isSymbol, - isString: isString$c, - isNumber: isNumber$3, + isString: isString, + isNumber: isNumber, isNullOrUndefined: isNullOrUndefined, - isNull: isNull$1, + isNull: isNull, isBoolean: isBoolean, - isArray: isArray$f, + isArray: isArray, inspect: inspect, deprecate: deprecate, format: format, @@ -3125,53735 +3120,53741 @@ var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({ default: _polyfillNode_util, deprecate: deprecate, format: format, - inherits: inherits$2, + inherits: inherits, inspect: inspect, - isArray: isArray$f, + isArray: isArray, isBoolean: isBoolean, isBuffer: isBuffer, isDate: isDate, isError: isError, - isFunction: isFunction$5, - isNull: isNull$1, + isFunction: isFunction, + isNull: isNull, isNullOrUndefined: isNullOrUndefined, - isNumber: isNumber$3, - isObject: isObject$6, - isPrimitive: isPrimitive$1, - isRegExp: isRegExp$1, - isString: isString$c, + isNumber: isNumber, + isObject: isObject, + isPrimitive: isPrimitive, + isRegExp: isRegExp, + isString: isString, isSymbol: isSymbol, isUndefined: isUndefined, - log: log$6, + log: log$1, promisify: promisify }); var require$$2$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_util$1); -function _array_like_to_array(arr, len) { - if (len == null || len > arr.length) len = arr.length; - for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i]; - return arr2; -} -function _array_with_holes(arr) { - if (Array.isArray(arr)) return arr; -} -function _array_without_holes(arr) { - if (Array.isArray(arr)) return _array_like_to_array(arr); -} -function _assert_this_initialized(self) { - if (self === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - return self; -} -function _class_call_check(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } -} -function _defineProperties(target, props) { - for(var i = 0; i < props.length; i++){ - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } -} -function _create_class(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - return Constructor; -} -function _define_property(obj, key, value1) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value1, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value1; - } - return obj; -} -function _get(target, property, receiver) { - if (typeof Reflect !== "undefined" && Reflect.get) { - _get = Reflect.get; - } else { - _get = function get(target, property, receiver) { - var base = _super_prop_base(target, property); - if (!base) return; - var desc = Object.getOwnPropertyDescriptor(base, property); - if (desc.get) { - return desc.get.call(receiver || target); - } - return desc.value; - }; - } - return _get(target, property, receiver || target); -} -function _get_prototype_of(o) { - _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return _get_prototype_of(o); -} -function _inherits$1(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } - }); - if (superClass) _set_prototype_of(subClass, superClass); -} -function _instanceof(left, right) { - if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { - return !!right[Symbol.hasInstance](left); - } else { - return left instanceof right; - } -} -function _iterable_to_array(iter) { - if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); -} -function _iterable_to_array_limit(arr, i) { - var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; - if (_i == null) return; - var _arr = []; - var _n = true; - var _d = false; - var _s, _e; - try { - for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){ - _arr.push(_s.value); - if (i && _arr.length === i) break; - } - } catch (err) { - _d = true; - _e = err; - } finally{ - try { - if (!_n && _i["return"] != null) _i["return"](); - } finally{ - if (_d) throw _e; - } - } - return _arr; -} -function _non_iterable_rest() { - throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} -function _non_iterable_spread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} -function _possible_constructor_return(self, call) { - if (call && (_type_of(call) === "object" || typeof call === "function")) { - return call; - } - return _assert_this_initialized(self); -} -function _set_prototype_of(o, p) { - _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - return _set_prototype_of(o, p); -} -function _sliced_to_array(arr, i) { - return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest(); -} -function _super_prop_base(object, property) { - while(!Object.prototype.hasOwnProperty.call(object, property)){ - object = _get_prototype_of(object); - if (object === null) break; - } - return object; -} -function _tagged_template_literal(strings, raw) { - if (!raw) { - raw = strings.slice(0); - } - return Object.freeze(Object.defineProperties(strings, { - raw: { - value: Object.freeze(raw) - } - })); -} -function _to_consumable_array(arr) { - return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread(); -} -function _type_of(obj) { - "@swc/helpers - typeof"; - return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; -} -function _unsupported_iterable_to_array(o, minLen) { - if (!o) return; - if (typeof o === "string") return _array_like_to_array(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(n); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen); -} -function _is_native_reflect_construct() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - if (Reflect.construct.sham) return false; - if (typeof Proxy === "function") return true; - try { - Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})); - return true; - } catch (e) { - return false; - } -} -function _create_super(Derived) { - var hasNativeReflectConstruct = _is_native_reflect_construct(); - return function _createSuperInternal() { - var Super = _get_prototype_of(Derived), result; - if (hasNativeReflectConstruct) { - var NewTarget = _get_prototype_of(this).constructor; - result = Reflect.construct(Super, arguments, NewTarget); - } else { - result = Super.apply(this, arguments); - } - return _possible_constructor_return(this, result); - }; -} -function _ts_generator(thisArg, body) { - var f, y, t, g, _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }; - return g = { - next: verb(0), - "throw": verb(1), - "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(_)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 - }; - } -} -function _templateObject() { - var data = _tagged_template_literal([ - "pipelineOperator" - ]); - _templateObject = function _templateObject() { - return data; - }; - return data; -} -function _templateObject1() { - var data = _tagged_template_literal([ - "flow" - ]); - _templateObject1 = function _templateObject() { - return data; - }; - return data; -} -function _templateObject2() { - var data = _tagged_template_literal([ - "jsx" - ]); - _templateObject2 = function _templateObject() { - return data; - }; - return data; -} -function _templateObject3() { - var data = _tagged_template_literal([ - "typescript" - ]); - _templateObject3 = function _templateObject() { - return data; - }; - return data; -} -function _templateObject4() { - var data = _tagged_template_literal([ - "placeholders" - ]); - _templateObject4 = function _templateObject() { - return data; - }; - return data; -} -function _templateObject5() { - var data = _tagged_template_literal([ - "\n (function (", - ") {\n function ", - "(", - ") {\n return ", - ".apply(this, arguments);\n }\n\n ", - ".toString = function () {\n return ", - ".toString();\n }\n\n return ", - ";\n })(", - ")\n " - ]); - _templateObject5 = function _templateObject() { - return data; - }; - return data; -} -var __create = Object.create; -var __defProp = Object.defineProperty; -var __getOwnPropDesc = Object.getOwnPropertyDescriptor; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __getProtoOf = Object.getPrototypeOf; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __defNormalProp = function(obj, key, value1) { - return key in obj ? __defProp(obj, key, { - enumerable: true, - configurable: true, - writable: true, - value: value1 - }) : obj[key] = value1; -}; -var __commonJS = function(cb, mod) { - return function __require() { - return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { - exports: {} - }).exports, mod), mod.exports; - }; -}; -var __export = function(target, all) { - for(var name in all)__defProp(target, name, { - get: all[name], - enumerable: true - }); -}; -var __copyProps = function(to, from, except, desc) { - if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") { - var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; - try { - var _loop = function() { - var key = _step.value; - if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { - get: function() { - return from[key]; - }, - enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable - }); - }; - for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop(); - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally{ - try { - if (!_iteratorNormalCompletion && _iterator.return != null) { - _iterator.return(); - } - } finally{ - if (_didIteratorError) { - throw _iteratorError; - } - } - } - } - return to; -}; -var __toESM = function(mod, isNodeMode, target) { - return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - __defProp(target, "default", { - value: mod, - enumerable: true - }) , mod); -}; -var __toCommonJS = function(mod) { - return __copyProps(__defProp({}, "__esModule", { - value: true - }), mod); -}; -var __publicField = function(obj, key, value1) { - return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value1); -}; -// node_modules/to-fast-properties/index.js -var require_to_fast_properties = __commonJS({ - "node_modules/to-fast-properties/index.js": function(exports2, module2) { - var fastProto = null; - function FastObject(o) { - if (fastProto !== null && _type_of(fastProto.property)) { - var result = fastProto; - fastProto = FastObject.prototype = null; - return result; - } - fastProto = FastObject.prototype = o == null ? /* @__PURE__ */ Object.create(null) : o; - return new FastObject(); - } - var inlineCacheCutoff = 10; - for(var i = 0; i <= inlineCacheCutoff; i++){ - FastObject(); - } - module2.exports = function toFastproperties(o) { - return FastObject(o); - }; - } -}); -// node_modules/js-tokens/index.js -var require_js_tokens = __commonJS({ - "node_modules/js-tokens/index.js": function(exports2, module2) { - var Identifier2; - var JSXIdentifier2; - var JSXPunctuator; - var JSXString; - var JSXText2; - var KeywordsWithExpressionAfter; - var KeywordsWithNoLineTerminatorAfter; - var LineTerminatorSequence; - var MultiLineComment; - var Newline; - var NumericLiteral3; - var Punctuator; - var RegularExpressionLiteral; - var SingleLineComment; - var StringLiteral3; - var Template; - var TokensNotPrecedingObjectLiteral; - var TokensPrecedingExpression; - var WhiteSpace; - RegularExpressionLiteral = RegExp("\\/(?![*\\/])(?:\\[(?:[^\\]\\\\\\n\\r\\u2028\\u2029]+|\\\\.)*\\]|[^\\/\\\\\\n\\r\\u2028\\u2029]+|\\\\.)*(\\/[$_\\u200C\\u200D\\p{ID_Continue}]*|\\\\)?", "yu"); - Punctuator = RegExp("--|\\+\\+|=>|\\.{3}|\\??\\.(?!\\d)|(?:&&|\\|\\||\\?\\?|[+\\-%&|^]|\\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\\/(?![\\/*]))=?|[?~,:;[\\](){}]", "y"); - Identifier2 = RegExp("(\\x23?)(?=[$_\\p{ID_Start}\\\\])(?:[$_\\u200C\\u200D\\p{ID_Continue}]+|\\\\u[\\da-fA-F]{4}|\\\\u\\{[\\da-fA-F]+\\})+", "yu"); - StringLiteral3 = RegExp("(['\"])(?:[^'\"\\\\\\n\\r]+|(?!\\1)['\"]|\\\\(?:\\r\\n|[^]))*(\\1)?", "y"); - NumericLiteral3 = RegExp("(?:0[xX][\\da-fA-F](?:_?[\\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\\d)*n|(?:(?:0(?!\\d)|0\\d*[89]\\d*|[1-9](?:_?\\d)*)(?:\\.(?:\\d(?:_?\\d)*)?)?|\\.\\d(?:_?\\d)*)(?:[eE][+-]?\\d(?:_?\\d)*)?|0[0-7]+", "y"); - Template = RegExp("[`}](?:[^`\\\\$]+|\\\\[^]|\\$(?!\\{))*(`|\\$\\{)?", "y"); - WhiteSpace = RegExp("[\\t\\v\\f\\ufeff\\p{Zs}]+", "yu"); - LineTerminatorSequence = RegExp("\\r?\\n|[\\r\\u2028\\u2029]", "y"); - MultiLineComment = RegExp("\\/\\*(?:[^*]+|\\*(?!\\/))*(\\*\\/)?", "y"); - SingleLineComment = RegExp("\\/\\/.*", "y"); - JSXPunctuator = RegExp("[<>.:={}]|\\/(?![\\/*])", "y"); - JSXIdentifier2 = RegExp("[$_\\p{ID_Start}][$_\\u200C\\u200D\\p{ID_Continue}-]*", "yu"); - JSXString = RegExp("(['\"])(?:[^'\"]+|(?!\\1)['\"])*(\\1)?", "y"); - JSXText2 = RegExp("[^<>{}]+", "y"); - TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/; - TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/; - KeywordsWithExpressionAfter = /^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/; - KeywordsWithNoLineTerminatorAfter = /^(?:return|throw|yield)$/; - Newline = RegExp(LineTerminatorSequence.source); - module2.exports = function jsTokens2(input) { - var _ref, tmp, jsx2, braces, firstCodePoint, isExpression3, lastIndex, lastSignificantToken, length, match, mode, nextLastIndex, nextLastSignificantToken, parenNesting, postfixIncDec, punctuator, stack, _, _1, _2; - var _arguments = arguments; - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - _ref = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, tmp = _ref.jsx, jsx2 = tmp === void 0 ? false : tmp; - length = input.length; - lastIndex = 0; - lastSignificantToken = ""; - stack = [ - { - tag: "JS" - } - ]; - braces = []; - parenNesting = 0; - postfixIncDec = false; - _state.label = 1; - case 1: - if (!(lastIndex < length)) return [ - 3, - 62 - ]; - mode = stack[stack.length - 1]; - _ = mode.tag; - switch(_){ - case "JS": - return [ - 3, - 2 - ]; - case "JSNonExpressionParen": - return [ - 3, - 2 - ]; - case "InterpolationInTemplate": - return [ - 3, - 2 - ]; - case "InterpolationInJSX": - return [ - 3, - 2 - ]; - case "JSXTag": - return [ - 3, - 38 - ]; - case "JSXTagEnd": - return [ - 3, - 38 - ]; - case "JSXChildren": - return [ - 3, - 45 - ]; - } - return [ - 3, - 52 - ]; - case 2: - if (!(input[lastIndex] === "/" && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken)))) return [ - 3, - 4 - ]; - RegularExpressionLiteral.lastIndex = lastIndex; - if (!(match = RegularExpressionLiteral.exec(input))) return [ - 3, - 4 - ]; - lastIndex = RegularExpressionLiteral.lastIndex; - lastSignificantToken = match[0]; - postfixIncDec = true; - return [ - 4, - { - type: "RegularExpressionLiteral", - value: match[0], - closed: match[1] !== void 0 && match[1] !== "\\" - } - ]; - case 3: - _state.sent(); - return [ - 3, - 1 - ]; - case 4: - Punctuator.lastIndex = lastIndex; - if (!(match = Punctuator.exec(input))) return [ - 3, - 26 - ]; - punctuator = match[0]; - nextLastIndex = Punctuator.lastIndex; - nextLastSignificantToken = punctuator; - switch(punctuator){ - case "(": - return [ - 3, - 5 - ]; - case ")": - return [ - 3, - 6 - ]; - case "{": - return [ - 3, - 7 - ]; - case "}": - return [ - 3, - 8 - ]; - case "]": - return [ - 3, - 18 - ]; - case "++": - return [ - 3, - 19 - ]; - case "--": - return [ - 3, - 19 - ]; - case "<": - return [ - 3, - 20 - ]; - } - return [ - 3, - 23 - ]; - case 5: - if (lastSignificantToken === "?NonExpressionParenKeyword") { - stack.push({ - tag: "JSNonExpressionParen", - nesting: parenNesting - }); - } - parenNesting++; - postfixIncDec = false; - return [ - 3, - 24 - ]; - case 6: - parenNesting--; - postfixIncDec = true; - if (mode.tag === "JSNonExpressionParen" && parenNesting === mode.nesting) { - stack.pop(); - nextLastSignificantToken = "?NonExpressionParenEnd"; - postfixIncDec = false; - } - return [ - 3, - 24 - ]; - case 7: - Punctuator.lastIndex = 0; - isExpression3 = !TokensNotPrecedingObjectLiteral.test(lastSignificantToken) && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken)); - braces.push(isExpression3); - postfixIncDec = false; - return [ - 3, - 24 - ]; - case 8: - _1 = mode.tag; - switch(_1){ - case "InterpolationInTemplate": - return [ - 3, - 9 - ]; - case "InterpolationInJSX": - return [ - 3, - 15 - ]; - } - return [ - 3, - 17 - ]; - case 9: - if (!(braces.length === mode.nesting)) return [ - 3, - 14 - ]; - Template.lastIndex = lastIndex; - match = Template.exec(input); - lastIndex = Template.lastIndex; - lastSignificantToken = match[0]; - if (!(match[1] === "${")) return [ - 3, - 11 - ]; - lastSignificantToken = "?InterpolationInTemplate"; - postfixIncDec = false; - return [ - 4, - { - type: "TemplateMiddle", - value: match[0] - } - ]; - case 10: - _state.sent(); - return [ - 3, - 13 - ]; - case 11: - stack.pop(); - postfixIncDec = true; - return [ - 4, - { - type: "TemplateTail", - value: match[0], - closed: match[1] === "`" - } - ]; - case 12: - _state.sent(); - _state.label = 13; - case 13: - return [ - 3, - 1 - ]; - case 14: - return [ - 3, - 17 - ]; - case 15: - if (!(braces.length === mode.nesting)) return [ - 3, - 17 - ]; - stack.pop(); - lastIndex += 1; - lastSignificantToken = "}"; - return [ - 4, - { - type: "JSXPunctuator", - value: "}" - } - ]; - case 16: - _state.sent(); - return [ - 3, - 1 - ]; - case 17: - postfixIncDec = braces.pop(); - nextLastSignificantToken = postfixIncDec ? "?ExpressionBraceEnd" : "}"; - return [ - 3, - 24 - ]; - case 18: - postfixIncDec = true; - return [ - 3, - 24 - ]; - case 19: - nextLastSignificantToken = postfixIncDec ? "?PostfixIncDec" : "?UnaryIncDec"; - return [ - 3, - 24 - ]; - case 20: - if (!(jsx2 && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken)))) return [ - 3, - 22 - ]; - stack.push({ - tag: "JSXTag" - }); - lastIndex += 1; - lastSignificantToken = "<"; - return [ - 4, - { - type: "JSXPunctuator", - value: punctuator - } - ]; - case 21: - _state.sent(); - return [ - 3, - 1 - ]; - case 22: - postfixIncDec = false; - return [ - 3, - 24 - ]; - case 23: - postfixIncDec = false; - _state.label = 24; - case 24: - lastIndex = nextLastIndex; - lastSignificantToken = nextLastSignificantToken; - return [ - 4, - { - type: "Punctuator", - value: punctuator - } - ]; - case 25: - _state.sent(); - return [ - 3, - 1 - ]; - case 26: - Identifier2.lastIndex = lastIndex; - if (!(match = Identifier2.exec(input))) return [ - 3, - 28 - ]; - lastIndex = Identifier2.lastIndex; - nextLastSignificantToken = match[0]; - switch(match[0]){ - case "for": - case "if": - case "while": - case "with": - if (lastSignificantToken !== "." && lastSignificantToken !== "?.") { - nextLastSignificantToken = "?NonExpressionParenKeyword"; - } - } - lastSignificantToken = nextLastSignificantToken; - postfixIncDec = !KeywordsWithExpressionAfter.test(match[0]); - return [ - 4, - { - type: match[1] === "#" ? "PrivateIdentifier" : "IdentifierName", - value: match[0] - } - ]; - case 27: - _state.sent(); - return [ - 3, - 1 - ]; - case 28: - StringLiteral3.lastIndex = lastIndex; - if (!(match = StringLiteral3.exec(input))) return [ - 3, - 30 - ]; - lastIndex = StringLiteral3.lastIndex; - lastSignificantToken = match[0]; - postfixIncDec = true; - return [ - 4, - { - type: "StringLiteral", - value: match[0], - closed: match[2] !== void 0 - } - ]; - case 29: - _state.sent(); - return [ - 3, - 1 - ]; - case 30: - NumericLiteral3.lastIndex = lastIndex; - if (!(match = NumericLiteral3.exec(input))) return [ - 3, - 32 - ]; - lastIndex = NumericLiteral3.lastIndex; - lastSignificantToken = match[0]; - postfixIncDec = true; - return [ - 4, - { - type: "NumericLiteral", - value: match[0] - } - ]; - case 31: - _state.sent(); - return [ - 3, - 1 - ]; - case 32: - Template.lastIndex = lastIndex; - if (!(match = Template.exec(input))) return [ - 3, - 37 - ]; - lastIndex = Template.lastIndex; - lastSignificantToken = match[0]; - if (!(match[1] === "${")) return [ - 3, - 34 - ]; - lastSignificantToken = "?InterpolationInTemplate"; - stack.push({ - tag: "InterpolationInTemplate", - nesting: braces.length - }); - postfixIncDec = false; - return [ - 4, - { - type: "TemplateHead", - value: match[0] - } - ]; - case 33: - _state.sent(); - return [ - 3, - 36 - ]; - case 34: - postfixIncDec = true; - return [ - 4, - { - type: "NoSubstitutionTemplate", - value: match[0], - closed: match[1] === "`" - } - ]; - case 35: - _state.sent(); - _state.label = 36; - case 36: - return [ - 3, - 1 - ]; - case 37: - return [ - 3, - 52 - ]; - case 38: - JSXPunctuator.lastIndex = lastIndex; - if (!(match = JSXPunctuator.exec(input))) return [ - 3, - 40 - ]; - lastIndex = JSXPunctuator.lastIndex; - nextLastSignificantToken = match[0]; - switch(match[0]){ - case "<": - stack.push({ - tag: "JSXTag" - }); - break; - case ">": - stack.pop(); - if (lastSignificantToken === "/" || mode.tag === "JSXTagEnd") { - nextLastSignificantToken = "?JSX"; - postfixIncDec = true; - } else { - stack.push({ - tag: "JSXChildren" - }); - } - break; - case "{": - stack.push({ - tag: "InterpolationInJSX", - nesting: braces.length - }); - nextLastSignificantToken = "?InterpolationInJSX"; - postfixIncDec = false; - break; - case "/": - if (lastSignificantToken === "<") { - stack.pop(); - if (stack[stack.length - 1].tag === "JSXChildren") { - stack.pop(); - } - stack.push({ - tag: "JSXTagEnd" - }); - } - } - lastSignificantToken = nextLastSignificantToken; - return [ - 4, - { - type: "JSXPunctuator", - value: match[0] - } - ]; - case 39: - _state.sent(); - return [ - 3, - 1 - ]; - case 40: - JSXIdentifier2.lastIndex = lastIndex; - if (!(match = JSXIdentifier2.exec(input))) return [ - 3, - 42 - ]; - lastIndex = JSXIdentifier2.lastIndex; - lastSignificantToken = match[0]; - return [ - 4, - { - type: "JSXIdentifier", - value: match[0] - } - ]; - case 41: - _state.sent(); - return [ - 3, - 1 - ]; - case 42: - JSXString.lastIndex = lastIndex; - if (!(match = JSXString.exec(input))) return [ - 3, - 44 - ]; - lastIndex = JSXString.lastIndex; - lastSignificantToken = match[0]; - return [ - 4, - { - type: "JSXString", - value: match[0], - closed: match[2] !== void 0 - } - ]; - case 43: - _state.sent(); - return [ - 3, - 1 - ]; - case 44: - return [ - 3, - 52 - ]; - case 45: - JSXText2.lastIndex = lastIndex; - if (!(match = JSXText2.exec(input))) return [ - 3, - 47 - ]; - lastIndex = JSXText2.lastIndex; - lastSignificantToken = match[0]; - return [ - 4, - { - type: "JSXText", - value: match[0] - } - ]; - case 46: - _state.sent(); - return [ - 3, - 1 - ]; - case 47: - _2 = input[lastIndex]; - switch(_2){ - case "<": - return [ - 3, - 48 - ]; - case "{": - return [ - 3, - 50 - ]; - } - return [ - 3, - 52 - ]; - case 48: - stack.push({ - tag: "JSXTag" - }); - lastIndex++; - lastSignificantToken = "<"; - return [ - 4, - { - type: "JSXPunctuator", - value: "<" - } - ]; - case 49: - _state.sent(); - return [ - 3, - 1 - ]; - case 50: - stack.push({ - tag: "InterpolationInJSX", - nesting: braces.length - }); - lastIndex++; - lastSignificantToken = "?InterpolationInJSX"; - postfixIncDec = false; - return [ - 4, - { - type: "JSXPunctuator", - value: "{" - } - ]; - case 51: - _state.sent(); - return [ - 3, - 1 - ]; - case 52: - WhiteSpace.lastIndex = lastIndex; - if (!(match = WhiteSpace.exec(input))) return [ - 3, - 54 - ]; - lastIndex = WhiteSpace.lastIndex; - return [ - 4, - { - type: "WhiteSpace", - value: match[0] - } - ]; - case 53: - _state.sent(); - return [ - 3, - 1 - ]; - case 54: - LineTerminatorSequence.lastIndex = lastIndex; - if (!(match = LineTerminatorSequence.exec(input))) return [ - 3, - 56 - ]; - lastIndex = LineTerminatorSequence.lastIndex; - postfixIncDec = false; - if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) { - lastSignificantToken = "?NoLineTerminatorHere"; - } - return [ - 4, - { - type: "LineTerminatorSequence", - value: match[0] - } - ]; - case 55: - _state.sent(); - return [ - 3, - 1 - ]; - case 56: - MultiLineComment.lastIndex = lastIndex; - if (!(match = MultiLineComment.exec(input))) return [ - 3, - 58 - ]; - lastIndex = MultiLineComment.lastIndex; - if (Newline.test(match[0])) { - postfixIncDec = false; - if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) { - lastSignificantToken = "?NoLineTerminatorHere"; - } - } - return [ - 4, - { - type: "MultiLineComment", - value: match[0], - closed: match[1] !== void 0 - } - ]; - case 57: - _state.sent(); - return [ - 3, - 1 - ]; - case 58: - SingleLineComment.lastIndex = lastIndex; - if (!(match = SingleLineComment.exec(input))) return [ - 3, - 60 - ]; - lastIndex = SingleLineComment.lastIndex; - postfixIncDec = false; - return [ - 4, - { - type: "SingleLineComment", - value: match[0] - } - ]; - case 59: - _state.sent(); - return [ - 3, - 1 - ]; - case 60: - firstCodePoint = String.fromCodePoint(input.codePointAt(lastIndex)); - lastIndex += firstCodePoint.length; - lastSignificantToken = firstCodePoint; - postfixIncDec = false; - return [ - 4, - { - type: mode.tag.startsWith("JSX") ? "JSXInvalid" : "Invalid", - value: firstCodePoint - } - ]; - case 61: - _state.sent(); - return [ - 3, - 1 - ]; - case 62: - return [ - 2, - void 0 - ]; - } - }); - }; - } -}); -// node_modules/picocolors/picocolors.js -var require_picocolors = __commonJS({ - "node_modules/picocolors/picocolors.js": function(exports2, module2) { - var argv = browser$1$1.argv || []; - var env = {}; - var isColorSupported = !("NO_COLOR" in env || argv.includes("--no-color")) && ("FORCE_COLOR" in env || argv.includes("--color") || "unix" === "win32" || commonjsRequire != null && require$$0$5.isatty(1) && env.TERM !== "dumb" || "CI" in env); - var formatter = function(open, close) { - var replace = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : open; - return function(input) { - var string = "" + input; - var index2 = string.indexOf(close, open.length); - return ~index2 ? open + replaceClose(string, close, replace, index2) + close : open + string + close; - }; - }; - var replaceClose = function(string, close, replace, index2) { - var result = ""; - var cursor = 0; - do { - result += string.substring(cursor, index2) + replace; - cursor = index2 + close.length; - index2 = string.indexOf(close, cursor); - }while (~index2); - return result + string.substring(cursor); - }; - var createColors3 = function() { - var enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : isColorSupported; - var init = enabled ? formatter : function() { - return String; - }; - return { - isColorSupported: enabled, - reset: init("\x1B[0m", "\x1B[0m"), - bold: init("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"), - dim: init("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"), - italic: init("\x1B[3m", "\x1B[23m"), - underline: init("\x1B[4m", "\x1B[24m"), - inverse: init("\x1B[7m", "\x1B[27m"), - hidden: init("\x1B[8m", "\x1B[28m"), - strikethrough: init("\x1B[9m", "\x1B[29m"), - black: init("\x1B[30m", "\x1B[39m"), - red: init("\x1B[31m", "\x1B[39m"), - green: init("\x1B[32m", "\x1B[39m"), - yellow: init("\x1B[33m", "\x1B[39m"), - blue: init("\x1B[34m", "\x1B[39m"), - magenta: init("\x1B[35m", "\x1B[39m"), - cyan: init("\x1B[36m", "\x1B[39m"), - white: init("\x1B[37m", "\x1B[39m"), - gray: init("\x1B[90m", "\x1B[39m"), - bgBlack: init("\x1B[40m", "\x1B[49m"), - bgRed: init("\x1B[41m", "\x1B[49m"), - bgGreen: init("\x1B[42m", "\x1B[49m"), - bgYellow: init("\x1B[43m", "\x1B[49m"), - bgBlue: init("\x1B[44m", "\x1B[49m"), - bgMagenta: init("\x1B[45m", "\x1B[49m"), - bgCyan: init("\x1B[46m", "\x1B[49m"), - bgWhite: init("\x1B[47m", "\x1B[49m") - }; - }; - module2.exports = createColors3(); - module2.exports.createColors = createColors3; - } -}); -// node_modules/jsesc/jsesc.js -var require_jsesc = __commonJS({ - "node_modules/jsesc/jsesc.js": function(exports2, module2) { - var object = {}; - var hasOwnProperty = object.hasOwnProperty; - var forOwn = function(object2, callback) { - for(var key in object2){ - if (hasOwnProperty.call(object2, key)) { - callback(key, object2[key]); - } - } - }; - var extend = function(destination, source) { - if (!source) { - return destination; - } - forOwn(source, function(key, value1) { - destination[key] = value1; - }); - return destination; - }; - var forEach = function(array, callback) { - var length = array.length; - var index2 = -1; - while(++index2 < length){ - callback(array[index2]); - } - }; - var fourHexEscape = function(hex) { - return "\\u" + ("0000" + hex).slice(-4); - }; - var hexadecimal = function(code2, lowercase) { - var hexadecimal2 = code2.toString(16); - if (lowercase) return hexadecimal2; - return hexadecimal2.toUpperCase(); - }; - var toString = object.toString; - var isArray = Array.isArray; - var isBuffer = function(value1) { - return typeof Buffer === "function" && Array.isArray(value1); - }; - var isObject = function(value1) { - return toString.call(value1) == "[object Object]"; - }; - var isString = function(value1) { - return typeof value1 == "string" || toString.call(value1) == "[object String]"; - }; - var isNumber2 = function(value1) { - return typeof value1 == "number" || toString.call(value1) == "[object Number]"; - }; - var isFunction5 = function(value1) { - return typeof value1 == "function"; - }; - var isMap = function(value1) { - return toString.call(value1) == "[object Map]"; - }; - var isSet = function(value1) { - return toString.call(value1) == "[object Set]"; - }; - var singleEscapes = { - "\\": "\\\\", - "\b": "\\b", - "\f": "\\f", - "\n": "\\n", - "\r": "\\r", - " ": "\\t" - }; - var regexSingleEscape = /[\\\b\f\n\r\t]/; - var regexDigit = /[0-9]/; - var regexWhitespace = /[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/; - var escapeEverythingRegex = /([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^]/g; - var escapeNonAsciiRegex = /([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^ !#-&\(-\[\]-_a-~]/g; - var jsesc2 = function(argument, options) { - var increaseIndentation = function() { - oldIndent = indent; - ++options.indentLevel; - indent = options.indent.repeat(options.indentLevel); - }; - var defaults = { - "escapeEverything": false, - "minimal": false, - "isScriptContext": false, - "quotes": "single", - "wrap": false, - "es6": false, - "json": false, - "compact": true, - "lowercaseHex": false, - "numbers": "decimal", - "indent": " ", - "indentLevel": 0, - "__inline1__": false, - "__inline2__": false - }; - var json = options && options.json; - if (json) { - defaults.quotes = "double"; - defaults.wrap = true; - } - options = extend(defaults, options); - if (options.quotes != "single" && options.quotes != "double" && options.quotes != "backtick") { - options.quotes = "single"; - } - var quote = options.quotes == "double" ? '"' : options.quotes == "backtick" ? "`" : "'"; - var compact = options.compact; - var lowercaseHex = options.lowercaseHex; - var indent = options.indent.repeat(options.indentLevel); - var oldIndent = ""; - var inline1 = options.__inline1__; - var inline2 = options.__inline2__; - var newLine = compact ? "" : "\n"; - var result; - var isEmpty = true; - var useBinNumbers = options.numbers == "binary"; - var useOctNumbers = options.numbers == "octal"; - var useDecNumbers = options.numbers == "decimal"; - var useHexNumbers = options.numbers == "hexadecimal"; - if (json && argument && isFunction5(argument.toJSON)) { - argument = argument.toJSON(); - } - if (!isString(argument)) { - if (isMap(argument)) { - if (argument.size == 0) { - return "new Map()"; - } - if (!compact) { - options.__inline1__ = true; - options.__inline2__ = false; - } - return "new Map(" + jsesc2(Array.from(argument), options) + ")"; - } - if (isSet(argument)) { - if (argument.size == 0) { - return "new Set()"; - } - return "new Set(" + jsesc2(Array.from(argument), options) + ")"; - } - if (isBuffer(argument)) { - if (argument.length == 0) { - return "Buffer.from([])"; - } - return "Buffer.from(" + jsesc2(Array.from(argument), options) + ")"; - } - if (isArray(argument)) { - result = []; - options.wrap = true; - if (inline1) { - options.__inline1__ = false; - options.__inline2__ = true; - } - if (!inline2) { - increaseIndentation(); - } - forEach(argument, function(value1) { - isEmpty = false; - if (inline2) { - options.__inline2__ = false; - } - result.push((compact || inline2 ? "" : indent) + jsesc2(value1, options)); - }); - if (isEmpty) { - return "[]"; - } - if (inline2) { - return "[" + result.join(", ") + "]"; - } - return "[" + newLine + result.join("," + newLine) + newLine + (compact ? "" : oldIndent) + "]"; - } else if (isNumber2(argument)) { - if (json) { - return JSON.stringify(argument); - } - if (useDecNumbers) { - return String(argument); - } - if (useHexNumbers) { - var hexadecimal2 = argument.toString(16); - if (!lowercaseHex) { - hexadecimal2 = hexadecimal2.toUpperCase(); - } - return "0x" + hexadecimal2; - } - if (useBinNumbers) { - return "0b" + argument.toString(2); - } - if (useOctNumbers) { - return "0o" + argument.toString(8); - } - } else if (!isObject(argument)) { - if (json) { - return JSON.stringify(argument) || "null"; - } - return String(argument); - } else { - result = []; - options.wrap = true; - increaseIndentation(); - forOwn(argument, function(key, value1) { - isEmpty = false; - result.push((compact ? "" : indent) + jsesc2(key, options) + ":" + (compact ? "" : " ") + jsesc2(value1, options)); - }); - if (isEmpty) { - return "{}"; - } - return "{" + newLine + result.join("," + newLine) + newLine + (compact ? "" : oldIndent) + "}"; - } - } - var regex = options.escapeEverything ? escapeEverythingRegex : escapeNonAsciiRegex; - result = argument.replace(regex, function(char, pair, lone, quoteChar, index2, string) { - if (pair) { - if (options.minimal) return pair; - var first = pair.charCodeAt(0); - var second = pair.charCodeAt(1); - if (options.es6) { - var codePoint = (first - 55296) * 1024 + second - 56320 + 65536; - var hex2 = hexadecimal(codePoint, lowercaseHex); - return "\\u{" + hex2 + "}"; - } - return fourHexEscape(hexadecimal(first, lowercaseHex)) + fourHexEscape(hexadecimal(second, lowercaseHex)); - } - if (lone) { - return fourHexEscape(hexadecimal(lone.charCodeAt(0), lowercaseHex)); - } - if (char == "\0" && !json && !regexDigit.test(string.charAt(index2 + 1))) { - return "\\0"; - } - if (quoteChar) { - if (quoteChar == quote || options.escapeEverything) { - return "\\" + quoteChar; - } - return quoteChar; - } - if (regexSingleEscape.test(char)) { - return singleEscapes[char]; - } - if (options.minimal && !regexWhitespace.test(char)) { - return char; - } - var hex = hexadecimal(char.charCodeAt(0), lowercaseHex); - if (json || hex.length > 2) { - return fourHexEscape(hex); - } - return "\\x" + ("00" + hex).slice(-2); - }); - if (quote == "`") { - result = result.replace(/\$\{/g, "\\${"); - } - if (options.isScriptContext) { - result = result.replace(/<\/(script|style)/gi, "<\\/$1").replace(/ [out] + */ -/** - * NFA state. - * - * Allows nondeterministic transitions to several states on the - * same symbol, and also epsilon-transitions. - */ + function char(c) { + var inState = new NFAState(); + var outState = new NFAState({ + accepting: true + }); -var NFAState$1 = function (_State) { - _inherits(NFAState, _State); + return new NFA(inState.addTransition(c, outState), outState); + } - function NFAState() { - _classCallCheck$1(this, NFAState); + // ----------------------------------------------------------------------------- + // Epsilon NFA fragment - return _possibleConstructorReturn(this, (NFAState.__proto__ || Object.getPrototypeOf(NFAState)).apply(this, arguments)); - } + /** + * Epsilon factory. + * + * Creates an NFA fragment for ε (recognizes an empty string). + * + * [in] --ε--> [out] + */ + function e() { + return char(EPSILON); + } - _createClass$1(NFAState, [{ - key: 'matches', - - - /** - * Whether this state matches a string. - * - * We maintain set of visited epsilon-states to avoid infinite loops - * when an epsilon-transition goes eventually to itself. - * - * NOTE: this function is rather "educational", since we use DFA for strings - * matching. DFA is built on top of NFA, and uses fast transition table. - */ - value: function matches(string) { - var visited = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set(); - - // An epsilon-state has been visited, stop to avoid infinite loop. - if (visited.has(this)) { - return false; - } + // ----------------------------------------------------------------------------- + // Alteration NFA fragment: `abc` - visited.add(this); + /** + * Creates a connection between two NFA fragments on epsilon transition. + * + * [in-a] --a--> [out-a] --ε--> [in-b] --b--> [out-b] + */ + function altPair(first, second) { + first.out.accepting = false; + second.out.accepting = true; - // No symbols left.. - if (string.length === 0) { - // .. and we're in the accepting state. - if (this.accepting) { - return true; - } + first.out.addTransition(EPSILON, second.in); - // Check if we can reach any accepting state from - // on the epsilon transitions. - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; + return new NFA(first.in, second.out); + } - try { - for (var _iterator = this.getTransitionsOnSymbol(EPSILON$1)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var nextState = _step.value; + /** + * Alteration factory. + * + * Creates a alteration NFA for (at least) two NFA-fragments. + */ + function alt(first) { + for (var _len = arguments.length, fragments = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + fragments[_key - 1] = arguments[_key]; + } - if (nextState.matches('', visited)) { - return true; - } - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; - return false; - } + try { + for (var _iterator = fragments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var fragment = _step.value; - // Else, we get some symbols. - var symbol = string[0]; - var rest = string.slice(1); + first = altPair(first, fragment); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } - var symbolTransitions = this.getTransitionsOnSymbol(symbol); - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; + return first; + } - try { - for (var _iterator2 = symbolTransitions[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var _nextState = _step2.value; + // ----------------------------------------------------------------------------- + // Disjunction NFA fragment: `a|b` - if (_nextState.matches(rest)) { - return true; - } - } + /** + * Creates a disjunction choice between two fragments. + */ + function orPair(first, second) { + var inState = new NFAState(); + var outState = new NFAState(); - // If we couldn't match on symbol, check still epsilon-transitions - // without consuming the symbol (i.e. continue from `string`, not `rest`). - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } + inState.addTransition(EPSILON, first.in); + inState.addTransition(EPSILON, second.in); - var _iteratorNormalCompletion3 = true; - var _didIteratorError3 = false; - var _iteratorError3 = undefined; + outState.accepting = true; + first.out.accepting = false; + second.out.accepting = false; - try { - for (var _iterator3 = this.getTransitionsOnSymbol(EPSILON$1)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { - var _nextState2 = _step3.value; + first.out.addTransition(EPSILON, outState); + second.out.addTransition(EPSILON, outState); - if (_nextState2.matches(string, visited)) { - return true; - } - } - } catch (err) { - _didIteratorError3 = true; - _iteratorError3 = err; - } finally { - try { - if (!_iteratorNormalCompletion3 && _iterator3.return) { - _iterator3.return(); - } - } finally { - if (_didIteratorError3) { - throw _iteratorError3; - } - } - } + return new NFA(inState, outState); + } - return false; - } + /** + * Disjunction factory. + * + * Creates a disjunction NFA for (at least) two NFA-fragments. + */ + function or(first) { + for (var _len2 = arguments.length, fragments = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + fragments[_key2 - 1] = arguments[_key2]; + } - /** - * Returns an ε-closure for this state: - * self + all states following ε-transitions. - */ - - }, { - key: 'getEpsilonClosure', - value: function getEpsilonClosure() { - var _this2 = this; - - if (!this._epsilonClosure) { - (function () { - var epsilonTransitions = _this2.getTransitionsOnSymbol(EPSILON$1); - var closure = _this2._epsilonClosure = new Set(); - closure.add(_this2); - var _iteratorNormalCompletion4 = true; - var _didIteratorError4 = false; - var _iteratorError4 = undefined; - - try { - for (var _iterator4 = epsilonTransitions[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { - var nextState = _step4.value; - - if (!closure.has(nextState)) { - closure.add(nextState); - var nextClosure = nextState.getEpsilonClosure(); - nextClosure.forEach(function (state) { - return closure.add(state); - }); - } - } - } catch (err) { - _didIteratorError4 = true; - _iteratorError4 = err; - } finally { - try { - if (!_iteratorNormalCompletion4 && _iterator4.return) { - _iterator4.return(); - } - } finally { - if (_didIteratorError4) { - throw _iteratorError4; - } - } - } - })(); - } + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; - return this._epsilonClosure; - } - }]); + try { + for (var _iterator2 = fragments[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var fragment = _step2.value; - return NFAState; -}(State); + first = orPair(first, fragment); + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } -var nfaState = NFAState$1; + return first; + } -nfaState.default; + // ----------------------------------------------------------------------------- + // Kleene-closure -/** - * The MIT License (MIT) - * Copyright (c) 2017-present Dmitry Soshnikov - */ + /** + * Kleene star/closure. + * + * a* + */ + function repExplicit(fragment) { + var inState = new NFAState(); + var outState = new NFAState({ + accepting: true + }); -var NFA$1 = nfa; -var NFAState = nfaState; + // 0 or more. + inState.addTransition(EPSILON, fragment.in); + inState.addTransition(EPSILON, outState); -var _require$2 = specialSymbols, - EPSILON = _require$2.EPSILON; + fragment.out.accepting = false; + fragment.out.addTransition(EPSILON, outState); + outState.addTransition(EPSILON, fragment.in); -// ----------------------------------------------------------------------------- -// Char NFA fragment: `c` + return new NFA(inState, outState); + } -/** - * Char factory. - * - * Creates an NFA fragment for a single char. - * - * [in] --c--> [out] - */ + /** + * Optimized Kleene-star: just adds ε-transitions from + * input to the output, and back. + */ + function rep(fragment) { + fragment.in.addTransition(EPSILON, fragment.out); + fragment.out.addTransition(EPSILON, fragment.in); + return fragment; + } + /** + * Optimized Plus: just adds ε-transitions from + * the output to the input. + */ + function plusRep(fragment) { + fragment.out.addTransition(EPSILON, fragment.in); + return fragment; + } -function char$1(c) { - var inState = new NFAState(); - var outState = new NFAState({ - accepting: true - }); + /** + * Optimized ? repetition: just adds ε-transitions from + * the input to the output. + */ + function questionRep(fragment) { + fragment.in.addTransition(EPSILON, fragment.out); + return fragment; + } - return new NFA$1(inState.addTransition(c, outState), outState); + builders = { + alt: alt, + char: char, + e: e, + or: or, + rep: rep, + repExplicit: repExplicit, + plusRep: plusRep, + questionRep: questionRep + }; + return builders; } -// ----------------------------------------------------------------------------- -// Epsilon NFA fragment - /** - * Epsilon factory. - * - * Creates an NFA fragment for ε (recognizes an empty string). - * - * [in] --ε--> [out] + * The MIT License (MIT) + * Copyright (c) 2017-present Dmitry Soshnikov */ -function e() { - return char$1(EPSILON); -} -// ----------------------------------------------------------------------------- -// Alteration NFA fragment: `abc` +var nfaFromRegexp; +var hasRequiredNfaFromRegexp; -/** - * Creates a connection between two NFA fragments on epsilon transition. - * - * [in-a] --a--> [out-a] --ε--> [in-b] --b--> [out-b] - */ -function altPair(first, second) { - first.out.accepting = false; - second.out.accepting = true; +function requireNfaFromRegexp () { + if (hasRequiredNfaFromRegexp) return nfaFromRegexp; + hasRequiredNfaFromRegexp = 1; - first.out.addTransition(EPSILON, second.in); + function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } - return new NFA$1(first.in, second.out); -} + var parser = requireParser(); -/** - * Alteration factory. - * - * Creates a alteration NFA for (at least) two NFA-fragments. - */ -function alt$1(first) { - for (var _len = arguments.length, fragments = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - fragments[_key - 1] = arguments[_key]; - } + var _require = requireBuilders(), + alt = _require.alt, + char = _require.char, + or = _require.or, + rep = _require.rep, + plusRep = _require.plusRep, + questionRep = _require.questionRep; - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; + /** + * Helper `gen` function calls node type handler. + */ - try { - for (var _iterator = fragments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var fragment = _step.value; - first = altPair(first, fragment); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } + function gen(node) { + if (node && !generator[node.type]) { + throw new Error(node.type + ' is not supported in NFA/DFA interpreter.'); + } - return first; -} + return node ? generator[node.type](node) : ''; + } -// ----------------------------------------------------------------------------- -// Disjunction NFA fragment: `a|b` + /** + * AST handler. + */ + var generator = { + RegExp: function RegExp(node) { + if (node.flags !== '') { + throw new Error('NFA/DFA: Flags are not supported yet.'); + } -/** - * Creates a disjunction choice between two fragments. - */ -function orPair(first, second) { - var inState = new NFAState(); - var outState = new NFAState(); + return gen(node.body); + }, + Alternative: function Alternative(node) { + var fragments = (node.expressions || []).map(gen); + return alt.apply(undefined, _toConsumableArray(fragments)); + }, + Disjunction: function Disjunction(node) { + return or(gen(node.left), gen(node.right)); + }, + Repetition: function Repetition(node) { + switch (node.quantifier.kind) { + case '*': + return rep(gen(node.expression)); + case '+': + return plusRep(gen(node.expression)); + case '?': + return questionRep(gen(node.expression)); + default: + throw new Error('Unknown repeatition: ' + node.quantifier.kind + '.'); + } + }, + Char: function Char(node) { + if (node.kind !== 'simple') { + throw new Error('NFA/DFA: Only simple chars are supported yet.'); + } + + return char(node.value); + }, + Group: function Group(node) { + return gen(node.expression); + } + }; - inState.addTransition(EPSILON, first.in); - inState.addTransition(EPSILON, second.in); + nfaFromRegexp = { + /** + * Builds an NFA from the passed regexp. + */ + build: function build(regexp) { + var ast = regexp; - outState.accepting = true; - first.out.accepting = false; - second.out.accepting = false; + if (regexp instanceof RegExp) { + regexp = '' + regexp; + } - first.out.addTransition(EPSILON, outState); - second.out.addTransition(EPSILON, outState); + if (typeof regexp === 'string') { + ast = parser.parse(regexp, { + captureLocations: true + }); + } - return new NFA$1(inState, outState); + return gen(ast); + } + }; + return nfaFromRegexp; } /** - * Disjunction factory. - * - * Creates a disjunction NFA for (at least) two NFA-fragments. + * The MIT License (MIT) + * Copyright (c) 2017-present Dmitry Soshnikov */ -function or$1(first) { - for (var _len2 = arguments.length, fragments = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - fragments[_key2 - 1] = arguments[_key2]; - } - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; +var finiteAutomaton; +var hasRequiredFiniteAutomaton; - try { - for (var _iterator2 = fragments[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var fragment = _step2.value; +function requireFiniteAutomaton () { + if (hasRequiredFiniteAutomaton) return finiteAutomaton; + hasRequiredFiniteAutomaton = 1; - first = orPair(first, fragment); - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } + var NFA = requireNfa(); + var DFA = requireDfa(); - return first; -} + var nfaFromRegExp = requireNfaFromRegexp(); + var builders = requireBuilders(); -// ----------------------------------------------------------------------------- -// Kleene-closure + finiteAutomaton = { -/** - * Kleene star/closure. - * - * a* - */ -function repExplicit(fragment) { - var inState = new NFAState(); - var outState = new NFAState({ - accepting: true - }); + /** + * Export NFA and DFA classes. + */ + NFA: NFA, + DFA: DFA, + + /** + * Expose builders. + */ + builders: builders, - // 0 or more. - inState.addTransition(EPSILON, fragment.in); - inState.addTransition(EPSILON, outState); + /** + * Builds an NFA for the passed regexp. + * + * @param string | AST | RegExp: + * + * a regular expression in different representations: a string, + * a RegExp object, or an AST. + */ + toNFA: function toNFA(regexp) { + return nfaFromRegExp.build(regexp); + }, - fragment.out.accepting = false; - fragment.out.addTransition(EPSILON, outState); - outState.addTransition(EPSILON, fragment.in); - return new NFA$1(inState, outState); -} + /** + * Builds DFA for the passed regexp. + * + * @param string | AST | RegExp: + * + * a regular expression in different representations: a string, + * a RegExp object, or an AST. + */ + toDFA: function toDFA(regexp) { + return new DFA(this.toNFA(regexp)); + }, -/** - * Optimized Kleene-star: just adds ε-transitions from - * input to the output, and back. - */ -function rep$1(fragment) { - fragment.in.addTransition(EPSILON, fragment.out); - fragment.out.addTransition(EPSILON, fragment.in); - return fragment; -} -/** - * Optimized Plus: just adds ε-transitions from - * the output to the input. - */ -function plusRep$1(fragment) { - fragment.out.addTransition(EPSILON, fragment.in); - return fragment; + /** + * Returns true if regexp accepts the string. + */ + test: function test(regexp, string) { + return this.toDFA(regexp).matches(string); + } + }; + return finiteAutomaton; } -/** - * Optimized ? repetition: just adds ε-transitions from - * the input to the output. - */ -function questionRep$1(fragment) { - fragment.in.addTransition(EPSILON, fragment.out); - return fragment; -} - -var builders$1 = { - alt: alt$1, - char: char$1, - e: e, - or: or$1, - rep: rep$1, - repExplicit: repExplicit, - plusRep: plusRep$1, - questionRep: questionRep$1 -}; - /** * The MIT License (MIT) * Copyright (c) 2017-present Dmitry Soshnikov */ -function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +var runtime; +var hasRequiredRuntime; -var parser$1 = parser$4; +function requireRuntime () { + if (hasRequiredRuntime) return runtime; + hasRequiredRuntime = 1; -var _require$1 = builders$1, - alt = _require$1.alt, - char = _require$1.char, - or = _require$1.or, - rep = _require$1.rep, - plusRep = _require$1.plusRep, - questionRep = _require$1.questionRep; + /** + * The `RegExpTree` class provides runtime support for `compat-transpiler` + * module from `regexp-tree`. + * + * E.g. it tracks names of the capturing groups, in order to access the + * names on the matched result. + * + * It's a thin-wrapper on top of original regexp. + */ -/** - * Helper `gen` function calls node type handler. - */ + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function gen(node) { - if (node && !generator$1[node.type]) { - throw new Error(node.type + ' is not supported in NFA/DFA interpreter.'); - } + var RegExpTree = function () { + /** + * Initializes a `RegExpTree` instance. + * + * @param RegExp - a regular expression + * + * @param Object state: + * + * An extra state which may store any related to transformation + * data, for example, names of the groups. + * + * - flags - original flags + * - groups - names of the groups, and their indices + * - source - original source + */ + function RegExpTree(re, _ref) { + var flags = _ref.flags, + groups = _ref.groups, + source = _ref.source; + + _classCallCheck(this, RegExpTree); + + this._re = re; + this._groups = groups; + + // Original props. + this.flags = flags; + this.source = source || re.source; + this.dotAll = flags.includes('s'); + + // Inherited directly from `re`. + this.global = re.global; + this.ignoreCase = re.ignoreCase; + this.multiline = re.multiline; + this.sticky = re.sticky; + this.unicode = re.unicode; + } - return node ? generator$1[node.type](node) : ''; -} + /** + * Facade wrapper for RegExp `test` method. + */ -/** - * AST handler. - */ -var generator$1 = { - RegExp: function RegExp(node) { - if (node.flags !== '') { - throw new Error('NFA/DFA: Flags are not supported yet.'); - } - return gen(node.body); - }, - Alternative: function Alternative(node) { - var fragments = (node.expressions || []).map(gen); - return alt.apply(undefined, _toConsumableArray(fragments)); - }, - Disjunction: function Disjunction(node) { - return or(gen(node.left), gen(node.right)); - }, - Repetition: function Repetition(node) { - switch (node.quantifier.kind) { - case '*': - return rep(gen(node.expression)); - case '+': - return plusRep(gen(node.expression)); - case '?': - return questionRep(gen(node.expression)); - default: - throw new Error('Unknown repeatition: ' + node.quantifier.kind + '.'); - } - }, - Char: function Char(node) { - if (node.kind !== 'simple') { - throw new Error('NFA/DFA: Only simple chars are supported yet.'); - } + _createClass(RegExpTree, [{ + key: 'test', + value: function test(string) { + return this._re.test(string); + } - return char(node.value); - }, - Group: function Group(node) { - return gen(node.expression); - } -}; + /** + * Facade wrapper for RegExp `compile` method. + */ -var nfaFromRegexp = { - /** - * Builds an NFA from the passed regexp. - */ - build: function build(regexp) { - var ast = regexp; + }, { + key: 'compile', + value: function compile(string) { + return this._re.compile(string); + } - if (regexp instanceof RegExp) { - regexp = '' + regexp; - } + /** + * Facade wrapper for RegExp `toString` method. + */ - if (typeof regexp === 'string') { - ast = parser$1.parse(regexp, { - captureLocations: true - }); - } + }, { + key: 'toString', + value: function toString() { + if (!this._toStringResult) { + this._toStringResult = '/' + this.source + '/' + this.flags; + } + return this._toStringResult; + } - return gen(ast); - } -}; + /** + * Facade wrapper for RegExp `exec` method. + */ + + }, { + key: 'exec', + value: function exec(string) { + var result = this._re.exec(string); + + if (!this._groups || !result) { + return result; + } + + result.groups = {}; + + for (var group in this._groups) { + var groupNumber = this._groups[group]; + result.groups[group] = result[groupNumber]; + } + + return result; + } + }]); + + return RegExpTree; + }(); + + runtime = { + RegExpTree: RegExpTree + }; + return runtime; +} /** * The MIT License (MIT) * Copyright (c) 2017-present Dmitry Soshnikov */ -var NFA = nfa; -var DFA = dfa; - -var nfaFromRegExp = nfaFromRegexp; -var builders = builders$1; - -var finiteAutomaton = { - - /** - * Export NFA and DFA classes. - */ - NFA: NFA, - DFA: DFA, - - /** - * Expose builders. - */ - builders: builders, - - /** - * Builds an NFA for the passed regexp. - * - * @param string | AST | RegExp: - * - * a regular expression in different representations: a string, - * a RegExp object, or an AST. - */ - toNFA: function toNFA(regexp) { - return nfaFromRegExp.build(regexp); - }, - - - /** - * Builds DFA for the passed regexp. - * - * @param string | AST | RegExp: - * - * a regular expression in different representations: a string, - * a RegExp object, or an AST. - */ - toDFA: function toDFA(regexp) { - return new DFA(this.toNFA(regexp)); - }, - - - /** - * Returns true if regexp accepts the string. - */ - test: function test(regexp, string) { - return this.toDFA(regexp).matches(string); - } -}; +var regexpTree_1; +var hasRequiredRegexpTree$1; + +function requireRegexpTree$1 () { + if (hasRequiredRegexpTree$1) return regexpTree_1; + hasRequiredRegexpTree$1 = 1; + + var compatTranspiler = requireCompatTranspiler(); + var generator = requireGenerator(); + var optimizer = requireOptimizer(); + var parser = requireParser(); + var _transform = requireTransform(); + var _traverse = requireTraverse(); + var fa = requireFiniteAutomaton(); + + var _require = requireRuntime(), + RegExpTree = _require.RegExpTree; + + /** + * An API object for RegExp processing (parsing/transform/generation). + */ + + + var regexpTree = { + /** + * Parser module exposed. + */ + parser: parser, + + /** + * Expose finite-automaton module. + */ + fa: fa, + + /** + * `TransformResult` exposed. + */ + TransformResult: _transform.TransformResult, -/** - * The MIT License (MIT) - * Copyright (c) 2017-present Dmitry Soshnikov - */ + /** + * Parses a regexp string, producing an AST. + * + * @param string regexp + * + * a regular expression in different formats: string, AST, RegExp. + * + * @param Object options + * + * parsing options for this parse call. Default are: + * + * - captureLocations: boolean + * - any other custom options + * + * @return Object AST + */ + parse: function parse(regexp, options) { + return parser.parse('' + regexp, options); + }, -/** - * The `RegExpTree` class provides runtime support for `compat-transpiler` - * module from `regexp-tree`. - * - * E.g. it tracks names of the capturing groups, in order to access the - * names on the matched result. - * - * It's a thin-wrapper on top of original regexp. - */ -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var RegExpTree$1 = function () { - /** - * Initializes a `RegExpTree` instance. - * - * @param RegExp - a regular expression - * - * @param Object state: - * - * An extra state which may store any related to transformation - * data, for example, names of the groups. - * - * - flags - original flags - * - groups - names of the groups, and their indices - * - source - original source - */ - function RegExpTree(re, _ref) { - var flags = _ref.flags, - groups = _ref.groups, - source = _ref.source; - - _classCallCheck(this, RegExpTree); - - this._re = re; - this._groups = groups; - - // Original props. - this.flags = flags; - this.source = source || re.source; - this.dotAll = flags.includes('s'); - - // Inherited directly from `re`. - this.global = re.global; - this.ignoreCase = re.ignoreCase; - this.multiline = re.multiline; - this.sticky = re.sticky; - this.unicode = re.unicode; - } + /** + * Traverses a RegExp AST. + * + * @param Object ast + * @param Object | Array handlers + * + * Each `handler` is an object containing handler function for needed + * node types. Example: + * + * regexpTree.traverse(ast, { + * onChar(node) { + * ... + * }, + * }); + * + * The value for a node type may also be an object with functions pre and post. + * This enables more context-aware analyses, e.g. measuring star height. + */ + traverse: function traverse(ast, handlers, options) { + return _traverse.traverse(ast, handlers, options); + }, - /** - * Facade wrapper for RegExp `test` method. - */ + /** + * Transforms a regular expression. + * + * A regexp can be passed in different formats (string, regexp or AST), + * applying a set of transformations. It is a convenient wrapper + * on top of "parse-traverse-generate" tool chain. + * + * @param string | AST | RegExp regexp - a regular expression; + * @param Object | Array handlers - a list of handlers. + * + * @return TransformResult - a transformation result. + */ + transform: function transform(regexp, handlers) { + return _transform.transform(regexp, handlers); + }, - _createClass(RegExpTree, [{ - key: 'test', - value: function test(string) { - return this._re.test(string); - } - /** - * Facade wrapper for RegExp `compile` method. - */ + /** + * Generates a RegExp string from an AST. + * + * @param Object ast + * + * Invariant: + * + * regexpTree.generate(regexpTree.parse('/[a-z]+/i')); // '/[a-z]+/i' + */ + generate: function generate(ast) { + return generator.generate(ast); + }, - }, { - key: 'compile', - value: function compile(string) { - return this._re.compile(string); - } - /** - * Facade wrapper for RegExp `toString` method. - */ + /** + * Creates a RegExp object from a regexp string. + * + * @param string regexp + */ + toRegExp: function toRegExp(regexp) { + var compat = this.compatTranspile(regexp); + return new RegExp(compat.getSource(), compat.getFlags()); + }, - }, { - key: 'toString', - value: function toString() { - if (!this._toStringResult) { - this._toStringResult = '/' + this.source + '/' + this.flags; - } - return this._toStringResult; - } - /** - * Facade wrapper for RegExp `exec` method. - */ + /** + * Optimizes a regular expression by replacing some + * sub-expressions with their idiomatic patterns. + * + * @param string regexp + * + * @return TransformResult object + */ + optimize: function optimize(regexp, whitelist) { + var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, + blacklist = _ref.blacklist; - }, { - key: 'exec', - value: function exec(string) { - var result = this._re.exec(string); + return optimizer.optimize(regexp, { whitelist: whitelist, blacklist: blacklist }); + }, - if (!this._groups || !result) { - return result; - } - result.groups = {}; + /** + * Translates a regular expression in new syntax or in new format + * into equivalent expressions in old syntax. + * + * @param string regexp + * + * @return TransformResult object + */ + compatTranspile: function compatTranspile(regexp, whitelist) { + return compatTranspiler.transform(regexp, whitelist); + }, - for (var group in this._groups) { - var groupNumber = this._groups[group]; - result.groups[group] = result[groupNumber]; - } - return result; - } - }]); + /** + * Executes a regular expression on a string. + * + * @param RegExp|string re - a regular expression. + * @param string string - a testing string. + */ + exec: function exec(re, string) { + if (typeof re === 'string') { + var compat = this.compatTranspile(re); + var extra = compat.getExtra(); + + if (extra.namedCapturingGroups) { + re = new RegExpTree(compat.toRegExp(), { + flags: compat.getFlags(), + source: compat.getSource(), + groups: extra.namedCapturingGroups + }); + } else { + re = compat.toRegExp(); + } + } - return RegExpTree; -}(); + return re.exec(string); + } + }; -var runtime = { - RegExpTree: RegExpTree$1 -}; + regexpTree_1 = regexpTree; + return regexpTree_1; +} /** * The MIT License (MIT) * Copyright (c) 2017-present Dmitry Soshnikov */ -var compatTranspiler = compatTranspiler$1; -var generator = generator_1; -var optimizer = optimizer$1; -var parser = parser$4; -var _transform = transform$3; -var _traverse = traverse$3; -var fa = finiteAutomaton; - -var _require = runtime, - RegExpTree = _require.RegExpTree; +var regexpTree; +var hasRequiredRegexpTree; -/** - * An API object for RegExp processing (parsing/transform/generation). - */ +function requireRegexpTree () { + if (hasRequiredRegexpTree) return regexpTree; + hasRequiredRegexpTree = 1; + regexpTree = requireRegexpTree$1(); + return regexpTree; +} -var regexpTree$2 = { - /** - * Parser module exposed. - */ - parser: parser, - - /** - * Expose finite-automaton module. - */ - fa: fa, - - /** - * `TransformResult` exposed. - */ - TransformResult: _transform.TransformResult, - - /** - * Parses a regexp string, producing an AST. - * - * @param string regexp - * - * a regular expression in different formats: string, AST, RegExp. - * - * @param Object options - * - * parsing options for this parse call. Default are: - * - * - captureLocations: boolean - * - any other custom options - * - * @return Object AST - */ - parse: function parse(regexp, options) { - return parser.parse('' + regexp, options); - }, - - - /** - * Traverses a RegExp AST. - * - * @param Object ast - * @param Object | Array handlers - * - * Each `handler` is an object containing handler function for needed - * node types. Example: - * - * regexpTree.traverse(ast, { - * onChar(node) { - * ... - * }, - * }); - * - * The value for a node type may also be an object with functions pre and post. - * This enables more context-aware analyses, e.g. measuring star height. - */ - traverse: function traverse(ast, handlers, options) { - return _traverse.traverse(ast, handlers, options); - }, - - - /** - * Transforms a regular expression. - * - * A regexp can be passed in different formats (string, regexp or AST), - * applying a set of transformations. It is a convenient wrapper - * on top of "parse-traverse-generate" tool chain. - * - * @param string | AST | RegExp regexp - a regular expression; - * @param Object | Array handlers - a list of handlers. - * - * @return TransformResult - a transformation result. - */ - transform: function transform(regexp, handlers) { - return _transform.transform(regexp, handlers); - }, - - - /** - * Generates a RegExp string from an AST. - * - * @param Object ast - * - * Invariant: - * - * regexpTree.generate(regexpTree.parse('/[a-z]+/i')); // '/[a-z]+/i' - */ - generate: function generate(ast) { - return generator.generate(ast); - }, - - - /** - * Creates a RegExp object from a regexp string. - * - * @param string regexp - */ - toRegExp: function toRegExp(regexp) { - var compat = this.compatTranspile(regexp); - return new RegExp(compat.getSource(), compat.getFlags()); - }, - - - /** - * Optimizes a regular expression by replacing some - * sub-expressions with their idiomatic patterns. - * - * @param string regexp - * - * @return TransformResult object - */ - optimize: function optimize(regexp, whitelist) { - var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, - blacklist = _ref.blacklist; - - return optimizer.optimize(regexp, { whitelist: whitelist, blacklist: blacklist }); - }, - - - /** - * Translates a regular expression in new syntax or in new format - * into equivalent expressions in old syntax. - * - * @param string regexp - * - * @return TransformResult object - */ - compatTranspile: function compatTranspile(regexp, whitelist) { - return compatTranspiler.transform(regexp, whitelist); - }, - - - /** - * Executes a regular expression on a string. - * - * @param RegExp|string re - a regular expression. - * @param string string - a testing string. - */ - exec: function exec(re, string) { - if (typeof re === 'string') { - var compat = this.compatTranspile(re); - var extra = compat.getExtra(); - - if (extra.namedCapturingGroups) { - re = new RegExpTree(compat.toRegExp(), { - flags: compat.getFlags(), - source: compat.getSource(), - groups: extra.namedCapturingGroups - }); - } else { - re = compat.toRegExp(); - } - } +var isSimpleRegexp; +var hasRequiredIsSimpleRegexp; - return re.exec(string); - } -}; +function requireIsSimpleRegexp () { + if (hasRequiredIsSimpleRegexp) return isSimpleRegexp; + hasRequiredIsSimpleRegexp = 1; -var regexpTree_1 = regexpTree$2; + const regexpTree = requireRegexpTree(); -/** - * The MIT License (MIT) - * Copyright (c) 2017-present Dmitry Soshnikov - */ + const notSimpleChar = ({type, kind}) => type !== 'Char' || kind !== 'simple'; -var regexpTree$1 = regexpTree_1; + isSimpleRegexp = (regexp) => { + let containsMoreThenSimpleChars = false; + const ast = regexpTree.parse(regexp); + + if (ast.body.type !== 'Alternative') + return false; + + regexpTree.traverse(ast, { + RegExp({node}) { + const {expressions} = node.body; + containsMoreThenSimpleChars = Boolean(expressions.find(notSimpleChar)); + }, + }); + + return !containsMoreThenSimpleChars; + }; + return isSimpleRegexp; +} -const regexpTree = regexpTree$1; +var regexp; +var hasRequiredRegexp; -const notSimpleChar = ({type, kind}) => type !== 'Char' || kind !== 'simple'; +function requireRegexp () { + if (hasRequiredRegexp) return regexp; + hasRequiredRegexp = 1; -var isSimpleRegexp = (regexp) => { - let containsMoreThenSimpleChars = false; - const ast = regexpTree.parse(regexp); - - if (ast.body.type !== 'Alternative') - return false; - - regexpTree.traverse(ast, { - RegExp({node}) { - const {expressions} = node.body; - containsMoreThenSimpleChars = Boolean(expressions.find(notSimpleChar)); - }, - }); - - return !containsMoreThenSimpleChars; -}; + const isSimpleRegExp = requireIsSimpleRegexp(); -isSimpleRegexp.default; + regexp = { + isSimpleRegExp, + }; + return regexp; +} -const isSimpleRegExp = isSimpleRegexp; +var addArgs = {}; -var regexp = { - isSimpleRegExp, -}; +var hasRequiredAddArgs; -var addArgs = {}; +function requireAddArgs () { + if (hasRequiredAddArgs) return addArgs; + hasRequiredAddArgs = 1; -const {compareAny} = compare$5; -const {template: template$1} = parser$6; -const {types: types$2} = bundle; -const { - ObjectPattern, - ObjectProperty, - isBlockStatement, - isFunction, - isLabeledStatement, - isObjectPattern, - isCallExpression, -} = types$2; + const {compareAny} = requireCompare(); + const {template} = requireParser$1(); + const {types} = requireBundle(); + const { + ObjectPattern, + ObjectProperty, + isBlockStatement, + isFunction, + isLabeledStatement, + isObjectPattern, + isCallExpression, + } = types; -const {entries: entries$1} = Object; + const {entries} = Object; -const COMPUTED = true; -const SHORTHAND = true; + const COMPUTED = true; + const SHORTHAND = true; -const isCallOrStatement = (path) => path.isCallExpression() || path.isStatement(); + const isCallOrStatement = (path) => path.isCallExpression() || path.isStatement(); -const isCall = (path) => { - return isCallExpression(path.find(isCallOrStatement)); -}; + const isCall = (path) => { + return isCallExpression(path.find(isCallOrStatement)); + }; -const report$2 = ({name}) => `Argument '${name}' is missing`; + const report = ({name}) => `Argument '${name}' is missing`; -addArgs.addArgs = (args) => ({ - report: report$2, - fix: fix$2, - traverse: traverse$1(args), -}); + addArgs.addArgs = (args) => ({ + report, + fix, + traverse: traverse(args), + }); -const fix$2 = ({declaration, path, pattern, params, index}) => { - const declarationNode = template$1.ast.fresh(declaration); - - if (isBlockStatement(declarationNode)) { - const prop = createProperty(declarationNode.body[0]); - pattern.properties.push(prop); - - if (!isObjectPattern(params[index])) - return params.push(pattern); - - return; - } - - path.scope.block.params = [ - declarationNode, - ]; -}; + const fix = ({declaration, path, pattern, params, index}) => { + const declarationNode = template.ast.fresh(declaration); + + if (isBlockStatement(declarationNode)) { + const prop = createProperty(declarationNode.body[0]); + pattern.properties.push(prop); + + if (!isObjectPattern(params[index])) + return params.push(pattern); + + return; + } + + path.scope.block.params = [ + declarationNode, + ]; + }; -const traverse$1 = (args) => ({push, options}) => { - const allArgs = { - ...options.args, - ...args, - }; - - return { - ReferencedIdentifier(path) { - for (const [name, [declaration, pattern]] of entries$1(allArgs)) { - if (path.node.name !== name) - continue; - - if (path.scope.hasBinding(name)) - continue; - - if (!isCall(path)) - continue; - - const fnPath = path.find(isFunction); - - if (!fnPath) - continue; - - const {block} = fnPath.scope; - - if (!compareAny(path.scope.path, pattern)) - continue; - - const {params} = block; - - const [index, lastParam] = getObjectPattern(params); - - if (isObjectPattern(lastParam)) { - push({ - name, - index, - declaration, - path, - params, - pattern: lastParam, - }); - return; - } - - if (params.length >= 3) - return; - - push({ - name, - index, - declaration, - path, - params, - pattern: ObjectPattern([]), - }); - } - }, - }; -}; + const traverse = (args) => ({push, options}) => { + const allArgs = { + ...options.args, + ...args, + }; + + return { + ReferencedIdentifier(path) { + for (const [name, [declaration, pattern]] of entries(allArgs)) { + if (path.node.name !== name) + continue; + + if (path.scope.hasBinding(name)) + continue; + + if (!isCall(path)) + continue; + + const fnPath = path.find(isFunction); + + if (!fnPath) + continue; + + const {block} = fnPath.scope; + + if (!compareAny(path.scope.path, pattern)) + continue; + + const {params} = block; + + const [index, lastParam] = getObjectPattern(params); + + if (isObjectPattern(lastParam)) { + push({ + name, + index, + declaration, + path, + params, + pattern: lastParam, + }); + return; + } + + if (params.length >= 3) + return; + + push({ + name, + index, + declaration, + path, + params, + pattern: ObjectPattern([]), + }); + } + }, + }; + }; -function createProperty(node) { - if (!isLabeledStatement(node)) { - const {expression} = node; - return ObjectProperty(expression, expression, !COMPUTED, SHORTHAND); - } - - const {label, body} = node; - - return ObjectProperty(label, body.expression, !COMPUTED, SHORTHAND); -} + function createProperty(node) { + if (!isLabeledStatement(node)) { + const {expression} = node; + return ObjectProperty(expression, expression, !COMPUTED, SHORTHAND); + } + + const {label, body} = node; + + return ObjectProperty(label, body.expression, !COMPUTED, SHORTHAND); + } -function getObjectPattern(params) { - for (const [i, param] of params.entries()) { - if (isObjectPattern(param)) - return [i, param]; - } - - return [ - -1, - null, - ]; + function getObjectPattern(params) { + for (const [i, param] of params.entries()) { + if (isObjectPattern(param)) + return [i, param]; + } + + return [ + -1, + null, + ]; + } + return addArgs; } var matchFiles = {}; -// A simple implementation of make-array -function makeArray (subject) { - return Array.isArray(subject) - ? subject - : [subject] -} - -const EMPTY = ''; -const SPACE = ' '; -const ESCAPE = '\\'; -const REGEX_TEST_BLANK_LINE = /^\s+$/; -const REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/; -const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/; -const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/; -const REGEX_SPLITALL_CRLF = /\r?\n/g; -// /foo, -// ./foo, -// ../foo, -// . -// .. -const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/; - -const SLASH = '/'; - -// Do not use ternary expression here, since "istanbul ignore next" is buggy -let TMP_KEY_IGNORE = 'node-ignore'; -/* istanbul ignore else */ -if (typeof Symbol !== 'undefined') { - TMP_KEY_IGNORE = Symbol.for('node-ignore'); -} -const KEY_IGNORE = TMP_KEY_IGNORE; - -const define = (object, key, value) => - Object.defineProperty(object, key, {value}); - -const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; - -const RETURN_FALSE = () => false; - -// Sanitize the range of a regular expression -// The cases are complicated, see test cases for details -const sanitizeRange = range => range.replace( - REGEX_REGEXP_RANGE, - (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) - ? match - // Invalid range (out of order) which is ok for gitignore rules but - // fatal for JavaScript regular expression, so eliminate it. - : EMPTY -); - -// See fixtures #59 -const cleanRangeBackSlash = slashes => { - const {length} = slashes; - return slashes.slice(0, length - length % 2) -}; - -// > If the pattern ends with a slash, -// > it is removed for the purpose of the following description, -// > but it would only find a match with a directory. -// > In other words, foo/ will match a directory foo and paths underneath it, -// > but will not match a regular file or a symbolic link foo -// > (this is consistent with the way how pathspec works in general in Git). -// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`' -// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call -// you could use option `mark: true` with `glob` - -// '`foo/`' should not continue with the '`..`' -const REPLACERS = [ - - [ - // remove BOM - // TODO: - // Other similar zero-width characters? - /^\uFEFF/, - () => EMPTY - ], - - // > Trailing spaces are ignored unless they are quoted with backslash ("\") - [ - // (a\ ) -> (a ) - // (a ) -> (a) - // (a ) -> (a) - // (a \ ) -> (a ) - /((?:\\\\)*?)(\\?\s+)$/, - (_, m1, m2) => m1 + ( - m2.indexOf('\\') === 0 - ? SPACE - : EMPTY - ) - ], - - // replace (\ ) with ' ' - // (\ ) -> ' ' - // (\\ ) -> '\\ ' - // (\\\ ) -> '\\ ' - [ - /(\\+?)\s/g, - (_, m1) => { - const {length} = m1; - return m1.slice(0, length - length % 2) + SPACE - } - ], - - // Escape metacharacters - // which is written down by users but means special for regular expressions. - - // > There are 12 characters with special meanings: - // > - the backslash \, - // > - the caret ^, - // > - the dollar sign $, - // > - the period or dot ., - // > - the vertical bar or pipe symbol |, - // > - the question mark ?, - // > - the asterisk or star *, - // > - the plus sign +, - // > - the opening parenthesis (, - // > - the closing parenthesis ), - // > - and the opening square bracket [, - // > - the opening curly brace {, - // > These special characters are often called "metacharacters". - [ - /[\\$.|*+(){^]/g, - match => `\\${match}` - ], - - [ - // > a question mark (?) matches a single character - /(?!\\)\?/g, - () => '[^/]' - ], - - // leading slash - [ - - // > A leading slash matches the beginning of the pathname. - // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c". - // A leading slash matches the beginning of the pathname - /^\//, - () => '^' - ], - - // replace special metacharacter slash after the leading slash - [ - /\//g, - () => '\\/' - ], - - [ - // > A leading "**" followed by a slash means match in all directories. - // > For example, "**/foo" matches file or directory "foo" anywhere, - // > the same as pattern "foo". - // > "**/foo/bar" matches file or directory "bar" anywhere that is directly - // > under directory "foo". - // Notice that the '*'s have been replaced as '\\*' - /^\^*\\\*\\\*\\\//, - - // '**/foo' <-> 'foo' - () => '^(?:.*\\/)?' - ], - - // starting - [ - // there will be no leading '/' - // (which has been replaced by section "leading slash") - // If starts with '**', adding a '^' to the regular expression also works - /^(?=[^^])/, - function startingReplacer () { - // If has a slash `/` at the beginning or middle - return !/\/(?!$)/.test(this) - // > Prior to 2.22.1 - // > If the pattern does not contain a slash /, - // > Git treats it as a shell glob pattern - // Actually, if there is only a trailing slash, - // git also treats it as a shell glob pattern - - // After 2.22.1 (compatible but clearer) - // > If there is a separator at the beginning or middle (or both) - // > of the pattern, then the pattern is relative to the directory - // > level of the particular .gitignore file itself. - // > Otherwise the pattern may also match at any level below - // > the .gitignore level. - ? '(?:^|\\/)' - - // > Otherwise, Git treats the pattern as a shell glob suitable for - // > consumption by fnmatch(3) - : '^' - } - ], - - // two globstars - [ - // Use lookahead assertions so that we could match more than one `'/**'` - /\\\/\\\*\\\*(?=\\\/|$)/g, - - // Zero, one or several directories - // should not use '*', or it will be replaced by the next replacer - - // Check if it is not the last `'/**'` - (_, index, str) => index + 6 < str.length - - // case: /**/ - // > A slash followed by two consecutive asterisks then a slash matches - // > zero or more directories. - // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on. - // '/**/' - ? '(?:\\/[^\\/]+)*' - - // case: /** - // > A trailing `"/**"` matches everything inside. - - // #21: everything inside but it should not include the current folder - : '\\/.+' - ], - - // normal intermediate wildcards - [ - // Never replace escaped '*' - // ignore rule '\*' will match the path '*' - - // 'abc.*/' -> go - // 'abc.*' -> skip this rule, - // coz trailing single wildcard will be handed by [trailing wildcard] - /(^|[^\\]+)(\\\*)+(?=.+)/g, - - // '*.js' matches '.js' - // '*.js' doesn't match 'abc' - (_, p1, p2) => { - // 1. - // > An asterisk "*" matches anything except a slash. - // 2. - // > Other consecutive asterisks are considered regular asterisks - // > and will match according to the previous rules. - const unescaped = p2.replace(/\\\*/g, '[^\\/]*'); - return p1 + unescaped - } - ], - - [ - // unescape, revert step 3 except for back slash - // For example, if a user escape a '\\*', - // after step 3, the result will be '\\\\\\*' - /\\\\\\(?=[$.|*+(){^])/g, - () => ESCAPE - ], - - [ - // '\\\\' -> '\\' - /\\\\/g, - () => ESCAPE - ], - - [ - // > The range notation, e.g. [a-zA-Z], - // > can be used to match one of the characters in a range. - - // `\` is escaped by step 3 - /(\\)?\[([^\]/]*?)(\\*)($|\])/g, - (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE - // '\\[bar]' -> '\\\\[bar\\]' - ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` - : close === ']' - ? endEscape.length % 2 === 0 - // A normal case, and it is a range notation - // '[bar]' - // '[bar\\\\]' - ? `[${sanitizeRange(range)}${endEscape}]` - // Invalid range notaton - // '[bar\\]' -> '[bar\\\\]' - : '[]' - : '[]' - ], - - // ending - [ - // 'js' will not match 'js.' - // 'ab' will not match 'abc' - /(?:[^*])$/, - - // WTF! - // https://git-scm.com/docs/gitignore - // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1) - // which re-fixes #24, #38 - - // > If there is a separator at the end of the pattern then the pattern - // > will only match directories, otherwise the pattern can match both - // > files and directories. - - // 'js*' will not match 'a.js' - // 'js/' will not match 'a.js' - // 'js' will match 'a.js' and 'a.js/' - match => /\/$/.test(match) - // foo/ will not match 'foo' - ? `${match}$` - // foo matches 'foo' and 'foo/' - : `${match}(?=$|\\/$)` - ], - - // trailing wildcard - [ - /(\^|\\\/)?\\\*$/, - (_, p1) => { - const prefix = p1 - // '\^': - // '/*' does not match EMPTY - // '/*' does not match everything - - // '\\\/': - // 'abc/*' does not match 'abc/' - ? `${p1}[^/]+` - - // 'a*' matches 'a' - // 'a*' matches 'aa' - : '[^/]*'; - - return `${prefix}(?=$|\\/$)` - } - ], -]; +var ignore$1; +var hasRequiredIgnore$1; + +function requireIgnore$1 () { + if (hasRequiredIgnore$1) return ignore$1; + hasRequiredIgnore$1 = 1; + // A simple implementation of make-array + function makeArray (subject) { + return Array.isArray(subject) + ? subject + : [subject] + } -// A simple cache, because an ignore rule only has only one certain meaning -const regexCache = Object.create(null); + const EMPTY = ''; + const SPACE = ' '; + const ESCAPE = '\\'; + const REGEX_TEST_BLANK_LINE = /^\s+$/; + const REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/; + const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/; + const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/; + const REGEX_SPLITALL_CRLF = /\r?\n/g; + // /foo, + // ./foo, + // ../foo, + // . + // .. + const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/; + + const SLASH = '/'; + + // Do not use ternary expression here, since "istanbul ignore next" is buggy + let TMP_KEY_IGNORE = 'node-ignore'; + /* istanbul ignore else */ + if (typeof Symbol !== 'undefined') { + TMP_KEY_IGNORE = Symbol.for('node-ignore'); + } + const KEY_IGNORE = TMP_KEY_IGNORE; + + const define = (object, key, value) => + Object.defineProperty(object, key, {value}); + + const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; + + const RETURN_FALSE = () => false; + + // Sanitize the range of a regular expression + // The cases are complicated, see test cases for details + const sanitizeRange = range => range.replace( + REGEX_REGEXP_RANGE, + (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) + ? match + // Invalid range (out of order) which is ok for gitignore rules but + // fatal for JavaScript regular expression, so eliminate it. + : EMPTY + ); + + // See fixtures #59 + const cleanRangeBackSlash = slashes => { + const {length} = slashes; + return slashes.slice(0, length - length % 2) + }; -// @param {pattern} -const makeRegex = (pattern, ignoreCase) => { - let source = regexCache[pattern]; + // > If the pattern ends with a slash, + // > it is removed for the purpose of the following description, + // > but it would only find a match with a directory. + // > In other words, foo/ will match a directory foo and paths underneath it, + // > but will not match a regular file or a symbolic link foo + // > (this is consistent with the way how pathspec works in general in Git). + // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`' + // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call + // you could use option `mark: true` with `glob` + + // '`foo/`' should not continue with the '`..`' + const REPLACERS = [ + + [ + // remove BOM + // TODO: + // Other similar zero-width characters? + /^\uFEFF/, + () => EMPTY + ], + + // > Trailing spaces are ignored unless they are quoted with backslash ("\") + [ + // (a\ ) -> (a ) + // (a ) -> (a) + // (a ) -> (a) + // (a \ ) -> (a ) + /((?:\\\\)*?)(\\?\s+)$/, + (_, m1, m2) => m1 + ( + m2.indexOf('\\') === 0 + ? SPACE + : EMPTY + ) + ], + + // replace (\ ) with ' ' + // (\ ) -> ' ' + // (\\ ) -> '\\ ' + // (\\\ ) -> '\\ ' + [ + /(\\+?)\s/g, + (_, m1) => { + const {length} = m1; + return m1.slice(0, length - length % 2) + SPACE + } + ], + + // Escape metacharacters + // which is written down by users but means special for regular expressions. + + // > There are 12 characters with special meanings: + // > - the backslash \, + // > - the caret ^, + // > - the dollar sign $, + // > - the period or dot ., + // > - the vertical bar or pipe symbol |, + // > - the question mark ?, + // > - the asterisk or star *, + // > - the plus sign +, + // > - the opening parenthesis (, + // > - the closing parenthesis ), + // > - and the opening square bracket [, + // > - the opening curly brace {, + // > These special characters are often called "metacharacters". + [ + /[\\$.|*+(){^]/g, + match => `\\${match}` + ], + + [ + // > a question mark (?) matches a single character + /(?!\\)\?/g, + () => '[^/]' + ], + + // leading slash + [ + + // > A leading slash matches the beginning of the pathname. + // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c". + // A leading slash matches the beginning of the pathname + /^\//, + () => '^' + ], + + // replace special metacharacter slash after the leading slash + [ + /\//g, + () => '\\/' + ], + + [ + // > A leading "**" followed by a slash means match in all directories. + // > For example, "**/foo" matches file or directory "foo" anywhere, + // > the same as pattern "foo". + // > "**/foo/bar" matches file or directory "bar" anywhere that is directly + // > under directory "foo". + // Notice that the '*'s have been replaced as '\\*' + /^\^*\\\*\\\*\\\//, + + // '**/foo' <-> 'foo' + () => '^(?:.*\\/)?' + ], + + // starting + [ + // there will be no leading '/' + // (which has been replaced by section "leading slash") + // If starts with '**', adding a '^' to the regular expression also works + /^(?=[^^])/, + function startingReplacer () { + // If has a slash `/` at the beginning or middle + return !/\/(?!$)/.test(this) + // > Prior to 2.22.1 + // > If the pattern does not contain a slash /, + // > Git treats it as a shell glob pattern + // Actually, if there is only a trailing slash, + // git also treats it as a shell glob pattern + + // After 2.22.1 (compatible but clearer) + // > If there is a separator at the beginning or middle (or both) + // > of the pattern, then the pattern is relative to the directory + // > level of the particular .gitignore file itself. + // > Otherwise the pattern may also match at any level below + // > the .gitignore level. + ? '(?:^|\\/)' + + // > Otherwise, Git treats the pattern as a shell glob suitable for + // > consumption by fnmatch(3) + : '^' + } + ], + + // two globstars + [ + // Use lookahead assertions so that we could match more than one `'/**'` + /\\\/\\\*\\\*(?=\\\/|$)/g, + + // Zero, one or several directories + // should not use '*', or it will be replaced by the next replacer + + // Check if it is not the last `'/**'` + (_, index, str) => index + 6 < str.length + + // case: /**/ + // > A slash followed by two consecutive asterisks then a slash matches + // > zero or more directories. + // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on. + // '/**/' + ? '(?:\\/[^\\/]+)*' + + // case: /** + // > A trailing `"/**"` matches everything inside. + + // #21: everything inside but it should not include the current folder + : '\\/.+' + ], + + // normal intermediate wildcards + [ + // Never replace escaped '*' + // ignore rule '\*' will match the path '*' + + // 'abc.*/' -> go + // 'abc.*' -> skip this rule, + // coz trailing single wildcard will be handed by [trailing wildcard] + /(^|[^\\]+)(\\\*)+(?=.+)/g, + + // '*.js' matches '.js' + // '*.js' doesn't match 'abc' + (_, p1, p2) => { + // 1. + // > An asterisk "*" matches anything except a slash. + // 2. + // > Other consecutive asterisks are considered regular asterisks + // > and will match according to the previous rules. + const unescaped = p2.replace(/\\\*/g, '[^\\/]*'); + return p1 + unescaped + } + ], + + [ + // unescape, revert step 3 except for back slash + // For example, if a user escape a '\\*', + // after step 3, the result will be '\\\\\\*' + /\\\\\\(?=[$.|*+(){^])/g, + () => ESCAPE + ], + + [ + // '\\\\' -> '\\' + /\\\\/g, + () => ESCAPE + ], + + [ + // > The range notation, e.g. [a-zA-Z], + // > can be used to match one of the characters in a range. + + // `\` is escaped by step 3 + /(\\)?\[([^\]/]*?)(\\*)($|\])/g, + (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE + // '\\[bar]' -> '\\\\[bar\\]' + ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` + : close === ']' + ? endEscape.length % 2 === 0 + // A normal case, and it is a range notation + // '[bar]' + // '[bar\\\\]' + ? `[${sanitizeRange(range)}${endEscape}]` + // Invalid range notaton + // '[bar\\]' -> '[bar\\\\]' + : '[]' + : '[]' + ], + + // ending + [ + // 'js' will not match 'js.' + // 'ab' will not match 'abc' + /(?:[^*])$/, + + // WTF! + // https://git-scm.com/docs/gitignore + // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1) + // which re-fixes #24, #38 + + // > If there is a separator at the end of the pattern then the pattern + // > will only match directories, otherwise the pattern can match both + // > files and directories. + + // 'js*' will not match 'a.js' + // 'js/' will not match 'a.js' + // 'js' will match 'a.js' and 'a.js/' + match => /\/$/.test(match) + // foo/ will not match 'foo' + ? `${match}$` + // foo matches 'foo' and 'foo/' + : `${match}(?=$|\\/$)` + ], + + // trailing wildcard + [ + /(\^|\\\/)?\\\*$/, + (_, p1) => { + const prefix = p1 + // '\^': + // '/*' does not match EMPTY + // '/*' does not match everything + + // '\\\/': + // 'abc/*' does not match 'abc/' + ? `${p1}[^/]+` + + // 'a*' matches 'a' + // 'a*' matches 'aa' + : '[^/]*'; + + return `${prefix}(?=$|\\/$)` + } + ], + ]; - if (!source) { - source = REPLACERS.reduce( - (prev, [matcher, replacer]) => - prev.replace(matcher, replacer.bind(pattern)), - pattern - ); - regexCache[pattern] = source; - } + // A simple cache, because an ignore rule only has only one certain meaning + const regexCache = Object.create(null); - return ignoreCase - ? new RegExp(source, 'i') - : new RegExp(source) -}; + // @param {pattern} + const makeRegex = (pattern, ignoreCase) => { + let source = regexCache[pattern]; -const isString$1 = subject => typeof subject === 'string'; - -// > A blank line matches no files, so it can serve as a separator for readability. -const checkPattern = pattern => pattern - && isString$1(pattern) - && !REGEX_TEST_BLANK_LINE.test(pattern) - && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) - - // > A line starting with # serves as a comment. - && pattern.indexOf('#') !== 0; - -const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF); - -class IgnoreRule { - constructor ( - origin, - pattern, - negative, - regex - ) { - this.origin = origin; - this.pattern = pattern; - this.negative = negative; - this.regex = regex; - } -} + if (!source) { + source = REPLACERS.reduce( + (prev, [matcher, replacer]) => + prev.replace(matcher, replacer.bind(pattern)), + pattern + ); + regexCache[pattern] = source; + } -const createRule = (pattern, ignoreCase) => { - const origin = pattern; - let negative = false; + return ignoreCase + ? new RegExp(source, 'i') + : new RegExp(source) + }; - // > An optional prefix "!" which negates the pattern; - if (pattern.indexOf('!') === 0) { - negative = true; - pattern = pattern.substr(1); - } + const isString = subject => typeof subject === 'string'; + + // > A blank line matches no files, so it can serve as a separator for readability. + const checkPattern = pattern => pattern + && isString(pattern) + && !REGEX_TEST_BLANK_LINE.test(pattern) + && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) + + // > A line starting with # serves as a comment. + && pattern.indexOf('#') !== 0; + + const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF); + + class IgnoreRule { + constructor ( + origin, + pattern, + negative, + regex + ) { + this.origin = origin; + this.pattern = pattern; + this.negative = negative; + this.regex = regex; + } + } - pattern = pattern - // > Put a backslash ("\") in front of the first "!" for patterns that - // > begin with a literal "!", for example, `"\!important!.txt"`. - .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!') - // > Put a backslash ("\") in front of the first hash for patterns that - // > begin with a hash. - .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#'); - - const regex = makeRegex(pattern, ignoreCase); - - return new IgnoreRule( - origin, - pattern, - negative, - regex - ) -}; + const createRule = (pattern, ignoreCase) => { + const origin = pattern; + let negative = false; -const throwError = (message, Ctor) => { - throw new Ctor(message) -}; + // > An optional prefix "!" which negates the pattern; + if (pattern.indexOf('!') === 0) { + negative = true; + pattern = pattern.substr(1); + } -const checkPath = (path, originalPath, doThrow) => { - if (!isString$1(path)) { - return doThrow( - `path must be a string, but got \`${originalPath}\``, - TypeError - ) - } + pattern = pattern + // > Put a backslash ("\") in front of the first "!" for patterns that + // > begin with a literal "!", for example, `"\!important!.txt"`. + .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!') + // > Put a backslash ("\") in front of the first hash for patterns that + // > begin with a hash. + .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#'); + + const regex = makeRegex(pattern, ignoreCase); + + return new IgnoreRule( + origin, + pattern, + negative, + regex + ) + }; - // We don't know if we should ignore EMPTY, so throw - if (!path) { - return doThrow(`path must not be empty`, TypeError) - } + const throwError = (message, Ctor) => { + throw new Ctor(message) + }; - // Check if it is a relative path - if (checkPath.isNotRelative(path)) { - const r = '`path.relative()`d'; - return doThrow( - `path should be a ${r} string, but got "${originalPath}"`, - RangeError - ) - } + const checkPath = (path, originalPath, doThrow) => { + if (!isString(path)) { + return doThrow( + `path must be a string, but got \`${originalPath}\``, + TypeError + ) + } - return true -}; + // We don't know if we should ignore EMPTY, so throw + if (!path) { + return doThrow(`path must not be empty`, TypeError) + } -const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path); + // Check if it is a relative path + if (checkPath.isNotRelative(path)) { + const r = '`path.relative()`d'; + return doThrow( + `path should be a ${r} string, but got "${originalPath}"`, + RangeError + ) + } -checkPath.isNotRelative = isNotRelative; -checkPath.convert = p => p; + return true + }; -class Ignore { - constructor ({ - ignorecase = true, - ignoreCase = ignorecase, - allowRelativePaths = false - } = {}) { - define(this, KEY_IGNORE, true); + const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path); - this._rules = []; - this._ignoreCase = ignoreCase; - this._allowRelativePaths = allowRelativePaths; - this._initCache(); - } + checkPath.isNotRelative = isNotRelative; + checkPath.convert = p => p; - _initCache () { - this._ignoreCache = Object.create(null); - this._testCache = Object.create(null); - } + class Ignore { + constructor ({ + ignorecase = true, + ignoreCase = ignorecase, + allowRelativePaths = false + } = {}) { + define(this, KEY_IGNORE, true); - _addPattern (pattern) { - // #32 - if (pattern && pattern[KEY_IGNORE]) { - this._rules = this._rules.concat(pattern._rules); - this._added = true; - return - } + this._rules = []; + this._ignoreCase = ignoreCase; + this._allowRelativePaths = allowRelativePaths; + this._initCache(); + } - if (checkPattern(pattern)) { - const rule = createRule(pattern, this._ignoreCase); - this._added = true; - this._rules.push(rule); - } - } + _initCache () { + this._ignoreCache = Object.create(null); + this._testCache = Object.create(null); + } - // @param {Array | string | Ignore} pattern - add (pattern) { - this._added = false; + _addPattern (pattern) { + // #32 + if (pattern && pattern[KEY_IGNORE]) { + this._rules = this._rules.concat(pattern._rules); + this._added = true; + return + } - makeArray( - isString$1(pattern) - ? splitPattern(pattern) - : pattern - ).forEach(this._addPattern, this); + if (checkPattern(pattern)) { + const rule = createRule(pattern, this._ignoreCase); + this._added = true; + this._rules.push(rule); + } + } - // Some rules have just added to the ignore, - // making the behavior changed. - if (this._added) { - this._initCache(); - } + // @param {Array | string | Ignore} pattern + add (pattern) { + this._added = false; - return this - } + makeArray( + isString(pattern) + ? splitPattern(pattern) + : pattern + ).forEach(this._addPattern, this); - // legacy - addPattern (pattern) { - return this.add(pattern) - } + // Some rules have just added to the ignore, + // making the behavior changed. + if (this._added) { + this._initCache(); + } - // | ignored : unignored - // negative | 0:0 | 0:1 | 1:0 | 1:1 - // -------- | ------- | ------- | ------- | -------- - // 0 | TEST | TEST | SKIP | X - // 1 | TESTIF | SKIP | TEST | X - - // - SKIP: always skip - // - TEST: always test - // - TESTIF: only test if checkUnignored - // - X: that never happen - - // @param {boolean} whether should check if the path is unignored, - // setting `checkUnignored` to `false` could reduce additional - // path matching. - - // @returns {TestResult} true if a file is ignored - _testOne (path, checkUnignored) { - let ignored = false; - let unignored = false; - - this._rules.forEach(rule => { - const {negative} = rule; - if ( - unignored === negative && ignored !== unignored - || negative && !ignored && !unignored && !checkUnignored - ) { - return - } + return this + } - const matched = rule.regex.test(path); + // legacy + addPattern (pattern) { + return this.add(pattern) + } - if (matched) { - ignored = !negative; - unignored = negative; - } - }); + // | ignored : unignored + // negative | 0:0 | 0:1 | 1:0 | 1:1 + // -------- | ------- | ------- | ------- | -------- + // 0 | TEST | TEST | SKIP | X + // 1 | TESTIF | SKIP | TEST | X + + // - SKIP: always skip + // - TEST: always test + // - TESTIF: only test if checkUnignored + // - X: that never happen + + // @param {boolean} whether should check if the path is unignored, + // setting `checkUnignored` to `false` could reduce additional + // path matching. + + // @returns {TestResult} true if a file is ignored + _testOne (path, checkUnignored) { + let ignored = false; + let unignored = false; + + this._rules.forEach(rule => { + const {negative} = rule; + if ( + unignored === negative && ignored !== unignored + || negative && !ignored && !unignored && !checkUnignored + ) { + return + } - return { - ignored, - unignored - } - } + const matched = rule.regex.test(path); - // @returns {TestResult} - _test (originalPath, cache, checkUnignored, slices) { - const path = originalPath - // Supports nullable path - && checkPath.convert(originalPath); - - checkPath( - path, - originalPath, - this._allowRelativePaths - ? RETURN_FALSE - : throwError - ); + if (matched) { + ignored = !negative; + unignored = negative; + } + }); - return this._t(path, cache, checkUnignored, slices) - } + return { + ignored, + unignored + } + } - _t (path, cache, checkUnignored, slices) { - if (path in cache) { - return cache[path] - } + // @returns {TestResult} + _test (originalPath, cache, checkUnignored, slices) { + const path = originalPath + // Supports nullable path + && checkPath.convert(originalPath); + + checkPath( + path, + originalPath, + this._allowRelativePaths + ? RETURN_FALSE + : throwError + ); - if (!slices) { - // path/to/a.js - // ['path', 'to', 'a.js'] - slices = path.split(SLASH); - } + return this._t(path, cache, checkUnignored, slices) + } - slices.pop(); + _t (path, cache, checkUnignored, slices) { + if (path in cache) { + return cache[path] + } - // If the path has no parent directory, just test it - if (!slices.length) { - return cache[path] = this._testOne(path, checkUnignored) - } + if (!slices) { + // path/to/a.js + // ['path', 'to', 'a.js'] + slices = path.split(SLASH); + } - const parent = this._t( - slices.join(SLASH) + SLASH, - cache, - checkUnignored, - slices - ); + slices.pop(); - // If the path contains a parent directory, check the parent first - return cache[path] = parent.ignored - // > It is not possible to re-include a file if a parent directory of - // > that file is excluded. - ? parent - : this._testOne(path, checkUnignored) - } + // If the path has no parent directory, just test it + if (!slices.length) { + return cache[path] = this._testOne(path, checkUnignored) + } - ignores (path) { - return this._test(path, this._ignoreCache, false).ignored - } + const parent = this._t( + slices.join(SLASH) + SLASH, + cache, + checkUnignored, + slices + ); - createFilter () { - return path => !this.ignores(path) - } + // If the path contains a parent directory, check the parent first + return cache[path] = parent.ignored + // > It is not possible to re-include a file if a parent directory of + // > that file is excluded. + ? parent + : this._testOne(path, checkUnignored) + } - filter (paths) { - return makeArray(paths).filter(this.createFilter()) - } + ignores (path) { + return this._test(path, this._ignoreCache, false).ignored + } - // @returns {TestResult} - test (path) { - return this._test(path, this._testCache, true) - } -} + createFilter () { + return path => !this.ignores(path) + } -const factory = options => new Ignore(options); + filter (paths) { + return makeArray(paths).filter(this.createFilter()) + } -const isPathValid = path => - checkPath(path && checkPath.convert(path), path, RETURN_FALSE); + // @returns {TestResult} + test (path) { + return this._test(path, this._testCache, true) + } + } -factory.isPathValid = isPathValid; + const factory = options => new Ignore(options); -// Fixes typescript -factory.default = factory; + const isPathValid = path => + checkPath(path && checkPath.convert(path), path, RETURN_FALSE); -var ignore$2 = factory; + factory.isPathValid = isPathValid; -// Windows -// -------------------------------------------------------------- -/* istanbul ignore if */ -if ( - // Detect `process` so that it can run in browsers. - typeof browser$1$1 !== 'undefined' - && ( - {} && browser$1$1.env.IGNORE_TEST_WIN32 - || "unix" === 'win32' - ) -) { - /* eslint no-control-regex: "off" */ - const makePosix = str => /^\\\\\?\\/.test(str) - || /["<>|\u0000-\u001F]+/u.test(str) - ? str - : str.replace(/\\/g, '/'); + // Fixes typescript + factory.default = factory; - checkPath.convert = makePosix; + ignore$1 = factory; - // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/' - // 'd:\\foo' - const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i; - checkPath.isNotRelative = path => - REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) - || isNotRelative(path); + // Windows + // -------------------------------------------------------------- + /* istanbul ignore if */ + if ( + // Detect `process` so that it can run in browsers. + typeof browser$1$1 !== 'undefined' + && ( + {} && browser$1$1.env.IGNORE_TEST_WIN32 + || "unix" === 'win32' + ) + ) { + /* eslint no-control-regex: "off" */ + const makePosix = str => /^\\\\\?\\/.test(str) + || /["<>|\u0000-\u001F]+/u.test(str) + ? str + : str.replace(/\\/g, '/'); + + checkPath.convert = makePosix; + + // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/' + // 'd:\\foo' + const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i; + checkPath.isNotRelative = path => + REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) + || isNotRelative(path); + } + return ignore$1; } -ignore$2.default; +var ignores; +var hasRequiredIgnores; -const {relative} = require$$0$2; -const ignore$1 = ignore$2; +function requireIgnores () { + if (hasRequiredIgnores) return ignores; + hasRequiredIgnores = 1; -const isNegative = (a) => !a.indexOf('!'); -const positive = (a) => a.replace(/^!/, ''); + const {relative} = require$$0$2; + const ignore = requireIgnore$1(); -var ignores$2 = (dirOpt, resolvedName, options = {}) => { - const relativeName = relative(dirOpt, resolvedName); - const ignorer = ignore$1(); - const ignoreList = mergeIgnores(options.ignore || []); - - ignorer.add(ignoreList); - - return dirOpt && ignorer.ignores(relativeName); -}; + const isNegative = (a) => !a.indexOf('!'); + const positive = (a) => a.replace(/^!/, ''); -function mergeIgnores(ignores) { - for (const [i, str] of ignores.entries()) { - const positiveIndex = ignores.indexOf(positive(str)); - - if (isNegative(str) && positiveIndex > i) - ignores[positiveIndex] = str; - } - - const noDuplicates = new Set(ignores); - - return Array.from(noDuplicates); + ignores = (dirOpt, resolvedName, options = {}) => { + const relativeName = relative(dirOpt, resolvedName); + const ignorer = ignore(); + const ignoreList = mergeIgnores(options.ignore || []); + + ignorer.add(ignoreList); + + return dirOpt && ignorer.ignores(relativeName); + }; + + function mergeIgnores(ignores) { + for (const [i, str] of ignores.entries()) { + const positiveIndex = ignores.indexOf(positive(str)); + + if (isNegative(str) && positiveIndex > i) + ignores[positiveIndex] = str; + } + + const noDuplicates = new Set(ignores); + + return Array.from(noDuplicates); + } + return ignores; } -ignores$2.default; +var hasRequiredMatchFiles; -const path = require$$0$2; +function requireMatchFiles () { + if (hasRequiredMatchFiles) return matchFiles; + hasRequiredMatchFiles = 1; -const {parse: parse$2, print: print$1} = parser$6; -const {transform: transform$1} = transform$5; -const {findPlaces: findPlaces$1} = findPlaces$2; -const ignores$1 = ignores$2; + const path = require$$0$2; -const {toJS, fromJS} = json; + const {parse, print} = requireParser$1(); + const {transform} = requireTransform$1(); + const {findPlaces} = requireFindPlaces(); + const ignores = requireIgnores(); -const { - readFileContent: readFileContent$1, - findFile: findFile$1, - writeFileContent, - getFilename: getFilename$1, - createFile, - removeFile, - getParentDirectory: getParentDirectory$1, -} = filesystem; + const {toJS, fromJS} = requireJson$1(); + + const { + readFileContent, + findFile, + writeFileContent, + getFilename, + createFile, + removeFile, + getParentDirectory, + } = requireFilesystem(); + + const {join} = path; + + const isObject = (a) => a && typeof a === 'object'; + const {entries} = Object; + const report = (path, {message}) => message; + + matchFiles.matchFiles = (files) => { + check(files); + const scan = createScan(files); + + return { + fix, + scan, + report, + }; + }; -const {join: join$1} = path; + function fix(inputFile, {dirPath, mainPath, matchInputFilename, outputFilename, matchedJS, matchedAST, options}) { + transform(matchedAST, matchedJS, options); + + const matchedJSON = magicPrint(outputFilename, matchedAST); + const outputFile = getOutputFile(mainPath, { + dirPath, + matchInputFilename, + outputFilename, + inputFile, + }); + + writeFileContent(outputFile, matchedJSON); + + if (inputFile !== outputFile) + removeFile(inputFile); + } -const isObject = (a) => a && typeof a === 'object'; -const {entries} = Object; -const report$1 = (path, {message}) => message; + const createScan = (files) => (mainPath, {push, progress, options}) => { + const allFiles = []; + const cwd = getFilename(mainPath); + + for (const [filename, rawOptions] of entries(files)) { + const [matchInputFilename, outputFilename = matchInputFilename] = parseMatcher(filename, options); + const inputFiles = findFile(mainPath, matchInputFilename); + + for (const inputFile of inputFiles) { + const dirPath = getParentDirectory(inputFile); + const inputFilename = getFilename(inputFile); + + if (ignores(cwd, inputFilename, options)) + continue; + + allFiles.push({ + mainPath, + dirPath, + matchInputFilename, + rawOptions, + inputFile, + inputFilename, + outputFilename, + }); + } + } + + const n = allFiles.length; + + for (const [i, current] of allFiles.entries()) { + const { + dirPath, + matchInputFilename, + inputFile, + inputFilename, + outputFilename, + rawOptions, + mainPath, + } = current; + + progress({ + i, + n, + }); + + const fileContent = readFileContent(inputFile) || '{}'; + const [matchedJS, matchedAST] = magicParse(inputFilename, fileContent); + + const options = parseOptions(inputFilename, rawOptions); + const places = findPlaces(matchedAST, matchedJS, options); + + if (!places.length) + continue; + + const {message} = places[0]; + + push(inputFile, { + dirPath, + mainPath, + matchInputFilename, + + outputFilename, + message, + options, + + matchedAST, + matchedJS, + }); + } + }; -matchFiles.matchFiles = (files) => { - check$1(files); - const scan = createScan(files); - - return { - fix: fix$1, - scan, - report: report$1, - }; -}; + function magicParse(name, content) { + if (/\.json$/.test(name)) { + const js = toJS(content); + const ast = parse(js); + + return [js, ast]; + } + + if (/\.(c|m)?ts(x)?$/.test(name)) { + const ast = parse(content, { + isTS: true, + }); + + return [content, ast]; + } + + return [content, parse(content)]; + } -function fix$1(inputFile, {dirPath, mainPath, matchInputFilename, outputFilename, matchedJS, matchedAST, options}) { - transform$1(matchedAST, matchedJS, options); - - const matchedJSON = magicPrint(outputFilename, matchedAST); - const outputFile = getOutputFile(mainPath, { - dirPath, - matchInputFilename, - outputFilename, - inputFile, - }); - - writeFileContent(outputFile, matchedJSON); - - if (inputFile !== outputFile) - removeFile(inputFile); -} + function magicPrint(name, ast) { + if (/\.json$/.test(name)) { + const js = print(ast); + + return fromJS(js); + } + + return print(ast); + } -const createScan = (files) => (mainPath, {push, progress, options}) => { - const allFiles = []; - const cwd = getFilename$1(mainPath); - - for (const [filename, rawOptions] of entries(files)) { - const [matchInputFilename, outputFilename = matchInputFilename] = parseMatcher(filename, options); - const inputFiles = findFile$1(mainPath, matchInputFilename); - - for (const inputFile of inputFiles) { - const dirPath = getParentDirectory$1(inputFile); - const inputFilename = getFilename$1(inputFile); - - if (ignores$1(cwd, inputFilename, options)) - continue; - - allFiles.push({ - mainPath, - dirPath, - matchInputFilename, - rawOptions, - inputFile, - inputFilename, - outputFilename, - }); - } - } - - const n = allFiles.length; - - for (const [i, current] of allFiles.entries()) { - const { - dirPath, - matchInputFilename, - inputFile, - inputFilename, - outputFilename, - rawOptions, - mainPath, - } = current; - - progress({ - i, - n, - }); - - const fileContent = readFileContent$1(inputFile) || '{}'; - const [matchedJS, matchedAST] = magicParse(inputFilename, fileContent); - - const options = parseOptions(inputFilename, rawOptions); - const places = findPlaces$1(matchedAST, matchedJS, options); - - if (!places.length) - continue; - - const {message} = places[0]; - - push(inputFile, { - dirPath, - mainPath, - matchInputFilename, - - outputFilename, - message, - options, - - matchedAST, - matchedJS, - }); - } -}; + function check(files) { + for (const [, plugin] of entries(files)) { + if (!isObject(plugin)) + throw Error(`☝️ Looks like provided to 'matchFiles()' typeof of plugin is not an 'object' but '${typeof plugin}'`); + } + } -function magicParse(name, content) { - if (/\.json$/.test(name)) { - const js = toJS(content); - const ast = parse$2(js); - - return [js, ast]; - } - - if (/\.(c|m)?ts(x)?$/.test(name)) { - const ast = parse$2(content, { - isTS: true, - }); - - return [content, ast]; - } - - return [content, parse$2(content)]; -} + function getOutputFile(path, {dirPath, matchInputFilename, outputFilename, inputFile}) { + if (matchInputFilename === outputFilename) + return inputFile; + + const name = join(getFilename(dirPath), outputFilename); + const [outputFile] = findFile(dirPath, name); + + if (outputFile) + return outputFile; + + return createFile(dirPath, outputFilename); + } -function magicPrint(name, ast) { - if (/\.json$/.test(name)) { - const js = print$1(ast); - - return fromJS(js); - } - - return print$1(ast); -} + function parseMatcher(matcher, options) { + const {filename} = options; + + if (!filename) + return matcher.split(' -> '); + + const {ext, name} = path.parse(filename); + + matcher = matcher.replaceAll(`__name`, name); + matcher = matcher.replaceAll(`__ext`, ext); + + return matcher.split(' -> '); + } -function check$1(files) { - for (const [, plugin] of entries(files)) { - if (!isObject(plugin)) - throw Error(`☝️ Looks like provided to 'matchFiles()' typeof of plugin is not an 'object' but '${typeof plugin}'`); - } + function parseOptions(inputFilename, rawOptions) { + if (rawOptions.plugins) + return rawOptions; + + const name = `match-file: ${inputFilename}`; + + const plugins = [ + [name, rawOptions], + ]; + + return { + plugins, + }; + } + return matchFiles; } -function getOutputFile(path, {dirPath, matchInputFilename, outputFilename, inputFile}) { - if (matchInputFilename === outputFilename) - return inputFile; - - const name = join$1(getFilename$1(dirPath), outputFilename); - const [outputFile] = findFile$1(dirPath, name); - - if (outputFile) - return outputFile; - - return createFile(dirPath, outputFilename); -} +var renameFiles = {}; -function parseMatcher(matcher, options) { - const {filename} = options; - - if (!filename) - return matcher.split(' -> '); - - const {ext, name} = path.parse(filename); - - matcher = matcher.replaceAll(`__name`, name); - matcher = matcher.replaceAll(`__ext`, ext); - - return matcher.split(' -> '); -} +var hasRequiredRenameFiles; -function parseOptions(inputFilename, rawOptions) { - if (rawOptions.plugins) - return rawOptions; - - const name = `match-file: ${inputFilename}`; - - const plugins = [ - [name, rawOptions], - ]; - - return { - plugins, - }; -} +function requireRenameFiles () { + if (hasRequiredRenameFiles) return renameFiles; + hasRequiredRenameFiles = 1; -var renameFiles = {}; + const {join} = require$$0$2; -const {join} = require$$0$2; - -const { - getParentDirectory, - getFilename, - readFileContent, - findFile, - renameFile, -} = filesystem; - -const {parse: parse$1} = JSON; - -renameFiles.renameFiles = ({type, mask, rename}) => ({ - report, - fix, - scan: scan({ - type, - mask, - rename, - }), -}); + const { + getParentDirectory, + getFilename, + readFileContent, + findFile, + renameFile, + } = requireFilesystem(); + + const {parse} = JSON; + + renameFiles.renameFiles = ({type, mask, rename}) => ({ + report, + fix, + scan: scan({ + type, + mask, + rename, + }), + }); -const report = (file, {from, to}) => `Rename '${from}' to '${to}'`; + const report = (file, {from, to}) => `Rename '${from}' to '${to}'`; -const fix = (file, {to}) => { - renameFile(file, to); -}; + const fix = (file, {to}) => { + renameFile(file, to); + }; -const scan = ({type, mask, rename}) => (path, {push, trackFile}) => { - for (const file of trackFile(path, mask)) { - if (type && !checkType(type, file)) - continue; - - const from = getFilename(file); - const to = rename(from); - - push(file, { - from, - to, - }); - } -}; + const scan = ({type, mask, rename}) => (path, {push, trackFile}) => { + for (const file of trackFile(path, mask)) { + if (type && !checkType(type, file)) + continue; + + const from = getFilename(file); + const to = rename(from); + + push(file, { + from, + to, + }); + } + }; -function checkType(type, file) { - const packagePath = findUpPackage(file); - - if (type === 'commonjs' && !packagePath) - return true; - - if (!packagePath) - return false; - - const packageContent = readFileContent(packagePath); - - if (!packageContent) - return false; - - const info = parse$1(packageContent); - const infoType = info.type || 'commonjs'; - - return infoType === type; -} + function checkType(type, file) { + const packagePath = findUpPackage(file); + + if (type === 'commonjs' && !packagePath) + return true; + + if (!packagePath) + return false; + + const packageContent = readFileContent(packagePath); + + if (!packageContent) + return false; + + const info = parse(packageContent); + const infoType = info.type || 'commonjs'; + + return infoType === type; + } -function findUpPackage(file) { - let packageJSON; - let dirPath = getParentDirectory(file); - - do { - const dir = getFilename(dirPath); - [packageJSON] = findFile(dirPath, join(dir, 'package.json')); - } while (!packageJSON && (dirPath = getParentDirectory(dirPath))); - - return packageJSON; + function findUpPackage(file) { + let packageJSON; + let dirPath = getParentDirectory(file); + + do { + const dir = getFilename(dirPath); + [packageJSON] = findFile(dirPath, join(dir, 'package.json')); + } while (!packageJSON && (dirPath = getParentDirectory(dirPath))); + + return packageJSON; + } + return renameFiles; } var ignore = {}; -const {types: types$1} = bundle; -const {traverseProperties} = operate; -const {StringLiteral} = types$1; -const getValue = ({value}) => value; +var hasRequiredIgnore; -ignore.ignore = (type, {name, property, list}) => { - const [, collector] = type.split(/\(|\)/); - - return { - report: createReport(name), - match: createMatch({ - type, - property, - collector, - list, - }), - replace: createReplace({ - type, - property, - collector, - list, - }), - }; -}; +function requireIgnore () { + if (hasRequiredIgnore) return ignore; + hasRequiredIgnore = 1; -const createReport = (name) => () => `Add dotfiles to '${name}'`; + const {types} = requireBundle(); + const {traverseProperties} = requireOperate(); + const {StringLiteral} = types; + const getValue = ({value}) => value; -const createMatch = ({type, property, collector, list}) => ({options}) => { - const {dismiss = []} = options; - const newNames = filterNames(list, dismiss); - - return { - [type]: (vars) => { - const elements = parseElements(vars, { - property, - collector, - }); - - if (!elements) - return false; - - const list = elements.map(getValue); - - for (const name of newNames) { - if (!list.includes(name)) - return true; - } - - return false; - }, - }; -}; + ignore.ignore = (type, {name, property, list}) => { + const [, collector] = type.split(/\(|\)/); + + return { + report: createReport(name), + match: createMatch({ + type, + property, + collector, + list, + }), + replace: createReplace({ + type, + property, + collector, + list, + }), + }; + }; -const createReplace = ({type, property, collector, list}) => ({options}) => { - const {dismiss = []} = options; - const newNames = filterNames(list, dismiss); - - return { - [type]: (vars, path) => { - const elements = parseElements(vars, { - property, - collector, - }); - - const list = elements.map(getValue); - - for (const name of newNames) { - if (!list.includes(name)) - elements.push(StringLiteral(name)); - } - - return path; - }, - }; -}; + const createReport = (name) => () => `Add dotfiles to '${name}'`; -function filterNames(names, dismiss) { - const newNames = []; - - for (const name of names) { - if (dismiss.includes(name)) - continue; - - newNames.push(name); - } - - return newNames; -} + const createMatch = ({type, property, collector, list}) => ({options}) => { + const {dismiss = []} = options; + const newNames = filterNames(list, dismiss); + + return { + [type]: (vars) => { + const elements = parseElements(vars, { + property, + collector, + }); + + if (!elements) + return false; + + const list = elements.map(getValue); + + for (const name of newNames) { + if (!list.includes(name)) + return true; + } + + return false; + }, + }; + }; -function parseElements(vars, {property, collector}) { - const node = vars[collector]; - - if (!property) - return node.elements; - - const [prop] = traverseProperties(node, property); - - if (!prop) - return null; - - return prop.node.value.elements; + const createReplace = ({type, property, collector, list}) => ({options}) => { + const {dismiss = []} = options; + const newNames = filterNames(list, dismiss); + + return { + [type]: (vars, path) => { + const elements = parseElements(vars, { + property, + collector, + }); + + const list = elements.map(getValue); + + for (const name of newNames) { + if (!list.includes(name)) + elements.push(StringLiteral(name)); + } + + return path; + }, + }; + }; + + function filterNames(names, dismiss) { + const newNames = []; + + for (const name of names) { + if (dismiss.includes(name)) + continue; + + newNames.push(name); + } + + return newNames; + } + + function parseElements(vars, {property, collector}) { + const node = vars[collector]; + + if (!property) + return node.elements; + + const [prop] = traverseProperties(node, property); + + if (!prop) + return null; + + return prop.node.value.elements; + } + return ignore; } -const {codeFrameColumns} = bundle; +var codeframe; +var hasRequiredCodeframe; -var codeframe$1 = ({source, error, highlightCode = true}) => { - const {message, loc} = error; - - if (!loc) - return message; - - const location = { - start: loc, - }; - - return codeFrameColumns(source, location, { - highlightCode, - message, - }); -}; +function requireCodeframe () { + if (hasRequiredCodeframe) return codeframe; + hasRequiredCodeframe = 1; -codeframe$1.default; + const {codeFrameColumns} = requireBundle(); -const {traverse, types} = bundle; -const { - parse, - print, - generate, - template, -} = parser$6; + codeframe = ({source, error, highlightCode = true}) => { + const {message, loc} = error; + + if (!loc) + return message; + + const location = { + start: loc, + }; + + return codeFrameColumns(source, location, { + highlightCode, + message, + }); + }; + return codeframe; +} -const {cutShebang, mergeShebang} = shebang; -const {defaultOptions} = defaultOptions$4; -const {transform, transformAsync} = transform$5; +var hasRequiredPutout; -const { - findPlaces, - findPlacesAsync, -} = findPlaces$2; +function requirePutout () { + if (hasRequiredPutout) return putout$1.exports; + hasRequiredPutout = 1; -const isString = (a) => typeof a === 'string'; + const {traverse, types} = requireBundle(); + const { + parse, + print, + generate, + template, + } = requireParser$1(); -putout$1.exports = putout; -var putout_2 = putout$1.exports.putout = putout; + const {cutShebang, mergeShebang} = requireShebang(); + const {defaultOptions} = requireDefaultOptions(); + const {transform, transformAsync} = requireTransform$1(); -function putout(source, opts) { - check(source); - opts = defaultOptions(opts); - - const { - parser, - isTS, - isFlow, - isJSX, - sourceFileName, - sourceMapName, - printer, - } = opts; - - const [clearSource, shebang] = cutShebang(source); - - const ast = parse(clearSource, { - sourceFileName, - parser, - isTS, - isFlow, - isJSX, - printer, - }); - - const places = transform(ast, source, opts); - - if (!opts.fix) - return { - code: source, - places, - }; - - const printed = print(ast, { - sourceMapName, - printer, - }); - - const code = mergeShebang(shebang, printed); - - return { - code, - places, - }; -} + const { + findPlaces, + findPlacesAsync, + } = requireFindPlaces(); -var putoutAsync = putout$1.exports.putoutAsync = async (source, opts) => { - check(source); - opts = defaultOptions(opts); - - const { - parser, - isTS, - isFlow, - isJSX, - sourceFileName, - sourceMapName, - printer, - } = opts; - - const [clearSource, shebang] = cutShebang(source); - - const ast = parse(clearSource, { - sourceFileName, - parser, - isTS, - isFlow, - isJSX, - printer, - }); - - const places = await transformAsync(ast, source, opts); - - if (!opts.fix) - return { - code: source, - places, - }; - - const printed = print(ast, { - sourceMapName, - printer, - }); - - const code = mergeShebang(shebang, printed); - - return { - code, - places, - }; -}; + const isString = (a) => typeof a === 'string'; -var transform_1 = putout$1.exports.transform = transform; -var transformAsync_1 = putout$1.exports.transformAsync = transformAsync; - -var findPlaces_1 = putout$1.exports.findPlaces = findPlaces; -var findPlacesAsync_1 = putout$1.exports.findPlacesAsync = findPlacesAsync; - -var parse_1 = putout$1.exports.parse = parse; -var print_1 = putout$1.exports.print = print; -var traverse_1 = putout$1.exports.traverse = traverse; -var types_1 = putout$1.exports.types = types; -var template_1 = putout$1.exports.template = template; -var generate_1 = putout$1.exports.generate = generate; -var initReport = putout$1.exports.initReport = report$3; - -var operator = putout$1.exports.operator = { - ...operate, - ...compare$5, - ...traverse$5, - ...json, - ...declare$2, - ...regexp, - ...addArgs, - ...filesystem, - ...matchFiles, - ...renameFiles, - ...ignore, -}; + putout$1.exports = putout; + putout$1.exports.putout = putout; + + function putout(source, opts) { + check(source); + opts = defaultOptions(opts); + + const { + parser, + isTS, + isFlow, + isJSX, + sourceFileName, + sourceMapName, + printer, + } = opts; + + const [clearSource, shebang] = cutShebang(source); + + const ast = parse(clearSource, { + sourceFileName, + parser, + isTS, + isFlow, + isJSX, + printer, + }); + + const places = transform(ast, source, opts); + + if (!opts.fix) + return { + code: source, + places, + }; + + const printed = print(ast, { + sourceMapName, + printer, + }); + + const code = mergeShebang(shebang, printed); + + return { + code, + places, + }; + } + + putout$1.exports.putoutAsync = async (source, opts) => { + check(source); + opts = defaultOptions(opts); + + const { + parser, + isTS, + isFlow, + isJSX, + sourceFileName, + sourceMapName, + printer, + } = opts; + + const [clearSource, shebang] = cutShebang(source); + + const ast = parse(clearSource, { + sourceFileName, + parser, + isTS, + isFlow, + isJSX, + printer, + }); + + const places = await transformAsync(ast, source, opts); + + if (!opts.fix) + return { + code: source, + places, + }; + + const printed = print(ast, { + sourceMapName, + printer, + }); + + const code = mergeShebang(shebang, printed); + + return { + code, + places, + }; + }; + + putout$1.exports.transform = transform; + putout$1.exports.transformAsync = transformAsync; + + putout$1.exports.findPlaces = findPlaces; + putout$1.exports.findPlacesAsync = findPlacesAsync; + + putout$1.exports.parse = parse; + putout$1.exports.print = print; + putout$1.exports.traverse = traverse; + putout$1.exports.types = types; + putout$1.exports.template = template; + putout$1.exports.generate = generate; + putout$1.exports.initReport = requireReport(); + + putout$1.exports.operator = { + ...requireOperate(), + ...requireCompare(), + ...requireTraverse$1(), + ...requireJson$1(), + ...requireDeclare$1(), + ...requireRegexp(), + ...requireAddArgs(), + ...requireFilesystem(), + ...requireMatchFiles(), + ...requireRenameFiles(), + ...requireIgnore(), + }; -var ignores = putout$1.exports.ignores = ignores$2; -var codeframe = putout$1.exports.codeframe = codeframe$1; + putout$1.exports.ignores = requireIgnores(); + putout$1.exports.codeframe = requireCodeframe(); -function check(source) { - if (!isString(source)) - throw Error(`☝️ Looks like 'source' has type '${typeof source}', expected: 'string'`); + function check(source) { + if (!isString(source)) + throw Error(`☝️ Looks like 'source' has type '${typeof source}', expected: 'string'`); + } + return putout$1.exports; } -var putoutExports = putout$1.exports; +var putoutExports = requirePutout(); +var putout = putoutExports.default; -export { codeframe, putoutExports as default, findPlaces_1 as findPlaces, findPlacesAsync_1 as findPlacesAsync, generate_1 as generate, ignores, initReport, operator, parse_1 as parse, print_1 as print, putout_2 as putout, putoutAsync, template_1 as template, transform_1 as transform, transformAsync_1 as transformAsync, traverse_1 as traverse, types_1 as types }; +export { putout as default }; diff --git a/bundle/putout.min.js b/bundle/putout.min.js index 8271635..26ba55e 100644 --- a/bundle/putout.min.js +++ b/bundle/putout.min.js @@ -1 +1 @@ -var A="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}function t(A){if(A.__esModule)return A;var e=A.default;if("function"==typeof e){var t=function A(){return this instanceof A?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(A).forEach((function(e){var r=Object.getOwnPropertyDescriptor(A,e);Object.defineProperty(t,e,r.get?r:{enumerable:!0,get:function(){return A[e]}})})),t}var r={exports:{}},i="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function n(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}var s=n,o=a;function g(A){if(s===setTimeout)return setTimeout(A,0);if((s===n||!s)&&setTimeout)return s=setTimeout,setTimeout(A,0);try{return s(A,0)}catch(e){try{return s.call(null,A,0)}catch(e){return s.call(this,A,0)}}}"function"==typeof i.setTimeout&&(s=setTimeout),"function"==typeof i.clearTimeout&&(o=clearTimeout);var I,C=[],u=!1,c=-1;function l(){u&&I&&(u=!1,I.length?C=I.concat(C):c=-1,C.length&&B())}function B(){if(!u){var A=g(l);u=!0;for(var e=C.length;e;){for(I=C,C=[];++c1)for(var t=1;t>18&63]+v[i>>12&63]+v[i>>6&63]+v[63&i]);return n.join("")}function R(A){var e;F||G();for(var t=A.length,r=t%3,i="",n=[],a=16383,s=0,o=t-r;so?o:s+a));return 1===r?(e=A[t-1],i+=v[e>>2],i+=v[e<<4&63],i+="=="):2===r&&(e=(A[t-2]<<8)+A[t-1],i+=v[e>>10],i+=v[e>>4&63],i+=v[e<<2&63],i+="="),n.push(i),n.join("")}function T(A,e,t,r,i){var n,a,s=8*i-r-1,o=(1<>1,I=-7,C=t?i-1:0,u=t?-1:1,c=A[e+C];for(C+=u,n=c&(1<<-I)-1,c>>=-I,I+=s;I>0;n=256*n+A[e+C],C+=u,I-=8);for(a=n&(1<<-I)-1,n>>=-I,I+=r;I>0;a=256*a+A[e+C],C+=u,I-=8);if(0===n)n=1-g;else{if(n===o)return a?NaN:1/0*(c?-1:1);a+=Math.pow(2,r),n-=g}return(c?-1:1)*a*Math.pow(2,n-r)}function M(A,e,t,r,i,n){var a,s,o,g=8*n-i-1,I=(1<>1,u=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,c=r?0:n-1,l=r?1:-1,B=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=I):(a=Math.floor(Math.log(e)/Math.LN2),e*(o=Math.pow(2,-a))<1&&(a--,o*=2),(e+=a+C>=1?u/o:u*Math.pow(2,1-C))*o>=2&&(a++,o/=2),a+C>=I?(s=0,a=I):a+C>=1?(s=(e*o-1)*Math.pow(2,i),a+=C):(s=e*Math.pow(2,C-1)*Math.pow(2,i),a=0));i>=8;A[t+c]=255&s,c+=l,s/=256,i-=8);for(a=a<0;A[t+c]=255&a,c+=l,a/=256,g-=8);A[t+c-l]|=128*B}var L={}.toString,U=Array.isArray||function(A){return"[object Array]"==L.call(A)};function P(){return K.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function J(A,e){if(P()=P())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+P().toString(16)+" bytes");return 0|A}function q(A){return!(null==A||!A._isBuffer)}function V(A,e){if(q(A))return A.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(A)||A instanceof ArrayBuffer))return A.byteLength;"string"!=typeof A&&(A=""+A);var t=A.length;if(0===t)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":case void 0:return yA(A).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*t;case"hex":return t>>>1;case"base64":return mA(A).length;default:if(r)return yA(A).length;e=(""+e).toLowerCase(),r=!0}}function W(A,e,t){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===t||t>this.length)&&(t=this.length),t<=0)return"";if((t>>>=0)<=(e>>>=0))return"";for(A||(A="utf8");;)switch(A){case"hex":return CA(this,e,t);case"utf8":case"utf-8":return sA(this,e,t);case"ascii":return gA(this,e,t);case"latin1":case"binary":return IA(this,e,t);case"base64":return aA(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return uA(this,e,t);default:if(r)throw new TypeError("Unknown encoding: "+A);A=(A+"").toLowerCase(),r=!0}}function Z(A,e,t){var r=A[e];A[e]=A[t],A[t]=r}function X(A,e,t,r,i){if(0===A.length)return-1;if("string"==typeof t?(r=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=i?0:A.length-1),t<0&&(t=A.length+t),t>=A.length){if(i)return-1;t=A.length-1}else if(t<0){if(!i)return-1;t=0}if("string"==typeof e&&(e=K.from(e,r)),q(e))return 0===e.length?-1:$(A,e,t,r,i);if("number"==typeof e)return e&=255,K.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(A,e,t):Uint8Array.prototype.lastIndexOf.call(A,e,t):$(A,[e],t,r,i);throw new TypeError("val must be string, number or Buffer")}function $(A,e,t,r,i){var n,a=1,s=A.length,o=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(A.length<2||e.length<2)return-1;a=2,s/=2,o/=2,t/=2}function g(A,e){return 1===a?A[e]:A.readUInt16BE(e*a)}if(i){var I=-1;for(n=t;ns&&(t=s-o),n=t;n>=0;n--){for(var C=!0,u=0;ui&&(r=i):r=i;var n=e.length;if(n%2!=0)throw new TypeError("Invalid hex string");r>n/2&&(r=n/2);for(var a=0;a>8,i=t%256,n.push(i),n.push(r);return n}(e,A.length-t),A,t,r)}function aA(A,e,t){return 0===e&&t===A.length?R(A):R(A.slice(e,t))}function sA(A,e,t){t=Math.min(A.length,t);for(var r=[],i=e;i239?4:g>223?3:g>191?2:1;if(i+C<=t)switch(C){case 1:g<128&&(I=g);break;case 2:128==(192&(n=A[i+1]))&&(o=(31&g)<<6|63&n)>127&&(I=o);break;case 3:n=A[i+1],a=A[i+2],128==(192&n)&&128==(192&a)&&(o=(15&g)<<12|(63&n)<<6|63&a)>2047&&(o<55296||o>57343)&&(I=o);break;case 4:n=A[i+1],a=A[i+2],s=A[i+3],128==(192&n)&&128==(192&a)&&128==(192&s)&&(o=(15&g)<<18|(63&n)<<12|(63&a)<<6|63&s)>65535&&o<1114112&&(I=o)}null===I?(I=65533,C=1):I>65535&&(I-=65536,r.push(I>>>10&1023|55296),I=56320|1023&I),r.push(I),i+=C}return function(A){var e=A.length;if(e<=oA)return String.fromCharCode.apply(String,A);var t="",r=0;for(;r0&&(A=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(A+=" ... ")),""},K.prototype.compare=function(A,e,t,r,i){if(!q(A))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===t&&(t=A?A.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||t>A.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=t)return 0;if(r>=i)return-1;if(e>=t)return 1;if(this===A)return 0;for(var n=(i>>>=0)-(r>>>=0),a=(t>>>=0)-(e>>>=0),s=Math.min(n,a),o=this.slice(r,i),g=A.slice(e,t),I=0;Ii)&&(t=i),A.length>0&&(t<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var n=!1;;)switch(r){case"hex":return AA(this,A,e,t);case"utf8":case"utf-8":return eA(this,A,e,t);case"ascii":return tA(this,A,e,t);case"latin1":case"binary":return rA(this,A,e,t);case"base64":return iA(this,A,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return nA(this,A,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),n=!0}},K.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var oA=4096;function gA(A,e,t){var r="";t=Math.min(A.length,t);for(var i=e;ir)&&(t=r);for(var i="",n=e;nt)throw new RangeError("Trying to access beyond buffer length")}function lA(A,e,t,r,i,n){if(!q(A))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||eA.length)throw new RangeError("Index out of range")}function BA(A,e,t,r){e<0&&(e=65535+e+1);for(var i=0,n=Math.min(A.length-t,2);i>>8*(r?i:1-i)}function EA(A,e,t,r){e<0&&(e=4294967295+e+1);for(var i=0,n=Math.min(A.length-t,4);i>>8*(r?i:3-i)&255}function QA(A,e,t,r,i,n){if(t+r>A.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function hA(A,e,t,r,i){return i||QA(A,0,t,4),M(A,e,t,r,23,4),t+4}function pA(A,e,t,r,i){return i||QA(A,0,t,8),M(A,e,t,r,52,8),t+8}K.prototype.slice=function(A,e){var t,r=this.length;if((A=~~A)<0?(A+=r)<0&&(A=0):A>r&&(A=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e0&&(i*=256);)r+=this[A+--e]*i;return r},K.prototype.readUInt8=function(A,e){return e||cA(A,1,this.length),this[A]},K.prototype.readUInt16LE=function(A,e){return e||cA(A,2,this.length),this[A]|this[A+1]<<8},K.prototype.readUInt16BE=function(A,e){return e||cA(A,2,this.length),this[A]<<8|this[A+1]},K.prototype.readUInt32LE=function(A,e){return e||cA(A,4,this.length),(this[A]|this[A+1]<<8|this[A+2]<<16)+16777216*this[A+3]},K.prototype.readUInt32BE=function(A,e){return e||cA(A,4,this.length),16777216*this[A]+(this[A+1]<<16|this[A+2]<<8|this[A+3])},K.prototype.readIntLE=function(A,e,t){A|=0,e|=0,t||cA(A,e,this.length);for(var r=this[A],i=1,n=0;++n=(i*=128)&&(r-=Math.pow(2,8*e)),r},K.prototype.readIntBE=function(A,e,t){A|=0,e|=0,t||cA(A,e,this.length);for(var r=e,i=1,n=this[A+--r];r>0&&(i*=256);)n+=this[A+--r]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},K.prototype.readInt8=function(A,e){return e||cA(A,1,this.length),128&this[A]?-1*(255-this[A]+1):this[A]},K.prototype.readInt16LE=function(A,e){e||cA(A,2,this.length);var t=this[A]|this[A+1]<<8;return 32768&t?4294901760|t:t},K.prototype.readInt16BE=function(A,e){e||cA(A,2,this.length);var t=this[A+1]|this[A]<<8;return 32768&t?4294901760|t:t},K.prototype.readInt32LE=function(A,e){return e||cA(A,4,this.length),this[A]|this[A+1]<<8|this[A+2]<<16|this[A+3]<<24},K.prototype.readInt32BE=function(A,e){return e||cA(A,4,this.length),this[A]<<24|this[A+1]<<16|this[A+2]<<8|this[A+3]},K.prototype.readFloatLE=function(A,e){return e||cA(A,4,this.length),T(this,A,!0,23,4)},K.prototype.readFloatBE=function(A,e){return e||cA(A,4,this.length),T(this,A,!1,23,4)},K.prototype.readDoubleLE=function(A,e){return e||cA(A,8,this.length),T(this,A,!0,52,8)},K.prototype.readDoubleBE=function(A,e){return e||cA(A,8,this.length),T(this,A,!1,52,8)},K.prototype.writeUIntLE=function(A,e,t,r){(A=+A,e|=0,t|=0,r)||lA(this,A,e,t,Math.pow(2,8*t)-1,0);var i=1,n=0;for(this[e]=255&A;++n=0&&(n*=256);)this[e+i]=A/n&255;return e+t},K.prototype.writeUInt8=function(A,e,t){return A=+A,e|=0,t||lA(this,A,e,1,255,0),K.TYPED_ARRAY_SUPPORT||(A=Math.floor(A)),this[e]=255&A,e+1},K.prototype.writeUInt16LE=function(A,e,t){return A=+A,e|=0,t||lA(this,A,e,2,65535,0),K.TYPED_ARRAY_SUPPORT?(this[e]=255&A,this[e+1]=A>>>8):BA(this,A,e,!0),e+2},K.prototype.writeUInt16BE=function(A,e,t){return A=+A,e|=0,t||lA(this,A,e,2,65535,0),K.TYPED_ARRAY_SUPPORT?(this[e]=A>>>8,this[e+1]=255&A):BA(this,A,e,!1),e+2},K.prototype.writeUInt32LE=function(A,e,t){return A=+A,e|=0,t||lA(this,A,e,4,4294967295,0),K.TYPED_ARRAY_SUPPORT?(this[e+3]=A>>>24,this[e+2]=A>>>16,this[e+1]=A>>>8,this[e]=255&A):EA(this,A,e,!0),e+4},K.prototype.writeUInt32BE=function(A,e,t){return A=+A,e|=0,t||lA(this,A,e,4,4294967295,0),K.TYPED_ARRAY_SUPPORT?(this[e]=A>>>24,this[e+1]=A>>>16,this[e+2]=A>>>8,this[e+3]=255&A):EA(this,A,e,!1),e+4},K.prototype.writeIntLE=function(A,e,t,r){if(A=+A,e|=0,!r){var i=Math.pow(2,8*t-1);lA(this,A,e,t,i-1,-i)}var n=0,a=1,s=0;for(this[e]=255&A;++n=0&&(a*=256);)A<0&&0===s&&0!==this[e+n+1]&&(s=1),this[e+n]=(A/a|0)-s&255;return e+t},K.prototype.writeInt8=function(A,e,t){return A=+A,e|=0,t||lA(this,A,e,1,127,-128),K.TYPED_ARRAY_SUPPORT||(A=Math.floor(A)),A<0&&(A=255+A+1),this[e]=255&A,e+1},K.prototype.writeInt16LE=function(A,e,t){return A=+A,e|=0,t||lA(this,A,e,2,32767,-32768),K.TYPED_ARRAY_SUPPORT?(this[e]=255&A,this[e+1]=A>>>8):BA(this,A,e,!0),e+2},K.prototype.writeInt16BE=function(A,e,t){return A=+A,e|=0,t||lA(this,A,e,2,32767,-32768),K.TYPED_ARRAY_SUPPORT?(this[e]=A>>>8,this[e+1]=255&A):BA(this,A,e,!1),e+2},K.prototype.writeInt32LE=function(A,e,t){return A=+A,e|=0,t||lA(this,A,e,4,2147483647,-2147483648),K.TYPED_ARRAY_SUPPORT?(this[e]=255&A,this[e+1]=A>>>8,this[e+2]=A>>>16,this[e+3]=A>>>24):EA(this,A,e,!0),e+4},K.prototype.writeInt32BE=function(A,e,t){return A=+A,e|=0,t||lA(this,A,e,4,2147483647,-2147483648),A<0&&(A=4294967295+A+1),K.TYPED_ARRAY_SUPPORT?(this[e]=A>>>24,this[e+1]=A>>>16,this[e+2]=A>>>8,this[e+3]=255&A):EA(this,A,e,!1),e+4},K.prototype.writeFloatLE=function(A,e,t){return hA(this,A,e,!0,t)},K.prototype.writeFloatBE=function(A,e,t){return hA(this,A,e,!1,t)},K.prototype.writeDoubleLE=function(A,e,t){return pA(this,A,e,!0,t)},K.prototype.writeDoubleBE=function(A,e,t){return pA(this,A,e,!1,t)},K.prototype.copy=function(A,e,t,r){if(t||(t=0),r||0===r||(r=this.length),e>=A.length&&(e=A.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),A.length-e=0;--i)A[i+e]=this[i+t];else if(n<1e3||!K.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,t=void 0===t?this.length:t>>>0,A||(A=0),"number"==typeof A)for(n=e;n55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&n.push(239,191,189);continue}if(a+1===r){(e-=3)>-1&&n.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&n.push(239,191,189),i=t;continue}t=65536+(i-55296<<10|t-56320)}else i&&(e-=3)>-1&&n.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;n.push(t)}else if(t<2048){if((e-=2)<0)break;n.push(t>>6|192,63&t|128)}else if(t<65536){if((e-=3)<0)break;n.push(t>>12|224,t>>6&63|128,63&t|128)}else{if(!(t<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;n.push(t>>18|240,t>>12&63|128,t>>6&63|128,63&t|128)}}return n}function mA(A){return function(A){var e,t,r,i,n,a;F||G();var s=A.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");n="="===A[s-2]?2:"="===A[s-1]?1:0,a=new b(3*s/4-n),r=n>0?s-4:s;var o=0;for(e=0,t=0;e>16&255,a[o++]=i>>8&255,a[o++]=255&i;return 2===n?(i=x[A.charCodeAt(e)]<<2|x[A.charCodeAt(e+1)]>>4,a[o++]=255&i):1===n&&(i=x[A.charCodeAt(e)]<<10|x[A.charCodeAt(e+1)]<<4|x[A.charCodeAt(e+2)]>>2,a[o++]=i>>8&255,a[o++]=255&i),a}(function(A){if((A=function(A){return A.trim?A.trim():A.replace(/^\s+|\s+$/g,"")}(A).replace(dA,"")).length<2)return"";for(;A.length%4!=0;)A+="=";return A}(A))}function DA(A,e,t,r){for(var i=0;i=e.length||i>=A.length);++i)e[i+t]=A[i];return i}function wA(A){return!!A.constructor&&"function"==typeof A.constructor.isBuffer&&A.constructor.isBuffer(A)}function SA(A){throw new Error('Could not dynamically require "'+A+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}function NA(){return!1}function kA(){throw new Error("tty.ReadStream is not implemented")}function vA(){throw new Error("tty.ReadStream is not implemented")}var xA,bA={isatty:NA,ReadStream:kA,WriteStream:vA},FA=t(Object.freeze({__proto__:null,ReadStream:kA,WriteStream:vA,default:bA,isatty:NA}));function GA(){if(void 0===xA){var A=new ArrayBuffer(2),e=new Uint8Array(A),t=new Uint16Array(A);if(e[0]=1,e[1]=2,258===t[0])xA="BE";else{if(513!==t[0])throw new Error("unable to figure out endianess");xA="LE"}}return xA}function YA(){return void 0!==i.location?i.location.hostname:""}function RA(){return[]}function TA(){return 0}function MA(){return Number.MAX_VALUE}function LA(){return Number.MAX_VALUE}function UA(){return[]}function PA(){return"Browser"}function JA(){return void 0!==i.navigator?i.navigator.appVersion:""}function KA(){return{}}function HA(){return{}}function OA(){return"javascript"}function _A(){return"browser"}function jA(){return"/tmp"}var zA=jA;function qA(){return"$HOME"}var VA={homedir:qA,EOL:"\n",arch:OA,platform:_A,tmpdir:zA,tmpDir:jA,networkInterfaces:KA,getNetworkInterfaces:HA,release:JA,type:PA,cpus:UA,totalmem:LA,freemem:MA,uptime:TA,loadavg:RA,hostname:YA,endianness:GA},WA=t(Object.freeze({__proto__:null,EOL:"\n",arch:OA,cpus:UA,default:VA,endianness:GA,freemem:MA,getNetworkInterfaces:HA,homedir:qA,hostname:YA,loadavg:RA,networkInterfaces:KA,platform:_A,release:JA,tmpDir:jA,tmpdir:zA,totalmem:LA,type:PA,uptime:TA})),ZA="function"==typeof Object.create?function(A,e){A.super_=e,A.prototype=Object.create(e.prototype,{constructor:{value:A,enumerable:!1,writable:!0,configurable:!0}})}:function(A,e){A.super_=e;var t=function(){};t.prototype=e.prototype,A.prototype=new t,A.prototype.constructor=A},XA=Object.getOwnPropertyDescriptors||function(A){for(var e=Object.keys(A),t={},r=0;r=i)return A;switch(A){case"%s":return String(r[t++]);case"%d":return Number(r[t++]);case"%j":try{return JSON.stringify(r[t++])}catch(A){return"[Circular]"}default:return A}})),a=r[t];t=3&&(t.depth=arguments[2]),arguments.length>=4&&(t.colors=arguments[3]),ue(e)?t.showHidden=e:e&&xe(t,e),he(t.showHidden)&&(t.showHidden=!1),he(t.depth)&&(t.depth=2),he(t.colors)&&(t.colors=!1),he(t.customInspect)&&(t.customInspect=!0),t.colors&&(t.stylize=ae),oe(t,A,t.depth)}function ae(A,e){var t=ne.styles[e];return t?"["+ne.colors[t][0]+"m"+A+"["+ne.colors[t][1]+"m":A}function se(A,e){return A}function oe(A,e,t){if(A.customInspect&&e&&me(e.inspect)&&e.inspect!==ne&&(!e.constructor||e.constructor.prototype!==e)){var r=e.inspect(t,A);return Ee(r)||(r=oe(A,r,t)),r}var i=function(A,e){if(he(e))return A.stylize("undefined","undefined");if(Ee(e)){var t="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return A.stylize(t,"string")}if(Be(e))return A.stylize(""+e,"number");if(ue(e))return A.stylize(""+e,"boolean");if(ce(e))return A.stylize("null","null")}(A,e);if(i)return i;var n=Object.keys(e),a=function(A){var e={};return A.forEach((function(A,t){e[A]=!0})),e}(n);if(A.showHidden&&(n=Object.getOwnPropertyNames(e)),ye(e)&&(n.indexOf("message")>=0||n.indexOf("description")>=0))return ge(e);if(0===n.length){if(me(e)){var s=e.name?": "+e.name:"";return A.stylize("[Function"+s+"]","special")}if(pe(e))return A.stylize(RegExp.prototype.toString.call(e),"regexp");if(fe(e))return A.stylize(Date.prototype.toString.call(e),"date");if(ye(e))return ge(e)}var o,g="",I=!1,C=["{","}"];(Ce(e)&&(I=!0,C=["[","]"]),me(e))&&(g=" [Function"+(e.name?": "+e.name:"")+"]");return pe(e)&&(g=" "+RegExp.prototype.toString.call(e)),fe(e)&&(g=" "+Date.prototype.toUTCString.call(e)),ye(e)&&(g=" "+ge(e)),0!==n.length||I&&0!=e.length?t<0?pe(e)?A.stylize(RegExp.prototype.toString.call(e),"regexp"):A.stylize("[Object]","special"):(A.seen.push(e),o=I?function(A,e,t,r,i){for(var n=[],a=0,s=e.length;a60)return t[0]+(""===e?"":e+"\n ")+" "+A.join(",\n ")+" "+t[1];return t[0]+e+" "+A.join(", ")+" "+t[1]}(o,g,C)):C[0]+g+C[1]}function ge(A){return"["+Error.prototype.toString.call(A)+"]"}function Ie(A,e,t,r,i,n){var a,s,o;if((o=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=o.set?A.stylize("[Getter/Setter]","special"):A.stylize("[Getter]","special"):o.set&&(s=A.stylize("[Setter]","special")),be(r,i)||(a="["+i+"]"),s||(A.seen.indexOf(o.value)<0?(s=ce(t)?oe(A,o.value,null):oe(A,o.value,t-1)).indexOf("\n")>-1&&(s=n?s.split("\n").map((function(A){return" "+A})).join("\n").substr(2):"\n"+s.split("\n").map((function(A){return" "+A})).join("\n")):s=A.stylize("[Circular]","special")),he(a)){if(n&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=A.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=A.stylize(a,"string"))}return a+": "+s}function Ce(A){return Array.isArray(A)}function ue(A){return"boolean"==typeof A}function ce(A){return null===A}function le(A){return null==A}function Be(A){return"number"==typeof A}function Ee(A){return"string"==typeof A}function Qe(A){return"symbol"==typeof A}function he(A){return void 0===A}function pe(A){return de(A)&&"[object RegExp]"===Se(A)}function de(A){return"object"==typeof A&&null!==A}function fe(A){return de(A)&&"[object Date]"===Se(A)}function ye(A){return de(A)&&("[object Error]"===Se(A)||A instanceof Error)}function me(A){return"function"==typeof A}function De(A){return null===A||"boolean"==typeof A||"number"==typeof A||"string"==typeof A||"symbol"==typeof A||void 0===A}function we(A){return K.isBuffer(A)}function Se(A){return Object.prototype.toString.call(A)}function Ne(A){return A<10?"0"+A.toString(10):A.toString(10)}ne.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},ne.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};var ke=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ve(){var A,e;console.log("%s - %s",(A=new Date,e=[Ne(A.getHours()),Ne(A.getMinutes()),Ne(A.getSeconds())].join(":"),[A.getDate(),ke[A.getMonth()],e].join(" ")),Ae.apply(null,arguments))}function xe(A,e){if(!e||!de(e))return A;for(var t=Object.keys(e),r=t.length;r--;)A[t[r]]=e[t[r]];return A}function be(A,e){return Object.prototype.hasOwnProperty.call(A,e)}var Fe="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function Ge(A){if("function"!=typeof A)throw new TypeError('The "original" argument must be of type Function');if(Fe&&A[Fe]){var e;if("function"!=typeof(e=A[Fe]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,Fe,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,t,r=new Promise((function(A,r){e=A,t=r})),i=[],n=0;nA.length)&&(e=A.length);for(var t=0,r=new Array(e);t0&&i[i.length-1])||6!==n[0]&&2!==n[0])){a=0;continue}if(3===n[0]&&(!i||n[1]>i[0]&&n[1]|\\.{3}|\\??\\.(?!\\d)|(?:&&|\\|\\||\\?\\?|[+\\-%&|^]|\\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\\/(?![\\/*]))=?|[?~,:;[\\](){}]","y"),t=RegExp("(\\x23?)(?=[$_\\p{ID_Start}\\\\])(?:[$_\\u200C\\u200D\\p{ID_Continue}]+|\\\\u[\\da-fA-F]{4}|\\\\u\\{[\\da-fA-F]+\\})+","yu"),E=RegExp("(['\"])(?:[^'\"\\\\\\n\\r]+|(?!\\1)['\"]|\\\\(?:\\r\\n|[^]))*(\\1)?","y"),u=RegExp("(?:0[xX][\\da-fA-F](?:_?[\\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\\d)*n|(?:(?:0(?!\\d)|0\\d*[89]\\d*|[1-9](?:_?\\d)*)(?:\\.(?:\\d(?:_?\\d)*)?)?|\\.\\d(?:_?\\d)*)(?:[eE][+-]?\\d(?:_?\\d)*)?|0[0-7]+","y"),Q=RegExp("[`}](?:[^`\\\\$]+|\\\\[^]|\\$(?!\\{))*(`|\\$\\{)?","y"),d=RegExp("[\\t\\v\\f\\ufeff\\p{Zs}]+","yu"),g=RegExp("\\r?\\n|[\\r\\u2028\\u2029]","y"),I=RegExp("\\/\\*(?:[^*]+|\\*(?!\\/))*(\\*\\/)?","y"),B=RegExp("\\/\\/.*","y"),i=RegExp("[<>.:={}]|\\/(?![\\/*])","y"),r=RegExp("[$_\\p{ID_Start}][$_\\u200C\\u200D\\p{ID_Continue}-]*","yu"),n=RegExp("(['\"])(?:[^'\"]+|(?!\\1)['\"])*(\\1)?","y"),a=RegExp("[^<>{}]+","y"),p=/^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/,h=/^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/,s=/^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/,o=/^(?:return|throw|yield)$/,C=RegExp(g.source),e.exports=function(A){var e,f,y,m,D,w,S,N,k,v,x,b,F,G,Y,R,T=arguments;return et(this,(function(M){switch(M.label){case 0:e=(T.length>1&&void 0!==T[1]?T[1]:{}).jsx,f=void 0!==e&&e,N=A.length,w=0,S="",R=[{tag:"JS"}],y=[],F=0,G=!1,M.label=1;case 1:if(!(w":R.pop(),"/"===S||"JSXTagEnd"===v.tag?(b="?JSX",G=!0):R.push({tag:"JSXChildren"});break;case"{":R.push({tag:"InterpolationInJSX",nesting:y.length}),b="?InterpolationInJSX",G=!1;break;case"/":"<"===S&&(R.pop(),"JSXChildren"===R[R.length-1].tag&&R.pop(),R.push({tag:"JSXTagEnd"}))}return S=b,[4,{type:"JSXPunctuator",value:k[0]}];case 39:return M.sent(),[3,1];case 40:return r.lastIndex=w,(k=r.exec(A))?(w=r.lastIndex,S=k[0],[4,{type:"JSXIdentifier",value:k[0]}]):[3,42];case 41:return M.sent(),[3,1];case 42:return n.lastIndex=w,(k=n.exec(A))?(w=n.lastIndex,S=k[0],[4,{type:"JSXString",value:k[0],closed:void 0!==k[2]}]):[3,44];case 43:return M.sent(),[3,1];case 44:return[3,52];case 45:return a.lastIndex=w,(k=a.exec(A))?(w=a.lastIndex,S=k[0],[4,{type:"JSXText",value:k[0]}]):[3,47];case 46:return M.sent(),[3,1];case 47:switch(A[w]){case"<":return[3,48];case"{":return[3,50]}return[3,52];case 48:return R.push({tag:"JSXTag"}),w++,S="<",[4,{type:"JSXPunctuator",value:"<"}];case 49:return M.sent(),[3,1];case 50:return R.push({tag:"InterpolationInJSX",nesting:y.length}),w++,S="?InterpolationInJSX",G=!1,[4,{type:"JSXPunctuator",value:"{"}];case 51:return M.sent(),[3,1];case 52:return d.lastIndex=w,(k=d.exec(A))?(w=d.lastIndex,[4,{type:"WhiteSpace",value:k[0]}]):[3,54];case 53:return M.sent(),[3,1];case 54:return g.lastIndex=w,(k=g.exec(A))?(w=g.lastIndex,G=!1,o.test(S)&&(S="?NoLineTerminatorHere"),[4,{type:"LineTerminatorSequence",value:k[0]}]):[3,56];case 55:return M.sent(),[3,1];case 56:return I.lastIndex=w,(k=I.exec(A))?(w=I.lastIndex,C.test(k[0])&&(G=!1,o.test(S)&&(S="?NoLineTerminatorHere")),[4,{type:"MultiLineComment",value:k[0],closed:void 0!==k[1]}]):[3,58];case 57:return M.sent(),[3,1];case 58:return B.lastIndex=w,(k=B.exec(A))?(w=B.lastIndex,G=!1,[4,{type:"SingleLineComment",value:k[0]}]):[3,60];case 59:return M.sent(),[3,1];case 60:return m=String.fromCodePoint(A.codePointAt(w)),w+=m.length,S=m,G=!1,[4,{type:v.tag.startsWith("JSX")?"JSXInvalid":"Invalid",value:m}];case 61:return M.sent(),[3,1];case 62:return[2,void 0]}}))}}}),ft=lt({"node_modules/picocolors/picocolors.js":function(A,e){var t=k.argv||[],r={},i=!("NO_COLOR"in r||t.includes("--no-color"))&&("FORCE_COLOR"in r||t.includes("--color")||null!=SA&&FA.isatty(1)&&"dumb"!==r.TERM||"CI"in r),n=function(A,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:A;return function(r){var i=""+r,n=i.indexOf(e,A.length);return~n?A+a(i,e,t,n)+e:A+i+e}},a=function(A,e,t,r){var i="",n=0;do{i+=A.substring(n,r)+t,n=r+e.length,r=A.indexOf(e,n)}while(~r);return i+A.substring(n)},s=function(){var A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i,e=A?n:function(){return String};return{isColorSupported:A,reset:e("",""),bold:e("","",""),dim:e("","",""),italic:e("",""),underline:e("",""),inverse:e("",""),hidden:e("",""),strikethrough:e("",""),black:e("",""),red:e("",""),green:e("",""),yellow:e("",""),blue:e("",""),magenta:e("",""),cyan:e("",""),white:e("",""),gray:e("",""),bgBlack:e("",""),bgRed:e("",""),bgGreen:e("",""),bgYellow:e("",""),bgBlue:e("",""),bgMagenta:e("",""),bgCyan:e("",""),bgWhite:e("","")}};e.exports=s(),e.exports.createColors=s}}),yt=lt({"node_modules/jsesc/jsesc.js":function(A,e){var t={},r=t.hasOwnProperty,i=function(A,e){for(var t in A)r.call(A,t)&&e(t,A[t])},n=function(A){return"\\u"+("0000"+A).slice(-4)},a=function(A,e){var t=A.toString(16);return e?t:t.toUpperCase()},s=t.toString,o=Array.isArray,g={"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},I=/[\\\b\f\n\r\t]/,C=/[0-9]/,u=/[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,c=/([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^]/g,l=/([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^ !#-&\(-\[\]-_a-~]/g,B=function(A,e){var t,r,E=function(){D=m,++e.indentLevel,m=e.indent.repeat(e.indentLevel)},Q={escapeEverything:!1,minimal:!1,isScriptContext:!1,quotes:"single",wrap:!1,es6:!1,json:!1,compact:!0,lowercaseHex:!1,numbers:"decimal",indent:"\t",indentLevel:0,__inline1__:!1,__inline2__:!1},h=e&&e.json;h&&(Q.quotes="double",Q.wrap=!0),t=Q,e=(r=e)?(i(r,(function(A,e){t[A]=e})),t):t,"single"!=e.quotes&&"double"!=e.quotes&&"backtick"!=e.quotes&&(e.quotes="single");var p,d="double"==e.quotes?'"':"backtick"==e.quotes?"`":"'",f=e.compact,y=e.lowercaseHex,m=e.indent.repeat(e.indentLevel),D="",w=e.__inline1__,S=e.__inline2__,N=f?"":"\n",k=!0,v="binary"==e.numbers,x="octal"==e.numbers,b="decimal"==e.numbers,F="hexadecimal"==e.numbers;if(h&&A&&"function"==typeof A.toJSON&&(A=A.toJSON()),!function(A){return"string"==typeof A||"[object String]"==s.call(A)}(A)){if(function(A){return"[object Map]"==s.call(A)}(A))return 0==A.size?"new Map()":(f||(e.__inline1__=!0,e.__inline2__=!1),"new Map("+B(Array.from(A),e)+")");if(function(A){return"[object Set]"==s.call(A)}(A))return 0==A.size?"new Set()":"new Set("+B(Array.from(A),e)+")";if(function(A){return Array.isArray(A)}(A))return 0==A.length?"Buffer.from([])":"Buffer.from("+B(Array.from(A),e)+")";if(o(A))return p=[],e.wrap=!0,w&&(e.__inline1__=!1,e.__inline2__=!0),S||E(),function(A,e){for(var t=A.length,r=-1;++r2?n(B):"\\x"+("00"+B).slice(-2)})),"`"==d&&(p=p.replace(/\$\{/g,"\\${")),e.isScriptContext&&(p=p.replace(/<\/(script|style)/gi,"<\\/$1").replace(/