This commit is contained in:
2025-05-09 05:30:08 +02:00
parent 7bb10e7df4
commit 73367bad9e
5322 changed files with 1266973 additions and 313 deletions

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _lowercase = require("./lowercase.js");
Object.keys(_lowercase).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _lowercase[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _lowercase[key];
}
});
});
var _uppercase = require("./uppercase.js");
Object.keys(_uppercase).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _uppercase[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _uppercase[key];
}
});
});
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1,17 @@
'use strict';
var isProduction = process.env.NODE_ENV === 'production';
var prefix = 'Invariant failed';
function invariant(condition, message) {
if (condition) {
return;
}
if (isProduction) {
throw new Error(prefix);
}
var provided = typeof message === 'function' ? message() : message;
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
throw new Error(value);
}
module.exports = invariant;

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _classCallCheck;
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
//# sourceMappingURL=classCallCheck.js.map

View File

@@ -0,0 +1 @@
module.exports={C:{"27":0.00264,"72":0.00264,"78":0.00264,"81":0.00264,"88":0.00264,"97":0.00528,"107":0.00264,"112":0.00264,"113":0.00264,"114":0.00264,"115":0.08442,"121":0.00528,"122":0.00264,"123":0.00528,"124":0.00264,"127":0.00791,"128":0.01055,"130":0.00264,"132":0.00528,"133":0.00791,"134":0.00791,"135":0.25061,"136":0.70435,"137":0.03429,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 73 74 75 76 77 79 80 82 83 84 85 86 87 89 90 91 92 93 94 95 96 98 99 100 101 102 103 104 105 106 108 109 110 111 116 117 118 119 120 125 126 129 131 138 139 140 3.5 3.6"},D:{"11":0.00528,"39":0.00264,"47":0.00264,"49":0.00264,"50":0.00528,"56":0.00264,"59":0.00528,"64":0.01055,"65":0.00264,"66":0.00264,"68":0.00528,"69":0.00528,"70":0.01055,"71":0.00264,"72":0.00264,"73":0.00528,"74":0.00264,"75":0.00264,"76":0.00264,"77":0.00528,"78":0.00264,"79":0.02374,"80":0.00264,"81":0.00791,"83":0.00264,"85":0.00264,"86":0.00528,"87":0.03429,"88":0.01583,"89":0.00264,"90":0.00528,"91":0.00528,"92":0.01055,"93":0.00528,"94":0.00528,"95":0.00791,"96":0.00528,"97":0.00528,"98":0.01319,"99":0.00264,"100":0.00264,"101":0.00264,"102":0.01583,"103":0.02902,"104":0.00264,"105":0.00791,"106":0.01055,"107":0.00264,"108":0.00528,"109":0.37723,"110":0.00264,"111":0.03166,"113":0.00264,"114":0.03957,"115":0.00264,"116":0.03429,"117":0.01055,"118":0.01583,"119":0.03166,"120":0.04221,"121":0.02902,"122":0.07123,"123":0.01319,"124":0.0211,"125":0.02374,"126":0.03693,"127":0.0211,"128":0.0554,"129":0.03693,"130":0.08705,"131":0.30073,"132":0.25589,"133":3.89633,"134":6.58709,"135":0.01847,"136":0.00264,_:"4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 40 41 42 43 44 45 46 48 51 52 53 54 55 57 58 60 61 62 63 67 84 112 137 138"},F:{"36":0.00264,"79":0.00791,"84":0.01055,"85":0.00264,"86":0.00528,"87":0.09233,"88":0.01055,"95":0.03166,"101":0.00264,"107":0.00264,"108":0.00264,"110":0.01055,"113":0.00528,"114":0.01583,"115":0.00264,"116":0.06595,"117":0.69116,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 80 81 82 83 89 90 91 92 93 94 96 97 98 99 100 102 103 104 105 106 109 111 112 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"12":0.00791,"13":0.00264,"14":0.00791,"15":0.00264,"16":0.02902,"17":0.00528,"18":0.10024,"84":0.00528,"89":0.01583,"90":0.02374,"92":0.10816,"99":0.00791,"100":0.03957,"102":0.00264,"103":0.00264,"107":0.00264,"109":0.01319,"111":0.00264,"112":0.00528,"114":0.00528,"115":0.00264,"117":0.00528,"118":0.00264,"120":0.00528,"121":0.00528,"122":0.0211,"123":0.00528,"124":0.01055,"125":0.01055,"126":0.01847,"127":0.01055,"128":0.01847,"129":0.01583,"130":0.03957,"131":0.12662,"132":0.10816,"133":1.53268,"134":2.70131,_:"79 80 81 83 85 86 87 88 91 93 94 95 96 97 98 101 104 105 106 108 110 113 116 119"},E:{"13":0.00528,"14":0.00528,"15":0.00264,_:"0 4 5 6 7 8 9 10 11 12 3.1 3.2 5.1 6.1 7.1 10.1","9.1":0.00528,"11.1":0.00264,"12.1":0.00528,"13.1":0.02638,"14.1":0.04221,"15.1":0.00264,"15.2-15.3":0.00528,"15.4":0.00264,"15.5":0.00528,"15.6":0.06595,"16.0":0.00264,"16.1":0.00528,"16.2":0.00264,"16.3":0.0211,"16.4":0.00264,"16.5":0.00264,"16.6":0.04748,"17.0":0.00264,"17.1":0.02638,"17.2":0.00264,"17.3":0.01583,"17.4":0.0211,"17.5":0.01847,"17.6":0.07386,"18.0":0.01319,"18.1":0.02374,"18.2":0.01319,"18.3":0.48275,"18.4":0.00791},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00106,"5.0-5.1":0,"6.0-6.1":0.00318,"7.0-7.1":0.00212,"8.1-8.4":0,"9.0-9.2":0.00159,"9.3":0.00742,"10.0-10.2":0.00053,"10.3":0.01219,"11.0-11.2":0.05618,"11.3-11.4":0.00371,"12.0-12.1":0.00212,"12.2-12.5":0.05247,"13.0-13.1":0.00106,"13.2":0.00159,"13.3":0.00212,"13.4-13.7":0.00742,"14.0-14.4":0.01855,"14.5-14.8":0.02226,"15.0-15.1":0.01219,"15.2-15.3":0.01219,"15.4":0.01484,"15.5":0.01696,"15.6-15.8":0.20882,"16.0":0.02968,"16.1":0.06095,"16.2":0.0318,"16.3":0.05512,"16.4":0.01219,"16.5":0.02279,"16.6-16.7":0.24751,"17.0":0.01484,"17.1":0.0265,"17.2":0.02014,"17.3":0.02809,"17.4":0.05618,"17.5":0.12508,"17.6-17.7":0.36304,"18.0":0.10176,"18.1":0.33283,"18.2":0.14893,"18.3":3.11264,"18.4":0.04611},P:{"4":0.02039,"20":0.0102,"21":0.11217,"22":0.12236,"23":0.11217,"24":0.40788,"25":0.25493,"26":0.21414,"27":2.99793,_:"5.0-5.4 6.2-6.4 8.2 10.1 12.0 13.0 14.0 15.0","7.2-7.4":0.23453,"9.2":0.0102,"11.1-11.2":0.0102,"16.0":0.04079,"17.0":0.0102,"18.0":0.03059,"19.0":0.11217},I:{"0":0.02938,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00001,"4.4":0,"4.4.3-4.4.4":0.00003},K:{"0":4.78659,_:"10 11 12 11.1 11.5 12.1"},A:{"10":0.00308,"11":0.01539,_:"6 7 8 9 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.1693},Q:{"14.9":0.06625},O:{"0":0.55208},H:{"0":0.16},L:{"0":62.76353}};

