@viritura/score-engine 0.0.0 → 0.1.0-next.1

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 ADDED
@@ -0,0 +1,50 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@viritura/score-engine` are documented here.
4
+ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
+
6
+ ## [Unreleased]
7
+
8
+ ### Breaking
9
+
10
+ - `Engine` is now a type-only interface; `DisplayList` is an opaque handle.
11
+ Renderer types (`RenderCommand`, `PageLayout`, `MeasureBounds`, …) and the
12
+ `./errors`, `./timeline`, `./types` subpath exports are removed.
13
+ - `paint()` draws ink only under the caller's transform: no clearing, no white
14
+ fill, no `zoom`/`scroll` options. Pass `background` for a fill.
15
+ - `measure()` returns `pages[]` and `parts[]` (was `pageSizes`, `partIds`).
16
+ - `beatToCanvas(dl, beat, partId)` is replaced by `positionToCanvas(dl, pos)`
17
+ and `playhead(dl, pos)`; geometry is page-local.
18
+ - Part IDs are the source MNX part ID or `#<n>` (was a mismatched `p0`/`p1`).
19
+ - `info()` returns `{ parts, measureCount, scores }`.
20
+
21
+ ### Added
22
+
23
+ - `version`, `systems()`, `measures()`, `horizonPaper()`, `toSvg()`,
24
+ `createLayoutWorker()`, `createTileRenderer()`, `ink` colour.
25
+ - `loadEngine({ textFont: false })`; default asset base next to the prebuilt bundle.
26
+ The default layout worker follows `assetBaseUrl`.
27
+ - Published to npm with provenance, versioned independently of
28
+ `@viritura/score-viewer` and `@viritura/score-viewer-react`. Every engine
29
+ change on `main` also publishes a `-next.<n>` prerelease under the `next`
30
+ dist-tag. The
31
+ package ships `dist/` only: an ES module with Viritura's internal packages
32
+ inlined (no runtime dependencies), declarations, the layout worker, `wasm/`
33
+ and `fonts/`.
34
+ - Prebuilt release archive (`pnpm build:score-engine-dist`) and CI workflow.
35
+
36
+ ### Fixed
37
+
38
+ - Load failures reject with the underlying cause and can be retried.
39
+ - Timeline uses real meters and honours `repeatExpansion`; no longer runs
40
+ schema validation (drops ~1.8 MB from bundles).
41
+ - Text font no longer overrides the host page's generic `serif` family.
42
+
43
+ ## [0.0.1] — Phase 3 internal release
44
+
45
+ ### Added
46
+
47
+ - `loadEngine(opts?)` singleton factory.
48
+ - `Engine.layout(mnx, opts)`, `Engine.paint(ctx, dl, opts?)`,
49
+ `Engine.measure(dl)`, `Engine.info(mnx)`.
50
+ - `EngineLoadError`, `ParseError`, `LayoutError` typed error classes.
package/README.md CHANGED
@@ -1,3 +1,127 @@
1
1
  # @viritura/score-engine
2
2
 
