@flourish/sdk 3.17.1 → 3.18.0
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/README.md~ +473 -0
- package/RELEASE_NOTES.md +9 -0
- package/RELEASE_NOTES.md~ +372 -0
- package/lib/cmd/publish.js +4 -2
- package/lib/log.js +7 -7
- package/lib/sdk.js +34 -22
- package/lib/sdk.js~ +540 -0
- package/lib/validate_config.js +2 -1
- package/lib/validate_config.js~ +437 -0
- package/package-lock.json~ +2669 -0
- package/package.json +4 -4
- package/package.json~ +53 -0
- package/server/data.js +40 -5
- package/server/index.js~ +540 -0
- package/site/embedded.js +1 -1
- package/site/images/flourish_in_canva.png +0 -0
- package/site/script.js +2 -2
- package/site/sdk.css +1 -1
- package/test/lib/validate_config.js +11 -2
- package/test/lib/validate_config.js~ +1006 -0
package/site/embedded.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){"use strict";var e,
|
|
1
|
+
!function(){"use strict";var e,t,n=!1;function i(e){if(n&&window.top!==window.self){var t=window;"srcdoc"===t.location.pathname&&(t=t.parent);var i,o=(i={},window._Flourish_template_id&&(i.template_id=window._Flourish_template_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_template_id&&(i.template_id=window.Flourish.app.loaded_template_id),window._Flourish_visualisation_id&&(i.visualisation_id=window._Flourish_visualisation_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_visualisation&&(i.visualisation_id=window.Flourish.app.loaded_visualisation.id),window.Flourish&&window.Flourish.app&&window.Flourish.app.story&&(i.story_id=window.Flourish.app.story.id,i.slide_count=window.Flourish.app.story.slides.length),window.Flourish&&window.Flourish.app&&window.Flourish.app.current_slide&&(i.slide_index=window.Flourish.app.current_slide.index+1),i),r={sender:"Flourish",method:"customerAnalytics"};for(var a in o)o.hasOwnProperty(a)&&(r[a]=o[a]);for(var a in e)e.hasOwnProperty(a)&&(r[a]=e[a]);t.parent.postMessage(JSON.stringify(r),"*")}}function o(e){if("function"!=typeof e)throw new Error("Analytics callback is not a function");window.Flourish._analytics_listeners.push(e)}function r(){n=!0;[{event_name:"click",action_name:"click",use_capture:!0},{event_name:"keydown",action_name:"key_down",use_capture:!0},{event_name:"mouseenter",action_name:"mouse_enter",use_capture:!1},{event_name:"mouseleave",action_name:"mouse_leave",use_capture:!1}].forEach((function(e){document.body.addEventListener(e.event_name,(function(){i({action:e.action_name})}),e.use_capture)}))}function a(){if(null==e){var t=function(){var e=window.location;"about:srcdoc"==e.href&&(e=window.parent.location);var t={};return function(e,n,i){for(;i=n.exec(e);)t[decodeURIComponent(i[1])]=decodeURIComponent(i[2])}(e.search.substring(1).replace(/\+/g,"%20"),/([^&=]+)=?([^&]*)/g),t}();e="referrer"in t?/^https:\/\/medium.com\//.test(t.referrer):!("auto"in t)}return e}function s(e){var t=e||window.innerWidth;return t>999?650:t>599?575:400}function l(e,n){if(window.top!==window.self){var i=window;if("srcdoc"==i.location.pathname&&(i=i.parent),t)return e=parseInt(e,10),void i.parent.postMessage({sentinel:"amp",type:"embed-size",height:e},"*");var o={sender:"Flourish",context:"iframe.resize",method:"resize",height:e,src:i.location.toString()};if(n)for(var r in n)o[r]=n[r];i.parent.postMessage(JSON.stringify(o),"*")}}function d(){return(-1!==navigator.userAgent.indexOf("Safari")||-1!==navigator.userAgent.indexOf("iPhone"))&&-1==navigator.userAgent.indexOf("Chrome")}function u(e){return"string"==typeof e||e instanceof String}function c(e){return"warn"!==e.method?(console.warn("BUG: validateWarnMessage called for method"+e.method),!1):!(null!=e.message&&!u(e.message))&&!(null!=e.explanation&&!u(e.explanation))}function h(e){return"resize"!==e.method?(console.warn("BUG: validateResizeMessage called for method"+e.method),!1):!!u(e.src)&&(!!u(e.context)&&!!("number"==typeof(t=e.height)?!isNaN(t)&&t>=0:u(t)&&/\d/.test(t)&&/^[0-9]*(\.[0-9]*)?(cm|mm|Q|in|pc|pt|px|em|ex|ch|rem|lh|vw|vh|vmin|vmax|%)?$/i.test(t)));var t}function f(e){throw new Error("Validation for setSetting is not implemented yet; see issue #4328")}function w(e){return"customerAnalytics"===e.method||(console.warn("BUG: validateCustomerAnalyticsMessage called for method"+e.method),!1)}function p(e){return"request-upload"!==e.method?(console.warn("BUG: validateResizeMessage called for method"+e.method),!1):!!u(e.name)&&!(null!=e.accept&&!u(e.accept))}function m(e,t){var n=function(e){for(var t={warn:c,resize:h,setSetting:f,customerAnalytics:w,"request-upload":p},n={},i=0;i<e.length;i++){var o=e[i];if(!t[o])throw new Error("No validator found for method "+o);n[o]=t[o]}return n}(t);window.addEventListener("message",(function(t){if(null!=t.source&&(t.origin===document.location.origin||t.origin.match(/\/\/localhost:\d+$|\/\/flourish-api\.com$|\.flourish\.(?:local(:\d+)?|net|rocks|studio)$|\.uri\.sh$/))){var i;try{i=JSON.parse(t.data)}catch(e){return void console.warn("Unexpected non-JSON message: "+JSON.stringify(t.data))}if("Flourish"===i.sender)if(i.method)if(Object.prototype.hasOwnProperty.call(n,i.method))if(n[i.method](i)){for(var o=document.querySelectorAll("iframe"),r=0;r<o.length;r++)if(o[r].contentWindow==t.source||o[r].contentWindow==t.source.parent)return void e(i,o[r]);console.warn("could not find frame",i)}else console.warn("Validation failed for the message",i);else console.warn("No validator implemented for message",i);else console.warn("The 'method' property was missing from message",i)}})),d()&&(window.addEventListener("resize",g),g())}function g(){for(var e=document.querySelectorAll(".flourish-embed"),t=0;t<e.length;t++){var n=e[t];if(!n.getAttribute("data-width")){var i=n.querySelector("iframe");if(i){var o=window.getComputedStyle(n),r=n.offsetWidth-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight);i.style.width=r+"px"}}}}function v(e,t,n,i,o){var r=document.createElement("iframe");if(r.setAttribute("scrolling","no"),r.setAttribute("frameborder","0"),r.setAttribute("title","Interactive or visual content"),r.setAttribute("sandbox","allow-same-origin allow-forms allow-scripts allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation"),t.appendChild(r),r.offsetParent||"fixed"===getComputedStyle(r).position)_(e,t,r,n,i,o);else{var a={embed_url:e,container:t,iframe:r,width:n,height:i,play_on_load:o};if(window._flourish_poll_items?window._flourish_poll_items.push(a):window._flourish_poll_items=[a],window._flourish_poll_items.length>1)return r;var s=setInterval((function(){window._flourish_poll_items=window._flourish_poll_items.filter((function(e){return!e.iframe.offsetParent||(_(e.embed_url,e.container,e.iframe,e.width,e.height,e.play_on_load),!1)})),window._flourish_poll_items.length||clearInterval(s)}),500)}return r}function _(e,t,n,i,o,r){var a;return i&&"number"==typeof i?(a=i,i+="px"):i&&i.match(/^[ \t\r\n\f]*([+-]?\d+|\d*\.\d+(?:[eE][+-]?\d+)?)(?:\\?[Pp]|\\0{0,4}[57]0(?:\r\n|[ \t\r\n\f])?)(?:\\?[Xx]|\\0{0,4}[57]8(?:\r\n|[ \t\r\n\f])?)[ \t\r\n\f]*$/)&&(a=parseFloat(i)),o&&"number"==typeof o&&(o+="px"),i?n.style.width=i:d()?n.style.width=t.offsetWidth+"px":n.style.width="100%",!!o||(e.match(/\?/)?e+="&auto=1":e+="?auto=1",o=s(a||n.offsetWidth)+"px"),o&&("%"===o.charAt(o.length-1)&&(o=parseFloat(o)/100*t.parentNode.offsetHeight+"px"),n.style.height=o),n.setAttribute("src",e+(r?"#play-on-load":"")),n}function y(e){return!Array.isArray(e)&&"object"==typeof e&&null!=e}function F(e,t){for(var n in t)y(e[n])&&y(t[n])?F(e[n],t[n]):e[n]=t[n];return e}!function(){var e,n=window.top===window.self,u=n?null:(t="#amp=1"==window.location.hash,{createEmbedIframe:v,isFixedHeight:a,getHeightForBreakpoint:s,startEventListeners:m,notifyParentWindow:l,isSafari:d,initCustomerAnalytics:r,addAnalyticsListener:o,sendCustomerAnalyticsMessage:i}),c=!0;function h(){var t;Flourish.fixed_height||(null!=e?t=e:c&&(t=u.getHeightForBreakpoint()),t!==window.innerHeight&&u.notifyParentWindow(t))}function f(){h(),window.addEventListener("resize",h)}Flourish.warn=function(e){if("string"==typeof e&&(e={message:e}),n||"editor"!==Flourish.environment)console.warn(e.message);else{var t={sender:"Flourish",method:"warn",message:e.message,explanation:e.explanation};window.parent.postMessage(JSON.stringify(t),"*")}},Flourish.uploadImage=function(e){if(n||"story_editor"!==Flourish.environment)throw"Invalid upload request";var t={sender:"Flourish",method:"request-upload",name:e.name,accept:e.accept};window.parent.postMessage(JSON.stringify(t),"*")},Flourish.setSetting=function(e,t){if("editor"===Flourish.environment||"sdk"===Flourish.environment){var n={sender:"Flourish",method:"setSetting",name:e,value:t};window.parent.postMessage(JSON.stringify(n),"*")}else if("story_editor"===Flourish.environment){var i={};i[e]=t,F(window.template.state,function(e){var t={};for(var n in e){for(var i=t,o=n.indexOf("."),r=0;o>=0;o=n.indexOf(".",r=o+1)){var a=n.substring(r,o);a in i||(i[a]={}),i=i[a]}i[n.substring(r)]=e[n]}return t}(i))}},Flourish.setHeight=function(t){Flourish.fixed_height||(e=t,c=null==t,h())},Flourish.checkHeight=function(){if(!n){var e=Flourish.__container_height;null!=e?(Flourish.fixed_height=!0,u.notifyParentWindow(e)):u.isFixedHeight()?Flourish.fixed_height=!0:(Flourish.fixed_height=!1,h())}},Flourish.fixed_height=n||u.isFixedHeight(),Flourish.enableCustomerAnalytics=function(){u&&u.initCustomerAnalytics()},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",f):f()}()}();
|
|
2
2
|
//# sourceMappingURL=embedded.js.map
|
|
Binary file
|