js-build-tools 2.4.0 → 3.0.1

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.
Files changed (204) hide show
  1. package/README.md +334 -205
  2. package/dist/build.js +59 -48
  3. package/dist/build.min.js +1 -1
  4. package/dist/bundle.js +12 -13
  5. package/dist/bundle.min.js +1 -1
  6. package/dist/bundleLint.js +17 -18
  7. package/dist/bundleLint.min.js +1 -1
  8. package/dist/bundleMinify.js +8 -9
  9. package/dist/bundleMinify.min.js +1 -1
  10. package/dist/copyFonts.js +12 -0
  11. package/dist/copyFonts.min.js +1 -0
  12. package/dist/default.js +1 -1
  13. package/dist/default.min.js +1 -1
  14. package/dist/dist.js +7 -8
  15. package/dist/distLint.js +17 -18
  16. package/dist/distLint.min.js +1 -1
  17. package/dist/distMinify.js +8 -9
  18. package/dist/distMinify.min.js +1 -1
  19. package/dist/images.js +11 -0
  20. package/dist/images.min.js +1 -0
  21. package/dist/partials/addToReadme.js +13 -14
  22. package/dist/partials/beginWatcher.js +9 -10
  23. package/dist/partials/clean.js +10 -11
  24. package/dist/partials/copyFor.js +16 -0
  25. package/dist/partials/distFor.js +16 -17
  26. package/dist/partials/distForSrc.js +9 -10
  27. package/dist/partials/distSeries.js +19 -20
  28. package/dist/partials/imagesFor.js +34 -0
  29. package/dist/partials/minifyFor.js +15 -16
  30. package/dist/partials/readmeTemplate.js +11 -12
  31. package/dist/partials/removeDirectory.js +11 -12
  32. package/dist/partials/runOnChange.js +27 -27
  33. package/dist/partials/sassFor.js +20 -21
  34. package/dist/partials/tsFor.js +20 -21
  35. package/dist/partials.js +35 -31
  36. package/dist/partials.min.js +1 -1
  37. package/dist/test-helpers/setUp.js +52 -60
  38. package/dist/testFull.js +17 -18
  39. package/dist/testFull.min.js +1 -1
  40. package/dist/testHelpers.js +10 -28
  41. package/dist/testHelpers.min.js +1 -1
  42. package/dist/testQuick.js +19 -20
  43. package/dist/testQuick.min.js +1 -1
  44. package/dist/typeScript.js +7 -8
  45. package/dist/utilities/dotGet.js +50 -0
  46. package/dist/utilities/dotNotate.js +77 -0
  47. package/dist/utilities/dotSet.js +44 -0
  48. package/dist/utilities/isObject.js +10 -0
  49. package/dist/utilities/strAfter.js +14 -0
  50. package/dist/utilities/strBefore.js +14 -0
  51. package/dist/watchFull.js +10 -11
  52. package/dist/watchTest.js +13 -14
  53. package/dist/watchTest.min.js +1 -1
  54. package/functions/build.js +15 -5
  55. package/functions/build.test.js +278 -42
  56. package/functions/bundle.js +3 -4
  57. package/functions/bundle.test.js +6 -6
  58. package/functions/bundleLint.js +2 -3
  59. package/functions/bundleLint.test.js +5 -5
  60. package/functions/bundleMinify.js +1 -2
  61. package/functions/bundleMinify.test.js +1 -1
  62. package/functions/copyFonts.js +11 -0
  63. package/functions/copyFonts.test.js +31 -0
  64. package/functions/default.js +1 -1
  65. package/functions/default.test.js +2 -2
  66. package/functions/dist.js +0 -1
  67. package/functions/dist.test.js +1 -1
  68. package/functions/distLint.js +2 -3
  69. package/functions/distLint.test.js +3 -3
  70. package/functions/distMinify.js +1 -2
  71. package/functions/distMinify.test.js +1 -1
  72. package/functions/images.js +10 -0
  73. package/functions/images.test.js +138 -0
  74. package/functions/partials/addToReadme.js +2 -3
  75. package/functions/partials/addToReadme.test.js +2 -2
  76. package/functions/partials/beginWatcher.js +1 -2
  77. package/functions/partials/beginWatcher.test.js +1 -1
  78. package/functions/partials/clean.js +0 -1
  79. package/functions/partials/copyFor.js +13 -0
  80. package/functions/partials/copyFor.test.js +34 -0
  81. package/functions/partials/distFor.js +1 -2
  82. package/functions/partials/distFor.test.js +4 -4
  83. package/functions/partials/distForSrc.js +3 -4
  84. package/functions/partials/distForSrc.test.js +6 -6
  85. package/functions/partials/distSeries.js +2 -3
  86. package/functions/partials/distSeries.test.js +5 -5
  87. package/functions/partials/imagesFor.js +33 -0
  88. package/functions/partials/imagesFor.test.js +143 -0
  89. package/functions/partials/minifyFor.js +0 -1
  90. package/functions/partials/minifyFor.test.js +1 -1
  91. package/functions/partials/readmeTemplate.js +3 -4
  92. package/functions/partials/readmeTemplate.test.js +2 -2
  93. package/functions/partials/removeDirectory.js +0 -1
  94. package/functions/partials/runOnChange.js +5 -6
  95. package/functions/partials/runOnChange.test.js +9 -9
  96. package/functions/partials/sassFor.js +1 -2
  97. package/functions/partials/sassFor.test.js +3 -3
  98. package/functions/partials/tsFor.js +3 -4
  99. package/functions/partials/tsFor.test.js +2 -2
  100. package/functions/partials.js +5 -1
  101. package/functions/partials.test.js +1 -1
  102. package/functions/sass.test.js +2 -2
  103. package/functions/test-helpers/setUp.js +24 -32
  104. package/functions/testFull.js +2 -3
  105. package/functions/testFull.test.js +1 -1
  106. package/functions/testHelpers.js +3 -20
  107. package/functions/testHelpers.test.js +1 -1
  108. package/functions/testQuick.js +1 -2
  109. package/functions/testQuick.test.js +1 -1
  110. package/functions/typeScript.js +0 -1
  111. package/functions/typeScript.test.js +0 -2
  112. package/functions/utilities/dotGet.js +47 -0
  113. package/functions/utilities/dotNotate.js +68 -0
  114. package/functions/utilities/dotSet.js +41 -0
  115. package/functions/utilities/isObject.js +9 -0
  116. package/functions/utilities/strAfter.js +13 -0
  117. package/functions/utilities/strBefore.js +13 -0
  118. package/functions/watchFull.js +0 -1
  119. package/functions/watchFull.test.js +1 -1
  120. package/functions/watchTest.js +1 -2
  121. package/functions/watchTest.test.js +1 -1
  122. package/gulp.config.js +153 -79
  123. package/gulpfile.base.js +5 -1
  124. package/jsdoc.base.js +1 -1
  125. package/package.json +13 -9
  126. package/vendor/array-union/index.js +31 -0
  127. package/vendor/easy-transform-stream/index.js +54 -0
  128. package/vendor/globby/gitignore.js +96 -0
  129. package/vendor/globby/index.js +191 -0
  130. package/vendor/globby/node_modules/slash/index.js +16 -0
  131. package/vendor/globby/stream-utils.js +58 -0
  132. package/vendor/globby/to-path.js +20 -0
  133. package/vendor/gulp-imagemin/index.js +128 -0
  134. package/vendor/gulp-imagemin/node_modules/chalk/source/index.js +265 -0
  135. package/vendor/gulp-imagemin/node_modules/chalk/source/utilities.js +36 -0
  136. package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/ansi-styles/index.js +217 -0
  137. package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/supports-color/index.js +154 -0
  138. package/vendor/gulp-plugin-extras/index.js +42 -0
  139. package/vendor/gulp-plugin-extras/node_modules/chalk/source/index.js +265 -0
  140. package/vendor/gulp-plugin-extras/node_modules/chalk/source/utilities.js +36 -0
  141. package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/ansi-styles/index.js +217 -0
  142. package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/supports-color/index.js +154 -0
  143. package/vendor/gulp-plugin-extras/plugin-error.js +145 -0
  144. package/vendor/ignore/index.js +468 -0
  145. package/vendor/imagemin/index.js +90 -0
  146. package/vendor/imagemin-gifsicle/index.js +33 -0
  147. package/vendor/imagemin-mozjpeg/index.js +100 -0
  148. package/vendor/imagemin-mozjpeg/node_modules/execa/index.js +260 -0
  149. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/command.js +47 -0
  150. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/error.js +102 -0
  151. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/kill.js +123 -0
  152. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/promise.js +47 -0
  153. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stdio.js +50 -0
  154. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stream.js +124 -0
  155. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/core.js +238 -0
  156. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/main.js +89 -0
  157. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/realtime.js +24 -0
  158. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/signals.js +44 -0
  159. package/vendor/imagemin-mozjpeg/node_modules/is-stream/index.js +25 -0
  160. package/vendor/imagemin-mozjpeg/node_modules/mimic-fn/index.js +70 -0
  161. package/vendor/imagemin-mozjpeg/node_modules/npm-run-path/index.js +52 -0
  162. package/vendor/imagemin-mozjpeg/node_modules/onetime/index.js +43 -0
  163. package/vendor/imagemin-mozjpeg/node_modules/path-key/index.js +20 -0
  164. package/vendor/imagemin-mozjpeg/node_modules/strip-final-newline/index.js +17 -0
  165. package/vendor/imagemin-optipng/index.js +44 -0
  166. package/vendor/imagemin-svgo/index.js +27 -0
  167. package/vendor/is-jpg/index.js +12 -0
  168. package/vendor/junk/index.js +49 -0
  169. package/vendor/mozjpeg/index.js +9 -0
  170. package/vendor/mozjpeg/lib/index.js +18 -0
  171. package/vendor/mozjpeg/package.json +49 -0
  172. package/vendor/mozjpeg/vendor/cjpeg +0 -0
  173. package/vendor/mozjpeg/vendor/source/mozjpeg.tar.gz +0 -0
  174. package/vendor/p-pipe/index.js +22 -0
  175. package/vendor/plur/index.js +32 -0
  176. package/vendor/pretty-bytes/index.js +71 -0
  177. package/vendor/slash/index.js +12 -0
  178. package/dist/test-helpers/circularObject.js +0 -50
  179. package/dist/test-helpers/countMatches.js +0 -12
  180. package/dist/test-helpers/deepReferenceObject.js +0 -20
  181. package/dist/test-helpers/domItem.js +0 -33
  182. package/dist/test-helpers/jsonDom.js +0 -20
  183. package/dist/test-helpers/linkedList.js +0 -23
  184. package/dist/test-helpers/logObject.js +0 -21
  185. package/dist/test-helpers/multiReferenceObject.js +0 -20
  186. package/dist/test-helpers/nodeTree.js +0 -28
  187. package/functions/test-helpers/circularObject.js +0 -28
  188. package/functions/test-helpers/circularObject.test.js +0 -14
  189. package/functions/test-helpers/countMatches.js +0 -11
  190. package/functions/test-helpers/countMatches.test.js +0 -9
  191. package/functions/test-helpers/deepReferenceObject.js +0 -25
  192. package/functions/test-helpers/deepReferenceObject.test.js +0 -7
  193. package/functions/test-helpers/domItem.js +0 -31
  194. package/functions/test-helpers/domItem.test.js +0 -12
  195. package/functions/test-helpers/jsonDom.js +0 -16
  196. package/functions/test-helpers/jsonDom.test.js +0 -12
  197. package/functions/test-helpers/linkedList.js +0 -10
  198. package/functions/test-helpers/linkedList.test.js +0 -22
  199. package/functions/test-helpers/logObject.js +0 -18
  200. package/functions/test-helpers/logObject.test.js +0 -20
  201. package/functions/test-helpers/multiReferenceObject.js +0 -25
  202. package/functions/test-helpers/multiReferenceObject.test.js +0 -14
  203. package/functions/test-helpers/nodeTree.js +0 -11
  204. package/functions/test-helpers/nodeTree.test.js +0 -18
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.gulpPlugin = gulpPlugin;
7
+ require("core-js/modules/web.dom-collections.iterator.js");
8
+ var _index = _interopRequireDefault(require("../easy-transform-stream/index.js"));
9
+ var _pluginError = _interopRequireDefault(require("./plugin-error.js"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function gulpPlugin(name, onFile) {
12
+ let {
13
+ onFinish,
14
+ supportsDirectories
15
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
16
+ return (0, _index.default)({
17
+ objectMode: true
18
+ }, async file => {
19
+ if (file.isNull() && !(supportsDirectories && file.isDirectory())) {
20
+ return file;
21
+ }
22
+ if (file.isStream()) {
23
+ throw new _pluginError.default(name, 'Streaming not supported');
24
+ }
25
+ try {
26
+ return await onFile(file);
27
+ } catch (error) {
28
+ throw new _pluginError.default(name, error, {
29
+ fileName: file.path,
30
+ showStack: true
31
+ });
32
+ }
33
+ }, onFinish && async function* (stream) {
34
+ try {
35
+ yield* onFinish(stream);
36
+ } catch (error) {
37
+ throw new _pluginError.default(name, error, {
38
+ showStack: true
39
+ });
40
+ }
41
+ });
42
+ }
@@ -0,0 +1,265 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/esnext.weak-map.delete-all.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.Chalk = void 0;
8
+ Object.defineProperty(exports, "backgroundColorNames", {
9
+ enumerable: true,
10
+ get: function () {
11
+ return _index.backgroundColorNames;
12
+ }
13
+ });
14
+ Object.defineProperty(exports, "backgroundColors", {
15
+ enumerable: true,
16
+ get: function () {
17
+ return _index.backgroundColorNames;
18
+ }
19
+ });
20
+ exports.chalkStderr = void 0;
21
+ Object.defineProperty(exports, "colorNames", {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _index.colorNames;
25
+ }
26
+ });
27
+ Object.defineProperty(exports, "colors", {
28
+ enumerable: true,
29
+ get: function () {
30
+ return _index.colorNames;
31
+ }
32
+ });
33
+ exports.default = void 0;
34
+ Object.defineProperty(exports, "foregroundColorNames", {
35
+ enumerable: true,
36
+ get: function () {
37
+ return _index.foregroundColorNames;
38
+ }
39
+ });
40
+ Object.defineProperty(exports, "foregroundColors", {
41
+ enumerable: true,
42
+ get: function () {
43
+ return _index.foregroundColorNames;
44
+ }
45
+ });
46
+ Object.defineProperty(exports, "modifierNames", {
47
+ enumerable: true,
48
+ get: function () {
49
+ return _index.modifierNames;
50
+ }
51
+ });
52
+ Object.defineProperty(exports, "modifiers", {
53
+ enumerable: true,
54
+ get: function () {
55
+ return _index.modifierNames;
56
+ }
57
+ });
58
+ exports.supportsColorStderr = exports.supportsColor = void 0;
59
+ require("core-js/modules/web.dom-collections.iterator.js");
60
+ var _index = _interopRequireWildcard(require("./vendor/ansi-styles/index.js"));
61
+ var _index2 = _interopRequireDefault(require("./vendor/supports-color/index.js"));
62
+ var _utilities = require("./utilities.js");
63
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
64
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
65
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
66
+ const {
67
+ stdout: stdoutColor,
68
+ stderr: stderrColor
69
+ } = _index2.default;
70
+ exports.supportsColorStderr = stderrColor;
71
+ exports.supportsColor = stdoutColor;
72
+ const GENERATOR = Symbol('GENERATOR');
73
+ const STYLER = Symbol('STYLER');
74
+ const IS_EMPTY = Symbol('IS_EMPTY');
75
+
76
+ // `supportsColor.level` → `ansiStyles.color[name]` mapping
77
+ const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
78
+ const styles = Object.create(null);
79
+ const applyOptions = function (object) {
80
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
81
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
82
+ throw new Error('The `level` option should be an integer from 0 to 3');
83
+ }
84
+
85
+ // Detect level if not set manually
86
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
87
+ object.level = options.level === undefined ? colorLevel : options.level;
88
+ };
89
+ class Chalk {
90
+ constructor(options) {
91
+ // eslint-disable-next-line no-constructor-return
92
+ return chalkFactory(options);
93
+ }
94
+ }
95
+ exports.Chalk = Chalk;
96
+ const chalkFactory = options => {
97
+ const chalk = function () {
98
+ for (var _len = arguments.length, strings = new Array(_len), _key = 0; _key < _len; _key++) {
99
+ strings[_key] = arguments[_key];
100
+ }
101
+ return strings.join(' ');
102
+ };
103
+ applyOptions(chalk, options);
104
+ Object.setPrototypeOf(chalk, createChalk.prototype);
105
+ return chalk;
106
+ };
107
+ function createChalk(options) {
108
+ return chalkFactory(options);
109
+ }
110
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
111
+ for (const [styleName, style] of Object.entries(_index.default)) {
112
+ styles[styleName] = {
113
+ get() {
114
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
115
+ Object.defineProperty(this, styleName, {
116
+ value: builder
117
+ });
118
+ return builder;
119
+ }
120
+ };
121
+ }
122
+ styles.visible = {
123
+ get() {
124
+ const builder = createBuilder(this, this[STYLER], true);
125
+ Object.defineProperty(this, 'visible', {
126
+ value: builder
127
+ });
128
+ return builder;
129
+ }
130
+ };
131
+ const getModelAnsi = function (model, level, type) {
132
+ for (var _len2 = arguments.length, arguments_ = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
133
+ arguments_[_key2 - 3] = arguments[_key2];
134
+ }
135
+ if (model === 'rgb') {
136
+ if (level === 'ansi16m') {
137
+ return _index.default[type].ansi16m(...arguments_);
138
+ }
139
+ if (level === 'ansi256') {
140
+ return _index.default[type].ansi256(_index.default.rgbToAnsi256(...arguments_));
141
+ }
142
+ return _index.default[type].ansi(_index.default.rgbToAnsi(...arguments_));
143
+ }
144
+ if (model === 'hex') {
145
+ return getModelAnsi('rgb', level, type, ..._index.default.hexToRgb(...arguments_));
146
+ }
147
+ return _index.default[type][model](...arguments_);
148
+ };
149
+ const usedModels = ['rgb', 'hex', 'ansi256'];
150
+ for (const model of usedModels) {
151
+ styles[model] = {
152
+ get() {
153
+ const {
154
+ level
155
+ } = this;
156
+ return function () {
157
+ for (var _len3 = arguments.length, arguments_ = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
158
+ arguments_[_key3] = arguments[_key3];
159
+ }
160
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], 'color', ...arguments_), _index.default.color.close, this[STYLER]);
161
+ return createBuilder(this, styler, this[IS_EMPTY]);
162
+ };
163
+ }
164
+ };
165
+ const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
166
+ styles[bgModel] = {
167
+ get() {
168
+ const {
169
+ level
170
+ } = this;
171
+ return function () {
172
+ for (var _len4 = arguments.length, arguments_ = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
173
+ arguments_[_key4] = arguments[_key4];
174
+ }
175
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], 'bgColor', ...arguments_), _index.default.bgColor.close, this[STYLER]);
176
+ return createBuilder(this, styler, this[IS_EMPTY]);
177
+ };
178
+ }
179
+ };
180
+ }
181
+ const proto = Object.defineProperties(() => {}, {
182
+ ...styles,
183
+ level: {
184
+ enumerable: true,
185
+ get() {
186
+ return this[GENERATOR].level;
187
+ },
188
+ set(level) {
189
+ this[GENERATOR].level = level;
190
+ }
191
+ }
192
+ });
193
+ const createStyler = (open, close, parent) => {
194
+ let openAll;
195
+ let closeAll;
196
+ if (parent === undefined) {
197
+ openAll = open;
198
+ closeAll = close;
199
+ } else {
200
+ openAll = parent.openAll + open;
201
+ closeAll = close + parent.closeAll;
202
+ }
203
+ return {
204
+ open,
205
+ close,
206
+ openAll,
207
+ closeAll,
208
+ parent
209
+ };
210
+ };
211
+ const createBuilder = (self, _styler, _isEmpty) => {
212
+ // Single argument is hot path, implicit coercion is faster than anything
213
+ // eslint-disable-next-line no-implicit-coercion
214
+ const builder = function () {
215
+ for (var _len5 = arguments.length, arguments_ = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
216
+ arguments_[_key5] = arguments[_key5];
217
+ }
218
+ return applyStyle(builder, arguments_.length === 1 ? '' + arguments_[0] : arguments_.join(' '));
219
+ };
220
+
221
+ // We alter the prototype because we must return a function, but there is
222
+ // no way to create a function with a different prototype
223
+ Object.setPrototypeOf(builder, proto);
224
+ builder[GENERATOR] = self;
225
+ builder[STYLER] = _styler;
226
+ builder[IS_EMPTY] = _isEmpty;
227
+ return builder;
228
+ };
229
+ const applyStyle = (self, string) => {
230
+ if (self.level <= 0 || !string) {
231
+ return self[IS_EMPTY] ? '' : string;
232
+ }
233
+ let styler = self[STYLER];
234
+ if (styler === undefined) {
235
+ return string;
236
+ }
237
+ const {
238
+ openAll,
239
+ closeAll
240
+ } = styler;
241
+ if (string.includes('\u001B')) {
242
+ while (styler !== undefined) {
243
+ // Replace any instances already present with a re-opening code
244
+ // otherwise only the part of the string until said closing code
245
+ // will be colored, and the rest will simply be 'plain'.
246
+ string = (0, _utilities.stringReplaceAll)(string, styler.close, styler.open);
247
+ styler = styler.parent;
248
+ }
249
+ }
250
+
251
+ // We can move both next actions out of loop, because remaining actions in loop won't have
252
+ // any/visible effect on parts we add here. Close the styling before a linebreak and reopen
253
+ // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
254
+ const lfIndex = string.indexOf('\n');
255
+ if (lfIndex !== -1) {
256
+ string = (0, _utilities.stringEncaseCRLFWithFirstIndex)(string, closeAll, openAll, lfIndex);
257
+ }
258
+ return openAll + string + closeAll;
259
+ };
260
+ Object.defineProperties(createChalk.prototype, styles);
261
+ const chalk = createChalk();
262
+ const chalkStderr = exports.chalkStderr = createChalk({
263
+ level: stderrColor ? stderrColor.level : 0
264
+ });
265
+ var _default = exports.default = chalk;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.stringEncaseCRLFWithFirstIndex = stringEncaseCRLFWithFirstIndex;
7
+ exports.stringReplaceAll = stringReplaceAll;
8
+ // TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.
9
+ function stringReplaceAll(string, substring, replacer) {
10
+ let index = string.indexOf(substring);
11
+ if (index === -1) {
12
+ return string;
13
+ }
14
+ const substringLength = substring.length;
15
+ let endIndex = 0;
16
+ let returnValue = '';
17
+ do {
18
+ returnValue += string.slice(endIndex, index) + substring + replacer;
19
+ endIndex = index + substringLength;
20
+ index = string.indexOf(substring, endIndex);
21
+ } while (index !== -1);
22
+ returnValue += string.slice(endIndex);
23
+ return returnValue;
24
+ }
25
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
26
+ let endIndex = 0;
27
+ let returnValue = '';
28
+ do {
29
+ const gotCR = string[index - 1] === '\r';
30
+ returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
31
+ endIndex = index + 1;
32
+ index = string.indexOf('\n', endIndex);
33
+ } while (index !== -1);
34
+ returnValue += string.slice(endIndex);
35
+ return returnValue;
36
+ }
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.modifierNames = exports.foregroundColorNames = exports.default = exports.colorNames = exports.backgroundColorNames = void 0;
7
+ require("core-js/modules/esnext.async-iterator.map.js");
8
+ require("core-js/modules/esnext.iterator.map.js");
9
+ require("core-js/modules/esnext.map.delete-all.js");
10
+ require("core-js/modules/esnext.map.every.js");
11
+ require("core-js/modules/esnext.map.filter.js");
12
+ require("core-js/modules/esnext.map.find.js");
13
+ require("core-js/modules/esnext.map.find-key.js");
14
+ require("core-js/modules/esnext.map.includes.js");
15
+ require("core-js/modules/esnext.map.key-of.js");
16
+ require("core-js/modules/esnext.map.map-keys.js");
17
+ require("core-js/modules/esnext.map.map-values.js");
18
+ require("core-js/modules/esnext.map.merge.js");
19
+ require("core-js/modules/esnext.map.reduce.js");
20
+ require("core-js/modules/esnext.map.some.js");
21
+ require("core-js/modules/esnext.map.update.js");
22
+ require("core-js/modules/web.dom-collections.iterator.js");
23
+ const ANSI_BACKGROUND_OFFSET = 10;
24
+ const wrapAnsi16 = function () {
25
+ let offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
26
+ return code => "\x1B[".concat(code + offset, "m");
27
+ };
28
+ const wrapAnsi256 = function () {
29
+ let offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
30
+ return code => "\x1B[".concat(38 + offset, ";5;").concat(code, "m");
31
+ };
32
+ const wrapAnsi16m = function () {
33
+ let offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
34
+ return (red, green, blue) => "\x1B[".concat(38 + offset, ";2;").concat(red, ";").concat(green, ";").concat(blue, "m");
35
+ };
36
+ const styles = {
37
+ modifier: {
38
+ reset: [0, 0],
39
+ // 21 isn't widely supported and 22 does the same thing
40
+ bold: [1, 22],
41
+ dim: [2, 22],
42
+ italic: [3, 23],
43
+ underline: [4, 24],
44
+ overline: [53, 55],
45
+ inverse: [7, 27],
46
+ hidden: [8, 28],
47
+ strikethrough: [9, 29]
48
+ },
49
+ color: {
50
+ black: [30, 39],
51
+ red: [31, 39],
52
+ green: [32, 39],
53
+ yellow: [33, 39],
54
+ blue: [34, 39],
55
+ magenta: [35, 39],
56
+ cyan: [36, 39],
57
+ white: [37, 39],
58
+ // Bright color
59
+ blackBright: [90, 39],
60
+ gray: [90, 39],
61
+ // Alias of `blackBright`
62
+ grey: [90, 39],
63
+ // Alias of `blackBright`
64
+ redBright: [91, 39],
65
+ greenBright: [92, 39],
66
+ yellowBright: [93, 39],
67
+ blueBright: [94, 39],
68
+ magentaBright: [95, 39],
69
+ cyanBright: [96, 39],
70
+ whiteBright: [97, 39]
71
+ },
72
+ bgColor: {
73
+ bgBlack: [40, 49],
74
+ bgRed: [41, 49],
75
+ bgGreen: [42, 49],
76
+ bgYellow: [43, 49],
77
+ bgBlue: [44, 49],
78
+ bgMagenta: [45, 49],
79
+ bgCyan: [46, 49],
80
+ bgWhite: [47, 49],
81
+ // Bright color
82
+ bgBlackBright: [100, 49],
83
+ bgGray: [100, 49],
84
+ // Alias of `bgBlackBright`
85
+ bgGrey: [100, 49],
86
+ // Alias of `bgBlackBright`
87
+ bgRedBright: [101, 49],
88
+ bgGreenBright: [102, 49],
89
+ bgYellowBright: [103, 49],
90
+ bgBlueBright: [104, 49],
91
+ bgMagentaBright: [105, 49],
92
+ bgCyanBright: [106, 49],
93
+ bgWhiteBright: [107, 49]
94
+ }
95
+ };
96
+ const modifierNames = exports.modifierNames = Object.keys(styles.modifier);
97
+ const foregroundColorNames = exports.foregroundColorNames = Object.keys(styles.color);
98
+ const backgroundColorNames = exports.backgroundColorNames = Object.keys(styles.bgColor);
99
+ const colorNames = exports.colorNames = [...foregroundColorNames, ...backgroundColorNames];
100
+ function assembleStyles() {
101
+ const codes = new Map();
102
+ for (const [groupName, group] of Object.entries(styles)) {
103
+ for (const [styleName, style] of Object.entries(group)) {
104
+ styles[styleName] = {
105
+ open: "\x1B[".concat(style[0], "m"),
106
+ close: "\x1B[".concat(style[1], "m")
107
+ };
108
+ group[styleName] = styles[styleName];
109
+ codes.set(style[0], style[1]);
110
+ }
111
+ Object.defineProperty(styles, groupName, {
112
+ value: group,
113
+ enumerable: false
114
+ });
115
+ }
116
+ Object.defineProperty(styles, 'codes', {
117
+ value: codes,
118
+ enumerable: false
119
+ });
120
+ styles.color.close = '\u001B[39m';
121
+ styles.bgColor.close = '\u001B[49m';
122
+ styles.color.ansi = wrapAnsi16();
123
+ styles.color.ansi256 = wrapAnsi256();
124
+ styles.color.ansi16m = wrapAnsi16m();
125
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
126
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
127
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
128
+
129
+ // From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
130
+ Object.defineProperties(styles, {
131
+ rgbToAnsi256: {
132
+ value(red, green, blue) {
133
+ // We use the extended greyscale palette here, with the exception of
134
+ // black and white. normal palette only has 4 greyscale shades.
135
+ if (red === green && green === blue) {
136
+ if (red < 8) {
137
+ return 16;
138
+ }
139
+ if (red > 248) {
140
+ return 231;
141
+ }
142
+ return Math.round((red - 8) / 247 * 24) + 232;
143
+ }
144
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
145
+ },
146
+ enumerable: false
147
+ },
148
+ hexToRgb: {
149
+ value(hex) {
150
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
151
+ if (!matches) {
152
+ return [0, 0, 0];
153
+ }
154
+ let [colorString] = matches;
155
+ if (colorString.length === 3) {
156
+ colorString = [...colorString].map(character => character + character).join('');
157
+ }
158
+ const integer = Number.parseInt(colorString, 16);
159
+ return [/* eslint-disable no-bitwise */
160
+ integer >> 16 & 0xFF, integer >> 8 & 0xFF, integer & 0xFF
161
+ /* eslint-enable no-bitwise */];
162
+ },
163
+ enumerable: false
164
+ },
165
+ hexToAnsi256: {
166
+ value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
167
+ enumerable: false
168
+ },
169
+ ansi256ToAnsi: {
170
+ value(code) {
171
+ if (code < 8) {
172
+ return 30 + code;
173
+ }
174
+ if (code < 16) {
175
+ return 90 + (code - 8);
176
+ }
177
+ let red;
178
+ let green;
179
+ let blue;
180
+ if (code >= 232) {
181
+ red = ((code - 232) * 10 + 8) / 255;
182
+ green = red;
183
+ blue = red;
184
+ } else {
185
+ code -= 16;
186
+ const remainder = code % 36;
187
+ red = Math.floor(code / 36) / 5;
188
+ green = Math.floor(remainder / 6) / 5;
189
+ blue = remainder % 6 / 5;
190
+ }
191
+ const value = Math.max(red, green, blue) * 2;
192
+ if (value === 0) {
193
+ return 30;
194
+ }
195
+
196
+ // eslint-disable-next-line no-bitwise
197
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
198
+ if (value === 2) {
199
+ result += 60;
200
+ }
201
+ return result;
202
+ },
203
+ enumerable: false
204
+ },
205
+ rgbToAnsi: {
206
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
207
+ enumerable: false
208
+ },
209
+ hexToAnsi: {
210
+ value: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
211
+ enumerable: false
212
+ }
213
+ });
214
+ return styles;
215
+ }
216
+ const ansiStyles = assembleStyles();
217
+ var _default = exports.default = ansiStyles;