@leofcoin/chain 1.0.4 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,176 +1,5 @@
1
1
  /******/ var __webpack_modules__ = ({
2
2
 
3
- /***/ 6434:
4
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
5
-
6
- /* module decorator */ module = __webpack_require__.nmd(module);
7
-
8
-
9
- const wrapAnsi16 = (fn, offset) => (...args) => {
10
- const code = fn(...args);
11
- return `\u001B[${code + offset}m`;
12
- };
13
-
14
- const wrapAnsi256 = (fn, offset) => (...args) => {
15
- const code = fn(...args);
16
- return `\u001B[${38 + offset};5;${code}m`;
17
- };
18
-
19
- const wrapAnsi16m = (fn, offset) => (...args) => {
20
- const rgb = fn(...args);
21
- return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
22
- };
23
-
24
- const ansi2ansi = n => n;
25
- const rgb2rgb = (r, g, b) => [r, g, b];
26
-
27
- const setLazyProperty = (object, property, get) => {
28
- Object.defineProperty(object, property, {
29
- get: () => {
30
- const value = get();
31
-
32
- Object.defineProperty(object, property, {
33
- value,
34
- enumerable: true,
35
- configurable: true
36
- });
37
-
38
- return value;
39
- },
40
- enumerable: true,
41
- configurable: true
42
- });
43
- };
44
-
45
- /** @type {typeof import('color-convert')} */
46
- let colorConvert;
47
- const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
48
- if (colorConvert === undefined) {
49
- colorConvert = __webpack_require__(2085);
50
- }
51
-
52
- const offset = isBackground ? 10 : 0;
53
- const styles = {};
54
-
55
- for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
56
- const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
57
- if (sourceSpace === targetSpace) {
58
- styles[name] = wrap(identity, offset);
59
- } else if (typeof suite === 'object') {
60
- styles[name] = wrap(suite[targetSpace], offset);
61
- }
62
- }
63
-
64
- return styles;
65
- };
66
-
67
- function assembleStyles() {
68
- const codes = new Map();
69
- const styles = {
70
- modifier: {
71
- reset: [0, 0],
72
- // 21 isn't widely supported and 22 does the same thing
73
- bold: [1, 22],
74
- dim: [2, 22],
75
- italic: [3, 23],
76
- underline: [4, 24],
77
- inverse: [7, 27],
78
- hidden: [8, 28],
79
- strikethrough: [9, 29]
80
- },
81
- color: {
82
- black: [30, 39],
83
- red: [31, 39],
84
- green: [32, 39],
85
- yellow: [33, 39],
86
- blue: [34, 39],
87
- magenta: [35, 39],
88
- cyan: [36, 39],
89
- white: [37, 39],
90
-
91
- // Bright color
92
- blackBright: [90, 39],
93
- redBright: [91, 39],
94
- greenBright: [92, 39],
95
- yellowBright: [93, 39],
96
- blueBright: [94, 39],
97
- magentaBright: [95, 39],
98
- cyanBright: [96, 39],
99
- whiteBright: [97, 39]
100
- },
101
- bgColor: {
102
- bgBlack: [40, 49],
103
- bgRed: [41, 49],
104
- bgGreen: [42, 49],
105
- bgYellow: [43, 49],
106
- bgBlue: [44, 49],
107
- bgMagenta: [45, 49],
108
- bgCyan: [46, 49],
109
- bgWhite: [47, 49],
110
-
111
- // Bright color
112
- bgBlackBright: [100, 49],
113
- bgRedBright: [101, 49],
114
- bgGreenBright: [102, 49],
115
- bgYellowBright: [103, 49],
116
- bgBlueBright: [104, 49],
117
- bgMagentaBright: [105, 49],
118
- bgCyanBright: [106, 49],
119
- bgWhiteBright: [107, 49]
120
- }
121
- };
122
-
123
- // Alias bright black as gray (and grey)
124
- styles.color.gray = styles.color.blackBright;
125
- styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
126
- styles.color.grey = styles.color.blackBright;
127
- styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
128
-
129
- for (const [groupName, group] of Object.entries(styles)) {
130
- for (const [styleName, style] of Object.entries(group)) {
131
- styles[styleName] = {
132
- open: `\u001B[${style[0]}m`,
133
- close: `\u001B[${style[1]}m`
134
- };
135
-
136
- group[styleName] = styles[styleName];
137
-
138
- codes.set(style[0], style[1]);
139
- }
140
-
141
- Object.defineProperty(styles, groupName, {
142
- value: group,
143
- enumerable: false
144
- });
145
- }
146
-
147
- Object.defineProperty(styles, 'codes', {
148
- value: codes,
149
- enumerable: false
150
- });
151
-
152
- styles.color.close = '\u001B[39m';
153
- styles.bgColor.close = '\u001B[49m';
154
-
155
- setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
156
- setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
157
- setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
158
- setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
159
- setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
160
- setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
161
-
162
- return styles;
163
- }
164
-
165
- // Make the export immutable
166
- Object.defineProperty(module, 'exports', {
167
- enumerable: true,
168
- get: assembleStyles
169
- });
170
-
171
-
172
- /***/ }),
173
-
174
3
  /***/ 9742:
175
4
  /***/ (function(__unused_webpack_module, exports) {
176
5
 
@@ -5895,1874 +5724,254 @@ function BufferBigIntNotDefined () {
5895
5724
 
5896
5725
  /***/ }),
5897
5726
 
5898
- /***/ 4061:
5899
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
5900
-
5901
-
5902
- const ansiStyles = __webpack_require__(6434);
5903
- const {stdout: stdoutColor, stderr: stderrColor} = __webpack_require__(8555);
5904
- const {
5905
- stringReplaceAll,
5906
- stringEncaseCRLFWithFirstIndex
5907
- } = __webpack_require__(3559);
5908
-
5909
- const {isArray} = Array;
5727
+ /***/ 7187:
5728
+ /***/ (function(module) {
5910
5729
 
5911
- // `supportsColor.level` `ansiStyles.color[name]` mapping
5912
- const levelMapping = [
5913
- 'ansi',
5914
- 'ansi',
5915
- 'ansi256',
5916
- 'ansi16m'
5917
- ];
5730
+ // Copyright Joyent, Inc. and other Node contributors.
5731
+ //
5732
+ // Permission is hereby granted, free of charge, to any person obtaining a
5733
+ // copy of this software and associated documentation files (the
5734
+ // "Software"), to deal in the Software without restriction, including
5735
+ // without limitation the rights to use, copy, modify, merge, publish,
5736
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
5737
+ // persons to whom the Software is furnished to do so, subject to the
5738
+ // following conditions:
5739
+ //
5740
+ // The above copyright notice and this permission notice shall be included
5741
+ // in all copies or substantial portions of the Software.
5742
+ //
5743
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
5744
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5745
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
5746
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
5747
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
5748
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
5749
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
5918
5750
 
5919
- const styles = Object.create(null);
5920
5751
 
5921
- const applyOptions = (object, options = {}) => {
5922
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
5923
- throw new Error('The `level` option should be an integer from 0 to 3');
5924
- }
5925
5752
 
5926
- // Detect level if not set manually
5927
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
5928
- object.level = options.level === undefined ? colorLevel : options.level;
5929
- };
5753
+ var R = typeof Reflect === 'object' ? Reflect : null
5754
+ var ReflectApply = R && typeof R.apply === 'function'
5755
+ ? R.apply
5756
+ : function ReflectApply(target, receiver, args) {
5757
+ return Function.prototype.apply.call(target, receiver, args);
5758
+ }
5930
5759
 
5931
- class ChalkClass {
5932
- constructor(options) {
5933
- // eslint-disable-next-line no-constructor-return
5934
- return chalkFactory(options);
5935
- }
5760
+ var ReflectOwnKeys
5761
+ if (R && typeof R.ownKeys === 'function') {
5762
+ ReflectOwnKeys = R.ownKeys
5763
+ } else if (Object.getOwnPropertySymbols) {
5764
+ ReflectOwnKeys = function ReflectOwnKeys(target) {
5765
+ return Object.getOwnPropertyNames(target)
5766
+ .concat(Object.getOwnPropertySymbols(target));
5767
+ };
5768
+ } else {
5769
+ ReflectOwnKeys = function ReflectOwnKeys(target) {
5770
+ return Object.getOwnPropertyNames(target);
5771
+ };
5936
5772
  }
5937
5773
 
5938
- const chalkFactory = options => {
5939
- const chalk = {};
5940
- applyOptions(chalk, options);
5941
-
5942
- chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
5943
-
5944
- Object.setPrototypeOf(chalk, Chalk.prototype);
5945
- Object.setPrototypeOf(chalk.template, chalk);
5946
-
5947
- chalk.template.constructor = () => {
5948
- throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
5949
- };
5950
-
5951
- chalk.template.Instance = ChalkClass;
5952
-
5953
- return chalk.template;
5954
- };
5774
+ function ProcessEmitWarning(warning) {
5775
+ if (console && console.warn) console.warn(warning);
5776
+ }
5955
5777
 
5956
- function Chalk(options) {
5957
- return chalkFactory(options);
5778
+ var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
5779
+ return value !== value;
5958
5780
  }
5959
5781
 
5960
- for (const [styleName, style] of Object.entries(ansiStyles)) {
5961
- styles[styleName] = {
5962
- get() {
5963
- const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
5964
- Object.defineProperty(this, styleName, {value: builder});
5965
- return builder;
5966
- }
5967
- };
5782
+ function EventEmitter() {
5783
+ EventEmitter.init.call(this);
5968
5784
  }
5785
+ module.exports = EventEmitter;
5786
+ module.exports.once = once;
5969
5787
 
5970
- styles.visible = {
5971
- get() {
5972
- const builder = createBuilder(this, this._styler, true);
5973
- Object.defineProperty(this, 'visible', {value: builder});
5974
- return builder;
5975
- }
5976
- };
5788
+ // Backwards-compat with node 0.10.x
5789
+ EventEmitter.EventEmitter = EventEmitter;
5977
5790
 
5978
- const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
5979
-
5980
- for (const model of usedModels) {
5981
- styles[model] = {
5982
- get() {
5983
- const {level} = this;
5984
- return function (...arguments_) {
5985
- const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
5986
- return createBuilder(this, styler, this._isEmpty);
5987
- };
5988
- }
5989
- };
5990
- }
5991
-
5992
- for (const model of usedModels) {
5993
- const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
5994
- styles[bgModel] = {
5995
- get() {
5996
- const {level} = this;
5997
- return function (...arguments_) {
5998
- const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
5999
- return createBuilder(this, styler, this._isEmpty);
6000
- };
6001
- }
6002
- };
6003
- }
6004
-
6005
- const proto = Object.defineProperties(() => {}, {
6006
- ...styles,
6007
- level: {
6008
- enumerable: true,
6009
- get() {
6010
- return this._generator.level;
6011
- },
6012
- set(level) {
6013
- this._generator.level = level;
6014
- }
6015
- }
6016
- });
5791
+ EventEmitter.prototype._events = undefined;
5792
+ EventEmitter.prototype._eventsCount = 0;
5793
+ EventEmitter.prototype._maxListeners = undefined;
6017
5794
 
6018
- const createStyler = (open, close, parent) => {
6019
- let openAll;
6020
- let closeAll;
6021
- if (parent === undefined) {
6022
- openAll = open;
6023
- closeAll = close;
6024
- } else {
6025
- openAll = parent.openAll + open;
6026
- closeAll = close + parent.closeAll;
6027
- }
6028
-
6029
- return {
6030
- open,
6031
- close,
6032
- openAll,
6033
- closeAll,
6034
- parent
6035
- };
6036
- };
5795
+ // By default EventEmitters will print a warning if more than 10 listeners are
5796
+ // added to it. This is a useful default which helps finding memory leaks.
5797
+ var defaultMaxListeners = 10;
6037
5798
 
6038
- const createBuilder = (self, _styler, _isEmpty) => {
6039
- const builder = (...arguments_) => {
6040
- if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
6041
- // Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
6042
- return applyStyle(builder, chalkTag(builder, ...arguments_));
6043
- }
5799
+ function checkListener(listener) {
5800
+ if (typeof listener !== 'function') {
5801
+ throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
5802
+ }
5803
+ }
6044
5804
 
6045
- // Single argument is hot path, implicit coercion is faster than anything
6046
- // eslint-disable-next-line no-implicit-coercion
6047
- return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
6048
- };
5805
+ Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
5806
+ enumerable: true,
5807
+ get: function() {
5808
+ return defaultMaxListeners;
5809
+ },
5810
+ set: function(arg) {
5811
+ if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
5812
+ throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
5813
+ }
5814
+ defaultMaxListeners = arg;
5815
+ }
5816
+ });
6049
5817
 
6050
- // We alter the prototype because we must return a function, but there is
6051
- // no way to create a function with a different prototype
6052
- Object.setPrototypeOf(builder, proto);
5818
+ EventEmitter.init = function() {
6053
5819
 
6054
- builder._generator = self;
6055
- builder._styler = _styler;
6056
- builder._isEmpty = _isEmpty;
5820
+ if (this._events === undefined ||
5821
+ this._events === Object.getPrototypeOf(this)._events) {
5822
+ this._events = Object.create(null);
5823
+ this._eventsCount = 0;
5824
+ }
6057
5825
 
6058
- return builder;
5826
+ this._maxListeners = this._maxListeners || undefined;
6059
5827
  };
6060
5828
 
6061
- const applyStyle = (self, string) => {
6062
- if (self.level <= 0 || !string) {
6063
- return self._isEmpty ? '' : string;
6064
- }
6065
-
6066
- let styler = self._styler;
6067
-
6068
- if (styler === undefined) {
6069
- return string;
6070
- }
6071
-
6072
- const {openAll, closeAll} = styler;
6073
- if (string.indexOf('\u001B') !== -1) {
6074
- while (styler !== undefined) {
6075
- // Replace any instances already present with a re-opening code
6076
- // otherwise only the part of the string until said closing code
6077
- // will be colored, and the rest will simply be 'plain'.
6078
- string = stringReplaceAll(string, styler.close, styler.open);
6079
-
6080
- styler = styler.parent;
6081
- }
6082
- }
6083
-
6084
- // We can move both next actions out of loop, because remaining actions in loop won't have
6085
- // any/visible effect on parts we add here. Close the styling before a linebreak and reopen
6086
- // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
6087
- const lfIndex = string.indexOf('\n');
6088
- if (lfIndex !== -1) {
6089
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
6090
- }
6091
-
6092
- return openAll + string + closeAll;
5829
+ // Obviously not all Emitters should be limited to 10. This function allows
5830
+ // that to be increased. Set to zero for unlimited.
5831
+ EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
5832
+ if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
5833
+ throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
5834
+ }
5835
+ this._maxListeners = n;
5836
+ return this;
6093
5837
  };
