@flyo/nitro-astro 2.0.10 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -56,25 +56,20 @@ import { usePagesApi, useConfig } from "@flyo/nitro-astro";
56
56
  import FlyoNitroPage from "@flyo/nitro-astro/FlyoNitroPage.astro";
57
57
  import MetaInfoPage from "@flyo/nitro-astro/MetaInfoPage.astro";
58
58
 
59
- const { slug } = Astro.params;
60
- const resolveSlug = slug === undefined ? "" : slug;
59
+ const slug = Astro.params.slug ?? "";
61
60
  const config = await useConfig(Astro);
61
+
62
+ if (!config.pages.includes(slug)) {
63
+ throw Astro.redirect("/404", 404);
64
+ }
65
+
62
66
  let page;
63
67
 
64
68
  try {
65
- if (!config.pages.includes(resolveSlug)) {
66
- return new Response("Not Found", {
67
- status: 404,
68
- statusText: "Page Not Found",
69
- });
70
- }
71
-
72
- page = await usePagesApi().page({ slug: resolveSlug });
69
+ const pagesApi = usePagesApi();
70
+ page = await pagesApi.page({ slug });
73
71
  } catch (e) {
74
- return new Response(e.body.name, {
75
- status: 404,
76
- statusText: "Page Not Found",
77
- });
72
+ throw Astro.redirect("/404", 404);
78
73
  }
79
74
  ---
80
75
 
@@ -232,10 +227,17 @@ export default defineConfig({
232
227
  i18n: {
233
228
  defaultLocale: "en",
234
229
  locales: ["en", "fr"],
230
+ routing: {
231
+ prefixDefaultLocale: true,
232
+ redirectToDefaultLocale: false
233
+ }
235
234
  }
236
235
  })
237
236
  ```
238
237
 
238
+ > [!NOTE]
239
+ > Flyo's i18n setup always prefixes the default language, making it essential to configure this in the i18n routing to avoid errors with adapters like Vercel.
240
+
239
241
  All endpoints accept a `lang` parameter to retrieve data in the desired language. The **Nitro Astro** package handles this automatically. However, since the Entity Details page is custom-built, you need to manually pass the language parameter.
240
242
 
241
243
  + For slug-based requests:
@@ -260,4 +262,4 @@ All endpoints accept a `lang` parameter to retrieve data in the desired language
260
262
  │ └── [slug].astro
261
263
  ```
262
264
 
