@qoh/core-react 1.0.0-rc.11 → 1.0.0-rc.12

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/lib/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var M=Object.create;var g=Object.defineProperty,z=Object.defineProperties,B=Object.getOwnPropertyDescriptor,H=Object.getOwnPropertyDescriptors,U=Object.getOwnPropertyNames,O=Object.getOwnPropertySymbols,J=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var q=(t,e,n)=>e in t?g(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,b=(t,e)=>{for(var n in e||(e={}))j.call(e,n)&&q(t,n,e[n]);if(O)for(var n of O(e))N.call(e,n)&&q(t,n,e[n]);return t},E=(t,e)=>z(t,H(e));var X=(t,e)=>{for(var n in e)g(t,n,{get:e[n],enumerable:!0})},R=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of U(e))!j.call(t,i)&&i!==n&&g(t,i,{get:()=>e[i],enumerable:!(r=B(e,i))||r.enumerable});return t};var f=(t,e,n)=>(n=t!=null?M(J(t)):{},R(e||!t||!t.__esModule?g(n,"default",{value:t,enumerable:!0}):n,t)),W=t=>R(g({},"__esModule",{value:!0}),t);var u=(t,e,n)=>new Promise((r,i)=>{var o=c=>{try{s(n.next(c))}catch(y){i(y)}},l=c=>{try{s(n.throw(c))}catch(y){i(y)}},s=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,l);s((n=n.apply(t,e)).next())});var ce={};X(ce,{ApiError:()=>m,DatoCMS:()=>w,Filter:()=>P,QueenofheartsRenderComponent:()=>G,QueenofheartsService:()=>h,StrapiCMS:()=>C,componentRegistry:()=>d,fetchDynamicComponents:()=>ae,getAllregisteredComponents:()=>$,registerComponent:()=>oe,registerLazyComponent:()=>se,unregisterComponent:()=>ie});module.exports=W(ce);var A=require("react");var v=require("react/jsx-runtime");function G(t){let e=h.getInstance(),{data:n,contextProps:r}=t;return n&&e?Array.isArray(n)?(0,v.jsx)(A.Suspense,{fallback:null,children:n.map((i,o)=>e.createComponent({data:i,contextProps:r}))}):(0,v.jsx)(A.Suspense,{fallback:null,children:e.createComponent({data:n,contextProps:r})}):e?(0,v.jsx)("div",{className:"error",children:"QueenofheartsRenderComponent: Invalid data received."}):(0,v.jsx)("div",{children:"QueenofheartsService is not initialized"})}var m=class extends Error{constructor(e,n){super(n.summary),this.name="ApiError",this.status=e,this.body=n}};var x=f(require("react"));var p=f(require("react"));var a=require("react/jsx-runtime"),V=({children:t,style:e})=>(0,a.jsx)("details",{style:e,children:t}),K=({children:t})=>(0,a.jsx)("summary",{children:t}),Y=({children:t})=>(0,a.jsx)("div",{style:{paddingLeft:"1em"},children:t}),_=({children:t,style:e})=>(0,a.jsx)("div",{style:E(b({},e),{border:"1px solid #ccc",padding:".5em"}),children:t}),Z=()=>(0,a.jsx)("span",{children:"\u25BC"}),D=p.lazy(()=>import("@mui/material/Accordion").catch(()=>({default:V}))),Q=p.lazy(()=>import("@mui/material/AccordionSummary").catch(()=>({default:K}))),k=p.lazy(()=>import("@mui/material/AccordionDetails").catch(()=>({default:Y}))),ee=p.lazy(()=>import("@mui/material/Paper").catch(()=>({default:_}))),F=p.lazy(()=>import("@mui/icons-material/ExpandMore").catch(()=>({default:Z})));function ne(t,e,n){return(0,a.jsxs)(D,{style:{width:"100%"},children:[(0,a.jsxs)(Q,{style:{padding:0},expandIcon:(0,a.jsx)(F,{}),children:[t,": Array[",e.length,"]"]}),(0,a.jsx)(k,{children:e.map((r,i)=>S("",r,i))})]},`${t}_${n}`)}function te(t,e,n){return(0,a.jsxs)(D,{style:{width:"100%"},children:[(0,a.jsx)(Q,{expandIcon:(0,a.jsx)(F,{}),children:t}),(0,a.jsx)(k,{children:Object.entries(e).map((r,i)=>S(r[0],r[1],i))})]},`${t}_${n}`)}function I(t,e,n){return(0,a.jsxs)("div",{children:[t,": ",`${e}`]},`${t}_${n}`)}function S(t,e,n){var i;if(Array.isArray(e))return ne(t,e,n);if(!e||["string","number"].includes(typeof e))return I(t,e,n);if(typeof e=="boolean")return I(t,e?"true":"false",n);let r=`${t?t+": ":""}${(i=e.__typename)!=null?i:"object"}`;return te(r,e,n)}function T(t){return typeof t.data=="object"?(0,a.jsx)(p.Suspense,{fallback:(0,a.jsx)(_,{style:{margin:".5em",width:"calc(100% - 1em)"},children:S("",t.data,1)}),children:(0,a.jsx)(ee,{style:{margin:".5em",width:"calc(100% - 1em)"},children:S("",t.data,1)})}):null}var P=(i=>(i.eq="eq",i.in="in",i.neq="neq",i.notIn="notIn",i))(P||{}),re="https://headless.li/api",d={};function ie(t){delete d[t]}function oe(t,e,n,r){if(e!==void 0&&(r||d[e]===void 0)){let i={component:t,fieldNames:n};d[e]=i}}function se(t,e,n,r=!1){e?(r||d[e]===void 0)&&(d[e]={fieldNames:n,loader:t}):console.warn("registerComponent failed: undefined typeName ")}function $(){return d}var ae=t=>u(null,null,function*(){let e=h.getInstance(),n=e.findComponentsInProps(t).filter((i,o,l)=>l.indexOf(i)===o);return(yield e.fetchDynamicComponents(n)).filter(i=>i!==null)}),h=class t{constructor(e,n){this.latestUrl="";this.latestData={};this.findComponentsInProps=e=>{if(e&&typeof e!="string"){let n=e.__typename?[e.__typename]:[],r=Array.isArray(e)?e:Object.values(e);return[...n,...r.reduce((o,l)=>{let s=this.findComponentsInProps(l);return s&&(o=[...o,...s]),o},[])]}return[]};this.fetchDynamicComponents=e=>u(this,null,function*(){let n=!1,r=!1,i=Promise.all(e.map(o=>u(this,null,function*(){var l;return d[o]&&d[o].component===void 0?(n=!0,yield this.loadAsyncComponent(o)):(l=d[o])!=null&&l.loader?o:null})));return r=!0,i});this.buildUrl=e=>{var r;return`${(r=this.localServer)!=null?r:re}/${e}`};this.queryGraphql=e=>u(this,null,function*(){let n=this.buildUrl("execGraphqlQuery");if(console.info(`using url : ${n}`),n){let r=yield fetch(n,{method:"POST",headers:{Authorization:`Bearer ${this.apiToken}`,"Content-Type":"application/json"},body:JSON.stringify({query:e})});if(r.ok){let i=yield r.json();return this.sendDebugEvent(),i}else{let i=yield r.json();throw console.log(i),new m(r.status,i)}}throw new m(500,{id:"99",summary:"queryUrl was not set",details:`LocalServer: ${this.localServer}`})});this.query=(e,n)=>u(this,null,function*(){var o,l;let r=this.buildUrl("execQuery"),i=n!=null&&n.variables?b({},n.variables):{};if(n!=null&&n.locale&&(i.locale=n.locale),n!=null&&n.filter&&Array.isArray(n.filter)&&(i.filter||(i.filter=[]),i.filter.push(...n.filter),(o=n==null?void 0:n.variables)!=null&&o.filter&&Array.isArray(n.variables.filter)&&i.filter.push(...n.variables.filter)),r&&n){let s=yield fetch(r,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiToken}`},method:"POST",credentials:"include",body:JSON.stringify({queryname:e,variables:i,components:this.getRegisteredComponentsWithFields(),ignoreProperties:n.ignoreProperties,depth:n.depth})});if(s.ok){let c=(l=yield s.json())==null?void 0:l.data,y=this.debug?this.injectIds(c):c;return this.latestData=y,this.sendDebugEvent(),y}else try{let c=yield s.json();throw console.log(c),new m(s.status,c)}catch(c){throw new m(s.status,c.toString())}}else throw new m(500,{id:"99",summary:`Query: queryUrl (${r}) or options are invalid`,details:`queryUrl: ${r}`})});this.getRegisteredComponentsWithFields=()=>{let e={},n=Object.entries($());return n&&Array.isArray(n)&&n.forEach(([r,i])=>{let o={},l=i.fieldNames,s=!1;l&&Array.isArray(l)&&l.forEach(c=>{o[c]=!0,s=!0}),s?e[r]=o:e[r]={__all:!0}}),e};this.getQueries=()=>u(this,null,function*(){let e=this.buildUrl("queries");if(e){let n=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json"}});if(n.ok)try{return yield n.json()}catch(r){console.error(r)}}else console.error("api, uri and CMSToken have to be provided");return""});this.apiToken=e,this.localServer=n,this.debug=typeof document!="undefined"&&document.getElementsByTagName("body")[0].classList.contains("qoh-inject-ids"),this.debug&&typeof globalThis.window!="undefined"&&(globalThis.window.addEventListener("QueenOfHearts-RequestData",()=>{this.sendDebugEvent()}),globalThis.window.addEventListener("QueenOfHearts-RequestQueries",()=>{this.sendQueriesEvent()}),globalThis.window.addEventListener("QueenOfHearts-HighlightComponent",(r=>{this.highlightComponent(r.detail)})),globalThis.window.addEventListener("QueenOfHearts-RequestComponentHTML",(r=>{this.sendComponentHTML(r.detail)})))}static init(e,n){t.instance=new t(e,n)}static getInstance(){return t.instance||console.error("QueenofheartsService was not initialized using QueenofheartsService.init(backend, apiToken)"),t.instance}loadAsyncComponent(e){return u(this,null,function*(){let n=d[e];if(n&&n.component===void 0){if(!(n!=null&&n.component)&&n.loader){let r=n.loader,i=yield r();i?d[e].component=i.default:(console.error(`error loading ${e}`),console.error(i))}return e}return null})}createComponent(e){var s;let{data:n,contextProps:r={}}=e,i=n.__typename,o=d[i];o&&o.loader&&(0,x.lazy)(o.loader);let l=(s=o==null?void 0:o.component)!=null?s:T;return x.default.createElement(l,E(b({},n),{contextProps:r}))}injectIds(e){if(Array.isArray(e))e.forEach(n=>this.injectIds(n));else if(e&&typeof e=="object"){if(e.hasOwnProperty("__typename")){let n=Math.random().toString();e.__qohId=n.substr(n.indexOf(".")+1)}Object.keys(e).forEach(n=>e[n]=this.injectIds(e[n]))}return e}sendDebugEvent(){if(typeof window=="undefined")return;let e={registeredComponents:Object.keys(d),url:this.latestUrl,data:this.latestData},n=new CustomEvent("QueenOfHearts-DebuggingData",{detail:e});window.dispatchEvent(n)}sendQueriesEvent(){return u(this,null,function*(){if(typeof window=="undefined")return;let e=new CustomEvent("QueenOfHearts-AvailableQueries",{detail:yield this.getQueries()});window.dispatchEvent(e)})}sendComponentHTML(e){var r;if(typeof window=="undefined")return;let n=(r=document.querySelector(`[qohId='${e}']`))==null?void 0:r.nextElementSibling;if(n){let i=new CustomEvent("QueenOfHearts-SelectedComponentHTML",{detail:{qohId:e,html:n.outerHTML}});window.dispatchEvent(i)}}highlightComponent(e){var o;let n=[{outline:"thick auto white"},{outline:"thick auto red"}],r={duration:1e3,iterations:2},i=(o=document.querySelector(`[qohId='${e}']`))==null?void 0:o.nextElementSibling;i&&i.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),i&&i.animate(n,r)}};var w=class{constructor(e){this.token="";this.uri="https://graphql.datocms.com/";this.token=e}renameSEOMetaTags(e){e.forEach(function(n,r,i){i[r].__typename="SEOMetaTag"})}normalize(e){if(e)return e._seoMetaTags&&this.renameSEOMetaTags(e._seoMetaTags),Object.keys(e).forEach(n=>{Array.isArray(e[n])&&(e[n]=e[n].map(r=>this.normalize(r))),e[n]&&typeof e[n]=="object"&&(e[n]=this.normalize(e[n]))}),e}};var L=f(require("dotenv"));L.default.config();var C=class{constructor(e,n){this.token="";this.uri="";this.token=e,this.uri=n}renameSEOMetaTags(e){e.forEach(function(n,r,i){i[r].__typename="SEOMetaTag"})}normalize(e){return e&&(e._seoMetaTags&&this.renameSEOMetaTags(e._seoMetaTags),Object.keys(e).forEach(n=>{Array.isArray(e[n])&&(e[n]=e[n].map(r=>this.normalize(r))),e[n]&&typeof e[n]=="object"&&(e[n]=this.normalize(e[n]))}),e)}};0&&(module.exports={ApiError,DatoCMS,Filter,QueenofheartsRenderComponent,QueenofheartsService,StrapiCMS,componentRegistry,fetchDynamicComponents,getAllregisteredComponents,registerComponent,registerLazyComponent,unregisterComponent});
1
+ "use strict";var L=Object.create;var g=Object.defineProperty,M=Object.defineProperties,z=Object.getOwnPropertyDescriptor,B=Object.getOwnPropertyDescriptors,H=Object.getOwnPropertyNames,O=Object.getOwnPropertySymbols,U=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var q=(t,e,n)=>e in t?g(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,b=(t,e)=>{for(var n in e||(e={}))j.call(e,n)&&q(t,n,e[n]);if(O)for(var n of O(e))J.call(e,n)&&q(t,n,e[n]);return t},E=(t,e)=>M(t,B(e));var N=(t,e)=>{for(var n in e)g(t,n,{get:e[n],enumerable:!0})},R=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of H(e))!j.call(t,i)&&i!==n&&g(t,i,{get:()=>e[i],enumerable:!(r=z(e,i))||r.enumerable});return t};var p=(t,e,n)=>(n=t!=null?L(U(t)):{},R(e||!t||!t.__esModule?g(n,"default",{value:t,enumerable:!0}):n,t)),X=t=>R(g({},"__esModule",{value:!0}),t);var u=(t,e,n)=>new Promise((r,i)=>{var o=c=>{try{s(n.next(c))}catch(y){i(y)}},l=c=>{try{s(n.throw(c))}catch(y){i(y)}},s=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,l);s((n=n.apply(t,e)).next())});var ae={};N(ae,{ApiError:()=>m,DatoCMS:()=>w,Filter:()=>P,QueenofheartsRenderComponent:()=>W,QueenofheartsService:()=>h,StrapiCMS:()=>C,componentRegistry:()=>d,fetchDynamicComponents:()=>se,getAllregisteredComponents:()=>$,registerComponent:()=>ie,registerLazyComponent:()=>oe,unregisterComponent:()=>re});module.exports=X(ae);var A=require("react");var v=require("react/jsx-runtime");function W(t){let e=h.getInstance(),{data:n,contextProps:r}=t;return n&&e?Array.isArray(n)?(0,v.jsx)(A.Suspense,{fallback:null,children:n.map((i,o)=>e.createComponent({data:i,contextProps:r}))}):(0,v.jsx)(A.Suspense,{fallback:null,children:e.createComponent({data:n,contextProps:r})}):e?(0,v.jsx)("div",{className:"error",children:"QueenofheartsRenderComponent: Invalid data received."}):(0,v.jsx)("div",{children:"QueenofheartsService is not initialized"})}var m=class extends Error{constructor(e,n){super(n.summary),this.name="ApiError",this.status=e,this.body=n}};var x=p(require("react"));var f=p(require("react"));var a=require("react/jsx-runtime"),G=({children:t,style:e})=>(0,a.jsx)("details",{style:e,children:t}),V=({children:t})=>(0,a.jsx)("summary",{children:t}),K=({children:t})=>(0,a.jsx)("div",{style:{paddingLeft:"1em"},children:t}),_=({children:t,style:e})=>(0,a.jsx)("div",{style:E(b({},e),{border:"1px solid #ccc",padding:".5em"}),children:t}),Y=()=>(0,a.jsx)("span",{children:"\u25BC"}),D=f.lazy(()=>import("@mui/material/Accordion").catch(()=>({default:G}))),Q=f.lazy(()=>import("@mui/material/AccordionSummary").catch(()=>({default:V}))),k=f.lazy(()=>import("@mui/material/AccordionDetails").catch(()=>({default:K}))),Z=f.lazy(()=>import("@mui/material/Paper").catch(()=>({default:_}))),F=f.lazy(()=>import("@mui/icons-material/ExpandMore").catch(()=>({default:Y})));function ee(t,e,n){return(0,a.jsxs)(D,{style:{width:"100%"},children:[(0,a.jsxs)(Q,{style:{padding:0},expandIcon:(0,a.jsx)(F,{}),children:[t,": Array[",e.length,"]"]}),(0,a.jsx)(k,{children:e.map((r,i)=>S("",r,i))})]},`${t}_${n}`)}function ne(t,e,n){return(0,a.jsxs)(D,{style:{width:"100%"},children:[(0,a.jsx)(Q,{expandIcon:(0,a.jsx)(F,{}),children:t}),(0,a.jsx)(k,{children:Object.entries(e).map((r,i)=>S(r[0],r[1],i))})]},`${t}_${n}`)}function I(t,e,n){return(0,a.jsxs)("div",{children:[t,": ",`${e}`]},`${t}_${n}`)}function S(t,e,n){var i;if(Array.isArray(e))return ee(t,e,n);if(!e||["string","number"].includes(typeof e))return I(t,e,n);if(typeof e=="boolean")return I(t,e?"true":"false",n);let r=`${t?t+": ":""}${(i=e.__typename)!=null?i:"object"}`;return ne(r,e,n)}function T(t){return typeof t.data=="object"?(0,a.jsx)(f.Suspense,{fallback:(0,a.jsx)(_,{style:{margin:".5em",width:"calc(100% - 1em)"},children:S("",t.data,1)}),children:(0,a.jsx)(Z,{style:{margin:".5em",width:"calc(100% - 1em)"},children:S("",t.data,1)})}):null}var P=(i=>(i.eq="eq",i.in="in",i.neq="neq",i.notIn="notIn",i))(P||{}),te="https://headless.li/api",d={};function re(t){delete d[t]}function ie(t,e,n,r){if(e!==void 0&&(r||d[e]===void 0)){let i={component:t,fieldNames:n};d[e]=i}}function oe(t,e,n,r=!1){e?(r||d[e]===void 0)&&(d[e]={fieldNames:n,loader:t}):console.warn("registerComponent failed: undefined typeName ")}function $(){return d}var se=t=>u(null,null,function*(){let e=h.getInstance(),n=e.findComponentsInProps(t).filter((i,o,l)=>l.indexOf(i)===o);return(yield e.fetchDynamicComponents(n)).filter(i=>i!==null)}),h=class t{constructor(e,n){this.latestUrl="";this.latestData={};this.findComponentsInProps=e=>{if(e&&typeof e!="string"){let n=e.__typename?[e.__typename]:[],r=Array.isArray(e)?e:Object.values(e);return[...n,...r.reduce((o,l)=>{let s=this.findComponentsInProps(l);return s&&(o=[...o,...s]),o},[])]}return[]};this.fetchDynamicComponents=e=>u(this,null,function*(){let n=!1,r=!1,i=Promise.all(e.map(o=>u(this,null,function*(){var l;return d[o]&&d[o].component===void 0?(n=!0,yield this.loadAsyncComponent(o)):(l=d[o])!=null&&l.loader?o:null})));return r=!0,i});this.buildUrl=e=>{var r;return`${(r=this.localServer)!=null?r:te}/${e}`};this.queryGraphql=e=>u(this,null,function*(){let n=this.buildUrl("execGraphqlQuery");if(console.info(`using url : ${n}`),n){let r=yield fetch(n,{method:"POST",headers:{Authorization:`Bearer ${this.apiToken}`,"Content-Type":"application/json"},body:JSON.stringify({query:e})});if(r.ok){let i=yield r.json();return this.sendDebugEvent(),i}else{let i=yield r.json();throw console.log(i),new m(r.status,i)}}throw new m(500,{id:"99",summary:"queryUrl was not set",details:`LocalServer: ${this.localServer}`})});this.query=(e,n)=>u(this,null,function*(){var o,l;let r=this.buildUrl("execQuery"),i=n!=null&&n.variables?b({},n.variables):{};if(n!=null&&n.locale&&(i.locale=n.locale),n!=null&&n.filter&&Array.isArray(n.filter)&&(i.filter||(i.filter=[]),i.filter.push(...n.filter),(o=n==null?void 0:n.variables)!=null&&o.filter&&Array.isArray(n.variables.filter)&&i.filter.push(...n.variables.filter)),r&&n){let s=yield fetch(r,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiToken}`},method:"POST",credentials:"include",body:JSON.stringify({queryname:e,variables:i,components:this.getRegisteredComponentsWithFields(),ignoreProperties:n.ignoreProperties,depth:n.depth})});if(s.ok){let c=(l=yield s.json())==null?void 0:l.data,y=this.debug?this.injectIds(c):c;return this.latestData=y,this.sendDebugEvent(),y}else try{let c=yield s.json();throw console.log(c),new m(s.status,c)}catch(c){throw new m(s.status,c.toString())}}else throw new m(500,{id:"99",summary:`Query: queryUrl (${r}) or options are invalid`,details:`queryUrl: ${r}`})});this.getRegisteredComponentsWithFields=()=>{let e={},n=Object.entries($());return n&&Array.isArray(n)&&n.forEach(([r,i])=>{let o={},l=i.fieldNames,s=!1;l&&Array.isArray(l)&&l.forEach(c=>{o[c]=!0,s=!0}),s?e[r]=o:e[r]={__all:!0}}),e};this.getQueries=()=>u(this,null,function*(){let e=this.buildUrl("queries");if(e){let n=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json"}});if(n.ok)try{return yield n.json()}catch(r){console.error(r)}}else console.error("api, uri and CMSToken have to be provided");return""});this.apiToken=e,this.localServer=n,this.debug=typeof document!="undefined"&&document.getElementsByTagName("body")[0].classList.contains("qoh-inject-ids"),this.debug&&typeof globalThis.window!="undefined"&&(globalThis.window.addEventListener("QueenOfHearts-RequestData",()=>{this.sendDebugEvent()}),globalThis.window.addEventListener("QueenOfHearts-RequestQueries",()=>{this.sendQueriesEvent()}),globalThis.window.addEventListener("QueenOfHearts-HighlightComponent",(r=>{this.highlightComponent(r.detail)})),globalThis.window.addEventListener("QueenOfHearts-RequestComponentHTML",(r=>{this.sendComponentHTML(r.detail)})))}static init(e,n){t.instance=new t(e,n)}static getInstance(){return t.instance||console.error("QueenofheartsService was not initialized using QueenofheartsService.init(backend, apiToken)"),t.instance}loadAsyncComponent(e){return u(this,null,function*(){let n=d[e];if(n&&n.component===void 0){if(!(n!=null&&n.component)&&n.loader){let r=n.loader,i=yield r();i?d[e].component=i.default:(console.error(`error loading ${e}`),console.error(i))}return e}return null})}createComponent(e){var s;let{data:n,contextProps:r={}}=e,i=n.__typename,o=d[i];o&&o.loader&&(0,x.lazy)(o.loader);let l=(s=o==null?void 0:o.component)!=null?s:T;return x.default.createElement(l,E(b({},n),{contextProps:r}))}injectIds(e){if(Array.isArray(e))e.forEach(n=>this.injectIds(n));else if(e&&typeof e=="object"){if(e.hasOwnProperty("__typename")){let n=Math.random().toString();e.__qohId=n.substr(n.indexOf(".")+1)}Object.keys(e).forEach(n=>e[n]=this.injectIds(e[n]))}return e}sendDebugEvent(){if(typeof window=="undefined")return;let e={registeredComponents:Object.keys(d),url:this.latestUrl,data:this.latestData},n=new CustomEvent("QueenOfHearts-DebuggingData",{detail:e});window.dispatchEvent(n)}sendQueriesEvent(){return u(this,null,function*(){if(typeof window=="undefined")return;let e=new CustomEvent("QueenOfHearts-AvailableQueries",{detail:yield this.getQueries()});window.dispatchEvent(e)})}sendComponentHTML(e){var r;if(typeof window=="undefined")return;let n=(r=document.querySelector(`[qohId='${e}']`))==null?void 0:r.nextElementSibling;if(n){let i=new CustomEvent("QueenOfHearts-SelectedComponentHTML",{detail:{qohId:e,html:n.outerHTML}});window.dispatchEvent(i)}}highlightComponent(e){var o;let n=[{outline:"thick auto white"},{outline:"thick auto red"}],r={duration:1e3,iterations:2},i=(o=document.querySelector(`[qohId='${e}']`))==null?void 0:o.nextElementSibling;i&&i.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),i&&i.animate(n,r)}};var w=class{constructor(e){this.token="";this.uri="https://graphql.datocms.com/";this.token=e}renameSEOMetaTags(e){e.forEach(function(n,r,i){i[r].__typename="SEOMetaTag"})}normalize(e){if(e)return e._seoMetaTags&&this.renameSEOMetaTags(e._seoMetaTags),Object.keys(e).forEach(n=>{Array.isArray(e[n])&&(e[n]=e[n].map(r=>this.normalize(r))),e[n]&&typeof e[n]=="object"&&(e[n]=this.normalize(e[n]))}),e}};var C=class{constructor(e,n){this.token="";this.uri="";this.token=e,this.uri=n}renameSEOMetaTags(e){e.forEach(function(n,r,i){i[r].__typename="SEOMetaTag"})}normalize(e){return e&&(e._seoMetaTags&&this.renameSEOMetaTags(e._seoMetaTags),Object.keys(e).forEach(n=>{Array.isArray(e[n])&&(e[n]=e[n].map(r=>this.normalize(r))),e[n]&&typeof e[n]=="object"&&(e[n]=this.normalize(e[n]))}),e)}};0&&(module.exports={ApiError,DatoCMS,Filter,QueenofheartsRenderComponent,QueenofheartsService,StrapiCMS,componentRegistry,fetchDynamicComponents,getAllregisteredComponents,registerComponent,registerLazyComponent,unregisterComponent});
package/lib/index.mjs CHANGED
@@ -1 +1 @@
1
- var D=Object.defineProperty,Q=Object.defineProperties;var k=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var A=(r,e,n)=>e in r?D(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,y=(r,e)=>{for(var n in e||(e={}))F.call(e,n)&&A(r,n,e[n]);if(x)for(var n of x(e))P.call(e,n)&&A(r,n,e[n]);return r},g=(r,e)=>Q(r,k(e));var u=(r,e,n)=>new Promise((t,i)=>{var o=a=>{try{s(n.next(a))}catch(p){i(p)}},c=a=>{try{s(n.throw(a))}catch(p){i(p)}},s=a=>a.done?t(a.value):Promise.resolve(a.value).then(o,c);s((n=n.apply(r,e)).next())});import{Suspense as T}from"react";import{jsx as b}from"react/jsx-runtime";function ne(r){let e=h.getInstance(),{data:n,contextProps:t}=r;return n&&e?Array.isArray(n)?b(T,{fallback:null,children:n.map((i,o)=>e.createComponent({data:i,contextProps:t}))}):b(T,{fallback:null,children:e.createComponent({data:n,contextProps:t})}):e?b("div",{className:"error",children:"QueenofheartsRenderComponent: Invalid data received."}):b("div",{children:"QueenofheartsService is not initialized"})}var m=class extends Error{constructor(e,n){super(n.summary),this.name="ApiError",this.status=e,this.body=n}};import J,{lazy as N}from"react";import*as f from"react";import{jsx as l,jsxs as w}from"react/jsx-runtime";var $=({children:r,style:e})=>l("details",{style:e,children:r}),L=({children:r})=>l("summary",{children:r}),M=({children:r})=>l("div",{style:{paddingLeft:"1em"},children:r}),q=({children:r,style:e})=>l("div",{style:g(y({},e),{border:"1px solid #ccc",padding:".5em"}),children:r}),z=()=>l("span",{children:"\u25BC"}),j=f.lazy(()=>import("@mui/material/Accordion").catch(()=>({default:$}))),R=f.lazy(()=>import("@mui/material/AccordionSummary").catch(()=>({default:L}))),I=f.lazy(()=>import("@mui/material/AccordionDetails").catch(()=>({default:M}))),B=f.lazy(()=>import("@mui/material/Paper").catch(()=>({default:q}))),_=f.lazy(()=>import("@mui/icons-material/ExpandMore").catch(()=>({default:z})));function H(r,e,n){return w(j,{style:{width:"100%"},children:[w(R,{style:{padding:0},expandIcon:l(_,{}),children:[r,": Array[",e.length,"]"]}),l(I,{children:e.map((t,i)=>v("",t,i))})]},`${r}_${n}`)}function U(r,e,n){return w(j,{style:{width:"100%"},children:[l(R,{expandIcon:l(_,{}),children:r}),l(I,{children:Object.entries(e).map((t,i)=>v(t[0],t[1],i))})]},`${r}_${n}`)}function O(r,e,n){return w("div",{children:[r,": ",`${e}`]},`${r}_${n}`)}function v(r,e,n){var i;if(Array.isArray(e))return H(r,e,n);if(!e||["string","number"].includes(typeof e))return O(r,e,n);if(typeof e=="boolean")return O(r,e?"true":"false",n);let t=`${r?r+": ":""}${(i=e.__typename)!=null?i:"object"}`;return U(t,e,n)}function S(r){return typeof r.data=="object"?l(f.Suspense,{fallback:l(q,{style:{margin:".5em",width:"calc(100% - 1em)"},children:v("",r.data,1)}),children:l(B,{style:{margin:".5em",width:"calc(100% - 1em)"},children:v("",r.data,1)})}):null}var X=(i=>(i.eq="eq",i.in="in",i.neq="neq",i.notIn="notIn",i))(X||{}),W="https://headless.li/api",d={};function me(r){delete d[r]}function fe(r,e,n,t){if(e!==void 0&&(t||d[e]===void 0)){let i={component:r,fieldNames:n};d[e]=i}}function pe(r,e,n,t=!1){e?(t||d[e]===void 0)&&(d[e]={fieldNames:n,loader:r}):console.warn("registerComponent failed: undefined typeName ")}function G(){return d}var ye=r=>u(null,null,function*(){let e=h.getInstance(),n=e.findComponentsInProps(r).filter((i,o,c)=>c.indexOf(i)===o);return(yield e.fetchDynamicComponents(n)).filter(i=>i!==null)}),h=class r{constructor(e,n){this.latestUrl="";this.latestData={};this.findComponentsInProps=e=>{if(e&&typeof e!="string"){let n=e.__typename?[e.__typename]:[],t=Array.isArray(e)?e:Object.values(e);return[...n,...t.reduce((o,c)=>{let s=this.findComponentsInProps(c);return s&&(o=[...o,...s]),o},[])]}return[]};this.fetchDynamicComponents=e=>u(this,null,function*(){let n=!1,t=!1,i=Promise.all(e.map(o=>u(this,null,function*(){var c;return d[o]&&d[o].component===void 0?(n=!0,yield this.loadAsyncComponent(o)):(c=d[o])!=null&&c.loader?o:null})));return t=!0,i});this.buildUrl=e=>{var t;return`${(t=this.localServer)!=null?t:W}/${e}`};this.queryGraphql=e=>u(this,null,function*(){let n=this.buildUrl("execGraphqlQuery");if(console.info(`using url : ${n}`),n){let t=yield fetch(n,{method:"POST",headers:{Authorization:`Bearer ${this.apiToken}`,"Content-Type":"application/json"},body:JSON.stringify({query:e})});if(t.ok){let i=yield t.json();return this.sendDebugEvent(),i}else{let i=yield t.json();throw console.log(i),new m(t.status,i)}}throw new m(500,{id:"99",summary:"queryUrl was not set",details:`LocalServer: ${this.localServer}`})});this.query=(e,n)=>u(this,null,function*(){var o,c;let t=this.buildUrl("execQuery"),i=n!=null&&n.variables?y({},n.variables):{};if(n!=null&&n.locale&&(i.locale=n.locale),n!=null&&n.filter&&Array.isArray(n.filter)&&(i.filter||(i.filter=[]),i.filter.push(...n.filter),(o=n==null?void 0:n.variables)!=null&&o.filter&&Array.isArray(n.variables.filter)&&i.filter.push(...n.variables.filter)),t&&n){let s=yield fetch(t,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiToken}`},method:"POST",credentials:"include",body:JSON.stringify({queryname:e,variables:i,components:this.getRegisteredComponentsWithFields(),ignoreProperties:n.ignoreProperties,depth:n.depth})});if(s.ok){let a=(c=yield s.json())==null?void 0:c.data,p=this.debug?this.injectIds(a):a;return this.latestData=p,this.sendDebugEvent(),p}else try{let a=yield s.json();throw console.log(a),new m(s.status,a)}catch(a){throw new m(s.status,a.toString())}}else throw new m(500,{id:"99",summary:`Query: queryUrl (${t}) or options are invalid`,details:`queryUrl: ${t}`})});this.getRegisteredComponentsWithFields=()=>{let e={},n=Object.entries(G());return n&&Array.isArray(n)&&n.forEach(([t,i])=>{let o={},c=i.fieldNames,s=!1;c&&Array.isArray(c)&&c.forEach(a=>{o[a]=!0,s=!0}),s?e[t]=o:e[t]={__all:!0}}),e};this.getQueries=()=>u(this,null,function*(){let e=this.buildUrl("queries");if(e){let n=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json"}});if(n.ok)try{return yield n.json()}catch(t){console.error(t)}}else console.error("api, uri and CMSToken have to be provided");return""});this.apiToken=e,this.localServer=n,this.debug=typeof document!="undefined"&&document.getElementsByTagName("body")[0].classList.contains("qoh-inject-ids"),this.debug&&typeof globalThis.window!="undefined"&&(globalThis.window.addEventListener("QueenOfHearts-RequestData",()=>{this.sendDebugEvent()}),globalThis.window.addEventListener("QueenOfHearts-RequestQueries",()=>{this.sendQueriesEvent()}),globalThis.window.addEventListener("QueenOfHearts-HighlightComponent",(t=>{this.highlightComponent(t.detail)})),globalThis.window.addEventListener("QueenOfHearts-RequestComponentHTML",(t=>{this.sendComponentHTML(t.detail)})))}static init(e,n){r.instance=new r(e,n)}static getInstance(){return r.instance||console.error("QueenofheartsService was not initialized using QueenofheartsService.init(backend, apiToken)"),r.instance}loadAsyncComponent(e){return u(this,null,function*(){let n=d[e];if(n&&n.component===void 0){if(!(n!=null&&n.component)&&n.loader){let t=n.loader,i=yield t();i?d[e].component=i.default:(console.error(`error loading ${e}`),console.error(i))}return e}return null})}createComponent(e){var s;let{data:n,contextProps:t={}}=e,i=n.__typename,o=d[i];o&&o.loader&&N(o.loader);let c=(s=o==null?void 0:o.component)!=null?s:S;return J.createElement(c,g(y({},n),{contextProps:t}))}injectIds(e){if(Array.isArray(e))e.forEach(n=>this.injectIds(n));else if(e&&typeof e=="object"){if(e.hasOwnProperty("__typename")){let n=Math.random().toString();e.__qohId=n.substr(n.indexOf(".")+1)}Object.keys(e).forEach(n=>e[n]=this.injectIds(e[n]))}return e}sendDebugEvent(){if(typeof window=="undefined")return;let e={registeredComponents:Object.keys(d),url:this.latestUrl,data:this.latestData},n=new CustomEvent("QueenOfHearts-DebuggingData",{detail:e});window.dispatchEvent(n)}sendQueriesEvent(){return u(this,null,function*(){if(typeof window=="undefined")return;let e=new CustomEvent("QueenOfHearts-AvailableQueries",{detail:yield this.getQueries()});window.dispatchEvent(e)})}sendComponentHTML(e){var t;if(typeof window=="undefined")return;let n=(t=document.querySelector(`[qohId='${e}']`))==null?void 0:t.nextElementSibling;if(n){let i=new CustomEvent("QueenOfHearts-SelectedComponentHTML",{detail:{qohId:e,html:n.outerHTML}});window.dispatchEvent(i)}}highlightComponent(e){var o;let n=[{outline:"thick auto white"},{outline:"thick auto red"}],t={duration:1e3,iterations:2},i=(o=document.querySelector(`[qohId='${e}']`))==null?void 0:o.nextElementSibling;i&&i.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),i&&i.animate(n,t)}};var C=class{constructor(e){this.token="";this.uri="https://graphql.datocms.com/";this.token=e}renameSEOMetaTags(e){e.forEach(function(n,t,i){i[t].__typename="SEOMetaTag"})}normalize(e){if(e)return e._seoMetaTags&&this.renameSEOMetaTags(e._seoMetaTags),Object.keys(e).forEach(n=>{Array.isArray(e[n])&&(e[n]=e[n].map(t=>this.normalize(t))),e[n]&&typeof e[n]=="object"&&(e[n]=this.normalize(e[n]))}),e}};import V from"dotenv";V.config();var E=class{constructor(e,n){this.token="";this.uri="";this.token=e,this.uri=n}renameSEOMetaTags(e){e.forEach(function(n,t,i){i[t].__typename="SEOMetaTag"})}normalize(e){return e&&(e._seoMetaTags&&this.renameSEOMetaTags(e._seoMetaTags),Object.keys(e).forEach(n=>{Array.isArray(e[n])&&(e[n]=e[n].map(t=>this.normalize(t))),e[n]&&typeof e[n]=="object"&&(e[n]=this.normalize(e[n]))}),e)}};export{m as ApiError,C as DatoCMS,X as Filter,ne as QueenofheartsRenderComponent,h as QueenofheartsService,E as StrapiCMS,d as componentRegistry,ye as fetchDynamicComponents,G as getAllregisteredComponents,fe as registerComponent,pe as registerLazyComponent,me as unregisterComponent};
1
+ var D=Object.defineProperty,Q=Object.defineProperties;var k=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var A=(r,e,n)=>e in r?D(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,y=(r,e)=>{for(var n in e||(e={}))F.call(e,n)&&A(r,n,e[n]);if(x)for(var n of x(e))P.call(e,n)&&A(r,n,e[n]);return r},g=(r,e)=>Q(r,k(e));var u=(r,e,n)=>new Promise((t,i)=>{var o=a=>{try{s(n.next(a))}catch(p){i(p)}},c=a=>{try{s(n.throw(a))}catch(p){i(p)}},s=a=>a.done?t(a.value):Promise.resolve(a.value).then(o,c);s((n=n.apply(r,e)).next())});import{Suspense as T}from"react";import{jsx as b}from"react/jsx-runtime";function ee(r){let e=h.getInstance(),{data:n,contextProps:t}=r;return n&&e?Array.isArray(n)?b(T,{fallback:null,children:n.map((i,o)=>e.createComponent({data:i,contextProps:t}))}):b(T,{fallback:null,children:e.createComponent({data:n,contextProps:t})}):e?b("div",{className:"error",children:"QueenofheartsRenderComponent: Invalid data received."}):b("div",{children:"QueenofheartsService is not initialized"})}var m=class extends Error{constructor(e,n){super(n.summary),this.name="ApiError",this.status=e,this.body=n}};import J,{lazy as N}from"react";import*as f from"react";import{jsx as l,jsxs as w}from"react/jsx-runtime";var $=({children:r,style:e})=>l("details",{style:e,children:r}),L=({children:r})=>l("summary",{children:r}),M=({children:r})=>l("div",{style:{paddingLeft:"1em"},children:r}),q=({children:r,style:e})=>l("div",{style:g(y({},e),{border:"1px solid #ccc",padding:".5em"}),children:r}),z=()=>l("span",{children:"\u25BC"}),j=f.lazy(()=>import("@mui/material/Accordion").catch(()=>({default:$}))),R=f.lazy(()=>import("@mui/material/AccordionSummary").catch(()=>({default:L}))),I=f.lazy(()=>import("@mui/material/AccordionDetails").catch(()=>({default:M}))),B=f.lazy(()=>import("@mui/material/Paper").catch(()=>({default:q}))),_=f.lazy(()=>import("@mui/icons-material/ExpandMore").catch(()=>({default:z})));function H(r,e,n){return w(j,{style:{width:"100%"},children:[w(R,{style:{padding:0},expandIcon:l(_,{}),children:[r,": Array[",e.length,"]"]}),l(I,{children:e.map((t,i)=>v("",t,i))})]},`${r}_${n}`)}function U(r,e,n){return w(j,{style:{width:"100%"},children:[l(R,{expandIcon:l(_,{}),children:r}),l(I,{children:Object.entries(e).map((t,i)=>v(t[0],t[1],i))})]},`${r}_${n}`)}function O(r,e,n){return w("div",{children:[r,": ",`${e}`]},`${r}_${n}`)}function v(r,e,n){var i;if(Array.isArray(e))return H(r,e,n);if(!e||["string","number"].includes(typeof e))return O(r,e,n);if(typeof e=="boolean")return O(r,e?"true":"false",n);let t=`${r?r+": ":""}${(i=e.__typename)!=null?i:"object"}`;return U(t,e,n)}function S(r){return typeof r.data=="object"?l(f.Suspense,{fallback:l(q,{style:{margin:".5em",width:"calc(100% - 1em)"},children:v("",r.data,1)}),children:l(B,{style:{margin:".5em",width:"calc(100% - 1em)"},children:v("",r.data,1)})}):null}var X=(i=>(i.eq="eq",i.in="in",i.neq="neq",i.notIn="notIn",i))(X||{}),W="https://headless.li/api",d={};function ue(r){delete d[r]}function me(r,e,n,t){if(e!==void 0&&(t||d[e]===void 0)){let i={component:r,fieldNames:n};d[e]=i}}function fe(r,e,n,t=!1){e?(t||d[e]===void 0)&&(d[e]={fieldNames:n,loader:r}):console.warn("registerComponent failed: undefined typeName ")}function G(){return d}var pe=r=>u(null,null,function*(){let e=h.getInstance(),n=e.findComponentsInProps(r).filter((i,o,c)=>c.indexOf(i)===o);return(yield e.fetchDynamicComponents(n)).filter(i=>i!==null)}),h=class r{constructor(e,n){this.latestUrl="";this.latestData={};this.findComponentsInProps=e=>{if(e&&typeof e!="string"){let n=e.__typename?[e.__typename]:[],t=Array.isArray(e)?e:Object.values(e);return[...n,...t.reduce((o,c)=>{let s=this.findComponentsInProps(c);return s&&(o=[...o,...s]),o},[])]}return[]};this.fetchDynamicComponents=e=>u(this,null,function*(){let n=!1,t=!1,i=Promise.all(e.map(o=>u(this,null,function*(){var c;return d[o]&&d[o].component===void 0?(n=!0,yield this.loadAsyncComponent(o)):(c=d[o])!=null&&c.loader?o:null})));return t=!0,i});this.buildUrl=e=>{var t;return`${(t=this.localServer)!=null?t:W}/${e}`};this.queryGraphql=e=>u(this,null,function*(){let n=this.buildUrl("execGraphqlQuery");if(console.info(`using url : ${n}`),n){let t=yield fetch(n,{method:"POST",headers:{Authorization:`Bearer ${this.apiToken}`,"Content-Type":"application/json"},body:JSON.stringify({query:e})});if(t.ok){let i=yield t.json();return this.sendDebugEvent(),i}else{let i=yield t.json();throw console.log(i),new m(t.status,i)}}throw new m(500,{id:"99",summary:"queryUrl was not set",details:`LocalServer: ${this.localServer}`})});this.query=(e,n)=>u(this,null,function*(){var o,c;let t=this.buildUrl("execQuery"),i=n!=null&&n.variables?y({},n.variables):{};if(n!=null&&n.locale&&(i.locale=n.locale),n!=null&&n.filter&&Array.isArray(n.filter)&&(i.filter||(i.filter=[]),i.filter.push(...n.filter),(o=n==null?void 0:n.variables)!=null&&o.filter&&Array.isArray(n.variables.filter)&&i.filter.push(...n.variables.filter)),t&&n){let s=yield fetch(t,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiToken}`},method:"POST",credentials:"include",body:JSON.stringify({queryname:e,variables:i,components:this.getRegisteredComponentsWithFields(),ignoreProperties:n.ignoreProperties,depth:n.depth})});if(s.ok){let a=(c=yield s.json())==null?void 0:c.data,p=this.debug?this.injectIds(a):a;return this.latestData=p,this.sendDebugEvent(),p}else try{let a=yield s.json();throw console.log(a),new m(s.status,a)}catch(a){throw new m(s.status,a.toString())}}else throw new m(500,{id:"99",summary:`Query: queryUrl (${t}) or options are invalid`,details:`queryUrl: ${t}`})});this.getRegisteredComponentsWithFields=()=>{let e={},n=Object.entries(G());return n&&Array.isArray(n)&&n.forEach(([t,i])=>{let o={},c=i.fieldNames,s=!1;c&&Array.isArray(c)&&c.forEach(a=>{o[a]=!0,s=!0}),s?e[t]=o:e[t]={__all:!0}}),e};this.getQueries=()=>u(this,null,function*(){let e=this.buildUrl("queries");if(e){let n=yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json"}});if(n.ok)try{return yield n.json()}catch(t){console.error(t)}}else console.error("api, uri and CMSToken have to be provided");return""});this.apiToken=e,this.localServer=n,this.debug=typeof document!="undefined"&&document.getElementsByTagName("body")[0].classList.contains("qoh-inject-ids"),this.debug&&typeof globalThis.window!="undefined"&&(globalThis.window.addEventListener("QueenOfHearts-RequestData",()=>{this.sendDebugEvent()}),globalThis.window.addEventListener("QueenOfHearts-RequestQueries",()=>{this.sendQueriesEvent()}),globalThis.window.addEventListener("QueenOfHearts-HighlightComponent",(t=>{this.highlightComponent(t.detail)})),globalThis.window.addEventListener("QueenOfHearts-RequestComponentHTML",(t=>{this.sendComponentHTML(t.detail)})))}static init(e,n){r.instance=new r(e,n)}static getInstance(){return r.instance||console.error("QueenofheartsService was not initialized using QueenofheartsService.init(backend, apiToken)"),r.instance}loadAsyncComponent(e){return u(this,null,function*(){let n=d[e];if(n&&n.component===void 0){if(!(n!=null&&n.component)&&n.loader){let t=n.loader,i=yield t();i?d[e].component=i.default:(console.error(`error loading ${e}`),console.error(i))}return e}return null})}createComponent(e){var s;let{data:n,contextProps:t={}}=e,i=n.__typename,o=d[i];o&&o.loader&&N(o.loader);let c=(s=o==null?void 0:o.component)!=null?s:S;return J.createElement(c,g(y({},n),{contextProps:t}))}injectIds(e){if(Array.isArray(e))e.forEach(n=>this.injectIds(n));else if(e&&typeof e=="object"){if(e.hasOwnProperty("__typename")){let n=Math.random().toString();e.__qohId=n.substr(n.indexOf(".")+1)}Object.keys(e).forEach(n=>e[n]=this.injectIds(e[n]))}return e}sendDebugEvent(){if(typeof window=="undefined")return;let e={registeredComponents:Object.keys(d),url:this.latestUrl,data:this.latestData},n=new CustomEvent("QueenOfHearts-DebuggingData",{detail:e});window.dispatchEvent(n)}sendQueriesEvent(){return u(this,null,function*(){if(typeof window=="undefined")return;let e=new CustomEvent("QueenOfHearts-AvailableQueries",{detail:yield this.getQueries()});window.dispatchEvent(e)})}sendComponentHTML(e){var t;if(typeof window=="undefined")return;let n=(t=document.querySelector(`[qohId='${e}']`))==null?void 0:t.nextElementSibling;if(n){let i=new CustomEvent("QueenOfHearts-SelectedComponentHTML",{detail:{qohId:e,html:n.outerHTML}});window.dispatchEvent(i)}}highlightComponent(e){var o;let n=[{outline:"thick auto white"},{outline:"thick auto red"}],t={duration:1e3,iterations:2},i=(o=document.querySelector(`[qohId='${e}']`))==null?void 0:o.nextElementSibling;i&&i.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),i&&i.animate(n,t)}};var C=class{constructor(e){this.token="";this.uri="https://graphql.datocms.com/";this.token=e}renameSEOMetaTags(e){e.forEach(function(n,t,i){i[t].__typename="SEOMetaTag"})}normalize(e){if(e)return e._seoMetaTags&&this.renameSEOMetaTags(e._seoMetaTags),Object.keys(e).forEach(n=>{Array.isArray(e[n])&&(e[n]=e[n].map(t=>this.normalize(t))),e[n]&&typeof e[n]=="object"&&(e[n]=this.normalize(e[n]))}),e}};var E=class{constructor(e,n){this.token="";this.uri="";this.token=e,this.uri=n}renameSEOMetaTags(e){e.forEach(function(n,t,i){i[t].__typename="SEOMetaTag"})}normalize(e){return e&&(e._seoMetaTags&&this.renameSEOMetaTags(e._seoMetaTags),Object.keys(e).forEach(n=>{Array.isArray(e[n])&&(e[n]=e[n].map(t=>this.normalize(t))),e[n]&&typeof e[n]=="object"&&(e[n]=this.normalize(e[n]))}),e)}};export{m as ApiError,C as DatoCMS,X as Filter,ee as QueenofheartsRenderComponent,h as QueenofheartsService,E as StrapiCMS,d as componentRegistry,pe as fetchDynamicComponents,G as getAllregisteredComponents,me as registerComponent,fe as registerLazyComponent,ue as unregisterComponent};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qoh/core-react",
3
3
  "description": "Queen of hearts Core React API",
4
- "version": "1.0.0-rc.11",
4
+ "version": "1.0.0-rc.12",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
7
7
  "module": "lib/index.mjs",
@@ -46,8 +46,7 @@
46
46
  "@types/react": "^17.0.0",
47
47
  "@types/react-dom": "^17.0.0",
48
48
  "cross-env": "^7.0.3",
49
- "dotenv": "^16.4.5",
50
- "identity-obj-proxy": "^3.0.0",
49
+ "identity-obj-proxy": "^3.0.0",
51
50
  "jest": "^29.7.0",
52
51
  "next": "^16.2.4",
53
52
  "prettier": "^3.3.3",