6094
5838
 
6095
- let template;
6096
- const chalkTag = (chalk, ...strings) => {
6097
- const [firstString] = strings;
6098
-
6099
- if (!isArray(firstString) || !isArray(firstString.raw)) {
6100
- // If chalk() was called by itself or with a string,
6101
- // return the string itself as a string.
6102
- return strings.join(' ');
6103
- }
6104
-
6105
- const arguments_ = strings.slice(1);
6106
- const parts = [firstString.raw[0]];
6107
-
6108
- for (let i = 1; i < firstString.length; i++) {
6109
- parts.push(
6110
- String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
6111
- String(firstString.raw[i])
6112
- );
6113
- }
6114
-
6115
- if (template === undefined) {
6116
- template = __webpack_require__(9515);
6117
- }
5839
+ function _getMaxListeners(that) {
5840
+ if (that._maxListeners === undefined)
5841
+ return EventEmitter.defaultMaxListeners;
5842
+ return that._maxListeners;
5843
+ }
6118
5844
 
6119
- return template(chalk, parts.join(''));
5845
+ EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
5846
+ return _getMaxListeners(this);
6120
5847
  };
6121
5848
 
6122
- Object.defineProperties(Chalk.prototype, styles);
6123
-
6124
- const chalk = Chalk(); // eslint-disable-line new-cap
6125
- chalk.supportsColor = stdoutColor;
6126
- chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
6127
- chalk.stderr.supportsColor = stderrColor;
6128
-
6129
- module.exports = chalk;
6130
-
5849
+ EventEmitter.prototype.emit = function emit(type) {
5850
+ var args = [];
5851
+ for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
5852
+ var doError = (type === 'error');
6131
5853
 
6132
- /***/ }),
5854
+ var events = this._events;
5855
+ if (events !== undefined)
5856
+ doError = (doError && events.error === undefined);
5857
+ else if (!doError)
5858
+ return false;
6133
5859
 
6134
- /***/ 9515:
6135
- /***/ (function(module) {
5860
+ // If there is no 'error' event listener then throw.
5861
+ if (doError) {
5862
+ var er;
5863
+ if (args.length > 0)
5864
+ er = args[0];
5865
+ if (er instanceof Error) {
5866
+ // Note: The comments on the `throw` lines are intentional, they show
5867
+ // up in Node's output if this results in an unhandled exception.
5868
+ throw er; // Unhandled 'error' event
5869
+ }
5870
+ // At least give some kind of context to the user
5871
+ var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
5872
+ err.context = er;
5873
+ throw err; // Unhandled 'error' event
5874
+ }
6136
5875
 
5876
+ var handler = events[type];
6137
5877
 
6138
- const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
6139
- const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
6140
- const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
6141
- const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
5878
+ if (handler === undefined)
5879
+ return false;
6142
5880
 
6143
- const ESCAPES = new Map([
6144
- ['n', '\n'],
6145
- ['r', '\r'],
6146
- ['t', '\t'],
6147
- ['b', '\b'],
6148
- ['f', '\f'],
6149
- ['v', '\v'],
6150
- ['0', '\0'],
6151
- ['\\', '\\'],
6152
- ['e', '\u001B'],
6153
- ['a', '\u0007']
6154
- ]);
6155
-
6156
- function unescape(c) {
6157
- const u = c[0] === 'u';
6158
- const bracket = c[1] === '{';
6159
-
6160
- if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
6161
- return String.fromCharCode(parseInt(c.slice(1), 16));
6162
- }
6163
-
6164
- if (u && bracket) {
6165
- return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
6166
- }
6167
-
6168
- return ESCAPES.get(c) || c;
6169
- }
6170
-
6171
- function parseArguments(name, arguments_) {
6172
- const results = [];
6173
- const chunks = arguments_.trim().split(/\s*,\s*/g);
6174
- let matches;
6175
-
6176
- for (const chunk of chunks) {
6177
- const number = Number(chunk);
6178
- if (!Number.isNaN(number)) {
6179
- results.push(number);
6180
- } else if ((matches = chunk.match(STRING_REGEX))) {
6181
- results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
6182
- } else {
6183
- throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
6184
- }
6185
- }
6186
-
6187
- return results;
6188
- }
6189
-
6190
- function parseStyle(style) {
6191
- STYLE_REGEX.lastIndex = 0;
6192
-
6193
- const results = [];
6194
- let matches;
6195
-
6196
- while ((matches = STYLE_REGEX.exec(style)) !== null) {
6197
- const name = matches[1];
6198
-
6199
- if (matches[2]) {
6200
- const args = parseArguments(name, matches[2]);
6201
- results.push([name].concat(args));
6202
- } else {
6203
- results.push([name]);
6204
- }
6205
- }
6206
-
6207
- return results;
6208
- }
6209
-
6210
- function buildStyle(chalk, styles) {
6211
- const enabled = {};
6212
-
6213
- for (const layer of styles) {
6214
- for (const style of layer.styles) {
6215
- enabled[style[0]] = layer.inverse ? null : style.slice(1);
6216
- }
6217
- }
6218
-
6219
- let current = chalk;
6220
- for (const [styleName, styles] of Object.entries(enabled)) {
6221
- if (!Array.isArray(styles)) {
6222
- continue;
6223
- }
6224
-
6225
- if (!(styleName in current)) {
6226
- throw new Error(`Unknown Chalk style: ${styleName}`);
6227
- }
6228
-
6229
- current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
6230
- }
6231
-
6232
- return current;
6233
- }
6234
-
6235
- module.exports = (chalk, temporary) => {
6236
- const styles = [];
6237
- const chunks = [];
6238
- let chunk = [];
6239
-
6240
- // eslint-disable-next-line max-params
6241
- temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
6242
- if (escapeCharacter) {
6243
- chunk.push(unescape(escapeCharacter));
6244
- } else if (style) {
6245
- const string = chunk.join('');
6246
- chunk = [];
6247
- chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
6248
- styles.push({inverse, styles: parseStyle(style)});
6249
- } else if (close) {
6250
- if (styles.length === 0) {
6251
- throw new Error('Found extraneous } in Chalk template literal');
6252
- }
6253
-
6254
- chunks.push(buildStyle(chalk, styles)(chunk.join('')));
6255
- chunk = [];
6256
- styles.pop();
6257
- } else {
6258
- chunk.push(character);
6259
- }
6260
- });
6261
-
6262
- chunks.push(chunk.join(''));
5881
+ if (typeof handler === 'function') {
5882
+ ReflectApply(handler, this, args);
5883
+ } else {
5884
+ var len = handler.length;
5885
+ var listeners = arrayClone(handler, len);
5886
+ for (var i = 0; i < len; ++i)
5887
+ ReflectApply(listeners[i], this, args);
5888
+ }
6263
5889
 
6264
- if (styles.length > 0) {
6265
- const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
6266
- throw new Error(errMessage);
6267
- }
6268
-
6269
- return chunks.join('');
5890
+ return true;
6270
5891
  };
6271
5892
 
5893
+ function _addListener(target, type, listener, prepend) {
5894
+ var m;
5895
+ var events;
5896
+ var existing;
6272
5897
 
6273
- /***/ }),
6274
-
6275
- /***/ 3559:
6276
- /***/ (function(module) {
6277
-
5898
+ checkListener(listener);
6278
5899
 
5900
+ events = target._events;
5901
+ if (events === undefined) {
5902
+ events = target._events = Object.create(null);
5903
+ target._eventsCount = 0;
5904
+ } else {
5905
+ // To avoid recursion in the case that type === "newListener"! Before
5906
+ // adding it to the listeners, first emit "newListener".
5907
+ if (events.newListener !== undefined) {
5908
+ target.emit('newListener', type,
5909
+ listener.listener ? listener.listener : listener);
6279
5910
 
6280
- const stringReplaceAll = (string, substring, replacer) => {
6281
- let index = string.indexOf(substring);
6282
- if (index === -1) {
6283
- return string;
6284
- }
5911
+ // Re-assign `events` because a newListener handler could have caused the
5912
+ // this._events to be assigned to a new object
5913
+ events = target._events;
5914
+ }
5915
+ existing = events[type];
5916
+ }
6285
5917
 
6286
- const substringLength = substring.length;
6287
- let endIndex = 0;
6288
- let returnValue = '';
6289
- do {
6290
- returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
6291
- endIndex = index + substringLength;
6292
- index = string.indexOf(substring, endIndex);
6293
- } while (index !== -1);
5918
+ if (existing === undefined) {
5919
+ // Optimize the case of one listener. Don't need the extra array object.
5920
+ existing = events[type] = listener;
5921
+ ++target._eventsCount;
5922
+ } else {
5923
+ if (typeof existing === 'function') {
5924
+ // Adding the second element, need to change to array.
5925
+ existing = events[type] =
5926
+ prepend ? [listener, existing] : [existing, listener];
5927
+ // If we've already got an array, just append.
5928
+ } else if (prepend) {
5929
+ existing.unshift(listener);
5930
+ } else {
5931
+ existing.push(listener);
5932
+ }
6294
5933
 
6295
- returnValue += string.substr(endIndex);
6296
- return returnValue;
6297
- };
5934
+ // Check for listener leak
5935
+ m = _getMaxListeners(target);
5936
+ if (m > 0 && existing.length > m && !existing.warned) {
5937
+ existing.warned = true;
5938
+ // No error code for this since it is a Warning
5939
+ // eslint-disable-next-line no-restricted-syntax
5940
+ var w = new Error('Possible EventEmitter memory leak detected. ' +
5941
+ existing.length + ' ' + String(type) + ' listeners ' +
5942
+ 'added. Use emitter.setMaxListeners() to ' +
5943
+ 'increase limit');
5944
+ w.name = 'MaxListenersExceededWarning';
5945
+ w.emitter = target;
5946
+ w.type = type;
5947
+ w.count = existing.length;
5948
+ ProcessEmitWarning(w);
5949
+ }
5950
+ }
6298
5951
 
6299
- const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
6300
- let endIndex = 0;
6301
- let returnValue = '';
6302
- do {
6303
- const gotCR = string[index - 1] === '\r';
6304
- returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
6305
- endIndex = index + 1;
6306
- index = string.indexOf('\n', endIndex);
6307
- } while (index !== -1);
6308
-
6309
- returnValue += string.substr(endIndex);
6310
- return returnValue;
6311
- };
5952
+ return target;
5953
+ }
6312
5954
 
6313
- module.exports = {
6314
- stringReplaceAll,
6315
- stringEncaseCRLFWithFirstIndex
5955
+ EventEmitter.prototype.addListener = function addListener(type, listener) {
5956
+ return _addListener(this, type, listener, false);
6316
5957
  };
6317
5958
 
5959
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
6318
5960
 
6319
- /***/ }),
5961
+ EventEmitter.prototype.prependListener =
5962
+ function prependListener(type, listener) {
5963
+ return _addListener(this, type, listener, true);
5964
+ };
6320
5965
 