263
- The above structure would be `/de/detail/[slug].astro` and `/fr/detail/[slug].astro`.
265
+ The above structure would be `/de/detail/[slug].astro` and `/fr/detail/[slug].astro`.
@@ -1,4 +1,4 @@
1
- (function(u,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(u=typeof globalThis<"u"?globalThis:u||self,p(u.flyoNitroIntegration={}))})(this,function(u){"use strict";const p="https://api.flyo.cloud/nitro/v1".replace(/\/+$/,"");class P{constructor(n={}){this.configuration=n}set config(n){this.configuration=n}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:p}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||_}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const n=this.configuration.apiKey;if(n)return typeof n=="function"?n:()=>n}get accessToken(){const n=this.configuration.accessToken;if(n)return typeof n=="function"?n:async()=>n}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const x=new P,w=class F{constructor(n=x){this.configuration=n,this.fetchApi=async(t,i)=>{let a={url:t,init:i};for(const r of this.middleware)r.pre&&(a=await r.pre({fetch:this.fetchApi,...a})||a);let o;try{o=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(r){for(const l of this.middleware)l.onError&&(o=await l.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:r,response:o?o.clone():void 0})||o);if(o===void 0)throw r instanceof Error?new N(r,"The request failed and the interceptors did not return an alternative response"):r}for(const r of this.middleware)r.post&&(o=await r.post({fetch:this.fetchApi,url:a.url,init:a.init,response:o.clone()})||o);return o},this.middleware=n.middleware}withMiddleware(...n){const t=this.clone();return t.middleware=t.middleware.concat(...n),t}withPreMiddleware(...n){const t=n.map(i=>({pre:i}));return this.withMiddleware(...t)}withPostMiddleware(...n){const t=n.map(i=>({post:i}));return this.withMiddleware(...t)}isJsonMime(n){return n?F.jsonRegex.test(n):!1}async request(n,t){const{url:i,init:a}=await this.createFetchParams(n,t),o=await this.fetchApi(i,a);if(o&&o.status>=200&&o.status<300)return o;throw new M(o,"Response returned an error code")}async createFetchParams(n,t){let i=this.configuration.basePath+n.path;n.query!==void 0&&Object.keys(n.query).length!==0&&(i+="?"+this.configuration.queryParamsStringify(n.query));const a=Object.assign({},this.configuration.headers,n.headers);Object.keys(a).forEach(h=>a[h]===void 0?delete a[h]:{});const o=typeof t=="function"?t:async()=>t,r={method:n.method,headers:a,body:n.body,credentials:this.configuration.credentials},l={...r,...await o({init:r,context:n})};let s;K(l.body)||l.body instanceof URLSearchParams||$(l.body)?s=l.body:this.isJsonMime(a["Content-Type"])?s=JSON.stringify(l.body):s=l.body;const c={...l,body:s};return{url:i,init:c}}clone(){const n=this.constructor,t=new n(this.configuration);return t.middleware=this.middleware.slice(),t}};w.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let g=w;function $(e){return typeof Blob<"u"&&e instanceof Blob}function K(e){return typeof FormData<"u"&&e instanceof FormData}class M extends Error{constructor(n,t){super(t),this.response=n,this.name="ResponseError"}}class N extends Error{constructor(n,t){super(t),this.cause=n,this.name="FetchError"}}class y extends Error{constructor(n,t){super(t),this.field=n,this.name="RequiredError"}}function _(e,n=""){return Object.keys(e).map(t=>b(t,e[t],n)).filter(t=>t.length>0).join("&")}function b(e,n,t=""){const i=t+(t.length?`[${e}]`:e);if(n instanceof Array){const a=n.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(i)}=`);return`${encodeURIComponent(i)}=${a}`}if(n instanceof Set){const a=Array.from(n);return b(e,a,t)}return n instanceof Date?`${encodeURIComponent(i)}=${encodeURIComponent(n.toISOString())}`:n instanceof Object?_(n,i):`${encodeURIComponent(i)}=${encodeURIComponent(String(n))}`}function v(e,n){return Object.keys(e).reduce((t,i)=>({...t,[i]:n(e[i])}),{})}class d{constructor(n,t=i=>i){this.raw=n,this.transformer=t}async value(){return this.transformer(await this.raw.json())}}function B(e){return O(e)}function O(e,n){return e==null?e:{identifier:e.identifier==null?void 0:e.identifier,content:e.content==null?void 0:e.content.map(C)}}function C(e){return D(e)}function D(e,n){return e==null?e:{items:e.items==null?void 0:e.items,content:e.content==null?void 0:e.content,config:e.config==null?void 0:e.config,identifier:e.identifier==null?void 0:e.identifier,uid:e.uid==null?void 0:e.uid,component:e.component==null?void 0:e.component,slots:e.slots==null?void 0:v(e.slots,B)}}function E(e){return G(e)}function G(e,n){return e==null?e:{slug:e.slug==null?void 0:e.slug,title:e.title==null?void 0:e.title,href:e.href==null?void 0:e.href}}function q(e){return H(e)}function H(e,n){return e==null?e:{type:e.type==null?void 0:e.type,target:e.target==null?void 0:e.target,label:e.label==null?void 0:e.label,href:e.href==null?void 0:e.href,slug:e.slug==null?void 0:e.slug,properties:e.properties==null?void 0:e.properties,children:e.children==null?void 0:e.children.map(q)}}function z(e){return V(e)}function V(e,n){return e==null?e:{items:e.items==null?void 0:e.items.map(q),uid:e.uid==null?void 0:e.uid,identifier:e.identifier==null?void 0:e.identifier,label:e.label==null?void 0:e.label}}function J(e){return W(e)}function W(e,n){return e==null?e:{domain:e.domain==null?void 0:e.domain,slug:e.slug==null?void 0:e.slug,version:e.version==null?void 0:e.version,updated_at:e.updated_at==null?void 0:e.updated_at,language:e.language==null?void 0:e.language,primary_language:e.primary_language==null?void 0:e.primary_language}}function Q(e){return X(e)}function X(e,n){return e==null?e:{nitro:e.nitro==null?void 0:J(e.nitro),pages:e.pages==null?void 0:e.pages,containers:e.containers==null?void 0:v(e.containers,z),globals:e.globals==null?void 0:e.globals}}function Y(e){return Z(e)}function Z(e,n){return e==null?e:{api:e.api==null?void 0:e.api,image:e.image==null?void 0:e.image}}function ee(e){return ne(e)}function ne(e,n){return e==null?e:{_version:e._version==null?void 0:e._version,entity_metric:e.entity_metric==null?void 0:Y(e.entity_metric),entity_unique_id:e.entity_unique_id==null?void 0:e.entity_unique_id,entity_id:e.entity_id==null?void 0:e.entity_id,entity_image:e.entity_image==null?void 0:e.entity_image,entity_slug:e.entity_slug==null?void 0:e.entity_slug,entity_teaser:e.entity_teaser==null?void 0:e.entity_teaser,entity_time_end:e.entity_time_end==null?void 0:e.entity_time_end,entity_time_start:e.entity_time_start==null?void 0:e.entity_time_start,entity_title:e.entity_title==null?void 0:e.entity_title,entity_type:e.entity_type==null?void 0:e.entity_type,entity_type_id:e.entity_type_id==null?void 0:e.entity_type_id,updated_at:e.updated_at==null?void 0:e.updated_at,routes:e.routes==null?void 0:e.routes}}function te(e){return ie(e)}function ie(e,n){return e==null?e:{shortcode:e.shortcode==null?void 0:e.shortcode,name:e.name==null?void 0:e.name}}function R(e){return oe(e)}function oe(e,n){return e==null?e:{language:e.language==null?void 0:te(e.language),slug:e.slug==null?void 0:e.slug,title:e.title==null?void 0:e.title,href:e.href==null?void 0:e.href}}function A(e){return ae(e)}function ae(e,n){return e==null?e:{entity:e.entity==null?void 0:ee(e.entity),model:e.model==null?void 0:e.model,language:e.language==null?void 0:e.language,jsonld:e.jsonld==null?void 0:e.jsonld,translation:e.translation==null?void 0:e.translation.map(R),breadcrumb:e.breadcrumb==null?void 0:e.breadcrumb.map(E)}}function I(e){return re(e)}function re(e,n){return e==null?e:{entity_unique_id:e.entity_unique_id==null?void 0:e.entity_unique_id,entity_title:e.entity_title==null?void 0:e.entity_title,entity_teaser:e.entity_teaser==null?void 0:e.entity_teaser,entity_slug:e.entity_slug==null?void 0:e.entity_slug,entity_time_start:e.entity_time_start==null?void 0:e.entity_time_start,entity_type:e.entity_type==null?void 0:e.entity_type,entity_type_id:e.entity_type_id==null?void 0:e.entity_type_id,entity_image:e.entity_image==null?void 0:e.entity_image,routes:e.routes==null?void 0:e.routes}}function le(e){return se(e)}function se(e,n){return e==null?e:{description:e.description==null?void 0:e.description,image:e.image==null?void 0:e.image,title:e.title==null?void 0:e.title}}function ue(e){return ce(e)}function ce(e,n){return e==null?e:{value:e.value==null?void 0:e.value,navigation:e.navigation==null?void 0:e.navigation,propagate:e.propagate==null?void 0:e.propagate}}function k(e){return de(e)}function de(e,n){return e==null?e:{id:e.id==null?void 0:e.id,title:e.title==null?void 0:e.title,href:e.href==null?void 0:e.href,slug:e.slug==null?void 0:e.slug,json:e.json==null?void 0:e.json.map(C),depth:e.depth==null?void 0:e.depth,is_home:e.is_home==null?void 0:e.is_home,created_at:e.created_at==null?void 0:e.created_at,updated_at:e.updated_at==null?void 0:e.updated_at,is_visible:e.is_visible==null?void 0:e.is_visible,meta_json:e.meta_json==null?void 0:le(e.meta_json),properties:e.properties==null?void 0:v(e.properties,ue),uid:e.uid==null?void 0:e.uid,type:e.type==null?void 0:e.type,target:e.target==null?void 0:e.target,container:e.container==null?void 0:e.container,breadcrumb:e.breadcrumb==null?void 0:e.breadcrumb.map(E),translation:e.translation==null?void 0:e.translation.map(R)}}function fe(e){return ge(e)}function ge(e,n){return e==null?e:{version:e.version==null?void 0:e.version,updated_at:e.updated_at==null?void 0:e.updated_at}}class pe extends g{async configRaw(n,t){const i={};n.lang!=null&&(i.lang=n.lang);const a={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/config",method:"GET",headers:a,query:i},t);return new d(o,r=>Q(r))}async config(n={},t){return await(await this.configRaw(n,t)).value()}}class he extends g{async entityBySlugRaw(n,t){if(n.slug==null)throw new y("slug",'Required parameter "slug" was null or undefined when calling entityBySlug().');const i={};n.typeId!=null&&(i.typeId=n.typeId),n.lang!=null&&(i.lang=n.lang);const a={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/entities/slug/{slug}".replace("{slug}",encodeURIComponent(String(n.slug))),method:"GET",headers:a,query:i},t);return new d(o,r=>A(r))}async entityBySlug(n,t){return await(await this.entityBySlugRaw(n,t)).value()}async entityByUniqueidRaw(n,t){if(n.uniqueid==null)throw new y("uniqueid",'Required parameter "uniqueid" was null or undefined when calling entityByUniqueid().');const i={};n.lang!=null&&(i.lang=n.lang);const a={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/entities/uniqueid/{uniqueid}".replace("{uniqueid}",encodeURIComponent(String(n.uniqueid))),method:"GET",headers:a,query:i},t);return new d(o,r=>A(r))}async entityByUniqueid(n,t){return await(await this.entityByUniqueidRaw(n,t)).value()}}class ye extends g{async homeRaw(n,t){const i={};n.lang!=null&&(i.lang=n.lang);const a={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/pages/home",method:"GET",headers:a,query:i},t);return new d(o,r=>k(r))}async home(n={},t){return await(await this.homeRaw(n,t)).value()}async pageRaw(n,t){const i={};n.slug!=null&&(i.slug=n.slug),n.lang!=null&&(i.lang=n.lang);const a={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/pages",method:"GET",headers:a,query:i},t);return new d(o,r=>k(r))}async page(n={},t){return await(await this.pageRaw(n,t)).value()}}class ve extends g{async searchRaw(n,t){if(n.query==null)throw new y("query",'Required parameter "query" was null or undefined when calling search().');const i={};n.query!=null&&(i.query=n.query),n.lang!=null&&(i.lang=n.lang);const a={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/search",method:"GET",headers:a,query:i},t);return new d(o,r=>r.map(I))}async search(n,t){return await(await this.searchRaw(n,t)).value()}}class me extends g{async sitemapRaw(n,t){const i={};n.lang!=null&&(i.lang=n.lang);const a={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/sitemap",method:"GET",headers:a,query:i},t);return new d(o,r=>r.map(I))}async sitemap(n={},t){return await(await this.sitemapRaw(n,t)).value()}}class we extends g{async versionRaw(n,t){const i={};n.lang!=null&&(i.lang=n.lang);const a={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/version",method:"GET",headers:a,query:i},t);return new d(o,r=>fe(r))}async version(n={},t){return await(await this.versionRaw(n,t)).value()}}const _e=/[\p{Lu}]/u,be=/[\p{Ll}]/u,T=/^[\p{Lu}](?![\p{Lu}])/gu,S=/([\p{Alpha}\p{N}_]|$)/u,m=/[_.\- ]+/,Ce=new RegExp("^"+m.source),U=new RegExp(m.source+S.source,"gu"),j=new RegExp("\\d+"+S.source,"gu"),Ee=(e,n,t,i)=>{let a=!1,o=!1,r=!1,l=!1;for(let s=0;s<e.length;s++){const c=e[s];l=s>2?e[s-3]==="-":!0,a&&_e.test(c)?(e=e.slice(0,s)+"-"+e.slice(s),a=!1,r=o,o=!0,s++):o&&r&&be.test(c)&&(!l||i)?(e=e.slice(0,s-1)+"-"+e.slice(s-1),r=o,o=!1,a=!0):(a=n(c)===c&&t(c)!==c,r=o,o=t(c)===c&&n(c)!==c)}return e},qe=(e,n)=>(T.lastIndex=0,e.replaceAll(T,t=>n(t))),Re=(e,n)=>(U.lastIndex=0,j.lastIndex=0,e.replaceAll(j,(t,i,a)=>["_","-"].includes(e.charAt(a+t.length))?t:n(t)).replaceAll(U,(t,i)=>n(i)));function Ae(e,n){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(n={pascalCase:!1,preserveConsecutiveUppercase:!1,...n},Array.isArray(e)?e=e.map(o=>o.trim()).filter(o=>o.length).join("-"):e=e.trim(),e.length===0)return"";const t=n.locale===!1?o=>o.toLowerCase():o=>o.toLocaleLowerCase(n.locale),i=n.locale===!1?o=>o.toUpperCase():o=>o.toLocaleUpperCase(n.locale);return e.length===1?m.test(e)?"":n.pascalCase?i(e):t(e):(e!==t(e)&&(e=Ee(e,t,i,n.preserveConsecutiveUppercase)),e=e.replace(Ce,""),e=n.preserveConsecutiveUppercase?qe(e,t):t(e),n.pascalCase&&(e=i(e.charAt(0))+e.slice(1)),Re(e,i))}function Ie(e,n,t){const i="virtual:flyo-components",a="\0"+i;return{name:"vite-plugin-flyo-components",async resolveId(o){if(o===i)return a},async load(o){if(o===a){const r=[];for(const[s,c]of Object.entries(n)){const h=await this.resolve("/"+e+"/"+c+".astro");h&&r.push(`export { default as ${Ae(s)} } from "${h.id}"`)}let l=null;return t&&(l=await this.resolve("/"+e+"/"+t+".astro")),l?r.push(`export { default as fallback } from "${l.id}"`):r.push('export { default as fallback } from "@flyo/nitro-astro/FallbackComponent.astro"'),r.join(";")}}}}function L(){return globalThis.flyoNitroInstance||console.error("The Flyo Typescript Configuration has not been initialized correctly"),globalThis.flyoNitroInstance}function f(){return L().config}async function ke(e){return await e.locals.config}function Te(){return new pe(f())}function Se(){return new he(f())}function Ue(){return new ye(f())}function je(){return new ve(f())}function Le(){return new me(f())}function Fe(){return new we(f())}function Pe(e){return{"data-flyo-block-uid":e.uid}}const xe=`
1
+ (function(u,h){typeof exports=="object"&&typeof module<"u"?h(exports):typeof define=="function"&&define.amd?define(["exports"],h):(u=typeof globalThis<"u"?globalThis:u||self,h(u.flyoNitroIntegration={}))})(this,function(u){"use strict";const h="https://api.flyo.cloud/nitro/v1".replace(/\/+$/,"");class F{constructor(n={}){this.configuration=n}set config(n){this.configuration=n}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||_}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const n=this.configuration.apiKey;if(n)return typeof n=="function"?n:()=>n}get accessToken(){const n=this.configuration.accessToken;if(n)return typeof n=="function"?n:async()=>n}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const x=new F,w=class P{constructor(n=x){this.configuration=n,this.fetchApi=async(t,i)=>{let r={url:t,init:i};for(const a of this.middleware)a.pre&&(r=await a.pre({fetch:this.fetchApi,...r})||r);let o;try{o=await(this.configuration.fetchApi||fetch)(r.url,r.init)}catch(a){for(const l of this.middleware)l.onError&&(o=await l.onError({fetch:this.fetchApi,url:r.url,init:r.init,error:a,response:o?o.clone():void 0})||o);if(o===void 0)throw a instanceof Error?new N(a,"The request failed and the interceptors did not return an alternative response"):a}for(const a of this.middleware)a.post&&(o=await a.post({fetch:this.fetchApi,url:r.url,init:r.init,response:o.clone()})||o);return o},this.middleware=n.middleware}withMiddleware(...n){const t=this.clone();return t.middleware=t.middleware.concat(...n),t}withPreMiddleware(...n){const t=n.map(i=>({pre:i}));return this.withMiddleware(...t)}withPostMiddleware(...n){const t=n.map(i=>({post:i}));return this.withMiddleware(...t)}isJsonMime(n){return n?P.jsonRegex.test(n):!1}async request(n,t){const{url:i,init:r}=await this.createFetchParams(n,t),o=await this.fetchApi(i,r);if(o&&o.status>=200&&o.status<300)return o;throw new M(o,"Response returned an error code")}async createFetchParams(n,t){let i=this.configuration.basePath+n.path;n.query!==void 0&&Object.keys(n.query).length!==0&&(i+="?"+this.configuration.queryParamsStringify(n.query));const r=Object.assign({},this.configuration.headers,n.headers);Object.keys(r).forEach(p=>r[p]===void 0?delete r[p]:{});const o=typeof t=="function"?t:async()=>t,a={method:n.method,headers:r,body:n.body,credentials:this.configuration.credentials},l={...a,...await o({init:a,context:n})};let s;K(l.body)||l.body instanceof URLSearchParams||$(l.body)?s=l.body:this.isJsonMime(r["Content-Type"])?s=JSON.stringify(l.body):s=l.body;const c={...l,body:s};return{url:i,init:c}}clone(){const n=this.constructor,t=new n(this.configuration);return t.middleware=this.middleware.slice(),t}};w.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let g=w;function $(e){return typeof Blob<"u"&&e instanceof Blob}function K(e){return typeof FormData<"u"&&e instanceof FormData}class M extends Error{constructor(n,t){super(t),this.response=n,this.name="ResponseError"}}class N extends Error{constructor(n,t){super(t),this.cause=n,this.name="FetchError"}}class y extends Error{constructor(n,t){super(t),this.field=n,this.name="RequiredError"}}function _(e,n=""){return Object.keys(e).map(t=>b(t,e[t],n)).filter(t=>t.length>0).join("&")}function b(e,n,t=""){const i=t+(t.length?`[${e}]`:e);if(n instanceof Array){const r=n.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(i)}=`);return`${encodeURIComponent(i)}=${r}`}if(n instanceof Set){const r=Array.from(n);return b(e,r,t)}return n instanceof Date?`${encodeURIComponent(i)}=${encodeURIComponent(n.toISOString())}`:n instanceof Object?_(n,i):`${encodeURIComponent(i)}=${encodeURIComponent(String(n))}`}function v(e,n){return Object.keys(e).reduce((t,i)=>({...t,[i]:n(e[i])}),{})}class d{constructor(n,t=i=>i){this.raw=n,this.transformer=t}async value(){return this.transformer(await this.raw.json())}}function O(e){return B(e)}function B(e,n){return e==null?e:{identifier:e.identifier==null?void 0:e.identifier,content:e.content==null?void 0:e.content.map(C)}}function C(e){return D(e)}function D(e,n){return e==null?e:{items:e.items==null?void 0:e.items,content:e.content==null?void 0:e.content,config:e.config==null?void 0:e.config,identifier:e.identifier==null?void 0:e.identifier,uid:e.uid==null?void 0:e.uid,component:e.component==null?void 0:e.component,slots:e.slots==null?void 0:v(e.slots,O)}}function E(e){return G(e)}function G(e,n){return e==null?e:{slug:e.slug==null?void 0:e.slug,title:e.title==null?void 0:e.title,href:e.href==null?void 0:e.href}}function q(e){return H(e)}function H(e,n){return e==null?e:{type:e.type==null?void 0:e.type,target:e.target==null?void 0:e.target,label:e.label==null?void 0:e.label,href:e.href==null?void 0:e.href,slug:e.slug==null?void 0:e.slug,properties:e.properties==null?void 0:e.properties,children:e.children==null?void 0:e.children.map(q)}}function z(e){return V(e)}function V(e,n){return e==null?e:{items:e.items==null?void 0:e.items.map(q),uid:e.uid==null?void 0:e.uid,identifier:e.identifier==null?void 0:e.identifier,label:e.label==null?void 0:e.label}}function W(e){return J(e)}function J(e,n){return e==null?e:{domain:e.domain==null?void 0:e.domain,slug:e.slug==null?void 0:e.slug,version:e.version==null?void 0:e.version,updated_at:e.updated_at==null?void 0:e.updated_at,language:e.language==null?void 0:e.language,primary_language:e.primary_language==null?void 0:e.primary_language}}function Q(e){return X(e)}function X(e,n){return e==null?e:{nitro:e.nitro==null?void 0:W(e.nitro),pages:e.pages==null?void 0:e.pages,containers:e.containers==null?void 0:v(e.containers,z),globals:e.globals==null?void 0:e.globals}}function Y(e){return Z(e)}function Z(e,n){return e==null?e:{api:e.api==null?void 0:e.api,image:e.image==null?void 0:e.image}}function ee(e){return ne(e)}function ne(e,n){return e==null?e:{_version:e._version==null?void 0:e._version,entity_metric:e.entity_metric==null?void 0:Y(e.entity_metric),entity_unique_id:e.entity_unique_id==null?void 0:e.entity_unique_id,entity_id:e.entity_id==null?void 0:e.entity_id,entity_image:e.entity_image==null?void 0:e.entity_image,entity_slug:e.entity_slug==null?void 0:e.entity_slug,entity_teaser:e.entity_teaser==null?void 0:e.entity_teaser,entity_time_end:e.entity_time_end==null?void 0:e.entity_time_end,entity_time_start:e.entity_time_start==null?void 0:e.entity_time_start,entity_title:e.entity_title==null?void 0:e.entity_title,entity_type:e.entity_type==null?void 0:e.entity_type,entity_type_id:e.entity_type_id==null?void 0:e.entity_type_id,updated_at:e.updated_at==null?void 0:e.updated_at,routes:e.routes==null?void 0:e.routes}}function te(e){return ie(e)}function ie(e,n){return e==null?e:{shortcode:e.shortcode==null?void 0:e.shortcode,name:e.name==null?void 0:e.name}}function R(e){return oe(e)}function oe(e,n){return e==null?e:{language:e.language==null?void 0:te(e.language),slug:e.slug==null?void 0:e.slug,title:e.title==null?void 0:e.title,href:e.href==null?void 0:e.href}}function A(e){return re(e)}function re(e,n){return e==null?e:{entity:e.entity==null?void 0:ee(e.entity),model:e.model==null?void 0:e.model,language:e.language==null?void 0:e.language,jsonld:e.jsonld==null?void 0:e.jsonld,translation:e.translation==null?void 0:e.translation.map(R),breadcrumb:e.breadcrumb==null?void 0:e.breadcrumb.map(E)}}function I(e){return ae(e)}function ae(e,n){return e==null?e:{entity_unique_id:e.entity_unique_id==null?void 0:e.entity_unique_id,entity_title:e.entity_title==null?void 0:e.entity_title,entity_teaser:e.entity_teaser==null?void 0:e.entity_teaser,entity_slug:e.entity_slug==null?void 0:e.entity_slug,entity_time_start:e.entity_time_start==null?void 0:e.entity_time_start,entity_type:e.entity_type==null?void 0:e.entity_type,entity_type_id:e.entity_type_id==null?void 0:e.entity_type_id,entity_image:e.entity_image==null?void 0:e.entity_image,routes:e.routes==null?void 0:e.routes}}function le(e){return se(e)}function se(e,n){return e==null?e:{description:e.description==null?void 0:e.description,image:e.image==null?void 0:e.image,title:e.title==null?void 0:e.title}}function ue(e){return ce(e)}function ce(e,n){return e==null?e:{value:e.value==null?void 0:e.value,navigation:e.navigation==null?void 0:e.navigation,propagate:e.propagate==null?void 0:e.propagate}}function T(e){return de(e)}function de(e,n){return e==null?e:{id:e.id==null?void 0:e.id,title:e.title==null?void 0:e.title,href:e.href==null?void 0:e.href,slug:e.slug==null?void 0:e.slug,json:e.json==null?void 0:e.json.map(C),depth:e.depth==null?void 0:e.depth,is_home:e.is_home==null?void 0:e.is_home,created_at:e.created_at==null?void 0:e.created_at,updated_at:e.updated_at==null?void 0:e.updated_at,is_visible:e.is_visible==null?void 0:e.is_visible,meta_json:e.meta_json==null?void 0:le(e.meta_json),properties:e.properties==null?void 0:v(e.properties,ue),uid:e.uid==null?void 0:e.uid,type:e.type==null?void 0:e.type,target:e.target==null?void 0:e.target,container:e.container==null?void 0:e.container,breadcrumb:e.breadcrumb==null?void 0:e.breadcrumb.map(E),translation:e.translation==null?void 0:e.translation.map(R)}}function fe(e){return ge(e)}function ge(e,n){return e==null?e:{version:e.version==null?void 0:e.version,updated_at:e.updated_at==null?void 0:e.updated_at}}class he extends g{async configRaw(n,t){const i={};n.lang!=null&&(i.lang=n.lang);const r={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/config",method:"GET",headers:r,query:i},t);return new d(o,a=>Q(a))}async config(n={},t){return await(await this.configRaw(n,t)).value()}}class pe extends g{async entityBySlugRaw(n,t){if(n.slug==null)throw new y("slug",'Required parameter "slug" was null or undefined when calling entityBySlug().');const i={};n.typeId!=null&&(i.typeId=n.typeId),n.lang!=null&&(i.lang=n.lang);const r={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/entities/slug/{slug}".replace("{slug}",encodeURIComponent(String(n.slug))),method:"GET",headers:r,query:i},t);return new d(o,a=>A(a))}async entityBySlug(n,t){return await(await this.entityBySlugRaw(n,t)).value()}async entityByUniqueidRaw(n,t){if(n.uniqueid==null)throw new y("uniqueid",'Required parameter "uniqueid" was null or undefined when calling entityByUniqueid().');const i={};n.lang!=null&&(i.lang=n.lang);const r={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/entities/uniqueid/{uniqueid}".replace("{uniqueid}",encodeURIComponent(String(n.uniqueid))),method:"GET",headers:r,query:i},t);return new d(o,a=>A(a))}async entityByUniqueid(n,t){return await(await this.entityByUniqueidRaw(n,t)).value()}}class ye extends g{async homeRaw(n,t){const i={};n.lang!=null&&(i.lang=n.lang);const r={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/pages/home",method:"GET",headers:r,query:i},t);return new d(o,a=>T(a))}async home(n={},t){return await(await this.homeRaw(n,t)).value()}async pageRaw(n,t){const i={};n.slug!=null&&(i.slug=n.slug),n.lang!=null&&(i.lang=n.lang);const r={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/pages",method:"GET",headers:r,query:i},t);return new d(o,a=>T(a))}async page(n={},t){return await(await this.pageRaw(n,t)).value()}}class ve extends g{async searchRaw(n,t){if(n.query==null)throw new y("query",'Required parameter "query" was null or undefined when calling search().');const i={};n.query!=null&&(i.query=n.query),n.lang!=null&&(i.lang=n.lang);const r={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/search",method:"GET",headers:r,query:i},t);return new d(o,a=>a.map(I))}async search(n,t){return await(await this.searchRaw(n,t)).value()}}class me extends g{async sitemapRaw(n,t){const i={};n.lang!=null&&(i.lang=n.lang);const r={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/sitemap",method:"GET",headers:r,query:i},t);return new d(o,a=>a.map(I))}async sitemap(n={},t){return await(await this.sitemapRaw(n,t)).value()}}class we extends g{async versionRaw(n,t){const i={};n.lang!=null&&(i.lang=n.lang);const r={};this.configuration&&this.configuration.apiKey&&(i.token=await this.configuration.apiKey("token"));const o=await this.request({path:"/version",method:"GET",headers:r,query:i},t);return new d(o,a=>fe(a))}async version(n={},t){return await(await this.versionRaw(n,t)).value()}}const _e=/[\p{Lu}]/u,be=/[\p{Ll}]/u,k=/^[\p{Lu}](?![\p{Lu}])/gu,S=/([\p{Alpha}\p{N}_]|$)/u,m=/[_.\- ]+/,Ce=new RegExp("^"+m.source),j=new RegExp(m.source+S.source,"gu"),L=new RegExp("\\d+"+S.source,"gu"),Ee=(e,n,t,i)=>{let r=!1,o=!1,a=!1,l=!1;for(let s=0;s<e.length;s++){const c=e[s];l=s>2?e[s-3]==="-":!0,r&&_e.test(c)?(e=e.slice(0,s)+"-"+e.slice(s),r=!1,a=o,o=!0,s++):o&&a&&be.test(c)&&(!l||i)?(e=e.slice(0,s-1)+"-"+e.slice(s-1),a=o,o=!1,r=!0):(r=n(c)===c&&t(c)!==c,a=o,o=t(c)===c&&n(c)!==c)}return e},qe=(e,n)=>(k.lastIndex=0,e.replaceAll(k,t=>n(t))),Re=(e,n)=>(j.lastIndex=0,L.lastIndex=0,e.replaceAll(L,(t,i,r)=>["_","-"].includes(e.charAt(r+t.length))?t:n(t)).replaceAll(j,(t,i)=>n(i)));function Ae(e,n){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(n={pascalCase:!1,preserveConsecutiveUppercase:!1,...n},Array.isArray(e)?e=e.map(o=>o.trim()).filter(o=>o.length).join("-"):e=e.trim(),e.length===0)return"";const t=n.locale===!1?o=>o.toLowerCase():o=>o.toLocaleLowerCase(n.locale),i=n.locale===!1?o=>o.toUpperCase():o=>o.toLocaleUpperCase(n.locale);return e.length===1?m.test(e)?"":n.pascalCase?i(e):t(e):(e!==t(e)&&(e=Ee(e,t,i,n.preserveConsecutiveUppercase)),e=e.replace(Ce,""),e=n.preserveConsecutiveUppercase?qe(e,t):t(e),n.pascalCase&&(e=i(e.charAt(0))+e.slice(1)),Re(e,i))}function Ie(e,n,t){const i="virtual:flyo-components",r="\0"+i;return{name:"vite-plugin-flyo-components",async resolveId(o){if(o===i)return r},async load(o){if(o===r){const a=[];for(const[s,c]of Object.entries(n)){const p=await this.resolve("/"+e+"/"+c+".astro");p&&a.push(`export { default as ${Ae(s)} } from "${p.id}"`)}let l=null;return t&&(l=await this.resolve("/"+e+"/"+t+".astro")),l?a.push(`export { default as fallback } from "${l.id}"`):a.push('export { default as fallback } from "@flyo/nitro-astro/FallbackComponent.astro"'),a.join(";")}}}}function U(){return globalThis.flyoNitroInstance||console.error("The Flyo Typescript Configuration has not been initialized correctly"),globalThis.flyoNitroInstance}function f(){return U().config}async function Te(e){return await e.locals.config}function ke(){return new he(f())}function Se(){return new pe(f())}function je(){return new ye(f())}function Le(){return new ve(f())}function Ue(){return new me(f())}function Pe(){return new we(f())}function Fe(e){return{"data-flyo-uid":e.uid}}const xe=`
2
2
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 163.4 88.5">
3
3
  <style type="text/css">
4
4
  .st8{fill:#FFFFFF;}
@@ -29,7 +29,7 @@
29
29
  </g>
30
30
  </g>
31
31
  </svg>
32
- `;function $e(e){const n={accessToken:!1,liveEdit:!1,fallbackComponent:null,componentsDir:"src/components/flyo",serverCacheHeaderTtl:1200,clientCacheHeaderTtl:900,...e};return n.liveEdit==="true"?n.liveEdit=!0:n.liveEdit==="false"&&(n.liveEdit=!1),{name:"@flyo/nitro-astro",hooks:{"astro:config:setup":({injectScript:t,updateConfig:i,injectRoute:a,addMiddleware:o,addDevToolbarApp:r})=>{r({id:"flyo-nitro",name:"Flyo Nitro",icon:xe,entrypoint:"@flyo/nitro-astro/toolbar.ts"}),a({pattern:"sitemap.xml",entrypoint:"@flyo/nitro-astro/sitemap.ts"}),o({entrypoint:"@flyo/nitro-astro/middleware.ts",order:"post"}),i({image:{service:{entrypoint:"@flyo/nitro-astro/cdn.ts"}},vite:{plugins:[Ie(n.componentsDir,n.components||{},n.fallbackComponent)]}}),t("page-ssr",`
32
+ `;function $e(e){const n={accessToken:!1,liveEdit:!1,fallbackComponent:null,componentsDir:"src/components/flyo",serverCacheHeaderTtl:1200,clientCacheHeaderTtl:900,...e};return n.liveEdit==="true"?n.liveEdit=!0:n.liveEdit==="false"&&(n.liveEdit=!1),{name:"@flyo/nitro-astro",hooks:{"astro:config:setup":({injectScript:t,updateConfig:i,injectRoute:r,addMiddleware:o,addDevToolbarApp:a})=>{if(!n.accessToken||n.accessToken.length==0)throw new Error("The Flyo Nitro Integration requires an accessToken");a({id:"flyo-nitro",name:"Flyo Nitro",icon:xe,entrypoint:"@flyo/nitro-astro/toolbar.ts"}),r({pattern:"sitemap.xml",entrypoint:"@flyo/nitro-astro/sitemap.ts"}),o({entrypoint:"@flyo/nitro-astro/middleware.ts",order:"post"}),i({image:{service:{entrypoint:"@flyo/nitro-astro/cdn.ts"}},vite:{plugins:[Ie(n.componentsDir,n.components||{},n.fallbackComponent)]}}),t("page-ssr",`
33
33
  import { Configuration } from '@flyo/nitro-typescript'
34
34
 
35
35
  var defaultConfig = new Configuration({
@@ -46,34 +46,25 @@
46
46
  }
47
47
  };
48
48
  `),n.liveEdit&&t("page",`
49
- window.addEventListener("message", (event) => {
50
- if (event.data?.action === 'pageRefresh') {
51
- window.location.reload(true);
52
- }
53
- })
49
+ import { reload, highlightAndClick } from '@flyo/nitro-js-bridge';
54
50
 
55
- function getActualWindow() {
56
- if (window === window.top) {
57
- return window;
58
- } else if (window.parent) {
59
- return window.parent;
60
- }
61
- return window;
62
- }
51
+ // Enable pageRefresh handling
52
+ reload();
63
53
 
64
- window.openBlockInFlyo = function(blockUid) {
65
- getActualWindow().postMessage({
66
- action: 'openEdit',
67
- data: JSON.parse(JSON.stringify({item:{uid: blockUid}}))
68
- }, 'https://flyo.cloud')
54
+ // Wire all elements with the 'data-flyo-uid' attribute
55
+ function wire() {
56
+ const elements = document.querySelectorAll('[data-flyo-uid]');
57
+ elements.forEach(el => {
58
+ const uid = el.getAttribute('data-flyo-uid');
59
+ if (uid) {
60
+ highlightAndClick(uid, el);
61
+ }
62
+ });
69
63
  }
70
64
 
71
- // Find all elements with the 'data-flyo-block-uid' attribute
72
- const elements = document.querySelectorAll('[data-flyo-block-uid]');
73
-
74
- elements.forEach(element => {
75
- element.addEventListener('click', function() {
76
- openBlockInFlyo(this.getAttribute('data-flyo-block-uid'))
77
- });
78
- });
79
- `)}}}}u.default=$e,u.editableBlock=Pe,u.useConfig=ke,u.useConfigApi=Te,u.useConfiguration=f,u.useEntitiesApi=Se,u.useFlyoIntegration=L,u.usePagesApi=Ue,u.useSearchApi=je,u.useSitemapApi=Le,u.useVersionApi=Fe,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
65
+ if (document.readyState === 'loading') {
66
+ document.addEventListener('DOMContentLoaded', wire, { once: true });
67
+ } else {
68
+ wire();
69
+ }
70
+ `)}}}}u.default=$e,u.editableBlock=Fe,u.useConfig=Te,u.useConfigApi=ke,u.useConfiguration=f,u.useEntitiesApi=Se,u.useFlyoIntegration=U,u.usePagesApi=je,u.useSearchApi=Le,u.useSitemapApi=Ue,u.useVersionApi=Pe,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,4 +1,4 @@
1
- const U = "https://api.flyo.cloud/nitro/v1".replace(/\/+$/, "");
1
+ const j = "https://api.flyo.cloud/nitro/v1".replace(/\/+$/, "");
2
2
  class L {
3
3
  constructor(n = {}) {
4
4
  this.configuration = n;
@@ -7,7 +7,7 @@ class L {
7
7
  this.configuration = n;
8
8
  }
9
9
  get basePath() {
10
- return this.configuration.basePath != null ? this.configuration.basePath : U;
10
+ return this.configuration.basePath != null ? this.configuration.basePath : j;
11
11
  }
12
12
  get fetchApi() {
13
13
  return this.configuration.fetchApi;
@@ -41,8 +41,8 @@ class L {
41
41
  return this.configuration.credentials;
42
42
  }
43
43
  }
44
- const j = new L(), C = class E {
45
- constructor(n = j) {
44
+ const U = new L(), C = class E {
45
+ constructor(n = U) {
46
46
  this.configuration = n, this.fetchApi = async (t, i) => {
47
47
  let r = { url: t, init: i };
48
48
  for (const a of this.middleware)
@@ -110,7 +110,7 @@ const j = new L(), C = class E {
110
110
  let i = this.configuration.basePath + n.path;
111
111
  n.query !== void 0 && Object.keys(n.query).length !== 0 && (i += "?" + this.configuration.queryParamsStringify(n.query));
112
112
  const r = Object.assign({}, this.configuration.headers, n.headers);
113
- Object.keys(r).forEach((p) => r[p] === void 0 ? delete r[p] : {});
113
+ Object.keys(r).forEach((h) => r[h] === void 0 ? delete r[h] : {});
114
114
  const o = typeof t == "function" ? t : async () => t, a = {
115
115
  method: n.method,
116
116
  headers: r,
@@ -124,7 +124,7 @@ const j = new L(), C = class E {
124
124
  })
125
125
  };
126
126
  let s;
127
- P(l.body) || l.body instanceof URLSearchParams || F(l.body) ? s = l.body : this.isJsonMime(r["Content-Type"]) ? s = JSON.stringify(l.body) : s = l.body;
127
+ F(l.body) || l.body instanceof URLSearchParams || P(l.body) ? s = l.body : this.isJsonMime(r["Content-Type"]) ? s = JSON.stringify(l.body) : s = l.body;
128
128
  const u = {
129
129
  ...l,
130
130
  body: s
@@ -142,10 +142,10 @@ const j = new L(), C = class E {
142
142
  };
143
143
  C.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
144
144
  let d = C;
145
- function F(e) {
145
+ function P(e) {
146
146
  return typeof Blob < "u" && e instanceof Blob;
147
147
  }
148
- function P(e) {
148
+ function F(e) {
149
149
  return typeof FormData < "u" && e instanceof FormData;
150
150
  }
151
151
  class $ extends Error {
@@ -178,7 +178,7 @@ function R(e, n, t = "") {
178
178
  }
179
179
  return n instanceof Date ? `${encodeURIComponent(i)}=${encodeURIComponent(n.toISOString())}` : n instanceof Object ? q(n, i) : `${encodeURIComponent(i)}=${encodeURIComponent(String(n))}`;
180
180
  }
181
- function h(e, n) {
181
+ function p(e, n) {
182
182
  return Object.keys(e).reduce(
183
183
  (t, i) => ({ ...t, [i]: n(e[i]) }),
184
184
  {}
@@ -192,19 +192,19 @@ class c {
192
192
  return this.transformer(await this.raw.json());
193
193
  }
194
194
  }
195
- function N(e) {
196
- return M(e);
195
+ function M(e) {
196
+ return N(e);
197
197
  }
198
- function M(e, n) {
198
+ function N(e, n) {
199
199
  return e == null ? e : {
200
200
  identifier: e.identifier == null ? void 0 : e.identifier,
201
201
  content: e.content == null ? void 0 : e.content.map(A)
202
202
  };
203
203
  }
204
204
  function A(e) {
205
- return B(e);
205
+ return D(e);
206
206
  }
207
- function B(e, n) {
207
+ function D(e, n) {
208
208
  return e == null ? e : {
209
209
  items: e.items == null ? void 0 : e.items,
210
210
  content: e.content == null ? void 0 : e.content,
@@ -212,10 +212,10 @@ function B(e, n) {
212
212
  identifier: e.identifier == null ? void 0 : e.identifier,
213
213
  uid: e.uid == null ? void 0 : e.uid,
214
214
  component: e.component == null ? void 0 : e.component,
215
- slots: e.slots == null ? void 0 : h(e.slots, N)
215
+ slots: e.slots == null ? void 0 : p(e.slots, M)
216
216
  };
217
217
  }
218
- function k(e) {
218
+ function I(e) {
219
219
  return O(e);
220
220
  }
221
221
  function O(e, n) {
@@ -225,10 +225,10 @@ function O(e, n) {
225
225
  href: e.href == null ? void 0 : e.href
226
226
  };
227
227
  }
228
- function I(e) {
229
- return D(e);
228
+ function T(e) {
229
+ return B(e);
230
230
  }
231
- function D(e, n) {
231
+ function B(e, n) {
232
232
  return e == null ? e : {
233
233
  type: e.type == null ? void 0 : e.type,
234
234
  target: e.target == null ? void 0 : e.target,
@@ -236,7 +236,7 @@ function D(e, n) {
236
236
  href: e.href == null ? void 0 : e.href,
237
237
  slug: e.slug == null ? void 0 : e.slug,
238
238
  properties: e.properties == null ? void 0 : e.properties,
239
- children: e.children == null ? void 0 : e.children.map(I)
239
+ children: e.children == null ? void 0 : e.children.map(T)
240
240
  };
241
241
  }
242
242
  function G(e) {
@@ -244,7 +244,7 @@ function G(e) {
244
244
  }
245
245
  function H(e, n) {
246
246
  return e == null ? e : {
247
- items: e.items == null ? void 0 : e.items.map(I),
247
+ items: e.items == null ? void 0 : e.items.map(T),
248
248
  uid: e.uid == null ? void 0 : e.uid,
249
249
  identifier: e.identifier == null ? void 0 : e.identifier,
250
250
  label: e.label == null ? void 0 : e.label
@@ -263,14 +263,14 @@ function V(e, n) {
263
263
  primary_language: e.primary_language == null ? void 0 : e.primary_language
264
264
  };
265
265
  }
266
- function J(e) {
267
- return W(e);
266
+ function W(e) {
267
+ return J(e);
268
268
  }
269
- function W(e, n) {
269
+ function J(e, n) {
270
270
  return e == null ? e : {
271
271
  nitro: e.nitro == null ? void 0 : z(e.nitro),
272
272
  pages: e.pages == null ? void 0 : e.pages,
273
- containers: e.containers == null ? void 0 : h(e.containers, G),
273
+ containers: e.containers == null ? void 0 : p(e.containers, G),
274
274
  globals: e.globals == null ? void 0 : e.globals
275
275
  };
276
276
  }
@@ -313,7 +313,7 @@ function ne(e, n) {
313
313
  name: e.name == null ? void 0 : e.name
314
314
  };
315
315
  }
316
- function T(e) {
316
+ function k(e) {
317
317
  return te(e);
318
318
  }
319
319
  function te(e, n) {
@@ -333,8 +333,8 @@ function ie(e, n) {
333
333
  model: e.model == null ? void 0 : e.model,
334
334
  language: e.language == null ? void 0 : e.language,
335
335
  jsonld: e.jsonld == null ? void 0 : e.jsonld,
336
- translation: e.translation == null ? void 0 : e.translation.map(T),
337
- breadcrumb: e.breadcrumb == null ? void 0 : e.breadcrumb.map(k)
336
+ translation: e.translation == null ? void 0 : e.translation.map(k),
337
+ breadcrumb: e.breadcrumb == null ? void 0 : e.breadcrumb.map(I)
338
338
  };
339
339
  }
340
340
  function x(e) {
@@ -389,13 +389,13 @@ function ue(e, n) {
389
389
  updated_at: e.updated_at == null ? void 0 : e.updated_at,
390
390
  is_visible: e.is_visible == null ? void 0 : e.is_visible,
391
391
  meta_json: e.meta_json == null ? void 0 : re(e.meta_json),
392
- properties: e.properties == null ? void 0 : h(e.properties, le),
392
+ properties: e.properties == null ? void 0 : p(e.properties, le),
393
393
  uid: e.uid == null ? void 0 : e.uid,
394
394
  type: e.type == null ? void 0 : e.type,
395
395
  target: e.target == null ? void 0 : e.target,
396
396
  container: e.container == null ? void 0 : e.container,
397
- breadcrumb: e.breadcrumb == null ? void 0 : e.breadcrumb.map(k),
398
- translation: e.translation == null ? void 0 : e.translation.map(T)
397
+ breadcrumb: e.breadcrumb == null ? void 0 : e.breadcrumb.map(I),
398
+ translation: e.translation == null ? void 0 : e.translation.map(k)
399
399
  };
400
400
  }
401
401
  function ce(e) {
@@ -423,7 +423,7 @@ class fe extends d {
423
423
  headers: r,
424
424
  query: i
425
425
  }, t);
426
- return new c(o, (a) => J(a));
426
+ return new c(o, (a) => W(a));
427
427
  }
428
428
  /**
429
429
  * The config API endpoint provides comprehensive information required for configuring the layout of websites. It encompasses various essential elements, including containers with pages, an extensive list of available slugs, globals containing content pool data, and crucial details about the Nitro configuration itself. By accessing this endpoint, developers can gather all the necessary data to effectively design and structure their websites. The endpoint offers a holistic view of the website\'s layout, empowering developers to tailor the user experience and optimize the overall design.
@@ -433,7 +433,7 @@ class fe extends d {
433
433
  return await (await this.configRaw(n, t)).value();
434
434
  }
435
435
  }
436
- class pe extends d {
436
+ class he extends d {
437
437
  /**
438
438
  * The endpoint allows for the retrieval of entities based on their slug, with an optional Entity-Type-ID for more accurate results. The endpoint requires a `slug` parameter to be passed in the path, which is necessary for identifying the entity. However, since slugs are not unique across different entities, it is highly recommended to also provide the `typeId` parameter through the query to avoid incorrect or unintended results. This `typeId` serves as an Entity-Definition-Schema ID, ensuring a more precise and targeted entity retrieval by distinguishing the entities more clearly. The `slug` parameter is mandatory and should be a string (e.g., \'hello-world\'), while the `typeId` parameter is optional and should be an integer (e.g., 123), representing the Entity-Definition-Schema ID.
439
439
  * Find entity by slug and optional Entity-Type-ID
@@ -543,7 +543,7 @@ class ge extends d {
543
543
  return await (await this.pageRaw(n, t)).value();
544
544
  }
545
545
  }
546
- class he extends d {
546
+ class pe extends d {
547
547
  /**
548
548
  * This endpoint offers a powerful capability to search through the websites sitemap, encompassing both pages and entities. With this endpoint, users can efficiently explore and retrieve information from your sitemap by creating a paginated search experience.
549
549
  * Get Search by query
@@ -660,11 +660,11 @@ function Re(e, n, t) {
660
660
  for (const [s, u] of Object.entries(
661
661
  n
662
662
  )) {
663
- const p = await this.resolve(
663
+ const h = await this.resolve(
664
664
  "/" + e + "/" + u + ".astro"
665
665
  );
666
- p && a.push(
667
- `export { default as ${qe(s)} } from "${p.id}"`
666
+ h && a.push(
667
+ `export { default as ${qe(s)} } from "${h.id}"`
668
668
  );
669
669
  }
670
670
  let l = null;
@@ -687,33 +687,33 @@ function Ae() {
687
687
  function f() {
688
688
  return Ae().config;
689
689
  }
690
- async function Ie(e) {
690
+ async function Te(e) {
691
691
  return await e.locals.config;
692
692
  }
693
- function Te() {
693
+ function ke() {
694
694
  return new fe(f());
695
695
  }
696
696
  function xe() {
697
- return new pe(f());
697
+ return new he(f());
698
698
  }
699
699
  function Se() {
700
700
  return new ge(f());
701
701
  }
702
- function Ue() {
703
- return new he(f());
702
+ function je() {
703
+ return new pe(f());
704
704
  }
705
705
  function Le() {
706
706
  return new ye(f());
707
707
  }
708
- function je() {
708
+ function Ue() {
709
709
  return new ve(f());
710
710
  }
711
- function Fe(e) {
711
+ function Pe(e) {
712
712
  return {
713
- "data-flyo-block-uid": e.uid
713
+ "data-flyo-uid": e.uid
714
714
  };
715
715
  }
716
- const ke = `
716
+ const Ie = `
717
717
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 163.4 88.5">
718
718
  <style type="text/css">
719
719
  .st8{fill:#FFFFFF;}
@@ -745,7 +745,7 @@ const ke = `
745
745
  </g>
746
746
  </svg>
747
747
  `;
748
- function Pe(e) {
748
+ function Fe(e) {
749
749
  const n = {
750
750
  accessToken: !1,
751
751
  liveEdit: !1,
@@ -767,11 +767,13 @@ function Pe(e) {
767
767
  addMiddleware: o,
768
768
  addDevToolbarApp: a
769
769
  }) => {
770
+ if (!n.accessToken || n.accessToken.length == 0)
771
+ throw new Error("The Flyo Nitro Integration requires an accessToken");
770
772
  a({
771
773
  id: "flyo-nitro",
772
774
  name: "Flyo Nitro",
773
775
  //icon: 'lightbulb',
774
- icon: ke,
776
+ icon: Ie,
775
777
  //icon: '<svg width="200" height="200" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><ellipse cx="100" cy="60" rx="90" ry="50" fill="#F4A460" /><circle cx="70" cy="45" r="5" fill="white" /><circle cx="90" cy="30" r="5" fill="white" /><circle cx="110" cy="45" r="5" fill="white" /><circle cx="130" cy="30" r="5" fill="white" /><circle cx="150" cy="45" r="5" fill="white" /><path d="M30 90 Q60 75, 90 90 T150 90 Q160 80, 180 90" fill="#228B22" /><rect x="30" y="90" width="140" height="15" fill="#FF6347" /><rect x="30" y="105" width="140" height="15" fill="#FFD700" /><rect x="30" y="120" width="140" height="25" fill="#8B4513" /><ellipse cx="100" cy="160" rx="90" ry="30" fill="#F4A460" /></svg>',
776
778
  entrypoint: "@flyo/nitro-astro/toolbar.ts"
777
779
  }), r({
@@ -817,36 +819,27 @@ function Pe(e) {
817
819
  ), n.liveEdit && t(
818
820
  "page",
819
821
  `
820
- window.addEventListener("message", (event) => {
821
- if (event.data?.action === 'pageRefresh') {
822
- window.location.reload(true);
823
- }
824
- })
822
+ import { reload, highlightAndClick } from '@flyo/nitro-js-bridge';
825
823
 
826
- function getActualWindow() {
827
- if (window === window.top) {
828
- return window;
829
- } else if (window.parent) {
830
- return window.parent;
831
- }
832
- return window;
833
- }
824
+ // Enable pageRefresh handling
825
+ reload();
834
826
 
835
- window.openBlockInFlyo = function(blockUid) {
836
- getActualWindow().postMessage({
837
- action: 'openEdit',
838
- data: JSON.parse(JSON.stringify({item:{uid: blockUid}}))
839
- }, 'https://flyo.cloud')
827
+ // Wire all elements with the 'data-flyo-uid' attribute
828
+ function wire() {
829
+ const elements = document.querySelectorAll('[data-flyo-uid]');
830
+ elements.forEach(el => {
831
+ const uid = el.getAttribute('data-flyo-uid');
832
+ if (uid) {
833
+ highlightAndClick(uid, el);
834
+ }
835
+ });
840
836
  }
841
837
 
842
- // Find all elements with the 'data-flyo-block-uid' attribute
843
- const elements = document.querySelectorAll('[data-flyo-block-uid]');
844
-
845
- elements.forEach(element => {
846
- element.addEventListener('click', function() {
847
- openBlockInFlyo(this.getAttribute('data-flyo-block-uid'))
848
- });
849
- });
838
+ if (document.readyState === 'loading') {
839
+ document.addEventListener('DOMContentLoaded', wire, { once: true });
840
+ } else {
841
+ wire();
842
+ }
850
843
  `
851
844
  );
852
845
  }
@@ -854,15 +847,15 @@ function Pe(e) {
854
847
  };
855
848
  }
856
849
  export {
857
- Pe as default,
858
- Fe as editableBlock,
859
- Ie as useConfig,
860
- Te as useConfigApi,
850
+ Fe as default,
851
+ Pe as editableBlock,
852
+ Te as useConfig,
853
+ ke as useConfigApi,
861
854
  f as useConfiguration,
862
855
  xe as useEntitiesApi,
863
856
  Ae as useFlyoIntegration,
864
857
  Se as usePagesApi,
865
- Ue as useSearchApi,
858
+ je as useSearchApi,
866
859
  Le as useSitemapApi,
867
- je as useVersionApi
860
+ Ue as useVersionApi
868
861
  };
@@ -36,6 +36,7 @@ export interface IntegrationOptions {
36
36
  /**
37
37
  * (Optional) Fallback component name.
38
38
  * If provided, this component will be used as a fallback. This fallback component will be used when the requested component is not found and only in live editing mode.
39
+ * An example for a fallback component could be `BlockNotFound` where the flyo is placed in `{componentsDir}/BlockNotFound.astro`.
39
40
  */
40
41
  fallbackComponent?: string;
41
42
  /**
package/middleware.ts CHANGED
@@ -9,6 +9,12 @@ async function getConfigPromise(context) {
9
9
  return resolvedValue;
10
10
  }
11
11
 
12
+ // check if useFlyoIntegration is available and configured correctly
13
+ if (!useFlyoIntegration()?.config || false) {
14
+ console.error("useFlyoIntegration is not available or not configured correctly.");
15
+ return null;
16
+ }
17
+
12
18
  // Fetch the config and store the resolved value
13
19
  const value = await useConfigApi().config({
14
20
  lang: context.currentLocale,
@@ -25,7 +31,13 @@ export const onRequest = defineMiddleware(async (context, next) => {
25
31
 
26
32
  context.locals.config = getConfigPromise(context);
27
33
 
28
- const liveEditEnabled = useFlyoIntegration().options.liveEdit;
34
+ let liveEditEnabled = false;
35
+ try {
36
+ // Safely retrieve options from useFlyoIntegration
37
+ liveEditEnabled = useFlyoIntegration()?.options?.liveEdit || false;
38
+ } catch (error) {
39
+ console.error("Error in useFlyoIntegration:", error);
40
+ }
29
41
 
30
42
  if (!liveEditEnabled) {
31
43
  const response = await next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flyo/nitro-astro",
3
- "version": "2.0.10",
3
+ "version": "2.1.0",
4
4
  "description": "Connecting Flyo Headless Content Hub into your Astro project.",
5
5
  "homepage": "https://dev.flyo.cloud/nitro",
6
6
  "keywords": [