exifreader 4.49.0 → 4.51.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 CHANGED
@@ -183,7 +183,8 @@ local file path and will make a network request or read from the file system.
183
183
  Never pass an untrusted or user-controlled string to `load()`. Doing so lets an
184
184
  attacker make the process fetch arbitrary URLs (server-side request forgery) or
185
185
  open arbitrary local files. For untrusted image data, always pass the bytes
186
- themselves (an `ArrayBuffer`, a `Buffer`, or a browser `File`), never a string.
186
+ themselves (an `ArrayBuffer`, a typed array such as `Uint8Array` or `Buffer`, or
187
+ a browser `File`), never a string.
187
188
 
188
189
  **Tip:** To read metadata from an `HTMLImageElement`, wait for its `load` event
189
190
  and call `ExifReader.load(image.src)`. The browser should reuse the cached file.
@@ -197,6 +198,7 @@ const tags = ExifReader.load(fileBuffer);
197
198
  Where `fileBuffer` is one of
198
199
 
199
200
  * `ArrayBuffer` or `SharedArrayBuffer` (browser, Node.js)
201
+ * any typed array such as `Uint8Array`, or a `DataView` (browser, Node.js)
200
202
  * `Buffer` (Node.js)
201
203
 
202
204
  See the [examples site](https://mattiasw.github.io/ExifReader/) for more
@@ -390,8 +392,9 @@ does not fit inside the part you read, no ICC tags are returned for it. Use
390
392
  yourself.
391
393
 
392
394
  Note that this option only works when ExifReader handles the loading of the
393
- file. If e.g. an already loaded ArrayBuffer or Buffer is passed into ExifReader,
394
- the whole file will already have been loaded into memory and it's too late.
395
+ file. If e.g. an already loaded ArrayBuffer, typed array or Buffer is passed
396
+ into ExifReader, the whole file will already have been loaded into memory and
397
+ it's too late.
395
398
  More specifically the length option will work for 1. local files when running
396
399
  through Node.js, 2. remote files when passing a URL, and 3. browser File objects
397
400
  (e.g., from form file fields). For remote files accessed through a web browser,
@@ -420,8 +423,11 @@ const tags = await ExifReader.load(url, {
420
423
  tags.metadataRange.end // exact byte count needed for the metadata
421
424
  tags.metadataRange.buffer // bytes [0, end), sliced from what we read.
422
425
  // Same kind as the input (ArrayBuffer,
423
- // SharedArrayBuffer or Node Buffer). Save
424
- // this to disk to keep only the
426
+ // SharedArrayBuffer or Node Buffer). For a
427
+ // typed array or DataView input it is an
428
+ // ArrayBuffer (a SharedArrayBuffer when the
429
+ // view is over one) holding only the view's
430
+ // bytes. Save this to disk to keep only the
425
431
  // metadata-bearing prefix.
426
432
  tags.metadataRange.fetched // bytes actually read. May be greater than
427
433
  // `end` because the loop reads in fixed-size
@@ -442,10 +448,10 @@ Exif/XMP `iloc` entries point near the end of the file typically take two.
442
448
  - Local file path via Node `fs`
443
449
  - Browser `File` object via `File.slice`
444
450
 
445
- It is also accepted for in-memory inputs (`ArrayBuffer`, `SharedArrayBuffer`
446
- and Node.js `Buffer`) as a convenience. There is no IO loop to run in that
447
- case, but `metadataRange.buffer` is still attached as the trimmed slice of
448
- what you passed in.
451
+ It is also accepted for in-memory inputs (`ArrayBuffer`, `SharedArrayBuffer`,
452
+ Node.js `Buffer`, any other typed array and `DataView`) as a convenience. There
453
+ is no IO loop to run in that case, but `metadataRange.buffer` is still attached
454
+ as the trimmed slice of what you passed in.
449
455
 
450
456
  Requirements and caveats:
451
457
 
package/bin/cli.js CHANGED
@@ -8,6 +8,7 @@
8
8
 
9
9
  const path = require('path');
10
10
  const fs = require('fs');
11
+ const {createRequire} = require('module');
11
12
  const {readMarker, markerMatches} = require('./custom-build-marker');
12
13
  const {collectImagePaths, loadFullParser, resolveDomParser, analyzeImages, deriveConfig, writeConfigToPackageJson} = require('./analyze');
13
14
  const {verifyImages, loadCustomParser} = require('./verify-build');
@@ -547,7 +548,9 @@ function checkLocalInstall(cwd, options) {
547
548
  }
548
549
 
549
550
  function defaultResolve(cwd) {
550
- return require.resolve('exifreader/package.json', {paths: [cwd]});
551
+ // The parent sits inside node_modules so Node skips package self-reference
552
+ // (an exports map enables it) and searches cwd's node_modules chain.
553
+ return createRequire(path.join(cwd, 'node_modules', 'noop.js')).resolve('exifreader/package.json');
551
554
  }
552
555
 
553
556
  function notInstalledMessage(isPnp) {