6321
- /***/ 8168:
6322
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
6323
-
6324
- /* MIT license */
6325
- /* eslint-disable no-mixed-operators */
6326
- const cssKeywords = __webpack_require__(8874);
6327
-
6328
- // NOTE: conversions should only return primitive values (i.e. arrays, or
6329
- // values that give correct `typeof` results).
6330
- // do not use box values types (i.e. Number(), String(), etc.)
6331
-
6332
- const reverseKeywords = {};
6333
- for (const key of Object.keys(cssKeywords)) {
6334
- reverseKeywords[cssKeywords[key]] = key;
6335
- }
6336
-
6337
- const convert = {
6338
- rgb: {channels: 3, labels: 'rgb'},
6339
- hsl: {channels: 3, labels: 'hsl'},
6340
- hsv: {channels: 3, labels: 'hsv'},
6341
- hwb: {channels: 3, labels: 'hwb'},
6342
- cmyk: {channels: 4, labels: 'cmyk'},
6343
- xyz: {channels: 3, labels: 'xyz'},
6344
- lab: {channels: 3, labels: 'lab'},
6345
- lch: {channels: 3, labels: 'lch'},
6346
- hex: {channels: 1, labels: ['hex']},
6347
- keyword: {channels: 1, labels: ['keyword']},
6348
- ansi16: {channels: 1, labels: ['ansi16']},
6349
- ansi256: {channels: 1, labels: ['ansi256']},
6350
- hcg: {channels: 3, labels: ['h', 'c', 'g']},
6351
- apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
6352
- gray: {channels: 1, labels: ['gray']}
6353
- };
6354
-
6355
- module.exports = convert;
6356
-
6357
- // Hide .channels and .labels properties
6358
- for (const model of Object.keys(convert)) {
6359
- if (!('channels' in convert[model])) {
6360
- throw new Error('missing channels property: ' + model);
6361
- }
6362
-
6363
- if (!('labels' in convert[model])) {
6364
- throw new Error('missing channel labels property: ' + model);
6365
- }
6366
-
6367
- if (convert[model].labels.length !== convert[model].channels) {
6368
- throw new Error('channel and label counts mismatch: ' + model);
6369
- }
6370
-
6371
- const {channels, labels} = convert[model];
6372
- delete convert[model].channels;
6373
- delete convert[model].labels;
6374
- Object.defineProperty(convert[model], 'channels', {value: channels});
6375
- Object.defineProperty(convert[model], 'labels', {value: labels});
6376
- }
6377
-
6378
- convert.rgb.hsl = function (rgb) {
6379
- const r = rgb[0] / 255;
6380
- const g = rgb[1] / 255;
6381
- const b = rgb[2] / 255;
6382
- const min = Math.min(r, g, b);
6383
- const max = Math.max(r, g, b);
6384
- const delta = max - min;
6385
- let h;
6386
- let s;
6387
-
6388
- if (max === min) {
6389
- h = 0;
6390
- } else if (r === max) {
6391
- h = (g - b) / delta;
6392
- } else if (g === max) {
6393
- h = 2 + (b - r) / delta;
6394
- } else if (b === max) {
6395
- h = 4 + (r - g) / delta;
6396
- }
6397
-
6398
- h = Math.min(h * 60, 360);
6399
-
6400
- if (h < 0) {
6401
- h += 360;
6402
- }
6403
-
6404
- const l = (min + max) / 2;
6405
-
6406
- if (max === min) {
6407
- s = 0;
6408
- } else if (l <= 0.5) {
6409
- s = delta / (max + min);
6410
- } else {
6411
- s = delta / (2 - max - min);
6412
- }
6413
-
6414
- return [h, s * 100, l * 100];
6415
- };
6416
-
6417
- convert.rgb.hsv = function (rgb) {
6418
- let rdif;
6419
- let gdif;
6420
- let bdif;
6421
- let h;
6422
- let s;
6423
-
6424
- const r = rgb[0] / 255;
6425
- const g = rgb[1] / 255;
6426
- const b = rgb[2] / 255;
6427
- const v = Math.max(r, g, b);
6428
- const diff = v - Math.min(r, g, b);
6429
- const diffc = function (c) {
6430
- return (v - c) / 6 / diff + 1 / 2;
6431
- };
6432
-
6433
- if (diff === 0) {
6434
- h = 0;
6435
- s = 0;
6436
- } else {
6437
- s = diff / v;
6438
- rdif = diffc(r);
6439
- gdif = diffc(g);
6440
- bdif = diffc(b);
6441
-
6442
- if (r === v) {
6443
- h = bdif - gdif;
6444
- } else if (g === v) {
6445
- h = (1 / 3) + rdif - bdif;
6446
- } else if (b === v) {
6447
- h = (2 / 3) + gdif - rdif;
6448
- }
6449
-
6450
- if (h < 0) {
6451
- h += 1;
6452
- } else if (h > 1) {
6453
- h -= 1;
6454
- }
6455
- }
6456
-
6457
- return [
6458
- h * 360,
6459
- s * 100,
6460
- v * 100
6461
- ];
6462
- };
6463
-
6464
- convert.rgb.hwb = function (rgb) {
6465
- const r = rgb[0];
6466
- const g = rgb[1];
6467
- let b = rgb[2];
6468
- const h = convert.rgb.hsl(rgb)[0];
6469
- const w = 1 / 255 * Math.min(r, Math.min(g, b));
6470
-
6471
- b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
6472
-
6473
- return [h, w * 100, b * 100];
6474
- };
6475
-
6476
- convert.rgb.cmyk = function (rgb) {
6477
- const r = rgb[0] / 255;
6478
- const g = rgb[1] / 255;
6479
- const b = rgb[2] / 255;
6480
-
6481
- const k = Math.min(1 - r, 1 - g, 1 - b);
6482
- const c = (1 - r - k) / (1 - k) || 0;
6483
- const m = (1 - g - k) / (1 - k) || 0;
6484
- const y = (1 - b - k) / (1 - k) || 0;
6485
-
6486
- return [c * 100, m * 100, y * 100, k * 100];
6487
- };
6488
-
6489
- function comparativeDistance(x, y) {
6490
- /*
6491
- See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
6492
- */
6493
- return (
6494
- ((x[0] - y[0]) ** 2) +
6495
- ((x[1] - y[1]) ** 2) +
6496
- ((x[2] - y[2]) ** 2)
6497
- );
6498
- }
6499
-
6500
- convert.rgb.keyword = function (rgb) {
6501
- const reversed = reverseKeywords[rgb];
6502
- if (reversed) {
6503
- return reversed;
6504
- }
6505
-
6506
- let currentClosestDistance = Infinity;
6507
- let currentClosestKeyword;
6508
-
6509
- for (const keyword of Object.keys(cssKeywords)) {
6510
- const value = cssKeywords[keyword];
6511
-
6512
- // Compute comparative distance
6513
- const distance = comparativeDistance(rgb, value);
6514
-
6515
- // Check if its less, if so set as closest
6516
- if (distance < currentClosestDistance) {
6517
- currentClosestDistance = distance;
6518
- currentClosestKeyword = keyword;
6519
- }
6520
- }
6521
-
6522
- return currentClosestKeyword;
6523
- };
6524
-
6525
- convert.keyword.rgb = function (keyword) {
6526
- return cssKeywords[keyword];
6527
- };
6528
-
6529
- convert.rgb.xyz = function (rgb) {
6530
- let r = rgb[0] / 255;
6531
- let g = rgb[1] / 255;
6532
- let b = rgb[2] / 255;
6533
-
6534
- // Assume sRGB
6535
- r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
6536
- g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
6537
- b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
6538
-
6539
- const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
6540
- const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
6541
- const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
6542
-
6543
- return [x * 100, y * 100, z * 100];
6544
- };
6545
-
6546
- convert.rgb.lab = function (rgb) {
6547
- const xyz = convert.rgb.xyz(rgb);
6548
- let x = xyz[0];
6549
- let y = xyz[1];
6550
- let z = xyz[2];
6551
-
6552
- x /= 95.047;
6553
- y /= 100;
6554
- z /= 108.883;
6555
-
6556
- x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
6557
- y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
6558
- z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
6559
-
6560
- const l = (116 * y) - 16;
6561
- const a = 500 * (x - y);
6562
- const b = 200 * (y - z);
6563
-
6564
- return [l, a, b];
6565
- };
6566
-
6567
- convert.hsl.rgb = function (hsl) {
6568
- const h = hsl[0] / 360;
6569
- const s = hsl[1] / 100;
6570
- const l = hsl[2] / 100;
6571
- let t2;
6572
- let t3;
6573
- let val;
6574
-
6575
- if (s === 0) {
6576
- val = l * 255;
6577
- return [val, val, val];
6578
- }
6579
-
6580
- if (l < 0.5) {
6581
- t2 = l * (1 + s);
6582
- } else {
6583
- t2 = l + s - l * s;
6584
- }
6585
-
6586
- const t1 = 2 * l - t2;
6587
-
6588
- const rgb = [0, 0, 0];
6589
- for (let i = 0; i < 3; i++) {
6590
- t3 = h + 1 / 3 * -(i - 1);
6591
- if (t3 < 0) {
6592
- t3++;
6593
- }
6594
-
6595
- if (t3 > 1) {
6596
- t3--;
6597
- }
6598
-
6599
- if (6 * t3 < 1) {
6600
- val = t1 + (t2 - t1) * 6 * t3;
6601
- } else if (2 * t3 < 1) {
6602
- val = t2;
6603
- } else if (3 * t3 < 2) {
6604
- val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
6605
- } else {
6606
- val = t1;
6607
- }
6608
-
6609
- rgb[i] = val * 255;
6610
- }
6611
-
6612
- return rgb;
6613
- };
6614
-
6615
- convert.hsl.hsv = function (hsl) {
6616
- const h = hsl[0];
6617
- let s = hsl[1] / 100;
6618
- let l = hsl[2] / 100;
6619
- let smin = s;
6620
- const lmin = Math.max(l, 0.01);
6621
-
6622
- l *= 2;
6623
- s *= (l <= 1) ? l : 2 - l;
6624
- smin *= lmin <= 1 ? lmin : 2 - lmin;
6625
- const v = (l + s) / 2;
6626
- const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
6627
-
6628
- return [h, sv * 100, v * 100];
6629
- };
6630
-
6631
- convert.hsv.rgb = function (hsv) {
6632
- const h = hsv[0] / 60;
6633
- const s = hsv[1] / 100;
6634
- let v = hsv[2] / 100;
6635
- const hi = Math.floor(h) % 6;
6636
-
6637
- const f = h - Math.floor(h);
6638
- const p = 255 * v * (1 - s);
6639
- const q = 255 * v * (1 - (s * f));
6640
- const t = 255 * v * (1 - (s * (1 - f)));
6641
- v *= 255;
6642
-
6643
- switch (hi) {
6644
- case 0:
6645
- return [v, t, p];
6646
- case 1:
6647
- return [q, v, p];
6648
- case 2:
6649
- return [p, v, t];
6650
- case 3:
6651
- return [p, q, v];
6652
- case 4:
6653
- return [t, p, v];
6654
- case 5:
6655
- return [v, p, q];
6656
- }
6657
- };
6658
-
6659
- convert.hsv.hsl = function (hsv) {
6660
- const h = hsv[0];
6661
- const s = hsv[1] / 100;
6662
- const v = hsv[2] / 100;
6663
- const vmin = Math.max(v, 0.01);
6664
- let sl;
6665
- let l;
6666
-
6667
- l = (2 - s) * v;
6668
- const lmin = (2 - s) * vmin;
6669
- sl = s * vmin;
6670
- sl /= (lmin <= 1) ? lmin : 2 - lmin;
6671
- sl = sl || 0;
6672
- l /= 2;
6673
-
6674
- return [h, sl * 100, l * 100];
6675
- };
6676
-
6677
- // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
6678
- convert.hwb.rgb = function (hwb) {
6679
- const h = hwb[0] / 360;
6680
- let wh = hwb[1] / 100;
6681
- let bl = hwb[2] / 100;
6682
- const ratio = wh + bl;
6683
- let f;
6684
-
6685
- // Wh + bl cant be > 1
6686
- if (ratio > 1) {
6687
- wh /= ratio;
6688
- bl /= ratio;
6689
- }
6690
-
6691
- const i = Math.floor(6 * h);
6692
- const v = 1 - bl;
6693
- f = 6 * h - i;
6694
-
6695
- if ((i & 0x01) !== 0) {
6696
- f = 1 - f;
6697
- }
6698
-
6699
- const n = wh + f * (v - wh); // Linear interpolation
6700
-
6701
- let r;
6702
- let g;
6703
- let b;
6704
- /* eslint-disable max-statements-per-line,no-multi-spaces */
6705
- switch (i) {
6706
- default:
6707
- case 6:
6708
- case 0: r = v; g = n; b = wh; break;
6709
- case 1: r = n; g = v; b = wh; break;
6710
- case 2: r = wh; g = v; b = n; break;
6711
- case 3: r = wh; g = n; b = v; break;
6712
- case 4: r = n; g = wh; b = v; break;
6713
- case 5: r = v; g = wh; b = n; break;
6714
- }
6715
- /* eslint-enable max-statements-per-line,no-multi-spaces */
6716
-
6717
- return [r * 255, g * 255, b * 255];
6718
- };
6719
-
6720
- convert.cmyk.rgb = function (cmyk) {
6721
- const c = cmyk[0] / 100;
6722
- const m = cmyk[1] / 100;
6723
- const y = cmyk[2] / 100;
6724
- const k = cmyk[3] / 100;
6725
-
6726
- const r = 1 - Math.min(1, c * (1 - k) + k);
6727
- const g = 1 - Math.min(1, m * (1 - k) + k);
6728
- const b = 1 - Math.min(1, y * (1 - k) + k);
6729
-
6730
- return [r * 255, g * 255, b * 255];
6731
- };
6732
-
6733
- convert.xyz.rgb = function (xyz) {
6734
- const x = xyz[0] / 100;
6735
- const y = xyz[1] / 100;
6736
- const z = xyz[2] / 100;
6737
- let r;
6738
- let g;
6739
- let b;
6740
-
6741
- r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
6742
- g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
6743
- b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
6744
-
6745
- // Assume sRGB
6746
- r = r > 0.0031308
6747
- ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
6748
- : r * 12.92;
6749
-
6750
- g = g > 0.0031308
6751
- ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
6752
- : g * 12.92;
6753
-
6754
- b = b > 0.0031308
6755
- ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
6756
- : b * 12.92;
6757
-
6758
- r = Math.min(Math.max(0, r), 1);
6759
- g = Math.min(Math.max(0, g), 1);
6760
- b = Math.min(Math.max(0, b), 1);
6761
-
6762
- return [r * 255, g * 255, b * 255];
6763
- };
6764
-
6765
- convert.xyz.lab = function (xyz) {
6766
- let x = xyz[0];
6767
- let y = xyz[1];
6768
- let z = xyz[2];
6769
-
6770
- x /= 95.047;
6771
- y /= 100;
6772
- z /= 108.883;
6773
-
6774
- x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
6775
- y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
6776
- z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
6777
-
6778
- const l = (116 * y) - 16;
6779
- const a = 500 * (x - y);
6780
- const b = 200 * (y - z);
6781
-
6782
- return [l, a, b];
6783
- };
6784
-
6785
- convert.lab.xyz = function (lab) {
6786
- const l = lab[0];
6787
- const a = lab[1];
6788
- const b = lab[2];
6789
- let x;
6790
- let y;
6791
- let z;
6792
-
6793
- y = (l + 16) / 116;
6794
- x = a / 500 + y;
6795
- z = y - b / 200;
6796
-
6797
- const y2 = y ** 3;
6798
- const x2 = x ** 3;
6799
- const z2 = z ** 3;
6800
- y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
6801
- x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
6802
- z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
6803
-
6804
- x *= 95.047;
6805
- y *= 100;
6806
- z *= 108.883;
6807
-
6808
- return [x, y, z];
6809
- };
6810
-
6811
- convert.lab.lch = function (lab) {
6812
- const l = lab[0];
6813
- const a = lab[1];
6814
- const b = lab[2];
6815
- let h;
6816
-
6817
- const hr = Math.atan2(b, a);
6818
- h = hr * 360 / 2 / Math.PI;
6819
-
6820
- if (h < 0) {
6821
- h += 360;
6822
- }
6823
-
6824
- const c = Math.sqrt(a * a + b * b);
6825
-
6826
- return [l, c, h];
6827
- };
6828
-
6829
- convert.lch.lab = function (lch) {
6830
- const l = lch[0];
6831
- const c = lch[1];
6832
- const h = lch[2];
6833
-
6834
- const hr = h / 360 * 2 * Math.PI;
6835
- const a = c * Math.cos(hr);
6836
- const b = c * Math.sin(hr);
6837
-
6838
- return [l, a, b];
6839
- };
6840
-
6841
- convert.rgb.ansi16 = function (args, saturation = null) {
6842
- const [r, g, b] = args;
6843
- let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
6844
-
6845
- value = Math.round(value / 50);
6846
-
6847
- if (value === 0) {
6848
- return 30;
6849
- }
6850
-
6851
- let ansi = 30
6852
- + ((Math.round(b / 255) << 2)
6853
- | (Math.round(g / 255) << 1)
6854
- | Math.round(r / 255));
6855
-
6856
- if (value === 2) {
6857
- ansi += 60;
6858
- }
6859
-
6860
- return ansi;
6861
- };
6862
-
6863
- convert.hsv.ansi16 = function (args) {
6864
- // Optimization here; we already know the value and don't need to get
6865
- // it converted for us.
6866
- return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
6867
- };
6868
-
6869
- convert.rgb.ansi256 = function (args) {
6870
- const r = args[0];
6871
- const g = args[1];
6872
- const b = args[2];
6873
-
6874
- // We use the extended greyscale palette here, with the exception of
6875
- // black and white. normal palette only has 4 greyscale shades.
6876
- if (r === g && g === b) {
6877
- if (r < 8) {
6878
- return 16;
6879
- }
6880
-
6881
- if (r > 248) {
6882
- return 231;
6883
- }
6884
-
6885
- return Math.round(((r - 8) / 247) * 24) + 232;
6886
- }
6887
-
6888
- const ansi = 16
6889
- + (36 * Math.round(r / 255 * 5))
6890
- + (6 * Math.round(g / 255 * 5))
6891
- + Math.round(b / 255 * 5);
6892
-
6893
- return ansi;
6894
- };
6895
-
6896
- convert.ansi16.rgb = function (args) {
6897
- let color = args % 10;
6898
-
6899
- // Handle greyscale
6900
- if (color === 0 || color === 7) {
6901
- if (args > 50) {
6902
- color += 3.5;
6903
- }
6904
-
6905
- color = color / 10.5 * 255;
6906
-
6907
- return [color, color, color];
6908
- }
6909
-
6910
- const mult = (~~(args > 50) + 1) * 0.5;
6911
- const r = ((color & 1) * mult) * 255;
6912
- const g = (((color >> 1) & 1) * mult) * 255;
6913
- const b = (((color >> 2) & 1) * mult) * 255;
6914
-
6915
- return [r, g, b];
6916
- };
6917
-
6918
- convert.ansi256.rgb = function (args) {
6919
- // Handle greyscale
6920
- if (args >= 232) {
6921
- const c = (args - 232) * 10 + 8;
6922
- return [c, c, c];
6923
- }
6924
-
6925
- args -= 16;
6926
-
6927
- let rem;
6928
- const r = Math.floor(args / 36) / 5 * 255;
6929
- const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
6930
- const b = (rem % 6) / 5 * 255;
6931
-
6932
- return [r, g, b];
6933
- };
6934
-
6935
- convert.rgb.hex = function (args) {
6936
- const integer = ((Math.round(args[0]) & 0xFF) << 16)
6937
- + ((Math.round(args[1]) & 0xFF) << 8)
6938
- + (Math.round(args[2]) & 0xFF);
6939
-
6940
- const string = integer.toString(16).toUpperCase();
6941
- return '000000'.substring(string.length) + string;
6942
- };
6943
-
6944
- convert.hex.rgb = function (args) {
6945
- const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
6946
- if (!match) {
6947
- return [0, 0, 0];
6948
- }
6949
-
6950
- let colorString = match[0];
6951
-
6952
- if (match[0].length === 3) {
6953
- colorString = colorString.split('').map(char => {
6954
- return char + char;
6955
- }).join('');
6956
- }
6957
-
6958
- const integer = parseInt(colorString, 16);
6959
- const r = (integer >> 16) & 0xFF;
6960
- const g = (integer >> 8) & 0xFF;
6961
- const b = integer & 0xFF;
6962
-
6963
- return [r, g, b];
6964
- };
6965
-
6966
- convert.rgb.hcg = function (rgb) {
6967
- const r = rgb[0] / 255;
6968
- const g = rgb[1] / 255;
6969
- const b = rgb[2] / 255;
6970
- const max = Math.max(Math.max(r, g), b);
6971
- const min = Math.min(Math.min(r, g), b);
6972
- const chroma = (max - min);
6973
- let grayscale;
6974
- let hue;
6975
-
6976
- if (chroma < 1) {
6977
- grayscale = min / (1 - chroma);
6978
- } else {
6979
- grayscale = 0;
6980
- }
6981
-
6982
- if (chroma <= 0) {
6983
- hue = 0;
6984
- } else
6985
- if (max === r) {
6986
- hue = ((g - b) / chroma) % 6;
6987
- } else
6988
- if (max === g) {
6989
- hue = 2 + (b - r) / chroma;
6990
- } else {
6991
- hue = 4 + (r - g) / chroma;
6992
- }
6993
-
6994
- hue /= 6;
6995
- hue %= 1;
6996
-
6997
- return [hue * 360, chroma * 100, grayscale * 100];
6998
- };
6999
-
7000
- convert.hsl.hcg = function (hsl) {
7001
- const s = hsl[1] / 100;
7002
- const l = hsl[2] / 100;
7003
-
7004
- const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
7005
-
7006
- let f = 0;
7007
- if (c < 1.0) {
7008
- f = (l - 0.5 * c) / (1.0 - c);
7009
- }
7010
-
7011
- return [hsl[0], c * 100, f * 100];
7012
- };
7013
-
7014
- convert.hsv.hcg = function (hsv) {
7015
- const s = hsv[1] / 100;
7016
- const v = hsv[2] / 100;
7017
-
7018
- const c = s * v;
7019
- let f = 0;
7020
-
7021
- if (c < 1.0) {
7022
- f = (v - c) / (1 - c);
7023
- }
7024
-
7025
- return [hsv[0], c * 100, f * 100];
7026
- };
7027
-
7028
- convert.hcg.rgb = function (hcg) {
7029
- const h = hcg[0] / 360;
7030
- const c = hcg[1] / 100;
7031
- const g = hcg[2] / 100;
7032
-
7033
- if (c === 0.0) {
7034
- return [g * 255, g * 255, g * 255];
7035
- }
7036
-
7037
- const pure = [0, 0, 0];
7038
- const hi = (h % 1) * 6;
7039
- const v = hi % 1;
7040
- const w = 1 - v;
7041
- let mg = 0;
7042
-
7043
- /* eslint-disable max-statements-per-line */
7044
- switch (Math.floor(hi)) {
7045
- case 0:
7046
- pure[0] = 1; pure[1] = v; pure[2] = 0; break;
7047
- case 1:
7048
- pure[0] = w; pure[1] = 1; pure[2] = 0; break;
7049
- case 2:
7050
- pure[0] = 0; pure[1] = 1; pure[2] = v; break;
7051
- case 3:
7052
- pure[0] = 0; pure[1] = w; pure[2] = 1; break;
7053
- case 4:
7054
- pure[0] = v; pure[1] = 0; pure[2] = 1; break;
7055
- default:
7056
- pure[0] = 1; pure[1] = 0; pure[2] = w;
7057
- }
7058
- /* eslint-enable max-statements-per-line */
7059
-
7060
- mg = (1.0 - c) * g;
7061
-
7062
- return [
7063
- (c * pure[0] + mg) * 255,
7064
- (c * pure[1] + mg) * 255,
7065
- (c * pure[2] + mg) * 255
7066
- ];
7067
- };
7068
-
7069
- convert.hcg.hsv = function (hcg) {
7070
- const c = hcg[1] / 100;
7071
- const g = hcg[2] / 100;
7072
-
7073
- const v = c + g * (1.0 - c);
7074
- let f = 0;
7075
-
7076
- if (v > 0.0) {
7077
- f = c / v;
7078
- }
7079
-
7080
- return [hcg[0], f * 100, v * 100];
7081
- };
7082
-
7083
- convert.hcg.hsl = function (hcg) {
7084
- const c = hcg[1] / 100;
7085
- const g = hcg[2] / 100;
7086
-
7087
- const l = g * (1.0 - c) + 0.5 * c;
7088
- let s = 0;
7089
-
7090
- if (l > 0.0 && l < 0.5) {
7091
- s = c / (2 * l);
7092
- } else
7093
- if (l >= 0.5 && l < 1.0) {
7094
- s = c / (2 * (1 - l));
7095
- }
7096
-
7097
- return [hcg[0], s * 100, l * 100];
7098
- };
7099
-
7100
- convert.hcg.hwb = function (hcg) {
7101
- const c = hcg[1] / 100;
7102
- const g = hcg[2] / 100;
7103
- const v = c + g * (1.0 - c);
7104
- return [hcg[0], (v - c) * 100, (1 - v) * 100];
7105
- };
7106
-
7107
- convert.hwb.hcg = function (hwb) {
7108
- const w = hwb[1] / 100;
7109
- const b = hwb[2] / 100;
7110
- const v = 1 - b;
7111
- const c = v - w;
7112
- let g = 0;
7113
-
7114
- if (c < 1) {
7115
- g = (v - c) / (1 - c);
7116
- }
7117
-
7118
- return [hwb[0], c * 100, g * 100];
7119
- };
7120
-
7121
- convert.apple.rgb = function (apple) {
7122
- return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
7123
- };
7124
-
7125
- convert.rgb.apple = function (rgb) {
7126
- return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
7127
- };
7128
-
7129
- convert.gray.rgb = function (args) {
7130
- return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
7131
- };
7132
-
7133
- convert.gray.hsl = function (args) {
7134
- return [0, 0, args[0]];
7135
- };
7136
-
7137
- convert.gray.hsv = convert.gray.hsl;
7138
-
7139
- convert.gray.hwb = function (gray) {
7140
- return [0, 100, gray[0]];
7141
- };
7142
-
7143
- convert.gray.cmyk = function (gray) {
7144
- return [0, 0, 0, gray[0]];
7145
- };
7146
-
7147
- convert.gray.lab = function (gray) {
7148
- return [gray[0], 0, 0];
7149
- };
7150
-
7151
- convert.gray.hex = function (gray) {
7152
- const val = Math.round(gray[0] / 100 * 255) & 0xFF;
7153
- const integer = (val << 16) + (val << 8) + val;
7154
-
7155
- const string = integer.toString(16).toUpperCase();
7156
- return '000000'.substring(string.length) + string;
7157
- };
7158
-
7159
- convert.rgb.gray = function (rgb) {
7160
- const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
7161
- return [val / 255 * 100];
7162
- };
7163
-
7164
-
7165
- /***/ }),
7166
-
7167
- /***/ 2085:
7168
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
7169
-
7170
- const conversions = __webpack_require__(8168);
7171
- const route = __webpack_require__(4111);
7172
-
7173
- const convert = {};
7174
-
7175
- const models = Object.keys(conversions);
7176
-
7177
- function wrapRaw(fn) {
7178
- const wrappedFn = function (...args) {
7179
- const arg0 = args[0];
7180
- if (arg0 === undefined || arg0 === null) {
7181
- return arg0;
7182
- }
7183
-
7184
- if (arg0.length > 1) {
7185
- args = arg0;
7186
- }
7187
-
7188
- return fn(args);
7189
- };
7190
-
7191
- // Preserve .conversion property if there is one
7192
- if ('conversion' in fn) {
7193
- wrappedFn.conversion = fn.conversion;
7194
- }
7195
-
7196
- return wrappedFn;
7197
- }
7198
-
7199
- function wrapRounded(fn) {
7200
- const wrappedFn = function (...args) {
7201
- const arg0 = args[0];
7202
-
7203
- if (arg0 === undefined || arg0 === null) {
7204
- return arg0;
7205
- }
7206
-
7207
- if (arg0.length > 1) {
7208
- args = arg0;
7209
- }
7210
-
7211
- const result = fn(args);
7212
-
7213
- // We're assuming the result is an array here.
7214
- // see notice in conversions.js; don't use box types
7215
- // in conversion functions.
7216
- if (typeof result === 'object') {
7217
- for (let len = result.length, i = 0; i < len; i++) {
7218
- result[i] = Math.round(result[i]);
7219
- }
7220
- }
7221
-
7222
- return result;
7223
- };
7224
-
7225
- // Preserve .conversion property if there is one
7226
- if ('conversion' in fn) {
7227
- wrappedFn.conversion = fn.conversion;
7228
- }
7229
-
7230
- return wrappedFn;
7231
- }
7232
-
7233
- models.forEach(fromModel => {
7234
- convert[fromModel] = {};
7235
-
7236
- Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
7237
- Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
7238
-
7239
- const routes = route(fromModel);
7240
- const routeModels = Object.keys(routes);
7241
-
7242
- routeModels.forEach(toModel => {
7243
- const fn = routes[toModel];
7244
-
7245
- convert[fromModel][toModel] = wrapRounded(fn);
7246
- convert[fromModel][toModel].raw = wrapRaw(fn);
7247
- });
7248
- });
7249
-
7250
- module.exports = convert;
7251
-
7252
-
7253
- /***/ }),
7254
-
7255
- /***/ 4111:
7256
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
7257
-
7258
- const conversions = __webpack_require__(8168);
7259
-
7260
- /*
7261
- This function routes a model to all other models.
7262
-
7263
- all functions that are routed have a property `.conversion` attached
7264
- to the returned synthetic function. This property is an array
7265
- of strings, each with the steps in between the 'from' and 'to'
7266
- color models (inclusive).
7267
-
7268
- conversions that are not possible simply are not included.
7269
- */
7270
-
7271
- function buildGraph() {
7272
- const graph = {};
7273
- // https://jsperf.com/object-keys-vs-for-in-with-closure/3
7274
- const models = Object.keys(conversions);
7275
-
7276
- for (let len = models.length, i = 0; i < len; i++) {
7277
- graph[models[i]] = {
7278
- // http://jsperf.com/1-vs-infinity
7279
- // micro-opt, but this is simple.
7280
- distance: -1,
7281
- parent: null
7282
- };
7283
- }
7284
-
7285
- return graph;
7286
- }
7287
-
7288
- // https://en.wikipedia.org/wiki/Breadth-first_search
7289
- function deriveBFS(fromModel) {
7290
- const graph = buildGraph();
7291
- const queue = [fromModel]; // Unshift -> queue -> pop
7292
-
7293
- graph[fromModel].distance = 0;
7294
-
7295
- while (queue.length) {
7296
- const current = queue.pop();
7297
- const adjacents = Object.keys(conversions[current]);
7298
-
7299
- for (let len = adjacents.length, i = 0; i < len; i++) {
7300
- const adjacent = adjacents[i];
7301
- const node = graph[adjacent];
7302
-
7303
- if (node.distance === -1) {
7304
- node.distance = graph[current].distance + 1;
7305
- node.parent = current;
7306
- queue.unshift(adjacent);
7307
- }
7308
- }
7309
- }
7310
-
7311
- return graph;
7312
- }
7313
-
7314
- function link(from, to) {
7315
- return function (args) {
7316
- return to(from(args));
7317
- };
7318
- }
7319
-
7320
- function wrapConversion(toModel, graph) {
7321
- const path = [graph[toModel].parent, toModel];
7322
- let fn = conversions[graph[toModel].parent][toModel];
7323
-
7324
- let cur = graph[toModel].parent;
7325
- while (graph[cur].parent) {
7326
- path.unshift(graph[cur].parent);
7327
- fn = link(conversions[graph[cur].parent][cur], fn);
7328
- cur = graph[cur].parent;
7329
- }
7330
-
7331
- fn.conversion = path;
7332
- return fn;
7333
- }
7334
-
7335
- module.exports = function (fromModel) {
7336
- const graph = deriveBFS(fromModel);
7337
- const conversion = {};
7338
-
7339
- const models = Object.keys(graph);
7340
- for (let len = models.length, i = 0; i < len; i++) {
7341
- const toModel = models[i];
7342
- const node = graph[toModel];
7343
-
7344
- if (node.parent === null) {
7345
- // No possible conversion, or this node is the source model.
7346
- continue;
7347
- }
7348
-
7349
- conversion[toModel] = wrapConversion(toModel, graph);
7350
- }
7351
-
7352
- return conversion;
7353
- };
7354
-
7355
-
7356
-
7357
- /***/ }),
7358
-
7359
- /***/ 8874:
7360
- /***/ (function(module) {
7361
-
7362
-
7363
-
7364
- module.exports = {
7365
- "aliceblue": [240, 248, 255],
7366
- "antiquewhite": [250, 235, 215],
7367
- "aqua": [0, 255, 255],
7368
- "aquamarine": [127, 255, 212],
7369
- "azure": [240, 255, 255],
7370
- "beige": [245, 245, 220],
7371
- "bisque": [255, 228, 196],
7372
- "black": [0, 0, 0],
7373
- "blanchedalmond": [255, 235, 205],
7374
- "blue": [0, 0, 255],
7375
- "blueviolet": [138, 43, 226],
7376
- "brown": [165, 42, 42],
7377
- "burlywood": [222, 184, 135],
7378
- "cadetblue": [95, 158, 160],
7379
- "chartreuse": [127, 255, 0],
7380
- "chocolate": [210, 105, 30],
7381
- "coral": [255, 127, 80],
7382
- "cornflowerblue": [100, 149, 237],
7383
- "cornsilk": [255, 248, 220],
7384
- "crimson": [220, 20, 60],
7385
- "cyan": [0, 255, 255],
7386
- "darkblue": [0, 0, 139],
7387
- "darkcyan": [0, 139, 139],
7388
- "darkgoldenrod": [184, 134, 11],
7389
- "darkgray": [169, 169, 169],
7390
- "darkgreen": [0, 100, 0],
7391
- "darkgrey": [169, 169, 169],
7392
- "darkkhaki": [189, 183, 107],
7393
- "darkmagenta": [139, 0, 139],
7394
- "darkolivegreen": [85, 107, 47],
7395
- "darkorange": [255, 140, 0],
7396
- "darkorchid": [153, 50, 204],
7397
- "darkred": [139, 0, 0],
7398
- "darksalmon": [233, 150, 122],
7399
- "darkseagreen": [143, 188, 143],
7400
- "darkslateblue": [72, 61, 139],
7401
- "darkslategray": [47, 79, 79],
7402
- "darkslategrey": [47, 79, 79],
7403
- "darkturquoise": [0, 206, 209],
7404
- "darkviolet": [148, 0, 211],
7405
- "deeppink": [255, 20, 147],
7406
- "deepskyblue": [0, 191, 255],
7407
- "dimgray": [105, 105, 105],
7408
- "dimgrey": [105, 105, 105],
7409
- "dodgerblue": [30, 144, 255],
7410
- "firebrick": [178, 34, 34],
7411
- "floralwhite": [255, 250, 240],
7412
- "forestgreen": [34, 139, 34],
7413
- "fuchsia": [255, 0, 255],
7414
- "gainsboro": [220, 220, 220],
7415
- "ghostwhite": [248, 248, 255],
7416
- "gold": [255, 215, 0],
7417
- "goldenrod": [218, 165, 32],
7418
- "gray": [128, 128, 128],
7419
- "green": [0, 128, 0],
7420
- "greenyellow": [173, 255, 47],
7421
- "grey": [128, 128, 128],
7422
- "honeydew": [240, 255, 240],
7423
- "hotpink": [255, 105, 180],
7424
- "indianred": [205, 92, 92],
7425
- "indigo": [75, 0, 130],
7426
- "ivory": [255, 255, 240],
7427
- "khaki": [240, 230, 140],
7428
- "lavender": [230, 230, 250],
7429
- "lavenderblush": [255, 240, 245],
7430
- "lawngreen": [124, 252, 0],
7431
- "lemonchiffon": [255, 250, 205],
7432
- "lightblue": [173, 216, 230],
7433
- "lightcoral": [240, 128, 128],
7434
- "lightcyan": [224, 255, 255],
7435
- "lightgoldenrodyellow": [250, 250, 210],
7436
- "lightgray": [211, 211, 211],
7437
- "lightgreen": [144, 238, 144],
7438
- "lightgrey": [211, 211, 211],
7439
- "lightpink": [255, 182, 193],
7440
- "lightsalmon": [255, 160, 122],
7441
- "lightseagreen": [32, 178, 170],
7442
- "lightskyblue": [135, 206, 250],
7443
- "lightslategray": [119, 136, 153],
7444
- "lightslategrey": [119, 136, 153],
7445
- "lightsteelblue": [176, 196, 222],
7446
- "lightyellow": [255, 255, 224],
7447
- "lime": [0, 255, 0],
7448
- "limegreen": [50, 205, 50],
7449
- "linen": [250, 240, 230],
7450
- "magenta": [255, 0, 255],
7451
- "maroon": [128, 0, 0],
7452
- "mediumaquamarine": [102, 205, 170],
7453
- "mediumblue": [0, 0, 205],
7454
- "mediumorchid": [186, 85, 211],
7455
- "mediumpurple": [147, 112, 219],
7456
- "mediumseagreen": [60, 179, 113],
7457
- "mediumslateblue": [123, 104, 238],
7458
- "mediumspringgreen": [0, 250, 154],
7459
- "mediumturquoise": [72, 209, 204],
7460
- "mediumvioletred": [199, 21, 133],
7461
- "midnightblue": [25, 25, 112],
7462
- "mintcream": [245, 255, 250],
7463
- "mistyrose": [255, 228, 225],
7464
- "moccasin": [255, 228, 181],
7465
- "navajowhite": [255, 222, 173],
7466
- "navy": [0, 0, 128],
7467
- "oldlace": [253, 245, 230],
7468
- "olive": [128, 128, 0],
7469
- "olivedrab": [107, 142, 35],
7470
- "orange": [255, 165, 0],
7471
- "orangered": [255, 69, 0],
7472
- "orchid": [218, 112, 214],
7473
- "palegoldenrod": [238, 232, 170],
7474
- "palegreen": [152, 251, 152],
7475
- "paleturquoise": [175, 238, 238],
7476
- "palevioletred": [219, 112, 147],
7477
- "papayawhip": [255, 239, 213],
7478
- "peachpuff": [255, 218, 185],
7479
- "peru": [205, 133, 63],
7480
- "pink": [255, 192, 203],
7481
- "plum": [221, 160, 221],
7482
- "powderblue": [176, 224, 230],
7483
- "purple": [128, 0, 128],
7484
- "rebeccapurple": [102, 51, 153],
7485
- "red": [255, 0, 0],
7486
- "rosybrown": [188, 143, 143],
7487
- "royalblue": [65, 105, 225],
7488
- "saddlebrown": [139, 69, 19],
7489
- "salmon": [250, 128, 114],
7490
- "sandybrown": [244, 164, 96],
7491
- "seagreen": [46, 139, 87],
7492
- "seashell": [255, 245, 238],
7493
- "sienna": [160, 82, 45],
7494
- "silver": [192, 192, 192],
7495
- "skyblue": [135, 206, 235],
7496
- "slateblue": [106, 90, 205],
7497
- "slategray": [112, 128, 144],
7498
- "slategrey": [112, 128, 144],
7499
- "snow": [255, 250, 250],
7500
- "springgreen": [0, 255, 127],
7501
- "steelblue": [70, 130, 180],
7502
- "tan": [210, 180, 140],
7503
- "teal": [0, 128, 128],
7504
- "thistle": [216, 191, 216],
7505
- "tomato": [255, 99, 71],
7506
- "turquoise": [64, 224, 208],
7507
- "violet": [238, 130, 238],
7508
- "wheat": [245, 222, 179],
7509
- "white": [255, 255, 255],
7510
- "whitesmoke": [245, 245, 245],
7511
- "yellow": [255, 255, 0],
7512
- "yellowgreen": [154, 205, 50]
7513
- };
7514
-
7515
-
7516
- /***/ }),
7517
-
7518
- /***/ 7187:
7519
- /***/ (function(module) {
7520
-
7521
- // Copyright Joyent, Inc. and other Node contributors.
7522
- //
7523
- // Permission is hereby granted, free of charge, to any person obtaining a
7524
- // copy of this software and associated documentation files (the
7525
- // "Software"), to deal in the Software without restriction, including
7526
- // without limitation the rights to use, copy, modify, merge, publish,
7527
- // distribute, sublicense, and/or sell copies of the Software, and to permit
7528
- // persons to whom the Software is furnished to do so, subject to the
7529
- // following conditions:
7530
- //
7531
- // The above copyright notice and this permission notice shall be included
7532
- // in all copies or substantial portions of the Software.
7533
- //
7534
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
7535
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
7536
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
7537
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
7538
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
7539
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
7540
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
7541
-
7542
-
7543
-
7544
- var R = typeof Reflect === 'object' ? Reflect : null
7545
- var ReflectApply = R && typeof R.apply === 'function'
7546
- ? R.apply
7547
- : function ReflectApply(target, receiver, args) {
7548
- return Function.prototype.apply.call(target, receiver, args);
7549
- }
7550
-
7551
- var ReflectOwnKeys
7552
- if (R && typeof R.ownKeys === 'function') {
7553
- ReflectOwnKeys = R.ownKeys
7554
- } else if (Object.getOwnPropertySymbols) {
7555
- ReflectOwnKeys = function ReflectOwnKeys(target) {
7556
- return Object.getOwnPropertyNames(target)
7557
- .concat(Object.getOwnPropertySymbols(target));
7558
- };
7559
- } else {
7560
- ReflectOwnKeys = function ReflectOwnKeys(target) {
7561
- return Object.getOwnPropertyNames(target);
7562
- };
7563
- }
7564
-
7565
- function ProcessEmitWarning(warning) {
7566
- if (console && console.warn) console.warn(warning);
7567
- }
7568
-
7569
- var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
7570
- return value !== value;
7571
- }
7572
-
7573
- function EventEmitter() {
7574
- EventEmitter.init.call(this);
7575
- }
7576
- module.exports = EventEmitter;
7577
- module.exports.once = once;
7578
-
7579
- // Backwards-compat with node 0.10.x
7580
- EventEmitter.EventEmitter = EventEmitter;
7581
-
7582
- EventEmitter.prototype._events = undefined;
7583
- EventEmitter.prototype._eventsCount = 0;
7584
- EventEmitter.prototype._maxListeners = undefined;
7585
-
7586
- // By default EventEmitters will print a warning if more than 10 listeners are
7587
- // added to it. This is a useful default which helps finding memory leaks.
7588
- var defaultMaxListeners = 10;
7589
-
7590
- function checkListener(listener) {
7591
- if (typeof listener !== 'function') {
7592
- throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
7593
- }
7594
- }
7595
-
7596
- Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
7597
- enumerable: true,
7598
- get: function() {
7599
- return defaultMaxListeners;
7600
- },
7601
- set: function(arg) {
7602
- if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
7603
- throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
7604
- }
7605
- defaultMaxListeners = arg;
7606
- }
7607
- });
7608
-
7609
- EventEmitter.init = function() {
7610
-
7611
- if (this._events === undefined ||
7612
- this._events === Object.getPrototypeOf(this)._events) {
7613
- this._events = Object.create(null);
7614
- this._eventsCount = 0;
7615
- }
7616
-
7617
- this._maxListeners = this._maxListeners || undefined;
7618
- };
7619
-
7620
- // Obviously not all Emitters should be limited to 10. This function allows
7621
- // that to be increased. Set to zero for unlimited.
7622
- EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
7623
- if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
7624
- throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
7625
- }
7626
- this._maxListeners = n;
7627
- return this;
7628
- };
7629
-
7630
- function _getMaxListeners(that) {
7631
- if (that._maxListeners === undefined)
7632
- return EventEmitter.defaultMaxListeners;
7633
- return that._maxListeners;
7634
- }
7635
-
7636
- EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
7637
- return _getMaxListeners(this);
7638
- };
7639
-
7640
- EventEmitter.prototype.emit = function emit(type) {
7641
- var args = [];
7642
- for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
7643
- var doError = (type === 'error');
7644
-
7645
- var events = this._events;
7646
- if (events !== undefined)
7647
- doError = (doError && events.error === undefined);
7648
- else if (!doError)
7649
- return false;
7650
-
7651
- // If there is no 'error' event listener then throw.
7652
- if (doError) {
7653
- var er;
7654
- if (args.length > 0)
7655
- er = args[0];
7656
- if (er instanceof Error) {
7657
- // Note: The comments on the `throw` lines are intentional, they show
7658
- // up in Node's output if this results in an unhandled exception.
7659
- throw er; // Unhandled 'error' event
7660
- }
7661
- // At least give some kind of context to the user
7662
- var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
7663
- err.context = er;
7664
- throw err; // Unhandled 'error' event
7665
- }
7666
-
7667
- var handler = events[type];
7668
-
7669
- if (handler === undefined)
7670
- return false;
7671
-
7672
- if (typeof handler === 'function') {
7673
- ReflectApply(handler, this, args);
7674
- } else {
7675
- var len = handler.length;
7676
- var listeners = arrayClone(handler, len);
7677
- for (var i = 0; i < len; ++i)
7678
- ReflectApply(listeners[i], this, args);
7679
- }
7680
-
7681
- return true;
7682
- };
7683
-
7684
- function _addListener(target, type, listener, prepend) {
7685
- var m;
7686
- var events;
7687
- var existing;
7688
-
7689
- checkListener(listener);
7690
-
7691
- events = target._events;
7692
- if (events === undefined) {
7693
- events = target._events = Object.create(null);
7694
- target._eventsCount = 0;
7695
- } else {
7696
- // To avoid recursion in the case that type === "newListener"! Before
7697
- // adding it to the listeners, first emit "newListener".
7698
- if (events.newListener !== undefined) {
7699
- target.emit('newListener', type,
7700
- listener.listener ? listener.listener : listener);
7701
-
7702
- // Re-assign `events` because a newListener handler could have caused the
7703
- // this._events to be assigned to a new object
7704
- events = target._events;
7705
- }
7706
- existing = events[type];
7707
- }
7708
-
7709
- if (existing === undefined) {
7710
- // Optimize the case of one listener. Don't need the extra array object.
7711
- existing = events[type] = listener;
7712
- ++target._eventsCount;
7713
- } else {
7714
- if (typeof existing === 'function') {
7715
- // Adding the second element, need to change to array.
7716
- existing = events[type] =
7717
- prepend ? [listener, existing] : [existing, listener];
7718
- // If we've already got an array, just append.
7719
- } else if (prepend) {
7720
- existing.unshift(listener);
7721
- } else {
7722
- existing.push(listener);
7723
- }
7724
-
7725
- // Check for listener leak
7726
- m = _getMaxListeners(target);
7727
- if (m > 0 && existing.length > m && !existing.warned) {
7728
- existing.warned = true;
7729
- // No error code for this since it is a Warning
7730
- // eslint-disable-next-line no-restricted-syntax
7731
- var w = new Error('Possible EventEmitter memory leak detected. ' +
7732
- existing.length + ' ' + String(type) + ' listeners ' +
7733
- 'added. Use emitter.setMaxListeners() to ' +
7734
- 'increase limit');
7735
- w.name = 'MaxListenersExceededWarning';
7736
- w.emitter = target;
7737
- w.type = type;
7738
- w.count = existing.length;
7739
- ProcessEmitWarning(w);
7740
- }
7741
- }
7742
-
7743
- return target;
7744
- }
7745
-
7746
- EventEmitter.prototype.addListener = function addListener(type, listener) {
7747
- return _addListener(this, type, listener, false);
7748
- };
7749
-
7750
- EventEmitter.prototype.on = EventEmitter.prototype.addListener;
7751
-
7752
- EventEmitter.prototype.prependListener =
7753
- function prependListener(type, listener) {
7754
- return _addListener(this, type, listener, true);
7755
- };
7756
-
7757
- function onceWrapper() {
7758
- if (!this.fired) {
7759
- this.target.removeListener(this.type, this.wrapFn);
7760
- this.fired = true;
7761
- if (arguments.length === 0)
7762
- return this.listener.call(this.target);
7763
- return this.listener.apply(this.target, arguments);
7764
- }
7765
- }
5966
+ function onceWrapper() {
5967
+ if (!this.fired) {
5968
+ this.target.removeListener(this.type, this.wrapFn);
5969
+ this.fired = true;
5970
+ if (arguments.length === 0)
5971
+ return this.listener.call(this.target);
5972
+ return this.listener.apply(this.target, arguments);
5973
+ }
5974
+ }
7766
5975
 