View File

@@ -0,0 +1,42 @@
'use strict'
let Container = require('./container')
let Input = require('./input')
let Parser = require('./parser')
function parse(css, opts) {
let input = new Input(css, opts)
let parser = new Parser(input)
try {
parser.parse()
} catch (e) {
if (process.env.NODE_ENV !== 'production') {
if (e.name === 'CssSyntaxError' && opts && opts.from) {
if (/\.scss$/i.test(opts.from)) {
e.message +=
'\nYou tried to parse SCSS with ' +
'the standard CSS parser; ' +
'try again with the postcss-scss parser'
} else if (/\.sass/i.test(opts.from)) {
e.message +=
'\nYou tried to parse Sass with ' +
'the standard CSS parser; ' +
'try again with the postcss-sass parser'
} else if (/\.less$/i.test(opts.from)) {
e.message +=
'\nYou tried to parse Less with ' +
'the standard CSS parser; ' +
'try again with the postcss-less parser'
}
}
}
throw e
}
return parser.root
}
module.exports = parse
parse.default = parse
Container.registerParse(parse)

View File

@@ -0,0 +1,30 @@
const fs = require('fs');
const path = require('path');
function del(targetPath) {
if (!fs.existsSync(targetPath)) {
return false;
}
try {
if (fs.statSync(targetPath).isDirectory()) {
// If it's a directory, delete its contents first
fs.readdirSync(targetPath).forEach(file => {
const curPath = path.join(targetPath, file);
if (fs.statSync(curPath).isFile()) {
fs.unlinkSync(curPath); // Delete file
}
});
fs.rmdirSync(targetPath); // Delete the now-empty directory
} else {
fs.unlinkSync(targetPath); // If it's a file, delete it directly
}
return true;
} catch (error) {
console.error(`Error while deleting ${targetPath}: ${error.message}`);
}
}
module.exports = { del };

View File

@@ -0,0 +1 @@
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"0 9 N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","2":"C L M G"},C:{"1":"0 9 nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"1 2 3 4 5 6 7 8 nC LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB qC rC"},D:{"1":"0 9 sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB"},E:{"1":"A B C L M G TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB K D E F sC SC tC uC vC wC"},F:{"1":"0 fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z","2":"1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB 4C 5C 6C 7C FC kC 8C GC"},G:{"1":"GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"E SC 9C lC AD BD CD DD ED FD"},H:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"2":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 eD fD gD hD TC iD jD kD lD mD IC JC KC nD","2":"J dD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"1":"rD","2":"qD"}},B:1,C:"\"once\" event listener option",D:true};

View File

@@ -0,0 +1 @@
module.exports={C:{"52":0.00243,"60":0.00486,"66":0.00243,"68":0.00243,"72":0.00243,"77":0.14817,"78":0.01457,"84":0.00486,"89":0.00486,"95":0.02915,"97":0.00486,"102":0.00243,"103":0.00243,"108":0.01215,"110":0.04129,"112":0.00486,"113":0.00486,"115":0.21618,"121":0.00972,"122":0.00243,"127":0.00972,"128":0.02186,"130":0.00243,"131":0.017,"132":0.00729,"133":0.00729,"134":0.02429,"135":0.28419,"136":1.00804,"137":0.03401,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 53 54 55 56 57 58 59 61 62 63 64 65 67 69 70 71 73 74 75 76 79 80 81 82 83 85 86 87 88 90 91 92 93 94 96 98 99 100 101 104 105 106 107 109 111 114 116 117 118 119 120 123 124 125 126 129 138 139 140 3.5 3.6"},D:{"11":0.00243,"38":0.00243,"40":0.00243,"42":0.00243,"43":0.00972,"48":0.00243,"49":0.00486,"50":0.00972,"53":0.00243,"55":0.00243,"56":0.00486,"58":0.00243,"63":0.00729,"64":0.00729,"65":0.00243,"66":0.00486,"67":0.00243,"68":0.00729,"69":0.00486,"70":0.00243,"71":0.00243,"72":0.00243,"73":0.02915,"74":0.00243,"75":0.00486,"76":0.00729,"77":0.00972,"79":0.0923,"80":0.01215,"81":0.01457,"83":0.01215,"84":0.017,"85":0.00243,"86":0.00729,"87":0.03886,"88":0.00972,"89":0.00243,"90":0.00243,"91":0.00729,"93":0.05101,"94":0.00729,"95":0.02915,"96":0.02672,"98":0.04615,"99":0.00243,"100":0.00243,"101":0.01457,"102":0.00486,"103":0.07287,"104":0.00243,"105":0.00243,"106":0.00729,"107":0.00243,"108":0.00729,"109":1.49384,"110":0.00729,"111":0.017,"113":0.00243,"114":0.03886,"115":0.00729,"116":0.017,"117":0.00243,"118":0.02672,"119":0.05344,"120":0.02429,"121":0.06315,"122":0.03401,"123":0.03158,"124":0.03401,"125":0.05101,"126":0.03158,"127":0.04372,"128":0.03644,"129":0.03886,"130":0.06801,"131":0.17246,"132":0.17489,"133":4.38677,"134":6.97123,"135":0.04615,"136":0.00729,_:"4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 39 41 44 45 46 47 51 52 54 57 59 60 61 62 78 92 97 112 137 138"},F:{"79":0.017,"82":0.00243,"85":0.00486,"86":0.00243,"87":0.00243,"88":0.00243,"95":0.03158,"114":0.00243,"115":0.00243,"116":0.03401,"117":0.63154,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 80 81 83 84 89 90 91 92 93 94 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"12":0.00243,"13":0.00729,"14":0.00243,"15":0.01457,"16":0.00486,"17":0.01215,"18":0.02186,"90":0.00243,"92":0.02672,"100":0.00243,"109":0.01457,"112":0.00243,"114":0.00486,"115":0.00243,"121":0.00243,"122":0.00243,"123":0.00243,"124":0.00243,"125":0.00729,"126":0.00486,"127":0.00729,"128":0.00486,"129":0.00972,"130":0.02429,"131":0.04129,"132":0.08259,"133":0.68498,"134":1.29466,_:"79 80 81 83 84 85 86 87 88 89 91 93 94 95 96 97 98 99 101 102 103 104 105 106 107 108 110 111 113 116 117 118 119 120"},E:{"7":0.00243,"13":0.00486,_:"0 4 5 6 8 9 10 11 12 14 15 3.1 3.2 5.1 6.1 7.1 9.1 10.1 11.1 15.1 15.2-15.3 16.0 16.2 16.3 16.4 16.5 17.0 17.2 17.4 18.4","12.1":0.00729,"13.1":0.00486,"14.1":0.00243,"15.4":0.00243,"15.5":0.00243,"15.6":0.01215,"16.1":0.00243,"16.6":0.00729,"17.1":0.00729,"17.3":0.00243,"17.5":0.02672,"17.6":0.01215,"18.0":0.00243,"18.1":0.00243,"18.2":0.00243,"18.3":0.01215},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00042,"5.0-5.1":0,"6.0-6.1":0.00127,"7.0-7.1":0.00085,"8.1-8.4":0,"9.0-9.2":0.00064,"9.3":0.00297,"10.0-10.2":0.00021,"10.3":0.00488,"11.0-11.2":0.02247,"11.3-11.4":0.00148,"12.0-12.1":0.00085,"12.2-12.5":0.02099,"13.0-13.1":0.00042,"13.2":0.00064,"13.3":0.00085,"13.4-13.7":0.00297,"14.0-14.4":0.00742,"14.5-14.8":0.0089,"15.0-15.1":0.00488,"15.2-15.3":0.00488,"15.4":0.00594,"15.5":0.00678,"15.6-15.8":0.08352,"16.0":0.01187,"16.1":0.02438,"16.2":0.01272,"16.3":0.02205,"16.4":0.00488,"16.5":0.00912,"16.6-16.7":0.099,"17.0":0.00594,"17.1":0.0106,"17.2":0.00806,"17.3":0.01124,"17.4":0.02247,"17.5":0.05003,"17.6-17.7":0.14521,"18.0":0.0407,"18.1":0.13313,"18.2":0.05957,"18.3":1.24501,"18.4":0.01844},P:{"4":0.22403,"20":0.01067,"21":0.01067,"22":0.032,"23":0.02134,"24":0.05334,"25":0.08535,"26":0.13869,"27":0.29871,_:"5.0-5.4 6.2-6.4 8.2 9.2 10.1 11.1-11.2 12.0","7.2-7.4":0.12802,"13.0":0.04267,"14.0":0.01067,"15.0":0.04267,"16.0":0.01067,"17.0":0.04267,"18.0":0.01067,"19.0":0.01067},I:{"0":0.09822,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00003,"4.4":0,"4.4.3-4.4.4":0.00011},K:{"0":0.71407,_:"10 11 12 11.1 11.5 12.1"},A:{"11":0.00243,_:"6 7 8 9 10 5.5"},S:{"2.5":0.03786,_:"3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.12114},Q:{"14.9":0.00757},O:{"0":0.09842},H:{"0":0.52},L:{"0":74.59496}};

