@modern-js/utils
Version:
A Progressive React Framework for modern web development.
1,545 lines • 986 kB
JavaScript
/*! LICENSE: index.js.LICENSE.txt */
(()=>{
var e = {
933: (e)=>{
"use strict";
const t = e.exports;
e.exports["default"] = t;
const r = "[";
const n = "]";
const i = "";
const o = ";";
const u = "Apple_Terminal" === process.env.TERM_PROGRAM;
t.cursorTo = (e, t)=>{
if ("number" != typeof e) throw new TypeError("The `x` argument is required");
if ("number" != typeof t) return r + (e + 1) + "G";
return r + (t + 1) + ";" + (e + 1) + "H";
};
t.cursorMove = (e, t)=>{
if ("number" != typeof e) throw new TypeError("The `x` argument is required");
let n = "";
if (e < 0) n += r + -e + "D";
else if (e > 0) n += r + e + "C";
if (t < 0) n += r + -t + "A";
else if (t > 0) n += r + t + "B";
return n;
};
t.cursorUp = (e = 1)=>r + e + "A";
t.cursorDown = (e = 1)=>r + e + "B";
t.cursorForward = (e = 1)=>r + e + "C";
t.cursorBackward = (e = 1)=>r + e + "D";
t.cursorLeft = r + "G";
t.cursorSavePosition = u ? "7" : r + "s";
t.cursorRestorePosition = u ? "8" : r + "u";
t.cursorGetPosition = r + "6n";
t.cursorNextLine = r + "E";
t.cursorPrevLine = r + "F";
t.cursorHide = r + "?25l";
t.cursorShow = r + "?25h";
t.eraseLines = (e)=>{
let r = "";
for(let n = 0; n < e; n++)r += t.eraseLine + (n < e - 1 ? t.cursorUp() : "");
if (e) r += t.cursorLeft;
return r;
};
t.eraseEndLine = r + "K";
t.eraseStartLine = r + "1K";
t.eraseLine = r + "2K";
t.eraseDown = r + "J";
t.eraseUp = r + "1J";
t.eraseScreen = r + "2J";
t.scrollUp = r + "S";
t.scrollDown = r + "T";
t.clearScreen = "c";
t.clearTerminal = "win32" === process.platform ? `${t.eraseScreen}${r}0f` : `${t.eraseScreen}${r}3J${r}H`;
t.beep = i;
t.link = (e, t)=>[
n,
"8",
o,
o,
t,
i,
e,
n,
"8",
o,
o,
i
].join("");
t.image = (e, t = {})=>{
let r = `${n}1337;File=inline=1`;
if (t.width) r += `;width=${t.width}`;
if (t.height) r += `;height=${t.height}`;
if (false === t.preserveAspectRatio) r += ";preserveAspectRatio=0";
return r + ":" + e.toString("base64") + i;
};
t.iTerm = {
setCwd: (e = process.cwd())=>`${n}50;CurrentDir=${e}${i}`,
annotation: (e, t = {})=>{
let r = `${n}1337;`;
const o = void 0 !== t.x;
const u = void 0 !== t.y;
if ((o || u) && !(o && u && void 0 !== t.length)) throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");
e = e.replace(/\|/g, "");
r += t.isHidden ? "AddHiddenAnnotation=" : "AddAnnotation=";
if (t.length > 0) r += (o ? [
e,
t.length,
t.x,
t.y
] : [
t.length,
e
]).join("|");
else r += e;
return r + i;
}
};
},
5133: (e, t, r)=>{
var n = r(3837), i = r(3527);
function ISO_2022() {}
ISO_2022.prototype.match = function(e) {
var t, r;
var n;
var o = 0;
var u = 0;
var a = 0;
var s;
var c = e.fInputBytes;
var l = e.fInputLen;
e: for(t = 0; t < l; t++){
if (27 == c[t]) {
t: for(n = 0; n < this.escapeSequences.length; n++){
var f = this.escapeSequences[n];
if (!(l - t < f.length)) {
for(r = 1; r < f.length; r++)if (f[r] != c[t + r]) continue t;
o++;
t += f.length - 1;
continue e;
}
}
u++;
}
if (14 == c[t] || 15 == c[t]) a++;
}
if (0 == o) return null;
s = (100 * o - 100 * u) / (o + u);
if (o + a < 5) s -= (5 - (o + a)) * 10;
return s <= 0 ? null : new i(e, this, s);
};
e.exports.ISO_2022_JP = function() {
this.name = function() {
return "ISO-2022-JP";
};
this.escapeSequences = [
[
27,
36,
40,
67
],
[
27,
36,
40,
68
],
[
27,
36,
64
],
[
27,
36,
65
],
[
27,
36,
66
],
[
27,
38,
64
],
[
27,
40,
66
],
[
27,
40,
72
],
[
27,
40,
73
],
[
27,
40,
74
],
[
27,
46,
65
],
[
27,
46,
70
]
];
};
n.inherits(e.exports.ISO_2022_JP, ISO_2022);
e.exports.ISO_2022_KR = function() {
this.name = function() {
return "ISO-2022-KR";
};
this.escapeSequences = [
[
27,
36,
41,
67
]
];
};
n.inherits(e.exports.ISO_2022_KR, ISO_2022);
e.exports.ISO_2022_CN = function() {
this.name = function() {
return "ISO-2022-CN";
};
this.escapeSequences = [
[
27,
36,
41,
65
],
[
27,
36,
41,
71
],
[
27,
36,
42,
72
],
[
27,
36,
41,
69
],
[
27,
36,
43,
73
],
[
27,
36,
43,
74
],
[
27,
36,
43,
75
],
[
27,
36,
43,
76
],
[
27,
36,
43,
77
],
[
27,
78
],
[
27,
79
]
];
};
n.inherits(e.exports.ISO_2022_CN, ISO_2022);
},
8941: (e, t, r)=>{
var n = r(3837), i = r(3527);
function binarySearch(e, t) {
function find(e, t, r, n) {
if (n < r) return -1;
var i = Math.floor(r + n >>> 1);
if (t > e[i]) return find(e, t, i + 1, n);
if (t < e[i]) return find(e, t, r, i - 1);
return i;
}
return find(e, t, 0, e.length - 1);
}
function IteratedChar() {
this.charValue = 0;
this.index = 0;
this.nextIndex = 0;
this.error = false;
this.done = false;
this.reset = function() {
this.charValue = 0;
this.index = -1;
this.nextIndex = 0;
this.error = false;
this.done = false;
};
this.nextByte = function(e) {
if (this.nextIndex >= e.fRawLength) {
this.done = true;
return -1;
}
var t = 255 & e.fRawInput[this.nextIndex++];
return t;
};
}
function mbcs() {}
mbcs.prototype.match = function(e) {
var r = 0, n = 0, o = 0, u = 0, a = 0;
var s = new IteratedChar;
e: {
for(s.reset(); this.nextChar(s, e);){
u++;
if (s.error) o++;
else {
var c = 0 | s.charValue;
if (c <= 255) ;
else {
r++;
if (null != this.commonChars) {
if (binarySearch(this.commonChars, c) >= 0) n++;
}
}
}
if (o >= 2 && 5 * o >= r) break e;
}
if (r <= 10 && 0 == o) {
a = 0 == r && u < 10 ? 0 : 10;
break e;
}
if (r < 20 * o) {
a = 0;
break e;
}
if (null == this.commonChars) {
a = 30 + r - 20 * o;
if (a > 100) a = 100;
} else {
var l = Math.log(parseFloat(r) / 4);
var f = 90 / l;
a = Math.floor(Math.log(n + 1) * f + 10);
a = Math.min(a, 100);
}
}
return 0 == a ? null : new i(e, this, a);
};
mbcs.prototype.nextChar = function(e, t) {};
e.exports.sjis = function() {
this.name = function() {
return "Shift-JIS";
};
this.language = function() {
return "ja";
};
this.commonChars = [
33088,
33089,
33090,
33093,
33115,
33129,
33130,
33141,
33142,
33440,
33442,
33444,
33449,
33450,
33451,
33453,
33455,
33457,
33459,
33461,
33463,
33469,
33470,
33473,
33476,
33477,
33478,
33480,
33481,
33484,
33485,
33500,
33504,
33511,
33512,
33513,
33514,
33520,
33521,
33601,
33603,
33614,
33615,
33624,
33630,
33634,
33639,
33653,
33654,
33673,
33674,
33675,
33677,
33683,
36502,
37882,
38314
];
this.nextChar = function(e, t) {
e.index = e.nextIndex;
e.error = false;
var r;
r = e.charValue = e.nextByte(t);
if (r < 0) return false;
if (r <= 127 || r > 160 && r <= 223) return true;
var n = e.nextByte(t);
if (n < 0) return false;
e.charValue = r << 8 | n;
if (!(n >= 64 && n <= 127 || n >= 128 && n <= 255)) e.error = true;
return true;
};
};
n.inherits(e.exports.sjis, mbcs);
e.exports.big5 = function() {
this.name = function() {
return "Big5";
};
this.language = function() {
return "zh";
};
this.commonChars = [
41280,
41281,
41282,
41283,
41287,
41289,
41333,
41334,
42048,
42054,
42055,
42056,
42065,
42068,
42071,
42084,
42090,
42092,
42103,
42147,
42148,
42151,
42177,
42190,
42193,
42207,
42216,
42237,
42304,
42312,
42328,
42345,
42445,
42471,
42583,
42593,
42594,
42600,
42608,
42664,
42675,
42681,
42707,
42715,
42726,
42738,
42816,
42833,
42841,
42970,
43171,
43173,
43181,
43217,
43219,
43236,
43260,
43456,
43474,
43507,
43627,
43706,
43710,
43724,
43772,
44103,
44111,
44208,
44242,
44377,
44745,
45024,
45290,
45423,
45747,
45764,
45935,
46156,
46158,
46412,
46501,
46525,
46544,
46552,
46705,
47085,
47207,
47428,
47832,
47940,
48033,
48593,
49860,
50105,
50240,
50271
];
this.nextChar = function(e, t) {
e.index = e.nextIndex;
e.error = false;
var r = e.charValue = e.nextByte(t);
if (r < 0) return false;
if (r <= 127 || 255 == r) return true;
var n = e.nextByte(t);
if (n < 0) return false;
e.charValue = e.charValue << 8 | n;
if (n < 64 || 127 == n || 255 == n) e.error = true;
return true;
};
};
n.inherits(e.exports.big5, mbcs);
function eucNextChar(e, t) {
e.index = e.nextIndex;
e.error = false;
var r = 0;
var n = 0;
var i = 0;
e: {
r = e.charValue = e.nextByte(t);
if (r < 0) {
e.done = true;
break e;
}
if (r <= 141) break e;
n = e.nextByte(t);
e.charValue = e.charValue << 8 | n;
if (r >= 161 && r <= 254) {
if (n < 161) e.error = true;
break e;
}
if (142 == r) {
if (n < 161) e.error = true;
break e;
}
if (143 == r) {
i = e.nextByte(t);
e.charValue = e.charValue << 8 | i;
if (i < 161) e.error = true;
}
}
return false == e.done;
}
e.exports.euc_jp = function() {
this.name = function() {
return "EUC-JP";
};
this.language = function() {
return "ja";
};
this.commonChars = [
41377,
41378,
41379,
41382,
41404,
41418,
41419,
41430,
41431,
42146,
42148,
42150,
42152,
42154,
42155,
42156,
42157,
42159,
42161,
42163,
42165,
42167,
42169,
42171,
42173,
42175,
42176,
42177,
42179,
42180,
42182,
42183,
42184,
42185,
42186,
42187,
42190,
42191,
42192,
42206,
42207,
42209,
42210,
42212,
42216,
42217,
42218,
42219,
42220,
42223,
42226,
42227,
42402,
42403,
42404,
42406,
42407,
42410,
42413,
42415,
42416,
42419,
42421,
42423,
42424,
42425,
42431,
42435,
42438,
42439,
42440,
42441,
42443,
42448,
42453,
42454,
42455,
42462,
42464,
42465,
42469,
42473,
42474,
42475,
42476,
42477,
42483,
47273,
47572,
47854,
48072,
48880,
49079,
50410,
50940,
51133,
51896,
51955,
52188,
52689
];
this.nextChar = eucNextChar;
};
n.inherits(e.exports.euc_jp, mbcs);
e.exports.euc_kr = function() {
this.name = function() {
return "EUC-KR";
};
this.language = function() {
return "ko";
};
this.commonChars = [
45217,
45235,
45253,
45261,
45268,
45286,
45293,
45304,
45306,
45308,
45496,
45497,
45511,
45527,
45538,
45994,
46011,
46274,
46287,
46297,
46315,
46501,
46517,
46527,
46535,
46569,
46835,
47023,
47042,
47054,
47270,
47278,
47286,
47288,
47291,
47337,
47531,
47534,
47564,
47566,
47613,
47800,
47822,
47824,
47857,
48103,
48115,
48125,
48301,
48314,
48338,
48374,
48570,
48576,
48579,
48581,
48838,
48840,
48863,
48878,
48888,
48890,
49057,
49065,
49088,
49124,
49131,
49132,
49144,
49319,
49327,
49336,
49338,
49339,
49341,
49351,
49356,
49358,
49359,
49366,
49370,
49381,
49403,
49404,
49572,
49574,
49590,
49622,
49631,
49654,
49656,
50337,
50637,
50862,
51151,
51153,
51154,
51160,
51173,
51373
];
this.nextChar = eucNextChar;
};
n.inherits(e.exports.euc_kr, mbcs);
e.exports.gb_18030 = function() {
this.name = function() {
return "GB18030";
};
this.language = function() {
return "zh";
};
this.nextChar = function(e, t) {
e.index = e.nextIndex;
e.error = false;
var r = 0;
var n = 0;
var i = 0;
var o = 0;
e: {
r = e.charValue = e.nextByte(t);
if (r < 0) {
e.done = true;
break e;
}
if (r <= 128) break e;
n = e.nextByte(t);
e.charValue = e.charValue << 8 | n;
if (r >= 129 && r <= 254) {
if (n >= 64 && n <= 126 || n >= 80 && n <= 254) break e;
if (n >= 48 && n <= 57) {
i = e.nextByte(t);
if (i >= 129 && i <= 254) {
o = e.nextByte(t);
if (o >= 48 && o <= 57) {
e.charValue = e.charValue << 16 | i << 8 | o;
break e;
}
}
}
e.error = true;
break e;
}
}
return false == e.done;
};
this.commonChars = [
41377,
41378,
41379,
41380,
41392,
41393,
41457,
41459,
41889,
41900,
41914,
45480,
45496,
45502,
45755,
46025,
46070,
46323,
46525,
46532,
46563,
46767,
46804,
46816,
47010,
47016,
47037,
47062,
47069,
47284,
47327,
47350,
47531,
47561,
47576,
47610,
47613,
47821,
48039,
48086,
48097,
48122,
48316,
48347,
48382,
48588,
48845,
48861,
49076,
49094,
49097,
49332,
49389,
49611,
49883,
50119,
50396,
50410,
50636,
50935,
51192,
51371,
51403,
51413,
51431,
51663,
51706,
51889,
51893,
51911,
51920,
51926,
51957,
51965,
52460,
52728,
52906,
52932,
52946,
52965,
53173,
53186,
53206,
53442,
53445,
53456,
53460,
53671,
53930,
53938,
53941,
53947,
53972,
54211,
54224,
54269,
54466,
54490,
54754,
54992
];
};
n.inherits(e.exports.gb_18030, mbcs);
},
183: (e, t, r)=>{
var n = r(3837), i = r(3527);
function NGramParser(e, t) {
var r = 16777215;
this.byteIndex = 0;
this.ngram = 0;
this.ngramList = e;
this.byteMap = t;
this.ngramCount = 0;
this.hitCount = 0;
this.spaceChar;
this.search = function(e, t) {
var r = 0;
if (e[r + 32] <= t) r += 32;
if (e[r + 16] <= t) r += 16;
if (e[r + 8] <= t) r += 8;
if (e[r + 4] <= t) r += 4;
if (e[r + 2] <= t) r += 2;
if (e[r + 1] <= t) r += 1;
if (e[r] > t) r -= 1;
if (r < 0 || e[r] != t) return -1;
return r;
};
this.lookup = function(e) {
this.ngramCount += 1;
if (this.search(this.ngramList, e) >= 0) this.hitCount += 1;
};
this.addByte = function(e) {
this.ngram = (this.ngram << 8) + (255 & e) & r;
this.lookup(this.ngram);
};
this.nextByte = function(e) {
if (this.byteIndex >= e.fInputLen) return -1;
return 255 & e.fInputBytes[this.byteIndex++];
};
this.parse = function(e, t) {
var r, n = false;
this.spaceChar = t;
while((r = this.nextByte(e)) >= 0){
var i = this.byteMap[r];
if (0 != i) {
if (!(i == this.spaceChar && n)) this.addByte(i);
n = i == this.spaceChar;
}
}
this.addByte(this.spaceChar);
var o = this.hitCount / this.ngramCount;
if (o > .33) return 98;
return Math.floor(300 * o);
};
}
function NGramsPlusLang(e, t) {
this.fLang = e;
this.fNGrams = t;
}
function sbcs() {}
sbcs.prototype.spaceChar = 32;
sbcs.prototype.ngrams = function() {};
sbcs.prototype.byteMap = function() {};
sbcs.prototype.match = function(e) {
var t = this.ngrams();
var r = Array.isArray(t) && t[0] instanceof NGramsPlusLang;
if (!r) {
var n = new NGramParser(t, this.byteMap());
var o = n.parse(e, this.spaceChar);
return o <= 0 ? null : new i(e, this, o);
}
var u = -1;
var a = null;
for(var s = t.length - 1; s >= 0; s--){
var c = t[s];
var n = new NGramParser(c.fNGrams, this.byteMap());
var o = n.parse(e, this.spaceChar);
if (o > u) {
u = o;
a = c.fLang;
}
}
var l = this.name(e);
return u <= 0 ? null : new i(e, this, u, l, a);
};
e.exports.ISO_8859_1 = function() {
this.byteMap = function() {
return [
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
0,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
97,
98,
99,
100,
101,
102,
103,
104,
105,
106,
107,
108,
109,
110,
111,
112,
113,
114,
115,
116,
117,
118,
119,
120,
121,
122,
32,
32,
32,
32,
32,
32,
97,
98,
99,
100,
101,
102,
103,
104,
105,
106,
107,
108,
109,
110,
111,
112,
113,
114,
115,
116,
117,
118,
119,
120,
121,
122,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
170,
32,
32,
32,
32,
32,
32,
32,
32,
32,
32,
181,
32,
32,
32,
32,
186,
32,
32,
32,
32,
32,
224,
225,
226,
227,
228,
229,
230,
231,
232,
233,
234,
235,
236,
237,
238,
239,
240,
241,
242,
243,
244,
245,
246,
32,
248,
249,
250,
251,
252,
253,
254,
223,
224,
225,
226,
227,
228,
229,
230,
231,
232,
233,
234,
235,
236,
237,
238,
239,
240,
241,
242,
243,
244,
245,
246,
32,
248,
249,
250,
251,
252,
253,
254,
255
];
};
this.ngrams = function() {
return [
new NGramsPlusLang("da", [
2122086,
2122100,
2122853,
2123118,
2123122,
2123375,
2123873,
2124064,
2125157,
2125671,
2126053,
2126697,
2126708,
2126953,
2127465,
6383136,
6385184,
6385252,
6386208,
6386720,
6579488,
6579566,
6579570,
6579572,
6627443,
6644768,
6644837,
6647328,
6647396,
6648352,
6648421,
6648608,
6648864,
6713202,
6776096,
6776174,
6776178,
6907749,
6908960,
6909543,
7038240,
7039845,
7103858,
7104871,
7105637,
7169380,
7234661,
7234848,
7235360,
7235429,
7300896,
7302432,
7303712,
7398688,
7479396,
7479397,
7479411,
7496992,
7566437,
7610483,
7628064,
7628146,
7629164,
7759218
]),
new NGramsPlusLang("de", [
2122094,
2122101,
2122341,
2122849,
2122853,
2122857,
2123113,
2123621,
2123873,
2124142,
2125161,
2126691,
2126693,
2127214,
2127461,
2127471,
2127717,
2128501,
6448498,
6514720,
6514789,
6514804,
6578547,
6579566,
6579570,
6580581,
6627428,
6627443,
6646126,
6646132,
6647328,
6648352,
6648608,
6776174,
6841710,
6845472,
6906728,
6907168,
6909472,
6909541,
6911008,
7104867,
7105637,
7217249,
7217252,
7217267,
7234592,
7234661,
7234848,
7235360,
7235429,
7238757,
7479396,
7496805,
7497065,
7562088,
7566437,
7610468,
7628064,
7628142,
7628146,
7695972,
7695975,
7759218
]),
new NGramsPlusLang("en", [
2122016,
2122094,
2122341,
2122607,
2123375,
2123873,
2123877,
2124142,
2125153,
2125670,
2125938,
2126437,
2126689,
2126708,
2126952,
2126959,
2127720,
6383972,
6384672,
6385184,
6385252,
6386464,
6386720,
6386789,
6386793,
6561889,
6561908,
6627425,
6627443,
6627444,
6644768,
6647412,
6648352,
6648608,
6713202,
6840692,
6841632,
6841714,
6906912,
6909472,
6909543,
6909806,
6910752,
7217249,
7217268,
7234592,
7235360,
7238688,
7300640,
7302688,
7303712,
7496992,
7500576,
7544929,
7544948,
7561577,
7566368,
7610484,
7628146,
7628897,
7628901,
7629167,
7630624,
7631648
]),
new NGramsPlusLang("es", [
2122016,
2122593,
2122607,
2122853,
2123116,
2123118,
2123123,
2124142,
2124897,
2124911,
2125921,
2125935,
2125938,
2126197,
2126437,
2126693,
2127214,
2128160,
6365283,
6365284,
6365285,
6365292,
6365296,
6382441,
6382703,
6384672,
6386208,
6386464,
6515187,
6516590,
6579488,
6579564,
6582048,
6627428,
6627429,
6627436,
6646816,
6647328,
6647412,
664860