analogger 1.28.3 → 1.29.2
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/README.md +48 -1
- package/ana-logger.d.cts +3 -1
- package/browser/ana-logger.mjs +18 -6
- package/demo.cjs +12 -2
- package/dist/analogger-browser.min.mjs +3 -3
- package/dist/html-to-image-plugin.min.mjs +3 -3
- package/esm/ana-logger.mjs +18 -6
- package/package.json +1 -1
- package/src/ana-logger.cjs +18 -6
- package/browser/imported/adm-zip/adm-zip.mjs +0 -959
- package/browser/imported/adm-zip/zipEntry.mjs +0 -414
- package/browser/imported/adm-zip/zipFile.mjs +0 -455
- package/esm/node_modules/adm-zip/adm-zip.mjs +0 -959
- package/esm/node_modules/adm-zip/zipEntry.mjs +0 -414
- package/esm/node_modules/adm-zip/zipFile.mjs +0 -455
|
@@ -1,414 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DO NOT EDIT THIS FILE DIRECTLY.
|
|
3
|
-
* This file is generated following the conversion of
|
|
4
|
-
* @see [./node_modules/adm-zip/zipEntry.js]{@link ./node_modules/adm-zip/zipEntry.js}
|
|
5
|
-
*
|
|
6
|
-
**/
|
|
7
|
-
import _toesmTemp1 from "./util.mjs";
|
|
8
|
-
var Utils = _toesmTemp1,
|
|
9
|
-
|
|
10
|
-
Headers = require("./headers"),
|
|
11
|
-
Constants = Utils.Constants,
|
|
12
|
-
Methods = require("./methods");
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export default function (/** object */ options, /*Buffer*/ input) {
|
|
16
|
-
var _centralHeader = new Headers.EntryHeader(),
|
|
17
|
-
_entryName = Buffer.alloc(0),
|
|
18
|
-
_comment = Buffer.alloc(0),
|
|
19
|
-
_isDirectory = false,
|
|
20
|
-
uncompressedData = null,
|
|
21
|
-
_extra = Buffer.alloc(0),
|
|
22
|
-
_extralocal = Buffer.alloc(0),
|
|
23
|
-
_efs = true;
|
|
24
|
-
|
|
25
|
-
// assign options
|
|
26
|
-
const opts = options;
|
|
27
|
-
|
|
28
|
-
const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
|
|
29
|
-
_efs = decoder.hasOwnProperty("efs") ? decoder.efs : false;
|
|
30
|
-
|
|
31
|
-
function getCompressedDataFromZip() {
|
|
32
|
-
//if (!input || !Buffer.isBuffer(input)) {
|
|
33
|
-
if (!input || !(input instanceof Uint8Array)) {
|
|
34
|
-
return Buffer.alloc(0);
|
|
35
|
-
}
|
|
36
|
-
_extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
|
|
37
|
-
return input.slice(_centralHeader.realDataOffset, _centralHeader.realDataOffset + _centralHeader.compressedSize);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function crc32OK(data) {
|
|
41
|
-
// if bit 3 (0x08) of the general-purpose flags field is set, then the CRC-32 and file sizes are not known when the local header is written
|
|
42
|
-
if (!_centralHeader.flags_desc) {
|
|
43
|
-
if (Utils.crc32(data) !== _centralHeader.localHeader.crc) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
} else {
|
|
47
|
-
const descriptor = {};
|
|
48
|
-
const dataEndOffset = _centralHeader.realDataOffset + _centralHeader.compressedSize;
|
|
49
|
-
// no descriptor after compressed data, instead new local header
|
|
50
|
-
if (input.readUInt32LE(dataEndOffset) == Constants.LOCSIG || input.readUInt32LE(dataEndOffset) == Constants.CENSIG) {
|
|
51
|
-
throw Utils.Errors.DESCRIPTOR_NOT_EXIST();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// get decriptor data
|
|
55
|
-
if (input.readUInt32LE(dataEndOffset) == Constants.EXTSIG) {
|
|
56
|
-
// descriptor with signature
|
|
57
|
-
descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC);
|
|
58
|
-
descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ);
|
|
59
|
-
descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN);
|
|
60
|
-
} else if (input.readUInt16LE(dataEndOffset + 12) === 0x4b50) {
|
|
61
|
-
// descriptor without signature (we check is new header starting where we expect)
|
|
62
|
-
descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC - 4);
|
|
63
|
-
descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ - 4);
|
|
64
|
-
descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN - 4);
|
|
65
|
-
} else {
|
|
66
|
-
throw Utils.Errors.DESCRIPTOR_UNKNOWN();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// check data integrity
|
|
70
|
-
if (descriptor.compressedSize !== _centralHeader.compressedSize || descriptor.size !== _centralHeader.size || descriptor.crc !== _centralHeader.crc) {
|
|
71
|
-
throw Utils.Errors.DESCRIPTOR_FAULTY();
|
|
72
|
-
}
|
|
73
|
-
if (Utils.crc32(data) !== descriptor.crc) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// @TODO: zip64 bit descriptor fields
|
|
78
|
-
// if bit 3 is set and any value in local header "zip64 Extended information" extra field are set 0 (place holder)
|
|
79
|
-
// then 64-bit descriptor format is used instead of 32-bit
|
|
80
|
-
// central header - "zip64 Extended information" extra field should store real values and not place holders
|
|
81
|
-
}
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function decompress(/*Boolean*/ async, /*Function*/ callback, /*String, Buffer*/ pass) {
|
|
86
|
-
if (typeof callback === "undefined" && typeof async === "string") {
|
|
87
|
-
pass = async;
|
|
88
|
-
async = void 0;
|
|
89
|
-
}
|
|
90
|
-
if (_isDirectory) {
|
|
91
|
-
if (async && callback) {
|
|
92
|
-
callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR()); //si added error.
|
|
93
|
-
}
|
|
94
|
-
return Buffer.alloc(0);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
var compressedData = getCompressedDataFromZip();
|
|
98
|
-
|
|
99
|
-
if (compressedData.length === 0) {
|
|
100
|
-
// File is empty, nothing to decompress.
|
|
101
|
-
if (async && callback) callback(compressedData);
|
|
102
|
-
return compressedData;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (_centralHeader.encrypted) {
|
|
106
|
-
if ("string" !== typeof pass && !Buffer.isBuffer(pass)) {
|
|
107
|
-
throw Utils.Errors.INVALID_PASS_PARAM();
|
|
108
|
-
}
|
|
109
|
-
compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
var data = Buffer.alloc(_centralHeader.size);
|
|
113
|
-
|
|
114
|
-
switch (_centralHeader.method) {
|
|
115
|
-
case Utils.Constants.STORED:
|
|
116
|
-
compressedData.copy(data);
|
|
117
|
-
if (!crc32OK(data)) {
|
|
118
|
-
if (async && callback) callback(data, Utils.Errors.BAD_CRC()); //si added error
|
|
119
|
-
throw Utils.Errors.BAD_CRC();
|
|
120
|
-
} else {
|
|
121
|
-
//si added otherwise did not seem to return data.
|
|
122
|
-
if (async && callback) callback(data);
|
|
123
|
-
return data;
|
|
124
|
-
}
|
|
125
|
-
case Utils.Constants.DEFLATED:
|
|
126
|
-
var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
|
|
127
|
-
if (!async) {
|
|
128
|
-
const result = inflater.inflate(data);
|
|
129
|
-
result.copy(data, 0);
|
|
130
|
-
if (!crc32OK(data)) {
|
|
131
|
-
throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
|
|
132
|
-
}
|
|
133
|
-
return data;
|
|
134
|
-
} else {
|
|
135
|
-
inflater.inflateAsync(function (result) {
|
|
136
|
-
result.copy(result, 0);
|
|
137
|
-
if (callback) {
|
|
138
|
-
if (!crc32OK(result)) {
|
|
139
|
-
callback(result, Utils.Errors.BAD_CRC()); //si added error
|
|
140
|
-
} else {
|
|
141
|
-
callback(result);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
break;
|
|
147
|
-
default:
|
|
148
|
-
if (async && callback) callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD());
|
|
149
|
-
throw Utils.Errors.UNKNOWN_METHOD();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function compress(/*Boolean*/ async, /*Function*/ callback) {
|
|
154
|
-
if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
|
|
155
|
-
// no data set or the data wasn't changed to require recompression
|
|
156
|
-
if (async && callback) callback(getCompressedDataFromZip());
|
|
157
|
-
return getCompressedDataFromZip();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (uncompressedData.length && !_isDirectory) {
|
|
161
|
-
var compressedData;
|
|
162
|
-
// Local file header
|
|
163
|
-
switch (_centralHeader.method) {
|
|
164
|
-
case Utils.Constants.STORED:
|
|
165
|
-
_centralHeader.compressedSize = _centralHeader.size;
|
|
166
|
-
|
|
167
|
-
compressedData = Buffer.alloc(uncompressedData.length);
|
|
168
|
-
uncompressedData.copy(compressedData);
|
|
169
|
-
|
|
170
|
-
if (async && callback) callback(compressedData);
|
|
171
|
-
return compressedData;
|
|
172
|
-
default:
|
|
173
|
-
case Utils.Constants.DEFLATED:
|
|
174
|
-
var deflater = new Methods.Deflater(uncompressedData);
|
|
175
|
-
if (!async) {
|
|
176
|
-
var deflated = deflater.deflate();
|
|
177
|
-
_centralHeader.compressedSize = deflated.length;
|
|
178
|
-
return deflated;
|
|
179
|
-
} else {
|
|
180
|
-
deflater.deflateAsync(function (data) {
|
|
181
|
-
compressedData = Buffer.alloc(data.length);
|
|
182
|
-
_centralHeader.compressedSize = data.length;
|
|
183
|
-
data.copy(compressedData);
|
|
184
|
-
callback && callback(compressedData);
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
deflater = null;
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
} else if (async && callback) {
|
|
191
|
-
callback(Buffer.alloc(0));
|
|
192
|
-
} else {
|
|
193
|
-
return Buffer.alloc(0);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function readUInt64LE(buffer, offset) {
|
|
198
|
-
return (buffer.readUInt32LE(offset + 4) << 4) + buffer.readUInt32LE(offset);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function parseExtra(data) {
|
|
202
|
-
try {
|
|
203
|
-
var offset = 0;
|
|
204
|
-
var signature, size, part;
|
|
205
|
-
while (offset + 4 < data.length) {
|
|
206
|
-
signature = data.readUInt16LE(offset);
|
|
207
|
-
offset += 2;
|
|
208
|
-
size = data.readUInt16LE(offset);
|
|
209
|
-
offset += 2;
|
|
210
|
-
part = data.slice(offset, offset + size);
|
|
211
|
-
offset += size;
|
|
212
|
-
if (Constants.ID_ZIP64 === signature) {
|
|
213
|
-
parseZip64ExtendedInformation(part);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
} catch (error) {
|
|
217
|
-
throw Utils.Errors.EXTRA_FIELD_PARSE_ERROR();
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
//Override header field values with values from the ZIP64 extra field
|
|
222
|
-
function parseZip64ExtendedInformation(data) {
|
|
223
|
-
var size, compressedSize, offset, diskNumStart;
|
|
224
|
-
|
|
225
|
-
if (data.length >= Constants.EF_ZIP64_SCOMP) {
|
|
226
|
-
size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
|
|
227
|
-
if (_centralHeader.size === Constants.EF_ZIP64_OR_32) {
|
|
228
|
-
_centralHeader.size = size;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
if (data.length >= Constants.EF_ZIP64_RHO) {
|
|
232
|
-
compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
|
|
233
|
-
if (_centralHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
|
|
234
|
-
_centralHeader.compressedSize = compressedSize;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
if (data.length >= Constants.EF_ZIP64_DSN) {
|
|
238
|
-
offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
|
|
239
|
-
if (_centralHeader.offset === Constants.EF_ZIP64_OR_32) {
|
|
240
|
-
_centralHeader.offset = offset;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
if (data.length >= Constants.EF_ZIP64_DSN + 4) {
|
|
244
|
-
diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
|
|
245
|
-
if (_centralHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
|
|
246
|
-
_centralHeader.diskNumStart = diskNumStart;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return {
|
|
252
|
-
get entryName() {
|
|
253
|
-
return decoder.decode(_entryName);
|
|
254
|
-
},
|
|
255
|
-
get rawEntryName() {
|
|
256
|
-
return _entryName;
|
|
257
|
-
},
|
|
258
|
-
set entryName(val) {
|
|
259
|
-
_entryName = Utils.toBuffer(val, decoder.encode);
|
|
260
|
-
var lastChar = _entryName[_entryName.length - 1];
|
|
261
|
-
_isDirectory = lastChar === 47 || lastChar === 92;
|
|
262
|
-
_centralHeader.fileNameLength = _entryName.length;
|
|
263
|
-
},
|
|
264
|
-
|
|
265
|
-
get efs() {
|
|
266
|
-
if (typeof _efs === "function") {
|
|
267
|
-
return _efs(this.entryName);
|
|
268
|
-
} else {
|
|
269
|
-
return _efs;
|
|
270
|
-
}
|
|
271
|
-
},
|
|
272
|
-
|
|
273
|
-
get extra() {
|
|
274
|
-
return _extra;
|
|
275
|
-
},
|
|
276
|
-
set extra(val) {
|
|
277
|
-
_extra = val;
|
|
278
|
-
_centralHeader.extraLength = val.length;
|
|
279
|
-
parseExtra(val);
|
|
280
|
-
},
|
|
281
|
-
|
|
282
|
-
get comment() {
|
|
283
|
-
return decoder.decode(_comment);
|
|
284
|
-
},
|
|
285
|
-
set comment(val) {
|
|
286
|
-
_comment = Utils.toBuffer(val, decoder.encode);
|
|
287
|
-
_centralHeader.commentLength = _comment.length;
|
|
288
|
-
if (_comment.length > 0xffff) throw Utils.Errors.COMMENT_TOO_LONG();
|
|
289
|
-
},
|
|
290
|
-
|
|
291
|
-
get name() {
|
|
292
|
-
var n = decoder.decode(_entryName);
|
|
293
|
-
return _isDirectory
|
|
294
|
-
? n
|
|
295
|
-
.substr(n.length - 1)
|
|
296
|
-
.split("/")
|
|
297
|
-
.pop()
|
|
298
|
-
: n.split("/").pop();
|
|
299
|
-
},
|
|
300
|
-
get isDirectory() {
|
|
301
|
-
return _isDirectory;
|
|
302
|
-
},
|
|
303
|
-
|
|
304
|
-
getCompressedData: function () {
|
|
305
|
-
return compress(false, null);
|
|
306
|
-
},
|
|
307
|
-
|
|
308
|
-
getCompressedDataAsync: function (/*Function*/ callback) {
|
|
309
|
-
compress(true, callback);
|
|
310
|
-
},
|
|
311
|
-
|
|
312
|
-
setData: function (value) {
|
|
313
|
-
uncompressedData = Utils.toBuffer(value, Utils.decoder.encode);
|
|
314
|
-
if (!_isDirectory && uncompressedData.length) {
|
|
315
|
-
_centralHeader.size = uncompressedData.length;
|
|
316
|
-
_centralHeader.method = Utils.Constants.DEFLATED;
|
|
317
|
-
_centralHeader.crc = Utils.crc32(value);
|
|
318
|
-
_centralHeader.changed = true;
|
|
319
|
-
} else {
|
|
320
|
-
// folders and blank files should be stored
|
|
321
|
-
_centralHeader.method = Utils.Constants.STORED;
|
|
322
|
-
}
|
|
323
|
-
},
|
|
324
|
-
|
|
325
|
-
getData: function (pass) {
|
|
326
|
-
if (_centralHeader.changed) {
|
|
327
|
-
return uncompressedData;
|
|
328
|
-
} else {
|
|
329
|
-
return decompress(false, null, pass);
|
|
330
|
-
}
|
|
331
|
-
},
|
|
332
|
-
|
|
333
|
-
getDataAsync: function (/*Function*/ callback, pass) {
|
|
334
|
-
if (_centralHeader.changed) {
|
|
335
|
-
callback(uncompressedData);
|
|
336
|
-
} else {
|
|
337
|
-
decompress(true, callback, pass);
|
|
338
|
-
}
|
|
339
|
-
},
|
|
340
|
-
|
|
341
|
-
set attr(attr) {
|
|
342
|
-
_centralHeader.attr = attr;
|
|
343
|
-
},
|
|
344
|
-
get attr() {
|
|
345
|
-
return _centralHeader.attr;
|
|
346
|
-
},
|
|
347
|
-
|
|
348
|
-
set header(/*Buffer*/ data) {
|
|
349
|
-
_centralHeader.loadFromBinary(data);
|
|
350
|
-
},
|
|
351
|
-
|
|
352
|
-
get header() {
|
|
353
|
-
return _centralHeader;
|
|
354
|
-
},
|
|
355
|
-
|
|
356
|
-
packCentralHeader: function () {
|
|
357
|
-
_centralHeader.flags_efs = this.efs;
|
|
358
|
-
_centralHeader.extraLength = _extra.length;
|
|
359
|
-
// 1. create header (buffer)
|
|
360
|
-
var header = _centralHeader.centralHeaderToBinary();
|
|
361
|
-
var addpos = Utils.Constants.CENHDR;
|
|
362
|
-
// 2. add file name
|
|
363
|
-
_entryName.copy(header, addpos);
|
|
364
|
-
addpos += _entryName.length;
|
|
365
|
-
// 3. add extra data
|
|
366
|
-
_extra.copy(header, addpos);
|
|
367
|
-
addpos += _centralHeader.extraLength;
|
|
368
|
-
// 4. add file comment
|
|
369
|
-
_comment.copy(header, addpos);
|
|
370
|
-
return header;
|
|
371
|
-
},
|
|
372
|
-
|
|
373
|
-
packLocalHeader: function () {
|
|
374
|
-
let addpos = 0;
|
|
375
|
-
_centralHeader.flags_efs = this.efs;
|
|
376
|
-
_centralHeader.extraLocalLength = _extralocal.length;
|
|
377
|
-
// 1. construct local header Buffer
|
|
378
|
-
const localHeaderBuf = _centralHeader.localHeaderToBinary();
|
|
379
|
-
// 2. localHeader - crate header buffer
|
|
380
|
-
const localHeader = Buffer.alloc(localHeaderBuf.length + _entryName.length + _centralHeader.extraLocalLength);
|
|
381
|
-
// 2.1 add localheader
|
|
382
|
-
localHeaderBuf.copy(localHeader, addpos);
|
|
383
|
-
addpos += localHeaderBuf.length;
|
|
384
|
-
// 2.2 add file name
|
|
385
|
-
_entryName.copy(localHeader, addpos);
|
|
386
|
-
addpos += _entryName.length;
|
|
387
|
-
// 2.3 add extra field
|
|
388
|
-
_extralocal.copy(localHeader, addpos);
|
|
389
|
-
addpos += _extralocal.length;
|
|
390
|
-
|
|
391
|
-
return localHeader;
|
|
392
|
-
},
|
|
393
|
-
|
|
394
|
-
toJSON: function () {
|
|
395
|
-
const bytes = function (nr) {
|
|
396
|
-
return "<" + ((nr && nr.length + " bytes buffer") || "null") + ">";
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
return {
|
|
400
|
-
entryName: this.entryName,
|
|
401
|
-
name: this.name,
|
|
402
|
-
comment: this.comment,
|
|
403
|
-
isDirectory: this.isDirectory,
|
|
404
|
-
header: _centralHeader.toJSON(),
|
|
405
|
-
compressedData: bytes(input),
|
|
406
|
-
data: bytes(uncompressedData)
|
|
407
|
-
};
|
|
408
|
-
},
|
|
409
|
-
|
|
410
|
-
toString: function () {
|
|
411
|
-
return JSON.stringify(this.toJSON(), null, "\t");
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
};
|