exifreader 4.49.0 → 4.50.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/bin/cli.js +4 -1
- package/dist/exif-reader.js +1 -1
- package/dist/exif-reader.js.map +1 -1
- package/package.json +20 -1
- package/src/dom-parser.js +3 -2
- package/src/file-loaders.js +11 -14
- package/src/node-require.js +84 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "exifreader",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.50.0",
|
|
4
4
|
"description": "Library that parses Exif metadata in images.",
|
|
5
5
|
"author": "Mattias Wallander <mattias@wallander.eu>",
|
|
6
6
|
"repository": {
|
|
@@ -21,6 +21,23 @@
|
|
|
21
21
|
"webpack.config.js"
|
|
22
22
|
],
|
|
23
23
|
"types": "./exif-reader.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./exif-reader.d.ts",
|
|
27
|
+
"browser": "./src/exif-reader.js",
|
|
28
|
+
"node": "./dist/exif-reader.js",
|
|
29
|
+
"module": "./src/exif-reader.js",
|
|
30
|
+
"import": "./dist/exif-reader.js",
|
|
31
|
+
"require": "./dist/exif-reader.js",
|
|
32
|
+
"default": "./dist/exif-reader.js"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json",
|
|
35
|
+
"./src/exif-reader": "./src/exif-reader.js",
|
|
36
|
+
"./dist/exif-reader": "./dist/exif-reader.js",
|
|
37
|
+
"./src/composable/*": null,
|
|
38
|
+
"./src/*": "./src/*",
|
|
39
|
+
"./dist/*": "./dist/*"
|
|
40
|
+
},
|
|
24
41
|
"bin": {
|
|
25
42
|
"exifreader": "bin/cli.js"
|
|
26
43
|
},
|
|
@@ -69,6 +86,8 @@
|
|
|
69
86
|
"test:e2e:chrome": "cypress run",
|
|
70
87
|
"test:e2e:firefox": "cypress run --browser firefox",
|
|
71
88
|
"test:types": "tsc --noEmit --project test/types",
|
|
89
|
+
"test:packaging:install": "npm install --prefix test/packaging/tools --no-package-lock --no-audit --no-fund --ignore-scripts",
|
|
90
|
+
"test:packaging": "node test/packaging/resolver-matrix.mjs",
|
|
72
91
|
"test:all": "npm-run-all2 lint test:types coverage test:e2e:chrome test:integration test:build test:build:custom",
|
|
73
92
|
"pre-commit": "npm-run-all2 lint test:types coverage test:build",
|
|
74
93
|
"postinstall": "node bin/build.js --only-with-config",
|
package/src/dom-parser.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
4
|
|
|
5
|
+
import NodeRequire from './node-require.js';
|
|
6
|
+
|
|
5
7
|
export default {
|
|
6
8
|
get
|
|
7
9
|
};
|
|
@@ -15,8 +17,7 @@ function get(domParser) {
|
|
|
15
17
|
return new DOMParser();
|
|
16
18
|
}
|
|
17
19
|
try {
|
|
18
|
-
|
|
19
|
-
const {DOMParser, onErrorStopParsing} = __non_webpack_require__('@xmldom/xmldom');
|
|
20
|
+
const {DOMParser, onErrorStopParsing} = NodeRequire.optionalPackage('@xmldom/xmldom');
|
|
20
21
|
return new DOMParser({onError: onErrorStopParsing});
|
|
21
22
|
} catch (error) {
|
|
22
23
|
return undefined;
|
package/src/file-loaders.js
CHANGED
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
7
7
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
8
8
|
*/
|
|
9
|
-
/* global Buffer
|
|
9
|
+
/* global Buffer */
|
|
10
10
|
|
|
11
11
|
import {dataUriToBuffer} from './utils.js';
|
|
12
|
+
import NodeRequire from './node-require.js';
|
|
12
13
|
|
|
13
14
|
export const HTTP_STATUS_OK = 200;
|
|
14
15
|
export const HTTP_STATUS_SUCCESS_MAX = 299;
|
|
@@ -271,6 +272,9 @@ export function nodeGetRange(url, {start = 0, end, maxBytes} = {}) {
|
|
|
271
272
|
}
|
|
272
273
|
|
|
273
274
|
const get = requireNodeGet(url);
|
|
275
|
+
if (!get) {
|
|
276
|
+
return reject(new Error('Node http support is not available.'));
|
|
277
|
+
}
|
|
274
278
|
get(url, options, (response) => {
|
|
275
279
|
if ((response.statusCode >= HTTP_STATUS_OK) && (response.statusCode <= HTTP_STATUS_SUCCESS_MAX)) {
|
|
276
280
|
const totalSize = totalSizeFromNodeResponse(response);
|
|
@@ -358,10 +362,8 @@ function totalSizeFromRangeHeaders(contentRange, contentLength) {
|
|
|
358
362
|
}
|
|
359
363
|
|
|
360
364
|
function requireNodeGet(url) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
return __non_webpack_require__('http').get;
|
|
365
|
+
const http = NodeRequire.builtin(/^https:\/\//.test(url) ? 'https' : 'http');
|
|
366
|
+
return http && http.get;
|
|
365
367
|
}
|
|
366
368
|
|
|
367
369
|
/**
|
|
@@ -376,7 +378,10 @@ function requireNodeGet(url) {
|
|
|
376
378
|
*/
|
|
377
379
|
export function readLocalFileRange(filename, {start = 0, end, totalSize} = {}) {
|
|
378
380
|
return new Promise((resolve, reject) => {
|
|
379
|
-
const fs =
|
|
381
|
+
const fs = NodeRequire.builtin('fs');
|
|
382
|
+
if (!fs) {
|
|
383
|
+
return reject(new Error('Node file system support is not available.'));
|
|
384
|
+
}
|
|
380
385
|
fs.open(filename, (openErr, fd) => {
|
|
381
386
|
if (openErr) {
|
|
382
387
|
return reject(openErr);
|
|
@@ -417,14 +422,6 @@ function finishLocalRead(filename, closeErr, buffer, total, resolve) {
|
|
|
417
422
|
resolve({buffer, totalSize: total});
|
|
418
423
|
}
|
|
419
424
|
|
|
420
|
-
function requireNodeFs() {
|
|
421
|
-
try {
|
|
422
|
-
return __non_webpack_require__('fs');
|
|
423
|
-
} catch (error) {
|
|
424
|
-
return undefined;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
|
|
428
425
|
/**
|
|
429
426
|
* Range-aware browser `File` reader. Uses `file.slice(start, end)` plus
|
|
430
427
|
* `FileReader.readAsArrayBuffer`.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
|
|
5
|
+
/* global globalThis, __non_webpack_require__ */
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
builtin,
|
|
9
|
+
optionalPackage
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Loads a Node builtin module such as `fs`, `http` or `https`.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} name
|
|
16
|
+
* @returns {Object|undefined} The module, or undefined where none is reachable
|
|
17
|
+
* (browsers, workers).
|
|
18
|
+
*/
|
|
19
|
+
function builtin(name) {
|
|
20
|
+
return firstLoaded(name, [webpackRequire, getBuiltinModule, mainModuleRequire]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Loads an installed package through the literal require that webpack emits,
|
|
25
|
+
* which Node and bundlers resolve from the UMD. The ES module source outside
|
|
26
|
+
* webpack gets none: programs pass the domParser option instead.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} name
|
|
29
|
+
* @returns {Object|undefined} The package, or undefined where none is reachable.
|
|
30
|
+
*/
|
|
31
|
+
function optionalPackage(name) {
|
|
32
|
+
return firstLoaded(name, [webpackRequire]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// A loader throws where its mechanism is missing (no process, no
|
|
36
|
+
// getBuiltinModule, no mainModule), which moves on to the next one. process is
|
|
37
|
+
// never named as a free variable: Parcel 2 and webpack 4 would then bundle a
|
|
38
|
+
// process polyfill into browser builds of the source.
|
|
39
|
+
function firstLoaded(name, loaders) {
|
|
40
|
+
for (let i = 0; i < loaders.length; i++) {
|
|
41
|
+
try {
|
|
42
|
+
return loaders[i](name);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
// Try the next loader.
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Literal names make webpack emit require('fs') and so on, which bundlers and
|
|
51
|
+
// file tracers follow. No typeof guard: webpack may not rewrite the identifier there.
|
|
52
|
+
// A try in this function makes bundlers treat fs and @xmldom/xmldom as optional.
|
|
53
|
+
function webpackRequire(name) {
|
|
54
|
+
switch (name) {
|
|
55
|
+
case 'fs':
|
|
56
|
+
// eslint-disable-next-line no-useless-catch
|
|
57
|
+
try {
|
|
58
|
+
return __non_webpack_require__('fs');
|
|
59
|
+
} catch (error) {
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
case 'http':
|
|
63
|
+
return __non_webpack_require__('http');
|
|
64
|
+
case 'https':
|
|
65
|
+
return __non_webpack_require__('https');
|
|
66
|
+
case '@xmldom/xmldom':
|
|
67
|
+
// eslint-disable-next-line no-useless-catch
|
|
68
|
+
try {
|
|
69
|
+
return __non_webpack_require__('@xmldom/xmldom');
|
|
70
|
+
} catch (error) {
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
default:
|
|
74
|
+
throw new Error(`No webpack require for ${name}.`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function getBuiltinModule(name) {
|
|
79
|
+
return globalThis.process.getBuiltinModule(name);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function mainModuleRequire(name) {
|
|
83
|
+
return globalThis.process.mainModule.require(name);
|
|
84
|
+
}
|