js-dev-tool 1.2.10 → 1.2.11
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/extras/cc-map.d.ts +141 -0
- package/extras/cc-map.js +140 -0
- package/extras/jsonl.d.ts +8 -1
- package/extras/jsonl.js +227 -0
- package/extras/progress-light.d.ts +29 -0
- package/extras/progress-light.js +207 -0
- package/lib/unzip.min.js +3 -1
- package/lib/zip.min.js +1 -0
- package/package.json +1 -1
- package/progress/spinners.d.ts +1 -1
- package/tool-lib/rws.js +2 -3
- package/tsconfig.json +5 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
+
// Copyright (C) 2026 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
+
// Released under the MIT license
|
|
5
|
+
// https://opensource.org/licenses/mit-license.php
|
|
6
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @file extras/cc-map.d.ts
|
|
10
|
+
*/
|
|
11
|
+
export declare type TCC_MAP = {
|
|
12
|
+
/** `\u0001` */ NULL: 0;
|
|
13
|
+
/** `\u0001` */ SOH: 1;
|
|
14
|
+
/** `\u0002` */ STX: 2;
|
|
15
|
+
/** `\u0003` */ ETX: 3;
|
|
16
|
+
/** `\u0004` */ EOT: 4;
|
|
17
|
+
/** `\u0005` */ ENQ: 5;
|
|
18
|
+
/** `\u0006` */ ACK: 6;
|
|
19
|
+
/** `\u0007` */ BEL: 7;
|
|
20
|
+
/** `\u0008` */ BS: 8;
|
|
21
|
+
/** `\t` */ TAB: 9;
|
|
22
|
+
/** `\n` */ LF: 10;
|
|
23
|
+
/** `\u000b` */ VT: 11;
|
|
24
|
+
/** `\f` */ FF: 12;
|
|
25
|
+
/** `\r` */ CR: 13;
|
|
26
|
+
/** `\u000e` */ SO: 14;
|
|
27
|
+
/** `\u000f` */ SI: 15;
|
|
28
|
+
/** `\u0010` */ DLE: 16;
|
|
29
|
+
/** `\u0011` */ DC1: 17;
|
|
30
|
+
/** `\u0012` */ DC2: 18;
|
|
31
|
+
/** `\u0013` */ DC3: 19;
|
|
32
|
+
/** `\u0014` */ DC4: 20;
|
|
33
|
+
/** `\u0015` */ NAK: 21;
|
|
34
|
+
/** `\u0016` */ SYN: 22;
|
|
35
|
+
/** `\u0017` */ ETB: 23;
|
|
36
|
+
/** `\u0018` */ CAN: 24;
|
|
37
|
+
/** `\u0019` */ EM: 25;
|
|
38
|
+
/** `\u001a` */ SUB: 26;
|
|
39
|
+
/** `\u001b` */ ESC: 27;
|
|
40
|
+
/** `\u001c` */ FS: 28;
|
|
41
|
+
/** `\u001d` */ GS: 29;
|
|
42
|
+
/** `\u001e` */ RS: 30;
|
|
43
|
+
/** `\u001f` */ US: 31;
|
|
44
|
+
/** " " */ SPACE: 32;
|
|
45
|
+
/** `!` */ EXCLAMATION: 33;
|
|
46
|
+
/** `"` */ DOUBLE_QUOTE: 34;
|
|
47
|
+
/** `#` */ HASH: 35;
|
|
48
|
+
/** `$` */ DOLLAR: 36;
|
|
49
|
+
/** `%` */ PERCENT: 37;
|
|
50
|
+
/** `&` */ AMPERSAND: 38;
|
|
51
|
+
/** `'` */ SINGLE_QUOTE: 39;
|
|
52
|
+
/** `(` */ LEFT_PAREN: 40;
|
|
53
|
+
/** `)` */ RIGHT_PAREN: 41;
|
|
54
|
+
/** `*` */ ASTERISK: 42;
|
|
55
|
+
/** `+` */ PLUS: 43;
|
|
56
|
+
/** `,` */ COMMA: 44;
|
|
57
|
+
/** `-` */ MINUS: 45;
|
|
58
|
+
/** `.` */ PERIOD: 46;
|
|
59
|
+
/** `/` */ SLASH: 47;
|
|
60
|
+
/** `0` */ ZERO: 48;
|
|
61
|
+
/** `1` */ ONE: 49;
|
|
62
|
+
/** `2` */ TWO: 50;
|
|
63
|
+
/** `3` */ THREE: 51;
|
|
64
|
+
/** `4` */ FOUR: 52;
|
|
65
|
+
/** `5` */ FIVE: 53;
|
|
66
|
+
/** `6` */ SIX: 54;
|
|
67
|
+
/** `7` */ SEVEN: 55;
|
|
68
|
+
/** `8` */ EIGHT: 56;
|
|
69
|
+
/** `9` */ NINE: 57;
|
|
70
|
+
/** `:` */ COLON: 58;
|
|
71
|
+
/** `;` */ SEMICOLON: 59;
|
|
72
|
+
/** `<` */ LESS_THAN: 60;
|
|
73
|
+
/** `=` */ EQUAL: 61;
|
|
74
|
+
/** `>` */ GREATER_THAN: 62;
|
|
75
|
+
/** `?` */ QUESTION: 63;
|
|
76
|
+
/** `@` */ AT: 64;
|
|
77
|
+
/** `A` */ A: 65;
|
|
78
|
+
/** `B` */ B: 66;
|
|
79
|
+
/** `C` */ C: 67;
|
|
80
|
+
/** `D` */ D: 68;
|
|
81
|
+
/** `E` */ E: 69;
|
|
82
|
+
/** `F` */ F: 70;
|
|
83
|
+
/** `G` */ G: 71;
|
|
84
|
+
/** `H` */ H: 72;
|
|
85
|
+
/** `I` */ I: 73;
|
|
86
|
+
/** `J` */ J: 74;
|
|
87
|
+
/** `K` */ K: 75;
|
|
88
|
+
/** `L` */ L: 76;
|
|
89
|
+
/** `M` */ M: 77;
|
|
90
|
+
/** `N` */ N: 78;
|
|
91
|
+
/** `O` */ O: 79;
|
|
92
|
+
/** `P` */ P: 80;
|
|
93
|
+
/** `Q` */ Q: 81;
|
|
94
|
+
/** `R` */ R: 82;
|
|
95
|
+
/** `S` */ S: 83;
|
|
96
|
+
/** `T` */ T: 84;
|
|
97
|
+
/** `U` */ U: 85;
|
|
98
|
+
/** `V` */ V: 86;
|
|
99
|
+
/** `W` */ W: 87;
|
|
100
|
+
/** `X` */ X: 88;
|
|
101
|
+
/** `Y` */ Y: 89;
|
|
102
|
+
/** `Z` */ Z: 90;
|
|
103
|
+
/** `[` */ LEFT_BRACKET: 91;
|
|
104
|
+
/** `\` */ BACKSLASH: 92;
|
|
105
|
+
/** `]` */ RIGHT_BRACKET: 93;
|
|
106
|
+
/** "^" */ CARET: 94;
|
|
107
|
+
/** "_" */ UNDERSCORE: 95;
|
|
108
|
+
/** __`__ */ GRAVE: 96;
|
|
109
|
+
/** `a` */ a: 97;
|
|
110
|
+
/** `b` */ b: 98;
|
|
111
|
+
/** `c` */ c: 99;
|
|
112
|
+
/** `d` */ d: 100;
|
|
113
|
+
/** `e` */ e: 101;
|
|
114
|
+
/** `f` */ f: 102;
|
|
115
|
+
/** `g` */ g: 103;
|
|
116
|
+
/** `h` */ h: 104;
|
|
117
|
+
/** `i` */ i: 105;
|
|
118
|
+
/** `j` */ j: 106;
|
|
119
|
+
/** `k` */ k: 107;
|
|
120
|
+
/** `l` */ l: 108;
|
|
121
|
+
/** `m` */ m: 109;
|
|
122
|
+
/** `n` */ n: 110;
|
|
123
|
+
/** `o` */ o: 111;
|
|
124
|
+
/** `p` */ p: 112;
|
|
125
|
+
/** `q` */ q: 113;
|
|
126
|
+
/** `r` */ r: 114;
|
|
127
|
+
/** `s` */ s: 115;
|
|
128
|
+
/** `t` */ t: 116;
|
|
129
|
+
/** `u` */ u: 117;
|
|
130
|
+
/** `v` */ v: 118;
|
|
131
|
+
/** `w` */ w: 119;
|
|
132
|
+
/** `x` */ x: 120;
|
|
133
|
+
/** `y` */ y: 121;
|
|
134
|
+
/** `z` */ z: 122;
|
|
135
|
+
/** `{` */ LEFT_BRACE: 123;
|
|
136
|
+
/** `|` */ PIPE: 124;
|
|
137
|
+
/** `}` */ RIGHT_BRACE: 125;
|
|
138
|
+
/** `~` */ TILDE: 126;
|
|
139
|
+
};
|
|
140
|
+
declare const CC_MAP: TCC_MAP;
|
|
141
|
+
export = CC_MAP;
|
package/extras/cc-map.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
+
// Copyright (C) 2026 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
+
// Released under the MIT license
|
|
5
|
+
// https://opensource.org/licenses/mit-license.php
|
|
6
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @file extras/cc-map.js
|
|
10
|
+
* @import { TCC_MAP } from "./cc-map";
|
|
11
|
+
*/
|
|
12
|
+
module.exports = /** @type {TCC_MAP} */({
|
|
13
|
+
/** `\u0001` */ NULL: 0,
|
|
14
|
+
/** `\u0001` */ SOH: 1,
|
|
15
|
+
/** `\u0002` */ STX: 2,
|
|
16
|
+
/** `\u0003` */ ETX: 3,
|
|
17
|
+
/** `\u0004` */ EOT: 4,
|
|
18
|
+
/** `\u0005` */ ENQ: 5,
|
|
19
|
+
/** `\u0006` */ ACK: 6,
|
|
20
|
+
/** `\u0007` */ BEL: 7,
|
|
21
|
+
/** `\u0008` */ BS: 8,
|
|
22
|
+
/** `\t` */ TAB: 9,
|
|
23
|
+
/** `\n` */ LF: 10,
|
|
24
|
+
/** `\u000b` */ VT: 11,
|
|
25
|
+
/** `\f` */ FF: 12,
|
|
26
|
+
/** `\r` */ CR: 13,
|
|
27
|
+
/** `\u000e` */ SO: 14,
|
|
28
|
+
/** `\u000f` */ SI: 15,
|
|
29
|
+
/** `\u0010` */ DLE: 16,
|
|
30
|
+
/** `\u0011` */ DC1: 17,
|
|
31
|
+
/** `\u0012` */ DC2: 18,
|
|
32
|
+
/** `\u0013` */ DC3: 19,
|
|
33
|
+
/** `\u0014` */ DC4: 20,
|
|
34
|
+
/** `\u0015` */ NAK: 21,
|
|
35
|
+
/** `\u0016` */ SYN: 22,
|
|
36
|
+
/** `\u0017` */ ETB: 23,
|
|
37
|
+
/** `\u0018` */ CAN: 24,
|
|
38
|
+
/** `\u0019` */ EM: 25,
|
|
39
|
+
/** `\u001a` */ SUB: 26,
|
|
40
|
+
/** `\u001b` */ ESC: 27,
|
|
41
|
+
/** `\u001c` */ FS: 28,
|
|
42
|
+
/** `\u001d` */ GS: 29,
|
|
43
|
+
/** `\u001e` */ RS: 30,
|
|
44
|
+
/** `\u001f` */ US: 31,
|
|
45
|
+
/** " " */ SPACE: 32,
|
|
46
|
+
/** `!` */ EXCLAMATION: 33,
|
|
47
|
+
/** `"` */ DOUBLE_QUOTE: 34,
|
|
48
|
+
/** `#` */ HASH: 35,
|
|
49
|
+
/** `$` */ DOLLAR: 36,
|
|
50
|
+
/** `%` */ PERCENT: 37,
|
|
51
|
+
/** `&` */ AMPERSAND: 38,
|
|
52
|
+
/** `'` */ SINGLE_QUOTE: 39,
|
|
53
|
+
/** `(` */ LEFT_PAREN: 40,
|
|
54
|
+
/** `)` */ RIGHT_PAREN: 41,
|
|
55
|
+
/** `*` */ ASTERISK: 42,
|
|
56
|
+
/** `+` */ PLUS: 43,
|
|
57
|
+
/** `,` */ COMMA: 44,
|
|
58
|
+
/** `-` */ MINUS: 45,
|
|
59
|
+
/** `.` */ PERIOD: 46,
|
|
60
|
+
/** `/` */ SLASH: 47,
|
|
61
|
+
/** `0` */ ZERO: 48,
|
|
62
|
+
/** `1` */ ONE: 49,
|
|
63
|
+
/** `2` */ TWO: 50,
|
|
64
|
+
/** `3` */ THREE: 51,
|
|
65
|
+
/** `4` */ FOUR: 52,
|
|
66
|
+
/** `5` */ FIVE: 53,
|
|
67
|
+
/** `6` */ SIX: 54,
|
|
68
|
+
/** `7` */ SEVEN: 55,
|
|
69
|
+
/** `8` */ EIGHT: 56,
|
|
70
|
+
/** `9` */ NINE: 57,
|
|
71
|
+
/** `:` */ COLON: 58,
|
|
72
|
+
/** `;` */ SEMICOLON: 59,
|
|
73
|
+
/** `<` */ LESS_THAN: 60,
|
|
74
|
+
/** `=` */ EQUAL: 61,
|
|
75
|
+
/** `>` */ GREATER_THAN: 62,
|
|
76
|
+
/** `?` */ QUESTION: 63,
|
|
77
|
+
/** `@` */ AT: 64,
|
|
78
|
+
/** `A` */ A: 65,
|
|
79
|
+
/** `B` */ B: 66,
|
|
80
|
+
/** `C` */ C: 67,
|
|
81
|
+
/** `D` */ D: 68,
|
|
82
|
+
/** `E` */ E: 69,
|
|
83
|
+
/** `F` */ F: 70,
|
|
84
|
+
/** `G` */ G: 71,
|
|
85
|
+
/** `H` */ H: 72,
|
|
86
|
+
/** `I` */ I: 73,
|
|
87
|
+
/** `J` */ J: 74,
|
|
88
|
+
/** `K` */ K: 75,
|
|
89
|
+
/** `L` */ L: 76,
|
|
90
|
+
/** `M` */ M: 77,
|
|
91
|
+
/** `N` */ N: 78,
|
|
92
|
+
/** `O` */ O: 79,
|
|
93
|
+
/** `P` */ P: 80,
|
|
94
|
+
/** `Q` */ Q: 81,
|
|
95
|
+
/** `R` */ R: 82,
|
|
96
|
+
/** `S` */ S: 83,
|
|
97
|
+
/** `T` */ T: 84,
|
|
98
|
+
/** `U` */ U: 85,
|
|
99
|
+
/** `V` */ V: 86,
|
|
100
|
+
/** `W` */ W: 87,
|
|
101
|
+
/** `X` */ X: 88,
|
|
102
|
+
/** `Y` */ Y: 89,
|
|
103
|
+
/** `Z` */ Z: 90,
|
|
104
|
+
/** `[` */ LEFT_BRACKET: 91,
|
|
105
|
+
/** `\` */ BACKSLASH: 92,
|
|
106
|
+
/** `]` */ RIGHT_BRACKET: 93,
|
|
107
|
+
/** "^" */ CARET: 94,
|
|
108
|
+
/** "_" */ UNDERSCORE: 95,
|
|
109
|
+
/** __`__ */ GRAVE: 96,
|
|
110
|
+
/** `a` */ a: 97,
|
|
111
|
+
/** `b` */ b: 98,
|
|
112
|
+
/** `c` */ c: 99,
|
|
113
|
+
/** `d` */ d: 100,
|
|
114
|
+
/** `e` */ e: 101,
|
|
115
|
+
/** `f` */ f: 102,
|
|
116
|
+
/** `g` */ g: 103,
|
|
117
|
+
/** `h` */ h: 104,
|
|
118
|
+
/** `i` */ i: 105,
|
|
119
|
+
/** `j` */ j: 106,
|
|
120
|
+
/** `k` */ k: 107,
|
|
121
|
+
/** `l` */ l: 108,
|
|
122
|
+
/** `m` */ m: 109,
|
|
123
|
+
/** `n` */ n: 110,
|
|
124
|
+
/** `o` */ o: 111,
|
|
125
|
+
/** `p` */ p: 112,
|
|
126
|
+
/** `q` */ q: 113,
|
|
127
|
+
/** `r` */ r: 114,
|
|
128
|
+
/** `s` */ s: 115,
|
|
129
|
+
/** `t` */ t: 116,
|
|
130
|
+
/** `u` */ u: 117,
|
|
131
|
+
/** `v` */ v: 118,
|
|
132
|
+
/** `w` */ w: 119,
|
|
133
|
+
/** `x` */ x: 120,
|
|
134
|
+
/** `y` */ y: 121,
|
|
135
|
+
/** `z` */ z: 122,
|
|
136
|
+
/** `{` */ LEFT_BRACE: 123,
|
|
137
|
+
/** `|` */ PIPE: 124,
|
|
138
|
+
/** `}` */ RIGHT_BRACE: 125,
|
|
139
|
+
/** `~` */ TILDE: 126,
|
|
140
|
+
});
|
package/extras/jsonl.d.ts
CHANGED
|
@@ -113,4 +113,11 @@ export function readJsonlMapByKey<TRow = any, TOut = TRow>(fileName: string, opt
|
|
|
113
113
|
*
|
|
114
114
|
* Intended for performance-sensitive hot paths where full `JSON.parse` is unnecessary.
|
|
115
115
|
*/
|
|
116
|
-
export function fastGetIntFieldCheap(line: string, key: string): number | undefined;
|
|
116
|
+
export function fastGetIntFieldCheap(line: string, key: string): number | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* Minify JSON or JSONL text by removing JSON whitespace outside strings.
|
|
119
|
+
*
|
|
120
|
+
* - A single top-level value is returned as minified JSON.
|
|
121
|
+
* - Multiple top-level values are returned as minified JSONL separated by `"\n"`.
|
|
122
|
+
*/
|
|
123
|
+
export function jsonMinify(source: string): string;
|
package/extras/jsonl.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
const fs = require("fs");
|
|
13
13
|
const path = require("path");
|
|
14
|
+
const ccMap = require("./cc-map");
|
|
14
15
|
/**
|
|
15
16
|
* @import { TJsonlReadOption, TJsonlReadBaseOption } from "./jsonl.js";
|
|
16
17
|
*/
|
|
@@ -71,6 +72,231 @@ function fastGetIntFieldCheap(line, key) {
|
|
|
71
72
|
}
|
|
72
73
|
return ok ? sign * n : undefined;
|
|
73
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* @typedef {{ src: string }} TJsonSourceEnvelop
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
* Minify JSON or JSONL text by removing JSON whitespace outside double-quoted strings.
|
|
80
|
+
*
|
|
81
|
+
* - A single top-level value is returned as minified JSON.
|
|
82
|
+
* - Multiple top-level values are returned as minified JSONL separated by `"\n"`.
|
|
83
|
+
*
|
|
84
|
+
* @param {string} source
|
|
85
|
+
* @returns {string}
|
|
86
|
+
*/
|
|
87
|
+
function jsonMinify(source) {
|
|
88
|
+
if (typeof source !== "string") {
|
|
89
|
+
throw new TypeError("jsonMinify(source): source must be a string");
|
|
90
|
+
}
|
|
91
|
+
/** @type {TJsonSourceEnvelop} */
|
|
92
|
+
const out = { src: "" };
|
|
93
|
+
const sourceLen = source.length;
|
|
94
|
+
let offset = 0;
|
|
95
|
+
let count = 0;
|
|
96
|
+
while (true) {
|
|
97
|
+
const next = skipWhitespaces(source, offset);
|
|
98
|
+
if (next >= sourceLen) {
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
if (count > 0) {
|
|
102
|
+
if (next === offset) {
|
|
103
|
+
throwJsonSyntaxError("Missing whitespace between top-level JSON values", next);
|
|
104
|
+
}
|
|
105
|
+
out.src += "\n";
|
|
106
|
+
}
|
|
107
|
+
offset = scanJsonValue(source, next, out);
|
|
108
|
+
count++;
|
|
109
|
+
}
|
|
110
|
+
return out.src;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* @param {string} source
|
|
114
|
+
* @param {number} offset
|
|
115
|
+
* @param {TJsonSourceEnvelop} out
|
|
116
|
+
* @returns {number}
|
|
117
|
+
*/
|
|
118
|
+
function scanJsonValue(source, offset, out) {
|
|
119
|
+
offset = skipWhitespaces(source, offset);
|
|
120
|
+
if (offset >= source.length) {
|
|
121
|
+
throwJsonSyntaxError("Unexpected end of JSON input", offset);
|
|
122
|
+
}
|
|
123
|
+
switch (source[offset]) {
|
|
124
|
+
case "\"": {
|
|
125
|
+
const next = skipQuotedString(source, offset);
|
|
126
|
+
out.src += source.slice(offset, next);
|
|
127
|
+
return next;
|
|
128
|
+
}
|
|
129
|
+
case "{": return scanJsonObject(source, offset, out);
|
|
130
|
+
case "[": return scanJsonArray(source, offset, out);
|
|
131
|
+
default: {
|
|
132
|
+
const next = skipOthers(source, offset);
|
|
133
|
+
out.src += source.slice(offset, next);
|
|
134
|
+
return next;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* @param {string} source
|
|
140
|
+
* @param {number} offset
|
|
141
|
+
* @param {TJsonSourceEnvelop} out
|
|
142
|
+
* @returns {number}
|
|
143
|
+
* @throws {SyntaxError}
|
|
144
|
+
*/
|
|
145
|
+
function scanJsonObject(source, offset, out) {
|
|
146
|
+
out.src += "{";
|
|
147
|
+
offset = skipWhitespaces(source, offset + 1);
|
|
148
|
+
if (offset >= source.length) {
|
|
149
|
+
throwJsonSyntaxError("Unterminated JSON object", offset);
|
|
150
|
+
}
|
|
151
|
+
if (source[offset] === "}") {
|
|
152
|
+
out.src += "}";
|
|
153
|
+
return offset + 1;
|
|
154
|
+
}
|
|
155
|
+
while (offset < source.length) {
|
|
156
|
+
if (source.charCodeAt(offset) !== ccMap.DOUBLE_QUOTE) {
|
|
157
|
+
throwJsonSyntaxError("JSON object key must start with a double quote", offset);
|
|
158
|
+
}
|
|
159
|
+
const keyEnd = skipQuotedString(source, offset);
|
|
160
|
+
out.src += source.slice(offset, keyEnd);
|
|
161
|
+
offset = skipWhitespaces(source, keyEnd);
|
|
162
|
+
if (source[offset] !== ":") {
|
|
163
|
+
throwJsonSyntaxError("Missing colon after JSON object key", offset);
|
|
164
|
+
}
|
|
165
|
+
out.src += ":";
|
|
166
|
+
offset = scanJsonValue(source, offset + 1, out);
|
|
167
|
+
offset = skipWhitespaces(source, offset);
|
|
168
|
+
if (offset >= source.length) {
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
const ch = source[offset];
|
|
172
|
+
if (ch === ",") {
|
|
173
|
+
out.src += ",";
|
|
174
|
+
offset = skipWhitespaces(source, offset + 1);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (ch === "}") {
|
|
178
|
+
out.src += "}";
|
|
179
|
+
return offset + 1;
|
|
180
|
+
}
|
|
181
|
+
throwJsonSyntaxError("Unexpected token in JSON object", offset);
|
|
182
|
+
}
|
|
183
|
+
throwJsonSyntaxError("Unterminated JSON object", offset);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* @param {string} source
|
|
187
|
+
* @param {number} offset
|
|
188
|
+
* @param {TJsonSourceEnvelop} out
|
|
189
|
+
* @returns {number}
|
|
190
|
+
*/
|
|
191
|
+
function scanJsonArray(source, offset, out) {
|
|
192
|
+
out.src += "[";
|
|
193
|
+
offset = skipWhitespaces(source, offset + 1);
|
|
194
|
+
if (offset >= source.length) {
|
|
195
|
+
throwJsonSyntaxError("Unterminated JSON array", offset);
|
|
196
|
+
}
|
|
197
|
+
if (source[offset] === "]") {
|
|
198
|
+
out.src += "]";
|
|
199
|
+
return offset + 1;
|
|
200
|
+
}
|
|
201
|
+
while (offset < source.length) {
|
|
202
|
+
offset = scanJsonValue(source, offset, out);
|
|
203
|
+
offset = skipWhitespaces(source, offset);
|
|
204
|
+
if (offset >= source.length) {
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
const ch = source[offset];
|
|
208
|
+
if (ch === ",") {
|
|
209
|
+
out.src += ",";
|
|
210
|
+
offset = skipWhitespaces(source, offset + 1);
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (ch === "]") {
|
|
214
|
+
out.src += "]";
|
|
215
|
+
return offset + 1;
|
|
216
|
+
}
|
|
217
|
+
throwJsonSyntaxError("Unexpected token in JSON array", offset);
|
|
218
|
+
}
|
|
219
|
+
throwJsonSyntaxError("Unterminated JSON array", offset);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* @param {string} source
|
|
223
|
+
* @param {number} offset
|
|
224
|
+
* @returns {number}
|
|
225
|
+
*/
|
|
226
|
+
function skipOthers(source, offset) {
|
|
227
|
+
const sourceLen = source.length;
|
|
228
|
+
let next = offset;
|
|
229
|
+
while (next < sourceLen) {
|
|
230
|
+
const code = source.charCodeAt(next++);
|
|
231
|
+
if (
|
|
232
|
+
isWhitespaceCode(code) ||
|
|
233
|
+
code === ccMap.COMMA ||
|
|
234
|
+
code === ccMap.COLON ||
|
|
235
|
+
code === ccMap.LEFT_BRACKET ||
|
|
236
|
+
code === ccMap.RIGHT_BRACKET ||
|
|
237
|
+
code === ccMap.LEFT_BRACE ||
|
|
238
|
+
code === ccMap.RIGHT_BRACE ||
|
|
239
|
+
code === ccMap.DOUBLE_QUOTE
|
|
240
|
+
) {
|
|
241
|
+
next -= 1;
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (next === offset) throwJsonSyntaxError("Invalid JSON primitive", offset);
|
|
246
|
+
return next;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Scan a JSON double-quoted string and return the next offset.
|
|
250
|
+
*
|
|
251
|
+
* @param {string} source
|
|
252
|
+
* @param {number} offset
|
|
253
|
+
* @returns {number}
|
|
254
|
+
*/
|
|
255
|
+
function skipQuotedString(source, offset) {
|
|
256
|
+
const srcLen = source.length;
|
|
257
|
+
let next = offset + 1;
|
|
258
|
+
let inEscape = false;
|
|
259
|
+
while (next < srcLen) {
|
|
260
|
+
const ch = source[next++];
|
|
261
|
+
if (ch === "\\") {
|
|
262
|
+
inEscape = !inEscape;
|
|
263
|
+
} else if (inEscape) {
|
|
264
|
+
inEscape = false;
|
|
265
|
+
} else if (ch === "\"") {
|
|
266
|
+
return next;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
throwJsonSyntaxError("Incomplete JSON string", offset);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* @param {number} code
|
|
273
|
+
* @returns {boolean}
|
|
274
|
+
*/
|
|
275
|
+
const isWhitespaceCode = (code) => code === ccMap.SPACE || code === ccMap.TAB || code === ccMap.LF || code === ccMap.CR;
|
|
276
|
+
/**
|
|
277
|
+
* @param {string} source
|
|
278
|
+
* @param {number} offset
|
|
279
|
+
* @returns {number}
|
|
280
|
+
*/
|
|
281
|
+
const skipWhitespaces = (source, offset) => {
|
|
282
|
+
const srcLen = source.length;
|
|
283
|
+
while (offset < srcLen) {
|
|
284
|
+
if (!isWhitespaceCode(source.charCodeAt(offset++))) {
|
|
285
|
+
offset -= 1;
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return offset;
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* @param {string} message
|
|
293
|
+
* @param {number} offset
|
|
294
|
+
* @returns {never}
|
|
295
|
+
* @throws {SyntaxError}
|
|
296
|
+
*/
|
|
297
|
+
const throwJsonSyntaxError = (message, offset) => {
|
|
298
|
+
throw new SyntaxError(`${message}, offset=${offset}`);
|
|
299
|
+
};
|
|
74
300
|
const HIGHWATERMARK_MIN = 128;
|
|
75
301
|
/**
|
|
76
302
|
* @param {unknown} n
|
|
@@ -201,4 +427,5 @@ module.exports = {
|
|
|
201
427
|
readJsonlArray,
|
|
202
428
|
readJsonlMapByKey,
|
|
203
429
|
fastGetIntFieldCheap,
|
|
430
|
+
jsonMinify,
|
|
204
431
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
+
// Copyright (C) 2026 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
+
// Released under the MIT license
|
|
5
|
+
// https://opensource.org/licenses/mit-license.php
|
|
6
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @file progress-light.d.ts
|
|
10
|
+
*/
|
|
11
|
+
export type ProgressFormatOptions = {
|
|
12
|
+
fmt: string;
|
|
13
|
+
payload?: Record<string, string>;
|
|
14
|
+
};
|
|
15
|
+
export type TProgressLight = {
|
|
16
|
+
updateOptions(newFrames?: string[], newOpt?: ProgressFormatOptions): void;
|
|
17
|
+
deadline(): void;
|
|
18
|
+
newLine(): void;
|
|
19
|
+
setFPS(fps: number): void;
|
|
20
|
+
renderSync(): void;
|
|
21
|
+
run(): void;
|
|
22
|
+
stop(): void;
|
|
23
|
+
isRunning(): boolean;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @param {number} [fps]
|
|
27
|
+
* @param {() => string} [messageEmitter]
|
|
28
|
+
*/
|
|
29
|
+
export function create(fps?: number, messageEmitter?: () => string): TProgressLight;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
+
Copyright (C) 2026 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
+
Released under the MIT license
|
|
5
|
+
https://opensource.org/licenses/mit-license.php
|
|
6
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
+
*/
|
|
8
|
+
"use strict";
|
|
9
|
+
/**
|
|
10
|
+
* [usage]
|
|
11
|
+
* > node -i
|
|
12
|
+
* let t = require("./extras/progress-light");
|
|
13
|
+
* let p = t.create();
|
|
14
|
+
* p.run();
|
|
15
|
+
* p.stop();
|
|
16
|
+
*/
|
|
17
|
+
const rl = require("readline");
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {{ fmt: string, payload?: Record<string, string> }} ProgressFormatOptions
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {{
|
|
23
|
+
* updateOptions(newFrames?: string[], newOpt?: ProgressFormatOptions): void;
|
|
24
|
+
* deadline(): void;
|
|
25
|
+
* newLine(): void;
|
|
26
|
+
* setFPS(fps: number): void;
|
|
27
|
+
* renderSync(): void;
|
|
28
|
+
* run(): void;
|
|
29
|
+
* stop(): void;
|
|
30
|
+
* isRunning(): boolean;
|
|
31
|
+
* }} TProgressLight
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* @param {boolean} enabled
|
|
35
|
+
* @param {NodeJS.WriteStream} [output]
|
|
36
|
+
*/
|
|
37
|
+
const cursor = (enabled, output = process.stderr) => {
|
|
38
|
+
if (enabled) {
|
|
39
|
+
output.write("\x1B[?25h");
|
|
40
|
+
} else {
|
|
41
|
+
output.write("\x1B[?25l");
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* @param {string=} msg
|
|
46
|
+
* @param {number=} row
|
|
47
|
+
*/
|
|
48
|
+
const renderLine = (msg, row) => {
|
|
49
|
+
const output = process.stderr || process.stdout;
|
|
50
|
+
rl.cursorTo(output, 0, row);
|
|
51
|
+
msg && (output.write(msg), rl.clearLine(output, 1));
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* @param {string[]} frames
|
|
55
|
+
* @param {ProgressFormatOptions} [formatOpt]
|
|
56
|
+
*/
|
|
57
|
+
const createProgressSync = (frames, formatOpt) => {
|
|
58
|
+
const fsize = frames.length;
|
|
59
|
+
let index = 0;
|
|
60
|
+
/** @type {string | undefined} */
|
|
61
|
+
let fmt;
|
|
62
|
+
/** @type {Record<string, string>} */
|
|
63
|
+
let payload = {};
|
|
64
|
+
/** @type {string[]} */
|
|
65
|
+
let keys = [];
|
|
66
|
+
if (formatOpt) {
|
|
67
|
+
fmt = formatOpt.fmt;
|
|
68
|
+
payload = formatOpt.payload || {};
|
|
69
|
+
keys = Object.keys(payload);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @param {string} tick
|
|
73
|
+
* @param {string} msg
|
|
74
|
+
*/
|
|
75
|
+
const formatter = (tick, msg) => {
|
|
76
|
+
if (fmt) {
|
|
77
|
+
let content = fmt;
|
|
78
|
+
for (let i = 0, end = keys.length; i < end; ) {
|
|
79
|
+
const key = keys[i++];
|
|
80
|
+
content = content.replace("{" + key + "}", payload[key]);
|
|
81
|
+
}
|
|
82
|
+
return content.replace("{tick}", tick).replace("{msg}", msg);
|
|
83
|
+
}
|
|
84
|
+
return `[${tick}]: ${msg}`;
|
|
85
|
+
};
|
|
86
|
+
return /** @type {(msg: string, done?: boolean) => void} */ ((msg, done = false) => {
|
|
87
|
+
const tick = done ? "-done-" : frames[index++ % fsize];
|
|
88
|
+
const line = msg ? formatter(tick, msg) : "";
|
|
89
|
+
renderLine(line);
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* @param {string[]} frames
|
|
94
|
+
* @param {ProgressFormatOptions} formatOpt
|
|
95
|
+
* @param {() => string} messageEmitter
|
|
96
|
+
* @returns {TProgressLight}
|
|
97
|
+
*/
|
|
98
|
+
const createProgressObject = (frames, formatOpt, messageEmitter) => {
|
|
99
|
+
let done = false;
|
|
100
|
+
const render = () => {
|
|
101
|
+
progress(messageEmitter(), done);
|
|
102
|
+
};
|
|
103
|
+
let progress = createProgressSync(frames, formatOpt);
|
|
104
|
+
/** @type {ReturnType<typeof setInterval> | undefined} */
|
|
105
|
+
let timer;
|
|
106
|
+
let ms = 33;
|
|
107
|
+
return {
|
|
108
|
+
updateOptions(newFrames, newOpt) {
|
|
109
|
+
if (Array.isArray(newFrames) && typeof newFrames[0] === "string") {
|
|
110
|
+
frames = newFrames;
|
|
111
|
+
}
|
|
112
|
+
if (typeof newOpt === "object" && newOpt && newOpt.fmt) {
|
|
113
|
+
formatOpt = newOpt;
|
|
114
|
+
}
|
|
115
|
+
done = false;
|
|
116
|
+
progress = createProgressSync(frames, formatOpt);
|
|
117
|
+
},
|
|
118
|
+
deadline() {
|
|
119
|
+
(done = true), render();
|
|
120
|
+
},
|
|
121
|
+
newLine() {
|
|
122
|
+
console.log();
|
|
123
|
+
},
|
|
124
|
+
setFPS(fps) {
|
|
125
|
+
ms = (1000 / fps) | 0;
|
|
126
|
+
if (timer) {
|
|
127
|
+
clearInterval(timer);
|
|
128
|
+
timer = setInterval(render, ms);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
renderSync() {
|
|
132
|
+
progress(messageEmitter(), done);
|
|
133
|
+
},
|
|
134
|
+
run() {
|
|
135
|
+
cursor(false);
|
|
136
|
+
done = false;
|
|
137
|
+
if (timer) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
timer = setInterval(render, ms);
|
|
141
|
+
},
|
|
142
|
+
stop() {
|
|
143
|
+
done = true;
|
|
144
|
+
clearInterval(timer);
|
|
145
|
+
timer = void 0;
|
|
146
|
+
cursor(true);
|
|
147
|
+
},
|
|
148
|
+
isRunning() {
|
|
149
|
+
return !!timer;
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
let fired = 0;
|
|
154
|
+
let pending = 0;
|
|
155
|
+
/** @type {() => { fired: number; pending: number; errors?: number; }} */
|
|
156
|
+
const cb = () => {
|
|
157
|
+
return {
|
|
158
|
+
fired: ++fired,
|
|
159
|
+
pending: ++pending,
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
let tag = "progress test";
|
|
163
|
+
/**
|
|
164
|
+
* progress callback
|
|
165
|
+
* @type {() => string}
|
|
166
|
+
*/
|
|
167
|
+
const pcb = () => {
|
|
168
|
+
if (cb) {
|
|
169
|
+
const { fired, pending, errors } = cb();
|
|
170
|
+
return `${tag} | error: ${(errors + "").padEnd(3)} | send: ${(fired + "").padStart(3)}, pending: ${(pending + "").padEnd(5)}`;
|
|
171
|
+
} else {
|
|
172
|
+
return "- - error - -";
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* @param {number} [fps]
|
|
177
|
+
* @param {() => string} [messageEmitter]
|
|
178
|
+
* @returns {TProgressLight}
|
|
179
|
+
*/
|
|
180
|
+
const create = (fps = 30, messageEmitter) => {
|
|
181
|
+
const frames = [
|
|
182
|
+
"⠋",
|
|
183
|
+
"⠙",
|
|
184
|
+
"⠹",
|
|
185
|
+
"⠸",
|
|
186
|
+
"⠼",
|
|
187
|
+
"⠴",
|
|
188
|
+
"⠦",
|
|
189
|
+
"⠧",
|
|
190
|
+
"⠇",
|
|
191
|
+
"⠏",
|
|
192
|
+
];
|
|
193
|
+
!messageEmitter && (messageEmitter = pcb);
|
|
194
|
+
/** @type {TProgressLight} */
|
|
195
|
+
const progress = createProgressObject(
|
|
196
|
+
frames, {
|
|
197
|
+
fmt: "{tick} - {msg}",
|
|
198
|
+
payload: {},
|
|
199
|
+
},
|
|
200
|
+
messageEmitter,
|
|
201
|
+
);
|
|
202
|
+
progress.setFPS(fps);
|
|
203
|
+
return progress;
|
|
204
|
+
};
|
|
205
|
+
module.exports = {
|
|
206
|
+
create,
|
|
207
|
+
};
|
package/lib/unzip.min.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
/*! @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */ /*! (C) 2022 jeffy-g https://github.com/jeffy-g Released under the MIT license https://opensource.org/licenses/mit-license.php */
|
|
1
|
+
/*! @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */ /*! (C) 2022 jeffy-g https://github.com/jeffy-g Released under the MIT license https://opensource.org/licenses/mit-license.php */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
(function () {
|
|
2
4
|
var m,
|
|
3
5
|
aa = this;
|
|
4
6
|
Math.floor(2147483648 * Math.random()).toString(36);
|
package/lib/zip.min.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/*! @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */
|
|
2
2
|
/*! Copyright (C) 2018 jeffy-g <hirotom1107@gmail.com> Released under the MIT license https://opensource.org/licenses/mit-license.php */
|
|
3
|
+
// @ts-nocheck
|
|
3
4
|
(function () {
|
|
4
5
|
"use strict";
|
|
5
6
|
var n = void 0,
|
package/package.json
CHANGED
package/progress/spinners.d.ts
CHANGED
package/tool-lib/rws.js
CHANGED
|
@@ -151,9 +151,8 @@ module.exports = (fs, utils) => {
|
|
|
151
151
|
msg = `${this.taskName}: webpack size record created: [%s]`;
|
|
152
152
|
}
|
|
153
153
|
if (needWrite) {
|
|
154
|
-
utils.
|
|
155
|
-
|
|
156
|
-
recordPath,
|
|
154
|
+
utils.writeJson(
|
|
155
|
+
sizeRecord, recordPath,
|
|
157
156
|
() => {
|
|
158
157
|
console.log(msg, recordPath, entry);
|
|
159
158
|
},
|
package/tsconfig.json
CHANGED
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"module": "nodenext",
|
|
16
16
|
"outDir": "./dts",
|
|
17
17
|
// "baseUrl": ".",
|
|
18
|
+
"types": [
|
|
19
|
+
"node"
|
|
20
|
+
],
|
|
18
21
|
"rootDir": ".",
|
|
19
22
|
"paths": {
|
|
20
23
|
"*": [
|
|
@@ -32,5 +35,7 @@
|
|
|
32
35
|
],
|
|
33
36
|
"exclude": [
|
|
34
37
|
"./**/npm-outdated*.js",
|
|
38
|
+
"./scripts/*.js",
|
|
39
|
+
"./lib/*.js",
|
|
35
40
|
]
|
|
36
41
|
}
|