View File

@@ -0,0 +1,117 @@
/**
* @fileoverview Rule to
* @author Toru Nagashima
*/
"use strict";
//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
/**
* Gets the variable object of `arguments` which is defined implicitly.
* @param {eslint-scope.Scope} scope A scope to get.
* @returns {eslint-scope.Variable} The found variable object.
*/
function getVariableOfArguments(scope) {
const variables = scope.variables;
for (let i = 0; i < variables.length; ++i) {
const variable = variables[i];
if (variable.name === "arguments") {
/*
* If there was a parameter which is named "arguments", the implicit "arguments" is not defined.
* So does fast return with null.
*/
return variable.identifiers.length === 0 ? variable : null;
}
}
/* c8 ignore next */
return null;
}
/**
* Checks if the given reference is not normal member access.
*
* - arguments .... true // not member access
* - arguments[i] .... true // computed member access
* - arguments[0] .... true // computed member access
* - arguments.length .... false // normal member access
* @param {eslint-scope.Reference} reference The reference to check.
* @returns {boolean} `true` if the reference is not normal member access.
*/
function isNotNormalMemberAccess(reference) {
const id = reference.identifier;
const parent = id.parent;
return !(
parent.type === "MemberExpression" &&
parent.object === id &&
!parent.computed
);
}
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
type: "suggestion",
docs: {
description: "Require rest parameters instead of `arguments`",
recommended: false,
url: "https://eslint.org/docs/latest/rules/prefer-rest-params",
},
schema: [],
messages: {
preferRestParams: "Use the rest parameters instead of 'arguments'.",
},
},
create(context) {
const sourceCode = context.sourceCode;
/**
* Reports a given reference.
* @param {eslint-scope.Reference} reference A reference to report.
* @returns {void}
*/
function report(reference) {
context.report({
node: reference.identifier,
loc: reference.identifier.loc,
messageId: "preferRestParams",
});
}
/**
* Reports references of the implicit `arguments` variable if exist.
* @param {ASTNode} node The node representing the function.
* @returns {void}
*/
function checkForArguments(node) {
const argumentsVar = getVariableOfArguments(
sourceCode.getScope(node),
);
if (argumentsVar) {
argumentsVar.references
.filter(isNotNormalMemberAccess)
.forEach(report);
}
}
return {
"FunctionDeclaration:exit": checkForArguments,
"FunctionExpression:exit": checkForArguments,
};
},
};

View File

