-
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.
Improve Gruntfile to support NodeJS module loading. Support window, g…
…lobalThis, and this. Improve Node JS example.
- Loading branch information
Showing
7 changed files
with
83 additions
and
32 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,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
This file was deleted.
Oops, something went wrong.
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 @@ | ||
// Usage: | ||
// node index.node.js | ||
// | ||
// THIS EXAMPLE FAILS with error: | ||
// SyntaxError: The requested module './vexflow-debug.js' does not provide an export named 'default' | ||
// | ||
// Solution: add the following to the bottom of vexflow-debug.js: | ||
// | ||
// export default globalThis.Vex; | ||
// | ||
// However, doing so will make vexflow-debug.js incompatible with classic <script src="..."></script> tags. | ||
|
||
import Vex from './vexflow-debug.js'; | ||
|
||
// 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! global 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,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 |