@nizza/core 0.4.5-alpha.5 → 0.4.5-alpha.7
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/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/dist/lib/event-buses/BroadcastChannelEventBus.d.ts +1 -1
- package/dist/lib/nizza-store/ConfigManager.d.ts +3 -3
- package/dist/lib/nizza-store/NizzaStore.d.ts +1 -15
- package/dist/lib/nizza-store/NizzaStore.v1.d.ts +3 -3
- package/dist/lib/types/nizza/globalStore.d.ts +41 -0
- package/dist/lib/types/nizza/index.d.ts +1 -1
- package/dist/lib/types/nizza/main.d.ts +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/dist/lib/types/nizza/nizzaGlobalObject.d.ts +0 -15
package/dist/index.cjs
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var q=V;function Xn(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var Yn=typeof Object.is=="function"?Object.is:Xn,ei=q.useState,ti=q.useEffect,ni=q.useLayoutEffect,ii=q.useDebugValue;function ai(n,e){var t=e(),i=ei({inst:{value:t,getSnapshot:e}}),a=i[0].inst,r=i[1];return ni(function(){a.value=t,a.getSnapshot=e,xe(a)&&r({inst:a})},[n,t,e]),ti(function(){return xe(a)&&r({inst:a}),n(function(){xe(a)&&r({inst:a})})},[n]),ii(t),t}function xe(n){var e=n.getSnapshot;n=n.value;try{var t=e();return!Yn(n,t)}catch{return!0}}function ri(n,e){return e()}var si=typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"?ri:ai;_t.useSyncExternalStore=q.useSyncExternalStore!==void 0?q.useSyncExternalStore:si;Vt.exports=_t;var Ut=Vt.exports;const oi=je(Ut);var li={NZ_AWS_REGION:"us-east-1",NZ_VTEX_PROJECT:"/Users/jbermudez/TODO/PROJECTS/live-shopping",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{use:et}=V,{useSyncExternalStore:di}=oi,ui=(n,e)=>{const t=V.useRef();V.useEffect(()=>{t.current=Wn(n,e,!0)}),V.useDebugValue(t.current)},ci=new WeakMap;function mi(n,e){const t=e==null?void 0:e.sync,i=V.useRef(),a=V.useRef();let r=!0;const s=di(V.useCallback(l=>{const u=Zn(n,l,t);return l(),u},[n,t]),()=>{const l=Ye(n,et);try{if(!r&&i.current&&a.current&&!It(i.current,l,a.current,new WeakMap))return i.current}catch{}return l},()=>Ye(n,et));r=!1;const o=new WeakMap;V.useEffect(()=>{i.current=s,a.current=o}),(li?"production":void 0)!=="production"&&ui(s,o);const d=V.useMemo(()=>new WeakMap,[]);return Lt(s,o,d,ci)}class jt{constructor(){x(this,"channel");x(this,"listeners",new Map);x(this,"eventQueue",new Map);try{this.channel=new BroadcastChannel(
|
|
10
|
-
`);return n.length<3?"":n[2].trim().substring(3)}var $t={exports:{}};(function(n){(function(e,t){n.exports?n.exports=t():e.log=t()})(Pt,function(){var e=function(){},t="undefined",i=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),a=["trace","debug","info","warn","error"];function r(k,y){var F=k[y];if(typeof F.bind=="function")return F.bind(k);try{return Function.prototype.bind.call(F,k)}catch{return function(){return Function.prototype.apply.apply(F,[k,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function o(k){return k==="debug"&&(k="log"),typeof console===t?!1:k==="trace"&&i?s:console[k]!==void 0?r(console,k):console.log!==void 0?r(console,"log"):e}function d(k,y){for(var F=0;F<a.length;F++){var w=a[F];this[w]=F<k?e:this.methodFactory(w,k,y)}this.log=this.debug}function l(k,y,F){return function(){typeof console!==t&&(d.call(this,y,F),this[k].apply(this,arguments))}}function u(k,y,F){return o(k)||l.apply(this,arguments)}function p(k,y,F){var w=this,L;y=y==null?"WARN":y;var E="loglevel";typeof k=="string"?E+=":"+k:typeof k=="symbol"&&(E=void 0);function I(m){var g=(a[m]||"silent").toUpperCase();if(!(typeof window===t||!E)){try{window.localStorage[E]=g;return}catch{}try{window.document.cookie=encodeURIComponent(E)+"="+g+";"}catch{}}}function P(){var m;if(!(typeof window===t||!E)){try{m=window.localStorage[E]}catch{}if(typeof m===t)try{var g=window.document.cookie,h=g.indexOf(encodeURIComponent(E)+"=");h!==-1&&(m=/^([^;]+)/.exec(g.slice(h))[1])}catch{}return w.levels[m]===void 0&&(m=void 0),m}}function A(){if(!(typeof window===t||!E)){try{window.localStorage.removeItem(E);return}catch{}try{window.document.cookie=encodeURIComponent(E)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}w.name=k,w.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},w.methodFactory=F||u,w.getLevel=function(){return L},w.setLevel=function(m,g){if(typeof m=="string"&&w.levels[m.toUpperCase()]!==void 0&&(m=w.levels[m.toUpperCase()]),typeof m=="number"&&m>=0&&m<=w.levels.SILENT){if(L=m,g!==!1&&I(m),d.call(w,m,k),typeof console===t&&m<w.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+m},w.setDefaultLevel=function(m){y=m,P()||w.setLevel(m,!1)},w.resetLevel=function(){w.setLevel(y,!1),A()},w.enableAll=function(m){w.setLevel(w.levels.TRACE,m)},w.disableAll=function(m){w.setLevel(w.levels.SILENT,m)};var f=P();f==null&&(f=y),w.setLevel(f,!1)}var c=new p,v={};c.getLogger=function(y){if(typeof y!="symbol"&&typeof y!="string"||y==="")throw new TypeError("You must supply a name when creating a logger.");var F=v[y];return F||(F=v[y]=new p(y,c.getLevel(),c.methodFactory)),F};var S=typeof window!==t?window.log:void 0;return c.noConflict=function(){return typeof window!==t&&window.log===c&&(window.log=S),c},c.getLoggers=function(){return v},c.default=c,c})})($t);var zt=$t.exports;const de=je(zt);var Bt={exports:{}};(function(n){(function(e,t){n.exports?n.exports=t():e.prefix=t(e)})(Pt,function(e){var t=function(u){for(var p=1,c=arguments.length,v;p<c;p++)for(v in arguments[p])Object.prototype.hasOwnProperty.call(arguments[p],v)&&(u[v]=arguments[p][v]);return u},i={template:"[%t] %l:",levelFormatter:function(u){return u.toUpperCase()},nameFormatter:function(u){return u||"root"},timestampFormatter:function(u){return u.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")},format:void 0},a,r={},s=function(u){if(!u||!u.getLogger)throw new TypeError("Argument is not a root logger");a=u},o=function(u,p){if(!u||!u.setLevel)throw new TypeError("Argument is not a logger");var c=u.methodFactory,v=u.name||"",S=r[v]||r[""]||i;function k(y,F,w){var L=c(y,F,w),E=r[w]||r[""],I=E.template.indexOf("%t")!==-1,P=E.template.indexOf("%l")!==-1,A=E.template.indexOf("%n")!==-1;return function(){for(var f="",m=arguments.length,g=Array(m),h=0;h<m;h++)g[h]=arguments[h];if(v||!r[w]){var N=E.timestampFormatter(new Date),C=E.levelFormatter(y),b=E.nameFormatter(w);E.format?f+=E.format(C,b,N):(f+=E.template,I&&(f=f.replace(/%t/,N)),P&&(f=f.replace(/%l/,C)),A&&(f=f.replace(/%n/,b))),g.length&&typeof g[0]=="string"?g[0]=f+" "+g[0]:g.unshift(f)}L.apply(void 0,g)}}return r[v]||(u.methodFactory=k),p=p||{},p.template&&(p.format=void 0),r[v]=t({},S,p),u.setLevel(u.getLevel()),a||u.warn("It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md"),u},d={reg:s,apply:o},l;return e&&(l=e.prefix,d.noConflict=function(){return e.prefix===d&&(e.prefix=l),d}),d})})(Bt);var gi=Bt.exports;const tt=je(gi);let Qt=class{constructor(e){x(this,"defaultLevel",zt.levels.INFO);x(this,"namePrefix");this.namePrefix=e?`${e}-`:"",de.setDefaultLevel(this.defaultLevel),tt.reg(de),tt.apply(de,{template:"[%t] %l (%n)",nameFormatter:t=>{var i;return(i=t==null?void 0:t.toLowerCase())!=null?i:""},timestampFormatter:()=>new Date().toTimeString().slice(0,8)})}createLogger(e){const t=this.namePrefix+e.toLowerCase(),i=de.getLogger(t),a=localStorage.getItem(`loglevel:${t}`);return a?i.setLevel(a):i.setLevel(this.defaultLevel),i}};const B=Hn({config:null,get accountName(){var n;return(n=this.config)==null?void 0:n.account},get ok(){return!!this.account}}),ki=async n=>{var e;try{if(B.config=n,((e=B.account)==null?void 0:e.account)!==n.account){const t=await sn(n.account);B.account=t}if(n.getProductDataSource){const t=await n.getProductDataSource();B.productDataSource=At(t)}}catch(t){console.error("Error configuring NizzaStore:",t)}},vi=n=>{B.productDataSource=At(n)},nt=()=>({state:B,configure:ki,setProductDataSource:vi,instanceId:Mt(),log:new Qt("nz"),eventBus:new jt,get account(){return B.account},get productDataSource(){return B.productDataSource}}),Si=()=>{if(typeof window!="undefined"){if(!window.nizza){const n=nt();window.nizza=n,window.nz=n}return window.nizza}return nt()},be=Si(),yi=be.log.createLogger("main"),J=be.log.createLogger("core");function W(n){return n!=null&&typeof n=="object"&&n["@@functional/placeholder"]===!0}function ce(n){return function e(t){return arguments.length===0||W(t)?e:n.apply(this,arguments)}}function Me(n){return function e(t,i){switch(arguments.length){case 0:return e;case 1:return W(t)?e:ce(function(a){return n(t,a)});default:return W(t)&&W(i)?e:W(t)?ce(function(a){return n(a,i)}):W(i)?ce(function(a){return n(t,a)}):n(t,i)}}}const Ni=Number.isInteger||function(e){return e<<0===e};function bi(n){return Object.prototype.toString.call(n)==="[object String]"}var Fi=Me(function(e,t){var i=e<0?t.length+e:e;return bi(t)?t.charAt(i):t[i]});const wi=Fi;var Ci=ce(function(e){return e==null});const Ei=Ci;var Oi=Me(function(e,t){return e.map(function(i){for(var a=t,r=0,s;r<i.length;){if(a==null)return;s=i[r],a=Ni(s)?wi(s,a):a[s],r+=1}return a})});const Ri=Oi;var xi=Me(function(e,t){return Ri([e],t)[0]});const Ti=xi;class se extends Error{constructor(e,t,i){super(t),this.value=i,this.name=e}toDTO(){return{name:this.name,message:this.message,...this.value&&{value:this.value}}}}class Kt extends se{constructor(e){super("RESOURCE_NOT_FOUND_ERROR",`Resource with id '${e}' not found.`,e)}}class Gt extends se{constructor(e){var t;super("APP_UNEXPECTED_ERROR",(t=e.message)!=null?t:"An unexpected error occurred.",e)}}class Di extends se{constructor(){super("APP_ACCOUNT_INVALID_ERROR","Account not defined")}}class Wt extends se{constructor(e){super("INVALID_NIZZA_GLOBAL_OBJECT_ERROR",`
|
|
9
|
+
*/var q=V;function Xn(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var Yn=typeof Object.is=="function"?Object.is:Xn,ei=q.useState,ti=q.useEffect,ni=q.useLayoutEffect,ii=q.useDebugValue;function ai(n,e){var t=e(),i=ei({inst:{value:t,getSnapshot:e}}),a=i[0].inst,r=i[1];return ni(function(){a.value=t,a.getSnapshot=e,xe(a)&&r({inst:a})},[n,t,e]),ti(function(){return xe(a)&&r({inst:a}),n(function(){xe(a)&&r({inst:a})})},[n]),ii(t),t}function xe(n){var e=n.getSnapshot;n=n.value;try{var t=e();return!Yn(n,t)}catch{return!0}}function ri(n,e){return e()}var si=typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"?ri:ai;_t.useSyncExternalStore=q.useSyncExternalStore!==void 0?q.useSyncExternalStore:si;Vt.exports=_t;var Ut=Vt.exports;const oi=je(Ut);var li={NZ_AWS_REGION:"us-east-1",NZ_VTEX_PROJECT:"/Users/jbermudez/TODO/PROJECTS/live-shopping",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{use:et}=V,{useSyncExternalStore:di}=oi,ui=(n,e)=>{const t=V.useRef();V.useEffect(()=>{t.current=Wn(n,e,!0)}),V.useDebugValue(t.current)},ci=new WeakMap;function mi(n,e){const t=e==null?void 0:e.sync,i=V.useRef(),a=V.useRef();let r=!0;const s=di(V.useCallback(l=>{const u=Zn(n,l,t);return l(),u},[n,t]),()=>{const l=Ye(n,et);try{if(!r&&i.current&&a.current&&!It(i.current,l,a.current,new WeakMap))return i.current}catch{}return l},()=>Ye(n,et));r=!1;const o=new WeakMap;V.useEffect(()=>{i.current=s,a.current=o}),(li?"production":void 0)!=="production"&&ui(s,o);const d=V.useMemo(()=>new WeakMap,[]);return Lt(s,o,d,ci)}class jt{constructor(e){x(this,"channel");x(this,"listeners",new Map);x(this,"eventQueue",new Map);try{this.channel=new BroadcastChannel(e),this.channel.onmessage=t=>this.handleMessage(t),this.channel.onmessageerror=t=>J.error("NizzaBroadcastChannel:",t)}catch(t){throw J.error("Failed to create NizzaBroadcastChannel:",t),t}}on(e,t){return this.subscribeToEvent(e,t),{off:()=>this.unsubscribeFromEvent(e,t)}}emit(e,t,i={}){this.emitEvent(e,t,i)}handleMessage(e){const t=e.data,{name:i}=t;for(const[a,r]of this.listeners.entries())this.matchWildcard(a,i)&&r.forEach(s=>s({...t,wildcard:a}))}subscribeToEvent(e,t){if(typeof e!="string"||typeof t!="function"){const i=new Error("Invalid arguments");throw J.error(i),i}for(const[i,a]of this.listeners.entries())if(this.matchWildcard(i,e)){a.add(t);const r=this.eventQueue.get(i);r&&(r.forEach(s=>{t({...s,wildcard:i})}),this.eventQueue.delete(i));return}this.listeners.set(e,new Set([t]))}emitEvent(e,t,i){if(typeof e!="string"){const s=new Error("Invalid arguments");throw J.error(s),s}const a={name:e,data:t,attrs:i},r=Array.from(this.getMatchingListeners(e));if(r.length)for(const[s,o]of r)o({...a,wildcard:s});else this.eventQueue.has(e)||this.eventQueue.set(e,[]),this.eventQueue.get(e).push(a);this.channel.postMessage(a)}*getMatchingListeners(e){for(const[t,i]of this.listeners.entries())if(this.matchWildcard(t,e))for(const a of i)yield[t,a]}unsubscribeFromEvent(e,t){if(this.listeners.has(e)){const i=this.listeners.get(e);i.delete(t),i.size===0&&this.listeners.delete(e)}}matchWildcard(e,t){const i=e.replace(/\*/g,"[^:]*").replace(/\*\*/g,".*");return new RegExp(`^${i}$`).test(t)}}let fi=(n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");const Mt=(n=8)=>fi(n),pi=n=>{const e=Object.entries(n).reduce((t,[i,a])=>a!==void 0?`${t}${t?"&":""}${i}=${a}`:t,"");return e?`?${e}`:""};function hi(){const n=new Error().stack.split(`
|
|
10
|
+
`);return n.length<3?"":n[2].trim().substring(3)}var $t={exports:{}};(function(n){(function(e,t){n.exports?n.exports=t():e.log=t()})(Pt,function(){var e=function(){},t="undefined",i=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),a=["trace","debug","info","warn","error"];function r(k,y){var F=k[y];if(typeof F.bind=="function")return F.bind(k);try{return Function.prototype.bind.call(F,k)}catch{return function(){return Function.prototype.apply.apply(F,[k,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function o(k){return k==="debug"&&(k="log"),typeof console===t?!1:k==="trace"&&i?s:console[k]!==void 0?r(console,k):console.log!==void 0?r(console,"log"):e}function d(k,y){for(var F=0;F<a.length;F++){var w=a[F];this[w]=F<k?e:this.methodFactory(w,k,y)}this.log=this.debug}function l(k,y,F){return function(){typeof console!==t&&(d.call(this,y,F),this[k].apply(this,arguments))}}function u(k,y,F){return o(k)||l.apply(this,arguments)}function p(k,y,F){var w=this,L;y=y==null?"WARN":y;var E="loglevel";typeof k=="string"?E+=":"+k:typeof k=="symbol"&&(E=void 0);function I(m){var g=(a[m]||"silent").toUpperCase();if(!(typeof window===t||!E)){try{window.localStorage[E]=g;return}catch{}try{window.document.cookie=encodeURIComponent(E)+"="+g+";"}catch{}}}function P(){var m;if(!(typeof window===t||!E)){try{m=window.localStorage[E]}catch{}if(typeof m===t)try{var g=window.document.cookie,h=g.indexOf(encodeURIComponent(E)+"=");h!==-1&&(m=/^([^;]+)/.exec(g.slice(h))[1])}catch{}return w.levels[m]===void 0&&(m=void 0),m}}function A(){if(!(typeof window===t||!E)){try{window.localStorage.removeItem(E);return}catch{}try{window.document.cookie=encodeURIComponent(E)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}w.name=k,w.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},w.methodFactory=F||u,w.getLevel=function(){return L},w.setLevel=function(m,g){if(typeof m=="string"&&w.levels[m.toUpperCase()]!==void 0&&(m=w.levels[m.toUpperCase()]),typeof m=="number"&&m>=0&&m<=w.levels.SILENT){if(L=m,g!==!1&&I(m),d.call(w,m,k),typeof console===t&&m<w.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+m},w.setDefaultLevel=function(m){y=m,P()||w.setLevel(m,!1)},w.resetLevel=function(){w.setLevel(y,!1),A()},w.enableAll=function(m){w.setLevel(w.levels.TRACE,m)},w.disableAll=function(m){w.setLevel(w.levels.SILENT,m)};var f=P();f==null&&(f=y),w.setLevel(f,!1)}var c=new p,v={};c.getLogger=function(y){if(typeof y!="symbol"&&typeof y!="string"||y==="")throw new TypeError("You must supply a name when creating a logger.");var F=v[y];return F||(F=v[y]=new p(y,c.getLevel(),c.methodFactory)),F};var S=typeof window!==t?window.log:void 0;return c.noConflict=function(){return typeof window!==t&&window.log===c&&(window.log=S),c},c.getLoggers=function(){return v},c.default=c,c})})($t);var zt=$t.exports;const de=je(zt);var Bt={exports:{}};(function(n){(function(e,t){n.exports?n.exports=t():e.prefix=t(e)})(Pt,function(e){var t=function(u){for(var p=1,c=arguments.length,v;p<c;p++)for(v in arguments[p])Object.prototype.hasOwnProperty.call(arguments[p],v)&&(u[v]=arguments[p][v]);return u},i={template:"[%t] %l:",levelFormatter:function(u){return u.toUpperCase()},nameFormatter:function(u){return u||"root"},timestampFormatter:function(u){return u.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")},format:void 0},a,r={},s=function(u){if(!u||!u.getLogger)throw new TypeError("Argument is not a root logger");a=u},o=function(u,p){if(!u||!u.setLevel)throw new TypeError("Argument is not a logger");var c=u.methodFactory,v=u.name||"",S=r[v]||r[""]||i;function k(y,F,w){var L=c(y,F,w),E=r[w]||r[""],I=E.template.indexOf("%t")!==-1,P=E.template.indexOf("%l")!==-1,A=E.template.indexOf("%n")!==-1;return function(){for(var f="",m=arguments.length,g=Array(m),h=0;h<m;h++)g[h]=arguments[h];if(v||!r[w]){var N=E.timestampFormatter(new Date),C=E.levelFormatter(y),b=E.nameFormatter(w);E.format?f+=E.format(C,b,N):(f+=E.template,I&&(f=f.replace(/%t/,N)),P&&(f=f.replace(/%l/,C)),A&&(f=f.replace(/%n/,b))),g.length&&typeof g[0]=="string"?g[0]=f+" "+g[0]:g.unshift(f)}L.apply(void 0,g)}}return r[v]||(u.methodFactory=k),p=p||{},p.template&&(p.format=void 0),r[v]=t({},S,p),u.setLevel(u.getLevel()),a||u.warn("It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md"),u},d={reg:s,apply:o},l;return e&&(l=e.prefix,d.noConflict=function(){return e.prefix===d&&(e.prefix=l),d}),d})})(Bt);var gi=Bt.exports;const tt=je(gi);let Qt=class{constructor(e){x(this,"defaultLevel",zt.levels.INFO);x(this,"namePrefix");this.namePrefix=e?`${e}-`:"",de.setDefaultLevel(this.defaultLevel),tt.reg(de),tt.apply(de,{template:"[%t] %l (%n)",nameFormatter:t=>{var i;return(i=t==null?void 0:t.toLowerCase())!=null?i:""},timestampFormatter:()=>new Date().toTimeString().slice(0,8)})}createLogger(e){const t=this.namePrefix+e.toLowerCase(),i=de.getLogger(t),a=localStorage.getItem(`loglevel:${t}`);return a?i.setLevel(a):i.setLevel(this.defaultLevel),i}};const B=Hn({config:null,get accountName(){var n;return(n=this.config)==null?void 0:n.account},get ok(){return!!this.account}}),ki=async n=>{var e;try{if(B.config=n,((e=B.account)==null?void 0:e.account)!==n.account){const t=await sn(n.account);B.account=t}if(n.getProductDataSource){const t=await n.getProductDataSource();B.productDataSource=At(t)}}catch(t){console.error("Error configuring NizzaStore:",t)}},vi=n=>{B.productDataSource=At(n)},nt=()=>({state:B,configure:ki,setProductDataSource:vi,instanceId:Mt(),log:new Qt("nz"),eventBus:new jt("nizza"),get account(){return B.account},get productDataSource(){return B.productDataSource}}),Si=()=>{if(typeof window!="undefined"){if(!window.nizza){const n=nt();window.nizza=n,window.nz=n}return window.nizza}return nt()},be=Si(),yi=be.log.createLogger("main"),J=be.log.createLogger("core");function W(n){return n!=null&&typeof n=="object"&&n["@@functional/placeholder"]===!0}function ce(n){return function e(t){return arguments.length===0||W(t)?e:n.apply(this,arguments)}}function Me(n){return function e(t,i){switch(arguments.length){case 0:return e;case 1:return W(t)?e:ce(function(a){return n(t,a)});default:return W(t)&&W(i)?e:W(t)?ce(function(a){return n(a,i)}):W(i)?ce(function(a){return n(t,a)}):n(t,i)}}}const Ni=Number.isInteger||function(e){return e<<0===e};function bi(n){return Object.prototype.toString.call(n)==="[object String]"}var Fi=Me(function(e,t){var i=e<0?t.length+e:e;return bi(t)?t.charAt(i):t[i]});const wi=Fi;var Ci=ce(function(e){return e==null});const Ei=Ci;var Oi=Me(function(e,t){return e.map(function(i){for(var a=t,r=0,s;r<i.length;){if(a==null)return;s=i[r],a=Ni(s)?wi(s,a):a[s],r+=1}return a})});const Ri=Oi;var xi=Me(function(e,t){return Ri([e],t)[0]});const Ti=xi;class se extends Error{constructor(e,t,i){super(t),this.value=i,this.name=e}toDTO(){return{name:this.name,message:this.message,...this.value&&{value:this.value}}}}class Kt extends se{constructor(e){super("RESOURCE_NOT_FOUND_ERROR",`Resource with id '${e}' not found.`,e)}}class Gt extends se{constructor(e){var t;super("APP_UNEXPECTED_ERROR",(t=e.message)!=null?t:"An unexpected error occurred.",e)}}class Di extends se{constructor(){super("APP_ACCOUNT_INVALID_ERROR","Account not defined")}}class Wt extends se{constructor(e){super("INVALID_NIZZA_GLOBAL_OBJECT_ERROR",`
|
|
11
11
|
Configuration property invalid: "${e}".
|
|
12
12
|
|
|
13
13
|
It looks like you are trying to use a configuration property that is required but is "undefined", make sure you have initialized the global object "nizza".
|