edfcore 0.3.60 → 0.3.61
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/CHANGELOG.md +19 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/inspect.d.ts +4 -0
- package/dist/inspect.d.ts.map +1 -1
- package/dist/inspect.js +31 -6
- package/dist/inspect.js.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/inspect.ts +32 -7
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,25 @@ 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.3.61
|
|
10
|
+
|
|
11
|
+
- **Fixed** `inspectEdf` reporting a complete, perfectly readable file as `SOURCE_TOO_SMALL`, at
|
|
12
|
+
error severity, immediately after it had already recorded the real reason.
|
|
13
|
+
- When the declared header exceeds the 128 KiB triage ceiling, `inspectEdf` records
|
|
14
|
+
`HEADER_EXCEEDS_INSPECTION_BUDGET` — and then handed the deliberately truncated buffer to
|
|
15
|
+
`parseHeader` anyway. The parse can only fail its "are all the header bytes here" check, and
|
|
16
|
+
that check reports `SOURCE_TOO_SMALL` saying "only 131072 bytes are available" — which is
|
|
17
|
+
`inspectEdf`'s own budget, not the file's size.
|
|
18
|
+
- A 512-signal file 133,376 bytes long, whose header needs 131,328 and which `readHeader` parses
|
|
19
|
+
without complaint, was therefore reported as too small.
|
|
20
|
+
- Both `api-reading.md` and `diagnostics.md` already say such a header "is reported as
|
|
21
|
+
`HEADER_EXCEEDS_INSPECTION_BUDGET` **rather than half-parsed**". It was half-parsed and then
|
|
22
|
+
misdiagnosed. `inspectEdf` now returns before the parse it knows cannot succeed, with that one
|
|
23
|
+
diagnostic and the variant hint.
|
|
24
|
+
- `ok` is still false, and the docblock now names this as the one case where that happens without an
|
|
25
|
+
error-severity diagnostic: nothing was parsed, so there is nothing to be right or wrong about, and
|
|
26
|
+
the diagnostic names the call that will read the file.
|
|
27
|
+
|
|
9
28
|
## 0.3.60
|
|
10
29
|
|
|
11
30
|
- **Fixed** `validateRecording` and `readEnvelope` reporting a different number of diagnostics for
|
package/dist/constants.d.ts
CHANGED
|
@@ -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.3.
|
|
112
|
+
export declare const VERSION = "0.3.61";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
package/dist/inspect.d.ts
CHANGED
|
@@ -26,6 +26,10 @@ import type { ByteSource, EdfInspection, ReadOptions } from './types.js';
|
|
|
26
26
|
* whose scale edfcore refuses is an error even though the header itself is readable, because
|
|
27
27
|
* physical units are unavailable for it. Warnings leave `ok` true: the file is impolite, and what
|
|
28
28
|
* it reports is still true.
|
|
29
|
+
*
|
|
30
|
+
* The one case where `ok` is false without an error-severity diagnostic is a header above the
|
|
31
|
+
* ceiling: nothing was parsed, so there is nothing to be right or wrong about, and
|
|
32
|
+
* `HEADER_EXCEEDS_INSPECTION_BUDGET` says so and names the call that will read it.
|
|
29
33
|
*/
|
|
30
34
|
export declare function inspectEdf(source: ByteSource, options?: ReadOptions): Promise<EdfInspection>;
|
|
31
35
|
//# sourceMappingURL=inspect.d.ts.map
|
package/dist/inspect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../src/inspect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAUH,OAAO,KAAK,EAAE,UAAU,EAAiB,aAAa,EAAc,WAAW,EAAE,MAAM,YAAY,CAAC;AAgFpG
|
|
1
|
+
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../src/inspect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAUH,OAAO,KAAK,EAAE,UAAU,EAAiB,aAAa,EAAc,WAAW,EAAE,MAAM,YAAY,CAAC;AAgFpG;;;;;;;;;;;GAWG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,UAAU,EAClB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,aAAa,CAAC,CA8FxB"}
|
package/dist/inspect.js
CHANGED
|
@@ -106,6 +106,10 @@ function budgetDiagnostic(signalCount, headerByteLength) {
|
|
|
106
106
|
* whose scale edfcore refuses is an error even though the header itself is readable, because
|
|
107
107
|
* physical units are unavailable for it. Warnings leave `ok` true: the file is impolite, and what
|
|
108
108
|
* it reports is still true.
|
|
109
|
+
*
|
|
110
|
+
* The one case where `ok` is false without an error-severity diagnostic is a header above the
|
|
111
|
+
* ceiling: nothing was parsed, so there is nothing to be right or wrong about, and
|
|
112
|
+
* `HEADER_EXCEEDS_INSPECTION_BUDGET` says so and names the call that will read it.
|
|
109
113
|
*/
|
|
110
114
|
export async function inspectEdf(source, options) {
|
|
111
115
|
const byteLength = source.byteLength;
|
|
@@ -132,11 +136,36 @@ export async function inspectEdf(source, options) {
|
|
|
132
136
|
headerBytes = combined;
|
|
133
137
|
}
|
|
134
138
|
}
|
|
139
|
+
if (overBudget !== undefined) {
|
|
140
|
+
/*
|
|
141
|
+
* Return rather than parse. `headerBytes` was truncated to the ceiling on purpose, so the
|
|
142
|
+
* parse can only fail its "are all the header bytes here" check — and that check reports
|
|
143
|
+
* `SOURCE_TOO_SMALL`, an ERROR saying "only 131072 bytes are available", which is this
|
|
144
|
+
* function's own budget and not the file's size.
|
|
145
|
+
*
|
|
146
|
+
* A complete, perfectly readable 512-signal file — 133,376 bytes on disk, needing 131,328 for
|
|
147
|
+
* its header, which `readHeader` parses without complaint — was therefore reported as too
|
|
148
|
+
* small, immediately after the real reason had already been recorded one line above. Both
|
|
149
|
+
* `api-reading.md` and `diagnostics.md` say such a header "is reported as
|
|
150
|
+
* HEADER_EXCEEDS_INSPECTION_BUDGET rather than half-parsed"; it was half-parsed and then
|
|
151
|
+
* misdiagnosed (fixed in 0.3.61).
|
|
152
|
+
*/
|
|
153
|
+
return {
|
|
154
|
+
ok: false,
|
|
155
|
+
variant: variantHint(headerBytes),
|
|
156
|
+
header: undefined,
|
|
157
|
+
byteLength,
|
|
158
|
+
bytesRead,
|
|
159
|
+
headerBytes,
|
|
160
|
+
diagnostics: Object.freeze([overBudget]),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
135
163
|
try {
|
|
136
164
|
// Never strict: a triage call that threw on the first impolite field would be useless for
|
|
137
165
|
// exactly the files it exists to describe.
|
|
138
166
|
const header = parseHeader(headerBytes, byteLength);
|
|
139
|
-
|
|
167
|
+
// `overBudget` returned above, so everything reaching here parsed the whole declared header.
|
|
168
|
+
const diagnostics = header.diagnostics;
|
|
140
169
|
return {
|
|
141
170
|
ok: diagnostics.every((diagnostic) => diagnostic.severity !== 'error'),
|
|
142
171
|
variant: header.variant,
|
|
@@ -167,11 +196,7 @@ export async function inspectEdf(source, options) {
|
|
|
167
196
|
headerBytes,
|
|
168
197
|
// The fatal comes LAST, after what led up to it: it is the reason parsing stopped, and a
|
|
169
198
|
// reader following the list downwards reaches it in the order the parse did.
|
|
170
|
-
diagnostics: Object.freeze([
|
|
171
|
-
...(overBudget === undefined ? [] : [overBudget]),
|
|
172
|
-
...collected,
|
|
173
|
-
failure,
|
|
174
|
-
]),
|
|
199
|
+
diagnostics: Object.freeze([...collected, failure]),
|
|
175
200
|
};
|
|
176
201
|
}
|
|
177
202
|
}
|
package/dist/inspect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect.js","sourceRoot":"","sources":["../src/inspect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM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,CAAC,CAAC;SACpD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
package/src/inspect.ts
CHANGED
|
@@ -114,6 +114,10 @@ function budgetDiagnostic(signalCount: number, headerByteLength: number): EdfDia
|
|
|
114
114
|
* whose scale edfcore refuses is an error even though the header itself is readable, because
|
|
115
115
|
* physical units are unavailable for it. Warnings leave `ok` true: the file is impolite, and what
|
|
116
116
|
* it reports is still true.
|
|
117
|
+
*
|
|
118
|
+
* The one case where `ok` is false without an error-severity diagnostic is a header above the
|
|
119
|
+
* ceiling: nothing was parsed, so there is nothing to be right or wrong about, and
|
|
120
|
+
* `HEADER_EXCEEDS_INSPECTION_BUDGET` says so and names the call that will read it.
|
|
117
121
|
*/
|
|
118
122
|
export async function inspectEdf(
|
|
119
123
|
source: ByteSource,
|
|
@@ -150,12 +154,37 @@ export async function inspectEdf(
|
|
|
150
154
|
}
|
|
151
155
|
}
|
|
152
156
|
|
|
157
|
+
if (overBudget !== undefined) {
|
|
158
|
+
/*
|
|
159
|
+
* Return rather than parse. `headerBytes` was truncated to the ceiling on purpose, so the
|
|
160
|
+
* parse can only fail its "are all the header bytes here" check — and that check reports
|
|
161
|
+
* `SOURCE_TOO_SMALL`, an ERROR saying "only 131072 bytes are available", which is this
|
|
162
|
+
* function's own budget and not the file's size.
|
|
163
|
+
*
|
|
164
|
+
* A complete, perfectly readable 512-signal file — 133,376 bytes on disk, needing 131,328 for
|
|
165
|
+
* its header, which `readHeader` parses without complaint — was therefore reported as too
|
|
166
|
+
* small, immediately after the real reason had already been recorded one line above. Both
|
|
167
|
+
* `api-reading.md` and `diagnostics.md` say such a header "is reported as
|
|
168
|
+
* HEADER_EXCEEDS_INSPECTION_BUDGET rather than half-parsed"; it was half-parsed and then
|
|
169
|
+
* misdiagnosed (fixed in 0.3.61).
|
|
170
|
+
*/
|
|
171
|
+
return {
|
|
172
|
+
ok: false,
|
|
173
|
+
variant: variantHint(headerBytes),
|
|
174
|
+
header: undefined,
|
|
175
|
+
byteLength,
|
|
176
|
+
bytesRead,
|
|
177
|
+
headerBytes,
|
|
178
|
+
diagnostics: Object.freeze([overBudget]),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
153
182
|
try {
|
|
154
183
|
// Never strict: a triage call that threw on the first impolite field would be useless for
|
|
155
184
|
// exactly the files it exists to describe.
|
|
156
185
|
const header = parseHeader(headerBytes, byteLength);
|
|
157
|
-
|
|
158
|
-
|
|
186
|
+
// `overBudget` returned above, so everything reaching here parsed the whole declared header.
|
|
187
|
+
const diagnostics = header.diagnostics;
|
|
159
188
|
return {
|
|
160
189
|
ok: diagnostics.every((diagnostic) => diagnostic.severity !== 'error'),
|
|
161
190
|
variant: header.variant,
|
|
@@ -184,11 +213,7 @@ export async function inspectEdf(
|
|
|
184
213
|
headerBytes,
|
|
185
214
|
// The fatal comes LAST, after what led up to it: it is the reason parsing stopped, and a
|
|
186
215
|
// reader following the list downwards reaches it in the order the parse did.
|
|
187
|
-
diagnostics: Object.freeze([
|
|
188
|
-
...(overBudget === undefined ? [] : [overBudget]),
|
|
189
|
-
...collected,
|
|
190
|
-
failure,
|
|
191
|
-
]),
|
|
216
|
+
diagnostics: Object.freeze([...collected, failure]),
|
|
192
217
|
};
|
|
193
218
|
}
|
|
194
219
|
}
|