@reliverse/relinka 1.1.5 → 1.1.6
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-npm/components/anykey/index.js +77 -57
- package/dist-npm/components/block/block.js +61 -48
- package/dist-npm/components/checkbox/index.js +211 -178
- package/dist-npm/components/confirm/confirm-main.js +122 -85
- package/dist-npm/components/confirm/confirm-three.js +27 -24
- package/dist-npm/components/confirm/index.js +45 -36
- package/dist-npm/components/core/Separator.js +17 -15
- package/dist-npm/components/core/create-prompt.js +124 -101
- package/dist-npm/components/core/errors.js +15 -19
- package/dist-npm/components/core/hook-engine.js +120 -91
- package/dist-npm/components/core/index.js +12 -12
- package/dist-npm/components/core/key.js +6 -16
- package/dist-npm/components/core/lines.js +54 -45
- package/dist-npm/components/core/make-theme.js +30 -21
- package/dist-npm/components/core/position.js +23 -27
- package/dist-npm/components/core/promise-polyfill.js +14 -11
- package/dist-npm/components/core/screen-manager.js +74 -59
- package/dist-npm/components/core/theme.js +32 -22
- package/dist-npm/components/core/use-effect.js +15 -9
- package/dist-npm/components/core/use-keypress.js +23 -19
- package/dist-npm/components/core/use-memo.js +16 -10
- package/dist-npm/components/core/use-pagination.js +32 -33
- package/dist-npm/components/core/use-prefix.js +38 -40
- package/dist-npm/components/core/use-ref.js +5 -2
- package/dist-npm/components/core/use-state.js +23 -15
- package/dist-npm/components/core/useKeyPress.js +17 -14
- package/dist-npm/components/core/usePromptState.js +14 -8
- package/dist-npm/components/core/utils.js +16 -7
- package/dist-npm/components/date/date.js +204 -167
- package/dist-npm/components/editor/index.js +92 -71
- package/dist-npm/components/expand/index.js +124 -96
- package/dist-npm/components/figures/index.js +294 -283
- package/dist-npm/components/input/index.js +87 -61
- package/dist-npm/components/input/text-main.js +124 -97
- package/dist-npm/components/input/text.js +28 -24
- package/dist-npm/components/instance/basic.js +25 -17
- package/dist-npm/components/instance/browser.js +18 -14
- package/dist-npm/components/instance/reporter/basic.js +65 -46
- package/dist-npm/components/instance/reporter/browser.js +47 -44
- package/dist-npm/components/instance/reporter/fancy.js +96 -83
- package/dist-npm/components/instance/shared.js +2 -2
- package/dist-npm/components/mono/mono.js +62 -52
- package/dist-npm/components/mono/monoTwo.js +49 -35
- package/dist-npm/components/multiselect/group-multiselect.js +71 -55
- package/dist-npm/components/multiselect/multi-select-two.js +130 -97
- package/dist-npm/components/multiselect/multi-select.js +49 -43
- package/dist-npm/components/multiselect/multiselect-main.js +146 -120
- package/dist-npm/components/multiselect/num-multi-select.js +130 -97
- package/dist-npm/components/multiselect/num-multiselect-main.js +35 -24
- package/dist-npm/components/next-steps/next-steps.js +25 -23
- package/dist-npm/components/number/index.js +112 -78
- package/dist-npm/components/number/number-main.js +2 -95
- package/dist-npm/components/password/index.js +73 -54
- package/dist-npm/components/password/password-main.js +2 -119
- package/dist-npm/components/password/password-three.js +30 -26
- package/dist-npm/components/progressbar/ProgressBar.js +64 -45
- package/dist-npm/components/progressbar/helper.js +40 -33
- package/dist-npm/components/progressbar/index.js +1 -1
- package/dist-npm/components/prompts/create.js +44 -29
- package/dist-npm/components/prompts/index.js +45 -45
- package/dist-npm/components/prompts/prompt.js +260 -211
- package/dist-npm/components/prompts/promptTwo.js +605 -561
- package/dist-npm/components/prompts/relinka.js +295 -237
- package/dist-npm/components/range/range.js +294 -247
- package/dist-npm/components/rawlist/index.js +107 -87
- package/dist-npm/components/results/results.js +37 -31
- package/dist-npm/components/search/index.js +193 -148
- package/dist-npm/components/select/index.js +186 -148
- package/dist-npm/components/select/num-select-main.js +27 -27
- package/dist-npm/components/select/num-select.js +5 -124
- package/dist-npm/components/select/select-key.js +25 -24
- package/dist-npm/components/select/select-main.js +133 -109
- package/dist-npm/components/select/select-three.js +36 -32
- package/dist-npm/components/select/select-two.js +87 -94
- package/dist-npm/components/spinner/index.js +136 -107
- package/dist-npm/components/st-end/end.js +26 -34
- package/dist-npm/components/st-end/start.js +15 -29
- package/dist-npm/components/toggle/index.js +137 -113
- package/dist-npm/components/visual/animate/animate.js +10 -53
- package/dist-npm/components/visual/ascii-art/ascii-art.js +1 -12
- package/dist-npm/mod.js +2 -1
- package/dist-npm/testing/index.js +83 -58
- package/dist-npm/types/general.js +1 -0
- package/dist-npm/types/index.js +3 -2
- package/dist-npm/types/keypress.js +36 -35
- package/dist-npm/types/readline.js +1 -0
- package/dist-npm/types/relinka.js +1 -0
- package/dist-npm/types/utils.js +1 -0
- package/dist-npm/utils/box.js +137 -135
- package/dist-npm/utils/color.js +74 -65
- package/dist-npm/utils/colorize.js +156 -124
- package/dist-npm/utils/component.js +657 -532
- package/dist-npm/utils/constants.js +63 -64
- package/dist-npm/utils/core.js +3 -2
- package/dist-npm/utils/decoder.js +223 -244
- package/dist-npm/utils/error.js +9 -4
- package/dist-npm/utils/errors.js +4 -14
- package/dist-npm/utils/format.js +24 -19
- package/dist-npm/utils/keypress.js +414 -316
- package/dist-npm/utils/log.js +15 -11
- package/dist-npm/utils/mapping.js +52 -45
- package/dist-npm/utils/messages.js +183 -183
- package/dist-npm/utils/platforms.js +20 -16
- package/dist-npm/utils/prompt-tmp.js +286 -235
- package/dist-npm/utils/prompt-two.js +286 -235
- package/dist-npm/utils/readline.js +7 -5
- package/dist-npm/utils/skeleton.js +170 -130
- package/dist-npm/utils/stream.js +2 -2
- package/dist-npm/utils/string.js +58 -44
- package/dist-npm/utils/terminal.js +34 -23
- package/dist-npm/utils/tree.js +41 -30
- package/dist-npm/utils/types.js +1 -0
- package/dist-npm/utils/utils.js +8 -8
- package/dist-npm/utils/variants.js +44 -36
- package/package.json +20 -28
|
@@ -1,68 +1,67 @@
|
|
|
1
1
|
export const LogLevels = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
silent: Number.NEGATIVE_INFINITY,
|
|
3
|
+
fatal: 0,
|
|
4
|
+
error: 0,
|
|
5
|
+
warn: 1,
|
|
6
|
+
log: 2,
|
|
7
|
+
info: 3,
|
|
8
|
+
success: 3,
|
|
9
|
+
fail: 3,
|
|
10
|
+
ready: 3,
|
|
11
|
+
start: 3,
|
|
12
|
+
box: 3,
|
|
13
|
+
debug: 4,
|
|
14
|
+
trace: 5,
|
|
15
|
+
verbose: Number.POSITIVE_INFINITY,
|
|
16
16
|
};
|
|
17
17
|
export const LogTypes = {
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
18
|
+
silent: {
|
|
19
|
+
level: -1,
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
fatal: {
|
|
23
|
+
level: LogLevels.fatal,
|
|
24
|
+
},
|
|
25
|
+
error: {
|
|
26
|
+
level: LogLevels.error,
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
warn: {
|
|
30
|
+
level: LogLevels.warn,
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
log: {
|
|
34
|
+
level: LogLevels.log,
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
info: {
|
|
38
|
+
level: LogLevels.info,
|
|
39
|
+
},
|
|
40
|
+
success: {
|
|
41
|
+
level: LogLevels.success,
|
|
42
|
+
},
|
|
43
|
+
fail: {
|
|
44
|
+
level: LogLevels.fail,
|
|
45
|
+
},
|
|
46
|
+
ready: {
|
|
47
|
+
level: LogLevels.info,
|
|
48
|
+
},
|
|
49
|
+
start: {
|
|
50
|
+
level: LogLevels.info,
|
|
51
|
+
},
|
|
52
|
+
box: {
|
|
53
|
+
level: LogLevels.info,
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
debug: {
|
|
57
|
+
level: LogLevels.debug,
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
trace: {
|
|
61
|
+
level: LogLevels.trace,
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
verbose: {
|
|
65
|
+
level: LogLevels.verbose,
|
|
66
|
+
},
|
|
68
67
|
};
|
package/dist-npm/utils/core.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export * from
|
|
1
|
+
export {createRelinka} from '../components/prompts/relinka.js';
|
|
2
|
+
export * from '../components/instance/shared.js';
|
|
3
|
+
|
|
@@ -1,281 +1,260 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Buffer} from 'safe-buffer';
|
|
2
|
+
|
|
3
|
+
const isString = (a) => typeof a === 'string';
|
|
2
4
|
const isEncoding = Buffer.isEncoding || function(encoding) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
case
|
|
7
|
-
case
|
|
8
|
-
case
|
|
9
|
-
case
|
|
10
|
-
case
|
|
11
|
-
case
|
|
12
|
-
case
|
|
13
|
-
case
|
|
14
|
-
case
|
|
15
|
-
case
|
|
16
|
-
|
|
5
|
+
const enc = String(encoding).toLowerCase();
|
|
6
|
+
|
|
7
|
+
switch(enc) {
|
|
8
|
+
case 'hex':
|
|
9
|
+
case 'utf8':
|
|
10
|
+
case 'utf-8':
|
|
11
|
+
case 'ascii':
|
|
12
|
+
case 'binary':
|
|
13
|
+
case 'base64':
|
|
14
|
+
case 'ucs2':
|
|
15
|
+
case 'ucs-2':
|
|
16
|
+
case 'utf16le':
|
|
17
|
+
case 'utf-16le':
|
|
18
|
+
case 'raw':
|
|
19
|
+
return true;
|
|
20
|
+
|
|
17
21
|
default:
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
20
24
|
};
|
|
25
|
+
|
|
21
26
|
function _normalizeEncoding(enc) {
|
|
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
|
-
|
|
27
|
+
if (!enc) {
|
|
28
|
+
return 'utf8';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let retried = false;
|
|
32
|
+
let encoding = String(enc);
|
|
33
|
+
|
|
34
|
+
while (true) {
|
|
35
|
+
switch(encoding) {
|
|
36
|
+
case 'utf8':
|
|
37
|
+
case 'utf-8':
|
|
38
|
+
return 'utf8';
|
|
39
|
+
|
|
40
|
+
case 'ucs2':
|
|
41
|
+
case 'ucs-2':
|
|
42
|
+
case 'utf16le':
|
|
43
|
+
case 'utf-16le':
|
|
44
|
+
return 'utf16le';
|
|
45
|
+
|
|
46
|
+
case 'latin1':
|
|
47
|
+
case 'binary':
|
|
48
|
+
return 'latin1';
|
|
49
|
+
|
|
50
|
+
case 'base64':
|
|
51
|
+
case 'ascii':
|
|
52
|
+
case 'hex':
|
|
53
|
+
return encoding;
|
|
54
|
+
|
|
55
|
+
default:
|
|
56
|
+
if (retried) {
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
encoding = encoding.toLowerCase();
|
|
61
|
+
retried = true;
|
|
47
62
|
}
|
|
48
|
-
encoding = encoding.toLowerCase();
|
|
49
|
-
retried = true;
|
|
50
63
|
}
|
|
51
|
-
}
|
|
52
64
|
}
|
|
65
|
+
|
|
53
66
|
function normalizeEncoding(enc) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
const nenc = _normalizeEncoding(enc);
|
|
68
|
+
|
|
69
|
+
if (!isString(nenc) && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) {
|
|
70
|
+
throw Error(`Unknown encoding: ${enc}`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return nenc || enc;
|
|
59
74
|
}
|
|
75
|
+
|
|
60
76
|
export class StringDecoder {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
77
|
+
encoding;
|
|
78
|
+
lastNeed;
|
|
79
|
+
lastTotal;
|
|
80
|
+
lastChar;
|
|
81
|
+
fillLast;
|
|
82
|
+
text;
|
|
83
|
+
endFn;
|
|
84
|
+
writeFn;
|
|
85
|
+
constructor(encoding) {
|
|
86
|
+
this.encoding = normalizeEncoding(encoding);
|
|
87
|
+
let nb;
|
|
88
|
+
|
|
89
|
+
switch(this.encoding) {
|
|
90
|
+
case 'utf16le':
|
|
91
|
+
this.text = utf16Text;
|
|
92
|
+
this.endFn = utf16End;
|
|
93
|
+
nb = 4;
|
|
94
|
+
break;
|
|
95
|
+
|
|
96
|
+
case 'utf8':
|
|
97
|
+
this.fillLast = utf8FillLast;
|
|
98
|
+
nb = 4;
|
|
99
|
+
break;
|
|
100
|
+
|
|
101
|
+
case 'base64':
|
|
102
|
+
this.text = base64Text;
|
|
103
|
+
this.endFn = base64End;
|
|
104
|
+
nb = 3;
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
default:
|
|
108
|
+
this.writeFn = simpleWrite;
|
|
109
|
+
this.endFn = simpleEnd;
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
this.lastNeed = 0;
|
|
114
|
+
this.lastTotal = 0;
|
|
115
|
+
this.lastChar = Buffer.allocUnsafe(nb);
|
|
116
|
+
this.writeFn = this.write.bind(this);
|
|
91
117
|
}
|
|
92
|
-
|
|
93
|
-
this.lastTotal = 0;
|
|
94
|
-
this.lastChar = Buffer.allocUnsafe(nb);
|
|
95
|
-
this.writeFn = this.write.bind(this);
|
|
96
|
-
}
|
|
118
|
+
|
|
97
119
|
write(buf) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
if (!buf.length) {
|
|
121
|
+
return '';
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let r;
|
|
125
|
+
let i;
|
|
126
|
+
|
|
127
|
+
if (this.lastNeed) {
|
|
128
|
+
r = this.fillLast(buf);
|
|
129
|
+
if (r === void 0) {
|
|
130
|
+
return '';
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
i = this.lastNeed;
|
|
134
|
+
this.lastNeed = 0;
|
|
135
|
+
} else {
|
|
136
|
+
i = 0;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (i < buf.length) {
|
|
140
|
+
return r ? r + (this.text ? this.text(buf, i) : '') : this.text ? this.text(buf, i) : '';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return r || '';
|
|
115
144
|
}
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
145
|
+
/**
|
|
119
146
|
* Ends the decoding and returns any remaining characters.
|
|
120
147
|
* @param buf - Optional buffer to write before ending.
|
|
121
148
|
* @returns The final decoded string.
|
|
122
149
|
*/
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return result;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function utf8FillLast(buf) {
|
|
129
|
-
const p = this.lastTotal - this.lastNeed;
|
|
130
|
-
const r = utf8CheckExtraBytes(this, buf, p);
|
|
131
|
-
if (r !== void 0) {
|
|
132
|
-
return r;
|
|
133
|
-
}
|
|
134
|
-
if (this.lastNeed <= buf.length) {
|
|
135
|
-
buf.copy(this.lastChar, p, 0, this.lastNeed);
|
|
136
|
-
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
|
137
|
-
}
|
|
138
|
-
buf.copy(this.lastChar, p, 0, buf.length);
|
|
139
|
-
this.lastNeed -= buf.length;
|
|
140
|
-
}
|
|
141
|
-
function utf8Text(buf, i) {
|
|
142
|
-
const total = utf8CheckIncomplete(this, buf, i);
|
|
143
|
-
if (!this.lastNeed) {
|
|
144
|
-
return buf.toString("utf8", i);
|
|
145
|
-
}
|
|
146
|
-
this.lastTotal = total;
|
|
147
|
-
const end = buf.length - (total - this.lastNeed);
|
|
148
|
-
buf.copy(this.lastChar, 0, end);
|
|
149
|
-
return buf.toString("utf8", i, end);
|
|
150
|
-
}
|
|
151
|
-
function utf8End(buf) {
|
|
152
|
-
const r = buf?.length ? this.write(buf) : "";
|
|
153
|
-
if (this.lastNeed) {
|
|
154
|
-
return r + "\uFFFD";
|
|
155
|
-
}
|
|
156
|
-
return r;
|
|
157
|
-
}
|
|
158
|
-
function utf8CheckByte(byte) {
|
|
159
|
-
if (byte <= 127) {
|
|
160
|
-
return 0;
|
|
161
|
-
} else if (byte >> 5 === 6) {
|
|
162
|
-
return 2;
|
|
163
|
-
} else if (byte >> 4 === 14) {
|
|
164
|
-
return 3;
|
|
165
|
-
} else if (byte >> 3 === 30) {
|
|
166
|
-
return 4;
|
|
167
|
-
}
|
|
168
|
-
return byte >> 6 === 2 ? -1 : -2;
|
|
169
|
-
}
|
|
170
|
-
function utf8CheckIncomplete(self, buf, i) {
|
|
171
|
-
let j = buf.length - 1;
|
|
172
|
-
if (j < i) {
|
|
173
|
-
return 0;
|
|
174
|
-
}
|
|
175
|
-
let nb = utf8CheckByte(buf[j]);
|
|
176
|
-
if (nb >= 0) {
|
|
177
|
-
if (nb > 0) {
|
|
178
|
-
self.lastNeed = nb - 1;
|
|
150
|
+
end(buf) {
|
|
151
|
+
return this.endFn?.(buf) ?? '';
|
|
179
152
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (nb >= 0) {
|
|
187
|
-
if (nb > 0) {
|
|
188
|
-
self.lastNeed = nb - 2;
|
|
153
|
+
}function utf8FillLast(buf) {
|
|
154
|
+
const p = this.lastTotal - this.lastNeed;
|
|
155
|
+
const r = utf8CheckExtraBytes(this, buf);
|
|
156
|
+
|
|
157
|
+
if (r !== void 0) {
|
|
158
|
+
return r;
|
|
189
159
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
nb = utf8CheckByte(buf[j]);
|
|
196
|
-
if (nb >= 0) {
|
|
197
|
-
if (nb > 0) {
|
|
198
|
-
if (nb === 2) {
|
|
199
|
-
nb = 0;
|
|
200
|
-
} else {
|
|
201
|
-
self.lastNeed = nb - 3;
|
|
202
|
-
}
|
|
160
|
+
|
|
161
|
+
if (this.lastNeed <= buf.length) {
|
|
162
|
+
buf.copy(this.lastChar, p, 0, this.lastNeed);
|
|
163
|
+
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
|
203
164
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
165
|
+
|
|
166
|
+
buf.copy(this.lastChar, p, 0, buf.length);
|
|
167
|
+
this.lastNeed -= buf.length;
|
|
207
168
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (self.lastNeed > 1 && buf.length > 1) {
|
|
214
|
-
if ((buf[1] & 192) !== 128) {
|
|
215
|
-
self.lastNeed = 1;
|
|
216
|
-
return "\uFFFD";
|
|
169
|
+
|
|
170
|
+
function utf8CheckExtraBytes(self, buf) {
|
|
171
|
+
if ((buf[0] & 192) !== 128) {
|
|
172
|
+
self.lastNeed = 0;
|
|
173
|
+
return '\uFFFD';
|
|
217
174
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
175
|
+
|
|
176
|
+
if (self.lastNeed > 1 && buf.length > 1) {
|
|
177
|
+
if ((buf[1] & 192) !== 128) {
|
|
178
|
+
self.lastNeed = 1;
|
|
179
|
+
return '\uFFFD';
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (self.lastNeed > 2 && buf.length > 2 && (buf[2] & 192) !== 128) {
|
|
183
|
+
self.lastNeed = 2;
|
|
184
|
+
return '\uFFFD';
|
|
185
|
+
}
|
|
223
186
|
}
|
|
224
|
-
}
|
|
225
187
|
}
|
|
188
|
+
|
|
226
189
|
function utf16Text(buf, i) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
190
|
+
if (!((buf.length - i) % 2)) {
|
|
191
|
+
const r = buf.toString('utf16le', i);
|
|
192
|
+
|
|
193
|
+
if (r) {
|
|
194
|
+
const c = r.charCodeAt(r.length - 1);
|
|
195
|
+
|
|
196
|
+
if (c >= 55_296 && c <= 56_319) {
|
|
197
|
+
this.lastNeed = 2;
|
|
198
|
+
this.lastTotal = 4;
|
|
199
|
+
this.lastChar[0] = buf[buf.length - 2];
|
|
200
|
+
this.lastChar[1] = buf[buf.length - 1];
|
|
201
|
+
return r.slice(0, -1);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return r;
|
|
238
206
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
return buf.toString("utf16le", i, buf.length - 1);
|
|
207
|
+
|
|
208
|
+
this.lastNeed = 1;
|
|
209
|
+
this.lastTotal = 2;
|
|
210
|
+
this.lastChar[0] = buf[buf.length - 1];
|
|
211
|
+
return buf.toString('utf16le', i, buf.length - 1);
|
|
245
212
|
}
|
|
213
|
+
|
|
246
214
|
function utf16End(buf) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
215
|
+
const r = buf?.length ? this.write(buf) : '';
|
|
216
|
+
|
|
217
|
+
if (this.lastNeed) {
|
|
218
|
+
const end = this.lastTotal - this.lastNeed;
|
|
219
|
+
return r + this.lastChar.toString('utf16le', 0, end);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return r;
|
|
253
223
|
}
|
|
224
|
+
|
|
254
225
|
function base64Text(buf, i) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
this.
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
226
|
+
const n = (buf.length - i) % 3;
|
|
227
|
+
|
|
228
|
+
if (!n) {
|
|
229
|
+
return buf.toString('base64', i);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
this.lastNeed = 3 - n;
|
|
233
|
+
this.lastTotal = 3;
|
|
234
|
+
if (n === 1) {
|
|
235
|
+
this.lastChar[0] = buf[buf.length - 1];
|
|
236
|
+
} else {
|
|
237
|
+
this.lastChar[0] = buf[buf.length - 2];
|
|
238
|
+
this.lastChar[1] = buf[buf.length - 1];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return buf.toString('base64', i, buf.length - n);
|
|
268
242
|
}
|
|
243
|
+
|
|
269
244
|
function base64End(buf) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
245
|
+
const r = buf?.length ? this.write(buf) : '';
|
|
246
|
+
|
|
247
|
+
if (this.lastNeed) {
|
|
248
|
+
return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return r;
|
|
275
252
|
}
|
|
253
|
+
|
|
276
254
|
function simpleWrite(buf) {
|
|
277
|
-
|
|
255
|
+
return buf.toString(this.encoding);
|
|
278
256
|
}
|
|
257
|
+
|
|
279
258
|
function simpleEnd(buf) {
|
|
280
|
-
|
|
259
|
+
return buf?.length ? this.write(buf) : '';
|
|
281
260
|
}
|
package/dist-npm/utils/error.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {sep} from 'node:path';
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
|
|
2
4
|
export function parseStack(stack) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
const cwd = process.cwd() + sep;
|
|
6
|
+
|
|
7
|
+
return stack
|
|
8
|
+
.split('\n')
|
|
9
|
+
.splice(1)
|
|
10
|
+
.map((l) => l.trim().replace('file://', '').replace(cwd, ''));
|
|
6
11
|
}
|