@flyo/nitro-astro 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -74,10 +74,12 @@ Entity Detail Example
74
74
  import { EntitiesApi } from '@flyo/nitro-js'
75
75
 
76
76
  const { slug } = Astro.params;
77
- const entity = await new EntitiesApi().entityBySlug(slug);
77
+ const data = await new EntitiesApi().entityBySlug(slug);
78
+ const isProd = import.meta.env.PROD;
78
79
  ---
79
80
  <h1>{ slug }</h1>
80
- <img src={ entity.model.image.source } style="width:100%" />
81
+ <img src={ data.model.image.source } style="width:100%" />
82
+ { isProd && <script is:inline define:vars={{ api: data.entity.entity_metric.api }}>fetch(api)</script> }
81
83
  ```
82
84
 
83
85
  Block Component Example:
@@ -1,12 +1,12 @@
1
- (function(l,h){typeof exports=="object"&&typeof module<"u"?h(exports):typeof define=="function"&&define.amd?define(["exports"],h):(l=typeof globalThis<"u"?globalThis:l||self,h(l.flyoNitroIntegration={}))})(this,function(l){"use strict";const h="https://api.flyo.cloud/nitro/v1".replace(/\/+$/,"");class j{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:h}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||b}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const L=new j,_=class U{constructor(t=L){this.configuration=t,this.fetchApi=async(i,o)=>{let a={url:i,init:o};for(const s of this.middleware)s.pre&&(a=await s.pre({fetch:this.fetchApi,...a})||a);let r;try{r=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(s){for(const u of this.middleware)u.onError&&(r=await u.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:s,response:r?r.clone():void 0})||r);if(r===void 0)throw s instanceof Error?new O(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(r=await s.post({fetch:this.fetchApi,url:a.url,init:a.init,response:r.clone()})||r);return r},this.middleware=t.middleware}withMiddleware(...t){const i=this.clone();return i.middleware=i.middleware.concat(...t),i}withPreMiddleware(...t){const i=t.map(o=>({pre:o}));return this.withMiddleware(...i)}withPostMiddleware(...t){const i=t.map(o=>({post:o}));return this.withMiddleware(...i)}isJsonMime(t){return t?U.jsonRegex.test(t):!1}async request(t,i){const{url:o,init:a}=await this.createFetchParams(t,i),r=await this.fetchApi(o,a);if(r&&r.status>=200&&r.status<300)return r;throw new N(r,"Response returned an error code")}async createFetchParams(t,i){let o=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(o+="?"+this.configuration.queryParamsStringify(t.query));const a=Object.assign({},this.configuration.headers,t.headers);Object.keys(a).forEach(g=>a[g]===void 0?delete a[g]:{});const r=typeof i=="function"?i:async()=>i,s={method:t.method,headers:a,body:t.body,credentials:this.configuration.credentials},u={...s,...await r({init:s,context:t})};let c;K(u.body)||u.body instanceof URLSearchParams||x(u.body)?c=u.body:this.isJsonMime(a["Content-Type"])?c=JSON.stringify(u.body):c=u.body;const d={...u,body:c};return{url:o,init:d}}clone(){const t=this.constructor,i=new t(this.configuration);return i.middleware=this.middleware.slice(),i}};_.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let y=_;function x(e){return typeof Blob<"u"&&e instanceof Blob}function K(e){return typeof FormData<"u"&&e instanceof FormData}class N extends Error{constructor(t,i){super(i),this.response=t,this.name="ResponseError"}}class O extends Error{constructor(t,i){super(i),this.cause=t,this.name="FetchError"}}class v extends Error{constructor(t,i){super(i),this.field=t,this.name="RequiredError"}}function n(e,t){return e[t]!=null}function b(e,t=""){return Object.keys(e).map(i=>q(i,e[i],t)).filter(i=>i.length>0).join("&")}function q(e,t,i=""){const o=i+(i.length?`[${e}]`:e);if(t instanceof Array){const a=t.map(r=>encodeURIComponent(String(r))).join(`&${encodeURIComponent(o)}=`);return`${encodeURIComponent(o)}=${a}`}if(t instanceof Set){const a=Array.from(t);return q(e,a,i)}return t instanceof Date?`${encodeURIComponent(o)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?b(t,o):`${encodeURIComponent(o)}=${encodeURIComponent(String(t))}`}function m(e,t){return Object.keys(e).reduce((i,o)=>({...i,[o]:t(e[o])}),{})}class f{constructor(t,i=o=>o){this.raw=t,this.transformer=i}async value(){return this.transformer(await this.raw.json())}}function $(e){return F(e)}function F(e,t){return e==null?e:{identifier:n(e,"identifier")?e.identifier:void 0,content:n(e,"content")?e.content.map(E):void 0}}function E(e){return M(e)}function M(e,t){return e==null?e:{items:n(e,"items")?e.items:void 0,content:n(e,"content")?e.content:void 0,config:n(e,"config")?e.config:void 0,identifier:n(e,"identifier")?e.identifier:void 0,uid:n(e,"uid")?e.uid:void 0,component:n(e,"component")?e.component:void 0,slots:n(e,"slots")?m(e.slots,$):void 0}}function R(e){return B(e)}function B(e,t){return e==null?e:{type:n(e,"type")?e.type:void 0,target:n(e,"target")?e.target:void 0,label:n(e,"label")?e.label:void 0,href:n(e,"href")?e.href:void 0,slug:n(e,"slug")?e.slug:void 0,properties:n(e,"properties")?e.properties:void 0,children:n(e,"children")?e.children.map(R):void 0}}function D(e){return G(e)}function G(e,t){return e==null?e:{items:n(e,"items")?e.items.map(R):void 0,uid:n(e,"uid")?e.uid:void 0,identifier:n(e,"identifier")?e.identifier:void 0,label:n(e,"label")?e.label:void 0}}function J(e){return V(e)}function V(e,t){return e==null?e:{domain:n(e,"domain")?e.domain:void 0,slug:n(e,"slug")?e.slug:void 0,version:n(e,"version")?e.version:void 0,updated_at:n(e,"updated_at")?e.updated_at:void 0,language:n(e,"language")?e.language:void 0}}function W(e){return z(e)}function z(e,t){return e==null?e:{nitro:n(e,"nitro")?J(e.nitro):void 0,pages:n(e,"pages")?e.pages:void 0,containers:n(e,"containers")?m(e.containers,D):void 0,globals:n(e,"globals")?e.globals:void 0}}function H(e){return X(e)}function X(e,t){return e==null?e:{api:n(e,"api")?e.api:void 0,image:n(e,"image")?e.image:void 0}}function Z(e){return Q(e)}function Q(e,t){return e==null?e:{_version:n(e,"_version")?e._version:void 0,entity_metric:n(e,"entity_metric")?H(e.entity_metric):void 0,entity_unique_id:n(e,"entity_unique_id")?e.entity_unique_id:void 0,entity_id:n(e,"entity_id")?e.entity_id:void 0,entity_image:n(e,"entity_image")?e.entity_image:void 0,entity_slug:n(e,"entity_slug")?e.entity_slug:void 0,entity_teaser:n(e,"entity_teaser")?e.entity_teaser:void 0,entity_time_end:n(e,"entity_time_end")?e.entity_time_end:void 0,entity_time_start:n(e,"entity_time_start")?e.entity_time_start:void 0,entity_title:n(e,"entity_title")?e.entity_title:void 0,entity_type:n(e,"entity_type")?e.entity_type:void 0,entity_type_id:n(e,"entity_type_id")?e.entity_type_id:void 0,updated_at:n(e,"updated_at")?e.updated_at:void 0,routes:n(e,"routes")?e.routes:void 0}}function A(e){return Y(e)}function Y(e,t){return e==null?e:{entity:n(e,"entity")?Z(e.entity):void 0,model:n(e,"model")?e.model:void 0,language:n(e,"language")?e.language:void 0,jsonld:n(e,"jsonld")?e.jsonld:void 0}}function C(e){return ee(e)}function ee(e,t){return e==null?e:{entity_unique_id:n(e,"entity_unique_id")?e.entity_unique_id:void 0,entity_title:n(e,"entity_title")?e.entity_title:void 0,entity_teaser:n(e,"entity_teaser")?e.entity_teaser:void 0,entity_slug:n(e,"entity_slug")?e.entity_slug:void 0,entity_time_start:n(e,"entity_time_start")?e.entity_time_start:void 0,entity_type:n(e,"entity_type")?e.entity_type:void 0,entity_type_id:n(e,"entity_type_id")?e.entity_type_id:void 0,entity_image:n(e,"entity_image")?e.entity_image:void 0,routes:n(e,"routes")?e.routes:void 0}}function te(e){return ie(e)}function ie(e,t){return e==null?e:{description:n(e,"description")?e.description:void 0,image:n(e,"image")?e.image:void 0,title:n(e,"title")?e.title:void 0}}function ne(e){return oe(e)}function oe(e,t){return e==null?e:{slug:n(e,"slug")?e.slug:void 0,title:n(e,"title")?e.title:void 0}}function re(e){return ae(e)}function ae(e,t){return e==null?e:{value:n(e,"value")?e.value:void 0,navigation:n(e,"navigation")?e.navigation:void 0,propagate:n(e,"propagate")?e.propagate:void 0}}function k(e){return se(e)}function se(e,t){return e==null?e:{id:n(e,"id")?e.id:void 0,title:n(e,"title")?e.title:void 0,href:n(e,"href")?e.href:void 0,slug:n(e,"slug")?e.slug:void 0,json:n(e,"json")?e.json.map(E):void 0,depth:n(e,"depth")?e.depth:void 0,is_home:n(e,"is_home")?e.is_home:void 0,created_at:n(e,"created_at")?e.created_at:void 0,updated_at:n(e,"updated_at")?e.updated_at:void 0,is_visible:n(e,"is_visible")?e.is_visible:void 0,meta_json:n(e,"meta_json")?te(e.meta_json):void 0,properties:n(e,"properties")?m(e.properties,re):void 0,uid:n(e,"uid")?e.uid:void 0,type:n(e,"type")?e.type:void 0,target:n(e,"target")?e.target:void 0,container:n(e,"container")?e.container:void 0,breadcrumb:n(e,"breadcrumb")?e.breadcrumb.map(ne):void 0}}function ue(e){return ce(e)}function ce(e,t){return e==null?e:{version:n(e,"version")?e.version:void 0,updated_at:n(e,"updated_at")?e.updated_at:void 0}}class le extends y{async configRaw(t){const i={},o={};this.configuration&&this.configuration.apiKey&&(i.token=this.configuration.apiKey("token"));const a=await this.request({path:"/config",method:"GET",headers:o,query:i},t);return new f(a,r=>W(r))}async config(t){return await(await this.configRaw(t)).value()}}class de extends y{async entityBySlugRaw(t,i){if(t.slug===null||t.slug===void 0)throw new v("slug","Required parameter requestParameters.slug was null or undefined when calling entityBySlug.");const o={};t.typeId!==void 0&&(o.typeId=t.typeId);const a={};this.configuration&&this.configuration.apiKey&&(o.token=this.configuration.apiKey("token"));const r=await this.request({path:"/entities/slug/{slug}".replace("{slug}",encodeURIComponent(String(t.slug))),method:"GET",headers:a,query:o},i);return new f(r,s=>A(s))}async entityBySlug(t,i){return await(await this.entityBySlugRaw(t,i)).value()}async entityByUniqueidRaw(t,i){if(t.uniqueid===null||t.uniqueid===void 0)throw new v("uniqueid","Required parameter requestParameters.uniqueid was null or undefined when calling entityByUniqueid.");const o={},a={};this.configuration&&this.configuration.apiKey&&(o.token=this.configuration.apiKey("token"));const r=await this.request({path:"/entities/uniqueid/{uniqueid}".replace("{uniqueid}",encodeURIComponent(String(t.uniqueid))),method:"GET",headers:a,query:o},i);return new f(r,s=>A(s))}async entityByUniqueid(t,i){return await(await this.entityByUniqueidRaw(t,i)).value()}}class fe extends y{async homeRaw(t){const i={},o={};this.configuration&&this.configuration.apiKey&&(i.token=this.configuration.apiKey("token"));const a=await this.request({path:"/pages/home",method:"GET",headers:o,query:i},t);return new f(a,r=>k(r))}async home(t){return await(await this.homeRaw(t)).value()}async pageRaw(t,i){const o={};t.slug!==void 0&&(o.slug=t.slug);const a={};this.configuration&&this.configuration.apiKey&&(o.token=this.configuration.apiKey("token"));const r=await this.request({path:"/pages",method:"GET",headers:a,query:o},i);return new f(r,s=>k(s))}async page(t={},i){return await(await this.pageRaw(t,i)).value()}}class pe extends y{async searchRaw(t,i){if(t.query===null||t.query===void 0)throw new v("query","Required parameter requestParameters.query was null or undefined when calling search.");const o={};t.query!==void 0&&(o.query=t.query);const a={};this.configuration&&this.configuration.apiKey&&(o.token=this.configuration.apiKey("token"));const r=await this.request({path:"/search",method:"GET",headers:a,query:o},i);return new f(r,s=>s.map(C))}async search(t,i){return await(await this.searchRaw(t,i)).value()}}class ye extends y{async sitemapRaw(t){const i={},o={};this.configuration&&this.configuration.apiKey&&(i.token=this.configuration.apiKey("token"));const a=await this.request({path:"/sitemap",method:"GET",headers:o,query:i},t);return new f(a,r=>r.map(C))}async sitemap(t){return await(await this.sitemapRaw(t)).value()}}class he extends y{async versionRaw(t){const i={},o={};this.configuration&&this.configuration.apiKey&&(i.token=this.configuration.apiKey("token"));const a=await this.request({path:"/version",method:"GET",headers:o,query:i},t);return new f(a,r=>ue(r))}async version(t){return await(await this.versionRaw(t)).value()}}const ge=/[\p{Lu}]/u,ve=/[\p{Ll}]/u,I=/^[\p{Lu}](?![\p{Lu}])/gu,S=/([\p{Alpha}\p{N}_]|$)/u,w=/[_.\- ]+/,me=new RegExp("^"+w.source),T=new RegExp(w.source+S.source,"gu"),P=new RegExp("\\d+"+S.source,"gu"),we=(e,t,i,o)=>{let a=!1,r=!1,s=!1,u=!1;for(let c=0;c<e.length;c++){const d=e[c];u=c>2?e[c-3]==="-":!0,a&&ge.test(d)?(e=e.slice(0,c)+"-"+e.slice(c),a=!1,s=r,r=!0,c++):r&&s&&ve.test(d)&&(!u||o)?(e=e.slice(0,c-1)+"-"+e.slice(c-1),s=r,r=!1,a=!0):(a=t(d)===d&&i(d)!==d,s=r,r=i(d)===d&&t(d)!==d)}return e},_e=(e,t)=>(I.lastIndex=0,e.replace(I,i=>t(i))),be=(e,t)=>(T.lastIndex=0,P.lastIndex=0,e.replace(T,(i,o)=>t(o)).replace(P,i=>t(i)));function qe(e,t){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(e)?e=e.map(r=>r.trim()).filter(r=>r.length).join("-"):e=e.trim(),e.length===0)return"";const i=t.locale===!1?r=>r.toLowerCase():r=>r.toLocaleLowerCase(t.locale),o=t.locale===!1?r=>r.toUpperCase():r=>r.toLocaleUpperCase(t.locale);return e.length===1?w.test(e)?"":t.pascalCase?o(e):i(e):(e!==i(e)&&(e=we(e,i,o,t.preserveConsecutiveUppercase)),e=e.replace(me,""),e=t.preserveConsecutiveUppercase?_e(e,i):i(e),t.pascalCase&&(e=o(e.charAt(0))+e.slice(1)),be(e,o))}function Ee(e,t,i){const o="virtual:flyo-components",a="\0"+o;return{name:"vite-plugin-flyo-components",async resolveId(r){if(r===o)return a},async load(r){if(r===a){const s=[];for(const[c,d]of Object.entries(t)){const g=await this.resolve("/"+e+"/"+d+".astro");g&&s.push(`export { default as ${qe(c)} } from "${g.id}"`)}let u=null;return i&&(u=await this.resolve("/"+e+"/"+i+".astro")),u?s.push(`export { default as fallback } from "${u.id}"`):s.push('export { default as fallback } from "@flyo/nitro-astro/FallbackComponent.astro"'),s.join(";")}}}}function Re(e){const t="virtual:flyo-user-config",i="\0"+t;return{name:"vite-plugin-flyo-components",async resolveId(o){if(o===t)return i},async load(o){if(o===i)return`export default ${JSON.stringify(e)}`}}}function p(){return globalThis.flyoNitroInstance||console.error("The Flyo Typescript Configuration has not been initialized correctly"),globalThis.flyoNitroInstance}function Ae(){return new le(p())}function Ce(){return new de(p())}function ke(){return new fe(p())}function Ie(){return new pe(p())}function Se(){return new ye(p())}function Te(){return new he(p())}function Pe(e){return{"data-flyo-block-uid":e.uid}}function Ue(e){const t={accessToken:!1,liveEdit:!1,fallbackComponent:null,...e};return t.liveEdit==="true"?t.liveEdit=!0:t.liveEdit==="false"&&(t.liveEdit=!1),{name:"@flyo/nitro-astro",hooks:{"astro:config:setup":({injectScript:i,updateConfig:o,injectRoute:a})=>{a({pattern:"sitemap.xml",entrypoint:"@flyo/nitro-astro/sitemap.js"}),o({image:{service:{entrypoint:"@flyo/nitro-astro/cdn.ts"}},vite:{plugins:[Ee(e.componentsDir,e.components,e.fallbackComponent),Re(t)]}}),i("page-ssr",`
1
+ (function(l,h){typeof exports=="object"&&typeof module<"u"?h(exports):typeof define=="function"&&define.amd?define(["exports"],h):(l=typeof globalThis<"u"?globalThis:l||self,h(l.flyoNitroIntegration={}))})(this,function(l){"use strict";const h="https://api.flyo.cloud/nitro/v1".replace(/\/+$/,"");class j{constructor(i={}){this.configuration=i}set config(i){this.configuration=i}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:h}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||b}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const i=this.configuration.apiKey;if(i)return typeof i=="function"?i:()=>i}get accessToken(){const i=this.configuration.accessToken;if(i)return typeof i=="function"?i:async()=>i}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const L=new j,_=class U{constructor(i=L){this.configuration=i,this.fetchApi=async(t,o)=>{let a={url:t,init:o};for(const s of this.middleware)s.pre&&(a=await s.pre({fetch:this.fetchApi,...a})||a);let r;try{r=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(s){for(const u of this.middleware)u.onError&&(r=await u.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:s,response:r?r.clone():void 0})||r);if(r===void 0)throw s instanceof Error?new O(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(r=await s.post({fetch:this.fetchApi,url:a.url,init:a.init,response:r.clone()})||r);return r},this.middleware=i.middleware}withMiddleware(...i){const t=this.clone();return t.middleware=t.middleware.concat(...i),t}withPreMiddleware(...i){const t=i.map(o=>({pre:o}));return this.withMiddleware(...t)}withPostMiddleware(...i){const t=i.map(o=>({post:o}));return this.withMiddleware(...t)}isJsonMime(i){return i?U.jsonRegex.test(i):!1}async request(i,t){const{url:o,init:a}=await this.createFetchParams(i,t),r=await this.fetchApi(o,a);if(r&&r.status>=200&&r.status<300)return r;throw new N(r,"Response returned an error code")}async createFetchParams(i,t){let o=this.configuration.basePath+i.path;i.query!==void 0&&Object.keys(i.query).length!==0&&(o+="?"+this.configuration.queryParamsStringify(i.query));const a=Object.assign({},this.configuration.headers,i.headers);Object.keys(a).forEach(g=>a[g]===void 0?delete a[g]:{});const r=typeof t=="function"?t:async()=>t,s={method:i.method,headers:a,body:i.body,credentials:this.configuration.credentials},u={...s,...await r({init:s,context:i})};let c;K(u.body)||u.body instanceof URLSearchParams||x(u.body)?c=u.body:this.isJsonMime(a["Content-Type"])?c=JSON.stringify(u.body):c=u.body;const d={...u,body:c};return{url:o,init:d}}clone(){const i=this.constructor,t=new i(this.configuration);return t.middleware=this.middleware.slice(),t}};_.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let y=_;function x(e){return typeof Blob<"u"&&e instanceof Blob}function K(e){return typeof FormData<"u"&&e instanceof FormData}class N extends Error{constructor(i,t){super(t),this.response=i,this.name="ResponseError"}}class O extends Error{constructor(i,t){super(t),this.cause=i,this.name="FetchError"}}class v extends Error{constructor(i,t){super(t),this.field=i,this.name="RequiredError"}}function n(e,i){return e[i]!=null}function b(e,i=""){return Object.keys(e).map(t=>q(t,e[t],i)).filter(t=>t.length>0).join("&")}function q(e,i,t=""){const o=t+(t.length?`[${e}]`:e);if(i instanceof Array){const a=i.map(r=>encodeURIComponent(String(r))).join(`&${encodeURIComponent(o)}=`);return`${encodeURIComponent(o)}=${a}`}if(i instanceof Set){const a=Array.from(i);return q(e,a,t)}return i instanceof Date?`${encodeURIComponent(o)}=${encodeURIComponent(i.toISOString())}`:i instanceof Object?b(i,o):`${encodeURIComponent(o)}=${encodeURIComponent(String(i))}`}function m(e,i){return Object.keys(e).reduce((t,o)=>({...t,[o]:i(e[o])}),{})}class f{constructor(i,t=o=>o){this.raw=i,this.transformer=t}async value(){return this.transformer(await this.raw.json())}}function $(e){return F(e)}function F(e,i){return e==null?e:{identifier:n(e,"identifier")?e.identifier:void 0,content:n(e,"content")?e.content.map(E):void 0}}function E(e){return M(e)}function M(e,i){return e==null?e:{items:n(e,"items")?e.items:void 0,content:n(e,"content")?e.content:void 0,config:n(e,"config")?e.config:void 0,identifier:n(e,"identifier")?e.identifier:void 0,uid:n(e,"uid")?e.uid:void 0,component:n(e,"component")?e.component:void 0,slots:n(e,"slots")?m(e.slots,$):void 0}}function R(e){return B(e)}function B(e,i){return e==null?e:{type:n(e,"type")?e.type:void 0,target:n(e,"target")?e.target:void 0,label:n(e,"label")?e.label:void 0,href:n(e,"href")?e.href:void 0,slug:n(e,"slug")?e.slug:void 0,properties:n(e,"properties")?e.properties:void 0,children:n(e,"children")?e.children.map(R):void 0}}function D(e){return G(e)}function G(e,i){return e==null?e:{items:n(e,"items")?e.items.map(R):void 0,uid:n(e,"uid")?e.uid:void 0,identifier:n(e,"identifier")?e.identifier:void 0,label:n(e,"label")?e.label:void 0}}function J(e){return V(e)}function V(e,i){return e==null?e:{domain:n(e,"domain")?e.domain:void 0,slug:n(e,"slug")?e.slug:void 0,version:n(e,"version")?e.version:void 0,updated_at:n(e,"updated_at")?e.updated_at:void 0,language:n(e,"language")?e.language:void 0}}function W(e){return z(e)}function z(e,i){return e==null?e:{nitro:n(e,"nitro")?J(e.nitro):void 0,pages:n(e,"pages")?e.pages:void 0,containers:n(e,"containers")?m(e.containers,D):void 0,globals:n(e,"globals")?e.globals:void 0}}function H(e){return X(e)}function X(e,i){return e==null?e:{api:n(e,"api")?e.api:void 0,image:n(e,"image")?e.image:void 0}}function Z(e){return Q(e)}function Q(e,i){return e==null?e:{_version:n(e,"_version")?e._version:void 0,entity_metric:n(e,"entity_metric")?H(e.entity_metric):void 0,entity_unique_id:n(e,"entity_unique_id")?e.entity_unique_id:void 0,entity_id:n(e,"entity_id")?e.entity_id:void 0,entity_image:n(e,"entity_image")?e.entity_image:void 0,entity_slug:n(e,"entity_slug")?e.entity_slug:void 0,entity_teaser:n(e,"entity_teaser")?e.entity_teaser:void 0,entity_time_end:n(e,"entity_time_end")?e.entity_time_end:void 0,entity_time_start:n(e,"entity_time_start")?e.entity_time_start:void 0,entity_title:n(e,"entity_title")?e.entity_title:void 0,entity_type:n(e,"entity_type")?e.entity_type:void 0,entity_type_id:n(e,"entity_type_id")?e.entity_type_id:void 0,updated_at:n(e,"updated_at")?e.updated_at:void 0,routes:n(e,"routes")?e.routes:void 0}}function C(e){return Y(e)}function Y(e,i){return e==null?e:{entity:n(e,"entity")?Z(e.entity):void 0,model:n(e,"model")?e.model:void 0,language:n(e,"language")?e.language:void 0,jsonld:n(e,"jsonld")?e.jsonld:void 0}}function A(e){return ee(e)}function ee(e,i){return e==null?e:{entity_unique_id:n(e,"entity_unique_id")?e.entity_unique_id:void 0,entity_title:n(e,"entity_title")?e.entity_title:void 0,entity_teaser:n(e,"entity_teaser")?e.entity_teaser:void 0,entity_slug:n(e,"entity_slug")?e.entity_slug:void 0,entity_time_start:n(e,"entity_time_start")?e.entity_time_start:void 0,entity_type:n(e,"entity_type")?e.entity_type:void 0,entity_type_id:n(e,"entity_type_id")?e.entity_type_id:void 0,entity_image:n(e,"entity_image")?e.entity_image:void 0,routes:n(e,"routes")?e.routes:void 0}}function ie(e){return te(e)}function te(e,i){return e==null?e:{description:n(e,"description")?e.description:void 0,image:n(e,"image")?e.image:void 0,title:n(e,"title")?e.title:void 0}}function ne(e){return oe(e)}function oe(e,i){return e==null?e:{slug:n(e,"slug")?e.slug:void 0,title:n(e,"title")?e.title:void 0}}function re(e){return ae(e)}function ae(e,i){return e==null?e:{value:n(e,"value")?e.value:void 0,navigation:n(e,"navigation")?e.navigation:void 0,propagate:n(e,"propagate")?e.propagate:void 0}}function I(e){return se(e)}function se(e,i){return e==null?e:{id:n(e,"id")?e.id:void 0,title:n(e,"title")?e.title:void 0,href:n(e,"href")?e.href:void 0,slug:n(e,"slug")?e.slug:void 0,json:n(e,"json")?e.json.map(E):void 0,depth:n(e,"depth")?e.depth:void 0,is_home:n(e,"is_home")?e.is_home:void 0,created_at:n(e,"created_at")?e.created_at:void 0,updated_at:n(e,"updated_at")?e.updated_at:void 0,is_visible:n(e,"is_visible")?e.is_visible:void 0,meta_json:n(e,"meta_json")?ie(e.meta_json):void 0,properties:n(e,"properties")?m(e.properties,re):void 0,uid:n(e,"uid")?e.uid:void 0,type:n(e,"type")?e.type:void 0,target:n(e,"target")?e.target:void 0,container:n(e,"container")?e.container:void 0,breadcrumb:n(e,"breadcrumb")?e.breadcrumb.map(ne):void 0}}function ue(e){return ce(e)}function ce(e,i){return e==null?e:{version:n(e,"version")?e.version:void 0,updated_at:n(e,"updated_at")?e.updated_at:void 0}}class le extends y{async configRaw(i){const t={},o={};this.configuration&&this.configuration.apiKey&&(t.token=this.configuration.apiKey("token"));const a=await this.request({path:"/config",method:"GET",headers:o,query:t},i);return new f(a,r=>W(r))}async config(i){return await(await this.configRaw(i)).value()}}class de extends y{async entityBySlugRaw(i,t){if(i.slug===null||i.slug===void 0)throw new v("slug","Required parameter requestParameters.slug was null or undefined when calling entityBySlug.");const o={};i.typeId!==void 0&&(o.typeId=i.typeId);const a={};this.configuration&&this.configuration.apiKey&&(o.token=this.configuration.apiKey("token"));const r=await this.request({path:"/entities/slug/{slug}".replace("{slug}",encodeURIComponent(String(i.slug))),method:"GET",headers:a,query:o},t);return new f(r,s=>C(s))}async entityBySlug(i,t){return await(await this.entityBySlugRaw(i,t)).value()}async entityByUniqueidRaw(i,t){if(i.uniqueid===null||i.uniqueid===void 0)throw new v("uniqueid","Required parameter requestParameters.uniqueid was null or undefined when calling entityByUniqueid.");const o={},a={};this.configuration&&this.configuration.apiKey&&(o.token=this.configuration.apiKey("token"));const r=await this.request({path:"/entities/uniqueid/{uniqueid}".replace("{uniqueid}",encodeURIComponent(String(i.uniqueid))),method:"GET",headers:a,query:o},t);return new f(r,s=>C(s))}async entityByUniqueid(i,t){return await(await this.entityByUniqueidRaw(i,t)).value()}}class fe extends y{async homeRaw(i){const t={},o={};this.configuration&&this.configuration.apiKey&&(t.token=this.configuration.apiKey("token"));const a=await this.request({path:"/pages/home",method:"GET",headers:o,query:t},i);return new f(a,r=>I(r))}async home(i){return await(await this.homeRaw(i)).value()}async pageRaw(i,t){const o={};i.slug!==void 0&&(o.slug=i.slug);const a={};this.configuration&&this.configuration.apiKey&&(o.token=this.configuration.apiKey("token"));const r=await this.request({path:"/pages",method:"GET",headers:a,query:o},t);return new f(r,s=>I(s))}async page(i={},t){return await(await this.pageRaw(i,t)).value()}}class pe extends y{async searchRaw(i,t){if(i.query===null||i.query===void 0)throw new v("query","Required parameter requestParameters.query was null or undefined when calling search.");const o={};i.query!==void 0&&(o.query=i.query);const a={};this.configuration&&this.configuration.apiKey&&(o.token=this.configuration.apiKey("token"));const r=await this.request({path:"/search",method:"GET",headers:a,query:o},t);return new f(r,s=>s.map(A))}async search(i,t){return await(await this.searchRaw(i,t)).value()}}class ye extends y{async sitemapRaw(i){const t={},o={};this.configuration&&this.configuration.apiKey&&(t.token=this.configuration.apiKey("token"));const a=await this.request({path:"/sitemap",method:"GET",headers:o,query:t},i);return new f(a,r=>r.map(A))}async sitemap(i){return await(await this.sitemapRaw(i)).value()}}class he extends y{async versionRaw(i){const t={},o={};this.configuration&&this.configuration.apiKey&&(t.token=this.configuration.apiKey("token"));const a=await this.request({path:"/version",method:"GET",headers:o,query:t},i);return new f(a,r=>ue(r))}async version(i){return await(await this.versionRaw(i)).value()}}const ge=/[\p{Lu}]/u,ve=/[\p{Ll}]/u,k=/^[\p{Lu}](?![\p{Lu}])/gu,S=/([\p{Alpha}\p{N}_]|$)/u,w=/[_.\- ]+/,me=new RegExp("^"+w.source),T=new RegExp(w.source+S.source,"gu"),P=new RegExp("\\d+"+S.source,"gu"),we=(e,i,t,o)=>{let a=!1,r=!1,s=!1,u=!1;for(let c=0;c<e.length;c++){const d=e[c];u=c>2?e[c-3]==="-":!0,a&&ge.test(d)?(e=e.slice(0,c)+"-"+e.slice(c),a=!1,s=r,r=!0,c++):r&&s&&ve.test(d)&&(!u||o)?(e=e.slice(0,c-1)+"-"+e.slice(c-1),s=r,r=!1,a=!0):(a=i(d)===d&&t(d)!==d,s=r,r=t(d)===d&&i(d)!==d)}return e},_e=(e,i)=>(k.lastIndex=0,e.replace(k,t=>i(t))),be=(e,i)=>(T.lastIndex=0,P.lastIndex=0,e.replace(T,(t,o)=>i(o)).replace(P,t=>i(t)));function qe(e,i){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(i={pascalCase:!1,preserveConsecutiveUppercase:!1,...i},Array.isArray(e)?e=e.map(r=>r.trim()).filter(r=>r.length).join("-"):e=e.trim(),e.length===0)return"";const t=i.locale===!1?r=>r.toLowerCase():r=>r.toLocaleLowerCase(i.locale),o=i.locale===!1?r=>r.toUpperCase():r=>r.toLocaleUpperCase(i.locale);return e.length===1?w.test(e)?"":i.pascalCase?o(e):t(e):(e!==t(e)&&(e=we(e,t,o,i.preserveConsecutiveUppercase)),e=e.replace(me,""),e=i.preserveConsecutiveUppercase?_e(e,t):t(e),i.pascalCase&&(e=o(e.charAt(0))+e.slice(1)),be(e,o))}function Ee(e,i,t){const o="virtual:flyo-components",a="\0"+o;return{name:"vite-plugin-flyo-components",async resolveId(r){if(r===o)return a},async load(r){if(r===a){const s=[];for(const[c,d]of Object.entries(i)){const g=await this.resolve("/"+e+"/"+d+".astro");g&&s.push(`export { default as ${qe(c)} } from "${g.id}"`)}let u=null;return t&&(u=await this.resolve("/"+e+"/"+t+".astro")),u?s.push(`export { default as fallback } from "${u.id}"`):s.push('export { default as fallback } from "@flyo/nitro-astro/FallbackComponent.astro"'),s.join(";")}}}}function Re(e){const i="virtual:flyo-user-config",t="\0"+i;return{name:"vite-plugin-flyo-user-config",async resolveId(o){if(o===i)return t},async load(o){if(o===t)return`export default ${JSON.stringify(e)}`}}}function p(){return globalThis.flyoNitroInstance||console.error("The Flyo Typescript Configuration has not been initialized correctly"),globalThis.flyoNitroInstance}function Ce(){return new le(p())}function Ae(){return new de(p())}function Ie(){return new fe(p())}function ke(){return new pe(p())}function Se(){return new ye(p())}function Te(){return new he(p())}function Pe(e){return{"data-flyo-block-uid":e.uid}}function Ue(e){const i={accessToken:!1,liveEdit:!1,fallbackComponent:null,...e};return i.liveEdit==="true"?i.liveEdit=!0:i.liveEdit==="false"&&(i.liveEdit=!1),{name:"@flyo/nitro-astro",hooks:{"astro:config:setup":({injectScript:t,updateConfig:o,injectRoute:a})=>{a({pattern:"sitemap.xml",entrypoint:"@flyo/nitro-astro/sitemap.ts"}),o({image:{service:{entrypoint:"@flyo/nitro-astro/cdn.ts"}},vite:{plugins:[Ee(e.componentsDir,e.components,e.fallbackComponent),Re(i)]}}),t("page-ssr",`
2
2
  import { Configuration } from '@flyo/nitro-typescript'
3
3
 
4
4
  var defaultConfig = new Configuration({
5
- apiKey: '${t.accessToken}'
5
+ apiKey: '${i.accessToken}'
6
6
  })
7
7
 
8
8
  globalThis.flyoNitroInstance = defaultConfig;
9
- `),t.liveEdit&&i("page",`
9
+ `),i.liveEdit&&t("page",`
10
10
  window.addEventListener("message", (event) => {
11
11
  if (event.data?.action === 'pageRefresh') {
12
12
  window.location.reload(true);
@@ -32,12 +32,9 @@
32
32
  // Find all elements with the 'data-flyo-block-uid' attribute
33
33
  const elements = document.querySelectorAll('[data-flyo-block-uid]');
34
34
 
35
- // Add a click event listener to each element
36
35
  elements.forEach(element => {
37
36
  element.addEventListener('click', function() {
38
- // On click, alert the value of 'data-flyo-block-uid'
39
- console.log('open', this.getAttribute('data-flyo-block-uid'))
40
37
  openBlockInFlyo(this.getAttribute('data-flyo-block-uid'))
41
38
  });
42
39
  });
43
- `)}}}}l.default=Ue,l.editableBlock=Pe,l.useConfigApi=Ae,l.useConfiguration=p,l.useEntitiesApi=Ce,l.usePagesApi=ke,l.useSearchApi=Ie,l.useSitemapApi=Se,l.useVersionApi=Te,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
40
+ `)}}}}l.default=Ue,l.editableBlock=Pe,l.useConfigApi=Ce,l.useConfiguration=p,l.useEntitiesApi=Ae,l.usePagesApi=Ie,l.useSearchApi=ke,l.useSitemapApi=Se,l.useVersionApi=Te,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -16,7 +16,7 @@ class T {
16
16
  return this.configuration.middleware || [];
17
17
  }
18
18
  get queryParamsStringify() {
19
- return this.configuration.queryParamsStringify || k;
19
+ return this.configuration.queryParamsStringify || C;
20
20
  }
21
21
  get username() {
22
22
  return this.configuration.username;
@@ -166,10 +166,10 @@ class h extends Error {
166
166
  function n(e, t) {
167
167
  return e[t] != null;
168
168
  }
169
- function k(e, t = "") {
170
- return Object.keys(e).map((i) => C(i, e[i], t)).filter((i) => i.length > 0).join("&");
169
+ function C(e, t = "") {
170
+ return Object.keys(e).map((i) => I(i, e[i], t)).filter((i) => i.length > 0).join("&");
171
171
  }
172
- function C(e, t, i = "") {
172
+ function I(e, t, i = "") {
173
173
  const o = i + (i.length ? `[${e}]` : e);
174
174
  if (t instanceof Array) {
175
175
  const a = t.map((r) => encodeURIComponent(String(r))).join(`&${encodeURIComponent(o)}=`);
@@ -177,9 +177,9 @@ function C(e, t, i = "") {
177
177
  }
178
178
  if (t instanceof Set) {
179
179
  const a = Array.from(t);
180
- return C(e, a, i);
180
+ return I(e, a, i);
181
181
  }
182
- return t instanceof Date ? `${encodeURIComponent(o)}=${encodeURIComponent(t.toISOString())}` : t instanceof Object ? k(t, o) : `${encodeURIComponent(o)}=${encodeURIComponent(String(t))}`;
182
+ return t instanceof Date ? `${encodeURIComponent(o)}=${encodeURIComponent(t.toISOString())}` : t instanceof Object ? C(t, o) : `${encodeURIComponent(o)}=${encodeURIComponent(String(t))}`;
183
183
  }
184
184
  function g(e, t) {
185
185
  return Object.keys(e).reduce(
@@ -195,19 +195,19 @@ class d {
195
195
  return this.transformer(await this.raw.json());
196
196
  }
197
197
  }
198
- function O(e) {
199
- return $(e);
198
+ function $(e) {
199
+ return F(e);
200
200
  }
201
- function $(e, t) {
201
+ function F(e, t) {
202
202
  return e == null ? e : {
203
203
  identifier: n(e, "identifier") ? e.identifier : void 0,
204
- content: n(e, "content") ? e.content.map(I) : void 0
204
+ content: n(e, "content") ? e.content.map(k) : void 0
205
205
  };
206
206
  }
207
- function I(e) {
208
- return F(e);
207
+ function k(e) {
208
+ return O(e);
209
209
  }
210
- function F(e, t) {
210
+ function O(e, t) {
211
211
  return e == null ? e : {
212
212
  items: n(e, "items") ? e.items : void 0,
213
213
  content: n(e, "content") ? e.content : void 0,
@@ -215,7 +215,7 @@ function F(e, t) {
215
215
  identifier: n(e, "identifier") ? e.identifier : void 0,
216
216
  uid: n(e, "uid") ? e.uid : void 0,
217
217
  component: n(e, "component") ? e.component : void 0,
218
- slots: n(e, "slots") ? g(e.slots, O) : void 0
218
+ slots: n(e, "slots") ? g(e.slots, $) : void 0
219
219
  };
220
220
  }
221
221
  function A(e) {
@@ -361,7 +361,7 @@ function ae(e, t) {
361
361
  title: n(e, "title") ? e.title : void 0,
362
362
  href: n(e, "href") ? e.href : void 0,
363
363
  slug: n(e, "slug") ? e.slug : void 0,
364
- json: n(e, "json") ? e.json.map(I) : void 0,
364
+ json: n(e, "json") ? e.json.map(k) : void 0,
365
365
  depth: n(e, "depth") ? e.depth : void 0,
366
366
  is_home: n(e, "is_home") ? e.is_home : void 0,
367
367
  created_at: n(e, "created_at") ? e.created_at : void 0,
@@ -633,7 +633,7 @@ function qe(e, t, i) {
633
633
  function Re(e) {
634
634
  const t = "virtual:flyo-user-config", i = "\0" + t;
635
635
  return {
636
- name: "vite-plugin-flyo-components",
636
+ name: "vite-plugin-flyo-user-config",
637
637
  async resolveId(o) {
638
638
  if (o === t)
639
639
  return i;
@@ -650,13 +650,13 @@ function p() {
650
650
  function Ee() {
651
651
  return new ce(p());
652
652
  }
653
- function ke() {
653
+ function Ce() {
654
654
  return new le(p());
655
655
  }
656
- function Ce() {
656
+ function Ie() {
657
657
  return new de(p());
658
658
  }
659
- function Ie() {
659
+ function ke() {
660
660
  return new fe(p());
661
661
  }
662
662
  function Ae() {
@@ -683,7 +683,7 @@ function xe(e) {
683
683
  "astro:config:setup": ({ injectScript: i, updateConfig: o, injectRoute: a }) => {
684
684
  a({
685
685
  pattern: "sitemap.xml",
686
- entrypoint: "@flyo/nitro-astro/sitemap.js"
686
+ entrypoint: "@flyo/nitro-astro/sitemap.ts"
687
687
  }), o({
688
688
  image: {
689
689
  service: {
@@ -739,11 +739,8 @@ function xe(e) {
739
739
  // Find all elements with the 'data-flyo-block-uid' attribute
740
740
  const elements = document.querySelectorAll('[data-flyo-block-uid]');
741
741
 
742
- // Add a click event listener to each element
743
742
  elements.forEach(element => {
744
743
  element.addEventListener('click', function() {
745
- // On click, alert the value of 'data-flyo-block-uid'
746
- console.log('open', this.getAttribute('data-flyo-block-uid'))
747
744
  openBlockInFlyo(this.getAttribute('data-flyo-block-uid'))
748
745
  });
749
746
  });
@@ -758,9 +755,9 @@ export {
758
755
  Ue as editableBlock,
759
756
  Ee as useConfigApi,
760
757
  p as useConfiguration,
761
- ke as useEntitiesApi,
762
- Ce as usePagesApi,
763
- Ie as useSearchApi,
758
+ Ce as useEntitiesApi,
759
+ Ie as usePagesApi,
760
+ ke as useSearchApi,
764
761
  Ae as useSitemapApi,
765
762
  Se as useVersionApi
766
763
  };
package/dist/sitemap.d.ts CHANGED
@@ -1 +1 @@
1
- export function GET(config: any): Promise<Response>;
1
+ export declare function GET(config: any): Promise<Response>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flyo/nitro-astro",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Astro Framework",
5
5
  "main": "./dist/nitro-astro.js",
6
6
  "module": "./dist/nitro-astro.mjs",
@@ -25,14 +25,14 @@
25
25
  "import": "./components/FlyoNitroPage.ts",
26
26
  "require": "./components/FlyoNitroPage.ts"
27
27
  },
28
- "./sitemap.js": "./sitemap.js",
28
+ "./sitemap.ts": "./sitemap.ts",
29
29
  "./cdn.ts": "./cdn.ts"
30
30
  },
31
31
  "type": "module",
32
32
  "files": [
33
33
  "dist",
34
34
  "components",
35
- "sitemap.js",
35
+ "sitemap.ts",
36
36
  "cdn.ts"
37
37
  ],
38
38
  "types": "./dist/index.d.ts",
@@ -43,10 +43,10 @@
43
43
  "build": "vite build"
44
44
  },
45
45
  "devDependencies": {
46
- "astro": "^4.0.2",
47
- "typescript": "5.3.2",
48
- "vite": "^5.0.6",
49
- "vite-plugin-dts": "^3.6.4"
46
+ "astro": "^4.1.3",
47
+ "typescript": "5.3.3",
48
+ "vite": "^5.0.11",
49
+ "vite-plugin-dts": "^3.7.1"
50
50
  },
51
51
  "repository": {
52
52
  "type": "git",
@@ -1,10 +1,10 @@
1
1
  import { useSitemapApi } from "@flyo/nitro-astro"
2
2
 
3
- function buildUrl(path, domain) {
3
+ function buildUrl(path: string, domain: string) {
4
4
  return `${domain.replace(/\/$/, '')}/${path.replace(/^\//, '')}`;
5
5
  }
6
6
 
7
- export async function GET(config) {
7
+ export async function GET(config: any) {
8
8
  const sitemap = await useSitemapApi().sitemap();
9
9
 
10
10
  let xml = '<?xml version="1.0" encoding="UTF-8"?>';