rapier-math 2.7.0 → 3.0.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 CHANGED
@@ -1,10 +1,24 @@
1
1
  # Changelog
2
2
 
3
- ## 2.6.1
3
+ ## 3.0.0 (2026-10-31)
4
+
5
+ - Breaking: types: `renderWithMathML` and `renderAccessible` take no `preview` or `caret`.
6
+ - Types: `markdown-it` takes extra `env` fields; `rehype` works without a `VFile`.
7
+ - Types: the classic `RapierMath` global is a `var`.
8
+ - `node src/tools/build-math.mjs --package .` refreshes source receipts and checksums.
9
+
10
+ ## 2.7.0 (2026-10-20)
11
+
12
+ - `\verb` and `\verb*` set verbatim text.
13
+ - `\mathchoice` picks its branch by display or script style, in SVG and MathML.
14
+ - Prescripts render as `mmultiscripts` in MathML.
15
+ - Monospace punctuation, visible space and the sharp s use Latin Modern Mono outlines.
16
+
17
+ ## 2.6.1 (2026-10-18)
4
18
 
5
19
  - Use the font's ellipses and correct extensible arrow sizes.
6
20
  - Match amscd row spacing and under-accent attachment points.
7
- - Correct chemistry labels, state spacing and superscripts. Keep chemistry arrows at least 2 em wide in MathML.
21
+ - Correct chemistry labels, state spacing and superscripts.
22
+ - Keep chemistry arrows at least 2 em wide in MathML.
8
23
  - Include the Latin Modern Mono sharp s outline for monospace text.
9
24
  - Preserve exact math fence source in shared Markdown rules.
10
-
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Rapier Math
2
2
 
3
- Offline TeX formulas as SVG or structured MathML. Embedded Latin Modern outlines for SVG; font-free native MathML. Synchronous, with no runtime downloads.
4
-
5
- ## Use
3
+ TeX to SVG or MathML, synchronously and offline. Latin Modern outlines are embedded in the SVG, so there are no font requests and no runtime downloads. No dependencies.
6
4
 
7
5
  ```sh
8
6
  npm install rapier-math
@@ -10,41 +8,32 @@ npm install rapier-math
10
8
 
11
9
  ```js
12
10
  import {renderToString} from 'rapier-math';