@@ -0,0 +1,947 @@
module.exports = minimatch
minimatch.Minimatch = Minimatch
var path = (function () { try { return require('path') } catch (e) {}}()) || {
sep: '/'
}
minimatch.sep = path.sep
var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
var expand = require('brace-expansion')
var plTypes = {
'!': { open: '(?:(?!(?:', close: '))[^/]*?)'},
'?': { open: '(?:', close: ')?' },
'+': { open: '(?:', close: ')+' },
'*': { open: '(?:', close: ')*' },
'@': { open: '(?:', close: ')' }
}
// any single thing other than /
// don't need to escape / when using new RegExp()
var qmark = '[^/]'
// * => any number of characters
var star = qmark + '*?'
// ** when dots are allowed. Anything goes, except .. and .
// not (^ or / followed by one or two dots followed by $ or /),
// followed by anything, any number of times.
var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'
// not a ^ or / followed by a dot,
// followed by anything, any number of times.
var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'
// characters that need to be escaped in RegExp.
var reSpecials = charSet('().*{}+?[]^$\\!')
// "abc" -> { a:true, b:true, c:true }
function charSet (s) {
return s.split('').reduce(function (set, c) {
set[c] = true
return set
}, {})
}
// normalizes slashes.
var slashSplit = /\/+/
minimatch.filter = filter
function filter (pattern, options) {
options = options || {}
return function (p, i, list) {
return minimatch(p, pattern, options)
}
}
function ext (a, b) {
b = b || {}
var t = {}
Object.keys(a).forEach(function (k) {
t[k] = a[k]
})
Object.keys(b).forEach(function (k) {
t[k] = b[k]
})
return t
}
minimatch.defaults = function (def) {
if (!def || typeof def !== 'object' || !Object.keys(def).length) {
return minimatch
}
var orig = minimatch
var m = function minimatch (p, pattern, options) {
return orig(p, pattern, ext(def, options))
}
m.Minimatch = function Minimatch (pattern, options) {
return new orig.Minimatch(pattern, ext(def, options))
}
m.Minimatch.defaults = function defaults (options) {
return orig.defaults(ext(def, options)).Minimatch
}
m.filter = function filter (pattern, options) {
return orig.filter(pattern, ext(def, options))
}
m.defaults = function defaults (options) {
return orig.defaults(ext(def, options))
}
m.makeRe = function makeRe (pattern, options) {
return orig.makeRe(pattern, ext(def, options))
}
m.braceExpand = function braceExpand (pattern, options) {
return orig.braceExpand(pattern, ext(def, options))
}
m.match = function (list, pattern, options) {
return orig.match(list, pattern, ext(def, options))
}
return m
}
Minimatch.defaults = function (def) {
return minimatch.defaults(def).Minimatch
}
function minimatch (p, pattern, options) {
assertValidPattern(pattern)
if (!options) options = {}
// shortcut: comments match nothing.
if (!options.nocomment && pattern.charAt(0) === '#') {
return false
}
return new Minimatch(pattern, options).match(p)
}
function Minimatch (pattern, options) {
if (!(this instanceof Minimatch)) {
return new Minimatch(pattern, options)
}
assertValidPattern(pattern)
if (!options) options = {}
pattern = pattern.trim()
// windows support: need to use /, not \
if (!options.allowWindowsEscape && path.sep !== '/') {
pattern = pattern.split(path.sep).join('/')
}
this.options = options
this.set = []
this.pattern = pattern
this.regexp = null
this.negate = false
this.comment = false
this.empty = false
this.partial = !!options.partial
// make the set of regexps etc.
this.make()
}
Minimatch.prototype.debug = function () {}
Minimatch.prototype.make = make
function make () {
var pattern = this.pattern
var options = this.options
// empty patterns and comments match nothing.
if (!options.nocomment && pattern.charAt(0) === '#') {
this.comment = true
return
}
if (!pattern) {
this.empty = true
return
}
// step 1: figure out negation, etc.
this.parseNegate()
// step 2: expand braces
var set = this.globSet = this.braceExpand()
if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) }
this.debug(this.pattern, set)
// step 3: now we have a set, so turn each one into a series of path-portion
// matching patterns.
// These will be regexps, except in the case of "**", which is
// set to the GLOBSTAR object for globstar behavior,
// and will not contain any / characters
set = this.globParts = set.map(function (s) {
return s.split(slashSplit)
})
this.debug(this.pattern, set)
// glob --> regexps
set = set.map(function (s, si, set) {
return s.map(this.parse, this)
}, this)
this.debug(this.pattern, set)
// filter out everything that didn't compile properly.
set = set.filter(function (s) {
return s.indexOf(false) === -1
})
this.debug(this.pattern, set)
this.set = set
}
Minimatch.prototype.parseNegate = parseNegate
function parseNegate () {
var pattern = this.pattern
var negate = false
var options = this.options
var negateOffset = 0
if (options.nonegate) return
for (var i = 0, l = pattern.length
; i < l && pattern.charAt(i) === '!'
; i++) {
negate = !negate
negateOffset++
}
if (negateOffset) this.pattern = pattern.substr(negateOffset)
this.negate = negate
}
// Brace expansion:
// a{b,c}d -> abd acd
// a{b,}c -> abc ac
// a{0..3}d -> a0d a1d a2d a3d
// a{b,c{d,e}f}g -> abg acdfg acefg
// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
//
// Invalid sets are not expanded.
// a{2..}b -> a{2..}b
// a{b}c -> a{b}c
minimatch.braceExpand = function (pattern, options) {
return braceExpand(pattern, options)
}
Minimatch.prototype.braceExpand = braceExpand
function braceExpand (pattern, options) {
if (!options) {
if (this instanceof Minimatch) {
options = this.options
} else {
options = {}
}
}
pattern = typeof pattern === 'undefined'
? this.pattern : pattern
assertValidPattern(pattern)
// Thanks to Yeting Li <https://github.com/yetingli> for
// improving this regexp to avoid a ReDOS vulnerability.
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
// shortcut. no need to expand.
return [pattern]
}
return expand(pattern)
}
var MAX_PATTERN_LENGTH = 1024 * 64
var assertValidPattern = function (pattern) {
if (typeof pattern !== 'string') {
throw new TypeError('invalid pattern')
}
if (pattern.length > MAX_PATTERN_LENGTH) {
throw new TypeError('pattern is too long')
}
}
// parse a component of the expanded set.
// At this point, no pattern may contain "/" in it
// so we're going to return a 2d array, where each entry is the full
// pattern, split on '/', and then turned into a regular expression.
// A regexp is made at the end which joins each array with an
// escaped /, and another full one which joins each regexp with |.
//
// Following the lead of Bash 4.1, note that "**" only has special meaning
// when it is the *only* thing in a path portion. Otherwise, any series
// of * is equivalent to a single *. Globstar behavior is enabled by
// default, and can be disabled by setting options.noglobstar.
Minimatch.prototype.parse = parse
var SUBPARSE = {}
function parse (pattern, isSub) {
assertValidPattern(pattern)
var options = this.options
// shortcuts
if (pattern === '**') {
if (!options.noglobstar)
return GLOBSTAR
else
pattern = '*'
}
if (pattern === '') return ''
var re = ''
var hasMagic = !!options.nocase
var escaping = false
// ? => one single character
var patternListStack = []
var negativeLists = []
var stateChar
var inClass = false
var reClassStart = -1
var classStart = -1
// . and .. never match anything that doesn't start with .,
// even when options.dot is set.
var patternStart = pattern.charAt(0) === '.' ? '' // anything
// not (start or / followed by . or .. followed by / or end)
: options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))'
: '(?!\\.)'
var self = this
function clearStateChar () {
if (stateChar) {
// we had some state-tracking character
// that wasn't consumed by this pass.
switch (stateChar) {
case '*':
re += star
hasMagic = true
break
case '?':
re += qmark
hasMagic = true
break
default:
re += '\\' + stateChar
break
}
self.debug('clearStateChar %j %j', stateChar, re)
stateChar = false
}
}
for (var i = 0, len = pattern.length, c
; (i < len) && (c = pattern.charAt(i))
; i++) {
this.debug('%s\t%s %s %j', pattern, i, re, c)
// skip over any that are escaped.
if (escaping && reSpecials[c]) {
re += '\\' + c
escaping = false
continue
}
switch (c) {
/* istanbul ignore next */
case '/': {
// completely not allowed, even escaped.
// Should already be path-split by now.
return false
}
case '\\':
clearStateChar()
escaping = true
continue
// the various stateChar values
// for the "extglob" stuff.
case '?':
case '*':
case '+':
case '@':
case '!':
this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c)
// all of those are literals inside a class, except that
// the glob [!a] means [^a] in regexp
if (inClass) {
this.debug(' in class')
if (c === '!' && i === classStart + 1) c = '^'
re += c
continue
}
// if we already have a stateChar, then it means
// that there was something like ** or +? in there.
// Handle the stateChar, then proceed with this one.
self.debug('call clearStateChar %j', stateChar)
clearStateChar()
stateChar = c
// if extglob is disabled, then +(asdf|foo) isn't a thing.
// just clear the statechar *now*, rather than even diving into
// the patternList stuff.
if (options.noext) clearStateChar()
continue
case '(':
if (inClass) {
re += '('
continue
}
if (!stateChar) {
re += '\\('
continue
}
patternListStack.push({
type: stateChar,
start: i - 1,
reStart: re.length,
open: plTypes[stateChar].open,
close: plTypes[stateChar].close
})
// negation is (?:(?!js)[^/]*)
re += stateChar === '!' ? '(?:(?!(?:' : '(?:'
this.debug('plType %j %j', stateChar, re)
stateChar = false
continue
case ')':
if (inClass || !patternListStack.length) {
re += '\\)'
continue
}
clearStateChar()
hasMagic = true
var pl = patternListStack.pop()
// negation is (?:(?!js)[^/]*)
// The others are (?:<pattern>)<type>
re += pl.close
if (pl.type === '!') {
negativeLists.push(pl)
}
pl.reEnd = re.length
continue
case '|':
if (inClass || !patternListStack.length || escaping) {
re += '\\|'
escaping = false
continue
}
clearStateChar()
re += '|'
continue
// these are mostly the same in regexp and glob
case '[':
// swallow any state-tracking char before the [
clearStateChar()
if (inClass) {
re += '\\' + c
continue
}
inClass = true
classStart = i
reClassStart = re.length
re += c
continue
case ']':
// a right bracket shall lose its special
// meaning and represent itself in
// a bracket expression if it occurs
// first in the list. -- POSIX.2 2.8.3.2
if (i === classStart + 1 || !inClass) {
re += '\\' + c
escaping = false
continue
}
// handle the case where we left a class open.
// "[z-a]" is valid, equivalent to "\[z-a\]"
// split where the last [ was, make sure we don't have
// an invalid re. if so, re-walk the contents of the
// would-be class to re-translate any characters that
// were passed through as-is
// TODO: It would probably be faster to determine this
// without a try/catch and a new RegExp, but it's tricky
// to do safely. For now, this is safe and works.
var cs = pattern.substring(classStart + 1, i)
try {
RegExp('[' + cs + ']')
} catch (er) {
// not a valid class!
var sp = this.parse(cs, SUBPARSE)
re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
hasMagic = hasMagic || sp[1]
inClass = false
continue
}
// finish up the class.
hasMagic = true
inClass = false
re += c
continue
default:
// swallow any state char that wasn't consumed
clearStateChar()
if (escaping) {
// no need
escaping = false
} else if (reSpecials[c]
&& !(c === '^' && inClass)) {
re += '\\'
}
re += c
} // switch
} // for
// handle the case where we left a class open.
// "[abc" is valid, equivalent to "\[abc"
if (inClass) {
// split where the last [ was, and escape it
// this is a huge pita. We now have to re-walk
// the contents of the would-be class to re-translate
// any characters that were passed through as-is
cs = pattern.substr(classStart + 1)
sp = this.parse(cs, SUBPARSE)
re = re.substr(0, reClassStart) + '\\[' + sp[0]
hasMagic = hasMagic || sp[1]
}
// handle the case where we had a +( thing at the *end*
// of the pattern.
// each pattern list stack adds 3 chars, and we need to go through
// and escape any | chars that were passed through as-is for the regexp.
// Go through and escape them, taking care not to double-escape any
// | chars that were already escaped.
for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
var tail = re.slice(pl.reStart + pl.open.length)
this.debug('setting tail', re, pl)
// maybe some even number of \, then maybe 1 \, followed by a |
tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
if (!$2) {
// the | isn't already escaped, so escape it.
$2 = '\\'
}
// need to escape all those slashes *again*, without escaping the
// one that we need for escaping the | character. As it works out,
// escaping an even number of slashes can be done by simply repeating
// it exactly after itself. That's why this trick works.
//
// I am sorry that you have to see this.
return $1 + $1 + $2 + '|'
})
this.debug('tail=%j\n %s', tail, tail, pl, re)
var t = pl.type === '*' ? star
: pl.type === '?' ? qmark
: '\\' + pl.type
hasMagic = true
re = re.slice(0, pl.reStart) + t + '\\(' + tail
}
// handle trailing things that only matter at the very end.
clearStateChar()
if (escaping) {
// trailing \\
re += '\\\\'
}
// only need to apply the nodot start if the re starts with
// something that could conceivably capture a dot
var addPatternStart = false
switch (re.charAt(0)) {
case '[': case '.': case '(': addPatternStart = true
}
// Hack to work around lack of negative lookbehind in JS
// A pattern like: *.!(x).!(y|z) needs to ensure that a name
// like 'a.xyz.yz' doesn't match. So, the first negative
// lookahead, has to look ALL the way ahead, to the end of
// the pattern.
for (var n = negativeLists.length - 1; n > -1; n--) {
var nl = negativeLists[n]
var nlBefore = re.slice(0, nl.reStart)
var nlFirst = re.slice(nl.reStart, nl.reEnd - 8)
var nlLast = re.slice(nl.reEnd - 8, nl.reEnd)
var nlAfter = re.slice(nl.reEnd)
nlLast += nlAfter
// Handle nested stuff like *(*.js|!(*.json)), where open parens
// mean that we should *not* include the ) in the bit that is considered
// "after" the negated section.
var openParensBefore = nlBefore.split('(').length - 1
var cleanAfter = nlAfter
for (i = 0; i < openParensBefore; i++) {
cleanAfter = cleanAfter.replace(/\)[+*?]?/, '')
}
nlAfter = cleanAfter
var dollar = ''
if (nlAfter === '' && isSub !== SUBPARSE) {
dollar = '$'
}
var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast
re = newRe
}
// if the re is not "" at this point, then we need to make sure
// it doesn't match against an empty path part.
// Otherwise a/* will match a/, which it should not.
if (re !== '' && hasMagic) {
re = '(?=.)' + re
}
if (addPatternStart) {
re = patternStart + re
}
// parsing just a piece of a larger pattern.
if (isSub === SUBPARSE) {
return [re, hasMagic]
}
// skip the regexp for non-magical patterns
// unescape anything in it, though, so that it'll be
// an exact match against a file etc.
if (!hasMagic) {
return globUnescape(pattern)
}
var flags = options.nocase ? 'i' : ''
try {
var regExp = new RegExp('^' + re + '$', flags)
} catch (er) /* istanbul ignore next - should be impossible */ {
// If it was an invalid regular expression, then it can't match
// anything. This trick looks for a character after the end of
// the string, which is of course impossible, except in multi-line
// mode, but it's not a /m regex.
return new RegExp('$.')
}
regExp._glob = pattern
regExp._src = re
return regExp
}
minimatch.makeRe = function (pattern, options) {
return new Minimatch(pattern, options || {}).makeRe()
}
Minimatch.prototype.makeRe = makeRe
function makeRe () {
if (this.regexp || this.regexp === false) return this.regexp
// at this point, this.set is a 2d array of partial
// pattern strings, or "**".
//
// It's better to use .match(). This function shouldn't
// be used, really, but it's pretty convenient sometimes,
// when you just want to work with a regex.
var set = this.set
if (!set.length) {
this.regexp = false
return this.regexp
}
var options = this.options
var twoStar = options.noglobstar ? star
: options.dot ? twoStarDot
: twoStarNoDot
var flags = options.nocase ? 'i' : ''
var re = set.map(function (pattern) {
return pattern.map(function (p) {
return (p === GLOBSTAR) ? twoStar
: (typeof p === 'string') ? regExpEscape(p)
: p._src
}).join('\\\/')
}).join('|')
// must match entire pattern
// ending in a * or ** will make it less strict.
re = '^(?:' + re + ')$'
// can match anything, as long as it's not this.
if (this.negate) re = '^(?!' + re + ').*$'
try {
this.regexp = new RegExp(re, flags)
} catch (ex) /* istanbul ignore next - should be impossible */ {
this.regexp = false
}
return this.regexp
}
minimatch.match = function (list, pattern, options) {
options = options || {}
var mm = new Minimatch(pattern, options)
list = list.filter(function (f) {
return mm.match(f)
})
if (mm.options.nonull && !list.length) {
list.push(pattern)
}
return list
}
Minimatch.prototype.match = function match (f, partial) {
if (typeof partial === 'undefined') partial = this.partial
this.debug('match', f, this.pattern)
// short-circuit in the case of busted things.
// comments, etc.
if (this.comment) return false
if (this.empty) return f === ''
if (f === '/' && partial) return true
var options = this.options
// windows: need to use /, not \
if (path.sep !== '/') {
f = f.split(path.sep).join('/')
}
// treat the test path as a set of pathparts.
f = f.split(slashSplit)
this.debug(this.pattern, 'split', f)
// just ONE of the pattern sets in this.set needs to match
// in order for it to be valid. If negating, then just one
// match means that we have failed.
// Either way, return on the first hit.
var set = this.set
this.debug(this.pattern, 'set', set)
// Find the basename of the path by looking for the last non-empty segment
var filename
var i
for (i = f.length - 1; i >= 0; i--) {
filename = f[i]
if (filename) break
}
for (i = 0; i < set.length; i++) {
var pattern = set[i]
var file = f
if (options.matchBase && pattern.length === 1) {
file = [filename]
}
var hit = this.matchOne(file, pattern, partial)
if (hit) {
if (options.flipNegate) return true
return !this.negate
}
}
// didn't get any hits. this is success if it's a negative
// pattern, failure otherwise.
if (options.flipNegate) return false
return this.negate
}
// set partial to true to test if, for example,
// "/a/b" matches the start of "/*/b/*/d"
// Partial means, if you run out of file before you run
// out of pattern, then that's fine, as long as all
// the parts match.
Minimatch.prototype.matchOne = function (file, pattern, partial) {
var options = this.options
this.debug('matchOne',
{ 'this': this, file: file, pattern: pattern })
this.debug('matchOne', file.length, pattern.length)
for (var fi = 0,
pi = 0,
fl = file.length,
pl = pattern.length
; (fi < fl) && (pi < pl)
; fi++, pi++) {
this.debug('matchOne loop')
var p = pattern[pi]
var f = file[fi]
this.debug(pattern, p, f)
// should be impossible.
// some invalid regexp stuff in the set.
/* istanbul ignore if */
if (p === false) return false
if (p === GLOBSTAR) {
this.debug('GLOBSTAR', [pattern, p, f])
// "**"
// a/**/b/**/c would match the following:
// a/b/x/y/z/c
// a/x/y/z/b/c
// a/b/x/b/x/c
// a/b/c
// To do this, take the rest of the pattern after
// the **, and see if it would match the file remainder.
// If so, return success.
// If not, the ** "swallows" a segment, and try again.
// This is recursively awful.
//
// a/**/b/**/c matching a/b/x/y/z/c
// - a matches a
// - doublestar
// - matchOne(b/x/y/z/c, b/**/c)
// - b matches b
// - doublestar
// - matchOne(x/y/z/c, c) -> no
// - matchOne(y/z/c, c) -> no
// - matchOne(z/c, c) -> no
// - matchOne(c, c) yes, hit
var fr = fi
var pr = pi + 1
if (pr === pl) {
this.debug('** at the end')
// a ** at the end will just swallow the rest.
// We have found a match.
// however, it will not swallow /.x, unless
// options.dot is set.
// . and .. are *never* matched by **, for explosively
// exponential reasons.
for (; fi < fl; fi++) {
if (file[fi] === '.' || file[fi] === '..' ||
(!options.dot && file[fi].charAt(0) === '.')) return false
}
return true
}
// ok, let's see if we can swallow whatever we can.
while (fr < fl) {
var swallowee = file[fr]
this.debug('\nglobstar while', file, fr, pattern, pr, swallowee)
// XXX remove this slice. Just pass the start index.
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
this.debug('globstar found match!', fr, fl, swallowee)
// found a match.
return true
} else {
// can't swallow "." or ".." ever.
// can only swallow ".foo" when explicitly asked.
if (swallowee === '.' || swallowee === '..' ||
(!options.dot && swallowee.charAt(0) === '.')) {
this.debug('dot detected!', file, fr, pattern, pr)
break
}
// ** swallows a segment, and continue.
this.debug('globstar swallow a segment, and continue')
fr++
}
}
// no match was found.
// However, in partial mode, we can't say this is necessarily over.
// If there's more *pattern* left, then
/* istanbul ignore if */
if (partial) {
// ran out of file
this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
if (fr === fl) return true
}
return false
}
// something other than **
// non-magic patterns just have to match exactly
// patterns with magic have been turned into regexps.
var hit
if (typeof p === 'string') {
hit = f === p
this.debug('string match', p, f, hit)
} else {
hit = f.match(p)
this.debug('pattern match', p, f, hit)
}
if (!hit) return false
}
// Note: ending in / means that we'll get a final ""
// at the end of the pattern. This can only match a
// corresponding "" at the end of the file.
// If the file ends in /, then it can only match a
// a pattern that ends in /, unless the pattern just
// doesn't have any more for it. But, a/b/ should *not*
// match "a/b/*", even though "" matches against the
// [^/]*? pattern, except in partial mode, where it might
// simply not be reached yet.
// However, a/b/ should still satisfy a/*
// now either we fell off the end of the pattern, or we're done.
if (fi === fl && pi === pl) {
// ran out of pattern and filename at the same time.
// an exact hit!
return true
} else if (fi === fl) {
// ran out of file, but still had pattern left.
// this is ok if we're doing the match as part of
// a glob fs traversal.
return partial
} else /* istanbul ignore else */ if (pi === pl) {
// ran out of pattern, still have file left.
// this is only acceptable if we're on the very last
// empty segment of a file with a trailing slash.
// a/* should match a/b/
return (fi === fl - 1) && (file[fi] === '')
}
// should be unreachable.
/* istanbul ignore next */
throw new Error('wtf?')
}
// replace stuff like \* with *
function globUnescape (s) {
return s.replace(/\\(.)/g, '$1')
}
function regExpEscape (s) {
return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
}