3
- Reserved. The first real release will be published from GitHub Actions: https://github.com/Viritura/Viritura
3
+ Framework-free music notation rendering kernel. MNX in; layout (Rust/WASM),
4
+ ink-only Canvas painting, SVG, geometry queries and a playback timeline out.
5
+
6
+ Page presentation — paper, shadows, zoom, scrolling, view modes, playhead
7
+ chrome — belongs to [`@viritura/score-viewer`](../score-viewer) (framework-free)
8
+ or [`@viritura/score-viewer-react`](../score-viewer-react).
9
+
10
+ > **Status:** `0.x`. Breaking changes are possible before `1.0.0`; pin an
11
+ > exact version. Public documentation:
12
+ > [viritura.com/developers](https://viritura.com/developers).
13
+
14
+ ## Quick start
15
+
16
+ ```sh
17
+ npm install @viritura/score-engine
18
+ ```
19
+
20
+ ```ts
21
+ import { loadEngine } from "@viritura/score-engine";
22
+
23
+ const engine = await loadEngine({ assetBaseUrl: "/score-engine/" });
24
+ const dl = engine.layout(mnx, { pageWidth: 800 });
25
+
26
+ const ctx = canvas.getContext("2d")!;
27
+ ctx.fillStyle = "#fff"; // paper is yours
28
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
29
+ engine.paint(ctx, dl, { page: 0 });
30
+ ```
31
+
32
+ `pageWidth: 0` selects unpaged (horizon) layout. `pageSetup` gives explicit
33
+ page height and margins in display-list units (CSS pixels at zoom 1).
34
+
35
+ ## Serving the runtime files
36
+
37
+ The engine loads `wasm/`, `fonts/` and `score-engine.worker.js` at runtime
38
+ from one base URL, which defaults to the directory of the engine module. A
39
+ bundler moves the engine's code away from those files, so copy them from
40
+ `node_modules/@viritura/score-engine/dist/` into your static assets and pass
41
+ their URL as `assetBaseUrl`:
42
+
43
+ ```sh
44
+ cp -r node_modules/@viritura/score-engine/dist/{wasm,fonts,score-engine.worker.js} public/score-engine/
45
+ ```
46
+
47
+ See [Serving the files](https://viritura.com/developers#serving-the-files) for
48
+ the Content Security Policy and font requirements.
49
+
50
+ ## Contract
51
+
52
+ - **Loading.** `loadEngine({ assetBaseUrl?, textFont? })` loads WASM and fonts
53
+ once. Failures reject with `EngineLoadError` (`wasm` / `font`) carrying the
54
+ real cause, and a later call retries. Bravura is always loaded: layout uses
55
+ its metrics, so other music fonts are unsupported. The text face is
56
+ registered under the private family `Viritura Serif`, so the host page's
57
+ generic `serif` is untouched; `textFont: false` skips it and text falls back
58
+ to the page's `serif`.
59
+ - **Opaque layouts.** `layout()` returns a `DisplayList` handle
60
+ (`width`, `height`, `pageCount`, `paged`). Its internals are not API.
61
+ `createLayoutWorker()` produces the same handles off the main thread.
62
+ - **Ink only.** `paint(ctx, dl, { page, region, ink, background })` draws under
63
+ the caller's current transform (DPR, zoom, scroll) and never clears.
64
+ `ink` recolours default black ink (dark themes) and keeps explicit colours.
65
+ - **Page-local geometry.** `measure`, `systems`, `measures`, `positionToCanvas`,
66
+ `playhead` and `canvasToBeat` use page-local coordinates (`y = 0` is the top
67
+ of that page). `horizonPaper` gives the paper rectangle for unpaged layouts.
68
+ - **Stable part IDs.** Parts are identified by the source MNX `parts[n].id`, or
69
+ `#<n>` (0-based) when absent — the same in `info`, `measure`, geometry and
70
+ `timeline`.
71
+ - **Timeline.** `timeline(mnx, { repeatExpansion })` is layout-independent and
72
+ deterministic, uses real meters, and expands repeats by default.
73
+ - **SVG.** `toSvg(dl, { page, ink })` returns a standalone SVG with text and
74
+ glyphs as outlines.
75
+ - **Large unpaged scores.** `createTileRenderer()` paints a viewport from
76
+ cached tiles.
77
+
78
+ ## Distribution
79
+
80
+ The engine is published to npm alongside `@viritura/score-viewer` and
81
+ `@viritura/score-viewer-react`, each versioned independently, and as a
82
+ standalone release archive for pages without a build step.
83
+
84
+ ### npm
85
+
86
+ `pnpm build:npm-packages` (after `pnpm wasm:build`) writes each package's
87
+ `dist/`: an ES module with Viritura's internal workspace packages inlined,
88
+ declarations, and (for this package) the worker, `wasm/`, `fonts/` and
89
+ licences. `publishConfig` points the packed manifest at `dist/`, while the
90
+ workspace keeps importing `src/`. `pnpm verify:npm-packages --render` packs
91
+ all three, installs the tarballs into a fresh npm + Vite project and renders
92
+ with them in headless Chromium.
93
+
94
+ npm holds the released versions: the workspace manifests carry `0.0.0-dev`,
95
+ and the viewers depend on siblings through `workspace:^`, which packs as a
96
+ caret range.
97
+
98
+ Every push to `main` that changes this package or its inputs publishes a
99
+ prerelease `<next patch>-next.<run>` under the `next` dist-tag
100
+ (`npm install @viritura/score-engine@next`), with provenance but no git tag
101
+ or GitHub Release. Pin one exactly to track the engine closely; plain
102
+ `npm install` and the viewers' caret ranges ignore prereleases.
103
+
104
+ For a stable release, run **Publish npm packages**
105
+ (`.github/workflows/npm-publish.yml`) from `main` and pick `patch`, `minor` or
106
+ `major` for each package to release. The run bumps each selected package from
107
+ its latest npm version (`pnpm score-release plan` shows the result locally),
108
+ verifies them together, and publishes in dependency order with npm trusted
109
+ publishing (no token) and provenance. Each release gets a
110
+ `<package>-v<version>` tag and GitHub Release; the engine's carries the zip
111
+ archive. A viewer released on its own is verified against the engine from npm,
112
+ and the run refuses releases whose ranges would not resolve. The default
113
+ `dry_run` does everything except upload. Keep changelog entries under
114
+ `Unreleased` and move them under the version after a release.
115
+
116
+ ### Release archive
117
+
118
+ `pnpm build:score-engine-dist` (after `pnpm wasm:build`) writes
119
+ `dist/score-engine/`: ESM bundles `score-engine.js`, `score-engine.worker.js`
120
+ and `score-viewer.js` with all workspace code inlined, declarations, `wasm/`,
121
+ `fonts/`, licences and a `manifest.json` with the commit and SHA-256 of every
122
+ file. The bundles find `wasm/`, `fonts/` and the worker next to themselves.
123
+
124
+ CI (`.github/workflows/score-engine-dist.yml`) uploads this as a workflow
125
+ artifact on pushes to `main` that change the bundle's inputs (the Rust engine,
126
+ fonts, or the core/format/midi/renderer/score-engine/score-viewer packages).
127
+ Release archives are attached to engine releases by the publish workflow.
package/dist/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Viritura contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,80 @@
1
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
2
+
3
+ PREAMBLE
4
+ The goals of the Open Font License (OFL) are to stimulate worldwide
5
+ development of collaborative font projects, to support the font creation
6
+ efforts of academic and linguistic communities, and to provide a free and
7
+ open framework in which fonts may be shared and improved in partnership
8
+ with others.
9
+
10
+ The OFL allows the licensed fonts to be used, studied, modified and
11
+ redistributed freely as long as they are not sold by themselves. The fonts,
12
+ including any derivative works, can be bundled, embedded, redistributed
13
+ and/or sold with any software provided that any reserved names are not used
14
+ by derivative works. The fonts and derivatives, however, cannot be released
15
+ under any other type of license. The requirement for fonts to remain under
16
+ this license does not apply to any document created using the fonts or their
17
+ derivatives.
18
+
19
+ DEFINITIONS
20
+ "Font Software" refers to the set of files released by the Copyright
21
+ Holder(s) under this license and clearly marked as such. This may include
22
+ source files, build scripts and documentation.
23
+
24
+ "Reserved Font Name" refers to any names specified as such after the
25
+ copyright statement(s).
26
+
27
+ "Original Version" refers to the collection of Font Software components as
28
+ distributed by the Copyright Holder(s).
29
+
30
+ "Modified Version" refers to any derivative made by adding to, deleting,
31
+ or substituting -- in part or in whole -- any of the components of the
32
+ Original Version, by changing formats or by porting the Font Software to a
33
+ new environment.
34
+
35
+ "Author" refers to any designer, engineer, programmer, technical writer or
36
+ other person who contributed to the Font Software.
37
+
38
+ PERMISSION & CONDITIONS
39
+ Permission is hereby granted, free of charge, to any person obtaining a copy
40
+ of the Font Software, to use, study, copy, merge, embed, modify, redistribute,
41
+ and sell modified and unmodified copies of the Font Software, subject to the
42
+ following conditions:
43
+
44
+ 1) Neither the Font Software nor any of its individual components, in
45
+ Original or Modified Versions, may be sold by itself.
46
+
47
+ 2) Original or Modified Versions of the Font Software may be bundled,
48
+ redistributed and/or sold with any software, provided that each copy contains
49
+ the above copyright notice and this license. These can be included either as
50
+ stand-alone text files, human-readable headers or in the appropriate
51
+ machine-readable metadata fields within text or binary files as long as those
52
+ fields can be easily viewed by the user.
53
+
54
+ 3) No Modified Version of the Font Software may use the Reserved Font Name(s)
55
+ unless explicit written permission is granted by the corresponding Copyright
56
+ Holder. This restriction only applies to the primary font name as presented
57
+ to the users.
58
+
59
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
60
+ Software shall not be used to promote, endorse or advertise any Modified
61
+ Version, except to acknowledge the contribution(s) of the Copyright Holder(s)
62
+ and the Author(s) or with their explicit written permission.
63
+
64
+ 5) The Font Software, modified or unmodified, in part or in whole, must be
65
+ distributed entirely under this license, and must not be distributed under
66
+ any other license. The requirement for fonts to remain under this license
67
+ does not apply to any document created using the Font Software.
68
+
69
+ TERMINATION
70
+ This license becomes null and void if any of the above conditions are not met.
71
+
72
+ DISCLAIMER
73
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
74
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
75
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
76
+ TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR
77
+ ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL,
78
+ INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF
79
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE
80
+ THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,95 @@
1
+ # Third-Party Notices
2
+
3
+ Viritura's MIT license applies to the original source code in this repository.
4
+ The assets and generated components below remain under their respective terms.
5
+
6
+ ## Music and text fonts
7
+
8
+ The following unmodified font binaries are distributed under the
9
+ [SIL Open Font License 1.1](LICENSES/OFL-1.1.txt):
10
+
11
+ | Font files | Copyright and source | Reserved font name |
12
+ | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------- |
13
+ | `Bravura.otf`, `BravuraText.otf` | Copyright 2021 Steinberg Media Technologies GmbH. Designed by Daniel Spreadbury and contributors. [Bravura](https://github.com/steinbergmedia/bravura) | Bravura |
14
+ | `LibertinusSerif-*.otf` | Copyright 2012-2021 The Libertinus Project Authors. [Libertinus](https://github.com/alerque/libertinus) | None recorded in the bundled files |
15
+ | `Anybody-700.ttf` | Copyright 2020 The Anybody Project Authors. [Anybody](https://github.com/Etcetera-Type-Co/Anybody) | None recorded in the bundled file |
16
+ | `BodoniModa-600.ttf` | Copyright 2020 The Bodoni Moda Project Authors. [Bodoni Moda](https://github.com/indestructible-type/Bodoni) | None recorded in the bundled file |
17
+
18
+ The font binaries have not been modified. Their embedded license metadata and
19
+ copyright notices are retained. The OFL does not apply to documents or images
20
+ created with these fonts.
21
+
22
+ ## SpessaSynth
23
+
24
+ The browser audio worklet is generated during application development/build from the
25
+ package-manager dependency rather than stored as a vendored bundle:
26
+
27
+ - `spessasynth_lib` 4.3.1, copyright its contributors,
28
+ [Apache License 2.0](LICENSES/Apache-2.0.txt),
29
+ <https://github.com/spessasus/spessasynth_lib>
30
+ - `spessasynth_core` 4.3.22, copyright its contributors,
31
+ [Apache License 2.0](LICENSES/Apache-2.0.txt),
32
+ <https://github.com/spessasus/spessasynth_core>
33
+
34
+ `packages/audio/src/assetStaging.ts` copies the unmodified processor and source map
35
+ from the installed `spessasynth_lib` package into Git-ignored application
36
+ public-assets directories. The package distributions include the Apache 2.0
37
+ license and no separate `NOTICE` file.
38
+
39
+ ## Denigma
40
+
41
+ The Finale MUSX importer bundles a WebAssembly build of
42
+ [Denigma](https://github.com/openmusx/denigma), distributed under the MIT
43
+ License. Exact source revisions and artifact hashes are recorded in
44
+ `packages/musx-import/assets/manifest.json`; the Denigma license is retained
45
+ beside the generated assets. The package also retains the license files for the
46
+ linked musxdom, mnxdom, smufl-mapping, pugixml, nlohmann/json,
47
+ json-schema-validator, zlib, Emscripten, musl, and libc++ runtime dependencies,
48
+ plus the smufl-mapping notice and Bravura-derived mapping data's SIL Open Font
49
+ License.
50
+
51
+ ## SoundFont
52
+
53
+ `packages/audio/assets/sounds/Shan-SGM-Pro-15.sf2` is the **Shan SGM Pro 15**
54
+ SoundFont by Shan.
55
+
56
+ - Creator reference: <https://www.youtube.com/@ShanAudioChannel>
57
+ - SHA-256: `01ab03ff5156724c7c922fcabdb653d053ba50bd38a814756365b49e6a8c8d57`
58
+
59
+ The bundled file does not contain a standard license identifier. Before a
60
+ public release, retain the creator's explicit redistribution permission with
61
+ the project's release records. A channel or download-page reference alone is
62
+ not a redistribution license.
63
+
64
+ ## Impulse responses
65
+
66
+ The five WAV files in `packages/audio/assets/sounds/ir/` come from
67
+ [Voxengo Free Reverb Impulse Responses](https://www.voxengo.com/impulses/)
68
+ and are distributed under the bundled
69
+ [Voxengo impulse-response conditions](LICENSES/Voxengo-Impulse-Responses.txt):
70
+
71
+ - `french-salon.wav`
72
+ - `masonic-lodge.wav`
73
+ - `musikvereinsaal.wav`
74
+ - `scala-milan-opera.wav`
75
+ - `st-nicolaes-church.wav`
76
+
77
+ These files are complete and byte-identical to their entries in Voxengo's
78
+ official `IMreverbs.zip`. Aleksey Vaneev retains exclusive ownership of the
79
+ impulse files and all intellectual property rights in them.
80
+
81
+ The Voxengo files must be removed before any paid version or paid distribution
82
+ of Viritura. Non-paid distributions that include them must remain free of
83
+ charge and include the copyright notice and complete conditions linked above.
84
+
85
+ ## Demo video
86
+
87
+ Viritura can stream **Caminandes 3: Llamigos**, copyright Blender Foundation,
88
+ from Wikimedia Commons. The video is not stored in this repository. It is used
89
+ under [Creative Commons Attribution 3.0](https://creativecommons.org/licenses/by/3.0/).
90
+
91
+ - Work page: <https://studio.blender.org/films/caminandes-3/>
92
+ - Credit: Caminandes 3: Llamigos, Blender Foundation
93
+
94
+ The source URL, license, and required attribution are also carried in
95
+ `packages/video-sync/src/demoSources.ts` and shown with the clip.
Binary file
@@ -0,0 +1 @@
1
+ export * from "./types/index.js";