13
- const svg = renderToString(String.raw`\frac{a}{b}`);
11
+
12
+ const svg = renderToString(String.raw`\frac{-b\pm\sqrt{b^2-4ac}}{2a}`);
14
13
  ```
15
14
 
16
- For a browser script, load [dist/rapier-math.js](dist/rapier-math.js) and use
17
- `globalThis.RapierMath`. The native ESM entry is [dist/index.mjs](dist/index.mjs).
18
- For one-file copying or inline-script embedding, use the classic file above. The native
19
- ESM entry imports relative `src/math/` modules: install/serve the whole package or bundle
20
- that import; copying only `dist/index.mjs` is insufficient. A CDN must retain that graph
21
- or bundle it. Formula rendering stays synchronous and offline after its chosen script
22
- or module graph has loaded.
15
+ Try it in [Rapier](https://rapier.website): type \$x^2\$.
23
16
 
24
- The SVG entry and classic script include the font. Use `rapier-math/mathml` for font-free MathML,
25
- `rapier-math/combined` for one-parse SVG and MathML, or `rapier-math/accessible` with its stylesheet
26
- for host composition. All return synchronously. Type declarations accompany the runtime files.
17
+ ## Entry points
27
18
 
28
- - [API and integration guide](docs/api.md)
29
- - [MathML, accessibility and source contracts](docs/semantics.md)
30
- - [Runnable examples](examples/README.md)
31
- - [Font source and regeneration](docs/font-source.md)
32
- - [Changes](CHANGELOG.md)
19
+ | Import | Gives |
20
+ | --- | --- |
21
+ | `rapier-math` | SVG with the font embedded |
22
+ | `rapier-math/mathml` | Native MathML, no font |
23
+ | `rapier-math/combined` | SVG and MathML from one parse |
24
+ | `rapier-math/accessible` | Accessible output for your own layout, with `rapier-math/accessible.css` |
25
+ | `rapier-math/markdown-it`, `rapier-math/rehype` | Markdown integrations; your parser stays in charge |
26
+ | `rapier-math/stream` | Formulas in streamed text, such as model output |
27
+ | `rapier-math/classic` | [dist/rapier-math.js](dist/rapier-math.js): one file, `globalThis.RapierMath` |
33
28
 
34
- ## Develop
29
+ Types ship with every entry. The classic file is the one to copy or inline: 742,684 bytes, 421,701 gzipped, font included. The ES modules import `src/math/`, so serve or bundle the whole package rather than copying `dist/index.mjs` alone.
35
30
 
36
- The classic script and native entry points live in `dist/`. Native entries import the editable
37
- modules in `src/math/` directly, sharing one parser without a duplicate generated renderer. Build
38
- tools live in `src/tools/`. Optional adapters have one source copy in `dist/`. Examples and documentation each
39
- have their own directory. Only the current release is kept in this checkout.
31
+ [API](docs/api.md) · [MathML and accessibility](docs/semantics.md) · [Examples](examples/README.md) · [Font](docs/font-source.md) · [Changes](CHANGELOG.md)
40
32
 
41
- Run `node src/tools/build-math.mjs --package .` to regenerate the classic and ESM files from source.
33
+ ## Build
42
34
 
43
- ## License
35
+ `node src/tools/build-math.mjs --package .` regenerates `dist/` from `src/math/`.
44
36
 
45
- The renderer and adapters are MIT-licensed. Embedded Latin Modern outlines and metrics are
46
- licensed under the GUST Font License. [LICENSE](LICENSE) contains both complete grants.
47
- [Component provenance](docs/math-components.json) and [source hashes](docs/math-resources.json)
48
- travel with the package.
37
+ ## License
49
38
 
50
- Version 2.7.0. Classic payload: 742684 bytes; gzip (level 9): 421702 bytes.
39
+ Code: MIT. Embedded Latin Modern outlines and metrics: GUST Font License. Both are in [LICENSE](LICENSE). [Components](docs/math-components.json) and [source hashes](docs/math-resources.json) ship with the package.
@@ -6,5 +6,5 @@ export interface AccessibleResult extends SemanticRenderResult {
6
6
  /** Authored links use visible native MathML, with standalone SVG still returned. */
7
7
  presentation: 'svg-mathml' | 'mathml' | 'refused';
8
8
  }
9
- /** Include accessible.css when inserting the combined SVG/MathML composition. */
10
- export function renderAccessible(source: unknown, options?: RenderOptions): AccessibleResult;
9
+ /** Include accessible.css when inserting the composition. Incomplete source is not repaired. */
10
+ export function renderAccessible(source: unknown, options?: Omit<RenderOptions, 'preview' | 'caret'>): AccessibleResult;
package/dist/classic.d.ts CHANGED
@@ -3,7 +3,7 @@ import type RapierMath from './index.js';
3
3
  import type {toMathML} from './mathml.js';
4
4
  import type {renderWithMathML} from './combined.js';
5
5
  declare global {
6
- const RapierMath: typeof import('./index.js').default & Readonly<{
6
+ var RapierMath: typeof import('./index.js').default & Readonly<{
7
7
  toMathML: typeof toMathML; renderWithMathML: typeof renderWithMathML;
8
8
  }>;
9
9
  }
@@ -1,4 +1,4 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  import type {RenderOptions, SemanticRenderResult} from './index.js';
3
- /** Render SVG and MathML from one admitted parse; check each result independently. */
4
- export function renderWithMathML(source: unknown, options?: RenderOptions): SemanticRenderResult;
3
+ /** Render SVG and MathML from one strict parse; incomplete source is not repaired. */
4
+ export function renderWithMathML(source: unknown, options?: Omit<RenderOptions, 'preview' | 'caret'>): SemanticRenderResult;
package/dist/index.mjs CHANGED
@@ -2,6 +2,6 @@
2
2
  import {parseMathTex as parse} from '../src/math/parser.js';
3
3
  import {renderMath as render, mathRenderToString as renderToString} from '../src/math/api.js';
4
4
  import {mathFit as fit, mathObserve as observe} from '../src/math/browser.js';
5
- const version = "2.7.0";
5
+ const version = "3.0.0";
6
6
  export {version, parse, render, renderToString, fit, observe};
7
7
  export default Object.freeze({version, parse, render, renderToString, fit, observe});
@@ -4,7 +4,7 @@ import type {MathSession} from './stream.js';
4
4
  export interface IntegrationOptions {
5
5
  /** Insert SVG with assistive MathML. Include accessible.css. */
6
6
  accessible?: boolean;
7
- /** With an explicit session, plain-data options and screen are captured once per document render. */
7
+ /** With a session, plain-data options are captured once per render. preview/caret apply only without accessible output. */
8
8
  renderOptions?: RenderOptions;
9
9
  /** Per document. Default 1024. Exhaustion leaves subsequent math as source. */
10
10
  maxFormulas?: number;
@@ -6,6 +6,8 @@ import type {MathError} from './index.js';
6
6
  import type {MathSession} from './stream.js';
7
7
  export interface MarkdownMathOptions extends DelimiterOptions, IntegrationOptions {}
8
8
  export interface MarkdownMathEnv {
9
+ /** The Markdown host and its other plug-ins may carry additional document data. */
10
+ [key: string | symbol]: unknown;
9
11
  /** Optional formula reuse for one message; each render still owns fresh budgets. */
10
12
  rapierMathSession?: MathSession;
11
13
  rapierMathErrors?: {source: string; errors: MathError[]}[];
@@ -4451,7 +4451,7 @@ function mathRenderWithMathML(source, options = {}) {
4451
4451
 
4452
4452
  // SPDX-License-Identifier: MIT
4453
4453
  globalThis.RapierMath=Object.freeze({
4454
- version:'2.7.0', parse:parseMathTex,
4454
+ version:'3.0.0', parse:parseMathTex,
4455
4455
  render:renderMath, renderToString:mathRenderToString,
4456
4456
  fit:mathFit, observe:mathObserve,
4457
4457
  toMathML:mathToMathML, renderWithMathML:mathRenderWithMathML,
package/dist/rehype.d.ts CHANGED
@@ -10,4 +10,4 @@ declare module 'vfile' {
10
10
  }
11
11
  }
12
12
  /** Install after sanitization. Recognizes remark-rehype math code nodes. */
13
- export default function rehypeRapierMath(options?: IntegrationOptions): (tree: Root, file: VFile) => void;
13
+ export default function rehypeRapierMath(options?: IntegrationOptions): (tree: Root, file?: VFile) => void;
package/docs/api.md CHANGED
@@ -286,12 +286,13 @@ visits, 4 Mi outline characters and 8 Mi composed SVG characters. Complete retur
286
286
  alternatives and diagnostics, is capped at 24 Mi UTF-16 code units. These are output/work bounds, not peak
287
287
  heap or device-memory claims. A later good render has a fresh budget.
288
288
 
289
- SVG labels contain raw TeX, not semantic MathML or mathematical speech. Ordinary equations are images in
290
- the accessibility tree. Equations containing authored HTTP(S) links use a group so the links remain exposed;
291
- each link is keyboard-focusable and labeled with its destination. Keep the editable source or a separate
292
- copy-source affordance in your host. Full semantic navigation, speech and screen-reader parity are not
293
- provided. A future semantic serializer needs an explicit AST-to-MathML mapping and assistive-technology
294
- evaluation; adding a raw TeX label does not satisfy that requirement.
289
+ SVG-only output labels contain raw TeX, not MathML or mathematical speech. Ordinary SVG equations are images in
290
+ the accessibility tree. Equations with authored HTTP(S) links use a group so the links remain exposed,
291
+ keyboard-focusable and labeled with their destinations. Use `rapier-math/mathml` for structured MathML or
292
+ `rapier-math/accessible` with `rapier-math/accessible.css` for MathML-backed presentation; see
293
+ [MathML and accessibility](semantics.md). Keep editable source or a copy-source control in the host.
294
+ Mathematical speech, navigation and screen-reader parity still need host testing. Improving SVG-only
295
+ accessibility remains future work.
295
296
 
296
297
  ## Security and deployment
297
298
 
@@ -332,8 +333,9 @@ For a classic script, use `dist/rapier-math.js` and `globalThis.RapierMath`.
332
333
  The payload includes the font: it is not a few-kilobyte renderer. Payload counts below describe this
333
334
  build, not npm tarball size or a comparison against another library.
334
335
 
335
- Run `node tests/verify.mjs` and `node tests/check.mjs` from this checkout. The carried source rebuilds the exact
336
- classic payload and ESM module; receipts also cover the adapters, declarations and examples. Follow
336
+ Run `node src/tools/build-math.mjs --package .` from the installed package directory. The carried source rebuilds the
337
+ classic payload and ESM modules and updates their source receipt and component provenance. The receipt also covers
338
+ the adapters, declarations and examples. Follow
337
339
  `docs/font-source.md` to regenerate font data. License and font provenance are carried with every build.
338
340
 
339
341
  Verified-claim scope: synchronous self-contained formula rendering; opt-in Markdown integrations; bounded
@@ -42,10 +42,10 @@ The generated asset uses Python 3.12, fontTools 4.61.1, Brotli 1.1.0 and zlib 1.
42
42
 
43
43
  ```sh
