keycloakify 11.6.2 → 11.7.0
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/bin/{735.index.js → 288.index.js} +226 -360
- package/bin/313.index.js +377 -0
- package/bin/{174.index.js → 33.index.js} +37 -2
- package/bin/{840.index.js → 355.index.js} +348 -97
- package/bin/363.index.js +153 -144
- package/bin/453.index.js +5 -41
- package/bin/{503.index.js → 678.index.js} +577 -53
- package/bin/{921.index.js → 780.index.js} +54 -45
- package/bin/880.index.js +206 -21
- package/bin/9.index.js +850 -0
- package/bin/{525.index.js → 911.index.js} +1302 -2
- package/bin/930.index.js +3 -4
- package/bin/{153.index.js → 947.index.js} +22 -797
- package/bin/main.js +6 -6
- package/bin/shared/initializeSpa/index.d.ts +1 -0
- package/bin/shared/initializeSpa/initializeSpa.d.ts +9 -0
- package/bin/tools/getInstalledModuleDirPath.d.ts +0 -1
- package/bin/tools/isRootPath.d.ts +1 -0
- package/bin/tools/listInstalledModules.d.ts +0 -1
- package/package.json +22 -44
- package/src/bin/eject-page.ts +7 -81
- package/src/bin/initialize-account-theme/initialize-account-theme.ts +15 -14
- package/src/bin/initialize-admin-theme.ts +17 -124
- package/src/bin/initialize-email-theme.ts +10 -34
- package/src/bin/keycloakify/generateResources/generateResources.ts +49 -21
- package/src/bin/own.ts +1 -2
- package/src/bin/shared/{addSyncExtensionsToPostinstallScript.ts → initializeSpa/addSyncExtensionsToPostinstallScript.ts} +2 -2
- package/src/bin/shared/initializeSpa/index.ts +1 -0
- package/src/bin/shared/initializeSpa/initializeSpa.ts +149 -0
- package/src/bin/sync-extensions/extensionModuleMeta.ts +0 -1
- package/src/bin/tools/getInstalledModuleDirPath.ts +24 -22
- package/src/bin/tools/isRootPath.ts +22 -0
- package/src/bin/tools/listInstalledModules.ts +2 -4
- package/src/bin/tsconfig.json +1 -1
- package/bin/375.index.js +0 -4089
- package/bin/490.index.js +0 -1108
- package/bin/568.index.js +0 -1867
- package/bin/743.index.js +0 -69
- package/bin/initialize-account-theme/copyBoilerplate.d.ts +0 -4
- package/bin/initialize-account-theme/initializeAccountTheme_multiPage.d.ts +0 -3
- package/bin/initialize-account-theme/initializeAccountTheme_singlePage.d.ts +0 -11
- package/bin/shared/getLatestsSemVersionedTag.d.ts +0 -15
- package/bin/shared/promptKeycloakVersion.d.ts +0 -10
- package/bin/tools/OptionalIfCanBeUndefined.d.ts +0 -14
- package/bin/tools/crc32.d.ts +0 -9
- package/bin/tools/deflate.d.ts +0 -24
- package/bin/tools/octokit-addons/getLatestsSemVersionedTag.d.ts +0 -15
- package/bin/tools/octokit-addons/listTags.d.ts +0 -13
- package/bin/tools/tee.d.ts +0 -3
- package/bin/tools/trimIndent.d.ts +0 -5
- package/src/bin/initialize-account-theme/copyBoilerplate.ts +0 -32
- package/src/bin/initialize-account-theme/initializeAccountTheme_multiPage.ts +0 -21
- package/src/bin/initialize-account-theme/initializeAccountTheme_singlePage.ts +0 -142
- package/src/bin/initialize-account-theme/src/single-page/KcContext.ts +0 -7
- package/src/bin/initialize-account-theme/src/single-page/KcPage.tsx +0 -11
- package/src/bin/shared/getLatestsSemVersionedTag.ts +0 -201
- package/src/bin/shared/promptKeycloakVersion.ts +0 -72
- package/src/bin/tools/OptionalIfCanBeUndefined.ts +0 -12
- package/src/bin/tools/crc32.ts +0 -73
- package/src/bin/tools/deflate.ts +0 -61
- package/src/bin/tools/octokit-addons/getLatestsSemVersionedTag.ts +0 -47
- package/src/bin/tools/octokit-addons/listTags.ts +0 -60
- package/src/bin/tools/tee.ts +0 -39
- package/src/bin/tools/trimIndent.ts +0 -49
- /package/bin/shared/{addSyncExtensionsToPostinstallScript.d.ts → initializeSpa/addSyncExtensionsToPostinstallScript.d.ts} +0 -0
- /package/src/bin/initialize-account-theme/{src/multi-page → multi-page-boilerplate}/KcContext.ts +0 -0
- /package/src/bin/initialize-account-theme/{src/multi-page → multi-page-boilerplate}/KcPage.tsx +0 -0
- /package/src/bin/initialize-account-theme/{src/multi-page → multi-page-boilerplate}/KcPageStory.tsx +0 -0
- /package/src/bin/initialize-account-theme/{src/multi-page → multi-page-boilerplate}/i18n.ts +0 -0
package/bin/568.index.js
DELETED
@@ -1,1867 +0,0 @@
|
|
1
|
-
exports.id = 568;
|
2
|
-
exports.ids = [568];
|
3
|
-
exports.modules = {
|
4
|
-
|
5
|
-
/***/ 18512:
|
6
|
-
/***/ ((module) => {
|
7
|
-
|
8
|
-
"use strict";
|
9
|
-
|
10
|
-
const x = module.exports;
|
11
|
-
const ESC = '\u001B[';
|
12
|
-
const OSC = '\u001B]';
|
13
|
-
const BEL = '\u0007';
|
14
|
-
const SEP = ';';
|
15
|
-
const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
|
16
|
-
|
17
|
-
x.cursorTo = (x, y) => {
|
18
|
-
if (typeof x !== 'number') {
|
19
|
-
throw new TypeError('The `x` argument is required');
|
20
|
-
}
|
21
|
-
|
22
|
-
if (typeof y !== 'number') {
|
23
|
-
return ESC + (x + 1) + 'G';
|
24
|
-
}
|
25
|
-
|
26
|
-
return ESC + (y + 1) + ';' + (x + 1) + 'H';
|
27
|
-
};
|
28
|
-
|
29
|
-
x.cursorMove = (x, y) => {
|
30
|
-
if (typeof x !== 'number') {
|
31
|
-
throw new TypeError('The `x` argument is required');
|
32
|
-
}
|
33
|
-
|
34
|
-
let ret = '';
|
35
|
-
|
36
|
-
if (x < 0) {
|
37
|
-
ret += ESC + (-x) + 'D';
|
38
|
-
} else if (x > 0) {
|
39
|
-
ret += ESC + x + 'C';
|
40
|
-
}
|
41
|
-
|
42
|
-
if (y < 0) {
|
43
|
-
ret += ESC + (-y) + 'A';
|
44
|
-
} else if (y > 0) {
|
45
|
-
ret += ESC + y + 'B';
|
46
|
-
}
|
47
|
-
|
48
|
-
return ret;
|
49
|
-
};
|
50
|
-
|
51
|
-
x.cursorUp = count => ESC + (typeof count === 'number' ? count : 1) + 'A';
|
52
|
-
x.cursorDown = count => ESC + (typeof count === 'number' ? count : 1) + 'B';
|
53
|
-
x.cursorForward = count => ESC + (typeof count === 'number' ? count : 1) + 'C';
|
54
|
-
x.cursorBackward = count => ESC + (typeof count === 'number' ? count : 1) + 'D';
|
55
|
-
|
56
|
-
x.cursorLeft = ESC + 'G';
|
57
|
-
x.cursorSavePosition = ESC + (isTerminalApp ? '7' : 's');
|
58
|
-
x.cursorRestorePosition = ESC + (isTerminalApp ? '8' : 'u');
|
59
|
-
x.cursorGetPosition = ESC + '6n';
|
60
|
-
x.cursorNextLine = ESC + 'E';
|
61
|
-
x.cursorPrevLine = ESC + 'F';
|
62
|
-
x.cursorHide = ESC + '?25l';
|
63
|
-
x.cursorShow = ESC + '?25h';
|
64
|
-
|
65
|
-
x.eraseLines = count => {
|
66
|
-
let clear = '';
|
67
|
-
|
68
|
-
for (let i = 0; i < count; i++) {
|
69
|
-
clear += x.eraseLine + (i < count - 1 ? x.cursorUp() : '');
|
70
|
-
}
|
71
|
-
|
72
|
-
if (count) {
|
73
|
-
clear += x.cursorLeft;
|
74
|
-
}
|
75
|
-
|
76
|
-
return clear;
|
77
|
-
};
|
78
|
-
|
79
|
-
x.eraseEndLine = ESC + 'K';
|
80
|
-
x.eraseStartLine = ESC + '1K';
|
81
|
-
x.eraseLine = ESC + '2K';
|
82
|
-
x.eraseDown = ESC + 'J';
|
83
|
-
x.eraseUp = ESC + '1J';
|
84
|
-
x.eraseScreen = ESC + '2J';
|
85
|
-
x.scrollUp = ESC + 'S';
|
86
|
-
x.scrollDown = ESC + 'T';
|
87
|
-
|
88
|
-
x.clearScreen = '\u001Bc';
|
89
|
-
|
90
|
-
x.clearTerminal = process.platform === 'win32' ?
|
91
|
-
`${x.eraseScreen}${ESC}0f` :
|
92
|
-
// 1. Erases the screen (Only done in case `2` is not supported)
|
93
|
-
// 2. Erases the whole screen including scrollback buffer
|
94
|
-
// 3. Moves cursor to the top-left position
|
95
|
-
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
96
|
-
`${x.eraseScreen}${ESC}3J${ESC}H`;
|
97
|
-
|
98
|
-
x.beep = BEL;
|
99
|
-
|
100
|
-
x.link = (text, url) => {
|
101
|
-
return [
|
102
|
-
OSC,
|
103
|
-
'8',
|
104
|
-
SEP,
|
105
|
-
SEP,
|
106
|
-
url,
|
107
|
-
BEL,
|
108
|
-
text,
|
109
|
-
OSC,
|
110
|
-
'8',
|
111
|
-
SEP,
|
112
|
-
SEP,
|
113
|
-
BEL
|
114
|
-
].join('');
|
115
|
-
};
|
116
|
-
|
117
|
-
x.image = (buf, opts) => {
|
118
|
-
opts = opts || {};
|
119
|
-
|
120
|
-
let ret = OSC + '1337;File=inline=1';
|
121
|
-
|
122
|
-
if (opts.width) {
|
123
|
-
ret += `;width=${opts.width}`;
|
124
|
-
}
|
125
|
-
|
126
|
-
if (opts.height) {
|
127
|
-
ret += `;height=${opts.height}`;
|
128
|
-
}
|
129
|
-
|
130
|
-
if (opts.preserveAspectRatio === false) {
|
131
|
-
ret += ';preserveAspectRatio=0';
|
132
|
-
}
|
133
|
-
|
134
|
-
return ret + ':' + buf.toString('base64') + BEL;
|
135
|
-
};
|
136
|
-
|
137
|
-
x.iTerm = {};
|
138
|
-
|
139
|
-
x.iTerm.setCwd = cwd => OSC + '50;CurrentDir=' + (cwd || process.cwd()) + BEL;
|
140
|
-
|
141
|
-
|
142
|
-
/***/ }),
|
143
|
-
|
144
|
-
/***/ 34024:
|
145
|
-
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
146
|
-
|
147
|
-
var Buffer = (__webpack_require__(14300).Buffer);
|
148
|
-
|
149
|
-
var CRC_TABLE = [
|
150
|
-
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
|
151
|
-
0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
|
152
|
-
0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
|
153
|
-
0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
|
154
|
-
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
|
155
|
-
0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
156
|
-
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
|
157
|
-
0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
158
|
-
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
|
159
|
-
0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
|
160
|
-
0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
|
161
|
-
0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
162
|
-
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
|
163
|
-
0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
|
164
|
-
0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
|
165
|
-
0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
166
|
-
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
|
167
|
-
0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
168
|
-
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
|
169
|
-
0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
|
170
|
-
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
|
171
|
-
0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
|
172
|
-
0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
|
173
|
-
0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
174
|
-
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
|
175
|
-
0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
|
176
|
-
0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
|
177
|
-
0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
|
178
|
-
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
|
179
|
-
0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
180
|
-
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
|
181
|
-
0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
182
|
-
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
|
183
|
-
0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
|
184
|
-
0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
|
185
|
-
0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
186
|
-
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
|
187
|
-
0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
|
188
|
-
0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
|
189
|
-
0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
190
|
-
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
|
191
|
-
0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
192
|
-
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
|
193
|
-
0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
|
194
|
-
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
|
195
|
-
0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
|
196
|
-
0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
|
197
|
-
0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
198
|
-
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
|
199
|
-
0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
|
200
|
-
0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
|
201
|
-
0x2d02ef8d
|
202
|
-
];
|
203
|
-
|
204
|
-
if (typeof Int32Array !== 'undefined') {
|
205
|
-
CRC_TABLE = new Int32Array(CRC_TABLE);
|
206
|
-
}
|
207
|
-
|
208
|
-
function ensureBuffer(input) {
|
209
|
-
if (Buffer.isBuffer(input)) {
|
210
|
-
return input;
|
211
|
-
}
|
212
|
-
|
213
|
-
var hasNewBufferAPI =
|
214
|
-
typeof Buffer.alloc === "function" &&
|
215
|
-
typeof Buffer.from === "function";
|
216
|
-
|
217
|
-
if (typeof input === "number") {
|
218
|
-
return hasNewBufferAPI ? Buffer.alloc(input) : new Buffer(input);
|
219
|
-
}
|
220
|
-
else if (typeof input === "string") {
|
221
|
-
return hasNewBufferAPI ? Buffer.from(input) : new Buffer(input);
|
222
|
-
}
|
223
|
-
else {
|
224
|
-
throw new Error("input must be buffer, number, or string, received " +
|
225
|
-
typeof input);
|
226
|
-
}
|
227
|
-
}
|
228
|
-
|
229
|
-
function bufferizeInt(num) {
|
230
|
-
var tmp = ensureBuffer(4);
|
231
|
-
tmp.writeInt32BE(num, 0);
|
232
|
-
return tmp;
|
233
|
-
}
|
234
|
-
|
235
|
-
function _crc32(buf, previous) {
|
236
|
-
buf = ensureBuffer(buf);
|
237
|
-
if (Buffer.isBuffer(previous)) {
|
238
|
-
previous = previous.readUInt32BE(0);
|
239
|
-
}
|
240
|
-
var crc = ~~previous ^ -1;
|
241
|
-
for (var n = 0; n < buf.length; n++) {
|
242
|
-
crc = CRC_TABLE[(crc ^ buf[n]) & 0xff] ^ (crc >>> 8);
|
243
|
-
}
|
244
|
-
return (crc ^ -1);
|
245
|
-
}
|
246
|
-
|
247
|
-
function crc32() {
|
248
|
-
return bufferizeInt(_crc32.apply(null, arguments));
|
249
|
-
}
|
250
|
-
crc32.signed = function () {
|
251
|
-
return _crc32.apply(null, arguments);
|
252
|
-
};
|
253
|
-
crc32.unsigned = function () {
|
254
|
-
return _crc32.apply(null, arguments) >>> 0;
|
255
|
-
};
|
256
|
-
|
257
|
-
module.exports = crc32;
|
258
|
-
|
259
|
-
|
260
|
-
/***/ }),
|
261
|
-
|
262
|
-
/***/ 39340:
|
263
|
-
/***/ ((__unused_webpack_module, exports) => {
|
264
|
-
|
265
|
-
"use strict";
|
266
|
-
|
267
|
-
|
268
|
-
Object.defineProperty(exports, "__esModule", ({
|
269
|
-
value: true
|
270
|
-
}));
|
271
|
-
exports.withPromise = exports.withCallback = void 0;
|
272
|
-
|
273
|
-
/**
|
274
|
-
* Open the input with a normal callback function
|
275
|
-
*
|
276
|
-
* @param {Input} input - input object
|
277
|
-
* @param {function} valueMapper - function which maps the resulting id and value back to the expected format
|
278
|
-
* @param {function} callback - callback function
|
279
|
-
*/
|
280
|
-
const withCallback = (input, valueMapper, callback) => {
|
281
|
-
input.open();
|
282
|
-
input.onSelect((id, value) => callback(valueMapper(id, value)));
|
283
|
-
};
|
284
|
-
/**
|
285
|
-
* Open the input with a promise
|
286
|
-
*
|
287
|
-
* @param {Input} input - input object
|
288
|
-
* @param {function} valueMapper - function which maps the resulting id and value back to the expected format
|
289
|
-
*/
|
290
|
-
|
291
|
-
|
292
|
-
exports.withCallback = withCallback;
|
293
|
-
|
294
|
-
const withPromise = (input, valueMapper) => {
|
295
|
-
return new Promise((resolve, reject) => {
|
296
|
-
input.open();
|
297
|
-
input.onSelect((id, value) => {
|
298
|
-
if (id === null) {
|
299
|
-
reject();
|
300
|
-
} else {
|
301
|
-
resolve(valueMapper(id, value));
|
302
|
-
}
|
303
|
-
});
|
304
|
-
});
|
305
|
-
};
|
306
|
-
|
307
|
-
exports.withPromise = withPromise;
|
308
|
-
|
309
|
-
/***/ }),
|
310
|
-
|
311
|
-
/***/ 99398:
|
312
|
-
/***/ ((module, exports, __webpack_require__) => {
|
313
|
-
|
314
|
-
"use strict";
|
315
|
-
|
316
|
-
|
317
|
-
Object.defineProperty(exports, "__esModule", ({
|
318
|
-
value: true
|
319
|
-
}));
|
320
|
-
exports["default"] = void 0;
|
321
|
-
|
322
|
-
var _input = _interopRequireDefault(__webpack_require__(25730));
|
323
|
-
|
324
|
-
var _renderer = _interopRequireDefault(__webpack_require__(16059));
|
325
|
-
|
326
|
-
var _callbackMappers = __webpack_require__(39340);
|
327
|
-
|
328
|
-
var _valueMappers = __webpack_require__(26730);
|
329
|
-
|
330
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
331
|
-
|
332
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
333
|
-
|
334
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
335
|
-
|
336
|
-
/**
|
337
|
-
* Default options
|
338
|
-
*/
|
339
|
-
const defaultOptions = {
|
340
|
-
outputStream: process.stdout,
|
341
|
-
inputStream: process.stdin,
|
342
|
-
values: [],
|
343
|
-
defaultValue: 0,
|
344
|
-
selected: '(x)',
|
345
|
-
unselected: '( )',
|
346
|
-
indentation: 0,
|
347
|
-
cleanup: true,
|
348
|
-
valueRenderer: value => value
|
349
|
-
};
|
350
|
-
/**
|
351
|
-
* Create an instance of cli-select with the given options
|
352
|
-
*
|
353
|
-
* @param {object} options - options for cli-select
|
354
|
-
* @param {function} callback - if specified, a callback will be used, otherwise a promise gets returned (optional)
|
355
|
-
*/
|
356
|
-
|
357
|
-
const creator = (options, callback) => {
|
358
|
-
// merge options with default options
|
359
|
-
options = _objectSpread({}, defaultOptions, options); // create renderer and input instances
|
360
|
-
|
361
|
-
const renderer = new _renderer.default(options, options.outputStream);
|
362
|
-
const input = new _input.default(options.inputStream);
|
363
|
-
input.setDefaultValue(options.defaultValue);
|
364
|
-
input.attachRenderer(renderer); // handle array and object values
|
365
|
-
|
366
|
-
let valueMapper;
|
367
|
-
|
368
|
-
if (Array.isArray(options.values)) {
|
369
|
-
valueMapper = (0, _valueMappers.withArrayValues)(options);
|
370
|
-
} else {
|
371
|
-
valueMapper = (0, _valueMappers.withObjectValues)(options);
|
372
|
-
} // map values
|
373
|
-
|
374
|
-
|
375
|
-
options.values = valueMapper.input;
|
376
|
-
input.setValues(options.values); // handle different callback methods
|
377
|
-
|
378
|
-
if (typeof callback === 'function') {
|
379
|
-
return (0, _callbackMappers.withCallback)(input, valueMapper.output, callback);
|
380
|
-
} else {
|
381
|
-
return (0, _callbackMappers.withPromise)(input, valueMapper.output);
|
382
|
-
}
|
383
|
-
};
|
384
|
-
|
385
|
-
exports = module.exports = creator;
|
386
|
-
Object.defineProperty(exports, "__esModule", ({
|
387
|
-
value: true
|
388
|
-
}));
|
389
|
-
var _default = creator;
|
390
|
-
exports["default"] = _default;
|
391
|
-
|
392
|
-
/***/ }),
|
393
|
-
|
394
|
-
/***/ 25730:
|
395
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
396
|
-
|
397
|
-
"use strict";
|
398
|
-
|
399
|
-
|
400
|
-
Object.defineProperty(exports, "__esModule", ({
|
401
|
-
value: true
|
402
|
-
}));
|
403
|
-
exports["default"] = void 0;
|
404
|
-
|
405
|
-
var _readline = _interopRequireDefault(__webpack_require__(14521));
|
406
|
-
|
407
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
408
|
-
|
409
|
-
/**
|
410
|
-
* Handle cli input
|
411
|
-
*/
|
412
|
-
class Input {
|
413
|
-
/**
|
414
|
-
* Input constructor
|
415
|
-
*
|
416
|
-
* @param {any} stream - stream to catch (optional)
|
417
|
-
*/
|
418
|
-
constructor(stream = process.stdin) {
|
419
|
-
// set default values
|
420
|
-
this.stream = stream;
|
421
|
-
this.values = [];
|
422
|
-
this.selectedValue = 0;
|
423
|
-
|
424
|
-
this.onSelectListener = () => {};
|
425
|
-
|
426
|
-
this.onKeyPress = this.onKeyPress.bind(this);
|
427
|
-
}
|
428
|
-
/**
|
429
|
-
* Set the available values
|
430
|
-
*
|
431
|
-
* @param {array} values - all available values
|
432
|
-
*/
|
433
|
-
|
434
|
-
|
435
|
-
setValues(values) {
|
436
|
-
this.values = values;
|
437
|
-
|
438
|
-
if (this.renderer) {
|
439
|
-
this.renderer.setValues(values);
|
440
|
-
}
|
441
|
-
}
|
442
|
-
/**
|
443
|
-
* Set the default value
|
444
|
-
*
|
445
|
-
* @param {number} defaultValue - default value id
|
446
|
-
*/
|
447
|
-
|
448
|
-
|
449
|
-
setDefaultValue(defaultValue) {
|
450
|
-
this.selectedValue = defaultValue;
|
451
|
-
}
|
452
|
-
/**
|
453
|
-
* Attach a renderer to the input catcher
|
454
|
-
*
|
455
|
-
* @param {Renderer} renderer - renderer to use for rendering responses
|
456
|
-
*/
|
457
|
-
|
458
|
-
|
459
|
-
attachRenderer(renderer) {
|
460
|
-
this.renderer = renderer;
|
461
|
-
this.renderer.setValues(this.values);
|
462
|
-
}
|
463
|
-
/**
|
464
|
-
* Register an on select listener
|
465
|
-
*
|
466
|
-
* @param {function} listener - listener function which receives two parameters: valueId and value
|
467
|
-
*/
|
468
|
-
|
469
|
-
|
470
|
-
onSelect(listener) {
|
471
|
-
this.onSelectListener = listener;
|
472
|
-
}
|
473
|
-
/**
|
474
|
-
* Open the stream and listen for input
|
475
|
-
*/
|
476
|
-
|
477
|
-
|
478
|
-
open() {
|
479
|
-
// register keypress event
|
480
|
-
_readline.default.emitKeypressEvents(this.stream); // handle keypress
|
481
|
-
|
482
|
-
|
483
|
-
this.stream.on('keypress', this.onKeyPress); // initially render the response
|
484
|
-
|
485
|
-
if (this.renderer) {
|
486
|
-
this.renderer.render(this.selectedValue);
|
487
|
-
} // hide pressed keys and start listening on input
|
488
|
-
|
489
|
-
|
490
|
-
this.stream.setRawMode(true);
|
491
|
-
this.stream.resume();
|
492
|
-
}
|
493
|
-
/**
|
494
|
-
* Close the stream
|
495
|
-
*
|
496
|
-
* @param {boolean} cancelled - true if no value was selected (optional)
|
497
|
-
*/
|
498
|
-
|
499
|
-
|
500
|
-
close(cancelled = false) {
|
501
|
-
// reset stream properties
|
502
|
-
this.stream.setRawMode(false);
|
503
|
-
this.stream.pause(); // cleanup the output
|
504
|
-
|
505
|
-
if (this.renderer) {
|
506
|
-
this.renderer.cleanup();
|
507
|
-
} // call the on select listener
|
508
|
-
|
509
|
-
|
510
|
-
if (cancelled) {
|
511
|
-
this.onSelectListener(null);
|
512
|
-
} else {
|
513
|
-
this.onSelectListener(this.selectedValue, this.values[this.selectedValue]);
|
514
|
-
}
|
515
|
-
|
516
|
-
this.stream.removeListener('keypress', this.onKeyPress);
|
517
|
-
}
|
518
|
-
/**
|
519
|
-
* Render the response
|
520
|
-
*/
|
521
|
-
|
522
|
-
|
523
|
-
render() {
|
524
|
-
if (!this.renderer) {
|
525
|
-
return;
|
526
|
-
}
|
527
|
-
|
528
|
-
this.renderer.render(this.selectedValue);
|
529
|
-
}
|
530
|
-
/**
|
531
|
-
* Handle key press event
|
532
|
-
*
|
533
|
-
* @param {string} string - input string
|
534
|
-
* @param {object} key - object containing information about the pressed key
|
535
|
-
*/
|
536
|
-
|
537
|
-
|
538
|
-
onKeyPress(string, key) {
|
539
|
-
if (key) {
|
540
|
-
if (key.name === 'up' && this.selectedValue > 0) {
|
541
|
-
this.selectedValue--;
|
542
|
-
this.render();
|
543
|
-
} else if (key.name === 'down' && this.selectedValue + 1 < this.values.length) {
|
544
|
-
this.selectedValue++;
|
545
|
-
this.render();
|
546
|
-
} else if (key.name === 'return') {
|
547
|
-
this.close();
|
548
|
-
} else if (key.name === 'escape' || key.name === 'c' && key.ctrl) {
|
549
|
-
this.close(true);
|
550
|
-
}
|
551
|
-
}
|
552
|
-
}
|
553
|
-
|
554
|
-
}
|
555
|
-
|
556
|
-
exports["default"] = Input;
|
557
|
-
|
558
|
-
/***/ }),
|
559
|
-
|
560
|
-
/***/ 16059:
|
561
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
562
|
-
|
563
|
-
"use strict";
|
564
|
-
|
565
|
-
|
566
|
-
Object.defineProperty(exports, "__esModule", ({
|
567
|
-
value: true
|
568
|
-
}));
|
569
|
-
exports["default"] = void 0;
|
570
|
-
|
571
|
-
var _readline = _interopRequireDefault(__webpack_require__(14521));
|
572
|
-
|
573
|
-
var _ansiEscapes = __webpack_require__(18512);
|
574
|
-
|
575
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
576
|
-
|
577
|
-
/**
|
578
|
-
* Response renderer
|
579
|
-
*/
|
580
|
-
class Renderer {
|
581
|
-
/**
|
582
|
-
* Renderer constructor
|
583
|
-
*
|
584
|
-
* @param {object} options - renderer options
|
585
|
-
* @param {any} stream - stream to write to (optional)
|
586
|
-
*/
|
587
|
-
constructor(options, stream = process.stdout) {
|
588
|
-
this.options = options;
|
589
|
-
this.stream = stream;
|
590
|
-
this.values = [];
|
591
|
-
this.initialRender = true;
|
592
|
-
}
|
593
|
-
/**
|
594
|
-
* Set the available values
|
595
|
-
*
|
596
|
-
* @param {array} values - all available values
|
597
|
-
*/
|
598
|
-
|
599
|
-
|
600
|
-
setValues(values) {
|
601
|
-
this.values = values;
|
602
|
-
}
|
603
|
-
/**
|
604
|
-
* Render the values
|
605
|
-
*
|
606
|
-
* @param {number} selectedValue - selected value (optional)
|
607
|
-
*/
|
608
|
-
|
609
|
-
|
610
|
-
render(selectedValue = 0) {
|
611
|
-
if (this.initialRender) {
|
612
|
-
// hide the cursor initially
|
613
|
-
this.initialRender = false;
|
614
|
-
this.stream.write(_ansiEscapes.cursorHide);
|
615
|
-
} else {
|
616
|
-
// remove previous lines and values
|
617
|
-
this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
|
618
|
-
} // output the current values
|
619
|
-
|
620
|
-
|
621
|
-
this.values.forEach((value, index) => {
|
622
|
-
const symbol = selectedValue === index ? this.options.selected : this.options.unselected;
|
623
|
-
const indentation = ' '.repeat(this.options.indentation);
|
624
|
-
const renderedValue = this.options.valueRenderer(value, selectedValue === index);
|
625
|
-
const end = index !== this.values.length - 1 ? '\n' : '';
|
626
|
-
this.stream.write(indentation + symbol + ' ' + renderedValue + end);
|
627
|
-
});
|
628
|
-
}
|
629
|
-
/**
|
630
|
-
* Cleanup the console at the end
|
631
|
-
*/
|
632
|
-
|
633
|
-
|
634
|
-
cleanup() {
|
635
|
-
this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
|
636
|
-
this.stream.write(_ansiEscapes.cursorShow);
|
637
|
-
}
|
638
|
-
|
639
|
-
}
|
640
|
-
|
641
|
-
exports["default"] = Renderer;
|
642
|
-
|
643
|
-
/***/ }),
|
644
|
-
|
645
|
-
/***/ 26730:
|
646
|
-
/***/ ((__unused_webpack_module, exports) => {
|
647
|
-
|
648
|
-
"use strict";
|
649
|
-
|
650
|
-
|
651
|
-
Object.defineProperty(exports, "__esModule", ({
|
652
|
-
value: true
|
653
|
-
}));
|
654
|
-
exports.withObjectValues = exports.withArrayValues = void 0;
|
655
|
-
|
656
|
-
/**
|
657
|
-
* Map incoming and outgoing values if the initial values are an array
|
658
|
-
*
|
659
|
-
* @param {object} options - cli-select options
|
660
|
-
*/
|
661
|
-
const withArrayValues = options => {
|
662
|
-
return {
|
663
|
-
input: options.values,
|
664
|
-
output: (id, value) => {
|
665
|
-
return {
|
666
|
-
id,
|
667
|
-
value
|
668
|
-
};
|
669
|
-
}
|
670
|
-
};
|
671
|
-
};
|
672
|
-
/**
|
673
|
-
* Map incoming and outgoing values if the initial values are an object
|
674
|
-
*
|
675
|
-
* @param {object} options - cli-select options
|
676
|
-
*/
|
677
|
-
|
678
|
-
|
679
|
-
exports.withArrayValues = withArrayValues;
|
680
|
-
|
681
|
-
const withObjectValues = options => {
|
682
|
-
const originalValues = options.values;
|
683
|
-
return {
|
684
|
-
input: Object.values(originalValues),
|
685
|
-
output: (id, value) => {
|
686
|
-
return {
|
687
|
-
id: Object.keys(originalValues)[id],
|
688
|
-
value
|
689
|
-
};
|
690
|
-
}
|
691
|
-
};
|
692
|
-
};
|
693
|
-
|
694
|
-
exports.withObjectValues = withObjectValues;
|
695
|
-
|
696
|
-
/***/ }),
|
697
|
-
|
698
|
-
/***/ 65010:
|
699
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
700
|
-
|
701
|
-
var fs = __webpack_require__(57147);
|
702
|
-
var util = __webpack_require__(73837);
|
703
|
-
var stream = __webpack_require__(12781);
|
704
|
-
var Readable = stream.Readable;
|
705
|
-
var Writable = stream.Writable;
|
706
|
-
var PassThrough = stream.PassThrough;
|
707
|
-
var Pend = __webpack_require__(54833);
|
708
|
-
var EventEmitter = (__webpack_require__(82361).EventEmitter);
|
709
|
-
|
710
|
-
exports.createFromBuffer = createFromBuffer;
|
711
|
-
exports.createFromFd = createFromFd;
|
712
|
-
exports.BufferSlicer = BufferSlicer;
|
713
|
-
exports.FdSlicer = FdSlicer;
|
714
|
-
|
715
|
-
util.inherits(FdSlicer, EventEmitter);
|
716
|
-
function FdSlicer(fd, options) {
|
717
|
-
options = options || {};
|
718
|
-
EventEmitter.call(this);
|
719
|
-
|
720
|
-
this.fd = fd;
|
721
|
-
this.pend = new Pend();
|
722
|
-
this.pend.max = 1;
|
723
|
-
this.refCount = 0;
|
724
|
-
this.autoClose = !!options.autoClose;
|
725
|
-
}
|
726
|
-
|
727
|
-
FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
728
|
-
var self = this;
|
729
|
-
self.pend.go(function(cb) {
|
730
|
-
fs.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer) {
|
731
|
-
cb();
|
732
|
-
callback(err, bytesRead, buffer);
|
733
|
-
});
|
734
|
-
});
|
735
|
-
};
|
736
|
-
|
737
|
-
FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
738
|
-
var self = this;
|
739
|
-
self.pend.go(function(cb) {
|
740
|
-
fs.write(self.fd, buffer, offset, length, position, function(err, written, buffer) {
|
741
|
-
cb();
|
742
|
-
callback(err, written, buffer);
|
743
|
-
});
|
744
|
-
});
|
745
|
-
};
|
746
|
-
|
747
|
-
FdSlicer.prototype.createReadStream = function(options) {
|
748
|
-
return new ReadStream(this, options);
|
749
|
-
};
|
750
|
-
|
751
|
-
FdSlicer.prototype.createWriteStream = function(options) {
|
752
|
-
return new WriteStream(this, options);
|
753
|
-
};
|
754
|
-
|
755
|
-
FdSlicer.prototype.ref = function() {
|
756
|
-
this.refCount += 1;
|
757
|
-
};
|
758
|
-
|
759
|
-
FdSlicer.prototype.unref = function() {
|
760
|
-
var self = this;
|
761
|
-
self.refCount -= 1;
|
762
|
-
|
763
|
-
if (self.refCount > 0) return;
|
764
|
-
if (self.refCount < 0) throw new Error("invalid unref");
|
765
|
-
|
766
|
-
if (self.autoClose) {
|
767
|
-
fs.close(self.fd, onCloseDone);
|
768
|
-
}
|
769
|
-
|
770
|
-
function onCloseDone(err) {
|
771
|
-
if (err) {
|
772
|
-
self.emit('error', err);
|
773
|
-
} else {
|
774
|
-
self.emit('close');
|
775
|
-
}
|
776
|
-
}
|
777
|
-
};
|
778
|
-
|
779
|
-
util.inherits(ReadStream, Readable);
|
780
|
-
function ReadStream(context, options) {
|
781
|
-
options = options || {};
|
782
|
-
Readable.call(this, options);
|
783
|
-
|
784
|
-
this.context = context;
|
785
|
-
this.context.ref();
|
786
|
-
|
787
|
-
this.start = options.start || 0;
|
788
|
-
this.endOffset = options.end;
|
789
|
-
this.pos = this.start;
|
790
|
-
this.destroyed = false;
|
791
|
-
}
|
792
|
-
|
793
|
-
ReadStream.prototype._read = function(n) {
|
794
|
-
var self = this;
|
795
|
-
if (self.destroyed) return;
|
796
|
-
|
797
|
-
var toRead = Math.min(self._readableState.highWaterMark, n);
|
798
|
-
if (self.endOffset != null) {
|
799
|
-
toRead = Math.min(toRead, self.endOffset - self.pos);
|
800
|
-
}
|
801
|
-
if (toRead <= 0) {
|
802
|
-
self.destroyed = true;
|
803
|
-
self.push(null);
|
804
|
-
self.context.unref();
|
805
|
-
return;
|
806
|
-
}
|
807
|
-
self.context.pend.go(function(cb) {
|
808
|
-
if (self.destroyed) return cb();
|
809
|
-
var buffer = Buffer.allocUnsafe ? Buffer.allocUnsafe(toRead) : new Buffer(toRead);
|
810
|
-
fs.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
|
811
|
-
if (err) {
|
812
|
-
self.destroy(err);
|
813
|
-
} else if (bytesRead === 0) {
|
814
|
-
self.destroyed = true;
|
815
|
-
self.push(null);
|
816
|
-
self.context.unref();
|
817
|
-
} else {
|
818
|
-
self.pos += bytesRead;
|
819
|
-
self.push(buffer.slice(0, bytesRead));
|
820
|
-
}
|
821
|
-
cb();
|
822
|
-
});
|
823
|
-
});
|
824
|
-
};
|
825
|
-
|
826
|
-
ReadStream.prototype.destroy = function(err) {
|
827
|
-
if (this.destroyed) return;
|
828
|
-
err = err || new Error("stream destroyed");
|
829
|
-
this.destroyed = true;
|
830
|
-
this.emit('error', err);
|
831
|
-
this.context.unref();
|
832
|
-
};
|
833
|
-
|
834
|
-
util.inherits(WriteStream, Writable);
|
835
|
-
function WriteStream(context, options) {
|
836
|
-
options = options || {};
|
837
|
-
Writable.call(this, options);
|
838
|
-
|
839
|
-
this.context = context;
|
840
|
-
this.context.ref();
|
841
|
-
|
842
|
-
this.start = options.start || 0;
|
843
|
-
this.endOffset = (options.end == null) ? Infinity : +options.end;
|
844
|
-
this.bytesWritten = 0;
|
845
|
-
this.pos = this.start;
|
846
|
-
this.destroyed = false;
|
847
|
-
|
848
|
-
this.on('finish', this.destroy.bind(this));
|
849
|
-
}
|
850
|
-
|
851
|
-
WriteStream.prototype._write = function(buffer, encoding, callback) {
|
852
|
-
var self = this;
|
853
|
-
if (self.destroyed) return;
|
854
|
-
|
855
|
-
if (self.pos + buffer.length > self.endOffset) {
|
856
|
-
var err = new Error("maximum file length exceeded");
|
857
|
-
err.code = 'ETOOBIG';
|
858
|
-
self.destroy();
|
859
|
-
callback(err);
|
860
|
-
return;
|
861
|
-
}
|
862
|
-
self.context.pend.go(function(cb) {
|
863
|
-
if (self.destroyed) return cb();
|
864
|
-
fs.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err, bytes) {
|
865
|
-
if (err) {
|
866
|
-
self.destroy();
|
867
|
-
cb();
|
868
|
-
callback(err);
|
869
|
-
} else {
|
870
|
-
self.bytesWritten += bytes;
|
871
|
-
self.pos += bytes;
|
872
|
-
self.emit('progress');
|
873
|
-
cb();
|
874
|
-
callback();
|
875
|
-
}
|
876
|
-
});
|
877
|
-
});
|
878
|
-
};
|
879
|
-
|
880
|
-
WriteStream.prototype.destroy = function() {
|
881
|
-
if (this.destroyed) return;
|
882
|
-
this.destroyed = true;
|
883
|
-
this.context.unref();
|
884
|
-
};
|
885
|
-
|
886
|
-
util.inherits(BufferSlicer, EventEmitter);
|
887
|
-
function BufferSlicer(buffer, options) {
|
888
|
-
EventEmitter.call(this);
|
889
|
-
|
890
|
-
options = options || {};
|
891
|
-
this.refCount = 0;
|
892
|
-
this.buffer = buffer;
|
893
|
-
this.maxChunkSize = options.maxChunkSize || Number.MAX_SAFE_INTEGER;
|
894
|
-
}
|
895
|
-
|
896
|
-
BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
897
|
-
var end = position + length;
|
898
|
-
var delta = end - this.buffer.length;
|
899
|
-
var written = (delta > 0) ? delta : length;
|
900
|
-
this.buffer.copy(buffer, offset, position, end);
|
901
|
-
setImmediate(function() {
|
902
|
-
callback(null, written);
|
903
|
-
});
|
904
|
-
};
|
905
|
-
|
906
|
-
BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
907
|
-
buffer.copy(this.buffer, position, offset, offset + length);
|
908
|
-
setImmediate(function() {
|
909
|
-
callback(null, length, buffer);
|
910
|
-
});
|
911
|
-
};
|
912
|
-
|
913
|
-
BufferSlicer.prototype.createReadStream = function(options) {
|
914
|
-
options = options || {};
|
915
|
-
var readStream = new PassThrough(options);
|
916
|
-
readStream.destroyed = false;
|
917
|
-
readStream.start = options.start || 0;
|
918
|
-
readStream.endOffset = options.end;
|
919
|
-
// by the time this function returns, we'll be done.
|
920
|
-
readStream.pos = readStream.endOffset || this.buffer.length;
|
921
|
-
|
922
|
-
// respect the maxChunkSize option to slice up the chunk into smaller pieces.
|
923
|
-
var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
|
924
|
-
var offset = 0;
|
925
|
-
while (true) {
|
926
|
-
var nextOffset = offset + this.maxChunkSize;
|
927
|
-
if (nextOffset >= entireSlice.length) {
|
928
|
-
// last chunk
|
929
|
-
if (offset < entireSlice.length) {
|
930
|
-
readStream.write(entireSlice.slice(offset, entireSlice.length));
|
931
|
-
}
|
932
|
-
break;
|
933
|
-
}
|
934
|
-
readStream.write(entireSlice.slice(offset, nextOffset));
|
935
|
-
offset = nextOffset;
|
936
|
-
}
|
937
|
-
|
938
|
-
readStream.end();
|
939
|
-
readStream.destroy = function() {
|
940
|
-
readStream.destroyed = true;
|
941
|
-
};
|
942
|
-
return readStream;
|
943
|
-
};
|
944
|
-
|
945
|
-
BufferSlicer.prototype.createWriteStream = function(options) {
|
946
|
-
var bufferSlicer = this;
|
947
|
-
options = options || {};
|
948
|
-
var writeStream = new Writable(options);
|
949
|
-
writeStream.start = options.start || 0;
|
950
|
-
writeStream.endOffset = (options.end == null) ? this.buffer.length : +options.end;
|
951
|
-
writeStream.bytesWritten = 0;
|
952
|
-
writeStream.pos = writeStream.start;
|
953
|
-
writeStream.destroyed = false;
|
954
|
-
writeStream._write = function(buffer, encoding, callback) {
|
955
|
-
if (writeStream.destroyed) return;
|
956
|
-
|
957
|
-
var end = writeStream.pos + buffer.length;
|
958
|
-
if (end > writeStream.endOffset) {
|
959
|
-
var err = new Error("maximum file length exceeded");
|
960
|
-
err.code = 'ETOOBIG';
|
961
|
-
writeStream.destroyed = true;
|
962
|
-
callback(err);
|
963
|
-
return;
|
964
|
-
}
|
965
|
-
buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
|
966
|
-
|
967
|
-
writeStream.bytesWritten += buffer.length;
|
968
|
-
writeStream.pos = end;
|
969
|
-
writeStream.emit('progress');
|
970
|
-
callback();
|
971
|
-
};
|
972
|
-
writeStream.destroy = function() {
|
973
|
-
writeStream.destroyed = true;
|
974
|
-
};
|
975
|
-
return writeStream;
|
976
|
-
};
|
977
|
-
|
978
|
-
BufferSlicer.prototype.ref = function() {
|
979
|
-
this.refCount += 1;
|
980
|
-
};
|
981
|
-
|
982
|
-
BufferSlicer.prototype.unref = function() {
|
983
|
-
this.refCount -= 1;
|
984
|
-
|
985
|
-
if (this.refCount < 0) {
|
986
|
-
throw new Error("invalid unref");
|
987
|
-
}
|
988
|
-
};
|
989
|
-
|
990
|
-
function createFromBuffer(buffer, options) {
|
991
|
-
return new BufferSlicer(buffer, options);
|
992
|
-
}
|
993
|
-
|
994
|
-
function createFromFd(fd, options) {
|
995
|
-
return new FdSlicer(fd, options);
|
996
|
-
}
|
997
|
-
|
998
|
-
|
999
|
-
/***/ }),
|
1000
|
-
|
1001
|
-
/***/ 54833:
|
1002
|
-
/***/ ((module) => {
|
1003
|
-
|
1004
|
-
module.exports = Pend;
|
1005
|
-
|
1006
|
-
function Pend() {
|
1007
|
-
this.pending = 0;
|
1008
|
-
this.max = Infinity;
|
1009
|
-
this.listeners = [];
|
1010
|
-
this.waiting = [];
|
1011
|
-
this.error = null;
|
1012
|
-
}
|
1013
|
-
|
1014
|
-
Pend.prototype.go = function(fn) {
|
1015
|
-
if (this.pending < this.max) {
|
1016
|
-
pendGo(this, fn);
|
1017
|
-
} else {
|
1018
|
-
this.waiting.push(fn);
|
1019
|
-
}
|
1020
|
-
};
|
1021
|
-
|
1022
|
-
Pend.prototype.wait = function(cb) {
|
1023
|
-
if (this.pending === 0) {
|
1024
|
-
cb(this.error);
|
1025
|
-
} else {
|
1026
|
-
this.listeners.push(cb);
|
1027
|
-
}
|
1028
|
-
};
|
1029
|
-
|
1030
|
-
Pend.prototype.hold = function() {
|
1031
|
-
return pendHold(this);
|
1032
|
-
};
|
1033
|
-
|
1034
|
-
function pendHold(self) {
|
1035
|
-
self.pending += 1;
|
1036
|
-
var called = false;
|
1037
|
-
return onCb;
|
1038
|
-
function onCb(err) {
|
1039
|
-
if (called) throw new Error("callback called twice");
|
1040
|
-
called = true;
|
1041
|
-
self.error = self.error || err;
|
1042
|
-
self.pending -= 1;
|
1043
|
-
if (self.waiting.length > 0 && self.pending < self.max) {
|
1044
|
-
pendGo(self, self.waiting.shift());
|
1045
|
-
} else if (self.pending === 0) {
|
1046
|
-
var listeners = self.listeners;
|
1047
|
-
self.listeners = [];
|
1048
|
-
listeners.forEach(cbListener);
|
1049
|
-
}
|
1050
|
-
}
|
1051
|
-
function cbListener(listener) {
|
1052
|
-
listener(self.error);
|
1053
|
-
}
|
1054
|
-
}
|
1055
|
-
|
1056
|
-
function pendGo(self, fn) {
|
1057
|
-
fn(pendHold(self));
|
1058
|
-
}
|
1059
|
-
|
1060
|
-
|
1061
|
-
/***/ }),
|
1062
|
-
|
1063
|
-
/***/ 78781:
|
1064
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
1065
|
-
|
1066
|
-
var fs = __webpack_require__(57147);
|
1067
|
-
var zlib = __webpack_require__(59796);
|
1068
|
-
var fd_slicer = __webpack_require__(65010);
|
1069
|
-
var crc32 = __webpack_require__(34024);
|
1070
|
-
var util = __webpack_require__(73837);
|
1071
|
-
var EventEmitter = (__webpack_require__(82361).EventEmitter);
|
1072
|
-
var Transform = (__webpack_require__(12781).Transform);
|
1073
|
-
var PassThrough = (__webpack_require__(12781).PassThrough);
|
1074
|
-
var Writable = (__webpack_require__(12781).Writable);
|
1075
|
-
|
1076
|
-
exports.open = open;
|
1077
|
-
exports.fromFd = fromFd;
|
1078
|
-
exports.fromBuffer = fromBuffer;
|
1079
|
-
exports.fromRandomAccessReader = fromRandomAccessReader;
|
1080
|
-
exports.dosDateTimeToDate = dosDateTimeToDate;
|
1081
|
-
exports.validateFileName = validateFileName;
|
1082
|
-
exports.ZipFile = ZipFile;
|
1083
|
-
exports.Entry = Entry;
|
1084
|
-
exports.RandomAccessReader = RandomAccessReader;
|
1085
|
-
|
1086
|
-
function open(path, options, callback) {
|
1087
|
-
if (typeof options === "function") {
|
1088
|
-
callback = options;
|
1089
|
-
options = null;
|
1090
|
-
}
|
1091
|
-
if (options == null) options = {};
|
1092
|
-
if (options.autoClose == null) options.autoClose = true;
|
1093
|
-
if (options.lazyEntries == null) options.lazyEntries = false;
|
1094
|
-
if (options.decodeStrings == null) options.decodeStrings = true;
|
1095
|
-
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
1096
|
-
if (options.strictFileNames == null) options.strictFileNames = false;
|
1097
|
-
if (callback == null) callback = defaultCallback;
|
1098
|
-
fs.open(path, "r", function(err, fd) {
|
1099
|
-
if (err) return callback(err);
|
1100
|
-
fromFd(fd, options, function(err, zipfile) {
|
1101
|
-
if (err) fs.close(fd, defaultCallback);
|
1102
|
-
callback(err, zipfile);
|
1103
|
-
});
|
1104
|
-
});
|
1105
|
-
}
|
1106
|
-
|
1107
|
-
function fromFd(fd, options, callback) {
|
1108
|
-
if (typeof options === "function") {
|
1109
|
-
callback = options;
|
1110
|
-
options = null;
|
1111
|
-
}
|
1112
|
-
if (options == null) options = {};
|
1113
|
-
if (options.autoClose == null) options.autoClose = false;
|
1114
|
-
if (options.lazyEntries == null) options.lazyEntries = false;
|
1115
|
-
if (options.decodeStrings == null) options.decodeStrings = true;
|
1116
|
-
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
1117
|
-
if (options.strictFileNames == null) options.strictFileNames = false;
|
1118
|
-
if (callback == null) callback = defaultCallback;
|
1119
|
-
fs.fstat(fd, function(err, stats) {
|
1120
|
-
if (err) return callback(err);
|
1121
|
-
var reader = fd_slicer.createFromFd(fd, {autoClose: true});
|
1122
|
-
fromRandomAccessReader(reader, stats.size, options, callback);
|
1123
|
-
});
|
1124
|
-
}
|
1125
|
-
|
1126
|
-
function fromBuffer(buffer, options, callback) {
|
1127
|
-
if (typeof options === "function") {
|
1128
|
-
callback = options;
|
1129
|
-
options = null;
|
1130
|
-
}
|
1131
|
-
if (options == null) options = {};
|
1132
|
-
options.autoClose = false;
|
1133
|
-
if (options.lazyEntries == null) options.lazyEntries = false;
|
1134
|
-
if (options.decodeStrings == null) options.decodeStrings = true;
|
1135
|
-
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
1136
|
-
if (options.strictFileNames == null) options.strictFileNames = false;
|
1137
|
-
// limit the max chunk size. see https://github.com/thejoshwolfe/yauzl/issues/87
|
1138
|
-
var reader = fd_slicer.createFromBuffer(buffer, {maxChunkSize: 0x10000});
|
1139
|
-
fromRandomAccessReader(reader, buffer.length, options, callback);
|
1140
|
-
}
|
1141
|
-
|
1142
|
-
function fromRandomAccessReader(reader, totalSize, options, callback) {
|
1143
|
-
if (typeof options === "function") {
|
1144
|
-
callback = options;
|
1145
|
-
options = null;
|
1146
|
-
}
|
1147
|
-
if (options == null) options = {};
|
1148
|
-
if (options.autoClose == null) options.autoClose = true;
|
1149
|
-
if (options.lazyEntries == null) options.lazyEntries = false;
|
1150
|
-
if (options.decodeStrings == null) options.decodeStrings = true;
|
1151
|
-
var decodeStrings = !!options.decodeStrings;
|
1152
|
-
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
1153
|
-
if (options.strictFileNames == null) options.strictFileNames = false;
|
1154
|
-
if (callback == null) callback = defaultCallback;
|
1155
|
-
if (typeof totalSize !== "number") throw new Error("expected totalSize parameter to be a number");
|
1156
|
-
if (totalSize > Number.MAX_SAFE_INTEGER) {
|
1157
|
-
throw new Error("zip file too large. only file sizes up to 2^52 are supported due to JavaScript's Number type being an IEEE 754 double.");
|
1158
|
-
}
|
1159
|
-
|
1160
|
-
// the matching unref() call is in zipfile.close()
|
1161
|
-
reader.ref();
|
1162
|
-
|
1163
|
-
// eocdr means End of Central Directory Record.
|
1164
|
-
// search backwards for the eocdr signature.
|
1165
|
-
// the last field of the eocdr is a variable-length comment.
|
1166
|
-
// the comment size is encoded in a 2-byte field in the eocdr, which we can't find without trudging backwards through the comment to find it.
|
1167
|
-
// as a consequence of this design decision, it's possible to have ambiguous zip file metadata if a coherent eocdr was in the comment.
|
1168
|
-
// we search backwards for a eocdr signature, and hope that whoever made the zip file was smart enough to forbid the eocdr signature in the comment.
|
1169
|
-
var eocdrWithoutCommentSize = 22;
|
1170
|
-
var maxCommentSize = 0xffff; // 2-byte size
|
1171
|
-
var bufferSize = Math.min(eocdrWithoutCommentSize + maxCommentSize, totalSize);
|
1172
|
-
var buffer = newBuffer(bufferSize);
|
1173
|
-
var bufferReadStart = totalSize - buffer.length;
|
1174
|
-
readAndAssertNoEof(reader, buffer, 0, bufferSize, bufferReadStart, function(err) {
|
1175
|
-
if (err) return callback(err);
|
1176
|
-
for (var i = bufferSize - eocdrWithoutCommentSize; i >= 0; i -= 1) {
|
1177
|
-
if (buffer.readUInt32LE(i) !== 0x06054b50) continue;
|
1178
|
-
// found eocdr
|
1179
|
-
var eocdrBuffer = buffer.slice(i);
|
1180
|
-
|
1181
|
-
// 0 - End of central directory signature = 0x06054b50
|
1182
|
-
// 4 - Number of this disk
|
1183
|
-
var diskNumber = eocdrBuffer.readUInt16LE(4);
|
1184
|
-
if (diskNumber !== 0) {
|
1185
|
-
return callback(new Error("multi-disk zip files are not supported: found disk number: " + diskNumber));
|
1186
|
-
}
|
1187
|
-
// 6 - Disk where central directory starts
|
1188
|
-
// 8 - Number of central directory records on this disk
|
1189
|
-
// 10 - Total number of central directory records
|
1190
|
-
var entryCount = eocdrBuffer.readUInt16LE(10);
|
1191
|
-
// 12 - Size of central directory (bytes)
|
1192
|
-
// 16 - Offset of start of central directory, relative to start of archive
|
1193
|
-
var centralDirectoryOffset = eocdrBuffer.readUInt32LE(16);
|
1194
|
-
// 20 - Comment length
|
1195
|
-
var commentLength = eocdrBuffer.readUInt16LE(20);
|
1196
|
-
var expectedCommentLength = eocdrBuffer.length - eocdrWithoutCommentSize;
|
1197
|
-
if (commentLength !== expectedCommentLength) {
|
1198
|
-
return callback(new Error("invalid comment length. expected: " + expectedCommentLength + ". found: " + commentLength));
|
1199
|
-
}
|
1200
|
-
// 22 - Comment
|
1201
|
-
// the encoding is always cp437.
|
1202
|
-
var comment = decodeStrings ? decodeBuffer(eocdrBuffer, 22, eocdrBuffer.length, false)
|
1203
|
-
: eocdrBuffer.slice(22);
|
1204
|
-
|
1205
|
-
if (!(entryCount === 0xffff || centralDirectoryOffset === 0xffffffff)) {
|
1206
|
-
return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
|
1207
|
-
}
|
1208
|
-
|
1209
|
-
// ZIP64 format
|
1210
|
-
|
1211
|
-
// ZIP64 Zip64 end of central directory locator
|
1212
|
-
var zip64EocdlBuffer = newBuffer(20);
|
1213
|
-
var zip64EocdlOffset = bufferReadStart + i - zip64EocdlBuffer.length;
|
1214
|
-
readAndAssertNoEof(reader, zip64EocdlBuffer, 0, zip64EocdlBuffer.length, zip64EocdlOffset, function(err) {
|
1215
|
-
if (err) return callback(err);
|
1216
|
-
|
1217
|
-
// 0 - zip64 end of central dir locator signature = 0x07064b50
|
1218
|
-
if (zip64EocdlBuffer.readUInt32LE(0) !== 0x07064b50) {
|
1219
|
-
return callback(new Error("invalid zip64 end of central directory locator signature"));
|
1220
|
-
}
|
1221
|
-
// 4 - number of the disk with the start of the zip64 end of central directory
|
1222
|
-
// 8 - relative offset of the zip64 end of central directory record
|
1223
|
-
var zip64EocdrOffset = readUInt64LE(zip64EocdlBuffer, 8);
|
1224
|
-
// 16 - total number of disks
|
1225
|
-
|
1226
|
-
// ZIP64 end of central directory record
|
1227
|
-
var zip64EocdrBuffer = newBuffer(56);
|
1228
|
-
readAndAssertNoEof(reader, zip64EocdrBuffer, 0, zip64EocdrBuffer.length, zip64EocdrOffset, function(err) {
|
1229
|
-
if (err) return callback(err);
|
1230
|
-
|
1231
|
-
// 0 - zip64 end of central dir signature 4 bytes (0x06064b50)
|
1232
|
-
if (zip64EocdrBuffer.readUInt32LE(0) !== 0x06064b50) {
|
1233
|
-
return callback(new Error("invalid zip64 end of central directory record signature"));
|
1234
|
-
}
|
1235
|
-
// 4 - size of zip64 end of central directory record 8 bytes
|
1236
|
-
// 12 - version made by 2 bytes
|
1237
|
-
// 14 - version needed to extract 2 bytes
|
1238
|
-
// 16 - number of this disk 4 bytes
|
1239
|
-
// 20 - number of the disk with the start of the central directory 4 bytes
|
1240
|
-
// 24 - total number of entries in the central directory on this disk 8 bytes
|
1241
|
-
// 32 - total number of entries in the central directory 8 bytes
|
1242
|
-
entryCount = readUInt64LE(zip64EocdrBuffer, 32);
|
1243
|
-
// 40 - size of the central directory 8 bytes
|
1244
|
-
// 48 - offset of start of central directory with respect to the starting disk number 8 bytes
|
1245
|
-
centralDirectoryOffset = readUInt64LE(zip64EocdrBuffer, 48);
|
1246
|
-
// 56 - zip64 extensible data sector (variable size)
|
1247
|
-
return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
|
1248
|
-
});
|
1249
|
-
});
|
1250
|
-
return;
|
1251
|
-
}
|
1252
|
-
callback(new Error("end of central directory record signature not found"));
|
1253
|
-
});
|
1254
|
-
}
|
1255
|
-
|
1256
|
-
util.inherits(ZipFile, EventEmitter);
|
1257
|
-
function ZipFile(reader, centralDirectoryOffset, fileSize, entryCount, comment, autoClose, lazyEntries, decodeStrings, validateEntrySizes, strictFileNames) {
|
1258
|
-
var self = this;
|
1259
|
-
EventEmitter.call(self);
|
1260
|
-
self.reader = reader;
|
1261
|
-
// forward close events
|
1262
|
-
self.reader.on("error", function(err) {
|
1263
|
-
// error closing the fd
|
1264
|
-
emitError(self, err);
|
1265
|
-
});
|
1266
|
-
self.reader.once("close", function() {
|
1267
|
-
self.emit("close");
|
1268
|
-
});
|
1269
|
-
self.readEntryCursor = centralDirectoryOffset;
|
1270
|
-
self.fileSize = fileSize;
|
1271
|
-
self.entryCount = entryCount;
|
1272
|
-
self.comment = comment;
|
1273
|
-
self.entriesRead = 0;
|
1274
|
-
self.autoClose = !!autoClose;
|
1275
|
-
self.lazyEntries = !!lazyEntries;
|
1276
|
-
self.decodeStrings = !!decodeStrings;
|
1277
|
-
self.validateEntrySizes = !!validateEntrySizes;
|
1278
|
-
self.strictFileNames = !!strictFileNames;
|
1279
|
-
self.isOpen = true;
|
1280
|
-
self.emittedError = false;
|
1281
|
-
|
1282
|
-
if (!self.lazyEntries) self._readEntry();
|
1283
|
-
}
|
1284
|
-
ZipFile.prototype.close = function() {
|
1285
|
-
if (!this.isOpen) return;
|
1286
|
-
this.isOpen = false;
|
1287
|
-
this.reader.unref();
|
1288
|
-
};
|
1289
|
-
|
1290
|
-
function emitErrorAndAutoClose(self, err) {
|
1291
|
-
if (self.autoClose) self.close();
|
1292
|
-
emitError(self, err);
|
1293
|
-
}
|
1294
|
-
function emitError(self, err) {
|
1295
|
-
if (self.emittedError) return;
|
1296
|
-
self.emittedError = true;
|
1297
|
-
self.emit("error", err);
|
1298
|
-
}
|
1299
|
-
|
1300
|
-
ZipFile.prototype.readEntry = function() {
|
1301
|
-
if (!this.lazyEntries) throw new Error("readEntry() called without lazyEntries:true");
|
1302
|
-
this._readEntry();
|
1303
|
-
};
|
1304
|
-
ZipFile.prototype._readEntry = function() {
|
1305
|
-
var self = this;
|
1306
|
-
if (self.entryCount === self.entriesRead) {
|
1307
|
-
// done with metadata
|
1308
|
-
setImmediate(function() {
|
1309
|
-
if (self.autoClose) self.close();
|
1310
|
-
if (self.emittedError) return;
|
1311
|
-
self.emit("end");
|
1312
|
-
});
|
1313
|
-
return;
|
1314
|
-
}
|
1315
|
-
if (self.emittedError) return;
|
1316
|
-
var buffer = newBuffer(46);
|
1317
|
-
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err) {
|
1318
|
-
if (err) return emitErrorAndAutoClose(self, err);
|
1319
|
-
if (self.emittedError) return;
|
1320
|
-
var entry = new Entry();
|
1321
|
-
// 0 - Central directory file header signature
|
1322
|
-
var signature = buffer.readUInt32LE(0);
|
1323
|
-
if (signature !== 0x02014b50) return emitErrorAndAutoClose(self, new Error("invalid central directory file header signature: 0x" + signature.toString(16)));
|
1324
|
-
// 4 - Version made by
|
1325
|
-
entry.versionMadeBy = buffer.readUInt16LE(4);
|
1326
|
-
// 6 - Version needed to extract (minimum)
|
1327
|
-
entry.versionNeededToExtract = buffer.readUInt16LE(6);
|
1328
|
-
// 8 - General purpose bit flag
|
1329
|
-
entry.generalPurposeBitFlag = buffer.readUInt16LE(8);
|
1330
|
-
// 10 - Compression method
|
1331
|
-
entry.compressionMethod = buffer.readUInt16LE(10);
|
1332
|
-
// 12 - File last modification time
|
1333
|
-
entry.lastModFileTime = buffer.readUInt16LE(12);
|
1334
|
-
// 14 - File last modification date
|
1335
|
-
entry.lastModFileDate = buffer.readUInt16LE(14);
|
1336
|
-
// 16 - CRC-32
|
1337
|
-
entry.crc32 = buffer.readUInt32LE(16);
|
1338
|
-
// 20 - Compressed size
|
1339
|
-
entry.compressedSize = buffer.readUInt32LE(20);
|
1340
|
-
// 24 - Uncompressed size
|
1341
|
-
entry.uncompressedSize = buffer.readUInt32LE(24);
|
1342
|
-
// 28 - File name length (n)
|
1343
|
-
entry.fileNameLength = buffer.readUInt16LE(28);
|
1344
|
-
// 30 - Extra field length (m)
|
1345
|
-
entry.extraFieldLength = buffer.readUInt16LE(30);
|
1346
|
-
// 32 - File comment length (k)
|
1347
|
-
entry.fileCommentLength = buffer.readUInt16LE(32);
|
1348
|
-
// 34 - Disk number where file starts
|
1349
|
-
// 36 - Internal file attributes
|
1350
|
-
entry.internalFileAttributes = buffer.readUInt16LE(36);
|
1351
|
-
// 38 - External file attributes
|
1352
|
-
entry.externalFileAttributes = buffer.readUInt32LE(38);
|
1353
|
-
// 42 - Relative offset of local file header
|
1354
|
-
entry.relativeOffsetOfLocalHeader = buffer.readUInt32LE(42);
|
1355
|
-
|
1356
|
-
if (entry.generalPurposeBitFlag & 0x40) return emitErrorAndAutoClose(self, new Error("strong encryption is not supported"));
|
1357
|
-
|
1358
|
-
self.readEntryCursor += 46;
|
1359
|
-
|
1360
|
-
buffer = newBuffer(entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
|
1361
|
-
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err) {
|
1362
|
-
if (err) return emitErrorAndAutoClose(self, err);
|
1363
|
-
if (self.emittedError) return;
|
1364
|
-
// 46 - File name
|
1365
|
-
var isUtf8 = (entry.generalPurposeBitFlag & 0x800) !== 0;
|
1366
|
-
entry.fileName = self.decodeStrings ? decodeBuffer(buffer, 0, entry.fileNameLength, isUtf8)
|
1367
|
-
: buffer.slice(0, entry.fileNameLength);
|
1368
|
-
|
1369
|
-
// 46+n - Extra field
|
1370
|
-
var fileCommentStart = entry.fileNameLength + entry.extraFieldLength;
|
1371
|
-
var extraFieldBuffer = buffer.slice(entry.fileNameLength, fileCommentStart);
|
1372
|
-
entry.extraFields = [];
|
1373
|
-
var i = 0;
|
1374
|
-
while (i < extraFieldBuffer.length - 3) {
|
1375
|
-
var headerId = extraFieldBuffer.readUInt16LE(i + 0);
|
1376
|
-
var dataSize = extraFieldBuffer.readUInt16LE(i + 2);
|
1377
|
-
var dataStart = i + 4;
|
1378
|
-
var dataEnd = dataStart + dataSize;
|
1379
|
-
if (dataEnd > extraFieldBuffer.length) return emitErrorAndAutoClose(self, new Error("extra field length exceeds extra field buffer size"));
|
1380
|
-
var dataBuffer = newBuffer(dataSize);
|
1381
|
-
extraFieldBuffer.copy(dataBuffer, 0, dataStart, dataEnd);
|
1382
|
-
entry.extraFields.push({
|
1383
|
-
id: headerId,
|
1384
|
-
data: dataBuffer,
|
1385
|
-
});
|
1386
|
-
i = dataEnd;
|
1387
|
-
}
|
1388
|
-
|
1389
|
-
// 46+n+m - File comment
|
1390
|
-
entry.fileComment = self.decodeStrings ? decodeBuffer(buffer, fileCommentStart, fileCommentStart + entry.fileCommentLength, isUtf8)
|
1391
|
-
: buffer.slice(fileCommentStart, fileCommentStart + entry.fileCommentLength);
|
1392
|
-
// compatibility hack for https://github.com/thejoshwolfe/yauzl/issues/47
|
1393
|
-
entry.comment = entry.fileComment;
|
1394
|
-
|
1395
|
-
self.readEntryCursor += buffer.length;
|
1396
|
-
self.entriesRead += 1;
|
1397
|
-
|
1398
|
-
if (entry.uncompressedSize === 0xffffffff ||
|
1399
|
-
entry.compressedSize === 0xffffffff ||
|
1400
|
-
entry.relativeOffsetOfLocalHeader === 0xffffffff) {
|
1401
|
-
// ZIP64 format
|
1402
|
-
// find the Zip64 Extended Information Extra Field
|
1403
|
-
var zip64EiefBuffer = null;
|
1404
|
-
for (var i = 0; i < entry.extraFields.length; i++) {
|
1405
|
-
var extraField = entry.extraFields[i];
|
1406
|
-
if (extraField.id === 0x0001) {
|
1407
|
-
zip64EiefBuffer = extraField.data;
|
1408
|
-
break;
|
1409
|
-
}
|
1410
|
-
}
|
1411
|
-
if (zip64EiefBuffer == null) {
|
1412
|
-
return emitErrorAndAutoClose(self, new Error("expected zip64 extended information extra field"));
|
1413
|
-
}
|
1414
|
-
var index = 0;
|
1415
|
-
// 0 - Original Size 8 bytes
|
1416
|
-
if (entry.uncompressedSize === 0xffffffff) {
|
1417
|
-
if (index + 8 > zip64EiefBuffer.length) {
|
1418
|
-
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include uncompressed size"));
|
1419
|
-
}
|
1420
|
-
entry.uncompressedSize = readUInt64LE(zip64EiefBuffer, index);
|
1421
|
-
index += 8;
|
1422
|
-
}
|
1423
|
-
// 8 - Compressed Size 8 bytes
|
1424
|
-
if (entry.compressedSize === 0xffffffff) {
|
1425
|
-
if (index + 8 > zip64EiefBuffer.length) {
|
1426
|
-
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include compressed size"));
|
1427
|
-
}
|
1428
|
-
entry.compressedSize = readUInt64LE(zip64EiefBuffer, index);
|
1429
|
-
index += 8;
|
1430
|
-
}
|
1431
|
-
// 16 - Relative Header Offset 8 bytes
|
1432
|
-
if (entry.relativeOffsetOfLocalHeader === 0xffffffff) {
|
1433
|
-
if (index + 8 > zip64EiefBuffer.length) {
|
1434
|
-
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include relative header offset"));
|
1435
|
-
}
|
1436
|
-
entry.relativeOffsetOfLocalHeader = readUInt64LE(zip64EiefBuffer, index);
|
1437
|
-
index += 8;
|
1438
|
-
}
|
1439
|
-
// 24 - Disk Start Number 4 bytes
|
1440
|
-
}
|
1441
|
-
|
1442
|
-
// check for Info-ZIP Unicode Path Extra Field (0x7075)
|
1443
|
-
// see https://github.com/thejoshwolfe/yauzl/issues/33
|
1444
|
-
if (self.decodeStrings) {
|
1445
|
-
for (var i = 0; i < entry.extraFields.length; i++) {
|
1446
|
-
var extraField = entry.extraFields[i];
|
1447
|
-
if (extraField.id === 0x7075) {
|
1448
|
-
if (extraField.data.length < 6) {
|
1449
|
-
// too short to be meaningful
|
1450
|
-
continue;
|
1451
|
-
}
|
1452
|
-
// Version 1 byte version of this extra field, currently 1
|
1453
|
-
if (extraField.data.readUInt8(0) !== 1) {
|
1454
|
-
// > Changes may not be backward compatible so this extra
|
1455
|
-
// > field should not be used if the version is not recognized.
|
1456
|
-
continue;
|
1457
|
-
}
|
1458
|
-
// NameCRC32 4 bytes File Name Field CRC32 Checksum
|
1459
|
-
var oldNameCrc32 = extraField.data.readUInt32LE(1);
|
1460
|
-
if (crc32.unsigned(buffer.slice(0, entry.fileNameLength)) !== oldNameCrc32) {
|
1461
|
-
// > If the CRC check fails, this UTF-8 Path Extra Field should be
|
1462
|
-
// > ignored and the File Name field in the header should be used instead.
|
1463
|
-
continue;
|
1464
|
-
}
|
1465
|
-
// UnicodeName Variable UTF-8 version of the entry File Name
|
1466
|
-
entry.fileName = decodeBuffer(extraField.data, 5, extraField.data.length, true);
|
1467
|
-
break;
|
1468
|
-
}
|
1469
|
-
}
|
1470
|
-
}
|
1471
|
-
|
1472
|
-
// validate file size
|
1473
|
-
if (self.validateEntrySizes && entry.compressionMethod === 0) {
|
1474
|
-
var expectedCompressedSize = entry.uncompressedSize;
|
1475
|
-
if (entry.isEncrypted()) {
|
1476
|
-
// traditional encryption prefixes the file data with a header
|
1477
|
-
expectedCompressedSize += 12;
|
1478
|
-
}
|
1479
|
-
if (entry.compressedSize !== expectedCompressedSize) {
|
1480
|
-
var msg = "compressed/uncompressed size mismatch for stored file: " + entry.compressedSize + " != " + entry.uncompressedSize;
|
1481
|
-
return emitErrorAndAutoClose(self, new Error(msg));
|
1482
|
-
}
|
1483
|
-
}
|
1484
|
-
|
1485
|
-
if (self.decodeStrings) {
|
1486
|
-
if (!self.strictFileNames) {
|
1487
|
-
// allow backslash
|
1488
|
-
entry.fileName = entry.fileName.replace(/\\/g, "/");
|
1489
|
-
}
|
1490
|
-
var errorMessage = validateFileName(entry.fileName, self.validateFileNameOptions);
|
1491
|
-
if (errorMessage != null) return emitErrorAndAutoClose(self, new Error(errorMessage));
|
1492
|
-
}
|
1493
|
-
self.emit("entry", entry);
|
1494
|
-
|
1495
|
-
if (!self.lazyEntries) self._readEntry();
|
1496
|
-
});
|
1497
|
-
});
|
1498
|
-
};
|
1499
|
-
|
1500
|
-
ZipFile.prototype.openReadStream = function(entry, options, callback) {
|
1501
|
-
var self = this;
|
1502
|
-
// parameter validation
|
1503
|
-
var relativeStart = 0;
|
1504
|
-
var relativeEnd = entry.compressedSize;
|
1505
|
-
if (callback == null) {
|
1506
|
-
callback = options;
|
1507
|
-
options = {};
|
1508
|
-
} else {
|
1509
|
-
// validate options that the caller has no excuse to get wrong
|
1510
|
-
if (options.decrypt != null) {
|
1511
|
-
if (!entry.isEncrypted()) {
|
1512
|
-
throw new Error("options.decrypt can only be specified for encrypted entries");
|
1513
|
-
}
|
1514
|
-
if (options.decrypt !== false) throw new Error("invalid options.decrypt value: " + options.decrypt);
|
1515
|
-
if (entry.isCompressed()) {
|
1516
|
-
if (options.decompress !== false) throw new Error("entry is encrypted and compressed, and options.decompress !== false");
|
1517
|
-
}
|
1518
|
-
}
|
1519
|
-
if (options.decompress != null) {
|
1520
|
-
if (!entry.isCompressed()) {
|
1521
|
-
throw new Error("options.decompress can only be specified for compressed entries");
|
1522
|
-
}
|
1523
|
-
if (!(options.decompress === false || options.decompress === true)) {
|
1524
|
-
throw new Error("invalid options.decompress value: " + options.decompress);
|
1525
|
-
}
|
1526
|
-
}
|
1527
|
-
if (options.start != null || options.end != null) {
|
1528
|
-
if (entry.isCompressed() && options.decompress !== false) {
|
1529
|
-
throw new Error("start/end range not allowed for compressed entry without options.decompress === false");
|
1530
|
-
}
|
1531
|
-
if (entry.isEncrypted() && options.decrypt !== false) {
|
1532
|
-
throw new Error("start/end range not allowed for encrypted entry without options.decrypt === false");
|
1533
|
-
}
|
1534
|
-
}
|
1535
|
-
if (options.start != null) {
|
1536
|
-
relativeStart = options.start;
|
1537
|
-
if (relativeStart < 0) throw new Error("options.start < 0");
|
1538
|
-
if (relativeStart > entry.compressedSize) throw new Error("options.start > entry.compressedSize");
|
1539
|
-
}
|
1540
|
-
if (options.end != null) {
|
1541
|
-
relativeEnd = options.end;
|
1542
|
-
if (relativeEnd < 0) throw new Error("options.end < 0");
|
1543
|
-
if (relativeEnd > entry.compressedSize) throw new Error("options.end > entry.compressedSize");
|
1544
|
-
if (relativeEnd < relativeStart) throw new Error("options.end < options.start");
|
1545
|
-
}
|
1546
|
-
}
|
1547
|
-
// any further errors can either be caused by the zipfile,
|
1548
|
-
// or were introduced in a minor version of yauzl,
|
1549
|
-
// so should be passed to the client rather than thrown.
|
1550
|
-
if (!self.isOpen) return callback(new Error("closed"));
|
1551
|
-
if (entry.isEncrypted()) {
|
1552
|
-
if (options.decrypt !== false) return callback(new Error("entry is encrypted, and options.decrypt !== false"));
|
1553
|
-
}
|
1554
|
-
// make sure we don't lose the fd before we open the actual read stream
|
1555
|
-
self.reader.ref();
|
1556
|
-
var buffer = newBuffer(30);
|
1557
|
-
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, entry.relativeOffsetOfLocalHeader, function(err) {
|
1558
|
-
try {
|
1559
|
-
if (err) return callback(err);
|
1560
|
-
// 0 - Local file header signature = 0x04034b50
|
1561
|
-
var signature = buffer.readUInt32LE(0);
|
1562
|
-
if (signature !== 0x04034b50) {
|
1563
|
-
return callback(new Error("invalid local file header signature: 0x" + signature.toString(16)));
|
1564
|
-
}
|
1565
|
-
// all this should be redundant
|
1566
|
-
// 4 - Version needed to extract (minimum)
|
1567
|
-
// 6 - General purpose bit flag
|
1568
|
-
// 8 - Compression method
|
1569
|
-
// 10 - File last modification time
|
1570
|
-
// 12 - File last modification date
|
1571
|
-
// 14 - CRC-32
|
1572
|
-
// 18 - Compressed size
|
1573
|
-
// 22 - Uncompressed size
|
1574
|
-
// 26 - File name length (n)
|
1575
|
-
var fileNameLength = buffer.readUInt16LE(26);
|
1576
|
-
// 28 - Extra field length (m)
|
1577
|
-
var extraFieldLength = buffer.readUInt16LE(28);
|
1578
|
-
// 30 - File name
|
1579
|
-
// 30+n - Extra field
|
1580
|
-
var localFileHeaderEnd = entry.relativeOffsetOfLocalHeader + buffer.length + fileNameLength + extraFieldLength;
|
1581
|
-
var decompress;
|
1582
|
-
if (entry.compressionMethod === 0) {
|
1583
|
-
// 0 - The file is stored (no compression)
|
1584
|
-
decompress = false;
|
1585
|
-
} else if (entry.compressionMethod === 8) {
|
1586
|
-
// 8 - The file is Deflated
|
1587
|
-
decompress = options.decompress != null ? options.decompress : true;
|
1588
|
-
} else {
|
1589
|
-
return callback(new Error("unsupported compression method: " + entry.compressionMethod));
|
1590
|
-
}
|
1591
|
-
var fileDataStart = localFileHeaderEnd;
|
1592
|
-
var fileDataEnd = fileDataStart + entry.compressedSize;
|
1593
|
-
if (entry.compressedSize !== 0) {
|
1594
|
-
// bounds check now, because the read streams will probably not complain loud enough.
|
1595
|
-
// since we're dealing with an unsigned offset plus an unsigned size,
|
1596
|
-
// we only have 1 thing to check for.
|
1597
|
-
if (fileDataEnd > self.fileSize) {
|
1598
|
-
return callback(new Error("file data overflows file bounds: " +
|
1599
|
-
fileDataStart + " + " + entry.compressedSize + " > " + self.fileSize));
|
1600
|
-
}
|
1601
|
-
}
|
1602
|
-
var readStream = self.reader.createReadStream({
|
1603
|
-
start: fileDataStart + relativeStart,
|
1604
|
-
end: fileDataStart + relativeEnd,
|
1605
|
-
});
|
1606
|
-
var endpointStream = readStream;
|
1607
|
-
if (decompress) {
|
1608
|
-
var destroyed = false;
|
1609
|
-
var inflateFilter = zlib.createInflateRaw();
|
1610
|
-
readStream.on("error", function(err) {
|
1611
|
-
// setImmediate here because errors can be emitted during the first call to pipe()
|
1612
|
-
setImmediate(function() {
|
1613
|
-
if (!destroyed) inflateFilter.emit("error", err);
|
1614
|
-
});
|
1615
|
-
});
|
1616
|
-
readStream.pipe(inflateFilter);
|
1617
|
-
|
1618
|
-
if (self.validateEntrySizes) {
|
1619
|
-
endpointStream = new AssertByteCountStream(entry.uncompressedSize);
|
1620
|
-
inflateFilter.on("error", function(err) {
|
1621
|
-
// forward zlib errors to the client-visible stream
|
1622
|
-
setImmediate(function() {
|
1623
|
-
if (!destroyed) endpointStream.emit("error", err);
|
1624
|
-
});
|
1625
|
-
});
|
1626
|
-
inflateFilter.pipe(endpointStream);
|
1627
|
-
} else {
|
1628
|
-
// the zlib filter is the client-visible stream
|
1629
|
-
endpointStream = inflateFilter;
|
1630
|
-
}
|
1631
|
-
// this is part of yauzl's API, so implement this function on the client-visible stream
|
1632
|
-
endpointStream.destroy = function() {
|
1633
|
-
destroyed = true;
|
1634
|
-
if (inflateFilter !== endpointStream) inflateFilter.unpipe(endpointStream);
|
1635
|
-
readStream.unpipe(inflateFilter);
|
1636
|
-
// TODO: the inflateFilter may cause a memory leak. see Issue #27.
|
1637
|
-
readStream.destroy();
|
1638
|
-
};
|
1639
|
-
}
|
1640
|
-
callback(null, endpointStream);
|
1641
|
-
} finally {
|
1642
|
-
self.reader.unref();
|
1643
|
-
}
|
1644
|
-
});
|
1645
|
-
};
|
1646
|
-
|
1647
|
-
function Entry() {
|
1648
|
-
}
|
1649
|
-
Entry.prototype.getLastModDate = function() {
|
1650
|
-
return dosDateTimeToDate(this.lastModFileDate, this.lastModFileTime);
|
1651
|
-
};
|
1652
|
-
Entry.prototype.isEncrypted = function() {
|
1653
|
-
return (this.generalPurposeBitFlag & 0x1) !== 0;
|
1654
|
-
};
|
1655
|
-
Entry.prototype.isCompressed = function() {
|
1656
|
-
return this.compressionMethod === 8;
|
1657
|
-
};
|
1658
|
-
|
1659
|
-
function dosDateTimeToDate(date, time) {
|
1660
|
-
var day = date & 0x1f; // 1-31
|
1661
|
-
var month = (date >> 5 & 0xf) - 1; // 1-12, 0-11
|
1662
|
-
var year = (date >> 9 & 0x7f) + 1980; // 0-128, 1980-2108
|
1663
|
-
|
1664
|
-
var millisecond = 0;
|
1665
|
-
var second = (time & 0x1f) * 2; // 0-29, 0-58 (even numbers)
|
1666
|
-
var minute = time >> 5 & 0x3f; // 0-59
|
1667
|
-
var hour = time >> 11 & 0x1f; // 0-23
|
1668
|
-
|
1669
|
-
return new Date(year, month, day, hour, minute, second, millisecond);
|
1670
|
-
}
|
1671
|
-
|
1672
|
-
function validateFileName(fileName) {
|
1673
|
-
if (fileName.indexOf("\\") !== -1) {
|
1674
|
-
return "invalid characters in fileName: " + fileName;
|
1675
|
-
}
|
1676
|
-
if (/^[a-zA-Z]:/.test(fileName) || /^\//.test(fileName)) {
|
1677
|
-
return "absolute path: " + fileName;
|
1678
|
-
}
|
1679
|
-
if (fileName.split("/").indexOf("..") !== -1) {
|
1680
|
-
return "invalid relative path: " + fileName;
|
1681
|
-
}
|
1682
|
-
// all good
|
1683
|
-
return null;
|
1684
|
-
}
|
1685
|
-
|
1686
|
-
function readAndAssertNoEof(reader, buffer, offset, length, position, callback) {
|
1687
|
-
if (length === 0) {
|
1688
|
-
// fs.read will throw an out-of-bounds error if you try to read 0 bytes from a 0 byte file
|
1689
|
-
return setImmediate(function() { callback(null, newBuffer(0)); });
|
1690
|
-
}
|
1691
|
-
reader.read(buffer, offset, length, position, function(err, bytesRead) {
|
1692
|
-
if (err) return callback(err);
|
1693
|
-
if (bytesRead < length) {
|
1694
|
-
return callback(new Error("unexpected EOF"));
|
1695
|
-
}
|
1696
|
-
callback();
|
1697
|
-
});
|
1698
|
-
}
|
1699
|
-
|
1700
|
-
util.inherits(AssertByteCountStream, Transform);
|
1701
|
-
function AssertByteCountStream(byteCount) {
|
1702
|
-
Transform.call(this);
|
1703
|
-
this.actualByteCount = 0;
|
1704
|
-
this.expectedByteCount = byteCount;
|
1705
|
-
}
|
1706
|
-
AssertByteCountStream.prototype._transform = function(chunk, encoding, cb) {
|
1707
|
-
this.actualByteCount += chunk.length;
|
1708
|
-
if (this.actualByteCount > this.expectedByteCount) {
|
1709
|
-
var msg = "too many bytes in the stream. expected " + this.expectedByteCount + ". got at least " + this.actualByteCount;
|
1710
|
-
return cb(new Error(msg));
|
1711
|
-
}
|
1712
|
-
cb(null, chunk);
|
1713
|
-
};
|
1714
|
-
AssertByteCountStream.prototype._flush = function(cb) {
|
1715
|
-
if (this.actualByteCount < this.expectedByteCount) {
|
1716
|
-
var msg = "not enough bytes in the stream. expected " + this.expectedByteCount + ". got only " + this.actualByteCount;
|
1717
|
-
return cb(new Error(msg));
|
1718
|
-
}
|
1719
|
-
cb();
|
1720
|
-
};
|
1721
|
-
|
1722
|
-
util.inherits(RandomAccessReader, EventEmitter);
|
1723
|
-
function RandomAccessReader() {
|
1724
|
-
EventEmitter.call(this);
|
1725
|
-
this.refCount = 0;
|
1726
|
-
}
|
1727
|
-
RandomAccessReader.prototype.ref = function() {
|
1728
|
-
this.refCount += 1;
|
1729
|
-
};
|
1730
|
-
RandomAccessReader.prototype.unref = function() {
|
1731
|
-
var self = this;
|
1732
|
-
self.refCount -= 1;
|
1733
|
-
|
1734
|
-
if (self.refCount > 0) return;
|
1735
|
-
if (self.refCount < 0) throw new Error("invalid unref");
|
1736
|
-
|
1737
|
-
self.close(onCloseDone);
|
1738
|
-
|
1739
|
-
function onCloseDone(err) {
|
1740
|
-
if (err) return self.emit('error', err);
|
1741
|
-
self.emit('close');
|
1742
|
-
}
|
1743
|
-
};
|
1744
|
-
RandomAccessReader.prototype.createReadStream = function(options) {
|
1745
|
-
var start = options.start;
|
1746
|
-
var end = options.end;
|
1747
|
-
if (start === end) {
|
1748
|
-
var emptyStream = new PassThrough();
|
1749
|
-
setImmediate(function() {
|
1750
|
-
emptyStream.end();
|
1751
|
-
});
|
1752
|
-
return emptyStream;
|
1753
|
-
}
|
1754
|
-
var stream = this._readStreamForRange(start, end);
|
1755
|
-
|
1756
|
-
var destroyed = false;
|
1757
|
-
var refUnrefFilter = new RefUnrefFilter(this);
|
1758
|
-
stream.on("error", function(err) {
|
1759
|
-
setImmediate(function() {
|
1760
|
-
if (!destroyed) refUnrefFilter.emit("error", err);
|
1761
|
-
});
|
1762
|
-
});
|
1763
|
-
refUnrefFilter.destroy = function() {
|
1764
|
-
stream.unpipe(refUnrefFilter);
|
1765
|
-
refUnrefFilter.unref();
|
1766
|
-
stream.destroy();
|
1767
|
-
};
|
1768
|
-
|
1769
|
-
var byteCounter = new AssertByteCountStream(end - start);
|
1770
|
-
refUnrefFilter.on("error", function(err) {
|
1771
|
-
setImmediate(function() {
|
1772
|
-
if (!destroyed) byteCounter.emit("error", err);
|
1773
|
-
});
|
1774
|
-
});
|
1775
|
-
byteCounter.destroy = function() {
|
1776
|
-
destroyed = true;
|
1777
|
-
refUnrefFilter.unpipe(byteCounter);
|
1778
|
-
refUnrefFilter.destroy();
|
1779
|
-
};
|
1780
|
-
|
1781
|
-
return stream.pipe(refUnrefFilter).pipe(byteCounter);
|
1782
|
-
};
|
1783
|
-
RandomAccessReader.prototype._readStreamForRange = function(start, end) {
|
1784
|
-
throw new Error("not implemented");
|
1785
|
-
};
|
1786
|
-
RandomAccessReader.prototype.read = function(buffer, offset, length, position, callback) {
|
1787
|
-
var readStream = this.createReadStream({start: position, end: position + length});
|
1788
|
-
var writeStream = new Writable();
|
1789
|
-
var written = 0;
|
1790
|
-
writeStream._write = function(chunk, encoding, cb) {
|
1791
|
-
chunk.copy(buffer, offset + written, 0, chunk.length);
|
1792
|
-
written += chunk.length;
|
1793
|
-
cb();
|
1794
|
-
};
|
1795
|
-
writeStream.on("finish", callback);
|
1796
|
-
readStream.on("error", function(error) {
|
1797
|
-
callback(error);
|
1798
|
-
});
|
1799
|
-
readStream.pipe(writeStream);
|
1800
|
-
};
|
1801
|
-
RandomAccessReader.prototype.close = function(callback) {
|
1802
|
-
setImmediate(callback);
|
1803
|
-
};
|
1804
|
-
|
1805
|
-
util.inherits(RefUnrefFilter, PassThrough);
|
1806
|
-
function RefUnrefFilter(context) {
|
1807
|
-
PassThrough.call(this);
|
1808
|
-
this.context = context;
|
1809
|
-
this.context.ref();
|
1810
|
-
this.unreffedYet = false;
|
1811
|
-
}
|
1812
|
-
RefUnrefFilter.prototype._flush = function(cb) {
|
1813
|
-
this.unref();
|
1814
|
-
cb();
|
1815
|
-
};
|
1816
|
-
RefUnrefFilter.prototype.unref = function(cb) {
|
1817
|
-
if (this.unreffedYet) return;
|
1818
|
-
this.unreffedYet = true;
|
1819
|
-
this.context.unref();
|
1820
|
-
};
|
1821
|
-
|
1822
|
-
var cp437 = '\u0000☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ';
|
1823
|
-
function decodeBuffer(buffer, start, end, isUtf8) {
|
1824
|
-
if (isUtf8) {
|
1825
|
-
return buffer.toString("utf8", start, end);
|
1826
|
-
} else {
|
1827
|
-
var result = "";
|
1828
|
-
for (var i = start; i < end; i++) {
|
1829
|
-
result += cp437[buffer[i]];
|
1830
|
-
}
|
1831
|
-
return result;
|
1832
|
-
}
|
1833
|
-
}
|
1834
|
-
|
1835
|
-
function readUInt64LE(buffer, offset) {
|
1836
|
-
// there is no native function for this, because we can't actually store 64-bit integers precisely.
|
1837
|
-
// after 53 bits, JavaScript's Number type (IEEE 754 double) can't store individual integers anymore.
|
1838
|
-
// but since 53 bits is a whole lot more than 32 bits, we do our best anyway.
|
1839
|
-
var lower32 = buffer.readUInt32LE(offset);
|
1840
|
-
var upper32 = buffer.readUInt32LE(offset + 4);
|
1841
|
-
// we can't use bitshifting here, because JavaScript bitshifting only works on 32-bit integers.
|
1842
|
-
return upper32 * 0x100000000 + lower32;
|
1843
|
-
// as long as we're bounds checking the result of this function against the total file size,
|
1844
|
-
// we'll catch any overflow errors, because we already made sure the total file size was within reason.
|
1845
|
-
}
|
1846
|
-
|
1847
|
-
// Node 10 deprecated new Buffer().
|
1848
|
-
var newBuffer;
|
1849
|
-
if (typeof Buffer.allocUnsafe === "function") {
|
1850
|
-
newBuffer = function(len) {
|
1851
|
-
return Buffer.allocUnsafe(len);
|
1852
|
-
};
|
1853
|
-
} else {
|
1854
|
-
newBuffer = function(len) {
|
1855
|
-
return new Buffer(len);
|
1856
|
-
};
|
1857
|
-
}
|
1858
|
-
|
1859
|
-
function defaultCallback(err) {
|
1860
|
-
if (err) throw err;
|
1861
|
-
}
|
1862
|
-
|
1863
|
-
|
1864
|
-
/***/ })
|
1865
|
-
|
1866
|
-
};
|
1867
|
-
;
|