file-type 16.1.0 → 16.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core.d.ts +4 -2
- package/core.js +13 -12
- package/package.json +3 -2
- package/readme.md +1 -0
- package/supported.js +4 -2
package/core.d.ts
CHANGED
|
@@ -136,7 +136,8 @@ declare namespace core {
|
|
|
136
136
|
| 'pgp'
|
|
137
137
|
| 'asar'
|
|
138
138
|
| 'stl'
|
|
139
|
-
| 'chm'
|
|
139
|
+
| 'chm'
|
|
140
|
+
| '3mf';
|
|
140
141
|
|
|
141
142
|
type MimeType =
|
|
142
143
|
| 'image/jpeg'
|
|
@@ -266,7 +267,8 @@ declare namespace core {
|
|
|
266
267
|
| 'application/pgp-encrypted'
|
|
267
268
|
| 'application/x-asar'
|
|
268
269
|
| 'model/stl'
|
|
269
|
-
| 'application/vnd.ms-htmlhelp'
|
|
270
|
+
| 'application/vnd.ms-htmlhelp'
|
|
271
|
+
| 'model/3mf';
|
|
270
272
|
|
|
271
273
|
interface FileTypeResult {
|
|
272
274
|
/**
|
package/core.js
CHANGED
|
@@ -55,15 +55,6 @@ function _check(buffer, headers, options) {
|
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
async function _checkSequence(sequence, tokenizer, ignoreBytes) {
|
|
59
|
-
const buffer = Buffer.alloc(minimumBytes);
|
|
60
|
-
await tokenizer.ignore(ignoreBytes);
|
|
61
|
-
|
|
62
|
-
await tokenizer.peekBuffer(buffer, {mayBeLess: true});
|
|
63
|
-
|
|
64
|
-
return buffer.includes(Buffer.from(sequence));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
58
|
async function fromTokenizer(tokenizer) {
|
|
68
59
|
try {
|
|
69
60
|
return _fromTokenizer(tokenizer);
|
|
@@ -79,7 +70,6 @@ async function _fromTokenizer(tokenizer) {
|
|
|
79
70
|
const bytesRead = 12;
|
|
80
71
|
const check = (header, options) => _check(buffer, header, options);
|
|
81
72
|
const checkString = (header, options) => check(stringToBytes(header), options);
|
|
82
|
-
const checkSequence = (sequence, ignoreBytes) => _checkSequence(sequence, tokenizer, ignoreBytes);
|
|
83
73
|
|
|
84
74
|
// Keep reading until EOF if the file size is unknown.
|
|
85
75
|
if (!tokenizer.fileInfo.size) {
|
|
@@ -318,6 +308,13 @@ async function _fromTokenizer(tokenizer) {
|
|
|
318
308
|
};
|
|
319
309
|
}
|
|
320
310
|
|
|
311
|
+
if (zipHeader.filename.startsWith('3D/') && zipHeader.filename.endsWith('.model')) {
|
|
312
|
+
return {
|
|
313
|
+
ext: '3mf',
|
|
314
|
+
mime: 'model/3mf'
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
321
318
|
// The docx, xlsx and pptx file types extend the Office Open XML file format:
|
|
322
319
|
// https://en.wikipedia.org/wiki/Office_Open_XML_file_formats
|
|
323
320
|
// We look for:
|
|
@@ -589,9 +586,13 @@ async function _fromTokenizer(tokenizer) {
|
|
|
589
586
|
}
|
|
590
587
|
|
|
591
588
|
if (checkString('%PDF')) {
|
|
589
|
+
await tokenizer.ignore(1350);
|
|
590
|
+
const maxBufferSize = 10 * 1024 * 1024;
|
|
591
|
+
const buffer = Buffer.alloc(Math.min(maxBufferSize, tokenizer.fileInfo.size));
|
|
592
|
+
await tokenizer.readBuffer(buffer, {mayBeLess: true});
|
|
593
|
+
|
|
592
594
|
// Check if this is an Adobe Illustrator file
|
|
593
|
-
|
|
594
|
-
if (isAiFile) {
|
|
595
|
+
if (buffer.includes(Buffer.from('AIPrivateData'))) {
|
|
595
596
|
return {
|
|
596
597
|
ext: 'ai',
|
|
597
598
|
mime: 'application/postscript'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "file-type",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.2.0",
|
|
4
4
|
"description": "Detect the file type of a Buffer/Uint8Array/ArrayBuffer",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "sindresorhus/file-type",
|
|
@@ -180,7 +180,8 @@
|
|
|
180
180
|
"pgp",
|
|
181
181
|
"asar",
|
|
182
182
|
"stl",
|
|
183
|
-
"chm"
|
|
183
|
+
"chm",
|
|
184
|
+
"3mf"
|
|
184
185
|
],
|
|
185
186
|
"devDependencies": {
|
|
186
187
|
"@types/node": "^13.1.4",
|
package/readme.md
CHANGED
|
@@ -405,6 +405,7 @@ Returns a set of supported MIME types.
|
|
|
405
405
|
- [`asar`](https://github.com/electron/asar#format) - Archive format primarily used to enclose Electron applications
|
|
406
406
|
- [`stl`](https://en.wikipedia.org/wiki/STL_(file_format)) - Standard Tesselated Geometry File Format (ASCII only)
|
|
407
407
|
- [`chm`](https://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help) - Microsoft Compiled HTML Help
|
|
408
|
+
- [`3mf`](https://en.wikipedia.org/wiki/3D_Manufacturing_Format) - 3D Manufacturing Format
|
|
408
409
|
|
|
409
410
|
*Pull requests are welcome for additional commonly used file types.*
|
|
410
411
|
|
package/supported.js
CHANGED
|
@@ -134,7 +134,8 @@ module.exports = {
|
|
|
134
134
|
'pgp',
|
|
135
135
|
'asar',
|
|
136
136
|
'stl',
|
|
137
|
-
'chm'
|
|
137
|
+
'chm',
|
|
138
|
+
'3mf'
|
|
138
139
|
],
|
|
139
140
|
mimeTypes: [
|
|
140
141
|
'image/jpeg',
|
|
@@ -264,6 +265,7 @@ module.exports = {
|
|
|
264
265
|
'application/pgp-encrypted',
|
|
265
266
|
'application/x-asar',
|
|
266
267
|
'model/stl',
|
|
267
|
-
'application/vnd.ms-htmlhelp'
|
|
268
|
+
'application/vnd.ms-htmlhelp',
|
|
269
|
+
'model/3mf'
|
|
268
270
|
]
|
|
269
271
|
};
|