44
44
  python -m pip install fonttools==4.61.1 Brotli==1.1.0
45
- python repo/math/build-font.py
45
+ python src/math/build-font.py
46
46
  ```
47
47
 
48
- In the standalone package, run `python src/math/build-font.py`. To regenerate without network access, supply the
48
+ To regenerate without network access, supply the
49
49
  exact inputs with `--font`, `--mono-font`, `--hook-font`, `--license`, `--lppl` and `--text-font`. `--out` selects the JavaScript path and writes
50
50
  the combined license beside it. When available, the generator uses the editor's local Geist font.
51
51
 
@@ -78,7 +78,7 @@ The typesetter retains its existing ordinary-letter fallback for those lowercase
78
78
  the absent calligraphic forms. Its unencoded glyphs contain no alternative lowercase script alphabet.
79
79
 
80
80
  Different zlib versions can encode the same exact data differently. The package budget is measured with
81
- Node 22.23.3 by `tools/build-math.mjs`; the packed stream always decodes to the original coordinates and metrics.
81
+ Node 22.23.3 by `src/tools/build-math.mjs`; the packed stream always decodes to the original coordinates and metrics.
82
82
 
83
83
  ## Height and optical forms
84
84
 
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" role="img" aria-label="x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}" data-rapier-math="display" data-math-lines="1" data-math-natural-width="9.053744" width="9.053744em" height="2.3804em" viewBox="-25 -1658.4 9053.744444 2380.4" style="font-size:1.229698em;max-width:100%;height:auto;vertical-align:-0.722em;fill-opacity:1;stroke-opacity:1" fill="#fff"><title>x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}</title><g transform="scale(1000)"><path d="M527 376C527 428 468 442 434 442C376 442 341 389 329 366C304 432 250 442 221 442C117 442 60 313 60 288C60 278 72 278 72 278C80 278 83 280 85 289C119 395 185 420 219 420C238 420 273 411 273 353C273 322 256 255 219 115C203 53 168 11 124 11C118 11 95 11 74 24C99 29 121 50 121 78C121 105 99 113 84 113C54 113 29 87 29 55C29 9 79 -11 123 -11C189 -11 225 59 228 65C240 28 276 -11 336 -11C439 -11 496 118 496 143C496 153 487 153 484 153C475 153 473 149 471 142C438 35 370 11 338 11C299 11 283 43 283 77C283 99 289 121 300 165L334 302C340 328 363 420 433 420C438 420 462 420 483 407C455 402 435 377 435 353C435 337 446 318 473 318C495 318 527 336 527 376Z" transform="scale(0.001 -0.001)"/><g transform="translate(0.849778 0)"><path d="M722 347C722 358 713 367 702 367H76C65 367 56 358 56 347C56 336 65 327 76 327H702C713 327 722 336 722 347ZM722 153C722 164 713 173 702 173H76C65 173 56 164 56 153C56 142 65 133 76 133H702C713 133 722 142 722 153Z" transform="scale(0.001 -0.001)"/></g><g transform="translate(1.905556 0)"><g transform="translate(0.12 -0.677)"><path d="M722 250C722 261 713 270 702 270H76C65 270 56 261 56 250C56 239 65 230 76 230H702C713 230 722 239 722 250Z" transform="scale(0.001 -0.001)"/><g transform="translate(0.778 0)"><path d="M415 282C415 373 362 442 282 442C236 442 195 413 165 382L239 683C239 683 239 694 226 694C203 694 130 686 104 684C96 683 85 682 85 664C85 652 94 652 109 652C157 652 159 645 159 635C159 628 150 594 145 573L63 247C51 197 47 181 47 146C47 51 100 -11 174 -11C292 -11 415 138 415 282ZM343 326C343 267 310 152 292 114C259 47 213 11 174 11C140 11 107 38 107 112C107 131 107 150 123 213L145 305C151 327 151 329 160 340C209 405 254 420 280 420C316 420 343 390 343 326Z" transform="scale(0.001 -0.001)"/></g><g transform="translate(1.443222 0)"><path d="M722 -64C722 -53 713 -44 702 -44H409V230H702C713 230 722 239 722 250C722 261 713 270 702 270H409V563C409 574 400 583 389 583C378 583 369 574 369 563V270H76C65 270 56 261 56 250C56 239 65 230 76 230H369V-44H76C65 -44 56 -53 56 -64C56 -75 65 -84 76 -84H702C713 -84 722 -75 722 -64Z" transform="scale(0.001 -0.001)"/></g><g transform="translate(2.443444 0)"><g transform="translate(0 -0.8764)"><path d="M853 20C853 31 845 40 833 40C821 40 818 33 812 21L389 -855L211 -463C207 -455 205 -449 198 -449C195 -449 193 -449 184 -457L85 -532C74 -541 73 -542 73 -546C73 -553 77 -557 83 -557C86 -557 88 -557 97 -549L149 -510L347 -945C353 -959 355 -960 366 -960C382 -960 384 -956 391 -941L847 3C852 14 853 15 853 20Z" transform="scale(0.001 -0.001)"/></g><g transform="translate(0.833 0)"><path d="M415 282C415 373 362 442 282 442C236 442 195 413 165 382L239 683C239 683 239 694 226 694C203 694 130 686 104 684C96 683 85 682 85 664C85 652 94 652 109 652C157 652 159 645 159 635C159 628 150 594 145 573L63 247C51 197 47 181 47 146C47 51 100 -11 174 -11C292 -11 415 138 415 282ZM343 326C343 267 310 152 292 114C259 47 213 11 174 11C140 11 107 38 107 112C107 131 107 150 123 213L145 305C151 327 151 329 160 340C209 405 254 420 280 420C316 420 343 390 343 326Z" transform="scale(0.001 -0.001)"/><g transform="translate(0.443 -0.289)"><path d="M505 182H471C468 160 458 101 445 91C437 85 360 85 346 85H162C267 178 302 206 362 253C436 312 505 374 505 469C505 590 399 664 271 664C147 664 63 577 63 485C63 434 106 429 116 429C140 429 169 446 169 482C169 500 162 535 110 535C141 606 209 628 256 628C356 628 408 550 408 469C408 382 346 313 314 277L73 39C63 30 63 28 63 0H475Z" transform="scale(0.0007 -0.0007)"/></g><g transform="translate(1.119522 0)"><path d="M722 250C722 261 713 270 702 270H76C65 270 56 261 56 250C56 239 65 230 76 230H702C713 230 722 239 722 250Z" transform="scale(0.001 -0.001)"/></g><g transform="translate(2.119744 0)"><path d="M471 165V196H371V651C371 671 371 677 355 677C346 677 343 677 335 665L28 196V165H294V78C294 42 292 31 218 31H197V0C238 3 290 3 332 3C374 3 427 3 468 0V31H447C373 31 371 42 371 78V165ZM300 196H56L300 569Z" transform="scale(0.001 -0.001)"/></g><g transform="translate(2.619744 0)"><path d="M498 143C498 153 489 153 486 153C476 153 475 149 472 135C455 70 437 11 396 11C369 11 366 37 366 57C366 79 368 87 379 131L401 221L437 361C444 389 444 391 444 395C444 412 432 422 415 422C391 422 376 400 373 378C355 415 326 442 281 442C164 442 40 295 40 149C40 55 95 -11 173 -11C193 -11 243 -7 303 64C311 22 346 -11 394 -11C429 -11 452 12 468 44C485 80 498 143 498 143ZM361 332C361 326 359 320 358 315L308 119C303 101 303 99 288 82C244 27 203 11 175 11C125 11 111 66 111 105C111 155 143 278 166 324C197 383 242 420 282 420C347 420 361 338 361 332Z" transform="scale(0.001 -0.001)"/></g><g transform="translate(3.148744 0)"><path d="M430 107C430 113 424 120 418 120C413 120 411 118 405 110C326 11 217 11 205 11C142 11 115 60 115 120C115 161 135 258 169 320C200 377 255 420 310 420C344 420 382 407 396 380C380 380 366 380 352 366C336 351 334 334 334 327C334 303 352 292 371 292C400 292 427 316 427 356C427 405 380 442 309 442C174 442 41 299 41 158C41 68 99 -11 203 -11C346 -11 430 95 430 107Z" transform="scale(0.001 -0.001)"/></g></g><g transform="translate(0.833 0)"><path data-math-rule="" d="M0 -0.9164H3.581744v0.04H0Z"/></g></g></g><g transform="translate(3.034594 0.686)"><path d="M449 174H424C419 144 412 100 402 85C395 77 329 77 307 77H127L233 180C389 318 449 372 449 472C449 586 359 666 237 666C124 666 50 574 50 485C50 429 100 429 103 429C120 429 155 441 155 482C155 508 137 534 102 534C94 534 92 534 89 533C112 598 166 635 224 635C315 635 358 554 358 472C358 392 308 313 253 251L61 37C50 26 50 24 50 0H421Z" transform="scale(0.001 -0.001)"/><g transform="translate(0.5 0)"><path d="M498 143C498 153 489 153 486 153C476 153 475 149 472 135C455 70 437 11 396 11C369 11 366 37 366 57C366 79 368 87 379 131L401 221L437 361C444 389 444 391 444 395C444 412 432 422 415 422C391 422 376 400 373 378C355 415 326 442 281 442C164 442 40 295 40 149C40 55 95 -11 173 -11C193 -11 243 -7 303 64C311 22 346 -11 394 -11C429 -11 452 12 468 44C485 80 498 143 498 143ZM361 332C361 326 359 320 358 315L308 119C303 101 303 99 288 82C244 27 203 11 175 11C125 11 111 66 111 105C111 155 143 278 166 324C197 383 242 420 282 420C347 420 361 338 361 332Z" transform="scale(0.001 -0.001)"/></g></g><g transform="translate(0.12 0)"><path data-math-rule="" d="M0 -0.27H6.858189v0.04H0Z"/></g></g></g></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" role="img" aria-label="x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}" data-rapier-math="display" data-math-lines="1" data-math-natural-width="9.053744" width="9.053744em" height="2.3804em" viewBox="-25 -1658.4 9053.744444 2380.4" style="font-size:1.229698em;max-width:100%;height:auto;vertical-align:-0.722em;fill-opacity:1;stroke-opacity:1" fill="#000"><title>x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}</title><g transform="scale(1000)"><path d="M527 376C527 428 468 442 434 442C376 442 341 389 329 366C304 432 250 442 221 442C117 442 60 313 60 288C60 278 72 278 72 278C80 278 83 280 85 289C119 395 185 420 219 420C238 420 273 411 273 353C273 322 256 255 219 115C203 53 168 11 124 11C118 11 95 11 74 24C99 29 121 50 121 78C121 105 99 113 84 113C54 113 29 87 29 55C29 9 79 -11 123 -11C189 -11 225 59 228 65C240 28 276 -11 336 -11C439 -11 496 118 496 143C496 153 487 153 484 153C475 153 473 149 471 142C438 35 370 11 338 11C299 11 283 43 283 77C283 99 289 121 300 165L334 302C340 328 363 420 433 420C438 420 462 420 483 407C455 402 435 377 435 353C435 337 446 318 473 318C495 318 527 336 527 376Z" transform="scale(0.001 -0.001)"/><g transform="translate(0.849778 0)"><path d="M722 347C722 358 713 367 702 367H76C65 367 56 358 56 347C56 336 65 327 76 327H702C713 327 722 336 722 347ZM722 153C722 164 713 173 702 173H76C65 173 56 164 56 153C56 142 65 133 76 133H702C713 133 722 142 722 153Z" transform="scale(0.001 -0.001)"/></g><g transform="translate(1.905556 0)"><g transform="translate(0.12 -0.677)"><path d="M722 250C722 261 713 270 702 270H76C65 270 56 261 56 250C56 239 65 230 76 230H702C713 230 722 239 722 250Z" transform="scale(0.001 -0.001)"/><g transform="translate(0.778 0)"><path d="M415 282C415 373 362 442 282 442C236 442 195 413 165 382L239 683C239 683 239 694 226 694C203 694 130 686 104 684C96 683 85 682 85 664C85 652 94 652 109 652C157 652 159 645 159 635C159 628 150 594 145 573L63 247C51 197 47 181 47 146C47 51 100 -11 174 -11C292 -11 415 138 415 282ZM343 326C343 267 310 152 292 114C259 47 213 11 174 11C140 11 107 38 107 112C107 131 107 150 123 213L145 305C151 327 151 329 160 340C209 405 254 420 280 420C316 420 343 390 343 326Z" transform="scale(0.001 -0.001)"/></g><g transform="translate(1.443222 0)"><path d="M722 -64C722 -53 713 -44 702 -44H409V230H702C713 230 722 239 722 250C722 261 713 270 702 270H409V563C409 574 400 583 389 583C378 583 369 574 369 563V270H76C65 270 56 261 56 250C56 239 65 230 76 230H369V-44H76C65 -44 56 -53 56 -64C56 -75 65 -84 76 -84H702C713 -84 722 -75 722 -64Z" transform="scale(0.001 -0.001)"/></g><g transform="translate(2.443444 0)"><g transform="translate(0 -0.8764)"><path d="M853 20C853 31 845 40 833 40C821 40 818 33 812 21L389 -855L211 -463C207 -455 205 -449 198 -449C195 -449 193 -449 184 -457L85 -532C74 -541 73 -542 73 -546C73 -553 77 -557 83 -557C86 -557 88 -557 97 -549L149 -510L347 -945C353 -959 355 -960 366 -960C382 -960 384 -956 391 -941L847 3C852 14 853 15 853 20Z" transform="scale(0.001 -0.001)"/></g><g transform="translate(0.833 0)"><path d="M415 282C415 373 362 442 282 442C236 442 195 413 165 382L239 683C239 683 239 694 226 694C203 694 130 686 104 684C96 683 85 682 85 664C85 652 94 652 109 652C157 652 159 645 159 635C159 628 150 594 145 573L63 247C51 197 47 181 47 146C47 51 100 -11 174 -11C292 -11 415 138 415 282ZM343 326C343 267 310 152 292 114C259 47 213 11 174 11C140 11 107 38 107 112C107 131 107 150 123 213L145 305C151 327 151 329 160 340C209 405 254 420 280 420C316 420 343 390 343 326Z" transform="scale(0.001 -0.001)"/><g transform="translate(0.443 -0.289)"><path d="M505 182H471C468 160 458 101 445 91C437 85 360 85 346 85H162C267 178 302 206 362 253C436 312 505 374 505 469C505 590 399 664 271 664C147 664 63 577 63 485C63 434 106 429 116 429C140 429 169 446 169 482C169 500 162 535 110 535C141 606 209 628 256 628C356 628 408 550 408 469C408 382 346 313 314 277L73 39C63 30 63 28 63 0H475Z" transform="scale(0.0007 -0.0007)"/></g><g transform="translate(1.119522 0)"><path d="M722 250C722 261 713 270 702 270H76C65 270 56 261 56 250C56 239 65 230 76 230H702C713 230 722 239 722 250Z" transform="scale(0.001 -0.001)"/></g><g transform="translate(2.119744 0)"><path d="M471 165V196H371V651C371 671 371 677 355 677C346 677 343 677 335 665L28 196V165H294V78C294 42 292 31 218 31H197V0C238 3 290 3 332 3C374 3 427 3 468 0V31H447C373 31 371 42 371 78V165ZM300 196H56L300 569Z" transform="scale(0.001 -0.001)"/></g><g transform="translate(2.619744 0)"><path d="M498 143C498 153 489 153 486 153C476 153 475 149 472 135C455 70 437 11 396 11C369 11 366 37 366 57C366 79 368 87 379 131L401 221L437 361C444 389 444 391 444 395C444 412 432 422 415 422C391 422 376 400 373 378C355 415 326 442 281 442C164 442 40 295 40 149C40 55 95 -11 173 -11C193 -11 243 -7 303 64C311 22 346 -11 394 -11C429 -11 452 12 468 44C485 80 498 143 498 143ZM361 332C361 326 359 320 358 315L308 119C303 101 303 99 288 82C244 27 203 11 175 11C125 11 111 66 111 105C111 155 143 278 166 324C197 383 242 420 282 420C347 420 361 338 361 332Z" transform="scale(0.001 -0.001)"/></g><g transform="translate(3.148744 0)"><path d="M430 107C430 113 424 120 418 120C413 120 411 118 405 110C326 11 217 11 205 11C142 11 115 60 115 120C115 161 135 258 169 320C200 377 255 420 310 420C344 420 382 407 396 380C380 380 366 380 352 366C336 351 334 334 334 327C334 303 352 292 371 292C400 292 427 316 427 356C427 405 380 442 309 442C174 442 41 299 41 158C41 68 99 -11 203 -11C346 -11 430 95 430 107Z" transform="scale(0.001 -0.001)"/></g></g><g transform="translate(0.833 0)"><path data-math-rule="" d="M0 -0.9164H3.581744v0.04H0Z"/></g></g></g><g transform="translate(3.034594 0.686)"><path d="M449 174H424C419 144 412 100 402 85C395 77 329 77 307 77H127L233 180C389 318 449 372 449 472C449 586 359 666 237 666C124 666 50 574 50 485C50 429 100 429 103 429C120 429 155 441 155 482C155 508 137 534 102 534C94 534 92 534 89 533C112 598 166 635 224 635C315 635 358 554 358 472C358 392 308 313 253 251L61 37C50 26 50 24 50 0H421Z" transform="scale(0.001 -0.001)"/><g transform="translate(0.5 0)"><path d="M498 143C498 153 489 153 486 153C476 153 475 149 472 135C455 70 437 11 396 11C369 11 366 37 366 57C366 79 368 87 379 131L401 221L437 361C444 389 444 391 444 395C444 412 432 422 415 422C391 422 376 400 373 378C355 415 326 442 281 442C164 442 40 295 40 149C40 55 95 -11 173 -11C193 -11 243 -7 303 64C311 22 346 -11 394 -11C429 -11 452 12 468 44C485 80 498 143 498 143ZM361 332C361 326 359 320 358 315L308 119C303 101 303 99 288 82C244 27 203 11 175 11C125 11 111 66 111 105C111 155 143 278 166 324C197 383 242 420 282 420C347 420 361 338 361 332Z" transform="scale(0.001 -0.001)"/></g></g><g transform="translate(0.12 0)"><path data-math-rule="" d="M0 -0.27H6.858189v0.04H0Z"/></g></g></g></svg>
@@ -2,10 +2,10 @@
2
2
  "spdxVersion": "SPDX-2.3",
3
3
  "dataLicense": "CC0-1.0",
4
4
  "SPDXID": "SPDXRef-DOCUMENT",
5
- "name": "rapier-math-2.7.0",
6
- "documentNamespace": "https://rapier.website/spdx/rapier-math-2.7.0-cb1c935e84744d41d516c03607a8383ff801ecfc6acdfd63b2eb38be0bc20d80",
5
+ "name": "rapier-math-3.0.0",
6
+ "documentNamespace": "https://rapier.website/spdx/rapier-math-3.0.0-2825714cd36ab23353d28c7947666e28dee9a9bdbf62b10fd0a8ab342e69ee47",
7
7
  "creationInfo": {
8
- "created": "2026-10-20T08:46:16.000Z",
8
+ "created": "2026-10-31T05:08:43.000Z",
9
9
  "creators": [
10
10
  "Tool: rapier-math-components",
11
11
  "Organization: rapier.website"
@@ -15,17 +15,17 @@
15
15
  {
16
16
  "name": "rapier-math",
17
17
  "SPDXID": "SPDXRef-rapier-math",
18
- "versionInfo": "2.7.0",
18
+ "versionInfo": "3.0.0",
19
19
  "downloadLocation": "NOASSERTION",
20
20
  "filesAnalyzed": false,
21
21
  "licenseConcluded": "MIT AND LicenseRef-GUST-Font-License",
22
22
  "licenseDeclared": "MIT AND LicenseRef-GUST-Font-License",
23
23
  "copyrightText": "NOASSERTION",
24
- "sourceInfo": "Verified public build inputs: docs/math-resources.json (SHA-256 5b417cfed5f3d1d1c1ca28d6419821129d2832b31284b6ba53a72a1205589bf7).",
24
+ "sourceInfo": "Verified public build inputs: docs/math-resources.json (SHA-256 d5d9b6b5c5320d97caf82ea1a3415def25b3ddfe1bb9f1a58d5f28b55aaa0bf8).",
25
25
  "checksums": [
26
26
  {
27
27
  "algorithm": "SHA256",
28
- "checksumValue": "cb1c935e84744d41d516c03607a8383ff801ecfc6acdfd63b2eb38be0bc20d80"
28
+ "checksumValue": "2825714cd36ab23353d28c7947666e28dee9a9bdbf62b10fd0a8ab342e69ee47"
29
29
  }
30
30
  ]
31
31
  },
@@ -1,12 +1,12 @@
1
1
  {
2
- "bundle": "rapier-math-2.7.0.js",
2
+ "bundle": "rapier-math-3.0.0.js",
3
3
  "packageBundle": "dist/rapier-math.js",
4
- "version": "2.7.0",
4
+ "version": "3.0.0",
5
5
  "license": "MIT AND LicenseRef-GUST-Font-License",
6
6
  "bytes": 742684,
7
- "gzipBytes": 421702,
8
- "sha256": "cb1c935e84744d41d516c03607a8383ff801ecfc6acdfd63b2eb38be0bc20d80",
9
- "sha384": "1rjhOOw690Mr3aVXwRTPlwQO2atMrWHY8Rm3nZ+SZRrm5mB9HK5FkY6ZWCDYtgzv",
7
+ "gzipBytes": 421701,
8
+ "sha256": "2825714cd36ab23353d28c7947666e28dee9a9bdbf62b10fd0a8ab342e69ee47",
9
+ "sha384": "t7kbxrkzF1YSQz1jItY5cbSBCUaO5aV0PPaQ3tgWvIXXS2jRL9Oq/6TLazcPCpJr",
10
10
  "sources": [
11
11
  {
12
12
  "file": "math/font.js",
@@ -90,7 +90,7 @@
90
90
  "file": "math/classic.js",
91
91
  "packageFile": "src/math/classic.js",
92
92
  "bytes": 269,
93
- "sha256": "ecc0aabe977198d013ebcbcfd739910e55cbb28303af5db97eb31333d7de4189"
93
+ "sha256": "c4d5fcbf318dd8ecb10871f67826111c2a436ca17f9065491e462eb721229857"
94
94
  }
95
95
  ],
96
96
  "recipe": [
@@ -103,8 +103,8 @@
103
103
  {
104
104
  "file": "math/FONT-SOURCE.md",
105
105
  "packageFile": "docs/font-source.md",
106
- "bytes": 12702,
107
- "sha256": "7d0d20d5982b5d4378a29aea803199df5f7618f88670f2c3b25545f7932db23d"
106
+ "bytes": 12641,
107
+ "sha256": "9827c9ab8e0b600f3b8646b0611819b68b52dc60b526aa39992a22111d9847eb"
108
108
  },
109
109
  {
110
110
  "file": "math/FONT-LICENSE.txt",
@@ -115,8 +115,8 @@
115
115
  {
116
116
  "file": "tools/build-math.mjs",
117
117
  "packageFile": "src/tools/build-math.mjs",
118
- "bytes": 10967,
119
- "sha256": "11c6f7d5ab962d24ff70a5497c23ccefd624f1add20b8840d8bb0c6f085ecbf9"
118
+ "bytes": 11595,
119
+ "sha256": "fc9b00db8882ebcc4fa316efd8a8749dab444926fc0f994b1e4ec32ffcd9ae18"
120
120
  },
121
121
  {
122
122
  "file": "math/LICENSE-MIT",
@@ -139,26 +139,26 @@
139
139
  {
140
140
  "file": "math/package-readme.mjs",
141
141
  "packageFile": "src/math/package-readme.mjs",
142
- "bytes": 2458,
143
- "sha256": "ed03aa38d7ed3d01fbab6836d2827ee0b2565bca4e998af7172e2da940611495"
142
+ "bytes": 1949,
143
+ "sha256": "a852b158999d03ec6a4b2e479cb49bf246e9b8f14d4b54a86d67e32bf7b58bb1"
144
144
  },
145
145
  {
146
146
  "file": "math/README.md",
147
147
  "packageFile": "docs/api.md",
148
- "bytes": 24062,
149
- "sha256": "59963d4156549530b73d15d2dc66d4f7cec108e4767856785605e71fe1f6162a"
148
+ "bytes": 24187,
149
+ "sha256": "636243ac6b4f9a5687359eaaa95abdd79ecc145a11ca0f9b393ff82166777bb4"
150
150
  },
151
151
  {
152
152
  "file": "math/CHANGELOG.md",
153
153
  "packageFile": "CHANGELOG.md",
154
- "bytes": 389,
155
- "sha256": "621ffa760f4ebeb72c7882e46caf8c8cb815abde50cd98d123da5a34ea105397"
154
+ "bytes": 1024,
155
+ "sha256": "4adf7ef95a37ca26ea3adfd98a6b2bef77120fa4b0cb2c45ad6eaa6c9d53b345"
156
156
  },
157
157
  {
158
158
  "file": "math/SEMANTICS.md",
159
159
  "packageFile": "docs/semantics.md",
160
- "bytes": 18282,
161
- "sha256": "98984313665984aaa29fd816cc7b79691deac7450d5d76b8e7dc0f79b575e2cf"
160
+ "bytes": 18413,
161
+ "sha256": "e0cd9370ffe88a38658bd4de193002429ad202b772655a0e8c7104e426ba1519"
162
162
  }
163
163
  ],
164
164
  "components": [
@@ -266,14 +266,14 @@
266
266
  {
267
267
  "file": "math/combined.d.ts",
268
268
  "packageFile": "dist/combined.d.ts",
269
- "bytes": 286,
270
- "sha256": "5f3837d9bb0c095365a387ce88ae0c4bccd538ba75d08152a2a540c51278d7d7"
269
+ "bytes": 313,
270
+ "sha256": "b48989c14ea7d290add0c98ad1758c223f6d0d6a0049170b4d7cff90d44f9698"
271
271
  },
272
272
  {
273
273
  "file": "math/accessible.d.ts",
274
274
  "packageFile": "dist/accessible.d.ts",
275
- "bytes": 582,
276
- "sha256": "d2d2285c084c19b87dae6c1a538b4711233dffd50098fa08bac3b8d41aa43cd3"
275
+ "bytes": 624,
276
+ "sha256": "9cef1d88ea6c2e3c44d3cc439fb49adca42726e3c7abfe5f24a684c02e12e56a"
277
277
  },
278
278
  {
279
279
  "file": "math/index.d.ts",
@@ -284,8 +284,8 @@
284
284
  {
285
285
  "file": "math/classic.d.ts",
286
286
  "packageFile": "dist/classic.d.ts",
287
- "bytes": 349,
288
- "sha256": "0415467509e356a5372caa0778586242de8cc0405aaa5b9db62b231d2f81de39"
287
+ "bytes": 347,
288
+ "sha256": "ce6c4d57a671e473a5a66c36a79b612f220954f49a624b22694311ca46a4be25"
289
289
  },
290
290
  {
291
291
  "file": "math/delimiters.d.ts",
@@ -296,20 +296,20 @@
296
296
  {
297
297
  "file": "math/integration.d.ts",
298
298
  "packageFile": "dist/integration.d.ts",
299
- "bytes": 1029,
300
- "sha256": "8f69318a973d37f8491799c12c28ce66e9512e7f1b09009fa0601be86bdea649"
299
+ "bytes": 1051,
300
+ "sha256": "c606cc0e2c693b42af5131c0fb59e6689ece569b7b51c920fe3e78ed56f6dd8f"
301
301
  },
302
302
  {
303
303
  "file": "math/markdown-it.d.ts",
304
304
  "packageFile": "dist/markdown-it.d.ts",
305
- "bytes": 693,
306
- "sha256": "b4bf25c7a72ebb30876b66a4ce21ce293eeae3f08b8ea7962c4589a1aa7f4b80"
305
+ "bytes": 814,
306
+ "sha256": "55059b5a4228edbfdb125f3e4c28c373bfe3b4feefb853dc34dc2299e05e734e"
307
307
  },
308
308
  {
309
309
  "file": "math/rehype.d.ts",
310
310
  "packageFile": "dist/rehype.d.ts",
311
- "bytes": 560,
312
- "sha256": "be3d05097c37c72cff12b46503cadfcf24efac396cb4398707136aa267f0a827"
311
+ "bytes": 561,
312
+ "sha256": "6cd2fc33830af68d4c995124977e64a6c07b073afcb680ab7d1dde96e2d9dc0c"
313
313
  },
314
314
  {
315
315
  "file": "math/stream.d.ts",
package/docs/semantics.md CHANGED
@@ -29,6 +29,9 @@ Unicode character absent from the embedded SVG font. A successful SVG does not t
29
29
  refusal into success. `renderToString` returns SVG. The complete classic `RapierMath` object
30
30
  also exposes `toMathML` and `renderWithMathML`.
31
31
 
32
+ `preview` and `caret` apply only to the SVG `render` and `renderToString` methods.
33
+ Combined and accessible rendering use the strict parse and never repair incomplete expressions.
34
+
32
35
  The font-free entry exports `parse` for inspection as well. Parse results are ordinary,
33
36
  detached data: changing a returned tree has no effect on subsequent renders. There is no
34
37
  public API accepting arbitrary or modified trees for serialization. Local macros are
@@ -223,6 +226,6 @@ These steps are manual acceptance, not an automated pass:
223
226
  explore the expression at different granularities and verify nested math within a link.
224
227
  Qualify macOS/Safari separately with its actual VoiceOver controls.
225
228
 
226
- Run `node tests/semantics.mjs` from the package for the focused structural/source corpus.
227
- This optional development check requires Python 3 with `lxml` for strict XML verification;
228
- the runtime package itself has no dependency on Python, `lxml` or an XML parser.
229
+ Run `node examples/semantic.mjs` from the installed package directory to inspect a formula's
230
+ MathML, parse tree, status and work counters. The runtime package has no dependency on Python,
231
+ `lxml` or an XML parser.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapier-math",
3
- "version": "2.7.0",
3
+ "version": "3.0.0",
4
4
  "description": "Self-contained offline LaTeX-to-SVG rendering with Latin Modern outlines, optional Markdown integrations and streaming helpers.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  globalThis.RapierMath=Object.freeze({
3
- version:'2.7.0', parse:parseMathTex,
3
+ version:'3.0.0', parse:parseMathTex,
4
4
  render:renderMath, renderToString:mathRenderToString,
5
5
  fit:mathFit, observe:mathObserve,
6
6
  toMathML:mathToMathML, renderWithMathML:mathRenderWithMathML,
@@ -2,9 +2,7 @@
2
2
  export function mathReadme(resources) {
3
3
  return `# Rapier Math