7767
5976
  function _onceWrap(target, type, listener) {
7768
5977
  var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
@@ -14762,19 +12971,7 @@ function simpleWrite(buf) {
14762
12971
 
14763
12972
  function simpleEnd(buf) {
14764
12973
  return buf && buf.length ? this.write(buf) : '';
14765
- }
14766
-
14767
- /***/ }),
14768
-
14769
- /***/ 8555:
14770
- /***/ (function(module) {
14771
-
14772
-
14773
- module.exports = {
14774
- stdout: false,
14775
- stderr: false
14776
- };
14777
-
12974
+ }
14778
12975
 
14779
12976
  /***/ }),
14780
12977
 
@@ -16635,6 +14832,10 @@ __webpack_require__.d(__webpack_exports__, {
16635
14832
  "Z": function() { return /* binding */ Chain; }
16636
14833
  });
16637
14834
 
14835
+ // NAMESPACE OBJECT: ./node_modules/@leofcoin/codec-format-interface/src/index.js
14836
+ var codec_format_interface_src_namespaceObject = {};
14837
+ __webpack_require__.r(codec_format_interface_src_namespaceObject);
14838
+
16638
14839
  // EXTERNAL MODULE: ./node_modules/bn.js/lib/bn.js
16639
14840
  var bn = __webpack_require__(3550);
