@echecs/pgn 3.6.1 → 3.7.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/CHANGELOG.md +30 -0
- package/README.md +25 -0
- package/dist/grammar.cjs +366 -256
- package/dist/grammar.cjs.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.js +55 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,36 @@ and this project adheres to
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [3.7.0] - 2026-03-15
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `onWarning` option for `parse()` and `stream()`: fires once per missing STR
|
|
16
|
+
tag. Emitted in alphabetical key order: `Black`, `Date`, `Event`, `Result`,
|
|
17
|
+
`Round`, `Site`, `White`.
|
|
18
|
+
- `ParseWarning` is now an exported type with the same shape as `ParseError`.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- `parse()` and `stream()` now strip a UTF-8 BOM (`\uFEFF`) at the start of
|
|
23
|
+
input. Chessbase and Windows editors commonly produce BOM-prefixed PGN files
|
|
24
|
+
that previously failed silently.
|
|
25
|
+
- Tag values containing escaped quotes (`\"`) or escaped backslashes (`\\`) now
|
|
26
|
+
parse correctly per PGN spec section 7.
|
|
27
|
+
- Games with no tag pairs (bare move list + result) now parse correctly per PGN
|
|
28
|
+
spec section 8.1 ("zero or more tag pairs"). These games return `meta: {}`.
|
|
29
|
+
|
|
30
|
+
## [3.6.2] - 2026-03-15
|
|
31
|
+
|
|
32
|
+
### Performance
|
|
33
|
+
|
|
34
|
+
- `pairMoves`: replaced `delete move.number; delete move.long` with an explicit
|
|
35
|
+
clean output object constructed from only the known public `Move` fields.
|
|
36
|
+
`delete` was fragmenting V8 hidden classes across move objects with different
|
|
37
|
+
optional fields (e.g. promotion moves), causing megamorphic deoptimisation and
|
|
38
|
+
GC pressure. `promotion.pgn` gap vs `pgn-parser` restored from 1.26x to 1.06x;
|
|
39
|
+
`long.pgn` and `twic.pgn` also improved.
|
|
40
|
+
|
|
11
41
|
## [3.6.1] - 2026-03-15
|
|
12
42
|
|
|
13
43
|
### Fixed
|
package/README.md
CHANGED
|
@@ -135,6 +135,31 @@ for await (const game of stream(chunks, { onError: console.error })) {
|
|
|
135
135
|
> (truncated input). Incomplete input at end-of-stream is treated as expected
|
|
136
136
|
> behaviour, not a parse error.
|
|
137
137
|
|
|
138
|
+
### Warnings
|
|
139
|
+
|
|
140
|
+
Pass `onWarning` to observe spec-compliance issues that do not prevent parsing:
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import parse, { type ParseWarning } from '@echecs/pgn';
|
|
144
|
+
|
|
145
|
+
const games = parse(input, {
|
|
146
|
+
onWarning(warn: ParseWarning) {
|
|
147
|
+
console.warn(warn.message);
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`onWarning` receives a `ParseWarning` with the same fields as `ParseError`:
|
|
153
|
+
`message`, `offset`, `line`, `column`.
|
|
154
|
+
|
|
155
|
+
Currently fires for: missing STR tags (`Event`, `Site`, `Date`, `Round`,
|
|
156
|
+
`White`, `Black`, `Result`). Warnings are emitted in alphabetical key order.
|
|
157
|
+
|
|
158
|
+
The same option is accepted by `stream()`.
|
|
159
|
+
|
|
160
|
+
> **Note:** `onWarning` position fields (`offset`, `line`, `column`) are nominal
|
|
161
|
+
> placeholders — missing tags have no source location.
|
|
162
|
+
|
|
138
163
|
### PGN object
|
|
139
164
|
|
|
140
165
|
```typescript
|