@werckmeister/components 1.1.6-130 → 1.1.6-131
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/package.json
CHANGED
|
@@ -500,7 +500,7 @@ var A;parcelRequire=function(e,t,n,r){var i,o="function"==typeof parcelRequire&&
|
|
|
500
500
|
},{"@werckmeister/midiplayer":"X3ym"}],"ksUX":[function(require,module,exports) {
|
|
501
501
|
"use strict";function e(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function n(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function t(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}var r=this&&this.__awaiter||function(e,n,t,r){return new(t||(t=Promise))(function(o,u){function i(e){try{s(r.next(e))}catch(n){u(n)}}function a(e){try{s(r.throw(e))}catch(n){u(n)}}function s(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t(function(e){e(n)})).then(i,a)}s((r=r.apply(e,n||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.EnvironmentInspector=exports.SoundFontRepoMap=void 0;var o=require("lodash");exports.SoundFontRepoMap={"FluidR3-GM":"https://raw.githubusercontent.com/werckme/soundfont-server/main/soundfonts/FluidR3_GM_EX/FluidR3_GM_EX.sf2.json","Live-HQ-Natural-SoundFont-GM":"https://raw.githubusercontent.com/werckme/soundfont-server/main/soundfonts/Live_HQ_Natural_SoundFont_GM/Live_HQ_Natural_SoundFont_GM.sf2.json"};var u=function(){function n(){e(this,n),this.environment="web",this.webplayerPresets=o.keys(exports.SoundFontRepoMap)}return t(n,[{key:"getMidiOutputDevices",value:function(){return r(this,void 0,void 0,regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",[]);case 1:case"end":return e.stop()}},e)}))}}]),n}();exports.EnvironmentInspector=u;
|
|
502
502
|
},{"lodash":"B1iE"}],"WYYH":[function(require,module,exports) {
|
|
503
|
-
"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function n(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,a){function o(e){try{l(r.next(e))}catch(t){a(t)}}function s(e){try{l(r.throw(e))}catch(t){a(t)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,s)}l((r=r.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Player=void 0;var s=a(require("lodash")),l=require("@werckmeister/midiplayer"),u=require("../shared/midiEvent"),c=require("../shared/player"),h=require("../components/editor/EnvironmentInspector")
|
|
503
|
+
"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function n(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,a){function o(e){try{l(r.next(e))}catch(t){a(t)}}function s(e){try{l(r.throw(e))}catch(t){a(t)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,s)}l((r=r.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Player=exports.MainSheetFile=void 0;var s=a(require("lodash")),l=require("@werckmeister/midiplayer"),u=require("../shared/midiEvent"),c=require("../shared/player"),h=require("../components/editor/EnvironmentInspector");exports.MainSheetFile="main.sheet";var p=function(){function t(){e(this,t),this.tempo=120,this.onMidiEvent=null,this.onPlayerStateChangedCallback=null,this.state=c.PlayerState.Stopped,this.repoUrl=null,this.repoMap=h.SoundFontRepoMap}return n(t,[{key:"getPlayer",value:function(e){return o(this,void 0,void 0,regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this._player){t.next=7;break}return this._player=new l.WerckmeisterMidiPlayer,t.next=4,this._player.initAudioEnvironment(e);case 4:this._player.onMidiEvent=this.onEvent.bind(this),this._player.onPlayerStateChanged=this._onPlayerStateChanged.bind(this),this.repoUrl&&this._player.setRepoUrl(this.repoUrl);case 7:return t.abrupt("return",this._player);case 8:case"end":return t.stop()}},t,this)}))}},{key:"prepare",value:function(e){return o(this,void 0,void 0,regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPlayer(e);case 2:case"end":return t.stop()}},t,this)}))}},{key:"setRepoUrl",value:function(e){this._player.setRepoUrl(e)}},{key:"_onPlayerStateChanged",value:function(e,t){t===l.PlayerState.Stopped&&this.onStop()}},{key:"onEvent",value:function(e){var t=e.absPositionTicks,n=new u.MidiEvent;n.eventType=e.type,n.parameter1=e.param1,n.parameter2=e.param2,n.channel=e.channel,this.onMidiEvent&&this.onMidiEvent({position:t/this._player.ppq,midiEvent:n})}},{key:"loadFile",value:function(e,t){return o(this,void 0,void 0,regeneratorRuntime.mark(function n(){return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.load(e,this.playerTaskVisitor);case 2:case"end":return n.stop()}},n,this)}))}},{key:"play",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return o(this,void 0,void 0,regeneratorRuntime.mark(function i(){var a;return regeneratorRuntime.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.getPlayer(t);case 2:return a=i.sent,i.prev=3,i.next=6,this.loadFile(e,a);case 6:i.next=12;break;case 8:i.prev=8,i.t0=i.catch(3),this._currentMidifile=null,console.error(i.t0);case 12:return this.onPlayerStateChangedCallback&&this.onStop(),this.onMidiEvent=n,this.onPlayerStateChangedCallback=r,this.onPlay(),i.next=18,a.play();case 18:case"end":return i.stop()}},i,this,[[3,8]])}))}},{key:"setDevice",value:function(e){var t=e.fontName.trim();if(t.startsWith("https://"))this.setRepoUrl(t);else{var n=this.repoMap[e.fontName];if(!n)throw new Error("unknown font for device ".concat(e.name,". Possible values are ").concat(s.keys(this.repoMap).map(function(e){return'"'.concat(e,'"')}).join(", ")));this.setRepoUrl(n)}}},{key:"prepareDevices",value:function(e){var t;try{if(!e.midi.devices||0===e.midi.devices.length)return;if((null===(t=e.midi.devices)||void 0===t?void 0:t.length)>1)throw new Error("only one device is supported you defined ".concat(e.midi.devices.length,"."));this.setDevice(s.first(e.midi.devices))}catch(n){throw{errorMessage:n.message,positionBegin:0,sourceFile:exports.MainSheetFile,sourceId:s.first(e.midi.sources.filter(function(e){return e.path=="/".concat(exports.MainSheetFile)}).map(function(e){return e.sourceId}))}}}},{key:"onStop",value:function(){this.onPlayerStateChangedCallback&&this.onPlayerStateChangedCallback(this.state,c.PlayerState.Stopped),this.state=c.PlayerState.Stopped,this.onMidiEvent=null,this.onPlayerStateChangedCallback=null}},{key:"onPlay",value:function(){this.onPlayerStateChangedCallback(this.state,c.PlayerState.Playing),this.state=c.PlayerState.Playing}},{key:"setSoundfontRepoUrl",value:function(e){this._player&&this._player.setRepoUrl(e),this.repoUrl=e}},{key:"stop",value:function(){return o(this,void 0,void 0,regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.state!==c.PlayerState.Stopped){e.next=2;break}return e.abrupt("return");case 2:return this.onStop(),e.next=5,this.getPlayer(null);case 5:e.sent.stop();case 7:case"end":return e.stop()}},e,this)}))}}]),t}();exports.Player=p;
|
|
504
504
|
},{"lodash":"B1iE","@werckmeister/midiplayer":"X3ym","../shared/midiEvent":"vkzS","../shared/player":"FYcy","../components/editor/EnvironmentInspector":"ksUX"}],"ooUX":[function(require,module,exports) {
|
|
505
505
|
"use strict";var e=this&&this.__awaiter||function(e,r,t,n){return new(t||(t=Promise))(function(o,i){function s(e){try{p(n.next(e))}catch(r){i(r)}}function a(e){try{p(n.throw(e))}catch(r){i(r)}}function p(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t(function(e){e(r)})).then(s,a)}p((n=n.apply(e,r||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.resetCompiler=exports.WM_Player=exports.WM_Compiler=void 0;var r=require("./compiler/Compiler"),t=require("./player/Player");function n(){return e(this,void 0,void 0,regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:exports.WM_Compiler=new r.WerckmeisterCompiler;case 1:case"end":return e.stop()}},e)}))}exports.WM_Compiler=new r.WerckmeisterCompiler,exports.WM_Player=new t.Player,exports.resetCompiler=n;
|
|
506
506
|
},{"./compiler/Compiler":"RSuL","./player/Player":"WYYH"}],"bSo5":[function(require,module,exports) {
|
|
@@ -508,8 +508,8 @@ var A;parcelRequire=function(e,t,n,r){var i,o="function"==typeof parcelRequire&&
|
|
|
508
508
|
},{"../../editor/Editor":"BzA4","@werckmeister/language-features":"LghJ","../../shared/http":"vSbS","../../Global":"ooUX","./EnvironmentInspector":"ksUX","lodash":"B1iE","fs":"rDCW"}],"F8Qk":[function(require,module,exports) {
|
|
509
509
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.snippetTemplate=exports.singleSnippetTemplate=void 0;var e="\ntempo: $tempo;\ndevice: MyDevice midi 1;\n$defLines\n[\ninstrument: ex1;\n{\n$code\n}\n]",n="\n$defLines\n$code";exports.singleSnippetTemplate=function(n,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;i=i||"instrumentDef:ex1 MyDevice 0 0 0;";var r=e.replace("$tempo",t.toString()).replace("$defLines",i),p=r.indexOf("$code");return{script:r=r.replace("$code",n),charOffset:p}},exports.snippetTemplate=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;i=i||"instrumentDef:ex1 MyDevice 0 0 0;";var r=n.replace("$tempo",t.toString()).replace("$defLines",i),p=r.indexOf("$code");return{script:r=r.replace("$code",e),charOffset:p}};
|
|
510
510
|
},{}],"Ii2z":[function(require,module,exports) {
|
|
511
|
-
"use strict";function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e){return o(e)||t(e)||a(e)||r()}function r(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function t(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function o(e){if(Array.isArray(e))return s(e)}function i(e,n){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=a(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0,o=function(){};return{s:o,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,c=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return s=e.done,e},e:function(e){c=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw i}}}}function a(e,n){if(e){if("string"==typeof e)return s(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,n):void 0}}function s(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function c(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function l(e,n){for(var r=0;r<n.length;r++){var t=n[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}function d(e,n,r){return n&&l(e.prototype,n),r&&l(e,r),e}function u(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&y(e,n)}function p(e){var n=b();return function(){var r,t=w(e);if(n){var o=w(this).constructor;r=Reflect.construct(t,arguments,o)}else r=t.apply(this,arguments);return m(this,r)}}function m(n,r){return!r||"object"!==e(r)&&"function"!=typeof r?f(n):r}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e){var n="function"==typeof Map?new Map:void 0;return(h=function(e){if(null===e||!v(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,r)}function r(){return g(e,arguments,w(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),y(r,e)})(e)}function g(e,n,r){return(g=b()?Reflect.construct:function(e,n,r){var t=[null];t.push.apply(t,n);var o=new(Function.bind.apply(e,t));return r&&y(o,r.prototype),o}).apply(null,arguments)}function b(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function v(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function y(e,n){return(y=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function w(e){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var k=this&&this.__awaiter||function(e,n,r,t){return new(r||(r=Promise))(function(o,i){function a(e){try{c(t.next(e))}catch(n){i(n)}}function s(e){try{c(t.throw(e))}catch(n){i(n)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}c((t=t.apply(e,n||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Snippet=void 0;var M=require("../../editor/Editor"),C=require("../../Global"),x=require("../../shared/midiEvent"),S=require("../../shared/player"),E=require("./templates"),z=require("../../shared/http"),R=require("lodash"),P="dracula",I="main.sheet",T=require("fs"),A="/* BASICS */\n\n.CodeMirror {\n /* Set height, width, borders, and global font properties here */\n font-family: monospace;\n height: 300px;\n color: black;\n direction: ltr;\n}\n\n/* PADDING */\n\n.CodeMirror-lines {\n padding: 4px 0; /* Vertical padding around content */\n}\n.CodeMirror pre.CodeMirror-line,\n.CodeMirror pre.CodeMirror-line-like {\n padding: 0 4px; /* Horizontal padding of content */\n}\n\n.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {\n background-color: white; /* The little square between H and V scrollbars */\n}\n\n/* GUTTER */\n\n.CodeMirror-gutters {\n border-right: 1px solid #ddd;\n background-color: #f7f7f7;\n white-space: nowrap;\n}\n.CodeMirror-linenumbers {}\n.CodeMirror-linenumber {\n padding: 0 3px 0 5px;\n min-width: 20px;\n text-align: right;\n color: #999;\n white-space: nowrap;\n}\n\n.CodeMirror-guttermarker { color: black; }\n.CodeMirror-guttermarker-subtle { color: #999; }\n\n/* CURSOR */\n\n.CodeMirror-cursor {\n border-left: 1px solid black;\n border-right: none;\n width: 0;\n}\n/* Shown when moving in bi-directional text */\n.CodeMirror div.CodeMirror-secondarycursor {\n border-left: 1px solid silver;\n}\n.cm-fat-cursor .CodeMirror-cursor {\n width: auto;\n border: 0 !important;\n background: #7e7;\n}\n.cm-fat-cursor div.CodeMirror-cursors {\n z-index: 1;\n}\n.cm-fat-cursor-mark {\n background-color: rgba(20, 255, 20, 0.5);\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n}\n.cm-animate-fat-cursor {\n width: auto;\n border: 0;\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n background-color: #7e7;\n}\n@-moz-keyframes blink {\n 0% {}\n 50% { background-color: transparent; }\n 100% {}\n}\n@-webkit-keyframes blink {\n 0% {}\n 50% { background-color: transparent; }\n 100% {}\n}\n@keyframes blink {\n 0% {}\n 50% { background-color: transparent; }\n 100% {}\n}\n\n/* Can style cursor different in overwrite (non-insert) mode */\n.CodeMirror-overwrite .CodeMirror-cursor {}\n\n.cm-tab { display: inline-block; text-decoration: inherit; }\n\n.CodeMirror-rulers {\n position: absolute;\n left: 0; right: 0; top: -50px; bottom: 0;\n overflow: hidden;\n}\n.CodeMirror-ruler {\n border-left: 1px solid #ccc;\n top: 0; bottom: 0;\n position: absolute;\n}\n\n/* DEFAULT THEME */\n\n.cm-s-default .cm-header {color: blue;}\n.cm-s-default .cm-quote {color: #090;}\n.cm-negative {color: #d44;}\n.cm-positive {color: #292;}\n.cm-header, .cm-strong {font-weight: bold;}\n.cm-em {font-style: italic;}\n.cm-link {text-decoration: underline;}\n.cm-strikethrough {text-decoration: line-through;}\n\n.cm-s-default .cm-keyword {color: #708;}\n.cm-s-default .cm-atom {color: #219;}\n.cm-s-default .cm-number {color: #164;}\n.cm-s-default .cm-def {color: #00f;}\n.cm-s-default .cm-variable,\n.cm-s-default .cm-punctuation,\n.cm-s-default .cm-property,\n.cm-s-default .cm-operator {}\n.cm-s-default .cm-variable-2 {color: #05a;}\n.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}\n.cm-s-default .cm-comment {color: #a50;}\n.cm-s-default .cm-string {color: #a11;}\n.cm-s-default .cm-string-2 {color: #f50;}\n.cm-s-default .cm-meta {color: #555;}\n.cm-s-default .cm-qualifier {color: #555;}\n.cm-s-default .cm-builtin {color: #30a;}\n.cm-s-default .cm-bracket {color: #997;}\n.cm-s-default .cm-tag {color: #170;}\n.cm-s-default .cm-attribute {color: #00c;}\n.cm-s-default .cm-hr {color: #999;}\n.cm-s-default .cm-link {color: #00c;}\n\n.cm-s-default .cm-error {color: #f00;}\n.cm-invalidchar {color: #f00;}\n\n.CodeMirror-composing { border-bottom: 2px solid; }\n\n/* Default styles for common addons */\n\ndiv.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}\ndiv.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}\n.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }\n.CodeMirror-activeline-background {background: #e8f2ff;}\n\n/* STOP */\n\n/* The rest of this file contains styles related to the mechanics of\n the editor. You probably shouldn't touch them. */\n\n.CodeMirror {\n position: relative;\n overflow: hidden;\n background: white;\n}\n\n.CodeMirror-scroll {\n overflow: scroll !important; /* Things will break if this is overridden */\n /* 50px is the magic margin used to hide the element's real scrollbars */\n /* See overflow: hidden in .CodeMirror */\n margin-bottom: -50px; margin-right: -50px;\n padding-bottom: 50px;\n height: 100%;\n outline: none; /* Prevent dragging from highlighting the element */\n position: relative;\n}\n.CodeMirror-sizer {\n position: relative;\n border-right: 50px solid transparent;\n}\n\n/* The fake, visible scrollbars. Used to force redraw during scrolling\n before actual scrolling happens, thus preventing shaking and\n flickering artifacts. */\n.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {\n position: absolute;\n z-index: 6;\n display: none;\n}\n.CodeMirror-vscrollbar {\n right: 0; top: 0;\n overflow-x: hidden;\n overflow-y: scroll;\n}\n.CodeMirror-hscrollbar {\n bottom: 0; left: 0;\n overflow-y: hidden;\n overflow-x: scroll;\n}\n.CodeMirror-scrollbar-filler {\n right: 0; bottom: 0;\n}\n.CodeMirror-gutter-filler {\n left: 0; bottom: 0;\n}\n\n.CodeMirror-gutters {\n position: absolute; left: 0; top: 0;\n min-height: 100%;\n z-index: 3;\n}\n.CodeMirror-gutter {\n white-space: normal;\n height: 100%;\n display: inline-block;\n vertical-align: top;\n margin-bottom: -50px;\n}\n.CodeMirror-gutter-wrapper {\n position: absolute;\n z-index: 4;\n background: none !important;\n border: none !important;\n}\n.CodeMirror-gutter-background {\n position: absolute;\n top: 0; bottom: 0;\n z-index: 4;\n}\n.CodeMirror-gutter-elt {\n position: absolute;\n cursor: default;\n z-index: 4;\n}\n.CodeMirror-gutter-wrapper ::selection { background-color: transparent }\n.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }\n\n.CodeMirror-lines {\n cursor: text;\n min-height: 1px; /* prevents collapsing before first draw */\n}\n.CodeMirror pre.CodeMirror-line,\n.CodeMirror pre.CodeMirror-line-like {\n /* Reset some styles that the rest of the page might have set */\n -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;\n border-width: 0;\n background: transparent;\n font-family: inherit;\n font-size: inherit;\n margin: 0;\n white-space: pre;\n word-wrap: normal;\n line-height: inherit;\n color: inherit;\n z-index: 2;\n position: relative;\n overflow: visible;\n -webkit-tap-highlight-color: transparent;\n -webkit-font-variant-ligatures: contextual;\n font-variant-ligatures: contextual;\n}\n.CodeMirror-wrap pre.CodeMirror-line,\n.CodeMirror-wrap pre.CodeMirror-line-like {\n word-wrap: break-word;\n white-space: pre-wrap;\n word-break: normal;\n}\n\n.CodeMirror-linebackground {\n position: absolute;\n left: 0; right: 0; top: 0; bottom: 0;\n z-index: 0;\n}\n\n.CodeMirror-linewidget {\n position: relative;\n z-index: 2;\n padding: 0.1px; /* Force widget margins to stay inside of the container */\n}\n\n.CodeMirror-widget {}\n\n.CodeMirror-rtl pre { direction: rtl; }\n\n.CodeMirror-code {\n outline: none;\n}\n\n/* Force content-box sizing for the elements where we expect it */\n.CodeMirror-scroll,\n.CodeMirror-sizer,\n.CodeMirror-gutter,\n.CodeMirror-gutters,\n.CodeMirror-linenumber {\n -moz-box-sizing: content-box;\n box-sizing: content-box;\n}\n\n.CodeMirror-measure {\n position: absolute;\n width: 100%;\n height: 0;\n overflow: hidden;\n visibility: hidden;\n}\n\n.CodeMirror-cursor {\n position: absolute;\n pointer-events: none;\n}\n.CodeMirror-measure pre { position: static; }\n\ndiv.CodeMirror-cursors {\n visibility: hidden;\n position: relative;\n z-index: 3;\n}\ndiv.CodeMirror-dragcursors {\n visibility: visible;\n}\n\n.CodeMirror-focused div.CodeMirror-cursors {\n visibility: visible;\n}\n\n.CodeMirror-selected { background: #d9d9d9; }\n.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }\n.CodeMirror-crosshair { cursor: crosshair; }\n.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }\n.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }\n\n.cm-searching {\n background-color: #ffa;\n background-color: rgba(255, 255, 0, .4);\n}\n\n/* Used to force a border model for a node */\n.cm-force-border { padding-right: .1px; }\n\n@media print {\n /* Hide the cursor when printing */\n .CodeMirror div.CodeMirror-cursors {\n visibility: hidden;\n }\n}\n\n/* See issue #2901 */\n.cm-tab-wrap-hack:after { content: ''; }\n\n/* Help users use markselection to safely style text background */\nspan.CodeMirror-selectedtext { background: none; }\n";A+="/*\n\n Name: dracula\n Author: Michael Kaminsky (http://github.com/mkaminsky11)\n\n Original dracula color scheme by Zeno Rocha (https://github.com/zenorocha/dracula-theme)\n\n*/\n\n\n.cm-s-dracula.CodeMirror, .cm-s-dracula .CodeMirror-gutters {\n background-color: #282a36 !important;\n color: #f8f8f2 !important;\n border: none;\n}\n.cm-s-dracula .CodeMirror-gutters { color: #282a36; }\n.cm-s-dracula .CodeMirror-cursor { border-left: solid thin #f8f8f0; }\n.cm-s-dracula .CodeMirror-linenumber { color: #6D8A88; }\n.cm-s-dracula .CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }\n.cm-s-dracula .CodeMirror-line::selection, .cm-s-dracula .CodeMirror-line > span::selection, .cm-s-dracula .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }\n.cm-s-dracula .CodeMirror-line::-moz-selection, .cm-s-dracula .CodeMirror-line > span::-moz-selection, .cm-s-dracula .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }\n.cm-s-dracula span.cm-comment { color: #6272a4; }\n.cm-s-dracula span.cm-string, .cm-s-dracula span.cm-string-2 { color: #f1fa8c; }\n.cm-s-dracula span.cm-number { color: #bd93f9; }\n.cm-s-dracula span.cm-variable { color: #50fa7b; }\n.cm-s-dracula span.cm-variable-2 { color: white; }\n.cm-s-dracula span.cm-def { color: #50fa7b; }\n.cm-s-dracula span.cm-operator { color: #ff79c6; }\n.cm-s-dracula span.cm-keyword { color: #ff79c6; }\n.cm-s-dracula span.cm-atom { color: #bd93f9; }\n.cm-s-dracula span.cm-meta { color: #f8f8f2; }\n.cm-s-dracula span.cm-tag { color: #ff79c6; }\n.cm-s-dracula span.cm-attribute { color: #50fa7b; }\n.cm-s-dracula span.cm-qualifier { color: #50fa7b; }\n.cm-s-dracula span.cm-property { color: #66d9ef; }\n.cm-s-dracula span.cm-builtin { color: #50fa7b; }\n.cm-s-dracula span.cm-variable-3, .cm-s-dracula span.cm-type { color: #ffb86c; }\n\n.cm-s-dracula .CodeMirror-activeline-background { background: rgba(255,255,255,0.1); }\n.cm-s-dracula .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }\n";var O,_='#editor {\n border: 1px solid black;\n width: 100%;\n height: 100%;\n}\n\n.CodeMirror {\n width: 100%;\n height: 100%;\n font-size: 14px;\n}\n\n#messages span {\n margin: 0.5em 0;\n padding: 8px 15px 8px 15px;\n color: black;\n font-size: 14px;\n font-variant: tabular-nums;\n line-height: 1.5;\n list-style: none;\n font-feature-settings: \'tnum\';\n display: block;\n position: relative;\n right: -2px;\n}\n\n#messages .error {\n background-color: #fff1f0;\n}\n\n#messages .error::before {\n --size: 20px;\n content: "!";\n margin-right: 1em;\n color: white;\n background: red;\n border-radius: var(--size);\n width: var(--size);\n display: inline-block;\n height: var(--size);\n text-align: center;\n}\n\n#wm-snippet {\n margin-bottom: 1.5em;\n font-family: Helvetica, Arial, sans-serif;\n}\n\n.wm-marked::before {\n content: " ";\n position: absolute;\n border-top: 4px solid #ff0;\n border-left: 4px solid #ff0;\n border-radius: 0;\n height: 8px;\n width: 8px;\n transform: rotate(-135deg);\n margin-top: -11px;\n margin-left: 8px;\n}\n\n\n.wm-error::before {\n content: " ";\n position: absolute;\n border-top: 4px solid red;\n border-left: 4px solid red;\n border-radius: 0;\n height: 8px;\n width: 8px;\n transform: rotate(-135deg);\n margin-top: -11px;\n margin-left: 8px;\n}\n\n#btnPlay, #btnStop {\n cursor: pointer;\n user-select: none;\n}\n\n.wm-state-playing #btnPlay {\n display: none;\n}\n\n.wm-state-stopped #btnStop {\n display: none;\n}\n\n.wm-player-fetching #btnStop\n, .wm-player-fetching #btnPlay\n{\n display: none;\n}\n\n#fetching {\n display: none;\n}\n\n@keyframes spin { 100% { transform:rotate(360deg); } }\n#fetching svg {\n animation:spin 2s linear infinite;\n}\n\n.wm-player-fetching #fetching {\n display: block;\n}\n\n.icon {\n vertical-align: top;\n}\n\n.whomai {\n display: block;\n width: 100%;\n text-align: right;\n font-size: 13px;\n font-style: italic;\n}\n\n.CodeMirror-line.wm-hidden-line {\n display: none;\n}',N='<div id="wm-snippet">\n <div id="wm-controls">\n <a id="btnPlay">\n <svg class="icon" width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-play-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg">\n <path d="M11.596 8.697l-6.363 3.692c-.54.313-1.233-.066-1.233-.697V4.308c0-.63.692-1.01 1.233-.696l6.363 3.692a.802.802 0 0 1 0 1.393z"/>\n </svg>\n Play\n </a>\n <a id="btnStop">\n <svg class="icon" width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-stop-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg">\n <path d="M5 3.5h6A1.5 1.5 0 0 1 12.5 5v6a1.5 1.5 0 0 1-1.5 1.5H5A1.5 1.5 0 0 1 3.5 11V5A1.5 1.5 0 0 1 5 3.5z"/>\n </svg>\n Stop\n </a>\n <span id="fetching">\n <svg class="icon" width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-gear" fill="currentColor" xmlns="http://www.w3.org/2000/svg">\n <path fill-rule="evenodd" d="M8.837 1.626c-.246-.835-1.428-.835-1.674 0l-.094.319A1.873 1.873 0 0 1 4.377 3.06l-.292-.16c-.764-.415-1.6.42-1.184 1.185l.159.292a1.873 1.873 0 0 1-1.115 2.692l-.319.094c-.835.246-.835 1.428 0 1.674l.319.094a1.873 1.873 0 0 1 1.115 2.693l-.16.291c-.415.764.42 1.6 1.185 1.184l.292-.159a1.873 1.873 0 0 1 2.692 1.116l.094.318c.246.835 1.428.835 1.674 0l.094-.319a1.873 1.873 0 0 1 2.693-1.115l.291.16c.764.415 1.6-.42 1.184-1.185l-.159-.291a1.873 1.873 0 0 1 1.116-2.693l.318-.094c.835-.246.835-1.428 0-1.674l-.319-.094a1.873 1.873 0 0 1-1.115-2.692l.16-.292c.415-.764-.42-1.6-1.185-1.184l-.291.159A1.873 1.873 0 0 1 8.93 1.945l-.094-.319zm-2.633-.283c.527-1.79 3.065-1.79 3.592 0l.094.319a.873.873 0 0 0 1.255.52l.292-.16c1.64-.892 3.434.901 2.54 2.541l-.159.292a.873.873 0 0 0 .52 1.255l.319.094c1.79.527 1.79 3.065 0 3.592l-.319.094a.873.873 0 0 0-.52 1.255l.16.292c.893 1.64-.902 3.434-2.541 2.54l-.292-.159a.873.873 0 0 0-1.255.52l-.094.319c-.527 1.79-3.065 1.79-3.592 0l-.094-.319a.873.873 0 0 0-1.255-.52l-.292.16c-1.64.893-3.433-.902-2.54-2.541l.159-.292a.873.873 0 0 0-.52-1.255l-.319-.094c-1.79-.527-1.79-3.065 0-3.592l.319-.094a.873.873 0 0 0 .52-1.255l-.16-.292c-.892-1.64.902-3.433 2.541-2.54l.292.159a.873.873 0 0 0 1.255-.52l.094-.319z"/>\n <path fill-rule="evenodd" d="M8 5.754a2.246 2.246 0 1 0 0 4.492 2.246 2.246 0 0 0 0-4.492zM4.754 8a3.246 3.246 0 1 1 6.492 0 3.246 3.246 0 0 1-6.492 0z"/>\n </svg>\n Play\n </span>\n </div>\n <div id="messages">\n\n </div>\n <div id="editor">\n </div>\n <span class="whomai">\n powered by <a href="https://github.com/werckme/werckmeister-component">werckmeister snippet</a>\n </span>\n</div>';!function(e){e[e.single=0]="single",e[e.default=1]="default"}(O||(O={}));var L=0,B=new Map,H=document.createElement("template");H.innerHTML="\n<style>\n ".concat(A,"\n ").concat(_,"\n</style>\n").concat(N,"\n");var j=function(e){u(t,h(HTMLElement));var r=p(t);function t(){var e;return c(this,t),(e=r.call(this)).snippetId=L++,e.bpm=120,e.type=O.default,e.eventMarkers=[],e.playingStateName="wm-state-playing",e.stoppedStateName="wm-state-stopped",e.snippetName="noname.sheet",e.scriptToSnippetCharOffset=0,e.createElement(),e}return d(t,[{key:"playerIsFetching",get:function(){return this._playerIsFetching},set:function(e){this._playerIsFetching=e;var n=this.snippetElement;e?n.classList.add("wm-player-fetching"):n.classList.remove("wm-player-fetching")}},{key:"snippetElement",get:function(){return this.shadowRoot.getElementById("wm-snippet")}},{key:"messagesElement",get:function(){return this.shadowRoot.getElementById("messages")}},{key:"playButtonElement",get:function(){return this.shadowRoot.getElementById("btnPlay")}},{key:"stopButtonElement",get:function(){return this.shadowRoot.getElementById("btnStop")}},{key:"createElement",value:function(){return k(this,void 0,void 0,regeneratorRuntime.mark(function e(){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.attachShadow({mode:"open"}),n=H.content.cloneNode(!0),this.shadowRoot.appendChild(n),setTimeout(this.init.bind(this));case 4:case"end":return e.stop()}},e,this)}))}},{key:"initListener",value:function(){this.playButtonElement.addEventListener("click",this.onPlayClicked.bind(this)),this.stopButtonElement.addEventListener("click",this.onStopClicked.bind(this))}},{key:"onMidiEvent",value:function(e){e.midiEvent.eventType===x.EventType.NoteOn&&this.updateMarkers(e.position)}},{key:"stopAllSippets",value:function(){return k(this,void 0,void 0,regeneratorRuntime.mark(function e(){var n,r,t,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n=Array.from(B.values()),r=0,t=n;case 2:if(!(r<t.length)){e.next=9;break}return o=t[r],e.next=6,o.stop();case 6:r++,e.next=2;break;case 9:return e.abrupt("return",new Promise(function(e){setTimeout(e,100)}));case 10:case"end":return e.stop()}},e)}))}},{key:"onPlayerState",value:function(e,n){n===S.PlayerState.Playing&&(B.set(this.snippetId,this),this.setControlsStatePlaying()),n===S.PlayerState.Stopped&&(B.delete(this.snippetId),this.clearEventMarkers(),this.setControlsStateStopped()),this.onPlayerStateChanged&&this.onPlayerStateChanged(e,n)}},{key:"setControlsStateStopped",value:function(){var e=this.snippetElement;e.classList.remove(this.playingStateName),e.classList.add(this.stoppedStateName)}},{key:"setControlsStatePlaying",value:function(){var e=this.snippetElement;e.classList.remove(this.stoppedStateName),e.classList.add(this.playingStateName)}},{key:"clearEventMarkers",value:function(){var e,n=i(this.eventMarkers);try{for(n.s();!(e=n.n()).done;){e.value.clear()}}catch(r){n.e(r)}finally{n.f()}}},{key:"updateMarkers",value:function(e){this.clearEventMarkers();var n=R(this.document.eventInfos).map(function(n){return{diff:Math.abs(e-n.sheetTime),sheetEvents:n.sheetEventInfos}}).minBy(function(e){return e.diff});if(n){var r,t=this.scriptToSnippetCharOffset,o=i(n.sheetEvents);try{for(o.s();!(r=o.n()).done;){var a=r.value;if(a.sourceId===this.snippetDocumentId){var s=this.editor.setEventMarker(a.beginPosition-t,a.beginPosition-t+1);this.eventMarkers.push(s)}}}catch(c){o.e(c)}finally{o.f()}}}},{key:"getPlayerImpl",value:function(){return C.WM_Player}},{key:"getScriptText",value:function(){var e=this.editor.getValue();if(!e.trim())return"";this.scriptToSnippetCharOffset=0;var n=void 0;if(this._defLines&&(n=atob(this._defLines)),this.type===O.single){var r=E.singleSnippetTemplate(e,this.bpm,n);return this.scriptToSnippetCharOffset=r.charOffset,r.script.trim()}if(n){var t=E.snippetTemplate(e,this.bpm,n);return this.scriptToSnippetCharOffset=t.charOffset,t.script.trim()}return e.trim()}},{key:"onPlayClicked",value:function(e){return k(this,void 0,void 0,regeneratorRuntime.mark(function n(){return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,this.stopAllSippets();case 3:return n.next=5,this.startPlayer(e);case 5:n.next=11;break;case 7:return n.prev=7,n.t0=n.catch(0),n.t0.error?this.onError(n.t0.error):console.log(n.t0),n.abrupt("return");case 11:case"end":return n.stop()}},n,this,[[0,7]])}))}},{key:"getWorkspaceFormUrl",value:function(e){return k(this,void 0,void 0,regeneratorRuntime.mark(function n(){var r,t,o;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,fetch(e);case 2:return r=n.sent,n.next=5,r.json();case 5:return t=n.sent,o=t.files,n.abrupt("return",o);case 8:case"end":return n.stop()}},n)}))}},{key:"getAdditionalSources",value:function(){if(this._addSources)return this._addSources;if(!this._addSourcesBase64String)return[];var e=atob(this._addSourcesBase64String),n=JSON.parse(e);return Array.isArray(n)?n:[]}},{key:"startPlayer",value:function(e){return k(this,void 0,void 0,regeneratorRuntime.mark(function r(){var t,o,i=this;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,C.WM_Player.prepare(e);case 2:return r.next=4,C.resetCompiler();case 4:if(this.editor.clearEventMarkers(),this.clearMessages(),t=this.getScriptText()){r.next=9;break}return r.abrupt("return");case 9:return this.snippetDocumentId=null,this.playerIsFetching=!0,r.prev=11,o=[{path:this.snippetName,data:t}].concat(n(this.getAdditionalSources())),r.next=15,C.WM_Compiler.compile(o);case 15:this.document=r.sent,r.next=23;break;case 18:return r.prev=18,r.t0=r.catch(11),r.t0.error?this.onError(r.t0.error):console.log(r.t0),this.playerIsFetching=!1,r.abrupt("return");case 23:return this.snippetDocumentId=R(this.document.midi.sources).find(function(e){return e.path==="/".concat(i.snippetName)}).sourceId,this.snippetDocumentId||console.error("werckmeister compiler could not assign main document"),C.WM_Player.tempo=this.document.midi.bpm,r.prev=26,r.next=29,C.WM_Player.play(this.document.midi.midiData,e,this.onMidiEvent.bind(this),this.onPlayerState.bind(this));case 29:return r.prev=29,this.playerIsFetching=!1,r.finish(29);case 32:case"end":return r.stop()}},r,this,[[11,18],[26,,29,32]])}))}},{key:"onStopClicked",value:function(e){return k(this,void 0,void 0,regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.stop();case 1:case"end":return e.stop()}},e,this)}))}},{key:"stop",value:function(){return k(this,void 0,void 0,regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,C.WM_Player.stop();case 2:case"end":return e.stop()}},e)}))}},{key:"editorOverlappingWorkaround",value:function(e){this.snippetElement.style.marginBottom=e?"".concat(e,"px"):""}},{key:"setMessage",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",r=this.messagesElement;r.innerHTML='<span class="'.concat(n,'">').concat(e,"</span>"),this.editorOverlappingWorkaround(2*r.clientHeight)}},{key:"clearMessages",value:function(){this.messagesElement.innerHTML="",this.editorOverlappingWorkaround(0)}},{key:"onError",value:function(e){var n=this.scriptToSnippetCharOffset;this.editor.setErrorMarker(e.positionBegin-n,e.positionBegin-n+1),console.error("werckmeister compiler error: ".concat(e.errorMessage)),this.setMessage("".concat(e.errorMessage),"error")}},{key:"getScriptContent",value:function(e){return k(this,void 0,void 0,regeneratorRuntime.mark(function n(){var r,t,o,i,a;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(r=this.attributes.getNamedItem("wm-workspace-url"))){n.next=8;break}return n.next=4,this.getWorkspaceFormUrl(r.value);case 4:return t=n.sent,o=t.find(function(e){return e.path===I}),this._addSources=t.filter(function(e){return e.path!==I}),n.abrupt("return",o.data);case 8:if(!(i=this.attributes.getNamedItem("wm-data"))){n.next=11;break}return n.abrupt("return",atob(i.value));case 11:if(!(a=e.match(/\[CDATA\[([\s\S]*)\]\]/))){n.next=14;break}return n.abrupt("return",a[1]);case 14:return n.abrupt("return",e);case 15:case"end":return n.stop()}},n,this)}))}},{key:"init",value:function(){return k(this,void 0,void 0,regeneratorRuntime.mark(function e(){var n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.shadowRoot.getElementById("editor"),e.next=3,this.getScriptContent(this.innerHTML);case 3:r=e.sent,this.editor=new M.Editor(n,r,{theme:P}),this.setControlsStateStopped(),this.initListener(),this.readAttributes(),this.applyHiddenLineHack();case 9:case"end":return e.stop()}},e,this)}))}},{key:"applyHiddenLineHack",value:function(){for(var e=this.shadowRoot.querySelectorAll(".cm-wm-hidden-line"),n=0,r=Array.from(e);n<r.length;n++){r[n].parentElement.parentElement.classList.add("wm-hidden-line")}}},{key:"loadExternalCss",value:function(e){return k(this,void 0,void 0,regeneratorRuntime.mark(function n(){var r,t;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,z.fetchText(e);case 2:r=n.sent,(t=document.createElement("style")).innerText=r,this.shadowRoot.appendChild(t);case 6:case"end":return n.stop()}},n,this)}))}},{key:"readAttributes",value:function(){return k(this,void 0,void 0,regeneratorRuntime.mark(function e(){var n,r,t,o,i,a,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:(n=this.attributes.getNamedItem("wm-type"))&&"single"===n.value&&(this.type=O.single),(r=this.attributes.getNamedItem("wm-tempo"))&&(this.bpm=Number.parseFloat(r.value)),(t=this.attributes.getNamedItem("wm-style"))&&this.snippetElement.setAttribute("style",t.value),(o=this.attributes.getNamedItem("wm-css-url"))&&this.loadExternalCss(o.value),(i=this.attributes.getNamedItem("wm-def"))&&(this._defLines=i.value),(a=this.attributes.getNamedItem("wm-add-sources"))&&(this._addSourcesBase64String=a.value),(s=this.attributes.getNamedItem("wm-soundfont-url"))&&C.WM_Player.setSoundfontRepoUrl(s.value);case 14:case"end":return e.stop()}},e,this)}))}}]),t}();exports.Snippet=j;
|
|
512
|
-
},{"../../editor/Editor":"BzA4","../../Global":"ooUX","../../shared/midiEvent":"vkzS","../../shared/player":"FYcy","./templates":"F8Qk","../../shared/http":"vSbS","lodash":"B1iE","fs":"rDCW"}],"DsX5":[function(require,module,exports) {
|
|
511
|
+
"use strict";function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e){return o(e)||t(e)||a(e)||r()}function r(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function t(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function o(e){if(Array.isArray(e))return s(e)}function i(e,n){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=a(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0,o=function(){};return{s:o,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,c=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return s=e.done,e},e:function(e){c=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw i}}}}function a(e,n){if(e){if("string"==typeof e)return s(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,n):void 0}}function s(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function c(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function l(e,n){for(var r=0;r<n.length;r++){var t=n[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}function d(e,n,r){return n&&l(e.prototype,n),r&&l(e,r),e}function u(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&y(e,n)}function p(e){var n=b();return function(){var r,t=w(e);if(n){var o=w(this).constructor;r=Reflect.construct(t,arguments,o)}else r=t.apply(this,arguments);return m(this,r)}}function m(n,r){return!r||"object"!==e(r)&&"function"!=typeof r?f(n):r}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e){var n="function"==typeof Map?new Map:void 0;return(h=function(e){if(null===e||!v(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,r)}function r(){return g(e,arguments,w(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),y(r,e)})(e)}function g(e,n,r){return(g=b()?Reflect.construct:function(e,n,r){var t=[null];t.push.apply(t,n);var o=new(Function.bind.apply(e,t));return r&&y(o,r.prototype),o}).apply(null,arguments)}function b(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function v(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function y(e,n){return(y=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function w(e){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var k=this&&this.__awaiter||function(e,n,r,t){return new(r||(r=Promise))(function(o,i){function a(e){try{c(t.next(e))}catch(n){i(n)}}function s(e){try{c(t.throw(e))}catch(n){i(n)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}c((t=t.apply(e,n||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Snippet=void 0;var M=require("../../editor/Editor"),C=require("../../Global"),x=require("../../player/Player"),S=require("../../shared/midiEvent"),E=require("../../shared/player"),z=require("./templates"),R=require("../../shared/http"),P=require("lodash"),I="dracula",T=x.MainSheetFile,A=require("fs"),O="/* BASICS */\n\n.CodeMirror {\n /* Set height, width, borders, and global font properties here */\n font-family: monospace;\n height: 300px;\n color: black;\n direction: ltr;\n}\n\n/* PADDING */\n\n.CodeMirror-lines {\n padding: 4px 0; /* Vertical padding around content */\n}\n.CodeMirror pre.CodeMirror-line,\n.CodeMirror pre.CodeMirror-line-like {\n padding: 0 4px; /* Horizontal padding of content */\n}\n\n.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {\n background-color: white; /* The little square between H and V scrollbars */\n}\n\n/* GUTTER */\n\n.CodeMirror-gutters {\n border-right: 1px solid #ddd;\n background-color: #f7f7f7;\n white-space: nowrap;\n}\n.CodeMirror-linenumbers {}\n.CodeMirror-linenumber {\n padding: 0 3px 0 5px;\n min-width: 20px;\n text-align: right;\n color: #999;\n white-space: nowrap;\n}\n\n.CodeMirror-guttermarker { color: black; }\n.CodeMirror-guttermarker-subtle { color: #999; }\n\n/* CURSOR */\n\n.CodeMirror-cursor {\n border-left: 1px solid black;\n border-right: none;\n width: 0;\n}\n/* Shown when moving in bi-directional text */\n.CodeMirror div.CodeMirror-secondarycursor {\n border-left: 1px solid silver;\n}\n.cm-fat-cursor .CodeMirror-cursor {\n width: auto;\n border: 0 !important;\n background: #7e7;\n}\n.cm-fat-cursor div.CodeMirror-cursors {\n z-index: 1;\n}\n.cm-fat-cursor-mark {\n background-color: rgba(20, 255, 20, 0.5);\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n}\n.cm-animate-fat-cursor {\n width: auto;\n border: 0;\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n background-color: #7e7;\n}\n@-moz-keyframes blink {\n 0% {}\n 50% { background-color: transparent; }\n 100% {}\n}\n@-webkit-keyframes blink {\n 0% {}\n 50% { background-color: transparent; }\n 100% {}\n}\n@keyframes blink {\n 0% {}\n 50% { background-color: transparent; }\n 100% {}\n}\n\n/* Can style cursor different in overwrite (non-insert) mode */\n.CodeMirror-overwrite .CodeMirror-cursor {}\n\n.cm-tab { display: inline-block; text-decoration: inherit; }\n\n.CodeMirror-rulers {\n position: absolute;\n left: 0; right: 0; top: -50px; bottom: 0;\n overflow: hidden;\n}\n.CodeMirror-ruler {\n border-left: 1px solid #ccc;\n top: 0; bottom: 0;\n position: absolute;\n}\n\n/* DEFAULT THEME */\n\n.cm-s-default .cm-header {color: blue;}\n.cm-s-default .cm-quote {color: #090;}\n.cm-negative {color: #d44;}\n.cm-positive {color: #292;}\n.cm-header, .cm-strong {font-weight: bold;}\n.cm-em {font-style: italic;}\n.cm-link {text-decoration: underline;}\n.cm-strikethrough {text-decoration: line-through;}\n\n.cm-s-default .cm-keyword {color: #708;}\n.cm-s-default .cm-atom {color: #219;}\n.cm-s-default .cm-number {color: #164;}\n.cm-s-default .cm-def {color: #00f;}\n.cm-s-default .cm-variable,\n.cm-s-default .cm-punctuation,\n.cm-s-default .cm-property,\n.cm-s-default .cm-operator {}\n.cm-s-default .cm-variable-2 {color: #05a;}\n.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}\n.cm-s-default .cm-comment {color: #a50;}\n.cm-s-default .cm-string {color: #a11;}\n.cm-s-default .cm-string-2 {color: #f50;}\n.cm-s-default .cm-meta {color: #555;}\n.cm-s-default .cm-qualifier {color: #555;}\n.cm-s-default .cm-builtin {color: #30a;}\n.cm-s-default .cm-bracket {color: #997;}\n.cm-s-default .cm-tag {color: #170;}\n.cm-s-default .cm-attribute {color: #00c;}\n.cm-s-default .cm-hr {color: #999;}\n.cm-s-default .cm-link {color: #00c;}\n\n.cm-s-default .cm-error {color: #f00;}\n.cm-invalidchar {color: #f00;}\n\n.CodeMirror-composing { border-bottom: 2px solid; }\n\n/* Default styles for common addons */\n\ndiv.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}\ndiv.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}\n.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }\n.CodeMirror-activeline-background {background: #e8f2ff;}\n\n/* STOP */\n\n/* The rest of this file contains styles related to the mechanics of\n the editor. You probably shouldn't touch them. */\n\n.CodeMirror {\n position: relative;\n overflow: hidden;\n background: white;\n}\n\n.CodeMirror-scroll {\n overflow: scroll !important; /* Things will break if this is overridden */\n /* 50px is the magic margin used to hide the element's real scrollbars */\n /* See overflow: hidden in .CodeMirror */\n margin-bottom: -50px; margin-right: -50px;\n padding-bottom: 50px;\n height: 100%;\n outline: none; /* Prevent dragging from highlighting the element */\n position: relative;\n}\n.CodeMirror-sizer {\n position: relative;\n border-right: 50px solid transparent;\n}\n\n/* The fake, visible scrollbars. Used to force redraw during scrolling\n before actual scrolling happens, thus preventing shaking and\n flickering artifacts. */\n.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {\n position: absolute;\n z-index: 6;\n display: none;\n}\n.CodeMirror-vscrollbar {\n right: 0; top: 0;\n overflow-x: hidden;\n overflow-y: scroll;\n}\n.CodeMirror-hscrollbar {\n bottom: 0; left: 0;\n overflow-y: hidden;\n overflow-x: scroll;\n}\n.CodeMirror-scrollbar-filler {\n right: 0; bottom: 0;\n}\n.CodeMirror-gutter-filler {\n left: 0; bottom: 0;\n}\n\n.CodeMirror-gutters {\n position: absolute; left: 0; top: 0;\n min-height: 100%;\n z-index: 3;\n}\n.CodeMirror-gutter {\n white-space: normal;\n height: 100%;\n display: inline-block;\n vertical-align: top;\n margin-bottom: -50px;\n}\n.CodeMirror-gutter-wrapper {\n position: absolute;\n z-index: 4;\n background: none !important;\n border: none !important;\n}\n.CodeMirror-gutter-background {\n position: absolute;\n top: 0; bottom: 0;\n z-index: 4;\n}\n.CodeMirror-gutter-elt {\n position: absolute;\n cursor: default;\n z-index: 4;\n}\n.CodeMirror-gutter-wrapper ::selection { background-color: transparent }\n.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }\n\n.CodeMirror-lines {\n cursor: text;\n min-height: 1px; /* prevents collapsing before first draw */\n}\n.CodeMirror pre.CodeMirror-line,\n.CodeMirror pre.CodeMirror-line-like {\n /* Reset some styles that the rest of the page might have set */\n -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;\n border-width: 0;\n background: transparent;\n font-family: inherit;\n font-size: inherit;\n margin: 0;\n white-space: pre;\n word-wrap: normal;\n line-height: inherit;\n color: inherit;\n z-index: 2;\n position: relative;\n overflow: visible;\n -webkit-tap-highlight-color: transparent;\n -webkit-font-variant-ligatures: contextual;\n font-variant-ligatures: contextual;\n}\n.CodeMirror-wrap pre.CodeMirror-line,\n.CodeMirror-wrap pre.CodeMirror-line-like {\n word-wrap: break-word;\n white-space: pre-wrap;\n word-break: normal;\n}\n\n.CodeMirror-linebackground {\n position: absolute;\n left: 0; right: 0; top: 0; bottom: 0;\n z-index: 0;\n}\n\n.CodeMirror-linewidget {\n position: relative;\n z-index: 2;\n padding: 0.1px; /* Force widget margins to stay inside of the container */\n}\n\n.CodeMirror-widget {}\n\n.CodeMirror-rtl pre { direction: rtl; }\n\n.CodeMirror-code {\n outline: none;\n}\n\n/* Force content-box sizing for the elements where we expect it */\n.CodeMirror-scroll,\n.CodeMirror-sizer,\n.CodeMirror-gutter,\n.CodeMirror-gutters,\n.CodeMirror-linenumber {\n -moz-box-sizing: content-box;\n box-sizing: content-box;\n}\n\n.CodeMirror-measure {\n position: absolute;\n width: 100%;\n height: 0;\n overflow: hidden;\n visibility: hidden;\n}\n\n.CodeMirror-cursor {\n position: absolute;\n pointer-events: none;\n}\n.CodeMirror-measure pre { position: static; }\n\ndiv.CodeMirror-cursors {\n visibility: hidden;\n position: relative;\n z-index: 3;\n}\ndiv.CodeMirror-dragcursors {\n visibility: visible;\n}\n\n.CodeMirror-focused div.CodeMirror-cursors {\n visibility: visible;\n}\n\n.CodeMirror-selected { background: #d9d9d9; }\n.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }\n.CodeMirror-crosshair { cursor: crosshair; }\n.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }\n.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }\n\n.cm-searching {\n background-color: #ffa;\n background-color: rgba(255, 255, 0, .4);\n}\n\n/* Used to force a border model for a node */\n.cm-force-border { padding-right: .1px; }\n\n@media print {\n /* Hide the cursor when printing */\n .CodeMirror div.CodeMirror-cursors {\n visibility: hidden;\n }\n}\n\n/* See issue #2901 */\n.cm-tab-wrap-hack:after { content: ''; }\n\n/* Help users use markselection to safely style text background */\nspan.CodeMirror-selectedtext { background: none; }\n";O+="/*\n\n Name: dracula\n Author: Michael Kaminsky (http://github.com/mkaminsky11)\n\n Original dracula color scheme by Zeno Rocha (https://github.com/zenorocha/dracula-theme)\n\n*/\n\n\n.cm-s-dracula.CodeMirror, .cm-s-dracula .CodeMirror-gutters {\n background-color: #282a36 !important;\n color: #f8f8f2 !important;\n border: none;\n}\n.cm-s-dracula .CodeMirror-gutters { color: #282a36; }\n.cm-s-dracula .CodeMirror-cursor { border-left: solid thin #f8f8f0; }\n.cm-s-dracula .CodeMirror-linenumber { color: #6D8A88; }\n.cm-s-dracula .CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }\n.cm-s-dracula .CodeMirror-line::selection, .cm-s-dracula .CodeMirror-line > span::selection, .cm-s-dracula .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }\n.cm-s-dracula .CodeMirror-line::-moz-selection, .cm-s-dracula .CodeMirror-line > span::-moz-selection, .cm-s-dracula .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }\n.cm-s-dracula span.cm-comment { color: #6272a4; }\n.cm-s-dracula span.cm-string, .cm-s-dracula span.cm-string-2 { color: #f1fa8c; }\n.cm-s-dracula span.cm-number { color: #bd93f9; }\n.cm-s-dracula span.cm-variable { color: #50fa7b; }\n.cm-s-dracula span.cm-variable-2 { color: white; }\n.cm-s-dracula span.cm-def { color: #50fa7b; }\n.cm-s-dracula span.cm-operator { color: #ff79c6; }\n.cm-s-dracula span.cm-keyword { color: #ff79c6; }\n.cm-s-dracula span.cm-atom { color: #bd93f9; }\n.cm-s-dracula span.cm-meta { color: #f8f8f2; }\n.cm-s-dracula span.cm-tag { color: #ff79c6; }\n.cm-s-dracula span.cm-attribute { color: #50fa7b; }\n.cm-s-dracula span.cm-qualifier { color: #50fa7b; }\n.cm-s-dracula span.cm-property { color: #66d9ef; }\n.cm-s-dracula span.cm-builtin { color: #50fa7b; }\n.cm-s-dracula span.cm-variable-3, .cm-s-dracula span.cm-type { color: #ffb86c; }\n\n.cm-s-dracula .CodeMirror-activeline-background { background: rgba(255,255,255,0.1); }\n.cm-s-dracula .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }\n";var _,N='#editor {\n border: 1px solid black;\n width: 100%;\n height: 100%;\n}\n\n.CodeMirror {\n width: 100%;\n height: 100%;\n font-size: 14px;\n}\n\n#messages span {\n margin: 0.5em 0;\n padding: 8px 15px 8px 15px;\n color: black;\n font-size: 14px;\n font-variant: tabular-nums;\n line-height: 1.5;\n list-style: none;\n font-feature-settings: \'tnum\';\n display: block;\n position: relative;\n right: -2px;\n}\n\n#messages .error {\n background-color: #fff1f0;\n}\n\n#messages .error::before {\n --size: 20px;\n content: "!";\n margin-right: 1em;\n color: white;\n background: red;\n border-radius: var(--size);\n width: var(--size);\n display: inline-block;\n height: var(--size);\n text-align: center;\n}\n\n#wm-snippet {\n margin-bottom: 1.5em;\n font-family: Helvetica, Arial, sans-serif;\n}\n\n.wm-marked::before {\n content: " ";\n position: absolute;\n border-top: 4px solid #ff0;\n border-left: 4px solid #ff0;\n border-radius: 0;\n height: 8px;\n width: 8px;\n transform: rotate(-135deg);\n margin-top: -11px;\n margin-left: 8px;\n}\n\n\n.wm-error::before {\n content: " ";\n position: absolute;\n border-top: 4px solid red;\n border-left: 4px solid red;\n border-radius: 0;\n height: 8px;\n width: 8px;\n transform: rotate(-135deg);\n margin-top: -11px;\n margin-left: 8px;\n}\n\n#btnPlay, #btnStop {\n cursor: pointer;\n user-select: none;\n}\n\n.wm-state-playing #btnPlay {\n display: none;\n}\n\n.wm-state-stopped #btnStop {\n display: none;\n}\n\n.wm-player-fetching #btnStop\n, .wm-player-fetching #btnPlay\n{\n display: none;\n}\n\n#fetching {\n display: none;\n}\n\n@keyframes spin { 100% { transform:rotate(360deg); } }\n#fetching svg {\n animation:spin 2s linear infinite;\n}\n\n.wm-player-fetching #fetching {\n display: block;\n}\n\n.icon {\n vertical-align: top;\n}\n\n.whomai {\n display: block;\n width: 100%;\n text-align: right;\n font-size: 13px;\n font-style: italic;\n}\n\n.CodeMirror-line.wm-hidden-line {\n display: none;\n}',L='<div id="wm-snippet">\n <div id="wm-controls">\n <a id="btnPlay">\n <svg class="icon" width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-play-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg">\n <path d="M11.596 8.697l-6.363 3.692c-.54.313-1.233-.066-1.233-.697V4.308c0-.63.692-1.01 1.233-.696l6.363 3.692a.802.802 0 0 1 0 1.393z"/>\n </svg>\n Play\n </a>\n <a id="btnStop">\n <svg class="icon" width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-stop-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg">\n <path d="M5 3.5h6A1.5 1.5 0 0 1 12.5 5v6a1.5 1.5 0 0 1-1.5 1.5H5A1.5 1.5 0 0 1 3.5 11V5A1.5 1.5 0 0 1 5 3.5z"/>\n </svg>\n Stop\n </a>\n <span id="fetching">\n <svg class="icon" width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-gear" fill="currentColor" xmlns="http://www.w3.org/2000/svg">\n <path fill-rule="evenodd" d="M8.837 1.626c-.246-.835-1.428-.835-1.674 0l-.094.319A1.873 1.873 0 0 1 4.377 3.06l-.292-.16c-.764-.415-1.6.42-1.184 1.185l.159.292a1.873 1.873 0 0 1-1.115 2.692l-.319.094c-.835.246-.835 1.428 0 1.674l.319.094a1.873 1.873 0 0 1 1.115 2.693l-.16.291c-.415.764.42 1.6 1.185 1.184l.292-.159a1.873 1.873 0 0 1 2.692 1.116l.094.318c.246.835 1.428.835 1.674 0l.094-.319a1.873 1.873 0 0 1 2.693-1.115l.291.16c.764.415 1.6-.42 1.184-1.185l-.159-.291a1.873 1.873 0 0 1 1.116-2.693l.318-.094c.835-.246.835-1.428 0-1.674l-.319-.094a1.873 1.873 0 0 1-1.115-2.692l.16-.292c.415-.764-.42-1.6-1.185-1.184l-.291.159A1.873 1.873 0 0 1 8.93 1.945l-.094-.319zm-2.633-.283c.527-1.79 3.065-1.79 3.592 0l.094.319a.873.873 0 0 0 1.255.52l.292-.16c1.64-.892 3.434.901 2.54 2.541l-.159.292a.873.873 0 0 0 .52 1.255l.319.094c1.79.527 1.79 3.065 0 3.592l-.319.094a.873.873 0 0 0-.52 1.255l.16.292c.893 1.64-.902 3.434-2.541 2.54l-.292-.159a.873.873 0 0 0-1.255.52l-.094.319c-.527 1.79-3.065 1.79-3.592 0l-.094-.319a.873.873 0 0 0-1.255-.52l-.292.16c-1.64.893-3.433-.902-2.54-2.541l.159-.292a.873.873 0 0 0-.52-1.255l-.319-.094c-1.79-.527-1.79-3.065 0-3.592l.319-.094a.873.873 0 0 0 .52-1.255l-.16-.292c-.892-1.64.902-3.433 2.541-2.54l.292.159a.873.873 0 0 0 1.255-.52l.094-.319z"/>\n <path fill-rule="evenodd" d="M8 5.754a2.246 2.246 0 1 0 0 4.492 2.246 2.246 0 0 0 0-4.492zM4.754 8a3.246 3.246 0 1 1 6.492 0 3.246 3.246 0 0 1-6.492 0z"/>\n </svg>\n Play\n </span>\n </div>\n <div id="messages">\n\n </div>\n <div id="editor">\n </div>\n <span class="whomai">\n powered by <a href="https://github.com/werckme/werckmeister-component">werckmeister snippet</a>\n </span>\n</div>';!function(e){e[e.single=0]="single",e[e.default=1]="default"}(_||(_={}));var B=0,H=new Map,j=document.createElement("template");j.innerHTML="\n<style>\n ".concat(O,"\n ").concat(N,"\n</style>\n").concat(L,"\n");var F=function(e){u(t,h(HTMLElement));var r=p(t);function t(){var e;return c(this,t),(e=r.call(this)).snippetId=B++,e.bpm=120,e.type=_.default,e.eventMarkers=[],e.playingStateName="wm-state-playing",e.stoppedStateName="wm-state-stopped",e.snippetName="noname.sheet",e.scriptToSnippetCharOffset=0,e.createElement(),e}return d(t,[{key:"playerIsFetching",get:function(){return this._playerIsFetching},set:function(e){this._playerIsFetching=e;var n=this.snippetElement;e?n.classList.add("wm-player-fetching"):n.classList.remove("wm-player-fetching")}},{key:"snippetElement",get:function(){return this.shadowRoot.getElementById("wm-snippet")}},{key:"messagesElement",get:function(){return this.shadowRoot.getElementById("messages")}},{key:"playButtonElement",get:function(){return this.shadowRoot.getElementById("btnPlay")}},{key:"stopButtonElement",get:function(){return this.shadowRoot.getElementById("btnStop")}},{key:"createElement",value:function(){return k(this,void 0,void 0,regeneratorRuntime.mark(function e(){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.attachShadow({mode:"open"}),n=j.content.cloneNode(!0),this.shadowRoot.appendChild(n),setTimeout(this.init.bind(this));case 4:case"end":return e.stop()}},e,this)}))}},{key:"initListener",value:function(){this.playButtonElement.addEventListener("click",this.onPlayClicked.bind(this)),this.stopButtonElement.addEventListener("click",this.onStopClicked.bind(this))}},{key:"onMidiEvent",value:function(e){e.midiEvent.eventType===S.EventType.NoteOn&&this.updateMarkers(e.position)}},{key:"stopAllSippets",value:function(){return k(this,void 0,void 0,regeneratorRuntime.mark(function e(){var n,r,t,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n=Array.from(H.values()),r=0,t=n;case 2:if(!(r<t.length)){e.next=9;break}return o=t[r],e.next=6,o.stop();case 6:r++,e.next=2;break;case 9:return e.abrupt("return",new Promise(function(e){setTimeout(e,100)}));case 10:case"end":return e.stop()}},e)}))}},{key:"onPlayerState",value:function(e,n){n===E.PlayerState.Playing&&(H.set(this.snippetId,this),this.setControlsStatePlaying()),n===E.PlayerState.Stopped&&(H.delete(this.snippetId),this.clearEventMarkers(),this.setControlsStateStopped()),this.onPlayerStateChanged&&this.onPlayerStateChanged(e,n)}},{key:"setControlsStateStopped",value:function(){var e=this.snippetElement;e.classList.remove(this.playingStateName),e.classList.add(this.stoppedStateName)}},{key:"setControlsStatePlaying",value:function(){var e=this.snippetElement;e.classList.remove(this.stoppedStateName),e.classList.add(this.playingStateName)}},{key:"clearEventMarkers",value:function(){var e,n=i(this.eventMarkers);try{for(n.s();!(e=n.n()).done;){e.value.clear()}}catch(r){n.e(r)}finally{n.f()}}},{key:"updateMarkers",value:function(e){this.clearEventMarkers();var n=P(this.document.eventInfos).map(function(n){return{diff:Math.abs(e-n.sheetTime),sheetEvents:n.sheetEventInfos}}).minBy(function(e){return e.diff});if(n){var r,t=this.scriptToSnippetCharOffset,o=i(n.sheetEvents);try{for(o.s();!(r=o.n()).done;){var a=r.value;if(a.sourceId===this.snippetDocumentId){var s=this.editor.setEventMarker(a.beginPosition-t,a.beginPosition-t+1);this.eventMarkers.push(s)}}}catch(c){o.e(c)}finally{o.f()}}}},{key:"getPlayerImpl",value:function(){return C.WM_Player}},{key:"getScriptText",value:function(){var e=this.editor.getValue();if(!e.trim())return"";this.scriptToSnippetCharOffset=0;var n=void 0;if(this._defLines&&(n=atob(this._defLines)),this.type===_.single){var r=z.singleSnippetTemplate(e,this.bpm,n);return this.scriptToSnippetCharOffset=r.charOffset,r.script.trim()}if(n){var t=z.snippetTemplate(e,this.bpm,n);return this.scriptToSnippetCharOffset=t.charOffset,t.script.trim()}return e.trim()}},{key:"onPlayClicked",value:function(e){return k(this,void 0,void 0,regeneratorRuntime.mark(function n(){return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,this.stopAllSippets();case 3:return n.next=5,this.startPlayer(e);case 5:n.next=11;break;case 7:return n.prev=7,n.t0=n.catch(0),n.t0.error?this.onError(n.t0.error):console.log(n.t0),n.abrupt("return");case 11:case"end":return n.stop()}},n,this,[[0,7]])}))}},{key:"getWorkspaceFormUrl",value:function(e){return k(this,void 0,void 0,regeneratorRuntime.mark(function n(){var r,t,o;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,fetch(e);case 2:return r=n.sent,n.next=5,r.json();case 5:return t=n.sent,o=t.files,n.abrupt("return",o);case 8:case"end":return n.stop()}},n)}))}},{key:"getAdditionalSources",value:function(){if(this._addSources)return this._addSources;if(!this._addSourcesBase64String)return[];var e=atob(this._addSourcesBase64String),n=JSON.parse(e);return Array.isArray(n)?n:[]}},{key:"startPlayer",value:function(e){return k(this,void 0,void 0,regeneratorRuntime.mark(function r(){var t,o,i=this;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,C.WM_Player.prepare(e);case 2:return r.next=4,C.resetCompiler();case 4:if(this.editor.clearEventMarkers(),this.clearMessages(),t=this.getScriptText()){r.next=9;break}return r.abrupt("return");case 9:return this.snippetDocumentId=null,this.playerIsFetching=!0,r.prev=11,o=[{path:this.snippetName,data:t}].concat(n(this.getAdditionalSources())),r.next=15,C.WM_Compiler.compile(o);case 15:this.document=r.sent,r.next=23;break;case 18:return r.prev=18,r.t0=r.catch(11),r.t0.error?this.onError(r.t0.error):console.log(r.t0),this.playerIsFetching=!1,r.abrupt("return");case 23:return this.snippetDocumentId=P(this.document.midi.sources).find(function(e){return e.path==="/".concat(i.snippetName)}).sourceId,this.snippetDocumentId||console.error("werckmeister compiler could not assign main document"),C.WM_Player.tempo=this.document.midi.bpm,r.prev=26,r.next=29,C.WM_Player.play(this.document.midi.midiData,e,this.onMidiEvent.bind(this),this.onPlayerState.bind(this));case 29:return r.prev=29,this.playerIsFetching=!1,r.finish(29);case 32:case"end":return r.stop()}},r,this,[[11,18],[26,,29,32]])}))}},{key:"onStopClicked",value:function(e){return k(this,void 0,void 0,regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.stop();case 1:case"end":return e.stop()}},e,this)}))}},{key:"stop",value:function(){return k(this,void 0,void 0,regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,C.WM_Player.stop();case 2:case"end":return e.stop()}},e)}))}},{key:"editorOverlappingWorkaround",value:function(e){this.snippetElement.style.marginBottom=e?"".concat(e,"px"):""}},{key:"setMessage",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",r=this.messagesElement;r.innerHTML='<span class="'.concat(n,'">').concat(e,"</span>"),this.editorOverlappingWorkaround(2*r.clientHeight)}},{key:"clearMessages",value:function(){this.messagesElement.innerHTML="",this.editorOverlappingWorkaround(0)}},{key:"onError",value:function(e){var n=this.scriptToSnippetCharOffset;this.editor.setErrorMarker(e.positionBegin-n,e.positionBegin-n+1),console.error("werckmeister compiler error: ".concat(e.errorMessage)),this.setMessage("".concat(e.errorMessage),"error")}},{key:"getScriptContent",value:function(e){return k(this,void 0,void 0,regeneratorRuntime.mark(function n(){var r,t,o,i,a;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(r=this.attributes.getNamedItem("wm-workspace-url"))){n.next=8;break}return n.next=4,this.getWorkspaceFormUrl(r.value);case 4:return t=n.sent,o=t.find(function(e){return e.path===T}),this._addSources=t.filter(function(e){return e.path!==T}),n.abrupt("return",o.data);case 8:if(!(i=this.attributes.getNamedItem("wm-data"))){n.next=11;break}return n.abrupt("return",atob(i.value));case 11:if(!(a=e.match(/\[CDATA\[([\s\S]*)\]\]/))){n.next=14;break}return n.abrupt("return",a[1]);case 14:return n.abrupt("return",e);case 15:case"end":return n.stop()}},n,this)}))}},{key:"init",value:function(){return k(this,void 0,void 0,regeneratorRuntime.mark(function e(){var n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.shadowRoot.getElementById("editor"),e.next=3,this.getScriptContent(this.innerHTML);case 3:r=e.sent,this.editor=new M.Editor(n,r,{theme:I}),this.setControlsStateStopped(),this.initListener(),this.readAttributes(),this.applyHiddenLineHack();case 9:case"end":return e.stop()}},e,this)}))}},{key:"applyHiddenLineHack",value:function(){for(var e=this.shadowRoot.querySelectorAll(".cm-wm-hidden-line"),n=0,r=Array.from(e);n<r.length;n++){r[n].parentElement.parentElement.classList.add("wm-hidden-line")}}},{key:"loadExternalCss",value:function(e){return k(this,void 0,void 0,regeneratorRuntime.mark(function n(){var r,t;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,R.fetchText(e);case 2:r=n.sent,(t=document.createElement("style")).innerText=r,this.shadowRoot.appendChild(t);case 6:case"end":return n.stop()}},n,this)}))}},{key:"readAttributes",value:function(){return k(this,void 0,void 0,regeneratorRuntime.mark(function e(){var n,r,t,o,i,a,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:(n=this.attributes.getNamedItem("wm-type"))&&"single"===n.value&&(this.type=_.single),(r=this.attributes.getNamedItem("wm-tempo"))&&(this.bpm=Number.parseFloat(r.value)),(t=this.attributes.getNamedItem("wm-style"))&&this.snippetElement.setAttribute("style",t.value),(o=this.attributes.getNamedItem("wm-css-url"))&&this.loadExternalCss(o.value),(i=this.attributes.getNamedItem("wm-def"))&&(this._defLines=i.value),(a=this.attributes.getNamedItem("wm-add-sources"))&&(this._addSourcesBase64String=a.value),(s=this.attributes.getNamedItem("wm-soundfont-url"))&&C.WM_Player.setSoundfontRepoUrl(s.value);case 14:case"end":return e.stop()}},e,this)}))}}]),t}();exports.Snippet=F;
|
|
512
|
+
},{"../../editor/Editor":"BzA4","../../Global":"ooUX","../../player/Player":"WYYH","../../shared/midiEvent":"vkzS","../../shared/player":"FYcy","./templates":"F8Qk","../../shared/http":"vSbS","lodash":"B1iE","fs":"rDCW"}],"DsX5":[function(require,module,exports) {
|
|
513
513
|
"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=n(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,o=function(){};return{s:o,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,c=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return s=e.done,e},e:function(e){c=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw a}}}}function n(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&y(e,t)}function c(e){var t=p();return function(){var n,r=m(e);if(t){var i=m(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return u(this,n)}}function u(t,n){return!n||"object"!==e(n)&&"function"!=typeof n?l(t):n}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e){var t="function"==typeof Map?new Map:void 0;return(f=function(e){if(null===e||!h(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return d(e,arguments,m(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),y(n,e)})(e)}function d(e,t,n){return(d=p()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&y(i,n.prototype),i}).apply(null,arguments)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function h(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function m(e){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var v=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{c(r.next(e))}catch(t){o(t)}}function s(e){try{c(r.throw(e))}catch(t){o(t)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Workspace=void 0;var g=require("../../Global"),w=require("../../shared/midiEvent"),b=require("../../shared/player"),k=require("../../shared/http"),E=require("lodash"),M=require("fs"),S="#wm-controls a {\n cursor: pointer;\n user-select: none;\n}\n\n.wm-state-playing #btnPlay {\n display: none;\n}\n \n.wm-state-stopped #btnStop {\n display: none;\n}\n \n.wm-player-fetching #btnStop\n, .wm-player-fetching #btnPlay\n{\n display: none;\n}\n \n#fetching {\n display: none;\n}\n\n@keyframes spin { 100% { transform:rotate(360deg); } }\n#fetching svg {\n animation:spin 2s linear infinite;\n}\n\n.wm-player-fetching #fetching {\n display: block;\n}\n",x='<div id="wm-controls" class="wm-state-stopped">\n <a id="btnPlay">\n <svg class="icon" width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-play-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg">\n <path d="M11.596 8.697l-6.363 3.692c-.54.313-1.233-.066-1.233-.697V4.308c0-.63.692-1.01 1.233-.696l6.363 3.692a.802.802 0 0 1 0 1.393z"/>\n </svg>\n Play\n </a>\n <a id="btnStop">\n <svg class="icon" width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-stop-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg">\n <path d="M5 3.5h6A1.5 1.5 0 0 1 12.5 5v6a1.5 1.5 0 0 1-1.5 1.5H5A1.5 1.5 0 0 1 3.5 11V5A1.5 1.5 0 0 1 5 3.5z"/>\n </svg>\n Stop\n </a>\n <span id="fetching">\n <svg class="icon" width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-gear" fill="currentColor" xmlns="http://www.w3.org/2000/svg">\n <path fill-rule="evenodd" d="M8.837 1.626c-.246-.835-1.428-.835-1.674 0l-.094.319A1.873 1.873 0 0 1 4.377 3.06l-.292-.16c-.764-.415-1.6.42-1.184 1.185l.159.292a1.873 1.873 0 0 1-1.115 2.692l-.319.094c-.835.246-.835 1.428 0 1.674l.319.094a1.873 1.873 0 0 1 1.115 2.693l-.16.291c-.415.764.42 1.6 1.185 1.184l.292-.159a1.873 1.873 0 0 1 2.692 1.116l.094.318c.246.835 1.428.835 1.674 0l.094-.319a1.873 1.873 0 0 1 2.693-1.115l.291.16c.764.415 1.6-.42 1.184-1.185l-.159-.291a1.873 1.873 0 0 1 1.116-2.693l.318-.094c.835-.246.835-1.428 0-1.674l-.319-.094a1.873 1.873 0 0 1-1.115-2.692l.16-.292c.415-.764-.42-1.6-1.185-1.184l-.291.159A1.873 1.873 0 0 1 8.93 1.945l-.094-.319zm-2.633-.283c.527-1.79 3.065-1.79 3.592 0l.094.319a.873.873 0 0 0 1.255.52l.292-.16c1.64-.892 3.434.901 2.54 2.541l-.159.292a.873.873 0 0 0 .52 1.255l.319.094c1.79.527 1.79 3.065 0 3.592l-.319.094a.873.873 0 0 0-.52 1.255l.16.292c.893 1.64-.902 3.434-2.541 2.54l-.292-.159a.873.873 0 0 0-1.255.52l-.094.319c-.527 1.79-3.065 1.79-3.592 0l-.094-.319a.873.873 0 0 0-1.255-.52l-.292.16c-1.64.893-3.433-.902-2.54-2.541l.159-.292a.873.873 0 0 0-.52-1.255l-.319-.094c-1.79-.527-1.79-3.065 0-3.592l.319-.094a.873.873 0 0 0 .52-1.255l-.16-.292c-.892-1.64.902-3.433 2.541-2.54l.292.159a.873.873 0 0 0 1.255-.52l.094-.319z"/>\n <path fill-rule="evenodd" d="M8 5.754a2.246 2.246 0 1 0 0 4.492 2.246 2.246 0 0 0 0-4.492zM4.754 8a3.246 3.246 0 1 1 6.492 0 3.246 3.246 0 0 1-6.492 0z"/>\n </svg>\n Play\n </span> \n</div>',C="_editor.css",P="\n<style>\n".concat(S,"\n</style>\n").concat(x,"\n"),_=document.createElement("template");_.innerHTML=P;var I=function(e){s(r,f(HTMLElement));var n=c(r);function r(){var e;return i(this,r),(e=n.call(this)).bpm=120,e.onError=function(e){},e.onWarnings=function(e){},e.onCompiled=function(e){},e.onStateChanged=function(e,t){},e.updateMarkersDebounceMillis=50,e.editors=[],e.sourceIdEditorMap=new Map,e.lastEventTimeQuarters=0,e.updateMarkersDebounced=E.debounce(e.updateMarkersImpl.bind(l(e)),e.updateMarkersDebounceMillis),e._beginQuarters=0,e.playerState=b.PlayerState.Stopped,e.createElement(),e}return a(r,[{key:"beginQuarters",get:function(){return this._beginQuarters},set:function(e){this._beginQuarters=Math.max(0,e)}},{key:"setAdditionalCssText",value:function(e){var n,r=t(this.editors);try{for(r.s();!(n=r.n()).done;){n.value.setAdditionalCssText(e)}}catch(i){r.e(i)}finally{r.f()}}},{key:"getEditorByFileName",value:function(e){var t=this.editors.map(function(e){return"/".concat(e.filename)}).indexOf(e);if(!(t<0))return this.editors[t]}},{key:"playerIsFetching",get:function(){return this._playerIsFetching},set:function(e){this._playerIsFetching=e;var t=this.workspaceControlsElement;e?t.classList.add("wm-player-fetching"):t.classList.remove("wm-player-fetching")}},{key:"workspaceControlsElement",get:function(){return this.shadowRoot.getElementById("wm-controls")}},{key:"playButtonElement",get:function(){return this.shadowRoot.getElementById("btnPlay")}},{key:"stopButtonElement",get:function(){return this.shadowRoot.getElementById("btnStop")}},{key:"createElement",value:function(){return v(this,void 0,void 0,regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.attachShadow({mode:"open"}),t=_.content.cloneNode(!0),this.shadowRoot.appendChild(t),setTimeout(this.init.bind(this));case 4:case"end":return e.stop()}},e,this)}))}},{key:"initListener",value:function(){this.playButtonElement.addEventListener("click",this.onPlayClicked.bind(this)),this.stopButtonElement.addEventListener("click",this.onStopClicked.bind(this))}},{key:"updateMarkers",value:function(e){this.lastEventTimeQuarters=e,this.updateMarkersDebounced()}},{key:"updateMarkersImpl",value:function(){var e=this.lastEventTimeQuarters;this.clearAllEventMarkers();var n=E(this.document.eventInfos).map(function(t){return{diff:Math.abs(e-t.sheetTime),sheetEvents:t.sheetEventInfos}}).minBy(function(e){return e.diff});if(n){var r,i=t(n.sheetEvents);try{for(i.s();!(r=i.n()).done;){var o=r.value,a=this.sourceIdEditorMap.get(o.sourceId);a&&a.addMarkers([o])}}catch(s){i.e(s)}finally{i.f()}}}},{key:"onMidiEvent",value:function(e){e.midiEvent.eventType===w.EventType.NoteOn&&this.updateMarkers(e.position+this.beginQuarters)}},{key:"onPlayerState",value:function(e,t){t===b.PlayerState.Stopped&&(this.clearAllEventMarkers(),this.workspaceControlsElement.classList.remove("wm-state-playing"),this.workspaceControlsElement.classList.add("wm-state-stopped")),t===b.PlayerState.Playing&&(this.workspaceControlsElement.classList.remove("wm-state-stopped"),this.workspaceControlsElement.classList.add("wm-state-playing")),this.playerState=t,this.onStateChanged(e,t)}},{key:"updateSourceIdMap",value:function(e){var n=this;this.sourceIdEditorMap.clear();var r,i=t(e.midi.sources);try{var o=function(){var e=r.value,t=n.editors.find(function(t){return"/"+t.filename===e.path});if(!t)return"continue";n.sourceIdEditorMap.set(e.sourceId,t)};for(i.s();!(r=i.n()).done;)o()}catch(a){i.e(a)}finally{i.f()}}},{key:"onPlayClicked",value:function(e){this.play(e)}},{key:"getEditorFiles",value:function(){var e=this.editors.map(function(e){return{path:e.filename,data:e.getScriptText()}}),t=e.find(function(e){return e.path===C});return t&&this.setAdditionalCssText(t.data),e.filter(function(e){return e.path!==C})}},{key:"play",value:function(e){return v(this,void 0,void 0,regeneratorRuntime.mark(function t(){var n=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,g.WM_Player.prepare(e);case 2:return t.next=4,g.resetCompiler();case 4:this.playerIsFetching=!0,this.onPlayerState(this.playerState,b.PlayerState.Preparing),setTimeout(function(){return v(n,void 0,void 0,regeneratorRuntime.mark(function t(){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,n=this.getEditorFiles(),this.clearAllEditorMarkers(),t.next=5,g.WM_Compiler.compile(n,this.beginQuarters);case 5:this.document=t.sent,this.onCompiled(this.document),this.updateSourceIdMap(this.document),this.document.midi.warnings&&this.document.midi.warnings.length>0&&this._onWarnings(this.document.midi.warnings),g.WM_Player.prepareDevices(this.document),t.next=18;break;case 12:return t.prev=12,t.t0=t.catch(0),this._onError(t.t0.error||t.t0),this.playerIsFetching=!1,this.onPlayerState(this.playerState,b.PlayerState.Stopped),t.abrupt("return");case 18:return g.WM_Player.tempo=this.document.midi.bpm,t.next=21,g.WM_Player.play(this.document.midi.midiData,e,this.onMidiEvent.bind(this),this.onPlayerState.bind(this));case 21:this.playerIsFetching=!1;case 22:case"end":return t.stop()}},t,this,[[0,12]])}))});case 7:case"end":return t.stop()}},t,this)}))}},{key:"download",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"WerckmeisterMidi.mid";return v(this,void 0,void 0,regeneratorRuntime.mark(function t(){var n,r,i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,g.resetCompiler();case 2:return t.prev=2,n=this.editors.map(function(e){return{path:e.filename,data:e.getScriptText()}}),t.next=6,g.WM_Compiler.compile(n);case 6:this.document=t.sent,t.next=13;break;case 9:return t.prev=9,t.t0=t.catch(2),this._onError(t.t0.error||t.t0),t.abrupt("return");case 13:r="data:midi;base64,".concat(this.document.midi.midiData),(i=document.createElement("a")).href=r,i.download=e,i.click();case 18:case"end":return t.stop()}},t,this,[[2,9]])}))}},{key:"onStopClicked",value:function(e){this.stop()}},{key:"stop",value:function(){return v(this,void 0,void 0,regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,g.WM_Player.stop();case 2:case"end":return e.stop()}},e)}))}},{key:"clearAllEditorMarkers",value:function(){var e,n=t(this.editors);try{for(n.s();!(e=n.n()).done;){e.value.clearAllMarkers()}}catch(r){n.e(r)}finally{n.f()}}},{key:"clearAllEventMarkers",value:function(){var e,n=t(this.editors);try{for(n.s();!(e=n.n()).done;){e.value.clearEventMarkers()}}catch(r){n.e(r)}finally{n.f()}}},{key:"_onError",value:function(e){if(e instanceof Error)console.error("".concat(e));else{this.onError(e),console.error("".concat(e.sourceFile,'": ').concat(e.errorMessage));var t=this.getEditorByFileName(e.sourceFile);t&&t.setError(e)}}},{key:"_onWarnings",value:function(e){var n,r=t(e);try{for(r.s();!(n=r.n()).done;){var i=n.value;console.warn(i.message),this.getEditorByFileName(i.sourceFile).addWarning(i)}}catch(o){r.e(o)}finally{r.f()}this.onWarnings(e)}},{key:"init",value:function(){this.initListener(),this.readAttributes()}},{key:"loadExternalCss",value:function(e){return v(this,void 0,void 0,regeneratorRuntime.mark(function t(){var n,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,k.fetchText(e);case 2:n=t.sent,(r=document.createElement("style")).innerText=n,this.shadowRoot.appendChild(r);case 6:case"end":return t.stop()}},t,this)}))}},{key:"readAttributes",value:function(){return v(this,void 0,void 0,regeneratorRuntime.mark(function e(){var t,n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:(t=this.attributes.getNamedItem("wm-onerror"))&&console.error(t),(n=this.attributes.getNamedItem("wm-css-url"))&&this.loadExternalCss(n.value),(r=this.attributes.getNamedItem("wm-soundfont-url"))&&g.WM_Player.setSoundfontRepoUrl(r.value);case 6:case"end":return e.stop()}},e,this)}))}},{key:"registerEditor",value:function(e){this.editors.push(e),e.initiated.then(function(){var t=e.filename,n=e.getScriptText();g.WM_Compiler.writeFileToFS(t,n)})}},{key:"unregisterEditor",value:function(e){var t=this.editors.indexOf(e);t<0||this.editors.splice(t,1)}},{key:"getPlayerImpl",value:function(){return g.WM_Player}},{key:"isClean",value:function(){return E.every(this.editors,function(e){return e.isClean()})}},{key:"markClean",value:function(){var e,n=t(this.editors);try{for(n.s();!(e=n.n()).done;){e.value.markClean()}}catch(r){n.e(r)}finally{n.f()}}}]),r}();exports.Workspace=I;
|
|
514
514
|
},{"../../Global":"ooUX","../../shared/midiEvent":"vkzS","../../shared/player":"FYcy","../../shared/http":"vSbS","lodash":"B1iE","fs":"rDCW"}],"Rngn":[function(require,module,exports) {
|
|
515
515
|
"use strict";exports.__esModule=!0,exports.default=function(){},module.exports=exports.default;
|