4
4
 
5
- Offline TeX formulas as SVG or structured MathML. Embedded Latin Modern outlines for SVG; font-free native MathML. Synchronous, with no runtime downloads.
6
-
7
- ## Use
5
+ TeX to SVG or MathML, synchronously and offline. Latin Modern outlines are embedded in the SVG, so there are no font requests and no runtime downloads. No dependencies.
8
6
 
9
7
  \`\`\`sh
10
8
  npm install rapier-math
@@ -12,43 +10,34 @@ npm install rapier-math
12
10
 
13
11
  \`\`\`js
14
12
  import {renderToString} from 'rapier-math';
15
- const svg = renderToString(String.raw\`\\frac{a}{b}\`);
13
+
14
+ const svg = renderToString(String.raw\`\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}\`);
16
15
  \`\`\`
17
16
 
18
- For a browser script, load [${resources.packageBundle}](${resources.packageBundle}) and use
19
- \`globalThis.RapierMath\`. The native ESM entry is [dist/index.mjs](dist/index.mjs).
20
- For one-file copying or inline-script embedding, use the classic file above. The native
21
- ESM entry imports relative \`src/math/\` modules: install/serve the whole package or bundle
22
- that import; copying only \`dist/index.mjs\` is insufficient. A CDN must retain that graph
23
- or bundle it. Formula rendering stays synchronous and offline after its chosen script
24
- or module graph has loaded.
17
+ Try it in [Rapier](https://rapier.website): type \\$x^2\\$.
25
18
 
26
- The SVG entry and classic script include the font. Use \`rapier-math/mathml\` for font-free MathML,
27
- \`rapier-math/combined\` for one-parse SVG and MathML, or \`rapier-math/accessible\` with its stylesheet
28
- for host composition. All return synchronously. Type declarations accompany the runtime files.
19
+ ## Entry points
29
20
 
30
- - [API and integration guide](docs/api.md)
31
- - [MathML, accessibility and source contracts](docs/semantics.md)
32
- - [Runnable examples](examples/README.md)
33
- - [Font source and regeneration](docs/font-source.md)
34
- - [Changes](CHANGELOG.md)
21
+ | Import | Gives |
22
+ | --- | --- |
23
+ | \`rapier-math\` | SVG with the font embedded |
24
+ | \`rapier-math/mathml\` | Native MathML, no font |
25
+ | \`rapier-math/combined\` | SVG and MathML from one parse |
26
+ | \`rapier-math/accessible\` | Accessible output for your own layout, with \`rapier-math/accessible.css\` |
27
+ | \`rapier-math/markdown-it\`, \`rapier-math/rehype\` | Markdown integrations; your parser stays in charge |
28
+ | \`rapier-math/stream\` | Formulas in streamed text, such as model output |
29
+ | \`rapier-math/classic\` | [${resources.packageBundle}](${resources.packageBundle}): one file, \`globalThis.RapierMath\` |
35
30
 
36
- ## Develop
31
+ Types ship with every entry. The classic file is the one to copy or inline: ${resources.bytes.toLocaleString('en-US')} bytes, ${resources.gzipBytes.toLocaleString('en-US')} gzipped, font included. The ES modules import \`src/math/\`, so serve or bundle the whole package rather than copying \`dist/index.mjs\` alone.
37
32
 
38
- The classic script and native entry points live in \`dist/\`. Native entries import the editable
39
- modules in \`src/math/\` directly, sharing one parser without a duplicate generated renderer. Build
40
- tools live in \`src/tools/\`. Optional adapters have one source copy in \`dist/\`. Examples and documentation each
41
- have their own directory. Only the current release is kept in this checkout.
33
+ [API](docs/api.md) · [MathML and accessibility](docs/semantics.md) · [Examples](examples/README.md) · [Font](docs/font-source.md) · [Changes](CHANGELOG.md)
42
34
 
43
- Run \`node src/tools/build-math.mjs --package .\` to regenerate the classic and ESM files from source.
35
+ ## Build
44
36
 
45
- ## License
37
+ \`node src/tools/build-math.mjs --package .\` regenerates \`dist/\` from \`src/math/\`.
46
38
 
47
- The renderer and adapters are MIT-licensed. Embedded Latin Modern outlines and metrics are
48
- licensed under the GUST Font License. [LICENSE](LICENSE) contains both complete grants.
49
- [Component provenance](docs/math-components.json) and [source hashes](docs/math-resources.json)
50
- travel with the package.
39
+ ## License
51
40
 
52
- Version ${resources.version}. Classic payload: ${resources.bytes} bytes; gzip (level 9): ${resources.gzipBytes} bytes.
41
+ Code: MIT. Embedded Latin Modern outlines and metrics: GUST Font License. Both are in [LICENSE](LICENSE). [Components](docs/math-components.json) and [source hashes](docs/math-resources.json) ship with the package.
53
42
  `;
