@simon_he/vue-tui 1.1.2 → 1.1.4
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/{TMermaidText-frVr8Ysb.js → TMermaidText-wLnMMvVS.js} +1 -1
- package/dist/{TSelect-tJ87rKPM.js → TSelect-CMBOOFwK.js} +4 -4
- package/dist/{TTree-CGdE-CYu.js → TTree-kk8ntrpg.js} +6 -5
- package/dist/agent/mermaid.d.cts +2 -2
- package/dist/agent/mermaid.d.ts +2 -2
- package/dist/agent.cjs +3896 -13616
- package/dist/agent.js +25 -82
- package/dist/{block-source-CrlmaBM5.js → block-source-D3YGTErb.js} +447 -326
- package/dist/cli.cjs +52 -15
- package/dist/cli.js +69 -14
- package/dist/core.js +3 -3
- package/dist/{hyperlink-_1FAj7Wq.js → create-terminal-Db_-UGVQ.js} +474 -102
- package/dist/{dom-renderer-DXx8fWzD.js → dom-renderer-BfwAEQMf.js} +3 -2
- package/dist/experimental.cjs +99 -66
- package/dist/experimental.js +20 -74
- package/dist/hyperlink-clbb_ha_.js +100 -0
- package/dist/index.js +8 -8
- package/dist/{linkify-D68T7rdW.js → linkify-CL9wwnZN.js} +2 -2
- package/dist/markdown.cjs +3376 -13056
- package/dist/markdown.d.cts +4 -0
- package/dist/markdown.d.ts +4 -0
- package/dist/markdown.js +79 -8
- package/dist/math-image-BZhmfUeu.js +308 -0
- package/dist/mermaid-uEfRItDe.js +1205 -0
- package/dist/mermaid.cjs +1089 -3
- package/dist/mermaid.d.cts +4 -0
- package/dist/mermaid.d.ts +4 -0
- package/dist/mermaid.js +7 -5
- package/dist/{rect-DUpeDfBg.js → rect-JzWMJxxc.js} +1 -1
- package/dist/renderer/cli/stdout-renderer.d.ts +44 -0
- package/dist/renderer/terminal-graphics.d.ts +44 -0
- package/dist/renderer-dom.js +4 -4
- package/dist/{terminal-graphics-Bbe83wSr.js → terminal-graphics-DWZrl3oh.js} +85 -2
- package/dist/{tlog-theme-Bul2Na3u.js → tlog-theme-DqnF_zNe.js} +5 -4
- package/dist/vue/components/TAgentTerminalGraphic.d.ts +1 -1
- package/dist/vue/components/TMarkdownText.d.ts +70 -2
- package/dist/vue/components/TMermaidImage.d.ts +733 -0
- package/dist/vue/components/TMermaidText.d.ts +2 -2
- package/dist/vue/components/TVirtualMarkdown.d.ts +70 -2
- package/dist/vue/markdown/ast.d.ts +5 -0
- package/dist/vue/markdown/document.d.ts +3 -0
- package/dist/vue/markdown/math-image.d.ts +68 -0
- package/dist/vue/markdown/math.d.ts +2 -0
- package/dist/vue/markdown/theme.d.ts +12 -0
- package/dist/vue/markdown/types.d.ts +12 -2
- package/dist/vue/mermaid/beautiful-mermaid.d.ts +4 -4
- package/dist/vue/mermaid/mermaid-image.d.ts +65 -0
- package/dist/vue.js +9 -9
- package/package.json +20 -3
- package/dist/mermaid-BNhM1jAZ.js +0 -123
- package/dist/width-GqllnV8C.js +0 -474
- /package/dist/{ansi-palette-CH6jc2Z7.js → ansi-palette-BHF1rN7R.js} +0 -0
package/dist/width-GqllnV8C.js
DELETED
|
@@ -1,474 +0,0 @@
|
|
|
1
|
-
//#region src/utils/grapheme.ts
|
|
2
|
-
let graphemeSegmenter = null;
|
|
3
|
-
try {
|
|
4
|
-
const Segmenter = typeof Intl !== "undefined" ? Intl.Segmenter : void 0;
|
|
5
|
-
graphemeSegmenter = Segmenter ? new Segmenter(void 0, { granularity: "grapheme" }) : null;
|
|
6
|
-
} catch {
|
|
7
|
-
graphemeSegmenter = null;
|
|
8
|
-
}
|
|
9
|
-
let unicodeMarkRe = null;
|
|
10
|
-
try {
|
|
11
|
-
unicodeMarkRe = new RegExp("\\p{Mark}", "u");
|
|
12
|
-
} catch {
|
|
13
|
-
unicodeMarkRe = null;
|
|
14
|
-
}
|
|
15
|
-
function needsGraphemeSegmentation(text) {
|
|
16
|
-
for (const ch of text) {
|
|
17
|
-
const cp = ch.codePointAt(0);
|
|
18
|
-
if (cp === 8205) return true;
|
|
19
|
-
if (cp >= 65024 && cp <= 65039 || cp >= 917760 && cp <= 917999) return true;
|
|
20
|
-
if (isCombiningMark(cp)) return true;
|
|
21
|
-
if (cp >= 127995 && cp <= 127999) return true;
|
|
22
|
-
if (cp >= 127462 && cp <= 127487) return true;
|
|
23
|
-
if (cp >= 917504 && cp <= 917631) return true;
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
function isVariationSelector(codePoint) {
|
|
28
|
-
return codePoint >= 65024 && codePoint <= 65039 || codePoint >= 917760 && codePoint <= 917999;
|
|
29
|
-
}
|
|
30
|
-
function isCombiningMark(codePoint) {
|
|
31
|
-
return codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071 || isDevanagariMark(codePoint) || unicodeMarkRe?.test(String.fromCodePoint(codePoint)) === true;
|
|
32
|
-
}
|
|
33
|
-
function isDevanagariMark(codePoint) {
|
|
34
|
-
return codePoint >= 2304 && codePoint <= 2307 || codePoint >= 2362 && codePoint <= 2364 || codePoint >= 2366 && codePoint <= 2383 || codePoint >= 2385 && codePoint <= 2391 || codePoint >= 2402 && codePoint <= 2403;
|
|
35
|
-
}
|
|
36
|
-
function isVirama(codePoint) {
|
|
37
|
-
return codePoint === 2381;
|
|
38
|
-
}
|
|
39
|
-
function isEmojiModifier(codePoint) {
|
|
40
|
-
return codePoint >= 127995 && codePoint <= 127999;
|
|
41
|
-
}
|
|
42
|
-
function isRegionalIndicator(codePoint) {
|
|
43
|
-
return codePoint >= 127462 && codePoint <= 127487;
|
|
44
|
-
}
|
|
45
|
-
function isEmojiTag(codePoint) {
|
|
46
|
-
return codePoint >= 917504 && codePoint <= 917631;
|
|
47
|
-
}
|
|
48
|
-
function fallbackGraphemeSegments(text) {
|
|
49
|
-
const out = [];
|
|
50
|
-
let segment = "";
|
|
51
|
-
let segmentStart = 0;
|
|
52
|
-
let pos = 0;
|
|
53
|
-
let regionalIndicators = 0;
|
|
54
|
-
let joinNext = false;
|
|
55
|
-
const pushSegment = () => {
|
|
56
|
-
if (segment) out.push({
|
|
57
|
-
segment,
|
|
58
|
-
index: segmentStart
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
for (const ch of text) {
|
|
62
|
-
const codePoint = ch.codePointAt(0);
|
|
63
|
-
const chStart = pos;
|
|
64
|
-
pos += ch.length;
|
|
65
|
-
const attach = segment !== "" && (joinNext || codePoint === 8205 || isVariationSelector(codePoint) || isCombiningMark(codePoint) || isEmojiModifier(codePoint) || isEmojiTag(codePoint) || isRegionalIndicator(codePoint) && regionalIndicators === 1);
|
|
66
|
-
if (!attach) {
|
|
67
|
-
pushSegment();
|
|
68
|
-
segment = ch;
|
|
69
|
-
segmentStart = chStart;
|
|
70
|
-
regionalIndicators = isRegionalIndicator(codePoint) ? 1 : 0;
|
|
71
|
-
} else {
|
|
72
|
-
segment += ch;
|
|
73
|
-
if (isRegionalIndicator(codePoint)) regionalIndicators++;
|
|
74
|
-
else if (!isVariationSelector(codePoint) && !isCombiningMark(codePoint)) regionalIndicators = 0;
|
|
75
|
-
}
|
|
76
|
-
if (codePoint === 8205 || isVirama(codePoint)) joinNext = true;
|
|
77
|
-
else if (joinNext && !isVariationSelector(codePoint) && !isCombiningMark(codePoint)) joinNext = false;
|
|
78
|
-
}
|
|
79
|
-
pushSegment();
|
|
80
|
-
return out;
|
|
81
|
-
}
|
|
82
|
-
function segmentedGraphemes(text) {
|
|
83
|
-
if (!needsGraphemeSegmentation(text)) return null;
|
|
84
|
-
if (graphemeSegmenter) return graphemeSegmenter.segment(text);
|
|
85
|
-
return fallbackGraphemeSegments(text);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region src/core/buffer/eaw-ranges-unicode-17.ts
|
|
90
|
-
const fullWidthRanges = [
|
|
91
|
-
[4352, 4447],
|
|
92
|
-
[8986, 8987],
|
|
93
|
-
[9001, 9002],
|
|
94
|
-
[9193, 9196],
|
|
95
|
-
[9200, 9200],
|
|
96
|
-
[9203, 9203],
|
|
97
|
-
[9725, 9726],
|
|
98
|
-
[9748, 9749],
|
|
99
|
-
[9776, 9783],
|
|
100
|
-
[9800, 9811],
|
|
101
|
-
[9855, 9855],
|
|
102
|
-
[9866, 9871],
|
|
103
|
-
[9875, 9875],
|
|
104
|
-
[9889, 9889],
|
|
105
|
-
[9898, 9899],
|
|
106
|
-
[9917, 9918],
|
|
107
|
-
[9924, 9925],
|
|
108
|
-
[9934, 9934],
|
|
109
|
-
[9940, 9940],
|
|
110
|
-
[9962, 9962],
|
|
111
|
-
[9970, 9971],
|
|
112
|
-
[9973, 9973],
|
|
113
|
-
[9978, 9978],
|
|
114
|
-
[9981, 9981],
|
|
115
|
-
[9989, 9989],
|
|
116
|
-
[9994, 9995],
|
|
117
|
-
[10024, 10024],
|
|
118
|
-
[10060, 10060],
|
|
119
|
-
[10062, 10062],
|
|
120
|
-
[10067, 10069],
|
|
121
|
-
[10071, 10071],
|
|
122
|
-
[10133, 10135],
|
|
123
|
-
[10160, 10160],
|
|
124
|
-
[10175, 10175],
|
|
125
|
-
[11035, 11036],
|
|
126
|
-
[11088, 11088],
|
|
127
|
-
[11093, 11093],
|
|
128
|
-
[11904, 11929],
|
|
129
|
-
[11931, 12019],
|
|
130
|
-
[12032, 12245],
|
|
131
|
-
[12272, 12350],
|
|
132
|
-
[12353, 12438],
|
|
133
|
-
[12441, 12543],
|
|
134
|
-
[12549, 12591],
|
|
135
|
-
[12593, 12686],
|
|
136
|
-
[12688, 12773],
|
|
137
|
-
[12783, 12830],
|
|
138
|
-
[12832, 12871],
|
|
139
|
-
[12880, 42124],
|
|
140
|
-
[42128, 42182],
|
|
141
|
-
[43360, 43388],
|
|
142
|
-
[44032, 55203],
|
|
143
|
-
[63744, 64255],
|
|
144
|
-
[65040, 65049],
|
|
145
|
-
[65072, 65106],
|
|
146
|
-
[65108, 65126],
|
|
147
|
-
[65128, 65131],
|
|
148
|
-
[65281, 65376],
|
|
149
|
-
[65504, 65510],
|
|
150
|
-
[94176, 94180],
|
|
151
|
-
[94192, 94198],
|
|
152
|
-
[94208, 101589],
|
|
153
|
-
[101631, 101662],
|
|
154
|
-
[101760, 101874],
|
|
155
|
-
[110576, 110579],
|
|
156
|
-
[110581, 110587],
|
|
157
|
-
[110589, 110590],
|
|
158
|
-
[110592, 110882],
|
|
159
|
-
[110898, 110898],
|
|
160
|
-
[110928, 110930],
|
|
161
|
-
[110933, 110933],
|
|
162
|
-
[110948, 110951],
|
|
163
|
-
[110960, 111355],
|
|
164
|
-
[119552, 119638],
|
|
165
|
-
[119648, 119670],
|
|
166
|
-
[126980, 126980],
|
|
167
|
-
[127183, 127183],
|
|
168
|
-
[127374, 127374],
|
|
169
|
-
[127377, 127386],
|
|
170
|
-
[127488, 127490],
|
|
171
|
-
[127504, 127547],
|
|
172
|
-
[127552, 127560],
|
|
173
|
-
[127568, 127569],
|
|
174
|
-
[127584, 127589],
|
|
175
|
-
[127744, 127776],
|
|
176
|
-
[127789, 127797],
|
|
177
|
-
[127799, 127868],
|
|
178
|
-
[127870, 127891],
|
|
179
|
-
[127904, 127946],
|
|
180
|
-
[127951, 127955],
|
|
181
|
-
[127968, 127984],
|
|
182
|
-
[127988, 127988],
|
|
183
|
-
[127992, 128062],
|
|
184
|
-
[128064, 128064],
|
|
185
|
-
[128066, 128252],
|
|
186
|
-
[128255, 128317],
|
|
187
|
-
[128331, 128334],
|
|
188
|
-
[128336, 128359],
|
|
189
|
-
[128378, 128378],
|
|
190
|
-
[128405, 128406],
|
|
191
|
-
[128420, 128420],
|
|
192
|
-
[128507, 128591],
|
|
193
|
-
[128640, 128709],
|
|
194
|
-
[128716, 128716],
|
|
195
|
-
[128720, 128722],
|
|
196
|
-
[128725, 128728],
|
|
197
|
-
[128732, 128735],
|
|
198
|
-
[128747, 128748],
|
|
199
|
-
[128756, 128764],
|
|
200
|
-
[128992, 129003],
|
|
201
|
-
[129008, 129008],
|
|
202
|
-
[129292, 129338],
|
|
203
|
-
[129340, 129349],
|
|
204
|
-
[129351, 129535],
|
|
205
|
-
[129648, 129660],
|
|
206
|
-
[129664, 129674],
|
|
207
|
-
[129678, 129734],
|
|
208
|
-
[129736, 129736],
|
|
209
|
-
[129741, 129756],
|
|
210
|
-
[129759, 129770],
|
|
211
|
-
[129775, 129784],
|
|
212
|
-
[131072, 196605],
|
|
213
|
-
[196608, 262141]
|
|
214
|
-
];
|
|
215
|
-
const ambiguousWidthRanges = [
|
|
216
|
-
[161, 161],
|
|
217
|
-
[164, 164],
|
|
218
|
-
[167, 168],
|
|
219
|
-
[170, 170],
|
|
220
|
-
[173, 174],
|
|
221
|
-
[176, 180],
|
|
222
|
-
[182, 186],
|
|
223
|
-
[188, 191],
|
|
224
|
-
[198, 198],
|
|
225
|
-
[208, 208],
|
|
226
|
-
[215, 216],
|
|
227
|
-
[222, 225],
|
|
228
|
-
[230, 230],
|
|
229
|
-
[232, 234],
|
|
230
|
-
[236, 237],
|
|
231
|
-
[240, 240],
|
|
232
|
-
[242, 243],
|
|
233
|
-
[247, 250],
|
|
234
|
-
[252, 252],
|
|
235
|
-
[254, 254],
|
|
236
|
-
[257, 257],
|
|
237
|
-
[273, 273],
|
|
238
|
-
[275, 275],
|
|
239
|
-
[283, 283],
|
|
240
|
-
[294, 295],
|
|
241
|
-
[299, 299],
|
|
242
|
-
[305, 307],
|
|
243
|
-
[312, 312],
|
|
244
|
-
[319, 322],
|
|
245
|
-
[324, 324],
|
|
246
|
-
[328, 331],
|
|
247
|
-
[333, 333],
|
|
248
|
-
[338, 339],
|
|
249
|
-
[358, 359],
|
|
250
|
-
[363, 363],
|
|
251
|
-
[462, 462],
|
|
252
|
-
[464, 464],
|
|
253
|
-
[466, 466],
|
|
254
|
-
[468, 468],
|
|
255
|
-
[470, 470],
|
|
256
|
-
[472, 472],
|
|
257
|
-
[474, 474],
|
|
258
|
-
[476, 476],
|
|
259
|
-
[593, 593],
|
|
260
|
-
[609, 609],
|
|
261
|
-
[708, 708],
|
|
262
|
-
[711, 711],
|
|
263
|
-
[713, 715],
|
|
264
|
-
[717, 717],
|
|
265
|
-
[720, 720],
|
|
266
|
-
[728, 731],
|
|
267
|
-
[733, 733],
|
|
268
|
-
[735, 735],
|
|
269
|
-
[768, 879],
|
|
270
|
-
[913, 929],
|
|
271
|
-
[931, 937],
|
|
272
|
-
[945, 961],
|
|
273
|
-
[963, 969],
|
|
274
|
-
[1025, 1025],
|
|
275
|
-
[1040, 1103],
|
|
276
|
-
[1105, 1105],
|
|
277
|
-
[8208, 8208],
|
|
278
|
-
[8211, 8214],
|
|
279
|
-
[8216, 8217],
|
|
280
|
-
[8220, 8221],
|
|
281
|
-
[8224, 8226],
|
|
282
|
-
[8228, 8231],
|
|
283
|
-
[8240, 8240],
|
|
284
|
-
[8242, 8243],
|
|
285
|
-
[8245, 8245],
|
|
286
|
-
[8251, 8251],
|
|
287
|
-
[8254, 8254],
|
|
288
|
-
[8308, 8308],
|
|
289
|
-
[8319, 8319],
|
|
290
|
-
[8321, 8324],
|
|
291
|
-
[8364, 8364],
|
|
292
|
-
[8451, 8451],
|
|
293
|
-
[8453, 8453],
|
|
294
|
-
[8457, 8457],
|
|
295
|
-
[8467, 8467],
|
|
296
|
-
[8470, 8470],
|
|
297
|
-
[8481, 8482],
|
|
298
|
-
[8486, 8486],
|
|
299
|
-
[8491, 8491],
|
|
300
|
-
[8531, 8532],
|
|
301
|
-
[8539, 8542],
|
|
302
|
-
[8544, 8555],
|
|
303
|
-
[8560, 8569],
|
|
304
|
-
[8585, 8585],
|
|
305
|
-
[8592, 8601],
|
|
306
|
-
[8632, 8633],
|
|
307
|
-
[8658, 8658],
|
|
308
|
-
[8660, 8660],
|
|
309
|
-
[8679, 8679],
|
|
310
|
-
[8704, 8704],
|
|
311
|
-
[8706, 8707],
|
|
312
|
-
[8711, 8712],
|
|
313
|
-
[8715, 8715],
|
|
314
|
-
[8719, 8719],
|
|
315
|
-
[8721, 8721],
|
|
316
|
-
[8725, 8725],
|
|
317
|
-
[8730, 8730],
|
|
318
|
-
[8733, 8736],
|
|
319
|
-
[8739, 8739],
|
|
320
|
-
[8741, 8741],
|
|
321
|
-
[8743, 8748],
|
|
322
|
-
[8750, 8750],
|
|
323
|
-
[8756, 8759],
|
|
324
|
-
[8764, 8765],
|
|
325
|
-
[8776, 8776],
|
|
326
|
-
[8780, 8780],
|
|
327
|
-
[8786, 8786],
|
|
328
|
-
[8800, 8801],
|
|
329
|
-
[8804, 8807],
|
|
330
|
-
[8810, 8811],
|
|
331
|
-
[8814, 8815],
|
|
332
|
-
[8834, 8835],
|
|
333
|
-
[8838, 8839],
|
|
334
|
-
[8853, 8853],
|
|
335
|
-
[8857, 8857],
|
|
336
|
-
[8869, 8869],
|
|
337
|
-
[8895, 8895],
|
|
338
|
-
[8978, 8978],
|
|
339
|
-
[9312, 9449],
|
|
340
|
-
[9451, 9547],
|
|
341
|
-
[9552, 9587],
|
|
342
|
-
[9600, 9615],
|
|
343
|
-
[9618, 9621],
|
|
344
|
-
[9632, 9633],
|
|
345
|
-
[9635, 9641],
|
|
346
|
-
[9650, 9651],
|
|
347
|
-
[9654, 9655],
|
|
348
|
-
[9660, 9661],
|
|
349
|
-
[9664, 9665],
|
|
350
|
-
[9670, 9672],
|
|
351
|
-
[9675, 9675],
|
|
352
|
-
[9678, 9681],
|
|
353
|
-
[9698, 9701],
|
|
354
|
-
[9711, 9711],
|
|
355
|
-
[9733, 9734],
|
|
356
|
-
[9737, 9737],
|
|
357
|
-
[9742, 9743],
|
|
358
|
-
[9756, 9756],
|
|
359
|
-
[9758, 9758],
|
|
360
|
-
[9792, 9792],
|
|
361
|
-
[9794, 9794],
|
|
362
|
-
[9824, 9825],
|
|
363
|
-
[9827, 9829],
|
|
364
|
-
[9831, 9834],
|
|
365
|
-
[9836, 9837],
|
|
366
|
-
[9839, 9839],
|
|
367
|
-
[9886, 9887],
|
|
368
|
-
[9919, 9919],
|
|
369
|
-
[9926, 9933],
|
|
370
|
-
[9935, 9939],
|
|
371
|
-
[9941, 9953],
|
|
372
|
-
[9955, 9955],
|
|
373
|
-
[9960, 9961],
|
|
374
|
-
[9963, 9969],
|
|
375
|
-
[9972, 9972],
|
|
376
|
-
[9974, 9977],
|
|
377
|
-
[9979, 9980],
|
|
378
|
-
[9982, 9983],
|
|
379
|
-
[10045, 10045],
|
|
380
|
-
[10102, 10111],
|
|
381
|
-
[11094, 11097],
|
|
382
|
-
[12872, 12879],
|
|
383
|
-
[57344, 63743],
|
|
384
|
-
[65024, 65039],
|
|
385
|
-
[65533, 65533],
|
|
386
|
-
[127232, 127242],
|
|
387
|
-
[127248, 127277],
|
|
388
|
-
[127280, 127337],
|
|
389
|
-
[127344, 127373],
|
|
390
|
-
[127375, 127376],
|
|
391
|
-
[127387, 127404],
|
|
392
|
-
[917760, 917999],
|
|
393
|
-
[983040, 1048573],
|
|
394
|
-
[1048576, 1114109]
|
|
395
|
-
];
|
|
396
|
-
|
|
397
|
-
//#endregion
|
|
398
|
-
//#region src/core/buffer/width.ts
|
|
399
|
-
function isFullWidthCodePoint(codePoint) {
|
|
400
|
-
if (codePoint < 4352) return false;
|
|
401
|
-
for (const [start, end] of fullWidthRanges) {
|
|
402
|
-
if (codePoint < start) return false;
|
|
403
|
-
if (codePoint <= end) return true;
|
|
404
|
-
}
|
|
405
|
-
return false;
|
|
406
|
-
}
|
|
407
|
-
function isAmbiguousWidthCodePoint(codePoint) {
|
|
408
|
-
const first = ambiguousWidthRanges[0];
|
|
409
|
-
const last = ambiguousWidthRanges[ambiguousWidthRanges.length - 1];
|
|
410
|
-
if (!first || !last) return false;
|
|
411
|
-
if (codePoint < first[0] || codePoint > last[1]) return false;
|
|
412
|
-
for (const [start, end] of ambiguousWidthRanges) {
|
|
413
|
-
if (codePoint < start) return false;
|
|
414
|
-
if (codePoint <= end) return true;
|
|
415
|
-
}
|
|
416
|
-
return false;
|
|
417
|
-
}
|
|
418
|
-
function isVariationSelectorCodePoint(codePoint) {
|
|
419
|
-
return codePoint >= 65024 && codePoint <= 65039 || codePoint >= 917760 && codePoint <= 917999;
|
|
420
|
-
}
|
|
421
|
-
function isCombiningMarkCodePoint(codePoint) {
|
|
422
|
-
return codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071 || codePoint >= 12330 && codePoint <= 12335 || codePoint >= 12441 && codePoint <= 12442 || codePoint === 94180;
|
|
423
|
-
}
|
|
424
|
-
function isEmojiLike(codePoint) {
|
|
425
|
-
return codePoint >= 127744 && codePoint <= 129791 || codePoint >= 127462 && codePoint <= 127487;
|
|
426
|
-
}
|
|
427
|
-
let extendedPictographicRe = null;
|
|
428
|
-
try {
|
|
429
|
-
extendedPictographicRe = new RegExp("\\p{Extended_Pictographic}", "u");
|
|
430
|
-
} catch {
|
|
431
|
-
extendedPictographicRe = null;
|
|
432
|
-
}
|
|
433
|
-
let emojiPresentationRe = null;
|
|
434
|
-
try {
|
|
435
|
-
emojiPresentationRe = new RegExp("\\p{Emoji_Presentation}", "u");
|
|
436
|
-
} catch {
|
|
437
|
-
emojiPresentationRe = null;
|
|
438
|
-
}
|
|
439
|
-
let emojiRe = null;
|
|
440
|
-
try {
|
|
441
|
-
emojiRe = new RegExp("\\p{Emoji}", "u");
|
|
442
|
-
} catch {
|
|
443
|
-
emojiRe = null;
|
|
444
|
-
}
|
|
445
|
-
function normalizeCustomWidth(width) {
|
|
446
|
-
return width === 2 ? 2 : 1;
|
|
447
|
-
}
|
|
448
|
-
function charCellWidth(text, provider = "default") {
|
|
449
|
-
if (!text) return 1;
|
|
450
|
-
if (typeof provider === "function") return normalizeCustomWidth(provider(text));
|
|
451
|
-
if (provider !== "cjk" && text.length === 1) {
|
|
452
|
-
const code = text.charCodeAt(0);
|
|
453
|
-
if (code < 4352) return 1;
|
|
454
|
-
}
|
|
455
|
-
const codePoint = text.codePointAt(0);
|
|
456
|
-
if (codePoint == null) return 1;
|
|
457
|
-
const hasVs16 = text.includes("️");
|
|
458
|
-
if (isVariationSelectorCodePoint(codePoint) || isCombiningMarkCodePoint(codePoint)) return 1;
|
|
459
|
-
if (codePoint >= 9472 && codePoint <= 9599) return 1;
|
|
460
|
-
if (isFullWidthCodePoint(codePoint)) return 2;
|
|
461
|
-
if (provider === "cjk" && isAmbiguousWidthCodePoint(codePoint)) return 2;
|
|
462
|
-
if (isEmojiLike(codePoint)) return 2;
|
|
463
|
-
if (emojiPresentationRe?.test(text)) return 2;
|
|
464
|
-
if (text.includes("⃣")) return 2;
|
|
465
|
-
if (hasVs16 && emojiRe?.test(text)) return 2;
|
|
466
|
-
if (extendedPictographicRe?.test(text)) {
|
|
467
|
-
if (codePoint <= 65535) return hasVs16 ? 2 : 1;
|
|
468
|
-
return 2;
|
|
469
|
-
}
|
|
470
|
-
return 1;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
//#endregion
|
|
474
|
-
export { charCellWidth, segmentedGraphemes };
|
|
File without changes
|