Changeset 2465987
- Timestamp:
- 01/31/2021 06:12:09 PM (5 years ago)
- Location:
- audius-block/trunk
- Files:
-
- 6 edited
-
README.txt (modified) (1 diff)
-
audius-plugin.php (modified) (1 diff)
-
build/index.asset.php (modified) (1 diff)
-
build/index.js (modified) (1 diff)
-
package.json (modified) (1 diff)
-
src/index.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
audius-block/trunk/README.txt
r2465731 r2465987 4 4 Requires at least: 5.0 5 5 Tested up to: 5.6 6 Stable tag: 1. 0.06 Stable tag: 1.1.0 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
audius-block/trunk/audius-plugin.php
r2465731 r2465987 5 5 * Plugin URI: https://github.com/audius/wordpress 6 6 * Description: Easily embed your favorite tracks from Audius, a brand-new streaming platform built for all musicians. 7 * Version: 1. 0.07 * Version: 1.1.0 8 8 * Author: Audius 9 9 * Author URI: https://audius.co/ -
audius-block/trunk/build/index.asset.php
r2465731 r2465987 1 <?php return array('dependencies' => array('wp-blocks', 'wp-components', 'wp-element', 'wp-polyfill'), 'version' => ' c5fb6cc0653ff1aa2b6325dcc7aca616');1 <?php return array('dependencies' => array('wp-blocks', 'wp-components', 'wp-element', 'wp-polyfill'), 'version' => '0d3e28143a3ab5e3a8f1ccfd7bd634d0'); -
audius-block/trunk/build/index.js
r2465731 r2465987 1 !function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=11)}([function(t,e){!function(){t.exports=this.wp.element}()},function(t,e){!function(){t.exports=this.regeneratorRuntime}()},function(t,e){function r(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(i,a){var o=t.apply(e,n);function c(t){r(o,i,a,c,s,"next",t)}function s(t){r(o,i,a,c,s,"throw",t)}c(void 0)}))}}},function(t,e,r){var n=r(6),i=r(7),a=r(8),o=r(10);t.exports=function(t,e){return n(t)||i(t,e)||a(t,e)||o()}},function(t,e){!function(){t.exports=this.wp.components}()},function(t,e){!function(){t.exports=this.wp.blocks}()},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var r=[],n=!0,i=!1,a=void 0;try{for(var o,c=t[Symbol.iterator]();!(n=(o=c.next()).done)&&(r.push(o.value),!e||r.length!==e);n=!0);}catch(t){i=!0,a=t}finally{try{n||null==c.return||c.return()}finally{if(i)throw a}}return r}}},function(t,e,r){var n=r(9);t.exports=function(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(t,e,r){"use strict";r.r(e);var n=r(1),i=r.n(n),a=r(2),o=r.n(a),c=r(3),s=r.n(c),l=r(0),u=r(5),h=r(4);function f(t){return function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e<t.length;e++)r[e]=t[e];return r}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var d=function(){function t(t,e,r,n){if(void 0===t&&(t=""),void 0===e&&(e=0),void 0===r&&(r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"),void 0===n&&(n="cfhistuCFHISTU"),this.minLength=e,"number"!=typeof e)throw new TypeError("Hashids: Provided 'minLength' has to be a number (is "+typeof e+")");if("string"!=typeof t)throw new TypeError("Hashids: Provided 'salt' has to be a string (is "+typeof t+")");if("string"!=typeof r)throw new TypeError("Hashids: Provided alphabet has to be a string (is "+typeof r+")");var i=Array.from(t),a=Array.from(r),o=Array.from(n);this.salt=i;var c=m(a);if(c.length<p)throw new Error("Hashids: alphabet must contain at least "+p+" unique characters, provided: "+c);this.alphabet=v(c,o);var s,l,u,h=y(o,c);(this.seps=j(h,i),0===this.seps.length||this.alphabet.length/this.seps.length>b)&&((s=Math.ceil(this.alphabet.length/b))>this.seps.length&&(l=s-this.seps.length,(u=this.seps).push.apply(u,f(this.alphabet.slice(0,l))),this.alphabet=this.alphabet.slice(l)));this.alphabet=j(this.alphabet,i);var d=Math.ceil(this.alphabet.length/g);this.alphabet.length<3?(this.guards=this.seps.slice(0,d),this.seps=this.seps.slice(d)):(this.guards=this.alphabet.slice(0,d),this.alphabet=this.alphabet.slice(d)),this.guardsRegExp=A(this.guards),this.sepsRegExp=A(this.seps),this.allowedCharsRegExp=T([].concat(f(this.alphabet),f(this.guards),f(this.seps)))}var e=t.prototype;return e.encode=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];var i="";return(r=Array.isArray(t)?t:[].concat(f(null!=t?[t]:[]),f(r))).length?(r.every(w)||(r=r.map((function(t){return"bigint"==typeof t||"number"==typeof t?t:k(String(t))}))),r.every(x)?this._encode(r).join(""):i):i},e.decode=function(t){return t&&"string"==typeof t&&0!==t.length?this._decode(t):[]},e.encodeHex=function(t){switch(typeof t){case"bigint":t=t.toString(16);break;case"string":if(!/^[0-9a-fA-F]+$/.test(t))return"";break;default:throw new Error("Hashids: The provided value is neither a string, nor a BigInt (got: "+typeof t+")")}var e=I(t,12,(function(t){return parseInt("1"+t,16)}));return this.encode(e)},e.decodeHex=function(t){return this.decode(t).map((function(t){return t.toString(16).slice(1)})).join("")},e._encode=function(t){var e=this,r=this.alphabet,n=t.reduce((function(t,e,r){return t+("bigint"==typeof e?Number(e%BigInt(r+100)):e%(r+100))}),0),i=[r[n%r.length]],a=i.slice(),o=this.seps,c=this.guards;if(t.forEach((function(n,c){var s,l=a.concat(e.salt,r);r=j(r,l);var u=E(n,r);if((s=i).push.apply(s,f(u)),c+1<t.length){var h=u[0].codePointAt(0)+c,d="bigint"==typeof n?Number(n%BigInt(h)):n%h;i.push(o[d%o.length])}})),i.length<this.minLength){var s=(n+i[0].codePointAt(0))%c.length;if(i.unshift(c[s]),i.length<this.minLength){var l=(n+i[2].codePointAt(0))%c.length;i.push(c[l])}}for(var u=Math.floor(r.length/2);i.length<this.minLength;){var h,d;r=j(r,r),(h=i).unshift.apply(h,f(r.slice(u))),(d=i).push.apply(d,f(r.slice(0,u)));var p=i.length-this.minLength;if(p>0){var b=p/2;i=i.slice(b,b+this.minLength)}}return i},e.isValidId=function(t){return this.allowedCharsRegExp.test(t)},e._decode=function(t){if(!this.isValidId(t))throw new Error("The provided ID ("+t+") is invalid, as it contains characters that do not exist in the alphabet ("+this.guards.join("")+this.seps.join("")+this.alphabet.join("")+")");var e=t.split(this.guardsRegExp),r=e[3===e.length||2===e.length?1:0];if(0===r.length)return[];var n=r[Symbol.iterator]().next().value,i=r.slice(n.length).split(this.sepsRegExp),a=this.alphabet,o=[],c=i,s=Array.isArray(c),l=0;for(c=s?c:c[Symbol.iterator]();;){var u;if(s){if(l>=c.length)break;u=c[l++]}else{if((l=c.next()).done)break;u=l.value}var h=u,d=j(a,[n].concat(f(this.salt),f(a)).slice(0,a.length));o.push(O(Array.from(h),d)),a=d}return this._encode(o).join("")!==t?[]:o},t}(),p=16,b=3.5,g=12,m=function(t){return Array.from(new Set(t))},v=function(t,e){return t.filter((function(t){return!e.includes(t)}))},y=function(t,e){return t.filter((function(t){return e.includes(t)}))},w=function(t){return"bigint"==typeof t||!Number.isNaN(Number(t))&&Math.floor(Number(t))===t},x=function(t){return"bigint"==typeof t||t>=0&&Number.isSafeInteger(t)};function j(t,e){if(0===e.length)return t;for(var r,n=t.slice(),i=n.length-1,a=0,o=0;i>0;i--,a++){o+=r=e[a%=e.length].codePointAt(0);var c=(r+a+o)%i,s=n[i],l=n[c];n[c]=s,n[i]=l}return n}var E=function(t,e){var r=[];if("bigint"==typeof t){var n=BigInt(e.length);do{r.unshift(e[Number(t%n)]),t/=n}while(t>BigInt(0))}else do{r.unshift(e[t%e.length]),t=Math.floor(t/e.length)}while(t>0);return r},O=function(t,e){return t.reduce((function(r,n){var i=e.indexOf(n);if(-1===i)throw new Error("The provided ID ("+t.join("")+") is invalid, as it contains characters that do not exist in the alphabet ("+e.join("")+")");if("bigint"==typeof r)return r*BigInt(e.length)+BigInt(i);var a=r*e.length+i;if(Number.isSafeInteger(a))return a;if("function"==typeof BigInt)return BigInt(r)*BigInt(e.length)+BigInt(i);throw new Error("Unable to decode the provided string, due to lack of support for BigInt numbers in the current environment")}),0)},S=/^\+?[0-9]+$/,k=function(t){return S.test(t)?parseInt(t,10):NaN},I=function(t,e,r){return Array.from({length:Math.ceil(t.length/e)},(function(n,i){return r(t.slice(i*e,(i+1)*e))}))},A=function(t){return new RegExp(t.map((function(t){return N(t)})).sort((function(t,e){return e.length-t.length})).join("|"))},T=function(t){return new RegExp("^["+t.map((function(t){return N(t)})).sort((function(t,e){return e.length-t.length})).join("")+"]+$")},N=function(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},B=new d("azowernasdfoia",5),C=function(t){try{var e=B.decode(t);if(!e.length)return null;var r=Number(e[0]);return isNaN(r)?null:r}catch(e){return console.error("Failed to decode ".concat(t),e),null}},M="";fetch("https://api.audius.co",{method:"GET"}).then((function(t){t.json().then((function(t){M=t.data[0]}))}));var P={backgroundColor:"#fff",color:"#858199",padding:"1.2em",borderRadius:"8px",boxShadow:"0 2px 5px -2px rgba(133,129,153,.25)"},U={width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"};Object(u.registerBlockType)("audius/embed-block",{title:"Audius",icon:"format-audio",attributes:{iframeUrl:{type:"string",source:"attribute",selector:"iframe",attribute:"src"},trackEmbedStyle:{type:"string",source:"attribute",selector:"iframe",attribute:"data-style"},trackId:{type:"string",source:"attribute",selector:"iframe",attribute:"data-track"},trackOwnerId:{type:"string",source:"attribute",selector:"iframe",attribute:"data-owner"}},category:"embed",edit:function(t){var e=t.attributes,r=t.setAttributes,n=Object(l.useState)([]),a=s()(n,2),c=(a[0],a[1]),u=Object(l.useState)([]),f=s()(u,2),d=(f[0],f[1],Object(l.useState)("")),p=s()(d,2),b=p[0],g=p[1],m=Object(l.useState)("url"),v=s()(m,2),y=v[0],w=(v[1],"compact"==e.trackEmbedStyle?"120":"400"),x=function(){return e.iframeUrl&&"string"==typeof e.iframeUrl&&e.iframeUrl.includes("https://audius.co/embed/track?")},j=function(){var t=o()(i.a.mark((function t(n){var a,o,c,s,l,u,h,f;return i.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((a=n.match(/\d+$/)).length>0)){t.next=17;break}return o=a[0],g(n),r({trackId:o}),c="".concat(M,"/v1/resolve?url=").concat(n,"&app_name=Wordpress"),t.next=8,fetch(c,{method:"GET"});case 8:return s=t.sent,t.next=11,s.json();case 11:l=t.sent.data,u=C(l.user.id),r({trackOwnerId:u}),h=e.trackEmbedStyle||"card",f="https://audius.co/embed/track?id=".concat(o,"&ownerId=").concat(u,"&flavor=").concat(h),r({iframeUrl:f});case 17:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),E=function(){var t=o()(i.a.mark((function t(n){var a,o,c,s;return i.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r({trackEmbedStyle:n}),a=e.trackId,o=e.trackOwnerId,b&&a&&o?(c="https://audius.co/embed/track?id=".concat(a,"&ownerId=").concat(o,"&flavor=").concat(n),r({iframeUrl:c})):x()&&(s="https://audius.co/embed/track?id=".concat(a,"&ownerId=").concat(o,"&flavor=").concat(n),r({iframeUrl:s}));case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),O=function(){var t=o()(i.a.mark((function t(e){var r,n,a;return i.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="".concat(M,"/v1/tracks/search?query=").concat(e,"&app_name=Wordpress"),t.next=3,fetch(r,{method:"GET"});case 3:return n=t.sent,t.next=6,n.json();case 6:a=t.sent.data.slice(0,10),c([].concat(a));case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();return Object(l.createElement)("div",{className:"audius-block"},Object(l.createElement)("div",{style:P},Object(l.createElement)("div",{style:U},Object(l.createElement)("svg",{width:"140",height:"52",viewBox:"0 0 93 24"},Object(l.createElement)("g",{fill:"none",fillRule:"evenodd",stroke:"none",strokeWidth:"1"},Object(l.createElement)("g",{fill:"#7e1bcc",transform:"translate(-35 -16)"},Object(l.createElement)("g",{transform:"translate(32 16)"},Object(l.createElement)("path",{d:"M88.522 14.969l1.313-1.55c.839.661 1.775 1.01 2.76 1.01.632 0 .972-.217.972-.577v-.024c0-.348-.28-.54-1.434-.805-1.812-.408-3.21-.912-3.21-2.641v-.024c0-1.561 1.252-2.69 3.295-2.69 1.447 0 2.577.385 3.501 1.117l-1.18 1.645c-.777-.54-1.628-.829-2.382-.829-.571 0-.851.24-.851.54v.025c0 .384.292.552 1.471.816 1.957.42 3.173 1.045 3.173 2.618v.024c0 1.717-1.374 2.737-3.44 2.737-1.508 0-2.942-.468-3.988-1.392zM76.879 12.53V7.812h2.395v4.671c0 1.213.62 1.79 1.568 1.79.948 0 1.568-.553 1.568-1.73v-4.73h2.395v4.658c0 2.714-1.568 3.902-3.987 3.902-2.42 0-3.94-1.212-3.94-3.842zm-6.88 3.686V7.812h2.37v8.405h-2.37zm-8.971-2.065c1.41 0 2.346-.768 2.346-2.125v-.024c0-1.345-.936-2.125-2.346-2.125h-.96v4.274h.96zm-3.319-6.34h3.283c3.039 0 4.802 1.73 4.802 4.155v.024c0 2.425-1.787 4.226-4.851 4.226h-3.234V7.812zm-12.425 4.72v-4.72h2.395v4.671c0 1.213.62 1.79 1.568 1.79.948 0 1.569-.553 1.569-1.73v-4.73h2.395v4.658c0 2.714-1.569 3.902-3.988 3.902-2.42 0-3.939-1.212-3.939-3.842zm-7.043.371l-.949-2.39-.96 2.39h1.909zm-2.067-5.15h2.273l3.623 8.464h-2.528l-.62-1.5h-3.283l-.608 1.5h-2.48l3.623-8.465zM27.66 23.01a.653.653 0 01-.573.98l-6.62-.005-6.606-.005-5.298-.003a.653.653 0 01-.572-.98l2.559-4.37a.663.663 0 01.572-.326l6.012.004a.655.655 0 00.573-.979l-.509-.873-2.756-4.721a.666.666 0 00-1.145 0l-.406.693-2.656 4.537a.663.663 0 01-.573.326l-5.11-.004a.653.653 0 01-.573-.98l2.705-4.62L13.303.378a.665.665 0 011.146 0l3.507 6.01 3.098 5.307 6.605 11.316z"}))))),x()&&Object(l.createElement)("div",{style:{display:"flex",alignItems:"center",cursor:"pointer"},onClick:function(){r({iframeUrl:null})}},Object(l.createElement)("svg",{fill:"#858199",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18"},Object(l.createElement)("path",{d:"M9 13.5c-2.49 0-4.5-2.01-4.5-4.5S6.51 4.5 9 4.5c1.24 0 2.36.52 3.17 1.33L10 8h5V3l-1.76 1.76C12.15 3.68 10.66 3 9 3 5.69 3 3.01 5.69 3.01 9S5.69 15 9 15c2.97 0 5.43-2.16 5.9-5h-1.52c-.46 2-2.24 3.5-4.38 3.5z"})),Object(l.createElement)("p",{className:"dfont",style:{margin:"0px",marginLeft:"3px",fontSize:"14px"}},"Start Over"))),"url"==y&&!x()&&Object(l.createElement)("div",null,Object(l.createElement)(h.TextControl,{type:"text",label:"Paste A Track Url",value:b,onChange:j})),"search"==y&&!x()&&Object(l.createElement)("div",null,Object(l.createElement)(h.TextControl,{type:"text",label:"Search Audius",value:e.searchQuery,onChange:O})),Object(l.createElement)("div",null,Object(l.createElement)(h.SelectControl,{style:{display:"flex"},label:"Embed Style",value:e.trackEmbedStyle,options:[{label:"Card",value:"card"},{label:"Compact",value:"compact"}],onChange:E}),e.iframeUrl&&Object(l.createElement)("div",null,Object(l.createElement)("iframe",{src:e.iframeUrl,height:w,width:"100%",allow:"encrypted-media"})))))},save:function(t){var e=t.attributes,r=e.iframeUrl,n=e.trackEmbedStyle,i=e.trackId,a=e.trackOwnerId,o="compact"==e.trackEmbedStyle?"120":"400";return Object(l.createElement)("div",null,Object(l.createElement)("iframe",{"data-style":n,"data-track":i,"data-owner":a,src:r,height:o,width:"100%",allow:"encrypted-media"}))}})}]);1 !function(t){var e={};function r(n){if(e[n])return e[n].exports;var a=e[n]={i:n,l:!1,exports:{}};return t[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)r.d(n,a,function(e){return t[e]}.bind(null,a));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=11)}([function(t,e){t.exports=window.wp.element},function(t,e){t.exports=window.regeneratorRuntime},function(t,e){function r(t,e,r,n,a,i,o){try{var c=t[i](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,a)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(a,i){var o=t.apply(e,n);function c(t){r(o,a,i,c,s,"next",t)}function s(t){r(o,a,i,c,s,"throw",t)}c(void 0)}))}}},function(t,e,r){var n=r(6),a=r(7),i=r(8),o=r(10);t.exports=function(t,e){return n(t)||a(t,e)||i(t,e)||o()}},function(t,e){t.exports=window.wp.components},function(t,e){t.exports=window.wp.blocks},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var r=[],n=!0,a=!1,i=void 0;try{for(var o,c=t[Symbol.iterator]();!(n=(o=c.next()).done)&&(r.push(o.value),!e||r.length!==e);n=!0);}catch(t){a=!0,i=t}finally{try{n||null==c.return||c.return()}finally{if(a)throw i}}return r}}},function(t,e,r){var n=r(9);t.exports=function(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(t,e,r){"use strict";r.r(e);var n=r(1),a=r.n(n),i=r(2),o=r.n(i),c=r(3),s=r.n(c),l=r(0),u=r(5),h=r(4);function f(t){return function(t){if(Array.isArray(t))return p(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||d(t)||function(){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 d(t,e){if(t){if("string"==typeof t)return p(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(t,e):void 0}}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var b=function(){function t(t,e,r,n){if(void 0===t&&(t=""),void 0===e&&(e=0),void 0===r&&(r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"),void 0===n&&(n="cfhistuCFHISTU"),this.minLength=e,"number"!=typeof e)throw new TypeError("Hashids: Provided 'minLength' has to be a number (is "+typeof e+")");if("string"!=typeof t)throw new TypeError("Hashids: Provided 'salt' has to be a string (is "+typeof t+")");if("string"!=typeof r)throw new TypeError("Hashids: Provided alphabet has to be a string (is "+typeof r+")");var a=Array.from(t),i=Array.from(r),o=Array.from(n);this.salt=a;var c=y(i);if(c.length<m)throw new Error("Hashids: alphabet must contain at least "+m+" unique characters, provided: "+c.join(""));this.alphabet=w(c,o);var s,l,u,h=x(o,c);(this.seps=S(h,a),0===this.seps.length||this.alphabet.length/this.seps.length>g)&&((s=Math.ceil(this.alphabet.length/g))>this.seps.length&&(l=s-this.seps.length,(u=this.seps).push.apply(u,f(this.alphabet.slice(0,l))),this.alphabet=this.alphabet.slice(l)));this.alphabet=S(this.alphabet,a);var d=Math.ceil(this.alphabet.length/v);this.alphabet.length<3?(this.guards=this.seps.slice(0,d),this.seps=this.seps.slice(d)):(this.guards=this.alphabet.slice(0,d),this.alphabet=this.alphabet.slice(d)),this.guardsRegExp=C(this.guards),this.sepsRegExp=C(this.seps),this.allowedCharsRegExp=N([].concat(f(this.alphabet),f(this.guards),f(this.seps)))}var e=t.prototype;return e.encode=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];var a="";return(r=Array.isArray(t)?t:[].concat(f(null!=t?[t]:[]),f(r))).length?(r.every(j)||(r=r.map((function(t){return"bigint"==typeof t||"number"==typeof t?t:A(String(t))}))),r.every(E)?this._encode(r).join(""):a):a},e.decode=function(t){return t&&"string"==typeof t&&0!==t.length?this._decode(t):[]},e.encodeHex=function(t){switch(typeof t){case"bigint":t=t.toString(16);break;case"string":if(!/^[0-9a-fA-F]+$/.test(t))return"";break;default:throw new Error("Hashids: The provided value is neither a string, nor a BigInt (got: "+typeof t+")")}var e=T(t,12,(function(t){return parseInt("1"+t,16)}));return this.encode(e)},e.decodeHex=function(t){return this.decode(t).map((function(t){return t.toString(16).slice(1)})).join("")},e._encode=function(t){var e=this,r=this.alphabet,n=t.reduce((function(t,e,r){return t+("bigint"==typeof e?Number(e%BigInt(r+100)):e%(r+100))}),0),a=[r[n%r.length]],i=a.slice(),o=this.seps,c=this.guards;if(t.forEach((function(n,c){var s,l=i.concat(e.salt,r);r=S(r,l);var u=O(n,r);if((s=a).push.apply(s,f(u)),c+1<t.length){var h=u[0].codePointAt(0)+c,d="bigint"==typeof n?Number(n%BigInt(h)):n%h;a.push(o[d%o.length])}})),a.length<this.minLength){var s=(n+a[0].codePointAt(0))%c.length;if(a.unshift(c[s]),a.length<this.minLength){var l=(n+a[2].codePointAt(0))%c.length;a.push(c[l])}}for(var u=Math.floor(r.length/2);a.length<this.minLength;){var h,d;r=S(r,r),(h=a).unshift.apply(h,f(r.slice(u))),(d=a).push.apply(d,f(r.slice(0,u)));var p=a.length-this.minLength;if(p>0){var b=p/2;a=a.slice(b,b+this.minLength)}}return a},e.isValidId=function(t){return this.allowedCharsRegExp.test(t)},e._decode=function(t){if(!this.isValidId(t))throw new Error("The provided ID ("+t+") is invalid, as it contains characters that do not exist in the alphabet ("+this.guards.join("")+this.seps.join("")+this.alphabet.join("")+")");var e=t.split(this.guardsRegExp),r=e[3===e.length||2===e.length?1:0];if(0===r.length)return[];for(var n,a=r[Symbol.iterator]().next().value,i=r.slice(a.length).split(this.sepsRegExp),o=this.alphabet,c=[],s=function(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=d(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=t[Symbol.iterator]()).next.bind(r)}(i);!(n=s()).done;){var l=n.value,u=S(o,[a].concat(f(this.salt),f(o)).slice(0,o.length));c.push(k(Array.from(l),u)),o=u}return this._encode(c).join("")!==t?[]:c},t}(),m=16,g=3.5,v=12,y=function(t){return Array.from(new Set(t))},w=function(t,e){return t.filter((function(t){return!e.includes(t)}))},x=function(t,e){return t.filter((function(t){return e.includes(t)}))},j=function(t){return"bigint"==typeof t||!Number.isNaN(Number(t))&&Math.floor(Number(t))===t},E=function(t){return"bigint"==typeof t||t>=0&&Number.isSafeInteger(t)};function S(t,e){if(0===e.length)return t;for(var r,n=t.slice(),a=n.length-1,i=0,o=0;a>0;a--,i++){o+=r=e[i%=e.length].codePointAt(0);var c=(r+i+o)%a,s=n[a],l=n[c];n[c]=s,n[a]=l}return n}var O=function(t,e){var r=[];if("bigint"==typeof t){var n=BigInt(e.length);do{r.unshift(e[Number(t%n)]),t/=n}while(t>BigInt(0))}else do{r.unshift(e[t%e.length]),t=Math.floor(t/e.length)}while(t>0);return r},k=function(t,e){return t.reduce((function(r,n){var a=e.indexOf(n);if(-1===a)throw new Error("The provided ID ("+t.join("")+") is invalid, as it contains characters that do not exist in the alphabet ("+e.join("")+")");if("bigint"==typeof r)return r*BigInt(e.length)+BigInt(a);var i=r*e.length+a;if(Number.isSafeInteger(i))return i;if("function"==typeof BigInt)return BigInt(r)*BigInt(e.length)+BigInt(a);throw new Error("Unable to decode the provided string, due to lack of support for BigInt numbers in the current environment")}),0)},I=/^\+?[0-9]+$/,A=function(t){return I.test(t)?parseInt(t,10):NaN},T=function(t,e,r){return Array.from({length:Math.ceil(t.length/e)},(function(n,a){return r(t.slice(a*e,(a+1)*e))}))},C=function(t){return new RegExp(t.map((function(t){return B(t)})).sort((function(t,e){return e.length-t.length})).join("|"))},N=function(t){return new RegExp("^["+t.map((function(t){return B(t)})).sort((function(t,e){return e.length-t.length})).join("")+"]+$")},B=function(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},M=new b("azowernasdfoia",5),U=function(t){try{var e=M.decode(t);if(!e.length)return null;var r=Number(e[0]);return isNaN(r)?null:r}catch(e){return console.error("Failed to decode ".concat(t),e),null}},P="";fetch("https://api.audius.co",{method:"GET"}).then((function(t){t.json().then((function(t){P=t.data[0]}))}));var z={backgroundColor:"#fff",color:"#858199",padding:"1.2em",borderRadius:"8px",boxShadow:"0 2px 5px -2px rgba(133,129,153,.25)"},_={width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"};Object(u.registerBlockType)("audius/embed-block",{title:"Audius",icon:"format-audio",attributes:{iframeUrl:{type:"string",source:"attribute",selector:"iframe",attribute:"src"},trackEmbedStyle:{type:"string",source:"attribute",selector:"iframe",attribute:"data-style"},trackId:{type:"string",source:"attribute",selector:"iframe",attribute:"data-track"},trackOwnerId:{type:"string",source:"attribute",selector:"iframe",attribute:"data-owner"}},category:"embed",edit:function(t){var e=t.attributes,r=t.setAttributes,n=Object(l.useState)([]),i=s()(n,2),c=(i[0],i[1]),u=Object(l.useState)([]),f=s()(u,2),d=(f[0],f[1],Object(l.useState)("")),p=s()(d,2),b=p[0],m=p[1],g=Object(l.useState)("url"),v=s()(g,2),y=v[0],w=(v[1],"400");"compact"==e.trackEmbedStyle?w="120":"card"==e.trackEmbedStyle?w="400":"tiny"==e.trackEmbedStyle&&(w="20");var x=function(){return e.iframeUrl&&"string"==typeof e.iframeUrl&&e.iframeUrl.includes("https://audius.co/embed/track?")},j=function(){var t=o()(a.a.mark((function t(n){var i,o,c,s,l,u,h,f;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((i=n.match(/\d+$/)).length>0)){t.next=17;break}return o=i[0],m(n),r({trackId:o}),c="".concat(P,"/v1/resolve?url=").concat(n,"&app_name=Wordpress"),t.next=8,fetch(c,{method:"GET"});case 8:return s=t.sent,t.next=11,s.json();case 11:l=t.sent.data,u=U(l.user.id),r({trackOwnerId:u}),h=e.trackEmbedStyle||"card",f="https://audius.co/embed/track?id=".concat(o,"&ownerId=").concat(u,"&flavor=").concat(h),r({iframeUrl:f});case 17:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),E=function(){var t=o()(a.a.mark((function t(n){var i,o,c,s;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r({trackEmbedStyle:n}),i=e.trackId,o=e.trackOwnerId,b&&i&&o?(c="https://audius.co/embed/track?id=".concat(i,"&ownerId=").concat(o,"&flavor=").concat(n),r({iframeUrl:c})):x()&&(s="https://audius.co/embed/track?id=".concat(i,"&ownerId=").concat(o,"&flavor=").concat(n),r({iframeUrl:s}));case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),S=function(){var t=o()(a.a.mark((function t(e){var r,n,i;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="".concat(P,"/v1/tracks/search?query=").concat(e,"&app_name=Wordpress"),t.next=3,fetch(r,{method:"GET"});case 3:return n=t.sent,t.next=6,n.json();case 6:i=t.sent.data.slice(0,10),c([].concat(i));case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();return Object(l.createElement)("div",{className:"audius-block"},Object(l.createElement)("div",{style:z},Object(l.createElement)("div",{style:_},Object(l.createElement)("svg",{width:"140",height:"52",viewBox:"0 0 93 24"},Object(l.createElement)("g",{fill:"none",fillRule:"evenodd",stroke:"none",strokeWidth:"1"},Object(l.createElement)("g",{fill:"#7e1bcc",transform:"translate(-35 -16)"},Object(l.createElement)("g",{transform:"translate(32 16)"},Object(l.createElement)("path",{d:"M88.522 14.969l1.313-1.55c.839.661 1.775 1.01 2.76 1.01.632 0 .972-.217.972-.577v-.024c0-.348-.28-.54-1.434-.805-1.812-.408-3.21-.912-3.21-2.641v-.024c0-1.561 1.252-2.69 3.295-2.69 1.447 0 2.577.385 3.501 1.117l-1.18 1.645c-.777-.54-1.628-.829-2.382-.829-.571 0-.851.24-.851.54v.025c0 .384.292.552 1.471.816 1.957.42 3.173 1.045 3.173 2.618v.024c0 1.717-1.374 2.737-3.44 2.737-1.508 0-2.942-.468-3.988-1.392zM76.879 12.53V7.812h2.395v4.671c0 1.213.62 1.79 1.568 1.79.948 0 1.568-.553 1.568-1.73v-4.73h2.395v4.658c0 2.714-1.568 3.902-3.987 3.902-2.42 0-3.94-1.212-3.94-3.842zm-6.88 3.686V7.812h2.37v8.405h-2.37zm-8.971-2.065c1.41 0 2.346-.768 2.346-2.125v-.024c0-1.345-.936-2.125-2.346-2.125h-.96v4.274h.96zm-3.319-6.34h3.283c3.039 0 4.802 1.73 4.802 4.155v.024c0 2.425-1.787 4.226-4.851 4.226h-3.234V7.812zm-12.425 4.72v-4.72h2.395v4.671c0 1.213.62 1.79 1.568 1.79.948 0 1.569-.553 1.569-1.73v-4.73h2.395v4.658c0 2.714-1.569 3.902-3.988 3.902-2.42 0-3.939-1.212-3.939-3.842zm-7.043.371l-.949-2.39-.96 2.39h1.909zm-2.067-5.15h2.273l3.623 8.464h-2.528l-.62-1.5h-3.283l-.608 1.5h-2.48l3.623-8.465zM27.66 23.01a.653.653 0 01-.573.98l-6.62-.005-6.606-.005-5.298-.003a.653.653 0 01-.572-.98l2.559-4.37a.663.663 0 01.572-.326l6.012.004a.655.655 0 00.573-.979l-.509-.873-2.756-4.721a.666.666 0 00-1.145 0l-.406.693-2.656 4.537a.663.663 0 01-.573.326l-5.11-.004a.653.653 0 01-.573-.98l2.705-4.62L13.303.378a.665.665 0 011.146 0l3.507 6.01 3.098 5.307 6.605 11.316z"}))))),x()&&Object(l.createElement)("div",{style:{display:"flex",alignItems:"center",cursor:"pointer"},onClick:function(){r({iframeUrl:null})}},Object(l.createElement)("svg",{fill:"#858199",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18"},Object(l.createElement)("path",{d:"M9 13.5c-2.49 0-4.5-2.01-4.5-4.5S6.51 4.5 9 4.5c1.24 0 2.36.52 3.17 1.33L10 8h5V3l-1.76 1.76C12.15 3.68 10.66 3 9 3 5.69 3 3.01 5.69 3.01 9S5.69 15 9 15c2.97 0 5.43-2.16 5.9-5h-1.52c-.46 2-2.24 3.5-4.38 3.5z"})),Object(l.createElement)("p",{className:"dfont",style:{margin:"0px",marginLeft:"3px",fontSize:"14px"}},"Start Over"))),"url"==y&&!x()&&Object(l.createElement)("div",null,Object(l.createElement)(h.TextControl,{type:"text",label:"Paste A Track Url",value:b,onChange:j})),"search"==y&&!x()&&Object(l.createElement)("div",null,Object(l.createElement)(h.TextControl,{type:"text",label:"Search Audius",value:e.searchQuery,onChange:S})),Object(l.createElement)("div",null,Object(l.createElement)(h.SelectControl,{style:{display:"flex"},label:"Embed Style",value:e.trackEmbedStyle,options:[{label:"Card",value:"card"},{label:"Compact",value:"compact"},{label:"Tiny",value:"tiny"}],onChange:E}),e.iframeUrl&&Object(l.createElement)("div",null,Object(l.createElement)("iframe",{src:e.iframeUrl,height:w,width:"100%",allow:"encrypted-media"})))))},save:function(t){var e=t.attributes,r=e.iframeUrl,n=e.trackId,a=e.trackOwnerId,i="120";return"compact"==e.trackEmbedStyle?i="120":"card"==e.trackEmbedStyle?i="400":"tiny"==e.trackEmbedStyle&&(i="20"),Object(l.createElement)("div",null,Object(l.createElement)("iframe",{"data-style":e.trackEmbedStyle,"data-track":n,"data-owner":a,src:r,height:i,width:"100%",allow:"encrypted-media"}))}})}]); -
audius-block/trunk/package.json
r2465731 r2465987 1 1 { 2 2 "name": "audius-wp", 3 "version": "1. 0.0",3 "version": "1.1.0", 4 4 "description": "Audius.co Wordpress plugin", 5 5 "main": "index.js", -
audius-block/trunk/src/index.js
r2465731 r2465987 1 1 import { registerBlockType } from '@wordpress/blocks' 2 2 import { useState } from '@wordpress/element' 3 import { Button, ButtonGroup, SelectControl, Text, TextControl } from '@wordpress/components'3 import { SelectControl, TextControl } from '@wordpress/components' 4 4 import { decodeHashId } from './utils' 5 5 … … 50 50 const [ trackUrl, setTrackUrl ] = useState('') 51 51 const [ trackSource, setTrackSource ] = useState('url') 52 const height = attributes.trackEmbedStyle == 'compact' ? '120' : '400' 52 let height = '400' 53 if(attributes.trackEmbedStyle == 'compact'){ 54 height = '120' 55 } else if(attributes.trackEmbedStyle == 'card'){ 56 height = '400' 57 } else if(attributes.trackEmbedStyle == 'tiny'){ 58 height = '20' 59 } 53 60 54 61 const hasValidIframeUrl = () => { … … 162 169 options={ [ 163 170 { label: 'Card', value: 'card' }, 164 { label: 'Compact', value: 'compact' } 171 { label: 'Compact', value: 'compact' }, 172 { label: 'Tiny', value: 'tiny' } 165 173 ] } 166 174 onChange={ handleEmbedStyleChanged } … … 188 196 const SaveBlock = ({ attributes }) => { 189 197 const url = attributes.iframeUrl 190 const trackEmbedStyle = attributes.trackEmbedStyle191 198 const trackId = attributes.trackId 192 199 const trackOwnerId = attributes.trackOwnerId 193 const height = attributes.trackEmbedStyle == 'compact' ? '120' : '400' 200 let height = '120' 201 if(attributes.trackEmbedStyle == 'compact'){ 202 height = '120' 203 } else if(attributes.trackEmbedStyle == 'card'){ 204 height = '400' 205 } else if(attributes.trackEmbedStyle == 'tiny'){ 206 height = '20' 207 } 194 208 return( 195 209 <div> 196 <iframe data-style={ trackEmbedStyle} data-track={trackId} data-owner={trackOwnerId} src={ url } height={ height } width='100%' allow="encrypted-media"/>210 <iframe data-style={attributes.trackEmbedStyle} data-track={trackId} data-owner={trackOwnerId} src={ url } height={ height } width='100%' allow="encrypted-media"/> 197 211 </div> 198 212 )
Note: See TracChangeset
for help on using the changeset viewer.