View File

@@ -0,0 +1,7 @@
/**
* @fileoverview Types for the plugin-kit package.
* @author Nicholas C. Zakas
*/
export type StringConfig = Record<string, string | null>;
export type BooleanConfig = Record<string, boolean>;

View File

@@ -0,0 +1,292 @@
/**
* This is the common logic for both the Node.js and web browser
* implementations of `debug()`.
*/
function setup(env) {
createDebug.debug = createDebug;
createDebug.default = createDebug;
createDebug.coerce = coerce;
createDebug.disable = disable;
createDebug.enable = enable;
createDebug.enabled = enabled;
createDebug.humanize = require('ms');
createDebug.destroy = destroy;
Object.keys(env).forEach(key => {
createDebug[key] = env[key];
});
/**
* The currently active debug mode names, and names to skip.
*/
createDebug.names = [];
createDebug.skips = [];
/**
* Map of special "%n" handling functions, for the debug "format" argument.
*
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
*/
createDebug.formatters = {};
/**
* Selects a color for a debug namespace
* @param {String} namespace The namespace string for the debug instance to be colored
* @return {Number|String} An ANSI color code for the given namespace
* @api private
*/
function selectColor(namespace) {
let hash = 0;
for (let i = 0; i < namespace.length; i++) {
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
hash |= 0; // Convert to 32bit integer
}
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
}
createDebug.selectColor = selectColor;
/**
* Create a debugger with the given `namespace`.
*
* @param {String} namespace
* @return {Function}
* @api public
*/
function createDebug(namespace) {
let prevTime;
let enableOverride = null;
let namespacesCache;
let enabledCache;
function debug(...args) {
// Disabled?
if (!debug.enabled) {
return;
}
const self = debug;
// Set `diff` timestamp
const curr = Number(new Date());
const ms = curr - (prevTime || curr);
self.diff = ms;
self.prev = prevTime;
self.curr = curr;
prevTime = curr;
args[0] = createDebug.coerce(args[0]);
if (typeof args[0] !== 'string') {
// Anything else let's inspect with %O
args.unshift('%O');
}
// Apply any `formatters` transformations
let index = 0;
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
// If we encounter an escaped % then don't increase the array index
if (match === '%%') {
return '%';
}
index++;
const formatter = createDebug.formatters[format];
if (typeof formatter === 'function') {
const val = args[index];
match = formatter.call(self, val);
// Now we need to remove `args[index]` since it's inlined in the `format`
args.splice(index, 1);
index--;
}
return match;
});
// Apply env-specific formatting (colors, etc.)
createDebug.formatArgs.call(self, args);
const logFn = self.log || createDebug.log;
logFn.apply(self, args);
}
debug.namespace = namespace;
debug.useColors = createDebug.useColors();
debug.color = createDebug.selectColor(namespace);
debug.extend = extend;
debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
Object.defineProperty(debug, 'enabled', {
enumerable: true,
configurable: false,
get: () => {
if (enableOverride !== null) {
return enableOverride;
}
if (namespacesCache !== createDebug.namespaces) {
namespacesCache = createDebug.namespaces;
enabledCache = createDebug.enabled(namespace);
}
return enabledCache;
},
set: v => {
enableOverride = v;
}
});
// Env-specific initialization logic for debug instances
if (typeof createDebug.init === 'function') {
createDebug.init(debug);
}
return debug;
}
function extend(namespace, delimiter) {
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
newDebug.log = this.log;
return newDebug;
}
/**
* Enables a debug mode by namespaces. This can include modes
* separated by a colon and wildcards.
*
* @param {String} namespaces
* @api public
*/
function enable(namespaces) {
createDebug.save(namespaces);
createDebug.namespaces = namespaces;
createDebug.names = [];
createDebug.skips = [];
const split = (typeof namespaces === 'string' ? namespaces : '')
.trim()
.replace(' ', ',')
.split(',')
.filter(Boolean);
for (const ns of split) {
if (ns[0] === '-') {
createDebug.skips.push(ns.slice(1));
} else {
createDebug.names.push(ns);
}
}
}
/**
* Checks if the given string matches a namespace template, honoring
* asterisks as wildcards.
*
* @param {String} search
* @param {String} template
* @return {Boolean}
*/
function matchesTemplate(search, template) {
let searchIndex = 0;
let templateIndex = 0;
let starIndex = -1;
let matchIndex = 0;
while (searchIndex < search.length) {
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
// Match character or proceed with wildcard
if (template[templateIndex] === '*') {
starIndex = templateIndex;
matchIndex = searchIndex;
templateIndex++; // Skip the '*'
} else {
searchIndex++;
templateIndex++;
}
} else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
// Backtrack to the last '*' and try to match more characters
templateIndex = starIndex + 1;
matchIndex++;
searchIndex = matchIndex;
} else {
return false; // No match
}
}
// Handle trailing '*' in template
while (templateIndex < template.length && template[templateIndex] === '*') {
templateIndex++;
}
return templateIndex === template.length;
}
/**
* Disable debug output.
*
* @return {String} namespaces
* @api public
*/
function disable() {
const namespaces = [
...createDebug.names,
...createDebug.skips.map(namespace => '-' + namespace)
].join(',');
createDebug.enable('');
return namespaces;
}
/**
* Returns true if the given mode name is enabled, false otherwise.
*
* @param {String} name
* @return {Boolean}
* @api public
*/
function enabled(name) {
for (const skip of createDebug.skips) {
if (matchesTemplate(name, skip)) {
return false;
}
}
for (const ns of createDebug.names) {
if (matchesTemplate(name, ns)) {
return true;
}
}
return false;
}
/**
* Coerce `val`.
*
* @param {Mixed} val
* @return {Mixed}
* @api private
*/
function coerce(val) {
if (val instanceof Error) {
return val.stack || val.message;
}
return val;
}
/**
* XXX DO NOT USE. This is a temporary stub function.
* XXX It WILL be removed in the next major release.
*/
function destroy() {
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
}
createDebug.enable(createDebug.load());
return createDebug;
}
module.exports = setup;

View File

@@ -0,0 +1,66 @@
{
"name": "js-yaml",
"version": "4.1.0",
"description": "YAML 1.2 parser and serializer",
"keywords": [
"yaml",
"parser",
"serializer",
"pyyaml"
],
"author": "Vladimir Zapparov <dervus.grim@gmail.com>",
"contributors": [
"Aleksey V Zapparov <ixti@member.fsf.org> (http://www.ixti.net/)",
"Vitaly Puzrin <vitaly@rcdesign.ru> (https://github.com/puzrin)",
"Martin Grenfell <martin.grenfell@gmail.com> (http://got-ravings.blogspot.com)"
],
"license": "MIT",
"repository": "nodeca/js-yaml",
"files": [
"index.js",
"lib/",
"bin/",
"dist/"
],
"bin": {
"js-yaml": "bin/js-yaml.js"
},
"module": "./dist/js-yaml.mjs",
"exports": {
".": {
"import": "./dist/js-yaml.mjs",
"require": "./index.js"
},
"./package.json": "./package.json"
},
"scripts": {
"lint": "eslint .",
"test": "npm run lint && mocha",
"coverage": "npm run lint && nyc mocha && nyc report --reporter html",
"demo": "npm run lint && node support/build_demo.js",
"gh-demo": "npm run demo && gh-pages -d demo -f",
"browserify": "rollup -c support/rollup.config.js",
"prepublishOnly": "npm run gh-demo"
},
"unpkg": "dist/js-yaml.min.js",
"jsdelivr": "dist/js-yaml.min.js",
"dependencies": {
"argparse": "^2.0.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"ansi": "^0.3.1",
"benchmark": "^2.1.4",
"codemirror": "^5.13.4",
"eslint": "^7.0.0",
"fast-check": "^2.8.0",
"gh-pages": "^3.1.0",
"mocha": "^8.2.1",
"nyc": "^15.1.0",
"rollup": "^2.34.1",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-terser": "^7.0.2",
"shelljs": "^0.8.4"
}
}

