@flyo/nitro-astro 2.0.10 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nitro-astro.js +3 -3
- package/dist/nitro-astro.mjs +2 -0
- package/dist/types/index.d.ts +1 -0
- package/middleware.ts +13 -1
- package/package.json +1 -1
package/dist/nitro-astro.js
CHANGED
|
@@ -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,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 L{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 M(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?L.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 K(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(h=>r[h]===void 0?delete r[h]:{});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;$(l.body)||l.body instanceof URLSearchParams||N(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 N(e){return typeof Blob<"u"&&e instanceof Blob}function $(e){return typeof FormData<"u"&&e instanceof FormData}class K extends Error{constructor(n,t){super(t),this.response=n,this.name="ResponseError"}}class M 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 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 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 k(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 I(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 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 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 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=>I(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=>I(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(k))}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(k))}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,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 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)=>(T.lastIndex=0,e.replaceAll(T,t=>n(t))),Re=(e,n)=>(U.lastIndex=0,j.lastIndex=0,e.replaceAll(j,(t,i,r)=>["_","-"].includes(e.charAt(r+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 ke(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 h=await this.resolve("/"+e+"/"+c+".astro");h&&a.push(`export { default as ${Ae(s)} } from "${h.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 F(){return globalThis.flyoNitroInstance||console.error("The Flyo Typescript Configuration has not been initialized correctly"),globalThis.flyoNitroInstance}function f(){return F().config}async function Ie(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 Fe(){return new me(f())}function Le(){return new we(f())}function Pe(e){return{"data-flyo-block-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
|
|
32
|
+
`;function Ne(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:[ke(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({
|
|
@@ -76,4 +76,4 @@
|
|
|
76
76
|
openBlockInFlyo(this.getAttribute('data-flyo-block-uid'))
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
|
-
`)}}}}u.default
|
|
79
|
+
`)}}}}u.default=Ne,u.editableBlock=Pe,u.useConfig=Ie,u.useConfigApi=Te,u.useConfiguration=f,u.useEntitiesApi=Se,u.useFlyoIntegration=F,u.usePagesApi=Ue,u.useSearchApi=je,u.useSitemapApi=Fe,u.useVersionApi=Le,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/nitro-astro.mjs
CHANGED
|
@@ -767,6 +767,8 @@ 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",
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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
|
-
|
|
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();
|