@autorender/sdk-core 0.1.35 → 0.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +207 -4024
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +207 -4043
- package/dist/index.js.map +1 -1
- package/dist/styles.d.ts +2 -0
- package/package.json +10 -4
package/dist/index.js
CHANGED
|
@@ -1,889 +1,3 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
-
}) : x)(function(x) {
|
|
11
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
-
});
|
|
14
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
-
};
|
|
17
|
-
var __copyProps = (to, from, except, desc) => {
|
|
18
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
-
for (let key of __getOwnPropNames(from))
|
|
20
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
-
}
|
|
23
|
-
return to;
|
|
24
|
-
};
|
|
25
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
-
mod
|
|
32
|
-
));
|
|
33
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
|
-
|
|
35
|
-
// ../../node_modules/ieee754/index.js
|
|
36
|
-
var require_ieee754 = __commonJS({
|
|
37
|
-
"../../node_modules/ieee754/index.js"(exports) {
|
|
38
|
-
"use strict";
|
|
39
|
-
exports.read = function(buffer, offset, isLE, mLen, nBytes) {
|
|
40
|
-
var e, m;
|
|
41
|
-
var eLen = nBytes * 8 - mLen - 1;
|
|
42
|
-
var eMax = (1 << eLen) - 1;
|
|
43
|
-
var eBias = eMax >> 1;
|
|
44
|
-
var nBits = -7;
|
|
45
|
-
var i = isLE ? nBytes - 1 : 0;
|
|
46
|
-
var d = isLE ? -1 : 1;
|
|
47
|
-
var s = buffer[offset + i];
|
|
48
|
-
i += d;
|
|
49
|
-
e = s & (1 << -nBits) - 1;
|
|
50
|
-
s >>= -nBits;
|
|
51
|
-
nBits += eLen;
|
|
52
|
-
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
53
|
-
}
|
|
54
|
-
m = e & (1 << -nBits) - 1;
|
|
55
|
-
e >>= -nBits;
|
|
56
|
-
nBits += mLen;
|
|
57
|
-
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
58
|
-
}
|
|
59
|
-
if (e === 0) {
|
|
60
|
-
e = 1 - eBias;
|
|
61
|
-
} else if (e === eMax) {
|
|
62
|
-
return m ? NaN : (s ? -1 : 1) * Infinity;
|
|
63
|
-
} else {
|
|
64
|
-
m = m + Math.pow(2, mLen);
|
|
65
|
-
e = e - eBias;
|
|
66
|
-
}
|
|
67
|
-
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
|
68
|
-
};
|
|
69
|
-
exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
|
|
70
|
-
var e, m, c;
|
|
71
|
-
var eLen = nBytes * 8 - mLen - 1;
|
|
72
|
-
var eMax = (1 << eLen) - 1;
|
|
73
|
-
var eBias = eMax >> 1;
|
|
74
|
-
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
|
|
75
|
-
var i = isLE ? 0 : nBytes - 1;
|
|
76
|
-
var d = isLE ? 1 : -1;
|
|
77
|
-
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
|
|
78
|
-
value = Math.abs(value);
|
|
79
|
-
if (isNaN(value) || value === Infinity) {
|
|
80
|
-
m = isNaN(value) ? 1 : 0;
|
|
81
|
-
e = eMax;
|
|
82
|
-
} else {
|
|
83
|
-
e = Math.floor(Math.log(value) / Math.LN2);
|
|
84
|
-
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
85
|
-
e--;
|
|
86
|
-
c *= 2;
|
|
87
|
-
}
|
|
88
|
-
if (e + eBias >= 1) {
|
|
89
|
-
value += rt / c;
|
|
90
|
-
} else {
|
|
91
|
-
value += rt * Math.pow(2, 1 - eBias);
|
|
92
|
-
}
|
|
93
|
-
if (value * c >= 2) {
|
|
94
|
-
e++;
|
|
95
|
-
c /= 2;
|
|
96
|
-
}
|
|
97
|
-
if (e + eBias >= eMax) {
|
|
98
|
-
m = 0;
|
|
99
|
-
e = eMax;
|
|
100
|
-
} else if (e + eBias >= 1) {
|
|
101
|
-
m = (value * c - 1) * Math.pow(2, mLen);
|
|
102
|
-
e = e + eBias;
|
|
103
|
-
} else {
|
|
104
|
-
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
105
|
-
e = 0;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
|
|
109
|
-
}
|
|
110
|
-
e = e << mLen | m;
|
|
111
|
-
eLen += mLen;
|
|
112
|
-
for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
|
|
113
|
-
}
|
|
114
|
-
buffer[offset + i - d] |= s * 128;
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
// ../../node_modules/ms/index.js
|
|
120
|
-
var require_ms = __commonJS({
|
|
121
|
-
"../../node_modules/ms/index.js"(exports, module) {
|
|
122
|
-
"use strict";
|
|
123
|
-
var s = 1e3;
|
|
124
|
-
var m = s * 60;
|
|
125
|
-
var h = m * 60;
|
|
126
|
-
var d = h * 24;
|
|
127
|
-
var w = d * 7;
|
|
128
|
-
var y = d * 365.25;
|
|
129
|
-
module.exports = function(val, options) {
|
|
130
|
-
options = options || {};
|
|
131
|
-
var type = typeof val;
|
|
132
|
-
if (type === "string" && val.length > 0) {
|
|
133
|
-
return parse(val);
|
|
134
|
-
} else if (type === "number" && isFinite(val)) {
|
|
135
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
|
136
|
-
}
|
|
137
|
-
throw new Error(
|
|
138
|
-
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
139
|
-
);
|
|
140
|
-
};
|
|
141
|
-
function parse(str) {
|
|
142
|
-
str = String(str);
|
|
143
|
-
if (str.length > 100) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
147
|
-
str
|
|
148
|
-
);
|
|
149
|
-
if (!match) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
var n = parseFloat(match[1]);
|
|
153
|
-
var type = (match[2] || "ms").toLowerCase();
|
|
154
|
-
switch (type) {
|
|
155
|
-
case "years":
|
|
156
|
-
case "year":
|
|
157
|
-
case "yrs":
|
|
158
|
-
case "yr":
|
|
159
|
-
case "y":
|
|
160
|
-
return n * y;
|
|
161
|
-
case "weeks":
|
|
162
|
-
case "week":
|
|
163
|
-
case "w":
|
|
164
|
-
return n * w;
|
|
165
|
-
case "days":
|
|
166
|
-
case "day":
|
|
167
|
-
case "d":
|
|
168
|
-
return n * d;
|
|
169
|
-
case "hours":
|
|
170
|
-
case "hour":
|
|
171
|
-
case "hrs":
|
|
172
|
-
case "hr":
|
|
173
|
-
case "h":
|
|
174
|
-
return n * h;
|
|
175
|
-
case "minutes":
|
|
176
|
-
case "minute":
|
|
177
|
-
case "mins":
|
|
178
|
-
case "min":
|
|
179
|
-
case "m":
|
|
180
|
-
return n * m;
|
|
181
|
-
case "seconds":
|
|
182
|
-
case "second":
|
|
183
|
-
case "secs":
|
|
184
|
-
case "sec":
|
|
185
|
-
case "s":
|
|
186
|
-
return n * s;
|
|
187
|
-
case "milliseconds":
|
|
188
|
-
case "millisecond":
|
|
189
|
-
case "msecs":
|
|
190
|
-
case "msec":
|
|
191
|
-
case "ms":
|
|
192
|
-
return n;
|
|
193
|
-
default:
|
|
194
|
-
return void 0;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
function fmtShort(ms) {
|
|
198
|
-
var msAbs = Math.abs(ms);
|
|
199
|
-
if (msAbs >= d) {
|
|
200
|
-
return Math.round(ms / d) + "d";
|
|
201
|
-
}
|
|
202
|
-
if (msAbs >= h) {
|
|
203
|
-
return Math.round(ms / h) + "h";
|
|
204
|
-
}
|
|
205
|
-
if (msAbs >= m) {
|
|
206
|
-
return Math.round(ms / m) + "m";
|
|
207
|
-
}
|
|
208
|
-
if (msAbs >= s) {
|
|
209
|
-
return Math.round(ms / s) + "s";
|
|
210
|
-
}
|
|
211
|
-
return ms + "ms";
|
|
212
|
-
}
|
|
213
|
-
function fmtLong(ms) {
|
|
214
|
-
var msAbs = Math.abs(ms);
|
|
215
|
-
if (msAbs >= d) {
|
|
216
|
-
return plural(ms, msAbs, d, "day");
|
|
217
|
-
}
|
|
218
|
-
if (msAbs >= h) {
|
|
219
|
-
return plural(ms, msAbs, h, "hour");
|
|
220
|
-
}
|
|
221
|
-
if (msAbs >= m) {
|
|
222
|
-
return plural(ms, msAbs, m, "minute");
|
|
223
|
-
}
|
|
224
|
-
if (msAbs >= s) {
|
|
225
|
-
return plural(ms, msAbs, s, "second");
|
|
226
|
-
}
|
|
227
|
-
return ms + " ms";
|
|
228
|
-
}
|
|
229
|
-
function plural(ms, msAbs, n, name) {
|
|
230
|
-
var isPlural = msAbs >= n * 1.5;
|
|
231
|
-
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
// ../../node_modules/debug/src/common.js
|
|
237
|
-
var require_common = __commonJS({
|
|
238
|
-
"../../node_modules/debug/src/common.js"(exports, module) {
|
|
239
|
-
"use strict";
|
|
240
|
-
function setup(env) {
|
|
241
|
-
createDebug.debug = createDebug;
|
|
242
|
-
createDebug.default = createDebug;
|
|
243
|
-
createDebug.coerce = coerce;
|
|
244
|
-
createDebug.disable = disable;
|
|
245
|
-
createDebug.enable = enable;
|
|
246
|
-
createDebug.enabled = enabled;
|
|
247
|
-
createDebug.humanize = require_ms();
|
|
248
|
-
createDebug.destroy = destroy;
|
|
249
|
-
Object.keys(env).forEach((key) => {
|
|
250
|
-
createDebug[key] = env[key];
|
|
251
|
-
});
|
|
252
|
-
createDebug.names = [];
|
|
253
|
-
createDebug.skips = [];
|
|
254
|
-
createDebug.formatters = {};
|
|
255
|
-
function selectColor(namespace) {
|
|
256
|
-
let hash = 0;
|
|
257
|
-
for (let i = 0; i < namespace.length; i++) {
|
|
258
|
-
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
259
|
-
hash |= 0;
|
|
260
|
-
}
|
|
261
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
262
|
-
}
|
|
263
|
-
createDebug.selectColor = selectColor;
|
|
264
|
-
function createDebug(namespace) {
|
|
265
|
-
let prevTime;
|
|
266
|
-
let enableOverride = null;
|
|
267
|
-
let namespacesCache;
|
|
268
|
-
let enabledCache;
|
|
269
|
-
function debug2(...args) {
|
|
270
|
-
if (!debug2.enabled) {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
const self = debug2;
|
|
274
|
-
const curr = Number(/* @__PURE__ */ new Date());
|
|
275
|
-
const ms = curr - (prevTime || curr);
|
|
276
|
-
self.diff = ms;
|
|
277
|
-
self.prev = prevTime;
|
|
278
|
-
self.curr = curr;
|
|
279
|
-
prevTime = curr;
|
|
280
|
-
args[0] = createDebug.coerce(args[0]);
|
|
281
|
-
if (typeof args[0] !== "string") {
|
|
282
|
-
args.unshift("%O");
|
|
283
|
-
}
|
|
284
|
-
let index = 0;
|
|
285
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
286
|
-
if (match === "%%") {
|
|
287
|
-
return "%";
|
|
288
|
-
}
|
|
289
|
-
index++;
|
|
290
|
-
const formatter = createDebug.formatters[format];
|
|
291
|
-
if (typeof formatter === "function") {
|
|
292
|
-
const val = args[index];
|
|
293
|
-
match = formatter.call(self, val);
|
|
294
|
-
args.splice(index, 1);
|
|
295
|
-
index--;
|
|
296
|
-
}
|
|
297
|
-
return match;
|
|
298
|
-
});
|
|
299
|
-
createDebug.formatArgs.call(self, args);
|
|
300
|
-
const logFn = self.log || createDebug.log;
|
|
301
|
-
logFn.apply(self, args);
|
|
302
|
-
}
|
|
303
|
-
debug2.namespace = namespace;
|
|
304
|
-
debug2.useColors = createDebug.useColors();
|
|
305
|
-
debug2.color = createDebug.selectColor(namespace);
|
|
306
|
-
debug2.extend = extend;
|
|
307
|
-
debug2.destroy = createDebug.destroy;
|
|
308
|
-
Object.defineProperty(debug2, "enabled", {
|
|
309
|
-
enumerable: true,
|
|
310
|
-
configurable: false,
|
|
311
|
-
get: () => {
|
|
312
|
-
if (enableOverride !== null) {
|
|
313
|
-
return enableOverride;
|
|
314
|
-
}
|
|
315
|
-
if (namespacesCache !== createDebug.namespaces) {
|
|
316
|
-
namespacesCache = createDebug.namespaces;
|
|
317
|
-
enabledCache = createDebug.enabled(namespace);
|
|
318
|
-
}
|
|
319
|
-
return enabledCache;
|
|
320
|
-
},
|
|
321
|
-
set: (v) => {
|
|
322
|
-
enableOverride = v;
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
if (typeof createDebug.init === "function") {
|
|
326
|
-
createDebug.init(debug2);
|
|
327
|
-
}
|
|
328
|
-
return debug2;
|
|
329
|
-
}
|
|
330
|
-
function extend(namespace, delimiter) {
|
|
331
|
-
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
332
|
-
newDebug.log = this.log;
|
|
333
|
-
return newDebug;
|
|
334
|
-
}
|
|
335
|
-
function enable(namespaces) {
|
|
336
|
-
createDebug.save(namespaces);
|
|
337
|
-
createDebug.namespaces = namespaces;
|
|
338
|
-
createDebug.names = [];
|
|
339
|
-
createDebug.skips = [];
|
|
340
|
-
const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
341
|
-
for (const ns of split) {
|
|
342
|
-
if (ns[0] === "-") {
|
|
343
|
-
createDebug.skips.push(ns.slice(1));
|
|
344
|
-
} else {
|
|
345
|
-
createDebug.names.push(ns);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
function matchesTemplate(search, template) {
|
|
350
|
-
let searchIndex = 0;
|
|
351
|
-
let templateIndex = 0;
|
|
352
|
-
let starIndex = -1;
|
|
353
|
-
let matchIndex = 0;
|
|
354
|
-
while (searchIndex < search.length) {
|
|
355
|
-
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
|
|
356
|
-
if (template[templateIndex] === "*") {
|
|
357
|
-
starIndex = templateIndex;
|
|
358
|
-
matchIndex = searchIndex;
|
|
359
|
-
templateIndex++;
|
|
360
|
-
} else {
|
|
361
|
-
searchIndex++;
|
|
362
|
-
templateIndex++;
|
|
363
|
-
}
|
|
364
|
-
} else if (starIndex !== -1) {
|
|
365
|
-
templateIndex = starIndex + 1;
|
|
366
|
-
matchIndex++;
|
|
367
|
-
searchIndex = matchIndex;
|
|
368
|
-
} else {
|
|
369
|
-
return false;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
while (templateIndex < template.length && template[templateIndex] === "*") {
|
|
373
|
-
templateIndex++;
|
|
374
|
-
}
|
|
375
|
-
return templateIndex === template.length;
|
|
376
|
-
}
|
|
377
|
-
function disable() {
|
|
378
|
-
const namespaces = [
|
|
379
|
-
...createDebug.names,
|
|
380
|
-
...createDebug.skips.map((namespace) => "-" + namespace)
|
|
381
|
-
].join(",");
|
|
382
|
-
createDebug.enable("");
|
|
383
|
-
return namespaces;
|
|
384
|
-
}
|
|
385
|
-
function enabled(name) {
|
|
386
|
-
for (const skip of createDebug.skips) {
|
|
387
|
-
if (matchesTemplate(name, skip)) {
|
|
388
|
-
return false;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
for (const ns of createDebug.names) {
|
|
392
|
-
if (matchesTemplate(name, ns)) {
|
|
393
|
-
return true;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
return false;
|
|
397
|
-
}
|
|
398
|
-
function coerce(val) {
|
|
399
|
-
if (val instanceof Error) {
|
|
400
|
-
return val.stack || val.message;
|
|
401
|
-
}
|
|
402
|
-
return val;
|
|
403
|
-
}
|
|
404
|
-
function destroy() {
|
|
405
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
406
|
-
}
|
|
407
|
-
createDebug.enable(createDebug.load());
|
|
408
|
-
return createDebug;
|
|
409
|
-
}
|
|
410
|
-
module.exports = setup;
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
// ../../node_modules/debug/src/browser.js
|
|
415
|
-
var require_browser = __commonJS({
|
|
416
|
-
"../../node_modules/debug/src/browser.js"(exports, module) {
|
|
417
|
-
"use strict";
|
|
418
|
-
exports.formatArgs = formatArgs;
|
|
419
|
-
exports.save = save;
|
|
420
|
-
exports.load = load;
|
|
421
|
-
exports.useColors = useColors;
|
|
422
|
-
exports.storage = localstorage();
|
|
423
|
-
exports.destroy = /* @__PURE__ */ (() => {
|
|
424
|
-
let warned = false;
|
|
425
|
-
return () => {
|
|
426
|
-
if (!warned) {
|
|
427
|
-
warned = true;
|
|
428
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
})();
|
|
432
|
-
exports.colors = [
|
|
433
|
-
"#0000CC",
|
|
434
|
-
"#0000FF",
|
|
435
|
-
"#0033CC",
|
|
436
|
-
"#0033FF",
|
|
437
|
-
"#0066CC",
|
|
438
|
-
"#0066FF",
|
|
439
|
-
"#0099CC",
|
|
440
|
-
"#0099FF",
|
|
441
|
-
"#00CC00",
|
|
442
|
-
"#00CC33",
|
|
443
|
-
"#00CC66",
|
|
444
|
-
"#00CC99",
|
|
445
|
-
"#00CCCC",
|
|
446
|
-
"#00CCFF",
|
|
447
|
-
"#3300CC",
|
|
448
|
-
"#3300FF",
|
|
449
|
-
"#3333CC",
|
|
450
|
-
"#3333FF",
|
|
451
|
-
"#3366CC",
|
|
452
|
-
"#3366FF",
|
|
453
|
-
"#3399CC",
|
|
454
|
-
"#3399FF",
|
|
455
|
-
"#33CC00",
|
|
456
|
-
"#33CC33",
|
|
457
|
-
"#33CC66",
|
|
458
|
-
"#33CC99",
|
|
459
|
-
"#33CCCC",
|
|
460
|
-
"#33CCFF",
|
|
461
|
-
"#6600CC",
|
|
462
|
-
"#6600FF",
|
|
463
|
-
"#6633CC",
|
|
464
|
-
"#6633FF",
|
|
465
|
-
"#66CC00",
|
|
466
|
-
"#66CC33",
|
|
467
|
-
"#9900CC",
|
|
468
|
-
"#9900FF",
|
|
469
|
-
"#9933CC",
|
|
470
|
-
"#9933FF",
|
|
471
|
-
"#99CC00",
|
|
472
|
-
"#99CC33",
|
|
473
|
-
"#CC0000",
|
|
474
|
-
"#CC0033",
|
|
475
|
-
"#CC0066",
|
|
476
|
-
"#CC0099",
|
|
477
|
-
"#CC00CC",
|
|
478
|
-
"#CC00FF",
|
|
479
|
-
"#CC3300",
|
|
480
|
-
"#CC3333",
|
|
481
|
-
"#CC3366",
|
|
482
|
-
"#CC3399",
|
|
483
|
-
"#CC33CC",
|
|
484
|
-
"#CC33FF",
|
|
485
|
-
"#CC6600",
|
|
486
|
-
"#CC6633",
|
|
487
|
-
"#CC9900",
|
|
488
|
-
"#CC9933",
|
|
489
|
-
"#CCCC00",
|
|
490
|
-
"#CCCC33",
|
|
491
|
-
"#FF0000",
|
|
492
|
-
"#FF0033",
|
|
493
|
-
"#FF0066",
|
|
494
|
-
"#FF0099",
|
|
495
|
-
"#FF00CC",
|
|
496
|
-
"#FF00FF",
|
|
497
|
-
"#FF3300",
|
|
498
|
-
"#FF3333",
|
|
499
|
-
"#FF3366",
|
|
500
|
-
"#FF3399",
|
|
501
|
-
"#FF33CC",
|
|
502
|
-
"#FF33FF",
|
|
503
|
-
"#FF6600",
|
|
504
|
-
"#FF6633",
|
|
505
|
-
"#FF9900",
|
|
506
|
-
"#FF9933",
|
|
507
|
-
"#FFCC00",
|
|
508
|
-
"#FFCC33"
|
|
509
|
-
];
|
|
510
|
-
function useColors() {
|
|
511
|
-
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
512
|
-
return true;
|
|
513
|
-
}
|
|
514
|
-
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
515
|
-
return false;
|
|
516
|
-
}
|
|
517
|
-
let m;
|
|
518
|
-
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
519
|
-
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
520
|
-
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
521
|
-
typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
522
|
-
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
523
|
-
}
|
|
524
|
-
function formatArgs(args) {
|
|
525
|
-
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
|
|
526
|
-
if (!this.useColors) {
|
|
527
|
-
return;
|
|
528
|
-
}
|
|
529
|
-
const c = "color: " + this.color;
|
|
530
|
-
args.splice(1, 0, c, "color: inherit");
|
|
531
|
-
let index = 0;
|
|
532
|
-
let lastC = 0;
|
|
533
|
-
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
534
|
-
if (match === "%%") {
|
|
535
|
-
return;
|
|
536
|
-
}
|
|
537
|
-
index++;
|
|
538
|
-
if (match === "%c") {
|
|
539
|
-
lastC = index;
|
|
540
|
-
}
|
|
541
|
-
});
|
|
542
|
-
args.splice(lastC, 0, c);
|
|
543
|
-
}
|
|
544
|
-
exports.log = console.debug || console.log || (() => {
|
|
545
|
-
});
|
|
546
|
-
function save(namespaces) {
|
|
547
|
-
try {
|
|
548
|
-
if (namespaces) {
|
|
549
|
-
exports.storage.setItem("debug", namespaces);
|
|
550
|
-
} else {
|
|
551
|
-
exports.storage.removeItem("debug");
|
|
552
|
-
}
|
|
553
|
-
} catch (error) {
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
function load() {
|
|
557
|
-
let r;
|
|
558
|
-
try {
|
|
559
|
-
r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
|
|
560
|
-
} catch (error) {
|
|
561
|
-
}
|
|
562
|
-
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
563
|
-
r = process.env.DEBUG;
|
|
564
|
-
}
|
|
565
|
-
return r;
|
|
566
|
-
}
|
|
567
|
-
function localstorage() {
|
|
568
|
-
try {
|
|
569
|
-
return localStorage;
|
|
570
|
-
} catch (error) {
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
module.exports = require_common()(exports);
|
|
574
|
-
var { formatters } = module.exports;
|
|
575
|
-
formatters.j = function(v) {
|
|
576
|
-
try {
|
|
577
|
-
return JSON.stringify(v);
|
|
578
|
-
} catch (error) {
|
|
579
|
-
return "[UnexpectedJSONParseError]: " + error.message;
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
// ../../node_modules/has-flag/index.js
|
|
586
|
-
var require_has_flag = __commonJS({
|
|
587
|
-
"../../node_modules/has-flag/index.js"(exports, module) {
|
|
588
|
-
"use strict";
|
|
589
|
-
module.exports = (flag, argv = process.argv) => {
|
|
590
|
-
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
591
|
-
const position = argv.indexOf(prefix + flag);
|
|
592
|
-
const terminatorPosition = argv.indexOf("--");
|
|
593
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
594
|
-
};
|
|
595
|
-
}
|
|
596
|
-
});
|
|
597
|
-
|
|
598
|
-
// ../../node_modules/supports-color/index.js
|
|
599
|
-
var require_supports_color = __commonJS({
|
|
600
|
-
"../../node_modules/supports-color/index.js"(exports, module) {
|
|
601
|
-
"use strict";
|
|
602
|
-
var os = __require("os");
|
|
603
|
-
var tty = __require("tty");
|
|
604
|
-
var hasFlag = require_has_flag();
|
|
605
|
-
var { env } = process;
|
|
606
|
-
var forceColor;
|
|
607
|
-
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
608
|
-
forceColor = 0;
|
|
609
|
-
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
610
|
-
forceColor = 1;
|
|
611
|
-
}
|
|
612
|
-
if ("FORCE_COLOR" in env) {
|
|
613
|
-
if (env.FORCE_COLOR === "true") {
|
|
614
|
-
forceColor = 1;
|
|
615
|
-
} else if (env.FORCE_COLOR === "false") {
|
|
616
|
-
forceColor = 0;
|
|
617
|
-
} else {
|
|
618
|
-
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
function translateLevel(level) {
|
|
622
|
-
if (level === 0) {
|
|
623
|
-
return false;
|
|
624
|
-
}
|
|
625
|
-
return {
|
|
626
|
-
level,
|
|
627
|
-
hasBasic: true,
|
|
628
|
-
has256: level >= 2,
|
|
629
|
-
has16m: level >= 3
|
|
630
|
-
};
|
|
631
|
-
}
|
|
632
|
-
function supportsColor(haveStream, streamIsTTY) {
|
|
633
|
-
if (forceColor === 0) {
|
|
634
|
-
return 0;
|
|
635
|
-
}
|
|
636
|
-
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
637
|
-
return 3;
|
|
638
|
-
}
|
|
639
|
-
if (hasFlag("color=256")) {
|
|
640
|
-
return 2;
|
|
641
|
-
}
|
|
642
|
-
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
643
|
-
return 0;
|
|
644
|
-
}
|
|
645
|
-
const min = forceColor || 0;
|
|
646
|
-
if (env.TERM === "dumb") {
|
|
647
|
-
return min;
|
|
648
|
-
}
|
|
649
|
-
if (process.platform === "win32") {
|
|
650
|
-
const osRelease = os.release().split(".");
|
|
651
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
652
|
-
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
653
|
-
}
|
|
654
|
-
return 1;
|
|
655
|
-
}
|
|
656
|
-
if ("CI" in env) {
|
|
657
|
-
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
658
|
-
return 1;
|
|
659
|
-
}
|
|
660
|
-
return min;
|
|
661
|
-
}
|
|
662
|
-
if ("TEAMCITY_VERSION" in env) {
|
|
663
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
664
|
-
}
|
|
665
|
-
if (env.COLORTERM === "truecolor") {
|
|
666
|
-
return 3;
|
|
667
|
-
}
|
|
668
|
-
if ("TERM_PROGRAM" in env) {
|
|
669
|
-
const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
670
|
-
switch (env.TERM_PROGRAM) {
|
|
671
|
-
case "iTerm.app":
|
|
672
|
-
return version >= 3 ? 3 : 2;
|
|
673
|
-
case "Apple_Terminal":
|
|
674
|
-
return 2;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
|
678
|
-
return 2;
|
|
679
|
-
}
|
|
680
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
681
|
-
return 1;
|
|
682
|
-
}
|
|
683
|
-
if ("COLORTERM" in env) {
|
|
684
|
-
return 1;
|
|
685
|
-
}
|
|
686
|
-
return min;
|
|
687
|
-
}
|
|
688
|
-
function getSupportLevel(stream) {
|
|
689
|
-
const level = supportsColor(stream, stream && stream.isTTY);
|
|
690
|
-
return translateLevel(level);
|
|
691
|
-
}
|
|
692
|
-
module.exports = {
|
|
693
|
-
supportsColor: getSupportLevel,
|
|
694
|
-
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
695
|
-
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
696
|
-
};
|
|
697
|
-
}
|
|
698
|
-
});
|
|
699
|
-
|
|
700
|
-
// ../../node_modules/debug/src/node.js
|
|
701
|
-
var require_node = __commonJS({
|
|
702
|
-
"../../node_modules/debug/src/node.js"(exports, module) {
|
|
703
|
-
"use strict";
|
|
704
|
-
var tty = __require("tty");
|
|
705
|
-
var util = __require("util");
|
|
706
|
-
exports.init = init;
|
|
707
|
-
exports.log = log;
|
|
708
|
-
exports.formatArgs = formatArgs;
|
|
709
|
-
exports.save = save;
|
|
710
|
-
exports.load = load;
|
|
711
|
-
exports.useColors = useColors;
|
|
712
|
-
exports.destroy = util.deprecate(
|
|
713
|
-
() => {
|
|
714
|
-
},
|
|
715
|
-
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
|
|
716
|
-
);
|
|
717
|
-
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
718
|
-
try {
|
|
719
|
-
const supportsColor = require_supports_color();
|
|
720
|
-
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
721
|
-
exports.colors = [
|
|
722
|
-
20,
|
|
723
|
-
21,
|
|
724
|
-
26,
|
|
725
|
-
27,
|
|
726
|
-
32,
|
|
727
|
-
33,
|
|
728
|
-
38,
|
|
729
|
-
39,
|
|
730
|
-
40,
|
|
731
|
-
41,
|
|
732
|
-
42,
|
|
733
|
-
43,
|
|
734
|
-
44,
|
|
735
|
-
45,
|
|
736
|
-
56,
|
|
737
|
-
57,
|
|
738
|
-
62,
|
|
739
|
-
63,
|
|
740
|
-
68,
|
|
741
|
-
69,
|
|
742
|
-
74,
|
|
743
|
-
75,
|
|
744
|
-
76,
|
|
745
|
-
77,
|
|
746
|
-
78,
|
|
747
|
-
79,
|
|
748
|
-
80,
|
|
749
|
-
81,
|
|
750
|
-
92,
|
|
751
|
-
93,
|
|
752
|
-
98,
|
|
753
|
-
99,
|
|
754
|
-
112,
|
|
755
|
-
113,
|
|
756
|
-
128,
|
|
757
|
-
129,
|
|
758
|
-
134,
|
|
759
|
-
135,
|
|
760
|
-
148,
|
|
761
|
-
149,
|
|
762
|
-
160,
|
|
763
|
-
161,
|
|
764
|
-
162,
|
|
765
|
-
163,
|
|
766
|
-
164,
|
|
767
|
-
165,
|
|
768
|
-
166,
|
|
769
|
-
167,
|
|
770
|
-
168,
|
|
771
|
-
169,
|
|
772
|
-
170,
|
|
773
|
-
171,
|
|
774
|
-
172,
|
|
775
|
-
173,
|
|
776
|
-
178,
|
|
777
|
-
179,
|
|
778
|
-
184,
|
|
779
|
-
185,
|
|
780
|
-
196,
|
|
781
|
-
197,
|
|
782
|
-
198,
|
|
783
|
-
199,
|
|
784
|
-
200,
|
|
785
|
-
201,
|
|
786
|
-
202,
|
|
787
|
-
203,
|
|
788
|
-
204,
|
|
789
|
-
205,
|
|
790
|
-
206,
|
|
791
|
-
207,
|
|
792
|
-
208,
|
|
793
|
-
209,
|
|
794
|
-
214,
|
|
795
|
-
215,
|
|
796
|
-
220,
|
|
797
|
-
221
|
|
798
|
-
];
|
|
799
|
-
}
|
|
800
|
-
} catch (error) {
|
|
801
|
-
}
|
|
802
|
-
exports.inspectOpts = Object.keys(process.env).filter((key) => {
|
|
803
|
-
return /^debug_/i.test(key);
|
|
804
|
-
}).reduce((obj, key) => {
|
|
805
|
-
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
|
|
806
|
-
return k.toUpperCase();
|
|
807
|
-
});
|
|
808
|
-
let val = process.env[key];
|
|
809
|
-
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
810
|
-
val = true;
|
|
811
|
-
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
812
|
-
val = false;
|
|
813
|
-
} else if (val === "null") {
|
|
814
|
-
val = null;
|
|
815
|
-
} else {
|
|
816
|
-
val = Number(val);
|
|
817
|
-
}
|
|
818
|
-
obj[prop] = val;
|
|
819
|
-
return obj;
|
|
820
|
-
}, {});
|
|
821
|
-
function useColors() {
|
|
822
|
-
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
|
823
|
-
}
|
|
824
|
-
function formatArgs(args) {
|
|
825
|
-
const { namespace: name, useColors: useColors2 } = this;
|
|
826
|
-
if (useColors2) {
|
|
827
|
-
const c = this.color;
|
|
828
|
-
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
|
|
829
|
-
const prefix = ` ${colorCode};1m${name} \x1B[0m`;
|
|
830
|
-
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
|
|
831
|
-
args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
|
|
832
|
-
} else {
|
|
833
|
-
args[0] = getDate() + name + " " + args[0];
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
function getDate() {
|
|
837
|
-
if (exports.inspectOpts.hideDate) {
|
|
838
|
-
return "";
|
|
839
|
-
}
|
|
840
|
-
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
841
|
-
}
|
|
842
|
-
function log(...args) {
|
|
843
|
-
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + "\n");
|
|
844
|
-
}
|
|
845
|
-
function save(namespaces) {
|
|
846
|
-
if (namespaces) {
|
|
847
|
-
process.env.DEBUG = namespaces;
|
|
848
|
-
} else {
|
|
849
|
-
delete process.env.DEBUG;
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
function load() {
|
|
853
|
-
return process.env.DEBUG;
|
|
854
|
-
}
|
|
855
|
-
function init(debug2) {
|
|
856
|
-
debug2.inspectOpts = {};
|
|
857
|
-
const keys = Object.keys(exports.inspectOpts);
|
|
858
|
-
for (let i = 0; i < keys.length; i++) {
|
|
859
|
-
debug2.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
module.exports = require_common()(exports);
|
|
863
|
-
var { formatters } = module.exports;
|
|
864
|
-
formatters.o = function(v) {
|
|
865
|
-
this.inspectOpts.colors = this.useColors;
|
|
866
|
-
return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
|
|
867
|
-
};
|
|
868
|
-
formatters.O = function(v) {
|
|
869
|
-
this.inspectOpts.colors = this.useColors;
|
|
870
|
-
return util.inspect(v, this.inspectOpts);
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
|
-
});
|
|
874
|
-
|
|
875
|
-
// ../../node_modules/debug/src/index.js
|
|
876
|
-
var require_src = __commonJS({
|
|
877
|
-
"../../node_modules/debug/src/index.js"(exports, module) {
|
|
878
|
-
"use strict";
|
|
879
|
-
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
880
|
-
module.exports = require_browser();
|
|
881
|
-
} else {
|
|
882
|
-
module.exports = require_node();
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
});
|
|
886
|
-
|
|
887
1
|
// src/constants/defaults.ts
|
|
888
2
|
function getBaseUrl(environment = "prod") {
|
|
889
3
|
switch (environment) {
|
|
@@ -1031,3158 +145,233 @@ var DEFAULT_THEME = {
|
|
|
1031
145
|
|
|
1032
146
|
// src/client/api-client.ts
|
|
1033
147
|
var AutorenderApiClient = class {
|
|
1034
|
-
constructor(opts) {
|
|
1035
|
-
if (!opts.apiKey) {
|
|
1036
|
-
throw new Error("apiKey is required");
|
|
1037
|
-
}
|
|
1038
|
-
this.apiKey = opts.apiKey;
|
|
1039
|
-
this.baseUrl = (opts.baseUrl || getBaseUrl(opts.environment || "prod")).replace(/\/+$/, "");
|
|
1040
|
-
}
|
|
1041
|
-
uploadFile(params, onProgress, signal) {
|
|
1042
|
-
return new Promise((resolve, reject) => {
|
|
1043
|
-
if (signal?.aborted) {
|
|
1044
|
-
reject(new DOMException("Upload aborted", "AbortError"));
|
|
1045
|
-
return;
|
|
1046
|
-
}
|
|
1047
|
-
const xhr = new XMLHttpRequest();
|
|
1048
|
-
if (signal) {
|
|
1049
|
-
signal.addEventListener("abort", () => {
|
|
1050
|
-
xhr.abort();
|
|
1051
|
-
reject(new DOMException("Upload aborted", "AbortError"));
|
|
1052
|
-
});
|
|
1053
|
-
}
|
|
1054
|
-
let lastProgress = 0;
|
|
1055
|
-
xhr.upload.onprogress = (event) => {
|
|
1056
|
-
if (event.lengthComputable && onProgress) {
|
|
1057
|
-
const progress = Math.round(event.loaded / event.total * 100);
|
|
1058
|
-
lastProgress = progress;
|
|
1059
|
-
onProgress(progress);
|
|
1060
|
-
} else if (onProgress && event.loaded > 0) {
|
|
1061
|
-
const estimatedProgress = Math.min(
|
|
1062
|
-
95,
|
|
1063
|
-
Math.round(event.loaded / (event.loaded + 1e6) * 100)
|
|
1064
|
-
);
|
|
1065
|
-
if (estimatedProgress > lastProgress) {
|
|
1066
|
-
lastProgress = estimatedProgress;
|
|
1067
|
-
onProgress(estimatedProgress);
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
};
|
|
1071
|
-
xhr.onerror = () => {
|
|
1072
|
-
reject(new Error(`Upload failed: ${xhr.statusText}`));
|
|
1073
|
-
};
|
|
1074
|
-
xhr.onload = () => {
|
|
1075
|
-
try {
|
|
1076
|
-
if (xhr.status < 200 || xhr.status >= 300) {
|
|
1077
|
-
const errorText = xhr.responseText || xhr.statusText;
|
|
1078
|
-
reject(new Error(`Upload failed: ${errorText}`));
|
|
1079
|
-
return;
|
|
1080
|
-
}
|
|
1081
|
-
const newResponse = JSON.parse(xhr.responseText);
|
|
1082
|
-
const response = {
|
|
1083
|
-
success: true,
|
|
1084
|
-
file_no: newResponse.file_no || newResponse.id,
|
|
1085
|
-
name: newResponse.name,
|
|
1086
|
-
url: newResponse.url,
|
|
1087
|
-
file_size: newResponse.size,
|
|
1088
|
-
format: newResponse.format,
|
|
1089
|
-
width: newResponse.width,
|
|
1090
|
-
height: newResponse.height,
|
|
1091
|
-
created_at: newResponse.created_at,
|
|
1092
|
-
path: newResponse.path,
|
|
1093
|
-
workspace_no: newResponse.workspace_id,
|
|
1094
|
-
isDuplicate: newResponse.is_duplicate || false
|
|
1095
|
-
};
|
|
1096
|
-
resolve(response);
|
|
1097
|
-
} catch (error) {
|
|
1098
|
-
reject(new Error("Failed to parse response"));
|
|
1099
|
-
}
|
|
1100
|
-
};
|
|
1101
|
-
const endpoint = `${this.baseUrl}/uploads`;
|
|
1102
|
-
const formData = new FormData();
|
|
1103
|
-
formData.append("file", params.file);
|
|
1104
|
-
formData.append("file_name", params.file.name);
|
|
1105
|
-
if (params.folderPath) {
|
|
1106
|
-
formData.append("folder", params.folderPath);
|
|
1107
|
-
}
|
|
1108
|
-
if (params.settings?.tags?.length) {
|
|
1109
|
-
formData.append("tags", params.settings.tags.join(","));
|
|
1110
|
-
}
|
|
1111
|
-
if (params.settings?.pretransformations) {
|
|
1112
|
-
formData.append("transform", params.settings.pretransformations);
|
|
1113
|
-
}
|
|
1114
|
-
if (params.settings?.custom_id) {
|
|
1115
|
-
formData.append("custom_id", params.settings.custom_id);
|
|
1116
|
-
}
|
|
1117
|
-
xhr.open("POST", endpoint);
|
|
1118
|
-
xhr.setRequestHeader("Authorization", `Bearer ${this.apiKey}`);
|
|
1119
|
-
xhr.setRequestHeader("accept", "application/json");
|
|
1120
|
-
xhr.send(formData);
|
|
1121
|
-
});
|
|
1122
|
-
}
|
|
1123
|
-
};
|
|
1124
|
-
|
|
1125
|
-
// src/utils/helpers.ts
|
|
1126
|
-
function generateId() {
|
|
1127
|
-
if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
|
|
1128
|
-
return crypto.randomUUID();
|
|
1129
|
-
}
|
|
1130
|
-
return "id-" + Math.random().toString(36).slice(2, 11);
|
|
1131
|
-
}
|
|
1132
|
-
function resolveIcon(renderer) {
|
|
1133
|
-
if (typeof renderer === "function") {
|
|
1134
|
-
return resolveIcon(renderer());
|
|
1135
|
-
}
|
|
1136
|
-
if (typeof renderer === "string") {
|
|
1137
|
-
const template = document.createElement("template");
|
|
1138
|
-
template.innerHTML = renderer.trim();
|
|
1139
|
-
return template.content.firstElementChild;
|
|
1140
|
-
}
|
|
1141
|
-
return renderer ? renderer.cloneNode(true) : null;
|
|
1142
|
-
}
|
|
1143
|
-
function toCssVars(theme) {
|
|
1144
|
-
const variables = {};
|
|
1145
|
-
if (theme.accentColor) {
|
|
1146
|
-
variables["--ar-accent"] = theme.accentColor;
|
|
1147
|
-
}
|
|
1148
|
-
if (theme.borderRadius !== void 0) {
|
|
1149
|
-
variables["--ar-radius"] = `${theme.borderRadius}px`;
|
|
1150
|
-
}
|
|
1151
|
-
if (theme.fontFamily) {
|
|
1152
|
-
variables["--ar-font-family"] = theme.fontFamily;
|
|
1153
|
-
}
|
|
1154
|
-
if (theme.dropzoneBackground) {
|
|
1155
|
-
variables["--ar-dropzone-bg"] = theme.dropzoneBackground;
|
|
1156
|
-
}
|
|
1157
|
-
if (theme.dropzoneBorder) {
|
|
1158
|
-
variables["--ar-dropzone-border"] = theme.dropzoneBorder;
|
|
1159
|
-
}
|
|
1160
|
-
return variables;
|
|
1161
|
-
}
|
|
1162
|
-
function applyCssVariables(element, variables) {
|
|
1163
|
-
Object.entries(variables).forEach(([key, value]) => {
|
|
1164
|
-
element.style.setProperty(key, value);
|
|
1165
|
-
});
|
|
1166
|
-
}
|
|
1167
|
-
function getRelativeFolderPath(basePath, relativePath) {
|
|
1168
|
-
if (!relativePath) return void 0;
|
|
1169
|
-
const parts = relativePath.split("/").map((segment) => segment.trim()).filter((segment) => segment && segment !== ".");
|
|
1170
|
-
if (parts.length <= 1) {
|
|
1171
|
-
return void 0;
|
|
1172
|
-
}
|
|
1173
|
-
const folderSegments = parts.slice(0, -1);
|
|
1174
|
-
if (basePath) {
|
|
1175
|
-
const baseSegments = basePath.split("/").map((segment) => segment.trim()).filter((segment) => segment && segment !== ".");
|
|
1176
|
-
let offset = 0;
|
|
1177
|
-
while (offset < baseSegments.length && offset < folderSegments.length && folderSegments[offset] === baseSegments[offset]) {
|
|
1178
|
-
offset += 1;
|
|
1179
|
-
}
|
|
1180
|
-
return offset < folderSegments.length ? folderSegments.slice(offset).join("/") : void 0;
|
|
1181
|
-
}
|
|
1182
|
-
return folderSegments.length ? folderSegments.join("/") : void 0;
|
|
1183
|
-
}
|
|
1184
|
-
function calculateBatchProgress(items) {
|
|
1185
|
-
if (items.length === 0) return 0;
|
|
1186
|
-
const total = items.reduce((acc, item) => acc + item.progress, 0);
|
|
1187
|
-
return Math.round(total / items.length);
|
|
1188
|
-
}
|
|
1189
|
-
var S3_URL_PATTERN = /^s3:\/\/([^/]+)\/(.+)$/i;
|
|
1190
|
-
function sanitizeBaseUrl(baseUrl) {
|
|
1191
|
-
if (!baseUrl) return void 0;
|
|
1192
|
-
const trimmed = baseUrl.trim();
|
|
1193
|
-
if (!trimmed) return void 0;
|
|
1194
|
-
return trimmed.replace(/\/+$/, "");
|
|
1195
|
-
}
|
|
1196
|
-
function extractWorkspaceFromUrl(url) {
|
|
1197
|
-
if (!url) return void 0;
|
|
1198
|
-
const s3Match = S3_URL_PATTERN.exec(url);
|
|
1199
|
-
if (s3Match) {
|
|
1200
|
-
return s3Match[1];
|
|
1201
|
-
}
|
|
1202
|
-
try {
|
|
1203
|
-
const parsed = new URL(url);
|
|
1204
|
-
const firstSegment = parsed.pathname.replace(/^\/+/, "").split("/")[0];
|
|
1205
|
-
return firstSegment || void 0;
|
|
1206
|
-
} catch {
|
|
1207
|
-
return void 0;
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
function extractPathFromUrl(url) {
|
|
1211
|
-
if (!url) return void 0;
|
|
1212
|
-
const s3Match = S3_URL_PATTERN.exec(url);
|
|
1213
|
-
if (s3Match) {
|
|
1214
|
-
return s3Match[2];
|
|
1215
|
-
}
|
|
1216
|
-
try {
|
|
1217
|
-
const parsed = new URL(url);
|
|
1218
|
-
const [, ...rest] = parsed.pathname.replace(/^\/+/, "").split("/");
|
|
1219
|
-
return rest.length ? rest.join("/") : void 0;
|
|
1220
|
-
} catch {
|
|
1221
|
-
return void 0;
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
function buildAssetDeliveryUrl(baseUrl, workspace, path, fallback) {
|
|
1225
|
-
const sanitizedBase = sanitizeBaseUrl(baseUrl);
|
|
1226
|
-
if (!sanitizedBase || !workspace || !path) {
|
|
1227
|
-
return fallback;
|
|
1228
|
-
}
|
|
1229
|
-
const normalizedPath = path.split("/").filter(Boolean).map((segment) => encodeURIComponent(segment)).join("/");
|
|
1230
|
-
return `${sanitizedBase}/${workspace}/${normalizedPath}`.replace(/([^:]\/)\/+/g, "$1");
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
// ../../node_modules/token-types/lib/index.js
|
|
1234
|
-
var ieee754 = __toESM(require_ieee754(), 1);
|
|
1235
|
-
|
|
1236
|
-
// ../../node_modules/@borewit/text-codec/lib/index.js
|
|
1237
|
-
var WINDOWS_1252_EXTRA = {
|
|
1238
|
-
128: "\u20AC",
|
|
1239
|
-
130: "\u201A",
|
|
1240
|
-
131: "\u0192",
|
|
1241
|
-
132: "\u201E",
|
|
1242
|
-
133: "\u2026",
|
|
1243
|
-
134: "\u2020",
|
|
1244
|
-
135: "\u2021",
|
|
1245
|
-
136: "\u02C6",
|
|
1246
|
-
137: "\u2030",
|
|
1247
|
-
138: "\u0160",
|
|
1248
|
-
139: "\u2039",
|
|
1249
|
-
140: "\u0152",
|
|
1250
|
-
142: "\u017D",
|
|
1251
|
-
145: "\u2018",
|
|
1252
|
-
146: "\u2019",
|
|
1253
|
-
147: "\u201C",
|
|
1254
|
-
148: "\u201D",
|
|
1255
|
-
149: "\u2022",
|
|
1256
|
-
150: "\u2013",
|
|
1257
|
-
151: "\u2014",
|
|
1258
|
-
152: "\u02DC",
|
|
1259
|
-
153: "\u2122",
|
|
1260
|
-
154: "\u0161",
|
|
1261
|
-
155: "\u203A",
|
|
1262
|
-
156: "\u0153",
|
|
1263
|
-
158: "\u017E",
|
|
1264
|
-
159: "\u0178"
|
|
1265
|
-
};
|
|
1266
|
-
var WINDOWS_1252_REVERSE = {};
|
|
1267
|
-
for (const [code, char] of Object.entries(WINDOWS_1252_EXTRA)) {
|
|
1268
|
-
WINDOWS_1252_REVERSE[char] = Number.parseInt(code);
|
|
1269
|
-
}
|
|
1270
|
-
function textDecode(bytes, encoding = "utf-8") {
|
|
1271
|
-
switch (encoding.toLowerCase()) {
|
|
1272
|
-
case "utf-8":
|
|
1273
|
-
case "utf8":
|
|
1274
|
-
if (typeof globalThis.TextDecoder !== "undefined") {
|
|
1275
|
-
return new globalThis.TextDecoder("utf-8").decode(bytes);
|
|
1276
|
-
}
|
|
1277
|
-
return decodeUTF8(bytes);
|
|
1278
|
-
case "utf-16le":
|
|
1279
|
-
return decodeUTF16LE(bytes);
|
|
1280
|
-
case "ascii":
|
|
1281
|
-
return decodeASCII(bytes);
|
|
1282
|
-
case "latin1":
|
|
1283
|
-
case "iso-8859-1":
|
|
1284
|
-
return decodeLatin1(bytes);
|
|
1285
|
-
case "windows-1252":
|
|
1286
|
-
return decodeWindows1252(bytes);
|
|
1287
|
-
default:
|
|
1288
|
-
throw new RangeError(`Encoding '${encoding}' not supported`);
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
function decodeUTF8(bytes) {
|
|
1292
|
-
let out = "";
|
|
1293
|
-
let i = 0;
|
|
1294
|
-
while (i < bytes.length) {
|
|
1295
|
-
const b1 = bytes[i++];
|
|
1296
|
-
if (b1 < 128) {
|
|
1297
|
-
out += String.fromCharCode(b1);
|
|
1298
|
-
} else if (b1 < 224) {
|
|
1299
|
-
const b2 = bytes[i++] & 63;
|
|
1300
|
-
out += String.fromCharCode((b1 & 31) << 6 | b2);
|
|
1301
|
-
} else if (b1 < 240) {
|
|
1302
|
-
const b2 = bytes[i++] & 63;
|
|
1303
|
-
const b3 = bytes[i++] & 63;
|
|
1304
|
-
out += String.fromCharCode((b1 & 15) << 12 | b2 << 6 | b3);
|
|
1305
|
-
} else {
|
|
1306
|
-
const b2 = bytes[i++] & 63;
|
|
1307
|
-
const b3 = bytes[i++] & 63;
|
|
1308
|
-
const b4 = bytes[i++] & 63;
|
|
1309
|
-
let cp = (b1 & 7) << 18 | b2 << 12 | b3 << 6 | b4;
|
|
1310
|
-
cp -= 65536;
|
|
1311
|
-
out += String.fromCharCode(55296 + (cp >> 10 & 1023), 56320 + (cp & 1023));
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
return out;
|
|
1315
|
-
}
|
|
1316
|
-
function decodeUTF16LE(bytes) {
|
|
1317
|
-
let out = "";
|
|
1318
|
-
for (let i = 0; i < bytes.length; i += 2) {
|
|
1319
|
-
out += String.fromCharCode(bytes[i] | bytes[i + 1] << 8);
|
|
1320
|
-
}
|
|
1321
|
-
return out;
|
|
1322
|
-
}
|
|
1323
|
-
function decodeASCII(bytes) {
|
|
1324
|
-
return String.fromCharCode(...bytes.map((b) => b & 127));
|
|
1325
|
-
}
|
|
1326
|
-
function decodeLatin1(bytes) {
|
|
1327
|
-
return String.fromCharCode(...bytes);
|
|
1328
|
-
}
|
|
1329
|
-
function decodeWindows1252(bytes) {
|
|
1330
|
-
let out = "";
|
|
1331
|
-
for (const b of bytes) {
|
|
1332
|
-
if (b >= 128 && b <= 159 && WINDOWS_1252_EXTRA[b]) {
|
|
1333
|
-
out += WINDOWS_1252_EXTRA[b];
|
|
1334
|
-
} else {
|
|
1335
|
-
out += String.fromCharCode(b);
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
return out;
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
// ../../node_modules/token-types/lib/index.js
|
|
1342
|
-
function dv(array) {
|
|
1343
|
-
return new DataView(array.buffer, array.byteOffset);
|
|
1344
|
-
}
|
|
1345
|
-
var UINT8 = {
|
|
1346
|
-
len: 1,
|
|
1347
|
-
get(array, offset) {
|
|
1348
|
-
return dv(array).getUint8(offset);
|
|
1349
|
-
},
|
|
1350
|
-
put(array, offset, value) {
|
|
1351
|
-
dv(array).setUint8(offset, value);
|
|
1352
|
-
return offset + 1;
|
|
1353
|
-
}
|
|
1354
|
-
};
|
|
1355
|
-
var UINT16_LE = {
|
|
1356
|
-
len: 2,
|
|
1357
|
-
get(array, offset) {
|
|
1358
|
-
return dv(array).getUint16(offset, true);
|
|
1359
|
-
},
|
|
1360
|
-
put(array, offset, value) {
|
|
1361
|
-
dv(array).setUint16(offset, value, true);
|
|
1362
|
-
return offset + 2;
|
|
1363
|
-
}
|
|
1364
|
-
};
|
|
1365
|
-
var UINT16_BE = {
|
|
1366
|
-
len: 2,
|
|
1367
|
-
get(array, offset) {
|
|
1368
|
-
return dv(array).getUint16(offset);
|
|
1369
|
-
},
|
|
1370
|
-
put(array, offset, value) {
|
|
1371
|
-
dv(array).setUint16(offset, value);
|
|
1372
|
-
return offset + 2;
|
|
1373
|
-
}
|
|
1374
|
-
};
|
|
1375
|
-
var UINT32_LE = {
|
|
1376
|
-
len: 4,
|
|
1377
|
-
get(array, offset) {
|
|
1378
|
-
return dv(array).getUint32(offset, true);
|
|
1379
|
-
},
|
|
1380
|
-
put(array, offset, value) {
|
|
1381
|
-
dv(array).setUint32(offset, value, true);
|
|
1382
|
-
return offset + 4;
|
|
1383
|
-
}
|
|
1384
|
-
};
|
|
1385
|
-
var UINT32_BE = {
|
|
1386
|
-
len: 4,
|
|
1387
|
-
get(array, offset) {
|
|
1388
|
-
return dv(array).getUint32(offset);
|
|
1389
|
-
},
|
|
1390
|
-
put(array, offset, value) {
|
|
1391
|
-
dv(array).setUint32(offset, value);
|
|
1392
|
-
return offset + 4;
|
|
1393
|
-
}
|
|
1394
|
-
};
|
|
1395
|
-
var INT32_BE = {
|
|
1396
|
-
len: 4,
|
|
1397
|
-
get(array, offset) {
|
|
1398
|
-
return dv(array).getInt32(offset);
|
|
1399
|
-
},
|
|
1400
|
-
put(array, offset, value) {
|
|
1401
|
-
dv(array).setInt32(offset, value);
|
|
1402
|
-
return offset + 4;
|
|
1403
|
-
}
|
|
1404
|
-
};
|
|
1405
|
-
var UINT64_LE = {
|
|
1406
|
-
len: 8,
|
|
1407
|
-
get(array, offset) {
|
|
1408
|
-
return dv(array).getBigUint64(offset, true);
|
|
1409
|
-
},
|
|
1410
|
-
put(array, offset, value) {
|
|
1411
|
-
dv(array).setBigUint64(offset, value, true);
|
|
1412
|
-
return offset + 8;
|
|
1413
|
-
}
|
|
1414
|
-
};
|
|
1415
|
-
var StringType = class {
|
|
1416
|
-
constructor(len, encoding) {
|
|
1417
|
-
this.len = len;
|
|
1418
|
-
this.encoding = encoding;
|
|
1419
|
-
}
|
|
1420
|
-
get(data, offset = 0) {
|
|
1421
|
-
const bytes = data.subarray(offset, offset + this.len);
|
|
1422
|
-
return textDecode(bytes, this.encoding);
|
|
1423
|
-
}
|
|
1424
|
-
};
|
|
1425
|
-
|
|
1426
|
-
// ../../node_modules/strtok3/lib/stream/Errors.js
|
|
1427
|
-
var defaultMessages = "End-Of-Stream";
|
|
1428
|
-
var EndOfStreamError = class extends Error {
|
|
1429
|
-
constructor() {
|
|
1430
|
-
super(defaultMessages);
|
|
1431
|
-
this.name = "EndOfStreamError";
|
|
1432
|
-
}
|
|
1433
|
-
};
|
|
1434
|
-
var AbortError = class extends Error {
|
|
1435
|
-
constructor(message = "The operation was aborted") {
|
|
1436
|
-
super(message);
|
|
1437
|
-
this.name = "AbortError";
|
|
1438
|
-
}
|
|
1439
|
-
};
|
|
1440
|
-
|
|
1441
|
-
// ../../node_modules/strtok3/lib/stream/AbstractStreamReader.js
|
|
1442
|
-
var AbstractStreamReader = class {
|
|
1443
|
-
constructor() {
|
|
1444
|
-
this.endOfStream = false;
|
|
1445
|
-
this.interrupted = false;
|
|
1446
|
-
this.peekQueue = [];
|
|
1447
|
-
}
|
|
1448
|
-
async peek(uint8Array, mayBeLess = false) {
|
|
1449
|
-
const bytesRead = await this.read(uint8Array, mayBeLess);
|
|
1450
|
-
this.peekQueue.push(uint8Array.subarray(0, bytesRead));
|
|
1451
|
-
return bytesRead;
|
|
1452
|
-
}
|
|
1453
|
-
async read(buffer, mayBeLess = false) {
|
|
1454
|
-
if (buffer.length === 0) {
|
|
1455
|
-
return 0;
|
|
1456
|
-
}
|
|
1457
|
-
let bytesRead = this.readFromPeekBuffer(buffer);
|
|
1458
|
-
if (!this.endOfStream) {
|
|
1459
|
-
bytesRead += await this.readRemainderFromStream(buffer.subarray(bytesRead), mayBeLess);
|
|
1460
|
-
}
|
|
1461
|
-
if (bytesRead === 0 && !mayBeLess) {
|
|
1462
|
-
throw new EndOfStreamError();
|
|
1463
|
-
}
|
|
1464
|
-
return bytesRead;
|
|
1465
|
-
}
|
|
1466
|
-
/**
|
|
1467
|
-
* Read chunk from stream
|
|
1468
|
-
* @param buffer - Target Uint8Array (or Buffer) to store data read from stream in
|
|
1469
|
-
* @returns Number of bytes read
|
|
1470
|
-
*/
|
|
1471
|
-
readFromPeekBuffer(buffer) {
|
|
1472
|
-
let remaining = buffer.length;
|
|
1473
|
-
let bytesRead = 0;
|
|
1474
|
-
while (this.peekQueue.length > 0 && remaining > 0) {
|
|
1475
|
-
const peekData = this.peekQueue.pop();
|
|
1476
|
-
if (!peekData)
|
|
1477
|
-
throw new Error("peekData should be defined");
|
|
1478
|
-
const lenCopy = Math.min(peekData.length, remaining);
|
|
1479
|
-
buffer.set(peekData.subarray(0, lenCopy), bytesRead);
|
|
1480
|
-
bytesRead += lenCopy;
|
|
1481
|
-
remaining -= lenCopy;
|
|
1482
|
-
if (lenCopy < peekData.length) {
|
|
1483
|
-
this.peekQueue.push(peekData.subarray(lenCopy));
|
|
1484
|
-
}
|
|
1485
|
-
}
|
|
1486
|
-
return bytesRead;
|
|
1487
|
-
}
|
|
1488
|
-
async readRemainderFromStream(buffer, mayBeLess) {
|
|
1489
|
-
let bytesRead = 0;
|
|
1490
|
-
while (bytesRead < buffer.length && !this.endOfStream) {
|
|
1491
|
-
if (this.interrupted) {
|
|
1492
|
-
throw new AbortError();
|
|
1493
|
-
}
|
|
1494
|
-
const chunkLen = await this.readFromStream(buffer.subarray(bytesRead), mayBeLess);
|
|
1495
|
-
if (chunkLen === 0)
|
|
1496
|
-
break;
|
|
1497
|
-
bytesRead += chunkLen;
|
|
1498
|
-
}
|
|
1499
|
-
if (!mayBeLess && bytesRead < buffer.length) {
|
|
1500
|
-
throw new EndOfStreamError();
|
|
1501
|
-
}
|
|
1502
|
-
return bytesRead;
|
|
1503
|
-
}
|
|
1504
|
-
};
|
|
1505
|
-
|
|
1506
|
-
// ../../node_modules/strtok3/lib/stream/WebStreamReader.js
|
|
1507
|
-
var WebStreamReader = class extends AbstractStreamReader {
|
|
1508
|
-
constructor(reader) {
|
|
1509
|
-
super();
|
|
1510
|
-
this.reader = reader;
|
|
1511
|
-
}
|
|
1512
|
-
async abort() {
|
|
1513
|
-
return this.close();
|
|
1514
|
-
}
|
|
1515
|
-
async close() {
|
|
1516
|
-
this.reader.releaseLock();
|
|
1517
|
-
}
|
|
1518
|
-
};
|
|
1519
|
-
|
|
1520
|
-
// ../../node_modules/strtok3/lib/stream/WebStreamByobReader.js
|
|
1521
|
-
var WebStreamByobReader = class extends WebStreamReader {
|
|
1522
|
-
/**
|
|
1523
|
-
* Read from stream
|
|
1524
|
-
* @param buffer - Target Uint8Array (or Buffer) to store data read from stream in
|
|
1525
|
-
* @param mayBeLess - If true, may fill the buffer partially
|
|
1526
|
-
* @protected Bytes read
|
|
1527
|
-
*/
|
|
1528
|
-
async readFromStream(buffer, mayBeLess) {
|
|
1529
|
-
if (buffer.length === 0)
|
|
1530
|
-
return 0;
|
|
1531
|
-
const result = await this.reader.read(new Uint8Array(buffer.length), { min: mayBeLess ? void 0 : buffer.length });
|
|
1532
|
-
if (result.done) {
|
|
1533
|
-
this.endOfStream = result.done;
|
|
1534
|
-
}
|
|
1535
|
-
if (result.value) {
|
|
1536
|
-
buffer.set(result.value);
|
|
1537
|
-
return result.value.length;
|
|
1538
|
-
}
|
|
1539
|
-
return 0;
|
|
1540
|
-
}
|
|
1541
|
-
};
|
|
1542
|
-
|
|
1543
|
-
// ../../node_modules/strtok3/lib/stream/WebStreamDefaultReader.js
|
|
1544
|
-
var WebStreamDefaultReader = class extends AbstractStreamReader {
|
|
1545
|
-
constructor(reader) {
|
|
1546
|
-
super();
|
|
1547
|
-
this.reader = reader;
|
|
1548
|
-
this.buffer = null;
|
|
1549
|
-
}
|
|
1550
|
-
/**
|
|
1551
|
-
* Copy chunk to target, and store the remainder in this.buffer
|
|
1552
|
-
*/
|
|
1553
|
-
writeChunk(target, chunk) {
|
|
1554
|
-
const written = Math.min(chunk.length, target.length);
|
|
1555
|
-
target.set(chunk.subarray(0, written));
|
|
1556
|
-
if (written < chunk.length) {
|
|
1557
|
-
this.buffer = chunk.subarray(written);
|
|
1558
|
-
} else {
|
|
1559
|
-
this.buffer = null;
|
|
1560
|
-
}
|
|
1561
|
-
return written;
|
|
1562
|
-
}
|
|
1563
|
-
/**
|
|
1564
|
-
* Read from stream
|
|
1565
|
-
* @param buffer - Target Uint8Array (or Buffer) to store data read from stream in
|
|
1566
|
-
* @param mayBeLess - If true, may fill the buffer partially
|
|
1567
|
-
* @protected Bytes read
|
|
1568
|
-
*/
|
|
1569
|
-
async readFromStream(buffer, mayBeLess) {
|
|
1570
|
-
if (buffer.length === 0)
|
|
1571
|
-
return 0;
|
|
1572
|
-
let totalBytesRead = 0;
|
|
1573
|
-
if (this.buffer) {
|
|
1574
|
-
totalBytesRead += this.writeChunk(buffer, this.buffer);
|
|
1575
|
-
}
|
|
1576
|
-
while (totalBytesRead < buffer.length && !this.endOfStream) {
|
|
1577
|
-
const result = await this.reader.read();
|
|
1578
|
-
if (result.done) {
|
|
1579
|
-
this.endOfStream = true;
|
|
1580
|
-
break;
|
|
1581
|
-
}
|
|
1582
|
-
if (result.value) {
|
|
1583
|
-
totalBytesRead += this.writeChunk(buffer.subarray(totalBytesRead), result.value);
|
|
1584
|
-
}
|
|
1585
|
-
}
|
|
1586
|
-
if (!mayBeLess && totalBytesRead === 0 && this.endOfStream) {
|
|
1587
|
-
throw new EndOfStreamError();
|
|
1588
|
-
}
|
|
1589
|
-
return totalBytesRead;
|
|
1590
|
-
}
|
|
1591
|
-
abort() {
|
|
1592
|
-
this.interrupted = true;
|
|
1593
|
-
return this.reader.cancel();
|
|
1594
|
-
}
|
|
1595
|
-
async close() {
|
|
1596
|
-
await this.abort();
|
|
1597
|
-
this.reader.releaseLock();
|
|
1598
|
-
}
|
|
1599
|
-
};
|
|
1600
|
-
|
|
1601
|
-
// ../../node_modules/strtok3/lib/stream/WebStreamReaderFactory.js
|
|
1602
|
-
function makeWebStreamReader(stream) {
|
|
1603
|
-
try {
|
|
1604
|
-
const reader = stream.getReader({ mode: "byob" });
|
|
1605
|
-
if (reader instanceof ReadableStreamDefaultReader) {
|
|
1606
|
-
return new WebStreamDefaultReader(reader);
|
|
1607
|
-
}
|
|
1608
|
-
return new WebStreamByobReader(reader);
|
|
1609
|
-
} catch (error) {
|
|
1610
|
-
if (error instanceof TypeError) {
|
|
1611
|
-
return new WebStreamDefaultReader(stream.getReader());
|
|
1612
|
-
}
|
|
1613
|
-
throw error;
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
|
|
1617
|
-
// ../../node_modules/strtok3/lib/AbstractTokenizer.js
|
|
1618
|
-
var AbstractTokenizer = class {
|
|
1619
|
-
/**
|
|
1620
|
-
* Constructor
|
|
1621
|
-
* @param options Tokenizer options
|
|
1622
|
-
* @protected
|
|
1623
|
-
*/
|
|
1624
|
-
constructor(options) {
|
|
1625
|
-
this.numBuffer = new Uint8Array(8);
|
|
1626
|
-
this.position = 0;
|
|
1627
|
-
this.onClose = options?.onClose;
|
|
1628
|
-
if (options?.abortSignal) {
|
|
1629
|
-
options.abortSignal.addEventListener("abort", () => {
|
|
1630
|
-
this.abort();
|
|
1631
|
-
});
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
/**
|
|
1635
|
-
* Read a token from the tokenizer-stream
|
|
1636
|
-
* @param token - The token to read
|
|
1637
|
-
* @param position - If provided, the desired position in the tokenizer-stream
|
|
1638
|
-
* @returns Promise with token data
|
|
1639
|
-
*/
|
|
1640
|
-
async readToken(token, position = this.position) {
|
|
1641
|
-
const uint8Array = new Uint8Array(token.len);
|
|
1642
|
-
const len = await this.readBuffer(uint8Array, { position });
|
|
1643
|
-
if (len < token.len)
|
|
1644
|
-
throw new EndOfStreamError();
|
|
1645
|
-
return token.get(uint8Array, 0);
|
|
1646
|
-
}
|
|
1647
|
-
/**
|
|
1648
|
-
* Peek a token from the tokenizer-stream.
|
|
1649
|
-
* @param token - Token to peek from the tokenizer-stream.
|
|
1650
|
-
* @param position - Offset where to begin reading within the file. If position is null, data will be read from the current file position.
|
|
1651
|
-
* @returns Promise with token data
|
|
1652
|
-
*/
|
|
1653
|
-
async peekToken(token, position = this.position) {
|
|
1654
|
-
const uint8Array = new Uint8Array(token.len);
|
|
1655
|
-
const len = await this.peekBuffer(uint8Array, { position });
|
|
1656
|
-
if (len < token.len)
|
|
1657
|
-
throw new EndOfStreamError();
|
|
1658
|
-
return token.get(uint8Array, 0);
|
|
1659
|
-
}
|
|
1660
|
-
/**
|
|
1661
|
-
* Read a numeric token from the stream
|
|
1662
|
-
* @param token - Numeric token
|
|
1663
|
-
* @returns Promise with number
|
|
1664
|
-
*/
|
|
1665
|
-
async readNumber(token) {
|
|
1666
|
-
const len = await this.readBuffer(this.numBuffer, { length: token.len });
|
|
1667
|
-
if (len < token.len)
|
|
1668
|
-
throw new EndOfStreamError();
|
|
1669
|
-
return token.get(this.numBuffer, 0);
|
|
1670
|
-
}
|
|
1671
|
-
/**
|
|
1672
|
-
* Read a numeric token from the stream
|
|
1673
|
-
* @param token - Numeric token
|
|
1674
|
-
* @returns Promise with number
|
|
1675
|
-
*/
|
|
1676
|
-
async peekNumber(token) {
|
|
1677
|
-
const len = await this.peekBuffer(this.numBuffer, { length: token.len });
|
|
1678
|
-
if (len < token.len)
|
|
1679
|
-
throw new EndOfStreamError();
|
|
1680
|
-
return token.get(this.numBuffer, 0);
|
|
1681
|
-
}
|
|
1682
|
-
/**
|
|
1683
|
-
* Ignore number of bytes, advances the pointer in under tokenizer-stream.
|
|
1684
|
-
* @param length - Number of bytes to ignore
|
|
1685
|
-
* @return resolves the number of bytes ignored, equals length if this available, otherwise the number of bytes available
|
|
1686
|
-
*/
|
|
1687
|
-
async ignore(length) {
|
|
1688
|
-
if (this.fileInfo.size !== void 0) {
|
|
1689
|
-
const bytesLeft = this.fileInfo.size - this.position;
|
|
1690
|
-
if (length > bytesLeft) {
|
|
1691
|
-
this.position += bytesLeft;
|
|
1692
|
-
return bytesLeft;
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
this.position += length;
|
|
1696
|
-
return length;
|
|
1697
|
-
}
|
|
1698
|
-
async close() {
|
|
1699
|
-
await this.abort();
|
|
1700
|
-
await this.onClose?.();
|
|
1701
|
-
}
|
|
1702
|
-
normalizeOptions(uint8Array, options) {
|
|
1703
|
-
if (!this.supportsRandomAccess() && options && options.position !== void 0 && options.position < this.position) {
|
|
1704
|
-
throw new Error("`options.position` must be equal or greater than `tokenizer.position`");
|
|
1705
|
-
}
|
|
1706
|
-
return {
|
|
1707
|
-
...{
|
|
1708
|
-
mayBeLess: false,
|
|
1709
|
-
offset: 0,
|
|
1710
|
-
length: uint8Array.length,
|
|
1711
|
-
position: this.position
|
|
1712
|
-
},
|
|
1713
|
-
...options
|
|
1714
|
-
};
|
|
1715
|
-
}
|
|
1716
|
-
abort() {
|
|
1717
|
-
return Promise.resolve();
|
|
1718
|
-
}
|
|
1719
|
-
};
|
|
1720
|
-
|
|
1721
|
-
// ../../node_modules/strtok3/lib/ReadStreamTokenizer.js
|
|
1722
|
-
var maxBufferSize = 256e3;
|
|
1723
|
-
var ReadStreamTokenizer = class extends AbstractTokenizer {
|
|
1724
|
-
/**
|
|
1725
|
-
* Constructor
|
|
1726
|
-
* @param streamReader stream-reader to read from
|
|
1727
|
-
* @param options Tokenizer options
|
|
1728
|
-
*/
|
|
1729
|
-
constructor(streamReader, options) {
|
|
1730
|
-
super(options);
|
|
1731
|
-
this.streamReader = streamReader;
|
|
1732
|
-
this.fileInfo = options?.fileInfo ?? {};
|
|
1733
|
-
}
|
|
1734
|
-
/**
|
|
1735
|
-
* Read buffer from tokenizer
|
|
1736
|
-
* @param uint8Array - Target Uint8Array to fill with data read from the tokenizer-stream
|
|
1737
|
-
* @param options - Read behaviour options
|
|
1738
|
-
* @returns Promise with number of bytes read
|
|
1739
|
-
*/
|
|
1740
|
-
async readBuffer(uint8Array, options) {
|
|
1741
|
-
const normOptions = this.normalizeOptions(uint8Array, options);
|
|
1742
|
-
const skipBytes = normOptions.position - this.position;
|
|
1743
|
-
if (skipBytes > 0) {
|
|
1744
|
-
await this.ignore(skipBytes);
|
|
1745
|
-
return this.readBuffer(uint8Array, options);
|
|
1746
|
-
}
|
|
1747
|
-
if (skipBytes < 0) {
|
|
1748
|
-
throw new Error("`options.position` must be equal or greater than `tokenizer.position`");
|
|
1749
|
-
}
|
|
1750
|
-
if (normOptions.length === 0) {
|
|
1751
|
-
return 0;
|
|
1752
|
-
}
|
|
1753
|
-
const bytesRead = await this.streamReader.read(uint8Array.subarray(0, normOptions.length), normOptions.mayBeLess);
|
|
1754
|
-
this.position += bytesRead;
|
|
1755
|
-
if ((!options || !options.mayBeLess) && bytesRead < normOptions.length) {
|
|
1756
|
-
throw new EndOfStreamError();
|
|
1757
|
-
}
|
|
1758
|
-
return bytesRead;
|
|
1759
|
-
}
|
|
1760
|
-
/**
|
|
1761
|
-
* Peek (read ahead) buffer from tokenizer
|
|
1762
|
-
* @param uint8Array - Uint8Array (or Buffer) to write data to
|
|
1763
|
-
* @param options - Read behaviour options
|
|
1764
|
-
* @returns Promise with number of bytes peeked
|
|
1765
|
-
*/
|
|
1766
|
-
async peekBuffer(uint8Array, options) {
|
|
1767
|
-
const normOptions = this.normalizeOptions(uint8Array, options);
|
|
1768
|
-
let bytesRead = 0;
|
|
1769
|
-
if (normOptions.position) {
|
|
1770
|
-
const skipBytes = normOptions.position - this.position;
|
|
1771
|
-
if (skipBytes > 0) {
|
|
1772
|
-
const skipBuffer = new Uint8Array(normOptions.length + skipBytes);
|
|
1773
|
-
bytesRead = await this.peekBuffer(skipBuffer, { mayBeLess: normOptions.mayBeLess });
|
|
1774
|
-
uint8Array.set(skipBuffer.subarray(skipBytes));
|
|
1775
|
-
return bytesRead - skipBytes;
|
|
1776
|
-
}
|
|
1777
|
-
if (skipBytes < 0) {
|
|
1778
|
-
throw new Error("Cannot peek from a negative offset in a stream");
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
if (normOptions.length > 0) {
|
|
1782
|
-
try {
|
|
1783
|
-
bytesRead = await this.streamReader.peek(uint8Array.subarray(0, normOptions.length), normOptions.mayBeLess);
|
|
1784
|
-
} catch (err) {
|
|
1785
|
-
if (options?.mayBeLess && err instanceof EndOfStreamError) {
|
|
1786
|
-
return 0;
|
|
1787
|
-
}
|
|
1788
|
-
throw err;
|
|
1789
|
-
}
|
|
1790
|
-
if (!normOptions.mayBeLess && bytesRead < normOptions.length) {
|
|
1791
|
-
throw new EndOfStreamError();
|
|
1792
|
-
}
|
|
1793
|
-
}
|
|
1794
|
-
return bytesRead;
|
|
1795
|
-
}
|
|
1796
|
-
async ignore(length) {
|
|
1797
|
-
const bufSize = Math.min(maxBufferSize, length);
|
|
1798
|
-
const buf = new Uint8Array(bufSize);
|
|
1799
|
-
let totBytesRead = 0;
|
|
1800
|
-
while (totBytesRead < length) {
|
|
1801
|
-
const remaining = length - totBytesRead;
|
|
1802
|
-
const bytesRead = await this.readBuffer(buf, { length: Math.min(bufSize, remaining) });
|
|
1803
|
-
if (bytesRead < 0) {
|
|
1804
|
-
return bytesRead;
|
|
1805
|
-
}
|
|
1806
|
-
totBytesRead += bytesRead;
|
|
1807
|
-
}
|
|
1808
|
-
return totBytesRead;
|
|
1809
|
-
}
|
|
1810
|
-
abort() {
|
|
1811
|
-
return this.streamReader.abort();
|
|
1812
|
-
}
|
|
1813
|
-
async close() {
|
|
1814
|
-
return this.streamReader.close();
|
|
1815
|
-
}
|
|
1816
|
-
supportsRandomAccess() {
|
|
1817
|
-
return false;
|
|
1818
|
-
}
|
|
1819
|
-
};
|
|
1820
|
-
|
|
1821
|
-
// ../../node_modules/strtok3/lib/BufferTokenizer.js
|
|
1822
|
-
var BufferTokenizer = class extends AbstractTokenizer {
|
|
1823
|
-
/**
|
|
1824
|
-
* Construct BufferTokenizer
|
|
1825
|
-
* @param uint8Array - Uint8Array to tokenize
|
|
1826
|
-
* @param options Tokenizer options
|
|
1827
|
-
*/
|
|
1828
|
-
constructor(uint8Array, options) {
|
|
1829
|
-
super(options);
|
|
1830
|
-
this.uint8Array = uint8Array;
|
|
1831
|
-
this.fileInfo = { ...options?.fileInfo ?? {}, ...{ size: uint8Array.length } };
|
|
1832
|
-
}
|
|
1833
|
-
/**
|
|
1834
|
-
* Read buffer from tokenizer
|
|
1835
|
-
* @param uint8Array - Uint8Array to tokenize
|
|
1836
|
-
* @param options - Read behaviour options
|
|
1837
|
-
* @returns {Promise<number>}
|
|
1838
|
-
*/
|
|
1839
|
-
async readBuffer(uint8Array, options) {
|
|
1840
|
-
if (options?.position) {
|
|
1841
|
-
this.position = options.position;
|
|
1842
|
-
}
|
|
1843
|
-
const bytesRead = await this.peekBuffer(uint8Array, options);
|
|
1844
|
-
this.position += bytesRead;
|
|
1845
|
-
return bytesRead;
|
|
1846
|
-
}
|
|
1847
|
-
/**
|
|
1848
|
-
* Peek (read ahead) buffer from tokenizer
|
|
1849
|
-
* @param uint8Array
|
|
1850
|
-
* @param options - Read behaviour options
|
|
1851
|
-
* @returns {Promise<number>}
|
|
1852
|
-
*/
|
|
1853
|
-
async peekBuffer(uint8Array, options) {
|
|
1854
|
-
const normOptions = this.normalizeOptions(uint8Array, options);
|
|
1855
|
-
const bytes2read = Math.min(this.uint8Array.length - normOptions.position, normOptions.length);
|
|
1856
|
-
if (!normOptions.mayBeLess && bytes2read < normOptions.length) {
|
|
1857
|
-
throw new EndOfStreamError();
|
|
1858
|
-
}
|
|
1859
|
-
uint8Array.set(this.uint8Array.subarray(normOptions.position, normOptions.position + bytes2read));
|
|
1860
|
-
return bytes2read;
|
|
1861
|
-
}
|
|
1862
|
-
close() {
|
|
1863
|
-
return super.close();
|
|
1864
|
-
}
|
|
1865
|
-
supportsRandomAccess() {
|
|
1866
|
-
return true;
|
|
1867
|
-
}
|
|
1868
|
-
setPosition(position) {
|
|
1869
|
-
this.position = position;
|
|
1870
|
-
}
|
|
1871
|
-
};
|
|
1872
|
-
|
|
1873
|
-
// ../../node_modules/strtok3/lib/BlobTokenizer.js
|
|
1874
|
-
var BlobTokenizer = class extends AbstractTokenizer {
|
|
1875
|
-
/**
|
|
1876
|
-
* Construct BufferTokenizer
|
|
1877
|
-
* @param blob - Uint8Array to tokenize
|
|
1878
|
-
* @param options Tokenizer options
|
|
1879
|
-
*/
|
|
1880
|
-
constructor(blob, options) {
|
|
1881
|
-
super(options);
|
|
1882
|
-
this.blob = blob;
|
|
1883
|
-
this.fileInfo = { ...options?.fileInfo ?? {}, ...{ size: blob.size, mimeType: blob.type } };
|
|
1884
|
-
}
|
|
1885
|
-
/**
|
|
1886
|
-
* Read buffer from tokenizer
|
|
1887
|
-
* @param uint8Array - Uint8Array to tokenize
|
|
1888
|
-
* @param options - Read behaviour options
|
|
1889
|
-
* @returns {Promise<number>}
|
|
1890
|
-
*/
|
|
1891
|
-
async readBuffer(uint8Array, options) {
|
|
1892
|
-
if (options?.position) {
|
|
1893
|
-
this.position = options.position;
|
|
1894
|
-
}
|
|
1895
|
-
const bytesRead = await this.peekBuffer(uint8Array, options);
|
|
1896
|
-
this.position += bytesRead;
|
|
1897
|
-
return bytesRead;
|
|
1898
|
-
}
|
|
1899
|
-
/**
|
|
1900
|
-
* Peek (read ahead) buffer from tokenizer
|
|
1901
|
-
* @param buffer
|
|
1902
|
-
* @param options - Read behaviour options
|
|
1903
|
-
* @returns {Promise<number>}
|
|
1904
|
-
*/
|
|
1905
|
-
async peekBuffer(buffer, options) {
|
|
1906
|
-
const normOptions = this.normalizeOptions(buffer, options);
|
|
1907
|
-
const bytes2read = Math.min(this.blob.size - normOptions.position, normOptions.length);
|
|
1908
|
-
if (!normOptions.mayBeLess && bytes2read < normOptions.length) {
|
|
1909
|
-
throw new EndOfStreamError();
|
|
1910
|
-
}
|
|
1911
|
-
const arrayBuffer = await this.blob.slice(normOptions.position, normOptions.position + bytes2read).arrayBuffer();
|
|
1912
|
-
buffer.set(new Uint8Array(arrayBuffer));
|
|
1913
|
-
return bytes2read;
|
|
1914
|
-
}
|
|
1915
|
-
close() {
|
|
1916
|
-
return super.close();
|
|
1917
|
-
}
|
|
1918
|
-
supportsRandomAccess() {
|
|
1919
|
-
return true;
|
|
1920
|
-
}
|
|
1921
|
-
setPosition(position) {
|
|
1922
|
-
this.position = position;
|
|
1923
|
-
}
|
|
1924
|
-
};
|
|
1925
|
-
|
|
1926
|
-
// ../../node_modules/strtok3/lib/core.js
|
|
1927
|
-
function fromWebStream(webStream, options) {
|
|
1928
|
-
const webStreamReader = makeWebStreamReader(webStream);
|
|
1929
|
-
const _options = options ?? {};
|
|
1930
|
-
const chainedClose = _options.onClose;
|
|
1931
|
-
_options.onClose = async () => {
|
|
1932
|
-
await webStreamReader.close();
|
|
1933
|
-
if (chainedClose) {
|
|
1934
|
-
return chainedClose();
|
|
1935
|
-
}
|
|
1936
|
-
};
|
|
1937
|
-
return new ReadStreamTokenizer(webStreamReader, _options);
|
|
1938
|
-
}
|
|
1939
|
-
function fromBuffer(uint8Array, options) {
|
|
1940
|
-
return new BufferTokenizer(uint8Array, options);
|
|
1941
|
-
}
|
|
1942
|
-
function fromBlob(blob, options) {
|
|
1943
|
-
return new BlobTokenizer(blob, options);
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
|
-
// ../../node_modules/@tokenizer/inflate/lib/ZipHandler.js
|
|
1947
|
-
var import_debug = __toESM(require_src(), 1);
|
|
1948
|
-
|
|
1949
|
-
// ../../node_modules/@tokenizer/inflate/lib/ZipToken.js
|
|
1950
|
-
var Signature = {
|
|
1951
|
-
LocalFileHeader: 67324752,
|
|
1952
|
-
DataDescriptor: 134695760,
|
|
1953
|
-
CentralFileHeader: 33639248,
|
|
1954
|
-
EndOfCentralDirectory: 101010256
|
|
1955
|
-
};
|
|
1956
|
-
var DataDescriptor = {
|
|
1957
|
-
get(array) {
|
|
1958
|
-
return {
|
|
1959
|
-
signature: UINT32_LE.get(array, 0),
|
|
1960
|
-
compressedSize: UINT32_LE.get(array, 8),
|
|
1961
|
-
uncompressedSize: UINT32_LE.get(array, 12)
|
|
1962
|
-
};
|
|
1963
|
-
},
|
|
1964
|
-
len: 16
|
|
1965
|
-
};
|
|
1966
|
-
var LocalFileHeaderToken = {
|
|
1967
|
-
get(array) {
|
|
1968
|
-
const flags = UINT16_LE.get(array, 6);
|
|
1969
|
-
return {
|
|
1970
|
-
signature: UINT32_LE.get(array, 0),
|
|
1971
|
-
minVersion: UINT16_LE.get(array, 4),
|
|
1972
|
-
dataDescriptor: !!(flags & 8),
|
|
1973
|
-
compressedMethod: UINT16_LE.get(array, 8),
|
|
1974
|
-
compressedSize: UINT32_LE.get(array, 18),
|
|
1975
|
-
uncompressedSize: UINT32_LE.get(array, 22),
|
|
1976
|
-
filenameLength: UINT16_LE.get(array, 26),
|
|
1977
|
-
extraFieldLength: UINT16_LE.get(array, 28),
|
|
1978
|
-
filename: null
|
|
1979
|
-
};
|
|
1980
|
-
},
|
|
1981
|
-
len: 30
|
|
1982
|
-
};
|
|
1983
|
-
var EndOfCentralDirectoryRecordToken = {
|
|
1984
|
-
get(array) {
|
|
1985
|
-
return {
|
|
1986
|
-
signature: UINT32_LE.get(array, 0),
|
|
1987
|
-
nrOfThisDisk: UINT16_LE.get(array, 4),
|
|
1988
|
-
nrOfThisDiskWithTheStart: UINT16_LE.get(array, 6),
|
|
1989
|
-
nrOfEntriesOnThisDisk: UINT16_LE.get(array, 8),
|
|
1990
|
-
nrOfEntriesOfSize: UINT16_LE.get(array, 10),
|
|
1991
|
-
sizeOfCd: UINT32_LE.get(array, 12),
|
|
1992
|
-
offsetOfStartOfCd: UINT32_LE.get(array, 16),
|
|
1993
|
-
zipFileCommentLength: UINT16_LE.get(array, 20)
|
|
1994
|
-
};
|
|
1995
|
-
},
|
|
1996
|
-
len: 22
|
|
1997
|
-
};
|
|
1998
|
-
var FileHeader = {
|
|
1999
|
-
get(array) {
|
|
2000
|
-
const flags = UINT16_LE.get(array, 8);
|
|
2001
|
-
return {
|
|
2002
|
-
signature: UINT32_LE.get(array, 0),
|
|
2003
|
-
minVersion: UINT16_LE.get(array, 6),
|
|
2004
|
-
dataDescriptor: !!(flags & 8),
|
|
2005
|
-
compressedMethod: UINT16_LE.get(array, 10),
|
|
2006
|
-
compressedSize: UINT32_LE.get(array, 20),
|
|
2007
|
-
uncompressedSize: UINT32_LE.get(array, 24),
|
|
2008
|
-
filenameLength: UINT16_LE.get(array, 28),
|
|
2009
|
-
extraFieldLength: UINT16_LE.get(array, 30),
|
|
2010
|
-
fileCommentLength: UINT16_LE.get(array, 32),
|
|
2011
|
-
relativeOffsetOfLocalHeader: UINT32_LE.get(array, 42),
|
|
2012
|
-
filename: null
|
|
2013
|
-
};
|
|
2014
|
-
},
|
|
2015
|
-
len: 46
|
|
2016
|
-
};
|
|
2017
|
-
|
|
2018
|
-
// ../../node_modules/@tokenizer/inflate/lib/ZipHandler.js
|
|
2019
|
-
function signatureToArray(signature) {
|
|
2020
|
-
const signatureBytes = new Uint8Array(UINT32_LE.len);
|
|
2021
|
-
UINT32_LE.put(signatureBytes, 0, signature);
|
|
2022
|
-
return signatureBytes;
|
|
2023
|
-
}
|
|
2024
|
-
var debug = (0, import_debug.default)("tokenizer:inflate");
|
|
2025
|
-
var syncBufferSize = 256 * 1024;
|
|
2026
|
-
var ddSignatureArray = signatureToArray(Signature.DataDescriptor);
|
|
2027
|
-
var eocdSignatureBytes = signatureToArray(Signature.EndOfCentralDirectory);
|
|
2028
|
-
var ZipHandler = class _ZipHandler {
|
|
2029
|
-
constructor(tokenizer) {
|
|
2030
|
-
this.tokenizer = tokenizer;
|
|
2031
|
-
this.syncBuffer = new Uint8Array(syncBufferSize);
|
|
2032
|
-
}
|
|
2033
|
-
async isZip() {
|
|
2034
|
-
return await this.peekSignature() === Signature.LocalFileHeader;
|
|
2035
|
-
}
|
|
2036
|
-
peekSignature() {
|
|
2037
|
-
return this.tokenizer.peekToken(UINT32_LE);
|
|
2038
|
-
}
|
|
2039
|
-
async findEndOfCentralDirectoryLocator() {
|
|
2040
|
-
const randomReadTokenizer = this.tokenizer;
|
|
2041
|
-
const chunkLength = Math.min(16 * 1024, randomReadTokenizer.fileInfo.size);
|
|
2042
|
-
const buffer = this.syncBuffer.subarray(0, chunkLength);
|
|
2043
|
-
await this.tokenizer.readBuffer(buffer, { position: randomReadTokenizer.fileInfo.size - chunkLength });
|
|
2044
|
-
for (let i = buffer.length - 4; i >= 0; i--) {
|
|
2045
|
-
if (buffer[i] === eocdSignatureBytes[0] && buffer[i + 1] === eocdSignatureBytes[1] && buffer[i + 2] === eocdSignatureBytes[2] && buffer[i + 3] === eocdSignatureBytes[3]) {
|
|
2046
|
-
return randomReadTokenizer.fileInfo.size - chunkLength + i;
|
|
2047
|
-
}
|
|
2048
|
-
}
|
|
2049
|
-
return -1;
|
|
2050
|
-
}
|
|
2051
|
-
async readCentralDirectory() {
|
|
2052
|
-
if (!this.tokenizer.supportsRandomAccess()) {
|
|
2053
|
-
debug("Cannot reading central-directory without random-read support");
|
|
2054
|
-
return;
|
|
2055
|
-
}
|
|
2056
|
-
debug("Reading central-directory...");
|
|
2057
|
-
const pos = this.tokenizer.position;
|
|
2058
|
-
const offset = await this.findEndOfCentralDirectoryLocator();
|
|
2059
|
-
if (offset > 0) {
|
|
2060
|
-
debug("Central-directory 32-bit signature found");
|
|
2061
|
-
const eocdHeader = await this.tokenizer.readToken(EndOfCentralDirectoryRecordToken, offset);
|
|
2062
|
-
const files = [];
|
|
2063
|
-
this.tokenizer.setPosition(eocdHeader.offsetOfStartOfCd);
|
|
2064
|
-
for (let n = 0; n < eocdHeader.nrOfEntriesOfSize; ++n) {
|
|
2065
|
-
const entry = await this.tokenizer.readToken(FileHeader);
|
|
2066
|
-
if (entry.signature !== Signature.CentralFileHeader) {
|
|
2067
|
-
throw new Error("Expected Central-File-Header signature");
|
|
2068
|
-
}
|
|
2069
|
-
entry.filename = await this.tokenizer.readToken(new StringType(entry.filenameLength, "utf-8"));
|
|
2070
|
-
await this.tokenizer.ignore(entry.extraFieldLength);
|
|
2071
|
-
await this.tokenizer.ignore(entry.fileCommentLength);
|
|
2072
|
-
files.push(entry);
|
|
2073
|
-
debug(`Add central-directory file-entry: n=${n + 1}/${files.length}: filename=${files[n].filename}`);
|
|
2074
|
-
}
|
|
2075
|
-
this.tokenizer.setPosition(pos);
|
|
2076
|
-
return files;
|
|
2077
|
-
}
|
|
2078
|
-
this.tokenizer.setPosition(pos);
|
|
2079
|
-
}
|
|
2080
|
-
async unzip(fileCb) {
|
|
2081
|
-
const entries = await this.readCentralDirectory();
|
|
2082
|
-
if (entries) {
|
|
2083
|
-
return this.iterateOverCentralDirectory(entries, fileCb);
|
|
2084
|
-
}
|
|
2085
|
-
let stop = false;
|
|
2086
|
-
do {
|
|
2087
|
-
const zipHeader = await this.readLocalFileHeader();
|
|
2088
|
-
if (!zipHeader)
|
|
2089
|
-
break;
|
|
2090
|
-
const next = fileCb(zipHeader);
|
|
2091
|
-
stop = !!next.stop;
|
|
2092
|
-
let fileData;
|
|
2093
|
-
await this.tokenizer.ignore(zipHeader.extraFieldLength);
|
|
2094
|
-
if (zipHeader.dataDescriptor && zipHeader.compressedSize === 0) {
|
|
2095
|
-
const chunks = [];
|
|
2096
|
-
let len = syncBufferSize;
|
|
2097
|
-
debug("Compressed-file-size unknown, scanning for next data-descriptor-signature....");
|
|
2098
|
-
let nextHeaderIndex = -1;
|
|
2099
|
-
while (nextHeaderIndex < 0 && len === syncBufferSize) {
|
|
2100
|
-
len = await this.tokenizer.peekBuffer(this.syncBuffer, { mayBeLess: true });
|
|
2101
|
-
nextHeaderIndex = indexOf(this.syncBuffer.subarray(0, len), ddSignatureArray);
|
|
2102
|
-
const size = nextHeaderIndex >= 0 ? nextHeaderIndex : len;
|
|
2103
|
-
if (next.handler) {
|
|
2104
|
-
const data = new Uint8Array(size);
|
|
2105
|
-
await this.tokenizer.readBuffer(data);
|
|
2106
|
-
chunks.push(data);
|
|
2107
|
-
} else {
|
|
2108
|
-
await this.tokenizer.ignore(size);
|
|
2109
|
-
}
|
|
2110
|
-
}
|
|
2111
|
-
debug(`Found data-descriptor-signature at pos=${this.tokenizer.position}`);
|
|
2112
|
-
if (next.handler) {
|
|
2113
|
-
await this.inflate(zipHeader, mergeArrays(chunks), next.handler);
|
|
2114
|
-
}
|
|
2115
|
-
} else {
|
|
2116
|
-
if (next.handler) {
|
|
2117
|
-
debug(`Reading compressed-file-data: ${zipHeader.compressedSize} bytes`);
|
|
2118
|
-
fileData = new Uint8Array(zipHeader.compressedSize);
|
|
2119
|
-
await this.tokenizer.readBuffer(fileData);
|
|
2120
|
-
await this.inflate(zipHeader, fileData, next.handler);
|
|
2121
|
-
} else {
|
|
2122
|
-
debug(`Ignoring compressed-file-data: ${zipHeader.compressedSize} bytes`);
|
|
2123
|
-
await this.tokenizer.ignore(zipHeader.compressedSize);
|
|
2124
|
-
}
|
|
2125
|
-
}
|
|
2126
|
-
debug(`Reading data-descriptor at pos=${this.tokenizer.position}`);
|
|
2127
|
-
if (zipHeader.dataDescriptor) {
|
|
2128
|
-
const dataDescriptor = await this.tokenizer.readToken(DataDescriptor);
|
|
2129
|
-
if (dataDescriptor.signature !== 134695760) {
|
|
2130
|
-
throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position - DataDescriptor.len}`);
|
|
2131
|
-
}
|
|
2132
|
-
}
|
|
2133
|
-
} while (!stop);
|
|
2134
|
-
}
|
|
2135
|
-
async iterateOverCentralDirectory(entries, fileCb) {
|
|
2136
|
-
for (const fileHeader of entries) {
|
|
2137
|
-
const next = fileCb(fileHeader);
|
|
2138
|
-
if (next.handler) {
|
|
2139
|
-
this.tokenizer.setPosition(fileHeader.relativeOffsetOfLocalHeader);
|
|
2140
|
-
const zipHeader = await this.readLocalFileHeader();
|
|
2141
|
-
if (zipHeader) {
|
|
2142
|
-
await this.tokenizer.ignore(zipHeader.extraFieldLength);
|
|
2143
|
-
const fileData = new Uint8Array(fileHeader.compressedSize);
|
|
2144
|
-
await this.tokenizer.readBuffer(fileData);
|
|
2145
|
-
await this.inflate(zipHeader, fileData, next.handler);
|
|
2146
|
-
}
|
|
2147
|
-
}
|
|
2148
|
-
if (next.stop)
|
|
2149
|
-
break;
|
|
2150
|
-
}
|
|
2151
|
-
}
|
|
2152
|
-
async inflate(zipHeader, fileData, cb) {
|
|
2153
|
-
if (zipHeader.compressedMethod === 0) {
|
|
2154
|
-
return cb(fileData);
|
|
2155
|
-
}
|
|
2156
|
-
if (zipHeader.compressedMethod !== 8) {
|
|
2157
|
-
throw new Error(`Unsupported ZIP compression method: ${zipHeader.compressedMethod}`);
|
|
2158
|
-
}
|
|
2159
|
-
debug(`Decompress filename=${zipHeader.filename}, compressed-size=${fileData.length}`);
|
|
2160
|
-
const uncompressedData = await _ZipHandler.decompressDeflateRaw(fileData);
|
|
2161
|
-
return cb(uncompressedData);
|
|
2162
|
-
}
|
|
2163
|
-
static async decompressDeflateRaw(data) {
|
|
2164
|
-
const input = new ReadableStream({
|
|
2165
|
-
start(controller) {
|
|
2166
|
-
controller.enqueue(data);
|
|
2167
|
-
controller.close();
|
|
2168
|
-
}
|
|
2169
|
-
});
|
|
2170
|
-
const ds = new DecompressionStream("deflate-raw");
|
|
2171
|
-
const output = input.pipeThrough(ds);
|
|
2172
|
-
try {
|
|
2173
|
-
const response = new Response(output);
|
|
2174
|
-
const buffer = await response.arrayBuffer();
|
|
2175
|
-
return new Uint8Array(buffer);
|
|
2176
|
-
} catch (err) {
|
|
2177
|
-
const message = err instanceof Error ? `Failed to deflate ZIP entry: ${err.message}` : "Unknown decompression error in ZIP entry";
|
|
2178
|
-
throw new TypeError(message);
|
|
2179
|
-
}
|
|
2180
|
-
}
|
|
2181
|
-
async readLocalFileHeader() {
|
|
2182
|
-
const signature = await this.tokenizer.peekToken(UINT32_LE);
|
|
2183
|
-
if (signature === Signature.LocalFileHeader) {
|
|
2184
|
-
const header = await this.tokenizer.readToken(LocalFileHeaderToken);
|
|
2185
|
-
header.filename = await this.tokenizer.readToken(new StringType(header.filenameLength, "utf-8"));
|
|
2186
|
-
return header;
|
|
2187
|
-
}
|
|
2188
|
-
if (signature === Signature.CentralFileHeader) {
|
|
2189
|
-
return false;
|
|
2190
|
-
}
|
|
2191
|
-
if (signature === 3759263696) {
|
|
2192
|
-
throw new Error("Encrypted ZIP");
|
|
2193
|
-
}
|
|
2194
|
-
throw new Error("Unexpected signature");
|
|
2195
|
-
}
|
|
2196
|
-
};
|
|
2197
|
-
function indexOf(buffer, portion) {
|
|
2198
|
-
const bufferLength = buffer.length;
|
|
2199
|
-
const portionLength = portion.length;
|
|
2200
|
-
if (portionLength > bufferLength)
|
|
2201
|
-
return -1;
|
|
2202
|
-
for (let i = 0; i <= bufferLength - portionLength; i++) {
|
|
2203
|
-
let found = true;
|
|
2204
|
-
for (let j = 0; j < portionLength; j++) {
|
|
2205
|
-
if (buffer[i + j] !== portion[j]) {
|
|
2206
|
-
found = false;
|
|
2207
|
-
break;
|
|
2208
|
-
}
|
|
2209
|
-
}
|
|
2210
|
-
if (found) {
|
|
2211
|
-
return i;
|
|
2212
|
-
}
|
|
2213
|
-
}
|
|
2214
|
-
return -1;
|
|
2215
|
-
}
|
|
2216
|
-
function mergeArrays(chunks) {
|
|
2217
|
-
const totalLength = chunks.reduce((acc, curr) => acc + curr.length, 0);
|
|
2218
|
-
const mergedArray = new Uint8Array(totalLength);
|
|
2219
|
-
let offset = 0;
|
|
2220
|
-
for (const chunk of chunks) {
|
|
2221
|
-
mergedArray.set(chunk, offset);
|
|
2222
|
-
offset += chunk.length;
|
|
2223
|
-
}
|
|
2224
|
-
return mergedArray;
|
|
2225
|
-
}
|
|
2226
|
-
|
|
2227
|
-
// ../../node_modules/@tokenizer/inflate/lib/GzipHandler.js
|
|
2228
|
-
var GzipHandler = class {
|
|
2229
|
-
constructor(tokenizer) {
|
|
2230
|
-
this.tokenizer = tokenizer;
|
|
2231
|
-
}
|
|
2232
|
-
inflate() {
|
|
2233
|
-
const tokenizer = this.tokenizer;
|
|
2234
|
-
return new ReadableStream({
|
|
2235
|
-
async pull(controller) {
|
|
2236
|
-
const buffer = new Uint8Array(1024);
|
|
2237
|
-
const size = await tokenizer.readBuffer(buffer, { mayBeLess: true });
|
|
2238
|
-
if (size === 0) {
|
|
2239
|
-
controller.close();
|
|
2240
|
-
return;
|
|
2241
|
-
}
|
|
2242
|
-
controller.enqueue(buffer.subarray(0, size));
|
|
2243
|
-
}
|
|
2244
|
-
}).pipeThrough(new DecompressionStream("gzip"));
|
|
2245
|
-
}
|
|
2246
|
-
};
|
|
2247
|
-
|
|
2248
|
-
// ../../node_modules/uint8array-extras/index.js
|
|
2249
|
-
var cachedDecoders = {
|
|
2250
|
-
utf8: new globalThis.TextDecoder("utf8")
|
|
2251
|
-
};
|
|
2252
|
-
var cachedEncoder = new globalThis.TextEncoder();
|
|
2253
|
-
var byteToHexLookupTable = Array.from({ length: 256 }, (_, index) => index.toString(16).padStart(2, "0"));
|
|
2254
|
-
function getUintBE(view) {
|
|
2255
|
-
const { byteLength } = view;
|
|
2256
|
-
if (byteLength === 6) {
|
|
2257
|
-
return view.getUint16(0) * 2 ** 32 + view.getUint32(2);
|
|
2258
|
-
}
|
|
2259
|
-
if (byteLength === 5) {
|
|
2260
|
-
return view.getUint8(0) * 2 ** 32 + view.getUint32(1);
|
|
2261
|
-
}
|
|
2262
|
-
if (byteLength === 4) {
|
|
2263
|
-
return view.getUint32(0);
|
|
2264
|
-
}
|
|
2265
|
-
if (byteLength === 3) {
|
|
2266
|
-
return view.getUint8(0) * 2 ** 16 + view.getUint16(1);
|
|
2267
|
-
}
|
|
2268
|
-
if (byteLength === 2) {
|
|
2269
|
-
return view.getUint16(0);
|
|
2270
|
-
}
|
|
2271
|
-
if (byteLength === 1) {
|
|
2272
|
-
return view.getUint8(0);
|
|
2273
|
-
}
|
|
2274
|
-
}
|
|
2275
|
-
|
|
2276
|
-
// ../../node_modules/file-type/util.js
|
|
2277
|
-
function stringToBytes(string, encoding) {
|
|
2278
|
-
if (encoding === "utf-16le") {
|
|
2279
|
-
const bytes = [];
|
|
2280
|
-
for (let index = 0; index < string.length; index++) {
|
|
2281
|
-
const code = string.charCodeAt(index);
|
|
2282
|
-
bytes.push(code & 255, code >> 8 & 255);
|
|
2283
|
-
}
|
|
2284
|
-
return bytes;
|
|
2285
|
-
}
|
|
2286
|
-
if (encoding === "utf-16be") {
|
|
2287
|
-
const bytes = [];
|
|
2288
|
-
for (let index = 0; index < string.length; index++) {
|
|
2289
|
-
const code = string.charCodeAt(index);
|
|
2290
|
-
bytes.push(code >> 8 & 255, code & 255);
|
|
2291
|
-
}
|
|
2292
|
-
return bytes;
|
|
2293
|
-
}
|
|
2294
|
-
return [...string].map((character) => character.charCodeAt(0));
|
|
2295
|
-
}
|
|
2296
|
-
function tarHeaderChecksumMatches(arrayBuffer, offset = 0) {
|
|
2297
|
-
const readSum = Number.parseInt(new StringType(6).get(arrayBuffer, 148).replace(/\0.*$/, "").trim(), 8);
|
|
2298
|
-
if (Number.isNaN(readSum)) {
|
|
2299
|
-
return false;
|
|
2300
|
-
}
|
|
2301
|
-
let sum = 8 * 32;
|
|
2302
|
-
for (let index = offset; index < offset + 148; index++) {
|
|
2303
|
-
sum += arrayBuffer[index];
|
|
2304
|
-
}
|
|
2305
|
-
for (let index = offset + 156; index < offset + 512; index++) {
|
|
2306
|
-
sum += arrayBuffer[index];
|
|
2307
|
-
}
|
|
2308
|
-
return readSum === sum;
|
|
2309
|
-
}
|
|
2310
|
-
var uint32SyncSafeToken = {
|
|
2311
|
-
get: (buffer, offset) => buffer[offset + 3] & 127 | buffer[offset + 2] << 7 | buffer[offset + 1] << 14 | buffer[offset] << 21,
|
|
2312
|
-
len: 4
|
|
2313
|
-
};
|
|
2314
|
-
|
|
2315
|
-
// ../../node_modules/file-type/supported.js
|
|
2316
|
-
var extensions = [
|
|
2317
|
-
"jpg",
|
|
2318
|
-
"png",
|
|
2319
|
-
"apng",
|
|
2320
|
-
"gif",
|
|
2321
|
-
"webp",
|
|
2322
|
-
"flif",
|
|
2323
|
-
"xcf",
|
|
2324
|
-
"cr2",
|
|
2325
|
-
"cr3",
|
|
2326
|
-
"orf",
|
|
2327
|
-
"arw",
|
|
2328
|
-
"dng",
|
|
2329
|
-
"nef",
|
|
2330
|
-
"rw2",
|
|
2331
|
-
"raf",
|
|
2332
|
-
"tif",
|
|
2333
|
-
"bmp",
|
|
2334
|
-
"icns",
|
|
2335
|
-
"jxr",
|
|
2336
|
-
"psd",
|
|
2337
|
-
"indd",
|
|
2338
|
-
"zip",
|
|
2339
|
-
"tar",
|
|
2340
|
-
"rar",
|
|
2341
|
-
"gz",
|
|
2342
|
-
"bz2",
|
|
2343
|
-
"7z",
|
|
2344
|
-
"dmg",
|
|
2345
|
-
"mp4",
|
|
2346
|
-
"mid",
|
|
2347
|
-
"mkv",
|
|
2348
|
-
"webm",
|
|
2349
|
-
"mov",
|
|
2350
|
-
"avi",
|
|
2351
|
-
"mpg",
|
|
2352
|
-
"mp2",
|
|
2353
|
-
"mp3",
|
|
2354
|
-
"m4a",
|
|
2355
|
-
"oga",
|
|
2356
|
-
"ogg",
|
|
2357
|
-
"ogv",
|
|
2358
|
-
"opus",
|
|
2359
|
-
"flac",
|
|
2360
|
-
"wav",
|
|
2361
|
-
"spx",
|
|
2362
|
-
"amr",
|
|
2363
|
-
"pdf",
|
|
2364
|
-
"epub",
|
|
2365
|
-
"elf",
|
|
2366
|
-
"macho",
|
|
2367
|
-
"exe",
|
|
2368
|
-
"swf",
|
|
2369
|
-
"rtf",
|
|
2370
|
-
"wasm",
|
|
2371
|
-
"woff",
|
|
2372
|
-
"woff2",
|
|
2373
|
-
"eot",
|
|
2374
|
-
"ttf",
|
|
2375
|
-
"otf",
|
|
2376
|
-
"ttc",
|
|
2377
|
-
"ico",
|
|
2378
|
-
"flv",
|
|
2379
|
-
"ps",
|
|
2380
|
-
"xz",
|
|
2381
|
-
"sqlite",
|
|
2382
|
-
"nes",
|
|
2383
|
-
"crx",
|
|
2384
|
-
"xpi",
|
|
2385
|
-
"cab",
|
|
2386
|
-
"deb",
|
|
2387
|
-
"ar",
|
|
2388
|
-
"rpm",
|
|
2389
|
-
"Z",
|
|
2390
|
-
"lz",
|
|
2391
|
-
"cfb",
|
|
2392
|
-
"mxf",
|
|
2393
|
-
"mts",
|
|
2394
|
-
"blend",
|
|
2395
|
-
"bpg",
|
|
2396
|
-
"docx",
|
|
2397
|
-
"pptx",
|
|
2398
|
-
"xlsx",
|
|
2399
|
-
"3gp",
|
|
2400
|
-
"3g2",
|
|
2401
|
-
"j2c",
|
|
2402
|
-
"jp2",
|
|
2403
|
-
"jpm",
|
|
2404
|
-
"jpx",
|
|
2405
|
-
"mj2",
|
|
2406
|
-
"aif",
|
|
2407
|
-
"qcp",
|
|
2408
|
-
"odt",
|
|
2409
|
-
"ods",
|
|
2410
|
-
"odp",
|
|
2411
|
-
"xml",
|
|
2412
|
-
"mobi",
|
|
2413
|
-
"heic",
|
|
2414
|
-
"cur",
|
|
2415
|
-
"ktx",
|
|
2416
|
-
"ape",
|
|
2417
|
-
"wv",
|
|
2418
|
-
"dcm",
|
|
2419
|
-
"ics",
|
|
2420
|
-
"glb",
|
|
2421
|
-
"pcap",
|
|
2422
|
-
"dsf",
|
|
2423
|
-
"lnk",
|
|
2424
|
-
"alias",
|
|
2425
|
-
"voc",
|
|
2426
|
-
"ac3",
|
|
2427
|
-
"m4v",
|
|
2428
|
-
"m4p",
|
|
2429
|
-
"m4b",
|
|
2430
|
-
"f4v",
|
|
2431
|
-
"f4p",
|
|
2432
|
-
"f4b",
|
|
2433
|
-
"f4a",
|
|
2434
|
-
"mie",
|
|
2435
|
-
"asf",
|
|
2436
|
-
"ogm",
|
|
2437
|
-
"ogx",
|
|
2438
|
-
"mpc",
|
|
2439
|
-
"arrow",
|
|
2440
|
-
"shp",
|
|
2441
|
-
"aac",
|
|
2442
|
-
"mp1",
|
|
2443
|
-
"it",
|
|
2444
|
-
"s3m",
|
|
2445
|
-
"xm",
|
|
2446
|
-
"skp",
|
|
2447
|
-
"avif",
|
|
2448
|
-
"eps",
|
|
2449
|
-
"lzh",
|
|
2450
|
-
"pgp",
|
|
2451
|
-
"asar",
|
|
2452
|
-
"stl",
|
|
2453
|
-
"chm",
|
|
2454
|
-
"3mf",
|
|
2455
|
-
"zst",
|
|
2456
|
-
"jxl",
|
|
2457
|
-
"vcf",
|
|
2458
|
-
"jls",
|
|
2459
|
-
"pst",
|
|
2460
|
-
"dwg",
|
|
2461
|
-
"parquet",
|
|
2462
|
-
"class",
|
|
2463
|
-
"arj",
|
|
2464
|
-
"cpio",
|
|
2465
|
-
"ace",
|
|
2466
|
-
"avro",
|
|
2467
|
-
"icc",
|
|
2468
|
-
"fbx",
|
|
2469
|
-
"vsdx",
|
|
2470
|
-
"vtt",
|
|
2471
|
-
"apk",
|
|
2472
|
-
"drc",
|
|
2473
|
-
"lz4",
|
|
2474
|
-
"potx",
|
|
2475
|
-
"xltx",
|
|
2476
|
-
"dotx",
|
|
2477
|
-
"xltm",
|
|
2478
|
-
"ott",
|
|
2479
|
-
"ots",
|
|
2480
|
-
"otp",
|
|
2481
|
-
"odg",
|
|
2482
|
-
"otg",
|
|
2483
|
-
"xlsm",
|
|
2484
|
-
"docm",
|
|
2485
|
-
"dotm",
|
|
2486
|
-
"potm",
|
|
2487
|
-
"pptm",
|
|
2488
|
-
"jar",
|
|
2489
|
-
"jmp",
|
|
2490
|
-
"rm",
|
|
2491
|
-
"sav",
|
|
2492
|
-
"ppsm",
|
|
2493
|
-
"ppsx",
|
|
2494
|
-
"tar.gz",
|
|
2495
|
-
"reg",
|
|
2496
|
-
"dat"
|
|
2497
|
-
];
|
|
2498
|
-
var mimeTypes = [
|
|
2499
|
-
"image/jpeg",
|
|
2500
|
-
"image/png",
|
|
2501
|
-
"image/gif",
|
|
2502
|
-
"image/webp",
|
|
2503
|
-
"image/flif",
|
|
2504
|
-
"image/x-xcf",
|
|
2505
|
-
"image/x-canon-cr2",
|
|
2506
|
-
"image/x-canon-cr3",
|
|
2507
|
-
"image/tiff",
|
|
2508
|
-
"image/bmp",
|
|
2509
|
-
"image/vnd.ms-photo",
|
|
2510
|
-
"image/vnd.adobe.photoshop",
|
|
2511
|
-
"application/x-indesign",
|
|
2512
|
-
"application/epub+zip",
|
|
2513
|
-
"application/x-xpinstall",
|
|
2514
|
-
"application/vnd.ms-powerpoint.slideshow.macroenabled.12",
|
|
2515
|
-
"application/vnd.oasis.opendocument.text",
|
|
2516
|
-
"application/vnd.oasis.opendocument.spreadsheet",
|
|
2517
|
-
"application/vnd.oasis.opendocument.presentation",
|
|
2518
|
-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
2519
|
-
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
2520
|
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
2521
|
-
"application/vnd.openxmlformats-officedocument.presentationml.slideshow",
|
|
2522
|
-
"application/zip",
|
|
2523
|
-
"application/x-tar",
|
|
2524
|
-
"application/x-rar-compressed",
|
|
2525
|
-
"application/gzip",
|
|
2526
|
-
"application/x-bzip2",
|
|
2527
|
-
"application/x-7z-compressed",
|
|
2528
|
-
"application/x-apple-diskimage",
|
|
2529
|
-
"application/vnd.apache.arrow.file",
|
|
2530
|
-
"video/mp4",
|
|
2531
|
-
"audio/midi",
|
|
2532
|
-
"video/matroska",
|
|
2533
|
-
"video/webm",
|
|
2534
|
-
"video/quicktime",
|
|
2535
|
-
"video/vnd.avi",
|
|
2536
|
-
"audio/wav",
|
|
2537
|
-
"audio/qcelp",
|
|
2538
|
-
"audio/x-ms-asf",
|
|
2539
|
-
"video/x-ms-asf",
|
|
2540
|
-
"application/vnd.ms-asf",
|
|
2541
|
-
"video/mpeg",
|
|
2542
|
-
"video/3gpp",
|
|
2543
|
-
"audio/mpeg",
|
|
2544
|
-
"audio/mp4",
|
|
2545
|
-
// RFC 4337
|
|
2546
|
-
"video/ogg",
|
|
2547
|
-
"audio/ogg",
|
|
2548
|
-
"audio/ogg; codecs=opus",
|
|
2549
|
-
"application/ogg",
|
|
2550
|
-
"audio/flac",
|
|
2551
|
-
"audio/ape",
|
|
2552
|
-
"audio/wavpack",
|
|
2553
|
-
"audio/amr",
|
|
2554
|
-
"application/pdf",
|
|
2555
|
-
"application/x-elf",
|
|
2556
|
-
"application/x-mach-binary",
|
|
2557
|
-
"application/x-msdownload",
|
|
2558
|
-
"application/x-shockwave-flash",
|
|
2559
|
-
"application/rtf",
|
|
2560
|
-
"application/wasm",
|
|
2561
|
-
"font/woff",
|
|
2562
|
-
"font/woff2",
|
|
2563
|
-
"application/vnd.ms-fontobject",
|
|
2564
|
-
"font/ttf",
|
|
2565
|
-
"font/otf",
|
|
2566
|
-
"font/collection",
|
|
2567
|
-
"image/x-icon",
|
|
2568
|
-
"video/x-flv",
|
|
2569
|
-
"application/postscript",
|
|
2570
|
-
"application/eps",
|
|
2571
|
-
"application/x-xz",
|
|
2572
|
-
"application/x-sqlite3",
|
|
2573
|
-
"application/x-nintendo-nes-rom",
|
|
2574
|
-
"application/x-google-chrome-extension",
|
|
2575
|
-
"application/vnd.ms-cab-compressed",
|
|
2576
|
-
"application/x-deb",
|
|
2577
|
-
"application/x-unix-archive",
|
|
2578
|
-
"application/x-rpm",
|
|
2579
|
-
"application/x-compress",
|
|
2580
|
-
"application/x-lzip",
|
|
2581
|
-
"application/x-cfb",
|
|
2582
|
-
"application/x-mie",
|
|
2583
|
-
"application/mxf",
|
|
2584
|
-
"video/mp2t",
|
|
2585
|
-
"application/x-blender",
|
|
2586
|
-
"image/bpg",
|
|
2587
|
-
"image/j2c",
|
|
2588
|
-
"image/jp2",
|
|
2589
|
-
"image/jpx",
|
|
2590
|
-
"image/jpm",
|
|
2591
|
-
"image/mj2",
|
|
2592
|
-
"audio/aiff",
|
|
2593
|
-
"application/xml",
|
|
2594
|
-
"application/x-mobipocket-ebook",
|
|
2595
|
-
"image/heif",
|
|
2596
|
-
"image/heif-sequence",
|
|
2597
|
-
"image/heic",
|
|
2598
|
-
"image/heic-sequence",
|
|
2599
|
-
"image/icns",
|
|
2600
|
-
"image/ktx",
|
|
2601
|
-
"application/dicom",
|
|
2602
|
-
"audio/x-musepack",
|
|
2603
|
-
"text/calendar",
|
|
2604
|
-
"text/vcard",
|
|
2605
|
-
"text/vtt",
|
|
2606
|
-
"model/gltf-binary",
|
|
2607
|
-
"application/vnd.tcpdump.pcap",
|
|
2608
|
-
"audio/x-dsf",
|
|
2609
|
-
// Non-standard
|
|
2610
|
-
"application/x.ms.shortcut",
|
|
2611
|
-
// Invented by us
|
|
2612
|
-
"application/x.apple.alias",
|
|
2613
|
-
// Invented by us
|
|
2614
|
-
"audio/x-voc",
|
|
2615
|
-
"audio/vnd.dolby.dd-raw",
|
|
2616
|
-
"audio/x-m4a",
|
|
2617
|
-
"image/apng",
|
|
2618
|
-
"image/x-olympus-orf",
|
|
2619
|
-
"image/x-sony-arw",
|
|
2620
|
-
"image/x-adobe-dng",
|
|
2621
|
-
"image/x-nikon-nef",
|
|
2622
|
-
"image/x-panasonic-rw2",
|
|
2623
|
-
"image/x-fujifilm-raf",
|
|
2624
|
-
"video/x-m4v",
|
|
2625
|
-
"video/3gpp2",
|
|
2626
|
-
"application/x-esri-shape",
|
|
2627
|
-
"audio/aac",
|
|
2628
|
-
"audio/x-it",
|
|
2629
|
-
"audio/x-s3m",
|
|
2630
|
-
"audio/x-xm",
|
|
2631
|
-
"video/MP1S",
|
|
2632
|
-
"video/MP2P",
|
|
2633
|
-
"application/vnd.sketchup.skp",
|
|
2634
|
-
"image/avif",
|
|
2635
|
-
"application/x-lzh-compressed",
|
|
2636
|
-
"application/pgp-encrypted",
|
|
2637
|
-
"application/x-asar",
|
|
2638
|
-
"model/stl",
|
|
2639
|
-
"application/vnd.ms-htmlhelp",
|
|
2640
|
-
"model/3mf",
|
|
2641
|
-
"image/jxl",
|
|
2642
|
-
"application/zstd",
|
|
2643
|
-
"image/jls",
|
|
2644
|
-
"application/vnd.ms-outlook",
|
|
2645
|
-
"image/vnd.dwg",
|
|
2646
|
-
"application/vnd.apache.parquet",
|
|
2647
|
-
"application/java-vm",
|
|
2648
|
-
"application/x-arj",
|
|
2649
|
-
"application/x-cpio",
|
|
2650
|
-
"application/x-ace-compressed",
|
|
2651
|
-
"application/avro",
|
|
2652
|
-
"application/vnd.iccprofile",
|
|
2653
|
-
"application/x.autodesk.fbx",
|
|
2654
|
-
// Invented by us
|
|
2655
|
-
"application/vnd.visio",
|
|
2656
|
-
"application/vnd.android.package-archive",
|
|
2657
|
-
"application/vnd.google.draco",
|
|
2658
|
-
// Invented by us
|
|
2659
|
-
"application/x-lz4",
|
|
2660
|
-
// Invented by us
|
|
2661
|
-
"application/vnd.openxmlformats-officedocument.presentationml.template",
|
|
2662
|
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.template",
|
|
2663
|
-
"application/vnd.openxmlformats-officedocument.wordprocessingml.template",
|
|
2664
|
-
"application/vnd.ms-excel.template.macroenabled.12",
|
|
2665
|
-
"application/vnd.oasis.opendocument.text-template",
|
|
2666
|
-
"application/vnd.oasis.opendocument.spreadsheet-template",
|
|
2667
|
-
"application/vnd.oasis.opendocument.presentation-template",
|
|
2668
|
-
"application/vnd.oasis.opendocument.graphics",
|
|
2669
|
-
"application/vnd.oasis.opendocument.graphics-template",
|
|
2670
|
-
"application/vnd.ms-excel.sheet.macroenabled.12",
|
|
2671
|
-
"application/vnd.ms-word.document.macroenabled.12",
|
|
2672
|
-
"application/vnd.ms-word.template.macroenabled.12",
|
|
2673
|
-
"application/vnd.ms-powerpoint.template.macroenabled.12",
|
|
2674
|
-
"application/vnd.ms-powerpoint.presentation.macroenabled.12",
|
|
2675
|
-
"application/java-archive",
|
|
2676
|
-
"application/vnd.rn-realmedia",
|
|
2677
|
-
"application/x-spss-sav",
|
|
2678
|
-
"application/x-ms-regedit",
|
|
2679
|
-
"application/x-ft-windows-registry-hive",
|
|
2680
|
-
"application/x-jmp-data"
|
|
2681
|
-
];
|
|
2682
|
-
|
|
2683
|
-
// ../../node_modules/file-type/core.js
|
|
2684
|
-
var reasonableDetectionSizeInBytes = 4100;
|
|
2685
|
-
async function fileTypeFromBlob(blob, options) {
|
|
2686
|
-
return new FileTypeParser(options).fromBlob(blob);
|
|
2687
|
-
}
|
|
2688
|
-
function getFileTypeFromMimeType(mimeType) {
|
|
2689
|
-
mimeType = mimeType.toLowerCase();
|
|
2690
|
-
switch (mimeType) {
|
|
2691
|
-
case "application/epub+zip":
|
|
2692
|
-
return {
|
|
2693
|
-
ext: "epub",
|
|
2694
|
-
mime: mimeType
|
|
2695
|
-
};
|
|
2696
|
-
case "application/vnd.oasis.opendocument.text":
|
|
2697
|
-
return {
|
|
2698
|
-
ext: "odt",
|
|
2699
|
-
mime: mimeType
|
|
2700
|
-
};
|
|
2701
|
-
case "application/vnd.oasis.opendocument.text-template":
|
|
2702
|
-
return {
|
|
2703
|
-
ext: "ott",
|
|
2704
|
-
mime: mimeType
|
|
2705
|
-
};
|
|
2706
|
-
case "application/vnd.oasis.opendocument.spreadsheet":
|
|
2707
|
-
return {
|
|
2708
|
-
ext: "ods",
|
|
2709
|
-
mime: mimeType
|
|
2710
|
-
};
|
|
2711
|
-
case "application/vnd.oasis.opendocument.spreadsheet-template":
|
|
2712
|
-
return {
|
|
2713
|
-
ext: "ots",
|
|
2714
|
-
mime: mimeType
|
|
2715
|
-
};
|
|
2716
|
-
case "application/vnd.oasis.opendocument.presentation":
|
|
2717
|
-
return {
|
|
2718
|
-
ext: "odp",
|
|
2719
|
-
mime: mimeType
|
|
2720
|
-
};
|
|
2721
|
-
case "application/vnd.oasis.opendocument.presentation-template":
|
|
2722
|
-
return {
|
|
2723
|
-
ext: "otp",
|
|
2724
|
-
mime: mimeType
|
|
2725
|
-
};
|
|
2726
|
-
case "application/vnd.oasis.opendocument.graphics":
|
|
2727
|
-
return {
|
|
2728
|
-
ext: "odg",
|
|
2729
|
-
mime: mimeType
|
|
2730
|
-
};
|
|
2731
|
-
case "application/vnd.oasis.opendocument.graphics-template":
|
|
2732
|
-
return {
|
|
2733
|
-
ext: "otg",
|
|
2734
|
-
mime: mimeType
|
|
2735
|
-
};
|
|
2736
|
-
case "application/vnd.openxmlformats-officedocument.presentationml.slideshow":
|
|
2737
|
-
return {
|
|
2738
|
-
ext: "ppsx",
|
|
2739
|
-
mime: mimeType
|
|
2740
|
-
};
|
|
2741
|
-
case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
|
|
2742
|
-
return {
|
|
2743
|
-
ext: "xlsx",
|
|
2744
|
-
mime: mimeType
|
|
2745
|
-
};
|
|
2746
|
-
case "application/vnd.ms-excel.sheet.macroenabled":
|
|
2747
|
-
return {
|
|
2748
|
-
ext: "xlsm",
|
|
2749
|
-
mime: "application/vnd.ms-excel.sheet.macroenabled.12"
|
|
2750
|
-
};
|
|
2751
|
-
case "application/vnd.openxmlformats-officedocument.spreadsheetml.template":
|
|
2752
|
-
return {
|
|
2753
|
-
ext: "xltx",
|
|
2754
|
-
mime: mimeType
|
|
2755
|
-
};
|
|
2756
|
-
case "application/vnd.ms-excel.template.macroenabled":
|
|
2757
|
-
return {
|
|
2758
|
-
ext: "xltm",
|
|
2759
|
-
mime: "application/vnd.ms-excel.template.macroenabled.12"
|
|
2760
|
-
};
|
|
2761
|
-
case "application/vnd.ms-powerpoint.slideshow.macroenabled":
|
|
2762
|
-
return {
|
|
2763
|
-
ext: "ppsm",
|
|
2764
|
-
mime: "application/vnd.ms-powerpoint.slideshow.macroenabled.12"
|
|
2765
|
-
};
|
|
2766
|
-
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
|
|
2767
|
-
return {
|
|
2768
|
-
ext: "docx",
|
|
2769
|
-
mime: mimeType
|
|
2770
|
-
};
|
|
2771
|
-
case "application/vnd.ms-word.document.macroenabled":
|
|
2772
|
-
return {
|
|
2773
|
-
ext: "docm",
|
|
2774
|
-
mime: "application/vnd.ms-word.document.macroenabled.12"
|
|
2775
|
-
};
|
|
2776
|
-
case "application/vnd.openxmlformats-officedocument.wordprocessingml.template":
|
|
2777
|
-
return {
|
|
2778
|
-
ext: "dotx",
|
|
2779
|
-
mime: mimeType
|
|
2780
|
-
};
|
|
2781
|
-
case "application/vnd.ms-word.template.macroenabledtemplate":
|
|
2782
|
-
return {
|
|
2783
|
-
ext: "dotm",
|
|
2784
|
-
mime: "application/vnd.ms-word.template.macroenabled.12"
|
|
2785
|
-
};
|
|
2786
|
-
case "application/vnd.openxmlformats-officedocument.presentationml.template":
|
|
2787
|
-
return {
|
|
2788
|
-
ext: "potx",
|
|
2789
|
-
mime: mimeType
|
|
2790
|
-
};
|
|
2791
|
-
case "application/vnd.ms-powerpoint.template.macroenabled":
|
|
2792
|
-
return {
|
|
2793
|
-
ext: "potm",
|
|
2794
|
-
mime: "application/vnd.ms-powerpoint.template.macroenabled.12"
|
|
2795
|
-
};
|
|
2796
|
-
case "application/vnd.openxmlformats-officedocument.presentationml.presentation":
|
|
2797
|
-
return {
|
|
2798
|
-
ext: "pptx",
|
|
2799
|
-
mime: mimeType
|
|
2800
|
-
};
|
|
2801
|
-
case "application/vnd.ms-powerpoint.presentation.macroenabled":
|
|
2802
|
-
return {
|
|
2803
|
-
ext: "pptm",
|
|
2804
|
-
mime: "application/vnd.ms-powerpoint.presentation.macroenabled.12"
|
|
2805
|
-
};
|
|
2806
|
-
case "application/vnd.ms-visio.drawing":
|
|
2807
|
-
return {
|
|
2808
|
-
ext: "vsdx",
|
|
2809
|
-
mime: "application/vnd.visio"
|
|
2810
|
-
};
|
|
2811
|
-
case "application/vnd.ms-package.3dmanufacturing-3dmodel+xml":
|
|
2812
|
-
return {
|
|
2813
|
-
ext: "3mf",
|
|
2814
|
-
mime: "model/3mf"
|
|
2815
|
-
};
|
|
2816
|
-
default:
|
|
2817
|
-
}
|
|
2818
|
-
}
|
|
2819
|
-
function _check(buffer, headers, options) {
|
|
2820
|
-
options = {
|
|
2821
|
-
offset: 0,
|
|
2822
|
-
...options
|
|
2823
|
-
};
|
|
2824
|
-
for (const [index, header] of headers.entries()) {
|
|
2825
|
-
if (options.mask) {
|
|
2826
|
-
if (header !== (options.mask[index] & buffer[index + options.offset])) {
|
|
2827
|
-
return false;
|
|
2828
|
-
}
|
|
2829
|
-
} else if (header !== buffer[index + options.offset]) {
|
|
2830
|
-
return false;
|
|
2831
|
-
}
|
|
2832
|
-
}
|
|
2833
|
-
return true;
|
|
2834
|
-
}
|
|
2835
|
-
var FileTypeParser = class {
|
|
2836
|
-
constructor(options) {
|
|
2837
|
-
// Detections with a high degree of certainty in identifying the correct file type
|
|
2838
|
-
__publicField(this, "detectConfident", async (tokenizer) => {
|
|
2839
|
-
this.buffer = new Uint8Array(reasonableDetectionSizeInBytes);
|
|
2840
|
-
if (tokenizer.fileInfo.size === void 0) {
|
|
2841
|
-
tokenizer.fileInfo.size = Number.MAX_SAFE_INTEGER;
|
|
2842
|
-
}
|
|
2843
|
-
this.tokenizer = tokenizer;
|
|
2844
|
-
await tokenizer.peekBuffer(this.buffer, { length: 32, mayBeLess: true });
|
|
2845
|
-
if (this.check([66, 77])) {
|
|
2846
|
-
return {
|
|
2847
|
-
ext: "bmp",
|
|
2848
|
-
mime: "image/bmp"
|
|
2849
|
-
};
|
|
2850
|
-
}
|
|
2851
|
-
if (this.check([11, 119])) {
|
|
2852
|
-
return {
|
|
2853
|
-
ext: "ac3",
|
|
2854
|
-
mime: "audio/vnd.dolby.dd-raw"
|
|
2855
|
-
};
|
|
2856
|
-
}
|
|
2857
|
-
if (this.check([120, 1])) {
|
|
2858
|
-
return {
|
|
2859
|
-
ext: "dmg",
|
|
2860
|
-
mime: "application/x-apple-diskimage"
|
|
2861
|
-
};
|
|
2862
|
-
}
|
|
2863
|
-
if (this.check([77, 90])) {
|
|
2864
|
-
return {
|
|
2865
|
-
ext: "exe",
|
|
2866
|
-
mime: "application/x-msdownload"
|
|
2867
|
-
};
|
|
2868
|
-
}
|
|
2869
|
-
if (this.check([37, 33])) {
|
|
2870
|
-
await tokenizer.peekBuffer(this.buffer, { length: 24, mayBeLess: true });
|
|
2871
|
-
if (this.checkString("PS-Adobe-", { offset: 2 }) && this.checkString(" EPSF-", { offset: 14 })) {
|
|
2872
|
-
return {
|
|
2873
|
-
ext: "eps",
|
|
2874
|
-
mime: "application/eps"
|
|
2875
|
-
};
|
|
2876
|
-
}
|
|
2877
|
-
return {
|
|
2878
|
-
ext: "ps",
|
|
2879
|
-
mime: "application/postscript"
|
|
2880
|
-
};
|
|
2881
|
-
}
|
|
2882
|
-
if (this.check([31, 160]) || this.check([31, 157])) {
|
|
2883
|
-
return {
|
|
2884
|
-
ext: "Z",
|
|
2885
|
-
mime: "application/x-compress"
|
|
2886
|
-
};
|
|
2887
|
-
}
|
|
2888
|
-
if (this.check([199, 113])) {
|
|
2889
|
-
return {
|
|
2890
|
-
ext: "cpio",
|
|
2891
|
-
mime: "application/x-cpio"
|
|
2892
|
-
};
|
|
2893
|
-
}
|
|
2894
|
-
if (this.check([96, 234])) {
|
|
2895
|
-
return {
|
|
2896
|
-
ext: "arj",
|
|
2897
|
-
mime: "application/x-arj"
|
|
2898
|
-
};
|
|
2899
|
-
}
|
|
2900
|
-
if (this.check([239, 187, 191])) {
|
|
2901
|
-
this.tokenizer.ignore(3);
|
|
2902
|
-
return this.detectConfident(tokenizer);
|
|
2903
|
-
}
|
|
2904
|
-
if (this.check([71, 73, 70])) {
|
|
2905
|
-
return {
|
|
2906
|
-
ext: "gif",
|
|
2907
|
-
mime: "image/gif"
|
|
2908
|
-
};
|
|
2909
|
-
}
|
|
2910
|
-
if (this.check([73, 73, 188])) {
|
|
2911
|
-
return {
|
|
2912
|
-
ext: "jxr",
|
|
2913
|
-
mime: "image/vnd.ms-photo"
|
|
2914
|
-
};
|
|
2915
|
-
}
|
|
2916
|
-
if (this.check([31, 139, 8])) {
|
|
2917
|
-
const gzipHandler = new GzipHandler(tokenizer);
|
|
2918
|
-
const stream = gzipHandler.inflate();
|
|
2919
|
-
let shouldCancelStream = true;
|
|
2920
|
-
try {
|
|
2921
|
-
let compressedFileType;
|
|
2922
|
-
try {
|
|
2923
|
-
compressedFileType = await this.fromStream(stream);
|
|
2924
|
-
} catch {
|
|
2925
|
-
shouldCancelStream = false;
|
|
2926
|
-
}
|
|
2927
|
-
if (compressedFileType && compressedFileType.ext === "tar") {
|
|
2928
|
-
return {
|
|
2929
|
-
ext: "tar.gz",
|
|
2930
|
-
mime: "application/gzip"
|
|
2931
|
-
};
|
|
2932
|
-
}
|
|
2933
|
-
} finally {
|
|
2934
|
-
if (shouldCancelStream) {
|
|
2935
|
-
await stream.cancel();
|
|
2936
|
-
}
|
|
2937
|
-
}
|
|
2938
|
-
return {
|
|
2939
|
-
ext: "gz",
|
|
2940
|
-
mime: "application/gzip"
|
|
2941
|
-
};
|
|
2942
|
-
}
|
|
2943
|
-
if (this.check([66, 90, 104])) {
|
|
2944
|
-
return {
|
|
2945
|
-
ext: "bz2",
|
|
2946
|
-
mime: "application/x-bzip2"
|
|
2947
|
-
};
|
|
2948
|
-
}
|
|
2949
|
-
if (this.checkString("ID3")) {
|
|
2950
|
-
await tokenizer.ignore(6);
|
|
2951
|
-
const id3HeaderLength = await tokenizer.readToken(uint32SyncSafeToken);
|
|
2952
|
-
if (tokenizer.position + id3HeaderLength > tokenizer.fileInfo.size) {
|
|
2953
|
-
return {
|
|
2954
|
-
ext: "mp3",
|
|
2955
|
-
mime: "audio/mpeg"
|
|
2956
|
-
};
|
|
2957
|
-
}
|
|
2958
|
-
await tokenizer.ignore(id3HeaderLength);
|
|
2959
|
-
return this.fromTokenizer(tokenizer);
|
|
2960
|
-
}
|
|
2961
|
-
if (this.checkString("MP+")) {
|
|
2962
|
-
return {
|
|
2963
|
-
ext: "mpc",
|
|
2964
|
-
mime: "audio/x-musepack"
|
|
2965
|
-
};
|
|
2966
|
-
}
|
|
2967
|
-
if ((this.buffer[0] === 67 || this.buffer[0] === 70) && this.check([87, 83], { offset: 1 })) {
|
|
2968
|
-
return {
|
|
2969
|
-
ext: "swf",
|
|
2970
|
-
mime: "application/x-shockwave-flash"
|
|
2971
|
-
};
|
|
2972
|
-
}
|
|
2973
|
-
if (this.check([255, 216, 255])) {
|
|
2974
|
-
if (this.check([247], { offset: 3 })) {
|
|
2975
|
-
return {
|
|
2976
|
-
ext: "jls",
|
|
2977
|
-
mime: "image/jls"
|
|
2978
|
-
};
|
|
2979
|
-
}
|
|
2980
|
-
return {
|
|
2981
|
-
ext: "jpg",
|
|
2982
|
-
mime: "image/jpeg"
|
|
2983
|
-
};
|
|
2984
|
-
}
|
|
2985
|
-
if (this.check([79, 98, 106, 1])) {
|
|
2986
|
-
return {
|
|
2987
|
-
ext: "avro",
|
|
2988
|
-
mime: "application/avro"
|
|
2989
|
-
};
|
|
2990
|
-
}
|
|
2991
|
-
if (this.checkString("FLIF")) {
|
|
2992
|
-
return {
|
|
2993
|
-
ext: "flif",
|
|
2994
|
-
mime: "image/flif"
|
|
2995
|
-
};
|
|
2996
|
-
}
|
|
2997
|
-
if (this.checkString("8BPS")) {
|
|
2998
|
-
return {
|
|
2999
|
-
ext: "psd",
|
|
3000
|
-
mime: "image/vnd.adobe.photoshop"
|
|
3001
|
-
};
|
|
3002
|
-
}
|
|
3003
|
-
if (this.checkString("MPCK")) {
|
|
3004
|
-
return {
|
|
3005
|
-
ext: "mpc",
|
|
3006
|
-
mime: "audio/x-musepack"
|
|
3007
|
-
};
|
|
3008
|
-
}
|
|
3009
|
-
if (this.checkString("FORM")) {
|
|
3010
|
-
return {
|
|
3011
|
-
ext: "aif",
|
|
3012
|
-
mime: "audio/aiff"
|
|
3013
|
-
};
|
|
3014
|
-
}
|
|
3015
|
-
if (this.checkString("icns", { offset: 0 })) {
|
|
3016
|
-
return {
|
|
3017
|
-
ext: "icns",
|
|
3018
|
-
mime: "image/icns"
|
|
3019
|
-
};
|
|
3020
|
-
}
|
|
3021
|
-
if (this.check([80, 75, 3, 4])) {
|
|
3022
|
-
let fileType;
|
|
3023
|
-
await new ZipHandler(tokenizer).unzip((zipHeader) => {
|
|
3024
|
-
switch (zipHeader.filename) {
|
|
3025
|
-
case "META-INF/mozilla.rsa":
|
|
3026
|
-
fileType = {
|
|
3027
|
-
ext: "xpi",
|
|
3028
|
-
mime: "application/x-xpinstall"
|
|
3029
|
-
};
|
|
3030
|
-
return {
|
|
3031
|
-
stop: true
|
|
3032
|
-
};
|
|
3033
|
-
case "META-INF/MANIFEST.MF":
|
|
3034
|
-
fileType = {
|
|
3035
|
-
ext: "jar",
|
|
3036
|
-
mime: "application/java-archive"
|
|
3037
|
-
};
|
|
3038
|
-
return {
|
|
3039
|
-
stop: true
|
|
3040
|
-
};
|
|
3041
|
-
case "mimetype":
|
|
3042
|
-
return {
|
|
3043
|
-
async handler(fileData) {
|
|
3044
|
-
const mimeType = new TextDecoder("utf-8").decode(fileData).trim();
|
|
3045
|
-
fileType = getFileTypeFromMimeType(mimeType);
|
|
3046
|
-
},
|
|
3047
|
-
stop: true
|
|
3048
|
-
};
|
|
3049
|
-
case "[Content_Types].xml":
|
|
3050
|
-
return {
|
|
3051
|
-
async handler(fileData) {
|
|
3052
|
-
let xmlContent = new TextDecoder("utf-8").decode(fileData);
|
|
3053
|
-
const endPos = xmlContent.indexOf('.main+xml"');
|
|
3054
|
-
if (endPos === -1) {
|
|
3055
|
-
const mimeType = "application/vnd.ms-package.3dmanufacturing-3dmodel+xml";
|
|
3056
|
-
if (xmlContent.includes(`ContentType="${mimeType}"`)) {
|
|
3057
|
-
fileType = getFileTypeFromMimeType(mimeType);
|
|
3058
|
-
}
|
|
3059
|
-
} else {
|
|
3060
|
-
xmlContent = xmlContent.slice(0, Math.max(0, endPos));
|
|
3061
|
-
const firstPos = xmlContent.lastIndexOf('"');
|
|
3062
|
-
const mimeType = xmlContent.slice(Math.max(0, firstPos + 1));
|
|
3063
|
-
fileType = getFileTypeFromMimeType(mimeType);
|
|
3064
|
-
}
|
|
3065
|
-
},
|
|
3066
|
-
stop: true
|
|
3067
|
-
};
|
|
3068
|
-
default:
|
|
3069
|
-
if (/classes\d*\.dex/.test(zipHeader.filename)) {
|
|
3070
|
-
fileType = {
|
|
3071
|
-
ext: "apk",
|
|
3072
|
-
mime: "application/vnd.android.package-archive"
|
|
3073
|
-
};
|
|
3074
|
-
return { stop: true };
|
|
3075
|
-
}
|
|
3076
|
-
return {};
|
|
3077
|
-
}
|
|
3078
|
-
}).catch((error) => {
|
|
3079
|
-
if (!(error instanceof EndOfStreamError)) {
|
|
3080
|
-
throw error;
|
|
3081
|
-
}
|
|
3082
|
-
});
|
|
3083
|
-
return fileType ?? {
|
|
3084
|
-
ext: "zip",
|
|
3085
|
-
mime: "application/zip"
|
|
3086
|
-
};
|
|
3087
|
-
}
|
|
3088
|
-
if (this.checkString("OggS")) {
|
|
3089
|
-
await tokenizer.ignore(28);
|
|
3090
|
-
const type = new Uint8Array(8);
|
|
3091
|
-
await tokenizer.readBuffer(type);
|
|
3092
|
-
if (_check(type, [79, 112, 117, 115, 72, 101, 97, 100])) {
|
|
3093
|
-
return {
|
|
3094
|
-
ext: "opus",
|
|
3095
|
-
mime: "audio/ogg; codecs=opus"
|
|
3096
|
-
};
|
|
3097
|
-
}
|
|
3098
|
-
if (_check(type, [128, 116, 104, 101, 111, 114, 97])) {
|
|
3099
|
-
return {
|
|
3100
|
-
ext: "ogv",
|
|
3101
|
-
mime: "video/ogg"
|
|
3102
|
-
};
|
|
3103
|
-
}
|
|
3104
|
-
if (_check(type, [1, 118, 105, 100, 101, 111, 0])) {
|
|
3105
|
-
return {
|
|
3106
|
-
ext: "ogm",
|
|
3107
|
-
mime: "video/ogg"
|
|
3108
|
-
};
|
|
3109
|
-
}
|
|
3110
|
-
if (_check(type, [127, 70, 76, 65, 67])) {
|
|
3111
|
-
return {
|
|
3112
|
-
ext: "oga",
|
|
3113
|
-
mime: "audio/ogg"
|
|
3114
|
-
};
|
|
3115
|
-
}
|
|
3116
|
-
if (_check(type, [83, 112, 101, 101, 120, 32, 32])) {
|
|
3117
|
-
return {
|
|
3118
|
-
ext: "spx",
|
|
3119
|
-
mime: "audio/ogg"
|
|
3120
|
-
};
|
|
3121
|
-
}
|
|
3122
|
-
if (_check(type, [1, 118, 111, 114, 98, 105, 115])) {
|
|
3123
|
-
return {
|
|
3124
|
-
ext: "ogg",
|
|
3125
|
-
mime: "audio/ogg"
|
|
3126
|
-
};
|
|
3127
|
-
}
|
|
3128
|
-
return {
|
|
3129
|
-
ext: "ogx",
|
|
3130
|
-
mime: "application/ogg"
|
|
3131
|
-
};
|
|
3132
|
-
}
|
|
3133
|
-
if (this.check([80, 75]) && (this.buffer[2] === 3 || this.buffer[2] === 5 || this.buffer[2] === 7) && (this.buffer[3] === 4 || this.buffer[3] === 6 || this.buffer[3] === 8)) {
|
|
3134
|
-
return {
|
|
3135
|
-
ext: "zip",
|
|
3136
|
-
mime: "application/zip"
|
|
3137
|
-
};
|
|
3138
|
-
}
|
|
3139
|
-
if (this.checkString("MThd")) {
|
|
3140
|
-
return {
|
|
3141
|
-
ext: "mid",
|
|
3142
|
-
mime: "audio/midi"
|
|
3143
|
-
};
|
|
3144
|
-
}
|
|
3145
|
-
if (this.checkString("wOFF") && (this.check([0, 1, 0, 0], { offset: 4 }) || this.checkString("OTTO", { offset: 4 }))) {
|
|
3146
|
-
return {
|
|
3147
|
-
ext: "woff",
|
|
3148
|
-
mime: "font/woff"
|
|
3149
|
-
};
|
|
3150
|
-
}
|
|
3151
|
-
if (this.checkString("wOF2") && (this.check([0, 1, 0, 0], { offset: 4 }) || this.checkString("OTTO", { offset: 4 }))) {
|
|
3152
|
-
return {
|
|
3153
|
-
ext: "woff2",
|
|
3154
|
-
mime: "font/woff2"
|
|
3155
|
-
};
|
|
3156
|
-
}
|
|
3157
|
-
if (this.check([212, 195, 178, 161]) || this.check([161, 178, 195, 212])) {
|
|
3158
|
-
return {
|
|
3159
|
-
ext: "pcap",
|
|
3160
|
-
mime: "application/vnd.tcpdump.pcap"
|
|
3161
|
-
};
|
|
3162
|
-
}
|
|
3163
|
-
if (this.checkString("DSD ")) {
|
|
3164
|
-
return {
|
|
3165
|
-
ext: "dsf",
|
|
3166
|
-
mime: "audio/x-dsf"
|
|
3167
|
-
// Non-standard
|
|
3168
|
-
};
|
|
3169
|
-
}
|
|
3170
|
-
if (this.checkString("LZIP")) {
|
|
3171
|
-
return {
|
|
3172
|
-
ext: "lz",
|
|
3173
|
-
mime: "application/x-lzip"
|
|
3174
|
-
};
|
|
3175
|
-
}
|
|
3176
|
-
if (this.checkString("fLaC")) {
|
|
3177
|
-
return {
|
|
3178
|
-
ext: "flac",
|
|
3179
|
-
mime: "audio/flac"
|
|
3180
|
-
};
|
|
3181
|
-
}
|
|
3182
|
-
if (this.check([66, 80, 71, 251])) {
|
|
3183
|
-
return {
|
|
3184
|
-
ext: "bpg",
|
|
3185
|
-
mime: "image/bpg"
|
|
3186
|
-
};
|
|
3187
|
-
}
|
|
3188
|
-
if (this.checkString("wvpk")) {
|
|
3189
|
-
return {
|
|
3190
|
-
ext: "wv",
|
|
3191
|
-
mime: "audio/wavpack"
|
|
3192
|
-
};
|
|
3193
|
-
}
|
|
3194
|
-
if (this.checkString("%PDF")) {
|
|
3195
|
-
return {
|
|
3196
|
-
ext: "pdf",
|
|
3197
|
-
mime: "application/pdf"
|
|
3198
|
-
};
|
|
3199
|
-
}
|
|
3200
|
-
if (this.check([0, 97, 115, 109])) {
|
|
3201
|
-
return {
|
|
3202
|
-
ext: "wasm",
|
|
3203
|
-
mime: "application/wasm"
|
|
3204
|
-
};
|
|
3205
|
-
}
|
|
3206
|
-
if (this.check([73, 73])) {
|
|
3207
|
-
const fileType = await this.readTiffHeader(false);
|
|
3208
|
-
if (fileType) {
|
|
3209
|
-
return fileType;
|
|
3210
|
-
}
|
|
3211
|
-
}
|
|
3212
|
-
if (this.check([77, 77])) {
|
|
3213
|
-
const fileType = await this.readTiffHeader(true);
|
|
3214
|
-
if (fileType) {
|
|
3215
|
-
return fileType;
|
|
3216
|
-
}
|
|
3217
|
-
}
|
|
3218
|
-
if (this.checkString("MAC ")) {
|
|
3219
|
-
return {
|
|
3220
|
-
ext: "ape",
|
|
3221
|
-
mime: "audio/ape"
|
|
3222
|
-
};
|
|
3223
|
-
}
|
|
3224
|
-
if (this.check([26, 69, 223, 163])) {
|
|
3225
|
-
async function readField() {
|
|
3226
|
-
const msb = await tokenizer.peekNumber(UINT8);
|
|
3227
|
-
let mask = 128;
|
|
3228
|
-
let ic = 0;
|
|
3229
|
-
while ((msb & mask) === 0 && mask !== 0) {
|
|
3230
|
-
++ic;
|
|
3231
|
-
mask >>= 1;
|
|
3232
|
-
}
|
|
3233
|
-
const id = new Uint8Array(ic + 1);
|
|
3234
|
-
await tokenizer.readBuffer(id);
|
|
3235
|
-
return id;
|
|
3236
|
-
}
|
|
3237
|
-
async function readElement() {
|
|
3238
|
-
const idField = await readField();
|
|
3239
|
-
const lengthField = await readField();
|
|
3240
|
-
lengthField[0] ^= 128 >> lengthField.length - 1;
|
|
3241
|
-
const nrLength = Math.min(6, lengthField.length);
|
|
3242
|
-
const idView = new DataView(idField.buffer);
|
|
3243
|
-
const lengthView = new DataView(lengthField.buffer, lengthField.length - nrLength, nrLength);
|
|
3244
|
-
return {
|
|
3245
|
-
id: getUintBE(idView),
|
|
3246
|
-
len: getUintBE(lengthView)
|
|
3247
|
-
};
|
|
3248
|
-
}
|
|
3249
|
-
async function readChildren(children) {
|
|
3250
|
-
while (children > 0) {
|
|
3251
|
-
const element = await readElement();
|
|
3252
|
-
if (element.id === 17026) {
|
|
3253
|
-
const rawValue = await tokenizer.readToken(new StringType(element.len));
|
|
3254
|
-
return rawValue.replaceAll(/\00.*$/g, "");
|
|
3255
|
-
}
|
|
3256
|
-
await tokenizer.ignore(element.len);
|
|
3257
|
-
--children;
|
|
3258
|
-
}
|
|
3259
|
-
}
|
|
3260
|
-
const re = await readElement();
|
|
3261
|
-
const documentType = await readChildren(re.len);
|
|
3262
|
-
switch (documentType) {
|
|
3263
|
-
case "webm":
|
|
3264
|
-
return {
|
|
3265
|
-
ext: "webm",
|
|
3266
|
-
mime: "video/webm"
|
|
3267
|
-
};
|
|
3268
|
-
case "matroska":
|
|
3269
|
-
return {
|
|
3270
|
-
ext: "mkv",
|
|
3271
|
-
mime: "video/matroska"
|
|
3272
|
-
};
|
|
3273
|
-
default:
|
|
3274
|
-
return;
|
|
3275
|
-
}
|
|
3276
|
-
}
|
|
3277
|
-
if (this.checkString("SQLi")) {
|
|
3278
|
-
return {
|
|
3279
|
-
ext: "sqlite",
|
|
3280
|
-
mime: "application/x-sqlite3"
|
|
3281
|
-
};
|
|
3282
|
-
}
|
|
3283
|
-
if (this.check([78, 69, 83, 26])) {
|
|
3284
|
-
return {
|
|
3285
|
-
ext: "nes",
|
|
3286
|
-
mime: "application/x-nintendo-nes-rom"
|
|
3287
|
-
};
|
|
3288
|
-
}
|
|
3289
|
-
if (this.checkString("Cr24")) {
|
|
3290
|
-
return {
|
|
3291
|
-
ext: "crx",
|
|
3292
|
-
mime: "application/x-google-chrome-extension"
|
|
3293
|
-
};
|
|
3294
|
-
}
|
|
3295
|
-
if (this.checkString("MSCF") || this.checkString("ISc(")) {
|
|
3296
|
-
return {
|
|
3297
|
-
ext: "cab",
|
|
3298
|
-
mime: "application/vnd.ms-cab-compressed"
|
|
3299
|
-
};
|
|
3300
|
-
}
|
|
3301
|
-
if (this.check([237, 171, 238, 219])) {
|
|
3302
|
-
return {
|
|
3303
|
-
ext: "rpm",
|
|
3304
|
-
mime: "application/x-rpm"
|
|
3305
|
-
};
|
|
3306
|
-
}
|
|
3307
|
-
if (this.check([197, 208, 211, 198])) {
|
|
3308
|
-
return {
|
|
3309
|
-
ext: "eps",
|
|
3310
|
-
mime: "application/eps"
|
|
3311
|
-
};
|
|
3312
|
-
}
|
|
3313
|
-
if (this.check([40, 181, 47, 253])) {
|
|
3314
|
-
return {
|
|
3315
|
-
ext: "zst",
|
|
3316
|
-
mime: "application/zstd"
|
|
3317
|
-
};
|
|
3318
|
-
}
|
|
3319
|
-
if (this.check([127, 69, 76, 70])) {
|
|
3320
|
-
return {
|
|
3321
|
-
ext: "elf",
|
|
3322
|
-
mime: "application/x-elf"
|
|
3323
|
-
};
|
|
3324
|
-
}
|
|
3325
|
-
if (this.check([33, 66, 68, 78])) {
|
|
3326
|
-
return {
|
|
3327
|
-
ext: "pst",
|
|
3328
|
-
mime: "application/vnd.ms-outlook"
|
|
3329
|
-
};
|
|
3330
|
-
}
|
|
3331
|
-
if (this.checkString("PAR1") || this.checkString("PARE")) {
|
|
3332
|
-
return {
|
|
3333
|
-
ext: "parquet",
|
|
3334
|
-
mime: "application/vnd.apache.parquet"
|
|
3335
|
-
};
|
|
3336
|
-
}
|
|
3337
|
-
if (this.checkString("ttcf")) {
|
|
3338
|
-
return {
|
|
3339
|
-
ext: "ttc",
|
|
3340
|
-
mime: "font/collection"
|
|
3341
|
-
};
|
|
3342
|
-
}
|
|
3343
|
-
if (this.check([207, 250, 237, 254])) {
|
|
3344
|
-
return {
|
|
3345
|
-
ext: "macho",
|
|
3346
|
-
mime: "application/x-mach-binary"
|
|
3347
|
-
};
|
|
3348
|
-
}
|
|
3349
|
-
if (this.check([4, 34, 77, 24])) {
|
|
3350
|
-
return {
|
|
3351
|
-
ext: "lz4",
|
|
3352
|
-
mime: "application/x-lz4"
|
|
3353
|
-
// Invented by us
|
|
3354
|
-
};
|
|
3355
|
-
}
|
|
3356
|
-
if (this.checkString("regf")) {
|
|
3357
|
-
return {
|
|
3358
|
-
ext: "dat",
|
|
3359
|
-
mime: "application/x-ft-windows-registry-hive"
|
|
3360
|
-
};
|
|
3361
|
-
}
|
|
3362
|
-
if (this.checkString("$FL2") || this.checkString("$FL3")) {
|
|
3363
|
-
return {
|
|
3364
|
-
ext: "sav",
|
|
3365
|
-
mime: "application/x-spss-sav"
|
|
3366
|
-
};
|
|
3367
|
-
}
|
|
3368
|
-
if (this.check([79, 84, 84, 79, 0])) {
|
|
3369
|
-
return {
|
|
3370
|
-
ext: "otf",
|
|
3371
|
-
mime: "font/otf"
|
|
3372
|
-
};
|
|
3373
|
-
}
|
|
3374
|
-
if (this.checkString("#!AMR")) {
|
|
3375
|
-
return {
|
|
3376
|
-
ext: "amr",
|
|
3377
|
-
mime: "audio/amr"
|
|
3378
|
-
};
|
|
3379
|
-
}
|
|
3380
|
-
if (this.checkString("{\\rtf")) {
|
|
3381
|
-
return {
|
|
3382
|
-
ext: "rtf",
|
|
3383
|
-
mime: "application/rtf"
|
|
3384
|
-
};
|
|
3385
|
-
}
|
|
3386
|
-
if (this.check([70, 76, 86, 1])) {
|
|
3387
|
-
return {
|
|
3388
|
-
ext: "flv",
|
|
3389
|
-
mime: "video/x-flv"
|
|
3390
|
-
};
|
|
3391
|
-
}
|
|
3392
|
-
if (this.checkString("IMPM")) {
|
|
3393
|
-
return {
|
|
3394
|
-
ext: "it",
|
|
3395
|
-
mime: "audio/x-it"
|
|
3396
|
-
};
|
|
3397
|
-
}
|
|
3398
|
-
if (this.checkString("-lh0-", { offset: 2 }) || this.checkString("-lh1-", { offset: 2 }) || this.checkString("-lh2-", { offset: 2 }) || this.checkString("-lh3-", { offset: 2 }) || this.checkString("-lh4-", { offset: 2 }) || this.checkString("-lh5-", { offset: 2 }) || this.checkString("-lh6-", { offset: 2 }) || this.checkString("-lh7-", { offset: 2 }) || this.checkString("-lzs-", { offset: 2 }) || this.checkString("-lz4-", { offset: 2 }) || this.checkString("-lz5-", { offset: 2 }) || this.checkString("-lhd-", { offset: 2 })) {
|
|
3399
|
-
return {
|
|
3400
|
-
ext: "lzh",
|
|
3401
|
-
mime: "application/x-lzh-compressed"
|
|
3402
|
-
};
|
|
3403
|
-
}
|
|
3404
|
-
if (this.check([0, 0, 1, 186])) {
|
|
3405
|
-
if (this.check([33], { offset: 4, mask: [241] })) {
|
|
3406
|
-
return {
|
|
3407
|
-
ext: "mpg",
|
|
3408
|
-
// May also be .ps, .mpeg
|
|
3409
|
-
mime: "video/MP1S"
|
|
3410
|
-
};
|
|
3411
|
-
}
|
|
3412
|
-
if (this.check([68], { offset: 4, mask: [196] })) {
|
|
3413
|
-
return {
|
|
3414
|
-
ext: "mpg",
|
|
3415
|
-
// May also be .mpg, .m2p, .vob or .sub
|
|
3416
|
-
mime: "video/MP2P"
|
|
3417
|
-
};
|
|
3418
|
-
}
|
|
3419
|
-
}
|
|
3420
|
-
if (this.checkString("ITSF")) {
|
|
3421
|
-
return {
|
|
3422
|
-
ext: "chm",
|
|
3423
|
-
mime: "application/vnd.ms-htmlhelp"
|
|
3424
|
-
};
|
|
3425
|
-
}
|
|
3426
|
-
if (this.check([202, 254, 186, 190])) {
|
|
3427
|
-
return {
|
|
3428
|
-
ext: "class",
|
|
3429
|
-
mime: "application/java-vm"
|
|
3430
|
-
};
|
|
3431
|
-
}
|
|
3432
|
-
if (this.checkString(".RMF")) {
|
|
3433
|
-
return {
|
|
3434
|
-
ext: "rm",
|
|
3435
|
-
mime: "application/vnd.rn-realmedia"
|
|
3436
|
-
};
|
|
3437
|
-
}
|
|
3438
|
-
if (this.checkString("DRACO")) {
|
|
3439
|
-
return {
|
|
3440
|
-
ext: "drc",
|
|
3441
|
-
mime: "application/vnd.google.draco"
|
|
3442
|
-
// Invented by us
|
|
3443
|
-
};
|
|
3444
|
-
}
|
|
3445
|
-
if (this.check([253, 55, 122, 88, 90, 0])) {
|
|
3446
|
-
return {
|
|
3447
|
-
ext: "xz",
|
|
3448
|
-
mime: "application/x-xz"
|
|
3449
|
-
};
|
|
3450
|
-
}
|
|
3451
|
-
if (this.checkString("<?xml ")) {
|
|
3452
|
-
return {
|
|
3453
|
-
ext: "xml",
|
|
3454
|
-
mime: "application/xml"
|
|
3455
|
-
};
|
|
3456
|
-
}
|
|
3457
|
-
if (this.check([55, 122, 188, 175, 39, 28])) {
|
|
3458
|
-
return {
|
|
3459
|
-
ext: "7z",
|
|
3460
|
-
mime: "application/x-7z-compressed"
|
|
3461
|
-
};
|
|
3462
|
-
}
|
|
3463
|
-
if (this.check([82, 97, 114, 33, 26, 7]) && (this.buffer[6] === 0 || this.buffer[6] === 1)) {
|
|
3464
|
-
return {
|
|
3465
|
-
ext: "rar",
|
|
3466
|
-
mime: "application/x-rar-compressed"
|
|
3467
|
-
};
|
|
3468
|
-
}
|
|
3469
|
-
if (this.checkString("solid ")) {
|
|
3470
|
-
return {
|
|
3471
|
-
ext: "stl",
|
|
3472
|
-
mime: "model/stl"
|
|
3473
|
-
};
|
|
3474
|
-
}
|
|
3475
|
-
if (this.checkString("AC")) {
|
|
3476
|
-
const version = new StringType(4, "latin1").get(this.buffer, 2);
|
|
3477
|
-
if (version.match("^d*") && version >= 1e3 && version <= 1050) {
|
|
3478
|
-
return {
|
|
3479
|
-
ext: "dwg",
|
|
3480
|
-
mime: "image/vnd.dwg"
|
|
3481
|
-
};
|
|
3482
|
-
}
|
|
3483
|
-
}
|
|
3484
|
-
if (this.checkString("070707")) {
|
|
3485
|
-
return {
|
|
3486
|
-
ext: "cpio",
|
|
3487
|
-
mime: "application/x-cpio"
|
|
3488
|
-
};
|
|
3489
|
-
}
|
|
3490
|
-
if (this.checkString("BLENDER")) {
|
|
3491
|
-
return {
|
|
3492
|
-
ext: "blend",
|
|
3493
|
-
mime: "application/x-blender"
|
|
3494
|
-
};
|
|
3495
|
-
}
|
|
3496
|
-
if (this.checkString("!<arch>")) {
|
|
3497
|
-
await tokenizer.ignore(8);
|
|
3498
|
-
const string = await tokenizer.readToken(new StringType(13, "ascii"));
|
|
3499
|
-
if (string === "debian-binary") {
|
|
3500
|
-
return {
|
|
3501
|
-
ext: "deb",
|
|
3502
|
-
mime: "application/x-deb"
|
|
3503
|
-
};
|
|
3504
|
-
}
|
|
3505
|
-
return {
|
|
3506
|
-
ext: "ar",
|
|
3507
|
-
mime: "application/x-unix-archive"
|
|
3508
|
-
};
|
|
3509
|
-
}
|
|
3510
|
-
if (this.checkString("WEBVTT") && // One of LF, CR, tab, space, or end of file must follow "WEBVTT" per the spec (see `fixture/fixture-vtt-*.vtt` for examples). Note that `\0` is technically the null character (there is no such thing as an EOF character). However, checking for `\0` gives us the same result as checking for the end of the stream.
|
|
3511
|
-
["\n", "\r", " ", " ", "\0"].some((char7) => this.checkString(char7, { offset: 6 }))) {
|
|
3512
|
-
return {
|
|
3513
|
-
ext: "vtt",
|
|
3514
|
-
mime: "text/vtt"
|
|
3515
|
-
};
|
|
3516
|
-
}
|
|
3517
|
-
if (this.check([137, 80, 78, 71, 13, 10, 26, 10])) {
|
|
3518
|
-
await tokenizer.ignore(8);
|
|
3519
|
-
async function readChunkHeader() {
|
|
3520
|
-
return {
|
|
3521
|
-
length: await tokenizer.readToken(INT32_BE),
|
|
3522
|
-
type: await tokenizer.readToken(new StringType(4, "latin1"))
|
|
3523
|
-
};
|
|
3524
|
-
}
|
|
3525
|
-
do {
|
|
3526
|
-
const chunk = await readChunkHeader();
|
|
3527
|
-
if (chunk.length < 0) {
|
|
3528
|
-
return;
|
|
3529
|
-
}
|
|
3530
|
-
switch (chunk.type) {
|
|
3531
|
-
case "IDAT":
|
|
3532
|
-
return {
|
|
3533
|
-
ext: "png",
|
|
3534
|
-
mime: "image/png"
|
|
3535
|
-
};
|
|
3536
|
-
case "acTL":
|
|
3537
|
-
return {
|
|
3538
|
-
ext: "apng",
|
|
3539
|
-
mime: "image/apng"
|
|
3540
|
-
};
|
|
3541
|
-
default:
|
|
3542
|
-
await tokenizer.ignore(chunk.length + 4);
|
|
3543
|
-
}
|
|
3544
|
-
} while (tokenizer.position + 8 < tokenizer.fileInfo.size);
|
|
3545
|
-
return {
|
|
3546
|
-
ext: "png",
|
|
3547
|
-
mime: "image/png"
|
|
3548
|
-
};
|
|
3549
|
-
}
|
|
3550
|
-
if (this.check([65, 82, 82, 79, 87, 49, 0, 0])) {
|
|
3551
|
-
return {
|
|
3552
|
-
ext: "arrow",
|
|
3553
|
-
mime: "application/vnd.apache.arrow.file"
|
|
3554
|
-
};
|
|
3555
|
-
}
|
|
3556
|
-
if (this.check([103, 108, 84, 70, 2, 0, 0, 0])) {
|
|
3557
|
-
return {
|
|
3558
|
-
ext: "glb",
|
|
3559
|
-
mime: "model/gltf-binary"
|
|
3560
|
-
};
|
|
3561
|
-
}
|
|
3562
|
-
if (this.check([102, 114, 101, 101], { offset: 4 }) || this.check([109, 100, 97, 116], { offset: 4 }) || this.check([109, 111, 111, 118], { offset: 4 }) || this.check([119, 105, 100, 101], { offset: 4 })) {
|
|
3563
|
-
return {
|
|
3564
|
-
ext: "mov",
|
|
3565
|
-
mime: "video/quicktime"
|
|
3566
|
-
};
|
|
3567
|
-
}
|
|
3568
|
-
if (this.check([73, 73, 82, 79, 8, 0, 0, 0, 24])) {
|
|
3569
|
-
return {
|
|
3570
|
-
ext: "orf",
|
|
3571
|
-
mime: "image/x-olympus-orf"
|
|
3572
|
-
};
|
|
3573
|
-
}
|
|
3574
|
-
if (this.checkString("gimp xcf ")) {
|
|
3575
|
-
return {
|
|
3576
|
-
ext: "xcf",
|
|
3577
|
-
mime: "image/x-xcf"
|
|
3578
|
-
};
|
|
3579
|
-
}
|
|
3580
|
-
if (this.checkString("ftyp", { offset: 4 }) && (this.buffer[8] & 96) !== 0) {
|
|
3581
|
-
const brandMajor = new StringType(4, "latin1").get(this.buffer, 8).replace("\0", " ").trim();
|
|
3582
|
-
switch (brandMajor) {
|
|
3583
|
-
case "avif":
|
|
3584
|
-
case "avis":
|
|
3585
|
-
return { ext: "avif", mime: "image/avif" };
|
|
3586
|
-
case "mif1":
|
|
3587
|
-
return { ext: "heic", mime: "image/heif" };
|
|
3588
|
-
case "msf1":
|
|
3589
|
-
return { ext: "heic", mime: "image/heif-sequence" };
|
|
3590
|
-
case "heic":
|
|
3591
|
-
case "heix":
|
|
3592
|
-
return { ext: "heic", mime: "image/heic" };
|
|
3593
|
-
case "hevc":
|
|
3594
|
-
case "hevx":
|
|
3595
|
-
return { ext: "heic", mime: "image/heic-sequence" };
|
|
3596
|
-
case "qt":
|
|
3597
|
-
return { ext: "mov", mime: "video/quicktime" };
|
|
3598
|
-
case "M4V":
|
|
3599
|
-
case "M4VH":
|
|
3600
|
-
case "M4VP":
|
|
3601
|
-
return { ext: "m4v", mime: "video/x-m4v" };
|
|
3602
|
-
case "M4P":
|
|
3603
|
-
return { ext: "m4p", mime: "video/mp4" };
|
|
3604
|
-
case "M4B":
|
|
3605
|
-
return { ext: "m4b", mime: "audio/mp4" };
|
|
3606
|
-
case "M4A":
|
|
3607
|
-
return { ext: "m4a", mime: "audio/x-m4a" };
|
|
3608
|
-
case "F4V":
|
|
3609
|
-
return { ext: "f4v", mime: "video/mp4" };
|
|
3610
|
-
case "F4P":
|
|
3611
|
-
return { ext: "f4p", mime: "video/mp4" };
|
|
3612
|
-
case "F4A":
|
|
3613
|
-
return { ext: "f4a", mime: "audio/mp4" };
|
|
3614
|
-
case "F4B":
|
|
3615
|
-
return { ext: "f4b", mime: "audio/mp4" };
|
|
3616
|
-
case "crx":
|
|
3617
|
-
return { ext: "cr3", mime: "image/x-canon-cr3" };
|
|
3618
|
-
default:
|
|
3619
|
-
if (brandMajor.startsWith("3g")) {
|
|
3620
|
-
if (brandMajor.startsWith("3g2")) {
|
|
3621
|
-
return { ext: "3g2", mime: "video/3gpp2" };
|
|
3622
|
-
}
|
|
3623
|
-
return { ext: "3gp", mime: "video/3gpp" };
|
|
3624
|
-
}
|
|
3625
|
-
return { ext: "mp4", mime: "video/mp4" };
|
|
3626
|
-
}
|
|
3627
|
-
}
|
|
3628
|
-
if (this.checkString("REGEDIT4\r\n")) {
|
|
3629
|
-
return {
|
|
3630
|
-
ext: "reg",
|
|
3631
|
-
mime: "application/x-ms-regedit"
|
|
3632
|
-
};
|
|
3633
|
-
}
|
|
3634
|
-
if (this.check([82, 73, 70, 70])) {
|
|
3635
|
-
if (this.checkString("WEBP", { offset: 8 })) {
|
|
3636
|
-
return {
|
|
3637
|
-
ext: "webp",
|
|
3638
|
-
mime: "image/webp"
|
|
3639
|
-
};
|
|
3640
|
-
}
|
|
3641
|
-
if (this.check([65, 86, 73], { offset: 8 })) {
|
|
3642
|
-
return {
|
|
3643
|
-
ext: "avi",
|
|
3644
|
-
mime: "video/vnd.avi"
|
|
3645
|
-
};
|
|
3646
|
-
}
|
|
3647
|
-
if (this.check([87, 65, 86, 69], { offset: 8 })) {
|
|
3648
|
-
return {
|
|
3649
|
-
ext: "wav",
|
|
3650
|
-
mime: "audio/wav"
|
|
3651
|
-
};
|
|
3652
|
-
}
|
|
3653
|
-
if (this.check([81, 76, 67, 77], { offset: 8 })) {
|
|
3654
|
-
return {
|
|
3655
|
-
ext: "qcp",
|
|
3656
|
-
mime: "audio/qcelp"
|
|
3657
|
-
};
|
|
3658
|
-
}
|
|
3659
|
-
}
|
|
3660
|
-
if (this.check([73, 73, 85, 0, 24, 0, 0, 0, 136, 231, 116, 216])) {
|
|
3661
|
-
return {
|
|
3662
|
-
ext: "rw2",
|
|
3663
|
-
mime: "image/x-panasonic-rw2"
|
|
3664
|
-
};
|
|
3665
|
-
}
|
|
3666
|
-
if (this.check([48, 38, 178, 117, 142, 102, 207, 17, 166, 217])) {
|
|
3667
|
-
async function readHeader() {
|
|
3668
|
-
const guid = new Uint8Array(16);
|
|
3669
|
-
await tokenizer.readBuffer(guid);
|
|
3670
|
-
return {
|
|
3671
|
-
id: guid,
|
|
3672
|
-
size: Number(await tokenizer.readToken(UINT64_LE))
|
|
3673
|
-
};
|
|
3674
|
-
}
|
|
3675
|
-
await tokenizer.ignore(30);
|
|
3676
|
-
while (tokenizer.position + 24 < tokenizer.fileInfo.size) {
|
|
3677
|
-
const header = await readHeader();
|
|
3678
|
-
let payload = header.size - 24;
|
|
3679
|
-
if (_check(header.id, [145, 7, 220, 183, 183, 169, 207, 17, 142, 230, 0, 192, 12, 32, 83, 101])) {
|
|
3680
|
-
const typeId = new Uint8Array(16);
|
|
3681
|
-
payload -= await tokenizer.readBuffer(typeId);
|
|
3682
|
-
if (_check(typeId, [64, 158, 105, 248, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43])) {
|
|
3683
|
-
return {
|
|
3684
|
-
ext: "asf",
|
|
3685
|
-
mime: "audio/x-ms-asf"
|
|
3686
|
-
};
|
|
3687
|
-
}
|
|
3688
|
-
if (_check(typeId, [192, 239, 25, 188, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43])) {
|
|
3689
|
-
return {
|
|
3690
|
-
ext: "asf",
|
|
3691
|
-
mime: "video/x-ms-asf"
|
|
3692
|
-
};
|
|
3693
|
-
}
|
|
3694
|
-
break;
|
|
3695
|
-
}
|
|
3696
|
-
await tokenizer.ignore(payload);
|
|
3697
|
-
}
|
|
3698
|
-
return {
|
|
3699
|
-
ext: "asf",
|
|
3700
|
-
mime: "application/vnd.ms-asf"
|
|
3701
|
-
};
|
|
3702
|
-
}
|
|
3703
|
-
if (this.check([171, 75, 84, 88, 32, 49, 49, 187, 13, 10, 26, 10])) {
|
|
3704
|
-
return {
|
|
3705
|
-
ext: "ktx",
|
|
3706
|
-
mime: "image/ktx"
|
|
3707
|
-
};
|
|
3708
|
-
}
|
|
3709
|
-
if ((this.check([126, 16, 4]) || this.check([126, 24, 4])) && this.check([48, 77, 73, 69], { offset: 4 })) {
|
|
3710
|
-
return {
|
|
3711
|
-
ext: "mie",
|
|
3712
|
-
mime: "application/x-mie"
|
|
3713
|
-
};
|
|
3714
|
-
}
|
|
3715
|
-
if (this.check([39, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], { offset: 2 })) {
|
|
3716
|
-
return {
|
|
3717
|
-
ext: "shp",
|
|
3718
|
-
mime: "application/x-esri-shape"
|
|
3719
|
-
};
|
|
3720
|
-
}
|
|
3721
|
-
if (this.check([255, 79, 255, 81])) {
|
|
3722
|
-
return {
|
|
3723
|
-
ext: "j2c",
|
|
3724
|
-
mime: "image/j2c"
|
|
3725
|
-
};
|
|
3726
|
-
}
|
|
3727
|
-
if (this.check([0, 0, 0, 12, 106, 80, 32, 32, 13, 10, 135, 10])) {
|
|
3728
|
-
await tokenizer.ignore(20);
|
|
3729
|
-
const type = await tokenizer.readToken(new StringType(4, "ascii"));
|
|
3730
|
-
switch (type) {
|
|
3731
|
-
case "jp2 ":
|
|
3732
|
-
return {
|
|
3733
|
-
ext: "jp2",
|
|
3734
|
-
mime: "image/jp2"
|
|
3735
|
-
};
|
|
3736
|
-
case "jpx ":
|
|
3737
|
-
return {
|
|
3738
|
-
ext: "jpx",
|
|
3739
|
-
mime: "image/jpx"
|
|
3740
|
-
};
|
|
3741
|
-
case "jpm ":
|
|
3742
|
-
return {
|
|
3743
|
-
ext: "jpm",
|
|
3744
|
-
mime: "image/jpm"
|
|
3745
|
-
};
|
|
3746
|
-
case "mjp2":
|
|
3747
|
-
return {
|
|
3748
|
-
ext: "mj2",
|
|
3749
|
-
mime: "image/mj2"
|
|
3750
|
-
};
|
|
3751
|
-
default:
|
|
3752
|
-
return;
|
|
3753
|
-
}
|
|
3754
|
-
}
|
|
3755
|
-
if (this.check([255, 10]) || this.check([0, 0, 0, 12, 74, 88, 76, 32, 13, 10, 135, 10])) {
|
|
3756
|
-
return {
|
|
3757
|
-
ext: "jxl",
|
|
3758
|
-
mime: "image/jxl"
|
|
3759
|
-
};
|
|
3760
|
-
}
|
|
3761
|
-
if (this.check([254, 255])) {
|
|
3762
|
-
if (this.checkString("<?xml ", { offset: 2, encoding: "utf-16be" })) {
|
|
3763
|
-
return {
|
|
3764
|
-
ext: "xml",
|
|
3765
|
-
mime: "application/xml"
|
|
3766
|
-
};
|
|
3767
|
-
}
|
|
3768
|
-
return void 0;
|
|
3769
|
-
}
|
|
3770
|
-
if (this.check([208, 207, 17, 224, 161, 177, 26, 225])) {
|
|
3771
|
-
return {
|
|
3772
|
-
ext: "cfb",
|
|
3773
|
-
mime: "application/x-cfb"
|
|
3774
|
-
};
|
|
3775
|
-
}
|
|
3776
|
-
await tokenizer.peekBuffer(this.buffer, { length: Math.min(256, tokenizer.fileInfo.size), mayBeLess: true });
|
|
3777
|
-
if (this.check([97, 99, 115, 112], { offset: 36 })) {
|
|
3778
|
-
return {
|
|
3779
|
-
ext: "icc",
|
|
3780
|
-
mime: "application/vnd.iccprofile"
|
|
3781
|
-
};
|
|
3782
|
-
}
|
|
3783
|
-
if (this.checkString("**ACE", { offset: 7 }) && this.checkString("**", { offset: 12 })) {
|
|
3784
|
-
return {
|
|
3785
|
-
ext: "ace",
|
|
3786
|
-
mime: "application/x-ace-compressed"
|
|
3787
|
-
};
|
|
3788
|
-
}
|
|
3789
|
-
if (this.checkString("BEGIN:")) {
|
|
3790
|
-
if (this.checkString("VCARD", { offset: 6 })) {
|
|
3791
|
-
return {
|
|
3792
|
-
ext: "vcf",
|
|
3793
|
-
mime: "text/vcard"
|
|
3794
|
-
};
|
|
3795
|
-
}
|
|
3796
|
-
if (this.checkString("VCALENDAR", { offset: 6 })) {
|
|
3797
|
-
return {
|
|
3798
|
-
ext: "ics",
|
|
3799
|
-
mime: "text/calendar"
|
|
3800
|
-
};
|
|
3801
|
-
}
|
|
3802
|
-
}
|
|
3803
|
-
if (this.checkString("FUJIFILMCCD-RAW")) {
|
|
3804
|
-
return {
|
|
3805
|
-
ext: "raf",
|
|
3806
|
-
mime: "image/x-fujifilm-raf"
|
|
3807
|
-
};
|
|
3808
|
-
}
|
|
3809
|
-
if (this.checkString("Extended Module:")) {
|
|
3810
|
-
return {
|
|
3811
|
-
ext: "xm",
|
|
3812
|
-
mime: "audio/x-xm"
|
|
3813
|
-
};
|
|
148
|
+
constructor(opts) {
|
|
149
|
+
if (!opts.apiKey) {
|
|
150
|
+
throw new Error("apiKey is required");
|
|
151
|
+
}
|
|
152
|
+
this.apiKey = opts.apiKey;
|
|
153
|
+
this.baseUrl = (opts.baseUrl || getBaseUrl(opts.environment || "prod")).replace(/\/+$/, "");
|
|
154
|
+
}
|
|
155
|
+
uploadFile(params, onProgress, signal) {
|
|
156
|
+
return new Promise((resolve, reject) => {
|
|
157
|
+
if (signal?.aborted) {
|
|
158
|
+
reject(new DOMException("Upload aborted", "AbortError"));
|
|
159
|
+
return;
|
|
3814
160
|
}
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
161
|
+
const xhr = new XMLHttpRequest();
|
|
162
|
+
if (signal) {
|
|
163
|
+
signal.addEventListener("abort", () => {
|
|
164
|
+
xhr.abort();
|
|
165
|
+
reject(new DOMException("Upload aborted", "AbortError"));
|
|
166
|
+
});
|
|
3820
167
|
}
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
if (
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
168
|
+
let lastProgress = 0;
|
|
169
|
+
xhr.upload.onprogress = (event) => {
|
|
170
|
+
if (event.lengthComputable && onProgress) {
|
|
171
|
+
const progress = Math.round(event.loaded / event.total * 100);
|
|
172
|
+
lastProgress = progress;
|
|
173
|
+
onProgress(progress);
|
|
174
|
+
} else if (onProgress && event.loaded > 0) {
|
|
175
|
+
const estimatedProgress = Math.min(
|
|
176
|
+
95,
|
|
177
|
+
Math.round(event.loaded / (event.loaded + 1e6) * 100)
|
|
178
|
+
);
|
|
179
|
+
if (estimatedProgress > lastProgress) {
|
|
180
|
+
lastProgress = estimatedProgress;
|
|
181
|
+
onProgress(estimatedProgress);
|
|
3834
182
|
}
|
|
3835
183
|
}
|
|
3836
|
-
}
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
if (this.check([66, 79, 79, 75, 77, 79, 66, 73], { offset: 60 })) {
|
|
3862
|
-
return {
|
|
3863
|
-
ext: "mobi",
|
|
3864
|
-
mime: "application/x-mobipocket-ebook"
|
|
3865
|
-
};
|
|
3866
|
-
}
|
|
3867
|
-
if (this.check([68, 73, 67, 77], { offset: 128 })) {
|
|
3868
|
-
return {
|
|
3869
|
-
ext: "dcm",
|
|
3870
|
-
mime: "application/dicom"
|
|
3871
|
-
};
|
|
3872
|
-
}
|
|
3873
|
-
if (this.check([76, 0, 0, 0, 1, 20, 2, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 70])) {
|
|
3874
|
-
return {
|
|
3875
|
-
ext: "lnk",
|
|
3876
|
-
mime: "application/x.ms.shortcut"
|
|
3877
|
-
// Invented by us
|
|
3878
|
-
};
|
|
3879
|
-
}
|
|
3880
|
-
if (this.check([98, 111, 111, 107, 0, 0, 0, 0, 109, 97, 114, 107, 0, 0, 0, 0])) {
|
|
3881
|
-
return {
|
|
3882
|
-
ext: "alias",
|
|
3883
|
-
mime: "application/x.apple.alias"
|
|
3884
|
-
// Invented by us
|
|
3885
|
-
};
|
|
3886
|
-
}
|
|
3887
|
-
if (this.checkString("Kaydara FBX Binary \0")) {
|
|
3888
|
-
return {
|
|
3889
|
-
ext: "fbx",
|
|
3890
|
-
mime: "application/x.autodesk.fbx"
|
|
3891
|
-
// Invented by us
|
|
3892
|
-
};
|
|
3893
|
-
}
|
|
3894
|
-
if (this.check([76, 80], { offset: 34 }) && (this.check([0, 0, 1], { offset: 8 }) || this.check([1, 0, 2], { offset: 8 }) || this.check([2, 0, 2], { offset: 8 }))) {
|
|
3895
|
-
return {
|
|
3896
|
-
ext: "eot",
|
|
3897
|
-
mime: "application/vnd.ms-fontobject"
|
|
3898
|
-
};
|
|
3899
|
-
}
|
|
3900
|
-
if (this.check([6, 6, 237, 245, 216, 29, 70, 229, 189, 49, 239, 231, 254, 116, 183, 29])) {
|
|
3901
|
-
return {
|
|
3902
|
-
ext: "indd",
|
|
3903
|
-
mime: "application/x-indesign"
|
|
3904
|
-
};
|
|
3905
|
-
}
|
|
3906
|
-
if (this.check([255, 255, 0, 0, 7, 0, 0, 0, 4, 0, 0, 0, 1, 0, 1, 0]) || this.check([0, 0, 255, 255, 0, 0, 0, 7, 0, 0, 0, 4, 0, 1, 0, 1])) {
|
|
3907
|
-
return {
|
|
3908
|
-
ext: "jmp",
|
|
3909
|
-
mime: "application/x-jmp-data"
|
|
3910
|
-
};
|
|
3911
|
-
}
|
|
3912
|
-
await tokenizer.peekBuffer(this.buffer, { length: Math.min(512, tokenizer.fileInfo.size), mayBeLess: true });
|
|
3913
|
-
if (this.checkString("ustar", { offset: 257 }) && (this.checkString("\0", { offset: 262 }) || this.checkString(" ", { offset: 262 })) || this.check([0, 0, 0, 0, 0, 0], { offset: 257 }) && tarHeaderChecksumMatches(this.buffer)) {
|
|
3914
|
-
return {
|
|
3915
|
-
ext: "tar",
|
|
3916
|
-
mime: "application/x-tar"
|
|
3917
|
-
};
|
|
3918
|
-
}
|
|
3919
|
-
if (this.check([255, 254])) {
|
|
3920
|
-
const encoding = "utf-16le";
|
|
3921
|
-
if (this.checkString("<?xml ", { offset: 2, encoding })) {
|
|
3922
|
-
return {
|
|
3923
|
-
ext: "xml",
|
|
3924
|
-
mime: "application/xml"
|
|
3925
|
-
};
|
|
3926
|
-
}
|
|
3927
|
-
if (this.check([255, 14], { offset: 2 }) && this.checkString("SketchUp Model", { offset: 4, encoding })) {
|
|
3928
|
-
return {
|
|
3929
|
-
ext: "skp",
|
|
3930
|
-
mime: "application/vnd.sketchup.skp"
|
|
3931
|
-
};
|
|
3932
|
-
}
|
|
3933
|
-
if (this.checkString("Windows Registry Editor Version 5.00\r\n", { offset: 2, encoding })) {
|
|
3934
|
-
return {
|
|
3935
|
-
ext: "reg",
|
|
3936
|
-
mime: "application/x-ms-regedit"
|
|
184
|
+
};
|
|
185
|
+
xhr.onerror = () => {
|
|
186
|
+
reject(new Error(`Upload failed: ${xhr.statusText}`));
|
|
187
|
+
};
|
|
188
|
+
xhr.onload = () => {
|
|
189
|
+
try {
|
|
190
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
191
|
+
const errorText = xhr.responseText || xhr.statusText;
|
|
192
|
+
reject(new Error(`Upload failed: ${errorText}`));
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const newResponse = JSON.parse(xhr.responseText);
|
|
196
|
+
const response = {
|
|
197
|
+
success: true,
|
|
198
|
+
file_no: newResponse.file_no || newResponse.id,
|
|
199
|
+
name: newResponse.name,
|
|
200
|
+
url: newResponse.url,
|
|
201
|
+
file_size: newResponse.size,
|
|
202
|
+
format: newResponse.format,
|
|
203
|
+
width: newResponse.width,
|
|
204
|
+
height: newResponse.height,
|
|
205
|
+
created_at: newResponse.created_at,
|
|
206
|
+
path: newResponse.path,
|
|
207
|
+
workspace_no: newResponse.workspace_id,
|
|
208
|
+
isDuplicate: newResponse.is_duplicate || false
|
|
3937
209
|
};
|
|
210
|
+
resolve(response);
|
|
211
|
+
} catch (error) {
|
|
212
|
+
reject(new Error("Failed to parse response"));
|
|
3938
213
|
}
|
|
3939
|
-
|
|
3940
|
-
}
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
}
|
|
3947
|
-
});
|
|
3948
|
-
// Detections with limited supporting data, resulting in a higher likelihood of false positives
|
|
3949
|
-
__publicField(this, "detectImprecise", async (tokenizer) => {
|
|
3950
|
-
this.buffer = new Uint8Array(reasonableDetectionSizeInBytes);
|
|
3951
|
-
await tokenizer.peekBuffer(this.buffer, { length: Math.min(8, tokenizer.fileInfo.size), mayBeLess: true });
|
|
3952
|
-
if (this.check([0, 0, 1, 186]) || this.check([0, 0, 1, 179])) {
|
|
3953
|
-
return {
|
|
3954
|
-
ext: "mpg",
|
|
3955
|
-
mime: "video/mpeg"
|
|
3956
|
-
};
|
|
3957
|
-
}
|
|
3958
|
-
if (this.check([0, 1, 0, 0, 0])) {
|
|
3959
|
-
return {
|
|
3960
|
-
ext: "ttf",
|
|
3961
|
-
mime: "font/ttf"
|
|
3962
|
-
};
|
|
214
|
+
};
|
|
215
|
+
const endpoint = `${this.baseUrl}/uploads`;
|
|
216
|
+
const formData = new FormData();
|
|
217
|
+
formData.append("file", params.file);
|
|
218
|
+
formData.append("file_name", params.file.name);
|
|
219
|
+
if (params.folderPath) {
|
|
220
|
+
formData.append("folder", params.folderPath);
|
|
3963
221
|
}
|
|
3964
|
-
if (
|
|
3965
|
-
|
|
3966
|
-
ext: "ico",
|
|
3967
|
-
mime: "image/x-icon"
|
|
3968
|
-
};
|
|
222
|
+
if (params.settings?.tags?.length) {
|
|
223
|
+
formData.append("tags", params.settings.tags.join(","));
|
|
3969
224
|
}
|
|
3970
|
-
if (
|
|
3971
|
-
|
|
3972
|
-
ext: "cur",
|
|
3973
|
-
mime: "image/x-icon"
|
|
3974
|
-
};
|
|
225
|
+
if (params.settings?.pretransformations) {
|
|
226
|
+
formData.append("transform", params.settings.pretransformations);
|
|
3975
227
|
}
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
for (let depth = 0; depth <= this.options.mpegOffsetTolerance; ++depth) {
|
|
3979
|
-
const type = this.scanMpeg(depth);
|
|
3980
|
-
if (type) {
|
|
3981
|
-
return type;
|
|
3982
|
-
}
|
|
3983
|
-
}
|
|
228
|
+
if (params.settings?.custom_id) {
|
|
229
|
+
formData.append("custom_id", params.settings.custom_id);
|
|
3984
230
|
}
|
|
231
|
+
xhr.open("POST", endpoint);
|
|
232
|
+
xhr.setRequestHeader("Authorization", `Bearer ${this.apiKey}`);
|
|
233
|
+
xhr.setRequestHeader("accept", "application/json");
|
|
234
|
+
xhr.send(formData);
|
|
3985
235
|
});
|
|
3986
|
-
this.options = {
|
|
3987
|
-
mpegOffsetTolerance: 0,
|
|
3988
|
-
...options
|
|
3989
|
-
};
|
|
3990
|
-
this.detectors = [
|
|
3991
|
-
...options?.customDetectors ?? [],
|
|
3992
|
-
{ id: "core", detect: this.detectConfident },
|
|
3993
|
-
{ id: "core.imprecise", detect: this.detectImprecise }
|
|
3994
|
-
];
|
|
3995
|
-
this.tokenizerOptions = {
|
|
3996
|
-
abortSignal: options?.signal
|
|
3997
|
-
};
|
|
3998
236
|
}
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
}
|
|
4006
|
-
if (initialPosition !== tokenizer.position) {
|
|
4007
|
-
return void 0;
|
|
4008
|
-
}
|
|
4009
|
-
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
// src/utils/helpers.ts
|
|
240
|
+
function generateId() {
|
|
241
|
+
if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
|
|
242
|
+
return crypto.randomUUID();
|
|
4010
243
|
}
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
if (!(buffer?.length > 1)) {
|
|
4017
|
-
return;
|
|
4018
|
-
}
|
|
4019
|
-
return this.fromTokenizer(fromBuffer(buffer, this.tokenizerOptions));
|
|
244
|
+
return "id-" + Math.random().toString(36).slice(2, 11);
|
|
245
|
+
}
|
|
246
|
+
function resolveIcon(renderer) {
|
|
247
|
+
if (typeof renderer === "function") {
|
|
248
|
+
return resolveIcon(renderer());
|
|
4020
249
|
}
|
|
4021
|
-
|
|
4022
|
-
const
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
} finally {
|
|
4026
|
-
await tokenizer.close();
|
|
4027
|
-
}
|
|
250
|
+
if (typeof renderer === "string") {
|
|
251
|
+
const template = document.createElement("template");
|
|
252
|
+
template.innerHTML = renderer.trim();
|
|
253
|
+
return template.content.firstElementChild;
|
|
4028
254
|
}
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
}
|
|
255
|
+
return renderer ? renderer.cloneNode(true) : null;
|
|
256
|
+
}
|
|
257
|
+
function toCssVars(theme) {
|
|
258
|
+
const variables = {};
|
|
259
|
+
if (theme.accentColor) {
|
|
260
|
+
variables["--ar-accent"] = theme.accentColor;
|
|
4036
261
|
}
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
let detectedFileType;
|
|
4040
|
-
let firstChunk;
|
|
4041
|
-
const reader = stream.getReader({ mode: "byob" });
|
|
4042
|
-
try {
|
|
4043
|
-
const { value: chunk, done } = await reader.read(new Uint8Array(sampleSize));
|
|
4044
|
-
firstChunk = chunk;
|
|
4045
|
-
if (!done && chunk) {
|
|
4046
|
-
try {
|
|
4047
|
-
detectedFileType = await this.fromBuffer(chunk.subarray(0, sampleSize));
|
|
4048
|
-
} catch (error) {
|
|
4049
|
-
if (!(error instanceof EndOfStreamError)) {
|
|
4050
|
-
throw error;
|
|
4051
|
-
}
|
|
4052
|
-
detectedFileType = void 0;
|
|
4053
|
-
}
|
|
4054
|
-
}
|
|
4055
|
-
firstChunk = chunk;
|
|
4056
|
-
} finally {
|
|
4057
|
-
reader.releaseLock();
|
|
4058
|
-
}
|
|
4059
|
-
const transformStream = new TransformStream({
|
|
4060
|
-
async start(controller) {
|
|
4061
|
-
controller.enqueue(firstChunk);
|
|
4062
|
-
},
|
|
4063
|
-
transform(chunk, controller) {
|
|
4064
|
-
controller.enqueue(chunk);
|
|
4065
|
-
}
|
|
4066
|
-
});
|
|
4067
|
-
const newStream = stream.pipeThrough(transformStream);
|
|
4068
|
-
newStream.fileType = detectedFileType;
|
|
4069
|
-
return newStream;
|
|
262
|
+
if (theme.borderRadius !== void 0) {
|
|
263
|
+
variables["--ar-radius"] = `${theme.borderRadius}px`;
|
|
4070
264
|
}
|
|
4071
|
-
|
|
4072
|
-
|
|
265
|
+
if (theme.fontFamily) {
|
|
266
|
+
variables["--ar-font-family"] = theme.fontFamily;
|
|
4073
267
|
}
|
|
4074
|
-
|
|
4075
|
-
|
|
268
|
+
if (theme.dropzoneBackground) {
|
|
269
|
+
variables["--ar-dropzone-bg"] = theme.dropzoneBackground;
|
|
4076
270
|
}
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
this.tokenizer.ignore(10);
|
|
4080
|
-
switch (tagId) {
|
|
4081
|
-
case 50341:
|
|
4082
|
-
return {
|
|
4083
|
-
ext: "arw",
|
|
4084
|
-
mime: "image/x-sony-arw"
|
|
4085
|
-
};
|
|
4086
|
-
case 50706:
|
|
4087
|
-
return {
|
|
4088
|
-
ext: "dng",
|
|
4089
|
-
mime: "image/x-adobe-dng"
|
|
4090
|
-
};
|
|
4091
|
-
default:
|
|
4092
|
-
}
|
|
271
|
+
if (theme.dropzoneBorder) {
|
|
272
|
+
variables["--ar-dropzone-border"] = theme.dropzoneBorder;
|
|
4093
273
|
}
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
274
|
+
return variables;
|
|
275
|
+
}
|
|
276
|
+
function applyCssVariables(element, variables) {
|
|
277
|
+
Object.entries(variables).forEach(([key, value]) => {
|
|
278
|
+
element.style.setProperty(key, value);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
function getRelativeFolderPath(basePath, relativePath) {
|
|
282
|
+
if (!relativePath) return void 0;
|
|
283
|
+
const parts = relativePath.split("/").map((segment) => segment.trim()).filter((segment) => segment && segment !== ".");
|
|
284
|
+
if (parts.length <= 1) {
|
|
285
|
+
return void 0;
|
|
4102
286
|
}
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
const
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
return {
|
|
4110
|
-
ext: "cr2",
|
|
4111
|
-
mime: "image/x-canon-cr2"
|
|
4112
|
-
};
|
|
4113
|
-
}
|
|
4114
|
-
if (ifdOffset >= 8) {
|
|
4115
|
-
const someId1 = (bigEndian ? UINT16_BE : UINT16_LE).get(this.buffer, 8);
|
|
4116
|
-
const someId2 = (bigEndian ? UINT16_BE : UINT16_LE).get(this.buffer, 10);
|
|
4117
|
-
if (someId1 === 28 && someId2 === 254 || someId1 === 31 && someId2 === 11) {
|
|
4118
|
-
return {
|
|
4119
|
-
ext: "nef",
|
|
4120
|
-
mime: "image/x-nikon-nef"
|
|
4121
|
-
};
|
|
4122
|
-
}
|
|
4123
|
-
}
|
|
4124
|
-
}
|
|
4125
|
-
await this.tokenizer.ignore(ifdOffset);
|
|
4126
|
-
const fileType = await this.readTiffIFD(bigEndian);
|
|
4127
|
-
return fileType ?? {
|
|
4128
|
-
ext: "tif",
|
|
4129
|
-
mime: "image/tiff"
|
|
4130
|
-
};
|
|
4131
|
-
}
|
|
4132
|
-
if (version === 43) {
|
|
4133
|
-
return {
|
|
4134
|
-
ext: "tif",
|
|
4135
|
-
mime: "image/tiff"
|
|
4136
|
-
};
|
|
287
|
+
const folderSegments = parts.slice(0, -1);
|
|
288
|
+
if (basePath) {
|
|
289
|
+
const baseSegments = basePath.split("/").map((segment) => segment.trim()).filter((segment) => segment && segment !== ".");
|
|
290
|
+
let offset = 0;
|
|
291
|
+
while (offset < baseSegments.length && offset < folderSegments.length && folderSegments[offset] === baseSegments[offset]) {
|
|
292
|
+
offset += 1;
|
|
4137
293
|
}
|
|
294
|
+
return offset < folderSegments.length ? folderSegments.slice(offset).join("/") : void 0;
|
|
4138
295
|
}
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
}
|
|
4159
|
-
if (this.check([2], { offset: offset + 1, mask: [6] })) {
|
|
4160
|
-
return {
|
|
4161
|
-
ext: "mp3",
|
|
4162
|
-
mime: "audio/mpeg"
|
|
4163
|
-
};
|
|
4164
|
-
}
|
|
4165
|
-
if (this.check([4], { offset: offset + 1, mask: [6] })) {
|
|
4166
|
-
return {
|
|
4167
|
-
ext: "mp2",
|
|
4168
|
-
mime: "audio/mpeg"
|
|
4169
|
-
};
|
|
4170
|
-
}
|
|
4171
|
-
if (this.check([6], { offset: offset + 1, mask: [6] })) {
|
|
4172
|
-
return {
|
|
4173
|
-
ext: "mp1",
|
|
4174
|
-
mime: "audio/mpeg"
|
|
4175
|
-
};
|
|
4176
|
-
}
|
|
4177
|
-
}
|
|
296
|
+
return folderSegments.length ? folderSegments.join("/") : void 0;
|
|
297
|
+
}
|
|
298
|
+
function calculateBatchProgress(items) {
|
|
299
|
+
if (items.length === 0) return 0;
|
|
300
|
+
const total = items.reduce((acc, item) => acc + item.progress, 0);
|
|
301
|
+
return Math.round(total / items.length);
|
|
302
|
+
}
|
|
303
|
+
var S3_URL_PATTERN = /^s3:\/\/([^/]+)\/(.+)$/i;
|
|
304
|
+
function sanitizeBaseUrl(baseUrl) {
|
|
305
|
+
if (!baseUrl) return void 0;
|
|
306
|
+
const trimmed = baseUrl.trim();
|
|
307
|
+
if (!trimmed) return void 0;
|
|
308
|
+
return trimmed.replace(/\/+$/, "");
|
|
309
|
+
}
|
|
310
|
+
function extractWorkspaceFromUrl(url) {
|
|
311
|
+
if (!url) return void 0;
|
|
312
|
+
const s3Match = S3_URL_PATTERN.exec(url);
|
|
313
|
+
if (s3Match) {
|
|
314
|
+
return s3Match[1];
|
|
4178
315
|
}
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
316
|
+
try {
|
|
317
|
+
const parsed = new URL(url);
|
|
318
|
+
const firstSegment = parsed.pathname.replace(/^\/+/, "").split("/")[0];
|
|
319
|
+
return firstSegment || void 0;
|
|
320
|
+
} catch {
|
|
321
|
+
return void 0;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function extractPathFromUrl(url) {
|
|
325
|
+
if (!url) return void 0;
|
|
326
|
+
const s3Match = S3_URL_PATTERN.exec(url);
|
|
327
|
+
if (s3Match) {
|
|
328
|
+
return s3Match[2];
|
|
329
|
+
}
|
|
330
|
+
try {
|
|
331
|
+
const parsed = new URL(url);
|
|
332
|
+
const [, ...rest] = parsed.pathname.replace(/^\/+/, "").split("/");
|
|
333
|
+
return rest.length ? rest.join("/") : void 0;
|
|
334
|
+
} catch {
|
|
335
|
+
return void 0;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
function buildAssetDeliveryUrl(baseUrl, workspace, path, fallback) {
|
|
339
|
+
const sanitizedBase = sanitizeBaseUrl(baseUrl);
|
|
340
|
+
if (!sanitizedBase || !workspace || !path) {
|
|
341
|
+
return fallback;
|
|
342
|
+
}
|
|
343
|
+
const normalizedPath = path.split("/").filter(Boolean).map((segment) => encodeURIComponent(segment)).join("/");
|
|
344
|
+
return `${sanitizedBase}/${workspace}/${normalizedPath}`.replace(/([^:]\/)\/+/g, "$1");
|
|
345
|
+
}
|
|
4182
346
|
|
|
4183
347
|
// src/core/uploader-controller.ts
|
|
4184
348
|
var DEFAULT_PARALLEL_UPLOADS = 4;
|
|
4185
349
|
var MAX_FILE_SIZE_BYTES = 100 * 1024 * 1024;
|
|
350
|
+
var MIME_TYPE_BY_EXTENSION = {
|
|
351
|
+
jpg: "image/jpeg",
|
|
352
|
+
jpeg: "image/jpeg",
|
|
353
|
+
png: "image/png",
|
|
354
|
+
gif: "image/gif",
|
|
355
|
+
webp: "image/webp",
|
|
356
|
+
avif: "image/avif",
|
|
357
|
+
svg: "image/svg+xml",
|
|
358
|
+
mp4: "video/mp4",
|
|
359
|
+
mov: "video/quicktime",
|
|
360
|
+
webm: "video/webm",
|
|
361
|
+
mp3: "audio/mpeg",
|
|
362
|
+
wav: "audio/wav",
|
|
363
|
+
pdf: "application/pdf"
|
|
364
|
+
};
|
|
365
|
+
function inferMimeType(file) {
|
|
366
|
+
if (file.type && file.type !== "application/octet-stream") {
|
|
367
|
+
return file.type;
|
|
368
|
+
}
|
|
369
|
+
const extension = file.name.split(".").pop()?.toLowerCase();
|
|
370
|
+
if (extension && MIME_TYPE_BY_EXTENSION[extension]) {
|
|
371
|
+
return MIME_TYPE_BY_EXTENSION[extension];
|
|
372
|
+
}
|
|
373
|
+
return "application/octet-stream";
|
|
374
|
+
}
|
|
4186
375
|
var UploaderController = class extends EventTarget {
|
|
4187
376
|
constructor(client, target, options) {
|
|
4188
377
|
super();
|
|
@@ -4228,29 +417,11 @@ var UploaderController = class extends EventTarget {
|
|
|
4228
417
|
this.items.forEach((item) => {
|
|
4229
418
|
existingKeys.set(buildKey(item.file, item.folderPath, item.relativePath), item);
|
|
4230
419
|
});
|
|
4231
|
-
const filesWithMimeType =
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
const detected = await fileTypeFromBlob(file);
|
|
4237
|
-
if (detected?.mime) {
|
|
4238
|
-
mimeType = detected.mime;
|
|
4239
|
-
Object.defineProperty(file, "type", {
|
|
4240
|
-
value: mimeType,
|
|
4241
|
-
writable: false,
|
|
4242
|
-
configurable: true
|
|
4243
|
-
});
|
|
4244
|
-
} else {
|
|
4245
|
-
mimeType = "application/octet-stream";
|
|
4246
|
-
}
|
|
4247
|
-
} catch (error) {
|
|
4248
|
-
mimeType = "application/octet-stream";
|
|
4249
|
-
}
|
|
4250
|
-
}
|
|
4251
|
-
return { file, relativePath, mimeType };
|
|
4252
|
-
})
|
|
4253
|
-
);
|
|
420
|
+
const filesWithMimeType = files.map(({ file, relativePath }) => ({
|
|
421
|
+
file,
|
|
422
|
+
relativePath,
|
|
423
|
+
mimeType: inferMimeType(file)
|
|
424
|
+
}));
|
|
4254
425
|
const newItems = filesWithMimeType.map(({ file, relativePath, mimeType }) => {
|
|
4255
426
|
const folderPath = getRelativeFolderPath(
|
|
4256
427
|
this.options.folderPath,
|
|
@@ -7292,7 +3463,7 @@ function parseMinVWFromSizes(sizes) {
|
|
|
7292
3463
|
const vwValues = vwMatches.map((m) => parseFloat(m));
|
|
7293
3464
|
return Math.min(...vwValues);
|
|
7294
3465
|
}
|
|
7295
|
-
function generateResponsiveAttributes(baseUrl, workspace, options, defaults, deviceBreakpoints = DEFAULT_DEVICE_BREAKPOINTS,
|
|
3466
|
+
function generateResponsiveAttributes(baseUrl, workspace, options, defaults, deviceBreakpoints = DEFAULT_DEVICE_BREAKPOINTS, _imageBreakpoints = DEFAULT_IMAGE_BREAKPOINTS, enableDPR = true) {
|
|
7296
3467
|
const { src, width, sizes, transform, breakpoints } = options;
|
|
7297
3468
|
const effectiveBreakpoints = breakpoints || deviceBreakpoints;
|
|
7298
3469
|
if (width !== void 0 && !sizes) {
|
|
@@ -7323,10 +3494,8 @@ function generateResponsiveAttributes(baseUrl, workspace, options, defaults, dev
|
|
|
7323
3494
|
};
|
|
7324
3495
|
}
|
|
7325
3496
|
if (sizes) {
|
|
7326
|
-
|
|
7327
|
-
const filteredBreakpoints = effectiveBreakpoints
|
|
7328
|
-
return true;
|
|
7329
|
-
});
|
|
3497
|
+
void parseMinVWFromSizes(sizes);
|
|
3498
|
+
const filteredBreakpoints = effectiveBreakpoints;
|
|
7330
3499
|
const srcSetParts2 = filteredBreakpoints.map((bp) => {
|
|
7331
3500
|
const transformWithWidth = {
|
|
7332
3501
|
...transform,
|
|
@@ -7696,9 +3865,4 @@ export {
|
|
|
7696
3865
|
registerAutorenderUploaderElement,
|
|
7697
3866
|
resetFormatCache
|
|
7698
3867
|
};
|
|
7699
|
-
/*! Bundled license information:
|
|
7700
|
-
|
|
7701
|
-
ieee754/index.js:
|
|
7702
|
-
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
7703
|
-
*/
|
|
7704
3868
|
//# sourceMappingURL=index.js.map
|