flat-embed
Advanced tools
Comparing version 1.0.0 to 1.1.0
# Changelog | ||
## v1.1.0 | ||
* Support for MIDI Output | ||
## v1.0.0 | ||
@@ -4,0 +8,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! flat-embed v1.0.0 | (c) 2019 Tutteo Ltd. (Flat) | Apache-2.0 License | https://github.com/FlatIO/embed-client */ | ||
/*! flat-embed v1.1.0 | (c) 2019 Tutteo Ltd. (Flat) | Apache-2.0 License | https://github.com/FlatIO/embed-client */ | ||
(function (global, factory) { | ||
@@ -114,2 +114,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
iframe.setAttribute('allowfullscreen', true); | ||
iframe.setAttribute('allow', 'midi'); | ||
iframe.setAttribute('frameborder', '0'); | ||
@@ -116,0 +117,0 @@ element.appendChild(iframe); |
@@ -1,2 +0,2 @@ | ||
/*! flat-embed v1.0.0 | (c) 2019 Tutteo Ltd. (Flat) | Apache-2.0 License | https://github.com/FlatIO/embed-client */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e=e||self).Flat=e.Flat||{},e.Flat.Embed=t())}(this,function(){"use strict";function o(e){return(o="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})(e)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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 e(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}if(void 0===window.postMessage)throw new Error("The Flat Embed JS API is not supported in this browser");function i(e,t){var n=function(e){var t=e.baseUrl||"https://flat-embed.com";t+="/"+(e.score||"blank");var n=Object.assign({jsapi:!0},e.embedParams);return t+"?"+Object.keys(n).map(function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(n[e]))}).join("&")}(t),r=document.createElement("iframe");return r.setAttribute("src",n),r.setAttribute("width",t.width||"100%"),r.setAttribute("height",t.height||"100%"),r.setAttribute("allowfullscreen",!0),r.setAttribute("frameborder","0"),e.appendChild(r),r}function s(e,t,n){if(!e.element.contentWindow||!e.element.contentWindow.postMessage)throw new Error("No `contentWindow` or `contentWindow.postMessage` avaialble on the element");var r={method:t,parameters:n};e.element.contentWindow.postMessage(r,e.origin)}var a=function(){function t(e){return n(this,t),this.embed=e,this.promises={},this.eventCallbacks={},this}return e(t,[{key:"pushCall",value:function(e,t,n){this.promises[e]=this.promises[e]||[],this.promises[e].push({resolve:t,reject:n})}},{key:"subscribeEvent",value:function(e,t){return this.eventCallbacks[e]=this.eventCallbacks[e]||[],this.eventCallbacks[e].push(t),1===this.eventCallbacks[e].length}},{key:"unsubscribeEvent",value:function(e,t){if(!this.eventCallbacks[e])return!1;if(t){var n=this.eventCallbacks[e].indexOf(t);0<=n&&this.eventCallbacks[e].splice(n,1)}else this.eventCallbacks[e]=[];return!t||0===this.eventCallbacks[e].length}},{key:"process",value:function(e){e.method?this.processMethodResponse(e):e.event&&this.processEvent(e)}},{key:"processMethodResponse",value:function(e){if(this.promises[e.method]){var t=this.promises[e.method].shift();t&&(e.error?t.reject(e.error):t.resolve(e.response))}}},{key:"processEvent",value:function(t){var n=this;this.eventCallbacks[t.event]&&0!==this.eventCallbacks[t.event].length&&this.eventCallbacks[t.event].forEach(function(e){e.call(n.embed,t.parameters)})}}]),t}(),u=new WeakMap,l=new WeakMap;return function(){function Embed(r){var o=this,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(n(this,Embed),r=function(e){if(window.jQuery&&e instanceof window.jQuery&&(e=e[0]),"string"==typeof e&&(e=document.getElementById(e)),!(e instanceof window.HTMLElement))throw new TypeError("The first parameter must be an existing DOM element or an identifier.");if("IFRAME"!==e.nodeName){var t=e.querySelector("iframe");t&&(e=t)}return e}(r),u.has(r))return u.get(r);"IFRAME"!==r.nodeName&&(r=i(r,e)),this.origin="*",this.element=r,this.embedCallback=new a;var t=new Promise(function(n){window.addEventListener("message",function(e){if(r.contentWindow===e.source){"*"===o.origin&&(o.origin=e.origin);var t=function(e){return"string"==typeof e&&(e=JSON.parse(e)),e}(e.data);"ready"!==t.event&&"ping"!==t.method?o.embedCallback.process(t):n()}},!1),s(o,"ping")});return u.set(this.element,this),l.set(this,t),this}return e(Embed,[{key:"ready",value:function(){return Promise.resolve(l.get(this))}},{key:"call",value:function(n){var r=this,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(e,t){return r.ready().then(function(){r.embedCallback.pushCall(n,e,t),s(r,n,o)})})}},{key:"on",value:function(e,t){if("string"!=typeof e)throw new TypeError("An event name (string) is required");if("function"!=typeof t)throw new TypeError("An callback (function) is required");this.embedCallback.subscribeEvent(e,t)&&this.call("addEventListener",e).catch(function(){})}},{key:"off",value:function(e,t){if("string"!=typeof e)throw new TypeError("An event name (string) is required");this.embedCallback.unsubscribeEvent(e,t)&&this.call("removeEventListener",e).catch(function(){})}},{key:"loadFlatScore",value:function(e,t){return this.call("loadFlatScore",{score:e,revision:t})}},{key:"loadMusicXML",value:function(e){return this.call("loadMusicXML",e)}},{key:"loadJSON",value:function(e){return this.call("loadJSON",e)}},{key:"getJSON",value:function(){return this.call("getJSON")}},{key:"getMusicXML",value:function(n){var r=this;return new Promise(function(t,e){if("object"!==o(n=n||{}))return e(new TypeError("Options must be an object"));r.call("getMusicXML",n).then(function(e){return t("string"==typeof e?e:new Uint8Array(e))}).catch(e)})}},{key:"getPNG",value:function(n){var r=this;return new Promise(function(t,e){if("object"!==o(n=n||{}))return e(new TypeError("Options must be an object"));r.call("getPNG",n).then(function(e){return t("string"==typeof e?e:new Uint8Array(e))}).catch(e)})}},{key:"getMIDI",value:function(){return this.call("getMIDI").then(function(e){return new Uint8Array(e)})}},{key:"getFlatScoreMetadata",value:function(){return this.call("getFlatScoreMetadata")}},{key:"getEmbedConfig",value:function(){return this.call("getEmbedConfig")}},{key:"setEditorConfig",value:function(e){return this.call("setEditorConfig",e)}},{key:"fullscreen",value:function(e){return this.call("fullscreen",e)}},{key:"play",value:function(){return this.call("play")}},{key:"pause",value:function(){return this.call("pause")}},{key:"stop",value:function(){return this.call("stop")}},{key:"mute",value:function(){return this.call("mute")}},{key:"print",value:function(){return this.call("print")}},{key:"getZoom",value:function(){return this.call("getZoom")}},{key:"setZoom",value:function(e){return this.call("setZoom",e)}},{key:"getAutoZoom",value:function(){return this.call("getAutoZoom")}},{key:"setAutoZoom",value:function(e){return this.call("setAutoZoom",e)}},{key:"focusScore",value:function(){return this.call("focusScore")}},{key:"getCursorPosition",value:function(){return this.call("getCursorPosition")}},{key:"setCursorPosition",value:function(e){return this.call("setCursorPosition",e)}}]),Embed}()}); | ||
/*! flat-embed v1.1.0 | (c) 2019 Tutteo Ltd. (Flat) | Apache-2.0 License | https://github.com/FlatIO/embed-client */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e=e||self).Flat=e.Flat||{},e.Flat.Embed=t())}(this,function(){"use strict";function o(e){return(o="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})(e)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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 e(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}if(void 0===window.postMessage)throw new Error("The Flat Embed JS API is not supported in this browser");function i(e,t){var n=function(e){var t=e.baseUrl||"https://flat-embed.com";t+="/"+(e.score||"blank");var n=Object.assign({jsapi:!0},e.embedParams);return t+"?"+Object.keys(n).map(function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(n[e]))}).join("&")}(t),r=document.createElement("iframe");return r.setAttribute("src",n),r.setAttribute("width",t.width||"100%"),r.setAttribute("height",t.height||"100%"),r.setAttribute("allowfullscreen",!0),r.setAttribute("allow","midi"),r.setAttribute("frameborder","0"),e.appendChild(r),r}function s(e,t,n){if(!e.element.contentWindow||!e.element.contentWindow.postMessage)throw new Error("No `contentWindow` or `contentWindow.postMessage` avaialble on the element");var r={method:t,parameters:n};e.element.contentWindow.postMessage(r,e.origin)}var a=function(){function t(e){return n(this,t),this.embed=e,this.promises={},this.eventCallbacks={},this}return e(t,[{key:"pushCall",value:function(e,t,n){this.promises[e]=this.promises[e]||[],this.promises[e].push({resolve:t,reject:n})}},{key:"subscribeEvent",value:function(e,t){return this.eventCallbacks[e]=this.eventCallbacks[e]||[],this.eventCallbacks[e].push(t),1===this.eventCallbacks[e].length}},{key:"unsubscribeEvent",value:function(e,t){if(!this.eventCallbacks[e])return!1;if(t){var n=this.eventCallbacks[e].indexOf(t);0<=n&&this.eventCallbacks[e].splice(n,1)}else this.eventCallbacks[e]=[];return!t||0===this.eventCallbacks[e].length}},{key:"process",value:function(e){e.method?this.processMethodResponse(e):e.event&&this.processEvent(e)}},{key:"processMethodResponse",value:function(e){if(this.promises[e.method]){var t=this.promises[e.method].shift();t&&(e.error?t.reject(e.error):t.resolve(e.response))}}},{key:"processEvent",value:function(t){var n=this;this.eventCallbacks[t.event]&&0!==this.eventCallbacks[t.event].length&&this.eventCallbacks[t.event].forEach(function(e){e.call(n.embed,t.parameters)})}}]),t}(),u=new WeakMap,l=new WeakMap;return function(){function Embed(r){var o=this,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(n(this,Embed),r=function(e){if(window.jQuery&&e instanceof window.jQuery&&(e=e[0]),"string"==typeof e&&(e=document.getElementById(e)),!(e instanceof window.HTMLElement))throw new TypeError("The first parameter must be an existing DOM element or an identifier.");if("IFRAME"!==e.nodeName){var t=e.querySelector("iframe");t&&(e=t)}return e}(r),u.has(r))return u.get(r);"IFRAME"!==r.nodeName&&(r=i(r,e)),this.origin="*",this.element=r,this.embedCallback=new a;var t=new Promise(function(n){window.addEventListener("message",function(e){if(r.contentWindow===e.source){"*"===o.origin&&(o.origin=e.origin);var t=function(e){return"string"==typeof e&&(e=JSON.parse(e)),e}(e.data);"ready"!==t.event&&"ping"!==t.method?o.embedCallback.process(t):n()}},!1),s(o,"ping")});return u.set(this.element,this),l.set(this,t),this}return e(Embed,[{key:"ready",value:function(){return Promise.resolve(l.get(this))}},{key:"call",value:function(n){var r=this,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(e,t){return r.ready().then(function(){r.embedCallback.pushCall(n,e,t),s(r,n,o)})})}},{key:"on",value:function(e,t){if("string"!=typeof e)throw new TypeError("An event name (string) is required");if("function"!=typeof t)throw new TypeError("An callback (function) is required");this.embedCallback.subscribeEvent(e,t)&&this.call("addEventListener",e).catch(function(){})}},{key:"off",value:function(e,t){if("string"!=typeof e)throw new TypeError("An event name (string) is required");this.embedCallback.unsubscribeEvent(e,t)&&this.call("removeEventListener",e).catch(function(){})}},{key:"loadFlatScore",value:function(e,t){return this.call("loadFlatScore",{score:e,revision:t})}},{key:"loadMusicXML",value:function(e){return this.call("loadMusicXML",e)}},{key:"loadJSON",value:function(e){return this.call("loadJSON",e)}},{key:"getJSON",value:function(){return this.call("getJSON")}},{key:"getMusicXML",value:function(n){var r=this;return new Promise(function(t,e){if("object"!==o(n=n||{}))return e(new TypeError("Options must be an object"));r.call("getMusicXML",n).then(function(e){return t("string"==typeof e?e:new Uint8Array(e))}).catch(e)})}},{key:"getPNG",value:function(n){var r=this;return new Promise(function(t,e){if("object"!==o(n=n||{}))return e(new TypeError("Options must be an object"));r.call("getPNG",n).then(function(e){return t("string"==typeof e?e:new Uint8Array(e))}).catch(e)})}},{key:"getMIDI",value:function(){return this.call("getMIDI").then(function(e){return new Uint8Array(e)})}},{key:"getFlatScoreMetadata",value:function(){return this.call("getFlatScoreMetadata")}},{key:"getEmbedConfig",value:function(){return this.call("getEmbedConfig")}},{key:"setEditorConfig",value:function(e){return this.call("setEditorConfig",e)}},{key:"fullscreen",value:function(e){return this.call("fullscreen",e)}},{key:"play",value:function(){return this.call("play")}},{key:"pause",value:function(){return this.call("pause")}},{key:"stop",value:function(){return this.call("stop")}},{key:"mute",value:function(){return this.call("mute")}},{key:"print",value:function(){return this.call("print")}},{key:"getZoom",value:function(){return this.call("getZoom")}},{key:"setZoom",value:function(e){return this.call("setZoom",e)}},{key:"getAutoZoom",value:function(){return this.call("getAutoZoom")}},{key:"setAutoZoom",value:function(e){return this.call("setAutoZoom",e)}},{key:"focusScore",value:function(){return this.call("focusScore")}},{key:"getCursorPosition",value:function(){return this.call("getCursorPosition")}},{key:"setCursorPosition",value:function(e){return this.call("setCursorPosition",e)}}]),Embed}()}); |
{ | ||
"name": "flat-embed", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Interact and get events from Flat's Sheet Music Embed", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -25,3 +25,3 @@ # Flat Sheet Music Embed Client | ||
```html | ||
<script src="https://prod.flat-cdn.com/embed-js/v1.0.0/embed.min.js"></script> | ||
<script src="https://prod.flat-cdn.com/embed-js/v1.1.0/embed.min.js"></script> | ||
``` | ||
@@ -35,3 +35,3 @@ | ||
<div id="embed-container"></div> | ||
<script src="https://prod.flat-cdn.com/embed-js/v1.0.0/embed.min.js"></script> | ||
<script src="https://prod.flat-cdn.com/embed-js/v1.1.0/embed.min.js"></script> | ||
<script> | ||
@@ -38,0 +38,0 @@ var container = document.getElementById('embed-container'); |
@@ -38,2 +38,3 @@ /** | ||
iframe.setAttribute('allowfullscreen', true); | ||
iframe.setAttribute('allow', 'midi'); | ||
iframe.setAttribute('frameborder', '0'); | ||
@@ -40,0 +41,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104995
1168