forked from DDMAL/Neon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from DDMAL/neume-line
Separate verovio prod and dev
- Loading branch information
Showing
19 changed files
with
557 additions
and
1,059 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
# TypeScript and JavaScript files | ||
[*.{ts,tsx,js,jsx}] | ||
indent_size = 2 | ||
quote_type = single |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,26 +1,36 @@ | ||
import { VerovioMessage } from './Types'; | ||
|
||
|
||
/** | ||
* A wrapper around the verovio web worker to permit mocking in tests. | ||
*/ | ||
export default class VerovioWrapper { | ||
verovioWorker: Worker; | ||
constructor () { | ||
this.verovioWorker = new Worker(__ASSET_PREFIX__ + 'workers/VerovioWorker.js'); | ||
constructor() { | ||
if (process.env.NODE_ENV === 'production') { | ||
this.verovioWorker = new Worker( | ||
__ASSET_PREFIX__ + 'workers/VerovioWorker.js' | ||
); | ||
} else { | ||
this.verovioWorker = new Worker( | ||
__ASSET_PREFIX__ + 'workers/VerovioWorker-dev.js' | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* Set an event listener onto the actual web worker. | ||
*/ | ||
addEventListener (type: string, handler: EventListenerOrEventListenerObject): void { | ||
addEventListener( | ||
type: string, | ||
handler: EventListenerOrEventListenerObject | ||
): void { | ||
return this.verovioWorker.addEventListener(type, handler); | ||
} | ||
|
||
/** | ||
* Send a message to the actual web worker. | ||
*/ | ||
postMessage (message: VerovioMessage): void { | ||
postMessage(message: VerovioMessage): void { | ||
return this.verovioWorker.postMessage(message); | ||
} | ||
} |
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,69 @@ | ||
importScripts('../assets/js/verovio-toolkit-wasm.js'); | ||
|
||
let toolkit; | ||
const backlog = []; | ||
|
||
/** | ||
* Parse and respond to messages sent by NeonCore. | ||
* @param {MessageEvent} evt | ||
*/ | ||
function handleNeonEvent (evt) { | ||
const data = evt.data; | ||
const result = { | ||
id: data.id | ||
}; | ||
|
||
switch (data.action) { | ||
case 'renderData': | ||
result.svg = toolkit.renderData(data.mei, {}); | ||
break; | ||
case 'getElementAttr': | ||
result.attributes = toolkit.getElementAttr(data.elementId); | ||
break; | ||
case 'edit': | ||
result.result = toolkit.edit(data.editorAction); | ||
break; | ||
case 'getMEI': | ||
result.mei = toolkit.getMEI({ | ||
pageNo: 0, | ||
scoreBased: true | ||
}); | ||
break; | ||
case 'editInfo': | ||
result.info = toolkit.editInfo(); | ||
break; | ||
case 'renderToSVG': | ||
result.svg = toolkit.renderToSVG(1); | ||
break; | ||
default: | ||
break; | ||
} | ||
postMessage(result); | ||
} | ||
|
||
|
||
verovio.module.onRuntimeInitialized = function () { | ||
|
||
toolkit = new verovio.toolkit(); | ||
toolkit.setOptions({ | ||
inputFrom: 'mei', | ||
footer: 'none', | ||
header: 'none', | ||
pageMarginLeft: 0, | ||
pageMarginTop: 0, | ||
font: 'Bravura', | ||
useFacsimile: false, | ||
}); | ||
console.debug('READY'); | ||
onmessage = handleNeonEvent; | ||
for (const message of backlog) { | ||
handleNeonEvent(message); | ||
} | ||
} | ||
|
||
|
||
function tempHandler (evt) { | ||
backlog.push(evt); | ||
} | ||
|
||
onmessage = tempHandler; |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.