edfcore 0.6.197 → 0.6.198

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.
@@ -109,5 +109,5 @@ export declare const SIGNAL_FIELD_BLOCK_OFFSETS: {
109
109
  readonly reserved: 224;
110
110
  };
111
111
  /** Published package version. Kept in sync with package.json by a test. */
112
- export declare const VERSION = "0.6.197";
112
+ export declare const VERSION = "0.6.198";
113
113
  //# sourceMappingURL=constants.d.ts.map
package/dist/constants.js CHANGED
@@ -79,5 +79,5 @@ export const SIGNAL_FIELD_BLOCK_OFFSETS = {
79
79
  reserved: 224,
80
80
  };
81
81
  /** Published package version. Kept in sync with package.json by a test. */
82
- export const VERSION = '0.6.197';
82
+ export const VERSION = '0.6.198';
83
83
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../src/io/blob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AAGrE;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAuDrD"}
1
+ {"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../src/io/blob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AAGrE;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CA8ErD"}
package/dist/io/blob.js CHANGED
@@ -63,6 +63,26 @@ export function blobSource(blob) {
63
63
  // `Blob.slice` takes an EXCLUSIVE end, unlike an HTTP byte range.
64
64
  const buffer = await blob.slice(offset, offset + length).arrayBuffer();
65
65
  throwIfAborted(options);
66
+ /*
67
+ * Diagnosed HERE rather than left to `assertExactRead`, which is the argument `node.ts` makes
68
+ * for its own short read — and the case it names there is this one: "a picked `File`'s backing
69
+ * file shrank". It was the only adapter of the three without the diagnosis.
70
+ *
71
+ * `assertExactRead` exists for a `ByteSource` the CALLER wrote. Its message says a source
72
+ * "must resolve with exactly the requested number of bytes or reject", which accuses the
73
+ * browser of breaking a contract it kept: the platform answered correctly for a file that is
74
+ * now shorter than the one the picker measured. This module's own docblock calls that the one
75
+ * legitimate short read there is.
76
+ *
77
+ * Same shape as the HTTP buffered-body path (0.3.75) and the file handle (0.3.93).
78
+ */
79
+ if (buffer.byteLength < length) {
80
+ throw new EdfSourceError(`Reading bytes ${offset}..${offset + length - 1}: the blob ended after ` +
81
+ `${buffer.byteLength} of them. This source was built for ${byteLength} bytes, so the ` +
82
+ 'range asked for is past the end of the blob as it is now. Next: a picked File is a ' +
83
+ 'handle on a file that can still change — the backing file was truncated or replaced ' +
84
+ 'since it was chosen, so ask for it again.', { offset, requestedLength: length, receivedLength: buffer.byteLength });
85
+ }
66
86
  return assertExactRead(new Uint8Array(buffer), offset, length);
67
87
  },
68
88
  };
