edfcore 0.6.13 → 0.6.15
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/dist/bytes/hex.d.ts +30 -0
- package/dist/bytes/hex.d.ts.map +1 -0
- package/dist/bytes/hex.js +43 -0
- package/dist/bytes/hex.js.map +1 -0
- package/dist/bytes/latin1.d.ts +17 -0
- package/dist/bytes/latin1.d.ts.map +1 -1
- package/dist/bytes/latin1.js +19 -3
- package/dist/bytes/latin1.js.map +1 -1
- package/dist/bytes/numbers.d.ts +2 -1
- package/dist/bytes/numbers.d.ts.map +1 -1
- package/dist/bytes/numbers.js +5 -7
- package/dist/bytes/numbers.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/header/fields.d.ts.map +1 -1
- package/dist/header/fields.js +5 -18
- package/dist/header/fields.js.map +1 -1
- package/dist/header/variant.d.ts.map +1 -1
- package/dist/header/variant.js +5 -12
- package/dist/header/variant.js.map +1 -1
- package/docs/CHANGELOG.md +43 -0
- package/package.json +1 -1
- package/src/bytes/hex.ts +48 -0
- package/src/bytes/latin1.ts +19 -3
- package/src/bytes/numbers.ts +6 -8
- package/src/constants.ts +1 -1
- package/src/header/fields.ts +5 -20
- package/src/header/variant.ts +5 -13
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bytes as hex, in prose.
|
|
3
|
+
*
|
|
4
|
+
* Layer 0. Imports nothing.
|
|
5
|
+
*
|
|
6
|
+
* Two modules had a private `hexBytes` under the same name and they disagreed about the answer.
|
|
7
|
+
* `header/fields.ts` wrote `0x4b 0x61 0x9f`; `header/variant.ts` wrote `44 6f 77`, in a sentence
|
|
8
|
+
* that goes on to say "nor BDF's 0xFF followed by BIOSEMI" — both spellings of a byte, three
|
|
9
|
+
* words apart, in one message. Without the prefix a short run reads as a decimal number until the
|
|
10
|
+
* eye reaches a digit above 9, which on the `NOT_AN_EDF_FILE` diagnostic is the fifth byte.
|
|
11
|
+
*
|
|
12
|
+
* `0x` per byte, because that message is the argument: the author reached for it the moment a
|
|
13
|
+
* single byte had to be named, and a list is the same claim repeated.
|
|
14
|
+
*
|
|
15
|
+
* This is NOT the renderer for the `rawBytes` block under a diagnostic. That one is a dump with an
|
|
16
|
+
* ASCII column beside it — `30 20 20 20 |0 |` — where the columns are the point and a prefix on
|
|
17
|
+
* every byte would push the ASCII off the line. It stays in `diagnostics/format.ts`, bare, and the
|
|
18
|
+
* difference is that one is prose and the other is a hex dump.
|
|
19
|
+
*/
|
|
20
|
+
/** `'0x9f'`. */
|
|
21
|
+
export declare function hexByte(byte: number): string;
|
|
22
|
+
/**
|
|
23
|
+
* `'0x4b 0x61 0x9f'`, from `from`, eliding with `...` on whichever side was cut.
|
|
24
|
+
*
|
|
25
|
+
* The ellipses are what stop a quoted run being read as the whole field: a caller pointing at the
|
|
26
|
+
* first bad byte 40 bytes into an 80-byte identification field is showing a window, and a window
|
|
27
|
+
* that does not say so is a claim about the field.
|
|
28
|
+
*/
|
|
29
|
+
export declare function hexBytes(bytes: Uint8Array, from?: number, max?: number): string;
|
|
30
|
+
//# sourceMappingURL=hex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../src/bytes/hex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,gBAAgB;AAChB,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,UAAU,EACjB,IAAI,GAAE,MAAU,EAChB,GAAG,GAAE,MAA0B,GAC9B,MAAM,CAQR"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bytes as hex, in prose.
|
|
3
|
+
*
|
|
4
|
+
* Layer 0. Imports nothing.
|
|
5
|
+
*
|
|
6
|
+
* Two modules had a private `hexBytes` under the same name and they disagreed about the answer.
|
|
7
|
+
* `header/fields.ts` wrote `0x4b 0x61 0x9f`; `header/variant.ts` wrote `44 6f 77`, in a sentence
|
|
8
|
+
* that goes on to say "nor BDF's 0xFF followed by BIOSEMI" — both spellings of a byte, three
|
|
9
|
+
* words apart, in one message. Without the prefix a short run reads as a decimal number until the
|
|
10
|
+
* eye reaches a digit above 9, which on the `NOT_AN_EDF_FILE` diagnostic is the fifth byte.
|
|
11
|
+
*
|
|
12
|
+
* `0x` per byte, because that message is the argument: the author reached for it the moment a
|
|
13
|
+
* single byte had to be named, and a list is the same claim repeated.
|
|
14
|
+
*
|
|
15
|
+
* This is NOT the renderer for the `rawBytes` block under a diagnostic. That one is a dump with an
|
|
16
|
+
* ASCII column beside it — `30 20 20 20 |0 |` — where the columns are the point and a prefix on
|
|
17
|
+
* every byte would push the ASCII off the line. It stays in `diagnostics/format.ts`, bare, and the
|
|
18
|
+
* difference is that one is prose and the other is a hex dump.
|
|
19
|
+
*/
|
|
20
|
+
/** How many bytes a message quotes before eliding. Enough to recognise the problem. */
|
|
21
|
+
const DEFAULT_MAX_BYTES = 16;
|
|
22
|
+
/** `'0x9f'`. */
|
|
23
|
+
export function hexByte(byte) {
|
|
24
|
+
return `0x${byte.toString(16).padStart(2, '0')}`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* `'0x4b 0x61 0x9f'`, from `from`, eliding with `...` on whichever side was cut.
|
|
28
|
+
*
|
|
29
|
+
* The ellipses are what stop a quoted run being read as the whole field: a caller pointing at the
|
|
30
|
+
* first bad byte 40 bytes into an 80-byte identification field is showing a window, and a window
|
|
31
|
+
* that does not say so is a claim about the field.
|
|
32
|
+
*/
|
|
33
|
+
export function hexBytes(bytes, from = 0, max = DEFAULT_MAX_BYTES) {
|
|
34
|
+
const start = Math.max(0, from);
|
|
35
|
+
const shown = bytes.subarray(start, start + max);
|
|
36
|
+
const parts = [];
|
|
37
|
+
for (const byte of shown)
|
|
38
|
+
parts.push(hexByte(byte));
|
|
39
|
+
const head = start > 0 ? '... ' : '';
|
|
40
|
+
const tail = start + shown.length < bytes.length ? ' ...' : '';
|
|
41
|
+
return head + parts.join(' ') + tail;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=hex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex.js","sourceRoot":"","sources":["../../src/bytes/hex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,uFAAuF;AACvF,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,gBAAgB;AAChB,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,KAAK,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACnD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAiB,EACjB,OAAe,CAAC,EAChB,MAAc,iBAAiB;IAE/B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,CAAC,CAAC;IACjD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACrC,MAAM,IAAI,GAAG,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/D,OAAO,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;AACvC,CAAC"}
|
package/dist/bytes/latin1.d.ts
CHANGED
|
@@ -26,6 +26,23 @@ export declare function decodeHeaderLatin1(bytes: Uint8Array): string;
|
|
|
26
26
|
* that wants to tolerate it can check the padding itself.
|
|
27
27
|
*/
|
|
28
28
|
export declare function hasNonPrintableAscii(bytes: Uint8Array): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* What EDF field padding is, once, for the four modules that act on it.
|
|
31
|
+
*
|
|
32
|
+
* `trimEdfField` below states the rule and the reason: only 0x20 and 0x00, because a trailing TAB
|
|
33
|
+
* or CR is not padding but content the file should not contain, and hiding it here would hide it
|
|
34
|
+
* from `NON_ASCII_HEADER_FIELD`. `bytes/numbers.ts` trims the same padding before parsing a number
|
|
35
|
+
* and `header/fields.ts` finds a field's content bounds inside its own bytes, `header/variant.ts` decides whether the version block is `'0'` and
|
|
36
|
+
* seven pad bytes, and each had grown a byte-identical copy of these two lines with its own pair
|
|
37
|
+
* of constants.
|
|
38
|
+
*
|
|
39
|
+
* Three copies of a rule are three chances for two of them to disagree, and the disagreement would
|
|
40
|
+
* not look like one: a field would trim one way for display and another way for its numeric parse,
|
|
41
|
+
* so `NUMERIC_FIELD_NOT_LEFT_JUSTIFIED` would fire on a field `trimEdfField` had already called
|
|
42
|
+
* clean. `padding.test.ts` checks the rule across all 256 byte values from both public
|
|
43
|
+
* sides, and that every module acting on it imports this rather than growing another.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isEdfPadding(code: number): boolean;
|
|
29
46
|
/**
|
|
30
47
|
* Strip EDF field padding: spaces and NULs, from both ends.
|
|
31
48
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latin1.d.ts","sourceRoot":"","sources":["../../src/bytes/latin1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAsBH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAO5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAK/D;
|
|
1
|
+
{"version":3,"file":"latin1.d.ts","sourceRoot":"","sources":["../../src/bytes/latin1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAsBH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAO5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAK/D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMjD"}
|
package/dist/bytes/latin1.js
CHANGED
|
@@ -56,7 +56,23 @@ export function hasNonPrintableAscii(bytes) {
|
|
|
56
56
|
}
|
|
57
57
|
return false;
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
/**
|
|
60
|
+
* What EDF field padding is, once, for the four modules that act on it.
|
|
61
|
+
*
|
|
62
|
+
* `trimEdfField` below states the rule and the reason: only 0x20 and 0x00, because a trailing TAB
|
|
63
|
+
* or CR is not padding but content the file should not contain, and hiding it here would hide it
|
|
64
|
+
* from `NON_ASCII_HEADER_FIELD`. `bytes/numbers.ts` trims the same padding before parsing a number
|
|
65
|
+
* and `header/fields.ts` finds a field's content bounds inside its own bytes, `header/variant.ts` decides whether the version block is `'0'` and
|
|
66
|
+
* seven pad bytes, and each had grown a byte-identical copy of these two lines with its own pair
|
|
67
|
+
* of constants.
|
|
68
|
+
*
|
|
69
|
+
* Three copies of a rule are three chances for two of them to disagree, and the disagreement would
|
|
70
|
+
* not look like one: a field would trim one way for display and another way for its numeric parse,
|
|
71
|
+
* so `NUMERIC_FIELD_NOT_LEFT_JUSTIFIED` would fire on a field `trimEdfField` had already called
|
|
72
|
+
* clean. `padding.test.ts` checks the rule across all 256 byte values from both public
|
|
73
|
+
* sides, and that every module acting on it imports this rather than growing another.
|
|
74
|
+
*/
|
|
75
|
+
export function isEdfPadding(code) {
|
|
60
76
|
return code === CHAR_SPACE || code === CHAR_NUL;
|
|
61
77
|
}
|
|
62
78
|
/**
|
|
@@ -75,9 +91,9 @@ function isPadding(code) {
|
|
|
75
91
|
export function trimEdfField(text) {
|
|
76
92
|
let start = 0;
|
|
77
93
|
let end = text.length;
|
|
78
|
-
while (end > start &&
|
|
94
|
+
while (end > start && isEdfPadding(text.charCodeAt(end - 1)))
|
|
79
95
|
end--;
|
|
80
|
-
while (start < end &&
|
|
96
|
+
while (start < end && isEdfPadding(text.charCodeAt(start)))
|
|
81
97
|
start++;
|
|
82
98
|
return text.slice(start, end);
|
|
83
99
|
}
|
package/dist/bytes/latin1.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latin1.js","sourceRoot":"","sources":["../../src/bytes/latin1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,2FAA2F;AAC3F,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB,oFAAoF;AACpF,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC;;;GAGG;AACH,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,SAAS,aAAa,CAAC,KAAiB;IACtC,mFAAmF;IACnF,+EAA+E;IAC/E,OAAO,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,KAA4B,CAAC,CAAC;AACvE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAiB;IAClD,IAAI,KAAK,CAAC,MAAM,IAAI,WAAW;QAAE,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;IAC7D,MAAM,KAAK,GAAa,EAAE,CAAC;I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
|
package/dist/bytes/numbers.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The two EDF numeric grammars.
|
|
3
3
|
*
|
|
4
|
-
* Layer 0. Imports nothing. Sole owner of turning an
|
|
4
|
+
* Layer 0. Imports one predicate from `latin1.ts` and nothing else. Sole owner of turning an
|
|
5
|
+
* 8-byte ASCII field into a number.
|
|
5
6
|
*
|
|
6
7
|
* The spec says these fields are ASCII, left-justified and space-padded. Real files break
|
|
7
8
|
* that in every way imaginable, so parsing reports *why* it failed rather than returning NaN
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/bytes/numbers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/bytes/numbers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,eAAe,GAAG,oBAAoB,GAAG,WAAW,CAAC;CAC3F;AA6DD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAE1D"}
|
package/dist/bytes/numbers.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The two EDF numeric grammars.
|
|
3
3
|
*
|
|
4
|
-
* Layer 0. Imports nothing. Sole owner of turning an
|
|
4
|
+
* Layer 0. Imports one predicate from `latin1.ts` and nothing else. Sole owner of turning an
|
|
5
|
+
* 8-byte ASCII field into a number.
|
|
5
6
|
*
|
|
6
7
|
* The spec says these fields are ASCII, left-justified and space-padded. Real files break
|
|
7
8
|
* that in every way imaginable, so parsing reports *why* it failed rather than returning NaN
|
|
8
9
|
* and leaving the caller to guess which diagnostic the bytes deserve: a comma decimal is
|
|
9
10
|
* fatal, a right-justified field is a warning, and `'20 48'` is neither of those.
|
|
10
11
|
*/
|
|
12
|
+
import { isEdfPadding } from './latin1.js';
|
|
11
13
|
const CHAR_NUL = 0x00;
|
|
12
|
-
const CHAR_SPACE = 0x20;
|
|
13
14
|
/** No decimal point and no exponent — see `parseEdfInteger`. */
|
|
14
15
|
const INTEGER_GRAMMAR = /^[+-]?[0-9]+$/;
|
|
15
16
|
/** `'.5'`, `'+22'`, `'1E3'` and `'-1.23E-4'` are all emitted by real writers. */
|
|
16
17
|
const NUMBER_GRAMMAR = /^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;
|
|
17
|
-
function isPadding(code) {
|
|
18
|
-
return code === CHAR_SPACE || code === CHAR_NUL;
|
|
19
|
-
}
|
|
20
18
|
function failure(raw, problem) {
|
|
21
19
|
return { ok: false, value: Number.NaN, raw, problem };
|
|
22
20
|
}
|
|
@@ -30,9 +28,9 @@ function containsNul(text) {
|
|
|
30
28
|
function parseField(raw, grammar, integral) {
|
|
31
29
|
let start = 0;
|
|
32
30
|
let end = raw.length;
|
|
33
|
-
while (start < end &&
|
|
31
|
+
while (start < end && isEdfPadding(raw.charCodeAt(start)))
|
|
34
32
|
start++;
|
|
35
|
-
while (end > start &&
|
|
33
|
+
while (end > start && isEdfPadding(raw.charCodeAt(end - 1)))
|
|
36
34
|
end--;
|
|
37
35
|
const core = raw.slice(start, end);
|
|
38
36
|
// Distinct from malformed: an all-space field is a writer omitting a value, not corrupting
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbers.js","sourceRoot":"","sources":["../../src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QG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,UAAU,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,OAAO,UAAU,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC"}
|
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.6.
|
|
112
|
+
export declare const VERSION = "0.6.15";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/header/fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/header/fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,KAAK,cAAc,EAAmC,MAAM,qBAAqB,CAAC;AAE3F,OAAO,EAAwB,aAAa,EAAoB,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAuB,KAAK,cAAc,EAAc,MAAM,6BAA6B,CAAC;AAEnG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,gFAAgF;AAChF,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,aAAa,CAAC;AAoC9D,0DAA0D;AAC1D,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAG3E;AAED,0DAA0D;AAC1D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAGtE;AA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,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,CAmE7E;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,CAOlF"}
|
package/dist/header/fields.js
CHANGED
|
@@ -10,13 +10,12 @@
|
|
|
10
10
|
* Raw first, always: a numeric field that failed to parse is exactly the case where the caller
|
|
11
11
|
* needs the bytes as written, so every field is exposed as text before it is interpreted.
|
|
12
12
|
*/
|
|
13
|
-
import {
|
|
13
|
+
import { hexBytes } from '../bytes/hex.js';
|
|
14
|
+
import { hasNonPrintableAscii, isEdfPadding } from '../bytes/latin1.js';
|
|
14
15
|
import { parseEdfInteger, parseEdfNumber } from '../bytes/numbers.js';
|
|
15
16
|
import { readAsciiField, sliceBytes } from '../bytes/view.js';
|
|
16
17
|
import { EDF_MAX_SIGNAL_COUNT, HEADER_FIELDS, TICKS_PER_SECOND } from '../constants.js';
|
|
17
18
|
import { fatalError } from '../diagnostics/collector.js';
|
|
18
|
-
const CHAR_NUL = 0x00;
|
|
19
|
-
const CHAR_SPACE = 0x20;
|
|
20
19
|
/** Enough bytes to recognise the problem in a message without pasting an 80-byte field. */
|
|
21
20
|
const RAW_EVIDENCE_MAX_BYTES = 16;
|
|
22
21
|
/** 10^7 is far below 2^53, so this conversion is exact. */
|
|
@@ -73,9 +72,6 @@ export function readRawHeaderFields(headerBytes) {
|
|
|
73
72
|
signalCount: read('signalCount'),
|
|
74
73
|
};
|
|
75
74
|
}
|
|
76
|
-
function isPadding(code) {
|
|
77
|
-
return code === CHAR_SPACE || code === CHAR_NUL;
|
|
78
|
-
}
|
|
79
75
|
/**
|
|
80
76
|
* The bounds of a field's content inside its own bytes, stripping the same padding
|
|
81
77
|
* `trimEdfField` does.
|
|
@@ -87,21 +83,12 @@ function isPadding(code) {
|
|
|
87
83
|
function contentBounds(raw) {
|
|
88
84
|
let start = 0;
|
|
89
85
|
let end = raw.length;
|
|
90
|
-
while (end > start &&
|
|
86
|
+
while (end > start && isEdfPadding(raw.charCodeAt(end - 1)))
|
|
91
87
|
end--;
|
|
92
|
-
while (start < end &&
|
|
88
|
+
while (start < end && isEdfPadding(raw.charCodeAt(start)))
|
|
93
89
|
start++;
|
|
94
90
|
return { start, end };
|
|
95
91
|
}
|
|
96
|
-
function hexBytes(bytes, from = 0) {
|
|
97
|
-
const shown = bytes.subarray(from, from + RAW_EVIDENCE_MAX_BYTES);
|
|
98
|
-
const parts = [];
|
|
99
|
-
for (const byte of shown)
|
|
100
|
-
parts.push(`0x${byte.toString(16).padStart(2, '0')}`);
|
|
101
|
-
const head = from > 0 ? '... ' : '';
|
|
102
|
-
const tail = from + shown.length < bytes.length ? ' ...' : '';
|
|
103
|
-
return head + parts.join(' ') + tail;
|
|
104
|
-
}
|
|
105
92
|
/** Index of the first byte outside printable ASCII, or 0 when the caller says there is one. */
|
|
106
93
|
function firstNonPrintable(bytes) {
|
|
107
94
|
for (let i = 0; i < bytes.length; i += 1) {
|
|
@@ -127,7 +114,7 @@ function evidenceWindow(content) {
|
|
|
127
114
|
const at = firstNonPrintable(content);
|
|
128
115
|
// A few bytes of lead-in, so the offending byte has context rather than sitting at the edge.
|
|
129
116
|
const from = Math.max(0, Math.min(at - 4, content.length - RAW_EVIDENCE_MAX_BYTES));
|
|
130
|
-
return { hex: hexBytes(content, Math.max(0, from)), at };
|
|
117
|
+
return { hex: hexBytes(content, Math.max(0, from), RAW_EVIDENCE_MAX_BYTES), at };
|
|
131
118
|
}
|
|
132
119
|
/**
|
|
133
120
|
* Report `NON_ASCII_HEADER_FIELD` for every fixed text field carrying a byte outside ASCII
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../src/header/fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAuB,eAAe,EAAE,cAAc,E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AAE,IAAI,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variant.d.ts","sourceRoot":"","sources":["../../src/header/variant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"variant.d.ts","sourceRoot":"","sources":["../../src/header/variant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAcH,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAW9C;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC;AAEtC,8FAA8F;AAC9F,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAUhF;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,CAAC,GAAG,CAAC,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,YAAY,GAAG,eAAe,CAAC;IACpD;uFACmF;IACnF,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB;wBACoB;IACpB,QAAQ,CAAC,cAAc,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACvD,gEAAgE;IAChE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,kFAAkF;IAClF,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;CACtC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,UAAU,GAAG,OAAO,CAOnE;AAED,iGAAiG;AACjG,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,UAAU,GAAG,OAAO,CAMnE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAKhF;AAgBD;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,GAAG,cAAc,CAgG3F"}
|
package/dist/header/variant.js
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* can be trusted to identify the family.
|
|
13
13
|
* - BDF's version block is not ASCII: byte 0 is 0xFF, then `'BIOSEMI'`.
|
|
14
14
|
*/
|
|
15
|
-
import {
|
|
15
|
+
import { hexBytes } from '../bytes/hex.js';
|
|
16
|
+
import { isEdfPadding, trimEdfField } from '../bytes/latin1.js';
|
|
16
17
|
import { readAsciiField, sliceBytes } from '../bytes/view.js';
|
|
17
18
|
import { BDF_ANNOTATIONS_LABEL, BDF_DIGITAL_MAX, BDF_DIGITAL_MIN, EDF_ANNOTATIONS_LABEL, EDF_DIGITAL_MAX, EDF_DIGITAL_MIN, HEADER_FIELDS, } from '../constants.js';
|
|
18
19
|
import { fatalError } from '../diagnostics/collector.js';
|
|
@@ -21,8 +22,6 @@ const EDF_VERSION_BYTE = 0x30;
|
|
|
21
22
|
/** Not ASCII. This single byte is what separates a BDF file from an EDF one. */
|
|
22
23
|
const BDF_VERSION_BYTE = 0xff;
|
|
23
24
|
const BDF_VERSION_TEXT = 'BIOSEMI';
|
|
24
|
-
const CHAR_NUL = 0x00;
|
|
25
|
-
const CHAR_SPACE = 0x20;
|
|
26
25
|
const EDF_BYTES_PER_SAMPLE = 2;
|
|
27
26
|
const BDF_BYTES_PER_SAMPLE = 3;
|
|
28
27
|
const RESERVED_MARKERS = [
|
|
@@ -44,7 +43,7 @@ export function isEdfVersionBlock(versionBytes) {
|
|
|
44
43
|
return false;
|
|
45
44
|
for (let i = 1; i < versionBytes.length; i++) {
|
|
46
45
|
const byte = versionBytes[i];
|
|
47
|
-
if (byte
|
|
46
|
+
if (byte === undefined || !isEdfPadding(byte))
|
|
48
47
|
return false;
|
|
49
48
|
}
|
|
50
49
|
return true;
|
|
@@ -74,12 +73,6 @@ export function reservedMarkerOf(reserved) {
|
|
|
74
73
|
function markerFamily(marker) {
|
|
75
74
|
return marker === 'EDF+C' || marker === 'EDF+D' ? 'EDF' : 'BDF';
|
|
76
75
|
}
|
|
77
|
-
function hexBytes(bytes) {
|
|
78
|
-
const parts = [];
|
|
79
|
-
for (const byte of bytes)
|
|
80
|
-
parts.push(byte.toString(16).padStart(2, '0'));
|
|
81
|
-
return parts.join(' ');
|
|
82
|
-
}
|
|
83
76
|
function variantOf(family, isPlus, continuity) {
|
|
84
77
|
if (!isPlus)
|
|
85
78
|
return family;
|
|
@@ -109,7 +102,7 @@ export function detectVariant(headerBytes, sink) {
|
|
|
109
102
|
code: 'NOT_AN_EDF_FILE',
|
|
110
103
|
message: `version field (8 bytes at offset ${HEADER_FIELDS.version.offset}) is ` +
|
|
111
104
|
`${JSON.stringify(raw)}, bytes ${hexBytes(versionBytes)}: this is neither EDF's ` +
|
|
112
|
-
`"0" followed by seven spaces nor BDF's
|
|
105
|
+
`"0" followed by seven spaces nor BDF's 0xff followed by "BIOSEMI". ` +
|
|
113
106
|
'EDF specification, header record bytes 0-7 (version of this data format). ' +
|
|
114
107
|
'Next: confirm the bytes are an uncompressed EDF or BDF recording — a gzip, zip or ' +
|
|
115
108
|
'vendor container has to be unpacked before edfcore sees it.',
|
|
@@ -118,7 +111,7 @@ export function detectVariant(headerBytes, sink) {
|
|
|
118
111
|
byteLength: HEADER_FIELDS.version.length,
|
|
119
112
|
rawBytes: versionBytes,
|
|
120
113
|
raw,
|
|
121
|
-
expected: '"0 " (EDF) or
|
|
114
|
+
expected: '"0 " (EDF) or 0xff "BIOSEMI" (BDF)',
|
|
122
115
|
actual: hexBytes(versionBytes),
|
|
123
116
|
specReference: 'EDF specification, header record bytes 0-7',
|
|
124
117
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variant.js","sourceRoot":"","sources":["../../src/header/variant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"variant.js","sourceRoot":"","sources":["../../src/header/variant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAuB,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG9E,qEAAqE;AACrE,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,gFAAgF;AAChF,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAEnC,MAAM,oBAAoB,GAAG,CAAU,CAAC;AACxC,MAAM,oBAAoB,GAAG,CAAU,CAAC;AAYxC,MAAM,gBAAgB,GAAiC;IACrD,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;CACR,CAAC;AA0BF;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,YAAwB;IACxD,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,gBAAgB;QAAE,OAAO,KAAK,CAAC;IACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7C,MAAM,IAAI,GAAG,YAAY,CAAC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C,QAAQ,CAAC,MAAM;YACzC,UAAU,EAAE,aAAa,CAAC,QAAQ,CAAC,MAAM;YACzC,GAAG,EAAE,WAAW;YAChB,QAAQ,EAAE,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,oBAAoB;YACjF,MAAM,EAAE,MAAM;YACd,aAAa,EAAE,4CAA4C;SAC5D,CAAC,CAAC;IACL,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,OAAO,CAAC;IAC1D,MAAM,UAAU,GAAG,MAAM,KAAK,OAAO,IAAI,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,YAAY,CAAC;IAE7F,OAAO;QACL,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC;QAC9C,MAAM;QACN,cAAc,EAAE,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,oBAAoB;QAC9E,UAAU;QACV,MAAM;QACN,cAAc,EAAE,MAAM;QACtB,gBAAgB,EAAE,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,qBAAqB;QAClF,mBAAmB,EAAE,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe;QACzE,mBAAmB,EAAE,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe;KAC1E,CAAC;AACJ,CAAC"}
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,49 @@ 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.15
|
|
10
|
+
|
|
11
|
+
- **Fixed** four copies of the definition of EDF field padding. `trimEdfField` states the rule and
|
|
12
|
+
why it is narrow — only 0x20 and 0x00, because a trailing TAB or CR is content the file should
|
|
13
|
+
not contain and stripping it there would hide it from `NON_ASCII_HEADER_FIELD` — and
|
|
14
|
+
`bytes/numbers.ts`, `header/fields.ts` and `header/variant.ts` each had a byte-identical copy of
|
|
15
|
+
the same two lines, with their own pair of constants. One owner now, in `bytes/latin1.ts`, which
|
|
16
|
+
is where the rule was already written down.
|
|
17
|
+
- Four copies are four chances for two of them to disagree, and the disagreement would not look
|
|
18
|
+
like one. A field would trim one way for display and another way for its numeric parse, so
|
|
19
|
+
`NUMERIC_FIELD_NOT_LEFT_JUSTIFIED` would fire on a field `trimEdfField` had already called clean,
|
|
20
|
+
or an evidence window would point at a byte the message says is not there. Nothing would name
|
|
21
|
+
padding as the cause.
|
|
22
|
+
- Same treatment `floorDiv` and `ceilDiv` got, and for the reason their docblock gives: one owner,
|
|
23
|
+
and a test saying every module doing the thing imports it.
|
|
24
|
+
- `padding.test.ts` also checks the direction that is invisible. A padding byte kept is visible —
|
|
25
|
+
the value is wrong, the label does not match. A CONTENT byte stripped is not: the field parses,
|
|
26
|
+
the label compares equal, and the diagnostic that would have named the byte never fires. So it
|
|
27
|
+
checks that no byte outside the number grammar survives being appended to a numeric field, over
|
|
28
|
+
all 256 values, which can only happen if something stripped it.
|
|
29
|
+
- No behaviour changed. The four copies agreed; this is about the fifth.
|
|
30
|
+
|
|
31
|
+
## 0.6.14
|
|
32
|
+
|
|
33
|
+
- **Fixed** two spellings of a byte in one sentence. `header/variant.ts` and `header/fields.ts`
|
|
34
|
+
each had a private `hexBytes`, under the same name, giving different answers — `44 6f 77` against
|
|
35
|
+
`0x4b 0x61 0x9f` — and the message the first one builds goes on to say "nor BDF's 0xFF followed
|
|
36
|
+
by BIOSEMI". Both spellings, three words apart, in the diagnostic a reader is likeliest to meet
|
|
37
|
+
first: `NOT_AN_EDF_FILE` is what a zip, a gzip or a text file earns.
|
|
38
|
+
- Without the prefix the list reads as a decimal number until the eye reaches a digit above 9,
|
|
39
|
+
which on that message is the fifth byte. `0x` per byte is what the author reached for the moment
|
|
40
|
+
a single byte had to be named, and a list is the same claim repeated. The literal in that
|
|
41
|
+
sentence is lower case now too, matching the bytes beside it.
|
|
42
|
+
- One renderer, in `src/bytes/hex.ts` at layer 0, replacing both copies. The ellipsis behaviour of
|
|
43
|
+
the surviving one is kept and stated: a caller pointing at the first bad byte forty bytes into an
|
|
44
|
+
eighty-byte identification field is showing a window, and a window that does not say so is a
|
|
45
|
+
claim about the whole field.
|
|
46
|
+
- The `rawBytes` dump under a diagnostic is deliberately not this. `30 20 20 20 |0 |` has an
|
|
47
|
+
ASCII column beside it and the columns are the point; a prefix on every byte would push it off
|
|
48
|
+
the line. Both are checked, so the difference is a decision rather than an oversight.
|
|
49
|
+
- The rule is enforced from `src/`: every `toString(16)` in the package is a byte becoming text,
|
|
50
|
+
there are three files with one, and each is named with what it is for. A fourth fails.
|
|
51
|
+
|
|
9
52
|
## 0.6.13
|
|
10
53
|
|
|
11
54
|
- **Added** `coveredSeconds` to `edfcore json`, beside the `spanSeconds` that was there alone.
|
package/package.json
CHANGED
package/src/bytes/hex.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bytes as hex, in prose.
|
|
3
|
+
*
|
|
4
|
+
* Layer 0. Imports nothing.
|
|
5
|
+
*
|
|
6
|
+
* Two modules had a private `hexBytes` under the same name and they disagreed about the answer.
|
|
7
|
+
* `header/fields.ts` wrote `0x4b 0x61 0x9f`; `header/variant.ts` wrote `44 6f 77`, in a sentence
|
|
8
|
+
* that goes on to say "nor BDF's 0xFF followed by BIOSEMI" — both spellings of a byte, three
|
|
9
|
+
* words apart, in one message. Without the prefix a short run reads as a decimal number until the
|
|
10
|
+
* eye reaches a digit above 9, which on the `NOT_AN_EDF_FILE` diagnostic is the fifth byte.
|
|
11
|
+
*
|
|
12
|
+
* `0x` per byte, because that message is the argument: the author reached for it the moment a
|
|
13
|
+
* single byte had to be named, and a list is the same claim repeated.
|
|
14
|
+
*
|
|
15
|
+
* This is NOT the renderer for the `rawBytes` block under a diagnostic. That one is a dump with an
|
|
16
|
+
* ASCII column beside it — `30 20 20 20 |0 |` — where the columns are the point and a prefix on
|
|
17
|
+
* every byte would push the ASCII off the line. It stays in `diagnostics/format.ts`, bare, and the
|
|
18
|
+
* difference is that one is prose and the other is a hex dump.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** How many bytes a message quotes before eliding. Enough to recognise the problem. */
|
|
22
|
+
const DEFAULT_MAX_BYTES = 16;
|
|
23
|
+
|
|
24
|
+
/** `'0x9f'`. */
|
|
25
|
+
export function hexByte(byte: number): string {
|
|
26
|
+
return `0x${byte.toString(16).padStart(2, '0')}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* `'0x4b 0x61 0x9f'`, from `from`, eliding with `...` on whichever side was cut.
|
|
31
|
+
*
|
|
32
|
+
* The ellipses are what stop a quoted run being read as the whole field: a caller pointing at the
|
|
33
|
+
* first bad byte 40 bytes into an 80-byte identification field is showing a window, and a window
|
|
34
|
+
* that does not say so is a claim about the field.
|
|
35
|
+
*/
|
|
36
|
+
export function hexBytes(
|
|
37
|
+
bytes: Uint8Array,
|
|
38
|
+
from: number = 0,
|
|
39
|
+
max: number = DEFAULT_MAX_BYTES,
|
|
40
|
+
): string {
|
|
41
|
+
const start = Math.max(0, from);
|
|
42
|
+
const shown = bytes.subarray(start, start + max);
|
|
43
|
+
const parts: string[] = [];
|
|
44
|
+
for (const byte of shown) parts.push(hexByte(byte));
|
|
45
|
+
const head = start > 0 ? '... ' : '';
|
|
46
|
+
const tail = start + shown.length < bytes.length ? ' ...' : '';
|
|
47
|
+
return head + parts.join(' ') + tail;
|
|
48
|
+
}
|
package/src/bytes/latin1.ts
CHANGED
|
@@ -61,7 +61,23 @@ export function hasNonPrintableAscii(bytes: Uint8Array): boolean {
|
|
|
61
61
|
return false;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
/**
|
|
65
|
+
* What EDF field padding is, once, for the four modules that act on it.
|
|
66
|
+
*
|
|
67
|
+
* `trimEdfField` below states the rule and the reason: only 0x20 and 0x00, because a trailing TAB
|
|
68
|
+
* or CR is not padding but content the file should not contain, and hiding it here would hide it
|
|
69
|
+
* from `NON_ASCII_HEADER_FIELD`. `bytes/numbers.ts` trims the same padding before parsing a number
|
|
70
|
+
* and `header/fields.ts` finds a field's content bounds inside its own bytes, `header/variant.ts` decides whether the version block is `'0'` and
|
|
71
|
+
* seven pad bytes, and each had grown a byte-identical copy of these two lines with its own pair
|
|
72
|
+
* of constants.
|
|
73
|
+
*
|
|
74
|
+
* Three copies of a rule are three chances for two of them to disagree, and the disagreement would
|
|
75
|
+
* not look like one: a field would trim one way for display and another way for its numeric parse,
|
|
76
|
+
* so `NUMERIC_FIELD_NOT_LEFT_JUSTIFIED` would fire on a field `trimEdfField` had already called
|
|
77
|
+
* clean. `padding.test.ts` checks the rule across all 256 byte values from both public
|
|
78
|
+
* sides, and that every module acting on it imports this rather than growing another.
|
|
79
|
+
*/
|
|
80
|
+
export function isEdfPadding(code: number): boolean {
|
|
65
81
|
return code === CHAR_SPACE || code === CHAR_NUL;
|
|
66
82
|
}
|
|
67
83
|
|
|
@@ -81,7 +97,7 @@ function isPadding(code: number): boolean {
|
|
|
81
97
|
export function trimEdfField(text: string): string {
|
|
82
98
|
let start = 0;
|
|
83
99
|
let end = text.length;
|
|
84
|
-
while (end > start &&
|
|
85
|
-
while (start < end &&
|
|
100
|
+
while (end > start && isEdfPadding(text.charCodeAt(end - 1))) end--;
|
|
101
|
+
while (start < end && isEdfPadding(text.charCodeAt(start))) start++;
|
|
86
102
|
return text.slice(start, end);
|
|
87
103
|
}
|
package/src/bytes/numbers.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The two EDF numeric grammars.
|
|
3
3
|
*
|
|
4
|
-
* Layer 0. Imports nothing. Sole owner of turning an
|
|
4
|
+
* Layer 0. Imports one predicate from `latin1.ts` and nothing else. Sole owner of turning an
|
|
5
|
+
* 8-byte ASCII field into a number.
|
|
5
6
|
*
|
|
6
7
|
* The spec says these fields are ASCII, left-justified and space-padded. Real files break
|
|
7
8
|
* that in every way imaginable, so parsing reports *why* it failed rather than returning NaN
|
|
@@ -9,6 +10,8 @@
|
|
|
9
10
|
* fatal, a right-justified field is a warning, and `'20 48'` is neither of those.
|
|
10
11
|
*/
|
|
11
12
|
|
|
13
|
+
import { isEdfPadding } from './latin1.js';
|
|
14
|
+
|
|
12
15
|
/**
|
|
13
16
|
* The outcome of parsing one numeric field.
|
|
14
17
|
*
|
|
@@ -30,7 +33,6 @@ export interface EdfNumberParse {
|
|
|
30
33
|
type EdfNumberProblem = EdfNumberParse['problem'];
|
|
31
34
|
|
|
32
35
|
const CHAR_NUL = 0x00;
|
|
33
|
-
const CHAR_SPACE = 0x20;
|
|
34
36
|
|
|
35
37
|
/** No decimal point and no exponent — see `parseEdfInteger`. */
|
|
36
38
|
const INTEGER_GRAMMAR = /^[+-]?[0-9]+$/;
|
|
@@ -38,10 +40,6 @@ const INTEGER_GRAMMAR = /^[+-]?[0-9]+$/;
|
|
|
38
40
|
/** `'.5'`, `'+22'`, `'1E3'` and `'-1.23E-4'` are all emitted by real writers. */
|
|
39
41
|
const NUMBER_GRAMMAR = /^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;
|
|
40
42
|
|
|
41
|
-
function isPadding(code: number): boolean {
|
|
42
|
-
return code === CHAR_SPACE || code === CHAR_NUL;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
43
|
function failure(raw: string, problem: EdfNumberProblem): EdfNumberParse {
|
|
46
44
|
return { ok: false, value: Number.NaN, raw, problem };
|
|
47
45
|
}
|
|
@@ -56,8 +54,8 @@ function containsNul(text: string): boolean {
|
|
|
56
54
|
function parseField(raw: string, grammar: RegExp, integral: boolean): EdfNumberParse {
|
|
57
55
|
let start = 0;
|
|
58
56
|
let end = raw.length;
|
|
59
|
-
while (start < end &&
|
|
60
|
-
while (end > start &&
|
|
57
|
+
while (start < end && isEdfPadding(raw.charCodeAt(start))) start++;
|
|
58
|
+
while (end > start && isEdfPadding(raw.charCodeAt(end - 1))) end--;
|
|
61
59
|
const core = raw.slice(start, end);
|
|
62
60
|
|
|
63
61
|
// Distinct from malformed: an all-space field is a writer omitting a value, not corrupting
|
package/src/constants.ts
CHANGED
package/src/header/fields.ts
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* needs the bytes as written, so every field is exposed as text before it is interpreted.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { hexBytes } from '../bytes/hex.js';
|
|
15
|
+
import { hasNonPrintableAscii, isEdfPadding } from '../bytes/latin1.js';
|
|
15
16
|
import { type EdfNumberParse, parseEdfInteger, parseEdfNumber } from '../bytes/numbers.js';
|
|
16
17
|
import { readAsciiField, sliceBytes } from '../bytes/view.js';
|
|
17
18
|
import { EDF_MAX_SIGNAL_COUNT, HEADER_FIELDS, TICKS_PER_SECOND } from '../constants.js';
|
|
@@ -22,9 +23,6 @@ import type { EdfRawHeaderFields } from '../types.js';
|
|
|
22
23
|
/** The ten fixed fields. Same keys as `EdfRawHeaderFields`, by construction. */
|
|
23
24
|
export type FixedHeaderFieldName = keyof typeof HEADER_FIELDS;
|
|
24
25
|
|
|
25
|
-
const CHAR_NUL = 0x00;
|
|
26
|
-
const CHAR_SPACE = 0x20;
|
|
27
|
-
|
|
28
26
|
/** Enough bytes to recognise the problem in a message without pasting an 80-byte field. */
|
|
29
27
|
const RAW_EVIDENCE_MAX_BYTES = 16;
|
|
30
28
|
|
|
@@ -89,10 +87,6 @@ export function readRawHeaderFields(headerBytes: Uint8Array): EdfRawHeaderFields
|
|
|
89
87
|
};
|
|
90
88
|
}
|
|
91
89
|
|
|
92
|
-
function isPadding(code: number): boolean {
|
|
93
|
-
return code === CHAR_SPACE || code === CHAR_NUL;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
90
|
/**
|
|
97
91
|
* The bounds of a field's content inside its own bytes, stripping the same padding
|
|
98
92
|
* `trimEdfField` does.
|
|
@@ -104,20 +98,11 @@ function isPadding(code: number): boolean {
|
|
|
104
98
|
function contentBounds(raw: string): { readonly start: number; readonly end: number } {
|
|
105
99
|
let start = 0;
|
|
106
100
|
let end = raw.length;
|
|
107
|
-
while (end > start &&
|
|
108
|
-
while (start < end &&
|
|
101
|
+
while (end > start && isEdfPadding(raw.charCodeAt(end - 1))) end--;
|
|
102
|
+
while (start < end && isEdfPadding(raw.charCodeAt(start))) start++;
|
|
109
103
|
return { start, end };
|
|
110
104
|
}
|
|
111
105
|
|
|
112
|
-
function hexBytes(bytes: Uint8Array, from = 0): string {
|
|
113
|
-
const shown = bytes.subarray(from, from + RAW_EVIDENCE_MAX_BYTES);
|
|
114
|
-
const parts: string[] = [];
|
|
115
|
-
for (const byte of shown) parts.push(`0x${byte.toString(16).padStart(2, '0')}`);
|
|
116
|
-
const head = from > 0 ? '... ' : '';
|
|
117
|
-
const tail = from + shown.length < bytes.length ? ' ...' : '';
|
|
118
|
-
return head + parts.join(' ') + tail;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
106
|
/** Index of the first byte outside printable ASCII, or 0 when the caller says there is one. */
|
|
122
107
|
function firstNonPrintable(bytes: Uint8Array): number {
|
|
123
108
|
for (let i = 0; i < bytes.length; i += 1) {
|
|
@@ -143,7 +128,7 @@ function evidenceWindow(content: Uint8Array): { readonly hex: string; readonly a
|
|
|
143
128
|
const at = firstNonPrintable(content);
|
|
144
129
|
// A few bytes of lead-in, so the offending byte has context rather than sitting at the edge.
|
|
145
130
|
const from = Math.max(0, Math.min(at - 4, content.length - RAW_EVIDENCE_MAX_BYTES));
|
|
146
|
-
return { hex: hexBytes(content, Math.max(0, from)), at };
|
|
131
|
+
return { hex: hexBytes(content, Math.max(0, from), RAW_EVIDENCE_MAX_BYTES), at };
|
|
147
132
|
}
|
|
148
133
|
|
|
149
134
|
/**
|
package/src/header/variant.ts
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* - BDF's version block is not ASCII: byte 0 is 0xFF, then `'BIOSEMI'`.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { hexBytes } from '../bytes/hex.js';
|
|
17
|
+
import { isEdfPadding, trimEdfField } from '../bytes/latin1.js';
|
|
17
18
|
import { readAsciiField, sliceBytes } from '../bytes/view.js';
|
|
18
19
|
import {
|
|
19
20
|
BDF_ANNOTATIONS_LABEL,
|
|
@@ -33,9 +34,6 @@ const EDF_VERSION_BYTE = 0x30;
|
|
|
33
34
|
const BDF_VERSION_BYTE = 0xff;
|
|
34
35
|
const BDF_VERSION_TEXT = 'BIOSEMI';
|
|
35
36
|
|
|
36
|
-
const CHAR_NUL = 0x00;
|
|
37
|
-
const CHAR_SPACE = 0x20;
|
|
38
|
-
|
|
39
37
|
const EDF_BYTES_PER_SAMPLE = 2 as const;
|
|
40
38
|
const BDF_BYTES_PER_SAMPLE = 3 as const;
|
|
41
39
|
|
|
@@ -92,7 +90,7 @@ export function isEdfVersionBlock(versionBytes: Uint8Array): boolean {
|
|
|
92
90
|
if (versionBytes[0] !== EDF_VERSION_BYTE) return false;
|
|
93
91
|
for (let i = 1; i < versionBytes.length; i++) {
|
|
94
92
|
const byte = versionBytes[i];
|
|
95
|
-
if (byte
|
|
93
|
+
if (byte === undefined || !isEdfPadding(byte)) return false;
|
|
96
94
|
}
|
|
97
95
|
return true;
|
|
98
96
|
}
|
|
@@ -122,12 +120,6 @@ function markerFamily(marker: EdfReservedMarker): EdfFamily {
|
|
|
122
120
|
return marker === 'EDF+C' || marker === 'EDF+D' ? 'EDF' : 'BDF';
|
|
123
121
|
}
|
|
124
122
|
|
|
125
|
-
function hexBytes(bytes: Uint8Array): string {
|
|
126
|
-
const parts: string[] = [];
|
|
127
|
-
for (const byte of bytes) parts.push(byte.toString(16).padStart(2, '0'));
|
|
128
|
-
return parts.join(' ');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
123
|
function variantOf(
|
|
132
124
|
family: EdfFamily,
|
|
133
125
|
isPlus: boolean,
|
|
@@ -170,7 +162,7 @@ export function detectVariant(headerBytes: Uint8Array, sink: DiagnosticSink): Ed
|
|
|
170
162
|
message:
|
|
171
163
|
`version field (8 bytes at offset ${HEADER_FIELDS.version.offset}) is ` +
|
|
172
164
|
`${JSON.stringify(raw)}, bytes ${hexBytes(versionBytes)}: this is neither EDF's ` +
|
|
173
|
-
`"0" followed by seven spaces nor BDF's
|
|
165
|
+
`"0" followed by seven spaces nor BDF's 0xff followed by "BIOSEMI". ` +
|
|
174
166
|
'EDF specification, header record bytes 0-7 (version of this data format). ' +
|
|
175
167
|
'Next: confirm the bytes are an uncompressed EDF or BDF recording — a gzip, zip or ' +
|
|
176
168
|
'vendor container has to be unpacked before edfcore sees it.',
|
|
@@ -179,7 +171,7 @@ export function detectVariant(headerBytes: Uint8Array, sink: DiagnosticSink): Ed
|
|
|
179
171
|
byteLength: HEADER_FIELDS.version.length,
|
|
180
172
|
rawBytes: versionBytes,
|
|
181
173
|
raw,
|
|
182
|
-
expected: '"0 " (EDF) or
|
|
174
|
+
expected: '"0 " (EDF) or 0xff "BIOSEMI" (BDF)',
|
|
183
175
|
actual: hexBytes(versionBytes),
|
|
184
176
|
specReference: 'EDF specification, header record bytes 0-7',
|
|
185
177
|
});
|