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