@@ -1 +1 @@
1
- {"version":3,"file":"blob.js","sourceRoot":"","sources":["../../src/io/blob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE/E;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAc;IACvC;;;;;;OAMG;IACH,MAAM,KAAK,GAAG,IAAmC,CAAC;IAClD,IAAI,OAAO,KAAK,EAAE,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;QACzE,MAAM,IAAI,cAAc,CACtB,2FAA2F;YACzF,GAAG,aAAa,CAAC,IAAI,CAAC,qEAAqE;YAC3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AAC,CAAC,WAAW,EAAE,CAAC;YACvE,cAAc,CAAC,OAAO,CAAC,CAAC;YACxB;;;;;;;;;;;;eAYG;YACH,IAAI,MAAM,CAAC,UAAU,GAAG,MAAM,EAAE,CAAC;gBAC/B,MAAM,IAAI,cAAc,CACtB,iBAAiB,MAAM,KAAK,MAAM,GAAG,MAAM,GAAG,CAAC,yBAAyB;oBACtE,GAAG,MAAM,CAAC,UAAU,uCAAuC,UAAU,iBAAiB;oBACtF,qFAAqF;oBACrF,sFAAsF;oBACtF,2CAA2C,EAC7C,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,CAAC,UAAU,EAAE,CACvE,CAAC;YACJ,CAAC;YACD,OAAO,eAAe,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACjE,CAAC;KACF,CAAC;AACJ,CAAC"}
package/docs/CHANGELOG.md CHANGED
@@ -6,6 +6,19 @@ alone does not tell you whether you were affected.
6
6
  edfcore is pre-1.0. Patch releases have carried behaviour changes where the old behaviour was a
7
7
  defect; those are called out below.
8
8
 
9
+ ## 0.6.198
10
+
11
+ - **Fixed** `blobSource` reporting a shrunk `File` as a `ByteSource` breaking its contract. Its own
12
+ docblock names this as the one legitimate short read there is — "a `File` whose backing file
13
+ changed on disk since the picker ran" — and then handed it to `assertExactRead`, whose message says
14
+ a source "must resolve with exactly the requested number of bytes or reject" and asks for a
15
+ `read()` that loops.
16
+ - So the browser was accused of breaking a contract it kept, and the advice asked it to loop for
17
+ bytes that no longer exist.
18
+ - `node.ts` diagnoses exactly this in its own reader and names this very case — "a picked `File`'s
19
+ backing file shrank". The HTTP buffered-body path got it in 0.3.75 and the file handle in 0.3.93;
20
+ `blobSource` was the third of three.
21
+
9
22
  ## 0.6.197
10
23
 
11
24
  - **Fixed** the three printers' flags being read as one side of a boolean when given as text —
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.6.197",
3
+ "version": "0.6.198",
4
4
  "description": "Modern, typed, zero-dependency reader for EDF, EDF+, BDF and BDF+ biosignal files. Works in browsers and Node with true random access.",
5
5
  "keywords": [
6
6
  "edf",
package/src/constants.ts CHANGED
@@ -93,4 +93,4 @@ export const SIGNAL_FIELD_BLOCK_OFFSETS = {
93
93
  } as const;
94
94
 
95
95
  /** Published package version. Kept in sync with package.json by a test. */
96
- export const VERSION = '0.6.197';
96
+ export const VERSION = '0.6.198';
package/src/io/blob.ts CHANGED
@@ -72,6 +72,29 @@ export function blobSource(blob: BlobLike): ByteSource {
72
72
  // `Blob.slice` takes an EXCLUSIVE end, unlike an HTTP byte range.
73
73
  const buffer = await blob.slice(offset, offset + length).arrayBuffer();
74
74
  throwIfAborted(options);
75
+ /*
76
+ * Diagnosed HERE rather than left to `assertExactRead`, which is the argument `node.ts` makes
77
+ * for its own short read — and the case it names there is this one: "a picked `File`'s backing
78
+ * file shrank". It was the only adapter of the three without the diagnosis.
79
+ *
80
+ * `assertExactRead` exists for a `ByteSource` the CALLER wrote. Its message says a source
81
+ * "must resolve with exactly the requested number of bytes or reject", which accuses the
82
+ * browser of breaking a contract it kept: the platform answered correctly for a file that is
83
+ * now shorter than the one the picker measured. This module's own docblock calls that the one
84
+ * legitimate short read there is.
85
+ *
86
+ * Same shape as the HTTP buffered-body path (0.3.75) and the file handle (0.3.93).
87
+ */
88
+ if (buffer.byteLength < length) {
89
+ throw new EdfSourceError(
90
+ `Reading bytes ${offset}..${offset + length - 1}: the blob ended after ` +
91
+ `${buffer.byteLength} of them. This source was built for ${byteLength} bytes, so the ` +
92
+ 'range asked for is past the end of the blob as it is now. Next: a picked File is a ' +
93
+ 'handle on a file that can still change — the backing file was truncated or replaced ' +
94
+ 'since it was chosen, so ask for it again.',
95
+ { offset, requestedLength: length, receivedLength: buffer.byteLength },
96
+ );
97
+ }
75
98
  return assertExactRead(new Uint8Array(buffer), offset, length);
76
99
  },
77
100
  };