exifreader 4.44.1 → 4.45.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/README.md +4 -4
- package/bin/parse-config.js +78 -0
- package/dist/exif-reader.js +1 -1
- package/dist/exif-reader.js.map +1 -1
- package/package.json +1 -1
- package/src/exif-reader.js +37 -8
- package/src/icc-tags.js +4 -2
- package/src/image-header-jpeg.js +11 -6
- package/src/jfif-tags.js +2 -1
- package/src/loadview-pipeline.js +9 -4
- package/src/mpf-tags.js +5 -2
- package/src/png-text-tags.js +2 -1
- package/src/tag-names.js +4 -4
- package/src/thumbnail.js +24 -5
- package/src/utils.js +7 -4
- package/src/xmp-tags.js +5 -2
- package/webpack.config.js +1 -53
package/package.json
CHANGED
package/src/exif-reader.js
CHANGED
|
@@ -92,6 +92,8 @@ export function loadView(
|
|
|
92
92
|
decompress: decompressConfig = undefined
|
|
93
93
|
} = {}
|
|
94
94
|
) {
|
|
95
|
+
dataView = getSelfContainedDataView(dataView);
|
|
96
|
+
|
|
95
97
|
const tagFilter = createTagFilter({includeTags, excludeTags});
|
|
96
98
|
const parsedGroups = Object.create(null);
|
|
97
99
|
const mergeSteps = [];
|
|
@@ -201,8 +203,7 @@ export function loadView(
|
|
|
201
203
|
parsedGroups.exif = parsedExifTags;
|
|
202
204
|
|
|
203
205
|
if (
|
|
204
|
-
Constants.
|
|
205
|
-
&& Constants.USE_IPTC
|
|
206
|
+
Constants.USE_IPTC
|
|
206
207
|
&& parsedExifTags['IPTC-NAA']
|
|
207
208
|
&& iptcDataOffset === undefined
|
|
208
209
|
&& tagFilter.shouldParseGroup('iptc')
|
|
@@ -227,8 +228,7 @@ export function loadView(
|
|
|
227
228
|
}
|
|
228
229
|
|
|
229
230
|
if (
|
|
230
|
-
Constants.
|
|
231
|
-
&& Constants.USE_XMP
|
|
231
|
+
Constants.USE_XMP
|
|
232
232
|
&& parsedExifTags['ApplicationNotes']
|
|
233
233
|
&& Array.isArray(parsedExifTags['ApplicationNotes'].value)
|
|
234
234
|
&& !hasXmpData(xmpChunks)
|
|
@@ -282,8 +282,7 @@ export function loadView(
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
if (
|
|
285
|
-
Constants.
|
|
286
|
-
&& Constants.USE_ICC
|
|
285
|
+
Constants.USE_ICC
|
|
287
286
|
&& parsedExifTags['ICC_Profile']
|
|
288
287
|
&& !hasIccData(iccChunks)
|
|
289
288
|
&& tagFilter.shouldParseGroup('icc')
|
|
@@ -650,7 +649,9 @@ export function loadView(
|
|
|
650
649
|
}
|
|
651
650
|
|
|
652
651
|
mergeSteps.push({type: 'gps'});
|
|
653
|
-
|
|
652
|
+
if (Constants.USE_EXIF || Constants.USE_XMP) {
|
|
653
|
+
mergeSteps.push({type: 'composite'});
|
|
654
|
+
}
|
|
654
655
|
mergeSteps.push({type: 'thumbnail'});
|
|
655
656
|
mergeSteps.push({type: 'fileType'});
|
|
656
657
|
|
|
@@ -672,7 +673,9 @@ export function loadView(
|
|
|
672
673
|
filterTagsForParse,
|
|
673
674
|
filterTagsForReturn,
|
|
674
675
|
getGpsGroupFromExifTags,
|
|
675
|
-
|
|
676
|
+
// A plain property here would keep the import alive for the bundler, so
|
|
677
|
+
// a build with neither Exif nor XMP would still carry composite.js.
|
|
678
|
+
Composite: (Constants.USE_EXIF || Constants.USE_XMP) ? Composite : undefined,
|
|
676
679
|
Thumbnail,
|
|
677
680
|
};
|
|
678
681
|
|
|
@@ -728,6 +731,32 @@ export function loadView(
|
|
|
728
731
|
}
|
|
729
732
|
}
|
|
730
733
|
|
|
734
|
+
// A caller-supplied DataView can be a window into a larger buffer. Extractors
|
|
735
|
+
// slice dataView.buffer, so copy the window out to keep them inside the image.
|
|
736
|
+
function getSelfContainedDataView(dataView) {
|
|
737
|
+
if (isWindowIntoLargerBuffer(dataView)) {
|
|
738
|
+
return getDataView(dataView.buffer.slice(dataView.byteOffset, dataView.byteOffset + dataView.byteLength));
|
|
739
|
+
}
|
|
740
|
+
return dataView;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
function isWindowIntoLargerBuffer(dataView) {
|
|
744
|
+
return isDataViewLike(dataView)
|
|
745
|
+
&& ((dataView.byteOffset > 0) || (dataView.byteLength < dataView.buffer.byteLength));
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
// A DataView from another realm, an iframe for example, fails instanceof, so
|
|
749
|
+
// match on the shape instead. A typed array has no getUint8 and the Node Buffer
|
|
750
|
+
// wrapper has no byteOffset, so neither is treated as a window here.
|
|
751
|
+
function isDataViewLike(dataView) {
|
|
752
|
+
return !!dataView
|
|
753
|
+
&& (typeof dataView.getUint8 === 'function')
|
|
754
|
+
&& (typeof dataView.byteOffset === 'number')
|
|
755
|
+
&& (typeof dataView.byteLength === 'number')
|
|
756
|
+
&& !!dataView.buffer
|
|
757
|
+
&& (typeof dataView.buffer.slice === 'function');
|
|
758
|
+
}
|
|
759
|
+
|
|
731
760
|
function getBrobDataView(dataView, brobChunk) {
|
|
732
761
|
// The box length is untrusted and comes through negative for a box shorter
|
|
733
762
|
// than its header, so bound the view by the bytes present. The JXL header
|
package/src/icc-tags.js
CHANGED
|
@@ -36,7 +36,8 @@ function readCompressedIcc(dataView, iccData, decompressConfig) {
|
|
|
36
36
|
if (!compressionMethodIsSupported(iccData[0].compressionMethod)) {
|
|
37
37
|
return {};
|
|
38
38
|
}
|
|
39
|
-
const
|
|
39
|
+
const byteOffset = dataView.byteOffset || 0;
|
|
40
|
+
const compressedDataView = new DataView(dataView.buffer.slice(byteOffset + iccData[0].offset, byteOffset + iccData[0].offset + iccData[0].length));
|
|
40
41
|
return decompress(compressedDataView, iccData[0].compressionMethod, 'utf-8', 'dataview', decompressConfig)
|
|
41
42
|
.then(parseTags)
|
|
42
43
|
.catch(() => ({}));
|
|
@@ -49,6 +50,7 @@ function compressionMethodIsSupported(compressionMethod) {
|
|
|
49
50
|
function readIcc(dataView, iccData) {
|
|
50
51
|
try {
|
|
51
52
|
const buffer = getBuffer(dataView);
|
|
53
|
+
const byteOffset = dataView.byteOffset || 0;
|
|
52
54
|
const declaredLength = iccData.reduce((sum, icc) => sum + icc.length, 0);
|
|
53
55
|
// The declared chunk lengths come from the file and are not trusted, so
|
|
54
56
|
// bound the profile by the size of the buffer it is copied out of.
|
|
@@ -63,7 +65,7 @@ function readIcc(dataView, iccData) {
|
|
|
63
65
|
throw new Error(`ICC chunk ${chunkNumber} not found`);
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
const data = buffer.slice(iccDataChunk.offset, iccDataChunk.offset + iccDataChunk.length);
|
|
68
|
+
const data = buffer.slice(byteOffset + iccDataChunk.offset, byteOffset + iccDataChunk.offset + iccDataChunk.length);
|
|
67
69
|
const chunkData = new Uint8Array(data);
|
|
68
70
|
|
|
69
71
|
iccBinaryData.set(chunkData, offset);
|
package/src/image-header-jpeg.js
CHANGED
|
@@ -37,6 +37,9 @@ const MPF_DATA_OFFSET = 8;
|
|
|
37
37
|
const APP2_ICC_IDENTIFIER = 'ICC_PROFILE\0';
|
|
38
38
|
const ICC_CHUNK_NUMBER_OFFSET = APP_ID_OFFSET + APP2_ICC_IDENTIFIER.length;
|
|
39
39
|
const ICC_TOTAL_CHUNKS_OFFSET = ICC_CHUNK_NUMBER_OFFSET + 1;
|
|
40
|
+
// Guards against memory exhaustion from a crafted file. Both chunk fields are a
|
|
41
|
+
// single byte, so a longer list could never be assembled into a profile anyway.
|
|
42
|
+
const MAX_ICC_CHUNKS = 255;
|
|
40
43
|
|
|
41
44
|
const APP2_MPF_IDENTIFIER = 'MPF\0';
|
|
42
45
|
|
|
@@ -180,15 +183,17 @@ function findJpegOffsets(dataView, metadataBlocks) {
|
|
|
180
183
|
blockType = 'iptc';
|
|
181
184
|
} else if (Constants.USE_ICC && isApp2ICCMarker(dataView, appMarkerPosition)) {
|
|
182
185
|
fieldLength = dataView.getUint16(appMarkerPosition + APP_MARKER_SIZE);
|
|
183
|
-
const iccDataOffset = appMarkerPosition + APP2_ICC_DATA_OFFSET;
|
|
184
|
-
const iccDataLength = fieldLength - (APP2_ICC_DATA_OFFSET - APP_MARKER_SIZE);
|
|
185
|
-
|
|
186
|
-
const iccChunkNumber = dataView.getUint8(appMarkerPosition + ICC_CHUNK_NUMBER_OFFSET);
|
|
187
|
-
const iccChunksTotal = dataView.getUint8(appMarkerPosition + ICC_TOTAL_CHUNKS_OFFSET);
|
|
188
186
|
if (!iccChunks) {
|
|
189
187
|
iccChunks = [];
|
|
190
188
|
}
|
|
191
|
-
iccChunks.
|
|
189
|
+
if (iccChunks.length < MAX_ICC_CHUNKS) {
|
|
190
|
+
const iccDataOffset = appMarkerPosition + APP2_ICC_DATA_OFFSET;
|
|
191
|
+
const iccDataLength = fieldLength - (APP2_ICC_DATA_OFFSET - APP_MARKER_SIZE);
|
|
192
|
+
|
|
193
|
+
const iccChunkNumber = dataView.getUint8(appMarkerPosition + ICC_CHUNK_NUMBER_OFFSET);
|
|
194
|
+
const iccChunksTotal = dataView.getUint8(appMarkerPosition + ICC_TOTAL_CHUNKS_OFFSET);
|
|
195
|
+
iccChunks.push({offset: iccDataOffset, length: iccDataLength, chunkNumber: iccChunkNumber, chunksTotal: iccChunksTotal});
|
|
196
|
+
}
|
|
192
197
|
blockType = 'icc';
|
|
193
198
|
} else if (Constants.USE_MPF && isApp2MPFMarker(dataView, appMarkerPosition)) {
|
|
194
199
|
fieldLength = dataView.getUint16(appMarkerPosition + APP_MARKER_SIZE);
|
package/src/jfif-tags.js
CHANGED
|
@@ -153,7 +153,8 @@ function getThumbnail(dataView, jfifDataOffset, thumbnailLength, length) {
|
|
|
153
153
|
return undefined;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
const
|
|
156
|
+
const byteOffset = dataView.byteOffset || 0;
|
|
157
|
+
const value = dataView.buffer.slice(byteOffset + jfifDataOffset + OFFSET, byteOffset + jfifDataOffset + OFFSET + thumbnailLength);
|
|
157
158
|
return {
|
|
158
159
|
value,
|
|
159
160
|
description: '<24-bit RGB pixel data>'
|
package/src/loadview-pipeline.js
CHANGED
|
@@ -239,7 +239,7 @@ export function applyMergeStep({
|
|
|
239
239
|
return tags;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
if (step.type === 'composite') {
|
|
242
|
+
if ((Constants.USE_EXIF || Constants.USE_XMP) && step.type === 'composite') {
|
|
243
243
|
if (!tagFilter.shouldReturnGroup('composite')) {
|
|
244
244
|
return tags;
|
|
245
245
|
}
|
|
@@ -291,8 +291,7 @@ export function applyMergeStep({
|
|
|
291
291
|
parsedGroups.thumbnail = parsedThumbnailIfdTags;
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
const thumbnail =
|
|
295
|
-
&& Constants.USE_EXIF
|
|
294
|
+
const thumbnail = Constants.USE_EXIF
|
|
296
295
|
&& Constants.USE_THUMBNAIL
|
|
297
296
|
&& deps.Thumbnail.get(exifDataView || dataView, parsedThumbnailIfdTags, tiffHeaderOffset);
|
|
298
297
|
if (thumbnail) {
|
|
@@ -414,7 +413,13 @@ export function addPngTextReadTagsToTagsAndGroups({
|
|
|
414
413
|
returnedEmbeddedExifTags
|
|
415
414
|
);
|
|
416
415
|
} else {
|
|
417
|
-
|
|
416
|
+
// The thumbnail image is never read from a text chunk, so the
|
|
417
|
+
// thumbnail IFD would land at the top level with no image.
|
|
418
|
+
const returnedEmbeddedExifTagsForFlat =
|
|
419
|
+
deps.objectAssign({}, returnedEmbeddedExifTags);
|
|
420
|
+
delete returnedEmbeddedExifTagsForFlat.Thumbnail;
|
|
421
|
+
|
|
422
|
+
tags = deps.objectAssign({}, tags, returnedEmbeddedExifTagsForFlat);
|
|
418
423
|
}
|
|
419
424
|
}
|
|
420
425
|
}
|
package/src/mpf-tags.js
CHANGED
|
@@ -55,7 +55,10 @@ function addMpfImages(dataView, dataOffset, tags, byteOrder) {
|
|
|
55
55
|
return tags;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
// The bound is the view's own extent, not the buffer's, since the slice
|
|
59
|
+
// starts at the view's byteOffset.
|
|
60
|
+
const bufferLength = dataView.byteLength;
|
|
61
|
+
const byteOffset = dataView.byteOffset || 0;
|
|
59
62
|
let remainingImageBytes = bufferLength * MAX_IMAGE_SIZE_PER_BUFFER_SIZE;
|
|
60
63
|
const images = [];
|
|
61
64
|
for (let i = 0; i < Math.ceil(tags['MPEntry'].value.length / ENTRY_SIZE); i++) {
|
|
@@ -94,7 +97,7 @@ function addMpfImages(dataView, dataOffset, tags, byteOrder) {
|
|
|
94
97
|
|
|
95
98
|
const start = Math.min(Math.max(imageOffset, 0), bufferLength);
|
|
96
99
|
const end = Math.min(start + Math.max(imageSize, 0), bufferLength, start + remainingImageBytes);
|
|
97
|
-
images[i].image = dataView.buffer.slice(start, end);
|
|
100
|
+
images[i].image = dataView.buffer.slice(byteOffset + start, byteOffset + end);
|
|
98
101
|
remainingImageBytes -= end - start;
|
|
99
102
|
deferInit(images[i], 'base64', function () {
|
|
100
103
|
return getBase64Image(this.image);
|
package/src/png-text-tags.js
CHANGED
|
@@ -108,6 +108,7 @@ function getNameAndValue(dataView, offset, length, type, async, decompressConfig
|
|
|
108
108
|
let valueChars;
|
|
109
109
|
let parsingState = STATE_KEYWORD;
|
|
110
110
|
let compressionMethod = COMPRESSION_METHOD_NONE;
|
|
111
|
+
const byteOffset = dataView.byteOffset || 0;
|
|
111
112
|
|
|
112
113
|
for (let i = 0; i < length && offset + i < dataView.byteLength; i++) {
|
|
113
114
|
if (parsingState === STATE_COMPRESSION) {
|
|
@@ -118,7 +119,7 @@ function getNameAndValue(dataView, offset, length, type, async, decompressConfig
|
|
|
118
119
|
parsingState = moveToNextState(type, parsingState);
|
|
119
120
|
continue;
|
|
120
121
|
} else if (parsingState === STATE_TEXT) {
|
|
121
|
-
valueChars = new DataView(dataView.buffer.slice(offset + i, offset + length));
|
|
122
|
+
valueChars = new DataView(dataView.buffer.slice(byteOffset + offset + i, byteOffset + offset + length));
|
|
122
123
|
break;
|
|
123
124
|
}
|
|
124
125
|
const byte = dataView.getUint8(offset + i);
|
package/src/tag-names.js
CHANGED
|
@@ -12,7 +12,7 @@ import TagNamesMpfIfd from './tag-names-mpf-ifd.js';
|
|
|
12
12
|
import TagNamesCanonIfd from './tag-names-canon-ifd.js';
|
|
13
13
|
import TagNamesPentaxIfd from './tag-names-pentax-ifd.js';
|
|
14
14
|
|
|
15
|
-
const tagNames0thExifIfds = objectAssign({}, TagNames0thIfd, TagNamesExifIfd);
|
|
15
|
+
const tagNames0thExifIfds = Constants.USE_EXIF ? objectAssign({}, TagNames0thIfd, TagNamesExifIfd) : {};
|
|
16
16
|
|
|
17
17
|
export const IFD_TYPE_0TH = '0th';
|
|
18
18
|
export const IFD_TYPE_1ST = '1st';
|
|
@@ -25,10 +25,10 @@ export const IFD_TYPE_PENTAX = 'pentax';
|
|
|
25
25
|
|
|
26
26
|
export default {
|
|
27
27
|
[IFD_TYPE_0TH]: tagNames0thExifIfds,
|
|
28
|
-
[IFD_TYPE_1ST]: TagNames0thIfd,
|
|
28
|
+
[IFD_TYPE_1ST]: Constants.USE_EXIF ? TagNames0thIfd : {},
|
|
29
29
|
[IFD_TYPE_EXIF]: tagNames0thExifIfds,
|
|
30
|
-
[IFD_TYPE_GPS]: TagNamesGpsIfd,
|
|
31
|
-
[IFD_TYPE_INTEROPERABILITY]: TagNamesInteroperabilityIfd,
|
|
30
|
+
[IFD_TYPE_GPS]: Constants.USE_EXIF ? TagNamesGpsIfd : {},
|
|
31
|
+
[IFD_TYPE_INTEROPERABILITY]: Constants.USE_EXIF ? TagNamesInteroperabilityIfd : {},
|
|
32
32
|
[IFD_TYPE_MPF]: Constants.USE_MPF ? TagNamesMpfIfd : {},
|
|
33
33
|
[IFD_TYPE_CANON]: Constants.USE_MAKER_NOTES ? TagNamesCanonIfd : {},
|
|
34
34
|
[IFD_TYPE_PENTAX]: Constants.USE_MAKER_NOTES ? TagNamesPentaxIfd : {},
|
package/src/thumbnail.js
CHANGED
|
@@ -13,12 +13,17 @@ export default {
|
|
|
13
13
|
|
|
14
14
|
function get(dataView, thumbnailTags, tiffHeaderOffset) {
|
|
15
15
|
if (hasJpegThumbnail(thumbnailTags)) {
|
|
16
|
-
thumbnailTags.type = 'image/jpeg';
|
|
17
16
|
const offset = tiffHeaderOffset + thumbnailTags.JPEGInterchangeFormat.value;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const length = thumbnailTags.JPEGInterchangeFormatLength.value;
|
|
18
|
+
|
|
19
|
+
if (fitsInDataView(dataView, offset, length)) {
|
|
20
|
+
thumbnailTags.type = 'image/jpeg';
|
|
21
|
+
const byteOffset = dataView.byteOffset || 0;
|
|
22
|
+
thumbnailTags.image = dataView.buffer.slice(byteOffset + offset, byteOffset + offset + length);
|
|
23
|
+
deferInit(thumbnailTags, 'base64', function () {
|
|
24
|
+
return getBase64Image(this.image);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
// There is a small possibility of thumbnails in TIFF format but they are
|
|
@@ -34,3 +39,17 @@ function hasJpegThumbnail(tags) {
|
|
|
34
39
|
&& tags.JPEGInterchangeFormat && tags.JPEGInterchangeFormat.value
|
|
35
40
|
&& tags.JPEGInterchangeFormatLength && tags.JPEGInterchangeFormatLength.value;
|
|
36
41
|
}
|
|
42
|
+
|
|
43
|
+
// The file declares the offset and the length, and slicing clamps a bad range
|
|
44
|
+
// instead of throwing, reading a negative start from the end of the buffer. The
|
|
45
|
+
// bound is the view's own extent, not the buffer's, since the slice starts at
|
|
46
|
+
// the view's byteOffset.
|
|
47
|
+
function fitsInDataView(dataView, offset, length) {
|
|
48
|
+
return isNonNegativeInteger(offset)
|
|
49
|
+
&& isNonNegativeInteger(length)
|
|
50
|
+
&& (offset + length <= dataView.byteLength);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function isNonNegativeInteger(value) {
|
|
54
|
+
return (typeof value === 'number') && (value >= 0) && (value % 1 === 0);
|
|
55
|
+
}
|
package/src/utils.js
CHANGED
|
@@ -196,13 +196,16 @@ export function decompress(dataView, compressionMethod, encoding, returnType = '
|
|
|
196
196
|
return rejectExceedsMax(maxDecompressedSize);
|
|
197
197
|
}
|
|
198
198
|
if (returnType === 'dataview') {
|
|
199
|
-
if (result instanceof DataView) {
|
|
200
|
-
return result;
|
|
201
|
-
}
|
|
202
199
|
if (result instanceof ArrayBuffer) {
|
|
203
200
|
return new DataView(result);
|
|
204
201
|
}
|
|
205
|
-
|
|
202
|
+
// A DataView or a pooled Buffer can be a window into a
|
|
203
|
+
// larger buffer, and parsers slice dataView.buffer, so
|
|
204
|
+
// copy a window out but keep a whole buffer as it is.
|
|
205
|
+
if ((result.byteOffset === 0) && (result.byteLength === result.buffer.byteLength)) {
|
|
206
|
+
return new DataView(result.buffer);
|
|
207
|
+
}
|
|
208
|
+
return new DataView(result.buffer.slice(result.byteOffset, result.byteOffset + result.byteLength));
|
|
206
209
|
}
|
|
207
210
|
return new TextDecoder(encoding).decode(result);
|
|
208
211
|
});
|
package/src/xmp-tags.js
CHANGED
|
@@ -79,10 +79,13 @@ function combineChunks(dataView, chunks) {
|
|
|
79
79
|
// A chunk length comes verbatim from the image and is not trusted. Bound it to
|
|
80
80
|
// the bytes actually present so a crafted length cannot force a huge allocation.
|
|
81
81
|
function getBoundedChunkBytes(dataView, chunk) {
|
|
82
|
-
|
|
82
|
+
// The bound is the view's own extent, not the buffer's, since the slice
|
|
83
|
+
// starts at the view's byteOffset.
|
|
84
|
+
const bufferLength = dataView.byteLength;
|
|
85
|
+
const byteOffset = dataView.byteOffset || 0;
|
|
83
86
|
const start = Math.min(Math.max(chunk.dataOffset, 0), bufferLength);
|
|
84
87
|
const end = Math.min(start + Math.max(chunk.length, 0), bufferLength);
|
|
85
|
-
return new Uint8Array(dataView.buffer.slice(start, end));
|
|
88
|
+
return new Uint8Array(dataView.buffer.slice(byteOffset + start, byteOffset + end));
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
function readTags(tags, chunkDataView, domParser) {
|
package/webpack.config.js
CHANGED
|
@@ -6,6 +6,7 @@ const path = require('path');
|
|
|
6
6
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
7
7
|
const findConfigFromClosestPackageJson = require('./bin/findDependentConfig');
|
|
8
8
|
const TagFilterPlugin = require('./bin/TagFilterPlugin');
|
|
9
|
+
const parseConfig = require('./bin/parse-config');
|
|
9
10
|
|
|
10
11
|
const config = getConfig();
|
|
11
12
|
const includedModules = parseConfig(config);
|
|
@@ -92,59 +93,6 @@ module.exports = {
|
|
|
92
93
|
}
|
|
93
94
|
};
|
|
94
95
|
|
|
95
|
-
function parseConfig({include: includesConfig, exclude: excludesConfig}) {
|
|
96
|
-
const modules = [
|
|
97
|
-
'file',
|
|
98
|
-
'jfif',
|
|
99
|
-
'png_file',
|
|
100
|
-
'exif',
|
|
101
|
-
'iptc',
|
|
102
|
-
'xmp',
|
|
103
|
-
'icc',
|
|
104
|
-
'photoshop',
|
|
105
|
-
'maker_notes',
|
|
106
|
-
'mpf',
|
|
107
|
-
'thumbnail',
|
|
108
|
-
'tiff',
|
|
109
|
-
'jpeg',
|
|
110
|
-
'png',
|
|
111
|
-
'heic',
|
|
112
|
-
'avif',
|
|
113
|
-
'jxl',
|
|
114
|
-
'webp',
|
|
115
|
-
'gif'
|
|
116
|
-
];
|
|
117
|
-
|
|
118
|
-
if (includesConfig) {
|
|
119
|
-
const includes = {};
|
|
120
|
-
for (const module of modules) {
|
|
121
|
-
includes[module] =
|
|
122
|
-
(
|
|
123
|
-
Object.keys(includesConfig).includes(module)
|
|
124
|
-
|| ((module === 'exif') && Object.keys(includesConfig).includes('thumbnail'))
|
|
125
|
-
|| ((module === 'exif') && Object.keys(includesConfig).includes('mpf'))
|
|
126
|
-
)
|
|
127
|
-
&& includesConfig[module];
|
|
128
|
-
}
|
|
129
|
-
return includes;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (excludesConfig) {
|
|
133
|
-
const includes = {};
|
|
134
|
-
for (const module of modules) {
|
|
135
|
-
includes[module] =
|
|
136
|
-
!(
|
|
137
|
-
excludesConfig.includes(module)
|
|
138
|
-
|| ((module === 'thumbnail') && excludesConfig.includes('exif'))
|
|
139
|
-
|| ((module === 'mpf') && excludesConfig.includes('exif'))
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
return includes;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
96
|
function getConfig() {
|
|
149
97
|
const packageJson = getPackageJson();
|
|
150
98
|
|