View File

@@ -0,0 +1,47 @@
import { Store } from './store.js';
import { Listener } from './types.js';
export type UnwrapDerivedOrStore<T> = T extends Derived<infer InnerD> ? InnerD : T extends Store<infer InnerS> ? InnerS : never;
type UnwrapReadonlyDerivedOrStoreArray<TArr extends ReadonlyArray<Derived<any> | Store<any>>> = TArr extends readonly [infer Head, ...infer Tail] ? Head extends Derived<any> | Store<any> ? Tail extends ReadonlyArray<Derived<any> | Store<any>> ? [UnwrapDerivedOrStore<Head>, ...UnwrapReadonlyDerivedOrStoreArray<Tail>] : [] : [] : [];
export interface DerivedFnProps<TArr extends ReadonlyArray<Derived<any> | Store<any>> = ReadonlyArray<any>, TUnwrappedArr extends UnwrapReadonlyDerivedOrStoreArray<TArr> = UnwrapReadonlyDerivedOrStoreArray<TArr>> {
/**
* `undefined` if it's the first run
* @privateRemarks this also cannot be typed as TState, as it breaks the inferencing of the function's return type when an argument is used - even with `NoInfer` usage
*/
prevVal: unknown | undefined;
prevDepVals: TUnwrappedArr | undefined;
currDepVals: TUnwrappedArr;
}
export interface DerivedOptions<TState, TArr extends ReadonlyArray<Derived<any> | Store<any>> = ReadonlyArray<any>> {
onSubscribe?: (listener: Listener<TState>, derived: Derived<TState>) => () => void;
onUpdate?: () => void;
deps: TArr;
/**
* Values of the `deps` from before and after the current invocation of `fn`
*/
fn: (props: DerivedFnProps<TArr>) => TState;
}
export declare class Derived<TState, const TArr extends ReadonlyArray<Derived<any> | Store<any>> = ReadonlyArray<any>> {
listeners: Set<Listener<TState>>;
state: TState;
prevState: TState | undefined;
options: DerivedOptions<TState, TArr>;
/**
* Functions representing the subscriptions. Call a function to cleanup
* @private
*/
_subscriptions: Array<() => void>;
lastSeenDepValues: Array<unknown>;
getDepVals: () => {
prevDepVals: unknown[];
currDepVals: unknown[];
prevVal: NonNullable<TState> | undefined;
};
constructor(options: DerivedOptions<TState, TArr>);
registerOnGraph(deps?: ReadonlyArray<Derived<any> | Store<any>>): void;
unregisterFromGraph(deps?: ReadonlyArray<Derived<any> | Store<any>>): void;
recompute: () => void;
checkIfRecalculationNeededDeeply: () => void;
mount: () => () => void;
subscribe: (listener: Listener<TState>) => () => void;
}
export {};

