1 | #!/usr/bin/env node
|
2 | 'use strict';
|
3 |
|
4 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
5 |
|
6 | var fs$3 = _interopDefault(require('fs'));
|
7 | var path$2 = _interopDefault(require('path'));
|
8 | var os$1 = _interopDefault(require('os'));
|
9 | var tty$1 = _interopDefault(require('tty'));
|
10 | var assert$1 = _interopDefault(require('assert'));
|
11 | var util$4 = _interopDefault(require('util'));
|
12 | var stream$6 = _interopDefault(require('stream'));
|
13 | var events$1 = _interopDefault(require('events'));
|
14 | var readline$1 = _interopDefault(require('readline'));
|
15 |
|
16 | var semverCompare = function cmp(a, b) {
|
17 | var pa = a.split('.');
|
18 | var pb = b.split('.');
|
19 |
|
20 | for (var i = 0; i < 3; i++) {
|
21 | var na = Number(pa[i]);
|
22 | var nb = Number(pb[i]);
|
23 | if (na > nb) return 1;
|
24 | if (nb > na) return -1;
|
25 | if (!isNaN(na) && isNaN(nb)) return 1;
|
26 | if (isNaN(na) && !isNaN(nb)) return -1;
|
27 | }
|
28 |
|
29 | return 0;
|
30 | };
|
31 |
|
32 | var pleaseUpgradeNode = function pleaseUpgradeNode(pkg, opts) {
|
33 | var opts = opts || {};
|
34 | var requiredVersion = pkg.engines.node.replace('>=', '');
|
35 | var currentVersion = process.version.replace('v', '');
|
36 |
|
37 | if (semverCompare(currentVersion, requiredVersion) === -1) {
|
38 | if (opts.message) {
|
39 | console.error(opts.message(requiredVersion));
|
40 | } else {
|
41 | console.error(pkg.name + ' requires at least version ' + requiredVersion + ' of Node, please upgrade');
|
42 | }
|
43 |
|
44 | if (opts.hasOwnProperty('exitCode')) {
|
45 | process.exit(opts.exitCode);
|
46 | } else {
|
47 | process.exit(1);
|
48 | }
|
49 | }
|
50 | };
|
51 |
|
52 | var name = "prettier";
|
53 | var version = "2.0.5";
|
54 | var description = "Prettier is an opinionated code formatter";
|
55 | var bin = "./bin/prettier.js";
|
56 | var repository = "prettier/prettier";
|
57 | var homepage = "https://prettier.io";
|
58 | var author = "James Long";
|
59 | var license = "MIT";
|
60 | var main = "./index.js";
|
61 | var engines = {
|
62 | node: ">=10.13.0"
|
63 | };
|
64 | var dependencies = {
|
65 | "@angular/compiler": "9.0.5",
|
66 | "@babel/code-frame": "7.8.0",
|
67 | "@babel/parser": "7.9.4",
|
68 | "@glimmer/syntax": "0.50.0",
|
69 | "@iarna/toml": "2.2.3",
|
70 | "@typescript-eslint/typescript-estree": "2.26.0",
|
71 | "angular-estree-parser": "1.3.0",
|
72 | "angular-html-parser": "1.4.0",
|
73 | camelcase: "5.3.1",
|
74 | chalk: "4.0.0",
|
75 | "ci-info": "watson/ci-info#f43f6a1cefff47fb361c88cf4b943fdbcaafe540",
|
76 | "cjk-regex": "2.0.0",
|
77 | cosmiconfig: "6.0.0",
|
78 | dashify: "2.0.0",
|
79 | dedent: "0.7.0",
|
80 | diff: "4.0.2",
|
81 | editorconfig: "0.15.3",
|
82 | "editorconfig-to-prettier": "0.1.1",
|
83 | "escape-string-regexp": "2.0.0",
|
84 | esutils: "2.0.3",
|
85 | "fast-glob": "3.2.2",
|
86 | "find-parent-dir": "0.3.0",
|
87 | "find-project-root": "1.1.1",
|
88 | "flow-parser": "0.122.0",
|
89 | "get-stream": "5.1.0",
|
90 | globby: "11.0.0",
|
91 | graphql: "15.0.0",
|
92 | "html-element-attributes": "2.2.1",
|
93 | "html-styles": "1.0.0",
|
94 | "html-tag-names": "1.1.5",
|
95 | ignore: "4.0.6",
|
96 | "jest-docblock": "25.2.6",
|
97 | "json-stable-stringify": "1.0.1",
|
98 | leven: "3.1.0",
|
99 | "lines-and-columns": "1.1.6",
|
100 | "linguist-languages": "7.9.0",
|
101 | lodash: "4.17.15",
|
102 | mem: "6.0.1",
|
103 | minimatch: "3.0.4",
|
104 | minimist: "1.2.5",
|
105 | "n-readlines": "1.0.0",
|
106 | "please-upgrade-node": "3.2.0",
|
107 | "postcss-less": "3.1.4",
|
108 | "postcss-media-query-parser": "0.2.3",
|
109 | "postcss-scss": "2.0.0",
|
110 | "postcss-selector-parser": "2.2.3",
|
111 | "postcss-values-parser": "2.0.1",
|
112 | "regexp-util": "1.2.2",
|
113 | "remark-math": "1.0.6",
|
114 | "remark-parse": "5.0.0",
|
115 | resolve: "1.16.1",
|
116 | semver: "7.1.3",
|
117 | srcset: "2.0.1",
|
118 | "string-width": "4.2.0",
|
119 | typescript: "3.8.3",
|
120 | "unicode-regex": "3.0.0",
|
121 | unified: "9.0.0",
|
122 | vnopts: "1.0.2",
|
123 | "yaml-unist-parser": "1.1.1"
|
124 | };
|
125 | var devDependencies = {
|
126 | "@babel/core": "7.9.0",
|
127 | "@babel/preset-env": "7.9.0",
|
128 | "@rollup/plugin-alias": "3.0.1",
|
129 | "@rollup/plugin-commonjs": "11.0.2",
|
130 | "@rollup/plugin-json": "4.0.2",
|
131 | "@rollup/plugin-node-resolve": "7.1.1",
|
132 | "@rollup/plugin-replace": "2.3.1",
|
133 | "babel-loader": "8.1.0",
|
134 | benchmark: "2.1.4",
|
135 | "builtin-modules": "3.1.0",
|
136 | codecov: "3.6.5",
|
137 | "cross-env": "7.0.2",
|
138 | cspell: "4.0.55",
|
139 | eslint: "6.8.0",
|
140 | "eslint-config-prettier": "6.10.1",
|
141 | "eslint-formatter-friendly": "7.0.0",
|
142 | "eslint-plugin-import": "2.20.2",
|
143 | "eslint-plugin-prettier": "3.1.2",
|
144 | "eslint-plugin-react": "7.19.0",
|
145 | "eslint-plugin-unicorn": "18.0.1",
|
146 | execa: "4.0.0",
|
147 | jest: "25.2.7",
|
148 | "jest-snapshot-serializer-ansi": "1.0.0",
|
149 | "jest-snapshot-serializer-raw": "1.1.0",
|
150 | "jest-watch-typeahead": "0.5.0",
|
151 | prettier: "2.0.4",
|
152 | rimraf: "3.0.2",
|
153 | rollup: "2.3.2",
|
154 | "rollup-plugin-babel": "4.4.0",
|
155 | "rollup-plugin-node-globals": "1.4.0",
|
156 | "rollup-plugin-terser": "5.3.0",
|
157 | shelljs: "0.8.3",
|
158 | "snapshot-diff": "0.7.0",
|
159 | "strip-ansi": "6.0.0",
|
160 | "synchronous-promise": "2.0.10",
|
161 | tempy: "0.5.0",
|
162 | "terser-webpack-plugin": "2.3.5",
|
163 | webpack: "4.42.1"
|
164 | };
|
165 | var scripts = {
|
166 | prepublishOnly: "echo \"Error: must publish from dist/\" && exit 1",
|
167 | "prepare-release": "yarn && yarn build && yarn test:dist",
|
168 | test: "jest",
|
169 | "test:dist": "cross-env NODE_ENV=production jest",
|
170 | "test:dist-standalone": "cross-env NODE_ENV=production TEST_STANDALONE=1 jest tests/",
|
171 | "test:integration": "jest tests_integration",
|
172 | "perf:repeat": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
173 | "perf:repeat-inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
174 | "perf:benchmark": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-benchmark --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
175 | "lint:typecheck": "tsc",
|
176 | "lint:eslint": "cross-env EFF_NO_LINK_RULES=true eslint . --format friendly",
|
177 | "lint:changelog": "node ./scripts/lint-changelog.js",
|
178 | "lint:prettier": "prettier \"**/*.{md,json,yml,html,css}\" --check",
|
179 | "lint:dist": "eslint --no-eslintrc --no-ignore --env=es6,browser --parser-options=ecmaVersion:2016 \"dist/!(bin-prettier|index|third-party).js\"",
|
180 | "lint:spellcheck": "cspell {bin,scripts,src,website}/**/*.js {docs,website/blog,changelog_unreleased}/**/*.md",
|
181 | "lint:deps": "node ./scripts/check-deps.js",
|
182 | build: "node --max-old-space-size=3072 ./scripts/build/build.js",
|
183 | "build-docs": "node ./scripts/build-docs.js"
|
184 | };
|
185 | var _package = {
|
186 | name: name,
|
187 | version: version,
|
188 | description: description,
|
189 | bin: bin,
|
190 | repository: repository,
|
191 | homepage: homepage,
|
192 | author: author,
|
193 | license: license,
|
194 | main: main,
|
195 | engines: engines,
|
196 | dependencies: dependencies,
|
197 | devDependencies: devDependencies,
|
198 | scripts: scripts
|
199 | };
|
200 |
|
201 | var _package$1 = Object.freeze({
|
202 | __proto__: null,
|
203 | name: name,
|
204 | version: version,
|
205 | description: description,
|
206 | bin: bin,
|
207 | repository: repository,
|
208 | homepage: homepage,
|
209 | author: author,
|
210 | license: license,
|
211 | main: main,
|
212 | engines: engines,
|
213 | dependencies: dependencies,
|
214 | devDependencies: devDependencies,
|
215 | scripts: scripts,
|
216 | 'default': _package
|
217 | });
|
218 |
|
219 | function Diff() {}
|
220 |
|
221 | Diff.prototype = {
|
222 | diff: function diff(oldString, newString) {
|
223 | var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
224 | var callback = options.callback;
|
225 |
|
226 | if (typeof options === 'function') {
|
227 | callback = options;
|
228 | options = {};
|
229 | }
|
230 |
|
231 | this.options = options;
|
232 | var self = this;
|
233 |
|
234 | function done(value) {
|
235 | if (callback) {
|
236 | setTimeout(function () {
|
237 | callback(undefined, value);
|
238 | }, 0);
|
239 | return true;
|
240 | } else {
|
241 | return value;
|
242 | }
|
243 | }
|
244 |
|
245 |
|
246 | oldString = this.castInput(oldString);
|
247 | newString = this.castInput(newString);
|
248 | oldString = this.removeEmpty(this.tokenize(oldString));
|
249 | newString = this.removeEmpty(this.tokenize(newString));
|
250 | var newLen = newString.length,
|
251 | oldLen = oldString.length;
|
252 | var editLength = 1;
|
253 | var maxEditLength = newLen + oldLen;
|
254 | var bestPath = [{
|
255 | newPos: -1,
|
256 | components: []
|
257 | }];
|
258 |
|
259 | var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
|
260 |
|
261 | if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
|
262 |
|
263 | return done([{
|
264 | value: this.join(newString),
|
265 | count: newString.length
|
266 | }]);
|
267 | }
|
268 |
|
269 |
|
270 | function execEditLength() {
|
271 | for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
|
272 | var basePath = void 0;
|
273 |
|
274 | var addPath = bestPath[diagonalPath - 1],
|
275 | removePath = bestPath[diagonalPath + 1],
|
276 | _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
|
277 |
|
278 | if (addPath) {
|
279 |
|
280 | bestPath[diagonalPath - 1] = undefined;
|
281 | }
|
282 |
|
283 | var canAdd = addPath && addPath.newPos + 1 < newLen,
|
284 | canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
|
285 |
|
286 | if (!canAdd && !canRemove) {
|
287 |
|
288 | bestPath[diagonalPath] = undefined;
|
289 | continue;
|
290 | }
|
291 |
|
292 |
|
293 |
|
294 |
|
295 | if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
|
296 | basePath = clonePath(removePath);
|
297 | self.pushComponent(basePath.components, undefined, true);
|
298 | } else {
|
299 | basePath = addPath;
|
300 |
|
301 | basePath.newPos++;
|
302 | self.pushComponent(basePath.components, true, undefined);
|
303 | }
|
304 |
|
305 | _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
|
306 |
|
307 | if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
|
308 | return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
|
309 | } else {
|
310 |
|
311 | bestPath[diagonalPath] = basePath;
|
312 | }
|
313 | }
|
314 |
|
315 | editLength++;
|
316 | }
|
317 |
|
318 |
|
319 |
|
320 |
|
321 | if (callback) {
|
322 | (function exec() {
|
323 | setTimeout(function () {
|
324 |
|
325 |
|
326 |
|
327 | if (editLength > maxEditLength) {
|
328 | return callback();
|
329 | }
|
330 |
|
331 | if (!execEditLength()) {
|
332 | exec();
|
333 | }
|
334 | }, 0);
|
335 | })();
|
336 | } else {
|
337 | while (editLength <= maxEditLength) {
|
338 | var ret = execEditLength();
|
339 |
|
340 | if (ret) {
|
341 | return ret;
|
342 | }
|
343 | }
|
344 | }
|
345 | },
|
346 | pushComponent: function pushComponent(components, added, removed) {
|
347 | var last = components[components.length - 1];
|
348 |
|
349 | if (last && last.added === added && last.removed === removed) {
|
350 |
|
351 |
|
352 | components[components.length - 1] = {
|
353 | count: last.count + 1,
|
354 | added: added,
|
355 | removed: removed
|
356 | };
|
357 | } else {
|
358 | components.push({
|
359 | count: 1,
|
360 | added: added,
|
361 | removed: removed
|
362 | });
|
363 | }
|
364 | },
|
365 | extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
|
366 | var newLen = newString.length,
|
367 | oldLen = oldString.length,
|
368 | newPos = basePath.newPos,
|
369 | oldPos = newPos - diagonalPath,
|
370 | commonCount = 0;
|
371 |
|
372 | while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
|
373 | newPos++;
|
374 | oldPos++;
|
375 | commonCount++;
|
376 | }
|
377 |
|
378 | if (commonCount) {
|
379 | basePath.components.push({
|
380 | count: commonCount
|
381 | });
|
382 | }
|
383 |
|
384 | basePath.newPos = newPos;
|
385 | return oldPos;
|
386 | },
|
387 | equals: function equals(left, right) {
|
388 | if (this.options.comparator) {
|
389 | return this.options.comparator(left, right);
|
390 | } else {
|
391 | return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
392 | }
|
393 | },
|
394 | removeEmpty: function removeEmpty(array) {
|
395 | var ret = [];
|
396 |
|
397 | for (var i = 0; i < array.length; i++) {
|
398 | if (array[i]) {
|
399 | ret.push(array[i]);
|
400 | }
|
401 | }
|
402 |
|
403 | return ret;
|
404 | },
|
405 | castInput: function castInput(value) {
|
406 | return value;
|
407 | },
|
408 | tokenize: function tokenize(value) {
|
409 | return value.split('');
|
410 | },
|
411 | join: function join(chars) {
|
412 | return chars.join('');
|
413 | }
|
414 | };
|
415 |
|
416 | function buildValues(diff, components, newString, oldString, useLongestToken) {
|
417 | var componentPos = 0,
|
418 | componentLen = components.length,
|
419 | newPos = 0,
|
420 | oldPos = 0;
|
421 |
|
422 | for (; componentPos < componentLen; componentPos++) {
|
423 | var component = components[componentPos];
|
424 |
|
425 | if (!component.removed) {
|
426 | if (!component.added && useLongestToken) {
|
427 | var value = newString.slice(newPos, newPos + component.count);
|
428 | value = value.map(function (value, i) {
|
429 | var oldValue = oldString[oldPos + i];
|
430 | return oldValue.length > value.length ? oldValue : value;
|
431 | });
|
432 | component.value = diff.join(value);
|
433 | } else {
|
434 | component.value = diff.join(newString.slice(newPos, newPos + component.count));
|
435 | }
|
436 |
|
437 | newPos += component.count;
|
438 |
|
439 | if (!component.added) {
|
440 | oldPos += component.count;
|
441 | }
|
442 | } else {
|
443 | component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
|
444 | oldPos += component.count;
|
445 |
|
446 |
|
447 |
|
448 | if (componentPos && components[componentPos - 1].added) {
|
449 | var tmp = components[componentPos - 1];
|
450 | components[componentPos - 1] = components[componentPos];
|
451 | components[componentPos] = tmp;
|
452 | }
|
453 | }
|
454 | }
|
455 |
|
456 |
|
457 |
|
458 |
|
459 | var lastComponent = components[componentLen - 1];
|
460 |
|
461 | if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
|
462 | components[componentLen - 2].value += lastComponent.value;
|
463 | components.pop();
|
464 | }
|
465 |
|
466 | return components;
|
467 | }
|
468 |
|
469 | function clonePath(path) {
|
470 | return {
|
471 | newPos: path.newPos,
|
472 | components: path.components.slice(0)
|
473 | };
|
474 | }
|
475 |
|
476 | var characterDiff = new Diff();
|
477 |
|
478 | function diffChars(oldStr, newStr, options) {
|
479 | return characterDiff.diff(oldStr, newStr, options);
|
480 | }
|
481 |
|
482 | function generateOptions(options, defaults) {
|
483 | if (typeof options === 'function') {
|
484 | defaults.callback = options;
|
485 | } else if (options) {
|
486 | for (var name in options) {
|
487 |
|
488 | if (options.hasOwnProperty(name)) {
|
489 | defaults[name] = options[name];
|
490 | }
|
491 | }
|
492 | }
|
493 |
|
494 | return defaults;
|
495 | }
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 | var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
|
515 | var reWhitespace = /\S/;
|
516 | var wordDiff = new Diff();
|
517 |
|
518 | wordDiff.equals = function (left, right) {
|
519 | if (this.options.ignoreCase) {
|
520 | left = left.toLowerCase();
|
521 | right = right.toLowerCase();
|
522 | }
|
523 |
|
524 | return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
|
525 | };
|
526 |
|
527 | wordDiff.tokenize = function (value) {
|
528 | var tokens = value.split(/(\s+|[()[\]{}'"]|\b)/);
|
529 |
|
530 | for (var i = 0; i < tokens.length - 1; i++) {
|
531 |
|
532 | if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
|
533 | tokens[i] += tokens[i + 2];
|
534 | tokens.splice(i + 1, 2);
|
535 | i--;
|
536 | }
|
537 | }
|
538 |
|
539 | return tokens;
|
540 | };
|
541 |
|
542 | function diffWords(oldStr, newStr, options) {
|
543 | options = generateOptions(options, {
|
544 | ignoreWhitespace: true
|
545 | });
|
546 | return wordDiff.diff(oldStr, newStr, options);
|
547 | }
|
548 |
|
549 | function diffWordsWithSpace(oldStr, newStr, options) {
|
550 | return wordDiff.diff(oldStr, newStr, options);
|
551 | }
|
552 |
|
553 | var lineDiff = new Diff();
|
554 |
|
555 | lineDiff.tokenize = function (value) {
|
556 | var retLines = [],
|
557 | linesAndNewlines = value.split(/(\n|\r\n)/);
|
558 |
|
559 | if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
560 | linesAndNewlines.pop();
|
561 | }
|
562 |
|
563 |
|
564 | for (var i = 0; i < linesAndNewlines.length; i++) {
|
565 | var line = linesAndNewlines[i];
|
566 |
|
567 | if (i % 2 && !this.options.newlineIsToken) {
|
568 | retLines[retLines.length - 1] += line;
|
569 | } else {
|
570 | if (this.options.ignoreWhitespace) {
|
571 | line = line.trim();
|
572 | }
|
573 |
|
574 | retLines.push(line);
|
575 | }
|
576 | }
|
577 |
|
578 | return retLines;
|
579 | };
|
580 |
|
581 | function diffLines(oldStr, newStr, callback) {
|
582 | return lineDiff.diff(oldStr, newStr, callback);
|
583 | }
|
584 |
|
585 | function diffTrimmedLines(oldStr, newStr, callback) {
|
586 | var options = generateOptions(callback, {
|
587 | ignoreWhitespace: true
|
588 | });
|
589 | return lineDiff.diff(oldStr, newStr, options);
|
590 | }
|
591 |
|
592 | var sentenceDiff = new Diff();
|
593 |
|
594 | sentenceDiff.tokenize = function (value) {
|
595 | return value.split(/(\S.+?[.!?])(?=\s+|$)/);
|
596 | };
|
597 |
|
598 | function diffSentences(oldStr, newStr, callback) {
|
599 | return sentenceDiff.diff(oldStr, newStr, callback);
|
600 | }
|
601 |
|
602 | var cssDiff = new Diff();
|
603 |
|
604 | cssDiff.tokenize = function (value) {
|
605 | return value.split(/([{}:;,]|\s+)/);
|
606 | };
|
607 |
|
608 | function diffCss(oldStr, newStr, callback) {
|
609 | return cssDiff.diff(oldStr, newStr, callback);
|
610 | }
|
611 |
|
612 | function _typeof(obj) {
|
613 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
614 | _typeof = function (obj) {
|
615 | return typeof obj;
|
616 | };
|
617 | } else {
|
618 | _typeof = function (obj) {
|
619 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
620 | };
|
621 | }
|
622 |
|
623 | return _typeof(obj);
|
624 | }
|
625 |
|
626 | function _toConsumableArray(arr) {
|
627 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
|
628 | }
|
629 |
|
630 | function _arrayWithoutHoles(arr) {
|
631 | if (Array.isArray(arr)) {
|
632 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
633 |
|
634 | return arr2;
|
635 | }
|
636 | }
|
637 |
|
638 | function _iterableToArray(iter) {
|
639 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
640 | }
|
641 |
|
642 | function _nonIterableSpread() {
|
643 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
644 | }
|
645 |
|
646 | var objectPrototypeToString = Object.prototype.toString;
|
647 | var jsonDiff = new Diff();
|
648 |
|
649 |
|
650 | jsonDiff.useLongestToken = true;
|
651 | jsonDiff.tokenize = lineDiff.tokenize;
|
652 |
|
653 | jsonDiff.castInput = function (value) {
|
654 | var _this$options = this.options,
|
655 | undefinedReplacement = _this$options.undefinedReplacement,
|
656 | _this$options$stringi = _this$options.stringifyReplacer,
|
657 | stringifyReplacer = _this$options$stringi === void 0 ? function (k, v) {
|
658 | return typeof v === 'undefined' ? undefinedReplacement : v;
|
659 | } : _this$options$stringi;
|
660 | return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
|
661 | };
|
662 |
|
663 | jsonDiff.equals = function (left, right) {
|
664 | return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'));
|
665 | };
|
666 |
|
667 | function diffJson(oldObj, newObj, options) {
|
668 | return jsonDiff.diff(oldObj, newObj, options);
|
669 | }
|
670 |
|
671 |
|
672 |
|
673 | function canonicalize(obj, stack, replacementStack, replacer, key) {
|
674 | stack = stack || [];
|
675 | replacementStack = replacementStack || [];
|
676 |
|
677 | if (replacer) {
|
678 | obj = replacer(key, obj);
|
679 | }
|
680 |
|
681 | var i;
|
682 |
|
683 | for (i = 0; i < stack.length; i += 1) {
|
684 | if (stack[i] === obj) {
|
685 | return replacementStack[i];
|
686 | }
|
687 | }
|
688 |
|
689 | var canonicalizedObj;
|
690 |
|
691 | if ('[object Array]' === objectPrototypeToString.call(obj)) {
|
692 | stack.push(obj);
|
693 | canonicalizedObj = new Array(obj.length);
|
694 | replacementStack.push(canonicalizedObj);
|
695 |
|
696 | for (i = 0; i < obj.length; i += 1) {
|
697 | canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
|
698 | }
|
699 |
|
700 | stack.pop();
|
701 | replacementStack.pop();
|
702 | return canonicalizedObj;
|
703 | }
|
704 |
|
705 | if (obj && obj.toJSON) {
|
706 | obj = obj.toJSON();
|
707 | }
|
708 |
|
709 | if (_typeof(obj) === 'object' && obj !== null) {
|
710 | stack.push(obj);
|
711 | canonicalizedObj = {};
|
712 | replacementStack.push(canonicalizedObj);
|
713 |
|
714 | var sortedKeys = [],
|
715 | _key;
|
716 |
|
717 | for (_key in obj) {
|
718 |
|
719 | if (obj.hasOwnProperty(_key)) {
|
720 | sortedKeys.push(_key);
|
721 | }
|
722 | }
|
723 |
|
724 | sortedKeys.sort();
|
725 |
|
726 | for (i = 0; i < sortedKeys.length; i += 1) {
|
727 | _key = sortedKeys[i];
|
728 | canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
|
729 | }
|
730 |
|
731 | stack.pop();
|
732 | replacementStack.pop();
|
733 | } else {
|
734 | canonicalizedObj = obj;
|
735 | }
|
736 |
|
737 | return canonicalizedObj;
|
738 | }
|
739 |
|
740 | var arrayDiff = new Diff();
|
741 |
|
742 | arrayDiff.tokenize = function (value) {
|
743 | return value.slice();
|
744 | };
|
745 |
|
746 | arrayDiff.join = arrayDiff.removeEmpty = function (value) {
|
747 | return value;
|
748 | };
|
749 |
|
750 | function diffArrays(oldArr, newArr, callback) {
|
751 | return arrayDiff.diff(oldArr, newArr, callback);
|
752 | }
|
753 |
|
754 | function parsePatch(uniDiff) {
|
755 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
756 | var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
|
757 | delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
|
758 | list = [],
|
759 | i = 0;
|
760 |
|
761 | function parseIndex() {
|
762 | var index = {};
|
763 | list.push(index);
|
764 |
|
765 | while (i < diffstr.length) {
|
766 | var line = diffstr[i];
|
767 |
|
768 | if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
|
769 | break;
|
770 | }
|
771 |
|
772 |
|
773 | var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
|
774 |
|
775 | if (header) {
|
776 | index.index = header[1];
|
777 | }
|
778 |
|
779 | i++;
|
780 | }
|
781 |
|
782 |
|
783 |
|
784 | parseFileHeader(index);
|
785 | parseFileHeader(index);
|
786 |
|
787 | index.hunks = [];
|
788 |
|
789 | while (i < diffstr.length) {
|
790 | var _line = diffstr[i];
|
791 |
|
792 | if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
|
793 | break;
|
794 | } else if (/^@@/.test(_line)) {
|
795 | index.hunks.push(parseHunk());
|
796 | } else if (_line && options.strict) {
|
797 |
|
798 | throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
|
799 | } else {
|
800 | i++;
|
801 | }
|
802 | }
|
803 | }
|
804 |
|
805 |
|
806 |
|
807 | function parseFileHeader(index) {
|
808 | var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
|
809 |
|
810 | if (fileHeader) {
|
811 | var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
|
812 | var data = fileHeader[2].split('\t', 2);
|
813 | var fileName = data[0].replace(/\\\\/g, '\\');
|
814 |
|
815 | if (/^".*"$/.test(fileName)) {
|
816 | fileName = fileName.substr(1, fileName.length - 2);
|
817 | }
|
818 |
|
819 | index[keyPrefix + 'FileName'] = fileName;
|
820 | index[keyPrefix + 'Header'] = (data[1] || '').trim();
|
821 | i++;
|
822 | }
|
823 | }
|
824 |
|
825 |
|
826 |
|
827 | function parseHunk() {
|
828 | var chunkHeaderIndex = i,
|
829 | chunkHeaderLine = diffstr[i++],
|
830 | chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
|
831 | var hunk = {
|
832 | oldStart: +chunkHeader[1],
|
833 | oldLines: +chunkHeader[2] || 1,
|
834 | newStart: +chunkHeader[3],
|
835 | newLines: +chunkHeader[4] || 1,
|
836 | lines: [],
|
837 | linedelimiters: []
|
838 | };
|
839 | var addCount = 0,
|
840 | removeCount = 0;
|
841 |
|
842 | for (; i < diffstr.length; i++) {
|
843 |
|
844 |
|
845 | if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
|
846 | break;
|
847 | }
|
848 |
|
849 | var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
|
850 |
|
851 | if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
|
852 | hunk.lines.push(diffstr[i]);
|
853 | hunk.linedelimiters.push(delimiters[i] || '\n');
|
854 |
|
855 | if (operation === '+') {
|
856 | addCount++;
|
857 | } else if (operation === '-') {
|
858 | removeCount++;
|
859 | } else if (operation === ' ') {
|
860 | addCount++;
|
861 | removeCount++;
|
862 | }
|
863 | } else {
|
864 | break;
|
865 | }
|
866 | }
|
867 |
|
868 |
|
869 | if (!addCount && hunk.newLines === 1) {
|
870 | hunk.newLines = 0;
|
871 | }
|
872 |
|
873 | if (!removeCount && hunk.oldLines === 1) {
|
874 | hunk.oldLines = 0;
|
875 | }
|
876 |
|
877 |
|
878 | if (options.strict) {
|
879 | if (addCount !== hunk.newLines) {
|
880 | throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
|
881 | }
|
882 |
|
883 | if (removeCount !== hunk.oldLines) {
|
884 | throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
|
885 | }
|
886 | }
|
887 |
|
888 | return hunk;
|
889 | }
|
890 |
|
891 | while (i < diffstr.length) {
|
892 | parseIndex();
|
893 | }
|
894 |
|
895 | return list;
|
896 | }
|
897 |
|
898 |
|
899 |
|
900 |
|
901 | function distanceIterator(start, minLine, maxLine) {
|
902 | var wantForward = true,
|
903 | backwardExhausted = false,
|
904 | forwardExhausted = false,
|
905 | localOffset = 1;
|
906 | return function iterator() {
|
907 | if (wantForward && !forwardExhausted) {
|
908 | if (backwardExhausted) {
|
909 | localOffset++;
|
910 | } else {
|
911 | wantForward = false;
|
912 | }
|
913 |
|
914 |
|
915 |
|
916 | if (start + localOffset <= maxLine) {
|
917 | return localOffset;
|
918 | }
|
919 |
|
920 | forwardExhausted = true;
|
921 | }
|
922 |
|
923 | if (!backwardExhausted) {
|
924 | if (!forwardExhausted) {
|
925 | wantForward = true;
|
926 | }
|
927 |
|
928 |
|
929 |
|
930 | if (minLine <= start - localOffset) {
|
931 | return -localOffset++;
|
932 | }
|
933 |
|
934 | backwardExhausted = true;
|
935 | return iterator();
|
936 | }
|
937 |
|
938 |
|
939 | };
|
940 | }
|
941 |
|
942 | function applyPatch(source, uniDiff) {
|
943 | var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
944 |
|
945 | if (typeof uniDiff === 'string') {
|
946 | uniDiff = parsePatch(uniDiff);
|
947 | }
|
948 |
|
949 | if (Array.isArray(uniDiff)) {
|
950 | if (uniDiff.length > 1) {
|
951 | throw new Error('applyPatch only works with a single input.');
|
952 | }
|
953 |
|
954 | uniDiff = uniDiff[0];
|
955 | }
|
956 |
|
957 |
|
958 | var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
|
959 | delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
|
960 | hunks = uniDiff.hunks,
|
961 | compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) {
|
962 | return line === patchContent;
|
963 | },
|
964 | errorCount = 0,
|
965 | fuzzFactor = options.fuzzFactor || 0,
|
966 | minLine = 0,
|
967 | offset = 0,
|
968 | removeEOFNL,
|
969 | addEOFNL;
|
970 | |
971 |
|
972 |
|
973 |
|
974 |
|
975 | function hunkFits(hunk, toPos) {
|
976 | for (var j = 0; j < hunk.lines.length; j++) {
|
977 | var line = hunk.lines[j],
|
978 | operation = line.length > 0 ? line[0] : ' ',
|
979 | content = line.length > 0 ? line.substr(1) : line;
|
980 |
|
981 | if (operation === ' ' || operation === '-') {
|
982 |
|
983 | if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
|
984 | errorCount++;
|
985 |
|
986 | if (errorCount > fuzzFactor) {
|
987 | return false;
|
988 | }
|
989 | }
|
990 |
|
991 | toPos++;
|
992 | }
|
993 | }
|
994 |
|
995 | return true;
|
996 | }
|
997 |
|
998 |
|
999 | for (var i = 0; i < hunks.length; i++) {
|
1000 | var hunk = hunks[i],
|
1001 | maxLine = lines.length - hunk.oldLines,
|
1002 | localOffset = 0,
|
1003 | toPos = offset + hunk.oldStart - 1;
|
1004 | var iterator = distanceIterator(toPos, minLine, maxLine);
|
1005 |
|
1006 | for (; localOffset !== undefined; localOffset = iterator()) {
|
1007 | if (hunkFits(hunk, toPos + localOffset)) {
|
1008 | hunk.offset = offset += localOffset;
|
1009 | break;
|
1010 | }
|
1011 | }
|
1012 |
|
1013 | if (localOffset === undefined) {
|
1014 | return false;
|
1015 | }
|
1016 |
|
1017 |
|
1018 |
|
1019 | minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
|
1020 | }
|
1021 |
|
1022 |
|
1023 | var diffOffset = 0;
|
1024 |
|
1025 | for (var _i = 0; _i < hunks.length; _i++) {
|
1026 | var _hunk = hunks[_i],
|
1027 | _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1;
|
1028 |
|
1029 | diffOffset += _hunk.newLines - _hunk.oldLines;
|
1030 |
|
1031 | if (_toPos < 0) {
|
1032 |
|
1033 | _toPos = 0;
|
1034 | }
|
1035 |
|
1036 | for (var j = 0; j < _hunk.lines.length; j++) {
|
1037 | var line = _hunk.lines[j],
|
1038 | operation = line.length > 0 ? line[0] : ' ',
|
1039 | content = line.length > 0 ? line.substr(1) : line,
|
1040 | delimiter = _hunk.linedelimiters[j];
|
1041 |
|
1042 | if (operation === ' ') {
|
1043 | _toPos++;
|
1044 | } else if (operation === '-') {
|
1045 | lines.splice(_toPos, 1);
|
1046 | delimiters.splice(_toPos, 1);
|
1047 |
|
1048 | } else if (operation === '+') {
|
1049 | lines.splice(_toPos, 0, content);
|
1050 | delimiters.splice(_toPos, 0, delimiter);
|
1051 | _toPos++;
|
1052 | } else if (operation === '\\') {
|
1053 | var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
|
1054 |
|
1055 | if (previousOperation === '+') {
|
1056 | removeEOFNL = true;
|
1057 | } else if (previousOperation === '-') {
|
1058 | addEOFNL = true;
|
1059 | }
|
1060 | }
|
1061 | }
|
1062 | }
|
1063 |
|
1064 |
|
1065 | if (removeEOFNL) {
|
1066 | while (!lines[lines.length - 1]) {
|
1067 | lines.pop();
|
1068 | delimiters.pop();
|
1069 | }
|
1070 | } else if (addEOFNL) {
|
1071 | lines.push('');
|
1072 | delimiters.push('\n');
|
1073 | }
|
1074 |
|
1075 | for (var _k = 0; _k < lines.length - 1; _k++) {
|
1076 | lines[_k] = lines[_k] + delimiters[_k];
|
1077 | }
|
1078 |
|
1079 | return lines.join('');
|
1080 | }
|
1081 |
|
1082 |
|
1083 | function applyPatches(uniDiff, options) {
|
1084 | if (typeof uniDiff === 'string') {
|
1085 | uniDiff = parsePatch(uniDiff);
|
1086 | }
|
1087 |
|
1088 | var currentIndex = 0;
|
1089 |
|
1090 | function processIndex() {
|
1091 | var index = uniDiff[currentIndex++];
|
1092 |
|
1093 | if (!index) {
|
1094 | return options.complete();
|
1095 | }
|
1096 |
|
1097 | options.loadFile(index, function (err, data) {
|
1098 | if (err) {
|
1099 | return options.complete(err);
|
1100 | }
|
1101 |
|
1102 | var updatedContent = applyPatch(data, index, options);
|
1103 | options.patched(index, updatedContent, function (err) {
|
1104 | if (err) {
|
1105 | return options.complete(err);
|
1106 | }
|
1107 |
|
1108 | processIndex();
|
1109 | });
|
1110 | });
|
1111 | }
|
1112 |
|
1113 | processIndex();
|
1114 | }
|
1115 |
|
1116 | function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
1117 | if (!options) {
|
1118 | options = {};
|
1119 | }
|
1120 |
|
1121 | if (typeof options.context === 'undefined') {
|
1122 | options.context = 4;
|
1123 | }
|
1124 |
|
1125 | var diff = diffLines(oldStr, newStr, options);
|
1126 | diff.push({
|
1127 | value: '',
|
1128 | lines: []
|
1129 | });
|
1130 |
|
1131 | function contextLines(lines) {
|
1132 | return lines.map(function (entry) {
|
1133 | return ' ' + entry;
|
1134 | });
|
1135 | }
|
1136 |
|
1137 | var hunks = [];
|
1138 | var oldRangeStart = 0,
|
1139 | newRangeStart = 0,
|
1140 | curRange = [],
|
1141 | oldLine = 1,
|
1142 | newLine = 1;
|
1143 |
|
1144 | var _loop = function _loop(i) {
|
1145 | var current = diff[i],
|
1146 | lines = current.lines || current.value.replace(/\n$/, '').split('\n');
|
1147 | current.lines = lines;
|
1148 |
|
1149 | if (current.added || current.removed) {
|
1150 | var _curRange;
|
1151 |
|
1152 |
|
1153 | if (!oldRangeStart) {
|
1154 | var prev = diff[i - 1];
|
1155 | oldRangeStart = oldLine;
|
1156 | newRangeStart = newLine;
|
1157 |
|
1158 | if (prev) {
|
1159 | curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
|
1160 | oldRangeStart -= curRange.length;
|
1161 | newRangeStart -= curRange.length;
|
1162 | }
|
1163 | }
|
1164 |
|
1165 |
|
1166 | (_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function (entry) {
|
1167 | return (current.added ? '+' : '-') + entry;
|
1168 | })));
|
1169 |
|
1170 |
|
1171 | if (current.added) {
|
1172 | newLine += lines.length;
|
1173 | } else {
|
1174 | oldLine += lines.length;
|
1175 | }
|
1176 | } else {
|
1177 |
|
1178 | if (oldRangeStart) {
|
1179 |
|
1180 | if (lines.length <= options.context * 2 && i < diff.length - 2) {
|
1181 | var _curRange2;
|
1182 |
|
1183 |
|
1184 | (_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines)));
|
1185 | } else {
|
1186 | var _curRange3;
|
1187 |
|
1188 |
|
1189 | var contextSize = Math.min(lines.length, options.context);
|
1190 |
|
1191 | (_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize))));
|
1192 |
|
1193 | var hunk = {
|
1194 | oldStart: oldRangeStart,
|
1195 | oldLines: oldLine - oldRangeStart + contextSize,
|
1196 | newStart: newRangeStart,
|
1197 | newLines: newLine - newRangeStart + contextSize,
|
1198 | lines: curRange
|
1199 | };
|
1200 |
|
1201 | if (i >= diff.length - 2 && lines.length <= options.context) {
|
1202 |
|
1203 | var oldEOFNewline = /\n$/.test(oldStr);
|
1204 | var newEOFNewline = /\n$/.test(newStr);
|
1205 | var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
|
1206 |
|
1207 | if (!oldEOFNewline && noNlBeforeAdds) {
|
1208 |
|
1209 | curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
|
1210 | }
|
1211 |
|
1212 | if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
|
1213 | curRange.push('\\ No newline at end of file');
|
1214 | }
|
1215 | }
|
1216 |
|
1217 | hunks.push(hunk);
|
1218 | oldRangeStart = 0;
|
1219 | newRangeStart = 0;
|
1220 | curRange = [];
|
1221 | }
|
1222 | }
|
1223 |
|
1224 | oldLine += lines.length;
|
1225 | newLine += lines.length;
|
1226 | }
|
1227 | };
|
1228 |
|
1229 | for (var i = 0; i < diff.length; i++) {
|
1230 | _loop(i);
|
1231 | }
|
1232 |
|
1233 | return {
|
1234 | oldFileName: oldFileName,
|
1235 | newFileName: newFileName,
|
1236 | oldHeader: oldHeader,
|
1237 | newHeader: newHeader,
|
1238 | hunks: hunks
|
1239 | };
|
1240 | }
|
1241 |
|
1242 | function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
1243 | var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
|
1244 | var ret = [];
|
1245 |
|
1246 | if (oldFileName == newFileName) {
|
1247 | ret.push('Index: ' + oldFileName);
|
1248 | }
|
1249 |
|
1250 | ret.push('===================================================================');
|
1251 | ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
|
1252 | ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
|
1253 |
|
1254 | for (var i = 0; i < diff.hunks.length; i++) {
|
1255 | var hunk = diff.hunks[i];
|
1256 | ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
|
1257 | ret.push.apply(ret, hunk.lines);
|
1258 | }
|
1259 |
|
1260 | return ret.join('\n') + '\n';
|
1261 | }
|
1262 |
|
1263 | function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
|
1264 | return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
|
1265 | }
|
1266 |
|
1267 | function arrayEqual(a, b) {
|
1268 | if (a.length !== b.length) {
|
1269 | return false;
|
1270 | }
|
1271 |
|
1272 | return arrayStartsWith(a, b);
|
1273 | }
|
1274 |
|
1275 | function arrayStartsWith(array, start) {
|
1276 | if (start.length > array.length) {
|
1277 | return false;
|
1278 | }
|
1279 |
|
1280 | for (var i = 0; i < start.length; i++) {
|
1281 | if (start[i] !== array[i]) {
|
1282 | return false;
|
1283 | }
|
1284 | }
|
1285 |
|
1286 | return true;
|
1287 | }
|
1288 |
|
1289 | function calcLineCount(hunk) {
|
1290 | var _calcOldNewLineCount = calcOldNewLineCount(hunk.lines),
|
1291 | oldLines = _calcOldNewLineCount.oldLines,
|
1292 | newLines = _calcOldNewLineCount.newLines;
|
1293 |
|
1294 | if (oldLines !== undefined) {
|
1295 | hunk.oldLines = oldLines;
|
1296 | } else {
|
1297 | delete hunk.oldLines;
|
1298 | }
|
1299 |
|
1300 | if (newLines !== undefined) {
|
1301 | hunk.newLines = newLines;
|
1302 | } else {
|
1303 | delete hunk.newLines;
|
1304 | }
|
1305 | }
|
1306 |
|
1307 | function merge(mine, theirs, base) {
|
1308 | mine = loadPatch(mine, base);
|
1309 | theirs = loadPatch(theirs, base);
|
1310 | var ret = {};
|
1311 |
|
1312 |
|
1313 |
|
1314 | if (mine.index || theirs.index) {
|
1315 | ret.index = mine.index || theirs.index;
|
1316 | }
|
1317 |
|
1318 | if (mine.newFileName || theirs.newFileName) {
|
1319 | if (!fileNameChanged(mine)) {
|
1320 |
|
1321 | ret.oldFileName = theirs.oldFileName || mine.oldFileName;
|
1322 | ret.newFileName = theirs.newFileName || mine.newFileName;
|
1323 | ret.oldHeader = theirs.oldHeader || mine.oldHeader;
|
1324 | ret.newHeader = theirs.newHeader || mine.newHeader;
|
1325 | } else if (!fileNameChanged(theirs)) {
|
1326 |
|
1327 | ret.oldFileName = mine.oldFileName;
|
1328 | ret.newFileName = mine.newFileName;
|
1329 | ret.oldHeader = mine.oldHeader;
|
1330 | ret.newHeader = mine.newHeader;
|
1331 | } else {
|
1332 |
|
1333 | ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName);
|
1334 | ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName);
|
1335 | ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader);
|
1336 | ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
|
1337 | }
|
1338 | }
|
1339 |
|
1340 | ret.hunks = [];
|
1341 | var mineIndex = 0,
|
1342 | theirsIndex = 0,
|
1343 | mineOffset = 0,
|
1344 | theirsOffset = 0;
|
1345 |
|
1346 | while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
|
1347 | var mineCurrent = mine.hunks[mineIndex] || {
|
1348 | oldStart: Infinity
|
1349 | },
|
1350 | theirsCurrent = theirs.hunks[theirsIndex] || {
|
1351 | oldStart: Infinity
|
1352 | };
|
1353 |
|
1354 | if (hunkBefore(mineCurrent, theirsCurrent)) {
|
1355 |
|
1356 | ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
|
1357 | mineIndex++;
|
1358 | theirsOffset += mineCurrent.newLines - mineCurrent.oldLines;
|
1359 | } else if (hunkBefore(theirsCurrent, mineCurrent)) {
|
1360 |
|
1361 | ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset));
|
1362 | theirsIndex++;
|
1363 | mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines;
|
1364 | } else {
|
1365 |
|
1366 | var mergedHunk = {
|
1367 | oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart),
|
1368 | oldLines: 0,
|
1369 | newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset),
|
1370 | newLines: 0,
|
1371 | lines: []
|
1372 | };
|
1373 | mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines);
|
1374 | theirsIndex++;
|
1375 | mineIndex++;
|
1376 | ret.hunks.push(mergedHunk);
|
1377 | }
|
1378 | }
|
1379 |
|
1380 | return ret;
|
1381 | }
|
1382 |
|
1383 | function loadPatch(param, base) {
|
1384 | if (typeof param === 'string') {
|
1385 | if (/^@@/m.test(param) || /^Index:/m.test(param)) {
|
1386 | return parsePatch(param)[0];
|
1387 | }
|
1388 |
|
1389 | if (!base) {
|
1390 | throw new Error('Must provide a base reference or pass in a patch');
|
1391 | }
|
1392 |
|
1393 | return structuredPatch(undefined, undefined, base, param);
|
1394 | }
|
1395 |
|
1396 | return param;
|
1397 | }
|
1398 |
|
1399 | function fileNameChanged(patch) {
|
1400 | return patch.newFileName && patch.newFileName !== patch.oldFileName;
|
1401 | }
|
1402 |
|
1403 | function selectField(index, mine, theirs) {
|
1404 | if (mine === theirs) {
|
1405 | return mine;
|
1406 | } else {
|
1407 | index.conflict = true;
|
1408 | return {
|
1409 | mine: mine,
|
1410 | theirs: theirs
|
1411 | };
|
1412 | }
|
1413 | }
|
1414 |
|
1415 | function hunkBefore(test, check) {
|
1416 | return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
|
1417 | }
|
1418 |
|
1419 | function cloneHunk(hunk, offset) {
|
1420 | return {
|
1421 | oldStart: hunk.oldStart,
|
1422 | oldLines: hunk.oldLines,
|
1423 | newStart: hunk.newStart + offset,
|
1424 | newLines: hunk.newLines,
|
1425 | lines: hunk.lines
|
1426 | };
|
1427 | }
|
1428 |
|
1429 | function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
|
1430 |
|
1431 |
|
1432 | var mine = {
|
1433 | offset: mineOffset,
|
1434 | lines: mineLines,
|
1435 | index: 0
|
1436 | },
|
1437 | their = {
|
1438 | offset: theirOffset,
|
1439 | lines: theirLines,
|
1440 | index: 0
|
1441 | };
|
1442 |
|
1443 | insertLeading(hunk, mine, their);
|
1444 | insertLeading(hunk, their, mine);
|
1445 |
|
1446 | while (mine.index < mine.lines.length && their.index < their.lines.length) {
|
1447 | var mineCurrent = mine.lines[mine.index],
|
1448 | theirCurrent = their.lines[their.index];
|
1449 |
|
1450 | if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
|
1451 |
|
1452 | mutualChange(hunk, mine, their);
|
1453 | } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
|
1454 | var _hunk$lines;
|
1455 |
|
1456 |
|
1457 | (_hunk$lines = hunk.lines).push.apply(_hunk$lines, _toConsumableArray(collectChange(mine)));
|
1458 | } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
|
1459 | var _hunk$lines2;
|
1460 |
|
1461 |
|
1462 | (_hunk$lines2 = hunk.lines).push.apply(_hunk$lines2, _toConsumableArray(collectChange(their)));
|
1463 | } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') {
|
1464 |
|
1465 | removal(hunk, mine, their);
|
1466 | } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') {
|
1467 |
|
1468 | removal(hunk, their, mine, true);
|
1469 | } else if (mineCurrent === theirCurrent) {
|
1470 |
|
1471 | hunk.lines.push(mineCurrent);
|
1472 | mine.index++;
|
1473 | their.index++;
|
1474 | } else {
|
1475 |
|
1476 | conflict(hunk, collectChange(mine), collectChange(their));
|
1477 | }
|
1478 | }
|
1479 |
|
1480 |
|
1481 | insertTrailing(hunk, mine);
|
1482 | insertTrailing(hunk, their);
|
1483 | calcLineCount(hunk);
|
1484 | }
|
1485 |
|
1486 | function mutualChange(hunk, mine, their) {
|
1487 | var myChanges = collectChange(mine),
|
1488 | theirChanges = collectChange(their);
|
1489 |
|
1490 | if (allRemoves(myChanges) && allRemoves(theirChanges)) {
|
1491 |
|
1492 | if (arrayStartsWith(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
|
1493 | var _hunk$lines3;
|
1494 |
|
1495 | (_hunk$lines3 = hunk.lines).push.apply(_hunk$lines3, _toConsumableArray(myChanges));
|
1496 |
|
1497 | return;
|
1498 | } else if (arrayStartsWith(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
|
1499 | var _hunk$lines4;
|
1500 |
|
1501 | (_hunk$lines4 = hunk.lines).push.apply(_hunk$lines4, _toConsumableArray(theirChanges));
|
1502 |
|
1503 | return;
|
1504 | }
|
1505 | } else if (arrayEqual(myChanges, theirChanges)) {
|
1506 | var _hunk$lines5;
|
1507 |
|
1508 | (_hunk$lines5 = hunk.lines).push.apply(_hunk$lines5, _toConsumableArray(myChanges));
|
1509 |
|
1510 | return;
|
1511 | }
|
1512 |
|
1513 | conflict(hunk, myChanges, theirChanges);
|
1514 | }
|
1515 |
|
1516 | function removal(hunk, mine, their, swap) {
|
1517 | var myChanges = collectChange(mine),
|
1518 | theirChanges = collectContext(their, myChanges);
|
1519 |
|
1520 | if (theirChanges.merged) {
|
1521 | var _hunk$lines6;
|
1522 |
|
1523 | (_hunk$lines6 = hunk.lines).push.apply(_hunk$lines6, _toConsumableArray(theirChanges.merged));
|
1524 | } else {
|
1525 | conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
|
1526 | }
|
1527 | }
|
1528 |
|
1529 | function conflict(hunk, mine, their) {
|
1530 | hunk.conflict = true;
|
1531 | hunk.lines.push({
|
1532 | conflict: true,
|
1533 | mine: mine,
|
1534 | theirs: their
|
1535 | });
|
1536 | }
|
1537 |
|
1538 | function insertLeading(hunk, insert, their) {
|
1539 | while (insert.offset < their.offset && insert.index < insert.lines.length) {
|
1540 | var line = insert.lines[insert.index++];
|
1541 | hunk.lines.push(line);
|
1542 | insert.offset++;
|
1543 | }
|
1544 | }
|
1545 |
|
1546 | function insertTrailing(hunk, insert) {
|
1547 | while (insert.index < insert.lines.length) {
|
1548 | var line = insert.lines[insert.index++];
|
1549 | hunk.lines.push(line);
|
1550 | }
|
1551 | }
|
1552 |
|
1553 | function collectChange(state) {
|
1554 | var ret = [],
|
1555 | operation = state.lines[state.index][0];
|
1556 |
|
1557 | while (state.index < state.lines.length) {
|
1558 | var line = state.lines[state.index];
|
1559 |
|
1560 | if (operation === '-' && line[0] === '+') {
|
1561 | operation = '+';
|
1562 | }
|
1563 |
|
1564 | if (operation === line[0]) {
|
1565 | ret.push(line);
|
1566 | state.index++;
|
1567 | } else {
|
1568 | break;
|
1569 | }
|
1570 | }
|
1571 |
|
1572 | return ret;
|
1573 | }
|
1574 |
|
1575 | function collectContext(state, matchChanges) {
|
1576 | var changes = [],
|
1577 | merged = [],
|
1578 | matchIndex = 0,
|
1579 | contextChanges = false,
|
1580 | conflicted = false;
|
1581 |
|
1582 | while (matchIndex < matchChanges.length && state.index < state.lines.length) {
|
1583 | var change = state.lines[state.index],
|
1584 | match = matchChanges[matchIndex];
|
1585 |
|
1586 | if (match[0] === '+') {
|
1587 | break;
|
1588 | }
|
1589 |
|
1590 | contextChanges = contextChanges || change[0] !== ' ';
|
1591 | merged.push(match);
|
1592 | matchIndex++;
|
1593 |
|
1594 |
|
1595 | if (change[0] === '+') {
|
1596 | conflicted = true;
|
1597 |
|
1598 | while (change[0] === '+') {
|
1599 | changes.push(change);
|
1600 | change = state.lines[++state.index];
|
1601 | }
|
1602 | }
|
1603 |
|
1604 | if (match.substr(1) === change.substr(1)) {
|
1605 | changes.push(change);
|
1606 | state.index++;
|
1607 | } else {
|
1608 | conflicted = true;
|
1609 | }
|
1610 | }
|
1611 |
|
1612 | if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
|
1613 | conflicted = true;
|
1614 | }
|
1615 |
|
1616 | if (conflicted) {
|
1617 | return changes;
|
1618 | }
|
1619 |
|
1620 | while (matchIndex < matchChanges.length) {
|
1621 | merged.push(matchChanges[matchIndex++]);
|
1622 | }
|
1623 |
|
1624 | return {
|
1625 | merged: merged,
|
1626 | changes: changes
|
1627 | };
|
1628 | }
|
1629 |
|
1630 | function allRemoves(changes) {
|
1631 | return changes.reduce(function (prev, change) {
|
1632 | return prev && change[0] === '-';
|
1633 | }, true);
|
1634 | }
|
1635 |
|
1636 | function skipRemoveSuperset(state, removeChanges, delta) {
|
1637 | for (var i = 0; i < delta; i++) {
|
1638 | var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
|
1639 |
|
1640 | if (state.lines[state.index + i] !== ' ' + changeContent) {
|
1641 | return false;
|
1642 | }
|
1643 | }
|
1644 |
|
1645 | state.index += delta;
|
1646 | return true;
|
1647 | }
|
1648 |
|
1649 | function calcOldNewLineCount(lines) {
|
1650 | var oldLines = 0;
|
1651 | var newLines = 0;
|
1652 | lines.forEach(function (line) {
|
1653 | if (typeof line !== 'string') {
|
1654 | var myCount = calcOldNewLineCount(line.mine);
|
1655 | var theirCount = calcOldNewLineCount(line.theirs);
|
1656 |
|
1657 | if (oldLines !== undefined) {
|
1658 | if (myCount.oldLines === theirCount.oldLines) {
|
1659 | oldLines += myCount.oldLines;
|
1660 | } else {
|
1661 | oldLines = undefined;
|
1662 | }
|
1663 | }
|
1664 |
|
1665 | if (newLines !== undefined) {
|
1666 | if (myCount.newLines === theirCount.newLines) {
|
1667 | newLines += myCount.newLines;
|
1668 | } else {
|
1669 | newLines = undefined;
|
1670 | }
|
1671 | }
|
1672 | } else {
|
1673 | if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
|
1674 | newLines++;
|
1675 | }
|
1676 |
|
1677 | if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
|
1678 | oldLines++;
|
1679 | }
|
1680 | }
|
1681 | });
|
1682 | return {
|
1683 | oldLines: oldLines,
|
1684 | newLines: newLines
|
1685 | };
|
1686 | }
|
1687 |
|
1688 |
|
1689 | function convertChangesToDMP(changes) {
|
1690 | var ret = [],
|
1691 | change,
|
1692 | operation;
|
1693 |
|
1694 | for (var i = 0; i < changes.length; i++) {
|
1695 | change = changes[i];
|
1696 |
|
1697 | if (change.added) {
|
1698 | operation = 1;
|
1699 | } else if (change.removed) {
|
1700 | operation = -1;
|
1701 | } else {
|
1702 | operation = 0;
|
1703 | }
|
1704 |
|
1705 | ret.push([operation, change.value]);
|
1706 | }
|
1707 |
|
1708 | return ret;
|
1709 | }
|
1710 |
|
1711 | function convertChangesToXML(changes) {
|
1712 | var ret = [];
|
1713 |
|
1714 | for (var i = 0; i < changes.length; i++) {
|
1715 | var change = changes[i];
|
1716 |
|
1717 | if (change.added) {
|
1718 | ret.push('<ins>');
|
1719 | } else if (change.removed) {
|
1720 | ret.push('<del>');
|
1721 | }
|
1722 |
|
1723 | ret.push(escapeHTML(change.value));
|
1724 |
|
1725 | if (change.added) {
|
1726 | ret.push('</ins>');
|
1727 | } else if (change.removed) {
|
1728 | ret.push('</del>');
|
1729 | }
|
1730 | }
|
1731 |
|
1732 | return ret.join('');
|
1733 | }
|
1734 |
|
1735 | function escapeHTML(s) {
|
1736 | var n = s;
|
1737 | n = n.replace(/&/g, '&');
|
1738 | n = n.replace(/</g, '<');
|
1739 | n = n.replace(/>/g, '>');
|
1740 | n = n.replace(/"/g, '"');
|
1741 | return n;
|
1742 | }
|
1743 |
|
1744 | var index_es6 = Object.freeze({
|
1745 | __proto__: null,
|
1746 | Diff: Diff,
|
1747 | diffChars: diffChars,
|
1748 | diffWords: diffWords,
|
1749 | diffWordsWithSpace: diffWordsWithSpace,
|
1750 | diffLines: diffLines,
|
1751 | diffTrimmedLines: diffTrimmedLines,
|
1752 | diffSentences: diffSentences,
|
1753 | diffCss: diffCss,
|
1754 | diffJson: diffJson,
|
1755 | diffArrays: diffArrays,
|
1756 | structuredPatch: structuredPatch,
|
1757 | createTwoFilesPatch: createTwoFilesPatch,
|
1758 | createPatch: createPatch,
|
1759 | applyPatch: applyPatch,
|
1760 | applyPatches: applyPatches,
|
1761 | parsePatch: parsePatch,
|
1762 | merge: merge,
|
1763 | convertChangesToDMP: convertChangesToDMP,
|
1764 | convertChangesToXML: convertChangesToXML,
|
1765 | canonicalize: canonicalize
|
1766 | });
|
1767 |
|
1768 |
|
1769 |
|
1770 |
|
1771 |
|
1772 |
|
1773 | class LineByLine {
|
1774 | constructor(file, options) {
|
1775 | options = options || {};
|
1776 | if (!options.readChunk) options.readChunk = 1024;
|
1777 |
|
1778 | if (!options.newLineCharacter) {
|
1779 | options.newLineCharacter = 0x0a;
|
1780 | } else {
|
1781 | options.newLineCharacter = options.newLineCharacter.charCodeAt(0);
|
1782 | }
|
1783 |
|
1784 | if (typeof file === 'number') {
|
1785 | this.fd = file;
|
1786 | } else {
|
1787 | this.fd = fs$3.openSync(file, 'r');
|
1788 | }
|
1789 |
|
1790 | this.options = options;
|
1791 | this.newLineCharacter = options.newLineCharacter;
|
1792 | this.reset();
|
1793 | }
|
1794 |
|
1795 | _searchInBuffer(buffer, hexNeedle) {
|
1796 | let found = -1;
|
1797 |
|
1798 | for (let i = 0; i <= buffer.length; i++) {
|
1799 | let b_byte = buffer[i];
|
1800 |
|
1801 | if (b_byte === hexNeedle) {
|
1802 | found = i;
|
1803 | break;
|
1804 | }
|
1805 | }
|
1806 |
|
1807 | return found;
|
1808 | }
|
1809 |
|
1810 | reset() {
|
1811 | this.eofReached = false;
|
1812 | this.linesCache = [];
|
1813 | this.fdPosition = 0;
|
1814 | }
|
1815 |
|
1816 | close() {
|
1817 | fs$3.closeSync(this.fd);
|
1818 | this.fd = null;
|
1819 | }
|
1820 |
|
1821 | _extractLines(buffer) {
|
1822 | let line;
|
1823 | const lines = [];
|
1824 | let bufferPosition = 0;
|
1825 | let lastNewLineBufferPosition = 0;
|
1826 |
|
1827 | while (true) {
|
1828 | let bufferPositionValue = buffer[bufferPosition++];
|
1829 |
|
1830 | if (bufferPositionValue === this.newLineCharacter) {
|
1831 | line = buffer.slice(lastNewLineBufferPosition, bufferPosition);
|
1832 | lines.push(line);
|
1833 | lastNewLineBufferPosition = bufferPosition;
|
1834 | } else if (!bufferPositionValue) {
|
1835 | break;
|
1836 | }
|
1837 | }
|
1838 |
|
1839 | let leftovers = buffer.slice(lastNewLineBufferPosition, bufferPosition);
|
1840 |
|
1841 | if (leftovers.length) {
|
1842 | lines.push(leftovers);
|
1843 | }
|
1844 |
|
1845 | return lines;
|
1846 | }
|
1847 |
|
1848 | _readChunk(lineLeftovers) {
|
1849 | let totalBytesRead = 0;
|
1850 | let bytesRead;
|
1851 | const buffers = [];
|
1852 |
|
1853 | do {
|
1854 | const readBuffer = new Buffer(this.options.readChunk);
|
1855 | bytesRead = fs$3.readSync(this.fd, readBuffer, 0, this.options.readChunk, this.fdPosition);
|
1856 | totalBytesRead = totalBytesRead + bytesRead;
|
1857 | this.fdPosition = this.fdPosition + bytesRead;
|
1858 | buffers.push(readBuffer);
|
1859 | } while (bytesRead && this._searchInBuffer(buffers[buffers.length - 1], this.options.newLineCharacter) === -1);
|
1860 |
|
1861 | let bufferData = Buffer.concat(buffers);
|
1862 |
|
1863 | if (bytesRead < this.options.readChunk) {
|
1864 | this.eofReached = true;
|
1865 | bufferData = bufferData.slice(0, totalBytesRead);
|
1866 | }
|
1867 |
|
1868 | if (totalBytesRead) {
|
1869 | this.linesCache = this._extractLines(bufferData);
|
1870 |
|
1871 | if (lineLeftovers) {
|
1872 | this.linesCache[0] = Buffer.concat([lineLeftovers, this.linesCache[0]]);
|
1873 | }
|
1874 | }
|
1875 |
|
1876 | return totalBytesRead;
|
1877 | }
|
1878 |
|
1879 | next() {
|
1880 | if (!this.fd) return false;
|
1881 | let line = false;
|
1882 |
|
1883 | if (this.eofReached && this.linesCache.length === 0) {
|
1884 | return line;
|
1885 | }
|
1886 |
|
1887 | let bytesRead;
|
1888 |
|
1889 | if (!this.linesCache.length) {
|
1890 | bytesRead = this._readChunk();
|
1891 | }
|
1892 |
|
1893 | if (this.linesCache.length) {
|
1894 | line = this.linesCache.shift();
|
1895 | const lastLineCharacter = line[line.length - 1];
|
1896 |
|
1897 | if (lastLineCharacter !== 0x0a) {
|
1898 | bytesRead = this._readChunk(line);
|
1899 |
|
1900 | if (bytesRead) {
|
1901 | line = this.linesCache.shift();
|
1902 | }
|
1903 | }
|
1904 | }
|
1905 |
|
1906 | if (this.eofReached && this.linesCache.length === 0) {
|
1907 | this.close();
|
1908 | }
|
1909 |
|
1910 | if (line && line[line.length - 1] === this.newLineCharacter) {
|
1911 | line = line.slice(0, line.length - 1);
|
1912 | }
|
1913 |
|
1914 | return line;
|
1915 | }
|
1916 |
|
1917 | }
|
1918 |
|
1919 | var readlines = LineByLine;
|
1920 |
|
1921 |
|
1922 |
|
1923 |
|
1924 |
|
1925 |
|
1926 |
|
1927 |
|
1928 |
|
1929 |
|
1930 |
|
1931 |
|
1932 |
|
1933 |
|
1934 |
|
1935 |
|
1936 | function fromPairs(pairs) {
|
1937 | var index = -1,
|
1938 | length = pairs == null ? 0 : pairs.length,
|
1939 | result = {};
|
1940 |
|
1941 | while (++index < length) {
|
1942 | var pair = pairs[index];
|
1943 | result[pair[0]] = pair[1];
|
1944 | }
|
1945 |
|
1946 | return result;
|
1947 | }
|
1948 |
|
1949 | var fromPairs_1 = fromPairs;
|
1950 |
|
1951 | class ConfigError extends Error {}
|
1952 |
|
1953 | class DebugError extends Error {}
|
1954 |
|
1955 | class UndefinedParserError extends Error {}
|
1956 |
|
1957 | var errors = {
|
1958 | ConfigError,
|
1959 | DebugError,
|
1960 | UndefinedParserError
|
1961 | };
|
1962 |
|
1963 | function _objectWithoutPropertiesLoose(source, excluded) {
|
1964 | if (source == null) return {};
|
1965 | var target = {};
|
1966 | var sourceKeys = Object.keys(source);
|
1967 | var key, i;
|
1968 |
|
1969 | for (i = 0; i < sourceKeys.length; i++) {
|
1970 | key = sourceKeys[i];
|
1971 | if (excluded.indexOf(key) >= 0) continue;
|
1972 | target[key] = source[key];
|
1973 | }
|
1974 |
|
1975 | return target;
|
1976 | }
|
1977 |
|
1978 | const debug = typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error('SEMVER', ...args) : () => {};
|
1979 | var debug_1 = debug;
|
1980 |
|
1981 |
|
1982 |
|
1983 | const SEMVER_SPEC_VERSION = '2.0.0';
|
1984 | const MAX_LENGTH = 256;
|
1985 | const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
1986 |
|
1987 | 9007199254740991;
|
1988 |
|
1989 | const MAX_SAFE_COMPONENT_LENGTH = 16;
|
1990 | var constants = {
|
1991 | SEMVER_SPEC_VERSION,
|
1992 | MAX_LENGTH,
|
1993 | MAX_SAFE_INTEGER,
|
1994 | MAX_SAFE_COMPONENT_LENGTH
|
1995 | };
|
1996 |
|
1997 | function unwrapExports (x) {
|
1998 | return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
1999 | }
|
2000 |
|
2001 | function createCommonjsModule(fn, module) {
|
2002 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
2003 | }
|
2004 |
|
2005 | function getCjsExportFromNamespace (n) {
|
2006 | return n && n['default'] || n;
|
2007 | }
|
2008 |
|
2009 | var re_1 = createCommonjsModule(function (module, exports) {
|
2010 | const {
|
2011 | MAX_SAFE_COMPONENT_LENGTH
|
2012 | } = constants;
|
2013 | exports = module.exports = {};
|
2014 |
|
2015 | const re = exports.re = [];
|
2016 | const src = exports.src = [];
|
2017 | const t = exports.t = {};
|
2018 | let R = 0;
|
2019 |
|
2020 | const createToken = (name, value, isGlobal) => {
|
2021 | const index = R++;
|
2022 | debug_1(index, value);
|
2023 | t[name] = index;
|
2024 | src[index] = value;
|
2025 | re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
|
2026 | };
|
2027 |
|
2028 |
|
2029 |
|
2030 |
|
2031 |
|
2032 | createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
|
2033 | createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
|
2034 |
|
2035 |
|
2036 |
|
2037 | createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
|
2038 |
|
2039 |
|
2040 | createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})`);
|
2041 | createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
2042 |
|
2043 |
|
2044 | createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`);
|
2045 | createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`);
|
2046 |
|
2047 |
|
2048 |
|
2049 | createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
2050 | createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
2051 |
|
2052 |
|
2053 | createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
|
2054 |
|
2055 |
|
2056 |
|
2057 | createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
2058 |
|
2059 |
|
2060 |
|
2061 |
|
2062 |
|
2063 |
|
2064 |
|
2065 | createToken('FULLPLAIN', `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
2066 | createToken('FULL', `^${src[t.FULLPLAIN]}$`);
|
2067 |
|
2068 |
|
2069 |
|
2070 | createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
2071 | createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
|
2072 | createToken('GTLT', '((?:<|>)?=?)');
|
2073 |
|
2074 |
|
2075 |
|
2076 | createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
2077 | createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
2078 | createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?` + `)?)?`);
|
2079 | createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?` + `)?)?`);
|
2080 | createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
2081 | createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
2082 |
|
2083 |
|
2084 | createToken('COERCE', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:$|[^\\d])`);
|
2085 | createToken('COERCERTL', src[t.COERCE], true);
|
2086 |
|
2087 |
|
2088 | createToken('LONETILDE', '(?:~>?)');
|
2089 | createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
2090 | exports.tildeTrimReplace = '$1~';
|
2091 | createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
2092 | createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
2093 |
|
2094 |
|
2095 | createToken('LONECARET', '(?:\\^)');
|
2096 | createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
2097 | exports.caretTrimReplace = '$1^';
|
2098 | createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
2099 | createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
2100 |
|
2101 | createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
2102 | createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
2103 |
|
2104 |
|
2105 | createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
2106 | exports.comparatorTrimReplace = '$1$2$3';
|
2107 |
|
2108 |
|
2109 |
|
2110 |
|
2111 | createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAIN]})` + `\\s*$`);
|
2112 | createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAINLOOSE]})` + `\\s*$`);
|
2113 |
|
2114 | createToken('STAR', '(<|>)?=?\\s*\\*');
|
2115 | });
|
2116 | var re_2 = re_1.re;
|
2117 | var re_3 = re_1.src;
|
2118 | var re_4 = re_1.t;
|
2119 | var re_5 = re_1.tildeTrimReplace;
|
2120 | var re_6 = re_1.caretTrimReplace;
|
2121 | var re_7 = re_1.comparatorTrimReplace;
|
2122 |
|
2123 | const numeric = /^[0-9]+$/;
|
2124 |
|
2125 | const compareIdentifiers = (a, b) => {
|
2126 | const anum = numeric.test(a);
|
2127 | const bnum = numeric.test(b);
|
2128 |
|
2129 | if (anum && bnum) {
|
2130 | a = +a;
|
2131 | b = +b;
|
2132 | }
|
2133 |
|
2134 | return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
2135 | };
|
2136 |
|
2137 | const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
2138 |
|
2139 | var identifiers = {
|
2140 | compareIdentifiers,
|
2141 | rcompareIdentifiers
|
2142 | };
|
2143 |
|
2144 | const {
|
2145 | MAX_LENGTH: MAX_LENGTH$1,
|
2146 | MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1
|
2147 | } = constants;
|
2148 | const {
|
2149 | re,
|
2150 | t
|
2151 | } = re_1;
|
2152 | const {
|
2153 | compareIdentifiers: compareIdentifiers$1
|
2154 | } = identifiers;
|
2155 |
|
2156 | class SemVer {
|
2157 | constructor(version, options) {
|
2158 | if (!options || typeof options !== 'object') {
|
2159 | options = {
|
2160 | loose: !!options,
|
2161 | includePrerelease: false
|
2162 | };
|
2163 | }
|
2164 |
|
2165 | if (version instanceof SemVer) {
|
2166 | if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
|
2167 | return version;
|
2168 | } else {
|
2169 | version = version.version;
|
2170 | }
|
2171 | } else if (typeof version !== 'string') {
|
2172 | throw new TypeError(`Invalid Version: ${version}`);
|
2173 | }
|
2174 |
|
2175 | if (version.length > MAX_LENGTH$1) {
|
2176 | throw new TypeError(`version is longer than ${MAX_LENGTH$1} characters`);
|
2177 | }
|
2178 |
|
2179 | debug_1('SemVer', version, options);
|
2180 | this.options = options;
|
2181 | this.loose = !!options.loose;
|
2182 |
|
2183 |
|
2184 | this.includePrerelease = !!options.includePrerelease;
|
2185 | const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
2186 |
|
2187 | if (!m) {
|
2188 | throw new TypeError(`Invalid Version: ${version}`);
|
2189 | }
|
2190 |
|
2191 | this.raw = version;
|
2192 |
|
2193 | this.major = +m[1];
|
2194 | this.minor = +m[2];
|
2195 | this.patch = +m[3];
|
2196 |
|
2197 | if (this.major > MAX_SAFE_INTEGER$1 || this.major < 0) {
|
2198 | throw new TypeError('Invalid major version');
|
2199 | }
|
2200 |
|
2201 | if (this.minor > MAX_SAFE_INTEGER$1 || this.minor < 0) {
|
2202 | throw new TypeError('Invalid minor version');
|
2203 | }
|
2204 |
|
2205 | if (this.patch > MAX_SAFE_INTEGER$1 || this.patch < 0) {
|
2206 | throw new TypeError('Invalid patch version');
|
2207 | }
|
2208 |
|
2209 |
|
2210 | if (!m[4]) {
|
2211 | this.prerelease = [];
|
2212 | } else {
|
2213 | this.prerelease = m[4].split('.').map(id => {
|
2214 | if (/^[0-9]+$/.test(id)) {
|
2215 | const num = +id;
|
2216 |
|
2217 | if (num >= 0 && num < MAX_SAFE_INTEGER$1) {
|
2218 | return num;
|
2219 | }
|
2220 | }
|
2221 |
|
2222 | return id;
|
2223 | });
|
2224 | }
|
2225 |
|
2226 | this.build = m[5] ? m[5].split('.') : [];
|
2227 | this.format();
|
2228 | }
|
2229 |
|
2230 | format() {
|
2231 | this.version = `${this.major}.${this.minor}.${this.patch}`;
|
2232 |
|
2233 | if (this.prerelease.length) {
|
2234 | this.version += `-${this.prerelease.join('.')}`;
|
2235 | }
|
2236 |
|
2237 | return this.version;
|
2238 | }
|
2239 |
|
2240 | toString() {
|
2241 | return this.version;
|
2242 | }
|
2243 |
|
2244 | compare(other) {
|
2245 | debug_1('SemVer.compare', this.version, this.options, other);
|
2246 |
|
2247 | if (!(other instanceof SemVer)) {
|
2248 | if (typeof other === 'string' && other === this.version) {
|
2249 | return 0;
|
2250 | }
|
2251 |
|
2252 | other = new SemVer(other, this.options);
|
2253 | }
|
2254 |
|
2255 | if (other.version === this.version) {
|
2256 | return 0;
|
2257 | }
|
2258 |
|
2259 | return this.compareMain(other) || this.comparePre(other);
|
2260 | }
|
2261 |
|
2262 | compareMain(other) {
|
2263 | if (!(other instanceof SemVer)) {
|
2264 | other = new SemVer(other, this.options);
|
2265 | }
|
2266 |
|
2267 | return compareIdentifiers$1(this.major, other.major) || compareIdentifiers$1(this.minor, other.minor) || compareIdentifiers$1(this.patch, other.patch);
|
2268 | }
|
2269 |
|
2270 | comparePre(other) {
|
2271 | if (!(other instanceof SemVer)) {
|
2272 | other = new SemVer(other, this.options);
|
2273 | }
|
2274 |
|
2275 |
|
2276 | if (this.prerelease.length && !other.prerelease.length) {
|
2277 | return -1;
|
2278 | } else if (!this.prerelease.length && other.prerelease.length) {
|
2279 | return 1;
|
2280 | } else if (!this.prerelease.length && !other.prerelease.length) {
|
2281 | return 0;
|
2282 | }
|
2283 |
|
2284 | let i = 0;
|
2285 |
|
2286 | do {
|
2287 | const a = this.prerelease[i];
|
2288 | const b = other.prerelease[i];
|
2289 | debug_1('prerelease compare', i, a, b);
|
2290 |
|
2291 | if (a === undefined && b === undefined) {
|
2292 | return 0;
|
2293 | } else if (b === undefined) {
|
2294 | return 1;
|
2295 | } else if (a === undefined) {
|
2296 | return -1;
|
2297 | } else if (a === b) {
|
2298 | continue;
|
2299 | } else {
|
2300 | return compareIdentifiers$1(a, b);
|
2301 | }
|
2302 | } while (++i);
|
2303 | }
|
2304 |
|
2305 | compareBuild(other) {
|
2306 | if (!(other instanceof SemVer)) {
|
2307 | other = new SemVer(other, this.options);
|
2308 | }
|
2309 |
|
2310 | let i = 0;
|
2311 |
|
2312 | do {
|
2313 | const a = this.build[i];
|
2314 | const b = other.build[i];
|
2315 | debug_1('prerelease compare', i, a, b);
|
2316 |
|
2317 | if (a === undefined && b === undefined) {
|
2318 | return 0;
|
2319 | } else if (b === undefined) {
|
2320 | return 1;
|
2321 | } else if (a === undefined) {
|
2322 | return -1;
|
2323 | } else if (a === b) {
|
2324 | continue;
|
2325 | } else {
|
2326 | return compareIdentifiers$1(a, b);
|
2327 | }
|
2328 | } while (++i);
|
2329 | }
|
2330 |
|
2331 |
|
2332 |
|
2333 | inc(release, identifier) {
|
2334 | switch (release) {
|
2335 | case 'premajor':
|
2336 | this.prerelease.length = 0;
|
2337 | this.patch = 0;
|
2338 | this.minor = 0;
|
2339 | this.major++;
|
2340 | this.inc('pre', identifier);
|
2341 | break;
|
2342 |
|
2343 | case 'preminor':
|
2344 | this.prerelease.length = 0;
|
2345 | this.patch = 0;
|
2346 | this.minor++;
|
2347 | this.inc('pre', identifier);
|
2348 | break;
|
2349 |
|
2350 | case 'prepatch':
|
2351 |
|
2352 |
|
2353 |
|
2354 | this.prerelease.length = 0;
|
2355 | this.inc('patch', identifier);
|
2356 | this.inc('pre', identifier);
|
2357 | break;
|
2358 |
|
2359 |
|
2360 |
|
2361 | case 'prerelease':
|
2362 | if (this.prerelease.length === 0) {
|
2363 | this.inc('patch', identifier);
|
2364 | }
|
2365 |
|
2366 | this.inc('pre', identifier);
|
2367 | break;
|
2368 |
|
2369 | case 'major':
|
2370 |
|
2371 |
|
2372 |
|
2373 |
|
2374 | if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
|
2375 | this.major++;
|
2376 | }
|
2377 |
|
2378 | this.minor = 0;
|
2379 | this.patch = 0;
|
2380 | this.prerelease = [];
|
2381 | break;
|
2382 |
|
2383 | case 'minor':
|
2384 |
|
2385 |
|
2386 |
|
2387 |
|
2388 | if (this.patch !== 0 || this.prerelease.length === 0) {
|
2389 | this.minor++;
|
2390 | }
|
2391 |
|
2392 | this.patch = 0;
|
2393 | this.prerelease = [];
|
2394 | break;
|
2395 |
|
2396 | case 'patch':
|
2397 |
|
2398 |
|
2399 |
|
2400 |
|
2401 | if (this.prerelease.length === 0) {
|
2402 | this.patch++;
|
2403 | }
|
2404 |
|
2405 | this.prerelease = [];
|
2406 | break;
|
2407 |
|
2408 |
|
2409 |
|
2410 | case 'pre':
|
2411 | if (this.prerelease.length === 0) {
|
2412 | this.prerelease = [0];
|
2413 | } else {
|
2414 | let i = this.prerelease.length;
|
2415 |
|
2416 | while (--i >= 0) {
|
2417 | if (typeof this.prerelease[i] === 'number') {
|
2418 | this.prerelease[i]++;
|
2419 | i = -2;
|
2420 | }
|
2421 | }
|
2422 |
|
2423 | if (i === -1) {
|
2424 |
|
2425 | this.prerelease.push(0);
|
2426 | }
|
2427 | }
|
2428 |
|
2429 | if (identifier) {
|
2430 |
|
2431 |
|
2432 | if (this.prerelease[0] === identifier) {
|
2433 | if (isNaN(this.prerelease[1])) {
|
2434 | this.prerelease = [identifier, 0];
|
2435 | }
|
2436 | } else {
|
2437 | this.prerelease = [identifier, 0];
|
2438 | }
|
2439 | }
|
2440 |
|
2441 | break;
|
2442 |
|
2443 | default:
|
2444 | throw new Error(`invalid increment argument: ${release}`);
|
2445 | }
|
2446 |
|
2447 | this.format();
|
2448 | this.raw = this.version;
|
2449 | return this;
|
2450 | }
|
2451 |
|
2452 | }
|
2453 |
|
2454 | var semver = SemVer;
|
2455 |
|
2456 | const compare = (a, b, loose) => new semver(a, loose).compare(new semver(b, loose));
|
2457 |
|
2458 | var compare_1 = compare;
|
2459 |
|
2460 | const lt = (a, b, loose) => compare_1(a, b, loose) < 0;
|
2461 |
|
2462 | var lt_1 = lt;
|
2463 |
|
2464 | const gte = (a, b, loose) => compare_1(a, b, loose) >= 0;
|
2465 |
|
2466 | var gte_1 = gte;
|
2467 |
|
2468 | var arrayify = (object, keyName) => Object.entries(object).map(([key, value]) => Object.assign({
|
2469 | [keyName]: key
|
2470 | }, value));
|
2471 |
|
2472 | var dedent_1 = createCommonjsModule(function (module) {
|
2473 |
|
2474 | function dedent(strings) {
|
2475 | var raw = void 0;
|
2476 |
|
2477 | if (typeof strings === "string") {
|
2478 |
|
2479 | raw = [strings];
|
2480 | } else {
|
2481 | raw = strings.raw;
|
2482 | }
|
2483 |
|
2484 |
|
2485 | var result = "";
|
2486 |
|
2487 | for (var i = 0; i < raw.length; i++) {
|
2488 | result += raw[i].
|
2489 | replace(/\\\n[ \t]*/g, "").
|
2490 | replace(/\\`/g, "`");
|
2491 |
|
2492 | if (i < (arguments.length <= 1 ? 0 : arguments.length - 1)) {
|
2493 | result += arguments.length <= i + 1 ? undefined : arguments[i + 1];
|
2494 | }
|
2495 | }
|
2496 |
|
2497 |
|
2498 | var lines = result.split("\n");
|
2499 | var mindent = null;
|
2500 | lines.forEach(function (l) {
|
2501 | var m = l.match(/^(\s+)\S+/);
|
2502 |
|
2503 | if (m) {
|
2504 | var indent = m[1].length;
|
2505 |
|
2506 | if (!mindent) {
|
2507 |
|
2508 | mindent = indent;
|
2509 | } else {
|
2510 | mindent = Math.min(mindent, indent);
|
2511 | }
|
2512 | }
|
2513 | });
|
2514 |
|
2515 | if (mindent !== null) {
|
2516 | result = lines.map(function (l) {
|
2517 | return l[0] === " " ? l.slice(mindent) : l;
|
2518 | }).join("\n");
|
2519 | }
|
2520 |
|
2521 |
|
2522 | result = result.trim();
|
2523 |
|
2524 | return result.replace(/\\n/g, "\n");
|
2525 | }
|
2526 |
|
2527 | {
|
2528 | module.exports = dedent;
|
2529 | }
|
2530 | });
|
2531 |
|
2532 | const CATEGORY_CONFIG = "Config";
|
2533 | const CATEGORY_EDITOR = "Editor";
|
2534 | const CATEGORY_FORMAT = "Format";
|
2535 | const CATEGORY_OTHER = "Other";
|
2536 | const CATEGORY_OUTPUT = "Output";
|
2537 | const CATEGORY_GLOBAL = "Global";
|
2538 | const CATEGORY_SPECIAL = "Special";
|
2539 |
|
2540 |
|
2541 |
|
2542 |
|
2543 |
|
2544 |
|
2545 |
|
2546 |
|
2547 |
|
2548 |
|
2549 |
|
2550 |
|
2551 |
|
2552 |
|
2553 |
|
2554 |
|
2555 |
|
2556 |
|
2557 |
|
2558 |
|
2559 |
|
2560 |
|
2561 |
|
2562 |
|
2563 |
|
2564 |
|
2565 |
|
2566 |
|
2567 |
|
2568 |
|
2569 |
|
2570 |
|
2571 |
|
2572 |
|
2573 |
|
2574 |
|
2575 |
|
2576 |
|
2577 |
|
2578 | const options = {
|
2579 | cursorOffset: {
|
2580 | since: "1.4.0",
|
2581 | category: CATEGORY_SPECIAL,
|
2582 | type: "int",
|
2583 | default: -1,
|
2584 | range: {
|
2585 | start: -1,
|
2586 | end: Infinity,
|
2587 | step: 1
|
2588 | },
|
2589 | description: dedent_1`
|
2590 | Print (to stderr) where a cursor at the given position would move to after formatting.
|
2591 | This option cannot be used with --range-start and --range-end.
|
2592 | `,
|
2593 | cliCategory: CATEGORY_EDITOR
|
2594 | },
|
2595 | endOfLine: {
|
2596 | since: "1.15.0",
|
2597 | category: CATEGORY_GLOBAL,
|
2598 | type: "choice",
|
2599 | default: [{
|
2600 | since: "1.15.0",
|
2601 | value: "auto"
|
2602 | }, {
|
2603 | since: "2.0.0",
|
2604 | value: "lf"
|
2605 | }],
|
2606 | description: "Which end of line characters to apply.",
|
2607 | choices: [{
|
2608 | value: "lf",
|
2609 | description: "Line Feed only (\\n), common on Linux and macOS as well as inside git repos"
|
2610 | }, {
|
2611 | value: "crlf",
|
2612 | description: "Carriage Return + Line Feed characters (\\r\\n), common on Windows"
|
2613 | }, {
|
2614 | value: "cr",
|
2615 | description: "Carriage Return character only (\\r), used very rarely"
|
2616 | }, {
|
2617 | value: "auto",
|
2618 | description: dedent_1`
|
2619 | Maintain existing
|
2620 | (mixed values within one file are normalised by looking at what's used after the first line)
|
2621 | `
|
2622 | }]
|
2623 | },
|
2624 | filepath: {
|
2625 | since: "1.4.0",
|
2626 | category: CATEGORY_SPECIAL,
|
2627 | type: "path",
|
2628 | description: "Specify the input filepath. This will be used to do parser inference.",
|
2629 | cliName: "stdin-filepath",
|
2630 | cliCategory: CATEGORY_OTHER,
|
2631 | cliDescription: "Path to the file to pretend that stdin comes from."
|
2632 | },
|
2633 | insertPragma: {
|
2634 | since: "1.8.0",
|
2635 | category: CATEGORY_SPECIAL,
|
2636 | type: "boolean",
|
2637 | default: false,
|
2638 | description: "Insert @format pragma into file's first docblock comment.",
|
2639 | cliCategory: CATEGORY_OTHER
|
2640 | },
|
2641 | parser: {
|
2642 | since: "0.0.10",
|
2643 | category: CATEGORY_GLOBAL,
|
2644 | type: "choice",
|
2645 | default: [{
|
2646 | since: "0.0.10",
|
2647 | value: "babylon"
|
2648 | }, {
|
2649 | since: "1.13.0",
|
2650 | value: undefined
|
2651 | }],
|
2652 | description: "Which parser to use.",
|
2653 | exception: value => typeof value === "string" || typeof value === "function",
|
2654 | choices: [{
|
2655 | value: "flow",
|
2656 | description: "Flow"
|
2657 | }, {
|
2658 | value: "babel",
|
2659 | since: "1.16.0",
|
2660 | description: "JavaScript"
|
2661 | }, {
|
2662 | value: "babel-flow",
|
2663 | since: "1.16.0",
|
2664 | description: "Flow"
|
2665 | }, {
|
2666 | value: "babel-ts",
|
2667 | since: "2.0.0",
|
2668 | description: "TypeScript"
|
2669 | }, {
|
2670 | value: "typescript",
|
2671 | since: "1.4.0",
|
2672 | description: "TypeScript"
|
2673 | }, {
|
2674 | value: "css",
|
2675 | since: "1.7.1",
|
2676 | description: "CSS"
|
2677 | }, {
|
2678 | value: "less",
|
2679 | since: "1.7.1",
|
2680 | description: "Less"
|
2681 | }, {
|
2682 | value: "scss",
|
2683 | since: "1.7.1",
|
2684 | description: "SCSS"
|
2685 | }, {
|
2686 | value: "json",
|
2687 | since: "1.5.0",
|
2688 | description: "JSON"
|
2689 | }, {
|
2690 | value: "json5",
|
2691 | since: "1.13.0",
|
2692 | description: "JSON5"
|
2693 | }, {
|
2694 | value: "json-stringify",
|
2695 | since: "1.13.0",
|
2696 | description: "JSON.stringify"
|
2697 | }, {
|
2698 | value: "graphql",
|
2699 | since: "1.5.0",
|
2700 | description: "GraphQL"
|
2701 | }, {
|
2702 | value: "markdown",
|
2703 | since: "1.8.0",
|
2704 | description: "Markdown"
|
2705 | }, {
|
2706 | value: "mdx",
|
2707 | since: "1.15.0",
|
2708 | description: "MDX"
|
2709 | }, {
|
2710 | value: "vue",
|
2711 | since: "1.10.0",
|
2712 | description: "Vue"
|
2713 | }, {
|
2714 | value: "yaml",
|
2715 | since: "1.14.0",
|
2716 | description: "YAML"
|
2717 | }, {
|
2718 | value: "glimmer",
|
2719 | since: null,
|
2720 | description: "Handlebars"
|
2721 | }, {
|
2722 | value: "html",
|
2723 | since: "1.15.0",
|
2724 | description: "HTML"
|
2725 | }, {
|
2726 | value: "angular",
|
2727 | since: "1.15.0",
|
2728 | description: "Angular"
|
2729 | }, {
|
2730 | value: "lwc",
|
2731 | since: "1.17.0",
|
2732 | description: "Lightning Web Components"
|
2733 | }]
|
2734 | },
|
2735 | plugins: {
|
2736 | since: "1.10.0",
|
2737 | type: "path",
|
2738 | array: true,
|
2739 | default: [{
|
2740 | value: []
|
2741 | }],
|
2742 | category: CATEGORY_GLOBAL,
|
2743 | description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",
|
2744 | exception: value => typeof value === "string" || typeof value === "object",
|
2745 | cliName: "plugin",
|
2746 | cliCategory: CATEGORY_CONFIG
|
2747 | },
|
2748 | pluginSearchDirs: {
|
2749 | since: "1.13.0",
|
2750 | type: "path",
|
2751 | array: true,
|
2752 | default: [{
|
2753 | value: []
|
2754 | }],
|
2755 | category: CATEGORY_GLOBAL,
|
2756 | description: dedent_1`
|
2757 | Custom directory that contains prettier plugins in node_modules subdirectory.
|
2758 | Overrides default behavior when plugins are searched relatively to the location of Prettier.
|
2759 | Multiple values are accepted.
|
2760 | `,
|
2761 | exception: value => typeof value === "string" || typeof value === "object",
|
2762 | cliName: "plugin-search-dir",
|
2763 | cliCategory: CATEGORY_CONFIG
|
2764 | },
|
2765 | printWidth: {
|
2766 | since: "0.0.0",
|
2767 | category: CATEGORY_GLOBAL,
|
2768 | type: "int",
|
2769 | default: 80,
|
2770 | description: "The line length where Prettier will try wrap.",
|
2771 | range: {
|
2772 | start: 0,
|
2773 | end: Infinity,
|
2774 | step: 1
|
2775 | }
|
2776 | },
|
2777 | rangeEnd: {
|
2778 | since: "1.4.0",
|
2779 | category: CATEGORY_SPECIAL,
|
2780 | type: "int",
|
2781 | default: Infinity,
|
2782 | range: {
|
2783 | start: 0,
|
2784 | end: Infinity,
|
2785 | step: 1
|
2786 | },
|
2787 | description: dedent_1`
|
2788 | Format code ending at a given character offset (exclusive).
|
2789 | The range will extend forwards to the end of the selected statement.
|
2790 | This option cannot be used with --cursor-offset.
|
2791 | `,
|
2792 | cliCategory: CATEGORY_EDITOR
|
2793 | },
|
2794 | rangeStart: {
|
2795 | since: "1.4.0",
|
2796 | category: CATEGORY_SPECIAL,
|
2797 | type: "int",
|
2798 | default: 0,
|
2799 | range: {
|
2800 | start: 0,
|
2801 | end: Infinity,
|
2802 | step: 1
|
2803 | },
|
2804 | description: dedent_1`
|
2805 | Format code starting at a given character offset.
|
2806 | The range will extend backwards to the start of the first line containing the selected statement.
|
2807 | This option cannot be used with --cursor-offset.
|
2808 | `,
|
2809 | cliCategory: CATEGORY_EDITOR
|
2810 | },
|
2811 | requirePragma: {
|
2812 | since: "1.7.0",
|
2813 | category: CATEGORY_SPECIAL,
|
2814 | type: "boolean",
|
2815 | default: false,
|
2816 | description: dedent_1`
|
2817 | Require either '@prettier' or '@format' to be present in the file's first docblock comment
|
2818 | in order for it to be formatted.
|
2819 | `,
|
2820 | cliCategory: CATEGORY_OTHER
|
2821 | },
|
2822 | tabWidth: {
|
2823 | type: "int",
|
2824 | category: CATEGORY_GLOBAL,
|
2825 | default: 2,
|
2826 | description: "Number of spaces per indentation level.",
|
2827 | range: {
|
2828 | start: 0,
|
2829 | end: Infinity,
|
2830 | step: 1
|
2831 | }
|
2832 | },
|
2833 | useTabs: {
|
2834 | since: "1.0.0",
|
2835 | category: CATEGORY_GLOBAL,
|
2836 | type: "boolean",
|
2837 | default: false,
|
2838 | description: "Indent with tabs instead of spaces."
|
2839 | }
|
2840 | };
|
2841 | var coreOptions = {
|
2842 | CATEGORY_CONFIG,
|
2843 | CATEGORY_EDITOR,
|
2844 | CATEGORY_FORMAT,
|
2845 | CATEGORY_OTHER,
|
2846 | CATEGORY_OUTPUT,
|
2847 | CATEGORY_GLOBAL,
|
2848 | CATEGORY_SPECIAL,
|
2849 | options
|
2850 | };
|
2851 |
|
2852 | var require$$1 = getCjsExportFromNamespace(_package$1);
|
2853 |
|
2854 | const semver$1 = {
|
2855 | compare: compare_1,
|
2856 | lt: lt_1,
|
2857 | gte: gte_1
|
2858 | };
|
2859 | const currentVersion = require$$1.version;
|
2860 | const coreOptions$1 = coreOptions.options;
|
2861 |
|
2862 |
|
2863 |
|
2864 |
|
2865 |
|
2866 |
|
2867 |
|
2868 |
|
2869 |
|
2870 |
|
2871 |
|
2872 | function getSupportInfo({
|
2873 | plugins = [],
|
2874 | showUnreleased = false,
|
2875 | showDeprecated = false,
|
2876 | showInternal = false
|
2877 | } = {}) {
|
2878 |
|
2879 |
|
2880 | const version = currentVersion.split("-", 1)[0];
|
2881 | const options = arrayify(Object.assign({}, ...plugins.map(({
|
2882 | options
|
2883 | }) => options), coreOptions$1), "name").filter(option => filterSince(option) && filterDeprecated(option)).sort((a, b) => a.name === b.name ? 0 : a.name < b.name ? -1 : 1).map(mapInternal).map(option => {
|
2884 | option = Object.assign({}, option);
|
2885 |
|
2886 | if (Array.isArray(option.default)) {
|
2887 | option.default = option.default.length === 1 ? option.default[0].value : option.default.filter(filterSince).sort((info1, info2) => semver$1.compare(info2.since, info1.since))[0].value;
|
2888 | }
|
2889 |
|
2890 | if (Array.isArray(option.choices)) {
|
2891 | option.choices = option.choices.filter(option => filterSince(option) && filterDeprecated(option));
|
2892 | }
|
2893 |
|
2894 | const filteredPlugins = plugins.filter(plugin => plugin.defaultOptions && plugin.defaultOptions[option.name] !== undefined);
|
2895 | const pluginDefaults = filteredPlugins.reduce((reduced, plugin) => {
|
2896 | reduced[plugin.name] = plugin.defaultOptions[option.name];
|
2897 | return reduced;
|
2898 | }, {});
|
2899 | return Object.assign({}, option, {
|
2900 | pluginDefaults
|
2901 | });
|
2902 | });
|
2903 | const languages = plugins.reduce((all, plugin) => all.concat(plugin.languages || []), []).filter(filterSince);
|
2904 | return {
|
2905 | languages,
|
2906 | options
|
2907 | };
|
2908 |
|
2909 | function filterSince(object) {
|
2910 | return showUnreleased || !("since" in object) || object.since && semver$1.gte(version, object.since);
|
2911 | }
|
2912 |
|
2913 | function filterDeprecated(object) {
|
2914 | return showDeprecated || !("deprecated" in object) || object.deprecated && semver$1.lt(version, object.deprecated);
|
2915 | }
|
2916 |
|
2917 | function mapInternal(object) {
|
2918 | if (showInternal) {
|
2919 | return object;
|
2920 | }
|
2921 |
|
2922 | const newObject = _objectWithoutPropertiesLoose(object, ["cliName", "cliCategory", "cliDescription"]);
|
2923 |
|
2924 | return newObject;
|
2925 | }
|
2926 | }
|
2927 |
|
2928 | var support = {
|
2929 | getSupportInfo
|
2930 | };
|
2931 |
|
2932 |
|
2933 |
|
2934 |
|
2935 |
|
2936 |
|
2937 |
|
2938 |
|
2939 |
|
2940 |
|
2941 |
|
2942 |
|
2943 |
|
2944 |
|
2945 |
|
2946 |
|
2947 |
|
2948 | var extendStatics = function (d, b) {
|
2949 | extendStatics = Object.setPrototypeOf || {
|
2950 | __proto__: []
|
2951 | } instanceof Array && function (d, b) {
|
2952 | d.__proto__ = b;
|
2953 | } || function (d, b) {
|
2954 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
2955 | };
|
2956 |
|
2957 | return extendStatics(d, b);
|
2958 | };
|
2959 |
|
2960 | function __extends(d, b) {
|
2961 | extendStatics(d, b);
|
2962 |
|
2963 | function __() {
|
2964 | this.constructor = d;
|
2965 | }
|
2966 |
|
2967 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
2968 | }
|
2969 | var __assign = function () {
|
2970 | __assign = Object.assign || function __assign(t) {
|
2971 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
2972 | s = arguments[i];
|
2973 |
|
2974 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
2975 | }
|
2976 |
|
2977 | return t;
|
2978 | };
|
2979 |
|
2980 | return __assign.apply(this, arguments);
|
2981 | };
|
2982 | function __rest(s, e) {
|
2983 | var t = {};
|
2984 |
|
2985 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
2986 |
|
2987 | if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
2988 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
2989 | }
|
2990 | return t;
|
2991 | }
|
2992 | function __decorate(decorators, target, key, desc) {
|
2993 | var c = arguments.length,
|
2994 | r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
2995 | d;
|
2996 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
2997 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
2998 | }
|
2999 | function __param(paramIndex, decorator) {
|
3000 | return function (target, key) {
|
3001 | decorator(target, key, paramIndex);
|
3002 | };
|
3003 | }
|
3004 | function __metadata(metadataKey, metadataValue) {
|
3005 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
3006 | }
|
3007 | function __awaiter(thisArg, _arguments, P, generator) {
|
3008 | return new (P || (P = Promise))(function (resolve, reject) {
|
3009 | function fulfilled(value) {
|
3010 | try {
|
3011 | step(generator.next(value));
|
3012 | } catch (e) {
|
3013 | reject(e);
|
3014 | }
|
3015 | }
|
3016 |
|
3017 | function rejected(value) {
|
3018 | try {
|
3019 | step(generator["throw"](value));
|
3020 | } catch (e) {
|
3021 | reject(e);
|
3022 | }
|
3023 | }
|
3024 |
|
3025 | function step(result) {
|
3026 | result.done ? resolve(result.value) : new P(function (resolve) {
|
3027 | resolve(result.value);
|
3028 | }).then(fulfilled, rejected);
|
3029 | }
|
3030 |
|
3031 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
3032 | });
|
3033 | }
|
3034 | function __generator(thisArg, body) {
|
3035 | var _ = {
|
3036 | label: 0,
|
3037 | sent: function () {
|
3038 | if (t[0] & 1) throw t[1];
|
3039 | return t[1];
|
3040 | },
|
3041 | trys: [],
|
3042 | ops: []
|
3043 | },
|
3044 | f,
|
3045 | y,
|
3046 | t,
|
3047 | g;
|
3048 | return g = {
|
3049 | next: verb(0),
|
3050 | "throw": verb(1),
|
3051 | "return": verb(2)
|
3052 | }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
3053 | return this;
|
3054 | }), g;
|
3055 |
|
3056 | function verb(n) {
|
3057 | return function (v) {
|
3058 | return step([n, v]);
|
3059 | };
|
3060 | }
|
3061 |
|
3062 | function step(op) {
|
3063 | if (f) throw new TypeError("Generator is already executing.");
|
3064 |
|
3065 | while (_) try {
|
3066 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
3067 | if (y = 0, t) op = [op[0] & 2, t.value];
|
3068 |
|
3069 | switch (op[0]) {
|
3070 | case 0:
|
3071 | case 1:
|
3072 | t = op;
|
3073 | break;
|
3074 |
|
3075 | case 4:
|
3076 | _.label++;
|
3077 | return {
|
3078 | value: op[1],
|
3079 | done: false
|
3080 | };
|
3081 |
|
3082 | case 5:
|
3083 | _.label++;
|
3084 | y = op[1];
|
3085 | op = [0];
|
3086 | continue;
|
3087 |
|
3088 | case 7:
|
3089 | op = _.ops.pop();
|
3090 |
|
3091 | _.trys.pop();
|
3092 |
|
3093 | continue;
|
3094 |
|
3095 | default:
|
3096 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
3097 | _ = 0;
|
3098 | continue;
|
3099 | }
|
3100 |
|
3101 | if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
3102 | _.label = op[1];
|
3103 | break;
|
3104 | }
|
3105 |
|
3106 | if (op[0] === 6 && _.label < t[1]) {
|
3107 | _.label = t[1];
|
3108 | t = op;
|
3109 | break;
|
3110 | }
|
3111 |
|
3112 | if (t && _.label < t[2]) {
|
3113 | _.label = t[2];
|
3114 |
|
3115 | _.ops.push(op);
|
3116 |
|
3117 | break;
|
3118 | }
|
3119 |
|
3120 | if (t[2]) _.ops.pop();
|
3121 |
|
3122 | _.trys.pop();
|
3123 |
|
3124 | continue;
|
3125 | }
|
3126 |
|
3127 | op = body.call(thisArg, _);
|
3128 | } catch (e) {
|
3129 | op = [6, e];
|
3130 | y = 0;
|
3131 | } finally {
|
3132 | f = t = 0;
|
3133 | }
|
3134 |
|
3135 | if (op[0] & 5) throw op[1];
|
3136 | return {
|
3137 | value: op[0] ? op[1] : void 0,
|
3138 | done: true
|
3139 | };
|
3140 | }
|
3141 | }
|
3142 | function __exportStar(m, exports) {
|
3143 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
3144 | }
|
3145 | function __values(o) {
|
3146 | var m = typeof Symbol === "function" && o[Symbol.iterator],
|
3147 | i = 0;
|
3148 | if (m) return m.call(o);
|
3149 | return {
|
3150 | next: function () {
|
3151 | if (o && i >= o.length) o = void 0;
|
3152 | return {
|
3153 | value: o && o[i++],
|
3154 | done: !o
|
3155 | };
|
3156 | }
|
3157 | };
|
3158 | }
|
3159 | function __read(o, n) {
|
3160 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
3161 | if (!m) return o;
|
3162 | var i = m.call(o),
|
3163 | r,
|
3164 | ar = [],
|
3165 | e;
|
3166 |
|
3167 | try {
|
3168 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
3169 | } catch (error) {
|
3170 | e = {
|
3171 | error: error
|
3172 | };
|
3173 | } finally {
|
3174 | try {
|
3175 | if (r && !r.done && (m = i["return"])) m.call(i);
|
3176 | } finally {
|
3177 | if (e) throw e.error;
|
3178 | }
|
3179 | }
|
3180 |
|
3181 | return ar;
|
3182 | }
|
3183 | function __spread() {
|
3184 | for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
3185 |
|
3186 | return ar;
|
3187 | }
|
3188 | function __spreadArrays() {
|
3189 | for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
3190 |
|
3191 | for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
|
3192 |
|
3193 | return r;
|
3194 | }
|
3195 | function __await(v) {
|
3196 | return this instanceof __await ? (this.v = v, this) : new __await(v);
|
3197 | }
|
3198 | function __asyncGenerator(thisArg, _arguments, generator) {
|
3199 | if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
3200 | var g = generator.apply(thisArg, _arguments || []),
|
3201 | i,
|
3202 | q = [];
|
3203 | return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
|
3204 | return this;
|
3205 | }, i;
|
3206 |
|
3207 | function verb(n) {
|
3208 | if (g[n]) i[n] = function (v) {
|
3209 | return new Promise(function (a, b) {
|
3210 | q.push([n, v, a, b]) > 1 || resume(n, v);
|
3211 | });
|
3212 | };
|
3213 | }
|
3214 |
|
3215 | function resume(n, v) {
|
3216 | try {
|
3217 | step(g[n](v));
|
3218 | } catch (e) {
|
3219 | settle(q[0][3], e);
|
3220 | }
|
3221 | }
|
3222 |
|
3223 | function step(r) {
|
3224 | r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
|
3225 | }
|
3226 |
|
3227 | function fulfill(value) {
|
3228 | resume("next", value);
|
3229 | }
|
3230 |
|
3231 | function reject(value) {
|
3232 | resume("throw", value);
|
3233 | }
|
3234 |
|
3235 | function settle(f, v) {
|
3236 | if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
|
3237 | }
|
3238 | }
|
3239 | function __asyncDelegator(o) {
|
3240 | var i, p;
|
3241 | return i = {}, verb("next"), verb("throw", function (e) {
|
3242 | throw e;
|
3243 | }), verb("return"), i[Symbol.iterator] = function () {
|
3244 | return this;
|
3245 | }, i;
|
3246 |
|
3247 | function verb(n, f) {
|
3248 | i[n] = o[n] ? function (v) {
|
3249 | return (p = !p) ? {
|
3250 | value: __await(o[n](v)),
|
3251 | done: n === "return"
|
3252 | } : f ? f(v) : v;
|
3253 | } : f;
|
3254 | }
|
3255 | }
|
3256 | function __asyncValues(o) {
|
3257 | if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
3258 | var m = o[Symbol.asyncIterator],
|
3259 | i;
|
3260 | return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
|
3261 | return this;
|
3262 | }, i);
|
3263 |
|
3264 | function verb(n) {
|
3265 | i[n] = o[n] && function (v) {
|
3266 | return new Promise(function (resolve, reject) {
|
3267 | v = o[n](v), settle(resolve, reject, v.done, v.value);
|
3268 | });
|
3269 | };
|
3270 | }
|
3271 |
|
3272 | function settle(resolve, reject, d, v) {
|
3273 | Promise.resolve(v).then(function (v) {
|
3274 | resolve({
|
3275 | value: v,
|
3276 | done: d
|
3277 | });
|
3278 | }, reject);
|
3279 | }
|
3280 | }
|
3281 | function __makeTemplateObject(cooked, raw) {
|
3282 | if (Object.defineProperty) {
|
3283 | Object.defineProperty(cooked, "raw", {
|
3284 | value: raw
|
3285 | });
|
3286 | } else {
|
3287 | cooked.raw = raw;
|
3288 | }
|
3289 |
|
3290 | return cooked;
|
3291 | }
|
3292 | function __importStar(mod) {
|
3293 | if (mod && mod.__esModule) return mod;
|
3294 | var result = {};
|
3295 | if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
3296 | result.default = mod;
|
3297 | return result;
|
3298 | }
|
3299 | function __importDefault(mod) {
|
3300 | return mod && mod.__esModule ? mod : {
|
3301 | default: mod
|
3302 | };
|
3303 | }
|
3304 |
|
3305 | var tslib_es6 = Object.freeze({
|
3306 | __proto__: null,
|
3307 | __extends: __extends,
|
3308 | get __assign () { return __assign; },
|
3309 | __rest: __rest,
|
3310 | __decorate: __decorate,
|
3311 | __param: __param,
|
3312 | __metadata: __metadata,
|
3313 | __awaiter: __awaiter,
|
3314 | __generator: __generator,
|
3315 | __exportStar: __exportStar,
|
3316 | __values: __values,
|
3317 | __read: __read,
|
3318 | __spread: __spread,
|
3319 | __spreadArrays: __spreadArrays,
|
3320 | __await: __await,
|
3321 | __asyncGenerator: __asyncGenerator,
|
3322 | __asyncDelegator: __asyncDelegator,
|
3323 | __asyncValues: __asyncValues,
|
3324 | __makeTemplateObject: __makeTemplateObject,
|
3325 | __importStar: __importStar,
|
3326 | __importDefault: __importDefault
|
3327 | });
|
3328 |
|
3329 | var api = createCommonjsModule(function (module, exports) {
|
3330 |
|
3331 | Object.defineProperty(exports, "__esModule", {
|
3332 | value: true
|
3333 | });
|
3334 | exports.apiDescriptor = {
|
3335 | key: key => /^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(key) ? key : JSON.stringify(key),
|
3336 |
|
3337 | value(value) {
|
3338 | if (value === null || typeof value !== 'object') {
|
3339 | return JSON.stringify(value);
|
3340 | }
|
3341 |
|
3342 | if (Array.isArray(value)) {
|
3343 | return `[${value.map(subValue => exports.apiDescriptor.value(subValue)).join(', ')}]`;
|
3344 | }
|
3345 |
|
3346 | const keys = Object.keys(value);
|
3347 | return keys.length === 0 ? '{}' : `{ ${keys.map(key => `${exports.apiDescriptor.key(key)}: ${exports.apiDescriptor.value(value[key])}`).join(', ')} }`;
|
3348 | },
|
3349 |
|
3350 | pair: ({
|
3351 | key,
|
3352 | value
|
3353 | }) => exports.apiDescriptor.value({
|
3354 | [key]: value
|
3355 | })
|
3356 | };
|
3357 | });
|
3358 | unwrapExports(api);
|
3359 | var api_1 = api.apiDescriptor;
|
3360 |
|
3361 | var tslib_1 = getCjsExportFromNamespace(tslib_es6);
|
3362 |
|
3363 | var descriptors = createCommonjsModule(function (module, exports) {
|
3364 |
|
3365 | Object.defineProperty(exports, "__esModule", {
|
3366 | value: true
|
3367 | });
|
3368 |
|
3369 | tslib_1.__exportStar(api, exports);
|
3370 | });
|
3371 | unwrapExports(descriptors);
|
3372 |
|
3373 | var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
|
3374 |
|
3375 | var escapeStringRegexp = function (str) {
|
3376 | if (typeof str !== 'string') {
|
3377 | throw new TypeError('Expected a string');
|
3378 | }
|
3379 |
|
3380 | return str.replace(matchOperatorsRe, '\\$&');
|
3381 | };
|
3382 |
|
3383 | var colorName = {
|
3384 | "aliceblue": [240, 248, 255],
|
3385 | "antiquewhite": [250, 235, 215],
|
3386 | "aqua": [0, 255, 255],
|
3387 | "aquamarine": [127, 255, 212],
|
3388 | "azure": [240, 255, 255],
|
3389 | "beige": [245, 245, 220],
|
3390 | "bisque": [255, 228, 196],
|
3391 | "black": [0, 0, 0],
|
3392 | "blanchedalmond": [255, 235, 205],
|
3393 | "blue": [0, 0, 255],
|
3394 | "blueviolet": [138, 43, 226],
|
3395 | "brown": [165, 42, 42],
|
3396 | "burlywood": [222, 184, 135],
|
3397 | "cadetblue": [95, 158, 160],
|
3398 | "chartreuse": [127, 255, 0],
|
3399 | "chocolate": [210, 105, 30],
|
3400 | "coral": [255, 127, 80],
|
3401 | "cornflowerblue": [100, 149, 237],
|
3402 | "cornsilk": [255, 248, 220],
|
3403 | "crimson": [220, 20, 60],
|
3404 | "cyan": [0, 255, 255],
|
3405 | "darkblue": [0, 0, 139],
|
3406 | "darkcyan": [0, 139, 139],
|
3407 | "darkgoldenrod": [184, 134, 11],
|
3408 | "darkgray": [169, 169, 169],
|
3409 | "darkgreen": [0, 100, 0],
|
3410 | "darkgrey": [169, 169, 169],
|
3411 | "darkkhaki": [189, 183, 107],
|
3412 | "darkmagenta": [139, 0, 139],
|
3413 | "darkolivegreen": [85, 107, 47],
|
3414 | "darkorange": [255, 140, 0],
|
3415 | "darkorchid": [153, 50, 204],
|
3416 | "darkred": [139, 0, 0],
|
3417 | "darksalmon": [233, 150, 122],
|
3418 | "darkseagreen": [143, 188, 143],
|
3419 | "darkslateblue": [72, 61, 139],
|
3420 | "darkslategray": [47, 79, 79],
|
3421 | "darkslategrey": [47, 79, 79],
|
3422 | "darkturquoise": [0, 206, 209],
|
3423 | "darkviolet": [148, 0, 211],
|
3424 | "deeppink": [255, 20, 147],
|
3425 | "deepskyblue": [0, 191, 255],
|
3426 | "dimgray": [105, 105, 105],
|
3427 | "dimgrey": [105, 105, 105],
|
3428 | "dodgerblue": [30, 144, 255],
|
3429 | "firebrick": [178, 34, 34],
|
3430 | "floralwhite": [255, 250, 240],
|
3431 | "forestgreen": [34, 139, 34],
|
3432 | "fuchsia": [255, 0, 255],
|
3433 | "gainsboro": [220, 220, 220],
|
3434 | "ghostwhite": [248, 248, 255],
|
3435 | "gold": [255, 215, 0],
|
3436 | "goldenrod": [218, 165, 32],
|
3437 | "gray": [128, 128, 128],
|
3438 | "green": [0, 128, 0],
|
3439 | "greenyellow": [173, 255, 47],
|
3440 | "grey": [128, 128, 128],
|
3441 | "honeydew": [240, 255, 240],
|
3442 | "hotpink": [255, 105, 180],
|
3443 | "indianred": [205, 92, 92],
|
3444 | "indigo": [75, 0, 130],
|
3445 | "ivory": [255, 255, 240],
|
3446 | "khaki": [240, 230, 140],
|
3447 | "lavender": [230, 230, 250],
|
3448 | "lavenderblush": [255, 240, 245],
|
3449 | "lawngreen": [124, 252, 0],
|
3450 | "lemonchiffon": [255, 250, 205],
|
3451 | "lightblue": [173, 216, 230],
|
3452 | "lightcoral": [240, 128, 128],
|
3453 | "lightcyan": [224, 255, 255],
|
3454 | "lightgoldenrodyellow": [250, 250, 210],
|
3455 | "lightgray": [211, 211, 211],
|
3456 | "lightgreen": [144, 238, 144],
|
3457 | "lightgrey": [211, 211, 211],
|
3458 | "lightpink": [255, 182, 193],
|
3459 | "lightsalmon": [255, 160, 122],
|
3460 | "lightseagreen": [32, 178, 170],
|
3461 | "lightskyblue": [135, 206, 250],
|
3462 | "lightslategray": [119, 136, 153],
|
3463 | "lightslategrey": [119, 136, 153],
|
3464 | "lightsteelblue": [176, 196, 222],
|
3465 | "lightyellow": [255, 255, 224],
|
3466 | "lime": [0, 255, 0],
|
3467 | "limegreen": [50, 205, 50],
|
3468 | "linen": [250, 240, 230],
|
3469 | "magenta": [255, 0, 255],
|
3470 | "maroon": [128, 0, 0],
|
3471 | "mediumaquamarine": [102, 205, 170],
|
3472 | "mediumblue": [0, 0, 205],
|
3473 | "mediumorchid": [186, 85, 211],
|
3474 | "mediumpurple": [147, 112, 219],
|
3475 | "mediumseagreen": [60, 179, 113],
|
3476 | "mediumslateblue": [123, 104, 238],
|
3477 | "mediumspringgreen": [0, 250, 154],
|
3478 | "mediumturquoise": [72, 209, 204],
|
3479 | "mediumvioletred": [199, 21, 133],
|
3480 | "midnightblue": [25, 25, 112],
|
3481 | "mintcream": [245, 255, 250],
|
3482 | "mistyrose": [255, 228, 225],
|
3483 | "moccasin": [255, 228, 181],
|
3484 | "navajowhite": [255, 222, 173],
|
3485 | "navy": [0, 0, 128],
|
3486 | "oldlace": [253, 245, 230],
|
3487 | "olive": [128, 128, 0],
|
3488 | "olivedrab": [107, 142, 35],
|
3489 | "orange": [255, 165, 0],
|
3490 | "orangered": [255, 69, 0],
|
3491 | "orchid": [218, 112, 214],
|
3492 | "palegoldenrod": [238, 232, 170],
|
3493 | "palegreen": [152, 251, 152],
|
3494 | "paleturquoise": [175, 238, 238],
|
3495 | "palevioletred": [219, 112, 147],
|
3496 | "papayawhip": [255, 239, 213],
|
3497 | "peachpuff": [255, 218, 185],
|
3498 | "peru": [205, 133, 63],
|
3499 | "pink": [255, 192, 203],
|
3500 | "plum": [221, 160, 221],
|
3501 | "powderblue": [176, 224, 230],
|
3502 | "purple": [128, 0, 128],
|
3503 | "rebeccapurple": [102, 51, 153],
|
3504 | "red": [255, 0, 0],
|
3505 | "rosybrown": [188, 143, 143],
|
3506 | "royalblue": [65, 105, 225],
|
3507 | "saddlebrown": [139, 69, 19],
|
3508 | "salmon": [250, 128, 114],
|
3509 | "sandybrown": [244, 164, 96],
|
3510 | "seagreen": [46, 139, 87],
|
3511 | "seashell": [255, 245, 238],
|
3512 | "sienna": [160, 82, 45],
|
3513 | "silver": [192, 192, 192],
|
3514 | "skyblue": [135, 206, 235],
|
3515 | "slateblue": [106, 90, 205],
|
3516 | "slategray": [112, 128, 144],
|
3517 | "slategrey": [112, 128, 144],
|
3518 | "snow": [255, 250, 250],
|
3519 | "springgreen": [0, 255, 127],
|
3520 | "steelblue": [70, 130, 180],
|
3521 | "tan": [210, 180, 140],
|
3522 | "teal": [0, 128, 128],
|
3523 | "thistle": [216, 191, 216],
|
3524 | "tomato": [255, 99, 71],
|
3525 | "turquoise": [64, 224, 208],
|
3526 | "violet": [238, 130, 238],
|
3527 | "wheat": [245, 222, 179],
|
3528 | "white": [255, 255, 255],
|
3529 | "whitesmoke": [245, 245, 245],
|
3530 | "yellow": [255, 255, 0],
|
3531 | "yellowgreen": [154, 205, 50]
|
3532 | };
|
3533 |
|
3534 | var conversions = createCommonjsModule(function (module) {
|
3535 |
|
3536 |
|
3537 |
|
3538 |
|
3539 | var reverseKeywords = {};
|
3540 |
|
3541 | for (var key in colorName) {
|
3542 | if (colorName.hasOwnProperty(key)) {
|
3543 | reverseKeywords[colorName[key]] = key;
|
3544 | }
|
3545 | }
|
3546 |
|
3547 | var convert = module.exports = {
|
3548 | rgb: {
|
3549 | channels: 3,
|
3550 | labels: 'rgb'
|
3551 | },
|
3552 | hsl: {
|
3553 | channels: 3,
|
3554 | labels: 'hsl'
|
3555 | },
|
3556 | hsv: {
|
3557 | channels: 3,
|
3558 | labels: 'hsv'
|
3559 | },
|
3560 | hwb: {
|
3561 | channels: 3,
|
3562 | labels: 'hwb'
|
3563 | },
|
3564 | cmyk: {
|
3565 | channels: 4,
|
3566 | labels: 'cmyk'
|
3567 | },
|
3568 | xyz: {
|
3569 | channels: 3,
|
3570 | labels: 'xyz'
|
3571 | },
|
3572 | lab: {
|
3573 | channels: 3,
|
3574 | labels: 'lab'
|
3575 | },
|
3576 | lch: {
|
3577 | channels: 3,
|
3578 | labels: 'lch'
|
3579 | },
|
3580 | hex: {
|
3581 | channels: 1,
|
3582 | labels: ['hex']
|
3583 | },
|
3584 | keyword: {
|
3585 | channels: 1,
|
3586 | labels: ['keyword']
|
3587 | },
|
3588 | ansi16: {
|
3589 | channels: 1,
|
3590 | labels: ['ansi16']
|
3591 | },
|
3592 | ansi256: {
|
3593 | channels: 1,
|
3594 | labels: ['ansi256']
|
3595 | },
|
3596 | hcg: {
|
3597 | channels: 3,
|
3598 | labels: ['h', 'c', 'g']
|
3599 | },
|
3600 | apple: {
|
3601 | channels: 3,
|
3602 | labels: ['r16', 'g16', 'b16']
|
3603 | },
|
3604 | gray: {
|
3605 | channels: 1,
|
3606 | labels: ['gray']
|
3607 | }
|
3608 | };
|
3609 |
|
3610 | for (var model in convert) {
|
3611 | if (convert.hasOwnProperty(model)) {
|
3612 | if (!('channels' in convert[model])) {
|
3613 | throw new Error('missing channels property: ' + model);
|
3614 | }
|
3615 |
|
3616 | if (!('labels' in convert[model])) {
|
3617 | throw new Error('missing channel labels property: ' + model);
|
3618 | }
|
3619 |
|
3620 | if (convert[model].labels.length !== convert[model].channels) {
|
3621 | throw new Error('channel and label counts mismatch: ' + model);
|
3622 | }
|
3623 |
|
3624 | var channels = convert[model].channels;
|
3625 | var labels = convert[model].labels;
|
3626 | delete convert[model].channels;
|
3627 | delete convert[model].labels;
|
3628 | Object.defineProperty(convert[model], 'channels', {
|
3629 | value: channels
|
3630 | });
|
3631 | Object.defineProperty(convert[model], 'labels', {
|
3632 | value: labels
|
3633 | });
|
3634 | }
|
3635 | }
|
3636 |
|
3637 | convert.rgb.hsl = function (rgb) {
|
3638 | var r = rgb[0] / 255;
|
3639 | var g = rgb[1] / 255;
|
3640 | var b = rgb[2] / 255;
|
3641 | var min = Math.min(r, g, b);
|
3642 | var max = Math.max(r, g, b);
|
3643 | var delta = max - min;
|
3644 | var h;
|
3645 | var s;
|
3646 | var l;
|
3647 |
|
3648 | if (max === min) {
|
3649 | h = 0;
|
3650 | } else if (r === max) {
|
3651 | h = (g - b) / delta;
|
3652 | } else if (g === max) {
|
3653 | h = 2 + (b - r) / delta;
|
3654 | } else if (b === max) {
|
3655 | h = 4 + (r - g) / delta;
|
3656 | }
|
3657 |
|
3658 | h = Math.min(h * 60, 360);
|
3659 |
|
3660 | if (h < 0) {
|
3661 | h += 360;
|
3662 | }
|
3663 |
|
3664 | l = (min + max) / 2;
|
3665 |
|
3666 | if (max === min) {
|
3667 | s = 0;
|
3668 | } else if (l <= 0.5) {
|
3669 | s = delta / (max + min);
|
3670 | } else {
|
3671 | s = delta / (2 - max - min);
|
3672 | }
|
3673 |
|
3674 | return [h, s * 100, l * 100];
|
3675 | };
|
3676 |
|
3677 | convert.rgb.hsv = function (rgb) {
|
3678 | var rdif;
|
3679 | var gdif;
|
3680 | var bdif;
|
3681 | var h;
|
3682 | var s;
|
3683 | var r = rgb[0] / 255;
|
3684 | var g = rgb[1] / 255;
|
3685 | var b = rgb[2] / 255;
|
3686 | var v = Math.max(r, g, b);
|
3687 | var diff = v - Math.min(r, g, b);
|
3688 |
|
3689 | var diffc = function (c) {
|
3690 | return (v - c) / 6 / diff + 1 / 2;
|
3691 | };
|
3692 |
|
3693 | if (diff === 0) {
|
3694 | h = s = 0;
|
3695 | } else {
|
3696 | s = diff / v;
|
3697 | rdif = diffc(r);
|
3698 | gdif = diffc(g);
|
3699 | bdif = diffc(b);
|
3700 |
|
3701 | if (r === v) {
|
3702 | h = bdif - gdif;
|
3703 | } else if (g === v) {
|
3704 | h = 1 / 3 + rdif - bdif;
|
3705 | } else if (b === v) {
|
3706 | h = 2 / 3 + gdif - rdif;
|
3707 | }
|
3708 |
|
3709 | if (h < 0) {
|
3710 | h += 1;
|
3711 | } else if (h > 1) {
|
3712 | h -= 1;
|
3713 | }
|
3714 | }
|
3715 |
|
3716 | return [h * 360, s * 100, v * 100];
|
3717 | };
|
3718 |
|
3719 | convert.rgb.hwb = function (rgb) {
|
3720 | var r = rgb[0];
|
3721 | var g = rgb[1];
|
3722 | var b = rgb[2];
|
3723 | var h = convert.rgb.hsl(rgb)[0];
|
3724 | var w = 1 / 255 * Math.min(r, Math.min(g, b));
|
3725 | b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
3726 | return [h, w * 100, b * 100];
|
3727 | };
|
3728 |
|
3729 | convert.rgb.cmyk = function (rgb) {
|
3730 | var r = rgb[0] / 255;
|
3731 | var g = rgb[1] / 255;
|
3732 | var b = rgb[2] / 255;
|
3733 | var c;
|
3734 | var m;
|
3735 | var y;
|
3736 | var k;
|
3737 | k = Math.min(1 - r, 1 - g, 1 - b);
|
3738 | c = (1 - r - k) / (1 - k) || 0;
|
3739 | m = (1 - g - k) / (1 - k) || 0;
|
3740 | y = (1 - b - k) / (1 - k) || 0;
|
3741 | return [c * 100, m * 100, y * 100, k * 100];
|
3742 | };
|
3743 | |
3744 |
|
3745 |
|
3746 |
|
3747 |
|
3748 | function comparativeDistance(x, y) {
|
3749 | return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
|
3750 | }
|
3751 |
|
3752 | convert.rgb.keyword = function (rgb) {
|
3753 | var reversed = reverseKeywords[rgb];
|
3754 |
|
3755 | if (reversed) {
|
3756 | return reversed;
|
3757 | }
|
3758 |
|
3759 | var currentClosestDistance = Infinity;
|
3760 | var currentClosestKeyword;
|
3761 |
|
3762 | for (var keyword in colorName) {
|
3763 | if (colorName.hasOwnProperty(keyword)) {
|
3764 | var value = colorName[keyword];
|
3765 |
|
3766 | var distance = comparativeDistance(rgb, value);
|
3767 |
|
3768 | if (distance < currentClosestDistance) {
|
3769 | currentClosestDistance = distance;
|
3770 | currentClosestKeyword = keyword;
|
3771 | }
|
3772 | }
|
3773 | }
|
3774 |
|
3775 | return currentClosestKeyword;
|
3776 | };
|
3777 |
|
3778 | convert.keyword.rgb = function (keyword) {
|
3779 | return colorName[keyword];
|
3780 | };
|
3781 |
|
3782 | convert.rgb.xyz = function (rgb) {
|
3783 | var r = rgb[0] / 255;
|
3784 | var g = rgb[1] / 255;
|
3785 | var b = rgb[2] / 255;
|
3786 |
|
3787 | r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
|
3788 | g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
|
3789 | b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
|
3790 | var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
3791 | var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
3792 | var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
3793 | return [x * 100, y * 100, z * 100];
|
3794 | };
|
3795 |
|
3796 | convert.rgb.lab = function (rgb) {
|
3797 | var xyz = convert.rgb.xyz(rgb);
|
3798 | var x = xyz[0];
|
3799 | var y = xyz[1];
|
3800 | var z = xyz[2];
|
3801 | var l;
|
3802 | var a;
|
3803 | var b;
|
3804 | x /= 95.047;
|
3805 | y /= 100;
|
3806 | z /= 108.883;
|
3807 | x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
|
3808 | y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
|
3809 | z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
|
3810 | l = 116 * y - 16;
|
3811 | a = 500 * (x - y);
|
3812 | b = 200 * (y - z);
|
3813 | return [l, a, b];
|
3814 | };
|
3815 |
|
3816 | convert.hsl.rgb = function (hsl) {
|
3817 | var h = hsl[0] / 360;
|
3818 | var s = hsl[1] / 100;
|
3819 | var l = hsl[2] / 100;
|
3820 | var t1;
|
3821 | var t2;
|
3822 | var t3;
|
3823 | var rgb;
|
3824 | var val;
|
3825 |
|
3826 | if (s === 0) {
|
3827 | val = l * 255;
|
3828 | return [val, val, val];
|
3829 | }
|
3830 |
|
3831 | if (l < 0.5) {
|
3832 | t2 = l * (1 + s);
|
3833 | } else {
|
3834 | t2 = l + s - l * s;
|
3835 | }
|
3836 |
|
3837 | t1 = 2 * l - t2;
|
3838 | rgb = [0, 0, 0];
|
3839 |
|
3840 | for (var i = 0; i < 3; i++) {
|
3841 | t3 = h + 1 / 3 * -(i - 1);
|
3842 |
|
3843 | if (t3 < 0) {
|
3844 | t3++;
|
3845 | }
|
3846 |
|
3847 | if (t3 > 1) {
|
3848 | t3--;
|
3849 | }
|
3850 |
|
3851 | if (6 * t3 < 1) {
|
3852 | val = t1 + (t2 - t1) * 6 * t3;
|
3853 | } else if (2 * t3 < 1) {
|
3854 | val = t2;
|
3855 | } else if (3 * t3 < 2) {
|
3856 | val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
3857 | } else {
|
3858 | val = t1;
|
3859 | }
|
3860 |
|
3861 | rgb[i] = val * 255;
|
3862 | }
|
3863 |
|
3864 | return rgb;
|
3865 | };
|
3866 |
|
3867 | convert.hsl.hsv = function (hsl) {
|
3868 | var h = hsl[0];
|
3869 | var s = hsl[1] / 100;
|
3870 | var l = hsl[2] / 100;
|
3871 | var smin = s;
|
3872 | var lmin = Math.max(l, 0.01);
|
3873 | var sv;
|
3874 | var v;
|
3875 | l *= 2;
|
3876 | s *= l <= 1 ? l : 2 - l;
|
3877 | smin *= lmin <= 1 ? lmin : 2 - lmin;
|
3878 | v = (l + s) / 2;
|
3879 | sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
3880 | return [h, sv * 100, v * 100];
|
3881 | };
|
3882 |
|
3883 | convert.hsv.rgb = function (hsv) {
|
3884 | var h = hsv[0] / 60;
|
3885 | var s = hsv[1] / 100;
|
3886 | var v = hsv[2] / 100;
|
3887 | var hi = Math.floor(h) % 6;
|
3888 | var f = h - Math.floor(h);
|
3889 | var p = 255 * v * (1 - s);
|
3890 | var q = 255 * v * (1 - s * f);
|
3891 | var t = 255 * v * (1 - s * (1 - f));
|
3892 | v *= 255;
|
3893 |
|
3894 | switch (hi) {
|
3895 | case 0:
|
3896 | return [v, t, p];
|
3897 |
|
3898 | case 1:
|
3899 | return [q, v, p];
|
3900 |
|
3901 | case 2:
|
3902 | return [p, v, t];
|
3903 |
|
3904 | case 3:
|
3905 | return [p, q, v];
|
3906 |
|
3907 | case 4:
|
3908 | return [t, p, v];
|
3909 |
|
3910 | case 5:
|
3911 | return [v, p, q];
|
3912 | }
|
3913 | };
|
3914 |
|
3915 | convert.hsv.hsl = function (hsv) {
|
3916 | var h = hsv[0];
|
3917 | var s = hsv[1] / 100;
|
3918 | var v = hsv[2] / 100;
|
3919 | var vmin = Math.max(v, 0.01);
|
3920 | var lmin;
|
3921 | var sl;
|
3922 | var l;
|
3923 | l = (2 - s) * v;
|
3924 | lmin = (2 - s) * vmin;
|
3925 | sl = s * vmin;
|
3926 | sl /= lmin <= 1 ? lmin : 2 - lmin;
|
3927 | sl = sl || 0;
|
3928 | l /= 2;
|
3929 | return [h, sl * 100, l * 100];
|
3930 | };
|
3931 |
|
3932 |
|
3933 | convert.hwb.rgb = function (hwb) {
|
3934 | var h = hwb[0] / 360;
|
3935 | var wh = hwb[1] / 100;
|
3936 | var bl = hwb[2] / 100;
|
3937 | var ratio = wh + bl;
|
3938 | var i;
|
3939 | var v;
|
3940 | var f;
|
3941 | var n;
|
3942 |
|
3943 | if (ratio > 1) {
|
3944 | wh /= ratio;
|
3945 | bl /= ratio;
|
3946 | }
|
3947 |
|
3948 | i = Math.floor(6 * h);
|
3949 | v = 1 - bl;
|
3950 | f = 6 * h - i;
|
3951 |
|
3952 | if ((i & 0x01) !== 0) {
|
3953 | f = 1 - f;
|
3954 | }
|
3955 |
|
3956 | n = wh + f * (v - wh);
|
3957 |
|
3958 | var r;
|
3959 | var g;
|
3960 | var b;
|
3961 |
|
3962 | switch (i) {
|
3963 | default:
|
3964 | case 6:
|
3965 | case 0:
|
3966 | r = v;
|
3967 | g = n;
|
3968 | b = wh;
|
3969 | break;
|
3970 |
|
3971 | case 1:
|
3972 | r = n;
|
3973 | g = v;
|
3974 | b = wh;
|
3975 | break;
|
3976 |
|
3977 | case 2:
|
3978 | r = wh;
|
3979 | g = v;
|
3980 | b = n;
|
3981 | break;
|
3982 |
|
3983 | case 3:
|
3984 | r = wh;
|
3985 | g = n;
|
3986 | b = v;
|
3987 | break;
|
3988 |
|
3989 | case 4:
|
3990 | r = n;
|
3991 | g = wh;
|
3992 | b = v;
|
3993 | break;
|
3994 |
|
3995 | case 5:
|
3996 | r = v;
|
3997 | g = wh;
|
3998 | b = n;
|
3999 | break;
|
4000 | }
|
4001 |
|
4002 | return [r * 255, g * 255, b * 255];
|
4003 | };
|
4004 |
|
4005 | convert.cmyk.rgb = function (cmyk) {
|
4006 | var c = cmyk[0] / 100;
|
4007 | var m = cmyk[1] / 100;
|
4008 | var y = cmyk[2] / 100;
|
4009 | var k = cmyk[3] / 100;
|
4010 | var r;
|
4011 | var g;
|
4012 | var b;
|
4013 | r = 1 - Math.min(1, c * (1 - k) + k);
|
4014 | g = 1 - Math.min(1, m * (1 - k) + k);
|
4015 | b = 1 - Math.min(1, y * (1 - k) + k);
|
4016 | return [r * 255, g * 255, b * 255];
|
4017 | };
|
4018 |
|
4019 | convert.xyz.rgb = function (xyz) {
|
4020 | var x = xyz[0] / 100;
|
4021 | var y = xyz[1] / 100;
|
4022 | var z = xyz[2] / 100;
|
4023 | var r;
|
4024 | var g;
|
4025 | var b;
|
4026 | r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
4027 | g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
4028 | b = x * 0.0557 + y * -0.2040 + z * 1.0570;
|
4029 |
|
4030 | r = r > 0.0031308 ? 1.055 * Math.pow(r, 1.0 / 2.4) - 0.055 : r * 12.92;
|
4031 | g = g > 0.0031308 ? 1.055 * Math.pow(g, 1.0 / 2.4) - 0.055 : g * 12.92;
|
4032 | b = b > 0.0031308 ? 1.055 * Math.pow(b, 1.0 / 2.4) - 0.055 : b * 12.92;
|
4033 | r = Math.min(Math.max(0, r), 1);
|
4034 | g = Math.min(Math.max(0, g), 1);
|
4035 | b = Math.min(Math.max(0, b), 1);
|
4036 | return [r * 255, g * 255, b * 255];
|
4037 | };
|
4038 |
|
4039 | convert.xyz.lab = function (xyz) {
|
4040 | var x = xyz[0];
|
4041 | var y = xyz[1];
|
4042 | var z = xyz[2];
|
4043 | var l;
|
4044 | var a;
|
4045 | var b;
|
4046 | x /= 95.047;
|
4047 | y /= 100;
|
4048 | z /= 108.883;
|
4049 | x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
|
4050 | y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
|
4051 | z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
|
4052 | l = 116 * y - 16;
|
4053 | a = 500 * (x - y);
|
4054 | b = 200 * (y - z);
|
4055 | return [l, a, b];
|
4056 | };
|
4057 |
|
4058 | convert.lab.xyz = function (lab) {
|
4059 | var l = lab[0];
|
4060 | var a = lab[1];
|
4061 | var b = lab[2];
|
4062 | var x;
|
4063 | var y;
|
4064 | var z;
|
4065 | y = (l + 16) / 116;
|
4066 | x = a / 500 + y;
|
4067 | z = y - b / 200;
|
4068 | var y2 = Math.pow(y, 3);
|
4069 | var x2 = Math.pow(x, 3);
|
4070 | var z2 = Math.pow(z, 3);
|
4071 | y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
|
4072 | x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
|
4073 | z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
|
4074 | x *= 95.047;
|
4075 | y *= 100;
|
4076 | z *= 108.883;
|
4077 | return [x, y, z];
|
4078 | };
|
4079 |
|
4080 | convert.lab.lch = function (lab) {
|
4081 | var l = lab[0];
|
4082 | var a = lab[1];
|
4083 | var b = lab[2];
|
4084 | var hr;
|
4085 | var h;
|
4086 | var c;
|
4087 | hr = Math.atan2(b, a);
|
4088 | h = hr * 360 / 2 / Math.PI;
|
4089 |
|
4090 | if (h < 0) {
|
4091 | h += 360;
|
4092 | }
|
4093 |
|
4094 | c = Math.sqrt(a * a + b * b);
|
4095 | return [l, c, h];
|
4096 | };
|
4097 |
|
4098 | convert.lch.lab = function (lch) {
|
4099 | var l = lch[0];
|
4100 | var c = lch[1];
|
4101 | var h = lch[2];
|
4102 | var a;
|
4103 | var b;
|
4104 | var hr;
|
4105 | hr = h / 360 * 2 * Math.PI;
|
4106 | a = c * Math.cos(hr);
|
4107 | b = c * Math.sin(hr);
|
4108 | return [l, a, b];
|
4109 | };
|
4110 |
|
4111 | convert.rgb.ansi16 = function (args) {
|
4112 | var r = args[0];
|
4113 | var g = args[1];
|
4114 | var b = args[2];
|
4115 | var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2];
|
4116 |
|
4117 | value = Math.round(value / 50);
|
4118 |
|
4119 | if (value === 0) {
|
4120 | return 30;
|
4121 | }
|
4122 |
|
4123 | var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
4124 |
|
4125 | if (value === 2) {
|
4126 | ansi += 60;
|
4127 | }
|
4128 |
|
4129 | return ansi;
|
4130 | };
|
4131 |
|
4132 | convert.hsv.ansi16 = function (args) {
|
4133 |
|
4134 |
|
4135 | return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
4136 | };
|
4137 |
|
4138 | convert.rgb.ansi256 = function (args) {
|
4139 | var r = args[0];
|
4140 | var g = args[1];
|
4141 | var b = args[2];
|
4142 |
|
4143 |
|
4144 | if (r === g && g === b) {
|
4145 | if (r < 8) {
|
4146 | return 16;
|
4147 | }
|
4148 |
|
4149 | if (r > 248) {
|
4150 | return 231;
|
4151 | }
|
4152 |
|
4153 | return Math.round((r - 8) / 247 * 24) + 232;
|
4154 | }
|
4155 |
|
4156 | var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
4157 | return ansi;
|
4158 | };
|
4159 |
|
4160 | convert.ansi16.rgb = function (args) {
|
4161 | var color = args % 10;
|
4162 |
|
4163 | if (color === 0 || color === 7) {
|
4164 | if (args > 50) {
|
4165 | color += 3.5;
|
4166 | }
|
4167 |
|
4168 | color = color / 10.5 * 255;
|
4169 | return [color, color, color];
|
4170 | }
|
4171 |
|
4172 | var mult = (~~(args > 50) + 1) * 0.5;
|
4173 | var r = (color & 1) * mult * 255;
|
4174 | var g = (color >> 1 & 1) * mult * 255;
|
4175 | var b = (color >> 2 & 1) * mult * 255;
|
4176 | return [r, g, b];
|
4177 | };
|
4178 |
|
4179 | convert.ansi256.rgb = function (args) {
|
4180 |
|
4181 | if (args >= 232) {
|
4182 | var c = (args - 232) * 10 + 8;
|
4183 | return [c, c, c];
|
4184 | }
|
4185 |
|
4186 | args -= 16;
|
4187 | var rem;
|
4188 | var r = Math.floor(args / 36) / 5 * 255;
|
4189 | var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
4190 | var b = rem % 6 / 5 * 255;
|
4191 | return [r, g, b];
|
4192 | };
|
4193 |
|
4194 | convert.rgb.hex = function (args) {
|
4195 | var integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
|
4196 | var string = integer.toString(16).toUpperCase();
|
4197 | return '000000'.substring(string.length) + string;
|
4198 | };
|
4199 |
|
4200 | convert.hex.rgb = function (args) {
|
4201 | var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
4202 |
|
4203 | if (!match) {
|
4204 | return [0, 0, 0];
|
4205 | }
|
4206 |
|
4207 | var colorString = match[0];
|
4208 |
|
4209 | if (match[0].length === 3) {
|
4210 | colorString = colorString.split('').map(function (char) {
|
4211 | return char + char;
|
4212 | }).join('');
|
4213 | }
|
4214 |
|
4215 | var integer = parseInt(colorString, 16);
|
4216 | var r = integer >> 16 & 0xFF;
|
4217 | var g = integer >> 8 & 0xFF;
|
4218 | var b = integer & 0xFF;
|
4219 | return [r, g, b];
|
4220 | };
|
4221 |
|
4222 | convert.rgb.hcg = function (rgb) {
|
4223 | var r = rgb[0] / 255;
|
4224 | var g = rgb[1] / 255;
|
4225 | var b = rgb[2] / 255;
|
4226 | var max = Math.max(Math.max(r, g), b);
|
4227 | var min = Math.min(Math.min(r, g), b);
|
4228 | var chroma = max - min;
|
4229 | var grayscale;
|
4230 | var hue;
|
4231 |
|
4232 | if (chroma < 1) {
|
4233 | grayscale = min / (1 - chroma);
|
4234 | } else {
|
4235 | grayscale = 0;
|
4236 | }
|
4237 |
|
4238 | if (chroma <= 0) {
|
4239 | hue = 0;
|
4240 | } else if (max === r) {
|
4241 | hue = (g - b) / chroma % 6;
|
4242 | } else if (max === g) {
|
4243 | hue = 2 + (b - r) / chroma;
|
4244 | } else {
|
4245 | hue = 4 + (r - g) / chroma + 4;
|
4246 | }
|
4247 |
|
4248 | hue /= 6;
|
4249 | hue %= 1;
|
4250 | return [hue * 360, chroma * 100, grayscale * 100];
|
4251 | };
|
4252 |
|
4253 | convert.hsl.hcg = function (hsl) {
|
4254 | var s = hsl[1] / 100;
|
4255 | var l = hsl[2] / 100;
|
4256 | var c = 1;
|
4257 | var f = 0;
|
4258 |
|
4259 | if (l < 0.5) {
|
4260 | c = 2.0 * s * l;
|
4261 | } else {
|
4262 | c = 2.0 * s * (1.0 - l);
|
4263 | }
|
4264 |
|
4265 | if (c < 1.0) {
|
4266 | f = (l - 0.5 * c) / (1.0 - c);
|
4267 | }
|
4268 |
|
4269 | return [hsl[0], c * 100, f * 100];
|
4270 | };
|
4271 |
|
4272 | convert.hsv.hcg = function (hsv) {
|
4273 | var s = hsv[1] / 100;
|
4274 | var v = hsv[2] / 100;
|
4275 | var c = s * v;
|
4276 | var f = 0;
|
4277 |
|
4278 | if (c < 1.0) {
|
4279 | f = (v - c) / (1 - c);
|
4280 | }
|
4281 |
|
4282 | return [hsv[0], c * 100, f * 100];
|
4283 | };
|
4284 |
|
4285 | convert.hcg.rgb = function (hcg) {
|
4286 | var h = hcg[0] / 360;
|
4287 | var c = hcg[1] / 100;
|
4288 | var g = hcg[2] / 100;
|
4289 |
|
4290 | if (c === 0.0) {
|
4291 | return [g * 255, g * 255, g * 255];
|
4292 | }
|
4293 |
|
4294 | var pure = [0, 0, 0];
|
4295 | var hi = h % 1 * 6;
|
4296 | var v = hi % 1;
|
4297 | var w = 1 - v;
|
4298 | var mg = 0;
|
4299 |
|
4300 | switch (Math.floor(hi)) {
|
4301 | case 0:
|
4302 | pure[0] = 1;
|
4303 | pure[1] = v;
|
4304 | pure[2] = 0;
|
4305 | break;
|
4306 |
|
4307 | case 1:
|
4308 | pure[0] = w;
|
4309 | pure[1] = 1;
|
4310 | pure[2] = 0;
|
4311 | break;
|
4312 |
|
4313 | case 2:
|
4314 | pure[0] = 0;
|
4315 | pure[1] = 1;
|
4316 | pure[2] = v;
|
4317 | break;
|
4318 |
|
4319 | case 3:
|
4320 | pure[0] = 0;
|
4321 | pure[1] = w;
|
4322 | pure[2] = 1;
|
4323 | break;
|
4324 |
|
4325 | case 4:
|
4326 | pure[0] = v;
|
4327 | pure[1] = 0;
|
4328 | pure[2] = 1;
|
4329 | break;
|
4330 |
|
4331 | default:
|
4332 | pure[0] = 1;
|
4333 | pure[1] = 0;
|
4334 | pure[2] = w;
|
4335 | }
|
4336 |
|
4337 | mg = (1.0 - c) * g;
|
4338 | return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
|
4339 | };
|
4340 |
|
4341 | convert.hcg.hsv = function (hcg) {
|
4342 | var c = hcg[1] / 100;
|
4343 | var g = hcg[2] / 100;
|
4344 | var v = c + g * (1.0 - c);
|
4345 | var f = 0;
|
4346 |
|
4347 | if (v > 0.0) {
|
4348 | f = c / v;
|
4349 | }
|
4350 |
|
4351 | return [hcg[0], f * 100, v * 100];
|
4352 | };
|
4353 |
|
4354 | convert.hcg.hsl = function (hcg) {
|
4355 | var c = hcg[1] / 100;
|
4356 | var g = hcg[2] / 100;
|
4357 | var l = g * (1.0 - c) + 0.5 * c;
|
4358 | var s = 0;
|
4359 |
|
4360 | if (l > 0.0 && l < 0.5) {
|
4361 | s = c / (2 * l);
|
4362 | } else if (l >= 0.5 && l < 1.0) {
|
4363 | s = c / (2 * (1 - l));
|
4364 | }
|
4365 |
|
4366 | return [hcg[0], s * 100, l * 100];
|
4367 | };
|
4368 |
|
4369 | convert.hcg.hwb = function (hcg) {
|
4370 | var c = hcg[1] / 100;
|
4371 | var g = hcg[2] / 100;
|
4372 | var v = c + g * (1.0 - c);
|
4373 | return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
4374 | };
|
4375 |
|
4376 | convert.hwb.hcg = function (hwb) {
|
4377 | var w = hwb[1] / 100;
|
4378 | var b = hwb[2] / 100;
|
4379 | var v = 1 - b;
|
4380 | var c = v - w;
|
4381 | var g = 0;
|
4382 |
|
4383 | if (c < 1) {
|
4384 | g = (v - c) / (1 - c);
|
4385 | }
|
4386 |
|
4387 | return [hwb[0], c * 100, g * 100];
|
4388 | };
|
4389 |
|
4390 | convert.apple.rgb = function (apple) {
|
4391 | return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
4392 | };
|
4393 |
|
4394 | convert.rgb.apple = function (rgb) {
|
4395 | return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
4396 | };
|
4397 |
|
4398 | convert.gray.rgb = function (args) {
|
4399 | return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
4400 | };
|
4401 |
|
4402 | convert.gray.hsl = convert.gray.hsv = function (args) {
|
4403 | return [0, 0, args[0]];
|
4404 | };
|
4405 |
|
4406 | convert.gray.hwb = function (gray) {
|
4407 | return [0, 100, gray[0]];
|
4408 | };
|
4409 |
|
4410 | convert.gray.cmyk = function (gray) {
|
4411 | return [0, 0, 0, gray[0]];
|
4412 | };
|
4413 |
|
4414 | convert.gray.lab = function (gray) {
|
4415 | return [gray[0], 0, 0];
|
4416 | };
|
4417 |
|
4418 | convert.gray.hex = function (gray) {
|
4419 | var val = Math.round(gray[0] / 100 * 255) & 0xFF;
|
4420 | var integer = (val << 16) + (val << 8) + val;
|
4421 | var string = integer.toString(16).toUpperCase();
|
4422 | return '000000'.substring(string.length) + string;
|
4423 | };
|
4424 |
|
4425 | convert.rgb.gray = function (rgb) {
|
4426 | var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
4427 | return [val / 255 * 100];
|
4428 | };
|
4429 | });
|
4430 | var conversions_1 = conversions.rgb;
|
4431 | var conversions_2 = conversions.hsl;
|
4432 | var conversions_3 = conversions.hsv;
|
4433 | var conversions_4 = conversions.hwb;
|
4434 | var conversions_5 = conversions.cmyk;
|
4435 | var conversions_6 = conversions.xyz;
|
4436 | var conversions_7 = conversions.lab;
|
4437 | var conversions_8 = conversions.lch;
|
4438 | var conversions_9 = conversions.hex;
|
4439 | var conversions_10 = conversions.keyword;
|
4440 | var conversions_11 = conversions.ansi16;
|
4441 | var conversions_12 = conversions.ansi256;
|
4442 | var conversions_13 = conversions.hcg;
|
4443 | var conversions_14 = conversions.apple;
|
4444 | var conversions_15 = conversions.gray;
|
4445 |
|
4446 |
|
4447 |
|
4448 |
|
4449 |
|
4450 |
|
4451 |
|
4452 |
|
4453 |
|
4454 |
|
4455 |
|
4456 |
|
4457 | function buildGraph() {
|
4458 | var graph = {};
|
4459 |
|
4460 | var models = Object.keys(conversions);
|
4461 |
|
4462 | for (var len = models.length, i = 0; i < len; i++) {
|
4463 | graph[models[i]] = {
|
4464 |
|
4465 |
|
4466 | distance: -1,
|
4467 | parent: null
|
4468 | };
|
4469 | }
|
4470 |
|
4471 | return graph;
|
4472 | }
|
4473 |
|
4474 |
|
4475 | function deriveBFS(fromModel) {
|
4476 | var graph = buildGraph();
|
4477 | var queue = [fromModel];
|
4478 |
|
4479 | graph[fromModel].distance = 0;
|
4480 |
|
4481 | while (queue.length) {
|
4482 | var current = queue.pop();
|
4483 | var adjacents = Object.keys(conversions[current]);
|
4484 |
|
4485 | for (var len = adjacents.length, i = 0; i < len; i++) {
|
4486 | var adjacent = adjacents[i];
|
4487 | var node = graph[adjacent];
|
4488 |
|
4489 | if (node.distance === -1) {
|
4490 | node.distance = graph[current].distance + 1;
|
4491 | node.parent = current;
|
4492 | queue.unshift(adjacent);
|
4493 | }
|
4494 | }
|
4495 | }
|
4496 |
|
4497 | return graph;
|
4498 | }
|
4499 |
|
4500 | function link(from, to) {
|
4501 | return function (args) {
|
4502 | return to(from(args));
|
4503 | };
|
4504 | }
|
4505 |
|
4506 | function wrapConversion(toModel, graph) {
|
4507 | var path = [graph[toModel].parent, toModel];
|
4508 | var fn = conversions[graph[toModel].parent][toModel];
|
4509 | var cur = graph[toModel].parent;
|
4510 |
|
4511 | while (graph[cur].parent) {
|
4512 | path.unshift(graph[cur].parent);
|
4513 | fn = link(conversions[graph[cur].parent][cur], fn);
|
4514 | cur = graph[cur].parent;
|
4515 | }
|
4516 |
|
4517 | fn.conversion = path;
|
4518 | return fn;
|
4519 | }
|
4520 |
|
4521 | var route = function (fromModel) {
|
4522 | var graph = deriveBFS(fromModel);
|
4523 | var conversion = {};
|
4524 | var models = Object.keys(graph);
|
4525 |
|
4526 | for (var len = models.length, i = 0; i < len; i++) {
|
4527 | var toModel = models[i];
|
4528 | var node = graph[toModel];
|
4529 |
|
4530 | if (node.parent === null) {
|
4531 |
|
4532 | continue;
|
4533 | }
|
4534 |
|
4535 | conversion[toModel] = wrapConversion(toModel, graph);
|
4536 | }
|
4537 |
|
4538 | return conversion;
|
4539 | };
|
4540 |
|
4541 | var convert = {};
|
4542 | var models = Object.keys(conversions);
|
4543 |
|
4544 | function wrapRaw(fn) {
|
4545 | var wrappedFn = function (args) {
|
4546 | if (args === undefined || args === null) {
|
4547 | return args;
|
4548 | }
|
4549 |
|
4550 | if (arguments.length > 1) {
|
4551 | args = Array.prototype.slice.call(arguments);
|
4552 | }
|
4553 |
|
4554 | return fn(args);
|
4555 | };
|
4556 |
|
4557 |
|
4558 | if ('conversion' in fn) {
|
4559 | wrappedFn.conversion = fn.conversion;
|
4560 | }
|
4561 |
|
4562 | return wrappedFn;
|
4563 | }
|
4564 |
|
4565 | function wrapRounded(fn) {
|
4566 | var wrappedFn = function (args) {
|
4567 | if (args === undefined || args === null) {
|
4568 | return args;
|
4569 | }
|
4570 |
|
4571 | if (arguments.length > 1) {
|
4572 | args = Array.prototype.slice.call(arguments);
|
4573 | }
|
4574 |
|
4575 | var result = fn(args);
|
4576 |
|
4577 |
|
4578 |
|
4579 | if (typeof result === 'object') {
|
4580 | for (var len = result.length, i = 0; i < len; i++) {
|
4581 | result[i] = Math.round(result[i]);
|
4582 | }
|
4583 | }
|
4584 |
|
4585 | return result;
|
4586 | };
|
4587 |
|
4588 |
|
4589 | if ('conversion' in fn) {
|
4590 | wrappedFn.conversion = fn.conversion;
|
4591 | }
|
4592 |
|
4593 | return wrappedFn;
|
4594 | }
|
4595 |
|
4596 | models.forEach(function (fromModel) {
|
4597 | convert[fromModel] = {};
|
4598 | Object.defineProperty(convert[fromModel], 'channels', {
|
4599 | value: conversions[fromModel].channels
|
4600 | });
|
4601 | Object.defineProperty(convert[fromModel], 'labels', {
|
4602 | value: conversions[fromModel].labels
|
4603 | });
|
4604 | var routes = route(fromModel);
|
4605 | var routeModels = Object.keys(routes);
|
4606 | routeModels.forEach(function (toModel) {
|
4607 | var fn = routes[toModel];
|
4608 | convert[fromModel][toModel] = wrapRounded(fn);
|
4609 | convert[fromModel][toModel].raw = wrapRaw(fn);
|
4610 | });
|
4611 | });
|
4612 | var colorConvert = convert;
|
4613 |
|
4614 | var ansiStyles = createCommonjsModule(function (module) {
|
4615 |
|
4616 | const wrapAnsi16 = (fn, offset) => function () {
|
4617 | const code = fn.apply(colorConvert, arguments);
|
4618 | return `\u001B[${code + offset}m`;
|
4619 | };
|
4620 |
|
4621 | const wrapAnsi256 = (fn, offset) => function () {
|
4622 | const code = fn.apply(colorConvert, arguments);
|
4623 | return `\u001B[${38 + offset};5;${code}m`;
|
4624 | };
|
4625 |
|
4626 | const wrapAnsi16m = (fn, offset) => function () {
|
4627 | const rgb = fn.apply(colorConvert, arguments);
|
4628 | return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
4629 | };
|
4630 |
|
4631 | function assembleStyles() {
|
4632 | const codes = new Map();
|
4633 | const styles = {
|
4634 | modifier: {
|
4635 | reset: [0, 0],
|
4636 |
|
4637 | bold: [1, 22],
|
4638 | dim: [2, 22],
|
4639 | italic: [3, 23],
|
4640 | underline: [4, 24],
|
4641 | inverse: [7, 27],
|
4642 | hidden: [8, 28],
|
4643 | strikethrough: [9, 29]
|
4644 | },
|
4645 | color: {
|
4646 | black: [30, 39],
|
4647 | red: [31, 39],
|
4648 | green: [32, 39],
|
4649 | yellow: [33, 39],
|
4650 | blue: [34, 39],
|
4651 | magenta: [35, 39],
|
4652 | cyan: [36, 39],
|
4653 | white: [37, 39],
|
4654 | gray: [90, 39],
|
4655 |
|
4656 | redBright: [91, 39],
|
4657 | greenBright: [92, 39],
|
4658 | yellowBright: [93, 39],
|
4659 | blueBright: [94, 39],
|
4660 | magentaBright: [95, 39],
|
4661 | cyanBright: [96, 39],
|
4662 | whiteBright: [97, 39]
|
4663 | },
|
4664 | bgColor: {
|
4665 | bgBlack: [40, 49],
|
4666 | bgRed: [41, 49],
|
4667 | bgGreen: [42, 49],
|
4668 | bgYellow: [43, 49],
|
4669 | bgBlue: [44, 49],
|
4670 | bgMagenta: [45, 49],
|
4671 | bgCyan: [46, 49],
|
4672 | bgWhite: [47, 49],
|
4673 |
|
4674 | bgBlackBright: [100, 49],
|
4675 | bgRedBright: [101, 49],
|
4676 | bgGreenBright: [102, 49],
|
4677 | bgYellowBright: [103, 49],
|
4678 | bgBlueBright: [104, 49],
|
4679 | bgMagentaBright: [105, 49],
|
4680 | bgCyanBright: [106, 49],
|
4681 | bgWhiteBright: [107, 49]
|
4682 | }
|
4683 | };
|
4684 |
|
4685 | styles.color.grey = styles.color.gray;
|
4686 |
|
4687 | for (const groupName of Object.keys(styles)) {
|
4688 | const group = styles[groupName];
|
4689 |
|
4690 | for (const styleName of Object.keys(group)) {
|
4691 | const style = group[styleName];
|
4692 | styles[styleName] = {
|
4693 | open: `\u001B[${style[0]}m`,
|
4694 | close: `\u001B[${style[1]}m`
|
4695 | };
|
4696 | group[styleName] = styles[styleName];
|
4697 | codes.set(style[0], style[1]);
|
4698 | }
|
4699 |
|
4700 | Object.defineProperty(styles, groupName, {
|
4701 | value: group,
|
4702 | enumerable: false
|
4703 | });
|
4704 | Object.defineProperty(styles, 'codes', {
|
4705 | value: codes,
|
4706 | enumerable: false
|
4707 | });
|
4708 | }
|
4709 |
|
4710 | const ansi2ansi = n => n;
|
4711 |
|
4712 | const rgb2rgb = (r, g, b) => [r, g, b];
|
4713 |
|
4714 | styles.color.close = '\u001B[39m';
|
4715 | styles.bgColor.close = '\u001B[49m';
|
4716 | styles.color.ansi = {
|
4717 | ansi: wrapAnsi16(ansi2ansi, 0)
|
4718 | };
|
4719 | styles.color.ansi256 = {
|
4720 | ansi256: wrapAnsi256(ansi2ansi, 0)
|
4721 | };
|
4722 | styles.color.ansi16m = {
|
4723 | rgb: wrapAnsi16m(rgb2rgb, 0)
|
4724 | };
|
4725 | styles.bgColor.ansi = {
|
4726 | ansi: wrapAnsi16(ansi2ansi, 10)
|
4727 | };
|
4728 | styles.bgColor.ansi256 = {
|
4729 | ansi256: wrapAnsi256(ansi2ansi, 10)
|
4730 | };
|
4731 | styles.bgColor.ansi16m = {
|
4732 | rgb: wrapAnsi16m(rgb2rgb, 10)
|
4733 | };
|
4734 |
|
4735 | for (let key of Object.keys(colorConvert)) {
|
4736 | if (typeof colorConvert[key] !== 'object') {
|
4737 | continue;
|
4738 | }
|
4739 |
|
4740 | const suite = colorConvert[key];
|
4741 |
|
4742 | if (key === 'ansi16') {
|
4743 | key = 'ansi';
|
4744 | }
|
4745 |
|
4746 | if ('ansi16' in suite) {
|
4747 | styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
|
4748 | styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
|
4749 | }
|
4750 |
|
4751 | if ('ansi256' in suite) {
|
4752 | styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
|
4753 | styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
|
4754 | }
|
4755 |
|
4756 | if ('rgb' in suite) {
|
4757 | styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
|
4758 | styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
|
4759 | }
|
4760 | }
|
4761 |
|
4762 | return styles;
|
4763 | }
|
4764 |
|
4765 |
|
4766 | Object.defineProperty(module, 'exports', {
|
4767 | enumerable: true,
|
4768 | get: assembleStyles
|
4769 | });
|
4770 | });
|
4771 |
|
4772 | var hasFlag = (flag, argv) => {
|
4773 | argv = argv || process.argv;
|
4774 | const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
|
4775 | const pos = argv.indexOf(prefix + flag);
|
4776 | const terminatorPos = argv.indexOf('--');
|
4777 | return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
|
4778 | };
|
4779 |
|
4780 | const env = process.env;
|
4781 | let forceColor;
|
4782 |
|
4783 | if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
|
4784 | forceColor = false;
|
4785 | } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
|
4786 | forceColor = true;
|
4787 | }
|
4788 |
|
4789 | if ('FORCE_COLOR' in env) {
|
4790 | forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
|
4791 | }
|
4792 |
|
4793 | function translateLevel(level) {
|
4794 | if (level === 0) {
|
4795 | return false;
|
4796 | }
|
4797 |
|
4798 | return {
|
4799 | level,
|
4800 | hasBasic: true,
|
4801 | has256: level >= 2,
|
4802 | has16m: level >= 3
|
4803 | };
|
4804 | }
|
4805 |
|
4806 | function supportsColor(stream) {
|
4807 | if (forceColor === false) {
|
4808 | return 0;
|
4809 | }
|
4810 |
|
4811 | if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
|
4812 | return 3;
|
4813 | }
|
4814 |
|
4815 | if (hasFlag('color=256')) {
|
4816 | return 2;
|
4817 | }
|
4818 |
|
4819 | if (stream && !stream.isTTY && forceColor !== true) {
|
4820 | return 0;
|
4821 | }
|
4822 |
|
4823 | const min = forceColor ? 1 : 0;
|
4824 |
|
4825 | if (process.platform === 'win32') {
|
4826 |
|
4827 |
|
4828 |
|
4829 |
|
4830 |
|
4831 |
|
4832 | const osRelease = os$1.release().split('.');
|
4833 |
|
4834 | if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
4835 | return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
4836 | }
|
4837 |
|
4838 | return 1;
|
4839 | }
|
4840 |
|
4841 | if ('CI' in env) {
|
4842 | if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
4843 | return 1;
|
4844 | }
|
4845 |
|
4846 | return min;
|
4847 | }
|
4848 |
|
4849 | if ('TEAMCITY_VERSION' in env) {
|
4850 | return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
4851 | }
|
4852 |
|
4853 | if (env.COLORTERM === 'truecolor') {
|
4854 | return 3;
|
4855 | }
|
4856 |
|
4857 | if ('TERM_PROGRAM' in env) {
|
4858 | const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
4859 |
|
4860 | switch (env.TERM_PROGRAM) {
|
4861 | case 'iTerm.app':
|
4862 | return version >= 3 ? 3 : 2;
|
4863 |
|
4864 | case 'Apple_Terminal':
|
4865 | return 2;
|
4866 |
|
4867 | }
|
4868 | }
|
4869 |
|
4870 | if (/-256(color)?$/i.test(env.TERM)) {
|
4871 | return 2;
|
4872 | }
|
4873 |
|
4874 | if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
4875 | return 1;
|
4876 | }
|
4877 |
|
4878 | if ('COLORTERM' in env) {
|
4879 | return 1;
|
4880 | }
|
4881 |
|
4882 | if (env.TERM === 'dumb') {
|
4883 | return min;
|
4884 | }
|
4885 |
|
4886 | return min;
|
4887 | }
|
4888 |
|
4889 | function getSupportLevel(stream) {
|
4890 | const level = supportsColor(stream);
|
4891 | return translateLevel(level);
|
4892 | }
|
4893 |
|
4894 | var supportsColor_1 = {
|
4895 | supportsColor: getSupportLevel,
|
4896 | stdout: getSupportLevel(process.stdout),
|
4897 | stderr: getSupportLevel(process.stderr)
|
4898 | };
|
4899 |
|
4900 | const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
4901 | const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
4902 | const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
4903 | const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
|
4904 | const ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
|
4905 |
|
4906 | function unescape(c) {
|
4907 | if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
|
4908 | return String.fromCharCode(parseInt(c.slice(1), 16));
|
4909 | }
|
4910 |
|
4911 | return ESCAPES.get(c) || c;
|
4912 | }
|
4913 |
|
4914 | function parseArguments(name, args) {
|
4915 | const results = [];
|
4916 | const chunks = args.trim().split(/\s*,\s*/g);
|
4917 | let matches;
|
4918 |
|
4919 | for (const chunk of chunks) {
|
4920 | if (!isNaN(chunk)) {
|
4921 | results.push(Number(chunk));
|
4922 | } else if (matches = chunk.match(STRING_REGEX)) {
|
4923 | results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
|
4924 | } else {
|
4925 | throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
4926 | }
|
4927 | }
|
4928 |
|
4929 | return results;
|
4930 | }
|
4931 |
|
4932 | function parseStyle(style) {
|
4933 | STYLE_REGEX.lastIndex = 0;
|
4934 | const results = [];
|
4935 | let matches;
|
4936 |
|
4937 | while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
4938 | const name = matches[1];
|
4939 |
|
4940 | if (matches[2]) {
|
4941 | const args = parseArguments(name, matches[2]);
|
4942 | results.push([name].concat(args));
|
4943 | } else {
|
4944 | results.push([name]);
|
4945 | }
|
4946 | }
|
4947 |
|
4948 | return results;
|
4949 | }
|
4950 |
|
4951 | function buildStyle(chalk, styles) {
|
4952 | const enabled = {};
|
4953 |
|
4954 | for (const layer of styles) {
|
4955 | for (const style of layer.styles) {
|
4956 | enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
4957 | }
|
4958 | }
|
4959 |
|
4960 | let current = chalk;
|
4961 |
|
4962 | for (const styleName of Object.keys(enabled)) {
|
4963 | if (Array.isArray(enabled[styleName])) {
|
4964 | if (!(styleName in current)) {
|
4965 | throw new Error(`Unknown Chalk style: ${styleName}`);
|
4966 | }
|
4967 |
|
4968 | if (enabled[styleName].length > 0) {
|
4969 | current = current[styleName].apply(current, enabled[styleName]);
|
4970 | } else {
|
4971 | current = current[styleName];
|
4972 | }
|
4973 | }
|
4974 | }
|
4975 |
|
4976 | return current;
|
4977 | }
|
4978 |
|
4979 | var templates = (chalk, tmp) => {
|
4980 | const styles = [];
|
4981 | const chunks = [];
|
4982 | let chunk = [];
|
4983 |
|
4984 | tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
|
4985 | if (escapeChar) {
|
4986 | chunk.push(unescape(escapeChar));
|
4987 | } else if (style) {
|
4988 | const str = chunk.join('');
|
4989 | chunk = [];
|
4990 | chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
|
4991 | styles.push({
|
4992 | inverse,
|
4993 | styles: parseStyle(style)
|
4994 | });
|
4995 | } else if (close) {
|
4996 | if (styles.length === 0) {
|
4997 | throw new Error('Found extraneous } in Chalk template literal');
|
4998 | }
|
4999 |
|
5000 | chunks.push(buildStyle(chalk, styles)(chunk.join('')));
|
5001 | chunk = [];
|
5002 | styles.pop();
|
5003 | } else {
|
5004 | chunk.push(chr);
|
5005 | }
|
5006 | });
|
5007 | chunks.push(chunk.join(''));
|
5008 |
|
5009 | if (styles.length > 0) {
|
5010 | const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
5011 | throw new Error(errMsg);
|
5012 | }
|
5013 |
|
5014 | return chunks.join('');
|
5015 | };
|
5016 |
|
5017 | var chalk = createCommonjsModule(function (module) {
|
5018 |
|
5019 | const stdoutColor = supportsColor_1.stdout;
|
5020 | const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');
|
5021 |
|
5022 | const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
|
5023 |
|
5024 | const skipModels = new Set(['gray']);
|
5025 | const styles = Object.create(null);
|
5026 |
|
5027 | function applyOptions(obj, options) {
|
5028 | options = options || {};
|
5029 |
|
5030 | const scLevel = stdoutColor ? stdoutColor.level : 0;
|
5031 | obj.level = options.level === undefined ? scLevel : options.level;
|
5032 | obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
|
5033 | }
|
5034 |
|
5035 | function Chalk(options) {
|
5036 |
|
5037 |
|
5038 | if (!this || !(this instanceof Chalk) || this.template) {
|
5039 | const chalk = {};
|
5040 | applyOptions(chalk, options);
|
5041 |
|
5042 | chalk.template = function () {
|
5043 | const args = [].slice.call(arguments);
|
5044 | return chalkTag.apply(null, [chalk.template].concat(args));
|
5045 | };
|
5046 |
|
5047 | Object.setPrototypeOf(chalk, Chalk.prototype);
|
5048 | Object.setPrototypeOf(chalk.template, chalk);
|
5049 | chalk.template.constructor = Chalk;
|
5050 | return chalk.template;
|
5051 | }
|
5052 |
|
5053 | applyOptions(this, options);
|
5054 | }
|
5055 |
|
5056 |
|
5057 | if (isSimpleWindowsTerm) {
|
5058 | ansiStyles.blue.open = '\u001B[94m';
|
5059 | }
|
5060 |
|
5061 | for (const key of Object.keys(ansiStyles)) {
|
5062 | ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
|
5063 | styles[key] = {
|
5064 | get() {
|
5065 | const codes = ansiStyles[key];
|
5066 | return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
|
5067 | }
|
5068 |
|
5069 | };
|
5070 | }
|
5071 |
|
5072 | styles.visible = {
|
5073 | get() {
|
5074 | return build.call(this, this._styles || [], true, 'visible');
|
5075 | }
|
5076 |
|
5077 | };
|
5078 | ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
|
5079 |
|
5080 | for (const model of Object.keys(ansiStyles.color.ansi)) {
|
5081 | if (skipModels.has(model)) {
|
5082 | continue;
|
5083 | }
|
5084 |
|
5085 | styles[model] = {
|
5086 | get() {
|
5087 | const level = this.level;
|
5088 | return function () {
|
5089 | const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
|
5090 | const codes = {
|
5091 | open,
|
5092 | close: ansiStyles.color.close,
|
5093 | closeRe: ansiStyles.color.closeRe
|
5094 | };
|
5095 | return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
|
5096 | };
|
5097 | }
|
5098 |
|
5099 | };
|
5100 | }
|
5101 |
|
5102 | ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
|
5103 |
|
5104 | for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
|
5105 | if (skipModels.has(model)) {
|
5106 | continue;
|
5107 | }
|
5108 |
|
5109 | const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
5110 | styles[bgModel] = {
|
5111 | get() {
|
5112 | const level = this.level;
|
5113 | return function () {
|
5114 | const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
|
5115 | const codes = {
|
5116 | open,
|
5117 | close: ansiStyles.bgColor.close,
|
5118 | closeRe: ansiStyles.bgColor.closeRe
|
5119 | };
|
5120 | return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
|
5121 | };
|
5122 | }
|
5123 |
|
5124 | };
|
5125 | }
|
5126 |
|
5127 | const proto = Object.defineProperties(() => {}, styles);
|
5128 |
|
5129 | function build(_styles, _empty, key) {
|
5130 | const builder = function () {
|
5131 | return applyStyle.apply(builder, arguments);
|
5132 | };
|
5133 |
|
5134 | builder._styles = _styles;
|
5135 | builder._empty = _empty;
|
5136 | const self = this;
|
5137 | Object.defineProperty(builder, 'level', {
|
5138 | enumerable: true,
|
5139 |
|
5140 | get() {
|
5141 | return self.level;
|
5142 | },
|
5143 |
|
5144 | set(level) {
|
5145 | self.level = level;
|
5146 | }
|
5147 |
|
5148 | });
|
5149 | Object.defineProperty(builder, 'enabled', {
|
5150 | enumerable: true,
|
5151 |
|
5152 | get() {
|
5153 | return self.enabled;
|
5154 | },
|
5155 |
|
5156 | set(enabled) {
|
5157 | self.enabled = enabled;
|
5158 | }
|
5159 |
|
5160 | });
|
5161 |
|
5162 | builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey';
|
5163 |
|
5164 |
|
5165 | builder.__proto__ = proto;
|
5166 |
|
5167 | return builder;
|
5168 | }
|
5169 |
|
5170 | function applyStyle() {
|
5171 |
|
5172 | const args = arguments;
|
5173 | const argsLen = args.length;
|
5174 | let str = String(arguments[0]);
|
5175 |
|
5176 | if (argsLen === 0) {
|
5177 | return '';
|
5178 | }
|
5179 |
|
5180 | if (argsLen > 1) {
|
5181 |
|
5182 | for (let a = 1; a < argsLen; a++) {
|
5183 | str += ' ' + args[a];
|
5184 | }
|
5185 | }
|
5186 |
|
5187 | if (!this.enabled || this.level <= 0 || !str) {
|
5188 | return this._empty ? '' : str;
|
5189 | }
|
5190 |
|
5191 |
|
5192 |
|
5193 |
|
5194 | const originalDim = ansiStyles.dim.open;
|
5195 |
|
5196 | if (isSimpleWindowsTerm && this.hasGrey) {
|
5197 | ansiStyles.dim.open = '';
|
5198 | }
|
5199 |
|
5200 | for (const code of this._styles.slice().reverse()) {
|
5201 |
|
5202 |
|
5203 |
|
5204 | str = code.open + str.replace(code.closeRe, code.open) + code.close;
|
5205 |
|
5206 |
|
5207 |
|
5208 | str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
|
5209 | }
|
5210 |
|
5211 |
|
5212 | ansiStyles.dim.open = originalDim;
|
5213 | return str;
|
5214 | }
|
5215 |
|
5216 | function chalkTag(chalk, strings) {
|
5217 | if (!Array.isArray(strings)) {
|
5218 |
|
5219 |
|
5220 | return [].slice.call(arguments, 1).join(' ');
|
5221 | }
|
5222 |
|
5223 | const args = [].slice.call(arguments, 2);
|
5224 | const parts = [strings.raw[0]];
|
5225 |
|
5226 | for (let i = 1; i < strings.length; i++) {
|
5227 | parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
|
5228 | parts.push(String(strings.raw[i]));
|
5229 | }
|
5230 |
|
5231 | return templates(chalk, parts.join(''));
|
5232 | }
|
5233 |
|
5234 | Object.defineProperties(Chalk.prototype, styles);
|
5235 | module.exports = Chalk();
|
5236 |
|
5237 | module.exports.supportsColor = stdoutColor;
|
5238 | module.exports.default = module.exports;
|
5239 | });
|
5240 | var chalk_1 = chalk.supportsColor;
|
5241 |
|
5242 | var common = createCommonjsModule(function (module, exports) {
|
5243 |
|
5244 | Object.defineProperty(exports, "__esModule", {
|
5245 | value: true
|
5246 | });
|
5247 |
|
5248 | exports.commonDeprecatedHandler = (keyOrPair, redirectTo, {
|
5249 | descriptor
|
5250 | }) => {
|
5251 | const messages = [`${chalk.default.yellow(typeof keyOrPair === 'string' ? descriptor.key(keyOrPair) : descriptor.pair(keyOrPair))} is deprecated`];
|
5252 |
|
5253 | if (redirectTo) {
|
5254 | messages.push(`we now treat it as ${chalk.default.blue(typeof redirectTo === 'string' ? descriptor.key(redirectTo) : descriptor.pair(redirectTo))}`);
|
5255 | }
|
5256 |
|
5257 | return messages.join('; ') + '.';
|
5258 | };
|
5259 | });
|
5260 | unwrapExports(common);
|
5261 | var common_1 = common.commonDeprecatedHandler;
|
5262 |
|
5263 | var deprecated = createCommonjsModule(function (module, exports) {
|
5264 |
|
5265 | Object.defineProperty(exports, "__esModule", {
|
5266 | value: true
|
5267 | });
|
5268 |
|
5269 | tslib_1.__exportStar(common, exports);
|
5270 | });
|
5271 | unwrapExports(deprecated);
|
5272 |
|
5273 | var common$1 = createCommonjsModule(function (module, exports) {
|
5274 |
|
5275 | Object.defineProperty(exports, "__esModule", {
|
5276 | value: true
|
5277 | });
|
5278 |
|
5279 | exports.commonInvalidHandler = (key, value, utils) => [`Invalid ${chalk.default.red(utils.descriptor.key(key))} value.`, `Expected ${chalk.default.blue(utils.schemas[key].expected(utils))},`, `but received ${chalk.default.red(utils.descriptor.value(value))}.`].join(' ');
|
5280 | });
|
5281 | unwrapExports(common$1);
|
5282 | var common_1$1 = common$1.commonInvalidHandler;
|
5283 |
|
5284 | var invalid = createCommonjsModule(function (module, exports) {
|
5285 |
|
5286 | Object.defineProperty(exports, "__esModule", {
|
5287 | value: true
|
5288 | });
|
5289 |
|
5290 | tslib_1.__exportStar(common$1, exports);
|
5291 | });
|
5292 | unwrapExports(invalid);
|
5293 |
|
5294 |
|
5295 |
|
5296 | var arr = [];
|
5297 | var charCodeCache = [];
|
5298 |
|
5299 | var leven = function (a, b) {
|
5300 | if (a === b) {
|
5301 | return 0;
|
5302 | }
|
5303 |
|
5304 | var swap = a;
|
5305 |
|
5306 |
|
5307 | if (a.length > b.length) {
|
5308 | a = b;
|
5309 | b = swap;
|
5310 | }
|
5311 |
|
5312 | var aLen = a.length;
|
5313 | var bLen = b.length;
|
5314 |
|
5315 | if (aLen === 0) {
|
5316 | return bLen;
|
5317 | }
|
5318 |
|
5319 | if (bLen === 0) {
|
5320 | return aLen;
|
5321 | }
|
5322 |
|
5323 |
|
5324 |
|
5325 |
|
5326 |
|
5327 | while (aLen > 0 && a.charCodeAt(~-aLen) === b.charCodeAt(~-bLen)) {
|
5328 | aLen--;
|
5329 | bLen--;
|
5330 | }
|
5331 |
|
5332 | if (aLen === 0) {
|
5333 | return bLen;
|
5334 | }
|
5335 |
|
5336 |
|
5337 |
|
5338 |
|
5339 | var start = 0;
|
5340 |
|
5341 | while (start < aLen && a.charCodeAt(start) === b.charCodeAt(start)) {
|
5342 | start++;
|
5343 | }
|
5344 |
|
5345 | aLen -= start;
|
5346 | bLen -= start;
|
5347 |
|
5348 | if (aLen === 0) {
|
5349 | return bLen;
|
5350 | }
|
5351 |
|
5352 | var bCharCode;
|
5353 | var ret;
|
5354 | var tmp;
|
5355 | var tmp2;
|
5356 | var i = 0;
|
5357 | var j = 0;
|
5358 |
|
5359 | while (i < aLen) {
|
5360 | charCodeCache[start + i] = a.charCodeAt(start + i);
|
5361 | arr[i] = ++i;
|
5362 | }
|
5363 |
|
5364 | while (j < bLen) {
|
5365 | bCharCode = b.charCodeAt(start + j);
|
5366 | tmp = j++;
|
5367 | ret = j;
|
5368 |
|
5369 | for (i = 0; i < aLen; i++) {
|
5370 | tmp2 = bCharCode === charCodeCache[start + i] ? tmp : tmp + 1;
|
5371 | tmp = arr[i];
|
5372 | ret = arr[i] = tmp > ret ? tmp2 > ret ? ret + 1 : tmp2 : tmp2 > tmp ? tmp + 1 : tmp2;
|
5373 | }
|
5374 | }
|
5375 |
|
5376 | return ret;
|
5377 | };
|
5378 |
|
5379 | var leven_1 = createCommonjsModule(function (module, exports) {
|
5380 |
|
5381 | Object.defineProperty(exports, "__esModule", {
|
5382 | value: true
|
5383 | });
|
5384 |
|
5385 | exports.levenUnknownHandler = (key, value, {
|
5386 | descriptor,
|
5387 | logger,
|
5388 | schemas
|
5389 | }) => {
|
5390 | const messages = [`Ignored unknown option ${chalk.default.yellow(descriptor.pair({
|
5391 | key,
|
5392 | value
|
5393 | }))}.`];
|
5394 | const suggestion = Object.keys(schemas).sort().find(knownKey => leven(key, knownKey) < 3);
|
5395 |
|
5396 | if (suggestion) {
|
5397 | messages.push(`Did you mean ${chalk.default.blue(descriptor.key(suggestion))}?`);
|
5398 | }
|
5399 |
|
5400 | logger.warn(messages.join(' '));
|
5401 | };
|
5402 | });
|
5403 | unwrapExports(leven_1);
|
5404 | var leven_2 = leven_1.levenUnknownHandler;
|
5405 |
|
5406 | var unknown = createCommonjsModule(function (module, exports) {
|
5407 |
|
5408 | Object.defineProperty(exports, "__esModule", {
|
5409 | value: true
|
5410 | });
|
5411 |
|
5412 | tslib_1.__exportStar(leven_1, exports);
|
5413 | });
|
5414 | unwrapExports(unknown);
|
5415 |
|
5416 | var handlers = createCommonjsModule(function (module, exports) {
|
5417 |
|
5418 | Object.defineProperty(exports, "__esModule", {
|
5419 | value: true
|
5420 | });
|
5421 |
|
5422 | tslib_1.__exportStar(deprecated, exports);
|
5423 |
|
5424 | tslib_1.__exportStar(invalid, exports);
|
5425 |
|
5426 | tslib_1.__exportStar(unknown, exports);
|
5427 | });
|
5428 | unwrapExports(handlers);
|
5429 |
|
5430 | var schema = createCommonjsModule(function (module, exports) {
|
5431 |
|
5432 | Object.defineProperty(exports, "__esModule", {
|
5433 | value: true
|
5434 | });
|
5435 | const HANDLER_KEYS = ['default', 'expected', 'validate', 'deprecated', 'forward', 'redirect', 'overlap', 'preprocess', 'postprocess'];
|
5436 |
|
5437 | function createSchema(SchemaConstructor, parameters) {
|
5438 | const schema = new SchemaConstructor(parameters);
|
5439 | const subSchema = Object.create(schema);
|
5440 |
|
5441 | for (const handlerKey of HANDLER_KEYS) {
|
5442 | if (handlerKey in parameters) {
|
5443 | subSchema[handlerKey] = normalizeHandler(parameters[handlerKey], schema, Schema.prototype[handlerKey].length);
|
5444 | }
|
5445 | }
|
5446 |
|
5447 | return subSchema;
|
5448 | }
|
5449 |
|
5450 | exports.createSchema = createSchema;
|
5451 |
|
5452 | class Schema {
|
5453 | constructor(parameters) {
|
5454 | this.name = parameters.name;
|
5455 | }
|
5456 |
|
5457 | static create(parameters) {
|
5458 |
|
5459 | return createSchema(this, parameters);
|
5460 | }
|
5461 |
|
5462 | default(_utils) {
|
5463 | return undefined;
|
5464 | }
|
5465 |
|
5466 |
|
5467 | expected(_utils) {
|
5468 | return 'nothing';
|
5469 | }
|
5470 |
|
5471 |
|
5472 | validate(_value, _utils) {
|
5473 | return false;
|
5474 | }
|
5475 |
|
5476 | deprecated(_value, _utils) {
|
5477 | return false;
|
5478 | }
|
5479 |
|
5480 | forward(_value, _utils) {
|
5481 | return undefined;
|
5482 | }
|
5483 |
|
5484 | redirect(_value, _utils) {
|
5485 | return undefined;
|
5486 | }
|
5487 |
|
5488 | overlap(currentValue, _newValue, _utils) {
|
5489 | return currentValue;
|
5490 | }
|
5491 |
|
5492 | preprocess(value, _utils) {
|
5493 | return value;
|
5494 | }
|
5495 |
|
5496 | postprocess(value, _utils) {
|
5497 | return value;
|
5498 | }
|
5499 |
|
5500 | }
|
5501 |
|
5502 | exports.Schema = Schema;
|
5503 |
|
5504 | function normalizeHandler(handler, superSchema, handlerArgumentsLength) {
|
5505 | return typeof handler === 'function' ? (...args) => handler(...args.slice(0, handlerArgumentsLength - 1), superSchema, ...args.slice(handlerArgumentsLength - 1)) : () => handler;
|
5506 | }
|
5507 | });
|
5508 | unwrapExports(schema);
|
5509 | var schema_1 = schema.createSchema;
|
5510 | var schema_2 = schema.Schema;
|
5511 |
|
5512 | var alias = createCommonjsModule(function (module, exports) {
|
5513 |
|
5514 | Object.defineProperty(exports, "__esModule", {
|
5515 | value: true
|
5516 | });
|
5517 |
|
5518 | class AliasSchema extends schema.Schema {
|
5519 | constructor(parameters) {
|
5520 | super(parameters);
|
5521 | this._sourceName = parameters.sourceName;
|
5522 | }
|
5523 |
|
5524 | expected(utils) {
|
5525 | return utils.schemas[this._sourceName].expected(utils);
|
5526 | }
|
5527 |
|
5528 | validate(value, utils) {
|
5529 | return utils.schemas[this._sourceName].validate(value, utils);
|
5530 | }
|
5531 |
|
5532 | redirect(_value, _utils) {
|
5533 | return this._sourceName;
|
5534 | }
|
5535 |
|
5536 | }
|
5537 |
|
5538 | exports.AliasSchema = AliasSchema;
|
5539 | });
|
5540 | unwrapExports(alias);
|
5541 | var alias_1 = alias.AliasSchema;
|
5542 |
|
5543 | var any = createCommonjsModule(function (module, exports) {
|
5544 |
|
5545 | Object.defineProperty(exports, "__esModule", {
|
5546 | value: true
|
5547 | });
|
5548 |
|
5549 | class AnySchema extends schema.Schema {
|
5550 | expected() {
|
5551 | return 'anything';
|
5552 | }
|
5553 |
|
5554 | validate() {
|
5555 | return true;
|
5556 | }
|
5557 |
|
5558 | }
|
5559 |
|
5560 | exports.AnySchema = AnySchema;
|
5561 | });
|
5562 | unwrapExports(any);
|
5563 | var any_1 = any.AnySchema;
|
5564 |
|
5565 | var array = createCommonjsModule(function (module, exports) {
|
5566 |
|
5567 | Object.defineProperty(exports, "__esModule", {
|
5568 | value: true
|
5569 | });
|
5570 |
|
5571 | class ArraySchema extends schema.Schema {
|
5572 | constructor(_a) {
|
5573 | var {
|
5574 | valueSchema,
|
5575 | name = valueSchema.name
|
5576 | } = _a,
|
5577 | handlers = tslib_1.__rest(_a, ["valueSchema", "name"]);
|
5578 |
|
5579 | super(Object.assign({}, handlers, {
|
5580 | name
|
5581 | }));
|
5582 | this._valueSchema = valueSchema;
|
5583 | }
|
5584 |
|
5585 | expected(utils) {
|
5586 | return `an array of ${this._valueSchema.expected(utils)}`;
|
5587 | }
|
5588 |
|
5589 | validate(value, utils) {
|
5590 | if (!Array.isArray(value)) {
|
5591 | return false;
|
5592 | }
|
5593 |
|
5594 | const invalidValues = [];
|
5595 |
|
5596 | for (const subValue of value) {
|
5597 | const subValidateResult = utils.normalizeValidateResult(this._valueSchema.validate(subValue, utils), subValue);
|
5598 |
|
5599 | if (subValidateResult !== true) {
|
5600 | invalidValues.push(subValidateResult.value);
|
5601 | }
|
5602 | }
|
5603 |
|
5604 | return invalidValues.length === 0 ? true : {
|
5605 | value: invalidValues
|
5606 | };
|
5607 | }
|
5608 |
|
5609 | deprecated(value, utils) {
|
5610 | const deprecatedResult = [];
|
5611 |
|
5612 | for (const subValue of value) {
|
5613 | const subDeprecatedResult = utils.normalizeDeprecatedResult(this._valueSchema.deprecated(subValue, utils), subValue);
|
5614 |
|
5615 | if (subDeprecatedResult !== false) {
|
5616 | deprecatedResult.push(...subDeprecatedResult.map(({
|
5617 | value: deprecatedValue
|
5618 | }) => ({
|
5619 | value: [deprecatedValue]
|
5620 | })));
|
5621 | }
|
5622 | }
|
5623 |
|
5624 | return deprecatedResult;
|
5625 | }
|
5626 |
|
5627 | forward(value, utils) {
|
5628 | const forwardResult = [];
|
5629 |
|
5630 | for (const subValue of value) {
|
5631 | const subForwardResult = utils.normalizeForwardResult(this._valueSchema.forward(subValue, utils), subValue);
|
5632 | forwardResult.push(...subForwardResult.map(wrapTransferResult));
|
5633 | }
|
5634 |
|
5635 | return forwardResult;
|
5636 | }
|
5637 |
|
5638 | redirect(value, utils) {
|
5639 | const remain = [];
|
5640 | const redirect = [];
|
5641 |
|
5642 | for (const subValue of value) {
|
5643 | const subRedirectResult = utils.normalizeRedirectResult(this._valueSchema.redirect(subValue, utils), subValue);
|
5644 |
|
5645 | if ('remain' in subRedirectResult) {
|
5646 | remain.push(subRedirectResult.remain);
|
5647 | }
|
5648 |
|
5649 | redirect.push(...subRedirectResult.redirect.map(wrapTransferResult));
|
5650 | }
|
5651 |
|
5652 | return remain.length === 0 ? {
|
5653 | redirect
|
5654 | } : {
|
5655 | redirect,
|
5656 | remain
|
5657 | };
|
5658 | }
|
5659 |
|
5660 | overlap(currentValue, newValue) {
|
5661 | return currentValue.concat(newValue);
|
5662 | }
|
5663 |
|
5664 | }
|
5665 |
|
5666 | exports.ArraySchema = ArraySchema;
|
5667 |
|
5668 | function wrapTransferResult({
|
5669 | from,
|
5670 | to
|
5671 | }) {
|
5672 | return {
|
5673 | from: [from],
|
5674 | to
|
5675 | };
|
5676 | }
|
5677 | });
|
5678 | unwrapExports(array);
|
5679 | var array_1 = array.ArraySchema;
|
5680 |
|
5681 | var boolean_1 = createCommonjsModule(function (module, exports) {
|
5682 |
|
5683 | Object.defineProperty(exports, "__esModule", {
|
5684 | value: true
|
5685 | });
|
5686 |
|
5687 | class BooleanSchema extends schema.Schema {
|
5688 | expected() {
|
5689 | return 'true or false';
|
5690 | }
|
5691 |
|
5692 | validate(value) {
|
5693 | return typeof value === 'boolean';
|
5694 | }
|
5695 |
|
5696 | }
|
5697 |
|
5698 | exports.BooleanSchema = BooleanSchema;
|
5699 | });
|
5700 | unwrapExports(boolean_1);
|
5701 | var boolean_2 = boolean_1.BooleanSchema;
|
5702 |
|
5703 | var utils = createCommonjsModule(function (module, exports) {
|
5704 |
|
5705 | Object.defineProperty(exports, "__esModule", {
|
5706 | value: true
|
5707 | });
|
5708 |
|
5709 | function recordFromArray(array, mainKey) {
|
5710 | const record = Object.create(null);
|
5711 |
|
5712 | for (const value of array) {
|
5713 | const key = value[mainKey];
|
5714 |
|
5715 | if (record[key]) {
|
5716 | throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`);
|
5717 | }
|
5718 |
|
5719 |
|
5720 | record[key] = value;
|
5721 | }
|
5722 |
|
5723 | return record;
|
5724 | }
|
5725 |
|
5726 | exports.recordFromArray = recordFromArray;
|
5727 |
|
5728 | function mapFromArray(array, mainKey) {
|
5729 | const map = new Map();
|
5730 |
|
5731 | for (const value of array) {
|
5732 | const key = value[mainKey];
|
5733 |
|
5734 | if (map.has(key)) {
|
5735 | throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`);
|
5736 | }
|
5737 |
|
5738 | map.set(key, value);
|
5739 | }
|
5740 |
|
5741 | return map;
|
5742 | }
|
5743 |
|
5744 | exports.mapFromArray = mapFromArray;
|
5745 |
|
5746 | function createAutoChecklist() {
|
5747 | const map = Object.create(null);
|
5748 | return id => {
|
5749 | const idString = JSON.stringify(id);
|
5750 |
|
5751 | if (map[idString]) {
|
5752 | return true;
|
5753 | }
|
5754 |
|
5755 | map[idString] = true;
|
5756 | return false;
|
5757 | };
|
5758 | }
|
5759 |
|
5760 | exports.createAutoChecklist = createAutoChecklist;
|
5761 |
|
5762 | function partition(array, predicate) {
|
5763 | const trueArray = [];
|
5764 | const falseArray = [];
|
5765 |
|
5766 | for (const value of array) {
|
5767 | if (predicate(value)) {
|
5768 | trueArray.push(value);
|
5769 | } else {
|
5770 | falseArray.push(value);
|
5771 | }
|
5772 | }
|
5773 |
|
5774 | return [trueArray, falseArray];
|
5775 | }
|
5776 |
|
5777 | exports.partition = partition;
|
5778 |
|
5779 | function isInt(value) {
|
5780 | return value === Math.floor(value);
|
5781 | }
|
5782 |
|
5783 | exports.isInt = isInt;
|
5784 |
|
5785 | function comparePrimitive(a, b) {
|
5786 | if (a === b) {
|
5787 | return 0;
|
5788 | }
|
5789 |
|
5790 | const typeofA = typeof a;
|
5791 | const typeofB = typeof b;
|
5792 | const orders = ['undefined', 'object', 'boolean', 'number', 'string'];
|
5793 |
|
5794 | if (typeofA !== typeofB) {
|
5795 | return orders.indexOf(typeofA) - orders.indexOf(typeofB);
|
5796 | }
|
5797 |
|
5798 | if (typeofA !== 'string') {
|
5799 | return Number(a) - Number(b);
|
5800 | }
|
5801 |
|
5802 | return a.localeCompare(b);
|
5803 | }
|
5804 |
|
5805 | exports.comparePrimitive = comparePrimitive;
|
5806 |
|
5807 | function normalizeDefaultResult(result) {
|
5808 | return result === undefined ? {} : result;
|
5809 | }
|
5810 |
|
5811 | exports.normalizeDefaultResult = normalizeDefaultResult;
|
5812 |
|
5813 | function normalizeValidateResult(result, value) {
|
5814 | return result === true ? true : result === false ? {
|
5815 | value
|
5816 | } : result;
|
5817 | }
|
5818 |
|
5819 | exports.normalizeValidateResult = normalizeValidateResult;
|
5820 |
|
5821 | function normalizeDeprecatedResult(result, value, doNotNormalizeTrue = false) {
|
5822 | return result === false ? false : result === true ? doNotNormalizeTrue ? true : [{
|
5823 | value
|
5824 | }] : 'value' in result ? [result] : result.length === 0 ? false : result;
|
5825 | }
|
5826 |
|
5827 | exports.normalizeDeprecatedResult = normalizeDeprecatedResult;
|
5828 |
|
5829 | function normalizeTransferResult(result, value) {
|
5830 | return typeof result === 'string' || 'key' in result ? {
|
5831 | from: value,
|
5832 | to: result
|
5833 | } : 'from' in result ? {
|
5834 | from: result.from,
|
5835 | to: result.to
|
5836 | } : {
|
5837 | from: value,
|
5838 | to: result.to
|
5839 | };
|
5840 | }
|
5841 |
|
5842 | exports.normalizeTransferResult = normalizeTransferResult;
|
5843 |
|
5844 | function normalizeForwardResult(result, value) {
|
5845 | return result === undefined ? [] : Array.isArray(result) ? result.map(transferResult => normalizeTransferResult(transferResult, value)) : [normalizeTransferResult(result, value)];
|
5846 | }
|
5847 |
|
5848 | exports.normalizeForwardResult = normalizeForwardResult;
|
5849 |
|
5850 | function normalizeRedirectResult(result, value) {
|
5851 | const redirect = normalizeForwardResult(typeof result === 'object' && 'redirect' in result ? result.redirect : result, value);
|
5852 | return redirect.length === 0 ? {
|
5853 | remain: value,
|
5854 | redirect
|
5855 | } : typeof result === 'object' && 'remain' in result ? {
|
5856 | remain: result.remain,
|
5857 | redirect
|
5858 | } : {
|
5859 | redirect
|
5860 | };
|
5861 | }
|
5862 |
|
5863 | exports.normalizeRedirectResult = normalizeRedirectResult;
|
5864 | });
|
5865 | unwrapExports(utils);
|
5866 | var utils_1 = utils.recordFromArray;
|
5867 | var utils_2 = utils.mapFromArray;
|
5868 | var utils_3 = utils.createAutoChecklist;
|
5869 | var utils_4 = utils.partition;
|
5870 | var utils_5 = utils.isInt;
|
5871 | var utils_6 = utils.comparePrimitive;
|
5872 | var utils_7 = utils.normalizeDefaultResult;
|
5873 | var utils_8 = utils.normalizeValidateResult;
|
5874 | var utils_9 = utils.normalizeDeprecatedResult;
|
5875 | var utils_10 = utils.normalizeTransferResult;
|
5876 | var utils_11 = utils.normalizeForwardResult;
|
5877 | var utils_12 = utils.normalizeRedirectResult;
|
5878 |
|
5879 | var choice = createCommonjsModule(function (module, exports) {
|
5880 |
|
5881 | Object.defineProperty(exports, "__esModule", {
|
5882 | value: true
|
5883 | });
|
5884 |
|
5885 | class ChoiceSchema extends schema.Schema {
|
5886 | constructor(parameters) {
|
5887 | super(parameters);
|
5888 | this._choices = utils.mapFromArray(parameters.choices.map(choice => choice && typeof choice === 'object' ? choice : {
|
5889 | value: choice
|
5890 | }), 'value');
|
5891 | }
|
5892 |
|
5893 | expected({
|
5894 | descriptor
|
5895 | }) {
|
5896 | const choiceValues = Array.from(this._choices.keys()).map(value => this._choices.get(value)).filter(choiceInfo => !choiceInfo.deprecated).map(choiceInfo => choiceInfo.value).sort(utils.comparePrimitive).map(descriptor.value);
|
5897 | const head = choiceValues.slice(0, -2);
|
5898 | const tail = choiceValues.slice(-2);
|
5899 | return head.concat(tail.join(' or ')).join(', ');
|
5900 | }
|
5901 |
|
5902 | validate(value) {
|
5903 | return this._choices.has(value);
|
5904 | }
|
5905 |
|
5906 | deprecated(value) {
|
5907 | const choiceInfo = this._choices.get(value);
|
5908 |
|
5909 | return choiceInfo && choiceInfo.deprecated ? {
|
5910 | value
|
5911 | } : false;
|
5912 | }
|
5913 |
|
5914 | forward(value) {
|
5915 | const choiceInfo = this._choices.get(value);
|
5916 |
|
5917 | return choiceInfo ? choiceInfo.forward : undefined;
|
5918 | }
|
5919 |
|
5920 | redirect(value) {
|
5921 | const choiceInfo = this._choices.get(value);
|
5922 |
|
5923 | return choiceInfo ? choiceInfo.redirect : undefined;
|
5924 | }
|
5925 |
|
5926 | }
|
5927 |
|
5928 | exports.ChoiceSchema = ChoiceSchema;
|
5929 | });
|
5930 | unwrapExports(choice);
|
5931 | var choice_1 = choice.ChoiceSchema;
|
5932 |
|
5933 | var number = createCommonjsModule(function (module, exports) {
|
5934 |
|
5935 | Object.defineProperty(exports, "__esModule", {
|
5936 | value: true
|
5937 | });
|
5938 |
|
5939 | class NumberSchema extends schema.Schema {
|
5940 | expected() {
|
5941 | return 'a number';
|
5942 | }
|
5943 |
|
5944 | validate(value, _utils) {
|
5945 | return typeof value === 'number';
|
5946 | }
|
5947 |
|
5948 | }
|
5949 |
|
5950 | exports.NumberSchema = NumberSchema;
|
5951 | });
|
5952 | unwrapExports(number);
|
5953 | var number_1 = number.NumberSchema;
|
5954 |
|
5955 | var integer = createCommonjsModule(function (module, exports) {
|
5956 |
|
5957 | Object.defineProperty(exports, "__esModule", {
|
5958 | value: true
|
5959 | });
|
5960 |
|
5961 | class IntegerSchema extends number.NumberSchema {
|
5962 | expected() {
|
5963 | return 'an integer';
|
5964 | }
|
5965 |
|
5966 | validate(value, utils$1) {
|
5967 | return utils$1.normalizeValidateResult(super.validate(value, utils$1), value) === true && utils.isInt(value);
|
5968 | }
|
5969 |
|
5970 | }
|
5971 |
|
5972 | exports.IntegerSchema = IntegerSchema;
|
5973 | });
|
5974 | unwrapExports(integer);
|
5975 | var integer_1 = integer.IntegerSchema;
|
5976 |
|
5977 | var string = createCommonjsModule(function (module, exports) {
|
5978 |
|
5979 | Object.defineProperty(exports, "__esModule", {
|
5980 | value: true
|
5981 | });
|
5982 |
|
5983 | class StringSchema extends schema.Schema {
|
5984 | expected() {
|
5985 | return 'a string';
|
5986 | }
|
5987 |
|
5988 | validate(value) {
|
5989 | return typeof value === 'string';
|
5990 | }
|
5991 |
|
5992 | }
|
5993 |
|
5994 | exports.StringSchema = StringSchema;
|
5995 | });
|
5996 | unwrapExports(string);
|
5997 | var string_1 = string.StringSchema;
|
5998 |
|
5999 | var schemas = createCommonjsModule(function (module, exports) {
|
6000 |
|
6001 | Object.defineProperty(exports, "__esModule", {
|
6002 | value: true
|
6003 | });
|
6004 |
|
6005 | tslib_1.__exportStar(alias, exports);
|
6006 |
|
6007 | tslib_1.__exportStar(any, exports);
|
6008 |
|
6009 | tslib_1.__exportStar(array, exports);
|
6010 |
|
6011 | tslib_1.__exportStar(boolean_1, exports);
|
6012 |
|
6013 | tslib_1.__exportStar(choice, exports);
|
6014 |
|
6015 | tslib_1.__exportStar(integer, exports);
|
6016 |
|
6017 | tslib_1.__exportStar(number, exports);
|
6018 |
|
6019 | tslib_1.__exportStar(string, exports);
|
6020 | });
|
6021 | unwrapExports(schemas);
|
6022 |
|
6023 | var defaults = createCommonjsModule(function (module, exports) {
|
6024 |
|
6025 | Object.defineProperty(exports, "__esModule", {
|
6026 | value: true
|
6027 | });
|
6028 | exports.defaultDescriptor = api.apiDescriptor;
|
6029 | exports.defaultUnknownHandler = leven_1.levenUnknownHandler;
|
6030 | exports.defaultInvalidHandler = invalid.commonInvalidHandler;
|
6031 | exports.defaultDeprecatedHandler = common.commonDeprecatedHandler;
|
6032 | });
|
6033 | unwrapExports(defaults);
|
6034 | var defaults_1 = defaults.defaultDescriptor;
|
6035 | var defaults_2 = defaults.defaultUnknownHandler;
|
6036 | var defaults_3 = defaults.defaultInvalidHandler;
|
6037 | var defaults_4 = defaults.defaultDeprecatedHandler;
|
6038 |
|
6039 | var normalize = createCommonjsModule(function (module, exports) {
|
6040 |
|
6041 | Object.defineProperty(exports, "__esModule", {
|
6042 | value: true
|
6043 | });
|
6044 |
|
6045 | exports.normalize = (options, schemas, opts) => new Normalizer(schemas, opts).normalize(options);
|
6046 |
|
6047 | class Normalizer {
|
6048 | constructor(schemas, opts) {
|
6049 |
|
6050 | const {
|
6051 | logger = console,
|
6052 | descriptor = defaults.defaultDescriptor,
|
6053 | unknown = defaults.defaultUnknownHandler,
|
6054 | invalid = defaults.defaultInvalidHandler,
|
6055 | deprecated = defaults.defaultDeprecatedHandler
|
6056 | } = opts || {};
|
6057 | this._utils = {
|
6058 | descriptor,
|
6059 | logger:
|
6060 |
|
6061 | logger || {
|
6062 | warn: () => {}
|
6063 | },
|
6064 | schemas: utils.recordFromArray(schemas, 'name'),
|
6065 | normalizeDefaultResult: utils.normalizeDefaultResult,
|
6066 | normalizeDeprecatedResult: utils.normalizeDeprecatedResult,
|
6067 | normalizeForwardResult: utils.normalizeForwardResult,
|
6068 | normalizeRedirectResult: utils.normalizeRedirectResult,
|
6069 | normalizeValidateResult: utils.normalizeValidateResult
|
6070 | };
|
6071 | this._unknownHandler = unknown;
|
6072 | this._invalidHandler = invalid;
|
6073 | this._deprecatedHandler = deprecated;
|
6074 | this.cleanHistory();
|
6075 | }
|
6076 |
|
6077 | cleanHistory() {
|
6078 | this._hasDeprecationWarned = utils.createAutoChecklist();
|
6079 | }
|
6080 |
|
6081 | normalize(options) {
|
6082 | const normalized = {};
|
6083 | const restOptionsArray = [options];
|
6084 |
|
6085 | const applyNormalization = () => {
|
6086 | while (restOptionsArray.length !== 0) {
|
6087 | const currentOptions = restOptionsArray.shift();
|
6088 |
|
6089 | const transferredOptionsArray = this._applyNormalization(currentOptions, normalized);
|
6090 |
|
6091 | restOptionsArray.push(...transferredOptionsArray);
|
6092 | }
|
6093 | };
|
6094 |
|
6095 | applyNormalization();
|
6096 |
|
6097 | for (const key of Object.keys(this._utils.schemas)) {
|
6098 | const schema = this._utils.schemas[key];
|
6099 |
|
6100 | if (!(key in normalized)) {
|
6101 | const defaultResult = utils.normalizeDefaultResult(schema.default(this._utils));
|
6102 |
|
6103 | if ('value' in defaultResult) {
|
6104 | restOptionsArray.push({
|
6105 | [key]: defaultResult.value
|
6106 | });
|
6107 | }
|
6108 | }
|
6109 | }
|
6110 |
|
6111 | applyNormalization();
|
6112 |
|
6113 | for (const key of Object.keys(this._utils.schemas)) {
|
6114 | const schema = this._utils.schemas[key];
|
6115 |
|
6116 | if (key in normalized) {
|
6117 | normalized[key] = schema.postprocess(normalized[key], this._utils);
|
6118 | }
|
6119 | }
|
6120 |
|
6121 | return normalized;
|
6122 | }
|
6123 |
|
6124 | _applyNormalization(options, normalized) {
|
6125 | const transferredOptionsArray = [];
|
6126 | const [knownOptionNames, unknownOptionNames] = utils.partition(Object.keys(options), key => key in this._utils.schemas);
|
6127 |
|
6128 | for (const key of knownOptionNames) {
|
6129 | const schema = this._utils.schemas[key];
|
6130 | const value = schema.preprocess(options[key], this._utils);
|
6131 | const validateResult = utils.normalizeValidateResult(schema.validate(value, this._utils), value);
|
6132 |
|
6133 | if (validateResult !== true) {
|
6134 | const {
|
6135 | value: invalidValue
|
6136 | } = validateResult;
|
6137 |
|
6138 | const errorMessageOrError = this._invalidHandler(key, invalidValue, this._utils);
|
6139 |
|
6140 | throw typeof errorMessageOrError === 'string' ? new Error(errorMessageOrError) :
|
6141 |
|
6142 | errorMessageOrError;
|
6143 | }
|
6144 |
|
6145 | const appendTransferredOptions = ({
|
6146 | from,
|
6147 | to
|
6148 | }) => {
|
6149 | transferredOptionsArray.push(typeof to === 'string' ? {
|
6150 | [to]: from
|
6151 | } : {
|
6152 | [to.key]: to.value
|
6153 | });
|
6154 | };
|
6155 |
|
6156 | const warnDeprecated = ({
|
6157 | value: currentValue,
|
6158 | redirectTo
|
6159 | }) => {
|
6160 | const deprecatedResult = utils.normalizeDeprecatedResult(schema.deprecated(currentValue, this._utils), value,
|
6161 |
|
6162 | true);
|
6163 |
|
6164 | if (deprecatedResult === false) {
|
6165 | return;
|
6166 | }
|
6167 |
|
6168 | if (deprecatedResult === true) {
|
6169 | if (!this._hasDeprecationWarned(key)) {
|
6170 | this._utils.logger.warn(this._deprecatedHandler(key, redirectTo, this._utils));
|
6171 | }
|
6172 | } else {
|
6173 | for (const {
|
6174 | value: deprecatedValue
|
6175 | } of deprecatedResult) {
|
6176 | const pair = {
|
6177 | key,
|
6178 | value: deprecatedValue
|
6179 | };
|
6180 |
|
6181 | if (!this._hasDeprecationWarned(pair)) {
|
6182 | const redirectToPair = typeof redirectTo === 'string' ? {
|
6183 | key: redirectTo,
|
6184 | value: deprecatedValue
|
6185 | } : redirectTo;
|
6186 |
|
6187 | this._utils.logger.warn(this._deprecatedHandler(pair, redirectToPair, this._utils));
|
6188 | }
|
6189 | }
|
6190 | }
|
6191 | };
|
6192 |
|
6193 | const forwardResult = utils.normalizeForwardResult(schema.forward(value, this._utils), value);
|
6194 | forwardResult.forEach(appendTransferredOptions);
|
6195 | const redirectResult = utils.normalizeRedirectResult(schema.redirect(value, this._utils), value);
|
6196 | redirectResult.redirect.forEach(appendTransferredOptions);
|
6197 |
|
6198 | if ('remain' in redirectResult) {
|
6199 | const remainingValue = redirectResult.remain;
|
6200 | normalized[key] = key in normalized ? schema.overlap(normalized[key], remainingValue, this._utils) : remainingValue;
|
6201 | warnDeprecated({
|
6202 | value: remainingValue
|
6203 | });
|
6204 | }
|
6205 |
|
6206 | for (const {
|
6207 | from,
|
6208 | to
|
6209 | } of redirectResult.redirect) {
|
6210 | warnDeprecated({
|
6211 | value: from,
|
6212 | redirectTo: to
|
6213 | });
|
6214 | }
|
6215 | }
|
6216 |
|
6217 | for (const key of unknownOptionNames) {
|
6218 | const value = options[key];
|
6219 |
|
6220 | const unknownResult = this._unknownHandler(key, value, this._utils);
|
6221 |
|
6222 | if (unknownResult) {
|
6223 | for (const unknownKey of Object.keys(unknownResult)) {
|
6224 | const unknownOption = {
|
6225 | [unknownKey]: unknownResult[unknownKey]
|
6226 | };
|
6227 |
|
6228 | if (unknownKey in this._utils.schemas) {
|
6229 | transferredOptionsArray.push(unknownOption);
|
6230 | } else {
|
6231 | Object.assign(normalized, unknownOption);
|
6232 | }
|
6233 | }
|
6234 | }
|
6235 | }
|
6236 |
|
6237 | return transferredOptionsArray;
|
6238 | }
|
6239 |
|
6240 | }
|
6241 |
|
6242 | exports.Normalizer = Normalizer;
|
6243 | });
|
6244 | unwrapExports(normalize);
|
6245 | var normalize_1 = normalize.normalize;
|
6246 | var normalize_2 = normalize.Normalizer;
|
6247 |
|
6248 | var lib = createCommonjsModule(function (module, exports) {
|
6249 |
|
6250 | Object.defineProperty(exports, "__esModule", {
|
6251 | value: true
|
6252 | });
|
6253 |
|
6254 | tslib_1.__exportStar(descriptors, exports);
|
6255 |
|
6256 | tslib_1.__exportStar(handlers, exports);
|
6257 |
|
6258 | tslib_1.__exportStar(schemas, exports);
|
6259 |
|
6260 | tslib_1.__exportStar(normalize, exports);
|
6261 |
|
6262 | tslib_1.__exportStar(schema, exports);
|
6263 | });
|
6264 | unwrapExports(lib);
|
6265 |
|
6266 | const array$1 = [];
|
6267 | const charCodeCache$1 = [];
|
6268 |
|
6269 | const leven$1 = (left, right) => {
|
6270 | if (left === right) {
|
6271 | return 0;
|
6272 | }
|
6273 |
|
6274 | const swap = left;
|
6275 |
|
6276 |
|
6277 | if (left.length > right.length) {
|
6278 | left = right;
|
6279 | right = swap;
|
6280 | }
|
6281 |
|
6282 | let leftLength = left.length;
|
6283 | let rightLength = right.length;
|
6284 |
|
6285 |
|
6286 |
|
6287 |
|
6288 | while (leftLength > 0 && left.charCodeAt(~-leftLength) === right.charCodeAt(~-rightLength)) {
|
6289 | leftLength--;
|
6290 | rightLength--;
|
6291 | }
|
6292 |
|
6293 |
|
6294 |
|
6295 |
|
6296 | let start = 0;
|
6297 |
|
6298 | while (start < leftLength && left.charCodeAt(start) === right.charCodeAt(start)) {
|
6299 | start++;
|
6300 | }
|
6301 |
|
6302 | leftLength -= start;
|
6303 | rightLength -= start;
|
6304 |
|
6305 | if (leftLength === 0) {
|
6306 | return rightLength;
|
6307 | }
|
6308 |
|
6309 | let bCharCode;
|
6310 | let result;
|
6311 | let temp;
|
6312 | let temp2;
|
6313 | let i = 0;
|
6314 | let j = 0;
|
6315 |
|
6316 | while (i < leftLength) {
|
6317 | charCodeCache$1[i] = left.charCodeAt(start + i);
|
6318 | array$1[i] = ++i;
|
6319 | }
|
6320 |
|
6321 | while (j < rightLength) {
|
6322 | bCharCode = right.charCodeAt(start + j);
|
6323 | temp = j++;
|
6324 | result = j;
|
6325 |
|
6326 | for (i = 0; i < leftLength; i++) {
|
6327 | temp2 = bCharCode === charCodeCache$1[i] ? temp : temp + 1;
|
6328 | temp = array$1[i];
|
6329 |
|
6330 | result = array$1[i] = temp > result ? temp2 > result ? result + 1 : temp2 : temp2 > temp ? temp + 1 : temp2;
|
6331 | }
|
6332 | }
|
6333 |
|
6334 | return result;
|
6335 | };
|
6336 |
|
6337 | var leven_1$1 = leven$1;
|
6338 |
|
6339 | var default_1 = leven$1;
|
6340 | leven_1$1.default = default_1;
|
6341 |
|
6342 | var colorName$1 = {
|
6343 | "aliceblue": [240, 248, 255],
|
6344 | "antiquewhite": [250, 235, 215],
|
6345 | "aqua": [0, 255, 255],
|
6346 | "aquamarine": [127, 255, 212],
|
6347 | "azure": [240, 255, 255],
|
6348 | "beige": [245, 245, 220],
|
6349 | "bisque": [255, 228, 196],
|
6350 | "black": [0, 0, 0],
|
6351 | "blanchedalmond": [255, 235, 205],
|
6352 | "blue": [0, 0, 255],
|
6353 | "blueviolet": [138, 43, 226],
|
6354 | "brown": [165, 42, 42],
|
6355 | "burlywood": [222, 184, 135],
|
6356 | "cadetblue": [95, 158, 160],
|
6357 | "chartreuse": [127, 255, 0],
|
6358 | "chocolate": [210, 105, 30],
|
6359 | "coral": [255, 127, 80],
|
6360 | "cornflowerblue": [100, 149, 237],
|
6361 | "cornsilk": [255, 248, 220],
|
6362 | "crimson": [220, 20, 60],
|
6363 | "cyan": [0, 255, 255],
|
6364 | "darkblue": [0, 0, 139],
|
6365 | "darkcyan": [0, 139, 139],
|
6366 | "darkgoldenrod": [184, 134, 11],
|
6367 | "darkgray": [169, 169, 169],
|
6368 | "darkgreen": [0, 100, 0],
|
6369 | "darkgrey": [169, 169, 169],
|
6370 | "darkkhaki": [189, 183, 107],
|
6371 | "darkmagenta": [139, 0, 139],
|
6372 | "darkolivegreen": [85, 107, 47],
|
6373 | "darkorange": [255, 140, 0],
|
6374 | "darkorchid": [153, 50, 204],
|
6375 | "darkred": [139, 0, 0],
|
6376 | "darksalmon": [233, 150, 122],
|
6377 | "darkseagreen": [143, 188, 143],
|
6378 | "darkslateblue": [72, 61, 139],
|
6379 | "darkslategray": [47, 79, 79],
|
6380 | "darkslategrey": [47, 79, 79],
|
6381 | "darkturquoise": [0, 206, 209],
|
6382 | "darkviolet": [148, 0, 211],
|
6383 | "deeppink": [255, 20, 147],
|
6384 | "deepskyblue": [0, 191, 255],
|
6385 | "dimgray": [105, 105, 105],
|
6386 | "dimgrey": [105, 105, 105],
|
6387 | "dodgerblue": [30, 144, 255],
|
6388 | "firebrick": [178, 34, 34],
|
6389 | "floralwhite": [255, 250, 240],
|
6390 | "forestgreen": [34, 139, 34],
|
6391 | "fuchsia": [255, 0, 255],
|
6392 | "gainsboro": [220, 220, 220],
|
6393 | "ghostwhite": [248, 248, 255],
|
6394 | "gold": [255, 215, 0],
|
6395 | "goldenrod": [218, 165, 32],
|
6396 | "gray": [128, 128, 128],
|
6397 | "green": [0, 128, 0],
|
6398 | "greenyellow": [173, 255, 47],
|
6399 | "grey": [128, 128, 128],
|
6400 | "honeydew": [240, 255, 240],
|
6401 | "hotpink": [255, 105, 180],
|
6402 | "indianred": [205, 92, 92],
|
6403 | "indigo": [75, 0, 130],
|
6404 | "ivory": [255, 255, 240],
|
6405 | "khaki": [240, 230, 140],
|
6406 | "lavender": [230, 230, 250],
|
6407 | "lavenderblush": [255, 240, 245],
|
6408 | "lawngreen": [124, 252, 0],
|
6409 | "lemonchiffon": [255, 250, 205],
|
6410 | "lightblue": [173, 216, 230],
|
6411 | "lightcoral": [240, 128, 128],
|
6412 | "lightcyan": [224, 255, 255],
|
6413 | "lightgoldenrodyellow": [250, 250, 210],
|
6414 | "lightgray": [211, 211, 211],
|
6415 | "lightgreen": [144, 238, 144],
|
6416 | "lightgrey": [211, 211, 211],
|
6417 | "lightpink": [255, 182, 193],
|
6418 | "lightsalmon": [255, 160, 122],
|
6419 | "lightseagreen": [32, 178, 170],
|
6420 | "lightskyblue": [135, 206, 250],
|
6421 | "lightslategray": [119, 136, 153],
|
6422 | "lightslategrey": [119, 136, 153],
|
6423 | "lightsteelblue": [176, 196, 222],
|
6424 | "lightyellow": [255, 255, 224],
|
6425 | "lime": [0, 255, 0],
|
6426 | "limegreen": [50, 205, 50],
|
6427 | "linen": [250, 240, 230],
|
6428 | "magenta": [255, 0, 255],
|
6429 | "maroon": [128, 0, 0],
|
6430 | "mediumaquamarine": [102, 205, 170],
|
6431 | "mediumblue": [0, 0, 205],
|
6432 | "mediumorchid": [186, 85, 211],
|
6433 | "mediumpurple": [147, 112, 219],
|
6434 | "mediumseagreen": [60, 179, 113],
|
6435 | "mediumslateblue": [123, 104, 238],
|
6436 | "mediumspringgreen": [0, 250, 154],
|
6437 | "mediumturquoise": [72, 209, 204],
|
6438 | "mediumvioletred": [199, 21, 133],
|
6439 | "midnightblue": [25, 25, 112],
|
6440 | "mintcream": [245, 255, 250],
|
6441 | "mistyrose": [255, 228, 225],
|
6442 | "moccasin": [255, 228, 181],
|
6443 | "navajowhite": [255, 222, 173],
|
6444 | "navy": [0, 0, 128],
|
6445 | "oldlace": [253, 245, 230],
|
6446 | "olive": [128, 128, 0],
|
6447 | "olivedrab": [107, 142, 35],
|
6448 | "orange": [255, 165, 0],
|
6449 | "orangered": [255, 69, 0],
|
6450 | "orchid": [218, 112, 214],
|
6451 | "palegoldenrod": [238, 232, 170],
|
6452 | "palegreen": [152, 251, 152],
|
6453 | "paleturquoise": [175, 238, 238],
|
6454 | "palevioletred": [219, 112, 147],
|
6455 | "papayawhip": [255, 239, 213],
|
6456 | "peachpuff": [255, 218, 185],
|
6457 | "peru": [205, 133, 63],
|
6458 | "pink": [255, 192, 203],
|
6459 | "plum": [221, 160, 221],
|
6460 | "powderblue": [176, 224, 230],
|
6461 | "purple": [128, 0, 128],
|
6462 | "rebeccapurple": [102, 51, 153],
|
6463 | "red": [255, 0, 0],
|
6464 | "rosybrown": [188, 143, 143],
|
6465 | "royalblue": [65, 105, 225],
|
6466 | "saddlebrown": [139, 69, 19],
|
6467 | "salmon": [250, 128, 114],
|
6468 | "sandybrown": [244, 164, 96],
|
6469 | "seagreen": [46, 139, 87],
|
6470 | "seashell": [255, 245, 238],
|
6471 | "sienna": [160, 82, 45],
|
6472 | "silver": [192, 192, 192],
|
6473 | "skyblue": [135, 206, 235],
|
6474 | "slateblue": [106, 90, 205],
|
6475 | "slategray": [112, 128, 144],
|
6476 | "slategrey": [112, 128, 144],
|
6477 | "snow": [255, 250, 250],
|
6478 | "springgreen": [0, 255, 127],
|
6479 | "steelblue": [70, 130, 180],
|
6480 | "tan": [210, 180, 140],
|
6481 | "teal": [0, 128, 128],
|
6482 | "thistle": [216, 191, 216],
|
6483 | "tomato": [255, 99, 71],
|
6484 | "turquoise": [64, 224, 208],
|
6485 | "violet": [238, 130, 238],
|
6486 | "wheat": [245, 222, 179],
|
6487 | "white": [255, 255, 255],
|
6488 | "whitesmoke": [245, 245, 245],
|
6489 | "yellow": [255, 255, 0],
|
6490 | "yellowgreen": [154, 205, 50]
|
6491 | };
|
6492 |
|
6493 |
|
6494 |
|
6495 |
|
6496 |
|
6497 |
|
6498 |
|
6499 |
|
6500 | const reverseKeywords = {};
|
6501 |
|
6502 | for (const key of Object.keys(colorName$1)) {
|
6503 | reverseKeywords[colorName$1[key]] = key;
|
6504 | }
|
6505 |
|
6506 | const convert$1 = {
|
6507 | rgb: {
|
6508 | channels: 3,
|
6509 | labels: 'rgb'
|
6510 | },
|
6511 | hsl: {
|
6512 | channels: 3,
|
6513 | labels: 'hsl'
|
6514 | },
|
6515 | hsv: {
|
6516 | channels: 3,
|
6517 | labels: 'hsv'
|
6518 | },
|
6519 | hwb: {
|
6520 | channels: 3,
|
6521 | labels: 'hwb'
|
6522 | },
|
6523 | cmyk: {
|
6524 | channels: 4,
|
6525 | labels: 'cmyk'
|
6526 | },
|
6527 | xyz: {
|
6528 | channels: 3,
|
6529 | labels: 'xyz'
|
6530 | },
|
6531 | lab: {
|
6532 | channels: 3,
|
6533 | labels: 'lab'
|
6534 | },
|
6535 | lch: {
|
6536 | channels: 3,
|
6537 | labels: 'lch'
|
6538 | },
|
6539 | hex: {
|
6540 | channels: 1,
|
6541 | labels: ['hex']
|
6542 | },
|
6543 | keyword: {
|
6544 | channels: 1,
|
6545 | labels: ['keyword']
|
6546 | },
|
6547 | ansi16: {
|
6548 | channels: 1,
|
6549 | labels: ['ansi16']
|
6550 | },
|
6551 | ansi256: {
|
6552 | channels: 1,
|
6553 | labels: ['ansi256']
|
6554 | },
|
6555 | hcg: {
|
6556 | channels: 3,
|
6557 | labels: ['h', 'c', 'g']
|
6558 | },
|
6559 | apple: {
|
6560 | channels: 3,
|
6561 | labels: ['r16', 'g16', 'b16']
|
6562 | },
|
6563 | gray: {
|
6564 | channels: 1,
|
6565 | labels: ['gray']
|
6566 | }
|
6567 | };
|
6568 | var conversions$1 = convert$1;
|
6569 |
|
6570 | for (const model of Object.keys(convert$1)) {
|
6571 | if (!('channels' in convert$1[model])) {
|
6572 | throw new Error('missing channels property: ' + model);
|
6573 | }
|
6574 |
|
6575 | if (!('labels' in convert$1[model])) {
|
6576 | throw new Error('missing channel labels property: ' + model);
|
6577 | }
|
6578 |
|
6579 | if (convert$1[model].labels.length !== convert$1[model].channels) {
|
6580 | throw new Error('channel and label counts mismatch: ' + model);
|
6581 | }
|
6582 |
|
6583 | const {
|
6584 | channels,
|
6585 | labels
|
6586 | } = convert$1[model];
|
6587 | delete convert$1[model].channels;
|
6588 | delete convert$1[model].labels;
|
6589 | Object.defineProperty(convert$1[model], 'channels', {
|
6590 | value: channels
|
6591 | });
|
6592 | Object.defineProperty(convert$1[model], 'labels', {
|
6593 | value: labels
|
6594 | });
|
6595 | }
|
6596 |
|
6597 | convert$1.rgb.hsl = function (rgb) {
|
6598 | const r = rgb[0] / 255;
|
6599 | const g = rgb[1] / 255;
|
6600 | const b = rgb[2] / 255;
|
6601 | const min = Math.min(r, g, b);
|
6602 | const max = Math.max(r, g, b);
|
6603 | const delta = max - min;
|
6604 | let h;
|
6605 | let s;
|
6606 |
|
6607 | if (max === min) {
|
6608 | h = 0;
|
6609 | } else if (r === max) {
|
6610 | h = (g - b) / delta;
|
6611 | } else if (g === max) {
|
6612 | h = 2 + (b - r) / delta;
|
6613 | } else if (b === max) {
|
6614 | h = 4 + (r - g) / delta;
|
6615 | }
|
6616 |
|
6617 | h = Math.min(h * 60, 360);
|
6618 |
|
6619 | if (h < 0) {
|
6620 | h += 360;
|
6621 | }
|
6622 |
|
6623 | const l = (min + max) / 2;
|
6624 |
|
6625 | if (max === min) {
|
6626 | s = 0;
|
6627 | } else if (l <= 0.5) {
|
6628 | s = delta / (max + min);
|
6629 | } else {
|
6630 | s = delta / (2 - max - min);
|
6631 | }
|
6632 |
|
6633 | return [h, s * 100, l * 100];
|
6634 | };
|
6635 |
|
6636 | convert$1.rgb.hsv = function (rgb) {
|
6637 | let rdif;
|
6638 | let gdif;
|
6639 | let bdif;
|
6640 | let h;
|
6641 | let s;
|
6642 | const r = rgb[0] / 255;
|
6643 | const g = rgb[1] / 255;
|
6644 | const b = rgb[2] / 255;
|
6645 | const v = Math.max(r, g, b);
|
6646 | const diff = v - Math.min(r, g, b);
|
6647 |
|
6648 | const diffc = function (c) {
|
6649 | return (v - c) / 6 / diff + 1 / 2;
|
6650 | };
|
6651 |
|
6652 | if (diff === 0) {
|
6653 | h = 0;
|
6654 | s = 0;
|
6655 | } else {
|
6656 | s = diff / v;
|
6657 | rdif = diffc(r);
|
6658 | gdif = diffc(g);
|
6659 | bdif = diffc(b);
|
6660 |
|
6661 | if (r === v) {
|
6662 | h = bdif - gdif;
|
6663 | } else if (g === v) {
|
6664 | h = 1 / 3 + rdif - bdif;
|
6665 | } else if (b === v) {
|
6666 | h = 2 / 3 + gdif - rdif;
|
6667 | }
|
6668 |
|
6669 | if (h < 0) {
|
6670 | h += 1;
|
6671 | } else if (h > 1) {
|
6672 | h -= 1;
|
6673 | }
|
6674 | }
|
6675 |
|
6676 | return [h * 360, s * 100, v * 100];
|
6677 | };
|
6678 |
|
6679 | convert$1.rgb.hwb = function (rgb) {
|
6680 | const r = rgb[0];
|
6681 | const g = rgb[1];
|
6682 | let b = rgb[2];
|
6683 | const h = convert$1.rgb.hsl(rgb)[0];
|
6684 | const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
6685 | b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
6686 | return [h, w * 100, b * 100];
|
6687 | };
|
6688 |
|
6689 | convert$1.rgb.cmyk = function (rgb) {
|
6690 | const r = rgb[0] / 255;
|
6691 | const g = rgb[1] / 255;
|
6692 | const b = rgb[2] / 255;
|
6693 | const k = Math.min(1 - r, 1 - g, 1 - b);
|
6694 | const c = (1 - r - k) / (1 - k) || 0;
|
6695 | const m = (1 - g - k) / (1 - k) || 0;
|
6696 | const y = (1 - b - k) / (1 - k) || 0;
|
6697 | return [c * 100, m * 100, y * 100, k * 100];
|
6698 | };
|
6699 |
|
6700 | function comparativeDistance(x, y) {
|
6701 | |
6702 |
|
6703 |
|
6704 | return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
6705 | }
|
6706 |
|
6707 | convert$1.rgb.keyword = function (rgb) {
|
6708 | const reversed = reverseKeywords[rgb];
|
6709 |
|
6710 | if (reversed) {
|
6711 | return reversed;
|
6712 | }
|
6713 |
|
6714 | let currentClosestDistance = Infinity;
|
6715 | let currentClosestKeyword;
|
6716 |
|
6717 | for (const keyword of Object.keys(colorName$1)) {
|
6718 | const value = colorName$1[keyword];
|
6719 |
|
6720 | const distance = comparativeDistance(rgb, value);
|
6721 |
|
6722 | if (distance < currentClosestDistance) {
|
6723 | currentClosestDistance = distance;
|
6724 | currentClosestKeyword = keyword;
|
6725 | }
|
6726 | }
|
6727 |
|
6728 | return currentClosestKeyword;
|
6729 | };
|
6730 |
|
6731 | convert$1.keyword.rgb = function (keyword) {
|
6732 | return colorName$1[keyword];
|
6733 | };
|
6734 |
|
6735 | convert$1.rgb.xyz = function (rgb) {
|
6736 | let r = rgb[0] / 255;
|
6737 | let g = rgb[1] / 255;
|
6738 | let b = rgb[2] / 255;
|
6739 |
|
6740 | r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
|
6741 | g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
|
6742 | b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
|
6743 | const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
6744 | const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
6745 | const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
6746 | return [x * 100, y * 100, z * 100];
|
6747 | };
|
6748 |
|
6749 | convert$1.rgb.lab = function (rgb) {
|
6750 | const xyz = convert$1.rgb.xyz(rgb);
|
6751 | let x = xyz[0];
|
6752 | let y = xyz[1];
|
6753 | let z = xyz[2];
|
6754 | x /= 95.047;
|
6755 | y /= 100;
|
6756 | z /= 108.883;
|
6757 | x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
6758 | y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
6759 | z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
6760 | const l = 116 * y - 16;
|
6761 | const a = 500 * (x - y);
|
6762 | const b = 200 * (y - z);
|
6763 | return [l, a, b];
|
6764 | };
|
6765 |
|
6766 | convert$1.hsl.rgb = function (hsl) {
|
6767 | const h = hsl[0] / 360;
|
6768 | const s = hsl[1] / 100;
|
6769 | const l = hsl[2] / 100;
|
6770 | let t2;
|
6771 | let t3;
|
6772 | let val;
|
6773 |
|
6774 | if (s === 0) {
|
6775 | val = l * 255;
|
6776 | return [val, val, val];
|
6777 | }
|
6778 |
|
6779 | if (l < 0.5) {
|
6780 | t2 = l * (1 + s);
|
6781 | } else {
|
6782 | t2 = l + s - l * s;
|
6783 | }
|
6784 |
|
6785 | const t1 = 2 * l - t2;
|
6786 | const rgb = [0, 0, 0];
|
6787 |
|
6788 | for (let i = 0; i < 3; i++) {
|
6789 | t3 = h + 1 / 3 * -(i - 1);
|
6790 |
|
6791 | if (t3 < 0) {
|
6792 | t3++;
|
6793 | }
|
6794 |
|
6795 | if (t3 > 1) {
|
6796 | t3--;
|
6797 | }
|
6798 |
|
6799 | if (6 * t3 < 1) {
|
6800 | val = t1 + (t2 - t1) * 6 * t3;
|
6801 | } else if (2 * t3 < 1) {
|
6802 | val = t2;
|
6803 | } else if (3 * t3 < 2) {
|
6804 | val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
6805 | } else {
|
6806 | val = t1;
|
6807 | }
|
6808 |
|
6809 | rgb[i] = val * 255;
|
6810 | }
|
6811 |
|
6812 | return rgb;
|
6813 | };
|
6814 |
|
6815 | convert$1.hsl.hsv = function (hsl) {
|
6816 | const h = hsl[0];
|
6817 | let s = hsl[1] / 100;
|
6818 | let l = hsl[2] / 100;
|
6819 | let smin = s;
|
6820 | const lmin = Math.max(l, 0.01);
|
6821 | l *= 2;
|
6822 | s *= l <= 1 ? l : 2 - l;
|
6823 | smin *= lmin <= 1 ? lmin : 2 - lmin;
|
6824 | const v = (l + s) / 2;
|
6825 | const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
6826 | return [h, sv * 100, v * 100];
|
6827 | };
|
6828 |
|
6829 | convert$1.hsv.rgb = function (hsv) {
|
6830 | const h = hsv[0] / 60;
|
6831 | const s = hsv[1] / 100;
|
6832 | let v = hsv[2] / 100;
|
6833 | const hi = Math.floor(h) % 6;
|
6834 | const f = h - Math.floor(h);
|
6835 | const p = 255 * v * (1 - s);
|
6836 | const q = 255 * v * (1 - s * f);
|
6837 | const t = 255 * v * (1 - s * (1 - f));
|
6838 | v *= 255;
|
6839 |
|
6840 | switch (hi) {
|
6841 | case 0:
|
6842 | return [v, t, p];
|
6843 |
|
6844 | case 1:
|
6845 | return [q, v, p];
|
6846 |
|
6847 | case 2:
|
6848 | return [p, v, t];
|
6849 |
|
6850 | case 3:
|
6851 | return [p, q, v];
|
6852 |
|
6853 | case 4:
|
6854 | return [t, p, v];
|
6855 |
|
6856 | case 5:
|
6857 | return [v, p, q];
|
6858 | }
|
6859 | };
|
6860 |
|
6861 | convert$1.hsv.hsl = function (hsv) {
|
6862 | const h = hsv[0];
|
6863 | const s = hsv[1] / 100;
|
6864 | const v = hsv[2] / 100;
|
6865 | const vmin = Math.max(v, 0.01);
|
6866 | let sl;
|
6867 | let l;
|
6868 | l = (2 - s) * v;
|
6869 | const lmin = (2 - s) * vmin;
|
6870 | sl = s * vmin;
|
6871 | sl /= lmin <= 1 ? lmin : 2 - lmin;
|
6872 | sl = sl || 0;
|
6873 | l /= 2;
|
6874 | return [h, sl * 100, l * 100];
|
6875 | };
|
6876 |
|
6877 |
|
6878 | convert$1.hwb.rgb = function (hwb) {
|
6879 | const h = hwb[0] / 360;
|
6880 | let wh = hwb[1] / 100;
|
6881 | let bl = hwb[2] / 100;
|
6882 | const ratio = wh + bl;
|
6883 | let f;
|
6884 |
|
6885 | if (ratio > 1) {
|
6886 | wh /= ratio;
|
6887 | bl /= ratio;
|
6888 | }
|
6889 |
|
6890 | const i = Math.floor(6 * h);
|
6891 | const v = 1 - bl;
|
6892 | f = 6 * h - i;
|
6893 |
|
6894 | if ((i & 0x01) !== 0) {
|
6895 | f = 1 - f;
|
6896 | }
|
6897 |
|
6898 | const n = wh + f * (v - wh);
|
6899 |
|
6900 | let r;
|
6901 | let g;
|
6902 | let b;
|
6903 |
|
6904 |
|
6905 | switch (i) {
|
6906 | default:
|
6907 | case 6:
|
6908 | case 0:
|
6909 | r = v;
|
6910 | g = n;
|
6911 | b = wh;
|
6912 | break;
|
6913 |
|
6914 | case 1:
|
6915 | r = n;
|
6916 | g = v;
|
6917 | b = wh;
|
6918 | break;
|
6919 |
|
6920 | case 2:
|
6921 | r = wh;
|
6922 | g = v;
|
6923 | b = n;
|
6924 | break;
|
6925 |
|
6926 | case 3:
|
6927 | r = wh;
|
6928 | g = n;
|
6929 | b = v;
|
6930 | break;
|
6931 |
|
6932 | case 4:
|
6933 | r = n;
|
6934 | g = wh;
|
6935 | b = v;
|
6936 | break;
|
6937 |
|
6938 | case 5:
|
6939 | r = v;
|
6940 | g = wh;
|
6941 | b = n;
|
6942 | break;
|
6943 | }
|
6944 |
|
6945 |
|
6946 |
|
6947 | return [r * 255, g * 255, b * 255];
|
6948 | };
|
6949 |
|
6950 | convert$1.cmyk.rgb = function (cmyk) {
|
6951 | const c = cmyk[0] / 100;
|
6952 | const m = cmyk[1] / 100;
|
6953 | const y = cmyk[2] / 100;
|
6954 | const k = cmyk[3] / 100;
|
6955 | const r = 1 - Math.min(1, c * (1 - k) + k);
|
6956 | const g = 1 - Math.min(1, m * (1 - k) + k);
|
6957 | const b = 1 - Math.min(1, y * (1 - k) + k);
|
6958 | return [r * 255, g * 255, b * 255];
|
6959 | };
|
6960 |
|
6961 | convert$1.xyz.rgb = function (xyz) {
|
6962 | const x = xyz[0] / 100;
|
6963 | const y = xyz[1] / 100;
|
6964 | const z = xyz[2] / 100;
|
6965 | let r;
|
6966 | let g;
|
6967 | let b;
|
6968 | r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
6969 | g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
6970 | b = x * 0.0557 + y * -0.2040 + z * 1.0570;
|
6971 |
|
6972 | r = r > 0.0031308 ? 1.055 * r ** (1.0 / 2.4) - 0.055 : r * 12.92;
|
6973 | g = g > 0.0031308 ? 1.055 * g ** (1.0 / 2.4) - 0.055 : g * 12.92;
|
6974 | b = b > 0.0031308 ? 1.055 * b ** (1.0 / 2.4) - 0.055 : b * 12.92;
|
6975 | r = Math.min(Math.max(0, r), 1);
|
6976 | g = Math.min(Math.max(0, g), 1);
|
6977 | b = Math.min(Math.max(0, b), 1);
|
6978 | return [r * 255, g * 255, b * 255];
|
6979 | };
|
6980 |
|
6981 | convert$1.xyz.lab = function (xyz) {
|
6982 | let x = xyz[0];
|
6983 | let y = xyz[1];
|
6984 | let z = xyz[2];
|
6985 | x /= 95.047;
|
6986 | y /= 100;
|
6987 | z /= 108.883;
|
6988 | x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
6989 | y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
6990 | z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
6991 | const l = 116 * y - 16;
|
6992 | const a = 500 * (x - y);
|
6993 | const b = 200 * (y - z);
|
6994 | return [l, a, b];
|
6995 | };
|
6996 |
|
6997 | convert$1.lab.xyz = function (lab) {
|
6998 | const l = lab[0];
|
6999 | const a = lab[1];
|
7000 | const b = lab[2];
|
7001 | let x;
|
7002 | let y;
|
7003 | let z;
|
7004 | y = (l + 16) / 116;
|
7005 | x = a / 500 + y;
|
7006 | z = y - b / 200;
|
7007 | const y2 = y ** 3;
|
7008 | const x2 = x ** 3;
|
7009 | const z2 = z ** 3;
|
7010 | y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
|
7011 | x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
|
7012 | z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
|
7013 | x *= 95.047;
|
7014 | y *= 100;
|
7015 | z *= 108.883;
|
7016 | return [x, y, z];
|
7017 | };
|
7018 |
|
7019 | convert$1.lab.lch = function (lab) {
|
7020 | const l = lab[0];
|
7021 | const a = lab[1];
|
7022 | const b = lab[2];
|
7023 | let h;
|
7024 | const hr = Math.atan2(b, a);
|
7025 | h = hr * 360 / 2 / Math.PI;
|
7026 |
|
7027 | if (h < 0) {
|
7028 | h += 360;
|
7029 | }
|
7030 |
|
7031 | const c = Math.sqrt(a * a + b * b);
|
7032 | return [l, c, h];
|
7033 | };
|
7034 |
|
7035 | convert$1.lch.lab = function (lch) {
|
7036 | const l = lch[0];
|
7037 | const c = lch[1];
|
7038 | const h = lch[2];
|
7039 | const hr = h / 360 * 2 * Math.PI;
|
7040 | const a = c * Math.cos(hr);
|
7041 | const b = c * Math.sin(hr);
|
7042 | return [l, a, b];
|
7043 | };
|
7044 |
|
7045 | convert$1.rgb.ansi16 = function (args, saturation = null) {
|
7046 | const [r, g, b] = args;
|
7047 | let value = saturation === null ? convert$1.rgb.hsv(args)[2] : saturation;
|
7048 |
|
7049 | value = Math.round(value / 50);
|
7050 |
|
7051 | if (value === 0) {
|
7052 | return 30;
|
7053 | }
|
7054 |
|
7055 | let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
7056 |
|
7057 | if (value === 2) {
|
7058 | ansi += 60;
|
7059 | }
|
7060 |
|
7061 | return ansi;
|
7062 | };
|
7063 |
|
7064 | convert$1.hsv.ansi16 = function (args) {
|
7065 |
|
7066 |
|
7067 | return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
|
7068 | };
|
7069 |
|
7070 | convert$1.rgb.ansi256 = function (args) {
|
7071 | const r = args[0];
|
7072 | const g = args[1];
|
7073 | const b = args[2];
|
7074 |
|
7075 |
|
7076 | if (r === g && g === b) {
|
7077 | if (r < 8) {
|
7078 | return 16;
|
7079 | }
|
7080 |
|
7081 | if (r > 248) {
|
7082 | return 231;
|
7083 | }
|
7084 |
|
7085 | return Math.round((r - 8) / 247 * 24) + 232;
|
7086 | }
|
7087 |
|
7088 | const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
7089 | return ansi;
|
7090 | };
|
7091 |
|
7092 | convert$1.ansi16.rgb = function (args) {
|
7093 | let color = args % 10;
|
7094 |
|
7095 | if (color === 0 || color === 7) {
|
7096 | if (args > 50) {
|
7097 | color += 3.5;
|
7098 | }
|
7099 |
|
7100 | color = color / 10.5 * 255;
|
7101 | return [color, color, color];
|
7102 | }
|
7103 |
|
7104 | const mult = (~~(args > 50) + 1) * 0.5;
|
7105 | const r = (color & 1) * mult * 255;
|
7106 | const g = (color >> 1 & 1) * mult * 255;
|
7107 | const b = (color >> 2 & 1) * mult * 255;
|
7108 | return [r, g, b];
|
7109 | };
|
7110 |
|
7111 | convert$1.ansi256.rgb = function (args) {
|
7112 |
|
7113 | if (args >= 232) {
|
7114 | const c = (args - 232) * 10 + 8;
|
7115 | return [c, c, c];
|
7116 | }
|
7117 |
|
7118 | args -= 16;
|
7119 | let rem;
|
7120 | const r = Math.floor(args / 36) / 5 * 255;
|
7121 | const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
7122 | const b = rem % 6 / 5 * 255;
|
7123 | return [r, g, b];
|
7124 | };
|
7125 |
|
7126 | convert$1.rgb.hex = function (args) {
|
7127 | const integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
|
7128 | const string = integer.toString(16).toUpperCase();
|
7129 | return '000000'.substring(string.length) + string;
|
7130 | };
|
7131 |
|
7132 | convert$1.hex.rgb = function (args) {
|
7133 | const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
7134 |
|
7135 | if (!match) {
|
7136 | return [0, 0, 0];
|
7137 | }
|
7138 |
|
7139 | let colorString = match[0];
|
7140 |
|
7141 | if (match[0].length === 3) {
|
7142 | colorString = colorString.split('').map(char => {
|
7143 | return char + char;
|
7144 | }).join('');
|
7145 | }
|
7146 |
|
7147 | const integer = parseInt(colorString, 16);
|
7148 | const r = integer >> 16 & 0xFF;
|
7149 | const g = integer >> 8 & 0xFF;
|
7150 | const b = integer & 0xFF;
|
7151 | return [r, g, b];
|
7152 | };
|
7153 |
|
7154 | convert$1.rgb.hcg = function (rgb) {
|
7155 | const r = rgb[0] / 255;
|
7156 | const g = rgb[1] / 255;
|
7157 | const b = rgb[2] / 255;
|
7158 | const max = Math.max(Math.max(r, g), b);
|
7159 | const min = Math.min(Math.min(r, g), b);
|
7160 | const chroma = max - min;
|
7161 | let grayscale;
|
7162 | let hue;
|
7163 |
|
7164 | if (chroma < 1) {
|
7165 | grayscale = min / (1 - chroma);
|
7166 | } else {
|
7167 | grayscale = 0;
|
7168 | }
|
7169 |
|
7170 | if (chroma <= 0) {
|
7171 | hue = 0;
|
7172 | } else if (max === r) {
|
7173 | hue = (g - b) / chroma % 6;
|
7174 | } else if (max === g) {
|
7175 | hue = 2 + (b - r) / chroma;
|
7176 | } else {
|
7177 | hue = 4 + (r - g) / chroma;
|
7178 | }
|
7179 |
|
7180 | hue /= 6;
|
7181 | hue %= 1;
|
7182 | return [hue * 360, chroma * 100, grayscale * 100];
|
7183 | };
|
7184 |
|
7185 | convert$1.hsl.hcg = function (hsl) {
|
7186 | const s = hsl[1] / 100;
|
7187 | const l = hsl[2] / 100;
|
7188 | const c = l < 0.5 ? 2.0 * s * l : 2.0 * s * (1.0 - l);
|
7189 | let f = 0;
|
7190 |
|
7191 | if (c < 1.0) {
|
7192 | f = (l - 0.5 * c) / (1.0 - c);
|
7193 | }
|
7194 |
|
7195 | return [hsl[0], c * 100, f * 100];
|
7196 | };
|
7197 |
|
7198 | convert$1.hsv.hcg = function (hsv) {
|
7199 | const s = hsv[1] / 100;
|
7200 | const v = hsv[2] / 100;
|
7201 | const c = s * v;
|
7202 | let f = 0;
|
7203 |
|
7204 | if (c < 1.0) {
|
7205 | f = (v - c) / (1 - c);
|
7206 | }
|
7207 |
|
7208 | return [hsv[0], c * 100, f * 100];
|
7209 | };
|
7210 |
|
7211 | convert$1.hcg.rgb = function (hcg) {
|
7212 | const h = hcg[0] / 360;
|
7213 | const c = hcg[1] / 100;
|
7214 | const g = hcg[2] / 100;
|
7215 |
|
7216 | if (c === 0.0) {
|
7217 | return [g * 255, g * 255, g * 255];
|
7218 | }
|
7219 |
|
7220 | const pure = [0, 0, 0];
|
7221 | const hi = h % 1 * 6;
|
7222 | const v = hi % 1;
|
7223 | const w = 1 - v;
|
7224 | let mg = 0;
|
7225 |
|
7226 |
|
7227 | switch (Math.floor(hi)) {
|
7228 | case 0:
|
7229 | pure[0] = 1;
|
7230 | pure[1] = v;
|
7231 | pure[2] = 0;
|
7232 | break;
|
7233 |
|
7234 | case 1:
|
7235 | pure[0] = w;
|
7236 | pure[1] = 1;
|
7237 | pure[2] = 0;
|
7238 | break;
|
7239 |
|
7240 | case 2:
|
7241 | pure[0] = 0;
|
7242 | pure[1] = 1;
|
7243 | pure[2] = v;
|
7244 | break;
|
7245 |
|
7246 | case 3:
|
7247 | pure[0] = 0;
|
7248 | pure[1] = w;
|
7249 | pure[2] = 1;
|
7250 | break;
|
7251 |
|
7252 | case 4:
|
7253 | pure[0] = v;
|
7254 | pure[1] = 0;
|
7255 | pure[2] = 1;
|
7256 | break;
|
7257 |
|
7258 | default:
|
7259 | pure[0] = 1;
|
7260 | pure[1] = 0;
|
7261 | pure[2] = w;
|
7262 | }
|
7263 |
|
7264 |
|
7265 |
|
7266 | mg = (1.0 - c) * g;
|
7267 | return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
|
7268 | };
|
7269 |
|
7270 | convert$1.hcg.hsv = function (hcg) {
|
7271 | const c = hcg[1] / 100;
|
7272 | const g = hcg[2] / 100;
|
7273 | const v = c + g * (1.0 - c);
|
7274 | let f = 0;
|
7275 |
|
7276 | if (v > 0.0) {
|
7277 | f = c / v;
|
7278 | }
|
7279 |
|
7280 | return [hcg[0], f * 100, v * 100];
|
7281 | };
|
7282 |
|
7283 | convert$1.hcg.hsl = function (hcg) {
|
7284 | const c = hcg[1] / 100;
|
7285 | const g = hcg[2] / 100;
|
7286 | const l = g * (1.0 - c) + 0.5 * c;
|
7287 | let s = 0;
|
7288 |
|
7289 | if (l > 0.0 && l < 0.5) {
|
7290 | s = c / (2 * l);
|
7291 | } else if (l >= 0.5 && l < 1.0) {
|
7292 | s = c / (2 * (1 - l));
|
7293 | }
|
7294 |
|
7295 | return [hcg[0], s * 100, l * 100];
|
7296 | };
|
7297 |
|
7298 | convert$1.hcg.hwb = function (hcg) {
|
7299 | const c = hcg[1] / 100;
|
7300 | const g = hcg[2] / 100;
|
7301 | const v = c + g * (1.0 - c);
|
7302 | return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
7303 | };
|
7304 |
|
7305 | convert$1.hwb.hcg = function (hwb) {
|
7306 | const w = hwb[1] / 100;
|
7307 | const b = hwb[2] / 100;
|
7308 | const v = 1 - b;
|
7309 | const c = v - w;
|
7310 | let g = 0;
|
7311 |
|
7312 | if (c < 1) {
|
7313 | g = (v - c) / (1 - c);
|
7314 | }
|
7315 |
|
7316 | return [hwb[0], c * 100, g * 100];
|
7317 | };
|
7318 |
|
7319 | convert$1.apple.rgb = function (apple) {
|
7320 | return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
7321 | };
|
7322 |
|
7323 | convert$1.rgb.apple = function (rgb) {
|
7324 | return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
7325 | };
|
7326 |
|
7327 | convert$1.gray.rgb = function (args) {
|
7328 | return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
7329 | };
|
7330 |
|
7331 | convert$1.gray.hsl = function (args) {
|
7332 | return [0, 0, args[0]];
|
7333 | };
|
7334 |
|
7335 | convert$1.gray.hsv = convert$1.gray.hsl;
|
7336 |
|
7337 | convert$1.gray.hwb = function (gray) {
|
7338 | return [0, 100, gray[0]];
|
7339 | };
|
7340 |
|
7341 | convert$1.gray.cmyk = function (gray) {
|
7342 | return [0, 0, 0, gray[0]];
|
7343 | };
|
7344 |
|
7345 | convert$1.gray.lab = function (gray) {
|
7346 | return [gray[0], 0, 0];
|
7347 | };
|
7348 |
|
7349 | convert$1.gray.hex = function (gray) {
|
7350 | const val = Math.round(gray[0] / 100 * 255) & 0xFF;
|
7351 | const integer = (val << 16) + (val << 8) + val;
|
7352 | const string = integer.toString(16).toUpperCase();
|
7353 | return '000000'.substring(string.length) + string;
|
7354 | };
|
7355 |
|
7356 | convert$1.rgb.gray = function (rgb) {
|
7357 | const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
7358 | return [val / 255 * 100];
|
7359 | };
|
7360 |
|
7361 |
|
7362 |
|
7363 |
|
7364 |
|
7365 |
|
7366 |
|
7367 |
|
7368 |
|
7369 |
|
7370 |
|
7371 |
|
7372 | function buildGraph$1() {
|
7373 | const graph = {};
|
7374 |
|
7375 | const models = Object.keys(conversions$1);
|
7376 |
|
7377 | for (let len = models.length, i = 0; i < len; i++) {
|
7378 | graph[models[i]] = {
|
7379 |
|
7380 |
|
7381 | distance: -1,
|
7382 | parent: null
|
7383 | };
|
7384 | }
|
7385 |
|
7386 | return graph;
|
7387 | }
|
7388 |
|
7389 |
|
7390 | function deriveBFS$1(fromModel) {
|
7391 | const graph = buildGraph$1();
|
7392 | const queue = [fromModel];
|
7393 |
|
7394 | graph[fromModel].distance = 0;
|
7395 |
|
7396 | while (queue.length) {
|
7397 | const current = queue.pop();
|
7398 | const adjacents = Object.keys(conversions$1[current]);
|
7399 |
|
7400 | for (let len = adjacents.length, i = 0; i < len; i++) {
|
7401 | const adjacent = adjacents[i];
|
7402 | const node = graph[adjacent];
|
7403 |
|
7404 | if (node.distance === -1) {
|
7405 | node.distance = graph[current].distance + 1;
|
7406 | node.parent = current;
|
7407 | queue.unshift(adjacent);
|
7408 | }
|
7409 | }
|
7410 | }
|
7411 |
|
7412 | return graph;
|
7413 | }
|
7414 |
|
7415 | function link$1(from, to) {
|
7416 | return function (args) {
|
7417 | return to(from(args));
|
7418 | };
|
7419 | }
|
7420 |
|
7421 | function wrapConversion$1(toModel, graph) {
|
7422 | const path = [graph[toModel].parent, toModel];
|
7423 | let fn = conversions$1[graph[toModel].parent][toModel];
|
7424 | let cur = graph[toModel].parent;
|
7425 |
|
7426 | while (graph[cur].parent) {
|
7427 | path.unshift(graph[cur].parent);
|
7428 | fn = link$1(conversions$1[graph[cur].parent][cur], fn);
|
7429 | cur = graph[cur].parent;
|
7430 | }
|
7431 |
|
7432 | fn.conversion = path;
|
7433 | return fn;
|
7434 | }
|
7435 |
|
7436 | var route$1 = function (fromModel) {
|
7437 | const graph = deriveBFS$1(fromModel);
|
7438 | const conversion = {};
|
7439 | const models = Object.keys(graph);
|
7440 |
|
7441 | for (let len = models.length, i = 0; i < len; i++) {
|
7442 | const toModel = models[i];
|
7443 | const node = graph[toModel];
|
7444 |
|
7445 | if (node.parent === null) {
|
7446 |
|
7447 | continue;
|
7448 | }
|
7449 |
|
7450 | conversion[toModel] = wrapConversion$1(toModel, graph);
|
7451 | }
|
7452 |
|
7453 | return conversion;
|
7454 | };
|
7455 |
|
7456 | const convert$2 = {};
|
7457 | const models$1 = Object.keys(conversions$1);
|
7458 |
|
7459 | function wrapRaw$1(fn) {
|
7460 | const wrappedFn = function (...args) {
|
7461 | const arg0 = args[0];
|
7462 |
|
7463 | if (arg0 === undefined || arg0 === null) {
|
7464 | return arg0;
|
7465 | }
|
7466 |
|
7467 | if (arg0.length > 1) {
|
7468 | args = arg0;
|
7469 | }
|
7470 |
|
7471 | return fn(args);
|
7472 | };
|
7473 |
|
7474 |
|
7475 | if ('conversion' in fn) {
|
7476 | wrappedFn.conversion = fn.conversion;
|
7477 | }
|
7478 |
|
7479 | return wrappedFn;
|
7480 | }
|
7481 |
|
7482 | function wrapRounded$1(fn) {
|
7483 | const wrappedFn = function (...args) {
|
7484 | const arg0 = args[0];
|
7485 |
|
7486 | if (arg0 === undefined || arg0 === null) {
|
7487 | return arg0;
|
7488 | }
|
7489 |
|
7490 | if (arg0.length > 1) {
|
7491 | args = arg0;
|
7492 | }
|
7493 |
|
7494 | const result = fn(args);
|
7495 |
|
7496 |
|
7497 |
|
7498 | if (typeof result === 'object') {
|
7499 | for (let len = result.length, i = 0; i < len; i++) {
|
7500 | result[i] = Math.round(result[i]);
|
7501 | }
|
7502 | }
|
7503 |
|
7504 | return result;
|
7505 | };
|
7506 |
|
7507 |
|
7508 | if ('conversion' in fn) {
|
7509 | wrappedFn.conversion = fn.conversion;
|
7510 | }
|
7511 |
|
7512 | return wrappedFn;
|
7513 | }
|
7514 |
|
7515 | models$1.forEach(fromModel => {
|
7516 | convert$2[fromModel] = {};
|
7517 | Object.defineProperty(convert$2[fromModel], 'channels', {
|
7518 | value: conversions$1[fromModel].channels
|
7519 | });
|
7520 | Object.defineProperty(convert$2[fromModel], 'labels', {
|
7521 | value: conversions$1[fromModel].labels
|
7522 | });
|
7523 | const routes = route$1(fromModel);
|
7524 | const routeModels = Object.keys(routes);
|
7525 | routeModels.forEach(toModel => {
|
7526 | const fn = routes[toModel];
|
7527 | convert$2[fromModel][toModel] = wrapRounded$1(fn);
|
7528 | convert$2[fromModel][toModel].raw = wrapRaw$1(fn);
|
7529 | });
|
7530 | });
|
7531 | var colorConvert$1 = convert$2;
|
7532 |
|
7533 | var ansiStyles$1 = createCommonjsModule(function (module) {
|
7534 |
|
7535 | const wrapAnsi16 = (fn, offset) => (...args) => {
|
7536 | const code = fn(...args);
|
7537 | return `\u001B[${code + offset}m`;
|
7538 | };
|
7539 |
|
7540 | const wrapAnsi256 = (fn, offset) => (...args) => {
|
7541 | const code = fn(...args);
|
7542 | return `\u001B[${38 + offset};5;${code}m`;
|
7543 | };
|
7544 |
|
7545 | const wrapAnsi16m = (fn, offset) => (...args) => {
|
7546 | const rgb = fn(...args);
|
7547 | return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
7548 | };
|
7549 |
|
7550 | const ansi2ansi = n => n;
|
7551 |
|
7552 | const rgb2rgb = (r, g, b) => [r, g, b];
|
7553 |
|
7554 | const setLazyProperty = (object, property, get) => {
|
7555 | Object.defineProperty(object, property, {
|
7556 | get: () => {
|
7557 | const value = get();
|
7558 | Object.defineProperty(object, property, {
|
7559 | value,
|
7560 | enumerable: true,
|
7561 | configurable: true
|
7562 | });
|
7563 | return value;
|
7564 | },
|
7565 | enumerable: true,
|
7566 | configurable: true
|
7567 | });
|
7568 | };
|
7569 |
|
7570 |
|
7571 |
|
7572 | let colorConvert;
|
7573 |
|
7574 | const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
7575 | if (colorConvert === undefined) {
|
7576 | colorConvert = colorConvert$1;
|
7577 | }
|
7578 |
|
7579 | const offset = isBackground ? 10 : 0;
|
7580 | const styles = {};
|
7581 |
|
7582 | for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
|
7583 | const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
|
7584 |
|
7585 | if (sourceSpace === targetSpace) {
|
7586 | styles[name] = wrap(identity, offset);
|
7587 | } else if (typeof suite === 'object') {
|
7588 | styles[name] = wrap(suite[targetSpace], offset);
|
7589 | }
|
7590 | }
|
7591 |
|
7592 | return styles;
|
7593 | };
|
7594 |
|
7595 | function assembleStyles() {
|
7596 | const codes = new Map();
|
7597 | const styles = {
|
7598 | modifier: {
|
7599 | reset: [0, 0],
|
7600 |
|
7601 | bold: [1, 22],
|
7602 | dim: [2, 22],
|
7603 | italic: [3, 23],
|
7604 | underline: [4, 24],
|
7605 | inverse: [7, 27],
|
7606 | hidden: [8, 28],
|
7607 | strikethrough: [9, 29]
|
7608 | },
|
7609 | color: {
|
7610 | black: [30, 39],
|
7611 | red: [31, 39],
|
7612 | green: [32, 39],
|
7613 | yellow: [33, 39],
|
7614 | blue: [34, 39],
|
7615 | magenta: [35, 39],
|
7616 | cyan: [36, 39],
|
7617 | white: [37, 39],
|
7618 |
|
7619 | blackBright: [90, 39],
|
7620 | redBright: [91, 39],
|
7621 | greenBright: [92, 39],
|
7622 | yellowBright: [93, 39],
|
7623 | blueBright: [94, 39],
|
7624 | magentaBright: [95, 39],
|
7625 | cyanBright: [96, 39],
|
7626 | whiteBright: [97, 39]
|
7627 | },
|
7628 | bgColor: {
|
7629 | bgBlack: [40, 49],
|
7630 | bgRed: [41, 49],
|
7631 | bgGreen: [42, 49],
|
7632 | bgYellow: [43, 49],
|
7633 | bgBlue: [44, 49],
|
7634 | bgMagenta: [45, 49],
|
7635 | bgCyan: [46, 49],
|
7636 | bgWhite: [47, 49],
|
7637 |
|
7638 | bgBlackBright: [100, 49],
|
7639 | bgRedBright: [101, 49],
|
7640 | bgGreenBright: [102, 49],
|
7641 | bgYellowBright: [103, 49],
|
7642 | bgBlueBright: [104, 49],
|
7643 | bgMagentaBright: [105, 49],
|
7644 | bgCyanBright: [106, 49],
|
7645 | bgWhiteBright: [107, 49]
|
7646 | }
|
7647 | };
|
7648 |
|
7649 | styles.color.gray = styles.color.blackBright;
|
7650 | styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
|
7651 | styles.color.grey = styles.color.blackBright;
|
7652 | styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
|
7653 |
|
7654 | for (const [groupName, group] of Object.entries(styles)) {
|
7655 | for (const [styleName, style] of Object.entries(group)) {
|
7656 | styles[styleName] = {
|
7657 | open: `\u001B[${style[0]}m`,
|
7658 | close: `\u001B[${style[1]}m`
|
7659 | };
|
7660 | group[styleName] = styles[styleName];
|
7661 | codes.set(style[0], style[1]);
|
7662 | }
|
7663 |
|
7664 | Object.defineProperty(styles, groupName, {
|
7665 | value: group,
|
7666 | enumerable: false
|
7667 | });
|
7668 | }
|
7669 |
|
7670 | Object.defineProperty(styles, 'codes', {
|
7671 | value: codes,
|
7672 | enumerable: false
|
7673 | });
|
7674 | styles.color.close = '\u001B[39m';
|
7675 | styles.bgColor.close = '\u001B[49m';
|
7676 | setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
|
7677 | setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
|
7678 | setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
|
7679 | setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
|
7680 | setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
|
7681 | setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
|
7682 | return styles;
|
7683 | }
|
7684 |
|
7685 |
|
7686 | Object.defineProperty(module, 'exports', {
|
7687 | enumerable: true,
|
7688 | get: assembleStyles
|
7689 | });
|
7690 | });
|
7691 |
|
7692 | var hasFlag$1 = (flag, argv = process.argv) => {
|
7693 | const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
|
7694 | const position = argv.indexOf(prefix + flag);
|
7695 | const terminatorPosition = argv.indexOf('--');
|
7696 | return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
7697 | };
|
7698 |
|
7699 | const {
|
7700 | env: env$1
|
7701 | } = process;
|
7702 | let forceColor$1;
|
7703 |
|
7704 | if (hasFlag$1('no-color') || hasFlag$1('no-colors') || hasFlag$1('color=false') || hasFlag$1('color=never')) {
|
7705 | forceColor$1 = 0;
|
7706 | } else if (hasFlag$1('color') || hasFlag$1('colors') || hasFlag$1('color=true') || hasFlag$1('color=always')) {
|
7707 | forceColor$1 = 1;
|
7708 | }
|
7709 |
|
7710 | if ('FORCE_COLOR' in env$1) {
|
7711 | if (env$1.FORCE_COLOR === 'true') {
|
7712 | forceColor$1 = 1;
|
7713 | } else if (env$1.FORCE_COLOR === 'false') {
|
7714 | forceColor$1 = 0;
|
7715 | } else {
|
7716 | forceColor$1 = env$1.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env$1.FORCE_COLOR, 10), 3);
|
7717 | }
|
7718 | }
|
7719 |
|
7720 | function translateLevel$1(level) {
|
7721 | if (level === 0) {
|
7722 | return false;
|
7723 | }
|
7724 |
|
7725 | return {
|
7726 | level,
|
7727 | hasBasic: true,
|
7728 | has256: level >= 2,
|
7729 | has16m: level >= 3
|
7730 | };
|
7731 | }
|
7732 |
|
7733 | function supportsColor$1(haveStream, streamIsTTY) {
|
7734 | if (forceColor$1 === 0) {
|
7735 | return 0;
|
7736 | }
|
7737 |
|
7738 | if (hasFlag$1('color=16m') || hasFlag$1('color=full') || hasFlag$1('color=truecolor')) {
|
7739 | return 3;
|
7740 | }
|
7741 |
|
7742 | if (hasFlag$1('color=256')) {
|
7743 | return 2;
|
7744 | }
|
7745 |
|
7746 | if (haveStream && !streamIsTTY && forceColor$1 === undefined) {
|
7747 | return 0;
|
7748 | }
|
7749 |
|
7750 | const min = forceColor$1 || 0;
|
7751 |
|
7752 | if (env$1.TERM === 'dumb') {
|
7753 | return min;
|
7754 | }
|
7755 |
|
7756 | if (process.platform === 'win32') {
|
7757 |
|
7758 |
|
7759 | const osRelease = os$1.release().split('.');
|
7760 |
|
7761 | if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
7762 | return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
7763 | }
|
7764 |
|
7765 | return 1;
|
7766 | }
|
7767 |
|
7768 | if ('CI' in env$1) {
|
7769 | if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env$1) || env$1.CI_NAME === 'codeship') {
|
7770 | return 1;
|
7771 | }
|
7772 |
|
7773 | return min;
|
7774 | }
|
7775 |
|
7776 | if ('TEAMCITY_VERSION' in env$1) {
|
7777 | return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0;
|
7778 | }
|
7779 |
|
7780 | if ('GITHUB_ACTIONS' in env$1) {
|
7781 | return 1;
|
7782 | }
|
7783 |
|
7784 | if (env$1.COLORTERM === 'truecolor') {
|
7785 | return 3;
|
7786 | }
|
7787 |
|
7788 | if ('TERM_PROGRAM' in env$1) {
|
7789 | const version = parseInt((env$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
7790 |
|
7791 | switch (env$1.TERM_PROGRAM) {
|
7792 | case 'iTerm.app':
|
7793 | return version >= 3 ? 3 : 2;
|
7794 |
|
7795 | case 'Apple_Terminal':
|
7796 | return 2;
|
7797 |
|
7798 | }
|
7799 | }
|
7800 |
|
7801 | if (/-256(color)?$/i.test(env$1.TERM)) {
|
7802 | return 2;
|
7803 | }
|
7804 |
|
7805 | if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) {
|
7806 | return 1;
|
7807 | }
|
7808 |
|
7809 | if ('COLORTERM' in env$1) {
|
7810 | return 1;
|
7811 | }
|
7812 |
|
7813 | return min;
|
7814 | }
|
7815 |
|
7816 | function getSupportLevel$1(stream) {
|
7817 | const level = supportsColor$1(stream, stream && stream.isTTY);
|
7818 | return translateLevel$1(level);
|
7819 | }
|
7820 |
|
7821 | var supportsColor_1$1 = {
|
7822 | supportsColor: getSupportLevel$1,
|
7823 | stdout: translateLevel$1(supportsColor$1(true, tty$1.isatty(1))),
|
7824 | stderr: translateLevel$1(supportsColor$1(true, tty$1.isatty(2)))
|
7825 | };
|
7826 |
|
7827 | const stringReplaceAll = (string, substring, replacer) => {
|
7828 | let index = string.indexOf(substring);
|
7829 |
|
7830 | if (index === -1) {
|
7831 | return string;
|
7832 | }
|
7833 |
|
7834 | const substringLength = substring.length;
|
7835 | let endIndex = 0;
|
7836 | let returnValue = '';
|
7837 |
|
7838 | do {
|
7839 | returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
7840 | endIndex = index + substringLength;
|
7841 | index = string.indexOf(substring, endIndex);
|
7842 | } while (index !== -1);
|
7843 |
|
7844 | returnValue += string.substr(endIndex);
|
7845 | return returnValue;
|
7846 | };
|
7847 |
|
7848 | const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
|
7849 | let endIndex = 0;
|
7850 | let returnValue = '';
|
7851 |
|
7852 | do {
|
7853 | const gotCR = string[index - 1] === '\r';
|
7854 | returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
|
7855 | endIndex = index + 1;
|
7856 | index = string.indexOf('\n', endIndex);
|
7857 | } while (index !== -1);
|
7858 |
|
7859 | returnValue += string.substr(endIndex);
|
7860 | return returnValue;
|
7861 | };
|
7862 |
|
7863 | var util = {
|
7864 | stringReplaceAll,
|
7865 | stringEncaseCRLFWithFirstIndex
|
7866 | };
|
7867 |
|
7868 | const TEMPLATE_REGEX$1 = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
7869 | const STYLE_REGEX$1 = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
7870 | const STRING_REGEX$1 = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
7871 | const ESCAPE_REGEX$1 = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
7872 | const ESCAPES$1 = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
|
7873 |
|
7874 | function unescape$1(c) {
|
7875 | const u = c[0] === 'u';
|
7876 | const bracket = c[1] === '{';
|
7877 |
|
7878 | if (u && !bracket && c.length === 5 || c[0] === 'x' && c.length === 3) {
|
7879 | return String.fromCharCode(parseInt(c.slice(1), 16));
|
7880 | }
|
7881 |
|
7882 | if (u && bracket) {
|
7883 | return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
7884 | }
|
7885 |
|
7886 | return ESCAPES$1.get(c) || c;
|
7887 | }
|
7888 |
|
7889 | function parseArguments$1(name, arguments_) {
|
7890 | const results = [];
|
7891 | const chunks = arguments_.trim().split(/\s*,\s*/g);
|
7892 | let matches;
|
7893 |
|
7894 | for (const chunk of chunks) {
|
7895 | const number = Number(chunk);
|
7896 |
|
7897 | if (!Number.isNaN(number)) {
|
7898 | results.push(number);
|
7899 | } else if (matches = chunk.match(STRING_REGEX$1)) {
|
7900 | results.push(matches[2].replace(ESCAPE_REGEX$1, (m, escape, character) => escape ? unescape$1(escape) : character));
|
7901 | } else {
|
7902 | throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
7903 | }
|
7904 | }
|
7905 |
|
7906 | return results;
|
7907 | }
|
7908 |
|
7909 | function parseStyle$1(style) {
|
7910 | STYLE_REGEX$1.lastIndex = 0;
|
7911 | const results = [];
|
7912 | let matches;
|
7913 |
|
7914 | while ((matches = STYLE_REGEX$1.exec(style)) !== null) {
|
7915 | const name = matches[1];
|
7916 |
|
7917 | if (matches[2]) {
|
7918 | const args = parseArguments$1(name, matches[2]);
|
7919 | results.push([name].concat(args));
|
7920 | } else {
|
7921 | results.push([name]);
|
7922 | }
|
7923 | }
|
7924 |
|
7925 | return results;
|
7926 | }
|
7927 |
|
7928 | function buildStyle$1(chalk, styles) {
|
7929 | const enabled = {};
|
7930 |
|
7931 | for (const layer of styles) {
|
7932 | for (const style of layer.styles) {
|
7933 | enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
7934 | }
|
7935 | }
|
7936 |
|
7937 | let current = chalk;
|
7938 |
|
7939 | for (const [styleName, styles] of Object.entries(enabled)) {
|
7940 | if (!Array.isArray(styles)) {
|
7941 | continue;
|
7942 | }
|
7943 |
|
7944 | if (!(styleName in current)) {
|
7945 | throw new Error(`Unknown Chalk style: ${styleName}`);
|
7946 | }
|
7947 |
|
7948 | current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
|
7949 | }
|
7950 |
|
7951 | return current;
|
7952 | }
|
7953 |
|
7954 | var templates$1 = (chalk, temporary) => {
|
7955 | const styles = [];
|
7956 | const chunks = [];
|
7957 | let chunk = [];
|
7958 |
|
7959 | temporary.replace(TEMPLATE_REGEX$1, (m, escapeCharacter, inverse, style, close, character) => {
|
7960 | if (escapeCharacter) {
|
7961 | chunk.push(unescape$1(escapeCharacter));
|
7962 | } else if (style) {
|
7963 | const string = chunk.join('');
|
7964 | chunk = [];
|
7965 | chunks.push(styles.length === 0 ? string : buildStyle$1(chalk, styles)(string));
|
7966 | styles.push({
|
7967 | inverse,
|
7968 | styles: parseStyle$1(style)
|
7969 | });
|
7970 | } else if (close) {
|
7971 | if (styles.length === 0) {
|
7972 | throw new Error('Found extraneous } in Chalk template literal');
|
7973 | }
|
7974 |
|
7975 | chunks.push(buildStyle$1(chalk, styles)(chunk.join('')));
|
7976 | chunk = [];
|
7977 | styles.pop();
|
7978 | } else {
|
7979 | chunk.push(character);
|
7980 | }
|
7981 | });
|
7982 | chunks.push(chunk.join(''));
|
7983 |
|
7984 | if (styles.length > 0) {
|
7985 | const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
7986 | throw new Error(errMessage);
|
7987 | }
|
7988 |
|
7989 | return chunks.join('');
|
7990 | };
|
7991 |
|
7992 | const {
|
7993 | stdout: stdoutColor,
|
7994 | stderr: stderrColor
|
7995 | } = supportsColor_1$1;
|
7996 | const {
|
7997 | stringReplaceAll: stringReplaceAll$1,
|
7998 | stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
|
7999 | } = util;
|
8000 |
|
8001 | const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
|
8002 | const styles = Object.create(null);
|
8003 |
|
8004 | const applyOptions = (object, options = {}) => {
|
8005 | if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
8006 | throw new Error('The `level` option should be an integer from 0 to 3');
|
8007 | }
|
8008 |
|
8009 |
|
8010 | const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
8011 | object.level = options.level === undefined ? colorLevel : options.level;
|
8012 | };
|
8013 |
|
8014 | class ChalkClass {
|
8015 | constructor(options) {
|
8016 |
|
8017 | return chalkFactory(options);
|
8018 | }
|
8019 |
|
8020 | }
|
8021 |
|
8022 | const chalkFactory = options => {
|
8023 | const chalk = {};
|
8024 | applyOptions(chalk, options);
|
8025 |
|
8026 | chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
|
8027 |
|
8028 | Object.setPrototypeOf(chalk, Chalk.prototype);
|
8029 | Object.setPrototypeOf(chalk.template, chalk);
|
8030 |
|
8031 | chalk.template.constructor = () => {
|
8032 | throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
|
8033 | };
|
8034 |
|
8035 | chalk.template.Instance = ChalkClass;
|
8036 | return chalk.template;
|
8037 | };
|
8038 |
|
8039 | function Chalk(options) {
|
8040 | return chalkFactory(options);
|
8041 | }
|
8042 |
|
8043 | for (const [styleName, style] of Object.entries(ansiStyles$1)) {
|
8044 | styles[styleName] = {
|
8045 | get() {
|
8046 | const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
8047 | Object.defineProperty(this, styleName, {
|
8048 | value: builder
|
8049 | });
|
8050 | return builder;
|
8051 | }
|
8052 |
|
8053 | };
|
8054 | }
|
8055 |
|
8056 | styles.visible = {
|
8057 | get() {
|
8058 | const builder = createBuilder(this, this._styler, true);
|
8059 | Object.defineProperty(this, 'visible', {
|
8060 | value: builder
|
8061 | });
|
8062 | return builder;
|
8063 | }
|
8064 |
|
8065 | };
|
8066 | const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
|
8067 |
|
8068 | for (const model of usedModels) {
|
8069 | styles[model] = {
|
8070 | get() {
|
8071 | const {
|
8072 | level
|
8073 | } = this;
|
8074 | return function (...arguments_) {
|
8075 | const styler = createStyler(ansiStyles$1.color[levelMapping[level]][model](...arguments_), ansiStyles$1.color.close, this._styler);
|
8076 | return createBuilder(this, styler, this._isEmpty);
|
8077 | };
|
8078 | }
|
8079 |
|
8080 | };
|
8081 | }
|
8082 |
|
8083 | for (const model of usedModels) {
|
8084 | const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
8085 | styles[bgModel] = {
|
8086 | get() {
|
8087 | const {
|
8088 | level
|
8089 | } = this;
|
8090 | return function (...arguments_) {
|
8091 | const styler = createStyler(ansiStyles$1.bgColor[levelMapping[level]][model](...arguments_), ansiStyles$1.bgColor.close, this._styler);
|
8092 | return createBuilder(this, styler, this._isEmpty);
|
8093 | };
|
8094 | }
|
8095 |
|
8096 | };
|
8097 | }
|
8098 |
|
8099 | const proto = Object.defineProperties(() => {}, Object.assign({}, styles, {
|
8100 | level: {
|
8101 | enumerable: true,
|
8102 |
|
8103 | get() {
|
8104 | return this._generator.level;
|
8105 | },
|
8106 |
|
8107 | set(level) {
|
8108 | this._generator.level = level;
|
8109 | }
|
8110 |
|
8111 | }
|
8112 | }));
|
8113 |
|
8114 | const createStyler = (open, close, parent) => {
|
8115 | let openAll;
|
8116 | let closeAll;
|
8117 |
|
8118 | if (parent === undefined) {
|
8119 | openAll = open;
|
8120 | closeAll = close;
|
8121 | } else {
|
8122 | openAll = parent.openAll + open;
|
8123 | closeAll = close + parent.closeAll;
|
8124 | }
|
8125 |
|
8126 | return {
|
8127 | open,
|
8128 | close,
|
8129 | openAll,
|
8130 | closeAll,
|
8131 | parent
|
8132 | };
|
8133 | };
|
8134 |
|
8135 | const createBuilder = (self, _styler, _isEmpty) => {
|
8136 | const builder = (...arguments_) => {
|
8137 |
|
8138 |
|
8139 | return applyStyle(builder, arguments_.length === 1 ? '' + arguments_[0] : arguments_.join(' '));
|
8140 | };
|
8141 |
|
8142 |
|
8143 |
|
8144 | Object.setPrototypeOf(builder, proto);
|
8145 | builder._generator = self;
|
8146 | builder._styler = _styler;
|
8147 | builder._isEmpty = _isEmpty;
|
8148 | return builder;
|
8149 | };
|
8150 |
|
8151 | const applyStyle = (self, string) => {
|
8152 | if (self.level <= 0 || !string) {
|
8153 | return self._isEmpty ? '' : string;
|
8154 | }
|
8155 |
|
8156 | let styler = self._styler;
|
8157 |
|
8158 | if (styler === undefined) {
|
8159 | return string;
|
8160 | }
|
8161 |
|
8162 | const {
|
8163 | openAll,
|
8164 | closeAll
|
8165 | } = styler;
|
8166 |
|
8167 | if (string.indexOf('\u001B') !== -1) {
|
8168 | while (styler !== undefined) {
|
8169 |
|
8170 |
|
8171 |
|
8172 | string = stringReplaceAll$1(string, styler.close, styler.open);
|
8173 | styler = styler.parent;
|
8174 | }
|
8175 | }
|
8176 |
|
8177 |
|
8178 |
|
8179 |
|
8180 | const lfIndex = string.indexOf('\n');
|
8181 |
|
8182 | if (lfIndex !== -1) {
|
8183 | string = stringEncaseCRLFWithFirstIndex$1(string, closeAll, openAll, lfIndex);
|
8184 | }
|
8185 |
|
8186 | return openAll + string + closeAll;
|
8187 | };
|
8188 |
|
8189 | let template;
|
8190 |
|
8191 | const chalkTag = (chalk, ...strings) => {
|
8192 | const [firstString] = strings;
|
8193 |
|
8194 | if (!Array.isArray(firstString)) {
|
8195 |
|
8196 |
|
8197 | return strings.join(' ');
|
8198 | }
|
8199 |
|
8200 | const arguments_ = strings.slice(1);
|
8201 | const parts = [firstString.raw[0]];
|
8202 |
|
8203 | for (let i = 1; i < firstString.length; i++) {
|
8204 | parts.push(String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'), String(firstString.raw[i]));
|
8205 | }
|
8206 |
|
8207 | if (template === undefined) {
|
8208 | template = templates$1;
|
8209 | }
|
8210 |
|
8211 | return template(chalk, parts.join(''));
|
8212 | };
|
8213 |
|
8214 | Object.defineProperties(Chalk.prototype, styles);
|
8215 | const chalk$1 = Chalk();
|
8216 |
|
8217 | chalk$1.supportsColor = stdoutColor;
|
8218 | chalk$1.stderr = Chalk({
|
8219 | level: stderrColor ? stderrColor.level : 0
|
8220 | });
|
8221 |
|
8222 | chalk$1.stderr.supportsColor = stderrColor;
|
8223 | var source = chalk$1;
|
8224 |
|
8225 | const cliDescriptor = {
|
8226 | key: key => key.length === 1 ? `-${key}` : `--${key}`,
|
8227 | value: value => lib.apiDescriptor.value(value),
|
8228 | pair: ({
|
8229 | key,
|
8230 | value
|
8231 | }) => value === false ? `--no-${key}` : value === true ? cliDescriptor.key(key) : value === "" ? `${cliDescriptor.key(key)} without an argument` : `${cliDescriptor.key(key)}=${value}`
|
8232 | };
|
8233 |
|
8234 | class FlagSchema extends lib.ChoiceSchema {
|
8235 | constructor({
|
8236 | name,
|
8237 | flags
|
8238 | }) {
|
8239 | super({
|
8240 | name,
|
8241 | choices: flags
|
8242 | });
|
8243 | this._flags = flags.slice().sort();
|
8244 | }
|
8245 |
|
8246 | preprocess(value, utils) {
|
8247 | if (typeof value === "string" && value.length !== 0 && !this._flags.includes(value)) {
|
8248 | const suggestion = this._flags.find(flag => leven_1$1(flag, value) < 3);
|
8249 |
|
8250 | if (suggestion) {
|
8251 | utils.logger.warn([`Unknown flag ${source.yellow(utils.descriptor.value(value))},`, `did you mean ${source.blue(utils.descriptor.value(suggestion))}?`].join(" "));
|
8252 | return suggestion;
|
8253 | }
|
8254 | }
|
8255 |
|
8256 | return value;
|
8257 | }
|
8258 |
|
8259 | expected() {
|
8260 | return "a flag";
|
8261 | }
|
8262 |
|
8263 | }
|
8264 |
|
8265 | let hasDeprecationWarned;
|
8266 |
|
8267 | function normalizeOptions(options, optionInfos, {
|
8268 | logger,
|
8269 | isCLI = false,
|
8270 | passThrough = false
|
8271 | } = {}) {
|
8272 | const unknown = !passThrough ? lib.levenUnknownHandler : Array.isArray(passThrough) ? (key, value) => !passThrough.includes(key) ? undefined : {
|
8273 | [key]: value
|
8274 | } : (key, value) => ({
|
8275 | [key]: value
|
8276 | });
|
8277 | const descriptor = isCLI ? cliDescriptor : lib.apiDescriptor;
|
8278 | const schemas = optionInfosToSchemas(optionInfos, {
|
8279 | isCLI
|
8280 | });
|
8281 | const normalizer = new lib.Normalizer(schemas, {
|
8282 | logger,
|
8283 | unknown,
|
8284 | descriptor
|
8285 | });
|
8286 | const shouldSuppressDuplicateDeprecationWarnings = logger !== false;
|
8287 |
|
8288 | if (shouldSuppressDuplicateDeprecationWarnings && hasDeprecationWarned) {
|
8289 | normalizer._hasDeprecationWarned = hasDeprecationWarned;
|
8290 | }
|
8291 |
|
8292 | const normalized = normalizer.normalize(options);
|
8293 |
|
8294 | if (shouldSuppressDuplicateDeprecationWarnings) {
|
8295 | hasDeprecationWarned = normalizer._hasDeprecationWarned;
|
8296 | }
|
8297 |
|
8298 | return normalized;
|
8299 | }
|
8300 |
|
8301 | function optionInfosToSchemas(optionInfos, {
|
8302 | isCLI
|
8303 | }) {
|
8304 | const schemas = [];
|
8305 |
|
8306 | if (isCLI) {
|
8307 | schemas.push(lib.AnySchema.create({
|
8308 | name: "_"
|
8309 | }));
|
8310 | }
|
8311 |
|
8312 | for (const optionInfo of optionInfos) {
|
8313 | schemas.push(optionInfoToSchema(optionInfo, {
|
8314 | isCLI,
|
8315 | optionInfos
|
8316 | }));
|
8317 |
|
8318 | if (optionInfo.alias && isCLI) {
|
8319 | schemas.push(lib.AliasSchema.create({
|
8320 | name: optionInfo.alias,
|
8321 | sourceName: optionInfo.name
|
8322 | }));
|
8323 | }
|
8324 | }
|
8325 |
|
8326 | return schemas;
|
8327 | }
|
8328 |
|
8329 | function optionInfoToSchema(optionInfo, {
|
8330 | isCLI,
|
8331 | optionInfos
|
8332 | }) {
|
8333 | let SchemaConstructor;
|
8334 | const parameters = {
|
8335 | name: optionInfo.name
|
8336 | };
|
8337 | const handlers = {};
|
8338 |
|
8339 | switch (optionInfo.type) {
|
8340 | case "int":
|
8341 | SchemaConstructor = lib.IntegerSchema;
|
8342 |
|
8343 | if (isCLI) {
|
8344 | parameters.preprocess = value => Number(value);
|
8345 | }
|
8346 |
|
8347 | break;
|
8348 |
|
8349 | case "string":
|
8350 | SchemaConstructor = lib.StringSchema;
|
8351 | break;
|
8352 |
|
8353 | case "choice":
|
8354 | SchemaConstructor = lib.ChoiceSchema;
|
8355 | parameters.choices = optionInfo.choices.map(choiceInfo => typeof choiceInfo === "object" && choiceInfo.redirect ? Object.assign({}, choiceInfo, {
|
8356 | redirect: {
|
8357 | to: {
|
8358 | key: optionInfo.name,
|
8359 | value: choiceInfo.redirect
|
8360 | }
|
8361 | }
|
8362 | }) : choiceInfo);
|
8363 | break;
|
8364 |
|
8365 | case "boolean":
|
8366 | SchemaConstructor = lib.BooleanSchema;
|
8367 | break;
|
8368 |
|
8369 | case "flag":
|
8370 | SchemaConstructor = FlagSchema;
|
8371 | parameters.flags = optionInfos.map(optionInfo => [].concat(optionInfo.alias || [], optionInfo.description ? optionInfo.name : [], optionInfo.oppositeDescription ? `no-${optionInfo.name}` : [])).reduce((a, b) => a.concat(b), []);
|
8372 | break;
|
8373 |
|
8374 | case "path":
|
8375 | SchemaConstructor = lib.StringSchema;
|
8376 | break;
|
8377 |
|
8378 | default:
|
8379 | throw new Error(`Unexpected type ${optionInfo.type}`);
|
8380 | }
|
8381 |
|
8382 | if (optionInfo.exception) {
|
8383 | parameters.validate = (value, schema, utils) => {
|
8384 | return optionInfo.exception(value) || schema.validate(value, utils);
|
8385 | };
|
8386 | } else {
|
8387 | parameters.validate = (value, schema, utils) => {
|
8388 | return value === undefined || schema.validate(value, utils);
|
8389 | };
|
8390 | }
|
8391 |
|
8392 | if (optionInfo.redirect) {
|
8393 | handlers.redirect = value => !value ? undefined : {
|
8394 | to: {
|
8395 | key: optionInfo.redirect.option,
|
8396 | value: optionInfo.redirect.value
|
8397 | }
|
8398 | };
|
8399 | }
|
8400 |
|
8401 | if (optionInfo.deprecated) {
|
8402 | handlers.deprecated = true;
|
8403 | }
|
8404 |
|
8405 |
|
8406 | if (isCLI && !optionInfo.array) {
|
8407 | const originalPreprocess = parameters.preprocess || (x => x);
|
8408 |
|
8409 | parameters.preprocess = (value, schema, utils) => schema.preprocess(originalPreprocess(Array.isArray(value) ? value[value.length - 1] : value), utils);
|
8410 | }
|
8411 |
|
8412 | return optionInfo.array ? lib.ArraySchema.create(Object.assign({}, isCLI ? {
|
8413 | preprocess: v => [].concat(v)
|
8414 | } : {}, {}, handlers, {
|
8415 | valueSchema: SchemaConstructor.create(parameters)
|
8416 | })) : SchemaConstructor.create(Object.assign({}, parameters, {}, handlers));
|
8417 | }
|
8418 |
|
8419 | function normalizeApiOptions(options, optionInfos, opts) {
|
8420 | return normalizeOptions(options, optionInfos, opts);
|
8421 | }
|
8422 |
|
8423 | function normalizeCliOptions(options, optionInfos, opts) {
|
8424 | return normalizeOptions(options, optionInfos, Object.assign({
|
8425 | isCLI: true
|
8426 | }, opts));
|
8427 | }
|
8428 |
|
8429 | var optionsNormalizer = {
|
8430 | normalizeApiOptions,
|
8431 | normalizeCliOptions
|
8432 | };
|
8433 |
|
8434 | var getLast = arr => arr[arr.length - 1];
|
8435 |
|
8436 | function locStart(node, opts) {
|
8437 | opts = opts || {};
|
8438 |
|
8439 | if (!opts.ignoreDecorators && node.declaration && node.declaration.decorators && node.declaration.decorators.length > 0) {
|
8440 | return locStart(node.declaration.decorators[0]);
|
8441 | }
|
8442 |
|
8443 | if (!opts.ignoreDecorators && node.decorators && node.decorators.length > 0) {
|
8444 | return locStart(node.decorators[0]);
|
8445 | }
|
8446 |
|
8447 | if (node.__location) {
|
8448 | return node.__location.startOffset;
|
8449 | }
|
8450 |
|
8451 | if (node.range) {
|
8452 | return node.range[0];
|
8453 | }
|
8454 |
|
8455 | if (typeof node.start === "number") {
|
8456 | return node.start;
|
8457 | }
|
8458 |
|
8459 | if (node.loc) {
|
8460 | return node.loc.start;
|
8461 | }
|
8462 |
|
8463 | return null;
|
8464 | }
|
8465 |
|
8466 | function locEnd(node) {
|
8467 | const endNode = node.nodes && getLast(node.nodes);
|
8468 |
|
8469 | if (endNode && node.source && !node.source.end) {
|
8470 | node = endNode;
|
8471 | }
|
8472 |
|
8473 | if (node.__location) {
|
8474 | return node.__location.endOffset;
|
8475 | }
|
8476 |
|
8477 | const loc = node.range ? node.range[1] : typeof node.end === "number" ? node.end : null;
|
8478 |
|
8479 | if (node.typeAnnotation) {
|
8480 | return Math.max(loc, locEnd(node.typeAnnotation));
|
8481 | }
|
8482 |
|
8483 | if (node.loc && !loc) {
|
8484 | return node.loc.end;
|
8485 | }
|
8486 |
|
8487 | return loc;
|
8488 | }
|
8489 |
|
8490 | function composeLoc(startNode, endNodeOrLength = startNode) {
|
8491 | const length = typeof endNodeOrLength === "number" ? endNodeOrLength : -1;
|
8492 | const start = locStart(startNode);
|
8493 | const end = length !== -1 ? start + length : locEnd(endNodeOrLength);
|
8494 | const startLoc = startNode.loc.start;
|
8495 | return {
|
8496 | start,
|
8497 | end,
|
8498 | range: [start, end],
|
8499 | loc: {
|
8500 | start: startLoc,
|
8501 | end: length !== -1 ? {
|
8502 | line: startLoc.line,
|
8503 | column: startLoc.column + length
|
8504 | } : endNodeOrLength.loc.end
|
8505 | }
|
8506 | };
|
8507 | }
|
8508 |
|
8509 | var loc = {
|
8510 | locStart,
|
8511 | locEnd,
|
8512 | composeLoc
|
8513 | };
|
8514 |
|
8515 | var jsTokens = createCommonjsModule(function (module, exports) {
|
8516 |
|
8517 |
|
8518 | Object.defineProperty(exports, "__esModule", {
|
8519 | value: true
|
8520 | });
|
8521 |
|
8522 |
|
8523 | exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g;
|
8524 |
|
8525 | exports.matchToToken = function (match) {
|
8526 | var token = {
|
8527 | type: "invalid",
|
8528 | value: match[0],
|
8529 | closed: undefined
|
8530 | };
|
8531 | if (match[1]) token.type = "string", token.closed = !!(match[3] || match[4]);else if (match[5]) token.type = "comment";else if (match[6]) token.type = "comment", token.closed = !!match[7];else if (match[8]) token.type = "regex";else if (match[9]) token.type = "number";else if (match[10]) token.type = "name";else if (match[11]) token.type = "punctuator";else if (match[12]) token.type = "whitespace";
|
8532 | return token;
|
8533 | };
|
8534 | });
|
8535 | unwrapExports(jsTokens);
|
8536 | var jsTokens_1 = jsTokens.matchToToken;
|
8537 |
|
8538 | var ast = createCommonjsModule(function (module) {
|
8539 | |
8540 |
|
8541 |
|
8542 |
|
8543 |
|
8544 |
|
8545 |
|
8546 |
|
8547 |
|
8548 |
|
8549 |
|
8550 |
|
8551 |
|
8552 |
|
8553 |
|
8554 |
|
8555 |
|
8556 |
|
8557 |
|
8558 |
|
8559 |
|
8560 |
|
8561 |
|
8562 | (function () {
|
8563 |
|
8564 | function isExpression(node) {
|
8565 | if (node == null) {
|
8566 | return false;
|
8567 | }
|
8568 |
|
8569 | switch (node.type) {
|
8570 | case 'ArrayExpression':
|
8571 | case 'AssignmentExpression':
|
8572 | case 'BinaryExpression':
|
8573 | case 'CallExpression':
|
8574 | case 'ConditionalExpression':
|
8575 | case 'FunctionExpression':
|
8576 | case 'Identifier':
|
8577 | case 'Literal':
|
8578 | case 'LogicalExpression':
|
8579 | case 'MemberExpression':
|
8580 | case 'NewExpression':
|
8581 | case 'ObjectExpression':
|
8582 | case 'SequenceExpression':
|
8583 | case 'ThisExpression':
|
8584 | case 'UnaryExpression':
|
8585 | case 'UpdateExpression':
|
8586 | return true;
|
8587 | }
|
8588 |
|
8589 | return false;
|
8590 | }
|
8591 |
|
8592 | function isIterationStatement(node) {
|
8593 | if (node == null) {
|
8594 | return false;
|
8595 | }
|
8596 |
|
8597 | switch (node.type) {
|
8598 | case 'DoWhileStatement':
|
8599 | case 'ForInStatement':
|
8600 | case 'ForStatement':
|
8601 | case 'WhileStatement':
|
8602 | return true;
|
8603 | }
|
8604 |
|
8605 | return false;
|
8606 | }
|
8607 |
|
8608 | function isStatement(node) {
|
8609 | if (node == null) {
|
8610 | return false;
|
8611 | }
|
8612 |
|
8613 | switch (node.type) {
|
8614 | case 'BlockStatement':
|
8615 | case 'BreakStatement':
|
8616 | case 'ContinueStatement':
|
8617 | case 'DebuggerStatement':
|
8618 | case 'DoWhileStatement':
|
8619 | case 'EmptyStatement':
|
8620 | case 'ExpressionStatement':
|
8621 | case 'ForInStatement':
|
8622 | case 'ForStatement':
|
8623 | case 'IfStatement':
|
8624 | case 'LabeledStatement':
|
8625 | case 'ReturnStatement':
|
8626 | case 'SwitchStatement':
|
8627 | case 'ThrowStatement':
|
8628 | case 'TryStatement':
|
8629 | case 'VariableDeclaration':
|
8630 | case 'WhileStatement':
|
8631 | case 'WithStatement':
|
8632 | return true;
|
8633 | }
|
8634 |
|
8635 | return false;
|
8636 | }
|
8637 |
|
8638 | function isSourceElement(node) {
|
8639 | return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
|
8640 | }
|
8641 |
|
8642 | function trailingStatement(node) {
|
8643 | switch (node.type) {
|
8644 | case 'IfStatement':
|
8645 | if (node.alternate != null) {
|
8646 | return node.alternate;
|
8647 | }
|
8648 |
|
8649 | return node.consequent;
|
8650 |
|
8651 | case 'LabeledStatement':
|
8652 | case 'ForStatement':
|
8653 | case 'ForInStatement':
|
8654 | case 'WhileStatement':
|
8655 | case 'WithStatement':
|
8656 | return node.body;
|
8657 | }
|
8658 |
|
8659 | return null;
|
8660 | }
|
8661 |
|
8662 | function isProblematicIfStatement(node) {
|
8663 | var current;
|
8664 |
|
8665 | if (node.type !== 'IfStatement') {
|
8666 | return false;
|
8667 | }
|
8668 |
|
8669 | if (node.alternate == null) {
|
8670 | return false;
|
8671 | }
|
8672 |
|
8673 | current = node.consequent;
|
8674 |
|
8675 | do {
|
8676 | if (current.type === 'IfStatement') {
|
8677 | if (current.alternate == null) {
|
8678 | return true;
|
8679 | }
|
8680 | }
|
8681 |
|
8682 | current = trailingStatement(current);
|
8683 | } while (current);
|
8684 |
|
8685 | return false;
|
8686 | }
|
8687 |
|
8688 | module.exports = {
|
8689 | isExpression: isExpression,
|
8690 | isStatement: isStatement,
|
8691 | isIterationStatement: isIterationStatement,
|
8692 | isSourceElement: isSourceElement,
|
8693 | isProblematicIfStatement: isProblematicIfStatement,
|
8694 | trailingStatement: trailingStatement
|
8695 | };
|
8696 | })();
|
8697 |
|
8698 |
|
8699 | });
|
8700 | var ast_1 = ast.isExpression;
|
8701 | var ast_2 = ast.isStatement;
|
8702 | var ast_3 = ast.isIterationStatement;
|
8703 | var ast_4 = ast.isSourceElement;
|
8704 | var ast_5 = ast.isProblematicIfStatement;
|
8705 | var ast_6 = ast.trailingStatement;
|
8706 |
|
8707 | var code = createCommonjsModule(function (module) {
|
8708 | |
8709 |
|
8710 |
|
8711 |
|
8712 |
|
8713 |
|
8714 |
|
8715 |
|
8716 |
|
8717 |
|
8718 |
|
8719 |
|
8720 |
|
8721 |
|
8722 |
|
8723 |
|
8724 |
|
8725 |
|
8726 |
|
8727 |
|
8728 |
|
8729 |
|
8730 |
|
8731 |
|
8732 | (function () {
|
8733 |
|
8734 | var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch;
|
8735 |
|
8736 | ES5Regex = {
|
8737 |
|
8738 | NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
|
8739 |
|
8740 | NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/
|
8741 | };
|
8742 | ES6Regex = {
|
8743 |
|
8744 | NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,
|
8745 |
|
8746 | NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
|
8747 | };
|
8748 |
|
8749 | function isDecimalDigit(ch) {
|
8750 | return 0x30 <= ch && ch <= 0x39;
|
8751 | }
|
8752 |
|
8753 | function isHexDigit(ch) {
|
8754 | return 0x30 <= ch && ch <= 0x39 ||
|
8755 | 0x61 <= ch && ch <= 0x66 ||
|
8756 | 0x41 <= ch && ch <= 0x46;
|
8757 | }
|
8758 |
|
8759 | function isOctalDigit(ch) {
|
8760 | return ch >= 0x30 && ch <= 0x37;
|
8761 | }
|
8762 |
|
8763 |
|
8764 | NON_ASCII_WHITESPACES = [0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF];
|
8765 |
|
8766 | function isWhiteSpace(ch) {
|
8767 | return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
|
8768 | }
|
8769 |
|
8770 |
|
8771 | function isLineTerminator(ch) {
|
8772 | return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
|
8773 | }
|
8774 |
|
8775 |
|
8776 | function fromCodePoint(cp) {
|
8777 | if (cp <= 0xFFFF) {
|
8778 | return String.fromCharCode(cp);
|
8779 | }
|
8780 |
|
8781 | var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
|
8782 | var cu2 = String.fromCharCode((cp - 0x10000) % 0x400 + 0xDC00);
|
8783 | return cu1 + cu2;
|
8784 | }
|
8785 |
|
8786 | IDENTIFIER_START = new Array(0x80);
|
8787 |
|
8788 | for (ch = 0; ch < 0x80; ++ch) {
|
8789 | IDENTIFIER_START[ch] = ch >= 0x61 && ch <= 0x7A ||
|
8790 | ch >= 0x41 && ch <= 0x5A ||
|
8791 | ch === 0x24 || ch === 0x5F;
|
8792 | }
|
8793 |
|
8794 | IDENTIFIER_PART = new Array(0x80);
|
8795 |
|
8796 | for (ch = 0; ch < 0x80; ++ch) {
|
8797 | IDENTIFIER_PART[ch] = ch >= 0x61 && ch <= 0x7A ||
|
8798 | ch >= 0x41 && ch <= 0x5A ||
|
8799 | ch >= 0x30 && ch <= 0x39 ||
|
8800 | ch === 0x24 || ch === 0x5F;
|
8801 | }
|
8802 |
|
8803 | function isIdentifierStartES5(ch) {
|
8804 | return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
|
8805 | }
|
8806 |
|
8807 | function isIdentifierPartES5(ch) {
|
8808 | return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
|
8809 | }
|
8810 |
|
8811 | function isIdentifierStartES6(ch) {
|
8812 | return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
|
8813 | }
|
8814 |
|
8815 | function isIdentifierPartES6(ch) {
|
8816 | return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
|
8817 | }
|
8818 |
|
8819 | module.exports = {
|
8820 | isDecimalDigit: isDecimalDigit,
|
8821 | isHexDigit: isHexDigit,
|
8822 | isOctalDigit: isOctalDigit,
|
8823 | isWhiteSpace: isWhiteSpace,
|
8824 | isLineTerminator: isLineTerminator,
|
8825 | isIdentifierStartES5: isIdentifierStartES5,
|
8826 | isIdentifierPartES5: isIdentifierPartES5,
|
8827 | isIdentifierStartES6: isIdentifierStartES6,
|
8828 | isIdentifierPartES6: isIdentifierPartES6
|
8829 | };
|
8830 | })();
|
8831 |
|
8832 |
|
8833 | });
|
8834 | var code_1 = code.isDecimalDigit;
|
8835 | var code_2 = code.isHexDigit;
|
8836 | var code_3 = code.isOctalDigit;
|
8837 | var code_4 = code.isWhiteSpace;
|
8838 | var code_5 = code.isLineTerminator;
|
8839 | var code_6 = code.isIdentifierStartES5;
|
8840 | var code_7 = code.isIdentifierPartES5;
|
8841 | var code_8 = code.isIdentifierStartES6;
|
8842 | var code_9 = code.isIdentifierPartES6;
|
8843 |
|
8844 | var keyword = createCommonjsModule(function (module) {
|
8845 | |
8846 |
|
8847 |
|
8848 |
|
8849 |
|
8850 |
|
8851 |
|
8852 |
|
8853 |
|
8854 |
|
8855 |
|
8856 |
|
8857 |
|
8858 |
|
8859 |
|
8860 |
|
8861 |
|
8862 |
|
8863 |
|
8864 |
|
8865 |
|
8866 |
|
8867 |
|
8868 | (function () {
|
8869 |
|
8870 | var code$1 = code;
|
8871 |
|
8872 | function isStrictModeReservedWordES6(id) {
|
8873 | switch (id) {
|
8874 | case 'implements':
|
8875 | case 'interface':
|
8876 | case 'package':
|
8877 | case 'private':
|
8878 | case 'protected':
|
8879 | case 'public':
|
8880 | case 'static':
|
8881 | case 'let':
|
8882 | return true;
|
8883 |
|
8884 | default:
|
8885 | return false;
|
8886 | }
|
8887 | }
|
8888 |
|
8889 | function isKeywordES5(id, strict) {
|
8890 |
|
8891 | if (!strict && id === 'yield') {
|
8892 | return false;
|
8893 | }
|
8894 |
|
8895 | return isKeywordES6(id, strict);
|
8896 | }
|
8897 |
|
8898 | function isKeywordES6(id, strict) {
|
8899 | if (strict && isStrictModeReservedWordES6(id)) {
|
8900 | return true;
|
8901 | }
|
8902 |
|
8903 | switch (id.length) {
|
8904 | case 2:
|
8905 | return id === 'if' || id === 'in' || id === 'do';
|
8906 |
|
8907 | case 3:
|
8908 | return id === 'var' || id === 'for' || id === 'new' || id === 'try';
|
8909 |
|
8910 | case 4:
|
8911 | return id === 'this' || id === 'else' || id === 'case' || id === 'void' || id === 'with' || id === 'enum';
|
8912 |
|
8913 | case 5:
|
8914 | return id === 'while' || id === 'break' || id === 'catch' || id === 'throw' || id === 'const' || id === 'yield' || id === 'class' || id === 'super';
|
8915 |
|
8916 | case 6:
|
8917 | return id === 'return' || id === 'typeof' || id === 'delete' || id === 'switch' || id === 'export' || id === 'import';
|
8918 |
|
8919 | case 7:
|
8920 | return id === 'default' || id === 'finally' || id === 'extends';
|
8921 |
|
8922 | case 8:
|
8923 | return id === 'function' || id === 'continue' || id === 'debugger';
|
8924 |
|
8925 | case 10:
|
8926 | return id === 'instanceof';
|
8927 |
|
8928 | default:
|
8929 | return false;
|
8930 | }
|
8931 | }
|
8932 |
|
8933 | function isReservedWordES5(id, strict) {
|
8934 | return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
|
8935 | }
|
8936 |
|
8937 | function isReservedWordES6(id, strict) {
|
8938 | return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
|
8939 | }
|
8940 |
|
8941 | function isRestrictedWord(id) {
|
8942 | return id === 'eval' || id === 'arguments';
|
8943 | }
|
8944 |
|
8945 | function isIdentifierNameES5(id) {
|
8946 | var i, iz, ch;
|
8947 |
|
8948 | if (id.length === 0) {
|
8949 | return false;
|
8950 | }
|
8951 |
|
8952 | ch = id.charCodeAt(0);
|
8953 |
|
8954 | if (!code$1.isIdentifierStartES5(ch)) {
|
8955 | return false;
|
8956 | }
|
8957 |
|
8958 | for (i = 1, iz = id.length; i < iz; ++i) {
|
8959 | ch = id.charCodeAt(i);
|
8960 |
|
8961 | if (!code$1.isIdentifierPartES5(ch)) {
|
8962 | return false;
|
8963 | }
|
8964 | }
|
8965 |
|
8966 | return true;
|
8967 | }
|
8968 |
|
8969 | function decodeUtf16(lead, trail) {
|
8970 | return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
|
8971 | }
|
8972 |
|
8973 | function isIdentifierNameES6(id) {
|
8974 | var i, iz, ch, lowCh, check;
|
8975 |
|
8976 | if (id.length === 0) {
|
8977 | return false;
|
8978 | }
|
8979 |
|
8980 | check = code$1.isIdentifierStartES6;
|
8981 |
|
8982 | for (i = 0, iz = id.length; i < iz; ++i) {
|
8983 | ch = id.charCodeAt(i);
|
8984 |
|
8985 | if (0xD800 <= ch && ch <= 0xDBFF) {
|
8986 | ++i;
|
8987 |
|
8988 | if (i >= iz) {
|
8989 | return false;
|
8990 | }
|
8991 |
|
8992 | lowCh = id.charCodeAt(i);
|
8993 |
|
8994 | if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
|
8995 | return false;
|
8996 | }
|
8997 |
|
8998 | ch = decodeUtf16(ch, lowCh);
|
8999 | }
|
9000 |
|
9001 | if (!check(ch)) {
|
9002 | return false;
|
9003 | }
|
9004 |
|
9005 | check = code$1.isIdentifierPartES6;
|
9006 | }
|
9007 |
|
9008 | return true;
|
9009 | }
|
9010 |
|
9011 | function isIdentifierES5(id, strict) {
|
9012 | return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
|
9013 | }
|
9014 |
|
9015 | function isIdentifierES6(id, strict) {
|
9016 | return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
|
9017 | }
|
9018 |
|
9019 | module.exports = {
|
9020 | isKeywordES5: isKeywordES5,
|
9021 | isKeywordES6: isKeywordES6,
|
9022 | isReservedWordES5: isReservedWordES5,
|
9023 | isReservedWordES6: isReservedWordES6,
|
9024 | isRestrictedWord: isRestrictedWord,
|
9025 | isIdentifierNameES5: isIdentifierNameES5,
|
9026 | isIdentifierNameES6: isIdentifierNameES6,
|
9027 | isIdentifierES5: isIdentifierES5,
|
9028 | isIdentifierES6: isIdentifierES6
|
9029 | };
|
9030 | })();
|
9031 |
|
9032 |
|
9033 | });
|
9034 | var keyword_1 = keyword.isKeywordES5;
|
9035 | var keyword_2 = keyword.isKeywordES6;
|
9036 | var keyword_3 = keyword.isReservedWordES5;
|
9037 | var keyword_4 = keyword.isReservedWordES6;
|
9038 | var keyword_5 = keyword.isRestrictedWord;
|
9039 | var keyword_6 = keyword.isIdentifierNameES5;
|
9040 | var keyword_7 = keyword.isIdentifierNameES6;
|
9041 | var keyword_8 = keyword.isIdentifierES5;
|
9042 | var keyword_9 = keyword.isIdentifierES6;
|
9043 |
|
9044 | var utils$1 = createCommonjsModule(function (module, exports) {
|
9045 | |
9046 |
|
9047 |
|
9048 |
|
9049 |
|
9050 |
|
9051 |
|
9052 |
|
9053 |
|
9054 |
|
9055 |
|
9056 |
|
9057 |
|
9058 |
|
9059 |
|
9060 |
|
9061 |
|
9062 |
|
9063 |
|
9064 |
|
9065 |
|
9066 |
|
9067 |
|
9068 | (function () {
|
9069 |
|
9070 | exports.ast = ast;
|
9071 | exports.code = code;
|
9072 | exports.keyword = keyword;
|
9073 | })();
|
9074 |
|
9075 |
|
9076 | });
|
9077 | var utils_1$1 = utils$1.ast;
|
9078 | var utils_2$1 = utils$1.code;
|
9079 | var utils_3$1 = utils$1.keyword;
|
9080 |
|
9081 | var matchOperatorsRe$1 = /[|\\{}()[\]^$+*?.]/g;
|
9082 |
|
9083 | var escapeStringRegexp$1 = function (str) {
|
9084 | if (typeof str !== 'string') {
|
9085 | throw new TypeError('Expected a string');
|
9086 | }
|
9087 |
|
9088 | return str.replace(matchOperatorsRe$1, '\\$&');
|
9089 | };
|
9090 |
|
9091 | var colorName$2 = {
|
9092 | "aliceblue": [240, 248, 255],
|
9093 | "antiquewhite": [250, 235, 215],
|
9094 | "aqua": [0, 255, 255],
|
9095 | "aquamarine": [127, 255, 212],
|
9096 | "azure": [240, 255, 255],
|
9097 | "beige": [245, 245, 220],
|
9098 | "bisque": [255, 228, 196],
|
9099 | "black": [0, 0, 0],
|
9100 | "blanchedalmond": [255, 235, 205],
|
9101 | "blue": [0, 0, 255],
|
9102 | "blueviolet": [138, 43, 226],
|
9103 | "brown": [165, 42, 42],
|
9104 | "burlywood": [222, 184, 135],
|
9105 | "cadetblue": [95, 158, 160],
|
9106 | "chartreuse": [127, 255, 0],
|
9107 | "chocolate": [210, 105, 30],
|
9108 | "coral": [255, 127, 80],
|
9109 | "cornflowerblue": [100, 149, 237],
|
9110 | "cornsilk": [255, 248, 220],
|
9111 | "crimson": [220, 20, 60],
|
9112 | "cyan": [0, 255, 255],
|
9113 | "darkblue": [0, 0, 139],
|
9114 | "darkcyan": [0, 139, 139],
|
9115 | "darkgoldenrod": [184, 134, 11],
|
9116 | "darkgray": [169, 169, 169],
|
9117 | "darkgreen": [0, 100, 0],
|
9118 | "darkgrey": [169, 169, 169],
|
9119 | "darkkhaki": [189, 183, 107],
|
9120 | "darkmagenta": [139, 0, 139],
|
9121 | "darkolivegreen": [85, 107, 47],
|
9122 | "darkorange": [255, 140, 0],
|
9123 | "darkorchid": [153, 50, 204],
|
9124 | "darkred": [139, 0, 0],
|
9125 | "darksalmon": [233, 150, 122],
|
9126 | "darkseagreen": [143, 188, 143],
|
9127 | "darkslateblue": [72, 61, 139],
|
9128 | "darkslategray": [47, 79, 79],
|
9129 | "darkslategrey": [47, 79, 79],
|
9130 | "darkturquoise": [0, 206, 209],
|
9131 | "darkviolet": [148, 0, 211],
|
9132 | "deeppink": [255, 20, 147],
|
9133 | "deepskyblue": [0, 191, 255],
|
9134 | "dimgray": [105, 105, 105],
|
9135 | "dimgrey": [105, 105, 105],
|
9136 | "dodgerblue": [30, 144, 255],
|
9137 | "firebrick": [178, 34, 34],
|
9138 | "floralwhite": [255, 250, 240],
|
9139 | "forestgreen": [34, 139, 34],
|
9140 | "fuchsia": [255, 0, 255],
|
9141 | "gainsboro": [220, 220, 220],
|
9142 | "ghostwhite": [248, 248, 255],
|
9143 | "gold": [255, 215, 0],
|
9144 | "goldenrod": [218, 165, 32],
|
9145 | "gray": [128, 128, 128],
|
9146 | "green": [0, 128, 0],
|
9147 | "greenyellow": [173, 255, 47],
|
9148 | "grey": [128, 128, 128],
|
9149 | "honeydew": [240, 255, 240],
|
9150 | "hotpink": [255, 105, 180],
|
9151 | "indianred": [205, 92, 92],
|
9152 | "indigo": [75, 0, 130],
|
9153 | "ivory": [255, 255, 240],
|
9154 | "khaki": [240, 230, 140],
|
9155 | "lavender": [230, 230, 250],
|
9156 | "lavenderblush": [255, 240, 245],
|
9157 | "lawngreen": [124, 252, 0],
|
9158 | "lemonchiffon": [255, 250, 205],
|
9159 | "lightblue": [173, 216, 230],
|
9160 | "lightcoral": [240, 128, 128],
|
9161 | "lightcyan": [224, 255, 255],
|
9162 | "lightgoldenrodyellow": [250, 250, 210],
|
9163 | "lightgray": [211, 211, 211],
|
9164 | "lightgreen": [144, 238, 144],
|
9165 | "lightgrey": [211, 211, 211],
|
9166 | "lightpink": [255, 182, 193],
|
9167 | "lightsalmon": [255, 160, 122],
|
9168 | "lightseagreen": [32, 178, 170],
|
9169 | "lightskyblue": [135, 206, 250],
|
9170 | "lightslategray": [119, 136, 153],
|
9171 | "lightslategrey": [119, 136, 153],
|
9172 | "lightsteelblue": [176, 196, 222],
|
9173 | "lightyellow": [255, 255, 224],
|
9174 | "lime": [0, 255, 0],
|
9175 | "limegreen": [50, 205, 50],
|
9176 | "linen": [250, 240, 230],
|
9177 | "magenta": [255, 0, 255],
|
9178 | "maroon": [128, 0, 0],
|
9179 | "mediumaquamarine": [102, 205, 170],
|
9180 | "mediumblue": [0, 0, 205],
|
9181 | "mediumorchid": [186, 85, 211],
|
9182 | "mediumpurple": [147, 112, 219],
|
9183 | "mediumseagreen": [60, 179, 113],
|
9184 | "mediumslateblue": [123, 104, 238],
|
9185 | "mediumspringgreen": [0, 250, 154],
|
9186 | "mediumturquoise": [72, 209, 204],
|
9187 | "mediumvioletred": [199, 21, 133],
|
9188 | "midnightblue": [25, 25, 112],
|
9189 | "mintcream": [245, 255, 250],
|
9190 | "mistyrose": [255, 228, 225],
|
9191 | "moccasin": [255, 228, 181],
|
9192 | "navajowhite": [255, 222, 173],
|
9193 | "navy": [0, 0, 128],
|
9194 | "oldlace": [253, 245, 230],
|
9195 | "olive": [128, 128, 0],
|
9196 | "olivedrab": [107, 142, 35],
|
9197 | "orange": [255, 165, 0],
|
9198 | "orangered": [255, 69, 0],
|
9199 | "orchid": [218, 112, 214],
|
9200 | "palegoldenrod": [238, 232, 170],
|
9201 | "palegreen": [152, 251, 152],
|
9202 | "paleturquoise": [175, 238, 238],
|
9203 | "palevioletred": [219, 112, 147],
|
9204 | "papayawhip": [255, 239, 213],
|
9205 | "peachpuff": [255, 218, 185],
|
9206 | "peru": [205, 133, 63],
|
9207 | "pink": [255, 192, 203],
|
9208 | "plum": [221, 160, 221],
|
9209 | "powderblue": [176, 224, 230],
|
9210 | "purple": [128, 0, 128],
|
9211 | "rebeccapurple": [102, 51, 153],
|
9212 | "red": [255, 0, 0],
|
9213 | "rosybrown": [188, 143, 143],
|
9214 | "royalblue": [65, 105, 225],
|
9215 | "saddlebrown": [139, 69, 19],
|
9216 | "salmon": [250, 128, 114],
|
9217 | "sandybrown": [244, 164, 96],
|
9218 | "seagreen": [46, 139, 87],
|
9219 | "seashell": [255, 245, 238],
|
9220 | "sienna": [160, 82, 45],
|
9221 | "silver": [192, 192, 192],
|
9222 | "skyblue": [135, 206, 235],
|
9223 | "slateblue": [106, 90, 205],
|
9224 | "slategray": [112, 128, 144],
|
9225 | "slategrey": [112, 128, 144],
|
9226 | "snow": [255, 250, 250],
|
9227 | "springgreen": [0, 255, 127],
|
9228 | "steelblue": [70, 130, 180],
|
9229 | "tan": [210, 180, 140],
|
9230 | "teal": [0, 128, 128],
|
9231 | "thistle": [216, 191, 216],
|
9232 | "tomato": [255, 99, 71],
|
9233 | "turquoise": [64, 224, 208],
|
9234 | "violet": [238, 130, 238],
|
9235 | "wheat": [245, 222, 179],
|
9236 | "white": [255, 255, 255],
|
9237 | "whitesmoke": [245, 245, 245],
|
9238 | "yellow": [255, 255, 0],
|
9239 | "yellowgreen": [154, 205, 50]
|
9240 | };
|
9241 |
|
9242 | var conversions$2 = createCommonjsModule(function (module) {
|
9243 |
|
9244 |
|
9245 |
|
9246 |
|
9247 | var reverseKeywords = {};
|
9248 |
|
9249 | for (var key in colorName$2) {
|
9250 | if (colorName$2.hasOwnProperty(key)) {
|
9251 | reverseKeywords[colorName$2[key]] = key;
|
9252 | }
|
9253 | }
|
9254 |
|
9255 | var convert = module.exports = {
|
9256 | rgb: {
|
9257 | channels: 3,
|
9258 | labels: 'rgb'
|
9259 | },
|
9260 | hsl: {
|
9261 | channels: 3,
|
9262 | labels: 'hsl'
|
9263 | },
|
9264 | hsv: {
|
9265 | channels: 3,
|
9266 | labels: 'hsv'
|
9267 | },
|
9268 | hwb: {
|
9269 | channels: 3,
|
9270 | labels: 'hwb'
|
9271 | },
|
9272 | cmyk: {
|
9273 | channels: 4,
|
9274 | labels: 'cmyk'
|
9275 | },
|
9276 | xyz: {
|
9277 | channels: 3,
|
9278 | labels: 'xyz'
|
9279 | },
|
9280 | lab: {
|
9281 | channels: 3,
|
9282 | labels: 'lab'
|
9283 | },
|
9284 | lch: {
|
9285 | channels: 3,
|
9286 | labels: 'lch'
|
9287 | },
|
9288 | hex: {
|
9289 | channels: 1,
|
9290 | labels: ['hex']
|
9291 | },
|
9292 | keyword: {
|
9293 | channels: 1,
|
9294 | labels: ['keyword']
|
9295 | },
|
9296 | ansi16: {
|
9297 | channels: 1,
|
9298 | labels: ['ansi16']
|
9299 | },
|
9300 | ansi256: {
|
9301 | channels: 1,
|
9302 | labels: ['ansi256']
|
9303 | },
|
9304 | hcg: {
|
9305 | channels: 3,
|
9306 | labels: ['h', 'c', 'g']
|
9307 | },
|
9308 | apple: {
|
9309 | channels: 3,
|
9310 | labels: ['r16', 'g16', 'b16']
|
9311 | },
|
9312 | gray: {
|
9313 | channels: 1,
|
9314 | labels: ['gray']
|
9315 | }
|
9316 | };
|
9317 |
|
9318 | for (var model in convert) {
|
9319 | if (convert.hasOwnProperty(model)) {
|
9320 | if (!('channels' in convert[model])) {
|
9321 | throw new Error('missing channels property: ' + model);
|
9322 | }
|
9323 |
|
9324 | if (!('labels' in convert[model])) {
|
9325 | throw new Error('missing channel labels property: ' + model);
|
9326 | }
|
9327 |
|
9328 | if (convert[model].labels.length !== convert[model].channels) {
|
9329 | throw new Error('channel and label counts mismatch: ' + model);
|
9330 | }
|
9331 |
|
9332 | var channels = convert[model].channels;
|
9333 | var labels = convert[model].labels;
|
9334 | delete convert[model].channels;
|
9335 | delete convert[model].labels;
|
9336 | Object.defineProperty(convert[model], 'channels', {
|
9337 | value: channels
|
9338 | });
|
9339 | Object.defineProperty(convert[model], 'labels', {
|
9340 | value: labels
|
9341 | });
|
9342 | }
|
9343 | }
|
9344 |
|
9345 | convert.rgb.hsl = function (rgb) {
|
9346 | var r = rgb[0] / 255;
|
9347 | var g = rgb[1] / 255;
|
9348 | var b = rgb[2] / 255;
|
9349 | var min = Math.min(r, g, b);
|
9350 | var max = Math.max(r, g, b);
|
9351 | var delta = max - min;
|
9352 | var h;
|
9353 | var s;
|
9354 | var l;
|
9355 |
|
9356 | if (max === min) {
|
9357 | h = 0;
|
9358 | } else if (r === max) {
|
9359 | h = (g - b) / delta;
|
9360 | } else if (g === max) {
|
9361 | h = 2 + (b - r) / delta;
|
9362 | } else if (b === max) {
|
9363 | h = 4 + (r - g) / delta;
|
9364 | }
|
9365 |
|
9366 | h = Math.min(h * 60, 360);
|
9367 |
|
9368 | if (h < 0) {
|
9369 | h += 360;
|
9370 | }
|
9371 |
|
9372 | l = (min + max) / 2;
|
9373 |
|
9374 | if (max === min) {
|
9375 | s = 0;
|
9376 | } else if (l <= 0.5) {
|
9377 | s = delta / (max + min);
|
9378 | } else {
|
9379 | s = delta / (2 - max - min);
|
9380 | }
|
9381 |
|
9382 | return [h, s * 100, l * 100];
|
9383 | };
|
9384 |
|
9385 | convert.rgb.hsv = function (rgb) {
|
9386 | var rdif;
|
9387 | var gdif;
|
9388 | var bdif;
|
9389 | var h;
|
9390 | var s;
|
9391 | var r = rgb[0] / 255;
|
9392 | var g = rgb[1] / 255;
|
9393 | var b = rgb[2] / 255;
|
9394 | var v = Math.max(r, g, b);
|
9395 | var diff = v - Math.min(r, g, b);
|
9396 |
|
9397 | var diffc = function (c) {
|
9398 | return (v - c) / 6 / diff + 1 / 2;
|
9399 | };
|
9400 |
|
9401 | if (diff === 0) {
|
9402 | h = s = 0;
|
9403 | } else {
|
9404 | s = diff / v;
|
9405 | rdif = diffc(r);
|
9406 | gdif = diffc(g);
|
9407 | bdif = diffc(b);
|
9408 |
|
9409 | if (r === v) {
|
9410 | h = bdif - gdif;
|
9411 | } else if (g === v) {
|
9412 | h = 1 / 3 + rdif - bdif;
|
9413 | } else if (b === v) {
|
9414 | h = 2 / 3 + gdif - rdif;
|
9415 | }
|
9416 |
|
9417 | if (h < 0) {
|
9418 | h += 1;
|
9419 | } else if (h > 1) {
|
9420 | h -= 1;
|
9421 | }
|
9422 | }
|
9423 |
|
9424 | return [h * 360, s * 100, v * 100];
|
9425 | };
|
9426 |
|
9427 | convert.rgb.hwb = function (rgb) {
|
9428 | var r = rgb[0];
|
9429 | var g = rgb[1];
|
9430 | var b = rgb[2];
|
9431 | var h = convert.rgb.hsl(rgb)[0];
|
9432 | var w = 1 / 255 * Math.min(r, Math.min(g, b));
|
9433 | b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
9434 | return [h, w * 100, b * 100];
|
9435 | };
|
9436 |
|
9437 | convert.rgb.cmyk = function (rgb) {
|
9438 | var r = rgb[0] / 255;
|
9439 | var g = rgb[1] / 255;
|
9440 | var b = rgb[2] / 255;
|
9441 | var c;
|
9442 | var m;
|
9443 | var y;
|
9444 | var k;
|
9445 | k = Math.min(1 - r, 1 - g, 1 - b);
|
9446 | c = (1 - r - k) / (1 - k) || 0;
|
9447 | m = (1 - g - k) / (1 - k) || 0;
|
9448 | y = (1 - b - k) / (1 - k) || 0;
|
9449 | return [c * 100, m * 100, y * 100, k * 100];
|
9450 | };
|
9451 | |
9452 |
|
9453 |
|
9454 |
|
9455 |
|
9456 | function comparativeDistance(x, y) {
|
9457 | return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
|
9458 | }
|
9459 |
|
9460 | convert.rgb.keyword = function (rgb) {
|
9461 | var reversed = reverseKeywords[rgb];
|
9462 |
|
9463 | if (reversed) {
|
9464 | return reversed;
|
9465 | }
|
9466 |
|
9467 | var currentClosestDistance = Infinity;
|
9468 | var currentClosestKeyword;
|
9469 |
|
9470 | for (var keyword in colorName$2) {
|
9471 | if (colorName$2.hasOwnProperty(keyword)) {
|
9472 | var value = colorName$2[keyword];
|
9473 |
|
9474 | var distance = comparativeDistance(rgb, value);
|
9475 |
|
9476 | if (distance < currentClosestDistance) {
|
9477 | currentClosestDistance = distance;
|
9478 | currentClosestKeyword = keyword;
|
9479 | }
|
9480 | }
|
9481 | }
|
9482 |
|
9483 | return currentClosestKeyword;
|
9484 | };
|
9485 |
|
9486 | convert.keyword.rgb = function (keyword) {
|
9487 | return colorName$2[keyword];
|
9488 | };
|
9489 |
|
9490 | convert.rgb.xyz = function (rgb) {
|
9491 | var r = rgb[0] / 255;
|
9492 | var g = rgb[1] / 255;
|
9493 | var b = rgb[2] / 255;
|
9494 |
|
9495 | r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
|
9496 | g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
|
9497 | b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
|
9498 | var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
9499 | var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
9500 | var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
9501 | return [x * 100, y * 100, z * 100];
|
9502 | };
|
9503 |
|
9504 | convert.rgb.lab = function (rgb) {
|
9505 | var xyz = convert.rgb.xyz(rgb);
|
9506 | var x = xyz[0];
|
9507 | var y = xyz[1];
|
9508 | var z = xyz[2];
|
9509 | var l;
|
9510 | var a;
|
9511 | var b;
|
9512 | x /= 95.047;
|
9513 | y /= 100;
|
9514 | z /= 108.883;
|
9515 | x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
|
9516 | y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
|
9517 | z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
|
9518 | l = 116 * y - 16;
|
9519 | a = 500 * (x - y);
|
9520 | b = 200 * (y - z);
|
9521 | return [l, a, b];
|
9522 | };
|
9523 |
|
9524 | convert.hsl.rgb = function (hsl) {
|
9525 | var h = hsl[0] / 360;
|
9526 | var s = hsl[1] / 100;
|
9527 | var l = hsl[2] / 100;
|
9528 | var t1;
|
9529 | var t2;
|
9530 | var t3;
|
9531 | var rgb;
|
9532 | var val;
|
9533 |
|
9534 | if (s === 0) {
|
9535 | val = l * 255;
|
9536 | return [val, val, val];
|
9537 | }
|
9538 |
|
9539 | if (l < 0.5) {
|
9540 | t2 = l * (1 + s);
|
9541 | } else {
|
9542 | t2 = l + s - l * s;
|
9543 | }
|
9544 |
|
9545 | t1 = 2 * l - t2;
|
9546 | rgb = [0, 0, 0];
|
9547 |
|
9548 | for (var i = 0; i < 3; i++) {
|
9549 | t3 = h + 1 / 3 * -(i - 1);
|
9550 |
|
9551 | if (t3 < 0) {
|
9552 | t3++;
|
9553 | }
|
9554 |
|
9555 | if (t3 > 1) {
|
9556 | t3--;
|
9557 | }
|
9558 |
|
9559 | if (6 * t3 < 1) {
|
9560 | val = t1 + (t2 - t1) * 6 * t3;
|
9561 | } else if (2 * t3 < 1) {
|
9562 | val = t2;
|
9563 | } else if (3 * t3 < 2) {
|
9564 | val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
9565 | } else {
|
9566 | val = t1;
|
9567 | }
|
9568 |
|
9569 | rgb[i] = val * 255;
|
9570 | }
|
9571 |
|
9572 | return rgb;
|
9573 | };
|
9574 |
|
9575 | convert.hsl.hsv = function (hsl) {
|
9576 | var h = hsl[0];
|
9577 | var s = hsl[1] / 100;
|
9578 | var l = hsl[2] / 100;
|
9579 | var smin = s;
|
9580 | var lmin = Math.max(l, 0.01);
|
9581 | var sv;
|
9582 | var v;
|
9583 | l *= 2;
|
9584 | s *= l <= 1 ? l : 2 - l;
|
9585 | smin *= lmin <= 1 ? lmin : 2 - lmin;
|
9586 | v = (l + s) / 2;
|
9587 | sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
9588 | return [h, sv * 100, v * 100];
|
9589 | };
|
9590 |
|
9591 | convert.hsv.rgb = function (hsv) {
|
9592 | var h = hsv[0] / 60;
|
9593 | var s = hsv[1] / 100;
|
9594 | var v = hsv[2] / 100;
|
9595 | var hi = Math.floor(h) % 6;
|
9596 | var f = h - Math.floor(h);
|
9597 | var p = 255 * v * (1 - s);
|
9598 | var q = 255 * v * (1 - s * f);
|
9599 | var t = 255 * v * (1 - s * (1 - f));
|
9600 | v *= 255;
|
9601 |
|
9602 | switch (hi) {
|
9603 | case 0:
|
9604 | return [v, t, p];
|
9605 |
|
9606 | case 1:
|
9607 | return [q, v, p];
|
9608 |
|
9609 | case 2:
|
9610 | return [p, v, t];
|
9611 |
|
9612 | case 3:
|
9613 | return [p, q, v];
|
9614 |
|
9615 | case 4:
|
9616 | return [t, p, v];
|
9617 |
|
9618 | case 5:
|
9619 | return [v, p, q];
|
9620 | }
|
9621 | };
|
9622 |
|
9623 | convert.hsv.hsl = function (hsv) {
|
9624 | var h = hsv[0];
|
9625 | var s = hsv[1] / 100;
|
9626 | var v = hsv[2] / 100;
|
9627 | var vmin = Math.max(v, 0.01);
|
9628 | var lmin;
|
9629 | var sl;
|
9630 | var l;
|
9631 | l = (2 - s) * v;
|
9632 | lmin = (2 - s) * vmin;
|
9633 | sl = s * vmin;
|
9634 | sl /= lmin <= 1 ? lmin : 2 - lmin;
|
9635 | sl = sl || 0;
|
9636 | l /= 2;
|
9637 | return [h, sl * 100, l * 100];
|
9638 | };
|
9639 |
|
9640 |
|
9641 | convert.hwb.rgb = function (hwb) {
|
9642 | var h = hwb[0] / 360;
|
9643 | var wh = hwb[1] / 100;
|
9644 | var bl = hwb[2] / 100;
|
9645 | var ratio = wh + bl;
|
9646 | var i;
|
9647 | var v;
|
9648 | var f;
|
9649 | var n;
|
9650 |
|
9651 | if (ratio > 1) {
|
9652 | wh /= ratio;
|
9653 | bl /= ratio;
|
9654 | }
|
9655 |
|
9656 | i = Math.floor(6 * h);
|
9657 | v = 1 - bl;
|
9658 | f = 6 * h - i;
|
9659 |
|
9660 | if ((i & 0x01) !== 0) {
|
9661 | f = 1 - f;
|
9662 | }
|
9663 |
|
9664 | n = wh + f * (v - wh);
|
9665 |
|
9666 | var r;
|
9667 | var g;
|
9668 | var b;
|
9669 |
|
9670 | switch (i) {
|
9671 | default:
|
9672 | case 6:
|
9673 | case 0:
|
9674 | r = v;
|
9675 | g = n;
|
9676 | b = wh;
|
9677 | break;
|
9678 |
|
9679 | case 1:
|
9680 | r = n;
|
9681 | g = v;
|
9682 | b = wh;
|
9683 | break;
|
9684 |
|
9685 | case 2:
|
9686 | r = wh;
|
9687 | g = v;
|
9688 | b = n;
|
9689 | break;
|
9690 |
|
9691 | case 3:
|
9692 | r = wh;
|
9693 | g = n;
|
9694 | b = v;
|
9695 | break;
|
9696 |
|
9697 | case 4:
|
9698 | r = n;
|
9699 | g = wh;
|
9700 | b = v;
|
9701 | break;
|
9702 |
|
9703 | case 5:
|
9704 | r = v;
|
9705 | g = wh;
|
9706 | b = n;
|
9707 | break;
|
9708 | }
|
9709 |
|
9710 | return [r * 255, g * 255, b * 255];
|
9711 | };
|
9712 |
|
9713 | convert.cmyk.rgb = function (cmyk) {
|
9714 | var c = cmyk[0] / 100;
|
9715 | var m = cmyk[1] / 100;
|
9716 | var y = cmyk[2] / 100;
|
9717 | var k = cmyk[3] / 100;
|
9718 | var r;
|
9719 | var g;
|
9720 | var b;
|
9721 | r = 1 - Math.min(1, c * (1 - k) + k);
|
9722 | g = 1 - Math.min(1, m * (1 - k) + k);
|
9723 | b = 1 - Math.min(1, y * (1 - k) + k);
|
9724 | return [r * 255, g * 255, b * 255];
|
9725 | };
|
9726 |
|
9727 | convert.xyz.rgb = function (xyz) {
|
9728 | var x = xyz[0] / 100;
|
9729 | var y = xyz[1] / 100;
|
9730 | var z = xyz[2] / 100;
|
9731 | var r;
|
9732 | var g;
|
9733 | var b;
|
9734 | r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
9735 | g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
9736 | b = x * 0.0557 + y * -0.2040 + z * 1.0570;
|
9737 |
|
9738 | r = r > 0.0031308 ? 1.055 * Math.pow(r, 1.0 / 2.4) - 0.055 : r * 12.92;
|
9739 | g = g > 0.0031308 ? 1.055 * Math.pow(g, 1.0 / 2.4) - 0.055 : g * 12.92;
|
9740 | b = b > 0.0031308 ? 1.055 * Math.pow(b, 1.0 / 2.4) - 0.055 : b * 12.92;
|
9741 | r = Math.min(Math.max(0, r), 1);
|
9742 | g = Math.min(Math.max(0, g), 1);
|
9743 | b = Math.min(Math.max(0, b), 1);
|
9744 | return [r * 255, g * 255, b * 255];
|
9745 | };
|
9746 |
|
9747 | convert.xyz.lab = function (xyz) {
|
9748 | var x = xyz[0];
|
9749 | var y = xyz[1];
|
9750 | var z = xyz[2];
|
9751 | var l;
|
9752 | var a;
|
9753 | var b;
|
9754 | x /= 95.047;
|
9755 | y /= 100;
|
9756 | z /= 108.883;
|
9757 | x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
|
9758 | y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
|
9759 | z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
|
9760 | l = 116 * y - 16;
|
9761 | a = 500 * (x - y);
|
9762 | b = 200 * (y - z);
|
9763 | return [l, a, b];
|
9764 | };
|
9765 |
|
9766 | convert.lab.xyz = function (lab) {
|
9767 | var l = lab[0];
|
9768 | var a = lab[1];
|
9769 | var b = lab[2];
|
9770 | var x;
|
9771 | var y;
|
9772 | var z;
|
9773 | y = (l + 16) / 116;
|
9774 | x = a / 500 + y;
|
9775 | z = y - b / 200;
|
9776 | var y2 = Math.pow(y, 3);
|
9777 | var x2 = Math.pow(x, 3);
|
9778 | var z2 = Math.pow(z, 3);
|
9779 | y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
|
9780 | x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
|
9781 | z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
|
9782 | x *= 95.047;
|
9783 | y *= 100;
|
9784 | z *= 108.883;
|
9785 | return [x, y, z];
|
9786 | };
|
9787 |
|
9788 | convert.lab.lch = function (lab) {
|
9789 | var l = lab[0];
|
9790 | var a = lab[1];
|
9791 | var b = lab[2];
|
9792 | var hr;
|
9793 | var h;
|
9794 | var c;
|
9795 | hr = Math.atan2(b, a);
|
9796 | h = hr * 360 / 2 / Math.PI;
|
9797 |
|
9798 | if (h < 0) {
|
9799 | h += 360;
|
9800 | }
|
9801 |
|
9802 | c = Math.sqrt(a * a + b * b);
|
9803 | return [l, c, h];
|
9804 | };
|
9805 |
|
9806 | convert.lch.lab = function (lch) {
|
9807 | var l = lch[0];
|
9808 | var c = lch[1];
|
9809 | var h = lch[2];
|
9810 | var a;
|
9811 | var b;
|
9812 | var hr;
|
9813 | hr = h / 360 * 2 * Math.PI;
|
9814 | a = c * Math.cos(hr);
|
9815 | b = c * Math.sin(hr);
|
9816 | return [l, a, b];
|
9817 | };
|
9818 |
|
9819 | convert.rgb.ansi16 = function (args) {
|
9820 | var r = args[0];
|
9821 | var g = args[1];
|
9822 | var b = args[2];
|
9823 | var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2];
|
9824 |
|
9825 | value = Math.round(value / 50);
|
9826 |
|
9827 | if (value === 0) {
|
9828 | return 30;
|
9829 | }
|
9830 |
|
9831 | var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
9832 |
|
9833 | if (value === 2) {
|
9834 | ansi += 60;
|
9835 | }
|
9836 |
|
9837 | return ansi;
|
9838 | };
|
9839 |
|
9840 | convert.hsv.ansi16 = function (args) {
|
9841 |
|
9842 |
|
9843 | return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
9844 | };
|
9845 |
|
9846 | convert.rgb.ansi256 = function (args) {
|
9847 | var r = args[0];
|
9848 | var g = args[1];
|
9849 | var b = args[2];
|
9850 |
|
9851 |
|
9852 | if (r === g && g === b) {
|
9853 | if (r < 8) {
|
9854 | return 16;
|
9855 | }
|
9856 |
|
9857 | if (r > 248) {
|
9858 | return 231;
|
9859 | }
|
9860 |
|
9861 | return Math.round((r - 8) / 247 * 24) + 232;
|
9862 | }
|
9863 |
|
9864 | var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
9865 | return ansi;
|
9866 | };
|
9867 |
|
9868 | convert.ansi16.rgb = function (args) {
|
9869 | var color = args % 10;
|
9870 |
|
9871 | if (color === 0 || color === 7) {
|
9872 | if (args > 50) {
|
9873 | color += 3.5;
|
9874 | }
|
9875 |
|
9876 | color = color / 10.5 * 255;
|
9877 | return [color, color, color];
|
9878 | }
|
9879 |
|
9880 | var mult = (~~(args > 50) + 1) * 0.5;
|
9881 | var r = (color & 1) * mult * 255;
|
9882 | var g = (color >> 1 & 1) * mult * 255;
|
9883 | var b = (color >> 2 & 1) * mult * 255;
|
9884 | return [r, g, b];
|
9885 | };
|
9886 |
|
9887 | convert.ansi256.rgb = function (args) {
|
9888 |
|
9889 | if (args >= 232) {
|
9890 | var c = (args - 232) * 10 + 8;
|
9891 | return [c, c, c];
|
9892 | }
|
9893 |
|
9894 | args -= 16;
|
9895 | var rem;
|
9896 | var r = Math.floor(args / 36) / 5 * 255;
|
9897 | var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
9898 | var b = rem % 6 / 5 * 255;
|
9899 | return [r, g, b];
|
9900 | };
|
9901 |
|
9902 | convert.rgb.hex = function (args) {
|
9903 | var integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
|
9904 | var string = integer.toString(16).toUpperCase();
|
9905 | return '000000'.substring(string.length) + string;
|
9906 | };
|
9907 |
|
9908 | convert.hex.rgb = function (args) {
|
9909 | var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
9910 |
|
9911 | if (!match) {
|
9912 | return [0, 0, 0];
|
9913 | }
|
9914 |
|
9915 | var colorString = match[0];
|
9916 |
|
9917 | if (match[0].length === 3) {
|
9918 | colorString = colorString.split('').map(function (char) {
|
9919 | return char + char;
|
9920 | }).join('');
|
9921 | }
|
9922 |
|
9923 | var integer = parseInt(colorString, 16);
|
9924 | var r = integer >> 16 & 0xFF;
|
9925 | var g = integer >> 8 & 0xFF;
|
9926 | var b = integer & 0xFF;
|
9927 | return [r, g, b];
|
9928 | };
|
9929 |
|
9930 | convert.rgb.hcg = function (rgb) {
|
9931 | var r = rgb[0] / 255;
|
9932 | var g = rgb[1] / 255;
|
9933 | var b = rgb[2] / 255;
|
9934 | var max = Math.max(Math.max(r, g), b);
|
9935 | var min = Math.min(Math.min(r, g), b);
|
9936 | var chroma = max - min;
|
9937 | var grayscale;
|
9938 | var hue;
|
9939 |
|
9940 | if (chroma < 1) {
|
9941 | grayscale = min / (1 - chroma);
|
9942 | } else {
|
9943 | grayscale = 0;
|
9944 | }
|
9945 |
|
9946 | if (chroma <= 0) {
|
9947 | hue = 0;
|
9948 | } else if (max === r) {
|
9949 | hue = (g - b) / chroma % 6;
|
9950 | } else if (max === g) {
|
9951 | hue = 2 + (b - r) / chroma;
|
9952 | } else {
|
9953 | hue = 4 + (r - g) / chroma + 4;
|
9954 | }
|
9955 |
|
9956 | hue /= 6;
|
9957 | hue %= 1;
|
9958 | return [hue * 360, chroma * 100, grayscale * 100];
|
9959 | };
|
9960 |
|
9961 | convert.hsl.hcg = function (hsl) {
|
9962 | var s = hsl[1] / 100;
|
9963 | var l = hsl[2] / 100;
|
9964 | var c = 1;
|
9965 | var f = 0;
|
9966 |
|
9967 | if (l < 0.5) {
|
9968 | c = 2.0 * s * l;
|
9969 | } else {
|
9970 | c = 2.0 * s * (1.0 - l);
|
9971 | }
|
9972 |
|
9973 | if (c < 1.0) {
|
9974 | f = (l - 0.5 * c) / (1.0 - c);
|
9975 | }
|
9976 |
|
9977 | return [hsl[0], c * 100, f * 100];
|
9978 | };
|
9979 |
|
9980 | convert.hsv.hcg = function (hsv) {
|
9981 | var s = hsv[1] / 100;
|
9982 | var v = hsv[2] / 100;
|
9983 | var c = s * v;
|
9984 | var f = 0;
|
9985 |
|
9986 | if (c < 1.0) {
|
9987 | f = (v - c) / (1 - c);
|
9988 | }
|
9989 |
|
9990 | return [hsv[0], c * 100, f * 100];
|
9991 | };
|
9992 |
|
9993 | convert.hcg.rgb = function (hcg) {
|
9994 | var h = hcg[0] / 360;
|
9995 | var c = hcg[1] / 100;
|
9996 | var g = hcg[2] / 100;
|
9997 |
|
9998 | if (c === 0.0) {
|
9999 | return [g * 255, g * 255, g * 255];
|
10000 | }
|
10001 |
|
10002 | var pure = [0, 0, 0];
|
10003 | var hi = h % 1 * 6;
|
10004 | var v = hi % 1;
|
10005 | var w = 1 - v;
|
10006 | var mg = 0;
|
10007 |
|
10008 | switch (Math.floor(hi)) {
|
10009 | case 0:
|
10010 | pure[0] = 1;
|
10011 | pure[1] = v;
|
10012 | pure[2] = 0;
|
10013 | break;
|
10014 |
|
10015 | case 1:
|
10016 | pure[0] = w;
|
10017 | pure[1] = 1;
|
10018 | pure[2] = 0;
|
10019 | break;
|
10020 |
|
10021 | case 2:
|
10022 | pure[0] = 0;
|
10023 | pure[1] = 1;
|
10024 | pure[2] = v;
|
10025 | break;
|
10026 |
|
10027 | case 3:
|
10028 | pure[0] = 0;
|
10029 | pure[1] = w;
|
10030 | pure[2] = 1;
|
10031 | break;
|
10032 |
|
10033 | case 4:
|
10034 | pure[0] = v;
|
10035 | pure[1] = 0;
|
10036 | pure[2] = 1;
|
10037 | break;
|
10038 |
|
10039 | default:
|
10040 | pure[0] = 1;
|
10041 | pure[1] = 0;
|
10042 | pure[2] = w;
|
10043 | }
|
10044 |
|
10045 | mg = (1.0 - c) * g;
|
10046 | return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
|
10047 | };
|
10048 |
|
10049 | convert.hcg.hsv = function (hcg) {
|
10050 | var c = hcg[1] / 100;
|
10051 | var g = hcg[2] / 100;
|
10052 | var v = c + g * (1.0 - c);
|
10053 | var f = 0;
|
10054 |
|
10055 | if (v > 0.0) {
|
10056 | f = c / v;
|
10057 | }
|
10058 |
|
10059 | return [hcg[0], f * 100, v * 100];
|
10060 | };
|
10061 |
|
10062 | convert.hcg.hsl = function (hcg) {
|
10063 | var c = hcg[1] / 100;
|
10064 | var g = hcg[2] / 100;
|
10065 | var l = g * (1.0 - c) + 0.5 * c;
|
10066 | var s = 0;
|
10067 |
|
10068 | if (l > 0.0 && l < 0.5) {
|
10069 | s = c / (2 * l);
|
10070 | } else if (l >= 0.5 && l < 1.0) {
|
10071 | s = c / (2 * (1 - l));
|
10072 | }
|
10073 |
|
10074 | return [hcg[0], s * 100, l * 100];
|
10075 | };
|
10076 |
|
10077 | convert.hcg.hwb = function (hcg) {
|
10078 | var c = hcg[1] / 100;
|
10079 | var g = hcg[2] / 100;
|
10080 | var v = c + g * (1.0 - c);
|
10081 | return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
10082 | };
|
10083 |
|
10084 | convert.hwb.hcg = function (hwb) {
|
10085 | var w = hwb[1] / 100;
|
10086 | var b = hwb[2] / 100;
|
10087 | var v = 1 - b;
|
10088 | var c = v - w;
|
10089 | var g = 0;
|
10090 |
|
10091 | if (c < 1) {
|
10092 | g = (v - c) / (1 - c);
|
10093 | }
|
10094 |
|
10095 | return [hwb[0], c * 100, g * 100];
|
10096 | };
|
10097 |
|
10098 | convert.apple.rgb = function (apple) {
|
10099 | return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
10100 | };
|
10101 |
|
10102 | convert.rgb.apple = function (rgb) {
|
10103 | return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
10104 | };
|
10105 |
|
10106 | convert.gray.rgb = function (args) {
|
10107 | return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
10108 | };
|
10109 |
|
10110 | convert.gray.hsl = convert.gray.hsv = function (args) {
|
10111 | return [0, 0, args[0]];
|
10112 | };
|
10113 |
|
10114 | convert.gray.hwb = function (gray) {
|
10115 | return [0, 100, gray[0]];
|
10116 | };
|
10117 |
|
10118 | convert.gray.cmyk = function (gray) {
|
10119 | return [0, 0, 0, gray[0]];
|
10120 | };
|
10121 |
|
10122 | convert.gray.lab = function (gray) {
|
10123 | return [gray[0], 0, 0];
|
10124 | };
|
10125 |
|
10126 | convert.gray.hex = function (gray) {
|
10127 | var val = Math.round(gray[0] / 100 * 255) & 0xFF;
|
10128 | var integer = (val << 16) + (val << 8) + val;
|
10129 | var string = integer.toString(16).toUpperCase();
|
10130 | return '000000'.substring(string.length) + string;
|
10131 | };
|
10132 |
|
10133 | convert.rgb.gray = function (rgb) {
|
10134 | var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
10135 | return [val / 255 * 100];
|
10136 | };
|
10137 | });
|
10138 | var conversions_1$1 = conversions$2.rgb;
|
10139 | var conversions_2$1 = conversions$2.hsl;
|
10140 | var conversions_3$1 = conversions$2.hsv;
|
10141 | var conversions_4$1 = conversions$2.hwb;
|
10142 | var conversions_5$1 = conversions$2.cmyk;
|
10143 | var conversions_6$1 = conversions$2.xyz;
|
10144 | var conversions_7$1 = conversions$2.lab;
|
10145 | var conversions_8$1 = conversions$2.lch;
|
10146 | var conversions_9$1 = conversions$2.hex;
|
10147 | var conversions_10$1 = conversions$2.keyword;
|
10148 | var conversions_11$1 = conversions$2.ansi16;
|
10149 | var conversions_12$1 = conversions$2.ansi256;
|
10150 | var conversions_13$1 = conversions$2.hcg;
|
10151 | var conversions_14$1 = conversions$2.apple;
|
10152 | var conversions_15$1 = conversions$2.gray;
|
10153 |
|
10154 |
|
10155 |
|
10156 |
|
10157 |
|
10158 |
|
10159 |
|
10160 |
|
10161 |
|
10162 |
|
10163 |
|
10164 |
|
10165 | function buildGraph$2() {
|
10166 | var graph = {};
|
10167 |
|
10168 | var models = Object.keys(conversions$2);
|
10169 |
|
10170 | for (var len = models.length, i = 0; i < len; i++) {
|
10171 | graph[models[i]] = {
|
10172 |
|
10173 |
|
10174 | distance: -1,
|
10175 | parent: null
|
10176 | };
|
10177 | }
|
10178 |
|
10179 | return graph;
|
10180 | }
|
10181 |
|
10182 |
|
10183 | function deriveBFS$2(fromModel) {
|
10184 | var graph = buildGraph$2();
|
10185 | var queue = [fromModel];
|
10186 |
|
10187 | graph[fromModel].distance = 0;
|
10188 |
|
10189 | while (queue.length) {
|
10190 | var current = queue.pop();
|
10191 | var adjacents = Object.keys(conversions$2[current]);
|
10192 |
|
10193 | for (var len = adjacents.length, i = 0; i < len; i++) {
|
10194 | var adjacent = adjacents[i];
|
10195 | var node = graph[adjacent];
|
10196 |
|
10197 | if (node.distance === -1) {
|
10198 | node.distance = graph[current].distance + 1;
|
10199 | node.parent = current;
|
10200 | queue.unshift(adjacent);
|
10201 | }
|
10202 | }
|
10203 | }
|
10204 |
|
10205 | return graph;
|
10206 | }
|
10207 |
|
10208 | function link$2(from, to) {
|
10209 | return function (args) {
|
10210 | return to(from(args));
|
10211 | };
|
10212 | }
|
10213 |
|
10214 | function wrapConversion$2(toModel, graph) {
|
10215 | var path = [graph[toModel].parent, toModel];
|
10216 | var fn = conversions$2[graph[toModel].parent][toModel];
|
10217 | var cur = graph[toModel].parent;
|
10218 |
|
10219 | while (graph[cur].parent) {
|
10220 | path.unshift(graph[cur].parent);
|
10221 | fn = link$2(conversions$2[graph[cur].parent][cur], fn);
|
10222 | cur = graph[cur].parent;
|
10223 | }
|
10224 |
|
10225 | fn.conversion = path;
|
10226 | return fn;
|
10227 | }
|
10228 |
|
10229 | var route$2 = function (fromModel) {
|
10230 | var graph = deriveBFS$2(fromModel);
|
10231 | var conversion = {};
|
10232 | var models = Object.keys(graph);
|
10233 |
|
10234 | for (var len = models.length, i = 0; i < len; i++) {
|
10235 | var toModel = models[i];
|
10236 | var node = graph[toModel];
|
10237 |
|
10238 | if (node.parent === null) {
|
10239 |
|
10240 | continue;
|
10241 | }
|
10242 |
|
10243 | conversion[toModel] = wrapConversion$2(toModel, graph);
|
10244 | }
|
10245 |
|
10246 | return conversion;
|
10247 | };
|
10248 |
|
10249 | var convert$3 = {};
|
10250 | var models$2 = Object.keys(conversions$2);
|
10251 |
|
10252 | function wrapRaw$2(fn) {
|
10253 | var wrappedFn = function (args) {
|
10254 | if (args === undefined || args === null) {
|
10255 | return args;
|
10256 | }
|
10257 |
|
10258 | if (arguments.length > 1) {
|
10259 | args = Array.prototype.slice.call(arguments);
|
10260 | }
|
10261 |
|
10262 | return fn(args);
|
10263 | };
|
10264 |
|
10265 |
|
10266 | if ('conversion' in fn) {
|
10267 | wrappedFn.conversion = fn.conversion;
|
10268 | }
|
10269 |
|
10270 | return wrappedFn;
|
10271 | }
|
10272 |
|
10273 | function wrapRounded$2(fn) {
|
10274 | var wrappedFn = function (args) {
|
10275 | if (args === undefined || args === null) {
|
10276 | return args;
|
10277 | }
|
10278 |
|
10279 | if (arguments.length > 1) {
|
10280 | args = Array.prototype.slice.call(arguments);
|
10281 | }
|
10282 |
|
10283 | var result = fn(args);
|
10284 |
|
10285 |
|
10286 |
|
10287 | if (typeof result === 'object') {
|
10288 | for (var len = result.length, i = 0; i < len; i++) {
|
10289 | result[i] = Math.round(result[i]);
|
10290 | }
|
10291 | }
|
10292 |
|
10293 | return result;
|
10294 | };
|
10295 |
|
10296 |
|
10297 | if ('conversion' in fn) {
|
10298 | wrappedFn.conversion = fn.conversion;
|
10299 | }
|
10300 |
|
10301 | return wrappedFn;
|
10302 | }
|
10303 |
|
10304 | models$2.forEach(function (fromModel) {
|
10305 | convert$3[fromModel] = {};
|
10306 | Object.defineProperty(convert$3[fromModel], 'channels', {
|
10307 | value: conversions$2[fromModel].channels
|
10308 | });
|
10309 | Object.defineProperty(convert$3[fromModel], 'labels', {
|
10310 | value: conversions$2[fromModel].labels
|
10311 | });
|
10312 | var routes = route$2(fromModel);
|
10313 | var routeModels = Object.keys(routes);
|
10314 | routeModels.forEach(function (toModel) {
|
10315 | var fn = routes[toModel];
|
10316 | convert$3[fromModel][toModel] = wrapRounded$2(fn);
|
10317 | convert$3[fromModel][toModel].raw = wrapRaw$2(fn);
|
10318 | });
|
10319 | });
|
10320 | var colorConvert$2 = convert$3;
|
10321 |
|
10322 | var ansiStyles$2 = createCommonjsModule(function (module) {
|
10323 |
|
10324 | const wrapAnsi16 = (fn, offset) => function () {
|
10325 | const code = fn.apply(colorConvert$2, arguments);
|
10326 | return `\u001B[${code + offset}m`;
|
10327 | };
|
10328 |
|
10329 | const wrapAnsi256 = (fn, offset) => function () {
|
10330 | const code = fn.apply(colorConvert$2, arguments);
|
10331 | return `\u001B[${38 + offset};5;${code}m`;
|
10332 | };
|
10333 |
|
10334 | const wrapAnsi16m = (fn, offset) => function () {
|
10335 | const rgb = fn.apply(colorConvert$2, arguments);
|
10336 | return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
10337 | };
|
10338 |
|
10339 | function assembleStyles() {
|
10340 | const codes = new Map();
|
10341 | const styles = {
|
10342 | modifier: {
|
10343 | reset: [0, 0],
|
10344 |
|
10345 | bold: [1, 22],
|
10346 | dim: [2, 22],
|
10347 | italic: [3, 23],
|
10348 | underline: [4, 24],
|
10349 | inverse: [7, 27],
|
10350 | hidden: [8, 28],
|
10351 | strikethrough: [9, 29]
|
10352 | },
|
10353 | color: {
|
10354 | black: [30, 39],
|
10355 | red: [31, 39],
|
10356 | green: [32, 39],
|
10357 | yellow: [33, 39],
|
10358 | blue: [34, 39],
|
10359 | magenta: [35, 39],
|
10360 | cyan: [36, 39],
|
10361 | white: [37, 39],
|
10362 | gray: [90, 39],
|
10363 |
|
10364 | redBright: [91, 39],
|
10365 | greenBright: [92, 39],
|
10366 | yellowBright: [93, 39],
|
10367 | blueBright: [94, 39],
|
10368 | magentaBright: [95, 39],
|
10369 | cyanBright: [96, 39],
|
10370 | whiteBright: [97, 39]
|
10371 | },
|
10372 | bgColor: {
|
10373 | bgBlack: [40, 49],
|
10374 | bgRed: [41, 49],
|
10375 | bgGreen: [42, 49],
|
10376 | bgYellow: [43, 49],
|
10377 | bgBlue: [44, 49],
|
10378 | bgMagenta: [45, 49],
|
10379 | bgCyan: [46, 49],
|
10380 | bgWhite: [47, 49],
|
10381 |
|
10382 | bgBlackBright: [100, 49],
|
10383 | bgRedBright: [101, 49],
|
10384 | bgGreenBright: [102, 49],
|
10385 | bgYellowBright: [103, 49],
|
10386 | bgBlueBright: [104, 49],
|
10387 | bgMagentaBright: [105, 49],
|
10388 | bgCyanBright: [106, 49],
|
10389 | bgWhiteBright: [107, 49]
|
10390 | }
|
10391 | };
|
10392 |
|
10393 | styles.color.grey = styles.color.gray;
|
10394 |
|
10395 | for (const groupName of Object.keys(styles)) {
|
10396 | const group = styles[groupName];
|
10397 |
|
10398 | for (const styleName of Object.keys(group)) {
|
10399 | const style = group[styleName];
|
10400 | styles[styleName] = {
|
10401 | open: `\u001B[${style[0]}m`,
|
10402 | close: `\u001B[${style[1]}m`
|
10403 | };
|
10404 | group[styleName] = styles[styleName];
|
10405 | codes.set(style[0], style[1]);
|
10406 | }
|
10407 |
|
10408 | Object.defineProperty(styles, groupName, {
|
10409 | value: group,
|
10410 | enumerable: false
|
10411 | });
|
10412 | Object.defineProperty(styles, 'codes', {
|
10413 | value: codes,
|
10414 | enumerable: false
|
10415 | });
|
10416 | }
|
10417 |
|
10418 | const ansi2ansi = n => n;
|
10419 |
|
10420 | const rgb2rgb = (r, g, b) => [r, g, b];
|
10421 |
|
10422 | styles.color.close = '\u001B[39m';
|
10423 | styles.bgColor.close = '\u001B[49m';
|
10424 | styles.color.ansi = {
|
10425 | ansi: wrapAnsi16(ansi2ansi, 0)
|
10426 | };
|
10427 | styles.color.ansi256 = {
|
10428 | ansi256: wrapAnsi256(ansi2ansi, 0)
|
10429 | };
|
10430 | styles.color.ansi16m = {
|
10431 | rgb: wrapAnsi16m(rgb2rgb, 0)
|
10432 | };
|
10433 | styles.bgColor.ansi = {
|
10434 | ansi: wrapAnsi16(ansi2ansi, 10)
|
10435 | };
|
10436 | styles.bgColor.ansi256 = {
|
10437 | ansi256: wrapAnsi256(ansi2ansi, 10)
|
10438 | };
|
10439 | styles.bgColor.ansi16m = {
|
10440 | rgb: wrapAnsi16m(rgb2rgb, 10)
|
10441 | };
|
10442 |
|
10443 | for (let key of Object.keys(colorConvert$2)) {
|
10444 | if (typeof colorConvert$2[key] !== 'object') {
|
10445 | continue;
|
10446 | }
|
10447 |
|
10448 | const suite = colorConvert$2[key];
|
10449 |
|
10450 | if (key === 'ansi16') {
|
10451 | key = 'ansi';
|
10452 | }
|
10453 |
|
10454 | if ('ansi16' in suite) {
|
10455 | styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
|
10456 | styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
|
10457 | }
|
10458 |
|
10459 | if ('ansi256' in suite) {
|
10460 | styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
|
10461 | styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
|
10462 | }
|
10463 |
|
10464 | if ('rgb' in suite) {
|
10465 | styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
|
10466 | styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
|
10467 | }
|
10468 | }
|
10469 |
|
10470 | return styles;
|
10471 | }
|
10472 |
|
10473 |
|
10474 | Object.defineProperty(module, 'exports', {
|
10475 | enumerable: true,
|
10476 | get: assembleStyles
|
10477 | });
|
10478 | });
|
10479 |
|
10480 | const env$2 = process.env;
|
10481 | let forceColor$2;
|
10482 |
|
10483 | if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
|
10484 | forceColor$2 = false;
|
10485 | } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
|
10486 | forceColor$2 = true;
|
10487 | }
|
10488 |
|
10489 | if ('FORCE_COLOR' in env$2) {
|
10490 | forceColor$2 = env$2.FORCE_COLOR.length === 0 || parseInt(env$2.FORCE_COLOR, 10) !== 0;
|
10491 | }
|
10492 |
|
10493 | function translateLevel$2(level) {
|
10494 | if (level === 0) {
|
10495 | return false;
|
10496 | }
|
10497 |
|
10498 | return {
|
10499 | level,
|
10500 | hasBasic: true,
|
10501 | has256: level >= 2,
|
10502 | has16m: level >= 3
|
10503 | };
|
10504 | }
|
10505 |
|
10506 | function supportsColor$2(stream) {
|
10507 | if (forceColor$2 === false) {
|
10508 | return 0;
|
10509 | }
|
10510 |
|
10511 | if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
|
10512 | return 3;
|
10513 | }
|
10514 |
|
10515 | if (hasFlag('color=256')) {
|
10516 | return 2;
|
10517 | }
|
10518 |
|
10519 | if (stream && !stream.isTTY && forceColor$2 !== true) {
|
10520 | return 0;
|
10521 | }
|
10522 |
|
10523 | const min = forceColor$2 ? 1 : 0;
|
10524 |
|
10525 | if (process.platform === 'win32') {
|
10526 |
|
10527 |
|
10528 |
|
10529 |
|
10530 |
|
10531 |
|
10532 | const osRelease = os$1.release().split('.');
|
10533 |
|
10534 | if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
10535 | return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
10536 | }
|
10537 |
|
10538 | return 1;
|
10539 | }
|
10540 |
|
10541 | if ('CI' in env$2) {
|
10542 | if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env$2) || env$2.CI_NAME === 'codeship') {
|
10543 | return 1;
|
10544 | }
|
10545 |
|
10546 | return min;
|
10547 | }
|
10548 |
|
10549 | if ('TEAMCITY_VERSION' in env$2) {
|
10550 | return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$2.TEAMCITY_VERSION) ? 1 : 0;
|
10551 | }
|
10552 |
|
10553 | if (env$2.COLORTERM === 'truecolor') {
|
10554 | return 3;
|
10555 | }
|
10556 |
|
10557 | if ('TERM_PROGRAM' in env$2) {
|
10558 | const version = parseInt((env$2.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
10559 |
|
10560 | switch (env$2.TERM_PROGRAM) {
|
10561 | case 'iTerm.app':
|
10562 | return version >= 3 ? 3 : 2;
|
10563 |
|
10564 | case 'Apple_Terminal':
|
10565 | return 2;
|
10566 |
|
10567 | }
|
10568 | }
|
10569 |
|
10570 | if (/-256(color)?$/i.test(env$2.TERM)) {
|
10571 | return 2;
|
10572 | }
|
10573 |
|
10574 | if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$2.TERM)) {
|
10575 | return 1;
|
10576 | }
|
10577 |
|
10578 | if ('COLORTERM' in env$2) {
|
10579 | return 1;
|
10580 | }
|
10581 |
|
10582 | if (env$2.TERM === 'dumb') {
|
10583 | return min;
|
10584 | }
|
10585 |
|
10586 | return min;
|
10587 | }
|
10588 |
|
10589 | function getSupportLevel$2(stream) {
|
10590 | const level = supportsColor$2(stream);
|
10591 | return translateLevel$2(level);
|
10592 | }
|
10593 |
|
10594 | var supportsColor_1$2 = {
|
10595 | supportsColor: getSupportLevel$2,
|
10596 | stdout: getSupportLevel$2(process.stdout),
|
10597 | stderr: getSupportLevel$2(process.stderr)
|
10598 | };
|
10599 |
|
10600 | const TEMPLATE_REGEX$2 = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
10601 | const STYLE_REGEX$2 = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
10602 | const STRING_REGEX$2 = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
10603 | const ESCAPE_REGEX$2 = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
|
10604 | const ESCAPES$2 = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
|
10605 |
|
10606 | function unescape$2(c) {
|
10607 | if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
|
10608 | return String.fromCharCode(parseInt(c.slice(1), 16));
|
10609 | }
|
10610 |
|
10611 | return ESCAPES$2.get(c) || c;
|
10612 | }
|
10613 |
|
10614 | function parseArguments$2(name, args) {
|
10615 | const results = [];
|
10616 | const chunks = args.trim().split(/\s*,\s*/g);
|
10617 | let matches;
|
10618 |
|
10619 | for (const chunk of chunks) {
|
10620 | if (!isNaN(chunk)) {
|
10621 | results.push(Number(chunk));
|
10622 | } else if (matches = chunk.match(STRING_REGEX$2)) {
|
10623 | results.push(matches[2].replace(ESCAPE_REGEX$2, (m, escape, chr) => escape ? unescape$2(escape) : chr));
|
10624 | } else {
|
10625 | throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
10626 | }
|
10627 | }
|
10628 |
|
10629 | return results;
|
10630 | }
|
10631 |
|
10632 | function parseStyle$2(style) {
|
10633 | STYLE_REGEX$2.lastIndex = 0;
|
10634 | const results = [];
|
10635 | let matches;
|
10636 |
|
10637 | while ((matches = STYLE_REGEX$2.exec(style)) !== null) {
|
10638 | const name = matches[1];
|
10639 |
|
10640 | if (matches[2]) {
|
10641 | const args = parseArguments$2(name, matches[2]);
|
10642 | results.push([name].concat(args));
|
10643 | } else {
|
10644 | results.push([name]);
|
10645 | }
|
10646 | }
|
10647 |
|
10648 | return results;
|
10649 | }
|
10650 |
|
10651 | function buildStyle$2(chalk, styles) {
|
10652 | const enabled = {};
|
10653 |
|
10654 | for (const layer of styles) {
|
10655 | for (const style of layer.styles) {
|
10656 | enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
10657 | }
|
10658 | }
|
10659 |
|
10660 | let current = chalk;
|
10661 |
|
10662 | for (const styleName of Object.keys(enabled)) {
|
10663 | if (Array.isArray(enabled[styleName])) {
|
10664 | if (!(styleName in current)) {
|
10665 | throw new Error(`Unknown Chalk style: ${styleName}`);
|
10666 | }
|
10667 |
|
10668 | if (enabled[styleName].length > 0) {
|
10669 | current = current[styleName].apply(current, enabled[styleName]);
|
10670 | } else {
|
10671 | current = current[styleName];
|
10672 | }
|
10673 | }
|
10674 | }
|
10675 |
|
10676 | return current;
|
10677 | }
|
10678 |
|
10679 | var templates$2 = (chalk, tmp) => {
|
10680 | const styles = [];
|
10681 | const chunks = [];
|
10682 | let chunk = [];
|
10683 |
|
10684 | tmp.replace(TEMPLATE_REGEX$2, (m, escapeChar, inverse, style, close, chr) => {
|
10685 | if (escapeChar) {
|
10686 | chunk.push(unescape$2(escapeChar));
|
10687 | } else if (style) {
|
10688 | const str = chunk.join('');
|
10689 | chunk = [];
|
10690 | chunks.push(styles.length === 0 ? str : buildStyle$2(chalk, styles)(str));
|
10691 | styles.push({
|
10692 | inverse,
|
10693 | styles: parseStyle$2(style)
|
10694 | });
|
10695 | } else if (close) {
|
10696 | if (styles.length === 0) {
|
10697 | throw new Error('Found extraneous } in Chalk template literal');
|
10698 | }
|
10699 |
|
10700 | chunks.push(buildStyle$2(chalk, styles)(chunk.join('')));
|
10701 | chunk = [];
|
10702 | styles.pop();
|
10703 | } else {
|
10704 | chunk.push(chr);
|
10705 | }
|
10706 | });
|
10707 | chunks.push(chunk.join(''));
|
10708 |
|
10709 | if (styles.length > 0) {
|
10710 | const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
10711 | throw new Error(errMsg);
|
10712 | }
|
10713 |
|
10714 | return chunks.join('');
|
10715 | };
|
10716 |
|
10717 | var chalk$2 = createCommonjsModule(function (module) {
|
10718 |
|
10719 | const stdoutColor = supportsColor_1$2.stdout;
|
10720 | const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');
|
10721 |
|
10722 | const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
|
10723 |
|
10724 | const skipModels = new Set(['gray']);
|
10725 | const styles = Object.create(null);
|
10726 |
|
10727 | function applyOptions(obj, options) {
|
10728 | options = options || {};
|
10729 |
|
10730 | const scLevel = stdoutColor ? stdoutColor.level : 0;
|
10731 | obj.level = options.level === undefined ? scLevel : options.level;
|
10732 | obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
|
10733 | }
|
10734 |
|
10735 | function Chalk(options) {
|
10736 |
|
10737 |
|
10738 | if (!this || !(this instanceof Chalk) || this.template) {
|
10739 | const chalk = {};
|
10740 | applyOptions(chalk, options);
|
10741 |
|
10742 | chalk.template = function () {
|
10743 | const args = [].slice.call(arguments);
|
10744 | return chalkTag.apply(null, [chalk.template].concat(args));
|
10745 | };
|
10746 |
|
10747 | Object.setPrototypeOf(chalk, Chalk.prototype);
|
10748 | Object.setPrototypeOf(chalk.template, chalk);
|
10749 | chalk.template.constructor = Chalk;
|
10750 | return chalk.template;
|
10751 | }
|
10752 |
|
10753 | applyOptions(this, options);
|
10754 | }
|
10755 |
|
10756 |
|
10757 | if (isSimpleWindowsTerm) {
|
10758 | ansiStyles$2.blue.open = '\u001B[94m';
|
10759 | }
|
10760 |
|
10761 | for (const key of Object.keys(ansiStyles$2)) {
|
10762 | ansiStyles$2[key].closeRe = new RegExp(escapeStringRegexp$1(ansiStyles$2[key].close), 'g');
|
10763 | styles[key] = {
|
10764 | get() {
|
10765 | const codes = ansiStyles$2[key];
|
10766 | return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
|
10767 | }
|
10768 |
|
10769 | };
|
10770 | }
|
10771 |
|
10772 | styles.visible = {
|
10773 | get() {
|
10774 | return build.call(this, this._styles || [], true, 'visible');
|
10775 | }
|
10776 |
|
10777 | };
|
10778 | ansiStyles$2.color.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles$2.color.close), 'g');
|
10779 |
|
10780 | for (const model of Object.keys(ansiStyles$2.color.ansi)) {
|
10781 | if (skipModels.has(model)) {
|
10782 | continue;
|
10783 | }
|
10784 |
|
10785 | styles[model] = {
|
10786 | get() {
|
10787 | const level = this.level;
|
10788 | return function () {
|
10789 | const open = ansiStyles$2.color[levelMapping[level]][model].apply(null, arguments);
|
10790 | const codes = {
|
10791 | open,
|
10792 | close: ansiStyles$2.color.close,
|
10793 | closeRe: ansiStyles$2.color.closeRe
|
10794 | };
|
10795 | return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
|
10796 | };
|
10797 | }
|
10798 |
|
10799 | };
|
10800 | }
|
10801 |
|
10802 | ansiStyles$2.bgColor.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles$2.bgColor.close), 'g');
|
10803 |
|
10804 | for (const model of Object.keys(ansiStyles$2.bgColor.ansi)) {
|
10805 | if (skipModels.has(model)) {
|
10806 | continue;
|
10807 | }
|
10808 |
|
10809 | const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
10810 | styles[bgModel] = {
|
10811 | get() {
|
10812 | const level = this.level;
|
10813 | return function () {
|
10814 | const open = ansiStyles$2.bgColor[levelMapping[level]][model].apply(null, arguments);
|
10815 | const codes = {
|
10816 | open,
|
10817 | close: ansiStyles$2.bgColor.close,
|
10818 | closeRe: ansiStyles$2.bgColor.closeRe
|
10819 | };
|
10820 | return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
|
10821 | };
|
10822 | }
|
10823 |
|
10824 | };
|
10825 | }
|
10826 |
|
10827 | const proto = Object.defineProperties(() => {}, styles);
|
10828 |
|
10829 | function build(_styles, _empty, key) {
|
10830 | const builder = function () {
|
10831 | return applyStyle.apply(builder, arguments);
|
10832 | };
|
10833 |
|
10834 | builder._styles = _styles;
|
10835 | builder._empty = _empty;
|
10836 | const self = this;
|
10837 | Object.defineProperty(builder, 'level', {
|
10838 | enumerable: true,
|
10839 |
|
10840 | get() {
|
10841 | return self.level;
|
10842 | },
|
10843 |
|
10844 | set(level) {
|
10845 | self.level = level;
|
10846 | }
|
10847 |
|
10848 | });
|
10849 | Object.defineProperty(builder, 'enabled', {
|
10850 | enumerable: true,
|
10851 |
|
10852 | get() {
|
10853 | return self.enabled;
|
10854 | },
|
10855 |
|
10856 | set(enabled) {
|
10857 | self.enabled = enabled;
|
10858 | }
|
10859 |
|
10860 | });
|
10861 |
|
10862 | builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey';
|
10863 |
|
10864 |
|
10865 | builder.__proto__ = proto;
|
10866 |
|
10867 | return builder;
|
10868 | }
|
10869 |
|
10870 | function applyStyle() {
|
10871 |
|
10872 | const args = arguments;
|
10873 | const argsLen = args.length;
|
10874 | let str = String(arguments[0]);
|
10875 |
|
10876 | if (argsLen === 0) {
|
10877 | return '';
|
10878 | }
|
10879 |
|
10880 | if (argsLen > 1) {
|
10881 |
|
10882 | for (let a = 1; a < argsLen; a++) {
|
10883 | str += ' ' + args[a];
|
10884 | }
|
10885 | }
|
10886 |
|
10887 | if (!this.enabled || this.level <= 0 || !str) {
|
10888 | return this._empty ? '' : str;
|
10889 | }
|
10890 |
|
10891 |
|
10892 |
|
10893 |
|
10894 | const originalDim = ansiStyles$2.dim.open;
|
10895 |
|
10896 | if (isSimpleWindowsTerm && this.hasGrey) {
|
10897 | ansiStyles$2.dim.open = '';
|
10898 | }
|
10899 |
|
10900 | for (const code of this._styles.slice().reverse()) {
|
10901 |
|
10902 |
|
10903 |
|
10904 | str = code.open + str.replace(code.closeRe, code.open) + code.close;
|
10905 |
|
10906 |
|
10907 |
|
10908 | str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
|
10909 | }
|
10910 |
|
10911 |
|
10912 | ansiStyles$2.dim.open = originalDim;
|
10913 | return str;
|
10914 | }
|
10915 |
|
10916 | function chalkTag(chalk, strings) {
|
10917 | if (!Array.isArray(strings)) {
|
10918 |
|
10919 |
|
10920 | return [].slice.call(arguments, 1).join(' ');
|
10921 | }
|
10922 |
|
10923 | const args = [].slice.call(arguments, 2);
|
10924 | const parts = [strings.raw[0]];
|
10925 |
|
10926 | for (let i = 1; i < strings.length; i++) {
|
10927 | parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
|
10928 | parts.push(String(strings.raw[i]));
|
10929 | }
|
10930 |
|
10931 | return templates$2(chalk, parts.join(''));
|
10932 | }
|
10933 |
|
10934 | Object.defineProperties(Chalk.prototype, styles);
|
10935 | module.exports = Chalk();
|
10936 |
|
10937 | module.exports.supportsColor = stdoutColor;
|
10938 | module.exports.default = module.exports;
|
10939 | });
|
10940 | var chalk_1$1 = chalk$2.supportsColor;
|
10941 |
|
10942 | var lib$1 = createCommonjsModule(function (module, exports) {
|
10943 |
|
10944 | Object.defineProperty(exports, "__esModule", {
|
10945 | value: true
|
10946 | });
|
10947 | exports.shouldHighlight = shouldHighlight;
|
10948 | exports.getChalk = getChalk;
|
10949 | exports.default = highlight;
|
10950 |
|
10951 | var _jsTokens = _interopRequireWildcard(jsTokens);
|
10952 |
|
10953 | var _esutils = _interopRequireDefault(utils$1);
|
10954 |
|
10955 | var _chalk = _interopRequireDefault(chalk$2);
|
10956 |
|
10957 | function _interopRequireDefault(obj) {
|
10958 | return obj && obj.__esModule ? obj : {
|
10959 | default: obj
|
10960 | };
|
10961 | }
|
10962 |
|
10963 | function _getRequireWildcardCache() {
|
10964 | if (typeof WeakMap !== "function") return null;
|
10965 | var cache = new WeakMap();
|
10966 |
|
10967 | _getRequireWildcardCache = function () {
|
10968 | return cache;
|
10969 | };
|
10970 |
|
10971 | return cache;
|
10972 | }
|
10973 |
|
10974 | function _interopRequireWildcard(obj) {
|
10975 | if (obj && obj.__esModule) {
|
10976 | return obj;
|
10977 | }
|
10978 |
|
10979 | if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
10980 | return {
|
10981 | default: obj
|
10982 | };
|
10983 | }
|
10984 |
|
10985 | var cache = _getRequireWildcardCache();
|
10986 |
|
10987 | if (cache && cache.has(obj)) {
|
10988 | return cache.get(obj);
|
10989 | }
|
10990 |
|
10991 | var newObj = {};
|
10992 | var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
10993 |
|
10994 | for (var key in obj) {
|
10995 | if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
10996 | var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
10997 |
|
10998 | if (desc && (desc.get || desc.set)) {
|
10999 | Object.defineProperty(newObj, key, desc);
|
11000 | } else {
|
11001 | newObj[key] = obj[key];
|
11002 | }
|
11003 | }
|
11004 | }
|
11005 |
|
11006 | newObj.default = obj;
|
11007 |
|
11008 | if (cache) {
|
11009 | cache.set(obj, newObj);
|
11010 | }
|
11011 |
|
11012 | return newObj;
|
11013 | }
|
11014 |
|
11015 | function getDefs(chalk) {
|
11016 | return {
|
11017 | keyword: chalk.cyan,
|
11018 | capitalized: chalk.yellow,
|
11019 | jsx_tag: chalk.yellow,
|
11020 | punctuator: chalk.yellow,
|
11021 | number: chalk.magenta,
|
11022 | string: chalk.green,
|
11023 | regex: chalk.magenta,
|
11024 | comment: chalk.grey,
|
11025 | invalid: chalk.white.bgRed.bold
|
11026 | };
|
11027 | }
|
11028 |
|
11029 | const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
11030 | const JSX_TAG = /^[a-z][\w-]*$/i;
|
11031 | const BRACKET = /^[()[\]{}]$/;
|
11032 |
|
11033 | function getTokenType(match) {
|
11034 | const [offset, text] = match.slice(-2);
|
11035 | const token = (0, _jsTokens.matchToToken)(match);
|
11036 |
|
11037 | if (token.type === "name") {
|
11038 | if (_esutils.default.keyword.isReservedWordES6(token.value)) {
|
11039 | return "keyword";
|
11040 | }
|
11041 |
|
11042 | if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
|
11043 | return "jsx_tag";
|
11044 | }
|
11045 |
|
11046 | if (token.value[0] !== token.value[0].toLowerCase()) {
|
11047 | return "capitalized";
|
11048 | }
|
11049 | }
|
11050 |
|
11051 | if (token.type === "punctuator" && BRACKET.test(token.value)) {
|
11052 | return "bracket";
|
11053 | }
|
11054 |
|
11055 | if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
|
11056 | return "punctuator";
|
11057 | }
|
11058 |
|
11059 | return token.type;
|
11060 | }
|
11061 |
|
11062 | function highlightTokens(defs, text) {
|
11063 | return text.replace(_jsTokens.default, function (...args) {
|
11064 | const type = getTokenType(args);
|
11065 | const colorize = defs[type];
|
11066 |
|
11067 | if (colorize) {
|
11068 | return args[0].split(NEWLINE).map(str => colorize(str)).join("\n");
|
11069 | } else {
|
11070 | return args[0];
|
11071 | }
|
11072 | });
|
11073 | }
|
11074 |
|
11075 | function shouldHighlight(options) {
|
11076 | return _chalk.default.supportsColor || options.forceColor;
|
11077 | }
|
11078 |
|
11079 | function getChalk(options) {
|
11080 | let chalk = _chalk.default;
|
11081 |
|
11082 | if (options.forceColor) {
|
11083 | chalk = new _chalk.default.constructor({
|
11084 | enabled: true,
|
11085 | level: 1
|
11086 | });
|
11087 | }
|
11088 |
|
11089 | return chalk;
|
11090 | }
|
11091 |
|
11092 | function highlight(code, options = {}) {
|
11093 | if (shouldHighlight(options)) {
|
11094 | const chalk = getChalk(options);
|
11095 | const defs = getDefs(chalk);
|
11096 | return highlightTokens(defs, code);
|
11097 | } else {
|
11098 | return code;
|
11099 | }
|
11100 | }
|
11101 | });
|
11102 | unwrapExports(lib$1);
|
11103 | var lib_1 = lib$1.shouldHighlight;
|
11104 | var lib_2 = lib$1.getChalk;
|
11105 |
|
11106 | var lib$2 = createCommonjsModule(function (module, exports) {
|
11107 |
|
11108 | Object.defineProperty(exports, "__esModule", {
|
11109 | value: true
|
11110 | });
|
11111 | exports.codeFrameColumns = codeFrameColumns;
|
11112 | exports.default = _default;
|
11113 |
|
11114 | var _highlight = _interopRequireWildcard(lib$1);
|
11115 |
|
11116 | function _getRequireWildcardCache() {
|
11117 | if (typeof WeakMap !== "function") return null;
|
11118 | var cache = new WeakMap();
|
11119 |
|
11120 | _getRequireWildcardCache = function () {
|
11121 | return cache;
|
11122 | };
|
11123 |
|
11124 | return cache;
|
11125 | }
|
11126 |
|
11127 | function _interopRequireWildcard(obj) {
|
11128 | if (obj && obj.__esModule) {
|
11129 | return obj;
|
11130 | }
|
11131 |
|
11132 | if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
11133 | return {
|
11134 | default: obj
|
11135 | };
|
11136 | }
|
11137 |
|
11138 | var cache = _getRequireWildcardCache();
|
11139 |
|
11140 | if (cache && cache.has(obj)) {
|
11141 | return cache.get(obj);
|
11142 | }
|
11143 |
|
11144 | var newObj = {};
|
11145 | var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
11146 |
|
11147 | for (var key in obj) {
|
11148 | if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
11149 | var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
11150 |
|
11151 | if (desc && (desc.get || desc.set)) {
|
11152 | Object.defineProperty(newObj, key, desc);
|
11153 | } else {
|
11154 | newObj[key] = obj[key];
|
11155 | }
|
11156 | }
|
11157 | }
|
11158 |
|
11159 | newObj.default = obj;
|
11160 |
|
11161 | if (cache) {
|
11162 | cache.set(obj, newObj);
|
11163 | }
|
11164 |
|
11165 | return newObj;
|
11166 | }
|
11167 |
|
11168 | let deprecationWarningShown = false;
|
11169 |
|
11170 | function getDefs(chalk) {
|
11171 | return {
|
11172 | gutter: chalk.grey,
|
11173 | marker: chalk.red.bold,
|
11174 | message: chalk.red.bold
|
11175 | };
|
11176 | }
|
11177 |
|
11178 | const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
11179 |
|
11180 | function getMarkerLines(loc, source, opts) {
|
11181 | const startLoc = Object.assign({
|
11182 | column: 0,
|
11183 | line: -1
|
11184 | }, loc.start);
|
11185 | const endLoc = Object.assign({}, startLoc, {}, loc.end);
|
11186 | const {
|
11187 | linesAbove = 2,
|
11188 | linesBelow = 3
|
11189 | } = opts || {};
|
11190 | const startLine = startLoc.line;
|
11191 | const startColumn = startLoc.column;
|
11192 | const endLine = endLoc.line;
|
11193 | const endColumn = endLoc.column;
|
11194 | let start = Math.max(startLine - (linesAbove + 1), 0);
|
11195 | let end = Math.min(source.length, endLine + linesBelow);
|
11196 |
|
11197 | if (startLine === -1) {
|
11198 | start = 0;
|
11199 | }
|
11200 |
|
11201 | if (endLine === -1) {
|
11202 | end = source.length;
|
11203 | }
|
11204 |
|
11205 | const lineDiff = endLine - startLine;
|
11206 | const markerLines = {};
|
11207 |
|
11208 | if (lineDiff) {
|
11209 | for (let i = 0; i <= lineDiff; i++) {
|
11210 | const lineNumber = i + startLine;
|
11211 |
|
11212 | if (!startColumn) {
|
11213 | markerLines[lineNumber] = true;
|
11214 | } else if (i === 0) {
|
11215 | const sourceLength = source[lineNumber - 1].length;
|
11216 | markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
|
11217 | } else if (i === lineDiff) {
|
11218 | markerLines[lineNumber] = [0, endColumn];
|
11219 | } else {
|
11220 | const sourceLength = source[lineNumber - i].length;
|
11221 | markerLines[lineNumber] = [0, sourceLength];
|
11222 | }
|
11223 | }
|
11224 | } else {
|
11225 | if (startColumn === endColumn) {
|
11226 | if (startColumn) {
|
11227 | markerLines[startLine] = [startColumn, 0];
|
11228 | } else {
|
11229 | markerLines[startLine] = true;
|
11230 | }
|
11231 | } else {
|
11232 | markerLines[startLine] = [startColumn, endColumn - startColumn];
|
11233 | }
|
11234 | }
|
11235 |
|
11236 | return {
|
11237 | start,
|
11238 | end,
|
11239 | markerLines
|
11240 | };
|
11241 | }
|
11242 |
|
11243 | function codeFrameColumns(rawLines, loc, opts = {}) {
|
11244 | const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts);
|
11245 | const chalk = (0, _highlight.getChalk)(opts);
|
11246 | const defs = getDefs(chalk);
|
11247 |
|
11248 | const maybeHighlight = (chalkFn, string) => {
|
11249 | return highlighted ? chalkFn(string) : string;
|
11250 | };
|
11251 |
|
11252 | const lines = rawLines.split(NEWLINE);
|
11253 | const {
|
11254 | start,
|
11255 | end,
|
11256 | markerLines
|
11257 | } = getMarkerLines(loc, lines, opts);
|
11258 | const hasColumns = loc.start && typeof loc.start.column === "number";
|
11259 | const numberMaxWidth = String(end).length;
|
11260 | const highlightedLines = highlighted ? (0, _highlight.default)(rawLines, opts) : rawLines;
|
11261 | let frame = highlightedLines.split(NEWLINE).slice(start, end).map((line, index) => {
|
11262 | const number = start + 1 + index;
|
11263 | const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
|
11264 | const gutter = ` ${paddedNumber} | `;
|
11265 | const hasMarker = markerLines[number];
|
11266 | const lastMarkerLine = !markerLines[number + 1];
|
11267 |
|
11268 | if (hasMarker) {
|
11269 | let markerLine = "";
|
11270 |
|
11271 | if (Array.isArray(hasMarker)) {
|
11272 | const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
|
11273 | const numberOfMarkers = hasMarker[1] || 1;
|
11274 | markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join("");
|
11275 |
|
11276 | if (lastMarkerLine && opts.message) {
|
11277 | markerLine += " " + maybeHighlight(defs.message, opts.message);
|
11278 | }
|
11279 | }
|
11280 |
|
11281 | return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
|
11282 | } else {
|
11283 | return ` ${maybeHighlight(defs.gutter, gutter)}${line}`;
|
11284 | }
|
11285 | }).join("\n");
|
11286 |
|
11287 | if (opts.message && !hasColumns) {
|
11288 | frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
|
11289 | }
|
11290 |
|
11291 | if (highlighted) {
|
11292 | return chalk.reset(frame);
|
11293 | } else {
|
11294 | return frame;
|
11295 | }
|
11296 | }
|
11297 |
|
11298 | function _default(rawLines, lineNumber, colNumber, opts = {}) {
|
11299 | if (!deprecationWarningShown) {
|
11300 | deprecationWarningShown = true;
|
11301 | const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
|
11302 |
|
11303 | if (process.emitWarning) {
|
11304 | process.emitWarning(message, "DeprecationWarning");
|
11305 | } else {
|
11306 | const deprecationError = new Error(message);
|
11307 | deprecationError.name = "DeprecationWarning";
|
11308 | console.warn(new Error(message));
|
11309 | }
|
11310 | }
|
11311 |
|
11312 | colNumber = Math.max(colNumber, 0);
|
11313 | const location = {
|
11314 | start: {
|
11315 | column: colNumber,
|
11316 | line: lineNumber
|
11317 | }
|
11318 | };
|
11319 | return codeFrameColumns(rawLines, location, opts);
|
11320 | }
|
11321 | });
|
11322 | unwrapExports(lib$2);
|
11323 | var lib_1$1 = lib$2.codeFrameColumns;
|
11324 |
|
11325 | const {
|
11326 | ConfigError: ConfigError$1
|
11327 | } = errors;
|
11328 | const {
|
11329 | locStart: locStart$1,
|
11330 | locEnd: locEnd$1
|
11331 | } = loc;
|
11332 |
|
11333 |
|
11334 | const ownNames = Object.getOwnPropertyNames;
|
11335 | const ownDescriptor = Object.getOwnPropertyDescriptor;
|
11336 |
|
11337 | function getParsers(options) {
|
11338 | const parsers = {};
|
11339 |
|
11340 | for (const plugin of options.plugins) {
|
11341 | if (!plugin.parsers) {
|
11342 | continue;
|
11343 | }
|
11344 |
|
11345 | for (const name of ownNames(plugin.parsers)) {
|
11346 | Object.defineProperty(parsers, name, ownDescriptor(plugin.parsers, name));
|
11347 | }
|
11348 | }
|
11349 |
|
11350 | return parsers;
|
11351 | }
|
11352 |
|
11353 | function resolveParser(opts, parsers) {
|
11354 | parsers = parsers || getParsers(opts);
|
11355 |
|
11356 | if (typeof opts.parser === "function") {
|
11357 |
|
11358 | return {
|
11359 | parse: opts.parser,
|
11360 | astFormat: "estree",
|
11361 | locStart: locStart$1,
|
11362 | locEnd: locEnd$1
|
11363 | };
|
11364 | }
|
11365 |
|
11366 | if (typeof opts.parser === "string") {
|
11367 | if (Object.prototype.hasOwnProperty.call(parsers, opts.parser)) {
|
11368 | return parsers[opts.parser];
|
11369 | }
|
11370 |
|
11371 |
|
11372 |
|
11373 | {
|
11374 | try {
|
11375 | return {
|
11376 | parse: require(path$2.resolve(process.cwd(), opts.parser)),
|
11377 | astFormat: "estree",
|
11378 | locStart: locStart$1,
|
11379 | locEnd: locEnd$1
|
11380 | };
|
11381 | } catch (err) {
|
11382 |
|
11383 | throw new ConfigError$1(`Couldn't resolve parser "${opts.parser}"`);
|
11384 | }
|
11385 | }
|
11386 | }
|
11387 | }
|
11388 |
|
11389 | function parse(text, opts) {
|
11390 | const parsers = getParsers(opts);
|
11391 |
|
11392 |
|
11393 | const parsersForCustomParserApi = Object.keys(parsers).reduce((object, parserName) => Object.defineProperty(object, parserName, {
|
11394 | enumerable: true,
|
11395 |
|
11396 | get() {
|
11397 | return parsers[parserName].parse;
|
11398 | }
|
11399 |
|
11400 | }), {});
|
11401 | const parser = resolveParser(opts, parsers);
|
11402 |
|
11403 | try {
|
11404 | if (parser.preprocess) {
|
11405 | text = parser.preprocess(text, opts);
|
11406 | }
|
11407 |
|
11408 | return {
|
11409 | text,
|
11410 | ast: parser.parse(text, parsersForCustomParserApi, opts)
|
11411 | };
|
11412 | } catch (error) {
|
11413 | const {
|
11414 | loc
|
11415 | } = error;
|
11416 |
|
11417 | if (loc) {
|
11418 | const codeFrame = lib$2;
|
11419 | error.codeFrame = codeFrame.codeFrameColumns(text, loc, {
|
11420 | highlightCode: true
|
11421 | });
|
11422 | error.message += "\n" + error.codeFrame;
|
11423 | throw error;
|
11424 | }
|
11425 |
|
11426 |
|
11427 |
|
11428 | throw error.stack;
|
11429 | }
|
11430 | }
|
11431 |
|
11432 | var parser = {
|
11433 | parse,
|
11434 | resolveParser
|
11435 | };
|
11436 |
|
11437 | const {
|
11438 | UndefinedParserError: UndefinedParserError$1
|
11439 | } = errors;
|
11440 | const {
|
11441 | getSupportInfo: getSupportInfo$1
|
11442 | } = support;
|
11443 | const {
|
11444 | resolveParser: resolveParser$1
|
11445 | } = parser;
|
11446 | const hiddenDefaults = {
|
11447 | astFormat: "estree",
|
11448 | printer: {},
|
11449 | originalText: undefined,
|
11450 | locStart: null,
|
11451 | locEnd: null
|
11452 | };
|
11453 |
|
11454 | function normalize$1(options, opts) {
|
11455 | opts = opts || {};
|
11456 | const rawOptions = Object.assign({}, options);
|
11457 | const supportOptions = getSupportInfo$1({
|
11458 | plugins: options.plugins,
|
11459 | showUnreleased: true,
|
11460 | showDeprecated: true
|
11461 | }).options;
|
11462 | const defaults = Object.assign({}, hiddenDefaults, {}, fromPairs_1(supportOptions.filter(optionInfo => optionInfo.default !== undefined).map(option => [option.name, option.default])));
|
11463 |
|
11464 | if (!rawOptions.parser) {
|
11465 | if (!rawOptions.filepath) {
|
11466 | const logger = opts.logger || console;
|
11467 | logger.warn("No parser and no filepath given, using 'babel' the parser now " + "but this will throw an error in the future. " + "Please specify a parser or a filepath so one can be inferred.");
|
11468 | rawOptions.parser = "babel";
|
11469 | } else {
|
11470 | rawOptions.parser = inferParser(rawOptions.filepath, rawOptions.plugins);
|
11471 |
|
11472 | if (!rawOptions.parser) {
|
11473 | throw new UndefinedParserError$1(`No parser could be inferred for file: ${rawOptions.filepath}`);
|
11474 | }
|
11475 | }
|
11476 | }
|
11477 |
|
11478 | const parser = resolveParser$1(optionsNormalizer.normalizeApiOptions(rawOptions, [supportOptions.find(x => x.name === "parser")], {
|
11479 | passThrough: true,
|
11480 | logger: false
|
11481 | }));
|
11482 | rawOptions.astFormat = parser.astFormat;
|
11483 | rawOptions.locEnd = parser.locEnd;
|
11484 | rawOptions.locStart = parser.locStart;
|
11485 | const plugin = getPlugin(rawOptions);
|
11486 | rawOptions.printer = plugin.printers[rawOptions.astFormat];
|
11487 | const pluginDefaults = supportOptions.filter(optionInfo => optionInfo.pluginDefaults && optionInfo.pluginDefaults[plugin.name] !== undefined).reduce((reduced, optionInfo) => Object.assign(reduced, {
|
11488 | [optionInfo.name]: optionInfo.pluginDefaults[plugin.name]
|
11489 | }), {});
|
11490 | const mixedDefaults = Object.assign({}, defaults, {}, pluginDefaults);
|
11491 | Object.keys(mixedDefaults).forEach(k => {
|
11492 | if (rawOptions[k] == null) {
|
11493 | rawOptions[k] = mixedDefaults[k];
|
11494 | }
|
11495 | });
|
11496 |
|
11497 | if (rawOptions.parser === "json") {
|
11498 | rawOptions.trailingComma = "none";
|
11499 | }
|
11500 |
|
11501 | return optionsNormalizer.normalizeApiOptions(rawOptions, supportOptions, Object.assign({
|
11502 | passThrough: Object.keys(hiddenDefaults)
|
11503 | }, opts));
|
11504 | }
|
11505 |
|
11506 | function getPlugin(options) {
|
11507 | const {
|
11508 | astFormat
|
11509 | } = options;
|
11510 |
|
11511 | if (!astFormat) {
|
11512 | throw new Error("getPlugin() requires astFormat to be set");
|
11513 | }
|
11514 |
|
11515 | const printerPlugin = options.plugins.find(plugin => plugin.printers && plugin.printers[astFormat]);
|
11516 |
|
11517 | if (!printerPlugin) {
|
11518 | throw new Error(`Couldn't find plugin for AST format "${astFormat}"`);
|
11519 | }
|
11520 |
|
11521 | return printerPlugin;
|
11522 | }
|
11523 |
|
11524 | function getInterpreter(filepath) {
|
11525 | if (typeof filepath !== "string") {
|
11526 | return "";
|
11527 | }
|
11528 |
|
11529 | let fd;
|
11530 |
|
11531 | try {
|
11532 | fd = fs$3.openSync(filepath, "r");
|
11533 | } catch (err) {
|
11534 |
|
11535 | return "";
|
11536 | }
|
11537 |
|
11538 | try {
|
11539 | const liner = new readlines(fd);
|
11540 | const firstLine = liner.next().toString("utf8");
|
11541 |
|
11542 | const m1 = firstLine.match(/^#!\/(?:usr\/)?bin\/env\s+(\S+)/);
|
11543 |
|
11544 | if (m1) {
|
11545 | return m1[1];
|
11546 | }
|
11547 |
|
11548 |
|
11549 | const m2 = firstLine.match(/^#!\/(?:usr\/(?:local\/)?)?bin\/(\S+)/);
|
11550 |
|
11551 | if (m2) {
|
11552 | return m2[1];
|
11553 | }
|
11554 |
|
11555 | return "";
|
11556 | } catch (err) {
|
11557 |
|
11558 |
|
11559 | return "";
|
11560 | } finally {
|
11561 | try {
|
11562 |
|
11563 |
|
11564 | fs$3.closeSync(fd);
|
11565 | } catch (err) {
|
11566 | }
|
11567 | }
|
11568 | }
|
11569 |
|
11570 | function inferParser(filepath, plugins) {
|
11571 | const filename = path$2.basename(filepath).toLowerCase();
|
11572 | const languages = getSupportInfo$1({
|
11573 | plugins
|
11574 | }).languages.filter(language => language.since !== null);
|
11575 |
|
11576 |
|
11577 |
|
11578 | let language = languages.find(language => language.extensions && language.extensions.some(extension => filename.endsWith(extension)) || language.filenames && language.filenames.find(name => name.toLowerCase() === filename));
|
11579 |
|
11580 | if (!language && !filename.includes(".")) {
|
11581 | const interpreter = getInterpreter(filepath);
|
11582 | language = languages.find(language => language.interpreters && language.interpreters.includes(interpreter));
|
11583 | }
|
11584 |
|
11585 | return language && language.parsers[0];
|
11586 | }
|
11587 |
|
11588 | var options$1 = {
|
11589 | normalize: normalize$1,
|
11590 | hiddenDefaults,
|
11591 | inferParser
|
11592 | };
|
11593 |
|
11594 | function massageAST(ast, options, parent) {
|
11595 | if (Array.isArray(ast)) {
|
11596 | return ast.map(e => massageAST(e, options, parent)).filter(Boolean);
|
11597 | }
|
11598 |
|
11599 | if (!ast || typeof ast !== "object") {
|
11600 | return ast;
|
11601 | }
|
11602 |
|
11603 | const newObj = {};
|
11604 |
|
11605 | for (const key of Object.keys(ast)) {
|
11606 | if (typeof ast[key] !== "function") {
|
11607 | newObj[key] = massageAST(ast[key], options, ast);
|
11608 | }
|
11609 | }
|
11610 |
|
11611 | if (options.printer.massageAstNode) {
|
11612 | const result = options.printer.massageAstNode(ast, newObj, parent);
|
11613 |
|
11614 | if (result === null) {
|
11615 | return undefined;
|
11616 | }
|
11617 |
|
11618 | if (result) {
|
11619 | return result;
|
11620 | }
|
11621 | }
|
11622 |
|
11623 | return newObj;
|
11624 | }
|
11625 |
|
11626 | var massageAst = massageAST;
|
11627 |
|
11628 |
|
11629 |
|
11630 |
|
11631 |
|
11632 |
|
11633 |
|
11634 | function concat(parts) {
|
11635 |
|
11636 |
|
11637 |
|
11638 |
|
11639 |
|
11640 |
|
11641 |
|
11642 | return {
|
11643 | type: "concat",
|
11644 | parts
|
11645 | };
|
11646 | }
|
11647 |
|
11648 |
|
11649 |
|
11650 |
|
11651 |
|
11652 |
|
11653 | function indent(contents) {
|
11654 |
|
11655 | return {
|
11656 | type: "indent",
|
11657 | contents
|
11658 | };
|
11659 | }
|
11660 |
|
11661 |
|
11662 |
|
11663 |
|
11664 |
|
11665 |
|
11666 |
|
11667 | function align(n, contents) {
|
11668 |
|
11669 | return {
|
11670 | type: "align",
|
11671 | contents,
|
11672 | n
|
11673 | };
|
11674 | }
|
11675 |
|
11676 |
|
11677 |
|
11678 |
|
11679 |
|
11680 |
|
11681 |
|
11682 | function group(contents, opts) {
|
11683 | opts = opts || {};
|
11684 |
|
11685 | return {
|
11686 | type: "group",
|
11687 | id: opts.id,
|
11688 | contents,
|
11689 | break: !!opts.shouldBreak,
|
11690 | expandedStates: opts.expandedStates
|
11691 | };
|
11692 | }
|
11693 |
|
11694 |
|
11695 |
|
11696 |
|
11697 |
|
11698 |
|
11699 | function dedentToRoot(contents) {
|
11700 | return align(-Infinity, contents);
|
11701 | }
|
11702 |
|
11703 |
|
11704 |
|
11705 |
|
11706 |
|
11707 |
|
11708 | function markAsRoot(contents) {
|
11709 |
|
11710 | return align({
|
11711 | type: "root"
|
11712 | }, contents);
|
11713 | }
|
11714 |
|
11715 |
|
11716 |
|
11717 |
|
11718 |
|
11719 |
|
11720 | function dedent(contents) {
|
11721 | return align(-1, contents);
|
11722 | }
|
11723 |
|
11724 |
|
11725 |
|
11726 |
|
11727 |
|
11728 |
|
11729 |
|
11730 | function conditionalGroup(states, opts) {
|
11731 | return group(states[0], Object.assign({}, opts, {
|
11732 | expandedStates: states
|
11733 | }));
|
11734 | }
|
11735 |
|
11736 |
|
11737 |
|
11738 |
|
11739 |
|
11740 |
|
11741 | function fill(parts) {
|
11742 |
|
11743 | return {
|
11744 | type: "fill",
|
11745 | parts
|
11746 | };
|
11747 | }
|
11748 |
|
11749 |
|
11750 |
|
11751 |
|
11752 |
|
11753 |
|
11754 |
|
11755 |
|
11756 | function ifBreak(breakContents, flatContents, opts) {
|
11757 | opts = opts || {};
|
11758 |
|
11759 | return {
|
11760 | type: "if-break",
|
11761 | breakContents,
|
11762 | flatContents,
|
11763 | groupId: opts.groupId
|
11764 | };
|
11765 | }
|
11766 |
|
11767 |
|
11768 |
|
11769 |
|
11770 |
|
11771 |
|
11772 | function lineSuffix(contents) {
|
11773 |
|
11774 | return {
|
11775 | type: "line-suffix",
|
11776 | contents
|
11777 | };
|
11778 | }
|
11779 |
|
11780 | const lineSuffixBoundary = {
|
11781 | type: "line-suffix-boundary"
|
11782 | };
|
11783 | const breakParent = {
|
11784 | type: "break-parent"
|
11785 | };
|
11786 | const trim = {
|
11787 | type: "trim"
|
11788 | };
|
11789 | const line = {
|
11790 | type: "line"
|
11791 | };
|
11792 | const softline = {
|
11793 | type: "line",
|
11794 | soft: true
|
11795 | };
|
11796 | const hardline = concat([{
|
11797 | type: "line",
|
11798 | hard: true
|
11799 | }, breakParent]);
|
11800 | const literalline = concat([{
|
11801 | type: "line",
|
11802 | hard: true,
|
11803 | literal: true
|
11804 | }, breakParent]);
|
11805 | const cursor = {
|
11806 | type: "cursor",
|
11807 | placeholder: Symbol("cursor")
|
11808 | };
|
11809 |
|
11810 |
|
11811 |
|
11812 |
|
11813 |
|
11814 |
|
11815 | function join(sep, arr) {
|
11816 | const res = [];
|
11817 |
|
11818 | for (let i = 0; i < arr.length; i++) {
|
11819 | if (i !== 0) {
|
11820 | res.push(sep);
|
11821 | }
|
11822 |
|
11823 | res.push(arr[i]);
|
11824 | }
|
11825 |
|
11826 | return concat(res);
|
11827 | }
|
11828 |
|
11829 |
|
11830 |
|
11831 |
|
11832 |
|
11833 |
|
11834 |
|
11835 | function addAlignmentToDoc(doc, size, tabWidth) {
|
11836 | let aligned = doc;
|
11837 |
|
11838 | if (size > 0) {
|
11839 |
|
11840 | for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
|
11841 | aligned = indent(aligned);
|
11842 | }
|
11843 |
|
11844 |
|
11845 | aligned = align(size % tabWidth, aligned);
|
11846 |
|
11847 |
|
11848 | aligned = align(-Infinity, aligned);
|
11849 | }
|
11850 |
|
11851 | return aligned;
|
11852 | }
|
11853 |
|
11854 | var docBuilders = {
|
11855 | concat,
|
11856 | join,
|
11857 | line,
|
11858 | softline,
|
11859 | hardline,
|
11860 | literalline,
|
11861 | group,
|
11862 | conditionalGroup,
|
11863 | fill,
|
11864 | lineSuffix,
|
11865 | lineSuffixBoundary,
|
11866 | cursor,
|
11867 | breakParent,
|
11868 | ifBreak,
|
11869 | trim,
|
11870 | indent,
|
11871 | align,
|
11872 | addAlignmentToDoc,
|
11873 | markAsRoot,
|
11874 | dedentToRoot,
|
11875 | dedent
|
11876 | };
|
11877 |
|
11878 | var ansiRegex = ({
|
11879 | onlyFirst = false
|
11880 | } = {}) => {
|
11881 | const pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
|
11882 | return new RegExp(pattern, onlyFirst ? undefined : 'g');
|
11883 | };
|
11884 |
|
11885 | var stripAnsi = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string;
|
11886 |
|
11887 |
|
11888 |
|
11889 | const isFullwidthCodePoint = codePoint => {
|
11890 | if (Number.isNaN(codePoint)) {
|
11891 | return false;
|
11892 | }
|
11893 |
|
11894 |
|
11895 |
|
11896 | if (codePoint >= 0x1100 && (codePoint <= 0x115F ||
|
11897 | codePoint === 0x2329 ||
|
11898 | codePoint === 0x232A ||
|
11899 |
|
11900 | 0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F ||
|
11901 | 0x3250 <= codePoint && codePoint <= 0x4DBF ||
|
11902 | 0x4E00 <= codePoint && codePoint <= 0xA4C6 ||
|
11903 | 0xA960 <= codePoint && codePoint <= 0xA97C ||
|
11904 | 0xAC00 <= codePoint && codePoint <= 0xD7A3 ||
|
11905 | 0xF900 <= codePoint && codePoint <= 0xFAFF ||
|
11906 | 0xFE10 <= codePoint && codePoint <= 0xFE19 ||
|
11907 | 0xFE30 <= codePoint && codePoint <= 0xFE6B ||
|
11908 | 0xFF01 <= codePoint && codePoint <= 0xFF60 || 0xFFE0 <= codePoint && codePoint <= 0xFFE6 ||
|
11909 | 0x1B000 <= codePoint && codePoint <= 0x1B001 ||
|
11910 | 0x1F200 <= codePoint && codePoint <= 0x1F251 ||
|
11911 | 0x20000 <= codePoint && codePoint <= 0x3FFFD)) {
|
11912 | return true;
|
11913 | }
|
11914 |
|
11915 | return false;
|
11916 | };
|
11917 |
|
11918 | var isFullwidthCodePoint_1 = isFullwidthCodePoint;
|
11919 | var default_1$1 = isFullwidthCodePoint;
|
11920 | isFullwidthCodePoint_1.default = default_1$1;
|
11921 |
|
11922 | var emojiRegex = function () {
|
11923 |
|
11924 | return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
|
11925 | };
|
11926 |
|
11927 | const stringWidth = string => {
|
11928 | string = string.replace(emojiRegex(), ' ');
|
11929 |
|
11930 | if (typeof string !== 'string' || string.length === 0) {
|
11931 | return 0;
|
11932 | }
|
11933 |
|
11934 | string = stripAnsi(string);
|
11935 | let width = 0;
|
11936 |
|
11937 | for (let i = 0; i < string.length; i++) {
|
11938 | const code = string.codePointAt(i);
|
11939 |
|
11940 | if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
|
11941 | continue;
|
11942 | }
|
11943 |
|
11944 |
|
11945 | if (code >= 0x300 && code <= 0x36F) {
|
11946 | continue;
|
11947 | }
|
11948 |
|
11949 |
|
11950 | if (code > 0xFFFF) {
|
11951 | i++;
|
11952 | }
|
11953 |
|
11954 | width += isFullwidthCodePoint_1(code) ? 2 : 1;
|
11955 | }
|
11956 |
|
11957 | return width;
|
11958 | };
|
11959 |
|
11960 | var stringWidth_1 = stringWidth;
|
11961 |
|
11962 | var default_1$2 = stringWidth;
|
11963 | stringWidth_1.default = default_1$2;
|
11964 |
|
11965 | const matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g;
|
11966 |
|
11967 | var escapeStringRegexp$2 = string => {
|
11968 | if (typeof string !== 'string') {
|
11969 | throw new TypeError('Expected a string');
|
11970 | }
|
11971 |
|
11972 | return string.replace(matchOperatorsRegex, '\\$&');
|
11973 | };
|
11974 |
|
11975 | const notAsciiRegex = /[^\x20-\x7F]/;
|
11976 |
|
11977 | function getPenultimate(arr) {
|
11978 | if (arr.length > 1) {
|
11979 | return arr[arr.length - 2];
|
11980 | }
|
11981 |
|
11982 | return null;
|
11983 | }
|
11984 |
|
11985 |
|
11986 |
|
11987 |
|
11988 |
|
11989 |
|
11990 |
|
11991 |
|
11992 |
|
11993 |
|
11994 | function skip(chars) {
|
11995 | return (text, index, opts) => {
|
11996 | const backwards = opts && opts.backwards;
|
11997 |
|
11998 |
|
11999 | if (index === false) {
|
12000 | return false;
|
12001 | }
|
12002 |
|
12003 | const {
|
12004 | length
|
12005 | } = text;
|
12006 | let cursor = index;
|
12007 |
|
12008 | while (cursor >= 0 && cursor < length) {
|
12009 | const c = text.charAt(cursor);
|
12010 |
|
12011 | if (chars instanceof RegExp) {
|
12012 | if (!chars.test(c)) {
|
12013 | return cursor;
|
12014 | }
|
12015 | } else if (!chars.includes(c)) {
|
12016 | return cursor;
|
12017 | }
|
12018 |
|
12019 | backwards ? cursor-- : cursor++;
|
12020 | }
|
12021 |
|
12022 | if (cursor === -1 || cursor === length) {
|
12023 |
|
12024 |
|
12025 |
|
12026 |
|
12027 | return cursor;
|
12028 | }
|
12029 |
|
12030 | return false;
|
12031 | };
|
12032 | }
|
12033 |
|
12034 |
|
12035 |
|
12036 |
|
12037 |
|
12038 | const skipWhitespace = skip(/\s/);
|
12039 |
|
12040 |
|
12041 |
|
12042 |
|
12043 | const skipSpaces = skip(" \t");
|
12044 |
|
12045 |
|
12046 |
|
12047 |
|
12048 | const skipToLineEnd = skip(",; \t");
|
12049 |
|
12050 |
|
12051 |
|
12052 |
|
12053 | const skipEverythingButNewLine = skip(/[^\r\n]/);
|
12054 |
|
12055 |
|
12056 |
|
12057 |
|
12058 |
|
12059 |
|
12060 | function skipInlineComment(text, index) {
|
12061 | if (index === false) {
|
12062 | return false;
|
12063 | }
|
12064 |
|
12065 | if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") {
|
12066 | for (let i = index + 2; i < text.length; ++i) {
|
12067 | if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
|
12068 | return i + 2;
|
12069 | }
|
12070 | }
|
12071 | }
|
12072 |
|
12073 | return index;
|
12074 | }
|
12075 |
|
12076 |
|
12077 |
|
12078 |
|
12079 |
|
12080 |
|
12081 |
|
12082 | function skipTrailingComment(text, index) {
|
12083 | if (index === false) {
|
12084 | return false;
|
12085 | }
|
12086 |
|
12087 | if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") {
|
12088 | return skipEverythingButNewLine(text, index);
|
12089 | }
|
12090 |
|
12091 | return index;
|
12092 | }
|
12093 |
|
12094 |
|
12095 |
|
12096 |
|
12097 |
|
12098 |
|
12099 |
|
12100 |
|
12101 |
|
12102 |
|
12103 |
|
12104 | function skipNewline(text, index, opts) {
|
12105 | const backwards = opts && opts.backwards;
|
12106 |
|
12107 | if (index === false) {
|
12108 | return false;
|
12109 | }
|
12110 |
|
12111 | const atIndex = text.charAt(index);
|
12112 |
|
12113 | if (backwards) {
|
12114 | if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
|
12115 | return index - 2;
|
12116 | }
|
12117 |
|
12118 | if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
|
12119 | return index - 1;
|
12120 | }
|
12121 | } else {
|
12122 | if (atIndex === "\r" && text.charAt(index + 1) === "\n") {
|
12123 | return index + 2;
|
12124 | }
|
12125 |
|
12126 | if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
|
12127 | return index + 1;
|
12128 | }
|
12129 | }
|
12130 |
|
12131 | return index;
|
12132 | }
|
12133 |
|
12134 |
|
12135 |
|
12136 |
|
12137 |
|
12138 |
|
12139 |
|
12140 |
|
12141 | function hasNewline(text, index, opts) {
|
12142 | opts = opts || {};
|
12143 | const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
|
12144 | const idx2 = skipNewline(text, idx, opts);
|
12145 | return idx !== idx2;
|
12146 | }
|
12147 |
|
12148 |
|
12149 |
|
12150 |
|
12151 |
|
12152 |
|
12153 |
|
12154 |
|
12155 | function hasNewlineInRange(text, start, end) {
|
12156 | for (let i = start; i < end; ++i) {
|
12157 | if (text.charAt(i) === "\n") {
|
12158 | return true;
|
12159 | }
|
12160 | }
|
12161 |
|
12162 | return false;
|
12163 | }
|
12164 |
|
12165 |
|
12166 |
|
12167 |
|
12168 |
|
12169 |
|
12170 |
|
12171 |
|
12172 |
|
12173 | function isPreviousLineEmpty(text, node, locStart) {
|
12174 |
|
12175 | let idx = locStart(node) - 1;
|
12176 | idx = skipSpaces(text, idx, {
|
12177 | backwards: true
|
12178 | });
|
12179 | idx = skipNewline(text, idx, {
|
12180 | backwards: true
|
12181 | });
|
12182 | idx = skipSpaces(text, idx, {
|
12183 | backwards: true
|
12184 | });
|
12185 | const idx2 = skipNewline(text, idx, {
|
12186 | backwards: true
|
12187 | });
|
12188 | return idx !== idx2;
|
12189 | }
|
12190 |
|
12191 |
|
12192 |
|
12193 |
|
12194 |
|
12195 |
|
12196 |
|
12197 | function isNextLineEmptyAfterIndex(text, index) {
|
12198 |
|
12199 | let oldIdx = null;
|
12200 |
|
12201 |
|
12202 | let idx = index;
|
12203 |
|
12204 | while (idx !== oldIdx) {
|
12205 |
|
12206 | oldIdx = idx;
|
12207 | idx = skipToLineEnd(text, idx);
|
12208 | idx = skipInlineComment(text, idx);
|
12209 | idx = skipSpaces(text, idx);
|
12210 | }
|
12211 |
|
12212 | idx = skipTrailingComment(text, idx);
|
12213 | idx = skipNewline(text, idx);
|
12214 | return idx !== false && hasNewline(text, idx);
|
12215 | }
|
12216 |
|
12217 |
|
12218 |
|
12219 |
|
12220 |
|
12221 |
|
12222 |
|
12223 |
|
12224 |
|
12225 | function isNextLineEmpty(text, node, locEnd) {
|
12226 | return isNextLineEmptyAfterIndex(text, locEnd(node));
|
12227 | }
|
12228 |
|
12229 |
|
12230 |
|
12231 |
|
12232 |
|
12233 |
|
12234 |
|
12235 | function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) {
|
12236 |
|
12237 | let oldIdx = null;
|
12238 |
|
12239 |
|
12240 | let nextIdx = idx;
|
12241 |
|
12242 | while (nextIdx !== oldIdx) {
|
12243 | oldIdx = nextIdx;
|
12244 | nextIdx = skipSpaces(text, nextIdx);
|
12245 | nextIdx = skipInlineComment(text, nextIdx);
|
12246 | nextIdx = skipTrailingComment(text, nextIdx);
|
12247 | nextIdx = skipNewline(text, nextIdx);
|
12248 | }
|
12249 |
|
12250 | return nextIdx;
|
12251 | }
|
12252 |
|
12253 |
|
12254 |
|
12255 |
|
12256 |
|
12257 |
|
12258 |
|
12259 |
|
12260 |
|
12261 | function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
|
12262 | return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd(node));
|
12263 | }
|
12264 |
|
12265 |
|
12266 |
|
12267 |
|
12268 |
|
12269 |
|
12270 |
|
12271 |
|
12272 |
|
12273 | function getNextNonSpaceNonCommentCharacter(text, node, locEnd) {
|
12274 | return text.charAt(
|
12275 | getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd));
|
12276 | }
|
12277 |
|
12278 |
|
12279 |
|
12280 |
|
12281 |
|
12282 |
|
12283 |
|
12284 |
|
12285 | function hasSpaces(text, index, opts) {
|
12286 | opts = opts || {};
|
12287 | const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
|
12288 | return idx !== index;
|
12289 | }
|
12290 |
|
12291 |
|
12292 |
|
12293 |
|
12294 |
|
12295 |
|
12296 | function setLocStart(node, index) {
|
12297 | if (node.range) {
|
12298 | node.range[0] = index;
|
12299 | } else {
|
12300 | node.start = index;
|
12301 | }
|
12302 | }
|
12303 |
|
12304 |
|
12305 |
|
12306 |
|
12307 |
|
12308 |
|
12309 | function setLocEnd(node, index) {
|
12310 | if (node.range) {
|
12311 | node.range[1] = index;
|
12312 | } else {
|
12313 | node.end = index;
|
12314 | }
|
12315 | }
|
12316 |
|
12317 | const PRECEDENCE = {};
|
12318 | [["|>"], ["??"], ["||"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"]].forEach((tier, i) => {
|
12319 | tier.forEach(op => {
|
12320 | PRECEDENCE[op] = i;
|
12321 | });
|
12322 | });
|
12323 |
|
12324 | function getPrecedence(op) {
|
12325 | return PRECEDENCE[op];
|
12326 | }
|
12327 |
|
12328 | const equalityOperators = {
|
12329 | "==": true,
|
12330 | "!=": true,
|
12331 | "===": true,
|
12332 | "!==": true
|
12333 | };
|
12334 | const multiplicativeOperators = {
|
12335 | "*": true,
|
12336 | "/": true,
|
12337 | "%": true
|
12338 | };
|
12339 | const bitshiftOperators = {
|
12340 | ">>": true,
|
12341 | ">>>": true,
|
12342 | "<<": true
|
12343 | };
|
12344 |
|
12345 | function shouldFlatten(parentOp, nodeOp) {
|
12346 | if (getPrecedence(nodeOp) !== getPrecedence(parentOp)) {
|
12347 | return false;
|
12348 | }
|
12349 |
|
12350 |
|
12351 |
|
12352 | if (parentOp === "**") {
|
12353 | return false;
|
12354 | }
|
12355 |
|
12356 |
|
12357 | if (equalityOperators[parentOp] && equalityOperators[nodeOp]) {
|
12358 | return false;
|
12359 | }
|
12360 |
|
12361 |
|
12362 | if (nodeOp === "%" && multiplicativeOperators[parentOp] || parentOp === "%" && multiplicativeOperators[nodeOp]) {
|
12363 | return false;
|
12364 | }
|
12365 |
|
12366 |
|
12367 |
|
12368 | if (nodeOp !== parentOp && multiplicativeOperators[nodeOp] && multiplicativeOperators[parentOp]) {
|
12369 | return false;
|
12370 | }
|
12371 |
|
12372 |
|
12373 | if (bitshiftOperators[parentOp] && bitshiftOperators[nodeOp]) {
|
12374 | return false;
|
12375 | }
|
12376 |
|
12377 | return true;
|
12378 | }
|
12379 |
|
12380 | function isBitwiseOperator(operator) {
|
12381 | return !!bitshiftOperators[operator] || operator === "|" || operator === "^" || operator === "&";
|
12382 | }
|
12383 |
|
12384 |
|
12385 |
|
12386 |
|
12387 | function startsWithNoLookaheadToken(node, forbidFunctionClassAndDoExpr) {
|
12388 | node = getLeftMost(node);
|
12389 |
|
12390 | switch (node.type) {
|
12391 | case "FunctionExpression":
|
12392 | case "ClassExpression":
|
12393 | case "DoExpression":
|
12394 | return forbidFunctionClassAndDoExpr;
|
12395 |
|
12396 | case "ObjectExpression":
|
12397 | return true;
|
12398 |
|
12399 | case "MemberExpression":
|
12400 | case "OptionalMemberExpression":
|
12401 | return startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr);
|
12402 |
|
12403 | case "TaggedTemplateExpression":
|
12404 | if (node.tag.type === "FunctionExpression") {
|
12405 |
|
12406 | return false;
|
12407 | }
|
12408 |
|
12409 | return startsWithNoLookaheadToken(node.tag, forbidFunctionClassAndDoExpr);
|
12410 |
|
12411 | case "CallExpression":
|
12412 | case "OptionalCallExpression":
|
12413 | if (node.callee.type === "FunctionExpression") {
|
12414 |
|
12415 | return false;
|
12416 | }
|
12417 |
|
12418 | return startsWithNoLookaheadToken(node.callee, forbidFunctionClassAndDoExpr);
|
12419 |
|
12420 | case "ConditionalExpression":
|
12421 | return startsWithNoLookaheadToken(node.test, forbidFunctionClassAndDoExpr);
|
12422 |
|
12423 | case "UpdateExpression":
|
12424 | return !node.prefix && startsWithNoLookaheadToken(node.argument, forbidFunctionClassAndDoExpr);
|
12425 |
|
12426 | case "BindExpression":
|
12427 | return node.object && startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr);
|
12428 |
|
12429 | case "SequenceExpression":
|
12430 | return startsWithNoLookaheadToken(node.expressions[0], forbidFunctionClassAndDoExpr);
|
12431 |
|
12432 | case "TSAsExpression":
|
12433 | return startsWithNoLookaheadToken(node.expression, forbidFunctionClassAndDoExpr);
|
12434 |
|
12435 | default:
|
12436 | return false;
|
12437 | }
|
12438 | }
|
12439 |
|
12440 | function getLeftMost(node) {
|
12441 | if (node.left) {
|
12442 | return getLeftMost(node.left);
|
12443 | }
|
12444 |
|
12445 | return node;
|
12446 | }
|
12447 |
|
12448 |
|
12449 |
|
12450 |
|
12451 |
|
12452 |
|
12453 |
|
12454 |
|
12455 | function getAlignmentSize(value, tabWidth, startIndex) {
|
12456 | startIndex = startIndex || 0;
|
12457 | let size = 0;
|
12458 |
|
12459 | for (let i = startIndex; i < value.length; ++i) {
|
12460 | if (value[i] === "\t") {
|
12461 |
|
12462 |
|
12463 |
|
12464 |
|
12465 | size = size + tabWidth - size % tabWidth;
|
12466 | } else {
|
12467 | size++;
|
12468 | }
|
12469 | }
|
12470 |
|
12471 | return size;
|
12472 | }
|
12473 |
|
12474 |
|
12475 |
|
12476 |
|
12477 |
|
12478 |
|
12479 |
|
12480 | function getIndentSize(value, tabWidth) {
|
12481 | const lastNewlineIndex = value.lastIndexOf("\n");
|
12482 |
|
12483 | if (lastNewlineIndex === -1) {
|
12484 | return 0;
|
12485 | }
|
12486 |
|
12487 | return getAlignmentSize(
|
12488 | value.slice(lastNewlineIndex + 1).match(/^[ \t]*/)[0], tabWidth);
|
12489 | }
|
12490 |
|
12491 |
|
12492 |
|
12493 |
|
12494 |
|
12495 |
|
12496 |
|
12497 |
|
12498 |
|
12499 |
|
12500 |
|
12501 |
|
12502 | function getPreferredQuote(raw, preferredQuote) {
|
12503 |
|
12504 |
|
12505 | const rawContent = raw.slice(1, -1);
|
12506 |
|
12507 |
|
12508 | const double = {
|
12509 | quote: '"',
|
12510 | regex: /"/g
|
12511 | };
|
12512 |
|
12513 |
|
12514 | const single = {
|
12515 | quote: "'",
|
12516 | regex: /'/g
|
12517 | };
|
12518 | const preferred = preferredQuote === "'" ? single : double;
|
12519 | const alternate = preferred === single ? double : single;
|
12520 | let result = preferred.quote;
|
12521 |
|
12522 |
|
12523 |
|
12524 | if (rawContent.includes(preferred.quote) || rawContent.includes(alternate.quote)) {
|
12525 | const numPreferredQuotes = (rawContent.match(preferred.regex) || []).length;
|
12526 | const numAlternateQuotes = (rawContent.match(alternate.regex) || []).length;
|
12527 | result = numPreferredQuotes > numAlternateQuotes ? alternate.quote : preferred.quote;
|
12528 | }
|
12529 |
|
12530 | return result;
|
12531 | }
|
12532 |
|
12533 | function printString(raw, options, isDirectiveLiteral) {
|
12534 |
|
12535 |
|
12536 | const rawContent = raw.slice(1, -1);
|
12537 |
|
12538 |
|
12539 | const canChangeDirectiveQuotes = !rawContent.includes('"') && !rawContent.includes("'");
|
12540 |
|
12541 |
|
12542 | const enclosingQuote = options.parser === "json" ? '"' : options.__isInHtmlAttribute ? "'" : getPreferredQuote(raw, options.singleQuote ? "'" : '"');
|
12543 |
|
12544 |
|
12545 |
|
12546 |
|
12547 | if (isDirectiveLiteral) {
|
12548 | if (canChangeDirectiveQuotes) {
|
12549 | return enclosingQuote + rawContent + enclosingQuote;
|
12550 | }
|
12551 |
|
12552 | return raw;
|
12553 | }
|
12554 |
|
12555 |
|
12556 |
|
12557 |
|
12558 |
|
12559 | return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.embeddedInHtml));
|
12560 | }
|
12561 |
|
12562 |
|
12563 |
|
12564 |
|
12565 |
|
12566 |
|
12567 |
|
12568 |
|
12569 | function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
|
12570 | const otherQuote = enclosingQuote === '"' ? "'" : '"';
|
12571 |
|
12572 | const regex = /\\([\s\S])|(['"])/g;
|
12573 |
|
12574 |
|
12575 | const newContent = rawContent.replace(regex, (match, escaped, quote) => {
|
12576 |
|
12577 |
|
12578 |
|
12579 | if (escaped === otherQuote) {
|
12580 | return escaped;
|
12581 | }
|
12582 |
|
12583 |
|
12584 |
|
12585 |
|
12586 | if (quote === enclosingQuote) {
|
12587 | return "\\" + quote;
|
12588 | }
|
12589 |
|
12590 | if (quote) {
|
12591 | return quote;
|
12592 | }
|
12593 |
|
12594 |
|
12595 |
|
12596 | return unescapeUnnecessaryEscapes && /^[^\\nrvtbfux\r\n\u2028\u2029"'0-7]$/.test(escaped) ? escaped : "\\" + escaped;
|
12597 | });
|
12598 | return enclosingQuote + newContent + enclosingQuote;
|
12599 | }
|
12600 |
|
12601 | function printNumber(rawNumber) {
|
12602 | return rawNumber.toLowerCase()
|
12603 | .replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/, "$1$2$3")
|
12604 | .replace(/^([+-]?[\d.]+)e[+-]?0+$/, "$1")
|
12605 | .replace(/^([+-])?\./, "$10.")
|
12606 | .replace(/(\.\d+?)0+(?=e|$)/, "$1")
|
12607 | .replace(/\.(?=e|$)/, "");
|
12608 | }
|
12609 |
|
12610 |
|
12611 |
|
12612 |
|
12613 |
|
12614 |
|
12615 |
|
12616 | function getMaxContinuousCount(str, target) {
|
12617 | const results = str.match(new RegExp(`(${escapeStringRegexp$2(target)})+`, "g"));
|
12618 |
|
12619 | if (results === null) {
|
12620 | return 0;
|
12621 | }
|
12622 |
|
12623 | return results.reduce((maxCount, result) => Math.max(maxCount, result.length / target.length), 0);
|
12624 | }
|
12625 |
|
12626 | function getMinNotPresentContinuousCount(str, target) {
|
12627 | const matches = str.match(new RegExp(`(${escapeStringRegexp$2(target)})+`, "g"));
|
12628 |
|
12629 | if (matches === null) {
|
12630 | return 0;
|
12631 | }
|
12632 |
|
12633 | const countPresent = new Map();
|
12634 | let max = 0;
|
12635 |
|
12636 | for (const match of matches) {
|
12637 | const count = match.length / target.length;
|
12638 | countPresent.set(count, true);
|
12639 |
|
12640 | if (count > max) {
|
12641 | max = count;
|
12642 | }
|
12643 | }
|
12644 |
|
12645 | for (let i = 1; i < max; i++) {
|
12646 | if (!countPresent.get(i)) {
|
12647 | return i;
|
12648 | }
|
12649 | }
|
12650 |
|
12651 | return max + 1;
|
12652 | }
|
12653 |
|
12654 |
|
12655 |
|
12656 |
|
12657 |
|
12658 |
|
12659 | function getStringWidth(text) {
|
12660 | if (!text) {
|
12661 | return 0;
|
12662 | }
|
12663 |
|
12664 |
|
12665 | if (!notAsciiRegex.test(text)) {
|
12666 | return text.length;
|
12667 | }
|
12668 |
|
12669 | return stringWidth_1(text);
|
12670 | }
|
12671 |
|
12672 | function hasIgnoreComment(path) {
|
12673 | const node = path.getValue();
|
12674 | return hasNodeIgnoreComment(node);
|
12675 | }
|
12676 |
|
12677 | function hasNodeIgnoreComment(node) {
|
12678 | return node && (node.comments && node.comments.length > 0 && node.comments.some(comment => isNodeIgnoreComment(comment) && !comment.unignore) || node.prettierIgnore);
|
12679 | }
|
12680 |
|
12681 | function isNodeIgnoreComment(comment) {
|
12682 | return comment.value.trim() === "prettier-ignore";
|
12683 | }
|
12684 |
|
12685 | function addCommentHelper(node, comment) {
|
12686 | const comments = node.comments || (node.comments = []);
|
12687 | comments.push(comment);
|
12688 | comment.printed = false;
|
12689 |
|
12690 |
|
12691 |
|
12692 | if (node.type === "JSXText") {
|
12693 | comment.printed = true;
|
12694 | }
|
12695 | }
|
12696 |
|
12697 | function addLeadingComment(node, comment) {
|
12698 | comment.leading = true;
|
12699 | comment.trailing = false;
|
12700 | addCommentHelper(node, comment);
|
12701 | }
|
12702 |
|
12703 | function addDanglingComment(node, comment) {
|
12704 | comment.leading = false;
|
12705 | comment.trailing = false;
|
12706 | addCommentHelper(node, comment);
|
12707 | }
|
12708 |
|
12709 | function addTrailingComment(node, comment) {
|
12710 | comment.leading = false;
|
12711 | comment.trailing = true;
|
12712 | addCommentHelper(node, comment);
|
12713 | }
|
12714 |
|
12715 | function isWithinParentArrayProperty(path, propertyName) {
|
12716 | const node = path.getValue();
|
12717 | const parent = path.getParentNode();
|
12718 |
|
12719 | if (parent == null) {
|
12720 | return false;
|
12721 | }
|
12722 |
|
12723 | if (!Array.isArray(parent[propertyName])) {
|
12724 | return false;
|
12725 | }
|
12726 |
|
12727 | const key = path.getName();
|
12728 | return parent[propertyName][key] === node;
|
12729 | }
|
12730 |
|
12731 | function replaceEndOfLineWith(text, replacement) {
|
12732 | const parts = [];
|
12733 |
|
12734 | for (const part of text.split("\n")) {
|
12735 | if (parts.length !== 0) {
|
12736 | parts.push(replacement);
|
12737 | }
|
12738 |
|
12739 | parts.push(part);
|
12740 | }
|
12741 |
|
12742 | return parts;
|
12743 | }
|
12744 |
|
12745 | var util$1 = {
|
12746 | replaceEndOfLineWith,
|
12747 | getStringWidth,
|
12748 | getMaxContinuousCount,
|
12749 | getMinNotPresentContinuousCount,
|
12750 | getPrecedence,
|
12751 | shouldFlatten,
|
12752 | isBitwiseOperator,
|
12753 | getPenultimate,
|
12754 | getLast,
|
12755 | getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
|
12756 | getNextNonSpaceNonCommentCharacterIndex,
|
12757 | getNextNonSpaceNonCommentCharacter,
|
12758 | skip,
|
12759 | skipWhitespace,
|
12760 | skipSpaces,
|
12761 | skipToLineEnd,
|
12762 | skipEverythingButNewLine,
|
12763 | skipInlineComment,
|
12764 | skipTrailingComment,
|
12765 | skipNewline,
|
12766 | isNextLineEmptyAfterIndex,
|
12767 | isNextLineEmpty,
|
12768 | isPreviousLineEmpty,
|
12769 | hasNewline,
|
12770 | hasNewlineInRange,
|
12771 | hasSpaces,
|
12772 | setLocStart,
|
12773 | setLocEnd,
|
12774 | startsWithNoLookaheadToken,
|
12775 | getAlignmentSize,
|
12776 | getIndentSize,
|
12777 | getPreferredQuote,
|
12778 | printString,
|
12779 | printNumber,
|
12780 | hasIgnoreComment,
|
12781 | hasNodeIgnoreComment,
|
12782 | isNodeIgnoreComment,
|
12783 | makeString,
|
12784 | addLeadingComment,
|
12785 | addDanglingComment,
|
12786 | addTrailingComment,
|
12787 | isWithinParentArrayProperty
|
12788 | };
|
12789 |
|
12790 | function guessEndOfLine(text) {
|
12791 | const index = text.indexOf("\r");
|
12792 |
|
12793 | if (index >= 0) {
|
12794 | return text.charAt(index + 1) === "\n" ? "crlf" : "cr";
|
12795 | }
|
12796 |
|
12797 | return "lf";
|
12798 | }
|
12799 |
|
12800 | function convertEndOfLineToChars(value) {
|
12801 | switch (value) {
|
12802 | case "cr":
|
12803 | return "\r";
|
12804 |
|
12805 | case "crlf":
|
12806 | return "\r\n";
|
12807 |
|
12808 | default:
|
12809 | return "\n";
|
12810 | }
|
12811 | }
|
12812 |
|
12813 | var endOfLine = {
|
12814 | guessEndOfLine,
|
12815 | convertEndOfLineToChars
|
12816 | };
|
12817 |
|
12818 | const {
|
12819 | getStringWidth: getStringWidth$1
|
12820 | } = util$1;
|
12821 | const {
|
12822 | convertEndOfLineToChars: convertEndOfLineToChars$1
|
12823 | } = endOfLine;
|
12824 | const {
|
12825 | concat: concat$1,
|
12826 | fill: fill$1,
|
12827 | cursor: cursor$1
|
12828 | } = docBuilders;
|
12829 |
|
12830 |
|
12831 | let groupModeMap;
|
12832 | const MODE_BREAK = 1;
|
12833 | const MODE_FLAT = 2;
|
12834 |
|
12835 | function rootIndent() {
|
12836 | return {
|
12837 | value: "",
|
12838 | length: 0,
|
12839 | queue: []
|
12840 | };
|
12841 | }
|
12842 |
|
12843 | function makeIndent(ind, options) {
|
12844 | return generateInd(ind, {
|
12845 | type: "indent"
|
12846 | }, options);
|
12847 | }
|
12848 |
|
12849 | function makeAlign(ind, n, options) {
|
12850 | return n === -Infinity ? ind.root || rootIndent() : n < 0 ? generateInd(ind, {
|
12851 | type: "dedent"
|
12852 | }, options) : !n ? ind : n.type === "root" ? Object.assign({}, ind, {
|
12853 | root: ind
|
12854 | }) : typeof n === "string" ? generateInd(ind, {
|
12855 | type: "stringAlign",
|
12856 | n
|
12857 | }, options) : generateInd(ind, {
|
12858 | type: "numberAlign",
|
12859 | n
|
12860 | }, options);
|
12861 | }
|
12862 |
|
12863 | function generateInd(ind, newPart, options) {
|
12864 | const queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : ind.queue.concat(newPart);
|
12865 | let value = "";
|
12866 | let length = 0;
|
12867 | let lastTabs = 0;
|
12868 | let lastSpaces = 0;
|
12869 |
|
12870 | for (const part of queue) {
|
12871 | switch (part.type) {
|
12872 | case "indent":
|
12873 | flush();
|
12874 |
|
12875 | if (options.useTabs) {
|
12876 | addTabs(1);
|
12877 | } else {
|
12878 | addSpaces(options.tabWidth);
|
12879 | }
|
12880 |
|
12881 | break;
|
12882 |
|
12883 | case "stringAlign":
|
12884 | flush();
|
12885 | value += part.n;
|
12886 | length += part.n.length;
|
12887 | break;
|
12888 |
|
12889 | case "numberAlign":
|
12890 | lastTabs += 1;
|
12891 | lastSpaces += part.n;
|
12892 | break;
|
12893 |
|
12894 |
|
12895 |
|
12896 | default:
|
12897 | throw new Error(`Unexpected type '${part.type}'`);
|
12898 | }
|
12899 | }
|
12900 |
|
12901 | flushSpaces();
|
12902 | return Object.assign({}, ind, {
|
12903 | value,
|
12904 | length,
|
12905 | queue
|
12906 | });
|
12907 |
|
12908 | function addTabs(count) {
|
12909 | value += "\t".repeat(count);
|
12910 | length += options.tabWidth * count;
|
12911 | }
|
12912 |
|
12913 | function addSpaces(count) {
|
12914 | value += " ".repeat(count);
|
12915 | length += count;
|
12916 | }
|
12917 |
|
12918 | function flush() {
|
12919 | if (options.useTabs) {
|
12920 | flushTabs();
|
12921 | } else {
|
12922 | flushSpaces();
|
12923 | }
|
12924 | }
|
12925 |
|
12926 | function flushTabs() {
|
12927 | if (lastTabs > 0) {
|
12928 | addTabs(lastTabs);
|
12929 | }
|
12930 |
|
12931 | resetLast();
|
12932 | }
|
12933 |
|
12934 | function flushSpaces() {
|
12935 | if (lastSpaces > 0) {
|
12936 | addSpaces(lastSpaces);
|
12937 | }
|
12938 |
|
12939 | resetLast();
|
12940 | }
|
12941 |
|
12942 | function resetLast() {
|
12943 | lastTabs = 0;
|
12944 | lastSpaces = 0;
|
12945 | }
|
12946 | }
|
12947 |
|
12948 | function trim$1(out) {
|
12949 | if (out.length === 0) {
|
12950 | return 0;
|
12951 | }
|
12952 |
|
12953 | let trimCount = 0;
|
12954 |
|
12955 | while (out.length > 0 && typeof out[out.length - 1] === "string" && out[out.length - 1].match(/^[ \t]*$/)) {
|
12956 | trimCount += out.pop().length;
|
12957 | }
|
12958 |
|
12959 | if (out.length && typeof out[out.length - 1] === "string") {
|
12960 | const trimmed = out[out.length - 1].replace(/[ \t]*$/, "");
|
12961 | trimCount += out[out.length - 1].length - trimmed.length;
|
12962 | out[out.length - 1] = trimmed;
|
12963 | }
|
12964 |
|
12965 | return trimCount;
|
12966 | }
|
12967 |
|
12968 | function fits(next, restCommands, width, options, mustBeFlat) {
|
12969 | let restIdx = restCommands.length;
|
12970 | const cmds = [next];
|
12971 |
|
12972 |
|
12973 | const out = [];
|
12974 |
|
12975 | while (width >= 0) {
|
12976 | if (cmds.length === 0) {
|
12977 | if (restIdx === 0) {
|
12978 | return true;
|
12979 | }
|
12980 |
|
12981 | cmds.push(restCommands[restIdx - 1]);
|
12982 | restIdx--;
|
12983 | continue;
|
12984 | }
|
12985 |
|
12986 | const [ind, mode, doc] = cmds.pop();
|
12987 |
|
12988 | if (typeof doc === "string") {
|
12989 | out.push(doc);
|
12990 | width -= getStringWidth$1(doc);
|
12991 | } else {
|
12992 | switch (doc.type) {
|
12993 | case "concat":
|
12994 | for (let i = doc.parts.length - 1; i >= 0; i--) {
|
12995 | cmds.push([ind, mode, doc.parts[i]]);
|
12996 | }
|
12997 |
|
12998 | break;
|
12999 |
|
13000 | case "indent":
|
13001 | cmds.push([makeIndent(ind, options), mode, doc.contents]);
|
13002 | break;
|
13003 |
|
13004 | case "align":
|
13005 | cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]);
|
13006 | break;
|
13007 |
|
13008 | case "trim":
|
13009 | width += trim$1(out);
|
13010 | break;
|
13011 |
|
13012 | case "group":
|
13013 | if (mustBeFlat && doc.break) {
|
13014 | return false;
|
13015 | }
|
13016 |
|
13017 | cmds.push([ind, doc.break ? MODE_BREAK : mode, doc.contents]);
|
13018 |
|
13019 | if (doc.id) {
|
13020 | groupModeMap[doc.id] = cmds[cmds.length - 1][1];
|
13021 | }
|
13022 |
|
13023 | break;
|
13024 |
|
13025 | case "fill":
|
13026 | for (let i = doc.parts.length - 1; i >= 0; i--) {
|
13027 | cmds.push([ind, mode, doc.parts[i]]);
|
13028 | }
|
13029 |
|
13030 | break;
|
13031 |
|
13032 | case "if-break":
|
13033 | {
|
13034 | const groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
|
13035 |
|
13036 | if (groupMode === MODE_BREAK) {
|
13037 | if (doc.breakContents) {
|
13038 | cmds.push([ind, mode, doc.breakContents]);
|
13039 | }
|
13040 | }
|
13041 |
|
13042 | if (groupMode === MODE_FLAT) {
|
13043 | if (doc.flatContents) {
|
13044 | cmds.push([ind, mode, doc.flatContents]);
|
13045 | }
|
13046 | }
|
13047 |
|
13048 | break;
|
13049 | }
|
13050 |
|
13051 | case "line":
|
13052 | switch (mode) {
|
13053 |
|
13054 | case MODE_FLAT:
|
13055 | if (!doc.hard) {
|
13056 | if (!doc.soft) {
|
13057 | out.push(" ");
|
13058 | width -= 1;
|
13059 | }
|
13060 |
|
13061 | break;
|
13062 | }
|
13063 |
|
13064 | return true;
|
13065 |
|
13066 | case MODE_BREAK:
|
13067 | return true;
|
13068 | }
|
13069 |
|
13070 | break;
|
13071 | }
|
13072 | }
|
13073 | }
|
13074 |
|
13075 | return false;
|
13076 | }
|
13077 |
|
13078 | function printDocToString(doc, options) {
|
13079 | groupModeMap = {};
|
13080 | const width = options.printWidth;
|
13081 | const newLine = convertEndOfLineToChars$1(options.endOfLine);
|
13082 | let pos = 0;
|
13083 |
|
13084 |
|
13085 |
|
13086 | const cmds = [[rootIndent(), MODE_BREAK, doc]];
|
13087 | const out = [];
|
13088 | let shouldRemeasure = false;
|
13089 | let lineSuffix = [];
|
13090 |
|
13091 | while (cmds.length !== 0) {
|
13092 | const [ind, mode, doc] = cmds.pop();
|
13093 |
|
13094 | if (typeof doc === "string") {
|
13095 | const formatted = newLine !== "\n" && doc.includes("\n") ? doc.replace(/\n/g, newLine) : doc;
|
13096 | out.push(formatted);
|
13097 | pos += getStringWidth$1(formatted);
|
13098 | } else {
|
13099 | switch (doc.type) {
|
13100 | case "cursor":
|
13101 | out.push(cursor$1.placeholder);
|
13102 | break;
|
13103 |
|
13104 | case "concat":
|
13105 | for (let i = doc.parts.length - 1; i >= 0; i--) {
|
13106 | cmds.push([ind, mode, doc.parts[i]]);
|
13107 | }
|
13108 |
|
13109 | break;
|
13110 |
|
13111 | case "indent":
|
13112 | cmds.push([makeIndent(ind, options), mode, doc.contents]);
|
13113 | break;
|
13114 |
|
13115 | case "align":
|
13116 | cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]);
|
13117 | break;
|
13118 |
|
13119 | case "trim":
|
13120 | pos -= trim$1(out);
|
13121 | break;
|
13122 |
|
13123 | case "group":
|
13124 | switch (mode) {
|
13125 | case MODE_FLAT:
|
13126 | if (!shouldRemeasure) {
|
13127 | cmds.push([ind, doc.break ? MODE_BREAK : MODE_FLAT, doc.contents]);
|
13128 | break;
|
13129 | }
|
13130 |
|
13131 |
|
13132 |
|
13133 | case MODE_BREAK:
|
13134 | {
|
13135 | shouldRemeasure = false;
|
13136 | const next = [ind, MODE_FLAT, doc.contents];
|
13137 | const rem = width - pos;
|
13138 |
|
13139 | if (!doc.break && fits(next, cmds, rem, options)) {
|
13140 | cmds.push(next);
|
13141 | } else {
|
13142 |
|
13143 |
|
13144 |
|
13145 |
|
13146 |
|
13147 |
|
13148 |
|
13149 | if (doc.expandedStates) {
|
13150 | const mostExpanded = doc.expandedStates[doc.expandedStates.length - 1];
|
13151 |
|
13152 | if (doc.break) {
|
13153 | cmds.push([ind, MODE_BREAK, mostExpanded]);
|
13154 | break;
|
13155 | } else {
|
13156 | for (let i = 1; i < doc.expandedStates.length + 1; i++) {
|
13157 | if (i >= doc.expandedStates.length) {
|
13158 | cmds.push([ind, MODE_BREAK, mostExpanded]);
|
13159 | break;
|
13160 | } else {
|
13161 | const state = doc.expandedStates[i];
|
13162 | const cmd = [ind, MODE_FLAT, state];
|
13163 |
|
13164 | if (fits(cmd, cmds, rem, options)) {
|
13165 | cmds.push(cmd);
|
13166 | break;
|
13167 | }
|
13168 | }
|
13169 | }
|
13170 | }
|
13171 | } else {
|
13172 | cmds.push([ind, MODE_BREAK, doc.contents]);
|
13173 | }
|
13174 | }
|
13175 |
|
13176 | break;
|
13177 | }
|
13178 | }
|
13179 |
|
13180 | if (doc.id) {
|
13181 | groupModeMap[doc.id] = cmds[cmds.length - 1][1];
|
13182 | }
|
13183 |
|
13184 | break;
|
13185 |
|
13186 |
|
13187 |
|
13188 |
|
13189 |
|
13190 |
|
13191 |
|
13192 |
|
13193 |
|
13194 |
|
13195 |
|
13196 |
|
13197 |
|
13198 |
|
13199 |
|
13200 |
|
13201 |
|
13202 |
|
13203 |
|
13204 |
|
13205 |
|
13206 | case "fill":
|
13207 | {
|
13208 | const rem = width - pos;
|
13209 | const {
|
13210 | parts
|
13211 | } = doc;
|
13212 |
|
13213 | if (parts.length === 0) {
|
13214 | break;
|
13215 | }
|
13216 |
|
13217 | const [content, whitespace] = parts;
|
13218 | const contentFlatCmd = [ind, MODE_FLAT, content];
|
13219 | const contentBreakCmd = [ind, MODE_BREAK, content];
|
13220 | const contentFits = fits(contentFlatCmd, [], rem, options, true);
|
13221 |
|
13222 | if (parts.length === 1) {
|
13223 | if (contentFits) {
|
13224 | cmds.push(contentFlatCmd);
|
13225 | } else {
|
13226 | cmds.push(contentBreakCmd);
|
13227 | }
|
13228 |
|
13229 | break;
|
13230 | }
|
13231 |
|
13232 | const whitespaceFlatCmd = [ind, MODE_FLAT, whitespace];
|
13233 | const whitespaceBreakCmd = [ind, MODE_BREAK, whitespace];
|
13234 |
|
13235 | if (parts.length === 2) {
|
13236 | if (contentFits) {
|
13237 | cmds.push(whitespaceFlatCmd);
|
13238 | cmds.push(contentFlatCmd);
|
13239 | } else {
|
13240 | cmds.push(whitespaceBreakCmd);
|
13241 | cmds.push(contentBreakCmd);
|
13242 | }
|
13243 |
|
13244 | break;
|
13245 | }
|
13246 |
|
13247 |
|
13248 |
|
13249 |
|
13250 |
|
13251 |
|
13252 | parts.splice(0, 2);
|
13253 | const remainingCmd = [ind, mode, fill$1(parts)];
|
13254 | const secondContent = parts[0];
|
13255 | const firstAndSecondContentFlatCmd = [ind, MODE_FLAT, concat$1([content, whitespace, secondContent])];
|
13256 | const firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], rem, options, true);
|
13257 |
|
13258 | if (firstAndSecondContentFits) {
|
13259 | cmds.push(remainingCmd);
|
13260 | cmds.push(whitespaceFlatCmd);
|
13261 | cmds.push(contentFlatCmd);
|
13262 | } else if (contentFits) {
|
13263 | cmds.push(remainingCmd);
|
13264 | cmds.push(whitespaceBreakCmd);
|
13265 | cmds.push(contentFlatCmd);
|
13266 | } else {
|
13267 | cmds.push(remainingCmd);
|
13268 | cmds.push(whitespaceBreakCmd);
|
13269 | cmds.push(contentBreakCmd);
|
13270 | }
|
13271 |
|
13272 | break;
|
13273 | }
|
13274 |
|
13275 | case "if-break":
|
13276 | {
|
13277 | const groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
|
13278 |
|
13279 | if (groupMode === MODE_BREAK) {
|
13280 | if (doc.breakContents) {
|
13281 | cmds.push([ind, mode, doc.breakContents]);
|
13282 | }
|
13283 | }
|
13284 |
|
13285 | if (groupMode === MODE_FLAT) {
|
13286 | if (doc.flatContents) {
|
13287 | cmds.push([ind, mode, doc.flatContents]);
|
13288 | }
|
13289 | }
|
13290 |
|
13291 | break;
|
13292 | }
|
13293 |
|
13294 | case "line-suffix":
|
13295 | lineSuffix.push([ind, mode, doc.contents]);
|
13296 | break;
|
13297 |
|
13298 | case "line-suffix-boundary":
|
13299 | if (lineSuffix.length > 0) {
|
13300 | cmds.push([ind, mode, {
|
13301 | type: "line",
|
13302 | hard: true
|
13303 | }]);
|
13304 | }
|
13305 |
|
13306 | break;
|
13307 |
|
13308 | case "line":
|
13309 | switch (mode) {
|
13310 | case MODE_FLAT:
|
13311 | if (!doc.hard) {
|
13312 | if (!doc.soft) {
|
13313 | out.push(" ");
|
13314 | pos += 1;
|
13315 | }
|
13316 |
|
13317 | break;
|
13318 | } else {
|
13319 |
|
13320 |
|
13321 |
|
13322 |
|
13323 |
|
13324 |
|
13325 | shouldRemeasure = true;
|
13326 | }
|
13327 |
|
13328 |
|
13329 |
|
13330 | case MODE_BREAK:
|
13331 | if (lineSuffix.length) {
|
13332 | cmds.push([ind, mode, doc]);
|
13333 | cmds.push(...lineSuffix.reverse());
|
13334 | lineSuffix = [];
|
13335 | break;
|
13336 | }
|
13337 |
|
13338 | if (doc.literal) {
|
13339 | if (ind.root) {
|
13340 | out.push(newLine, ind.root.value);
|
13341 | pos = ind.root.length;
|
13342 | } else {
|
13343 | out.push(newLine);
|
13344 | pos = 0;
|
13345 | }
|
13346 | } else {
|
13347 | pos -= trim$1(out);
|
13348 | out.push(newLine + ind.value);
|
13349 | pos = ind.length;
|
13350 | }
|
13351 |
|
13352 | break;
|
13353 | }
|
13354 |
|
13355 | break;
|
13356 | }
|
13357 | }
|
13358 | }
|
13359 |
|
13360 | const cursorPlaceholderIndex = out.indexOf(cursor$1.placeholder);
|
13361 |
|
13362 | if (cursorPlaceholderIndex !== -1) {
|
13363 | const otherCursorPlaceholderIndex = out.indexOf(cursor$1.placeholder, cursorPlaceholderIndex + 1);
|
13364 | const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
|
13365 | const aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
|
13366 | const afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
|
13367 | return {
|
13368 | formatted: beforeCursor + aroundCursor + afterCursor,
|
13369 | cursorNodeStart: beforeCursor.length,
|
13370 | cursorNodeText: aroundCursor
|
13371 | };
|
13372 | }
|
13373 |
|
13374 | return {
|
13375 | formatted: out.join("")
|
13376 | };
|
13377 | }
|
13378 |
|
13379 | var docPrinter = {
|
13380 | printDocToString
|
13381 | };
|
13382 |
|
13383 | const traverseDocOnExitStackMarker = {};
|
13384 |
|
13385 | function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
|
13386 | const docsStack = [doc];
|
13387 |
|
13388 | while (docsStack.length !== 0) {
|
13389 | const doc = docsStack.pop();
|
13390 |
|
13391 | if (doc === traverseDocOnExitStackMarker) {
|
13392 | onExit(docsStack.pop());
|
13393 | continue;
|
13394 | }
|
13395 |
|
13396 | let shouldRecurse = true;
|
13397 |
|
13398 | if (onEnter) {
|
13399 | if (onEnter(doc) === false) {
|
13400 | shouldRecurse = false;
|
13401 | }
|
13402 | }
|
13403 |
|
13404 | if (onExit) {
|
13405 | docsStack.push(doc);
|
13406 | docsStack.push(traverseDocOnExitStackMarker);
|
13407 | }
|
13408 |
|
13409 | if (shouldRecurse) {
|
13410 |
|
13411 |
|
13412 |
|
13413 |
|
13414 | if (doc.type === "concat" || doc.type === "fill") {
|
13415 | for (let ic = doc.parts.length, i = ic - 1; i >= 0; --i) {
|
13416 | docsStack.push(doc.parts[i]);
|
13417 | }
|
13418 | } else if (doc.type === "if-break") {
|
13419 | if (doc.flatContents) {
|
13420 | docsStack.push(doc.flatContents);
|
13421 | }
|
13422 |
|
13423 | if (doc.breakContents) {
|
13424 | docsStack.push(doc.breakContents);
|
13425 | }
|
13426 | } else if (doc.type === "group" && doc.expandedStates) {
|
13427 | if (shouldTraverseConditionalGroups) {
|
13428 | for (let ic = doc.expandedStates.length, i = ic - 1; i >= 0; --i) {
|
13429 | docsStack.push(doc.expandedStates[i]);
|
13430 | }
|
13431 | } else {
|
13432 | docsStack.push(doc.contents);
|
13433 | }
|
13434 | } else if (doc.contents) {
|
13435 | docsStack.push(doc.contents);
|
13436 | }
|
13437 | }
|
13438 | }
|
13439 | }
|
13440 |
|
13441 | function mapDoc(doc, cb) {
|
13442 | if (doc.type === "concat" || doc.type === "fill") {
|
13443 | const parts = doc.parts.map(part => mapDoc(part, cb));
|
13444 | return cb(Object.assign({}, doc, {
|
13445 | parts
|
13446 | }));
|
13447 | } else if (doc.type === "if-break") {
|
13448 | const breakContents = doc.breakContents && mapDoc(doc.breakContents, cb);
|
13449 | const flatContents = doc.flatContents && mapDoc(doc.flatContents, cb);
|
13450 | return cb(Object.assign({}, doc, {
|
13451 | breakContents,
|
13452 | flatContents
|
13453 | }));
|
13454 | } else if (doc.contents) {
|
13455 | const contents = mapDoc(doc.contents, cb);
|
13456 | return cb(Object.assign({}, doc, {
|
13457 | contents
|
13458 | }));
|
13459 | }
|
13460 |
|
13461 | return cb(doc);
|
13462 | }
|
13463 |
|
13464 | function findInDoc(doc, fn, defaultValue) {
|
13465 | let result = defaultValue;
|
13466 | let hasStopped = false;
|
13467 |
|
13468 | function findInDocOnEnterFn(doc) {
|
13469 | const maybeResult = fn(doc);
|
13470 |
|
13471 | if (maybeResult !== undefined) {
|
13472 | hasStopped = true;
|
13473 | result = maybeResult;
|
13474 | }
|
13475 |
|
13476 | if (hasStopped) {
|
13477 | return false;
|
13478 | }
|
13479 | }
|
13480 |
|
13481 | traverseDoc(doc, findInDocOnEnterFn);
|
13482 | return result;
|
13483 | }
|
13484 |
|
13485 | function isEmpty(n) {
|
13486 | return typeof n === "string" && n.length === 0;
|
13487 | }
|
13488 |
|
13489 | function isLineNextFn(doc) {
|
13490 | if (typeof doc === "string") {
|
13491 | return false;
|
13492 | }
|
13493 |
|
13494 | if (doc.type === "line") {
|
13495 | return true;
|
13496 | }
|
13497 | }
|
13498 |
|
13499 | function isLineNext(doc) {
|
13500 | return findInDoc(doc, isLineNextFn, false);
|
13501 | }
|
13502 |
|
13503 | function willBreakFn(doc) {
|
13504 | if (doc.type === "group" && doc.break) {
|
13505 | return true;
|
13506 | }
|
13507 |
|
13508 | if (doc.type === "line" && doc.hard) {
|
13509 | return true;
|
13510 | }
|
13511 |
|
13512 | if (doc.type === "break-parent") {
|
13513 | return true;
|
13514 | }
|
13515 | }
|
13516 |
|
13517 | function willBreak(doc) {
|
13518 | return findInDoc(doc, willBreakFn, false);
|
13519 | }
|
13520 |
|
13521 | function breakParentGroup(groupStack) {
|
13522 | if (groupStack.length > 0) {
|
13523 | const parentGroup = groupStack[groupStack.length - 1];
|
13524 |
|
13525 |
|
13526 | if (!parentGroup.expandedStates) {
|
13527 | parentGroup.break = true;
|
13528 | }
|
13529 | }
|
13530 |
|
13531 | return null;
|
13532 | }
|
13533 |
|
13534 | function propagateBreaks(doc) {
|
13535 | const alreadyVisitedSet = new Set();
|
13536 | const groupStack = [];
|
13537 |
|
13538 | function propagateBreaksOnEnterFn(doc) {
|
13539 | if (doc.type === "break-parent") {
|
13540 | breakParentGroup(groupStack);
|
13541 | }
|
13542 |
|
13543 | if (doc.type === "group") {
|
13544 | groupStack.push(doc);
|
13545 |
|
13546 | if (alreadyVisitedSet.has(doc)) {
|
13547 | return false;
|
13548 | }
|
13549 |
|
13550 | alreadyVisitedSet.add(doc);
|
13551 | }
|
13552 | }
|
13553 |
|
13554 | function propagateBreaksOnExitFn(doc) {
|
13555 | if (doc.type === "group") {
|
13556 | const group = groupStack.pop();
|
13557 |
|
13558 | if (group.break) {
|
13559 | breakParentGroup(groupStack);
|
13560 | }
|
13561 | }
|
13562 | }
|
13563 |
|
13564 | traverseDoc(doc, propagateBreaksOnEnterFn, propagateBreaksOnExitFn,
|
13565 |
|
13566 | true);
|
13567 | }
|
13568 |
|
13569 | function removeLinesFn(doc) {
|
13570 |
|
13571 |
|
13572 |
|
13573 |
|
13574 | if (doc.type === "line" && !doc.hard) {
|
13575 | return doc.soft ? "" : " ";
|
13576 | } else if (doc.type === "if-break") {
|
13577 | return doc.flatContents || "";
|
13578 | }
|
13579 |
|
13580 | return doc;
|
13581 | }
|
13582 |
|
13583 | function removeLines(doc) {
|
13584 | return mapDoc(doc, removeLinesFn);
|
13585 | }
|
13586 |
|
13587 | function stripTrailingHardline(doc) {
|
13588 |
|
13589 | if (doc.type === "concat" && doc.parts.length !== 0) {
|
13590 | const lastPart = doc.parts[doc.parts.length - 1];
|
13591 |
|
13592 | if (lastPart.type === "concat") {
|
13593 | if (lastPart.parts.length === 2 && lastPart.parts[0].hard && lastPart.parts[1].type === "break-parent") {
|
13594 | return {
|
13595 | type: "concat",
|
13596 | parts: doc.parts.slice(0, -1)
|
13597 | };
|
13598 | }
|
13599 |
|
13600 | return {
|
13601 | type: "concat",
|
13602 | parts: doc.parts.slice(0, -1).concat(stripTrailingHardline(lastPart))
|
13603 | };
|
13604 | }
|
13605 | }
|
13606 |
|
13607 | return doc;
|
13608 | }
|
13609 |
|
13610 | var docUtils = {
|
13611 | isEmpty,
|
13612 | willBreak,
|
13613 | isLineNext,
|
13614 | traverseDoc,
|
13615 | findInDoc,
|
13616 | mapDoc,
|
13617 | propagateBreaks,
|
13618 | removeLines,
|
13619 | stripTrailingHardline
|
13620 | };
|
13621 |
|
13622 | function flattenDoc(doc) {
|
13623 | if (doc.type === "concat") {
|
13624 | const res = [];
|
13625 |
|
13626 | for (let i = 0; i < doc.parts.length; ++i) {
|
13627 | const doc2 = doc.parts[i];
|
13628 |
|
13629 | if (typeof doc2 !== "string" && doc2.type === "concat") {
|
13630 | res.push(...flattenDoc(doc2).parts);
|
13631 | } else {
|
13632 | const flattened = flattenDoc(doc2);
|
13633 |
|
13634 | if (flattened !== "") {
|
13635 | res.push(flattened);
|
13636 | }
|
13637 | }
|
13638 | }
|
13639 |
|
13640 | return Object.assign({}, doc, {
|
13641 | parts: res
|
13642 | });
|
13643 | } else if (doc.type === "if-break") {
|
13644 | return Object.assign({}, doc, {
|
13645 | breakContents: doc.breakContents != null ? flattenDoc(doc.breakContents) : null,
|
13646 | flatContents: doc.flatContents != null ? flattenDoc(doc.flatContents) : null
|
13647 | });
|
13648 | } else if (doc.type === "group") {
|
13649 | return Object.assign({}, doc, {
|
13650 | contents: flattenDoc(doc.contents),
|
13651 | expandedStates: doc.expandedStates ? doc.expandedStates.map(flattenDoc) : doc.expandedStates
|
13652 | });
|
13653 | } else if (doc.contents) {
|
13654 | return Object.assign({}, doc, {
|
13655 | contents: flattenDoc(doc.contents)
|
13656 | });
|
13657 | }
|
13658 |
|
13659 | return doc;
|
13660 | }
|
13661 |
|
13662 | function printDoc(doc) {
|
13663 | if (typeof doc === "string") {
|
13664 | return JSON.stringify(doc);
|
13665 | }
|
13666 |
|
13667 | if (doc.type === "line") {
|
13668 | if (doc.literal) {
|
13669 | return "literalline";
|
13670 | }
|
13671 |
|
13672 | if (doc.hard) {
|
13673 | return "hardline";
|
13674 | }
|
13675 |
|
13676 | if (doc.soft) {
|
13677 | return "softline";
|
13678 | }
|
13679 |
|
13680 | return "line";
|
13681 | }
|
13682 |
|
13683 | if (doc.type === "break-parent") {
|
13684 | return "breakParent";
|
13685 | }
|
13686 |
|
13687 | if (doc.type === "trim") {
|
13688 | return "trim";
|
13689 | }
|
13690 |
|
13691 | if (doc.type === "concat") {
|
13692 | return "[" + doc.parts.map(printDoc).join(", ") + "]";
|
13693 | }
|
13694 |
|
13695 | if (doc.type === "indent") {
|
13696 | return "indent(" + printDoc(doc.contents) + ")";
|
13697 | }
|
13698 |
|
13699 | if (doc.type === "align") {
|
13700 | return doc.n === -Infinity ? "dedentToRoot(" + printDoc(doc.contents) + ")" : doc.n < 0 ? "dedent(" + printDoc(doc.contents) + ")" : doc.n.type === "root" ? "markAsRoot(" + printDoc(doc.contents) + ")" : "align(" + JSON.stringify(doc.n) + ", " + printDoc(doc.contents) + ")";
|
13701 | }
|
13702 |
|
13703 | if (doc.type === "if-break") {
|
13704 | return "ifBreak(" + printDoc(doc.breakContents) + (doc.flatContents ? ", " + printDoc(doc.flatContents) : "") + ")";
|
13705 | }
|
13706 |
|
13707 | if (doc.type === "group") {
|
13708 | if (doc.expandedStates) {
|
13709 | return "conditionalGroup(" + "[" + doc.expandedStates.map(printDoc).join(",") + "])";
|
13710 | }
|
13711 |
|
13712 | return (doc.break ? "wrappedGroup" : "group") + "(" + printDoc(doc.contents) + ")";
|
13713 | }
|
13714 |
|
13715 | if (doc.type === "fill") {
|
13716 | return "fill" + "(" + doc.parts.map(printDoc).join(", ") + ")";
|
13717 | }
|
13718 |
|
13719 | if (doc.type === "line-suffix") {
|
13720 | return "lineSuffix(" + printDoc(doc.contents) + ")";
|
13721 | }
|
13722 |
|
13723 | if (doc.type === "line-suffix-boundary") {
|
13724 | return "lineSuffixBoundary";
|
13725 | }
|
13726 |
|
13727 | throw new Error("Unknown doc type " + doc.type);
|
13728 | }
|
13729 |
|
13730 | var docDebug = {
|
13731 | printDocToDebug(doc) {
|
13732 | return printDoc(flattenDoc(doc));
|
13733 | }
|
13734 |
|
13735 | };
|
13736 |
|
13737 | var document = {
|
13738 | builders: docBuilders,
|
13739 | printer: docPrinter,
|
13740 | utils: docUtils,
|
13741 | debug: docDebug
|
13742 | };
|
13743 |
|
13744 | const {
|
13745 | getMaxContinuousCount: getMaxContinuousCount$1,
|
13746 | getStringWidth: getStringWidth$2,
|
13747 | getAlignmentSize: getAlignmentSize$1,
|
13748 | getIndentSize: getIndentSize$1,
|
13749 | skip: skip$1,
|
13750 | skipWhitespace: skipWhitespace$1,
|
13751 | skipSpaces: skipSpaces$1,
|
13752 | skipNewline: skipNewline$1,
|
13753 | skipToLineEnd: skipToLineEnd$1,
|
13754 | skipEverythingButNewLine: skipEverythingButNewLine$1,
|
13755 | skipInlineComment: skipInlineComment$1,
|
13756 | skipTrailingComment: skipTrailingComment$1,
|
13757 | hasNewline: hasNewline$1,
|
13758 | hasNewlineInRange: hasNewlineInRange$1,
|
13759 | hasSpaces: hasSpaces$1,
|
13760 | isNextLineEmpty: isNextLineEmpty$1,
|
13761 | isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$1,
|
13762 | isPreviousLineEmpty: isPreviousLineEmpty$1,
|
13763 | getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$1,
|
13764 | makeString: makeString$1,
|
13765 | addLeadingComment: addLeadingComment$1,
|
13766 | addDanglingComment: addDanglingComment$1,
|
13767 | addTrailingComment: addTrailingComment$1
|
13768 | } = util$1;
|
13769 | var utilShared = {
|
13770 | getMaxContinuousCount: getMaxContinuousCount$1,
|
13771 | getStringWidth: getStringWidth$2,
|
13772 | getAlignmentSize: getAlignmentSize$1,
|
13773 | getIndentSize: getIndentSize$1,
|
13774 | skip: skip$1,
|
13775 | skipWhitespace: skipWhitespace$1,
|
13776 | skipSpaces: skipSpaces$1,
|
13777 | skipNewline: skipNewline$1,
|
13778 | skipToLineEnd: skipToLineEnd$1,
|
13779 | skipEverythingButNewLine: skipEverythingButNewLine$1,
|
13780 | skipInlineComment: skipInlineComment$1,
|
13781 | skipTrailingComment: skipTrailingComment$1,
|
13782 | hasNewline: hasNewline$1,
|
13783 | hasNewlineInRange: hasNewlineInRange$1,
|
13784 | hasSpaces: hasSpaces$1,
|
13785 | isNextLineEmpty: isNextLineEmpty$1,
|
13786 | isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$1,
|
13787 | isPreviousLineEmpty: isPreviousLineEmpty$1,
|
13788 | getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$1,
|
13789 | makeString: makeString$1,
|
13790 | addLeadingComment: addLeadingComment$1,
|
13791 | addDanglingComment: addDanglingComment$1,
|
13792 | addTrailingComment: addTrailingComment$1
|
13793 | };
|
13794 |
|
13795 | const {
|
13796 | concat: concat$2,
|
13797 | line: line$1,
|
13798 | hardline: hardline$1,
|
13799 | breakParent: breakParent$1,
|
13800 | indent: indent$1,
|
13801 | lineSuffix: lineSuffix$1,
|
13802 | join: join$1,
|
13803 | cursor: cursor$2
|
13804 | } = document.builders;
|
13805 | const {
|
13806 | hasNewline: hasNewline$2,
|
13807 | skipNewline: skipNewline$2,
|
13808 | isPreviousLineEmpty: isPreviousLineEmpty$2
|
13809 | } = util$1;
|
13810 | const {
|
13811 | addLeadingComment: addLeadingComment$2,
|
13812 | addDanglingComment: addDanglingComment$2,
|
13813 | addTrailingComment: addTrailingComment$2
|
13814 | } = utilShared;
|
13815 | const childNodesCacheKey = Symbol("child-nodes");
|
13816 |
|
13817 | function getSortedChildNodes(node, options, resultArray) {
|
13818 | if (!node) {
|
13819 | return;
|
13820 | }
|
13821 |
|
13822 | const {
|
13823 | printer,
|
13824 | locStart,
|
13825 | locEnd
|
13826 | } = options;
|
13827 |
|
13828 | if (resultArray) {
|
13829 | if (printer.canAttachComment && printer.canAttachComment(node)) {
|
13830 |
|
13831 |
|
13832 |
|
13833 | let i;
|
13834 |
|
13835 | for (i = resultArray.length - 1; i >= 0; --i) {
|
13836 | if (locStart(resultArray[i]) <= locStart(node) && locEnd(resultArray[i]) <= locEnd(node)) {
|
13837 | break;
|
13838 | }
|
13839 | }
|
13840 |
|
13841 | resultArray.splice(i + 1, 0, node);
|
13842 | return;
|
13843 | }
|
13844 | } else if (node[childNodesCacheKey]) {
|
13845 | return node[childNodesCacheKey];
|
13846 | }
|
13847 |
|
13848 | const childNodes = printer.getCommentChildNodes && printer.getCommentChildNodes(node, options) || typeof node === "object" && Object.keys(node).filter(n => n !== "enclosingNode" && n !== "precedingNode" && n !== "followingNode").map(n => node[n]);
|
13849 |
|
13850 | if (!childNodes) {
|
13851 | return;
|
13852 | }
|
13853 |
|
13854 | if (!resultArray) {
|
13855 | Object.defineProperty(node, childNodesCacheKey, {
|
13856 | value: resultArray = [],
|
13857 | enumerable: false
|
13858 | });
|
13859 | }
|
13860 |
|
13861 | childNodes.forEach(childNode => {
|
13862 | getSortedChildNodes(childNode, options, resultArray);
|
13863 | });
|
13864 | return resultArray;
|
13865 | }
|
13866 |
|
13867 |
|
13868 |
|
13869 |
|
13870 | function decorateComment(node, comment, options) {
|
13871 | const {
|
13872 | locStart,
|
13873 | locEnd
|
13874 | } = options;
|
13875 | const childNodes = getSortedChildNodes(node, options);
|
13876 | let precedingNode;
|
13877 | let followingNode;
|
13878 |
|
13879 | let left = 0;
|
13880 | let right = childNodes.length;
|
13881 |
|
13882 | while (left < right) {
|
13883 | const middle = left + right >> 1;
|
13884 | const child = childNodes[middle];
|
13885 |
|
13886 | if (locStart(child) - locStart(comment) <= 0 && locEnd(comment) - locEnd(child) <= 0) {
|
13887 |
|
13888 | comment.enclosingNode = child;
|
13889 | decorateComment(child, comment, options);
|
13890 | return;
|
13891 | }
|
13892 |
|
13893 | if (locEnd(child) - locStart(comment) <= 0) {
|
13894 |
|
13895 |
|
13896 |
|
13897 |
|
13898 | precedingNode = child;
|
13899 | left = middle + 1;
|
13900 | continue;
|
13901 | }
|
13902 |
|
13903 | if (locEnd(comment) - locStart(child) <= 0) {
|
13904 |
|
13905 |
|
13906 |
|
13907 |
|
13908 | followingNode = child;
|
13909 | right = middle;
|
13910 | continue;
|
13911 | }
|
13912 |
|
13913 |
|
13914 |
|
13915 | throw new Error("Comment location overlaps with node location");
|
13916 | }
|
13917 |
|
13918 |
|
13919 |
|
13920 | if (comment.enclosingNode && comment.enclosingNode.type === "TemplateLiteral") {
|
13921 | const {
|
13922 | quasis
|
13923 | } = comment.enclosingNode;
|
13924 | const commentIndex = findExpressionIndexForComment(quasis, comment, options);
|
13925 |
|
13926 | if (precedingNode && findExpressionIndexForComment(quasis, precedingNode, options) !== commentIndex) {
|
13927 | precedingNode = null;
|
13928 | }
|
13929 |
|
13930 | if (followingNode && findExpressionIndexForComment(quasis, followingNode, options) !== commentIndex) {
|
13931 | followingNode = null;
|
13932 | }
|
13933 | }
|
13934 |
|
13935 | if (precedingNode) {
|
13936 | comment.precedingNode = precedingNode;
|
13937 | }
|
13938 |
|
13939 | if (followingNode) {
|
13940 | comment.followingNode = followingNode;
|
13941 | }
|
13942 | }
|
13943 |
|
13944 | function attach(comments, ast, text, options) {
|
13945 | if (!Array.isArray(comments)) {
|
13946 | return;
|
13947 | }
|
13948 |
|
13949 | const tiesToBreak = [];
|
13950 | const {
|
13951 | locStart,
|
13952 | locEnd
|
13953 | } = options;
|
13954 | comments.forEach((comment, i) => {
|
13955 | if (options.parser === "json" || options.parser === "json5" || options.parser === "__js_expression" || options.parser === "__vue_expression") {
|
13956 | if (locStart(comment) - locStart(ast) <= 0) {
|
13957 | addLeadingComment$2(ast, comment);
|
13958 | return;
|
13959 | }
|
13960 |
|
13961 | if (locEnd(comment) - locEnd(ast) >= 0) {
|
13962 | addTrailingComment$2(ast, comment);
|
13963 | return;
|
13964 | }
|
13965 | }
|
13966 |
|
13967 | decorateComment(ast, comment, options);
|
13968 | const {
|
13969 | precedingNode,
|
13970 | enclosingNode,
|
13971 | followingNode
|
13972 | } = comment;
|
13973 | const pluginHandleOwnLineComment = options.printer.handleComments && options.printer.handleComments.ownLine ? options.printer.handleComments.ownLine : () => false;
|
13974 | const pluginHandleEndOfLineComment = options.printer.handleComments && options.printer.handleComments.endOfLine ? options.printer.handleComments.endOfLine : () => false;
|
13975 | const pluginHandleRemainingComment = options.printer.handleComments && options.printer.handleComments.remaining ? options.printer.handleComments.remaining : () => false;
|
13976 | const isLastComment = comments.length - 1 === i;
|
13977 |
|
13978 | if (hasNewline$2(text, locStart(comment), {
|
13979 | backwards: true
|
13980 | })) {
|
13981 |
|
13982 |
|
13983 | if (pluginHandleOwnLineComment(comment, text, options, ast, isLastComment)) ; else if (followingNode) {
|
13984 |
|
13985 | addLeadingComment$2(followingNode, comment);
|
13986 | } else if (precedingNode) {
|
13987 | addTrailingComment$2(precedingNode, comment);
|
13988 | } else if (enclosingNode) {
|
13989 | addDanglingComment$2(enclosingNode, comment);
|
13990 | } else {
|
13991 |
|
13992 |
|
13993 |
|
13994 | addDanglingComment$2(ast, comment);
|
13995 | }
|
13996 | } else if (hasNewline$2(text, locEnd(comment))) {
|
13997 | if (pluginHandleEndOfLineComment(comment, text, options, ast, isLastComment)) ; else if (precedingNode) {
|
13998 |
|
13999 |
|
14000 | addTrailingComment$2(precedingNode, comment);
|
14001 | } else if (followingNode) {
|
14002 | addLeadingComment$2(followingNode, comment);
|
14003 | } else if (enclosingNode) {
|
14004 | addDanglingComment$2(enclosingNode, comment);
|
14005 | } else {
|
14006 |
|
14007 |
|
14008 |
|
14009 | addDanglingComment$2(ast, comment);
|
14010 | }
|
14011 | } else {
|
14012 | if (pluginHandleRemainingComment(comment, text, options, ast, isLastComment)) ; else if (precedingNode && followingNode) {
|
14013 |
|
14014 |
|
14015 |
|
14016 |
|
14017 |
|
14018 | const tieCount = tiesToBreak.length;
|
14019 |
|
14020 | if (tieCount > 0) {
|
14021 | const lastTie = tiesToBreak[tieCount - 1];
|
14022 |
|
14023 | if (lastTie.followingNode !== comment.followingNode) {
|
14024 | breakTies(tiesToBreak, text, options);
|
14025 | }
|
14026 | }
|
14027 |
|
14028 | tiesToBreak.push(comment);
|
14029 | } else if (precedingNode) {
|
14030 | addTrailingComment$2(precedingNode, comment);
|
14031 | } else if (followingNode) {
|
14032 | addLeadingComment$2(followingNode, comment);
|
14033 | } else if (enclosingNode) {
|
14034 | addDanglingComment$2(enclosingNode, comment);
|
14035 | } else {
|
14036 |
|
14037 |
|
14038 |
|
14039 | addDanglingComment$2(ast, comment);
|
14040 | }
|
14041 | }
|
14042 | });
|
14043 | breakTies(tiesToBreak, text, options);
|
14044 | comments.forEach(comment => {
|
14045 |
|
14046 |
|
14047 |
|
14048 | delete comment.precedingNode;
|
14049 | delete comment.enclosingNode;
|
14050 | delete comment.followingNode;
|
14051 | });
|
14052 | }
|
14053 |
|
14054 | function breakTies(tiesToBreak, text, options) {
|
14055 | const tieCount = tiesToBreak.length;
|
14056 |
|
14057 | if (tieCount === 0) {
|
14058 | return;
|
14059 | }
|
14060 |
|
14061 | const {
|
14062 | precedingNode,
|
14063 | followingNode,
|
14064 | enclosingNode
|
14065 | } = tiesToBreak[0];
|
14066 | const gapRegExp = options.printer.getGapRegex && options.printer.getGapRegex(enclosingNode) || /^[\s(]*$/;
|
14067 | let gapEndPos = options.locStart(followingNode);
|
14068 |
|
14069 |
|
14070 |
|
14071 |
|
14072 |
|
14073 | let indexOfFirstLeadingComment;
|
14074 |
|
14075 | for (indexOfFirstLeadingComment = tieCount; indexOfFirstLeadingComment > 0; --indexOfFirstLeadingComment) {
|
14076 | const comment = tiesToBreak[indexOfFirstLeadingComment - 1];
|
14077 | assert$1.strictEqual(comment.precedingNode, precedingNode);
|
14078 | assert$1.strictEqual(comment.followingNode, followingNode);
|
14079 | const gap = text.slice(options.locEnd(comment), gapEndPos);
|
14080 |
|
14081 | if (gapRegExp.test(gap)) {
|
14082 | gapEndPos = options.locStart(comment);
|
14083 | } else {
|
14084 |
|
14085 |
|
14086 | break;
|
14087 | }
|
14088 | }
|
14089 |
|
14090 | tiesToBreak.forEach((comment, i) => {
|
14091 | if (i < indexOfFirstLeadingComment) {
|
14092 | addTrailingComment$2(precedingNode, comment);
|
14093 | } else {
|
14094 | addLeadingComment$2(followingNode, comment);
|
14095 | }
|
14096 | });
|
14097 | tiesToBreak.length = 0;
|
14098 | }
|
14099 |
|
14100 | function printComment(commentPath, options) {
|
14101 | const comment = commentPath.getValue();
|
14102 | comment.printed = true;
|
14103 | return options.printer.printComment(commentPath, options);
|
14104 | }
|
14105 |
|
14106 | function findExpressionIndexForComment(quasis, comment, options) {
|
14107 | const startPos = options.locStart(comment) - 1;
|
14108 |
|
14109 | for (let i = 1; i < quasis.length; ++i) {
|
14110 | if (startPos < getQuasiRange(quasis[i]).start) {
|
14111 | return i - 1;
|
14112 | }
|
14113 | }
|
14114 |
|
14115 |
|
14116 |
|
14117 |
|
14118 |
|
14119 | return 0;
|
14120 | }
|
14121 |
|
14122 | function getQuasiRange(expr) {
|
14123 | if (expr.start !== undefined) {
|
14124 |
|
14125 | return {
|
14126 | start: expr.start,
|
14127 | end: expr.end
|
14128 | };
|
14129 | }
|
14130 |
|
14131 |
|
14132 | return {
|
14133 | start: expr.range[0],
|
14134 | end: expr.range[1]
|
14135 | };
|
14136 | }
|
14137 |
|
14138 | function printLeadingComment(commentPath, print, options) {
|
14139 | const comment = commentPath.getValue();
|
14140 | const contents = printComment(commentPath, options);
|
14141 |
|
14142 | if (!contents) {
|
14143 | return "";
|
14144 | }
|
14145 |
|
14146 | const isBlock = options.printer.isBlockComment && options.printer.isBlockComment(comment);
|
14147 |
|
14148 |
|
14149 | if (isBlock) {
|
14150 | const lineBreak = hasNewline$2(options.originalText, options.locEnd(comment)) ? hasNewline$2(options.originalText, options.locStart(comment), {
|
14151 | backwards: true
|
14152 | }) ? hardline$1 : line$1 : " ";
|
14153 | return concat$2([contents, lineBreak]);
|
14154 | }
|
14155 |
|
14156 | return concat$2([contents, hardline$1]);
|
14157 | }
|
14158 |
|
14159 | function printTrailingComment(commentPath, print, options) {
|
14160 | const comment = commentPath.getValue();
|
14161 | const contents = printComment(commentPath, options);
|
14162 |
|
14163 | if (!contents) {
|
14164 | return "";
|
14165 | }
|
14166 |
|
14167 | const isBlock = options.printer.isBlockComment && options.printer.isBlockComment(comment);
|
14168 |
|
14169 |
|
14170 |
|
14171 | const parentNode = commentPath.getNode(1);
|
14172 | const parentParentNode = commentPath.getNode(2);
|
14173 | const isParentSuperClass = parentParentNode && (parentParentNode.type === "ClassDeclaration" || parentParentNode.type === "ClassExpression") && parentParentNode.superClass === parentNode;
|
14174 |
|
14175 | if (hasNewline$2(options.originalText, options.locStart(comment), {
|
14176 | backwards: true
|
14177 | })) {
|
14178 |
|
14179 |
|
14180 |
|
14181 |
|
14182 |
|
14183 |
|
14184 |
|
14185 |
|
14186 |
|
14187 |
|
14188 |
|
14189 | const isLineBeforeEmpty = isPreviousLineEmpty$2(options.originalText, comment, options.locStart);
|
14190 | return lineSuffix$1(concat$2([hardline$1, isLineBeforeEmpty ? hardline$1 : "", contents]));
|
14191 | } else if (isBlock || isParentSuperClass) {
|
14192 |
|
14193 | return concat$2([" ", contents]);
|
14194 | }
|
14195 |
|
14196 | return concat$2([lineSuffix$1(concat$2([" ", contents])), !isBlock ? breakParent$1 : ""]);
|
14197 | }
|
14198 |
|
14199 | function printDanglingComments(path, options, sameIndent, filter) {
|
14200 | const parts = [];
|
14201 | const node = path.getValue();
|
14202 |
|
14203 | if (!node || !node.comments) {
|
14204 | return "";
|
14205 | }
|
14206 |
|
14207 | path.each(commentPath => {
|
14208 | const comment = commentPath.getValue();
|
14209 |
|
14210 | if (comment && !comment.leading && !comment.trailing && (!filter || filter(comment))) {
|
14211 | parts.push(printComment(commentPath, options));
|
14212 | }
|
14213 | }, "comments");
|
14214 |
|
14215 | if (parts.length === 0) {
|
14216 | return "";
|
14217 | }
|
14218 |
|
14219 | if (sameIndent) {
|
14220 | return join$1(hardline$1, parts);
|
14221 | }
|
14222 |
|
14223 | return indent$1(concat$2([hardline$1, join$1(hardline$1, parts)]));
|
14224 | }
|
14225 |
|
14226 | function prependCursorPlaceholder(path, options, printed) {
|
14227 | if (path.getNode() === options.cursorNode && path.getValue()) {
|
14228 | return concat$2([cursor$2, printed, cursor$2]);
|
14229 | }
|
14230 |
|
14231 | return printed;
|
14232 | }
|
14233 |
|
14234 | function printComments(path, print, options, needsSemi) {
|
14235 | const value = path.getValue();
|
14236 | const printed = print(path);
|
14237 | const comments = value && value.comments;
|
14238 |
|
14239 | if (!comments || comments.length === 0) {
|
14240 | return prependCursorPlaceholder(path, options, printed);
|
14241 | }
|
14242 |
|
14243 | const leadingParts = [];
|
14244 | const trailingParts = [needsSemi ? ";" : "", printed];
|
14245 | path.each(commentPath => {
|
14246 | const comment = commentPath.getValue();
|
14247 | const {
|
14248 | leading,
|
14249 | trailing
|
14250 | } = comment;
|
14251 |
|
14252 | if (leading) {
|
14253 | const contents = printLeadingComment(commentPath, print, options);
|
14254 |
|
14255 | if (!contents) {
|
14256 | return;
|
14257 | }
|
14258 |
|
14259 | leadingParts.push(contents);
|
14260 | const text = options.originalText;
|
14261 | const index = skipNewline$2(text, options.locEnd(comment));
|
14262 |
|
14263 | if (index !== false && hasNewline$2(text, index)) {
|
14264 | leadingParts.push(hardline$1);
|
14265 | }
|
14266 | } else if (trailing) {
|
14267 | trailingParts.push(printTrailingComment(commentPath, print, options));
|
14268 | }
|
14269 | }, "comments");
|
14270 | return prependCursorPlaceholder(path, options, concat$2(leadingParts.concat(trailingParts)));
|
14271 | }
|
14272 |
|
14273 | var comments = {
|
14274 | attach,
|
14275 | printComments,
|
14276 | printDanglingComments,
|
14277 | getSortedChildNodes
|
14278 | };
|
14279 |
|
14280 | function getNodeHelper(path, count) {
|
14281 | const stackIndex = getNodeStackIndexHelper(path.stack, count);
|
14282 | return stackIndex === -1 ? null : path.stack[stackIndex];
|
14283 | }
|
14284 |
|
14285 | function getNodeStackIndexHelper(stack, count) {
|
14286 | for (let i = stack.length - 1; i >= 0; i -= 2) {
|
14287 | const value = stack[i];
|
14288 |
|
14289 | if (value && !Array.isArray(value) && --count < 0) {
|
14290 | return i;
|
14291 | }
|
14292 | }
|
14293 |
|
14294 | return -1;
|
14295 | }
|
14296 |
|
14297 | class FastPath {
|
14298 | constructor(value) {
|
14299 | this.stack = [value];
|
14300 | }
|
14301 |
|
14302 |
|
14303 |
|
14304 | getName() {
|
14305 | const {
|
14306 | stack
|
14307 | } = this;
|
14308 | const {
|
14309 | length
|
14310 | } = stack;
|
14311 |
|
14312 | if (length > 1) {
|
14313 | return stack[length - 2];
|
14314 | }
|
14315 |
|
14316 |
|
14317 |
|
14318 |
|
14319 |
|
14320 | return null;
|
14321 | }
|
14322 |
|
14323 |
|
14324 |
|
14325 | getValue() {
|
14326 | return getLast(this.stack);
|
14327 | }
|
14328 |
|
14329 | getNode(count = 0) {
|
14330 | return getNodeHelper(this, count);
|
14331 | }
|
14332 |
|
14333 | getParentNode(count = 0) {
|
14334 | return getNodeHelper(this, count + 1);
|
14335 | }
|
14336 |
|
14337 |
|
14338 |
|
14339 |
|
14340 |
|
14341 |
|
14342 | call(callback, ...names) {
|
14343 | const {
|
14344 | stack
|
14345 | } = this;
|
14346 | const {
|
14347 | length
|
14348 | } = stack;
|
14349 | let value = getLast(stack);
|
14350 |
|
14351 | for (const name of names) {
|
14352 | value = value[name];
|
14353 | stack.push(name, value);
|
14354 | }
|
14355 |
|
14356 | const result = callback(this);
|
14357 | stack.length = length;
|
14358 | return result;
|
14359 | }
|
14360 |
|
14361 | callParent(callback, count = 0) {
|
14362 | const stackIndex = getNodeStackIndexHelper(this.stack, count + 1);
|
14363 | const parentValues = this.stack.splice(stackIndex + 1);
|
14364 | const result = callback(this);
|
14365 | this.stack.push(...parentValues);
|
14366 | return result;
|
14367 | }
|
14368 |
|
14369 |
|
14370 |
|
14371 |
|
14372 |
|
14373 | each(callback, ...names) {
|
14374 | const {
|
14375 | stack
|
14376 | } = this;
|
14377 | const {
|
14378 | length
|
14379 | } = stack;
|
14380 | let value = getLast(stack);
|
14381 |
|
14382 | for (const name of names) {
|
14383 | value = value[name];
|
14384 | stack.push(name, value);
|
14385 | }
|
14386 |
|
14387 | for (let i = 0; i < value.length; ++i) {
|
14388 | if (i in value) {
|
14389 | stack.push(i, value[i]);
|
14390 |
|
14391 |
|
14392 | callback(this);
|
14393 | stack.length -= 2;
|
14394 | }
|
14395 | }
|
14396 |
|
14397 | stack.length = length;
|
14398 | }
|
14399 |
|
14400 |
|
14401 |
|
14402 |
|
14403 | map(callback, ...names) {
|
14404 | const {
|
14405 | stack
|
14406 | } = this;
|
14407 | const {
|
14408 | length
|
14409 | } = stack;
|
14410 | let value = getLast(stack);
|
14411 |
|
14412 | for (const name of names) {
|
14413 | value = value[name];
|
14414 | stack.push(name, value);
|
14415 | }
|
14416 |
|
14417 | const result = new Array(value.length);
|
14418 |
|
14419 | for (let i = 0; i < value.length; ++i) {
|
14420 | if (i in value) {
|
14421 | stack.push(i, value[i]);
|
14422 | result[i] = callback(this, i);
|
14423 | stack.length -= 2;
|
14424 | }
|
14425 | }
|
14426 |
|
14427 | stack.length = length;
|
14428 | return result;
|
14429 | }
|
14430 | |
14431 |
|
14432 |
|
14433 |
|
14434 |
|
14435 |
|
14436 |
|
14437 |
|
14438 | match(...predicates) {
|
14439 | let stackPointer = this.stack.length - 1;
|
14440 | let name = null;
|
14441 | let node = this.stack[stackPointer--];
|
14442 |
|
14443 | for (const predicate of predicates) {
|
14444 | if (node === undefined) {
|
14445 | return false;
|
14446 | }
|
14447 |
|
14448 |
|
14449 | let number = null;
|
14450 |
|
14451 | if (typeof name === "number") {
|
14452 | number = name;
|
14453 | name = this.stack[stackPointer--];
|
14454 | node = this.stack[stackPointer--];
|
14455 | }
|
14456 |
|
14457 | if (predicate && !predicate(node, name, number)) {
|
14458 | return false;
|
14459 | }
|
14460 |
|
14461 | name = this.stack[stackPointer--];
|
14462 | node = this.stack[stackPointer--];
|
14463 | }
|
14464 |
|
14465 | return true;
|
14466 | }
|
14467 |
|
14468 | }
|
14469 |
|
14470 | var fastPath = FastPath;
|
14471 |
|
14472 | const {
|
14473 | normalize: normalize$2
|
14474 | } = options$1;
|
14475 |
|
14476 | function printSubtree(path, print, options, printAstToDoc) {
|
14477 | if (options.printer.embed) {
|
14478 | return options.printer.embed(path, print, (text, partialNextOptions) => textToDoc(text, partialNextOptions, options, printAstToDoc), options);
|
14479 | }
|
14480 | }
|
14481 |
|
14482 | function textToDoc(text, partialNextOptions, parentOptions, printAstToDoc) {
|
14483 | const nextOptions = normalize$2(Object.assign({}, parentOptions, {}, partialNextOptions, {
|
14484 | parentParser: parentOptions.parser,
|
14485 | embeddedInHtml: !!(parentOptions.embeddedInHtml || parentOptions.parser === "html" || parentOptions.parser === "vue" || parentOptions.parser === "angular" || parentOptions.parser === "lwc"),
|
14486 | originalText: text
|
14487 | }), {
|
14488 | passThrough: true
|
14489 | });
|
14490 | const result = parser.parse(text, nextOptions);
|
14491 | const {
|
14492 | ast
|
14493 | } = result;
|
14494 | text = result.text;
|
14495 | const astComments = ast.comments;
|
14496 | delete ast.comments;
|
14497 | comments.attach(astComments, ast, text, nextOptions);
|
14498 | return printAstToDoc(ast, nextOptions);
|
14499 | }
|
14500 |
|
14501 | var multiparser = {
|
14502 | printSubtree
|
14503 | };
|
14504 |
|
14505 | const doc = document;
|
14506 | const docBuilders$1 = doc.builders;
|
14507 | const {
|
14508 | concat: concat$3,
|
14509 | hardline: hardline$2,
|
14510 | addAlignmentToDoc: addAlignmentToDoc$1
|
14511 | } = docBuilders$1;
|
14512 | const docUtils$1 = doc.utils;
|
14513 |
|
14514 |
|
14515 |
|
14516 |
|
14517 |
|
14518 |
|
14519 |
|
14520 |
|
14521 |
|
14522 |
|
14523 |
|
14524 |
|
14525 |
|
14526 |
|
14527 |
|
14528 |
|
14529 |
|
14530 |
|
14531 |
|
14532 |
|
14533 |
|
14534 |
|
14535 | function printAstToDoc(ast, options, alignmentSize = 0) {
|
14536 | const {
|
14537 | printer
|
14538 | } = options;
|
14539 |
|
14540 | if (printer.preprocess) {
|
14541 | ast = printer.preprocess(ast, options);
|
14542 | }
|
14543 |
|
14544 | const cache = new Map();
|
14545 |
|
14546 | function printGenerically(path, args) {
|
14547 | const node = path.getValue();
|
14548 | const shouldCache = node && typeof node === "object" && args === undefined;
|
14549 |
|
14550 | if (shouldCache && cache.has(node)) {
|
14551 | return cache.get(node);
|
14552 | }
|
14553 |
|
14554 |
|
14555 |
|
14556 | let res;
|
14557 |
|
14558 | if (printer.willPrintOwnComments && printer.willPrintOwnComments(path, options)) {
|
14559 | res = callPluginPrintFunction(path, options, printGenerically, args);
|
14560 | } else {
|
14561 |
|
14562 |
|
14563 | res = comments.printComments(path, p => callPluginPrintFunction(p, options, printGenerically, args), options, args && args.needsSemi);
|
14564 | }
|
14565 |
|
14566 | if (shouldCache) {
|
14567 | cache.set(node, res);
|
14568 | }
|
14569 |
|
14570 | return res;
|
14571 | }
|
14572 |
|
14573 | let doc = printGenerically(new fastPath(ast));
|
14574 |
|
14575 | if (alignmentSize > 0) {
|
14576 |
|
14577 |
|
14578 | doc = addAlignmentToDoc$1(concat$3([hardline$2, doc]), alignmentSize, options.tabWidth);
|
14579 | }
|
14580 |
|
14581 | docUtils$1.propagateBreaks(doc);
|
14582 | return doc;
|
14583 | }
|
14584 |
|
14585 | function callPluginPrintFunction(path, options, printPath, args) {
|
14586 | assert$1.ok(path instanceof fastPath);
|
14587 | const node = path.getValue();
|
14588 | const {
|
14589 | printer
|
14590 | } = options;
|
14591 |
|
14592 | if (printer.hasPrettierIgnore && printer.hasPrettierIgnore(path)) {
|
14593 | return options.originalText.slice(options.locStart(node), options.locEnd(node));
|
14594 | }
|
14595 |
|
14596 | if (node) {
|
14597 | try {
|
14598 |
|
14599 | const sub = multiparser.printSubtree(path, printPath, options, printAstToDoc);
|
14600 |
|
14601 | if (sub) {
|
14602 | return sub;
|
14603 | }
|
14604 | } catch (error) {
|
14605 |
|
14606 | if (process.env.PRETTIER_DEBUG) {
|
14607 | throw error;
|
14608 | }
|
14609 |
|
14610 | }
|
14611 | }
|
14612 |
|
14613 | return printer.print(path, options, printPath, args);
|
14614 | }
|
14615 |
|
14616 | var astToDoc = printAstToDoc;
|
14617 |
|
14618 | function findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts) {
|
14619 | let resultStartNode = startNodeAndParents.node;
|
14620 | let resultEndNode = endNodeAndParents.node;
|
14621 |
|
14622 | if (resultStartNode === resultEndNode) {
|
14623 | return {
|
14624 | startNode: resultStartNode,
|
14625 | endNode: resultEndNode
|
14626 | };
|
14627 | }
|
14628 |
|
14629 | for (const endParent of endNodeAndParents.parentNodes) {
|
14630 | if (endParent.type !== "Program" && endParent.type !== "File" && opts.locStart(endParent) >= opts.locStart(startNodeAndParents.node)) {
|
14631 | resultEndNode = endParent;
|
14632 | } else {
|
14633 | break;
|
14634 | }
|
14635 | }
|
14636 |
|
14637 | for (const startParent of startNodeAndParents.parentNodes) {
|
14638 | if (startParent.type !== "Program" && startParent.type !== "File" && opts.locEnd(startParent) <= opts.locEnd(endNodeAndParents.node)) {
|
14639 | resultStartNode = startParent;
|
14640 | } else {
|
14641 | break;
|
14642 | }
|
14643 | }
|
14644 |
|
14645 | return {
|
14646 | startNode: resultStartNode,
|
14647 | endNode: resultEndNode
|
14648 | };
|
14649 | }
|
14650 |
|
14651 | function findNodeAtOffset(node, offset, options, predicate, parentNodes) {
|
14652 | predicate = predicate || (() => true);
|
14653 |
|
14654 | parentNodes = parentNodes || [];
|
14655 | const start = options.locStart(node, options.locStart);
|
14656 | const end = options.locEnd(node, options.locEnd);
|
14657 |
|
14658 | if (start <= offset && offset <= end) {
|
14659 | for (const childNode of comments.getSortedChildNodes(node, options)) {
|
14660 | const childResult = findNodeAtOffset(childNode, offset, options, predicate, [node].concat(parentNodes));
|
14661 |
|
14662 | if (childResult) {
|
14663 | return childResult;
|
14664 | }
|
14665 | }
|
14666 |
|
14667 | if (predicate(node)) {
|
14668 | return {
|
14669 | node,
|
14670 | parentNodes
|
14671 | };
|
14672 | }
|
14673 | }
|
14674 | }
|
14675 |
|
14676 |
|
14677 | function isSourceElement(opts, node) {
|
14678 | if (node == null) {
|
14679 | return false;
|
14680 | }
|
14681 |
|
14682 |
|
14683 | const jsSourceElements = ["FunctionDeclaration", "BlockStatement", "BreakStatement", "ContinueStatement", "DebuggerStatement", "DoWhileStatement", "EmptyStatement", "ExpressionStatement", "ForInStatement", "ForStatement", "IfStatement", "LabeledStatement", "ReturnStatement", "SwitchStatement", "ThrowStatement", "TryStatement", "VariableDeclaration", "WhileStatement", "WithStatement", "ClassDeclaration",
|
14684 | "ImportDeclaration",
|
14685 | "ExportDefaultDeclaration",
|
14686 | "ExportNamedDeclaration",
|
14687 | "ExportAllDeclaration",
|
14688 | "TypeAlias",
|
14689 | "InterfaceDeclaration",
|
14690 | "TypeAliasDeclaration",
|
14691 | "ExportAssignment",
|
14692 | "ExportDeclaration"
|
14693 | ];
|
14694 | const jsonSourceElements = ["ObjectExpression", "ArrayExpression", "StringLiteral", "NumericLiteral", "BooleanLiteral", "NullLiteral"];
|
14695 | const graphqlSourceElements = ["OperationDefinition", "FragmentDefinition", "VariableDefinition", "TypeExtensionDefinition", "ObjectTypeDefinition", "FieldDefinition", "DirectiveDefinition", "EnumTypeDefinition", "EnumValueDefinition", "InputValueDefinition", "InputObjectTypeDefinition", "SchemaDefinition", "OperationTypeDefinition", "InterfaceTypeDefinition", "UnionTypeDefinition", "ScalarTypeDefinition"];
|
14696 |
|
14697 | switch (opts.parser) {
|
14698 | case "flow":
|
14699 | case "babel":
|
14700 | case "babel-flow":
|
14701 | case "babel-ts":
|
14702 | case "typescript":
|
14703 | return jsSourceElements.includes(node.type);
|
14704 |
|
14705 | case "json":
|
14706 | return jsonSourceElements.includes(node.type);
|
14707 |
|
14708 | case "graphql":
|
14709 | return graphqlSourceElements.includes(node.kind);
|
14710 |
|
14711 | case "vue":
|
14712 | return node.tag !== "root";
|
14713 | }
|
14714 |
|
14715 | return false;
|
14716 | }
|
14717 |
|
14718 | function calculateRange(text, opts, ast) {
|
14719 |
|
14720 |
|
14721 | const rangeStringOrig = text.slice(opts.rangeStart, opts.rangeEnd);
|
14722 | const startNonWhitespace = Math.max(opts.rangeStart + rangeStringOrig.search(/\S/), opts.rangeStart);
|
14723 | let endNonWhitespace;
|
14724 |
|
14725 | for (endNonWhitespace = opts.rangeEnd; endNonWhitespace > opts.rangeStart; --endNonWhitespace) {
|
14726 | if (text[endNonWhitespace - 1].match(/\S/)) {
|
14727 | break;
|
14728 | }
|
14729 | }
|
14730 |
|
14731 | const startNodeAndParents = findNodeAtOffset(ast, startNonWhitespace, opts, node => isSourceElement(opts, node));
|
14732 | const endNodeAndParents = findNodeAtOffset(ast, endNonWhitespace, opts, node => isSourceElement(opts, node));
|
14733 |
|
14734 | if (!startNodeAndParents || !endNodeAndParents) {
|
14735 | return {
|
14736 | rangeStart: 0,
|
14737 | rangeEnd: 0
|
14738 | };
|
14739 | }
|
14740 |
|
14741 | const siblingAncestors = findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts);
|
14742 | const {
|
14743 | startNode,
|
14744 | endNode
|
14745 | } = siblingAncestors;
|
14746 | const rangeStart = Math.min(opts.locStart(startNode, opts.locStart), opts.locStart(endNode, opts.locStart));
|
14747 | const rangeEnd = Math.max(opts.locEnd(startNode, opts.locEnd), opts.locEnd(endNode, opts.locEnd));
|
14748 | return {
|
14749 | rangeStart,
|
14750 | rangeEnd
|
14751 | };
|
14752 | }
|
14753 |
|
14754 | var rangeUtil = {
|
14755 | calculateRange,
|
14756 | findNodeAtOffset
|
14757 | };
|
14758 |
|
14759 | var require$$0 = getCjsExportFromNamespace(index_es6);
|
14760 |
|
14761 | const normalizeOptions$1 = options$1.normalize;
|
14762 | const {
|
14763 | guessEndOfLine: guessEndOfLine$1,
|
14764 | convertEndOfLineToChars: convertEndOfLineToChars$2
|
14765 | } = endOfLine;
|
14766 | const {
|
14767 | printer: {
|
14768 | printDocToString: printDocToString$1
|
14769 | },
|
14770 | debug: {
|
14771 | printDocToDebug
|
14772 | }
|
14773 | } = document;
|
14774 | const BOM = "\uFEFF";
|
14775 | const CURSOR = Symbol("cursor");
|
14776 | const PLACEHOLDERS = {
|
14777 | cursorOffset: "<<<PRETTIER_CURSOR>>>",
|
14778 | rangeStart: "<<<PRETTIER_RANGE_START>>>",
|
14779 | rangeEnd: "<<<PRETTIER_RANGE_END>>>"
|
14780 | };
|
14781 |
|
14782 | function ensureAllCommentsPrinted(astComments) {
|
14783 | if (!astComments) {
|
14784 | return;
|
14785 | }
|
14786 |
|
14787 | for (let i = 0; i < astComments.length; ++i) {
|
14788 | if (util$1.isNodeIgnoreComment(astComments[i])) {
|
14789 |
|
14790 |
|
14791 | return;
|
14792 | }
|
14793 | }
|
14794 |
|
14795 | astComments.forEach(comment => {
|
14796 | if (!comment.printed) {
|
14797 | throw new Error('Comment "' + comment.value.trim() + '" was not printed. Please report this error!');
|
14798 | }
|
14799 |
|
14800 | delete comment.printed;
|
14801 | });
|
14802 | }
|
14803 |
|
14804 | function attachComments(text, ast, opts) {
|
14805 | const astComments = ast.comments;
|
14806 |
|
14807 | if (astComments) {
|
14808 | delete ast.comments;
|
14809 | comments.attach(astComments, ast, text, opts);
|
14810 | }
|
14811 |
|
14812 | ast.tokens = [];
|
14813 | opts.originalText = opts.parser === "yaml" ? text : text.trimEnd();
|
14814 | return astComments;
|
14815 | }
|
14816 |
|
14817 | function coreFormat(text, opts, addAlignmentSize) {
|
14818 | if (!text || !text.trim().length) {
|
14819 | return {
|
14820 | formatted: "",
|
14821 | cursorOffset: 0
|
14822 | };
|
14823 | }
|
14824 |
|
14825 | addAlignmentSize = addAlignmentSize || 0;
|
14826 | const parsed = parser.parse(text, opts);
|
14827 | const {
|
14828 | ast
|
14829 | } = parsed;
|
14830 | text = parsed.text;
|
14831 |
|
14832 | if (opts.cursorOffset >= 0) {
|
14833 | const nodeResult = rangeUtil.findNodeAtOffset(ast, opts.cursorOffset, opts);
|
14834 |
|
14835 | if (nodeResult && nodeResult.node) {
|
14836 | opts.cursorNode = nodeResult.node;
|
14837 | }
|
14838 | }
|
14839 |
|
14840 | const astComments = attachComments(text, ast, opts);
|
14841 | const doc = astToDoc(ast, opts, addAlignmentSize);
|
14842 | const result = printDocToString$1(doc, opts);
|
14843 | ensureAllCommentsPrinted(astComments);
|
14844 |
|
14845 | if (addAlignmentSize > 0) {
|
14846 | const trimmed = result.formatted.trim();
|
14847 |
|
14848 | if (result.cursorNodeStart !== undefined) {
|
14849 | result.cursorNodeStart -= result.formatted.indexOf(trimmed);
|
14850 | }
|
14851 |
|
14852 | result.formatted = trimmed + convertEndOfLineToChars$2(opts.endOfLine);
|
14853 | }
|
14854 |
|
14855 | if (opts.cursorOffset >= 0) {
|
14856 | let oldCursorNodeStart;
|
14857 | let oldCursorNodeText;
|
14858 | let cursorOffsetRelativeToOldCursorNode;
|
14859 | let newCursorNodeStart;
|
14860 | let newCursorNodeText;
|
14861 |
|
14862 | if (opts.cursorNode && result.cursorNodeText) {
|
14863 | oldCursorNodeStart = opts.locStart(opts.cursorNode);
|
14864 | oldCursorNodeText = text.slice(oldCursorNodeStart, opts.locEnd(opts.cursorNode));
|
14865 | cursorOffsetRelativeToOldCursorNode = opts.cursorOffset - oldCursorNodeStart;
|
14866 | newCursorNodeStart = result.cursorNodeStart;
|
14867 | newCursorNodeText = result.cursorNodeText;
|
14868 | } else {
|
14869 | oldCursorNodeStart = 0;
|
14870 | oldCursorNodeText = text;
|
14871 | cursorOffsetRelativeToOldCursorNode = opts.cursorOffset;
|
14872 | newCursorNodeStart = 0;
|
14873 | newCursorNodeText = result.formatted;
|
14874 | }
|
14875 |
|
14876 | if (oldCursorNodeText === newCursorNodeText) {
|
14877 | return {
|
14878 | formatted: result.formatted,
|
14879 | cursorOffset: newCursorNodeStart + cursorOffsetRelativeToOldCursorNode
|
14880 | };
|
14881 | }
|
14882 |
|
14883 |
|
14884 |
|
14885 | const oldCursorNodeCharArray = oldCursorNodeText.split("");
|
14886 | oldCursorNodeCharArray.splice(cursorOffsetRelativeToOldCursorNode, 0, CURSOR);
|
14887 | const newCursorNodeCharArray = newCursorNodeText.split("");
|
14888 | const cursorNodeDiff = require$$0.diffArrays(oldCursorNodeCharArray, newCursorNodeCharArray);
|
14889 | let cursorOffset = newCursorNodeStart;
|
14890 |
|
14891 | for (const entry of cursorNodeDiff) {
|
14892 | if (entry.removed) {
|
14893 | if (entry.value.includes(CURSOR)) {
|
14894 | break;
|
14895 | }
|
14896 | } else {
|
14897 | cursorOffset += entry.count;
|
14898 | }
|
14899 | }
|
14900 |
|
14901 | return {
|
14902 | formatted: result.formatted,
|
14903 | cursorOffset
|
14904 | };
|
14905 | }
|
14906 |
|
14907 | return {
|
14908 | formatted: result.formatted
|
14909 | };
|
14910 | }
|
14911 |
|
14912 | function formatRange(text, opts) {
|
14913 | const parsed = parser.parse(text, opts);
|
14914 | const {
|
14915 | ast
|
14916 | } = parsed;
|
14917 | text = parsed.text;
|
14918 | const range = rangeUtil.calculateRange(text, opts, ast);
|
14919 | const {
|
14920 | rangeStart,
|
14921 | rangeEnd
|
14922 | } = range;
|
14923 | const rangeString = text.slice(rangeStart, rangeEnd);
|
14924 |
|
14925 |
|
14926 |
|
14927 | const rangeStart2 = Math.min(rangeStart, text.lastIndexOf("\n", rangeStart) + 1);
|
14928 | const indentString = text.slice(rangeStart2, rangeStart);
|
14929 | const alignmentSize = util$1.getAlignmentSize(indentString, opts.tabWidth);
|
14930 | const rangeResult = coreFormat(rangeString, Object.assign({}, opts, {
|
14931 | rangeStart: 0,
|
14932 | rangeEnd: Infinity,
|
14933 |
|
14934 | cursorOffset: opts.cursorOffset >= rangeStart && opts.cursorOffset < rangeEnd ? opts.cursorOffset - rangeStart : -1
|
14935 | }), alignmentSize);
|
14936 |
|
14937 |
|
14938 | const rangeTrimmed = rangeResult.formatted.trimEnd();
|
14939 | const rangeLeft = text.slice(0, rangeStart);
|
14940 | const rangeRight = text.slice(rangeEnd);
|
14941 | let {
|
14942 | cursorOffset
|
14943 | } = opts;
|
14944 |
|
14945 | if (opts.cursorOffset >= rangeEnd) {
|
14946 |
|
14947 | cursorOffset = opts.cursorOffset - rangeEnd + (rangeStart + rangeTrimmed.length);
|
14948 | } else if (rangeResult.cursorOffset !== undefined) {
|
14949 |
|
14950 | cursorOffset = rangeResult.cursorOffset + rangeStart;
|
14951 | }
|
14952 |
|
14953 |
|
14954 | let formatted;
|
14955 |
|
14956 | if (opts.endOfLine === "lf") {
|
14957 | formatted = rangeLeft + rangeTrimmed + rangeRight;
|
14958 | } else {
|
14959 | const eol = convertEndOfLineToChars$2(opts.endOfLine);
|
14960 |
|
14961 | if (cursorOffset >= 0) {
|
14962 | const parts = [rangeLeft, rangeTrimmed, rangeRight];
|
14963 | let partIndex = 0;
|
14964 | let partOffset = cursorOffset;
|
14965 |
|
14966 | while (partIndex < parts.length) {
|
14967 | const part = parts[partIndex];
|
14968 |
|
14969 | if (partOffset < part.length) {
|
14970 | parts[partIndex] = parts[partIndex].slice(0, partOffset) + PLACEHOLDERS.cursorOffset + parts[partIndex].slice(partOffset);
|
14971 | break;
|
14972 | }
|
14973 |
|
14974 | partIndex++;
|
14975 | partOffset -= part.length;
|
14976 | }
|
14977 |
|
14978 | const [newRangeLeft, newRangeTrimmed, newRangeRight] = parts;
|
14979 | formatted = (newRangeLeft.replace(/\n/g, eol) + newRangeTrimmed + newRangeRight.replace(/\n/g, eol)).replace(PLACEHOLDERS.cursorOffset, (_, index) => {
|
14980 | cursorOffset = index;
|
14981 | return "";
|
14982 | });
|
14983 | } else {
|
14984 | formatted = rangeLeft.replace(/\n/g, eol) + rangeTrimmed + rangeRight.replace(/\n/g, eol);
|
14985 | }
|
14986 | }
|
14987 |
|
14988 | return {
|
14989 | formatted,
|
14990 | cursorOffset
|
14991 | };
|
14992 | }
|
14993 |
|
14994 | function format(text, opts) {
|
14995 | const selectedParser = parser.resolveParser(opts);
|
14996 | const hasPragma = !selectedParser.hasPragma || selectedParser.hasPragma(text);
|
14997 |
|
14998 | if (opts.requirePragma && !hasPragma) {
|
14999 | return {
|
15000 | formatted: text
|
15001 | };
|
15002 | }
|
15003 |
|
15004 | if (opts.endOfLine === "auto") {
|
15005 | opts.endOfLine = guessEndOfLine$1(text);
|
15006 | }
|
15007 |
|
15008 | const hasCursor = opts.cursorOffset >= 0;
|
15009 | const hasRangeStart = opts.rangeStart > 0;
|
15010 | const hasRangeEnd = opts.rangeEnd < text.length;
|
15011 |
|
15012 | if (text.includes("\r")) {
|
15013 | const offsetKeys = [hasCursor && "cursorOffset", hasRangeStart && "rangeStart", hasRangeEnd && "rangeEnd"].filter(Boolean).sort((aKey, bKey) => opts[aKey] - opts[bKey]);
|
15014 |
|
15015 | for (let i = offsetKeys.length - 1; i >= 0; i--) {
|
15016 | const key = offsetKeys[i];
|
15017 | text = text.slice(0, opts[key]) + PLACEHOLDERS[key] + text.slice(opts[key]);
|
15018 | }
|
15019 |
|
15020 | text = text.replace(/\r\n?/g, "\n");
|
15021 |
|
15022 | for (let i = 0; i < offsetKeys.length; i++) {
|
15023 | const key = offsetKeys[i];
|
15024 | text = text.replace(PLACEHOLDERS[key], (_, index) => {
|
15025 | opts[key] = index;
|
15026 | return "";
|
15027 | });
|
15028 | }
|
15029 | }
|
15030 |
|
15031 | const hasUnicodeBOM = text.charAt(0) === BOM;
|
15032 |
|
15033 | if (hasUnicodeBOM) {
|
15034 | text = text.slice(1);
|
15035 |
|
15036 | if (hasCursor) {
|
15037 | opts.cursorOffset++;
|
15038 | }
|
15039 |
|
15040 | if (hasRangeStart) {
|
15041 | opts.rangeStart++;
|
15042 | }
|
15043 |
|
15044 | if (hasRangeEnd) {
|
15045 | opts.rangeEnd++;
|
15046 | }
|
15047 | }
|
15048 |
|
15049 | if (!hasCursor) {
|
15050 | opts.cursorOffset = -1;
|
15051 | }
|
15052 |
|
15053 | if (opts.rangeStart < 0) {
|
15054 | opts.rangeStart = 0;
|
15055 | }
|
15056 |
|
15057 | if (opts.rangeEnd > text.length) {
|
15058 | opts.rangeEnd = text.length;
|
15059 | }
|
15060 |
|
15061 | const result = hasRangeStart || hasRangeEnd ? formatRange(text, opts) : coreFormat(opts.insertPragma && opts.printer.insertPragma && !hasPragma ? opts.printer.insertPragma(text) : text, opts);
|
15062 |
|
15063 | if (hasUnicodeBOM) {
|
15064 | result.formatted = BOM + result.formatted;
|
15065 |
|
15066 | if (hasCursor) {
|
15067 | result.cursorOffset++;
|
15068 | }
|
15069 | }
|
15070 |
|
15071 | return result;
|
15072 | }
|
15073 |
|
15074 | var core = {
|
15075 | formatWithCursor(text, opts) {
|
15076 | opts = normalizeOptions$1(opts);
|
15077 | return format(text, opts);
|
15078 | },
|
15079 |
|
15080 | parse(text, opts, massage) {
|
15081 | opts = normalizeOptions$1(opts);
|
15082 |
|
15083 | if (text.includes("\r")) {
|
15084 | text = text.replace(/\r\n?/g, "\n");
|
15085 | }
|
15086 |
|
15087 | const parsed = parser.parse(text, opts);
|
15088 |
|
15089 | if (massage) {
|
15090 | parsed.ast = massageAst(parsed.ast, opts);
|
15091 | }
|
15092 |
|
15093 | return parsed;
|
15094 | },
|
15095 |
|
15096 | formatAST(ast, opts) {
|
15097 | opts = normalizeOptions$1(opts);
|
15098 | const doc = astToDoc(ast, opts);
|
15099 | return printDocToString$1(doc, opts);
|
15100 | },
|
15101 |
|
15102 |
|
15103 | formatDoc(doc, opts) {
|
15104 | const debug = printDocToDebug(doc);
|
15105 | opts = normalizeOptions$1(Object.assign({}, opts, {
|
15106 | parser: "babel"
|
15107 | }));
|
15108 | return format(debug, opts).formatted;
|
15109 | },
|
15110 |
|
15111 | printToDoc(text, opts) {
|
15112 | opts = normalizeOptions$1(opts);
|
15113 | const parsed = parser.parse(text, opts);
|
15114 | const {
|
15115 | ast
|
15116 | } = parsed;
|
15117 | text = parsed.text;
|
15118 | attachComments(text, ast, opts);
|
15119 | return astToDoc(ast, opts);
|
15120 | },
|
15121 |
|
15122 | printDocToString(doc, opts) {
|
15123 | return printDocToString$1(doc, normalizeOptions$1(opts));
|
15124 | }
|
15125 |
|
15126 | };
|
15127 |
|
15128 |
|
15129 | function make_array(subject) {
|
15130 | return Array.isArray(subject) ? subject : [subject];
|
15131 | }
|
15132 |
|
15133 | const REGEX_BLANK_LINE = /^\s+$/;
|
15134 | const REGEX_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
15135 | const REGEX_LEADING_EXCAPED_HASH = /^\\#/;
|
15136 | const SLASH = '/';
|
15137 | const KEY_IGNORE = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
|
15138 |
|
15139 | : 'node-ignore';
|
15140 |
|
15141 | const define = (object, key, value) => Object.defineProperty(object, key, {
|
15142 | value
|
15143 | });
|
15144 |
|
15145 | const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
15146 |
|
15147 |
|
15148 | const sanitizeRange = range => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match
|
15149 |
|
15150 | : '');
|
15151 |
|
15152 |
|
15153 |
|
15154 |
|
15155 |
|
15156 |
|
15157 |
|
15158 |
|
15159 |
|
15160 |
|
15161 |
|
15162 | const DEFAULT_REPLACER_PREFIX = [
|
15163 | [
|
15164 |
|
15165 |
|
15166 | /\\?\s+$/, match => match.indexOf('\\') === 0 ? ' ' : ''],
|
15167 | [/\\\s/g, () => ' '],
|
15168 |
|
15169 |
|
15170 |
|
15171 |
|
15172 |
|
15173 |
|
15174 |
|
15175 |
|
15176 |
|
15177 |
|
15178 |
|
15179 |
|
15180 |
|
15181 |
|
15182 |
|
15183 | [/[\\^$.|*+(){]/g, match => `\\${match}`], [
|
15184 |
|
15185 | /\[([^\]/]*)($|\])/g, (match, p1, p2) => p2 === ']' ? `[${sanitizeRange(p1)}]` : `\\${match}`], [
|
15186 | /(?!\\)\?/g, () => '[^/]'],
|
15187 | [
|
15188 |
|
15189 |
|
15190 | /^\
|
15191 | [/\//g, () => '\\/'], [
|
15192 |
|
15193 |
|
15194 |
|
15195 |
|
15196 |
|
15197 | /^\^*\\\*\\\*\\\
|
15198 | () => '^(?:.*\\/)?']];
|
15199 | const DEFAULT_REPLACER_SUFFIX = [
|
15200 | [
|
15201 |
|
15202 |
|
15203 | /^(?=[^^])/, function startingReplacer() {
|
15204 | return !/\/(?!$)/.test(this)
|
15205 |
|
15206 |
|
15207 |
|
15208 | ? '(?:^|\\/)'
|
15209 |
|
15210 | : '^';
|
15211 | }],
|
15212 | [
|
15213 | /\\\/\\\*\\\*(?=\\\/|$)/g,
|
15214 |
|
15215 |
|
15216 | (match, index, str) => index + 6 < str.length
|
15217 |
|
15218 |
|
15219 |
|
15220 |
|
15221 | ? '(?:\\/[^\\/]+)*'
|
15222 |
|
15223 |
|
15224 | : '\\/.+'],
|
15225 | [
|
15226 |
|
15227 |
|
15228 |
|
15229 | /(^|[^\\]+)\\\*(?=.+)/g,
|
15230 |
|
15231 | (match, p1) => `${p1}[^\\/]*`],
|
15232 | [/(\^|\\\/)?\\\*$/, (match, p1) => {
|
15233 | const prefix = p1
|
15234 |
|
15235 |
|
15236 |
|
15237 |
|
15238 | ? `${p1}[^/]+`
|
15239 |
|
15240 | : '[^/]*';
|
15241 | return `${prefix}(?=$|\\/$)`;
|
15242 | }], [
|
15243 | /\\\\\\/g, () => '\\']];
|
15244 | const POSITIVE_REPLACERS = [...DEFAULT_REPLACER_PREFIX,
|
15245 |
|
15246 |
|
15247 |
|
15248 |
|
15249 |
|
15250 |
|
15251 |
|
15252 |
|
15253 |
|
15254 |
|
15255 |
|
15256 | [
|
15257 |
|
15258 | /(?:[^*/])$/,
|
15259 |
|
15260 |
|
15261 | match => `${match}(?=$|\\/)`], ...DEFAULT_REPLACER_SUFFIX];
|
15262 | const NEGATIVE_REPLACERS = [...DEFAULT_REPLACER_PREFIX,
|
15263 |
|
15264 |
|
15265 |
|
15266 |
|
15267 |
|
15268 |
|
15269 | [/(?:[^*])$/, match => `${match}(?=$|\\/$)`], ...DEFAULT_REPLACER_SUFFIX];
|
15270 |
|
15271 | const cache = Object.create(null);
|
15272 |
|
15273 | const make_regex = (pattern, negative, ignorecase) => {
|
15274 | const r = cache[pattern];
|
15275 |
|
15276 | if (r) {
|
15277 | return r;
|
15278 | }
|
15279 |
|
15280 | const replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
|
15281 | const source = replacers.reduce((prev, current) => prev.replace(current[0], current[1].bind(pattern)), pattern);
|
15282 | return cache[pattern] = ignorecase ? new RegExp(source, 'i') : new RegExp(source);
|
15283 | };
|
15284 |
|
15285 |
|
15286 | const checkPattern = pattern => pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern)
|
15287 | && pattern.indexOf('#') !== 0;
|
15288 |
|
15289 | const createRule = (pattern, ignorecase) => {
|
15290 | const origin = pattern;
|
15291 | let negative = false;
|
15292 |
|
15293 | if (pattern.indexOf('!') === 0) {
|
15294 | negative = true;
|
15295 | pattern = pattern.substr(1);
|
15296 | }
|
15297 |
|
15298 | pattern = pattern
|
15299 |
|
15300 | .replace(REGEX_LEADING_EXCAPED_EXCLAMATION, '!')
|
15301 |
|
15302 | .replace(REGEX_LEADING_EXCAPED_HASH, '#');
|
15303 | const regex = make_regex(pattern, negative, ignorecase);
|
15304 | return {
|
15305 | origin,
|
15306 | pattern,
|
15307 | negative,
|
15308 | regex
|
15309 | };
|
15310 | };
|
15311 |
|
15312 | class IgnoreBase {
|
15313 | constructor({
|
15314 | ignorecase = true
|
15315 | } = {}) {
|
15316 | this._rules = [];
|
15317 | this._ignorecase = ignorecase;
|
15318 | define(this, KEY_IGNORE, true);
|
15319 |
|
15320 | this._initCache();
|
15321 | }
|
15322 |
|
15323 | _initCache() {
|
15324 | this._cache = Object.create(null);
|
15325 | }
|
15326 |
|
15327 |
|
15328 | add(pattern) {
|
15329 | this._added = false;
|
15330 |
|
15331 | if (typeof pattern === 'string') {
|
15332 | pattern = pattern.split(/\r?\n/g);
|
15333 | }
|
15334 |
|
15335 | make_array(pattern).forEach(this._addPattern, this);
|
15336 |
|
15337 |
|
15338 | if (this._added) {
|
15339 | this._initCache();
|
15340 | }
|
15341 |
|
15342 | return this;
|
15343 | }
|
15344 |
|
15345 |
|
15346 | addPattern(pattern) {
|
15347 | return this.add(pattern);
|
15348 | }
|
15349 |
|
15350 | _addPattern(pattern) {
|
15351 |
|
15352 | if (pattern && pattern[KEY_IGNORE]) {
|
15353 | this._rules = this._rules.concat(pattern._rules);
|
15354 | this._added = true;
|
15355 | return;
|
15356 | }
|
15357 |
|
15358 | if (checkPattern(pattern)) {
|
15359 | const rule = createRule(pattern, this._ignorecase);
|
15360 | this._added = true;
|
15361 |
|
15362 | this._rules.push(rule);
|
15363 | }
|
15364 | }
|
15365 |
|
15366 | filter(paths) {
|
15367 | return make_array(paths).filter(path => this._filter(path));
|
15368 | }
|
15369 |
|
15370 | createFilter() {
|
15371 | return path => this._filter(path);
|
15372 | }
|
15373 |
|
15374 | ignores(path) {
|
15375 | return !this._filter(path);
|
15376 | }
|
15377 |
|
15378 |
|
15379 | _filter(path, slices) {
|
15380 | if (!path) {
|
15381 | return false;
|
15382 | }
|
15383 |
|
15384 | if (path in this._cache) {
|
15385 | return this._cache[path];
|
15386 | }
|
15387 |
|
15388 | if (!slices) {
|
15389 |
|
15390 |
|
15391 | slices = path.split(SLASH);
|
15392 | }
|
15393 |
|
15394 | slices.pop();
|
15395 | return this._cache[path] = slices.length
|
15396 |
|
15397 |
|
15398 | ? this._filter(slices.join(SLASH) + SLASH, slices) && this._test(path)
|
15399 | : this._test(path);
|
15400 | }
|
15401 |
|
15402 |
|
15403 | _test(path) {
|
15404 |
|
15405 | let matched = 0;
|
15406 |
|
15407 | this._rules.forEach(rule => {
|
15408 |
|
15409 |
|
15410 | if (!(matched ^ rule.negative)) {
|
15411 | matched = rule.negative ^ rule.regex.test(path);
|
15412 | }
|
15413 | });
|
15414 |
|
15415 | return !matched;
|
15416 | }
|
15417 |
|
15418 | }
|
15419 |
|
15420 |
|
15421 |
|
15422 |
|
15423 |
|
15424 | if (
|
15425 | typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
|
15426 | const filter = IgnoreBase.prototype._filter;
|
15427 |
|
15428 |
|
15429 | const make_posix = str => /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
|
15430 |
|
15431 | IgnoreBase.prototype._filter = function filterWin32(path, slices) {
|
15432 | path = make_posix(path);
|
15433 | return filter.call(this, path, slices);
|
15434 | };
|
15435 | }
|
15436 |
|
15437 | var ignore = options => new IgnoreBase(options);
|
15438 |
|
15439 |
|
15440 |
|
15441 |
|
15442 |
|
15443 |
|
15444 |
|
15445 | function getFileContentOrNull(filename) {
|
15446 | return new Promise((resolve, reject) => {
|
15447 | fs$3.readFile(filename, "utf8", (error, data) => {
|
15448 | if (error && error.code !== "ENOENT") {
|
15449 | reject(createError(filename, error));
|
15450 | } else {
|
15451 | resolve(error ? null : data);
|
15452 | }
|
15453 | });
|
15454 | });
|
15455 | }
|
15456 |
|
15457 |
|
15458 |
|
15459 |
|
15460 |
|
15461 |
|
15462 | getFileContentOrNull.sync = function (filename) {
|
15463 | try {
|
15464 | return fs$3.readFileSync(filename, "utf8");
|
15465 | } catch (error) {
|
15466 | if (error && error.code === "ENOENT") {
|
15467 | return null;
|
15468 | }
|
15469 |
|
15470 | throw createError(filename, error);
|
15471 | }
|
15472 | };
|
15473 |
|
15474 | function createError(filename, error) {
|
15475 | return new Error(`Unable to read ${filename}: ${error.message}`);
|
15476 | }
|
15477 |
|
15478 | var getFileContentOrNull_1 = getFileContentOrNull;
|
15479 |
|
15480 |
|
15481 |
|
15482 |
|
15483 |
|
15484 |
|
15485 |
|
15486 | async function createIgnorer(ignorePath, withNodeModules) {
|
15487 | const ignoreContent = ignorePath ? await getFileContentOrNull_1(path$2.resolve(ignorePath)) : null;
|
15488 | return _createIgnorer(ignoreContent, withNodeModules);
|
15489 | }
|
15490 |
|
15491 |
|
15492 |
|
15493 |
|
15494 |
|
15495 |
|
15496 | createIgnorer.sync = function (ignorePath, withNodeModules) {
|
15497 | const ignoreContent = !ignorePath ? null : getFileContentOrNull_1.sync(path$2.resolve(ignorePath));
|
15498 | return _createIgnorer(ignoreContent, withNodeModules);
|
15499 | };
|
15500 |
|
15501 |
|
15502 |
|
15503 |
|
15504 |
|
15505 |
|
15506 | function _createIgnorer(ignoreContent, withNodeModules) {
|
15507 | const ignorer = ignore().add(ignoreContent || "");
|
15508 |
|
15509 | if (!withNodeModules) {
|
15510 | ignorer.add("node_modules");
|
15511 | }
|
15512 |
|
15513 | return ignorer;
|
15514 | }
|
15515 |
|
15516 | var createIgnorer_1 = createIgnorer;
|
15517 |
|
15518 | var thirdParty = require("./third-party");
|
15519 |
|
15520 | var concatMap = function (xs, fn) {
|
15521 | var res = [];
|
15522 |
|
15523 | for (var i = 0; i < xs.length; i++) {
|
15524 | var x = fn(xs[i], i);
|
15525 | if (isArray(x)) res.push.apply(res, x);else res.push(x);
|
15526 | }
|
15527 |
|
15528 | return res;
|
15529 | };
|
15530 |
|
15531 | var isArray = Array.isArray || function (xs) {
|
15532 | return Object.prototype.toString.call(xs) === '[object Array]';
|
15533 | };
|
15534 |
|
15535 | var balancedMatch = balanced;
|
15536 |
|
15537 | function balanced(a, b, str) {
|
15538 | if (a instanceof RegExp) a = maybeMatch(a, str);
|
15539 | if (b instanceof RegExp) b = maybeMatch(b, str);
|
15540 | var r = range(a, b, str);
|
15541 | return r && {
|
15542 | start: r[0],
|
15543 | end: r[1],
|
15544 | pre: str.slice(0, r[0]),
|
15545 | body: str.slice(r[0] + a.length, r[1]),
|
15546 | post: str.slice(r[1] + b.length)
|
15547 | };
|
15548 | }
|
15549 |
|
15550 | function maybeMatch(reg, str) {
|
15551 | var m = str.match(reg);
|
15552 | return m ? m[0] : null;
|
15553 | }
|
15554 |
|
15555 | balanced.range = range;
|
15556 |
|
15557 | function range(a, b, str) {
|
15558 | var begs, beg, left, right, result;
|
15559 | var ai = str.indexOf(a);
|
15560 | var bi = str.indexOf(b, ai + 1);
|
15561 | var i = ai;
|
15562 |
|
15563 | if (ai >= 0 && bi > 0) {
|
15564 | begs = [];
|
15565 | left = str.length;
|
15566 |
|
15567 | while (i >= 0 && !result) {
|
15568 | if (i == ai) {
|
15569 | begs.push(i);
|
15570 | ai = str.indexOf(a, i + 1);
|
15571 | } else if (begs.length == 1) {
|
15572 | result = [begs.pop(), bi];
|
15573 | } else {
|
15574 | beg = begs.pop();
|
15575 |
|
15576 | if (beg < left) {
|
15577 | left = beg;
|
15578 | right = bi;
|
15579 | }
|
15580 |
|
15581 | bi = str.indexOf(b, i + 1);
|
15582 | }
|
15583 |
|
15584 | i = ai < bi && ai >= 0 ? ai : bi;
|
15585 | }
|
15586 |
|
15587 | if (begs.length) {
|
15588 | result = [left, right];
|
15589 | }
|
15590 | }
|
15591 |
|
15592 | return result;
|
15593 | }
|
15594 |
|
15595 | var braceExpansion = expandTop;
|
15596 | var escSlash = '\0SLASH' + Math.random() + '\0';
|
15597 | var escOpen = '\0OPEN' + Math.random() + '\0';
|
15598 | var escClose = '\0CLOSE' + Math.random() + '\0';
|
15599 | var escComma = '\0COMMA' + Math.random() + '\0';
|
15600 | var escPeriod = '\0PERIOD' + Math.random() + '\0';
|
15601 |
|
15602 | function numeric$1(str) {
|
15603 | return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
|
15604 | }
|
15605 |
|
15606 | function escapeBraces(str) {
|
15607 | return str.split('\\\\').join(escSlash).split('\\{').join(escOpen).split('\\}').join(escClose).split('\\,').join(escComma).split('\\.').join(escPeriod);
|
15608 | }
|
15609 |
|
15610 | function unescapeBraces(str) {
|
15611 | return str.split(escSlash).join('\\').split(escOpen).join('{').split(escClose).join('}').split(escComma).join(',').split(escPeriod).join('.');
|
15612 | }
|
15613 |
|
15614 |
|
15615 |
|
15616 |
|
15617 | function parseCommaParts(str) {
|
15618 | if (!str) return [''];
|
15619 | var parts = [];
|
15620 | var m = balancedMatch('{', '}', str);
|
15621 | if (!m) return str.split(',');
|
15622 | var pre = m.pre;
|
15623 | var body = m.body;
|
15624 | var post = m.post;
|
15625 | var p = pre.split(',');
|
15626 | p[p.length - 1] += '{' + body + '}';
|
15627 | var postParts = parseCommaParts(post);
|
15628 |
|
15629 | if (post.length) {
|
15630 | p[p.length - 1] += postParts.shift();
|
15631 | p.push.apply(p, postParts);
|
15632 | }
|
15633 |
|
15634 | parts.push.apply(parts, p);
|
15635 | return parts;
|
15636 | }
|
15637 |
|
15638 | function expandTop(str) {
|
15639 | if (!str) return [];
|
15640 |
|
15641 |
|
15642 |
|
15643 |
|
15644 |
|
15645 |
|
15646 | if (str.substr(0, 2) === '{}') {
|
15647 | str = '\\{\\}' + str.substr(2);
|
15648 | }
|
15649 |
|
15650 | return expand(escapeBraces(str), true).map(unescapeBraces);
|
15651 | }
|
15652 |
|
15653 | function embrace(str) {
|
15654 | return '{' + str + '}';
|
15655 | }
|
15656 |
|
15657 | function isPadded(el) {
|
15658 | return /^-?0\d/.test(el);
|
15659 | }
|
15660 |
|
15661 | function lte(i, y) {
|
15662 | return i <= y;
|
15663 | }
|
15664 |
|
15665 | function gte$1(i, y) {
|
15666 | return i >= y;
|
15667 | }
|
15668 |
|
15669 | function expand(str, isTop) {
|
15670 | var expansions = [];
|
15671 | var m = balancedMatch('{', '}', str);
|
15672 | if (!m || /\$$/.test(m.pre)) return [str];
|
15673 | var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
15674 | var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
15675 | var isSequence = isNumericSequence || isAlphaSequence;
|
15676 | var isOptions = m.body.indexOf(',') >= 0;
|
15677 |
|
15678 | if (!isSequence && !isOptions) {
|
15679 |
|
15680 | if (m.post.match(/,.*\}/)) {
|
15681 | str = m.pre + '{' + m.body + escClose + m.post;
|
15682 | return expand(str);
|
15683 | }
|
15684 |
|
15685 | return [str];
|
15686 | }
|
15687 |
|
15688 | var n;
|
15689 |
|
15690 | if (isSequence) {
|
15691 | n = m.body.split(/\.\./);
|
15692 | } else {
|
15693 | n = parseCommaParts(m.body);
|
15694 |
|
15695 | if (n.length === 1) {
|
15696 |
|
15697 | n = expand(n[0], false).map(embrace);
|
15698 |
|
15699 | if (n.length === 1) {
|
15700 | var post = m.post.length ? expand(m.post, false) : [''];
|
15701 | return post.map(function (p) {
|
15702 | return m.pre + n[0] + p;
|
15703 | });
|
15704 | }
|
15705 | }
|
15706 | }
|
15707 |
|
15708 |
|
15709 |
|
15710 |
|
15711 | var pre = m.pre;
|
15712 | var post = m.post.length ? expand(m.post, false) : [''];
|
15713 | var N;
|
15714 |
|
15715 | if (isSequence) {
|
15716 | var x = numeric$1(n[0]);
|
15717 | var y = numeric$1(n[1]);
|
15718 | var width = Math.max(n[0].length, n[1].length);
|
15719 | var incr = n.length == 3 ? Math.abs(numeric$1(n[2])) : 1;
|
15720 | var test = lte;
|
15721 | var reverse = y < x;
|
15722 |
|
15723 | if (reverse) {
|
15724 | incr *= -1;
|
15725 | test = gte$1;
|
15726 | }
|
15727 |
|
15728 | var pad = n.some(isPadded);
|
15729 | N = [];
|
15730 |
|
15731 | for (var i = x; test(i, y); i += incr) {
|
15732 | var c;
|
15733 |
|
15734 | if (isAlphaSequence) {
|
15735 | c = String.fromCharCode(i);
|
15736 | if (c === '\\') c = '';
|
15737 | } else {
|
15738 | c = String(i);
|
15739 |
|
15740 | if (pad) {
|
15741 | var need = width - c.length;
|
15742 |
|
15743 | if (need > 0) {
|
15744 | var z = new Array(need + 1).join('0');
|
15745 | if (i < 0) c = '-' + z + c.slice(1);else c = z + c;
|
15746 | }
|
15747 | }
|
15748 | }
|
15749 |
|
15750 | N.push(c);
|
15751 | }
|
15752 | } else {
|
15753 | N = concatMap(n, function (el) {
|
15754 | return expand(el, false);
|
15755 | });
|
15756 | }
|
15757 |
|
15758 | for (var j = 0; j < N.length; j++) {
|
15759 | for (var k = 0; k < post.length; k++) {
|
15760 | var expansion = pre + N[j] + post[k];
|
15761 | if (!isTop || isSequence || expansion) expansions.push(expansion);
|
15762 | }
|
15763 | }
|
15764 |
|
15765 | return expansions;
|
15766 | }
|
15767 |
|
15768 | var minimatch_1 = minimatch;
|
15769 | minimatch.Minimatch = Minimatch;
|
15770 | var path = {
|
15771 | sep: '/'
|
15772 | };
|
15773 |
|
15774 | try {
|
15775 | path = path$2;
|
15776 | } catch (er) {}
|
15777 |
|
15778 | var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {};
|
15779 | var plTypes = {
|
15780 | '!': {
|
15781 | open: '(?:(?!(?:',
|
15782 | close: '))[^/]*?)'
|
15783 | },
|
15784 | '?': {
|
15785 | open: '(?:',
|
15786 | close: ')?'
|
15787 | },
|
15788 | '+': {
|
15789 | open: '(?:',
|
15790 | close: ')+'
|
15791 | },
|
15792 | '*': {
|
15793 | open: '(?:',
|
15794 | close: ')*'
|
15795 | },
|
15796 | '@': {
|
15797 | open: '(?:',
|
15798 | close: ')'
|
15799 | }
|
15800 | };
|
15801 |
|
15802 |
|
15803 | var qmark = '[^/]';
|
15804 |
|
15805 | var star = qmark + '*?';
|
15806 |
|
15807 |
|
15808 |
|
15809 | var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?';
|
15810 |
|
15811 |
|
15812 | var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?';
|
15813 |
|
15814 | var reSpecials = charSet('().*{}+?[]^$\\!');
|
15815 |
|
15816 | function charSet(s) {
|
15817 | return s.split('').reduce(function (set, c) {
|
15818 | set[c] = true;
|
15819 | return set;
|
15820 | }, {});
|
15821 | }
|
15822 |
|
15823 |
|
15824 | var slashSplit = /\/+/;
|
15825 | minimatch.filter = filter;
|
15826 |
|
15827 | function filter(pattern, options) {
|
15828 | options = options || {};
|
15829 | return function (p, i, list) {
|
15830 | return minimatch(p, pattern, options);
|
15831 | };
|
15832 | }
|
15833 |
|
15834 | function ext(a, b) {
|
15835 | a = a || {};
|
15836 | b = b || {};
|
15837 | var t = {};
|
15838 | Object.keys(b).forEach(function (k) {
|
15839 | t[k] = b[k];
|
15840 | });
|
15841 | Object.keys(a).forEach(function (k) {
|
15842 | t[k] = a[k];
|
15843 | });
|
15844 | return t;
|
15845 | }
|
15846 |
|
15847 | minimatch.defaults = function (def) {
|
15848 | if (!def || !Object.keys(def).length) return minimatch;
|
15849 | var orig = minimatch;
|
15850 |
|
15851 | var m = function minimatch(p, pattern, options) {
|
15852 | return orig.minimatch(p, pattern, ext(def, options));
|
15853 | };
|
15854 |
|
15855 | m.Minimatch = function Minimatch(pattern, options) {
|
15856 | return new orig.Minimatch(pattern, ext(def, options));
|
15857 | };
|
15858 |
|
15859 | return m;
|
15860 | };
|
15861 |
|
15862 | Minimatch.defaults = function (def) {
|
15863 | if (!def || !Object.keys(def).length) return Minimatch;
|
15864 | return minimatch.defaults(def).Minimatch;
|
15865 | };
|
15866 |
|
15867 | function minimatch(p, pattern, options) {
|
15868 | if (typeof pattern !== 'string') {
|
15869 | throw new TypeError('glob pattern string required');
|
15870 | }
|
15871 |
|
15872 | if (!options) options = {};
|
15873 |
|
15874 | if (!options.nocomment && pattern.charAt(0) === '#') {
|
15875 | return false;
|
15876 | }
|
15877 |
|
15878 |
|
15879 | if (pattern.trim() === '') return p === '';
|
15880 | return new Minimatch(pattern, options).match(p);
|
15881 | }
|
15882 |
|
15883 | function Minimatch(pattern, options) {
|
15884 | if (!(this instanceof Minimatch)) {
|
15885 | return new Minimatch(pattern, options);
|
15886 | }
|
15887 |
|
15888 | if (typeof pattern !== 'string') {
|
15889 | throw new TypeError('glob pattern string required');
|
15890 | }
|
15891 |
|
15892 | if (!options) options = {};
|
15893 | pattern = pattern.trim();
|
15894 |
|
15895 | if (path.sep !== '/') {
|
15896 | pattern = pattern.split(path.sep).join('/');
|
15897 | }
|
15898 |
|
15899 | this.options = options;
|
15900 | this.set = [];
|
15901 | this.pattern = pattern;
|
15902 | this.regexp = null;
|
15903 | this.negate = false;
|
15904 | this.comment = false;
|
15905 | this.empty = false;
|
15906 |
|
15907 | this.make();
|
15908 | }
|
15909 |
|
15910 | Minimatch.prototype.debug = function () {};
|
15911 |
|
15912 | Minimatch.prototype.make = make;
|
15913 |
|
15914 | function make() {
|
15915 |
|
15916 | if (this._made) return;
|
15917 | var pattern = this.pattern;
|
15918 | var options = this.options;
|
15919 |
|
15920 | if (!options.nocomment && pattern.charAt(0) === '#') {
|
15921 | this.comment = true;
|
15922 | return;
|
15923 | }
|
15924 |
|
15925 | if (!pattern) {
|
15926 | this.empty = true;
|
15927 | return;
|
15928 | }
|
15929 |
|
15930 |
|
15931 | this.parseNegate();
|
15932 |
|
15933 | var set = this.globSet = this.braceExpand();
|
15934 | if (options.debug) this.debug = console.error;
|
15935 | this.debug(this.pattern, set); // step 3: now we have a set, so turn each one into a series of path-portion
|
15936 | // matching patterns.
|
15937 | // These will be regexps, except in the case of "**", which is
|
15938 | // set to the GLOBSTAR object for globstar behavior,
|
15939 | // and will not contain any / characters
|
15940 |
|
15941 | set = this.globParts = set.map(function (s) {
|
15942 | return s.split(slashSplit);
|
15943 | });
|
15944 | this.debug(this.pattern, set); // glob --> regexps
|
15945 |
|
15946 | set = set.map(function (s, si, set) {
|
15947 | return s.map(this.parse, this);
|
15948 | }, this);
|
15949 | this.debug(this.pattern, set); // filter out everything that didn't compile properly.
|
15950 |
|
15951 | set = set.filter(function (s) {
|
15952 | return s.indexOf(false) === -1;
|
15953 | });
|
15954 | this.debug(this.pattern, set);
|
15955 | this.set = set;
|
15956 | }
|
15957 |
|
15958 | Minimatch.prototype.parseNegate = parseNegate;
|
15959 |
|
15960 | function parseNegate() {
|
15961 | var pattern = this.pattern;
|
15962 | var negate = false;
|
15963 | var options = this.options;
|
15964 | var negateOffset = 0;
|
15965 | if (options.nonegate) return;
|
15966 |
|
15967 | for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === '!'; i++) {
|
15968 | negate = !negate;
|
15969 | negateOffset++;
|
15970 | }
|
15971 |
|
15972 | if (negateOffset) this.pattern = pattern.substr(negateOffset);
|
15973 | this.negate = negate;
|
15974 | }
|
15975 |
|
15976 |
|
15977 |
|
15978 |
|
15979 |
|
15980 |
|
15981 |
|
15982 |
|
15983 |
|
15984 |
|
15985 |
|
15986 | minimatch.braceExpand = function (pattern, options) {
|
15987 | return braceExpand(pattern, options);
|
15988 | };
|
15989 |
|
15990 | Minimatch.prototype.braceExpand = braceExpand;
|
15991 |
|
15992 | function braceExpand(pattern, options) {
|
15993 | if (!options) {
|
15994 | if (this instanceof Minimatch) {
|
15995 | options = this.options;
|
15996 | } else {
|
15997 | options = {};
|
15998 | }
|
15999 | }
|
16000 |
|
16001 | pattern = typeof pattern === 'undefined' ? this.pattern : pattern;
|
16002 |
|
16003 | if (typeof pattern === 'undefined') {
|
16004 | throw new TypeError('undefined pattern');
|
16005 | }
|
16006 |
|
16007 | if (options.nobrace || !pattern.match(/\{.*\}/)) {
|
16008 |
|
16009 | return [pattern];
|
16010 | }
|
16011 |
|
16012 | return braceExpansion(pattern);
|
16013 | }
|
16014 |
|
16015 |
|
16016 |
|
16017 |
|
16018 |
|
16019 |
|
16020 |
|
16021 |
|
16022 |
|
16023 |
|
16024 |
|
16025 |
|
16026 | Minimatch.prototype.parse = parse$1;
|
16027 | var SUBPARSE = {};
|
16028 |
|
16029 | function parse$1(pattern, isSub) {
|
16030 | if (pattern.length > 1024 * 64) {
|
16031 | throw new TypeError('pattern is too long');
|
16032 | }
|
16033 |
|
16034 | var options = this.options;
|
16035 |
|
16036 | if (!options.noglobstar && pattern === '**') return GLOBSTAR;
|
16037 | if (pattern === '') return '';
|
16038 | var re = '';
|
16039 | var hasMagic = !!options.nocase;
|
16040 | var escaping = false;
|
16041 |
|
16042 | var patternListStack = [];
|
16043 | var negativeLists = [];
|
16044 | var stateChar;
|
16045 | var inClass = false;
|
16046 | var reClassStart = -1;
|
16047 | var classStart = -1;
|
16048 |
|
16049 |
|
16050 | var patternStart = pattern.charAt(0) === '.' ? ''
|
16051 |
|
16052 | : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' : '(?!\\.)';
|
16053 | var self = this;
|
16054 |
|
16055 | function clearStateChar() {
|
16056 | if (stateChar) {
|
16057 |
|
16058 |
|
16059 | switch (stateChar) {
|
16060 | case '*':
|
16061 | re += star;
|
16062 | hasMagic = true;
|
16063 | break;
|
16064 |
|
16065 | case '?':
|
16066 | re += qmark;
|
16067 | hasMagic = true;
|
16068 | break;
|
16069 |
|
16070 | default:
|
16071 | re += '\\' + stateChar;
|
16072 | break;
|
16073 | }
|
16074 |
|
16075 | self.debug('clearStateChar %j %j', stateChar, re);
|
16076 | stateChar = false;
|
16077 | }
|
16078 | }
|
16079 |
|
16080 | for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
|
16081 | this.debug('%s\t%s %s %j', pattern, i, re, c);
|
16082 |
|
16083 | if (escaping && reSpecials[c]) {
|
16084 | re += '\\' + c;
|
16085 | escaping = false;
|
16086 | continue;
|
16087 | }
|
16088 |
|
16089 | switch (c) {
|
16090 | case '/':
|
16091 |
|
16092 |
|
16093 | return false;
|
16094 |
|
16095 | case '\\':
|
16096 | clearStateChar();
|
16097 | escaping = true;
|
16098 | continue;
|
16099 |
|
16100 |
|
16101 |
|
16102 | case '?':
|
16103 | case '*':
|
16104 | case '+':
|
16105 | case '@':
|
16106 | case '!':
|
16107 | this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c);
|
16108 |
|
16109 |
|
16110 | if (inClass) {
|
16111 | this.debug(' in class');
|
16112 | if (c === '!' && i === classStart + 1) c = '^';
|
16113 | re += c;
|
16114 | continue;
|
16115 | }
|
16116 |
|
16117 |
|
16118 |
|
16119 |
|
16120 | self.debug('call clearStateChar %j', stateChar);
|
16121 | clearStateChar();
|
16122 | stateChar = c;
|
16123 |
|
16124 |
|
16125 |
|
16126 | if (options.noext) clearStateChar();
|
16127 | continue;
|
16128 |
|
16129 | case '(':
|
16130 | if (inClass) {
|
16131 | re += '(';
|
16132 | continue;
|
16133 | }
|
16134 |
|
16135 | if (!stateChar) {
|
16136 | re += '\\(';
|
16137 | continue;
|
16138 | }
|
16139 |
|
16140 | patternListStack.push({
|
16141 | type: stateChar,
|
16142 | start: i - 1,
|
16143 | reStart: re.length,
|
16144 | open: plTypes[stateChar].open,
|
16145 | close: plTypes[stateChar].close
|
16146 | });
|
16147 |
|
16148 | re += stateChar === '!' ? '(?:(?!(?:' : '(?:';
|
16149 | this.debug('plType %j %j', stateChar, re);
|
16150 | stateChar = false;
|
16151 | continue;
|
16152 |
|
16153 | case ')':
|
16154 | if (inClass || !patternListStack.length) {
|
16155 | re += '\\)';
|
16156 | continue;
|
16157 | }
|
16158 |
|
16159 | clearStateChar();
|
16160 | hasMagic = true;
|
16161 | var pl = patternListStack.pop();
|
16162 |
|
16163 |
|
16164 | re += pl.close;
|
16165 |
|
16166 | if (pl.type === '!') {
|
16167 | negativeLists.push(pl);
|
16168 | }
|
16169 |
|
16170 | pl.reEnd = re.length;
|
16171 | continue;
|
16172 |
|
16173 | case '|':
|
16174 | if (inClass || !patternListStack.length || escaping) {
|
16175 | re += '\\|';
|
16176 | escaping = false;
|
16177 | continue;
|
16178 | }
|
16179 |
|
16180 | clearStateChar();
|
16181 | re += '|';
|
16182 | continue;
|
16183 |
|
16184 |
|
16185 | case '[':
|
16186 |
|
16187 | clearStateChar();
|
16188 |
|
16189 | if (inClass) {
|
16190 | re += '\\' + c;
|
16191 | continue;
|
16192 | }
|
16193 |
|
16194 | inClass = true;
|
16195 | classStart = i;
|
16196 | reClassStart = re.length;
|
16197 | re += c;
|
16198 | continue;
|
16199 |
|
16200 | case ']':
|
16201 |
|
16202 |
|
16203 |
|
16204 |
|
16205 | if (i === classStart + 1 || !inClass) {
|
16206 | re += '\\' + c;
|
16207 | escaping = false;
|
16208 | continue;
|
16209 | }
|
16210 |
|
16211 |
|
16212 |
|
16213 | if (inClass) {
|
16214 |
|
16215 |
|
16216 |
|
16217 |
|
16218 |
|
16219 |
|
16220 |
|
16221 | var cs = pattern.substring(classStart + 1, i);
|
16222 |
|
16223 | try {
|
16224 | RegExp('[' + cs + ']');
|
16225 | } catch (er) {
|
16226 |
|
16227 | var sp = this.parse(cs, SUBPARSE);
|
16228 | re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]';
|
16229 | hasMagic = hasMagic || sp[1];
|
16230 | inClass = false;
|
16231 | continue;
|
16232 | }
|
16233 | }
|
16234 |
|
16235 |
|
16236 | hasMagic = true;
|
16237 | inClass = false;
|
16238 | re += c;
|
16239 | continue;
|
16240 |
|
16241 | default:
|
16242 |
|
16243 | clearStateChar();
|
16244 |
|
16245 | if (escaping) {
|
16246 |
|
16247 | escaping = false;
|
16248 | } else if (reSpecials[c] && !(c === '^' && inClass)) {
|
16249 | re += '\\';
|
16250 | }
|
16251 |
|
16252 | re += c;
|
16253 | }
|
16254 |
|
16255 | }
|
16256 |
|
16257 |
|
16258 |
|
16259 |
|
16260 | if (inClass) {
|
16261 |
|
16262 |
|
16263 |
|
16264 |
|
16265 | cs = pattern.substr(classStart + 1);
|
16266 | sp = this.parse(cs, SUBPARSE);
|
16267 | re = re.substr(0, reClassStart) + '\\[' + sp[0];
|
16268 | hasMagic = hasMagic || sp[1];
|
16269 | }
|
16270 |
|
16271 |
|
16272 |
|
16273 |
|
16274 |
|
16275 |
|
16276 |
|
16277 | for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
|
16278 | var tail = re.slice(pl.reStart + pl.open.length);
|
16279 | this.debug('setting tail', re, pl);
|
16280 |
|
16281 | tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
|
16282 | if (!$2) {
|
16283 |
|
16284 | $2 = '\\';
|
16285 | }
|
16286 |
|
16287 |
|
16288 |
|
16289 |
|
16290 |
|
16291 |
|
16292 |
|
16293 | return $1 + $1 + $2 + '|';
|
16294 | });
|
16295 | this.debug('tail=%j\n %s', tail, tail, pl, re);
|
16296 | var t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type;
|
16297 | hasMagic = true;
|
16298 | re = re.slice(0, pl.reStart) + t + '\\(' + tail;
|
16299 | }
|
16300 |
|
16301 |
|
16302 | clearStateChar();
|
16303 |
|
16304 | if (escaping) {
|
16305 |
|
16306 | re += '\\\\';
|
16307 | }
|
16308 |
|
16309 |
|
16310 |
|
16311 | var addPatternStart = false;
|
16312 |
|
16313 | switch (re.charAt(0)) {
|
16314 | case '.':
|
16315 | case '[':
|
16316 | case '(':
|
16317 | addPatternStart = true;
|
16318 | }
|
16319 |
|
16320 |
|
16321 |
|
16322 |
|
16323 |
|
16324 |
|
16325 | for (var n = negativeLists.length - 1; n > -1; n--) {
|
16326 | var nl = negativeLists[n];
|
16327 | var nlBefore = re.slice(0, nl.reStart);
|
16328 | var nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
|
16329 | var nlLast = re.slice(nl.reEnd - 8, nl.reEnd);
|
16330 | var nlAfter = re.slice(nl.reEnd);
|
16331 | nlLast += nlAfter;
|
16332 |
|
16333 |
|
16334 |
|
16335 | var openParensBefore = nlBefore.split('(').length - 1;
|
16336 | var cleanAfter = nlAfter;
|
16337 |
|
16338 | for (i = 0; i < openParensBefore; i++) {
|
16339 | cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
|
16340 | }
|
16341 |
|
16342 | nlAfter = cleanAfter;
|
16343 | var dollar = '';
|
16344 |
|
16345 | if (nlAfter === '' && isSub !== SUBPARSE) {
|
16346 | dollar = '$';
|
16347 | }
|
16348 |
|
16349 | var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast;
|
16350 | re = newRe;
|
16351 | }
|
16352 |
|
16353 |
|
16354 |
|
16355 |
|
16356 | if (re !== '' && hasMagic) {
|
16357 | re = '(?=.)' + re;
|
16358 | }
|
16359 |
|
16360 | if (addPatternStart) {
|
16361 | re = patternStart + re;
|
16362 | }
|
16363 |
|
16364 |
|
16365 | if (isSub === SUBPARSE) {
|
16366 | return [re, hasMagic];
|
16367 | }
|
16368 |
|
16369 |
|
16370 |
|
16371 |
|
16372 | if (!hasMagic) {
|
16373 | return globUnescape(pattern);
|
16374 | }
|
16375 |
|
16376 | var flags = options.nocase ? 'i' : '';
|
16377 |
|
16378 | try {
|
16379 | var regExp = new RegExp('^' + re + '$', flags);
|
16380 | } catch (er) {
|
16381 |
|
16382 |
|
16383 |
|
16384 |
|
16385 | return new RegExp('$.');
|
16386 | }
|
16387 |
|
16388 | regExp._glob = pattern;
|
16389 | regExp._src = re;
|
16390 | return regExp;
|
16391 | }
|
16392 |
|
16393 | minimatch.makeRe = function (pattern, options) {
|
16394 | return new Minimatch(pattern, options || {}).makeRe();
|
16395 | };
|
16396 |
|
16397 | Minimatch.prototype.makeRe = makeRe;
|
16398 |
|
16399 | function makeRe() {
|
16400 | if (this.regexp || this.regexp === false) return this.regexp;
|
16401 |
|
16402 |
|
16403 |
|
16404 |
|
16405 |
|
16406 |
|
16407 | var set = this.set;
|
16408 |
|
16409 | if (!set.length) {
|
16410 | this.regexp = false;
|
16411 | return this.regexp;
|
16412 | }
|
16413 |
|
16414 | var options = this.options;
|
16415 | var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
|
16416 | var flags = options.nocase ? 'i' : '';
|
16417 | var re = set.map(function (pattern) {
|
16418 | return pattern.map(function (p) {
|
16419 | return p === GLOBSTAR ? twoStar : typeof p === 'string' ? regExpEscape(p) : p._src;
|
16420 | }).join('\\\/');
|
16421 | }).join('|');
|
16422 |
|
16423 |
|
16424 | re = '^(?:' + re + ')$';
|
16425 |
|
16426 | if (this.negate) re = '^(?!' + re + ').*$';
|
16427 |
|
16428 | try {
|
16429 | this.regexp = new RegExp(re, flags);
|
16430 | } catch (ex) {
|
16431 | this.regexp = false;
|
16432 | }
|
16433 |
|
16434 | return this.regexp;
|
16435 | }
|
16436 |
|
16437 | minimatch.match = function (list, pattern, options) {
|
16438 | options = options || {};
|
16439 | var mm = new Minimatch(pattern, options);
|
16440 | list = list.filter(function (f) {
|
16441 | return mm.match(f);
|
16442 | });
|
16443 |
|
16444 | if (mm.options.nonull && !list.length) {
|
16445 | list.push(pattern);
|
16446 | }
|
16447 |
|
16448 | return list;
|
16449 | };
|
16450 |
|
16451 | Minimatch.prototype.match = match;
|
16452 |
|
16453 | function match(f, partial) {
|
16454 | this.debug('match', f, this.pattern);
|
16455 |
|
16456 |
|
16457 | if (this.comment) return false;
|
16458 | if (this.empty) return f === '';
|
16459 | if (f === '/' && partial) return true;
|
16460 | var options = this.options;
|
16461 |
|
16462 | if (path.sep !== '/') {
|
16463 | f = f.split(path.sep).join('/');
|
16464 | }
|
16465 |
|
16466 |
|
16467 | f = f.split(slashSplit);
|
16468 | this.debug(this.pattern, 'split', f);
|
16469 |
|
16470 |
|
16471 |
|
16472 |
|
16473 | var set = this.set;
|
16474 | this.debug(this.pattern, 'set', set); // Find the basename of the path by looking for the last non-empty segment
|
16475 |
|
16476 | var filename;
|
16477 | var i;
|
16478 |
|
16479 | for (i = f.length - 1; i >= 0; i--) {
|
16480 | filename = f[i];
|
16481 | if (filename) break;
|
16482 | }
|
16483 |
|
16484 | for (i = 0; i < set.length; i++) {
|
16485 | var pattern = set[i];
|
16486 | var file = f;
|
16487 |
|
16488 | if (options.matchBase && pattern.length === 1) {
|
16489 | file = [filename];
|
16490 | }
|
16491 |
|
16492 | var hit = this.matchOne(file, pattern, partial);
|
16493 |
|
16494 | if (hit) {
|
16495 | if (options.flipNegate) return true;
|
16496 | return !this.negate;
|
16497 | }
|
16498 | }
|
16499 |
|
16500 |
|
16501 |
|
16502 | if (options.flipNegate) return false;
|
16503 | return this.negate;
|
16504 | }
|
16505 |
|
16506 |
|
16507 |
|
16508 |
|
16509 |
|
16510 |
|
16511 | Minimatch.prototype.matchOne = function (file, pattern, partial) {
|
16512 | var options = this.options;
|
16513 | this.debug('matchOne', {
|
16514 | 'this': this,
|
16515 | file: file,
|
16516 | pattern: pattern
|
16517 | });
|
16518 | this.debug('matchOne', file.length, pattern.length);
|
16519 |
|
16520 | for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
16521 | this.debug('matchOne loop');
|
16522 | var p = pattern[pi];
|
16523 | var f = file[fi];
|
16524 | this.debug(pattern, p, f);
|
16525 |
|
16526 |
|
16527 | if (p === false) return false;
|
16528 |
|
16529 | if (p === GLOBSTAR) {
|
16530 | this.debug('GLOBSTAR', [pattern, p, f]);
|
16531 |
|
16532 |
|
16533 |
|
16534 |
|
16535 |
|
16536 |
|
16537 |
|
16538 |
|
16539 |
|
16540 |
|
16541 |
|
16542 |
|
16543 |
|
16544 |
|
16545 |
|
16546 |
|
16547 |
|
16548 |
|
16549 |
|
16550 |
|
16551 |
|
16552 |
|
16553 | var fr = fi;
|
16554 | var pr = pi + 1;
|
16555 |
|
16556 | if (pr === pl) {
|
16557 | this.debug('** at the end');
|
16558 |
|
16559 |
|
16560 |
|
16561 |
|
16562 |
|
16563 |
|
16564 | for (; fi < fl; fi++) {
|
16565 | if (file[fi] === '.' || file[fi] === '..' || !options.dot && file[fi].charAt(0) === '.') return false;
|
16566 | }
|
16567 |
|
16568 | return true;
|
16569 | }
|
16570 |
|
16571 |
|
16572 | while (fr < fl) {
|
16573 | var swallowee = file[fr];
|
16574 | this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
|
16575 |
|
16576 | if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
16577 | this.debug('globstar found match!', fr, fl, swallowee);
|
16578 |
|
16579 | return true;
|
16580 | } else {
|
16581 |
|
16582 |
|
16583 | if (swallowee === '.' || swallowee === '..' || !options.dot && swallowee.charAt(0) === '.') {
|
16584 | this.debug('dot detected!', file, fr, pattern, pr);
|
16585 | break;
|
16586 | }
|
16587 |
|
16588 |
|
16589 | this.debug('globstar swallow a segment, and continue');
|
16590 | fr++;
|
16591 | }
|
16592 | }
|
16593 |
|
16594 |
|
16595 |
|
16596 |
|
16597 | if (partial) {
|
16598 |
|
16599 | this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
|
16600 | if (fr === fl) return true;
|
16601 | }
|
16602 |
|
16603 | return false;
|
16604 | }
|
16605 |
|
16606 |
|
16607 |
|
16608 |
|
16609 | var hit;
|
16610 |
|
16611 | if (typeof p === 'string') {
|
16612 | if (options.nocase) {
|
16613 | hit = f.toLowerCase() === p.toLowerCase();
|
16614 | } else {
|
16615 | hit = f === p;
|
16616 | }
|
16617 |
|
16618 | this.debug('string match', p, f, hit);
|
16619 | } else {
|
16620 | hit = f.match(p);
|
16621 | this.debug('pattern match', p, f, hit);
|
16622 | }
|
16623 |
|
16624 | if (!hit) return false;
|
16625 | }
|
16626 |
|
16627 |
|
16628 |
|
16629 |
|
16630 |
|
16631 |
|
16632 |
|
16633 |
|
16634 |
|
16635 |
|
16636 |
|
16637 |
|
16638 | if (fi === fl && pi === pl) {
|
16639 |
|
16640 |
|
16641 | return true;
|
16642 | } else if (fi === fl) {
|
16643 |
|
16644 |
|
16645 |
|
16646 | return partial;
|
16647 | } else if (pi === pl) {
|
16648 |
|
16649 |
|
16650 |
|
16651 |
|
16652 | var emptyFileEnd = fi === fl - 1 && file[fi] === '';
|
16653 | return emptyFileEnd;
|
16654 | }
|
16655 |
|
16656 |
|
16657 | throw new Error('wtf?');
|
16658 | };
|
16659 |
|
16660 |
|
16661 | function globUnescape(s) {
|
16662 | return s.replace(/\\(.)/g, '$1');
|
16663 | }
|
16664 |
|
16665 | function regExpEscape(s) {
|
16666 | return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
16667 | }
|
16668 |
|
16669 | const copyProperty = (to, from, property, ignoreNonConfigurable) => {
|
16670 |
|
16671 |
|
16672 | if (property === 'length' || property === 'prototype') {
|
16673 | return;
|
16674 | }
|
16675 |
|
16676 | const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
|
16677 | const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
|
16678 |
|
16679 | if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
|
16680 | return;
|
16681 | }
|
16682 |
|
16683 | Object.defineProperty(to, property, fromDescriptor);
|
16684 | };
|
16685 |
|
16686 |
|
16687 |
|
16688 |
|
16689 | const canCopyProperty = function (toDescriptor, fromDescriptor) {
|
16690 | return toDescriptor === undefined || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
|
16691 | };
|
16692 |
|
16693 | const changePrototype = (to, from) => {
|
16694 | const fromPrototype = Object.getPrototypeOf(from);
|
16695 |
|
16696 | if (fromPrototype === Object.getPrototypeOf(to)) {
|
16697 | return;
|
16698 | }
|
16699 |
|
16700 | Object.setPrototypeOf(to, fromPrototype);
|
16701 | };
|
16702 |
|
16703 | const wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\n${fromBody}`;
|
16704 |
|
16705 | const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');
|
16706 | const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name');
|
16707 |
|
16708 |
|
16709 |
|
16710 | const changeToString = (to, from, name) => {
|
16711 | const withName = name === '' ? '' : `with ${name.trim()}() `;
|
16712 | const newToString = wrappedToString.bind(null, withName, from.toString());
|
16713 |
|
16714 | Object.defineProperty(newToString, 'name', toStringName);
|
16715 | Object.defineProperty(to, 'toString', Object.assign({}, toStringDescriptor, {
|
16716 | value: newToString
|
16717 | }));
|
16718 | };
|
16719 |
|
16720 | const mimicFn = (to, from, {
|
16721 | ignoreNonConfigurable = false
|
16722 | } = {}) => {
|
16723 | const {
|
16724 | name
|
16725 | } = to;
|
16726 |
|
16727 | for (const property of Reflect.ownKeys(from)) {
|
16728 | copyProperty(to, from, property, ignoreNonConfigurable);
|
16729 | }
|
16730 |
|
16731 | changePrototype(to, from);
|
16732 | changeToString(to, from, name);
|
16733 | return to;
|
16734 | };
|
16735 |
|
16736 | var mimicFn_1 = mimicFn;
|
16737 |
|
16738 | var pDefer = () => {
|
16739 | const ret = {};
|
16740 | ret.promise = new Promise((resolve, reject) => {
|
16741 | ret.resolve = resolve;
|
16742 | ret.reject = reject;
|
16743 | });
|
16744 | return ret;
|
16745 | };
|
16746 |
|
16747 | var dist = createCommonjsModule(function (module, exports) {
|
16748 |
|
16749 | var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
16750 | return new (P || (P = Promise))(function (resolve, reject) {
|
16751 | function fulfilled(value) {
|
16752 | try {
|
16753 | step(generator.next(value));
|
16754 | } catch (e) {
|
16755 | reject(e);
|
16756 | }
|
16757 | }
|
16758 |
|
16759 | function rejected(value) {
|
16760 | try {
|
16761 | step(generator["throw"](value));
|
16762 | } catch (e) {
|
16763 | reject(e);
|
16764 | }
|
16765 | }
|
16766 |
|
16767 | function step(result) {
|
16768 | result.done ? resolve(result.value) : new P(function (resolve) {
|
16769 | resolve(result.value);
|
16770 | }).then(fulfilled, rejected);
|
16771 | }
|
16772 |
|
16773 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
16774 | });
|
16775 | };
|
16776 |
|
16777 | var __importDefault = this && this.__importDefault || function (mod) {
|
16778 | return mod && mod.__esModule ? mod : {
|
16779 | "default": mod
|
16780 | };
|
16781 | };
|
16782 |
|
16783 | Object.defineProperty(exports, "__esModule", {
|
16784 | value: true
|
16785 | });
|
16786 |
|
16787 | const p_defer_1 = __importDefault(pDefer);
|
16788 |
|
16789 | function mapAgeCleaner(map, property = 'maxAge') {
|
16790 | let processingKey;
|
16791 | let processingTimer;
|
16792 | let processingDeferred;
|
16793 |
|
16794 | const cleanup = () => __awaiter(this, void 0, void 0, function* () {
|
16795 | if (processingKey !== undefined) {
|
16796 |
|
16797 | return;
|
16798 | }
|
16799 |
|
16800 | const setupTimer = item => __awaiter(this, void 0, void 0, function* () {
|
16801 | processingDeferred = p_defer_1.default();
|
16802 | const delay = item[1][property] - Date.now();
|
16803 |
|
16804 | if (delay <= 0) {
|
16805 |
|
16806 | map.delete(item[0]);
|
16807 | processingDeferred.resolve();
|
16808 | return;
|
16809 | }
|
16810 |
|
16811 |
|
16812 | processingKey = item[0];
|
16813 | processingTimer = setTimeout(() => {
|
16814 |
|
16815 | map.delete(item[0]);
|
16816 |
|
16817 | if (processingDeferred) {
|
16818 | processingDeferred.resolve();
|
16819 | }
|
16820 | }, delay);
|
16821 |
|
16822 | if (typeof processingTimer.unref === 'function') {
|
16823 |
|
16824 | processingTimer.unref();
|
16825 | }
|
16826 |
|
16827 | return processingDeferred.promise;
|
16828 | });
|
16829 |
|
16830 | try {
|
16831 | for (const entry of map) {
|
16832 | yield setupTimer(entry);
|
16833 | }
|
16834 | } catch (_a) {
|
16835 | }
|
16836 |
|
16837 | processingKey = undefined;
|
16838 | });
|
16839 |
|
16840 | const reset = () => {
|
16841 | processingKey = undefined;
|
16842 |
|
16843 | if (processingTimer !== undefined) {
|
16844 | clearTimeout(processingTimer);
|
16845 | processingTimer = undefined;
|
16846 | }
|
16847 |
|
16848 | if (processingDeferred !== undefined) {
|
16849 |
|
16850 | processingDeferred.reject(undefined);
|
16851 | processingDeferred = undefined;
|
16852 | }
|
16853 | };
|
16854 |
|
16855 | const originalSet = map.set.bind(map);
|
16856 |
|
16857 | map.set = (key, value) => {
|
16858 | if (map.has(key)) {
|
16859 |
|
16860 | map.delete(key);
|
16861 | }
|
16862 |
|
16863 |
|
16864 | const result = originalSet(key, value);
|
16865 |
|
16866 | if (processingKey && processingKey === key) {
|
16867 | reset();
|
16868 | }
|
16869 |
|
16870 |
|
16871 | cleanup();
|
16872 |
|
16873 | return result;
|
16874 | };
|
16875 |
|
16876 | cleanup();
|
16877 |
|
16878 | return map;
|
16879 | }
|
16880 |
|
16881 | exports.default = mapAgeCleaner;
|
16882 |
|
16883 | module.exports = mapAgeCleaner;
|
16884 | module.exports.default = mapAgeCleaner;
|
16885 | });
|
16886 | unwrapExports(dist);
|
16887 |
|
16888 | const cacheStore = new WeakMap();
|
16889 |
|
16890 | const mem = (fn, {
|
16891 | cacheKey = ([firstArgument]) => firstArgument,
|
16892 | cache = new Map(),
|
16893 | maxAge
|
16894 | } = {}) => {
|
16895 | if (typeof maxAge === 'number') {
|
16896 | dist(cache);
|
16897 | }
|
16898 |
|
16899 | const memoized = function (...arguments_) {
|
16900 | const key = cacheKey(arguments_);
|
16901 |
|
16902 | if (cache.has(key)) {
|
16903 | return cache.get(key).data;
|
16904 | }
|
16905 |
|
16906 | const cacheItem = fn.apply(this, arguments_);
|
16907 | cache.set(key, {
|
16908 | data: cacheItem,
|
16909 | maxAge: maxAge ? Date.now() + maxAge : Infinity
|
16910 | });
|
16911 | return cacheItem;
|
16912 | };
|
16913 |
|
16914 | try {
|
16915 |
|
16916 |
|
16917 | mimicFn_1(memoized, fn);
|
16918 | } catch (_) {}
|
16919 |
|
16920 | cacheStore.set(memoized, cache);
|
16921 | return memoized;
|
16922 | };
|
16923 |
|
16924 | var mem_1 = mem;
|
16925 |
|
16926 | var clear = fn => {
|
16927 | if (!cacheStore.has(fn)) {
|
16928 | throw new Error('Can\'t clear a function that was not memoized!');
|
16929 | }
|
16930 |
|
16931 | const cache = cacheStore.get(fn);
|
16932 |
|
16933 | if (typeof cache.clear === 'function') {
|
16934 | cache.clear();
|
16935 | }
|
16936 | };
|
16937 | mem_1.clear = clear;
|
16938 |
|
16939 | var semver$2 = createCommonjsModule(function (module, exports) {
|
16940 | exports = module.exports = SemVer;
|
16941 | var debug;
|
16942 |
|
16943 |
|
16944 | if (typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
16945 | debug = function () {
|
16946 | var args = Array.prototype.slice.call(arguments, 0);
|
16947 | args.unshift('SEMVER');
|
16948 | console.log.apply(console, args);
|
16949 | };
|
16950 | } else {
|
16951 | debug = function () {};
|
16952 | }
|
16953 |
|
16954 |
|
16955 |
|
16956 | exports.SEMVER_SPEC_VERSION = '2.0.0';
|
16957 | var MAX_LENGTH = 256;
|
16958 | var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
16959 |
|
16960 | 9007199254740991;
|
16961 |
|
16962 | var MAX_SAFE_COMPONENT_LENGTH = 16;
|
16963 |
|
16964 | var re = exports.re = [];
|
16965 | var src = exports.src = [];
|
16966 | var R = 0;
|
16967 |
|
16968 |
|
16969 |
|
16970 |
|
16971 | var NUMERICIDENTIFIER = R++;
|
16972 | src[NUMERICIDENTIFIER] = '0|[1-9]\\d*';
|
16973 | var NUMERICIDENTIFIERLOOSE = R++;
|
16974 | src[NUMERICIDENTIFIERLOOSE] = '[0-9]+';
|
16975 |
|
16976 |
|
16977 |
|
16978 | var NONNUMERICIDENTIFIER = R++;
|
16979 | src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
|
16980 |
|
16981 |
|
16982 | var MAINVERSION = R++;
|
16983 | src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')';
|
16984 | var MAINVERSIONLOOSE = R++;
|
16985 | src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')';
|
16986 |
|
16987 |
|
16988 | var PRERELEASEIDENTIFIER = R++;
|
16989 | src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + '|' + src[NONNUMERICIDENTIFIER] + ')';
|
16990 | var PRERELEASEIDENTIFIERLOOSE = R++;
|
16991 | src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + '|' + src[NONNUMERICIDENTIFIER] + ')';
|
16992 |
|
16993 |
|
16994 |
|
16995 | var PRERELEASE = R++;
|
16996 | src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))';
|
16997 | var PRERELEASELOOSE = R++;
|
16998 | src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))';
|
16999 |
|
17000 |
|
17001 | var BUILDIDENTIFIER = R++;
|
17002 | src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+';
|
17003 |
|
17004 |
|
17005 |
|
17006 | var BUILD = R++;
|
17007 | src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))';
|
17008 |
|
17009 |
|
17010 |
|
17011 |
|
17012 |
|
17013 |
|
17014 |
|
17015 | var FULL = R++;
|
17016 | var FULLPLAIN = 'v?' + src[MAINVERSION] + src[PRERELEASE] + '?' + src[BUILD] + '?';
|
17017 | src[FULL] = '^' + FULLPLAIN + '$';
|
17018 |
|
17019 |
|
17020 |
|
17021 | var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + '?' + src[BUILD] + '?';
|
17022 | var LOOSE = R++;
|
17023 | src[LOOSE] = '^' + LOOSEPLAIN + '$';
|
17024 | var GTLT = R++;
|
17025 | src[GTLT] = '((?:<|>)?=?)';
|
17026 |
|
17027 |
|
17028 |
|
17029 | var XRANGEIDENTIFIERLOOSE = R++;
|
17030 | src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
|
17031 | var XRANGEIDENTIFIER = R++;
|
17032 | src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*';
|
17033 | var XRANGEPLAIN = R++;
|
17034 | src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:' + src[PRERELEASE] + ')?' + src[BUILD] + '?' + ')?)?';
|
17035 | var XRANGEPLAINLOOSE = R++;
|
17036 | src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[PRERELEASELOOSE] + ')?' + src[BUILD] + '?' + ')?)?';
|
17037 | var XRANGE = R++;
|
17038 | src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$';
|
17039 | var XRANGELOOSE = R++;
|
17040 | src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$';
|
17041 |
|
17042 |
|
17043 | var COERCE = R++;
|
17044 | src[COERCE] = '(?:^|[^\\d])' + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:$|[^\\d])';
|
17045 |
|
17046 |
|
17047 | var LONETILDE = R++;
|
17048 | src[LONETILDE] = '(?:~>?)';
|
17049 | var TILDETRIM = R++;
|
17050 | src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+';
|
17051 | re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g');
|
17052 | var tildeTrimReplace = '$1~';
|
17053 | var TILDE = R++;
|
17054 | src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$';
|
17055 | var TILDELOOSE = R++;
|
17056 | src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$';
|
17057 |
|
17058 |
|
17059 | var LONECARET = R++;
|
17060 | src[LONECARET] = '(?:\\^)';
|
17061 | var CARETTRIM = R++;
|
17062 | src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+';
|
17063 | re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g');
|
17064 | var caretTrimReplace = '$1^';
|
17065 | var CARET = R++;
|
17066 | src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$';
|
17067 | var CARETLOOSE = R++;
|
17068 | src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$';
|
17069 |
|
17070 | var COMPARATORLOOSE = R++;
|
17071 | src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$';
|
17072 | var COMPARATOR = R++;
|
17073 | src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$';
|
17074 |
|
17075 |
|
17076 | var COMPARATORTRIM = R++;
|
17077 | src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')';
|
17078 |
|
17079 | re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g');
|
17080 | var comparatorTrimReplace = '$1$2$3';
|
17081 |
|
17082 |
|
17083 |
|
17084 |
|
17085 | var HYPHENRANGE = R++;
|
17086 | src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAIN] + ')' + '\\s*$';
|
17087 | var HYPHENRANGELOOSE = R++;
|
17088 | src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAINLOOSE] + ')' + '\\s*$';
|
17089 |
|
17090 | var STAR = R++;
|
17091 | src[STAR] = '(<|>)?=?\\s*\\*';
|
17092 |
|
17093 |
|
17094 | for (var i = 0; i < R; i++) {
|
17095 | debug(i, src[i]);
|
17096 |
|
17097 | if (!re[i]) {
|
17098 | re[i] = new RegExp(src[i]);
|
17099 | }
|
17100 | }
|
17101 |
|
17102 | exports.parse = parse;
|
17103 |
|
17104 | function parse(version, options) {
|
17105 | if (!options || typeof options !== 'object') {
|
17106 | options = {
|
17107 | loose: !!options,
|
17108 | includePrerelease: false
|
17109 | };
|
17110 | }
|
17111 |
|
17112 | if (version instanceof SemVer) {
|
17113 | return version;
|
17114 | }
|
17115 |
|
17116 | if (typeof version !== 'string') {
|
17117 | return null;
|
17118 | }
|
17119 |
|
17120 | if (version.length > MAX_LENGTH) {
|
17121 | return null;
|
17122 | }
|
17123 |
|
17124 | var r = options.loose ? re[LOOSE] : re[FULL];
|
17125 |
|
17126 | if (!r.test(version)) {
|
17127 | return null;
|
17128 | }
|
17129 |
|
17130 | try {
|
17131 | return new SemVer(version, options);
|
17132 | } catch (er) {
|
17133 | return null;
|
17134 | }
|
17135 | }
|
17136 |
|
17137 | exports.valid = valid;
|
17138 |
|
17139 | function valid(version, options) {
|
17140 | var v = parse(version, options);
|
17141 | return v ? v.version : null;
|
17142 | }
|
17143 |
|
17144 | exports.clean = clean;
|
17145 |
|
17146 | function clean(version, options) {
|
17147 | var s = parse(version.trim().replace(/^[=v]+/, ''), options);
|
17148 | return s ? s.version : null;
|
17149 | }
|
17150 |
|
17151 | exports.SemVer = SemVer;
|
17152 |
|
17153 | function SemVer(version, options) {
|
17154 | if (!options || typeof options !== 'object') {
|
17155 | options = {
|
17156 | loose: !!options,
|
17157 | includePrerelease: false
|
17158 | };
|
17159 | }
|
17160 |
|
17161 | if (version instanceof SemVer) {
|
17162 | if (version.loose === options.loose) {
|
17163 | return version;
|
17164 | } else {
|
17165 | version = version.version;
|
17166 | }
|
17167 | } else if (typeof version !== 'string') {
|
17168 | throw new TypeError('Invalid Version: ' + version);
|
17169 | }
|
17170 |
|
17171 | if (version.length > MAX_LENGTH) {
|
17172 | throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
|
17173 | }
|
17174 |
|
17175 | if (!(this instanceof SemVer)) {
|
17176 | return new SemVer(version, options);
|
17177 | }
|
17178 |
|
17179 | debug('SemVer', version, options);
|
17180 | this.options = options;
|
17181 | this.loose = !!options.loose;
|
17182 | var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL]);
|
17183 |
|
17184 | if (!m) {
|
17185 | throw new TypeError('Invalid Version: ' + version);
|
17186 | }
|
17187 |
|
17188 | this.raw = version;
|
17189 |
|
17190 | this.major = +m[1];
|
17191 | this.minor = +m[2];
|
17192 | this.patch = +m[3];
|
17193 |
|
17194 | if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
17195 | throw new TypeError('Invalid major version');
|
17196 | }
|
17197 |
|
17198 | if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
17199 | throw new TypeError('Invalid minor version');
|
17200 | }
|
17201 |
|
17202 | if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
17203 | throw new TypeError('Invalid patch version');
|
17204 | }
|
17205 |
|
17206 |
|
17207 | if (!m[4]) {
|
17208 | this.prerelease = [];
|
17209 | } else {
|
17210 | this.prerelease = m[4].split('.').map(function (id) {
|
17211 | if (/^[0-9]+$/.test(id)) {
|
17212 | var num = +id;
|
17213 |
|
17214 | if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
17215 | return num;
|
17216 | }
|
17217 | }
|
17218 |
|
17219 | return id;
|
17220 | });
|
17221 | }
|
17222 |
|
17223 | this.build = m[5] ? m[5].split('.') : [];
|
17224 | this.format();
|
17225 | }
|
17226 |
|
17227 | SemVer.prototype.format = function () {
|
17228 | this.version = this.major + '.' + this.minor + '.' + this.patch;
|
17229 |
|
17230 | if (this.prerelease.length) {
|
17231 | this.version += '-' + this.prerelease.join('.');
|
17232 | }
|
17233 |
|
17234 | return this.version;
|
17235 | };
|
17236 |
|
17237 | SemVer.prototype.toString = function () {
|
17238 | return this.version;
|
17239 | };
|
17240 |
|
17241 | SemVer.prototype.compare = function (other) {
|
17242 | debug('SemVer.compare', this.version, this.options, other);
|
17243 |
|
17244 | if (!(other instanceof SemVer)) {
|
17245 | other = new SemVer(other, this.options);
|
17246 | }
|
17247 |
|
17248 | return this.compareMain(other) || this.comparePre(other);
|
17249 | };
|
17250 |
|
17251 | SemVer.prototype.compareMain = function (other) {
|
17252 | if (!(other instanceof SemVer)) {
|
17253 | other = new SemVer(other, this.options);
|
17254 | }
|
17255 |
|
17256 | return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
|
17257 | };
|
17258 |
|
17259 | SemVer.prototype.comparePre = function (other) {
|
17260 | if (!(other instanceof SemVer)) {
|
17261 | other = new SemVer(other, this.options);
|
17262 | }
|
17263 |
|
17264 |
|
17265 | if (this.prerelease.length && !other.prerelease.length) {
|
17266 | return -1;
|
17267 | } else if (!this.prerelease.length && other.prerelease.length) {
|
17268 | return 1;
|
17269 | } else if (!this.prerelease.length && !other.prerelease.length) {
|
17270 | return 0;
|
17271 | }
|
17272 |
|
17273 | var i = 0;
|
17274 |
|
17275 | do {
|
17276 | var a = this.prerelease[i];
|
17277 | var b = other.prerelease[i];
|
17278 | debug('prerelease compare', i, a, b);
|
17279 |
|
17280 | if (a === undefined && b === undefined) {
|
17281 | return 0;
|
17282 | } else if (b === undefined) {
|
17283 | return 1;
|
17284 | } else if (a === undefined) {
|
17285 | return -1;
|
17286 | } else if (a === b) {
|
17287 | continue;
|
17288 | } else {
|
17289 | return compareIdentifiers(a, b);
|
17290 | }
|
17291 | } while (++i);
|
17292 | };
|
17293 |
|
17294 |
|
17295 |
|
17296 | SemVer.prototype.inc = function (release, identifier) {
|
17297 | switch (release) {
|
17298 | case 'premajor':
|
17299 | this.prerelease.length = 0;
|
17300 | this.patch = 0;
|
17301 | this.minor = 0;
|
17302 | this.major++;
|
17303 | this.inc('pre', identifier);
|
17304 | break;
|
17305 |
|
17306 | case 'preminor':
|
17307 | this.prerelease.length = 0;
|
17308 | this.patch = 0;
|
17309 | this.minor++;
|
17310 | this.inc('pre', identifier);
|
17311 | break;
|
17312 |
|
17313 | case 'prepatch':
|
17314 |
|
17315 |
|
17316 |
|
17317 | this.prerelease.length = 0;
|
17318 | this.inc('patch', identifier);
|
17319 | this.inc('pre', identifier);
|
17320 | break;
|
17321 |
|
17322 |
|
17323 |
|
17324 | case 'prerelease':
|
17325 | if (this.prerelease.length === 0) {
|
17326 | this.inc('patch', identifier);
|
17327 | }
|
17328 |
|
17329 | this.inc('pre', identifier);
|
17330 | break;
|
17331 |
|
17332 | case 'major':
|
17333 |
|
17334 |
|
17335 |
|
17336 |
|
17337 | if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
|
17338 | this.major++;
|
17339 | }
|
17340 |
|
17341 | this.minor = 0;
|
17342 | this.patch = 0;
|
17343 | this.prerelease = [];
|
17344 | break;
|
17345 |
|
17346 | case 'minor':
|
17347 |
|
17348 |
|
17349 |
|
17350 |
|
17351 | if (this.patch !== 0 || this.prerelease.length === 0) {
|
17352 | this.minor++;
|
17353 | }
|
17354 |
|
17355 | this.patch = 0;
|
17356 | this.prerelease = [];
|
17357 | break;
|
17358 |
|
17359 | case 'patch':
|
17360 |
|
17361 |
|
17362 |
|
17363 |
|
17364 | if (this.prerelease.length === 0) {
|
17365 | this.patch++;
|
17366 | }
|
17367 |
|
17368 | this.prerelease = [];
|
17369 | break;
|
17370 |
|
17371 |
|
17372 |
|
17373 | case 'pre':
|
17374 | if (this.prerelease.length === 0) {
|
17375 | this.prerelease = [0];
|
17376 | } else {
|
17377 | var i = this.prerelease.length;
|
17378 |
|
17379 | while (--i >= 0) {
|
17380 | if (typeof this.prerelease[i] === 'number') {
|
17381 | this.prerelease[i]++;
|
17382 | i = -2;
|
17383 | }
|
17384 | }
|
17385 |
|
17386 | if (i === -1) {
|
17387 |
|
17388 | this.prerelease.push(0);
|
17389 | }
|
17390 | }
|
17391 |
|
17392 | if (identifier) {
|
17393 |
|
17394 |
|
17395 | if (this.prerelease[0] === identifier) {
|
17396 | if (isNaN(this.prerelease[1])) {
|
17397 | this.prerelease = [identifier, 0];
|
17398 | }
|
17399 | } else {
|
17400 | this.prerelease = [identifier, 0];
|
17401 | }
|
17402 | }
|
17403 |
|
17404 | break;
|
17405 |
|
17406 | default:
|
17407 | throw new Error('invalid increment argument: ' + release);
|
17408 | }
|
17409 |
|
17410 | this.format();
|
17411 | this.raw = this.version;
|
17412 | return this;
|
17413 | };
|
17414 |
|
17415 | exports.inc = inc;
|
17416 |
|
17417 | function inc(version, release, loose, identifier) {
|
17418 | if (typeof loose === 'string') {
|
17419 | identifier = loose;
|
17420 | loose = undefined;
|
17421 | }
|
17422 |
|
17423 | try {
|
17424 | return new SemVer(version, loose).inc(release, identifier).version;
|
17425 | } catch (er) {
|
17426 | return null;
|
17427 | }
|
17428 | }
|
17429 |
|
17430 | exports.diff = diff;
|
17431 |
|
17432 | function diff(version1, version2) {
|
17433 | if (eq(version1, version2)) {
|
17434 | return null;
|
17435 | } else {
|
17436 | var v1 = parse(version1);
|
17437 | var v2 = parse(version2);
|
17438 | var prefix = '';
|
17439 |
|
17440 | if (v1.prerelease.length || v2.prerelease.length) {
|
17441 | prefix = 'pre';
|
17442 | var defaultResult = 'prerelease';
|
17443 | }
|
17444 |
|
17445 | for (var key in v1) {
|
17446 | if (key === 'major' || key === 'minor' || key === 'patch') {
|
17447 | if (v1[key] !== v2[key]) {
|
17448 | return prefix + key;
|
17449 | }
|
17450 | }
|
17451 | }
|
17452 |
|
17453 | return defaultResult;
|
17454 | }
|
17455 | }
|
17456 |
|
17457 | exports.compareIdentifiers = compareIdentifiers;
|
17458 | var numeric = /^[0-9]+$/;
|
17459 |
|
17460 | function compareIdentifiers(a, b) {
|
17461 | var anum = numeric.test(a);
|
17462 | var bnum = numeric.test(b);
|
17463 |
|
17464 | if (anum && bnum) {
|
17465 | a = +a;
|
17466 | b = +b;
|
17467 | }
|
17468 |
|
17469 | return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
17470 | }
|
17471 |
|
17472 | exports.rcompareIdentifiers = rcompareIdentifiers;
|
17473 |
|
17474 | function rcompareIdentifiers(a, b) {
|
17475 | return compareIdentifiers(b, a);
|
17476 | }
|
17477 |
|
17478 | exports.major = major;
|
17479 |
|
17480 | function major(a, loose) {
|
17481 | return new SemVer(a, loose).major;
|
17482 | }
|
17483 |
|
17484 | exports.minor = minor;
|
17485 |
|
17486 | function minor(a, loose) {
|
17487 | return new SemVer(a, loose).minor;
|
17488 | }
|
17489 |
|
17490 | exports.patch = patch;
|
17491 |
|
17492 | function patch(a, loose) {
|
17493 | return new SemVer(a, loose).patch;
|
17494 | }
|
17495 |
|
17496 | exports.compare = compare;
|
17497 |
|
17498 | function compare(a, b, loose) {
|
17499 | return new SemVer(a, loose).compare(new SemVer(b, loose));
|
17500 | }
|
17501 |
|
17502 | exports.compareLoose = compareLoose;
|
17503 |
|
17504 | function compareLoose(a, b) {
|
17505 | return compare(a, b, true);
|
17506 | }
|
17507 |
|
17508 | exports.rcompare = rcompare;
|
17509 |
|
17510 | function rcompare(a, b, loose) {
|
17511 | return compare(b, a, loose);
|
17512 | }
|
17513 |
|
17514 | exports.sort = sort;
|
17515 |
|
17516 | function sort(list, loose) {
|
17517 | return list.sort(function (a, b) {
|
17518 | return exports.compare(a, b, loose);
|
17519 | });
|
17520 | }
|
17521 |
|
17522 | exports.rsort = rsort;
|
17523 |
|
17524 | function rsort(list, loose) {
|
17525 | return list.sort(function (a, b) {
|
17526 | return exports.rcompare(a, b, loose);
|
17527 | });
|
17528 | }
|
17529 |
|
17530 | exports.gt = gt;
|
17531 |
|
17532 | function gt(a, b, loose) {
|
17533 | return compare(a, b, loose) > 0;
|
17534 | }
|
17535 |
|
17536 | exports.lt = lt;
|
17537 |
|
17538 | function lt(a, b, loose) {
|
17539 | return compare(a, b, loose) < 0;
|
17540 | }
|
17541 |
|
17542 | exports.eq = eq;
|
17543 |
|
17544 | function eq(a, b, loose) {
|
17545 | return compare(a, b, loose) === 0;
|
17546 | }
|
17547 |
|
17548 | exports.neq = neq;
|
17549 |
|
17550 | function neq(a, b, loose) {
|
17551 | return compare(a, b, loose) !== 0;
|
17552 | }
|
17553 |
|
17554 | exports.gte = gte;
|
17555 |
|
17556 | function gte(a, b, loose) {
|
17557 | return compare(a, b, loose) >= 0;
|
17558 | }
|
17559 |
|
17560 | exports.lte = lte;
|
17561 |
|
17562 | function lte(a, b, loose) {
|
17563 | return compare(a, b, loose) <= 0;
|
17564 | }
|
17565 |
|
17566 | exports.cmp = cmp;
|
17567 |
|
17568 | function cmp(a, op, b, loose) {
|
17569 | switch (op) {
|
17570 | case '===':
|
17571 | if (typeof a === 'object') a = a.version;
|
17572 | if (typeof b === 'object') b = b.version;
|
17573 | return a === b;
|
17574 |
|
17575 | case '!==':
|
17576 | if (typeof a === 'object') a = a.version;
|
17577 | if (typeof b === 'object') b = b.version;
|
17578 | return a !== b;
|
17579 |
|
17580 | case '':
|
17581 | case '=':
|
17582 | case '==':
|
17583 | return eq(a, b, loose);
|
17584 |
|
17585 | case '!=':
|
17586 | return neq(a, b, loose);
|
17587 |
|
17588 | case '>':
|
17589 | return gt(a, b, loose);
|
17590 |
|
17591 | case '>=':
|
17592 | return gte(a, b, loose);
|
17593 |
|
17594 | case '<':
|
17595 | return lt(a, b, loose);
|
17596 |
|
17597 | case '<=':
|
17598 | return lte(a, b, loose);
|
17599 |
|
17600 | default:
|
17601 | throw new TypeError('Invalid operator: ' + op);
|
17602 | }
|
17603 | }
|
17604 |
|
17605 | exports.Comparator = Comparator;
|
17606 |
|
17607 | function Comparator(comp, options) {
|
17608 | if (!options || typeof options !== 'object') {
|
17609 | options = {
|
17610 | loose: !!options,
|
17611 | includePrerelease: false
|
17612 | };
|
17613 | }
|
17614 |
|
17615 | if (comp instanceof Comparator) {
|
17616 | if (comp.loose === !!options.loose) {
|
17617 | return comp;
|
17618 | } else {
|
17619 | comp = comp.value;
|
17620 | }
|
17621 | }
|
17622 |
|
17623 | if (!(this instanceof Comparator)) {
|
17624 | return new Comparator(comp, options);
|
17625 | }
|
17626 |
|
17627 | debug('comparator', comp, options);
|
17628 | this.options = options;
|
17629 | this.loose = !!options.loose;
|
17630 | this.parse(comp);
|
17631 |
|
17632 | if (this.semver === ANY) {
|
17633 | this.value = '';
|
17634 | } else {
|
17635 | this.value = this.operator + this.semver.version;
|
17636 | }
|
17637 |
|
17638 | debug('comp', this);
|
17639 | }
|
17640 |
|
17641 | var ANY = {};
|
17642 |
|
17643 | Comparator.prototype.parse = function (comp) {
|
17644 | var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
|
17645 | var m = comp.match(r);
|
17646 |
|
17647 | if (!m) {
|
17648 | throw new TypeError('Invalid comparator: ' + comp);
|
17649 | }
|
17650 |
|
17651 | this.operator = m[1];
|
17652 |
|
17653 | if (this.operator === '=') {
|
17654 | this.operator = '';
|
17655 | }
|
17656 |
|
17657 |
|
17658 | if (!m[2]) {
|
17659 | this.semver = ANY;
|
17660 | } else {
|
17661 | this.semver = new SemVer(m[2], this.options.loose);
|
17662 | }
|
17663 | };
|
17664 |
|
17665 | Comparator.prototype.toString = function () {
|
17666 | return this.value;
|
17667 | };
|
17668 |
|
17669 | Comparator.prototype.test = function (version) {
|
17670 | debug('Comparator.test', version, this.options.loose);
|
17671 |
|
17672 | if (this.semver === ANY) {
|
17673 | return true;
|
17674 | }
|
17675 |
|
17676 | if (typeof version === 'string') {
|
17677 | version = new SemVer(version, this.options);
|
17678 | }
|
17679 |
|
17680 | return cmp(version, this.operator, this.semver, this.options);
|
17681 | };
|
17682 |
|
17683 | Comparator.prototype.intersects = function (comp, options) {
|
17684 | if (!(comp instanceof Comparator)) {
|
17685 | throw new TypeError('a Comparator is required');
|
17686 | }
|
17687 |
|
17688 | if (!options || typeof options !== 'object') {
|
17689 | options = {
|
17690 | loose: !!options,
|
17691 | includePrerelease: false
|
17692 | };
|
17693 | }
|
17694 |
|
17695 | var rangeTmp;
|
17696 |
|
17697 | if (this.operator === '') {
|
17698 | rangeTmp = new Range(comp.value, options);
|
17699 | return satisfies(this.value, rangeTmp, options);
|
17700 | } else if (comp.operator === '') {
|
17701 | rangeTmp = new Range(this.value, options);
|
17702 | return satisfies(comp.semver, rangeTmp, options);
|
17703 | }
|
17704 |
|
17705 | var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
|
17706 | var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
|
17707 | var sameSemVer = this.semver.version === comp.semver.version;
|
17708 | var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
|
17709 | var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, options) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
|
17710 | var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, options) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
|
17711 | return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
|
17712 | };
|
17713 |
|
17714 | exports.Range = Range;
|
17715 |
|
17716 | function Range(range, options) {
|
17717 | if (!options || typeof options !== 'object') {
|
17718 | options = {
|
17719 | loose: !!options,
|
17720 | includePrerelease: false
|
17721 | };
|
17722 | }
|
17723 |
|
17724 | if (range instanceof Range) {
|
17725 | if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
|
17726 | return range;
|
17727 | } else {
|
17728 | return new Range(range.raw, options);
|
17729 | }
|
17730 | }
|
17731 |
|
17732 | if (range instanceof Comparator) {
|
17733 | return new Range(range.value, options);
|
17734 | }
|
17735 |
|
17736 | if (!(this instanceof Range)) {
|
17737 | return new Range(range, options);
|
17738 | }
|
17739 |
|
17740 | this.options = options;
|
17741 | this.loose = !!options.loose;
|
17742 | this.includePrerelease = !!options.includePrerelease;
|
17743 |
|
17744 | this.raw = range;
|
17745 | this.set = range.split(/\s*\|\|\s*/).map(function (range) {
|
17746 | return this.parseRange(range.trim());
|
17747 | }, this).filter(function (c) {
|
17748 |
|
17749 | return c.length;
|
17750 | });
|
17751 |
|
17752 | if (!this.set.length) {
|
17753 | throw new TypeError('Invalid SemVer Range: ' + range);
|
17754 | }
|
17755 |
|
17756 | this.format();
|
17757 | }
|
17758 |
|
17759 | Range.prototype.format = function () {
|
17760 | this.range = this.set.map(function (comps) {
|
17761 | return comps.join(' ').trim();
|
17762 | }).join('||').trim();
|
17763 | return this.range;
|
17764 | };
|
17765 |
|
17766 | Range.prototype.toString = function () {
|
17767 | return this.range;
|
17768 | };
|
17769 |
|
17770 | Range.prototype.parseRange = function (range) {
|
17771 | var loose = this.options.loose;
|
17772 | range = range.trim();
|
17773 |
|
17774 | var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE];
|
17775 | range = range.replace(hr, hyphenReplace);
|
17776 | debug('hyphen replace', range);
|
17777 |
|
17778 | range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
|
17779 | debug('comparator trim', range, re[COMPARATORTRIM]);
|
17780 |
|
17781 | range = range.replace(re[TILDETRIM], tildeTrimReplace);
|
17782 |
|
17783 | range = range.replace(re[CARETTRIM], caretTrimReplace);
|
17784 |
|
17785 | range = range.split(/\s+/).join(' ');
|
17786 |
|
17787 |
|
17788 | var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
|
17789 | var set = range.split(' ').map(function (comp) {
|
17790 | return parseComparator(comp, this.options);
|
17791 | }, this).join(' ').split(/\s+/);
|
17792 |
|
17793 | if (this.options.loose) {
|
17794 |
|
17795 | set = set.filter(function (comp) {
|
17796 | return !!comp.match(compRe);
|
17797 | });
|
17798 | }
|
17799 |
|
17800 | set = set.map(function (comp) {
|
17801 | return new Comparator(comp, this.options);
|
17802 | }, this);
|
17803 | return set;
|
17804 | };
|
17805 |
|
17806 | Range.prototype.intersects = function (range, options) {
|
17807 | if (!(range instanceof Range)) {
|
17808 | throw new TypeError('a Range is required');
|
17809 | }
|
17810 |
|
17811 | return this.set.some(function (thisComparators) {
|
17812 | return thisComparators.every(function (thisComparator) {
|
17813 | return range.set.some(function (rangeComparators) {
|
17814 | return rangeComparators.every(function (rangeComparator) {
|
17815 | return thisComparator.intersects(rangeComparator, options);
|
17816 | });
|
17817 | });
|
17818 | });
|
17819 | });
|
17820 | };
|
17821 |
|
17822 |
|
17823 | exports.toComparators = toComparators;
|
17824 |
|
17825 | function toComparators(range, options) {
|
17826 | return new Range(range, options).set.map(function (comp) {
|
17827 | return comp.map(function (c) {
|
17828 | return c.value;
|
17829 | }).join(' ').trim().split(' ');
|
17830 | });
|
17831 | }
|
17832 |
|
17833 |
|
17834 |
|
17835 |
|
17836 | function parseComparator(comp, options) {
|
17837 | debug('comp', comp, options);
|
17838 | comp = replaceCarets(comp, options);
|
17839 | debug('caret', comp);
|
17840 | comp = replaceTildes(comp, options);
|
17841 | debug('tildes', comp);
|
17842 | comp = replaceXRanges(comp, options);
|
17843 | debug('xrange', comp);
|
17844 | comp = replaceStars(comp, options);
|
17845 | debug('stars', comp);
|
17846 | return comp;
|
17847 | }
|
17848 |
|
17849 | function isX(id) {
|
17850 | return !id || id.toLowerCase() === 'x' || id === '*';
|
17851 | }
|
17852 |
|
17853 |
|
17854 |
|
17855 |
|
17856 |
|
17857 |
|
17858 |
|
17859 | function replaceTildes(comp, options) {
|
17860 | return comp.trim().split(/\s+/).map(function (comp) {
|
17861 | return replaceTilde(comp, options);
|
17862 | }).join(' ');
|
17863 | }
|
17864 |
|
17865 | function replaceTilde(comp, options) {
|
17866 | var r = options.loose ? re[TILDELOOSE] : re[TILDE];
|
17867 | return comp.replace(r, function (_, M, m, p, pr) {
|
17868 | debug('tilde', comp, _, M, m, p, pr);
|
17869 | var ret;
|
17870 |
|
17871 | if (isX(M)) {
|
17872 | ret = '';
|
17873 | } else if (isX(m)) {
|
17874 | ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
|
17875 | } else if (isX(p)) {
|
17876 |
|
17877 | ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
|
17878 | } else if (pr) {
|
17879 | debug('replaceTilde pr', pr);
|
17880 | ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
|
17881 | } else {
|
17882 |
|
17883 | ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
|
17884 | }
|
17885 |
|
17886 | debug('tilde return', ret);
|
17887 | return ret;
|
17888 | });
|
17889 | }
|
17890 |
|
17891 |
|
17892 |
|
17893 |
|
17894 |
|
17895 |
|
17896 |
|
17897 | function replaceCarets(comp, options) {
|
17898 | return comp.trim().split(/\s+/).map(function (comp) {
|
17899 | return replaceCaret(comp, options);
|
17900 | }).join(' ');
|
17901 | }
|
17902 |
|
17903 | function replaceCaret(comp, options) {
|
17904 | debug('caret', comp, options);
|
17905 | var r = options.loose ? re[CARETLOOSE] : re[CARET];
|
17906 | return comp.replace(r, function (_, M, m, p, pr) {
|
17907 | debug('caret', comp, _, M, m, p, pr);
|
17908 | var ret;
|
17909 |
|
17910 | if (isX(M)) {
|
17911 | ret = '';
|
17912 | } else if (isX(m)) {
|
17913 | ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
|
17914 | } else if (isX(p)) {
|
17915 | if (M === '0') {
|
17916 | ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
|
17917 | } else {
|
17918 | ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
|
17919 | }
|
17920 | } else if (pr) {
|
17921 | debug('replaceCaret pr', pr);
|
17922 |
|
17923 | if (M === '0') {
|
17924 | if (m === '0') {
|
17925 | ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + m + '.' + (+p + 1);
|
17926 | } else {
|
17927 | ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
|
17928 | }
|
17929 | } else {
|
17930 | ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + (+M + 1) + '.0.0';
|
17931 | }
|
17932 | } else {
|
17933 | debug('no pr');
|
17934 |
|
17935 | if (M === '0') {
|
17936 | if (m === '0') {
|
17937 | ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);
|
17938 | } else {
|
17939 | ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
|
17940 | }
|
17941 | } else {
|
17942 | ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
|
17943 | }
|
17944 | }
|
17945 |
|
17946 | debug('caret return', ret);
|
17947 | return ret;
|
17948 | });
|
17949 | }
|
17950 |
|
17951 | function replaceXRanges(comp, options) {
|
17952 | debug('replaceXRanges', comp, options);
|
17953 | return comp.split(/\s+/).map(function (comp) {
|
17954 | return replaceXRange(comp, options);
|
17955 | }).join(' ');
|
17956 | }
|
17957 |
|
17958 | function replaceXRange(comp, options) {
|
17959 | comp = comp.trim();
|
17960 | var r = options.loose ? re[XRANGELOOSE] : re[XRANGE];
|
17961 | return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
|
17962 | debug('xRange', comp, ret, gtlt, M, m, p, pr);
|
17963 | var xM = isX(M);
|
17964 | var xm = xM || isX(m);
|
17965 | var xp = xm || isX(p);
|
17966 | var anyX = xp;
|
17967 |
|
17968 | if (gtlt === '=' && anyX) {
|
17969 | gtlt = '';
|
17970 | }
|
17971 |
|
17972 | if (xM) {
|
17973 | if (gtlt === '>' || gtlt === '<') {
|
17974 |
|
17975 | ret = '<0.0.0';
|
17976 | } else {
|
17977 |
|
17978 | ret = '*';
|
17979 | }
|
17980 | } else if (gtlt && anyX) {
|
17981 |
|
17982 |
|
17983 | if (xm) {
|
17984 | m = 0;
|
17985 | }
|
17986 |
|
17987 | p = 0;
|
17988 |
|
17989 | if (gtlt === '>') {
|
17990 |
|
17991 |
|
17992 |
|
17993 | gtlt = '>=';
|
17994 |
|
17995 | if (xm) {
|
17996 | M = +M + 1;
|
17997 | m = 0;
|
17998 | p = 0;
|
17999 | } else {
|
18000 | m = +m + 1;
|
18001 | p = 0;
|
18002 | }
|
18003 | } else if (gtlt === '<=') {
|
18004 |
|
18005 |
|
18006 | gtlt = '<';
|
18007 |
|
18008 | if (xm) {
|
18009 | M = +M + 1;
|
18010 | } else {
|
18011 | m = +m + 1;
|
18012 | }
|
18013 | }
|
18014 |
|
18015 | ret = gtlt + M + '.' + m + '.' + p;
|
18016 | } else if (xm) {
|
18017 | ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
|
18018 | } else if (xp) {
|
18019 | ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
|
18020 | }
|
18021 |
|
18022 | debug('xRange return', ret);
|
18023 | return ret;
|
18024 | });
|
18025 | }
|
18026 |
|
18027 |
|
18028 |
|
18029 | function replaceStars(comp, options) {
|
18030 | debug('replaceStars', comp, options);
|
18031 |
|
18032 | return comp.trim().replace(re[STAR], '');
|
18033 | }
|
18034 |
|
18035 |
|
18036 |
|
18037 |
|
18038 |
|
18039 |
|
18040 | function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
|
18041 | if (isX(fM)) {
|
18042 | from = '';
|
18043 | } else if (isX(fm)) {
|
18044 | from = '>=' + fM + '.0.0';
|
18045 | } else if (isX(fp)) {
|
18046 | from = '>=' + fM + '.' + fm + '.0';
|
18047 | } else {
|
18048 | from = '>=' + from;
|
18049 | }
|
18050 |
|
18051 | if (isX(tM)) {
|
18052 | to = '';
|
18053 | } else if (isX(tm)) {
|
18054 | to = '<' + (+tM + 1) + '.0.0';
|
18055 | } else if (isX(tp)) {
|
18056 | to = '<' + tM + '.' + (+tm + 1) + '.0';
|
18057 | } else if (tpr) {
|
18058 | to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
|
18059 | } else {
|
18060 | to = '<=' + to;
|
18061 | }
|
18062 |
|
18063 | return (from + ' ' + to).trim();
|
18064 | }
|
18065 |
|
18066 |
|
18067 | Range.prototype.test = function (version) {
|
18068 | if (!version) {
|
18069 | return false;
|
18070 | }
|
18071 |
|
18072 | if (typeof version === 'string') {
|
18073 | version = new SemVer(version, this.options);
|
18074 | }
|
18075 |
|
18076 | for (var i = 0; i < this.set.length; i++) {
|
18077 | if (testSet(this.set[i], version, this.options)) {
|
18078 | return true;
|
18079 | }
|
18080 | }
|
18081 |
|
18082 | return false;
|
18083 | };
|
18084 |
|
18085 | function testSet(set, version, options) {
|
18086 | for (var i = 0; i < set.length; i++) {
|
18087 | if (!set[i].test(version)) {
|
18088 | return false;
|
18089 | }
|
18090 | }
|
18091 |
|
18092 | if (version.prerelease.length && !options.includePrerelease) {
|
18093 |
|
18094 |
|
18095 |
|
18096 |
|
18097 |
|
18098 | for (i = 0; i < set.length; i++) {
|
18099 | debug(set[i].semver);
|
18100 |
|
18101 | if (set[i].semver === ANY) {
|
18102 | continue;
|
18103 | }
|
18104 |
|
18105 | if (set[i].semver.prerelease.length > 0) {
|
18106 | var allowed = set[i].semver;
|
18107 |
|
18108 | if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
|
18109 | return true;
|
18110 | }
|
18111 | }
|
18112 | }
|
18113 |
|
18114 |
|
18115 | return false;
|
18116 | }
|
18117 |
|
18118 | return true;
|
18119 | }
|
18120 |
|
18121 | exports.satisfies = satisfies;
|
18122 |
|
18123 | function satisfies(version, range, options) {
|
18124 | try {
|
18125 | range = new Range(range, options);
|
18126 | } catch (er) {
|
18127 | return false;
|
18128 | }
|
18129 |
|
18130 | return range.test(version);
|
18131 | }
|
18132 |
|
18133 | exports.maxSatisfying = maxSatisfying;
|
18134 |
|
18135 | function maxSatisfying(versions, range, options) {
|
18136 | var max = null;
|
18137 | var maxSV = null;
|
18138 |
|
18139 | try {
|
18140 | var rangeObj = new Range(range, options);
|
18141 | } catch (er) {
|
18142 | return null;
|
18143 | }
|
18144 |
|
18145 | versions.forEach(function (v) {
|
18146 | if (rangeObj.test(v)) {
|
18147 |
|
18148 | if (!max || maxSV.compare(v) === -1) {
|
18149 |
|
18150 | max = v;
|
18151 | maxSV = new SemVer(max, options);
|
18152 | }
|
18153 | }
|
18154 | });
|
18155 | return max;
|
18156 | }
|
18157 |
|
18158 | exports.minSatisfying = minSatisfying;
|
18159 |
|
18160 | function minSatisfying(versions, range, options) {
|
18161 | var min = null;
|
18162 | var minSV = null;
|
18163 |
|
18164 | try {
|
18165 | var rangeObj = new Range(range, options);
|
18166 | } catch (er) {
|
18167 | return null;
|
18168 | }
|
18169 |
|
18170 | versions.forEach(function (v) {
|
18171 | if (rangeObj.test(v)) {
|
18172 |
|
18173 | if (!min || minSV.compare(v) === 1) {
|
18174 |
|
18175 | min = v;
|
18176 | minSV = new SemVer(min, options);
|
18177 | }
|
18178 | }
|
18179 | });
|
18180 | return min;
|
18181 | }
|
18182 |
|
18183 | exports.minVersion = minVersion;
|
18184 |
|
18185 | function minVersion(range, loose) {
|
18186 | range = new Range(range, loose);
|
18187 | var minver = new SemVer('0.0.0');
|
18188 |
|
18189 | if (range.test(minver)) {
|
18190 | return minver;
|
18191 | }
|
18192 |
|
18193 | minver = new SemVer('0.0.0-0');
|
18194 |
|
18195 | if (range.test(minver)) {
|
18196 | return minver;
|
18197 | }
|
18198 |
|
18199 | minver = null;
|
18200 |
|
18201 | for (var i = 0; i < range.set.length; ++i) {
|
18202 | var comparators = range.set[i];
|
18203 | comparators.forEach(function (comparator) {
|
18204 |
|
18205 | var compver = new SemVer(comparator.semver.version);
|
18206 |
|
18207 | switch (comparator.operator) {
|
18208 | case '>':
|
18209 | if (compver.prerelease.length === 0) {
|
18210 | compver.patch++;
|
18211 | } else {
|
18212 | compver.prerelease.push(0);
|
18213 | }
|
18214 |
|
18215 | compver.raw = compver.format();
|
18216 |
|
18217 |
|
18218 |
|
18219 | case '':
|
18220 | case '>=':
|
18221 | if (!minver || gt(minver, compver)) {
|
18222 | minver = compver;
|
18223 | }
|
18224 |
|
18225 | break;
|
18226 |
|
18227 | case '<':
|
18228 | case '<=':
|
18229 |
|
18230 | break;
|
18231 |
|
18232 |
|
18233 |
|
18234 | default:
|
18235 | throw new Error('Unexpected operation: ' + comparator.operator);
|
18236 | }
|
18237 | });
|
18238 | }
|
18239 |
|
18240 | if (minver && range.test(minver)) {
|
18241 | return minver;
|
18242 | }
|
18243 |
|
18244 | return null;
|
18245 | }
|
18246 |
|
18247 | exports.validRange = validRange;
|
18248 |
|
18249 | function validRange(range, options) {
|
18250 | try {
|
18251 |
|
18252 |
|
18253 | return new Range(range, options).range || '*';
|
18254 | } catch (er) {
|
18255 | return null;
|
18256 | }
|
18257 | }
|
18258 |
|
18259 |
|
18260 | exports.ltr = ltr;
|
18261 |
|
18262 | function ltr(version, range, options) {
|
18263 | return outside(version, range, '<', options);
|
18264 | }
|
18265 |
|
18266 |
|
18267 | exports.gtr = gtr;
|
18268 |
|
18269 | function gtr(version, range, options) {
|
18270 | return outside(version, range, '>', options);
|
18271 | }
|
18272 |
|
18273 | exports.outside = outside;
|
18274 |
|
18275 | function outside(version, range, hilo, options) {
|
18276 | version = new SemVer(version, options);
|
18277 | range = new Range(range, options);
|
18278 | var gtfn, ltefn, ltfn, comp, ecomp;
|
18279 |
|
18280 | switch (hilo) {
|
18281 | case '>':
|
18282 | gtfn = gt;
|
18283 | ltefn = lte;
|
18284 | ltfn = lt;
|
18285 | comp = '>';
|
18286 | ecomp = '>=';
|
18287 | break;
|
18288 |
|
18289 | case '<':
|
18290 | gtfn = lt;
|
18291 | ltefn = gte;
|
18292 | ltfn = gt;
|
18293 | comp = '<';
|
18294 | ecomp = '<=';
|
18295 | break;
|
18296 |
|
18297 | default:
|
18298 | throw new TypeError('Must provide a hilo val of "<" or ">"');
|
18299 | }
|
18300 |
|
18301 |
|
18302 | if (satisfies(version, range, options)) {
|
18303 | return false;
|
18304 | }
|
18305 |
|
18306 |
|
18307 |
|
18308 | for (var i = 0; i < range.set.length; ++i) {
|
18309 | var comparators = range.set[i];
|
18310 | var high = null;
|
18311 | var low = null;
|
18312 | comparators.forEach(function (comparator) {
|
18313 | if (comparator.semver === ANY) {
|
18314 | comparator = new Comparator('>=0.0.0');
|
18315 | }
|
18316 |
|
18317 | high = high || comparator;
|
18318 | low = low || comparator;
|
18319 |
|
18320 | if (gtfn(comparator.semver, high.semver, options)) {
|
18321 | high = comparator;
|
18322 | } else if (ltfn(comparator.semver, low.semver, options)) {
|
18323 | low = comparator;
|
18324 | }
|
18325 | });
|
18326 |
|
18327 |
|
18328 | if (high.operator === comp || high.operator === ecomp) {
|
18329 | return false;
|
18330 | }
|
18331 |
|
18332 |
|
18333 |
|
18334 | if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
|
18335 | return false;
|
18336 | } else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
18337 | return false;
|
18338 | }
|
18339 | }
|
18340 |
|
18341 | return true;
|
18342 | }
|
18343 |
|
18344 | exports.prerelease = prerelease;
|
18345 |
|
18346 | function prerelease(version, options) {
|
18347 | var parsed = parse(version, options);
|
18348 | return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
18349 | }
|
18350 |
|
18351 | exports.intersects = intersects;
|
18352 |
|
18353 | function intersects(r1, r2, options) {
|
18354 | r1 = new Range(r1, options);
|
18355 | r2 = new Range(r2, options);
|
18356 | return r1.intersects(r2);
|
18357 | }
|
18358 |
|
18359 | exports.coerce = coerce;
|
18360 |
|
18361 | function coerce(version) {
|
18362 | if (version instanceof SemVer) {
|
18363 | return version;
|
18364 | }
|
18365 |
|
18366 | if (typeof version !== 'string') {
|
18367 | return null;
|
18368 | }
|
18369 |
|
18370 | var match = version.match(re[COERCE]);
|
18371 |
|
18372 | if (match == null) {
|
18373 | return null;
|
18374 | }
|
18375 |
|
18376 | return parse(match[1] + '.' + (match[2] || '0') + '.' + (match[3] || '0'));
|
18377 | }
|
18378 | });
|
18379 | var semver_1 = semver$2.SEMVER_SPEC_VERSION;
|
18380 | var semver_2 = semver$2.re;
|
18381 | var semver_3 = semver$2.src;
|
18382 | var semver_4 = semver$2.parse;
|
18383 | var semver_5 = semver$2.valid;
|
18384 | var semver_6 = semver$2.clean;
|
18385 | var semver_7 = semver$2.SemVer;
|
18386 | var semver_8 = semver$2.inc;
|
18387 | var semver_9 = semver$2.diff;
|
18388 | var semver_10 = semver$2.compareIdentifiers;
|
18389 | var semver_11 = semver$2.rcompareIdentifiers;
|
18390 | var semver_12 = semver$2.major;
|
18391 | var semver_13 = semver$2.minor;
|
18392 | var semver_14 = semver$2.patch;
|
18393 | var semver_15 = semver$2.compare;
|
18394 | var semver_16 = semver$2.compareLoose;
|
18395 | var semver_17 = semver$2.rcompare;
|
18396 | var semver_18 = semver$2.sort;
|
18397 | var semver_19 = semver$2.rsort;
|
18398 | var semver_20 = semver$2.gt;
|
18399 | var semver_21 = semver$2.lt;
|
18400 | var semver_22 = semver$2.eq;
|
18401 | var semver_23 = semver$2.neq;
|
18402 | var semver_24 = semver$2.gte;
|
18403 | var semver_25 = semver$2.lte;
|
18404 | var semver_26 = semver$2.cmp;
|
18405 | var semver_27 = semver$2.Comparator;
|
18406 | var semver_28 = semver$2.Range;
|
18407 | var semver_29 = semver$2.toComparators;
|
18408 | var semver_30 = semver$2.satisfies;
|
18409 | var semver_31 = semver$2.maxSatisfying;
|
18410 | var semver_32 = semver$2.minSatisfying;
|
18411 | var semver_33 = semver$2.minVersion;
|
18412 | var semver_34 = semver$2.validRange;
|
18413 | var semver_35 = semver$2.ltr;
|
18414 | var semver_36 = semver$2.gtr;
|
18415 | var semver_37 = semver$2.outside;
|
18416 | var semver_38 = semver$2.prerelease;
|
18417 | var semver_39 = semver$2.intersects;
|
18418 | var semver_40 = semver$2.coerce;
|
18419 |
|
18420 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
18421 | var pseudomap = PseudoMap;
|
18422 |
|
18423 | function PseudoMap(set) {
|
18424 | if (!(this instanceof PseudoMap))
|
18425 | throw new TypeError("Constructor PseudoMap requires 'new'");
|
18426 | this.clear();
|
18427 |
|
18428 | if (set) {
|
18429 | if (set instanceof PseudoMap || typeof Map === 'function' && set instanceof Map) set.forEach(function (value, key) {
|
18430 | this.set(key, value);
|
18431 | }, this);else if (Array.isArray(set)) set.forEach(function (kv) {
|
18432 | this.set(kv[0], kv[1]);
|
18433 | }, this);else throw new TypeError('invalid argument');
|
18434 | }
|
18435 | }
|
18436 |
|
18437 | PseudoMap.prototype.forEach = function (fn, thisp) {
|
18438 | thisp = thisp || this;
|
18439 | Object.keys(this._data).forEach(function (k) {
|
18440 | if (k !== 'size') fn.call(thisp, this._data[k].value, this._data[k].key);
|
18441 | }, this);
|
18442 | };
|
18443 |
|
18444 | PseudoMap.prototype.has = function (k) {
|
18445 | return !!find(this._data, k);
|
18446 | };
|
18447 |
|
18448 | PseudoMap.prototype.get = function (k) {
|
18449 | var res = find(this._data, k);
|
18450 | return res && res.value;
|
18451 | };
|
18452 |
|
18453 | PseudoMap.prototype.set = function (k, v) {
|
18454 | set(this._data, k, v);
|
18455 | };
|
18456 |
|
18457 | PseudoMap.prototype.delete = function (k) {
|
18458 | var res = find(this._data, k);
|
18459 |
|
18460 | if (res) {
|
18461 | delete this._data[res._index];
|
18462 | this._data.size--;
|
18463 | }
|
18464 | };
|
18465 |
|
18466 | PseudoMap.prototype.clear = function () {
|
18467 | var data = Object.create(null);
|
18468 | data.size = 0;
|
18469 | Object.defineProperty(this, '_data', {
|
18470 | value: data,
|
18471 | enumerable: false,
|
18472 | configurable: true,
|
18473 | writable: false
|
18474 | });
|
18475 | };
|
18476 |
|
18477 | Object.defineProperty(PseudoMap.prototype, 'size', {
|
18478 | get: function () {
|
18479 | return this._data.size;
|
18480 | },
|
18481 | set: function (n) {},
|
18482 | enumerable: true,
|
18483 | configurable: true
|
18484 | });
|
18485 |
|
18486 | PseudoMap.prototype.values = PseudoMap.prototype.keys = PseudoMap.prototype.entries = function () {
|
18487 | throw new Error('iterators are not implemented in this version');
|
18488 | };
|
18489 |
|
18490 |
|
18491 | function same(a, b) {
|
18492 | return a === b || a !== a && b !== b;
|
18493 | }
|
18494 |
|
18495 | function Entry(k, v, i) {
|
18496 | this.key = k;
|
18497 | this.value = v;
|
18498 | this._index = i;
|
18499 | }
|
18500 |
|
18501 | function find(data, k) {
|
18502 | for (var i = 0, s = '_' + k, key = s; hasOwnProperty.call(data, key); key = s + i++) {
|
18503 | if (same(data[key].key, k)) return data[key];
|
18504 | }
|
18505 | }
|
18506 |
|
18507 | function set(data, k, v) {
|
18508 | for (var i = 0, s = '_' + k, key = s; hasOwnProperty.call(data, key); key = s + i++) {
|
18509 | if (same(data[key].key, k)) {
|
18510 | data[key].value = v;
|
18511 | return;
|
18512 | }
|
18513 | }
|
18514 |
|
18515 | data.size++;
|
18516 | data[key] = new Entry(k, v, key);
|
18517 | }
|
18518 |
|
18519 | var map = createCommonjsModule(function (module) {
|
18520 | if (process.env.npm_package_name === 'pseudomap' && process.env.npm_lifecycle_script === 'test') process.env.TEST_PSEUDOMAP = 'true';
|
18521 |
|
18522 | if (typeof Map === 'function' && !process.env.TEST_PSEUDOMAP) {
|
18523 | module.exports = Map;
|
18524 | } else {
|
18525 | module.exports = pseudomap;
|
18526 | }
|
18527 | });
|
18528 |
|
18529 | var yallist = Yallist;
|
18530 | Yallist.Node = Node;
|
18531 | Yallist.create = Yallist;
|
18532 |
|
18533 | function Yallist(list) {
|
18534 | var self = this;
|
18535 |
|
18536 | if (!(self instanceof Yallist)) {
|
18537 | self = new Yallist();
|
18538 | }
|
18539 |
|
18540 | self.tail = null;
|
18541 | self.head = null;
|
18542 | self.length = 0;
|
18543 |
|
18544 | if (list && typeof list.forEach === 'function') {
|
18545 | list.forEach(function (item) {
|
18546 | self.push(item);
|
18547 | });
|
18548 | } else if (arguments.length > 0) {
|
18549 | for (var i = 0, l = arguments.length; i < l; i++) {
|
18550 | self.push(arguments[i]);
|
18551 | }
|
18552 | }
|
18553 |
|
18554 | return self;
|
18555 | }
|
18556 |
|
18557 | Yallist.prototype.removeNode = function (node) {
|
18558 | if (node.list !== this) {
|
18559 | throw new Error('removing node which does not belong to this list');
|
18560 | }
|
18561 |
|
18562 | var next = node.next;
|
18563 | var prev = node.prev;
|
18564 |
|
18565 | if (next) {
|
18566 | next.prev = prev;
|
18567 | }
|
18568 |
|
18569 | if (prev) {
|
18570 | prev.next = next;
|
18571 | }
|
18572 |
|
18573 | if (node === this.head) {
|
18574 | this.head = next;
|
18575 | }
|
18576 |
|
18577 | if (node === this.tail) {
|
18578 | this.tail = prev;
|
18579 | }
|
18580 |
|
18581 | node.list.length--;
|
18582 | node.next = null;
|
18583 | node.prev = null;
|
18584 | node.list = null;
|
18585 | };
|
18586 |
|
18587 | Yallist.prototype.unshiftNode = function (node) {
|
18588 | if (node === this.head) {
|
18589 | return;
|
18590 | }
|
18591 |
|
18592 | if (node.list) {
|
18593 | node.list.removeNode(node);
|
18594 | }
|
18595 |
|
18596 | var head = this.head;
|
18597 | node.list = this;
|
18598 | node.next = head;
|
18599 |
|
18600 | if (head) {
|
18601 | head.prev = node;
|
18602 | }
|
18603 |
|
18604 | this.head = node;
|
18605 |
|
18606 | if (!this.tail) {
|
18607 | this.tail = node;
|
18608 | }
|
18609 |
|
18610 | this.length++;
|
18611 | };
|
18612 |
|
18613 | Yallist.prototype.pushNode = function (node) {
|
18614 | if (node === this.tail) {
|
18615 | return;
|
18616 | }
|
18617 |
|
18618 | if (node.list) {
|
18619 | node.list.removeNode(node);
|
18620 | }
|
18621 |
|
18622 | var tail = this.tail;
|
18623 | node.list = this;
|
18624 | node.prev = tail;
|
18625 |
|
18626 | if (tail) {
|
18627 | tail.next = node;
|
18628 | }
|
18629 |
|
18630 | this.tail = node;
|
18631 |
|
18632 | if (!this.head) {
|
18633 | this.head = node;
|
18634 | }
|
18635 |
|
18636 | this.length++;
|
18637 | };
|
18638 |
|
18639 | Yallist.prototype.push = function () {
|
18640 | for (var i = 0, l = arguments.length; i < l; i++) {
|
18641 | push(this, arguments[i]);
|
18642 | }
|
18643 |
|
18644 | return this.length;
|
18645 | };
|
18646 |
|
18647 | Yallist.prototype.unshift = function () {
|
18648 | for (var i = 0, l = arguments.length; i < l; i++) {
|
18649 | unshift(this, arguments[i]);
|
18650 | }
|
18651 |
|
18652 | return this.length;
|
18653 | };
|
18654 |
|
18655 | Yallist.prototype.pop = function () {
|
18656 | if (!this.tail) {
|
18657 | return undefined;
|
18658 | }
|
18659 |
|
18660 | var res = this.tail.value;
|
18661 | this.tail = this.tail.prev;
|
18662 |
|
18663 | if (this.tail) {
|
18664 | this.tail.next = null;
|
18665 | } else {
|
18666 | this.head = null;
|
18667 | }
|
18668 |
|
18669 | this.length--;
|
18670 | return res;
|
18671 | };
|
18672 |
|
18673 | Yallist.prototype.shift = function () {
|
18674 | if (!this.head) {
|
18675 | return undefined;
|
18676 | }
|
18677 |
|
18678 | var res = this.head.value;
|
18679 | this.head = this.head.next;
|
18680 |
|
18681 | if (this.head) {
|
18682 | this.head.prev = null;
|
18683 | } else {
|
18684 | this.tail = null;
|
18685 | }
|
18686 |
|
18687 | this.length--;
|
18688 | return res;
|
18689 | };
|
18690 |
|
18691 | Yallist.prototype.forEach = function (fn, thisp) {
|
18692 | thisp = thisp || this;
|
18693 |
|
18694 | for (var walker = this.head, i = 0; walker !== null; i++) {
|
18695 | fn.call(thisp, walker.value, i, this);
|
18696 | walker = walker.next;
|
18697 | }
|
18698 | };
|
18699 |
|
18700 | Yallist.prototype.forEachReverse = function (fn, thisp) {
|
18701 | thisp = thisp || this;
|
18702 |
|
18703 | for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
|
18704 | fn.call(thisp, walker.value, i, this);
|
18705 | walker = walker.prev;
|
18706 | }
|
18707 | };
|
18708 |
|
18709 | Yallist.prototype.get = function (n) {
|
18710 | for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
|
18711 |
|
18712 | walker = walker.next;
|
18713 | }
|
18714 |
|
18715 | if (i === n && walker !== null) {
|
18716 | return walker.value;
|
18717 | }
|
18718 | };
|
18719 |
|
18720 | Yallist.prototype.getReverse = function (n) {
|
18721 | for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
|
18722 |
|
18723 | walker = walker.prev;
|
18724 | }
|
18725 |
|
18726 | if (i === n && walker !== null) {
|
18727 | return walker.value;
|
18728 | }
|
18729 | };
|
18730 |
|
18731 | Yallist.prototype.map = function (fn, thisp) {
|
18732 | thisp = thisp || this;
|
18733 | var res = new Yallist();
|
18734 |
|
18735 | for (var walker = this.head; walker !== null;) {
|
18736 | res.push(fn.call(thisp, walker.value, this));
|
18737 | walker = walker.next;
|
18738 | }
|
18739 |
|
18740 | return res;
|
18741 | };
|
18742 |
|
18743 | Yallist.prototype.mapReverse = function (fn, thisp) {
|
18744 | thisp = thisp || this;
|
18745 | var res = new Yallist();
|
18746 |
|
18747 | for (var walker = this.tail; walker !== null;) {
|
18748 | res.push(fn.call(thisp, walker.value, this));
|
18749 | walker = walker.prev;
|
18750 | }
|
18751 |
|
18752 | return res;
|
18753 | };
|
18754 |
|
18755 | Yallist.prototype.reduce = function (fn, initial) {
|
18756 | var acc;
|
18757 | var walker = this.head;
|
18758 |
|
18759 | if (arguments.length > 1) {
|
18760 | acc = initial;
|
18761 | } else if (this.head) {
|
18762 | walker = this.head.next;
|
18763 | acc = this.head.value;
|
18764 | } else {
|
18765 | throw new TypeError('Reduce of empty list with no initial value');
|
18766 | }
|
18767 |
|
18768 | for (var i = 0; walker !== null; i++) {
|
18769 | acc = fn(acc, walker.value, i);
|
18770 | walker = walker.next;
|
18771 | }
|
18772 |
|
18773 | return acc;
|
18774 | };
|
18775 |
|
18776 | Yallist.prototype.reduceReverse = function (fn, initial) {
|
18777 | var acc;
|
18778 | var walker = this.tail;
|
18779 |
|
18780 | if (arguments.length > 1) {
|
18781 | acc = initial;
|
18782 | } else if (this.tail) {
|
18783 | walker = this.tail.prev;
|
18784 | acc = this.tail.value;
|
18785 | } else {
|
18786 | throw new TypeError('Reduce of empty list with no initial value');
|
18787 | }
|
18788 |
|
18789 | for (var i = this.length - 1; walker !== null; i--) {
|
18790 | acc = fn(acc, walker.value, i);
|
18791 | walker = walker.prev;
|
18792 | }
|
18793 |
|
18794 | return acc;
|
18795 | };
|
18796 |
|
18797 | Yallist.prototype.toArray = function () {
|
18798 | var arr = new Array(this.length);
|
18799 |
|
18800 | for (var i = 0, walker = this.head; walker !== null; i++) {
|
18801 | arr[i] = walker.value;
|
18802 | walker = walker.next;
|
18803 | }
|
18804 |
|
18805 | return arr;
|
18806 | };
|
18807 |
|
18808 | Yallist.prototype.toArrayReverse = function () {
|
18809 | var arr = new Array(this.length);
|
18810 |
|
18811 | for (var i = 0, walker = this.tail; walker !== null; i++) {
|
18812 | arr[i] = walker.value;
|
18813 | walker = walker.prev;
|
18814 | }
|
18815 |
|
18816 | return arr;
|
18817 | };
|
18818 |
|
18819 | Yallist.prototype.slice = function (from, to) {
|
18820 | to = to || this.length;
|
18821 |
|
18822 | if (to < 0) {
|
18823 | to += this.length;
|
18824 | }
|
18825 |
|
18826 | from = from || 0;
|
18827 |
|
18828 | if (from < 0) {
|
18829 | from += this.length;
|
18830 | }
|
18831 |
|
18832 | var ret = new Yallist();
|
18833 |
|
18834 | if (to < from || to < 0) {
|
18835 | return ret;
|
18836 | }
|
18837 |
|
18838 | if (from < 0) {
|
18839 | from = 0;
|
18840 | }
|
18841 |
|
18842 | if (to > this.length) {
|
18843 | to = this.length;
|
18844 | }
|
18845 |
|
18846 | for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
|
18847 | walker = walker.next;
|
18848 | }
|
18849 |
|
18850 | for (; walker !== null && i < to; i++, walker = walker.next) {
|
18851 | ret.push(walker.value);
|
18852 | }
|
18853 |
|
18854 | return ret;
|
18855 | };
|
18856 |
|
18857 | Yallist.prototype.sliceReverse = function (from, to) {
|
18858 | to = to || this.length;
|
18859 |
|
18860 | if (to < 0) {
|
18861 | to += this.length;
|
18862 | }
|
18863 |
|
18864 | from = from || 0;
|
18865 |
|
18866 | if (from < 0) {
|
18867 | from += this.length;
|
18868 | }
|
18869 |
|
18870 | var ret = new Yallist();
|
18871 |
|
18872 | if (to < from || to < 0) {
|
18873 | return ret;
|
18874 | }
|
18875 |
|
18876 | if (from < 0) {
|
18877 | from = 0;
|
18878 | }
|
18879 |
|
18880 | if (to > this.length) {
|
18881 | to = this.length;
|
18882 | }
|
18883 |
|
18884 | for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
|
18885 | walker = walker.prev;
|
18886 | }
|
18887 |
|
18888 | for (; walker !== null && i > from; i--, walker = walker.prev) {
|
18889 | ret.push(walker.value);
|
18890 | }
|
18891 |
|
18892 | return ret;
|
18893 | };
|
18894 |
|
18895 | Yallist.prototype.reverse = function () {
|
18896 | var head = this.head;
|
18897 | var tail = this.tail;
|
18898 |
|
18899 | for (var walker = head; walker !== null; walker = walker.prev) {
|
18900 | var p = walker.prev;
|
18901 | walker.prev = walker.next;
|
18902 | walker.next = p;
|
18903 | }
|
18904 |
|
18905 | this.head = tail;
|
18906 | this.tail = head;
|
18907 | return this;
|
18908 | };
|
18909 |
|
18910 | function push(self, item) {
|
18911 | self.tail = new Node(item, self.tail, null, self);
|
18912 |
|
18913 | if (!self.head) {
|
18914 | self.head = self.tail;
|
18915 | }
|
18916 |
|
18917 | self.length++;
|
18918 | }
|
18919 |
|
18920 | function unshift(self, item) {
|
18921 | self.head = new Node(item, null, self.head, self);
|
18922 |
|
18923 | if (!self.tail) {
|
18924 | self.tail = self.head;
|
18925 | }
|
18926 |
|
18927 | self.length++;
|
18928 | }
|
18929 |
|
18930 | function Node(value, prev, next, list) {
|
18931 | if (!(this instanceof Node)) {
|
18932 | return new Node(value, prev, next, list);
|
18933 | }
|
18934 |
|
18935 | this.list = list;
|
18936 | this.value = value;
|
18937 |
|
18938 | if (prev) {
|
18939 | prev.next = this;
|
18940 | this.prev = prev;
|
18941 | } else {
|
18942 | this.prev = null;
|
18943 | }
|
18944 |
|
18945 | if (next) {
|
18946 | next.prev = this;
|
18947 | this.next = next;
|
18948 | } else {
|
18949 | this.next = null;
|
18950 | }
|
18951 | }
|
18952 |
|
18953 | var lruCache = LRUCache;
|
18954 |
|
18955 |
|
18956 |
|
18957 |
|
18958 | var hasSymbol = typeof Symbol === 'function' && process.env._nodeLRUCacheForceNoSymbol !== '1';
|
18959 | var makeSymbol;
|
18960 |
|
18961 | if (hasSymbol) {
|
18962 | makeSymbol = function (key) {
|
18963 | return Symbol(key);
|
18964 | };
|
18965 | } else {
|
18966 | makeSymbol = function (key) {
|
18967 | return '_' + key;
|
18968 | };
|
18969 | }
|
18970 |
|
18971 | var MAX = makeSymbol('max');
|
18972 | var LENGTH = makeSymbol('length');
|
18973 | var LENGTH_CALCULATOR = makeSymbol('lengthCalculator');
|
18974 | var ALLOW_STALE = makeSymbol('allowStale');
|
18975 | var MAX_AGE = makeSymbol('maxAge');
|
18976 | var DISPOSE = makeSymbol('dispose');
|
18977 | var NO_DISPOSE_ON_SET = makeSymbol('noDisposeOnSet');
|
18978 | var LRU_LIST = makeSymbol('lruList');
|
18979 | var CACHE = makeSymbol('cache');
|
18980 |
|
18981 | function naiveLength() {
|
18982 | return 1;
|
18983 | }
|
18984 |
|
18985 |
|
18986 |
|
18987 |
|
18988 |
|
18989 |
|
18990 |
|
18991 |
|
18992 |
|
18993 | function LRUCache(options) {
|
18994 | if (!(this instanceof LRUCache)) {
|
18995 | return new LRUCache(options);
|
18996 | }
|
18997 |
|
18998 | if (typeof options === 'number') {
|
18999 | options = {
|
19000 | max: options
|
19001 | };
|
19002 | }
|
19003 |
|
19004 | if (!options) {
|
19005 | options = {};
|
19006 | }
|
19007 |
|
19008 | var max = this[MAX] = options.max;
|
19009 |
|
19010 | if (!max || !(typeof max === 'number') || max <= 0) {
|
19011 | this[MAX] = Infinity;
|
19012 | }
|
19013 |
|
19014 | var lc = options.length || naiveLength;
|
19015 |
|
19016 | if (typeof lc !== 'function') {
|
19017 | lc = naiveLength;
|
19018 | }
|
19019 |
|
19020 | this[LENGTH_CALCULATOR] = lc;
|
19021 | this[ALLOW_STALE] = options.stale || false;
|
19022 | this[MAX_AGE] = options.maxAge || 0;
|
19023 | this[DISPOSE] = options.dispose;
|
19024 | this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
|
19025 | this.reset();
|
19026 | }
|
19027 |
|
19028 |
|
19029 | Object.defineProperty(LRUCache.prototype, 'max', {
|
19030 | set: function (mL) {
|
19031 | if (!mL || !(typeof mL === 'number') || mL <= 0) {
|
19032 | mL = Infinity;
|
19033 | }
|
19034 |
|
19035 | this[MAX] = mL;
|
19036 | trim$2(this);
|
19037 | },
|
19038 | get: function () {
|
19039 | return this[MAX];
|
19040 | },
|
19041 | enumerable: true
|
19042 | });
|
19043 | Object.defineProperty(LRUCache.prototype, 'allowStale', {
|
19044 | set: function (allowStale) {
|
19045 | this[ALLOW_STALE] = !!allowStale;
|
19046 | },
|
19047 | get: function () {
|
19048 | return this[ALLOW_STALE];
|
19049 | },
|
19050 | enumerable: true
|
19051 | });
|
19052 | Object.defineProperty(LRUCache.prototype, 'maxAge', {
|
19053 | set: function (mA) {
|
19054 | if (!mA || !(typeof mA === 'number') || mA < 0) {
|
19055 | mA = 0;
|
19056 | }
|
19057 |
|
19058 | this[MAX_AGE] = mA;
|
19059 | trim$2(this);
|
19060 | },
|
19061 | get: function () {
|
19062 | return this[MAX_AGE];
|
19063 | },
|
19064 | enumerable: true
|
19065 | });
|
19066 |
|
19067 | Object.defineProperty(LRUCache.prototype, 'lengthCalculator', {
|
19068 | set: function (lC) {
|
19069 | if (typeof lC !== 'function') {
|
19070 | lC = naiveLength;
|
19071 | }
|
19072 |
|
19073 | if (lC !== this[LENGTH_CALCULATOR]) {
|
19074 | this[LENGTH_CALCULATOR] = lC;
|
19075 | this[LENGTH] = 0;
|
19076 | this[LRU_LIST].forEach(function (hit) {
|
19077 | hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
|
19078 | this[LENGTH] += hit.length;
|
19079 | }, this);
|
19080 | }
|
19081 |
|
19082 | trim$2(this);
|
19083 | },
|
19084 | get: function () {
|
19085 | return this[LENGTH_CALCULATOR];
|
19086 | },
|
19087 | enumerable: true
|
19088 | });
|
19089 | Object.defineProperty(LRUCache.prototype, 'length', {
|
19090 | get: function () {
|
19091 | return this[LENGTH];
|
19092 | },
|
19093 | enumerable: true
|
19094 | });
|
19095 | Object.defineProperty(LRUCache.prototype, 'itemCount', {
|
19096 | get: function () {
|
19097 | return this[LRU_LIST].length;
|
19098 | },
|
19099 | enumerable: true
|
19100 | });
|
19101 |
|
19102 | LRUCache.prototype.rforEach = function (fn, thisp) {
|
19103 | thisp = thisp || this;
|
19104 |
|
19105 | for (var walker = this[LRU_LIST].tail; walker !== null;) {
|
19106 | var prev = walker.prev;
|
19107 | forEachStep(this, fn, walker, thisp);
|
19108 | walker = prev;
|
19109 | }
|
19110 | };
|
19111 |
|
19112 | function forEachStep(self, fn, node, thisp) {
|
19113 | var hit = node.value;
|
19114 |
|
19115 | if (isStale(self, hit)) {
|
19116 | del(self, node);
|
19117 |
|
19118 | if (!self[ALLOW_STALE]) {
|
19119 | hit = undefined;
|
19120 | }
|
19121 | }
|
19122 |
|
19123 | if (hit) {
|
19124 | fn.call(thisp, hit.value, hit.key, self);
|
19125 | }
|
19126 | }
|
19127 |
|
19128 | LRUCache.prototype.forEach = function (fn, thisp) {
|
19129 | thisp = thisp || this;
|
19130 |
|
19131 | for (var walker = this[LRU_LIST].head; walker !== null;) {
|
19132 | var next = walker.next;
|
19133 | forEachStep(this, fn, walker, thisp);
|
19134 | walker = next;
|
19135 | }
|
19136 | };
|
19137 |
|
19138 | LRUCache.prototype.keys = function () {
|
19139 | return this[LRU_LIST].toArray().map(function (k) {
|
19140 | return k.key;
|
19141 | }, this);
|
19142 | };
|
19143 |
|
19144 | LRUCache.prototype.values = function () {
|
19145 | return this[LRU_LIST].toArray().map(function (k) {
|
19146 | return k.value;
|
19147 | }, this);
|
19148 | };
|
19149 |
|
19150 | LRUCache.prototype.reset = function () {
|
19151 | if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) {
|
19152 | this[LRU_LIST].forEach(function (hit) {
|
19153 | this[DISPOSE](hit.key, hit.value);
|
19154 | }, this);
|
19155 | }
|
19156 |
|
19157 | this[CACHE] = new map();
|
19158 |
|
19159 | this[LRU_LIST] = new yallist();
|
19160 |
|
19161 | this[LENGTH] = 0;
|
19162 | };
|
19163 |
|
19164 | LRUCache.prototype.dump = function () {
|
19165 | return this[LRU_LIST].map(function (hit) {
|
19166 | if (!isStale(this, hit)) {
|
19167 | return {
|
19168 | k: hit.key,
|
19169 | v: hit.value,
|
19170 | e: hit.now + (hit.maxAge || 0)
|
19171 | };
|
19172 | }
|
19173 | }, this).toArray().filter(function (h) {
|
19174 | return h;
|
19175 | });
|
19176 | };
|
19177 |
|
19178 | LRUCache.prototype.dumpLru = function () {
|
19179 | return this[LRU_LIST];
|
19180 | };
|
19181 |
|
19182 |
|
19183 |
|
19184 | LRUCache.prototype.inspect = function (n, opts) {
|
19185 | var str = 'LRUCache {';
|
19186 | var extras = false;
|
19187 | var as = this[ALLOW_STALE];
|
19188 |
|
19189 | if (as) {
|
19190 | str += '\n allowStale: true';
|
19191 | extras = true;
|
19192 | }
|
19193 |
|
19194 | var max = this[MAX];
|
19195 |
|
19196 | if (max && max !== Infinity) {
|
19197 | if (extras) {
|
19198 | str += ',';
|
19199 | }
|
19200 |
|
19201 | str += '\n max: ' + util$4.inspect(max, opts);
|
19202 | extras = true;
|
19203 | }
|
19204 |
|
19205 | var maxAge = this[MAX_AGE];
|
19206 |
|
19207 | if (maxAge) {
|
19208 | if (extras) {
|
19209 | str += ',';
|
19210 | }
|
19211 |
|
19212 | str += '\n maxAge: ' + util$4.inspect(maxAge, opts);
|
19213 | extras = true;
|
19214 | }
|
19215 |
|
19216 | var lc = this[LENGTH_CALCULATOR];
|
19217 |
|
19218 | if (lc && lc !== naiveLength) {
|
19219 | if (extras) {
|
19220 | str += ',';
|
19221 | }
|
19222 |
|
19223 | str += '\n length: ' + util$4.inspect(this[LENGTH], opts);
|
19224 | extras = true;
|
19225 | }
|
19226 |
|
19227 | var didFirst = false;
|
19228 | this[LRU_LIST].forEach(function (item) {
|
19229 | if (didFirst) {
|
19230 | str += ',\n ';
|
19231 | } else {
|
19232 | if (extras) {
|
19233 | str += ',\n';
|
19234 | }
|
19235 |
|
19236 | didFirst = true;
|
19237 | str += '\n ';
|
19238 | }
|
19239 |
|
19240 | var key = util$4.inspect(item.key).split('\n').join('\n ');
|
19241 | var val = {
|
19242 | value: item.value
|
19243 | };
|
19244 |
|
19245 | if (item.maxAge !== maxAge) {
|
19246 | val.maxAge = item.maxAge;
|
19247 | }
|
19248 |
|
19249 | if (lc !== naiveLength) {
|
19250 | val.length = item.length;
|
19251 | }
|
19252 |
|
19253 | if (isStale(this, item)) {
|
19254 | val.stale = true;
|
19255 | }
|
19256 |
|
19257 | val = util$4.inspect(val, opts).split('\n').join('\n ');
|
19258 | str += key + ' => ' + val;
|
19259 | });
|
19260 |
|
19261 | if (didFirst || extras) {
|
19262 | str += '\n';
|
19263 | }
|
19264 |
|
19265 | str += '}';
|
19266 | return str;
|
19267 | };
|
19268 |
|
19269 | LRUCache.prototype.set = function (key, value, maxAge) {
|
19270 | maxAge = maxAge || this[MAX_AGE];
|
19271 | var now = maxAge ? Date.now() : 0;
|
19272 | var len = this[LENGTH_CALCULATOR](value, key);
|
19273 |
|
19274 | if (this[CACHE].has(key)) {
|
19275 | if (len > this[MAX]) {
|
19276 | del(this, this[CACHE].get(key));
|
19277 | return false;
|
19278 | }
|
19279 |
|
19280 | var node = this[CACHE].get(key);
|
19281 | var item = node.value;
|
19282 |
|
19283 |
|
19284 | if (this[DISPOSE]) {
|
19285 | if (!this[NO_DISPOSE_ON_SET]) {
|
19286 | this[DISPOSE](key, item.value);
|
19287 | }
|
19288 | }
|
19289 |
|
19290 | item.now = now;
|
19291 | item.maxAge = maxAge;
|
19292 | item.value = value;
|
19293 | this[LENGTH] += len - item.length;
|
19294 | item.length = len;
|
19295 | this.get(key);
|
19296 | trim$2(this);
|
19297 | return true;
|
19298 | }
|
19299 |
|
19300 | var hit = new Entry$1(key, value, len, now, maxAge);
|
19301 |
|
19302 | if (hit.length > this[MAX]) {
|
19303 | if (this[DISPOSE]) {
|
19304 | this[DISPOSE](key, value);
|
19305 | }
|
19306 |
|
19307 | return false;
|
19308 | }
|
19309 |
|
19310 | this[LENGTH] += hit.length;
|
19311 | this[LRU_LIST].unshift(hit);
|
19312 | this[CACHE].set(key, this[LRU_LIST].head);
|
19313 | trim$2(this);
|
19314 | return true;
|
19315 | };
|
19316 |
|
19317 | LRUCache.prototype.has = function (key) {
|
19318 | if (!this[CACHE].has(key)) return false;
|
19319 | var hit = this[CACHE].get(key).value;
|
19320 |
|
19321 | if (isStale(this, hit)) {
|
19322 | return false;
|
19323 | }
|
19324 |
|
19325 | return true;
|
19326 | };
|
19327 |
|
19328 | LRUCache.prototype.get = function (key) {
|
19329 | return get(this, key, true);
|
19330 | };
|
19331 |
|
19332 | LRUCache.prototype.peek = function (key) {
|
19333 | return get(this, key, false);
|
19334 | };
|
19335 |
|
19336 | LRUCache.prototype.pop = function () {
|
19337 | var node = this[LRU_LIST].tail;
|
19338 | if (!node) return null;
|
19339 | del(this, node);
|
19340 | return node.value;
|
19341 | };
|
19342 |
|
19343 | LRUCache.prototype.del = function (key) {
|
19344 | del(this, this[CACHE].get(key));
|
19345 | };
|
19346 |
|
19347 | LRUCache.prototype.load = function (arr) {
|
19348 |
|
19349 | this.reset();
|
19350 | var now = Date.now();
|
19351 |
|
19352 | for (var l = arr.length - 1; l >= 0; l--) {
|
19353 | var hit = arr[l];
|
19354 | var expiresAt = hit.e || 0;
|
19355 |
|
19356 | if (expiresAt === 0) {
|
19357 |
|
19358 | this.set(hit.k, hit.v);
|
19359 | } else {
|
19360 | var maxAge = expiresAt - now;
|
19361 |
|
19362 | if (maxAge > 0) {
|
19363 | this.set(hit.k, hit.v, maxAge);
|
19364 | }
|
19365 | }
|
19366 | }
|
19367 | };
|
19368 |
|
19369 | LRUCache.prototype.prune = function () {
|
19370 | var self = this;
|
19371 | this[CACHE].forEach(function (value, key) {
|
19372 | get(self, key, false);
|
19373 | });
|
19374 | };
|
19375 |
|
19376 | function get(self, key, doUse) {
|
19377 | var node = self[CACHE].get(key);
|
19378 |
|
19379 | if (node) {
|
19380 | var hit = node.value;
|
19381 |
|
19382 | if (isStale(self, hit)) {
|
19383 | del(self, node);
|
19384 | if (!self[ALLOW_STALE]) hit = undefined;
|
19385 | } else {
|
19386 | if (doUse) {
|
19387 | self[LRU_LIST].unshiftNode(node);
|
19388 | }
|
19389 | }
|
19390 |
|
19391 | if (hit) hit = hit.value;
|
19392 | }
|
19393 |
|
19394 | return hit;
|
19395 | }
|
19396 |
|
19397 | function isStale(self, hit) {
|
19398 | if (!hit || !hit.maxAge && !self[MAX_AGE]) {
|
19399 | return false;
|
19400 | }
|
19401 |
|
19402 | var stale = false;
|
19403 | var diff = Date.now() - hit.now;
|
19404 |
|
19405 | if (hit.maxAge) {
|
19406 | stale = diff > hit.maxAge;
|
19407 | } else {
|
19408 | stale = self[MAX_AGE] && diff > self[MAX_AGE];
|
19409 | }
|
19410 |
|
19411 | return stale;
|
19412 | }
|
19413 |
|
19414 | function trim$2(self) {
|
19415 | if (self[LENGTH] > self[MAX]) {
|
19416 | for (var walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null;) {
|
19417 |
|
19418 |
|
19419 |
|
19420 | var prev = walker.prev;
|
19421 | del(self, walker);
|
19422 | walker = prev;
|
19423 | }
|
19424 | }
|
19425 | }
|
19426 |
|
19427 | function del(self, node) {
|
19428 | if (node) {
|
19429 | var hit = node.value;
|
19430 |
|
19431 | if (self[DISPOSE]) {
|
19432 | self[DISPOSE](hit.key, hit.value);
|
19433 | }
|
19434 |
|
19435 | self[LENGTH] -= hit.length;
|
19436 | self[CACHE].delete(hit.key);
|
19437 | self[LRU_LIST].removeNode(node);
|
19438 | }
|
19439 | }
|
19440 |
|
19441 |
|
19442 | function Entry$1(key, value, length, now, maxAge) {
|
19443 | this.key = key;
|
19444 | this.value = value;
|
19445 | this.length = length;
|
19446 | this.now = now;
|
19447 | this.maxAge = maxAge || 0;
|
19448 | }
|
19449 |
|
19450 | var sigmund_1 = sigmund;
|
19451 |
|
19452 | function sigmund(subject, maxSessions) {
|
19453 | maxSessions = maxSessions || 10;
|
19454 | var notes = [];
|
19455 | var analysis = '';
|
19456 | var RE = RegExp;
|
19457 |
|
19458 | function psychoAnalyze(subject, session) {
|
19459 | if (session > maxSessions) return;
|
19460 |
|
19461 | if (typeof subject === 'function' || typeof subject === 'undefined') {
|
19462 | return;
|
19463 | }
|
19464 |
|
19465 | if (typeof subject !== 'object' || !subject || subject instanceof RE) {
|
19466 | analysis += subject;
|
19467 | return;
|
19468 | }
|
19469 |
|
19470 | if (notes.indexOf(subject) !== -1 || session === maxSessions) return;
|
19471 | notes.push(subject);
|
19472 | analysis += '{';
|
19473 | Object.keys(subject).forEach(function (issue, _, __) {
|
19474 |
|
19475 | if (issue.charAt(0) === '_') return;
|
19476 | var to = typeof subject[issue];
|
19477 | if (to === 'function' || to === 'undefined') return;
|
19478 | analysis += issue;
|
19479 | psychoAnalyze(subject[issue], session + 1);
|
19480 | });
|
19481 | }
|
19482 |
|
19483 | psychoAnalyze(subject, 0);
|
19484 | return analysis;
|
19485 | }
|
19486 |
|
19487 | var fnmatch = createCommonjsModule(function (module, exports) {
|
19488 |
|
19489 | var platform = typeof process === "object" ? process.platform : "win32";
|
19490 | if (module) module.exports = minimatch;else exports.minimatch = minimatch;
|
19491 | minimatch.Minimatch = Minimatch;
|
19492 | var cache = minimatch.cache = new lruCache({
|
19493 | max: 100
|
19494 | }),
|
19495 | GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {};
|
19496 | var qmark = "[^/]"
|
19497 | ,
|
19498 | star = qmark + "*?"
|
19499 |
|
19500 |
|
19501 | ,
|
19502 | twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?"
|
19503 |
|
19504 | ,
|
19505 | twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?"
|
19506 | ,
|
19507 | reSpecials = charSet("().*{}+?[]^$\\!");
|
19508 |
|
19509 | function charSet(s) {
|
19510 | return s.split("").reduce(function (set, c) {
|
19511 | set[c] = true;
|
19512 | return set;
|
19513 | }, {});
|
19514 | }
|
19515 |
|
19516 |
|
19517 | var slashSplit = /\/+/;
|
19518 | minimatch.monkeyPatch = monkeyPatch;
|
19519 |
|
19520 | function monkeyPatch() {
|
19521 | var desc = Object.getOwnPropertyDescriptor(String.prototype, "match");
|
19522 | var orig = desc.value;
|
19523 |
|
19524 | desc.value = function (p) {
|
19525 | if (p instanceof Minimatch) return p.match(this);
|
19526 | return orig.call(this, p);
|
19527 | };
|
19528 |
|
19529 | Object.defineProperty(String.prototype, desc);
|
19530 | }
|
19531 |
|
19532 | minimatch.filter = filter;
|
19533 |
|
19534 | function filter(pattern, options) {
|
19535 | options = options || {};
|
19536 | return function (p, i, list) {
|
19537 | return minimatch(p, pattern, options);
|
19538 | };
|
19539 | }
|
19540 |
|
19541 | function ext(a, b) {
|
19542 | a = a || {};
|
19543 | b = b || {};
|
19544 | var t = {};
|
19545 | Object.keys(b).forEach(function (k) {
|
19546 | t[k] = b[k];
|
19547 | });
|
19548 | Object.keys(a).forEach(function (k) {
|
19549 | t[k] = a[k];
|
19550 | });
|
19551 | return t;
|
19552 | }
|
19553 |
|
19554 | minimatch.defaults = function (def) {
|
19555 | if (!def || !Object.keys(def).length) return minimatch;
|
19556 | var orig = minimatch;
|
19557 |
|
19558 | var m = function minimatch(p, pattern, options) {
|
19559 | return orig.minimatch(p, pattern, ext(def, options));
|
19560 | };
|
19561 |
|
19562 | m.Minimatch = function Minimatch(pattern, options) {
|
19563 | return new orig.Minimatch(pattern, ext(def, options));
|
19564 | };
|
19565 |
|
19566 | return m;
|
19567 | };
|
19568 |
|
19569 | Minimatch.defaults = function (def) {
|
19570 | if (!def || !Object.keys(def).length) return Minimatch;
|
19571 | return minimatch.defaults(def).Minimatch;
|
19572 | };
|
19573 |
|
19574 | function minimatch(p, pattern, options) {
|
19575 | if (typeof pattern !== "string") {
|
19576 | throw new TypeError("glob pattern string required");
|
19577 | }
|
19578 |
|
19579 | if (!options) options = {};
|
19580 |
|
19581 | if (!options.nocomment && pattern.charAt(0) === "#") {
|
19582 | return false;
|
19583 | }
|
19584 |
|
19585 |
|
19586 | if (pattern.trim() === "") return p === "";
|
19587 | return new Minimatch(pattern, options).match(p);
|
19588 | }
|
19589 |
|
19590 | function Minimatch(pattern, options) {
|
19591 | if (!(this instanceof Minimatch)) {
|
19592 | return new Minimatch(pattern, options, cache);
|
19593 | }
|
19594 |
|
19595 | if (typeof pattern !== "string") {
|
19596 | throw new TypeError("glob pattern string required");
|
19597 | }
|
19598 |
|
19599 | if (!options) options = {};
|
19600 |
|
19601 |
|
19602 | if (platform === "win32") {
|
19603 | pattern = pattern.split("\\").join("/");
|
19604 | }
|
19605 |
|
19606 |
|
19607 |
|
19608 |
|
19609 | var cacheKey = pattern + "\n" + sigmund_1(options);
|
19610 | var cached = minimatch.cache.get(cacheKey);
|
19611 | if (cached) return cached;
|
19612 | minimatch.cache.set(cacheKey, this);
|
19613 | this.options = options;
|
19614 | this.set = [];
|
19615 | this.pattern = pattern;
|
19616 | this.regexp = null;
|
19617 | this.negate = false;
|
19618 | this.comment = false;
|
19619 | this.empty = false;
|
19620 |
|
19621 | this.make();
|
19622 | }
|
19623 |
|
19624 | Minimatch.prototype.make = make;
|
19625 |
|
19626 | function make() {
|
19627 |
|
19628 | if (this._made) return;
|
19629 | var pattern = this.pattern;
|
19630 | var options = this.options;
|
19631 |
|
19632 | if (!options.nocomment && pattern.charAt(0) === "#") {
|
19633 | this.comment = true;
|
19634 | return;
|
19635 | }
|
19636 |
|
19637 | if (!pattern) {
|
19638 | this.empty = true;
|
19639 | return;
|
19640 | }
|
19641 |
|
19642 |
|
19643 | this.parseNegate();
|
19644 |
|
19645 | var set = this.globSet = this.braceExpand();
|
19646 | if (options.debug) console.error(this.pattern, set); // step 3: now we have a set, so turn each one into a series of path-portion
|
19647 | // matching patterns.
|
19648 | // These will be regexps, except in the case of "**", which is
|
19649 | // set to the GLOBSTAR object for globstar behavior,
|
19650 | // and will not contain any / characters
|
19651 |
|
19652 | set = this.globParts = set.map(function (s) {
|
19653 | return s.split(slashSplit);
|
19654 | });
|
19655 | if (options.debug) console.error(this.pattern, set); // glob --> regexps
|
19656 |
|
19657 | set = set.map(function (s, si, set) {
|
19658 | return s.map(this.parse, this);
|
19659 | }, this);
|
19660 | if (options.debug) console.error(this.pattern, set); // filter out everything that didn't compile properly.
|
19661 |
|
19662 | set = set.filter(function (s) {
|
19663 | return -1 === s.indexOf(false);
|
19664 | });
|
19665 | if (options.debug) console.error(this.pattern, set);
|
19666 | this.set = set;
|
19667 | }
|
19668 |
|
19669 | Minimatch.prototype.parseNegate = parseNegate;
|
19670 |
|
19671 | function parseNegate() {
|
19672 | var pattern = this.pattern,
|
19673 | negate = false,
|
19674 | options = this.options,
|
19675 | negateOffset = 0;
|
19676 | if (options.nonegate) return;
|
19677 |
|
19678 | for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === "!"; i++) {
|
19679 | negate = !negate;
|
19680 | negateOffset++;
|
19681 | }
|
19682 |
|
19683 | if (negateOffset) this.pattern = pattern.substr(negateOffset);
|
19684 | this.negate = negate;
|
19685 | }
|
19686 |
|
19687 |
|
19688 |
|
19689 |
|
19690 |
|
19691 |
|
19692 |
|
19693 |
|
19694 |
|
19695 |
|
19696 |
|
19697 | minimatch.braceExpand = function (pattern, options) {
|
19698 | return new Minimatch(pattern, options).braceExpand();
|
19699 | };
|
19700 |
|
19701 | Minimatch.prototype.braceExpand = braceExpand;
|
19702 |
|
19703 | function braceExpand(pattern, options) {
|
19704 | options = options || this.options;
|
19705 | pattern = typeof pattern === "undefined" ? this.pattern : pattern;
|
19706 |
|
19707 | if (typeof pattern === "undefined") {
|
19708 | throw new Error("undefined pattern");
|
19709 | }
|
19710 |
|
19711 | if (options.nobrace || !pattern.match(/\{.*\}/)) {
|
19712 |
|
19713 | return [pattern];
|
19714 | }
|
19715 |
|
19716 | var escaping = false;
|
19717 |
|
19718 |
|
19719 |
|
19720 |
|
19721 |
|
19722 |
|
19723 |
|
19724 |
|
19725 |
|
19726 |
|
19727 |
|
19728 |
|
19729 |
|
19730 |
|
19731 |
|
19732 |
|
19733 | if (pattern.charAt(0) !== "{") {
|
19734 |
|
19735 | var prefix = null;
|
19736 |
|
19737 | for (var i = 0, l = pattern.length; i < l; i++) {
|
19738 | var c = pattern.charAt(i);
|
19739 |
|
19740 | if (c === "\\") {
|
19741 | escaping = !escaping;
|
19742 | } else if (c === "{" && !escaping) {
|
19743 | prefix = pattern.substr(0, i);
|
19744 | break;
|
19745 | }
|
19746 | }
|
19747 |
|
19748 |
|
19749 | if (prefix === null) {
|
19750 |
|
19751 | return [pattern];
|
19752 | }
|
19753 |
|
19754 | var tail = braceExpand(pattern.substr(i), options);
|
19755 | return tail.map(function (t) {
|
19756 | return prefix + t;
|
19757 | });
|
19758 | }
|
19759 |
|
19760 |
|
19761 |
|
19762 |
|
19763 |
|
19764 |
|
19765 |
|
19766 | var numset = pattern.match(/^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/);
|
19767 |
|
19768 | if (numset) {
|
19769 |
|
19770 | var suf = braceExpand(pattern.substr(numset[0].length), options),
|
19771 | start = +numset[1],
|
19772 | end = +numset[2],
|
19773 | inc = start > end ? -1 : 1,
|
19774 | set = [];
|
19775 |
|
19776 | for (var i = start; i != end + inc; i += inc) {
|
19777 |
|
19778 | for (var ii = 0, ll = suf.length; ii < ll; ii++) {
|
19779 | set.push(i + suf[ii]);
|
19780 | }
|
19781 | }
|
19782 |
|
19783 | return set;
|
19784 | } // ok, walk through the set
|
19785 | // We hope, somewhat optimistically, that there
|
19786 | // will be a } at the end.
|
19787 | // If the closing brace isn't found, then the pattern is
|
19788 | // interpreted as braceExpand("\\" + pattern) so that
|
19789 | // the leading \{ will be interpreted literally.
|
19790 |
|
19791 |
|
19792 | var i = 1
|
19793 | ,
|
19794 | depth = 1,
|
19795 | set = [],
|
19796 | member = "",
|
19797 | escaping = false;
|
19798 |
|
19799 | function addMember() {
|
19800 | set.push(member);
|
19801 | member = "";
|
19802 | } // console.error("Entering for")
|
19803 |
|
19804 |
|
19805 | FOR: for (i = 1, l = pattern.length; i < l; i++) {
|
19806 | var c = pattern.charAt(i);
|
19807 |
|
19808 | if (escaping) {
|
19809 | escaping = false;
|
19810 | member += "\\" + c;
|
19811 | } else {
|
19812 | switch (c) {
|
19813 | case "\\":
|
19814 | escaping = true;
|
19815 | continue;
|
19816 |
|
19817 | case "{":
|
19818 | depth++;
|
19819 | member += "{";
|
19820 | continue;
|
19821 |
|
19822 | case "}":
|
19823 | depth--;
|
19824 |
|
19825 | if (depth === 0) {
|
19826 | addMember();
|
19827 |
|
19828 | i++;
|
19829 | break FOR;
|
19830 | } else {
|
19831 | member += c;
|
19832 | continue;
|
19833 | }
|
19834 |
|
19835 | case ",":
|
19836 | if (depth === 1) {
|
19837 | addMember();
|
19838 | } else {
|
19839 | member += c;
|
19840 | }
|
19841 |
|
19842 | continue;
|
19843 |
|
19844 | default:
|
19845 | member += c;
|
19846 | continue;
|
19847 | }
|
19848 |
|
19849 | }
|
19850 |
|
19851 | }
|
19852 |
|
19853 |
|
19854 |
|
19855 |
|
19856 |
|
19857 | if (depth !== 0) {
|
19858 |
|
19859 | return braceExpand("\\" + pattern, options);
|
19860 | }
|
19861 |
|
19862 |
|
19863 |
|
19864 |
|
19865 | var suf = braceExpand(pattern.substr(i), options);
|
19866 |
|
19867 |
|
19868 | var addBraces = set.length === 1; // console.error("set pre-expanded", set)
|
19869 |
|
19870 | set = set.map(function (p) {
|
19871 | return braceExpand(p, options);
|
19872 | });
|
19873 |
|
19874 |
|
19875 |
|
19876 | set = set.reduce(function (l, r) {
|
19877 | return l.concat(r);
|
19878 | });
|
19879 |
|
19880 | if (addBraces) {
|
19881 | set = set.map(function (s) {
|
19882 | return "{" + s + "}";
|
19883 | });
|
19884 | }
|
19885 |
|
19886 |
|
19887 | var ret = [];
|
19888 |
|
19889 | for (var i = 0, l = set.length; i < l; i++) {
|
19890 | for (var ii = 0, ll = suf.length; ii < ll; ii++) {
|
19891 | ret.push(set[i] + suf[ii]);
|
19892 | }
|
19893 | }
|
19894 |
|
19895 | return ret;
|
19896 | } // parse a component of the expanded set.
|
19897 | // At this point, no pattern may contain "/" in it
|
19898 | // so we're going to return a 2d array, where each entry is the full
|
19899 | // pattern, split on '/', and then turned into a regular expression.
|
19900 | // A regexp is made at the end which joins each array with an
|
19901 | // escaped /, and another full one which joins each regexp with |.
|
19902 | //
|
19903 | // Following the lead of Bash 4.1, note that "**" only has special meaning
|
19904 | // when it is the *only* thing in a path portion. Otherwise, any series
|
19905 | // of * is equivalent to a single *. Globstar behavior is enabled by
|
19906 | // default, and can be disabled by setting options.noglobstar.
|
19907 |
|
19908 |
|
19909 | Minimatch.prototype.parse = parse;
|
19910 | var SUBPARSE = {};
|
19911 |
|
19912 | function parse(pattern, isSub) {
|
19913 | var options = this.options;
|
19914 |
|
19915 | if (!options.noglobstar && pattern === "**") return GLOBSTAR;
|
19916 | if (pattern === "") return "";
|
19917 | var re = "",
|
19918 | hasMagic = !!options.nocase,
|
19919 | escaping = false
|
19920 | ,
|
19921 | patternListStack = [],
|
19922 | plType,
|
19923 | stateChar,
|
19924 | inClass = false,
|
19925 | reClassStart = -1,
|
19926 | classStart = -1
|
19927 |
|
19928 | ,
|
19929 | patternStart = pattern.charAt(0) === "." ? ""
|
19930 |
|
19931 | : options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))" : "(?!\\.)";
|
19932 |
|
19933 | function clearStateChar() {
|
19934 | if (stateChar) {
|
19935 |
|
19936 |
|
19937 | switch (stateChar) {
|
19938 | case "*":
|
19939 | re += star;
|
19940 | hasMagic = true;
|
19941 | break;
|
19942 |
|
19943 | case "?":
|
19944 | re += qmark;
|
19945 | hasMagic = true;
|
19946 | break;
|
19947 |
|
19948 | default:
|
19949 | re += "\\" + stateChar;
|
19950 | break;
|
19951 | }
|
19952 |
|
19953 | stateChar = false;
|
19954 | }
|
19955 | }
|
19956 |
|
19957 | for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
|
19958 | if (options.debug) {
|
19959 | console.error("%s\t%s %s %j", pattern, i, re, c);
|
19960 | }
|
19961 |
|
19962 |
|
19963 | if (escaping && reSpecials[c]) {
|
19964 | re += "\\" + c;
|
19965 | escaping = false;
|
19966 | continue;
|
19967 | }
|
19968 |
|
19969 | switch (c) {
|
19970 | case "/":
|
19971 |
|
19972 |
|
19973 | return false;
|
19974 |
|
19975 | case "\\":
|
19976 | clearStateChar();
|
19977 | escaping = true;
|
19978 | continue;
|
19979 |
|
19980 |
|
19981 |
|
19982 | case "?":
|
19983 | case "*":
|
19984 | case "+":
|
19985 | case "@":
|
19986 | case "!":
|
19987 | if (options.debug) {
|
19988 | console.error("%s\t%s %s %j <-- stateChar", pattern, i, re, c);
|
19989 | }
|
19990 |
|
19991 |
|
19992 |
|
19993 | if (inClass) {
|
19994 | if (c === "!" && i === classStart + 1) c = "^";
|
19995 | re += c;
|
19996 | continue;
|
19997 | }
|
19998 |
|
19999 |
|
20000 |
|
20001 |
|
20002 | clearStateChar();
|
20003 | stateChar = c;
|
20004 |
|
20005 |
|
20006 |
|
20007 | if (options.noext) clearStateChar();
|
20008 | continue;
|
20009 |
|
20010 | case "(":
|
20011 | if (inClass) {
|
20012 | re += "(";
|
20013 | continue;
|
20014 | }
|
20015 |
|
20016 | if (!stateChar) {
|
20017 | re += "\\(";
|
20018 | continue;
|
20019 | }
|
20020 |
|
20021 | plType = stateChar;
|
20022 | patternListStack.push({
|
20023 | type: plType,
|
20024 | start: i - 1,
|
20025 | reStart: re.length
|
20026 | });
|
20027 |
|
20028 | re += stateChar === "!" ? "(?:(?!" : "(?:";
|
20029 | stateChar = false;
|
20030 | continue;
|
20031 |
|
20032 | case ")":
|
20033 | if (inClass || !patternListStack.length) {
|
20034 | re += "\\)";
|
20035 | continue;
|
20036 | }
|
20037 |
|
20038 | hasMagic = true;
|
20039 | re += ")";
|
20040 | plType = patternListStack.pop().type;
|
20041 |
|
20042 |
|
20043 | switch (plType) {
|
20044 | case "!":
|
20045 | re += "[^/]*?)";
|
20046 | break;
|
20047 |
|
20048 | case "?":
|
20049 | case "+":
|
20050 | case "*":
|
20051 | re += plType;
|
20052 |
|
20053 | }
|
20054 |
|
20055 | continue;
|
20056 |
|
20057 | case "|":
|
20058 | if (inClass || !patternListStack.length || escaping) {
|
20059 | re += "\\|";
|
20060 | escaping = false;
|
20061 | continue;
|
20062 | }
|
20063 |
|
20064 | re += "|";
|
20065 | continue;
|
20066 |
|
20067 |
|
20068 | case "[":
|
20069 |
|
20070 | clearStateChar();
|
20071 |
|
20072 | if (inClass) {
|
20073 | re += "\\" + c;
|
20074 | continue;
|
20075 | }
|
20076 |
|
20077 | inClass = true;
|
20078 | classStart = i;
|
20079 | reClassStart = re.length;
|
20080 | re += c;
|
20081 | continue;
|
20082 |
|
20083 | case "]":
|
20084 |
|
20085 |
|
20086 |
|
20087 |
|
20088 | if (i === classStart + 1 || !inClass) {
|
20089 | re += "\\" + c;
|
20090 | escaping = false;
|
20091 | continue;
|
20092 | }
|
20093 |
|
20094 |
|
20095 | hasMagic = true;
|
20096 | inClass = false;
|
20097 | re += c;
|
20098 | continue;
|
20099 |
|
20100 | default:
|
20101 |
|
20102 | clearStateChar();
|
20103 |
|
20104 | if (escaping) {
|
20105 |
|
20106 | escaping = false;
|
20107 | } else if (reSpecials[c] && !(c === "^" && inClass)) {
|
20108 | re += "\\";
|
20109 | }
|
20110 |
|
20111 | re += c;
|
20112 | }
|
20113 |
|
20114 | }
|
20115 |
|
20116 |
|
20117 |
|
20118 |
|
20119 | if (inClass) {
|
20120 |
|
20121 |
|
20122 |
|
20123 |
|
20124 | var cs = pattern.substr(classStart + 1),
|
20125 | sp = this.parse(cs, SUBPARSE);
|
20126 | re = re.substr(0, reClassStart) + "\\[" + sp[0];
|
20127 | hasMagic = hasMagic || sp[1];
|
20128 | }
|
20129 |
|
20130 |
|
20131 |
|
20132 |
|
20133 |
|
20134 |
|
20135 |
|
20136 | var pl;
|
20137 |
|
20138 | while (pl = patternListStack.pop()) {
|
20139 | var tail = re.slice(pl.reStart + 3);
|
20140 |
|
20141 | tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) {
|
20142 | if (!$2) {
|
20143 |
|
20144 | $2 = "\\";
|
20145 | }
|
20146 |
|
20147 |
|
20148 |
|
20149 |
|
20150 |
|
20151 |
|
20152 |
|
20153 | return $1 + $1 + $2 + "|";
|
20154 | });
|
20155 |
|
20156 | var t = pl.type === "*" ? star : pl.type === "?" ? qmark : "\\" + pl.type;
|
20157 | hasMagic = true;
|
20158 | re = re.slice(0, pl.reStart) + t + "\\(" + tail;
|
20159 | }
|
20160 |
|
20161 |
|
20162 | clearStateChar();
|
20163 |
|
20164 | if (escaping) {
|
20165 |
|
20166 | re += "\\\\";
|
20167 | }
|
20168 |
|
20169 |
|
20170 |
|
20171 | var addPatternStart = false;
|
20172 |
|
20173 | switch (re.charAt(0)) {
|
20174 | case ".":
|
20175 | case "[":
|
20176 | case "(":
|
20177 | addPatternStart = true;
|
20178 | }
|
20179 |
|
20180 |
|
20181 |
|
20182 |
|
20183 | if (re !== "" && hasMagic) re = "(?=.)" + re;
|
20184 | if (addPatternStart) re = patternStart + re;
|
20185 |
|
20186 | if (isSub === SUBPARSE) {
|
20187 | return [re, hasMagic];
|
20188 | }
|
20189 |
|
20190 |
|
20191 |
|
20192 |
|
20193 | if (!hasMagic) {
|
20194 | return globUnescape(pattern);
|
20195 | }
|
20196 |
|
20197 | var flags = options.nocase ? "i" : "",
|
20198 | regExp = new RegExp("^" + re + "$", flags);
|
20199 | regExp._glob = pattern;
|
20200 | regExp._src = re;
|
20201 | return regExp;
|
20202 | }
|
20203 |
|
20204 | minimatch.makeRe = function (pattern, options) {
|
20205 | return new Minimatch(pattern, options || {}).makeRe();
|
20206 | };
|
20207 |
|
20208 | Minimatch.prototype.makeRe = makeRe;
|
20209 |
|
20210 | function makeRe() {
|
20211 | if (this.regexp || this.regexp === false) return this.regexp;
|
20212 |
|
20213 |
|
20214 |
|
20215 |
|
20216 |
|
20217 |
|
20218 | var set = this.set;
|
20219 | if (!set.length) return this.regexp = false;
|
20220 | var options = this.options;
|
20221 | var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot,
|
20222 | flags = options.nocase ? "i" : "";
|
20223 | var re = set.map(function (pattern) {
|
20224 | return pattern.map(function (p) {
|
20225 | return p === GLOBSTAR ? twoStar : typeof p === "string" ? regExpEscape(p) : p._src;
|
20226 | }).join("\\\/");
|
20227 | }).join("|");
|
20228 |
|
20229 |
|
20230 | re = "^(?:" + re + ")$";
|
20231 |
|
20232 | if (this.negate) re = "^(?!" + re + ").*$";
|
20233 |
|
20234 | try {
|
20235 | return this.regexp = new RegExp(re, flags);
|
20236 | } catch (ex) {
|
20237 | return this.regexp = false;
|
20238 | }
|
20239 | }
|
20240 |
|
20241 | minimatch.match = function (list, pattern, options) {
|
20242 | var mm = new Minimatch(pattern, options);
|
20243 | list = list.filter(function (f) {
|
20244 | return mm.match(f);
|
20245 | });
|
20246 |
|
20247 | if (options.nonull && !list.length) {
|
20248 | list.push(pattern);
|
20249 | }
|
20250 |
|
20251 | return list;
|
20252 | };
|
20253 |
|
20254 | Minimatch.prototype.match = match;
|
20255 |
|
20256 | function match(f, partial) {
|
20257 |
|
20258 |
|
20259 |
|
20260 | if (this.comment) return false;
|
20261 | if (this.empty) return f === "";
|
20262 | if (f === "/" && partial) return true;
|
20263 | var options = this.options;
|
20264 |
|
20265 |
|
20266 | if (platform === "win32") {
|
20267 | f = f.split("\\").join("/");
|
20268 | }
|
20269 |
|
20270 |
|
20271 | f = f.split(slashSplit);
|
20272 |
|
20273 | if (options.debug) {
|
20274 | console.error(this.pattern, "split", f);
|
20275 | }
|
20276 |
|
20277 |
|
20278 |
|
20279 |
|
20280 |
|
20281 | var set = this.set; // console.error(this.pattern, "set", set)
|
20282 |
|
20283 | for (var i = 0, l = set.length; i < l; i++) {
|
20284 | var pattern = set[i];
|
20285 | var hit = this.matchOne(f, pattern, partial);
|
20286 |
|
20287 | if (hit) {
|
20288 | if (options.flipNegate) return true;
|
20289 | return !this.negate;
|
20290 | }
|
20291 | }
|
20292 |
|
20293 |
|
20294 |
|
20295 | if (options.flipNegate) return false;
|
20296 | return this.negate;
|
20297 | }
|
20298 |
|
20299 |
|
20300 |
|
20301 |
|
20302 |
|
20303 |
|
20304 | Minimatch.prototype.matchOne = function (file, pattern, partial) {
|
20305 | var options = this.options;
|
20306 |
|
20307 | if (options.debug) {
|
20308 | console.error("matchOne", {
|
20309 | "this": this,
|
20310 | file: file,
|
20311 | pattern: pattern
|
20312 | });
|
20313 | }
|
20314 |
|
20315 | if (options.matchBase && pattern.length === 1) {
|
20316 | file = path$2.basename(file.join("/")).split("/");
|
20317 | }
|
20318 |
|
20319 | if (options.debug) {
|
20320 | console.error("matchOne", file.length, pattern.length);
|
20321 | }
|
20322 |
|
20323 | for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
20324 | if (options.debug) {
|
20325 | console.error("matchOne loop");
|
20326 | }
|
20327 |
|
20328 | var p = pattern[pi],
|
20329 | f = file[fi];
|
20330 |
|
20331 | if (options.debug) {
|
20332 | console.error(pattern, p, f);
|
20333 | }
|
20334 |
|
20335 |
|
20336 |
|
20337 | if (p === false) return false;
|
20338 |
|
20339 | if (p === GLOBSTAR) {
|
20340 | if (options.debug) console.error('GLOBSTAR', [pattern, p, f]);
|
20341 |
|
20342 |
|
20343 |
|
20344 |
|
20345 |
|
20346 |
|
20347 |
|
20348 |
|
20349 |
|
20350 |
|
20351 |
|
20352 |
|
20353 |
|
20354 |
|
20355 |
|
20356 |
|
20357 |
|
20358 |
|
20359 |
|
20360 |
|
20361 |
|
20362 |
|
20363 | var fr = fi,
|
20364 | pr = pi + 1;
|
20365 |
|
20366 | if (pr === pl) {
|
20367 | if (options.debug) console.error('** at the end');
|
20368 |
|
20369 |
|
20370 |
|
20371 |
|
20372 |
|
20373 |
|
20374 | for (; fi < fl; fi++) {
|
20375 | if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".") return false;
|
20376 | }
|
20377 |
|
20378 | return true;
|
20379 | }
|
20380 |
|
20381 |
|
20382 | WHILE: while (fr < fl) {
|
20383 | var swallowee = file[fr];
|
20384 |
|
20385 | if (options.debug) {
|
20386 | console.error('\nglobstar while', file, fr, pattern, pr, swallowee);
|
20387 | }
|
20388 |
|
20389 |
|
20390 | if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
20391 | if (options.debug) console.error('globstar found match!', fr, fl, swallowee);
|
20392 |
|
20393 | return true;
|
20394 | } else {
|
20395 |
|
20396 |
|
20397 | if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
|
20398 | if (options.debug) console.error("dot detected!", file, fr, pattern, pr);
|
20399 | break WHILE;
|
20400 | }
|
20401 |
|
20402 |
|
20403 | if (options.debug) console.error('globstar swallow a segment, and continue');
|
20404 | fr++;
|
20405 | }
|
20406 | }
|
20407 |
|
20408 |
|
20409 |
|
20410 |
|
20411 | if (partial) {
|
20412 |
|
20413 |
|
20414 | if (fr === fl) return true;
|
20415 | }
|
20416 |
|
20417 | return false;
|
20418 | }
|
20419 |
|
20420 |
|
20421 |
|
20422 |
|
20423 | var hit;
|
20424 |
|
20425 | if (typeof p === "string") {
|
20426 | if (options.nocase) {
|
20427 | hit = f.toLowerCase() === p.toLowerCase();
|
20428 | } else {
|
20429 | hit = f === p;
|
20430 | }
|
20431 |
|
20432 | if (options.debug) {
|
20433 | console.error("string match", p, f, hit);
|
20434 | }
|
20435 | } else {
|
20436 | hit = f.match(p);
|
20437 |
|
20438 | if (options.debug) {
|
20439 | console.error("pattern match", p, f, hit);
|
20440 | }
|
20441 | }
|
20442 |
|
20443 | if (!hit) return false;
|
20444 | }
|
20445 |
|
20446 |
|
20447 |
|
20448 |
|
20449 |
|
20450 |
|
20451 |
|
20452 |
|
20453 |
|
20454 |
|
20455 |
|
20456 |
|
20457 | if (fi === fl && pi === pl) {
|
20458 |
|
20459 |
|
20460 | return true;
|
20461 | } else if (fi === fl) {
|
20462 |
|
20463 |
|
20464 |
|
20465 | return partial;
|
20466 | } else if (pi === pl) {
|
20467 |
|
20468 |
|
20469 |
|
20470 |
|
20471 | var emptyFileEnd = fi === fl - 1 && file[fi] === "";
|
20472 | return emptyFileEnd;
|
20473 | }
|
20474 |
|
20475 |
|
20476 | throw new Error("wtf?");
|
20477 | };
|
20478 |
|
20479 |
|
20480 | function globUnescape(s) {
|
20481 | return s.replace(/\\(.)/g, "$1");
|
20482 | }
|
20483 |
|
20484 | function regExpEscape(s) {
|
20485 | return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
20486 | }
|
20487 | });
|
20488 | var fnmatch_1 = fnmatch.minimatch;
|
20489 |
|
20490 | var ini = createCommonjsModule(function (module, exports) {
|
20491 |
|
20492 | var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
20493 | return new (P || (P = Promise))(function (resolve, reject) {
|
20494 | function fulfilled(value) {
|
20495 | try {
|
20496 | step(generator.next(value));
|
20497 | } catch (e) {
|
20498 | reject(e);
|
20499 | }
|
20500 | }
|
20501 |
|
20502 | function rejected(value) {
|
20503 | try {
|
20504 | step(generator["throw"](value));
|
20505 | } catch (e) {
|
20506 | reject(e);
|
20507 | }
|
20508 | }
|
20509 |
|
20510 | function step(result) {
|
20511 | result.done ? resolve(result.value) : new P(function (resolve) {
|
20512 | resolve(result.value);
|
20513 | }).then(fulfilled, rejected);
|
20514 | }
|
20515 |
|
20516 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
20517 | });
|
20518 | };
|
20519 |
|
20520 | var __generator = this && this.__generator || function (thisArg, body) {
|
20521 | var _ = {
|
20522 | label: 0,
|
20523 | sent: function () {
|
20524 | if (t[0] & 1) throw t[1];
|
20525 | return t[1];
|
20526 | },
|
20527 | trys: [],
|
20528 | ops: []
|
20529 | },
|
20530 | f,
|
20531 | y,
|
20532 | t,
|
20533 | g;
|
20534 | return g = {
|
20535 | next: verb(0),
|
20536 | "throw": verb(1),
|
20537 | "return": verb(2)
|
20538 | }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
20539 | return this;
|
20540 | }), g;
|
20541 |
|
20542 | function verb(n) {
|
20543 | return function (v) {
|
20544 | return step([n, v]);
|
20545 | };
|
20546 | }
|
20547 |
|
20548 | function step(op) {
|
20549 | if (f) throw new TypeError("Generator is already executing.");
|
20550 |
|
20551 | while (_) try {
|
20552 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
20553 | if (y = 0, t) op = [op[0] & 2, t.value];
|
20554 |
|
20555 | switch (op[0]) {
|
20556 | case 0:
|
20557 | case 1:
|
20558 | t = op;
|
20559 | break;
|
20560 |
|
20561 | case 4:
|
20562 | _.label++;
|
20563 | return {
|
20564 | value: op[1],
|
20565 | done: false
|
20566 | };
|
20567 |
|
20568 | case 5:
|
20569 | _.label++;
|
20570 | y = op[1];
|
20571 | op = [0];
|
20572 | continue;
|
20573 |
|
20574 | case 7:
|
20575 | op = _.ops.pop();
|
20576 |
|
20577 | _.trys.pop();
|
20578 |
|
20579 | continue;
|
20580 |
|
20581 | default:
|
20582 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
20583 | _ = 0;
|
20584 | continue;
|
20585 | }
|
20586 |
|
20587 | if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
20588 | _.label = op[1];
|
20589 | break;
|
20590 | }
|
20591 |
|
20592 | if (op[0] === 6 && _.label < t[1]) {
|
20593 | _.label = t[1];
|
20594 | t = op;
|
20595 | break;
|
20596 | }
|
20597 |
|
20598 | if (t && _.label < t[2]) {
|
20599 | _.label = t[2];
|
20600 |
|
20601 | _.ops.push(op);
|
20602 |
|
20603 | break;
|
20604 | }
|
20605 |
|
20606 | if (t[2]) _.ops.pop();
|
20607 |
|
20608 | _.trys.pop();
|
20609 |
|
20610 | continue;
|
20611 | }
|
20612 |
|
20613 | op = body.call(thisArg, _);
|
20614 | } catch (e) {
|
20615 | op = [6, e];
|
20616 | y = 0;
|
20617 | } finally {
|
20618 | f = t = 0;
|
20619 | }
|
20620 |
|
20621 | if (op[0] & 5) throw op[1];
|
20622 | return {
|
20623 | value: op[0] ? op[1] : void 0,
|
20624 | done: true
|
20625 | };
|
20626 | }
|
20627 | };
|
20628 |
|
20629 | var __importStar = this && this.__importStar || function (mod) {
|
20630 | if (mod && mod.__esModule) return mod;
|
20631 | var result = {};
|
20632 | if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
20633 | result["default"] = mod;
|
20634 | return result;
|
20635 | };
|
20636 |
|
20637 | Object.defineProperty(exports, "__esModule", {
|
20638 | value: true
|
20639 | });
|
20640 |
|
20641 | var fs = __importStar(fs$3);
|
20642 | |
20643 |
|
20644 |
|
20645 |
|
20646 |
|
20647 |
|
20648 |
|
20649 |
|
20650 | var regex = {
|
20651 | section: /^\s*\[(([^#;]|\\#|\\;)+)\]\s*([#;].*)?$/,
|
20652 | param: /^\s*([\w\.\-\_]+)\s*[=:]\s*(.*?)\s*([#;].*)?$/,
|
20653 | comment: /^\s*[#;].*$/
|
20654 | };
|
20655 | |
20656 |
|
20657 |
|
20658 |
|
20659 |
|
20660 | function parse(file) {
|
20661 | return __awaiter(this, void 0, void 0, function () {
|
20662 | return __generator(this, function (_a) {
|
20663 | return [2
|
20664 |
|
20665 | , new Promise(function (resolve, reject) {
|
20666 | fs.readFile(file, 'utf8', function (err, data) {
|
20667 | if (err) {
|
20668 | reject(err);
|
20669 | return;
|
20670 | }
|
20671 |
|
20672 | resolve(parseString(data));
|
20673 | });
|
20674 | })];
|
20675 | });
|
20676 | });
|
20677 | }
|
20678 |
|
20679 | exports.parse = parse;
|
20680 |
|
20681 | function parseSync(file) {
|
20682 | return parseString(fs.readFileSync(file, 'utf8'));
|
20683 | }
|
20684 |
|
20685 | exports.parseSync = parseSync;
|
20686 |
|
20687 | function parseString(data) {
|
20688 | var sectionBody = {};
|
20689 | var sectionName = null;
|
20690 | var value = [[sectionName, sectionBody]];
|
20691 | var lines = data.split(/\r\n|\r|\n/);
|
20692 | lines.forEach(function (line) {
|
20693 | var match;
|
20694 |
|
20695 | if (regex.comment.test(line)) {
|
20696 | return;
|
20697 | }
|
20698 |
|
20699 | if (regex.param.test(line)) {
|
20700 | match = line.match(regex.param);
|
20701 | sectionBody[match[1]] = match[2];
|
20702 | } else if (regex.section.test(line)) {
|
20703 | match = line.match(regex.section);
|
20704 | sectionName = match[1];
|
20705 | sectionBody = {};
|
20706 | value.push([sectionName, sectionBody]);
|
20707 | }
|
20708 | });
|
20709 | return value;
|
20710 | }
|
20711 |
|
20712 | exports.parseString = parseString;
|
20713 | });
|
20714 | unwrapExports(ini);
|
20715 | var ini_1 = ini.parse;
|
20716 | var ini_2 = ini.parseSync;
|
20717 | var ini_3 = ini.parseString;
|
20718 |
|
20719 | var name$1 = "editorconfig";
|
20720 | var version$1 = "0.15.3";
|
20721 | var description$1 = "EditorConfig File Locator and Interpreter for Node.js";
|
20722 | var keywords = [
|
20723 | "editorconfig",
|
20724 | "core"
|
20725 | ];
|
20726 | var main$1 = "src/index.js";
|
20727 | var contributors = [
|
20728 | "Hong Xu (topbug.net)",
|
20729 | "Jed Mao (https://github.com/jedmao/)",
|
20730 | "Trey Hunner (http://treyhunner.com)"
|
20731 | ];
|
20732 | var directories = {
|
20733 | bin: "./bin",
|
20734 | lib: "./lib"
|
20735 | };
|
20736 | var scripts$1 = {
|
20737 | clean: "rimraf dist",
|
20738 | prebuild: "npm run clean",
|
20739 | build: "tsc",
|
20740 | pretest: "npm run lint && npm run build && npm run copy && cmake .",
|
20741 | test: "ctest .",
|
20742 | "pretest:ci": "npm run pretest",
|
20743 | "test:ci": "ctest -VV --output-on-failure .",
|
20744 | lint: "npm run eclint && npm run tslint",
|
20745 | eclint: "eclint check --indent_size ignore \"src/**\"",
|
20746 | tslint: "tslint --project tsconfig.json --exclude package.json",
|
20747 | copy: "cpy .npmignore LICENSE README.md CHANGELOG.md dist && cpy bin/* dist/bin && cpy src/lib/fnmatch*.* dist/src/lib",
|
20748 | prepub: "npm run lint && npm run build && npm run copy",
|
20749 | pub: "npm publish ./dist"
|
20750 | };
|
20751 | var repository$1 = {
|
20752 | type: "git",
|
20753 | url: "git://github.com/editorconfig/editorconfig-core-js.git"
|
20754 | };
|
20755 | var bugs = "https://github.com/editorconfig/editorconfig-core-js/issues";
|
20756 | var author$1 = "EditorConfig Team";
|
20757 | var license$1 = "MIT";
|
20758 | var dependencies$1 = {
|
20759 | commander: "^2.19.0",
|
20760 | "lru-cache": "^4.1.5",
|
20761 | semver: "^5.6.0",
|
20762 | sigmund: "^1.0.1"
|
20763 | };
|
20764 | var devDependencies$1 = {
|
20765 | "@types/mocha": "^5.2.6",
|
20766 | "@types/node": "^10.12.29",
|
20767 | "@types/semver": "^5.5.0",
|
20768 | "cpy-cli": "^2.0.0",
|
20769 | eclint: "^2.8.1",
|
20770 | mocha: "^5.2.0",
|
20771 | rimraf: "^2.6.3",
|
20772 | should: "^13.2.3",
|
20773 | tslint: "^5.13.1",
|
20774 | typescript: "^3.3.3333"
|
20775 | };
|
20776 | var _package$2 = {
|
20777 | name: name$1,
|
20778 | version: version$1,
|
20779 | description: description$1,
|
20780 | keywords: keywords,
|
20781 | main: main$1,
|
20782 | contributors: contributors,
|
20783 | directories: directories,
|
20784 | scripts: scripts$1,
|
20785 | repository: repository$1,
|
20786 | bugs: bugs,
|
20787 | author: author$1,
|
20788 | license: license$1,
|
20789 | dependencies: dependencies$1,
|
20790 | devDependencies: devDependencies$1
|
20791 | };
|
20792 |
|
20793 | var _package$3 = Object.freeze({
|
20794 | __proto__: null,
|
20795 | name: name$1,
|
20796 | version: version$1,
|
20797 | description: description$1,
|
20798 | keywords: keywords,
|
20799 | main: main$1,
|
20800 | contributors: contributors,
|
20801 | directories: directories,
|
20802 | scripts: scripts$1,
|
20803 | repository: repository$1,
|
20804 | bugs: bugs,
|
20805 | author: author$1,
|
20806 | license: license$1,
|
20807 | dependencies: dependencies$1,
|
20808 | devDependencies: devDependencies$1,
|
20809 | 'default': _package$2
|
20810 | });
|
20811 |
|
20812 | var require$$4 = getCjsExportFromNamespace(_package$3);
|
20813 |
|
20814 | var src = createCommonjsModule(function (module, exports) {
|
20815 |
|
20816 | var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
20817 | return new (P || (P = Promise))(function (resolve, reject) {
|
20818 | function fulfilled(value) {
|
20819 | try {
|
20820 | step(generator.next(value));
|
20821 | } catch (e) {
|
20822 | reject(e);
|
20823 | }
|
20824 | }
|
20825 |
|
20826 | function rejected(value) {
|
20827 | try {
|
20828 | step(generator["throw"](value));
|
20829 | } catch (e) {
|
20830 | reject(e);
|
20831 | }
|
20832 | }
|
20833 |
|
20834 | function step(result) {
|
20835 | result.done ? resolve(result.value) : new P(function (resolve) {
|
20836 | resolve(result.value);
|
20837 | }).then(fulfilled, rejected);
|
20838 | }
|
20839 |
|
20840 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
20841 | });
|
20842 | };
|
20843 |
|
20844 | var __generator = this && this.__generator || function (thisArg, body) {
|
20845 | var _ = {
|
20846 | label: 0,
|
20847 | sent: function () {
|
20848 | if (t[0] & 1) throw t[1];
|
20849 | return t[1];
|
20850 | },
|
20851 | trys: [],
|
20852 | ops: []
|
20853 | },
|
20854 | f,
|
20855 | y,
|
20856 | t,
|
20857 | g;
|
20858 | return g = {
|
20859 | next: verb(0),
|
20860 | "throw": verb(1),
|
20861 | "return": verb(2)
|
20862 | }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
20863 | return this;
|
20864 | }), g;
|
20865 |
|
20866 | function verb(n) {
|
20867 | return function (v) {
|
20868 | return step([n, v]);
|
20869 | };
|
20870 | }
|
20871 |
|
20872 | function step(op) {
|
20873 | if (f) throw new TypeError("Generator is already executing.");
|
20874 |
|
20875 | while (_) try {
|
20876 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
20877 | if (y = 0, t) op = [op[0] & 2, t.value];
|
20878 |
|
20879 | switch (op[0]) {
|
20880 | case 0:
|
20881 | case 1:
|
20882 | t = op;
|
20883 | break;
|
20884 |
|
20885 | case 4:
|
20886 | _.label++;
|
20887 | return {
|
20888 | value: op[1],
|
20889 | done: false
|
20890 | };
|
20891 |
|
20892 | case 5:
|
20893 | _.label++;
|
20894 | y = op[1];
|
20895 | op = [0];
|
20896 | continue;
|
20897 |
|
20898 | case 7:
|
20899 | op = _.ops.pop();
|
20900 |
|
20901 | _.trys.pop();
|
20902 |
|
20903 | continue;
|
20904 |
|
20905 | default:
|
20906 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
20907 | _ = 0;
|
20908 | continue;
|
20909 | }
|
20910 |
|
20911 | if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
20912 | _.label = op[1];
|
20913 | break;
|
20914 | }
|
20915 |
|
20916 | if (op[0] === 6 && _.label < t[1]) {
|
20917 | _.label = t[1];
|
20918 | t = op;
|
20919 | break;
|
20920 | }
|
20921 |
|
20922 | if (t && _.label < t[2]) {
|
20923 | _.label = t[2];
|
20924 |
|
20925 | _.ops.push(op);
|
20926 |
|
20927 | break;
|
20928 | }
|
20929 |
|
20930 | if (t[2]) _.ops.pop();
|
20931 |
|
20932 | _.trys.pop();
|
20933 |
|
20934 | continue;
|
20935 | }
|
20936 |
|
20937 | op = body.call(thisArg, _);
|
20938 | } catch (e) {
|
20939 | op = [6, e];
|
20940 | y = 0;
|
20941 | } finally {
|
20942 | f = t = 0;
|
20943 | }
|
20944 |
|
20945 | if (op[0] & 5) throw op[1];
|
20946 | return {
|
20947 | value: op[0] ? op[1] : void 0,
|
20948 | done: true
|
20949 | };
|
20950 | }
|
20951 | };
|
20952 |
|
20953 | var __importStar = this && this.__importStar || function (mod) {
|
20954 | if (mod && mod.__esModule) return mod;
|
20955 | var result = {};
|
20956 | if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
20957 | result["default"] = mod;
|
20958 | return result;
|
20959 | };
|
20960 |
|
20961 | var __importDefault = this && this.__importDefault || function (mod) {
|
20962 | return mod && mod.__esModule ? mod : {
|
20963 | "default": mod
|
20964 | };
|
20965 | };
|
20966 |
|
20967 | Object.defineProperty(exports, "__esModule", {
|
20968 | value: true
|
20969 | });
|
20970 |
|
20971 | var fs = __importStar(fs$3);
|
20972 |
|
20973 | var path = __importStar(path$2);
|
20974 |
|
20975 | var semver = __importStar(semver$2);
|
20976 |
|
20977 | var fnmatch_1 = __importDefault(fnmatch);
|
20978 |
|
20979 | exports.parseString = ini.parseString;
|
20980 |
|
20981 | var package_json_1 = __importDefault(require$$4);
|
20982 |
|
20983 | var knownProps = {
|
20984 | end_of_line: true,
|
20985 | indent_style: true,
|
20986 | indent_size: true,
|
20987 | insert_final_newline: true,
|
20988 | trim_trailing_whitespace: true,
|
20989 | charset: true
|
20990 | };
|
20991 |
|
20992 | function fnmatch$1(filepath, glob) {
|
20993 | var matchOptions = {
|
20994 | matchBase: true,
|
20995 | dot: true,
|
20996 | noext: true
|
20997 | };
|
20998 | glob = glob.replace(/\*\*/g, '{*,**/**/**}');
|
20999 | return fnmatch_1.default(filepath, glob, matchOptions);
|
21000 | }
|
21001 |
|
21002 | function getConfigFileNames(filepath, options) {
|
21003 | var paths = [];
|
21004 |
|
21005 | do {
|
21006 | filepath = path.dirname(filepath);
|
21007 | paths.push(path.join(filepath, options.config));
|
21008 | } while (filepath !== options.root);
|
21009 |
|
21010 | return paths;
|
21011 | }
|
21012 |
|
21013 | function processMatches(matches, version) {
|
21014 |
|
21015 |
|
21016 | if ('indent_style' in matches && matches.indent_style === 'tab' && !('indent_size' in matches) && semver.gte(version, '0.10.0')) {
|
21017 | matches.indent_size = 'tab';
|
21018 | }
|
21019 |
|
21020 |
|
21021 |
|
21022 | if ('indent_size' in matches && !('tab_width' in matches) && matches.indent_size !== 'tab') {
|
21023 | matches.tab_width = matches.indent_size;
|
21024 | }
|
21025 |
|
21026 |
|
21027 | if ('indent_size' in matches && 'tab_width' in matches && matches.indent_size === 'tab') {
|
21028 | matches.indent_size = matches.tab_width;
|
21029 | }
|
21030 |
|
21031 | return matches;
|
21032 | }
|
21033 |
|
21034 | function processOptions(options, filepath) {
|
21035 | if (options === void 0) {
|
21036 | options = {};
|
21037 | }
|
21038 |
|
21039 | return {
|
21040 | config: options.config || '.editorconfig',
|
21041 | version: options.version || package_json_1.default.version,
|
21042 | root: path.resolve(options.root || path.parse(filepath).root)
|
21043 | };
|
21044 | }
|
21045 |
|
21046 | function buildFullGlob(pathPrefix, glob) {
|
21047 | switch (glob.indexOf('/')) {
|
21048 | case -1:
|
21049 | glob = '**/' + glob;
|
21050 | break;
|
21051 |
|
21052 | case 0:
|
21053 | glob = glob.substring(1);
|
21054 | break;
|
21055 | }
|
21056 |
|
21057 | return path.join(pathPrefix, glob);
|
21058 | }
|
21059 |
|
21060 | function extendProps(props, options) {
|
21061 | if (props === void 0) {
|
21062 | props = {};
|
21063 | }
|
21064 |
|
21065 | if (options === void 0) {
|
21066 | options = {};
|
21067 | }
|
21068 |
|
21069 | for (var key in options) {
|
21070 | if (options.hasOwnProperty(key)) {
|
21071 | var value = options[key];
|
21072 | var key2 = key.toLowerCase();
|
21073 | var value2 = value;
|
21074 |
|
21075 | if (knownProps[key2]) {
|
21076 | value2 = value.toLowerCase();
|
21077 | }
|
21078 |
|
21079 | try {
|
21080 | value2 = JSON.parse(value);
|
21081 | } catch (e) {}
|
21082 |
|
21083 | if (typeof value === 'undefined' || value === null) {
|
21084 |
|
21085 |
|
21086 | value2 = String(value);
|
21087 | }
|
21088 |
|
21089 | props[key2] = value2;
|
21090 | }
|
21091 | }
|
21092 |
|
21093 | return props;
|
21094 | }
|
21095 |
|
21096 | function parseFromConfigs(configs, filepath, options) {
|
21097 | return processMatches(configs.reverse().reduce(function (matches, file) {
|
21098 | var pathPrefix = path.dirname(file.name);
|
21099 | file.contents.forEach(function (section) {
|
21100 | var glob = section[0];
|
21101 | var options2 = section[1];
|
21102 |
|
21103 | if (!glob) {
|
21104 | return;
|
21105 | }
|
21106 |
|
21107 | var fullGlob = buildFullGlob(pathPrefix, glob);
|
21108 |
|
21109 | if (!fnmatch$1(filepath, fullGlob)) {
|
21110 | return;
|
21111 | }
|
21112 |
|
21113 | matches = extendProps(matches, options2);
|
21114 | });
|
21115 | return matches;
|
21116 | }, {}), options.version);
|
21117 | }
|
21118 |
|
21119 | function getConfigsForFiles(files) {
|
21120 | var configs = [];
|
21121 |
|
21122 | for (var i in files) {
|
21123 | if (files.hasOwnProperty(i)) {
|
21124 | var file = files[i];
|
21125 | var contents = ini.parseString(file.contents);
|
21126 | configs.push({
|
21127 | name: file.name,
|
21128 | contents: contents
|
21129 | });
|
21130 |
|
21131 | if ((contents[0][1].root || '').toLowerCase() === 'true') {
|
21132 | break;
|
21133 | }
|
21134 | }
|
21135 | }
|
21136 |
|
21137 | return configs;
|
21138 | }
|
21139 |
|
21140 | function readConfigFiles(filepaths) {
|
21141 | return __awaiter(this, void 0, void 0, function () {
|
21142 | return __generator(this, function (_a) {
|
21143 | return [2
|
21144 |
|
21145 | , Promise.all(filepaths.map(function (name) {
|
21146 | return new Promise(function (resolve) {
|
21147 | fs.readFile(name, 'utf8', function (err, data) {
|
21148 | resolve({
|
21149 | name: name,
|
21150 | contents: err ? '' : data
|
21151 | });
|
21152 | });
|
21153 | });
|
21154 | }))];
|
21155 | });
|
21156 | });
|
21157 | }
|
21158 |
|
21159 | function readConfigFilesSync(filepaths) {
|
21160 | var files = [];
|
21161 | var file;
|
21162 | filepaths.forEach(function (filepath) {
|
21163 | try {
|
21164 | file = fs.readFileSync(filepath, 'utf8');
|
21165 | } catch (e) {
|
21166 | file = '';
|
21167 | }
|
21168 |
|
21169 | files.push({
|
21170 | name: filepath,
|
21171 | contents: file
|
21172 | });
|
21173 | });
|
21174 | return files;
|
21175 | }
|
21176 |
|
21177 | function opts(filepath, options) {
|
21178 | if (options === void 0) {
|
21179 | options = {};
|
21180 | }
|
21181 |
|
21182 | var resolvedFilePath = path.resolve(filepath);
|
21183 | return [resolvedFilePath, processOptions(options, resolvedFilePath)];
|
21184 | }
|
21185 |
|
21186 | function parseFromFiles(filepath, files, options) {
|
21187 | if (options === void 0) {
|
21188 | options = {};
|
21189 | }
|
21190 |
|
21191 | return __awaiter(this, void 0, void 0, function () {
|
21192 | var _a, resolvedFilePath, processedOptions;
|
21193 |
|
21194 | return __generator(this, function (_b) {
|
21195 | _a = opts(filepath, options), resolvedFilePath = _a[0], processedOptions = _a[1];
|
21196 | return [2
|
21197 |
|
21198 | , files.then(getConfigsForFiles).then(function (configs) {
|
21199 | return parseFromConfigs(configs, resolvedFilePath, processedOptions);
|
21200 | })];
|
21201 | });
|
21202 | });
|
21203 | }
|
21204 |
|
21205 | exports.parseFromFiles = parseFromFiles;
|
21206 |
|
21207 | function parseFromFilesSync(filepath, files, options) {
|
21208 | if (options === void 0) {
|
21209 | options = {};
|
21210 | }
|
21211 |
|
21212 | var _a = opts(filepath, options),
|
21213 | resolvedFilePath = _a[0],
|
21214 | processedOptions = _a[1];
|
21215 |
|
21216 | return parseFromConfigs(getConfigsForFiles(files), resolvedFilePath, processedOptions);
|
21217 | }
|
21218 |
|
21219 | exports.parseFromFilesSync = parseFromFilesSync;
|
21220 |
|
21221 | function parse(_filepath, _options) {
|
21222 | if (_options === void 0) {
|
21223 | _options = {};
|
21224 | }
|
21225 |
|
21226 | return __awaiter(this, void 0, void 0, function () {
|
21227 | var _a, resolvedFilePath, processedOptions, filepaths;
|
21228 |
|
21229 | return __generator(this, function (_b) {
|
21230 | _a = opts(_filepath, _options), resolvedFilePath = _a[0], processedOptions = _a[1];
|
21231 | filepaths = getConfigFileNames(resolvedFilePath, processedOptions);
|
21232 | return [2
|
21233 |
|
21234 | , readConfigFiles(filepaths).then(getConfigsForFiles).then(function (configs) {
|
21235 | return parseFromConfigs(configs, resolvedFilePath, processedOptions);
|
21236 | })];
|
21237 | });
|
21238 | });
|
21239 | }
|
21240 |
|
21241 | exports.parse = parse;
|
21242 |
|
21243 | function parseSync(_filepath, _options) {
|
21244 | if (_options === void 0) {
|
21245 | _options = {};
|
21246 | }
|
21247 |
|
21248 | var _a = opts(_filepath, _options),
|
21249 | resolvedFilePath = _a[0],
|
21250 | processedOptions = _a[1];
|
21251 |
|
21252 | var filepaths = getConfigFileNames(resolvedFilePath, processedOptions);
|
21253 | var files = readConfigFilesSync(filepaths);
|
21254 | return parseFromConfigs(getConfigsForFiles(files), resolvedFilePath, processedOptions);
|
21255 | }
|
21256 |
|
21257 | exports.parseSync = parseSync;
|
21258 | });
|
21259 | unwrapExports(src);
|
21260 | var src_1 = src.parseString;
|
21261 | var src_2 = src.parseFromFiles;
|
21262 | var src_3 = src.parseFromFilesSync;
|
21263 | var src_4 = src.parse;
|
21264 | var src_5 = src.parseSync;
|
21265 |
|
21266 | var editorconfigToPrettier = editorConfigToPrettier;
|
21267 |
|
21268 | function removeUnset(editorConfig) {
|
21269 | const result = {};
|
21270 | const keys = Object.keys(editorConfig);
|
21271 |
|
21272 | for (let i = 0; i < keys.length; i++) {
|
21273 | const key = keys[i];
|
21274 |
|
21275 | if (editorConfig[key] === "unset") {
|
21276 | continue;
|
21277 | }
|
21278 |
|
21279 | result[key] = editorConfig[key];
|
21280 | }
|
21281 |
|
21282 | return result;
|
21283 | }
|
21284 |
|
21285 | function editorConfigToPrettier(editorConfig) {
|
21286 | if (!editorConfig) {
|
21287 | return null;
|
21288 | }
|
21289 |
|
21290 | editorConfig = removeUnset(editorConfig);
|
21291 |
|
21292 | if (Object.keys(editorConfig).length === 0) {
|
21293 | return null;
|
21294 | }
|
21295 |
|
21296 | const result = {};
|
21297 |
|
21298 | if (editorConfig.indent_style) {
|
21299 | result.useTabs = editorConfig.indent_style === "tab";
|
21300 | }
|
21301 |
|
21302 | if (editorConfig.indent_size === "tab") {
|
21303 | result.useTabs = true;
|
21304 | }
|
21305 |
|
21306 | if (result.useTabs && editorConfig.tab_width) {
|
21307 | result.tabWidth = editorConfig.tab_width;
|
21308 | } else if (editorConfig.indent_style === "space" && editorConfig.indent_size && editorConfig.indent_size !== "tab") {
|
21309 | result.tabWidth = editorConfig.indent_size;
|
21310 | } else if (editorConfig.tab_width !== undefined) {
|
21311 | result.tabWidth = editorConfig.tab_width;
|
21312 | }
|
21313 |
|
21314 | if (editorConfig.max_line_length && editorConfig.max_line_length !== "off") {
|
21315 | result.printWidth = editorConfig.max_line_length;
|
21316 | }
|
21317 |
|
21318 | if (editorConfig.quote_type === "single") {
|
21319 | result.singleQuote = true;
|
21320 | } else if (editorConfig.quote_type === "double") {
|
21321 | result.singleQuote = false;
|
21322 | }
|
21323 |
|
21324 | if (["cr", "crlf", "lf"].indexOf(editorConfig.end_of_line) !== -1) {
|
21325 | result.endOfLine = editorConfig.end_of_line;
|
21326 | }
|
21327 |
|
21328 | return result;
|
21329 | }
|
21330 |
|
21331 | function markerExists(files, markers) {
|
21332 | return markers.some(function (marker) {
|
21333 | return files.some(function (file) {
|
21334 | return file === marker;
|
21335 | });
|
21336 | });
|
21337 | }
|
21338 |
|
21339 | function traverseFolder(directory, levels, markers) {
|
21340 | var files = fs$3.readdirSync(directory);
|
21341 |
|
21342 | if (levels === 0) {
|
21343 | return null;
|
21344 | } else if (markerExists(files, markers)) {
|
21345 | return directory;
|
21346 | } else {
|
21347 | return traverseFolder(path$2.resolve(directory, '..'), levels - 1, markers);
|
21348 | }
|
21349 | }
|
21350 |
|
21351 | var findProjectRoot = function findRoot(dir, opts) {
|
21352 | if (!dir) throw new Error("Directory not defined");
|
21353 | opts = opts || {};
|
21354 | var levels = opts.maxDepth || findRoot.MAX_DEPTH;
|
21355 | var markers = opts.markers || findRoot.MARKERS;
|
21356 | return traverseFolder(dir, levels, markers);
|
21357 | };
|
21358 |
|
21359 | var MAX_DEPTH = 9;
|
21360 | var MARKERS = ['.git', '.hg'];
|
21361 | findProjectRoot.MAX_DEPTH = MAX_DEPTH;
|
21362 | findProjectRoot.MARKERS = MARKERS;
|
21363 |
|
21364 | const jsonStringifyMem = fn => mem_1(fn, {
|
21365 | cacheKey: JSON.stringify
|
21366 | });
|
21367 |
|
21368 | const maybeParse = (filePath, parse) => {
|
21369 |
|
21370 |
|
21371 |
|
21372 |
|
21373 | let dirPath = path$2.dirname(path$2.resolve(filePath));
|
21374 | const fsRoot = path$2.parse(dirPath).root;
|
21375 |
|
21376 | while (dirPath !== fsRoot && !fs$3.existsSync(dirPath)) {
|
21377 | dirPath = path$2.dirname(dirPath);
|
21378 | }
|
21379 |
|
21380 | const root = findProjectRoot(dirPath);
|
21381 | return filePath && parse(filePath, {
|
21382 | root
|
21383 | });
|
21384 | };
|
21385 |
|
21386 | const editorconfigAsyncNoCache = async filePath => {
|
21387 | const editorConfig = await maybeParse(filePath, src.parse);
|
21388 | return editorconfigToPrettier(editorConfig);
|
21389 | };
|
21390 |
|
21391 | const editorconfigAsyncWithCache = jsonStringifyMem(editorconfigAsyncNoCache);
|
21392 |
|
21393 | const editorconfigSyncNoCache = filePath => {
|
21394 | return editorconfigToPrettier(maybeParse(filePath, src.parseSync));
|
21395 | };
|
21396 |
|
21397 | const editorconfigSyncWithCache = jsonStringifyMem(editorconfigSyncNoCache);
|
21398 |
|
21399 | function getLoadFunction(opts) {
|
21400 | if (!opts.editorconfig) {
|
21401 | return () => null;
|
21402 | }
|
21403 |
|
21404 | if (opts.sync) {
|
21405 | return opts.cache ? editorconfigSyncWithCache : editorconfigSyncNoCache;
|
21406 | }
|
21407 |
|
21408 | return opts.cache ? editorconfigAsyncWithCache : editorconfigAsyncNoCache;
|
21409 | }
|
21410 |
|
21411 | function clearCache() {
|
21412 | mem_1.clear(editorconfigSyncWithCache);
|
21413 | mem_1.clear(editorconfigAsyncWithCache);
|
21414 | }
|
21415 |
|
21416 | var resolveConfigEditorconfig = {
|
21417 | getLoadFunction,
|
21418 | clearCache
|
21419 | };
|
21420 |
|
21421 | const ParserEND = 0x110000;
|
21422 |
|
21423 | class ParserError extends Error {
|
21424 |
|
21425 | constructor(msg, filename, linenumber) {
|
21426 | super('[ParserError] ' + msg, filename, linenumber);
|
21427 | this.name = 'ParserError';
|
21428 | this.code = 'ParserError';
|
21429 | if (Error.captureStackTrace) Error.captureStackTrace(this, ParserError);
|
21430 | }
|
21431 |
|
21432 | }
|
21433 |
|
21434 | class State {
|
21435 | constructor(parser) {
|
21436 | this.parser = parser;
|
21437 | this.buf = '';
|
21438 | this.returned = null;
|
21439 | this.result = null;
|
21440 | this.resultTable = null;
|
21441 | this.resultArr = null;
|
21442 | }
|
21443 |
|
21444 | }
|
21445 |
|
21446 | class Parser {
|
21447 | constructor() {
|
21448 | this.pos = 0;
|
21449 | this.col = 0;
|
21450 | this.line = 0;
|
21451 | this.obj = {};
|
21452 | this.ctx = this.obj;
|
21453 | this.stack = [];
|
21454 | this._buf = '';
|
21455 | this.char = null;
|
21456 | this.ii = 0;
|
21457 | this.state = new State(this.parseStart);
|
21458 | }
|
21459 |
|
21460 | parse(str) {
|
21461 |
|
21462 | if (str.length === 0 || str.length == null) return;
|
21463 | this._buf = String(str);
|
21464 | this.ii = -1;
|
21465 | this.char = -1;
|
21466 | let getNext;
|
21467 |
|
21468 | while (getNext === false || this.nextChar()) {
|
21469 | getNext = this.runOne();
|
21470 | }
|
21471 |
|
21472 | this._buf = null;
|
21473 | }
|
21474 |
|
21475 | nextChar() {
|
21476 | if (this.char === 0x0A) {
|
21477 | ++this.line;
|
21478 | this.col = -1;
|
21479 | }
|
21480 |
|
21481 | ++this.ii;
|
21482 | this.char = this._buf.codePointAt(this.ii);
|
21483 | ++this.pos;
|
21484 | ++this.col;
|
21485 | return this.haveBuffer();
|
21486 | }
|
21487 |
|
21488 | haveBuffer() {
|
21489 | return this.ii < this._buf.length;
|
21490 | }
|
21491 |
|
21492 | runOne() {
|
21493 | return this.state.parser.call(this, this.state.returned);
|
21494 | }
|
21495 |
|
21496 | finish() {
|
21497 | this.char = ParserEND;
|
21498 | let last;
|
21499 |
|
21500 | do {
|
21501 | last = this.state.parser;
|
21502 | this.runOne();
|
21503 | } while (this.state.parser !== last);
|
21504 |
|
21505 | this.ctx = null;
|
21506 | this.state = null;
|
21507 | this._buf = null;
|
21508 | return this.obj;
|
21509 | }
|
21510 |
|
21511 | next(fn) {
|
21512 |
|
21513 | if (typeof fn !== 'function') throw new ParserError('Tried to set state to non-existent state: ' + JSON.stringify(fn));
|
21514 | this.state.parser = fn;
|
21515 | }
|
21516 |
|
21517 | goto(fn) {
|
21518 | this.next(fn);
|
21519 | return this.runOne();
|
21520 | }
|
21521 |
|
21522 | call(fn, returnWith) {
|
21523 | if (returnWith) this.next(returnWith);
|
21524 | this.stack.push(this.state);
|
21525 | this.state = new State(fn);
|
21526 | }
|
21527 |
|
21528 | callNow(fn, returnWith) {
|
21529 | this.call(fn, returnWith);
|
21530 | return this.runOne();
|
21531 | }
|
21532 |
|
21533 | return(value) {
|
21534 |
|
21535 | if (this.stack.length === 0) throw this.error(new ParserError('Stack underflow'));
|
21536 | if (value === undefined) value = this.state.buf;
|
21537 | this.state = this.stack.pop();
|
21538 | this.state.returned = value;
|
21539 | }
|
21540 |
|
21541 | returnNow(value) {
|
21542 | this.return(value);
|
21543 | return this.runOne();
|
21544 | }
|
21545 |
|
21546 | consume() {
|
21547 |
|
21548 | if (this.char === ParserEND) throw this.error(new ParserError('Unexpected end-of-buffer'));
|
21549 | this.state.buf += this._buf[this.ii];
|
21550 | }
|
21551 |
|
21552 | error(err) {
|
21553 | err.line = this.line;
|
21554 | err.col = this.col;
|
21555 | err.pos = this.pos;
|
21556 | return err;
|
21557 | }
|
21558 |
|
21559 |
|
21560 |
|
21561 | parseStart() {
|
21562 | throw new ParserError('Must declare a parseStart method');
|
21563 | }
|
21564 |
|
21565 | }
|
21566 |
|
21567 | Parser.END = ParserEND;
|
21568 | Parser.Error = ParserError;
|
21569 | var parser$1 = Parser;
|
21570 |
|
21571 | var createDatetime = value => {
|
21572 | const date = new Date(value);
|
21573 |
|
21574 |
|
21575 | if (isNaN(date)) {
|
21576 | throw new TypeError('Invalid Datetime');
|
21577 | } else {
|
21578 | return date;
|
21579 | }
|
21580 | };
|
21581 |
|
21582 | var formatNum = (d, num) => {
|
21583 | num = String(num);
|
21584 |
|
21585 | while (num.length < d) num = '0' + num;
|
21586 |
|
21587 | return num;
|
21588 | };
|
21589 |
|
21590 | class FloatingDateTime extends Date {
|
21591 | constructor(value) {
|
21592 | super(value + 'Z');
|
21593 | this.isFloating = true;
|
21594 | }
|
21595 |
|
21596 | toISOString() {
|
21597 | const date = `${this.getUTCFullYear()}-${formatNum(2, this.getUTCMonth() + 1)}-${formatNum(2, this.getUTCDate())}`;
|
21598 | const time = `${formatNum(2, this.getUTCHours())}:${formatNum(2, this.getUTCMinutes())}:${formatNum(2, this.getUTCSeconds())}.${formatNum(3, this.getUTCMilliseconds())}`;
|
21599 | return `${date}T${time}`;
|
21600 | }
|
21601 |
|
21602 | }
|
21603 |
|
21604 | var createDatetimeFloat = value => {
|
21605 | const date = new FloatingDateTime(value);
|
21606 |
|
21607 |
|
21608 | if (isNaN(date)) {
|
21609 | throw new TypeError('Invalid Datetime');
|
21610 | } else {
|
21611 | return date;
|
21612 | }
|
21613 | };
|
21614 |
|
21615 | const DateTime = global.Date;
|
21616 |
|
21617 | class Date$1 extends DateTime {
|
21618 | constructor(value) {
|
21619 | super(value);
|
21620 | this.isDate = true;
|
21621 | }
|
21622 |
|
21623 | toISOString() {
|
21624 | return `${this.getUTCFullYear()}-${formatNum(2, this.getUTCMonth() + 1)}-${formatNum(2, this.getUTCDate())}`;
|
21625 | }
|
21626 |
|
21627 | }
|
21628 |
|
21629 | var createDate = value => {
|
21630 | const date = new Date$1(value);
|
21631 |
|
21632 |
|
21633 | if (isNaN(date)) {
|
21634 | throw new TypeError('Invalid Datetime');
|
21635 | } else {
|
21636 | return date;
|
21637 | }
|
21638 | };
|
21639 |
|
21640 | class Time extends Date {
|
21641 | constructor(value) {
|
21642 | super(`0000-01-01T${value}Z`);
|
21643 | this.isTime = true;
|
21644 | }
|
21645 |
|
21646 | toISOString() {
|
21647 | return `${formatNum(2, this.getUTCHours())}:${formatNum(2, this.getUTCMinutes())}:${formatNum(2, this.getUTCSeconds())}.${formatNum(3, this.getUTCMilliseconds())}`;
|
21648 | }
|
21649 |
|
21650 | }
|
21651 |
|
21652 | var createTime = value => {
|
21653 | const date = new Time(value);
|
21654 |
|
21655 |
|
21656 | if (isNaN(date)) {
|
21657 | throw new TypeError('Invalid Datetime');
|
21658 | } else {
|
21659 | return date;
|
21660 | }
|
21661 | };
|
21662 |
|
21663 |
|
21664 |
|
21665 |
|
21666 | var tomlParser = makeParserClass(parser$1);
|
21667 | var makeParserClass_1 = makeParserClass;
|
21668 |
|
21669 | class TomlError extends Error {
|
21670 | constructor(msg) {
|
21671 | super(msg);
|
21672 | this.name = 'TomlError';
|
21673 |
|
21674 |
|
21675 | if (Error.captureStackTrace) Error.captureStackTrace(this, TomlError);
|
21676 | this.fromTOML = true;
|
21677 | this.wrapped = null;
|
21678 | }
|
21679 |
|
21680 | }
|
21681 |
|
21682 | TomlError.wrap = err => {
|
21683 | const terr = new TomlError(err.message);
|
21684 | terr.code = err.code;
|
21685 | terr.wrapped = err;
|
21686 | return terr;
|
21687 | };
|
21688 |
|
21689 | var TomlError_1 = TomlError;
|
21690 | const CTRL_I = 0x09;
|
21691 | const CTRL_J = 0x0A;
|
21692 | const CTRL_M = 0x0D;
|
21693 | const CTRL_CHAR_BOUNDARY = 0x1F;
|
21694 |
|
21695 | const CHAR_SP = 0x20;
|
21696 | const CHAR_QUOT = 0x22;
|
21697 | const CHAR_NUM = 0x23;
|
21698 | const CHAR_APOS = 0x27;
|
21699 | const CHAR_PLUS = 0x2B;
|
21700 | const CHAR_COMMA = 0x2C;
|
21701 | const CHAR_HYPHEN = 0x2D;
|
21702 | const CHAR_PERIOD = 0x2E;
|
21703 | const CHAR_0 = 0x30;
|
21704 | const CHAR_1 = 0x31;
|
21705 | const CHAR_7 = 0x37;
|
21706 | const CHAR_9 = 0x39;
|
21707 | const CHAR_COLON = 0x3A;
|
21708 | const CHAR_EQUALS = 0x3D;
|
21709 | const CHAR_A = 0x41;
|
21710 | const CHAR_E = 0x45;
|
21711 | const CHAR_F = 0x46;
|
21712 | const CHAR_T = 0x54;
|
21713 | const CHAR_U = 0x55;
|
21714 | const CHAR_Z = 0x5A;
|
21715 | const CHAR_LOWBAR = 0x5F;
|
21716 | const CHAR_a = 0x61;
|
21717 | const CHAR_b = 0x62;
|
21718 | const CHAR_e = 0x65;
|
21719 | const CHAR_f = 0x66;
|
21720 | const CHAR_i = 0x69;
|
21721 | const CHAR_l = 0x6C;
|
21722 | const CHAR_n = 0x6E;
|
21723 | const CHAR_o = 0x6F;
|
21724 | const CHAR_r = 0x72;
|
21725 | const CHAR_s = 0x73;
|
21726 | const CHAR_t = 0x74;
|
21727 | const CHAR_u = 0x75;
|
21728 | const CHAR_x = 0x78;
|
21729 | const CHAR_z = 0x7A;
|
21730 | const CHAR_LCUB = 0x7B;
|
21731 | const CHAR_RCUB = 0x7D;
|
21732 | const CHAR_LSQB = 0x5B;
|
21733 | const CHAR_BSOL = 0x5C;
|
21734 | const CHAR_RSQB = 0x5D;
|
21735 | const CHAR_DEL = 0x7F;
|
21736 | const SURROGATE_FIRST = 0xD800;
|
21737 | const SURROGATE_LAST = 0xDFFF;
|
21738 | const escapes = {
|
21739 | [CHAR_b]: '\u0008',
|
21740 | [CHAR_t]: '\u0009',
|
21741 | [CHAR_n]: '\u000A',
|
21742 | [CHAR_f]: '\u000C',
|
21743 | [CHAR_r]: '\u000D',
|
21744 | [CHAR_QUOT]: '\u0022',
|
21745 | [CHAR_BSOL]: '\u005C'
|
21746 | };
|
21747 |
|
21748 | function isDigit(cp) {
|
21749 | return cp >= CHAR_0 && cp <= CHAR_9;
|
21750 | }
|
21751 |
|
21752 | function isHexit(cp) {
|
21753 | return cp >= CHAR_A && cp <= CHAR_F || cp >= CHAR_a && cp <= CHAR_f || cp >= CHAR_0 && cp <= CHAR_9;
|
21754 | }
|
21755 |
|
21756 | function isBit(cp) {
|
21757 | return cp === CHAR_1 || cp === CHAR_0;
|
21758 | }
|
21759 |
|
21760 | function isOctit(cp) {
|
21761 | return cp >= CHAR_0 && cp <= CHAR_7;
|
21762 | }
|
21763 |
|
21764 | function isAlphaNumQuoteHyphen(cp) {
|
21765 | return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_APOS || cp === CHAR_QUOT || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN;
|
21766 | }
|
21767 |
|
21768 | function isAlphaNumHyphen(cp) {
|
21769 | return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN;
|
21770 | }
|
21771 |
|
21772 | const _type = Symbol('type');
|
21773 |
|
21774 | const _declared = Symbol('declared');
|
21775 |
|
21776 | const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
21777 | const defineProperty = Object.defineProperty;
|
21778 | const descriptor = {
|
21779 | configurable: true,
|
21780 | enumerable: true,
|
21781 | writable: true,
|
21782 | value: undefined
|
21783 | };
|
21784 |
|
21785 | function hasKey(obj, key) {
|
21786 | if (hasOwnProperty$1.call(obj, key)) return true;
|
21787 | if (key === '__proto__') defineProperty(obj, '__proto__', descriptor);
|
21788 | return false;
|
21789 | }
|
21790 |
|
21791 | const INLINE_TABLE = Symbol('inline-table');
|
21792 |
|
21793 | function InlineTable() {
|
21794 | return Object.defineProperties({}, {
|
21795 | [_type]: {
|
21796 | value: INLINE_TABLE
|
21797 | }
|
21798 | });
|
21799 | }
|
21800 |
|
21801 | function isInlineTable(obj) {
|
21802 | if (obj === null || typeof obj !== 'object') return false;
|
21803 | return obj[_type] === INLINE_TABLE;
|
21804 | }
|
21805 |
|
21806 | const TABLE = Symbol('table');
|
21807 |
|
21808 | function Table() {
|
21809 | return Object.defineProperties({}, {
|
21810 | [_type]: {
|
21811 | value: TABLE
|
21812 | },
|
21813 | [_declared]: {
|
21814 | value: false,
|
21815 | writable: true
|
21816 | }
|
21817 | });
|
21818 | }
|
21819 |
|
21820 | function isTable(obj) {
|
21821 | if (obj === null || typeof obj !== 'object') return false;
|
21822 | return obj[_type] === TABLE;
|
21823 | }
|
21824 |
|
21825 | const _contentType = Symbol('content-type');
|
21826 |
|
21827 | const INLINE_LIST = Symbol('inline-list');
|
21828 |
|
21829 | function InlineList(type) {
|
21830 | return Object.defineProperties([], {
|
21831 | [_type]: {
|
21832 | value: INLINE_LIST
|
21833 | },
|
21834 | [_contentType]: {
|
21835 | value: type
|
21836 | }
|
21837 | });
|
21838 | }
|
21839 |
|
21840 | function isInlineList(obj) {
|
21841 | if (obj === null || typeof obj !== 'object') return false;
|
21842 | return obj[_type] === INLINE_LIST;
|
21843 | }
|
21844 |
|
21845 | const LIST = Symbol('list');
|
21846 |
|
21847 | function List() {
|
21848 | return Object.defineProperties([], {
|
21849 | [_type]: {
|
21850 | value: LIST
|
21851 | }
|
21852 | });
|
21853 | }
|
21854 |
|
21855 | function isList(obj) {
|
21856 | if (obj === null || typeof obj !== 'object') return false;
|
21857 | return obj[_type] === LIST;
|
21858 | }
|
21859 |
|
21860 |
|
21861 | let _custom;
|
21862 |
|
21863 | try {
|
21864 | const utilInspect = eval("require('util').inspect");
|
21865 | _custom = utilInspect.custom;
|
21866 | } catch (_) {}
|
21867 |
|
21868 |
|
21869 |
|
21870 |
|
21871 |
|
21872 | const _inspect = _custom || 'inspect';
|
21873 |
|
21874 | class BoxedBigInt {
|
21875 | constructor(value) {
|
21876 | try {
|
21877 | this.value = global.BigInt.asIntN(64, value);
|
21878 | } catch (_) {
|
21879 |
|
21880 | this.value = null;
|
21881 | }
|
21882 |
|
21883 | Object.defineProperty(this, _type, {
|
21884 | value: INTEGER
|
21885 | });
|
21886 | }
|
21887 |
|
21888 | isNaN() {
|
21889 | return this.value === null;
|
21890 | }
|
21891 |
|
21892 |
|
21893 |
|
21894 | toString() {
|
21895 | return String(this.value);
|
21896 | }
|
21897 |
|
21898 |
|
21899 |
|
21900 | [_inspect]() {
|
21901 | return `[BigInt: ${this.toString()}]}`;
|
21902 | }
|
21903 |
|
21904 | valueOf() {
|
21905 | return this.value;
|
21906 | }
|
21907 |
|
21908 | }
|
21909 |
|
21910 | const INTEGER = Symbol('integer');
|
21911 |
|
21912 | function Integer(value) {
|
21913 | let num = Number(value);
|
21914 |
|
21915 | if (Object.is(num, -0)) num = 0;
|
21916 |
|
21917 |
|
21918 | if (global.BigInt && !Number.isSafeInteger(num)) {
|
21919 | return new BoxedBigInt(value);
|
21920 | } else {
|
21921 |
|
21922 | return Object.defineProperties(new Number(num), {
|
21923 | isNaN: {
|
21924 | value: function () {
|
21925 | return isNaN(this);
|
21926 | }
|
21927 | },
|
21928 | [_type]: {
|
21929 | value: INTEGER
|
21930 | },
|
21931 | [_inspect]: {
|
21932 | value: () => `[Integer: ${value}]`
|
21933 | }
|
21934 | });
|
21935 | }
|
21936 | }
|
21937 |
|
21938 | function isInteger(obj) {
|
21939 | if (obj === null || typeof obj !== 'object') return false;
|
21940 | return obj[_type] === INTEGER;
|
21941 | }
|
21942 |
|
21943 | const FLOAT = Symbol('float');
|
21944 |
|
21945 | function Float(value) {
|
21946 |
|
21947 | return Object.defineProperties(new Number(value), {
|
21948 | [_type]: {
|
21949 | value: FLOAT
|
21950 | },
|
21951 | [_inspect]: {
|
21952 | value: () => `[Float: ${value}]`
|
21953 | }
|
21954 | });
|
21955 | }
|
21956 |
|
21957 | function isFloat(obj) {
|
21958 | if (obj === null || typeof obj !== 'object') return false;
|
21959 | return obj[_type] === FLOAT;
|
21960 | }
|
21961 |
|
21962 | function tomlType(value) {
|
21963 | const type = typeof value;
|
21964 |
|
21965 | if (type === 'object') {
|
21966 |
|
21967 | if (value === null) return 'null';
|
21968 | if (value instanceof Date) return 'datetime';
|
21969 |
|
21970 |
|
21971 | if (_type in value) {
|
21972 | switch (value[_type]) {
|
21973 | case INLINE_TABLE:
|
21974 | return 'inline-table';
|
21975 |
|
21976 | case INLINE_LIST:
|
21977 | return 'inline-list';
|
21978 |
|
21979 |
|
21980 |
|
21981 | case TABLE:
|
21982 | return 'table';
|
21983 |
|
21984 |
|
21985 |
|
21986 | case LIST:
|
21987 | return 'list';
|
21988 |
|
21989 | case FLOAT:
|
21990 | return 'float';
|
21991 |
|
21992 | case INTEGER:
|
21993 | return 'integer';
|
21994 | }
|
21995 | }
|
21996 | }
|
21997 |
|
21998 | return type;
|
21999 | }
|
22000 |
|
22001 | function makeParserClass(Parser) {
|
22002 | class TOMLParser extends Parser {
|
22003 | constructor() {
|
22004 | super();
|
22005 | this.ctx = this.obj = Table();
|
22006 | }
|
22007 |
|
22008 |
|
22009 |
|
22010 | atEndOfWord() {
|
22011 | return this.char === CHAR_NUM || this.char === CTRL_I || this.char === CHAR_SP || this.atEndOfLine();
|
22012 | }
|
22013 |
|
22014 | atEndOfLine() {
|
22015 | return this.char === Parser.END || this.char === CTRL_J || this.char === CTRL_M;
|
22016 | }
|
22017 |
|
22018 | parseStart() {
|
22019 | if (this.char === Parser.END) {
|
22020 | return null;
|
22021 | } else if (this.char === CHAR_LSQB) {
|
22022 | return this.call(this.parseTableOrList);
|
22023 | } else if (this.char === CHAR_NUM) {
|
22024 | return this.call(this.parseComment);
|
22025 | } else if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
|
22026 | return null;
|
22027 | } else if (isAlphaNumQuoteHyphen(this.char)) {
|
22028 | return this.callNow(this.parseAssignStatement);
|
22029 | } else {
|
22030 | throw this.error(new TomlError(`Unknown character "${this.char}"`));
|
22031 | }
|
22032 | }
|
22033 |
|
22034 |
|
22035 |
|
22036 | parseWhitespaceToEOL() {
|
22037 | if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
|
22038 | return null;
|
22039 | } else if (this.char === CHAR_NUM) {
|
22040 | return this.goto(this.parseComment);
|
22041 | } else if (this.char === Parser.END || this.char === CTRL_J) {
|
22042 | return this.return();
|
22043 | } else {
|
22044 | throw this.error(new TomlError('Unexpected character, expected only whitespace or comments till end of line'));
|
22045 | }
|
22046 | }
|
22047 |
|
22048 |
|
22049 |
|
22050 | parseAssignStatement() {
|
22051 | return this.callNow(this.parseAssign, this.recordAssignStatement);
|
22052 | }
|
22053 |
|
22054 | recordAssignStatement(kv) {
|
22055 | let target = this.ctx;
|
22056 | let finalKey = kv.key.pop();
|
22057 |
|
22058 | for (let kw of kv.key) {
|
22059 | if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) {
|
22060 | throw this.error(new TomlError("Can't redefine existing key"));
|
22061 | }
|
22062 |
|
22063 | target = target[kw] = target[kw] || Table();
|
22064 | }
|
22065 |
|
22066 | if (hasKey(target, finalKey)) {
|
22067 | throw this.error(new TomlError("Can't redefine existing key"));
|
22068 | }
|
22069 |
|
22070 |
|
22071 | if (isInteger(kv.value) || isFloat(kv.value)) {
|
22072 | target[finalKey] = kv.value.valueOf();
|
22073 | } else {
|
22074 | target[finalKey] = kv.value;
|
22075 | }
|
22076 |
|
22077 | return this.goto(this.parseWhitespaceToEOL);
|
22078 | }
|
22079 |
|
22080 |
|
22081 |
|
22082 | parseAssign() {
|
22083 | return this.callNow(this.parseKeyword, this.recordAssignKeyword);
|
22084 | }
|
22085 |
|
22086 | recordAssignKeyword(key) {
|
22087 | if (this.state.resultTable) {
|
22088 | this.state.resultTable.push(key);
|
22089 | } else {
|
22090 | this.state.resultTable = [key];
|
22091 | }
|
22092 |
|
22093 | return this.goto(this.parseAssignKeywordPreDot);
|
22094 | }
|
22095 |
|
22096 | parseAssignKeywordPreDot() {
|
22097 | if (this.char === CHAR_PERIOD) {
|
22098 | return this.next(this.parseAssignKeywordPostDot);
|
22099 | } else if (this.char !== CHAR_SP && this.char !== CTRL_I) {
|
22100 | return this.goto(this.parseAssignEqual);
|
22101 | }
|
22102 | }
|
22103 |
|
22104 | parseAssignKeywordPostDot() {
|
22105 | if (this.char !== CHAR_SP && this.char !== CTRL_I) {
|
22106 | return this.callNow(this.parseKeyword, this.recordAssignKeyword);
|
22107 | }
|
22108 | }
|
22109 |
|
22110 | parseAssignEqual() {
|
22111 | if (this.char === CHAR_EQUALS) {
|
22112 | return this.next(this.parseAssignPreValue);
|
22113 | } else {
|
22114 | throw this.error(new TomlError('Invalid character, expected "="'));
|
22115 | }
|
22116 | }
|
22117 |
|
22118 | parseAssignPreValue() {
|
22119 | if (this.char === CHAR_SP || this.char === CTRL_I) {
|
22120 | return null;
|
22121 | } else {
|
22122 | return this.callNow(this.parseValue, this.recordAssignValue);
|
22123 | }
|
22124 | }
|
22125 |
|
22126 | recordAssignValue(value) {
|
22127 | return this.returnNow({
|
22128 | key: this.state.resultTable,
|
22129 | value: value
|
22130 | });
|
22131 | }
|
22132 |
|
22133 |
|
22134 |
|
22135 | parseComment() {
|
22136 | do {
|
22137 | if (this.char === Parser.END || this.char === CTRL_J) {
|
22138 | return this.return();
|
22139 | }
|
22140 | } while (this.nextChar());
|
22141 | }
|
22142 |
|
22143 |
|
22144 |
|
22145 | parseTableOrList() {
|
22146 | if (this.char === CHAR_LSQB) {
|
22147 | this.next(this.parseList);
|
22148 | } else {
|
22149 | return this.goto(this.parseTable);
|
22150 | }
|
22151 | }
|
22152 |
|
22153 |
|
22154 |
|
22155 | parseTable() {
|
22156 | this.ctx = this.obj;
|
22157 | return this.goto(this.parseTableNext);
|
22158 | }
|
22159 |
|
22160 | parseTableNext() {
|
22161 | if (this.char === CHAR_SP || this.char === CTRL_I) {
|
22162 | return null;
|
22163 | } else {
|
22164 | return this.callNow(this.parseKeyword, this.parseTableMore);
|
22165 | }
|
22166 | }
|
22167 |
|
22168 | parseTableMore(keyword) {
|
22169 | if (this.char === CHAR_SP || this.char === CTRL_I) {
|
22170 | return null;
|
22171 | } else if (this.char === CHAR_RSQB) {
|
22172 | if (hasKey(this.ctx, keyword) && (!isTable(this.ctx[keyword]) || this.ctx[keyword][_declared])) {
|
22173 | throw this.error(new TomlError("Can't redefine existing key"));
|
22174 | } else {
|
22175 | this.ctx = this.ctx[keyword] = this.ctx[keyword] || Table();
|
22176 | this.ctx[_declared] = true;
|
22177 | }
|
22178 |
|
22179 | return this.next(this.parseWhitespaceToEOL);
|
22180 | } else if (this.char === CHAR_PERIOD) {
|
22181 | if (!hasKey(this.ctx, keyword)) {
|
22182 | this.ctx = this.ctx[keyword] = Table();
|
22183 | } else if (isTable(this.ctx[keyword])) {
|
22184 | this.ctx = this.ctx[keyword];
|
22185 | } else if (isList(this.ctx[keyword])) {
|
22186 | this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
|
22187 | } else {
|
22188 | throw this.error(new TomlError("Can't redefine existing key"));
|
22189 | }
|
22190 |
|
22191 | return this.next(this.parseTableNext);
|
22192 | } else {
|
22193 | throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
|
22194 | }
|
22195 | }
|
22196 |
|
22197 |
|
22198 |
|
22199 | parseList() {
|
22200 | this.ctx = this.obj;
|
22201 | return this.goto(this.parseListNext);
|
22202 | }
|
22203 |
|
22204 | parseListNext() {
|
22205 | if (this.char === CHAR_SP || this.char === CTRL_I) {
|
22206 | return null;
|
22207 | } else {
|
22208 | return this.callNow(this.parseKeyword, this.parseListMore);
|
22209 | }
|
22210 | }
|
22211 |
|
22212 | parseListMore(keyword) {
|
22213 | if (this.char === CHAR_SP || this.char === CTRL_I) {
|
22214 | return null;
|
22215 | } else if (this.char === CHAR_RSQB) {
|
22216 | if (!hasKey(this.ctx, keyword)) {
|
22217 | this.ctx[keyword] = List();
|
22218 | }
|
22219 |
|
22220 | if (isInlineList(this.ctx[keyword])) {
|
22221 | throw this.error(new TomlError("Can't extend an inline array"));
|
22222 | } else if (isList(this.ctx[keyword])) {
|
22223 | const next = Table();
|
22224 | this.ctx[keyword].push(next);
|
22225 | this.ctx = next;
|
22226 | } else {
|
22227 | throw this.error(new TomlError("Can't redefine an existing key"));
|
22228 | }
|
22229 |
|
22230 | return this.next(this.parseListEnd);
|
22231 | } else if (this.char === CHAR_PERIOD) {
|
22232 | if (!hasKey(this.ctx, keyword)) {
|
22233 | this.ctx = this.ctx[keyword] = Table();
|
22234 | } else if (isInlineList(this.ctx[keyword])) {
|
22235 | throw this.error(new TomlError("Can't extend an inline array"));
|
22236 | } else if (isInlineTable(this.ctx[keyword])) {
|
22237 | throw this.error(new TomlError("Can't extend an inline table"));
|
22238 | } else if (isList(this.ctx[keyword])) {
|
22239 | this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
|
22240 | } else if (isTable(this.ctx[keyword])) {
|
22241 | this.ctx = this.ctx[keyword];
|
22242 | } else {
|
22243 | throw this.error(new TomlError("Can't redefine an existing key"));
|
22244 | }
|
22245 |
|
22246 | return this.next(this.parseListNext);
|
22247 | } else {
|
22248 | throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
|
22249 | }
|
22250 | }
|
22251 |
|
22252 | parseListEnd(keyword) {
|
22253 | if (this.char === CHAR_RSQB) {
|
22254 | return this.next(this.parseWhitespaceToEOL);
|
22255 | } else {
|
22256 | throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
|
22257 | }
|
22258 | }
|
22259 |
|
22260 |
|
22261 |
|
22262 | parseValue() {
|
22263 | if (this.char === Parser.END) {
|
22264 | throw this.error(new TomlError('Key without value'));
|
22265 | } else if (this.char === CHAR_QUOT) {
|
22266 | return this.next(this.parseDoubleString);
|
22267 | }
|
22268 |
|
22269 | if (this.char === CHAR_APOS) {
|
22270 | return this.next(this.parseSingleString);
|
22271 | } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
|
22272 | return this.goto(this.parseNumberSign);
|
22273 | } else if (this.char === CHAR_i) {
|
22274 | return this.next(this.parseInf);
|
22275 | } else if (this.char === CHAR_n) {
|
22276 | return this.next(this.parseNan);
|
22277 | } else if (isDigit(this.char)) {
|
22278 | return this.goto(this.parseNumberOrDateTime);
|
22279 | } else if (this.char === CHAR_t || this.char === CHAR_f) {
|
22280 | return this.goto(this.parseBoolean);
|
22281 | } else if (this.char === CHAR_LSQB) {
|
22282 | return this.call(this.parseInlineList, this.recordValue);
|
22283 | } else if (this.char === CHAR_LCUB) {
|
22284 | return this.call(this.parseInlineTable, this.recordValue);
|
22285 | } else {
|
22286 | throw this.error(new TomlError('Unexpected character, expecting string, number, datetime, boolean, inline array or inline table'));
|
22287 | }
|
22288 | }
|
22289 |
|
22290 | recordValue(value) {
|
22291 | return this.returnNow(value);
|
22292 | }
|
22293 |
|
22294 | parseInf() {
|
22295 | if (this.char === CHAR_n) {
|
22296 | return this.next(this.parseInf2);
|
22297 | } else {
|
22298 | throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
|
22299 | }
|
22300 | }
|
22301 |
|
22302 | parseInf2() {
|
22303 | if (this.char === CHAR_f) {
|
22304 | if (this.state.buf === '-') {
|
22305 | return this.return(-Infinity);
|
22306 | } else {
|
22307 | return this.return(Infinity);
|
22308 | }
|
22309 | } else {
|
22310 | throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
|
22311 | }
|
22312 | }
|
22313 |
|
22314 | parseNan() {
|
22315 | if (this.char === CHAR_a) {
|
22316 | return this.next(this.parseNan2);
|
22317 | } else {
|
22318 | throw this.error(new TomlError('Unexpected character, expected "nan"'));
|
22319 | }
|
22320 | }
|
22321 |
|
22322 | parseNan2() {
|
22323 | if (this.char === CHAR_n) {
|
22324 | return this.return(NaN);
|
22325 | } else {
|
22326 | throw this.error(new TomlError('Unexpected character, expected "nan"'));
|
22327 | }
|
22328 | }
|
22329 |
|
22330 |
|
22331 |
|
22332 | parseKeyword() {
|
22333 | if (this.char === CHAR_QUOT) {
|
22334 | return this.next(this.parseBasicString);
|
22335 | } else if (this.char === CHAR_APOS) {
|
22336 | return this.next(this.parseLiteralString);
|
22337 | } else {
|
22338 | return this.goto(this.parseBareKey);
|
22339 | }
|
22340 | }
|
22341 |
|
22342 |
|
22343 |
|
22344 | parseBareKey() {
|
22345 | do {
|
22346 | if (this.char === Parser.END) {
|
22347 | throw this.error(new TomlError('Key ended without value'));
|
22348 | } else if (isAlphaNumHyphen(this.char)) {
|
22349 | this.consume();
|
22350 | } else if (this.state.buf.length === 0) {
|
22351 | throw this.error(new TomlError('Empty bare keys are not allowed'));
|
22352 | } else {
|
22353 | return this.returnNow();
|
22354 | }
|
22355 | } while (this.nextChar());
|
22356 | }
|
22357 |
|
22358 |
|
22359 |
|
22360 | parseSingleString() {
|
22361 | if (this.char === CHAR_APOS) {
|
22362 | return this.next(this.parseLiteralMultiStringMaybe);
|
22363 | } else {
|
22364 | return this.goto(this.parseLiteralString);
|
22365 | }
|
22366 | }
|
22367 |
|
22368 | parseLiteralString() {
|
22369 | do {
|
22370 | if (this.char === CHAR_APOS) {
|
22371 | return this.return();
|
22372 | } else if (this.atEndOfLine()) {
|
22373 | throw this.error(new TomlError('Unterminated string'));
|
22374 | } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) {
|
22375 | throw this.errorControlCharInString();
|
22376 | } else {
|
22377 | this.consume();
|
22378 | }
|
22379 | } while (this.nextChar());
|
22380 | }
|
22381 |
|
22382 | parseLiteralMultiStringMaybe() {
|
22383 | if (this.char === CHAR_APOS) {
|
22384 | return this.next(this.parseLiteralMultiString);
|
22385 | } else {
|
22386 | return this.returnNow();
|
22387 | }
|
22388 | }
|
22389 |
|
22390 | parseLiteralMultiString() {
|
22391 | if (this.char === CTRL_M) {
|
22392 | return null;
|
22393 | } else if (this.char === CTRL_J) {
|
22394 | return this.next(this.parseLiteralMultiStringContent);
|
22395 | } else {
|
22396 | return this.goto(this.parseLiteralMultiStringContent);
|
22397 | }
|
22398 | }
|
22399 |
|
22400 | parseLiteralMultiStringContent() {
|
22401 | do {
|
22402 | if (this.char === CHAR_APOS) {
|
22403 | return this.next(this.parseLiteralMultiEnd);
|
22404 | } else if (this.char === Parser.END) {
|
22405 | throw this.error(new TomlError('Unterminated multi-line string'));
|
22406 | } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) {
|
22407 | throw this.errorControlCharInString();
|
22408 | } else {
|
22409 | this.consume();
|
22410 | }
|
22411 | } while (this.nextChar());
|
22412 | }
|
22413 |
|
22414 | parseLiteralMultiEnd() {
|
22415 | if (this.char === CHAR_APOS) {
|
22416 | return this.next(this.parseLiteralMultiEnd2);
|
22417 | } else {
|
22418 | this.state.buf += "'";
|
22419 | return this.goto(this.parseLiteralMultiStringContent);
|
22420 | }
|
22421 | }
|
22422 |
|
22423 | parseLiteralMultiEnd2() {
|
22424 | if (this.char === CHAR_APOS) {
|
22425 | return this.return();
|
22426 | } else {
|
22427 | this.state.buf += "''";
|
22428 | return this.goto(this.parseLiteralMultiStringContent);
|
22429 | }
|
22430 | }
|
22431 |
|
22432 |
|
22433 |
|
22434 | parseDoubleString() {
|
22435 | if (this.char === CHAR_QUOT) {
|
22436 | return this.next(this.parseMultiStringMaybe);
|
22437 | } else {
|
22438 | return this.goto(this.parseBasicString);
|
22439 | }
|
22440 | }
|
22441 |
|
22442 | parseBasicString() {
|
22443 | do {
|
22444 | if (this.char === CHAR_BSOL) {
|
22445 | return this.call(this.parseEscape, this.recordEscapeReplacement);
|
22446 | } else if (this.char === CHAR_QUOT) {
|
22447 | return this.return();
|
22448 | } else if (this.atEndOfLine()) {
|
22449 | throw this.error(new TomlError('Unterminated string'));
|
22450 | } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) {
|
22451 | throw this.errorControlCharInString();
|
22452 | } else {
|
22453 | this.consume();
|
22454 | }
|
22455 | } while (this.nextChar());
|
22456 | }
|
22457 |
|
22458 | recordEscapeReplacement(replacement) {
|
22459 | this.state.buf += replacement;
|
22460 | return this.goto(this.parseBasicString);
|
22461 | }
|
22462 |
|
22463 | parseMultiStringMaybe() {
|
22464 | if (this.char === CHAR_QUOT) {
|
22465 | return this.next(this.parseMultiString);
|
22466 | } else {
|
22467 | return this.returnNow();
|
22468 | }
|
22469 | }
|
22470 |
|
22471 | parseMultiString() {
|
22472 | if (this.char === CTRL_M) {
|
22473 | return null;
|
22474 | } else if (this.char === CTRL_J) {
|
22475 | return this.next(this.parseMultiStringContent);
|
22476 | } else {
|
22477 | return this.goto(this.parseMultiStringContent);
|
22478 | }
|
22479 | }
|
22480 |
|
22481 | parseMultiStringContent() {
|
22482 | do {
|
22483 | if (this.char === CHAR_BSOL) {
|
22484 | return this.call(this.parseMultiEscape, this.recordMultiEscapeReplacement);
|
22485 | } else if (this.char === CHAR_QUOT) {
|
22486 | return this.next(this.parseMultiEnd);
|
22487 | } else if (this.char === Parser.END) {
|
22488 | throw this.error(new TomlError('Unterminated multi-line string'));
|
22489 | } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) {
|
22490 | throw this.errorControlCharInString();
|
22491 | } else {
|
22492 | this.consume();
|
22493 | }
|
22494 | } while (this.nextChar());
|
22495 | }
|
22496 |
|
22497 | errorControlCharInString() {
|
22498 | let displayCode = '\\u00';
|
22499 |
|
22500 | if (this.char < 16) {
|
22501 | displayCode += '0';
|
22502 | }
|
22503 |
|
22504 | displayCode += this.char.toString(16);
|
22505 | return this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in strings, use ${displayCode} instead`));
|
22506 | }
|
22507 |
|
22508 | recordMultiEscapeReplacement(replacement) {
|
22509 | this.state.buf += replacement;
|
22510 | return this.goto(this.parseMultiStringContent);
|
22511 | }
|
22512 |
|
22513 | parseMultiEnd() {
|
22514 | if (this.char === CHAR_QUOT) {
|
22515 | return this.next(this.parseMultiEnd2);
|
22516 | } else {
|
22517 | this.state.buf += '"';
|
22518 | return this.goto(this.parseMultiStringContent);
|
22519 | }
|
22520 | }
|
22521 |
|
22522 | parseMultiEnd2() {
|
22523 | if (this.char === CHAR_QUOT) {
|
22524 | return this.return();
|
22525 | } else {
|
22526 | this.state.buf += '""';
|
22527 | return this.goto(this.parseMultiStringContent);
|
22528 | }
|
22529 | }
|
22530 |
|
22531 | parseMultiEscape() {
|
22532 | if (this.char === CTRL_M || this.char === CTRL_J) {
|
22533 | return this.next(this.parseMultiTrim);
|
22534 | } else if (this.char === CHAR_SP || this.char === CTRL_I) {
|
22535 | return this.next(this.parsePreMultiTrim);
|
22536 | } else {
|
22537 | return this.goto(this.parseEscape);
|
22538 | }
|
22539 | }
|
22540 |
|
22541 | parsePreMultiTrim() {
|
22542 | if (this.char === CHAR_SP || this.char === CTRL_I) {
|
22543 | return null;
|
22544 | } else if (this.char === CTRL_M || this.char === CTRL_J) {
|
22545 | return this.next(this.parseMultiTrim);
|
22546 | } else {
|
22547 | throw this.error(new TomlError("Can't escape whitespace"));
|
22548 | }
|
22549 | }
|
22550 |
|
22551 | parseMultiTrim() {
|
22552 |
|
22553 | if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
|
22554 | return null;
|
22555 | } else {
|
22556 | return this.returnNow();
|
22557 | }
|
22558 | }
|
22559 |
|
22560 | parseEscape() {
|
22561 | if (this.char in escapes) {
|
22562 | return this.return(escapes[this.char]);
|
22563 | } else if (this.char === CHAR_u) {
|
22564 | return this.call(this.parseSmallUnicode, this.parseUnicodeReturn);
|
22565 | } else if (this.char === CHAR_U) {
|
22566 | return this.call(this.parseLargeUnicode, this.parseUnicodeReturn);
|
22567 | } else {
|
22568 | throw this.error(new TomlError('Unknown escape character: ' + this.char));
|
22569 | }
|
22570 | }
|
22571 |
|
22572 | parseUnicodeReturn(char) {
|
22573 | try {
|
22574 | const codePoint = parseInt(char, 16);
|
22575 |
|
22576 | if (codePoint >= SURROGATE_FIRST && codePoint <= SURROGATE_LAST) {
|
22577 | throw this.error(new TomlError('Invalid unicode, character in range 0xD800 - 0xDFFF is reserved'));
|
22578 | }
|
22579 |
|
22580 | return this.returnNow(String.fromCodePoint(codePoint));
|
22581 | } catch (err) {
|
22582 | throw this.error(TomlError.wrap(err));
|
22583 | }
|
22584 | }
|
22585 |
|
22586 | parseSmallUnicode() {
|
22587 | if (!isHexit(this.char)) {
|
22588 | throw this.error(new TomlError('Invalid character in unicode sequence, expected hex'));
|
22589 | } else {
|
22590 | this.consume();
|
22591 | if (this.state.buf.length >= 4) return this.return();
|
22592 | }
|
22593 | }
|
22594 |
|
22595 | parseLargeUnicode() {
|
22596 | if (!isHexit(this.char)) {
|
22597 | throw this.error(new TomlError('Invalid character in unicode sequence, expected hex'));
|
22598 | } else {
|
22599 | this.consume();
|
22600 | if (this.state.buf.length >= 8) return this.return();
|
22601 | }
|
22602 | }
|
22603 |
|
22604 |
|
22605 |
|
22606 | parseNumberSign() {
|
22607 | this.consume();
|
22608 | return this.next(this.parseMaybeSignedInfOrNan);
|
22609 | }
|
22610 |
|
22611 | parseMaybeSignedInfOrNan() {
|
22612 | if (this.char === CHAR_i) {
|
22613 | return this.next(this.parseInf);
|
22614 | } else if (this.char === CHAR_n) {
|
22615 | return this.next(this.parseNan);
|
22616 | } else {
|
22617 | return this.callNow(this.parseNoUnder, this.parseNumberIntegerStart);
|
22618 | }
|
22619 | }
|
22620 |
|
22621 | parseNumberIntegerStart() {
|
22622 | if (this.char === CHAR_0) {
|
22623 | this.consume();
|
22624 | return this.next(this.parseNumberIntegerExponentOrDecimal);
|
22625 | } else {
|
22626 | return this.goto(this.parseNumberInteger);
|
22627 | }
|
22628 | }
|
22629 |
|
22630 | parseNumberIntegerExponentOrDecimal() {
|
22631 | if (this.char === CHAR_PERIOD) {
|
22632 | this.consume();
|
22633 | return this.call(this.parseNoUnder, this.parseNumberFloat);
|
22634 | } else if (this.char === CHAR_E || this.char === CHAR_e) {
|
22635 | this.consume();
|
22636 | return this.next(this.parseNumberExponentSign);
|
22637 | } else {
|
22638 | return this.returnNow(Integer(this.state.buf));
|
22639 | }
|
22640 | }
|
22641 |
|
22642 | parseNumberInteger() {
|
22643 | if (isDigit(this.char)) {
|
22644 | this.consume();
|
22645 | } else if (this.char === CHAR_LOWBAR) {
|
22646 | return this.call(this.parseNoUnder);
|
22647 | } else if (this.char === CHAR_E || this.char === CHAR_e) {
|
22648 | this.consume();
|
22649 | return this.next(this.parseNumberExponentSign);
|
22650 | } else if (this.char === CHAR_PERIOD) {
|
22651 | this.consume();
|
22652 | return this.call(this.parseNoUnder, this.parseNumberFloat);
|
22653 | } else {
|
22654 | const result = Integer(this.state.buf);
|
22655 |
|
22656 |
|
22657 | if (result.isNaN()) {
|
22658 | throw this.error(new TomlError('Invalid number'));
|
22659 | } else {
|
22660 | return this.returnNow(result);
|
22661 | }
|
22662 | }
|
22663 | }
|
22664 |
|
22665 | parseNoUnder() {
|
22666 | if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD || this.char === CHAR_E || this.char === CHAR_e) {
|
22667 | throw this.error(new TomlError('Unexpected character, expected digit'));
|
22668 | } else if (this.atEndOfWord()) {
|
22669 | throw this.error(new TomlError('Incomplete number'));
|
22670 | }
|
22671 |
|
22672 | return this.returnNow();
|
22673 | }
|
22674 |
|
22675 | parseNumberFloat() {
|
22676 | if (this.char === CHAR_LOWBAR) {
|
22677 | return this.call(this.parseNoUnder, this.parseNumberFloat);
|
22678 | } else if (isDigit(this.char)) {
|
22679 | this.consume();
|
22680 | } else if (this.char === CHAR_E || this.char === CHAR_e) {
|
22681 | this.consume();
|
22682 | return this.next(this.parseNumberExponentSign);
|
22683 | } else {
|
22684 | return this.returnNow(Float(this.state.buf));
|
22685 | }
|
22686 | }
|
22687 |
|
22688 | parseNumberExponentSign() {
|
22689 | if (isDigit(this.char)) {
|
22690 | return this.goto(this.parseNumberExponent);
|
22691 | } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
|
22692 | this.consume();
|
22693 | this.call(this.parseNoUnder, this.parseNumberExponent);
|
22694 | } else {
|
22695 | throw this.error(new TomlError('Unexpected character, expected -, + or digit'));
|
22696 | }
|
22697 | }
|
22698 |
|
22699 | parseNumberExponent() {
|
22700 | if (isDigit(this.char)) {
|
22701 | this.consume();
|
22702 | } else if (this.char === CHAR_LOWBAR) {
|
22703 | return this.call(this.parseNoUnder);
|
22704 | } else {
|
22705 | return this.returnNow(Float(this.state.buf));
|
22706 | }
|
22707 | }
|
22708 |
|
22709 |
|
22710 |
|
22711 | parseNumberOrDateTime() {
|
22712 | if (this.char === CHAR_0) {
|
22713 | this.consume();
|
22714 | return this.next(this.parseNumberBaseOrDateTime);
|
22715 | } else {
|
22716 | return this.goto(this.parseNumberOrDateTimeOnly);
|
22717 | }
|
22718 | }
|
22719 |
|
22720 | parseNumberOrDateTimeOnly() {
|
22721 |
|
22722 | if (this.char === CHAR_LOWBAR) {
|
22723 | return this.call(this.parseNoUnder, this.parseNumberInteger);
|
22724 | } else if (isDigit(this.char)) {
|
22725 | this.consume();
|
22726 | if (this.state.buf.length > 4) this.next(this.parseNumberInteger);
|
22727 | } else if (this.char === CHAR_E || this.char === CHAR_e) {
|
22728 | this.consume();
|
22729 | return this.next(this.parseNumberExponentSign);
|
22730 | } else if (this.char === CHAR_PERIOD) {
|
22731 | this.consume();
|
22732 | return this.call(this.parseNoUnder, this.parseNumberFloat);
|
22733 | } else if (this.char === CHAR_HYPHEN) {
|
22734 | return this.goto(this.parseDateTime);
|
22735 | } else if (this.char === CHAR_COLON) {
|
22736 | return this.goto(this.parseOnlyTimeHour);
|
22737 | } else {
|
22738 | return this.returnNow(Integer(this.state.buf));
|
22739 | }
|
22740 | }
|
22741 |
|
22742 | parseDateTimeOnly() {
|
22743 | if (this.state.buf.length < 4) {
|
22744 | if (isDigit(this.char)) {
|
22745 | return this.consume();
|
22746 | } else if (this.char === CHAR_COLON) {
|
22747 | return this.goto(this.parseOnlyTimeHour);
|
22748 | } else {
|
22749 | throw this.error(new TomlError('Expected digit while parsing year part of a date'));
|
22750 | }
|
22751 | } else {
|
22752 | if (this.char === CHAR_HYPHEN) {
|
22753 | return this.goto(this.parseDateTime);
|
22754 | } else {
|
22755 | throw this.error(new TomlError('Expected hyphen (-) while parsing year part of date'));
|
22756 | }
|
22757 | }
|
22758 | }
|
22759 |
|
22760 | parseNumberBaseOrDateTime() {
|
22761 | if (this.char === CHAR_b) {
|
22762 | this.consume();
|
22763 | return this.call(this.parseNoUnder, this.parseIntegerBin);
|
22764 | } else if (this.char === CHAR_o) {
|
22765 | this.consume();
|
22766 | return this.call(this.parseNoUnder, this.parseIntegerOct);
|
22767 | } else if (this.char === CHAR_x) {
|
22768 | this.consume();
|
22769 | return this.call(this.parseNoUnder, this.parseIntegerHex);
|
22770 | } else if (this.char === CHAR_PERIOD) {
|
22771 | return this.goto(this.parseNumberInteger);
|
22772 | } else if (isDigit(this.char)) {
|
22773 | return this.goto(this.parseDateTimeOnly);
|
22774 | } else {
|
22775 | return this.returnNow(Integer(this.state.buf));
|
22776 | }
|
22777 | }
|
22778 |
|
22779 | parseIntegerHex() {
|
22780 | if (isHexit(this.char)) {
|
22781 | this.consume();
|
22782 | } else if (this.char === CHAR_LOWBAR) {
|
22783 | return this.call(this.parseNoUnder);
|
22784 | } else {
|
22785 | const result = Integer(this.state.buf);
|
22786 |
|
22787 |
|
22788 | if (result.isNaN()) {
|
22789 | throw this.error(new TomlError('Invalid number'));
|
22790 | } else {
|
22791 | return this.returnNow(result);
|
22792 | }
|
22793 | }
|
22794 | }
|
22795 |
|
22796 | parseIntegerOct() {
|
22797 | if (isOctit(this.char)) {
|
22798 | this.consume();
|
22799 | } else if (this.char === CHAR_LOWBAR) {
|
22800 | return this.call(this.parseNoUnder);
|
22801 | } else {
|
22802 | const result = Integer(this.state.buf);
|
22803 |
|
22804 |
|
22805 | if (result.isNaN()) {
|
22806 | throw this.error(new TomlError('Invalid number'));
|
22807 | } else {
|
22808 | return this.returnNow(result);
|
22809 | }
|
22810 | }
|
22811 | }
|
22812 |
|
22813 | parseIntegerBin() {
|
22814 | if (isBit(this.char)) {
|
22815 | this.consume();
|
22816 | } else if (this.char === CHAR_LOWBAR) {
|
22817 | return this.call(this.parseNoUnder);
|
22818 | } else {
|
22819 | const result = Integer(this.state.buf);
|
22820 |
|
22821 |
|
22822 | if (result.isNaN()) {
|
22823 | throw this.error(new TomlError('Invalid number'));
|
22824 | } else {
|
22825 | return this.returnNow(result);
|
22826 | }
|
22827 | }
|
22828 | }
|
22829 |
|
22830 |
|
22831 |
|
22832 | parseDateTime() {
|
22833 |
|
22834 | if (this.state.buf.length < 4) {
|
22835 | throw this.error(new TomlError('Years less than 1000 must be zero padded to four characters'));
|
22836 | }
|
22837 |
|
22838 | this.state.result = this.state.buf;
|
22839 | this.state.buf = '';
|
22840 | return this.next(this.parseDateMonth);
|
22841 | }
|
22842 |
|
22843 | parseDateMonth() {
|
22844 | if (this.char === CHAR_HYPHEN) {
|
22845 | if (this.state.buf.length < 2) {
|
22846 | throw this.error(new TomlError('Months less than 10 must be zero padded to two characters'));
|
22847 | }
|
22848 |
|
22849 | this.state.result += '-' + this.state.buf;
|
22850 | this.state.buf = '';
|
22851 | return this.next(this.parseDateDay);
|
22852 | } else if (isDigit(this.char)) {
|
22853 | this.consume();
|
22854 | } else {
|
22855 | throw this.error(new TomlError('Incomplete datetime'));
|
22856 | }
|
22857 | }
|
22858 |
|
22859 | parseDateDay() {
|
22860 | if (this.char === CHAR_T || this.char === CHAR_SP) {
|
22861 | if (this.state.buf.length < 2) {
|
22862 | throw this.error(new TomlError('Days less than 10 must be zero padded to two characters'));
|
22863 | }
|
22864 |
|
22865 | this.state.result += '-' + this.state.buf;
|
22866 | this.state.buf = '';
|
22867 | return this.next(this.parseStartTimeHour);
|
22868 | } else if (this.atEndOfWord()) {
|
22869 | return this.return(createDate(this.state.result + '-' + this.state.buf));
|
22870 | } else if (isDigit(this.char)) {
|
22871 | this.consume();
|
22872 | } else {
|
22873 | throw this.error(new TomlError('Incomplete datetime'));
|
22874 | }
|
22875 | }
|
22876 |
|
22877 | parseStartTimeHour() {
|
22878 | if (this.atEndOfWord()) {
|
22879 | return this.returnNow(createDate(this.state.result));
|
22880 | } else {
|
22881 | return this.goto(this.parseTimeHour);
|
22882 | }
|
22883 | }
|
22884 |
|
22885 | parseTimeHour() {
|
22886 | if (this.char === CHAR_COLON) {
|
22887 | if (this.state.buf.length < 2) {
|
22888 | throw this.error(new TomlError('Hours less than 10 must be zero padded to two characters'));
|
22889 | }
|
22890 |
|
22891 | this.state.result += 'T' + this.state.buf;
|
22892 | this.state.buf = '';
|
22893 | return this.next(this.parseTimeMin);
|
22894 | } else if (isDigit(this.char)) {
|
22895 | this.consume();
|
22896 | } else {
|
22897 | throw this.error(new TomlError('Incomplete datetime'));
|
22898 | }
|
22899 | }
|
22900 |
|
22901 | parseTimeMin() {
|
22902 | if (this.state.buf.length < 2 && isDigit(this.char)) {
|
22903 | this.consume();
|
22904 | } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) {
|
22905 | this.state.result += ':' + this.state.buf;
|
22906 | this.state.buf = '';
|
22907 | return this.next(this.parseTimeSec);
|
22908 | } else {
|
22909 | throw this.error(new TomlError('Incomplete datetime'));
|
22910 | }
|
22911 | }
|
22912 |
|
22913 | parseTimeSec() {
|
22914 | if (isDigit(this.char)) {
|
22915 | this.consume();
|
22916 |
|
22917 | if (this.state.buf.length === 2) {
|
22918 | this.state.result += ':' + this.state.buf;
|
22919 | this.state.buf = '';
|
22920 | return this.next(this.parseTimeZoneOrFraction);
|
22921 | }
|
22922 | } else {
|
22923 | throw this.error(new TomlError('Incomplete datetime'));
|
22924 | }
|
22925 | }
|
22926 |
|
22927 | parseOnlyTimeHour() {
|
22928 |
|
22929 | if (this.char === CHAR_COLON) {
|
22930 | if (this.state.buf.length < 2) {
|
22931 | throw this.error(new TomlError('Hours less than 10 must be zero padded to two characters'));
|
22932 | }
|
22933 |
|
22934 | this.state.result = this.state.buf;
|
22935 | this.state.buf = '';
|
22936 | return this.next(this.parseOnlyTimeMin);
|
22937 | } else {
|
22938 | throw this.error(new TomlError('Incomplete time'));
|
22939 | }
|
22940 | }
|
22941 |
|
22942 | parseOnlyTimeMin() {
|
22943 | if (this.state.buf.length < 2 && isDigit(this.char)) {
|
22944 | this.consume();
|
22945 | } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) {
|
22946 | this.state.result += ':' + this.state.buf;
|
22947 | this.state.buf = '';
|
22948 | return this.next(this.parseOnlyTimeSec);
|
22949 | } else {
|
22950 | throw this.error(new TomlError('Incomplete time'));
|
22951 | }
|
22952 | }
|
22953 |
|
22954 | parseOnlyTimeSec() {
|
22955 | if (isDigit(this.char)) {
|
22956 | this.consume();
|
22957 |
|
22958 | if (this.state.buf.length === 2) {
|
22959 | return this.next(this.parseOnlyTimeFractionMaybe);
|
22960 | }
|
22961 | } else {
|
22962 | throw this.error(new TomlError('Incomplete time'));
|
22963 | }
|
22964 | }
|
22965 |
|
22966 | parseOnlyTimeFractionMaybe() {
|
22967 | this.state.result += ':' + this.state.buf;
|
22968 |
|
22969 | if (this.char === CHAR_PERIOD) {
|
22970 | this.state.buf = '';
|
22971 | this.next(this.parseOnlyTimeFraction);
|
22972 | } else {
|
22973 | return this.return(createTime(this.state.result));
|
22974 | }
|
22975 | }
|
22976 |
|
22977 | parseOnlyTimeFraction() {
|
22978 | if (isDigit(this.char)) {
|
22979 | this.consume();
|
22980 | } else if (this.atEndOfWord()) {
|
22981 | if (this.state.buf.length === 0) throw this.error(new TomlError('Expected digit in milliseconds'));
|
22982 | return this.returnNow(createTime(this.state.result + '.' + this.state.buf));
|
22983 | } else {
|
22984 | throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
|
22985 | }
|
22986 | }
|
22987 |
|
22988 | parseTimeZoneOrFraction() {
|
22989 | if (this.char === CHAR_PERIOD) {
|
22990 | this.consume();
|
22991 | this.next(this.parseDateTimeFraction);
|
22992 | } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
|
22993 | this.consume();
|
22994 | this.next(this.parseTimeZoneHour);
|
22995 | } else if (this.char === CHAR_Z) {
|
22996 | this.consume();
|
22997 | return this.return(createDatetime(this.state.result + this.state.buf));
|
22998 | } else if (this.atEndOfWord()) {
|
22999 | return this.returnNow(createDatetimeFloat(this.state.result + this.state.buf));
|
23000 | } else {
|
23001 | throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
|
23002 | }
|
23003 | }
|
23004 |
|
23005 | parseDateTimeFraction() {
|
23006 | if (isDigit(this.char)) {
|
23007 | this.consume();
|
23008 | } else if (this.state.buf.length === 1) {
|
23009 | throw this.error(new TomlError('Expected digit in milliseconds'));
|
23010 | } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
|
23011 | this.consume();
|
23012 | this.next(this.parseTimeZoneHour);
|
23013 | } else if (this.char === CHAR_Z) {
|
23014 | this.consume();
|
23015 | return this.return(createDatetime(this.state.result + this.state.buf));
|
23016 | } else if (this.atEndOfWord()) {
|
23017 | return this.returnNow(createDatetimeFloat(this.state.result + this.state.buf));
|
23018 | } else {
|
23019 | throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
|
23020 | }
|
23021 | }
|
23022 |
|
23023 | parseTimeZoneHour() {
|
23024 | if (isDigit(this.char)) {
|
23025 | this.consume();
|
23026 |
|
23027 | if (/\d\d$/.test(this.state.buf)) return this.next(this.parseTimeZoneSep);
|
23028 | } else {
|
23029 | throw this.error(new TomlError('Unexpected character in datetime, expected digit'));
|
23030 | }
|
23031 | }
|
23032 |
|
23033 | parseTimeZoneSep() {
|
23034 | if (this.char === CHAR_COLON) {
|
23035 | this.consume();
|
23036 | this.next(this.parseTimeZoneMin);
|
23037 | } else {
|
23038 | throw this.error(new TomlError('Unexpected character in datetime, expected colon'));
|
23039 | }
|
23040 | }
|
23041 |
|
23042 | parseTimeZoneMin() {
|
23043 | if (isDigit(this.char)) {
|
23044 | this.consume();
|
23045 | if (/\d\d$/.test(this.state.buf)) return this.return(createDatetime(this.state.result + this.state.buf));
|
23046 | } else {
|
23047 | throw this.error(new TomlError('Unexpected character in datetime, expected digit'));
|
23048 | }
|
23049 | }
|
23050 |
|
23051 |
|
23052 |
|
23053 | parseBoolean() {
|
23054 |
|
23055 | if (this.char === CHAR_t) {
|
23056 | this.consume();
|
23057 | return this.next(this.parseTrue_r);
|
23058 | } else if (this.char === CHAR_f) {
|
23059 | this.consume();
|
23060 | return this.next(this.parseFalse_a);
|
23061 | }
|
23062 | }
|
23063 |
|
23064 | parseTrue_r() {
|
23065 | if (this.char === CHAR_r) {
|
23066 | this.consume();
|
23067 | return this.next(this.parseTrue_u);
|
23068 | } else {
|
23069 | throw this.error(new TomlError('Invalid boolean, expected true or false'));
|
23070 | }
|
23071 | }
|
23072 |
|
23073 | parseTrue_u() {
|
23074 | if (this.char === CHAR_u) {
|
23075 | this.consume();
|
23076 | return this.next(this.parseTrue_e);
|
23077 | } else {
|
23078 | throw this.error(new TomlError('Invalid boolean, expected true or false'));
|
23079 | }
|
23080 | }
|
23081 |
|
23082 | parseTrue_e() {
|
23083 | if (this.char === CHAR_e) {
|
23084 | return this.return(true);
|
23085 | } else {
|
23086 | throw this.error(new TomlError('Invalid boolean, expected true or false'));
|
23087 | }
|
23088 | }
|
23089 |
|
23090 | parseFalse_a() {
|
23091 | if (this.char === CHAR_a) {
|
23092 | this.consume();
|
23093 | return this.next(this.parseFalse_l);
|
23094 | } else {
|
23095 | throw this.error(new TomlError('Invalid boolean, expected true or false'));
|
23096 | }
|
23097 | }
|
23098 |
|
23099 | parseFalse_l() {
|
23100 | if (this.char === CHAR_l) {
|
23101 | this.consume();
|
23102 | return this.next(this.parseFalse_s);
|
23103 | } else {
|
23104 | throw this.error(new TomlError('Invalid boolean, expected true or false'));
|
23105 | }
|
23106 | }
|
23107 |
|
23108 | parseFalse_s() {
|
23109 | if (this.char === CHAR_s) {
|
23110 | this.consume();
|
23111 | return this.next(this.parseFalse_e);
|
23112 | } else {
|
23113 | throw this.error(new TomlError('Invalid boolean, expected true or false'));
|
23114 | }
|
23115 | }
|
23116 |
|
23117 | parseFalse_e() {
|
23118 | if (this.char === CHAR_e) {
|
23119 | return this.return(false);
|
23120 | } else {
|
23121 | throw this.error(new TomlError('Invalid boolean, expected true or false'));
|
23122 | }
|
23123 | }
|
23124 |
|
23125 |
|
23126 |
|
23127 | parseInlineList() {
|
23128 | if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) {
|
23129 | return null;
|
23130 | } else if (this.char === Parser.END) {
|
23131 | throw this.error(new TomlError('Unterminated inline array'));
|
23132 | } else if (this.char === CHAR_NUM) {
|
23133 | return this.call(this.parseComment);
|
23134 | } else if (this.char === CHAR_RSQB) {
|
23135 | return this.return(this.state.resultArr || InlineList());
|
23136 | } else {
|
23137 | return this.callNow(this.parseValue, this.recordInlineListValue);
|
23138 | }
|
23139 | }
|
23140 |
|
23141 | recordInlineListValue(value) {
|
23142 | if (this.state.resultArr) {
|
23143 | const listType = this.state.resultArr[_contentType];
|
23144 | const valueType = tomlType(value);
|
23145 |
|
23146 | if (listType !== valueType) {
|
23147 | throw this.error(new TomlError(`Inline lists must be a single type, not a mix of ${listType} and ${valueType}`));
|
23148 | }
|
23149 | } else {
|
23150 | this.state.resultArr = InlineList(tomlType(value));
|
23151 | }
|
23152 |
|
23153 | if (isFloat(value) || isInteger(value)) {
|
23154 |
|
23155 | this.state.resultArr.push(value.valueOf());
|
23156 | } else {
|
23157 | this.state.resultArr.push(value);
|
23158 | }
|
23159 |
|
23160 | return this.goto(this.parseInlineListNext);
|
23161 | }
|
23162 |
|
23163 | parseInlineListNext() {
|
23164 | if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) {
|
23165 | return null;
|
23166 | } else if (this.char === CHAR_NUM) {
|
23167 | return this.call(this.parseComment);
|
23168 | } else if (this.char === CHAR_COMMA) {
|
23169 | return this.next(this.parseInlineList);
|
23170 | } else if (this.char === CHAR_RSQB) {
|
23171 | return this.goto(this.parseInlineList);
|
23172 | } else {
|
23173 | throw this.error(new TomlError('Invalid character, expected whitespace, comma (,) or close bracket (])'));
|
23174 | }
|
23175 | }
|
23176 |
|
23177 |
|
23178 |
|
23179 | parseInlineTable() {
|
23180 | if (this.char === CHAR_SP || this.char === CTRL_I) {
|
23181 | return null;
|
23182 | } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
|
23183 | throw this.error(new TomlError('Unterminated inline array'));
|
23184 | } else if (this.char === CHAR_RCUB) {
|
23185 | return this.return(this.state.resultTable || InlineTable());
|
23186 | } else {
|
23187 | if (!this.state.resultTable) this.state.resultTable = InlineTable();
|
23188 | return this.callNow(this.parseAssign, this.recordInlineTableValue);
|
23189 | }
|
23190 | }
|
23191 |
|
23192 | recordInlineTableValue(kv) {
|
23193 | let target = this.state.resultTable;
|
23194 | let finalKey = kv.key.pop();
|
23195 |
|
23196 | for (let kw of kv.key) {
|
23197 | if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) {
|
23198 | throw this.error(new TomlError("Can't redefine existing key"));
|
23199 | }
|
23200 |
|
23201 | target = target[kw] = target[kw] || Table();
|
23202 | }
|
23203 |
|
23204 | if (hasKey(target, finalKey)) {
|
23205 | throw this.error(new TomlError("Can't redefine existing key"));
|
23206 | }
|
23207 |
|
23208 | if (isInteger(kv.value) || isFloat(kv.value)) {
|
23209 | target[finalKey] = kv.value.valueOf();
|
23210 | } else {
|
23211 | target[finalKey] = kv.value;
|
23212 | }
|
23213 |
|
23214 | return this.goto(this.parseInlineTableNext);
|
23215 | }
|
23216 |
|
23217 | parseInlineTableNext() {
|
23218 | if (this.char === CHAR_SP || this.char === CTRL_I) {
|
23219 | return null;
|
23220 | } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
|
23221 | throw this.error(new TomlError('Unterminated inline array'));
|
23222 | } else if (this.char === CHAR_COMMA) {
|
23223 | return this.next(this.parseInlineTable);
|
23224 | } else if (this.char === CHAR_RCUB) {
|
23225 | return this.goto(this.parseInlineTable);
|
23226 | } else {
|
23227 | throw this.error(new TomlError('Invalid character, expected whitespace, comma (,) or close bracket (])'));
|
23228 | }
|
23229 | }
|
23230 |
|
23231 | }
|
23232 |
|
23233 | return TOMLParser;
|
23234 | }
|
23235 | tomlParser.makeParserClass = makeParserClass_1;
|
23236 | tomlParser.TomlError = TomlError_1;
|
23237 |
|
23238 | var parsePrettyError = prettyError;
|
23239 |
|
23240 | function prettyError(err, buf) {
|
23241 |
|
23242 | if (err.pos == null || err.line == null) return err;
|
23243 | let msg = err.message;
|
23244 | msg += ` at row ${err.line + 1}, col ${err.col + 1}, pos ${err.pos}:\n`;
|
23245 |
|
23246 |
|
23247 | if (buf && buf.split) {
|
23248 | const lines = buf.split(/\n/);
|
23249 | const lineNumWidth = String(Math.min(lines.length, err.line + 3)).length;
|
23250 | let linePadding = ' ';
|
23251 |
|
23252 | while (linePadding.length < lineNumWidth) linePadding += ' ';
|
23253 |
|
23254 | for (let ii = Math.max(0, err.line - 1); ii < Math.min(lines.length, err.line + 2); ++ii) {
|
23255 | let lineNum = String(ii + 1);
|
23256 | if (lineNum.length < lineNumWidth) lineNum = ' ' + lineNum;
|
23257 |
|
23258 | if (err.line === ii) {
|
23259 | msg += lineNum + '> ' + lines[ii] + '\n';
|
23260 | msg += linePadding + ' ';
|
23261 |
|
23262 | for (let hh = 0; hh < err.col; ++hh) {
|
23263 | msg += ' ';
|
23264 | }
|
23265 |
|
23266 | msg += '^\n';
|
23267 | } else {
|
23268 | msg += lineNum + ': ' + lines[ii] + '\n';
|
23269 | }
|
23270 | }
|
23271 | }
|
23272 |
|
23273 | err.message = msg + '\n';
|
23274 | return err;
|
23275 | }
|
23276 |
|
23277 | var parseString_1 = parseString;
|
23278 |
|
23279 | function parseString(str) {
|
23280 | if (global.Buffer && global.Buffer.isBuffer(str)) {
|
23281 | str = str.toString('utf8');
|
23282 | }
|
23283 |
|
23284 | const parser = new tomlParser();
|
23285 |
|
23286 | try {
|
23287 | parser.parse(str);
|
23288 | return parser.finish();
|
23289 | } catch (err) {
|
23290 | throw parsePrettyError(err, str);
|
23291 | }
|
23292 | }
|
23293 |
|
23294 | var loadToml = function (filePath, content) {
|
23295 | try {
|
23296 | return parseString_1(content);
|
23297 | } catch (error) {
|
23298 | error.message = `TOML Error in ${filePath}:\n${error.message}`;
|
23299 | throw error;
|
23300 | }
|
23301 | };
|
23302 |
|
23303 | var caller = function () {
|
23304 |
|
23305 | var origPrepareStackTrace = Error.prepareStackTrace;
|
23306 |
|
23307 | Error.prepareStackTrace = function (_, stack) {
|
23308 | return stack;
|
23309 | };
|
23310 |
|
23311 | var stack = new Error().stack;
|
23312 | Error.prepareStackTrace = origPrepareStackTrace;
|
23313 | return stack[2].getFileName();
|
23314 | };
|
23315 |
|
23316 | var pathParse = createCommonjsModule(function (module) {
|
23317 |
|
23318 | var isWindows = process.platform === 'win32';
|
23319 |
|
23320 |
|
23321 | var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
|
23322 |
|
23323 | var splitTailRe = /^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/;
|
23324 | var win32 = {};
|
23325 |
|
23326 | function win32SplitPath(filename) {
|
23327 |
|
23328 | var result = splitDeviceRe.exec(filename),
|
23329 | device = (result[1] || '') + (result[2] || ''),
|
23330 | tail = result[3] || '';
|
23331 |
|
23332 | var result2 = splitTailRe.exec(tail),
|
23333 | dir = result2[1],
|
23334 | basename = result2[2],
|
23335 | ext = result2[3];
|
23336 | return [device, dir, basename, ext];
|
23337 | }
|
23338 |
|
23339 | win32.parse = function (pathString) {
|
23340 | if (typeof pathString !== 'string') {
|
23341 | throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
|
23342 | }
|
23343 |
|
23344 | var allParts = win32SplitPath(pathString);
|
23345 |
|
23346 | if (!allParts || allParts.length !== 4) {
|
23347 | throw new TypeError("Invalid path '" + pathString + "'");
|
23348 | }
|
23349 |
|
23350 | return {
|
23351 | root: allParts[0],
|
23352 | dir: allParts[0] + allParts[1].slice(0, -1),
|
23353 | base: allParts[2],
|
23354 | ext: allParts[3],
|
23355 | name: allParts[2].slice(0, allParts[2].length - allParts[3].length)
|
23356 | };
|
23357 | };
|
23358 |
|
23359 |
|
23360 |
|
23361 | var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
|
23362 | var posix = {};
|
23363 |
|
23364 | function posixSplitPath(filename) {
|
23365 | return splitPathRe.exec(filename).slice(1);
|
23366 | }
|
23367 |
|
23368 | posix.parse = function (pathString) {
|
23369 | if (typeof pathString !== 'string') {
|
23370 | throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
|
23371 | }
|
23372 |
|
23373 | var allParts = posixSplitPath(pathString);
|
23374 |
|
23375 | if (!allParts || allParts.length !== 4) {
|
23376 | throw new TypeError("Invalid path '" + pathString + "'");
|
23377 | }
|
23378 |
|
23379 | allParts[1] = allParts[1] || '';
|
23380 | allParts[2] = allParts[2] || '';
|
23381 | allParts[3] = allParts[3] || '';
|
23382 | return {
|
23383 | root: allParts[0],
|
23384 | dir: allParts[0] + allParts[1].slice(0, -1),
|
23385 | base: allParts[2],
|
23386 | ext: allParts[3],
|
23387 | name: allParts[2].slice(0, allParts[2].length - allParts[3].length)
|
23388 | };
|
23389 | };
|
23390 |
|
23391 | if (isWindows) module.exports = win32.parse;else
|
23392 |
|
23393 | module.exports = posix.parse;
|
23394 | module.exports.posix = posix.parse;
|
23395 | module.exports.win32 = win32.parse;
|
23396 | });
|
23397 | var pathParse_1 = pathParse.posix;
|
23398 | var pathParse_2 = pathParse.win32;
|
23399 |
|
23400 | var parse$2 = path$2.parse || pathParse;
|
23401 |
|
23402 | var getNodeModulesDirs = function getNodeModulesDirs(absoluteStart, modules) {
|
23403 | var prefix = '/';
|
23404 |
|
23405 | if (/^([A-Za-z]:)/.test(absoluteStart)) {
|
23406 | prefix = '';
|
23407 | } else if (/^\\\\/.test(absoluteStart)) {
|
23408 | prefix = '\\\\';
|
23409 | }
|
23410 |
|
23411 | var paths = [absoluteStart];
|
23412 | var parsed = parse$2(absoluteStart);
|
23413 |
|
23414 | while (parsed.dir !== paths[paths.length - 1]) {
|
23415 | paths.push(parsed.dir);
|
23416 | parsed = parse$2(parsed.dir);
|
23417 | }
|
23418 |
|
23419 | return paths.reduce(function (dirs, aPath) {
|
23420 | return dirs.concat(modules.map(function (moduleDir) {
|
23421 | return path$2.resolve(prefix, aPath, moduleDir);
|
23422 | }));
|
23423 | }, []);
|
23424 | };
|
23425 |
|
23426 | var nodeModulesPaths = function nodeModulesPaths(start, opts, request) {
|
23427 | var modules = opts && opts.moduleDirectory ? [].concat(opts.moduleDirectory) : ['node_modules'];
|
23428 |
|
23429 | if (opts && typeof opts.paths === 'function') {
|
23430 | return opts.paths(request, start, function () {
|
23431 | return getNodeModulesDirs(start, modules);
|
23432 | }, opts);
|
23433 | }
|
23434 |
|
23435 | var dirs = getNodeModulesDirs(start, modules);
|
23436 | return opts && opts.paths ? dirs.concat(opts.paths) : dirs;
|
23437 | };
|
23438 |
|
23439 | var normalizeOptions$2 = function (x, opts) {
|
23440 | |
23441 |
|
23442 |
|
23443 |
|
23444 |
|
23445 |
|
23446 | return opts || {};
|
23447 | };
|
23448 |
|
23449 | var assert = true;
|
23450 | var async_hooks = ">= 8";
|
23451 | var buffer_ieee754 = "< 0.9.7";
|
23452 | var buffer = true;
|
23453 | var child_process = true;
|
23454 | var cluster = true;
|
23455 | var console$1 = true;
|
23456 | var constants$1 = true;
|
23457 | var crypto = true;
|
23458 | var _debug_agent = ">= 1 && < 8";
|
23459 | var _debugger = "< 8";
|
23460 | var dgram = true;
|
23461 | var dns = true;
|
23462 | var domain = true;
|
23463 | var events = true;
|
23464 | var freelist = "< 6";
|
23465 | var fs = true;
|
23466 | var _http_agent = ">= 0.11.1";
|
23467 | var _http_client = ">= 0.11.1";
|
23468 | var _http_common = ">= 0.11.1";
|
23469 | var _http_incoming = ">= 0.11.1";
|
23470 | var _http_outgoing = ">= 0.11.1";
|
23471 | var _http_server = ">= 0.11.1";
|
23472 | var http = true;
|
23473 | var http2 = ">= 8.8";
|
23474 | var https = true;
|
23475 | var inspector = ">= 8.0.0";
|
23476 | var _linklist = "< 8";
|
23477 | var module$1 = true;
|
23478 | var net = true;
|
23479 | var os = true;
|
23480 | var path$1 = true;
|
23481 | var perf_hooks = ">= 8.5";
|
23482 | var process$1 = ">= 1";
|
23483 | var punycode = true;
|
23484 | var querystring = true;
|
23485 | var readline = true;
|
23486 | var repl = true;
|
23487 | var smalloc = ">= 0.11.5 && < 3";
|
23488 | var _stream_duplex = ">= 0.9.4";
|
23489 | var _stream_transform = ">= 0.9.4";
|
23490 | var _stream_wrap = ">= 1.4.1";
|
23491 | var _stream_passthrough = ">= 0.9.4";
|
23492 | var _stream_readable = ">= 0.9.4";
|
23493 | var _stream_writable = ">= 0.9.4";
|
23494 | var stream = true;
|
23495 | var string_decoder = true;
|
23496 | var sys = true;
|
23497 | var timers = true;
|
23498 | var _tls_common = ">= 0.11.13";
|
23499 | var _tls_legacy = ">= 0.11.3 && < 10";
|
23500 | var _tls_wrap = ">= 0.11.3";
|
23501 | var tls = true;
|
23502 | var trace_events = ">= 10";
|
23503 | var tty = true;
|
23504 | var url = true;
|
23505 | var util$2 = true;
|
23506 | var v8 = ">= 1";
|
23507 | var vm = true;
|
23508 | var wasi = ">= 13.4 && < 13.5";
|
23509 | var worker_threads = ">= 11.7";
|
23510 | var zlib = true;
|
23511 | var core$1 = {
|
23512 | assert: assert,
|
23513 | async_hooks: async_hooks,
|
23514 | buffer_ieee754: buffer_ieee754,
|
23515 | buffer: buffer,
|
23516 | child_process: child_process,
|
23517 | cluster: cluster,
|
23518 | console: console$1,
|
23519 | constants: constants$1,
|
23520 | crypto: crypto,
|
23521 | _debug_agent: _debug_agent,
|
23522 | _debugger: _debugger,
|
23523 | dgram: dgram,
|
23524 | dns: dns,
|
23525 | domain: domain,
|
23526 | events: events,
|
23527 | freelist: freelist,
|
23528 | fs: fs,
|
23529 | "fs/promises": [
|
23530 | ">= 10 && < 10.1",
|
23531 | ">= 14"
|
23532 | ],
|
23533 | _http_agent: _http_agent,
|
23534 | _http_client: _http_client,
|
23535 | _http_common: _http_common,
|
23536 | _http_incoming: _http_incoming,
|
23537 | _http_outgoing: _http_outgoing,
|
23538 | _http_server: _http_server,
|
23539 | http: http,
|
23540 | http2: http2,
|
23541 | https: https,
|
23542 | inspector: inspector,
|
23543 | _linklist: _linklist,
|
23544 | module: module$1,
|
23545 | net: net,
|
23546 | "node-inspect/lib/_inspect": ">= 7.6.0 && < 12",
|
23547 | "node-inspect/lib/internal/inspect_client": ">= 7.6.0 && < 12",
|
23548 | "node-inspect/lib/internal/inspect_repl": ">= 7.6.0 && < 12",
|
23549 | os: os,
|
23550 | path: path$1,
|
23551 | perf_hooks: perf_hooks,
|
23552 | process: process$1,
|
23553 | punycode: punycode,
|
23554 | querystring: querystring,
|
23555 | readline: readline,
|
23556 | repl: repl,
|
23557 | smalloc: smalloc,
|
23558 | _stream_duplex: _stream_duplex,
|
23559 | _stream_transform: _stream_transform,
|
23560 | _stream_wrap: _stream_wrap,
|
23561 | _stream_passthrough: _stream_passthrough,
|
23562 | _stream_readable: _stream_readable,
|
23563 | _stream_writable: _stream_writable,
|
23564 | stream: stream,
|
23565 | string_decoder: string_decoder,
|
23566 | sys: sys,
|
23567 | timers: timers,
|
23568 | _tls_common: _tls_common,
|
23569 | _tls_legacy: _tls_legacy,
|
23570 | _tls_wrap: _tls_wrap,
|
23571 | tls: tls,
|
23572 | trace_events: trace_events,
|
23573 | tty: tty,
|
23574 | url: url,
|
23575 | util: util$2,
|
23576 | "v8/tools/arguments": ">= 10 && < 12",
|
23577 | "v8/tools/codemap": [
|
23578 | ">= 4.4.0 && < 5",
|
23579 | ">= 5.2.0 && < 12"
|
23580 | ],
|
23581 | "v8/tools/consarray": [
|
23582 | ">= 4.4.0 && < 5",
|
23583 | ">= 5.2.0 && < 12"
|
23584 | ],
|
23585 | "v8/tools/csvparser": [
|
23586 | ">= 4.4.0 && < 5",
|
23587 | ">= 5.2.0 && < 12"
|
23588 | ],
|
23589 | "v8/tools/logreader": [
|
23590 | ">= 4.4.0 && < 5",
|
23591 | ">= 5.2.0 && < 12"
|
23592 | ],
|
23593 | "v8/tools/profile_view": [
|
23594 | ">= 4.4.0 && < 5",
|
23595 | ">= 5.2.0 && < 12"
|
23596 | ],
|
23597 | "v8/tools/splaytree": [
|
23598 | ">= 4.4.0 && < 5",
|
23599 | ">= 5.2.0 && < 12"
|
23600 | ],
|
23601 | v8: v8,
|
23602 | vm: vm,
|
23603 | wasi: wasi,
|
23604 | worker_threads: worker_threads,
|
23605 | zlib: zlib
|
23606 | };
|
23607 |
|
23608 | var core$2 = Object.freeze({
|
23609 | __proto__: null,
|
23610 | assert: assert,
|
23611 | async_hooks: async_hooks,
|
23612 | buffer_ieee754: buffer_ieee754,
|
23613 | buffer: buffer,
|
23614 | child_process: child_process,
|
23615 | cluster: cluster,
|
23616 | console: console$1,
|
23617 | constants: constants$1,
|
23618 | crypto: crypto,
|
23619 | _debug_agent: _debug_agent,
|
23620 | _debugger: _debugger,
|
23621 | dgram: dgram,
|
23622 | dns: dns,
|
23623 | domain: domain,
|
23624 | events: events,
|
23625 | freelist: freelist,
|
23626 | fs: fs,
|
23627 | _http_agent: _http_agent,
|
23628 | _http_client: _http_client,
|
23629 | _http_common: _http_common,
|
23630 | _http_incoming: _http_incoming,
|
23631 | _http_outgoing: _http_outgoing,
|
23632 | _http_server: _http_server,
|
23633 | http: http,
|
23634 | http2: http2,
|
23635 | https: https,
|
23636 | inspector: inspector,
|
23637 | _linklist: _linklist,
|
23638 | module: module$1,
|
23639 | net: net,
|
23640 | os: os,
|
23641 | path: path$1,
|
23642 | perf_hooks: perf_hooks,
|
23643 | process: process$1,
|
23644 | punycode: punycode,
|
23645 | querystring: querystring,
|
23646 | readline: readline,
|
23647 | repl: repl,
|
23648 | smalloc: smalloc,
|
23649 | _stream_duplex: _stream_duplex,
|
23650 | _stream_transform: _stream_transform,
|
23651 | _stream_wrap: _stream_wrap,
|
23652 | _stream_passthrough: _stream_passthrough,
|
23653 | _stream_readable: _stream_readable,
|
23654 | _stream_writable: _stream_writable,
|
23655 | stream: stream,
|
23656 | string_decoder: string_decoder,
|
23657 | sys: sys,
|
23658 | timers: timers,
|
23659 | _tls_common: _tls_common,
|
23660 | _tls_legacy: _tls_legacy,
|
23661 | _tls_wrap: _tls_wrap,
|
23662 | tls: tls,
|
23663 | trace_events: trace_events,
|
23664 | tty: tty,
|
23665 | url: url,
|
23666 | util: util$2,
|
23667 | v8: v8,
|
23668 | vm: vm,
|
23669 | wasi: wasi,
|
23670 | worker_threads: worker_threads,
|
23671 | zlib: zlib,
|
23672 | 'default': core$1
|
23673 | });
|
23674 |
|
23675 | var data = getCjsExportFromNamespace(core$2);
|
23676 |
|
23677 | var current = process.versions && process.versions.node && process.versions.node.split('.') || [];
|
23678 |
|
23679 | function specifierIncluded(specifier) {
|
23680 | var parts = specifier.split(' ');
|
23681 | var op = parts.length > 1 ? parts[0] : '=';
|
23682 | var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split('.');
|
23683 |
|
23684 | for (var i = 0; i < 3; ++i) {
|
23685 | var cur = Number(current[i] || 0);
|
23686 | var ver = Number(versionParts[i] || 0);
|
23687 |
|
23688 | if (cur === ver) {
|
23689 | continue;
|
23690 | }
|
23691 |
|
23692 | if (op === '<') {
|
23693 | return cur < ver;
|
23694 | } else if (op === '>=') {
|
23695 | return cur >= ver;
|
23696 | } else {
|
23697 | return false;
|
23698 | }
|
23699 | }
|
23700 |
|
23701 | return op === '>=';
|
23702 | }
|
23703 |
|
23704 | function matchesRange(range) {
|
23705 | var specifiers = range.split(/ ?&& ?/);
|
23706 |
|
23707 | if (specifiers.length === 0) {
|
23708 | return false;
|
23709 | }
|
23710 |
|
23711 | for (var i = 0; i < specifiers.length; ++i) {
|
23712 | if (!specifierIncluded(specifiers[i])) {
|
23713 | return false;
|
23714 | }
|
23715 | }
|
23716 |
|
23717 | return true;
|
23718 | }
|
23719 |
|
23720 | function versionIncluded(specifierValue) {
|
23721 | if (typeof specifierValue === 'boolean') {
|
23722 | return specifierValue;
|
23723 | }
|
23724 |
|
23725 | if (specifierValue && typeof specifierValue === 'object') {
|
23726 | for (var i = 0; i < specifierValue.length; ++i) {
|
23727 | if (matchesRange(specifierValue[i])) {
|
23728 | return true;
|
23729 | }
|
23730 | }
|
23731 |
|
23732 | return false;
|
23733 | }
|
23734 |
|
23735 | return matchesRange(specifierValue);
|
23736 | }
|
23737 |
|
23738 | var core$3 = {};
|
23739 |
|
23740 | for (var mod in data) {
|
23741 |
|
23742 | if (Object.prototype.hasOwnProperty.call(data, mod)) {
|
23743 | core$3[mod] = versionIncluded(data[mod]);
|
23744 | }
|
23745 | }
|
23746 |
|
23747 | var core_1 = core$3;
|
23748 |
|
23749 | var isCore = function isCore(x) {
|
23750 | return Object.prototype.hasOwnProperty.call(core_1, x);
|
23751 | };
|
23752 |
|
23753 | var realpath = fs$3.realpath && typeof fs$3.realpath.native === 'function' ? fs$3.realpath.native : fs$3.realpath;
|
23754 |
|
23755 | var defaultIsFile = function isFile(file, cb) {
|
23756 | fs$3.stat(file, function (err, stat) {
|
23757 | if (!err) {
|
23758 | return cb(null, stat.isFile() || stat.isFIFO());
|
23759 | }
|
23760 |
|
23761 | if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
|
23762 | return cb(err);
|
23763 | });
|
23764 | };
|
23765 |
|
23766 | var defaultIsDir = function isDirectory(dir, cb) {
|
23767 | fs$3.stat(dir, function (err, stat) {
|
23768 | if (!err) {
|
23769 | return cb(null, stat.isDirectory());
|
23770 | }
|
23771 |
|
23772 | if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
|
23773 | return cb(err);
|
23774 | });
|
23775 | };
|
23776 |
|
23777 | var maybeUnwrapSymlink = function maybeUnwrapSymlink(x, opts, cb) {
|
23778 | if (opts && opts.preserveSymlinks === false) {
|
23779 | realpath(x, function (realPathErr, realPath) {
|
23780 | if (realPathErr && realPathErr.code !== 'ENOENT') cb(realPathErr);else cb(null, realPathErr ? x : realPath);
|
23781 | });
|
23782 | } else {
|
23783 | cb(null, x);
|
23784 | }
|
23785 | };
|
23786 |
|
23787 | var getPackageCandidates = function getPackageCandidates(x, start, opts) {
|
23788 | var dirs = nodeModulesPaths(start, opts, x);
|
23789 |
|
23790 | for (var i = 0; i < dirs.length; i++) {
|
23791 | dirs[i] = path$2.join(dirs[i], x);
|
23792 | }
|
23793 |
|
23794 | return dirs;
|
23795 | };
|
23796 |
|
23797 | var async = function resolve(x, options, callback) {
|
23798 | var cb = callback;
|
23799 | var opts = options;
|
23800 |
|
23801 | if (typeof options === 'function') {
|
23802 | cb = opts;
|
23803 | opts = {};
|
23804 | }
|
23805 |
|
23806 | if (typeof x !== 'string') {
|
23807 | var err = new TypeError('Path must be a string.');
|
23808 | return process.nextTick(function () {
|
23809 | cb(err);
|
23810 | });
|
23811 | }
|
23812 |
|
23813 | opts = normalizeOptions$2(x, opts);
|
23814 | var isFile = opts.isFile || defaultIsFile;
|
23815 | var isDirectory = opts.isDirectory || defaultIsDir;
|
23816 | var readFile = opts.readFile || fs$3.readFile;
|
23817 | var packageIterator = opts.packageIterator;
|
23818 | var extensions = opts.extensions || ['.js'];
|
23819 | var basedir = opts.basedir || path$2.dirname(caller());
|
23820 | var parent = opts.filename || basedir;
|
23821 | opts.paths = opts.paths || [];
|
23822 |
|
23823 | var absoluteStart = path$2.resolve(basedir);
|
23824 | maybeUnwrapSymlink(absoluteStart, opts, function (err, realStart) {
|
23825 | if (err) cb(err);else init(realStart);
|
23826 | });
|
23827 | var res;
|
23828 |
|
23829 | function init(basedir) {
|
23830 | if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
|
23831 | res = path$2.resolve(basedir, x);
|
23832 | if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/';
|
23833 |
|
23834 | if (/\/$/.test(x) && res === basedir) {
|
23835 | loadAsDirectory(res, opts.package, onfile);
|
23836 | } else loadAsFile(res, opts.package, onfile);
|
23837 | } else if (isCore(x)) {
|
23838 | return cb(null, x);
|
23839 | } else loadNodeModules(x, basedir, function (err, n, pkg) {
|
23840 | if (err) cb(err);else if (n) {
|
23841 | return maybeUnwrapSymlink(n, opts, function (err, realN) {
|
23842 | if (err) {
|
23843 | cb(err);
|
23844 | } else {
|
23845 | cb(null, realN, pkg);
|
23846 | }
|
23847 | });
|
23848 | } else {
|
23849 | var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
|
23850 | moduleError.code = 'MODULE_NOT_FOUND';
|
23851 | cb(moduleError);
|
23852 | }
|
23853 | });
|
23854 | }
|
23855 |
|
23856 | function onfile(err, m, pkg) {
|
23857 | if (err) cb(err);else if (m) cb(null, m, pkg);else loadAsDirectory(res, function (err, d, pkg) {
|
23858 | if (err) cb(err);else if (d) {
|
23859 | maybeUnwrapSymlink(d, opts, function (err, realD) {
|
23860 | if (err) {
|
23861 | cb(err);
|
23862 | } else {
|
23863 | cb(null, realD, pkg);
|
23864 | }
|
23865 | });
|
23866 | } else {
|
23867 | var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
|
23868 | moduleError.code = 'MODULE_NOT_FOUND';
|
23869 | cb(moduleError);
|
23870 | }
|
23871 | });
|
23872 | }
|
23873 |
|
23874 | function loadAsFile(x, thePackage, callback) {
|
23875 | var loadAsFilePackage = thePackage;
|
23876 | var cb = callback;
|
23877 |
|
23878 | if (typeof loadAsFilePackage === 'function') {
|
23879 | cb = loadAsFilePackage;
|
23880 | loadAsFilePackage = undefined;
|
23881 | }
|
23882 |
|
23883 | var exts = [''].concat(extensions);
|
23884 | load(exts, x, loadAsFilePackage);
|
23885 |
|
23886 | function load(exts, x, loadPackage) {
|
23887 | if (exts.length === 0) return cb(null, undefined, loadPackage);
|
23888 | var file = x + exts[0];
|
23889 | var pkg = loadPackage;
|
23890 | if (pkg) onpkg(null, pkg);else loadpkg(path$2.dirname(file), onpkg);
|
23891 |
|
23892 | function onpkg(err, pkg_, dir) {
|
23893 | pkg = pkg_;
|
23894 | if (err) return cb(err);
|
23895 |
|
23896 | if (dir && pkg && opts.pathFilter) {
|
23897 | var rfile = path$2.relative(dir, file);
|
23898 | var rel = rfile.slice(0, rfile.length - exts[0].length);
|
23899 | var r = opts.pathFilter(pkg, x, rel);
|
23900 | if (r) return load([''].concat(extensions.slice()), path$2.resolve(dir, r), pkg);
|
23901 | }
|
23902 |
|
23903 | isFile(file, onex);
|
23904 | }
|
23905 |
|
23906 | function onex(err, ex) {
|
23907 | if (err) return cb(err);
|
23908 | if (ex) return cb(null, file, pkg);
|
23909 | load(exts.slice(1), x, pkg);
|
23910 | }
|
23911 | }
|
23912 | }
|
23913 |
|
23914 | function loadpkg(dir, cb) {
|
23915 | if (dir === '' || dir === '/') return cb(null);
|
23916 |
|
23917 | if (process.platform === 'win32' && /^\w:[/\\]*$/.test(dir)) {
|
23918 | return cb(null);
|
23919 | }
|
23920 |
|
23921 | if (/[/\\]node_modules[/\\]*$/.test(dir)) return cb(null);
|
23922 | maybeUnwrapSymlink(dir, opts, function (unwrapErr, pkgdir) {
|
23923 | if (unwrapErr) return loadpkg(path$2.dirname(dir), cb);
|
23924 | var pkgfile = path$2.join(pkgdir, 'package.json');
|
23925 | isFile(pkgfile, function (err, ex) {
|
23926 |
|
23927 | if (!ex) return loadpkg(path$2.dirname(dir), cb);
|
23928 | readFile(pkgfile, function (err, body) {
|
23929 | if (err) cb(err);
|
23930 |
|
23931 | try {
|
23932 | var pkg = JSON.parse(body);
|
23933 | } catch (jsonErr) {}
|
23934 |
|
23935 | if (pkg && opts.packageFilter) {
|
23936 | pkg = opts.packageFilter(pkg, pkgfile);
|
23937 | }
|
23938 |
|
23939 | cb(null, pkg, dir);
|
23940 | });
|
23941 | });
|
23942 | });
|
23943 | }
|
23944 |
|
23945 | function loadAsDirectory(x, loadAsDirectoryPackage, callback) {
|
23946 | var cb = callback;
|
23947 | var fpkg = loadAsDirectoryPackage;
|
23948 |
|
23949 | if (typeof fpkg === 'function') {
|
23950 | cb = fpkg;
|
23951 | fpkg = opts.package;
|
23952 | }
|
23953 |
|
23954 | maybeUnwrapSymlink(x, opts, function (unwrapErr, pkgdir) {
|
23955 | if (unwrapErr) return cb(unwrapErr);
|
23956 | var pkgfile = path$2.join(pkgdir, 'package.json');
|
23957 | isFile(pkgfile, function (err, ex) {
|
23958 | if (err) return cb(err);
|
23959 | if (!ex) return loadAsFile(path$2.join(x, 'index'), fpkg, cb);
|
23960 | readFile(pkgfile, function (err, body) {
|
23961 | if (err) return cb(err);
|
23962 |
|
23963 | try {
|
23964 | var pkg = JSON.parse(body);
|
23965 | } catch (jsonErr) {}
|
23966 |
|
23967 | if (pkg && opts.packageFilter) {
|
23968 | pkg = opts.packageFilter(pkg, pkgfile);
|
23969 | }
|
23970 |
|
23971 | if (pkg && pkg.main) {
|
23972 | if (typeof pkg.main !== 'string') {
|
23973 | var mainError = new TypeError('package “' + pkg.name + '” `main` must be a string');
|
23974 | mainError.code = 'INVALID_PACKAGE_MAIN';
|
23975 | return cb(mainError);
|
23976 | }
|
23977 |
|
23978 | if (pkg.main === '.' || pkg.main === './') {
|
23979 | pkg.main = 'index';
|
23980 | }
|
23981 |
|
23982 | loadAsFile(path$2.resolve(x, pkg.main), pkg, function (err, m, pkg) {
|
23983 | if (err) return cb(err);
|
23984 | if (m) return cb(null, m, pkg);
|
23985 | if (!pkg) return loadAsFile(path$2.join(x, 'index'), pkg, cb);
|
23986 | var dir = path$2.resolve(x, pkg.main);
|
23987 | loadAsDirectory(dir, pkg, function (err, n, pkg) {
|
23988 | if (err) return cb(err);
|
23989 | if (n) return cb(null, n, pkg);
|
23990 | loadAsFile(path$2.join(x, 'index'), pkg, cb);
|
23991 | });
|
23992 | });
|
23993 | return;
|
23994 | }
|
23995 |
|
23996 | loadAsFile(path$2.join(x, '/index'), pkg, cb);
|
23997 | });
|
23998 | });
|
23999 | });
|
24000 | }
|
24001 |
|
24002 | function processDirs(cb, dirs) {
|
24003 | if (dirs.length === 0) return cb(null, undefined);
|
24004 | var dir = dirs[0];
|
24005 | isDirectory(path$2.dirname(dir), isdir);
|
24006 |
|
24007 | function isdir(err, isdir) {
|
24008 | if (err) return cb(err);
|
24009 | if (!isdir) return processDirs(cb, dirs.slice(1));
|
24010 | loadAsFile(dir, opts.package, onfile);
|
24011 | }
|
24012 |
|
24013 | function onfile(err, m, pkg) {
|
24014 | if (err) return cb(err);
|
24015 | if (m) return cb(null, m, pkg);
|
24016 | loadAsDirectory(dir, opts.package, ondir);
|
24017 | }
|
24018 |
|
24019 | function ondir(err, n, pkg) {
|
24020 | if (err) return cb(err);
|
24021 | if (n) return cb(null, n, pkg);
|
24022 | processDirs(cb, dirs.slice(1));
|
24023 | }
|
24024 | }
|
24025 |
|
24026 | function loadNodeModules(x, start, cb) {
|
24027 | var thunk = function () {
|
24028 | return getPackageCandidates(x, start, opts);
|
24029 | };
|
24030 |
|
24031 | processDirs(cb, packageIterator ? packageIterator(x, start, thunk, opts) : thunk());
|
24032 | }
|
24033 | };
|
24034 |
|
24035 | var realpath$1 = fs$3.realpathSync && typeof fs$3.realpathSync.native === 'function' ? fs$3.realpathSync.native : fs$3.realpathSync;
|
24036 |
|
24037 | var defaultIsFile$1 = function isFile(file) {
|
24038 | try {
|
24039 | var stat = fs$3.statSync(file);
|
24040 | } catch (e) {
|
24041 | if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
|
24042 | throw e;
|
24043 | }
|
24044 |
|
24045 | return stat.isFile() || stat.isFIFO();
|
24046 | };
|
24047 |
|
24048 | var defaultIsDir$1 = function isDirectory(dir) {
|
24049 | try {
|
24050 | var stat = fs$3.statSync(dir);
|
24051 | } catch (e) {
|
24052 | if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
|
24053 | throw e;
|
24054 | }
|
24055 |
|
24056 | return stat.isDirectory();
|
24057 | };
|
24058 |
|
24059 | var maybeUnwrapSymlink$1 = function maybeUnwrapSymlink(x, opts) {
|
24060 | if (opts && opts.preserveSymlinks === false) {
|
24061 | try {
|
24062 | return realpath$1(x);
|
24063 | } catch (realPathErr) {
|
24064 | if (realPathErr.code !== 'ENOENT') {
|
24065 | throw realPathErr;
|
24066 | }
|
24067 | }
|
24068 | }
|
24069 |
|
24070 | return x;
|
24071 | };
|
24072 |
|
24073 | var getPackageCandidates$1 = function getPackageCandidates(x, start, opts) {
|
24074 | var dirs = nodeModulesPaths(start, opts, x);
|
24075 |
|
24076 | for (var i = 0; i < dirs.length; i++) {
|
24077 | dirs[i] = path$2.join(dirs[i], x);
|
24078 | }
|
24079 |
|
24080 | return dirs;
|
24081 | };
|
24082 |
|
24083 | var sync = function resolveSync(x, options) {
|
24084 | if (typeof x !== 'string') {
|
24085 | throw new TypeError('Path must be a string.');
|
24086 | }
|
24087 |
|
24088 | var opts = normalizeOptions$2(x, options);
|
24089 | var isFile = opts.isFile || defaultIsFile$1;
|
24090 | var readFileSync = opts.readFileSync || fs$3.readFileSync;
|
24091 | var isDirectory = opts.isDirectory || defaultIsDir$1;
|
24092 | var packageIterator = opts.packageIterator;
|
24093 | var extensions = opts.extensions || ['.js'];
|
24094 | var basedir = opts.basedir || path$2.dirname(caller());
|
24095 | var parent = opts.filename || basedir;
|
24096 | opts.paths = opts.paths || [];
|
24097 |
|
24098 | var absoluteStart = maybeUnwrapSymlink$1(path$2.resolve(basedir), opts);
|
24099 |
|
24100 | if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
|
24101 | var res = path$2.resolve(absoluteStart, x);
|
24102 | if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/';
|
24103 | var m = loadAsFileSync(res) || loadAsDirectorySync(res);
|
24104 | if (m) return maybeUnwrapSymlink$1(m, opts);
|
24105 | } else if (isCore(x)) {
|
24106 | return x;
|
24107 | } else {
|
24108 | var n = loadNodeModulesSync(x, absoluteStart);
|
24109 | if (n) return maybeUnwrapSymlink$1(n, opts);
|
24110 | }
|
24111 |
|
24112 | var err = new Error("Cannot find module '" + x + "' from '" + parent + "'");
|
24113 | err.code = 'MODULE_NOT_FOUND';
|
24114 | throw err;
|
24115 |
|
24116 | function loadAsFileSync(x) {
|
24117 | var pkg = loadpkg(path$2.dirname(x));
|
24118 |
|
24119 | if (pkg && pkg.dir && pkg.pkg && opts.pathFilter) {
|
24120 | var rfile = path$2.relative(pkg.dir, x);
|
24121 | var r = opts.pathFilter(pkg.pkg, x, rfile);
|
24122 |
|
24123 | if (r) {
|
24124 | x = path$2.resolve(pkg.dir, r);
|
24125 | }
|
24126 | }
|
24127 |
|
24128 | if (isFile(x)) {
|
24129 | return x;
|
24130 | }
|
24131 |
|
24132 | for (var i = 0; i < extensions.length; i++) {
|
24133 | var file = x + extensions[i];
|
24134 |
|
24135 | if (isFile(file)) {
|
24136 | return file;
|
24137 | }
|
24138 | }
|
24139 | }
|
24140 |
|
24141 | function loadpkg(dir) {
|
24142 | if (dir === '' || dir === '/') return;
|
24143 |
|
24144 | if (process.platform === 'win32' && /^\w:[/\\]*$/.test(dir)) {
|
24145 | return;
|
24146 | }
|
24147 |
|
24148 | if (/[/\\]node_modules[/\\]*$/.test(dir)) return;
|
24149 | var pkgfile = path$2.join(maybeUnwrapSymlink$1(dir, opts), 'package.json');
|
24150 |
|
24151 | if (!isFile(pkgfile)) {
|
24152 | return loadpkg(path$2.dirname(dir));
|
24153 | }
|
24154 |
|
24155 | var body = readFileSync(pkgfile);
|
24156 |
|
24157 | try {
|
24158 | var pkg = JSON.parse(body);
|
24159 | } catch (jsonErr) {}
|
24160 |
|
24161 | if (pkg && opts.packageFilter) {
|
24162 |
|
24163 | pkg = opts.packageFilter(pkg,
|
24164 |
|
24165 | dir);
|
24166 | }
|
24167 |
|
24168 | return {
|
24169 | pkg: pkg,
|
24170 | dir: dir
|
24171 | };
|
24172 | }
|
24173 |
|
24174 | function loadAsDirectorySync(x) {
|
24175 | var pkgfile = path$2.join(maybeUnwrapSymlink$1(x, opts), '/package.json');
|
24176 |
|
24177 | if (isFile(pkgfile)) {
|
24178 | try {
|
24179 | var body = readFileSync(pkgfile, 'UTF8');
|
24180 | var pkg = JSON.parse(body);
|
24181 | } catch (e) {}
|
24182 |
|
24183 | if (pkg && opts.packageFilter) {
|
24184 |
|
24185 | pkg = opts.packageFilter(pkg,
|
24186 |
|
24187 | x);
|
24188 | }
|
24189 |
|
24190 | if (pkg && pkg.main) {
|
24191 | if (typeof pkg.main !== 'string') {
|
24192 | var mainError = new TypeError('package “' + pkg.name + '” `main` must be a string');
|
24193 | mainError.code = 'INVALID_PACKAGE_MAIN';
|
24194 | throw mainError;
|
24195 | }
|
24196 |
|
24197 | if (pkg.main === '.' || pkg.main === './') {
|
24198 | pkg.main = 'index';
|
24199 | }
|
24200 |
|
24201 | try {
|
24202 | var m = loadAsFileSync(path$2.resolve(x, pkg.main));
|
24203 | if (m) return m;
|
24204 | var n = loadAsDirectorySync(path$2.resolve(x, pkg.main));
|
24205 | if (n) return n;
|
24206 | } catch (e) {}
|
24207 | }
|
24208 | }
|
24209 |
|
24210 | return loadAsFileSync(path$2.join(x, '/index'));
|
24211 | }
|
24212 |
|
24213 | function loadNodeModulesSync(x, start) {
|
24214 | var thunk = function () {
|
24215 | return getPackageCandidates$1(x, start, opts);
|
24216 | };
|
24217 |
|
24218 | var dirs = packageIterator ? packageIterator(x, start, thunk, opts) : thunk();
|
24219 |
|
24220 | for (var i = 0; i < dirs.length; i++) {
|
24221 | var dir = dirs[i];
|
24222 |
|
24223 | if (isDirectory(path$2.dirname(dir))) {
|
24224 | var m = loadAsFileSync(dir);
|
24225 | if (m) return m;
|
24226 | var n = loadAsDirectorySync(dir);
|
24227 | if (n) return n;
|
24228 | }
|
24229 | }
|
24230 | }
|
24231 | };
|
24232 |
|
24233 | async.core = core_1;
|
24234 | async.isCore = isCore;
|
24235 | async.sync = sync;
|
24236 | var resolve = async;
|
24237 |
|
24238 |
|
24239 |
|
24240 |
|
24241 | let resolve$1 = require.resolve;
|
24242 |
|
24243 | if (resolve$1.length === 1 || process.env.PRETTIER_FALLBACK_RESOLVE) {
|
24244 | resolve$1 = (id, options) => {
|
24245 | let basedir;
|
24246 |
|
24247 | if (options && options.paths && options.paths.length === 1) {
|
24248 | basedir = options.paths[0];
|
24249 | }
|
24250 |
|
24251 | return resolve.sync(id, {
|
24252 | basedir
|
24253 | });
|
24254 | };
|
24255 | }
|
24256 |
|
24257 | var resolve_1 = resolve$1;
|
24258 |
|
24259 | const getExplorerMemoized = mem_1(opts => {
|
24260 | const cosmiconfig = thirdParty["cosmiconfig" + (opts.sync ? "Sync" : "")];
|
24261 | const explorer = cosmiconfig("prettier", {
|
24262 | cache: opts.cache,
|
24263 | transform: result => {
|
24264 | if (result && result.config) {
|
24265 | if (typeof result.config === "string") {
|
24266 | const dir = path$2.dirname(result.filepath);
|
24267 |
|
24268 | try {
|
24269 | const modulePath = resolve_1(result.config, {
|
24270 | paths: [dir]
|
24271 | });
|
24272 | result.config = require(modulePath);
|
24273 | } catch (error) {
|
24274 |
|
24275 | error.message = `Cannot find module '${result.config}' from '${dir}'`;
|
24276 | throw error;
|
24277 | }
|
24278 | }
|
24279 |
|
24280 | if (typeof result.config !== "object") {
|
24281 | throw new Error("Config is only allowed to be an object, " + `but received ${typeof result.config} in "${result.filepath}"`);
|
24282 | }
|
24283 |
|
24284 | delete result.config.$schema;
|
24285 | }
|
24286 |
|
24287 | return result;
|
24288 | },
|
24289 | searchPlaces: ["package.json", ".prettierrc", ".prettierrc.json", ".prettierrc.yaml", ".prettierrc.yml", ".prettierrc.js", "prettier.config.js", ".prettierrc.toml"],
|
24290 | loaders: {
|
24291 | ".toml": loadToml
|
24292 | }
|
24293 | });
|
24294 | return explorer;
|
24295 | }, {
|
24296 | cacheKey: JSON.stringify
|
24297 | });
|
24298 |
|
24299 |
|
24300 | function getExplorer(opts) {
|
24301 |
|
24302 | opts = Object.assign({
|
24303 | sync: false,
|
24304 | cache: false
|
24305 | }, opts);
|
24306 | return getExplorerMemoized(opts);
|
24307 | }
|
24308 |
|
24309 | function _resolveConfig(filePath, opts, sync) {
|
24310 | opts = Object.assign({
|
24311 | useCache: true
|
24312 | }, opts);
|
24313 | const loadOpts = {
|
24314 | cache: !!opts.useCache,
|
24315 | sync: !!sync,
|
24316 | editorconfig: !!opts.editorconfig
|
24317 | };
|
24318 | const {
|
24319 | load,
|
24320 | search
|
24321 | } = getExplorer(loadOpts);
|
24322 | const loadEditorConfig = resolveConfigEditorconfig.getLoadFunction(loadOpts);
|
24323 | const arr = [opts.config ? load(opts.config) : search(filePath), loadEditorConfig(filePath)];
|
24324 |
|
24325 | const unwrapAndMerge = ([result, editorConfigured]) => {
|
24326 | const merged = Object.assign({}, editorConfigured, {}, mergeOverrides(result, filePath));
|
24327 | ["plugins", "pluginSearchDirs"].forEach(optionName => {
|
24328 | if (Array.isArray(merged[optionName])) {
|
24329 | merged[optionName] = merged[optionName].map(value => typeof value === "string" && value.startsWith(".")
|
24330 | ? path$2.resolve(path$2.dirname(result.filepath), value) : value);
|
24331 | }
|
24332 | });
|
24333 |
|
24334 | if (!result && !editorConfigured) {
|
24335 | return null;
|
24336 | }
|
24337 |
|
24338 | return merged;
|
24339 | };
|
24340 |
|
24341 | if (loadOpts.sync) {
|
24342 | return unwrapAndMerge(arr);
|
24343 | }
|
24344 |
|
24345 | return Promise.all(arr).then(unwrapAndMerge);
|
24346 | }
|
24347 |
|
24348 | const resolveConfig = (filePath, opts) => _resolveConfig(filePath, opts, false);
|
24349 |
|
24350 | resolveConfig.sync = (filePath, opts) => _resolveConfig(filePath, opts, true);
|
24351 |
|
24352 | function clearCache$1() {
|
24353 | mem_1.clear(getExplorerMemoized);
|
24354 | resolveConfigEditorconfig.clearCache();
|
24355 | }
|
24356 |
|
24357 | async function resolveConfigFile(filePath) {
|
24358 | const {
|
24359 | search
|
24360 | } = getExplorer({
|
24361 | sync: false
|
24362 | });
|
24363 | const result = await search(filePath);
|
24364 | return result ? result.filepath : null;
|
24365 | }
|
24366 |
|
24367 | resolveConfigFile.sync = filePath => {
|
24368 | const {
|
24369 | search
|
24370 | } = getExplorer({
|
24371 | sync: true
|
24372 | });
|
24373 | const result = search(filePath);
|
24374 | return result ? result.filepath : null;
|
24375 | };
|
24376 |
|
24377 | function mergeOverrides(configResult, filePath) {
|
24378 | const {
|
24379 | config,
|
24380 | filepath: configPath
|
24381 | } = configResult || {};
|
24382 |
|
24383 | const _ref = config || {},
|
24384 | {
|
24385 | overrides
|
24386 | } = _ref,
|
24387 | options = _objectWithoutPropertiesLoose(_ref, ["overrides"]);
|
24388 |
|
24389 | if (filePath && overrides) {
|
24390 | const relativeFilePath = path$2.relative(path$2.dirname(configPath), filePath);
|
24391 |
|
24392 | for (const override of overrides) {
|
24393 | if (pathMatchesGlobs(relativeFilePath, override.files, override.excludeFiles)) {
|
24394 | Object.assign(options, override.options);
|
24395 | }
|
24396 | }
|
24397 | }
|
24398 |
|
24399 | return options;
|
24400 | }
|
24401 |
|
24402 |
|
24403 | function pathMatchesGlobs(filePath, patterns, excludedPatterns) {
|
24404 | const patternList = [].concat(patterns);
|
24405 | const excludedPatternList = [].concat(excludedPatterns || []);
|
24406 | const opts = {
|
24407 | matchBase: true,
|
24408 | dot: true
|
24409 | };
|
24410 | return patternList.some(pattern => minimatch_1(filePath, pattern, opts)) && !excludedPatternList.some(excludedPattern => minimatch_1(filePath, excludedPattern, opts));
|
24411 | }
|
24412 |
|
24413 | var resolveConfig_1 = {
|
24414 | resolveConfig,
|
24415 | resolveConfigFile,
|
24416 | clearCache: clearCache$1
|
24417 | };
|
24418 |
|
24419 |
|
24420 |
|
24421 |
|
24422 |
|
24423 |
|
24424 |
|
24425 |
|
24426 |
|
24427 |
|
24428 |
|
24429 |
|
24430 |
|
24431 |
|
24432 |
|
24433 |
|
24434 |
|
24435 | async function getFileInfo(filePath, opts) {
|
24436 | if (typeof filePath !== "string") {
|
24437 | throw new TypeError(`expect \`filePath\` to be a string, got \`${typeof filePath}\``);
|
24438 | }
|
24439 |
|
24440 | const ignorer = await createIgnorer_1(opts.ignorePath, opts.withNodeModules);
|
24441 | return _getFileInfo({
|
24442 | ignorer,
|
24443 | filePath: normalizeFilePath(filePath, opts.ignorePath),
|
24444 | plugins: opts.plugins,
|
24445 | resolveConfig: opts.resolveConfig,
|
24446 | sync: false
|
24447 | });
|
24448 | }
|
24449 |
|
24450 |
|
24451 |
|
24452 |
|
24453 |
|
24454 |
|
24455 |
|
24456 | getFileInfo.sync = function (filePath, opts) {
|
24457 | if (typeof filePath !== "string") {
|
24458 | throw new TypeError(`expect \`filePath\` to be a string, got \`${typeof filePath}\``);
|
24459 | }
|
24460 |
|
24461 | const ignorer = createIgnorer_1.sync(opts.ignorePath, opts.withNodeModules);
|
24462 | return _getFileInfo({
|
24463 | ignorer,
|
24464 | filePath: normalizeFilePath(filePath, opts.ignorePath),
|
24465 | plugins: opts.plugins,
|
24466 | resolveConfig: opts.resolveConfig,
|
24467 | sync: true
|
24468 | });
|
24469 | };
|
24470 |
|
24471 | function _getFileInfo({
|
24472 | ignorer,
|
24473 | filePath,
|
24474 | plugins,
|
24475 | resolveConfig = false,
|
24476 | sync = false
|
24477 | }) {
|
24478 | const fileInfo = {
|
24479 | ignored: ignorer.ignores(filePath),
|
24480 | inferredParser: options$1.inferParser(filePath, plugins) || null
|
24481 | };
|
24482 |
|
24483 | if (!fileInfo.inferredParser && resolveConfig) {
|
24484 | if (!sync) {
|
24485 | return resolveConfig_1.resolveConfig(filePath).then(resolvedConfig => {
|
24486 | if (resolvedConfig && resolvedConfig.parser) {
|
24487 | fileInfo.inferredParser = resolvedConfig.parser;
|
24488 | }
|
24489 |
|
24490 | return fileInfo;
|
24491 | });
|
24492 | }
|
24493 |
|
24494 | const resolvedConfig = resolveConfig_1.resolveConfig.sync(filePath);
|
24495 |
|
24496 | if (resolvedConfig && resolvedConfig.parser) {
|
24497 | fileInfo.inferredParser = resolvedConfig.parser;
|
24498 | }
|
24499 | }
|
24500 |
|
24501 | return fileInfo;
|
24502 | }
|
24503 |
|
24504 | function normalizeFilePath(filePath, ignorePath) {
|
24505 | return ignorePath ? path$2.relative(path$2.dirname(ignorePath), filePath) : filePath;
|
24506 | }
|
24507 |
|
24508 | var getFileInfo_1 = getFileInfo;
|
24509 |
|
24510 |
|
24511 |
|
24512 |
|
24513 |
|
24514 |
|
24515 |
|
24516 |
|
24517 | function listCacheClear() {
|
24518 | this.__data__ = [];
|
24519 | this.size = 0;
|
24520 | }
|
24521 |
|
24522 | var _listCacheClear = listCacheClear;
|
24523 |
|
24524 |
|
24525 |
|
24526 |
|
24527 |
|
24528 |
|
24529 |
|
24530 |
|
24531 |
|
24532 |
|
24533 |
|
24534 |
|
24535 |
|
24536 |
|
24537 |
|
24538 |
|
24539 |
|
24540 |
|
24541 |
|
24542 |
|
24543 |
|
24544 |
|
24545 |
|
24546 |
|
24547 |
|
24548 |
|
24549 |
|
24550 |
|
24551 |
|
24552 |
|
24553 |
|
24554 |
|
24555 |
|
24556 | function eq(value, other) {
|
24557 | return value === other || value !== value && other !== other;
|
24558 | }
|
24559 |
|
24560 | var eq_1 = eq;
|
24561 |
|
24562 |
|
24563 |
|
24564 |
|
24565 |
|
24566 |
|
24567 |
|
24568 |
|
24569 |
|
24570 |
|
24571 | function assocIndexOf(array, key) {
|
24572 | var length = array.length;
|
24573 |
|
24574 | while (length--) {
|
24575 | if (eq_1(array[length][0], key)) {
|
24576 | return length;
|
24577 | }
|
24578 | }
|
24579 |
|
24580 | return -1;
|
24581 | }
|
24582 |
|
24583 | var _assocIndexOf = assocIndexOf;
|
24584 |
|
24585 |
|
24586 |
|
24587 | var arrayProto = Array.prototype;
|
24588 |
|
24589 |
|
24590 | var splice = arrayProto.splice;
|
24591 |
|
24592 |
|
24593 |
|
24594 |
|
24595 |
|
24596 |
|
24597 |
|
24598 |
|
24599 |
|
24600 |
|
24601 | function listCacheDelete(key) {
|
24602 | var data = this.__data__,
|
24603 | index = _assocIndexOf(data, key);
|
24604 |
|
24605 | if (index < 0) {
|
24606 | return false;
|
24607 | }
|
24608 |
|
24609 | var lastIndex = data.length - 1;
|
24610 |
|
24611 | if (index == lastIndex) {
|
24612 | data.pop();
|
24613 | } else {
|
24614 | splice.call(data, index, 1);
|
24615 | }
|
24616 |
|
24617 | --this.size;
|
24618 | return true;
|
24619 | }
|
24620 |
|
24621 | var _listCacheDelete = listCacheDelete;
|
24622 |
|
24623 |
|
24624 |
|
24625 |
|
24626 |
|
24627 |
|
24628 |
|
24629 |
|
24630 |
|
24631 |
|
24632 |
|
24633 | function listCacheGet(key) {
|
24634 | var data = this.__data__,
|
24635 | index = _assocIndexOf(data, key);
|
24636 | return index < 0 ? undefined : data[index][1];
|
24637 | }
|
24638 |
|
24639 | var _listCacheGet = listCacheGet;
|
24640 |
|
24641 |
|
24642 |
|
24643 |
|
24644 |
|
24645 |
|
24646 |
|
24647 |
|
24648 |
|
24649 |
|
24650 |
|
24651 | function listCacheHas(key) {
|
24652 | return _assocIndexOf(this.__data__, key) > -1;
|
24653 | }
|
24654 |
|
24655 | var _listCacheHas = listCacheHas;
|
24656 |
|
24657 |
|
24658 |
|
24659 |
|
24660 |
|
24661 |
|
24662 |
|
24663 |
|
24664 |
|
24665 |
|
24666 |
|
24667 |
|
24668 | function listCacheSet(key, value) {
|
24669 | var data = this.__data__,
|
24670 | index = _assocIndexOf(data, key);
|
24671 |
|
24672 | if (index < 0) {
|
24673 | ++this.size;
|
24674 | data.push([key, value]);
|
24675 | } else {
|
24676 | data[index][1] = value;
|
24677 | }
|
24678 |
|
24679 | return this;
|
24680 | }
|
24681 |
|
24682 | var _listCacheSet = listCacheSet;
|
24683 |
|
24684 |
|
24685 |
|
24686 |
|
24687 |
|
24688 |
|
24689 |
|
24690 |
|
24691 |
|
24692 | function ListCache(entries) {
|
24693 | var index = -1,
|
24694 | length = entries == null ? 0 : entries.length;
|
24695 | this.clear();
|
24696 |
|
24697 | while (++index < length) {
|
24698 | var entry = entries[index];
|
24699 | this.set(entry[0], entry[1]);
|
24700 | }
|
24701 | }
|
24702 |
|
24703 |
|
24704 | ListCache.prototype.clear = _listCacheClear;
|
24705 | ListCache.prototype['delete'] = _listCacheDelete;
|
24706 | ListCache.prototype.get = _listCacheGet;
|
24707 | ListCache.prototype.has = _listCacheHas;
|
24708 | ListCache.prototype.set = _listCacheSet;
|
24709 | var _ListCache = ListCache;
|
24710 |
|
24711 |
|
24712 |
|
24713 |
|
24714 |
|
24715 |
|
24716 |
|
24717 |
|
24718 |
|
24719 | function stackClear() {
|
24720 | this.__data__ = new _ListCache();
|
24721 | this.size = 0;
|
24722 | }
|
24723 |
|
24724 | var _stackClear = stackClear;
|
24725 |
|
24726 |
|
24727 |
|
24728 |
|
24729 |
|
24730 |
|
24731 |
|
24732 |
|
24733 |
|
24734 |
|
24735 | function stackDelete(key) {
|
24736 | var data = this.__data__,
|
24737 | result = data['delete'](key);
|
24738 | this.size = data.size;
|
24739 | return result;
|
24740 | }
|
24741 |
|
24742 | var _stackDelete = stackDelete;
|
24743 |
|
24744 |
|
24745 |
|
24746 |
|
24747 |
|
24748 |
|
24749 |
|
24750 |
|
24751 |
|
24752 |
|
24753 | function stackGet(key) {
|
24754 | return this.__data__.get(key);
|
24755 | }
|
24756 |
|
24757 | var _stackGet = stackGet;
|
24758 |
|
24759 |
|
24760 |
|
24761 |
|
24762 |
|
24763 |
|
24764 |
|
24765 |
|
24766 |
|
24767 |
|
24768 | function stackHas(key) {
|
24769 | return this.__data__.has(key);
|
24770 | }
|
24771 |
|
24772 | var _stackHas = stackHas;
|
24773 |
|
24774 |
|
24775 |
|
24776 | var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
24777 | var _freeGlobal = freeGlobal;
|
24778 |
|
24779 |
|
24780 |
|
24781 | var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
24782 |
|
24783 |
|
24784 | var root = _freeGlobal || freeSelf || Function('return this')();
|
24785 | var _root = root;
|
24786 |
|
24787 |
|
24788 |
|
24789 | var Symbol$1 = _root.Symbol;
|
24790 | var _Symbol = Symbol$1;
|
24791 |
|
24792 |
|
24793 |
|
24794 | var objectProto = Object.prototype;
|
24795 |
|
24796 |
|
24797 | var hasOwnProperty$2 = objectProto.hasOwnProperty;
|
24798 |
|
24799 |
|
24800 |
|
24801 |
|
24802 |
|
24803 |
|
24804 | var nativeObjectToString = objectProto.toString;
|
24805 |
|
24806 |
|
24807 | var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
|
24808 |
|
24809 |
|
24810 |
|
24811 |
|
24812 |
|
24813 |
|
24814 |
|
24815 |
|
24816 | function getRawTag(value) {
|
24817 | var isOwn = hasOwnProperty$2.call(value, symToStringTag),
|
24818 | tag = value[symToStringTag];
|
24819 |
|
24820 | try {
|
24821 | value[symToStringTag] = undefined;
|
24822 | var unmasked = true;
|
24823 | } catch (e) {}
|
24824 |
|
24825 | var result = nativeObjectToString.call(value);
|
24826 |
|
24827 | if (unmasked) {
|
24828 | if (isOwn) {
|
24829 | value[symToStringTag] = tag;
|
24830 | } else {
|
24831 | delete value[symToStringTag];
|
24832 | }
|
24833 | }
|
24834 |
|
24835 | return result;
|
24836 | }
|
24837 |
|
24838 | var _getRawTag = getRawTag;
|
24839 |
|
24840 |
|
24841 | var objectProto$1 = Object.prototype;
|
24842 |
|
24843 |
|
24844 |
|
24845 |
|
24846 |
|
24847 |
|
24848 | var nativeObjectToString$1 = objectProto$1.toString;
|
24849 |
|
24850 |
|
24851 |
|
24852 |
|
24853 |
|
24854 |
|
24855 |
|
24856 |
|
24857 | function objectToString(value) {
|
24858 | return nativeObjectToString$1.call(value);
|
24859 | }
|
24860 |
|
24861 | var _objectToString = objectToString;
|
24862 |
|
24863 |
|
24864 |
|
24865 | var nullTag = '[object Null]',
|
24866 | undefinedTag = '[object Undefined]';
|
24867 |
|
24868 |
|
24869 | var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
|
24870 |
|
24871 |
|
24872 |
|
24873 |
|
24874 |
|
24875 |
|
24876 |
|
24877 |
|
24878 | function baseGetTag(value) {
|
24879 | if (value == null) {
|
24880 | return value === undefined ? undefinedTag : nullTag;
|
24881 | }
|
24882 |
|
24883 | return symToStringTag$1 && symToStringTag$1 in Object(value) ? _getRawTag(value) : _objectToString(value);
|
24884 | }
|
24885 |
|
24886 | var _baseGetTag = baseGetTag;
|
24887 |
|
24888 |
|
24889 |
|
24890 |
|
24891 |
|
24892 |
|
24893 |
|
24894 |
|
24895 |
|
24896 |
|
24897 |
|
24898 |
|
24899 |
|
24900 |
|
24901 |
|
24902 |
|
24903 |
|
24904 |
|
24905 |
|
24906 |
|
24907 |
|
24908 |
|
24909 |
|
24910 |
|
24911 |
|
24912 |
|
24913 | function isObject(value) {
|
24914 | var type = typeof value;
|
24915 | return value != null && (type == 'object' || type == 'function');
|
24916 | }
|
24917 |
|
24918 | var isObject_1 = isObject;
|
24919 |
|
24920 |
|
24921 |
|
24922 | var asyncTag = '[object AsyncFunction]',
|
24923 | funcTag = '[object Function]',
|
24924 | genTag = '[object GeneratorFunction]',
|
24925 | proxyTag = '[object Proxy]';
|
24926 |
|
24927 |
|
24928 |
|
24929 |
|
24930 |
|
24931 |
|
24932 |
|
24933 |
|
24934 |
|
24935 |
|
24936 |
|
24937 |
|
24938 |
|
24939 |
|
24940 |
|
24941 |
|
24942 |
|
24943 |
|
24944 | function isFunction(value) {
|
24945 | if (!isObject_1(value)) {
|
24946 | return false;
|
24947 | }
|
24948 |
|
24949 |
|
24950 |
|
24951 | var tag = _baseGetTag(value);
|
24952 | return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
24953 | }
|
24954 |
|
24955 | var isFunction_1 = isFunction;
|
24956 |
|
24957 |
|
24958 |
|
24959 | var coreJsData = _root['__core-js_shared__'];
|
24960 | var _coreJsData = coreJsData;
|
24961 |
|
24962 |
|
24963 |
|
24964 | var maskSrcKey = function () {
|
24965 | var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
|
24966 | return uid ? 'Symbol(src)_1.' + uid : '';
|
24967 | }();
|
24968 |
|
24969 |
|
24970 |
|
24971 |
|
24972 |
|
24973 |
|
24974 |
|
24975 |
|
24976 |
|
24977 | function isMasked(func) {
|
24978 | return !!maskSrcKey && maskSrcKey in func;
|
24979 | }
|
24980 |
|
24981 | var _isMasked = isMasked;
|
24982 |
|
24983 |
|
24984 | var funcProto = Function.prototype;
|
24985 |
|
24986 |
|
24987 | var funcToString = funcProto.toString;
|
24988 |
|
24989 |
|
24990 |
|
24991 |
|
24992 |
|
24993 |
|
24994 |
|
24995 |
|
24996 | function toSource(func) {
|
24997 | if (func != null) {
|
24998 | try {
|
24999 | return funcToString.call(func);
|
25000 | } catch (e) {}
|
25001 |
|
25002 | try {
|
25003 | return func + '';
|
25004 | } catch (e) {}
|
25005 | }
|
25006 |
|
25007 | return '';
|
25008 | }
|
25009 |
|
25010 | var _toSource = toSource;
|
25011 |
|
25012 |
|
25013 |
|
25014 |
|
25015 |
|
25016 |
|
25017 | var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
25018 |
|
25019 |
|
25020 | var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
25021 |
|
25022 |
|
25023 | var funcProto$1 = Function.prototype,
|
25024 | objectProto$2 = Object.prototype;
|
25025 |
|
25026 |
|
25027 | var funcToString$1 = funcProto$1.toString;
|
25028 |
|
25029 |
|
25030 | var hasOwnProperty$3 = objectProto$2.hasOwnProperty;
|
25031 |
|
25032 |
|
25033 | var reIsNative = RegExp('^' + funcToString$1.call(hasOwnProperty$3).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
|
25034 |
|
25035 |
|
25036 |
|
25037 |
|
25038 |
|
25039 |
|
25040 |
|
25041 |
|
25042 |
|
25043 | function baseIsNative(value) {
|
25044 | if (!isObject_1(value) || _isMasked(value)) {
|
25045 | return false;
|
25046 | }
|
25047 |
|
25048 | var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
|
25049 | return pattern.test(_toSource(value));
|
25050 | }
|
25051 |
|
25052 | var _baseIsNative = baseIsNative;
|
25053 |
|
25054 |
|
25055 |
|
25056 |
|
25057 |
|
25058 |
|
25059 |
|
25060 |
|
25061 |
|
25062 | function getValue(object, key) {
|
25063 | return object == null ? undefined : object[key];
|
25064 | }
|
25065 |
|
25066 | var _getValue = getValue;
|
25067 |
|
25068 |
|
25069 |
|
25070 |
|
25071 |
|
25072 |
|
25073 |
|
25074 |
|
25075 |
|
25076 |
|
25077 | function getNative(object, key) {
|
25078 | var value = _getValue(object, key);
|
25079 | return _baseIsNative(value) ? value : undefined;
|
25080 | }
|
25081 |
|
25082 | var _getNative = getNative;
|
25083 |
|
25084 |
|
25085 |
|
25086 | var Map$1 = _getNative(_root, 'Map');
|
25087 | var _Map = Map$1;
|
25088 |
|
25089 |
|
25090 |
|
25091 | var nativeCreate = _getNative(Object, 'create');
|
25092 | var _nativeCreate = nativeCreate;
|
25093 |
|
25094 |
|
25095 |
|
25096 |
|
25097 |
|
25098 |
|
25099 |
|
25100 |
|
25101 |
|
25102 | function hashClear() {
|
25103 | this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
|
25104 | this.size = 0;
|
25105 | }
|
25106 |
|
25107 | var _hashClear = hashClear;
|
25108 |
|
25109 |
|
25110 |
|
25111 |
|
25112 |
|
25113 |
|
25114 |
|
25115 |
|
25116 |
|
25117 |
|
25118 |
|
25119 | function hashDelete(key) {
|
25120 | var result = this.has(key) && delete this.__data__[key];
|
25121 | this.size -= result ? 1 : 0;
|
25122 | return result;
|
25123 | }
|
25124 |
|
25125 | var _hashDelete = hashDelete;
|
25126 |
|
25127 |
|
25128 |
|
25129 | var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
25130 |
|
25131 |
|
25132 | var objectProto$3 = Object.prototype;
|
25133 |
|
25134 |
|
25135 | var hasOwnProperty$4 = objectProto$3.hasOwnProperty;
|
25136 |
|
25137 |
|
25138 |
|
25139 |
|
25140 |
|
25141 |
|
25142 |
|
25143 |
|
25144 |
|
25145 |
|
25146 | function hashGet(key) {
|
25147 | var data = this.__data__;
|
25148 |
|
25149 | if (_nativeCreate) {
|
25150 | var result = data[key];
|
25151 | return result === HASH_UNDEFINED ? undefined : result;
|
25152 | }
|
25153 |
|
25154 | return hasOwnProperty$4.call(data, key) ? data[key] : undefined;
|
25155 | }
|
25156 |
|
25157 | var _hashGet = hashGet;
|
25158 |
|
25159 |
|
25160 |
|
25161 | var objectProto$4 = Object.prototype;
|
25162 |
|
25163 |
|
25164 | var hasOwnProperty$5 = objectProto$4.hasOwnProperty;
|
25165 |
|
25166 |
|
25167 |
|
25168 |
|
25169 |
|
25170 |
|
25171 |
|
25172 |
|
25173 |
|
25174 |
|
25175 | function hashHas(key) {
|
25176 | var data = this.__data__;
|
25177 | return _nativeCreate ? data[key] !== undefined : hasOwnProperty$5.call(data, key);
|
25178 | }
|
25179 |
|
25180 | var _hashHas = hashHas;
|
25181 |
|
25182 |
|
25183 |
|
25184 | var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
|
25185 |
|
25186 |
|
25187 |
|
25188 |
|
25189 |
|
25190 |
|
25191 |
|
25192 |
|
25193 |
|
25194 |
|
25195 |
|
25196 | function hashSet(key, value) {
|
25197 | var data = this.__data__;
|
25198 | this.size += this.has(key) ? 0 : 1;
|
25199 | data[key] = _nativeCreate && value === undefined ? HASH_UNDEFINED$1 : value;
|
25200 | return this;
|
25201 | }
|
25202 |
|
25203 | var _hashSet = hashSet;
|
25204 |
|
25205 |
|
25206 |
|
25207 |
|
25208 |
|
25209 |
|
25210 |
|
25211 |
|
25212 |
|
25213 | function Hash(entries) {
|
25214 | var index = -1,
|
25215 | length = entries == null ? 0 : entries.length;
|
25216 | this.clear();
|
25217 |
|
25218 | while (++index < length) {
|
25219 | var entry = entries[index];
|
25220 | this.set(entry[0], entry[1]);
|
25221 | }
|
25222 | }
|
25223 |
|
25224 |
|
25225 | Hash.prototype.clear = _hashClear;
|
25226 | Hash.prototype['delete'] = _hashDelete;
|
25227 | Hash.prototype.get = _hashGet;
|
25228 | Hash.prototype.has = _hashHas;
|
25229 | Hash.prototype.set = _hashSet;
|
25230 | var _Hash = Hash;
|
25231 |
|
25232 |
|
25233 |
|
25234 |
|
25235 |
|
25236 |
|
25237 |
|
25238 |
|
25239 |
|
25240 | function mapCacheClear() {
|
25241 | this.size = 0;
|
25242 | this.__data__ = {
|
25243 | 'hash': new _Hash(),
|
25244 | 'map': new (_Map || _ListCache)(),
|
25245 | 'string': new _Hash()
|
25246 | };
|
25247 | }
|
25248 |
|
25249 | var _mapCacheClear = mapCacheClear;
|
25250 |
|
25251 |
|
25252 |
|
25253 |
|
25254 |
|
25255 |
|
25256 |
|
25257 |
|
25258 | function isKeyable(value) {
|
25259 | var type = typeof value;
|
25260 | return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
|
25261 | }
|
25262 |
|
25263 | var _isKeyable = isKeyable;
|
25264 |
|
25265 |
|
25266 |
|
25267 |
|
25268 |
|
25269 |
|
25270 |
|
25271 |
|
25272 |
|
25273 |
|
25274 | function getMapData(map, key) {
|
25275 | var data = map.__data__;
|
25276 | return _isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
|
25277 | }
|
25278 |
|
25279 | var _getMapData = getMapData;
|
25280 |
|
25281 |
|
25282 |
|
25283 |
|
25284 |
|
25285 |
|
25286 |
|
25287 |
|
25288 |
|
25289 |
|
25290 |
|
25291 | function mapCacheDelete(key) {
|
25292 | var result = _getMapData(this, key)['delete'](key);
|
25293 | this.size -= result ? 1 : 0;
|
25294 | return result;
|
25295 | }
|
25296 |
|
25297 | var _mapCacheDelete = mapCacheDelete;
|
25298 |
|
25299 |
|
25300 |
|
25301 |
|
25302 |
|
25303 |
|
25304 |
|
25305 |
|
25306 |
|
25307 |
|
25308 |
|
25309 | function mapCacheGet(key) {
|
25310 | return _getMapData(this, key).get(key);
|
25311 | }
|
25312 |
|
25313 | var _mapCacheGet = mapCacheGet;
|
25314 |
|
25315 |
|
25316 |
|
25317 |
|
25318 |
|
25319 |
|
25320 |
|
25321 |
|
25322 |
|
25323 |
|
25324 |
|
25325 | function mapCacheHas(key) {
|
25326 | return _getMapData(this, key).has(key);
|
25327 | }
|
25328 |
|
25329 | var _mapCacheHas = mapCacheHas;
|
25330 |
|
25331 |
|
25332 |
|
25333 |
|
25334 |
|
25335 |
|
25336 |
|
25337 |
|
25338 |
|
25339 |
|
25340 |
|
25341 |
|
25342 | function mapCacheSet(key, value) {
|
25343 | var data = _getMapData(this, key),
|
25344 | size = data.size;
|
25345 | data.set(key, value);
|
25346 | this.size += data.size == size ? 0 : 1;
|
25347 | return this;
|
25348 | }
|
25349 |
|
25350 | var _mapCacheSet = mapCacheSet;
|
25351 |
|
25352 |
|
25353 |
|
25354 |
|
25355 |
|
25356 |
|
25357 |
|
25358 |
|
25359 |
|
25360 | function MapCache(entries) {
|
25361 | var index = -1,
|
25362 | length = entries == null ? 0 : entries.length;
|
25363 | this.clear();
|
25364 |
|
25365 | while (++index < length) {
|
25366 | var entry = entries[index];
|
25367 | this.set(entry[0], entry[1]);
|
25368 | }
|
25369 | }
|
25370 |
|
25371 |
|
25372 | MapCache.prototype.clear = _mapCacheClear;
|
25373 | MapCache.prototype['delete'] = _mapCacheDelete;
|
25374 | MapCache.prototype.get = _mapCacheGet;
|
25375 | MapCache.prototype.has = _mapCacheHas;
|
25376 | MapCache.prototype.set = _mapCacheSet;
|
25377 | var _MapCache = MapCache;
|
25378 |
|
25379 |
|
25380 |
|
25381 | var LARGE_ARRAY_SIZE = 200;
|
25382 |
|
25383 |
|
25384 |
|
25385 |
|
25386 |
|
25387 |
|
25388 |
|
25389 |
|
25390 |
|
25391 |
|
25392 |
|
25393 | function stackSet(key, value) {
|
25394 | var data = this.__data__;
|
25395 |
|
25396 | if (data instanceof _ListCache) {
|
25397 | var pairs = data.__data__;
|
25398 |
|
25399 | if (!_Map || pairs.length < LARGE_ARRAY_SIZE - 1) {
|
25400 | pairs.push([key, value]);
|
25401 | this.size = ++data.size;
|
25402 | return this;
|
25403 | }
|
25404 |
|
25405 | data = this.__data__ = new _MapCache(pairs);
|
25406 | }
|
25407 |
|
25408 | data.set(key, value);
|
25409 | this.size = data.size;
|
25410 | return this;
|
25411 | }
|
25412 |
|
25413 | var _stackSet = stackSet;
|
25414 |
|
25415 |
|
25416 |
|
25417 |
|
25418 |
|
25419 |
|
25420 |
|
25421 |
|
25422 |
|
25423 | function Stack(entries) {
|
25424 | var data = this.__data__ = new _ListCache(entries);
|
25425 | this.size = data.size;
|
25426 | }
|
25427 |
|
25428 |
|
25429 | Stack.prototype.clear = _stackClear;
|
25430 | Stack.prototype['delete'] = _stackDelete;
|
25431 | Stack.prototype.get = _stackGet;
|
25432 | Stack.prototype.has = _stackHas;
|
25433 | Stack.prototype.set = _stackSet;
|
25434 | var _Stack = Stack;
|
25435 |
|
25436 |
|
25437 | var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
|
25438 |
|
25439 |
|
25440 |
|
25441 |
|
25442 |
|
25443 |
|
25444 |
|
25445 |
|
25446 |
|
25447 |
|
25448 |
|
25449 | function setCacheAdd(value) {
|
25450 | this.__data__.set(value, HASH_UNDEFINED$2);
|
25451 |
|
25452 | return this;
|
25453 | }
|
25454 |
|
25455 | var _setCacheAdd = setCacheAdd;
|
25456 |
|
25457 |
|
25458 |
|
25459 |
|
25460 |
|
25461 |
|
25462 |
|
25463 |
|
25464 |
|
25465 |
|
25466 | function setCacheHas(value) {
|
25467 | return this.__data__.has(value);
|
25468 | }
|
25469 |
|
25470 | var _setCacheHas = setCacheHas;
|
25471 |
|
25472 |
|
25473 |
|
25474 |
|
25475 |
|
25476 |
|
25477 |
|
25478 |
|
25479 |
|
25480 |
|
25481 | function SetCache(values) {
|
25482 | var index = -1,
|
25483 | length = values == null ? 0 : values.length;
|
25484 | this.__data__ = new _MapCache();
|
25485 |
|
25486 | while (++index < length) {
|
25487 | this.add(values[index]);
|
25488 | }
|
25489 | }
|
25490 |
|
25491 |
|
25492 | SetCache.prototype.add = SetCache.prototype.push = _setCacheAdd;
|
25493 | SetCache.prototype.has = _setCacheHas;
|
25494 | var _SetCache = SetCache;
|
25495 |
|
25496 |
|
25497 |
|
25498 |
|
25499 |
|
25500 |
|
25501 |
|
25502 |
|
25503 |
|
25504 |
|
25505 |
|
25506 | function arraySome(array, predicate) {
|
25507 | var index = -1,
|
25508 | length = array == null ? 0 : array.length;
|
25509 |
|
25510 | while (++index < length) {
|
25511 | if (predicate(array[index], index, array)) {
|
25512 | return true;
|
25513 | }
|
25514 | }
|
25515 |
|
25516 | return false;
|
25517 | }
|
25518 |
|
25519 | var _arraySome = arraySome;
|
25520 |
|
25521 |
|
25522 |
|
25523 |
|
25524 |
|
25525 |
|
25526 |
|
25527 |
|
25528 |
|
25529 | function cacheHas(cache, key) {
|
25530 | return cache.has(key);
|
25531 | }
|
25532 |
|
25533 | var _cacheHas = cacheHas;
|
25534 |
|
25535 |
|
25536 |
|
25537 | var COMPARE_PARTIAL_FLAG = 1,
|
25538 | COMPARE_UNORDERED_FLAG = 2;
|
25539 |
|
25540 |
|
25541 |
|
25542 |
|
25543 |
|
25544 |
|
25545 |
|
25546 |
|
25547 |
|
25548 |
|
25549 |
|
25550 |
|
25551 |
|
25552 |
|
25553 | function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
25554 | var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
|
25555 | arrLength = array.length,
|
25556 | othLength = other.length;
|
25557 |
|
25558 | if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
25559 | return false;
|
25560 | }
|
25561 |
|
25562 |
|
25563 | var stacked = stack.get(array);
|
25564 |
|
25565 | if (stacked && stack.get(other)) {
|
25566 | return stacked == other;
|
25567 | }
|
25568 |
|
25569 | var index = -1,
|
25570 | result = true,
|
25571 | seen = bitmask & COMPARE_UNORDERED_FLAG ? new _SetCache() : undefined;
|
25572 | stack.set(array, other);
|
25573 | stack.set(other, array);
|
25574 |
|
25575 | while (++index < arrLength) {
|
25576 | var arrValue = array[index],
|
25577 | othValue = other[index];
|
25578 |
|
25579 | if (customizer) {
|
25580 | var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
|
25581 | }
|
25582 |
|
25583 | if (compared !== undefined) {
|
25584 | if (compared) {
|
25585 | continue;
|
25586 | }
|
25587 |
|
25588 | result = false;
|
25589 | break;
|
25590 | }
|
25591 |
|
25592 |
|
25593 | if (seen) {
|
25594 | if (!_arraySome(other, function (othValue, othIndex) {
|
25595 | if (!_cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
|
25596 | return seen.push(othIndex);
|
25597 | }
|
25598 | })) {
|
25599 | result = false;
|
25600 | break;
|
25601 | }
|
25602 | } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
|
25603 | result = false;
|
25604 | break;
|
25605 | }
|
25606 | }
|
25607 |
|
25608 | stack['delete'](array);
|
25609 | stack['delete'](other);
|
25610 | return result;
|
25611 | }
|
25612 |
|
25613 | var _equalArrays = equalArrays;
|
25614 |
|
25615 |
|
25616 |
|
25617 | var Uint8Array = _root.Uint8Array;
|
25618 | var _Uint8Array = Uint8Array;
|
25619 |
|
25620 |
|
25621 |
|
25622 |
|
25623 |
|
25624 |
|
25625 |
|
25626 |
|
25627 | function mapToArray(map) {
|
25628 | var index = -1,
|
25629 | result = Array(map.size);
|
25630 | map.forEach(function (value, key) {
|
25631 | result[++index] = [key, value];
|
25632 | });
|
25633 | return result;
|
25634 | }
|
25635 |
|
25636 | var _mapToArray = mapToArray;
|
25637 |
|
25638 |
|
25639 |
|
25640 |
|
25641 |
|
25642 |
|
25643 |
|
25644 |
|
25645 | function setToArray(set) {
|
25646 | var index = -1,
|
25647 | result = Array(set.size);
|
25648 | set.forEach(function (value) {
|
25649 | result[++index] = value;
|
25650 | });
|
25651 | return result;
|
25652 | }
|
25653 |
|
25654 | var _setToArray = setToArray;
|
25655 |
|
25656 |
|
25657 |
|
25658 | var COMPARE_PARTIAL_FLAG$1 = 1,
|
25659 | COMPARE_UNORDERED_FLAG$1 = 2;
|
25660 |
|
25661 |
|
25662 | var boolTag = '[object Boolean]',
|
25663 | dateTag = '[object Date]',
|
25664 | errorTag = '[object Error]',
|
25665 | mapTag = '[object Map]',
|
25666 | numberTag = '[object Number]',
|
25667 | regexpTag = '[object RegExp]',
|
25668 | setTag = '[object Set]',
|
25669 | stringTag = '[object String]',
|
25670 | symbolTag = '[object Symbol]';
|
25671 | var arrayBufferTag = '[object ArrayBuffer]',
|
25672 | dataViewTag = '[object DataView]';
|
25673 |
|
25674 |
|
25675 | var symbolProto = _Symbol ? _Symbol.prototype : undefined,
|
25676 | symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
25677 |
|
25678 |
|
25679 |
|
25680 |
|
25681 |
|
25682 |
|
25683 |
|
25684 |
|
25685 |
|
25686 |
|
25687 |
|
25688 |
|
25689 |
|
25690 |
|
25691 |
|
25692 |
|
25693 |
|
25694 |
|
25695 | function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
25696 | switch (tag) {
|
25697 | case dataViewTag:
|
25698 | if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
|
25699 | return false;
|
25700 | }
|
25701 |
|
25702 | object = object.buffer;
|
25703 | other = other.buffer;
|
25704 |
|
25705 | case arrayBufferTag:
|
25706 | if (object.byteLength != other.byteLength || !equalFunc(new _Uint8Array(object), new _Uint8Array(other))) {
|
25707 | return false;
|
25708 | }
|
25709 |
|
25710 | return true;
|
25711 |
|
25712 | case boolTag:
|
25713 | case dateTag:
|
25714 | case numberTag:
|
25715 |
|
25716 |
|
25717 | return eq_1(+object, +other);
|
25718 |
|
25719 | case errorTag:
|
25720 | return object.name == other.name && object.message == other.message;
|
25721 |
|
25722 | case regexpTag:
|
25723 | case stringTag:
|
25724 |
|
25725 |
|
25726 |
|
25727 | return object == other + '';
|
25728 |
|
25729 | case mapTag:
|
25730 | var convert = _mapToArray;
|
25731 |
|
25732 | case setTag:
|
25733 | var isPartial = bitmask & COMPARE_PARTIAL_FLAG$1;
|
25734 | convert || (convert = _setToArray);
|
25735 |
|
25736 | if (object.size != other.size && !isPartial) {
|
25737 | return false;
|
25738 | }
|
25739 |
|
25740 |
|
25741 | var stacked = stack.get(object);
|
25742 |
|
25743 | if (stacked) {
|
25744 | return stacked == other;
|
25745 | }
|
25746 |
|
25747 | bitmask |= COMPARE_UNORDERED_FLAG$1;
|
25748 |
|
25749 | stack.set(object, other);
|
25750 | var result = _equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
25751 | stack['delete'](object);
|
25752 | return result;
|
25753 |
|
25754 | case symbolTag:
|
25755 | if (symbolValueOf) {
|
25756 | return symbolValueOf.call(object) == symbolValueOf.call(other);
|
25757 | }
|
25758 |
|
25759 | }
|
25760 |
|
25761 | return false;
|
25762 | }
|
25763 |
|
25764 | var _equalByTag = equalByTag;
|
25765 |
|
25766 |
|
25767 |
|
25768 |
|
25769 |
|
25770 |
|
25771 |
|
25772 |
|
25773 |
|
25774 | function arrayPush(array, values) {
|
25775 | var index = -1,
|
25776 | length = values.length,
|
25777 | offset = array.length;
|
25778 |
|
25779 | while (++index < length) {
|
25780 | array[offset + index] = values[index];
|
25781 | }
|
25782 |
|
25783 | return array;
|
25784 | }
|
25785 |
|
25786 | var _arrayPush = arrayPush;
|
25787 |
|
25788 |
|
25789 |
|
25790 |
|
25791 |
|
25792 |
|
25793 |
|
25794 |
|
25795 |
|
25796 |
|
25797 |
|
25798 |
|
25799 |
|
25800 |
|
25801 |
|
25802 |
|
25803 |
|
25804 |
|
25805 |
|
25806 |
|
25807 |
|
25808 |
|
25809 |
|
25810 |
|
25811 | var isArray$1 = Array.isArray;
|
25812 | var isArray_1 = isArray$1;
|
25813 |
|
25814 |
|
25815 |
|
25816 |
|
25817 |
|
25818 |
|
25819 |
|
25820 |
|
25821 |
|
25822 |
|
25823 |
|
25824 |
|
25825 |
|
25826 | function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
25827 | var result = keysFunc(object);
|
25828 | return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
|
25829 | }
|
25830 |
|
25831 | var _baseGetAllKeys = baseGetAllKeys;
|
25832 |
|
25833 |
|
25834 |
|
25835 |
|
25836 |
|
25837 |
|
25838 |
|
25839 |
|
25840 |
|
25841 |
|
25842 | function arrayFilter(array, predicate) {
|
25843 | var index = -1,
|
25844 | length = array == null ? 0 : array.length,
|
25845 | resIndex = 0,
|
25846 | result = [];
|
25847 |
|
25848 | while (++index < length) {
|
25849 | var value = array[index];
|
25850 |
|
25851 | if (predicate(value, index, array)) {
|
25852 | result[resIndex++] = value;
|
25853 | }
|
25854 | }
|
25855 |
|
25856 | return result;
|
25857 | }
|
25858 |
|
25859 | var _arrayFilter = arrayFilter;
|
25860 |
|
25861 |
|
25862 |
|
25863 |
|
25864 |
|
25865 |
|
25866 |
|
25867 |
|
25868 |
|
25869 |
|
25870 |
|
25871 |
|
25872 |
|
25873 |
|
25874 |
|
25875 |
|
25876 |
|
25877 |
|
25878 |
|
25879 | function stubArray() {
|
25880 | return [];
|
25881 | }
|
25882 |
|
25883 | var stubArray_1 = stubArray;
|
25884 |
|
25885 |
|
25886 |
|
25887 | var objectProto$5 = Object.prototype;
|
25888 |
|
25889 |
|
25890 | var propertyIsEnumerable = objectProto$5.propertyIsEnumerable;
|
25891 |
|
25892 |
|
25893 | var nativeGetSymbols = Object.getOwnPropertySymbols;
|
25894 |
|
25895 |
|
25896 |
|
25897 |
|
25898 |
|
25899 |
|
25900 |
|
25901 |
|
25902 | var getSymbols = !nativeGetSymbols ? stubArray_1 : function (object) {
|
25903 | if (object == null) {
|
25904 | return [];
|
25905 | }
|
25906 |
|
25907 | object = Object(object);
|
25908 | return _arrayFilter(nativeGetSymbols(object), function (symbol) {
|
25909 | return propertyIsEnumerable.call(object, symbol);
|
25910 | });
|
25911 | };
|
25912 | var _getSymbols = getSymbols;
|
25913 |
|
25914 |
|
25915 |
|
25916 |
|
25917 |
|
25918 |
|
25919 |
|
25920 |
|
25921 |
|
25922 |
|
25923 | function baseTimes(n, iteratee) {
|
25924 | var index = -1,
|
25925 | result = Array(n);
|
25926 |
|
25927 | while (++index < n) {
|
25928 | result[index] = iteratee(index);
|
25929 | }
|
25930 |
|
25931 | return result;
|
25932 | }
|
25933 |
|
25934 | var _baseTimes = baseTimes;
|
25935 |
|
25936 |
|
25937 |
|
25938 |
|
25939 |
|
25940 |
|
25941 |
|
25942 |
|
25943 |
|
25944 |
|
25945 |
|
25946 |
|
25947 |
|
25948 |
|
25949 |
|
25950 |
|
25951 |
|
25952 |
|
25953 |
|
25954 |
|
25955 |
|
25956 |
|
25957 |
|
25958 |
|
25959 |
|
25960 | function isObjectLike(value) {
|
25961 | return value != null && typeof value == 'object';
|
25962 | }
|
25963 |
|
25964 | var isObjectLike_1 = isObjectLike;
|
25965 |
|
25966 |
|
25967 |
|
25968 | var argsTag = '[object Arguments]';
|
25969 |
|
25970 |
|
25971 |
|
25972 |
|
25973 |
|
25974 |
|
25975 |
|
25976 |
|
25977 | function baseIsArguments(value) {
|
25978 | return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
|
25979 | }
|
25980 |
|
25981 | var _baseIsArguments = baseIsArguments;
|
25982 |
|
25983 |
|
25984 |
|
25985 | var objectProto$6 = Object.prototype;
|
25986 |
|
25987 |
|
25988 | var hasOwnProperty$6 = objectProto$6.hasOwnProperty;
|
25989 |
|
25990 |
|
25991 | var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
|
25992 |
|
25993 |
|
25994 |
|
25995 |
|
25996 |
|
25997 |
|
25998 |
|
25999 |
|
26000 |
|
26001 |
|
26002 |
|
26003 |
|
26004 |
|
26005 |
|
26006 |
|
26007 |
|
26008 |
|
26009 |
|
26010 |
|
26011 | var isArguments = _baseIsArguments(function () {
|
26012 | return arguments;
|
26013 | }()) ? _baseIsArguments : function (value) {
|
26014 | return isObjectLike_1(value) && hasOwnProperty$6.call(value, 'callee') && !propertyIsEnumerable$1.call(value, 'callee');
|
26015 | };
|
26016 | var isArguments_1 = isArguments;
|
26017 |
|
26018 |
|
26019 |
|
26020 |
|
26021 |
|
26022 |
|
26023 |
|
26024 |
|
26025 |
|
26026 |
|
26027 |
|
26028 |
|
26029 |
|
26030 |
|
26031 | function stubFalse() {
|
26032 | return false;
|
26033 | }
|
26034 |
|
26035 | var stubFalse_1 = stubFalse;
|
26036 |
|
26037 | var isBuffer_1 = createCommonjsModule(function (module, exports) {
|
26038 |
|
26039 | var freeExports = exports && !exports.nodeType && exports;
|
26040 |
|
26041 |
|
26042 | var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
26043 |
|
26044 |
|
26045 | var moduleExports = freeModule && freeModule.exports === freeExports;
|
26046 |
|
26047 |
|
26048 | var Buffer = moduleExports ? _root.Buffer : undefined;
|
26049 |
|
26050 |
|
26051 | var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
|
26052 | |
26053 |
|
26054 |
|
26055 |
|
26056 |
|
26057 |
|
26058 |
|
26059 |
|
26060 |
|
26061 |
|
26062 |
|
26063 |
|
26064 |
|
26065 |
|
26066 |
|
26067 |
|
26068 |
|
26069 |
|
26070 | var isBuffer = nativeIsBuffer || stubFalse_1;
|
26071 | module.exports = isBuffer;
|
26072 | });
|
26073 |
|
26074 |
|
26075 | var MAX_SAFE_INTEGER$2 = 9007199254740991;
|
26076 |
|
26077 |
|
26078 | var reIsUint = /^(?:0|[1-9]\d*)$/;
|
26079 |
|
26080 |
|
26081 |
|
26082 |
|
26083 |
|
26084 |
|
26085 |
|
26086 |
|
26087 |
|
26088 | function isIndex(value, length) {
|
26089 | var type = typeof value;
|
26090 | length = length == null ? MAX_SAFE_INTEGER$2 : length;
|
26091 | return !!length && (type == 'number' || type != 'symbol' && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
|
26092 | }
|
26093 |
|
26094 | var _isIndex = isIndex;
|
26095 |
|
26096 |
|
26097 | var MAX_SAFE_INTEGER$3 = 9007199254740991;
|
26098 |
|
26099 |
|
26100 |
|
26101 |
|
26102 |
|
26103 |
|
26104 |
|
26105 |
|
26106 |
|
26107 |
|
26108 |
|
26109 |
|
26110 |
|
26111 |
|
26112 |
|
26113 |
|
26114 |
|
26115 |
|
26116 |
|
26117 |
|
26118 |
|
26119 |
|
26120 |
|
26121 |
|
26122 |
|
26123 |
|
26124 |
|
26125 | function isLength(value) {
|
26126 | return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$3;
|
26127 | }
|
26128 |
|
26129 | var isLength_1 = isLength;
|
26130 |
|
26131 |
|
26132 |
|
26133 | var argsTag$1 = '[object Arguments]',
|
26134 | arrayTag = '[object Array]',
|
26135 | boolTag$1 = '[object Boolean]',
|
26136 | dateTag$1 = '[object Date]',
|
26137 | errorTag$1 = '[object Error]',
|
26138 | funcTag$1 = '[object Function]',
|
26139 | mapTag$1 = '[object Map]',
|
26140 | numberTag$1 = '[object Number]',
|
26141 | objectTag = '[object Object]',
|
26142 | regexpTag$1 = '[object RegExp]',
|
26143 | setTag$1 = '[object Set]',
|
26144 | stringTag$1 = '[object String]',
|
26145 | weakMapTag = '[object WeakMap]';
|
26146 | var arrayBufferTag$1 = '[object ArrayBuffer]',
|
26147 | dataViewTag$1 = '[object DataView]',
|
26148 | float32Tag = '[object Float32Array]',
|
26149 | float64Tag = '[object Float64Array]',
|
26150 | int8Tag = '[object Int8Array]',
|
26151 | int16Tag = '[object Int16Array]',
|
26152 | int32Tag = '[object Int32Array]',
|
26153 | uint8Tag = '[object Uint8Array]',
|
26154 | uint8ClampedTag = '[object Uint8ClampedArray]',
|
26155 | uint16Tag = '[object Uint16Array]',
|
26156 | uint32Tag = '[object Uint32Array]';
|
26157 |
|
26158 |
|
26159 | var typedArrayTags = {};
|
26160 | typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
|
26161 | typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag$1] = typedArrayTags[mapTag$1] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$1] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag] = false;
|
26162 |
|
26163 |
|
26164 |
|
26165 |
|
26166 |
|
26167 |
|
26168 |
|
26169 |
|
26170 | function baseIsTypedArray(value) {
|
26171 | return isObjectLike_1(value) && isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
|
26172 | }
|
26173 |
|
26174 | var _baseIsTypedArray = baseIsTypedArray;
|
26175 |
|
26176 |
|
26177 |
|
26178 |
|
26179 |
|
26180 |
|
26181 |
|
26182 |
|
26183 | function baseUnary(func) {
|
26184 | return function (value) {
|
26185 | return func(value);
|
26186 | };
|
26187 | }
|
26188 |
|
26189 | var _baseUnary = baseUnary;
|
26190 |
|
26191 | var _nodeUtil = createCommonjsModule(function (module, exports) {
|
26192 |
|
26193 | var freeExports = exports && !exports.nodeType && exports;
|
26194 |
|
26195 |
|
26196 | var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
26197 |
|
26198 |
|
26199 | var moduleExports = freeModule && freeModule.exports === freeExports;
|
26200 |
|
26201 |
|
26202 | var freeProcess = moduleExports && _freeGlobal.process;
|
26203 |
|
26204 |
|
26205 | var nodeUtil = function () {
|
26206 | try {
|
26207 |
|
26208 | var types = freeModule && freeModule.require && freeModule.require('util').types;
|
26209 |
|
26210 | if (types) {
|
26211 | return types;
|
26212 | }
|
26213 |
|
26214 |
|
26215 | return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
26216 | } catch (e) {}
|
26217 | }();
|
26218 |
|
26219 | module.exports = nodeUtil;
|
26220 | });
|
26221 |
|
26222 |
|
26223 |
|
26224 | var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
|
26225 |
|
26226 |
|
26227 |
|
26228 |
|
26229 |
|
26230 |
|
26231 |
|
26232 |
|
26233 |
|
26234 |
|
26235 |
|
26236 |
|
26237 |
|
26238 |
|
26239 |
|
26240 |
|
26241 |
|
26242 |
|
26243 | var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
|
26244 | var isTypedArray_1 = isTypedArray;
|
26245 |
|
26246 |
|
26247 |
|
26248 | var objectProto$7 = Object.prototype;
|
26249 |
|
26250 |
|
26251 | var hasOwnProperty$7 = objectProto$7.hasOwnProperty;
|
26252 |
|
26253 |
|
26254 |
|
26255 |
|
26256 |
|
26257 |
|
26258 |
|
26259 |
|
26260 |
|
26261 | function arrayLikeKeys(value, inherited) {
|
26262 | var isArr = isArray_1(value),
|
26263 | isArg = !isArr && isArguments_1(value),
|
26264 | isBuff = !isArr && !isArg && isBuffer_1(value),
|
26265 | isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
|
26266 | skipIndexes = isArr || isArg || isBuff || isType,
|
26267 | result = skipIndexes ? _baseTimes(value.length, String) : [],
|
26268 | length = result.length;
|
26269 |
|
26270 | for (var key in value) {
|
26271 | if ((inherited || hasOwnProperty$7.call(value, key)) && !(skipIndexes && (
|
26272 | key == 'length' ||
|
26273 | isBuff && (key == 'offset' || key == 'parent') ||
|
26274 | isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') ||
|
26275 | _isIndex(key, length)))) {
|
26276 | result.push(key);
|
26277 | }
|
26278 | }
|
26279 |
|
26280 | return result;
|
26281 | }
|
26282 |
|
26283 | var _arrayLikeKeys = arrayLikeKeys;
|
26284 |
|
26285 |
|
26286 | var objectProto$8 = Object.prototype;
|
26287 |
|
26288 |
|
26289 |
|
26290 |
|
26291 |
|
26292 |
|
26293 |
|
26294 |
|
26295 | function isPrototype(value) {
|
26296 | var Ctor = value && value.constructor,
|
26297 | proto = typeof Ctor == 'function' && Ctor.prototype || objectProto$8;
|
26298 | return value === proto;
|
26299 | }
|
26300 |
|
26301 | var _isPrototype = isPrototype;
|
26302 |
|
26303 |
|
26304 |
|
26305 |
|
26306 |
|
26307 |
|
26308 |
|
26309 |
|
26310 |
|
26311 | function overArg(func, transform) {
|
26312 | return function (arg) {
|
26313 | return func(transform(arg));
|
26314 | };
|
26315 | }
|
26316 |
|
26317 | var _overArg = overArg;
|
26318 |
|
26319 |
|
26320 |
|
26321 | var nativeKeys = _overArg(Object.keys, Object);
|
26322 | var _nativeKeys = nativeKeys;
|
26323 |
|
26324 |
|
26325 |
|
26326 | var objectProto$9 = Object.prototype;
|
26327 |
|
26328 |
|
26329 | var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
|
26330 |
|
26331 |
|
26332 |
|
26333 |
|
26334 |
|
26335 |
|
26336 |
|
26337 |
|
26338 | function baseKeys(object) {
|
26339 | if (!_isPrototype(object)) {
|
26340 | return _nativeKeys(object);
|
26341 | }
|
26342 |
|
26343 | var result = [];
|
26344 |
|
26345 | for (var key in Object(object)) {
|
26346 | if (hasOwnProperty$8.call(object, key) && key != 'constructor') {
|
26347 | result.push(key);
|
26348 | }
|
26349 | }
|
26350 |
|
26351 | return result;
|
26352 | }
|
26353 |
|
26354 | var _baseKeys = baseKeys;
|
26355 |
|
26356 |
|
26357 |
|
26358 |
|
26359 |
|
26360 |
|
26361 |
|
26362 |
|
26363 |
|
26364 |
|
26365 |
|
26366 |
|
26367 |
|
26368 |
|
26369 |
|
26370 |
|
26371 |
|
26372 |
|
26373 |
|
26374 |
|
26375 |
|
26376 |
|
26377 |
|
26378 |
|
26379 |
|
26380 |
|
26381 |
|
26382 | function isArrayLike(value) {
|
26383 | return value != null && isLength_1(value.length) && !isFunction_1(value);
|
26384 | }
|
26385 |
|
26386 | var isArrayLike_1 = isArrayLike;
|
26387 |
|
26388 |
|
26389 |
|
26390 |
|
26391 |
|
26392 |
|
26393 |
|
26394 |
|
26395 |
|
26396 |
|
26397 |
|
26398 |
|
26399 |
|
26400 |
|
26401 |
|
26402 |
|
26403 |
|
26404 |
|
26405 |
|
26406 |
|
26407 |
|
26408 |
|
26409 |
|
26410 |
|
26411 |
|
26412 |
|
26413 |
|
26414 |
|
26415 |
|
26416 |
|
26417 | function keys(object) {
|
26418 | return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
|
26419 | }
|
26420 |
|
26421 | var keys_1 = keys;
|
26422 |
|
26423 |
|
26424 |
|
26425 |
|
26426 |
|
26427 |
|
26428 |
|
26429 |
|
26430 |
|
26431 | function getAllKeys(object) {
|
26432 | return _baseGetAllKeys(object, keys_1, _getSymbols);
|
26433 | }
|
26434 |
|
26435 | var _getAllKeys = getAllKeys;
|
26436 |
|
26437 |
|
26438 |
|
26439 | var COMPARE_PARTIAL_FLAG$2 = 1;
|
26440 |
|
26441 |
|
26442 | var objectProto$a = Object.prototype;
|
26443 |
|
26444 |
|
26445 | var hasOwnProperty$9 = objectProto$a.hasOwnProperty;
|
26446 |
|
26447 |
|
26448 |
|
26449 |
|
26450 |
|
26451 |
|
26452 |
|
26453 |
|
26454 |
|
26455 |
|
26456 |
|
26457 |
|
26458 |
|
26459 |
|
26460 | function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
26461 | var isPartial = bitmask & COMPARE_PARTIAL_FLAG$2,
|
26462 | objProps = _getAllKeys(object),
|
26463 | objLength = objProps.length,
|
26464 | othProps = _getAllKeys(other),
|
26465 | othLength = othProps.length;
|
26466 |
|
26467 | if (objLength != othLength && !isPartial) {
|
26468 | return false;
|
26469 | }
|
26470 |
|
26471 | var index = objLength;
|
26472 |
|
26473 | while (index--) {
|
26474 | var key = objProps[index];
|
26475 |
|
26476 | if (!(isPartial ? key in other : hasOwnProperty$9.call(other, key))) {
|
26477 | return false;
|
26478 | }
|
26479 | }
|
26480 |
|
26481 |
|
26482 | var stacked = stack.get(object);
|
26483 |
|
26484 | if (stacked && stack.get(other)) {
|
26485 | return stacked == other;
|
26486 | }
|
26487 |
|
26488 | var result = true;
|
26489 | stack.set(object, other);
|
26490 | stack.set(other, object);
|
26491 | var skipCtor = isPartial;
|
26492 |
|
26493 | while (++index < objLength) {
|
26494 | key = objProps[index];
|
26495 | var objValue = object[key],
|
26496 | othValue = other[key];
|
26497 |
|
26498 | if (customizer) {
|
26499 | var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
|
26500 | }
|
26501 |
|
26502 |
|
26503 | if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
|
26504 | result = false;
|
26505 | break;
|
26506 | }
|
26507 |
|
26508 | skipCtor || (skipCtor = key == 'constructor');
|
26509 | }
|
26510 |
|
26511 | if (result && !skipCtor) {
|
26512 | var objCtor = object.constructor,
|
26513 | othCtor = other.constructor;
|
26514 |
|
26515 | if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
|
26516 | result = false;
|
26517 | }
|
26518 | }
|
26519 |
|
26520 | stack['delete'](object);
|
26521 | stack['delete'](other);
|
26522 | return result;
|
26523 | }
|
26524 |
|
26525 | var _equalObjects = equalObjects;
|
26526 |
|
26527 |
|
26528 |
|
26529 | var DataView = _getNative(_root, 'DataView');
|
26530 | var _DataView = DataView;
|
26531 |
|
26532 |
|
26533 |
|
26534 | var Promise$1 = _getNative(_root, 'Promise');
|
26535 | var _Promise = Promise$1;
|
26536 |
|
26537 |
|
26538 |
|
26539 | var Set$1 = _getNative(_root, 'Set');
|
26540 | var _Set = Set$1;
|
26541 |
|
26542 |
|
26543 |
|
26544 | var WeakMap$1 = _getNative(_root, 'WeakMap');
|
26545 | var _WeakMap = WeakMap$1;
|
26546 |
|
26547 |
|
26548 |
|
26549 | var mapTag$2 = '[object Map]',
|
26550 | objectTag$1 = '[object Object]',
|
26551 | promiseTag = '[object Promise]',
|
26552 | setTag$2 = '[object Set]',
|
26553 | weakMapTag$1 = '[object WeakMap]';
|
26554 | var dataViewTag$2 = '[object DataView]';
|
26555 |
|
26556 |
|
26557 | var dataViewCtorString = _toSource(_DataView),
|
26558 | mapCtorString = _toSource(_Map),
|
26559 | promiseCtorString = _toSource(_Promise),
|
26560 | setCtorString = _toSource(_Set),
|
26561 | weakMapCtorString = _toSource(_WeakMap);
|
26562 |
|
26563 |
|
26564 |
|
26565 |
|
26566 |
|
26567 |
|
26568 |
|
26569 |
|
26570 | var getTag = _baseGetTag;
|
26571 |
|
26572 | if (_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$2 || _Map && getTag(new _Map()) != mapTag$2 || _Promise && getTag(_Promise.resolve()) != promiseTag || _Set && getTag(new _Set()) != setTag$2 || _WeakMap && getTag(new _WeakMap()) != weakMapTag$1) {
|
26573 | getTag = function (value) {
|
26574 | var result = _baseGetTag(value),
|
26575 | Ctor = result == objectTag$1 ? value.constructor : undefined,
|
26576 | ctorString = Ctor ? _toSource(Ctor) : '';
|
26577 |
|
26578 | if (ctorString) {
|
26579 | switch (ctorString) {
|
26580 | case dataViewCtorString:
|
26581 | return dataViewTag$2;
|
26582 |
|
26583 | case mapCtorString:
|
26584 | return mapTag$2;
|
26585 |
|
26586 | case promiseCtorString:
|
26587 | return promiseTag;
|
26588 |
|
26589 | case setCtorString:
|
26590 | return setTag$2;
|
26591 |
|
26592 | case weakMapCtorString:
|
26593 | return weakMapTag$1;
|
26594 | }
|
26595 | }
|
26596 |
|
26597 | return result;
|
26598 | };
|
26599 | }
|
26600 |
|
26601 | var _getTag = getTag;
|
26602 |
|
26603 |
|
26604 |
|
26605 | var COMPARE_PARTIAL_FLAG$3 = 1;
|
26606 |
|
26607 |
|
26608 | var argsTag$2 = '[object Arguments]',
|
26609 | arrayTag$1 = '[object Array]',
|
26610 | objectTag$2 = '[object Object]';
|
26611 |
|
26612 |
|
26613 | var objectProto$b = Object.prototype;
|
26614 |
|
26615 |
|
26616 | var hasOwnProperty$a = objectProto$b.hasOwnProperty;
|
26617 |
|
26618 |
|
26619 |
|
26620 |
|
26621 |
|
26622 |
|
26623 |
|
26624 |
|
26625 |
|
26626 |
|
26627 |
|
26628 |
|
26629 |
|
26630 |
|
26631 |
|
26632 | function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
26633 | var objIsArr = isArray_1(object),
|
26634 | othIsArr = isArray_1(other),
|
26635 | objTag = objIsArr ? arrayTag$1 : _getTag(object),
|
26636 | othTag = othIsArr ? arrayTag$1 : _getTag(other);
|
26637 | objTag = objTag == argsTag$2 ? objectTag$2 : objTag;
|
26638 | othTag = othTag == argsTag$2 ? objectTag$2 : othTag;
|
26639 | var objIsObj = objTag == objectTag$2,
|
26640 | othIsObj = othTag == objectTag$2,
|
26641 | isSameTag = objTag == othTag;
|
26642 |
|
26643 | if (isSameTag && isBuffer_1(object)) {
|
26644 | if (!isBuffer_1(other)) {
|
26645 | return false;
|
26646 | }
|
26647 |
|
26648 | objIsArr = true;
|
26649 | objIsObj = false;
|
26650 | }
|
26651 |
|
26652 | if (isSameTag && !objIsObj) {
|
26653 | stack || (stack = new _Stack());
|
26654 | return objIsArr || isTypedArray_1(object) ? _equalArrays(object, other, bitmask, customizer, equalFunc, stack) : _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
26655 | }
|
26656 |
|
26657 | if (!(bitmask & COMPARE_PARTIAL_FLAG$3)) {
|
26658 | var objIsWrapped = objIsObj && hasOwnProperty$a.call(object, '__wrapped__'),
|
26659 | othIsWrapped = othIsObj && hasOwnProperty$a.call(other, '__wrapped__');
|
26660 |
|
26661 | if (objIsWrapped || othIsWrapped) {
|
26662 | var objUnwrapped = objIsWrapped ? object.value() : object,
|
26663 | othUnwrapped = othIsWrapped ? other.value() : other;
|
26664 | stack || (stack = new _Stack());
|
26665 | return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
|
26666 | }
|
26667 | }
|
26668 |
|
26669 | if (!isSameTag) {
|
26670 | return false;
|
26671 | }
|
26672 |
|
26673 | stack || (stack = new _Stack());
|
26674 | return _equalObjects(object, other, bitmask, customizer, equalFunc, stack);
|
26675 | }
|
26676 |
|
26677 | var _baseIsEqualDeep = baseIsEqualDeep;
|
26678 |
|
26679 |
|
26680 |
|
26681 |
|
26682 |
|
26683 |
|
26684 |
|
26685 |
|
26686 |
|
26687 |
|
26688 |
|
26689 |
|
26690 |
|
26691 |
|
26692 |
|
26693 |
|
26694 | function baseIsEqual(value, other, bitmask, customizer, stack) {
|
26695 | if (value === other) {
|
26696 | return true;
|
26697 | }
|
26698 |
|
26699 | if (value == null || other == null || !isObjectLike_1(value) && !isObjectLike_1(other)) {
|
26700 | return value !== value && other !== other;
|
26701 | }
|
26702 |
|
26703 | return _baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
|
26704 | }
|
26705 |
|
26706 | var _baseIsEqual = baseIsEqual;
|
26707 |
|
26708 |
|
26709 |
|
26710 | var COMPARE_PARTIAL_FLAG$4 = 1,
|
26711 | COMPARE_UNORDERED_FLAG$2 = 2;
|
26712 |
|
26713 |
|
26714 |
|
26715 |
|
26716 |
|
26717 |
|
26718 |
|
26719 |
|
26720 |
|
26721 |
|
26722 |
|
26723 | function baseIsMatch(object, source, matchData, customizer) {
|
26724 | var index = matchData.length,
|
26725 | length = index,
|
26726 | noCustomizer = !customizer;
|
26727 |
|
26728 | if (object == null) {
|
26729 | return !length;
|
26730 | }
|
26731 |
|
26732 | object = Object(object);
|
26733 |
|
26734 | while (index--) {
|
26735 | var data = matchData[index];
|
26736 |
|
26737 | if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
|
26738 | return false;
|
26739 | }
|
26740 | }
|
26741 |
|
26742 | while (++index < length) {
|
26743 | data = matchData[index];
|
26744 | var key = data[0],
|
26745 | objValue = object[key],
|
26746 | srcValue = data[1];
|
26747 |
|
26748 | if (noCustomizer && data[2]) {
|
26749 | if (objValue === undefined && !(key in object)) {
|
26750 | return false;
|
26751 | }
|
26752 | } else {
|
26753 | var stack = new _Stack();
|
26754 |
|
26755 | if (customizer) {
|
26756 | var result = customizer(objValue, srcValue, key, object, source, stack);
|
26757 | }
|
26758 |
|
26759 | if (!(result === undefined ? _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$4 | COMPARE_UNORDERED_FLAG$2, customizer, stack) : result)) {
|
26760 | return false;
|
26761 | }
|
26762 | }
|
26763 | }
|
26764 |
|
26765 | return true;
|
26766 | }
|
26767 |
|
26768 | var _baseIsMatch = baseIsMatch;
|
26769 |
|
26770 |
|
26771 |
|
26772 |
|
26773 |
|
26774 |
|
26775 |
|
26776 |
|
26777 |
|
26778 |
|
26779 | function isStrictComparable(value) {
|
26780 | return value === value && !isObject_1(value);
|
26781 | }
|
26782 |
|
26783 | var _isStrictComparable = isStrictComparable;
|
26784 |
|
26785 |
|
26786 |
|
26787 |
|
26788 |
|
26789 |
|
26790 |
|
26791 |
|
26792 |
|
26793 | function getMatchData(object) {
|
26794 | var result = keys_1(object),
|
26795 | length = result.length;
|
26796 |
|
26797 | while (length--) {
|
26798 | var key = result[length],
|
26799 | value = object[key];
|
26800 | result[length] = [key, value, _isStrictComparable(value)];
|
26801 | }
|
26802 |
|
26803 | return result;
|
26804 | }
|
26805 |
|
26806 | var _getMatchData = getMatchData;
|
26807 |
|
26808 |
|
26809 |
|
26810 |
|
26811 |
|
26812 |
|
26813 |
|
26814 |
|
26815 |
|
26816 |
|
26817 | function matchesStrictComparable(key, srcValue) {
|
26818 | return function (object) {
|
26819 | if (object == null) {
|
26820 | return false;
|
26821 | }
|
26822 |
|
26823 | return object[key] === srcValue && (srcValue !== undefined || key in Object(object));
|
26824 | };
|
26825 | }
|
26826 |
|
26827 | var _matchesStrictComparable = matchesStrictComparable;
|
26828 |
|
26829 |
|
26830 |
|
26831 |
|
26832 |
|
26833 |
|
26834 |
|
26835 |
|
26836 |
|
26837 | function baseMatches(source) {
|
26838 | var matchData = _getMatchData(source);
|
26839 |
|
26840 | if (matchData.length == 1 && matchData[0][2]) {
|
26841 | return _matchesStrictComparable(matchData[0][0], matchData[0][1]);
|
26842 | }
|
26843 |
|
26844 | return function (object) {
|
26845 | return object === source || _baseIsMatch(object, source, matchData);
|
26846 | };
|
26847 | }
|
26848 |
|
26849 | var _baseMatches = baseMatches;
|
26850 |
|
26851 |
|
26852 |
|
26853 | var symbolTag$1 = '[object Symbol]';
|
26854 |
|
26855 |
|
26856 |
|
26857 |
|
26858 |
|
26859 |
|
26860 |
|
26861 |
|
26862 |
|
26863 |
|
26864 |
|
26865 |
|
26866 |
|
26867 |
|
26868 |
|
26869 |
|
26870 |
|
26871 |
|
26872 | function isSymbol(value) {
|
26873 | return typeof value == 'symbol' || isObjectLike_1(value) && _baseGetTag(value) == symbolTag$1;
|
26874 | }
|
26875 |
|
26876 | var isSymbol_1 = isSymbol;
|
26877 |
|
26878 |
|
26879 |
|
26880 | var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
26881 | reIsPlainProp = /^\w*$/;
|
26882 |
|
26883 |
|
26884 |
|
26885 |
|
26886 |
|
26887 |
|
26888 |
|
26889 |
|
26890 |
|
26891 | function isKey(value, object) {
|
26892 | if (isArray_1(value)) {
|
26893 | return false;
|
26894 | }
|
26895 |
|
26896 | var type = typeof value;
|
26897 |
|
26898 | if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol_1(value)) {
|
26899 | return true;
|
26900 | }
|
26901 |
|
26902 | return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
|
26903 | }
|
26904 |
|
26905 | var _isKey = isKey;
|
26906 |
|
26907 |
|
26908 |
|
26909 | var FUNC_ERROR_TEXT = 'Expected a function';
|
26910 |
|
26911 |
|
26912 |
|
26913 |
|
26914 |
|
26915 |
|
26916 |
|
26917 |
|
26918 |
|
26919 |
|
26920 |
|
26921 |
|
26922 |
|
26923 |
|
26924 |
|
26925 |
|
26926 |
|
26927 |
|
26928 |
|
26929 |
|
26930 |
|
26931 |
|
26932 |
|
26933 |
|
26934 |
|
26935 |
|
26936 |
|
26937 |
|
26938 |
|
26939 |
|
26940 |
|
26941 |
|
26942 |
|
26943 |
|
26944 |
|
26945 |
|
26946 |
|
26947 |
|
26948 |
|
26949 |
|
26950 |
|
26951 |
|
26952 |
|
26953 |
|
26954 |
|
26955 | function memoize(func, resolver) {
|
26956 | if (typeof func != 'function' || resolver != null && typeof resolver != 'function') {
|
26957 | throw new TypeError(FUNC_ERROR_TEXT);
|
26958 | }
|
26959 |
|
26960 | var memoized = function () {
|
26961 | var args = arguments,
|
26962 | key = resolver ? resolver.apply(this, args) : args[0],
|
26963 | cache = memoized.cache;
|
26964 |
|
26965 | if (cache.has(key)) {
|
26966 | return cache.get(key);
|
26967 | }
|
26968 |
|
26969 | var result = func.apply(this, args);
|
26970 | memoized.cache = cache.set(key, result) || cache;
|
26971 | return result;
|
26972 | };
|
26973 |
|
26974 | memoized.cache = new (memoize.Cache || _MapCache)();
|
26975 | return memoized;
|
26976 | }
|
26977 |
|
26978 |
|
26979 | memoize.Cache = _MapCache;
|
26980 | var memoize_1 = memoize;
|
26981 |
|
26982 |
|
26983 |
|
26984 | var MAX_MEMOIZE_SIZE = 500;
|
26985 |
|
26986 |
|
26987 |
|
26988 |
|
26989 |
|
26990 |
|
26991 |
|
26992 |
|
26993 |
|
26994 | function memoizeCapped(func) {
|
26995 | var result = memoize_1(func, function (key) {
|
26996 | if (cache.size === MAX_MEMOIZE_SIZE) {
|
26997 | cache.clear();
|
26998 | }
|
26999 |
|
27000 | return key;
|
27001 | });
|
27002 | var cache = result.cache;
|
27003 | return result;
|
27004 | }
|
27005 |
|
27006 | var _memoizeCapped = memoizeCapped;
|
27007 |
|
27008 |
|
27009 |
|
27010 | var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
27011 |
|
27012 |
|
27013 | var reEscapeChar = /\\(\\)?/g;
|
27014 |
|
27015 |
|
27016 |
|
27017 |
|
27018 |
|
27019 |
|
27020 |
|
27021 |
|
27022 | var stringToPath = _memoizeCapped(function (string) {
|
27023 | var result = [];
|
27024 |
|
27025 | if (string.charCodeAt(0) === 46
|
27026 |
|
27027 | ) {
|
27028 | result.push('');
|
27029 | }
|
27030 |
|
27031 | string.replace(rePropName, function (match, number, quote, subString) {
|
27032 | result.push(quote ? subString.replace(reEscapeChar, '$1') : number || match);
|
27033 | });
|
27034 | return result;
|
27035 | });
|
27036 | var _stringToPath = stringToPath;
|
27037 |
|
27038 |
|
27039 |
|
27040 |
|
27041 |
|
27042 |
|
27043 |
|
27044 |
|
27045 |
|
27046 |
|
27047 | function arrayMap(array, iteratee) {
|
27048 | var index = -1,
|
27049 | length = array == null ? 0 : array.length,
|
27050 | result = Array(length);
|
27051 |
|
27052 | while (++index < length) {
|
27053 | result[index] = iteratee(array[index], index, array);
|
27054 | }
|
27055 |
|
27056 | return result;
|
27057 | }
|
27058 |
|
27059 | var _arrayMap = arrayMap;
|
27060 |
|
27061 |
|
27062 |
|
27063 | var INFINITY = 1 / 0;
|
27064 |
|
27065 |
|
27066 | var symbolProto$1 = _Symbol ? _Symbol.prototype : undefined,
|
27067 | symbolToString = symbolProto$1 ? symbolProto$1.toString : undefined;
|
27068 |
|
27069 |
|
27070 |
|
27071 |
|
27072 |
|
27073 |
|
27074 |
|
27075 |
|
27076 |
|
27077 | function baseToString(value) {
|
27078 |
|
27079 | if (typeof value == 'string') {
|
27080 | return value;
|
27081 | }
|
27082 |
|
27083 | if (isArray_1(value)) {
|
27084 |
|
27085 | return _arrayMap(value, baseToString) + '';
|
27086 | }
|
27087 |
|
27088 | if (isSymbol_1(value)) {
|
27089 | return symbolToString ? symbolToString.call(value) : '';
|
27090 | }
|
27091 |
|
27092 | var result = value + '';
|
27093 | return result == '0' && 1 / value == -INFINITY ? '-0' : result;
|
27094 | }
|
27095 |
|
27096 | var _baseToString = baseToString;
|
27097 |
|
27098 |
|
27099 |
|
27100 |
|
27101 |
|
27102 |
|
27103 |
|
27104 |
|
27105 |
|
27106 |
|
27107 |
|
27108 |
|
27109 |
|
27110 |
|
27111 |
|
27112 |
|
27113 |
|
27114 |
|
27115 |
|
27116 |
|
27117 |
|
27118 |
|
27119 |
|
27120 | function toString(value) {
|
27121 | return value == null ? '' : _baseToString(value);
|
27122 | }
|
27123 |
|
27124 | var toString_1 = toString;
|
27125 |
|
27126 |
|
27127 |
|
27128 |
|
27129 |
|
27130 |
|
27131 |
|
27132 |
|
27133 |
|
27134 |
|
27135 | function castPath(value, object) {
|
27136 | if (isArray_1(value)) {
|
27137 | return value;
|
27138 | }
|
27139 |
|
27140 | return _isKey(value, object) ? [value] : _stringToPath(toString_1(value));
|
27141 | }
|
27142 |
|
27143 | var _castPath = castPath;
|
27144 |
|
27145 |
|
27146 |
|
27147 | var INFINITY$1 = 1 / 0;
|
27148 |
|
27149 |
|
27150 |
|
27151 |
|
27152 |
|
27153 |
|
27154 |
|
27155 |
|
27156 | function toKey(value) {
|
27157 | if (typeof value == 'string' || isSymbol_1(value)) {
|
27158 | return value;
|
27159 | }
|
27160 |
|
27161 | var result = value + '';
|
27162 | return result == '0' && 1 / value == -INFINITY$1 ? '-0' : result;
|
27163 | }
|
27164 |
|
27165 | var _toKey = toKey;
|
27166 |
|
27167 |
|
27168 |
|
27169 |
|
27170 |
|
27171 |
|
27172 |
|
27173 |
|
27174 |
|
27175 |
|
27176 | function baseGet(object, path) {
|
27177 | path = _castPath(path, object);
|
27178 | var index = 0,
|
27179 | length = path.length;
|
27180 |
|
27181 | while (object != null && index < length) {
|
27182 | object = object[_toKey(path[index++])];
|
27183 | }
|
27184 |
|
27185 | return index && index == length ? object : undefined;
|
27186 | }
|
27187 |
|
27188 | var _baseGet = baseGet;
|
27189 |
|
27190 |
|
27191 |
|
27192 |
|
27193 |
|
27194 |
|
27195 |
|
27196 |
|
27197 |
|
27198 |
|
27199 |
|
27200 |
|
27201 |
|
27202 |
|
27203 |
|
27204 |
|
27205 |
|
27206 |
|
27207 |
|
27208 |
|
27209 |
|
27210 |
|
27211 |
|
27212 |
|
27213 |
|
27214 |
|
27215 |
|
27216 | function get$1(object, path, defaultValue) {
|
27217 | var result = object == null ? undefined : _baseGet(object, path);
|
27218 | return result === undefined ? defaultValue : result;
|
27219 | }
|
27220 |
|
27221 | var get_1 = get$1;
|
27222 |
|
27223 | /**
|
27224 | * The base implementation of `_.hasIn` without support for deep paths.
|
27225 | *
|
27226 | * @private
|
27227 | * @param {Object} [object] The object to query.
|
27228 | * @param {Array|string} key The key to check.
|
27229 | * @returns {boolean} Returns `true` if `key` exists, else `false`.
|
27230 | */
|
27231 | function baseHasIn(object, key) {
|
27232 | return object != null && key in Object(object);
|
27233 | }
|
27234 |
|
27235 | var _baseHasIn = baseHasIn;
|
27236 |
|
27237 |
|
27238 |
|
27239 |
|
27240 |
|
27241 |
|
27242 |
|
27243 |
|
27244 |
|
27245 |
|
27246 |
|
27247 | function hasPath(object, path, hasFunc) {
|
27248 | path = _castPath(path, object);
|
27249 | var index = -1,
|
27250 | length = path.length,
|
27251 | result = false;
|
27252 |
|
27253 | while (++index < length) {
|
27254 | var key = _toKey(path[index]);
|
27255 |
|
27256 | if (!(result = object != null && hasFunc(object, key))) {
|
27257 | break;
|
27258 | }
|
27259 |
|
27260 | object = object[key];
|
27261 | }
|
27262 |
|
27263 | if (result || ++index != length) {
|
27264 | return result;
|
27265 | }
|
27266 |
|
27267 | length = object == null ? 0 : object.length;
|
27268 | return !!length && isLength_1(length) && _isIndex(key, length) && (isArray_1(object) || isArguments_1(object));
|
27269 | }
|
27270 |
|
27271 | var _hasPath = hasPath;
|
27272 |
|
27273 |
|
27274 |
|
27275 |
|
27276 |
|
27277 |
|
27278 |
|
27279 |
|
27280 |
|
27281 |
|
27282 |
|
27283 |
|
27284 |
|
27285 |
|
27286 |
|
27287 |
|
27288 |
|
27289 |
|
27290 |
|
27291 |
|
27292 |
|
27293 |
|
27294 |
|
27295 |
|
27296 |
|
27297 |
|
27298 |
|
27299 |
|
27300 | function hasIn(object, path) {
|
27301 | return object != null && _hasPath(object, path, _baseHasIn);
|
27302 | }
|
27303 |
|
27304 | var hasIn_1 = hasIn;
|
27305 |
|
27306 |
|
27307 |
|
27308 | var COMPARE_PARTIAL_FLAG$5 = 1,
|
27309 | COMPARE_UNORDERED_FLAG$3 = 2;
|
27310 |
|
27311 |
|
27312 |
|
27313 |
|
27314 |
|
27315 |
|
27316 |
|
27317 |
|
27318 |
|
27319 | function baseMatchesProperty(path, srcValue) {
|
27320 | if (_isKey(path) && _isStrictComparable(srcValue)) {
|
27321 | return _matchesStrictComparable(_toKey(path), srcValue);
|
27322 | }
|
27323 |
|
27324 | return function (object) {
|
27325 | var objValue = get_1(object, path);
|
27326 | return objValue === undefined && objValue === srcValue ? hasIn_1(object, path) : _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$5 | COMPARE_UNORDERED_FLAG$3);
|
27327 | };
|
27328 | }
|
27329 |
|
27330 | var _baseMatchesProperty = baseMatchesProperty;
|
27331 |
|
27332 |
|
27333 |
|
27334 |
|
27335 |
|
27336 |
|
27337 |
|
27338 |
|
27339 |
|
27340 |
|
27341 |
|
27342 |
|
27343 |
|
27344 |
|
27345 |
|
27346 |
|
27347 |
|
27348 | function identity(value) {
|
27349 | return value;
|
27350 | }
|
27351 |
|
27352 | var identity_1 = identity;
|
27353 |
|
27354 |
|
27355 |
|
27356 |
|
27357 |
|
27358 |
|
27359 |
|
27360 |
|
27361 | function baseProperty(key) {
|
27362 | return function (object) {
|
27363 | return object == null ? undefined : object[key];
|
27364 | };
|
27365 | }
|
27366 |
|
27367 | var _baseProperty = baseProperty;
|
27368 |
|
27369 |
|
27370 |
|
27371 |
|
27372 |
|
27373 |
|
27374 |
|
27375 |
|
27376 |
|
27377 | function basePropertyDeep(path) {
|
27378 | return function (object) {
|
27379 | return _baseGet(object, path);
|
27380 | };
|
27381 | }
|
27382 |
|
27383 | var _basePropertyDeep = basePropertyDeep;
|
27384 |
|
27385 |
|
27386 |
|
27387 |
|
27388 |
|
27389 |
|
27390 |
|
27391 |
|
27392 |
|
27393 |
|
27394 |
|
27395 |
|
27396 |
|
27397 |
|
27398 |
|
27399 |
|
27400 |
|
27401 |
|
27402 |
|
27403 |
|
27404 |
|
27405 |
|
27406 |
|
27407 |
|
27408 | function property(path) {
|
27409 | return _isKey(path) ? _baseProperty(_toKey(path)) : _basePropertyDeep(path);
|
27410 | }
|
27411 |
|
27412 | var property_1 = property;
|
27413 |
|
27414 |
|
27415 |
|
27416 |
|
27417 |
|
27418 |
|
27419 |
|
27420 |
|
27421 |
|
27422 | function baseIteratee(value) {
|
27423 |
|
27424 |
|
27425 | if (typeof value == 'function') {
|
27426 | return value;
|
27427 | }
|
27428 |
|
27429 | if (value == null) {
|
27430 | return identity_1;
|
27431 | }
|
27432 |
|
27433 | if (typeof value == 'object') {
|
27434 | return isArray_1(value) ? _baseMatchesProperty(value[0], value[1]) : _baseMatches(value);
|
27435 | }
|
27436 |
|
27437 | return property_1(value);
|
27438 | }
|
27439 |
|
27440 | var _baseIteratee = baseIteratee;
|
27441 |
|
27442 |
|
27443 |
|
27444 |
|
27445 |
|
27446 |
|
27447 |
|
27448 |
|
27449 |
|
27450 |
|
27451 |
|
27452 |
|
27453 | function baseFindIndex(array, predicate, fromIndex, fromRight) {
|
27454 | var length = array.length,
|
27455 | index = fromIndex + (fromRight ? 1 : -1);
|
27456 |
|
27457 | while (fromRight ? index-- : ++index < length) {
|
27458 | if (predicate(array[index], index, array)) {
|
27459 | return index;
|
27460 | }
|
27461 | }
|
27462 |
|
27463 | return -1;
|
27464 | }
|
27465 |
|
27466 | var _baseFindIndex = baseFindIndex;
|
27467 |
|
27468 |
|
27469 |
|
27470 |
|
27471 |
|
27472 |
|
27473 |
|
27474 |
|
27475 | function baseIsNaN(value) {
|
27476 | return value !== value;
|
27477 | }
|
27478 |
|
27479 | var _baseIsNaN = baseIsNaN;
|
27480 |
|
27481 |
|
27482 |
|
27483 |
|
27484 |
|
27485 |
|
27486 |
|
27487 |
|
27488 |
|
27489 |
|
27490 |
|
27491 | function strictIndexOf(array, value, fromIndex) {
|
27492 | var index = fromIndex - 1,
|
27493 | length = array.length;
|
27494 |
|
27495 | while (++index < length) {
|
27496 | if (array[index] === value) {
|
27497 | return index;
|
27498 | }
|
27499 | }
|
27500 |
|
27501 | return -1;
|
27502 | }
|
27503 |
|
27504 | var _strictIndexOf = strictIndexOf;
|
27505 |
|
27506 |
|
27507 |
|
27508 |
|
27509 |
|
27510 |
|
27511 |
|
27512 |
|
27513 |
|
27514 |
|
27515 |
|
27516 | function baseIndexOf(array, value, fromIndex) {
|
27517 | return value === value ? _strictIndexOf(array, value, fromIndex) : _baseFindIndex(array, _baseIsNaN, fromIndex);
|
27518 | }
|
27519 |
|
27520 | var _baseIndexOf = baseIndexOf;
|
27521 |
|
27522 |
|
27523 |
|
27524 |
|
27525 |
|
27526 |
|
27527 |
|
27528 |
|
27529 |
|
27530 |
|
27531 |
|
27532 | function arrayIncludes(array, value) {
|
27533 | var length = array == null ? 0 : array.length;
|
27534 | return !!length && _baseIndexOf(array, value, 0) > -1;
|
27535 | }
|
27536 |
|
27537 | var _arrayIncludes = arrayIncludes;
|
27538 |
|
27539 |
|
27540 |
|
27541 |
|
27542 |
|
27543 |
|
27544 |
|
27545 |
|
27546 |
|
27547 |
|
27548 | function arrayIncludesWith(array, value, comparator) {
|
27549 | var index = -1,
|
27550 | length = array == null ? 0 : array.length;
|
27551 |
|
27552 | while (++index < length) {
|
27553 | if (comparator(value, array[index])) {
|
27554 | return true;
|
27555 | }
|
27556 | }
|
27557 |
|
27558 | return false;
|
27559 | }
|
27560 |
|
27561 | var _arrayIncludesWith = arrayIncludesWith;
|
27562 |
|
27563 |
|
27564 |
|
27565 |
|
27566 |
|
27567 |
|
27568 |
|
27569 |
|
27570 |
|
27571 |
|
27572 |
|
27573 |
|
27574 |
|
27575 | function noop() {
|
27576 | }
|
27577 |
|
27578 | var noop_1 = noop;
|
27579 |
|
27580 |
|
27581 |
|
27582 | var INFINITY$2 = 1 / 0;
|
27583 |
|
27584 |
|
27585 |
|
27586 |
|
27587 |
|
27588 |
|
27589 |
|
27590 |
|
27591 | var createSet = !(_Set && 1 / _setToArray(new _Set([, -0]))[1] == INFINITY$2) ? noop_1 : function (values) {
|
27592 | return new _Set(values);
|
27593 | };
|
27594 | var _createSet = createSet;
|
27595 |
|
27596 |
|
27597 |
|
27598 | var LARGE_ARRAY_SIZE$1 = 200;
|
27599 |
|
27600 |
|
27601 |
|
27602 |
|
27603 |
|
27604 |
|
27605 |
|
27606 |
|
27607 |
|
27608 |
|
27609 | function baseUniq(array, iteratee, comparator) {
|
27610 | var index = -1,
|
27611 | includes = _arrayIncludes,
|
27612 | length = array.length,
|
27613 | isCommon = true,
|
27614 | result = [],
|
27615 | seen = result;
|
27616 |
|
27617 | if (comparator) {
|
27618 | isCommon = false;
|
27619 | includes = _arrayIncludesWith;
|
27620 | } else if (length >= LARGE_ARRAY_SIZE$1) {
|
27621 | var set = iteratee ? null : _createSet(array);
|
27622 |
|
27623 | if (set) {
|
27624 | return _setToArray(set);
|
27625 | }
|
27626 |
|
27627 | isCommon = false;
|
27628 | includes = _cacheHas;
|
27629 | seen = new _SetCache();
|
27630 | } else {
|
27631 | seen = iteratee ? [] : result;
|
27632 | }
|
27633 |
|
27634 | outer: while (++index < length) {
|
27635 | var value = array[index],
|
27636 | computed = iteratee ? iteratee(value) : value;
|
27637 | value = comparator || value !== 0 ? value : 0;
|
27638 |
|
27639 | if (isCommon && computed === computed) {
|
27640 | var seenIndex = seen.length;
|
27641 |
|
27642 | while (seenIndex--) {
|
27643 | if (seen[seenIndex] === computed) {
|
27644 | continue outer;
|
27645 | }
|
27646 | }
|
27647 |
|
27648 | if (iteratee) {
|
27649 | seen.push(computed);
|
27650 | }
|
27651 |
|
27652 | result.push(value);
|
27653 | } else if (!includes(seen, computed, comparator)) {
|
27654 | if (seen !== result) {
|
27655 | seen.push(computed);
|
27656 | }
|
27657 |
|
27658 | result.push(value);
|
27659 | }
|
27660 | }
|
27661 |
|
27662 | return result;
|
27663 | }
|
27664 |
|
27665 | var _baseUniq = baseUniq;
|
27666 |
|
27667 |
|
27668 |
|
27669 |
|
27670 |
|
27671 |
|
27672 |
|
27673 |
|
27674 |
|
27675 |
|
27676 |
|
27677 |
|
27678 |
|
27679 |
|
27680 |
|
27681 |
|
27682 |
|
27683 |
|
27684 |
|
27685 |
|
27686 |
|
27687 |
|
27688 |
|
27689 |
|
27690 |
|
27691 | function uniqBy(array, iteratee) {
|
27692 | return array && array.length ? _baseUniq(array, _baseIteratee(iteratee)) : [];
|
27693 | }
|
27694 |
|
27695 | var uniqBy_1 = uniqBy;
|
27696 |
|
27697 |
|
27698 |
|
27699 |
|
27700 |
|
27701 |
|
27702 |
|
27703 |
|
27704 |
|
27705 |
|
27706 |
|
27707 | function arrayAggregator(array, setter, iteratee, accumulator) {
|
27708 | var index = -1,
|
27709 | length = array == null ? 0 : array.length;
|
27710 |
|
27711 | while (++index < length) {
|
27712 | var value = array[index];
|
27713 | setter(accumulator, value, iteratee(value), array);
|
27714 | }
|
27715 |
|
27716 | return accumulator;
|
27717 | }
|
27718 |
|
27719 | var _arrayAggregator = arrayAggregator;
|
27720 |
|
27721 |
|
27722 |
|
27723 |
|
27724 |
|
27725 |
|
27726 |
|
27727 |
|
27728 | function createBaseFor(fromRight) {
|
27729 | return function (object, iteratee, keysFunc) {
|
27730 | var index = -1,
|
27731 | iterable = Object(object),
|
27732 | props = keysFunc(object),
|
27733 | length = props.length;
|
27734 |
|
27735 | while (length--) {
|
27736 | var key = props[fromRight ? length : ++index];
|
27737 |
|
27738 | if (iteratee(iterable[key], key, iterable) === false) {
|
27739 | break;
|
27740 | }
|
27741 | }
|
27742 |
|
27743 | return object;
|
27744 | };
|
27745 | }
|
27746 |
|
27747 | var _createBaseFor = createBaseFor;
|
27748 |
|
27749 |
|
27750 |
|
27751 |
|
27752 |
|
27753 |
|
27754 |
|
27755 |
|
27756 |
|
27757 |
|
27758 |
|
27759 |
|
27760 |
|
27761 | var baseFor = _createBaseFor();
|
27762 | var _baseFor = baseFor;
|
27763 |
|
27764 |
|
27765 |
|
27766 |
|
27767 |
|
27768 |
|
27769 |
|
27770 |
|
27771 |
|
27772 |
|
27773 | function baseForOwn(object, iteratee) {
|
27774 | return object && _baseFor(object, iteratee, keys_1);
|
27775 | }
|
27776 |
|
27777 | var _baseForOwn = baseForOwn;
|
27778 |
|
27779 |
|
27780 |
|
27781 |
|
27782 |
|
27783 |
|
27784 |
|
27785 |
|
27786 |
|
27787 |
|
27788 | function createBaseEach(eachFunc, fromRight) {
|
27789 | return function (collection, iteratee) {
|
27790 | if (collection == null) {
|
27791 | return collection;
|
27792 | }
|
27793 |
|
27794 | if (!isArrayLike_1(collection)) {
|
27795 | return eachFunc(collection, iteratee);
|
27796 | }
|
27797 |
|
27798 | var length = collection.length,
|
27799 | index = fromRight ? length : -1,
|
27800 | iterable = Object(collection);
|
27801 |
|
27802 | while (fromRight ? index-- : ++index < length) {
|
27803 | if (iteratee(iterable[index], index, iterable) === false) {
|
27804 | break;
|
27805 | }
|
27806 | }
|
27807 |
|
27808 | return collection;
|
27809 | };
|
27810 | }
|
27811 |
|
27812 | var _createBaseEach = createBaseEach;
|
27813 |
|
27814 |
|
27815 |
|
27816 |
|
27817 |
|
27818 |
|
27819 |
|
27820 |
|
27821 |
|
27822 |
|
27823 | var baseEach = _createBaseEach(_baseForOwn);
|
27824 | var _baseEach = baseEach;
|
27825 |
|
27826 |
|
27827 |
|
27828 |
|
27829 |
|
27830 |
|
27831 |
|
27832 |
|
27833 |
|
27834 |
|
27835 |
|
27836 |
|
27837 |
|
27838 | function baseAggregator(collection, setter, iteratee, accumulator) {
|
27839 | _baseEach(collection, function (value, key, collection) {
|
27840 | setter(accumulator, value, iteratee(value), collection);
|
27841 | });
|
27842 | return accumulator;
|
27843 | }
|
27844 |
|
27845 | var _baseAggregator = baseAggregator;
|
27846 |
|
27847 |
|
27848 |
|
27849 |
|
27850 |
|
27851 |
|
27852 |
|
27853 |
|
27854 |
|
27855 |
|
27856 | function createAggregator(setter, initializer) {
|
27857 | return function (collection, iteratee) {
|
27858 | var func = isArray_1(collection) ? _arrayAggregator : _baseAggregator,
|
27859 | accumulator = initializer ? initializer() : {};
|
27860 | return func(collection, setter, _baseIteratee(iteratee), accumulator);
|
27861 | };
|
27862 | }
|
27863 |
|
27864 | var _createAggregator = createAggregator;
|
27865 |
|
27866 |
|
27867 |
|
27868 |
|
27869 |
|
27870 |
|
27871 |
|
27872 |
|
27873 |
|
27874 |
|
27875 |
|
27876 |
|
27877 |
|
27878 |
|
27879 |
|
27880 |
|
27881 |
|
27882 |
|
27883 |
|
27884 |
|
27885 |
|
27886 |
|
27887 |
|
27888 |
|
27889 |
|
27890 |
|
27891 |
|
27892 |
|
27893 |
|
27894 |
|
27895 |
|
27896 |
|
27897 |
|
27898 |
|
27899 |
|
27900 |
|
27901 |
|
27902 |
|
27903 | var partition = _createAggregator(function (result, value, key) {
|
27904 | result[key ? 0 : 1].push(value);
|
27905 | }, function () {
|
27906 | return [[], []];
|
27907 | });
|
27908 | var partition_1 = partition;
|
27909 |
|
27910 | var arrayUnion = (...arguments_) => {
|
27911 | return [...new Set([].concat(...arguments_))];
|
27912 | };
|
27913 |
|
27914 |
|
27915 |
|
27916 |
|
27917 |
|
27918 |
|
27919 |
|
27920 |
|
27921 |
|
27922 |
|
27923 | const PassThrough = stream$6.PassThrough;
|
27924 | const slice = Array.prototype.slice;
|
27925 | var merge2_1 = merge2;
|
27926 |
|
27927 | function merge2() {
|
27928 | const streamsQueue = [];
|
27929 | let merging = false;
|
27930 | const args = slice.call(arguments);
|
27931 | let options = args[args.length - 1];
|
27932 | if (options && !Array.isArray(options) && options.pipe == null) args.pop();else options = {};
|
27933 | const doEnd = options.end !== false;
|
27934 | if (options.objectMode == null) options.objectMode = true;
|
27935 | if (options.highWaterMark == null) options.highWaterMark = 64 * 1024;
|
27936 | const mergedStream = PassThrough(options);
|
27937 |
|
27938 | function addStream() {
|
27939 | for (let i = 0, len = arguments.length; i < len; i++) {
|
27940 | streamsQueue.push(pauseStreams(arguments[i], options));
|
27941 | }
|
27942 |
|
27943 | mergeStream();
|
27944 | return this;
|
27945 | }
|
27946 |
|
27947 | function mergeStream() {
|
27948 | if (merging) return;
|
27949 | merging = true;
|
27950 | let streams = streamsQueue.shift();
|
27951 |
|
27952 | if (!streams) {
|
27953 | process.nextTick(endStream);
|
27954 | return;
|
27955 | }
|
27956 |
|
27957 | if (!Array.isArray(streams)) streams = [streams];
|
27958 | let pipesCount = streams.length + 1;
|
27959 |
|
27960 | function next() {
|
27961 | if (--pipesCount > 0) return;
|
27962 | merging = false;
|
27963 | mergeStream();
|
27964 | }
|
27965 |
|
27966 | function pipe(stream) {
|
27967 | function onend() {
|
27968 | stream.removeListener('merge2UnpipeEnd', onend);
|
27969 | stream.removeListener('end', onend);
|
27970 | next();
|
27971 | }
|
27972 |
|
27973 |
|
27974 | if (stream._readableState.endEmitted) return next();
|
27975 | stream.on('merge2UnpipeEnd', onend);
|
27976 | stream.on('end', onend);
|
27977 | stream.pipe(mergedStream, {
|
27978 | end: false
|
27979 | });
|
27980 |
|
27981 | stream.resume();
|
27982 | }
|
27983 |
|
27984 | for (let i = 0; i < streams.length; i++) pipe(streams[i]);
|
27985 |
|
27986 | next();
|
27987 | }
|
27988 |
|
27989 | function endStream() {
|
27990 | merging = false;
|
27991 |
|
27992 | mergedStream.emit('queueDrain');
|
27993 | return doEnd && mergedStream.end();
|
27994 | }
|
27995 |
|
27996 | mergedStream.setMaxListeners(0);
|
27997 | mergedStream.add = addStream;
|
27998 | mergedStream.on('unpipe', function (stream) {
|
27999 | stream.emit('merge2UnpipeEnd');
|
28000 | });
|
28001 | if (args.length) addStream.apply(null, args);
|
28002 | return mergedStream;
|
28003 | }
|
28004 |
|
28005 |
|
28006 | function pauseStreams(streams, options) {
|
28007 | if (!Array.isArray(streams)) {
|
28008 |
|
28009 | if (!streams._readableState && streams.pipe) streams = streams.pipe(PassThrough(options));
|
28010 |
|
28011 | if (!streams._readableState || !streams.pause || !streams.pipe) {
|
28012 | throw new Error('Only readable stream can be merged.');
|
28013 | }
|
28014 |
|
28015 | streams.pause();
|
28016 | } else {
|
28017 | for (let i = 0, len = streams.length; i < len; i++) streams[i] = pauseStreams(streams[i], options);
|
28018 | }
|
28019 |
|
28020 | return streams;
|
28021 | }
|
28022 |
|
28023 | var array$2 = createCommonjsModule(function (module, exports) {
|
28024 |
|
28025 | Object.defineProperty(exports, "__esModule", {
|
28026 | value: true
|
28027 | });
|
28028 |
|
28029 | function flatten(items) {
|
28030 | return items.reduce((collection, item) => [].concat(collection, item), []);
|
28031 | }
|
28032 |
|
28033 | exports.flatten = flatten;
|
28034 |
|
28035 | function splitWhen(items, predicate) {
|
28036 | const result = [[]];
|
28037 | let groupIndex = 0;
|
28038 |
|
28039 | for (const item of items) {
|
28040 | if (predicate(item)) {
|
28041 | groupIndex++;
|
28042 | result[groupIndex] = [];
|
28043 | } else {
|
28044 | result[groupIndex].push(item);
|
28045 | }
|
28046 | }
|
28047 |
|
28048 | return result;
|
28049 | }
|
28050 |
|
28051 | exports.splitWhen = splitWhen;
|
28052 | });
|
28053 | unwrapExports(array$2);
|
28054 | var array_1$1 = array$2.flatten;
|
28055 | var array_2 = array$2.splitWhen;
|
28056 |
|
28057 | var errno = createCommonjsModule(function (module, exports) {
|
28058 |
|
28059 | Object.defineProperty(exports, "__esModule", {
|
28060 | value: true
|
28061 | });
|
28062 |
|
28063 | function isEnoentCodeError(error) {
|
28064 | return error.code === 'ENOENT';
|
28065 | }
|
28066 |
|
28067 | exports.isEnoentCodeError = isEnoentCodeError;
|
28068 | });
|
28069 | unwrapExports(errno);
|
28070 | var errno_1 = errno.isEnoentCodeError;
|
28071 |
|
28072 | var fs$1 = createCommonjsModule(function (module, exports) {
|
28073 |
|
28074 | Object.defineProperty(exports, "__esModule", {
|
28075 | value: true
|
28076 | });
|
28077 |
|
28078 | class DirentFromStats {
|
28079 | constructor(name, stats) {
|
28080 | this.name = name;
|
28081 | this.isBlockDevice = stats.isBlockDevice.bind(stats);
|
28082 | this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
|
28083 | this.isDirectory = stats.isDirectory.bind(stats);
|
28084 | this.isFIFO = stats.isFIFO.bind(stats);
|
28085 | this.isFile = stats.isFile.bind(stats);
|
28086 | this.isSocket = stats.isSocket.bind(stats);
|
28087 | this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
|
28088 | }
|
28089 |
|
28090 | }
|
28091 |
|
28092 | function createDirentFromStats(name, stats) {
|
28093 | return new DirentFromStats(name, stats);
|
28094 | }
|
28095 |
|
28096 | exports.createDirentFromStats = createDirentFromStats;
|
28097 | });
|
28098 | unwrapExports(fs$1);
|
28099 | var fs_1 = fs$1.createDirentFromStats;
|
28100 |
|
28101 | var path_1 = createCommonjsModule(function (module, exports) {
|
28102 |
|
28103 | Object.defineProperty(exports, "__esModule", {
|
28104 | value: true
|
28105 | });
|
28106 | const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2;
|
28107 |
|
28108 | const UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;
|
28109 | |
28110 |
|
28111 |
|
28112 |
|
28113 | function unixify(filepath) {
|
28114 | return filepath.replace(/\\/g, '/');
|
28115 | }
|
28116 |
|
28117 | exports.unixify = unixify;
|
28118 |
|
28119 | function makeAbsolute(cwd, filepath) {
|
28120 | return path$2.resolve(cwd, filepath);
|
28121 | }
|
28122 |
|
28123 | exports.makeAbsolute = makeAbsolute;
|
28124 |
|
28125 | function escape(pattern) {
|
28126 | return pattern.replace(UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
|
28127 | }
|
28128 |
|
28129 | exports.escape = escape;
|
28130 |
|
28131 | function removeLeadingDotSegment(entry) {
|
28132 |
|
28133 |
|
28134 | if (entry.charAt(0) === '.') {
|
28135 | const secondCharactery = entry.charAt(1);
|
28136 |
|
28137 | if (secondCharactery === '/' || secondCharactery === '\\') {
|
28138 | return entry.slice(LEADING_DOT_SEGMENT_CHARACTERS_COUNT);
|
28139 | }
|
28140 | }
|
28141 |
|
28142 | return entry;
|
28143 | }
|
28144 |
|
28145 | exports.removeLeadingDotSegment = removeLeadingDotSegment;
|
28146 | });
|
28147 | unwrapExports(path_1);
|
28148 | var path_2 = path_1.unixify;
|
28149 | var path_3 = path_1.makeAbsolute;
|
28150 | var path_4 = path_1.escape;
|
28151 | var path_5 = path_1.removeLeadingDotSegment;
|
28152 |
|
28153 |
|
28154 |
|
28155 |
|
28156 |
|
28157 |
|
28158 |
|
28159 | var isExtglob = function isExtglob(str) {
|
28160 | if (typeof str !== 'string' || str === '') {
|
28161 | return false;
|
28162 | }
|
28163 |
|
28164 | var match;
|
28165 |
|
28166 | while (match = /(\\).|([@?!+*]\(.*\))/g.exec(str)) {
|
28167 | if (match[2]) return true;
|
28168 | str = str.slice(match.index + match[0].length);
|
28169 | }
|
28170 |
|
28171 | return false;
|
28172 | };
|
28173 |
|
28174 |
|
28175 |
|
28176 |
|
28177 |
|
28178 |
|
28179 |
|
28180 |
|
28181 | var chars = {
|
28182 | '{': '}',
|
28183 | '(': ')',
|
28184 | '[': ']'
|
28185 | };
|
28186 | var strictRegex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/;
|
28187 | var relaxedRegex = /\\(.)|(^!|[*?{}()[\]]|\(\?)/;
|
28188 |
|
28189 | var isGlob = function isGlob(str, options) {
|
28190 | if (typeof str !== 'string' || str === '') {
|
28191 | return false;
|
28192 | }
|
28193 |
|
28194 | if (isExtglob(str)) {
|
28195 | return true;
|
28196 | }
|
28197 |
|
28198 | var regex = strictRegex;
|
28199 | var match;
|
28200 |
|
28201 | if (options && options.strict === false) {
|
28202 | regex = relaxedRegex;
|
28203 | }
|
28204 |
|
28205 | while (match = regex.exec(str)) {
|
28206 | if (match[2]) return true;
|
28207 | var idx = match.index + match[0].length;
|
28208 |
|
28209 |
|
28210 | var open = match[1];
|
28211 | var close = open ? chars[open] : null;
|
28212 |
|
28213 | if (open && close) {
|
28214 | var n = str.indexOf(close, idx);
|
28215 |
|
28216 | if (n !== -1) {
|
28217 | idx = n + 1;
|
28218 | }
|
28219 | }
|
28220 |
|
28221 | str = str.slice(idx);
|
28222 | }
|
28223 |
|
28224 | return false;
|
28225 | };
|
28226 |
|
28227 | var pathPosixDirname = path$2.posix.dirname;
|
28228 | var isWin32 = os$1.platform() === 'win32';
|
28229 | var slash = '/';
|
28230 | var backslash = /\\/g;
|
28231 | var enclosure = /[\{\[].*[\/]*.*[\}\]]$/;
|
28232 | var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/;
|
28233 | var escaped = /\\([\*\?\|\[\]\(\)\{\}])/g;
|
28234 |
|
28235 |
|
28236 |
|
28237 |
|
28238 |
|
28239 |
|
28240 | var globParent = function globParent(str, opts) {
|
28241 | var options = Object.assign({
|
28242 | flipBackslashes: true
|
28243 | }, opts);
|
28244 |
|
28245 | if (options.flipBackslashes && isWin32 && str.indexOf(slash) < 0) {
|
28246 | str = str.replace(backslash, slash);
|
28247 | }
|
28248 |
|
28249 |
|
28250 | if (enclosure.test(str)) {
|
28251 | str += slash;
|
28252 | }
|
28253 |
|
28254 |
|
28255 | str += 'a';
|
28256 |
|
28257 | do {
|
28258 | str = pathPosixDirname(str);
|
28259 | } while (isGlob(str) || globby.test(str));
|
28260 |
|
28261 |
|
28262 | return str.replace(escaped, '$1');
|
28263 | };
|
28264 |
|
28265 | var utils$2 = createCommonjsModule(function (module, exports) {
|
28266 |
|
28267 | exports.isInteger = num => {
|
28268 | if (typeof num === 'number') {
|
28269 | return Number.isInteger(num);
|
28270 | }
|
28271 |
|
28272 | if (typeof num === 'string' && num.trim() !== '') {
|
28273 | return Number.isInteger(Number(num));
|
28274 | }
|
28275 |
|
28276 | return false;
|
28277 | };
|
28278 | |
28279 |
|
28280 |
|
28281 |
|
28282 |
|
28283 | exports.find = (node, type) => node.nodes.find(node => node.type === type);
|
28284 | |
28285 |
|
28286 |
|
28287 |
|
28288 |
|
28289 | exports.exceedsLimit = (min, max, step = 1, limit) => {
|
28290 | if (limit === false) return false;
|
28291 | if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
|
28292 | return (Number(max) - Number(min)) / Number(step) >= limit;
|
28293 | };
|
28294 | |
28295 |
|
28296 |
|
28297 |
|
28298 |
|
28299 | exports.escapeNode = (block, n = 0, type) => {
|
28300 | let node = block.nodes[n];
|
28301 | if (!node) return;
|
28302 |
|
28303 | if (type && node.type === type || node.type === 'open' || node.type === 'close') {
|
28304 | if (node.escaped !== true) {
|
28305 | node.value = '\\' + node.value;
|
28306 | node.escaped = true;
|
28307 | }
|
28308 | }
|
28309 | };
|
28310 | |
28311 |
|
28312 |
|
28313 |
|
28314 |
|
28315 | exports.encloseBrace = node => {
|
28316 | if (node.type !== 'brace') return false;
|
28317 |
|
28318 | if (node.commas >> 0 + node.ranges >> 0 === 0) {
|
28319 | node.invalid = true;
|
28320 | return true;
|
28321 | }
|
28322 |
|
28323 | return false;
|
28324 | };
|
28325 | |
28326 |
|
28327 |
|
28328 |
|
28329 |
|
28330 | exports.isInvalidBrace = block => {
|
28331 | if (block.type !== 'brace') return false;
|
28332 | if (block.invalid === true || block.dollar) return true;
|
28333 |
|
28334 | if (block.commas >> 0 + block.ranges >> 0 === 0) {
|
28335 | block.invalid = true;
|
28336 | return true;
|
28337 | }
|
28338 |
|
28339 | if (block.open !== true || block.close !== true) {
|
28340 | block.invalid = true;
|
28341 | return true;
|
28342 | }
|
28343 |
|
28344 | return false;
|
28345 | };
|
28346 | |
28347 |
|
28348 |
|
28349 |
|
28350 |
|
28351 | exports.isOpenOrClose = node => {
|
28352 | if (node.type === 'open' || node.type === 'close') {
|
28353 | return true;
|
28354 | }
|
28355 |
|
28356 | return node.open === true || node.close === true;
|
28357 | };
|
28358 | |
28359 |
|
28360 |
|
28361 |
|
28362 |
|
28363 | exports.reduce = nodes => nodes.reduce((acc, node) => {
|
28364 | if (node.type === 'text') acc.push(node.value);
|
28365 | if (node.type === 'range') node.type = 'text';
|
28366 | return acc;
|
28367 | }, []);
|
28368 | |
28369 |
|
28370 |
|
28371 |
|
28372 |
|
28373 | exports.flatten = (...args) => {
|
28374 | const result = [];
|
28375 |
|
28376 | const flat = arr => {
|
28377 | for (let i = 0; i < arr.length; i++) {
|
28378 | let ele = arr[i];
|
28379 | Array.isArray(ele) ? flat(ele) : ele !== void 0 && result.push(ele);
|
28380 | }
|
28381 |
|
28382 | return result;
|
28383 | };
|
28384 |
|
28385 | flat(args);
|
28386 | return result;
|
28387 | };
|
28388 | });
|
28389 | var utils_1$2 = utils$2.isInteger;
|
28390 | var utils_2$2 = utils$2.find;
|
28391 | var utils_3$2 = utils$2.exceedsLimit;
|
28392 | var utils_4$1 = utils$2.escapeNode;
|
28393 | var utils_5$1 = utils$2.encloseBrace;
|
28394 | var utils_6$1 = utils$2.isInvalidBrace;
|
28395 | var utils_7$1 = utils$2.isOpenOrClose;
|
28396 | var utils_8$1 = utils$2.reduce;
|
28397 | var utils_9$1 = utils$2.flatten;
|
28398 |
|
28399 | var stringify = (ast, options = {}) => {
|
28400 | let stringify = (node, parent = {}) => {
|
28401 | let invalidBlock = options.escapeInvalid && utils$2.isInvalidBrace(parent);
|
28402 | let invalidNode = node.invalid === true && options.escapeInvalid === true;
|
28403 | let output = '';
|
28404 |
|
28405 | if (node.value) {
|
28406 | if ((invalidBlock || invalidNode) && utils$2.isOpenOrClose(node)) {
|
28407 | return '\\' + node.value;
|
28408 | }
|
28409 |
|
28410 | return node.value;
|
28411 | }
|
28412 |
|
28413 | if (node.value) {
|
28414 | return node.value;
|
28415 | }
|
28416 |
|
28417 | if (node.nodes) {
|
28418 | for (let child of node.nodes) {
|
28419 | output += stringify(child);
|
28420 | }
|
28421 | }
|
28422 |
|
28423 | return output;
|
28424 | };
|
28425 |
|
28426 | return stringify(ast);
|
28427 | };
|
28428 |
|
28429 |
|
28430 |
|
28431 |
|
28432 |
|
28433 |
|
28434 |
|
28435 |
|
28436 | var isNumber = function (num) {
|
28437 | if (typeof num === 'number') {
|
28438 | return num - num === 0;
|
28439 | }
|
28440 |
|
28441 | if (typeof num === 'string' && num.trim() !== '') {
|
28442 | return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
|
28443 | }
|
28444 |
|
28445 | return false;
|
28446 | };
|
28447 |
|
28448 | const toRegexRange = (min, max, options) => {
|
28449 | if (isNumber(min) === false) {
|
28450 | throw new TypeError('toRegexRange: expected the first argument to be a number');
|
28451 | }
|
28452 |
|
28453 | if (max === void 0 || min === max) {
|
28454 | return String(min);
|
28455 | }
|
28456 |
|
28457 | if (isNumber(max) === false) {
|
28458 | throw new TypeError('toRegexRange: expected the second argument to be a number.');
|
28459 | }
|
28460 |
|
28461 | let opts = Object.assign({
|
28462 | relaxZeros: true
|
28463 | }, options);
|
28464 |
|
28465 | if (typeof opts.strictZeros === 'boolean') {
|
28466 | opts.relaxZeros = opts.strictZeros === false;
|
28467 | }
|
28468 |
|
28469 | let relax = String(opts.relaxZeros);
|
28470 | let shorthand = String(opts.shorthand);
|
28471 | let capture = String(opts.capture);
|
28472 | let wrap = String(opts.wrap);
|
28473 | let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap;
|
28474 |
|
28475 | if (toRegexRange.cache.hasOwnProperty(cacheKey)) {
|
28476 | return toRegexRange.cache[cacheKey].result;
|
28477 | }
|
28478 |
|
28479 | let a = Math.min(min, max);
|
28480 | let b = Math.max(min, max);
|
28481 |
|
28482 | if (Math.abs(a - b) === 1) {
|
28483 | let result = min + '|' + max;
|
28484 |
|
28485 | if (opts.capture) {
|
28486 | return `(${result})`;
|
28487 | }
|
28488 |
|
28489 | if (opts.wrap === false) {
|
28490 | return result;
|
28491 | }
|
28492 |
|
28493 | return `(?:${result})`;
|
28494 | }
|
28495 |
|
28496 | let isPadded = hasPadding(min) || hasPadding(max);
|
28497 | let state = {
|
28498 | min,
|
28499 | max,
|
28500 | a,
|
28501 | b
|
28502 | };
|
28503 | let positives = [];
|
28504 | let negatives = [];
|
28505 |
|
28506 | if (isPadded) {
|
28507 | state.isPadded = isPadded;
|
28508 | state.maxLen = String(state.max).length;
|
28509 | }
|
28510 |
|
28511 | if (a < 0) {
|
28512 | let newMin = b < 0 ? Math.abs(b) : 1;
|
28513 | negatives = splitToPatterns(newMin, Math.abs(a), state, opts);
|
28514 | a = state.a = 0;
|
28515 | }
|
28516 |
|
28517 | if (b >= 0) {
|
28518 | positives = splitToPatterns(a, b, state, opts);
|
28519 | }
|
28520 |
|
28521 | state.negatives = negatives;
|
28522 | state.positives = positives;
|
28523 | state.result = collatePatterns(negatives, positives);
|
28524 |
|
28525 | if (opts.capture === true) {
|
28526 | state.result = `(${state.result})`;
|
28527 | } else if (opts.wrap !== false && positives.length + negatives.length > 1) {
|
28528 | state.result = `(?:${state.result})`;
|
28529 | }
|
28530 |
|
28531 | toRegexRange.cache[cacheKey] = state;
|
28532 | return state.result;
|
28533 | };
|
28534 |
|
28535 | function collatePatterns(neg, pos, options) {
|
28536 | let onlyNegative = filterPatterns(neg, pos, '-', false) || [];
|
28537 | let onlyPositive = filterPatterns(pos, neg, '', false) || [];
|
28538 | let intersected = filterPatterns(neg, pos, '-?', true) || [];
|
28539 | let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive);
|
28540 | return subpatterns.join('|');
|
28541 | }
|
28542 |
|
28543 | function splitToRanges(min, max) {
|
28544 | let nines = 1;
|
28545 | let zeros = 1;
|
28546 | let stop = countNines(min, nines);
|
28547 | let stops = new Set([max]);
|
28548 |
|
28549 | while (min <= stop && stop <= max) {
|
28550 | stops.add(stop);
|
28551 | nines += 1;
|
28552 | stop = countNines(min, nines);
|
28553 | }
|
28554 |
|
28555 | stop = countZeros(max + 1, zeros) - 1;
|
28556 |
|
28557 | while (min < stop && stop <= max) {
|
28558 | stops.add(stop);
|
28559 | zeros += 1;
|
28560 | stop = countZeros(max + 1, zeros) - 1;
|
28561 | }
|
28562 |
|
28563 | stops = [...stops];
|
28564 | stops.sort(compare$1);
|
28565 | return stops;
|
28566 | }
|
28567 |
|
28568 |
|
28569 |
|
28570 |
|
28571 |
|
28572 |
|
28573 |
|
28574 |
|
28575 | function rangeToPattern(start, stop, options) {
|
28576 | if (start === stop) {
|
28577 | return {
|
28578 | pattern: start,
|
28579 | count: [],
|
28580 | digits: 0
|
28581 | };
|
28582 | }
|
28583 |
|
28584 | let zipped = zip(start, stop);
|
28585 | let digits = zipped.length;
|
28586 | let pattern = '';
|
28587 | let count = 0;
|
28588 |
|
28589 | for (let i = 0; i < digits; i++) {
|
28590 | let [startDigit, stopDigit] = zipped[i];
|
28591 |
|
28592 | if (startDigit === stopDigit) {
|
28593 | pattern += startDigit;
|
28594 | } else if (startDigit !== '0' || stopDigit !== '9') {
|
28595 | pattern += toCharacterClass(startDigit, stopDigit);
|
28596 | } else {
|
28597 | count++;
|
28598 | }
|
28599 | }
|
28600 |
|
28601 | if (count) {
|
28602 | pattern += options.shorthand === true ? '\\d' : '[0-9]';
|
28603 | }
|
28604 |
|
28605 | return {
|
28606 | pattern,
|
28607 | count: [count],
|
28608 | digits
|
28609 | };
|
28610 | }
|
28611 |
|
28612 | function splitToPatterns(min, max, tok, options) {
|
28613 | let ranges = splitToRanges(min, max);
|
28614 | let tokens = [];
|
28615 | let start = min;
|
28616 | let prev;
|
28617 |
|
28618 | for (let i = 0; i < ranges.length; i++) {
|
28619 | let max = ranges[i];
|
28620 | let obj = rangeToPattern(String(start), String(max), options);
|
28621 | let zeros = '';
|
28622 |
|
28623 | if (!tok.isPadded && prev && prev.pattern === obj.pattern) {
|
28624 | if (prev.count.length > 1) {
|
28625 | prev.count.pop();
|
28626 | }
|
28627 |
|
28628 | prev.count.push(obj.count[0]);
|
28629 | prev.string = prev.pattern + toQuantifier(prev.count);
|
28630 | start = max + 1;
|
28631 | continue;
|
28632 | }
|
28633 |
|
28634 | if (tok.isPadded) {
|
28635 | zeros = padZeros(max, tok, options);
|
28636 | }
|
28637 |
|
28638 | obj.string = zeros + obj.pattern + toQuantifier(obj.count);
|
28639 | tokens.push(obj);
|
28640 | start = max + 1;
|
28641 | prev = obj;
|
28642 | }
|
28643 |
|
28644 | return tokens;
|
28645 | }
|
28646 |
|
28647 | function filterPatterns(arr, comparison, prefix, intersection, options) {
|
28648 | let result = [];
|
28649 |
|
28650 | for (let ele of arr) {
|
28651 | let {
|
28652 | string
|
28653 | } = ele;
|
28654 |
|
28655 | if (!intersection && !contains(comparison, 'string', string)) {
|
28656 | result.push(prefix + string);
|
28657 | }
|
28658 |
|
28659 |
|
28660 | if (intersection && contains(comparison, 'string', string)) {
|
28661 | result.push(prefix + string);
|
28662 | }
|
28663 | }
|
28664 |
|
28665 | return result;
|
28666 | }
|
28667 |
|
28668 |
|
28669 |
|
28670 |
|
28671 |
|
28672 | function zip(a, b) {
|
28673 | let arr = [];
|
28674 |
|
28675 | for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]);
|
28676 |
|
28677 | return arr;
|
28678 | }
|
28679 |
|
28680 | function compare$1(a, b) {
|
28681 | return a > b ? 1 : b > a ? -1 : 0;
|
28682 | }
|
28683 |
|
28684 | function contains(arr, key, val) {
|
28685 | return arr.some(ele => ele[key] === val);
|
28686 | }
|
28687 |
|
28688 | function countNines(min, len) {
|
28689 | return Number(String(min).slice(0, -len) + '9'.repeat(len));
|
28690 | }
|
28691 |
|
28692 | function countZeros(integer, zeros) {
|
28693 | return integer - integer % Math.pow(10, zeros);
|
28694 | }
|
28695 |
|
28696 | function toQuantifier(digits) {
|
28697 | let [start = 0, stop = ''] = digits;
|
28698 |
|
28699 | if (stop || start > 1) {
|
28700 | return `{${start + (stop ? ',' + stop : '')}}`;
|
28701 | }
|
28702 |
|
28703 | return '';
|
28704 | }
|
28705 |
|
28706 | function toCharacterClass(a, b, options) {
|
28707 | return `[${a}${b - a === 1 ? '' : '-'}${b}]`;
|
28708 | }
|
28709 |
|
28710 | function hasPadding(str) {
|
28711 | return /^-?(0+)\d/.test(str);
|
28712 | }
|
28713 |
|
28714 | function padZeros(value, tok, options) {
|
28715 | if (!tok.isPadded) {
|
28716 | return value;
|
28717 | }
|
28718 |
|
28719 | let diff = Math.abs(tok.maxLen - String(value).length);
|
28720 | let relax = options.relaxZeros !== false;
|
28721 |
|
28722 | switch (diff) {
|
28723 | case 0:
|
28724 | return '';
|
28725 |
|
28726 | case 1:
|
28727 | return relax ? '0?' : '0';
|
28728 |
|
28729 | case 2:
|
28730 | return relax ? '0{0,2}' : '00';
|
28731 |
|
28732 | default:
|
28733 | {
|
28734 | return relax ? `0{0,${diff}}` : `0{${diff}}`;
|
28735 | }
|
28736 | }
|
28737 | }
|
28738 |
|
28739 |
|
28740 |
|
28741 |
|
28742 |
|
28743 | toRegexRange.cache = {};
|
28744 |
|
28745 | toRegexRange.clearCache = () => toRegexRange.cache = {};
|
28746 |
|
28747 |
|
28748 |
|
28749 |
|
28750 |
|
28751 | var toRegexRange_1 = toRegexRange;
|
28752 |
|
28753 | const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
28754 |
|
28755 | const transform = toNumber => {
|
28756 | return value => toNumber === true ? Number(value) : String(value);
|
28757 | };
|
28758 |
|
28759 | const isValidValue = value => {
|
28760 | return typeof value === 'number' || typeof value === 'string' && value !== '';
|
28761 | };
|
28762 |
|
28763 | const isNumber$1 = num => Number.isInteger(+num);
|
28764 |
|
28765 | const zeros = input => {
|
28766 | let value = `${input}`;
|
28767 | let index = -1;
|
28768 | if (value[0] === '-') value = value.slice(1);
|
28769 | if (value === '0') return false;
|
28770 |
|
28771 | while (value[++index] === '0');
|
28772 |
|
28773 | return index > 0;
|
28774 | };
|
28775 |
|
28776 | const stringify$1 = (start, end, options) => {
|
28777 | if (typeof start === 'string' || typeof end === 'string') {
|
28778 | return true;
|
28779 | }
|
28780 |
|
28781 | return options.stringify === true;
|
28782 | };
|
28783 |
|
28784 | const pad = (input, maxLength, toNumber) => {
|
28785 | if (maxLength > 0) {
|
28786 | let dash = input[0] === '-' ? '-' : '';
|
28787 | if (dash) input = input.slice(1);
|
28788 | input = dash + input.padStart(dash ? maxLength - 1 : maxLength, '0');
|
28789 | }
|
28790 |
|
28791 | if (toNumber === false) {
|
28792 | return String(input);
|
28793 | }
|
28794 |
|
28795 | return input;
|
28796 | };
|
28797 |
|
28798 | const toMaxLen = (input, maxLength) => {
|
28799 | let negative = input[0] === '-' ? '-' : '';
|
28800 |
|
28801 | if (negative) {
|
28802 | input = input.slice(1);
|
28803 | maxLength--;
|
28804 | }
|
28805 |
|
28806 | while (input.length < maxLength) input = '0' + input;
|
28807 |
|
28808 | return negative ? '-' + input : input;
|
28809 | };
|
28810 |
|
28811 | const toSequence = (parts, options) => {
|
28812 | parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
28813 | parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
28814 | let prefix = options.capture ? '' : '?:';
|
28815 | let positives = '';
|
28816 | let negatives = '';
|
28817 | let result;
|
28818 |
|
28819 | if (parts.positives.length) {
|
28820 | positives = parts.positives.join('|');
|
28821 | }
|
28822 |
|
28823 | if (parts.negatives.length) {
|
28824 | negatives = `-(${prefix}${parts.negatives.join('|')})`;
|
28825 | }
|
28826 |
|
28827 | if (positives && negatives) {
|
28828 | result = `${positives}|${negatives}`;
|
28829 | } else {
|
28830 | result = positives || negatives;
|
28831 | }
|
28832 |
|
28833 | if (options.wrap) {
|
28834 | return `(${prefix}${result})`;
|
28835 | }
|
28836 |
|
28837 | return result;
|
28838 | };
|
28839 |
|
28840 | const toRange = (a, b, isNumbers, options) => {
|
28841 | if (isNumbers) {
|
28842 | return toRegexRange_1(a, b, Object.assign({
|
28843 | wrap: false
|
28844 | }, options));
|
28845 | }
|
28846 |
|
28847 | let start = String.fromCharCode(a);
|
28848 | if (a === b) return start;
|
28849 | let stop = String.fromCharCode(b);
|
28850 | return `[${start}-${stop}]`;
|
28851 | };
|
28852 |
|
28853 | const toRegex = (start, end, options) => {
|
28854 | if (Array.isArray(start)) {
|
28855 | let wrap = options.wrap === true;
|
28856 | let prefix = options.capture ? '' : '?:';
|
28857 | return wrap ? `(${prefix}${start.join('|')})` : start.join('|');
|
28858 | }
|
28859 |
|
28860 | return toRegexRange_1(start, end, options);
|
28861 | };
|
28862 |
|
28863 | const rangeError = (...args) => {
|
28864 | return new RangeError('Invalid range arguments: ' + util$4.inspect(...args));
|
28865 | };
|
28866 |
|
28867 | const invalidRange = (start, end, options) => {
|
28868 | if (options.strictRanges === true) throw rangeError([start, end]);
|
28869 | return [];
|
28870 | };
|
28871 |
|
28872 | const invalidStep = (step, options) => {
|
28873 | if (options.strictRanges === true) {
|
28874 | throw new TypeError(`Expected step "${step}" to be a number`);
|
28875 | }
|
28876 |
|
28877 | return [];
|
28878 | };
|
28879 |
|
28880 | const fillNumbers = (start, end, step = 1, options = {}) => {
|
28881 | let a = Number(start);
|
28882 | let b = Number(end);
|
28883 |
|
28884 | if (!Number.isInteger(a) || !Number.isInteger(b)) {
|
28885 | if (options.strictRanges === true) throw rangeError([start, end]);
|
28886 | return [];
|
28887 | }
|
28888 |
|
28889 |
|
28890 | if (a === 0) a = 0;
|
28891 | if (b === 0) b = 0;
|
28892 | let descending = a > b;
|
28893 | let startString = String(start);
|
28894 | let endString = String(end);
|
28895 | let stepString = String(step);
|
28896 | step = Math.max(Math.abs(step), 1);
|
28897 | let padded = zeros(startString) || zeros(endString) || zeros(stepString);
|
28898 | let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
|
28899 | let toNumber = padded === false && stringify$1(start, end, options) === false;
|
28900 | let format = options.transform || transform(toNumber);
|
28901 |
|
28902 | if (options.toRegex && step === 1) {
|
28903 | return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
|
28904 | }
|
28905 |
|
28906 | let parts = {
|
28907 | negatives: [],
|
28908 | positives: []
|
28909 | };
|
28910 |
|
28911 | let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num));
|
28912 |
|
28913 | let range = [];
|
28914 | let index = 0;
|
28915 |
|
28916 | while (descending ? a >= b : a <= b) {
|
28917 | if (options.toRegex === true && step > 1) {
|
28918 | push(a);
|
28919 | } else {
|
28920 | range.push(pad(format(a, index), maxLen, toNumber));
|
28921 | }
|
28922 |
|
28923 | a = descending ? a - step : a + step;
|
28924 | index++;
|
28925 | }
|
28926 |
|
28927 | if (options.toRegex === true) {
|
28928 | return step > 1 ? toSequence(parts, options) : toRegex(range, null, Object.assign({
|
28929 | wrap: false
|
28930 | }, options));
|
28931 | }
|
28932 |
|
28933 | return range;
|
28934 | };
|
28935 |
|
28936 | const fillLetters = (start, end, step = 1, options = {}) => {
|
28937 | if (!isNumber$1(start) && start.length > 1 || !isNumber$1(end) && end.length > 1) {
|
28938 | return invalidRange(start, end, options);
|
28939 | }
|
28940 |
|
28941 | let format = options.transform || (val => String.fromCharCode(val));
|
28942 |
|
28943 | let a = `${start}`.charCodeAt(0);
|
28944 | let b = `${end}`.charCodeAt(0);
|
28945 | let descending = a > b;
|
28946 | let min = Math.min(a, b);
|
28947 | let max = Math.max(a, b);
|
28948 |
|
28949 | if (options.toRegex && step === 1) {
|
28950 | return toRange(min, max, false, options);
|
28951 | }
|
28952 |
|
28953 | let range = [];
|
28954 | let index = 0;
|
28955 |
|
28956 | while (descending ? a >= b : a <= b) {
|
28957 | range.push(format(a, index));
|
28958 | a = descending ? a - step : a + step;
|
28959 | index++;
|
28960 | }
|
28961 |
|
28962 | if (options.toRegex === true) {
|
28963 | return toRegex(range, null, {
|
28964 | wrap: false,
|
28965 | options
|
28966 | });
|
28967 | }
|
28968 |
|
28969 | return range;
|
28970 | };
|
28971 |
|
28972 | const fill$2 = (start, end, step, options = {}) => {
|
28973 | if (end == null && isValidValue(start)) {
|
28974 | return [start];
|
28975 | }
|
28976 |
|
28977 | if (!isValidValue(start) || !isValidValue(end)) {
|
28978 | return invalidRange(start, end, options);
|
28979 | }
|
28980 |
|
28981 | if (typeof step === 'function') {
|
28982 | return fill$2(start, end, 1, {
|
28983 | transform: step
|
28984 | });
|
28985 | }
|
28986 |
|
28987 | if (isObject$1(step)) {
|
28988 | return fill$2(start, end, 0, step);
|
28989 | }
|
28990 |
|
28991 | let opts = Object.assign({}, options);
|
28992 | if (opts.capture === true) opts.wrap = true;
|
28993 | step = step || opts.step || 1;
|
28994 |
|
28995 | if (!isNumber$1(step)) {
|
28996 | if (step != null && !isObject$1(step)) return invalidStep(step, opts);
|
28997 | return fill$2(start, end, 1, step);
|
28998 | }
|
28999 |
|
29000 | if (isNumber$1(start) && isNumber$1(end)) {
|
29001 | return fillNumbers(start, end, step, opts);
|
29002 | }
|
29003 |
|
29004 | return fillLetters(start, end, Math.max(Math.abs(step), 1), opts);
|
29005 | };
|
29006 |
|
29007 | var fillRange = fill$2;
|
29008 |
|
29009 | const compile = (ast, options = {}) => {
|
29010 | let walk = (node, parent = {}) => {
|
29011 | let invalidBlock = utils$2.isInvalidBrace(parent);
|
29012 | let invalidNode = node.invalid === true && options.escapeInvalid === true;
|
29013 | let invalid = invalidBlock === true || invalidNode === true;
|
29014 | let prefix = options.escapeInvalid === true ? '\\' : '';
|
29015 | let output = '';
|
29016 |
|
29017 | if (node.isOpen === true) {
|
29018 | return prefix + node.value;
|
29019 | }
|
29020 |
|
29021 | if (node.isClose === true) {
|
29022 | return prefix + node.value;
|
29023 | }
|
29024 |
|
29025 | if (node.type === 'open') {
|
29026 | return invalid ? prefix + node.value : '(';
|
29027 | }
|
29028 |
|
29029 | if (node.type === 'close') {
|
29030 | return invalid ? prefix + node.value : ')';
|
29031 | }
|
29032 |
|
29033 | if (node.type === 'comma') {
|
29034 | return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
|
29035 | }
|
29036 |
|
29037 | if (node.value) {
|
29038 | return node.value;
|
29039 | }
|
29040 |
|
29041 | if (node.nodes && node.ranges > 0) {
|
29042 | let args = utils$2.reduce(node.nodes);
|
29043 | let range = fillRange(...args, Object.assign({}, options, {
|
29044 | wrap: false,
|
29045 | toRegex: true
|
29046 | }));
|
29047 |
|
29048 | if (range.length !== 0) {
|
29049 | return args.length > 1 && range.length > 1 ? `(${range})` : range;
|
29050 | }
|
29051 | }
|
29052 |
|
29053 | if (node.nodes) {
|
29054 | for (let child of node.nodes) {
|
29055 | output += walk(child, node);
|
29056 | }
|
29057 | }
|
29058 |
|
29059 | return output;
|
29060 | };
|
29061 |
|
29062 | return walk(ast);
|
29063 | };
|
29064 |
|
29065 | var compile_1 = compile;
|
29066 |
|
29067 | const append = (queue = '', stash = '', enclose = false) => {
|
29068 | let result = [];
|
29069 | queue = [].concat(queue);
|
29070 | stash = [].concat(stash);
|
29071 | if (!stash.length) return queue;
|
29072 |
|
29073 | if (!queue.length) {
|
29074 | return enclose ? utils$2.flatten(stash).map(ele => `{${ele}}`) : stash;
|
29075 | }
|
29076 |
|
29077 | for (let item of queue) {
|
29078 | if (Array.isArray(item)) {
|
29079 | for (let value of item) {
|
29080 | result.push(append(value, stash, enclose));
|
29081 | }
|
29082 | } else {
|
29083 | for (let ele of stash) {
|
29084 | if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
|
29085 | result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
|
29086 | }
|
29087 | }
|
29088 | }
|
29089 |
|
29090 | return utils$2.flatten(result);
|
29091 | };
|
29092 |
|
29093 | const expand$1 = (ast, options = {}) => {
|
29094 | let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
|
29095 |
|
29096 | let walk = (node, parent = {}) => {
|
29097 | node.queue = [];
|
29098 | let p = parent;
|
29099 | let q = parent.queue;
|
29100 |
|
29101 | while (p.type !== 'brace' && p.type !== 'root' && p.parent) {
|
29102 | p = p.parent;
|
29103 | q = p.queue;
|
29104 | }
|
29105 |
|
29106 | if (node.invalid || node.dollar) {
|
29107 | q.push(append(q.pop(), stringify(node, options)));
|
29108 | return;
|
29109 | }
|
29110 |
|
29111 | if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) {
|
29112 | q.push(append(q.pop(), ['{}']));
|
29113 | return;
|
29114 | }
|
29115 |
|
29116 | if (node.nodes && node.ranges > 0) {
|
29117 | let args = utils$2.reduce(node.nodes);
|
29118 |
|
29119 | if (utils$2.exceedsLimit(...args, options.step, rangeLimit)) {
|
29120 | throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
|
29121 | }
|
29122 |
|
29123 | let range = fillRange(...args, options);
|
29124 |
|
29125 | if (range.length === 0) {
|
29126 | range = stringify(node, options);
|
29127 | }
|
29128 |
|
29129 | q.push(append(q.pop(), range));
|
29130 | node.nodes = [];
|
29131 | return;
|
29132 | }
|
29133 |
|
29134 | let enclose = utils$2.encloseBrace(node);
|
29135 | let queue = node.queue;
|
29136 | let block = node;
|
29137 |
|
29138 | while (block.type !== 'brace' && block.type !== 'root' && block.parent) {
|
29139 | block = block.parent;
|
29140 | queue = block.queue;
|
29141 | }
|
29142 |
|
29143 | for (let i = 0; i < node.nodes.length; i++) {
|
29144 | let child = node.nodes[i];
|
29145 |
|
29146 | if (child.type === 'comma' && node.type === 'brace') {
|
29147 | if (i === 1) queue.push('');
|
29148 | queue.push('');
|
29149 | continue;
|
29150 | }
|
29151 |
|
29152 | if (child.type === 'close') {
|
29153 | q.push(append(q.pop(), queue, enclose));
|
29154 | continue;
|
29155 | }
|
29156 |
|
29157 | if (child.value && child.type !== 'open') {
|
29158 | queue.push(append(queue.pop(), child.value));
|
29159 | continue;
|
29160 | }
|
29161 |
|
29162 | if (child.nodes) {
|
29163 | walk(child, node);
|
29164 | }
|
29165 | }
|
29166 |
|
29167 | return queue;
|
29168 | };
|
29169 |
|
29170 | return utils$2.flatten(walk(ast));
|
29171 | };
|
29172 |
|
29173 | var expand_1 = expand$1;
|
29174 |
|
29175 | var constants$2 = {
|
29176 | MAX_LENGTH: 1024 * 64,
|
29177 |
|
29178 | CHAR_0: '0',
|
29179 |
|
29180 |
|
29181 | CHAR_9: '9',
|
29182 |
|
29183 |
|
29184 |
|
29185 | CHAR_UPPERCASE_A: 'A',
|
29186 |
|
29187 |
|
29188 | CHAR_LOWERCASE_A: 'a',
|
29189 |
|
29190 |
|
29191 | CHAR_UPPERCASE_Z: 'Z',
|
29192 |
|
29193 |
|
29194 | CHAR_LOWERCASE_Z: 'z',
|
29195 |
|
29196 |
|
29197 | CHAR_LEFT_PARENTHESES: '(',
|
29198 |
|
29199 |
|
29200 | CHAR_RIGHT_PARENTHESES: ')',
|
29201 |
|
29202 |
|
29203 | CHAR_ASTERISK: '*',
|
29204 |
|
29205 |
|
29206 |
|
29207 | CHAR_AMPERSAND: '&',
|
29208 |
|
29209 |
|
29210 | CHAR_AT: '@',
|
29211 |
|
29212 |
|
29213 | CHAR_BACKSLASH: '\\',
|
29214 |
|
29215 |
|
29216 | CHAR_BACKTICK: '`',
|
29217 |
|
29218 |
|
29219 | CHAR_CARRIAGE_RETURN: '\r',
|
29220 |
|
29221 |
|
29222 | CHAR_CIRCUMFLEX_ACCENT: '^',
|
29223 |
|
29224 |
|
29225 | CHAR_COLON: ':',
|
29226 |
|
29227 |
|
29228 | CHAR_COMMA: ',',
|
29229 |
|
29230 |
|
29231 | CHAR_DOLLAR: '$',
|
29232 |
|
29233 |
|
29234 | CHAR_DOT: '.',
|
29235 |
|
29236 |
|
29237 | CHAR_DOUBLE_QUOTE: '"',
|
29238 |
|
29239 |
|
29240 | CHAR_EQUAL: '=',
|
29241 |
|
29242 |
|
29243 | CHAR_EXCLAMATION_MARK: '!',
|
29244 |
|
29245 |
|
29246 | CHAR_FORM_FEED: '\f',
|
29247 |
|
29248 |
|
29249 | CHAR_FORWARD_SLASH: '/',
|
29250 |
|
29251 |
|
29252 | CHAR_HASH: '#',
|
29253 |
|
29254 |
|
29255 | CHAR_HYPHEN_MINUS: '-',
|
29256 |
|
29257 |
|
29258 | CHAR_LEFT_ANGLE_BRACKET: '<',
|
29259 |
|
29260 |
|
29261 | CHAR_LEFT_CURLY_BRACE: '{',
|
29262 |
|
29263 |
|
29264 | CHAR_LEFT_SQUARE_BRACKET: '[',
|
29265 |
|
29266 |
|
29267 | CHAR_LINE_FEED: '\n',
|
29268 |
|
29269 |
|
29270 | CHAR_NO_BREAK_SPACE: '\u00A0',
|
29271 |
|
29272 |
|
29273 | CHAR_PERCENT: '%',
|
29274 |
|
29275 |
|
29276 | CHAR_PLUS: '+',
|
29277 |
|
29278 |
|
29279 | CHAR_QUESTION_MARK: '?',
|
29280 |
|
29281 |
|
29282 | CHAR_RIGHT_ANGLE_BRACKET: '>',
|
29283 |
|
29284 |
|
29285 | CHAR_RIGHT_CURLY_BRACE: '}',
|
29286 |
|
29287 |
|
29288 | CHAR_RIGHT_SQUARE_BRACKET: ']',
|
29289 |
|
29290 |
|
29291 | CHAR_SEMICOLON: ';',
|
29292 |
|
29293 |
|
29294 | CHAR_SINGLE_QUOTE: '\'',
|
29295 |
|
29296 |
|
29297 | CHAR_SPACE: ' ',
|
29298 |
|
29299 |
|
29300 | CHAR_TAB: '\t',
|
29301 |
|
29302 |
|
29303 | CHAR_UNDERSCORE: '_',
|
29304 |
|
29305 |
|
29306 | CHAR_VERTICAL_LINE: '|',
|
29307 |
|
29308 |
|
29309 | CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF'
|
29310 |
|
29311 |
|
29312 | };
|
29313 |
|
29314 |
|
29315 |
|
29316 |
|
29317 |
|
29318 |
|
29319 | const {
|
29320 | MAX_LENGTH: MAX_LENGTH$2,
|
29321 | CHAR_BACKSLASH,
|
29322 |
|
29323 |
|
29324 | CHAR_BACKTICK,
|
29325 |
|
29326 |
|
29327 | CHAR_COMMA: CHAR_COMMA$1,
|
29328 |
|
29329 |
|
29330 | CHAR_DOT,
|
29331 |
|
29332 |
|
29333 | CHAR_LEFT_PARENTHESES,
|
29334 |
|
29335 |
|
29336 | CHAR_RIGHT_PARENTHESES,
|
29337 |
|
29338 |
|
29339 | CHAR_LEFT_CURLY_BRACE,
|
29340 |
|
29341 |
|
29342 | CHAR_RIGHT_CURLY_BRACE,
|
29343 |
|
29344 |
|
29345 | CHAR_LEFT_SQUARE_BRACKET,
|
29346 |
|
29347 |
|
29348 | CHAR_RIGHT_SQUARE_BRACKET,
|
29349 |
|
29350 |
|
29351 | CHAR_DOUBLE_QUOTE,
|
29352 |
|
29353 |
|
29354 | CHAR_SINGLE_QUOTE,
|
29355 |
|
29356 |
|
29357 | CHAR_NO_BREAK_SPACE,
|
29358 | CHAR_ZERO_WIDTH_NOBREAK_SPACE
|
29359 | } = constants$2;
|
29360 |
|
29361 |
|
29362 |
|
29363 |
|
29364 | const parse$3 = (input, options = {}) => {
|
29365 | if (typeof input !== 'string') {
|
29366 | throw new TypeError('Expected a string');
|
29367 | }
|
29368 |
|
29369 | let opts = options || {};
|
29370 | let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$2, opts.maxLength) : MAX_LENGTH$2;
|
29371 |
|
29372 | if (input.length > max) {
|
29373 | throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
|
29374 | }
|
29375 |
|
29376 | let ast = {
|
29377 | type: 'root',
|
29378 | input,
|
29379 | nodes: []
|
29380 | };
|
29381 | let stack = [ast];
|
29382 | let block = ast;
|
29383 | let prev = ast;
|
29384 | let brackets = 0;
|
29385 | let length = input.length;
|
29386 | let index = 0;
|
29387 | let depth = 0;
|
29388 | let value;
|
29389 | |
29390 |
|
29391 |
|
29392 |
|
29393 | const advance = () => input[index++];
|
29394 |
|
29395 | const push = node => {
|
29396 | if (node.type === 'text' && prev.type === 'dot') {
|
29397 | prev.type = 'text';
|
29398 | }
|
29399 |
|
29400 | if (prev && prev.type === 'text' && node.type === 'text') {
|
29401 | prev.value += node.value;
|
29402 | return;
|
29403 | }
|
29404 |
|
29405 | block.nodes.push(node);
|
29406 | node.parent = block;
|
29407 | node.prev = prev;
|
29408 | prev = node;
|
29409 | return node;
|
29410 | };
|
29411 |
|
29412 | push({
|
29413 | type: 'bos'
|
29414 | });
|
29415 |
|
29416 | while (index < length) {
|
29417 | block = stack[stack.length - 1];
|
29418 | value = advance();
|
29419 | |
29420 |
|
29421 |
|
29422 |
|
29423 | if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) {
|
29424 | continue;
|
29425 | }
|
29426 | |
29427 |
|
29428 |
|
29429 |
|
29430 |
|
29431 | if (value === CHAR_BACKSLASH) {
|
29432 | push({
|
29433 | type: 'text',
|
29434 | value: (options.keepEscaping ? value : '') + advance()
|
29435 | });
|
29436 | continue;
|
29437 | }
|
29438 | |
29439 |
|
29440 |
|
29441 |
|
29442 |
|
29443 | if (value === CHAR_RIGHT_SQUARE_BRACKET) {
|
29444 | push({
|
29445 | type: 'text',
|
29446 | value: '\\' + value
|
29447 | });
|
29448 | continue;
|
29449 | }
|
29450 | |
29451 |
|
29452 |
|
29453 |
|
29454 |
|
29455 | if (value === CHAR_LEFT_SQUARE_BRACKET) {
|
29456 | brackets++;
|
29457 | let next;
|
29458 |
|
29459 | while (index < length && (next = advance())) {
|
29460 | value += next;
|
29461 |
|
29462 | if (next === CHAR_LEFT_SQUARE_BRACKET) {
|
29463 | brackets++;
|
29464 | continue;
|
29465 | }
|
29466 |
|
29467 | if (next === CHAR_BACKSLASH) {
|
29468 | value += advance();
|
29469 | continue;
|
29470 | }
|
29471 |
|
29472 | if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
29473 | brackets--;
|
29474 |
|
29475 | if (brackets === 0) {
|
29476 | break;
|
29477 | }
|
29478 | }
|
29479 | }
|
29480 |
|
29481 | push({
|
29482 | type: 'text',
|
29483 | value
|
29484 | });
|
29485 | continue;
|
29486 | }
|
29487 | |
29488 |
|
29489 |
|
29490 |
|
29491 |
|
29492 | if (value === CHAR_LEFT_PARENTHESES) {
|
29493 | block = push({
|
29494 | type: 'paren',
|
29495 | nodes: []
|
29496 | });
|
29497 | stack.push(block);
|
29498 | push({
|
29499 | type: 'text',
|
29500 | value
|
29501 | });
|
29502 | continue;
|
29503 | }
|
29504 |
|
29505 | if (value === CHAR_RIGHT_PARENTHESES) {
|
29506 | if (block.type !== 'paren') {
|
29507 | push({
|
29508 | type: 'text',
|
29509 | value
|
29510 | });
|
29511 | continue;
|
29512 | }
|
29513 |
|
29514 | block = stack.pop();
|
29515 | push({
|
29516 | type: 'text',
|
29517 | value
|
29518 | });
|
29519 | block = stack[stack.length - 1];
|
29520 | continue;
|
29521 | }
|
29522 | |
29523 |
|
29524 |
|
29525 |
|
29526 |
|
29527 | if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
|
29528 | let open = value;
|
29529 | let next;
|
29530 |
|
29531 | if (options.keepQuotes !== true) {
|
29532 | value = '';
|
29533 | }
|
29534 |
|
29535 | while (index < length && (next = advance())) {
|
29536 | if (next === CHAR_BACKSLASH) {
|
29537 | value += next + advance();
|
29538 | continue;
|
29539 | }
|
29540 |
|
29541 | if (next === open) {
|
29542 | if (options.keepQuotes === true) value += next;
|
29543 | break;
|
29544 | }
|
29545 |
|
29546 | value += next;
|
29547 | }
|
29548 |
|
29549 | push({
|
29550 | type: 'text',
|
29551 | value
|
29552 | });
|
29553 | continue;
|
29554 | }
|
29555 | |
29556 |
|
29557 |
|
29558 |
|
29559 |
|
29560 | if (value === CHAR_LEFT_CURLY_BRACE) {
|
29561 | depth++;
|
29562 | let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
|
29563 | let brace = {
|
29564 | type: 'brace',
|
29565 | open: true,
|
29566 | close: false,
|
29567 | dollar,
|
29568 | depth,
|
29569 | commas: 0,
|
29570 | ranges: 0,
|
29571 | nodes: []
|
29572 | };
|
29573 | block = push(brace);
|
29574 | stack.push(block);
|
29575 | push({
|
29576 | type: 'open',
|
29577 | value
|
29578 | });
|
29579 | continue;
|
29580 | }
|
29581 | |
29582 |
|
29583 |
|
29584 |
|
29585 |
|
29586 | if (value === CHAR_RIGHT_CURLY_BRACE) {
|
29587 | if (block.type !== 'brace') {
|
29588 | push({
|
29589 | type: 'text',
|
29590 | value
|
29591 | });
|
29592 | continue;
|
29593 | }
|
29594 |
|
29595 | let type = 'close';
|
29596 | block = stack.pop();
|
29597 | block.close = true;
|
29598 | push({
|
29599 | type,
|
29600 | value
|
29601 | });
|
29602 | depth--;
|
29603 | block = stack[stack.length - 1];
|
29604 | continue;
|
29605 | }
|
29606 | |
29607 |
|
29608 |
|
29609 |
|
29610 |
|
29611 | if (value === CHAR_COMMA$1 && depth > 0) {
|
29612 | if (block.ranges > 0) {
|
29613 | block.ranges = 0;
|
29614 | let open = block.nodes.shift();
|
29615 | block.nodes = [open, {
|
29616 | type: 'text',
|
29617 | value: stringify(block)
|
29618 | }];
|
29619 | }
|
29620 |
|
29621 | push({
|
29622 | type: 'comma',
|
29623 | value
|
29624 | });
|
29625 | block.commas++;
|
29626 | continue;
|
29627 | }
|
29628 | |
29629 |
|
29630 |
|
29631 |
|
29632 |
|
29633 | if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
|
29634 | let siblings = block.nodes;
|
29635 |
|
29636 | if (depth === 0 || siblings.length === 0) {
|
29637 | push({
|
29638 | type: 'text',
|
29639 | value
|
29640 | });
|
29641 | continue;
|
29642 | }
|
29643 |
|
29644 | if (prev.type === 'dot') {
|
29645 | block.range = [];
|
29646 | prev.value += value;
|
29647 | prev.type = 'range';
|
29648 |
|
29649 | if (block.nodes.length !== 3 && block.nodes.length !== 5) {
|
29650 | block.invalid = true;
|
29651 | block.ranges = 0;
|
29652 | prev.type = 'text';
|
29653 | continue;
|
29654 | }
|
29655 |
|
29656 | block.ranges++;
|
29657 | block.args = [];
|
29658 | continue;
|
29659 | }
|
29660 |
|
29661 | if (prev.type === 'range') {
|
29662 | siblings.pop();
|
29663 | let before = siblings[siblings.length - 1];
|
29664 | before.value += prev.value + value;
|
29665 | prev = before;
|
29666 | block.ranges--;
|
29667 | continue;
|
29668 | }
|
29669 |
|
29670 | push({
|
29671 | type: 'dot',
|
29672 | value
|
29673 | });
|
29674 | continue;
|
29675 | }
|
29676 | |
29677 |
|
29678 |
|
29679 |
|
29680 |
|
29681 | push({
|
29682 | type: 'text',
|
29683 | value
|
29684 | });
|
29685 | }
|
29686 |
|
29687 |
|
29688 | do {
|
29689 | block = stack.pop();
|
29690 |
|
29691 | if (block.type !== 'root') {
|
29692 | block.nodes.forEach(node => {
|
29693 | if (!node.nodes) {
|
29694 | if (node.type === 'open') node.isOpen = true;
|
29695 | if (node.type === 'close') node.isClose = true;
|
29696 | if (!node.nodes) node.type = 'text';
|
29697 | node.invalid = true;
|
29698 | }
|
29699 | });
|
29700 |
|
29701 | let parent = stack[stack.length - 1];
|
29702 | let index = parent.nodes.indexOf(block);
|
29703 |
|
29704 | parent.nodes.splice(index, 1, ...block.nodes);
|
29705 | }
|
29706 | } while (stack.length > 0);
|
29707 |
|
29708 | push({
|
29709 | type: 'eos'
|
29710 | });
|
29711 | return ast;
|
29712 | };
|
29713 |
|
29714 | var parse_1 = parse$3;
|
29715 |
|
29716 |
|
29717 |
|
29718 |
|
29719 |
|
29720 |
|
29721 |
|
29722 |
|
29723 |
|
29724 |
|
29725 |
|
29726 |
|
29727 |
|
29728 |
|
29729 |
|
29730 |
|
29731 | const braces = (input, options = {}) => {
|
29732 | let output = [];
|
29733 |
|
29734 | if (Array.isArray(input)) {
|
29735 | for (let pattern of input) {
|
29736 | let result = braces.create(pattern, options);
|
29737 |
|
29738 | if (Array.isArray(result)) {
|
29739 | output.push(...result);
|
29740 | } else {
|
29741 | output.push(result);
|
29742 | }
|
29743 | }
|
29744 | } else {
|
29745 | output = [].concat(braces.create(input, options));
|
29746 | }
|
29747 |
|
29748 | if (options && options.expand === true && options.nodupes === true) {
|
29749 | output = [...new Set(output)];
|
29750 | }
|
29751 |
|
29752 | return output;
|
29753 | };
|
29754 |
|
29755 |
|
29756 |
|
29757 |
|
29758 |
|
29759 |
|
29760 |
|
29761 |
|
29762 |
|
29763 |
|
29764 |
|
29765 |
|
29766 |
|
29767 |
|
29768 |
|
29769 | braces.parse = (input, options = {}) => parse_1(input, options);
|
29770 |
|
29771 |
|
29772 |
|
29773 |
|
29774 |
|
29775 |
|
29776 |
|
29777 |
|
29778 |
|
29779 |
|
29780 |
|
29781 |
|
29782 |
|
29783 |
|
29784 |
|
29785 | braces.stringify = (input, options = {}) => {
|
29786 | if (typeof input === 'string') {
|
29787 | return stringify(braces.parse(input, options), options);
|
29788 | }
|
29789 |
|
29790 | return stringify(input, options);
|
29791 | };
|
29792 |
|
29793 |
|
29794 |
|
29795 |
|
29796 |
|
29797 |
|
29798 |
|
29799 |
|
29800 |
|
29801 |
|
29802 |
|
29803 |
|
29804 |
|
29805 |
|
29806 |
|
29807 |
|
29808 | braces.compile = (input, options = {}) => {
|
29809 | if (typeof input === 'string') {
|
29810 | input = braces.parse(input, options);
|
29811 | }
|
29812 |
|
29813 | return compile_1(input, options);
|
29814 | };
|
29815 |
|
29816 |
|
29817 |
|
29818 |
|
29819 |
|
29820 |
|
29821 |
|
29822 |
|
29823 |
|
29824 |
|
29825 |
|
29826 |
|
29827 |
|
29828 |
|
29829 |
|
29830 |
|
29831 |
|
29832 |
|
29833 | braces.expand = (input, options = {}) => {
|
29834 | if (typeof input === 'string') {
|
29835 | input = braces.parse(input, options);
|
29836 | }
|
29837 |
|
29838 | let result = expand_1(input, options);
|
29839 |
|
29840 | if (options.noempty === true) {
|
29841 | result = result.filter(Boolean);
|
29842 | }
|
29843 |
|
29844 |
|
29845 | if (options.nodupes === true) {
|
29846 | result = [...new Set(result)];
|
29847 | }
|
29848 |
|
29849 | return result;
|
29850 | };
|
29851 |
|
29852 |
|
29853 |
|
29854 |
|
29855 |
|
29856 |
|
29857 |
|
29858 |
|
29859 |
|
29860 |
|
29861 |
|
29862 |
|
29863 |
|
29864 |
|
29865 |
|
29866 |
|
29867 |
|
29868 | braces.create = (input, options = {}) => {
|
29869 | if (input === '' || input.length < 3) {
|
29870 | return [input];
|
29871 | }
|
29872 |
|
29873 | return options.expand !== true ? braces.compile(input, options) : braces.expand(input, options);
|
29874 | };
|
29875 |
|
29876 |
|
29877 |
|
29878 |
|
29879 |
|
29880 | var braces_1 = braces;
|
29881 |
|
29882 | const WIN_SLASH = '\\\\/';
|
29883 | const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
29884 |
|
29885 |
|
29886 |
|
29887 |
|
29888 | const DOT_LITERAL = '\\.';
|
29889 | const PLUS_LITERAL = '\\+';
|
29890 | const QMARK_LITERAL = '\\?';
|
29891 | const SLASH_LITERAL = '\\/';
|
29892 | const ONE_CHAR = '(?=.)';
|
29893 | const QMARK = '[^/]';
|
29894 | const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
29895 | const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
29896 | const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
29897 | const NO_DOT = `(?!${DOT_LITERAL})`;
|
29898 | const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
29899 | const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
29900 | const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
29901 | const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
29902 | const STAR = `${QMARK}*?`;
|
29903 | const POSIX_CHARS = {
|
29904 | DOT_LITERAL,
|
29905 | PLUS_LITERAL,
|
29906 | QMARK_LITERAL,
|
29907 | SLASH_LITERAL,
|
29908 | ONE_CHAR,
|
29909 | QMARK,
|
29910 | END_ANCHOR,
|
29911 | DOTS_SLASH,
|
29912 | NO_DOT,
|
29913 | NO_DOTS,
|
29914 | NO_DOT_SLASH,
|
29915 | NO_DOTS_SLASH,
|
29916 | QMARK_NO_DOT,
|
29917 | STAR,
|
29918 | START_ANCHOR
|
29919 | };
|
29920 |
|
29921 |
|
29922 |
|
29923 |
|
29924 | const WINDOWS_CHARS = Object.assign({}, POSIX_CHARS, {
|
29925 | SLASH_LITERAL: `[${WIN_SLASH}]`,
|
29926 | QMARK: WIN_NO_SLASH,
|
29927 | STAR: `${WIN_NO_SLASH}*?`,
|
29928 | DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
29929 | NO_DOT: `(?!${DOT_LITERAL})`,
|
29930 | NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
29931 | NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
29932 | NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
29933 | QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
29934 | START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
29935 | END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
|
29936 | });
|
29937 |
|
29938 |
|
29939 |
|
29940 |
|
29941 | const POSIX_REGEX_SOURCE = {
|
29942 | alnum: 'a-zA-Z0-9',
|
29943 | alpha: 'a-zA-Z',
|
29944 | ascii: '\\x00-\\x7F',
|
29945 | blank: ' \\t',
|
29946 | cntrl: '\\x00-\\x1F\\x7F',
|
29947 | digit: '0-9',
|
29948 | graph: '\\x21-\\x7E',
|
29949 | lower: 'a-z',
|
29950 | print: '\\x20-\\x7E ',
|
29951 | punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
|
29952 | space: ' \\t\\r\\n\\v\\f',
|
29953 | upper: 'A-Z',
|
29954 | word: 'A-Za-z0-9_',
|
29955 | xdigit: 'A-Fa-f0-9'
|
29956 | };
|
29957 | var constants$3 = {
|
29958 | MAX_LENGTH: 1024 * 64,
|
29959 | POSIX_REGEX_SOURCE,
|
29960 |
|
29961 | REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
29962 | REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
29963 | REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
29964 | REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
29965 | REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
29966 | REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
29967 |
|
29968 | REPLACEMENTS: {
|
29969 | '***': '*',
|
29970 | '**/**': '**',
|
29971 | '**/**/**': '**'
|
29972 | },
|
29973 |
|
29974 | CHAR_0: 48,
|
29975 |
|
29976 |
|
29977 | CHAR_9: 57,
|
29978 |
|
29979 |
|
29980 |
|
29981 | CHAR_UPPERCASE_A: 65,
|
29982 |
|
29983 |
|
29984 | CHAR_LOWERCASE_A: 97,
|
29985 |
|
29986 |
|
29987 | CHAR_UPPERCASE_Z: 90,
|
29988 |
|
29989 |
|
29990 | CHAR_LOWERCASE_Z: 122,
|
29991 |
|
29992 |
|
29993 | CHAR_LEFT_PARENTHESES: 40,
|
29994 |
|
29995 |
|
29996 | CHAR_RIGHT_PARENTHESES: 41,
|
29997 |
|
29998 |
|
29999 | CHAR_ASTERISK: 42,
|
30000 |
|
30001 |
|
30002 |
|
30003 | CHAR_AMPERSAND: 38,
|
30004 |
|
30005 |
|
30006 | CHAR_AT: 64,
|
30007 |
|
30008 |
|
30009 | CHAR_BACKWARD_SLASH: 92,
|
30010 |
|
30011 |
|
30012 | CHAR_CARRIAGE_RETURN: 13,
|
30013 |
|
30014 |
|
30015 | CHAR_CIRCUMFLEX_ACCENT: 94,
|
30016 |
|
30017 |
|
30018 | CHAR_COLON: 58,
|
30019 |
|
30020 |
|
30021 | CHAR_COMMA: 44,
|
30022 |
|
30023 |
|
30024 | CHAR_DOT: 46,
|
30025 |
|
30026 |
|
30027 | CHAR_DOUBLE_QUOTE: 34,
|
30028 |
|
30029 |
|
30030 | CHAR_EQUAL: 61,
|
30031 |
|
30032 |
|
30033 | CHAR_EXCLAMATION_MARK: 33,
|
30034 |
|
30035 |
|
30036 | CHAR_FORM_FEED: 12,
|
30037 |
|
30038 |
|
30039 | CHAR_FORWARD_SLASH: 47,
|
30040 |
|
30041 |
|
30042 | CHAR_GRAVE_ACCENT: 96,
|
30043 |
|
30044 |
|
30045 | CHAR_HASH: 35,
|
30046 |
|
30047 |
|
30048 | CHAR_HYPHEN_MINUS: 45,
|
30049 |
|
30050 |
|
30051 | CHAR_LEFT_ANGLE_BRACKET: 60,
|
30052 |
|
30053 |
|
30054 | CHAR_LEFT_CURLY_BRACE: 123,
|
30055 |
|
30056 |
|
30057 | CHAR_LEFT_SQUARE_BRACKET: 91,
|
30058 |
|
30059 |
|
30060 | CHAR_LINE_FEED: 10,
|
30061 |
|
30062 |
|
30063 | CHAR_NO_BREAK_SPACE: 160,
|
30064 |
|
30065 |
|
30066 | CHAR_PERCENT: 37,
|
30067 |
|
30068 |
|
30069 | CHAR_PLUS: 43,
|
30070 |
|
30071 |
|
30072 | CHAR_QUESTION_MARK: 63,
|
30073 |
|
30074 |
|
30075 | CHAR_RIGHT_ANGLE_BRACKET: 62,
|
30076 |
|
30077 |
|
30078 | CHAR_RIGHT_CURLY_BRACE: 125,
|
30079 |
|
30080 |
|
30081 | CHAR_RIGHT_SQUARE_BRACKET: 93,
|
30082 |
|
30083 |
|
30084 | CHAR_SEMICOLON: 59,
|
30085 |
|
30086 |
|
30087 | CHAR_SINGLE_QUOTE: 39,
|
30088 |
|
30089 |
|
30090 | CHAR_SPACE: 32,
|
30091 |
|
30092 |
|
30093 | CHAR_TAB: 9,
|
30094 |
|
30095 |
|
30096 | CHAR_UNDERSCORE: 95,
|
30097 |
|
30098 |
|
30099 | CHAR_VERTICAL_LINE: 124,
|
30100 |
|
30101 |
|
30102 | CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
30103 |
|
30104 |
|
30105 | SEP: path$2.sep,
|
30106 |
|
30107 | |
30108 |
|
30109 |
|
30110 | extglobChars(chars) {
|
30111 | return {
|
30112 | '!': {
|
30113 | type: 'negate',
|
30114 | open: '(?:(?!(?:',
|
30115 | close: `))${chars.STAR})`
|
30116 | },
|
30117 | '?': {
|
30118 | type: 'qmark',
|
30119 | open: '(?:',
|
30120 | close: ')?'
|
30121 | },
|
30122 | '+': {
|
30123 | type: 'plus',
|
30124 | open: '(?:',
|
30125 | close: ')+'
|
30126 | },
|
30127 | '*': {
|
30128 | type: 'star',
|
30129 | open: '(?:',
|
30130 | close: ')*'
|
30131 | },
|
30132 | '@': {
|
30133 | type: 'at',
|
30134 | open: '(?:',
|
30135 | close: ')'
|
30136 | }
|
30137 | };
|
30138 | },
|
30139 |
|
30140 | |
30141 |
|
30142 |
|
30143 | globChars(win32) {
|
30144 | return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
30145 | }
|
30146 |
|
30147 | };
|
30148 |
|
30149 | var utils$3 = createCommonjsModule(function (module, exports) {
|
30150 |
|
30151 | const win32 = process.platform === 'win32';
|
30152 | const {
|
30153 | REGEX_BACKSLASH,
|
30154 | REGEX_REMOVE_BACKSLASH,
|
30155 | REGEX_SPECIAL_CHARS,
|
30156 | REGEX_SPECIAL_CHARS_GLOBAL
|
30157 | } = constants$3;
|
30158 |
|
30159 | exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
30160 |
|
30161 | exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
|
30162 |
|
30163 | exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
|
30164 |
|
30165 | exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
30166 |
|
30167 | exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
|
30168 |
|
30169 | exports.removeBackslashes = str => {
|
30170 | return str.replace(REGEX_REMOVE_BACKSLASH, match => {
|
30171 | return match === '\\' ? '' : match;
|
30172 | });
|
30173 | };
|
30174 |
|
30175 | exports.supportsLookbehinds = () => {
|
30176 | const segs = process.version.slice(1).split('.').map(Number);
|
30177 |
|
30178 | if (segs.length === 3 && segs[0] >= 9 || segs[0] === 8 && segs[1] >= 10) {
|
30179 | return true;
|
30180 | }
|
30181 |
|
30182 | return false;
|
30183 | };
|
30184 |
|
30185 | exports.isWindows = options => {
|
30186 | if (options && typeof options.windows === 'boolean') {
|
30187 | return options.windows;
|
30188 | }
|
30189 |
|
30190 | return win32 === true || path$2.sep === '\\';
|
30191 | };
|
30192 |
|
30193 | exports.escapeLast = (input, char, lastIdx) => {
|
30194 | const idx = input.lastIndexOf(char, lastIdx);
|
30195 | if (idx === -1) return input;
|
30196 | if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
|
30197 | return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
30198 | };
|
30199 |
|
30200 | exports.removePrefix = (input, state = {}) => {
|
30201 | let output = input;
|
30202 |
|
30203 | if (output.startsWith('./')) {
|
30204 | output = output.slice(2);
|
30205 | state.prefix = './';
|
30206 | }
|
30207 |
|
30208 | return output;
|
30209 | };
|
30210 |
|
30211 | exports.wrapOutput = (input, state = {}, options = {}) => {
|
30212 | const prepend = options.contains ? '' : '^';
|
30213 | const append = options.contains ? '' : '$';
|
30214 | let output = `${prepend}(?:${input})${append}`;
|
30215 |
|
30216 | if (state.negated === true) {
|
30217 | output = `(?:^(?!${output}).*$)`;
|
30218 | }
|
30219 |
|
30220 | return output;
|
30221 | };
|
30222 | });
|
30223 | var utils_1$3 = utils$3.isObject;
|
30224 | var utils_2$3 = utils$3.hasRegexChars;
|
30225 | var utils_3$3 = utils$3.isRegexChar;
|
30226 | var utils_4$2 = utils$3.escapeRegex;
|
30227 | var utils_5$2 = utils$3.toPosixSlashes;
|
30228 | var utils_6$2 = utils$3.removeBackslashes;
|
30229 | var utils_7$2 = utils$3.supportsLookbehinds;
|
30230 | var utils_8$2 = utils$3.isWindows;
|
30231 | var utils_9$2 = utils$3.escapeLast;
|
30232 | var utils_10$1 = utils$3.removePrefix;
|
30233 | var utils_11$1 = utils$3.wrapOutput;
|
30234 |
|
30235 | const {
|
30236 | CHAR_ASTERISK,
|
30237 |
|
30238 |
|
30239 | CHAR_AT,
|
30240 |
|
30241 |
|
30242 | CHAR_BACKWARD_SLASH,
|
30243 |
|
30244 |
|
30245 | CHAR_COMMA: CHAR_COMMA$2,
|
30246 |
|
30247 |
|
30248 | CHAR_DOT: CHAR_DOT$1,
|
30249 |
|
30250 |
|
30251 | CHAR_EXCLAMATION_MARK,
|
30252 |
|
30253 |
|
30254 | CHAR_FORWARD_SLASH,
|
30255 |
|
30256 |
|
30257 | CHAR_LEFT_CURLY_BRACE: CHAR_LEFT_CURLY_BRACE$1,
|
30258 |
|
30259 |
|
30260 | CHAR_LEFT_PARENTHESES: CHAR_LEFT_PARENTHESES$1,
|
30261 |
|
30262 |
|
30263 | CHAR_LEFT_SQUARE_BRACKET: CHAR_LEFT_SQUARE_BRACKET$1,
|
30264 |
|
30265 |
|
30266 | CHAR_PLUS: CHAR_PLUS$1,
|
30267 |
|
30268 |
|
30269 | CHAR_QUESTION_MARK,
|
30270 |
|
30271 |
|
30272 | CHAR_RIGHT_CURLY_BRACE: CHAR_RIGHT_CURLY_BRACE$1,
|
30273 |
|
30274 |
|
30275 | CHAR_RIGHT_PARENTHESES: CHAR_RIGHT_PARENTHESES$1,
|
30276 |
|
30277 |
|
30278 | CHAR_RIGHT_SQUARE_BRACKET: CHAR_RIGHT_SQUARE_BRACKET$1
|
30279 |
|
30280 |
|
30281 | } = constants$3;
|
30282 |
|
30283 | const isPathSeparator = code => {
|
30284 | return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
30285 | };
|
30286 |
|
30287 | const depth = token => {
|
30288 | if (token.isPrefix !== true) {
|
30289 | token.depth = token.isGlobstar ? Infinity : 1;
|
30290 | }
|
30291 | };
|
30292 |
|
30293 |
|
30294 |
|
30295 |
|
30296 |
|
30297 |
|
30298 |
|
30299 |
|
30300 |
|
30301 |
|
30302 |
|
30303 |
|
30304 |
|
30305 |
|
30306 |
|
30307 |
|
30308 |
|
30309 | const scan = (input, options) => {
|
30310 | const opts = options || {};
|
30311 | const length = input.length - 1;
|
30312 | const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
30313 | const slashes = [];
|
30314 | const tokens = [];
|
30315 | const parts = [];
|
30316 | let str = input;
|
30317 | let index = -1;
|
30318 | let start = 0;
|
30319 | let lastIndex = 0;
|
30320 | let isBrace = false;
|
30321 | let isBracket = false;
|
30322 | let isGlob = false;
|
30323 | let isExtglob = false;
|
30324 | let isGlobstar = false;
|
30325 | let braceEscaped = false;
|
30326 | let backslashes = false;
|
30327 | let negated = false;
|
30328 | let finished = false;
|
30329 | let braces = 0;
|
30330 | let prev;
|
30331 | let code;
|
30332 | let token = {
|
30333 | value: '',
|
30334 | depth: 0,
|
30335 | isGlob: false
|
30336 | };
|
30337 |
|
30338 | const eos = () => index >= length;
|
30339 |
|
30340 | const peek = () => str.charCodeAt(index + 1);
|
30341 |
|
30342 | const advance = () => {
|
30343 | prev = code;
|
30344 | return str.charCodeAt(++index);
|
30345 | };
|
30346 |
|
30347 | while (index < length) {
|
30348 | code = advance();
|
30349 | let next;
|
30350 |
|
30351 | if (code === CHAR_BACKWARD_SLASH) {
|
30352 | backslashes = token.backslashes = true;
|
30353 | code = advance();
|
30354 |
|
30355 | if (code === CHAR_LEFT_CURLY_BRACE$1) {
|
30356 | braceEscaped = true;
|
30357 | }
|
30358 |
|
30359 | continue;
|
30360 | }
|
30361 |
|
30362 | if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE$1) {
|
30363 | braces++;
|
30364 |
|
30365 | while (eos() !== true && (code = advance())) {
|
30366 | if (code === CHAR_BACKWARD_SLASH) {
|
30367 | backslashes = token.backslashes = true;
|
30368 | advance();
|
30369 | continue;
|
30370 | }
|
30371 |
|
30372 | if (code === CHAR_LEFT_CURLY_BRACE$1) {
|
30373 | braces++;
|
30374 | continue;
|
30375 | }
|
30376 |
|
30377 | if (braceEscaped !== true && code === CHAR_DOT$1 && (code = advance()) === CHAR_DOT$1) {
|
30378 | isBrace = token.isBrace = true;
|
30379 | isGlob = token.isGlob = true;
|
30380 | finished = true;
|
30381 |
|
30382 | if (scanToEnd === true) {
|
30383 | continue;
|
30384 | }
|
30385 |
|
30386 | break;
|
30387 | }
|
30388 |
|
30389 | if (braceEscaped !== true && code === CHAR_COMMA$2) {
|
30390 | isBrace = token.isBrace = true;
|
30391 | isGlob = token.isGlob = true;
|
30392 | finished = true;
|
30393 |
|
30394 | if (scanToEnd === true) {
|
30395 | continue;
|
30396 | }
|
30397 |
|
30398 | break;
|
30399 | }
|
30400 |
|
30401 | if (code === CHAR_RIGHT_CURLY_BRACE$1) {
|
30402 | braces--;
|
30403 |
|
30404 | if (braces === 0) {
|
30405 | braceEscaped = false;
|
30406 | isBrace = token.isBrace = true;
|
30407 | finished = true;
|
30408 | break;
|
30409 | }
|
30410 | }
|
30411 | }
|
30412 |
|
30413 | if (scanToEnd === true) {
|
30414 | continue;
|
30415 | }
|
30416 |
|
30417 | break;
|
30418 | }
|
30419 |
|
30420 | if (code === CHAR_FORWARD_SLASH) {
|
30421 | slashes.push(index);
|
30422 | tokens.push(token);
|
30423 | token = {
|
30424 | value: '',
|
30425 | depth: 0,
|
30426 | isGlob: false
|
30427 | };
|
30428 | if (finished === true) continue;
|
30429 |
|
30430 | if (prev === CHAR_DOT$1 && index === start + 1) {
|
30431 | start += 2;
|
30432 | continue;
|
30433 | }
|
30434 |
|
30435 | lastIndex = index + 1;
|
30436 | continue;
|
30437 | }
|
30438 |
|
30439 | if (opts.noext !== true) {
|
30440 | const isExtglobChar = code === CHAR_PLUS$1 || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
30441 |
|
30442 | if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES$1) {
|
30443 | isGlob = token.isGlob = true;
|
30444 | isExtglob = token.isExtglob = true;
|
30445 | finished = true;
|
30446 |
|
30447 | if (scanToEnd === true) {
|
30448 | while (eos() !== true && (code = advance())) {
|
30449 | if (code === CHAR_BACKWARD_SLASH) {
|
30450 | backslashes = token.backslashes = true;
|
30451 | code = advance();
|
30452 | continue;
|
30453 | }
|
30454 |
|
30455 | if (code === CHAR_RIGHT_PARENTHESES$1) {
|
30456 | isGlob = token.isGlob = true;
|
30457 | finished = true;
|
30458 | break;
|
30459 | }
|
30460 | }
|
30461 |
|
30462 | continue;
|
30463 | }
|
30464 |
|
30465 | break;
|
30466 | }
|
30467 | }
|
30468 |
|
30469 | if (code === CHAR_ASTERISK) {
|
30470 | if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
30471 | isGlob = token.isGlob = true;
|
30472 | finished = true;
|
30473 |
|
30474 | if (scanToEnd === true) {
|
30475 | continue;
|
30476 | }
|
30477 |
|
30478 | break;
|
30479 | }
|
30480 |
|
30481 | if (code === CHAR_QUESTION_MARK) {
|
30482 | isGlob = token.isGlob = true;
|
30483 | finished = true;
|
30484 |
|
30485 | if (scanToEnd === true) {
|
30486 | continue;
|
30487 | }
|
30488 |
|
30489 | break;
|
30490 | }
|
30491 |
|
30492 | if (code === CHAR_LEFT_SQUARE_BRACKET$1) {
|
30493 | while (eos() !== true && (next = advance())) {
|
30494 | if (next === CHAR_BACKWARD_SLASH) {
|
30495 | backslashes = token.backslashes = true;
|
30496 | advance();
|
30497 | continue;
|
30498 | }
|
30499 |
|
30500 | if (next === CHAR_RIGHT_SQUARE_BRACKET$1) {
|
30501 | isBracket = token.isBracket = true;
|
30502 | isGlob = token.isGlob = true;
|
30503 | finished = true;
|
30504 |
|
30505 | if (scanToEnd === true) {
|
30506 | continue;
|
30507 | }
|
30508 |
|
30509 | break;
|
30510 | }
|
30511 | }
|
30512 | }
|
30513 |
|
30514 | if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
30515 | negated = token.negated = true;
|
30516 | start++;
|
30517 | continue;
|
30518 | }
|
30519 |
|
30520 | if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES$1) {
|
30521 | while (eos() !== true && (code = advance())) {
|
30522 | if (code === CHAR_BACKWARD_SLASH) {
|
30523 | backslashes = token.backslashes = true;
|
30524 | code = advance();
|
30525 | continue;
|
30526 | }
|
30527 |
|
30528 | if (code === CHAR_RIGHT_PARENTHESES$1) {
|
30529 | isGlob = token.isGlob = true;
|
30530 | finished = true;
|
30531 |
|
30532 | if (scanToEnd === true) {
|
30533 | continue;
|
30534 | }
|
30535 |
|
30536 | break;
|
30537 | }
|
30538 | }
|
30539 | }
|
30540 |
|
30541 | if (isGlob === true) {
|
30542 | finished = true;
|
30543 |
|
30544 | if (scanToEnd === true) {
|
30545 | continue;
|
30546 | }
|
30547 |
|
30548 | break;
|
30549 | }
|
30550 | }
|
30551 |
|
30552 | if (opts.noext === true) {
|
30553 | isExtglob = false;
|
30554 | isGlob = false;
|
30555 | }
|
30556 |
|
30557 | let base = str;
|
30558 | let prefix = '';
|
30559 | let glob = '';
|
30560 |
|
30561 | if (start > 0) {
|
30562 | prefix = str.slice(0, start);
|
30563 | str = str.slice(start);
|
30564 | lastIndex -= start;
|
30565 | }
|
30566 |
|
30567 | if (base && isGlob === true && lastIndex > 0) {
|
30568 | base = str.slice(0, lastIndex);
|
30569 | glob = str.slice(lastIndex);
|
30570 | } else if (isGlob === true) {
|
30571 | base = '';
|
30572 | glob = str;
|
30573 | } else {
|
30574 | base = str;
|
30575 | }
|
30576 |
|
30577 | if (base && base !== '' && base !== '/' && base !== str) {
|
30578 | if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
30579 | base = base.slice(0, -1);
|
30580 | }
|
30581 | }
|
30582 |
|
30583 | if (opts.unescape === true) {
|
30584 | if (glob) glob = utils$3.removeBackslashes(glob);
|
30585 |
|
30586 | if (base && backslashes === true) {
|
30587 | base = utils$3.removeBackslashes(base);
|
30588 | }
|
30589 | }
|
30590 |
|
30591 | const state = {
|
30592 | prefix,
|
30593 | input,
|
30594 | start,
|
30595 | base,
|
30596 | glob,
|
30597 | isBrace,
|
30598 | isBracket,
|
30599 | isGlob,
|
30600 | isExtglob,
|
30601 | isGlobstar,
|
30602 | negated
|
30603 | };
|
30604 |
|
30605 | if (opts.tokens === true) {
|
30606 | state.maxDepth = 0;
|
30607 |
|
30608 | if (!isPathSeparator(code)) {
|
30609 | tokens.push(token);
|
30610 | }
|
30611 |
|
30612 | state.tokens = tokens;
|
30613 | }
|
30614 |
|
30615 | if (opts.parts === true || opts.tokens === true) {
|
30616 | let prevIndex;
|
30617 |
|
30618 | for (let idx = 0; idx < slashes.length; idx++) {
|
30619 | const n = prevIndex ? prevIndex + 1 : start;
|
30620 | const i = slashes[idx];
|
30621 | const value = input.slice(n, i);
|
30622 |
|
30623 | if (opts.tokens) {
|
30624 | if (idx === 0 && start !== 0) {
|
30625 | tokens[idx].isPrefix = true;
|
30626 | tokens[idx].value = prefix;
|
30627 | } else {
|
30628 | tokens[idx].value = value;
|
30629 | }
|
30630 |
|
30631 | depth(tokens[idx]);
|
30632 | state.maxDepth += tokens[idx].depth;
|
30633 | }
|
30634 |
|
30635 | if (idx !== 0 || value !== '') {
|
30636 | parts.push(value);
|
30637 | }
|
30638 |
|
30639 | prevIndex = i;
|
30640 | }
|
30641 |
|
30642 | if (prevIndex && prevIndex + 1 < input.length) {
|
30643 | const value = input.slice(prevIndex + 1);
|
30644 | parts.push(value);
|
30645 |
|
30646 | if (opts.tokens) {
|
30647 | tokens[tokens.length - 1].value = value;
|
30648 | depth(tokens[tokens.length - 1]);
|
30649 | state.maxDepth += tokens[tokens.length - 1].depth;
|
30650 | }
|
30651 | }
|
30652 |
|
30653 | state.slashes = slashes;
|
30654 | state.parts = parts;
|
30655 | }
|
30656 |
|
30657 | return state;
|
30658 | };
|
30659 |
|
30660 | var scan_1 = scan;
|
30661 |
|
30662 |
|
30663 |
|
30664 |
|
30665 |
|
30666 |
|
30667 | const {
|
30668 | MAX_LENGTH: MAX_LENGTH$3,
|
30669 | POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
|
30670 | REGEX_NON_SPECIAL_CHARS,
|
30671 | REGEX_SPECIAL_CHARS_BACKREF,
|
30672 | REPLACEMENTS
|
30673 | } = constants$3;
|
30674 |
|
30675 |
|
30676 |
|
30677 |
|
30678 | const expandRange = (args, options) => {
|
30679 | if (typeof options.expandRange === 'function') {
|
30680 | return options.expandRange(...args, options);
|
30681 | }
|
30682 |
|
30683 | args.sort();
|
30684 | const value = `[${args.join('-')}]`;
|
30685 |
|
30686 | try {
|
30687 |
|
30688 | new RegExp(value);
|
30689 | } catch (ex) {
|
30690 | return args.map(v => utils$3.escapeRegex(v)).join('..');
|
30691 | }
|
30692 |
|
30693 | return value;
|
30694 | };
|
30695 |
|
30696 |
|
30697 |
|
30698 |
|
30699 |
|
30700 | const syntaxError = (type, char) => {
|
30701 | return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
30702 | };
|
30703 |
|
30704 |
|
30705 |
|
30706 |
|
30707 |
|
30708 |
|
30709 |
|
30710 |
|
30711 | const parse$4 = (input, options) => {
|
30712 | if (typeof input !== 'string') {
|
30713 | throw new TypeError('Expected a string');
|
30714 | }
|
30715 |
|
30716 | input = REPLACEMENTS[input] || input;
|
30717 | const opts = Object.assign({}, options);
|
30718 | const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$3, opts.maxLength) : MAX_LENGTH$3;
|
30719 | let len = input.length;
|
30720 |
|
30721 | if (len > max) {
|
30722 | throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
30723 | }
|
30724 |
|
30725 | const bos = {
|
30726 | type: 'bos',
|
30727 | value: '',
|
30728 | output: opts.prepend || ''
|
30729 | };
|
30730 | const tokens = [bos];
|
30731 | const capture = opts.capture ? '' : '?:';
|
30732 | const win32 = utils$3.isWindows(options);
|
30733 |
|
30734 | const PLATFORM_CHARS = constants$3.globChars(win32);
|
30735 | const EXTGLOB_CHARS = constants$3.extglobChars(PLATFORM_CHARS);
|
30736 | const {
|
30737 | DOT_LITERAL,
|
30738 | PLUS_LITERAL,
|
30739 | SLASH_LITERAL,
|
30740 | ONE_CHAR,
|
30741 | DOTS_SLASH,
|
30742 | NO_DOT,
|
30743 | NO_DOT_SLASH,
|
30744 | NO_DOTS_SLASH,
|
30745 | QMARK,
|
30746 | QMARK_NO_DOT,
|
30747 | STAR,
|
30748 | START_ANCHOR
|
30749 | } = PLATFORM_CHARS;
|
30750 |
|
30751 | const globstar = opts => {
|
30752 | return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
30753 | };
|
30754 |
|
30755 | const nodot = opts.dot ? '' : NO_DOT;
|
30756 | const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
30757 | let star = opts.bash === true ? globstar(opts) : STAR;
|
30758 |
|
30759 | if (opts.capture) {
|
30760 | star = `(${star})`;
|
30761 | }
|
30762 |
|
30763 |
|
30764 | if (typeof opts.noext === 'boolean') {
|
30765 | opts.noextglob = opts.noext;
|
30766 | }
|
30767 |
|
30768 | const state = {
|
30769 | input,
|
30770 | index: -1,
|
30771 | start: 0,
|
30772 | dot: opts.dot === true,
|
30773 | consumed: '',
|
30774 | output: '',
|
30775 | prefix: '',
|
30776 | backtrack: false,
|
30777 | negated: false,
|
30778 | brackets: 0,
|
30779 | braces: 0,
|
30780 | parens: 0,
|
30781 | quotes: 0,
|
30782 | globstar: false,
|
30783 | tokens
|
30784 | };
|
30785 | input = utils$3.removePrefix(input, state);
|
30786 | len = input.length;
|
30787 | const extglobs = [];
|
30788 | const braces = [];
|
30789 | const stack = [];
|
30790 | let prev = bos;
|
30791 | let value;
|
30792 | |
30793 |
|
30794 |
|
30795 |
|
30796 | const eos = () => state.index === len - 1;
|
30797 |
|
30798 | const peek = state.peek = (n = 1) => input[state.index + n];
|
30799 |
|
30800 | const advance = state.advance = () => input[++state.index];
|
30801 |
|
30802 | const remaining = () => input.slice(state.index + 1);
|
30803 |
|
30804 | const consume = (value = '', num = 0) => {
|
30805 | state.consumed += value;
|
30806 | state.index += num;
|
30807 | };
|
30808 |
|
30809 | const append = token => {
|
30810 | state.output += token.output != null ? token.output : token.value;
|
30811 | consume(token.value);
|
30812 | };
|
30813 |
|
30814 | const negate = () => {
|
30815 | let count = 1;
|
30816 |
|
30817 | while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
|
30818 | advance();
|
30819 | state.start++;
|
30820 | count++;
|
30821 | }
|
30822 |
|
30823 | if (count % 2 === 0) {
|
30824 | return false;
|
30825 | }
|
30826 |
|
30827 | state.negated = true;
|
30828 | state.start++;
|
30829 | return true;
|
30830 | };
|
30831 |
|
30832 | const increment = type => {
|
30833 | state[type]++;
|
30834 | stack.push(type);
|
30835 | };
|
30836 |
|
30837 | const decrement = type => {
|
30838 | state[type]--;
|
30839 | stack.pop();
|
30840 | };
|
30841 | |
30842 |
|
30843 |
|
30844 |
|
30845 |
|
30846 |
|
30847 |
|
30848 |
|
30849 |
|
30850 | const push = tok => {
|
30851 | if (prev.type === 'globstar') {
|
30852 | const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
|
30853 | const isExtglob = tok.extglob === true || extglobs.length && (tok.type === 'pipe' || tok.type === 'paren');
|
30854 |
|
30855 | if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
|
30856 | state.output = state.output.slice(0, -prev.output.length);
|
30857 | prev.type = 'star';
|
30858 | prev.value = '*';
|
30859 | prev.output = star;
|
30860 | state.output += prev.output;
|
30861 | }
|
30862 | }
|
30863 |
|
30864 | if (extglobs.length && tok.type !== 'paren' && !EXTGLOB_CHARS[tok.value]) {
|
30865 | extglobs[extglobs.length - 1].inner += tok.value;
|
30866 | }
|
30867 |
|
30868 | if (tok.value || tok.output) append(tok);
|
30869 |
|
30870 | if (prev && prev.type === 'text' && tok.type === 'text') {
|
30871 | prev.value += tok.value;
|
30872 | prev.output = (prev.output || '') + tok.value;
|
30873 | return;
|
30874 | }
|
30875 |
|
30876 | tok.prev = prev;
|
30877 | tokens.push(tok);
|
30878 | prev = tok;
|
30879 | };
|
30880 |
|
30881 | const extglobOpen = (type, value) => {
|
30882 | const token = Object.assign({}, EXTGLOB_CHARS[value], {
|
30883 | conditions: 1,
|
30884 | inner: ''
|
30885 | });
|
30886 | token.prev = prev;
|
30887 | token.parens = state.parens;
|
30888 | token.output = state.output;
|
30889 | const output = (opts.capture ? '(' : '') + token.open;
|
30890 | increment('parens');
|
30891 | push({
|
30892 | type,
|
30893 | value,
|
30894 | output: state.output ? '' : ONE_CHAR
|
30895 | });
|
30896 | push({
|
30897 | type: 'paren',
|
30898 | extglob: true,
|
30899 | value: advance(),
|
30900 | output
|
30901 | });
|
30902 | extglobs.push(token);
|
30903 | };
|
30904 |
|
30905 | const extglobClose = token => {
|
30906 | let output = token.close + (opts.capture ? ')' : '');
|
30907 |
|
30908 | if (token.type === 'negate') {
|
30909 | let extglobStar = star;
|
30910 |
|
30911 | if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
|
30912 | extglobStar = globstar(opts);
|
30913 | }
|
30914 |
|
30915 | if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
30916 | output = token.close = `)$))${extglobStar}`;
|
30917 | }
|
30918 |
|
30919 | if (token.prev.type === 'bos' && eos()) {
|
30920 | state.negatedExtglob = true;
|
30921 | }
|
30922 | }
|
30923 |
|
30924 | push({
|
30925 | type: 'paren',
|
30926 | extglob: true,
|
30927 | value,
|
30928 | output
|
30929 | });
|
30930 | decrement('parens');
|
30931 | };
|
30932 | |
30933 |
|
30934 |
|
30935 |
|
30936 |
|
30937 | if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
30938 | let backslashes = false;
|
30939 | let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
30940 | if (first === '\\') {
|
30941 | backslashes = true;
|
30942 | return m;
|
30943 | }
|
30944 |
|
30945 | if (first === '?') {
|
30946 | if (esc) {
|
30947 | return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
30948 | }
|
30949 |
|
30950 | if (index === 0) {
|
30951 | return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
30952 | }
|
30953 |
|
30954 | return QMARK.repeat(chars.length);
|
30955 | }
|
30956 |
|
30957 | if (first === '.') {
|
30958 | return DOT_LITERAL.repeat(chars.length);
|
30959 | }
|
30960 |
|
30961 | if (first === '*') {
|
30962 | if (esc) {
|
30963 | return esc + first + (rest ? star : '');
|
30964 | }
|
30965 |
|
30966 | return star;
|
30967 | }
|
30968 |
|
30969 | return esc ? m : `\\${m}`;
|
30970 | });
|
30971 |
|
30972 | if (backslashes === true) {
|
30973 | if (opts.unescape === true) {
|
30974 | output = output.replace(/\\/g, '');
|
30975 | } else {
|
30976 | output = output.replace(/\\+/g, m => {
|
30977 | return m.length % 2 === 0 ? '\\\\' : m ? '\\' : '';
|
30978 | });
|
30979 | }
|
30980 | }
|
30981 |
|
30982 | if (output === input && opts.contains === true) {
|
30983 | state.output = input;
|
30984 | return state;
|
30985 | }
|
30986 |
|
30987 | state.output = utils$3.wrapOutput(output, state, options);
|
30988 | return state;
|
30989 | }
|
30990 | |
30991 |
|
30992 |
|
30993 |
|
30994 |
|
30995 | while (!eos()) {
|
30996 | value = advance();
|
30997 |
|
30998 | if (value === '\u0000') {
|
30999 | continue;
|
31000 | }
|
31001 | |
31002 |
|
31003 |
|
31004 |
|
31005 |
|
31006 | if (value === '\\') {
|
31007 | const next = peek();
|
31008 |
|
31009 | if (next === '/' && opts.bash !== true) {
|
31010 | continue;
|
31011 | }
|
31012 |
|
31013 | if (next === '.' || next === ';') {
|
31014 | continue;
|
31015 | }
|
31016 |
|
31017 | if (!next) {
|
31018 | value += '\\';
|
31019 | push({
|
31020 | type: 'text',
|
31021 | value
|
31022 | });
|
31023 | continue;
|
31024 | }
|
31025 |
|
31026 |
|
31027 | const match = /^\\+/.exec(remaining());
|
31028 | let slashes = 0;
|
31029 |
|
31030 | if (match && match[0].length > 2) {
|
31031 | slashes = match[0].length;
|
31032 | state.index += slashes;
|
31033 |
|
31034 | if (slashes % 2 !== 0) {
|
31035 | value += '\\';
|
31036 | }
|
31037 | }
|
31038 |
|
31039 | if (opts.unescape === true) {
|
31040 | value = advance() || '';
|
31041 | } else {
|
31042 | value += advance() || '';
|
31043 | }
|
31044 |
|
31045 | if (state.brackets === 0) {
|
31046 | push({
|
31047 | type: 'text',
|
31048 | value
|
31049 | });
|
31050 | continue;
|
31051 | }
|
31052 | }
|
31053 | |
31054 |
|
31055 |
|
31056 |
|
31057 |
|
31058 |
|
31059 | if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
|
31060 | if (opts.posix !== false && value === ':') {
|
31061 | const inner = prev.value.slice(1);
|
31062 |
|
31063 | if (inner.includes('[')) {
|
31064 | prev.posix = true;
|
31065 |
|
31066 | if (inner.includes(':')) {
|
31067 | const idx = prev.value.lastIndexOf('[');
|
31068 | const pre = prev.value.slice(0, idx);
|
31069 | const rest = prev.value.slice(idx + 2);
|
31070 | const posix = POSIX_REGEX_SOURCE$1[rest];
|
31071 |
|
31072 | if (posix) {
|
31073 | prev.value = pre + posix;
|
31074 | state.backtrack = true;
|
31075 | advance();
|
31076 |
|
31077 | if (!bos.output && tokens.indexOf(prev) === 1) {
|
31078 | bos.output = ONE_CHAR;
|
31079 | }
|
31080 |
|
31081 | continue;
|
31082 | }
|
31083 | }
|
31084 | }
|
31085 | }
|
31086 |
|
31087 | if (value === '[' && peek() !== ':' || value === '-' && peek() === ']') {
|
31088 | value = `\\${value}`;
|
31089 | }
|
31090 |
|
31091 | if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
|
31092 | value = `\\${value}`;
|
31093 | }
|
31094 |
|
31095 | if (opts.posix === true && value === '!' && prev.value === '[') {
|
31096 | value = '^';
|
31097 | }
|
31098 |
|
31099 | prev.value += value;
|
31100 | append({
|
31101 | value
|
31102 | });
|
31103 | continue;
|
31104 | }
|
31105 | |
31106 |
|
31107 |
|
31108 |
|
31109 |
|
31110 |
|
31111 | if (state.quotes === 1 && value !== '"') {
|
31112 | value = utils$3.escapeRegex(value);
|
31113 | prev.value += value;
|
31114 | append({
|
31115 | value
|
31116 | });
|
31117 | continue;
|
31118 | }
|
31119 | |
31120 |
|
31121 |
|
31122 |
|
31123 |
|
31124 | if (value === '"') {
|
31125 | state.quotes = state.quotes === 1 ? 0 : 1;
|
31126 |
|
31127 | if (opts.keepQuotes === true) {
|
31128 | push({
|
31129 | type: 'text',
|
31130 | value
|
31131 | });
|
31132 | }
|
31133 |
|
31134 | continue;
|
31135 | }
|
31136 | |
31137 |
|
31138 |
|
31139 |
|
31140 |
|
31141 | if (value === '(') {
|
31142 | increment('parens');
|
31143 | push({
|
31144 | type: 'paren',
|
31145 | value
|
31146 | });
|
31147 | continue;
|
31148 | }
|
31149 |
|
31150 | if (value === ')') {
|
31151 | if (state.parens === 0 && opts.strictBrackets === true) {
|
31152 | throw new SyntaxError(syntaxError('opening', '('));
|
31153 | }
|
31154 |
|
31155 | const extglob = extglobs[extglobs.length - 1];
|
31156 |
|
31157 | if (extglob && state.parens === extglob.parens + 1) {
|
31158 | extglobClose(extglobs.pop());
|
31159 | continue;
|
31160 | }
|
31161 |
|
31162 | push({
|
31163 | type: 'paren',
|
31164 | value,
|
31165 | output: state.parens ? ')' : '\\)'
|
31166 | });
|
31167 | decrement('parens');
|
31168 | continue;
|
31169 | }
|
31170 | |
31171 |
|
31172 |
|
31173 |
|
31174 |
|
31175 | if (value === '[') {
|
31176 | if (opts.nobracket === true || !remaining().includes(']')) {
|
31177 | if (opts.nobracket !== true && opts.strictBrackets === true) {
|
31178 | throw new SyntaxError(syntaxError('closing', ']'));
|
31179 | }
|
31180 |
|
31181 | value = `\\${value}`;
|
31182 | } else {
|
31183 | increment('brackets');
|
31184 | }
|
31185 |
|
31186 | push({
|
31187 | type: 'bracket',
|
31188 | value
|
31189 | });
|
31190 | continue;
|
31191 | }
|
31192 |
|
31193 | if (value === ']') {
|
31194 | if (opts.nobracket === true || prev && prev.type === 'bracket' && prev.value.length === 1) {
|
31195 | push({
|
31196 | type: 'text',
|
31197 | value,
|
31198 | output: `\\${value}`
|
31199 | });
|
31200 | continue;
|
31201 | }
|
31202 |
|
31203 | if (state.brackets === 0) {
|
31204 | if (opts.strictBrackets === true) {
|
31205 | throw new SyntaxError(syntaxError('opening', '['));
|
31206 | }
|
31207 |
|
31208 | push({
|
31209 | type: 'text',
|
31210 | value,
|
31211 | output: `\\${value}`
|
31212 | });
|
31213 | continue;
|
31214 | }
|
31215 |
|
31216 | decrement('brackets');
|
31217 | const prevValue = prev.value.slice(1);
|
31218 |
|
31219 | if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
|
31220 | value = `/${value}`;
|
31221 | }
|
31222 |
|
31223 | prev.value += value;
|
31224 | append({
|
31225 | value
|
31226 | });
|
31227 |
|
31228 |
|
31229 | if (opts.literalBrackets === false || utils$3.hasRegexChars(prevValue)) {
|
31230 | continue;
|
31231 | }
|
31232 |
|
31233 | const escaped = utils$3.escapeRegex(prev.value);
|
31234 | state.output = state.output.slice(0, -prev.value.length);
|
31235 |
|
31236 |
|
31237 | if (opts.literalBrackets === true) {
|
31238 | state.output += escaped;
|
31239 | prev.value = escaped;
|
31240 | continue;
|
31241 | }
|
31242 |
|
31243 |
|
31244 | prev.value = `(${capture}${escaped}|${prev.value})`;
|
31245 | state.output += prev.value;
|
31246 | continue;
|
31247 | }
|
31248 | |
31249 |
|
31250 |
|
31251 |
|
31252 |
|
31253 | if (value === '{' && opts.nobrace !== true) {
|
31254 | increment('braces');
|
31255 | const open = {
|
31256 | type: 'brace',
|
31257 | value,
|
31258 | output: '(',
|
31259 | outputIndex: state.output.length,
|
31260 | tokensIndex: state.tokens.length
|
31261 | };
|
31262 | braces.push(open);
|
31263 | push(open);
|
31264 | continue;
|
31265 | }
|
31266 |
|
31267 | if (value === '}') {
|
31268 | const brace = braces[braces.length - 1];
|
31269 |
|
31270 | if (opts.nobrace === true || !brace) {
|
31271 | push({
|
31272 | type: 'text',
|
31273 | value,
|
31274 | output: value
|
31275 | });
|
31276 | continue;
|
31277 | }
|
31278 |
|
31279 | let output = ')';
|
31280 |
|
31281 | if (brace.dots === true) {
|
31282 | const arr = tokens.slice();
|
31283 | const range = [];
|
31284 |
|
31285 | for (let i = arr.length - 1; i >= 0; i--) {
|
31286 | tokens.pop();
|
31287 |
|
31288 | if (arr[i].type === 'brace') {
|
31289 | break;
|
31290 | }
|
31291 |
|
31292 | if (arr[i].type !== 'dots') {
|
31293 | range.unshift(arr[i].value);
|
31294 | }
|
31295 | }
|
31296 |
|
31297 | output = expandRange(range, opts);
|
31298 | state.backtrack = true;
|
31299 | }
|
31300 |
|
31301 | if (brace.comma !== true && brace.dots !== true) {
|
31302 | const out = state.output.slice(0, brace.outputIndex);
|
31303 | const toks = state.tokens.slice(brace.tokensIndex);
|
31304 | brace.value = brace.output = '\\{';
|
31305 | value = output = `\\}`;
|
31306 | state.output = out;
|
31307 |
|
31308 | for (const t of toks) {
|
31309 | state.output += t.output || t.value;
|
31310 | }
|
31311 | }
|
31312 |
|
31313 | push({
|
31314 | type: 'brace',
|
31315 | value,
|
31316 | output
|
31317 | });
|
31318 | decrement('braces');
|
31319 | braces.pop();
|
31320 | continue;
|
31321 | }
|
31322 | |
31323 |
|
31324 |
|
31325 |
|
31326 |
|
31327 | if (value === '|') {
|
31328 | if (extglobs.length > 0) {
|
31329 | extglobs[extglobs.length - 1].conditions++;
|
31330 | }
|
31331 |
|
31332 | push({
|
31333 | type: 'text',
|
31334 | value
|
31335 | });
|
31336 | continue;
|
31337 | }
|
31338 | |
31339 |
|
31340 |
|
31341 |
|
31342 |
|
31343 | if (value === ',') {
|
31344 | let output = value;
|
31345 | const brace = braces[braces.length - 1];
|
31346 |
|
31347 | if (brace && stack[stack.length - 1] === 'braces') {
|
31348 | brace.comma = true;
|
31349 | output = '|';
|
31350 | }
|
31351 |
|
31352 | push({
|
31353 | type: 'comma',
|
31354 | value,
|
31355 | output
|
31356 | });
|
31357 | continue;
|
31358 | }
|
31359 | |
31360 |
|
31361 |
|
31362 |
|
31363 |
|
31364 | if (value === '/') {
|
31365 |
|
31366 |
|
31367 |
|
31368 |
|
31369 | if (prev.type === 'dot' && state.index === state.start + 1) {
|
31370 | state.start = state.index + 1;
|
31371 | state.consumed = '';
|
31372 | state.output = '';
|
31373 | tokens.pop();
|
31374 | prev = bos;
|
31375 |
|
31376 | continue;
|
31377 | }
|
31378 |
|
31379 | push({
|
31380 | type: 'slash',
|
31381 | value,
|
31382 | output: SLASH_LITERAL
|
31383 | });
|
31384 | continue;
|
31385 | }
|
31386 | |
31387 |
|
31388 |
|
31389 |
|
31390 |
|
31391 | if (value === '.') {
|
31392 | if (state.braces > 0 && prev.type === 'dot') {
|
31393 | if (prev.value === '.') prev.output = DOT_LITERAL;
|
31394 | const brace = braces[braces.length - 1];
|
31395 | prev.type = 'dots';
|
31396 | prev.output += value;
|
31397 | prev.value += value;
|
31398 | brace.dots = true;
|
31399 | continue;
|
31400 | }
|
31401 |
|
31402 | if (state.braces + state.parens === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
|
31403 | push({
|
31404 | type: 'text',
|
31405 | value,
|
31406 | output: DOT_LITERAL
|
31407 | });
|
31408 | continue;
|
31409 | }
|
31410 |
|
31411 | push({
|
31412 | type: 'dot',
|
31413 | value,
|
31414 | output: DOT_LITERAL
|
31415 | });
|
31416 | continue;
|
31417 | }
|
31418 | |
31419 |
|
31420 |
|
31421 |
|
31422 |
|
31423 | if (value === '?') {
|
31424 | const isGroup = prev && prev.value === '(';
|
31425 |
|
31426 | if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
31427 | extglobOpen('qmark', value);
|
31428 | continue;
|
31429 | }
|
31430 |
|
31431 | if (prev && prev.type === 'paren') {
|
31432 | const next = peek();
|
31433 | let output = value;
|
31434 |
|
31435 | if (next === '<' && !utils$3.supportsLookbehinds()) {
|
31436 | throw new Error('Node.js v10 or higher is required for regex lookbehinds');
|
31437 | }
|
31438 |
|
31439 | if (prev.value === '(' && !/[!=<:]/.test(next) || next === '<' && !/<([!=]|\w+>)/.test(remaining())) {
|
31440 | output = `\\${value}`;
|
31441 | }
|
31442 |
|
31443 | push({
|
31444 | type: 'text',
|
31445 | value,
|
31446 | output
|
31447 | });
|
31448 | continue;
|
31449 | }
|
31450 |
|
31451 | if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
|
31452 | push({
|
31453 | type: 'qmark',
|
31454 | value,
|
31455 | output: QMARK_NO_DOT
|
31456 | });
|
31457 | continue;
|
31458 | }
|
31459 |
|
31460 | push({
|
31461 | type: 'qmark',
|
31462 | value,
|
31463 | output: QMARK
|
31464 | });
|
31465 | continue;
|
31466 | }
|
31467 | |
31468 |
|
31469 |
|
31470 |
|
31471 |
|
31472 | if (value === '!') {
|
31473 | if (opts.noextglob !== true && peek() === '(') {
|
31474 | if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
|
31475 | extglobOpen('negate', value);
|
31476 | continue;
|
31477 | }
|
31478 | }
|
31479 |
|
31480 | if (opts.nonegate !== true && state.index === 0) {
|
31481 | negate();
|
31482 | continue;
|
31483 | }
|
31484 | }
|
31485 | |
31486 |
|
31487 |
|
31488 |
|
31489 |
|
31490 | if (value === '+') {
|
31491 | if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
31492 | extglobOpen('plus', value);
|
31493 | continue;
|
31494 | }
|
31495 |
|
31496 | if (prev && prev.value === '(' || opts.regex === false) {
|
31497 | push({
|
31498 | type: 'plus',
|
31499 | value,
|
31500 | output: PLUS_LITERAL
|
31501 | });
|
31502 | continue;
|
31503 | }
|
31504 |
|
31505 | if (prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace') || state.parens > 0) {
|
31506 | push({
|
31507 | type: 'plus',
|
31508 | value
|
31509 | });
|
31510 | continue;
|
31511 | }
|
31512 |
|
31513 | push({
|
31514 | type: 'plus',
|
31515 | value: PLUS_LITERAL
|
31516 | });
|
31517 | continue;
|
31518 | }
|
31519 | |
31520 |
|
31521 |
|
31522 |
|
31523 |
|
31524 | if (value === '@') {
|
31525 | if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
31526 | push({
|
31527 | type: 'at',
|
31528 | extglob: true,
|
31529 | value,
|
31530 | output: ''
|
31531 | });
|
31532 | continue;
|
31533 | }
|
31534 |
|
31535 | push({
|
31536 | type: 'text',
|
31537 | value
|
31538 | });
|
31539 | continue;
|
31540 | }
|
31541 | |
31542 |
|
31543 |
|
31544 |
|
31545 |
|
31546 | if (value !== '*') {
|
31547 | if (value === '$' || value === '^') {
|
31548 | value = `\\${value}`;
|
31549 | }
|
31550 |
|
31551 | const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
31552 |
|
31553 | if (match) {
|
31554 | value += match[0];
|
31555 | state.index += match[0].length;
|
31556 | }
|
31557 |
|
31558 | push({
|
31559 | type: 'text',
|
31560 | value
|
31561 | });
|
31562 | continue;
|
31563 | }
|
31564 | |
31565 |
|
31566 |
|
31567 |
|
31568 |
|
31569 | if (prev && (prev.type === 'globstar' || prev.star === true)) {
|
31570 | prev.type = 'star';
|
31571 | prev.star = true;
|
31572 | prev.value += value;
|
31573 | prev.output = star;
|
31574 | state.backtrack = true;
|
31575 | state.globstar = true;
|
31576 | consume(value);
|
31577 | continue;
|
31578 | }
|
31579 |
|
31580 | let rest = remaining();
|
31581 |
|
31582 | if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
31583 | extglobOpen('star', value);
|
31584 | continue;
|
31585 | }
|
31586 |
|
31587 | if (prev.type === 'star') {
|
31588 | if (opts.noglobstar === true) {
|
31589 | consume(value);
|
31590 | continue;
|
31591 | }
|
31592 |
|
31593 | const prior = prev.prev;
|
31594 | const before = prior.prev;
|
31595 | const isStart = prior.type === 'slash' || prior.type === 'bos';
|
31596 | const afterStar = before && (before.type === 'star' || before.type === 'globstar');
|
31597 |
|
31598 | if (opts.bash === true && (!isStart || rest[0] && rest[0] !== '/')) {
|
31599 | push({
|
31600 | type: 'star',
|
31601 | value,
|
31602 | output: ''
|
31603 | });
|
31604 | continue;
|
31605 | }
|
31606 |
|
31607 | const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
|
31608 | const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
|
31609 |
|
31610 | if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
|
31611 | push({
|
31612 | type: 'star',
|
31613 | value,
|
31614 | output: ''
|
31615 | });
|
31616 | continue;
|
31617 | }
|
31618 |
|
31619 |
|
31620 | while (rest.slice(0, 3) === '/**') {
|
31621 | const after = input[state.index + 4];
|
31622 |
|
31623 | if (after && after !== '/') {
|
31624 | break;
|
31625 | }
|
31626 |
|
31627 | rest = rest.slice(3);
|
31628 | consume('/**', 3);
|
31629 | }
|
31630 |
|
31631 | if (prior.type === 'bos' && eos()) {
|
31632 | prev.type = 'globstar';
|
31633 | prev.value += value;
|
31634 | prev.output = globstar(opts);
|
31635 | state.output = prev.output;
|
31636 | state.globstar = true;
|
31637 | consume(value);
|
31638 | continue;
|
31639 | }
|
31640 |
|
31641 | if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
|
31642 | state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
31643 | prior.output = `(?:${prior.output}`;
|
31644 | prev.type = 'globstar';
|
31645 | prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
|
31646 | prev.value += value;
|
31647 | state.globstar = true;
|
31648 | state.output += prior.output + prev.output;
|
31649 | consume(value);
|
31650 | continue;
|
31651 | }
|
31652 |
|
31653 | if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
|
31654 | const end = rest[1] !== void 0 ? '|$' : '';
|
31655 | state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
31656 | prior.output = `(?:${prior.output}`;
|
31657 | prev.type = 'globstar';
|
31658 | prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
31659 | prev.value += value;
|
31660 | state.output += prior.output + prev.output;
|
31661 | state.globstar = true;
|
31662 | consume(value + advance());
|
31663 | push({
|
31664 | type: 'slash',
|
31665 | value: '/',
|
31666 | output: ''
|
31667 | });
|
31668 | continue;
|
31669 | }
|
31670 |
|
31671 | if (prior.type === 'bos' && rest[0] === '/') {
|
31672 | prev.type = 'globstar';
|
31673 | prev.value += value;
|
31674 | prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
31675 | state.output = prev.output;
|
31676 | state.globstar = true;
|
31677 | consume(value + advance());
|
31678 | push({
|
31679 | type: 'slash',
|
31680 | value: '/',
|
31681 | output: ''
|
31682 | });
|
31683 | continue;
|
31684 | }
|
31685 |
|
31686 |
|
31687 | state.output = state.output.slice(0, -prev.output.length);
|
31688 |
|
31689 | prev.type = 'globstar';
|
31690 | prev.output = globstar(opts);
|
31691 | prev.value += value;
|
31692 |
|
31693 | state.output += prev.output;
|
31694 | state.globstar = true;
|
31695 | consume(value);
|
31696 | continue;
|
31697 | }
|
31698 |
|
31699 | const token = {
|
31700 | type: 'star',
|
31701 | value,
|
31702 | output: star
|
31703 | };
|
31704 |
|
31705 | if (opts.bash === true) {
|
31706 | token.output = '.*?';
|
31707 |
|
31708 | if (prev.type === 'bos' || prev.type === 'slash') {
|
31709 | token.output = nodot + token.output;
|
31710 | }
|
31711 |
|
31712 | push(token);
|
31713 | continue;
|
31714 | }
|
31715 |
|
31716 | if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
|
31717 | token.output = value;
|
31718 | push(token);
|
31719 | continue;
|
31720 | }
|
31721 |
|
31722 | if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
|
31723 | if (prev.type === 'dot') {
|
31724 | state.output += NO_DOT_SLASH;
|
31725 | prev.output += NO_DOT_SLASH;
|
31726 | } else if (opts.dot === true) {
|
31727 | state.output += NO_DOTS_SLASH;
|
31728 | prev.output += NO_DOTS_SLASH;
|
31729 | } else {
|
31730 | state.output += nodot;
|
31731 | prev.output += nodot;
|
31732 | }
|
31733 |
|
31734 | if (peek() !== '*') {
|
31735 | state.output += ONE_CHAR;
|
31736 | prev.output += ONE_CHAR;
|
31737 | }
|
31738 | }
|
31739 |
|
31740 | push(token);
|
31741 | }
|
31742 |
|
31743 | while (state.brackets > 0) {
|
31744 | if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
|
31745 | state.output = utils$3.escapeLast(state.output, '[');
|
31746 | decrement('brackets');
|
31747 | }
|
31748 |
|
31749 | while (state.parens > 0) {
|
31750 | if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
|
31751 | state.output = utils$3.escapeLast(state.output, '(');
|
31752 | decrement('parens');
|
31753 | }
|
31754 |
|
31755 | while (state.braces > 0) {
|
31756 | if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
|
31757 | state.output = utils$3.escapeLast(state.output, '{');
|
31758 | decrement('braces');
|
31759 | }
|
31760 |
|
31761 | if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
|
31762 | push({
|
31763 | type: 'maybe_slash',
|
31764 | value: '',
|
31765 | output: `${SLASH_LITERAL}?`
|
31766 | });
|
31767 | }
|
31768 |
|
31769 |
|
31770 | if (state.backtrack === true) {
|
31771 | state.output = '';
|
31772 |
|
31773 | for (const token of state.tokens) {
|
31774 | state.output += token.output != null ? token.output : token.value;
|
31775 |
|
31776 | if (token.suffix) {
|
31777 | state.output += token.suffix;
|
31778 | }
|
31779 | }
|
31780 | }
|
31781 |
|
31782 | return state;
|
31783 | };
|
31784 |
|
31785 |
|
31786 |
|
31787 |
|
31788 |
|
31789 |
|
31790 |
|
31791 | parse$4.fastpaths = (input, options) => {
|
31792 | const opts = Object.assign({}, options);
|
31793 | const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$3, opts.maxLength) : MAX_LENGTH$3;
|
31794 | const len = input.length;
|
31795 |
|
31796 | if (len > max) {
|
31797 | throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
31798 | }
|
31799 |
|
31800 | input = REPLACEMENTS[input] || input;
|
31801 | const win32 = utils$3.isWindows(options);
|
31802 |
|
31803 | const {
|
31804 | DOT_LITERAL,
|
31805 | SLASH_LITERAL,
|
31806 | ONE_CHAR,
|
31807 | DOTS_SLASH,
|
31808 | NO_DOT,
|
31809 | NO_DOTS,
|
31810 | NO_DOTS_SLASH,
|
31811 | STAR,
|
31812 | START_ANCHOR
|
31813 | } = constants$3.globChars(win32);
|
31814 | const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
31815 | const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
31816 | const capture = opts.capture ? '' : '?:';
|
31817 | const state = {
|
31818 | negated: false,
|
31819 | prefix: ''
|
31820 | };
|
31821 | let star = opts.bash === true ? '.*?' : STAR;
|
31822 |
|
31823 | if (opts.capture) {
|
31824 | star = `(${star})`;
|
31825 | }
|
31826 |
|
31827 | const globstar = opts => {
|
31828 | if (opts.noglobstar === true) return star;
|
31829 | return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
31830 | };
|
31831 |
|
31832 | const create = str => {
|
31833 | switch (str) {
|
31834 | case '*':
|
31835 | return `${nodot}${ONE_CHAR}${star}`;
|
31836 |
|
31837 | case '.*':
|
31838 | return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
31839 |
|
31840 | case '*.*':
|
31841 | return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
31842 |
|
31843 | case '*/*':
|
31844 | return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
31845 |
|
31846 | case '**':
|
31847 | return nodot + globstar(opts);
|
31848 |
|
31849 | case '**/*':
|
31850 | return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
31851 |
|
31852 | case '**/*.*':
|
31853 | return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
31854 |
|
31855 | case '**/.*':
|
31856 | return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
31857 |
|
31858 | default:
|
31859 | {
|
31860 | const match = /^(.*?)\.(\w+)$/.exec(str);
|
31861 | if (!match) return;
|
31862 | const source = create(match[1]);
|
31863 | if (!source) return;
|
31864 | return source + DOT_LITERAL + match[2];
|
31865 | }
|
31866 | }
|
31867 | };
|
31868 |
|
31869 | const output = utils$3.removePrefix(input, state);
|
31870 | let source = create(output);
|
31871 |
|
31872 | if (source && opts.strictSlashes !== true) {
|
31873 | source += `${SLASH_LITERAL}?`;
|
31874 | }
|
31875 |
|
31876 | return source;
|
31877 | };
|
31878 |
|
31879 | var parse_1$1 = parse$4;
|
31880 |
|
31881 | const isObject$2 = val => val && typeof val === 'object' && !Array.isArray(val);
|
31882 |
|
31883 |
|
31884 |
|
31885 |
|
31886 |
|
31887 |
|
31888 |
|
31889 |
|
31890 |
|
31891 |
|
31892 |
|
31893 |
|
31894 |
|
31895 |
|
31896 |
|
31897 |
|
31898 |
|
31899 |
|
31900 |
|
31901 |
|
31902 |
|
31903 |
|
31904 |
|
31905 | const picomatch = (glob, options, returnState = false) => {
|
31906 | if (Array.isArray(glob)) {
|
31907 | const fns = glob.map(input => picomatch(input, options, returnState));
|
31908 |
|
31909 | const arrayMatcher = str => {
|
31910 | for (const isMatch of fns) {
|
31911 | const state = isMatch(str);
|
31912 | if (state) return state;
|
31913 | }
|
31914 |
|
31915 | return false;
|
31916 | };
|
31917 |
|
31918 | return arrayMatcher;
|
31919 | }
|
31920 |
|
31921 | const isState = isObject$2(glob) && glob.tokens && glob.input;
|
31922 |
|
31923 | if (glob === '' || typeof glob !== 'string' && !isState) {
|
31924 | throw new TypeError('Expected pattern to be a non-empty string');
|
31925 | }
|
31926 |
|
31927 | const opts = options || {};
|
31928 | const posix = utils$3.isWindows(options);
|
31929 | const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
31930 | const state = regex.state;
|
31931 | delete regex.state;
|
31932 |
|
31933 | let isIgnored = () => false;
|
31934 |
|
31935 | if (opts.ignore) {
|
31936 | const ignoreOpts = Object.assign({}, options, {
|
31937 | ignore: null,
|
31938 | onMatch: null,
|
31939 | onResult: null
|
31940 | });
|
31941 | isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
31942 | }
|
31943 |
|
31944 | const matcher = (input, returnObject = false) => {
|
31945 | const {
|
31946 | isMatch,
|
31947 | match,
|
31948 | output
|
31949 | } = picomatch.test(input, regex, options, {
|
31950 | glob,
|
31951 | posix
|
31952 | });
|
31953 | const result = {
|
31954 | glob,
|
31955 | state,
|
31956 | regex,
|
31957 | posix,
|
31958 | input,
|
31959 | output,
|
31960 | match,
|
31961 | isMatch
|
31962 | };
|
31963 |
|
31964 | if (typeof opts.onResult === 'function') {
|
31965 | opts.onResult(result);
|
31966 | }
|
31967 |
|
31968 | if (isMatch === false) {
|
31969 | result.isMatch = false;
|
31970 | return returnObject ? result : false;
|
31971 | }
|
31972 |
|
31973 | if (isIgnored(input)) {
|
31974 | if (typeof opts.onIgnore === 'function') {
|
31975 | opts.onIgnore(result);
|
31976 | }
|
31977 |
|
31978 | result.isMatch = false;
|
31979 | return returnObject ? result : false;
|
31980 | }
|
31981 |
|
31982 | if (typeof opts.onMatch === 'function') {
|
31983 | opts.onMatch(result);
|
31984 | }
|
31985 |
|
31986 | return returnObject ? result : true;
|
31987 | };
|
31988 |
|
31989 | if (returnState) {
|
31990 | matcher.state = state;
|
31991 | }
|
31992 |
|
31993 | return matcher;
|
31994 | };
|
31995 |
|
31996 |
|
31997 |
|
31998 |
|
31999 |
|
32000 |
|
32001 |
|
32002 |
|
32003 |
|
32004 |
|
32005 |
|
32006 |
|
32007 |
|
32008 |
|
32009 |
|
32010 |
|
32011 |
|
32012 |
|
32013 | picomatch.test = (input, regex, options, {
|
32014 | glob,
|
32015 | posix
|
32016 | } = {}) => {
|
32017 | if (typeof input !== 'string') {
|
32018 | throw new TypeError('Expected input to be a string');
|
32019 | }
|
32020 |
|
32021 | if (input === '') {
|
32022 | return {
|
32023 | isMatch: false,
|
32024 | output: ''
|
32025 | };
|
32026 | }
|
32027 |
|
32028 | const opts = options || {};
|
32029 | const format = opts.format || (posix ? utils$3.toPosixSlashes : null);
|
32030 | let match = input === glob;
|
32031 | let output = match && format ? format(input) : input;
|
32032 |
|
32033 | if (match === false) {
|
32034 | output = format ? format(input) : input;
|
32035 | match = output === glob;
|
32036 | }
|
32037 |
|
32038 | if (match === false || opts.capture === true) {
|
32039 | if (opts.matchBase === true || opts.basename === true) {
|
32040 | match = picomatch.matchBase(input, regex, options, posix);
|
32041 | } else {
|
32042 | match = regex.exec(output);
|
32043 | }
|
32044 | }
|
32045 |
|
32046 | return {
|
32047 | isMatch: Boolean(match),
|
32048 | match,
|
32049 | output
|
32050 | };
|
32051 | };
|
32052 |
|
32053 |
|
32054 |
|
32055 |
|
32056 |
|
32057 |
|
32058 |
|
32059 |
|
32060 |
|
32061 |
|
32062 |
|
32063 |
|
32064 |
|
32065 |
|
32066 |
|
32067 | picomatch.matchBase = (input, glob, options, posix = utils$3.isWindows(options)) => {
|
32068 | const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
32069 | return regex.test(path$2.basename(input));
|
32070 | };
|
32071 |
|
32072 |
|
32073 |
|
32074 |
|
32075 |
|
32076 |
|
32077 |
|
32078 |
|
32079 |
|
32080 |
|
32081 |
|
32082 |
|
32083 |
|
32084 |
|
32085 |
|
32086 |
|
32087 |
|
32088 |
|
32089 | picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
32090 |
|
32091 |
|
32092 |
|
32093 |
|
32094 |
|
32095 |
|
32096 |
|
32097 |
|
32098 |
|
32099 |
|
32100 |
|
32101 |
|
32102 |
|
32103 |
|
32104 |
|
32105 | picomatch.parse = (pattern, options) => {
|
32106 | if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
|
32107 | return parse_1$1(pattern, Object.assign({}, options, {
|
32108 | fastpaths: false
|
32109 | }));
|
32110 | };
|
32111 |
|
32112 |
|
32113 |
|
32114 |
|
32115 |
|
32116 |
|
32117 |
|
32118 |
|
32119 |
|
32120 |
|
32121 |
|
32122 |
|
32123 |
|
32124 |
|
32125 |
|
32126 |
|
32127 |
|
32128 |
|
32129 |
|
32130 |
|
32131 |
|
32132 |
|
32133 |
|
32134 |
|
32135 |
|
32136 |
|
32137 |
|
32138 |
|
32139 | picomatch.scan = (input, options) => scan_1(input, options);
|
32140 |
|
32141 |
|
32142 |
|
32143 |
|
32144 |
|
32145 |
|
32146 |
|
32147 |
|
32148 |
|
32149 |
|
32150 |
|
32151 |
|
32152 |
|
32153 |
|
32154 |
|
32155 |
|
32156 |
|
32157 | picomatch.compileRe = (parsed, options, returnOutput = false, returnState = false) => {
|
32158 | if (returnOutput === true) {
|
32159 | return parsed.output;
|
32160 | }
|
32161 |
|
32162 | const opts = options || {};
|
32163 | const prepend = opts.contains ? '' : '^';
|
32164 | const append = opts.contains ? '' : '$';
|
32165 | let source = `${prepend}(?:${parsed.output})${append}`;
|
32166 |
|
32167 | if (parsed && parsed.negated === true) {
|
32168 | source = `^(?!${source}).*$`;
|
32169 | }
|
32170 |
|
32171 | const regex = picomatch.toRegex(source, options);
|
32172 |
|
32173 | if (returnState === true) {
|
32174 | regex.state = parsed;
|
32175 | }
|
32176 |
|
32177 | return regex;
|
32178 | };
|
32179 |
|
32180 | picomatch.makeRe = (input, options, returnOutput = false, returnState = false) => {
|
32181 | if (!input || typeof input !== 'string') {
|
32182 | throw new TypeError('Expected a non-empty string');
|
32183 | }
|
32184 |
|
32185 | const opts = options || {};
|
32186 | let parsed = {
|
32187 | negated: false,
|
32188 | fastpaths: true
|
32189 | };
|
32190 | let prefix = '';
|
32191 | let output;
|
32192 |
|
32193 | if (input.startsWith('./')) {
|
32194 | input = input.slice(2);
|
32195 | prefix = parsed.prefix = './';
|
32196 | }
|
32197 |
|
32198 | if (opts.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
|
32199 | output = parse_1$1.fastpaths(input, options);
|
32200 | }
|
32201 |
|
32202 | if (output === undefined) {
|
32203 | parsed = parse_1$1(input, options);
|
32204 | parsed.prefix = prefix + (parsed.prefix || '');
|
32205 | } else {
|
32206 | parsed.output = output;
|
32207 | }
|
32208 |
|
32209 | return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
32210 | };
|
32211 |
|
32212 |
|
32213 |
|
32214 |
|
32215 |
|
32216 |
|
32217 |
|
32218 |
|
32219 |
|
32220 |
|
32221 |
|
32222 |
|
32223 |
|
32224 |
|
32225 |
|
32226 |
|
32227 |
|
32228 |
|
32229 | picomatch.toRegex = (source, options) => {
|
32230 | try {
|
32231 | const opts = options || {};
|
32232 | return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
32233 | } catch (err) {
|
32234 | if (options && options.debug === true) throw err;
|
32235 | return /$^/;
|
32236 | }
|
32237 | };
|
32238 |
|
32239 |
|
32240 |
|
32241 |
|
32242 |
|
32243 |
|
32244 | picomatch.constants = constants$3;
|
32245 |
|
32246 |
|
32247 |
|
32248 |
|
32249 | var picomatch_1 = picomatch;
|
32250 |
|
32251 | var picomatch$1 = picomatch_1;
|
32252 |
|
32253 | const isEmptyString = val => typeof val === 'string' && (val === '' || val === './');
|
32254 |
|
32255 |
|
32256 |
|
32257 |
|
32258 |
|
32259 |
|
32260 |
|
32261 |
|
32262 |
|
32263 |
|
32264 |
|
32265 |
|
32266 |
|
32267 |
|
32268 |
|
32269 |
|
32270 |
|
32271 |
|
32272 |
|
32273 | const micromatch = (list, patterns, options) => {
|
32274 | patterns = [].concat(patterns);
|
32275 | list = [].concat(list);
|
32276 | let omit = new Set();
|
32277 | let keep = new Set();
|
32278 | let items = new Set();
|
32279 | let negatives = 0;
|
32280 |
|
32281 | let onResult = state => {
|
32282 | items.add(state.output);
|
32283 |
|
32284 | if (options && options.onResult) {
|
32285 | options.onResult(state);
|
32286 | }
|
32287 | };
|
32288 |
|
32289 | for (let i = 0; i < patterns.length; i++) {
|
32290 | let isMatch = picomatch$1(String(patterns[i]), Object.assign({}, options, {
|
32291 | onResult
|
32292 | }), true);
|
32293 | let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
|
32294 | if (negated) negatives++;
|
32295 |
|
32296 | for (let item of list) {
|
32297 | let matched = isMatch(item, true);
|
32298 | let match = negated ? !matched.isMatch : matched.isMatch;
|
32299 | if (!match) continue;
|
32300 |
|
32301 | if (negated) {
|
32302 | omit.add(matched.output);
|
32303 | } else {
|
32304 | omit.delete(matched.output);
|
32305 | keep.add(matched.output);
|
32306 | }
|
32307 | }
|
32308 | }
|
32309 |
|
32310 | let result = negatives === patterns.length ? [...items] : [...keep];
|
32311 | let matches = result.filter(item => !omit.has(item));
|
32312 |
|
32313 | if (options && matches.length === 0) {
|
32314 | if (options.failglob === true) {
|
32315 | throw new Error(`No matches found for "${patterns.join(', ')}"`);
|
32316 | }
|
32317 |
|
32318 | if (options.nonull === true || options.nullglob === true) {
|
32319 | return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns;
|
32320 | }
|
32321 | }
|
32322 |
|
32323 | return matches;
|
32324 | };
|
32325 |
|
32326 |
|
32327 |
|
32328 |
|
32329 |
|
32330 | micromatch.match = micromatch;
|
32331 |
|
32332 |
|
32333 |
|
32334 |
|
32335 |
|
32336 |
|
32337 |
|
32338 |
|
32339 |
|
32340 |
|
32341 |
|
32342 |
|
32343 |
|
32344 |
|
32345 |
|
32346 |
|
32347 |
|
32348 |
|
32349 |
|
32350 | micromatch.matcher = (pattern, options) => picomatch$1(pattern, options);
|
32351 |
|
32352 |
|
32353 |
|
32354 |
|
32355 |
|
32356 |
|
32357 |
|
32358 |
|
32359 |
|
32360 |
|
32361 |
|
32362 |
|
32363 |
|
32364 |
|
32365 |
|
32366 |
|
32367 |
|
32368 |
|
32369 | micromatch.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
|
32370 |
|
32371 |
|
32372 |
|
32373 |
|
32374 |
|
32375 | micromatch.any = micromatch.isMatch;
|
32376 |
|
32377 |
|
32378 |
|
32379 |
|
32380 |
|
32381 |
|
32382 |
|
32383 |
|
32384 |
|
32385 |
|
32386 |
|
32387 |
|
32388 |
|
32389 |
|
32390 |
|
32391 |
|
32392 |
|
32393 | micromatch.not = (list, patterns, options = {}) => {
|
32394 | patterns = [].concat(patterns).map(String);
|
32395 | let result = new Set();
|
32396 | let items = [];
|
32397 |
|
32398 | let onResult = state => {
|
32399 | if (options.onResult) options.onResult(state);
|
32400 | items.push(state.output);
|
32401 | };
|
32402 |
|
32403 | let matches = micromatch(list, patterns, Object.assign({}, options, {
|
32404 | onResult
|
32405 | }));
|
32406 |
|
32407 | for (let item of items) {
|
32408 | if (!matches.includes(item)) {
|
32409 | result.add(item);
|
32410 | }
|
32411 | }
|
32412 |
|
32413 | return [...result];
|
32414 | };
|
32415 |
|
32416 |
|
32417 |
|
32418 |
|
32419 |
|
32420 |
|
32421 |
|
32422 |
|
32423 |
|
32424 |
|
32425 |
|
32426 |
|
32427 |
|
32428 |
|
32429 |
|
32430 |
|
32431 |
|
32432 |
|
32433 |
|
32434 |
|
32435 |
|
32436 | micromatch.contains = (str, pattern, options) => {
|
32437 | if (typeof str !== 'string') {
|
32438 | throw new TypeError(`Expected a string: "${util$4.inspect(str)}"`);
|
32439 | }
|
32440 |
|
32441 | if (Array.isArray(pattern)) {
|
32442 | return pattern.some(p => micromatch.contains(str, p, options));
|
32443 | }
|
32444 |
|
32445 | if (typeof pattern === 'string') {
|
32446 | if (isEmptyString(str) || isEmptyString(pattern)) {
|
32447 | return false;
|
32448 | }
|
32449 |
|
32450 | if (str.includes(pattern) || str.startsWith('./') && str.slice(2).includes(pattern)) {
|
32451 | return true;
|
32452 | }
|
32453 | }
|
32454 |
|
32455 | return micromatch.isMatch(str, pattern, Object.assign({}, options, {
|
32456 | contains: true
|
32457 | }));
|
32458 | };
|
32459 |
|
32460 |
|
32461 |
|
32462 |
|
32463 |
|
32464 |
|
32465 |
|
32466 |
|
32467 |
|
32468 |
|
32469 |
|
32470 |
|
32471 |
|
32472 |
|
32473 |
|
32474 |
|
32475 |
|
32476 |
|
32477 |
|
32478 |
|
32479 |
|
32480 | micromatch.matchKeys = (obj, patterns, options) => {
|
32481 | if (!utils$3.isObject(obj)) {
|
32482 | throw new TypeError('Expected the first argument to be an object');
|
32483 | }
|
32484 |
|
32485 | let keys = micromatch(Object.keys(obj), patterns, options);
|
32486 | let res = {};
|
32487 |
|
32488 | for (let key of keys) res[key] = obj[key];
|
32489 |
|
32490 | return res;
|
32491 | };
|
32492 |
|
32493 |
|
32494 |
|
32495 |
|
32496 |
|
32497 |
|
32498 |
|
32499 |
|
32500 |
|
32501 |
|
32502 |
|
32503 |
|
32504 |
|
32505 |
|
32506 |
|
32507 |
|
32508 |
|
32509 |
|
32510 |
|
32511 |
|
32512 | micromatch.some = (list, patterns, options) => {
|
32513 | let items = [].concat(list);
|
32514 |
|
32515 | for (let pattern of [].concat(patterns)) {
|
32516 | let isMatch = picomatch$1(String(pattern), options);
|
32517 |
|
32518 | if (items.some(item => isMatch(item))) {
|
32519 | return true;
|
32520 | }
|
32521 | }
|
32522 |
|
32523 | return false;
|
32524 | };
|
32525 |
|
32526 |
|
32527 |
|
32528 |
|
32529 |
|
32530 |
|
32531 |
|
32532 |
|
32533 |
|
32534 |
|
32535 |
|
32536 |
|
32537 |
|
32538 |
|
32539 |
|
32540 |
|
32541 |
|
32542 |
|
32543 |
|
32544 |
|
32545 |
|
32546 |
|
32547 |
|
32548 |
|
32549 |
|
32550 | micromatch.every = (list, patterns, options) => {
|
32551 | let items = [].concat(list);
|
32552 |
|
32553 | for (let pattern of [].concat(patterns)) {
|
32554 | let isMatch = picomatch$1(String(pattern), options);
|
32555 |
|
32556 | if (!items.every(item => isMatch(item))) {
|
32557 | return false;
|
32558 | }
|
32559 | }
|
32560 |
|
32561 | return true;
|
32562 | };
|
32563 |
|
32564 |
|
32565 |
|
32566 |
|
32567 |
|
32568 |
|
32569 |
|
32570 |
|
32571 |
|
32572 |
|
32573 |
|
32574 |
|
32575 |
|
32576 |
|
32577 |
|
32578 |
|
32579 |
|
32580 |
|
32581 |
|
32582 |
|
32583 |
|
32584 |
|
32585 |
|
32586 |
|
32587 |
|
32588 |
|
32589 |
|
32590 |
|
32591 | micromatch.all = (str, patterns, options) => {
|
32592 | if (typeof str !== 'string') {
|
32593 | throw new TypeError(`Expected a string: "${util$4.inspect(str)}"`);
|
32594 | }
|
32595 |
|
32596 | return [].concat(patterns).every(p => picomatch$1(p, options)(str));
|
32597 | };
|
32598 |
|
32599 |
|
32600 |
|
32601 |
|
32602 |
|
32603 |
|
32604 |
|
32605 |
|
32606 |
|
32607 |
|
32608 |
|
32609 |
|
32610 |
|
32611 |
|
32612 |
|
32613 |
|
32614 |
|
32615 |
|
32616 |
|
32617 |
|
32618 | micromatch.capture = (glob, input, options) => {
|
32619 | let posix = utils$3.isWindows(options);
|
32620 | let regex = picomatch$1.makeRe(String(glob), Object.assign({}, options, {
|
32621 | capture: true
|
32622 | }));
|
32623 | let match = regex.exec(posix ? utils$3.toPosixSlashes(input) : input);
|
32624 |
|
32625 | if (match) {
|
32626 | return match.slice(1).map(v => v === void 0 ? '' : v);
|
32627 | }
|
32628 | };
|
32629 |
|
32630 |
|
32631 |
|
32632 |
|
32633 |
|
32634 |
|
32635 |
|
32636 |
|
32637 |
|
32638 |
|
32639 |
|
32640 |
|
32641 |
|
32642 |
|
32643 |
|
32644 |
|
32645 |
|
32646 | micromatch.makeRe = (...args) => picomatch$1.makeRe(...args);
|
32647 |
|
32648 |
|
32649 |
|
32650 |
|
32651 |
|
32652 |
|
32653 |
|
32654 |
|
32655 |
|
32656 |
|
32657 |
|
32658 |
|
32659 |
|
32660 |
|
32661 |
|
32662 | micromatch.scan = (...args) => picomatch$1.scan(...args);
|
32663 |
|
32664 |
|
32665 |
|
32666 |
|
32667 |
|
32668 |
|
32669 |
|
32670 |
|
32671 |
|
32672 |
|
32673 |
|
32674 |
|
32675 |
|
32676 |
|
32677 |
|
32678 | micromatch.parse = (patterns, options) => {
|
32679 | let res = [];
|
32680 |
|
32681 | for (let pattern of [].concat(patterns || [])) {
|
32682 | for (let str of braces_1(String(pattern), options)) {
|
32683 | res.push(picomatch$1.parse(str, options));
|
32684 | }
|
32685 | }
|
32686 |
|
32687 | return res;
|
32688 | };
|
32689 |
|
32690 |
|
32691 |
|
32692 |
|
32693 |
|
32694 |
|
32695 |
|
32696 |
|
32697 |
|
32698 |
|
32699 |
|
32700 |
|
32701 |
|
32702 |
|
32703 |
|
32704 |
|
32705 |
|
32706 |
|
32707 | micromatch.braces = (pattern, options) => {
|
32708 | if (typeof pattern !== 'string') throw new TypeError('Expected a string');
|
32709 |
|
32710 | if (options && options.nobrace === true || !/\{.*\}/.test(pattern)) {
|
32711 | return [pattern];
|
32712 | }
|
32713 |
|
32714 | return braces_1(pattern, options);
|
32715 | };
|
32716 |
|
32717 |
|
32718 |
|
32719 |
|
32720 |
|
32721 | micromatch.braceExpand = (pattern, options) => {
|
32722 | if (typeof pattern !== 'string') throw new TypeError('Expected a string');
|
32723 | return micromatch.braces(pattern, Object.assign({}, options, {
|
32724 | expand: true
|
32725 | }));
|
32726 | };
|
32727 |
|
32728 |
|
32729 |
|
32730 |
|
32731 |
|
32732 | var micromatch_1 = micromatch;
|
32733 |
|
32734 | var pattern = createCommonjsModule(function (module, exports) {
|
32735 |
|
32736 | Object.defineProperty(exports, "__esModule", {
|
32737 | value: true
|
32738 | });
|
32739 | const GLOBSTAR = '**';
|
32740 | const ESCAPE_SYMBOL = '\\';
|
32741 | const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
|
32742 | const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[.*]/;
|
32743 | const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\(.*\|.*\)/;
|
32744 | const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\(.*\)/;
|
32745 | const BRACE_EXPANSIONS_SYMBOLS_RE = /{.*(?:,|\.\.).*}/;
|
32746 |
|
32747 | function isStaticPattern(pattern, options = {}) {
|
32748 | return !isDynamicPattern(pattern, options);
|
32749 | }
|
32750 |
|
32751 | exports.isStaticPattern = isStaticPattern;
|
32752 |
|
32753 | function isDynamicPattern(pattern, options = {}) {
|
32754 | |
32755 |
|
32756 |
|
32757 |
|
32758 | if (options.caseSensitiveMatch === false || pattern.includes(ESCAPE_SYMBOL)) {
|
32759 | return true;
|
32760 | }
|
32761 |
|
32762 | if (COMMON_GLOB_SYMBOLS_RE.test(pattern) || REGEX_CHARACTER_CLASS_SYMBOLS_RE.test(pattern) || REGEX_GROUP_SYMBOLS_RE.test(pattern)) {
|
32763 | return true;
|
32764 | }
|
32765 |
|
32766 | if (options.extglob !== false && GLOB_EXTENSION_SYMBOLS_RE.test(pattern)) {
|
32767 | return true;
|
32768 | }
|
32769 |
|
32770 | if (options.braceExpansion !== false && BRACE_EXPANSIONS_SYMBOLS_RE.test(pattern)) {
|
32771 | return true;
|
32772 | }
|
32773 |
|
32774 | return false;
|
32775 | }
|
32776 |
|
32777 | exports.isDynamicPattern = isDynamicPattern;
|
32778 |
|
32779 | function convertToPositivePattern(pattern) {
|
32780 | return isNegativePattern(pattern) ? pattern.slice(1) : pattern;
|
32781 | }
|
32782 |
|
32783 | exports.convertToPositivePattern = convertToPositivePattern;
|
32784 |
|
32785 | function convertToNegativePattern(pattern) {
|
32786 | return '!' + pattern;
|
32787 | }
|
32788 |
|
32789 | exports.convertToNegativePattern = convertToNegativePattern;
|
32790 |
|
32791 | function isNegativePattern(pattern) {
|
32792 | return pattern.startsWith('!') && pattern[1] !== '(';
|
32793 | }
|
32794 |
|
32795 | exports.isNegativePattern = isNegativePattern;
|
32796 |
|
32797 | function isPositivePattern(pattern) {
|
32798 | return !isNegativePattern(pattern);
|
32799 | }
|
32800 |
|
32801 | exports.isPositivePattern = isPositivePattern;
|
32802 |
|
32803 | function getNegativePatterns(patterns) {
|
32804 | return patterns.filter(isNegativePattern);
|
32805 | }
|
32806 |
|
32807 | exports.getNegativePatterns = getNegativePatterns;
|
32808 |
|
32809 | function getPositivePatterns(patterns) {
|
32810 | return patterns.filter(isPositivePattern);
|
32811 | }
|
32812 |
|
32813 | exports.getPositivePatterns = getPositivePatterns;
|
32814 |
|
32815 | function getBaseDirectory(pattern) {
|
32816 | return globParent(pattern, {
|
32817 | flipBackslashes: false
|
32818 | });
|
32819 | }
|
32820 |
|
32821 | exports.getBaseDirectory = getBaseDirectory;
|
32822 |
|
32823 | function hasGlobStar(pattern) {
|
32824 | return pattern.includes(GLOBSTAR);
|
32825 | }
|
32826 |
|
32827 | exports.hasGlobStar = hasGlobStar;
|
32828 |
|
32829 | function endsWithSlashGlobStar(pattern) {
|
32830 | return pattern.endsWith('/' + GLOBSTAR);
|
32831 | }
|
32832 |
|
32833 | exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
|
32834 |
|
32835 | function isAffectDepthOfReadingPattern(pattern) {
|
32836 | const basename = path$2.basename(pattern);
|
32837 | return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
|
32838 | }
|
32839 |
|
32840 | exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
|
32841 |
|
32842 | function expandPatternsWithBraceExpansion(patterns) {
|
32843 | return patterns.reduce((collection, pattern) => {
|
32844 | return collection.concat(expandBraceExpansion(pattern));
|
32845 | }, []);
|
32846 | }
|
32847 |
|
32848 | exports.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
|
32849 |
|
32850 | function expandBraceExpansion(pattern) {
|
32851 | return micromatch_1.braces(pattern, {
|
32852 | expand: true,
|
32853 | nodupes: true
|
32854 | });
|
32855 | }
|
32856 |
|
32857 | exports.expandBraceExpansion = expandBraceExpansion;
|
32858 |
|
32859 | function getPatternParts(pattern, options) {
|
32860 | const info = picomatch$1.scan(pattern, Object.assign(Object.assign({}, options), {
|
32861 | parts: true
|
32862 | }));
|
32863 |
|
32864 | if (info.parts.length === 0) {
|
32865 | return [pattern];
|
32866 | }
|
32867 |
|
32868 | return info.parts;
|
32869 | }
|
32870 |
|
32871 | exports.getPatternParts = getPatternParts;
|
32872 |
|
32873 | function makeRe(pattern, options) {
|
32874 | return micromatch_1.makeRe(pattern, options);
|
32875 | }
|
32876 |
|
32877 | exports.makeRe = makeRe;
|
32878 |
|
32879 | function convertPatternsToRe(patterns, options) {
|
32880 | return patterns.map(pattern => makeRe(pattern, options));
|
32881 | }
|
32882 |
|
32883 | exports.convertPatternsToRe = convertPatternsToRe;
|
32884 |
|
32885 | function matchAny(entry, patternsRe) {
|
32886 | return patternsRe.some(patternRe => patternRe.test(entry));
|
32887 | }
|
32888 |
|
32889 | exports.matchAny = matchAny;
|
32890 | });
|
32891 | unwrapExports(pattern);
|
32892 | var pattern_1 = pattern.isStaticPattern;
|
32893 | var pattern_2 = pattern.isDynamicPattern;
|
32894 | var pattern_3 = pattern.convertToPositivePattern;
|
32895 | var pattern_4 = pattern.convertToNegativePattern;
|
32896 | var pattern_5 = pattern.isNegativePattern;
|
32897 | var pattern_6 = pattern.isPositivePattern;
|
32898 | var pattern_7 = pattern.getNegativePatterns;
|
32899 | var pattern_8 = pattern.getPositivePatterns;
|
32900 | var pattern_9 = pattern.getBaseDirectory;
|
32901 | var pattern_10 = pattern.hasGlobStar;
|
32902 | var pattern_11 = pattern.endsWithSlashGlobStar;
|
32903 | var pattern_12 = pattern.isAffectDepthOfReadingPattern;
|
32904 | var pattern_13 = pattern.expandPatternsWithBraceExpansion;
|
32905 | var pattern_14 = pattern.expandBraceExpansion;
|
32906 | var pattern_15 = pattern.getPatternParts;
|
32907 | var pattern_16 = pattern.makeRe;
|
32908 | var pattern_17 = pattern.convertPatternsToRe;
|
32909 | var pattern_18 = pattern.matchAny;
|
32910 |
|
32911 | var stream$1 = createCommonjsModule(function (module, exports) {
|
32912 |
|
32913 | Object.defineProperty(exports, "__esModule", {
|
32914 | value: true
|
32915 | });
|
32916 |
|
32917 | function merge(streams) {
|
32918 | const mergedStream = merge2_1(streams);
|
32919 | streams.forEach(stream => {
|
32920 | stream.once('error', error => mergedStream.emit('error', error));
|
32921 | });
|
32922 | mergedStream.once('close', () => propagateCloseEventToSources(streams));
|
32923 | mergedStream.once('end', () => propagateCloseEventToSources(streams));
|
32924 | return mergedStream;
|
32925 | }
|
32926 |
|
32927 | exports.merge = merge;
|
32928 |
|
32929 | function propagateCloseEventToSources(streams) {
|
32930 | streams.forEach(stream => stream.emit('close'));
|
32931 | }
|
32932 | });
|
32933 | unwrapExports(stream$1);
|
32934 | var stream_1 = stream$1.merge;
|
32935 |
|
32936 | var string$1 = createCommonjsModule(function (module, exports) {
|
32937 |
|
32938 | Object.defineProperty(exports, "__esModule", {
|
32939 | value: true
|
32940 | });
|
32941 |
|
32942 | function isString(input) {
|
32943 | return typeof input === 'string';
|
32944 | }
|
32945 |
|
32946 | exports.isString = isString;
|
32947 |
|
32948 | function isEmpty(input) {
|
32949 | return input === '';
|
32950 | }
|
32951 |
|
32952 | exports.isEmpty = isEmpty;
|
32953 | });
|
32954 | unwrapExports(string$1);
|
32955 | var string_1$1 = string$1.isString;
|
32956 | var string_2 = string$1.isEmpty;
|
32957 |
|
32958 | var utils$4 = createCommonjsModule(function (module, exports) {
|
32959 |
|
32960 | Object.defineProperty(exports, "__esModule", {
|
32961 | value: true
|
32962 | });
|
32963 | exports.array = array$2;
|
32964 | exports.errno = errno;
|
32965 | exports.fs = fs$1;
|
32966 | exports.path = path_1;
|
32967 | exports.pattern = pattern;
|
32968 | exports.stream = stream$1;
|
32969 | exports.string = string$1;
|
32970 | });
|
32971 | unwrapExports(utils$4);
|
32972 | var utils_1$4 = utils$4.array;
|
32973 | var utils_2$4 = utils$4.errno;
|
32974 | var utils_3$4 = utils$4.fs;
|
32975 | var utils_4$3 = utils$4.path;
|
32976 | var utils_5$3 = utils$4.pattern;
|
32977 | var utils_6$3 = utils$4.stream;
|
32978 | var utils_7$3 = utils$4.string;
|
32979 |
|
32980 | var tasks = createCommonjsModule(function (module, exports) {
|
32981 |
|
32982 | Object.defineProperty(exports, "__esModule", {
|
32983 | value: true
|
32984 | });
|
32985 |
|
32986 | function generate(patterns, settings) {
|
32987 | const positivePatterns = getPositivePatterns(patterns);
|
32988 | const negativePatterns = getNegativePatternsAsPositive(patterns, settings.ignore);
|
32989 | const staticPatterns = positivePatterns.filter(pattern => utils$4.pattern.isStaticPattern(pattern, settings));
|
32990 | const dynamicPatterns = positivePatterns.filter(pattern => utils$4.pattern.isDynamicPattern(pattern, settings));
|
32991 | const staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns,
|
32992 |
|
32993 | false);
|
32994 | const dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns,
|
32995 |
|
32996 | true);
|
32997 | return staticTasks.concat(dynamicTasks);
|
32998 | }
|
32999 |
|
33000 | exports.generate = generate;
|
33001 |
|
33002 | function convertPatternsToTasks(positive, negative, dynamic) {
|
33003 | const positivePatternsGroup = groupPatternsByBaseDirectory(positive);
|
33004 |
|
33005 |
|
33006 | if ('.' in positivePatternsGroup) {
|
33007 | const task = convertPatternGroupToTask('.', positive, negative, dynamic);
|
33008 | return [task];
|
33009 | }
|
33010 |
|
33011 | return convertPatternGroupsToTasks(positivePatternsGroup, negative, dynamic);
|
33012 | }
|
33013 |
|
33014 | exports.convertPatternsToTasks = convertPatternsToTasks;
|
33015 |
|
33016 | function getPositivePatterns(patterns) {
|
33017 | return utils$4.pattern.getPositivePatterns(patterns);
|
33018 | }
|
33019 |
|
33020 | exports.getPositivePatterns = getPositivePatterns;
|
33021 |
|
33022 | function getNegativePatternsAsPositive(patterns, ignore) {
|
33023 | const negative = utils$4.pattern.getNegativePatterns(patterns).concat(ignore);
|
33024 | const positive = negative.map(utils$4.pattern.convertToPositivePattern);
|
33025 | return positive;
|
33026 | }
|
33027 |
|
33028 | exports.getNegativePatternsAsPositive = getNegativePatternsAsPositive;
|
33029 |
|
33030 | function groupPatternsByBaseDirectory(patterns) {
|
33031 | const group = {};
|
33032 | return patterns.reduce((collection, pattern) => {
|
33033 | const base = utils$4.pattern.getBaseDirectory(pattern);
|
33034 |
|
33035 | if (base in collection) {
|
33036 | collection[base].push(pattern);
|
33037 | } else {
|
33038 | collection[base] = [pattern];
|
33039 | }
|
33040 |
|
33041 | return collection;
|
33042 | }, group);
|
33043 | }
|
33044 |
|
33045 | exports.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory;
|
33046 |
|
33047 | function convertPatternGroupsToTasks(positive, negative, dynamic) {
|
33048 | return Object.keys(positive).map(base => {
|
33049 | return convertPatternGroupToTask(base, positive[base], negative, dynamic);
|
33050 | });
|
33051 | }
|
33052 |
|
33053 | exports.convertPatternGroupsToTasks = convertPatternGroupsToTasks;
|
33054 |
|
33055 | function convertPatternGroupToTask(base, positive, negative, dynamic) {
|
33056 | return {
|
33057 | dynamic,
|
33058 | positive,
|
33059 | negative,
|
33060 | base,
|
33061 | patterns: [].concat(positive, negative.map(utils$4.pattern.convertToNegativePattern))
|
33062 | };
|
33063 | }
|
33064 |
|
33065 | exports.convertPatternGroupToTask = convertPatternGroupToTask;
|
33066 | });
|
33067 | unwrapExports(tasks);
|
33068 | var tasks_1 = tasks.generate;
|
33069 | var tasks_2 = tasks.convertPatternsToTasks;
|
33070 | var tasks_3 = tasks.getPositivePatterns;
|
33071 | var tasks_4 = tasks.getNegativePatternsAsPositive;
|
33072 | var tasks_5 = tasks.groupPatternsByBaseDirectory;
|
33073 | var tasks_6 = tasks.convertPatternGroupsToTasks;
|
33074 | var tasks_7 = tasks.convertPatternGroupToTask;
|
33075 |
|
33076 | var async$1 = createCommonjsModule(function (module, exports) {
|
33077 |
|
33078 | Object.defineProperty(exports, "__esModule", {
|
33079 | value: true
|
33080 | });
|
33081 |
|
33082 | function read(path, settings, callback) {
|
33083 | settings.fs.lstat(path, (lstatError, lstat) => {
|
33084 | if (lstatError !== null) {
|
33085 | return callFailureCallback(callback, lstatError);
|
33086 | }
|
33087 |
|
33088 | if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
|
33089 | return callSuccessCallback(callback, lstat);
|
33090 | }
|
33091 |
|
33092 | settings.fs.stat(path, (statError, stat) => {
|
33093 | if (statError !== null) {
|
33094 | if (settings.throwErrorOnBrokenSymbolicLink) {
|
33095 | return callFailureCallback(callback, statError);
|
33096 | }
|
33097 |
|
33098 | return callSuccessCallback(callback, lstat);
|
33099 | }
|
33100 |
|
33101 | if (settings.markSymbolicLink) {
|
33102 | stat.isSymbolicLink = () => true;
|
33103 | }
|
33104 |
|
33105 | callSuccessCallback(callback, stat);
|
33106 | });
|
33107 | });
|
33108 | }
|
33109 |
|
33110 | exports.read = read;
|
33111 |
|
33112 | function callFailureCallback(callback, error) {
|
33113 | callback(error);
|
33114 | }
|
33115 |
|
33116 | function callSuccessCallback(callback, result) {
|
33117 | callback(null, result);
|
33118 | }
|
33119 | });
|
33120 | unwrapExports(async$1);
|
33121 | var async_1 = async$1.read;
|
33122 |
|
33123 | var sync$1 = createCommonjsModule(function (module, exports) {
|
33124 |
|
33125 | Object.defineProperty(exports, "__esModule", {
|
33126 | value: true
|
33127 | });
|
33128 |
|
33129 | function read(path, settings) {
|
33130 | const lstat = settings.fs.lstatSync(path);
|
33131 |
|
33132 | if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
|
33133 | return lstat;
|
33134 | }
|
33135 |
|
33136 | try {
|
33137 | const stat = settings.fs.statSync(path);
|
33138 |
|
33139 | if (settings.markSymbolicLink) {
|
33140 | stat.isSymbolicLink = () => true;
|
33141 | }
|
33142 |
|
33143 | return stat;
|
33144 | } catch (error) {
|
33145 | if (!settings.throwErrorOnBrokenSymbolicLink) {
|
33146 | return lstat;
|
33147 | }
|
33148 |
|
33149 | throw error;
|
33150 | }
|
33151 | }
|
33152 |
|
33153 | exports.read = read;
|
33154 | });
|
33155 | unwrapExports(sync$1);
|
33156 | var sync_1 = sync$1.read;
|
33157 |
|
33158 | var fs_1$1 = createCommonjsModule(function (module, exports) {
|
33159 |
|
33160 | Object.defineProperty(exports, "__esModule", {
|
33161 | value: true
|
33162 | });
|
33163 | exports.FILE_SYSTEM_ADAPTER = {
|
33164 | lstat: fs$3.lstat,
|
33165 | stat: fs$3.stat,
|
33166 | lstatSync: fs$3.lstatSync,
|
33167 | statSync: fs$3.statSync
|
33168 | };
|
33169 |
|
33170 | function createFileSystemAdapter(fsMethods) {
|
33171 | if (fsMethods === undefined) {
|
33172 | return exports.FILE_SYSTEM_ADAPTER;
|
33173 | }
|
33174 |
|
33175 | return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
|
33176 | }
|
33177 |
|
33178 | exports.createFileSystemAdapter = createFileSystemAdapter;
|
33179 | });
|
33180 | unwrapExports(fs_1$1);
|
33181 | var fs_2 = fs_1$1.FILE_SYSTEM_ADAPTER;
|
33182 | var fs_3 = fs_1$1.createFileSystemAdapter;
|
33183 |
|
33184 | var settings = createCommonjsModule(function (module, exports) {
|
33185 |
|
33186 | Object.defineProperty(exports, "__esModule", {
|
33187 | value: true
|
33188 | });
|
33189 |
|
33190 | class Settings {
|
33191 | constructor(_options = {}) {
|
33192 | this._options = _options;
|
33193 | this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
|
33194 | this.fs = fs_1$1.createFileSystemAdapter(this._options.fs);
|
33195 | this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
|
33196 | this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
33197 | }
|
33198 |
|
33199 | _getValue(option, value) {
|
33200 | return option === undefined ? value : option;
|
33201 | }
|
33202 |
|
33203 | }
|
33204 |
|
33205 | exports.default = Settings;
|
33206 | });
|
33207 | unwrapExports(settings);
|
33208 |
|
33209 | var out = createCommonjsModule(function (module, exports) {
|
33210 |
|
33211 | Object.defineProperty(exports, "__esModule", {
|
33212 | value: true
|
33213 | });
|
33214 | exports.Settings = settings.default;
|
33215 |
|
33216 | function stat(path, optionsOrSettingsOrCallback, callback) {
|
33217 | if (typeof optionsOrSettingsOrCallback === 'function') {
|
33218 | return async$1.read(path, getSettings(), optionsOrSettingsOrCallback);
|
33219 | }
|
33220 |
|
33221 | async$1.read(path, getSettings(optionsOrSettingsOrCallback), callback);
|
33222 | }
|
33223 |
|
33224 | exports.stat = stat;
|
33225 |
|
33226 | function statSync(path, optionsOrSettings) {
|
33227 | const settings = getSettings(optionsOrSettings);
|
33228 | return sync$1.read(path, settings);
|
33229 | }
|
33230 |
|
33231 | exports.statSync = statSync;
|
33232 |
|
33233 | function getSettings(settingsOrOptions = {}) {
|
33234 | if (settingsOrOptions instanceof settings.default) {
|
33235 | return settingsOrOptions;
|
33236 | }
|
33237 |
|
33238 | return new settings.default(settingsOrOptions);
|
33239 | }
|
33240 | });
|
33241 | unwrapExports(out);
|
33242 | var out_1 = out.Settings;
|
33243 | var out_2 = out.stat;
|
33244 | var out_3 = out.statSync;
|
33245 |
|
33246 | var runParallel_1 = runParallel;
|
33247 |
|
33248 | function runParallel(tasks, cb) {
|
33249 | var results, pending, keys;
|
33250 | var isSync = true;
|
33251 |
|
33252 | if (Array.isArray(tasks)) {
|
33253 | results = [];
|
33254 | pending = tasks.length;
|
33255 | } else {
|
33256 | keys = Object.keys(tasks);
|
33257 | results = {};
|
33258 | pending = keys.length;
|
33259 | }
|
33260 |
|
33261 | function done(err) {
|
33262 | function end() {
|
33263 | if (cb) cb(err, results);
|
33264 | cb = null;
|
33265 | }
|
33266 |
|
33267 | if (isSync) process.nextTick(end);else end();
|
33268 | }
|
33269 |
|
33270 | function each(i, err, result) {
|
33271 | results[i] = result;
|
33272 |
|
33273 | if (--pending === 0 || err) {
|
33274 | done(err);
|
33275 | }
|
33276 | }
|
33277 |
|
33278 | if (!pending) {
|
33279 |
|
33280 | done(null);
|
33281 | } else if (keys) {
|
33282 |
|
33283 | keys.forEach(function (key) {
|
33284 | tasks[key](function (err, result) {
|
33285 | each(key, err, result);
|
33286 | });
|
33287 | });
|
33288 | } else {
|
33289 |
|
33290 | tasks.forEach(function (task, i) {
|
33291 | task(function (err, result) {
|
33292 | each(i, err, result);
|
33293 | });
|
33294 | });
|
33295 | }
|
33296 |
|
33297 | isSync = false;
|
33298 | }
|
33299 |
|
33300 | var constants$4 = createCommonjsModule(function (module, exports) {
|
33301 |
|
33302 | Object.defineProperty(exports, "__esModule", {
|
33303 | value: true
|
33304 | });
|
33305 | const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.');
|
33306 | const MAJOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[0], 10);
|
33307 | const MINOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[1], 10);
|
33308 | const SUPPORTED_MAJOR_VERSION = 10;
|
33309 | const SUPPORTED_MINOR_VERSION = 10;
|
33310 | const IS_MATCHED_BY_MAJOR = MAJOR_VERSION > SUPPORTED_MAJOR_VERSION;
|
33311 | const IS_MATCHED_BY_MAJOR_AND_MINOR = MAJOR_VERSION === SUPPORTED_MAJOR_VERSION && MINOR_VERSION >= SUPPORTED_MINOR_VERSION;
|
33312 | |
33313 |
|
33314 |
|
33315 |
|
33316 | exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = IS_MATCHED_BY_MAJOR || IS_MATCHED_BY_MAJOR_AND_MINOR;
|
33317 | });
|
33318 | unwrapExports(constants$4);
|
33319 | var constants_1 = constants$4.IS_SUPPORT_READDIR_WITH_FILE_TYPES;
|
33320 |
|
33321 | var fs$2 = createCommonjsModule(function (module, exports) {
|
33322 |
|
33323 | Object.defineProperty(exports, "__esModule", {
|
33324 | value: true
|
33325 | });
|
33326 |
|
33327 | class DirentFromStats {
|
33328 | constructor(name, stats) {
|
33329 | this.name = name;
|
33330 | this.isBlockDevice = stats.isBlockDevice.bind(stats);
|
33331 | this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
|
33332 | this.isDirectory = stats.isDirectory.bind(stats);
|
33333 | this.isFIFO = stats.isFIFO.bind(stats);
|
33334 | this.isFile = stats.isFile.bind(stats);
|
33335 | this.isSocket = stats.isSocket.bind(stats);
|
33336 | this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
|
33337 | }
|
33338 |
|
33339 | }
|
33340 |
|
33341 | function createDirentFromStats(name, stats) {
|
33342 | return new DirentFromStats(name, stats);
|
33343 | }
|
33344 |
|
33345 | exports.createDirentFromStats = createDirentFromStats;
|
33346 | });
|
33347 | unwrapExports(fs$2);
|
33348 | var fs_1$2 = fs$2.createDirentFromStats;
|
33349 |
|
33350 | var utils$5 = createCommonjsModule(function (module, exports) {
|
33351 |
|
33352 | Object.defineProperty(exports, "__esModule", {
|
33353 | value: true
|
33354 | });
|
33355 | exports.fs = fs$2;
|
33356 | });
|
33357 | unwrapExports(utils$5);
|
33358 | var utils_1$5 = utils$5.fs;
|
33359 |
|
33360 | var async$2 = createCommonjsModule(function (module, exports) {
|
33361 |
|
33362 | Object.defineProperty(exports, "__esModule", {
|
33363 | value: true
|
33364 | });
|
33365 |
|
33366 | function read(directory, settings, callback) {
|
33367 | if (!settings.stats && constants$4.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
|
33368 | return readdirWithFileTypes(directory, settings, callback);
|
33369 | }
|
33370 |
|
33371 | return readdir(directory, settings, callback);
|
33372 | }
|
33373 |
|
33374 | exports.read = read;
|
33375 |
|
33376 | function readdirWithFileTypes(directory, settings, callback) {
|
33377 | settings.fs.readdir(directory, {
|
33378 | withFileTypes: true
|
33379 | }, (readdirError, dirents) => {
|
33380 | if (readdirError !== null) {
|
33381 | return callFailureCallback(callback, readdirError);
|
33382 | }
|
33383 |
|
33384 | const entries = dirents.map(dirent => ({
|
33385 | dirent,
|
33386 | name: dirent.name,
|
33387 | path: `${directory}${settings.pathSegmentSeparator}${dirent.name}`
|
33388 | }));
|
33389 |
|
33390 | if (!settings.followSymbolicLinks) {
|
33391 | return callSuccessCallback(callback, entries);
|
33392 | }
|
33393 |
|
33394 | const tasks = entries.map(entry => makeRplTaskEntry(entry, settings));
|
33395 | runParallel_1(tasks, (rplError, rplEntries) => {
|
33396 | if (rplError !== null) {
|
33397 | return callFailureCallback(callback, rplError);
|
33398 | }
|
33399 |
|
33400 | callSuccessCallback(callback, rplEntries);
|
33401 | });
|
33402 | });
|
33403 | }
|
33404 |
|
33405 | exports.readdirWithFileTypes = readdirWithFileTypes;
|
33406 |
|
33407 | function makeRplTaskEntry(entry, settings) {
|
33408 | return done => {
|
33409 | if (!entry.dirent.isSymbolicLink()) {
|
33410 | return done(null, entry);
|
33411 | }
|
33412 |
|
33413 | settings.fs.stat(entry.path, (statError, stats) => {
|
33414 | if (statError !== null) {
|
33415 | if (settings.throwErrorOnBrokenSymbolicLink) {
|
33416 | return done(statError);
|
33417 | }
|
33418 |
|
33419 | return done(null, entry);
|
33420 | }
|
33421 |
|
33422 | entry.dirent = utils$5.fs.createDirentFromStats(entry.name, stats);
|
33423 | return done(null, entry);
|
33424 | });
|
33425 | };
|
33426 | }
|
33427 |
|
33428 | function readdir(directory, settings, callback) {
|
33429 | settings.fs.readdir(directory, (readdirError, names) => {
|
33430 | if (readdirError !== null) {
|
33431 | return callFailureCallback(callback, readdirError);
|
33432 | }
|
33433 |
|
33434 | const filepaths = names.map(name => `${directory}${settings.pathSegmentSeparator}${name}`);
|
33435 | const tasks = filepaths.map(filepath => {
|
33436 | return done => out.stat(filepath, settings.fsStatSettings, done);
|
33437 | });
|
33438 | runParallel_1(tasks, (rplError, results) => {
|
33439 | if (rplError !== null) {
|
33440 | return callFailureCallback(callback, rplError);
|
33441 | }
|
33442 |
|
33443 | const entries = [];
|
33444 | names.forEach((name, index) => {
|
33445 | const stats = results[index];
|
33446 | const entry = {
|
33447 | name,
|
33448 | path: filepaths[index],
|
33449 | dirent: utils$5.fs.createDirentFromStats(name, stats)
|
33450 | };
|
33451 |
|
33452 | if (settings.stats) {
|
33453 | entry.stats = stats;
|
33454 | }
|
33455 |
|
33456 | entries.push(entry);
|
33457 | });
|
33458 | callSuccessCallback(callback, entries);
|
33459 | });
|
33460 | });
|
33461 | }
|
33462 |
|
33463 | exports.readdir = readdir;
|
33464 |
|
33465 | function callFailureCallback(callback, error) {
|
33466 | callback(error);
|
33467 | }
|
33468 |
|
33469 | function callSuccessCallback(callback, result) {
|
33470 | callback(null, result);
|
33471 | }
|
33472 | });
|
33473 | unwrapExports(async$2);
|
33474 | var async_1$1 = async$2.read;
|
33475 | var async_2 = async$2.readdirWithFileTypes;
|
33476 | var async_3 = async$2.readdir;
|
33477 |
|
33478 | var sync$2 = createCommonjsModule(function (module, exports) {
|
33479 |
|
33480 | Object.defineProperty(exports, "__esModule", {
|
33481 | value: true
|
33482 | });
|
33483 |
|
33484 | function read(directory, settings) {
|
33485 | if (!settings.stats && constants$4.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
|
33486 | return readdirWithFileTypes(directory, settings);
|
33487 | }
|
33488 |
|
33489 | return readdir(directory, settings);
|
33490 | }
|
33491 |
|
33492 | exports.read = read;
|
33493 |
|
33494 | function readdirWithFileTypes(directory, settings) {
|
33495 | const dirents = settings.fs.readdirSync(directory, {
|
33496 | withFileTypes: true
|
33497 | });
|
33498 | return dirents.map(dirent => {
|
33499 | const entry = {
|
33500 | dirent,
|
33501 | name: dirent.name,
|
33502 | path: `${directory}${settings.pathSegmentSeparator}${dirent.name}`
|
33503 | };
|
33504 |
|
33505 | if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) {
|
33506 | try {
|
33507 | const stats = settings.fs.statSync(entry.path);
|
33508 | entry.dirent = utils$5.fs.createDirentFromStats(entry.name, stats);
|
33509 | } catch (error) {
|
33510 | if (settings.throwErrorOnBrokenSymbolicLink) {
|
33511 | throw error;
|
33512 | }
|
33513 | }
|
33514 | }
|
33515 |
|
33516 | return entry;
|
33517 | });
|
33518 | }
|
33519 |
|
33520 | exports.readdirWithFileTypes = readdirWithFileTypes;
|
33521 |
|
33522 | function readdir(directory, settings) {
|
33523 | const names = settings.fs.readdirSync(directory);
|
33524 | return names.map(name => {
|
33525 | const entryPath = `${directory}${settings.pathSegmentSeparator}${name}`;
|
33526 | const stats = out.statSync(entryPath, settings.fsStatSettings);
|
33527 | const entry = {
|
33528 | name,
|
33529 | path: entryPath,
|
33530 | dirent: utils$5.fs.createDirentFromStats(name, stats)
|
33531 | };
|
33532 |
|
33533 | if (settings.stats) {
|
33534 | entry.stats = stats;
|
33535 | }
|
33536 |
|
33537 | return entry;
|
33538 | });
|
33539 | }
|
33540 |
|
33541 | exports.readdir = readdir;
|
33542 | });
|
33543 | unwrapExports(sync$2);
|
33544 | var sync_1$1 = sync$2.read;
|
33545 | var sync_2 = sync$2.readdirWithFileTypes;
|
33546 | var sync_3 = sync$2.readdir;
|
33547 |
|
33548 | var fs_1$3 = createCommonjsModule(function (module, exports) {
|
33549 |
|
33550 | Object.defineProperty(exports, "__esModule", {
|
33551 | value: true
|
33552 | });
|
33553 | exports.FILE_SYSTEM_ADAPTER = {
|
33554 | lstat: fs$3.lstat,
|
33555 | stat: fs$3.stat,
|
33556 | lstatSync: fs$3.lstatSync,
|
33557 | statSync: fs$3.statSync,
|
33558 | readdir: fs$3.readdir,
|
33559 | readdirSync: fs$3.readdirSync
|
33560 | };
|
33561 |
|
33562 | function createFileSystemAdapter(fsMethods) {
|
33563 | if (fsMethods === undefined) {
|
33564 | return exports.FILE_SYSTEM_ADAPTER;
|
33565 | }
|
33566 |
|
33567 | return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
|
33568 | }
|
33569 |
|
33570 | exports.createFileSystemAdapter = createFileSystemAdapter;
|
33571 | });
|
33572 | unwrapExports(fs_1$3);
|
33573 | var fs_2$1 = fs_1$3.FILE_SYSTEM_ADAPTER;
|
33574 | var fs_3$1 = fs_1$3.createFileSystemAdapter;
|
33575 |
|
33576 | var settings$1 = createCommonjsModule(function (module, exports) {
|
33577 |
|
33578 | Object.defineProperty(exports, "__esModule", {
|
33579 | value: true
|
33580 | });
|
33581 |
|
33582 | class Settings {
|
33583 | constructor(_options = {}) {
|
33584 | this._options = _options;
|
33585 | this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
|
33586 | this.fs = fs_1$3.createFileSystemAdapter(this._options.fs);
|
33587 | this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$2.sep);
|
33588 | this.stats = this._getValue(this._options.stats, false);
|
33589 | this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
33590 | this.fsStatSettings = new out.Settings({
|
33591 | followSymbolicLink: this.followSymbolicLinks,
|
33592 | fs: this.fs,
|
33593 | throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink
|
33594 | });
|
33595 | }
|
33596 |
|
33597 | _getValue(option, value) {
|
33598 | return option === undefined ? value : option;
|
33599 | }
|
33600 |
|
33601 | }
|
33602 |
|
33603 | exports.default = Settings;
|
33604 | });
|
33605 | unwrapExports(settings$1);
|
33606 |
|
33607 | var out$1 = createCommonjsModule(function (module, exports) {
|
33608 |
|
33609 | Object.defineProperty(exports, "__esModule", {
|
33610 | value: true
|
33611 | });
|
33612 | exports.Settings = settings$1.default;
|
33613 |
|
33614 | function scandir(path, optionsOrSettingsOrCallback, callback) {
|
33615 | if (typeof optionsOrSettingsOrCallback === 'function') {
|
33616 | return async$2.read(path, getSettings(), optionsOrSettingsOrCallback);
|
33617 | }
|
33618 |
|
33619 | async$2.read(path, getSettings(optionsOrSettingsOrCallback), callback);
|
33620 | }
|
33621 |
|
33622 | exports.scandir = scandir;
|
33623 |
|
33624 | function scandirSync(path, optionsOrSettings) {
|
33625 | const settings = getSettings(optionsOrSettings);
|
33626 | return sync$2.read(path, settings);
|
33627 | }
|
33628 |
|
33629 | exports.scandirSync = scandirSync;
|
33630 |
|
33631 | function getSettings(settingsOrOptions = {}) {
|
33632 | if (settingsOrOptions instanceof settings$1.default) {
|
33633 | return settingsOrOptions;
|
33634 | }
|
33635 |
|
33636 | return new settings$1.default(settingsOrOptions);
|
33637 | }
|
33638 | });
|
33639 | unwrapExports(out$1);
|
33640 | var out_1$1 = out$1.Settings;
|
33641 | var out_2$1 = out$1.scandir;
|
33642 | var out_3$1 = out$1.scandirSync;
|
33643 |
|
33644 | function reusify(Constructor) {
|
33645 | var head = new Constructor();
|
33646 | var tail = head;
|
33647 |
|
33648 | function get() {
|
33649 | var current = head;
|
33650 |
|
33651 | if (current.next) {
|
33652 | head = current.next;
|
33653 | } else {
|
33654 | head = new Constructor();
|
33655 | tail = head;
|
33656 | }
|
33657 |
|
33658 | current.next = null;
|
33659 | return current;
|
33660 | }
|
33661 |
|
33662 | function release(obj) {
|
33663 | tail.next = obj;
|
33664 | tail = obj;
|
33665 | }
|
33666 |
|
33667 | return {
|
33668 | get: get,
|
33669 | release: release
|
33670 | };
|
33671 | }
|
33672 |
|
33673 | var reusify_1 = reusify;
|
33674 |
|
33675 | function fastqueue(context, worker, concurrency) {
|
33676 | if (typeof context === 'function') {
|
33677 | concurrency = worker;
|
33678 | worker = context;
|
33679 | context = null;
|
33680 | }
|
33681 |
|
33682 | var cache = reusify_1(Task);
|
33683 | var queueHead = null;
|
33684 | var queueTail = null;
|
33685 | var _running = 0;
|
33686 | var self = {
|
33687 | push: push,
|
33688 | drain: noop$1,
|
33689 | saturated: noop$1,
|
33690 | pause: pause,
|
33691 | paused: false,
|
33692 | concurrency: concurrency,
|
33693 | running: running,
|
33694 | resume: resume,
|
33695 | idle: idle,
|
33696 | length: length,
|
33697 | unshift: unshift,
|
33698 | empty: noop$1,
|
33699 | kill: kill,
|
33700 | killAndDrain: killAndDrain
|
33701 | };
|
33702 | return self;
|
33703 |
|
33704 | function running() {
|
33705 | return _running;
|
33706 | }
|
33707 |
|
33708 | function pause() {
|
33709 | self.paused = true;
|
33710 | }
|
33711 |
|
33712 | function length() {
|
33713 | var current = queueHead;
|
33714 | var counter = 0;
|
33715 |
|
33716 | while (current) {
|
33717 | current = current.next;
|
33718 | counter++;
|
33719 | }
|
33720 |
|
33721 | return counter;
|
33722 | }
|
33723 |
|
33724 | function resume() {
|
33725 | if (!self.paused) return;
|
33726 | self.paused = false;
|
33727 |
|
33728 | for (var i = 0; i < self.concurrency; i++) {
|
33729 | _running++;
|
33730 | release();
|
33731 | }
|
33732 | }
|
33733 |
|
33734 | function idle() {
|
33735 | return _running === 0 && self.length() === 0;
|
33736 | }
|
33737 |
|
33738 | function push(value, done) {
|
33739 | var current = cache.get();
|
33740 | current.context = context;
|
33741 | current.release = release;
|
33742 | current.value = value;
|
33743 | current.callback = done || noop$1;
|
33744 |
|
33745 | if (_running === self.concurrency || self.paused) {
|
33746 | if (queueTail) {
|
33747 | queueTail.next = current;
|
33748 | queueTail = current;
|
33749 | } else {
|
33750 | queueHead = current;
|
33751 | queueTail = current;
|
33752 | self.saturated();
|
33753 | }
|
33754 | } else {
|
33755 | _running++;
|
33756 | worker.call(context, current.value, current.worked);
|
33757 | }
|
33758 | }
|
33759 |
|
33760 | function unshift(value, done) {
|
33761 | var current = cache.get();
|
33762 | current.context = context;
|
33763 | current.release = release;
|
33764 | current.value = value;
|
33765 | current.callback = done || noop$1;
|
33766 |
|
33767 | if (_running === self.concurrency || self.paused) {
|
33768 | if (queueHead) {
|
33769 | current.next = queueHead;
|
33770 | queueHead = current;
|
33771 | } else {
|
33772 | queueHead = current;
|
33773 | queueTail = current;
|
33774 | self.saturated();
|
33775 | }
|
33776 | } else {
|
33777 | _running++;
|
33778 | worker.call(context, current.value, current.worked);
|
33779 | }
|
33780 | }
|
33781 |
|
33782 | function release(holder) {
|
33783 | if (holder) {
|
33784 | cache.release(holder);
|
33785 | }
|
33786 |
|
33787 | var next = queueHead;
|
33788 |
|
33789 | if (next) {
|
33790 | if (!self.paused) {
|
33791 | if (queueTail === queueHead) {
|
33792 | queueTail = null;
|
33793 | }
|
33794 |
|
33795 | queueHead = next.next;
|
33796 | next.next = null;
|
33797 | worker.call(context, next.value, next.worked);
|
33798 |
|
33799 | if (queueTail === null) {
|
33800 | self.empty();
|
33801 | }
|
33802 | } else {
|
33803 | _running--;
|
33804 | }
|
33805 | } else if (--_running === 0) {
|
33806 | self.drain();
|
33807 | }
|
33808 | }
|
33809 |
|
33810 | function kill() {
|
33811 | queueHead = null;
|
33812 | queueTail = null;
|
33813 | self.drain = noop$1;
|
33814 | }
|
33815 |
|
33816 | function killAndDrain() {
|
33817 | queueHead = null;
|
33818 | queueTail = null;
|
33819 | self.drain();
|
33820 | self.drain = noop$1;
|
33821 | }
|
33822 | }
|
33823 |
|
33824 | function noop$1() {}
|
33825 |
|
33826 | function Task() {
|
33827 | this.value = null;
|
33828 | this.callback = noop$1;
|
33829 | this.next = null;
|
33830 | this.release = noop$1;
|
33831 | this.context = null;
|
33832 | var self = this;
|
33833 |
|
33834 | this.worked = function worked(err, result) {
|
33835 | var callback = self.callback;
|
33836 | self.value = null;
|
33837 | self.callback = noop$1;
|
33838 | callback.call(self.context, err, result);
|
33839 | self.release(self);
|
33840 | };
|
33841 | }
|
33842 |
|
33843 | var queue = fastqueue;
|
33844 |
|
33845 | var common$2 = createCommonjsModule(function (module, exports) {
|
33846 |
|
33847 | Object.defineProperty(exports, "__esModule", {
|
33848 | value: true
|
33849 | });
|
33850 |
|
33851 | function isFatalError(settings, error) {
|
33852 | if (settings.errorFilter === null) {
|
33853 | return true;
|
33854 | }
|
33855 |
|
33856 | return !settings.errorFilter(error);
|
33857 | }
|
33858 |
|
33859 | exports.isFatalError = isFatalError;
|
33860 |
|
33861 | function isAppliedFilter(filter, value) {
|
33862 | return filter === null || filter(value);
|
33863 | }
|
33864 |
|
33865 | exports.isAppliedFilter = isAppliedFilter;
|
33866 |
|
33867 | function replacePathSegmentSeparator(filepath, separator) {
|
33868 | return filepath.split(/[\\/]/).join(separator);
|
33869 | }
|
33870 |
|
33871 | exports.replacePathSegmentSeparator = replacePathSegmentSeparator;
|
33872 |
|
33873 | function joinPathSegments(a, b, separator) {
|
33874 | if (a === '') {
|
33875 | return b;
|
33876 | }
|
33877 |
|
33878 | return a + separator + b;
|
33879 | }
|
33880 |
|
33881 | exports.joinPathSegments = joinPathSegments;
|
33882 | });
|
33883 | unwrapExports(common$2);
|
33884 | var common_1$2 = common$2.isFatalError;
|
33885 | var common_2 = common$2.isAppliedFilter;
|
33886 | var common_3 = common$2.replacePathSegmentSeparator;
|
33887 | var common_4 = common$2.joinPathSegments;
|
33888 |
|
33889 | var reader = createCommonjsModule(function (module, exports) {
|
33890 |
|
33891 | Object.defineProperty(exports, "__esModule", {
|
33892 | value: true
|
33893 | });
|
33894 |
|
33895 | class Reader {
|
33896 | constructor(_root, _settings) {
|
33897 | this._root = _root;
|
33898 | this._settings = _settings;
|
33899 | this._root = common$2.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator);
|
33900 | }
|
33901 |
|
33902 | }
|
33903 |
|
33904 | exports.default = Reader;
|
33905 | });
|
33906 | unwrapExports(reader);
|
33907 |
|
33908 | var async$3 = createCommonjsModule(function (module, exports) {
|
33909 |
|
33910 | Object.defineProperty(exports, "__esModule", {
|
33911 | value: true
|
33912 | });
|
33913 |
|
33914 | class AsyncReader extends reader.default {
|
33915 | constructor(_root, _settings) {
|
33916 | super(_root, _settings);
|
33917 | this._settings = _settings;
|
33918 | this._scandir = out$1.scandir;
|
33919 | this._emitter = new events$1.EventEmitter();
|
33920 | this._queue = queue(this._worker.bind(this), this._settings.concurrency);
|
33921 | this._isFatalError = false;
|
33922 | this._isDestroyed = false;
|
33923 |
|
33924 | this._queue.drain = () => {
|
33925 | if (!this._isFatalError) {
|
33926 | this._emitter.emit('end');
|
33927 | }
|
33928 | };
|
33929 | }
|
33930 |
|
33931 | read() {
|
33932 | this._isFatalError = false;
|
33933 | this._isDestroyed = false;
|
33934 | setImmediate(() => {
|
33935 | this._pushToQueue(this._root, this._settings.basePath);
|
33936 | });
|
33937 | return this._emitter;
|
33938 | }
|
33939 |
|
33940 | destroy() {
|
33941 | if (this._isDestroyed) {
|
33942 | throw new Error('The reader is already destroyed');
|
33943 | }
|
33944 |
|
33945 | this._isDestroyed = true;
|
33946 |
|
33947 | this._queue.killAndDrain();
|
33948 | }
|
33949 |
|
33950 | onEntry(callback) {
|
33951 | this._emitter.on('entry', callback);
|
33952 | }
|
33953 |
|
33954 | onError(callback) {
|
33955 | this._emitter.once('error', callback);
|
33956 | }
|
33957 |
|
33958 | onEnd(callback) {
|
33959 | this._emitter.once('end', callback);
|
33960 | }
|
33961 |
|
33962 | _pushToQueue(directory, base) {
|
33963 | const queueItem = {
|
33964 | directory,
|
33965 | base
|
33966 | };
|
33967 |
|
33968 | this._queue.push(queueItem, error => {
|
33969 | if (error !== null) {
|
33970 | this._handleError(error);
|
33971 | }
|
33972 | });
|
33973 | }
|
33974 |
|
33975 | _worker(item, done) {
|
33976 | this._scandir(item.directory, this._settings.fsScandirSettings, (error, entries) => {
|
33977 | if (error !== null) {
|
33978 | return done(error, undefined);
|
33979 | }
|
33980 |
|
33981 | for (const entry of entries) {
|
33982 | this._handleEntry(entry, item.base);
|
33983 | }
|
33984 |
|
33985 | done(null, undefined);
|
33986 | });
|
33987 | }
|
33988 |
|
33989 | _handleError(error) {
|
33990 | if (!common$2.isFatalError(this._settings, error)) {
|
33991 | return;
|
33992 | }
|
33993 |
|
33994 | this._isFatalError = true;
|
33995 | this._isDestroyed = true;
|
33996 |
|
33997 | this._emitter.emit('error', error);
|
33998 | }
|
33999 |
|
34000 | _handleEntry(entry, base) {
|
34001 | if (this._isDestroyed || this._isFatalError) {
|
34002 | return;
|
34003 | }
|
34004 |
|
34005 | const fullpath = entry.path;
|
34006 |
|
34007 | if (base !== undefined) {
|
34008 | entry.path = common$2.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
|
34009 | }
|
34010 |
|
34011 | if (common$2.isAppliedFilter(this._settings.entryFilter, entry)) {
|
34012 | this._emitEntry(entry);
|
34013 | }
|
34014 |
|
34015 | if (entry.dirent.isDirectory() && common$2.isAppliedFilter(this._settings.deepFilter, entry)) {
|
34016 | this._pushToQueue(fullpath, entry.path);
|
34017 | }
|
34018 | }
|
34019 |
|
34020 | _emitEntry(entry) {
|
34021 | this._emitter.emit('entry', entry);
|
34022 | }
|
34023 |
|
34024 | }
|
34025 |
|
34026 | exports.default = AsyncReader;
|
34027 | });
|
34028 | unwrapExports(async$3);
|
34029 |
|
34030 | var async$4 = createCommonjsModule(function (module, exports) {
|
34031 |
|
34032 | Object.defineProperty(exports, "__esModule", {
|
34033 | value: true
|
34034 | });
|
34035 |
|
34036 | class AsyncProvider {
|
34037 | constructor(_root, _settings) {
|
34038 | this._root = _root;
|
34039 | this._settings = _settings;
|
34040 | this._reader = new async$3.default(this._root, this._settings);
|
34041 | this._storage = new Set();
|
34042 | }
|
34043 |
|
34044 | read(callback) {
|
34045 | this._reader.onError(error => {
|
34046 | callFailureCallback(callback, error);
|
34047 | });
|
34048 |
|
34049 | this._reader.onEntry(entry => {
|
34050 | this._storage.add(entry);
|
34051 | });
|
34052 |
|
34053 | this._reader.onEnd(() => {
|
34054 | callSuccessCallback(callback, [...this._storage]);
|
34055 | });
|
34056 |
|
34057 | this._reader.read();
|
34058 | }
|
34059 |
|
34060 | }
|
34061 |
|
34062 | exports.default = AsyncProvider;
|
34063 |
|
34064 | function callFailureCallback(callback, error) {
|
34065 | callback(error);
|
34066 | }
|
34067 |
|
34068 | function callSuccessCallback(callback, entries) {
|
34069 | callback(null, entries);
|
34070 | }
|
34071 | });
|
34072 | unwrapExports(async$4);
|
34073 |
|
34074 | var stream$2 = createCommonjsModule(function (module, exports) {
|
34075 |
|
34076 | Object.defineProperty(exports, "__esModule", {
|
34077 | value: true
|
34078 | });
|
34079 |
|
34080 | class StreamProvider {
|
34081 | constructor(_root, _settings) {
|
34082 | this._root = _root;
|
34083 | this._settings = _settings;
|
34084 | this._reader = new async$3.default(this._root, this._settings);
|
34085 | this._stream = new stream$6.Readable({
|
34086 | objectMode: true,
|
34087 | read: () => {},
|
34088 | destroy: this._reader.destroy.bind(this._reader)
|
34089 | });
|
34090 | }
|
34091 |
|
34092 | read() {
|
34093 | this._reader.onError(error => {
|
34094 | this._stream.emit('error', error);
|
34095 | });
|
34096 |
|
34097 | this._reader.onEntry(entry => {
|
34098 | this._stream.push(entry);
|
34099 | });
|
34100 |
|
34101 | this._reader.onEnd(() => {
|
34102 | this._stream.push(null);
|
34103 | });
|
34104 |
|
34105 | this._reader.read();
|
34106 |
|
34107 | return this._stream;
|
34108 | }
|
34109 |
|
34110 | }
|
34111 |
|
34112 | exports.default = StreamProvider;
|
34113 | });
|
34114 | unwrapExports(stream$2);
|
34115 |
|
34116 | var sync$3 = createCommonjsModule(function (module, exports) {
|
34117 |
|
34118 | Object.defineProperty(exports, "__esModule", {
|
34119 | value: true
|
34120 | });
|
34121 |
|
34122 | class SyncReader extends reader.default {
|
34123 | constructor() {
|
34124 | super(...arguments);
|
34125 | this._scandir = out$1.scandirSync;
|
34126 | this._storage = new Set();
|
34127 | this._queue = new Set();
|
34128 | }
|
34129 |
|
34130 | read() {
|
34131 | this._pushToQueue(this._root, this._settings.basePath);
|
34132 |
|
34133 | this._handleQueue();
|
34134 |
|
34135 | return [...this._storage];
|
34136 | }
|
34137 |
|
34138 | _pushToQueue(directory, base) {
|
34139 | this._queue.add({
|
34140 | directory,
|
34141 | base
|
34142 | });
|
34143 | }
|
34144 |
|
34145 | _handleQueue() {
|
34146 | for (const item of this._queue.values()) {
|
34147 | this._handleDirectory(item.directory, item.base);
|
34148 | }
|
34149 | }
|
34150 |
|
34151 | _handleDirectory(directory, base) {
|
34152 | try {
|
34153 | const entries = this._scandir(directory, this._settings.fsScandirSettings);
|
34154 |
|
34155 | for (const entry of entries) {
|
34156 | this._handleEntry(entry, base);
|
34157 | }
|
34158 | } catch (error) {
|
34159 | this._handleError(error);
|
34160 | }
|
34161 | }
|
34162 |
|
34163 | _handleError(error) {
|
34164 | if (!common$2.isFatalError(this._settings, error)) {
|
34165 | return;
|
34166 | }
|
34167 |
|
34168 | throw error;
|
34169 | }
|
34170 |
|
34171 | _handleEntry(entry, base) {
|
34172 | const fullpath = entry.path;
|
34173 |
|
34174 | if (base !== undefined) {
|
34175 | entry.path = common$2.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
|
34176 | }
|
34177 |
|
34178 | if (common$2.isAppliedFilter(this._settings.entryFilter, entry)) {
|
34179 | this._pushToStorage(entry);
|
34180 | }
|
34181 |
|
34182 | if (entry.dirent.isDirectory() && common$2.isAppliedFilter(this._settings.deepFilter, entry)) {
|
34183 | this._pushToQueue(fullpath, entry.path);
|
34184 | }
|
34185 | }
|
34186 |
|
34187 | _pushToStorage(entry) {
|
34188 | this._storage.add(entry);
|
34189 | }
|
34190 |
|
34191 | }
|
34192 |
|
34193 | exports.default = SyncReader;
|
34194 | });
|
34195 | unwrapExports(sync$3);
|
34196 |
|
34197 | var sync$4 = createCommonjsModule(function (module, exports) {
|
34198 |
|
34199 | Object.defineProperty(exports, "__esModule", {
|
34200 | value: true
|
34201 | });
|
34202 |
|
34203 | class SyncProvider {
|
34204 | constructor(_root, _settings) {
|
34205 | this._root = _root;
|
34206 | this._settings = _settings;
|
34207 | this._reader = new sync$3.default(this._root, this._settings);
|
34208 | }
|
34209 |
|
34210 | read() {
|
34211 | return this._reader.read();
|
34212 | }
|
34213 |
|
34214 | }
|
34215 |
|
34216 | exports.default = SyncProvider;
|
34217 | });
|
34218 | unwrapExports(sync$4);
|
34219 |
|
34220 | var settings$2 = createCommonjsModule(function (module, exports) {
|
34221 |
|
34222 | Object.defineProperty(exports, "__esModule", {
|
34223 | value: true
|
34224 | });
|
34225 |
|
34226 | class Settings {
|
34227 | constructor(_options = {}) {
|
34228 | this._options = _options;
|
34229 | this.basePath = this._getValue(this._options.basePath, undefined);
|
34230 | this.concurrency = this._getValue(this._options.concurrency, Infinity);
|
34231 | this.deepFilter = this._getValue(this._options.deepFilter, null);
|
34232 | this.entryFilter = this._getValue(this._options.entryFilter, null);
|
34233 | this.errorFilter = this._getValue(this._options.errorFilter, null);
|
34234 | this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$2.sep);
|
34235 | this.fsScandirSettings = new out$1.Settings({
|
34236 | followSymbolicLinks: this._options.followSymbolicLinks,
|
34237 | fs: this._options.fs,
|
34238 | pathSegmentSeparator: this._options.pathSegmentSeparator,
|
34239 | stats: this._options.stats,
|
34240 | throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink
|
34241 | });
|
34242 | }
|
34243 |
|
34244 | _getValue(option, value) {
|
34245 | return option === undefined ? value : option;
|
34246 | }
|
34247 |
|
34248 | }
|
34249 |
|
34250 | exports.default = Settings;
|
34251 | });
|
34252 | unwrapExports(settings$2);
|
34253 |
|
34254 | var out$2 = createCommonjsModule(function (module, exports) {
|
34255 |
|
34256 | Object.defineProperty(exports, "__esModule", {
|
34257 | value: true
|
34258 | });
|
34259 | exports.Settings = settings$2.default;
|
34260 |
|
34261 | function walk(directory, optionsOrSettingsOrCallback, callback) {
|
34262 | if (typeof optionsOrSettingsOrCallback === 'function') {
|
34263 | return new async$4.default(directory, getSettings()).read(optionsOrSettingsOrCallback);
|
34264 | }
|
34265 |
|
34266 | new async$4.default(directory, getSettings(optionsOrSettingsOrCallback)).read(callback);
|
34267 | }
|
34268 |
|
34269 | exports.walk = walk;
|
34270 |
|
34271 | function walkSync(directory, optionsOrSettings) {
|
34272 | const settings = getSettings(optionsOrSettings);
|
34273 | const provider = new sync$4.default(directory, settings);
|
34274 | return provider.read();
|
34275 | }
|
34276 |
|
34277 | exports.walkSync = walkSync;
|
34278 |
|
34279 | function walkStream(directory, optionsOrSettings) {
|
34280 | const settings = getSettings(optionsOrSettings);
|
34281 | const provider = new stream$2.default(directory, settings);
|
34282 | return provider.read();
|
34283 | }
|
34284 |
|
34285 | exports.walkStream = walkStream;
|
34286 |
|
34287 | function getSettings(settingsOrOptions = {}) {
|
34288 | if (settingsOrOptions instanceof settings$2.default) {
|
34289 | return settingsOrOptions;
|
34290 | }
|
34291 |
|
34292 | return new settings$2.default(settingsOrOptions);
|
34293 | }
|
34294 | });
|
34295 | unwrapExports(out$2);
|
34296 | var out_1$2 = out$2.Settings;
|
34297 | var out_2$2 = out$2.walk;
|
34298 | var out_3$2 = out$2.walkSync;
|
34299 | var out_4 = out$2.walkStream;
|
34300 |
|
34301 | var reader$1 = createCommonjsModule(function (module, exports) {
|
34302 |
|
34303 | Object.defineProperty(exports, "__esModule", {
|
34304 | value: true
|
34305 | });
|
34306 |
|
34307 | class Reader {
|
34308 | constructor(_settings) {
|
34309 | this._settings = _settings;
|
34310 | this._fsStatSettings = new out.Settings({
|
34311 | followSymbolicLink: this._settings.followSymbolicLinks,
|
34312 | fs: this._settings.fs,
|
34313 | throwErrorOnBrokenSymbolicLink: this._settings.followSymbolicLinks
|
34314 | });
|
34315 | }
|
34316 |
|
34317 | _getFullEntryPath(filepath) {
|
34318 | return path$2.resolve(this._settings.cwd, filepath);
|
34319 | }
|
34320 |
|
34321 | _makeEntry(stats, pattern) {
|
34322 | const entry = {
|
34323 | name: pattern,
|
34324 | path: pattern,
|
34325 | dirent: utils$4.fs.createDirentFromStats(pattern, stats)
|
34326 | };
|
34327 |
|
34328 | if (this._settings.stats) {
|
34329 | entry.stats = stats;
|
34330 | }
|
34331 |
|
34332 | return entry;
|
34333 | }
|
34334 |
|
34335 | _isFatalError(error) {
|
34336 | return !utils$4.errno.isEnoentCodeError(error) && !this._settings.suppressErrors;
|
34337 | }
|
34338 |
|
34339 | }
|
34340 |
|
34341 | exports.default = Reader;
|
34342 | });
|
34343 | unwrapExports(reader$1);
|
34344 |
|
34345 | var stream$3 = createCommonjsModule(function (module, exports) {
|
34346 |
|
34347 | Object.defineProperty(exports, "__esModule", {
|
34348 | value: true
|
34349 | });
|
34350 |
|
34351 | class ReaderStream extends reader$1.default {
|
34352 | constructor() {
|
34353 | super(...arguments);
|
34354 | this._walkStream = out$2.walkStream;
|
34355 | this._stat = out.stat;
|
34356 | }
|
34357 |
|
34358 | dynamic(root, options) {
|
34359 | return this._walkStream(root, options);
|
34360 | }
|
34361 |
|
34362 | static(patterns, options) {
|
34363 | const filepaths = patterns.map(this._getFullEntryPath, this);
|
34364 | const stream = new stream$6.PassThrough({
|
34365 | objectMode: true
|
34366 | });
|
34367 |
|
34368 | stream._write = (index, _enc, done) => {
|
34369 | return this._getEntry(filepaths[index], patterns[index], options).then(entry => {
|
34370 | if (entry !== null && options.entryFilter(entry)) {
|
34371 | stream.push(entry);
|
34372 | }
|
34373 |
|
34374 | if (index === filepaths.length - 1) {
|
34375 | stream.end();
|
34376 | }
|
34377 |
|
34378 | done();
|
34379 | }).catch(done);
|
34380 | };
|
34381 |
|
34382 | for (let i = 0; i < filepaths.length; i++) {
|
34383 | stream.write(i);
|
34384 | }
|
34385 |
|
34386 | return stream;
|
34387 | }
|
34388 |
|
34389 | _getEntry(filepath, pattern, options) {
|
34390 | return this._getStat(filepath).then(stats => this._makeEntry(stats, pattern)).catch(error => {
|
34391 | if (options.errorFilter(error)) {
|
34392 | return null;
|
34393 | }
|
34394 |
|
34395 | throw error;
|
34396 | });
|
34397 | }
|
34398 |
|
34399 | _getStat(filepath) {
|
34400 | return new Promise((resolve, reject) => {
|
34401 | this._stat(filepath, this._fsStatSettings, (error, stats) => {
|
34402 | return error === null ? resolve(stats) : reject(error);
|
34403 | });
|
34404 | });
|
34405 | }
|
34406 |
|
34407 | }
|
34408 |
|
34409 | exports.default = ReaderStream;
|
34410 | });
|
34411 | unwrapExports(stream$3);
|
34412 |
|
34413 | var matcher = createCommonjsModule(function (module, exports) {
|
34414 |
|
34415 | Object.defineProperty(exports, "__esModule", {
|
34416 | value: true
|
34417 | });
|
34418 |
|
34419 | class Matcher {
|
34420 | constructor(_patterns, _settings, _micromatchOptions) {
|
34421 | this._patterns = _patterns;
|
34422 | this._settings = _settings;
|
34423 | this._micromatchOptions = _micromatchOptions;
|
34424 | this._storage = [];
|
34425 |
|
34426 | this._fillStorage();
|
34427 | }
|
34428 |
|
34429 | _fillStorage() {
|
34430 | |
34431 |
|
34432 |
|
34433 |
|
34434 | const patterns = utils$4.pattern.expandPatternsWithBraceExpansion(this._patterns);
|
34435 |
|
34436 | for (const pattern of patterns) {
|
34437 | const segments = this._getPatternSegments(pattern);
|
34438 |
|
34439 | const sections = this._splitSegmentsIntoSections(segments);
|
34440 |
|
34441 | this._storage.push({
|
34442 | complete: sections.length <= 1,
|
34443 | pattern,
|
34444 | segments,
|
34445 | sections
|
34446 | });
|
34447 | }
|
34448 | }
|
34449 |
|
34450 | _getPatternSegments(pattern) {
|
34451 | const parts = utils$4.pattern.getPatternParts(pattern, this._micromatchOptions);
|
34452 | return parts.map(part => {
|
34453 | const dynamic = utils$4.pattern.isDynamicPattern(part, this._settings);
|
34454 |
|
34455 | if (!dynamic) {
|
34456 | return {
|
34457 | dynamic: false,
|
34458 | pattern: part
|
34459 | };
|
34460 | }
|
34461 |
|
34462 | return {
|
34463 | dynamic: true,
|
34464 | pattern: part,
|
34465 | patternRe: utils$4.pattern.makeRe(part, this._micromatchOptions)
|
34466 | };
|
34467 | });
|
34468 | }
|
34469 |
|
34470 | _splitSegmentsIntoSections(segments) {
|
34471 | return utils$4.array.splitWhen(segments, segment => segment.dynamic && utils$4.pattern.hasGlobStar(segment.pattern));
|
34472 | }
|
34473 |
|
34474 | }
|
34475 |
|
34476 | exports.default = Matcher;
|
34477 | });
|
34478 | unwrapExports(matcher);
|
34479 |
|
34480 | var partial = createCommonjsModule(function (module, exports) {
|
34481 |
|
34482 | Object.defineProperty(exports, "__esModule", {
|
34483 | value: true
|
34484 | });
|
34485 |
|
34486 | class PartialMatcher extends matcher.default {
|
34487 | match(filepath) {
|
34488 | const parts = filepath.split('/');
|
34489 | const levels = parts.length;
|
34490 |
|
34491 | const patterns = this._storage.filter(info => !info.complete || info.segments.length > levels);
|
34492 |
|
34493 | for (const pattern of patterns) {
|
34494 | const section = pattern.sections[0];
|
34495 | |
34496 |
|
34497 |
|
34498 |
|
34499 |
|
34500 |
|
34501 |
|
34502 |
|
34503 | if (!pattern.complete && levels > section.length) {
|
34504 | return true;
|
34505 | }
|
34506 |
|
34507 | const match = parts.every((part, index) => {
|
34508 | const segment = pattern.segments[index];
|
34509 |
|
34510 | if (segment.dynamic && segment.patternRe.test(part)) {
|
34511 | return true;
|
34512 | }
|
34513 |
|
34514 | if (!segment.dynamic && segment.pattern === part) {
|
34515 | return true;
|
34516 | }
|
34517 |
|
34518 | return false;
|
34519 | });
|
34520 |
|
34521 | if (match) {
|
34522 | return true;
|
34523 | }
|
34524 | }
|
34525 |
|
34526 | return false;
|
34527 | }
|
34528 |
|
34529 | }
|
34530 |
|
34531 | exports.default = PartialMatcher;
|
34532 | });
|
34533 | unwrapExports(partial);
|
34534 |
|
34535 | var deep = createCommonjsModule(function (module, exports) {
|
34536 |
|
34537 | Object.defineProperty(exports, "__esModule", {
|
34538 | value: true
|
34539 | });
|
34540 |
|
34541 | class DeepFilter {
|
34542 | constructor(_settings, _micromatchOptions) {
|
34543 | this._settings = _settings;
|
34544 | this._micromatchOptions = _micromatchOptions;
|
34545 | }
|
34546 |
|
34547 | getFilter(basePath, positive, negative) {
|
34548 | const matcher = this._getMatcher(positive);
|
34549 |
|
34550 | const negativeRe = this._getNegativePatternsRe(negative);
|
34551 |
|
34552 | return entry => this._filter(basePath, entry, matcher, negativeRe);
|
34553 | }
|
34554 |
|
34555 | _getMatcher(patterns) {
|
34556 | return new partial.default(patterns, this._settings, this._micromatchOptions);
|
34557 | }
|
34558 |
|
34559 | _getNegativePatternsRe(patterns) {
|
34560 | const affectDepthOfReadingPatterns = patterns.filter(utils$4.pattern.isAffectDepthOfReadingPattern);
|
34561 | return utils$4.pattern.convertPatternsToRe(affectDepthOfReadingPatterns, this._micromatchOptions);
|
34562 | }
|
34563 |
|
34564 | _filter(basePath, entry, matcher, negativeRe) {
|
34565 | const depth = this._getEntryLevel(basePath, entry.path);
|
34566 |
|
34567 | if (this._isSkippedByDeep(depth)) {
|
34568 | return false;
|
34569 | }
|
34570 |
|
34571 | if (this._isSkippedSymbolicLink(entry)) {
|
34572 | return false;
|
34573 | }
|
34574 |
|
34575 | const filepath = utils$4.path.removeLeadingDotSegment(entry.path);
|
34576 |
|
34577 | if (this._isSkippedByPositivePatterns(filepath, matcher)) {
|
34578 | return false;
|
34579 | }
|
34580 |
|
34581 | return this._isSkippedByNegativePatterns(filepath, negativeRe);
|
34582 | }
|
34583 |
|
34584 | _isSkippedByDeep(entryDepth) {
|
34585 | return entryDepth >= this._settings.deep;
|
34586 | }
|
34587 |
|
34588 | _isSkippedSymbolicLink(entry) {
|
34589 | return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink();
|
34590 | }
|
34591 |
|
34592 | _getEntryLevel(basePath, entryPath) {
|
34593 | const basePathDepth = basePath.split('/').length;
|
34594 | const entryPathDepth = entryPath.split('/').length;
|
34595 | return entryPathDepth - (basePath === '' ? 0 : basePathDepth);
|
34596 | }
|
34597 |
|
34598 | _isSkippedByPositivePatterns(entryPath, matcher) {
|
34599 | return !this._settings.baseNameMatch && !matcher.match(entryPath);
|
34600 | }
|
34601 |
|
34602 | _isSkippedByNegativePatterns(entryPath, negativeRe) {
|
34603 | return !utils$4.pattern.matchAny(entryPath, negativeRe);
|
34604 | }
|
34605 |
|
34606 | }
|
34607 |
|
34608 | exports.default = DeepFilter;
|
34609 | });
|
34610 | unwrapExports(deep);
|
34611 |
|
34612 | var entry = createCommonjsModule(function (module, exports) {
|
34613 |
|
34614 | Object.defineProperty(exports, "__esModule", {
|
34615 | value: true
|
34616 | });
|
34617 |
|
34618 | class EntryFilter {
|
34619 | constructor(_settings, _micromatchOptions) {
|
34620 | this._settings = _settings;
|
34621 | this._micromatchOptions = _micromatchOptions;
|
34622 | this.index = new Map();
|
34623 | }
|
34624 |
|
34625 | getFilter(positive, negative) {
|
34626 | const positiveRe = utils$4.pattern.convertPatternsToRe(positive, this._micromatchOptions);
|
34627 | const negativeRe = utils$4.pattern.convertPatternsToRe(negative, this._micromatchOptions);
|
34628 | return entry => this._filter(entry, positiveRe, negativeRe);
|
34629 | }
|
34630 |
|
34631 | _filter(entry, positiveRe, negativeRe) {
|
34632 | if (this._settings.unique) {
|
34633 | if (this._isDuplicateEntry(entry)) {
|
34634 | return false;
|
34635 | }
|
34636 |
|
34637 | this._createIndexRecord(entry);
|
34638 | }
|
34639 |
|
34640 | if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) {
|
34641 | return false;
|
34642 | }
|
34643 |
|
34644 | if (this._isSkippedByAbsoluteNegativePatterns(entry, negativeRe)) {
|
34645 | return false;
|
34646 | }
|
34647 |
|
34648 | const filepath = this._settings.baseNameMatch ? entry.name : entry.path;
|
34649 | return this._isMatchToPatterns(filepath, positiveRe) && !this._isMatchToPatterns(entry.path, negativeRe);
|
34650 | }
|
34651 |
|
34652 | _isDuplicateEntry(entry) {
|
34653 | return this.index.has(entry.path);
|
34654 | }
|
34655 |
|
34656 | _createIndexRecord(entry) {
|
34657 | this.index.set(entry.path, undefined);
|
34658 | }
|
34659 |
|
34660 | _onlyFileFilter(entry) {
|
34661 | return this._settings.onlyFiles && !entry.dirent.isFile();
|
34662 | }
|
34663 |
|
34664 | _onlyDirectoryFilter(entry) {
|
34665 | return this._settings.onlyDirectories && !entry.dirent.isDirectory();
|
34666 | }
|
34667 |
|
34668 | _isSkippedByAbsoluteNegativePatterns(entry, negativeRe) {
|
34669 | if (!this._settings.absolute) {
|
34670 | return false;
|
34671 | }
|
34672 |
|
34673 | const fullpath = utils$4.path.makeAbsolute(this._settings.cwd, entry.path);
|
34674 | return this._isMatchToPatterns(fullpath, negativeRe);
|
34675 | }
|
34676 |
|
34677 | _isMatchToPatterns(entryPath, patternsRe) {
|
34678 | const filepath = utils$4.path.removeLeadingDotSegment(entryPath);
|
34679 | return utils$4.pattern.matchAny(filepath, patternsRe);
|
34680 | }
|
34681 |
|
34682 | }
|
34683 |
|
34684 | exports.default = EntryFilter;
|
34685 | });
|
34686 | unwrapExports(entry);
|
34687 |
|
34688 | var error = createCommonjsModule(function (module, exports) {
|
34689 |
|
34690 | Object.defineProperty(exports, "__esModule", {
|
34691 | value: true
|
34692 | });
|
34693 |
|
34694 | class ErrorFilter {
|
34695 | constructor(_settings) {
|
34696 | this._settings = _settings;
|
34697 | }
|
34698 |
|
34699 | getFilter() {
|
34700 | return error => this._isNonFatalError(error);
|
34701 | }
|
34702 |
|
34703 | _isNonFatalError(error) {
|
34704 | return utils$4.errno.isEnoentCodeError(error) || this._settings.suppressErrors;
|
34705 | }
|
34706 |
|
34707 | }
|
34708 |
|
34709 | exports.default = ErrorFilter;
|
34710 | });
|
34711 | unwrapExports(error);
|
34712 |
|
34713 | var entry$1 = createCommonjsModule(function (module, exports) {
|
34714 |
|
34715 | Object.defineProperty(exports, "__esModule", {
|
34716 | value: true
|
34717 | });
|
34718 |
|
34719 | class EntryTransformer {
|
34720 | constructor(_settings) {
|
34721 | this._settings = _settings;
|
34722 | }
|
34723 |
|
34724 | getTransformer() {
|
34725 | return entry => this._transform(entry);
|
34726 | }
|
34727 |
|
34728 | _transform(entry) {
|
34729 | let filepath = entry.path;
|
34730 |
|
34731 | if (this._settings.absolute) {
|
34732 | filepath = utils$4.path.makeAbsolute(this._settings.cwd, filepath);
|
34733 | filepath = utils$4.path.unixify(filepath);
|
34734 | }
|
34735 |
|
34736 | if (this._settings.markDirectories && entry.dirent.isDirectory()) {
|
34737 | filepath += '/';
|
34738 | }
|
34739 |
|
34740 | if (!this._settings.objectMode) {
|
34741 | return filepath;
|
34742 | }
|
34743 |
|
34744 | return Object.assign(Object.assign({}, entry), {
|
34745 | path: filepath
|
34746 | });
|
34747 | }
|
34748 |
|
34749 | }
|
34750 |
|
34751 | exports.default = EntryTransformer;
|
34752 | });
|
34753 | unwrapExports(entry$1);
|
34754 |
|
34755 | var provider = createCommonjsModule(function (module, exports) {
|
34756 |
|
34757 | Object.defineProperty(exports, "__esModule", {
|
34758 | value: true
|
34759 | });
|
34760 |
|
34761 | class Provider {
|
34762 | constructor(_settings) {
|
34763 | this._settings = _settings;
|
34764 | this.errorFilter = new error.default(this._settings);
|
34765 | this.entryFilter = new entry.default(this._settings, this._getMicromatchOptions());
|
34766 | this.deepFilter = new deep.default(this._settings, this._getMicromatchOptions());
|
34767 | this.entryTransformer = new entry$1.default(this._settings);
|
34768 | }
|
34769 |
|
34770 | _getRootDirectory(task) {
|
34771 | return path$2.resolve(this._settings.cwd, task.base);
|
34772 | }
|
34773 |
|
34774 | _getReaderOptions(task) {
|
34775 | const basePath = task.base === '.' ? '' : task.base;
|
34776 | return {
|
34777 | basePath,
|
34778 | pathSegmentSeparator: '/',
|
34779 | concurrency: this._settings.concurrency,
|
34780 | deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative),
|
34781 | entryFilter: this.entryFilter.getFilter(task.positive, task.negative),
|
34782 | errorFilter: this.errorFilter.getFilter(),
|
34783 | followSymbolicLinks: this._settings.followSymbolicLinks,
|
34784 | fs: this._settings.fs,
|
34785 | stats: this._settings.stats,
|
34786 | throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink,
|
34787 | transform: this.entryTransformer.getTransformer()
|
34788 | };
|
34789 | }
|
34790 |
|
34791 | _getMicromatchOptions() {
|
34792 | return {
|
34793 | dot: this._settings.dot,
|
34794 | matchBase: this._settings.baseNameMatch,
|
34795 | nobrace: !this._settings.braceExpansion,
|
34796 | nocase: !this._settings.caseSensitiveMatch,
|
34797 | noext: !this._settings.extglob,
|
34798 | noglobstar: !this._settings.globstar,
|
34799 | posix: true,
|
34800 | strictSlashes: false
|
34801 | };
|
34802 | }
|
34803 |
|
34804 | }
|
34805 |
|
34806 | exports.default = Provider;
|
34807 | });
|
34808 | unwrapExports(provider);
|
34809 |
|
34810 | var async$5 = createCommonjsModule(function (module, exports) {
|
34811 |
|
34812 | Object.defineProperty(exports, "__esModule", {
|
34813 | value: true
|
34814 | });
|
34815 |
|
34816 | class ProviderAsync extends provider.default {
|
34817 | constructor() {
|
34818 | super(...arguments);
|
34819 | this._reader = new stream$3.default(this._settings);
|
34820 | }
|
34821 |
|
34822 | read(task) {
|
34823 | const root = this._getRootDirectory(task);
|
34824 |
|
34825 | const options = this._getReaderOptions(task);
|
34826 |
|
34827 | const entries = [];
|
34828 | return new Promise((resolve, reject) => {
|
34829 | const stream = this.api(root, task, options);
|
34830 | stream.once('error', reject);
|
34831 | stream.on('data', entry => entries.push(options.transform(entry)));
|
34832 | stream.once('end', () => resolve(entries));
|
34833 | });
|
34834 | }
|
34835 |
|
34836 | api(root, task, options) {
|
34837 | if (task.dynamic) {
|
34838 | return this._reader.dynamic(root, options);
|
34839 | }
|
34840 |
|
34841 | return this._reader.static(task.patterns, options);
|
34842 | }
|
34843 |
|
34844 | }
|
34845 |
|
34846 | exports.default = ProviderAsync;
|
34847 | });
|
34848 | unwrapExports(async$5);
|
34849 |
|
34850 | var stream$4 = createCommonjsModule(function (module, exports) {
|
34851 |
|
34852 | Object.defineProperty(exports, "__esModule", {
|
34853 | value: true
|
34854 | });
|
34855 |
|
34856 | class ProviderStream extends provider.default {
|
34857 | constructor() {
|
34858 | super(...arguments);
|
34859 | this._reader = new stream$3.default(this._settings);
|
34860 | }
|
34861 |
|
34862 | read(task) {
|
34863 | const root = this._getRootDirectory(task);
|
34864 |
|
34865 | const options = this._getReaderOptions(task);
|
34866 |
|
34867 | const source = this.api(root, task, options);
|
34868 | const destination = new stream$6.Readable({
|
34869 | objectMode: true,
|
34870 | read: () => {}
|
34871 | });
|
34872 | source.once('error', error => destination.emit('error', error)).on('data', entry => destination.emit('data', options.transform(entry))).once('end', () => destination.emit('end'));
|
34873 | destination.once('close', () => source.destroy());
|
34874 | return destination;
|
34875 | }
|
34876 |
|
34877 | api(root, task, options) {
|
34878 | if (task.dynamic) {
|
34879 | return this._reader.dynamic(root, options);
|
34880 | }
|
34881 |
|
34882 | return this._reader.static(task.patterns, options);
|
34883 | }
|
34884 |
|
34885 | }
|
34886 |
|
34887 | exports.default = ProviderStream;
|
34888 | });
|
34889 | unwrapExports(stream$4);
|
34890 |
|
34891 | var sync$5 = createCommonjsModule(function (module, exports) {
|
34892 |
|
34893 | Object.defineProperty(exports, "__esModule", {
|
34894 | value: true
|
34895 | });
|
34896 |
|
34897 | class ReaderSync extends reader$1.default {
|
34898 | constructor() {
|
34899 | super(...arguments);
|
34900 | this._walkSync = out$2.walkSync;
|
34901 | this._statSync = out.statSync;
|
34902 | }
|
34903 |
|
34904 | dynamic(root, options) {
|
34905 | return this._walkSync(root, options);
|
34906 | }
|
34907 |
|
34908 | static(patterns, options) {
|
34909 | const entries = [];
|
34910 |
|
34911 | for (const pattern of patterns) {
|
34912 | const filepath = this._getFullEntryPath(pattern);
|
34913 |
|
34914 | const entry = this._getEntry(filepath, pattern, options);
|
34915 |
|
34916 | if (entry === null || !options.entryFilter(entry)) {
|
34917 | continue;
|
34918 | }
|
34919 |
|
34920 | entries.push(entry);
|
34921 | }
|
34922 |
|
34923 | return entries;
|
34924 | }
|
34925 |
|
34926 | _getEntry(filepath, pattern, options) {
|
34927 | try {
|
34928 | const stats = this._getStat(filepath);
|
34929 |
|
34930 | return this._makeEntry(stats, pattern);
|
34931 | } catch (error) {
|
34932 | if (options.errorFilter(error)) {
|
34933 | return null;
|
34934 | }
|
34935 |
|
34936 | throw error;
|
34937 | }
|
34938 | }
|
34939 |
|
34940 | _getStat(filepath) {
|
34941 | return this._statSync(filepath, this._fsStatSettings);
|
34942 | }
|
34943 |
|
34944 | }
|
34945 |
|
34946 | exports.default = ReaderSync;
|
34947 | });
|
34948 | unwrapExports(sync$5);
|
34949 |
|
34950 | var sync$6 = createCommonjsModule(function (module, exports) {
|
34951 |
|
34952 | Object.defineProperty(exports, "__esModule", {
|
34953 | value: true
|
34954 | });
|
34955 |
|
34956 | class ProviderSync extends provider.default {
|
34957 | constructor() {
|
34958 | super(...arguments);
|
34959 | this._reader = new sync$5.default(this._settings);
|
34960 | }
|
34961 |
|
34962 | read(task) {
|
34963 | const root = this._getRootDirectory(task);
|
34964 |
|
34965 | const options = this._getReaderOptions(task);
|
34966 |
|
34967 | const entries = this.api(root, task, options);
|
34968 | return entries.map(options.transform);
|
34969 | }
|
34970 |
|
34971 | api(root, task, options) {
|
34972 | if (task.dynamic) {
|
34973 | return this._reader.dynamic(root, options);
|
34974 | }
|
34975 |
|
34976 | return this._reader.static(task.patterns, options);
|
34977 | }
|
34978 |
|
34979 | }
|
34980 |
|
34981 | exports.default = ProviderSync;
|
34982 | });
|
34983 | unwrapExports(sync$6);
|
34984 |
|
34985 | var settings$3 = createCommonjsModule(function (module, exports) {
|
34986 |
|
34987 | Object.defineProperty(exports, "__esModule", {
|
34988 | value: true
|
34989 | });
|
34990 | const CPU_COUNT = os$1.cpus().length;
|
34991 | exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
|
34992 | lstat: fs$3.lstat,
|
34993 | lstatSync: fs$3.lstatSync,
|
34994 | stat: fs$3.stat,
|
34995 | statSync: fs$3.statSync,
|
34996 | readdir: fs$3.readdir,
|
34997 | readdirSync: fs$3.readdirSync
|
34998 | };
|
34999 |
|
35000 | class Settings {
|
35001 | constructor(_options = {}) {
|
35002 | this._options = _options;
|
35003 | this.absolute = this._getValue(this._options.absolute, false);
|
35004 | this.baseNameMatch = this._getValue(this._options.baseNameMatch, false);
|
35005 | this.braceExpansion = this._getValue(this._options.braceExpansion, true);
|
35006 | this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true);
|
35007 | this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT);
|
35008 | this.cwd = this._getValue(this._options.cwd, process.cwd());
|
35009 | this.deep = this._getValue(this._options.deep, Infinity);
|
35010 | this.dot = this._getValue(this._options.dot, false);
|
35011 | this.extglob = this._getValue(this._options.extglob, true);
|
35012 | this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true);
|
35013 | this.fs = this._getFileSystemMethods(this._options.fs);
|
35014 | this.globstar = this._getValue(this._options.globstar, true);
|
35015 | this.ignore = this._getValue(this._options.ignore, []);
|
35016 | this.markDirectories = this._getValue(this._options.markDirectories, false);
|
35017 | this.objectMode = this._getValue(this._options.objectMode, false);
|
35018 | this.onlyDirectories = this._getValue(this._options.onlyDirectories, false);
|
35019 | this.onlyFiles = this._getValue(this._options.onlyFiles, true);
|
35020 | this.stats = this._getValue(this._options.stats, false);
|
35021 | this.suppressErrors = this._getValue(this._options.suppressErrors, false);
|
35022 | this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false);
|
35023 | this.unique = this._getValue(this._options.unique, true);
|
35024 |
|
35025 | if (this.onlyDirectories) {
|
35026 | this.onlyFiles = false;
|
35027 | }
|
35028 |
|
35029 | if (this.stats) {
|
35030 | this.objectMode = true;
|
35031 | }
|
35032 | }
|
35033 |
|
35034 | _getValue(option, value) {
|
35035 | return option === undefined ? value : option;
|
35036 | }
|
35037 |
|
35038 | _getFileSystemMethods(methods = {}) {
|
35039 | return Object.assign(Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER), methods);
|
35040 | }
|
35041 |
|
35042 | }
|
35043 |
|
35044 | exports.default = Settings;
|
35045 | });
|
35046 | unwrapExports(settings$3);
|
35047 | var settings_1 = settings$3.DEFAULT_FILE_SYSTEM_ADAPTER;
|
35048 |
|
35049 | async function FastGlob(source, options) {
|
35050 | assertPatternsInput(source);
|
35051 | const works = getWorks(source, async$5.default, options);
|
35052 | const result = await Promise.all(works);
|
35053 | return utils$4.array.flatten(result);
|
35054 | }
|
35055 |
|
35056 |
|
35057 |
|
35058 | (function (FastGlob) {
|
35059 | function sync(source, options) {
|
35060 | assertPatternsInput(source);
|
35061 | const works = getWorks(source, sync$6.default, options);
|
35062 | return utils$4.array.flatten(works);
|
35063 | }
|
35064 |
|
35065 | FastGlob.sync = sync;
|
35066 |
|
35067 | function stream(source, options) {
|
35068 | assertPatternsInput(source);
|
35069 | const works = getWorks(source, stream$4.default, options);
|
35070 | |
35071 |
|
35072 |
|
35073 |
|
35074 |
|
35075 |
|
35076 | return utils$4.stream.merge(works);
|
35077 | }
|
35078 |
|
35079 | FastGlob.stream = stream;
|
35080 |
|
35081 | function generateTasks(source, options) {
|
35082 | assertPatternsInput(source);
|
35083 | const patterns = [].concat(source);
|
35084 | const settings = new settings$3.default(options);
|
35085 | return tasks.generate(patterns, settings);
|
35086 | }
|
35087 |
|
35088 | FastGlob.generateTasks = generateTasks;
|
35089 |
|
35090 | function isDynamicPattern(source, options) {
|
35091 | assertPatternsInput(source);
|
35092 | const settings = new settings$3.default(options);
|
35093 | return utils$4.pattern.isDynamicPattern(source, settings);
|
35094 | }
|
35095 |
|
35096 | FastGlob.isDynamicPattern = isDynamicPattern;
|
35097 |
|
35098 | function escapePath(source) {
|
35099 | assertPatternsInput(source);
|
35100 | return utils$4.path.escape(source);
|
35101 | }
|
35102 |
|
35103 | FastGlob.escapePath = escapePath;
|
35104 | })(FastGlob || (FastGlob = {}));
|
35105 |
|
35106 | function getWorks(source, _Provider, options) {
|
35107 | const patterns = [].concat(source);
|
35108 | const settings = new settings$3.default(options);
|
35109 | const tasks$1 = tasks.generate(patterns, settings);
|
35110 | const provider = new _Provider(settings);
|
35111 | return tasks$1.map(provider.read, provider);
|
35112 | }
|
35113 |
|
35114 | function assertPatternsInput(input) {
|
35115 | const source = [].concat(input);
|
35116 | const isValidSource = source.every(item => utils$4.string.isString(item) && !utils$4.string.isEmpty(item));
|
35117 |
|
35118 | if (!isValidSource) {
|
35119 | throw new TypeError('Patterns must be a string (non empty) or an array of strings');
|
35120 | }
|
35121 | }
|
35122 |
|
35123 | var out$3 = FastGlob;
|
35124 |
|
35125 | const {
|
35126 | promisify
|
35127 | } = util$4;
|
35128 |
|
35129 | async function isType(fsStatType, statsMethodName, filePath) {
|
35130 | if (typeof filePath !== 'string') {
|
35131 | throw new TypeError(`Expected a string, got ${typeof filePath}`);
|
35132 | }
|
35133 |
|
35134 | try {
|
35135 | const stats = await promisify(fs$3[fsStatType])(filePath);
|
35136 | return stats[statsMethodName]();
|
35137 | } catch (error) {
|
35138 | if (error.code === 'ENOENT') {
|
35139 | return false;
|
35140 | }
|
35141 |
|
35142 | throw error;
|
35143 | }
|
35144 | }
|
35145 |
|
35146 | function isTypeSync(fsStatType, statsMethodName, filePath) {
|
35147 | if (typeof filePath !== 'string') {
|
35148 | throw new TypeError(`Expected a string, got ${typeof filePath}`);
|
35149 | }
|
35150 |
|
35151 | try {
|
35152 | return fs$3[fsStatType](filePath)[statsMethodName]();
|
35153 | } catch (error) {
|
35154 | if (error.code === 'ENOENT') {
|
35155 | return false;
|
35156 | }
|
35157 |
|
35158 | throw error;
|
35159 | }
|
35160 | }
|
35161 |
|
35162 | var isFile = isType.bind(null, 'stat', 'isFile');
|
35163 | var isDirectory = isType.bind(null, 'stat', 'isDirectory');
|
35164 | var isSymlink = isType.bind(null, 'lstat', 'isSymbolicLink');
|
35165 | var isFileSync = isTypeSync.bind(null, 'statSync', 'isFile');
|
35166 | var isDirectorySync = isTypeSync.bind(null, 'statSync', 'isDirectory');
|
35167 | var isSymlinkSync = isTypeSync.bind(null, 'lstatSync', 'isSymbolicLink');
|
35168 | var pathType = {
|
35169 | isFile: isFile,
|
35170 | isDirectory: isDirectory,
|
35171 | isSymlink: isSymlink,
|
35172 | isFileSync: isFileSync,
|
35173 | isDirectorySync: isDirectorySync,
|
35174 | isSymlinkSync: isSymlinkSync
|
35175 | };
|
35176 |
|
35177 | const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0];
|
35178 |
|
35179 | const getPath = (filepath, cwd) => {
|
35180 | const pth = filepath[0] === '!' ? filepath.slice(1) : filepath;
|
35181 | return path$2.isAbsolute(pth) ? pth : path$2.join(cwd, pth);
|
35182 | };
|
35183 |
|
35184 | const addExtensions = (file, extensions) => {
|
35185 | if (path$2.extname(file)) {
|
35186 | return `**/${file}`;
|
35187 | }
|
35188 |
|
35189 | return `**/${file}.${getExtensions(extensions)}`;
|
35190 | };
|
35191 |
|
35192 | const getGlob = (directory, options) => {
|
35193 | if (options.files && !Array.isArray(options.files)) {
|
35194 | throw new TypeError(`Expected \`files\` to be of type \`Array\` but received type \`${typeof options.files}\``);
|
35195 | }
|
35196 |
|
35197 | if (options.extensions && !Array.isArray(options.extensions)) {
|
35198 | throw new TypeError(`Expected \`extensions\` to be of type \`Array\` but received type \`${typeof options.extensions}\``);
|
35199 | }
|
35200 |
|
35201 | if (options.files && options.extensions) {
|
35202 | return options.files.map(x => path$2.posix.join(directory, addExtensions(x, options.extensions)));
|
35203 | }
|
35204 |
|
35205 | if (options.files) {
|
35206 | return options.files.map(x => path$2.posix.join(directory, `**/${x}`));
|
35207 | }
|
35208 |
|
35209 | if (options.extensions) {
|
35210 | return [path$2.posix.join(directory, `**/*.${getExtensions(options.extensions)}`)];
|
35211 | }
|
35212 |
|
35213 | return [path$2.posix.join(directory, '**')];
|
35214 | };
|
35215 |
|
35216 | var dirGlob = async (input, options) => {
|
35217 | options = Object.assign({
|
35218 | cwd: process.cwd()
|
35219 | }, options);
|
35220 |
|
35221 | if (typeof options.cwd !== 'string') {
|
35222 | throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
|
35223 | }
|
35224 |
|
35225 | const globs = await Promise.all([].concat(input).map(async x => {
|
35226 | const isDirectory = await pathType.isDirectory(getPath(x, options.cwd));
|
35227 | return isDirectory ? getGlob(x, options) : x;
|
35228 | }));
|
35229 | return [].concat.apply([], globs);
|
35230 | };
|
35231 |
|
35232 | var sync$7 = (input, options) => {
|
35233 | options = Object.assign({
|
35234 | cwd: process.cwd()
|
35235 | }, options);
|
35236 |
|
35237 | if (typeof options.cwd !== 'string') {
|
35238 | throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
|
35239 | }
|
35240 |
|
35241 | const globs = [].concat(input).map(x => pathType.isDirectorySync(getPath(x, options.cwd)) ? getGlob(x, options) : x);
|
35242 | return [].concat.apply([], globs);
|
35243 | };
|
35244 | dirGlob.sync = sync$7;
|
35245 |
|
35246 |
|
35247 | function makeArray(subject) {
|
35248 | return Array.isArray(subject) ? subject : [subject];
|
35249 | }
|
35250 |
|
35251 | const REGEX_TEST_BLANK_LINE = /^\s+$/;
|
35252 | const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
35253 | const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
35254 | const REGEX_SPLITALL_CRLF = /\r?\n/g;
|
35255 |
|
35256 |
|
35257 |
|
35258 |
|
35259 |
|
35260 | const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/;
|
35261 | const SLASH$1 = '/';
|
35262 | const KEY_IGNORE$1 = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
|
35263 |
|
35264 | : 'node-ignore';
|
35265 |
|
35266 | const define$1 = (object, key, value) => Object.defineProperty(object, key, {
|
35267 | value
|
35268 | });
|
35269 |
|
35270 | const REGEX_REGEXP_RANGE$1 = /([0-z])-([0-z])/g;
|
35271 |
|
35272 |
|
35273 | const sanitizeRange$1 = range => range.replace(REGEX_REGEXP_RANGE$1, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match
|
35274 |
|
35275 | : '');
|
35276 |
|
35277 |
|
35278 |
|
35279 |
|
35280 |
|
35281 |
|
35282 |
|
35283 |
|
35284 |
|
35285 |
|
35286 |
|
35287 | const REPLACERS = [
|
35288 | [
|
35289 |
|
35290 |
|
35291 | /\\?\s+$/, match => match.indexOf('\\') === 0 ? ' ' : ''],
|
35292 | [/\\\s/g, () => ' '],
|
35293 |
|
35294 |
|
35295 |
|
35296 |
|
35297 |
|
35298 |
|
35299 |
|
35300 |
|
35301 |
|
35302 |
|
35303 |
|
35304 |
|
35305 |
|
35306 |
|
35307 |
|
35308 | [/[\\^$.|*+(){]/g, match => `\\${match}`], [
|
35309 |
|
35310 | /\[([^\]/]*)($|\])/g, (match, p1, p2) => p2 === ']' ? `[${sanitizeRange$1(p1)}]` : `\\${match}`], [
|
35311 | /(?!\\)\?/g, () => '[^/]'],
|
35312 | [
|
35313 |
|
35314 |
|
35315 | /^\
|
35316 | [/\//g, () => '\\/'], [
|
35317 |
|
35318 |
|
35319 |
|
35320 |
|
35321 |
|
35322 | /^\^*\\\*\\\*\\\
|
35323 | () => '^(?:.*\\/)?'],
|
35324 | [
|
35325 |
|
35326 | /(?:[^*])$/,
|
35327 |
|
35328 |
|
35329 |
|
35330 |
|
35331 |
|
35332 |
|
35333 |
|
35334 |
|
35335 |
|
35336 | match => /\/$/.test(match)
|
35337 | ? `${match}$`
|
35338 | : `${match}(?=$|\\/$)`],
|
35339 | [
|
35340 |
|
35341 |
|
35342 | /^(?=[^^])/, function startingReplacer() {
|
35343 |
|
35344 | return !/\/(?!$)/.test(this)
|
35345 |
|
35346 |
|
35347 |
|
35348 |
|
35349 |
|
35350 |
|
35351 |
|
35352 |
|
35353 |
|
35354 |
|
35355 | ? '(?:^|\\/)'
|
35356 |
|
35357 | : '^';
|
35358 | }],
|
35359 | [
|
35360 | /\\\/\\\*\\\*(?=\\\/|$)/g,
|
35361 |
|
35362 |
|
35363 | (_, index, str) => index + 6 < str.length
|
35364 |
|
35365 |
|
35366 |
|
35367 |
|
35368 | ? '(?:\\/[^\\/]+)*'
|
35369 |
|
35370 |
|
35371 | : '\\/.+'],
|
35372 | [
|
35373 |
|
35374 |
|
35375 |
|
35376 | /(^|[^\\]+)\\\*(?=.+)/g,
|
35377 |
|
35378 | (_, p1) => `${p1}[^\\/]*`],
|
35379 | [/(\^|\\\/)?\\\*$/, (_, p1) => {
|
35380 | const prefix = p1
|
35381 |
|
35382 |
|
35383 |
|
35384 |
|
35385 | ? `${p1}[^/]+`
|
35386 |
|
35387 | : '[^/]*';
|
35388 | return `${prefix}(?=$|\\/$)`;
|
35389 | }], [
|
35390 | /\\\\\\/g, () => '\\']];
|
35391 |
|
35392 | const regexCache = Object.create(null);
|
35393 |
|
35394 | const makeRegex = (pattern, negative, ignorecase) => {
|
35395 | const r = regexCache[pattern];
|
35396 |
|
35397 | if (r) {
|
35398 | return r;
|
35399 | }
|
35400 |
|
35401 |
|
35402 |
|
35403 |
|
35404 | const source = REPLACERS.reduce((prev, current) => prev.replace(current[0], current[1].bind(pattern)), pattern);
|
35405 | return regexCache[pattern] = ignorecase ? new RegExp(source, 'i') : new RegExp(source);
|
35406 | };
|
35407 |
|
35408 | const isString = subject => typeof subject === 'string';
|
35409 |
|
35410 |
|
35411 | const checkPattern$1 = pattern => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern)
|
35412 | && pattern.indexOf('#') !== 0;
|
35413 |
|
35414 | const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF);
|
35415 |
|
35416 | class IgnoreRule {
|
35417 | constructor(origin, pattern, negative, regex) {
|
35418 | this.origin = origin;
|
35419 | this.pattern = pattern;
|
35420 | this.negative = negative;
|
35421 | this.regex = regex;
|
35422 | }
|
35423 |
|
35424 | }
|
35425 |
|
35426 | const createRule$1 = (pattern, ignorecase) => {
|
35427 | const origin = pattern;
|
35428 | let negative = false;
|
35429 |
|
35430 | if (pattern.indexOf('!') === 0) {
|
35431 | negative = true;
|
35432 | pattern = pattern.substr(1);
|
35433 | }
|
35434 |
|
35435 | pattern = pattern
|
35436 |
|
35437 | .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!')
|
35438 |
|
35439 | .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#');
|
35440 | const regex = makeRegex(pattern, negative, ignorecase);
|
35441 | return new IgnoreRule(origin, pattern, negative, regex);
|
35442 | };
|
35443 |
|
35444 | const throwError = (message, Ctor) => {
|
35445 | throw new Ctor(message);
|
35446 | };
|
35447 |
|
35448 | const checkPath = (path, originalPath, doThrow) => {
|
35449 | if (!isString(path)) {
|
35450 | return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
35451 | }
|
35452 |
|
35453 |
|
35454 | if (!path) {
|
35455 | return doThrow(`path must not be empty`, TypeError);
|
35456 | }
|
35457 |
|
35458 |
|
35459 | if (checkPath.isNotRelative(path)) {
|
35460 | const r = '`path.relative()`d';
|
35461 | return doThrow(`path should be a ${r} string, but got "${originalPath}"`, RangeError);
|
35462 | }
|
35463 |
|
35464 | return true;
|
35465 | };
|
35466 |
|
35467 | const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path);
|
35468 |
|
35469 | checkPath.isNotRelative = isNotRelative;
|
35470 |
|
35471 | checkPath.convert = p => p;
|
35472 |
|
35473 | class Ignore {
|
35474 | constructor({
|
35475 | ignorecase = true
|
35476 | } = {}) {
|
35477 | this._rules = [];
|
35478 | this._ignorecase = ignorecase;
|
35479 | define$1(this, KEY_IGNORE$1, true);
|
35480 |
|
35481 | this._initCache();
|
35482 | }
|
35483 |
|
35484 | _initCache() {
|
35485 | this._ignoreCache = Object.create(null);
|
35486 | this._testCache = Object.create(null);
|
35487 | }
|
35488 |
|
35489 | _addPattern(pattern) {
|
35490 |
|
35491 | if (pattern && pattern[KEY_IGNORE$1]) {
|
35492 | this._rules = this._rules.concat(pattern._rules);
|
35493 | this._added = true;
|
35494 | return;
|
35495 | }
|
35496 |
|
35497 | if (checkPattern$1(pattern)) {
|
35498 | const rule = createRule$1(pattern, this._ignorecase);
|
35499 | this._added = true;
|
35500 |
|
35501 | this._rules.push(rule);
|
35502 | }
|
35503 | }
|
35504 |
|
35505 |
|
35506 | add(pattern) {
|
35507 | this._added = false;
|
35508 | makeArray(isString(pattern) ? splitPattern(pattern) : pattern).forEach(this._addPattern, this);
|
35509 |
|
35510 |
|
35511 | if (this._added) {
|
35512 | this._initCache();
|
35513 | }
|
35514 |
|
35515 | return this;
|
35516 | }
|
35517 |
|
35518 |
|
35519 | addPattern(pattern) {
|
35520 | return this.add(pattern);
|
35521 | }
|
35522 |
|
35523 |
|
35524 |
|
35525 |
|
35526 |
|
35527 |
|
35528 |
|
35529 |
|
35530 |
|
35531 |
|
35532 |
|
35533 |
|
35534 |
|
35535 |
|
35536 | _testOne(path, checkUnignored) {
|
35537 | let ignored = false;
|
35538 | let unignored = false;
|
35539 |
|
35540 | this._rules.forEach(rule => {
|
35541 | const {
|
35542 | negative
|
35543 | } = rule;
|
35544 |
|
35545 | if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
35546 | return;
|
35547 | }
|
35548 |
|
35549 | const matched = rule.regex.test(path);
|
35550 |
|
35551 | if (matched) {
|
35552 | ignored = !negative;
|
35553 | unignored = negative;
|
35554 | }
|
35555 | });
|
35556 |
|
35557 | return {
|
35558 | ignored,
|
35559 | unignored
|
35560 | };
|
35561 | }
|
35562 |
|
35563 |
|
35564 | _test(originalPath, cache, checkUnignored, slices) {
|
35565 | const path = originalPath
|
35566 | && checkPath.convert(originalPath);
|
35567 | checkPath(path, originalPath, throwError);
|
35568 | return this._t(path, cache, checkUnignored, slices);
|
35569 | }
|
35570 |
|
35571 | _t(path, cache, checkUnignored, slices) {
|
35572 | if (path in cache) {
|
35573 | return cache[path];
|
35574 | }
|
35575 |
|
35576 | if (!slices) {
|
35577 |
|
35578 |
|
35579 | slices = path.split(SLASH$1);
|
35580 | }
|
35581 |
|
35582 | slices.pop();
|
35583 |
|
35584 | if (!slices.length) {
|
35585 | return cache[path] = this._testOne(path, checkUnignored);
|
35586 | }
|
35587 |
|
35588 | const parent = this._t(slices.join(SLASH$1) + SLASH$1, cache, checkUnignored, slices);
|
35589 |
|
35590 |
|
35591 | return cache[path] = parent.ignored
|
35592 |
|
35593 | ? parent : this._testOne(path, checkUnignored);
|
35594 | }
|
35595 |
|
35596 | ignores(path) {
|
35597 | return this._test(path, this._ignoreCache, false).ignored;
|
35598 | }
|
35599 |
|
35600 | createFilter() {
|
35601 | return path => !this.ignores(path);
|
35602 | }
|
35603 |
|
35604 | filter(paths) {
|
35605 | return makeArray(paths).filter(this.createFilter());
|
35606 | }
|
35607 |
|
35608 |
|
35609 | test(path) {
|
35610 | return this._test(path, this._testCache, true);
|
35611 | }
|
35612 |
|
35613 | }
|
35614 |
|
35615 | const factory = options => new Ignore(options);
|
35616 |
|
35617 | const returnFalse = () => false;
|
35618 |
|
35619 | const isPathValid = path => checkPath(path && checkPath.convert(path), path, returnFalse);
|
35620 |
|
35621 | factory.isPathValid = isPathValid;
|
35622 |
|
35623 | factory.default = factory;
|
35624 | var ignore$1 = factory;
|
35625 |
|
35626 |
|
35627 |
|
35628 |
|
35629 | if (
|
35630 | typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
|
35631 |
|
35632 | const makePosix = str => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, '/');
|
35633 |
|
35634 | checkPath.convert = makePosix;
|
35635 |
|
35636 |
|
35637 | const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
35638 |
|
35639 | checkPath.isNotRelative = path => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
|
35640 | }
|
35641 |
|
35642 | var slash$1 = path => {
|
35643 | const isExtendedLengthPath = /^\\\\\?\\/.test(path);
|
35644 | const hasNonAscii = /[^\u0000-\u0080]+/.test(path);
|
35645 |
|
35646 | if (isExtendedLengthPath || hasNonAscii) {
|
35647 | return path;
|
35648 | }
|
35649 |
|
35650 | return path.replace(/\\/g, '/');
|
35651 | };
|
35652 |
|
35653 | const {
|
35654 | promisify: promisify$1
|
35655 | } = util$4;
|
35656 | const DEFAULT_IGNORE = ['**/node_modules/**', '**/flow-typed/**', '**/coverage/**', '**/.git'];
|
35657 | const readFileP = promisify$1(fs$3.readFile);
|
35658 |
|
35659 | const mapGitIgnorePatternTo = base => ignore => {
|
35660 | if (ignore.startsWith('!')) {
|
35661 | return '!' + path$2.posix.join(base, ignore.slice(1));
|
35662 | }
|
35663 |
|
35664 | return path$2.posix.join(base, ignore);
|
35665 | };
|
35666 |
|
35667 | const parseGitIgnore = (content, options) => {
|
35668 | const base = slash$1(path$2.relative(options.cwd, path$2.dirname(options.fileName)));
|
35669 | return content.split(/\r?\n/).filter(Boolean).filter(line => !line.startsWith('#')).map(mapGitIgnorePatternTo(base));
|
35670 | };
|
35671 |
|
35672 | const reduceIgnore = files => {
|
35673 | return files.reduce((ignores, file) => {
|
35674 | ignores.add(parseGitIgnore(file.content, {
|
35675 | cwd: file.cwd,
|
35676 | fileName: file.filePath
|
35677 | }));
|
35678 | return ignores;
|
35679 | }, ignore$1());
|
35680 | };
|
35681 |
|
35682 | const ensureAbsolutePathForCwd = (cwd, p) => {
|
35683 | if (path$2.isAbsolute(p)) {
|
35684 | if (p.startsWith(cwd)) {
|
35685 | return p;
|
35686 | }
|
35687 |
|
35688 | throw new Error(`Path ${p} is not in cwd ${cwd}`);
|
35689 | }
|
35690 |
|
35691 | return path$2.join(cwd, p);
|
35692 | };
|
35693 |
|
35694 | const getIsIgnoredPredecate = (ignores, cwd) => {
|
35695 | return p => ignores.ignores(slash$1(path$2.relative(cwd, ensureAbsolutePathForCwd(cwd, p))));
|
35696 | };
|
35697 |
|
35698 | const getFile = async (file, cwd) => {
|
35699 | const filePath = path$2.join(cwd, file);
|
35700 | const content = await readFileP(filePath, 'utf8');
|
35701 | return {
|
35702 | cwd,
|
35703 | filePath,
|
35704 | content
|
35705 | };
|
35706 | };
|
35707 |
|
35708 | const getFileSync = (file, cwd) => {
|
35709 | const filePath = path$2.join(cwd, file);
|
35710 | const content = fs$3.readFileSync(filePath, 'utf8');
|
35711 | return {
|
35712 | cwd,
|
35713 | filePath,
|
35714 | content
|
35715 | };
|
35716 | };
|
35717 |
|
35718 | const normalizeOptions$3 = ({
|
35719 | ignore = [],
|
35720 | cwd = slash$1(process.cwd())
|
35721 | } = {}) => {
|
35722 | return {
|
35723 | ignore,
|
35724 | cwd
|
35725 | };
|
35726 | };
|
35727 |
|
35728 | var gitignore = async options => {
|
35729 | options = normalizeOptions$3(options);
|
35730 | const paths = await out$3('**/.gitignore', {
|
35731 | ignore: DEFAULT_IGNORE.concat(options.ignore),
|
35732 | cwd: options.cwd
|
35733 | });
|
35734 | const files = await Promise.all(paths.map(file => getFile(file, options.cwd)));
|
35735 | const ignores = reduceIgnore(files);
|
35736 | return getIsIgnoredPredecate(ignores, options.cwd);
|
35737 | };
|
35738 |
|
35739 | var sync$8 = options => {
|
35740 | options = normalizeOptions$3(options);
|
35741 | const paths = out$3.sync('**/.gitignore', {
|
35742 | ignore: DEFAULT_IGNORE.concat(options.ignore),
|
35743 | cwd: options.cwd
|
35744 | });
|
35745 | const files = paths.map(file => getFileSync(file, options.cwd));
|
35746 | const ignores = reduceIgnore(files);
|
35747 | return getIsIgnoredPredecate(ignores, options.cwd);
|
35748 | };
|
35749 | gitignore.sync = sync$8;
|
35750 |
|
35751 | const {
|
35752 | Transform
|
35753 | } = stream$6;
|
35754 |
|
35755 | class ObjectTransform extends Transform {
|
35756 | constructor() {
|
35757 | super({
|
35758 | objectMode: true
|
35759 | });
|
35760 | }
|
35761 |
|
35762 | }
|
35763 |
|
35764 | class FilterStream extends ObjectTransform {
|
35765 | constructor(filter) {
|
35766 | super();
|
35767 | this._filter = filter;
|
35768 | }
|
35769 |
|
35770 | _transform(data, encoding, callback) {
|
35771 | if (this._filter(data)) {
|
35772 | this.push(data);
|
35773 | }
|
35774 |
|
35775 | callback();
|
35776 | }
|
35777 |
|
35778 | }
|
35779 |
|
35780 | class UniqueStream extends ObjectTransform {
|
35781 | constructor() {
|
35782 | super();
|
35783 | this._pushed = new Set();
|
35784 | }
|
35785 |
|
35786 | _transform(data, encoding, callback) {
|
35787 | if (!this._pushed.has(data)) {
|
35788 | this.push(data);
|
35789 |
|
35790 | this._pushed.add(data);
|
35791 | }
|
35792 |
|
35793 | callback();
|
35794 | }
|
35795 |
|
35796 | }
|
35797 |
|
35798 | var streamUtils = {
|
35799 | FilterStream,
|
35800 | UniqueStream
|
35801 | };
|
35802 |
|
35803 | const {
|
35804 | FilterStream: FilterStream$1,
|
35805 | UniqueStream: UniqueStream$1
|
35806 | } = streamUtils;
|
35807 |
|
35808 | const DEFAULT_FILTER = () => false;
|
35809 |
|
35810 | const isNegative = pattern => pattern[0] === '!';
|
35811 |
|
35812 | const assertPatternsInput$1 = patterns => {
|
35813 | if (!patterns.every(pattern => typeof pattern === 'string')) {
|
35814 | throw new TypeError('Patterns must be a string or an array of strings');
|
35815 | }
|
35816 | };
|
35817 |
|
35818 | const checkCwdOption = (options = {}) => {
|
35819 | if (!options.cwd) {
|
35820 | return;
|
35821 | }
|
35822 |
|
35823 | let stat;
|
35824 |
|
35825 | try {
|
35826 | stat = fs$3.statSync(options.cwd);
|
35827 | } catch (_) {
|
35828 | return;
|
35829 | }
|
35830 |
|
35831 | if (!stat.isDirectory()) {
|
35832 | throw new Error('The `cwd` option must be a path to a directory');
|
35833 | }
|
35834 | };
|
35835 |
|
35836 | const getPathString = p => p.stats instanceof fs$3.Stats ? p.path : p;
|
35837 |
|
35838 | const generateGlobTasks = (patterns, taskOptions) => {
|
35839 | patterns = arrayUnion([].concat(patterns));
|
35840 | assertPatternsInput$1(patterns);
|
35841 | checkCwdOption(taskOptions);
|
35842 | const globTasks = [];
|
35843 | taskOptions = Object.assign({
|
35844 | ignore: [],
|
35845 | expandDirectories: true
|
35846 | }, taskOptions);
|
35847 |
|
35848 | for (const [index, pattern] of patterns.entries()) {
|
35849 | if (isNegative(pattern)) {
|
35850 | continue;
|
35851 | }
|
35852 |
|
35853 | const ignore = patterns.slice(index).filter(isNegative).map(pattern => pattern.slice(1));
|
35854 | const options = Object.assign({}, taskOptions, {
|
35855 | ignore: taskOptions.ignore.concat(ignore)
|
35856 | });
|
35857 | globTasks.push({
|
35858 | pattern,
|
35859 | options
|
35860 | });
|
35861 | }
|
35862 |
|
35863 | return globTasks;
|
35864 | };
|
35865 |
|
35866 | const globDirs = (task, fn) => {
|
35867 | let options = {};
|
35868 |
|
35869 | if (task.options.cwd) {
|
35870 | options.cwd = task.options.cwd;
|
35871 | }
|
35872 |
|
35873 | if (Array.isArray(task.options.expandDirectories)) {
|
35874 | options = Object.assign({}, options, {
|
35875 | files: task.options.expandDirectories
|
35876 | });
|
35877 | } else if (typeof task.options.expandDirectories === 'object') {
|
35878 | options = Object.assign({}, options, {}, task.options.expandDirectories);
|
35879 | }
|
35880 |
|
35881 | return fn(task.pattern, options);
|
35882 | };
|
35883 |
|
35884 | const getPattern = (task, fn) => task.options.expandDirectories ? globDirs(task, fn) : [task.pattern];
|
35885 |
|
35886 | const getFilterSync = options => {
|
35887 | return options && options.gitignore ? gitignore.sync({
|
35888 | cwd: options.cwd,
|
35889 | ignore: options.ignore
|
35890 | }) : DEFAULT_FILTER;
|
35891 | };
|
35892 |
|
35893 | const globToTask = task => glob => {
|
35894 | const {
|
35895 | options
|
35896 | } = task;
|
35897 |
|
35898 | if (options.ignore && Array.isArray(options.ignore) && options.expandDirectories) {
|
35899 | options.ignore = dirGlob.sync(options.ignore);
|
35900 | }
|
35901 |
|
35902 | return {
|
35903 | pattern: glob,
|
35904 | options
|
35905 | };
|
35906 | };
|
35907 |
|
35908 | var globby$1 = async (patterns, options) => {
|
35909 | const globTasks = generateGlobTasks(patterns, options);
|
35910 |
|
35911 | const getFilter = async () => {
|
35912 | return options && options.gitignore ? gitignore({
|
35913 | cwd: options.cwd,
|
35914 | ignore: options.ignore
|
35915 | }) : DEFAULT_FILTER;
|
35916 | };
|
35917 |
|
35918 | const getTasks = async () => {
|
35919 | const tasks = await Promise.all(globTasks.map(async task => {
|
35920 | const globs = await getPattern(task, dirGlob);
|
35921 | return Promise.all(globs.map(globToTask(task)));
|
35922 | }));
|
35923 | return arrayUnion(...tasks);
|
35924 | };
|
35925 |
|
35926 | const [filter, tasks] = await Promise.all([getFilter(), getTasks()]);
|
35927 | const paths = await Promise.all(tasks.map(task => out$3(task.pattern, task.options)));
|
35928 | return arrayUnion(...paths).filter(path_ => !filter(getPathString(path_)));
|
35929 | };
|
35930 |
|
35931 | var sync$9 = (patterns, options) => {
|
35932 | const globTasks = generateGlobTasks(patterns, options);
|
35933 | const tasks = globTasks.reduce((tasks, task) => {
|
35934 | const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
|
35935 | return tasks.concat(newTask);
|
35936 | }, []);
|
35937 | const filter = getFilterSync(options);
|
35938 | return tasks.reduce((matches, task) => arrayUnion(matches, out$3.sync(task.pattern, task.options)), []).filter(path_ => !filter(path_));
|
35939 | };
|
35940 |
|
35941 | var stream$5 = (patterns, options) => {
|
35942 | const globTasks = generateGlobTasks(patterns, options);
|
35943 | const tasks = globTasks.reduce((tasks, task) => {
|
35944 | const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
|
35945 | return tasks.concat(newTask);
|
35946 | }, []);
|
35947 | const filter = getFilterSync(options);
|
35948 | const filterStream = new FilterStream$1(p => !filter(p));
|
35949 | const uniqueStream = new UniqueStream$1();
|
35950 | return merge2_1(tasks.map(task => out$3.stream(task.pattern, task.options))).pipe(filterStream).pipe(uniqueStream);
|
35951 | };
|
35952 |
|
35953 | var generateGlobTasks_1 = generateGlobTasks;
|
35954 |
|
35955 | var hasMagic = (patterns, options) => [].concat(patterns).some(pattern => out$3.isDynamicPattern(pattern, options));
|
35956 |
|
35957 | var gitignore_1 = gitignore;
|
35958 | globby$1.sync = sync$9;
|
35959 | globby$1.stream = stream$5;
|
35960 | globby$1.generateGlobTasks = generateGlobTasks_1;
|
35961 | globby$1.hasMagic = hasMagic;
|
35962 | globby$1.gitignore = gitignore_1;
|
35963 |
|
35964 | const {
|
35965 | addLeadingComment: addLeadingComment$3,
|
35966 | addTrailingComment: addTrailingComment$3,
|
35967 | addDanglingComment: addDanglingComment$3,
|
35968 | getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$2
|
35969 | } = utilShared;
|
35970 |
|
35971 | function handleOwnLineComment(comment, text, options, ast, isLastComment) {
|
35972 | const {
|
35973 | precedingNode,
|
35974 | enclosingNode,
|
35975 | followingNode
|
35976 | } = comment;
|
35977 | return handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleMemberExpressionComments(enclosingNode, followingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleImportSpecifierComments(enclosingNode, comment) || handleForComments(enclosingNode, precedingNode, comment) || handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) || handleAssignmentPatternComments(enclosingNode, comment) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) || handleLabeledStatementComments(enclosingNode, comment);
|
35978 | }
|
35979 |
|
35980 | function handleEndOfLineComment(comment, text, options, ast, isLastComment) {
|
35981 | const {
|
35982 | precedingNode,
|
35983 | enclosingNode,
|
35984 | followingNode
|
35985 | } = comment;
|
35986 | return handleClosureTypeCastComments(followingNode, comment) || handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) || handleImportSpecifierComments(enclosingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleLabeledStatementComments(enclosingNode, comment) || handleCallExpressionComments(precedingNode, enclosingNode, comment) || handlePropertyComments(enclosingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleTypeAliasComments(enclosingNode, followingNode, comment) || handleVariableDeclaratorComments(enclosingNode, followingNode, comment);
|
35987 | }
|
35988 |
|
35989 | function handleRemainingComment(comment, text, options, ast, isLastComment) {
|
35990 | const {
|
35991 | precedingNode,
|
35992 | enclosingNode,
|
35993 | followingNode
|
35994 | } = comment;
|
35995 |
|
35996 | if (handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) || handleCommentInEmptyParens(text, enclosingNode, comment, options) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleCommentAfterArrowParams(text, enclosingNode, comment, options) || handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) || handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) || handleBreakAndContinueStatementComments(enclosingNode, comment) || handleTSFunctionTrailingComments(text, enclosingNode, followingNode, comment, options)) {
|
35997 | return true;
|
35998 | }
|
35999 |
|
36000 | return false;
|
36001 | }
|
36002 |
|
36003 | function addBlockStatementFirstComment(node, comment) {
|
36004 | const body = node.body.filter(n => n.type !== "EmptyStatement");
|
36005 |
|
36006 | if (body.length === 0) {
|
36007 | addDanglingComment$3(node, comment);
|
36008 | } else {
|
36009 | addLeadingComment$3(body[0], comment);
|
36010 | }
|
36011 | }
|
36012 |
|
36013 | function addBlockOrNotComment(node, comment) {
|
36014 | if (node.type === "BlockStatement") {
|
36015 | addBlockStatementFirstComment(node, comment);
|
36016 | } else {
|
36017 | addLeadingComment$3(node, comment);
|
36018 | }
|
36019 | }
|
36020 |
|
36021 | function handleClosureTypeCastComments(followingNode, comment) {
|
36022 | if (followingNode && isTypeCastComment(comment)) {
|
36023 | addLeadingComment$3(followingNode, comment);
|
36024 | return true;
|
36025 | }
|
36026 |
|
36027 | return false;
|
36028 | }
|
36029 |
|
36030 |
|
36031 |
|
36032 |
|
36033 |
|
36034 |
|
36035 |
|
36036 |
|
36037 |
|
36038 |
|
36039 |
|
36040 |
|
36041 |
|
36042 |
|
36043 |
|
36044 |
|
36045 |
|
36046 | function handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
|
36047 | if (!enclosingNode || enclosingNode.type !== "IfStatement" || !followingNode) {
|
36048 | return false;
|
36049 | }
|
36050 |
|
36051 |
|
36052 |
|
36053 |
|
36054 |
|
36055 |
|
36056 | const nextCharacter = util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
|
36057 |
|
36058 | if (nextCharacter === ")") {
|
36059 | addTrailingComment$3(precedingNode, comment);
|
36060 | return true;
|
36061 | }
|
36062 |
|
36063 |
|
36064 |
|
36065 |
|
36066 | if (precedingNode === enclosingNode.consequent && followingNode === enclosingNode.alternate) {
|
36067 | if (precedingNode.type === "BlockStatement") {
|
36068 | addTrailingComment$3(precedingNode, comment);
|
36069 | } else {
|
36070 | addDanglingComment$3(enclosingNode, comment);
|
36071 | }
|
36072 |
|
36073 | return true;
|
36074 | }
|
36075 |
|
36076 | if (followingNode.type === "BlockStatement") {
|
36077 | addBlockStatementFirstComment(followingNode, comment);
|
36078 | return true;
|
36079 | }
|
36080 |
|
36081 | if (followingNode.type === "IfStatement") {
|
36082 | addBlockOrNotComment(followingNode.consequent, comment);
|
36083 | return true;
|
36084 | }
|
36085 |
|
36086 |
|
36087 |
|
36088 |
|
36089 |
|
36090 |
|
36091 | if (enclosingNode.consequent === followingNode) {
|
36092 | addLeadingComment$3(followingNode, comment);
|
36093 | return true;
|
36094 | }
|
36095 |
|
36096 | return false;
|
36097 | }
|
36098 |
|
36099 | function handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
|
36100 | if (!enclosingNode || enclosingNode.type !== "WhileStatement" || !followingNode) {
|
36101 | return false;
|
36102 | }
|
36103 |
|
36104 |
|
36105 |
|
36106 |
|
36107 |
|
36108 |
|
36109 | const nextCharacter = util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
|
36110 |
|
36111 | if (nextCharacter === ")") {
|
36112 | addTrailingComment$3(precedingNode, comment);
|
36113 | return true;
|
36114 | }
|
36115 |
|
36116 | if (followingNode.type === "BlockStatement") {
|
36117 | addBlockStatementFirstComment(followingNode, comment);
|
36118 | return true;
|
36119 | }
|
36120 |
|
36121 | return false;
|
36122 | }
|
36123 |
|
36124 |
|
36125 | function handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) {
|
36126 | if (!enclosingNode || enclosingNode.type !== "TryStatement" && enclosingNode.type !== "CatchClause" || !followingNode) {
|
36127 | return false;
|
36128 | }
|
36129 |
|
36130 | if (enclosingNode.type === "CatchClause" && precedingNode) {
|
36131 | addTrailingComment$3(precedingNode, comment);
|
36132 | return true;
|
36133 | }
|
36134 |
|
36135 | if (followingNode.type === "BlockStatement") {
|
36136 | addBlockStatementFirstComment(followingNode, comment);
|
36137 | return true;
|
36138 | }
|
36139 |
|
36140 | if (followingNode.type === "TryStatement") {
|
36141 | addBlockOrNotComment(followingNode.finalizer, comment);
|
36142 | return true;
|
36143 | }
|
36144 |
|
36145 | if (followingNode.type === "CatchClause") {
|
36146 | addBlockOrNotComment(followingNode.body, comment);
|
36147 | return true;
|
36148 | }
|
36149 |
|
36150 | return false;
|
36151 | }
|
36152 |
|
36153 | function handleMemberExpressionComments(enclosingNode, followingNode, comment) {
|
36154 | if (enclosingNode && (enclosingNode.type === "MemberExpression" || enclosingNode.type === "OptionalMemberExpression") && followingNode && followingNode.type === "Identifier") {
|
36155 | addLeadingComment$3(enclosingNode, comment);
|
36156 | return true;
|
36157 | }
|
36158 |
|
36159 | return false;
|
36160 | }
|
36161 |
|
36162 | function handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) {
|
36163 | const isSameLineAsPrecedingNode = precedingNode && !util$1.hasNewlineInRange(text, options.locEnd(precedingNode), options.locStart(comment));
|
36164 |
|
36165 | if ((!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && enclosingNode.type === "ConditionalExpression" && followingNode) {
|
36166 | addLeadingComment$3(followingNode, comment);
|
36167 | return true;
|
36168 | }
|
36169 |
|
36170 | return false;
|
36171 | }
|
36172 |
|
36173 | function handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) {
|
36174 | if (enclosingNode && (enclosingNode.type === "ObjectProperty" || enclosingNode.type === "Property") && enclosingNode.shorthand && enclosingNode.key === precedingNode && enclosingNode.value.type === "AssignmentPattern") {
|
36175 | addTrailingComment$3(enclosingNode.value.left, comment);
|
36176 | return true;
|
36177 | }
|
36178 |
|
36179 | return false;
|
36180 | }
|
36181 |
|
36182 | function handleClassComments(enclosingNode, precedingNode, followingNode, comment) {
|
36183 | if (enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression") && enclosingNode.decorators && enclosingNode.decorators.length > 0 && !(followingNode && followingNode.type === "Decorator")) {
|
36184 | if (!enclosingNode.decorators || enclosingNode.decorators.length === 0) {
|
36185 | addLeadingComment$3(enclosingNode, comment);
|
36186 | } else {
|
36187 | addTrailingComment$3(enclosingNode.decorators[enclosingNode.decorators.length - 1], comment);
|
36188 | }
|
36189 |
|
36190 | return true;
|
36191 | }
|
36192 |
|
36193 | return false;
|
36194 | }
|
36195 |
|
36196 | function handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) {
|
36197 |
|
36198 |
|
36199 |
|
36200 | if (enclosingNode && precedingNode && (
|
36201 | enclosingNode.type === "Property" || enclosingNode.type === "TSDeclareMethod" || enclosingNode.type === "TSAbstractMethodDefinition") && precedingNode.type === "Identifier" && enclosingNode.key === precedingNode &&
|
36202 |
|
36203 | util$1.getNextNonSpaceNonCommentCharacter(text, precedingNode, options.locEnd) !== ":") {
|
36204 | addTrailingComment$3(precedingNode, comment);
|
36205 | return true;
|
36206 | }
|
36207 |
|
36208 |
|
36209 |
|
36210 | if (precedingNode && enclosingNode && precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "TSAbstractClassProperty" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "TSDeclareMethod" || enclosingNode.type === "MethodDefinition")) {
|
36211 | addTrailingComment$3(precedingNode, comment);
|
36212 | return true;
|
36213 | }
|
36214 |
|
36215 | return false;
|
36216 | }
|
36217 |
|
36218 | function handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) {
|
36219 | if (util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== "(") {
|
36220 | return false;
|
36221 | }
|
36222 |
|
36223 | if (precedingNode && enclosingNode && (enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "MethodDefinition" || enclosingNode.type === "ObjectMethod")) {
|
36224 | addTrailingComment$3(precedingNode, comment);
|
36225 | return true;
|
36226 | }
|
36227 |
|
36228 | return false;
|
36229 | }
|
36230 |
|
36231 | function handleCommentAfterArrowParams(text, enclosingNode, comment, options) {
|
36232 | if (!(enclosingNode && enclosingNode.type === "ArrowFunctionExpression")) {
|
36233 | return false;
|
36234 | }
|
36235 |
|
36236 | const index = getNextNonSpaceNonCommentCharacterIndex$2(text, comment, options.locEnd);
|
36237 |
|
36238 | if (text.slice(index, index + 2) === "=>") {
|
36239 | addDanglingComment$3(enclosingNode, comment);
|
36240 | return true;
|
36241 | }
|
36242 |
|
36243 | return false;
|
36244 | }
|
36245 |
|
36246 | function handleCommentInEmptyParens(text, enclosingNode, comment, options) {
|
36247 | if (util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== ")") {
|
36248 | return false;
|
36249 | }
|
36250 |
|
36251 |
|
36252 |
|
36253 | if (enclosingNode && (isRealFunctionLikeNode(enclosingNode) &&
|
36254 | (enclosingNode.params || enclosingNode.parameters).length === 0 || (enclosingNode.type === "CallExpression" || enclosingNode.type === "OptionalCallExpression" || enclosingNode.type === "NewExpression") && enclosingNode.arguments.length === 0)) {
|
36255 | addDanglingComment$3(enclosingNode, comment);
|
36256 | return true;
|
36257 | }
|
36258 |
|
36259 | if (enclosingNode && enclosingNode.type === "MethodDefinition" && enclosingNode.value.params.length === 0) {
|
36260 | addDanglingComment$3(enclosingNode.value, comment);
|
36261 | return true;
|
36262 | }
|
36263 |
|
36264 | return false;
|
36265 | }
|
36266 |
|
36267 | function handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
|
36268 |
|
36269 | if (precedingNode && precedingNode.type === "FunctionTypeParam" && enclosingNode && enclosingNode.type === "FunctionTypeAnnotation" && followingNode && followingNode.type !== "FunctionTypeParam") {
|
36270 | addTrailingComment$3(precedingNode, comment);
|
36271 | return true;
|
36272 | }
|
36273 |
|
36274 |
|
36275 | if (precedingNode && (precedingNode.type === "Identifier" || precedingNode.type === "AssignmentPattern") && enclosingNode && isRealFunctionLikeNode(enclosingNode) && util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) === ")") {
|
36276 | addTrailingComment$3(precedingNode, comment);
|
36277 | return true;
|
36278 | }
|
36279 |
|
36280 | if (enclosingNode && enclosingNode.type === "FunctionDeclaration" && followingNode && followingNode.type === "BlockStatement") {
|
36281 | const functionParamRightParenIndex = (() => {
|
36282 | if ((enclosingNode.params || enclosingNode.parameters).length !== 0) {
|
36283 | return util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(util$1.getLast(enclosingNode.params || enclosingNode.parameters)));
|
36284 | }
|
36285 |
|
36286 | const functionParamLeftParenIndex = util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(enclosingNode.id));
|
36287 | return util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, functionParamLeftParenIndex + 1);
|
36288 | })();
|
36289 |
|
36290 | if (options.locStart(comment) > functionParamRightParenIndex) {
|
36291 | addBlockStatementFirstComment(followingNode, comment);
|
36292 | return true;
|
36293 | }
|
36294 | }
|
36295 |
|
36296 | return false;
|
36297 | }
|
36298 |
|
36299 | function handleImportSpecifierComments(enclosingNode, comment) {
|
36300 | if (enclosingNode && enclosingNode.type === "ImportSpecifier") {
|
36301 | addLeadingComment$3(enclosingNode, comment);
|
36302 | return true;
|
36303 | }
|
36304 |
|
36305 | return false;
|
36306 | }
|
36307 |
|
36308 | function handleLabeledStatementComments(enclosingNode, comment) {
|
36309 | if (enclosingNode && enclosingNode.type === "LabeledStatement") {
|
36310 | addLeadingComment$3(enclosingNode, comment);
|
36311 | return true;
|
36312 | }
|
36313 |
|
36314 | return false;
|
36315 | }
|
36316 |
|
36317 | function handleBreakAndContinueStatementComments(enclosingNode, comment) {
|
36318 | if (enclosingNode && (enclosingNode.type === "ContinueStatement" || enclosingNode.type === "BreakStatement") && !enclosingNode.label) {
|
36319 | addTrailingComment$3(enclosingNode, comment);
|
36320 | return true;
|
36321 | }
|
36322 |
|
36323 | return false;
|
36324 | }
|
36325 |
|
36326 | function handleCallExpressionComments(precedingNode, enclosingNode, comment) {
|
36327 | if (enclosingNode && (enclosingNode.type === "CallExpression" || enclosingNode.type === "OptionalCallExpression") && precedingNode && enclosingNode.callee === precedingNode && enclosingNode.arguments.length > 0) {
|
36328 | addLeadingComment$3(enclosingNode.arguments[0], comment);
|
36329 | return true;
|
36330 | }
|
36331 |
|
36332 | return false;
|
36333 | }
|
36334 |
|
36335 | function handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) {
|
36336 | if (enclosingNode && (enclosingNode.type === "UnionTypeAnnotation" || enclosingNode.type === "TSUnionType")) {
|
36337 | if (util$1.isNodeIgnoreComment(comment)) {
|
36338 | followingNode.prettierIgnore = true;
|
36339 | comment.unignore = true;
|
36340 | }
|
36341 |
|
36342 | if (precedingNode) {
|
36343 | addTrailingComment$3(precedingNode, comment);
|
36344 | return true;
|
36345 | }
|
36346 |
|
36347 | return false;
|
36348 | }
|
36349 |
|
36350 | if (followingNode && (followingNode.type === "UnionTypeAnnotation" || followingNode.type === "TSUnionType") && util$1.isNodeIgnoreComment(comment)) {
|
36351 | followingNode.types[0].prettierIgnore = true;
|
36352 | comment.unignore = true;
|
36353 | }
|
36354 |
|
36355 | return false;
|
36356 | }
|
36357 |
|
36358 | function handlePropertyComments(enclosingNode, comment) {
|
36359 | if (enclosingNode && (enclosingNode.type === "Property" || enclosingNode.type === "ObjectProperty")) {
|
36360 | addLeadingComment$3(enclosingNode, comment);
|
36361 | return true;
|
36362 | }
|
36363 |
|
36364 | return false;
|
36365 | }
|
36366 |
|
36367 | function handleOnlyComments(enclosingNode, ast, comment, isLastComment) {
|
36368 |
|
36369 | if (ast && ast.body && ast.body.length === 0) {
|
36370 | if (isLastComment) {
|
36371 | addDanglingComment$3(ast, comment);
|
36372 | } else {
|
36373 | addLeadingComment$3(ast, comment);
|
36374 | }
|
36375 |
|
36376 | return true;
|
36377 | } else if (enclosingNode && enclosingNode.type === "Program" && enclosingNode.body.length === 0 && enclosingNode.directives && enclosingNode.directives.length === 0) {
|
36378 | if (isLastComment) {
|
36379 | addDanglingComment$3(enclosingNode, comment);
|
36380 | } else {
|
36381 | addLeadingComment$3(enclosingNode, comment);
|
36382 | }
|
36383 |
|
36384 | return true;
|
36385 | }
|
36386 |
|
36387 | return false;
|
36388 | }
|
36389 |
|
36390 | function handleForComments(enclosingNode, precedingNode, comment) {
|
36391 | if (enclosingNode && (enclosingNode.type === "ForInStatement" || enclosingNode.type === "ForOfStatement")) {
|
36392 | addLeadingComment$3(enclosingNode, comment);
|
36393 | return true;
|
36394 | }
|
36395 |
|
36396 | return false;
|
36397 | }
|
36398 |
|
36399 | function handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) {
|
36400 | if (precedingNode && precedingNode.type === "ImportSpecifier" && enclosingNode && enclosingNode.type === "ImportDeclaration" && util$1.hasNewline(text, options.locEnd(comment))) {
|
36401 | addTrailingComment$3(precedingNode, comment);
|
36402 | return true;
|
36403 | }
|
36404 |
|
36405 | return false;
|
36406 | }
|
36407 |
|
36408 | function handleAssignmentPatternComments(enclosingNode, comment) {
|
36409 | if (enclosingNode && enclosingNode.type === "AssignmentPattern") {
|
36410 | addLeadingComment$3(enclosingNode, comment);
|
36411 | return true;
|
36412 | }
|
36413 |
|
36414 | return false;
|
36415 | }
|
36416 |
|
36417 | function handleTypeAliasComments(enclosingNode, followingNode, comment) {
|
36418 | if (enclosingNode && enclosingNode.type === "TypeAlias") {
|
36419 | addLeadingComment$3(enclosingNode, comment);
|
36420 | return true;
|
36421 | }
|
36422 |
|
36423 | return false;
|
36424 | }
|
36425 |
|
36426 | function handleVariableDeclaratorComments(enclosingNode, followingNode, comment) {
|
36427 | if (enclosingNode && (enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression") && followingNode && (followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression" || isBlockComment(comment))) {
|
36428 | addLeadingComment$3(followingNode, comment);
|
36429 | return true;
|
36430 | }
|
36431 |
|
36432 | return false;
|
36433 | }
|
36434 |
|
36435 | function handleTSFunctionTrailingComments(text, enclosingNode, followingNode, comment, options) {
|
36436 | if (!followingNode && enclosingNode && (enclosingNode.type === "TSMethodSignature" || enclosingNode.type === "TSDeclareFunction" || enclosingNode.type === "TSAbstractMethodDefinition") && util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) === ";") {
|
36437 | addTrailingComment$3(enclosingNode, comment);
|
36438 | return true;
|
36439 | }
|
36440 |
|
36441 | return false;
|
36442 | }
|
36443 |
|
36444 | function handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) {
|
36445 | if (!enclosingNode || enclosingNode.type !== "TSMappedType") {
|
36446 | return false;
|
36447 | }
|
36448 |
|
36449 | if (followingNode && followingNode.type === "TSTypeParameter" && followingNode.name) {
|
36450 | addLeadingComment$3(followingNode.name, comment);
|
36451 | return true;
|
36452 | }
|
36453 |
|
36454 | if (precedingNode && precedingNode.type === "TSTypeParameter" && precedingNode.constraint) {
|
36455 | addTrailingComment$3(precedingNode.constraint, comment);
|
36456 | return true;
|
36457 | }
|
36458 |
|
36459 | return false;
|
36460 | }
|
36461 |
|
36462 | function isBlockComment(comment) {
|
36463 | return comment.type === "Block" || comment.type === "CommentBlock";
|
36464 | }
|
36465 |
|
36466 | function hasLeadingComment(node, fn = () => true) {
|
36467 | if (node.leadingComments) {
|
36468 | return node.leadingComments.some(fn);
|
36469 | }
|
36470 |
|
36471 | if (node.comments) {
|
36472 | return node.comments.some(comment => comment.leading && fn(comment));
|
36473 | }
|
36474 |
|
36475 | return false;
|
36476 | }
|
36477 |
|
36478 | function isRealFunctionLikeNode(node) {
|
36479 | return node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression" || node.type === "FunctionDeclaration" || node.type === "ObjectMethod" || node.type === "ClassMethod" || node.type === "TSDeclareFunction" || node.type === "TSCallSignatureDeclaration" || node.type === "TSConstructSignatureDeclaration" || node.type === "TSConstructSignatureDeclaration" || node.type === "TSMethodSignature" || node.type === "TSConstructorType" || node.type === "TSFunctionType" || node.type === "TSDeclareMethod";
|
36480 | }
|
36481 |
|
36482 | function getGapRegex(enclosingNode) {
|
36483 | if (enclosingNode && enclosingNode.type !== "BinaryExpression" && enclosingNode.type !== "LogicalExpression") {
|
36484 |
|
36485 |
|
36486 | return /^[\s(&|]*$/;
|
36487 | }
|
36488 | }
|
36489 |
|
36490 | function getCommentChildNodes(node, options) {
|
36491 |
|
36492 |
|
36493 |
|
36494 |
|
36495 |
|
36496 |
|
36497 |
|
36498 | if ((options.parser === "typescript" || options.parser === "flow") && node.type === "MethodDefinition" && node.value && node.value.type === "FunctionExpression" && node.value.params.length === 0 && !node.value.returnType && (!node.value.typeParameters || node.value.typeParameters.length === 0) && node.value.body) {
|
36499 | return [...(node.decorators || []), node.key, node.value.body];
|
36500 | }
|
36501 | }
|
36502 |
|
36503 | function isTypeCastComment(comment) {
|
36504 | return isBlockComment(comment) && comment.value[0] === "*" &&
|
36505 |
|
36506 |
|
36507 | /@type\b/.test(comment.value);
|
36508 | }
|
36509 |
|
36510 | var comments$1 = {
|
36511 | handleOwnLineComment,
|
36512 | handleEndOfLineComment,
|
36513 | handleRemainingComment,
|
36514 | hasLeadingComment,
|
36515 | isBlockComment,
|
36516 | isTypeCastComment,
|
36517 | getGapRegex,
|
36518 | getCommentChildNodes
|
36519 | };
|
36520 |
|
36521 | const {
|
36522 | isBlockComment: isBlockComment$1,
|
36523 | hasLeadingComment: hasLeadingComment$1
|
36524 | } = comments$1;
|
36525 | const {
|
36526 | builders: {
|
36527 | indent: indent$2,
|
36528 | join: join$2,
|
36529 | line: line$2,
|
36530 | hardline: hardline$3,
|
36531 | softline: softline$1,
|
36532 | literalline: literalline$1,
|
36533 | concat: concat$4,
|
36534 | group: group$1,
|
36535 | dedentToRoot: dedentToRoot$1
|
36536 | },
|
36537 | utils: {
|
36538 | mapDoc: mapDoc$1,
|
36539 | stripTrailingHardline: stripTrailingHardline$1
|
36540 | }
|
36541 | } = document;
|
36542 |
|
36543 | function embed(path, print, textToDoc, options) {
|
36544 | const node = path.getValue();
|
36545 | const parent = path.getParentNode();
|
36546 | const parentParent = path.getParentNode(1);
|
36547 |
|
36548 | switch (node.type) {
|
36549 | case "TemplateLiteral":
|
36550 | {
|
36551 | const isCss = [isStyledJsx, isStyledComponents, isCssProp, isAngularComponentStyles].some(isIt => isIt(path));
|
36552 |
|
36553 | if (isCss) {
|
36554 |
|
36555 | const rawQuasis = node.quasis.map(q => q.value.raw);
|
36556 | let placeholderID = 0;
|
36557 | const text = rawQuasis.reduce((prevVal, currVal, idx) => {
|
36558 | return idx === 0 ? currVal : prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal;
|
36559 | }, "");
|
36560 | const doc = textToDoc(text, {
|
36561 | parser: "scss"
|
36562 | });
|
36563 | return transformCssDoc(doc, path, print);
|
36564 | }
|
36565 | |
36566 |
|
36567 |
|
36568 |
|
36569 |
|
36570 |
|
36571 |
|
36572 |
|
36573 |
|
36574 |
|
36575 |
|
36576 | if (isGraphQL(path)) {
|
36577 | const expressionDocs = node.expressions ? path.map(print, "expressions") : [];
|
36578 | const numQuasis = node.quasis.length;
|
36579 |
|
36580 | if (numQuasis === 1 && node.quasis[0].value.raw.trim() === "") {
|
36581 | return "``";
|
36582 | }
|
36583 |
|
36584 | const parts = [];
|
36585 |
|
36586 | for (let i = 0; i < numQuasis; i++) {
|
36587 | const templateElement = node.quasis[i];
|
36588 | const isFirst = i === 0;
|
36589 | const isLast = i === numQuasis - 1;
|
36590 | const text = templateElement.value.cooked;
|
36591 |
|
36592 |
|
36593 | if (typeof text !== "string") {
|
36594 | return null;
|
36595 | }
|
36596 |
|
36597 | const lines = text.split("\n");
|
36598 | const numLines = lines.length;
|
36599 | const expressionDoc = expressionDocs[i];
|
36600 | const startsWithBlankLine = numLines > 2 && lines[0].trim() === "" && lines[1].trim() === "";
|
36601 | const endsWithBlankLine = numLines > 2 && lines[numLines - 1].trim() === "" && lines[numLines - 2].trim() === "";
|
36602 | const commentsAndWhitespaceOnly = lines.every(line => /^\s*(?:#[^\r\n]*)?$/.test(line));
|
36603 |
|
36604 | if (!isLast && /#[^\r\n]*$/.test(lines[numLines - 1])) {
|
36605 | return null;
|
36606 | }
|
36607 |
|
36608 | let doc = null;
|
36609 |
|
36610 | if (commentsAndWhitespaceOnly) {
|
36611 | doc = printGraphqlComments(lines);
|
36612 | } else {
|
36613 | doc = stripTrailingHardline$1(textToDoc(text, {
|
36614 | parser: "graphql"
|
36615 | }));
|
36616 | }
|
36617 |
|
36618 | if (doc) {
|
36619 | doc = escapeTemplateCharacters(doc, false);
|
36620 |
|
36621 | if (!isFirst && startsWithBlankLine) {
|
36622 | parts.push("");
|
36623 | }
|
36624 |
|
36625 | parts.push(doc);
|
36626 |
|
36627 | if (!isLast && endsWithBlankLine) {
|
36628 | parts.push("");
|
36629 | }
|
36630 | } else if (!isFirst && !isLast && startsWithBlankLine) {
|
36631 | parts.push("");
|
36632 | }
|
36633 |
|
36634 | if (expressionDoc) {
|
36635 | parts.push(concat$4(["${", expressionDoc, "}"]));
|
36636 | }
|
36637 | }
|
36638 |
|
36639 | return concat$4(["`", indent$2(concat$4([hardline$3, join$2(hardline$3, parts)])), hardline$3, "`"]);
|
36640 | }
|
36641 |
|
36642 | const htmlParser = isHtml(path) ? "html" : isAngularComponentTemplate(path) ? "angular" : undefined;
|
36643 |
|
36644 | if (htmlParser) {
|
36645 | return printHtmlTemplateLiteral(path, print, textToDoc, htmlParser, options);
|
36646 | }
|
36647 |
|
36648 | break;
|
36649 | }
|
36650 |
|
36651 | case "TemplateElement":
|
36652 | {
|
36653 | |
36654 |
|
36655 |
|
36656 |
|
36657 | if (parentParent && parentParent.type === "TaggedTemplateExpression" && parent.quasis.length === 1 && parentParent.tag.type === "Identifier" && (parentParent.tag.name === "md" || parentParent.tag.name === "markdown")) {
|
36658 | const text = parent.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, (_, backslashes) => "\\".repeat(backslashes.length / 2) + "`");
|
36659 | const indentation = getIndentation(text);
|
36660 | const hasIndent = indentation !== "";
|
36661 | return concat$4([hasIndent ? indent$2(concat$4([softline$1, printMarkdown(text.replace(new RegExp(`^${indentation}`, "gm"), ""))])) : concat$4([literalline$1, dedentToRoot$1(printMarkdown(text))]), softline$1]);
|
36662 | }
|
36663 |
|
36664 | break;
|
36665 | }
|
36666 | }
|
36667 |
|
36668 | function printMarkdown(text) {
|
36669 | const doc = textToDoc(text, {
|
36670 | parser: "markdown",
|
36671 | __inJsTemplate: true
|
36672 | });
|
36673 | return stripTrailingHardline$1(escapeTemplateCharacters(doc, true));
|
36674 | }
|
36675 | }
|
36676 |
|
36677 | function getIndentation(str) {
|
36678 | const firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
|
36679 | return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
|
36680 | }
|
36681 |
|
36682 | function uncook(cookedValue) {
|
36683 | return cookedValue.replace(/([\\`]|\$\{)/g, "\\$1");
|
36684 | }
|
36685 |
|
36686 | function escapeTemplateCharacters(doc, raw) {
|
36687 | return mapDoc$1(doc, currentDoc => {
|
36688 | if (!currentDoc.parts) {
|
36689 | return currentDoc;
|
36690 | }
|
36691 |
|
36692 | const parts = [];
|
36693 | currentDoc.parts.forEach(part => {
|
36694 | if (typeof part === "string") {
|
36695 | parts.push(raw ? part.replace(/(\\*)`/g, "$1$1\\`") : uncook(part));
|
36696 | } else {
|
36697 | parts.push(part);
|
36698 | }
|
36699 | });
|
36700 | return Object.assign({}, currentDoc, {
|
36701 | parts
|
36702 | });
|
36703 | });
|
36704 | }
|
36705 |
|
36706 | function transformCssDoc(quasisDoc, path, print) {
|
36707 | const parentNode = path.getValue();
|
36708 | const isEmpty = parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim();
|
36709 |
|
36710 | if (isEmpty) {
|
36711 | return "``";
|
36712 | }
|
36713 |
|
36714 | const expressionDocs = parentNode.expressions ? path.map(print, "expressions") : [];
|
36715 | const newDoc = replacePlaceholders(quasisDoc, expressionDocs);
|
36716 |
|
36717 |
|
36718 | if (!newDoc) {
|
36719 | throw new Error("Couldn't insert all the expressions");
|
36720 | }
|
36721 |
|
36722 | return concat$4(["`", indent$2(concat$4([hardline$3, stripTrailingHardline$1(newDoc)])), softline$1, "`"]);
|
36723 | }
|
36724 |
|
36725 |
|
36726 |
|
36727 |
|
36728 |
|
36729 | function replacePlaceholders(quasisDoc, expressionDocs) {
|
36730 | if (!expressionDocs || !expressionDocs.length) {
|
36731 | return quasisDoc;
|
36732 | }
|
36733 |
|
36734 | const expressions = expressionDocs.slice();
|
36735 | let replaceCounter = 0;
|
36736 | const newDoc = mapDoc$1(quasisDoc, doc => {
|
36737 | if (!doc || !doc.parts || !doc.parts.length) {
|
36738 | return doc;
|
36739 | }
|
36740 |
|
36741 | let {
|
36742 | parts
|
36743 | } = doc;
|
36744 | const atIndex = parts.indexOf("@");
|
36745 | const placeholderIndex = atIndex + 1;
|
36746 |
|
36747 | if (atIndex > -1 && typeof parts[placeholderIndex] === "string" && parts[placeholderIndex].startsWith("prettier-placeholder")) {
|
36748 |
|
36749 | const at = parts[atIndex];
|
36750 | const placeholder = parts[placeholderIndex];
|
36751 | const rest = parts.slice(placeholderIndex + 1);
|
36752 | parts = parts.slice(0, atIndex).concat([at + placeholder]).concat(rest);
|
36753 | }
|
36754 |
|
36755 | const atPlaceholderIndex = parts.findIndex(part => typeof part === "string" && part.startsWith("@prettier-placeholder"));
|
36756 |
|
36757 | if (atPlaceholderIndex > -1) {
|
36758 | const placeholder = parts[atPlaceholderIndex];
|
36759 | const rest = parts.slice(atPlaceholderIndex + 1);
|
36760 | const placeholderMatch = placeholder.match(/@prettier-placeholder-(.+)-id([\s\S]*)/);
|
36761 | const placeholderID = placeholderMatch[1];
|
36762 |
|
36763 |
|
36764 | const suffix = placeholderMatch[2];
|
36765 | const expression = expressions[placeholderID];
|
36766 | replaceCounter++;
|
36767 | parts = parts.slice(0, atPlaceholderIndex).concat(["${", expression, "}" + suffix]).concat(rest);
|
36768 | }
|
36769 |
|
36770 | return Object.assign({}, doc, {
|
36771 | parts
|
36772 | });
|
36773 | });
|
36774 | return expressions.length === replaceCounter ? newDoc : null;
|
36775 | }
|
36776 |
|
36777 | function printGraphqlComments(lines) {
|
36778 | const parts = [];
|
36779 | let seenComment = false;
|
36780 | lines.map(textLine => textLine.trim()).forEach((textLine, i, array) => {
|
36781 |
|
36782 |
|
36783 | if (textLine === "") {
|
36784 | return;
|
36785 | }
|
36786 |
|
36787 | if (array[i - 1] === "" && seenComment) {
|
36788 |
|
36789 |
|
36790 | parts.push(concat$4([hardline$3, textLine]));
|
36791 | } else {
|
36792 | parts.push(textLine);
|
36793 | }
|
36794 |
|
36795 | seenComment = true;
|
36796 | });
|
36797 |
|
36798 | return parts.length === 0 ? null : join$2(hardline$3, parts);
|
36799 | }
|
36800 |
|
36801 |
|
36802 |
|
36803 |
|
36804 |
|
36805 |
|
36806 |
|
36807 |
|
36808 |
|
36809 | function isStyledJsx(path) {
|
36810 | const node = path.getValue();
|
36811 | const parent = path.getParentNode();
|
36812 | const parentParent = path.getParentNode(1);
|
36813 | return parentParent && node.quasis && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXElement" && parentParent.openingElement.name.name === "style" && parentParent.openingElement.attributes.some(attribute => attribute.name.name === "jsx") || parent && parent.type === "TaggedTemplateExpression" && parent.tag.type === "Identifier" && parent.tag.name === "css" || parent && parent.type === "TaggedTemplateExpression" && parent.tag.type === "MemberExpression" && parent.tag.object.name === "css" && (parent.tag.property.name === "global" || parent.tag.property.name === "resolve");
|
36814 | }
|
36815 |
|
36816 |
|
36817 |
|
36818 |
|
36819 |
|
36820 |
|
36821 |
|
36822 |
|
36823 |
|
36824 |
|
36825 |
|
36826 |
|
36827 |
|
36828 |
|
36829 |
|
36830 |
|
36831 | function isAngularComponentStyles(path) {
|
36832 | return path.match(node => node.type === "TemplateLiteral", (node, name) => node.type === "ArrayExpression" && name === "elements", (node, name) => (node.type === "Property" || node.type === "ObjectProperty") && node.key.type === "Identifier" && node.key.name === "styles" && name === "value", ...angularComponentObjectExpressionPredicates);
|
36833 | }
|
36834 |
|
36835 | function isAngularComponentTemplate(path) {
|
36836 | return path.match(node => node.type === "TemplateLiteral", (node, name) => (node.type === "Property" || node.type === "ObjectProperty") && node.key.type === "Identifier" && node.key.name === "template" && name === "value", ...angularComponentObjectExpressionPredicates);
|
36837 | }
|
36838 |
|
36839 | const angularComponentObjectExpressionPredicates = [(node, name) => node.type === "ObjectExpression" && name === "properties", (node, name) => node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "Component" && name === "arguments", (node, name) => node.type === "Decorator" && name === "expression"];
|
36840 |
|
36841 |
|
36842 |
|
36843 |
|
36844 | function isStyledComponents(path) {
|
36845 | const parent = path.getParentNode();
|
36846 |
|
36847 | if (!parent || parent.type !== "TaggedTemplateExpression") {
|
36848 | return false;
|
36849 | }
|
36850 |
|
36851 | const {
|
36852 | tag
|
36853 | } = parent;
|
36854 |
|
36855 | switch (tag.type) {
|
36856 | case "MemberExpression":
|
36857 | return (
|
36858 | isStyledIdentifier(tag.object) ||
|
36859 | isStyledExtend(tag)
|
36860 | );
|
36861 |
|
36862 | case "CallExpression":
|
36863 | return (
|
36864 | isStyledIdentifier(tag.callee) || tag.callee.type === "MemberExpression" && (tag.callee.object.type === "MemberExpression" && (
|
36865 | isStyledIdentifier(tag.callee.object.object) ||
|
36866 | isStyledExtend(tag.callee.object)) ||
|
36867 | tag.callee.object.type === "CallExpression" && isStyledIdentifier(tag.callee.object.callee))
|
36868 | );
|
36869 |
|
36870 | case "Identifier":
|
36871 |
|
36872 | return tag.name === "css";
|
36873 |
|
36874 | default:
|
36875 | return false;
|
36876 | }
|
36877 | }
|
36878 |
|
36879 |
|
36880 |
|
36881 |
|
36882 |
|
36883 | function isCssProp(path) {
|
36884 | const parent = path.getParentNode();
|
36885 | const parentParent = path.getParentNode(1);
|
36886 | return parentParent && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" && parentParent.name.type === "JSXIdentifier" && parentParent.name.name === "css";
|
36887 | }
|
36888 |
|
36889 | function isStyledIdentifier(node) {
|
36890 | return node.type === "Identifier" && node.name === "styled";
|
36891 | }
|
36892 |
|
36893 | function isStyledExtend(node) {
|
36894 | return /^[A-Z]/.test(node.object.name) && node.property.name === "extend";
|
36895 | }
|
36896 |
|
36897 |
|
36898 |
|
36899 |
|
36900 |
|
36901 |
|
36902 |
|
36903 |
|
36904 |
|
36905 |
|
36906 |
|
36907 |
|
36908 | function isGraphQL(path) {
|
36909 | const node = path.getValue();
|
36910 | const parent = path.getParentNode();
|
36911 | return hasLanguageComment(node, "GraphQL") || parent && (parent.type === "TaggedTemplateExpression" && (parent.tag.type === "MemberExpression" && parent.tag.object.name === "graphql" && parent.tag.property.name === "experimental" || parent.tag.type === "Identifier" && (parent.tag.name === "gql" || parent.tag.name === "graphql")) || parent.type === "CallExpression" && parent.callee.type === "Identifier" && parent.callee.name === "graphql");
|
36912 | }
|
36913 |
|
36914 | function hasLanguageComment(node, languageName) {
|
36915 |
|
36916 |
|
36917 |
|
36918 |
|
36919 |
|
36920 | return hasLeadingComment$1(node, comment => isBlockComment$1(comment) && comment.value === ` ${languageName} `);
|
36921 | }
|
36922 |
|
36923 |
|
36924 |
|
36925 |
|
36926 |
|
36927 |
|
36928 | function isHtml(path) {
|
36929 | return hasLanguageComment(path.getValue(), "HTML") || path.match(node => node.type === "TemplateLiteral", (node, name) => node.type === "TaggedTemplateExpression" && node.tag.type === "Identifier" && node.tag.name === "html" && name === "quasi");
|
36930 | }
|
36931 |
|
36932 |
|
36933 | let htmlTemplateLiteralCounter = 0;
|
36934 |
|
36935 | function printHtmlTemplateLiteral(path, print, textToDoc, parser, options) {
|
36936 | const node = path.getValue();
|
36937 | const counter = htmlTemplateLiteralCounter;
|
36938 | htmlTemplateLiteralCounter = htmlTemplateLiteralCounter + 1 >>> 0;
|
36939 |
|
36940 | const composePlaceholder = index => `PRETTIER_HTML_PLACEHOLDER_${index}_${counter}_IN_JS`;
|
36941 |
|
36942 | const text = node.quasis.map((quasi, index, quasis) => index === quasis.length - 1 ? quasi.value.cooked : quasi.value.cooked + composePlaceholder(index)).join("");
|
36943 | const expressionDocs = path.map(print, "expressions");
|
36944 |
|
36945 | if (expressionDocs.length === 0 && text.trim().length === 0) {
|
36946 | return "``";
|
36947 | }
|
36948 |
|
36949 | const placeholderRegex = new RegExp(composePlaceholder("(\\d+)"), "g");
|
36950 | let topLevelCount = 0;
|
36951 | const contentDoc = mapDoc$1(stripTrailingHardline$1(textToDoc(text, {
|
36952 | parser,
|
36953 |
|
36954 | __onHtmlRoot(root) {
|
36955 | topLevelCount = root.children.length;
|
36956 | }
|
36957 |
|
36958 | })), doc => {
|
36959 | if (typeof doc !== "string") {
|
36960 | return doc;
|
36961 | }
|
36962 |
|
36963 | const parts = [];
|
36964 | const components = doc.split(placeholderRegex);
|
36965 |
|
36966 | for (let i = 0; i < components.length; i++) {
|
36967 | let component = components[i];
|
36968 |
|
36969 | if (i % 2 === 0) {
|
36970 | if (component) {
|
36971 | component = uncook(component);
|
36972 |
|
36973 | if (options.embeddedInHtml) {
|
36974 | component = component.replace(/<\/(script)\b/gi, "<\\/$1");
|
36975 | }
|
36976 |
|
36977 | parts.push(component);
|
36978 | }
|
36979 |
|
36980 | continue;
|
36981 | }
|
36982 |
|
36983 | const placeholderIndex = +component;
|
36984 | parts.push(concat$4(["${", group$1(expressionDocs[placeholderIndex]), "}"]));
|
36985 | }
|
36986 |
|
36987 | return concat$4(parts);
|
36988 | });
|
36989 | const leadingWhitespace = /^\s/.test(text) ? " " : "";
|
36990 | const trailingWhitespace = /\s$/.test(text) ? " " : "";
|
36991 | const linebreak = options.htmlWhitespaceSensitivity === "ignore" ? hardline$3 : leadingWhitespace && trailingWhitespace ? line$2 : null;
|
36992 |
|
36993 | if (linebreak) {
|
36994 | return group$1(concat$4(["`", indent$2(concat$4([linebreak, group$1(contentDoc)])), linebreak, "`"]));
|
36995 | }
|
36996 |
|
36997 | return group$1(concat$4(["`", leadingWhitespace, topLevelCount > 1 ? indent$2(group$1(contentDoc)) : group$1(contentDoc), trailingWhitespace, "`"]));
|
36998 | }
|
36999 |
|
37000 | var embed_1 = embed;
|
37001 |
|
37002 | function clean(ast, newObj, parent) {
|
37003 | ["range", "raw", "comments", "leadingComments", "trailingComments", "innerComments", "extra", "start", "end", "flags", "errors"].forEach(name => {
|
37004 | delete newObj[name];
|
37005 | });
|
37006 |
|
37007 | if (ast.loc && ast.loc.source === null) {
|
37008 | delete newObj.loc.source;
|
37009 | }
|
37010 |
|
37011 | if (ast.type === "BigIntLiteral") {
|
37012 | newObj.value = newObj.value.toLowerCase();
|
37013 | }
|
37014 |
|
37015 |
|
37016 | if (ast.type === "EmptyStatement") {
|
37017 | return null;
|
37018 | }
|
37019 |
|
37020 |
|
37021 | if (ast.type === "JSXText") {
|
37022 | return null;
|
37023 | }
|
37024 |
|
37025 | if (ast.type === "JSXExpressionContainer" && ast.expression.type === "Literal" && ast.expression.value === " ") {
|
37026 | return null;
|
37027 | }
|
37028 |
|
37029 |
|
37030 |
|
37031 | if (ast.type === "TSParameterProperty" && ast.accessibility === null && !ast.readonly) {
|
37032 | return {
|
37033 | type: "Identifier",
|
37034 | name: ast.parameter.name,
|
37035 | typeAnnotation: newObj.parameter.typeAnnotation,
|
37036 | decorators: newObj.decorators
|
37037 | };
|
37038 | }
|
37039 |
|
37040 |
|
37041 | if (ast.type === "TSNamespaceExportDeclaration" && ast.specifiers && ast.specifiers.length === 0) {
|
37042 | delete newObj.specifiers;
|
37043 | }
|
37044 |
|
37045 |
|
37046 | if (ast.type === "JSXOpeningElement") {
|
37047 | delete newObj.selfClosing;
|
37048 | }
|
37049 |
|
37050 | if (ast.type === "JSXElement") {
|
37051 | delete newObj.closingElement;
|
37052 | }
|
37053 |
|
37054 |
|
37055 | if ((ast.type === "Property" || ast.type === "ObjectProperty" || ast.type === "MethodDefinition" || ast.type === "ClassProperty" || ast.type === "TSPropertySignature" || ast.type === "ObjectTypeProperty") && typeof ast.key === "object" && ast.key && (ast.key.type === "Literal" || ast.key.type === "StringLiteral" || ast.key.type === "Identifier")) {
|
37056 | delete newObj.key;
|
37057 | }
|
37058 |
|
37059 | if (ast.type === "OptionalMemberExpression" && ast.optional === false) {
|
37060 | newObj.type = "MemberExpression";
|
37061 | delete newObj.optional;
|
37062 | }
|
37063 |
|
37064 |
|
37065 |
|
37066 | if (ast.type === "JSXElement" && ast.openingElement.name.name === "style" && ast.openingElement.attributes.some(attr => attr.name.name === "jsx")) {
|
37067 | const templateLiterals = newObj.children.filter(child => child.type === "JSXExpressionContainer" && child.expression.type === "TemplateLiteral").map(container => container.expression);
|
37068 | const quasis = templateLiterals.reduce((quasis, templateLiteral) => quasis.concat(templateLiteral.quasis), []);
|
37069 | quasis.forEach(q => delete q.value);
|
37070 | }
|
37071 |
|
37072 |
|
37073 | if (ast.type === "JSXAttribute" && ast.name.name === "css" && ast.value.type === "JSXExpressionContainer" && ast.value.expression.type === "TemplateLiteral") {
|
37074 | newObj.value.expression.quasis.forEach(q => delete q.value);
|
37075 | }
|
37076 |
|
37077 |
|
37078 | const expression = ast.expression || ast.callee;
|
37079 |
|
37080 | if (ast.type === "Decorator" && expression.type === "CallExpression" && expression.callee.name === "Component" && expression.arguments.length === 1) {
|
37081 | const astProps = ast.expression.arguments[0].properties;
|
37082 | newObj.expression.arguments[0].properties.forEach((prop, index) => {
|
37083 | let templateLiteral = null;
|
37084 |
|
37085 | switch (astProps[index].key.name) {
|
37086 | case "styles":
|
37087 | if (prop.value.type === "ArrayExpression") {
|
37088 | templateLiteral = prop.value.elements[0];
|
37089 | }
|
37090 |
|
37091 | break;
|
37092 |
|
37093 | case "template":
|
37094 | if (prop.value.type === "TemplateLiteral") {
|
37095 | templateLiteral = prop.value;
|
37096 | }
|
37097 |
|
37098 | break;
|
37099 | }
|
37100 |
|
37101 | if (templateLiteral) {
|
37102 | templateLiteral.quasis.forEach(q => delete q.value);
|
37103 | }
|
37104 | });
|
37105 | }
|
37106 |
|
37107 |
|
37108 | if (ast.type === "TaggedTemplateExpression" && (ast.tag.type === "MemberExpression" || ast.tag.type === "Identifier" && (ast.tag.name === "gql" || ast.tag.name === "graphql" || ast.tag.name === "css" || ast.tag.name === "md" || ast.tag.name === "markdown" || ast.tag.name === "html") || ast.tag.type === "CallExpression")) {
|
37109 | newObj.quasi.quasis.forEach(quasi => delete quasi.value);
|
37110 | }
|
37111 |
|
37112 | if (ast.type === "TemplateLiteral") {
|
37113 |
|
37114 |
|
37115 |
|
37116 |
|
37117 |
|
37118 | const hasLanguageComment = ast.leadingComments && ast.leadingComments.some(comment => comment.type === "CommentBlock" && ["GraphQL", "HTML"].some(languageName => comment.value === ` ${languageName} `));
|
37119 |
|
37120 | if (hasLanguageComment || parent.type === "CallExpression" && parent.callee.name === "graphql") {
|
37121 | newObj.quasis.forEach(quasi => delete quasi.value);
|
37122 | }
|
37123 | }
|
37124 | }
|
37125 |
|
37126 | var clean_1 = clean;
|
37127 |
|
37128 | const detectNewline = string => {
|
37129 | if (typeof string !== 'string') {
|
37130 | throw new TypeError('Expected a string');
|
37131 | }
|
37132 |
|
37133 | const newlines = string.match(/(?:\r?\n)/g) || [];
|
37134 |
|
37135 | if (newlines.length === 0) {
|
37136 | return;
|
37137 | }
|
37138 |
|
37139 | const crlf = newlines.filter(newline => newline === '\r\n').length;
|
37140 | const lf = newlines.length - crlf;
|
37141 | return crlf > lf ? '\r\n' : '\n';
|
37142 | };
|
37143 |
|
37144 | var detectNewline_1 = detectNewline;
|
37145 |
|
37146 | var graceful = string => typeof string === 'string' && detectNewline(string) || '\n';
|
37147 | detectNewline_1.graceful = graceful;
|
37148 |
|
37149 | var build = createCommonjsModule(function (module, exports) {
|
37150 |
|
37151 | Object.defineProperty(exports, '__esModule', {
|
37152 | value: true
|
37153 | });
|
37154 | exports.extract = extract;
|
37155 | exports.strip = strip;
|
37156 | exports.parse = parse;
|
37157 | exports.parseWithComments = parseWithComments;
|
37158 | exports.print = print;
|
37159 |
|
37160 | function _os() {
|
37161 | const data = os$1;
|
37162 |
|
37163 | _os = function () {
|
37164 | return data;
|
37165 | };
|
37166 |
|
37167 | return data;
|
37168 | }
|
37169 |
|
37170 | function _detectNewline() {
|
37171 | const data = _interopRequireDefault(detectNewline_1);
|
37172 |
|
37173 | _detectNewline = function () {
|
37174 | return data;
|
37175 | };
|
37176 |
|
37177 | return data;
|
37178 | }
|
37179 |
|
37180 | function _interopRequireDefault(obj) {
|
37181 | return obj && obj.__esModule ? obj : {
|
37182 | default: obj
|
37183 | };
|
37184 | }
|
37185 | |
37186 |
|
37187 |
|
37188 |
|
37189 |
|
37190 |
|
37191 |
|
37192 |
|
37193 | const commentEndRe = /\*\/$/;
|
37194 | const commentStartRe = /^\/\*\*/;
|
37195 | const docblockRe = /^\s*(\/\*\*?(.|\r?\n)*?\*\/)/;
|
37196 | const lineCommentRe = /(^|\s+)\/\/([^\r\n]*)/g;
|
37197 | const ltrimNewlineRe = /^(\r?\n)+/;
|
37198 | const multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g;
|
37199 | const propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g;
|
37200 | const stringStartRe = /(\r?\n|^) *\* ?/g;
|
37201 |
|
37202 | function extract(contents) {
|
37203 | const match = contents.match(docblockRe);
|
37204 | return match ? match[0].trimLeft() : '';
|
37205 | }
|
37206 |
|
37207 | function strip(contents) {
|
37208 | const match = contents.match(docblockRe);
|
37209 | return match && match[0] ? contents.substring(match[0].length) : contents;
|
37210 | }
|
37211 |
|
37212 | function parse(docblock) {
|
37213 | return parseWithComments(docblock).pragmas;
|
37214 | }
|
37215 |
|
37216 | function parseWithComments(docblock) {
|
37217 | const line = (0, _detectNewline().default)(docblock) || _os().EOL;
|
37218 |
|
37219 | docblock = docblock.replace(commentStartRe, '').replace(commentEndRe, '').replace(stringStartRe, '$1');
|
37220 |
|
37221 | let prev = '';
|
37222 |
|
37223 | while (prev !== docblock) {
|
37224 | prev = docblock;
|
37225 | docblock = docblock.replace(multilineRe, `${line}$1 $2${line}`);
|
37226 | }
|
37227 |
|
37228 | docblock = docblock.replace(ltrimNewlineRe, '').trimRight();
|
37229 | const result = Object.create(null);
|
37230 | const comments = docblock.replace(propertyRe, '').replace(ltrimNewlineRe, '').trimRight();
|
37231 | let match;
|
37232 |
|
37233 | while (match = propertyRe.exec(docblock)) {
|
37234 |
|
37235 | const nextPragma = match[2].replace(lineCommentRe, '');
|
37236 |
|
37237 | if (typeof result[match[1]] === 'string' || Array.isArray(result[match[1]])) {
|
37238 | result[match[1]] = [].concat(result[match[1]], nextPragma);
|
37239 | } else {
|
37240 | result[match[1]] = nextPragma;
|
37241 | }
|
37242 | }
|
37243 |
|
37244 | return {
|
37245 | comments,
|
37246 | pragmas: result
|
37247 | };
|
37248 | }
|
37249 |
|
37250 | function print({
|
37251 | comments = '',
|
37252 | pragmas = {}
|
37253 | }) {
|
37254 | const line = (0, _detectNewline().default)(comments) || _os().EOL;
|
37255 |
|
37256 | const head = '/**';
|
37257 | const start = ' *';
|
37258 | const tail = ' */';
|
37259 | const keys = Object.keys(pragmas);
|
37260 | const printedObject = keys.map(key => printKeyValues(key, pragmas[key])).reduce((arr, next) => arr.concat(next), []).map(keyValue => start + ' ' + keyValue + line).join('');
|
37261 |
|
37262 | if (!comments) {
|
37263 | if (keys.length === 0) {
|
37264 | return '';
|
37265 | }
|
37266 |
|
37267 | if (keys.length === 1 && !Array.isArray(pragmas[keys[0]])) {
|
37268 | const value = pragmas[keys[0]];
|
37269 | return `${head} ${printKeyValues(keys[0], value)[0]}${tail}`;
|
37270 | }
|
37271 | }
|
37272 |
|
37273 | const printedComments = comments.split(line).map(textLine => `${start} ${textLine}`).join(line) + line;
|
37274 | return head + line + (comments ? printedComments : '') + (comments && keys.length ? start + line : '') + printedObject + tail;
|
37275 | }
|
37276 |
|
37277 | function printKeyValues(key, valueOrArray) {
|
37278 | return [].concat(valueOrArray).map(value => `@${key} ${value}`.trim());
|
37279 | }
|
37280 | });
|
37281 | unwrapExports(build);
|
37282 | var build_1 = build.extract;
|
37283 | var build_2 = build.strip;
|
37284 | var build_3 = build.parse;
|
37285 | var build_4 = build.parseWithComments;
|
37286 | var build_5 = build.print;
|
37287 |
|
37288 | function hasPragma(text) {
|
37289 | const pragmas = Object.keys(build.parse(build.extract(text)));
|
37290 | return pragmas.includes("prettier") || pragmas.includes("format");
|
37291 | }
|
37292 |
|
37293 | function insertPragma(text) {
|
37294 | const parsedDocblock = build.parseWithComments(build.extract(text));
|
37295 | const pragmas = Object.assign({
|
37296 | format: ""
|
37297 | }, parsedDocblock.pragmas);
|
37298 | const newDocblock = build.print({
|
37299 | pragmas,
|
37300 | comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, "")
|
37301 |
|
37302 | }).replace(/(\r\n|\r)/g, "\n");
|
37303 |
|
37304 | const strippedText = build.strip(text);
|
37305 | const separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
|
37306 | return newDocblock + separatingNewlines + strippedText;
|
37307 | }
|
37308 |
|
37309 | var pragma = {
|
37310 | hasPragma,
|
37311 | insertPragma
|
37312 | };
|
37313 |
|
37314 | const {
|
37315 | getLast: getLast$1,
|
37316 | hasNewline: hasNewline$3,
|
37317 | hasNewlineInRange: hasNewlineInRange$2,
|
37318 | hasIgnoreComment: hasIgnoreComment$1,
|
37319 | hasNodeIgnoreComment: hasNodeIgnoreComment$1,
|
37320 | skipWhitespace: skipWhitespace$2
|
37321 | } = util$1;
|
37322 | const isIdentifierName = utils$1.keyword.isIdentifierNameES5;
|
37323 |
|
37324 |
|
37325 |
|
37326 |
|
37327 |
|
37328 |
|
37329 |
|
37330 |
|
37331 |
|
37332 | const NON_LINE_TERMINATING_WHITE_SPACE = "(?:(?=.)\\s)";
|
37333 | const FLOW_SHORTHAND_ANNOTATION = new RegExp(`^${NON_LINE_TERMINATING_WHITE_SPACE}*:`);
|
37334 | const FLOW_ANNOTATION = new RegExp(`^${NON_LINE_TERMINATING_WHITE_SPACE}*::`);
|
37335 |
|
37336 | function hasFlowShorthandAnnotationComment(node) {
|
37337 |
|
37338 |
|
37339 | return node.extra && node.extra.parenthesized && node.trailingComments && node.trailingComments[0].value.match(FLOW_SHORTHAND_ANNOTATION);
|
37340 | }
|
37341 |
|
37342 | function hasFlowAnnotationComment(comments) {
|
37343 | return comments && comments[0].value.match(FLOW_ANNOTATION);
|
37344 | }
|
37345 |
|
37346 | function hasNode(node, fn) {
|
37347 | if (!node || typeof node !== "object") {
|
37348 | return false;
|
37349 | }
|
37350 |
|
37351 | if (Array.isArray(node)) {
|
37352 | return node.some(value => hasNode(value, fn));
|
37353 | }
|
37354 |
|
37355 | const result = fn(node);
|
37356 | return typeof result === "boolean" ? result : Object.keys(node).some(key => hasNode(node[key], fn));
|
37357 | }
|
37358 |
|
37359 | function hasNakedLeftSide(node) {
|
37360 | return node.type === "AssignmentExpression" || node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression" || node.type === "ConditionalExpression" || node.type === "CallExpression" || node.type === "OptionalCallExpression" || node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "BindExpression" || node.type === "UpdateExpression" && !node.prefix || node.type === "TSAsExpression" || node.type === "TSNonNullExpression";
|
37361 | }
|
37362 |
|
37363 | function getLeftSide(node) {
|
37364 | if (node.expressions) {
|
37365 | return node.expressions[0];
|
37366 | }
|
37367 |
|
37368 | return node.left || node.test || node.callee || node.object || node.tag || node.argument || node.expression;
|
37369 | }
|
37370 |
|
37371 | function getLeftSidePathName(path, node) {
|
37372 | if (node.expressions) {
|
37373 | return ["expressions", 0];
|
37374 | }
|
37375 |
|
37376 | if (node.left) {
|
37377 | return ["left"];
|
37378 | }
|
37379 |
|
37380 | if (node.test) {
|
37381 | return ["test"];
|
37382 | }
|
37383 |
|
37384 | if (node.object) {
|
37385 | return ["object"];
|
37386 | }
|
37387 |
|
37388 | if (node.callee) {
|
37389 | return ["callee"];
|
37390 | }
|
37391 |
|
37392 | if (node.tag) {
|
37393 | return ["tag"];
|
37394 | }
|
37395 |
|
37396 | if (node.argument) {
|
37397 | return ["argument"];
|
37398 | }
|
37399 |
|
37400 | if (node.expression) {
|
37401 | return ["expression"];
|
37402 | }
|
37403 |
|
37404 | throw new Error("Unexpected node has no left side", node);
|
37405 | }
|
37406 |
|
37407 | const exportDeclarationTypes = new Set(["ExportDefaultDeclaration", "ExportDefaultSpecifier", "DeclareExportDeclaration", "ExportNamedDeclaration", "ExportAllDeclaration"]);
|
37408 |
|
37409 | function isExportDeclaration(node) {
|
37410 | return node && exportDeclarationTypes.has(node.type);
|
37411 | }
|
37412 |
|
37413 | function getParentExportDeclaration(path) {
|
37414 | const parentNode = path.getParentNode();
|
37415 |
|
37416 | if (path.getName() === "declaration" && isExportDeclaration(parentNode)) {
|
37417 | return parentNode;
|
37418 | }
|
37419 |
|
37420 | return null;
|
37421 | }
|
37422 |
|
37423 | function isLiteral(node) {
|
37424 | return node.type === "BooleanLiteral" || node.type === "DirectiveLiteral" || node.type === "Literal" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "RegExpLiteral" || node.type === "StringLiteral" || node.type === "TemplateLiteral" || node.type === "TSTypeLiteral" || node.type === "JSXText";
|
37425 | }
|
37426 |
|
37427 | function isNumericLiteral(node) {
|
37428 | return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
|
37429 | }
|
37430 |
|
37431 | function isStringLiteral(node) {
|
37432 | return node.type === "StringLiteral" || node.type === "Literal" && typeof node.value === "string";
|
37433 | }
|
37434 |
|
37435 | function isObjectType(n) {
|
37436 | return n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral";
|
37437 | }
|
37438 |
|
37439 | function isFunctionOrArrowExpression(node) {
|
37440 | return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
|
37441 | }
|
37442 |
|
37443 | function isFunctionOrArrowExpressionWithBody(node) {
|
37444 | return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement";
|
37445 | }
|
37446 |
|
37447 | function isTemplateLiteral(node) {
|
37448 | return node.type === "TemplateLiteral";
|
37449 | }
|
37450 |
|
37451 |
|
37452 |
|
37453 | function isAngularTestWrapper(node) {
|
37454 | return (node.type === "CallExpression" || node.type === "OptionalCallExpression") && node.callee.type === "Identifier" && (node.callee.name === "async" || node.callee.name === "inject" || node.callee.name === "fakeAsync");
|
37455 | }
|
37456 |
|
37457 | function isJSXNode(node) {
|
37458 | return node.type === "JSXElement" || node.type === "JSXFragment";
|
37459 | }
|
37460 |
|
37461 | function isTheOnlyJSXElementInMarkdown(options, path) {
|
37462 | if (options.parentParser !== "markdown" && options.parentParser !== "mdx") {
|
37463 | return false;
|
37464 | }
|
37465 |
|
37466 | const node = path.getNode();
|
37467 |
|
37468 | if (!node.expression || !isJSXNode(node.expression)) {
|
37469 | return false;
|
37470 | }
|
37471 |
|
37472 | const parent = path.getParentNode();
|
37473 | return parent.type === "Program" && parent.body.length === 1;
|
37474 | }
|
37475 |
|
37476 |
|
37477 | function isJSXWhitespaceExpression(node) {
|
37478 | return node.type === "JSXExpressionContainer" && isLiteral(node.expression) && node.expression.value === " " && !node.expression.comments;
|
37479 | }
|
37480 |
|
37481 | function isMemberExpressionChain(node) {
|
37482 | if (node.type !== "MemberExpression" && node.type !== "OptionalMemberExpression") {
|
37483 | return false;
|
37484 | }
|
37485 |
|
37486 | if (node.object.type === "Identifier") {
|
37487 | return true;
|
37488 | }
|
37489 |
|
37490 | return isMemberExpressionChain(node.object);
|
37491 | }
|
37492 |
|
37493 | function isGetterOrSetter(node) {
|
37494 | return node.kind === "get" || node.kind === "set";
|
37495 | }
|
37496 |
|
37497 | function sameLocStart(nodeA, nodeB, options) {
|
37498 | return options.locStart(nodeA) === options.locStart(nodeB);
|
37499 | }
|
37500 |
|
37501 |
|
37502 |
|
37503 | function isFunctionNotation(node, options) {
|
37504 | return isGetterOrSetter(node) || sameLocStart(node, node.value, options);
|
37505 | }
|
37506 |
|
37507 |
|
37508 |
|
37509 |
|
37510 | function isObjectTypePropertyAFunction(node, options) {
|
37511 | return (node.type === "ObjectTypeProperty" || node.type === "ObjectTypeInternalSlot") && node.value.type === "FunctionTypeAnnotation" && !node.static && !isFunctionNotation(node, options);
|
37512 | }
|
37513 |
|
37514 |
|
37515 |
|
37516 |
|
37517 | function isTypeAnnotationAFunction(node, options) {
|
37518 | return (node.type === "TypeAnnotation" || node.type === "TSTypeAnnotation") && node.typeAnnotation.type === "FunctionTypeAnnotation" && !node.static && !sameLocStart(node, node.typeAnnotation, options);
|
37519 | }
|
37520 |
|
37521 | const binaryishNodeTypes = new Set(["BinaryExpression", "LogicalExpression", "NGPipeExpression"]);
|
37522 |
|
37523 | function isBinaryish(node) {
|
37524 | return binaryishNodeTypes.has(node.type);
|
37525 | }
|
37526 |
|
37527 | function isMemberish(node) {
|
37528 | return node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "BindExpression" && node.object;
|
37529 | }
|
37530 |
|
37531 | function isSimpleFlowType(node) {
|
37532 | const flowTypeAnnotations = ["AnyTypeAnnotation", "NullLiteralTypeAnnotation", "GenericTypeAnnotation", "ThisTypeAnnotation", "NumberTypeAnnotation", "VoidTypeAnnotation", "EmptyTypeAnnotation", "MixedTypeAnnotation", "BooleanTypeAnnotation", "BooleanLiteralTypeAnnotation", "StringTypeAnnotation"];
|
37533 | return node && flowTypeAnnotations.includes(node.type) && !(node.type === "GenericTypeAnnotation" && node.typeParameters);
|
37534 | }
|
37535 |
|
37536 | const unitTestRe = /^(skip|[fx]?(it|describe|test))$/;
|
37537 |
|
37538 | function isSkipOrOnlyBlock(node) {
|
37539 | return (node.callee.type === "MemberExpression" || node.callee.type === "OptionalMemberExpression") && node.callee.object.type === "Identifier" && node.callee.property.type === "Identifier" && unitTestRe.test(node.callee.object.name) && (node.callee.property.name === "only" || node.callee.property.name === "skip");
|
37540 | }
|
37541 |
|
37542 | function isUnitTestSetUp(n) {
|
37543 | const unitTestSetUpRe = /^(before|after)(Each|All)$/;
|
37544 | return n.callee.type === "Identifier" && unitTestSetUpRe.test(n.callee.name) && n.arguments.length === 1;
|
37545 | }
|
37546 |
|
37547 |
|
37548 | function isTestCall(n, parent) {
|
37549 | if (n.type !== "CallExpression") {
|
37550 | return false;
|
37551 | }
|
37552 |
|
37553 | if (n.arguments.length === 1) {
|
37554 | if (isAngularTestWrapper(n) && parent && isTestCall(parent)) {
|
37555 | return isFunctionOrArrowExpression(n.arguments[0]);
|
37556 | }
|
37557 |
|
37558 | if (isUnitTestSetUp(n)) {
|
37559 | return isAngularTestWrapper(n.arguments[0]);
|
37560 | }
|
37561 | } else if (n.arguments.length === 2 || n.arguments.length === 3) {
|
37562 | if ((n.callee.type === "Identifier" && unitTestRe.test(n.callee.name) || isSkipOrOnlyBlock(n)) && (isTemplateLiteral(n.arguments[0]) || isStringLiteral(n.arguments[0]))) {
|
37563 |
|
37564 | if (n.arguments[2] && !isNumericLiteral(n.arguments[2])) {
|
37565 | return false;
|
37566 | }
|
37567 |
|
37568 | return (n.arguments.length === 2 ? isFunctionOrArrowExpression(n.arguments[1]) : isFunctionOrArrowExpressionWithBody(n.arguments[1]) && n.arguments[1].params.length <= 1) || isAngularTestWrapper(n.arguments[1]);
|
37569 | }
|
37570 | }
|
37571 |
|
37572 | return false;
|
37573 | }
|
37574 |
|
37575 | function hasLeadingComment$2(node) {
|
37576 | return node.comments && node.comments.some(comment => comment.leading);
|
37577 | }
|
37578 |
|
37579 | function hasTrailingComment(node) {
|
37580 | return node.comments && node.comments.some(comment => comment.trailing);
|
37581 | }
|
37582 |
|
37583 | function isCallOrOptionalCallExpression(node) {
|
37584 | return node.type === "CallExpression" || node.type === "OptionalCallExpression";
|
37585 | }
|
37586 |
|
37587 | function hasDanglingComments(node) {
|
37588 | return node.comments && node.comments.some(comment => !comment.leading && !comment.trailing);
|
37589 | }
|
37590 |
|
37591 |
|
37592 |
|
37593 | function hasNgSideEffect(path) {
|
37594 | return hasNode(path.getValue(), node => {
|
37595 | switch (node.type) {
|
37596 | case undefined:
|
37597 | return false;
|
37598 |
|
37599 | case "CallExpression":
|
37600 | case "OptionalCallExpression":
|
37601 | case "AssignmentExpression":
|
37602 | return true;
|
37603 | }
|
37604 | });
|
37605 | }
|
37606 |
|
37607 | function isNgForOf(node, index, parentNode) {
|
37608 | return node.type === "NGMicrosyntaxKeyedExpression" && node.key.name === "of" && index === 1 && parentNode.body[0].type === "NGMicrosyntaxLet" && parentNode.body[0].value === null;
|
37609 | }
|
37610 |
|
37611 |
|
37612 |
|
37613 | function isSimpleTemplateLiteral(node) {
|
37614 | if (node.expressions.length === 0) {
|
37615 | return false;
|
37616 | }
|
37617 |
|
37618 | return node.expressions.every(expr => {
|
37619 |
|
37620 | if (expr.comments) {
|
37621 | return false;
|
37622 | }
|
37623 |
|
37624 |
|
37625 | if (expr.type === "Identifier" || expr.type === "ThisExpression") {
|
37626 | return true;
|
37627 | }
|
37628 |
|
37629 |
|
37630 | if (expr.type === "MemberExpression" || expr.type === "OptionalMemberExpression") {
|
37631 | let head = expr;
|
37632 |
|
37633 | while (head.type === "MemberExpression" || head.type === "OptionalMemberExpression") {
|
37634 | if (head.property.type !== "Identifier" && head.property.type !== "Literal" && head.property.type !== "StringLiteral" && head.property.type !== "NumericLiteral") {
|
37635 | return false;
|
37636 | }
|
37637 |
|
37638 | head = head.object;
|
37639 |
|
37640 | if (head.comments) {
|
37641 | return false;
|
37642 | }
|
37643 | }
|
37644 |
|
37645 | if (head.type === "Identifier" || head.type === "ThisExpression") {
|
37646 | return true;
|
37647 | }
|
37648 |
|
37649 | return false;
|
37650 | }
|
37651 |
|
37652 | return false;
|
37653 | });
|
37654 | }
|
37655 |
|
37656 | function getFlowVariance(path) {
|
37657 | if (!path.variance) {
|
37658 | return null;
|
37659 | }
|
37660 |
|
37661 |
|
37662 |
|
37663 |
|
37664 | const variance = path.variance.kind || path.variance;
|
37665 |
|
37666 | switch (variance) {
|
37667 | case "plus":
|
37668 | return "+";
|
37669 |
|
37670 | case "minus":
|
37671 | return "-";
|
37672 |
|
37673 | default:
|
37674 |
|
37675 | return variance;
|
37676 | }
|
37677 | }
|
37678 |
|
37679 | function classPropMayCauseASIProblems(path) {
|
37680 | const node = path.getNode();
|
37681 |
|
37682 | if (node.type !== "ClassProperty") {
|
37683 | return false;
|
37684 | }
|
37685 |
|
37686 | const name = node.key && node.key.name;
|
37687 |
|
37688 |
|
37689 | if ((name === "static" || name === "get" || name === "set") && !node.value && !node.typeAnnotation) {
|
37690 | return true;
|
37691 | }
|
37692 | }
|
37693 |
|
37694 | function classChildNeedsASIProtection(node) {
|
37695 | if (!node) {
|
37696 | return;
|
37697 | }
|
37698 |
|
37699 | if (node.static || node.accessibility
|
37700 | ) {
|
37701 | return false;
|
37702 | }
|
37703 |
|
37704 | if (!node.computed) {
|
37705 | const name = node.key && node.key.name;
|
37706 |
|
37707 | if (name === "in" || name === "instanceof") {
|
37708 | return true;
|
37709 | }
|
37710 | }
|
37711 |
|
37712 | switch (node.type) {
|
37713 | case "ClassProperty":
|
37714 | case "TSAbstractClassProperty":
|
37715 | return node.computed;
|
37716 |
|
37717 | case "MethodDefinition":
|
37718 |
|
37719 | case "TSAbstractMethodDefinition":
|
37720 |
|
37721 | case "ClassMethod":
|
37722 | case "ClassPrivateMethod":
|
37723 | {
|
37724 |
|
37725 | const isAsync = node.value ? node.value.async : node.async;
|
37726 | const isGenerator = node.value ? node.value.generator : node.generator;
|
37727 |
|
37728 | if (isAsync || node.kind === "get" || node.kind === "set") {
|
37729 | return false;
|
37730 | }
|
37731 |
|
37732 | if (node.computed || isGenerator) {
|
37733 | return true;
|
37734 | }
|
37735 |
|
37736 | return false;
|
37737 | }
|
37738 |
|
37739 | case "TSIndexSignature":
|
37740 | return true;
|
37741 |
|
37742 | default:
|
37743 |
|
37744 | return false;
|
37745 | }
|
37746 | }
|
37747 |
|
37748 | function getTypeScriptMappedTypeModifier(tokenNode, keyword) {
|
37749 | if (tokenNode === "+") {
|
37750 | return "+" + keyword;
|
37751 | } else if (tokenNode === "-") {
|
37752 | return "-" + keyword;
|
37753 | }
|
37754 |
|
37755 | return keyword;
|
37756 | }
|
37757 |
|
37758 | function hasNewlineBetweenOrAfterDecorators(node, options) {
|
37759 | return hasNewlineInRange$2(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$1(node.decorators))) || hasNewline$3(options.originalText, options.locEnd(getLast$1(node.decorators)));
|
37760 | }
|
37761 |
|
37762 |
|
37763 |
|
37764 | const jsxWhitespaceChars = " \n\r\t";
|
37765 | const matchJsxWhitespaceRegex = new RegExp("([" + jsxWhitespaceChars + "]+)");
|
37766 | const containsNonJsxWhitespaceRegex = new RegExp("[^" + jsxWhitespaceChars + "]");
|
37767 |
|
37768 |
|
37769 | function isMeaningfulJSXText(node) {
|
37770 | return isLiteral(node) && (containsNonJsxWhitespaceRegex.test(rawText(node)) || !/\n/.test(rawText(node)));
|
37771 | }
|
37772 |
|
37773 | function hasJsxIgnoreComment(path) {
|
37774 | const node = path.getValue();
|
37775 | const parent = path.getParentNode();
|
37776 |
|
37777 | if (!parent || !node || !isJSXNode(node) || !isJSXNode(parent)) {
|
37778 | return false;
|
37779 | }
|
37780 |
|
37781 |
|
37782 | const index = parent.children.indexOf(node);
|
37783 | let prevSibling = null;
|
37784 |
|
37785 | for (let i = index; i > 0; i--) {
|
37786 | const candidate = parent.children[i - 1];
|
37787 |
|
37788 | if (candidate.type === "JSXText" && !isMeaningfulJSXText(candidate)) {
|
37789 | continue;
|
37790 | }
|
37791 |
|
37792 | prevSibling = candidate;
|
37793 | break;
|
37794 | }
|
37795 |
|
37796 | return prevSibling && prevSibling.type === "JSXExpressionContainer" && prevSibling.expression.type === "JSXEmptyExpression" && prevSibling.expression.comments && prevSibling.expression.comments.find(comment => comment.value.trim() === "prettier-ignore");
|
37797 | }
|
37798 |
|
37799 | function isEmptyJSXElement(node) {
|
37800 | if (node.children.length === 0) {
|
37801 | return true;
|
37802 | }
|
37803 |
|
37804 | if (node.children.length > 1) {
|
37805 | return false;
|
37806 | }
|
37807 |
|
37808 |
|
37809 |
|
37810 | const child = node.children[0];
|
37811 | return isLiteral(child) && !isMeaningfulJSXText(child);
|
37812 | }
|
37813 |
|
37814 | function hasPrettierIgnore(path) {
|
37815 | return hasIgnoreComment$1(path) || hasJsxIgnoreComment(path);
|
37816 | }
|
37817 |
|
37818 | function isLastStatement(path) {
|
37819 | const parent = path.getParentNode();
|
37820 |
|
37821 | if (!parent) {
|
37822 | return true;
|
37823 | }
|
37824 |
|
37825 | const node = path.getValue();
|
37826 | const body = (parent.body || parent.consequent).filter(stmt => stmt.type !== "EmptyStatement");
|
37827 | return body && body[body.length - 1] === node;
|
37828 | }
|
37829 |
|
37830 | function isFlowAnnotationComment(text, typeAnnotation, options) {
|
37831 | const start = options.locStart(typeAnnotation);
|
37832 | const end = skipWhitespace$2(text, options.locEnd(typeAnnotation));
|
37833 | return text.slice(start, start + 2) === "/*" && text.slice(end, end + 2) === "*/";
|
37834 | }
|
37835 |
|
37836 | function hasLeadingOwnLineComment(text, node, options) {
|
37837 | if (isJSXNode(node)) {
|
37838 | return hasNodeIgnoreComment$1(node);
|
37839 | }
|
37840 |
|
37841 | const res = node.comments && node.comments.some(comment => comment.leading && hasNewline$3(text, options.locEnd(comment)));
|
37842 | return res;
|
37843 | }
|
37844 |
|
37845 |
|
37846 |
|
37847 |
|
37848 | function returnArgumentHasLeadingComment(options, argument) {
|
37849 | if (hasLeadingOwnLineComment(options.originalText, argument, options)) {
|
37850 | return true;
|
37851 | }
|
37852 |
|
37853 | if (hasNakedLeftSide(argument)) {
|
37854 | let leftMost = argument;
|
37855 | let newLeftMost;
|
37856 |
|
37857 | while (newLeftMost = getLeftSide(leftMost)) {
|
37858 | leftMost = newLeftMost;
|
37859 |
|
37860 | if (hasLeadingOwnLineComment(options.originalText, leftMost, options)) {
|
37861 | return true;
|
37862 | }
|
37863 | }
|
37864 | }
|
37865 |
|
37866 | return false;
|
37867 | }
|
37868 |
|
37869 | function isStringPropSafeToCoerceToIdentifier(node, options) {
|
37870 | return isStringLiteral(node.key) && isIdentifierName(node.key.value) && options.parser !== "json" &&
|
37871 |
|
37872 | !((options.parser === "typescript" || options.parser === "babel-ts") && node.type === "ClassProperty");
|
37873 | }
|
37874 |
|
37875 | function isJestEachTemplateLiteral(node, parentNode) {
|
37876 | |
37877 |
|
37878 |
|
37879 |
|
37880 |
|
37881 |
|
37882 |
|
37883 |
|
37884 |
|
37885 |
|
37886 | const jestEachTriggerRegex = /^[xf]?(describe|it|test)$/;
|
37887 | return parentNode.type === "TaggedTemplateExpression" && parentNode.quasi === node && parentNode.tag.type === "MemberExpression" && parentNode.tag.property.type === "Identifier" && parentNode.tag.property.name === "each" && (parentNode.tag.object.type === "Identifier" && jestEachTriggerRegex.test(parentNode.tag.object.name) || parentNode.tag.object.type === "MemberExpression" && parentNode.tag.object.property.type === "Identifier" && (parentNode.tag.object.property.name === "only" || parentNode.tag.object.property.name === "skip") && parentNode.tag.object.object.type === "Identifier" && jestEachTriggerRegex.test(parentNode.tag.object.object.name));
|
37888 | }
|
37889 |
|
37890 | function templateLiteralHasNewLines(template) {
|
37891 | return template.quasis.some(quasi => quasi.value.raw.includes("\n"));
|
37892 | }
|
37893 |
|
37894 | function isTemplateOnItsOwnLine(n, text, options) {
|
37895 | return (n.type === "TemplateLiteral" && templateLiteralHasNewLines(n) || n.type === "TaggedTemplateExpression" && templateLiteralHasNewLines(n.quasi)) && !hasNewline$3(text, options.locStart(n), {
|
37896 | backwards: true
|
37897 | });
|
37898 | }
|
37899 |
|
37900 | function needsHardlineAfterDanglingComment(node) {
|
37901 | if (!node.comments) {
|
37902 | return false;
|
37903 | }
|
37904 |
|
37905 | const lastDanglingComment = getLast$1(node.comments.filter(comment => !comment.leading && !comment.trailing));
|
37906 | return lastDanglingComment && !comments$1.isBlockComment(lastDanglingComment);
|
37907 | }
|
37908 |
|
37909 |
|
37910 |
|
37911 |
|
37912 |
|
37913 |
|
37914 |
|
37915 |
|
37916 |
|
37917 |
|
37918 |
|
37919 |
|
37920 |
|
37921 |
|
37922 |
|
37923 |
|
37924 |
|
37925 |
|
37926 |
|
37927 |
|
37928 |
|
37929 |
|
37930 |
|
37931 |
|
37932 |
|
37933 |
|
37934 |
|
37935 |
|
37936 |
|
37937 |
|
37938 |
|
37939 |
|
37940 | function getConditionalChainContents(node) {
|
37941 |
|
37942 |
|
37943 |
|
37944 |
|
37945 |
|
37946 |
|
37947 |
|
37948 |
|
37949 |
|
37950 |
|
37951 |
|
37952 |
|
37953 |
|
37954 |
|
37955 |
|
37956 |
|
37957 |
|
37958 |
|
37959 |
|
37960 |
|
37961 |
|
37962 |
|
37963 |
|
37964 |
|
37965 |
|
37966 |
|
37967 |
|
37968 |
|
37969 |
|
37970 |
|
37971 |
|
37972 |
|
37973 |
|
37974 |
|
37975 |
|
37976 |
|
37977 |
|
37978 |
|
37979 |
|
37980 |
|
37981 |
|
37982 |
|
37983 |
|
37984 | const nonConditionalExpressions = [];
|
37985 |
|
37986 | function recurse(node) {
|
37987 | if (node.type === "ConditionalExpression") {
|
37988 | recurse(node.test);
|
37989 | recurse(node.consequent);
|
37990 | recurse(node.alternate);
|
37991 | } else {
|
37992 | nonConditionalExpressions.push(node);
|
37993 | }
|
37994 | }
|
37995 |
|
37996 | recurse(node);
|
37997 | return nonConditionalExpressions;
|
37998 | }
|
37999 |
|
38000 | function conditionalExpressionChainContainsJSX(node) {
|
38001 | return Boolean(getConditionalChainContents(node).find(isJSXNode));
|
38002 | }
|
38003 |
|
38004 |
|
38005 |
|
38006 |
|
38007 | function isFunctionCompositionArgs(args) {
|
38008 | if (args.length <= 1) {
|
38009 | return false;
|
38010 | }
|
38011 |
|
38012 | let count = 0;
|
38013 |
|
38014 | for (const arg of args) {
|
38015 | if (isFunctionOrArrowExpression(arg)) {
|
38016 | count += 1;
|
38017 |
|
38018 | if (count > 1) {
|
38019 | return true;
|
38020 | }
|
38021 | } else if (isCallOrOptionalCallExpression(arg)) {
|
38022 | for (const childArg of arg.arguments) {
|
38023 | if (isFunctionOrArrowExpression(childArg)) {
|
38024 | return true;
|
38025 | }
|
38026 | }
|
38027 | }
|
38028 | }
|
38029 |
|
38030 | return false;
|
38031 | }
|
38032 |
|
38033 |
|
38034 |
|
38035 |
|
38036 |
|
38037 |
|
38038 |
|
38039 | function isLongCurriedCallExpression(path) {
|
38040 | const node = path.getValue();
|
38041 | const parent = path.getParentNode();
|
38042 | return isCallOrOptionalCallExpression(node) && isCallOrOptionalCallExpression(parent) && parent.callee === node && node.arguments.length > parent.arguments.length && parent.arguments.length > 0;
|
38043 | }
|
38044 |
|
38045 |
|
38046 |
|
38047 |
|
38048 |
|
38049 |
|
38050 |
|
38051 | function isSimpleCallArgument(node, depth) {
|
38052 | if (depth >= 2) {
|
38053 | return false;
|
38054 | }
|
38055 |
|
38056 | const isChildSimple = child => isSimpleCallArgument(child, depth + 1);
|
38057 |
|
38058 | const regexpPattern = node.type === "Literal" && node.regex && node.regex.pattern || node.type === "RegExpLiteral" && node.pattern;
|
38059 |
|
38060 | if (regexpPattern && regexpPattern.length > 5) {
|
38061 | return false;
|
38062 | }
|
38063 |
|
38064 | if (node.type === "Literal" || node.type === "BooleanLiteral" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "StringLiteral" || node.type === "Identifier" || node.type === "ThisExpression" || node.type === "Super" || node.type === "BigIntLiteral" || node.type === "PrivateName" || node.type === "ArgumentPlaceholder" || node.type === "RegExpLiteral" || node.type === "Import") {
|
38065 | return true;
|
38066 | }
|
38067 |
|
38068 | if (node.type === "TemplateLiteral") {
|
38069 | return node.expressions.every(isChildSimple);
|
38070 | }
|
38071 |
|
38072 | if (node.type === "ObjectExpression") {
|
38073 | return node.properties.every(p => !p.computed && (p.shorthand || p.value && isChildSimple(p.value)));
|
38074 | }
|
38075 |
|
38076 | if (node.type === "ArrayExpression") {
|
38077 | return node.elements.every(x => x == null || isChildSimple(x));
|
38078 | }
|
38079 |
|
38080 | if (node.type === "CallExpression" || node.type === "OptionalCallExpression" || node.type === "NewExpression") {
|
38081 | return isSimpleCallArgument(node.callee, depth) && node.arguments.every(isChildSimple);
|
38082 | }
|
38083 |
|
38084 | if (node.type === "MemberExpression" || node.type === "OptionalMemberExpression") {
|
38085 | return isSimpleCallArgument(node.object, depth) && isSimpleCallArgument(node.property, depth);
|
38086 | }
|
38087 |
|
38088 | if (node.type === "UnaryExpression" && (node.operator === "!" || node.operator === "-")) {
|
38089 | return isSimpleCallArgument(node.argument, depth);
|
38090 | }
|
38091 |
|
38092 | if (node.type === "TSNonNullExpression") {
|
38093 | return isSimpleCallArgument(node.expression, depth);
|
38094 | }
|
38095 |
|
38096 | return false;
|
38097 | }
|
38098 |
|
38099 | function rawText(node) {
|
38100 | return node.extra ? node.extra.raw : node.raw;
|
38101 | }
|
38102 |
|
38103 | function identity$1(x) {
|
38104 | return x;
|
38105 | }
|
38106 |
|
38107 | function isTSXFile(options) {
|
38108 | return options.filepath && /\.tsx$/i.test(options.filepath);
|
38109 | }
|
38110 |
|
38111 | var utils$6 = {
|
38112 | classChildNeedsASIProtection,
|
38113 | classPropMayCauseASIProblems,
|
38114 | conditionalExpressionChainContainsJSX,
|
38115 | getFlowVariance,
|
38116 | getLeftSidePathName,
|
38117 | getParentExportDeclaration,
|
38118 | getTypeScriptMappedTypeModifier,
|
38119 | hasDanglingComments,
|
38120 | hasFlowAnnotationComment,
|
38121 | hasFlowShorthandAnnotationComment,
|
38122 | hasLeadingComment: hasLeadingComment$2,
|
38123 | hasLeadingOwnLineComment,
|
38124 | hasNakedLeftSide,
|
38125 | hasNewlineBetweenOrAfterDecorators,
|
38126 | hasNgSideEffect,
|
38127 | hasNode,
|
38128 | hasPrettierIgnore,
|
38129 | hasTrailingComment,
|
38130 | identity: identity$1,
|
38131 | isBinaryish,
|
38132 | isCallOrOptionalCallExpression,
|
38133 | isEmptyJSXElement,
|
38134 | isExportDeclaration,
|
38135 | isFlowAnnotationComment,
|
38136 | isFunctionCompositionArgs,
|
38137 | isFunctionNotation,
|
38138 | isFunctionOrArrowExpression,
|
38139 | isGetterOrSetter,
|
38140 | isJestEachTemplateLiteral,
|
38141 | isJSXNode,
|
38142 | isJSXWhitespaceExpression,
|
38143 | isLastStatement,
|
38144 | isLiteral,
|
38145 | isLongCurriedCallExpression,
|
38146 | isSimpleCallArgument,
|
38147 | isMeaningfulJSXText,
|
38148 | isMemberExpressionChain,
|
38149 | isMemberish,
|
38150 | isNgForOf,
|
38151 | isNumericLiteral,
|
38152 | isObjectType,
|
38153 | isObjectTypePropertyAFunction,
|
38154 | isSimpleFlowType,
|
38155 | isSimpleTemplateLiteral,
|
38156 | isStringLiteral,
|
38157 | isStringPropSafeToCoerceToIdentifier,
|
38158 | isTemplateOnItsOwnLine,
|
38159 | isTestCall,
|
38160 | isTheOnlyJSXElementInMarkdown,
|
38161 | isTSXFile,
|
38162 | isTypeAnnotationAFunction,
|
38163 | matchJsxWhitespaceRegex,
|
38164 | needsHardlineAfterDanglingComment,
|
38165 | rawText,
|
38166 | returnArgumentHasLeadingComment
|
38167 | };
|
38168 |
|
38169 | const {
|
38170 | getLeftSidePathName: getLeftSidePathName$1,
|
38171 | hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$1,
|
38172 | hasNakedLeftSide: hasNakedLeftSide$1,
|
38173 | hasNode: hasNode$1
|
38174 | } = utils$6;
|
38175 |
|
38176 | function needsParens(path, options) {
|
38177 | const parent = path.getParentNode();
|
38178 |
|
38179 | if (!parent) {
|
38180 | return false;
|
38181 | }
|
38182 |
|
38183 | const name = path.getName();
|
38184 | const node = path.getNode();
|
38185 |
|
38186 |
|
38187 |
|
38188 | if (path.getValue() !== node) {
|
38189 | return false;
|
38190 | }
|
38191 |
|
38192 |
|
38193 | if (options.__isInHtmlInterpolation && !options.bracketSpacing && endsWithRightBracket(node) && isFollowedByRightBracket(path)) {
|
38194 | return true;
|
38195 | }
|
38196 |
|
38197 |
|
38198 | if (isStatement(node)) {
|
38199 | return false;
|
38200 | }
|
38201 |
|
38202 | if (
|
38203 |
|
38204 |
|
38205 | options.parser !== "flow" && hasFlowShorthandAnnotationComment$1(path.getValue())) {
|
38206 | return true;
|
38207 | }
|
38208 |
|
38209 |
|
38210 | if (node.type === "Identifier") {
|
38211 |
|
38212 |
|
38213 |
|
38214 |
|
38215 |
|
38216 | if (node.extra && node.extra.parenthesized && /^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(node.name)) {
|
38217 | return true;
|
38218 | }
|
38219 |
|
38220 | return false;
|
38221 | }
|
38222 |
|
38223 | if (parent.type === "ParenthesizedExpression") {
|
38224 | return false;
|
38225 | }
|
38226 |
|
38227 |
|
38228 |
|
38229 | if ((parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.superClass === node && (node.type === "ArrowFunctionExpression" || node.type === "AssignmentExpression" || node.type === "AwaitExpression" || node.type === "BinaryExpression" || node.type === "ConditionalExpression" || node.type === "LogicalExpression" || node.type === "NewExpression" || node.type === "ObjectExpression" || node.type === "ParenthesizedExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "UnaryExpression" || node.type === "UpdateExpression" || node.type === "YieldExpression")) {
|
38230 | return true;
|
38231 | }
|
38232 |
|
38233 | if (parent.type === "ExportDefaultDeclaration") {
|
38234 | return (
|
38235 |
|
38236 |
|
38237 | shouldWrapFunctionForExportDefault(path, options) ||
|
38238 | node.type === "SequenceExpression"
|
38239 | );
|
38240 | }
|
38241 |
|
38242 | if (parent.type === "Decorator" && parent.expression === node) {
|
38243 | let hasCallExpression = false;
|
38244 | let hasMemberExpression = false;
|
38245 | let current = node;
|
38246 |
|
38247 | while (current) {
|
38248 | switch (current.type) {
|
38249 | case "MemberExpression":
|
38250 | hasMemberExpression = true;
|
38251 | current = current.object;
|
38252 | break;
|
38253 |
|
38254 | case "CallExpression":
|
38255 | if (
|
38256 |
|
38257 | hasMemberExpression ||
|
38258 |
|
38259 | hasCallExpression) {
|
38260 | return true;
|
38261 | }
|
38262 |
|
38263 | hasCallExpression = true;
|
38264 | current = current.callee;
|
38265 | break;
|
38266 |
|
38267 | case "Identifier":
|
38268 | return false;
|
38269 |
|
38270 | default:
|
38271 | return true;
|
38272 | }
|
38273 | }
|
38274 |
|
38275 | return true;
|
38276 | }
|
38277 |
|
38278 | if (parent.type === "ArrowFunctionExpression" && parent.body === node && node.type !== "SequenceExpression" &&
|
38279 | util$1.startsWithNoLookaheadToken(node,
|
38280 |
|
38281 | false) || parent.type === "ExpressionStatement" && util$1.startsWithNoLookaheadToken(node,
|
38282 |
|
38283 | true)) {
|
38284 | return true;
|
38285 | }
|
38286 |
|
38287 | switch (node.type) {
|
38288 | case "SpreadElement":
|
38289 | case "SpreadProperty":
|
38290 | return parent.type === "MemberExpression" && name === "object" && parent.object === node;
|
38291 |
|
38292 | case "UpdateExpression":
|
38293 | if (parent.type === "UnaryExpression") {
|
38294 | return node.prefix && (node.operator === "++" && parent.operator === "+" || node.operator === "--" && parent.operator === "-");
|
38295 | }
|
38296 |
|
38297 |
|
38298 |
|
38299 | case "UnaryExpression":
|
38300 | switch (parent.type) {
|
38301 | case "UnaryExpression":
|
38302 | return node.operator === parent.operator && (node.operator === "+" || node.operator === "-");
|
38303 |
|
38304 | case "BindExpression":
|
38305 | return true;
|
38306 |
|
38307 | case "MemberExpression":
|
38308 | case "OptionalMemberExpression":
|
38309 | return name === "object";
|
38310 |
|
38311 | case "TaggedTemplateExpression":
|
38312 | return true;
|
38313 |
|
38314 | case "NewExpression":
|
38315 | case "CallExpression":
|
38316 | case "OptionalCallExpression":
|
38317 | return name === "callee";
|
38318 |
|
38319 | case "BinaryExpression":
|
38320 | return parent.operator === "**" && name === "left";
|
38321 |
|
38322 | case "TSNonNullExpression":
|
38323 | return true;
|
38324 |
|
38325 | default:
|
38326 | return false;
|
38327 | }
|
38328 |
|
38329 | case "BinaryExpression":
|
38330 | {
|
38331 | if (parent.type === "UpdateExpression") {
|
38332 | return true;
|
38333 | }
|
38334 |
|
38335 | const isLeftOfAForStatement = node => {
|
38336 | let i = 0;
|
38337 |
|
38338 | while (node) {
|
38339 | const parent = path.getParentNode(i++);
|
38340 |
|
38341 | if (!parent) {
|
38342 | return false;
|
38343 | }
|
38344 |
|
38345 | if (parent.type === "ForStatement" && parent.init === node) {
|
38346 | return true;
|
38347 | }
|
38348 |
|
38349 | node = parent;
|
38350 | }
|
38351 |
|
38352 | return false;
|
38353 | };
|
38354 |
|
38355 | if (node.operator === "in" && isLeftOfAForStatement(node)) {
|
38356 | return true;
|
38357 | }
|
38358 | }
|
38359 |
|
38360 |
|
38361 | case "TSTypeAssertion":
|
38362 | case "TSAsExpression":
|
38363 | case "LogicalExpression":
|
38364 | switch (parent.type) {
|
38365 | case "ConditionalExpression":
|
38366 | return node.type === "TSAsExpression";
|
38367 |
|
38368 | case "CallExpression":
|
38369 | case "NewExpression":
|
38370 | case "OptionalCallExpression":
|
38371 | return name === "callee";
|
38372 |
|
38373 | case "ClassExpression":
|
38374 | case "ClassDeclaration":
|
38375 | return name === "superClass" && parent.superClass === node;
|
38376 |
|
38377 | case "TSTypeAssertion":
|
38378 | case "TaggedTemplateExpression":
|
38379 | case "UnaryExpression":
|
38380 | case "JSXSpreadAttribute":
|
38381 | case "SpreadElement":
|
38382 | case "SpreadProperty":
|
38383 | case "BindExpression":
|
38384 | case "AwaitExpression":
|
38385 | case "TSAsExpression":
|
38386 | case "TSNonNullExpression":
|
38387 | case "UpdateExpression":
|
38388 | return true;
|
38389 |
|
38390 | case "MemberExpression":
|
38391 | case "OptionalMemberExpression":
|
38392 | return name === "object";
|
38393 |
|
38394 | case "AssignmentExpression":
|
38395 | return parent.left === node && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression");
|
38396 |
|
38397 | case "LogicalExpression":
|
38398 | if (node.type === "LogicalExpression") {
|
38399 | return parent.operator !== node.operator;
|
38400 | }
|
38401 |
|
38402 |
|
38403 |
|
38404 | case "BinaryExpression":
|
38405 | {
|
38406 | if (!node.operator && node.type !== "TSTypeAssertion") {
|
38407 | return true;
|
38408 | }
|
38409 |
|
38410 | const po = parent.operator;
|
38411 | const pp = util$1.getPrecedence(po);
|
38412 | const no = node.operator;
|
38413 | const np = util$1.getPrecedence(no);
|
38414 |
|
38415 | if (pp > np) {
|
38416 | return true;
|
38417 | }
|
38418 |
|
38419 | if (pp === np && name === "right") {
|
38420 | assert$1.strictEqual(parent.right, node);
|
38421 | return true;
|
38422 | }
|
38423 |
|
38424 | if (pp === np && !util$1.shouldFlatten(po, no)) {
|
38425 | return true;
|
38426 | }
|
38427 |
|
38428 | if (pp < np && no === "%") {
|
38429 | return po === "+" || po === "-";
|
38430 | }
|
38431 |
|
38432 |
|
38433 |
|
38434 | if (util$1.isBitwiseOperator(po)) {
|
38435 | return true;
|
38436 | }
|
38437 |
|
38438 | return false;
|
38439 | }
|
38440 |
|
38441 | default:
|
38442 | return false;
|
38443 | }
|
38444 |
|
38445 | case "SequenceExpression":
|
38446 | switch (parent.type) {
|
38447 | case "ReturnStatement":
|
38448 | return false;
|
38449 |
|
38450 | case "ForStatement":
|
38451 |
|
38452 |
|
38453 |
|
38454 |
|
38455 | return false;
|
38456 |
|
38457 | case "ExpressionStatement":
|
38458 | return name !== "expression";
|
38459 |
|
38460 | case "ArrowFunctionExpression":
|
38461 |
|
38462 |
|
38463 | return name !== "body";
|
38464 |
|
38465 | default:
|
38466 |
|
38467 |
|
38468 | return true;
|
38469 | }
|
38470 |
|
38471 | case "YieldExpression":
|
38472 | if (parent.type === "UnaryExpression" || parent.type === "AwaitExpression" || parent.type === "TSAsExpression" || parent.type === "TSNonNullExpression") {
|
38473 | return true;
|
38474 | }
|
38475 |
|
38476 |
|
38477 |
|
38478 | case "AwaitExpression":
|
38479 | switch (parent.type) {
|
38480 | case "TaggedTemplateExpression":
|
38481 | case "UnaryExpression":
|
38482 | case "BinaryExpression":
|
38483 | case "LogicalExpression":
|
38484 | case "SpreadElement":
|
38485 | case "SpreadProperty":
|
38486 | case "TSAsExpression":
|
38487 | case "TSNonNullExpression":
|
38488 | case "BindExpression":
|
38489 | return true;
|
38490 |
|
38491 | case "MemberExpression":
|
38492 | case "OptionalMemberExpression":
|
38493 | return name === "object";
|
38494 |
|
38495 | case "NewExpression":
|
38496 | case "CallExpression":
|
38497 | case "OptionalCallExpression":
|
38498 | return name === "callee";
|
38499 |
|
38500 | case "ConditionalExpression":
|
38501 | return parent.test === node;
|
38502 |
|
38503 | default:
|
38504 | return false;
|
38505 | }
|
38506 |
|
38507 | case "TSJSDocFunctionType":
|
38508 | case "TSConditionalType":
|
38509 | if (parent.type === "TSConditionalType" && node === parent.extendsType) {
|
38510 | return true;
|
38511 | }
|
38512 |
|
38513 |
|
38514 |
|
38515 | case "TSFunctionType":
|
38516 | case "TSConstructorType":
|
38517 | if (parent.type === "TSConditionalType" && node === parent.checkType) {
|
38518 | return true;
|
38519 | }
|
38520 |
|
38521 |
|
38522 |
|
38523 | case "TSUnionType":
|
38524 | case "TSIntersectionType":
|
38525 | if (parent.type === "TSUnionType" || parent.type === "TSIntersectionType") {
|
38526 | return true;
|
38527 | }
|
38528 |
|
38529 |
|
38530 |
|
38531 | case "TSTypeOperator":
|
38532 | case "TSInferType":
|
38533 | return parent.type === "TSArrayType" || parent.type === "TSOptionalType" || parent.type === "TSRestType" || parent.type === "TSIndexedAccessType" && node === parent.objectType || parent.type === "TSTypeOperator" || parent.type === "TSTypeAnnotation" && /^TSJSDoc/.test(path.getParentNode(1).type);
|
38534 |
|
38535 | case "ArrayTypeAnnotation":
|
38536 | return parent.type === "NullableTypeAnnotation";
|
38537 |
|
38538 | case "IntersectionTypeAnnotation":
|
38539 | case "UnionTypeAnnotation":
|
38540 | return parent.type === "ArrayTypeAnnotation" || parent.type === "NullableTypeAnnotation" || parent.type === "IntersectionTypeAnnotation" || parent.type === "UnionTypeAnnotation";
|
38541 |
|
38542 | case "NullableTypeAnnotation":
|
38543 | return parent.type === "ArrayTypeAnnotation";
|
38544 |
|
38545 | case "FunctionTypeAnnotation":
|
38546 | {
|
38547 | const ancestor = parent.type === "NullableTypeAnnotation" ? path.getParentNode(1) : parent;
|
38548 | return ancestor.type === "UnionTypeAnnotation" || ancestor.type === "IntersectionTypeAnnotation" || ancestor.type === "ArrayTypeAnnotation" ||
|
38549 |
|
38550 |
|
38551 | ancestor.type === "NullableTypeAnnotation";
|
38552 | }
|
38553 |
|
38554 | case "StringLiteral":
|
38555 | case "NumericLiteral":
|
38556 | case "Literal":
|
38557 | if (typeof node.value === "string" && parent.type === "ExpressionStatement" && (
|
38558 |
|
38559 | options.parser !== "typescript" && !parent.directive || options.parser === "typescript" && options.originalText.charAt(options.locStart(node) - 1) === "(")) {
|
38560 |
|
38561 | const grandParent = path.getParentNode(1);
|
38562 | return grandParent.type === "Program" || grandParent.type === "BlockStatement";
|
38563 | }
|
38564 |
|
38565 | return parent.type === "MemberExpression" && typeof node.value === "number" && name === "object" && parent.object === node;
|
38566 |
|
38567 | case "AssignmentExpression":
|
38568 | {
|
38569 | const grandParent = path.getParentNode(1);
|
38570 |
|
38571 | if (parent.type === "ArrowFunctionExpression" && parent.body === node) {
|
38572 | return true;
|
38573 | } else if (parent.type === "ClassProperty" && parent.key === node && parent.computed) {
|
38574 | return false;
|
38575 | } else if (parent.type === "TSPropertySignature" && parent.name === node) {
|
38576 | return false;
|
38577 | } else if (parent.type === "ForStatement" && (parent.init === node || parent.update === node)) {
|
38578 | return false;
|
38579 | } else if (parent.type === "ExpressionStatement") {
|
38580 | return node.left.type === "ObjectPattern";
|
38581 | } else if (parent.type === "TSPropertySignature" && parent.key === node) {
|
38582 | return false;
|
38583 | } else if (parent.type === "AssignmentExpression") {
|
38584 | return false;
|
38585 | } else if (parent.type === "SequenceExpression" && grandParent && grandParent.type === "ForStatement" && (grandParent.init === parent || grandParent.update === parent)) {
|
38586 | return false;
|
38587 | } else if (parent.type === "Property" && parent.value === node) {
|
38588 | return false;
|
38589 | } else if (parent.type === "NGChainedExpression") {
|
38590 | return false;
|
38591 | }
|
38592 |
|
38593 | return true;
|
38594 | }
|
38595 |
|
38596 | case "ConditionalExpression":
|
38597 | switch (parent.type) {
|
38598 | case "TaggedTemplateExpression":
|
38599 | case "UnaryExpression":
|
38600 | case "SpreadElement":
|
38601 | case "SpreadProperty":
|
38602 | case "BinaryExpression":
|
38603 | case "LogicalExpression":
|
38604 | case "NGPipeExpression":
|
38605 | case "ExportDefaultDeclaration":
|
38606 | case "AwaitExpression":
|
38607 | case "JSXSpreadAttribute":
|
38608 | case "TSTypeAssertion":
|
38609 | case "TypeCastExpression":
|
38610 | case "TSAsExpression":
|
38611 | case "TSNonNullExpression":
|
38612 | return true;
|
38613 |
|
38614 | case "NewExpression":
|
38615 | case "CallExpression":
|
38616 | case "OptionalCallExpression":
|
38617 | return name === "callee";
|
38618 |
|
38619 | case "ConditionalExpression":
|
38620 | return name === "test" && parent.test === node;
|
38621 |
|
38622 | case "MemberExpression":
|
38623 | case "OptionalMemberExpression":
|
38624 | return name === "object";
|
38625 |
|
38626 | default:
|
38627 | return false;
|
38628 | }
|
38629 |
|
38630 | case "FunctionExpression":
|
38631 | switch (parent.type) {
|
38632 | case "NewExpression":
|
38633 | case "CallExpression":
|
38634 | case "OptionalCallExpression":
|
38635 |
|
38636 |
|
38637 | return name === "callee";
|
38638 |
|
38639 | case "TaggedTemplateExpression":
|
38640 | return true;
|
38641 |
|
38642 |
|
38643 | default:
|
38644 | return false;
|
38645 | }
|
38646 |
|
38647 | case "ArrowFunctionExpression":
|
38648 | switch (parent.type) {
|
38649 | case "NewExpression":
|
38650 | case "CallExpression":
|
38651 | case "OptionalCallExpression":
|
38652 | return name === "callee";
|
38653 |
|
38654 | case "MemberExpression":
|
38655 | case "OptionalMemberExpression":
|
38656 | return name === "object";
|
38657 |
|
38658 | case "TSAsExpression":
|
38659 | case "BindExpression":
|
38660 | case "TaggedTemplateExpression":
|
38661 | case "UnaryExpression":
|
38662 | case "LogicalExpression":
|
38663 | case "BinaryExpression":
|
38664 | case "AwaitExpression":
|
38665 | case "TSTypeAssertion":
|
38666 | return true;
|
38667 |
|
38668 | case "ConditionalExpression":
|
38669 | return name === "test";
|
38670 |
|
38671 | default:
|
38672 | return false;
|
38673 | }
|
38674 |
|
38675 | case "ClassExpression":
|
38676 | switch (parent.type) {
|
38677 | case "NewExpression":
|
38678 | return name === "callee" && parent.callee === node;
|
38679 |
|
38680 | default:
|
38681 | return false;
|
38682 | }
|
38683 |
|
38684 | case "OptionalMemberExpression":
|
38685 | case "OptionalCallExpression":
|
38686 | if (parent.type === "MemberExpression" && name === "object" || (parent.type === "CallExpression" || parent.type === "NewExpression") && name === "callee") {
|
38687 | return true;
|
38688 | }
|
38689 |
|
38690 |
|
38691 |
|
38692 | case "CallExpression":
|
38693 | case "MemberExpression":
|
38694 | case "TaggedTemplateExpression":
|
38695 | case "TSNonNullExpression":
|
38696 | if ((parent.type === "BindExpression" || parent.type === "NewExpression") && name === "callee") {
|
38697 | let object = node;
|
38698 |
|
38699 | while (object) {
|
38700 | switch (object.type) {
|
38701 | case "CallExpression":
|
38702 | case "OptionalCallExpression":
|
38703 | return true;
|
38704 |
|
38705 | case "MemberExpression":
|
38706 | case "OptionalMemberExpression":
|
38707 | case "BindExpression":
|
38708 | object = object.object;
|
38709 | break;
|
38710 |
|
38711 |
|
38712 |
|
38713 | case "TaggedTemplateExpression":
|
38714 | object = object.tag;
|
38715 | break;
|
38716 |
|
38717 | case "TSNonNullExpression":
|
38718 | object = object.expression;
|
38719 | break;
|
38720 |
|
38721 | default:
|
38722 | return false;
|
38723 | }
|
38724 | }
|
38725 | }
|
38726 |
|
38727 | return false;
|
38728 |
|
38729 | case "BindExpression":
|
38730 | return (parent.type === "BindExpression" || parent.type === "NewExpression") && name === "callee" || (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && name === "object";
|
38731 |
|
38732 | case "NGPipeExpression":
|
38733 | if (parent.type === "NGRoot" || parent.type === "NGMicrosyntaxExpression" || parent.type === "ObjectProperty" || parent.type === "ArrayExpression" || (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.arguments[name] === node || parent.type === "NGPipeExpression" && name === "right" || parent.type === "MemberExpression" && name === "property" || parent.type === "AssignmentExpression") {
|
38734 | return false;
|
38735 | }
|
38736 |
|
38737 | return true;
|
38738 |
|
38739 | case "JSXFragment":
|
38740 | case "JSXElement":
|
38741 | return name === "callee" || parent.type !== "ArrayExpression" && parent.type !== "ArrowFunctionExpression" && parent.type !== "AssignmentExpression" && parent.type !== "AssignmentPattern" && parent.type !== "BinaryExpression" && parent.type !== "CallExpression" && parent.type !== "NewExpression" && parent.type !== "ConditionalExpression" && parent.type !== "ExpressionStatement" && parent.type !== "JsExpressionRoot" && parent.type !== "JSXAttribute" && parent.type !== "JSXElement" && parent.type !== "JSXExpressionContainer" && parent.type !== "JSXFragment" && parent.type !== "LogicalExpression" && parent.type !== "ObjectProperty" && parent.type !== "OptionalCallExpression" && parent.type !== "Property" && parent.type !== "ReturnStatement" && parent.type !== "ThrowStatement" && parent.type !== "TypeCastExpression" && parent.type !== "VariableDeclarator" && parent.type !== "YieldExpression";
|
38742 |
|
38743 | case "TypeAnnotation":
|
38744 | return name === "returnType" && parent.type === "ArrowFunctionExpression" && includesFunctionTypeInObjectType(node);
|
38745 | }
|
38746 |
|
38747 | return false;
|
38748 | }
|
38749 |
|
38750 | function isStatement(node) {
|
38751 | return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "EnumDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "TSDeclareFunction" || node.type === "TSEnumDeclaration" || node.type === "TSImportEqualsDeclaration" || node.type === "TSInterfaceDeclaration" || node.type === "TSModuleDeclaration" || node.type === "TSNamespaceExportDeclaration" || node.type === "TypeAlias" || node.type === "VariableDeclaration" || node.type === "WhileStatement" || node.type === "WithStatement";
|
38752 | }
|
38753 |
|
38754 | function includesFunctionTypeInObjectType(node) {
|
38755 | return hasNode$1(node, n1 => n1.type === "ObjectTypeAnnotation" && hasNode$1(n1, n2 => n2.type === "FunctionTypeAnnotation" || undefined) || undefined);
|
38756 | }
|
38757 |
|
38758 | function endsWithRightBracket(node) {
|
38759 | switch (node.type) {
|
38760 | case "ObjectExpression":
|
38761 | return true;
|
38762 |
|
38763 | default:
|
38764 | return false;
|
38765 | }
|
38766 | }
|
38767 |
|
38768 | function isFollowedByRightBracket(path) {
|
38769 | const node = path.getValue();
|
38770 | const parent = path.getParentNode();
|
38771 | const name = path.getName();
|
38772 |
|
38773 | switch (parent.type) {
|
38774 | case "NGPipeExpression":
|
38775 | if (typeof name === "number" && parent.arguments[name] === node && parent.arguments.length - 1 === name) {
|
38776 | return path.callParent(isFollowedByRightBracket);
|
38777 | }
|
38778 |
|
38779 | break;
|
38780 |
|
38781 | case "ObjectProperty":
|
38782 | if (name === "value") {
|
38783 | const parentParent = path.getParentNode(1);
|
38784 | return parentParent.properties[parentParent.properties.length - 1] === parent;
|
38785 | }
|
38786 |
|
38787 | break;
|
38788 |
|
38789 | case "BinaryExpression":
|
38790 | case "LogicalExpression":
|
38791 | if (name === "right") {
|
38792 | return path.callParent(isFollowedByRightBracket);
|
38793 | }
|
38794 |
|
38795 | break;
|
38796 |
|
38797 | case "ConditionalExpression":
|
38798 | if (name === "alternate") {
|
38799 | return path.callParent(isFollowedByRightBracket);
|
38800 | }
|
38801 |
|
38802 | break;
|
38803 |
|
38804 | case "UnaryExpression":
|
38805 | if (parent.prefix) {
|
38806 | return path.callParent(isFollowedByRightBracket);
|
38807 | }
|
38808 |
|
38809 | break;
|
38810 | }
|
38811 |
|
38812 | return false;
|
38813 | }
|
38814 |
|
38815 | function shouldWrapFunctionForExportDefault(path, options) {
|
38816 | const node = path.getValue();
|
38817 | const parent = path.getParentNode();
|
38818 |
|
38819 | if (node.type === "FunctionExpression" || node.type === "ClassExpression") {
|
38820 | return parent.type === "ExportDefaultDeclaration" ||
|
38821 |
|
38822 |
|
38823 | !needsParens(path, options);
|
38824 | }
|
38825 |
|
38826 | if (!hasNakedLeftSide$1(node) || parent.type !== "ExportDefaultDeclaration" && needsParens(path, options)) {
|
38827 | return false;
|
38828 | }
|
38829 |
|
38830 | return path.call(childPath => shouldWrapFunctionForExportDefault(childPath, options), ...getLeftSidePathName$1(path, node));
|
38831 | }
|
38832 |
|
38833 | var needsParens_1 = needsParens;
|
38834 |
|
38835 | const {
|
38836 | builders: {
|
38837 | concat: concat$5,
|
38838 | join: join$3,
|
38839 | line: line$3
|
38840 | }
|
38841 | } = document;
|
38842 |
|
38843 | function printHtmlBinding(path, options, print) {
|
38844 | const node = path.getValue();
|
38845 |
|
38846 | if (options.__onHtmlBindingRoot && path.getName() === null) {
|
38847 | options.__onHtmlBindingRoot(node, options);
|
38848 | }
|
38849 |
|
38850 | if (node.type !== "File") {
|
38851 | return;
|
38852 | }
|
38853 |
|
38854 | if (options.__isVueForBindingLeft) {
|
38855 | return path.call(functionDeclarationPath => {
|
38856 | const {
|
38857 | params
|
38858 | } = functionDeclarationPath.getValue();
|
38859 | return concat$5([params.length > 1 ? "(" : "", join$3(concat$5([",", line$3]), functionDeclarationPath.map(print, "params")), params.length > 1 ? ")" : ""]);
|
38860 | }, "program", "body", 0);
|
38861 | }
|
38862 |
|
38863 | if (options.__isVueSlotScope) {
|
38864 | return path.call(functionDeclarationPath => join$3(concat$5([",", line$3]), functionDeclarationPath.map(print, "params")), "program", "body", 0);
|
38865 | }
|
38866 | }
|
38867 |
|
38868 |
|
38869 | function isVueEventBindingExpression(node) {
|
38870 | switch (node.type) {
|
38871 | case "MemberExpression":
|
38872 | switch (node.property.type) {
|
38873 | case "Identifier":
|
38874 | case "NumericLiteral":
|
38875 | case "StringLiteral":
|
38876 | return isVueEventBindingExpression(node.object);
|
38877 | }
|
38878 |
|
38879 | return false;
|
38880 |
|
38881 | case "Identifier":
|
38882 | return true;
|
38883 |
|
38884 | default:
|
38885 | return false;
|
38886 | }
|
38887 | }
|
38888 |
|
38889 | var htmlBinding = {
|
38890 | isVueEventBindingExpression,
|
38891 | printHtmlBinding
|
38892 | };
|
38893 |
|
38894 | function preprocess(ast, options) {
|
38895 | switch (options.parser) {
|
38896 | case "json":
|
38897 | case "json5":
|
38898 | case "json-stringify":
|
38899 | case "__js_expression":
|
38900 | case "__vue_expression":
|
38901 | return Object.assign({}, ast, {
|
38902 | type: options.parser.startsWith("__") ? "JsExpressionRoot" : "JsonRoot",
|
38903 | node: ast,
|
38904 | comments: [],
|
38905 | rootMarker: options.rootMarker
|
38906 | });
|
38907 |
|
38908 | default:
|
38909 | return ast;
|
38910 | }
|
38911 | }
|
38912 |
|
38913 | var preprocess_1 = preprocess;
|
38914 |
|
38915 | const {
|
38916 | shouldFlatten: shouldFlatten$1,
|
38917 | getNextNonSpaceNonCommentCharacter: getNextNonSpaceNonCommentCharacter$1,
|
38918 | hasNewline: hasNewline$4,
|
38919 | hasNewlineInRange: hasNewlineInRange$3,
|
38920 | getLast: getLast$2,
|
38921 | getStringWidth: getStringWidth$3,
|
38922 | printString: printString$1,
|
38923 | printNumber: printNumber$1,
|
38924 | hasIgnoreComment: hasIgnoreComment$2,
|
38925 | hasNodeIgnoreComment: hasNodeIgnoreComment$2,
|
38926 | getPenultimate: getPenultimate$1,
|
38927 | startsWithNoLookaheadToken: startsWithNoLookaheadToken$1,
|
38928 | getIndentSize: getIndentSize$2,
|
38929 | getPreferredQuote: getPreferredQuote$1
|
38930 | } = util$1;
|
38931 | const {
|
38932 | isNextLineEmpty: isNextLineEmpty$2,
|
38933 | isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$2,
|
38934 | getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$3
|
38935 | } = utilShared;
|
38936 | const {
|
38937 | insertPragma: insertPragma$1
|
38938 | } = pragma;
|
38939 | const {
|
38940 | printHtmlBinding: printHtmlBinding$1,
|
38941 | isVueEventBindingExpression: isVueEventBindingExpression$1
|
38942 | } = htmlBinding;
|
38943 | const {
|
38944 | classChildNeedsASIProtection: classChildNeedsASIProtection$1,
|
38945 | classPropMayCauseASIProblems: classPropMayCauseASIProblems$1,
|
38946 | conditionalExpressionChainContainsJSX: conditionalExpressionChainContainsJSX$1,
|
38947 | getFlowVariance: getFlowVariance$1,
|
38948 | getLeftSidePathName: getLeftSidePathName$2,
|
38949 | getParentExportDeclaration: getParentExportDeclaration$1,
|
38950 | getTypeScriptMappedTypeModifier: getTypeScriptMappedTypeModifier$1,
|
38951 | hasDanglingComments: hasDanglingComments$1,
|
38952 | hasFlowAnnotationComment: hasFlowAnnotationComment$1,
|
38953 | hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$2,
|
38954 | hasLeadingComment: hasLeadingComment$3,
|
38955 | hasLeadingOwnLineComment: hasLeadingOwnLineComment$1,
|
38956 | hasNakedLeftSide: hasNakedLeftSide$2,
|
38957 | hasNewlineBetweenOrAfterDecorators: hasNewlineBetweenOrAfterDecorators$1,
|
38958 | hasNgSideEffect: hasNgSideEffect$1,
|
38959 | hasPrettierIgnore: hasPrettierIgnore$1,
|
38960 | hasTrailingComment: hasTrailingComment$1,
|
38961 | identity: identity$2,
|
38962 | isBinaryish: isBinaryish$1,
|
38963 | isCallOrOptionalCallExpression: isCallOrOptionalCallExpression$1,
|
38964 | isEmptyJSXElement: isEmptyJSXElement$1,
|
38965 | isExportDeclaration: isExportDeclaration$1,
|
38966 | isFlowAnnotationComment: isFlowAnnotationComment$1,
|
38967 | isFunctionCompositionArgs: isFunctionCompositionArgs$1,
|
38968 | isFunctionNotation: isFunctionNotation$1,
|
38969 | isFunctionOrArrowExpression: isFunctionOrArrowExpression$1,
|
38970 | isGetterOrSetter: isGetterOrSetter$1,
|
38971 | isJestEachTemplateLiteral: isJestEachTemplateLiteral$1,
|
38972 | isJSXNode: isJSXNode$1,
|
38973 | isJSXWhitespaceExpression: isJSXWhitespaceExpression$1,
|
38974 | isLastStatement: isLastStatement$1,
|
38975 | isLiteral: isLiteral$1,
|
38976 | isLongCurriedCallExpression: isLongCurriedCallExpression$1,
|
38977 | isMeaningfulJSXText: isMeaningfulJSXText$1,
|
38978 | isMemberExpressionChain: isMemberExpressionChain$1,
|
38979 | isMemberish: isMemberish$1,
|
38980 | isNgForOf: isNgForOf$1,
|
38981 | isNumericLiteral: isNumericLiteral$1,
|
38982 | isObjectType: isObjectType$1,
|
38983 | isObjectTypePropertyAFunction: isObjectTypePropertyAFunction$1,
|
38984 | isSimpleCallArgument: isSimpleCallArgument$1,
|
38985 | isSimpleFlowType: isSimpleFlowType$1,
|
38986 | isSimpleTemplateLiteral: isSimpleTemplateLiteral$1,
|
38987 | isStringLiteral: isStringLiteral$1,
|
38988 | isStringPropSafeToCoerceToIdentifier: isStringPropSafeToCoerceToIdentifier$1,
|
38989 | isTemplateOnItsOwnLine: isTemplateOnItsOwnLine$1,
|
38990 | isTestCall: isTestCall$1,
|
38991 | isTheOnlyJSXElementInMarkdown: isTheOnlyJSXElementInMarkdown$1,
|
38992 | isTSXFile: isTSXFile$1,
|
38993 | isTypeAnnotationAFunction: isTypeAnnotationAFunction$1,
|
38994 | matchJsxWhitespaceRegex: matchJsxWhitespaceRegex$1,
|
38995 | needsHardlineAfterDanglingComment: needsHardlineAfterDanglingComment$1,
|
38996 | rawText: rawText$1,
|
38997 | returnArgumentHasLeadingComment: returnArgumentHasLeadingComment$1
|
38998 | } = utils$6;
|
38999 | const needsQuoteProps = new WeakMap();
|
39000 | const {
|
39001 | builders: {
|
39002 | concat: concat$6,
|
39003 | join: join$4,
|
39004 | line: line$4,
|
39005 | hardline: hardline$4,
|
39006 | softline: softline$2,
|
39007 | literalline: literalline$2,
|
39008 | group: group$2,
|
39009 | indent: indent$3,
|
39010 | align: align$1,
|
39011 | conditionalGroup: conditionalGroup$1,
|
39012 | fill: fill$3,
|
39013 | ifBreak: ifBreak$1,
|
39014 | breakParent: breakParent$2,
|
39015 | lineSuffixBoundary: lineSuffixBoundary$1,
|
39016 | addAlignmentToDoc: addAlignmentToDoc$2,
|
39017 | dedent: dedent$1
|
39018 | },
|
39019 | utils: {
|
39020 | willBreak: willBreak$1,
|
39021 | isLineNext: isLineNext$1,
|
39022 | isEmpty: isEmpty$1,
|
39023 | removeLines: removeLines$1
|
39024 | },
|
39025 | printer: {
|
39026 | printDocToString: printDocToString$2
|
39027 | }
|
39028 | } = document;
|
39029 | let uid = 0;
|
39030 |
|
39031 | function shouldPrintComma(options, level) {
|
39032 | level = level || "es5";
|
39033 |
|
39034 | switch (options.trailingComma) {
|
39035 | case "all":
|
39036 | if (level === "all") {
|
39037 | return true;
|
39038 | }
|
39039 |
|
39040 |
|
39041 |
|
39042 | case "es5":
|
39043 | if (level === "es5") {
|
39044 | return true;
|
39045 | }
|
39046 |
|
39047 |
|
39048 |
|
39049 | case "none":
|
39050 | default:
|
39051 | return false;
|
39052 | }
|
39053 | }
|
39054 |
|
39055 | function genericPrint(path, options, printPath, args) {
|
39056 | const node = path.getValue();
|
39057 | let needsParens = false;
|
39058 | const linesWithoutParens = printPathNoParens(path, options, printPath, args);
|
39059 |
|
39060 | if (!node || isEmpty$1(linesWithoutParens)) {
|
39061 | return linesWithoutParens;
|
39062 | }
|
39063 |
|
39064 | const parentExportDecl = getParentExportDeclaration$1(path);
|
39065 | const decorators = [];
|
39066 |
|
39067 | if (node.type === "ClassMethod" || node.type === "ClassPrivateMethod" || node.type === "ClassProperty" || node.type === "TSAbstractClassProperty" || node.type === "ClassPrivateProperty" || node.type === "MethodDefinition" || node.type === "TSAbstractMethodDefinition" || node.type === "TSDeclareMethod") ; else if (node.decorators && node.decorators.length > 0 &&
|
39068 |
|
39069 |
|
39070 | !(parentExportDecl && options.locStart(parentExportDecl, {
|
39071 | ignoreDecorators: true
|
39072 | }) > options.locStart(node.decorators[0]))) {
|
39073 | const shouldBreak = node.type === "ClassExpression" || node.type === "ClassDeclaration" || hasNewlineBetweenOrAfterDecorators$1(node, options);
|
39074 | const separator = shouldBreak ? hardline$4 : line$4;
|
39075 | path.each(decoratorPath => {
|
39076 | let decorator = decoratorPath.getValue();
|
39077 |
|
39078 | if (decorator.expression) {
|
39079 | decorator = decorator.expression;
|
39080 | } else {
|
39081 | decorator = decorator.callee;
|
39082 | }
|
39083 |
|
39084 | decorators.push(printPath(decoratorPath), separator);
|
39085 | }, "decorators");
|
39086 |
|
39087 | if (parentExportDecl) {
|
39088 | decorators.unshift(hardline$4);
|
39089 | }
|
39090 | } else if (isExportDeclaration$1(node) && node.declaration && node.declaration.decorators && node.declaration.decorators.length > 0 &&
|
39091 |
|
39092 | options.locStart(node, {
|
39093 | ignoreDecorators: true
|
39094 | }) > options.locStart(node.declaration.decorators[0])) {
|
39095 |
|
39096 |
|
39097 | path.each(decoratorPath => {
|
39098 | const decorator = decoratorPath.getValue();
|
39099 | const prefix = decorator.type === "Decorator" ? "" : "@";
|
39100 | decorators.push(prefix, printPath(decoratorPath), hardline$4);
|
39101 | }, "declaration", "decorators");
|
39102 | } else {
|
39103 |
|
39104 |
|
39105 | needsParens = needsParens_1(path, options);
|
39106 | }
|
39107 |
|
39108 | const parts = [];
|
39109 |
|
39110 | if (needsParens) {
|
39111 | parts.unshift("(");
|
39112 | }
|
39113 |
|
39114 | parts.push(linesWithoutParens);
|
39115 |
|
39116 | if (needsParens) {
|
39117 | const node = path.getValue();
|
39118 |
|
39119 | if (hasFlowShorthandAnnotationComment$2(node)) {
|
39120 | parts.push(" /*");
|
39121 | parts.push(node.trailingComments[0].value.trimStart());
|
39122 | parts.push("*/");
|
39123 | node.trailingComments[0].printed = true;
|
39124 | }
|
39125 |
|
39126 | parts.push(")");
|
39127 | }
|
39128 |
|
39129 | if (decorators.length > 0) {
|
39130 | return group$2(concat$6(decorators.concat(parts)));
|
39131 | }
|
39132 |
|
39133 | return concat$6(parts);
|
39134 | }
|
39135 |
|
39136 | function printDecorators(path, options, print) {
|
39137 | const node = path.getValue();
|
39138 | return group$2(concat$6([join$4(line$4, path.map(print, "decorators")), hasNewlineBetweenOrAfterDecorators$1(node, options) ? hardline$4 : line$4]));
|
39139 | }
|
39140 |
|
39141 |
|
39142 |
|
39143 |
|
39144 |
|
39145 |
|
39146 |
|
39147 |
|
39148 |
|
39149 |
|
39150 |
|
39151 |
|
39152 |
|
39153 |
|
39154 |
|
39155 |
|
39156 |
|
39157 |
|
39158 |
|
39159 |
|
39160 | function printTernaryOperator(path, options, print, operatorOptions) {
|
39161 | const node = path.getValue();
|
39162 | const consequentNode = node[operatorOptions.consequentNodePropertyName];
|
39163 | const alternateNode = node[operatorOptions.alternateNodePropertyName];
|
39164 | const parts = [];
|
39165 |
|
39166 |
|
39167 | let jsxMode = false;
|
39168 | const parent = path.getParentNode();
|
39169 | const isParentTest = parent.type === operatorOptions.conditionalNodeType && operatorOptions.testNodePropertyNames.some(prop => parent[prop] === node);
|
39170 | let forceNoIndent = parent.type === operatorOptions.conditionalNodeType && !isParentTest;
|
39171 |
|
39172 |
|
39173 |
|
39174 | let currentParent;
|
39175 | let previousParent;
|
39176 | let i = 0;
|
39177 |
|
39178 | do {
|
39179 | previousParent = currentParent || node;
|
39180 | currentParent = path.getParentNode(i);
|
39181 | i++;
|
39182 | } while (currentParent && currentParent.type === operatorOptions.conditionalNodeType && operatorOptions.testNodePropertyNames.every(prop => currentParent[prop] !== previousParent));
|
39183 |
|
39184 | const firstNonConditionalParent = currentParent || parent;
|
39185 | const lastConditionalParent = previousParent;
|
39186 |
|
39187 | if (operatorOptions.shouldCheckJsx && (isJSXNode$1(node[operatorOptions.testNodePropertyNames[0]]) || isJSXNode$1(consequentNode) || isJSXNode$1(alternateNode) || conditionalExpressionChainContainsJSX$1(lastConditionalParent))) {
|
39188 | jsxMode = true;
|
39189 | forceNoIndent = true;
|
39190 |
|
39191 |
|
39192 |
|
39193 | const wrap = doc => concat$6([ifBreak$1("(", ""), indent$3(concat$6([softline$2, doc])), softline$2, ifBreak$1(")", "")]);
|
39194 |
|
39195 |
|
39196 |
|
39197 |
|
39198 |
|
39199 | const isNil = node => node.type === "NullLiteral" || node.type === "Literal" && node.value === null || node.type === "Identifier" && node.name === "undefined";
|
39200 |
|
39201 | parts.push(" ? ", isNil(consequentNode) ? path.call(print, operatorOptions.consequentNodePropertyName) : wrap(path.call(print, operatorOptions.consequentNodePropertyName)), " : ", alternateNode.type === operatorOptions.conditionalNodeType || isNil(alternateNode) ? path.call(print, operatorOptions.alternateNodePropertyName) : wrap(path.call(print, operatorOptions.alternateNodePropertyName)));
|
39202 | } else {
|
39203 |
|
39204 | const part = concat$6([line$4, "? ", consequentNode.type === operatorOptions.conditionalNodeType ? ifBreak$1("", "(") : "", align$1(2, path.call(print, operatorOptions.consequentNodePropertyName)), consequentNode.type === operatorOptions.conditionalNodeType ? ifBreak$1("", ")") : "", line$4, ": ", alternateNode.type === operatorOptions.conditionalNodeType ? path.call(print, operatorOptions.alternateNodePropertyName) : align$1(2, path.call(print, operatorOptions.alternateNodePropertyName))]);
|
39205 | parts.push(parent.type !== operatorOptions.conditionalNodeType || parent[operatorOptions.alternateNodePropertyName] === node || isParentTest ? part : options.useTabs ? dedent$1(indent$3(part)) : align$1(Math.max(0, options.tabWidth - 2), part));
|
39206 | }
|
39207 |
|
39208 |
|
39209 |
|
39210 |
|
39211 | const maybeGroup = doc => parent === firstNonConditionalParent ? group$2(doc) : doc;
|
39212 |
|
39213 |
|
39214 |
|
39215 |
|
39216 |
|
39217 |
|
39218 | const breakClosingParen = !jsxMode && (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression" || parent.type === "NGPipeExpression" && parent.left === node) && !parent.computed;
|
39219 | const result = maybeGroup(concat$6([].concat((testDoc =>
|
39220 | |
39221 |
|
39222 |
|
39223 |
|
39224 |
|
39225 |
|
39226 |
|
39227 |
|
39228 |
|
39229 |
|
39230 | parent.type === operatorOptions.conditionalNodeType && parent[operatorOptions.alternateNodePropertyName] === node ? align$1(2, testDoc) : testDoc)(concat$6(operatorOptions.beforeParts())), forceNoIndent ? concat$6(parts) : indent$3(concat$6(parts)), operatorOptions.afterParts(breakClosingParen))));
|
39231 | return isParentTest ? group$2(concat$6([indent$3(concat$6([softline$2, result])), softline$2])) : result;
|
39232 | }
|
39233 |
|
39234 | function printPathNoParens(path, options, print, args) {
|
39235 | const n = path.getValue();
|
39236 | const semi = options.semi ? ";" : "";
|
39237 |
|
39238 | if (!n) {
|
39239 | return "";
|
39240 | }
|
39241 |
|
39242 | if (typeof n === "string") {
|
39243 | return n;
|
39244 | }
|
39245 |
|
39246 | const htmlBinding = printHtmlBinding$1(path, options, print);
|
39247 |
|
39248 | if (htmlBinding) {
|
39249 | return htmlBinding;
|
39250 | }
|
39251 |
|
39252 | let parts = [];
|
39253 |
|
39254 | switch (n.type) {
|
39255 | case "JsExpressionRoot":
|
39256 | return path.call(print, "node");
|
39257 |
|
39258 | case "JsonRoot":
|
39259 | return concat$6([path.call(print, "node"), hardline$4]);
|
39260 |
|
39261 | case "File":
|
39262 |
|
39263 |
|
39264 | if (n.program && n.program.interpreter) {
|
39265 | parts.push(path.call(programPath => programPath.call(print, "interpreter"), "program"));
|
39266 | }
|
39267 |
|
39268 | parts.push(path.call(print, "program"));
|
39269 | return concat$6(parts);
|
39270 |
|
39271 | case "Program":
|
39272 |
|
39273 | if (n.directives) {
|
39274 | path.each(childPath => {
|
39275 | parts.push(print(childPath), semi, hardline$4);
|
39276 |
|
39277 | if (isNextLineEmpty$2(options.originalText, childPath.getValue(), options.locEnd)) {
|
39278 | parts.push(hardline$4);
|
39279 | }
|
39280 | }, "directives");
|
39281 | }
|
39282 |
|
39283 | parts.push(path.call(bodyPath => {
|
39284 | return printStatementSequence(bodyPath, options, print);
|
39285 | }, "body"));
|
39286 | parts.push(comments.printDanglingComments(path, options,
|
39287 |
|
39288 | true));
|
39289 |
|
39290 | if (!n.body.every(({
|
39291 | type
|
39292 | }) => type === "EmptyStatement") || n.comments) {
|
39293 | parts.push(hardline$4);
|
39294 | }
|
39295 |
|
39296 | return concat$6(parts);
|
39297 |
|
39298 |
|
39299 | case "EmptyStatement":
|
39300 | return "";
|
39301 |
|
39302 | case "ExpressionStatement":
|
39303 |
|
39304 | if (n.directive) {
|
39305 | return concat$6([nodeStr(n.expression, options, true), semi]);
|
39306 | }
|
39307 |
|
39308 | if (options.parser === "__vue_event_binding") {
|
39309 | const parent = path.getParentNode();
|
39310 |
|
39311 | if (parent.type === "Program" && parent.body.length === 1 && parent.body[0] === n) {
|
39312 | return concat$6([path.call(print, "expression"), isVueEventBindingExpression$1(n.expression) ? ";" : ""]);
|
39313 | }
|
39314 | }
|
39315 |
|
39316 |
|
39317 | return concat$6([path.call(print, "expression"), isTheOnlyJSXElementInMarkdown$1(options, path) ? "" : semi]);
|
39318 |
|
39319 |
|
39320 | case "ParenthesizedExpression":
|
39321 | {
|
39322 | const shouldHug = !n.expression.comments;
|
39323 |
|
39324 | if (shouldHug) {
|
39325 | return concat$6(["(", path.call(print, "expression"), ")"]);
|
39326 | }
|
39327 |
|
39328 | return group$2(concat$6(["(", indent$3(concat$6([softline$2, path.call(print, "expression")])), softline$2, ")"]));
|
39329 | }
|
39330 |
|
39331 | case "AssignmentExpression":
|
39332 | return printAssignment(n.left, path.call(print, "left"), concat$6([" ", n.operator]), n.right, path.call(print, "right"), options);
|
39333 |
|
39334 | case "BinaryExpression":
|
39335 | case "LogicalExpression":
|
39336 | case "NGPipeExpression":
|
39337 | {
|
39338 | const parent = path.getParentNode();
|
39339 | const parentParent = path.getParentNode(1);
|
39340 | const isInsideParenthesis = n !== parent.body && (parent.type === "IfStatement" || parent.type === "WhileStatement" || parent.type === "SwitchStatement" || parent.type === "DoWhileStatement");
|
39341 | const parts = printBinaryishExpressions(path, print, options,
|
39342 |
|
39343 | false, isInsideParenthesis);
|
39344 |
|
39345 |
|
39346 |
|
39347 |
|
39348 |
|
39349 |
|
39350 |
|
39351 |
|
39352 |
|
39353 |
|
39354 | if (isInsideParenthesis) {
|
39355 | return concat$6(parts);
|
39356 | }
|
39357 |
|
39358 |
|
39359 |
|
39360 |
|
39361 |
|
39362 |
|
39363 |
|
39364 |
|
39365 |
|
39366 | if ((parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.callee === n || parent.type === "UnaryExpression" || (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && !parent.computed) {
|
39367 | return group$2(concat$6([indent$3(concat$6([softline$2, concat$6(parts)])), softline$2]));
|
39368 | }
|
39369 |
|
39370 |
|
39371 |
|
39372 | const shouldNotIndent = parent.type === "ReturnStatement" || parent.type === "ThrowStatement" || parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" || n.operator !== "|" && parent.type === "JsExpressionRoot" || n.type !== "NGPipeExpression" && (parent.type === "NGRoot" && options.parser === "__ng_binding" || parent.type === "NGMicrosyntaxExpression" && parentParent.type === "NGMicrosyntax" && parentParent.body.length === 1) || n === parent.body && parent.type === "ArrowFunctionExpression" || n !== parent.body && parent.type === "ForStatement" || parent.type === "ConditionalExpression" && parentParent.type !== "ReturnStatement" && parentParent.type !== "ThrowStatement" && parentParent.type !== "CallExpression" && parentParent.type !== "OptionalCallExpression" || parent.type === "TemplateLiteral";
|
39373 | const shouldIndentIfInlining = parent.type === "AssignmentExpression" || parent.type === "VariableDeclarator" || parent.type === "ClassProperty" || parent.type === "TSAbstractClassProperty" || parent.type === "ClassPrivateProperty" || parent.type === "ObjectProperty" || parent.type === "Property";
|
39374 | const samePrecedenceSubExpression = isBinaryish$1(n.left) && shouldFlatten$1(n.operator, n.left.operator);
|
39375 |
|
39376 | if (shouldNotIndent || shouldInlineLogicalExpression(n) && !samePrecedenceSubExpression || !shouldInlineLogicalExpression(n) && shouldIndentIfInlining) {
|
39377 | return group$2(concat$6(parts));
|
39378 | }
|
39379 |
|
39380 | if (parts.length === 0) {
|
39381 | return "";
|
39382 | }
|
39383 |
|
39384 |
|
39385 |
|
39386 |
|
39387 |
|
39388 |
|
39389 |
|
39390 |
|
39391 |
|
39392 | const hasJSX = isJSXNode$1(n.right);
|
39393 | const rest = concat$6(hasJSX ? parts.slice(1, -1) : parts.slice(1));
|
39394 | const groupId = Symbol("logicalChain-" + ++uid);
|
39395 | const chain = group$2(concat$6([
|
39396 |
|
39397 |
|
39398 | parts.length > 0 ? parts[0] : "", indent$3(rest)]), {
|
39399 | id: groupId
|
39400 | });
|
39401 |
|
39402 | if (!hasJSX) {
|
39403 | return chain;
|
39404 | }
|
39405 |
|
39406 | const jsxPart = getLast$2(parts);
|
39407 | return group$2(concat$6([chain, ifBreak$1(indent$3(jsxPart), jsxPart, {
|
39408 | groupId
|
39409 | })]));
|
39410 | }
|
39411 |
|
39412 | case "AssignmentPattern":
|
39413 | return concat$6([path.call(print, "left"), " = ", path.call(print, "right")]);
|
39414 |
|
39415 | case "TSTypeAssertion":
|
39416 | {
|
39417 | const shouldBreakAfterCast = !(n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression");
|
39418 | const castGroup = group$2(concat$6(["<", indent$3(concat$6([softline$2, path.call(print, "typeAnnotation")])), softline$2, ">"]));
|
39419 | const exprContents = concat$6([ifBreak$1("("), indent$3(concat$6([softline$2, path.call(print, "expression")])), softline$2, ifBreak$1(")")]);
|
39420 |
|
39421 | if (shouldBreakAfterCast) {
|
39422 | return conditionalGroup$1([concat$6([castGroup, path.call(print, "expression")]), concat$6([castGroup, group$2(exprContents, {
|
39423 | shouldBreak: true
|
39424 | })]), concat$6([castGroup, path.call(print, "expression")])]);
|
39425 | }
|
39426 |
|
39427 | return group$2(concat$6([castGroup, path.call(print, "expression")]));
|
39428 | }
|
39429 |
|
39430 | case "OptionalMemberExpression":
|
39431 | case "MemberExpression":
|
39432 | {
|
39433 | const parent = path.getParentNode();
|
39434 | let firstNonMemberParent;
|
39435 | let i = 0;
|
39436 |
|
39437 | do {
|
39438 | firstNonMemberParent = path.getParentNode(i);
|
39439 | i++;
|
39440 | } while (firstNonMemberParent && (firstNonMemberParent.type === "MemberExpression" || firstNonMemberParent.type === "OptionalMemberExpression" || firstNonMemberParent.type === "TSNonNullExpression"));
|
39441 |
|
39442 | const shouldInline = firstNonMemberParent && (firstNonMemberParent.type === "NewExpression" || firstNonMemberParent.type === "BindExpression" || firstNonMemberParent.type === "VariableDeclarator" && firstNonMemberParent.id.type !== "Identifier" || firstNonMemberParent.type === "AssignmentExpression" && firstNonMemberParent.left.type !== "Identifier") || n.computed || n.object.type === "Identifier" && n.property.type === "Identifier" && parent.type !== "MemberExpression" && parent.type !== "OptionalMemberExpression";
|
39443 | return concat$6([path.call(print, "object"), shouldInline ? printMemberLookup(path, options, print) : group$2(indent$3(concat$6([softline$2, printMemberLookup(path, options, print)])))]);
|
39444 | }
|
39445 |
|
39446 | case "MetaProperty":
|
39447 | return concat$6([path.call(print, "meta"), ".", path.call(print, "property")]);
|
39448 |
|
39449 | case "BindExpression":
|
39450 | if (n.object) {
|
39451 | parts.push(path.call(print, "object"));
|
39452 | }
|
39453 |
|
39454 | parts.push(group$2(indent$3(concat$6([softline$2, printBindExpressionCallee(path, options, print)]))));
|
39455 | return concat$6(parts);
|
39456 |
|
39457 | case "Identifier":
|
39458 | {
|
39459 | return concat$6([n.name, printOptionalToken(path), printTypeAnnotation(path, options, print)]);
|
39460 | }
|
39461 |
|
39462 | case "V8IntrinsicIdentifier":
|
39463 | return concat$6(["%", n.name]);
|
39464 |
|
39465 | case "SpreadElement":
|
39466 | case "SpreadElementPattern":
|
39467 | case "SpreadProperty":
|
39468 | case "SpreadPropertyPattern":
|
39469 | case "RestElement":
|
39470 | case "ObjectTypeSpreadProperty":
|
39471 | return concat$6(["...", path.call(print, "argument"), printTypeAnnotation(path, options, print)]);
|
39472 |
|
39473 | case "FunctionDeclaration":
|
39474 | case "FunctionExpression":
|
39475 | parts.push(printFunctionDeclaration(path, print, options));
|
39476 |
|
39477 | if (!n.body) {
|
39478 | parts.push(semi);
|
39479 | }
|
39480 |
|
39481 | return concat$6(parts);
|
39482 |
|
39483 | case "ArrowFunctionExpression":
|
39484 | {
|
39485 | if (n.async) {
|
39486 | parts.push("async ");
|
39487 | }
|
39488 |
|
39489 | if (shouldPrintParamsWithoutParens(path, options)) {
|
39490 | parts.push(path.call(print, "params", 0));
|
39491 | } else {
|
39492 | parts.push(group$2(concat$6([printFunctionParams(path, print, options,
|
39493 |
|
39494 | args && (args.expandLastArg || args.expandFirstArg),
|
39495 |
|
39496 | true), printReturnType(path, print, options)])));
|
39497 | }
|
39498 |
|
39499 | const dangling = comments.printDanglingComments(path, options,
|
39500 |
|
39501 | true, comment => {
|
39502 | const nextCharacter = getNextNonSpaceNonCommentCharacterIndex$3(options.originalText, comment, options.locEnd);
|
39503 | return options.originalText.slice(nextCharacter, nextCharacter + 2) === "=>";
|
39504 | });
|
39505 |
|
39506 | if (dangling) {
|
39507 | parts.push(" ", dangling);
|
39508 | }
|
39509 |
|
39510 | parts.push(" =>");
|
39511 | const body = path.call(bodyPath => print(bodyPath, args), "body");
|
39512 |
|
39513 |
|
39514 | if (!hasLeadingOwnLineComment$1(options.originalText, n.body, options) && (n.body.type === "ArrayExpression" || n.body.type === "ObjectExpression" || n.body.type === "BlockStatement" || isJSXNode$1(n.body) || isTemplateOnItsOwnLine$1(n.body, options.originalText, options) || n.body.type === "ArrowFunctionExpression" || n.body.type === "DoExpression")) {
|
39515 | return group$2(concat$6([concat$6(parts), " ", body]));
|
39516 | }
|
39517 |
|
39518 |
|
39519 |
|
39520 | if (n.body.type === "SequenceExpression") {
|
39521 | return group$2(concat$6([concat$6(parts), group$2(concat$6([" (", indent$3(concat$6([softline$2, body])), softline$2, ")"]))]));
|
39522 | }
|
39523 |
|
39524 |
|
39525 |
|
39526 |
|
39527 |
|
39528 | const shouldAddSoftLine = (args && args.expandLastArg || path.getParentNode().type === "JSXExpressionContainer") && !(n.comments && n.comments.length);
|
39529 | const printTrailingComma = args && args.expandLastArg && shouldPrintComma(options, "all");
|
39530 |
|
39531 |
|
39532 |
|
39533 | const shouldAddParens = n.body.type === "ConditionalExpression" && !startsWithNoLookaheadToken$1(n.body,
|
39534 |
|
39535 | false);
|
39536 | return group$2(concat$6([concat$6(parts), group$2(concat$6([indent$3(concat$6([line$4, shouldAddParens ? ifBreak$1("", "(") : "", body, shouldAddParens ? ifBreak$1("", ")") : ""])), shouldAddSoftLine ? concat$6([ifBreak$1(printTrailingComma ? "," : ""), softline$2]) : ""]))]));
|
39537 | }
|
39538 |
|
39539 | case "YieldExpression":
|
39540 | parts.push("yield");
|
39541 |
|
39542 | if (n.delegate) {
|
39543 | parts.push("*");
|
39544 | }
|
39545 |
|
39546 | if (n.argument) {
|
39547 | parts.push(" ", path.call(print, "argument"));
|
39548 | }
|
39549 |
|
39550 | return concat$6(parts);
|
39551 |
|
39552 | case "AwaitExpression":
|
39553 | {
|
39554 | parts.push("await ", path.call(print, "argument"));
|
39555 | const parent = path.getParentNode();
|
39556 |
|
39557 | if ((parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.callee === n || (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && parent.object === n) {
|
39558 | return group$2(concat$6([indent$3(concat$6([softline$2, concat$6(parts)])), softline$2]));
|
39559 | }
|
39560 |
|
39561 | return concat$6(parts);
|
39562 | }
|
39563 |
|
39564 | case "ImportSpecifier":
|
39565 | if (n.importKind) {
|
39566 | parts.push(path.call(print, "importKind"), " ");
|
39567 | }
|
39568 |
|
39569 | parts.push(path.call(print, "imported"));
|
39570 |
|
39571 | if (n.local && n.local.name !== n.imported.name) {
|
39572 | parts.push(" as ", path.call(print, "local"));
|
39573 | }
|
39574 |
|
39575 | return concat$6(parts);
|
39576 |
|
39577 | case "ExportSpecifier":
|
39578 | parts.push(path.call(print, "local"));
|
39579 |
|
39580 | if (n.exported && n.exported.name !== n.local.name) {
|
39581 | parts.push(" as ", path.call(print, "exported"));
|
39582 | }
|
39583 |
|
39584 | return concat$6(parts);
|
39585 |
|
39586 | case "ImportNamespaceSpecifier":
|
39587 | parts.push("* as ");
|
39588 | parts.push(path.call(print, "local"));
|
39589 | return concat$6(parts);
|
39590 |
|
39591 | case "ImportDefaultSpecifier":
|
39592 | return path.call(print, "local");
|
39593 |
|
39594 | case "TSExportAssignment":
|
39595 | return concat$6(["export = ", path.call(print, "expression"), semi]);
|
39596 |
|
39597 | case "ExportDefaultDeclaration":
|
39598 | case "ExportNamedDeclaration":
|
39599 | return printExportDeclaration(path, options, print);
|
39600 |
|
39601 | case "ExportAllDeclaration":
|
39602 | parts.push("export ");
|
39603 |
|
39604 | if (n.exportKind === "type") {
|
39605 | parts.push("type ");
|
39606 | }
|
39607 |
|
39608 | parts.push("* ");
|
39609 |
|
39610 | if (n.exported) {
|
39611 | parts.push("as ", path.call(print, "exported"), " ");
|
39612 | }
|
39613 |
|
39614 | parts.push("from ", path.call(print, "source"), semi);
|
39615 | return concat$6(parts);
|
39616 |
|
39617 | case "ExportNamespaceSpecifier":
|
39618 | case "ExportDefaultSpecifier":
|
39619 | return path.call(print, "exported");
|
39620 |
|
39621 | case "ImportDeclaration":
|
39622 | {
|
39623 | parts.push("import ");
|
39624 |
|
39625 | if (n.importKind && n.importKind !== "value") {
|
39626 | parts.push(n.importKind + " ");
|
39627 | }
|
39628 |
|
39629 | const standalones = [];
|
39630 | const grouped = [];
|
39631 |
|
39632 | if (n.specifiers && n.specifiers.length > 0) {
|
39633 | path.each(specifierPath => {
|
39634 | const value = specifierPath.getValue();
|
39635 |
|
39636 | if (value.type === "ImportDefaultSpecifier" || value.type === "ImportNamespaceSpecifier") {
|
39637 | standalones.push(print(specifierPath));
|
39638 | } else {
|
39639 | grouped.push(print(specifierPath));
|
39640 | }
|
39641 | }, "specifiers");
|
39642 |
|
39643 | if (standalones.length > 0) {
|
39644 | parts.push(join$4(", ", standalones));
|
39645 | }
|
39646 |
|
39647 | if (standalones.length > 0 && grouped.length > 0) {
|
39648 | parts.push(", ");
|
39649 | }
|
39650 |
|
39651 | if (grouped.length === 1 && standalones.length === 0 && n.specifiers && !n.specifiers.some(node => node.comments)) {
|
39652 | parts.push(concat$6(["{", options.bracketSpacing ? " " : "", concat$6(grouped), options.bracketSpacing ? " " : "", "}"]));
|
39653 | } else if (grouped.length >= 1) {
|
39654 | parts.push(group$2(concat$6(["{", indent$3(concat$6([options.bracketSpacing ? line$4 : softline$2, join$4(concat$6([",", line$4]), grouped)])), ifBreak$1(shouldPrintComma(options) ? "," : ""), options.bracketSpacing ? line$4 : softline$2, "}"])));
|
39655 | }
|
39656 |
|
39657 | parts.push(" from ");
|
39658 | } else if (n.importKind && n.importKind === "type" ||
|
39659 | /{\s*}/.test(options.originalText.slice(options.locStart(n), options.locStart(n.source)))) {
|
39660 | parts.push("{} from ");
|
39661 | }
|
39662 |
|
39663 | parts.push(path.call(print, "source"), semi);
|
39664 | return concat$6(parts);
|
39665 | }
|
39666 |
|
39667 | case "Import":
|
39668 | return "import";
|
39669 |
|
39670 | case "TSModuleBlock":
|
39671 | case "BlockStatement":
|
39672 | {
|
39673 | const naked = path.call(bodyPath => {
|
39674 | return printStatementSequence(bodyPath, options, print);
|
39675 | }, "body");
|
39676 | const hasContent = n.body.find(node => node.type !== "EmptyStatement");
|
39677 | const hasDirectives = n.directives && n.directives.length > 0;
|
39678 | const parent = path.getParentNode();
|
39679 | const parentParent = path.getParentNode(1);
|
39680 |
|
39681 | if (!hasContent && !hasDirectives && !hasDanglingComments$1(n) && (parent.type === "ArrowFunctionExpression" || parent.type === "FunctionExpression" || parent.type === "FunctionDeclaration" || parent.type === "ObjectMethod" || parent.type === "ClassMethod" || parent.type === "ClassPrivateMethod" || parent.type === "ForStatement" || parent.type === "WhileStatement" || parent.type === "DoWhileStatement" || parent.type === "DoExpression" || parent.type === "CatchClause" && !parentParent.finalizer || parent.type === "TSModuleDeclaration")) {
|
39682 | return "{}";
|
39683 | }
|
39684 |
|
39685 | parts.push("{");
|
39686 |
|
39687 | if (hasDirectives) {
|
39688 | path.each(childPath => {
|
39689 | parts.push(indent$3(concat$6([hardline$4, print(childPath), semi])));
|
39690 |
|
39691 | if (isNextLineEmpty$2(options.originalText, childPath.getValue(), options.locEnd)) {
|
39692 | parts.push(hardline$4);
|
39693 | }
|
39694 | }, "directives");
|
39695 | }
|
39696 |
|
39697 | if (hasContent) {
|
39698 | parts.push(indent$3(concat$6([hardline$4, naked])));
|
39699 | }
|
39700 |
|
39701 | parts.push(comments.printDanglingComments(path, options));
|
39702 | parts.push(hardline$4, "}");
|
39703 | return concat$6(parts);
|
39704 | }
|
39705 |
|
39706 | case "ReturnStatement":
|
39707 | return concat$6(["return", printReturnAndThrowArgument(path, options, print)]);
|
39708 |
|
39709 | case "NewExpression":
|
39710 | case "OptionalCallExpression":
|
39711 | case "CallExpression":
|
39712 | {
|
39713 | const isNew = n.type === "NewExpression";
|
39714 | const optional = printOptionalToken(path);
|
39715 |
|
39716 | if (
|
39717 |
|
39718 |
|
39719 | !isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") ||
|
39720 | n.arguments.length === 1 && isTemplateOnItsOwnLine$1(n.arguments[0], options.originalText, options) ||
|
39721 |
|
39722 | !isNew && isTestCall$1(n, path.getParentNode())) {
|
39723 | return concat$6([isNew ? "new " : "", path.call(print, "callee"), optional, printFunctionTypeParameters(path, options, print), concat$6(["(", join$4(", ", path.map(print, "arguments")), ")"])]);
|
39724 | }
|
39725 |
|
39726 |
|
39727 |
|
39728 |
|
39729 |
|
39730 |
|
39731 |
|
39732 | const isIdentifierWithFlowAnnotation = n.callee.type === "Identifier" && hasFlowAnnotationComment$1(n.callee.trailingComments);
|
39733 |
|
39734 | if (isIdentifierWithFlowAnnotation) {
|
39735 | n.callee.trailingComments[0].printed = true;
|
39736 | }
|
39737 |
|
39738 |
|
39739 |
|
39740 | if (!isNew && isMemberish$1(n.callee) && !path.call(path => needsParens_1(path, options), "callee")) {
|
39741 | return printMemberChain(path, options, print);
|
39742 | }
|
39743 |
|
39744 | const contents = concat$6([isNew ? "new " : "", path.call(print, "callee"), optional, isIdentifierWithFlowAnnotation ? `/*:: ${n.callee.trailingComments[0].value.slice(2).trim()} */` : "", printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)]);
|
39745 |
|
39746 |
|
39747 | if (isCallOrOptionalCallExpression$1(n.callee)) {
|
39748 | return group$2(contents);
|
39749 | }
|
39750 |
|
39751 | return contents;
|
39752 | }
|
39753 |
|
39754 | case "TSInterfaceDeclaration":
|
39755 | if (n.declare) {
|
39756 | parts.push("declare ");
|
39757 | }
|
39758 |
|
39759 | parts.push(n.abstract ? "abstract " : "", printTypeScriptModifiers(path, options, print), "interface ", path.call(print, "id"), n.typeParameters ? path.call(print, "typeParameters") : "", " ");
|
39760 |
|
39761 | if (n.extends && n.extends.length) {
|
39762 | parts.push(group$2(indent$3(concat$6([softline$2, "extends ", (n.extends.length === 1 ? identity$2 : indent$3)(join$4(concat$6([",", line$4]), path.map(print, "extends"))), " "]))));
|
39763 | }
|
39764 |
|
39765 | parts.push(path.call(print, "body"));
|
39766 | return concat$6(parts);
|
39767 |
|
39768 | case "ObjectTypeInternalSlot":
|
39769 | return concat$6([n.static ? "static " : "", "[[", path.call(print, "id"), "]]", printOptionalToken(path), n.method ? "" : ": ", path.call(print, "value")]);
|
39770 |
|
39771 | case "ObjectExpression":
|
39772 | case "ObjectPattern":
|
39773 | case "ObjectTypeAnnotation":
|
39774 | case "TSInterfaceBody":
|
39775 | case "TSTypeLiteral":
|
39776 | {
|
39777 | let propertiesField;
|
39778 |
|
39779 | if (n.type === "TSTypeLiteral") {
|
39780 | propertiesField = "members";
|
39781 | } else if (n.type === "TSInterfaceBody") {
|
39782 | propertiesField = "body";
|
39783 | } else {
|
39784 | propertiesField = "properties";
|
39785 | }
|
39786 |
|
39787 | const isTypeAnnotation = n.type === "ObjectTypeAnnotation";
|
39788 | const fields = [];
|
39789 |
|
39790 | if (isTypeAnnotation) {
|
39791 | fields.push("indexers", "callProperties", "internalSlots");
|
39792 | }
|
39793 |
|
39794 | fields.push(propertiesField);
|
39795 | const firstProperty = fields.map(field => n[field][0]).sort((a, b) => options.locStart(a) - options.locStart(b))[0];
|
39796 | const parent = path.getParentNode(0);
|
39797 | const isFlowInterfaceLikeBody = isTypeAnnotation && parent && (parent.type === "InterfaceDeclaration" || parent.type === "DeclareInterface" || parent.type === "DeclareClass") && path.getName() === "body";
|
39798 | const shouldBreak = n.type === "TSInterfaceBody" || isFlowInterfaceLikeBody || n.type === "ObjectPattern" && parent.type !== "FunctionDeclaration" && parent.type !== "FunctionExpression" && parent.type !== "ArrowFunctionExpression" && parent.type !== "ObjectMethod" && parent.type !== "ClassMethod" && parent.type !== "ClassPrivateMethod" && parent.type !== "AssignmentPattern" && parent.type !== "CatchClause" && n.properties.some(property => property.value && (property.value.type === "ObjectPattern" || property.value.type === "ArrayPattern")) || n.type !== "ObjectPattern" && firstProperty && hasNewlineInRange$3(options.originalText, options.locStart(n), options.locStart(firstProperty));
|
39799 | const separator = isFlowInterfaceLikeBody ? ";" : n.type === "TSInterfaceBody" || n.type === "TSTypeLiteral" ? ifBreak$1(semi, ";") : ",";
|
39800 | const leftBrace = n.exact ? "{|" : "{";
|
39801 | const rightBrace = n.exact ? "|}" : "}";
|
39802 |
|
39803 |
|
39804 |
|
39805 | const propsAndLoc = [];
|
39806 | fields.forEach(field => {
|
39807 | path.each(childPath => {
|
39808 | const node = childPath.getValue();
|
39809 | propsAndLoc.push({
|
39810 | node,
|
39811 | printed: print(childPath),
|
39812 | loc: options.locStart(node)
|
39813 | });
|
39814 | }, field);
|
39815 | });
|
39816 | let separatorParts = [];
|
39817 | const props = propsAndLoc.sort((a, b) => a.loc - b.loc).map(prop => {
|
39818 | const result = concat$6(separatorParts.concat(group$2(prop.printed)));
|
39819 | separatorParts = [separator, line$4];
|
39820 |
|
39821 | if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature" || prop.node.type === "TSConstructSignatureDeclaration") && hasNodeIgnoreComment$2(prop.node)) {
|
39822 | separatorParts.shift();
|
39823 | }
|
39824 |
|
39825 | if (isNextLineEmpty$2(options.originalText, prop.node, options.locEnd)) {
|
39826 | separatorParts.push(hardline$4);
|
39827 | }
|
39828 |
|
39829 | return result;
|
39830 | });
|
39831 |
|
39832 | if (n.inexact) {
|
39833 | let printed;
|
39834 |
|
39835 | if (hasDanglingComments$1(n)) {
|
39836 | const hasLineComments = !n.comments.every(comments$1.isBlockComment);
|
39837 | const printedDanglingComments = comments.printDanglingComments(path, options,
|
39838 |
|
39839 | true);
|
39840 | printed = concat$6([printedDanglingComments, hasLineComments || hasNewline$4(options.originalText, options.locEnd(n.comments[n.comments.length - 1])) ? hardline$4 : line$4, "..."]);
|
39841 | } else {
|
39842 | printed = "...";
|
39843 | }
|
39844 |
|
39845 | props.push(concat$6(separatorParts.concat(printed)));
|
39846 | }
|
39847 |
|
39848 | const lastElem = getLast$2(n[propertiesField]);
|
39849 | const canHaveTrailingSeparator = !(n.inexact || lastElem && (lastElem.type === "RestElement" || hasNodeIgnoreComment$2(lastElem)));
|
39850 | let content;
|
39851 |
|
39852 | if (props.length === 0) {
|
39853 | if (!hasDanglingComments$1(n)) {
|
39854 | return concat$6([leftBrace, rightBrace, printTypeAnnotation(path, options, print)]);
|
39855 | }
|
39856 |
|
39857 | content = group$2(concat$6([leftBrace, comments.printDanglingComments(path, options), softline$2, rightBrace, printOptionalToken(path), printTypeAnnotation(path, options, print)]));
|
39858 | } else {
|
39859 | content = concat$6([leftBrace, indent$3(concat$6([options.bracketSpacing ? line$4 : softline$2, concat$6(props)])), ifBreak$1(canHaveTrailingSeparator && (separator !== "," || shouldPrintComma(options)) ? separator : ""), concat$6([options.bracketSpacing ? line$4 : softline$2, rightBrace]), printOptionalToken(path), printTypeAnnotation(path, options, print)]);
|
39860 | }
|
39861 |
|
39862 |
|
39863 |
|
39864 |
|
39865 | if (path.match(node => node.type === "ObjectPattern" && !node.decorators, (node, name, number) => shouldHugArguments(node) && (name === "params" || name === "parameters") && number === 0) || path.match(shouldHugType, (node, name) => name === "typeAnnotation", (node, name) => name === "typeAnnotation", (node, name, number) => shouldHugArguments(node) && (name === "params" || name === "parameters") && number === 0)) {
|
39866 | return content;
|
39867 | }
|
39868 |
|
39869 | return group$2(content, {
|
39870 | shouldBreak
|
39871 | });
|
39872 | }
|
39873 |
|
39874 |
|
39875 | case "ObjectProperty":
|
39876 |
|
39877 | case "Property":
|
39878 | if (n.method || n.kind === "get" || n.kind === "set") {
|
39879 | return printMethod(path, options, print);
|
39880 | }
|
39881 |
|
39882 | if (n.shorthand) {
|
39883 | parts.push(path.call(print, "value"));
|
39884 | } else {
|
39885 | parts.push(printAssignment(n.key, printPropertyKey(path, options, print), ":", n.value, path.call(print, "value"), options));
|
39886 | }
|
39887 |
|
39888 | return concat$6(parts);
|
39889 |
|
39890 |
|
39891 | case "ClassMethod":
|
39892 | case "ClassPrivateMethod":
|
39893 | case "MethodDefinition":
|
39894 | case "TSAbstractMethodDefinition":
|
39895 | case "TSDeclareMethod":
|
39896 | if (n.decorators && n.decorators.length !== 0) {
|
39897 | parts.push(printDecorators(path, options, print));
|
39898 | }
|
39899 |
|
39900 | if (n.accessibility) {
|
39901 | parts.push(n.accessibility + " ");
|
39902 | }
|
39903 |
|
39904 | if (n.static) {
|
39905 | parts.push("static ");
|
39906 | }
|
39907 |
|
39908 | if (n.type === "TSAbstractMethodDefinition" || n.abstract) {
|
39909 | parts.push("abstract ");
|
39910 | }
|
39911 |
|
39912 | parts.push(printMethod(path, options, print));
|
39913 | return concat$6(parts);
|
39914 |
|
39915 | case "ObjectMethod":
|
39916 | return printMethod(path, options, print);
|
39917 |
|
39918 | case "Decorator":
|
39919 | return concat$6(["@", path.call(print, "expression"), path.call(print, "callee")]);
|
39920 |
|
39921 | case "ArrayExpression":
|
39922 | case "ArrayPattern":
|
39923 | if (n.elements.length === 0) {
|
39924 | if (!hasDanglingComments$1(n)) {
|
39925 | parts.push("[]");
|
39926 | } else {
|
39927 | parts.push(group$2(concat$6(["[", comments.printDanglingComments(path, options), softline$2, "]"])));
|
39928 | }
|
39929 | } else {
|
39930 | const lastElem = getLast$2(n.elements);
|
39931 | const canHaveTrailingComma = !(lastElem && lastElem.type === "RestElement");
|
39932 |
|
39933 |
|
39934 |
|
39935 |
|
39936 |
|
39937 |
|
39938 |
|
39939 |
|
39940 |
|
39941 |
|
39942 | const needsForcedTrailingComma = canHaveTrailingComma && lastElem === null;
|
39943 | const shouldBreak = n.elements.length > 1 && n.elements.every((element, i, elements) => {
|
39944 | const elementType = element && element.type;
|
39945 |
|
39946 | if (elementType !== "ArrayExpression" && elementType !== "ObjectExpression") {
|
39947 | return false;
|
39948 | }
|
39949 |
|
39950 | const nextElement = elements[i + 1];
|
39951 |
|
39952 | if (nextElement && elementType !== nextElement.type) {
|
39953 | return false;
|
39954 | }
|
39955 |
|
39956 | const itemsKey = elementType === "ArrayExpression" ? "elements" : "properties";
|
39957 | return element[itemsKey] && element[itemsKey].length > 1;
|
39958 | });
|
39959 | parts.push(group$2(concat$6(["[", indent$3(concat$6([softline$2, printArrayItems(path, options, "elements", print)])), needsForcedTrailingComma ? "," : "", ifBreak$1(canHaveTrailingComma && !needsForcedTrailingComma && shouldPrintComma(options) ? "," : ""), comments.printDanglingComments(path, options,
|
39960 |
|
39961 | true), softline$2, "]"]), {
|
39962 | shouldBreak
|
39963 | }));
|
39964 | }
|
39965 |
|
39966 | parts.push(printOptionalToken(path), printTypeAnnotation(path, options, print));
|
39967 | return concat$6(parts);
|
39968 |
|
39969 | case "SequenceExpression":
|
39970 | {
|
39971 | const parent = path.getParentNode(0);
|
39972 |
|
39973 | if (parent.type === "ExpressionStatement" || parent.type === "ForStatement") {
|
39974 |
|
39975 |
|
39976 |
|
39977 | const parts = [];
|
39978 | path.each(p => {
|
39979 | if (p.getName() === 0) {
|
39980 | parts.push(print(p));
|
39981 | } else {
|
39982 | parts.push(",", indent$3(concat$6([line$4, print(p)])));
|
39983 | }
|
39984 | }, "expressions");
|
39985 | return group$2(concat$6(parts));
|
39986 | }
|
39987 |
|
39988 | return group$2(concat$6([join$4(concat$6([",", line$4]), path.map(print, "expressions"))]));
|
39989 | }
|
39990 |
|
39991 | case "ThisExpression":
|
39992 | return "this";
|
39993 |
|
39994 | case "Super":
|
39995 | return "super";
|
39996 |
|
39997 | case "NullLiteral":
|
39998 |
|
39999 | return "null";
|
40000 |
|
40001 | case "RegExpLiteral":
|
40002 |
|
40003 | return printRegex(n);
|
40004 |
|
40005 | case "NumericLiteral":
|
40006 |
|
40007 | return printNumber$1(n.extra.raw);
|
40008 |
|
40009 | case "BigIntLiteral":
|
40010 |
|
40011 | return (n.bigint || (n.extra ? n.extra.raw : n.raw)).toLowerCase();
|
40012 |
|
40013 | case "BooleanLiteral":
|
40014 |
|
40015 | case "StringLiteral":
|
40016 |
|
40017 | case "Literal":
|
40018 | {
|
40019 | if (n.regex) {
|
40020 | return printRegex(n.regex);
|
40021 | }
|
40022 |
|
40023 | if (typeof n.value === "number") {
|
40024 | return printNumber$1(n.raw);
|
40025 | }
|
40026 |
|
40027 | if (typeof n.value !== "string") {
|
40028 | return "" + n.value;
|
40029 | }
|
40030 |
|
40031 |
|
40032 |
|
40033 | const grandParent = path.getParentNode(1);
|
40034 | const isTypeScriptDirective = options.parser === "typescript" && typeof n.value === "string" && grandParent && (grandParent.type === "Program" || grandParent.type === "BlockStatement");
|
40035 | return nodeStr(n, options, isTypeScriptDirective);
|
40036 | }
|
40037 |
|
40038 | case "Directive":
|
40039 | return path.call(print, "value");
|
40040 |
|
40041 |
|
40042 | case "DirectiveLiteral":
|
40043 | return nodeStr(n, options);
|
40044 |
|
40045 | case "UnaryExpression":
|
40046 | parts.push(n.operator);
|
40047 |
|
40048 | if (/[a-z]$/.test(n.operator)) {
|
40049 | parts.push(" ");
|
40050 | }
|
40051 |
|
40052 | if (n.argument.comments && n.argument.comments.length > 0) {
|
40053 | parts.push(group$2(concat$6(["(", indent$3(concat$6([softline$2, path.call(print, "argument")])), softline$2, ")"])));
|
40054 | } else {
|
40055 | parts.push(path.call(print, "argument"));
|
40056 | }
|
40057 |
|
40058 | return concat$6(parts);
|
40059 |
|
40060 | case "UpdateExpression":
|
40061 | parts.push(path.call(print, "argument"), n.operator);
|
40062 |
|
40063 | if (n.prefix) {
|
40064 | parts.reverse();
|
40065 | }
|
40066 |
|
40067 | return concat$6(parts);
|
40068 |
|
40069 | case "ConditionalExpression":
|
40070 | return printTernaryOperator(path, options, print, {
|
40071 | beforeParts: () => [path.call(print, "test")],
|
40072 | afterParts: breakClosingParen => [breakClosingParen ? softline$2 : ""],
|
40073 | shouldCheckJsx: true,
|
40074 | conditionalNodeType: "ConditionalExpression",
|
40075 | consequentNodePropertyName: "consequent",
|
40076 | alternateNodePropertyName: "alternate",
|
40077 | testNodePropertyNames: ["test"]
|
40078 | });
|
40079 |
|
40080 | case "VariableDeclaration":
|
40081 | {
|
40082 | const printed = path.map(childPath => {
|
40083 | return print(childPath);
|
40084 | }, "declarations");
|
40085 |
|
40086 |
|
40087 | const parentNode = path.getParentNode();
|
40088 | const isParentForLoop = parentNode.type === "ForStatement" || parentNode.type === "ForInStatement" || parentNode.type === "ForOfStatement";
|
40089 | const hasValue = n.declarations.some(decl => decl.init);
|
40090 | let firstVariable;
|
40091 |
|
40092 | if (printed.length === 1 && !n.declarations[0].comments) {
|
40093 | firstVariable = printed[0];
|
40094 | } else if (printed.length > 0) {
|
40095 |
|
40096 | firstVariable = indent$3(printed[0]);
|
40097 | }
|
40098 |
|
40099 | parts = [n.declare ? "declare " : "", n.kind, firstVariable ? concat$6([" ", firstVariable]) : "", indent$3(concat$6(printed.slice(1).map(p => concat$6([",", hasValue && !isParentForLoop ? hardline$4 : line$4, p]))))];
|
40100 |
|
40101 | if (!(isParentForLoop && parentNode.body !== n)) {
|
40102 | parts.push(semi);
|
40103 | }
|
40104 |
|
40105 | return group$2(concat$6(parts));
|
40106 | }
|
40107 |
|
40108 | case "TSTypeAliasDeclaration":
|
40109 | {
|
40110 | if (n.declare) {
|
40111 | parts.push("declare ");
|
40112 | }
|
40113 |
|
40114 | const printed = printAssignmentRight(n.id, n.typeAnnotation, n.typeAnnotation && path.call(print, "typeAnnotation"), options);
|
40115 | parts.push("type ", path.call(print, "id"), path.call(print, "typeParameters"), " =", printed, semi);
|
40116 | return group$2(concat$6(parts));
|
40117 | }
|
40118 |
|
40119 | case "VariableDeclarator":
|
40120 | return printAssignment(n.id, path.call(print, "id"), " =", n.init, n.init && path.call(print, "init"), options);
|
40121 |
|
40122 | case "WithStatement":
|
40123 | return group$2(concat$6(["with (", path.call(print, "object"), ")", adjustClause(n.body, path.call(print, "body"))]));
|
40124 |
|
40125 | case "IfStatement":
|
40126 | {
|
40127 | const con = adjustClause(n.consequent, path.call(print, "consequent"));
|
40128 | const opening = group$2(concat$6(["if (", group$2(concat$6([indent$3(concat$6([softline$2, path.call(print, "test")])), softline$2])), ")", con]));
|
40129 | parts.push(opening);
|
40130 |
|
40131 | if (n.alternate) {
|
40132 | const commentOnOwnLine = hasTrailingComment$1(n.consequent) && n.consequent.comments.some(comment => comment.trailing && !comments$1.isBlockComment(comment)) || needsHardlineAfterDanglingComment$1(n);
|
40133 | const elseOnSameLine = n.consequent.type === "BlockStatement" && !commentOnOwnLine;
|
40134 | parts.push(elseOnSameLine ? " " : hardline$4);
|
40135 |
|
40136 | if (hasDanglingComments$1(n)) {
|
40137 | parts.push(comments.printDanglingComments(path, options, true), commentOnOwnLine ? hardline$4 : " ");
|
40138 | }
|
40139 |
|
40140 | parts.push("else", group$2(adjustClause(n.alternate, path.call(print, "alternate"), n.alternate.type === "IfStatement")));
|
40141 | }
|
40142 |
|
40143 | return concat$6(parts);
|
40144 | }
|
40145 |
|
40146 | case "ForStatement":
|
40147 | {
|
40148 | const body = adjustClause(n.body, path.call(print, "body"));
|
40149 |
|
40150 |
|
40151 |
|
40152 | const dangling = comments.printDanglingComments(path, options,
|
40153 |
|
40154 | true);
|
40155 | const printedComments = dangling ? concat$6([dangling, softline$2]) : "";
|
40156 |
|
40157 | if (!n.init && !n.test && !n.update) {
|
40158 | return concat$6([printedComments, group$2(concat$6(["for (;;)", body]))]);
|
40159 | }
|
40160 |
|
40161 | return concat$6([printedComments, group$2(concat$6(["for (", group$2(concat$6([indent$3(concat$6([softline$2, path.call(print, "init"), ";", line$4, path.call(print, "test"), ";", line$4, path.call(print, "update")])), softline$2])), ")", body]))]);
|
40162 | }
|
40163 |
|
40164 | case "WhileStatement":
|
40165 | return group$2(concat$6(["while (", group$2(concat$6([indent$3(concat$6([softline$2, path.call(print, "test")])), softline$2])), ")", adjustClause(n.body, path.call(print, "body"))]));
|
40166 |
|
40167 | case "ForInStatement":
|
40168 |
|
40169 | return group$2(concat$6([n.each ? "for each (" : "for (", path.call(print, "left"), " in ", path.call(print, "right"), ")", adjustClause(n.body, path.call(print, "body"))]));
|
40170 |
|
40171 | case "ForOfStatement":
|
40172 | return group$2(concat$6(["for", n.await ? " await" : "", " (", path.call(print, "left"), " of ", path.call(print, "right"), ")", adjustClause(n.body, path.call(print, "body"))]));
|
40173 |
|
40174 | case "DoWhileStatement":
|
40175 | {
|
40176 | const clause = adjustClause(n.body, path.call(print, "body"));
|
40177 | const doBody = group$2(concat$6(["do", clause]));
|
40178 | parts = [doBody];
|
40179 |
|
40180 | if (n.body.type === "BlockStatement") {
|
40181 | parts.push(" ");
|
40182 | } else {
|
40183 | parts.push(hardline$4);
|
40184 | }
|
40185 |
|
40186 | parts.push("while (");
|
40187 | parts.push(group$2(concat$6([indent$3(concat$6([softline$2, path.call(print, "test")])), softline$2])), ")", semi);
|
40188 | return concat$6(parts);
|
40189 | }
|
40190 |
|
40191 | case "DoExpression":
|
40192 | return concat$6(["do ", path.call(print, "body")]);
|
40193 |
|
40194 | case "BreakStatement":
|
40195 | parts.push("break");
|
40196 |
|
40197 | if (n.label) {
|
40198 | parts.push(" ", path.call(print, "label"));
|
40199 | }
|
40200 |
|
40201 | parts.push(semi);
|
40202 | return concat$6(parts);
|
40203 |
|
40204 | case "ContinueStatement":
|
40205 | parts.push("continue");
|
40206 |
|
40207 | if (n.label) {
|
40208 | parts.push(" ", path.call(print, "label"));
|
40209 | }
|
40210 |
|
40211 | parts.push(semi);
|
40212 | return concat$6(parts);
|
40213 |
|
40214 | case "LabeledStatement":
|
40215 | if (n.body.type === "EmptyStatement") {
|
40216 | return concat$6([path.call(print, "label"), ":;"]);
|
40217 | }
|
40218 |
|
40219 | return concat$6([path.call(print, "label"), ": ", path.call(print, "body")]);
|
40220 |
|
40221 | case "TryStatement":
|
40222 | return concat$6(["try ", path.call(print, "block"), n.handler ? concat$6([" ", path.call(print, "handler")]) : "", n.finalizer ? concat$6([" finally ", path.call(print, "finalizer")]) : ""]);
|
40223 |
|
40224 | case "CatchClause":
|
40225 | if (n.param) {
|
40226 | const hasComments = n.param.comments && n.param.comments.some(comment => !comments$1.isBlockComment(comment) || comment.leading && hasNewline$4(options.originalText, options.locEnd(comment)) || comment.trailing && hasNewline$4(options.originalText, options.locStart(comment), {
|
40227 | backwards: true
|
40228 | }));
|
40229 | const param = path.call(print, "param");
|
40230 | return concat$6(["catch ", hasComments ? concat$6(["(", indent$3(concat$6([softline$2, param])), softline$2, ") "]) : concat$6(["(", param, ") "]), path.call(print, "body")]);
|
40231 | }
|
40232 |
|
40233 | return concat$6(["catch ", path.call(print, "body")]);
|
40234 |
|
40235 | case "ThrowStatement":
|
40236 | return concat$6(["throw", printReturnAndThrowArgument(path, options, print)]);
|
40237 |
|
40238 |
|
40239 | case "SwitchStatement":
|
40240 | return concat$6([group$2(concat$6(["switch (", indent$3(concat$6([softline$2, path.call(print, "discriminant")])), softline$2, ")"])), " {", n.cases.length > 0 ? indent$3(concat$6([hardline$4, join$4(hardline$4, path.map(casePath => {
|
40241 | const caseNode = casePath.getValue();
|
40242 | return concat$6([casePath.call(print), n.cases.indexOf(caseNode) !== n.cases.length - 1 && isNextLineEmpty$2(options.originalText, caseNode, options.locEnd) ? hardline$4 : ""]);
|
40243 | }, "cases"))])) : "", hardline$4, "}"]);
|
40244 |
|
40245 | case "SwitchCase":
|
40246 | {
|
40247 | if (n.test) {
|
40248 | parts.push("case ", path.call(print, "test"), ":");
|
40249 | } else {
|
40250 | parts.push("default:");
|
40251 | }
|
40252 |
|
40253 | const consequent = n.consequent.filter(node => node.type !== "EmptyStatement");
|
40254 |
|
40255 | if (consequent.length > 0) {
|
40256 | const cons = path.call(consequentPath => {
|
40257 | return printStatementSequence(consequentPath, options, print);
|
40258 | }, "consequent");
|
40259 | parts.push(consequent.length === 1 && consequent[0].type === "BlockStatement" ? concat$6([" ", cons]) : indent$3(concat$6([hardline$4, cons])));
|
40260 | }
|
40261 |
|
40262 | return concat$6(parts);
|
40263 | }
|
40264 |
|
40265 |
|
40266 | case "DebuggerStatement":
|
40267 | return concat$6(["debugger", semi]);
|
40268 |
|
40269 | case "JSXAttribute":
|
40270 | parts.push(path.call(print, "name"));
|
40271 |
|
40272 | if (n.value) {
|
40273 | let res;
|
40274 |
|
40275 | if (isStringLiteral$1(n.value)) {
|
40276 | const raw = rawText$1(n.value);
|
40277 |
|
40278 | let final = raw.replace(/'/g, "'").replace(/"/g, '"');
|
40279 | const quote = getPreferredQuote$1(final, options.jsxSingleQuote ? "'" : '"');
|
40280 | const escape = quote === "'" ? "'" : """;
|
40281 | final = final.slice(1, -1).replace(new RegExp(quote, "g"), escape);
|
40282 | res = concat$6([quote, final, quote]);
|
40283 | } else {
|
40284 | res = path.call(print, "value");
|
40285 | }
|
40286 |
|
40287 | parts.push("=", res);
|
40288 | }
|
40289 |
|
40290 | return concat$6(parts);
|
40291 |
|
40292 | case "JSXIdentifier":
|
40293 | return "" + n.name;
|
40294 |
|
40295 | case "JSXNamespacedName":
|
40296 | return join$4(":", [path.call(print, "namespace"), path.call(print, "name")]);
|
40297 |
|
40298 | case "JSXMemberExpression":
|
40299 | return join$4(".", [path.call(print, "object"), path.call(print, "property")]);
|
40300 |
|
40301 | case "TSQualifiedName":
|
40302 | return join$4(".", [path.call(print, "left"), path.call(print, "right")]);
|
40303 |
|
40304 | case "JSXSpreadAttribute":
|
40305 | case "JSXSpreadChild":
|
40306 | {
|
40307 | return concat$6(["{", path.call(p => {
|
40308 | const printed = concat$6(["...", print(p)]);
|
40309 | const n = p.getValue();
|
40310 |
|
40311 | if (!n.comments || !n.comments.length) {
|
40312 | return printed;
|
40313 | }
|
40314 |
|
40315 | return concat$6([indent$3(concat$6([softline$2, comments.printComments(p, () => printed, options)])), softline$2]);
|
40316 | }, n.type === "JSXSpreadAttribute" ? "argument" : "expression"), "}"]);
|
40317 | }
|
40318 |
|
40319 | case "JSXExpressionContainer":
|
40320 | {
|
40321 | const parent = path.getParentNode(0);
|
40322 | const hasComments = n.expression.comments && n.expression.comments.length > 0;
|
40323 | const shouldInline = n.expression.type === "JSXEmptyExpression" || !hasComments && (n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression" || n.expression.type === "ArrowFunctionExpression" || n.expression.type === "CallExpression" || n.expression.type === "OptionalCallExpression" || n.expression.type === "FunctionExpression" || n.expression.type === "TemplateLiteral" || n.expression.type === "TaggedTemplateExpression" || n.expression.type === "DoExpression" || isJSXNode$1(parent) && (n.expression.type === "ConditionalExpression" || isBinaryish$1(n.expression)));
|
40324 |
|
40325 | if (shouldInline) {
|
40326 | return group$2(concat$6(["{", path.call(print, "expression"), lineSuffixBoundary$1, "}"]));
|
40327 | }
|
40328 |
|
40329 | return group$2(concat$6(["{", indent$3(concat$6([softline$2, path.call(print, "expression")])), softline$2, lineSuffixBoundary$1, "}"]));
|
40330 | }
|
40331 |
|
40332 | case "JSXFragment":
|
40333 | case "JSXElement":
|
40334 | {
|
40335 | const elem = comments.printComments(path, () => printJSXElement(path, options, print), options);
|
40336 | return maybeWrapJSXElementInParens(path, elem, options);
|
40337 | }
|
40338 |
|
40339 | case "JSXOpeningElement":
|
40340 | {
|
40341 | const n = path.getValue();
|
40342 | const nameHasComments = n.name && n.name.comments && n.name.comments.length > 0 || n.typeParameters && n.typeParameters.comments && n.typeParameters.comments.length > 0;
|
40343 |
|
40344 | if (n.selfClosing && !n.attributes.length && !nameHasComments) {
|
40345 | return concat$6(["<", path.call(print, "name"), path.call(print, "typeParameters"), " />"]);
|
40346 | }
|
40347 |
|
40348 |
|
40349 | if (n.attributes && n.attributes.length === 1 && n.attributes[0].value && isStringLiteral$1(n.attributes[0].value) && !n.attributes[0].value.value.includes("\n") &&
|
40350 |
|
40351 |
|
40352 |
|
40353 |
|
40354 |
|
40355 |
|
40356 |
|
40357 |
|
40358 | !nameHasComments && (!n.attributes[0].comments || !n.attributes[0].comments.length)) {
|
40359 | return group$2(concat$6(["<", path.call(print, "name"), path.call(print, "typeParameters"), " ", concat$6(path.map(print, "attributes")), n.selfClosing ? " />" : ">"]));
|
40360 | }
|
40361 |
|
40362 | const lastAttrHasTrailingComments = n.attributes.length && hasTrailingComment$1(getLast$2(n.attributes));
|
40363 | const bracketSameLine =
|
40364 |
|
40365 | !n.attributes.length && !nameHasComments || options.jsxBracketSameLine && (
|
40366 |
|
40367 |
|
40368 |
|
40369 |
|
40370 |
|
40371 |
|
40372 | !nameHasComments || n.attributes.length) && !lastAttrHasTrailingComments;
|
40373 |
|
40374 |
|
40375 | const shouldBreak = n.attributes && n.attributes.some(attr => attr.value && isStringLiteral$1(attr.value) && attr.value.value.includes("\n"));
|
40376 | return group$2(concat$6(["<", path.call(print, "name"), path.call(print, "typeParameters"), concat$6([indent$3(concat$6(path.map(attr => concat$6([line$4, print(attr)]), "attributes"))), n.selfClosing ? line$4 : bracketSameLine ? ">" : softline$2]), n.selfClosing ? "/>" : bracketSameLine ? "" : ">"]), {
|
40377 | shouldBreak
|
40378 | });
|
40379 | }
|
40380 |
|
40381 | case "JSXClosingElement":
|
40382 | return concat$6(["</", path.call(print, "name"), ">"]);
|
40383 |
|
40384 | case "JSXOpeningFragment":
|
40385 | case "JSXClosingFragment":
|
40386 | {
|
40387 | const hasComment = n.comments && n.comments.length;
|
40388 | const hasOwnLineComment = hasComment && !n.comments.every(comments$1.isBlockComment);
|
40389 | const isOpeningFragment = n.type === "JSXOpeningFragment";
|
40390 | return concat$6([isOpeningFragment ? "<" : "</", indent$3(concat$6([hasOwnLineComment ? hardline$4 : hasComment && !isOpeningFragment ? " " : "", comments.printDanglingComments(path, options, true)])), hasOwnLineComment ? hardline$4 : "", ">"]);
|
40391 | }
|
40392 |
|
40393 | case "JSXText":
|
40394 |
|
40395 | throw new Error("JSXTest should be handled by JSXElement");
|
40396 |
|
40397 | case "JSXEmptyExpression":
|
40398 | {
|
40399 | const requiresHardline = n.comments && !n.comments.every(comments$1.isBlockComment);
|
40400 | return concat$6([comments.printDanglingComments(path, options,
|
40401 |
|
40402 | !requiresHardline), requiresHardline ? hardline$4 : ""]);
|
40403 | }
|
40404 |
|
40405 | case "ClassBody":
|
40406 | if (!n.comments && n.body.length === 0) {
|
40407 | return "{}";
|
40408 | }
|
40409 |
|
40410 | return concat$6(["{", n.body.length > 0 ? indent$3(concat$6([hardline$4, path.call(bodyPath => {
|
40411 | return printStatementSequence(bodyPath, options, print);
|
40412 | }, "body")])) : comments.printDanglingComments(path, options), hardline$4, "}"]);
|
40413 |
|
40414 | case "ClassProperty":
|
40415 | case "TSAbstractClassProperty":
|
40416 | case "ClassPrivateProperty":
|
40417 | {
|
40418 | if (n.decorators && n.decorators.length !== 0) {
|
40419 | parts.push(printDecorators(path, options, print));
|
40420 | }
|
40421 |
|
40422 | if (n.accessibility) {
|
40423 | parts.push(n.accessibility + " ");
|
40424 | }
|
40425 |
|
40426 | if (n.declare) {
|
40427 | parts.push("declare ");
|
40428 | }
|
40429 |
|
40430 | if (n.static) {
|
40431 | parts.push("static ");
|
40432 | }
|
40433 |
|
40434 | if (n.type === "TSAbstractClassProperty" || n.abstract) {
|
40435 | parts.push("abstract ");
|
40436 | }
|
40437 |
|
40438 | if (n.readonly) {
|
40439 | parts.push("readonly ");
|
40440 | }
|
40441 |
|
40442 | const variance = getFlowVariance$1(n);
|
40443 |
|
40444 | if (variance) {
|
40445 | parts.push(variance);
|
40446 | }
|
40447 |
|
40448 | parts.push(printPropertyKey(path, options, print), printOptionalToken(path), printTypeAnnotation(path, options, print));
|
40449 |
|
40450 | if (n.value) {
|
40451 | parts.push(" =", printAssignmentRight(n.key, n.value, path.call(print, "value"), options));
|
40452 | }
|
40453 |
|
40454 | parts.push(semi);
|
40455 | return group$2(concat$6(parts));
|
40456 | }
|
40457 |
|
40458 | case "ClassDeclaration":
|
40459 | case "ClassExpression":
|
40460 | if (n.declare) {
|
40461 | parts.push("declare ");
|
40462 | }
|
40463 |
|
40464 | parts.push(concat$6(printClass(path, options, print)));
|
40465 | return concat$6(parts);
|
40466 |
|
40467 | case "TSInterfaceHeritage":
|
40468 | case "TSExpressionWithTypeArguments":
|
40469 |
|
40470 | parts.push(path.call(print, "expression"));
|
40471 |
|
40472 | if (n.typeParameters) {
|
40473 | parts.push(path.call(print, "typeParameters"));
|
40474 | }
|
40475 |
|
40476 | return concat$6(parts);
|
40477 |
|
40478 | case "TemplateElement":
|
40479 | return join$4(literalline$2, n.value.raw.split(/\r?\n/g));
|
40480 |
|
40481 | case "TemplateLiteral":
|
40482 | {
|
40483 | let expressions = path.map(print, "expressions");
|
40484 | const parentNode = path.getParentNode();
|
40485 |
|
40486 | if (isJestEachTemplateLiteral$1(n, parentNode)) {
|
40487 | const printed = printJestEachTemplateLiteral(n, expressions, options);
|
40488 |
|
40489 | if (printed) {
|
40490 | return printed;
|
40491 | }
|
40492 | }
|
40493 |
|
40494 | const isSimple = isSimpleTemplateLiteral$1(n);
|
40495 |
|
40496 | if (isSimple) {
|
40497 | expressions = expressions.map(doc => printDocToString$2(doc, Object.assign({}, options, {
|
40498 | printWidth: Infinity
|
40499 | })).formatted);
|
40500 | }
|
40501 |
|
40502 | parts.push(lineSuffixBoundary$1, "`");
|
40503 | path.each(childPath => {
|
40504 | const i = childPath.getName();
|
40505 | parts.push(print(childPath));
|
40506 |
|
40507 | if (i < expressions.length) {
|
40508 |
|
40509 |
|
40510 |
|
40511 |
|
40512 |
|
40513 |
|
40514 |
|
40515 |
|
40516 |
|
40517 |
|
40518 |
|
40519 | const {
|
40520 | tabWidth
|
40521 | } = options;
|
40522 | const quasi = childPath.getValue();
|
40523 | const indentSize = getIndentSize$2(quasi.value.raw, tabWidth);
|
40524 | let printed = expressions[i];
|
40525 |
|
40526 | if (!isSimple) {
|
40527 |
|
40528 |
|
40529 | if (n.expressions[i].comments && n.expressions[i].comments.length || n.expressions[i].type === "MemberExpression" || n.expressions[i].type === "OptionalMemberExpression" || n.expressions[i].type === "ConditionalExpression" || n.expressions[i].type === "SequenceExpression" || n.expressions[i].type === "TSAsExpression" || isBinaryish$1(n.expressions[i])) {
|
40530 | printed = concat$6([indent$3(concat$6([softline$2, printed])), softline$2]);
|
40531 | }
|
40532 | }
|
40533 |
|
40534 | const aligned = indentSize === 0 && quasi.value.raw.endsWith("\n") ? align$1(-Infinity, printed) : addAlignmentToDoc$2(printed, indentSize, tabWidth);
|
40535 | parts.push(group$2(concat$6(["${", aligned, lineSuffixBoundary$1, "}"])));
|
40536 | }
|
40537 | }, "quasis");
|
40538 | parts.push("`");
|
40539 | return concat$6(parts);
|
40540 | }
|
40541 |
|
40542 |
|
40543 |
|
40544 | case "TaggedTemplateExpression":
|
40545 | return concat$6([path.call(print, "tag"), path.call(print, "typeParameters"), path.call(print, "quasi")]);
|
40546 |
|
40547 | case "Node":
|
40548 | case "Printable":
|
40549 | case "SourceLocation":
|
40550 | case "Position":
|
40551 | case "Statement":
|
40552 | case "Function":
|
40553 | case "Pattern":
|
40554 | case "Expression":
|
40555 | case "Declaration":
|
40556 | case "Specifier":
|
40557 | case "NamedSpecifier":
|
40558 | case "Comment":
|
40559 | case "MemberTypeAnnotation":
|
40560 |
|
40561 | case "Type":
|
40562 |
|
40563 | throw new Error("unprintable type: " + JSON.stringify(n.type));
|
40564 |
|
40565 |
|
40566 |
|
40567 | case "TypeAnnotation":
|
40568 | case "TSTypeAnnotation":
|
40569 | if (n.typeAnnotation) {
|
40570 | return path.call(print, "typeAnnotation");
|
40571 | }
|
40572 |
|
40573 |
|
40574 |
|
40575 | return "";
|
40576 |
|
40577 | case "TSTupleType":
|
40578 | case "TupleTypeAnnotation":
|
40579 | {
|
40580 | const typesField = n.type === "TSTupleType" ? "elementTypes" : "types";
|
40581 | const hasRest = n[typesField].length > 0 && getLast$2(n[typesField]).type === "TSRestType";
|
40582 | return group$2(concat$6(["[", indent$3(concat$6([softline$2, printArrayItems(path, options, typesField, print)])), ifBreak$1(shouldPrintComma(options, "all") && !hasRest ? "," : ""), comments.printDanglingComments(path, options,
|
40583 |
|
40584 | true), softline$2, "]"]));
|
40585 | }
|
40586 |
|
40587 | case "ExistsTypeAnnotation":
|
40588 | return "*";
|
40589 |
|
40590 | case "EmptyTypeAnnotation":
|
40591 | return "empty";
|
40592 |
|
40593 | case "AnyTypeAnnotation":
|
40594 | return "any";
|
40595 |
|
40596 | case "MixedTypeAnnotation":
|
40597 | return "mixed";
|
40598 |
|
40599 | case "ArrayTypeAnnotation":
|
40600 | return concat$6([path.call(print, "elementType"), "[]"]);
|
40601 |
|
40602 | case "BooleanTypeAnnotation":
|
40603 | return "boolean";
|
40604 |
|
40605 | case "BooleanLiteralTypeAnnotation":
|
40606 | return "" + n.value;
|
40607 |
|
40608 | case "DeclareClass":
|
40609 | return printFlowDeclaration(path, printClass(path, options, print));
|
40610 |
|
40611 | case "TSDeclareFunction":
|
40612 |
|
40613 |
|
40614 | return concat$6([n.declare ? "declare " : "", printFunctionDeclaration(path, print, options), semi]);
|
40615 |
|
40616 | case "DeclareFunction":
|
40617 | return printFlowDeclaration(path, ["function ", path.call(print, "id"), n.predicate ? " " : "", path.call(print, "predicate"), semi]);
|
40618 |
|
40619 | case "DeclareModule":
|
40620 | return printFlowDeclaration(path, ["module ", path.call(print, "id"), " ", path.call(print, "body")]);
|
40621 |
|
40622 | case "DeclareModuleExports":
|
40623 | return printFlowDeclaration(path, ["module.exports", ": ", path.call(print, "typeAnnotation"), semi]);
|
40624 |
|
40625 | case "DeclareVariable":
|
40626 | return printFlowDeclaration(path, ["var ", path.call(print, "id"), semi]);
|
40627 |
|
40628 | case "DeclareExportAllDeclaration":
|
40629 | return concat$6(["declare export * from ", path.call(print, "source")]);
|
40630 |
|
40631 | case "DeclareExportDeclaration":
|
40632 | return concat$6(["declare ", printExportDeclaration(path, options, print)]);
|
40633 |
|
40634 | case "DeclareOpaqueType":
|
40635 | case "OpaqueType":
|
40636 | {
|
40637 | parts.push("opaque type ", path.call(print, "id"), path.call(print, "typeParameters"));
|
40638 |
|
40639 | if (n.supertype) {
|
40640 | parts.push(": ", path.call(print, "supertype"));
|
40641 | }
|
40642 |
|
40643 | if (n.impltype) {
|
40644 | parts.push(" = ", path.call(print, "impltype"));
|
40645 | }
|
40646 |
|
40647 | parts.push(semi);
|
40648 |
|
40649 | if (n.type === "DeclareOpaqueType") {
|
40650 | return printFlowDeclaration(path, parts);
|
40651 | }
|
40652 |
|
40653 | return concat$6(parts);
|
40654 | }
|
40655 |
|
40656 | case "EnumDeclaration":
|
40657 | return concat$6(["enum ", path.call(print, "id"), " ", path.call(print, "body")]);
|
40658 |
|
40659 | case "EnumBooleanBody":
|
40660 | case "EnumNumberBody":
|
40661 | case "EnumStringBody":
|
40662 | case "EnumSymbolBody":
|
40663 | {
|
40664 | if (n.type === "EnumSymbolBody" || n.explicitType) {
|
40665 | let type = null;
|
40666 |
|
40667 | switch (n.type) {
|
40668 | case "EnumBooleanBody":
|
40669 | type = "boolean";
|
40670 | break;
|
40671 |
|
40672 | case "EnumNumberBody":
|
40673 | type = "number";
|
40674 | break;
|
40675 |
|
40676 | case "EnumStringBody":
|
40677 | type = "string";
|
40678 | break;
|
40679 |
|
40680 | case "EnumSymbolBody":
|
40681 | type = "symbol";
|
40682 | break;
|
40683 | }
|
40684 |
|
40685 | parts.push("of ", type, " ");
|
40686 | }
|
40687 |
|
40688 | if (n.members.length === 0) {
|
40689 | parts.push(group$2(concat$6(["{", comments.printDanglingComments(path, options), softline$2, "}"])));
|
40690 | } else {
|
40691 | parts.push(group$2(concat$6(["{", indent$3(concat$6([hardline$4, printArrayItems(path, options, "members", print), shouldPrintComma(options) ? "," : ""])), comments.printDanglingComments(path, options,
|
40692 |
|
40693 | true), hardline$4, "}"])));
|
40694 | }
|
40695 |
|
40696 | return concat$6(parts);
|
40697 | }
|
40698 |
|
40699 | case "EnumBooleanMember":
|
40700 | case "EnumNumberMember":
|
40701 | case "EnumStringMember":
|
40702 | return concat$6([path.call(print, "id"), " = ", typeof n.init === "object" ? path.call(print, "init") : String(n.init)]);
|
40703 |
|
40704 | case "EnumDefaultedMember":
|
40705 | return path.call(print, "id");
|
40706 |
|
40707 | case "FunctionTypeAnnotation":
|
40708 | case "TSFunctionType":
|
40709 | {
|
40710 |
|
40711 |
|
40712 |
|
40713 | const parent = path.getParentNode(0);
|
40714 | const parentParent = path.getParentNode(1);
|
40715 | const parentParentParent = path.getParentNode(2);
|
40716 | let isArrowFunctionTypeAnnotation = n.type === "TSFunctionType" || !((parent.type === "ObjectTypeProperty" || parent.type === "ObjectTypeInternalSlot") && !getFlowVariance$1(parent) && !parent.optional && options.locStart(parent) === options.locStart(n) || parent.type === "ObjectTypeCallProperty" || parentParentParent && parentParentParent.type === "DeclareFunction");
|
40717 | let needsColon = isArrowFunctionTypeAnnotation && (parent.type === "TypeAnnotation" || parent.type === "TSTypeAnnotation");
|
40718 |
|
40719 |
|
40720 |
|
40721 | const needsParens = needsColon && isArrowFunctionTypeAnnotation && (parent.type === "TypeAnnotation" || parent.type === "TSTypeAnnotation") && parentParent.type === "ArrowFunctionExpression";
|
40722 |
|
40723 | if (isObjectTypePropertyAFunction$1(parent, options)) {
|
40724 | isArrowFunctionTypeAnnotation = true;
|
40725 | needsColon = true;
|
40726 | }
|
40727 |
|
40728 | if (needsParens) {
|
40729 | parts.push("(");
|
40730 | }
|
40731 |
|
40732 | parts.push(printFunctionParams(path, print, options,
|
40733 |
|
40734 | false,
|
40735 |
|
40736 | true));
|
40737 |
|
40738 |
|
40739 | if (n.returnType || n.predicate || n.typeAnnotation) {
|
40740 | parts.push(isArrowFunctionTypeAnnotation ? " => " : ": ", path.call(print, "returnType"), path.call(print, "predicate"), path.call(print, "typeAnnotation"));
|
40741 | }
|
40742 |
|
40743 | if (needsParens) {
|
40744 | parts.push(")");
|
40745 | }
|
40746 |
|
40747 | return group$2(concat$6(parts));
|
40748 | }
|
40749 |
|
40750 | case "TSRestType":
|
40751 | return concat$6(["...", path.call(print, "typeAnnotation")]);
|
40752 |
|
40753 | case "TSOptionalType":
|
40754 | return concat$6([path.call(print, "typeAnnotation"), "?"]);
|
40755 |
|
40756 | case "FunctionTypeParam":
|
40757 | return concat$6([path.call(print, "name"), printOptionalToken(path), n.name ? ": " : "", path.call(print, "typeAnnotation")]);
|
40758 |
|
40759 | case "GenericTypeAnnotation":
|
40760 | return concat$6([path.call(print, "id"), path.call(print, "typeParameters")]);
|
40761 |
|
40762 | case "DeclareInterface":
|
40763 | case "InterfaceDeclaration":
|
40764 | case "InterfaceTypeAnnotation":
|
40765 | {
|
40766 | if (n.type === "DeclareInterface" || n.declare) {
|
40767 | parts.push("declare ");
|
40768 | }
|
40769 |
|
40770 | parts.push("interface");
|
40771 |
|
40772 | if (n.type === "DeclareInterface" || n.type === "InterfaceDeclaration") {
|
40773 | parts.push(" ", path.call(print, "id"), path.call(print, "typeParameters"));
|
40774 | }
|
40775 |
|
40776 | if (n.extends.length > 0) {
|
40777 | parts.push(group$2(indent$3(concat$6([line$4, "extends ", (n.extends.length === 1 ? identity$2 : indent$3)(join$4(concat$6([",", line$4]), path.map(print, "extends")))]))));
|
40778 | }
|
40779 |
|
40780 | parts.push(" ", path.call(print, "body"));
|
40781 | return group$2(concat$6(parts));
|
40782 | }
|
40783 |
|
40784 | case "ClassImplements":
|
40785 | case "InterfaceExtends":
|
40786 | return concat$6([path.call(print, "id"), path.call(print, "typeParameters")]);
|
40787 |
|
40788 | case "TSClassImplements":
|
40789 | return concat$6([path.call(print, "expression"), path.call(print, "typeParameters")]);
|
40790 |
|
40791 | case "TSIntersectionType":
|
40792 | case "IntersectionTypeAnnotation":
|
40793 | {
|
40794 | const types = path.map(print, "types");
|
40795 | const result = [];
|
40796 | let wasIndented = false;
|
40797 |
|
40798 | for (let i = 0; i < types.length; ++i) {
|
40799 | if (i === 0) {
|
40800 | result.push(types[i]);
|
40801 | } else if (isObjectType$1(n.types[i - 1]) && isObjectType$1(n.types[i])) {
|
40802 |
|
40803 | result.push(concat$6([" & ", wasIndented ? indent$3(types[i]) : types[i]]));
|
40804 | } else if (!isObjectType$1(n.types[i - 1]) && !isObjectType$1(n.types[i])) {
|
40805 |
|
40806 | result.push(indent$3(concat$6([" &", line$4, types[i]])));
|
40807 | } else {
|
40808 |
|
40809 | if (i > 1) {
|
40810 | wasIndented = true;
|
40811 | }
|
40812 |
|
40813 | result.push(" & ", i > 1 ? indent$3(types[i]) : types[i]);
|
40814 | }
|
40815 | }
|
40816 |
|
40817 | return group$2(concat$6(result));
|
40818 | }
|
40819 |
|
40820 | case "TSUnionType":
|
40821 | case "UnionTypeAnnotation":
|
40822 | {
|
40823 |
|
40824 |
|
40825 |
|
40826 |
|
40827 |
|
40828 |
|
40829 | const parent = path.getParentNode();
|
40830 |
|
40831 | const shouldIndent = parent.type !== "TypeParameterInstantiation" && parent.type !== "TSTypeParameterInstantiation" && parent.type !== "GenericTypeAnnotation" && parent.type !== "TSTypeReference" && parent.type !== "TSTypeAssertion" && parent.type !== "TupleTypeAnnotation" && parent.type !== "TSTupleType" && !(parent.type === "FunctionTypeParam" && !parent.name) && !((parent.type === "TypeAlias" || parent.type === "VariableDeclarator" || parent.type === "TSTypeAliasDeclaration") && hasLeadingOwnLineComment$1(options.originalText, n, options));
|
40832 |
|
40833 |
|
40834 |
|
40835 |
|
40836 | const shouldHug = shouldHugType(n);
|
40837 |
|
40838 |
|
40839 |
|
40840 |
|
40841 | const printed = path.map(typePath => {
|
40842 | let printedType = typePath.call(print);
|
40843 |
|
40844 | if (!shouldHug) {
|
40845 | printedType = align$1(2, printedType);
|
40846 | }
|
40847 |
|
40848 | return comments.printComments(typePath, () => printedType, options);
|
40849 | }, "types");
|
40850 |
|
40851 | if (shouldHug) {
|
40852 | return join$4(" | ", printed);
|
40853 | }
|
40854 |
|
40855 | const shouldAddStartLine = shouldIndent && !hasLeadingOwnLineComment$1(options.originalText, n, options);
|
40856 | const code = concat$6([ifBreak$1(concat$6([shouldAddStartLine ? line$4 : "", "| "])), join$4(concat$6([line$4, "| "]), printed)]);
|
40857 |
|
40858 | if (needsParens_1(path, options)) {
|
40859 | return group$2(concat$6([indent$3(code), softline$2]));
|
40860 | }
|
40861 |
|
40862 | if (parent.type === "TupleTypeAnnotation" && parent.types.length > 1 || parent.type === "TSTupleType" && parent.elementTypes.length > 1) {
|
40863 | return group$2(concat$6([indent$3(concat$6([ifBreak$1(concat$6(["(", softline$2])), code])), softline$2, ifBreak$1(")")]));
|
40864 | }
|
40865 |
|
40866 | return group$2(shouldIndent ? indent$3(code) : code);
|
40867 | }
|
40868 |
|
40869 | case "NullableTypeAnnotation":
|
40870 | return concat$6(["?", path.call(print, "typeAnnotation")]);
|
40871 |
|
40872 | case "TSNullKeyword":
|
40873 | case "NullLiteralTypeAnnotation":
|
40874 | return "null";
|
40875 |
|
40876 | case "ThisTypeAnnotation":
|
40877 | return "this";
|
40878 |
|
40879 | case "NumberTypeAnnotation":
|
40880 | return "number";
|
40881 |
|
40882 | case "SymbolTypeAnnotation":
|
40883 | return "symbol";
|
40884 |
|
40885 | case "ObjectTypeCallProperty":
|
40886 | if (n.static) {
|
40887 | parts.push("static ");
|
40888 | }
|
40889 |
|
40890 | parts.push(path.call(print, "value"));
|
40891 | return concat$6(parts);
|
40892 |
|
40893 | case "ObjectTypeIndexer":
|
40894 | {
|
40895 | const variance = getFlowVariance$1(n);
|
40896 | return concat$6([variance || "", "[", path.call(print, "id"), n.id ? ": " : "", path.call(print, "key"), "]: ", path.call(print, "value")]);
|
40897 | }
|
40898 |
|
40899 | case "ObjectTypeProperty":
|
40900 | {
|
40901 | const variance = getFlowVariance$1(n);
|
40902 | let modifier = "";
|
40903 |
|
40904 | if (n.proto) {
|
40905 | modifier = "proto ";
|
40906 | } else if (n.static) {
|
40907 | modifier = "static ";
|
40908 | }
|
40909 |
|
40910 | return concat$6([modifier, isGetterOrSetter$1(n) ? n.kind + " " : "", variance || "", printPropertyKey(path, options, print), printOptionalToken(path), isFunctionNotation$1(n, options) ? "" : ": ", path.call(print, "value")]);
|
40911 | }
|
40912 |
|
40913 | case "QualifiedTypeIdentifier":
|
40914 | return concat$6([path.call(print, "qualification"), ".", path.call(print, "id")]);
|
40915 |
|
40916 | case "StringLiteralTypeAnnotation":
|
40917 | return nodeStr(n, options);
|
40918 |
|
40919 | case "NumberLiteralTypeAnnotation":
|
40920 | assert$1.strictEqual(typeof n.value, "number");
|
40921 |
|
40922 | if (n.extra != null) {
|
40923 | return printNumber$1(n.extra.raw);
|
40924 | }
|
40925 |
|
40926 | return printNumber$1(n.raw);
|
40927 |
|
40928 | case "StringTypeAnnotation":
|
40929 | return "string";
|
40930 |
|
40931 | case "DeclareTypeAlias":
|
40932 | case "TypeAlias":
|
40933 | {
|
40934 | if (n.type === "DeclareTypeAlias" || n.declare) {
|
40935 | parts.push("declare ");
|
40936 | }
|
40937 |
|
40938 | const printed = printAssignmentRight(n.id, n.right, path.call(print, "right"), options);
|
40939 | parts.push("type ", path.call(print, "id"), path.call(print, "typeParameters"), " =", printed, semi);
|
40940 | return group$2(concat$6(parts));
|
40941 | }
|
40942 |
|
40943 | case "TypeCastExpression":
|
40944 | {
|
40945 | return concat$6(["(", path.call(print, "expression"), printTypeAnnotation(path, options, print), ")"]);
|
40946 | }
|
40947 |
|
40948 | case "TypeParameterDeclaration":
|
40949 | case "TypeParameterInstantiation":
|
40950 | {
|
40951 | const value = path.getValue();
|
40952 | const commentStart = value.range ? options.originalText.slice(0, value.range[0]).lastIndexOf("/*") : -1;
|
40953 |
|
40954 |
|
40955 | const commentSyntax = commentStart >= 0 && options.originalText.slice(commentStart).match(/^\/\*\s*::/);
|
40956 |
|
40957 | if (commentSyntax) {
|
40958 | return concat$6(["/*:: ", printTypeParameters(path, options, print, "params"), " */"]);
|
40959 | }
|
40960 |
|
40961 | return printTypeParameters(path, options, print, "params");
|
40962 | }
|
40963 |
|
40964 | case "TSTypeParameterDeclaration":
|
40965 | case "TSTypeParameterInstantiation":
|
40966 | return printTypeParameters(path, options, print, "params");
|
40967 |
|
40968 | case "TSTypeParameter":
|
40969 | case "TypeParameter":
|
40970 | {
|
40971 | const parent = path.getParentNode();
|
40972 |
|
40973 | if (parent.type === "TSMappedType") {
|
40974 | parts.push("[", path.call(print, "name"));
|
40975 |
|
40976 | if (n.constraint) {
|
40977 | parts.push(" in ", path.call(print, "constraint"));
|
40978 | }
|
40979 |
|
40980 | parts.push("]");
|
40981 | return concat$6(parts);
|
40982 | }
|
40983 |
|
40984 | const variance = getFlowVariance$1(n);
|
40985 |
|
40986 | if (variance) {
|
40987 | parts.push(variance);
|
40988 | }
|
40989 |
|
40990 | parts.push(path.call(print, "name"));
|
40991 |
|
40992 | if (n.bound) {
|
40993 | parts.push(": ");
|
40994 | parts.push(path.call(print, "bound"));
|
40995 | }
|
40996 |
|
40997 | if (n.constraint) {
|
40998 | parts.push(" extends ", path.call(print, "constraint"));
|
40999 | }
|
41000 |
|
41001 | if (n.default) {
|
41002 | parts.push(" = ", path.call(print, "default"));
|
41003 | }
|
41004 |
|
41005 |
|
41006 |
|
41007 |
|
41008 | const grandParent = path.getNode(2);
|
41009 |
|
41010 | if (parent.params && parent.params.length === 1 && isTSXFile$1(options) && !n.constraint && grandParent.type === "ArrowFunctionExpression") {
|
41011 | parts.push(",");
|
41012 | }
|
41013 |
|
41014 | return concat$6(parts);
|
41015 | }
|
41016 |
|
41017 | case "TypeofTypeAnnotation":
|
41018 | return concat$6(["typeof ", path.call(print, "argument")]);
|
41019 |
|
41020 | case "VoidTypeAnnotation":
|
41021 | return "void";
|
41022 |
|
41023 | case "InferredPredicate":
|
41024 | return "%checks";
|
41025 |
|
41026 |
|
41027 |
|
41028 |
|
41029 | case "DeclaredPredicate":
|
41030 | return concat$6(["%checks(", path.call(print, "value"), ")"]);
|
41031 |
|
41032 | case "TSAbstractKeyword":
|
41033 | return "abstract";
|
41034 |
|
41035 | case "TSAnyKeyword":
|
41036 | return "any";
|
41037 |
|
41038 | case "TSAsyncKeyword":
|
41039 | return "async";
|
41040 |
|
41041 | case "TSBooleanKeyword":
|
41042 | return "boolean";
|
41043 |
|
41044 | case "TSBigIntKeyword":
|
41045 | return "bigint";
|
41046 |
|
41047 | case "TSConstKeyword":
|
41048 | return "const";
|
41049 |
|
41050 | case "TSDeclareKeyword":
|
41051 | return "declare";
|
41052 |
|
41053 | case "TSExportKeyword":
|
41054 | return "export";
|
41055 |
|
41056 | case "TSNeverKeyword":
|
41057 | return "never";
|
41058 |
|
41059 | case "TSNumberKeyword":
|
41060 | return "number";
|
41061 |
|
41062 | case "TSObjectKeyword":
|
41063 | return "object";
|
41064 |
|
41065 | case "TSProtectedKeyword":
|
41066 | return "protected";
|
41067 |
|
41068 | case "TSPrivateKeyword":
|
41069 | return "private";
|
41070 |
|
41071 | case "TSPublicKeyword":
|
41072 | return "public";
|
41073 |
|
41074 | case "TSReadonlyKeyword":
|
41075 | return "readonly";
|
41076 |
|
41077 | case "TSSymbolKeyword":
|
41078 | return "symbol";
|
41079 |
|
41080 | case "TSStaticKeyword":
|
41081 | return "static";
|
41082 |
|
41083 | case "TSStringKeyword":
|
41084 | return "string";
|
41085 |
|
41086 | case "TSUndefinedKeyword":
|
41087 | return "undefined";
|
41088 |
|
41089 | case "TSUnknownKeyword":
|
41090 | return "unknown";
|
41091 |
|
41092 | case "TSVoidKeyword":
|
41093 | return "void";
|
41094 |
|
41095 | case "TSAsExpression":
|
41096 | return concat$6([path.call(print, "expression"), " as ", path.call(print, "typeAnnotation")]);
|
41097 |
|
41098 | case "TSArrayType":
|
41099 | return concat$6([path.call(print, "elementType"), "[]"]);
|
41100 |
|
41101 | case "TSPropertySignature":
|
41102 | {
|
41103 | if (n.export) {
|
41104 | parts.push("export ");
|
41105 | }
|
41106 |
|
41107 | if (n.accessibility) {
|
41108 | parts.push(n.accessibility + " ");
|
41109 | }
|
41110 |
|
41111 | if (n.static) {
|
41112 | parts.push("static ");
|
41113 | }
|
41114 |
|
41115 | if (n.readonly) {
|
41116 | parts.push("readonly ");
|
41117 | }
|
41118 |
|
41119 | parts.push(printPropertyKey(path, options, print), printOptionalToken(path));
|
41120 |
|
41121 | if (n.typeAnnotation) {
|
41122 | parts.push(": ");
|
41123 | parts.push(path.call(print, "typeAnnotation"));
|
41124 | }
|
41125 |
|
41126 |
|
41127 | if (n.initializer) {
|
41128 | parts.push(" = ", path.call(print, "initializer"));
|
41129 | }
|
41130 |
|
41131 | return concat$6(parts);
|
41132 | }
|
41133 |
|
41134 | case "TSParameterProperty":
|
41135 | if (n.accessibility) {
|
41136 | parts.push(n.accessibility + " ");
|
41137 | }
|
41138 |
|
41139 | if (n.export) {
|
41140 | parts.push("export ");
|
41141 | }
|
41142 |
|
41143 | if (n.static) {
|
41144 | parts.push("static ");
|
41145 | }
|
41146 |
|
41147 | if (n.readonly) {
|
41148 | parts.push("readonly ");
|
41149 | }
|
41150 |
|
41151 | parts.push(path.call(print, "parameter"));
|
41152 | return concat$6(parts);
|
41153 |
|
41154 | case "TSTypeReference":
|
41155 | return concat$6([path.call(print, "typeName"), printTypeParameters(path, options, print, "typeParameters")]);
|
41156 |
|
41157 | case "TSTypeQuery":
|
41158 | return concat$6(["typeof ", path.call(print, "exprName")]);
|
41159 |
|
41160 | case "TSIndexSignature":
|
41161 | {
|
41162 | const parent = path.getParentNode();
|
41163 |
|
41164 |
|
41165 |
|
41166 |
|
41167 | const trailingComma = n.parameters.length > 1 ? ifBreak$1(shouldPrintComma(options) ? "," : "") : "";
|
41168 | const parametersGroup = group$2(concat$6([indent$3(concat$6([softline$2, join$4(concat$6([", ", softline$2]), path.map(print, "parameters"))])), trailingComma, softline$2]));
|
41169 | return concat$6([n.export ? "export " : "", n.accessibility ? concat$6([n.accessibility, " "]) : "", n.static ? "static " : "", n.readonly ? "readonly " : "", "[", n.parameters ? parametersGroup : "", n.typeAnnotation ? "]: " : "]", n.typeAnnotation ? path.call(print, "typeAnnotation") : "", parent.type === "ClassBody" ? semi : ""]);
|
41170 | }
|
41171 |
|
41172 | case "TSTypePredicate":
|
41173 | return concat$6([n.asserts ? "asserts " : "", path.call(print, "parameterName"), n.typeAnnotation ? concat$6([" is ", path.call(print, "typeAnnotation")]) : ""]);
|
41174 |
|
41175 | case "TSNonNullExpression":
|
41176 | return concat$6([path.call(print, "expression"), "!"]);
|
41177 |
|
41178 | case "TSThisType":
|
41179 | return "this";
|
41180 |
|
41181 | case "TSImportType":
|
41182 | return concat$6([!n.isTypeOf ? "" : "typeof ", "import(", path.call(print, n.parameter ? "parameter" : "argument"), ")", !n.qualifier ? "" : concat$6([".", path.call(print, "qualifier")]), printTypeParameters(path, options, print, "typeParameters")]);
|
41183 |
|
41184 | case "TSLiteralType":
|
41185 | return path.call(print, "literal");
|
41186 |
|
41187 | case "TSIndexedAccessType":
|
41188 | return concat$6([path.call(print, "objectType"), "[", path.call(print, "indexType"), "]"]);
|
41189 |
|
41190 | case "TSConstructSignatureDeclaration":
|
41191 | case "TSCallSignatureDeclaration":
|
41192 | case "TSConstructorType":
|
41193 | {
|
41194 | if (n.type !== "TSCallSignatureDeclaration") {
|
41195 | parts.push("new ");
|
41196 | }
|
41197 |
|
41198 | parts.push(group$2(printFunctionParams(path, print, options,
|
41199 |
|
41200 | false,
|
41201 |
|
41202 | true)));
|
41203 |
|
41204 | if (n.returnType || n.typeAnnotation) {
|
41205 | const isType = n.type === "TSConstructorType";
|
41206 | parts.push(isType ? " => " : ": ", path.call(print, "returnType"), path.call(print, "typeAnnotation"));
|
41207 | }
|
41208 |
|
41209 | return concat$6(parts);
|
41210 | }
|
41211 |
|
41212 | case "TSTypeOperator":
|
41213 | return concat$6([n.operator, " ", path.call(print, "typeAnnotation")]);
|
41214 |
|
41215 | case "TSMappedType":
|
41216 | {
|
41217 | const shouldBreak = hasNewlineInRange$3(options.originalText, options.locStart(n), options.locEnd(n));
|
41218 | return group$2(concat$6(["{", indent$3(concat$6([options.bracketSpacing ? line$4 : softline$2, n.readonly ? concat$6([getTypeScriptMappedTypeModifier$1(n.readonly, "readonly"), " "]) : "", printTypeScriptModifiers(path, options, print), path.call(print, "typeParameter"), n.optional ? getTypeScriptMappedTypeModifier$1(n.optional, "?") : "", n.typeAnnotation ? ": " : "", path.call(print, "typeAnnotation"), ifBreak$1(semi, "")])), comments.printDanglingComments(path, options,
|
41219 |
|
41220 | true), options.bracketSpacing ? line$4 : softline$2, "}"]), {
|
41221 | shouldBreak
|
41222 | });
|
41223 | }
|
41224 |
|
41225 | case "TSMethodSignature":
|
41226 | parts.push(n.accessibility ? concat$6([n.accessibility, " "]) : "", n.export ? "export " : "", n.static ? "static " : "", n.readonly ? "readonly " : "", n.computed ? "[" : "", path.call(print, "key"), n.computed ? "]" : "", printOptionalToken(path), printFunctionParams(path, print, options,
|
41227 |
|
41228 | false,
|
41229 |
|
41230 | true));
|
41231 |
|
41232 | if (n.returnType || n.typeAnnotation) {
|
41233 | parts.push(": ", path.call(print, "returnType"), path.call(print, "typeAnnotation"));
|
41234 | }
|
41235 |
|
41236 | return group$2(concat$6(parts));
|
41237 |
|
41238 | case "TSNamespaceExportDeclaration":
|
41239 | parts.push("export as namespace ", path.call(print, "id"));
|
41240 |
|
41241 | if (options.semi) {
|
41242 | parts.push(";");
|
41243 | }
|
41244 |
|
41245 | return group$2(concat$6(parts));
|
41246 |
|
41247 | case "TSEnumDeclaration":
|
41248 | if (n.declare) {
|
41249 | parts.push("declare ");
|
41250 | }
|
41251 |
|
41252 | if (n.modifiers) {
|
41253 | parts.push(printTypeScriptModifiers(path, options, print));
|
41254 | }
|
41255 |
|
41256 | if (n.const) {
|
41257 | parts.push("const ");
|
41258 | }
|
41259 |
|
41260 | parts.push("enum ", path.call(print, "id"), " ");
|
41261 |
|
41262 | if (n.members.length === 0) {
|
41263 | parts.push(group$2(concat$6(["{", comments.printDanglingComments(path, options), softline$2, "}"])));
|
41264 | } else {
|
41265 | parts.push(group$2(concat$6(["{", indent$3(concat$6([hardline$4, printArrayItems(path, options, "members", print), shouldPrintComma(options, "es5") ? "," : ""])), comments.printDanglingComments(path, options,
|
41266 |
|
41267 | true), hardline$4, "}"])));
|
41268 | }
|
41269 |
|
41270 | return concat$6(parts);
|
41271 |
|
41272 | case "TSEnumMember":
|
41273 | parts.push(path.call(print, "id"));
|
41274 |
|
41275 | if (n.initializer) {
|
41276 | parts.push(" = ", path.call(print, "initializer"));
|
41277 | }
|
41278 |
|
41279 | return concat$6(parts);
|
41280 |
|
41281 | case "TSImportEqualsDeclaration":
|
41282 | if (n.isExport) {
|
41283 | parts.push("export ");
|
41284 | }
|
41285 |
|
41286 | parts.push("import ", path.call(print, "id"), " = ", path.call(print, "moduleReference"));
|
41287 |
|
41288 | if (options.semi) {
|
41289 | parts.push(";");
|
41290 | }
|
41291 |
|
41292 | return group$2(concat$6(parts));
|
41293 |
|
41294 | case "TSExternalModuleReference":
|
41295 | return concat$6(["require(", path.call(print, "expression"), ")"]);
|
41296 |
|
41297 | case "TSModuleDeclaration":
|
41298 | {
|
41299 | const parent = path.getParentNode();
|
41300 | const isExternalModule = isLiteral$1(n.id);
|
41301 | const parentIsDeclaration = parent.type === "TSModuleDeclaration";
|
41302 | const bodyIsDeclaration = n.body && n.body.type === "TSModuleDeclaration";
|
41303 |
|
41304 | if (parentIsDeclaration) {
|
41305 | parts.push(".");
|
41306 | } else {
|
41307 | if (n.declare) {
|
41308 | parts.push("declare ");
|
41309 | }
|
41310 |
|
41311 | parts.push(printTypeScriptModifiers(path, options, print));
|
41312 | const textBetweenNodeAndItsId = options.originalText.slice(options.locStart(n), options.locStart(n.id));
|
41313 |
|
41314 |
|
41315 | const isGlobalDeclaration = n.id.type === "Identifier" && n.id.name === "global" && !/namespace|module/.test(textBetweenNodeAndItsId);
|
41316 |
|
41317 | if (!isGlobalDeclaration) {
|
41318 | parts.push(isExternalModule || /(^|\s)module(\s|$)/.test(textBetweenNodeAndItsId) ? "module " : "namespace ");
|
41319 | }
|
41320 | }
|
41321 |
|
41322 | parts.push(path.call(print, "id"));
|
41323 |
|
41324 | if (bodyIsDeclaration) {
|
41325 | parts.push(path.call(print, "body"));
|
41326 | } else if (n.body) {
|
41327 | parts.push(" ", group$2(path.call(print, "body")));
|
41328 | } else {
|
41329 | parts.push(semi);
|
41330 | }
|
41331 |
|
41332 | return concat$6(parts);
|
41333 | }
|
41334 |
|
41335 | case "PrivateName":
|
41336 | return concat$6(["#", path.call(print, "id")]);
|
41337 |
|
41338 |
|
41339 | case "TSPrivateIdentifier":
|
41340 | return n.escapedText;
|
41341 |
|
41342 | case "TSConditionalType":
|
41343 | return printTernaryOperator(path, options, print, {
|
41344 | beforeParts: () => [path.call(print, "checkType"), " ", "extends", " ", path.call(print, "extendsType")],
|
41345 | afterParts: () => [],
|
41346 | shouldCheckJsx: false,
|
41347 | conditionalNodeType: "TSConditionalType",
|
41348 | consequentNodePropertyName: "trueType",
|
41349 | alternateNodePropertyName: "falseType",
|
41350 | testNodePropertyNames: ["checkType", "extendsType"]
|
41351 | });
|
41352 |
|
41353 | case "TSInferType":
|
41354 | return concat$6(["infer", " ", path.call(print, "typeParameter")]);
|
41355 |
|
41356 | case "InterpreterDirective":
|
41357 | parts.push("#!", n.value, hardline$4);
|
41358 |
|
41359 | if (isNextLineEmpty$2(options.originalText, n, options.locEnd)) {
|
41360 | parts.push(hardline$4);
|
41361 | }
|
41362 |
|
41363 | return concat$6(parts);
|
41364 |
|
41365 | case "NGRoot":
|
41366 | return concat$6([].concat(path.call(print, "node"), !n.node.comments || n.node.comments.length === 0 ? [] : concat$6([" //", n.node.comments[0].value.trimEnd()])));
|
41367 |
|
41368 | case "NGChainedExpression":
|
41369 | return group$2(join$4(concat$6([";", line$4]), path.map(childPath => hasNgSideEffect$1(childPath) ? print(childPath) : concat$6(["(", print(childPath), ")"]), "expressions")));
|
41370 |
|
41371 | case "NGEmptyExpression":
|
41372 | return "";
|
41373 |
|
41374 | case "NGQuotedExpression":
|
41375 | return concat$6([n.prefix, ": ", n.value.trim()]);
|
41376 |
|
41377 | case "NGMicrosyntax":
|
41378 | return concat$6(path.map((childPath, index) => concat$6([index === 0 ? "" : isNgForOf$1(childPath.getValue(), index, n) ? " " : concat$6([";", line$4]), print(childPath)]), "body"));
|
41379 |
|
41380 | case "NGMicrosyntaxKey":
|
41381 | return /^[a-z_$][a-z0-9_$]*(-[a-z_$][a-z0-9_$])*$/i.test(n.name) ? n.name : JSON.stringify(n.name);
|
41382 |
|
41383 | case "NGMicrosyntaxExpression":
|
41384 | return concat$6([path.call(print, "expression"), n.alias === null ? "" : concat$6([" as ", path.call(print, "alias")])]);
|
41385 |
|
41386 | case "NGMicrosyntaxKeyedExpression":
|
41387 | {
|
41388 | const index = path.getName();
|
41389 | const parentNode = path.getParentNode();
|
41390 | const shouldNotPrintColon = isNgForOf$1(n, index, parentNode) || (index === 1 && (n.key.name === "then" || n.key.name === "else") || index === 2 && n.key.name === "else" && parentNode.body[index - 1].type === "NGMicrosyntaxKeyedExpression" && parentNode.body[index - 1].key.name === "then") && parentNode.body[0].type === "NGMicrosyntaxExpression";
|
41391 | return concat$6([path.call(print, "key"), shouldNotPrintColon ? " " : ": ", path.call(print, "expression")]);
|
41392 | }
|
41393 |
|
41394 | case "NGMicrosyntaxLet":
|
41395 | return concat$6(["let ", path.call(print, "key"), n.value === null ? "" : concat$6([" = ", path.call(print, "value")])]);
|
41396 |
|
41397 | case "NGMicrosyntaxAs":
|
41398 | return concat$6([path.call(print, "key"), " as ", path.call(print, "alias")]);
|
41399 |
|
41400 | case "ArgumentPlaceholder":
|
41401 | return "?";
|
41402 |
|
41403 |
|
41404 | case "TSJSDocAllType":
|
41405 | return "*";
|
41406 |
|
41407 | case "TSJSDocUnknownType":
|
41408 | return "?";
|
41409 |
|
41410 | case "TSJSDocNullableType":
|
41411 | return concat$6(["?", path.call(print, "typeAnnotation")]);
|
41412 |
|
41413 | case "TSJSDocNonNullableType":
|
41414 | return concat$6(["!", path.call(print, "typeAnnotation")]);
|
41415 |
|
41416 | case "TSJSDocFunctionType":
|
41417 | return concat$6(["function(",
|
41418 | "): ", path.call(print, "typeAnnotation")]);
|
41419 |
|
41420 | default:
|
41421 |
|
41422 | throw new Error("unknown type: " + JSON.stringify(n.type));
|
41423 | }
|
41424 | }
|
41425 |
|
41426 | function printStatementSequence(path, options, print) {
|
41427 | const printed = [];
|
41428 | const bodyNode = path.getNode();
|
41429 | const isClass = bodyNode.type === "ClassBody";
|
41430 | path.map((stmtPath, i) => {
|
41431 | const stmt = stmtPath.getValue();
|
41432 |
|
41433 |
|
41434 |
|
41435 |
|
41436 | if (!stmt) {
|
41437 | return;
|
41438 | }
|
41439 |
|
41440 |
|
41441 |
|
41442 | if (stmt.type === "EmptyStatement") {
|
41443 | return;
|
41444 | }
|
41445 |
|
41446 | const stmtPrinted = print(stmtPath);
|
41447 | const text = options.originalText;
|
41448 | const parts = [];
|
41449 |
|
41450 |
|
41451 | if (!options.semi && !isClass && !isTheOnlyJSXElementInMarkdown$1(options, stmtPath) && stmtNeedsASIProtection(stmtPath, options)) {
|
41452 | if (stmt.comments && stmt.comments.some(comment => comment.leading)) {
|
41453 | parts.push(print(stmtPath, {
|
41454 | needsSemi: true
|
41455 | }));
|
41456 | } else {
|
41457 | parts.push(";", stmtPrinted);
|
41458 | }
|
41459 | } else {
|
41460 | parts.push(stmtPrinted);
|
41461 | }
|
41462 |
|
41463 | if (!options.semi && isClass) {
|
41464 | if (classPropMayCauseASIProblems$1(stmtPath)) {
|
41465 | parts.push(";");
|
41466 | } else if (stmt.type === "ClassProperty") {
|
41467 | const nextChild = bodyNode.body[i + 1];
|
41468 |
|
41469 | if (classChildNeedsASIProtection$1(nextChild)) {
|
41470 | parts.push(";");
|
41471 | }
|
41472 | }
|
41473 | }
|
41474 |
|
41475 | if (isNextLineEmpty$2(text, stmt, options.locEnd) && !isLastStatement$1(stmtPath)) {
|
41476 | parts.push(hardline$4);
|
41477 | }
|
41478 |
|
41479 | printed.push(concat$6(parts));
|
41480 | });
|
41481 | return join$4(hardline$4, printed);
|
41482 | }
|
41483 |
|
41484 | function printPropertyKey(path, options, print) {
|
41485 | const node = path.getNode();
|
41486 |
|
41487 | if (node.computed) {
|
41488 | return concat$6(["[", path.call(print, "key"), "]"]);
|
41489 | }
|
41490 |
|
41491 | const parent = path.getParentNode();
|
41492 | const {
|
41493 | key
|
41494 | } = node;
|
41495 |
|
41496 | if (node.type === "ClassPrivateProperty" &&
|
41497 | key.type === "Identifier") {
|
41498 | return concat$6(["#", path.call(print, "key")]);
|
41499 | }
|
41500 |
|
41501 | if (options.quoteProps === "consistent" && !needsQuoteProps.has(parent)) {
|
41502 | const objectHasStringProp = (parent.properties || parent.body || parent.members).some(prop => !prop.computed && prop.key && isStringLiteral$1(prop.key) && !isStringPropSafeToCoerceToIdentifier$1(prop, options));
|
41503 | needsQuoteProps.set(parent, objectHasStringProp);
|
41504 | }
|
41505 |
|
41506 | if (key.type === "Identifier" && (options.parser === "json" || options.quoteProps === "consistent" && needsQuoteProps.get(parent))) {
|
41507 |
|
41508 | const prop = printString$1(JSON.stringify(key.name), options);
|
41509 | return path.call(keyPath => comments.printComments(keyPath, () => prop, options), "key");
|
41510 | }
|
41511 |
|
41512 | if (isStringPropSafeToCoerceToIdentifier$1(node, options) && (options.quoteProps === "as-needed" || options.quoteProps === "consistent" && !needsQuoteProps.get(parent))) {
|
41513 |
|
41514 | return path.call(keyPath => comments.printComments(keyPath, () => key.value, options), "key");
|
41515 | }
|
41516 |
|
41517 | return path.call(print, "key");
|
41518 | }
|
41519 |
|
41520 | function printMethod(path, options, print) {
|
41521 | const node = path.getNode();
|
41522 | const {
|
41523 | kind
|
41524 | } = node;
|
41525 | const value = node.value || node;
|
41526 | const parts = [];
|
41527 |
|
41528 | if (!kind || kind === "init" || kind === "method" || kind === "constructor") {
|
41529 | if (value.async) {
|
41530 | parts.push("async ");
|
41531 | }
|
41532 |
|
41533 | if (value.generator) {
|
41534 | parts.push("*");
|
41535 | }
|
41536 | } else {
|
41537 | assert$1.ok(kind === "get" || kind === "set");
|
41538 | parts.push(kind, " ");
|
41539 | }
|
41540 |
|
41541 | parts.push(printPropertyKey(path, options, print), node.optional || node.key.optional ? "?" : "", node === value ? printMethodInternal(path, options, print) : path.call(path => printMethodInternal(path, options, print), "value"));
|
41542 | return concat$6(parts);
|
41543 | }
|
41544 |
|
41545 | function printMethodInternal(path, options, print) {
|
41546 | const parts = [printFunctionTypeParameters(path, options, print), group$2(concat$6([printFunctionParams(path, print, options), printReturnType(path, print, options)]))];
|
41547 |
|
41548 | if (path.getNode().body) {
|
41549 | parts.push(" ", path.call(print, "body"));
|
41550 | } else {
|
41551 | parts.push(options.semi ? ";" : "");
|
41552 | }
|
41553 |
|
41554 | return concat$6(parts);
|
41555 | }
|
41556 |
|
41557 | function couldGroupArg(arg) {
|
41558 | return arg.type === "ObjectExpression" && (arg.properties.length > 0 || arg.comments) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || arg.comments) || arg.type === "TSTypeAssertion" && couldGroupArg(arg.expression) || arg.type === "TSAsExpression" && couldGroupArg(arg.expression) || arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression" && (
|
41559 |
|
41560 |
|
41561 |
|
41562 |
|
41563 |
|
41564 |
|
41565 |
|
41566 |
|
41567 |
|
41568 |
|
41569 | !arg.returnType || !arg.returnType.typeAnnotation || arg.returnType.typeAnnotation.type !== "TSTypeReference") && (arg.body.type === "BlockStatement" || arg.body.type === "ArrowFunctionExpression" || arg.body.type === "ObjectExpression" || arg.body.type === "ArrayExpression" || arg.body.type === "CallExpression" || arg.body.type === "OptionalCallExpression" || arg.body.type === "ConditionalExpression" || isJSXNode$1(arg.body));
|
41570 | }
|
41571 |
|
41572 | function shouldGroupLastArg(args) {
|
41573 | const lastArg = getLast$2(args);
|
41574 | const penultimateArg = getPenultimate$1(args);
|
41575 | return !hasLeadingComment$3(lastArg) && !hasTrailingComment$1(lastArg) && couldGroupArg(lastArg) && (
|
41576 |
|
41577 | !penultimateArg || penultimateArg.type !== lastArg.type);
|
41578 | }
|
41579 |
|
41580 | function shouldGroupFirstArg(args) {
|
41581 | if (args.length !== 2) {
|
41582 | return false;
|
41583 | }
|
41584 |
|
41585 | const [firstArg, secondArg] = args;
|
41586 | return (!firstArg.comments || !firstArg.comments.length) && (firstArg.type === "FunctionExpression" || firstArg.type === "ArrowFunctionExpression" && firstArg.body.type === "BlockStatement") && secondArg.type !== "FunctionExpression" && secondArg.type !== "ArrowFunctionExpression" && secondArg.type !== "ConditionalExpression" && !couldGroupArg(secondArg);
|
41587 | }
|
41588 |
|
41589 | function printJestEachTemplateLiteral(node, expressions, options) {
|
41590 | |
41591 |
|
41592 |
|
41593 |
|
41594 |
|
41595 |
|
41596 | const headerNames = node.quasis[0].value.raw.trim().split(/\s*\|\s*/);
|
41597 |
|
41598 | if (headerNames.length > 1 || headerNames.some(headerName => headerName.length !== 0)) {
|
41599 | const parts = [];
|
41600 | const stringifiedExpressions = expressions.map(doc => "${" + printDocToString$2(doc, Object.assign({}, options, {
|
41601 | printWidth: Infinity,
|
41602 | endOfLine: "lf"
|
41603 | })).formatted + "}");
|
41604 | const tableBody = [{
|
41605 | hasLineBreak: false,
|
41606 | cells: []
|
41607 | }];
|
41608 |
|
41609 | for (let i = 1; i < node.quasis.length; i++) {
|
41610 | const row = tableBody[tableBody.length - 1];
|
41611 | const correspondingExpression = stringifiedExpressions[i - 1];
|
41612 | row.cells.push(correspondingExpression);
|
41613 |
|
41614 | if (correspondingExpression.includes("\n")) {
|
41615 | row.hasLineBreak = true;
|
41616 | }
|
41617 |
|
41618 | if (node.quasis[i].value.raw.includes("\n")) {
|
41619 | tableBody.push({
|
41620 | hasLineBreak: false,
|
41621 | cells: []
|
41622 | });
|
41623 | }
|
41624 | }
|
41625 |
|
41626 | const maxColumnCount = Math.max(headerNames.length, ...tableBody.map(row => row.cells.length));
|
41627 | const maxColumnWidths = Array.from({
|
41628 | length: maxColumnCount
|
41629 | }).fill(0);
|
41630 | const table = [{
|
41631 | cells: headerNames
|
41632 | }, ...tableBody.filter(row => row.cells.length !== 0)];
|
41633 |
|
41634 | for (const {
|
41635 | cells
|
41636 | } of table.filter(row => !row.hasLineBreak)) {
|
41637 | cells.forEach((cell, index) => {
|
41638 | maxColumnWidths[index] = Math.max(maxColumnWidths[index], getStringWidth$3(cell));
|
41639 | });
|
41640 | }
|
41641 |
|
41642 | parts.push(lineSuffixBoundary$1, "`", indent$3(concat$6([hardline$4, join$4(hardline$4, table.map(row => join$4(" | ", row.cells.map((cell, index) => row.hasLineBreak ? cell : cell + " ".repeat(maxColumnWidths[index] - getStringWidth$3(cell))))))])), hardline$4, "`");
|
41643 | return concat$6(parts);
|
41644 | }
|
41645 | }
|
41646 |
|
41647 | function printArgumentsList(path, options, print) {
|
41648 | const node = path.getValue();
|
41649 | const args = node.arguments;
|
41650 |
|
41651 | if (args.length === 0) {
|
41652 | return concat$6(["(", comments.printDanglingComments(path, options,
|
41653 |
|
41654 | true), ")"]);
|
41655 | }
|
41656 |
|
41657 |
|
41658 | if (args.length === 2 && args[0].type === "ArrowFunctionExpression" && args[0].params.length === 0 && args[0].body.type === "BlockStatement" && args[1].type === "ArrayExpression" && !args.find(arg => arg.comments)) {
|
41659 | return concat$6(["(", path.call(print, "arguments", 0), ", ", path.call(print, "arguments", 1), ")"]);
|
41660 | }
|
41661 |
|
41662 |
|
41663 |
|
41664 |
|
41665 |
|
41666 |
|
41667 |
|
41668 | function shouldBreakForArrowFunctionInArguments(arg, argPath) {
|
41669 | if (!arg || arg.type !== "ArrowFunctionExpression" || !arg.body || arg.body.type !== "BlockStatement" || !arg.params || arg.params.length < 1) {
|
41670 | return false;
|
41671 | }
|
41672 |
|
41673 | let shouldBreak = false;
|
41674 | argPath.each(paramPath => {
|
41675 | const printed = concat$6([print(paramPath)]);
|
41676 | shouldBreak = shouldBreak || willBreak$1(printed);
|
41677 | }, "params");
|
41678 | return shouldBreak;
|
41679 | }
|
41680 |
|
41681 | let anyArgEmptyLine = false;
|
41682 | let shouldBreakForArrowFunction = false;
|
41683 | let hasEmptyLineFollowingFirstArg = false;
|
41684 | const lastArgIndex = args.length - 1;
|
41685 | const printedArguments = path.map((argPath, index) => {
|
41686 | const arg = argPath.getNode();
|
41687 | const parts = [print(argPath)];
|
41688 |
|
41689 | if (index === lastArgIndex) ; else if (isNextLineEmpty$2(options.originalText, arg, options.locEnd)) {
|
41690 | if (index === 0) {
|
41691 | hasEmptyLineFollowingFirstArg = true;
|
41692 | }
|
41693 |
|
41694 | anyArgEmptyLine = true;
|
41695 | parts.push(",", hardline$4, hardline$4);
|
41696 | } else {
|
41697 | parts.push(",", line$4);
|
41698 | }
|
41699 |
|
41700 | shouldBreakForArrowFunction = shouldBreakForArrowFunctionInArguments(arg, argPath);
|
41701 | return concat$6(parts);
|
41702 | }, "arguments");
|
41703 | const maybeTrailingComma =
|
41704 | !(node.callee && node.callee.type === "Import") && shouldPrintComma(options, "all") ? "," : "";
|
41705 |
|
41706 | function allArgsBrokenOut() {
|
41707 | return group$2(concat$6(["(", indent$3(concat$6([line$4, concat$6(printedArguments)])), maybeTrailingComma, line$4, ")"]), {
|
41708 | shouldBreak: true
|
41709 | });
|
41710 | }
|
41711 |
|
41712 | if (path.getParentNode().type !== "Decorator" && isFunctionCompositionArgs$1(args)) {
|
41713 | return allArgsBrokenOut();
|
41714 | }
|
41715 |
|
41716 | const shouldGroupFirst = shouldGroupFirstArg(args);
|
41717 | const shouldGroupLast = shouldGroupLastArg(args);
|
41718 |
|
41719 | if (shouldGroupFirst || shouldGroupLast) {
|
41720 | const shouldBreak = (shouldGroupFirst ? printedArguments.slice(1).some(willBreak$1) : printedArguments.slice(0, -1).some(willBreak$1)) || anyArgEmptyLine || shouldBreakForArrowFunction;
|
41721 |
|
41722 | let printedExpanded;
|
41723 | let i = 0;
|
41724 | path.each(argPath => {
|
41725 | if (shouldGroupFirst && i === 0) {
|
41726 | printedExpanded = [concat$6([argPath.call(p => print(p, {
|
41727 | expandFirstArg: true
|
41728 | })), printedArguments.length > 1 ? "," : "", hasEmptyLineFollowingFirstArg ? hardline$4 : line$4, hasEmptyLineFollowingFirstArg ? hardline$4 : ""])].concat(printedArguments.slice(1));
|
41729 | }
|
41730 |
|
41731 | if (shouldGroupLast && i === args.length - 1) {
|
41732 | printedExpanded = printedArguments.slice(0, -1).concat(argPath.call(p => print(p, {
|
41733 | expandLastArg: true
|
41734 | })));
|
41735 | }
|
41736 |
|
41737 | i++;
|
41738 | }, "arguments");
|
41739 | const somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
|
41740 | const simpleConcat = concat$6(["(", concat$6(printedExpanded), ")"]);
|
41741 | return concat$6([somePrintedArgumentsWillBreak ? breakParent$2 : "", conditionalGroup$1([!somePrintedArgumentsWillBreak && !node.typeArguments && !node.typeParameters ? simpleConcat : ifBreak$1(allArgsBrokenOut(), simpleConcat), shouldGroupFirst ? concat$6(["(", group$2(printedExpanded[0], {
|
41742 | shouldBreak: true
|
41743 | }), concat$6(printedExpanded.slice(1)), ")"]) : concat$6(["(", concat$6(printedArguments.slice(0, -1)), group$2(getLast$2(printedExpanded), {
|
41744 | shouldBreak: true
|
41745 | }), ")"]), allArgsBrokenOut()], {
|
41746 | shouldBreak
|
41747 | })]);
|
41748 | }
|
41749 |
|
41750 | const contents = concat$6(["(", indent$3(concat$6([softline$2, concat$6(printedArguments)])), ifBreak$1(maybeTrailingComma), softline$2, ")"]);
|
41751 |
|
41752 | if (isLongCurriedCallExpression$1(path)) {
|
41753 |
|
41754 |
|
41755 | return contents;
|
41756 | }
|
41757 |
|
41758 | return group$2(contents, {
|
41759 | shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine
|
41760 | });
|
41761 | }
|
41762 |
|
41763 | function printTypeAnnotation(path, options, print) {
|
41764 | const node = path.getValue();
|
41765 |
|
41766 | if (!node.typeAnnotation) {
|
41767 | return "";
|
41768 | }
|
41769 |
|
41770 | const parentNode = path.getParentNode();
|
41771 | const isDefinite = node.definite || parentNode && parentNode.type === "VariableDeclarator" && parentNode.definite;
|
41772 | const isFunctionDeclarationIdentifier = parentNode.type === "DeclareFunction" && parentNode.id === node;
|
41773 |
|
41774 | if (isFlowAnnotationComment$1(options.originalText, node.typeAnnotation, options)) {
|
41775 | return concat$6([" /*: ", path.call(print, "typeAnnotation"), " */"]);
|
41776 | }
|
41777 |
|
41778 | return concat$6([isFunctionDeclarationIdentifier ? "" : isDefinite ? "!: " : ": ", path.call(print, "typeAnnotation")]);
|
41779 | }
|
41780 |
|
41781 | function printFunctionTypeParameters(path, options, print) {
|
41782 | const fun = path.getValue();
|
41783 |
|
41784 | if (fun.typeArguments) {
|
41785 | return path.call(print, "typeArguments");
|
41786 | }
|
41787 |
|
41788 | if (fun.typeParameters) {
|
41789 | return path.call(print, "typeParameters");
|
41790 | }
|
41791 |
|
41792 | return "";
|
41793 | }
|
41794 |
|
41795 | function printFunctionParams(path, print, options, expandArg, printTypeParams) {
|
41796 | const fun = path.getValue();
|
41797 | const parent = path.getParentNode();
|
41798 | const paramsField = fun.parameters ? "parameters" : "params";
|
41799 | const isParametersInTestCall = isTestCall$1(parent);
|
41800 | const shouldHugParameters = shouldHugArguments(fun);
|
41801 | const shouldExpandParameters = expandArg && !(fun[paramsField] && fun[paramsField].some(n => n.comments));
|
41802 | const typeParams = printTypeParams ? printFunctionTypeParameters(path, options, print) : "";
|
41803 | let printed = [];
|
41804 |
|
41805 | if (fun[paramsField]) {
|
41806 | const lastArgIndex = fun[paramsField].length - 1;
|
41807 | printed = path.map((childPath, index) => {
|
41808 | const parts = [];
|
41809 | const param = childPath.getValue();
|
41810 | parts.push(print(childPath));
|
41811 |
|
41812 | if (index === lastArgIndex) {
|
41813 | if (fun.rest) {
|
41814 | parts.push(",", line$4);
|
41815 | }
|
41816 | } else if (isParametersInTestCall || shouldHugParameters || shouldExpandParameters) {
|
41817 | parts.push(", ");
|
41818 | } else if (isNextLineEmpty$2(options.originalText, param, options.locEnd)) {
|
41819 | parts.push(",", hardline$4, hardline$4);
|
41820 | } else {
|
41821 | parts.push(",", line$4);
|
41822 | }
|
41823 |
|
41824 | return concat$6(parts);
|
41825 | }, paramsField);
|
41826 | }
|
41827 |
|
41828 | if (fun.rest) {
|
41829 | printed.push(concat$6(["...", path.call(print, "rest")]));
|
41830 | }
|
41831 |
|
41832 | if (printed.length === 0) {
|
41833 | return concat$6([typeParams, "(", comments.printDanglingComments(path, options,
|
41834 |
|
41835 | true, comment => getNextNonSpaceNonCommentCharacter$1(options.originalText, comment, options.locEnd) === ")"), ")"]);
|
41836 | }
|
41837 |
|
41838 | const lastParam = getLast$2(fun[paramsField]);
|
41839 |
|
41840 |
|
41841 |
|
41842 |
|
41843 |
|
41844 |
|
41845 |
|
41846 |
|
41847 |
|
41848 |
|
41849 | if (shouldExpandParameters) {
|
41850 | return group$2(concat$6([removeLines$1(typeParams), "(", concat$6(printed.map(removeLines$1)), ")"]));
|
41851 | }
|
41852 |
|
41853 |
|
41854 |
|
41855 |
|
41856 |
|
41857 |
|
41858 |
|
41859 |
|
41860 | const hasNotParameterDecorator = fun[paramsField].every(param => !param.decorators);
|
41861 |
|
41862 | if (shouldHugParameters && hasNotParameterDecorator) {
|
41863 | return concat$6([typeParams, "(", concat$6(printed), ")"]);
|
41864 | }
|
41865 |
|
41866 |
|
41867 | if (isParametersInTestCall) {
|
41868 | return concat$6([typeParams, "(", concat$6(printed), ")"]);
|
41869 | }
|
41870 |
|
41871 | const isFlowShorthandWithOneArg = (isObjectTypePropertyAFunction$1(parent, options) || isTypeAnnotationAFunction$1(parent, options) || parent.type === "TypeAlias" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || parent.type === "IntersectionTypeAnnotation" || parent.type === "FunctionTypeAnnotation" && parent.returnType === fun) && fun[paramsField].length === 1 && fun[paramsField][0].name === null && fun[paramsField][0].typeAnnotation && fun.typeParameters === null && isSimpleFlowType$1(fun[paramsField][0].typeAnnotation) && !fun.rest;
|
41872 |
|
41873 | if (isFlowShorthandWithOneArg) {
|
41874 | if (options.arrowParens === "always") {
|
41875 | return concat$6(["(", concat$6(printed), ")"]);
|
41876 | }
|
41877 |
|
41878 | return concat$6(printed);
|
41879 | }
|
41880 |
|
41881 | const canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
|
41882 | return concat$6([typeParams, "(", indent$3(concat$6([softline$2, concat$6(printed)])), ifBreak$1(canHaveTrailingComma && shouldPrintComma(options, "all") ? "," : ""), softline$2, ")"]);
|
41883 | }
|
41884 |
|
41885 | function shouldPrintParamsWithoutParens(path, options) {
|
41886 | if (options.arrowParens === "always") {
|
41887 | return false;
|
41888 | }
|
41889 |
|
41890 | if (options.arrowParens === "avoid") {
|
41891 | const node = path.getValue();
|
41892 | return canPrintParamsWithoutParens(node);
|
41893 | }
|
41894 |
|
41895 |
|
41896 | return false;
|
41897 | }
|
41898 |
|
41899 | function canPrintParamsWithoutParens(node) {
|
41900 | return node.params.length === 1 && !node.rest && !node.typeParameters && !hasDanglingComments$1(node) && node.params[0].type === "Identifier" && !node.params[0].typeAnnotation && !node.params[0].comments && !node.params[0].optional && !node.predicate && !node.returnType;
|
41901 | }
|
41902 |
|
41903 | function printFunctionDeclaration(path, print, options) {
|
41904 | const n = path.getValue();
|
41905 | const parts = [];
|
41906 |
|
41907 | if (n.async) {
|
41908 | parts.push("async ");
|
41909 | }
|
41910 |
|
41911 | if (n.generator) {
|
41912 | parts.push("function* ");
|
41913 | } else {
|
41914 | parts.push("function ");
|
41915 | }
|
41916 |
|
41917 | if (n.id) {
|
41918 | parts.push(path.call(print, "id"));
|
41919 | }
|
41920 |
|
41921 | parts.push(printFunctionTypeParameters(path, options, print), group$2(concat$6([printFunctionParams(path, print, options), printReturnType(path, print, options)])), n.body ? " " : "", path.call(print, "body"));
|
41922 | return concat$6(parts);
|
41923 | }
|
41924 |
|
41925 | function printReturnType(path, print, options) {
|
41926 | const n = path.getValue();
|
41927 | const returnType = path.call(print, "returnType");
|
41928 |
|
41929 | if (n.returnType && isFlowAnnotationComment$1(options.originalText, n.returnType, options)) {
|
41930 | return concat$6([" /*: ", returnType, " */"]);
|
41931 | }
|
41932 |
|
41933 | const parts = [returnType];
|
41934 |
|
41935 | if (n.returnType && n.returnType.typeAnnotation) {
|
41936 | parts.unshift(": ");
|
41937 | }
|
41938 |
|
41939 | if (n.predicate) {
|
41940 |
|
41941 |
|
41942 | parts.push(n.returnType ? " " : ": ", path.call(print, "predicate"));
|
41943 | }
|
41944 |
|
41945 | return concat$6(parts);
|
41946 | }
|
41947 |
|
41948 | function printExportDeclaration(path, options, print) {
|
41949 | const decl = path.getValue();
|
41950 | const semi = options.semi ? ";" : "";
|
41951 | const parts = ["export "];
|
41952 | const isDefault = decl.default || decl.type === "ExportDefaultDeclaration";
|
41953 |
|
41954 | if (isDefault) {
|
41955 | parts.push("default ");
|
41956 | }
|
41957 |
|
41958 | parts.push(comments.printDanglingComments(path, options,
|
41959 |
|
41960 | true));
|
41961 |
|
41962 | if (needsHardlineAfterDanglingComment$1(decl)) {
|
41963 | parts.push(hardline$4);
|
41964 | }
|
41965 |
|
41966 | if (decl.declaration) {
|
41967 | parts.push(path.call(print, "declaration"));
|
41968 |
|
41969 | if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "TSInterfaceDeclaration" && decl.declaration.type !== "DeclareClass" && decl.declaration.type !== "DeclareFunction" && decl.declaration.type !== "TSDeclareFunction") {
|
41970 | parts.push(semi);
|
41971 | }
|
41972 | } else {
|
41973 | if (decl.specifiers && decl.specifiers.length > 0) {
|
41974 | const specifiers = [];
|
41975 | const defaultSpecifiers = [];
|
41976 | const namespaceSpecifiers = [];
|
41977 | path.each(specifierPath => {
|
41978 | const specifierType = path.getValue().type;
|
41979 |
|
41980 | if (specifierType === "ExportSpecifier") {
|
41981 | specifiers.push(print(specifierPath));
|
41982 | } else if (specifierType === "ExportDefaultSpecifier") {
|
41983 | defaultSpecifiers.push(print(specifierPath));
|
41984 | } else if (specifierType === "ExportNamespaceSpecifier") {
|
41985 | namespaceSpecifiers.push(concat$6(["* as ", print(specifierPath)]));
|
41986 | }
|
41987 | }, "specifiers");
|
41988 | const isNamespaceFollowed = namespaceSpecifiers.length !== 0 && specifiers.length !== 0;
|
41989 | const isDefaultFollowed = defaultSpecifiers.length !== 0 && (namespaceSpecifiers.length !== 0 || specifiers.length !== 0);
|
41990 | const canBreak = specifiers.length > 1 || defaultSpecifiers.length > 0 || decl.specifiers && decl.specifiers.some(node => node.comments);
|
41991 | let printed = "";
|
41992 |
|
41993 | if (specifiers.length !== 0) {
|
41994 | if (canBreak) {
|
41995 | printed = group$2(concat$6(["{", indent$3(concat$6([options.bracketSpacing ? line$4 : softline$2, join$4(concat$6([",", line$4]), specifiers)])), ifBreak$1(shouldPrintComma(options) ? "," : ""), options.bracketSpacing ? line$4 : softline$2, "}"]));
|
41996 | } else {
|
41997 | printed = concat$6(["{", options.bracketSpacing ? " " : "", concat$6(specifiers), options.bracketSpacing ? " " : "", "}"]);
|
41998 | }
|
41999 | }
|
42000 |
|
42001 | parts.push(decl.exportKind === "type" ? "type " : "", concat$6(defaultSpecifiers), concat$6([isDefaultFollowed ? ", " : ""]), concat$6(namespaceSpecifiers), concat$6([isNamespaceFollowed ? ", " : ""]), printed);
|
42002 | } else {
|
42003 | parts.push("{}");
|
42004 | }
|
42005 |
|
42006 | if (decl.source) {
|
42007 | parts.push(" from ", path.call(print, "source"));
|
42008 | }
|
42009 |
|
42010 | parts.push(semi);
|
42011 | }
|
42012 |
|
42013 | return concat$6(parts);
|
42014 | }
|
42015 |
|
42016 | function printFlowDeclaration(path, parts) {
|
42017 | const parentExportDecl = getParentExportDeclaration$1(path);
|
42018 |
|
42019 | if (parentExportDecl) {
|
42020 | assert$1.strictEqual(parentExportDecl.type, "DeclareExportDeclaration");
|
42021 | } else {
|
42022 |
|
42023 |
|
42024 |
|
42025 | parts.unshift("declare ");
|
42026 | }
|
42027 |
|
42028 | return concat$6(parts);
|
42029 | }
|
42030 |
|
42031 | function printTypeScriptModifiers(path, options, print) {
|
42032 | const n = path.getValue();
|
42033 |
|
42034 | if (!n.modifiers || !n.modifiers.length) {
|
42035 | return "";
|
42036 | }
|
42037 |
|
42038 | return concat$6([join$4(" ", path.map(print, "modifiers")), " "]);
|
42039 | }
|
42040 |
|
42041 | function printTypeParameters(path, options, print, paramsKey) {
|
42042 | const n = path.getValue();
|
42043 |
|
42044 | if (!n[paramsKey]) {
|
42045 | return "";
|
42046 | }
|
42047 |
|
42048 |
|
42049 | if (!Array.isArray(n[paramsKey])) {
|
42050 | return path.call(print, paramsKey);
|
42051 | }
|
42052 |
|
42053 | const grandparent = path.getNode(2);
|
42054 | const greatGrandParent = path.getNode(3);
|
42055 | const greatGreatGrandParent = path.getNode(4);
|
42056 | const isParameterInTestCall = grandparent != null && isTestCall$1(grandparent);
|
42057 | const shouldInline = isParameterInTestCall || n[paramsKey].length === 0 || n[paramsKey].length === 1 && (shouldHugType(n[paramsKey][0]) || n[paramsKey][0].type === "GenericTypeAnnotation" && shouldHugType(n[paramsKey][0].id) || n[paramsKey][0].type === "TSTypeReference" && shouldHugType(n[paramsKey][0].typeName) || n[paramsKey][0].type === "NullableTypeAnnotation" ||
|
42058 | greatGreatGrandParent && greatGreatGrandParent.type === "VariableDeclarator" && grandparent.type === "TSTypeAnnotation" && greatGrandParent.type !== "ArrowFunctionExpression" && n[paramsKey][0].type !== "TSUnionType" && n[paramsKey][0].type !== "UnionTypeAnnotation" && n[paramsKey][0].type !== "TSIntersectionType" && n[paramsKey][0].type !== "IntersectionTypeAnnotation" && n[paramsKey][0].type !== "TSConditionalType" && n[paramsKey][0].type !== "TSMappedType" && n[paramsKey][0].type !== "TSTypeOperator" && n[paramsKey][0].type !== "TSIndexedAccessType" && n[paramsKey][0].type !== "TSArrayType");
|
42059 |
|
42060 | function printDanglingCommentsForInline(n) {
|
42061 | if (!hasDanglingComments$1(n)) {
|
42062 | return "";
|
42063 | }
|
42064 |
|
42065 | const hasOnlyBlockComments = n.comments.every(comments$1.isBlockComment);
|
42066 | const printed = comments.printDanglingComments(path, options,
|
42067 |
|
42068 | hasOnlyBlockComments);
|
42069 |
|
42070 | if (hasOnlyBlockComments) {
|
42071 | return printed;
|
42072 | }
|
42073 |
|
42074 | return concat$6([printed, hardline$4]);
|
42075 | }
|
42076 |
|
42077 | if (shouldInline) {
|
42078 | return concat$6(["<", join$4(", ", path.map(print, paramsKey)), printDanglingCommentsForInline(n), ">"]);
|
42079 | }
|
42080 |
|
42081 | return group$2(concat$6(["<", indent$3(concat$6([softline$2, join$4(concat$6([",", line$4]), path.map(print, paramsKey))])), ifBreak$1(options.parser !== "typescript" && options.parser !== "babel-ts" && shouldPrintComma(options, "all") ? "," : ""), softline$2, ">"]));
|
42082 | }
|
42083 |
|
42084 | function printClass(path, options, print) {
|
42085 | const n = path.getValue();
|
42086 | const parts = [];
|
42087 |
|
42088 | if (n.abstract) {
|
42089 | parts.push("abstract ");
|
42090 | }
|
42091 |
|
42092 | parts.push("class");
|
42093 |
|
42094 | if (n.id) {
|
42095 | parts.push(" ", path.call(print, "id"));
|
42096 | }
|
42097 |
|
42098 | parts.push(path.call(print, "typeParameters"));
|
42099 | const partsGroup = [];
|
42100 |
|
42101 | if (n.superClass) {
|
42102 | const printed = concat$6(["extends ", path.call(print, "superClass"), path.call(print, "superTypeParameters")]);
|
42103 |
|
42104 |
|
42105 | if ((!n.implements || n.implements.length === 0) && (!n.superClass.comments || n.superClass.comments.length === 0)) {
|
42106 | parts.push(concat$6([" ", path.call(superClass => comments.printComments(superClass, () => printed, options), "superClass")]));
|
42107 | } else {
|
42108 | partsGroup.push(group$2(concat$6([line$4, path.call(superClass => comments.printComments(superClass, () => printed, options), "superClass")])));
|
42109 | }
|
42110 | } else if (n.extends && n.extends.length > 0) {
|
42111 | parts.push(" extends ", join$4(", ", path.map(print, "extends")));
|
42112 | }
|
42113 |
|
42114 | if (n.mixins && n.mixins.length > 0) {
|
42115 | partsGroup.push(line$4, "mixins ", group$2(indent$3(join$4(concat$6([",", line$4]), path.map(print, "mixins")))));
|
42116 | }
|
42117 |
|
42118 | if (n.implements && n.implements.length > 0) {
|
42119 | partsGroup.push(line$4, "implements", group$2(indent$3(concat$6([line$4, join$4(concat$6([",", line$4]), path.map(print, "implements"))]))));
|
42120 | }
|
42121 |
|
42122 | if (partsGroup.length > 0) {
|
42123 | parts.push(group$2(indent$3(concat$6(partsGroup))));
|
42124 | }
|
42125 |
|
42126 | if (n.body && n.body.comments && hasLeadingOwnLineComment$1(options.originalText, n.body, options)) {
|
42127 | parts.push(hardline$4);
|
42128 | } else {
|
42129 | parts.push(" ");
|
42130 | }
|
42131 |
|
42132 | parts.push(path.call(print, "body"));
|
42133 | return parts;
|
42134 | }
|
42135 |
|
42136 | function printOptionalToken(path) {
|
42137 | const node = path.getValue();
|
42138 |
|
42139 | if (!node.optional ||
|
42140 |
|
42141 | node.type === "Identifier" && node === path.getParentNode().key) {
|
42142 | return "";
|
42143 | }
|
42144 |
|
42145 | if (node.type === "OptionalCallExpression" || node.type === "OptionalMemberExpression" && node.computed) {
|
42146 | return "?.";
|
42147 | }
|
42148 |
|
42149 | return "?";
|
42150 | }
|
42151 |
|
42152 | function printMemberLookup(path, options, print) {
|
42153 | const property = path.call(print, "property");
|
42154 | const n = path.getValue();
|
42155 | const optional = printOptionalToken(path);
|
42156 |
|
42157 | if (!n.computed) {
|
42158 | return concat$6([optional, ".", property]);
|
42159 | }
|
42160 |
|
42161 | if (!n.property || isNumericLiteral$1(n.property)) {
|
42162 | return concat$6([optional, "[", property, "]"]);
|
42163 | }
|
42164 |
|
42165 | return group$2(concat$6([optional, "[", indent$3(concat$6([softline$2, property])), softline$2, "]"]));
|
42166 | }
|
42167 |
|
42168 | function printBindExpressionCallee(path, options, print) {
|
42169 | return concat$6(["::", path.call(print, "callee")]);
|
42170 | }
|
42171 |
|
42172 |
|
42173 |
|
42174 |
|
42175 |
|
42176 |
|
42177 |
|
42178 |
|
42179 |
|
42180 |
|
42181 |
|
42182 |
|
42183 | function printMemberChain(path, options, print) {
|
42184 |
|
42185 |
|
42186 |
|
42187 |
|
42188 |
|
42189 |
|
42190 |
|
42191 | const printedNodes = [];
|
42192 |
|
42193 |
|
42194 | function shouldInsertEmptyLineAfter(node) {
|
42195 | const {
|
42196 | originalText
|
42197 | } = options;
|
42198 | const nextCharIndex = getNextNonSpaceNonCommentCharacterIndex$3(originalText, node, options.locEnd);
|
42199 | const nextChar = originalText.charAt(nextCharIndex);
|
42200 |
|
42201 |
|
42202 | if (nextChar === ")") {
|
42203 | return isNextLineEmptyAfterIndex$2(originalText, nextCharIndex + 1, options.locEnd);
|
42204 | }
|
42205 |
|
42206 | return isNextLineEmpty$2(originalText, node, options.locEnd);
|
42207 | }
|
42208 |
|
42209 | function rec(path) {
|
42210 | const node = path.getValue();
|
42211 |
|
42212 | if ((node.type === "CallExpression" || node.type === "OptionalCallExpression") && (isMemberish$1(node.callee) || node.callee.type === "CallExpression" || node.callee.type === "OptionalCallExpression")) {
|
42213 | printedNodes.unshift({
|
42214 | node,
|
42215 | printed: concat$6([comments.printComments(path, () => concat$6([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)]), options), shouldInsertEmptyLineAfter(node) ? hardline$4 : ""])
|
42216 | });
|
42217 | path.call(callee => rec(callee), "callee");
|
42218 | } else if (isMemberish$1(node)) {
|
42219 | printedNodes.unshift({
|
42220 | node,
|
42221 | needsParens: needsParens_1(path, options),
|
42222 | printed: comments.printComments(path, () => node.type === "OptionalMemberExpression" || node.type === "MemberExpression" ? printMemberLookup(path, options, print) : printBindExpressionCallee(path, options, print), options)
|
42223 | });
|
42224 | path.call(object => rec(object), "object");
|
42225 | } else if (node.type === "TSNonNullExpression") {
|
42226 | printedNodes.unshift({
|
42227 | node,
|
42228 | printed: comments.printComments(path, () => "!", options)
|
42229 | });
|
42230 | path.call(expression => rec(expression), "expression");
|
42231 | } else {
|
42232 | printedNodes.unshift({
|
42233 | node,
|
42234 | printed: path.call(print)
|
42235 | });
|
42236 | }
|
42237 | }
|
42238 |
|
42239 |
|
42240 |
|
42241 |
|
42242 | const node = path.getValue();
|
42243 | printedNodes.unshift({
|
42244 | node,
|
42245 | printed: concat$6([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)])
|
42246 | });
|
42247 | path.call(callee => rec(callee), "callee");
|
42248 |
|
42249 |
|
42250 |
|
42251 |
|
42252 |
|
42253 |
|
42254 |
|
42255 |
|
42256 |
|
42257 |
|
42258 |
|
42259 |
|
42260 |
|
42261 |
|
42262 |
|
42263 |
|
42264 |
|
42265 |
|
42266 |
|
42267 |
|
42268 |
|
42269 |
|
42270 |
|
42271 | const groups = [];
|
42272 | let currentGroup = [printedNodes[0]];
|
42273 | let i = 1;
|
42274 |
|
42275 | for (; i < printedNodes.length; ++i) {
|
42276 | if (printedNodes[i].node.type === "TSNonNullExpression" || printedNodes[i].node.type === "OptionalCallExpression" || printedNodes[i].node.type === "CallExpression" || (printedNodes[i].node.type === "MemberExpression" || printedNodes[i].node.type === "OptionalMemberExpression") && printedNodes[i].node.computed && isNumericLiteral$1(printedNodes[i].node.property)) {
|
42277 | currentGroup.push(printedNodes[i]);
|
42278 | } else {
|
42279 | break;
|
42280 | }
|
42281 | }
|
42282 |
|
42283 | if (printedNodes[0].node.type !== "CallExpression" && printedNodes[0].node.type !== "OptionalCallExpression") {
|
42284 | for (; i + 1 < printedNodes.length; ++i) {
|
42285 | if (isMemberish$1(printedNodes[i].node) && isMemberish$1(printedNodes[i + 1].node)) {
|
42286 | currentGroup.push(printedNodes[i]);
|
42287 | } else {
|
42288 | break;
|
42289 | }
|
42290 | }
|
42291 | }
|
42292 |
|
42293 | groups.push(currentGroup);
|
42294 | currentGroup = [];
|
42295 |
|
42296 |
|
42297 |
|
42298 |
|
42299 | let hasSeenCallExpression = false;
|
42300 |
|
42301 | for (; i < printedNodes.length; ++i) {
|
42302 | if (hasSeenCallExpression && isMemberish$1(printedNodes[i].node)) {
|
42303 |
|
42304 |
|
42305 | if (printedNodes[i].node.computed && isNumericLiteral$1(printedNodes[i].node.property)) {
|
42306 | currentGroup.push(printedNodes[i]);
|
42307 | continue;
|
42308 | }
|
42309 |
|
42310 | groups.push(currentGroup);
|
42311 | currentGroup = [];
|
42312 | hasSeenCallExpression = false;
|
42313 | }
|
42314 |
|
42315 | if (printedNodes[i].node.type === "CallExpression" || printedNodes[i].node.type === "OptionalCallExpression") {
|
42316 | hasSeenCallExpression = true;
|
42317 | }
|
42318 |
|
42319 | currentGroup.push(printedNodes[i]);
|
42320 |
|
42321 | if (printedNodes[i].node.comments && printedNodes[i].node.comments.some(comment => comment.trailing)) {
|
42322 | groups.push(currentGroup);
|
42323 | currentGroup = [];
|
42324 | hasSeenCallExpression = false;
|
42325 | }
|
42326 | }
|
42327 |
|
42328 | if (currentGroup.length > 0) {
|
42329 | groups.push(currentGroup);
|
42330 | }
|
42331 |
|
42332 |
|
42333 |
|
42334 |
|
42335 |
|
42336 |
|
42337 |
|
42338 |
|
42339 |
|
42340 |
|
42341 |
|
42342 |
|
42343 |
|
42344 | function isFactory(name) {
|
42345 | return /^[A-Z]|^[_$]+$/.test(name);
|
42346 | }
|
42347 |
|
42348 |
|
42349 |
|
42350 |
|
42351 |
|
42352 |
|
42353 |
|
42354 |
|
42355 | function isShort(name) {
|
42356 | return name.length <= options.tabWidth;
|
42357 | }
|
42358 |
|
42359 | function shouldNotWrap(groups) {
|
42360 | const parent = path.getParentNode();
|
42361 | const isExpression = parent && parent.type === "ExpressionStatement";
|
42362 | const hasComputed = groups[1].length && groups[1][0].node.computed;
|
42363 |
|
42364 | if (groups[0].length === 1) {
|
42365 | const firstNode = groups[0][0].node;
|
42366 | return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed);
|
42367 | }
|
42368 |
|
42369 | const lastNode = getLast$2(groups[0]).node;
|
42370 | return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
|
42371 | }
|
42372 |
|
42373 | const shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups);
|
42374 |
|
42375 | function printGroup(printedGroup) {
|
42376 | const printed = printedGroup.map(tuple => tuple.printed);
|
42377 |
|
42378 |
|
42379 | if (printedGroup.length > 0 && printedGroup[printedGroup.length - 1].needsParens) {
|
42380 | return concat$6(["(", ...printed, ")"]);
|
42381 | }
|
42382 |
|
42383 | return concat$6(printed);
|
42384 | }
|
42385 |
|
42386 | function printIndentedGroup(groups) {
|
42387 | if (groups.length === 0) {
|
42388 | return "";
|
42389 | }
|
42390 |
|
42391 | return indent$3(group$2(concat$6([hardline$4, join$4(hardline$4, groups.map(printGroup))])));
|
42392 | }
|
42393 |
|
42394 | const printedGroups = groups.map(printGroup);
|
42395 | const oneLine = concat$6(printedGroups);
|
42396 | const cutoff = shouldMerge ? 3 : 2;
|
42397 | const flatGroups = groups.reduce((res, group) => res.concat(group), []);
|
42398 | const hasComment = flatGroups.slice(1, -1).some(node => hasLeadingComment$3(node.node)) || flatGroups.slice(0, -1).some(node => hasTrailingComment$1(node.node)) || groups[cutoff] && hasLeadingComment$3(groups[cutoff][0].node);
|
42399 |
|
42400 |
|
42401 | if (groups.length <= cutoff && !hasComment) {
|
42402 | if (isLongCurriedCallExpression$1(path)) {
|
42403 | return oneLine;
|
42404 | }
|
42405 |
|
42406 | return group$2(oneLine);
|
42407 | }
|
42408 |
|
42409 |
|
42410 |
|
42411 | const lastNodeBeforeIndent = getLast$2(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node;
|
42412 | const shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
|
42413 | const expanded = concat$6([printGroup(groups[0]), shouldMerge ? concat$6(groups.slice(1, 2).map(printGroup)) : "", shouldHaveEmptyLineBeforeIndent ? hardline$4 : "", printIndentedGroup(groups.slice(shouldMerge ? 2 : 1))]);
|
42414 | const callExpressions = printedNodes.map(({
|
42415 | node
|
42416 | }) => node).filter(isCallOrOptionalCallExpression$1);
|
42417 |
|
42418 |
|
42419 |
|
42420 |
|
42421 |
|
42422 | if (hasComment || callExpressions.length > 2 && callExpressions.some(expr => !expr.arguments.every(arg => isSimpleCallArgument$1(arg, 0))) || printedGroups.slice(0, -1).some(willBreak$1) ||
|
42423 | |
42424 |
|
42425 |
|
42426 |
|
42427 |
|
42428 | ((lastGroupDoc, lastGroupNode) => isCallOrOptionalCallExpression$1(lastGroupNode) && willBreak$1(lastGroupDoc))(getLast$2(printedGroups), getLast$2(getLast$2(groups)).node) && callExpressions.slice(0, -1).some(n => n.arguments.some(isFunctionOrArrowExpression$1))) {
|
42429 | return group$2(expanded);
|
42430 | }
|
42431 |
|
42432 | return concat$6([
|
42433 |
|
42434 |
|
42435 | willBreak$1(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent$2 : "", conditionalGroup$1([oneLine, expanded])]);
|
42436 | }
|
42437 |
|
42438 | function separatorNoWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
|
42439 | if (isFacebookTranslationTag) {
|
42440 | return "";
|
42441 | }
|
42442 |
|
42443 | if (childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement) {
|
42444 | return child.length === 1 ? softline$2 : hardline$4;
|
42445 | }
|
42446 |
|
42447 | return softline$2;
|
42448 | }
|
42449 |
|
42450 | function separatorWithWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
|
42451 | if (isFacebookTranslationTag) {
|
42452 | return hardline$4;
|
42453 | }
|
42454 |
|
42455 | if (child.length === 1) {
|
42456 | return childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement ? hardline$4 : softline$2;
|
42457 | }
|
42458 |
|
42459 | return hardline$4;
|
42460 | }
|
42461 |
|
42462 |
|
42463 |
|
42464 |
|
42465 |
|
42466 |
|
42467 |
|
42468 |
|
42469 |
|
42470 |
|
42471 |
|
42472 |
|
42473 |
|
42474 | function printJSXChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag) {
|
42475 | const n = path.getValue();
|
42476 | const children = [];
|
42477 |
|
42478 | path.map((childPath, i) => {
|
42479 | const child = childPath.getValue();
|
42480 |
|
42481 | if (isLiteral$1(child)) {
|
42482 | const text = rawText$1(child);
|
42483 |
|
42484 | if (isMeaningfulJSXText$1(child)) {
|
42485 | const words = text.split(matchJsxWhitespaceRegex$1);
|
42486 |
|
42487 | if (words[0] === "") {
|
42488 | children.push("");
|
42489 | words.shift();
|
42490 |
|
42491 | if (/\n/.test(words[0])) {
|
42492 | const next = n.children[i + 1];
|
42493 | children.push(separatorWithWhitespace(isFacebookTranslationTag, words[1], child, next));
|
42494 | } else {
|
42495 | children.push(jsxWhitespace);
|
42496 | }
|
42497 |
|
42498 | words.shift();
|
42499 | }
|
42500 |
|
42501 | let endWhitespace;
|
42502 |
|
42503 | if (getLast$2(words) === "") {
|
42504 | words.pop();
|
42505 | endWhitespace = words.pop();
|
42506 | }
|
42507 |
|
42508 |
|
42509 | if (words.length === 0) {
|
42510 | return;
|
42511 | }
|
42512 |
|
42513 | words.forEach((word, i) => {
|
42514 | if (i % 2 === 1) {
|
42515 | children.push(line$4);
|
42516 | } else {
|
42517 | children.push(word);
|
42518 | }
|
42519 | });
|
42520 |
|
42521 | if (endWhitespace !== undefined) {
|
42522 | if (/\n/.test(endWhitespace)) {
|
42523 | const next = n.children[i + 1];
|
42524 | children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$2(children), child, next));
|
42525 | } else {
|
42526 | children.push(jsxWhitespace);
|
42527 | }
|
42528 | } else {
|
42529 | const next = n.children[i + 1];
|
42530 | children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$2(children), child, next));
|
42531 | }
|
42532 | } else if (/\n/.test(text)) {
|
42533 |
|
42534 |
|
42535 | if (text.match(/\n/g).length > 1) {
|
42536 | children.push("");
|
42537 | children.push(hardline$4);
|
42538 | }
|
42539 | } else {
|
42540 | children.push("");
|
42541 | children.push(jsxWhitespace);
|
42542 | }
|
42543 | } else {
|
42544 | const printedChild = print(childPath);
|
42545 | children.push(printedChild);
|
42546 | const next = n.children[i + 1];
|
42547 | const directlyFollowedByMeaningfulText = next && isMeaningfulJSXText$1(next);
|
42548 |
|
42549 | if (directlyFollowedByMeaningfulText) {
|
42550 | const firstWord = rawText$1(next).trim().split(matchJsxWhitespaceRegex$1)[0];
|
42551 | children.push(separatorNoWhitespace(isFacebookTranslationTag, firstWord, child, next));
|
42552 | } else {
|
42553 | children.push(hardline$4);
|
42554 | }
|
42555 | }
|
42556 | }, "children");
|
42557 | return children;
|
42558 | }
|
42559 |
|
42560 |
|
42561 |
|
42562 |
|
42563 |
|
42564 |
|
42565 |
|
42566 |
|
42567 |
|
42568 |
|
42569 |
|
42570 |
|
42571 |
|
42572 |
|
42573 |
|
42574 |
|
42575 | function printJSXElement(path, options, print) {
|
42576 | const n = path.getValue();
|
42577 |
|
42578 | if (n.type === "JSXElement" && isEmptyJSXElement$1(n)) {
|
42579 | return concat$6([path.call(print, "openingElement"), path.call(print, "closingElement")]);
|
42580 | }
|
42581 |
|
42582 | const openingLines = n.type === "JSXElement" ? path.call(print, "openingElement") : path.call(print, "openingFragment");
|
42583 | const closingLines = n.type === "JSXElement" ? path.call(print, "closingElement") : path.call(print, "closingFragment");
|
42584 |
|
42585 | if (n.children.length === 1 && n.children[0].type === "JSXExpressionContainer" && (n.children[0].expression.type === "TemplateLiteral" || n.children[0].expression.type === "TaggedTemplateExpression")) {
|
42586 | return concat$6([openingLines, concat$6(path.map(print, "children")), closingLines]);
|
42587 | }
|
42588 |
|
42589 |
|
42590 |
|
42591 |
|
42592 | n.children = n.children.map(child => {
|
42593 | if (isJSXWhitespaceExpression$1(child)) {
|
42594 | return {
|
42595 | type: "JSXText",
|
42596 | value: " ",
|
42597 | raw: " "
|
42598 | };
|
42599 | }
|
42600 |
|
42601 | return child;
|
42602 | });
|
42603 | const containsTag = n.children.filter(isJSXNode$1).length > 0;
|
42604 | const containsMultipleExpressions = n.children.filter(child => child.type === "JSXExpressionContainer").length > 1;
|
42605 | const containsMultipleAttributes = n.type === "JSXElement" && n.openingElement.attributes.length > 1;
|
42606 |
|
42607 | let forcedBreak = willBreak$1(openingLines) || containsTag || containsMultipleAttributes || containsMultipleExpressions;
|
42608 | const isMdxBlock = path.getParentNode().rootMarker === "mdx";
|
42609 | const rawJsxWhitespace = options.singleQuote ? "{' '}" : '{" "}';
|
42610 | const jsxWhitespace = isMdxBlock ? concat$6([" "]) : ifBreak$1(concat$6([rawJsxWhitespace, softline$2]), " ");
|
42611 | const isFacebookTranslationTag = n.openingElement && n.openingElement.name && n.openingElement.name.name === "fbt";
|
42612 | const children = printJSXChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag);
|
42613 | const containsText = n.children.some(child => isMeaningfulJSXText$1(child));
|
42614 |
|
42615 |
|
42616 |
|
42617 |
|
42618 | for (let i = children.length - 2; i >= 0; i--) {
|
42619 | const isPairOfEmptyStrings = children[i] === "" && children[i + 1] === "";
|
42620 | const isPairOfHardlines = children[i] === hardline$4 && children[i + 1] === "" && children[i + 2] === hardline$4;
|
42621 | const isLineFollowedByJSXWhitespace = (children[i] === softline$2 || children[i] === hardline$4) && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
|
42622 | const isJSXWhitespaceFollowedByLine = children[i] === jsxWhitespace && children[i + 1] === "" && (children[i + 2] === softline$2 || children[i + 2] === hardline$4);
|
42623 | const isDoubleJSXWhitespace = children[i] === jsxWhitespace && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
|
42624 | const isPairOfHardOrSoftLines = children[i] === softline$2 && children[i + 1] === "" && children[i + 2] === hardline$4 || children[i] === hardline$4 && children[i + 1] === "" && children[i + 2] === softline$2;
|
42625 |
|
42626 | if (isPairOfHardlines && containsText || isPairOfEmptyStrings || isLineFollowedByJSXWhitespace || isDoubleJSXWhitespace || isPairOfHardOrSoftLines) {
|
42627 | children.splice(i, 2);
|
42628 | } else if (isJSXWhitespaceFollowedByLine) {
|
42629 | children.splice(i + 1, 2);
|
42630 | }
|
42631 | }
|
42632 |
|
42633 |
|
42634 | while (children.length && (isLineNext$1(getLast$2(children)) || isEmpty$1(getLast$2(children)))) {
|
42635 | children.pop();
|
42636 | }
|
42637 |
|
42638 |
|
42639 | while (children.length && (isLineNext$1(children[0]) || isEmpty$1(children[0])) && (isLineNext$1(children[1]) || isEmpty$1(children[1]))) {
|
42640 | children.shift();
|
42641 | children.shift();
|
42642 | }
|
42643 |
|
42644 |
|
42645 |
|
42646 | const multilineChildren = [];
|
42647 | children.forEach((child, i) => {
|
42648 |
|
42649 |
|
42650 | if (child === jsxWhitespace) {
|
42651 | if (i === 1 && children[i - 1] === "") {
|
42652 | if (children.length === 2) {
|
42653 |
|
42654 | multilineChildren.push(rawJsxWhitespace);
|
42655 | return;
|
42656 | }
|
42657 |
|
42658 |
|
42659 | multilineChildren.push(concat$6([rawJsxWhitespace, hardline$4]));
|
42660 | return;
|
42661 | } else if (i === children.length - 1) {
|
42662 |
|
42663 | multilineChildren.push(rawJsxWhitespace);
|
42664 | return;
|
42665 | } else if (children[i - 1] === "" && children[i - 2] === hardline$4) {
|
42666 |
|
42667 | multilineChildren.push(rawJsxWhitespace);
|
42668 | return;
|
42669 | }
|
42670 | }
|
42671 |
|
42672 | multilineChildren.push(child);
|
42673 |
|
42674 | if (willBreak$1(child)) {
|
42675 | forcedBreak = true;
|
42676 | }
|
42677 | });
|
42678 |
|
42679 |
|
42680 |
|
42681 | const content = containsText ? fill$3(multilineChildren) : group$2(concat$6(multilineChildren), {
|
42682 | shouldBreak: true
|
42683 | });
|
42684 |
|
42685 | if (isMdxBlock) {
|
42686 | return content;
|
42687 | }
|
42688 |
|
42689 | const multiLineElem = group$2(concat$6([openingLines, indent$3(concat$6([hardline$4, content])), hardline$4, closingLines]));
|
42690 |
|
42691 | if (forcedBreak) {
|
42692 | return multiLineElem;
|
42693 | }
|
42694 |
|
42695 | return conditionalGroup$1([group$2(concat$6([openingLines, concat$6(children), closingLines])), multiLineElem]);
|
42696 | }
|
42697 |
|
42698 | function maybeWrapJSXElementInParens(path, elem, options) {
|
42699 | const parent = path.getParentNode();
|
42700 |
|
42701 | if (!parent) {
|
42702 | return elem;
|
42703 | }
|
42704 |
|
42705 | const NO_WRAP_PARENTS = {
|
42706 | ArrayExpression: true,
|
42707 | JSXAttribute: true,
|
42708 | JSXElement: true,
|
42709 | JSXExpressionContainer: true,
|
42710 | JSXFragment: true,
|
42711 | ExpressionStatement: true,
|
42712 | CallExpression: true,
|
42713 | OptionalCallExpression: true,
|
42714 | ConditionalExpression: true,
|
42715 | JsExpressionRoot: true
|
42716 | };
|
42717 |
|
42718 | if (NO_WRAP_PARENTS[parent.type]) {
|
42719 | return elem;
|
42720 | }
|
42721 |
|
42722 | const shouldBreak = path.match(undefined, node => node.type === "ArrowFunctionExpression", isCallOrOptionalCallExpression$1, node => node.type === "JSXExpressionContainer");
|
42723 | const needsParens = needsParens_1(path, options);
|
42724 | return group$2(concat$6([needsParens ? "" : ifBreak$1("("), indent$3(concat$6([softline$2, elem])), softline$2, needsParens ? "" : ifBreak$1(")")]), {
|
42725 | shouldBreak
|
42726 | });
|
42727 | }
|
42728 |
|
42729 | function shouldInlineLogicalExpression(node) {
|
42730 | if (node.type !== "LogicalExpression") {
|
42731 | return false;
|
42732 | }
|
42733 |
|
42734 | if (node.right.type === "ObjectExpression" && node.right.properties.length !== 0) {
|
42735 | return true;
|
42736 | }
|
42737 |
|
42738 | if (node.right.type === "ArrayExpression" && node.right.elements.length !== 0) {
|
42739 | return true;
|
42740 | }
|
42741 |
|
42742 | if (isJSXNode$1(node.right)) {
|
42743 | return true;
|
42744 | }
|
42745 |
|
42746 | return false;
|
42747 | }
|
42748 |
|
42749 |
|
42750 |
|
42751 |
|
42752 |
|
42753 |
|
42754 |
|
42755 |
|
42756 |
|
42757 | function printBinaryishExpressions(path, print, options, isNested, isInsideParenthesis) {
|
42758 | let parts = [];
|
42759 | const node = path.getValue();
|
42760 |
|
42761 | if (isBinaryish$1(node)) {
|
42762 |
|
42763 |
|
42764 |
|
42765 |
|
42766 |
|
42767 |
|
42768 |
|
42769 |
|
42770 |
|
42771 | if (shouldFlatten$1(node.operator, node.left.operator)) {
|
42772 |
|
42773 | parts = parts.concat(path.call(left => printBinaryishExpressions(left, print, options,
|
42774 |
|
42775 | true, isInsideParenthesis), "left"));
|
42776 | } else {
|
42777 | parts.push(path.call(print, "left"));
|
42778 | }
|
42779 |
|
42780 | const shouldInline = shouldInlineLogicalExpression(node);
|
42781 | const lineBeforeOperator = (node.operator === "|>" || node.type === "NGPipeExpression" || node.operator === "|" && options.parser === "__vue_expression") && !hasLeadingOwnLineComment$1(options.originalText, node.right, options);
|
42782 | const operator = node.type === "NGPipeExpression" ? "|" : node.operator;
|
42783 | const rightSuffix = node.type === "NGPipeExpression" && node.arguments.length !== 0 ? group$2(indent$3(concat$6([softline$2, ": ", join$4(concat$6([softline$2, ":", ifBreak$1(" ")]), path.map(print, "arguments").map(arg => align$1(2, group$2(arg))))]))) : "";
|
42784 | const right = shouldInline ? concat$6([operator, " ", path.call(print, "right"), rightSuffix]) : concat$6([lineBeforeOperator ? softline$2 : "", operator, lineBeforeOperator ? " " : line$4, path.call(print, "right"), rightSuffix]);
|
42785 |
|
42786 |
|
42787 | const parent = path.getParentNode();
|
42788 | const shouldGroup = !(isInsideParenthesis && node.type === "LogicalExpression") && parent.type !== node.type && node.left.type !== node.type && node.right.type !== node.type;
|
42789 | parts.push(" ", shouldGroup ? group$2(right) : right);
|
42790 |
|
42791 |
|
42792 |
|
42793 | if (isNested && node.comments) {
|
42794 | parts = comments.printComments(path, () => concat$6(parts), options);
|
42795 | }
|
42796 | } else {
|
42797 |
|
42798 | parts.push(path.call(print));
|
42799 | }
|
42800 |
|
42801 | return parts;
|
42802 | }
|
42803 |
|
42804 | function printAssignmentRight(leftNode, rightNode, printedRight, options) {
|
42805 | if (hasLeadingOwnLineComment$1(options.originalText, rightNode, options)) {
|
42806 | return indent$3(concat$6([line$4, printedRight]));
|
42807 | }
|
42808 |
|
42809 | const canBreak = isBinaryish$1(rightNode) && !shouldInlineLogicalExpression(rightNode) || rightNode.type === "ConditionalExpression" && isBinaryish$1(rightNode.test) && !shouldInlineLogicalExpression(rightNode.test) || rightNode.type === "StringLiteralTypeAnnotation" || rightNode.type === "ClassExpression" && rightNode.decorators && rightNode.decorators.length || (leftNode.type === "Identifier" || isStringLiteral$1(leftNode) || leftNode.type === "MemberExpression") && (isStringLiteral$1(rightNode) || isMemberExpressionChain$1(rightNode)) &&
|
42810 | options.parser !== "json" && options.parser !== "json5" || rightNode.type === "SequenceExpression";
|
42811 |
|
42812 | if (canBreak) {
|
42813 | return group$2(indent$3(concat$6([line$4, printedRight])));
|
42814 | }
|
42815 |
|
42816 | return concat$6([" ", printedRight]);
|
42817 | }
|
42818 |
|
42819 | function printAssignment(leftNode, printedLeft, operator, rightNode, printedRight, options) {
|
42820 | if (!rightNode) {
|
42821 | return printedLeft;
|
42822 | }
|
42823 |
|
42824 | const printed = printAssignmentRight(leftNode, rightNode, printedRight, options);
|
42825 | return group$2(concat$6([printedLeft, operator, printed]));
|
42826 | }
|
42827 |
|
42828 | function adjustClause(node, clause, forceSpace) {
|
42829 | if (node.type === "EmptyStatement") {
|
42830 | return ";";
|
42831 | }
|
42832 |
|
42833 | if (node.type === "BlockStatement" || forceSpace) {
|
42834 | return concat$6([" ", clause]);
|
42835 | }
|
42836 |
|
42837 | return indent$3(concat$6([line$4, clause]));
|
42838 | }
|
42839 |
|
42840 | function nodeStr(node, options, isFlowOrTypeScriptDirectiveLiteral) {
|
42841 | const raw = rawText$1(node);
|
42842 | const isDirectiveLiteral = isFlowOrTypeScriptDirectiveLiteral || node.type === "DirectiveLiteral";
|
42843 | return printString$1(raw, options, isDirectiveLiteral);
|
42844 | }
|
42845 |
|
42846 | function printRegex(node) {
|
42847 | const flags = node.flags.split("").sort().join("");
|
42848 | return `/${node.pattern}/${flags}`;
|
42849 | }
|
42850 |
|
42851 | function exprNeedsASIProtection(path, options) {
|
42852 | const node = path.getValue();
|
42853 | const maybeASIProblem = needsParens_1(path, options) || node.type === "ParenthesizedExpression" || node.type === "TypeCastExpression" || node.type === "ArrowFunctionExpression" && !shouldPrintParamsWithoutParens(path, options) || node.type === "ArrayExpression" || node.type === "ArrayPattern" || node.type === "UnaryExpression" && node.prefix && (node.operator === "+" || node.operator === "-") || node.type === "TemplateLiteral" || node.type === "TemplateElement" || isJSXNode$1(node) || node.type === "BindExpression" && !node.object || node.type === "RegExpLiteral" || node.type === "Literal" && node.pattern || node.type === "Literal" && node.regex;
|
42854 |
|
42855 | if (maybeASIProblem) {
|
42856 | return true;
|
42857 | }
|
42858 |
|
42859 | if (!hasNakedLeftSide$2(node)) {
|
42860 | return false;
|
42861 | }
|
42862 |
|
42863 | return path.call(childPath => exprNeedsASIProtection(childPath, options), ...getLeftSidePathName$2(path, node));
|
42864 | }
|
42865 |
|
42866 | function stmtNeedsASIProtection(path, options) {
|
42867 | const node = path.getNode();
|
42868 |
|
42869 | if (node.type !== "ExpressionStatement") {
|
42870 | return false;
|
42871 | }
|
42872 |
|
42873 | return path.call(childPath => exprNeedsASIProtection(childPath, options), "expression");
|
42874 | }
|
42875 |
|
42876 | function shouldHugType(node) {
|
42877 | if (isSimpleFlowType$1(node) || isObjectType$1(node)) {
|
42878 | return true;
|
42879 | }
|
42880 |
|
42881 | if (node.type === "UnionTypeAnnotation" || node.type === "TSUnionType") {
|
42882 | const voidCount = node.types.filter(n => n.type === "VoidTypeAnnotation" || n.type === "TSVoidKeyword" || n.type === "NullLiteralTypeAnnotation" || n.type === "TSNullKeyword").length;
|
42883 | const hasObject = node.types.some(n => n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral" ||
|
42884 | n.type === "GenericTypeAnnotation" || n.type === "TSTypeReference");
|
42885 |
|
42886 | if (node.types.length - 1 === voidCount && hasObject) {
|
42887 | return true;
|
42888 | }
|
42889 | }
|
42890 |
|
42891 | return false;
|
42892 | }
|
42893 |
|
42894 | function shouldHugArguments(fun) {
|
42895 | if (!fun || fun.rest) {
|
42896 | return false;
|
42897 | }
|
42898 |
|
42899 | const params = fun.params || fun.parameters;
|
42900 |
|
42901 | if (!params || params.length !== 1) {
|
42902 | return false;
|
42903 | }
|
42904 |
|
42905 | const param = params[0];
|
42906 | return !param.comments && (param.type === "ObjectPattern" || param.type === "ArrayPattern" || param.type === "Identifier" && param.typeAnnotation && (param.typeAnnotation.type === "TypeAnnotation" || param.typeAnnotation.type === "TSTypeAnnotation") && isObjectType$1(param.typeAnnotation.typeAnnotation) || param.type === "FunctionTypeParam" && isObjectType$1(param.typeAnnotation) || param.type === "AssignmentPattern" && (param.left.type === "ObjectPattern" || param.left.type === "ArrayPattern") && (param.right.type === "Identifier" || param.right.type === "ObjectExpression" && param.right.properties.length === 0 || param.right.type === "ArrayExpression" && param.right.elements.length === 0));
|
42907 | }
|
42908 |
|
42909 | function printArrayItems(path, options, printPath, print) {
|
42910 | const printedElements = [];
|
42911 | let separatorParts = [];
|
42912 | path.each(childPath => {
|
42913 | printedElements.push(concat$6(separatorParts));
|
42914 | printedElements.push(group$2(print(childPath)));
|
42915 | separatorParts = [",", line$4];
|
42916 |
|
42917 | if (childPath.getValue() && isNextLineEmpty$2(options.originalText, childPath.getValue(), options.locEnd)) {
|
42918 | separatorParts.push(softline$2);
|
42919 | }
|
42920 | }, printPath);
|
42921 | return concat$6(printedElements);
|
42922 | }
|
42923 |
|
42924 | function printReturnAndThrowArgument(path, options, print) {
|
42925 | const node = path.getValue();
|
42926 | const semi = options.semi ? ";" : "";
|
42927 | const parts = [];
|
42928 |
|
42929 | if (node.argument) {
|
42930 | if (returnArgumentHasLeadingComment$1(options, node.argument)) {
|
42931 | parts.push(concat$6([" (", indent$3(concat$6([hardline$4, path.call(print, "argument")])), hardline$4, ")"]));
|
42932 | } else if (isBinaryish$1(node.argument) || node.argument.type === "SequenceExpression") {
|
42933 | parts.push(group$2(concat$6([ifBreak$1(" (", " "), indent$3(concat$6([softline$2, path.call(print, "argument")])), softline$2, ifBreak$1(")")])));
|
42934 | } else {
|
42935 | parts.push(" ", path.call(print, "argument"));
|
42936 | }
|
42937 | }
|
42938 |
|
42939 | const lastComment = Array.isArray(node.comments) && node.comments[node.comments.length - 1];
|
42940 | const isLastCommentLine = lastComment && (lastComment.type === "CommentLine" || lastComment.type === "Line");
|
42941 |
|
42942 | if (isLastCommentLine) {
|
42943 | parts.push(semi);
|
42944 | }
|
42945 |
|
42946 | if (hasDanglingComments$1(node)) {
|
42947 | parts.push(" ", comments.printDanglingComments(path, options,
|
42948 |
|
42949 | true));
|
42950 | }
|
42951 |
|
42952 | if (!isLastCommentLine) {
|
42953 | parts.push(semi);
|
42954 | }
|
42955 |
|
42956 | return concat$6(parts);
|
42957 | }
|
42958 |
|
42959 | function willPrintOwnComments(path
|
42960 | /*, options */
|
42961 | ) {
|
42962 | const node = path.getValue();
|
42963 | const parent = path.getParentNode();
|
42964 | return (node && (isJSXNode$1(node) || hasFlowShorthandAnnotationComment$2(node) || parent && (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && (hasFlowAnnotationComment$1(node.leadingComments) || hasFlowAnnotationComment$1(node.trailingComments))) || parent && (parent.type === "JSXSpreadAttribute" || parent.type === "JSXSpreadChild" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || (parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.superClass === node)) && (!hasIgnoreComment$2(path) || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType");
|
42965 | }
|
42966 |
|
42967 | function canAttachComment(node) {
|
42968 | return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import";
|
42969 | }
|
42970 |
|
42971 | function printComment$1(commentPath, options) {
|
42972 | const comment = commentPath.getValue();
|
42973 |
|
42974 | switch (comment.type) {
|
42975 | case "CommentBlock":
|
42976 | case "Block":
|
42977 | {
|
42978 | if (isIndentableBlockComment(comment)) {
|
42979 | const printed = printIndentableBlockComment(comment);
|
42980 |
|
42981 |
|
42982 |
|
42983 | if (comment.trailing && !hasNewline$4(options.originalText, options.locStart(comment), {
|
42984 | backwards: true
|
42985 | })) {
|
42986 | return concat$6([hardline$4, printed]);
|
42987 | }
|
42988 |
|
42989 | return printed;
|
42990 | }
|
42991 |
|
42992 | const commentEnd = options.locEnd(comment);
|
42993 | const isInsideFlowComment = options.originalText.slice(commentEnd - 3, commentEnd) === "*-/";
|
42994 | return "/*" + comment.value + (isInsideFlowComment ? "*-/" : "*/");
|
42995 | }
|
42996 |
|
42997 | case "CommentLine":
|
42998 | case "Line":
|
42999 |
|
43000 | if (options.originalText.slice(options.locStart(comment)).startsWith("#!")) {
|
43001 | return "#!" + comment.value.trimEnd();
|
43002 | }
|
43003 |
|
43004 | return "//" + comment.value.trimEnd();
|
43005 |
|
43006 | default:
|
43007 | throw new Error("Not a comment: " + JSON.stringify(comment));
|
43008 | }
|
43009 | }
|
43010 |
|
43011 | function isIndentableBlockComment(comment) {
|
43012 |
|
43013 |
|
43014 |
|
43015 |
|
43016 | const lines = `*${comment.value}*`.split("\n");
|
43017 | return lines.length > 1 && lines.every(line => line.trim()[0] === "*");
|
43018 | }
|
43019 |
|
43020 | function printIndentableBlockComment(comment) {
|
43021 | const lines = comment.value.split("\n");
|
43022 | return concat$6(["/*", join$4(hardline$4, lines.map((line, index) => index === 0 ? line.trimEnd() : " " + (index < lines.length - 1 ? line.trim() : line.trimStart()))), "*/"]);
|
43023 | }
|
43024 |
|
43025 | var printerEstree = {
|
43026 | preprocess: preprocess_1,
|
43027 | print: genericPrint,
|
43028 | embed: embed_1,
|
43029 | insertPragma: insertPragma$1,
|
43030 | massageAstNode: clean_1,
|
43031 | hasPrettierIgnore: hasPrettierIgnore$1,
|
43032 | willPrintOwnComments,
|
43033 | canAttachComment,
|
43034 | printComment: printComment$1,
|
43035 | isBlockComment: comments$1.isBlockComment,
|
43036 | handleComments: {
|
43037 | ownLine: comments$1.handleOwnLineComment,
|
43038 | endOfLine: comments$1.handleEndOfLineComment,
|
43039 | remaining: comments$1.handleRemainingComment
|
43040 | },
|
43041 | getGapRegex: comments$1.getGapRegex,
|
43042 | getCommentChildNodes: comments$1.getCommentChildNodes
|
43043 | };
|
43044 |
|
43045 | const {
|
43046 | concat: concat$7,
|
43047 | hardline: hardline$5,
|
43048 | indent: indent$4,
|
43049 | join: join$5
|
43050 | } = document.builders;
|
43051 |
|
43052 | function genericPrint$1(path, options, print) {
|
43053 | const node = path.getValue();
|
43054 |
|
43055 | switch (node.type) {
|
43056 | case "JsonRoot":
|
43057 | return concat$7([path.call(print, "node"), hardline$5]);
|
43058 |
|
43059 | case "ArrayExpression":
|
43060 | return node.elements.length === 0 ? "[]" : concat$7(["[", indent$4(concat$7([hardline$5, join$5(concat$7([",", hardline$5]), path.map(print, "elements"))])), hardline$5, "]"]);
|
43061 |
|
43062 | case "ObjectExpression":
|
43063 | return node.properties.length === 0 ? "{}" : concat$7(["{", indent$4(concat$7([hardline$5, join$5(concat$7([",", hardline$5]), path.map(print, "properties"))])), hardline$5, "}"]);
|
43064 |
|
43065 | case "ObjectProperty":
|
43066 | return concat$7([path.call(print, "key"), ": ", path.call(print, "value")]);
|
43067 |
|
43068 | case "UnaryExpression":
|
43069 | return concat$7([node.operator === "+" ? "" : node.operator, path.call(print, "argument")]);
|
43070 |
|
43071 | case "NullLiteral":
|
43072 | return "null";
|
43073 |
|
43074 | case "BooleanLiteral":
|
43075 | return node.value ? "true" : "false";
|
43076 |
|
43077 | case "StringLiteral":
|
43078 | case "NumericLiteral":
|
43079 | return JSON.stringify(node.value);
|
43080 |
|
43081 | case "Identifier":
|
43082 | return JSON.stringify(node.name);
|
43083 |
|
43084 | default:
|
43085 |
|
43086 | throw new Error("unknown type: " + JSON.stringify(node.type));
|
43087 | }
|
43088 | }
|
43089 |
|
43090 | function clean$1(node, newNode
|
43091 | /*, parent*/
|
43092 | ) {
|
43093 | delete newNode.start;
|
43094 | delete newNode.end;
|
43095 | delete newNode.extra;
|
43096 | delete newNode.loc;
|
43097 | delete newNode.comments;
|
43098 | delete newNode.errors;
|
43099 |
|
43100 | if (node.type === "Identifier") {
|
43101 | return {
|
43102 | type: "StringLiteral",
|
43103 | value: node.name
|
43104 | };
|
43105 | }
|
43106 |
|
43107 | if (node.type === "UnaryExpression" && node.operator === "+") {
|
43108 | return newNode.argument;
|
43109 | }
|
43110 | }
|
43111 |
|
43112 | var printerEstreeJson = {
|
43113 | preprocess: preprocess_1,
|
43114 | print: genericPrint$1,
|
43115 | massageAstNode: clean$1
|
43116 | };
|
43117 |
|
43118 | const CATEGORY_COMMON = "Common";
|
43119 |
|
43120 | var commonOptions = {
|
43121 | bracketSpacing: {
|
43122 | since: "0.0.0",
|
43123 | category: CATEGORY_COMMON,
|
43124 | type: "boolean",
|
43125 | default: true,
|
43126 | description: "Print spaces between brackets.",
|
43127 | oppositeDescription: "Do not print spaces between brackets."
|
43128 | },
|
43129 | singleQuote: {
|
43130 | since: "0.0.0",
|
43131 | category: CATEGORY_COMMON,
|
43132 | type: "boolean",
|
43133 | default: false,
|
43134 | description: "Use single quotes instead of double quotes."
|
43135 | },
|
43136 | proseWrap: {
|
43137 | since: "1.8.2",
|
43138 | category: CATEGORY_COMMON,
|
43139 | type: "choice",
|
43140 | default: [{
|
43141 | since: "1.8.2",
|
43142 | value: true
|
43143 | }, {
|
43144 | since: "1.9.0",
|
43145 | value: "preserve"
|
43146 | }],
|
43147 | description: "How to wrap prose.",
|
43148 | choices: [{
|
43149 | since: "1.9.0",
|
43150 | value: "always",
|
43151 | description: "Wrap prose if it exceeds the print width."
|
43152 | }, {
|
43153 | since: "1.9.0",
|
43154 | value: "never",
|
43155 | description: "Do not wrap prose."
|
43156 | }, {
|
43157 | since: "1.9.0",
|
43158 | value: "preserve",
|
43159 | description: "Wrap prose as-is."
|
43160 | }]
|
43161 | }
|
43162 | };
|
43163 |
|
43164 | const CATEGORY_JAVASCRIPT = "JavaScript";
|
43165 |
|
43166 | var options$2 = {
|
43167 | arrowParens: {
|
43168 | since: "1.9.0",
|
43169 | category: CATEGORY_JAVASCRIPT,
|
43170 | type: "choice",
|
43171 | default: [{
|
43172 | since: "1.9.0",
|
43173 | value: "avoid"
|
43174 | }, {
|
43175 | since: "2.0.0",
|
43176 | value: "always"
|
43177 | }],
|
43178 | description: "Include parentheses around a sole arrow function parameter.",
|
43179 | choices: [{
|
43180 | value: "always",
|
43181 | description: "Always include parens. Example: `(x) => x`"
|
43182 | }, {
|
43183 | value: "avoid",
|
43184 | description: "Omit parens when possible. Example: `x => x`"
|
43185 | }]
|
43186 | },
|
43187 | bracketSpacing: commonOptions.bracketSpacing,
|
43188 | jsxBracketSameLine: {
|
43189 | since: "0.17.0",
|
43190 | category: CATEGORY_JAVASCRIPT,
|
43191 | type: "boolean",
|
43192 | default: false,
|
43193 | description: "Put > on the last line instead of at a new line."
|
43194 | },
|
43195 | semi: {
|
43196 | since: "1.0.0",
|
43197 | category: CATEGORY_JAVASCRIPT,
|
43198 | type: "boolean",
|
43199 | default: true,
|
43200 | description: "Print semicolons.",
|
43201 | oppositeDescription: "Do not print semicolons, except at the beginning of lines which may need them."
|
43202 | },
|
43203 | singleQuote: commonOptions.singleQuote,
|
43204 | jsxSingleQuote: {
|
43205 | since: "1.15.0",
|
43206 | category: CATEGORY_JAVASCRIPT,
|
43207 | type: "boolean",
|
43208 | default: false,
|
43209 | description: "Use single quotes in JSX."
|
43210 | },
|
43211 | quoteProps: {
|
43212 | since: "1.17.0",
|
43213 | category: CATEGORY_JAVASCRIPT,
|
43214 | type: "choice",
|
43215 | default: "as-needed",
|
43216 | description: "Change when properties in objects are quoted.",
|
43217 | choices: [{
|
43218 | value: "as-needed",
|
43219 | description: "Only add quotes around object properties where required."
|
43220 | }, {
|
43221 | value: "consistent",
|
43222 | description: "If at least one property in an object requires quotes, quote all properties."
|
43223 | }, {
|
43224 | value: "preserve",
|
43225 | description: "Respect the input use of quotes in object properties."
|
43226 | }]
|
43227 | },
|
43228 | trailingComma: {
|
43229 | since: "0.0.0",
|
43230 | category: CATEGORY_JAVASCRIPT,
|
43231 | type: "choice",
|
43232 | default: [{
|
43233 | since: "0.0.0",
|
43234 | value: false
|
43235 | }, {
|
43236 | since: "0.19.0",
|
43237 | value: "none"
|
43238 | }, {
|
43239 | since: "2.0.0",
|
43240 | value: "es5"
|
43241 | }],
|
43242 | description: "Print trailing commas wherever possible when multi-line.",
|
43243 | choices: [{
|
43244 | value: "es5",
|
43245 | description: "Trailing commas where valid in ES5 (objects, arrays, etc.)"
|
43246 | }, {
|
43247 | value: "none",
|
43248 | description: "No trailing commas."
|
43249 | }, {
|
43250 | value: "all",
|
43251 | description: "Trailing commas wherever possible (including function arguments)."
|
43252 | }]
|
43253 | }
|
43254 | };
|
43255 |
|
43256 | var createLanguage = function (linguistData, override) {
|
43257 | const {
|
43258 | languageId
|
43259 | } = linguistData,
|
43260 | rest = _objectWithoutPropertiesLoose(linguistData, ["languageId"]);
|
43261 |
|
43262 | return Object.assign({
|
43263 | linguistLanguageId: languageId
|
43264 | }, rest, {}, override(linguistData));
|
43265 | };
|
43266 |
|
43267 | var name$2 = "JavaScript";
|
43268 | var type = "programming";
|
43269 | var tmScope = "source.js";
|
43270 | var aceMode = "javascript";
|
43271 | var codemirrorMode = "javascript";
|
43272 | var codemirrorMimeType = "text/javascript";
|
43273 | var color = "#f1e05a";
|
43274 | var aliases = [
|
43275 | "js",
|
43276 | "node"
|
43277 | ];
|
43278 | var extensions = [
|
43279 | ".js",
|
43280 | "._js",
|
43281 | ".bones",
|
43282 | ".cjs",
|
43283 | ".es",
|
43284 | ".es6",
|
43285 | ".frag",
|
43286 | ".gs",
|
43287 | ".jake",
|
43288 | ".jsb",
|
43289 | ".jscad",
|
43290 | ".jsfl",
|
43291 | ".jsm",
|
43292 | ".jss",
|
43293 | ".mjs",
|
43294 | ".njs",
|
43295 | ".pac",
|
43296 | ".sjs",
|
43297 | ".ssjs",
|
43298 | ".xsjs",
|
43299 | ".xsjslib"
|
43300 | ];
|
43301 | var filenames = [
|
43302 | "Jakefile"
|
43303 | ];
|
43304 | var interpreters = [
|
43305 | "chakra",
|
43306 | "d8",
|
43307 | "gjs",
|
43308 | "js",
|
43309 | "node",
|
43310 | "qjs",
|
43311 | "rhino",
|
43312 | "v8",
|
43313 | "v8-shell"
|
43314 | ];
|
43315 | var languageId = 183;
|
43316 | var JavaScript = {
|
43317 | name: name$2,
|
43318 | type: type,
|
43319 | tmScope: tmScope,
|
43320 | aceMode: aceMode,
|
43321 | codemirrorMode: codemirrorMode,
|
43322 | codemirrorMimeType: codemirrorMimeType,
|
43323 | color: color,
|
43324 | aliases: aliases,
|
43325 | extensions: extensions,
|
43326 | filenames: filenames,
|
43327 | interpreters: interpreters,
|
43328 | languageId: languageId
|
43329 | };
|
43330 |
|
43331 | var JavaScript$1 = Object.freeze({
|
43332 | __proto__: null,
|
43333 | name: name$2,
|
43334 | type: type,
|
43335 | tmScope: tmScope,
|
43336 | aceMode: aceMode,
|
43337 | codemirrorMode: codemirrorMode,
|
43338 | codemirrorMimeType: codemirrorMimeType,
|
43339 | color: color,
|
43340 | aliases: aliases,
|
43341 | extensions: extensions,
|
43342 | filenames: filenames,
|
43343 | interpreters: interpreters,
|
43344 | languageId: languageId,
|
43345 | 'default': JavaScript
|
43346 | });
|
43347 |
|
43348 | var name$3 = "JSX";
|
43349 | var type$1 = "programming";
|
43350 | var group$3 = "JavaScript";
|
43351 | var extensions$1 = [
|
43352 | ".jsx"
|
43353 | ];
|
43354 | var tmScope$1 = "source.js.jsx";
|
43355 | var aceMode$1 = "javascript";
|
43356 | var codemirrorMode$1 = "jsx";
|
43357 | var codemirrorMimeType$1 = "text/jsx";
|
43358 | var languageId$1 = 178;
|
43359 | var JSX = {
|
43360 | name: name$3,
|
43361 | type: type$1,
|
43362 | group: group$3,
|
43363 | extensions: extensions$1,
|
43364 | tmScope: tmScope$1,
|
43365 | aceMode: aceMode$1,
|
43366 | codemirrorMode: codemirrorMode$1,
|
43367 | codemirrorMimeType: codemirrorMimeType$1,
|
43368 | languageId: languageId$1
|
43369 | };
|
43370 |
|
43371 | var JSX$1 = Object.freeze({
|
43372 | __proto__: null,
|
43373 | name: name$3,
|
43374 | type: type$1,
|
43375 | group: group$3,
|
43376 | extensions: extensions$1,
|
43377 | tmScope: tmScope$1,
|
43378 | aceMode: aceMode$1,
|
43379 | codemirrorMode: codemirrorMode$1,
|
43380 | codemirrorMimeType: codemirrorMimeType$1,
|
43381 | languageId: languageId$1,
|
43382 | 'default': JSX
|
43383 | });
|
43384 |
|
43385 | var name$4 = "TypeScript";
|
43386 | var type$2 = "programming";
|
43387 | var color$1 = "#2b7489";
|
43388 | var aliases$1 = [
|
43389 | "ts"
|
43390 | ];
|
43391 | var interpreters$1 = [
|
43392 | "deno",
|
43393 | "ts-node"
|
43394 | ];
|
43395 | var extensions$2 = [
|
43396 | ".ts"
|
43397 | ];
|
43398 | var tmScope$2 = "source.ts";
|
43399 | var aceMode$2 = "typescript";
|
43400 | var codemirrorMode$2 = "javascript";
|
43401 | var codemirrorMimeType$2 = "application/typescript";
|
43402 | var languageId$2 = 378;
|
43403 | var TypeScript = {
|
43404 | name: name$4,
|
43405 | type: type$2,
|
43406 | color: color$1,
|
43407 | aliases: aliases$1,
|
43408 | interpreters: interpreters$1,
|
43409 | extensions: extensions$2,
|
43410 | tmScope: tmScope$2,
|
43411 | aceMode: aceMode$2,
|
43412 | codemirrorMode: codemirrorMode$2,
|
43413 | codemirrorMimeType: codemirrorMimeType$2,
|
43414 | languageId: languageId$2
|
43415 | };
|
43416 |
|
43417 | var TypeScript$1 = Object.freeze({
|
43418 | __proto__: null,
|
43419 | name: name$4,
|
43420 | type: type$2,
|
43421 | color: color$1,
|
43422 | aliases: aliases$1,
|
43423 | interpreters: interpreters$1,
|
43424 | extensions: extensions$2,
|
43425 | tmScope: tmScope$2,
|
43426 | aceMode: aceMode$2,
|
43427 | codemirrorMode: codemirrorMode$2,
|
43428 | codemirrorMimeType: codemirrorMimeType$2,
|
43429 | languageId: languageId$2,
|
43430 | 'default': TypeScript
|
43431 | });
|
43432 |
|
43433 | var name$5 = "TSX";
|
43434 | var type$3 = "programming";
|
43435 | var group$4 = "TypeScript";
|
43436 | var extensions$3 = [
|
43437 | ".tsx"
|
43438 | ];
|
43439 | var tmScope$3 = "source.tsx";
|
43440 | var aceMode$3 = "javascript";
|
43441 | var codemirrorMode$3 = "jsx";
|
43442 | var codemirrorMimeType$3 = "text/jsx";
|
43443 | var languageId$3 = 94901924;
|
43444 | var TSX = {
|
43445 | name: name$5,
|
43446 | type: type$3,
|
43447 | group: group$4,
|
43448 | extensions: extensions$3,
|
43449 | tmScope: tmScope$3,
|
43450 | aceMode: aceMode$3,
|
43451 | codemirrorMode: codemirrorMode$3,
|
43452 | codemirrorMimeType: codemirrorMimeType$3,
|
43453 | languageId: languageId$3
|
43454 | };
|
43455 |
|
43456 | var TSX$1 = Object.freeze({
|
43457 | __proto__: null,
|
43458 | name: name$5,
|
43459 | type: type$3,
|
43460 | group: group$4,
|
43461 | extensions: extensions$3,
|
43462 | tmScope: tmScope$3,
|
43463 | aceMode: aceMode$3,
|
43464 | codemirrorMode: codemirrorMode$3,
|
43465 | codemirrorMimeType: codemirrorMimeType$3,
|
43466 | languageId: languageId$3,
|
43467 | 'default': TSX
|
43468 | });
|
43469 |
|
43470 | var name$6 = "JSON";
|
43471 | var type$4 = "data";
|
43472 | var tmScope$4 = "source.json";
|
43473 | var aceMode$4 = "json";
|
43474 | var codemirrorMode$4 = "javascript";
|
43475 | var codemirrorMimeType$4 = "application/json";
|
43476 | var searchable = false;
|
43477 | var extensions$4 = [
|
43478 | ".json",
|
43479 | ".avsc",
|
43480 | ".geojson",
|
43481 | ".gltf",
|
43482 | ".har",
|
43483 | ".ice",
|
43484 | ".JSON-tmLanguage",
|
43485 | ".jsonl",
|
43486 | ".mcmeta",
|
43487 | ".tfstate",
|
43488 | ".tfstate.backup",
|
43489 | ".topojson",
|
43490 | ".webapp",
|
43491 | ".webmanifest",
|
43492 | ".yy",
|
43493 | ".yyp"
|
43494 | ];
|
43495 | var filenames$1 = [
|
43496 | ".arcconfig",
|
43497 | ".htmlhintrc",
|
43498 | ".tern-config",
|
43499 | ".tern-project",
|
43500 | ".watchmanconfig",
|
43501 | "composer.lock",
|
43502 | "mcmod.info"
|
43503 | ];
|
43504 | var languageId$4 = 174;
|
43505 | var _JSON = {
|
43506 | name: name$6,
|
43507 | type: type$4,
|
43508 | tmScope: tmScope$4,
|
43509 | aceMode: aceMode$4,
|
43510 | codemirrorMode: codemirrorMode$4,
|
43511 | codemirrorMimeType: codemirrorMimeType$4,
|
43512 | searchable: searchable,
|
43513 | extensions: extensions$4,
|
43514 | filenames: filenames$1,
|
43515 | languageId: languageId$4
|
43516 | };
|
43517 |
|
43518 | var _JSON$1 = Object.freeze({
|
43519 | __proto__: null,
|
43520 | name: name$6,
|
43521 | type: type$4,
|
43522 | tmScope: tmScope$4,
|
43523 | aceMode: aceMode$4,
|
43524 | codemirrorMode: codemirrorMode$4,
|
43525 | codemirrorMimeType: codemirrorMimeType$4,
|
43526 | searchable: searchable,
|
43527 | extensions: extensions$4,
|
43528 | filenames: filenames$1,
|
43529 | languageId: languageId$4,
|
43530 | 'default': _JSON
|
43531 | });
|
43532 |
|
43533 | var name$7 = "JSON with Comments";
|
43534 | var type$5 = "data";
|
43535 | var group$5 = "JSON";
|
43536 | var tmScope$5 = "source.js";
|
43537 | var aceMode$5 = "javascript";
|
43538 | var codemirrorMode$5 = "javascript";
|
43539 | var codemirrorMimeType$5 = "text/javascript";
|
43540 | var aliases$2 = [
|
43541 | "jsonc"
|
43542 | ];
|
43543 | var extensions$5 = [
|
43544 | ".jsonc",
|
43545 | ".sublime-build",
|
43546 | ".sublime-commands",
|
43547 | ".sublime-completions",
|
43548 | ".sublime-keymap",
|
43549 | ".sublime-macro",
|
43550 | ".sublime-menu",
|
43551 | ".sublime-mousemap",
|
43552 | ".sublime-project",
|
43553 | ".sublime-settings",
|
43554 | ".sublime-theme",
|
43555 | ".sublime-workspace",
|
43556 | ".sublime_metrics",
|
43557 | ".sublime_session"
|
43558 | ];
|
43559 | var filenames$2 = [
|
43560 | ".babelrc",
|
43561 | ".eslintrc.json",
|
43562 | ".jscsrc",
|
43563 | ".jshintrc",
|
43564 | ".jslintrc",
|
43565 | "jsconfig.json",
|
43566 | "language-configuration.json",
|
43567 | "tsconfig.json"
|
43568 | ];
|
43569 | var languageId$5 = 423;
|
43570 | var JSON_with_Comments = {
|
43571 | name: name$7,
|
43572 | type: type$5,
|
43573 | group: group$5,
|
43574 | tmScope: tmScope$5,
|
43575 | aceMode: aceMode$5,
|
43576 | codemirrorMode: codemirrorMode$5,
|
43577 | codemirrorMimeType: codemirrorMimeType$5,
|
43578 | aliases: aliases$2,
|
43579 | extensions: extensions$5,
|
43580 | filenames: filenames$2,
|
43581 | languageId: languageId$5
|
43582 | };
|
43583 |
|
43584 | var JSON_with_Comments$1 = Object.freeze({
|
43585 | __proto__: null,
|
43586 | name: name$7,
|
43587 | type: type$5,
|
43588 | group: group$5,
|
43589 | tmScope: tmScope$5,
|
43590 | aceMode: aceMode$5,
|
43591 | codemirrorMode: codemirrorMode$5,
|
43592 | codemirrorMimeType: codemirrorMimeType$5,
|
43593 | aliases: aliases$2,
|
43594 | extensions: extensions$5,
|
43595 | filenames: filenames$2,
|
43596 | languageId: languageId$5,
|
43597 | 'default': JSON_with_Comments
|
43598 | });
|
43599 |
|
43600 | var name$8 = "JSON5";
|
43601 | var type$6 = "data";
|
43602 | var extensions$6 = [
|
43603 | ".json5"
|
43604 | ];
|
43605 | var tmScope$6 = "source.js";
|
43606 | var aceMode$6 = "javascript";
|
43607 | var codemirrorMode$6 = "javascript";
|
43608 | var codemirrorMimeType$6 = "application/json";
|
43609 | var languageId$6 = 175;
|
43610 | var JSON5 = {
|
43611 | name: name$8,
|
43612 | type: type$6,
|
43613 | extensions: extensions$6,
|
43614 | tmScope: tmScope$6,
|
43615 | aceMode: aceMode$6,
|
43616 | codemirrorMode: codemirrorMode$6,
|
43617 | codemirrorMimeType: codemirrorMimeType$6,
|
43618 | languageId: languageId$6
|
43619 | };
|
43620 |
|
43621 | var JSON5$1 = Object.freeze({
|
43622 | __proto__: null,
|
43623 | name: name$8,
|
43624 | type: type$6,
|
43625 | extensions: extensions$6,
|
43626 | tmScope: tmScope$6,
|
43627 | aceMode: aceMode$6,
|
43628 | codemirrorMode: codemirrorMode$6,
|
43629 | codemirrorMimeType: codemirrorMimeType$6,
|
43630 | languageId: languageId$6,
|
43631 | 'default': JSON5
|
43632 | });
|
43633 |
|
43634 | var require$$0$1 = getCjsExportFromNamespace(JavaScript$1);
|
43635 |
|
43636 | var require$$1$1 = getCjsExportFromNamespace(JSX$1);
|
43637 |
|
43638 | var require$$2 = getCjsExportFromNamespace(TypeScript$1);
|
43639 |
|
43640 | var require$$3 = getCjsExportFromNamespace(TSX$1);
|
43641 |
|
43642 | var require$$4$1 = getCjsExportFromNamespace(_JSON$1);
|
43643 |
|
43644 | var require$$5 = getCjsExportFromNamespace(JSON_with_Comments$1);
|
43645 |
|
43646 | var require$$6 = getCjsExportFromNamespace(JSON5$1);
|
43647 |
|
43648 | const languages = [createLanguage(require$$0$1, data => ({
|
43649 | since: "0.0.0",
|
43650 | parsers: ["babel", "flow"],
|
43651 | vscodeLanguageIds: ["javascript", "mongo"],
|
43652 | interpreters: data.interpreters.concat(["nodejs"])
|
43653 | })), createLanguage(require$$0$1, () => ({
|
43654 | name: "Flow",
|
43655 | since: "0.0.0",
|
43656 | parsers: ["babel", "flow"],
|
43657 | vscodeLanguageIds: ["javascript"],
|
43658 | aliases: [],
|
43659 | filenames: [],
|
43660 | extensions: [".js.flow"]
|
43661 | })), createLanguage(require$$1$1, () => ({
|
43662 | since: "0.0.0",
|
43663 | parsers: ["babel", "flow"],
|
43664 | vscodeLanguageIds: ["javascriptreact"]
|
43665 | })), createLanguage(require$$2, () => ({
|
43666 | since: "1.4.0",
|
43667 | parsers: ["typescript", "babel-ts"],
|
43668 | vscodeLanguageIds: ["typescript"]
|
43669 | })), createLanguage(require$$3, () => ({
|
43670 | since: "1.4.0",
|
43671 | parsers: ["typescript", "babel-ts"],
|
43672 | vscodeLanguageIds: ["typescriptreact"]
|
43673 | })), createLanguage(require$$4$1, () => ({
|
43674 | name: "JSON.stringify",
|
43675 | since: "1.13.0",
|
43676 | parsers: ["json-stringify"],
|
43677 | vscodeLanguageIds: ["json"],
|
43678 | extensions: [],
|
43679 |
|
43680 | filenames: ["package.json", "package-lock.json", "composer.json"]
|
43681 | })), createLanguage(require$$4$1, data => ({
|
43682 | since: "1.5.0",
|
43683 | parsers: ["json"],
|
43684 | vscodeLanguageIds: ["json"],
|
43685 | filenames: data.filenames.concat([".prettierrc"])
|
43686 | })), createLanguage(require$$5, data => ({
|
43687 | since: "1.5.0",
|
43688 | parsers: ["json"],
|
43689 | vscodeLanguageIds: ["jsonc"],
|
43690 | filenames: data.filenames.concat([".eslintrc"])
|
43691 | })), createLanguage(require$$6, () => ({
|
43692 | since: "1.13.0",
|
43693 | parsers: ["json5"],
|
43694 | vscodeLanguageIds: ["json5"]
|
43695 | }))];
|
43696 | const printers = {
|
43697 | estree: printerEstree,
|
43698 | "estree-json": printerEstreeJson
|
43699 | };
|
43700 | var languageJs = {
|
43701 | languages,
|
43702 | options: options$2,
|
43703 | printers
|
43704 | };
|
43705 |
|
43706 | function clean$2(ast, newObj, parent) {
|
43707 | ["raw",
|
43708 | "raws", "sourceIndex", "source", "before", "after", "trailingComma"].forEach(name => {
|
43709 | delete newObj[name];
|
43710 | });
|
43711 |
|
43712 | if (ast.type === "yaml") {
|
43713 | delete newObj.value;
|
43714 | }
|
43715 |
|
43716 |
|
43717 | if (ast.type === "css-comment" && parent.type === "css-root" && parent.nodes.length !== 0 && (
|
43718 | parent.nodes[0] === ast || (parent.nodes[0].type === "yaml" || parent.nodes[0].type === "toml") && parent.nodes[1] === ast)) {
|
43719 | |
43720 |
|
43721 |
|
43722 |
|
43723 |
|
43724 | delete newObj.text;
|
43725 |
|
43726 | if (/^\*\s*@(format|prettier)\s*$/.test(ast.text)) {
|
43727 | return null;
|
43728 | }
|
43729 | }
|
43730 |
|
43731 | if (ast.type === "media-query" || ast.type === "media-query-list" || ast.type === "media-feature-expression") {
|
43732 | delete newObj.value;
|
43733 | }
|
43734 |
|
43735 | if (ast.type === "css-rule") {
|
43736 | delete newObj.params;
|
43737 | }
|
43738 |
|
43739 | if (ast.type === "selector-combinator") {
|
43740 | newObj.value = newObj.value.replace(/\s+/g, " ");
|
43741 | }
|
43742 |
|
43743 | if (ast.type === "media-feature") {
|
43744 | newObj.value = newObj.value.replace(/ /g, "");
|
43745 | }
|
43746 |
|
43747 | if (ast.type === "value-word" && (ast.isColor && ast.isHex || ["initial", "inherit", "unset", "revert"].includes(newObj.value.replace().toLowerCase())) || ast.type === "media-feature" || ast.type === "selector-root-invalid" || ast.type === "selector-pseudo") {
|
43748 | newObj.value = newObj.value.toLowerCase();
|
43749 | }
|
43750 |
|
43751 | if (ast.type === "css-decl") {
|
43752 | newObj.prop = newObj.prop.toLowerCase();
|
43753 | }
|
43754 |
|
43755 | if (ast.type === "css-atrule" || ast.type === "css-import") {
|
43756 | newObj.name = newObj.name.toLowerCase();
|
43757 | }
|
43758 |
|
43759 | if (ast.type === "value-number") {
|
43760 | newObj.unit = newObj.unit.toLowerCase();
|
43761 | }
|
43762 |
|
43763 | if ((ast.type === "media-feature" || ast.type === "media-keyword" || ast.type === "media-type" || ast.type === "media-unknown" || ast.type === "media-url" || ast.type === "media-value" || ast.type === "selector-attribute" || ast.type === "selector-string" || ast.type === "selector-class" || ast.type === "selector-combinator" || ast.type === "value-string") && newObj.value) {
|
43764 | newObj.value = cleanCSSStrings(newObj.value);
|
43765 | }
|
43766 |
|
43767 | if (ast.type === "selector-attribute") {
|
43768 | newObj.attribute = newObj.attribute.trim();
|
43769 |
|
43770 | if (newObj.namespace) {
|
43771 | if (typeof newObj.namespace === "string") {
|
43772 | newObj.namespace = newObj.namespace.trim();
|
43773 |
|
43774 | if (newObj.namespace.length === 0) {
|
43775 | newObj.namespace = true;
|
43776 | }
|
43777 | }
|
43778 | }
|
43779 |
|
43780 | if (newObj.value) {
|
43781 | newObj.value = newObj.value.trim().replace(/^['"]|['"]$/g, "");
|
43782 | delete newObj.quoted;
|
43783 | }
|
43784 | }
|
43785 |
|
43786 | if ((ast.type === "media-value" || ast.type === "media-type" || ast.type === "value-number" || ast.type === "selector-root-invalid" || ast.type === "selector-class" || ast.type === "selector-combinator" || ast.type === "selector-tag") && newObj.value) {
|
43787 | newObj.value = newObj.value.replace(/([\d.eE+-]+)([a-zA-Z]*)/g, (match, numStr, unit) => {
|
43788 | const num = Number(numStr);
|
43789 | return isNaN(num) ? match : num + unit.toLowerCase();
|
43790 | });
|
43791 | }
|
43792 |
|
43793 | if (ast.type === "selector-tag") {
|
43794 | const lowercasedValue = ast.value.toLowerCase();
|
43795 |
|
43796 | if (["from", "to"].includes(lowercasedValue)) {
|
43797 | newObj.value = lowercasedValue;
|
43798 | }
|
43799 | }
|
43800 |
|
43801 |
|
43802 | if (ast.type === "css-atrule" && ast.name.toLowerCase() === "supports") {
|
43803 | delete newObj.value;
|
43804 | }
|
43805 |
|
43806 |
|
43807 | if (ast.type === "selector-unknown") {
|
43808 | delete newObj.value;
|
43809 | }
|
43810 | }
|
43811 |
|
43812 | function cleanCSSStrings(value) {
|
43813 | return value.replace(/'/g, '"').replace(/\\([^a-fA-F\d])/g, "$1");
|
43814 | }
|
43815 |
|
43816 | var clean_1$1 = clean$2;
|
43817 |
|
43818 | const {
|
43819 | builders: {
|
43820 | hardline: hardline$6,
|
43821 | literalline: literalline$3,
|
43822 | concat: concat$8,
|
43823 | markAsRoot: markAsRoot$1
|
43824 | },
|
43825 | utils: {
|
43826 | mapDoc: mapDoc$2
|
43827 | }
|
43828 | } = document;
|
43829 |
|
43830 | function embed$1(path, print, textToDoc
|
43831 | /*, options */
|
43832 | ) {
|
43833 | const node = path.getValue();
|
43834 |
|
43835 | if (node.type === "yaml") {
|
43836 | return markAsRoot$1(concat$8(["---", hardline$6, node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
|
43837 | parser: "yaml"
|
43838 | })) : "", "---", hardline$6]));
|
43839 | }
|
43840 |
|
43841 | return null;
|
43842 |
|
43843 | function replaceNewlinesWithLiterallines(doc) {
|
43844 | return mapDoc$2(doc, currentDoc => typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$8(currentDoc.split(/(\n)/g).map((v, i) => i % 2 === 0 ? v : literalline$3)) : currentDoc);
|
43845 | }
|
43846 | }
|
43847 |
|
43848 | var embed_1$1 = embed$1;
|
43849 |
|
43850 | const DELIMITER_MAP = {
|
43851 | "---": "yaml",
|
43852 | "+++": "toml"
|
43853 | };
|
43854 |
|
43855 | function parse$5(text) {
|
43856 | const delimiterRegex = Object.keys(DELIMITER_MAP).map(escapeStringRegexp$2).join("|");
|
43857 | const match = text.match(
|
43858 | new RegExp(`^(${delimiterRegex})[^\\n\\S]*\\n(?:([\\s\\S]*?)\\n)?\\1[^\\n\\S]*(\\n|$)`));
|
43859 |
|
43860 | if (match === null) {
|
43861 | return {
|
43862 | frontMatter: null,
|
43863 | content: text
|
43864 | };
|
43865 | }
|
43866 |
|
43867 | const [raw, delimiter, value] = match;
|
43868 | return {
|
43869 | frontMatter: {
|
43870 | type: DELIMITER_MAP[delimiter],
|
43871 | value,
|
43872 | raw: raw.replace(/\n$/, "")
|
43873 | },
|
43874 | content: raw.replace(/[^\n]/g, " ") + text.slice(raw.length)
|
43875 | };
|
43876 | }
|
43877 |
|
43878 | var frontMatter = parse$5;
|
43879 |
|
43880 | function hasPragma$1(text) {
|
43881 | return pragma.hasPragma(frontMatter(text).content);
|
43882 | }
|
43883 |
|
43884 | function insertPragma$2(text) {
|
43885 | const {
|
43886 | frontMatter: frontMatter$1,
|
43887 | content
|
43888 | } = frontMatter(text);
|
43889 | return (frontMatter$1 ? frontMatter$1.raw + "\n\n" : "") + pragma.insertPragma(content);
|
43890 | }
|
43891 |
|
43892 | var pragma$1 = {
|
43893 | hasPragma: hasPragma$1,
|
43894 | insertPragma: insertPragma$2
|
43895 | };
|
43896 |
|
43897 | var lineColumnToIndex = function (lineColumn, text) {
|
43898 | let index = 0;
|
43899 |
|
43900 | for (let i = 0; i < lineColumn.line - 1; ++i) {
|
43901 | index = text.indexOf("\n", index) + 1;
|
43902 |
|
43903 | if (index === -1) {
|
43904 | return -1;
|
43905 | }
|
43906 | }
|
43907 |
|
43908 | return index + lineColumn.column;
|
43909 | };
|
43910 |
|
43911 | const {
|
43912 | getLast: getLast$3,
|
43913 | skipEverythingButNewLine: skipEverythingButNewLine$2
|
43914 | } = util$1;
|
43915 |
|
43916 | function calculateLocStart(node, text) {
|
43917 | if (node.source) {
|
43918 | return lineColumnToIndex(node.source.start, text) - 1;
|
43919 | }
|
43920 |
|
43921 | return null;
|
43922 | }
|
43923 |
|
43924 | function calculateLocEnd(node, text) {
|
43925 | if (node.type === "css-comment" && node.inline) {
|
43926 | return skipEverythingButNewLine$2(text, node.source.startOffset);
|
43927 | }
|
43928 |
|
43929 | const endNode = node.nodes && getLast$3(node.nodes);
|
43930 |
|
43931 | if (endNode && node.source && !node.source.end) {
|
43932 | node = endNode;
|
43933 | }
|
43934 |
|
43935 | if (node.source && node.source.end) {
|
43936 | return lineColumnToIndex(node.source.end, text);
|
43937 | }
|
43938 |
|
43939 | return null;
|
43940 | }
|
43941 |
|
43942 | function calculateLoc(node, text) {
|
43943 | if (node && typeof node === "object") {
|
43944 | if (node.source) {
|
43945 | node.source.startOffset = calculateLocStart(node, text);
|
43946 | node.source.endOffset = calculateLocEnd(node, text);
|
43947 | }
|
43948 |
|
43949 | for (const key in node) {
|
43950 | calculateLoc(node[key], text);
|
43951 | }
|
43952 | }
|
43953 | }
|
43954 |
|
43955 |
|
43956 |
|
43957 |
|
43958 |
|
43959 |
|
43960 |
|
43961 |
|
43962 |
|
43963 |
|
43964 |
|
43965 |
|
43966 | function replaceQuotesInInlineComments(text) {
|
43967 |
|
43968 |
|
43969 |
|
43970 | let state = "initial";
|
43971 |
|
43972 |
|
43973 | let stateToReturnFromQuotes = "initial";
|
43974 | let inlineCommentStartIndex;
|
43975 | let inlineCommentContainsQuotes = false;
|
43976 | const inlineCommentsToReplace = [];
|
43977 |
|
43978 | for (let i = 0; i < text.length; i++) {
|
43979 | const c = text[i];
|
43980 |
|
43981 | switch (state) {
|
43982 | case "initial":
|
43983 | if (c === "'") {
|
43984 | state = "single-quotes";
|
43985 | continue;
|
43986 | }
|
43987 |
|
43988 | if (c === '"') {
|
43989 | state = "double-quotes";
|
43990 | continue;
|
43991 | }
|
43992 |
|
43993 | if ((c === "u" || c === "U") && text.slice(i, i + 4).toLowerCase() === "url(") {
|
43994 | state = "url";
|
43995 | i += 3;
|
43996 | continue;
|
43997 | }
|
43998 |
|
43999 | if (c === "*" && text[i - 1] === "/") {
|
44000 | state = "comment-block";
|
44001 | continue;
|
44002 | }
|
44003 |
|
44004 | if (c === "/" && text[i - 1] === "/") {
|
44005 | state = "comment-inline";
|
44006 | inlineCommentStartIndex = i - 1;
|
44007 | continue;
|
44008 | }
|
44009 |
|
44010 | continue;
|
44011 |
|
44012 | case "single-quotes":
|
44013 | if (c === "'" && text[i - 1] !== "\\") {
|
44014 | state = stateToReturnFromQuotes;
|
44015 | stateToReturnFromQuotes = "initial";
|
44016 | }
|
44017 |
|
44018 | if (c === "\n" || c === "\r") {
|
44019 | return text;
|
44020 | }
|
44021 |
|
44022 | continue;
|
44023 |
|
44024 | case "double-quotes":
|
44025 | if (c === '"' && text[i - 1] !== "\\") {
|
44026 | state = stateToReturnFromQuotes;
|
44027 | stateToReturnFromQuotes = "initial";
|
44028 | }
|
44029 |
|
44030 | if (c === "\n" || c === "\r") {
|
44031 | return text;
|
44032 | }
|
44033 |
|
44034 | continue;
|
44035 |
|
44036 | case "url":
|
44037 | if (c === ")") {
|
44038 | state = "initial";
|
44039 | }
|
44040 |
|
44041 | if (c === "\n" || c === "\r") {
|
44042 | return text;
|
44043 | }
|
44044 |
|
44045 | if (c === "'") {
|
44046 | state = "single-quotes";
|
44047 | stateToReturnFromQuotes = "url";
|
44048 | continue;
|
44049 | }
|
44050 |
|
44051 | if (c === '"') {
|
44052 | state = "double-quotes";
|
44053 | stateToReturnFromQuotes = "url";
|
44054 | continue;
|
44055 | }
|
44056 |
|
44057 | continue;
|
44058 |
|
44059 | case "comment-block":
|
44060 | if (c === "/" && text[i - 1] === "*") {
|
44061 | state = "initial";
|
44062 | }
|
44063 |
|
44064 | continue;
|
44065 |
|
44066 | case "comment-inline":
|
44067 | if (c === '"' || c === "'") {
|
44068 | inlineCommentContainsQuotes = true;
|
44069 | }
|
44070 |
|
44071 | if (c === "\n" || c === "\r") {
|
44072 | if (inlineCommentContainsQuotes) {
|
44073 | inlineCommentsToReplace.push([inlineCommentStartIndex, i]);
|
44074 | }
|
44075 |
|
44076 | state = "initial";
|
44077 | inlineCommentContainsQuotes = false;
|
44078 | }
|
44079 |
|
44080 | continue;
|
44081 | }
|
44082 | }
|
44083 |
|
44084 | for (const [start, end] of inlineCommentsToReplace) {
|
44085 | text = text.slice(0, start) + text.slice(start, end).replace(/'/g, "\ufffe").replace(/"/g, "\uffff") + text.slice(end);
|
44086 | }
|
44087 |
|
44088 | return text;
|
44089 | }
|
44090 |
|
44091 | function restoreQuotesInInlineComments(text) {
|
44092 | return text.replace(/\ufffe/g, "'").replace(/\uffff/g, '"');
|
44093 | }
|
44094 |
|
44095 | var loc$1 = {
|
44096 | calculateLoc,
|
44097 | replaceQuotesInInlineComments,
|
44098 | restoreQuotesInInlineComments
|
44099 | };
|
44100 |
|
44101 | const colorAdjusterFunctions = ["red", "green", "blue", "alpha", "a", "rgb", "hue", "h", "saturation", "s", "lightness", "l", "whiteness", "w", "blackness", "b", "tint", "shade", "blend", "blenda", "contrast", "hsl", "hsla", "hwb", "hwba"];
|
44102 |
|
44103 | function getAncestorCounter(path, typeOrTypes) {
|
44104 | const types = [].concat(typeOrTypes);
|
44105 | let counter = -1;
|
44106 | let ancestorNode;
|
44107 |
|
44108 | while (ancestorNode = path.getParentNode(++counter)) {
|
44109 | if (types.includes(ancestorNode.type)) {
|
44110 | return counter;
|
44111 | }
|
44112 | }
|
44113 |
|
44114 | return -1;
|
44115 | }
|
44116 |
|
44117 | function getAncestorNode(path, typeOrTypes) {
|
44118 | const counter = getAncestorCounter(path, typeOrTypes);
|
44119 | return counter === -1 ? null : path.getParentNode(counter);
|
44120 | }
|
44121 |
|
44122 | function getPropOfDeclNode(path) {
|
44123 | const declAncestorNode = getAncestorNode(path, "css-decl");
|
44124 | return declAncestorNode && declAncestorNode.prop && declAncestorNode.prop.toLowerCase();
|
44125 | }
|
44126 |
|
44127 | function isSCSS(parser, text) {
|
44128 | const hasExplicitParserChoice = parser === "less" || parser === "scss";
|
44129 | const IS_POSSIBLY_SCSS = /(\w\s*:\s*[^}:]+|#){|@import[^\n]+(?:url|,)/;
|
44130 | return hasExplicitParserChoice ? parser === "scss" : IS_POSSIBLY_SCSS.test(text);
|
44131 | }
|
44132 |
|
44133 | function isWideKeywords(value) {
|
44134 | return ["initial", "inherit", "unset", "revert"].includes(value.toLowerCase());
|
44135 | }
|
44136 |
|
44137 | function isKeyframeAtRuleKeywords(path, value) {
|
44138 | const atRuleAncestorNode = getAncestorNode(path, "css-atrule");
|
44139 | return atRuleAncestorNode && atRuleAncestorNode.name && atRuleAncestorNode.name.toLowerCase().endsWith("keyframes") && ["from", "to"].includes(value.toLowerCase());
|
44140 | }
|
44141 |
|
44142 | function maybeToLowerCase(value) {
|
44143 | return value.includes("$") || value.includes("@") || value.includes("#") || value.startsWith("%") || value.startsWith("--") || value.startsWith(":--") || value.includes("(") && value.includes(")") ? value : value.toLowerCase();
|
44144 | }
|
44145 |
|
44146 | function insideValueFunctionNode(path, functionName) {
|
44147 | const funcAncestorNode = getAncestorNode(path, "value-func");
|
44148 | return funcAncestorNode && funcAncestorNode.value && funcAncestorNode.value.toLowerCase() === functionName;
|
44149 | }
|
44150 |
|
44151 | function insideICSSRuleNode(path) {
|
44152 | const ruleAncestorNode = getAncestorNode(path, "css-rule");
|
44153 | return ruleAncestorNode && ruleAncestorNode.raws && ruleAncestorNode.raws.selector && (ruleAncestorNode.raws.selector.startsWith(":import") || ruleAncestorNode.raws.selector.startsWith(":export"));
|
44154 | }
|
44155 |
|
44156 | function insideAtRuleNode(path, atRuleNameOrAtRuleNames) {
|
44157 | const atRuleNames = [].concat(atRuleNameOrAtRuleNames);
|
44158 | const atRuleAncestorNode = getAncestorNode(path, "css-atrule");
|
44159 | return atRuleAncestorNode && atRuleNames.includes(atRuleAncestorNode.name.toLowerCase());
|
44160 | }
|
44161 |
|
44162 | function insideURLFunctionInImportAtRuleNode(path) {
|
44163 | const node = path.getValue();
|
44164 | const atRuleAncestorNode = getAncestorNode(path, "css-atrule");
|
44165 | return atRuleAncestorNode && atRuleAncestorNode.name === "import" && node.groups[0].value === "url" && node.groups.length === 2;
|
44166 | }
|
44167 |
|
44168 | function isURLFunctionNode(node) {
|
44169 | return node.type === "value-func" && node.value.toLowerCase() === "url";
|
44170 | }
|
44171 |
|
44172 | function isLastNode(path, node) {
|
44173 | const parentNode = path.getParentNode();
|
44174 |
|
44175 | if (!parentNode) {
|
44176 | return false;
|
44177 | }
|
44178 |
|
44179 | const {
|
44180 | nodes
|
44181 | } = parentNode;
|
44182 | return nodes && nodes.indexOf(node) === nodes.length - 1;
|
44183 | }
|
44184 |
|
44185 | function isDetachedRulesetDeclarationNode(node) {
|
44186 |
|
44187 |
|
44188 |
|
44189 | if (!node.selector) {
|
44190 | return false;
|
44191 | }
|
44192 |
|
44193 | return typeof node.selector === "string" && /^@.+:.*$/.test(node.selector) || node.selector.value && /^@.+:.*$/.test(node.selector.value);
|
44194 | }
|
44195 |
|
44196 | function isForKeywordNode(node) {
|
44197 | return node.type === "value-word" && ["from", "through", "end"].includes(node.value);
|
44198 | }
|
44199 |
|
44200 | function isIfElseKeywordNode(node) {
|
44201 | return node.type === "value-word" && ["and", "or", "not"].includes(node.value);
|
44202 | }
|
44203 |
|
44204 | function isEachKeywordNode(node) {
|
44205 | return node.type === "value-word" && node.value === "in";
|
44206 | }
|
44207 |
|
44208 | function isMultiplicationNode(node) {
|
44209 | return node.type === "value-operator" && node.value === "*";
|
44210 | }
|
44211 |
|
44212 | function isDivisionNode(node) {
|
44213 | return node.type === "value-operator" && node.value === "/";
|
44214 | }
|
44215 |
|
44216 | function isAdditionNode(node) {
|
44217 | return node.type === "value-operator" && node.value === "+";
|
44218 | }
|
44219 |
|
44220 | function isSubtractionNode(node) {
|
44221 | return node.type === "value-operator" && node.value === "-";
|
44222 | }
|
44223 |
|
44224 | function isModuloNode(node) {
|
44225 | return node.type === "value-operator" && node.value === "%";
|
44226 | }
|
44227 |
|
44228 | function isMathOperatorNode(node) {
|
44229 | return isMultiplicationNode(node) || isDivisionNode(node) || isAdditionNode(node) || isSubtractionNode(node) || isModuloNode(node);
|
44230 | }
|
44231 |
|
44232 | function isEqualityOperatorNode(node) {
|
44233 | return node.type === "value-word" && ["==", "!="].includes(node.value);
|
44234 | }
|
44235 |
|
44236 | function isRelationalOperatorNode(node) {
|
44237 | return node.type === "value-word" && ["<", ">", "<=", ">="].includes(node.value);
|
44238 | }
|
44239 |
|
44240 | function isSCSSControlDirectiveNode(node) {
|
44241 | return node.type === "css-atrule" && ["if", "else", "for", "each", "while"].includes(node.name);
|
44242 | }
|
44243 |
|
44244 | function isSCSSNestedPropertyNode(node) {
|
44245 | if (!node.selector) {
|
44246 | return false;
|
44247 | }
|
44248 |
|
44249 | return node.selector.replace(/\/\*.*?\*\//, "").replace(/\/\/.*?\n/, "").trim().endsWith(":");
|
44250 | }
|
44251 |
|
44252 | function isDetachedRulesetCallNode(node) {
|
44253 | return node.raws && node.raws.params && /^\(\s*\)$/.test(node.raws.params);
|
44254 | }
|
44255 |
|
44256 | function isTemplatePlaceholderNode(node) {
|
44257 | return node.name.startsWith("prettier-placeholder");
|
44258 | }
|
44259 |
|
44260 | function isTemplatePropNode(node) {
|
44261 | return node.prop.startsWith("@prettier-placeholder");
|
44262 | }
|
44263 |
|
44264 | function isPostcssSimpleVarNode(currentNode, nextNode) {
|
44265 | return currentNode.value === "$$" && currentNode.type === "value-func" && nextNode && nextNode.type === "value-word" && !nextNode.raws.before;
|
44266 | }
|
44267 |
|
44268 | function hasComposesNode(node) {
|
44269 | return node.value && node.value.type === "value-root" && node.value.group && node.value.group.type === "value-value" && node.prop.toLowerCase() === "composes";
|
44270 | }
|
44271 |
|
44272 | function hasParensAroundNode(node) {
|
44273 | return node.value && node.value.group && node.value.group.group && node.value.group.group.type === "value-paren_group" && node.value.group.group.open !== null && node.value.group.group.close !== null;
|
44274 | }
|
44275 |
|
44276 | function hasEmptyRawBefore(node) {
|
44277 | return node.raws && node.raws.before === "";
|
44278 | }
|
44279 |
|
44280 | function isKeyValuePairNode(node) {
|
44281 | return node.type === "value-comma_group" && node.groups && node.groups[1] && node.groups[1].type === "value-colon";
|
44282 | }
|
44283 |
|
44284 | function isKeyValuePairInParenGroupNode(node) {
|
44285 | return node.type === "value-paren_group" && node.groups && node.groups[0] && isKeyValuePairNode(node.groups[0]);
|
44286 | }
|
44287 |
|
44288 | function isSCSSMapItemNode(path) {
|
44289 | const node = path.getValue();
|
44290 |
|
44291 | if (node.groups.length === 0) {
|
44292 | return false;
|
44293 | }
|
44294 |
|
44295 | const parentParentNode = path.getParentNode(1);
|
44296 |
|
44297 | if (!isKeyValuePairInParenGroupNode(node) && !(parentParentNode && isKeyValuePairInParenGroupNode(parentParentNode))) {
|
44298 | return false;
|
44299 | }
|
44300 |
|
44301 | const declNode = getAncestorNode(path, "css-decl");
|
44302 |
|
44303 | if (declNode && declNode.prop && declNode.prop.startsWith("$")) {
|
44304 | return true;
|
44305 | }
|
44306 |
|
44307 |
|
44308 | if (isKeyValuePairInParenGroupNode(parentParentNode)) {
|
44309 | return true;
|
44310 | }
|
44311 |
|
44312 |
|
44313 | if (parentParentNode.type === "value-func") {
|
44314 | return true;
|
44315 | }
|
44316 |
|
44317 | return false;
|
44318 | }
|
44319 |
|
44320 | function isInlineValueCommentNode(node) {
|
44321 | return node.type === "value-comment" && node.inline;
|
44322 | }
|
44323 |
|
44324 | function isHashNode(node) {
|
44325 | return node.type === "value-word" && node.value === "#";
|
44326 | }
|
44327 |
|
44328 | function isLeftCurlyBraceNode(node) {
|
44329 | return node.type === "value-word" && node.value === "{";
|
44330 | }
|
44331 |
|
44332 | function isRightCurlyBraceNode(node) {
|
44333 | return node.type === "value-word" && node.value === "}";
|
44334 | }
|
44335 |
|
44336 | function isWordNode(node) {
|
44337 | return ["value-word", "value-atword"].includes(node.type);
|
44338 | }
|
44339 |
|
44340 | function isColonNode(node) {
|
44341 | return node.type === "value-colon";
|
44342 | }
|
44343 |
|
44344 | function isMediaAndSupportsKeywords(node) {
|
44345 | return node.value && ["not", "and", "or"].includes(node.value.toLowerCase());
|
44346 | }
|
44347 |
|
44348 | function isColorAdjusterFuncNode(node) {
|
44349 | if (node.type !== "value-func") {
|
44350 | return false;
|
44351 | }
|
44352 |
|
44353 | return colorAdjusterFunctions.includes(node.value.toLowerCase());
|
44354 | }
|
44355 |
|
44356 |
|
44357 | function isLessParser(options) {
|
44358 | return options.parser === "css" || options.parser === "less";
|
44359 | }
|
44360 |
|
44361 | function lastLineHasInlineComment(text) {
|
44362 | return /\/\//.test(text.split(/[\r\n]/).pop());
|
44363 | }
|
44364 |
|
44365 | var utils$7 = {
|
44366 | getAncestorCounter,
|
44367 | getAncestorNode,
|
44368 | getPropOfDeclNode,
|
44369 | maybeToLowerCase,
|
44370 | insideValueFunctionNode,
|
44371 | insideICSSRuleNode,
|
44372 | insideAtRuleNode,
|
44373 | insideURLFunctionInImportAtRuleNode,
|
44374 | isKeyframeAtRuleKeywords,
|
44375 | isWideKeywords,
|
44376 | isSCSS,
|
44377 | isLastNode,
|
44378 | isLessParser,
|
44379 | isSCSSControlDirectiveNode,
|
44380 | isDetachedRulesetDeclarationNode,
|
44381 | isRelationalOperatorNode,
|
44382 | isEqualityOperatorNode,
|
44383 | isMultiplicationNode,
|
44384 | isDivisionNode,
|
44385 | isAdditionNode,
|
44386 | isSubtractionNode,
|
44387 | isModuloNode,
|
44388 | isMathOperatorNode,
|
44389 | isEachKeywordNode,
|
44390 | isForKeywordNode,
|
44391 | isURLFunctionNode,
|
44392 | isIfElseKeywordNode,
|
44393 | hasComposesNode,
|
44394 | hasParensAroundNode,
|
44395 | hasEmptyRawBefore,
|
44396 | isSCSSNestedPropertyNode,
|
44397 | isDetachedRulesetCallNode,
|
44398 | isTemplatePlaceholderNode,
|
44399 | isTemplatePropNode,
|
44400 | isPostcssSimpleVarNode,
|
44401 | isKeyValuePairNode,
|
44402 | isKeyValuePairInParenGroupNode,
|
44403 | isSCSSMapItemNode,
|
44404 | isInlineValueCommentNode,
|
44405 | isHashNode,
|
44406 | isLeftCurlyBraceNode,
|
44407 | isRightCurlyBraceNode,
|
44408 | isWordNode,
|
44409 | isColonNode,
|
44410 | isMediaAndSupportsKeywords,
|
44411 | isColorAdjusterFuncNode,
|
44412 | lastLineHasInlineComment
|
44413 | };
|
44414 |
|
44415 | const {
|
44416 | insertPragma: insertPragma$3
|
44417 | } = pragma$1;
|
44418 | const {
|
44419 | printNumber: printNumber$2,
|
44420 | printString: printString$2,
|
44421 | hasIgnoreComment: hasIgnoreComment$3,
|
44422 | hasNewline: hasNewline$5
|
44423 | } = util$1;
|
44424 | const {
|
44425 | isNextLineEmpty: isNextLineEmpty$3
|
44426 | } = utilShared;
|
44427 | const {
|
44428 | restoreQuotesInInlineComments: restoreQuotesInInlineComments$1
|
44429 | } = loc$1;
|
44430 | const {
|
44431 | builders: {
|
44432 | concat: concat$9,
|
44433 | join: join$6,
|
44434 | line: line$5,
|
44435 | hardline: hardline$7,
|
44436 | softline: softline$3,
|
44437 | group: group$6,
|
44438 | fill: fill$4,
|
44439 | indent: indent$5,
|
44440 | dedent: dedent$2,
|
44441 | ifBreak: ifBreak$2
|
44442 | },
|
44443 | utils: {
|
44444 | removeLines: removeLines$2
|
44445 | }
|
44446 | } = document;
|
44447 | const {
|
44448 | getAncestorNode: getAncestorNode$1,
|
44449 | getPropOfDeclNode: getPropOfDeclNode$1,
|
44450 | maybeToLowerCase: maybeToLowerCase$1,
|
44451 | insideValueFunctionNode: insideValueFunctionNode$1,
|
44452 | insideICSSRuleNode: insideICSSRuleNode$1,
|
44453 | insideAtRuleNode: insideAtRuleNode$1,
|
44454 | insideURLFunctionInImportAtRuleNode: insideURLFunctionInImportAtRuleNode$1,
|
44455 | isKeyframeAtRuleKeywords: isKeyframeAtRuleKeywords$1,
|
44456 | isWideKeywords: isWideKeywords$1,
|
44457 | isSCSS: isSCSS$1,
|
44458 | isLastNode: isLastNode$1,
|
44459 | isLessParser: isLessParser$1,
|
44460 | isSCSSControlDirectiveNode: isSCSSControlDirectiveNode$1,
|
44461 | isDetachedRulesetDeclarationNode: isDetachedRulesetDeclarationNode$1,
|
44462 | isRelationalOperatorNode: isRelationalOperatorNode$1,
|
44463 | isEqualityOperatorNode: isEqualityOperatorNode$1,
|
44464 | isMultiplicationNode: isMultiplicationNode$1,
|
44465 | isDivisionNode: isDivisionNode$1,
|
44466 | isAdditionNode: isAdditionNode$1,
|
44467 | isSubtractionNode: isSubtractionNode$1,
|
44468 | isMathOperatorNode: isMathOperatorNode$1,
|
44469 | isEachKeywordNode: isEachKeywordNode$1,
|
44470 | isForKeywordNode: isForKeywordNode$1,
|
44471 | isURLFunctionNode: isURLFunctionNode$1,
|
44472 | isIfElseKeywordNode: isIfElseKeywordNode$1,
|
44473 | hasComposesNode: hasComposesNode$1,
|
44474 | hasParensAroundNode: hasParensAroundNode$1,
|
44475 | hasEmptyRawBefore: hasEmptyRawBefore$1,
|
44476 | isKeyValuePairNode: isKeyValuePairNode$1,
|
44477 | isDetachedRulesetCallNode: isDetachedRulesetCallNode$1,
|
44478 | isTemplatePlaceholderNode: isTemplatePlaceholderNode$1,
|
44479 | isTemplatePropNode: isTemplatePropNode$1,
|
44480 | isPostcssSimpleVarNode: isPostcssSimpleVarNode$1,
|
44481 | isSCSSMapItemNode: isSCSSMapItemNode$1,
|
44482 | isInlineValueCommentNode: isInlineValueCommentNode$1,
|
44483 | isHashNode: isHashNode$1,
|
44484 | isLeftCurlyBraceNode: isLeftCurlyBraceNode$1,
|
44485 | isRightCurlyBraceNode: isRightCurlyBraceNode$1,
|
44486 | isWordNode: isWordNode$1,
|
44487 | isColonNode: isColonNode$1,
|
44488 | isMediaAndSupportsKeywords: isMediaAndSupportsKeywords$1,
|
44489 | isColorAdjusterFuncNode: isColorAdjusterFuncNode$1,
|
44490 | lastLineHasInlineComment: lastLineHasInlineComment$1
|
44491 | } = utils$7;
|
44492 |
|
44493 | function shouldPrintComma$1(options) {
|
44494 | switch (options.trailingComma) {
|
44495 | case "all":
|
44496 | case "es5":
|
44497 | return true;
|
44498 |
|
44499 | case "none":
|
44500 | default:
|
44501 | return false;
|
44502 | }
|
44503 | }
|
44504 |
|
44505 | function genericPrint$2(path, options, print) {
|
44506 | const node = path.getValue();
|
44507 |
|
44508 |
|
44509 | if (!node) {
|
44510 | return "";
|
44511 | }
|
44512 |
|
44513 | if (typeof node === "string") {
|
44514 | return node;
|
44515 | }
|
44516 |
|
44517 | switch (node.type) {
|
44518 | case "yaml":
|
44519 | case "toml":
|
44520 | return concat$9([node.raw, hardline$7]);
|
44521 |
|
44522 | case "css-root":
|
44523 | {
|
44524 | const nodes = printNodeSequence(path, options, print);
|
44525 |
|
44526 | if (nodes.parts.length) {
|
44527 | return concat$9([nodes, options.__isHTMLStyleAttribute ? "" : hardline$7]);
|
44528 | }
|
44529 |
|
44530 | return nodes;
|
44531 | }
|
44532 |
|
44533 | case "css-comment":
|
44534 | {
|
44535 | const isInlineComment = node.inline || node.raws.inline;
|
44536 | const text = options.originalText.slice(options.locStart(node), options.locEnd(node));
|
44537 | return isInlineComment ? text.trimEnd() : text;
|
44538 | }
|
44539 |
|
44540 | case "css-rule":
|
44541 | {
|
44542 | return concat$9([path.call(print, "selector"), node.important ? " !important" : "", node.nodes ? concat$9([node.selector && node.selector.type === "selector-unknown" && lastLineHasInlineComment$1(node.selector.value) ? line$5 : " ", "{", node.nodes.length > 0 ? indent$5(concat$9([hardline$7, printNodeSequence(path, options, print)])) : "", hardline$7, "}", isDetachedRulesetDeclarationNode$1(node) ? ";" : ""]) : ";"]);
|
44543 | }
|
44544 |
|
44545 | case "css-decl":
|
44546 | {
|
44547 | const parentNode = path.getParentNode();
|
44548 | return concat$9([node.raws.before.replace(/[\s;]/g, ""), insideICSSRuleNode$1(path) ? node.prop : maybeToLowerCase$1(node.prop), node.raws.between.trim() === ":" ? ":" : node.raws.between.trim(), node.extend ? "" : " ", hasComposesNode$1(node) ? removeLines$2(path.call(print, "value")) : path.call(print, "value"), node.raws.important ? node.raws.important.replace(/\s*!\s*important/i, " !important") : node.important ? " !important" : "", node.raws.scssDefault ? node.raws.scssDefault.replace(/\s*!default/i, " !default") : node.scssDefault ? " !default" : "", node.raws.scssGlobal ? node.raws.scssGlobal.replace(/\s*!global/i, " !global") : node.scssGlobal ? " !global" : "", node.nodes ? concat$9([" {", indent$5(concat$9([softline$3, printNodeSequence(path, options, print)])), softline$3, "}"]) : isTemplatePropNode$1(node) && !parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";" ? "" : ";"]);
|
44549 | }
|
44550 |
|
44551 | case "css-atrule":
|
44552 | {
|
44553 | const parentNode = path.getParentNode();
|
44554 | const isTemplatePlaceholderNodeWithoutSemiColon = isTemplatePlaceholderNode$1(node) && !parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";";
|
44555 |
|
44556 | if (isLessParser$1(options)) {
|
44557 | if (node.mixin) {
|
44558 | return concat$9([path.call(print, "selector"), node.important ? " !important" : "", isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"]);
|
44559 | }
|
44560 |
|
44561 | if (node.function) {
|
44562 | return concat$9([node.name, concat$9([path.call(print, "params")]), isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"]);
|
44563 | }
|
44564 |
|
44565 | if (node.variable) {
|
44566 | return concat$9(["@", node.name, ": ", node.value ? concat$9([path.call(print, "value")]) : "", node.raws.between.trim() ? node.raws.between.trim() + " " : "", node.nodes ? concat$9(["{", indent$5(concat$9([node.nodes.length > 0 ? softline$3 : "", printNodeSequence(path, options, print)])), softline$3, "}"]) : "", isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"]);
|
44567 | }
|
44568 | }
|
44569 |
|
44570 | return concat$9(["@",
|
44571 |
|
44572 |
|
44573 | isDetachedRulesetCallNode$1(node) || node.name.endsWith(":") ? node.name : maybeToLowerCase$1(node.name), node.params ? concat$9([isDetachedRulesetCallNode$1(node) ? "" : isTemplatePlaceholderNode$1(node) ? node.raws.afterName === "" ? "" : node.name.endsWith(":") ? " " : /^\s*\n\s*\n/.test(node.raws.afterName) ? concat$9([hardline$7, hardline$7]) : /^\s*\n/.test(node.raws.afterName) ? hardline$7 : " " : " ", path.call(print, "params")]) : "", node.selector ? indent$5(concat$9([" ", path.call(print, "selector")])) : "", node.value ? group$6(concat$9([" ", path.call(print, "value"), isSCSSControlDirectiveNode$1(node) ? hasParensAroundNode$1(node) ? " " : line$5 : ""])) : node.name === "else" ? " " : "", node.nodes ? concat$9([isSCSSControlDirectiveNode$1(node) ? "" : " ", "{", indent$5(concat$9([node.nodes.length > 0 ? softline$3 : "", printNodeSequence(path, options, print)])), softline$3, "}"]) : isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"]);
|
44574 | }
|
44575 |
|
44576 |
|
44577 | case "media-query-list":
|
44578 | {
|
44579 | const parts = [];
|
44580 | path.each(childPath => {
|
44581 | const node = childPath.getValue();
|
44582 |
|
44583 | if (node.type === "media-query" && node.value === "") {
|
44584 | return;
|
44585 | }
|
44586 |
|
44587 | parts.push(childPath.call(print));
|
44588 | }, "nodes");
|
44589 | return group$6(indent$5(join$6(line$5, parts)));
|
44590 | }
|
44591 |
|
44592 | case "media-query":
|
44593 | {
|
44594 | return concat$9([join$6(" ", path.map(print, "nodes")), isLastNode$1(path, node) ? "" : ","]);
|
44595 | }
|
44596 |
|
44597 | case "media-type":
|
44598 | {
|
44599 | return adjustNumbers(adjustStrings(node.value, options));
|
44600 | }
|
44601 |
|
44602 | case "media-feature-expression":
|
44603 | {
|
44604 | if (!node.nodes) {
|
44605 | return node.value;
|
44606 | }
|
44607 |
|
44608 | return concat$9(["(", concat$9(path.map(print, "nodes")), ")"]);
|
44609 | }
|
44610 |
|
44611 | case "media-feature":
|
44612 | {
|
44613 | return maybeToLowerCase$1(adjustStrings(node.value.replace(/ +/g, " "), options));
|
44614 | }
|
44615 |
|
44616 | case "media-colon":
|
44617 | {
|
44618 | return concat$9([node.value, " "]);
|
44619 | }
|
44620 |
|
44621 | case "media-value":
|
44622 | {
|
44623 | return adjustNumbers(adjustStrings(node.value, options));
|
44624 | }
|
44625 |
|
44626 | case "media-keyword":
|
44627 | {
|
44628 | return adjustStrings(node.value, options);
|
44629 | }
|
44630 |
|
44631 | case "media-url":
|
44632 | {
|
44633 | return adjustStrings(node.value.replace(/^url\(\s+/gi, "url(").replace(/\s+\)$/gi, ")"), options);
|
44634 | }
|
44635 |
|
44636 | case "media-unknown":
|
44637 | {
|
44638 | return node.value;
|
44639 | }
|
44640 |
|
44641 |
|
44642 | case "selector-root":
|
44643 | {
|
44644 | return group$6(concat$9([insideAtRuleNode$1(path, "custom-selector") ? concat$9([getAncestorNode$1(path, "css-atrule").customSelector, line$5]) : "", join$6(concat$9([",", insideAtRuleNode$1(path, ["extend", "custom-selector", "nest"]) ? line$5 : hardline$7]), path.map(print, "nodes"))]));
|
44645 | }
|
44646 |
|
44647 | case "selector-selector":
|
44648 | {
|
44649 | return group$6(indent$5(concat$9(path.map(print, "nodes"))));
|
44650 | }
|
44651 |
|
44652 | case "selector-comment":
|
44653 | {
|
44654 | return node.value;
|
44655 | }
|
44656 |
|
44657 | case "selector-string":
|
44658 | {
|
44659 | return adjustStrings(node.value, options);
|
44660 | }
|
44661 |
|
44662 | case "selector-tag":
|
44663 | {
|
44664 | const parentNode = path.getParentNode();
|
44665 | const index = parentNode && parentNode.nodes.indexOf(node);
|
44666 | const prevNode = index && parentNode.nodes[index - 1];
|
44667 | return concat$9([node.namespace ? concat$9([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", prevNode.type === "selector-nesting" ? node.value : adjustNumbers(isKeyframeAtRuleKeywords$1(path, node.value) ? node.value.toLowerCase() : node.value)]);
|
44668 | }
|
44669 |
|
44670 | case "selector-id":
|
44671 | {
|
44672 | return concat$9(["#", node.value]);
|
44673 | }
|
44674 |
|
44675 | case "selector-class":
|
44676 | {
|
44677 | return concat$9([".", adjustNumbers(adjustStrings(node.value, options))]);
|
44678 | }
|
44679 |
|
44680 | case "selector-attribute":
|
44681 | {
|
44682 | return concat$9(["[", node.namespace ? concat$9([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", node.attribute.trim(), node.operator ? node.operator : "", node.value ? quoteAttributeValue(adjustStrings(node.value.trim(), options), options) : "", node.insensitive ? " i" : "", "]"]);
|
44683 | }
|
44684 |
|
44685 | case "selector-combinator":
|
44686 | {
|
44687 | if (node.value === "+" || node.value === ">" || node.value === "~" || node.value === ">>>") {
|
44688 | const parentNode = path.getParentNode();
|
44689 | const leading = parentNode.type === "selector-selector" && parentNode.nodes[0] === node ? "" : line$5;
|
44690 | return concat$9([leading, node.value, isLastNode$1(path, node) ? "" : " "]);
|
44691 | }
|
44692 |
|
44693 | const leading = node.value.trim().startsWith("(") ? line$5 : "";
|
44694 | const value = adjustNumbers(adjustStrings(node.value.trim(), options)) || line$5;
|
44695 | return concat$9([leading, value]);
|
44696 | }
|
44697 |
|
44698 | case "selector-universal":
|
44699 | {
|
44700 | return concat$9([node.namespace ? concat$9([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", node.value]);
|
44701 | }
|
44702 |
|
44703 | case "selector-pseudo":
|
44704 | {
|
44705 | return concat$9([maybeToLowerCase$1(node.value), node.nodes && node.nodes.length > 0 ? concat$9(["(", join$6(", ", path.map(print, "nodes")), ")"]) : ""]);
|
44706 | }
|
44707 |
|
44708 | case "selector-nesting":
|
44709 | {
|
44710 | return node.value;
|
44711 | }
|
44712 |
|
44713 | case "selector-unknown":
|
44714 | {
|
44715 | const ruleAncestorNode = getAncestorNode$1(path, "css-rule");
|
44716 |
|
44717 | if (ruleAncestorNode && ruleAncestorNode.isSCSSNesterProperty) {
|
44718 | return adjustNumbers(adjustStrings(maybeToLowerCase$1(node.value), options));
|
44719 | }
|
44720 |
|
44721 |
|
44722 | const parentNode = path.getParentNode();
|
44723 |
|
44724 | if (parentNode.raws && parentNode.raws.selector) {
|
44725 | const start = options.locStart(parentNode);
|
44726 | const end = start + parentNode.raws.selector.length;
|
44727 | return options.originalText.slice(start, end).trim();
|
44728 | }
|
44729 |
|
44730 | return node.value;
|
44731 | }
|
44732 |
|
44733 |
|
44734 | case "value-value":
|
44735 | case "value-root":
|
44736 | {
|
44737 | return path.call(print, "group");
|
44738 | }
|
44739 |
|
44740 | case "value-comment":
|
44741 | {
|
44742 | return concat$9([node.inline ? "//" : "/*",
|
44743 |
|
44744 | restoreQuotesInInlineComments$1(node.value), node.inline ? "" : "*/"]);
|
44745 | }
|
44746 |
|
44747 | case "value-comma_group":
|
44748 | {
|
44749 | const parentNode = path.getParentNode();
|
44750 | const parentParentNode = path.getParentNode(1);
|
44751 | const declAncestorProp = getPropOfDeclNode$1(path);
|
44752 | const isGridValue = declAncestorProp && parentNode.type === "value-value" && (declAncestorProp === "grid" || declAncestorProp.startsWith("grid-template"));
|
44753 | const atRuleAncestorNode = getAncestorNode$1(path, "css-atrule");
|
44754 | const isControlDirective = atRuleAncestorNode && isSCSSControlDirectiveNode$1(atRuleAncestorNode);
|
44755 | const printed = path.map(print, "groups");
|
44756 | const parts = [];
|
44757 | const insideURLFunction = insideValueFunctionNode$1(path, "url");
|
44758 | let insideSCSSInterpolationInString = false;
|
44759 | let didBreak = false;
|
44760 |
|
44761 | for (let i = 0; i < node.groups.length; ++i) {
|
44762 | parts.push(printed[i]);
|
44763 | const iPrevNode = node.groups[i - 1];
|
44764 | const iNode = node.groups[i];
|
44765 | const iNextNode = node.groups[i + 1];
|
44766 | const iNextNextNode = node.groups[i + 2];
|
44767 |
|
44768 | if (insideURLFunction) {
|
44769 | if (iNextNode && isAdditionNode$1(iNextNode) || isAdditionNode$1(iNode)) {
|
44770 | parts.push(" ");
|
44771 | }
|
44772 |
|
44773 | continue;
|
44774 | }
|
44775 |
|
44776 |
|
44777 | if (!iNextNode) {
|
44778 | continue;
|
44779 | }
|
44780 |
|
44781 |
|
44782 | if (!iPrevNode && iNode.value === "--" && iNextNode.type === "value-atword") {
|
44783 | continue;
|
44784 | }
|
44785 |
|
44786 |
|
44787 | const isStartSCSSInterpolationInString = iNode.type === "value-string" && iNode.value.startsWith("#{");
|
44788 | const isEndingSCSSInterpolationInString = insideSCSSInterpolationInString && iNextNode.type === "value-string" && iNextNode.value.endsWith("}");
|
44789 |
|
44790 | if (isStartSCSSInterpolationInString || isEndingSCSSInterpolationInString) {
|
44791 | insideSCSSInterpolationInString = !insideSCSSInterpolationInString;
|
44792 | continue;
|
44793 | }
|
44794 |
|
44795 | if (insideSCSSInterpolationInString) {
|
44796 | continue;
|
44797 | }
|
44798 |
|
44799 |
|
44800 | if (isColonNode$1(iNode) || isColonNode$1(iNextNode)) {
|
44801 | continue;
|
44802 | }
|
44803 |
|
44804 |
|
44805 | if (iNode.type === "value-atword" && iNode.value === "") {
|
44806 | continue;
|
44807 | }
|
44808 |
|
44809 |
|
44810 | if (iNode.value === "~") {
|
44811 | continue;
|
44812 | }
|
44813 |
|
44814 |
|
44815 | if (iNode.value && iNode.value.includes("\\") && iNextNode && iNextNode.type !== "value-comment") {
|
44816 | continue;
|
44817 | }
|
44818 |
|
44819 |
|
44820 | if (iPrevNode && iPrevNode.value && iPrevNode.value.indexOf("\\") === iPrevNode.value.length - 1 && iNode.type === "value-operator" && iNode.value === "/") {
|
44821 | continue;
|
44822 | }
|
44823 |
|
44824 |
|
44825 | if (iNode.value === "\\") {
|
44826 | continue;
|
44827 | }
|
44828 |
|
44829 |
|
44830 | if (isPostcssSimpleVarNode$1(iNode, iNextNode)) {
|
44831 | continue;
|
44832 | }
|
44833 |
|
44834 |
|
44835 | if (isHashNode$1(iNode) || isLeftCurlyBraceNode$1(iNode) || isRightCurlyBraceNode$1(iNextNode) || isLeftCurlyBraceNode$1(iNextNode) && hasEmptyRawBefore$1(iNextNode) || isRightCurlyBraceNode$1(iNode) && hasEmptyRawBefore$1(iNextNode)) {
|
44836 | continue;
|
44837 | }
|
44838 |
|
44839 |
|
44840 | if (iNode.value === "--" && isHashNode$1(iNextNode)) {
|
44841 | continue;
|
44842 | }
|
44843 |
|
44844 |
|
44845 | const isMathOperator = isMathOperatorNode$1(iNode);
|
44846 | const isNextMathOperator = isMathOperatorNode$1(iNextNode);
|
44847 |
|
44848 |
|
44849 |
|
44850 | if ((isMathOperator && isHashNode$1(iNextNode) || isNextMathOperator && isRightCurlyBraceNode$1(iNode)) && hasEmptyRawBefore$1(iNextNode)) {
|
44851 | continue;
|
44852 | }
|
44853 |
|
44854 |
|
44855 |
|
44856 |
|
44857 | if (insideValueFunctionNode$1(path, "calc") && (isAdditionNode$1(iNode) || isAdditionNode$1(iNextNode) || isSubtractionNode$1(iNode) || isSubtractionNode$1(iNextNode)) && hasEmptyRawBefore$1(iNextNode)) {
|
44858 | continue;
|
44859 | }
|
44860 |
|
44861 |
|
44862 |
|
44863 | const isColorAdjusterNode = (isAdditionNode$1(iNode) || isSubtractionNode$1(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && parentParentNode && isColorAdjusterFuncNode$1(parentParentNode) && !hasEmptyRawBefore$1(iNextNode);
|
44864 | const requireSpaceBeforeOperator = iNextNextNode && iNextNextNode.type === "value-func" || iNextNextNode && isWordNode$1(iNextNextNode) || iNode.type === "value-func" || isWordNode$1(iNode);
|
44865 | const requireSpaceAfterOperator = iNextNode.type === "value-func" || isWordNode$1(iNextNode) || iPrevNode && iPrevNode.type === "value-func" || iPrevNode && isWordNode$1(iPrevNode);
|
44866 |
|
44867 | if (!(isMultiplicationNode$1(iNextNode) || isMultiplicationNode$1(iNode)) && !insideValueFunctionNode$1(path, "calc") && !isColorAdjusterNode && (isDivisionNode$1(iNextNode) && !requireSpaceBeforeOperator || isDivisionNode$1(iNode) && !requireSpaceAfterOperator || isAdditionNode$1(iNextNode) && !requireSpaceBeforeOperator || isAdditionNode$1(iNode) && !requireSpaceAfterOperator || isSubtractionNode$1(iNextNode) || isSubtractionNode$1(iNode)) && (hasEmptyRawBefore$1(iNextNode) || isMathOperator && (!iPrevNode || iPrevNode && isMathOperatorNode$1(iPrevNode)))) {
|
44868 | continue;
|
44869 | }
|
44870 |
|
44871 |
|
44872 | if (isInlineValueCommentNode$1(iNode)) {
|
44873 | parts.push(hardline$7);
|
44874 | continue;
|
44875 | }
|
44876 |
|
44877 |
|
44878 | if (isControlDirective && (isEqualityOperatorNode$1(iNextNode) || isRelationalOperatorNode$1(iNextNode) || isIfElseKeywordNode$1(iNextNode) || isEachKeywordNode$1(iNode) || isForKeywordNode$1(iNode))) {
|
44879 | parts.push(" ");
|
44880 | continue;
|
44881 | }
|
44882 |
|
44883 |
|
44884 | if (atRuleAncestorNode && atRuleAncestorNode.name.toLowerCase() === "namespace") {
|
44885 | parts.push(" ");
|
44886 | continue;
|
44887 | }
|
44888 |
|
44889 |
|
44890 | if (isGridValue) {
|
44891 | if (iNode.source && iNextNode.source && iNode.source.start.line !== iNextNode.source.start.line) {
|
44892 | parts.push(hardline$7);
|
44893 | didBreak = true;
|
44894 | } else {
|
44895 | parts.push(" ");
|
44896 | }
|
44897 |
|
44898 | continue;
|
44899 | }
|
44900 |
|
44901 |
|
44902 |
|
44903 |
|
44904 | if (isNextMathOperator) {
|
44905 | parts.push(" ");
|
44906 | continue;
|
44907 | }
|
44908 |
|
44909 |
|
44910 | parts.push(line$5);
|
44911 | }
|
44912 |
|
44913 | if (didBreak) {
|
44914 | parts.unshift(hardline$7);
|
44915 | }
|
44916 |
|
44917 | if (isControlDirective) {
|
44918 | return group$6(indent$5(concat$9(parts)));
|
44919 | }
|
44920 |
|
44921 |
|
44922 |
|
44923 |
|
44924 |
|
44925 | if (insideURLFunctionInImportAtRuleNode$1(path)) {
|
44926 | return group$6(fill$4(parts));
|
44927 | }
|
44928 |
|
44929 | return group$6(indent$5(fill$4(parts)));
|
44930 | }
|
44931 |
|
44932 | case "value-paren_group":
|
44933 | {
|
44934 | const parentNode = path.getParentNode();
|
44935 |
|
44936 | if (parentNode && isURLFunctionNode$1(parentNode) && (node.groups.length === 1 || node.groups.length > 0 && node.groups[0].type === "value-comma_group" && node.groups[0].groups.length > 0 && node.groups[0].groups[0].type === "value-word" && node.groups[0].groups[0].value.startsWith("data:"))) {
|
44937 | return concat$9([node.open ? path.call(print, "open") : "", join$6(",", path.map(print, "groups")), node.close ? path.call(print, "close") : ""]);
|
44938 | }
|
44939 |
|
44940 | if (!node.open) {
|
44941 | const printed = path.map(print, "groups");
|
44942 | const res = [];
|
44943 |
|
44944 | for (let i = 0; i < printed.length; i++) {
|
44945 | if (i !== 0) {
|
44946 | res.push(concat$9([",", line$5]));
|
44947 | }
|
44948 |
|
44949 | res.push(printed[i]);
|
44950 | }
|
44951 |
|
44952 | return group$6(indent$5(fill$4(res)));
|
44953 | }
|
44954 |
|
44955 | const isSCSSMapItem = isSCSSMapItemNode$1(path);
|
44956 | const lastItem = node.groups[node.groups.length - 1];
|
44957 | const isLastItemComment = lastItem && lastItem.type === "value-comment";
|
44958 | return group$6(concat$9([node.open ? path.call(print, "open") : "", indent$5(concat$9([softline$3, join$6(concat$9([",", line$5]), path.map(childPath => {
|
44959 | const node = childPath.getValue();
|
44960 | const printed = print(childPath);
|
44961 |
|
44962 | if (isKeyValuePairNode$1(node) && node.type === "value-comma_group" && node.groups && node.groups[2] && node.groups[2].type === "value-paren_group") {
|
44963 | printed.contents.contents.parts[1] = group$6(printed.contents.contents.parts[1]);
|
44964 | return group$6(dedent$2(printed));
|
44965 | }
|
44966 |
|
44967 | return printed;
|
44968 | }, "groups"))])), ifBreak$2(!isLastItemComment && isSCSS$1(options.parser, options.originalText) && isSCSSMapItem && shouldPrintComma$1(options) ? "," : ""), softline$3, node.close ? path.call(print, "close") : ""]), {
|
44969 | shouldBreak: isSCSSMapItem
|
44970 | });
|
44971 | }
|
44972 |
|
44973 | case "value-func":
|
44974 | {
|
44975 | return concat$9([node.value, insideAtRuleNode$1(path, "supports") && isMediaAndSupportsKeywords$1(node) ? " " : "", path.call(print, "group")]);
|
44976 | }
|
44977 |
|
44978 | case "value-paren":
|
44979 | {
|
44980 | return node.value;
|
44981 | }
|
44982 |
|
44983 | case "value-number":
|
44984 | {
|
44985 | return concat$9([printCssNumber(node.value), maybeToLowerCase$1(node.unit)]);
|
44986 | }
|
44987 |
|
44988 | case "value-operator":
|
44989 | {
|
44990 | return node.value;
|
44991 | }
|
44992 |
|
44993 | case "value-word":
|
44994 | {
|
44995 | if (node.isColor && node.isHex || isWideKeywords$1(node.value)) {
|
44996 | return node.value.toLowerCase();
|
44997 | }
|
44998 |
|
44999 | return node.value;
|
45000 | }
|
45001 |
|
45002 | case "value-colon":
|
45003 | {
|
45004 | return concat$9([node.value,
|
45005 | insideValueFunctionNode$1(path, "url") ? "" : line$5]);
|
45006 | }
|
45007 |
|
45008 | case "value-comma":
|
45009 | {
|
45010 | return concat$9([node.value, " "]);
|
45011 | }
|
45012 |
|
45013 | case "value-string":
|
45014 | {
|
45015 | return printString$2(node.raws.quote + node.value + node.raws.quote, options);
|
45016 | }
|
45017 |
|
45018 | case "value-atword":
|
45019 | {
|
45020 | return concat$9(["@", node.value]);
|
45021 | }
|
45022 |
|
45023 | case "value-unicode-range":
|
45024 | {
|
45025 | return node.value;
|
45026 | }
|
45027 |
|
45028 | case "value-unknown":
|
45029 | {
|
45030 | return node.value;
|
45031 | }
|
45032 |
|
45033 | default:
|
45034 |
|
45035 | throw new Error(`Unknown postcss type ${JSON.stringify(node.type)}`);
|
45036 | }
|
45037 | }
|
45038 |
|
45039 | function printNodeSequence(path, options, print) {
|
45040 | const node = path.getValue();
|
45041 | const parts = [];
|
45042 | let i = 0;
|
45043 | path.map(pathChild => {
|
45044 | const prevNode = node.nodes[i - 1];
|
45045 |
|
45046 | if (prevNode && prevNode.type === "css-comment" && prevNode.text.trim() === "prettier-ignore") {
|
45047 | const childNode = pathChild.getValue();
|
45048 | parts.push(options.originalText.slice(options.locStart(childNode), options.locEnd(childNode)));
|
45049 | } else {
|
45050 | parts.push(pathChild.call(print));
|
45051 | }
|
45052 |
|
45053 | if (i !== node.nodes.length - 1) {
|
45054 | if (node.nodes[i + 1].type === "css-comment" && !hasNewline$5(options.originalText, options.locStart(node.nodes[i + 1]), {
|
45055 | backwards: true
|
45056 | }) && node.nodes[i].type !== "yaml" && node.nodes[i].type !== "toml" || node.nodes[i + 1].type === "css-atrule" && node.nodes[i + 1].name === "else" && node.nodes[i].type !== "css-comment") {
|
45057 | parts.push(" ");
|
45058 | } else {
|
45059 | parts.push(options.__isHTMLStyleAttribute ? line$5 : hardline$7);
|
45060 |
|
45061 | if (isNextLineEmpty$3(options.originalText, pathChild.getValue(), options.locEnd) && node.nodes[i].type !== "yaml" && node.nodes[i].type !== "toml") {
|
45062 | parts.push(hardline$7);
|
45063 | }
|
45064 | }
|
45065 | }
|
45066 |
|
45067 | i++;
|
45068 | }, "nodes");
|
45069 | return concat$9(parts);
|
45070 | }
|
45071 |
|
45072 | const STRING_REGEX$3 = /(['"])(?:(?!\1)[^\\]|\\[\s\S])*\1/g;
|
45073 | const NUMBER_REGEX = /(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g;
|
45074 | const STANDARD_UNIT_REGEX = /[a-zA-Z]+/g;
|
45075 | const WORD_PART_REGEX = /[$@]?[a-zA-Z_\u0080-\uFFFF][\w\-\u0080-\uFFFF]*/g;
|
45076 | const ADJUST_NUMBERS_REGEX = new RegExp(STRING_REGEX$3.source + "|" + `(${WORD_PART_REGEX.source})?` + `(${NUMBER_REGEX.source})` + `(${STANDARD_UNIT_REGEX.source})?`, "g");
|
45077 |
|
45078 | function adjustStrings(value, options) {
|
45079 | return value.replace(STRING_REGEX$3, match => printString$2(match, options));
|
45080 | }
|
45081 |
|
45082 | function quoteAttributeValue(value, options) {
|
45083 | const quote = options.singleQuote ? "'" : '"';
|
45084 | return value.includes('"') || value.includes("'") ? value : quote + value + quote;
|
45085 | }
|
45086 |
|
45087 | function adjustNumbers(value) {
|
45088 | return value.replace(ADJUST_NUMBERS_REGEX, (match, quote, wordPart, number, unit) => !wordPart && number ? printCssNumber(number) + maybeToLowerCase$1(unit || "") : match);
|
45089 | }
|
45090 |
|
45091 | function printCssNumber(rawNumber) {
|
45092 | return printNumber$2(rawNumber)
|
45093 | .replace(/\.0(?=$|e)/, "");
|
45094 | }
|
45095 |
|
45096 | var printerPostcss = {
|
45097 | print: genericPrint$2,
|
45098 | embed: embed_1$1,
|
45099 | insertPragma: insertPragma$3,
|
45100 | hasPrettierIgnore: hasIgnoreComment$3,
|
45101 | massageAstNode: clean_1$1
|
45102 | };
|
45103 |
|
45104 | var options$3 = {
|
45105 | singleQuote: commonOptions.singleQuote
|
45106 | };
|
45107 |
|
45108 | var name$9 = "CSS";
|
45109 | var type$7 = "markup";
|
45110 | var tmScope$7 = "source.css";
|
45111 | var aceMode$7 = "css";
|
45112 | var codemirrorMode$7 = "css";
|
45113 | var codemirrorMimeType$7 = "text/css";
|
45114 | var color$2 = "#563d7c";
|
45115 | var extensions$7 = [
|
45116 | ".css"
|
45117 | ];
|
45118 | var languageId$7 = 50;
|
45119 | var CSS = {
|
45120 | name: name$9,
|
45121 | type: type$7,
|
45122 | tmScope: tmScope$7,
|
45123 | aceMode: aceMode$7,
|
45124 | codemirrorMode: codemirrorMode$7,
|
45125 | codemirrorMimeType: codemirrorMimeType$7,
|
45126 | color: color$2,
|
45127 | extensions: extensions$7,
|
45128 | languageId: languageId$7
|
45129 | };
|
45130 |
|
45131 | var CSS$1 = Object.freeze({
|
45132 | __proto__: null,
|
45133 | name: name$9,
|
45134 | type: type$7,
|
45135 | tmScope: tmScope$7,
|
45136 | aceMode: aceMode$7,
|
45137 | codemirrorMode: codemirrorMode$7,
|
45138 | codemirrorMimeType: codemirrorMimeType$7,
|
45139 | color: color$2,
|
45140 | extensions: extensions$7,
|
45141 | languageId: languageId$7,
|
45142 | 'default': CSS
|
45143 | });
|
45144 |
|
45145 | var name$a = "PostCSS";
|
45146 | var type$8 = "markup";
|
45147 | var tmScope$8 = "source.postcss";
|
45148 | var group$7 = "CSS";
|
45149 | var extensions$8 = [
|
45150 | ".pcss",
|
45151 | ".postcss"
|
45152 | ];
|
45153 | var aceMode$8 = "text";
|
45154 | var languageId$8 = 262764437;
|
45155 | var PostCSS = {
|
45156 | name: name$a,
|
45157 | type: type$8,
|
45158 | tmScope: tmScope$8,
|
45159 | group: group$7,
|
45160 | extensions: extensions$8,
|
45161 | aceMode: aceMode$8,
|
45162 | languageId: languageId$8
|
45163 | };
|
45164 |
|
45165 | var PostCSS$1 = Object.freeze({
|
45166 | __proto__: null,
|
45167 | name: name$a,
|
45168 | type: type$8,
|
45169 | tmScope: tmScope$8,
|
45170 | group: group$7,
|
45171 | extensions: extensions$8,
|
45172 | aceMode: aceMode$8,
|
45173 | languageId: languageId$8,
|
45174 | 'default': PostCSS
|
45175 | });
|
45176 |
|
45177 | var name$b = "Less";
|
45178 | var type$9 = "markup";
|
45179 | var group$8 = "CSS";
|
45180 | var extensions$9 = [
|
45181 | ".less"
|
45182 | ];
|
45183 | var tmScope$9 = "source.css.less";
|
45184 | var aceMode$9 = "less";
|
45185 | var codemirrorMode$8 = "css";
|
45186 | var codemirrorMimeType$8 = "text/css";
|
45187 | var languageId$9 = 198;
|
45188 | var Less = {
|
45189 | name: name$b,
|
45190 | type: type$9,
|
45191 | group: group$8,
|
45192 | extensions: extensions$9,
|
45193 | tmScope: tmScope$9,
|
45194 | aceMode: aceMode$9,
|
45195 | codemirrorMode: codemirrorMode$8,
|
45196 | codemirrorMimeType: codemirrorMimeType$8,
|
45197 | languageId: languageId$9
|
45198 | };
|
45199 |
|
45200 | var Less$1 = Object.freeze({
|
45201 | __proto__: null,
|
45202 | name: name$b,
|
45203 | type: type$9,
|
45204 | group: group$8,
|
45205 | extensions: extensions$9,
|
45206 | tmScope: tmScope$9,
|
45207 | aceMode: aceMode$9,
|
45208 | codemirrorMode: codemirrorMode$8,
|
45209 | codemirrorMimeType: codemirrorMimeType$8,
|
45210 | languageId: languageId$9,
|
45211 | 'default': Less
|
45212 | });
|
45213 |
|
45214 | var name$c = "SCSS";
|
45215 | var type$a = "markup";
|
45216 | var tmScope$a = "source.css.scss";
|
45217 | var group$9 = "CSS";
|
45218 | var aceMode$a = "scss";
|
45219 | var codemirrorMode$9 = "css";
|
45220 | var codemirrorMimeType$9 = "text/x-scss";
|
45221 | var extensions$a = [
|
45222 | ".scss"
|
45223 | ];
|
45224 | var languageId$a = 329;
|
45225 | var SCSS = {
|
45226 | name: name$c,
|
45227 | type: type$a,
|
45228 | tmScope: tmScope$a,
|
45229 | group: group$9,
|
45230 | aceMode: aceMode$a,
|
45231 | codemirrorMode: codemirrorMode$9,
|
45232 | codemirrorMimeType: codemirrorMimeType$9,
|
45233 | extensions: extensions$a,
|
45234 | languageId: languageId$a
|
45235 | };
|
45236 |
|
45237 | var SCSS$1 = Object.freeze({
|
45238 | __proto__: null,
|
45239 | name: name$c,
|
45240 | type: type$a,
|
45241 | tmScope: tmScope$a,
|
45242 | group: group$9,
|
45243 | aceMode: aceMode$a,
|
45244 | codemirrorMode: codemirrorMode$9,
|
45245 | codemirrorMimeType: codemirrorMimeType$9,
|
45246 | extensions: extensions$a,
|
45247 | languageId: languageId$a,
|
45248 | 'default': SCSS
|
45249 | });
|
45250 |
|
45251 | var require$$0$2 = getCjsExportFromNamespace(CSS$1);
|
45252 |
|
45253 | var require$$1$2 = getCjsExportFromNamespace(PostCSS$1);
|
45254 |
|
45255 | var require$$2$1 = getCjsExportFromNamespace(Less$1);
|
45256 |
|
45257 | var require$$3$1 = getCjsExportFromNamespace(SCSS$1);
|
45258 |
|
45259 | const languages$1 = [createLanguage(require$$0$2, () => ({
|
45260 | since: "1.4.0",
|
45261 | parsers: ["css"],
|
45262 | vscodeLanguageIds: ["css"]
|
45263 | })), createLanguage(require$$1$2, () => ({
|
45264 | since: "1.4.0",
|
45265 | parsers: ["css"],
|
45266 | vscodeLanguageIds: ["postcss"]
|
45267 | })), createLanguage(require$$2$1, () => ({
|
45268 | since: "1.4.0",
|
45269 | parsers: ["less"],
|
45270 | vscodeLanguageIds: ["less"]
|
45271 | })), createLanguage(require$$3$1, () => ({
|
45272 | since: "1.4.0",
|
45273 | parsers: ["scss"],
|
45274 | vscodeLanguageIds: ["scss"]
|
45275 | }))];
|
45276 | const printers$1 = {
|
45277 | postcss: printerPostcss
|
45278 | };
|
45279 | var languageCss = {
|
45280 | languages: languages$1,
|
45281 | options: options$3,
|
45282 | printers: printers$1
|
45283 | };
|
45284 |
|
45285 | var clean$3 = function (ast, newNode) {
|
45286 | delete newNode.loc;
|
45287 | delete newNode.selfClosing;
|
45288 |
|
45289 | if (ast.type === "TextNode") {
|
45290 | const trimmed = ast.chars.trim();
|
45291 |
|
45292 | if (!trimmed) {
|
45293 | return null;
|
45294 | }
|
45295 |
|
45296 | newNode.chars = trimmed;
|
45297 | }
|
45298 | };
|
45299 |
|
45300 | function isUppercase(string) {
|
45301 | return string.toUpperCase() === string;
|
45302 | }
|
45303 |
|
45304 | function isGlimmerComponent(node) {
|
45305 | return isNodeOfSomeType(node, ["ElementNode"]) && typeof node.tag === "string" && (isUppercase(node.tag[0]) || node.tag.includes("."));
|
45306 | }
|
45307 |
|
45308 | function isWhitespaceNode(node) {
|
45309 | return isNodeOfSomeType(node, ["TextNode"]) && !/\S/.test(node.chars);
|
45310 | }
|
45311 |
|
45312 | function isNodeOfSomeType(node, types) {
|
45313 | return node && types.some(type => node.type === type);
|
45314 | }
|
45315 |
|
45316 | function isParentOfSomeType(path, types) {
|
45317 | const parentNode = path.getParentNode(0);
|
45318 | return isNodeOfSomeType(parentNode, types);
|
45319 | }
|
45320 |
|
45321 | function isPreviousNodeOfSomeType(path, types) {
|
45322 | const previousNode = getPreviousNode(path);
|
45323 | return isNodeOfSomeType(previousNode, types);
|
45324 | }
|
45325 |
|
45326 | function isNextNodeOfSomeType(path, types) {
|
45327 | const nextNode = getNextNode(path);
|
45328 | return isNodeOfSomeType(nextNode, types);
|
45329 | }
|
45330 |
|
45331 | function getSiblingNode(path, offset) {
|
45332 | const node = path.getValue();
|
45333 | const parentNode = path.getParentNode(0) || {};
|
45334 | const children = parentNode.children || parentNode.body || [];
|
45335 | const index = children.indexOf(node);
|
45336 | return index !== -1 && children[index + offset];
|
45337 | }
|
45338 |
|
45339 | function getPreviousNode(path, lookBack = 1) {
|
45340 | return getSiblingNode(path, -lookBack);
|
45341 | }
|
45342 |
|
45343 | function getNextNode(path) {
|
45344 | return getSiblingNode(path, 1);
|
45345 | }
|
45346 |
|
45347 | function isPrettierIgnoreNode(node) {
|
45348 | return isNodeOfSomeType(node, ["MustacheCommentStatement"]) && typeof node.value === "string" && node.value.trim() === "prettier-ignore";
|
45349 | }
|
45350 |
|
45351 | function hasPrettierIgnore$2(path) {
|
45352 | const node = path.getValue();
|
45353 | const previousPreviousNode = getPreviousNode(path, 2);
|
45354 | return isPrettierIgnoreNode(node) || isPrettierIgnoreNode(previousPreviousNode);
|
45355 | }
|
45356 |
|
45357 | var utils$8 = {
|
45358 | getNextNode,
|
45359 | getPreviousNode,
|
45360 | hasPrettierIgnore: hasPrettierIgnore$2,
|
45361 | isGlimmerComponent,
|
45362 | isNextNodeOfSomeType,
|
45363 | isNodeOfSomeType,
|
45364 | isParentOfSomeType,
|
45365 | isPreviousNodeOfSomeType,
|
45366 | isWhitespaceNode
|
45367 | };
|
45368 |
|
45369 | const {
|
45370 | concat: concat$a,
|
45371 | join: join$7,
|
45372 | softline: softline$4,
|
45373 | hardline: hardline$8,
|
45374 | line: line$6,
|
45375 | group: group$a,
|
45376 | indent: indent$6,
|
45377 | ifBreak: ifBreak$3
|
45378 | } = document.builders;
|
45379 | const {
|
45380 | getNextNode: getNextNode$1,
|
45381 | getPreviousNode: getPreviousNode$1,
|
45382 | hasPrettierIgnore: hasPrettierIgnore$3,
|
45383 | isGlimmerComponent: isGlimmerComponent$1,
|
45384 | isNextNodeOfSomeType: isNextNodeOfSomeType$1,
|
45385 | isParentOfSomeType: isParentOfSomeType$1,
|
45386 | isPreviousNodeOfSomeType: isPreviousNodeOfSomeType$1,
|
45387 | isWhitespaceNode: isWhitespaceNode$1
|
45388 | } = utils$8;
|
45389 |
|
45390 | const voidTags = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"];
|
45391 |
|
45392 |
|
45393 | function print(path, options, print) {
|
45394 | const n = path.getValue();
|
45395 |
|
45396 |
|
45397 | if (!n) {
|
45398 | return "";
|
45399 | }
|
45400 |
|
45401 | if (hasPrettierIgnore$3(path)) {
|
45402 | const startOffset = locationToOffset(options.originalText, n.loc.start.line - 1, n.loc.start.column);
|
45403 | const endOffset = locationToOffset(options.originalText, n.loc.end.line - 1, n.loc.end.column);
|
45404 | const ignoredText = options.originalText.slice(startOffset, endOffset);
|
45405 | return ignoredText;
|
45406 | }
|
45407 |
|
45408 | switch (n.type) {
|
45409 | case "Block":
|
45410 | case "Program":
|
45411 | case "Template":
|
45412 | {
|
45413 | return group$a(concat$a(path.map(print, "body")));
|
45414 | }
|
45415 |
|
45416 | case "ElementNode":
|
45417 | {
|
45418 | const hasChildren = n.children.length > 0;
|
45419 | const hasNonWhitespaceChildren = n.children.some(n => !isWhitespaceNode$1(n));
|
45420 | const isVoid = isGlimmerComponent$1(n) && (!hasChildren || !hasNonWhitespaceChildren) || voidTags.includes(n.tag);
|
45421 | const closeTagForNoBreak = isVoid ? concat$a([" />", softline$4]) : ">";
|
45422 | const closeTagForBreak = isVoid ? "/>" : ">";
|
45423 |
|
45424 | const printParams = (path, print) => indent$6(concat$a([n.attributes.length ? line$6 : "", join$7(line$6, path.map(print, "attributes")), n.modifiers.length ? line$6 : "", join$7(line$6, path.map(print, "modifiers")), n.comments.length ? line$6 : "", join$7(line$6, path.map(print, "comments"))]));
|
45425 |
|
45426 | const nextNode = getNextNode$1(path);
|
45427 | return concat$a([group$a(concat$a(["<", n.tag, printParams(path, print), n.blockParams.length ? ` as |${n.blockParams.join(" ")}|` : "", ifBreak$3(softline$4, ""), ifBreak$3(closeTagForBreak, closeTagForNoBreak)])), !isVoid ? group$a(concat$a([hasNonWhitespaceChildren ? indent$6(printChildren(path, options, print)) : "", ifBreak$3(hasChildren ? hardline$8 : "", ""), concat$a(["</", n.tag, ">"])])) : "", nextNode && nextNode.type === "ElementNode" ? hardline$8 : ""]);
|
45428 | }
|
45429 |
|
45430 | case "BlockStatement":
|
45431 | {
|
45432 | const pp = path.getParentNode(1);
|
45433 | const isElseIf = pp && pp.inverse && pp.inverse.body.length === 1 && pp.inverse.body[0] === n && pp.inverse.body[0].path.parts[0] === "if";
|
45434 | const hasElseIf = n.inverse && n.inverse.body.length === 1 && n.inverse.body[0].type === "BlockStatement" && n.inverse.body[0].path.parts[0] === "if";
|
45435 | const indentElse = hasElseIf ? a => a : indent$6;
|
45436 | const inverseElseStatement = (n.inverseStrip.open ? "{{~" : "{{") + "else" + (n.inverseStrip.close ? "~}}" : "}}");
|
45437 |
|
45438 | if (n.inverse) {
|
45439 | return concat$a([isElseIf ? concat$a([n.openStrip.open ? "{{~else " : "{{else ", printPathParams(path, print), n.openStrip.close ? "~}}" : "}}"]) : printOpenBlock(path, print, n.openStrip), indent$6(concat$a([hardline$8, path.call(print, "program")])), n.inverse && !hasElseIf ? concat$a([hardline$8, inverseElseStatement]) : "", n.inverse ? indentElse(concat$a([hardline$8, path.call(print, "inverse")])) : "", isElseIf ? "" : concat$a([hardline$8, printCloseBlock(path, print, n.closeStrip)])]);
|
45440 | } else if (isElseIf) {
|
45441 | return concat$a([concat$a([n.openStrip.open ? "{{~else" : "{{else ", printPathParams(path, print), n.openStrip.close ? "~}}" : "}}"]), indent$6(concat$a([hardline$8, path.call(print, "program")]))]);
|
45442 | }
|
45443 |
|
45444 | const hasNonWhitespaceChildren = n.program.body.some(n => !isWhitespaceNode$1(n));
|
45445 | return concat$a([printOpenBlock(path, print, n.openStrip), group$a(concat$a([indent$6(concat$a([softline$4, path.call(print, "program")])), hasNonWhitespaceChildren ? hardline$8 : softline$4, printCloseBlock(path, print, n.closeStrip)]))]);
|
45446 | }
|
45447 |
|
45448 | case "ElementModifierStatement":
|
45449 | {
|
45450 | return group$a(concat$a(["{{", printPathParams(path, print), softline$4, "}}"]));
|
45451 | }
|
45452 |
|
45453 | case "MustacheStatement":
|
45454 | {
|
45455 | const isEscaped = n.escaped === false;
|
45456 | const {
|
45457 | open: openStrip,
|
45458 | close: closeStrip
|
45459 | } = n.strip;
|
45460 | const opening = (isEscaped ? "{{{" : "{{") + (openStrip ? "~" : "");
|
45461 | const closing = (closeStrip ? "~" : "") + (isEscaped ? "}}}" : "}}");
|
45462 | const leading = isParentOfSomeType$1(path, ["AttrNode", "ConcatStatement", "ElementNode"]) ? [opening, indent$6(softline$4)] : [opening];
|
45463 | return group$a(concat$a([...leading, printPathParams(path, print), softline$4, closing]));
|
45464 | }
|
45465 |
|
45466 | case "SubExpression":
|
45467 | {
|
45468 | const params = printParams(path, print);
|
45469 | const printedParams = params.length > 0 ? indent$6(concat$a([line$6, group$a(join$7(line$6, params))])) : "";
|
45470 | return group$a(concat$a(["(", printPath(path, print), printedParams, softline$4, ")"]));
|
45471 | }
|
45472 |
|
45473 | case "AttrNode":
|
45474 | {
|
45475 | const isText = n.value.type === "TextNode";
|
45476 | const isEmptyText = isText && n.value.chars === "";
|
45477 |
|
45478 |
|
45479 |
|
45480 | const isEmptyValue = isEmptyText && n.value.loc.start.column === n.value.loc.end.column;
|
45481 |
|
45482 | if (isEmptyValue) {
|
45483 | return concat$a([n.name]);
|
45484 | }
|
45485 |
|
45486 | const value = path.call(print, "value");
|
45487 | const quotedValue = isText ? printStringLiteral(value.parts.join(), options) : value;
|
45488 | return concat$a([n.name, "=", quotedValue]);
|
45489 | }
|
45490 |
|
45491 | case "ConcatStatement":
|
45492 | {
|
45493 | return concat$a(['"', concat$a(path.map(partPath => print(partPath), "parts").filter(a => a !== "")), '"']);
|
45494 | }
|
45495 |
|
45496 | case "Hash":
|
45497 | {
|
45498 | return concat$a([join$7(line$6, path.map(print, "pairs"))]);
|
45499 | }
|
45500 |
|
45501 | case "HashPair":
|
45502 | {
|
45503 | return concat$a([n.key, "=", path.call(print, "value")]);
|
45504 | }
|
45505 |
|
45506 | case "TextNode":
|
45507 | {
|
45508 | const maxLineBreaksToPreserve = 2;
|
45509 | const isFirstElement = !getPreviousNode$1(path);
|
45510 | const isLastElement = !getNextNode$1(path);
|
45511 | const isWhitespaceOnly = !/\S/.test(n.chars);
|
45512 | const lineBreaksCount = countNewLines(n.chars);
|
45513 | const hasBlockParent = path.getParentNode(0).type === "Block";
|
45514 | const hasElementParent = path.getParentNode(0).type === "ElementNode";
|
45515 | const hasTemplateParent = path.getParentNode(0).type === "Template";
|
45516 | let leadingLineBreaksCount = countLeadingNewLines(n.chars);
|
45517 | let trailingLineBreaksCount = countTrailingNewLines(n.chars);
|
45518 |
|
45519 | if ((isFirstElement || isLastElement) && isWhitespaceOnly && (hasBlockParent || hasElementParent || hasTemplateParent)) {
|
45520 | return "";
|
45521 | }
|
45522 |
|
45523 | if (isWhitespaceOnly && lineBreaksCount) {
|
45524 | leadingLineBreaksCount = Math.min(lineBreaksCount, maxLineBreaksToPreserve);
|
45525 | trailingLineBreaksCount = 0;
|
45526 | } else {
|
45527 | if (isNextNodeOfSomeType$1(path, ["BlockStatement", "ElementNode"])) {
|
45528 | trailingLineBreaksCount = Math.max(trailingLineBreaksCount, 1);
|
45529 | }
|
45530 |
|
45531 | if (isPreviousNodeOfSomeType$1(path, ["ElementNode"]) || isPreviousNodeOfSomeType$1(path, ["BlockStatement"])) {
|
45532 | leadingLineBreaksCount = Math.max(leadingLineBreaksCount, 1);
|
45533 | }
|
45534 | }
|
45535 |
|
45536 | let leadingSpace = "";
|
45537 | let trailingSpace = "";
|
45538 |
|
45539 |
|
45540 | const inAttrNode = path.stack.includes("attributes");
|
45541 |
|
45542 | if (inAttrNode) {
|
45543 | const parentNode = path.getParentNode(0);
|
45544 | const isConcat = parentNode.type === "ConcatStatement";
|
45545 |
|
45546 | if (isConcat) {
|
45547 | const {
|
45548 | parts
|
45549 | } = parentNode;
|
45550 | const partIndex = parts.indexOf(n);
|
45551 |
|
45552 | if (partIndex > 0) {
|
45553 | const partType = parts[partIndex - 1].type;
|
45554 | const isMustache = partType === "MustacheStatement";
|
45555 |
|
45556 | if (isMustache) {
|
45557 | leadingSpace = " ";
|
45558 | }
|
45559 | }
|
45560 |
|
45561 | if (partIndex < parts.length - 1) {
|
45562 | const partType = parts[partIndex + 1].type;
|
45563 | const isMustache = partType === "MustacheStatement";
|
45564 |
|
45565 | if (isMustache) {
|
45566 | trailingSpace = " ";
|
45567 | }
|
45568 | }
|
45569 | }
|
45570 | } else {
|
45571 | if (trailingLineBreaksCount === 0 && isNextNodeOfSomeType$1(path, ["MustacheStatement"])) {
|
45572 | trailingSpace = " ";
|
45573 | }
|
45574 |
|
45575 | if (leadingLineBreaksCount === 0 && isPreviousNodeOfSomeType$1(path, ["MustacheStatement"])) {
|
45576 | leadingSpace = " ";
|
45577 | }
|
45578 |
|
45579 | if (isFirstElement) {
|
45580 | leadingLineBreaksCount = 0;
|
45581 | leadingSpace = "";
|
45582 | }
|
45583 |
|
45584 | if (isLastElement) {
|
45585 | trailingLineBreaksCount = 0;
|
45586 | trailingSpace = "";
|
45587 | }
|
45588 | }
|
45589 |
|
45590 | return concat$a([...generateHardlines(leadingLineBreaksCount, maxLineBreaksToPreserve), n.chars.replace(/^[\s ]+/g, leadingSpace).replace(/[\s ]+$/, trailingSpace), ...generateHardlines(trailingLineBreaksCount, maxLineBreaksToPreserve)].filter(Boolean));
|
45591 | }
|
45592 |
|
45593 | case "MustacheCommentStatement":
|
45594 | {
|
45595 | const dashes = n.value.includes("}}") ? "--" : "";
|
45596 | return concat$a(["{{!", dashes, n.value, dashes, "}}"]);
|
45597 | }
|
45598 |
|
45599 | case "PathExpression":
|
45600 | {
|
45601 | return n.original;
|
45602 | }
|
45603 |
|
45604 | case "BooleanLiteral":
|
45605 | {
|
45606 | return String(n.value);
|
45607 | }
|
45608 |
|
45609 | case "CommentStatement":
|
45610 | {
|
45611 | return concat$a(["<!--", n.value, "-->"]);
|
45612 | }
|
45613 |
|
45614 | case "StringLiteral":
|
45615 | {
|
45616 | return printStringLiteral(n.value, options);
|
45617 | }
|
45618 |
|
45619 | case "NumberLiteral":
|
45620 | {
|
45621 | return String(n.value);
|
45622 | }
|
45623 |
|
45624 | case "UndefinedLiteral":
|
45625 | {
|
45626 | return "undefined";
|
45627 | }
|
45628 |
|
45629 | case "NullLiteral":
|
45630 | {
|
45631 | return "null";
|
45632 | }
|
45633 |
|
45634 |
|
45635 |
|
45636 | default:
|
45637 | throw new Error("unknown glimmer type: " + JSON.stringify(n.type));
|
45638 | }
|
45639 | }
|
45640 |
|
45641 | function printChildren(path, options, print) {
|
45642 | return concat$a(path.map((childPath, childIndex) => {
|
45643 | const childNode = path.getValue();
|
45644 | const isFirstNode = childIndex === 0;
|
45645 | const isLastNode = childIndex === path.getParentNode(0).children.length - 1;
|
45646 | const isLastNodeInMultiNodeList = isLastNode && !isFirstNode;
|
45647 | const isWhitespace = isWhitespaceNode$1(childNode);
|
45648 |
|
45649 | if (isWhitespace && isLastNodeInMultiNodeList) {
|
45650 | return print(childPath, options, print);
|
45651 | } else if (isFirstNode) {
|
45652 | return concat$a([softline$4, print(childPath, options, print)]);
|
45653 | }
|
45654 |
|
45655 | return print(childPath, options, print);
|
45656 | }, "children"));
|
45657 | }
|
45658 |
|
45659 |
|
45660 |
|
45661 |
|
45662 |
|
45663 |
|
45664 |
|
45665 |
|
45666 |
|
45667 |
|
45668 |
|
45669 | function printStringLiteral(stringLiteral, options) {
|
45670 | const double = {
|
45671 | quote: '"',
|
45672 | regex: /"/g
|
45673 | };
|
45674 | const single = {
|
45675 | quote: "'",
|
45676 | regex: /'/g
|
45677 | };
|
45678 | const preferred = options.singleQuote ? single : double;
|
45679 | const alternate = preferred === single ? double : single;
|
45680 | let shouldUseAlternateQuote = false;
|
45681 |
|
45682 |
|
45683 |
|
45684 | if (stringLiteral.includes(preferred.quote) || stringLiteral.includes(alternate.quote)) {
|
45685 | const numPreferredQuotes = (stringLiteral.match(preferred.regex) || []).length;
|
45686 | const numAlternateQuotes = (stringLiteral.match(alternate.regex) || []).length;
|
45687 | shouldUseAlternateQuote = numPreferredQuotes > numAlternateQuotes;
|
45688 | }
|
45689 |
|
45690 | const enclosingQuote = shouldUseAlternateQuote ? alternate : preferred;
|
45691 | const escapedStringLiteral = stringLiteral.replace(enclosingQuote.regex, `\\${enclosingQuote.quote}`);
|
45692 | return concat$a([enclosingQuote.quote, escapedStringLiteral, enclosingQuote.quote]);
|
45693 | }
|
45694 |
|
45695 | function printPath(path, print) {
|
45696 | return path.call(print, "path");
|
45697 | }
|
45698 |
|
45699 | function printParams(path, print) {
|
45700 | const node = path.getValue();
|
45701 | let parts = [];
|
45702 |
|
45703 | if (node.params.length > 0) {
|
45704 | parts = parts.concat(path.map(print, "params"));
|
45705 | }
|
45706 |
|
45707 | if (node.hash && node.hash.pairs.length > 0) {
|
45708 | parts.push(path.call(print, "hash"));
|
45709 | }
|
45710 |
|
45711 | return parts;
|
45712 | }
|
45713 |
|
45714 | function printPathParams(path, print) {
|
45715 | const printedPath = printPath(path, print);
|
45716 | const printedParams = printParams(path, print);
|
45717 | const parts = [printedPath, ...printedParams];
|
45718 | return indent$6(group$a(join$7(line$6, parts)));
|
45719 | }
|
45720 |
|
45721 | function printBlockParams(path) {
|
45722 | const block = path.getValue();
|
45723 |
|
45724 | if (!block.program || !block.program.blockParams.length) {
|
45725 | return "";
|
45726 | }
|
45727 |
|
45728 | return concat$a([" as |", block.program.blockParams.join(" "), "|"]);
|
45729 | }
|
45730 |
|
45731 | function printOpenBlock(path, print, {
|
45732 | open: isOpenStrip = false,
|
45733 | close: isCloseStrip = false
|
45734 | } = {}) {
|
45735 | return group$a(concat$a([isOpenStrip ? "{{~#" : "{{#", printPathParams(path, print), printBlockParams(path), softline$4, isCloseStrip ? "~}}" : "}}"]));
|
45736 | }
|
45737 |
|
45738 | function printCloseBlock(path, print, {
|
45739 | open: isOpenStrip = false,
|
45740 | close: isCloseStrip = false
|
45741 | } = {}) {
|
45742 | return concat$a([isOpenStrip ? "{{~/" : "{{/", path.call(print, "path"), isCloseStrip ? "~}}" : "}}"]);
|
45743 | }
|
45744 |
|
45745 | function countNewLines(string) {
|
45746 |
|
45747 | string = typeof string === "string" ? string : "";
|
45748 | return string.split("\n").length - 1;
|
45749 | }
|
45750 |
|
45751 | function countLeadingNewLines(string) {
|
45752 |
|
45753 | string = typeof string === "string" ? string : "";
|
45754 | const newLines = (string.match(/^([^\S\r\n]*[\r\n])+/g) || [])[0] || "";
|
45755 | return countNewLines(newLines);
|
45756 | }
|
45757 |
|
45758 | function countTrailingNewLines(string) {
|
45759 |
|
45760 | string = typeof string === "string" ? string : "";
|
45761 | const newLines = (string.match(/([\r\n][^\S\r\n]*)+$/g) || [])[0] || "";
|
45762 | return countNewLines(newLines);
|
45763 | }
|
45764 |
|
45765 | function generateHardlines(number = 0, max = 0) {
|
45766 | return new Array(Math.min(number, max)).fill(hardline$8);
|
45767 | }
|
45768 |
|
45769 |
|
45770 |
|
45771 |
|
45772 |
|
45773 | function locationToOffset(source, line, column) {
|
45774 | let seenLines = 0;
|
45775 | let seenChars = 0;
|
45776 |
|
45777 | while (true) {
|
45778 | if (seenChars === source.length) {
|
45779 | return null;
|
45780 | }
|
45781 |
|
45782 | let nextLine = source.indexOf("\n", seenChars);
|
45783 |
|
45784 | if (nextLine === -1) {
|
45785 | nextLine = source.length;
|
45786 | }
|
45787 |
|
45788 | if (seenLines === line) {
|
45789 | if (seenChars + column > nextLine) {
|
45790 | return null;
|
45791 | }
|
45792 |
|
45793 | return seenChars + column;
|
45794 | } else if (nextLine === -1) {
|
45795 | return null;
|
45796 | }
|
45797 |
|
45798 | seenLines += 1;
|
45799 | seenChars = nextLine + 1;
|
45800 | }
|
45801 | }
|
45802 |
|
45803 | var printerGlimmer = {
|
45804 | print,
|
45805 | massageAstNode: clean$3
|
45806 | };
|
45807 |
|
45808 | var name$d = "Handlebars";
|
45809 | var type$b = "markup";
|
45810 | var group$b = "HTML";
|
45811 | var aliases$3 = [
|
45812 | "hbs",
|
45813 | "htmlbars"
|
45814 | ];
|
45815 | var extensions$b = [
|
45816 | ".handlebars",
|
45817 | ".hbs"
|
45818 | ];
|
45819 | var tmScope$b = "text.html.handlebars";
|
45820 | var aceMode$b = "handlebars";
|
45821 | var languageId$b = 155;
|
45822 | var Handlebars = {
|
45823 | name: name$d,
|
45824 | type: type$b,
|
45825 | group: group$b,
|
45826 | aliases: aliases$3,
|
45827 | extensions: extensions$b,
|
45828 | tmScope: tmScope$b,
|
45829 | aceMode: aceMode$b,
|
45830 | languageId: languageId$b
|
45831 | };
|
45832 |
|
45833 | var Handlebars$1 = Object.freeze({
|
45834 | __proto__: null,
|
45835 | name: name$d,
|
45836 | type: type$b,
|
45837 | group: group$b,
|
45838 | aliases: aliases$3,
|
45839 | extensions: extensions$b,
|
45840 | tmScope: tmScope$b,
|
45841 | aceMode: aceMode$b,
|
45842 | languageId: languageId$b,
|
45843 | 'default': Handlebars
|
45844 | });
|
45845 |
|
45846 | var require$$0$3 = getCjsExportFromNamespace(Handlebars$1);
|
45847 |
|
45848 | const languages$2 = [createLanguage(require$$0$3, () => ({
|
45849 | since: null,
|
45850 |
|
45851 | parsers: ["glimmer"],
|
45852 | vscodeLanguageIds: ["handlebars"]
|
45853 | }))];
|
45854 | const printers$2 = {
|
45855 | glimmer: printerGlimmer
|
45856 | };
|
45857 | var languageHandlebars = {
|
45858 | languages: languages$2,
|
45859 | printers: printers$2
|
45860 | };
|
45861 |
|
45862 | function hasPragma$2(text) {
|
45863 | return /^\s*#[^\n\S]*@(format|prettier)\s*(\n|$)/.test(text);
|
45864 | }
|
45865 |
|
45866 | function insertPragma$4(text) {
|
45867 | return "# @format\n\n" + text;
|
45868 | }
|
45869 |
|
45870 | var pragma$2 = {
|
45871 | hasPragma: hasPragma$2,
|
45872 | insertPragma: insertPragma$4
|
45873 | };
|
45874 |
|
45875 | const {
|
45876 | concat: concat$b,
|
45877 | join: join$8,
|
45878 | hardline: hardline$9,
|
45879 | line: line$7,
|
45880 | softline: softline$5,
|
45881 | group: group$c,
|
45882 | indent: indent$7,
|
45883 | ifBreak: ifBreak$4
|
45884 | } = document.builders;
|
45885 | const {
|
45886 | hasIgnoreComment: hasIgnoreComment$4
|
45887 | } = util$1;
|
45888 | const {
|
45889 | isNextLineEmpty: isNextLineEmpty$4
|
45890 | } = utilShared;
|
45891 | const {
|
45892 | insertPragma: insertPragma$5
|
45893 | } = pragma$2;
|
45894 |
|
45895 | function genericPrint$3(path, options, print) {
|
45896 | const n = path.getValue();
|
45897 |
|
45898 | if (!n) {
|
45899 | return "";
|
45900 | }
|
45901 |
|
45902 | if (typeof n === "string") {
|
45903 | return n;
|
45904 | }
|
45905 |
|
45906 | switch (n.kind) {
|
45907 | case "Document":
|
45908 | {
|
45909 | const parts = [];
|
45910 | path.map((pathChild, index) => {
|
45911 | parts.push(concat$b([pathChild.call(print)]));
|
45912 |
|
45913 | if (index !== n.definitions.length - 1) {
|
45914 | parts.push(hardline$9);
|
45915 |
|
45916 | if (isNextLineEmpty$4(options.originalText, pathChild.getValue(), options.locEnd)) {
|
45917 | parts.push(hardline$9);
|
45918 | }
|
45919 | }
|
45920 | }, "definitions");
|
45921 | return concat$b([concat$b(parts), hardline$9]);
|
45922 | }
|
45923 |
|
45924 | case "OperationDefinition":
|
45925 | {
|
45926 | const hasOperation = options.originalText[options.locStart(n)] !== "{";
|
45927 | const hasName = !!n.name;
|
45928 | return concat$b([hasOperation ? n.operation : "", hasOperation && hasName ? concat$b([" ", path.call(print, "name")]) : "", n.variableDefinitions && n.variableDefinitions.length ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.map(print, "variableDefinitions"))])), softline$5, ")"])) : "", printDirectives(path, print, n), n.selectionSet ? !hasOperation && !hasName ? "" : " " : "", path.call(print, "selectionSet")]);
|
45929 | }
|
45930 |
|
45931 | case "FragmentDefinition":
|
45932 | {
|
45933 | return concat$b(["fragment ", path.call(print, "name"), n.variableDefinitions && n.variableDefinitions.length ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.map(print, "variableDefinitions"))])), softline$5, ")"])) : "", " on ", path.call(print, "typeCondition"), printDirectives(path, print, n), " ", path.call(print, "selectionSet")]);
|
45934 | }
|
45935 |
|
45936 | case "SelectionSet":
|
45937 | {
|
45938 | return concat$b(["{", indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(selectionsPath => printSequence(selectionsPath, options, print), "selections"))])), hardline$9, "}"]);
|
45939 | }
|
45940 |
|
45941 | case "Field":
|
45942 | {
|
45943 | return group$c(concat$b([n.alias ? concat$b([path.call(print, "alias"), ": "]) : "", path.call(print, "name"), n.arguments.length > 0 ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.call(argsPath => printSequence(argsPath, options, print), "arguments"))])), softline$5, ")"])) : "", printDirectives(path, print, n), n.selectionSet ? " " : "", path.call(print, "selectionSet")]));
|
45944 | }
|
45945 |
|
45946 | case "Name":
|
45947 | {
|
45948 | return n.value;
|
45949 | }
|
45950 |
|
45951 | case "StringValue":
|
45952 | {
|
45953 | if (n.block) {
|
45954 | return concat$b(['"""', hardline$9, join$8(hardline$9, n.value.replace(/"""/g, "\\$&").split("\n")), hardline$9, '"""']);
|
45955 | }
|
45956 |
|
45957 | return concat$b(['"', n.value.replace(/["\\]/g, "\\$&").replace(/\n/g, "\\n"), '"']);
|
45958 | }
|
45959 |
|
45960 | case "IntValue":
|
45961 | case "FloatValue":
|
45962 | case "EnumValue":
|
45963 | {
|
45964 | return n.value;
|
45965 | }
|
45966 |
|
45967 | case "BooleanValue":
|
45968 | {
|
45969 | return n.value ? "true" : "false";
|
45970 | }
|
45971 |
|
45972 | case "NullValue":
|
45973 | {
|
45974 | return "null";
|
45975 | }
|
45976 |
|
45977 | case "Variable":
|
45978 | {
|
45979 | return concat$b(["$", path.call(print, "name")]);
|
45980 | }
|
45981 |
|
45982 | case "ListValue":
|
45983 | {
|
45984 | return group$c(concat$b(["[", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.map(print, "values"))])), softline$5, "]"]));
|
45985 | }
|
45986 |
|
45987 | case "ObjectValue":
|
45988 | {
|
45989 | return group$c(concat$b(["{", options.bracketSpacing && n.fields.length > 0 ? " " : "", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.map(print, "fields"))])), softline$5, ifBreak$4("", options.bracketSpacing && n.fields.length > 0 ? " " : ""), "}"]));
|
45990 | }
|
45991 |
|
45992 | case "ObjectField":
|
45993 | case "Argument":
|
45994 | {
|
45995 | return concat$b([path.call(print, "name"), ": ", path.call(print, "value")]);
|
45996 | }
|
45997 |
|
45998 | case "Directive":
|
45999 | {
|
46000 | return concat$b(["@", path.call(print, "name"), n.arguments.length > 0 ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.call(argsPath => printSequence(argsPath, options, print), "arguments"))])), softline$5, ")"])) : ""]);
|
46001 | }
|
46002 |
|
46003 | case "NamedType":
|
46004 | {
|
46005 | return path.call(print, "name");
|
46006 | }
|
46007 |
|
46008 | case "VariableDefinition":
|
46009 | {
|
46010 | return concat$b([path.call(print, "variable"), ": ", path.call(print, "type"), n.defaultValue ? concat$b([" = ", path.call(print, "defaultValue")]) : "", printDirectives(path, print, n)]);
|
46011 | }
|
46012 |
|
46013 | case "TypeExtensionDefinition":
|
46014 | {
|
46015 | return concat$b(["extend ", path.call(print, "definition")]);
|
46016 | }
|
46017 |
|
46018 | case "ObjectTypeExtension":
|
46019 | case "ObjectTypeDefinition":
|
46020 | {
|
46021 | return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", n.kind === "ObjectTypeExtension" ? "extend " : "", "type ", path.call(print, "name"), n.interfaces.length > 0 ? concat$b([" implements ", concat$b(printInterfaces(path, options, print))]) : "", printDirectives(path, print, n), n.fields.length > 0 ? concat$b([" {", indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))])), hardline$9, "}"]) : ""]);
|
46022 | }
|
46023 |
|
46024 | case "FieldDefinition":
|
46025 | {
|
46026 | return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", path.call(print, "name"), n.arguments.length > 0 ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.call(argsPath => printSequence(argsPath, options, print), "arguments"))])), softline$5, ")"])) : "", ": ", path.call(print, "type"), printDirectives(path, print, n)]);
|
46027 | }
|
46028 |
|
46029 | case "DirectiveDefinition":
|
46030 | {
|
46031 | return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", "directive ", "@", path.call(print, "name"), n.arguments.length > 0 ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.call(argsPath => printSequence(argsPath, options, print), "arguments"))])), softline$5, ")"])) : "", n.repeatable ? " repeatable" : "", concat$b([" on ", join$8(" | ", path.map(print, "locations"))])]);
|
46032 | }
|
46033 |
|
46034 | case "EnumTypeExtension":
|
46035 | case "EnumTypeDefinition":
|
46036 | {
|
46037 | return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", n.kind === "EnumTypeExtension" ? "extend " : "", "enum ", path.call(print, "name"), printDirectives(path, print, n), n.values.length > 0 ? concat$b([" {", indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(valuesPath => printSequence(valuesPath, options, print), "values"))])), hardline$9, "}"]) : ""]);
|
46038 | }
|
46039 |
|
46040 | case "EnumValueDefinition":
|
46041 | {
|
46042 | return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", path.call(print, "name"), printDirectives(path, print, n)]);
|
46043 | }
|
46044 |
|
46045 | case "InputValueDefinition":
|
46046 | {
|
46047 | return concat$b([path.call(print, "description"), n.description ? n.description.block ? hardline$9 : line$7 : "", path.call(print, "name"), ": ", path.call(print, "type"), n.defaultValue ? concat$b([" = ", path.call(print, "defaultValue")]) : "", printDirectives(path, print, n)]);
|
46048 | }
|
46049 |
|
46050 | case "InputObjectTypeExtension":
|
46051 | case "InputObjectTypeDefinition":
|
46052 | {
|
46053 | return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", n.kind === "InputObjectTypeExtension" ? "extend " : "", "input ", path.call(print, "name"), printDirectives(path, print, n), n.fields.length > 0 ? concat$b([" {", indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))])), hardline$9, "}"]) : ""]);
|
46054 | }
|
46055 |
|
46056 | case "SchemaDefinition":
|
46057 | {
|
46058 | return concat$b(["schema", printDirectives(path, print, n), " {", n.operationTypes.length > 0 ? indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(opsPath => printSequence(opsPath, options, print), "operationTypes"))])) : "", hardline$9, "}"]);
|
46059 | }
|
46060 |
|
46061 | case "OperationTypeDefinition":
|
46062 | {
|
46063 | return concat$b([path.call(print, "operation"), ": ", path.call(print, "type")]);
|
46064 | }
|
46065 |
|
46066 | case "InterfaceTypeExtension":
|
46067 | case "InterfaceTypeDefinition":
|
46068 | {
|
46069 | return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", n.kind === "InterfaceTypeExtension" ? "extend " : "", "interface ", path.call(print, "name"), printDirectives(path, print, n), n.fields.length > 0 ? concat$b([" {", indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))])), hardline$9, "}"]) : ""]);
|
46070 | }
|
46071 |
|
46072 | case "FragmentSpread":
|
46073 | {
|
46074 | return concat$b(["...", path.call(print, "name"), printDirectives(path, print, n)]);
|
46075 | }
|
46076 |
|
46077 | case "InlineFragment":
|
46078 | {
|
46079 | return concat$b(["...", n.typeCondition ? concat$b([" on ", path.call(print, "typeCondition")]) : "", printDirectives(path, print, n), " ", path.call(print, "selectionSet")]);
|
46080 | }
|
46081 |
|
46082 | case "UnionTypeExtension":
|
46083 | case "UnionTypeDefinition":
|
46084 | {
|
46085 | return group$c(concat$b([path.call(print, "description"), n.description ? hardline$9 : "", group$c(concat$b([n.kind === "UnionTypeExtension" ? "extend " : "", "union ", path.call(print, "name"), printDirectives(path, print, n), n.types.length > 0 ? concat$b([" =", ifBreak$4("", " "), indent$7(concat$b([ifBreak$4(concat$b([line$7, " "])), join$8(concat$b([line$7, "| "]), path.map(print, "types"))]))]) : ""]))]));
|
46086 | }
|
46087 |
|
46088 | case "ScalarTypeExtension":
|
46089 | case "ScalarTypeDefinition":
|
46090 | {
|
46091 | return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", n.kind === "ScalarTypeExtension" ? "extend " : "", "scalar ", path.call(print, "name"), printDirectives(path, print, n)]);
|
46092 | }
|
46093 |
|
46094 | case "NonNullType":
|
46095 | {
|
46096 | return concat$b([path.call(print, "type"), "!"]);
|
46097 | }
|
46098 |
|
46099 | case "ListType":
|
46100 | {
|
46101 | return concat$b(["[", path.call(print, "type"), "]"]);
|
46102 | }
|
46103 |
|
46104 | default:
|
46105 |
|
46106 | throw new Error("unknown graphql type: " + JSON.stringify(n.kind));
|
46107 | }
|
46108 | }
|
46109 |
|
46110 | function printDirectives(path, print, n) {
|
46111 | if (n.directives.length === 0) {
|
46112 | return "";
|
46113 | }
|
46114 |
|
46115 | return concat$b([" ", group$c(indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", " "), softline$5]), path.map(print, "directives"))])))]);
|
46116 | }
|
46117 |
|
46118 | function printSequence(sequencePath, options, print) {
|
46119 | const count = sequencePath.getValue().length;
|
46120 | return sequencePath.map((path, i) => {
|
46121 | const printed = print(path);
|
46122 |
|
46123 | if (isNextLineEmpty$4(options.originalText, path.getValue(), options.locEnd) && i < count - 1) {
|
46124 | return concat$b([printed, hardline$9]);
|
46125 | }
|
46126 |
|
46127 | return printed;
|
46128 | });
|
46129 | }
|
46130 |
|
46131 | function canAttachComment$1(node) {
|
46132 | return node.kind && node.kind !== "Comment";
|
46133 | }
|
46134 |
|
46135 | function printComment$2(commentPath) {
|
46136 | const comment = commentPath.getValue();
|
46137 |
|
46138 | if (comment.kind === "Comment") {
|
46139 | return "#" + comment.value.trimEnd();
|
46140 | }
|
46141 |
|
46142 | throw new Error("Not a comment: " + JSON.stringify(comment));
|
46143 | }
|
46144 |
|
46145 | function determineInterfaceSeparatorBetween(first, second, options) {
|
46146 | const textBetween = options.originalText.slice(first.loc.end, second.loc.start).replace(/#.*/g, "").trim();
|
46147 | return textBetween === "," ? ", " : " & ";
|
46148 | }
|
46149 |
|
46150 | function printInterfaces(path, options, print) {
|
46151 | const node = path.getNode();
|
46152 | const parts = [];
|
46153 | const {
|
46154 | interfaces
|
46155 | } = node;
|
46156 | const printed = path.map(node => print(node), "interfaces");
|
46157 |
|
46158 | for (let index = 0; index < interfaces.length; index++) {
|
46159 | const interfaceNode = interfaces[index];
|
46160 |
|
46161 | if (index > 0) {
|
46162 | parts.push(determineInterfaceSeparatorBetween(interfaces[index - 1], interfaceNode, options));
|
46163 | }
|
46164 |
|
46165 | parts.push(printed[index]);
|
46166 | }
|
46167 |
|
46168 | return parts;
|
46169 | }
|
46170 |
|
46171 | function clean$4(node, newNode
|
46172 | /*, parent*/
|
46173 | ) {
|
46174 | delete newNode.loc;
|
46175 | delete newNode.comments;
|
46176 | }
|
46177 |
|
46178 | var printerGraphql = {
|
46179 | print: genericPrint$3,
|
46180 | massageAstNode: clean$4,
|
46181 | hasPrettierIgnore: hasIgnoreComment$4,
|
46182 | insertPragma: insertPragma$5,
|
46183 | printComment: printComment$2,
|
46184 | canAttachComment: canAttachComment$1
|
46185 | };
|
46186 |
|
46187 | var options$4 = {
|
46188 | bracketSpacing: commonOptions.bracketSpacing
|
46189 | };
|
46190 |
|
46191 | var name$e = "GraphQL";
|
46192 | var type$c = "data";
|
46193 | var extensions$c = [
|
46194 | ".graphql",
|
46195 | ".gql",
|
46196 | ".graphqls"
|
46197 | ];
|
46198 | var tmScope$c = "source.graphql";
|
46199 | var aceMode$c = "text";
|
46200 | var languageId$c = 139;
|
46201 | var GraphQL = {
|
46202 | name: name$e,
|
46203 | type: type$c,
|
46204 | extensions: extensions$c,
|
46205 | tmScope: tmScope$c,
|
46206 | aceMode: aceMode$c,
|
46207 | languageId: languageId$c
|
46208 | };
|
46209 |
|
46210 | var GraphQL$1 = Object.freeze({
|
46211 | __proto__: null,
|
46212 | name: name$e,
|
46213 | type: type$c,
|
46214 | extensions: extensions$c,
|
46215 | tmScope: tmScope$c,
|
46216 | aceMode: aceMode$c,
|
46217 | languageId: languageId$c,
|
46218 | 'default': GraphQL
|
46219 | });
|
46220 |
|
46221 | var require$$0$4 = getCjsExportFromNamespace(GraphQL$1);
|
46222 |
|
46223 | const languages$3 = [createLanguage(require$$0$4, () => ({
|
46224 | since: "1.5.0",
|
46225 | parsers: ["graphql"],
|
46226 | vscodeLanguageIds: ["graphql"]
|
46227 | }))];
|
46228 | const printers$3 = {
|
46229 | graphql: printerGraphql
|
46230 | };
|
46231 | var languageGraphql = {
|
46232 | languages: languages$3,
|
46233 | options: options$4,
|
46234 | printers: printers$3
|
46235 | };
|
46236 |
|
46237 | var json = {
|
46238 | "cjkPattern": "[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u3000-\\u303f\\u3041-\\u3096\\u3099-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u3190-\\u3191\\u3196-\\u31ba\\u31c0-\\u31e3\\u31f0-\\u321e\\u322a-\\u3247\\u3260-\\u327e\\u328a-\\u32b0\\u32c0-\\u32cb\\u32d0-\\u3370\\u337b-\\u337f\\u33e0-\\u33fe\\u3400-\\u4db5\\u4e00-\\u9fef\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufe10-\\ufe1f\\ufe30-\\ufe6f\\uff00-\\uffef]|[\\ud840-\\ud868\\ud86a-\\ud86c\\ud86f-\\ud872\\ud874-\\ud879][\\udc00-\\udfff]|\\ud82c[\\udc00-\\udd1e\\udd50-\\udd52\\udd64-\\udd67]|\\ud83c[\\ude00\\ude50-\\ude51]|\\ud869[\\udc00-\\uded6\\udf00-\\udfff]|\\ud86d[\\udc00-\\udf34\\udf40-\\udfff]|\\ud86e[\\udc00-\\udc1d\\udc20-\\udfff]|\\ud873[\\udc00-\\udea1\\udeb0-\\udfff]|\\ud87a[\\udc00-\\udfe0]|\\ud87e[\\udc00-\\ude1d]",
|
46239 | "kPattern": "[\\u1100-\\u11ff\\u3001-\\u3003\\u3008-\\u3011\\u3013-\\u301f\\u302e-\\u3030\\u3037\\u30fb\\u3131-\\u318e\\u3200-\\u321e\\u3260-\\u327e\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\ufe45-\\ufe46\\uff61-\\uff65\\uffa0-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc]",
|
46240 | "punctuationPattern": "[\\u0021-\\u002f\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u007e\\u00a1\\u00a7\\u00ab\\u00b6-\\u00b7\\u00bb\\u00bf\\u037e\\u0387\\u055a-\\u055f\\u0589-\\u058a\\u05be\\u05c0\\u05c3\\u05c6\\u05f3-\\u05f4\\u0609-\\u060a\\u060c-\\u060d\\u061b\\u061e-\\u061f\\u066a-\\u066d\\u06d4\\u0700-\\u070d\\u07f7-\\u07f9\\u0830-\\u083e\\u085e\\u0964-\\u0965\\u0970\\u09fd\\u0a76\\u0af0\\u0c77\\u0c84\\u0df4\\u0e4f\\u0e5a-\\u0e5b\\u0f04-\\u0f12\\u0f14\\u0f3a-\\u0f3d\\u0f85\\u0fd0-\\u0fd4\\u0fd9-\\u0fda\\u104a-\\u104f\\u10fb\\u1360-\\u1368\\u1400\\u166e\\u169b-\\u169c\\u16eb-\\u16ed\\u1735-\\u1736\\u17d4-\\u17d6\\u17d8-\\u17da\\u1800-\\u180a\\u1944-\\u1945\\u1a1e-\\u1a1f\\u1aa0-\\u1aa6\\u1aa8-\\u1aad\\u1b5a-\\u1b60\\u1bfc-\\u1bff\\u1c3b-\\u1c3f\\u1c7e-\\u1c7f\\u1cc0-\\u1cc7\\u1cd3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205e\\u207d-\\u207e\\u208d-\\u208e\\u2308-\\u230b\\u2329-\\u232a\\u2768-\\u2775\\u27c5-\\u27c6\\u27e6-\\u27ef\\u2983-\\u2998\\u29d8-\\u29db\\u29fc-\\u29fd\\u2cf9-\\u2cfc\\u2cfe-\\u2cff\\u2d70\\u2e00-\\u2e2e\\u2e30-\\u2e4f\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301f\\u3030\\u303d\\u30a0\\u30fb\\ua4fe-\\ua4ff\\ua60d-\\ua60f\\ua673\\ua67e\\ua6f2-\\ua6f7\\ua874-\\ua877\\ua8ce-\\ua8cf\\ua8f8-\\ua8fa\\ua8fc\\ua92e-\\ua92f\\ua95f\\ua9c1-\\ua9cd\\ua9de-\\ua9df\\uaa5c-\\uaa5f\\uaade-\\uaadf\\uaaf0-\\uaaf1\\uabeb\\ufd3e-\\ufd3f\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe61\\ufe63\\ufe68\\ufe6a-\\ufe6b\\uff01-\\uff03\\uff05-\\uff0a\\uff0c-\\uff0f\\uff1a-\\uff1b\\uff1f-\\uff20\\uff3b-\\uff3d\\uff3f\\uff5b\\uff5d\\uff5f-\\uff65]|\\ud800[\\udd00-\\udd02\\udf9f\\udfd0]|\\ud801[\\udd6f]|\\ud802[\\udc57\\udd1f\\udd3f\\ude50-\\ude58\\ude7f\\udef0-\\udef6\\udf39-\\udf3f\\udf99-\\udf9c]|\\ud803[\\udf55-\\udf59]|\\ud804[\\udc47-\\udc4d\\udcbb-\\udcbc\\udcbe-\\udcc1\\udd40-\\udd43\\udd74-\\udd75\\uddc5-\\uddc8\\uddcd\\udddb\\udddd-\\udddf\\ude38-\\ude3d\\udea9]|\\ud805[\\udc4b-\\udc4f\\udc5b\\udc5d\\udcc6\\uddc1-\\uddd7\\ude41-\\ude43\\ude60-\\ude6c\\udf3c-\\udf3e]|\\ud806[\\udc3b\\udde2\\ude3f-\\ude46\\ude9a-\\ude9c\\ude9e-\\udea2]|\\ud807[\\udc41-\\udc45\\udc70-\\udc71\\udef7-\\udef8\\udfff]|\\ud809[\\udc70-\\udc74]|\\ud81a[\\ude6e-\\ude6f\\udef5\\udf37-\\udf3b\\udf44]|\\ud81b[\\ude97-\\ude9a\\udfe2]|\\ud82f[\\udc9f]|\\ud836[\\ude87-\\ude8b]|\\ud83a[\\udd5e-\\udd5f]"
|
46241 | };
|
46242 |
|
46243 | const {
|
46244 | cjkPattern,
|
46245 | kPattern,
|
46246 | punctuationPattern
|
46247 | } = json;
|
46248 | const {
|
46249 | getLast: getLast$4
|
46250 | } = util$1;
|
46251 | const INLINE_NODE_TYPES = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
|
46252 | const INLINE_NODE_WRAPPER_TYPES = INLINE_NODE_TYPES.concat(["tableCell", "paragraph", "heading"]);
|
46253 | const kRegex = new RegExp(kPattern);
|
46254 | const punctuationRegex = new RegExp(punctuationPattern);
|
46255 |
|
46256 |
|
46257 |
|
46258 |
|
46259 |
|
46260 |
|
46261 | function splitText(text, options) {
|
46262 | const KIND_NON_CJK = "non-cjk";
|
46263 | const KIND_CJ_LETTER = "cj-letter";
|
46264 | const KIND_K_LETTER = "k-letter";
|
46265 | const KIND_CJK_PUNCTUATION = "cjk-punctuation";
|
46266 | const nodes = [];
|
46267 | (options.proseWrap === "preserve" ? text : text.replace(new RegExp(`(${cjkPattern})\n(${cjkPattern})`, "g"), "$1$2")).split(/([ \t\n]+)/).forEach((token, index, tokens) => {
|
46268 |
|
46269 | if (index % 2 === 1) {
|
46270 | nodes.push({
|
46271 | type: "whitespace",
|
46272 | value: /\n/.test(token) ? "\n" : " "
|
46273 | });
|
46274 | return;
|
46275 | }
|
46276 |
|
46277 |
|
46278 | if ((index === 0 || index === tokens.length - 1) && token === "") {
|
46279 | return;
|
46280 | }
|
46281 |
|
46282 | token.split(new RegExp(`(${cjkPattern})`)).forEach((innerToken, innerIndex, innerTokens) => {
|
46283 | if ((innerIndex === 0 || innerIndex === innerTokens.length - 1) && innerToken === "") {
|
46284 | return;
|
46285 | }
|
46286 |
|
46287 |
|
46288 | if (innerIndex % 2 === 0) {
|
46289 | if (innerToken !== "") {
|
46290 | appendNode({
|
46291 | type: "word",
|
46292 | value: innerToken,
|
46293 | kind: KIND_NON_CJK,
|
46294 | hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
|
46295 | hasTrailingPunctuation: punctuationRegex.test(getLast$4(innerToken))
|
46296 | });
|
46297 | }
|
46298 |
|
46299 | return;
|
46300 | }
|
46301 |
|
46302 |
|
46303 | appendNode(punctuationRegex.test(innerToken) ? {
|
46304 | type: "word",
|
46305 | value: innerToken,
|
46306 | kind: KIND_CJK_PUNCTUATION,
|
46307 | hasLeadingPunctuation: true,
|
46308 | hasTrailingPunctuation: true
|
46309 | } : {
|
46310 | type: "word",
|
46311 | value: innerToken,
|
46312 | kind: kRegex.test(innerToken) ? KIND_K_LETTER : KIND_CJ_LETTER,
|
46313 | hasLeadingPunctuation: false,
|
46314 | hasTrailingPunctuation: false
|
46315 | });
|
46316 | });
|
46317 | });
|
46318 | return nodes;
|
46319 |
|
46320 | function appendNode(node) {
|
46321 | const lastNode = getLast$4(nodes);
|
46322 |
|
46323 | if (lastNode && lastNode.type === "word") {
|
46324 | if (lastNode.kind === KIND_NON_CJK && node.kind === KIND_CJ_LETTER && !lastNode.hasTrailingPunctuation || lastNode.kind === KIND_CJ_LETTER && node.kind === KIND_NON_CJK && !node.hasLeadingPunctuation) {
|
46325 | nodes.push({
|
46326 | type: "whitespace",
|
46327 | value: " "
|
46328 | });
|
46329 | } else if (!isBetween(KIND_NON_CJK, KIND_CJK_PUNCTUATION) &&
|
46330 | ![lastNode.value, node.value].some(value => /\u3000/.test(value))) {
|
46331 | nodes.push({
|
46332 | type: "whitespace",
|
46333 | value: ""
|
46334 | });
|
46335 | }
|
46336 | }
|
46337 |
|
46338 | nodes.push(node);
|
46339 |
|
46340 | function isBetween(kind1, kind2) {
|
46341 | return lastNode.kind === kind1 && node.kind === kind2 || lastNode.kind === kind2 && node.kind === kind1;
|
46342 | }
|
46343 | }
|
46344 | }
|
46345 |
|
46346 | function getOrderedListItemInfo(orderListItem, originalText) {
|
46347 | const [, numberText, marker, leadingSpaces] = originalText.slice(orderListItem.position.start.offset, orderListItem.position.end.offset).match(/^\s*(\d+)(\.|\))(\s*)/);
|
46348 | return {
|
46349 | numberText,
|
46350 | marker,
|
46351 | leadingSpaces
|
46352 | };
|
46353 | }
|
46354 |
|
46355 | function hasGitDiffFriendlyOrderedList(node, options) {
|
46356 | if (!node.ordered) {
|
46357 | return false;
|
46358 | }
|
46359 |
|
46360 | if (node.children.length < 2) {
|
46361 | return false;
|
46362 | }
|
46363 |
|
46364 | const firstNumber = Number(getOrderedListItemInfo(node.children[0], options.originalText).numberText);
|
46365 | const secondNumber = Number(getOrderedListItemInfo(node.children[1], options.originalText).numberText);
|
46366 |
|
46367 | if (firstNumber === 0 && node.children.length > 2) {
|
46368 | const thirdNumber = Number(getOrderedListItemInfo(node.children[2], options.originalText).numberText);
|
46369 | return secondNumber === 1 && thirdNumber === 1;
|
46370 | }
|
46371 |
|
46372 | return secondNumber === 1;
|
46373 | }
|
46374 |
|
46375 |
|
46376 |
|
46377 | function getFencedCodeBlockValue(node, originalText) {
|
46378 | const text = originalText.slice(node.position.start.offset, node.position.end.offset);
|
46379 | const leadingSpaceCount = text.match(/^\s*/)[0].length;
|
46380 | const replaceRegex = new RegExp(`^\\s{0,${leadingSpaceCount}}`);
|
46381 | const lineContents = text.split("\n");
|
46382 | const markerStyle = text[leadingSpaceCount];
|
46383 |
|
46384 | const marker = text.slice(leadingSpaceCount).match(new RegExp(`^[${markerStyle}]+`))[0];
|
46385 |
|
46386 |
|
46387 | const hasEndMarker = new RegExp(`^\\s{0,3}${marker}`).test(lineContents[lineContents.length - 1].slice(getIndent(lineContents.length - 1)));
|
46388 | return lineContents.slice(1, hasEndMarker ? -1 : undefined).map((x, i) => x.slice(getIndent(i + 1)).replace(replaceRegex, "")).join("\n");
|
46389 |
|
46390 | function getIndent(lineIndex) {
|
46391 | return node.position.indent[lineIndex - 1] - 1;
|
46392 | }
|
46393 | }
|
46394 |
|
46395 | function mapAst(ast, handler) {
|
46396 | return function preorder(node, index, parentStack) {
|
46397 | parentStack = parentStack || [];
|
46398 | const newNode = Object.assign({}, handler(node, index, parentStack));
|
46399 |
|
46400 | if (newNode.children) {
|
46401 | newNode.children = newNode.children.map((child, index) => {
|
46402 | return preorder(child, index, [newNode].concat(parentStack));
|
46403 | });
|
46404 | }
|
46405 |
|
46406 | return newNode;
|
46407 | }(ast, null, null);
|
46408 | }
|
46409 |
|
46410 | var utils$9 = {
|
46411 | mapAst,
|
46412 | splitText,
|
46413 | punctuationPattern,
|
46414 | getFencedCodeBlockValue,
|
46415 | getOrderedListItemInfo,
|
46416 | hasGitDiffFriendlyOrderedList,
|
46417 | INLINE_NODE_TYPES,
|
46418 | INLINE_NODE_WRAPPER_TYPES
|
46419 | };
|
46420 |
|
46421 | const {
|
46422 | builders: {
|
46423 | hardline: hardline$a,
|
46424 | literalline: literalline$4,
|
46425 | concat: concat$c,
|
46426 | markAsRoot: markAsRoot$2
|
46427 | },
|
46428 | utils: {
|
46429 | mapDoc: mapDoc$3
|
46430 | }
|
46431 | } = document;
|
46432 | const {
|
46433 | getFencedCodeBlockValue: getFencedCodeBlockValue$1
|
46434 | } = utils$9;
|
46435 |
|
46436 | function embed$2(path, print, textToDoc, options) {
|
46437 | const node = path.getValue();
|
46438 |
|
46439 | if (node.type === "code" && node.lang !== null) {
|
46440 |
|
46441 | const langMatch = node.lang.match(/^[A-Za-z0-9_-]+/);
|
46442 | const lang = langMatch ? langMatch[0] : "";
|
46443 | const parser = getParserName(lang);
|
46444 |
|
46445 | if (parser) {
|
46446 | const styleUnit = options.__inJsTemplate ? "~" : "`";
|
46447 | const style = styleUnit.repeat(Math.max(3, util$1.getMaxContinuousCount(node.value, styleUnit) + 1));
|
46448 | const doc = textToDoc(getFencedCodeBlockValue$1(node, options.originalText), {
|
46449 | parser
|
46450 | });
|
46451 | return markAsRoot$2(concat$c([style, node.lang, hardline$a, replaceNewlinesWithLiterallines(doc), style]));
|
46452 | }
|
46453 | }
|
46454 |
|
46455 | if (node.type === "yaml") {
|
46456 | return markAsRoot$2(concat$c(["---", hardline$a, node.value && node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
|
46457 | parser: "yaml"
|
46458 | })) : "", "---"]));
|
46459 | }
|
46460 |
|
46461 |
|
46462 | switch (node.type) {
|
46463 | case "importExport":
|
46464 | return textToDoc(node.value, {
|
46465 | parser: "babel"
|
46466 | });
|
46467 |
|
46468 | case "jsx":
|
46469 | return textToDoc(`<$>${node.value}</$>`, {
|
46470 | parser: "__js_expression",
|
46471 | rootMarker: "mdx"
|
46472 | });
|
46473 | }
|
46474 |
|
46475 | return null;
|
46476 |
|
46477 | function getParserName(lang) {
|
46478 | const supportInfo = support.getSupportInfo({
|
46479 | plugins: options.plugins
|
46480 | });
|
46481 | const language = supportInfo.languages.find(language => language.name.toLowerCase() === lang || language.aliases && language.aliases.includes(lang) || language.extensions && language.extensions.find(ext => ext === `.${lang}`));
|
46482 |
|
46483 | if (language) {
|
46484 | return language.parsers[0];
|
46485 | }
|
46486 |
|
46487 | return null;
|
46488 | }
|
46489 |
|
46490 | function replaceNewlinesWithLiterallines(doc) {
|
46491 | return mapDoc$3(doc, currentDoc => typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$c(currentDoc.split(/(\n)/g).map((v, i) => i % 2 === 0 ? v : literalline$4)) : currentDoc);
|
46492 | }
|
46493 | }
|
46494 |
|
46495 | var embed_1$2 = embed$2;
|
46496 |
|
46497 | const pragmas = ["format", "prettier"];
|
46498 |
|
46499 | function startWithPragma(text) {
|
46500 | const pragma = `@(${pragmas.join("|")})`;
|
46501 | const regex = new RegExp([`<!--\\s*${pragma}\\s*-->`, `<!--.*\r?\n[\\s\\S]*(^|\n)[^\\S\n]*${pragma}[^\\S\n]*($|\n)[\\s\\S]*\n.*-->`].join("|"), "m");
|
46502 | const matched = text.match(regex);
|
46503 | return matched && matched.index === 0;
|
46504 | }
|
46505 |
|
46506 | var pragma$3 = {
|
46507 | startWithPragma,
|
46508 | hasPragma: text => startWithPragma(frontMatter(text).content.trimStart()),
|
46509 | insertPragma: text => {
|
46510 | const extracted = frontMatter(text);
|
46511 | const pragma = `<!-- @${pragmas[0]} -->`;
|
46512 | return extracted.frontMatter ? `${extracted.frontMatter.raw}\n\n${pragma}\n\n${extracted.content}` : `${pragma}\n\n${extracted.content}`;
|
46513 | }
|
46514 | };
|
46515 |
|
46516 | const {
|
46517 | getOrderedListItemInfo: getOrderedListItemInfo$1,
|
46518 | mapAst: mapAst$1,
|
46519 | splitText: splitText$1
|
46520 | } = utils$9;
|
46521 |
|
46522 |
|
46523 | const isSingleCharRegex = /^([\u0000-\uffff]|[\ud800-\udbff][\udc00-\udfff])$/;
|
46524 |
|
46525 | function preprocess$1(ast, options) {
|
46526 | ast = restoreUnescapedCharacter(ast, options);
|
46527 | ast = mergeContinuousTexts(ast);
|
46528 | ast = transformInlineCode(ast);
|
46529 | ast = transformIndentedCodeblockAndMarkItsParentList(ast, options);
|
46530 | ast = markAlignedList(ast, options);
|
46531 | ast = splitTextIntoSentences(ast, options);
|
46532 | ast = transformImportExport(ast);
|
46533 | ast = mergeContinuousImportExport(ast);
|
46534 | return ast;
|
46535 | }
|
46536 |
|
46537 | function transformImportExport(ast) {
|
46538 | return mapAst$1(ast, node => {
|
46539 | if (node.type !== "import" && node.type !== "export") {
|
46540 | return node;
|
46541 | }
|
46542 |
|
46543 | return Object.assign({}, node, {
|
46544 | type: "importExport"
|
46545 | });
|
46546 | });
|
46547 | }
|
46548 |
|
46549 | function transformInlineCode(ast) {
|
46550 | return mapAst$1(ast, node => {
|
46551 | if (node.type !== "inlineCode") {
|
46552 | return node;
|
46553 | }
|
46554 |
|
46555 | return Object.assign({}, node, {
|
46556 | value: node.value.replace(/\s+/g, " ")
|
46557 | });
|
46558 | });
|
46559 | }
|
46560 |
|
46561 | function restoreUnescapedCharacter(ast, options) {
|
46562 | return mapAst$1(ast, node => {
|
46563 | return node.type !== "text" ? node : Object.assign({}, node, {
|
46564 | value: node.value !== "*" && node.value !== "_" && node.value !== "$" &&
|
46565 | isSingleCharRegex.test(node.value) && node.position.end.offset - node.position.start.offset !== node.value.length ? options.originalText.slice(node.position.start.offset, node.position.end.offset) : node.value
|
46566 | });
|
46567 | });
|
46568 | }
|
46569 |
|
46570 | function mergeContinuousImportExport(ast) {
|
46571 | return mergeChildren(ast, (prevNode, node) => prevNode.type === "importExport" && node.type === "importExport", (prevNode, node) => ({
|
46572 | type: "importExport",
|
46573 | value: prevNode.value + "\n\n" + node.value,
|
46574 | position: {
|
46575 | start: prevNode.position.start,
|
46576 | end: node.position.end
|
46577 | }
|
46578 | }));
|
46579 | }
|
46580 |
|
46581 | function mergeChildren(ast, shouldMerge, mergeNode) {
|
46582 | return mapAst$1(ast, node => {
|
46583 | if (!node.children) {
|
46584 | return node;
|
46585 | }
|
46586 |
|
46587 | const children = node.children.reduce((current, child) => {
|
46588 | const lastChild = current[current.length - 1];
|
46589 |
|
46590 | if (lastChild && shouldMerge(lastChild, child)) {
|
46591 | current.splice(-1, 1, mergeNode(lastChild, child));
|
46592 | } else {
|
46593 | current.push(child);
|
46594 | }
|
46595 |
|
46596 | return current;
|
46597 | }, []);
|
46598 | return Object.assign({}, node, {
|
46599 | children
|
46600 | });
|
46601 | });
|
46602 | }
|
46603 |
|
46604 | function mergeContinuousTexts(ast) {
|
46605 | return mergeChildren(ast, (prevNode, node) => prevNode.type === "text" && node.type === "text", (prevNode, node) => ({
|
46606 | type: "text",
|
46607 | value: prevNode.value + node.value,
|
46608 | position: {
|
46609 | start: prevNode.position.start,
|
46610 | end: node.position.end
|
46611 | }
|
46612 | }));
|
46613 | }
|
46614 |
|
46615 | function splitTextIntoSentences(ast, options) {
|
46616 | return mapAst$1(ast, (node, index, [parentNode]) => {
|
46617 | if (node.type !== "text") {
|
46618 | return node;
|
46619 | }
|
46620 |
|
46621 | let {
|
46622 | value
|
46623 | } = node;
|
46624 |
|
46625 | if (parentNode.type === "paragraph") {
|
46626 | if (index === 0) {
|
46627 | value = value.trimStart();
|
46628 | }
|
46629 |
|
46630 | if (index === parentNode.children.length - 1) {
|
46631 | value = value.trimEnd();
|
46632 | }
|
46633 | }
|
46634 |
|
46635 | return {
|
46636 | type: "sentence",
|
46637 | position: node.position,
|
46638 | children: splitText$1(value, options)
|
46639 | };
|
46640 | });
|
46641 | }
|
46642 |
|
46643 | function transformIndentedCodeblockAndMarkItsParentList(ast, options) {
|
46644 | return mapAst$1(ast, (node, index, parentStack) => {
|
46645 | if (node.type === "code") {
|
46646 |
|
46647 | const isIndented = /^\n?( {4,}|\t)/.test(options.originalText.slice(node.position.start.offset, node.position.end.offset));
|
46648 | node.isIndented = isIndented;
|
46649 |
|
46650 | if (isIndented) {
|
46651 | for (let i = 0; i < parentStack.length; i++) {
|
46652 | const parent = parentStack[i];
|
46653 |
|
46654 | if (parent.hasIndentedCodeblock) {
|
46655 | break;
|
46656 | }
|
46657 |
|
46658 | if (parent.type === "list") {
|
46659 | parent.hasIndentedCodeblock = true;
|
46660 | }
|
46661 | }
|
46662 | }
|
46663 | }
|
46664 |
|
46665 | return node;
|
46666 | });
|
46667 | }
|
46668 |
|
46669 | function markAlignedList(ast, options) {
|
46670 | return mapAst$1(ast, (node, index, parentStack) => {
|
46671 | if (node.type === "list" && node.children.length !== 0) {
|
46672 |
|
46673 | for (let i = 0; i < parentStack.length; i++) {
|
46674 | const parent = parentStack[i];
|
46675 |
|
46676 | if (parent.type === "list" && !parent.isAligned) {
|
46677 | node.isAligned = false;
|
46678 | return node;
|
46679 | }
|
46680 | }
|
46681 |
|
46682 | node.isAligned = isAligned(node);
|
46683 | }
|
46684 |
|
46685 | return node;
|
46686 | });
|
46687 |
|
46688 | function getListItemStart(listItem) {
|
46689 | return listItem.children.length === 0 ? -1 : listItem.children[0].position.start.column - 1;
|
46690 | }
|
46691 |
|
46692 | function isAligned(list) {
|
46693 | if (!list.ordered) {
|
46694 | |
46695 |
|
46696 |
|
46697 |
|
46698 | return true;
|
46699 | }
|
46700 |
|
46701 | const [firstItem, secondItem] = list.children;
|
46702 | const firstInfo = getOrderedListItemInfo$1(firstItem, options.originalText);
|
46703 |
|
46704 | if (firstInfo.leadingSpaces.length > 1) {
|
46705 | |
46706 |
|
46707 |
|
46708 |
|
46709 |
|
46710 |
|
46711 | return true;
|
46712 | }
|
46713 |
|
46714 | const firstStart = getListItemStart(firstItem);
|
46715 |
|
46716 | if (firstStart === -1) {
|
46717 | |
46718 |
|
46719 |
|
46720 |
|
46721 |
|
46722 |
|
46723 | return false;
|
46724 | }
|
46725 |
|
46726 | if (list.children.length === 1) {
|
46727 | |
46728 |
|
46729 |
|
46730 |
|
46731 |
|
46732 |
|
46733 |
|
46734 |
|
46735 |
|
46736 | return firstStart % options.tabWidth === 0;
|
46737 | }
|
46738 |
|
46739 | const secondStart = getListItemStart(secondItem);
|
46740 |
|
46741 | if (firstStart !== secondStart) {
|
46742 | |
46743 |
|
46744 |
|
46745 |
|
46746 |
|
46747 |
|
46748 |
|
46749 | return false;
|
46750 | }
|
46751 |
|
46752 | if (firstStart % options.tabWidth === 0) {
|
46753 | |
46754 |
|
46755 |
|
46756 |
|
46757 | return true;
|
46758 | }
|
46759 | |
46760 |
|
46761 |
|
46762 |
|
46763 |
|
46764 |
|
46765 |
|
46766 |
|
46767 |
|
46768 |
|
46769 |
|
46770 |
|
46771 |
|
46772 | const secondInfo = getOrderedListItemInfo$1(secondItem, options.originalText);
|
46773 | return secondInfo.leadingSpaces.length > 1;
|
46774 | }
|
46775 | }
|
46776 |
|
46777 | var preprocess_1$1 = preprocess$1;
|
46778 |
|
46779 | const {
|
46780 | builders: {
|
46781 | breakParent: breakParent$3,
|
46782 | concat: concat$d,
|
46783 | join: join$9,
|
46784 | line: line$8,
|
46785 | literalline: literalline$5,
|
46786 | markAsRoot: markAsRoot$3,
|
46787 | hardline: hardline$b,
|
46788 | softline: softline$6,
|
46789 | ifBreak: ifBreak$5,
|
46790 | fill: fill$5,
|
46791 | align: align$2,
|
46792 | indent: indent$8,
|
46793 | group: group$d
|
46794 | },
|
46795 | utils: {
|
46796 | mapDoc: mapDoc$4
|
46797 | },
|
46798 | printer: {
|
46799 | printDocToString: printDocToString$3
|
46800 | }
|
46801 | } = document;
|
46802 | const {
|
46803 | getFencedCodeBlockValue: getFencedCodeBlockValue$2,
|
46804 | hasGitDiffFriendlyOrderedList: hasGitDiffFriendlyOrderedList$1,
|
46805 | splitText: splitText$2,
|
46806 | punctuationPattern: punctuationPattern$1,
|
46807 | INLINE_NODE_TYPES: INLINE_NODE_TYPES$1,
|
46808 | INLINE_NODE_WRAPPER_TYPES: INLINE_NODE_WRAPPER_TYPES$1
|
46809 | } = utils$9;
|
46810 | const {
|
46811 | replaceEndOfLineWith: replaceEndOfLineWith$1
|
46812 | } = util$1;
|
46813 | const TRAILING_HARDLINE_NODES = ["importExport"];
|
46814 | const SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
|
46815 | const SIBLING_NODE_TYPES = ["listItem", "definition", "footnoteDefinition"];
|
46816 |
|
46817 | function genericPrint$4(path, options, print) {
|
46818 | const node = path.getValue();
|
46819 |
|
46820 | if (shouldRemainTheSameContent(path)) {
|
46821 | return concat$d(splitText$2(options.originalText.slice(node.position.start.offset, node.position.end.offset), options).map(node => node.type === "word" ? node.value : node.value === "" ? "" : printLine(path, node.value, options)));
|
46822 | }
|
46823 |
|
46824 | switch (node.type) {
|
46825 | case "root":
|
46826 | if (node.children.length === 0) {
|
46827 | return "";
|
46828 | }
|
46829 |
|
46830 | return concat$d([normalizeDoc(printRoot(path, options, print)), !TRAILING_HARDLINE_NODES.includes(getLastDescendantNode(node).type) ? hardline$b : ""]);
|
46831 |
|
46832 | case "paragraph":
|
46833 | return printChildren$1(path, options, print, {
|
46834 | postprocessor: fill$5
|
46835 | });
|
46836 |
|
46837 | case "sentence":
|
46838 | return printChildren$1(path, options, print);
|
46839 |
|
46840 | case "word":
|
46841 | return node.value.replace(/[*$]/g, "\\$&")
|
46842 | .replace(new RegExp([`(^|${punctuationPattern$1})(_+)`, `(_+)(${punctuationPattern$1}|$)`].join("|"), "g"), (_, text1, underscore1, underscore2, text2) => (underscore1 ? `${text1}${underscore1}` : `${underscore2}${text2}`).replace(/_/g, "\\_"));
|
46843 |
|
46844 |
|
46845 | case "whitespace":
|
46846 | {
|
46847 | const parentNode = path.getParentNode();
|
46848 | const index = parentNode.children.indexOf(node);
|
46849 | const nextNode = parentNode.children[index + 1];
|
46850 | const proseWrap =
|
46851 | nextNode && /^>|^([-+*]|#{1,6}|[0-9]+[.)])$/.test(nextNode.value) ? "never" : options.proseWrap;
|
46852 | return printLine(path, node.value, {
|
46853 | proseWrap
|
46854 | });
|
46855 | }
|
46856 |
|
46857 | case "emphasis":
|
46858 | {
|
46859 | const parentNode = path.getParentNode();
|
46860 | const index = parentNode.children.indexOf(node);
|
46861 | const prevNode = parentNode.children[index - 1];
|
46862 | const nextNode = parentNode.children[index + 1];
|
46863 | const hasPrevOrNextWord =
|
46864 | prevNode && prevNode.type === "sentence" && prevNode.children.length > 0 && util$1.getLast(prevNode.children).type === "word" && !util$1.getLast(prevNode.children).hasTrailingPunctuation || nextNode && nextNode.type === "sentence" && nextNode.children.length > 0 && nextNode.children[0].type === "word" && !nextNode.children[0].hasLeadingPunctuation;
|
46865 | const style = hasPrevOrNextWord || getAncestorNode$2(path, "emphasis") ? "*" : "_";
|
46866 | return concat$d([style, printChildren$1(path, options, print), style]);
|
46867 | }
|
46868 |
|
46869 | case "strong":
|
46870 | return concat$d(["**", printChildren$1(path, options, print), "**"]);
|
46871 |
|
46872 | case "delete":
|
46873 | return concat$d(["~~", printChildren$1(path, options, print), "~~"]);
|
46874 |
|
46875 | case "inlineCode":
|
46876 | {
|
46877 | const backtickCount = util$1.getMinNotPresentContinuousCount(node.value, "`");
|
46878 | const style = "`".repeat(backtickCount || 1);
|
46879 | const gap = backtickCount ? " " : "";
|
46880 | return concat$d([style, gap, node.value, gap, style]);
|
46881 | }
|
46882 |
|
46883 | case "link":
|
46884 | switch (options.originalText[node.position.start.offset]) {
|
46885 | case "<":
|
46886 | {
|
46887 | const mailto = "mailto:";
|
46888 | const url =
|
46889 | node.url.startsWith(mailto) && options.originalText.slice(node.position.start.offset + 1, node.position.start.offset + 1 + mailto.length) !== mailto ? node.url.slice(mailto.length) : node.url;
|
46890 | return concat$d(["<", url, ">"]);
|
46891 | }
|
46892 |
|
46893 | case "[":
|
46894 | return concat$d(["[", printChildren$1(path, options, print), "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
|
46895 |
|
46896 | default:
|
46897 | return options.originalText.slice(node.position.start.offset, node.position.end.offset);
|
46898 | }
|
46899 |
|
46900 | case "image":
|
46901 | return concat$d(["![", node.alt || "", "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
|
46902 |
|
46903 | case "blockquote":
|
46904 | return concat$d(["> ", align$2("> ", printChildren$1(path, options, print))]);
|
46905 |
|
46906 | case "heading":
|
46907 | return concat$d(["#".repeat(node.depth) + " ", printChildren$1(path, options, print)]);
|
46908 |
|
46909 | case "code":
|
46910 | {
|
46911 | if (node.isIndented) {
|
46912 |
|
46913 | const alignment = " ".repeat(4);
|
46914 | return align$2(alignment, concat$d([alignment, concat$d(replaceEndOfLineWith$1(node.value, hardline$b))]));
|
46915 | }
|
46916 |
|
46917 |
|
46918 | const styleUnit = options.__inJsTemplate ? "~" : "`";
|
46919 | const style = styleUnit.repeat(Math.max(3, util$1.getMaxContinuousCount(node.value, styleUnit) + 1));
|
46920 | return concat$d([style, node.lang || "", hardline$b, concat$d(replaceEndOfLineWith$1(getFencedCodeBlockValue$2(node, options.originalText), hardline$b)), hardline$b, style]);
|
46921 | }
|
46922 |
|
46923 | case "yaml":
|
46924 | case "toml":
|
46925 | return options.originalText.slice(node.position.start.offset, node.position.end.offset);
|
46926 |
|
46927 | case "html":
|
46928 | {
|
46929 | const parentNode = path.getParentNode();
|
46930 | const value = parentNode.type === "root" && util$1.getLast(parentNode.children) === node ? node.value.trimEnd() : node.value;
|
46931 | const isHtmlComment = /^<!--[\s\S]*-->$/.test(value);
|
46932 | return concat$d(replaceEndOfLineWith$1(value, isHtmlComment ? hardline$b : markAsRoot$3(literalline$5)));
|
46933 | }
|
46934 |
|
46935 | case "list":
|
46936 | {
|
46937 | const nthSiblingIndex = getNthListSiblingIndex(node, path.getParentNode());
|
46938 | const isGitDiffFriendlyOrderedList = hasGitDiffFriendlyOrderedList$1(node, options);
|
46939 | return printChildren$1(path, options, print, {
|
46940 | processor: (childPath, index) => {
|
46941 | const prefix = getPrefix();
|
46942 | const childNode = childPath.getValue();
|
46943 |
|
46944 | if (childNode.children.length === 2 && childNode.children[1].type === "html" && childNode.children[0].position.start.column !== childNode.children[1].position.start.column) {
|
46945 | return concat$d([prefix, printListItem(childPath, options, print, prefix)]);
|
46946 | }
|
46947 |
|
46948 | return concat$d([prefix, align$2(" ".repeat(prefix.length), printListItem(childPath, options, print, prefix))]);
|
46949 |
|
46950 | function getPrefix() {
|
46951 | const rawPrefix = node.ordered ? (index === 0 ? node.start : isGitDiffFriendlyOrderedList ? 1 : node.start + index) + (nthSiblingIndex % 2 === 0 ? ". " : ") ") : nthSiblingIndex % 2 === 0 ? "- " : "* ";
|
46952 | return node.isAligned ||
|
46953 |
|
46954 | node.hasIndentedCodeblock ? alignListPrefix(rawPrefix, options) : rawPrefix;
|
46955 | }
|
46956 | }
|
46957 | });
|
46958 | }
|
46959 |
|
46960 | case "thematicBreak":
|
46961 | {
|
46962 | const counter = getAncestorCounter$1(path, "list");
|
46963 |
|
46964 | if (counter === -1) {
|
46965 | return "---";
|
46966 | }
|
46967 |
|
46968 | const nthSiblingIndex = getNthListSiblingIndex(path.getParentNode(counter), path.getParentNode(counter + 1));
|
46969 | return nthSiblingIndex % 2 === 0 ? "***" : "---";
|
46970 | }
|
46971 |
|
46972 | case "linkReference":
|
46973 | return concat$d(["[", printChildren$1(path, options, print), "]", node.referenceType === "full" ? concat$d(["[", node.identifier, "]"]) : node.referenceType === "collapsed" ? "[]" : ""]);
|
46974 |
|
46975 | case "imageReference":
|
46976 | switch (node.referenceType) {
|
46977 | case "full":
|
46978 | return concat$d(["![", node.alt || "", "][", node.identifier, "]"]);
|
46979 |
|
46980 | default:
|
46981 | return concat$d(["![", node.alt, "]", node.referenceType === "collapsed" ? "[]" : ""]);
|
46982 | }
|
46983 |
|
46984 | case "definition":
|
46985 | {
|
46986 | const lineOrSpace = options.proseWrap === "always" ? line$8 : " ";
|
46987 | return group$d(concat$d([concat$d(["[", node.identifier, "]:"]), indent$8(concat$d([lineOrSpace, printUrl(node.url), node.title === null ? "" : concat$d([lineOrSpace, printTitle(node.title, options, false)])]))]));
|
46988 | }
|
46989 |
|
46990 | case "footnote":
|
46991 | return concat$d(["[^", printChildren$1(path, options, print), "]"]);
|
46992 |
|
46993 | case "footnoteReference":
|
46994 | return concat$d(["[^", node.identifier, "]"]);
|
46995 |
|
46996 | case "footnoteDefinition":
|
46997 | {
|
46998 | const nextNode = path.getParentNode().children[path.getName() + 1];
|
46999 | const shouldInlineFootnote = node.children.length === 1 && node.children[0].type === "paragraph" && (options.proseWrap === "never" || options.proseWrap === "preserve" && node.children[0].position.start.line === node.children[0].position.end.line);
|
47000 | return concat$d(["[^", node.identifier, "]: ", shouldInlineFootnote ? printChildren$1(path, options, print) : group$d(concat$d([align$2(" ".repeat(options.tabWidth), printChildren$1(path, options, print, {
|
47001 | processor: (childPath, index) => {
|
47002 | return index === 0 ? group$d(concat$d([softline$6, childPath.call(print)])) : childPath.call(print);
|
47003 | }
|
47004 | })), nextNode && nextNode.type === "footnoteDefinition" ? softline$6 : ""]))]);
|
47005 | }
|
47006 |
|
47007 | case "table":
|
47008 | return printTable(path, options, print);
|
47009 |
|
47010 | case "tableCell":
|
47011 | return printChildren$1(path, options, print);
|
47012 |
|
47013 | case "break":
|
47014 | return /\s/.test(options.originalText[node.position.start.offset]) ? concat$d([" ", markAsRoot$3(literalline$5)]) : concat$d(["\\", hardline$b]);
|
47015 |
|
47016 | case "liquidNode":
|
47017 | return concat$d(replaceEndOfLineWith$1(node.value, hardline$b));
|
47018 |
|
47019 |
|
47020 | case "importExport":
|
47021 | case "jsx":
|
47022 | return node.value;
|
47023 |
|
47024 |
|
47025 | case "math":
|
47026 | return concat$d(["$$", hardline$b, node.value ? concat$d([concat$d(replaceEndOfLineWith$1(node.value, hardline$b)), hardline$b]) : "", "$$"]);
|
47027 |
|
47028 | case "inlineMath":
|
47029 | {
|
47030 |
|
47031 |
|
47032 | return options.originalText.slice(options.locStart(node), options.locEnd(node));
|
47033 | }
|
47034 |
|
47035 | case "tableRow":
|
47036 |
|
47037 | case "listItem":
|
47038 |
|
47039 | default:
|
47040 | throw new Error(`Unknown markdown type ${JSON.stringify(node.type)}`);
|
47041 | }
|
47042 | }
|
47043 |
|
47044 | function printListItem(path, options, print, listPrefix) {
|
47045 | const node = path.getValue();
|
47046 | const prefix = node.checked === null ? "" : node.checked ? "[x] " : "[ ] ";
|
47047 | return concat$d([prefix, printChildren$1(path, options, print, {
|
47048 | processor: (childPath, index) => {
|
47049 | if (index === 0 && childPath.getValue().type !== "list") {
|
47050 | return align$2(" ".repeat(prefix.length), childPath.call(print));
|
47051 | }
|
47052 |
|
47053 | const alignment = " ".repeat(clamp(options.tabWidth - listPrefix.length, 0, 3)
|
47054 | );
|
47055 | return concat$d([alignment, align$2(alignment, childPath.call(print))]);
|
47056 | }
|
47057 | })]);
|
47058 | }
|
47059 |
|
47060 | function alignListPrefix(prefix, options) {
|
47061 | const additionalSpaces = getAdditionalSpaces();
|
47062 | return prefix + " ".repeat(additionalSpaces >= 4 ? 0 : additionalSpaces
|
47063 | );
|
47064 |
|
47065 | function getAdditionalSpaces() {
|
47066 | const restSpaces = prefix.length % options.tabWidth;
|
47067 | return restSpaces === 0 ? 0 : options.tabWidth - restSpaces;
|
47068 | }
|
47069 | }
|
47070 |
|
47071 | function getNthListSiblingIndex(node, parentNode) {
|
47072 | return getNthSiblingIndex(node, parentNode, siblingNode => siblingNode.ordered === node.ordered);
|
47073 | }
|
47074 |
|
47075 | function getNthSiblingIndex(node, parentNode, condition) {
|
47076 | condition = condition || (() => true);
|
47077 |
|
47078 | let index = -1;
|
47079 |
|
47080 | for (const childNode of parentNode.children) {
|
47081 | if (childNode.type === node.type && condition(childNode)) {
|
47082 | index++;
|
47083 | } else {
|
47084 | index = -1;
|
47085 | }
|
47086 |
|
47087 | if (childNode === node) {
|
47088 | return index;
|
47089 | }
|
47090 | }
|
47091 | }
|
47092 |
|
47093 | function getAncestorCounter$1(path, typeOrTypes) {
|
47094 | const types = [].concat(typeOrTypes);
|
47095 | let counter = -1;
|
47096 | let ancestorNode;
|
47097 |
|
47098 | while (ancestorNode = path.getParentNode(++counter)) {
|
47099 | if (types.includes(ancestorNode.type)) {
|
47100 | return counter;
|
47101 | }
|
47102 | }
|
47103 |
|
47104 | return -1;
|
47105 | }
|
47106 |
|
47107 | function getAncestorNode$2(path, typeOrTypes) {
|
47108 | const counter = getAncestorCounter$1(path, typeOrTypes);
|
47109 | return counter === -1 ? null : path.getParentNode(counter);
|
47110 | }
|
47111 |
|
47112 | function printLine(path, value, options) {
|
47113 | if (options.proseWrap === "preserve" && value === "\n") {
|
47114 | return hardline$b;
|
47115 | }
|
47116 |
|
47117 | const isBreakable = options.proseWrap === "always" && !getAncestorNode$2(path, SINGLE_LINE_NODE_TYPES);
|
47118 | return value !== "" ? isBreakable ? line$8 : " " : isBreakable ? softline$6 : "";
|
47119 | }
|
47120 |
|
47121 | function printTable(path, options, print) {
|
47122 | const hardlineWithoutBreakParent = hardline$b.parts[0];
|
47123 | const node = path.getValue();
|
47124 | const contents = [];
|
47125 |
|
47126 | path.map(rowPath => {
|
47127 | const rowContents = [];
|
47128 | rowPath.map(cellPath => {
|
47129 | rowContents.push(printDocToString$3(cellPath.call(print), options).formatted);
|
47130 | }, "children");
|
47131 | contents.push(rowContents);
|
47132 | }, "children");
|
47133 |
|
47134 | const columnMaxWidths = contents.reduce((currentWidths, rowContents) => currentWidths.map((width, columnIndex) => Math.max(width, util$1.getStringWidth(rowContents[columnIndex]))), contents[0].map(() => 3)
|
47135 | );
|
47136 | const alignedTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0]), printSeparator(), join$9(hardlineWithoutBreakParent, contents.slice(1).map(rowContents => printRow(rowContents)))]);
|
47137 |
|
47138 | if (options.proseWrap !== "never") {
|
47139 | return concat$d([breakParent$3, alignedTable]);
|
47140 | }
|
47141 |
|
47142 |
|
47143 | const compactTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0],
|
47144 |
|
47145 | true), printSeparator(
|
47146 |
|
47147 | true), join$9(hardlineWithoutBreakParent, contents.slice(1).map(rowContents => printRow(rowContents,
|
47148 |
|
47149 | true)))]);
|
47150 | return concat$d([breakParent$3, group$d(ifBreak$5(compactTable, alignedTable))]);
|
47151 |
|
47152 | function printSeparator(isCompact) {
|
47153 | return concat$d(["| ", join$9(" | ", columnMaxWidths.map((width, index) => {
|
47154 | const spaces = isCompact ? 3 : width;
|
47155 |
|
47156 | switch (node.align[index]) {
|
47157 | case "left":
|
47158 | return ":" + "-".repeat(spaces - 1);
|
47159 |
|
47160 | case "right":
|
47161 | return "-".repeat(spaces - 1) + ":";
|
47162 |
|
47163 | case "center":
|
47164 | return ":" + "-".repeat(spaces - 2) + ":";
|
47165 |
|
47166 | default:
|
47167 | return "-".repeat(spaces);
|
47168 | }
|
47169 | })), " |"]);
|
47170 | }
|
47171 |
|
47172 | function printRow(rowContents, isCompact) {
|
47173 | return concat$d(["| ", join$9(" | ", isCompact ? rowContents : rowContents.map((rowContent, columnIndex) => {
|
47174 | switch (node.align[columnIndex]) {
|
47175 | case "right":
|
47176 | return alignRight(rowContent, columnMaxWidths[columnIndex]);
|
47177 |
|
47178 | case "center":
|
47179 | return alignCenter(rowContent, columnMaxWidths[columnIndex]);
|
47180 |
|
47181 | default:
|
47182 | return alignLeft(rowContent, columnMaxWidths[columnIndex]);
|
47183 | }
|
47184 | })), " |"]);
|
47185 | }
|
47186 |
|
47187 | function alignLeft(text, width) {
|
47188 | const spaces = width - util$1.getStringWidth(text);
|
47189 | return concat$d([text, " ".repeat(spaces)]);
|
47190 | }
|
47191 |
|
47192 | function alignRight(text, width) {
|
47193 | const spaces = width - util$1.getStringWidth(text);
|
47194 | return concat$d([" ".repeat(spaces), text]);
|
47195 | }
|
47196 |
|
47197 | function alignCenter(text, width) {
|
47198 | const spaces = width - util$1.getStringWidth(text);
|
47199 | const left = Math.floor(spaces / 2);
|
47200 | const right = spaces - left;
|
47201 | return concat$d([" ".repeat(left), text, " ".repeat(right)]);
|
47202 | }
|
47203 | }
|
47204 |
|
47205 | function printRoot(path, options, print) {
|
47206 |
|
47207 |
|
47208 |
|
47209 | const ignoreRanges = [];
|
47210 |
|
47211 |
|
47212 | let ignoreStart = null;
|
47213 | const {
|
47214 | children
|
47215 | } = path.getValue();
|
47216 | children.forEach((childNode, index) => {
|
47217 | switch (isPrettierIgnore(childNode)) {
|
47218 | case "start":
|
47219 | if (ignoreStart === null) {
|
47220 | ignoreStart = {
|
47221 | index,
|
47222 | offset: childNode.position.end.offset
|
47223 | };
|
47224 | }
|
47225 |
|
47226 | break;
|
47227 |
|
47228 | case "end":
|
47229 | if (ignoreStart !== null) {
|
47230 | ignoreRanges.push({
|
47231 | start: ignoreStart,
|
47232 | end: {
|
47233 | index,
|
47234 | offset: childNode.position.start.offset
|
47235 | }
|
47236 | });
|
47237 | ignoreStart = null;
|
47238 | }
|
47239 |
|
47240 | break;
|
47241 | }
|
47242 | });
|
47243 | return printChildren$1(path, options, print, {
|
47244 | processor: (childPath, index) => {
|
47245 | if (ignoreRanges.length !== 0) {
|
47246 | const ignoreRange = ignoreRanges[0];
|
47247 |
|
47248 | if (index === ignoreRange.start.index) {
|
47249 | return concat$d([children[ignoreRange.start.index].value, options.originalText.slice(ignoreRange.start.offset, ignoreRange.end.offset), children[ignoreRange.end.index].value]);
|
47250 | }
|
47251 |
|
47252 | if (ignoreRange.start.index < index && index < ignoreRange.end.index) {
|
47253 | return false;
|
47254 | }
|
47255 |
|
47256 | if (index === ignoreRange.end.index) {
|
47257 | ignoreRanges.shift();
|
47258 | return false;
|
47259 | }
|
47260 | }
|
47261 |
|
47262 | return childPath.call(print);
|
47263 | }
|
47264 | });
|
47265 | }
|
47266 |
|
47267 | function printChildren$1(path, options, print, events) {
|
47268 | events = events || {};
|
47269 | const postprocessor = events.postprocessor || concat$d;
|
47270 |
|
47271 | const processor = events.processor || (childPath => childPath.call(print));
|
47272 |
|
47273 | const node = path.getValue();
|
47274 | const parts = [];
|
47275 | let lastChildNode;
|
47276 | path.map((childPath, index) => {
|
47277 | const childNode = childPath.getValue();
|
47278 | const result = processor(childPath, index);
|
47279 |
|
47280 | if (result !== false) {
|
47281 | const data = {
|
47282 | parts,
|
47283 | prevNode: lastChildNode,
|
47284 | parentNode: node,
|
47285 | options
|
47286 | };
|
47287 |
|
47288 | if (!shouldNotPrePrintHardline(childNode, data)) {
|
47289 | parts.push(hardline$b);
|
47290 |
|
47291 | if (lastChildNode && TRAILING_HARDLINE_NODES.includes(lastChildNode.type)) {
|
47292 | if (shouldPrePrintTripleHardline(childNode, data)) {
|
47293 | parts.push(hardline$b);
|
47294 | }
|
47295 | } else {
|
47296 | if (shouldPrePrintDoubleHardline(childNode, data) || shouldPrePrintTripleHardline(childNode, data)) {
|
47297 | parts.push(hardline$b);
|
47298 | }
|
47299 |
|
47300 | if (shouldPrePrintTripleHardline(childNode, data)) {
|
47301 | parts.push(hardline$b);
|
47302 | }
|
47303 | }
|
47304 | }
|
47305 |
|
47306 | parts.push(result);
|
47307 | lastChildNode = childNode;
|
47308 | }
|
47309 | }, "children");
|
47310 | return postprocessor(parts);
|
47311 | }
|
47312 |
|
47313 | function getLastDescendantNode(node) {
|
47314 | let current = node;
|
47315 |
|
47316 | while (current.children && current.children.length !== 0) {
|
47317 | current = current.children[current.children.length - 1];
|
47318 | }
|
47319 |
|
47320 | return current;
|
47321 | }
|
47322 |
|
47323 |
|
47324 |
|
47325 | function isPrettierIgnore(node) {
|
47326 | if (node.type !== "html") {
|
47327 | return false;
|
47328 | }
|
47329 |
|
47330 | const match = node.value.match(/^<!--\s*prettier-ignore(?:-(start|end))?\s*-->$/);
|
47331 | return match === null ? false : match[1] ? match[1] : "next";
|
47332 | }
|
47333 |
|
47334 | function shouldNotPrePrintHardline(node, data) {
|
47335 | const isFirstNode = data.parts.length === 0;
|
47336 | const isInlineNode = INLINE_NODE_TYPES$1.includes(node.type);
|
47337 | const isInlineHTML = node.type === "html" && INLINE_NODE_WRAPPER_TYPES$1.includes(data.parentNode.type);
|
47338 | return isFirstNode || isInlineNode || isInlineHTML;
|
47339 | }
|
47340 |
|
47341 | function shouldPrePrintDoubleHardline(node, data) {
|
47342 | const isSequence = (data.prevNode && data.prevNode.type) === node.type;
|
47343 | const isSiblingNode = isSequence && SIBLING_NODE_TYPES.includes(node.type);
|
47344 | const isInTightListItem = data.parentNode.type === "listItem" && !data.parentNode.loose;
|
47345 | const isPrevNodeLooseListItem = data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
|
47346 | const isPrevNodePrettierIgnore = isPrettierIgnore(data.prevNode) === "next";
|
47347 | const isBlockHtmlWithoutBlankLineBetweenPrevHtml = node.type === "html" && data.prevNode && data.prevNode.type === "html" && data.prevNode.position.end.line + 1 === node.position.start.line;
|
47348 | const isHtmlDirectAfterListItem = node.type === "html" && data.parentNode.type === "listItem" && data.prevNode && data.prevNode.type === "paragraph" && data.prevNode.position.end.line + 1 === node.position.start.line;
|
47349 | return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore || isBlockHtmlWithoutBlankLineBetweenPrevHtml || isHtmlDirectAfterListItem);
|
47350 | }
|
47351 |
|
47352 | function shouldPrePrintTripleHardline(node, data) {
|
47353 | const isPrevNodeList = data.prevNode && data.prevNode.type === "list";
|
47354 | const isIndentedCode = node.type === "code" && node.isIndented;
|
47355 | return isPrevNodeList && isIndentedCode;
|
47356 | }
|
47357 |
|
47358 | function shouldRemainTheSameContent(path) {
|
47359 | const ancestorNode = getAncestorNode$2(path, ["linkReference", "imageReference"]);
|
47360 | return ancestorNode && (ancestorNode.type !== "linkReference" || ancestorNode.referenceType !== "full");
|
47361 | }
|
47362 |
|
47363 | function normalizeDoc(doc) {
|
47364 | return mapDoc$4(doc, currentDoc => {
|
47365 | if (!currentDoc.parts) {
|
47366 | return currentDoc;
|
47367 | }
|
47368 |
|
47369 | if (currentDoc.type === "concat" && currentDoc.parts.length === 1) {
|
47370 | return currentDoc.parts[0];
|
47371 | }
|
47372 |
|
47373 | const parts = currentDoc.parts.reduce((parts, part) => {
|
47374 | if (part.type === "concat") {
|
47375 | parts.push(...part.parts);
|
47376 | } else if (part !== "") {
|
47377 | parts.push(part);
|
47378 | }
|
47379 |
|
47380 | return parts;
|
47381 | }, []);
|
47382 | return Object.assign({}, currentDoc, {
|
47383 | parts: normalizeParts(parts)
|
47384 | });
|
47385 | });
|
47386 | }
|
47387 |
|
47388 | function printUrl(url, dangerousCharOrChars) {
|
47389 | const dangerousChars = [" "].concat(dangerousCharOrChars || []);
|
47390 | return new RegExp(dangerousChars.map(x => `\\${x}`).join("|")).test(url) ? `<${url}>` : url;
|
47391 | }
|
47392 |
|
47393 | function printTitle(title, options, printSpace) {
|
47394 | if (printSpace == null) {
|
47395 | printSpace = true;
|
47396 | }
|
47397 |
|
47398 | if (!title) {
|
47399 | return "";
|
47400 | }
|
47401 |
|
47402 | if (printSpace) {
|
47403 | return " " + printTitle(title, options, false);
|
47404 | }
|
47405 |
|
47406 | if (title.includes('"') && title.includes("'") && !title.includes(")")) {
|
47407 | return `(${title})`;
|
47408 | }
|
47409 |
|
47410 |
|
47411 | const singleCount = title.split("'").length - 1;
|
47412 | const doubleCount = title.split('"').length - 1;
|
47413 | const quote = singleCount > doubleCount ? '"' : doubleCount > singleCount ? "'" : options.singleQuote ? "'" : '"';
|
47414 | title = title.replace(new RegExp(`(${quote})`, "g"), "\\$1");
|
47415 | return `${quote}${title}${quote}`;
|
47416 | }
|
47417 |
|
47418 | function normalizeParts(parts) {
|
47419 | return parts.reduce((current, part) => {
|
47420 | const lastPart = util$1.getLast(current);
|
47421 |
|
47422 | if (typeof lastPart === "string" && typeof part === "string") {
|
47423 | current.splice(-1, 1, lastPart + part);
|
47424 | } else {
|
47425 | current.push(part);
|
47426 | }
|
47427 |
|
47428 | return current;
|
47429 | }, []);
|
47430 | }
|
47431 |
|
47432 | function clamp(value, min, max) {
|
47433 | return value < min ? min : value > max ? max : value;
|
47434 | }
|
47435 |
|
47436 | function clean$5(ast, newObj, parent) {
|
47437 | delete newObj.position;
|
47438 | delete newObj.raw;
|
47439 |
|
47440 |
|
47441 | if (ast.type === "code" || ast.type === "yaml" || ast.type === "import" || ast.type === "export" || ast.type === "jsx") {
|
47442 | delete newObj.value;
|
47443 | }
|
47444 |
|
47445 | if (ast.type === "list") {
|
47446 | delete newObj.isAligned;
|
47447 | }
|
47448 |
|
47449 |
|
47450 | if (ast.type === "text") {
|
47451 | return null;
|
47452 | }
|
47453 |
|
47454 | if (ast.type === "inlineCode") {
|
47455 | newObj.value = ast.value.replace(/[ \t\n]+/g, " ");
|
47456 | }
|
47457 |
|
47458 |
|
47459 | if (parent && parent.type === "root" && parent.children.length > 0 && (parent.children[0] === ast || (parent.children[0].type === "yaml" || parent.children[0].type === "toml") && parent.children[1] === ast) && ast.type === "html" && pragma$3.startWithPragma(ast.value)) {
|
47460 | return null;
|
47461 | }
|
47462 | }
|
47463 |
|
47464 | function hasPrettierIgnore$4(path) {
|
47465 | const index = +path.getName();
|
47466 |
|
47467 | if (index === 0) {
|
47468 | return false;
|
47469 | }
|
47470 |
|
47471 | const prevNode = path.getParentNode().children[index - 1];
|
47472 | return isPrettierIgnore(prevNode) === "next";
|
47473 | }
|
47474 |
|
47475 | var printerMarkdown = {
|
47476 | preprocess: preprocess_1$1,
|
47477 | print: genericPrint$4,
|
47478 | embed: embed_1$2,
|
47479 | massageAstNode: clean$5,
|
47480 | hasPrettierIgnore: hasPrettierIgnore$4,
|
47481 | insertPragma: pragma$3.insertPragma
|
47482 | };
|
47483 |
|
47484 | var options$5 = {
|
47485 | proseWrap: commonOptions.proseWrap,
|
47486 | singleQuote: commonOptions.singleQuote
|
47487 | };
|
47488 |
|
47489 | var name$f = "Markdown";
|
47490 | var type$d = "prose";
|
47491 | var aliases$4 = [
|
47492 | "pandoc"
|
47493 | ];
|
47494 | var aceMode$d = "markdown";
|
47495 | var codemirrorMode$a = "gfm";
|
47496 | var codemirrorMimeType$a = "text/x-gfm";
|
47497 | var wrap = true;
|
47498 | var extensions$d = [
|
47499 | ".md",
|
47500 | ".markdown",
|
47501 | ".mdown",
|
47502 | ".mdwn",
|
47503 | ".mdx",
|
47504 | ".mkd",
|
47505 | ".mkdn",
|
47506 | ".mkdown",
|
47507 | ".ronn",
|
47508 | ".workbook"
|
47509 | ];
|
47510 | var filenames$3 = [
|
47511 | "contents.lr"
|
47512 | ];
|
47513 | var tmScope$d = "source.gfm";
|
47514 | var languageId$d = 222;
|
47515 | var Markdown = {
|
47516 | name: name$f,
|
47517 | type: type$d,
|
47518 | aliases: aliases$4,
|
47519 | aceMode: aceMode$d,
|
47520 | codemirrorMode: codemirrorMode$a,
|
47521 | codemirrorMimeType: codemirrorMimeType$a,
|
47522 | wrap: wrap,
|
47523 | extensions: extensions$d,
|
47524 | filenames: filenames$3,
|
47525 | tmScope: tmScope$d,
|
47526 | languageId: languageId$d
|
47527 | };
|
47528 |
|
47529 | var Markdown$1 = Object.freeze({
|
47530 | __proto__: null,
|
47531 | name: name$f,
|
47532 | type: type$d,
|
47533 | aliases: aliases$4,
|
47534 | aceMode: aceMode$d,
|
47535 | codemirrorMode: codemirrorMode$a,
|
47536 | codemirrorMimeType: codemirrorMimeType$a,
|
47537 | wrap: wrap,
|
47538 | extensions: extensions$d,
|
47539 | filenames: filenames$3,
|
47540 | tmScope: tmScope$d,
|
47541 | languageId: languageId$d,
|
47542 | 'default': Markdown
|
47543 | });
|
47544 |
|
47545 | var require$$0$5 = getCjsExportFromNamespace(Markdown$1);
|
47546 |
|
47547 | const languages$4 = [createLanguage(require$$0$5, data => ({
|
47548 | since: "1.8.0",
|
47549 | parsers: ["markdown"],
|
47550 | vscodeLanguageIds: ["markdown"],
|
47551 | filenames: data.filenames.concat(["README"]),
|
47552 | extensions: data.extensions.filter(extension => extension !== ".mdx")
|
47553 | })), createLanguage(require$$0$5, () => ({
|
47554 | name: "MDX",
|
47555 | since: "1.15.0",
|
47556 | parsers: ["mdx"],
|
47557 | vscodeLanguageIds: ["mdx"],
|
47558 | filenames: [],
|
47559 | extensions: [".mdx"]
|
47560 | }))];
|
47561 | const printers$4 = {
|
47562 | mdast: printerMarkdown
|
47563 | };
|
47564 | var languageMarkdown = {
|
47565 | languages: languages$4,
|
47566 | options: options$5,
|
47567 | printers: printers$4
|
47568 | };
|
47569 |
|
47570 | var clean$6 = function (ast, newNode) {
|
47571 | delete newNode.sourceSpan;
|
47572 | delete newNode.startSourceSpan;
|
47573 | delete newNode.endSourceSpan;
|
47574 | delete newNode.nameSpan;
|
47575 | delete newNode.valueSpan;
|
47576 |
|
47577 | if (ast.type === "text" || ast.type === "comment") {
|
47578 | return null;
|
47579 | }
|
47580 |
|
47581 |
|
47582 | if (ast.type === "yaml" || ast.type === "toml") {
|
47583 | return null;
|
47584 | }
|
47585 |
|
47586 | if (ast.type === "attribute") {
|
47587 | delete newNode.value;
|
47588 | }
|
47589 |
|
47590 | if (ast.type === "docType") {
|
47591 | delete newNode.value;
|
47592 | }
|
47593 | };
|
47594 |
|
47595 | var json$1 = {
|
47596 | "CSS_DISPLAY_TAGS": {
|
47597 | "area": "none",
|
47598 | "base": "none",
|
47599 | "basefont": "none",
|
47600 | "datalist": "none",
|
47601 | "head": "none",
|
47602 | "link": "none",
|
47603 | "meta": "none",
|
47604 | "noembed": "none",
|
47605 | "noframes": "none",
|
47606 | "param": "none",
|
47607 | "rp": "none",
|
47608 | "script": "block",
|
47609 | "source": "block",
|
47610 | "style": "none",
|
47611 | "template": "inline",
|
47612 | "track": "block",
|
47613 | "title": "none",
|
47614 | "html": "block",
|
47615 | "body": "block",
|
47616 | "address": "block",
|
47617 | "blockquote": "block",
|
47618 | "center": "block",
|
47619 | "div": "block",
|
47620 | "figure": "block",
|
47621 | "figcaption": "block",
|
47622 | "footer": "block",
|
47623 | "form": "block",
|
47624 | "header": "block",
|
47625 | "hr": "block",
|
47626 | "legend": "block",
|
47627 | "listing": "block",
|
47628 | "main": "block",
|
47629 | "p": "block",
|
47630 | "plaintext": "block",
|
47631 | "pre": "block",
|
47632 | "xmp": "block",
|
47633 | "slot": "contents",
|
47634 | "ruby": "ruby",
|
47635 | "rt": "ruby-text",
|
47636 | "article": "block",
|
47637 | "aside": "block",
|
47638 | "h1": "block",
|
47639 | "h2": "block",
|
47640 | "h3": "block",
|
47641 | "h4": "block",
|
47642 | "h5": "block",
|
47643 | "h6": "block",
|
47644 | "hgroup": "block",
|
47645 | "nav": "block",
|
47646 | "section": "block",
|
47647 | "dir": "block",
|
47648 | "dd": "block",
|
47649 | "dl": "block",
|
47650 | "dt": "block",
|
47651 | "ol": "block",
|
47652 | "ul": "block",
|
47653 | "li": "list-item",
|
47654 | "table": "table",
|
47655 | "caption": "table-caption",
|
47656 | "colgroup": "table-column-group",
|
47657 | "col": "table-column",
|
47658 | "thead": "table-header-group",
|
47659 | "tbody": "table-row-group",
|
47660 | "tfoot": "table-footer-group",
|
47661 | "tr": "table-row",
|
47662 | "td": "table-cell",
|
47663 | "th": "table-cell",
|
47664 | "fieldset": "block",
|
47665 | "button": "inline-block",
|
47666 | "video": "inline-block",
|
47667 | "audio": "inline-block"
|
47668 | },
|
47669 | "CSS_DISPLAY_DEFAULT": "inline",
|
47670 | "CSS_WHITE_SPACE_TAGS": {
|
47671 | "listing": "pre",
|
47672 | "plaintext": "pre",
|
47673 | "pre": "pre",
|
47674 | "xmp": "pre",
|
47675 | "nobr": "nowrap",
|
47676 | "table": "initial",
|
47677 | "textarea": "pre-wrap"
|
47678 | },
|
47679 | "CSS_WHITE_SPACE_DEFAULT": "normal"
|
47680 | };
|
47681 |
|
47682 | var index = [
|
47683 | "a",
|
47684 | "abbr",
|
47685 | "acronym",
|
47686 | "address",
|
47687 | "applet",
|
47688 | "area",
|
47689 | "article",
|
47690 | "aside",
|
47691 | "audio",
|
47692 | "b",
|
47693 | "base",
|
47694 | "basefont",
|
47695 | "bdi",
|
47696 | "bdo",
|
47697 | "bgsound",
|
47698 | "big",
|
47699 | "blink",
|
47700 | "blockquote",
|
47701 | "body",
|
47702 | "br",
|
47703 | "button",
|
47704 | "canvas",
|
47705 | "caption",
|
47706 | "center",
|
47707 | "cite",
|
47708 | "code",
|
47709 | "col",
|
47710 | "colgroup",
|
47711 | "command",
|
47712 | "content",
|
47713 | "data",
|
47714 | "datalist",
|
47715 | "dd",
|
47716 | "del",
|
47717 | "details",
|
47718 | "dfn",
|
47719 | "dialog",
|
47720 | "dir",
|
47721 | "div",
|
47722 | "dl",
|
47723 | "dt",
|
47724 | "element",
|
47725 | "em",
|
47726 | "embed",
|
47727 | "fieldset",
|
47728 | "figcaption",
|
47729 | "figure",
|
47730 | "font",
|
47731 | "footer",
|
47732 | "form",
|
47733 | "frame",
|
47734 | "frameset",
|
47735 | "h1",
|
47736 | "h2",
|
47737 | "h3",
|
47738 | "h4",
|
47739 | "h5",
|
47740 | "h6",
|
47741 | "head",
|
47742 | "header",
|
47743 | "hgroup",
|
47744 | "hr",
|
47745 | "html",
|
47746 | "i",
|
47747 | "iframe",
|
47748 | "image",
|
47749 | "img",
|
47750 | "input",
|
47751 | "ins",
|
47752 | "isindex",
|
47753 | "kbd",
|
47754 | "keygen",
|
47755 | "label",
|
47756 | "legend",
|
47757 | "li",
|
47758 | "link",
|
47759 | "listing",
|
47760 | "main",
|
47761 | "map",
|
47762 | "mark",
|
47763 | "marquee",
|
47764 | "math",
|
47765 | "menu",
|
47766 | "menuitem",
|
47767 | "meta",
|
47768 | "meter",
|
47769 | "multicol",
|
47770 | "nav",
|
47771 | "nextid",
|
47772 | "nobr",
|
47773 | "noembed",
|
47774 | "noframes",
|
47775 | "noscript",
|
47776 | "object",
|
47777 | "ol",
|
47778 | "optgroup",
|
47779 | "option",
|
47780 | "output",
|
47781 | "p",
|
47782 | "param",
|
47783 | "picture",
|
47784 | "plaintext",
|
47785 | "pre",
|
47786 | "progress",
|
47787 | "q",
|
47788 | "rb",
|
47789 | "rbc",
|
47790 | "rp",
|
47791 | "rt",
|
47792 | "rtc",
|
47793 | "ruby",
|
47794 | "s",
|
47795 | "samp",
|
47796 | "script",
|
47797 | "section",
|
47798 | "select",
|
47799 | "shadow",
|
47800 | "slot",
|
47801 | "small",
|
47802 | "source",
|
47803 | "spacer",
|
47804 | "span",
|
47805 | "strike",
|
47806 | "strong",
|
47807 | "style",
|
47808 | "sub",
|
47809 | "summary",
|
47810 | "sup",
|
47811 | "svg",
|
47812 | "table",
|
47813 | "tbody",
|
47814 | "td",
|
47815 | "template",
|
47816 | "textarea",
|
47817 | "tfoot",
|
47818 | "th",
|
47819 | "thead",
|
47820 | "time",
|
47821 | "title",
|
47822 | "tr",
|
47823 | "track",
|
47824 | "tt",
|
47825 | "u",
|
47826 | "ul",
|
47827 | "var",
|
47828 | "video",
|
47829 | "wbr",
|
47830 | "xmp"
|
47831 | ];
|
47832 |
|
47833 | var htmlTagNames = Object.freeze({
|
47834 | __proto__: null,
|
47835 | 'default': index
|
47836 | });
|
47837 |
|
47838 | var a = [
|
47839 | "accesskey",
|
47840 | "charset",
|
47841 | "coords",
|
47842 | "download",
|
47843 | "href",
|
47844 | "hreflang",
|
47845 | "name",
|
47846 | "ping",
|
47847 | "referrerpolicy",
|
47848 | "rel",
|
47849 | "rev",
|
47850 | "shape",
|
47851 | "tabindex",
|
47852 | "target",
|
47853 | "type"
|
47854 | ];
|
47855 | var abbr = [
|
47856 | "title"
|
47857 | ];
|
47858 | var applet = [
|
47859 | "align",
|
47860 | "alt",
|
47861 | "archive",
|
47862 | "code",
|
47863 | "codebase",
|
47864 | "height",
|
47865 | "hspace",
|
47866 | "name",
|
47867 | "object",
|
47868 | "vspace",
|
47869 | "width"
|
47870 | ];
|
47871 | var area = [
|
47872 | "accesskey",
|
47873 | "alt",
|
47874 | "coords",
|
47875 | "download",
|
47876 | "href",
|
47877 | "hreflang",
|
47878 | "nohref",
|
47879 | "ping",
|
47880 | "referrerpolicy",
|
47881 | "rel",
|
47882 | "shape",
|
47883 | "tabindex",
|
47884 | "target",
|
47885 | "type"
|
47886 | ];
|
47887 | var audio = [
|
47888 | "autoplay",
|
47889 | "controls",
|
47890 | "crossorigin",
|
47891 | "loop",
|
47892 | "muted",
|
47893 | "preload",
|
47894 | "src"
|
47895 | ];
|
47896 | var base = [
|
47897 | "href",
|
47898 | "target"
|
47899 | ];
|
47900 | var basefont = [
|
47901 | "color",
|
47902 | "face",
|
47903 | "size"
|
47904 | ];
|
47905 | var bdo = [
|
47906 | "dir"
|
47907 | ];
|
47908 | var blockquote = [
|
47909 | "cite"
|
47910 | ];
|
47911 | var body = [
|
47912 | "alink",
|
47913 | "background",
|
47914 | "bgcolor",
|
47915 | "link",
|
47916 | "text",
|
47917 | "vlink"
|
47918 | ];
|
47919 | var br = [
|
47920 | "clear"
|
47921 | ];
|
47922 | var button = [
|
47923 | "accesskey",
|
47924 | "autofocus",
|
47925 | "disabled",
|
47926 | "form",
|
47927 | "formaction",
|
47928 | "formenctype",
|
47929 | "formmethod",
|
47930 | "formnovalidate",
|
47931 | "formtarget",
|
47932 | "name",
|
47933 | "tabindex",
|
47934 | "type",
|
47935 | "value"
|
47936 | ];
|
47937 | var canvas = [
|
47938 | "height",
|
47939 | "width"
|
47940 | ];
|
47941 | var caption = [
|
47942 | "align"
|
47943 | ];
|
47944 | var col = [
|
47945 | "align",
|
47946 | "char",
|
47947 | "charoff",
|
47948 | "span",
|
47949 | "valign",
|
47950 | "width"
|
47951 | ];
|
47952 | var colgroup = [
|
47953 | "align",
|
47954 | "char",
|
47955 | "charoff",
|
47956 | "span",
|
47957 | "valign",
|
47958 | "width"
|
47959 | ];
|
47960 | var data$1 = [
|
47961 | "value"
|
47962 | ];
|
47963 | var del$1 = [
|
47964 | "cite",
|
47965 | "datetime"
|
47966 | ];
|
47967 | var details = [
|
47968 | "open"
|
47969 | ];
|
47970 | var dfn = [
|
47971 | "title"
|
47972 | ];
|
47973 | var dialog = [
|
47974 | "open"
|
47975 | ];
|
47976 | var dir = [
|
47977 | "compact"
|
47978 | ];
|
47979 | var div = [
|
47980 | "align"
|
47981 | ];
|
47982 | var dl = [
|
47983 | "compact"
|
47984 | ];
|
47985 | var embed$3 = [
|
47986 | "height",
|
47987 | "src",
|
47988 | "type",
|
47989 | "width"
|
47990 | ];
|
47991 | var fieldset = [
|
47992 | "disabled",
|
47993 | "form",
|
47994 | "name"
|
47995 | ];
|
47996 | var font = [
|
47997 | "color",
|
47998 | "face",
|
47999 | "size"
|
48000 | ];
|
48001 | var form = [
|
48002 | "accept",
|
48003 | "accept-charset",
|
48004 | "action",
|
48005 | "autocomplete",
|
48006 | "enctype",
|
48007 | "method",
|
48008 | "name",
|
48009 | "novalidate",
|
48010 | "target"
|
48011 | ];
|
48012 | var frame = [
|
48013 | "frameborder",
|
48014 | "longdesc",
|
48015 | "marginheight",
|
48016 | "marginwidth",
|
48017 | "name",
|
48018 | "noresize",
|
48019 | "scrolling",
|
48020 | "src"
|
48021 | ];
|
48022 | var frameset = [
|
48023 | "cols",
|
48024 | "rows"
|
48025 | ];
|
48026 | var h1 = [
|
48027 | "align"
|
48028 | ];
|
48029 | var h2 = [
|
48030 | "align"
|
48031 | ];
|
48032 | var h3 = [
|
48033 | "align"
|
48034 | ];
|
48035 | var h4 = [
|
48036 | "align"
|
48037 | ];
|
48038 | var h5 = [
|
48039 | "align"
|
48040 | ];
|
48041 | var h6 = [
|
48042 | "align"
|
48043 | ];
|
48044 | var head = [
|
48045 | "profile"
|
48046 | ];
|
48047 | var hr = [
|
48048 | "align",
|
48049 | "noshade",
|
48050 | "size",
|
48051 | "width"
|
48052 | ];
|
48053 | var html = [
|
48054 | "manifest",
|
48055 | "version"
|
48056 | ];
|
48057 | var iframe = [
|
48058 | "align",
|
48059 | "allow",
|
48060 | "allowfullscreen",
|
48061 | "allowpaymentrequest",
|
48062 | "allowusermedia",
|
48063 | "frameborder",
|
48064 | "height",
|
48065 | "longdesc",
|
48066 | "marginheight",
|
48067 | "marginwidth",
|
48068 | "name",
|
48069 | "referrerpolicy",
|
48070 | "sandbox",
|
48071 | "scrolling",
|
48072 | "src",
|
48073 | "srcdoc",
|
48074 | "width"
|
48075 | ];
|
48076 | var img = [
|
48077 | "align",
|
48078 | "alt",
|
48079 | "border",
|
48080 | "crossorigin",
|
48081 | "decoding",
|
48082 | "height",
|
48083 | "hspace",
|
48084 | "ismap",
|
48085 | "longdesc",
|
48086 | "name",
|
48087 | "referrerpolicy",
|
48088 | "sizes",
|
48089 | "src",
|
48090 | "srcset",
|
48091 | "usemap",
|
48092 | "vspace",
|
48093 | "width"
|
48094 | ];
|
48095 | var input = [
|
48096 | "accept",
|
48097 | "accesskey",
|
48098 | "align",
|
48099 | "alt",
|
48100 | "autocomplete",
|
48101 | "autofocus",
|
48102 | "checked",
|
48103 | "dirname",
|
48104 | "disabled",
|
48105 | "form",
|
48106 | "formaction",
|
48107 | "formenctype",
|
48108 | "formmethod",
|
48109 | "formnovalidate",
|
48110 | "formtarget",
|
48111 | "height",
|
48112 | "ismap",
|
48113 | "list",
|
48114 | "max",
|
48115 | "maxlength",
|
48116 | "min",
|
48117 | "minlength",
|
48118 | "multiple",
|
48119 | "name",
|
48120 | "pattern",
|
48121 | "placeholder",
|
48122 | "readonly",
|
48123 | "required",
|
48124 | "size",
|
48125 | "src",
|
48126 | "step",
|
48127 | "tabindex",
|
48128 | "title",
|
48129 | "type",
|
48130 | "usemap",
|
48131 | "value",
|
48132 | "width"
|
48133 | ];
|
48134 | var ins = [
|
48135 | "cite",
|
48136 | "datetime"
|
48137 | ];
|
48138 | var isindex = [
|
48139 | "prompt"
|
48140 | ];
|
48141 | var label = [
|
48142 | "accesskey",
|
48143 | "for",
|
48144 | "form"
|
48145 | ];
|
48146 | var legend = [
|
48147 | "accesskey",
|
48148 | "align"
|
48149 | ];
|
48150 | var li = [
|
48151 | "type",
|
48152 | "value"
|
48153 | ];
|
48154 | var link$3 = [
|
48155 | "as",
|
48156 | "charset",
|
48157 | "color",
|
48158 | "crossorigin",
|
48159 | "href",
|
48160 | "hreflang",
|
48161 | "imagesizes",
|
48162 | "imagesrcset",
|
48163 | "integrity",
|
48164 | "media",
|
48165 | "nonce",
|
48166 | "referrerpolicy",
|
48167 | "rel",
|
48168 | "rev",
|
48169 | "sizes",
|
48170 | "target",
|
48171 | "title",
|
48172 | "type"
|
48173 | ];
|
48174 | var map$1 = [
|
48175 | "name"
|
48176 | ];
|
48177 | var menu = [
|
48178 | "compact"
|
48179 | ];
|
48180 | var meta = [
|
48181 | "charset",
|
48182 | "content",
|
48183 | "http-equiv",
|
48184 | "name",
|
48185 | "scheme"
|
48186 | ];
|
48187 | var meter = [
|
48188 | "high",
|
48189 | "low",
|
48190 | "max",
|
48191 | "min",
|
48192 | "optimum",
|
48193 | "value"
|
48194 | ];
|
48195 | var object = [
|
48196 | "align",
|
48197 | "archive",
|
48198 | "border",
|
48199 | "classid",
|
48200 | "codebase",
|
48201 | "codetype",
|
48202 | "data",
|
48203 | "declare",
|
48204 | "form",
|
48205 | "height",
|
48206 | "hspace",
|
48207 | "name",
|
48208 | "standby",
|
48209 | "tabindex",
|
48210 | "type",
|
48211 | "typemustmatch",
|
48212 | "usemap",
|
48213 | "vspace",
|
48214 | "width"
|
48215 | ];
|
48216 | var ol = [
|
48217 | "compact",
|
48218 | "reversed",
|
48219 | "start",
|
48220 | "type"
|
48221 | ];
|
48222 | var optgroup = [
|
48223 | "disabled",
|
48224 | "label"
|
48225 | ];
|
48226 | var option = [
|
48227 | "disabled",
|
48228 | "label",
|
48229 | "selected",
|
48230 | "value"
|
48231 | ];
|
48232 | var output = [
|
48233 | "for",
|
48234 | "form",
|
48235 | "name"
|
48236 | ];
|
48237 | var p = [
|
48238 | "align"
|
48239 | ];
|
48240 | var param = [
|
48241 | "name",
|
48242 | "type",
|
48243 | "value",
|
48244 | "valuetype"
|
48245 | ];
|
48246 | var pre = [
|
48247 | "width"
|
48248 | ];
|
48249 | var progress = [
|
48250 | "max",
|
48251 | "value"
|
48252 | ];
|
48253 | var q = [
|
48254 | "cite"
|
48255 | ];
|
48256 | var script = [
|
48257 | "async",
|
48258 | "charset",
|
48259 | "crossorigin",
|
48260 | "defer",
|
48261 | "integrity",
|
48262 | "language",
|
48263 | "nomodule",
|
48264 | "nonce",
|
48265 | "referrerpolicy",
|
48266 | "src",
|
48267 | "type"
|
48268 | ];
|
48269 | var select = [
|
48270 | "autocomplete",
|
48271 | "autofocus",
|
48272 | "disabled",
|
48273 | "form",
|
48274 | "multiple",
|
48275 | "name",
|
48276 | "required",
|
48277 | "size",
|
48278 | "tabindex"
|
48279 | ];
|
48280 | var slot = [
|
48281 | "name"
|
48282 | ];
|
48283 | var source$1 = [
|
48284 | "media",
|
48285 | "sizes",
|
48286 | "src",
|
48287 | "srcset",
|
48288 | "type"
|
48289 | ];
|
48290 | var style = [
|
48291 | "media",
|
48292 | "nonce",
|
48293 | "title",
|
48294 | "type"
|
48295 | ];
|
48296 | var table = [
|
48297 | "align",
|
48298 | "bgcolor",
|
48299 | "border",
|
48300 | "cellpadding",
|
48301 | "cellspacing",
|
48302 | "frame",
|
48303 | "rules",
|
48304 | "summary",
|
48305 | "width"
|
48306 | ];
|
48307 | var tbody = [
|
48308 | "align",
|
48309 | "char",
|
48310 | "charoff",
|
48311 | "valign"
|
48312 | ];
|
48313 | var td = [
|
48314 | "abbr",
|
48315 | "align",
|
48316 | "axis",
|
48317 | "bgcolor",
|
48318 | "char",
|
48319 | "charoff",
|
48320 | "colspan",
|
48321 | "headers",
|
48322 | "height",
|
48323 | "nowrap",
|
48324 | "rowspan",
|
48325 | "scope",
|
48326 | "valign",
|
48327 | "width"
|
48328 | ];
|
48329 | var textarea = [
|
48330 | "accesskey",
|
48331 | "autocomplete",
|
48332 | "autofocus",
|
48333 | "cols",
|
48334 | "dirname",
|
48335 | "disabled",
|
48336 | "form",
|
48337 | "maxlength",
|
48338 | "minlength",
|
48339 | "name",
|
48340 | "placeholder",
|
48341 | "readonly",
|
48342 | "required",
|
48343 | "rows",
|
48344 | "tabindex",
|
48345 | "wrap"
|
48346 | ];
|
48347 | var tfoot = [
|
48348 | "align",
|
48349 | "char",
|
48350 | "charoff",
|
48351 | "valign"
|
48352 | ];
|
48353 | var th = [
|
48354 | "abbr",
|
48355 | "align",
|
48356 | "axis",
|
48357 | "bgcolor",
|
48358 | "char",
|
48359 | "charoff",
|
48360 | "colspan",
|
48361 | "headers",
|
48362 | "height",
|
48363 | "nowrap",
|
48364 | "rowspan",
|
48365 | "scope",
|
48366 | "valign",
|
48367 | "width"
|
48368 | ];
|
48369 | var thead = [
|
48370 | "align",
|
48371 | "char",
|
48372 | "charoff",
|
48373 | "valign"
|
48374 | ];
|
48375 | var time = [
|
48376 | "datetime"
|
48377 | ];
|
48378 | var tr = [
|
48379 | "align",
|
48380 | "bgcolor",
|
48381 | "char",
|
48382 | "charoff",
|
48383 | "valign"
|
48384 | ];
|
48385 | var track = [
|
48386 | "default",
|
48387 | "kind",
|
48388 | "label",
|
48389 | "src",
|
48390 | "srclang"
|
48391 | ];
|
48392 | var ul = [
|
48393 | "compact",
|
48394 | "type"
|
48395 | ];
|
48396 | var video = [
|
48397 | "autoplay",
|
48398 | "controls",
|
48399 | "crossorigin",
|
48400 | "height",
|
48401 | "loop",
|
48402 | "muted",
|
48403 | "playsinline",
|
48404 | "poster",
|
48405 | "preload",
|
48406 | "src",
|
48407 | "width"
|
48408 | ];
|
48409 | var index$1 = {
|
48410 | "*": [
|
48411 | "accesskey",
|
48412 | "autocapitalize",
|
48413 | "autofocus",
|
48414 | "class",
|
48415 | "contenteditable",
|
48416 | "dir",
|
48417 | "draggable",
|
48418 | "enterkeyhint",
|
48419 | "hidden",
|
48420 | "id",
|
48421 | "inputmode",
|
48422 | "is",
|
48423 | "itemid",
|
48424 | "itemprop",
|
48425 | "itemref",
|
48426 | "itemscope",
|
48427 | "itemtype",
|
48428 | "lang",
|
48429 | "nonce",
|
48430 | "slot",
|
48431 | "spellcheck",
|
48432 | "style",
|
48433 | "tabindex",
|
48434 | "title",
|
48435 | "translate"
|
48436 | ],
|
48437 | a: a,
|
48438 | abbr: abbr,
|
48439 | applet: applet,
|
48440 | area: area,
|
48441 | audio: audio,
|
48442 | base: base,
|
48443 | basefont: basefont,
|
48444 | bdo: bdo,
|
48445 | blockquote: blockquote,
|
48446 | body: body,
|
48447 | br: br,
|
48448 | button: button,
|
48449 | canvas: canvas,
|
48450 | caption: caption,
|
48451 | col: col,
|
48452 | colgroup: colgroup,
|
48453 | data: data$1,
|
48454 | del: del$1,
|
48455 | details: details,
|
48456 | dfn: dfn,
|
48457 | dialog: dialog,
|
48458 | dir: dir,
|
48459 | div: div,
|
48460 | dl: dl,
|
48461 | embed: embed$3,
|
48462 | fieldset: fieldset,
|
48463 | font: font,
|
48464 | form: form,
|
48465 | frame: frame,
|
48466 | frameset: frameset,
|
48467 | h1: h1,
|
48468 | h2: h2,
|
48469 | h3: h3,
|
48470 | h4: h4,
|
48471 | h5: h5,
|
48472 | h6: h6,
|
48473 | head: head,
|
48474 | hr: hr,
|
48475 | html: html,
|
48476 | iframe: iframe,
|
48477 | img: img,
|
48478 | input: input,
|
48479 | ins: ins,
|
48480 | isindex: isindex,
|
48481 | label: label,
|
48482 | legend: legend,
|
48483 | li: li,
|
48484 | link: link$3,
|
48485 | map: map$1,
|
48486 | menu: menu,
|
48487 | meta: meta,
|
48488 | meter: meter,
|
48489 | object: object,
|
48490 | ol: ol,
|
48491 | optgroup: optgroup,
|
48492 | option: option,
|
48493 | output: output,
|
48494 | p: p,
|
48495 | param: param,
|
48496 | pre: pre,
|
48497 | progress: progress,
|
48498 | q: q,
|
48499 | script: script,
|
48500 | select: select,
|
48501 | slot: slot,
|
48502 | source: source$1,
|
48503 | style: style,
|
48504 | table: table,
|
48505 | tbody: tbody,
|
48506 | td: td,
|
48507 | textarea: textarea,
|
48508 | tfoot: tfoot,
|
48509 | th: th,
|
48510 | thead: thead,
|
48511 | time: time,
|
48512 | tr: tr,
|
48513 | track: track,
|
48514 | ul: ul,
|
48515 | video: video
|
48516 | };
|
48517 |
|
48518 | var htmlElementAttributes = Object.freeze({
|
48519 | __proto__: null,
|
48520 | a: a,
|
48521 | abbr: abbr,
|
48522 | applet: applet,
|
48523 | area: area,
|
48524 | audio: audio,
|
48525 | base: base,
|
48526 | basefont: basefont,
|
48527 | bdo: bdo,
|
48528 | blockquote: blockquote,
|
48529 | body: body,
|
48530 | br: br,
|
48531 | button: button,
|
48532 | canvas: canvas,
|
48533 | caption: caption,
|
48534 | col: col,
|
48535 | colgroup: colgroup,
|
48536 | data: data$1,
|
48537 | del: del$1,
|
48538 | details: details,
|
48539 | dfn: dfn,
|
48540 | dialog: dialog,
|
48541 | dir: dir,
|
48542 | div: div,
|
48543 | dl: dl,
|
48544 | embed: embed$3,
|
48545 | fieldset: fieldset,
|
48546 | font: font,
|
48547 | form: form,
|
48548 | frame: frame,
|
48549 | frameset: frameset,
|
48550 | h1: h1,
|
48551 | h2: h2,
|
48552 | h3: h3,
|
48553 | h4: h4,
|
48554 | h5: h5,
|
48555 | h6: h6,
|
48556 | head: head,
|
48557 | hr: hr,
|
48558 | html: html,
|
48559 | iframe: iframe,
|
48560 | img: img,
|
48561 | input: input,
|
48562 | ins: ins,
|
48563 | isindex: isindex,
|
48564 | label: label,
|
48565 | legend: legend,
|
48566 | li: li,
|
48567 | link: link$3,
|
48568 | map: map$1,
|
48569 | menu: menu,
|
48570 | meta: meta,
|
48571 | meter: meter,
|
48572 | object: object,
|
48573 | ol: ol,
|
48574 | optgroup: optgroup,
|
48575 | option: option,
|
48576 | output: output,
|
48577 | p: p,
|
48578 | param: param,
|
48579 | pre: pre,
|
48580 | progress: progress,
|
48581 | q: q,
|
48582 | script: script,
|
48583 | select: select,
|
48584 | slot: slot,
|
48585 | source: source$1,
|
48586 | style: style,
|
48587 | table: table,
|
48588 | tbody: tbody,
|
48589 | td: td,
|
48590 | textarea: textarea,
|
48591 | tfoot: tfoot,
|
48592 | th: th,
|
48593 | thead: thead,
|
48594 | time: time,
|
48595 | tr: tr,
|
48596 | track: track,
|
48597 | ul: ul,
|
48598 | video: video,
|
48599 | 'default': index$1
|
48600 | });
|
48601 |
|
48602 | var htmlTagNames$1 = getCjsExportFromNamespace(htmlTagNames);
|
48603 |
|
48604 | var htmlElementAttributes$1 = getCjsExportFromNamespace(htmlElementAttributes);
|
48605 |
|
48606 | const {
|
48607 | CSS_DISPLAY_TAGS,
|
48608 | CSS_DISPLAY_DEFAULT,
|
48609 | CSS_WHITE_SPACE_TAGS,
|
48610 | CSS_WHITE_SPACE_DEFAULT
|
48611 | } = json$1;
|
48612 | const HTML_TAGS = arrayToMap(htmlTagNames$1);
|
48613 | const HTML_ELEMENT_ATTRIBUTES = mapObject(htmlElementAttributes$1, arrayToMap);
|
48614 |
|
48615 | function arrayToMap(array) {
|
48616 | const map = Object.create(null);
|
48617 |
|
48618 | for (const value of array) {
|
48619 | map[value] = true;
|
48620 | }
|
48621 |
|
48622 | return map;
|
48623 | }
|
48624 |
|
48625 | function mapObject(object, fn) {
|
48626 | const newObject = Object.create(null);
|
48627 |
|
48628 | for (const key of Object.keys(object)) {
|
48629 | newObject[key] = fn(object[key], key);
|
48630 | }
|
48631 |
|
48632 | return newObject;
|
48633 | }
|
48634 |
|
48635 | function shouldPreserveContent(node, options) {
|
48636 | if (!node.endSourceSpan) {
|
48637 | return false;
|
48638 | }
|
48639 |
|
48640 | if (node.type === "element" && node.fullName === "template" && node.attrMap.lang && node.attrMap.lang !== "html") {
|
48641 | return true;
|
48642 | }
|
48643 |
|
48644 |
|
48645 |
|
48646 | if (node.type === "ieConditionalComment" && node.lastChild && !node.lastChild.isSelfClosing && !node.lastChild.endSourceSpan) {
|
48647 | return true;
|
48648 | }
|
48649 |
|
48650 |
|
48651 |
|
48652 | if (node.type === "ieConditionalComment" && !node.complete) {
|
48653 | return true;
|
48654 | }
|
48655 |
|
48656 |
|
48657 |
|
48658 | if (options.parser === "vue" && node.type === "element" && node.parent.type === "root" && !["template", "style", "script",
|
48659 | "html"].includes(node.fullName)) {
|
48660 | return true;
|
48661 | }
|
48662 |
|
48663 |
|
48664 | if (isPreLikeNode(node) && node.children.some(child => child.type !== "text" && child.type !== "interpolation")) {
|
48665 | return true;
|
48666 | }
|
48667 |
|
48668 | return false;
|
48669 | }
|
48670 |
|
48671 | function hasPrettierIgnore$5(node) {
|
48672 | if (node.type === "attribute") {
|
48673 | return false;
|
48674 | }
|
48675 |
|
48676 | if (!node.parent) {
|
48677 | return false;
|
48678 | }
|
48679 |
|
48680 | if (typeof node.index !== "number" || node.index === 0) {
|
48681 | return false;
|
48682 | }
|
48683 |
|
48684 | const prevNode = node.parent.children[node.index - 1];
|
48685 | return isPrettierIgnore$1(prevNode);
|
48686 | }
|
48687 |
|
48688 | function isPrettierIgnore$1(node) {
|
48689 | return node.type === "comment" && node.value.trim() === "prettier-ignore";
|
48690 | }
|
48691 |
|
48692 | function getPrettierIgnoreAttributeCommentData(value) {
|
48693 | const match = value.trim().match(/^prettier-ignore-attribute(?:\s+([^]+))?$/);
|
48694 |
|
48695 | if (!match) {
|
48696 | return false;
|
48697 | }
|
48698 |
|
48699 | if (!match[1]) {
|
48700 | return true;
|
48701 | }
|
48702 |
|
48703 | return match[1].split(/\s+/);
|
48704 | }
|
48705 |
|
48706 |
|
48707 |
|
48708 | function isTextLikeNode(node) {
|
48709 | return node.type === "text" || node.type === "comment";
|
48710 | }
|
48711 |
|
48712 | function isScriptLikeTag(node) {
|
48713 | return node.type === "element" && (node.fullName === "script" || node.fullName === "style" || node.fullName === "svg:style" || isUnknownNamespace(node) && (node.name === "script" || node.name === "style"));
|
48714 | }
|
48715 |
|
48716 | function isFrontMatterNode(node) {
|
48717 | return node.type === "yaml" || node.type === "toml";
|
48718 | }
|
48719 |
|
48720 | function canHaveInterpolation(node) {
|
48721 | return node.children && !isScriptLikeTag(node);
|
48722 | }
|
48723 |
|
48724 | function isWhitespaceSensitiveNode(node) {
|
48725 | return isScriptLikeTag(node) || node.type === "interpolation" || isIndentationSensitiveNode(node);
|
48726 | }
|
48727 |
|
48728 | function isIndentationSensitiveNode(node) {
|
48729 | return getNodeCssStyleWhiteSpace(node).startsWith("pre");
|
48730 | }
|
48731 |
|
48732 | function isLeadingSpaceSensitiveNode(node) {
|
48733 | const isLeadingSpaceSensitive = _isLeadingSpaceSensitiveNode();
|
48734 |
|
48735 | if (isLeadingSpaceSensitive && !node.prev && node.parent && node.parent.tagDefinition && node.parent.tagDefinition.ignoreFirstLf) {
|
48736 | return node.type === "interpolation";
|
48737 | }
|
48738 |
|
48739 | return isLeadingSpaceSensitive;
|
48740 |
|
48741 | function _isLeadingSpaceSensitiveNode() {
|
48742 | if (isFrontMatterNode(node)) {
|
48743 | return false;
|
48744 | }
|
48745 |
|
48746 | if ((node.type === "text" || node.type === "interpolation") && node.prev && (node.prev.type === "text" || node.prev.type === "interpolation")) {
|
48747 | return true;
|
48748 | }
|
48749 |
|
48750 | if (!node.parent || node.parent.cssDisplay === "none") {
|
48751 | return false;
|
48752 | }
|
48753 |
|
48754 | if (isPreLikeNode(node.parent)) {
|
48755 | return true;
|
48756 | }
|
48757 |
|
48758 | if (!node.prev && (node.parent.type === "root" || isPreLikeNode(node) && node.parent || isScriptLikeTag(node.parent) || !isFirstChildLeadingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
|
48759 | return false;
|
48760 | }
|
48761 |
|
48762 | if (node.prev && !isNextLeadingSpaceSensitiveCssDisplay(node.prev.cssDisplay)) {
|
48763 | return false;
|
48764 | }
|
48765 |
|
48766 | return true;
|
48767 | }
|
48768 | }
|
48769 |
|
48770 | function isTrailingSpaceSensitiveNode(node) {
|
48771 | if (isFrontMatterNode(node)) {
|
48772 | return false;
|
48773 | }
|
48774 |
|
48775 | if ((node.type === "text" || node.type === "interpolation") && node.next && (node.next.type === "text" || node.next.type === "interpolation")) {
|
48776 | return true;
|
48777 | }
|
48778 |
|
48779 | if (!node.parent || node.parent.cssDisplay === "none") {
|
48780 | return false;
|
48781 | }
|
48782 |
|
48783 | if (isPreLikeNode(node.parent)) {
|
48784 | return true;
|
48785 | }
|
48786 |
|
48787 | if (!node.next && (node.parent.type === "root" || isPreLikeNode(node) && node.parent || isScriptLikeTag(node.parent) || !isLastChildTrailingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
|
48788 | return false;
|
48789 | }
|
48790 |
|
48791 | if (node.next && !isPrevTrailingSpaceSensitiveCssDisplay(node.next.cssDisplay)) {
|
48792 | return false;
|
48793 | }
|
48794 |
|
48795 | return true;
|
48796 | }
|
48797 |
|
48798 | function isDanglingSpaceSensitiveNode(node) {
|
48799 | return isDanglingSpaceSensitiveCssDisplay(node.cssDisplay) && !isScriptLikeTag(node);
|
48800 | }
|
48801 |
|
48802 | function forceNextEmptyLine(node) {
|
48803 | return isFrontMatterNode(node) || node.next && node.sourceSpan.end.line + 1 < node.next.sourceSpan.start.line;
|
48804 | }
|
48805 |
|
48806 |
|
48807 |
|
48808 | function forceBreakContent(node) {
|
48809 | return forceBreakChildren(node) || node.type === "element" && node.children.length !== 0 && (["body", "script", "style"].includes(node.name) || node.children.some(child => hasNonTextChild(child))) || node.firstChild && node.firstChild === node.lastChild && hasLeadingLineBreak(node.firstChild) && (!node.lastChild.isTrailingSpaceSensitive || hasTrailingLineBreak(node.lastChild));
|
48810 | }
|
48811 |
|
48812 |
|
48813 |
|
48814 | function forceBreakChildren(node) {
|
48815 | return node.type === "element" && node.children.length !== 0 && (["html", "head", "ul", "ol", "select"].includes(node.name) || node.cssDisplay.startsWith("table") && node.cssDisplay !== "table-cell");
|
48816 | }
|
48817 |
|
48818 | function preferHardlineAsLeadingSpaces(node) {
|
48819 | return preferHardlineAsSurroundingSpaces(node) || node.prev && preferHardlineAsTrailingSpaces(node.prev) || hasSurroundingLineBreak(node);
|
48820 | }
|
48821 |
|
48822 | function preferHardlineAsTrailingSpaces(node) {
|
48823 | return preferHardlineAsSurroundingSpaces(node) || node.type === "element" && node.fullName === "br" || hasSurroundingLineBreak(node);
|
48824 | }
|
48825 |
|
48826 | function hasSurroundingLineBreak(node) {
|
48827 | return hasLeadingLineBreak(node) && hasTrailingLineBreak(node);
|
48828 | }
|
48829 |
|
48830 | function hasLeadingLineBreak(node) {
|
48831 | return node.hasLeadingSpaces && (node.prev ? node.prev.sourceSpan.end.line < node.sourceSpan.start.line : node.parent.type === "root" || node.parent.startSourceSpan.end.line < node.sourceSpan.start.line);
|
48832 | }
|
48833 |
|
48834 | function hasTrailingLineBreak(node) {
|
48835 | return node.hasTrailingSpaces && (node.next ? node.next.sourceSpan.start.line > node.sourceSpan.end.line : node.parent.type === "root" || node.parent.endSourceSpan && node.parent.endSourceSpan.start.line > node.sourceSpan.end.line);
|
48836 | }
|
48837 |
|
48838 | function preferHardlineAsSurroundingSpaces(node) {
|
48839 | switch (node.type) {
|
48840 | case "ieConditionalComment":
|
48841 | case "comment":
|
48842 | case "directive":
|
48843 | return true;
|
48844 |
|
48845 | case "element":
|
48846 | return ["script", "select"].includes(node.name);
|
48847 | }
|
48848 |
|
48849 | return false;
|
48850 | }
|
48851 |
|
48852 | function getLastDescendant(node) {
|
48853 | return node.lastChild ? getLastDescendant(node.lastChild) : node;
|
48854 | }
|
48855 |
|
48856 | function hasNonTextChild(node) {
|
48857 | return node.children && node.children.some(child => child.type !== "text");
|
48858 | }
|
48859 |
|
48860 | function inferScriptParser(node) {
|
48861 | if (node.name === "script" && !node.attrMap.src) {
|
48862 | if (!node.attrMap.lang && !node.attrMap.type || node.attrMap.type === "module" || node.attrMap.type === "text/javascript" || node.attrMap.type === "text/babel" || node.attrMap.type === "application/javascript" || node.attrMap.lang === "jsx") {
|
48863 | return "babel";
|
48864 | }
|
48865 |
|
48866 | if (node.attrMap.type === "application/x-typescript" || node.attrMap.lang === "ts" || node.attrMap.lang === "tsx") {
|
48867 | return "typescript";
|
48868 | }
|
48869 |
|
48870 | if (node.attrMap.type === "text/markdown") {
|
48871 | return "markdown";
|
48872 | }
|
48873 |
|
48874 | if (node.attrMap.type.endsWith("json") || node.attrMap.type.endsWith("importmap")) {
|
48875 | return "json";
|
48876 | }
|
48877 |
|
48878 | if (node.attrMap.type === "text/x-handlebars-template") {
|
48879 | return "glimmer";
|
48880 | }
|
48881 | }
|
48882 |
|
48883 | if (node.name === "style") {
|
48884 | if (!node.attrMap.lang || node.attrMap.lang === "postcss" || node.attrMap.lang === "css") {
|
48885 | return "css";
|
48886 | }
|
48887 |
|
48888 | if (node.attrMap.lang === "scss") {
|
48889 | return "scss";
|
48890 | }
|
48891 |
|
48892 | if (node.attrMap.lang === "less") {
|
48893 | return "less";
|
48894 | }
|
48895 | }
|
48896 |
|
48897 | return null;
|
48898 | }
|
48899 |
|
48900 | function isBlockLikeCssDisplay(cssDisplay) {
|
48901 | return cssDisplay === "block" || cssDisplay === "list-item" || cssDisplay.startsWith("table");
|
48902 | }
|
48903 |
|
48904 | function isFirstChildLeadingSpaceSensitiveCssDisplay(cssDisplay) {
|
48905 | return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
|
48906 | }
|
48907 |
|
48908 | function isLastChildTrailingSpaceSensitiveCssDisplay(cssDisplay) {
|
48909 | return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
|
48910 | }
|
48911 |
|
48912 | function isPrevTrailingSpaceSensitiveCssDisplay(cssDisplay) {
|
48913 | return !isBlockLikeCssDisplay(cssDisplay);
|
48914 | }
|
48915 |
|
48916 | function isNextLeadingSpaceSensitiveCssDisplay(cssDisplay) {
|
48917 | return !isBlockLikeCssDisplay(cssDisplay);
|
48918 | }
|
48919 |
|
48920 | function isDanglingSpaceSensitiveCssDisplay(cssDisplay) {
|
48921 | return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
|
48922 | }
|
48923 |
|
48924 | function isPreLikeNode(node) {
|
48925 | return getNodeCssStyleWhiteSpace(node).startsWith("pre");
|
48926 | }
|
48927 |
|
48928 | function countParents(path, predicate = () => true) {
|
48929 | let counter = 0;
|
48930 |
|
48931 | for (let i = path.stack.length - 1; i >= 0; i--) {
|
48932 | const value = path.stack[i];
|
48933 |
|
48934 | if (value && typeof value === "object" && !Array.isArray(value) && predicate(value)) {
|
48935 | counter++;
|
48936 | }
|
48937 | }
|
48938 |
|
48939 | return counter;
|
48940 | }
|
48941 |
|
48942 | function hasParent(node, fn) {
|
48943 | let current = node;
|
48944 |
|
48945 | while (current) {
|
48946 | if (fn(current)) {
|
48947 | return true;
|
48948 | }
|
48949 |
|
48950 | current = current.parent;
|
48951 | }
|
48952 |
|
48953 | return false;
|
48954 | }
|
48955 |
|
48956 | function getNodeCssStyleDisplay(node, options) {
|
48957 | if (node.prev && node.prev.type === "comment") {
|
48958 |
|
48959 | const match = node.prev.value.match(/^\s*display:\s*([a-z]+)\s*$/);
|
48960 |
|
48961 | if (match) {
|
48962 | return match[1];
|
48963 | }
|
48964 | }
|
48965 |
|
48966 | let isInSvgForeignObject = false;
|
48967 |
|
48968 | if (node.type === "element" && node.namespace === "svg") {
|
48969 | if (hasParent(node, parent => parent.fullName === "svg:foreignObject")) {
|
48970 | isInSvgForeignObject = true;
|
48971 | } else {
|
48972 | return node.name === "svg" ? "inline-block" : "block";
|
48973 | }
|
48974 | }
|
48975 |
|
48976 | switch (options.htmlWhitespaceSensitivity) {
|
48977 | case "strict":
|
48978 | return "inline";
|
48979 |
|
48980 | case "ignore":
|
48981 | return "block";
|
48982 |
|
48983 | default:
|
48984 | return node.type === "element" && (!node.namespace || isInSvgForeignObject || isUnknownNamespace(node)) && CSS_DISPLAY_TAGS[node.name] || CSS_DISPLAY_DEFAULT;
|
48985 | }
|
48986 | }
|
48987 |
|
48988 | function isUnknownNamespace(node) {
|
48989 | return node.type === "element" && !node.hasExplicitNamespace && !["html", "svg"].includes(node.namespace);
|
48990 | }
|
48991 |
|
48992 | function getNodeCssStyleWhiteSpace(node) {
|
48993 | return node.type === "element" && (!node.namespace || isUnknownNamespace(node)) && CSS_WHITE_SPACE_TAGS[node.name] || CSS_WHITE_SPACE_DEFAULT;
|
48994 | }
|
48995 |
|
48996 | function getMinIndentation(text) {
|
48997 | let minIndentation = Infinity;
|
48998 |
|
48999 | for (const lineText of text.split("\n")) {
|
49000 | if (lineText.length === 0) {
|
49001 | continue;
|
49002 | }
|
49003 |
|
49004 | if (/\S/.test(lineText[0])) {
|
49005 | return 0;
|
49006 | }
|
49007 |
|
49008 | const indentation = lineText.match(/^\s*/)[0].length;
|
49009 |
|
49010 | if (lineText.length === indentation) {
|
49011 | continue;
|
49012 | }
|
49013 |
|
49014 | if (indentation < minIndentation) {
|
49015 | minIndentation = indentation;
|
49016 | }
|
49017 | }
|
49018 |
|
49019 | return minIndentation === Infinity ? 0 : minIndentation;
|
49020 | }
|
49021 |
|
49022 | function dedentString(text, minIndent = getMinIndentation(text)) {
|
49023 | return minIndent === 0 ? text : text.split("\n").map(lineText => lineText.slice(minIndent)).join("\n");
|
49024 | }
|
49025 |
|
49026 | function normalizeParts$1(parts) {
|
49027 | const newParts = [];
|
49028 | const restParts = parts.slice();
|
49029 |
|
49030 | while (restParts.length !== 0) {
|
49031 | const part = restParts.shift();
|
49032 |
|
49033 | if (!part) {
|
49034 | continue;
|
49035 | }
|
49036 |
|
49037 | if (part.type === "concat") {
|
49038 | restParts.unshift(...part.parts);
|
49039 | continue;
|
49040 | }
|
49041 |
|
49042 | if (newParts.length !== 0 && typeof newParts[newParts.length - 1] === "string" && typeof part === "string") {
|
49043 | newParts.push(newParts.pop() + part);
|
49044 | continue;
|
49045 | }
|
49046 |
|
49047 | newParts.push(part);
|
49048 | }
|
49049 |
|
49050 | return newParts;
|
49051 | }
|
49052 |
|
49053 | function identity$3(x) {
|
49054 | return x;
|
49055 | }
|
49056 |
|
49057 | function shouldNotPrintClosingTag(node, options) {
|
49058 | return !node.isSelfClosing && !node.endSourceSpan && (hasPrettierIgnore$5(node) || shouldPreserveContent(node.parent, options));
|
49059 | }
|
49060 |
|
49061 | function countChars(text, char) {
|
49062 | let counter = 0;
|
49063 |
|
49064 | for (let i = 0; i < text.length; i++) {
|
49065 | if (text[i] === char) {
|
49066 | counter++;
|
49067 | }
|
49068 | }
|
49069 |
|
49070 | return counter;
|
49071 | }
|
49072 |
|
49073 | function unescapeQuoteEntities(text) {
|
49074 | return text.replace(/'/g, "'").replace(/"/g, '"');
|
49075 | }
|
49076 |
|
49077 | var utils$a = {
|
49078 | HTML_ELEMENT_ATTRIBUTES,
|
49079 | HTML_TAGS,
|
49080 | canHaveInterpolation,
|
49081 | countChars,
|
49082 | countParents,
|
49083 | dedentString,
|
49084 | forceBreakChildren,
|
49085 | forceBreakContent,
|
49086 | forceNextEmptyLine,
|
49087 | getLastDescendant,
|
49088 | getNodeCssStyleDisplay,
|
49089 | getNodeCssStyleWhiteSpace,
|
49090 | getPrettierIgnoreAttributeCommentData,
|
49091 | hasPrettierIgnore: hasPrettierIgnore$5,
|
49092 | identity: identity$3,
|
49093 | inferScriptParser,
|
49094 | isDanglingSpaceSensitiveNode,
|
49095 | isFrontMatterNode,
|
49096 | isIndentationSensitiveNode,
|
49097 | isLeadingSpaceSensitiveNode,
|
49098 | isPreLikeNode,
|
49099 | isScriptLikeTag,
|
49100 | isTextLikeNode,
|
49101 | isTrailingSpaceSensitiveNode,
|
49102 | isWhitespaceSensitiveNode,
|
49103 | isUnknownNamespace,
|
49104 | normalizeParts: normalizeParts$1,
|
49105 | preferHardlineAsLeadingSpaces,
|
49106 | preferHardlineAsTrailingSpaces,
|
49107 | shouldNotPrintClosingTag,
|
49108 | shouldPreserveContent,
|
49109 | unescapeQuoteEntities
|
49110 | };
|
49111 |
|
49112 | const {
|
49113 | canHaveInterpolation: canHaveInterpolation$1,
|
49114 | getNodeCssStyleDisplay: getNodeCssStyleDisplay$1,
|
49115 | isDanglingSpaceSensitiveNode: isDanglingSpaceSensitiveNode$1,
|
49116 | isIndentationSensitiveNode: isIndentationSensitiveNode$1,
|
49117 | isLeadingSpaceSensitiveNode: isLeadingSpaceSensitiveNode$1,
|
49118 | isTrailingSpaceSensitiveNode: isTrailingSpaceSensitiveNode$1,
|
49119 | isWhitespaceSensitiveNode: isWhitespaceSensitiveNode$1
|
49120 | } = utils$a;
|
49121 | const PREPROCESS_PIPELINE = [removeIgnorableFirstLf, mergeIeConditonalStartEndCommentIntoElementOpeningTag, mergeCdataIntoText, extractInterpolation, extractWhitespaces, addCssDisplay, addIsSelfClosing, addHasHtmComponentClosingTag, addIsSpaceSensitive, mergeSimpleElementIntoText];
|
49122 |
|
49123 | function preprocess$2(ast, options) {
|
49124 | for (const fn of PREPROCESS_PIPELINE) {
|
49125 | ast = fn(ast, options);
|
49126 | }
|
49127 |
|
49128 | return ast;
|
49129 | }
|
49130 |
|
49131 | function removeIgnorableFirstLf(ast
|
49132 | /*, options */
|
49133 | ) {
|
49134 | return ast.map(node => {
|
49135 | if (node.type === "element" && node.tagDefinition.ignoreFirstLf && node.children.length !== 0 && node.children[0].type === "text" && node.children[0].value[0] === "\n") {
|
49136 | const [text, ...rest] = node.children;
|
49137 | return node.clone({
|
49138 | children: text.value.length === 1 ? rest : [text.clone({
|
49139 | value: text.value.slice(1)
|
49140 | }), ...rest]
|
49141 | });
|
49142 | }
|
49143 |
|
49144 | return node;
|
49145 | });
|
49146 | }
|
49147 |
|
49148 | function mergeIeConditonalStartEndCommentIntoElementOpeningTag(ast
|
49149 | /*, options */
|
49150 | ) {
|
49151 | |
49152 |
|
49153 |
|
49154 | const isTarget = node => node.type === "element" && node.prev && node.prev.type === "ieConditionalStartComment" && node.prev.sourceSpan.end.offset === node.startSourceSpan.start.offset && node.firstChild && node.firstChild.type === "ieConditionalEndComment" && node.firstChild.sourceSpan.start.offset === node.startSourceSpan.end.offset;
|
49155 |
|
49156 | return ast.map(node => {
|
49157 | if (node.children) {
|
49158 | const isTargetResults = node.children.map(isTarget);
|
49159 |
|
49160 | if (isTargetResults.some(Boolean)) {
|
49161 | const newChildren = [];
|
49162 |
|
49163 | for (let i = 0; i < node.children.length; i++) {
|
49164 | const child = node.children[i];
|
49165 |
|
49166 | if (isTargetResults[i + 1]) {
|
49167 |
|
49168 | continue;
|
49169 | }
|
49170 |
|
49171 | if (isTargetResults[i]) {
|
49172 | const ieConditionalStartComment = child.prev;
|
49173 | const ieConditionalEndComment = child.firstChild;
|
49174 | const ParseSourceSpan = child.sourceSpan.constructor;
|
49175 | const startSourceSpan = new ParseSourceSpan(ieConditionalStartComment.sourceSpan.start, ieConditionalEndComment.sourceSpan.end);
|
49176 | const sourceSpan = new ParseSourceSpan(startSourceSpan.start, child.sourceSpan.end);
|
49177 | newChildren.push(child.clone({
|
49178 | condition: ieConditionalStartComment.condition,
|
49179 | sourceSpan,
|
49180 | startSourceSpan,
|
49181 | children: child.children.slice(1)
|
49182 | }));
|
49183 | continue;
|
49184 | }
|
49185 |
|
49186 | newChildren.push(child);
|
49187 | }
|
49188 |
|
49189 | return node.clone({
|
49190 | children: newChildren
|
49191 | });
|
49192 | }
|
49193 | }
|
49194 |
|
49195 | return node;
|
49196 | });
|
49197 | }
|
49198 |
|
49199 | function mergeNodeIntoText(ast, shouldMerge, getValue) {
|
49200 | return ast.map(node => {
|
49201 | if (node.children) {
|
49202 | const shouldMergeResults = node.children.map(shouldMerge);
|
49203 |
|
49204 | if (shouldMergeResults.some(Boolean)) {
|
49205 | const newChildren = [];
|
49206 |
|
49207 | for (let i = 0; i < node.children.length; i++) {
|
49208 | const child = node.children[i];
|
49209 |
|
49210 | if (child.type !== "text" && !shouldMergeResults[i]) {
|
49211 | newChildren.push(child);
|
49212 | continue;
|
49213 | }
|
49214 |
|
49215 | const newChild = child.type === "text" ? child : child.clone({
|
49216 | type: "text",
|
49217 | value: getValue(child)
|
49218 | });
|
49219 |
|
49220 | if (newChildren.length === 0 || newChildren[newChildren.length - 1].type !== "text") {
|
49221 | newChildren.push(newChild);
|
49222 | continue;
|
49223 | }
|
49224 |
|
49225 | const lastChild = newChildren.pop();
|
49226 | const ParseSourceSpan = lastChild.sourceSpan.constructor;
|
49227 | newChildren.push(lastChild.clone({
|
49228 | value: lastChild.value + newChild.value,
|
49229 | sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, newChild.sourceSpan.end)
|
49230 | }));
|
49231 | }
|
49232 |
|
49233 | return node.clone({
|
49234 | children: newChildren
|
49235 | });
|
49236 | }
|
49237 | }
|
49238 |
|
49239 | return node;
|
49240 | });
|
49241 | }
|
49242 |
|
49243 | function mergeCdataIntoText(ast
|
49244 | /*, options */
|
49245 | ) {
|
49246 | return mergeNodeIntoText(ast, node => node.type === "cdata", node => `<![CDATA[${node.value}]]>`);
|
49247 | }
|
49248 |
|
49249 | function mergeSimpleElementIntoText(ast
|
49250 | /*, options */
|
49251 | ) {
|
49252 | const isSimpleElement = node => node.type === "element" && node.attrs.length === 0 && node.children.length === 1 && node.firstChild.type === "text" &&
|
49253 | !/[^\S\xA0]/.test(node.children[0].value) && !node.firstChild.hasLeadingSpaces && !node.firstChild.hasTrailingSpaces && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces && node.prev && node.prev.type === "text" && node.next && node.next.type === "text";
|
49254 |
|
49255 | return ast.map(node => {
|
49256 | if (node.children) {
|
49257 | const isSimpleElementResults = node.children.map(isSimpleElement);
|
49258 |
|
49259 | if (isSimpleElementResults.some(Boolean)) {
|
49260 | const newChildren = [];
|
49261 |
|
49262 | for (let i = 0; i < node.children.length; i++) {
|
49263 | const child = node.children[i];
|
49264 |
|
49265 | if (isSimpleElementResults[i]) {
|
49266 | const lastChild = newChildren.pop();
|
49267 | const nextChild = node.children[++i];
|
49268 | const ParseSourceSpan = node.sourceSpan.constructor;
|
49269 | const {
|
49270 | isTrailingSpaceSensitive,
|
49271 | hasTrailingSpaces
|
49272 | } = nextChild;
|
49273 | newChildren.push(lastChild.clone({
|
49274 | value: lastChild.value + `<${child.rawName}>` + child.firstChild.value + `</${child.rawName}>` + nextChild.value,
|
49275 | sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, nextChild.sourceSpan.end),
|
49276 | isTrailingSpaceSensitive,
|
49277 | hasTrailingSpaces
|
49278 | }));
|
49279 | } else {
|
49280 | newChildren.push(child);
|
49281 | }
|
49282 | }
|
49283 |
|
49284 | return node.clone({
|
49285 | children: newChildren
|
49286 | });
|
49287 | }
|
49288 | }
|
49289 |
|
49290 | return node;
|
49291 | });
|
49292 | }
|
49293 |
|
49294 | function extractInterpolation(ast, options) {
|
49295 | if (options.parser === "html") {
|
49296 | return ast;
|
49297 | }
|
49298 |
|
49299 | const interpolationRegex = /\{\{([\s\S]+?)\}\}/g;
|
49300 | return ast.map(node => {
|
49301 | if (!canHaveInterpolation$1(node)) {
|
49302 | return node;
|
49303 | }
|
49304 |
|
49305 | const newChildren = [];
|
49306 |
|
49307 | for (const child of node.children) {
|
49308 | if (child.type !== "text") {
|
49309 | newChildren.push(child);
|
49310 | continue;
|
49311 | }
|
49312 |
|
49313 | const ParseSourceSpan = child.sourceSpan.constructor;
|
49314 | let startSourceSpan = child.sourceSpan.start;
|
49315 | let endSourceSpan = null;
|
49316 | const components = child.value.split(interpolationRegex);
|
49317 |
|
49318 | for (let i = 0; i < components.length; i++, startSourceSpan = endSourceSpan) {
|
49319 | const value = components[i];
|
49320 |
|
49321 | if (i % 2 === 0) {
|
49322 | endSourceSpan = startSourceSpan.moveBy(value.length);
|
49323 |
|
49324 | if (value.length !== 0) {
|
49325 | newChildren.push({
|
49326 | type: "text",
|
49327 | value,
|
49328 | sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan)
|
49329 | });
|
49330 | }
|
49331 |
|
49332 | continue;
|
49333 | }
|
49334 |
|
49335 | endSourceSpan = startSourceSpan.moveBy(value.length + 4);
|
49336 |
|
49337 | newChildren.push({
|
49338 | type: "interpolation",
|
49339 | sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan),
|
49340 | children: value.length === 0 ? [] : [{
|
49341 | type: "text",
|
49342 | value,
|
49343 | sourceSpan: new ParseSourceSpan(startSourceSpan.moveBy(2), endSourceSpan.moveBy(-2))
|
49344 | }]
|
49345 | });
|
49346 | }
|
49347 | }
|
49348 |
|
49349 | return node.clone({
|
49350 | children: newChildren
|
49351 | });
|
49352 | });
|
49353 | }
|
49354 |
|
49355 |
|
49356 |
|
49357 |
|
49358 |
|
49359 |
|
49360 |
|
49361 |
|
49362 |
|
49363 | function extractWhitespaces(ast
|
49364 | /*, options*/
|
49365 | ) {
|
49366 | const TYPE_WHITESPACE = "whitespace";
|
49367 | return ast.map(node => {
|
49368 | if (!node.children) {
|
49369 | return node;
|
49370 | }
|
49371 |
|
49372 | if (node.children.length === 0 || node.children.length === 1 && node.children[0].type === "text" && node.children[0].value.trim().length === 0) {
|
49373 | return node.clone({
|
49374 | children: [],
|
49375 | hasDanglingSpaces: node.children.length !== 0
|
49376 | });
|
49377 | }
|
49378 |
|
49379 | const isWhitespaceSensitive = isWhitespaceSensitiveNode$1(node);
|
49380 | const isIndentationSensitive = isIndentationSensitiveNode$1(node);
|
49381 | return node.clone({
|
49382 | isWhitespaceSensitive,
|
49383 | isIndentationSensitive,
|
49384 | children: node.children
|
49385 | .reduce((newChildren, child) => {
|
49386 | if (child.type !== "text" || isWhitespaceSensitive) {
|
49387 | return newChildren.concat(child);
|
49388 | }
|
49389 |
|
49390 | const localChildren = [];
|
49391 | const [, leadingSpaces, text, trailingSpaces] = child.value.match(/^(\s*)([\s\S]*?)(\s*)$/);
|
49392 |
|
49393 | if (leadingSpaces) {
|
49394 | localChildren.push({
|
49395 | type: TYPE_WHITESPACE
|
49396 | });
|
49397 | }
|
49398 |
|
49399 | const ParseSourceSpan = child.sourceSpan.constructor;
|
49400 |
|
49401 | if (text) {
|
49402 | localChildren.push({
|
49403 | type: "text",
|
49404 | value: text,
|
49405 | sourceSpan: new ParseSourceSpan(child.sourceSpan.start.moveBy(leadingSpaces.length), child.sourceSpan.end.moveBy(-trailingSpaces.length))
|
49406 | });
|
49407 | }
|
49408 |
|
49409 | if (trailingSpaces) {
|
49410 | localChildren.push({
|
49411 | type: TYPE_WHITESPACE
|
49412 | });
|
49413 | }
|
49414 |
|
49415 | return newChildren.concat(localChildren);
|
49416 | }, [])
|
49417 | .reduce((newChildren, child, i, children) => {
|
49418 | if (child.type === TYPE_WHITESPACE) {
|
49419 | return newChildren;
|
49420 | }
|
49421 |
|
49422 | const hasLeadingSpaces = i !== 0 && children[i - 1].type === TYPE_WHITESPACE;
|
49423 | const hasTrailingSpaces = i !== children.length - 1 && children[i + 1].type === TYPE_WHITESPACE;
|
49424 | return newChildren.concat(Object.assign({}, child, {
|
49425 | hasLeadingSpaces,
|
49426 | hasTrailingSpaces
|
49427 | }));
|
49428 | }, [])
|
49429 | });
|
49430 | });
|
49431 | }
|
49432 |
|
49433 | function addIsSelfClosing(ast
|
49434 | /*, options */
|
49435 | ) {
|
49436 | return ast.map(node => Object.assign(node, {
|
49437 | isSelfClosing: !node.children || node.type === "element" && (node.tagDefinition.isVoid ||
|
49438 | node.startSourceSpan === node.endSourceSpan)
|
49439 | }));
|
49440 | }
|
49441 |
|
49442 | function addHasHtmComponentClosingTag(ast, options) {
|
49443 | return ast.map(node => node.type !== "element" ? node : Object.assign(node, {
|
49444 | hasHtmComponentClosingTag: node.endSourceSpan && /^<\s*\/\s*\/\s*>$/.test(options.originalText.slice(node.endSourceSpan.start.offset, node.endSourceSpan.end.offset))
|
49445 | }));
|
49446 | }
|
49447 |
|
49448 | function addCssDisplay(ast, options) {
|
49449 | return ast.map(node => Object.assign(node, {
|
49450 | cssDisplay: getNodeCssStyleDisplay$1(node, options)
|
49451 | }));
|
49452 | }
|
49453 |
|
49454 |
|
49455 |
|
49456 |
|
49457 |
|
49458 |
|
49459 |
|
49460 | function addIsSpaceSensitive(ast
|
49461 | /*, options */
|
49462 | ) {
|
49463 | return ast.map(node => {
|
49464 | if (!node.children) {
|
49465 | return node;
|
49466 | }
|
49467 |
|
49468 | if (node.children.length === 0) {
|
49469 | return node.clone({
|
49470 | isDanglingSpaceSensitive: isDanglingSpaceSensitiveNode$1(node)
|
49471 | });
|
49472 | }
|
49473 |
|
49474 | return node.clone({
|
49475 | children: node.children.map(child => {
|
49476 | return Object.assign({}, child, {
|
49477 | isLeadingSpaceSensitive: isLeadingSpaceSensitiveNode$1(child),
|
49478 | isTrailingSpaceSensitive: isTrailingSpaceSensitiveNode$1(child)
|
49479 | });
|
49480 | }).map((child, index, children) => Object.assign({}, child, {
|
49481 | isLeadingSpaceSensitive: index === 0 ? child.isLeadingSpaceSensitive : children[index - 1].isTrailingSpaceSensitive && child.isLeadingSpaceSensitive,
|
49482 | isTrailingSpaceSensitive: index === children.length - 1 ? child.isTrailingSpaceSensitive : children[index + 1].isLeadingSpaceSensitive && child.isTrailingSpaceSensitive
|
49483 | }))
|
49484 | });
|
49485 | });
|
49486 | }
|
49487 |
|
49488 | var preprocess_1$2 = preprocess$2;
|
49489 |
|
49490 | function hasPragma$3(text) {
|
49491 | return /^\s*<!--\s*@(format|prettier)\s*-->/.test(text);
|
49492 | }
|
49493 |
|
49494 | function insertPragma$6(text) {
|
49495 | return "<!-- @format -->\n\n" + text.replace(/^\s*\n/, "");
|
49496 | }
|
49497 |
|
49498 | var pragma$4 = {
|
49499 | hasPragma: hasPragma$3,
|
49500 | insertPragma: insertPragma$6
|
49501 | };
|
49502 |
|
49503 | const {
|
49504 | builders: {
|
49505 | concat: concat$e,
|
49506 | group: group$e
|
49507 | }
|
49508 | } = document;
|
49509 |
|
49510 |
|
49511 |
|
49512 |
|
49513 |
|
49514 |
|
49515 |
|
49516 | function printVueFor(value, textToDoc) {
|
49517 | const {
|
49518 | left,
|
49519 | operator,
|
49520 | right
|
49521 | } = parseVueFor(value);
|
49522 | return concat$e([group$e(textToDoc(`function _(${left}) {}`, {
|
49523 | parser: "babel",
|
49524 | __isVueForBindingLeft: true
|
49525 | })), " ", operator, " ", textToDoc(right, {
|
49526 | parser: "__js_expression"
|
49527 | })]);
|
49528 | }
|
49529 |
|
49530 |
|
49531 | function parseVueFor(value) {
|
49532 | const forAliasRE = /([^]*?)\s+(in|of)\s+([^]*)/;
|
49533 | const forIteratorRE = /,([^,}\]]*)(?:,([^,}\]]*))?$/;
|
49534 | const stripParensRE = /^\(|\)$/g;
|
49535 | const inMatch = value.match(forAliasRE);
|
49536 |
|
49537 | if (!inMatch) {
|
49538 | return;
|
49539 | }
|
49540 |
|
49541 | const res = {};
|
49542 | res.for = inMatch[3].trim();
|
49543 | const alias = inMatch[1].trim().replace(stripParensRE, "");
|
49544 | const iteratorMatch = alias.match(forIteratorRE);
|
49545 |
|
49546 | if (iteratorMatch) {
|
49547 | res.alias = alias.replace(forIteratorRE, "");
|
49548 | res.iterator1 = iteratorMatch[1].trim();
|
49549 |
|
49550 | if (iteratorMatch[2]) {
|
49551 | res.iterator2 = iteratorMatch[2].trim();
|
49552 | }
|
49553 | } else {
|
49554 | res.alias = alias;
|
49555 | }
|
49556 |
|
49557 | return {
|
49558 | left: `${[res.alias, res.iterator1, res.iterator2].filter(Boolean).join(",")}`,
|
49559 | operator: inMatch[2],
|
49560 | right: res.for
|
49561 | };
|
49562 | }
|
49563 |
|
49564 | function printVueSlotScope(value, textToDoc) {
|
49565 | return textToDoc(`function _(${value}) {}`, {
|
49566 | parser: "babel",
|
49567 | __isVueSlotScope: true
|
49568 | });
|
49569 | }
|
49570 |
|
49571 | function isVueEventBindingExpression$2(eventBindingValue) {
|
49572 |
|
49573 |
|
49574 | const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
|
49575 |
|
49576 | const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
|
49577 |
|
49578 | const value = eventBindingValue.trim();
|
49579 | return fnExpRE.test(value) || simplePathRE.test(value);
|
49580 | }
|
49581 |
|
49582 | var syntaxVue = {
|
49583 | isVueEventBindingExpression: isVueEventBindingExpression$2,
|
49584 | printVueFor,
|
49585 | printVueSlotScope
|
49586 | };
|
49587 |
|
49588 | const integerRegex = /^\d+$/;
|
49589 |
|
49590 | function deepUnique(array) {
|
49591 | return array.sort().filter((element, index) => {
|
49592 | return JSON.stringify(element) !== JSON.stringify(array[index - 1]);
|
49593 | });
|
49594 | }
|
49595 |
|
49596 | var parse$6 = string => {
|
49597 | return deepUnique(string.split(',').map(part => {
|
49598 | const result = {};
|
49599 | part.trim().split(/\s+/).forEach((element, index) => {
|
49600 | if (index === 0) {
|
49601 | result.url = element;
|
49602 | return;
|
49603 | }
|
49604 |
|
49605 | const value = element.slice(0, element.length - 1);
|
49606 | const postfix = element[element.length - 1];
|
49607 | const integerValue = parseInt(value, 10);
|
49608 | const floatValue = parseFloat(value);
|
49609 |
|
49610 | if (postfix === 'w' && integerRegex.test(value)) {
|
49611 | result.width = integerValue;
|
49612 | } else if (postfix === 'h' && integerRegex.test(value)) {
|
49613 | result.height = integerValue;
|
49614 | } else if (postfix === 'x' && !Number.isNaN(floatValue)) {
|
49615 | result.density = floatValue;
|
49616 | } else {
|
49617 | throw new Error(`Invalid srcset descriptor: ${element}`);
|
49618 | }
|
49619 | });
|
49620 | return result;
|
49621 | }));
|
49622 | };
|
49623 |
|
49624 | var stringify$2 = array => {
|
49625 | return [...new Set(array.map(element => {
|
49626 | if (!element.url) {
|
49627 | throw new Error('URL is required');
|
49628 | }
|
49629 |
|
49630 | const result = [element.url];
|
49631 |
|
49632 | if (element.width) {
|
49633 | result.push(`${element.width}w`);
|
49634 | }
|
49635 |
|
49636 | if (element.height) {
|
49637 | result.push(`${element.height}h`);
|
49638 | }
|
49639 |
|
49640 | if (element.density) {
|
49641 | result.push(`${element.density}x`);
|
49642 | }
|
49643 |
|
49644 | return result.join(' ');
|
49645 | }))].join(', ');
|
49646 | };
|
49647 |
|
49648 | var srcset = {
|
49649 | parse: parse$6,
|
49650 | stringify: stringify$2
|
49651 | };
|
49652 |
|
49653 | const {
|
49654 | builders: {
|
49655 | concat: concat$f,
|
49656 | ifBreak: ifBreak$6,
|
49657 | join: join$a,
|
49658 | line: line$9
|
49659 | }
|
49660 | } = document;
|
49661 | const parseSrcset = srcset.parse;
|
49662 |
|
49663 | function printImgSrcset(value) {
|
49664 | const srcset = parseSrcset(value);
|
49665 | const hasW = srcset.some(src => src.width);
|
49666 | const hasH = srcset.some(src => src.height);
|
49667 | const hasX = srcset.some(src => src.density);
|
49668 |
|
49669 | if (hasW + hasH + hasX > 1) {
|
49670 | throw new Error("Mixed descriptor in srcset is not supported");
|
49671 | }
|
49672 |
|
49673 | const key = hasW ? "width" : hasH ? "height" : "density";
|
49674 | const unit = hasW ? "w" : hasH ? "h" : "x";
|
49675 |
|
49676 | const getMax = values => Math.max(...values);
|
49677 |
|
49678 | const urls = srcset.map(src => src.url);
|
49679 | const maxUrlLength = getMax(urls.map(url => url.length));
|
49680 | const descriptors = srcset.map(src => src[key]).map(descriptor => descriptor ? descriptor.toString() : "");
|
49681 | const descriptorLeftLengths = descriptors.map(descriptor => {
|
49682 | const index = descriptor.indexOf(".");
|
49683 | return index === -1 ? descriptor.length : index;
|
49684 | });
|
49685 | const maxDescriptorLeftLength = getMax(descriptorLeftLengths);
|
49686 | return join$a(concat$f([",", line$9]), urls.map((url, index) => {
|
49687 | const parts = [url];
|
49688 | const descriptor = descriptors[index];
|
49689 |
|
49690 | if (descriptor) {
|
49691 | const urlPadding = maxUrlLength - url.length + 1;
|
49692 | const descriptorPadding = maxDescriptorLeftLength - descriptorLeftLengths[index];
|
49693 | const alignment = " ".repeat(urlPadding + descriptorPadding);
|
49694 | parts.push(ifBreak$6(alignment, " "), descriptor + unit);
|
49695 | }
|
49696 |
|
49697 | return concat$f(parts);
|
49698 | }));
|
49699 | }
|
49700 |
|
49701 | function printClassNames(value) {
|
49702 | return value.trim().split(/\s+/).join(" ");
|
49703 | }
|
49704 |
|
49705 | var syntaxAttribute = {
|
49706 | printImgSrcset,
|
49707 | printClassNames
|
49708 | };
|
49709 |
|
49710 | const {
|
49711 | builders,
|
49712 | utils: {
|
49713 | stripTrailingHardline: stripTrailingHardline$2,
|
49714 | mapDoc: mapDoc$5
|
49715 | }
|
49716 | } = document;
|
49717 | const {
|
49718 | breakParent: breakParent$4,
|
49719 | dedentToRoot: dedentToRoot$2,
|
49720 | fill: fill$6,
|
49721 | group: group$f,
|
49722 | hardline: hardline$c,
|
49723 | ifBreak: ifBreak$7,
|
49724 | indent: indent$9,
|
49725 | join: join$b,
|
49726 | line: line$a,
|
49727 | literalline: literalline$6,
|
49728 | markAsRoot: markAsRoot$4,
|
49729 | softline: softline$7
|
49730 | } = builders;
|
49731 | const {
|
49732 | countChars: countChars$1,
|
49733 | countParents: countParents$1,
|
49734 | dedentString: dedentString$1,
|
49735 | forceBreakChildren: forceBreakChildren$1,
|
49736 | forceBreakContent: forceBreakContent$1,
|
49737 | forceNextEmptyLine: forceNextEmptyLine$1,
|
49738 | getLastDescendant: getLastDescendant$1,
|
49739 | getPrettierIgnoreAttributeCommentData: getPrettierIgnoreAttributeCommentData$1,
|
49740 | hasPrettierIgnore: hasPrettierIgnore$6,
|
49741 | inferScriptParser: inferScriptParser$1,
|
49742 | isScriptLikeTag: isScriptLikeTag$1,
|
49743 | isTextLikeNode: isTextLikeNode$1,
|
49744 | normalizeParts: normalizeParts$2,
|
49745 | preferHardlineAsLeadingSpaces: preferHardlineAsLeadingSpaces$1,
|
49746 | shouldNotPrintClosingTag: shouldNotPrintClosingTag$1,
|
49747 | shouldPreserveContent: shouldPreserveContent$1,
|
49748 | unescapeQuoteEntities: unescapeQuoteEntities$1
|
49749 | } = utils$a;
|
49750 | const {
|
49751 | replaceEndOfLineWith: replaceEndOfLineWith$2
|
49752 | } = util$1;
|
49753 | const {
|
49754 | insertPragma: insertPragma$7
|
49755 | } = pragma$4;
|
49756 | const {
|
49757 | printVueFor: printVueFor$1,
|
49758 | printVueSlotScope: printVueSlotScope$1,
|
49759 | isVueEventBindingExpression: isVueEventBindingExpression$3
|
49760 | } = syntaxVue;
|
49761 | const {
|
49762 | printImgSrcset: printImgSrcset$1,
|
49763 | printClassNames: printClassNames$1
|
49764 | } = syntaxAttribute;
|
49765 |
|
49766 | function concat$g(parts) {
|
49767 | const newParts = normalizeParts$2(parts);
|
49768 | return newParts.length === 0 ? "" : newParts.length === 1 ? newParts[0] : builders.concat(newParts);
|
49769 | }
|
49770 |
|
49771 | function embed$4(path, print, textToDoc, options) {
|
49772 | const node = path.getValue();
|
49773 |
|
49774 | switch (node.type) {
|
49775 | case "text":
|
49776 | {
|
49777 | if (isScriptLikeTag$1(node.parent)) {
|
49778 | const parser = inferScriptParser$1(node.parent);
|
49779 |
|
49780 | if (parser) {
|
49781 | const value = parser === "markdown" ? dedentString$1(node.value.replace(/^[^\S\n]*?\n/, "")) : node.value;
|
49782 | return builders.concat([concat$g([breakParent$4, printOpeningTagPrefix(node, options), stripTrailingHardline$2(textToDoc(value, {
|
49783 | parser
|
49784 | })), printClosingTagSuffix(node, options)])]);
|
49785 | }
|
49786 | } else if (node.parent.type === "interpolation") {
|
49787 | return concat$g([indent$9(concat$g([line$a, textToDoc(node.value, Object.assign({
|
49788 | __isInHtmlInterpolation: true
|
49789 | }, options.parser === "angular" ? {
|
49790 | parser: "__ng_interpolation",
|
49791 | trailingComma: "none"
|
49792 | } : options.parser === "vue" ? {
|
49793 | parser: "__vue_expression"
|
49794 | } : {
|
49795 | parser: "__js_expression"
|
49796 | }))])), node.parent.next && needsToBorrowPrevClosingTagEndMarker(node.parent.next) ? " " : line$a]);
|
49797 | }
|
49798 |
|
49799 | break;
|
49800 | }
|
49801 |
|
49802 | case "attribute":
|
49803 | {
|
49804 | if (!node.value) {
|
49805 | break;
|
49806 | }
|
49807 |
|
49808 |
|
49809 | if (/^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
|
49810 | return concat$g([node.rawName, "=", node.value]);
|
49811 | }
|
49812 |
|
49813 |
|
49814 | if (options.parser === "lwc") {
|
49815 | const interpolationRegex = /^\{[\s\S]*\}$/;
|
49816 |
|
49817 | if (interpolationRegex.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
|
49818 | return concat$g([node.rawName, "=", node.value]);
|
49819 | }
|
49820 | }
|
49821 |
|
49822 | const embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, (code, opts) =>
|
49823 | textToDoc(code, Object.assign({
|
49824 | __isInHtmlAttribute: true
|
49825 | }, opts)), options);
|
49826 |
|
49827 | if (embeddedAttributeValueDoc) {
|
49828 | return concat$g([node.rawName, '="', group$f(mapDoc$5(embeddedAttributeValueDoc, doc => typeof doc === "string" ? doc.replace(/"/g, """) : doc)), '"']);
|
49829 | }
|
49830 |
|
49831 | break;
|
49832 | }
|
49833 |
|
49834 | case "yaml":
|
49835 | return markAsRoot$4(concat$g(["---", hardline$c, node.value.trim().length === 0 ? "" : textToDoc(node.value, {
|
49836 | parser: "yaml"
|
49837 | }), "---"]));
|
49838 | }
|
49839 | }
|
49840 |
|
49841 | function genericPrint$5(path, options, print) {
|
49842 | const node = path.getValue();
|
49843 |
|
49844 | switch (node.type) {
|
49845 | case "root":
|
49846 | if (options.__onHtmlRoot) {
|
49847 | options.__onHtmlRoot(node);
|
49848 | }
|
49849 |
|
49850 |
|
49851 | return builders.concat([group$f(printChildren$2(path, options, print)), hardline$c]);
|
49852 |
|
49853 | case "element":
|
49854 | case "ieConditionalComment":
|
49855 | {
|
49856 | |
49857 |
|
49858 |
|
49859 |
|
49860 |
|
49861 |
|
49862 |
|
49863 |
|
49864 |
|
49865 |
|
49866 |
|
49867 |
|
49868 |
|
49869 |
|
49870 |
|
49871 |
|
49872 |
|
49873 |
|
49874 |
|
49875 |
|
49876 | const shouldHugContent = node.children.length === 1 && node.firstChild.type === "interpolation" && node.firstChild.isLeadingSpaceSensitive && !node.firstChild.hasLeadingSpaces && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces;
|
49877 | const attrGroupId = Symbol("element-attr-group-id");
|
49878 | return concat$g([group$f(concat$g([group$f(printOpeningTag(path, options, print), {
|
49879 | id: attrGroupId
|
49880 | }), node.children.length === 0 ? node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$a : "" : concat$g([forceBreakContent$1(node) ? breakParent$4 : "", (childrenDoc => shouldHugContent ? ifBreak$7(indent$9(childrenDoc), childrenDoc, {
|
49881 | groupId: attrGroupId
|
49882 | }) : isScriptLikeTag$1(node) && node.parent.type === "root" && options.parser === "vue" && !options.vueIndentScriptAndStyle ? childrenDoc : indent$9(childrenDoc))(concat$g([shouldHugContent ? ifBreak$7(softline$7, "", {
|
49883 | groupId: attrGroupId
|
49884 | }) : node.firstChild.hasLeadingSpaces && node.firstChild.isLeadingSpaceSensitive ? line$a : node.firstChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive ? dedentToRoot$2(softline$7) : softline$7, printChildren$2(path, options, print)])), (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? " " : "" : shouldHugContent ? ifBreak$7(softline$7, "", {
|
49885 | groupId: attrGroupId
|
49886 | }) : node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? line$a : (node.lastChild.type === "comment" || node.lastChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive) && new RegExp(`\\n\\s{${options.tabWidth * countParents$1(path, n => n.parent && n.parent.type !== "root")}}$`).test(node.lastChild.value) ?
|
49887 | |
49888 |
|
49889 |
|
49890 |
|
49891 |
|
49892 |
|
49893 |
|
49894 |
|
49895 | "" : softline$7])])), printClosingTag(node, options)]);
|
49896 | }
|
49897 |
|
49898 | case "ieConditionalStartComment":
|
49899 | case "ieConditionalEndComment":
|
49900 | return concat$g([printOpeningTagStart(node), printClosingTagEnd(node)]);
|
49901 |
|
49902 | case "interpolation":
|
49903 | return concat$g([printOpeningTagStart(node, options), concat$g(path.map(print, "children")), printClosingTagEnd(node, options)]);
|
49904 |
|
49905 | case "text":
|
49906 | {
|
49907 | if (node.parent.type === "interpolation") {
|
49908 |
|
49909 | const trailingNewlineRegex = /\n[^\S\n]*?$/;
|
49910 | const hasTrailingNewline = trailingNewlineRegex.test(node.value);
|
49911 | const value = hasTrailingNewline ? node.value.replace(trailingNewlineRegex, "") : node.value;
|
49912 | return concat$g([concat$g(replaceEndOfLineWith$2(value, literalline$6)), hasTrailingNewline ? hardline$c : ""]);
|
49913 | }
|
49914 |
|
49915 | return fill$6(normalizeParts$2([].concat(printOpeningTagPrefix(node, options), getTextValueParts(node), printClosingTagSuffix(node, options))));
|
49916 | }
|
49917 |
|
49918 | case "docType":
|
49919 | return concat$g([group$f(concat$g([printOpeningTagStart(node, options), " ", node.value.replace(/^html\b/i, "html").replace(/\s+/g, " ")])), printClosingTagEnd(node, options)]);
|
49920 |
|
49921 | case "comment":
|
49922 | {
|
49923 | return concat$g([printOpeningTagPrefix(node, options), concat$g(replaceEndOfLineWith$2(options.originalText.slice(options.locStart(node), options.locEnd(node)), literalline$6)), printClosingTagSuffix(node, options)]);
|
49924 | }
|
49925 |
|
49926 | case "attribute":
|
49927 | {
|
49928 | if (node.value === null) {
|
49929 | return node.rawName;
|
49930 | }
|
49931 |
|
49932 | const value = unescapeQuoteEntities$1(node.value);
|
49933 | const singleQuoteCount = countChars$1(value, "'");
|
49934 | const doubleQuoteCount = countChars$1(value, '"');
|
49935 | const quote = singleQuoteCount < doubleQuoteCount ? "'" : '"';
|
49936 | return concat$g([node.rawName, concat$g(["=", quote, concat$g(replaceEndOfLineWith$2(quote === '"' ? value.replace(/"/g, """) : value.replace(/'/g, "'"), literalline$6)), quote])]);
|
49937 | }
|
49938 |
|
49939 | case "yaml":
|
49940 | case "toml":
|
49941 | return concat$g(replaceEndOfLineWith$2(node.raw, literalline$6));
|
49942 |
|
49943 | default:
|
49944 | throw new Error(`Unexpected node type ${node.type}`);
|
49945 | }
|
49946 | }
|
49947 |
|
49948 | function printChildren$2(path, options, print) {
|
49949 | const node = path.getValue();
|
49950 |
|
49951 | if (forceBreakChildren$1(node)) {
|
49952 | return concat$g([breakParent$4, concat$g(path.map(childPath => {
|
49953 | const childNode = childPath.getValue();
|
49954 | const prevBetweenLine = !childNode.prev ? "" : printBetweenLine(childNode.prev, childNode);
|
49955 | return concat$g([!prevBetweenLine ? "" : concat$g([prevBetweenLine, forceNextEmptyLine$1(childNode.prev) ? hardline$c : ""]), printChild(childPath)]);
|
49956 | }, "children"))]);
|
49957 | }
|
49958 |
|
49959 | const groupIds = node.children.map(() => Symbol(""));
|
49960 | return concat$g(path.map((childPath, childIndex) => {
|
49961 | const childNode = childPath.getValue();
|
49962 |
|
49963 | if (isTextLikeNode$1(childNode)) {
|
49964 | if (childNode.prev && isTextLikeNode$1(childNode.prev)) {
|
49965 | const prevBetweenLine = printBetweenLine(childNode.prev, childNode);
|
49966 |
|
49967 | if (prevBetweenLine) {
|
49968 | if (forceNextEmptyLine$1(childNode.prev)) {
|
49969 | return concat$g([hardline$c, hardline$c, printChild(childPath)]);
|
49970 | }
|
49971 |
|
49972 | return concat$g([prevBetweenLine, printChild(childPath)]);
|
49973 | }
|
49974 | }
|
49975 |
|
49976 | return printChild(childPath);
|
49977 | }
|
49978 |
|
49979 | const prevParts = [];
|
49980 | const leadingParts = [];
|
49981 | const trailingParts = [];
|
49982 | const nextParts = [];
|
49983 | const prevBetweenLine = childNode.prev ? printBetweenLine(childNode.prev, childNode) : "";
|
49984 | const nextBetweenLine = childNode.next ? printBetweenLine(childNode, childNode.next) : "";
|
49985 |
|
49986 | if (prevBetweenLine) {
|
49987 | if (forceNextEmptyLine$1(childNode.prev)) {
|
49988 | prevParts.push(hardline$c, hardline$c);
|
49989 | } else if (prevBetweenLine === hardline$c) {
|
49990 | prevParts.push(hardline$c);
|
49991 | } else {
|
49992 | if (isTextLikeNode$1(childNode.prev)) {
|
49993 | leadingParts.push(prevBetweenLine);
|
49994 | } else {
|
49995 | leadingParts.push(ifBreak$7("", softline$7, {
|
49996 | groupId: groupIds[childIndex - 1]
|
49997 | }));
|
49998 | }
|
49999 | }
|
50000 | }
|
50001 |
|
50002 | if (nextBetweenLine) {
|
50003 | if (forceNextEmptyLine$1(childNode)) {
|
50004 | if (isTextLikeNode$1(childNode.next)) {
|
50005 | nextParts.push(hardline$c, hardline$c);
|
50006 | }
|
50007 | } else if (nextBetweenLine === hardline$c) {
|
50008 | if (isTextLikeNode$1(childNode.next)) {
|
50009 | nextParts.push(hardline$c);
|
50010 | }
|
50011 | } else {
|
50012 | trailingParts.push(nextBetweenLine);
|
50013 | }
|
50014 | }
|
50015 |
|
50016 | return concat$g([].concat(prevParts, group$f(concat$g([concat$g(leadingParts), group$f(concat$g([printChild(childPath), concat$g(trailingParts)]), {
|
50017 | id: groupIds[childIndex]
|
50018 | })])), nextParts));
|
50019 | }, "children"));
|
50020 |
|
50021 | function printChild(childPath) {
|
50022 | const child = childPath.getValue();
|
50023 |
|
50024 | if (hasPrettierIgnore$6(child)) {
|
50025 | return concat$g([].concat(printOpeningTagPrefix(child, options), replaceEndOfLineWith$2(options.originalText.slice(options.locStart(child) + (child.prev && needsToBorrowNextOpeningTagStartMarker(child.prev) ? printOpeningTagStartMarker(child).length : 0), options.locEnd(child) - (child.next && needsToBorrowPrevClosingTagEndMarker(child.next) ? printClosingTagEndMarker(child, options).length : 0)), literalline$6), printClosingTagSuffix(child, options)));
|
50026 | }
|
50027 |
|
50028 | if (shouldPreserveContent$1(child, options)) {
|
50029 | return concat$g([].concat(printOpeningTagPrefix(child, options), group$f(printOpeningTag(childPath, options, print)), replaceEndOfLineWith$2(options.originalText.slice(child.startSourceSpan.end.offset + (child.firstChild && needsToBorrowParentOpeningTagEndMarker(child.firstChild) ? -printOpeningTagEndMarker(child).length : 0), child.endSourceSpan.start.offset + (child.lastChild && needsToBorrowParentClosingTagStartMarker(child.lastChild) ? printClosingTagStartMarker(child, options).length : needsToBorrowLastChildClosingTagEndMarker(child) ? -printClosingTagEndMarker(child.lastChild, options).length : 0)), literalline$6), printClosingTag(child, options), printClosingTagSuffix(child, options)));
|
50030 | }
|
50031 |
|
50032 | return print(childPath);
|
50033 | }
|
50034 |
|
50035 | function printBetweenLine(prevNode, nextNode) {
|
50036 | return isTextLikeNode$1(prevNode) && isTextLikeNode$1(nextNode) ? prevNode.isTrailingSpaceSensitive ? prevNode.hasTrailingSpaces ? preferHardlineAsLeadingSpaces$1(nextNode) ? hardline$c : line$a : "" : preferHardlineAsLeadingSpaces$1(nextNode) ? hardline$c : softline$7 : needsToBorrowNextOpeningTagStartMarker(prevNode) && (hasPrettierIgnore$6(nextNode) ||
|
50037 | |
50038 |
|
50039 |
|
50040 |
|
50041 |
|
50042 | nextNode.firstChild ||
|
50043 | |
50044 |
|
50045 |
|
50046 |
|
50047 |
|
50048 | nextNode.isSelfClosing ||
|
50049 | |
50050 |
|
50051 |
|
50052 |
|
50053 |
|
50054 | nextNode.type === "element" && nextNode.attrs.length !== 0) ||
|
50055 | |
50056 |
|
50057 |
|
50058 |
|
50059 |
|
50060 |
|
50061 | prevNode.type === "element" && prevNode.isSelfClosing && needsToBorrowPrevClosingTagEndMarker(nextNode) ? "" : !nextNode.isLeadingSpaceSensitive || preferHardlineAsLeadingSpaces$1(nextNode) ||
|
50062 | |
50063 |
|
50064 |
|
50065 |
|
50066 |
|
50067 |
|
50068 | needsToBorrowPrevClosingTagEndMarker(nextNode) && prevNode.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild) && prevNode.lastChild.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild.lastChild) ? hardline$c : nextNode.hasLeadingSpaces ? line$a : softline$7;
|
50069 | }
|
50070 | }
|
50071 |
|
50072 | function printOpeningTag(path, options, print) {
|
50073 | const node = path.getValue();
|
50074 | const forceNotToBreakAttrContent = node.type === "element" && node.fullName === "script" && node.attrs.length === 1 && node.attrs[0].fullName === "src" && node.children.length === 0;
|
50075 | return concat$g([printOpeningTagStart(node, options), !node.attrs || node.attrs.length === 0 ? node.isSelfClosing ?
|
50076 | |
50077 |
|
50078 |
|
50079 |
|
50080 | " " : "" : concat$g([indent$9(concat$g([forceNotToBreakAttrContent ? " " : line$a, join$b(line$a, (ignoreAttributeData => {
|
50081 | const hasPrettierIgnoreAttribute = typeof ignoreAttributeData === "boolean" ? () => ignoreAttributeData : Array.isArray(ignoreAttributeData) ? attr => ignoreAttributeData.includes(attr.rawName) : () => false;
|
50082 | return path.map(attrPath => {
|
50083 | const attr = attrPath.getValue();
|
50084 | return hasPrettierIgnoreAttribute(attr) ? concat$g(replaceEndOfLineWith$2(options.originalText.slice(options.locStart(attr), options.locEnd(attr)), literalline$6)) : print(attrPath);
|
50085 | }, "attrs");
|
50086 | })(node.prev && node.prev.type === "comment" && getPrettierIgnoreAttributeCommentData$1(node.prev.value)))])),
|
50087 | |
50088 |
|
50089 |
|
50090 |
|
50091 |
|
50092 |
|
50093 | node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild) ||
|
50094 | |
50095 |
|
50096 |
|
50097 |
|
50098 |
|
50099 |
|
50100 | node.isSelfClosing && needsToBorrowLastChildClosingTagEndMarker(node.parent) ? node.isSelfClosing ? " " : "" : node.isSelfClosing ? forceNotToBreakAttrContent ? " " : line$a : forceNotToBreakAttrContent ? "" : softline$7]), node.isSelfClosing ? "" : printOpeningTagEnd(node)]);
|
50101 | }
|
50102 |
|
50103 | function printOpeningTagStart(node, options) {
|
50104 | return node.prev && needsToBorrowNextOpeningTagStartMarker(node.prev) ? "" : concat$g([printOpeningTagPrefix(node, options), printOpeningTagStartMarker(node)]);
|
50105 | }
|
50106 |
|
50107 | function printOpeningTagEnd(node) {
|
50108 | return node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild) ? "" : printOpeningTagEndMarker(node);
|
50109 | }
|
50110 |
|
50111 | function printClosingTag(node, options) {
|
50112 | return concat$g([node.isSelfClosing ? "" : printClosingTagStart(node, options), printClosingTagEnd(node, options)]);
|
50113 | }
|
50114 |
|
50115 | function printClosingTagStart(node, options) {
|
50116 | return node.lastChild && needsToBorrowParentClosingTagStartMarker(node.lastChild) ? "" : concat$g([printClosingTagPrefix(node, options), printClosingTagStartMarker(node, options)]);
|
50117 | }
|
50118 |
|
50119 | function printClosingTagEnd(node, options) {
|
50120 | return (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? "" : concat$g([printClosingTagEndMarker(node, options), printClosingTagSuffix(node, options)]);
|
50121 | }
|
50122 |
|
50123 | function needsToBorrowNextOpeningTagStartMarker(node) {
|
50124 | |
50125 |
|
50126 |
|
50127 |
|
50128 |
|
50129 | return node.next && !isTextLikeNode$1(node.next) && isTextLikeNode$1(node) && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces;
|
50130 | }
|
50131 |
|
50132 | function needsToBorrowParentOpeningTagEndMarker(node) {
|
50133 | |
50134 |
|
50135 |
|
50136 |
|
50137 |
|
50138 |
|
50139 |
|
50140 |
|
50141 |
|
50142 | return !node.prev && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
|
50143 | }
|
50144 |
|
50145 | function needsToBorrowPrevClosingTagEndMarker(node) {
|
50146 | |
50147 |
|
50148 |
|
50149 |
|
50150 |
|
50151 |
|
50152 |
|
50153 |
|
50154 |
|
50155 | return node.prev && !isTextLikeNode$1(node.prev) && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
|
50156 | }
|
50157 |
|
50158 | function needsToBorrowLastChildClosingTagEndMarker(node) {
|
50159 | |
50160 |
|
50161 |
|
50162 |
|
50163 |
|
50164 |
|
50165 |
|
50166 | return node.lastChild && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces && !isTextLikeNode$1(getLastDescendant$1(node.lastChild));
|
50167 | }
|
50168 |
|
50169 | function needsToBorrowParentClosingTagStartMarker(node) {
|
50170 | |
50171 |
|
50172 |
|
50173 |
|
50174 |
|
50175 |
|
50176 |
|
50177 |
|
50178 |
|
50179 |
|
50180 |
|
50181 | return !node.next && !node.hasTrailingSpaces && node.isTrailingSpaceSensitive && isTextLikeNode$1(getLastDescendant$1(node));
|
50182 | }
|
50183 |
|
50184 | function printOpeningTagPrefix(node, options) {
|
50185 | return needsToBorrowParentOpeningTagEndMarker(node) ? printOpeningTagEndMarker(node.parent) : needsToBorrowPrevClosingTagEndMarker(node) ? printClosingTagEndMarker(node.prev, options) : "";
|
50186 | }
|
50187 |
|
50188 | function printClosingTagPrefix(node, options) {
|
50189 | return needsToBorrowLastChildClosingTagEndMarker(node) ? printClosingTagEndMarker(node.lastChild, options) : "";
|
50190 | }
|
50191 |
|
50192 | function printClosingTagSuffix(node, options) {
|
50193 | return needsToBorrowParentClosingTagStartMarker(node) ? printClosingTagStartMarker(node.parent, options) : needsToBorrowNextOpeningTagStartMarker(node) ? printOpeningTagStartMarker(node.next) : "";
|
50194 | }
|
50195 |
|
50196 | function printOpeningTagStartMarker(node) {
|
50197 | switch (node.type) {
|
50198 | case "ieConditionalComment":
|
50199 | case "ieConditionalStartComment":
|
50200 | return `<!--[if ${node.condition}`;
|
50201 |
|
50202 | case "ieConditionalEndComment":
|
50203 | return "<!--<!";
|
50204 |
|
50205 | case "interpolation":
|
50206 | return "{{";
|
50207 |
|
50208 | case "docType":
|
50209 | return "<!DOCTYPE";
|
50210 |
|
50211 | case "element":
|
50212 | if (node.condition) {
|
50213 | return `<!--[if ${node.condition}]><!--><${node.rawName}`;
|
50214 | }
|
50215 |
|
50216 |
|
50217 |
|
50218 | default:
|
50219 | return `<${node.rawName}`;
|
50220 | }
|
50221 | }
|
50222 |
|
50223 | function printOpeningTagEndMarker(node) {
|
50224 | assert$1(!node.isSelfClosing);
|
50225 |
|
50226 | switch (node.type) {
|
50227 | case "ieConditionalComment":
|
50228 | return "]>";
|
50229 |
|
50230 | case "element":
|
50231 | if (node.condition) {
|
50232 | return "><!--<![endif]-->";
|
50233 | }
|
50234 |
|
50235 |
|
50236 |
|
50237 | default:
|
50238 | return ">";
|
50239 | }
|
50240 | }
|
50241 |
|
50242 | function printClosingTagStartMarker(node, options) {
|
50243 | assert$1(!node.isSelfClosing);
|
50244 |
|
50245 | if (shouldNotPrintClosingTag$1(node, options)) {
|
50246 | return "";
|
50247 | }
|
50248 |
|
50249 | switch (node.type) {
|
50250 | case "ieConditionalComment":
|
50251 | return "<!";
|
50252 |
|
50253 | case "element":
|
50254 | if (node.hasHtmComponentClosingTag) {
|
50255 | return "<//";
|
50256 | }
|
50257 |
|
50258 |
|
50259 |
|
50260 | default:
|
50261 | return `</${node.rawName}`;
|
50262 | }
|
50263 | }
|
50264 |
|
50265 | function printClosingTagEndMarker(node, options) {
|
50266 | if (shouldNotPrintClosingTag$1(node, options)) {
|
50267 | return "";
|
50268 | }
|
50269 |
|
50270 | switch (node.type) {
|
50271 | case "ieConditionalComment":
|
50272 | case "ieConditionalEndComment":
|
50273 | return "[endif]-->";
|
50274 |
|
50275 | case "ieConditionalStartComment":
|
50276 | return "]><!-->";
|
50277 |
|
50278 | case "interpolation":
|
50279 | return "}}";
|
50280 |
|
50281 | case "element":
|
50282 | if (node.isSelfClosing) {
|
50283 | return "/>";
|
50284 | }
|
50285 |
|
50286 |
|
50287 |
|
50288 | default:
|
50289 | return ">";
|
50290 | }
|
50291 | }
|
50292 |
|
50293 | function getTextValueParts(node, value = node.value) {
|
50294 | return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceEndOfLineWith$2(value, literalline$6) : replaceEndOfLineWith$2(dedentString$1(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$c) :
|
50295 | join$b(line$a, value.split(/[\t\n\f\r ]+/)).parts;
|
50296 | }
|
50297 |
|
50298 | function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
|
50299 | const isKeyMatched = patterns => new RegExp(patterns.join("|")).test(node.fullName);
|
50300 |
|
50301 | const getValue = () => unescapeQuoteEntities$1(node.value);
|
50302 |
|
50303 | let shouldHug = false;
|
50304 |
|
50305 | const __onHtmlBindingRoot = (root, options) => {
|
50306 | const rootNode = root.type === "NGRoot" ? root.node.type === "NGMicrosyntax" && root.node.body.length === 1 && root.node.body[0].type === "NGMicrosyntaxExpression" ? root.node.body[0].expression : root.node : root.type === "JsExpressionRoot" ? root.node : root;
|
50307 |
|
50308 | if (rootNode && (rootNode.type === "ObjectExpression" || rootNode.type === "ArrayExpression" || options.parser === "__vue_expression" && (rootNode.type === "TemplateLiteral" || rootNode.type === "StringLiteral"))) {
|
50309 | shouldHug = true;
|
50310 | }
|
50311 | };
|
50312 |
|
50313 | const printHug = doc => group$f(doc);
|
50314 |
|
50315 | const printExpand = (doc, canHaveTrailingWhitespace = true) => group$f(concat$g([indent$9(concat$g([softline$7, doc])), canHaveTrailingWhitespace ? softline$7 : ""]));
|
50316 |
|
50317 | const printMaybeHug = doc => shouldHug ? printHug(doc) : printExpand(doc);
|
50318 |
|
50319 | const textToDoc = (code, opts) => originalTextToDoc(code, Object.assign({
|
50320 | __onHtmlBindingRoot
|
50321 | }, opts));
|
50322 |
|
50323 | if (node.fullName === "srcset" && (node.parent.fullName === "img" || node.parent.fullName === "source")) {
|
50324 | return printExpand(printImgSrcset$1(getValue()));
|
50325 | }
|
50326 |
|
50327 | if (node.fullName === "class" && !options.parentParser) {
|
50328 | const value = getValue();
|
50329 |
|
50330 | if (!value.includes("{{")) {
|
50331 | return printClassNames$1(value);
|
50332 | }
|
50333 | }
|
50334 |
|
50335 | if (node.fullName === "style" && !options.parentParser) {
|
50336 | const value = getValue();
|
50337 |
|
50338 | if (!value.includes("{{")) {
|
50339 | return printExpand(textToDoc(value, {
|
50340 | parser: "css",
|
50341 | __isHTMLStyleAttribute: true
|
50342 | }));
|
50343 | }
|
50344 | }
|
50345 |
|
50346 | if (options.parser === "vue") {
|
50347 | if (node.fullName === "v-for") {
|
50348 | return printVueFor$1(getValue(), textToDoc);
|
50349 | }
|
50350 |
|
50351 | if (node.fullName === "slot-scope") {
|
50352 | return printVueSlotScope$1(getValue(), textToDoc);
|
50353 | }
|
50354 | |
50355 |
|
50356 |
|
50357 |
|
50358 |
|
50359 |
|
50360 |
|
50361 |
|
50362 | const vueEventBindingPatterns = ["^@", "^v-on:"];
|
50363 | |
50364 |
|
50365 |
|
50366 |
|
50367 |
|
50368 | const vueExpressionBindingPatterns = ["^:", "^v-bind:"];
|
50369 | |
50370 |
|
50371 |
|
50372 |
|
50373 | const jsExpressionBindingPatterns = ["^v-"];
|
50374 |
|
50375 | if (isKeyMatched(vueEventBindingPatterns)) {
|
50376 | const value = getValue();
|
50377 | return printMaybeHug(isVueEventBindingExpression$3(value) ? textToDoc(value, {
|
50378 | parser: "__js_expression"
|
50379 | }) : stripTrailingHardline$2(textToDoc(value, {
|
50380 | parser: "__vue_event_binding"
|
50381 | })));
|
50382 | }
|
50383 |
|
50384 | if (isKeyMatched(vueExpressionBindingPatterns)) {
|
50385 | return printMaybeHug(textToDoc(getValue(), {
|
50386 | parser: "__vue_expression"
|
50387 | }));
|
50388 | }
|
50389 |
|
50390 | if (isKeyMatched(jsExpressionBindingPatterns)) {
|
50391 | return printMaybeHug(textToDoc(getValue(), {
|
50392 | parser: "__js_expression"
|
50393 | }));
|
50394 | }
|
50395 | }
|
50396 |
|
50397 | if (options.parser === "angular") {
|
50398 | const ngTextToDoc = (code, opts) =>
|
50399 | textToDoc(code, Object.assign({}, opts, {
|
50400 | trailingComma: "none"
|
50401 | }));
|
50402 | |
50403 |
|
50404 |
|
50405 |
|
50406 |
|
50407 | const ngDirectiveBindingPatterns = ["^\\*"];
|
50408 | |
50409 |
|
50410 |
|
50411 |
|
50412 |
|
50413 | const ngStatementBindingPatterns = ["^\\(.+\\)$", "^on-"];
|
50414 | |
50415 |
|
50416 |
|
50417 |
|
50418 |
|
50419 |
|
50420 |
|
50421 | const ngExpressionBindingPatterns = ["^\\[.+\\]$", "^bind(on)?-",
|
50422 | "^ng-(if|show|hide|class|style)$"];
|
50423 | |
50424 |
|
50425 |
|
50426 |
|
50427 |
|
50428 | const ngI18nPatterns = ["^i18n(-.+)?$"];
|
50429 |
|
50430 | if (isKeyMatched(ngStatementBindingPatterns)) {
|
50431 | return printMaybeHug(ngTextToDoc(getValue(), {
|
50432 | parser: "__ng_action"
|
50433 | }));
|
50434 | }
|
50435 |
|
50436 | if (isKeyMatched(ngExpressionBindingPatterns)) {
|
50437 | return printMaybeHug(ngTextToDoc(getValue(), {
|
50438 | parser: "__ng_binding"
|
50439 | }));
|
50440 | }
|
50441 |
|
50442 | if (isKeyMatched(ngI18nPatterns)) {
|
50443 | const value = getValue().trim();
|
50444 | return printExpand(fill$6(getTextValueParts(node, value)), !value.includes("@@"));
|
50445 | }
|
50446 |
|
50447 | if (isKeyMatched(ngDirectiveBindingPatterns)) {
|
50448 | return printMaybeHug(ngTextToDoc(getValue(), {
|
50449 | parser: "__ng_directive"
|
50450 | }));
|
50451 | }
|
50452 |
|
50453 | const interpolationRegex = /\{\{([\s\S]+?)\}\}/g;
|
50454 | const value = getValue();
|
50455 |
|
50456 | if (interpolationRegex.test(value)) {
|
50457 | const parts = [];
|
50458 | value.split(interpolationRegex).forEach((part, index) => {
|
50459 | if (index % 2 === 0) {
|
50460 | parts.push(concat$g(replaceEndOfLineWith$2(part, literalline$6)));
|
50461 | } else {
|
50462 | try {
|
50463 | parts.push(group$f(concat$g(["{{", indent$9(concat$g([line$a, ngTextToDoc(part, {
|
50464 | parser: "__ng_interpolation",
|
50465 | __isInHtmlInterpolation: true
|
50466 |
|
50467 | })])), line$a, "}}"])));
|
50468 | } catch (e) {
|
50469 | parts.push("{{", concat$g(replaceEndOfLineWith$2(part, literalline$6)), "}}");
|
50470 | }
|
50471 | }
|
50472 | });
|
50473 | return group$f(concat$g(parts));
|
50474 | }
|
50475 | }
|
50476 |
|
50477 | return null;
|
50478 | }
|
50479 |
|
50480 | var printerHtml = {
|
50481 | preprocess: preprocess_1$2,
|
50482 | print: genericPrint$5,
|
50483 | insertPragma: insertPragma$7,
|
50484 | massageAstNode: clean$6,
|
50485 | embed: embed$4
|
50486 | };
|
50487 |
|
50488 | const CATEGORY_HTML = "HTML";
|
50489 |
|
50490 | var options$6 = {
|
50491 | htmlWhitespaceSensitivity: {
|
50492 | since: "1.15.0",
|
50493 | category: CATEGORY_HTML,
|
50494 | type: "choice",
|
50495 | default: "css",
|
50496 | description: "How to handle whitespaces in HTML.",
|
50497 | choices: [{
|
50498 | value: "css",
|
50499 | description: "Respect the default value of CSS display property."
|
50500 | }, {
|
50501 | value: "strict",
|
50502 | description: "Whitespaces are considered sensitive."
|
50503 | }, {
|
50504 | value: "ignore",
|
50505 | description: "Whitespaces are considered insensitive."
|
50506 | }]
|
50507 | },
|
50508 | vueIndentScriptAndStyle: {
|
50509 | since: "1.19.0",
|
50510 | category: CATEGORY_HTML,
|
50511 | type: "boolean",
|
50512 | default: false,
|
50513 | description: "Indent script and style tags in Vue files."
|
50514 | }
|
50515 | };
|
50516 |
|
50517 | var name$g = "HTML";
|
50518 | var type$e = "markup";
|
50519 | var tmScope$e = "text.html.basic";
|
50520 | var aceMode$e = "html";
|
50521 | var codemirrorMode$b = "htmlmixed";
|
50522 | var codemirrorMimeType$b = "text/html";
|
50523 | var color$3 = "#e34c26";
|
50524 | var aliases$5 = [
|
50525 | "xhtml"
|
50526 | ];
|
50527 | var extensions$e = [
|
50528 | ".html",
|
50529 | ".htm",
|
50530 | ".html.hl",
|
50531 | ".inc",
|
50532 | ".st",
|
50533 | ".xht",
|
50534 | ".xhtml"
|
50535 | ];
|
50536 | var languageId$e = 146;
|
50537 | var HTML = {
|
50538 | name: name$g,
|
50539 | type: type$e,
|
50540 | tmScope: tmScope$e,
|
50541 | aceMode: aceMode$e,
|
50542 | codemirrorMode: codemirrorMode$b,
|
50543 | codemirrorMimeType: codemirrorMimeType$b,
|
50544 | color: color$3,
|
50545 | aliases: aliases$5,
|
50546 | extensions: extensions$e,
|
50547 | languageId: languageId$e
|
50548 | };
|
50549 |
|
50550 | var HTML$1 = Object.freeze({
|
50551 | __proto__: null,
|
50552 | name: name$g,
|
50553 | type: type$e,
|
50554 | tmScope: tmScope$e,
|
50555 | aceMode: aceMode$e,
|
50556 | codemirrorMode: codemirrorMode$b,
|
50557 | codemirrorMimeType: codemirrorMimeType$b,
|
50558 | color: color$3,
|
50559 | aliases: aliases$5,
|
50560 | extensions: extensions$e,
|
50561 | languageId: languageId$e,
|
50562 | 'default': HTML
|
50563 | });
|
50564 |
|
50565 | var name$h = "Vue";
|
50566 | var type$f = "markup";
|
50567 | var color$4 = "#2c3e50";
|
50568 | var extensions$f = [
|
50569 | ".vue"
|
50570 | ];
|
50571 | var tmScope$f = "text.html.vue";
|
50572 | var aceMode$f = "html";
|
50573 | var languageId$f = 391;
|
50574 | var Vue = {
|
50575 | name: name$h,
|
50576 | type: type$f,
|
50577 | color: color$4,
|
50578 | extensions: extensions$f,
|
50579 | tmScope: tmScope$f,
|
50580 | aceMode: aceMode$f,
|
50581 | languageId: languageId$f
|
50582 | };
|
50583 |
|
50584 | var Vue$1 = Object.freeze({
|
50585 | __proto__: null,
|
50586 | name: name$h,
|
50587 | type: type$f,
|
50588 | color: color$4,
|
50589 | extensions: extensions$f,
|
50590 | tmScope: tmScope$f,
|
50591 | aceMode: aceMode$f,
|
50592 | languageId: languageId$f,
|
50593 | 'default': Vue
|
50594 | });
|
50595 |
|
50596 | var require$$0$6 = getCjsExportFromNamespace(HTML$1);
|
50597 |
|
50598 | var require$$1$3 = getCjsExportFromNamespace(Vue$1);
|
50599 |
|
50600 | const languages$5 = [createLanguage(require$$0$6, () => ({
|
50601 | name: "Angular",
|
50602 | since: "1.15.0",
|
50603 | parsers: ["angular"],
|
50604 | vscodeLanguageIds: ["html"],
|
50605 | extensions: [".component.html"],
|
50606 | filenames: []
|
50607 | })), createLanguage(require$$0$6, data => ({
|
50608 | since: "1.15.0",
|
50609 | parsers: ["html"],
|
50610 | vscodeLanguageIds: ["html"],
|
50611 | extensions: data.extensions.concat([".mjml"
|
50612 | ])
|
50613 | })), createLanguage(require$$0$6, () => ({
|
50614 | name: "Lightning Web Components",
|
50615 | since: "1.17.0",
|
50616 | parsers: ["lwc"],
|
50617 | vscodeLanguageIds: ["html"],
|
50618 | extensions: [],
|
50619 | filenames: []
|
50620 | })), createLanguage(require$$1$3, () => ({
|
50621 | since: "1.10.0",
|
50622 | parsers: ["vue"],
|
50623 | vscodeLanguageIds: ["vue"]
|
50624 | }))];
|
50625 | const printers$5 = {
|
50626 | html: printerHtml
|
50627 | };
|
50628 | var languageHtml = {
|
50629 | languages: languages$5,
|
50630 | printers: printers$5,
|
50631 | options: options$6
|
50632 | };
|
50633 |
|
50634 | function isPragma(text) {
|
50635 | return /^\s*@(prettier|format)\s*$/.test(text);
|
50636 | }
|
50637 |
|
50638 | function hasPragma$4(text) {
|
50639 | return /^\s*#[^\n\S]*@(prettier|format)\s*?(\n|$)/.test(text);
|
50640 | }
|
50641 |
|
50642 | function insertPragma$8(text) {
|
50643 | return `# @format\n\n${text}`;
|
50644 | }
|
50645 |
|
50646 | var pragma$5 = {
|
50647 | isPragma,
|
50648 | hasPragma: hasPragma$4,
|
50649 | insertPragma: insertPragma$8
|
50650 | };
|
50651 |
|
50652 | const {
|
50653 | getLast: getLast$5
|
50654 | } = util$1;
|
50655 |
|
50656 | function getAncestorCount(path, filter) {
|
50657 | let counter = 0;
|
50658 | const pathStackLength = path.stack.length - 1;
|
50659 |
|
50660 | for (let i = 0; i < pathStackLength; i++) {
|
50661 | const value = path.stack[i];
|
50662 |
|
50663 | if (isNode(value) && filter(value)) {
|
50664 | counter++;
|
50665 | }
|
50666 | }
|
50667 |
|
50668 | return counter;
|
50669 | }
|
50670 |
|
50671 |
|
50672 |
|
50673 |
|
50674 |
|
50675 |
|
50676 | function isNode(value, types) {
|
50677 | return value && typeof value.type === "string" && (!types || types.includes(value.type));
|
50678 | }
|
50679 |
|
50680 | function mapNode(node, callback, parent) {
|
50681 | return callback("children" in node ? Object.assign({}, node, {
|
50682 | children: node.children.map(childNode => mapNode(childNode, callback, node))
|
50683 | }) : node, parent);
|
50684 | }
|
50685 |
|
50686 | function defineShortcut(x, key, getter) {
|
50687 | Object.defineProperty(x, key, {
|
50688 | get: getter,
|
50689 | enumerable: false
|
50690 | });
|
50691 | }
|
50692 |
|
50693 | function isNextLineEmpty$5(node, text) {
|
50694 | let newlineCount = 0;
|
50695 | const textLength = text.length;
|
50696 |
|
50697 | for (let i = node.position.end.offset - 1; i < textLength; i++) {
|
50698 | const char = text[i];
|
50699 |
|
50700 | if (char === "\n") {
|
50701 | newlineCount++;
|
50702 | }
|
50703 |
|
50704 | if (newlineCount === 1 && /\S/.test(char)) {
|
50705 | return false;
|
50706 | }
|
50707 |
|
50708 | if (newlineCount === 2) {
|
50709 | return true;
|
50710 | }
|
50711 | }
|
50712 |
|
50713 | return false;
|
50714 | }
|
50715 |
|
50716 | function isLastDescendantNode(path) {
|
50717 | const node = path.getValue();
|
50718 |
|
50719 | switch (node.type) {
|
50720 | case "tag":
|
50721 | case "anchor":
|
50722 | case "comment":
|
50723 | return false;
|
50724 | }
|
50725 |
|
50726 | const pathStackLength = path.stack.length;
|
50727 |
|
50728 | for (let i = 1; i < pathStackLength; i++) {
|
50729 | const item = path.stack[i];
|
50730 | const parentItem = path.stack[i - 1];
|
50731 |
|
50732 | if (Array.isArray(parentItem) && typeof item === "number" && item !== parentItem.length - 1) {
|
50733 | return false;
|
50734 | }
|
50735 | }
|
50736 |
|
50737 | return true;
|
50738 | }
|
50739 |
|
50740 | function getLastDescendantNode$1(node) {
|
50741 | return "children" in node && node.children.length !== 0 ? getLastDescendantNode$1(getLast$5(node.children)) : node;
|
50742 | }
|
50743 |
|
50744 | function isPrettierIgnore$2(comment) {
|
50745 | return comment.value.trim() === "prettier-ignore";
|
50746 | }
|
50747 |
|
50748 | function hasPrettierIgnore$7(path) {
|
50749 | const node = path.getValue();
|
50750 |
|
50751 | if (node.type === "documentBody") {
|
50752 | const document = path.getParentNode();
|
50753 | return hasEndComments(document.head) && isPrettierIgnore$2(getLast$5(document.head.endComments));
|
50754 | }
|
50755 |
|
50756 | return hasLeadingComments(node) && isPrettierIgnore$2(getLast$5(node.leadingComments));
|
50757 | }
|
50758 |
|
50759 | function isEmptyNode(node) {
|
50760 | return (!node.children || node.children.length === 0) && !hasComments(node);
|
50761 | }
|
50762 |
|
50763 | function hasComments(node) {
|
50764 | return hasLeadingComments(node) || hasMiddleComments(node) || hasIndicatorComment(node) || hasTrailingComment$2(node) || hasEndComments(node);
|
50765 | }
|
50766 |
|
50767 | function hasLeadingComments(node) {
|
50768 | return node && node.leadingComments && node.leadingComments.length !== 0;
|
50769 | }
|
50770 |
|
50771 | function hasMiddleComments(node) {
|
50772 | return node && node.middleComments && node.middleComments.length !== 0;
|
50773 | }
|
50774 |
|
50775 | function hasIndicatorComment(node) {
|
50776 | return node && node.indicatorComment;
|
50777 | }
|
50778 |
|
50779 | function hasTrailingComment$2(node) {
|
50780 | return node && node.trailingComment;
|
50781 | }
|
50782 |
|
50783 | function hasEndComments(node) {
|
50784 | return node && node.endComments && node.endComments.length !== 0;
|
50785 | }
|
50786 |
|
50787 |
|
50788 |
|
50789 |
|
50790 |
|
50791 | function splitWithSingleSpace(text) {
|
50792 | const parts = [];
|
50793 | let lastPart = undefined;
|
50794 |
|
50795 | for (const part of text.split(/( +)/g)) {
|
50796 | if (part !== " ") {
|
50797 | if (lastPart === " ") {
|
50798 | parts.push(part);
|
50799 | } else {
|
50800 | parts.push((parts.pop() || "") + part);
|
50801 | }
|
50802 | } else if (lastPart === undefined) {
|
50803 | parts.unshift("");
|
50804 | }
|
50805 |
|
50806 | lastPart = part;
|
50807 | }
|
50808 |
|
50809 | if (lastPart === " ") {
|
50810 | parts.push((parts.pop() || "") + " ");
|
50811 | }
|
50812 |
|
50813 | if (parts[0] === "") {
|
50814 | parts.shift();
|
50815 | parts.unshift(" " + (parts.shift() || ""));
|
50816 | }
|
50817 |
|
50818 | return parts;
|
50819 | }
|
50820 |
|
50821 | function getFlowScalarLineContents(nodeType, content, options) {
|
50822 | const rawLineContents = content.split("\n").map((lineContent, index, lineContents) => index === 0 && index === lineContents.length - 1 ? lineContent : index !== 0 && index !== lineContents.length - 1 ? lineContent.trim() : index === 0 ? lineContent.trimEnd() : lineContent.trimStart());
|
50823 |
|
50824 | if (options.proseWrap === "preserve") {
|
50825 | return rawLineContents.map(lineContent => lineContent.length === 0 ? [] : [lineContent]);
|
50826 | }
|
50827 |
|
50828 | return rawLineContents.map(lineContent => lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent)).reduce((reduced, lineContentWords, index) => index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !(
|
50829 | nodeType === "quoteDouble" && getLast$5(getLast$5(reduced)).endsWith("\\")) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]), []).map(lineContentWords => options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords);
|
50830 | }
|
50831 |
|
50832 | function getBlockValueLineContents(node, {
|
50833 | parentIndent,
|
50834 | isLastDescendant,
|
50835 | options
|
50836 | }) {
|
50837 | const content = node.position.start.line === node.position.end.line ? "" : options.originalText.slice(node.position.start.offset, node.position.end.offset)
|
50838 | .match(/^[^\n]*?\n([\s\S]*)$/)[1];
|
50839 | const leadingSpaceCount = node.indent === null ? (match => match ? match[1].length : Infinity)(content.match(/^( *)\S/m)) : node.indent - 1 + parentIndent;
|
50840 | const rawLineContents = content.split("\n").map(lineContent => lineContent.slice(leadingSpaceCount));
|
50841 |
|
50842 | if (options.proseWrap === "preserve" || node.type === "blockLiteral") {
|
50843 | return removeUnnecessaryTrailingNewlines(rawLineContents.map(lineContent => lineContent.length === 0 ? [] : [lineContent]));
|
50844 | }
|
50845 |
|
50846 | return removeUnnecessaryTrailingNewlines(rawLineContents.map(lineContent => lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent)).reduce((reduced, lineContentWords, index) => index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$5(reduced)) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]), []).map(lineContentWords => lineContentWords.reduce((reduced, word) =>
|
50847 | reduced.length !== 0 && /\s$/.test(getLast$5(reduced)) ? reduced.concat(reduced.pop() + " " + word) : reduced.concat(word), [])).map(lineContentWords => options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords));
|
50848 |
|
50849 | function removeUnnecessaryTrailingNewlines(lineContents) {
|
50850 | if (node.chomping === "keep") {
|
50851 | return getLast$5(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents;
|
50852 | }
|
50853 |
|
50854 | let trailingNewlineCount = 0;
|
50855 |
|
50856 | for (let i = lineContents.length - 1; i >= 0; i--) {
|
50857 | if (lineContents[i].length === 0) {
|
50858 | trailingNewlineCount++;
|
50859 | } else {
|
50860 | break;
|
50861 | }
|
50862 | }
|
50863 |
|
50864 | return trailingNewlineCount === 0 ? lineContents : trailingNewlineCount >= 2 && !isLastDescendant ?
|
50865 | lineContents.slice(0, -(trailingNewlineCount - 1)) : lineContents.slice(0, -trailingNewlineCount);
|
50866 | }
|
50867 | }
|
50868 |
|
50869 | var utils$b = {
|
50870 | getLast: getLast$5,
|
50871 | getAncestorCount,
|
50872 | isNode,
|
50873 | isEmptyNode,
|
50874 | mapNode,
|
50875 | defineShortcut,
|
50876 | isNextLineEmpty: isNextLineEmpty$5,
|
50877 | isLastDescendantNode,
|
50878 | getBlockValueLineContents,
|
50879 | getFlowScalarLineContents,
|
50880 | getLastDescendantNode: getLastDescendantNode$1,
|
50881 | hasPrettierIgnore: hasPrettierIgnore$7,
|
50882 | hasLeadingComments,
|
50883 | hasMiddleComments,
|
50884 | hasIndicatorComment,
|
50885 | hasTrailingComment: hasTrailingComment$2,
|
50886 | hasEndComments
|
50887 | };
|
50888 |
|
50889 | const {
|
50890 | insertPragma: insertPragma$9,
|
50891 | isPragma: isPragma$1
|
50892 | } = pragma$5;
|
50893 | const {
|
50894 | getAncestorCount: getAncestorCount$1,
|
50895 | getBlockValueLineContents: getBlockValueLineContents$1,
|
50896 | getFlowScalarLineContents: getFlowScalarLineContents$1,
|
50897 | getLast: getLast$6,
|
50898 | getLastDescendantNode: getLastDescendantNode$2,
|
50899 | hasLeadingComments: hasLeadingComments$1,
|
50900 | hasMiddleComments: hasMiddleComments$1,
|
50901 | hasIndicatorComment: hasIndicatorComment$1,
|
50902 | hasTrailingComment: hasTrailingComment$3,
|
50903 | hasEndComments: hasEndComments$1,
|
50904 | hasPrettierIgnore: hasPrettierIgnore$8,
|
50905 | isLastDescendantNode: isLastDescendantNode$1,
|
50906 | isNextLineEmpty: isNextLineEmpty$6,
|
50907 | isNode: isNode$1,
|
50908 | isEmptyNode: isEmptyNode$1,
|
50909 | defineShortcut: defineShortcut$1,
|
50910 | mapNode: mapNode$1
|
50911 | } = utils$b;
|
50912 | const docBuilders$2 = document.builders;
|
50913 | const {
|
50914 | conditionalGroup: conditionalGroup$2,
|
50915 | breakParent: breakParent$5,
|
50916 | concat: concat$h,
|
50917 | dedent: dedent$3,
|
50918 | dedentToRoot: dedentToRoot$3,
|
50919 | fill: fill$7,
|
50920 | group: group$g,
|
50921 | hardline: hardline$d,
|
50922 | ifBreak: ifBreak$8,
|
50923 | join: join$c,
|
50924 | line: line$b,
|
50925 | lineSuffix: lineSuffix$2,
|
50926 | literalline: literalline$7,
|
50927 | markAsRoot: markAsRoot$5,
|
50928 | softline: softline$8
|
50929 | } = docBuilders$2;
|
50930 | const {
|
50931 | replaceEndOfLineWith: replaceEndOfLineWith$3
|
50932 | } = util$1;
|
50933 |
|
50934 | function preprocess$3(ast) {
|
50935 | return mapNode$1(ast, defineShortcuts);
|
50936 | }
|
50937 |
|
50938 | function defineShortcuts(node) {
|
50939 | switch (node.type) {
|
50940 | case "document":
|
50941 | defineShortcut$1(node, "head", () => node.children[0]);
|
50942 | defineShortcut$1(node, "body", () => node.children[1]);
|
50943 | break;
|
50944 |
|
50945 | case "documentBody":
|
50946 | case "sequenceItem":
|
50947 | case "flowSequenceItem":
|
50948 | case "mappingKey":
|
50949 | case "mappingValue":
|
50950 | defineShortcut$1(node, "content", () => node.children[0]);
|
50951 | break;
|
50952 |
|
50953 | case "mappingItem":
|
50954 | case "flowMappingItem":
|
50955 | defineShortcut$1(node, "key", () => node.children[0]);
|
50956 | defineShortcut$1(node, "value", () => node.children[1]);
|
50957 | break;
|
50958 | }
|
50959 |
|
50960 | return node;
|
50961 | }
|
50962 |
|
50963 | function genericPrint$6(path, options, print) {
|
50964 | const node = path.getValue();
|
50965 | const parentNode = path.getParentNode();
|
50966 | const tag = !node.tag ? "" : path.call(print, "tag");
|
50967 | const anchor = !node.anchor ? "" : path.call(print, "anchor");
|
50968 | const nextEmptyLine = isNode$1(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode$1(path) ? printNextEmptyLine(path, options.originalText) : "";
|
50969 | return concat$h([node.type !== "mappingValue" && hasLeadingComments$1(node) ? concat$h([join$c(hardline$d, path.map(print, "leadingComments")), hardline$d]) : "", tag, tag && anchor ? " " : "", anchor, tag || anchor ? isNode$1(node, ["sequence", "mapping"]) && !hasMiddleComments$1(node) ? hardline$d : " " : "", hasMiddleComments$1(node) ? concat$h([node.middleComments.length === 1 ? "" : hardline$d, join$c(hardline$d, path.map(print, "middleComments")), hardline$d]) : "", hasPrettierIgnore$8(path) ? concat$h(replaceEndOfLineWith$3(options.originalText.slice(node.position.start.offset, node.position.end.offset), literalline$7)) : group$g(_print(node, parentNode, path, options, print)), hasTrailingComment$3(node) && !isNode$1(node, ["document", "documentHead"]) ? lineSuffix$2(concat$h([node.type === "mappingValue" && !node.content ? "" : " ", parentNode.type === "mappingKey" && path.getParentNode(2).type === "mapping" && isInlineNode(node) ? "" : breakParent$5, path.call(print, "trailingComment")])) : "", nextEmptyLine, hasEndComments$1(node) && !isNode$1(node, ["documentHead", "documentBody"]) ? align$3(node.type === "sequenceItem" ? 2 : 0, concat$h([hardline$d, join$c(hardline$d, path.map(print, "endComments"))])) : ""]);
|
50970 | }
|
50971 |
|
50972 | function _print(node, parentNode, path, options, print) {
|
50973 | switch (node.type) {
|
50974 | case "root":
|
50975 | return concat$h([join$c(hardline$d, path.map((childPath, index) => {
|
50976 | const document = node.children[index];
|
50977 | const nextDocument = node.children[index + 1];
|
50978 | return concat$h([print(childPath), shouldPrintDocumentEndMarker(document, nextDocument) ? concat$h([hardline$d, "...", hasTrailingComment$3(document) ? concat$h([" ", path.call(print, "trailingComment")]) : ""]) : !nextDocument || hasTrailingComment$3(nextDocument.head) ? "" : concat$h([hardline$d, "---"])]);
|
50979 | }, "children")), node.children.length === 0 || (lastDescendantNode => isNode$1(lastDescendantNode, ["blockLiteral", "blockFolded"]) && lastDescendantNode.chomping === "keep")(getLastDescendantNode$2(node)) ? "" : hardline$d]);
|
50980 |
|
50981 | case "document":
|
50982 | {
|
50983 | const nextDocument = parentNode.children[path.getName() + 1];
|
50984 | return join$c(hardline$d, [shouldPrintDocumentHeadEndMarker(node, nextDocument, parentNode, options) === "head" ? join$c(hardline$d, [node.head.children.length === 0 && node.head.endComments.length === 0 ? "" : path.call(print, "head"), concat$h(["---", hasTrailingComment$3(node.head) ? concat$h([" ", path.call(print, "head", "trailingComment")]) : ""])].filter(Boolean)) : "", shouldPrintDocumentBody(node) ? path.call(print, "body") : ""].filter(Boolean));
|
50985 | }
|
50986 |
|
50987 | case "documentHead":
|
50988 | return join$c(hardline$d, [].concat(path.map(print, "children"), path.map(print, "endComments")));
|
50989 |
|
50990 | case "documentBody":
|
50991 | {
|
50992 | const children = join$c(hardline$d, path.map(print, "children")).parts;
|
50993 | const endComments = join$c(hardline$d, path.map(print, "endComments")).parts;
|
50994 | const separator = children.length === 0 || endComments.length === 0 ? "" : (lastDescendantNode => isNode$1(lastDescendantNode, ["blockFolded", "blockLiteral"]) ? lastDescendantNode.chomping === "keep" ?
|
50995 | "" :
|
50996 | concat$h([hardline$d, hardline$d]) : hardline$d)(getLastDescendantNode$2(node));
|
50997 | return concat$h([].concat(children, separator, endComments));
|
50998 | }
|
50999 |
|
51000 | case "directive":
|
51001 | return concat$h(["%", join$c(" ", [node.name].concat(node.parameters))]);
|
51002 |
|
51003 | case "comment":
|
51004 | return concat$h(["#", node.value]);
|
51005 |
|
51006 | case "alias":
|
51007 | return concat$h(["*", node.value]);
|
51008 |
|
51009 | case "tag":
|
51010 | return options.originalText.slice(node.position.start.offset, node.position.end.offset);
|
51011 |
|
51012 | case "anchor":
|
51013 | return concat$h(["&", node.value]);
|
51014 |
|
51015 | case "plain":
|
51016 | return printFlowScalarContent(node.type, options.originalText.slice(node.position.start.offset, node.position.end.offset), options);
|
51017 |
|
51018 | case "quoteDouble":
|
51019 | case "quoteSingle":
|
51020 | {
|
51021 | const singleQuote = "'";
|
51022 | const doubleQuote = '"';
|
51023 | const raw = options.originalText.slice(node.position.start.offset + 1, node.position.end.offset - 1);
|
51024 |
|
51025 | if (node.type === "quoteSingle" && raw.includes("\\") || node.type === "quoteDouble" && /\\[^"]/.test(raw)) {
|
51026 |
|
51027 |
|
51028 | const originalQuote = node.type === "quoteDouble" ? doubleQuote : singleQuote;
|
51029 | return concat$h([originalQuote, printFlowScalarContent(node.type, raw, options), originalQuote]);
|
51030 | } else if (raw.includes(doubleQuote)) {
|
51031 | return concat$h([singleQuote, printFlowScalarContent(node.type, node.type === "quoteDouble" ? raw
|
51032 | .replace(/\\"/g, doubleQuote).replace(/'/g, singleQuote.repeat(2)) : raw, options), singleQuote]);
|
51033 | }
|
51034 |
|
51035 | if (raw.includes(singleQuote)) {
|
51036 | return concat$h([doubleQuote, printFlowScalarContent(node.type, node.type === "quoteSingle" ?
|
51037 | raw.replace(/''/g, singleQuote) : raw, options), doubleQuote]);
|
51038 | }
|
51039 |
|
51040 | const quote = options.singleQuote ? singleQuote : doubleQuote;
|
51041 | return concat$h([quote, printFlowScalarContent(node.type, raw, options), quote]);
|
51042 | }
|
51043 |
|
51044 | case "blockFolded":
|
51045 | case "blockLiteral":
|
51046 | {
|
51047 | const parentIndent = getAncestorCount$1(path, ancestorNode => isNode$1(ancestorNode, ["sequence", "mapping"]));
|
51048 | const isLastDescendant = isLastDescendantNode$1(path);
|
51049 | return concat$h([node.type === "blockFolded" ? ">" : "|", node.indent === null ? "" : node.indent.toString(), node.chomping === "clip" ? "" : node.chomping === "keep" ? "+" : "-", hasIndicatorComment$1(node) ? concat$h([" ", path.call(print, "indicatorComment")]) : "", (node.indent === null ? dedent$3 : dedentToRoot$3)(align$3(node.indent === null ? options.tabWidth : node.indent - 1 + parentIndent, concat$h(getBlockValueLineContents$1(node, {
|
51050 | parentIndent,
|
51051 | isLastDescendant,
|
51052 | options
|
51053 | }).reduce((reduced, lineWords, index, lineContents) => reduced.concat(index === 0 ? hardline$d : "", fill$7(join$c(line$b, lineWords).parts), index !== lineContents.length - 1 ? lineWords.length === 0 ? hardline$d : markAsRoot$5(literalline$7) : node.chomping === "keep" && isLastDescendant ? lineWords.length === 0 ? dedentToRoot$3(hardline$d) : dedentToRoot$3(literalline$7) : ""), []))))]);
|
51054 | }
|
51055 |
|
51056 | case "sequence":
|
51057 | return join$c(hardline$d, path.map(print, "children"));
|
51058 |
|
51059 | case "sequenceItem":
|
51060 | return concat$h(["- ", align$3(2, !node.content ? "" : path.call(print, "content"))]);
|
51061 |
|
51062 | case "mappingKey":
|
51063 | return !node.content ? "" : path.call(print, "content");
|
51064 |
|
51065 | case "mappingValue":
|
51066 | return !node.content ? "" : path.call(print, "content");
|
51067 |
|
51068 | case "mapping":
|
51069 | return join$c(hardline$d, path.map(print, "children"));
|
51070 |
|
51071 | case "mappingItem":
|
51072 | case "flowMappingItem":
|
51073 | {
|
51074 | const isEmptyMappingKey = isEmptyNode$1(node.key);
|
51075 | const isEmptyMappingValue = isEmptyNode$1(node.value);
|
51076 |
|
51077 | if (isEmptyMappingKey && isEmptyMappingValue) {
|
51078 | return concat$h([": "]);
|
51079 | }
|
51080 |
|
51081 | const key = path.call(print, "key");
|
51082 | const value = path.call(print, "value");
|
51083 |
|
51084 | if (isEmptyMappingValue) {
|
51085 | return node.type === "flowMappingItem" && parentNode.type === "flowMapping" ? key : node.type === "mappingItem" && isAbsolutelyPrintedAsSingleLineNode(node.key.content, options) && !hasTrailingComment$3(node.key.content) && (!parentNode.tag || parentNode.tag.value !== "tag:yaml.org,2002:set") ? concat$h([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ":"]) : concat$h(["? ", align$3(2, key)]);
|
51086 | }
|
51087 |
|
51088 | if (isEmptyMappingKey) {
|
51089 | return concat$h([": ", align$3(2, value)]);
|
51090 | }
|
51091 |
|
51092 | const groupId = Symbol("mappingKey");
|
51093 | const forceExplicitKey = hasLeadingComments$1(node.value) || !isInlineNode(node.key.content);
|
51094 | return forceExplicitKey ? concat$h(["? ", align$3(2, key), hardline$d, join$c("", path.map(print, "value", "leadingComments").map(comment => concat$h([comment, hardline$d]))), ": ", align$3(2, value)]) :
|
51095 | isSingleLineNode(node.key.content) && !hasLeadingComments$1(node.key.content) && !hasMiddleComments$1(node.key.content) && !hasTrailingComment$3(node.key.content) && !hasEndComments$1(node.key) && !hasLeadingComments$1(node.value.content) && !hasMiddleComments$1(node.value.content) && !hasEndComments$1(node.value) && isAbsolutelyPrintedAsSingleLineNode(node.value.content, options) ? concat$h([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ": ", value]) : conditionalGroup$2([concat$h([group$g(concat$h([ifBreak$8("? "), group$g(align$3(2, key), {
|
51096 | id: groupId
|
51097 | })])), ifBreak$8(concat$h([hardline$d, ": ", align$3(2, value)]), indent(concat$h([needsSpaceInFrontOfMappingValue(node) ? " " : "", ":", hasLeadingComments$1(node.value.content) || hasEndComments$1(node.value) && node.value.content && !isNode$1(node.value.content, ["mapping", "sequence"]) || parentNode.type === "mapping" && hasTrailingComment$3(node.key.content) && isInlineNode(node.value.content) || isNode$1(node.value.content, ["mapping", "sequence"]) && node.value.content.tag === null && node.value.content.anchor === null ? hardline$d : !node.value.content ? "" : line$b, value])), {
|
51098 | groupId
|
51099 | })])]);
|
51100 | }
|
51101 |
|
51102 | case "flowMapping":
|
51103 | case "flowSequence":
|
51104 | {
|
51105 | const openMarker = node.type === "flowMapping" ? "{" : "[";
|
51106 | const closeMarker = node.type === "flowMapping" ? "}" : "]";
|
51107 | const bracketSpacing = node.type === "flowMapping" && node.children.length !== 0 && options.bracketSpacing ? line$b : softline$8;
|
51108 |
|
51109 | const isLastItemEmptyMappingItem = node.children.length !== 0 && (lastItem => lastItem.type === "flowMappingItem" && isEmptyNode$1(lastItem.key) && isEmptyNode$1(lastItem.value))(getLast$6(node.children));
|
51110 |
|
51111 | return concat$h([openMarker, indent(concat$h([bracketSpacing, concat$h(path.map((childPath, index) => concat$h([print(childPath), index === node.children.length - 1 ? "" : concat$h([",", line$b, node.children[index].position.start.line !== node.children[index + 1].position.start.line ? printNextEmptyLine(childPath, options.originalText) : ""])]), "children")), ifBreak$8(",", "")])), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker]);
|
51112 | }
|
51113 |
|
51114 | case "flowSequenceItem":
|
51115 | return path.call(print, "content");
|
51116 |
|
51117 |
|
51118 | default:
|
51119 | throw new Error(`Unexpected node type ${node.type}`);
|
51120 | }
|
51121 |
|
51122 | function indent(doc) {
|
51123 | return docBuilders$2.align(" ".repeat(options.tabWidth), doc);
|
51124 | }
|
51125 | }
|
51126 |
|
51127 | function align$3(n, doc) {
|
51128 | return typeof n === "number" && n > 0 ? docBuilders$2.align(" ".repeat(n), doc) : docBuilders$2.align(n, doc);
|
51129 | }
|
51130 |
|
51131 | function isInlineNode(node) {
|
51132 | if (!node) {
|
51133 | return true;
|
51134 | }
|
51135 |
|
51136 | switch (node.type) {
|
51137 | case "plain":
|
51138 | case "quoteDouble":
|
51139 | case "quoteSingle":
|
51140 | case "alias":
|
51141 | case "flowMapping":
|
51142 | case "flowSequence":
|
51143 | return true;
|
51144 |
|
51145 | default:
|
51146 | return false;
|
51147 | }
|
51148 | }
|
51149 |
|
51150 | function isSingleLineNode(node) {
|
51151 | if (!node) {
|
51152 | return true;
|
51153 | }
|
51154 |
|
51155 | switch (node.type) {
|
51156 | case "plain":
|
51157 | case "quoteDouble":
|
51158 | case "quoteSingle":
|
51159 | return node.position.start.line === node.position.end.line;
|
51160 |
|
51161 | case "alias":
|
51162 | return true;
|
51163 |
|
51164 | default:
|
51165 | return false;
|
51166 | }
|
51167 | }
|
51168 |
|
51169 | function shouldPrintDocumentBody(document) {
|
51170 | return document.body.children.length !== 0 || hasEndComments$1(document.body);
|
51171 | }
|
51172 |
|
51173 | function shouldPrintDocumentEndMarker(document, nextDocument) {
|
51174 | return (
|
51175 | |
51176 |
|
51177 |
|
51178 | hasTrailingComment$3(document) || nextDocument && (
|
51179 | |
51180 |
|
51181 |
|
51182 |
|
51183 |
|
51184 | nextDocument.head.children.length !== 0 ||
|
51185 | |
51186 |
|
51187 |
|
51188 |
|
51189 |
|
51190 | hasEndComments$1(nextDocument.head))
|
51191 | );
|
51192 | }
|
51193 |
|
51194 | function shouldPrintDocumentHeadEndMarker(document, nextDocument, root, options) {
|
51195 | if (
|
51196 | |
51197 |
|
51198 |
|
51199 |
|
51200 | root.children[0] === document && /---(\s|$)/.test(options.originalText.slice(options.locStart(document), options.locStart(document) + 4)) ||
|
51201 | |
51202 |
|
51203 |
|
51204 |
|
51205 | document.head.children.length !== 0 ||
|
51206 | |
51207 |
|
51208 |
|
51209 |
|
51210 | hasEndComments$1(document.head) ||
|
51211 | |
51212 |
|
51213 |
|
51214 | hasTrailingComment$3(document.head)) {
|
51215 | return "head";
|
51216 | }
|
51217 |
|
51218 | if (shouldPrintDocumentEndMarker(document, nextDocument)) {
|
51219 | return false;
|
51220 | }
|
51221 |
|
51222 | return nextDocument ? "root" : false;
|
51223 | }
|
51224 |
|
51225 | function isAbsolutelyPrintedAsSingleLineNode(node, options) {
|
51226 | if (!node) {
|
51227 | return true;
|
51228 | }
|
51229 |
|
51230 | switch (node.type) {
|
51231 | case "plain":
|
51232 | case "quoteSingle":
|
51233 | case "quoteDouble":
|
51234 | break;
|
51235 |
|
51236 | case "alias":
|
51237 | return true;
|
51238 |
|
51239 | default:
|
51240 | return false;
|
51241 | }
|
51242 |
|
51243 | if (options.proseWrap === "preserve") {
|
51244 | return node.position.start.line === node.position.end.line;
|
51245 | }
|
51246 |
|
51247 | if (
|
51248 | /\\$/m.test(options.originalText.slice(node.position.start.offset, node.position.end.offset))) {
|
51249 | return false;
|
51250 | }
|
51251 |
|
51252 | switch (options.proseWrap) {
|
51253 | case "never":
|
51254 | return !node.value.includes("\n");
|
51255 |
|
51256 | case "always":
|
51257 | return !/[\n ]/.test(node.value);
|
51258 |
|
51259 |
|
51260 | default:
|
51261 | return false;
|
51262 | }
|
51263 | }
|
51264 |
|
51265 | function needsSpaceInFrontOfMappingValue(node) {
|
51266 | return node.key.content && node.key.content.type === "alias";
|
51267 | }
|
51268 |
|
51269 | function printNextEmptyLine(path, originalText) {
|
51270 | const node = path.getValue();
|
51271 | const root = path.stack[0];
|
51272 | root.isNextEmptyLinePrintedChecklist = root.isNextEmptyLinePrintedChecklist || [];
|
51273 |
|
51274 | if (!root.isNextEmptyLinePrintedChecklist[node.position.end.line]) {
|
51275 | if (isNextLineEmpty$6(node, originalText)) {
|
51276 | root.isNextEmptyLinePrintedChecklist[node.position.end.line] = true;
|
51277 | return softline$8;
|
51278 | }
|
51279 | }
|
51280 |
|
51281 | return "";
|
51282 | }
|
51283 |
|
51284 | function printFlowScalarContent(nodeType, content, options) {
|
51285 | const lineContents = getFlowScalarLineContents$1(nodeType, content, options);
|
51286 | return join$c(hardline$d, lineContents.map(lineContentWords => fill$7(join$c(line$b, lineContentWords).parts)));
|
51287 | }
|
51288 |
|
51289 | function clean$7(node, newNode
|
51290 | /*, parent */
|
51291 | ) {
|
51292 | if (isNode$1(newNode)) {
|
51293 | delete newNode.position;
|
51294 |
|
51295 | switch (newNode.type) {
|
51296 | case "comment":
|
51297 |
|
51298 | if (isPragma$1(newNode.value)) {
|
51299 | return null;
|
51300 | }
|
51301 |
|
51302 | break;
|
51303 |
|
51304 | case "quoteDouble":
|
51305 | case "quoteSingle":
|
51306 | newNode.type = "quote";
|
51307 | break;
|
51308 | }
|
51309 | }
|
51310 | }
|
51311 |
|
51312 | var printerYaml = {
|
51313 | preprocess: preprocess$3,
|
51314 | print: genericPrint$6,
|
51315 | massageAstNode: clean$7,
|
51316 | insertPragma: insertPragma$9
|
51317 | };
|
51318 |
|
51319 | var options$7 = {
|
51320 | bracketSpacing: commonOptions.bracketSpacing,
|
51321 | singleQuote: commonOptions.singleQuote,
|
51322 | proseWrap: commonOptions.proseWrap
|
51323 | };
|
51324 |
|
51325 | var name$i = "YAML";
|
51326 | var type$g = "data";
|
51327 | var tmScope$g = "source.yaml";
|
51328 | var aliases$6 = [
|
51329 | "yml"
|
51330 | ];
|
51331 | var extensions$g = [
|
51332 | ".yml",
|
51333 | ".mir",
|
51334 | ".reek",
|
51335 | ".rviz",
|
51336 | ".sublime-syntax",
|
51337 | ".syntax",
|
51338 | ".yaml",
|
51339 | ".yaml-tmlanguage",
|
51340 | ".yaml.sed",
|
51341 | ".yml.mysql"
|
51342 | ];
|
51343 | var filenames$4 = [
|
51344 | ".clang-format",
|
51345 | ".clang-tidy",
|
51346 | ".gemrc",
|
51347 | "glide.lock",
|
51348 | "yarn.lock"
|
51349 | ];
|
51350 | var aceMode$g = "yaml";
|
51351 | var codemirrorMode$c = "yaml";
|
51352 | var codemirrorMimeType$c = "text/x-yaml";
|
51353 | var languageId$g = 407;
|
51354 | var YAML = {
|
51355 | name: name$i,
|
51356 | type: type$g,
|
51357 | tmScope: tmScope$g,
|
51358 | aliases: aliases$6,
|
51359 | extensions: extensions$g,
|
51360 | filenames: filenames$4,
|
51361 | aceMode: aceMode$g,
|
51362 | codemirrorMode: codemirrorMode$c,
|
51363 | codemirrorMimeType: codemirrorMimeType$c,
|
51364 | languageId: languageId$g
|
51365 | };
|
51366 |
|
51367 | var YAML$1 = Object.freeze({
|
51368 | __proto__: null,
|
51369 | name: name$i,
|
51370 | type: type$g,
|
51371 | tmScope: tmScope$g,
|
51372 | aliases: aliases$6,
|
51373 | extensions: extensions$g,
|
51374 | filenames: filenames$4,
|
51375 | aceMode: aceMode$g,
|
51376 | codemirrorMode: codemirrorMode$c,
|
51377 | codemirrorMimeType: codemirrorMimeType$c,
|
51378 | languageId: languageId$g,
|
51379 | 'default': YAML
|
51380 | });
|
51381 |
|
51382 | var require$$0$7 = getCjsExportFromNamespace(YAML$1);
|
51383 |
|
51384 | const languages$6 = [createLanguage(require$$0$7, data => ({
|
51385 | since: "1.14.0",
|
51386 | parsers: ["yaml"],
|
51387 | vscodeLanguageIds: ["yaml"],
|
51388 |
|
51389 | filenames: data.filenames.filter(filename => filename !== "yarn.lock")
|
51390 | }))];
|
51391 | var languageYaml = {
|
51392 | languages: languages$6,
|
51393 | printers: {
|
51394 | yaml: printerYaml
|
51395 | },
|
51396 | options: options$7
|
51397 | };
|
51398 |
|
51399 |
|
51400 |
|
51401 |
|
51402 |
|
51403 |
|
51404 | var internalPlugins = [
|
51405 | languageJs, {
|
51406 | parsers: {
|
51407 |
|
51408 | get babel() {
|
51409 | return require("./parser-babel").parsers.babel;
|
51410 | },
|
51411 |
|
51412 | get "babel-flow"() {
|
51413 | return require("./parser-babel").parsers["babel-flow"];
|
51414 | },
|
51415 |
|
51416 | get "babel-ts"() {
|
51417 | return require("./parser-babel").parsers["babel-ts"];
|
51418 | },
|
51419 |
|
51420 | get json() {
|
51421 | return require("./parser-babel").parsers.json;
|
51422 | },
|
51423 |
|
51424 | get json5() {
|
51425 | return require("./parser-babel").parsers.json5;
|
51426 | },
|
51427 |
|
51428 | get "json-stringify"() {
|
51429 | return require("./parser-babel").parsers["json-stringify"];
|
51430 | },
|
51431 |
|
51432 | get __js_expression() {
|
51433 | return require("./parser-babel").parsers.__js_expression;
|
51434 | },
|
51435 |
|
51436 | get __vue_expression() {
|
51437 | return require("./parser-babel").parsers.__vue_expression;
|
51438 | },
|
51439 |
|
51440 | get __vue_event_binding() {
|
51441 | return require("./parser-babel").parsers.__vue_event_binding;
|
51442 | },
|
51443 |
|
51444 |
|
51445 | get flow() {
|
51446 | return require("./parser-flow").parsers.flow;
|
51447 | },
|
51448 |
|
51449 |
|
51450 | get typescript() {
|
51451 | return require("./parser-typescript").parsers.typescript;
|
51452 | },
|
51453 |
|
51454 |
|
51455 | get __ng_action() {
|
51456 | return require("./parser-angular").parsers.__ng_action;
|
51457 | },
|
51458 |
|
51459 |
|
51460 | get __ng_binding() {
|
51461 | return require("./parser-angular").parsers.__ng_binding;
|
51462 | },
|
51463 |
|
51464 |
|
51465 | get __ng_interpolation() {
|
51466 | return require("./parser-angular").parsers.__ng_interpolation;
|
51467 | },
|
51468 |
|
51469 |
|
51470 | get __ng_directive() {
|
51471 | return require("./parser-angular").parsers.__ng_directive;
|
51472 | }
|
51473 |
|
51474 | }
|
51475 | },
|
51476 | languageCss, {
|
51477 | parsers: {
|
51478 |
|
51479 | get css() {
|
51480 | return require("./parser-postcss").parsers.css;
|
51481 | },
|
51482 |
|
51483 | get less() {
|
51484 | return require("./parser-postcss").parsers.less;
|
51485 | },
|
51486 |
|
51487 | get scss() {
|
51488 | return require("./parser-postcss").parsers.scss;
|
51489 | }
|
51490 |
|
51491 | }
|
51492 | },
|
51493 | languageHandlebars, {
|
51494 | parsers: {
|
51495 | get glimmer() {
|
51496 | return require("./parser-glimmer").parsers.glimmer;
|
51497 | }
|
51498 |
|
51499 | }
|
51500 | },
|
51501 | languageGraphql, {
|
51502 | parsers: {
|
51503 | get graphql() {
|
51504 | return require("./parser-graphql").parsers.graphql;
|
51505 | }
|
51506 |
|
51507 | }
|
51508 | },
|
51509 | languageMarkdown, {
|
51510 | parsers: {
|
51511 | get remark() {
|
51512 | return require("./parser-markdown").parsers.remark;
|
51513 | },
|
51514 |
|
51515 | get markdown() {
|
51516 | return require("./parser-markdown").parsers.remark;
|
51517 | },
|
51518 |
|
51519 | get mdx() {
|
51520 | return require("./parser-markdown").parsers.mdx;
|
51521 | }
|
51522 |
|
51523 | }
|
51524 | }, languageHtml, {
|
51525 | parsers: {
|
51526 |
|
51527 | get html() {
|
51528 | return require("./parser-html").parsers.html;
|
51529 | },
|
51530 |
|
51531 |
|
51532 | get vue() {
|
51533 | return require("./parser-html").parsers.vue;
|
51534 | },
|
51535 |
|
51536 |
|
51537 | get angular() {
|
51538 | return require("./parser-html").parsers.angular;
|
51539 | },
|
51540 |
|
51541 |
|
51542 | get lwc() {
|
51543 | return require("./parser-html").parsers.lwc;
|
51544 | }
|
51545 |
|
51546 | }
|
51547 | },
|
51548 | languageYaml, {
|
51549 | parsers: {
|
51550 | get yaml() {
|
51551 | return require("./parser-yaml").parsers.yaml;
|
51552 | }
|
51553 |
|
51554 | }
|
51555 | }];
|
51556 |
|
51557 | const memoizedLoad = mem_1(load, {
|
51558 | cacheKey: JSON.stringify
|
51559 | });
|
51560 | const memoizedSearch = mem_1(findPluginsInNodeModules);
|
51561 |
|
51562 | const clearCache$2 = () => {
|
51563 | mem_1.clear(memoizedLoad);
|
51564 | mem_1.clear(memoizedSearch);
|
51565 | };
|
51566 |
|
51567 | function load(plugins, pluginSearchDirs) {
|
51568 | if (!plugins) {
|
51569 | plugins = [];
|
51570 | }
|
51571 |
|
51572 | if (!pluginSearchDirs) {
|
51573 | pluginSearchDirs = [];
|
51574 | }
|
51575 |
|
51576 |
|
51577 | if (!pluginSearchDirs.length) {
|
51578 | const autoLoadDir = thirdParty.findParentDir(__dirname, "node_modules");
|
51579 |
|
51580 | if (autoLoadDir) {
|
51581 | pluginSearchDirs = [autoLoadDir];
|
51582 | }
|
51583 | }
|
51584 |
|
51585 | const [externalPluginNames, externalPluginInstances] = partition_1(plugins, plugin => typeof plugin === "string");
|
51586 | const externalManualLoadPluginInfos = externalPluginNames.map(pluginName => {
|
51587 | let requirePath;
|
51588 |
|
51589 | try {
|
51590 |
|
51591 | requirePath = resolve_1(path$2.resolve(process.cwd(), pluginName));
|
51592 | } catch (_) {
|
51593 |
|
51594 | requirePath = resolve_1(pluginName, {
|
51595 | paths: [process.cwd()]
|
51596 | });
|
51597 | }
|
51598 |
|
51599 | return {
|
51600 | name: pluginName,
|
51601 | requirePath
|
51602 | };
|
51603 | });
|
51604 | const externalAutoLoadPluginInfos = pluginSearchDirs.map(pluginSearchDir => {
|
51605 | const resolvedPluginSearchDir = path$2.resolve(process.cwd(), pluginSearchDir);
|
51606 | const nodeModulesDir = path$2.resolve(resolvedPluginSearchDir, "node_modules");
|
51607 |
|
51608 |
|
51609 |
|
51610 | if (!isDirectory$1(nodeModulesDir) && !isDirectory$1(resolvedPluginSearchDir)) {
|
51611 | throw new Error(`${pluginSearchDir} does not exist or is not a directory`);
|
51612 | }
|
51613 |
|
51614 | return memoizedSearch(nodeModulesDir).map(pluginName => ({
|
51615 | name: pluginName,
|
51616 | requirePath: resolve_1(pluginName, {
|
51617 | paths: [resolvedPluginSearchDir]
|
51618 | })
|
51619 | }));
|
51620 | }).reduce((a, b) => a.concat(b), []);
|
51621 | const externalPlugins = uniqBy_1(externalManualLoadPluginInfos.concat(externalAutoLoadPluginInfos), "requirePath").map(externalPluginInfo => Object.assign({
|
51622 | name: externalPluginInfo.name
|
51623 | }, require(externalPluginInfo.requirePath))).concat(externalPluginInstances);
|
51624 | return internalPlugins.concat(externalPlugins);
|
51625 | }
|
51626 |
|
51627 | function findPluginsInNodeModules(nodeModulesDir) {
|
51628 | const pluginPackageJsonPaths = globby$1.sync(["prettier-plugin-*/package.json", "@*/prettier-plugin-*/package.json", "@prettier/plugin-*/package.json"], {
|
51629 | cwd: nodeModulesDir,
|
51630 | expandDirectories: false
|
51631 | });
|
51632 | return pluginPackageJsonPaths.map(path$2.dirname);
|
51633 | }
|
51634 |
|
51635 | function isDirectory$1(dir) {
|
51636 | try {
|
51637 | return fs$3.statSync(dir).isDirectory();
|
51638 | } catch (e) {
|
51639 | return false;
|
51640 | }
|
51641 | }
|
51642 |
|
51643 | var loadPlugins = {
|
51644 | loadPlugins: memoizedLoad,
|
51645 | clearCache: clearCache$2
|
51646 | };
|
51647 |
|
51648 | const {
|
51649 | version: version$2
|
51650 | } = require$$1;
|
51651 | const {
|
51652 | getSupportInfo: getSupportInfo$2
|
51653 | } = support;
|
51654 |
|
51655 | function _withPlugins(fn, optsArgIdx = 1 // Usually `opts` is the 2nd argument
|
51656 | ) {
|
51657 | return (...args) => {
|
51658 | const opts = args[optsArgIdx] || {};
|
51659 | args[optsArgIdx] = Object.assign({}, opts, {
|
51660 | plugins: loadPlugins.loadPlugins(opts.plugins, opts.pluginSearchDirs)
|
51661 | });
|
51662 | return fn(...args);
|
51663 | };
|
51664 | }
|
51665 |
|
51666 | function withPlugins(fn, optsArgIdx) {
|
51667 | const resultingFn = _withPlugins(fn, optsArgIdx);
|
51668 |
|
51669 | if (fn.sync) {
|
51670 |
|
51671 | resultingFn.sync = _withPlugins(fn.sync, optsArgIdx);
|
51672 | }
|
51673 |
|
51674 | return resultingFn;
|
51675 | }
|
51676 |
|
51677 | const formatWithCursor = withPlugins(core.formatWithCursor);
|
51678 | var src$1 = {
|
51679 | formatWithCursor,
|
51680 |
|
51681 | format(text, opts) {
|
51682 | return formatWithCursor(text, opts).formatted;
|
51683 | },
|
51684 |
|
51685 | check(text, opts) {
|
51686 | const {
|
51687 | formatted
|
51688 | } = formatWithCursor(text, opts);
|
51689 | return formatted === text;
|
51690 | },
|
51691 |
|
51692 | doc: document,
|
51693 | resolveConfig: resolveConfig_1.resolveConfig,
|
51694 | resolveConfigFile: resolveConfig_1.resolveConfigFile,
|
51695 |
|
51696 | clearConfigCache() {
|
51697 | resolveConfig_1.clearCache();
|
51698 | loadPlugins.clearCache();
|
51699 | },
|
51700 |
|
51701 | getFileInfo:
|
51702 |
|
51703 | withPlugins(getFileInfo_1),
|
51704 | getSupportInfo:
|
51705 |
|
51706 | withPlugins(getSupportInfo$2, 0),
|
51707 | version: version$2,
|
51708 | util: utilShared,
|
51709 |
|
51710 |
|
51711 | __debug: {
|
51712 | parse: withPlugins(core.parse),
|
51713 | formatAST: withPlugins(core.formatAST),
|
51714 | formatDoc: withPlugins(core.formatDoc),
|
51715 | printToDoc: withPlugins(core.printToDoc),
|
51716 | printDocToString: withPlugins(core.printDocToString)
|
51717 | }
|
51718 | };
|
51719 |
|
51720 | var prettier = src$1;
|
51721 |
|
51722 | var at,
|
51723 |
|
51724 | ch,
|
51725 |
|
51726 | escapee = {
|
51727 | '"': '"',
|
51728 | '\\': '\\',
|
51729 | '/': '/',
|
51730 | b: '\b',
|
51731 | f: '\f',
|
51732 | n: '\n',
|
51733 | r: '\r',
|
51734 | t: '\t'
|
51735 | },
|
51736 | text,
|
51737 | error$1 = function (m) {
|
51738 |
|
51739 | throw {
|
51740 | name: 'SyntaxError',
|
51741 | message: m,
|
51742 | at: at,
|
51743 | text: text
|
51744 | };
|
51745 | },
|
51746 | next = function (c) {
|
51747 |
|
51748 | if (c && c !== ch) {
|
51749 | error$1("Expected '" + c + "' instead of '" + ch + "'");
|
51750 | }
|
51751 |
|
51752 |
|
51753 |
|
51754 | ch = text.charAt(at);
|
51755 | at += 1;
|
51756 | return ch;
|
51757 | },
|
51758 | number$1 = function () {
|
51759 |
|
51760 | var number,
|
51761 | string = '';
|
51762 |
|
51763 | if (ch === '-') {
|
51764 | string = '-';
|
51765 | next('-');
|
51766 | }
|
51767 |
|
51768 | while (ch >= '0' && ch <= '9') {
|
51769 | string += ch;
|
51770 | next();
|
51771 | }
|
51772 |
|
51773 | if (ch === '.') {
|
51774 | string += '.';
|
51775 |
|
51776 | while (next() && ch >= '0' && ch <= '9') {
|
51777 | string += ch;
|
51778 | }
|
51779 | }
|
51780 |
|
51781 | if (ch === 'e' || ch === 'E') {
|
51782 | string += ch;
|
51783 | next();
|
51784 |
|
51785 | if (ch === '-' || ch === '+') {
|
51786 | string += ch;
|
51787 | next();
|
51788 | }
|
51789 |
|
51790 | while (ch >= '0' && ch <= '9') {
|
51791 | string += ch;
|
51792 | next();
|
51793 | }
|
51794 | }
|
51795 |
|
51796 | number = +string;
|
51797 |
|
51798 | if (!isFinite(number)) {
|
51799 | error$1("Bad number");
|
51800 | } else {
|
51801 | return number;
|
51802 | }
|
51803 | },
|
51804 | string$2 = function () {
|
51805 |
|
51806 | var hex,
|
51807 | i,
|
51808 | string = '',
|
51809 | uffff;
|
51810 |
|
51811 | if (ch === '"') {
|
51812 | while (next()) {
|
51813 | if (ch === '"') {
|
51814 | next();
|
51815 | return string;
|
51816 | } else if (ch === '\\') {
|
51817 | next();
|
51818 |
|
51819 | if (ch === 'u') {
|
51820 | uffff = 0;
|
51821 |
|
51822 | for (i = 0; i < 4; i += 1) {
|
51823 | hex = parseInt(next(), 16);
|
51824 |
|
51825 | if (!isFinite(hex)) {
|
51826 | break;
|
51827 | }
|
51828 |
|
51829 | uffff = uffff * 16 + hex;
|
51830 | }
|
51831 |
|
51832 | string += String.fromCharCode(uffff);
|
51833 | } else if (typeof escapee[ch] === 'string') {
|
51834 | string += escapee[ch];
|
51835 | } else {
|
51836 | break;
|
51837 | }
|
51838 | } else {
|
51839 | string += ch;
|
51840 | }
|
51841 | }
|
51842 | }
|
51843 |
|
51844 | error$1("Bad string");
|
51845 | },
|
51846 | white = function () {
|
51847 |
|
51848 | while (ch && ch <= ' ') {
|
51849 | next();
|
51850 | }
|
51851 | },
|
51852 | word = function () {
|
51853 |
|
51854 | switch (ch) {
|
51855 | case 't':
|
51856 | next('t');
|
51857 | next('r');
|
51858 | next('u');
|
51859 | next('e');
|
51860 | return true;
|
51861 |
|
51862 | case 'f':
|
51863 | next('f');
|
51864 | next('a');
|
51865 | next('l');
|
51866 | next('s');
|
51867 | next('e');
|
51868 | return false;
|
51869 |
|
51870 | case 'n':
|
51871 | next('n');
|
51872 | next('u');
|
51873 | next('l');
|
51874 | next('l');
|
51875 | return null;
|
51876 | }
|
51877 |
|
51878 | error$1("Unexpected '" + ch + "'");
|
51879 | },
|
51880 | value,
|
51881 |
|
51882 | array$3 = function () {
|
51883 |
|
51884 | var array = [];
|
51885 |
|
51886 | if (ch === '[') {
|
51887 | next('[');
|
51888 | white();
|
51889 |
|
51890 | if (ch === ']') {
|
51891 | next(']');
|
51892 | return array;
|
51893 | }
|
51894 |
|
51895 | while (ch) {
|
51896 | array.push(value());
|
51897 | white();
|
51898 |
|
51899 | if (ch === ']') {
|
51900 | next(']');
|
51901 | return array;
|
51902 | }
|
51903 |
|
51904 | next(',');
|
51905 | white();
|
51906 | }
|
51907 | }
|
51908 |
|
51909 | error$1("Bad array");
|
51910 | },
|
51911 | object$1 = function () {
|
51912 |
|
51913 | var key,
|
51914 | object = {};
|
51915 |
|
51916 | if (ch === '{') {
|
51917 | next('{');
|
51918 | white();
|
51919 |
|
51920 | if (ch === '}') {
|
51921 | next('}');
|
51922 | return object;
|
51923 | }
|
51924 |
|
51925 | while (ch) {
|
51926 | key = string$2();
|
51927 | white();
|
51928 | next(':');
|
51929 |
|
51930 | if (Object.hasOwnProperty.call(object, key)) {
|
51931 | error$1('Duplicate key "' + key + '"');
|
51932 | }
|
51933 |
|
51934 | object[key] = value();
|
51935 | white();
|
51936 |
|
51937 | if (ch === '}') {
|
51938 | next('}');
|
51939 | return object;
|
51940 | }
|
51941 |
|
51942 | next(',');
|
51943 | white();
|
51944 | }
|
51945 | }
|
51946 |
|
51947 | error$1("Bad object");
|
51948 | };
|
51949 |
|
51950 | value = function () {
|
51951 |
|
51952 |
|
51953 | white();
|
51954 |
|
51955 | switch (ch) {
|
51956 | case '{':
|
51957 | return object$1();
|
51958 |
|
51959 | case '[':
|
51960 | return array$3();
|
51961 |
|
51962 | case '"':
|
51963 | return string$2();
|
51964 |
|
51965 | case '-':
|
51966 | return number$1();
|
51967 |
|
51968 | default:
|
51969 | return ch >= '0' && ch <= '9' ? number$1() : word();
|
51970 | }
|
51971 | };
|
51972 |
|
51973 |
|
51974 |
|
51975 | var parse$7 = function (source, reviver) {
|
51976 | var result;
|
51977 | text = source;
|
51978 | at = 0;
|
51979 | ch = ' ';
|
51980 | result = value();
|
51981 | white();
|
51982 |
|
51983 | if (ch) {
|
51984 | error$1("Syntax error");
|
51985 | }
|
51986 |
|
51987 |
|
51988 |
|
51989 |
|
51990 |
|
51991 |
|
51992 | return typeof reviver === 'function' ? function walk(holder, key) {
|
51993 | var k,
|
51994 | v,
|
51995 | value = holder[key];
|
51996 |
|
51997 | if (value && typeof value === 'object') {
|
51998 | for (k in value) {
|
51999 | if (Object.prototype.hasOwnProperty.call(value, k)) {
|
52000 | v = walk(value, k);
|
52001 |
|
52002 | if (v !== undefined) {
|
52003 | value[k] = v;
|
52004 | } else {
|
52005 | delete value[k];
|
52006 | }
|
52007 | }
|
52008 | }
|
52009 | }
|
52010 |
|
52011 | return reviver.call(holder, key, value);
|
52012 | }({
|
52013 | '': result
|
52014 | }, '') : result;
|
52015 | };
|
52016 |
|
52017 | var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
52018 | gap,
|
52019 | indent$a,
|
52020 | meta$1 = {
|
52021 |
|
52022 | '\b': '\\b',
|
52023 | '\t': '\\t',
|
52024 | '\n': '\\n',
|
52025 | '\f': '\\f',
|
52026 | '\r': '\\r',
|
52027 | '"': '\\"',
|
52028 | '\\': '\\\\'
|
52029 | },
|
52030 | rep;
|
52031 |
|
52032 | function quote(string) {
|
52033 |
|
52034 |
|
52035 |
|
52036 |
|
52037 | escapable.lastIndex = 0;
|
52038 | return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
|
52039 | var c = meta$1[a];
|
52040 | return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
52041 | }) + '"' : '"' + string + '"';
|
52042 | }
|
52043 |
|
52044 | function str(key, holder) {
|
52045 |
|
52046 | var i,
|
52047 |
|
52048 | k,
|
52049 |
|
52050 | v,
|
52051 |
|
52052 | length,
|
52053 | mind = gap,
|
52054 | partial,
|
52055 | value = holder[key];
|
52056 |
|
52057 | if (value && typeof value === 'object' && typeof value.toJSON === 'function') {
|
52058 | value = value.toJSON(key);
|
52059 | }
|
52060 |
|
52061 |
|
52062 |
|
52063 | if (typeof rep === 'function') {
|
52064 | value = rep.call(holder, key, value);
|
52065 | }
|
52066 |
|
52067 |
|
52068 | switch (typeof value) {
|
52069 | case 'string':
|
52070 | return quote(value);
|
52071 |
|
52072 | case 'number':
|
52073 |
|
52074 | return isFinite(value) ? String(value) : 'null';
|
52075 |
|
52076 | case 'boolean':
|
52077 | case 'null':
|
52078 |
|
52079 |
|
52080 |
|
52081 | return String(value);
|
52082 |
|
52083 | case 'object':
|
52084 | if (!value) return 'null';
|
52085 | gap += indent$a;
|
52086 | partial = [];
|
52087 |
|
52088 | if (Object.prototype.toString.apply(value) === '[object Array]') {
|
52089 | length = value.length;
|
52090 |
|
52091 | for (i = 0; i < length; i += 1) {
|
52092 | partial[i] = str(i, value) || 'null';
|
52093 | }
|
52094 |
|
52095 |
|
52096 |
|
52097 | v = partial.length === 0 ? '[]' : gap ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : '[' + partial.join(',') + ']';
|
52098 | gap = mind;
|
52099 | return v;
|
52100 | }
|
52101 |
|
52102 |
|
52103 |
|
52104 | if (rep && typeof rep === 'object') {
|
52105 | length = rep.length;
|
52106 |
|
52107 | for (i = 0; i < length; i += 1) {
|
52108 | k = rep[i];
|
52109 |
|
52110 | if (typeof k === 'string') {
|
52111 | v = str(k, value);
|
52112 |
|
52113 | if (v) {
|
52114 | partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
52115 | }
|
52116 | }
|
52117 | }
|
52118 | } else {
|
52119 |
|
52120 | for (k in value) {
|
52121 | if (Object.prototype.hasOwnProperty.call(value, k)) {
|
52122 | v = str(k, value);
|
52123 |
|
52124 | if (v) {
|
52125 | partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
52126 | }
|
52127 | }
|
52128 | }
|
52129 | }
|
52130 |
|
52131 |
|
52132 |
|
52133 | v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : '{' + partial.join(',') + '}';
|
52134 | gap = mind;
|
52135 | return v;
|
52136 | }
|
52137 | }
|
52138 |
|
52139 | var stringify$3 = function (value, replacer, space) {
|
52140 | var i;
|
52141 | gap = '';
|
52142 | indent$a = '';
|
52143 |
|
52144 |
|
52145 | if (typeof space === 'number') {
|
52146 | for (i = 0; i < space; i += 1) {
|
52147 | indent$a += ' ';
|
52148 | }
|
52149 | }
|
52150 | else if (typeof space === 'string') {
|
52151 | indent$a = space;
|
52152 | }
|
52153 |
|
52154 |
|
52155 |
|
52156 | rep = replacer;
|
52157 |
|
52158 | if (replacer && typeof replacer !== 'function' && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) {
|
52159 | throw new Error('JSON.stringify');
|
52160 | }
|
52161 |
|
52162 |
|
52163 |
|
52164 | return str('', {
|
52165 | '': value
|
52166 | });
|
52167 | };
|
52168 |
|
52169 | var parse$8 = parse$7;
|
52170 | var stringify$4 = stringify$3;
|
52171 | var jsonify = {
|
52172 | parse: parse$8,
|
52173 | stringify: stringify$4
|
52174 | };
|
52175 |
|
52176 | var json$2 = typeof JSON !== 'undefined' ? JSON : jsonify;
|
52177 |
|
52178 | var jsonStableStringify = function (obj, opts) {
|
52179 | if (!opts) opts = {};
|
52180 | if (typeof opts === 'function') opts = {
|
52181 | cmp: opts
|
52182 | };
|
52183 | var space = opts.space || '';
|
52184 | if (typeof space === 'number') space = Array(space + 1).join(' ');
|
52185 | var cycles = typeof opts.cycles === 'boolean' ? opts.cycles : false;
|
52186 |
|
52187 | var replacer = opts.replacer || function (key, value) {
|
52188 | return value;
|
52189 | };
|
52190 |
|
52191 | var cmp = opts.cmp && function (f) {
|
52192 | return function (node) {
|
52193 | return function (a, b) {
|
52194 | var aobj = {
|
52195 | key: a,
|
52196 | value: node[a]
|
52197 | };
|
52198 | var bobj = {
|
52199 | key: b,
|
52200 | value: node[b]
|
52201 | };
|
52202 | return f(aobj, bobj);
|
52203 | };
|
52204 | };
|
52205 | }(opts.cmp);
|
52206 |
|
52207 | var seen = [];
|
52208 | return function stringify(parent, key, node, level) {
|
52209 | var indent = space ? '\n' + new Array(level + 1).join(space) : '';
|
52210 | var colonSeparator = space ? ': ' : ':';
|
52211 |
|
52212 | if (node && node.toJSON && typeof node.toJSON === 'function') {
|
52213 | node = node.toJSON();
|
52214 | }
|
52215 |
|
52216 | node = replacer.call(parent, key, node);
|
52217 |
|
52218 | if (node === undefined) {
|
52219 | return;
|
52220 | }
|
52221 |
|
52222 | if (typeof node !== 'object' || node === null) {
|
52223 | return json$2.stringify(node);
|
52224 | }
|
52225 |
|
52226 | if (isArray$2(node)) {
|
52227 | var out = [];
|
52228 |
|
52229 | for (var i = 0; i < node.length; i++) {
|
52230 | var item = stringify(node, i, node[i], level + 1) || json$2.stringify(null);
|
52231 | out.push(indent + space + item);
|
52232 | }
|
52233 |
|
52234 | return '[' + out.join(',') + indent + ']';
|
52235 | } else {
|
52236 | if (seen.indexOf(node) !== -1) {
|
52237 | if (cycles) return json$2.stringify('__cycle__');
|
52238 | throw new TypeError('Converting circular structure to JSON');
|
52239 | } else seen.push(node);
|
52240 |
|
52241 | var keys = objectKeys(node).sort(cmp && cmp(node));
|
52242 | var out = [];
|
52243 |
|
52244 | for (var i = 0; i < keys.length; i++) {
|
52245 | var key = keys[i];
|
52246 | var value = stringify(node, key, node[key], level + 1);
|
52247 | if (!value) continue;
|
52248 | var keyValue = json$2.stringify(key) + colonSeparator + value;
|
52249 | out.push(indent + space + keyValue);
|
52250 | }
|
52251 |
|
52252 | seen.splice(seen.indexOf(node), 1);
|
52253 | return '{' + out.join(',') + indent + '}';
|
52254 | }
|
52255 | }({
|
52256 | '': obj
|
52257 | }, '', obj, 0);
|
52258 | };
|
52259 |
|
52260 | var isArray$2 = Array.isArray || function (x) {
|
52261 | return {}.toString.call(x) === '[object Array]';
|
52262 | };
|
52263 |
|
52264 | var objectKeys = Object.keys || function (obj) {
|
52265 | var has = Object.prototype.hasOwnProperty || function () {
|
52266 | return true;
|
52267 | };
|
52268 |
|
52269 | var keys = [];
|
52270 |
|
52271 | for (var key in obj) {
|
52272 | if (has.call(obj, key)) keys.push(key);
|
52273 | }
|
52274 |
|
52275 | return keys;
|
52276 | };
|
52277 |
|
52278 | const preserveCamelCase = string => {
|
52279 | let isLastCharLower = false;
|
52280 | let isLastCharUpper = false;
|
52281 | let isLastLastCharUpper = false;
|
52282 |
|
52283 | for (let i = 0; i < string.length; i++) {
|
52284 | const character = string[i];
|
52285 |
|
52286 | if (isLastCharLower && /[a-zA-Z]/.test(character) && character.toUpperCase() === character) {
|
52287 | string = string.slice(0, i) + '-' + string.slice(i);
|
52288 | isLastCharLower = false;
|
52289 | isLastLastCharUpper = isLastCharUpper;
|
52290 | isLastCharUpper = true;
|
52291 | i++;
|
52292 | } else if (isLastCharUpper && isLastLastCharUpper && /[a-zA-Z]/.test(character) && character.toLowerCase() === character) {
|
52293 | string = string.slice(0, i - 1) + '-' + string.slice(i - 1);
|
52294 | isLastLastCharUpper = isLastCharUpper;
|
52295 | isLastCharUpper = false;
|
52296 | isLastCharLower = true;
|
52297 | } else {
|
52298 | isLastCharLower = character.toLowerCase() === character && character.toUpperCase() !== character;
|
52299 | isLastLastCharUpper = isLastCharUpper;
|
52300 | isLastCharUpper = character.toUpperCase() === character && character.toLowerCase() !== character;
|
52301 | }
|
52302 | }
|
52303 |
|
52304 | return string;
|
52305 | };
|
52306 |
|
52307 | const camelCase = (input, options) => {
|
52308 | if (!(typeof input === 'string' || Array.isArray(input))) {
|
52309 | throw new TypeError('Expected the input to be `string | string[]`');
|
52310 | }
|
52311 |
|
52312 | options = Object.assign({
|
52313 | pascalCase: false
|
52314 | }, options);
|
52315 |
|
52316 | const postProcess = x => options.pascalCase ? x.charAt(0).toUpperCase() + x.slice(1) : x;
|
52317 |
|
52318 | if (Array.isArray(input)) {
|
52319 | input = input.map(x => x.trim()).filter(x => x.length).join('-');
|
52320 | } else {
|
52321 | input = input.trim();
|
52322 | }
|
52323 |
|
52324 | if (input.length === 0) {
|
52325 | return '';
|
52326 | }
|
52327 |
|
52328 | if (input.length === 1) {
|
52329 | return options.pascalCase ? input.toUpperCase() : input.toLowerCase();
|
52330 | }
|
52331 |
|
52332 | const hasUpperCase = input !== input.toLowerCase();
|
52333 |
|
52334 | if (hasUpperCase) {
|
52335 | input = preserveCamelCase(input);
|
52336 | }
|
52337 |
|
52338 | input = input.replace(/^[_.\- ]+/, '').toLowerCase().replace(/[_.\- ]+(\w|$)/g, (_, p1) => p1.toUpperCase()).replace(/\d+(\w|$)/g, m => m.toUpperCase());
|
52339 | return postProcess(input);
|
52340 | };
|
52341 |
|
52342 | var camelcase = camelCase;
|
52343 |
|
52344 | var default_1$3 = camelCase;
|
52345 | camelcase.default = default_1$3;
|
52346 |
|
52347 |
|
52348 |
|
52349 |
|
52350 |
|
52351 |
|
52352 |
|
52353 |
|
52354 | var dashify = (str, options) => {
|
52355 | if (typeof str !== 'string') throw new TypeError('expected a string');
|
52356 | return str.trim().replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\W/g, m => /[À-ž]/.test(m) ? m : '-').replace(/^-+|-+$/g, '').replace(/-{2,}/g, m => options && options.condense ? '-' : m).toLowerCase();
|
52357 | };
|
52358 |
|
52359 | var defineProperty$1 = function () {
|
52360 | try {
|
52361 | var func = _getNative(Object, 'defineProperty');
|
52362 | func({}, '', {});
|
52363 | return func;
|
52364 | } catch (e) {}
|
52365 | }();
|
52366 |
|
52367 | var _defineProperty = defineProperty$1;
|
52368 |
|
52369 |
|
52370 |
|
52371 |
|
52372 |
|
52373 |
|
52374 |
|
52375 |
|
52376 |
|
52377 |
|
52378 |
|
52379 | function baseAssignValue(object, key, value) {
|
52380 | if (key == '__proto__' && _defineProperty) {
|
52381 | _defineProperty(object, key, {
|
52382 | 'configurable': true,
|
52383 | 'enumerable': true,
|
52384 | 'value': value,
|
52385 | 'writable': true
|
52386 | });
|
52387 | } else {
|
52388 | object[key] = value;
|
52389 | }
|
52390 | }
|
52391 |
|
52392 | var _baseAssignValue = baseAssignValue;
|
52393 |
|
52394 |
|
52395 |
|
52396 | var objectProto$c = Object.prototype;
|
52397 |
|
52398 |
|
52399 | var hasOwnProperty$b = objectProto$c.hasOwnProperty;
|
52400 |
|
52401 |
|
52402 |
|
52403 |
|
52404 |
|
52405 |
|
52406 |
|
52407 |
|
52408 |
|
52409 |
|
52410 |
|
52411 | function assignValue(object, key, value) {
|
52412 | var objValue = object[key];
|
52413 |
|
52414 | if (!(hasOwnProperty$b.call(object, key) && eq_1(objValue, value)) || value === undefined && !(key in object)) {
|
52415 | _baseAssignValue(object, key, value);
|
52416 | }
|
52417 | }
|
52418 |
|
52419 | var _assignValue = assignValue;
|
52420 |
|
52421 |
|
52422 |
|
52423 |
|
52424 |
|
52425 |
|
52426 |
|
52427 |
|
52428 |
|
52429 |
|
52430 |
|
52431 |
|
52432 | function baseSet(object, path, value, customizer) {
|
52433 | if (!isObject_1(object)) {
|
52434 | return object;
|
52435 | }
|
52436 |
|
52437 | path = _castPath(path, object);
|
52438 | var index = -1,
|
52439 | length = path.length,
|
52440 | lastIndex = length - 1,
|
52441 | nested = object;
|
52442 |
|
52443 | while (nested != null && ++index < length) {
|
52444 | var key = _toKey(path[index]),
|
52445 | newValue = value;
|
52446 |
|
52447 | if (index != lastIndex) {
|
52448 | var objValue = nested[key];
|
52449 | newValue = customizer ? customizer(objValue, key, nested) : undefined;
|
52450 |
|
52451 | if (newValue === undefined) {
|
52452 | newValue = isObject_1(objValue) ? objValue : _isIndex(path[index + 1]) ? [] : {};
|
52453 | }
|
52454 | }
|
52455 |
|
52456 | _assignValue(nested, key, newValue);
|
52457 | nested = nested[key];
|
52458 | }
|
52459 |
|
52460 | return object;
|
52461 | }
|
52462 |
|
52463 | var _baseSet = baseSet;
|
52464 |
|
52465 |
|
52466 |
|
52467 |
|
52468 |
|
52469 |
|
52470 |
|
52471 |
|
52472 |
|
52473 |
|
52474 |
|
52475 | function basePickBy(object, paths, predicate) {
|
52476 | var index = -1,
|
52477 | length = paths.length,
|
52478 | result = {};
|
52479 |
|
52480 | while (++index < length) {
|
52481 | var path = paths[index],
|
52482 | value = _baseGet(object, path);
|
52483 |
|
52484 | if (predicate(value, path)) {
|
52485 | _baseSet(result, _castPath(path, object), value);
|
52486 | }
|
52487 | }
|
52488 |
|
52489 | return result;
|
52490 | }
|
52491 |
|
52492 | var _basePickBy = basePickBy;
|
52493 |
|
52494 |
|
52495 |
|
52496 |
|
52497 |
|
52498 |
|
52499 |
|
52500 |
|
52501 |
|
52502 |
|
52503 |
|
52504 | function basePick(object, paths) {
|
52505 | return _basePickBy(object, paths, function (value, path) {
|
52506 | return hasIn_1(object, path);
|
52507 | });
|
52508 | }
|
52509 |
|
52510 | var _basePick = basePick;
|
52511 |
|
52512 |
|
52513 |
|
52514 | var spreadableSymbol = _Symbol ? _Symbol.isConcatSpreadable : undefined;
|
52515 |
|
52516 |
|
52517 |
|
52518 |
|
52519 |
|
52520 |
|
52521 |
|
52522 |
|
52523 | function isFlattenable(value) {
|
52524 | return isArray_1(value) || isArguments_1(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
|
52525 | }
|
52526 |
|
52527 | var _isFlattenable = isFlattenable;
|
52528 |
|
52529 |
|
52530 |
|
52531 |
|
52532 |
|
52533 |
|
52534 |
|
52535 |
|
52536 |
|
52537 |
|
52538 |
|
52539 |
|
52540 |
|
52541 | function baseFlatten(array, depth, predicate, isStrict, result) {
|
52542 | var index = -1,
|
52543 | length = array.length;
|
52544 | predicate || (predicate = _isFlattenable);
|
52545 | result || (result = []);
|
52546 |
|
52547 | while (++index < length) {
|
52548 | var value = array[index];
|
52549 |
|
52550 | if (depth > 0 && predicate(value)) {
|
52551 | if (depth > 1) {
|
52552 |
|
52553 | baseFlatten(value, depth - 1, predicate, isStrict, result);
|
52554 | } else {
|
52555 | _arrayPush(result, value);
|
52556 | }
|
52557 | } else if (!isStrict) {
|
52558 | result[result.length] = value;
|
52559 | }
|
52560 | }
|
52561 |
|
52562 | return result;
|
52563 | }
|
52564 |
|
52565 | var _baseFlatten = baseFlatten;
|
52566 |
|
52567 |
|
52568 |
|
52569 |
|
52570 |
|
52571 |
|
52572 |
|
52573 |
|
52574 |
|
52575 |
|
52576 |
|
52577 |
|
52578 |
|
52579 |
|
52580 |
|
52581 |
|
52582 | function flatten(array) {
|
52583 | var length = array == null ? 0 : array.length;
|
52584 | return length ? _baseFlatten(array, 1) : [];
|
52585 | }
|
52586 |
|
52587 | var flatten_1 = flatten;
|
52588 |
|
52589 |
|
52590 |
|
52591 |
|
52592 |
|
52593 |
|
52594 |
|
52595 |
|
52596 |
|
52597 |
|
52598 |
|
52599 | function apply(func, thisArg, args) {
|
52600 | switch (args.length) {
|
52601 | case 0:
|
52602 | return func.call(thisArg);
|
52603 |
|
52604 | case 1:
|
52605 | return func.call(thisArg, args[0]);
|
52606 |
|
52607 | case 2:
|
52608 | return func.call(thisArg, args[0], args[1]);
|
52609 |
|
52610 | case 3:
|
52611 | return func.call(thisArg, args[0], args[1], args[2]);
|
52612 | }
|
52613 |
|
52614 | return func.apply(thisArg, args);
|
52615 | }
|
52616 |
|
52617 | var _apply = apply;
|
52618 |
|
52619 |
|
52620 |
|
52621 | var nativeMax = Math.max;
|
52622 |
|
52623 |
|
52624 |
|
52625 |
|
52626 |
|
52627 |
|
52628 |
|
52629 |
|
52630 |
|
52631 |
|
52632 | function overRest(func, start, transform) {
|
52633 | start = nativeMax(start === undefined ? func.length - 1 : start, 0);
|
52634 | return function () {
|
52635 | var args = arguments,
|
52636 | index = -1,
|
52637 | length = nativeMax(args.length - start, 0),
|
52638 | array = Array(length);
|
52639 |
|
52640 | while (++index < length) {
|
52641 | array[index] = args[start + index];
|
52642 | }
|
52643 |
|
52644 | index = -1;
|
52645 | var otherArgs = Array(start + 1);
|
52646 |
|
52647 | while (++index < start) {
|
52648 | otherArgs[index] = args[index];
|
52649 | }
|
52650 |
|
52651 | otherArgs[start] = transform(array);
|
52652 | return _apply(func, this, otherArgs);
|
52653 | };
|
52654 | }
|
52655 |
|
52656 | var _overRest = overRest;
|
52657 |
|
52658 |
|
52659 |
|
52660 |
|
52661 |
|
52662 |
|
52663 |
|
52664 |
|
52665 |
|
52666 |
|
52667 |
|
52668 |
|
52669 |
|
52670 |
|
52671 |
|
52672 |
|
52673 |
|
52674 |
|
52675 |
|
52676 |
|
52677 | function constant(value) {
|
52678 | return function () {
|
52679 | return value;
|
52680 | };
|
52681 | }
|
52682 |
|
52683 | var constant_1 = constant;
|
52684 |
|
52685 |
|
52686 |
|
52687 |
|
52688 |
|
52689 |
|
52690 |
|
52691 |
|
52692 |
|
52693 |
|
52694 | var baseSetToString = !_defineProperty ? identity_1 : function (func, string) {
|
52695 | return _defineProperty(func, 'toString', {
|
52696 | 'configurable': true,
|
52697 | 'enumerable': false,
|
52698 | 'value': constant_1(string),
|
52699 | 'writable': true
|
52700 | });
|
52701 | };
|
52702 | var _baseSetToString = baseSetToString;
|
52703 |
|
52704 |
|
52705 | var HOT_COUNT = 800,
|
52706 | HOT_SPAN = 16;
|
52707 |
|
52708 |
|
52709 | var nativeNow = Date.now;
|
52710 |
|
52711 |
|
52712 |
|
52713 |
|
52714 |
|
52715 |
|
52716 |
|
52717 |
|
52718 |
|
52719 |
|
52720 | function shortOut(func) {
|
52721 | var count = 0,
|
52722 | lastCalled = 0;
|
52723 | return function () {
|
52724 | var stamp = nativeNow(),
|
52725 | remaining = HOT_SPAN - (stamp - lastCalled);
|
52726 | lastCalled = stamp;
|
52727 |
|
52728 | if (remaining > 0) {
|
52729 | if (++count >= HOT_COUNT) {
|
52730 | return arguments[0];
|
52731 | }
|
52732 | } else {
|
52733 | count = 0;
|
52734 | }
|
52735 |
|
52736 | return func.apply(undefined, arguments);
|
52737 | };
|
52738 | }
|
52739 |
|
52740 | var _shortOut = shortOut;
|
52741 |
|
52742 |
|
52743 |
|
52744 |
|
52745 |
|
52746 |
|
52747 |
|
52748 |
|
52749 |
|
52750 |
|
52751 | var setToString = _shortOut(_baseSetToString);
|
52752 | var _setToString = setToString;
|
52753 |
|
52754 |
|
52755 |
|
52756 |
|
52757 |
|
52758 |
|
52759 |
|
52760 |
|
52761 |
|
52762 | function flatRest(func) {
|
52763 | return _setToString(_overRest(func, undefined, flatten_1), func + '');
|
52764 | }
|
52765 |
|
52766 | var _flatRest = flatRest;
|
52767 |
|
52768 |
|
52769 |
|
52770 |
|
52771 |
|
52772 |
|
52773 |
|
52774 |
|
52775 |
|
52776 |
|
52777 |
|
52778 |
|
52779 |
|
52780 |
|
52781 |
|
52782 |
|
52783 |
|
52784 |
|
52785 |
|
52786 | var pick = _flatRest(function (object, paths) {
|
52787 | return object == null ? {} : _basePick(object, paths);
|
52788 | });
|
52789 | var pick_1 = pick;
|
52790 |
|
52791 |
|
52792 |
|
52793 | var objectProto$d = Object.prototype;
|
52794 |
|
52795 |
|
52796 | var hasOwnProperty$c = objectProto$d.hasOwnProperty;
|
52797 |
|
52798 |
|
52799 |
|
52800 |
|
52801 |
|
52802 |
|
52803 |
|
52804 |
|
52805 |
|
52806 |
|
52807 |
|
52808 |
|
52809 |
|
52810 |
|
52811 |
|
52812 |
|
52813 |
|
52814 |
|
52815 |
|
52816 |
|
52817 |
|
52818 |
|
52819 |
|
52820 |
|
52821 | var groupBy = _createAggregator(function (result, value, key) {
|
52822 | if (hasOwnProperty$c.call(result, key)) {
|
52823 | result[key].push(value);
|
52824 | } else {
|
52825 | _baseAssignValue(result, key, [value]);
|
52826 | }
|
52827 | });
|
52828 | var groupBy_1 = groupBy;
|
52829 |
|
52830 | var minimist = function (args, opts) {
|
52831 | if (!opts) opts = {};
|
52832 | var flags = {
|
52833 | bools: {},
|
52834 | strings: {},
|
52835 | unknownFn: null
|
52836 | };
|
52837 |
|
52838 | if (typeof opts['unknown'] === 'function') {
|
52839 | flags.unknownFn = opts['unknown'];
|
52840 | }
|
52841 |
|
52842 | if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
|
52843 | flags.allBools = true;
|
52844 | } else {
|
52845 | [].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
|
52846 | flags.bools[key] = true;
|
52847 | });
|
52848 | }
|
52849 |
|
52850 | var aliases = {};
|
52851 | Object.keys(opts.alias || {}).forEach(function (key) {
|
52852 | aliases[key] = [].concat(opts.alias[key]);
|
52853 | aliases[key].forEach(function (x) {
|
52854 | aliases[x] = [key].concat(aliases[key].filter(function (y) {
|
52855 | return x !== y;
|
52856 | }));
|
52857 | });
|
52858 | });
|
52859 | [].concat(opts.string).filter(Boolean).forEach(function (key) {
|
52860 | flags.strings[key] = true;
|
52861 |
|
52862 | if (aliases[key]) {
|
52863 | flags.strings[aliases[key]] = true;
|
52864 | }
|
52865 | });
|
52866 | var defaults = opts['default'] || {};
|
52867 | var argv = {
|
52868 | _: []
|
52869 | };
|
52870 | Object.keys(flags.bools).forEach(function (key) {
|
52871 | setArg(key, defaults[key] === undefined ? false : defaults[key]);
|
52872 | });
|
52873 | var notFlags = [];
|
52874 |
|
52875 | if (args.indexOf('--') !== -1) {
|
52876 | notFlags = args.slice(args.indexOf('--') + 1);
|
52877 | args = args.slice(0, args.indexOf('--'));
|
52878 | }
|
52879 |
|
52880 | function argDefined(key, arg) {
|
52881 | return flags.allBools && /^--[^=]+$/.test(arg) || flags.strings[key] || flags.bools[key] || aliases[key];
|
52882 | }
|
52883 |
|
52884 | function setArg(key, val, arg) {
|
52885 | if (arg && flags.unknownFn && !argDefined(key, arg)) {
|
52886 | if (flags.unknownFn(arg) === false) return;
|
52887 | }
|
52888 |
|
52889 | var value = !flags.strings[key] && isNumber$2(val) ? Number(val) : val;
|
52890 | setKey(argv, key.split('.'), value);
|
52891 | (aliases[key] || []).forEach(function (x) {
|
52892 | setKey(argv, x.split('.'), value);
|
52893 | });
|
52894 | }
|
52895 |
|
52896 | function setKey(obj, keys, value) {
|
52897 | var o = obj;
|
52898 |
|
52899 | for (var i = 0; i < keys.length - 1; i++) {
|
52900 | var key = keys[i];
|
52901 | if (key === '__proto__') return;
|
52902 | if (o[key] === undefined) o[key] = {};
|
52903 | if (o[key] === Object.prototype || o[key] === Number.prototype || o[key] === String.prototype) o[key] = {};
|
52904 | if (o[key] === Array.prototype) o[key] = [];
|
52905 | o = o[key];
|
52906 | }
|
52907 |
|
52908 | var key = keys[keys.length - 1];
|
52909 | if (key === '__proto__') return;
|
52910 | if (o === Object.prototype || o === Number.prototype || o === String.prototype) o = {};
|
52911 | if (o === Array.prototype) o = [];
|
52912 |
|
52913 | if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') {
|
52914 | o[key] = value;
|
52915 | } else if (Array.isArray(o[key])) {
|
52916 | o[key].push(value);
|
52917 | } else {
|
52918 | o[key] = [o[key], value];
|
52919 | }
|
52920 | }
|
52921 |
|
52922 | function aliasIsBoolean(key) {
|
52923 | return aliases[key].some(function (x) {
|
52924 | return flags.bools[x];
|
52925 | });
|
52926 | }
|
52927 |
|
52928 | for (var i = 0; i < args.length; i++) {
|
52929 | var arg = args[i];
|
52930 |
|
52931 | if (/^--.+=/.test(arg)) {
|
52932 |
|
52933 |
|
52934 |
|
52935 | var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
|
52936 | var key = m[1];
|
52937 | var value = m[2];
|
52938 |
|
52939 | if (flags.bools[key]) {
|
52940 | value = value !== 'false';
|
52941 | }
|
52942 |
|
52943 | setArg(key, value, arg);
|
52944 | } else if (/^--no-.+/.test(arg)) {
|
52945 | var key = arg.match(/^--no-(.+)/)[1];
|
52946 | setArg(key, false, arg);
|
52947 | } else if (/^--.+/.test(arg)) {
|
52948 | var key = arg.match(/^--(.+)/)[1];
|
52949 | var next = args[i + 1];
|
52950 |
|
52951 | if (next !== undefined && !/^-/.test(next) && !flags.bools[key] && !flags.allBools && (aliases[key] ? !aliasIsBoolean(key) : true)) {
|
52952 | setArg(key, next, arg);
|
52953 | i++;
|
52954 | } else if (/^(true|false)$/.test(next)) {
|
52955 | setArg(key, next === 'true', arg);
|
52956 | i++;
|
52957 | } else {
|
52958 | setArg(key, flags.strings[key] ? '' : true, arg);
|
52959 | }
|
52960 | } else if (/^-[^-]+/.test(arg)) {
|
52961 | var letters = arg.slice(1, -1).split('');
|
52962 | var broken = false;
|
52963 |
|
52964 | for (var j = 0; j < letters.length; j++) {
|
52965 | var next = arg.slice(j + 2);
|
52966 |
|
52967 | if (next === '-') {
|
52968 | setArg(letters[j], next, arg);
|
52969 | continue;
|
52970 | }
|
52971 |
|
52972 | if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
|
52973 | setArg(letters[j], next.split('=')[1], arg);
|
52974 | broken = true;
|
52975 | break;
|
52976 | }
|
52977 |
|
52978 | if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
|
52979 | setArg(letters[j], next, arg);
|
52980 | broken = true;
|
52981 | break;
|
52982 | }
|
52983 |
|
52984 | if (letters[j + 1] && letters[j + 1].match(/\W/)) {
|
52985 | setArg(letters[j], arg.slice(j + 2), arg);
|
52986 | broken = true;
|
52987 | break;
|
52988 | } else {
|
52989 | setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
|
52990 | }
|
52991 | }
|
52992 |
|
52993 | var key = arg.slice(-1)[0];
|
52994 |
|
52995 | if (!broken && key !== '-') {
|
52996 | if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !flags.bools[key] && (aliases[key] ? !aliasIsBoolean(key) : true)) {
|
52997 | setArg(key, args[i + 1], arg);
|
52998 | i++;
|
52999 | } else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
|
53000 | setArg(key, args[i + 1] === 'true', arg);
|
53001 | i++;
|
53002 | } else {
|
53003 | setArg(key, flags.strings[key] ? '' : true, arg);
|
53004 | }
|
53005 | }
|
53006 | } else {
|
53007 | if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
|
53008 | argv._.push(flags.strings['_'] || !isNumber$2(arg) ? arg : Number(arg));
|
53009 | }
|
53010 |
|
53011 | if (opts.stopEarly) {
|
53012 | argv._.push.apply(argv._, args.slice(i + 1));
|
53013 |
|
53014 | break;
|
53015 | }
|
53016 | }
|
53017 | }
|
53018 |
|
53019 | Object.keys(defaults).forEach(function (key) {
|
53020 | if (!hasKey$1(argv, key.split('.'))) {
|
53021 | setKey(argv, key.split('.'), defaults[key]);
|
53022 | (aliases[key] || []).forEach(function (x) {
|
53023 | setKey(argv, x.split('.'), defaults[key]);
|
53024 | });
|
53025 | }
|
53026 | });
|
53027 |
|
53028 | if (opts['--']) {
|
53029 | argv['--'] = new Array();
|
53030 | notFlags.forEach(function (key) {
|
53031 | argv['--'].push(key);
|
53032 | });
|
53033 | } else {
|
53034 | notFlags.forEach(function (key) {
|
53035 | argv._.push(key);
|
53036 | });
|
53037 | }
|
53038 |
|
53039 | return argv;
|
53040 | };
|
53041 |
|
53042 | function hasKey$1(obj, keys) {
|
53043 | var o = obj;
|
53044 | keys.slice(0, -1).forEach(function (key) {
|
53045 | o = o[key] || {};
|
53046 | });
|
53047 | var key = keys[keys.length - 1];
|
53048 | return key in o;
|
53049 | }
|
53050 |
|
53051 | function isNumber$2(x) {
|
53052 | if (typeof x === 'number') return true;
|
53053 | if (/^0x[0-9a-f]+$/i.test(x)) return true;
|
53054 | return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
|
53055 | }
|
53056 |
|
53057 | const PLACEHOLDER = null;
|
53058 |
|
53059 |
|
53060 |
|
53061 |
|
53062 | var minimist_1 = function (args, options) {
|
53063 | const boolean = options.boolean || [];
|
53064 | const defaults = options.default || {};
|
53065 | const booleanWithoutDefault = boolean.filter(key => !(key in defaults));
|
53066 | const newDefaults = Object.assign({}, defaults, {}, fromPairs_1(booleanWithoutDefault.map(key => [key, PLACEHOLDER])));
|
53067 | const parsed = minimist(args, Object.assign({}, options, {
|
53068 | default: newDefaults
|
53069 | }));
|
53070 | return fromPairs_1(Object.entries(parsed).filter(([, value]) => value !== PLACEHOLDER));
|
53071 | };
|
53072 |
|
53073 |
|
53074 |
|
53075 |
|
53076 |
|
53077 |
|
53078 |
|
53079 |
|
53080 | function* expandPatterns(context) {
|
53081 | const cwd = process.cwd();
|
53082 | const seen = new Set();
|
53083 | let noResults = true;
|
53084 |
|
53085 | for (const pathOrError of expandPatternsInternal(context)) {
|
53086 | noResults = false;
|
53087 |
|
53088 | if (typeof pathOrError !== "string") {
|
53089 | yield pathOrError;
|
53090 | continue;
|
53091 | }
|
53092 |
|
53093 | const relativePath = path$2.relative(cwd, pathOrError);
|
53094 |
|
53095 | if (seen.has(relativePath)) {
|
53096 | continue;
|
53097 | }
|
53098 |
|
53099 | seen.add(relativePath);
|
53100 | yield relativePath;
|
53101 | }
|
53102 |
|
53103 | if (noResults) {
|
53104 |
|
53105 | yield {
|
53106 | error: `No matching files. Patterns: ${context.filePatterns.join(" ")}`
|
53107 | };
|
53108 | }
|
53109 | }
|
53110 |
|
53111 |
|
53112 |
|
53113 |
|
53114 |
|
53115 | function* expandPatternsInternal(context) {
|
53116 |
|
53117 | const silentlyIgnoredDirs = {
|
53118 | ".git": true,
|
53119 | ".svn": true,
|
53120 | ".hg": true,
|
53121 | node_modules: context.argv["with-node-modules"] !== true
|
53122 | };
|
53123 | const globOptions = {
|
53124 | dot: true,
|
53125 | ignore: Object.keys(silentlyIgnoredDirs).filter(dir => silentlyIgnoredDirs[dir]).map(dir => "**/" + dir)
|
53126 | };
|
53127 | let supportedFilesGlob;
|
53128 | const cwd = process.cwd();
|
53129 |
|
53130 |
|
53131 | const entries = [];
|
53132 |
|
53133 | for (const pattern of context.filePatterns) {
|
53134 | const absolutePath = path$2.resolve(cwd, pattern);
|
53135 |
|
53136 | if (containsIgnoredPathSegment(absolutePath, cwd, silentlyIgnoredDirs)) {
|
53137 | continue;
|
53138 | }
|
53139 |
|
53140 | const stat = statSafeSync(absolutePath);
|
53141 |
|
53142 | if (stat) {
|
53143 | if (stat.isFile()) {
|
53144 | entries.push({
|
53145 | type: "file",
|
53146 | glob: escapePathForGlob(fixWindowsSlashes(pattern)),
|
53147 | input: pattern
|
53148 | });
|
53149 | } else if (stat.isDirectory()) {
|
53150 | entries.push({
|
53151 | type: "dir",
|
53152 | glob: escapePathForGlob(fixWindowsSlashes(pattern)) + "/" + getSupportedFilesGlob(),
|
53153 | input: pattern
|
53154 | });
|
53155 | }
|
53156 | } else if (pattern[0] === "!") {
|
53157 |
|
53158 | globOptions.ignore.push(fixWindowsSlashes(pattern.slice(1)));
|
53159 | } else {
|
53160 | entries.push({
|
53161 | type: "glob",
|
53162 | glob: fixWindowsSlashes(pattern),
|
53163 | input: pattern
|
53164 | });
|
53165 | }
|
53166 | }
|
53167 |
|
53168 | for (const {
|
53169 | type,
|
53170 | glob,
|
53171 | input
|
53172 | } of entries) {
|
53173 | let result;
|
53174 |
|
53175 | try {
|
53176 | result = out$3.sync(glob, globOptions);
|
53177 | } catch ({
|
53178 | message
|
53179 | }) {
|
53180 | yield {
|
53181 | error: `${errorMessages.globError[type]}: ${input}\n${message}`
|
53182 | };
|
53183 | continue;
|
53184 | }
|
53185 |
|
53186 | if (result.length === 0) {
|
53187 | yield {
|
53188 | error: `${errorMessages.emptyResults[type]}: "${input}".`
|
53189 | };
|
53190 | } else {
|
53191 | yield* sortPaths(result);
|
53192 | }
|
53193 | }
|
53194 |
|
53195 | function getSupportedFilesGlob() {
|
53196 | if (!supportedFilesGlob) {
|
53197 | const extensions = flatten_1(context.languages.map(lang => lang.extensions || []));
|
53198 | const filenames = flatten_1(context.languages.map(lang => lang.filenames || []));
|
53199 | supportedFilesGlob = `**/{${extensions.map(ext => "*" + (ext[0] === "." ? ext : "." + ext)).concat(filenames)}}`;
|
53200 | }
|
53201 |
|
53202 | return supportedFilesGlob;
|
53203 | }
|
53204 | }
|
53205 |
|
53206 | const errorMessages = {
|
53207 | globError: {
|
53208 | file: "Unable to resolve file",
|
53209 | dir: "Unable to expand directory",
|
53210 | glob: "Unable to expand glob pattern"
|
53211 | },
|
53212 | emptyResults: {
|
53213 | file: "Explicitly specified file was ignored due to negative glob patterns",
|
53214 | dir: "No supported files were found in the directory",
|
53215 | glob: "No files matching the pattern were found"
|
53216 | }
|
53217 | };
|
53218 |
|
53219 |
|
53220 |
|
53221 |
|
53222 |
|
53223 |
|
53224 | function containsIgnoredPathSegment(absolutePath, cwd, ignoredDirectories) {
|
53225 | return path$2.relative(cwd, absolutePath).split(path$2.sep).some(dir => ignoredDirectories[dir]);
|
53226 | }
|
53227 |
|
53228 |
|
53229 |
|
53230 |
|
53231 |
|
53232 | function sortPaths(paths) {
|
53233 | return paths.sort((a, b) => a.localeCompare(b));
|
53234 | }
|
53235 |
|
53236 |
|
53237 |
|
53238 |
|
53239 |
|
53240 |
|
53241 |
|
53242 | function statSafeSync(filePath) {
|
53243 | try {
|
53244 | return fs$3.statSync(filePath);
|
53245 | } catch (error) {
|
53246 |
|
53247 | if (error.code !== "ENOENT") {
|
53248 | throw error;
|
53249 | }
|
53250 | }
|
53251 | }
|
53252 |
|
53253 |
|
53254 |
|
53255 |
|
53256 |
|
53257 |
|
53258 |
|
53259 |
|
53260 | function escapePathForGlob(path) {
|
53261 | return out$3.escapePath(path.replace(/\\/g, "\0")
|
53262 | ).replace(/\\!/g, "@(!)")
|
53263 | .replace(/\0/g, "@(\\\\)");
|
53264 | }
|
53265 |
|
53266 | const isWindows = path$2.sep === "\\";
|
53267 |
|
53268 |
|
53269 |
|
53270 |
|
53271 |
|
53272 |
|
53273 |
|
53274 |
|
53275 | function fixWindowsSlashes(pattern) {
|
53276 | return isWindows ? pattern.replace(/\\/g, "/") : pattern;
|
53277 | }
|
53278 |
|
53279 | var expandPatterns_1 = expandPatterns;
|
53280 |
|
53281 | const categoryOrder = [coreOptions.CATEGORY_OUTPUT, coreOptions.CATEGORY_FORMAT, coreOptions.CATEGORY_CONFIG, coreOptions.CATEGORY_EDITOR, coreOptions.CATEGORY_OTHER];
|
53282 |
|
53283 |
|
53284 |
|
53285 |
|
53286 |
|
53287 |
|
53288 |
|
53289 |
|
53290 |
|
53291 |
|
53292 |
|
53293 |
|
53294 |
|
53295 |
|
53296 |
|
53297 |
|
53298 |
|
53299 |
|
53300 |
|
53301 |
|
53302 |
|
53303 |
|
53304 |
|
53305 |
|
53306 |
|
53307 |
|
53308 |
|
53309 |
|
53310 |
|
53311 |
|
53312 |
|
53313 |
|
53314 |
|
53315 |
|
53316 |
|
53317 |
|
53318 |
|
53319 |
|
53320 |
|
53321 |
|
53322 |
|
53323 |
|
53324 |
|
53325 |
|
53326 |
|
53327 |
|
53328 |
|
53329 |
|
53330 |
|
53331 |
|
53332 |
|
53333 |
|
53334 |
|
53335 |
|
53336 |
|
53337 |
|
53338 |
|
53339 |
|
53340 |
|
53341 | const options$8 = {
|
53342 | check: {
|
53343 | type: "boolean",
|
53344 | category: coreOptions.CATEGORY_OUTPUT,
|
53345 | alias: "c",
|
53346 | description: dedent_1`
|
53347 | Check if the given files are formatted, print a human-friendly summary
|
53348 | message and paths to unformatted files (see also --list-different).
|
53349 | `
|
53350 | },
|
53351 | color: {
|
53352 |
|
53353 |
|
53354 |
|
53355 |
|
53356 | type: "boolean",
|
53357 | default: true,
|
53358 | description: "Colorize error messages.",
|
53359 | oppositeDescription: "Do not colorize error messages."
|
53360 | },
|
53361 | config: {
|
53362 | type: "path",
|
53363 | category: coreOptions.CATEGORY_CONFIG,
|
53364 | description: "Path to a Prettier configuration file (.prettierrc, package.json, prettier.config.js).",
|
53365 | oppositeDescription: "Do not look for a configuration file.",
|
53366 | exception: value => value === false
|
53367 | },
|
53368 | "config-precedence": {
|
53369 | type: "choice",
|
53370 | category: coreOptions.CATEGORY_CONFIG,
|
53371 | default: "cli-override",
|
53372 | choices: [{
|
53373 | value: "cli-override",
|
53374 | description: "CLI options take precedence over config file"
|
53375 | }, {
|
53376 | value: "file-override",
|
53377 | description: "Config file take precedence over CLI options"
|
53378 | }, {
|
53379 | value: "prefer-file",
|
53380 | description: dedent_1`
|
53381 | If a config file is found will evaluate it and ignore other CLI options.
|
53382 | If no config file is found CLI options will evaluate as normal.
|
53383 | `
|
53384 | }],
|
53385 | description: "Define in which order config files and CLI options should be evaluated."
|
53386 | },
|
53387 | "debug-benchmark": {
|
53388 |
|
53389 | type: "boolean"
|
53390 | },
|
53391 | "debug-check": {
|
53392 |
|
53393 | type: "boolean"
|
53394 | },
|
53395 | "debug-print-doc": {
|
53396 | type: "boolean"
|
53397 | },
|
53398 | "debug-repeat": {
|
53399 |
|
53400 | type: "int",
|
53401 | default: 0
|
53402 | },
|
53403 | editorconfig: {
|
53404 | type: "boolean",
|
53405 | category: coreOptions.CATEGORY_CONFIG,
|
53406 | description: "Take .editorconfig into account when parsing configuration.",
|
53407 | oppositeDescription: "Don't take .editorconfig into account when parsing configuration.",
|
53408 | default: true
|
53409 | },
|
53410 | "find-config-path": {
|
53411 | type: "path",
|
53412 | category: coreOptions.CATEGORY_CONFIG,
|
53413 | description: "Find and print the path to a configuration file for the given input file."
|
53414 | },
|
53415 | "file-info": {
|
53416 | type: "path",
|
53417 | description: dedent_1`
|
53418 | Extract the following info (as JSON) for a given file path. Reported fields:
|
53419 | * ignored (boolean) - true if file path is filtered by --ignore-path
|
53420 | * inferredParser (string | null) - name of parser inferred from file path
|
53421 | `
|
53422 | },
|
53423 | help: {
|
53424 | type: "flag",
|
53425 | alias: "h",
|
53426 | description: dedent_1`
|
53427 | Show CLI usage, or details about the given flag.
|
53428 | Example: --help write
|
53429 | `,
|
53430 | exception: value => value === ""
|
53431 | },
|
53432 | "ignore-path": {
|
53433 | type: "path",
|
53434 | category: coreOptions.CATEGORY_CONFIG,
|
53435 | default: ".prettierignore",
|
53436 | description: "Path to a file with patterns describing files to ignore."
|
53437 | },
|
53438 | "list-different": {
|
53439 | type: "boolean",
|
53440 | category: coreOptions.CATEGORY_OUTPUT,
|
53441 | alias: "l",
|
53442 | description: "Print the names of files that are different from Prettier's formatting (see also --check)."
|
53443 | },
|
53444 | loglevel: {
|
53445 | type: "choice",
|
53446 | description: "What level of logs to report.",
|
53447 | default: "log",
|
53448 | choices: ["silent", "error", "warn", "log", "debug"]
|
53449 | },
|
53450 | "support-info": {
|
53451 | type: "boolean",
|
53452 | description: "Print support information as JSON."
|
53453 | },
|
53454 | version: {
|
53455 | type: "boolean",
|
53456 | alias: "v",
|
53457 | description: "Print Prettier version."
|
53458 | },
|
53459 | "with-node-modules": {
|
53460 | type: "boolean",
|
53461 | category: coreOptions.CATEGORY_CONFIG,
|
53462 | description: "Process files inside 'node_modules' directory."
|
53463 | },
|
53464 | write: {
|
53465 | type: "boolean",
|
53466 | category: coreOptions.CATEGORY_OUTPUT,
|
53467 | description: "Edit files in-place. (Beware!)"
|
53468 | }
|
53469 | };
|
53470 | const usageSummary = dedent_1`
|
53471 | Usage: prettier [options] [file/dir/glob ...]
|
53472 |
|
53473 | By default, output is written to stdout.
|
53474 | Stdin is read if it is piped to Prettier and no files are given.
|
53475 | `;
|
53476 | var constant$1 = {
|
53477 | categoryOrder,
|
53478 | options: options$8,
|
53479 | usageSummary
|
53480 | };
|
53481 |
|
53482 |
|
53483 |
|
53484 |
|
53485 |
|
53486 | var isTty = function isTTY() {
|
53487 | return process.stdout.isTTY && !thirdParty.isCI();
|
53488 | };
|
53489 |
|
53490 | const OPTION_USAGE_THRESHOLD = 25;
|
53491 | const CHOICE_USAGE_MARGIN = 3;
|
53492 | const CHOICE_USAGE_INDENTATION = 2;
|
53493 |
|
53494 | function getOptions(argv, detailedOptions) {
|
53495 | return fromPairs_1(detailedOptions.filter(({
|
53496 | forwardToApi
|
53497 | }) => forwardToApi).map(({
|
53498 | forwardToApi,
|
53499 | name
|
53500 | }) => [forwardToApi, argv[name]]));
|
53501 | }
|
53502 |
|
53503 | function cliifyOptions(object, apiDetailedOptionMap) {
|
53504 | return Object.keys(object || {}).reduce((output, key) => {
|
53505 | const apiOption = apiDetailedOptionMap[key];
|
53506 | const cliKey = apiOption ? apiOption.name : key;
|
53507 | output[dashify(cliKey)] = object[key];
|
53508 | return output;
|
53509 | }, {});
|
53510 | }
|
53511 |
|
53512 | function diff(a, b) {
|
53513 | return require$$0.createTwoFilesPatch("", "", a, b, "", "", {
|
53514 | context: 2
|
53515 | });
|
53516 | }
|
53517 |
|
53518 | function handleError(context, filename, error) {
|
53519 | if (error instanceof errors.UndefinedParserError) {
|
53520 | if (context.argv.write && isTty()) {
|
53521 | readline$1.clearLine(process.stdout, 0);
|
53522 | readline$1.cursorTo(process.stdout, 0, null);
|
53523 | }
|
53524 |
|
53525 | if (!context.argv.check && !context.argv["list-different"]) {
|
53526 | process.exitCode = 2;
|
53527 | }
|
53528 |
|
53529 | context.logger.error(error.message);
|
53530 | return;
|
53531 | }
|
53532 |
|
53533 | if (context.argv.write) {
|
53534 |
|
53535 | process.stdout.write("\n");
|
53536 | }
|
53537 |
|
53538 | const isParseError = Boolean(error && error.loc);
|
53539 | const isValidationError = /^Invalid \S+ value\./.test(error && error.message);
|
53540 |
|
53541 | if (isParseError) {
|
53542 |
|
53543 | context.logger.error(`${filename}: ${String(error)}`);
|
53544 | } else if (isValidationError || error instanceof errors.ConfigError) {
|
53545 |
|
53546 | context.logger.error(error.message);
|
53547 |
|
53548 | process.exit(1);
|
53549 | } else if (error instanceof errors.DebugError) {
|
53550 |
|
53551 | context.logger.error(`${filename}: ${error.message}`);
|
53552 | } else {
|
53553 |
|
53554 | context.logger.error(filename + ": " + (error.stack || error));
|
53555 | }
|
53556 |
|
53557 |
|
53558 | process.exitCode = 2;
|
53559 | }
|
53560 |
|
53561 | function logResolvedConfigPathOrDie(context) {
|
53562 | const configFile = prettier.resolveConfigFile.sync(context.argv["find-config-path"]);
|
53563 |
|
53564 | if (configFile) {
|
53565 | context.logger.log(path$2.relative(process.cwd(), configFile));
|
53566 | } else {
|
53567 | process.exit(1);
|
53568 | }
|
53569 | }
|
53570 |
|
53571 | function logFileInfoOrDie(context) {
|
53572 | const options = {
|
53573 | ignorePath: context.argv["ignore-path"],
|
53574 | withNodeModules: context.argv["with-node-modules"],
|
53575 | plugins: context.argv.plugin,
|
53576 | pluginSearchDirs: context.argv["plugin-search-dir"]
|
53577 | };
|
53578 | context.logger.log(prettier.format(jsonStableStringify(prettier.getFileInfo.sync(context.argv["file-info"], options)), {
|
53579 | parser: "json"
|
53580 | }));
|
53581 | }
|
53582 |
|
53583 | function writeOutput(context, result, options) {
|
53584 |
|
53585 | process.stdout.write(context.argv["debug-check"] ? result.filepath : result.formatted);
|
53586 |
|
53587 | if (options && options.cursorOffset >= 0) {
|
53588 | process.stderr.write(result.cursorOffset + "\n");
|
53589 | }
|
53590 | }
|
53591 |
|
53592 | function listDifferent(context, input, options, filename) {
|
53593 | if (!context.argv.check && !context.argv["list-different"]) {
|
53594 | return;
|
53595 | }
|
53596 |
|
53597 | try {
|
53598 | if (!options.filepath && !options.parser) {
|
53599 | throw new errors.UndefinedParserError("No parser and no file path given, couldn't infer a parser.");
|
53600 | }
|
53601 |
|
53602 | if (!prettier.check(input, options)) {
|
53603 | if (!context.argv.write) {
|
53604 | context.logger.log(filename);
|
53605 | process.exitCode = 1;
|
53606 | }
|
53607 | }
|
53608 | } catch (error) {
|
53609 | context.logger.error(error.message);
|
53610 | }
|
53611 |
|
53612 | return true;
|
53613 | }
|
53614 |
|
53615 | function format$1(context, input, opt) {
|
53616 | if (!opt.parser && !opt.filepath) {
|
53617 | throw new errors.UndefinedParserError("No parser and no file path given, couldn't infer a parser.");
|
53618 | }
|
53619 |
|
53620 | if (context.argv["debug-print-doc"]) {
|
53621 | const doc = prettier.__debug.printToDoc(input, opt);
|
53622 |
|
53623 | return {
|
53624 | formatted: prettier.__debug.formatDoc(doc)
|
53625 | };
|
53626 | }
|
53627 |
|
53628 | if (context.argv["debug-check"]) {
|
53629 | const pp = prettier.format(input, opt);
|
53630 | const pppp = prettier.format(pp, opt);
|
53631 |
|
53632 | if (pp !== pppp) {
|
53633 | throw new errors.DebugError("prettier(input) !== prettier(prettier(input))\n" + diff(pp, pppp));
|
53634 | } else {
|
53635 | const stringify = obj => JSON.stringify(obj, null, 2);
|
53636 |
|
53637 | const ast = stringify(prettier.__debug.parse(input, opt,
|
53638 |
|
53639 | true).ast);
|
53640 | const past = stringify(prettier.__debug.parse(pp, opt,
|
53641 |
|
53642 | true).ast);
|
53643 |
|
53644 |
|
53645 | if (ast !== past) {
|
53646 | const MAX_AST_SIZE = 2097152;
|
53647 |
|
53648 | const astDiff = ast.length > MAX_AST_SIZE || past.length > MAX_AST_SIZE ? "AST diff too large to render" : diff(ast, past);
|
53649 | throw new errors.DebugError("ast(input) !== ast(prettier(input))\n" + astDiff + "\n" + diff(input, pp));
|
53650 | }
|
53651 | }
|
53652 |
|
53653 | return {
|
53654 | formatted: pp,
|
53655 | filepath: opt.filepath || "(stdin)\n"
|
53656 | };
|
53657 | }
|
53658 |
|
53659 |
|
53660 |
|
53661 | if (context.argv["debug-benchmark"]) {
|
53662 | let benchmark;
|
53663 |
|
53664 | try {
|
53665 | benchmark = require("benchmark");
|
53666 | } catch (err) {
|
53667 | context.logger.debug("'--debug-benchmark' requires the 'benchmark' package to be installed.");
|
53668 | process.exit(2);
|
53669 | }
|
53670 |
|
53671 | context.logger.debug("'--debug-benchmark' option found, measuring formatWithCursor with 'benchmark' module.");
|
53672 | const suite = new benchmark.Suite();
|
53673 | suite.add("format", () => {
|
53674 | prettier.formatWithCursor(input, opt);
|
53675 | }).on("cycle", event => {
|
53676 | const results = {
|
53677 | benchmark: String(event.target),
|
53678 | hz: event.target.hz,
|
53679 | ms: event.target.times.cycle * 1000
|
53680 | };
|
53681 | context.logger.debug("'--debug-benchmark' measurements for formatWithCursor: " + JSON.stringify(results, null, 2));
|
53682 | }).run({
|
53683 | async: false
|
53684 | });
|
53685 | } else if (context.argv["debug-repeat"] > 0) {
|
53686 | const repeat = context.argv["debug-repeat"];
|
53687 | context.logger.debug("'--debug-repeat' option found, running formatWithCursor " + repeat + " times.");
|
53688 |
|
53689 | const now = Date.now ? () => Date.now() : () => +new Date();
|
53690 | let totalMs = 0;
|
53691 |
|
53692 | for (let i = 0; i < repeat; ++i) {
|
53693 | const startMs = now();
|
53694 | prettier.formatWithCursor(input, opt);
|
53695 | totalMs += now() - startMs;
|
53696 | }
|
53697 |
|
53698 | const averageMs = totalMs / repeat;
|
53699 | const results = {
|
53700 | repeat,
|
53701 | hz: 1000 / averageMs,
|
53702 | ms: averageMs
|
53703 | };
|
53704 | context.logger.debug("'--debug-repeat' measurements for formatWithCursor: " + JSON.stringify(results, null, 2));
|
53705 | }
|
53706 |
|
53707 | return prettier.formatWithCursor(input, opt);
|
53708 | }
|
53709 |
|
53710 | function getOptionsOrDie(context, filePath) {
|
53711 | try {
|
53712 | if (context.argv.config === false) {
|
53713 | context.logger.debug("'--no-config' option found, skip loading config file.");
|
53714 | return null;
|
53715 | }
|
53716 |
|
53717 | context.logger.debug(context.argv.config ? `load config file from '${context.argv.config}'` : `resolve config from '${filePath}'`);
|
53718 | const options = prettier.resolveConfig.sync(filePath, {
|
53719 | editorconfig: context.argv.editorconfig,
|
53720 | config: context.argv.config
|
53721 | });
|
53722 | context.logger.debug("loaded options `" + JSON.stringify(options) + "`");
|
53723 | return options;
|
53724 | } catch (error) {
|
53725 | context.logger.error(`Invalid configuration file \`${filePath}\`: ` + error.message);
|
53726 | process.exit(2);
|
53727 | }
|
53728 | }
|
53729 |
|
53730 | function getOptionsForFile(context, filepath) {
|
53731 | const options = getOptionsOrDie(context, filepath);
|
53732 | const hasPlugins = options && options.plugins;
|
53733 |
|
53734 | if (hasPlugins) {
|
53735 | pushContextPlugins(context, options.plugins);
|
53736 | }
|
53737 |
|
53738 | const appliedOptions = Object.assign({
|
53739 | filepath
|
53740 | }, applyConfigPrecedence(context, options && optionsNormalizer.normalizeApiOptions(options, context.supportOptions, {
|
53741 | logger: context.logger
|
53742 | })));
|
53743 | context.logger.debug(`applied config-precedence (${context.argv["config-precedence"]}): ` + `${JSON.stringify(appliedOptions)}`);
|
53744 |
|
53745 | if (hasPlugins) {
|
53746 | popContextPlugins(context);
|
53747 | }
|
53748 |
|
53749 | return appliedOptions;
|
53750 | }
|
53751 |
|
53752 | function parseArgsToOptions(context, overrideDefaults) {
|
53753 | const minimistOptions = createMinimistOptions(context.detailedOptions);
|
53754 | const apiDetailedOptionMap = createApiDetailedOptionMap(context.detailedOptions);
|
53755 | return getOptions(optionsNormalizer.normalizeCliOptions(minimist_1(context.args, {
|
53756 | string: minimistOptions.string,
|
53757 | boolean: minimistOptions.boolean,
|
53758 | default: cliifyOptions(overrideDefaults, apiDetailedOptionMap)
|
53759 | }), context.detailedOptions, {
|
53760 | logger: false
|
53761 | }), context.detailedOptions);
|
53762 | }
|
53763 |
|
53764 | function applyConfigPrecedence(context, options) {
|
53765 | try {
|
53766 | switch (context.argv["config-precedence"]) {
|
53767 | case "cli-override":
|
53768 | return parseArgsToOptions(context, options);
|
53769 |
|
53770 | case "file-override":
|
53771 | return Object.assign({}, parseArgsToOptions(context), {}, options);
|
53772 |
|
53773 | case "prefer-file":
|
53774 | return options || parseArgsToOptions(context);
|
53775 | }
|
53776 | } catch (error) {
|
53777 | context.logger.error(error.toString());
|
53778 | process.exit(2);
|
53779 | }
|
53780 | }
|
53781 |
|
53782 | function formatStdin(context) {
|
53783 | const filepath = context.argv["stdin-filepath"] ? path$2.resolve(process.cwd(), context.argv["stdin-filepath"]) : process.cwd();
|
53784 | const ignorer = createIgnorerFromContextOrDie(context);
|
53785 |
|
53786 |
|
53787 | const relativeFilepath = context.argv["ignore-path"] ? path$2.relative(path$2.dirname(context.argv["ignore-path"]), filepath) : path$2.relative(process.cwd(), filepath);
|
53788 | thirdParty.getStream(process.stdin).then(input => {
|
53789 | if (relativeFilepath && ignorer.filter([relativeFilepath]).length === 0) {
|
53790 | writeOutput(context, {
|
53791 | formatted: input
|
53792 | });
|
53793 | return;
|
53794 | }
|
53795 |
|
53796 | const options = getOptionsForFile(context, filepath);
|
53797 |
|
53798 | if (listDifferent(context, input, options, "(stdin)")) {
|
53799 | return;
|
53800 | }
|
53801 |
|
53802 | writeOutput(context, format$1(context, input, options), options);
|
53803 | }).catch(error => {
|
53804 | handleError(context, relativeFilepath || "stdin", error);
|
53805 | });
|
53806 | }
|
53807 |
|
53808 | function createIgnorerFromContextOrDie(context) {
|
53809 | try {
|
53810 | return createIgnorer_1.sync(context.argv["ignore-path"], context.argv["with-node-modules"]);
|
53811 | } catch (e) {
|
53812 | context.logger.error(e.message);
|
53813 | process.exit(2);
|
53814 | }
|
53815 | }
|
53816 |
|
53817 | function formatFiles(context) {
|
53818 |
|
53819 |
|
53820 | const ignorer = createIgnorerFromContextOrDie(context);
|
53821 | let numberOfUnformattedFilesFound = 0;
|
53822 |
|
53823 | if (context.argv.check) {
|
53824 | context.logger.log("Checking formatting...");
|
53825 | }
|
53826 |
|
53827 | for (const pathOrError of expandPatterns_1(context)) {
|
53828 | if (typeof pathOrError === "object") {
|
53829 | context.logger.error(pathOrError.error);
|
53830 |
|
53831 | process.exitCode = 2;
|
53832 | continue;
|
53833 | }
|
53834 |
|
53835 | const filename = pathOrError;
|
53836 |
|
53837 |
|
53838 | const ignoreFilename = context.argv["ignore-path"] ? path$2.relative(path$2.dirname(context.argv["ignore-path"]), filename) : filename;
|
53839 | const fileIgnored = ignorer.filter([ignoreFilename]).length === 0;
|
53840 |
|
53841 | if (fileIgnored && (context.argv["debug-check"] || context.argv.write || context.argv.check || context.argv["list-different"])) {
|
53842 | continue;
|
53843 | }
|
53844 |
|
53845 | const options = Object.assign({}, getOptionsForFile(context, filename), {
|
53846 | filepath: filename
|
53847 | });
|
53848 |
|
53849 | if (isTty()) {
|
53850 | context.logger.log(filename, {
|
53851 | newline: false
|
53852 | });
|
53853 | }
|
53854 |
|
53855 | let input;
|
53856 |
|
53857 | try {
|
53858 | input = fs$3.readFileSync(filename, "utf8");
|
53859 | } catch (error) {
|
53860 |
|
53861 | context.logger.log("");
|
53862 | context.logger.error(`Unable to read file: ${filename}\n${error.message}`);
|
53863 |
|
53864 | process.exitCode = 2;
|
53865 | continue;
|
53866 | }
|
53867 |
|
53868 | if (fileIgnored) {
|
53869 | writeOutput(context, {
|
53870 | formatted: input
|
53871 | }, options);
|
53872 | continue;
|
53873 | }
|
53874 |
|
53875 | const start = Date.now();
|
53876 | let result;
|
53877 | let output;
|
53878 |
|
53879 | try {
|
53880 | result = format$1(context, input, options);
|
53881 | output = result.formatted;
|
53882 | } catch (error) {
|
53883 | handleError(context, filename, error);
|
53884 | continue;
|
53885 | }
|
53886 |
|
53887 | const isDifferent = output !== input;
|
53888 |
|
53889 | if (isTty()) {
|
53890 |
|
53891 | readline$1.clearLine(process.stdout, 0);
|
53892 | readline$1.cursorTo(process.stdout, 0, null);
|
53893 | }
|
53894 |
|
53895 | if (context.argv.write) {
|
53896 |
|
53897 |
|
53898 | if (isDifferent) {
|
53899 | if (!context.argv.check && !context.argv["list-different"]) {
|
53900 | context.logger.log(`${filename} ${Date.now() - start}ms`);
|
53901 | }
|
53902 |
|
53903 | try {
|
53904 | fs$3.writeFileSync(filename, output, "utf8");
|
53905 | } catch (error) {
|
53906 | context.logger.error(`Unable to write file: ${filename}\n${error.message}`);
|
53907 |
|
53908 | process.exitCode = 2;
|
53909 | }
|
53910 | } else if (!context.argv.check && !context.argv["list-different"]) {
|
53911 | context.logger.log(`${source.grey(filename)} ${Date.now() - start}ms`);
|
53912 | }
|
53913 | } else if (context.argv["debug-check"]) {
|
53914 | if (result.filepath) {
|
53915 | context.logger.log(result.filepath);
|
53916 | } else {
|
53917 | process.exitCode = 2;
|
53918 | }
|
53919 | } else if (!context.argv.check && !context.argv["list-different"]) {
|
53920 | writeOutput(context, result, options);
|
53921 | }
|
53922 |
|
53923 | if ((context.argv.check || context.argv["list-different"]) && isDifferent) {
|
53924 | context.logger.log(filename);
|
53925 | numberOfUnformattedFilesFound += 1;
|
53926 | }
|
53927 | }
|
53928 |
|
53929 |
|
53930 | if (context.argv.check) {
|
53931 | context.logger.log(numberOfUnformattedFilesFound === 0 ? "All matched files use Prettier code style!" : context.argv.write ? "Code style issues fixed in the above file(s)." : "Code style issues found in the above file(s). Forgot to run Prettier?");
|
53932 | }
|
53933 |
|
53934 |
|
53935 | if ((context.argv.check || context.argv["list-different"]) && numberOfUnformattedFilesFound > 0 && !process.exitCode && !context.argv.write) {
|
53936 | process.exitCode = 1;
|
53937 | }
|
53938 | }
|
53939 |
|
53940 | function getOptionsWithOpposites(options) {
|
53941 |
|
53942 | const optionsWithOpposites = options.map(option => [option.description ? option : null, option.oppositeDescription ? Object.assign({}, option, {
|
53943 | name: `no-${option.name}`,
|
53944 | type: "boolean",
|
53945 | description: option.oppositeDescription
|
53946 | }) : null]);
|
53947 | return flatten_1(optionsWithOpposites).filter(Boolean);
|
53948 | }
|
53949 |
|
53950 | function createUsage(context) {
|
53951 | const options = getOptionsWithOpposites(context.detailedOptions).filter(
|
53952 | option => !(option.type === "boolean" && option.oppositeDescription && !option.name.startsWith("no-")));
|
53953 | const groupedOptions = groupBy_1(options, option => option.category);
|
53954 | const firstCategories = constant$1.categoryOrder.slice(0, -1);
|
53955 | const lastCategories = constant$1.categoryOrder.slice(-1);
|
53956 | const restCategories = Object.keys(groupedOptions).filter(category => !constant$1.categoryOrder.includes(category));
|
53957 | const allCategories = [...firstCategories, ...restCategories, ...lastCategories];
|
53958 | const optionsUsage = allCategories.map(category => {
|
53959 | const categoryOptions = groupedOptions[category].map(option => createOptionUsage(context, option, OPTION_USAGE_THRESHOLD)).join("\n");
|
53960 | return `${category} options:\n\n${indent$b(categoryOptions, 2)}`;
|
53961 | });
|
53962 | return [constant$1.usageSummary].concat(optionsUsage, [""]).join("\n\n");
|
53963 | }
|
53964 |
|
53965 | function createOptionUsage(context, option, threshold) {
|
53966 | const header = createOptionUsageHeader(option);
|
53967 | const optionDefaultValue = getOptionDefaultValue(context, option.name);
|
53968 | return createOptionUsageRow(header, `${option.description}${optionDefaultValue === undefined ? "" : `\nDefaults to ${createDefaultValueDisplay(optionDefaultValue)}.`}`, threshold);
|
53969 | }
|
53970 |
|
53971 | function createDefaultValueDisplay(value) {
|
53972 | return Array.isArray(value) ? `[${value.map(createDefaultValueDisplay).join(", ")}]` : value;
|
53973 | }
|
53974 |
|
53975 | function createOptionUsageHeader(option) {
|
53976 | const name = `--${option.name}`;
|
53977 | const alias = option.alias ? `-${option.alias},` : null;
|
53978 | const type = createOptionUsageType(option);
|
53979 | return [alias, name, type].filter(Boolean).join(" ");
|
53980 | }
|
53981 |
|
53982 | function createOptionUsageRow(header, content, threshold) {
|
53983 | const separator = header.length >= threshold ? `\n${" ".repeat(threshold)}` : " ".repeat(threshold - header.length);
|
53984 | const description = content.replace(/\n/g, `\n${" ".repeat(threshold)}`);
|
53985 | return `${header}${separator}${description}`;
|
53986 | }
|
53987 |
|
53988 | function createOptionUsageType(option) {
|
53989 | switch (option.type) {
|
53990 | case "boolean":
|
53991 | return null;
|
53992 |
|
53993 | case "choice":
|
53994 | return `<${option.choices.filter(choice => !choice.deprecated && choice.since !== null).map(choice => choice.value).join("|")}>`;
|
53995 |
|
53996 | default:
|
53997 | return `<${option.type}>`;
|
53998 | }
|
53999 | }
|
54000 |
|
54001 | function createChoiceUsages(choices, margin, indentation) {
|
54002 | const activeChoices = choices.filter(choice => !choice.deprecated && choice.since !== null);
|
54003 | const threshold = activeChoices.map(choice => choice.value.length).reduce((current, length) => Math.max(current, length), 0) + margin;
|
54004 | return activeChoices.map(choice => indent$b(createOptionUsageRow(choice.value, choice.description, threshold), indentation));
|
54005 | }
|
54006 |
|
54007 | function createDetailedUsage(context, flag) {
|
54008 | const option = getOptionsWithOpposites(context.detailedOptions).find(option => option.name === flag || option.alias === flag);
|
54009 | const header = createOptionUsageHeader(option);
|
54010 | const description = `\n\n${indent$b(option.description, 2)}`;
|
54011 | const choices = option.type !== "choice" ? "" : `\n\nValid options:\n\n${createChoiceUsages(option.choices, CHOICE_USAGE_MARGIN, CHOICE_USAGE_INDENTATION).join("\n")}`;
|
54012 | const optionDefaultValue = getOptionDefaultValue(context, option.name);
|
54013 | const defaults = optionDefaultValue !== undefined ? `\n\nDefault: ${createDefaultValueDisplay(optionDefaultValue)}` : "";
|
54014 | const pluginDefaults = option.pluginDefaults && Object.keys(option.pluginDefaults).length ? `\nPlugin defaults:${Object.keys(option.pluginDefaults).map(key => `\n* ${key}: ${createDefaultValueDisplay(option.pluginDefaults[key])}`)}` : "";
|
54015 | return `${header}${description}${choices}${defaults}${pluginDefaults}`;
|
54016 | }
|
54017 |
|
54018 | function getOptionDefaultValue(context, optionName) {
|
54019 |
|
54020 | if (!(optionName in context.detailedOptionMap)) {
|
54021 | return undefined;
|
54022 | }
|
54023 |
|
54024 | const option = context.detailedOptionMap[optionName];
|
54025 |
|
54026 | if (option.default !== undefined) {
|
54027 | return option.default;
|
54028 | }
|
54029 |
|
54030 | const optionCamelName = camelcase(optionName);
|
54031 |
|
54032 | if (optionCamelName in context.apiDefaultOptions) {
|
54033 | return context.apiDefaultOptions[optionCamelName];
|
54034 | }
|
54035 |
|
54036 | return undefined;
|
54037 | }
|
54038 |
|
54039 | function indent$b(str, spaces) {
|
54040 | return str.replace(/^/gm, " ".repeat(spaces));
|
54041 | }
|
54042 |
|
54043 | function createLogger(logLevel) {
|
54044 | return {
|
54045 | warn: createLogFunc("warn", "yellow"),
|
54046 | error: createLogFunc("error", "red"),
|
54047 | debug: createLogFunc("debug", "blue"),
|
54048 | log: createLogFunc("log")
|
54049 | };
|
54050 |
|
54051 | function createLogFunc(loggerName, color) {
|
54052 | if (!shouldLog(loggerName)) {
|
54053 | return () => {};
|
54054 | }
|
54055 |
|
54056 | const prefix = color ? `[${source[color](loggerName)}] ` : "";
|
54057 | return function (message, opts) {
|
54058 | opts = Object.assign({
|
54059 | newline: true
|
54060 | }, opts);
|
54061 | const stream = process[loggerName === "log" ? "stdout" : "stderr"];
|
54062 | stream.write(message.replace(/^/gm, prefix) + (opts.newline ? "\n" : ""));
|
54063 | };
|
54064 | }
|
54065 |
|
54066 | function shouldLog(loggerName) {
|
54067 | switch (logLevel) {
|
54068 | case "silent":
|
54069 | return false;
|
54070 |
|
54071 | default:
|
54072 | return true;
|
54073 |
|
54074 | case "debug":
|
54075 | if (loggerName === "debug") {
|
54076 | return true;
|
54077 | }
|
54078 |
|
54079 |
|
54080 |
|
54081 | case "log":
|
54082 | if (loggerName === "log") {
|
54083 | return true;
|
54084 | }
|
54085 |
|
54086 |
|
54087 |
|
54088 | case "warn":
|
54089 | if (loggerName === "warn") {
|
54090 | return true;
|
54091 | }
|
54092 |
|
54093 |
|
54094 |
|
54095 | case "error":
|
54096 | return loggerName === "error";
|
54097 | }
|
54098 | }
|
54099 | }
|
54100 |
|
54101 | function normalizeDetailedOption(name, option) {
|
54102 | return Object.assign({
|
54103 | category: coreOptions.CATEGORY_OTHER
|
54104 | }, option, {
|
54105 | choices: option.choices && option.choices.map(choice => {
|
54106 | const newChoice = Object.assign({
|
54107 | description: "",
|
54108 | deprecated: false
|
54109 | }, typeof choice === "object" ? choice : {
|
54110 | value: choice
|
54111 | });
|
54112 |
|
54113 | if (newChoice.value === true) {
|
54114 | newChoice.value = "";
|
54115 | }
|
54116 |
|
54117 | return newChoice;
|
54118 | })
|
54119 | });
|
54120 | }
|
54121 |
|
54122 | function normalizeDetailedOptionMap(detailedOptionMap) {
|
54123 | return fromPairs_1(Object.entries(detailedOptionMap).sort(([leftName], [rightName]) => leftName.localeCompare(rightName)).map(([name, option]) => [name, normalizeDetailedOption(name, option)]));
|
54124 | }
|
54125 |
|
54126 | function createMinimistOptions(detailedOptions) {
|
54127 | return {
|
54128 |
|
54129 | alias: {},
|
54130 | boolean: detailedOptions.filter(option => option.type === "boolean").map(option => [option.name].concat(option.alias || [])).reduce((a, b) => a.concat(b)),
|
54131 | string: detailedOptions.filter(option => option.type !== "boolean").map(option => [option.name].concat(option.alias || [])).reduce((a, b) => a.concat(b)),
|
54132 | default: detailedOptions.filter(option => !option.deprecated && (!option.forwardToApi || option.name === "plugin" || option.name === "plugin-search-dir") && option.default !== undefined).reduce((current, option) => Object.assign({
|
54133 | [option.name]: option.default
|
54134 | }, current), {})
|
54135 | };
|
54136 | }
|
54137 |
|
54138 | function createApiDetailedOptionMap(detailedOptions) {
|
54139 | return fromPairs_1(detailedOptions.filter(option => option.forwardToApi && option.forwardToApi !== option.name).map(option => [option.forwardToApi, option]));
|
54140 | }
|
54141 |
|
54142 | function createDetailedOptionMap(supportOptions) {
|
54143 | return fromPairs_1(supportOptions.map(option => {
|
54144 | const newOption = Object.assign({}, option, {
|
54145 | name: option.cliName || dashify(option.name),
|
54146 | description: option.cliDescription || option.description,
|
54147 | category: option.cliCategory || coreOptions.CATEGORY_FORMAT,
|
54148 | forwardToApi: option.name
|
54149 | });
|
54150 |
|
54151 | if (option.deprecated) {
|
54152 | delete newOption.forwardToApi;
|
54153 | delete newOption.description;
|
54154 | delete newOption.oppositeDescription;
|
54155 | newOption.deprecated = true;
|
54156 | }
|
54157 |
|
54158 | return [newOption.name, newOption];
|
54159 | }));
|
54160 | }
|
54161 |
|
54162 |
|
54163 |
|
54164 |
|
54165 |
|
54166 |
|
54167 |
|
54168 |
|
54169 |
|
54170 |
|
54171 |
|
54172 |
|
54173 |
|
54174 |
|
54175 |
|
54176 |
|
54177 |
|
54178 |
|
54179 | function createContext(args) {
|
54180 | const context = {
|
54181 | args,
|
54182 | stack: []
|
54183 | };
|
54184 | updateContextArgv(context);
|
54185 | normalizeContextArgv(context, ["loglevel", "plugin", "plugin-search-dir"]);
|
54186 | context.logger = createLogger(context.argv.loglevel);
|
54187 | updateContextArgv(context, context.argv.plugin, context.argv["plugin-search-dir"]);
|
54188 | return (
|
54189 |
|
54190 | context
|
54191 | );
|
54192 | }
|
54193 |
|
54194 | function initContext(context) {
|
54195 |
|
54196 | normalizeContextArgv(context);
|
54197 | }
|
54198 |
|
54199 |
|
54200 |
|
54201 |
|
54202 |
|
54203 |
|
54204 |
|
54205 | function updateContextOptions(context, plugins, pluginSearchDirs) {
|
54206 | const {
|
54207 | options: supportOptions,
|
54208 | languages
|
54209 | } = prettier.getSupportInfo({
|
54210 | showDeprecated: true,
|
54211 | showUnreleased: true,
|
54212 | showInternal: true,
|
54213 | plugins,
|
54214 | pluginSearchDirs
|
54215 | });
|
54216 | const detailedOptionMap = normalizeDetailedOptionMap(Object.assign({}, createDetailedOptionMap(supportOptions), {}, constant$1.options));
|
54217 | const detailedOptions = arrayify(detailedOptionMap, "name");
|
54218 | const apiDefaultOptions = Object.assign({}, options$1.hiddenDefaults, {}, fromPairs_1(supportOptions.filter(({
|
54219 | deprecated
|
54220 | }) => !deprecated).map(option => [option.name, option.default])));
|
54221 | Object.assign(context, {
|
54222 | supportOptions,
|
54223 | detailedOptions,
|
54224 | detailedOptionMap,
|
54225 | apiDefaultOptions,
|
54226 | languages
|
54227 | });
|
54228 | }
|
54229 |
|
54230 |
|
54231 |
|
54232 |
|
54233 |
|
54234 |
|
54235 |
|
54236 | function pushContextPlugins(context, plugins, pluginSearchDirs) {
|
54237 | context.stack.push(pick_1(context, ["supportOptions", "detailedOptions", "detailedOptionMap", "apiDefaultOptions", "languages"]));
|
54238 | updateContextOptions(context, plugins, pluginSearchDirs);
|
54239 | }
|
54240 |
|
54241 |
|
54242 |
|
54243 |
|
54244 |
|
54245 | function popContextPlugins(context) {
|
54246 | Object.assign(context, context.stack.pop());
|
54247 | }
|
54248 |
|
54249 | function updateContextArgv(context, plugins, pluginSearchDirs) {
|
54250 | pushContextPlugins(context, plugins, pluginSearchDirs);
|
54251 | const minimistOptions = createMinimistOptions(context.detailedOptions);
|
54252 | const argv = minimist_1(context.args, minimistOptions);
|
54253 | context.argv = argv;
|
54254 | context.filePatterns = argv._;
|
54255 | }
|
54256 |
|
54257 | function normalizeContextArgv(context, keys) {
|
54258 | const detailedOptions = !keys ? context.detailedOptions : context.detailedOptions.filter(option => keys.includes(option.name));
|
54259 | const argv = !keys ? context.argv : pick_1(context.argv, keys);
|
54260 | context.argv = optionsNormalizer.normalizeCliOptions(argv, detailedOptions, {
|
54261 | logger: context.logger
|
54262 | });
|
54263 | }
|
54264 |
|
54265 |
|
54266 | var util$3 = {
|
54267 | createContext,
|
54268 | createDetailedOptionMap,
|
54269 | createDetailedUsage,
|
54270 | createUsage,
|
54271 | format: format$1,
|
54272 | formatFiles,
|
54273 | formatStdin,
|
54274 | initContext,
|
54275 | logResolvedConfigPathOrDie,
|
54276 | logFileInfoOrDie,
|
54277 | normalizeDetailedOptionMap
|
54278 | };
|
54279 |
|
54280 | pleaseUpgradeNode(require$$1);
|
54281 |
|
54282 | function run(args) {
|
54283 | const context = util$3.createContext(args);
|
54284 |
|
54285 | try {
|
54286 | util$3.initContext(context);
|
54287 | context.logger.debug(`normalized argv: ${JSON.stringify(context.argv)}`);
|
54288 |
|
54289 | if (context.argv.check && context.argv["list-different"]) {
|
54290 | context.logger.error("Cannot use --check and --list-different together.");
|
54291 | process.exit(1);
|
54292 | }
|
54293 |
|
54294 | if (context.argv.write && context.argv["debug-check"]) {
|
54295 | context.logger.error("Cannot use --write and --debug-check together.");
|
54296 | process.exit(1);
|
54297 | }
|
54298 |
|
54299 | if (context.argv["find-config-path"] && context.filePatterns.length) {
|
54300 | context.logger.error("Cannot use --find-config-path with multiple files");
|
54301 | process.exit(1);
|
54302 | }
|
54303 |
|
54304 | if (context.argv["file-info"] && context.filePatterns.length) {
|
54305 | context.logger.error("Cannot use --file-info with multiple files");
|
54306 | process.exit(1);
|
54307 | }
|
54308 |
|
54309 | if (context.argv.version) {
|
54310 | context.logger.log(prettier.version);
|
54311 | process.exit(0);
|
54312 | }
|
54313 |
|
54314 | if (context.argv.help !== undefined) {
|
54315 | context.logger.log(typeof context.argv.help === "string" && context.argv.help !== "" ? util$3.createDetailedUsage(context, context.argv.help) : util$3.createUsage(context));
|
54316 | process.exit(0);
|
54317 | }
|
54318 |
|
54319 | if (context.argv["support-info"]) {
|
54320 | context.logger.log(prettier.format(jsonStableStringify(prettier.getSupportInfo()), {
|
54321 | parser: "json"
|
54322 | }));
|
54323 | process.exit(0);
|
54324 | }
|
54325 |
|
54326 | const hasFilePatterns = context.filePatterns.length !== 0;
|
54327 | const useStdin = !hasFilePatterns && (!process.stdin.isTTY || context.args["stdin-filepath"]);
|
54328 |
|
54329 | if (context.argv["find-config-path"]) {
|
54330 | util$3.logResolvedConfigPathOrDie(context);
|
54331 | } else if (context.argv["file-info"]) {
|
54332 | util$3.logFileInfoOrDie(context);
|
54333 | } else if (useStdin) {
|
54334 | util$3.formatStdin(context);
|
54335 | } else if (hasFilePatterns) {
|
54336 | util$3.formatFiles(context);
|
54337 | } else {
|
54338 | context.logger.log(util$3.createUsage(context));
|
54339 | process.exit(1);
|
54340 | }
|
54341 | } catch (error) {
|
54342 | context.logger.error(error.message);
|
54343 | process.exit(1);
|
54344 | }
|
54345 | }
|
54346 |
|
54347 | var cli = {
|
54348 | run
|
54349 | };
|
54350 |
|
54351 | cli.run(process.argv.slice(2));
|