-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
23 changed files
with
411 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Using VexFlow with ES Modules | ||
|
||
Use `test.sh`to build and copy `vexflow-debug.js` into this folder. Or do this manually: | ||
|
||
``` | ||
grunt | ||
cp ../../build/vexflow-debug.js vexflow-debug.js | ||
``` | ||
|
||
Start a web server in this folder. | ||
|
||
``` | ||
npx http-server | ||
Starting up http-server, serving ./ | ||
Available on: | ||
http://127.0.0.1:8080 | ||
Hit CTRL-C to stop the server | ||
``` | ||
|
||
Then load the `index.html` in a browser by visiting http://127.0.0.1:8080. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<div id="output"></div> | ||
<p>VexFlow Build: <span id="info"></span></p> | ||
<p>See also: <a href="index.html">index.html</a></p> | ||
<script src="vexflow-debug.js"></script> | ||
<script> | ||
document.querySelector('#info').innerText = Vex.Flow.BUILD; | ||
|
||
const vf = new Vex.Flow.Factory({ | ||
renderer: { elementId: 'output', width: 500, height: 200 }, | ||
}); | ||
|
||
const score = vf.EasyScore(); | ||
const system = vf.System(); | ||
|
||
system | ||
.addStave({ | ||
voices: [ | ||
score.voice(score.notes('C#5/q, B4, A4, G#4', { stem: 'up' })), | ||
score.voice(score.notes('C#4/h, C#4', { stem: 'down' })), | ||
], | ||
}) | ||
.addClef('treble') | ||
.addTimeSignature('4/4'); | ||
|
||
vf.draw(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<div id="output"></div> | ||
<p>VexFlow Build: <span id="info"></span></p> | ||
<p>See also: <a href="index.classic.html">index.classic.html</a></p> | ||
<script type="module" src="vexflow-debug.js"></script> | ||
<script type="module"> | ||
document.querySelector('#info').innerText = Vex.Flow.BUILD; | ||
|
||
const vf = new Vex.Flow.Factory({ | ||
renderer: { elementId: 'output', width: 500, height: 200 }, | ||
}); | ||
|
||
const score = vf.EasyScore(); | ||
const system = vf.System(); | ||
|
||
system | ||
.addStave({ | ||
voices: [ | ||
score.voice(score.notes('C#5/q, B4, A4, G#4', { stem: 'up' })), | ||
score.voice(score.notes('C#4/h, C#4', { stem: 'down' })), | ||
], | ||
}) | ||
.addClef('treble') | ||
.addTimeSignature('4/4'); | ||
|
||
vf.draw(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
# Build vexflow-debug.js if it does not exist. | ||
BUILD_FILE=../../build/vexflow-debug.js | ||
LOCAL_FILE=vexflow-debug.js | ||
|
||
if [ ! -f "$LOCAL_FILE" ]; then | ||
printf "\n$LOCAL_FILE not found. Copy it from the build folder.\n" | ||
|
||
if [ ! -f "$BUILD_FILE" ]; then | ||
printf "\n$BUILD_FILE not found. Running grunt.\n\n" | ||
grunt | ||
fi | ||
|
||
# Copy vexflow-debug.js into this folder. | ||
cp $BUILD_FILE $LOCAL_FILE | ||
fi | ||
|
||
# Launch a web server to test index.html and index.classic.html | ||
npx http-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// node index.js | ||
|
||
/* eslint-disable no-console */ | ||
|
||
import Vex from '../../../build/vexflow-debug.js'; | ||
|
||
// If you copy vexflow-debug.js to this folder and then update the import as follows: | ||
// import Vex from './vexflow-debug.js'; | ||
// It will fail with error: | ||
// SyntaxError: The requested module './vexflow-debug.js' does not provide an export named 'default' | ||
// This is because this folder includes a package.json which indicates that all JS files should be treated as ES6 modules. | ||
// To fix this, append the following to the end of vexflow-debug.js: | ||
// export default Vex; | ||
// However, doing so will make vexflow-debug.js incompatible with classic <script src="..."></script> tags. | ||
|
||
// console.log(this); // this === undefined | ||
// console.log(window); // ReferenceError: window is not defined | ||
// console.log(self); // ReferenceError: self is not defined | ||
// console.log(global); // success! global is the Node JS global object. | ||
// console.log(globalThis); // success! globalThis is the Node JS global object. | ||
// console.log(globalThis === global); // true | ||
|
||
console.log('VexFlow BUILD: ' + Vex.Flow.BUILD); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "modules-demo", | ||
"version": "1.0.0", | ||
"type": "module" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// node legacy.js | ||
// | ||
// Older versions of Node JS (e.g. v11.15.0) do not support globalThis. | ||
// This demonstrates that VexFlow can be imported even if globalThis is not available. | ||
|
||
/* eslint-disable no-console */ | ||
|
||
const Vex = require('../../build/vexflow-debug'); | ||
console.log(Vex); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.