file-type 16.3.0 → 16.4.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 CHANGED
@@ -10,6 +10,7 @@ declare namespace core {
10
10
  | 'gif'
11
11
  | 'webp'
12
12
  | 'flif'
13
+ | 'xcf'
13
14
  | 'cr2'
14
15
  | 'cr3'
15
16
  | 'orf'
@@ -138,7 +139,8 @@ declare namespace core {
138
139
  | 'stl'
139
140
  | 'chm'
140
141
  | '3mf'
141
- | 'zst';
142
+ | 'zst'
143
+ | 'vcf';
142
144
 
143
145
  type MimeType =
144
146
  | 'image/jpeg'
@@ -146,6 +148,7 @@ declare namespace core {
146
148
  | 'image/gif'
147
149
  | 'image/webp'
148
150
  | 'image/flif'
151
+ | 'image/x-xcf'
149
152
  | 'image/x-canon-cr2'
150
153
  | 'image/x-canon-cr3'
151
154
  | 'image/tiff'
@@ -238,6 +241,7 @@ declare namespace core {
238
241
  | 'application/dicom'
239
242
  | 'audio/x-musepack'
240
243
  | 'text/calendar'
244
+ | 'text/vcard'
241
245
  | 'model/gltf-binary'
242
246
  | 'application/vnd.tcpdump.pcap'
243
247
  | 'audio/x-dsf' // Non-standard
package/core.js CHANGED
@@ -911,13 +911,6 @@ async function _fromTokenizer(tokenizer) {
911
911
  };
912
912
  }
913
913
 
914
- if (checkString('BEGIN:')) {
915
- return {
916
- ext: 'ics',
917
- mime: 'text/calendar'
918
- };
919
- }
920
-
921
914
  if (check([0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C])) {
922
915
  return {
923
916
  ext: '7z',
@@ -1051,6 +1044,13 @@ async function _fromTokenizer(tokenizer) {
1051
1044
  };
1052
1045
  }
1053
1046
 
1047
+ if (checkString('gimp xcf ')) {
1048
+ return {
1049
+ ext: 'xcf',
1050
+ mime: 'image/x-xcf'
1051
+ };
1052
+ }
1053
+
1054
1054
  // -- 12-byte signatures --
1055
1055
 
1056
1056
  if (check([0x49, 0x49, 0x55, 0x00, 0x18, 0x00, 0x00, 0x00, 0x88, 0xE7, 0x74, 0xD8])) {
@@ -1206,6 +1206,24 @@ async function _fromTokenizer(tokenizer) {
1206
1206
  // Increase sample size from 12 to 256.
1207
1207
  await tokenizer.peekBuffer(buffer, {length: Math.min(256, tokenizer.fileInfo.size), mayBeLess: true});
1208
1208
 
1209
+ // -- 15-byte signatures --
1210
+
1211
+ if (checkString('BEGIN:')) {
1212
+ if (checkString('VCARD', {offset: 6})) {
1213
+ return {
1214
+ ext: 'vcf',
1215
+ mime: 'text/vcard'
1216
+ };
1217
+ }
1218
+
1219
+ if (checkString('VCALENDAR', {offset: 6})) {
1220
+ return {
1221
+ ext: 'ics',
1222
+ mime: 'text/calendar'
1223
+ };
1224
+ }
1225
+ }
1226
+
1209
1227
  // `raf` is here just to keep all the raw image detectors together.
1210
1228
  if (checkString('FUJIFILMCCD-RAW')) {
1211
1229
  return {
@@ -1341,50 +1359,47 @@ async function _fromTokenizer(tokenizer) {
1341
1359
  };
1342
1360
  }
1343
1361
 
1344
- // Check for MPEG header at different starting offsets
1345
- for (let start = 0; start < 2 && start < (buffer.length - 16); start++) {
1346
- // Check MPEG 1 or 2 Layer 3 header, or 'layer 0' for ADTS (MPEG sync-word 0xFFE)
1347
- if (buffer.length >= start + 2 && check([0xFF, 0xE0], {offset: start, mask: [0xFF, 0xE0]})) {
1348
- if (check([0x10], {offset: start + 1, mask: [0x16]})) {
1349
- // Check for (ADTS) MPEG-2
1350
- if (check([0x08], {offset: start + 1, mask: [0x08]})) {
1351
- return {
1352
- ext: 'aac',
1353
- mime: 'audio/aac'
1354
- };
1355
- }
1356
-
1357
- // Must be (ADTS) MPEG-4
1362
+ // Check MPEG 1 or 2 Layer 3 header, or 'layer 0' for ADTS (MPEG sync-word 0xFFE)
1363
+ if (buffer.length >= 2 && check([0xFF, 0xE0], {offset: 0, mask: [0xFF, 0xE0]})) {
1364
+ if (check([0x10], {offset: 1, mask: [0x16]})) {
1365
+ // Check for (ADTS) MPEG-2
1366
+ if (check([0x08], {offset: 1, mask: [0x08]})) {
1358
1367
  return {
1359
1368
  ext: 'aac',
1360
1369
  mime: 'audio/aac'
1361
1370
  };
1362
1371
  }
1363
1372
 
1364
- // MPEG 1 or 2 Layer 3 header
1365
- // Check for MPEG layer 3
1366
- if (check([0x02], {offset: start + 1, mask: [0x06]})) {
1367
- return {
1368
- ext: 'mp3',
1369
- mime: 'audio/mpeg'
1370
- };
1371
- }
1373
+ // Must be (ADTS) MPEG-4
1374
+ return {
1375
+ ext: 'aac',
1376
+ mime: 'audio/aac'
1377
+ };
1378
+ }
1372
1379
 
1373
- // Check for MPEG layer 2
1374
- if (check([0x04], {offset: start + 1, mask: [0x06]})) {
1375
- return {
1376
- ext: 'mp2',
1377
- mime: 'audio/mpeg'
1378
- };
1379
- }
1380
+ // MPEG 1 or 2 Layer 3 header
1381
+ // Check for MPEG layer 3
1382
+ if (check([0x02], {offset: 1, mask: [0x06]})) {
1383
+ return {
1384
+ ext: 'mp3',
1385
+ mime: 'audio/mpeg'
1386
+ };
1387
+ }
1380
1388
 
1381
- // Check for MPEG layer 1
1382
- if (check([0x06], {offset: start + 1, mask: [0x06]})) {
1383
- return {
1384
- ext: 'mp1',
1385
- mime: 'audio/mpeg'
1386
- };
1387
- }
1389
+ // Check for MPEG layer 2
1390
+ if (check([0x04], {offset: 1, mask: [0x06]})) {
1391
+ return {
1392
+ ext: 'mp2',
1393
+ mime: 'audio/mpeg'
1394
+ };
1395
+ }
1396
+
1397
+ // Check for MPEG layer 1
1398
+ if (check([0x06], {offset: 1, mask: [0x06]})) {
1399
+ return {
1400
+ ext: 'mp1',
1401
+ mime: 'audio/mpeg'
1402
+ };
1388
1403
  }
1389
1404
  }
1390
1405
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "file-type",
3
- "version": "16.3.0",
3
+ "version": "16.4.0",
4
4
  "description": "Detect the file type of a Buffer/Uint8Array/ArrayBuffer",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/file-type",
@@ -54,6 +54,7 @@
54
54
  "gif",
55
55
  "webp",
56
56
  "flif",
57
+ "xcf",
57
58
  "cr2",
58
59
  "cr3",
59
60
  "orf",
@@ -182,7 +183,8 @@
182
183
  "stl",
183
184
  "chm",
184
185
  "3mf",
185
- "zst"
186
+ "zst",
187
+ "vcf"
186
188
  ],
187
189
  "devDependencies": {
188
190
  "@types/node": "^13.1.4",
package/readme.md CHANGED
@@ -278,6 +278,7 @@ Returns a set of supported MIME types.
278
278
  - [`gif`](https://en.wikipedia.org/wiki/GIF) - Graphics Interchange Format
279
279
  - [`webp`](https://en.wikipedia.org/wiki/WebP) - Web Picture format
280
280
  - [`flif`](https://en.wikipedia.org/wiki/Free_Lossless_Image_Format) - Free Lossless Image Format
281
+ - [`xcf`](https://en.wikipedia.org/wiki/XCF_(file_format)) - eXperimental Computing Facility
281
282
  - [`cr2`](https://fileinfo.com/extension/cr2) - Canon Raw image file (v2)
282
283
  - [`cr3`](https://fileinfo.com/extension/cr3) - Canon Raw image file (v3)
283
284
  - [`orf`](https://en.wikipedia.org/wiki/ORF_format) - Olympus Raw image file
@@ -373,6 +374,7 @@ Returns a set of supported MIME types.
373
374
  - [`dcm`](https://en.wikipedia.org/wiki/DICOM#Data_format) - DICOM Image File
374
375
  - [`mpc`](https://en.wikipedia.org/wiki/Musepack) - Musepack (SV7 & SV8)
375
376
  - [`ics`](https://en.wikipedia.org/wiki/ICalendar#Data_format) - iCalendar
377
+ - [`vcf`](https://en.wikipedia.org/wiki/VCard) - vCard
376
378
  - [`glb`](https://github.com/KhronosGroup/glTF) - GL Transmission Format
377
379
  - [`pcap`](https://wiki.wireshark.org/Development/LibpcapFileFormat) - Libpcap File Format
378
380
  - [`dsf`](https://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf) - Sony DSD Stream File (DSF)
package/supported.js CHANGED
@@ -8,6 +8,7 @@ module.exports = {
8
8
  'gif',
9
9
  'webp',
10
10
  'flif',
11
+ 'xcf',
11
12
  'cr2',
12
13
  'cr3',
13
14
  'orf',
@@ -136,7 +137,8 @@ module.exports = {
136
137
  'stl',
137
138
  'chm',
138
139
  '3mf',
139
- 'zst'
140
+ 'zst',
141
+ 'vcf'
140
142
  ],
141
143
  mimeTypes: [
142
144
  'image/jpeg',
@@ -144,6 +146,7 @@ module.exports = {
144
146
  'image/gif',
145
147
  'image/webp',
146
148
  'image/flif',
149
+ 'image/x-xcf',
147
150
  'image/x-canon-cr2',
148
151
  'image/x-canon-cr3',
149
152
  'image/tiff',
@@ -236,6 +239,7 @@ module.exports = {
236
239
  'application/dicom',
237
240
  'audio/x-musepack',
238
241
  'text/calendar',
242
+ 'text/vcard',
239
243
  'model/gltf-binary',
240
244
  'application/vnd.tcpdump.pcap',
241
245
  'audio/x-dsf', // Non-standard