verovio 3.10.0 → 3.12.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/README.md CHANGED
@@ -4,24 +4,62 @@ Verovio is a fast, portable and lightweight library for engraving [Music Encodin
4
4
 
5
5
  See it running in the [MEI Viewer](http://www.verovio.org/mei-viewer.xhtml) and check out the [tutorial](http://www.verovio.org/tutorial.xhtml) for its web integration and for enabling user interaction.
6
6
 
7
- ## Usage
7
+ ## Basic usage
8
8
 
9
- ```javascript
10
- var verovio = require( 'verovio' );
11
- var fs = require( 'fs' );
9
+ ```js
10
+ const verovio = require('verovio');
11
+ const fs = require('fs');
12
12
 
13
13
  /* Wait for verovio to load */
14
14
  verovio.module.onRuntimeInitialized = function ()
15
15
  {
16
- /* create the toolkit instance */
17
- var vrvToolkit = new verovio.toolkit();
18
- /* read the MEI file */
19
- mei = fs.readFileSync("hello.mei");
20
- /* load the MEI data as string into the toolkit */
21
- vrvToolkit.loadData(mei.toString());
22
- /* render the fist page as SVG */
23
- svg = vrvToolkit.renderToSVG(1, {});
24
- /* save the SVG into a file */
25
- fs.writeFileSync("hello.svg", svg);
16
+ // create the toolkit instance
17
+ const vrvToolkit = new verovio.toolkit();
18
+ // read the MEI file
19
+ mei = fs.readFileSync('hello.mei');
20
+ // load the MEI data as string into the toolkit
21
+ vrvToolkit.loadData(mei.toString());
22
+ // render the fist page as SVG
23
+ svg = vrvToolkit.renderToSVG(1, {});
24
+ // save the SVG into a file
25
+ fs.writeFileSync('hello.svg', svg);
26
26
  }
27
- ```
27
+ ```
28
+
29
+ ## Usage with ESM
30
+
31
+ This package also provides an ESM version which can be used with a modularized build of the Verovio module. Use `.mjs` as file extension when using this directly in Node.js or set `"type": "module"` in your `package.json`.
32
+
33
+ ```js
34
+ import createVerovioModule from 'verovio/wasm';
35
+ import { VerovioToolkit } from 'verovio/esm';
36
+ import fs from 'node:fs';
37
+
38
+ createVerovioModule().then(VerovioModule => {
39
+ const verovioToolkit = new VerovioToolkit(VerovioModule);
40
+ const score = fs.readFileSync('hello.mei').toString();
41
+ verovioToolkit.loadData(score);
42
+ const data = verovioToolkit.renderToSVG(1);
43
+ console.log(data);
44
+ });
45
+ ```
46
+
47
+ This is the recommended way to use Verovio when creating a website or web app with bundlers like webpack or Vite or when using JavaScript frameworks like React or Vue.js.
48
+
49
+ ## Usage with CommonJS
50
+
51
+ Alternatively this package also exports a version compatible with CommonJS
52
+
53
+ ```js
54
+ const createVerovioModule = require('verovio/wasm');
55
+ const { VerovioToolkit } = require('verovio/esm');
56
+ ```
57
+
58
+ ## Humdrum support
59
+
60
+ Since version 3.11.0 the npm package provides an additional module with Humdrum support:
61
+
62
+ ```js
63
+ import createVerovioModule from 'verovio/wasm-hum';
64
+ ```
65
+