tocco-widget-utils 0.1.5 → 0.1.8

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/changelog.md CHANGED
@@ -1,3 +1,12 @@
1
+ 0.1.8
2
+ - set embedType for widgets
3
+
4
+ 0.1.7
5
+ - split backend url in asset and backend url
6
+
7
+ 0.1.6
8
+
9
+
1
10
  0.1.5
2
11
  - fix cache clearance to keep notifications session
3
12
  - Tiny millisecond values (1 - 3) are now displayed correctly.
package/dist/bootstrap.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["tocco-widget-utils"]=e():t["tocco-widget-utils"]=e()}(self,(function(){return(()=>{var t={926:t=>{function e(t,e,r,n,o,c,i){try{var a=t[c](i),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,o)}t.exports=function(t){return function(){var r=this,n=arguments;return new Promise((function(o,c){var i=t.apply(r,n);function a(t){e(i,o,c,a,u,"next",t)}function u(t){e(i,o,c,a,u,"throw",t)}a(void 0)}))}}},713:t=>{t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}},8:t=>{function e(r){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=e=function(t){return typeof t}:t.exports=e=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(r)}t.exports=e},757:(t,e,r)=>{t.exports=r(666)},666:t=>{var e=function(t){"use strict";var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",c=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function a(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{a({},"")}catch(t){a=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof p?e:p,c=Object.create(o.prototype),i=new x(n||[]);return c._invoke=function(t,e,r){var n="suspendedStart";return function(o,c){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw c;return E()}for(r.method=o,r.arg=c;;){var i=r.delegate;if(i){var a=b(i,r);if(a){if(a===f)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),c}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var f={};function p(){}function l(){}function d(){}var h={};h[o]=function(){return this};var y=Object.getPrototypeOf,v=y&&y(y(P([])));v&&v!==e&&r.call(v,o)&&(h=v);var g=d.prototype=p.prototype=Object.create(h);function m(t){["next","throw","return"].forEach((function(e){a(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,c){function i(){return new e((function(n,i){!function n(o,c,i,a){var u=s(t[o],t,c);if("throw"!==u.type){var f=u.arg,p=f.value;return p&&"object"==typeof p&&r.call(p,"__await")?e.resolve(p.__await).then((function(t){n("next",t,i,a)}),(function(t){n("throw",t,i,a)})):e.resolve(p).then((function(t){f.value=t,i(f)}),(function(t){return n("throw",t,i,a)}))}a(u.arg)}(o,c,n,i)}))}return n=n?n.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function P(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,c=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return c.next=c}}return{next:E}}function E(){return{value:void 0,done:!0}}return l.prototype=g.constructor=d,d.constructor=l,l.displayName=a(d,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,a(t,i,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(w.prototype),w.prototype[c]=function(){return this},t.AsyncIterator=w,t.async=function(e,r,n,o,c){void 0===c&&(c=Promise);var i=new w(u(e,r,n,o),c);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},m(g),a(g,i,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=P,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var c=this.tryEntries[o],i=c.completion;if("root"===c.tryLoc)return n("end");if(c.tryLoc<=this.prev){var a=r.call(c,"catchLoc"),u=r.call(c,"finallyLoc");if(a&&u){if(this.prev<c.catchLoc)return n(c.catchLoc,!0);if(this.prev<c.finallyLoc)return n(c.finallyLoc)}else if(a){if(this.prev<c.catchLoc)return n(c.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<c.finallyLoc)return n(c.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var c=o;break}}c&&("break"===t||"continue"===t)&&c.tryLoc<=e&&e<=c.finallyLoc&&(c=null);var i=c?c.completion:{};return i.type=t,i.arg=e,c?(this.method="next",this.next=c.finallyLoc,f):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}},255:t=>{"use strict";t.exports=JSON.parse('{"name":"tocco-widget-utils","version":"0.1.5","description":"","scripts":{"compile:prod":"cd ../../ && npm run compile:prod -- --package=widget-utils","prepublish":"npm run compile:prod"},"dependencies":{},"devDependencies":{"tocco-util":"*"}}')}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var c=e[n]={exports:{}};return t[n](c,c.exports,r),c.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n);var t=r(757),e=r.n(t),o=r(926),c=r.n(o),i=r(713),a=r.n(i);const u=function(){var t;window.console&&(t=console).log.apply(t,arguments)},s=function(){if(window.console){var t=console.error||console.log;t.apply(void 0,arguments)}};function f(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function p(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?f(Object(r),!0).forEach((function(e){a()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var l=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new Headers;r.set("Content-Type","application/json");var n=p({headers:r,method:"GET",credentials:"include"},e);return fetch(t,n)},d=function(t){var e=t.ok,r=t.status;return t.json().then((function(t){return{ok:e,status:r,body:t}}))},h="error",y=function(){var t=c()(e().mark((function t(r,n,o){var c,i;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return c="ERROR MESSAGE: ".concat(o.message," \nSTACK: ").concat(o.stack?o.stack.substring(0,1e3):"-"),i="".concat(n,"\n").concat(c),s(i),t.next=5,g(h,r,i);case 5:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),v=function(){var t=c()(e().mark((function t(r,n){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s(n),t.next=3,g(h,r,n);case 3:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),g=function(){var t=c()(e().mark((function t(r,n,o){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,l("".concat(n,"/nice2/log?level=").concat(r,"&message=").concat(encodeURI(o)),{method:"POST"});case 3:t.next=7;break;case 5:t.prev=5,t.t0=t.catch(0);case 7:case"end":return t.stop()}}),t,null,[[0,5]])})));return function(e,r,n){return t.apply(this,arguments)}}(),m=r(8),w=r.n(m);function b(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function O(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?b(Object(r),!0).forEach((function(e){a()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var j=function(t){return t.getAttribute("data-id")},x=function(t){return new Promise((function(e,r){var n=document.createElement("script");n.src=t,n.async=!0,n.type="text/javascript",n.onload=function(){e()},n.onerror=function(){r(new Error("Could not load script."))},n.crossorogin=!0;var o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(n,o)}))},P=function(){var t=window.toccoTheme;if(t&&"object"===w()(t))return t},E=function(t){return t&&Object.keys(t).length>0&&"function"==typeof t[Object.keys(t)[0]]},k=function(t){var e=window.toccoEventHandlers;if(E(e))return e;if(e){var r=j(t);if(r){var n=e[r];if(E(n))return n}}return{}},L=function(t,e){var r=j(t);r&&(window.toccoMethods=O(O({},window.toccoMethods),{},a()({},r,e)))};function S(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function _(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?S(Object(r),!0).forEach((function(e){a()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var D=function(t){return t.getAttribute("data-tocco-widget-key")},T=function(t,e,r){var n=e.ok,o=e.status,c=e.body;return n?e:(403===o&&"INVALID_DOMAIN"===(null==c?void 0:c.errorCode)&&v(t,c.message),void(404===o&&v(t,"Widget config '".concat(r,"' not found."))))},N=function(){var t=c()(e().mark((function t(r,n){var o,c,i,a,u,s,f,p,h,v,g;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=D(n),t.next=3,l("".concat(r,"/nice2/rest/widget/configs/").concat(o)).then(d).then((function(t){return T(r,t,o)})).then((function(t){return null==t?void 0:t.body})).catch((function(t){y(r,"Could not fetch widget config '".concat(o,"'."),t)}));case 3:if(!(c=t.sent)){t.next=20;break}return i=c.appName,a=c.packageName,u=c.locale,s=c.config,t.prev=6,t.next=9,x("".concat(r,"/js/tocco-").concat(a,"/dist/index.js"));case 9:t.next=15;break;case 11:return t.prev=11,t.t0=t.catch(6),y(r,"Could not fetch package 'tocco-".concat(a,"'."),t.t0),t.abrupt("return");case 15:f=P(),p=_(_(_({backendUrl:r},f?{customTheme:f}:{}),{},{locale:u},s),{},{themeType:"WIDGET"}),h=k(n),v="".concat(r,"/js/tocco-").concat(a,"/dist/");try{g=window.reactRegistry.render(i,n,"",p,h,v),L(n,g)}catch(t){y(r,"Could not render app '".concat(i,"'."),t)}case 20:case"end":return t.stop()}}),t,null,[[6,11]])})));return function(e,r){return t.apply(this,arguments)}}(),A=function(){if(window.toccoBootstrap)return u("tocco-widget-utils - bootstrap script is already initialized"),!1;var t=r(255).version;return window.toccoBootstrap={version:t},u("tocco-widget-utils - v".concat(t," - bootstrap")),!0};const G=function(){var t=c()(e().mark((function t(r){var n,o,c;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(A()){t.next=3;break}return t.abrupt("return");case 3:return n=r.backendUrl,o=document.querySelectorAll("[".concat("data-tocco-widget-key","]")),c=Array.prototype.slice.call(o),t.next=8,Promise.all(c.map((function(t){return N(n,t)})));case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();var C,I;C=function(t){var e=t.currentScript.getAttribute("src"),r=new URL(e);return r.protocol+"//"+r.host}(document),I={backendUrl:C},document.addEventListener("DOMContentLoaded",c()(e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,x("".concat(C,"/nice2/javascript/nice2-react.release.js"));case 2:return t.next=4,G(I);case 4:case"end":return t.stop()}}),t)}))))})(),n})()}));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["tocco-widget-utils"]=e():t["tocco-widget-utils"]=e()}(self,(function(){return(()=>{var t={926:t=>{function e(t,e,r,n,o,c,i){try{var a=t[c](i),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,o)}t.exports=function(t){return function(){var r=this,n=arguments;return new Promise((function(o,c){var i=t.apply(r,n);function a(t){e(i,o,c,a,u,"next",t)}function u(t){e(i,o,c,a,u,"throw",t)}a(void 0)}))}}},713:t=>{t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}},8:t=>{function e(r){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=e=function(t){return typeof t}:t.exports=e=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(r)}t.exports=e},757:(t,e,r)=>{t.exports=r(666)},666:t=>{var e=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},c=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",a=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=e&&e.prototype instanceof v?e:v,c=Object.create(o.prototype),i=new S(n||[]);return c._invoke=function(t,e,r){var n=p;return function(o,c){if(n===h)throw new Error("Generator is already running");if(n===d){if("throw"===o)throw c;return D()}for(r.method=o,r.arg=c;;){var i=r.delegate;if(i){var a=E(i,r);if(a){if(a===y)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===p)throw n=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=h;var u=f(t,e,r);if("normal"===u.type){if(n=r.done?d:l,u.arg===y)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=d,r.method="throw",r.arg=u.arg)}}}(t,r,i),c}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var p="suspendedStart",l="suspendedYield",h="executing",d="completed",y={};function v(){}function g(){}function w(){}var m={};m[c]=function(){return this};var b=Object.getPrototypeOf,O=b&&b(b(_([])));O&&O!==r&&n.call(O,c)&&(m=O);var j=w.prototype=v.prototype=Object.create(m);function x(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function P(t,e){function r(o,c,i,a){var u=f(t[o],t,c);if("throw"!==u.type){var s=u.arg,p=s.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,i,a)}),(function(t){r("throw",t,i,a)})):e.resolve(p).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,a)}))}a(u.arg)}var o;this._invoke=function(t,n){function c(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(c,c):c()}}function E(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,E(t,r),"throw"===r.method))return y;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var o=f(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,y;var c=o.arg;return c?c.done?(r[t.resultName]=c.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):c:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function _(t){if(t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}return{next:D}}function D(){return{value:e,done:!0}}return g.prototype=j.constructor=w,w.constructor=g,g.displayName=u(w,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,u(t,a,"GeneratorFunction")),t.prototype=Object.create(j),t},t.awrap=function(t){return{__await:t}},x(P.prototype),P.prototype[i]=function(){return this},t.AsyncIterator=P,t.async=function(e,r,n,o,c){void 0===c&&(c=Promise);var i=new P(s(e,r,n,o),c);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},x(j),u(j,a,"Generator"),j[c]=function(){return this},j.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=_,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return a.type="throw",a.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var c=this.tryEntries.length-1;c>=0;--c){var i=this.tryEntries[c],a=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var c=o;break}}c&&("break"===t||"continue"===t)&&c.tryLoc<=e&&e<=c.finallyLoc&&(c=null);var i=c?c.completion:{};return i.type=t,i.arg=e,c?(this.method="next",this.next=c.finallyLoc,y):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:_(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}},659:t=>{"use strict";t.exports=JSON.parse('{"name":"tocco-widget-utils","version":"0.1.8","description":"","scripts":{"compile:prod":"cd ../../../ && npm run compile:prod -- --package=widget-utils","prepublish":"npm run compile:prod"},"dependencies":{},"devDependencies":{"tocco-util":"*"}}')}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var c=e[n]={exports:{}};return t[n](c,c.exports,r),c.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n);var t=r(926),e=r.n(t),o=r(757),c=r.n(o),i=r(713),a=r.n(i);const u=function(){var t;window.console&&(t=console).log.apply(t,arguments)},s=function(){if(window.console){var t=console.error||console.log;t.apply(void 0,arguments)}};var f="toccoBackendUrl",p="data-tocco-widget-key";function l(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function h(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?l(Object(r),!0).forEach((function(e){a()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var d=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new Headers;r.set("Content-Type","application/json");var n=h({headers:r,method:"GET",credentials:"include"},e);return fetch(t,n)},y=function(t){var e=t.ok,r=t.status;return t.json().then((function(t){return{ok:e,status:r,body:t}}))},v="error",g=function(){var t=e()(c().mark((function t(e,r,n){var o,i;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o="ERROR MESSAGE: ".concat(n.message," \nSTACK: ").concat(n.stack?n.stack.substring(0,1e3):"-"),i="".concat(r,"\n").concat(o),s(i),t.next=5,m(v,e,i);case 5:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),w=function(){var t=e()(c().mark((function t(e,r){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s(r),t.next=3,m(v,e,r);case 3:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),m=function(){var t=e()(c().mark((function t(e,r,n){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,d("".concat(r,"/nice2/log?level=").concat(e,"&message=").concat(encodeURI(n)),{method:"POST"});case 3:t.next=7;break;case 5:t.prev=5,t.t0=t.catch(0);case 7:case"end":return t.stop()}}),t,null,[[0,5]])})));return function(e,r,n){return t.apply(this,arguments)}}(),b=r(8),O=r.n(b);function j(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function x(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?j(Object(r),!0).forEach((function(e){a()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var P=function(t){return t.getAttribute("data-id")},E=function(t){return new Promise((function(e,r){var n=document.createElement("script");n.src=t,n.async=!0,n.type="text/javascript",n.onload=function(){e()},n.onerror=function(){r(new Error("Could not load script."))},n.crossorogin=!0;var o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(n,o)}))},k=function(){var t=window.toccoTheme;if(t&&"object"===O()(t))return t},L=function(t){return t&&Object.keys(t).length>0&&"function"==typeof t[Object.keys(t)[0]]},S=function(t){var e=window.toccoEventHandlers;if(L(e))return e;if(e){var r=P(t);if(r){var n=e[r];if(L(n))return n}}return{}},_=function(t,e){var r=P(t);r&&(window.toccoMethods=x(x({},window.toccoMethods),{},a()({},r,e)))};function D(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function N(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?D(Object(r),!0).forEach((function(e){a()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):D(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var T=function(t){return t.getAttribute(p)},A=function(t,e,r){var n=e.ok,o=e.status,c=e.body;return n?e:(403===o&&"INVALID_DOMAIN"===(null==c?void 0:c.errorCode)&&w(t,c.message),void(404===o&&w(t,"Widget config '".concat(r,"' not found."))))},G=function(){var t=e()(c().mark((function t(e,r,n){var o,i,a,u,s,f,p,l,h,v,w;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=T(n),t.next=3,d("".concat(e,"/nice2/rest/widget/configs/").concat(o)).then(y).then((function(t){return A(e,t,o)})).then((function(t){return null==t?void 0:t.body})).catch((function(t){g(e,"Could not fetch widget config '".concat(o,"'."),t)}));case 3:if(!(i=t.sent)){t.next=20;break}return a=i.appName,u=i.packageName,s=i.locale,f=i.config,t.prev=6,t.next=9,E("".concat(r,"/js/tocco-").concat(u,"/dist/index.js"));case 9:t.next=15;break;case 11:return t.prev=11,t.t0=t.catch(6),g(e,"Could not fetch package 'tocco-".concat(u,"'."),t.t0),t.abrupt("return");case 15:p=k(),l=N(N(N({backendUrl:e},p?{customTheme:p}:{}),{},{locale:s},f),{},{appContext:{embedType:"widget"}}),h=S(n),v="".concat(r,"/js/tocco-").concat(u,"/dist/");try{w=window.reactRegistry.render(a,n,"",l,h,v),_(n,w)}catch(t){g(e,"Could not render app '".concat(a,"'."),t)}case 20:case"end":return t.stop()}}),t,null,[[6,11]])})));return function(e,r,n){return t.apply(this,arguments)}}(),C=function(){if(window.toccoBootstrap)return u("tocco-widget-utils - bootstrap script is already initialized"),!1;var t=r(659).version;return window.toccoBootstrap={version:t},u("tocco-widget-utils - v".concat(t," - bootstrap")),!0},M=function(){var t=e()(c().mark((function t(e){var r,n,o,i;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(C()){t.next=3;break}return t.abrupt("return");case 3:return r=e.backendUrl,n=e.assetUrl,o=document.querySelectorAll("[".concat(p,"]")),i=Array.prototype.slice.call(o),t.next=8,Promise.all(i.map((function(t){return G(r,n,t)})));case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();const R=M;var U,I;U=function(t){var e=t.currentScript.getAttribute("src"),r=new URL(e);return r.protocol+"//"+r.host}(document),I={backendUrl:window[f]?window[f]:U,assetUrl:U},document.addEventListener("DOMContentLoaded",e()(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,E("".concat(U,"/nice2/javascript/nice2-react.release.js"));case 2:return t.next=4,R(I);case 4:case"end":return t.stop()}}),t)}))))})(),n})()}));
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "tocco-widget-utils",
3
- "version": "0.1.5",
3
+ "version": "0.1.8",
4
4
  "description": "",
5
5
  "scripts": {
6
- "compile:prod": "cd ../../ && npm run compile:prod -- --package=widget-utils",
6
+ "compile:prod": "cd ../../../ && npm run compile:prod -- --package=widget-utils",
7
7
  "prepublish": "npm run compile:prod"
8
8
  },
9
9
  "dependencies": {},