54
43
  }
@@ -12,7 +12,7 @@ import {mathModules, mathClassicSource} from '../math/package-build.mjs';
12
12
  import {mathReadme} from '../math/package-readme.mjs';
13
13
 
14
14
  const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
15
- export const MATH_VERSION = '2.7.0';
15
+ export const MATH_VERSION = '3.0.0';
16
16
  export const MATH_BUNDLE = 'rapier-math-' + MATH_VERSION + '.js';
17
17
  export const MATH_SOURCES = ['font.js', 'symbols.js', 'parser.js', 'source.js', 'variants.js', 'layout.js', 'fallbacks.js', 'responsive.js', 'api.js', 'browser.js', 'mathml.js', 'semantic-api.js', 'combined.js', 'classic.js'].map(name => 'math/' + name);
18
18
  export const MATH_RECIPE = ['math/build-font.py', 'math/FONT-SOURCE.md', 'math/FONT-LICENSE.txt', 'math/package-verify.mjs', 'tools/build-math.mjs', 'math/LICENSE-MIT', 'math/adoption-verify.mjs', 'math/package-build.mjs', 'math/package-layout.mjs', 'math/package-check.mjs', 'math/package-readme.mjs', 'math/README.md', 'math/CHANGELOG.md', 'math/SEMANTICS.md', 'math/semantic-verify.mjs', 'math/typeset-verify.mjs'];