16640
14841
  var bn_default = /*#__PURE__*/__webpack_require__.n(bn);
@@ -18166,24 +16367,6 @@ function parseEther(ether) {
18166
16367
  return parseUnits(ether, 18);
18167
16368
  }
18168
16369
  //# sourceMappingURL=index.js.map
18169
- // EXTERNAL MODULE: ./node_modules/chalk/source/index.js
18170
- var source = __webpack_require__(4061);
18171
- var source_default = /*#__PURE__*/__webpack_require__.n(source);
18172
- ;// CONCATENATED MODULE: ./src/utils/utils.js
18173
- // import { promisify } from 'util'
18174
- // import { writeFile, readFile } from 'fs'
18175
-
18176
-
18177
- ;
18178
-
18179
- const info = text => console.log(source_default().blueBright(text))
18180
-
18181
- const subinfo = text => console.log(source_default().magentaBright(text))
18182
-
18183
-
18184
- // export const write = promisify(writeFile)
18185
- // export const read = promisify(readFile)
18186
-
18187
16370
  // EXTERNAL MODULE: ./node_modules/vm-browserify/index.js
18188
16371
  var vm_browserify = __webpack_require__(5140);
18189
16372
  // EXTERNAL MODULE: ./node_modules/protons/src/index.js
@@ -18325,17 +16508,17 @@ const base = ALPHABET => {
18325
16508
  ;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/base32/src/base32.js
18326
16509
 
18327
16510
 
18328
- const base32 = 'abcdefghijklmnopqrstuvwxyz234567'
16511
+ const base32_base32 = 'abcdefghijklmnopqrstuvwxyz234567'
18329
16512
  const base32Hex = '0123456789abcdefghijklmnopqrstuv'
18330
16513
 
18331
16514
  const decode = (uint8Array, hex = false) => {
18332
- const decoder = hex ? base_x(base32Hex) : base_x(base32)
16515
+ const decoder = hex ? base_x(base32Hex) : base_x(base32_base32)
18333
16516
  return decoder.decode(uint8Array)
18334
16517
  }
18335
16518
 
18336
16519
  /* harmony default export */ var src_base32 = ({
18337
16520
  encode: (uint8Array, hex = false) => {
18338
- const encoder = hex ? base_x(base32Hex) : base_x(base32)
16521
+ const encoder = hex ? base_x(base32Hex) : base_x(base32_base32)
18339
16522
  return encoder.encode(uint8Array)
18340
16523
  },
18341
16524
  decode,
@@ -18352,12 +16535,12 @@ const decode = (uint8Array, hex = false) => {
18352
16535
  ;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/base58/src/base58.js
18353
16536
 
18354
16537
 
18355
- const base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
16538
+ const base58_base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
18356
16539
 
18357
- const base58_decode = uint8Array => base_x(base58).decode(uint8Array)
16540
+ const base58_decode = uint8Array => base_x(base58_base58).decode(uint8Array)
18358
16541
 
18359
16542
  /* harmony default export */ var src_base58 = ({
18360
- encode: uint8Array => base_x(base58).encode(uint8Array),
16543
+ encode: uint8Array => base_x(base58_base58).encode(uint8Array),
18361
16544
  decode: base58_decode,
18362
16545
  isBase58: uint8Array => {
18363
16546
  try {
@@ -18372,10 +16555,136 @@ const base58_decode = uint8Array => base_x(base58).decode(uint8Array)
18372
16555
  ;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/is-hex/is-hex.js
18373
16556
  /* harmony default export */ var is_hex = (string => /^[A-F0-9]+$/i.test(string));
18374
16557
 
16558
+ ;// CONCATENATED MODULE: ./node_modules/@leofcoin/codec-format-interface/src/basic-interface.js
16559
+ /* provided dependency */ var Buffer = __webpack_require__(8764)["Buffer"];
16560
+
16561
+
16562
+
16563
+
16564
+ class BasicInterface {
16565
+ #handleDecode() {
16566
+ if (!this.decode) throw new Error('bad implementation: needs decode func')
16567
+ this.decode()
16568
+ }
16569
+
16570
+ #handleEncode() {
16571
+ if (!this.encode) throw new Error('bad implementation: needs encode func')
16572
+ this.encode()
16573
+ }
16574
+ isHex(string) {
16575
+ return is_hex(string)
16576
+ }
16577
+ isBase32(string) {
16578
+ return base32.isBase32(string)
16579
+ }
16580
+ isBase58(string) {
16581
+ return base58.isBase32(string)
16582
+ }
16583
+ /**
16584
+ * @param {String} encoded
16585
+ */
16586
+ fromBs32(encoded) {
16587
+ this.encoded = src_base32.decode(encoded)
16588
+ return this.#handleDecode()
16589
+ }
16590
+
16591
+ /**
16592
+ * @param {String} encoded
16593
+ */
16594
+ fromBs58(encoded) {
16595
+ this.encoded = src_base58.decode(encoded)
16596
+ return this.#handleDecode()
16597
+ }
16598
+
16599
+ async toArray() {
16600
+ const array = []
16601
+ for await (const value of this.encoded.values()) {
16602
+ array.push(value)
16603
+ }
16604
+ return array
16605
+ }
16606
+
16607
+ fromString(string) {
16608
+ this.encoded = new Uint8Array(string.split(','))
16609
+ return this.#handleDecode()
16610
+ }
16611
+
16612
+ fromArray(array) {
16613
+ this.encoded = new Uint8Array([...array])
16614
+ return this.#handleDecode()
16615
+ }
16616
+
16617
+ /**
16618
+ * @param {Buffer} encoded
16619
+ */
16620
+ fromEncoded(encoded) {
16621
+ this.encoded = encoded
16622
+ return this.#handleDecode()
16623
+ }
16624
+
16625
+ /**
16626
+ * @param {String} encoded
16627
+ */
16628
+ fromHex(encoded) {
16629
+ this.encoded = Buffer.from(encoded, 'hex')
16630
+ return this.#handleDecode()
16631
+ }
16632
+
16633
+ toString(encoding = 'utf8') {
16634
+ if (!this.encoded) this.#handleEncode()
16635
+ return this.encoded.toString(encoding)
16636
+ }
16637
+
16638
+ /**
16639
+ * @return {String} encoded
16640
+ */
16641
+ toHex() {
16642
+ return this.toString('hex')
16643
+ }
16644
+
16645
+ /**
16646
+ * @return {String} encoded
16647
+ */
16648
+ toBs32() {
16649
+ if (!this.encoded) this.#handleEncode()
16650
+ return src_base32.encode(this.encoded)
16651
+ }
16652
+
16653
+ /**
16654
+ * @return {String} encoded
16655
+ */
16656
+ toBs58() {
16657
+ if (!this.encoded) this.#handleEncode()
16658
+ return src_base58.encode(this.encoded)
16659
+ }
16660
+
16661
+ /**
16662
+ * @param {Object} data
16663
+ */
16664
+ create(data) {
16665
+ const decoded = {}
16666
+ if (this.keys?.length > 0) {
16667
+ for (const key of this.keys) {
16668
+ Object.defineProperties(decoded, {
16669
+ [key]: {
16670
+ enumerable: true,
16671
+ configurable: true,
16672
+ set: (val) => value = data[key],
16673
+ get: () => data[key]
16674
+ }
16675
+ })
16676
+ }
16677
+
16678
+ this.decoded = decoded
16679
+ this.encode()
16680
+ }
16681
+ }
16682
+ }
16683
+
18375
16684
  // EXTERNAL MODULE: ./node_modules/varint/index.js
18376
16685
  var varint = __webpack_require__(4676);
18377
16686
  var varint_default = /*#__PURE__*/__webpack_require__.n(varint);
18378
- ;// CONCATENATED MODULE: ./node_modules/@leofcoin/peernet/src/codec/codecs.js
16687
+ ;// CONCATENATED MODULE: ./node_modules/@leofcoin/codec-format-interface/src/codecs.js
18379
16688
  /* harmony default export */ var codecs = ({
18380
16689
  // just a hash
18381
16690
  'disco-hash': {
@@ -18456,19 +16765,17 @@ var varint_default = /*#__PURE__*/__webpack_require__.n(varint);
18456
16765
  },
18457
16766
  });
18458
16767
 
18459
- ;// CONCATENATED MODULE: ./node_modules/@leofcoin/peernet/src/codec/codec.js
18460
- /* provided dependency */ var Buffer = __webpack_require__(8764)["Buffer"];
16768
+ ;// CONCATENATED MODULE: ./node_modules/@leofcoin/codec-format-interface/src/codec.js
18461
16769
 
18462
16770
 
18463
16771
 
18464
16772
 
18465
-
18466
-
18467
- class PeernetCodec {
16773
+ class PeernetCodec extends BasicInterface {
18468
16774
  get codecs() {
18469
16775
  return {...globalThis.peernet.codecs, ...codecs}
18470
16776
  }
18471
16777
  constructor(buffer) {
16778
+ super()
18472
16779
  if (buffer) {
18473
16780
  if (buffer instanceof Uint8Array) {
18474
16781
  const codec = varint_default().decode(buffer);
@@ -18493,9 +16800,9 @@ class PeernetCodec {
18493
16800
  }
18494
16801
  if (typeof buffer === 'string') {
18495
16802
  if (this.codecs[buffer]) this.fromName(buffer)
18496
- else if (is_hex(buffer)) this.fromHex(buffer)
18497
- else if (src_base32.isBase32(buffer)) this.fromBs32(buffer)
18498
- else if (src_base58.isBase58(buffer)) this.fromBs58(buffer)
16803
+ else if (this.isHex(buffer)) this.fromHex(buffer)
16804
+ else if (this.isBase32(buffer)) this.fromBs32(buffer)
16805
+ else if (this.isBase58(buffer)) this.fromBs58(buffer)
18499
16806
  else throw new Error(`unsupported string ${buffer}`)
18500
16807
  }
18501
16808
  if (!isNaN(buffer)) if (this.codecs[this.getCodecName(buffer)]) this.fromCodec(buffer)
@@ -18510,21 +16817,6 @@ class PeernetCodec {
18510
16817
  this.decode(encoded)
18511
16818
  }
18512
16819
 
18513
- fromHex(hex) {
18514
- this.encoded = Buffer.from(hex, 'hex')
18515
- this.decode()
18516
- }
18517
-
18518
- fromBs32(input) {
18519
- this.encoded = src_base32.decode(input)
18520
- this.decode()
18521
- }
18522
-
18523
- fromBs58(input) {
18524
- this.encoded = src_base58.decode(input)
18525
- this.decode()
18526
- }
18527
-
18528
16820
  getCodec(name) {
18529
16821
  return this.codecs[name].codec
18530
16822
  }
@@ -18557,20 +16849,6 @@ class PeernetCodec {
18557
16849
  this.codecBuffer = varint_default().encode(codec)
18558
16850
  }
18559
16851
 
18560
- toBs32() {
18561
- this.encode()
18562
- return src_base32.encode(this.encoded)
18563
- }
18564
-
18565
- toBs58() {
18566
- this.encode()
18567
- return src_base58.encode(this.encoded)
18568
- }
18569
-
18570
- toHex() {
18571
- return this.encoded.toString('hex')
18572
- }
18573
-
18574
16852
  decode() {
18575
16853
  const codec = varint_default().decode(this.encoded);
18576
16854
  this.fromCodec(codec)
@@ -18586,17 +16864,16 @@ class PeernetCodec {
18586
16864
  // EXTERNAL MODULE: ./node_modules/keccak/js.js
18587
16865
  var js = __webpack_require__(5811);
18588
16866
  var js_default = /*#__PURE__*/__webpack_require__.n(js);
18589
- ;// CONCATENATED MODULE: ./node_modules/@leofcoin/peernet/src/hash/hash.js
18590
- /* provided dependency */ var hash_Buffer = __webpack_require__(8764)["Buffer"];
16867
+ ;// CONCATENATED MODULE: ./node_modules/@leofcoin/codec-format-interface/src/codec-hash.js
16868
+ /* provided dependency */ var codec_hash_Buffer = __webpack_require__(8764)["Buffer"];
18591
16869
 
18592
16870
 
18593
16871
 
18594
16872
 
18595
16873
 
18596
-
18597
-
18598
- class PeernetHash {
16874
+ class CodecHash extends BasicInterface {
18599
16875
  constructor(buffer, options = {}) {
16876
+ super()
18600
16877
  if (options.name) this.name = options.name
18601
16878
  else this.name = 'disco-hash'
18602
16879
  if (options.codecs) this.codecs = options.codecs
@@ -18614,9 +16891,9 @@ class PeernetHash {
18614
16891
  }
18615
16892
 
18616
16893
  if (typeof buffer === 'string') {
18617
- if (is_hex(buffer)) this.fromHex(buffer)
18618
- if (src_base32.isBase32(buffer)) this.fromBs32(buffer)
18619
- else if (src_base58.isBase58(buffer)) this.fromBs58(buffer)
16894
+ if (this.isHex(buffer)) this.fromHex(buffer)
16895
+ if (this.isBase32(buffer)) this.fromBs32(buffer)
16896
+ else if (this.isBase58(buffer)) this.fromBs58(buffer)
18620
16897
  else throw new Error(`unsupported string ${buffer}`)
18621
16898
  } else if (typeof buffer === 'object') this.fromJSON(buffer)
18622
16899
  }
@@ -18636,39 +16913,15 @@ class PeernetHash {
18636
16913
  }
18637
16914
 
18638
16915
  get buffer() {
18639
- return this.hash
18640
- }
18641
-
18642
- toHex() {
18643
- return this.hash.toString('hex')
16916
+ return this.encoded
18644
16917
  }
18645
16918
 
18646
- fromHex(hex) {
18647
- return this.decode(hash_Buffer.from(hex, 'hex'))
16919
+ get hash() {
16920
+ return this.encoded
18648
16921
  }
18649
16922
 
18650
16923
  fromJSON(json) {
18651
- return this.encode(hash_Buffer.from(JSON.stringify(json)))
18652
- }
18653
-
18654
- toBs32() {
18655
- return src_base32.encode(this.hash)
18656
- }
18657
-
18658
- fromBs32(bs) {
18659
- return this.decode(src_base32.decode(bs))
18660
- }
18661
-
18662
- toBs58() {
18663
- return src_base58.encode(this.hash)
18664
- }
18665
-
18666
- fromBs58(bs) {
18667
- return this.decode(src_base58.decode(bs))
18668
- }
18669
-
18670
- toString(encoding = 'utf8') {
18671
- return this.hash.toString(encoding)
16924
+ return this.encode(codec_hash_Buffer.from(JSON.stringify(json)))
18672
16925
  }
18673
16926
 
18674
16927
  encode(buffer, name) {
@@ -18690,13 +16943,13 @@ class PeernetHash {
18690
16943
  uint8Array.set(this.prefix)
18691
16944
  uint8Array.set(this.digest, this.prefix.length)
18692
16945
 
18693
- this.hash = uint8Array
16946
+ this.encoded = uint8Array
18694
16947
 
18695
- return this.hash
16948
+ return this.encoded
18696
16949
  }
18697
16950
 
18698
16951
  validate(buffer) {
18699
- if (hash_Buffer.isBuffer(buffer)) {
16952
+ if (codec_hash_Buffer.isBuffer(buffer)) {
18700
16953
  const codec = varint_default().decode(buffer);
18701
16954
  if (this.codecs[codec]) {
18702
16955
  this.decode(buffer)
@@ -18705,14 +16958,14 @@ class PeernetHash {
18705
16958
  }
18706
16959
  }
18707
16960
  if (typeof buffer === 'string') {
18708
- if (is_hex(buffer)) this.fromHex(buffer)
18709
- if (src_base32.test(buffer)) this.fromBs32(buffer)
16961
+ if (this.isHex(buffer)) this.fromHex(buffer)
16962
+ if (this.isBase32(buffer)) this.fromBs32(buffer)
18710
16963
  }
18711
16964
  if (typeof buffer === 'object') this.fromJSON(buffer)
18712
16965
  }
18713
16966
 
18714
16967
  decode(buffer) {
18715
- this.hash = buffer
16968
+ this.encoded = buffer
18716
16969
  const codec = varint_default().decode(buffer);
18717
16970
 
18718
16971
  this.discoCodec = new PeernetCodec(codec, this.codecs)
@@ -18721,7 +16974,7 @@ class PeernetHash {
18721
16974
  this.size = varint_default().decode(buffer);
18722
16975
  this.digest = buffer.slice((varint_default()).decode.bytes);
18723
16976
  if (this.digest.length !== this.size) {
18724
- throw new Error(`hash length inconsistent: 0x${this.hash.toString('hex')}`)
16977
+ throw new Error(`hash length inconsistent: 0x${this.encoded.toString('hex')}`)
18725
16978
  }
18726
16979
 
18727
16980
  // const discoCodec = new Codec(codec, this.codecs)
@@ -18741,21 +16994,19 @@ class PeernetHash {
18741
16994
  }
18742
16995
  }
18743
16996
 
18744
- ;// CONCATENATED MODULE: ./node_modules/@leofcoin/peernet/src/codec/codec-format-interface.js
18745
- /* provided dependency */ var codec_format_interface_Buffer = __webpack_require__(8764)["Buffer"];
16997
+ ;// CONCATENATED MODULE: ./node_modules/@leofcoin/codec-format-interface/src/codec-format-interface.js
18746
16998
 
18747
16999
 
18748
17000
 
18749
17001
 
18750
-
18751
-
18752
- class FormatInterface {
17002
+ class FormatInterface extends BasicInterface {
18753
17003
  /**
18754
17004
  * @param {Buffer|String|Object} buffer - data - The data needed to create the desired message
18755
17005
  * @param {Object} proto - {encode, decode}
18756
17006
  * @param {Object} options - {hashFormat, name}
18757
17007
  */
18758
17008
  constructor(buffer, proto, options = {}) {
17009
+ super()
18759
17010
  this.protoEncode = proto.encode
18760
17011
  this.protoDecode = proto.decode
18761
17012
  this.hashFormat = options.hashFormat || 'bs32'
@@ -18764,9 +17015,9 @@ class FormatInterface {
18764
17015
  else if (buffer instanceof ArrayBuffer) this.fromArrayBuffer(buffer)
18765
17016
  else if (buffer.name === options.name) return buffer
18766
17017
  else if (buffer instanceof String) {
18767
- if (is_hex(buffer)) this.fromHex(buffer)
18768
- else if (src_base32.isBase32(buffer)) this.fromBs32(buffer)
18769
- else if (src_base58.isBase58(buffer)) this.fromBs58(buffer)
17018
+ if (this.isHex(buffer)) this.fromHex(buffer)
17019
+ else if (this.isBase32(buffer)) this.fromBs32(buffer)
17020
+ else if (this.isBase58(buffer)) this.fromBs58(buffer)
18770
17021
  else throw new Error(`unsupported string ${buffer}`)
18771
17022
  } else {
18772
17023
  this.create(buffer)
@@ -18777,7 +17028,7 @@ class FormatInterface {
18777
17028
  * @return {PeernetHash}
18778
17029
  */
18779
17030
  get peernetHash() {
18780
- return new PeernetHash(this.decoded, {name: this.name})
17031
+ return new CodecHash(this.decoded, {name: this.name})
18781
17032
  }
18782
17033
 
18783
17034
  /**
@@ -18836,114 +17087,23 @@ class FormatInterface {
18836
17087
  )
18837
17088
  else this.decode()
18838
17089
  }
17090
+ }
17091
+
17092
+ ;// CONCATENATED MODULE: ./node_modules/@leofcoin/codec-format-interface/src/index.js
18839
17093
 
18840
- toString() {
18841
- return this.encoded.toString()
18842
- }
18843
-
18844
- async toArray() {
18845
- const array = []
18846
- for await (const value of this.encoded.values()) {
18847
- array.push(value)
18848
- }
18849
- return array
18850
- }
18851
-
18852
- fromString(string) {
18853
- this.encoded = new Uint8Array(string.split(','))
18854
- this.decode()
18855
- }
18856
-
18857
- fromArray(array) {
18858
- this.encoded = new Uint8Array([...array])
18859
- this.decode()
18860
- }
18861
-
18862
- /**
18863
- * @param {Buffer} encoded
18864
- */
18865
- fromEncoded(encoded) {
18866
- this.encoded = encoded
18867
- this.decode()
18868
- }
18869
-
18870
- /**
18871
- * @param {String} encoded
18872
- */
18873
- fromHex(encoded) {
18874
- this.encoded = codec_format_interface_Buffer.from(encoded, 'hex')
18875
- this.decode()
18876
- }
18877
-
18878
- /**
18879
- * @param {String} encoded
18880
- */
18881
- fromBs32(encoded) {
18882
- this.encoded = src_base32.decode(encoded)
18883
- this.decode()
18884
- }
18885
-
18886
- /**
18887
- * @param {String} encoded
18888
- */
18889
- fromBs58(encoded) {
18890
- this.encoded = src_base58.decode(encoded)
18891
- this.decode()
18892
- }
18893
17094
 
18894
- /**
18895
- * @return {String} encoded
18896
- */
18897
- toHex() {
18898
- if (!this.encoded) this.encode()
18899
- return this.encoded.toString('hex')
18900
- }
18901
17095
 
18902
- /**
18903
- * @return {String} encoded
18904
- */
18905
- toBs32() {
18906
- if (!this.encoded) this.encode()
18907
- return src_base32.encode(this.encoded)
18908
- }
18909
17096
 
18910
- /**
18911
- * @return {String} encoded
18912
- */
18913
- toBs58() {
18914
- if (!this.encoded) this.encode()
18915
- return src_base58.encode(this.encoded)
18916
- }
18917
17097
 
18918
- /**
18919
- * @param {Object} data
18920
- */
18921
- create(data) {
18922
- const decoded = {}
18923
- if (this.keys?.length > 0) {
18924
- for (const key of this.keys) {
18925
- Object.defineProperties(decoded, {
18926
- [key]: {
18927
- enumerable: true,
18928
- configurable: true,
18929
- set: (val) => value = data[key],
18930
- get: () => data[key]
18931
- }
18932
- })
18933
- }
18934
17098
 
18935
- this.decoded = decoded
18936
- this.encode()
18937
- }
18938
- }
18939
- }
17099
+ /* harmony default export */ var codec_format_interface_src = ({ codecs: codecs, Codec: PeernetCodec, CodecHash: CodecHash, FormatInterface: FormatInterface, BasicInterface: BasicInterface });
18940
17100
 
18941
17101
  ;// CONCATENATED MODULE: ./src/messages/contract.js
18942
17102
 
18943
17103
 
18944
17104
 
18945
17105
 
18946
- class ContractMessage extends FormatInterface {
17106
+ class ContractMessage extends codec_format_interface_src_namespaceObject.FormatInterface {
18947
17107
  get keys() {
18948
17108
  return ['creator', 'contract', 'constructorParameters']
18949
17109
  }
@@ -18971,7 +17131,7 @@ message TransactionMessage {
18971
17131
 
18972
17132
 
18973
17133
 
18974
- class TransactionMessage extends FormatInterface {
17134
+ class TransactionMessage extends codec_format_interface_src_namespaceObject.FormatInterface {
18975
17135
  get keys() {
18976
17136
  return ['timestamp', 'from', 'to', 'nonce', 'method', 'params']
18977
17137
  }
@@ -19015,7 +17175,7 @@ message BlockMessage {
19015
17175
 
19016
17176
 
19017
17177
 
19018
- class BlockMessage extends FormatInterface {
17178
+ class BlockMessage extends codec_format_interface_src_namespaceObject.FormatInterface {
19019
17179
  get keys() {
19020
17180
  return ['index', 'previousHash', 'timestamp', 'reward', 'fees', 'transactions', 'validators']
19021
17181
  }
@@ -19040,7 +17200,7 @@ message BWMessage {
19040
17200
 
19041
17201
 
19042
17202
 
19043
- class BWMessage extends FormatInterface {
17203
+ class BWMessage extends codec_format_interface_src_namespaceObject.FormatInterface {
19044
17204
  get keys() {
19045
17205
  return ['up', 'down']
19046
17206
  }
@@ -19063,7 +17223,7 @@ message BWRequestMessage {
19063
17223
 
19064
17224
 
19065
17225
 
19066
- class BWRequestMessage extends FormatInterface {
17226
+ class BWRequestMessage extends codec_format_interface_src_namespaceObject.FormatInterface {
19067
17227
  get keys() {
19068
17228
  return []
19069
17229
  }
@@ -19152,7 +17312,6 @@ const calculateReward = (validators, fees) => {
19152
17312
 
19153
17313
 
19154
17314
 
19155
-
19156
17315
  // import State from './state'
19157
17316
 
19158
17317
  class Machine {
@@ -19212,8 +17371,8 @@ console.log(e);
19212
17371
  globalThis.msg = this.#createMessage(contractMessage.decoded.creator)
19213
17372
  // globalThis.msg = {sender: contractMessage.decoded.creator}
19214
17373
  this.#contracts[contractMessage.hash] = new Contract(...params)
19215
- info(`loaded contract: ${contractMessage.hash}`);
19216
- subinfo(`size: ${Math.round((contractMessage.encoded.length / 1024) * 100) / 100} kb`);
17374
+ debug(`loaded contract: ${contractMessage.hash}`);
17375
+ debug(`size: ${Math.round((contractMessage.encoded.length / 1024) * 100) / 100} kb`);
19217
17376
  } catch (e) {
19218
17377
  console.log(e);
19219
17378
  console.warn(`removing contract ${contractMessage.hash}`);
@@ -19436,7 +17595,7 @@ class Chain {
19436
17595
  console.log(this.#blocks);
19437
17596
  let blocksSynced = localIndex > 0 ? localIndex - index : index
19438
17597
  blocksSynced += 1
19439
- info(`synced ${blocksSynced} ${blocksSynced > 1 ? 'blocks' : 'block'}`)
17598
+ debug(`synced ${blocksSynced} ${blocksSynced > 1 ? 'blocks' : 'block'}`)
19440
17599
 
19441
17600
  const end = this.#blocks.length
19442
17601
  const start = (this.#blocks.length) - blocksSynced
@@ -19550,7 +17709,7 @@ class Chain {
19550
17709
  this.#lastBlock = {hash: blockMessage.hash, ...blockMessage.decoded}
19551
17710
  await blockStore.put(blockMessage.hash, blockMessage.encoded)
19552
17711
  await chainStore.put('lastBlock', new TextEncoder().encode(blockMessage.hash))
19553
- info(`added block: ${blockMessage.hash}`)
17712
+ debug(`added block: ${blockMessage.hash}`)
19554
17713
  let promises = []
19555
17714
  let contracts = []
19556
17715
  for (let transaction of blockMessage.decoded.transactions) {
@@ -19563,11 +17722,12 @@ class Chain {
19563
17722
  promises = await Promise.allSettled(promises)
19564
17723
 
19565
17724
  // todo finish state
19566
- for (const contract of contracts) {
19567
- const state = await this.#machine.get(contract, 'state')
19568
- // await stateStore.put(contract, state)
19569
- console.log(state);
19570
- }
17725
+ // for (const contract of contracts) {
17726
+ // const state = await this.#machine.get(contract, 'state')
17727
+ // // await stateStore.put(contract, state)
17728
+ // console.log(state);
17729
+ // }
17730
+ pubsub.publish('block-processed', blockMessage.decoded)
19571
17731
  } catch (e) {
19572
17732
  console.log(e);
19573
17733
  }