@socketsecurity/cli-with-sentry 0.14.137 → 0.14.138
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blessed/LICENSE +20 -0
- package/dist/blessed/lib/alias.js +519 -0
- package/dist/blessed/lib/blessed.js +32 -0
- package/dist/blessed/lib/colors.js +490 -0
- package/dist/blessed/lib/events.js +195 -0
- package/dist/blessed/lib/gpmclient.js +245 -0
- package/dist/blessed/lib/helpers.js +170 -0
- package/dist/blessed/lib/keys.js +512 -0
- package/dist/blessed/lib/program.js +4530 -0
- package/dist/blessed/lib/tput.js +3111 -0
- package/dist/blessed/lib/unicode.js +912 -0
- package/dist/blessed/lib/widget.js +60 -0
- package/dist/blessed/lib/widgets/ansiimage.js +173 -0
- package/dist/blessed/lib/widgets/bigtext.js +170 -0
- package/dist/blessed/lib/widgets/box.js +34 -0
- package/dist/blessed/lib/widgets/button.js +62 -0
- package/dist/blessed/lib/widgets/checkbox.js +95 -0
- package/dist/blessed/lib/widgets/element.js +2871 -0
- package/dist/blessed/lib/widgets/filemanager.js +223 -0
- package/dist/blessed/lib/widgets/form.js +301 -0
- package/dist/blessed/lib/widgets/image.js +71 -0
- package/dist/blessed/lib/widgets/input.js +34 -0
- package/dist/blessed/lib/widgets/layout.js +249 -0
- package/dist/blessed/lib/widgets/line.js +59 -0
- package/dist/blessed/lib/widgets/list.js +652 -0
- package/dist/blessed/lib/widgets/listbar.js +452 -0
- package/dist/blessed/lib/widgets/listtable.js +265 -0
- package/dist/blessed/lib/widgets/loading.js +88 -0
- package/dist/blessed/lib/widgets/log.js +82 -0
- package/dist/blessed/lib/widgets/message.js +145 -0
- package/dist/blessed/lib/widgets/node.js +314 -0
- package/dist/blessed/lib/widgets/overlayimage.js +794 -0
- package/dist/blessed/lib/widgets/progressbar.js +166 -0
- package/dist/blessed/lib/widgets/prompt.js +127 -0
- package/dist/blessed/lib/widgets/question.js +129 -0
- package/dist/blessed/lib/widgets/radiobutton.js +62 -0
- package/dist/blessed/lib/widgets/radioset.js +36 -0
- package/dist/blessed/lib/widgets/screen.js +2485 -0
- package/dist/blessed/lib/widgets/scrollablebox.js +415 -0
- package/dist/blessed/lib/widgets/scrollabletext.js +35 -0
- package/dist/blessed/lib/widgets/table.js +383 -0
- package/dist/blessed/lib/widgets/terminal.js +452 -0
- package/dist/blessed/lib/widgets/text.js +35 -0
- package/dist/blessed/lib/widgets/textarea.js +376 -0
- package/dist/blessed/lib/widgets/textbox.js +79 -0
- package/dist/blessed/lib/widgets/video.js +130 -0
- package/dist/blessed/usr/fonts/AUTHORS +1 -0
- package/dist/blessed/usr/fonts/LICENSE +94 -0
- package/dist/blessed/usr/fonts/README +340 -0
- package/dist/blessed/usr/fonts/ter-u14b.json +17826 -0
- package/dist/blessed/usr/fonts/ter-u14n.json +17826 -0
- package/dist/blessed/usr/linux +0 -0
- package/dist/blessed/usr/windows-ansi +0 -0
- package/dist/blessed/usr/xterm +0 -0
- package/dist/blessed/usr/xterm-256color +0 -0
- package/dist/blessed/usr/xterm.termcap +243 -0
- package/dist/blessed/usr/xterm.terminfo +1977 -0
- package/dist/blessed/vendor/tng.js +1876 -0
- package/dist/blessed-contrib/LICENSE.md +21 -0
- package/dist/blessed-contrib/lib/layout/carousel.js +82 -0
- package/dist/blessed-contrib/lib/layout/grid.js +46 -0
- package/dist/blessed-contrib/lib/server-utils.js +83 -0
- package/dist/blessed-contrib/lib/utils.js +73 -0
- package/dist/blessed-contrib/lib/widget/canvas.js +52 -0
- package/dist/blessed-contrib/lib/widget/charts/bar.js +99 -0
- package/dist/blessed-contrib/lib/widget/charts/line.js +311 -0
- package/dist/blessed-contrib/lib/widget/charts/stacked-bar.js +245 -0
- package/dist/blessed-contrib/lib/widget/donut.js +183 -0
- package/dist/blessed-contrib/lib/widget/gauge-list.js +111 -0
- package/dist/blessed-contrib/lib/widget/gauge.js +127 -0
- package/dist/blessed-contrib/lib/widget/lcd.js +497 -0
- package/dist/blessed-contrib/lib/widget/log.js +32 -0
- package/dist/blessed-contrib/lib/widget/map.js +97 -0
- package/dist/blessed-contrib/lib/widget/markdown.js +68 -0
- package/dist/blessed-contrib/lib/widget/picture.js +61 -0
- package/dist/blessed-contrib/lib/widget/sparkline.js +66 -0
- package/dist/blessed-contrib/lib/widget/table.js +141 -0
- package/dist/blessed-contrib/lib/widget/tree.js +179 -0
- package/dist/blessed-contrib/node_modules/ansi-regex/index.js +6 -0
- package/dist/blessed-contrib/node_modules/ansi-regex/license +21 -0
- package/dist/blessed-contrib/node_modules/ansi-regex/package.json +64 -0
- package/dist/blessed-contrib/node_modules/ansi-regex/readme.md +39 -0
- package/dist/blessed-contrib/node_modules/ansi-styles/index.js +67 -0
- package/dist/blessed-contrib/node_modules/ansi-styles/license +21 -0
- package/dist/blessed-contrib/node_modules/ansi-styles/package.json +50 -0
- package/dist/blessed-contrib/node_modules/ansi-styles/readme.md +86 -0
- package/dist/blessed-contrib/node_modules/chalk/index.js +118 -0
- package/dist/blessed-contrib/node_modules/chalk/license +21 -0
- package/dist/blessed-contrib/node_modules/chalk/package.json +70 -0
- package/dist/blessed-contrib/node_modules/chalk/readme.md +213 -0
- package/dist/blessed-contrib/node_modules/escape-string-regexp/index.js +13 -0
- package/dist/blessed-contrib/node_modules/escape-string-regexp/license +21 -0
- package/dist/blessed-contrib/node_modules/escape-string-regexp/package.json +41 -0
- package/dist/blessed-contrib/node_modules/escape-string-regexp/readme.md +27 -0
- package/dist/blessed-contrib/node_modules/strip-ansi/index.js +8 -0
- package/dist/blessed-contrib/node_modules/strip-ansi/license +21 -0
- package/dist/blessed-contrib/node_modules/strip-ansi/package.json +57 -0
- package/dist/blessed-contrib/node_modules/strip-ansi/readme.md +33 -0
- package/dist/blessed-contrib/node_modules/supports-color/index.js +52 -0
- package/dist/blessed-contrib/node_modules/supports-color/license +21 -0
- package/dist/blessed-contrib/node_modules/supports-color/package.json +49 -0
- package/dist/blessed-contrib/node_modules/supports-color/readme.md +36 -0
- package/dist/cli.js +9 -8
- package/dist/cli.js.map +1 -1
- package/dist/instrument-with-sentry.js +2 -2
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/shadow-npm-inject.js +2 -2
- package/dist/shadow-npm-inject.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,912 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* unicode.js - east asian width and surrogate pairs
|
|
3
|
+
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
|
|
4
|
+
* https://github.com/chjj/blessed
|
|
5
|
+
* Borrowed from vangie/east-asian-width, komagata/eastasianwidth,
|
|
6
|
+
* and mathiasbynens/String.prototype.codePointAt. Licenses below.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// east-asian-width
|
|
10
|
+
//
|
|
11
|
+
// Copyright (c) 2015 Vangie Du
|
|
12
|
+
// https://github.com/vangie/east-asian-width
|
|
13
|
+
//
|
|
14
|
+
// Permission is hereby granted, free of charge, to any person
|
|
15
|
+
// obtaining a copy of this software and associated documentation
|
|
16
|
+
// files (the "Software"), to deal in the Software without
|
|
17
|
+
// restriction, including without limitation the rights to use,
|
|
18
|
+
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
// copies of the Software, and to permit persons to whom the
|
|
20
|
+
// Software is furnished to do so, subject to the following
|
|
21
|
+
// conditions:
|
|
22
|
+
//
|
|
23
|
+
// The above copyright notice and this permission notice shall be
|
|
24
|
+
// included in all copies or substantial portions of the Software.
|
|
25
|
+
//
|
|
26
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
27
|
+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
28
|
+
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
29
|
+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
30
|
+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
31
|
+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
32
|
+
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
33
|
+
// OTHER DEALINGS IN THE SOFTWARE.
|
|
34
|
+
|
|
35
|
+
// eastasianwidth
|
|
36
|
+
//
|
|
37
|
+
// Copyright (c) 2013, Masaki Komagata
|
|
38
|
+
// https://github.com/komagata/eastasianwidth
|
|
39
|
+
//
|
|
40
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
41
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
42
|
+
// in the Software without restriction, including without limitation the rights
|
|
43
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
44
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
45
|
+
// furnished to do so, subject to the following conditions:
|
|
46
|
+
//
|
|
47
|
+
// The above copyright notice and this permission notice shall be included in
|
|
48
|
+
// all copies or substantial portions of the Software.
|
|
49
|
+
//
|
|
50
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
51
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
52
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
53
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
54
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
55
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
56
|
+
// THE SOFTWARE.
|
|
57
|
+
|
|
58
|
+
// String.prototype.codePointAt
|
|
59
|
+
//
|
|
60
|
+
// Copyright Mathias Bynens <https://mathiasbynens.be/>
|
|
61
|
+
// https://github.com/mathiasbynens/String.prototype.codePointAt
|
|
62
|
+
//
|
|
63
|
+
// Permission is hereby granted, free of charge, to any person obtaining
|
|
64
|
+
// a copy of this software and associated documentation files (the
|
|
65
|
+
// "Software"), to deal in the Software without restriction, including
|
|
66
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
67
|
+
// distribute, sublicense, and/or sell copies of the Software, and to
|
|
68
|
+
// permit persons to whom the Software is furnished to do so, subject to
|
|
69
|
+
// the following conditions:
|
|
70
|
+
//
|
|
71
|
+
// The above copyright notice and this permission notice shall be
|
|
72
|
+
// included in all copies or substantial portions of the Software.
|
|
73
|
+
//
|
|
74
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
75
|
+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
76
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
77
|
+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
78
|
+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
79
|
+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
80
|
+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
81
|
+
|
|
82
|
+
// String.fromCodePoint
|
|
83
|
+
//
|
|
84
|
+
// Copyright Mathias Bynens <https://mathiasbynens.be/>
|
|
85
|
+
// https://github.com/mathiasbynens/String.fromCodePoint
|
|
86
|
+
//
|
|
87
|
+
// Permission is hereby granted, free of charge, to any person obtaining
|
|
88
|
+
// a copy of this software and associated documentation files (the
|
|
89
|
+
// "Software"), to deal in the Software without restriction, including
|
|
90
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
91
|
+
// distribute, sublicense, and/or sell copies of the Software, and to
|
|
92
|
+
// permit persons to whom the Software is furnished to do so, subject to
|
|
93
|
+
// the following conditions:
|
|
94
|
+
//
|
|
95
|
+
// The above copyright notice and this permission notice shall be
|
|
96
|
+
// included in all copies or substantial portions of the Software.
|
|
97
|
+
//
|
|
98
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
99
|
+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
100
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
101
|
+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
102
|
+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
103
|
+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
104
|
+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
105
|
+
|
|
106
|
+
const stringFromCharCode = String.fromCharCode
|
|
107
|
+
const floor = Math.floor
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Wide, Surrogates, and Combining
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
exports.charWidth = function (str, i) {
|
|
114
|
+
const point = typeof str !== 'number' ? exports.codePointAt(str, i || 0) : str
|
|
115
|
+
|
|
116
|
+
// nul
|
|
117
|
+
if (point === 0) {
|
|
118
|
+
return 0
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// tab
|
|
122
|
+
if (point === 0x09) {
|
|
123
|
+
if (!exports.blessed) {
|
|
124
|
+
exports.blessed = require('../')
|
|
125
|
+
}
|
|
126
|
+
return exports.blessed.screen.global
|
|
127
|
+
? exports.blessed.screen.global.tabc.length
|
|
128
|
+
: 8
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// 8-bit control characters (2-width according to unicode??)
|
|
132
|
+
if (point < 32 || (point >= 0x7f && point < 0xa0)) {
|
|
133
|
+
return 0
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// search table of non-spacing characters
|
|
137
|
+
// is ucs combining or C0/C1 control character
|
|
138
|
+
if (exports.combining[point]) {
|
|
139
|
+
return 0
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// check for double-wide
|
|
143
|
+
// if (point >= 0x1100
|
|
144
|
+
// && (point <= 0x115f // Hangul Jamo init. consonants
|
|
145
|
+
// || point === 0x2329 || point === 0x232a
|
|
146
|
+
// || (point >= 0x2e80 && point <= 0xa4cf
|
|
147
|
+
// && point !== 0x303f) // CJK ... Yi
|
|
148
|
+
// || (point >= 0xac00 && point <= 0xd7a3) // Hangul Syllables
|
|
149
|
+
// || (point >= 0xf900 && point <= 0xfaff) // CJK Compatibility Ideographs
|
|
150
|
+
// || (point >= 0xfe10 && point <= 0xfe19) // Vertical forms
|
|
151
|
+
// || (point >= 0xfe30 && point <= 0xfe6f) // CJK Compatibility Forms
|
|
152
|
+
// || (point >= 0xff00 && point <= 0xff60) // Fullwidth Forms
|
|
153
|
+
// || (point >= 0xffe0 && point <= 0xffe6)
|
|
154
|
+
// || (point >= 0x20000 && point <= 0x2fffd)
|
|
155
|
+
// || (point >= 0x30000 && point <= 0x3fffd))) {
|
|
156
|
+
// return 2;
|
|
157
|
+
// }
|
|
158
|
+
|
|
159
|
+
// check for double-wide
|
|
160
|
+
if (
|
|
161
|
+
0x3000 === point ||
|
|
162
|
+
(0xff01 <= point && point <= 0xff60) ||
|
|
163
|
+
(0xffe0 <= point && point <= 0xffe6)
|
|
164
|
+
) {
|
|
165
|
+
return 2
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (
|
|
169
|
+
(0x1100 <= point && point <= 0x115f) ||
|
|
170
|
+
(0x11a3 <= point && point <= 0x11a7) ||
|
|
171
|
+
(0x11fa <= point && point <= 0x11ff) ||
|
|
172
|
+
(0x2329 <= point && point <= 0x232a) ||
|
|
173
|
+
(0x2e80 <= point && point <= 0x2e99) ||
|
|
174
|
+
(0x2e9b <= point && point <= 0x2ef3) ||
|
|
175
|
+
(0x2f00 <= point && point <= 0x2fd5) ||
|
|
176
|
+
(0x2ff0 <= point && point <= 0x2ffb) ||
|
|
177
|
+
(0x3001 <= point && point <= 0x303e) ||
|
|
178
|
+
(0x3041 <= point && point <= 0x3096) ||
|
|
179
|
+
(0x3099 <= point && point <= 0x30ff) ||
|
|
180
|
+
(0x3105 <= point && point <= 0x312d) ||
|
|
181
|
+
(0x3131 <= point && point <= 0x318e) ||
|
|
182
|
+
(0x3190 <= point && point <= 0x31ba) ||
|
|
183
|
+
(0x31c0 <= point && point <= 0x31e3) ||
|
|
184
|
+
(0x31f0 <= point && point <= 0x321e) ||
|
|
185
|
+
(0x3220 <= point && point <= 0x3247) ||
|
|
186
|
+
(0x3250 <= point && point <= 0x32fe) ||
|
|
187
|
+
(0x3300 <= point && point <= 0x4dbf) ||
|
|
188
|
+
(0x4e00 <= point && point <= 0xa48c) ||
|
|
189
|
+
(0xa490 <= point && point <= 0xa4c6) ||
|
|
190
|
+
(0xa960 <= point && point <= 0xa97c) ||
|
|
191
|
+
(0xac00 <= point && point <= 0xd7a3) ||
|
|
192
|
+
(0xd7b0 <= point && point <= 0xd7c6) ||
|
|
193
|
+
(0xd7cb <= point && point <= 0xd7fb) ||
|
|
194
|
+
(0xf900 <= point && point <= 0xfaff) ||
|
|
195
|
+
(0xfe10 <= point && point <= 0xfe19) ||
|
|
196
|
+
(0xfe30 <= point && point <= 0xfe52) ||
|
|
197
|
+
(0xfe54 <= point && point <= 0xfe66) ||
|
|
198
|
+
(0xfe68 <= point && point <= 0xfe6b) ||
|
|
199
|
+
(0x1b000 <= point && point <= 0x1b001) ||
|
|
200
|
+
(0x1f200 <= point && point <= 0x1f202) ||
|
|
201
|
+
(0x1f210 <= point && point <= 0x1f23a) ||
|
|
202
|
+
(0x1f240 <= point && point <= 0x1f248) ||
|
|
203
|
+
(0x1f250 <= point && point <= 0x1f251) ||
|
|
204
|
+
(0x20000 <= point && point <= 0x2f73f) ||
|
|
205
|
+
(0x2b740 <= point && point <= 0x2fffd) ||
|
|
206
|
+
(0x30000 <= point && point <= 0x3fffd)
|
|
207
|
+
) {
|
|
208
|
+
return 2
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// CJK Ambiguous
|
|
212
|
+
// http://www.unicode.org/reports/tr11/
|
|
213
|
+
// http://www.unicode.org/reports/tr11/#Ambiguous
|
|
214
|
+
if (process.env.NCURSES_CJK_WIDTH) {
|
|
215
|
+
if (
|
|
216
|
+
0x00a1 === point ||
|
|
217
|
+
0x00a4 === point ||
|
|
218
|
+
(0x00a7 <= point && point <= 0x00a8) ||
|
|
219
|
+
0x00aa === point ||
|
|
220
|
+
(0x00ad <= point && point <= 0x00ae) ||
|
|
221
|
+
(0x00b0 <= point && point <= 0x00b4) ||
|
|
222
|
+
(0x00b6 <= point && point <= 0x00ba) ||
|
|
223
|
+
(0x00bc <= point && point <= 0x00bf) ||
|
|
224
|
+
0x00c6 === point ||
|
|
225
|
+
0x00d0 === point ||
|
|
226
|
+
(0x00d7 <= point && point <= 0x00d8) ||
|
|
227
|
+
(0x00de <= point && point <= 0x00e1) ||
|
|
228
|
+
0x00e6 === point ||
|
|
229
|
+
(0x00e8 <= point && point <= 0x00ea) ||
|
|
230
|
+
(0x00ec <= point && point <= 0x00ed) ||
|
|
231
|
+
0x00f0 === point ||
|
|
232
|
+
(0x00f2 <= point && point <= 0x00f3) ||
|
|
233
|
+
(0x00f7 <= point && point <= 0x00fa) ||
|
|
234
|
+
0x00fc === point ||
|
|
235
|
+
0x00fe === point ||
|
|
236
|
+
0x0101 === point ||
|
|
237
|
+
0x0111 === point ||
|
|
238
|
+
0x0113 === point ||
|
|
239
|
+
0x011b === point ||
|
|
240
|
+
(0x0126 <= point && point <= 0x0127) ||
|
|
241
|
+
0x012b === point ||
|
|
242
|
+
(0x0131 <= point && point <= 0x0133) ||
|
|
243
|
+
0x0138 === point ||
|
|
244
|
+
(0x013f <= point && point <= 0x0142) ||
|
|
245
|
+
0x0144 === point ||
|
|
246
|
+
(0x0148 <= point && point <= 0x014b) ||
|
|
247
|
+
0x014d === point ||
|
|
248
|
+
(0x0152 <= point && point <= 0x0153) ||
|
|
249
|
+
(0x0166 <= point && point <= 0x0167) ||
|
|
250
|
+
0x016b === point ||
|
|
251
|
+
0x01ce === point ||
|
|
252
|
+
0x01d0 === point ||
|
|
253
|
+
0x01d2 === point ||
|
|
254
|
+
0x01d4 === point ||
|
|
255
|
+
0x01d6 === point ||
|
|
256
|
+
0x01d8 === point ||
|
|
257
|
+
0x01da === point ||
|
|
258
|
+
0x01dc === point ||
|
|
259
|
+
0x0251 === point ||
|
|
260
|
+
0x0261 === point ||
|
|
261
|
+
0x02c4 === point ||
|
|
262
|
+
0x02c7 === point ||
|
|
263
|
+
(0x02c9 <= point && point <= 0x02cb) ||
|
|
264
|
+
0x02cd === point ||
|
|
265
|
+
0x02d0 === point ||
|
|
266
|
+
(0x02d8 <= point && point <= 0x02db) ||
|
|
267
|
+
0x02dd === point ||
|
|
268
|
+
0x02df === point ||
|
|
269
|
+
(0x0300 <= point && point <= 0x036f) ||
|
|
270
|
+
(0x0391 <= point && point <= 0x03a1) ||
|
|
271
|
+
(0x03a3 <= point && point <= 0x03a9) ||
|
|
272
|
+
(0x03b1 <= point && point <= 0x03c1) ||
|
|
273
|
+
(0x03c3 <= point && point <= 0x03c9) ||
|
|
274
|
+
0x0401 === point ||
|
|
275
|
+
(0x0410 <= point && point <= 0x044f) ||
|
|
276
|
+
0x0451 === point ||
|
|
277
|
+
0x2010 === point ||
|
|
278
|
+
(0x2013 <= point && point <= 0x2016) ||
|
|
279
|
+
(0x2018 <= point && point <= 0x2019) ||
|
|
280
|
+
(0x201c <= point && point <= 0x201d) ||
|
|
281
|
+
(0x2020 <= point && point <= 0x2022) ||
|
|
282
|
+
(0x2024 <= point && point <= 0x2027) ||
|
|
283
|
+
0x2030 === point ||
|
|
284
|
+
(0x2032 <= point && point <= 0x2033) ||
|
|
285
|
+
0x2035 === point ||
|
|
286
|
+
0x203b === point ||
|
|
287
|
+
0x203e === point ||
|
|
288
|
+
0x2074 === point ||
|
|
289
|
+
0x207f === point ||
|
|
290
|
+
(0x2081 <= point && point <= 0x2084) ||
|
|
291
|
+
0x20ac === point ||
|
|
292
|
+
0x2103 === point ||
|
|
293
|
+
0x2105 === point ||
|
|
294
|
+
0x2109 === point ||
|
|
295
|
+
0x2113 === point ||
|
|
296
|
+
0x2116 === point ||
|
|
297
|
+
(0x2121 <= point && point <= 0x2122) ||
|
|
298
|
+
0x2126 === point ||
|
|
299
|
+
0x212b === point ||
|
|
300
|
+
(0x2153 <= point && point <= 0x2154) ||
|
|
301
|
+
(0x215b <= point && point <= 0x215e) ||
|
|
302
|
+
(0x2160 <= point && point <= 0x216b) ||
|
|
303
|
+
(0x2170 <= point && point <= 0x2179) ||
|
|
304
|
+
0x2189 === point ||
|
|
305
|
+
(0x2190 <= point && point <= 0x2199) ||
|
|
306
|
+
(0x21b8 <= point && point <= 0x21b9) ||
|
|
307
|
+
0x21d2 === point ||
|
|
308
|
+
0x21d4 === point ||
|
|
309
|
+
0x21e7 === point ||
|
|
310
|
+
0x2200 === point ||
|
|
311
|
+
(0x2202 <= point && point <= 0x2203) ||
|
|
312
|
+
(0x2207 <= point && point <= 0x2208) ||
|
|
313
|
+
0x220b === point ||
|
|
314
|
+
0x220f === point ||
|
|
315
|
+
0x2211 === point ||
|
|
316
|
+
0x2215 === point ||
|
|
317
|
+
0x221a === point ||
|
|
318
|
+
(0x221d <= point && point <= 0x2220) ||
|
|
319
|
+
0x2223 === point ||
|
|
320
|
+
0x2225 === point ||
|
|
321
|
+
(0x2227 <= point && point <= 0x222c) ||
|
|
322
|
+
0x222e === point ||
|
|
323
|
+
(0x2234 <= point && point <= 0x2237) ||
|
|
324
|
+
(0x223c <= point && point <= 0x223d) ||
|
|
325
|
+
0x2248 === point ||
|
|
326
|
+
0x224c === point ||
|
|
327
|
+
0x2252 === point ||
|
|
328
|
+
(0x2260 <= point && point <= 0x2261) ||
|
|
329
|
+
(0x2264 <= point && point <= 0x2267) ||
|
|
330
|
+
(0x226a <= point && point <= 0x226b) ||
|
|
331
|
+
(0x226e <= point && point <= 0x226f) ||
|
|
332
|
+
(0x2282 <= point && point <= 0x2283) ||
|
|
333
|
+
(0x2286 <= point && point <= 0x2287) ||
|
|
334
|
+
0x2295 === point ||
|
|
335
|
+
0x2299 === point ||
|
|
336
|
+
0x22a5 === point ||
|
|
337
|
+
0x22bf === point ||
|
|
338
|
+
0x2312 === point ||
|
|
339
|
+
(0x2460 <= point && point <= 0x24e9) ||
|
|
340
|
+
(0x24eb <= point && point <= 0x254b) ||
|
|
341
|
+
(0x2550 <= point && point <= 0x2573) ||
|
|
342
|
+
(0x2580 <= point && point <= 0x258f) ||
|
|
343
|
+
(0x2592 <= point && point <= 0x2595) ||
|
|
344
|
+
(0x25a0 <= point && point <= 0x25a1) ||
|
|
345
|
+
(0x25a3 <= point && point <= 0x25a9) ||
|
|
346
|
+
(0x25b2 <= point && point <= 0x25b3) ||
|
|
347
|
+
(0x25b6 <= point && point <= 0x25b7) ||
|
|
348
|
+
(0x25bc <= point && point <= 0x25bd) ||
|
|
349
|
+
(0x25c0 <= point && point <= 0x25c1) ||
|
|
350
|
+
(0x25c6 <= point && point <= 0x25c8) ||
|
|
351
|
+
0x25cb === point ||
|
|
352
|
+
(0x25ce <= point && point <= 0x25d1) ||
|
|
353
|
+
(0x25e2 <= point && point <= 0x25e5) ||
|
|
354
|
+
0x25ef === point ||
|
|
355
|
+
(0x2605 <= point && point <= 0x2606) ||
|
|
356
|
+
0x2609 === point ||
|
|
357
|
+
(0x260e <= point && point <= 0x260f) ||
|
|
358
|
+
(0x2614 <= point && point <= 0x2615) ||
|
|
359
|
+
0x261c === point ||
|
|
360
|
+
0x261e === point ||
|
|
361
|
+
0x2640 === point ||
|
|
362
|
+
0x2642 === point ||
|
|
363
|
+
(0x2660 <= point && point <= 0x2661) ||
|
|
364
|
+
(0x2663 <= point && point <= 0x2665) ||
|
|
365
|
+
(0x2667 <= point && point <= 0x266a) ||
|
|
366
|
+
(0x266c <= point && point <= 0x266d) ||
|
|
367
|
+
0x266f === point ||
|
|
368
|
+
(0x269e <= point && point <= 0x269f) ||
|
|
369
|
+
(0x26be <= point && point <= 0x26bf) ||
|
|
370
|
+
(0x26c4 <= point && point <= 0x26cd) ||
|
|
371
|
+
(0x26cf <= point && point <= 0x26e1) ||
|
|
372
|
+
0x26e3 === point ||
|
|
373
|
+
(0x26e8 <= point && point <= 0x26ff) ||
|
|
374
|
+
0x273d === point ||
|
|
375
|
+
0x2757 === point ||
|
|
376
|
+
(0x2776 <= point && point <= 0x277f) ||
|
|
377
|
+
(0x2b55 <= point && point <= 0x2b59) ||
|
|
378
|
+
(0x3248 <= point && point <= 0x324f) ||
|
|
379
|
+
(0xe000 <= point && point <= 0xf8ff) ||
|
|
380
|
+
(0xfe00 <= point && point <= 0xfe0f) ||
|
|
381
|
+
0xfffd === point ||
|
|
382
|
+
(0x1f100 <= point && point <= 0x1f10a) ||
|
|
383
|
+
(0x1f110 <= point && point <= 0x1f12d) ||
|
|
384
|
+
(0x1f130 <= point && point <= 0x1f169) ||
|
|
385
|
+
(0x1f170 <= point && point <= 0x1f19a) ||
|
|
386
|
+
(0xe0100 <= point && point <= 0xe01ef) ||
|
|
387
|
+
(0xf0000 <= point && point <= 0xffffd) ||
|
|
388
|
+
(0x100000 <= point && point <= 0x10fffd)
|
|
389
|
+
) {
|
|
390
|
+
return +process.env.NCURSES_CJK_WIDTH || 1
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
return 1
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
exports.strWidth = function (str) {
|
|
398
|
+
let width = 0
|
|
399
|
+
for (let i = 0; i < str.length; i++) {
|
|
400
|
+
width += exports.charWidth(str, i)
|
|
401
|
+
if (exports.isSurrogate(str, i)) {
|
|
402
|
+
i++
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return width
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
exports.isSurrogate = function (str, i) {
|
|
409
|
+
const point = typeof str !== 'number' ? exports.codePointAt(str, i || 0) : str
|
|
410
|
+
return point > 0x00ffff
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
exports.combiningTable = [
|
|
414
|
+
[0x0300, 0x036f],
|
|
415
|
+
[0x0483, 0x0486],
|
|
416
|
+
[0x0488, 0x0489],
|
|
417
|
+
[0x0591, 0x05bd],
|
|
418
|
+
[0x05bf, 0x05bf],
|
|
419
|
+
[0x05c1, 0x05c2],
|
|
420
|
+
[0x05c4, 0x05c5],
|
|
421
|
+
[0x05c7, 0x05c7],
|
|
422
|
+
[0x0600, 0x0603],
|
|
423
|
+
[0x0610, 0x0615],
|
|
424
|
+
[0x064b, 0x065e],
|
|
425
|
+
[0x0670, 0x0670],
|
|
426
|
+
[0x06d6, 0x06e4],
|
|
427
|
+
[0x06e7, 0x06e8],
|
|
428
|
+
[0x06ea, 0x06ed],
|
|
429
|
+
[0x070f, 0x070f],
|
|
430
|
+
[0x0711, 0x0711],
|
|
431
|
+
[0x0730, 0x074a],
|
|
432
|
+
[0x07a6, 0x07b0],
|
|
433
|
+
[0x07eb, 0x07f3],
|
|
434
|
+
[0x0901, 0x0902],
|
|
435
|
+
[0x093c, 0x093c],
|
|
436
|
+
[0x0941, 0x0948],
|
|
437
|
+
[0x094d, 0x094d],
|
|
438
|
+
[0x0951, 0x0954],
|
|
439
|
+
[0x0962, 0x0963],
|
|
440
|
+
[0x0981, 0x0981],
|
|
441
|
+
[0x09bc, 0x09bc],
|
|
442
|
+
[0x09c1, 0x09c4],
|
|
443
|
+
[0x09cd, 0x09cd],
|
|
444
|
+
[0x09e2, 0x09e3],
|
|
445
|
+
[0x0a01, 0x0a02],
|
|
446
|
+
[0x0a3c, 0x0a3c],
|
|
447
|
+
[0x0a41, 0x0a42],
|
|
448
|
+
[0x0a47, 0x0a48],
|
|
449
|
+
[0x0a4b, 0x0a4d],
|
|
450
|
+
[0x0a70, 0x0a71],
|
|
451
|
+
[0x0a81, 0x0a82],
|
|
452
|
+
[0x0abc, 0x0abc],
|
|
453
|
+
[0x0ac1, 0x0ac5],
|
|
454
|
+
[0x0ac7, 0x0ac8],
|
|
455
|
+
[0x0acd, 0x0acd],
|
|
456
|
+
[0x0ae2, 0x0ae3],
|
|
457
|
+
[0x0b01, 0x0b01],
|
|
458
|
+
[0x0b3c, 0x0b3c],
|
|
459
|
+
[0x0b3f, 0x0b3f],
|
|
460
|
+
[0x0b41, 0x0b43],
|
|
461
|
+
[0x0b4d, 0x0b4d],
|
|
462
|
+
[0x0b56, 0x0b56],
|
|
463
|
+
[0x0b82, 0x0b82],
|
|
464
|
+
[0x0bc0, 0x0bc0],
|
|
465
|
+
[0x0bcd, 0x0bcd],
|
|
466
|
+
[0x0c3e, 0x0c40],
|
|
467
|
+
[0x0c46, 0x0c48],
|
|
468
|
+
[0x0c4a, 0x0c4d],
|
|
469
|
+
[0x0c55, 0x0c56],
|
|
470
|
+
[0x0cbc, 0x0cbc],
|
|
471
|
+
[0x0cbf, 0x0cbf],
|
|
472
|
+
[0x0cc6, 0x0cc6],
|
|
473
|
+
[0x0ccc, 0x0ccd],
|
|
474
|
+
[0x0ce2, 0x0ce3],
|
|
475
|
+
[0x0d41, 0x0d43],
|
|
476
|
+
[0x0d4d, 0x0d4d],
|
|
477
|
+
[0x0dca, 0x0dca],
|
|
478
|
+
[0x0dd2, 0x0dd4],
|
|
479
|
+
[0x0dd6, 0x0dd6],
|
|
480
|
+
[0x0e31, 0x0e31],
|
|
481
|
+
[0x0e34, 0x0e3a],
|
|
482
|
+
[0x0e47, 0x0e4e],
|
|
483
|
+
[0x0eb1, 0x0eb1],
|
|
484
|
+
[0x0eb4, 0x0eb9],
|
|
485
|
+
[0x0ebb, 0x0ebc],
|
|
486
|
+
[0x0ec8, 0x0ecd],
|
|
487
|
+
[0x0f18, 0x0f19],
|
|
488
|
+
[0x0f35, 0x0f35],
|
|
489
|
+
[0x0f37, 0x0f37],
|
|
490
|
+
[0x0f39, 0x0f39],
|
|
491
|
+
[0x0f71, 0x0f7e],
|
|
492
|
+
[0x0f80, 0x0f84],
|
|
493
|
+
[0x0f86, 0x0f87],
|
|
494
|
+
[0x0f90, 0x0f97],
|
|
495
|
+
[0x0f99, 0x0fbc],
|
|
496
|
+
[0x0fc6, 0x0fc6],
|
|
497
|
+
[0x102d, 0x1030],
|
|
498
|
+
[0x1032, 0x1032],
|
|
499
|
+
[0x1036, 0x1037],
|
|
500
|
+
[0x1039, 0x1039],
|
|
501
|
+
[0x1058, 0x1059],
|
|
502
|
+
[0x1160, 0x11ff],
|
|
503
|
+
[0x135f, 0x135f],
|
|
504
|
+
[0x1712, 0x1714],
|
|
505
|
+
[0x1732, 0x1734],
|
|
506
|
+
[0x1752, 0x1753],
|
|
507
|
+
[0x1772, 0x1773],
|
|
508
|
+
[0x17b4, 0x17b5],
|
|
509
|
+
[0x17b7, 0x17bd],
|
|
510
|
+
[0x17c6, 0x17c6],
|
|
511
|
+
[0x17c9, 0x17d3],
|
|
512
|
+
[0x17dd, 0x17dd],
|
|
513
|
+
[0x180b, 0x180d],
|
|
514
|
+
[0x18a9, 0x18a9],
|
|
515
|
+
[0x1920, 0x1922],
|
|
516
|
+
[0x1927, 0x1928],
|
|
517
|
+
[0x1932, 0x1932],
|
|
518
|
+
[0x1939, 0x193b],
|
|
519
|
+
[0x1a17, 0x1a18],
|
|
520
|
+
[0x1b00, 0x1b03],
|
|
521
|
+
[0x1b34, 0x1b34],
|
|
522
|
+
[0x1b36, 0x1b3a],
|
|
523
|
+
[0x1b3c, 0x1b3c],
|
|
524
|
+
[0x1b42, 0x1b42],
|
|
525
|
+
[0x1b6b, 0x1b73],
|
|
526
|
+
[0x1dc0, 0x1dca],
|
|
527
|
+
[0x1dfe, 0x1dff],
|
|
528
|
+
[0x200b, 0x200f],
|
|
529
|
+
[0x202a, 0x202e],
|
|
530
|
+
[0x2060, 0x2063],
|
|
531
|
+
[0x206a, 0x206f],
|
|
532
|
+
[0x20d0, 0x20ef],
|
|
533
|
+
[0x302a, 0x302f],
|
|
534
|
+
[0x3099, 0x309a],
|
|
535
|
+
[0xa806, 0xa806],
|
|
536
|
+
[0xa80b, 0xa80b],
|
|
537
|
+
[0xa825, 0xa826],
|
|
538
|
+
[0xfb1e, 0xfb1e],
|
|
539
|
+
[0xfe00, 0xfe0f],
|
|
540
|
+
[0xfe20, 0xfe23],
|
|
541
|
+
[0xfeff, 0xfeff],
|
|
542
|
+
[0xfff9, 0xfffb],
|
|
543
|
+
[0x10a01, 0x10a03],
|
|
544
|
+
[0x10a05, 0x10a06],
|
|
545
|
+
[0x10a0c, 0x10a0f],
|
|
546
|
+
[0x10a38, 0x10a3a],
|
|
547
|
+
[0x10a3f, 0x10a3f],
|
|
548
|
+
[0x1d167, 0x1d169],
|
|
549
|
+
[0x1d173, 0x1d182],
|
|
550
|
+
[0x1d185, 0x1d18b],
|
|
551
|
+
[0x1d1aa, 0x1d1ad],
|
|
552
|
+
[0x1d242, 0x1d244],
|
|
553
|
+
[0xe0001, 0xe0001],
|
|
554
|
+
[0xe0020, 0xe007f],
|
|
555
|
+
[0xe0100, 0xe01ef]
|
|
556
|
+
]
|
|
557
|
+
|
|
558
|
+
exports.combining = exports.combiningTable.reduce(function (out, row) {
|
|
559
|
+
for (let i = row[0]; i <= row[1]; i++) {
|
|
560
|
+
out[i] = true
|
|
561
|
+
}
|
|
562
|
+
return out
|
|
563
|
+
}, {})
|
|
564
|
+
|
|
565
|
+
exports.isCombining = function (str, i) {
|
|
566
|
+
const point = typeof str !== 'number' ? exports.codePointAt(str, i || 0) : str
|
|
567
|
+
return exports.combining[point] === true
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Code Point Helpers
|
|
572
|
+
*/
|
|
573
|
+
|
|
574
|
+
exports.codePointAt = function (str, position) {
|
|
575
|
+
if (str == null) {
|
|
576
|
+
throw TypeError()
|
|
577
|
+
}
|
|
578
|
+
const string = String(str)
|
|
579
|
+
if (string.codePointAt) {
|
|
580
|
+
return string.codePointAt(position)
|
|
581
|
+
}
|
|
582
|
+
const size = string.length
|
|
583
|
+
// `ToInteger`
|
|
584
|
+
let index = position ? Number(position) : 0
|
|
585
|
+
if (index !== index) {
|
|
586
|
+
// better `isNaN`
|
|
587
|
+
index = 0
|
|
588
|
+
}
|
|
589
|
+
// Account for out-of-bounds indices:
|
|
590
|
+
if (index < 0 || index >= size) {
|
|
591
|
+
return undefined
|
|
592
|
+
}
|
|
593
|
+
// Get the first code unit
|
|
594
|
+
const first = string.charCodeAt(index)
|
|
595
|
+
let second
|
|
596
|
+
if (
|
|
597
|
+
// check if it’s the start of a surrogate pair
|
|
598
|
+
first >= 0xd800 &&
|
|
599
|
+
first <= 0xdbff && // high surrogate
|
|
600
|
+
size > index + 1 // there is a next code unit
|
|
601
|
+
) {
|
|
602
|
+
second = string.charCodeAt(index + 1)
|
|
603
|
+
if (second >= 0xdc00 && second <= 0xdfff) {
|
|
604
|
+
// low surrogate
|
|
605
|
+
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
|
606
|
+
return (first - 0xd800) * 0x400 + second - 0xdc00 + 0x10000
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
return first
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// exports.codePointAt = function(str, position) {
|
|
613
|
+
// position = +position || 0;
|
|
614
|
+
// var x = str.charCodeAt(position);
|
|
615
|
+
// var y = str.length > 1 ? str.charCodeAt(position + 1) : 0;
|
|
616
|
+
// var point = x;
|
|
617
|
+
// if ((0xD800 <= x && x <= 0xDBFF) && (0xDC00 <= y && y <= 0xDFFF)) {
|
|
618
|
+
// x &= 0x3FF;
|
|
619
|
+
// y &= 0x3FF;
|
|
620
|
+
// point = (x << 10) | y;
|
|
621
|
+
// point += 0x10000;
|
|
622
|
+
// }
|
|
623
|
+
// return point;
|
|
624
|
+
// };
|
|
625
|
+
|
|
626
|
+
exports.fromCodePoint = function () {
|
|
627
|
+
if (String.fromCodePoint) {
|
|
628
|
+
return String.fromCodePoint.apply(String, arguments)
|
|
629
|
+
}
|
|
630
|
+
const MAX_SIZE = 0x4000
|
|
631
|
+
const codeUnits = []
|
|
632
|
+
let highSurrogate
|
|
633
|
+
let lowSurrogate
|
|
634
|
+
let index = -1
|
|
635
|
+
const length = arguments.length
|
|
636
|
+
if (!length) {
|
|
637
|
+
return ''
|
|
638
|
+
}
|
|
639
|
+
let result = ''
|
|
640
|
+
while (++index < length) {
|
|
641
|
+
let codePoint = Number(arguments[index])
|
|
642
|
+
if (
|
|
643
|
+
!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
|
|
644
|
+
codePoint < 0 || // not a valid Unicode code point
|
|
645
|
+
codePoint > 0x10ffff || // not a valid Unicode code point
|
|
646
|
+
floor(codePoint) !== codePoint // not an integer
|
|
647
|
+
) {
|
|
648
|
+
throw RangeError('Invalid code point: ' + codePoint)
|
|
649
|
+
}
|
|
650
|
+
if (codePoint <= 0xffff) {
|
|
651
|
+
// BMP code point
|
|
652
|
+
codeUnits.push(codePoint)
|
|
653
|
+
} else {
|
|
654
|
+
// Astral code point; split in surrogate halves
|
|
655
|
+
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
|
656
|
+
codePoint -= 0x10000
|
|
657
|
+
highSurrogate = (codePoint >> 10) + 0xd800
|
|
658
|
+
lowSurrogate = (codePoint % 0x400) + 0xdc00
|
|
659
|
+
codeUnits.push(highSurrogate, lowSurrogate)
|
|
660
|
+
}
|
|
661
|
+
if (index + 1 === length || codeUnits.length > MAX_SIZE) {
|
|
662
|
+
result += stringFromCharCode.apply(null, codeUnits)
|
|
663
|
+
codeUnits.length = 0
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return result
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Regexes
|
|
671
|
+
*/
|
|
672
|
+
|
|
673
|
+
exports.chars = {}
|
|
674
|
+
|
|
675
|
+
// Double width characters that are _not_ surrogate pairs.
|
|
676
|
+
// NOTE: 0x20000 - 0x2fffd and 0x30000 - 0x3fffd are not necessary for this
|
|
677
|
+
// regex anyway. This regex is used to put a blank char after wide chars to
|
|
678
|
+
// be eaten, however, if this is a surrogate pair, parseContent already adds
|
|
679
|
+
// the extra one char because its length equals 2 instead of 1.
|
|
680
|
+
exports.chars.wide = new RegExp(
|
|
681
|
+
'([' +
|
|
682
|
+
'\\u1100-\\u115f' + // Hangul Jamo init. consonants
|
|
683
|
+
'\\u2329\\u232a' +
|
|
684
|
+
'\\u2e80-\\u303e\\u3040-\\ua4cf' + // CJK ... Yi
|
|
685
|
+
'\\uac00-\\ud7a3' + // Hangul Syllables
|
|
686
|
+
'\\uf900-\\ufaff' + // CJK Compatibility Ideographs
|
|
687
|
+
'\\ufe10-\\ufe19' + // Vertical forms
|
|
688
|
+
'\\ufe30-\\ufe6f' + // CJK Compatibility Forms
|
|
689
|
+
'\\uff00-\\uff60' + // Fullwidth Forms
|
|
690
|
+
'\\uffe0-\\uffe6' +
|
|
691
|
+
'])',
|
|
692
|
+
'g'
|
|
693
|
+
)
|
|
694
|
+
|
|
695
|
+
// All surrogate pair wide chars.
|
|
696
|
+
exports.chars.swide = new RegExp(
|
|
697
|
+
'(' +
|
|
698
|
+
// 0x20000 - 0x2fffd:
|
|
699
|
+
'[\\ud840-\\ud87f][\\udc00-\\udffd]' +
|
|
700
|
+
'|' +
|
|
701
|
+
// 0x30000 - 0x3fffd:
|
|
702
|
+
'[\\ud880-\\ud8bf][\\udc00-\\udffd]' +
|
|
703
|
+
')',
|
|
704
|
+
'g'
|
|
705
|
+
)
|
|
706
|
+
|
|
707
|
+
// All wide chars including surrogate pairs.
|
|
708
|
+
exports.chars.all = new RegExp(
|
|
709
|
+
'(' +
|
|
710
|
+
exports.chars.swide.source.slice(1, -1) +
|
|
711
|
+
'|' +
|
|
712
|
+
exports.chars.wide.source.slice(1, -1) +
|
|
713
|
+
')',
|
|
714
|
+
'g'
|
|
715
|
+
)
|
|
716
|
+
|
|
717
|
+
// Regex to detect a surrogate pair.
|
|
718
|
+
exports.chars.surrogate = /[\ud800-\udbff][\udc00-\udfff]/g
|
|
719
|
+
|
|
720
|
+
// Regex to find combining characters.
|
|
721
|
+
exports.chars.combining = exports.combiningTable.reduce(function (out, row) {
|
|
722
|
+
let low, high, range
|
|
723
|
+
if (row[0] > 0x00ffff) {
|
|
724
|
+
low = exports.fromCodePoint(row[0])
|
|
725
|
+
low = [hexify(low.charCodeAt(0)), hexify(low.charCodeAt(1))]
|
|
726
|
+
high = exports.fromCodePoint(row[1])
|
|
727
|
+
high = [hexify(high.charCodeAt(0)), hexify(high.charCodeAt(1))]
|
|
728
|
+
range =
|
|
729
|
+
'[\\u' +
|
|
730
|
+
low[0] +
|
|
731
|
+
'-' +
|
|
732
|
+
'\\u' +
|
|
733
|
+
high[0] +
|
|
734
|
+
']' +
|
|
735
|
+
'[\\u' +
|
|
736
|
+
low[1] +
|
|
737
|
+
'-' +
|
|
738
|
+
'\\u' +
|
|
739
|
+
high[1] +
|
|
740
|
+
']'
|
|
741
|
+
if (!~out.indexOf('|')) {
|
|
742
|
+
out += ']'
|
|
743
|
+
}
|
|
744
|
+
out += '|' + range
|
|
745
|
+
} else {
|
|
746
|
+
low = hexify(row[0])
|
|
747
|
+
high = hexify(row[1])
|
|
748
|
+
low = '\\u' + low
|
|
749
|
+
high = '\\u' + high
|
|
750
|
+
out += low + '-' + high
|
|
751
|
+
}
|
|
752
|
+
return out
|
|
753
|
+
}, '[')
|
|
754
|
+
|
|
755
|
+
exports.chars.combining = new RegExp(exports.chars.combining, 'g')
|
|
756
|
+
|
|
757
|
+
function hexify(n) {
|
|
758
|
+
n = n.toString(16)
|
|
759
|
+
while (n.length < 4) {
|
|
760
|
+
n = '0' + n
|
|
761
|
+
}
|
|
762
|
+
return n
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/*
|
|
766
|
+
exports.chars.combining = new RegExp(
|
|
767
|
+
'['
|
|
768
|
+
+ '\\u0300-\\u036f'
|
|
769
|
+
+ '\\u0483-\\u0486'
|
|
770
|
+
+ '\\u0488-\\u0489'
|
|
771
|
+
+ '\\u0591-\\u05bd'
|
|
772
|
+
+ '\\u05bf-\\u05bf'
|
|
773
|
+
+ '\\u05c1-\\u05c2'
|
|
774
|
+
+ '\\u05c4-\\u05c5'
|
|
775
|
+
+ '\\u05c7-\\u05c7'
|
|
776
|
+
+ '\\u0600-\\u0603'
|
|
777
|
+
+ '\\u0610-\\u0615'
|
|
778
|
+
+ '\\u064b-\\u065e'
|
|
779
|
+
+ '\\u0670-\\u0670'
|
|
780
|
+
+ '\\u06d6-\\u06e4'
|
|
781
|
+
+ '\\u06e7-\\u06e8'
|
|
782
|
+
+ '\\u06ea-\\u06ed'
|
|
783
|
+
+ '\\u070f-\\u070f'
|
|
784
|
+
+ '\\u0711-\\u0711'
|
|
785
|
+
+ '\\u0730-\\u074a'
|
|
786
|
+
+ '\\u07a6-\\u07b0'
|
|
787
|
+
+ '\\u07eb-\\u07f3'
|
|
788
|
+
+ '\\u0901-\\u0902'
|
|
789
|
+
+ '\\u093c-\\u093c'
|
|
790
|
+
+ '\\u0941-\\u0948'
|
|
791
|
+
+ '\\u094d-\\u094d'
|
|
792
|
+
+ '\\u0951-\\u0954'
|
|
793
|
+
+ '\\u0962-\\u0963'
|
|
794
|
+
+ '\\u0981-\\u0981'
|
|
795
|
+
+ '\\u09bc-\\u09bc'
|
|
796
|
+
+ '\\u09c1-\\u09c4'
|
|
797
|
+
+ '\\u09cd-\\u09cd'
|
|
798
|
+
+ '\\u09e2-\\u09e3'
|
|
799
|
+
+ '\\u0a01-\\u0a02'
|
|
800
|
+
+ '\\u0a3c-\\u0a3c'
|
|
801
|
+
+ '\\u0a41-\\u0a42'
|
|
802
|
+
+ '\\u0a47-\\u0a48'
|
|
803
|
+
+ '\\u0a4b-\\u0a4d'
|
|
804
|
+
+ '\\u0a70-\\u0a71'
|
|
805
|
+
+ '\\u0a81-\\u0a82'
|
|
806
|
+
+ '\\u0abc-\\u0abc'
|
|
807
|
+
+ '\\u0ac1-\\u0ac5'
|
|
808
|
+
+ '\\u0ac7-\\u0ac8'
|
|
809
|
+
+ '\\u0acd-\\u0acd'
|
|
810
|
+
+ '\\u0ae2-\\u0ae3'
|
|
811
|
+
+ '\\u0b01-\\u0b01'
|
|
812
|
+
+ '\\u0b3c-\\u0b3c'
|
|
813
|
+
+ '\\u0b3f-\\u0b3f'
|
|
814
|
+
+ '\\u0b41-\\u0b43'
|
|
815
|
+
+ '\\u0b4d-\\u0b4d'
|
|
816
|
+
+ '\\u0b56-\\u0b56'
|
|
817
|
+
+ '\\u0b82-\\u0b82'
|
|
818
|
+
+ '\\u0bc0-\\u0bc0'
|
|
819
|
+
+ '\\u0bcd-\\u0bcd'
|
|
820
|
+
+ '\\u0c3e-\\u0c40'
|
|
821
|
+
+ '\\u0c46-\\u0c48'
|
|
822
|
+
+ '\\u0c4a-\\u0c4d'
|
|
823
|
+
+ '\\u0c55-\\u0c56'
|
|
824
|
+
+ '\\u0cbc-\\u0cbc'
|
|
825
|
+
+ '\\u0cbf-\\u0cbf'
|
|
826
|
+
+ '\\u0cc6-\\u0cc6'
|
|
827
|
+
+ '\\u0ccc-\\u0ccd'
|
|
828
|
+
+ '\\u0ce2-\\u0ce3'
|
|
829
|
+
+ '\\u0d41-\\u0d43'
|
|
830
|
+
+ '\\u0d4d-\\u0d4d'
|
|
831
|
+
+ '\\u0dca-\\u0dca'
|
|
832
|
+
+ '\\u0dd2-\\u0dd4'
|
|
833
|
+
+ '\\u0dd6-\\u0dd6'
|
|
834
|
+
+ '\\u0e31-\\u0e31'
|
|
835
|
+
+ '\\u0e34-\\u0e3a'
|
|
836
|
+
+ '\\u0e47-\\u0e4e'
|
|
837
|
+
+ '\\u0eb1-\\u0eb1'
|
|
838
|
+
+ '\\u0eb4-\\u0eb9'
|
|
839
|
+
+ '\\u0ebb-\\u0ebc'
|
|
840
|
+
+ '\\u0ec8-\\u0ecd'
|
|
841
|
+
+ '\\u0f18-\\u0f19'
|
|
842
|
+
+ '\\u0f35-\\u0f35'
|
|
843
|
+
+ '\\u0f37-\\u0f37'
|
|
844
|
+
+ '\\u0f39-\\u0f39'
|
|
845
|
+
+ '\\u0f71-\\u0f7e'
|
|
846
|
+
+ '\\u0f80-\\u0f84'
|
|
847
|
+
+ '\\u0f86-\\u0f87'
|
|
848
|
+
+ '\\u0f90-\\u0f97'
|
|
849
|
+
+ '\\u0f99-\\u0fbc'
|
|
850
|
+
+ '\\u0fc6-\\u0fc6'
|
|
851
|
+
+ '\\u102d-\\u1030'
|
|
852
|
+
+ '\\u1032-\\u1032'
|
|
853
|
+
+ '\\u1036-\\u1037'
|
|
854
|
+
+ '\\u1039-\\u1039'
|
|
855
|
+
+ '\\u1058-\\u1059'
|
|
856
|
+
+ '\\u1160-\\u11ff'
|
|
857
|
+
+ '\\u135f-\\u135f'
|
|
858
|
+
+ '\\u1712-\\u1714'
|
|
859
|
+
+ '\\u1732-\\u1734'
|
|
860
|
+
+ '\\u1752-\\u1753'
|
|
861
|
+
+ '\\u1772-\\u1773'
|
|
862
|
+
+ '\\u17b4-\\u17b5'
|
|
863
|
+
+ '\\u17b7-\\u17bd'
|
|
864
|
+
+ '\\u17c6-\\u17c6'
|
|
865
|
+
+ '\\u17c9-\\u17d3'
|
|
866
|
+
+ '\\u17dd-\\u17dd'
|
|
867
|
+
+ '\\u180b-\\u180d'
|
|
868
|
+
+ '\\u18a9-\\u18a9'
|
|
869
|
+
+ '\\u1920-\\u1922'
|
|
870
|
+
+ '\\u1927-\\u1928'
|
|
871
|
+
+ '\\u1932-\\u1932'
|
|
872
|
+
+ '\\u1939-\\u193b'
|
|
873
|
+
+ '\\u1a17-\\u1a18'
|
|
874
|
+
+ '\\u1b00-\\u1b03'
|
|
875
|
+
+ '\\u1b34-\\u1b34'
|
|
876
|
+
+ '\\u1b36-\\u1b3a'
|
|
877
|
+
+ '\\u1b3c-\\u1b3c'
|
|
878
|
+
+ '\\u1b42-\\u1b42'
|
|
879
|
+
+ '\\u1b6b-\\u1b73'
|
|
880
|
+
+ '\\u1dc0-\\u1dca'
|
|
881
|
+
+ '\\u1dfe-\\u1dff'
|
|
882
|
+
+ '\\u200b-\\u200f'
|
|
883
|
+
+ '\\u202a-\\u202e'
|
|
884
|
+
+ '\\u2060-\\u2063'
|
|
885
|
+
+ '\\u206a-\\u206f'
|
|
886
|
+
+ '\\u20d0-\\u20ef'
|
|
887
|
+
+ '\\u302a-\\u302f'
|
|
888
|
+
+ '\\u3099-\\u309a'
|
|
889
|
+
+ '\\ua806-\\ua806'
|
|
890
|
+
+ '\\ua80b-\\ua80b'
|
|
891
|
+
+ '\\ua825-\\ua826'
|
|
892
|
+
+ '\\ufb1e-\\ufb1e'
|
|
893
|
+
+ '\\ufe00-\\ufe0f'
|
|
894
|
+
+ '\\ufe20-\\ufe23'
|
|
895
|
+
+ '\\ufeff-\\ufeff'
|
|
896
|
+
+ '\\ufff9-\\ufffb'
|
|
897
|
+
+ ']'
|
|
898
|
+
+ '|[\\ud802-\\ud802][\\ude01-\\ude03]'
|
|
899
|
+
+ '|[\\ud802-\\ud802][\\ude05-\\ude06]'
|
|
900
|
+
+ '|[\\ud802-\\ud802][\\ude0c-\\ude0f]'
|
|
901
|
+
+ '|[\\ud802-\\ud802][\\ude38-\\ude3a]'
|
|
902
|
+
+ '|[\\ud802-\\ud802][\\ude3f-\\ude3f]'
|
|
903
|
+
+ '|[\\ud834-\\ud834][\\udd67-\\udd69]'
|
|
904
|
+
+ '|[\\ud834-\\ud834][\\udd73-\\udd82]'
|
|
905
|
+
+ '|[\\ud834-\\ud834][\\udd85-\\udd8b]'
|
|
906
|
+
+ '|[\\ud834-\\ud834][\\uddaa-\\uddad]'
|
|
907
|
+
+ '|[\\ud834-\\ud834][\\ude42-\\ude44]'
|
|
908
|
+
+ '|[\\udb40-\\udb40][\\udc01-\\udc01]'
|
|
909
|
+
+ '|[\\udb40-\\udb40][\\udc20-\\udc7f]'
|
|
910
|
+
+ '|[\\udb40-\\udb40][\\udd00-\\uddef]'
|
|
911
|
+
, 'g');
|
|
912
|
+
*/
|