@@ -69,6 +69,9 @@ export async function assembleMath({root = ROOT, packageLayout = false} = {}) {
69
69
  const bytes = await read(file);
70
70
  inputs.push({file, bytes, text: bytes.toString('utf8')});
71
71
  }
72
+ // Keep the self-contained browser API's version equal to the package identity.
73
+ const classicVersion = /version:\s*'([^']+)'/.exec(inputs.find(input => input.file === 'math/classic.js')?.text || '')?.[1];
74
+ if (classicVersion !== MATH_VERSION) throw new Error('The classic Math API version differs from its package version');
72
75
  const license = await fontLicense(root, packageLayout);
73
76
  if (!inputs[0].text.includes(FONT.copyright) || !inputs[0].text.includes('Complete license: FONT-LICENSE.txt')) throw new Error('The embedded math font is missing its notice');
74
77
  // The single-file bundle travels alone, so it carries both complete licenses itself.
@@ -80,6 +83,7 @@ export async function assembleMath({root = ROOT, packageLayout = false} = {}) {
80
83
  const sha256 = digest(bytes), sha384 = digest(bytes, 'sha384', 'base64');
81
84
  const recipe = [];
82
85
  for (const file of MATH_RECIPE) {
86
+ if (packageLayout && mathPackagePath(file).startsWith('tests/')) continue;
83
87
  const content = await read(file);
84
88
  recipe.push({file, packageFile: mathPackagePath(file), bytes: content.length, sha256: digest(content)});
85
89
  }
@@ -108,11 +112,14 @@ export async function buildMath({root = ROOT, updatePins = true, packageLayout =
108
112
  await mkdir(dirname(resolve(root, file)), {recursive: true});
109
113
  await writeFile(resolve(root, file), content);
110
114
  }
111
- await writeFile(resolve(root, 'docs/math-resources.json'), JSON.stringify(resources, null, 2) + '\n');
115
+ const publicReceipt = JSON.stringify(resources, null, 2) + '\n';
116
+ await writeFile(resolve(root, 'docs/math-resources.json'), publicReceipt);
112
117
  await writeFile(resolve(root, 'README.md'), mathReadme(resources));
113
118
  const sbomPath = resolve(root, 'docs/math-components.json');
114
119
  const sbom = JSON.parse(await readFile(sbomPath, 'utf8'));
115
120
  sbom.packages.find(item => item.name === 'rapier-math').checksums = [{algorithm: 'SHA256', checksumValue: resources.sha256}];
121
+ sbom.packages.find(item => item.name === 'rapier-math').sourceInfo =
122
+ 'Verified public build inputs: docs/math-resources.json (SHA-256 ' + digest(publicReceipt) + ').';
116
123
  sbom.documentNamespace = 'https://rapier.website/spdx/rapier-math-' + resources.version + '-' + resources.sha256;
117
124
  await writeFile(sbomPath, JSON.stringify(sbom, null, 2) + '\n');
118
125
  return {bundle: MATH_CLASSIC, bytes: bytes.length, sha256: resources.sha256};