View File

@@ -0,0 +1,18 @@
import { Derived, DerivedOptions } from './derived.js';
interface EffectOptions extends Omit<DerivedOptions<unknown>, 'onUpdate' | 'onSubscribe' | 'lazy' | 'fn'> {
/**
* Should the effect trigger immediately?
* @default false
*/
eager?: boolean;
fn: () => void;
}
export declare class Effect {
/**
* @private
*/
_derived: Derived<void>;
constructor(opts: EffectOptions);
mount(): () => void;
}
export {};

View File

@@ -0,0 +1,59 @@
'use strict';
const isWin = process.platform === 'win32';
function notFoundError(original, syscall) {
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
code: 'ENOENT',
errno: 'ENOENT',
syscall: `${syscall} ${original.command}`,
path: original.command,
spawnargs: original.args,
});
}
function hookChildProcess(cp, parsed) {
if (!isWin) {
return;
}
const originalEmit = cp.emit;
cp.emit = function (name, arg1) {
// If emitting "exit" event and exit code is 1, we need to check if
// the command exists and emit an "error" instead
// See https://github.com/IndigoUnited/node-cross-spawn/issues/16
if (name === 'exit') {
const err = verifyENOENT(arg1, parsed);
if (err) {
return originalEmit.call(cp, 'error', err);
}
}
return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
};
}
function verifyENOENT(status, parsed) {
if (isWin && status === 1 && !parsed.file) {
return notFoundError(parsed.original, 'spawn');
}
return null;
}
function verifyENOENTSync(status, parsed) {
if (isWin && status === 1 && !parsed.file) {
return notFoundError(parsed.original, 'spawnSync');
}
return null;
}
module.exports = {
hookChildProcess,
verifyENOENT,
verifyENOENTSync,
notFoundError,
};