Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flat-embed

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flat-embed - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

4

CHANGELOG.md
# Changelog
## v0.9.0
* Add method: `mute`
## v0.8.0

@@ -4,0 +8,0 @@

125

dist/embed.js

@@ -1,2 +0,2 @@

/*! flat-embed v0.7.0 | (c) 2017 Tutteo Ltd. (Flat) | Apache-2.0 License | https://github.com/FlatIO/embed-client */
/*! flat-embed v0.9.0 | (c) 2017 Tutteo Ltd. (Flat) | Apache-2.0 License | https://github.com/FlatIO/embed-client */
(function (global, factory) {

@@ -132,119 +132,8 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :

var asyncGenerator = function () {
function AwaitValue(value) {
this.value = value;
}
function AsyncGenerator(gen) {
var front, back;
function send(key, arg) {
return new Promise(function (resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};
if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
}
function resume(key, arg) {
try {
var result = gen[key](arg);
var value = result.value;
if (value instanceof AwaitValue) {
Promise.resolve(value.value).then(function (arg) {
resume("next", arg);
}, function (arg) {
resume("throw", arg);
});
} else {
settle(result.done ? "return" : "normal", result.value);
}
} catch (err) {
settle("throw", err);
}
}
function settle(type, value) {
switch (type) {
case "return":
front.resolve({
value: value,
done: true
});
break;
case "throw":
front.reject(value);
break;
default:
front.resolve({
value: value,
done: false
});
break;
}
front = front.next;
if (front) {
resume(front.key, front.arg);
} else {
back = null;
}
}
this._invoke = send;
if (typeof gen.return !== "function") {
this.return = undefined;
}
}
if (typeof Symbol === "function" && Symbol.asyncIterator) {
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
return this;
};
}
AsyncGenerator.prototype.next = function (arg) {
return this._invoke("next", arg);
};
AsyncGenerator.prototype.throw = function (arg) {
return this._invoke("throw", arg);
};
AsyncGenerator.prototype.return = function (arg) {
return this._invoke("return", arg);
};
return {
wrap: function (fn) {
return function () {
return new AsyncGenerator(fn.apply(this, arguments));
};
},
await: function (value) {
return new AwaitValue(value);
}
};
}();
var classCallCheck = function (instance, Constructor) {

@@ -727,2 +616,14 @@ if (!(instance instanceof Constructor)) {

/**
* Mute playback
*
* @return {Promise}
*/
}, {
key: 'mute',
value: function mute() {
return this.call('mute');
}
/**
* Print the score

@@ -729,0 +630,0 @@ *

@@ -1,2 +0,2 @@

/*! flat-embed v0.7.0 | (c) 2017 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.Flat=e.Flat||{},e.Flat.Embed=t())}(this,function(){"use strict";function e(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}function t(e){var t=e.baseUrl||"https://flat.io/embed";t+="/"+(e.score||"blank");var n=Object.assign({jsapi:!0},e.embedParams);return t+"?"+Object.keys(n).map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(n[e])}).join("&")}function n(e,n){var r=t(n),o=document.createElement("iframe");return o.setAttribute("src",r),o.setAttribute("width",n.width||"100%"),o.setAttribute("height",n.height||"100%"),o.setAttribute("allowfullscreen",!0),o.setAttribute("frameborder","0"),e.appendChild(o),o}function r(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)}function o(e){return"string"==typeof e&&(e=JSON.parse(e)),e}if(void 0===window.postMessage)throw new Error("The Flat Embed JS API is not supported in this browser");var i="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},s=(function(){function e(e){this.value=e}function t(t){function n(o,i){try{var s=t[o](i),u=s.value;u instanceof e?Promise.resolve(u.value).then(function(e){n("next",e)},function(e){n("throw",e)}):r(s.done?"return":"normal",s.value)}catch(e){r("throw",e)}}function r(e,t){switch(e){case"return":o.resolve({value:t,done:!0});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:!1})}(o=o.next)?n(o.key,o.arg):i=null}var o,i;this._invoke=function(e,t){return new Promise(function(r,s){var u={key:e,arg:t,resolve:r,reject:s,next:null};i?i=i.next=u:(o=i=u,n(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}),u=function(){function e(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)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(t){return s(this,e),this.embed=t,this.promises={},this.eventCallbacks={},this}return u(e,[{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);n>=0&&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){var t=this.promises[e.method].shift();t&&(e.error?t.reject(e.error):t.resolve(e.response))}},{key:"processEvent",value:function(e){var t=this;this.eventCallbacks[e.event]&&0!==this.eventCallbacks[e.event].length&&this.eventCallbacks[e.event].forEach(function(n){n.call(t.embed,e.parameters)})}}]),e}(),l=new WeakMap,c=new WeakMap;return function(){function Embed(t){var i=this,u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(s(this,Embed),t=e(t),l.has(t))return l.get(t);"IFRAME"!==t.nodeName&&(t=n(t,u)),this.origin="*",this.element=t,this.embedCallback=new a;var f=new Promise(function(e){window.addEventListener("message",function(n){if(t.contentWindow===n.source){"*"===i.origin&&(i.origin=n.origin);var r=o(n.data);"ready"!==r.event&&"ping"!==r.method?i.embedCallback.process(r):e()}},!1),r(i,"ping")});return l.set(this.element,this),c.set(this,f),this}return u(Embed,[{key:"ready",value:function(){return Promise.resolve(c.get(this))}},{key:"call",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(o,i){return t.ready().then(function(){t.embedCallback.pushCall(e,o,i),r(t,e,n)})})}},{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(e){var t=this;return new Promise(function(n,r){if("object"!==(void 0===(e=e||{})?"undefined":i(e)))return r(new TypeError("Options must be an object"));t.call("getMusicXML",e).then(function(e){return n("string"==typeof e?e:new Uint8Array(e.data))}).catch(r)})}},{key:"getPNG",value:function(e){var t=this;return new Promise(function(n,r){if("object"!==(void 0===(e=e||{})?"undefined":i(e)))return r(new TypeError("Options must be an object"));t.call("getPNG",e).then(function(e){return n("string"==typeof e?e:new Uint8Array(e))}).catch(r)})}},{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:"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)}},{key:"edit",value:function(e){return this.call("edit",e)}},{key:"setNoteColor",value:function(e,t){return this.call("setNoteColor",{note:e,color:t})}}]),Embed}()});
/*! flat-embed v0.9.0 | (c) 2017 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.Flat=e.Flat||{},e.Flat.Embed=t())}(this,function(){"use strict";function e(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}function t(e){var t=e.baseUrl||"https://flat.io/embed";t+="/"+(e.score||"blank");var n=Object.assign({jsapi:!0},e.embedParams);return t+"?"+Object.keys(n).map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(n[e])}).join("&")}function n(e,n){var r=t(n),o=document.createElement("iframe");return o.setAttribute("src",r),o.setAttribute("width",n.width||"100%"),o.setAttribute("height",n.height||"100%"),o.setAttribute("allowfullscreen",!0),o.setAttribute("frameborder","0"),e.appendChild(o),o}function r(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)}function o(e){return"string"==typeof e&&(e=JSON.parse(e)),e}if(void 0===window.postMessage)throw new Error("The Flat Embed JS API is not supported in this browser");var i="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},s=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},a=function(){function e(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)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=function(){function e(t){return s(this,e),this.embed=t,this.promises={},this.eventCallbacks={},this}return a(e,[{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);n>=0&&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){var t=this.promises[e.method].shift();t&&(e.error?t.reject(e.error):t.resolve(e.response))}},{key:"processEvent",value:function(e){var t=this;this.eventCallbacks[e.event]&&0!==this.eventCallbacks[e.event].length&&this.eventCallbacks[e.event].forEach(function(n){n.call(t.embed,e.parameters)})}}]),e}(),l=new WeakMap,c=new WeakMap;return function(){function Embed(t){var i=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(s(this,Embed),t=e(t),l.has(t))return l.get(t);"IFRAME"!==t.nodeName&&(t=n(t,a)),this.origin="*",this.element=t,this.embedCallback=new u;var f=new Promise(function(e){window.addEventListener("message",function(n){if(t.contentWindow===n.source){"*"===i.origin&&(i.origin=n.origin);var r=o(n.data);"ready"!==r.event&&"ping"!==r.method?i.embedCallback.process(r):e()}},!1),r(i,"ping")});return l.set(this.element,this),c.set(this,f),this}return a(Embed,[{key:"ready",value:function(){return Promise.resolve(c.get(this))}},{key:"call",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(o,i){return t.ready().then(function(){t.embedCallback.pushCall(e,o,i),r(t,e,n)})})}},{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(e){var t=this;return new Promise(function(n,r){if("object"!==(void 0===(e=e||{})?"undefined":i(e)))return r(new TypeError("Options must be an object"));t.call("getMusicXML",e).then(function(e){return n("string"==typeof e?e:new Uint8Array(e.data))}).catch(r)})}},{key:"getPNG",value:function(e){var t=this;return new Promise(function(n,r){if("object"!==(void 0===(e=e||{})?"undefined":i(e)))return r(new TypeError("Options must be an object"));t.call("getPNG",e).then(function(e){return n("string"==typeof e?e:new Uint8Array(e))}).catch(r)})}},{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)}},{key:"edit",value:function(e){return this.call("edit",e)}},{key:"setNoteColor",value:function(e,t){return this.call("setNoteColor",{note:e,color:t})}}]),Embed}()});
{
"name": "flat-embed",
"version": "0.8.0",
"version": "0.9.0",
"description": "Interact and get events from Flat's Sheet Music Embed",

@@ -53,3 +53,3 @@ "license": "Apache-2.0",

"mocha": "^4.0.0",
"rollup": "^0.50.0",
"rollup": "^0.51.0",
"rollup-plugin-babel": "^3.0.0",

@@ -56,0 +56,0 @@ "rollup-plugin-commonjs": "^8.0.2",

@@ -98,2 +98,3 @@ # Flat Sheet Music Embed Client

* [`stop`](#stop-promisevoid-error): Stop playback
* [`mute`](#mute-promisevoid-error): Mute playback
* [`print`](#print-promisevoid-error): Print the score

@@ -356,2 +357,12 @@ * [`getZoom`](#getzoom-promisenumber-error): Get the current display zoom ratio

### `mute(): Promise<void, Error>`
Mute the playback
```js
embed.mute().then(function () {
// The playback is muted
});
```
### `print(): Promise<void, Error>`

@@ -358,0 +369,0 @@

@@ -278,2 +278,11 @@ import './lib/compatibility';

/**
* Mute playback
*
* @return {Promise}
*/
mute() {
return this.call('mute');
}
/**
* Print the score

@@ -280,0 +289,0 @@ *

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc