@miroart/sdk 0.1.0 → 0.3.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/dist/MiroText.d.ts +14 -0
- package/dist/asset.d.ts +19 -0
- package/dist/collection.d.ts +15 -0
- package/dist/composables.d.ts +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +11 -6
- package/dist/index.js +1 -1
- package/dist/list.d.ts +14 -0
- package/dist/locales.d.ts +14 -0
- package/dist/menu.d.ts +6 -2
- package/dist/page.d.ts +58 -8
- package/dist/paths.d.ts +1 -0
- package/dist/richText.d.ts +36 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/site.d.ts +7 -3
- package/dist/types.d.ts +32 -0
- package/dist/values.d.ts +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type FunctionalComponent } from "vue";
|
|
2
|
+
/**
|
|
3
|
+
* Tekst z CMS z formatowaniem: `<h1><MiroText :value="heading" /></h1>`.
|
|
4
|
+
*
|
|
5
|
+
* Bez `v-html`: tagi i style pochodzą ze stałych list, a tekst użytkownika trafia tylko do
|
|
6
|
+
* węzłów tekstowych. `<script>` w wartości pokaże się jako tekst. Wartość bez znaczników i
|
|
7
|
+
* złamań linii daje zwykły węzeł tekstowy, więc można tu podać wszystko to co do `{{ }}`.
|
|
8
|
+
*
|
|
9
|
+
* W ramce edytora wynik dostaje `data-miro-rich`: po tym nakładka poznaje, że znaczniki się
|
|
10
|
+
* tu wyrenderują, i pokazuje pasek formatowania. `display: contents` nie zmienia układu.
|
|
11
|
+
*/
|
|
12
|
+
export declare const MiroText: FunctionalComponent<{
|
|
13
|
+
value?: unknown;
|
|
14
|
+
}>;
|
package/dist/asset.d.ts
CHANGED
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
import { AssetName, UrlValue } from "./values";
|
|
2
2
|
import type { AssetRecord } from "./types";
|
|
3
3
|
import type { Kernel } from "./context";
|
|
4
|
+
export type GalleryMembership = {
|
|
5
|
+
id: number | string | null;
|
|
6
|
+
uuid: string;
|
|
7
|
+
name: string;
|
|
8
|
+
sort_order: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function imageAssetRecord(raw: unknown): AssetRecord | null;
|
|
4
11
|
export declare class Asset {
|
|
5
12
|
private readonly record;
|
|
6
13
|
private readonly runtime;
|
|
7
14
|
constructor(record: AssetRecord, runtime: Kernel);
|
|
8
15
|
getUuid(): string;
|
|
9
16
|
getName(): AssetName;
|
|
17
|
+
getAlt(): string;
|
|
18
|
+
getCaption(): string;
|
|
19
|
+
getGallery(): GalleryMembership | null;
|
|
20
|
+
galleryUuid(): string;
|
|
21
|
+
galleryName(): string;
|
|
22
|
+
memberships(): GalleryMembership[];
|
|
10
23
|
getMime(): string;
|
|
24
|
+
getSize(): number;
|
|
25
|
+
getType(): string;
|
|
26
|
+
getSortOrder(): number;
|
|
11
27
|
isImage(): boolean;
|
|
12
28
|
url(): UrlValue;
|
|
13
29
|
srcset(): string;
|
|
14
30
|
raw(): AssetRecord;
|
|
15
31
|
private urlString;
|
|
32
|
+
private mediaUrl;
|
|
16
33
|
}
|
|
17
34
|
export declare class Gallery {
|
|
18
35
|
private readonly items;
|
|
@@ -26,4 +43,6 @@ export declare class Gallery {
|
|
|
26
43
|
count(): number;
|
|
27
44
|
[Symbol.iterator](): Iterator<Asset>;
|
|
28
45
|
}
|
|
46
|
+
export declare function readGalleryMembership(value: unknown): GalleryMembership | null;
|
|
47
|
+
export declare function galleryKeyMatches(membership: GalleryMembership, needle: string): boolean;
|
|
29
48
|
export declare function assetsFromUnknown(value: unknown, runtime: Kernel): Asset[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Asset } from "./asset";
|
|
2
|
+
import type { Kernel } from "./context";
|
|
3
|
+
import type { Dict } from "./types";
|
|
4
|
+
import { UrlValue } from "./values";
|
|
5
|
+
export declare class CollectionCard {
|
|
6
|
+
private readonly row;
|
|
7
|
+
private readonly kernel;
|
|
8
|
+
constructor(row: Dict, kernel: Kernel);
|
|
9
|
+
getHref(): UrlValue;
|
|
10
|
+
getTitle(): string;
|
|
11
|
+
item(): Dict;
|
|
12
|
+
image(): Asset | null;
|
|
13
|
+
}
|
|
14
|
+
export declare function imageInRecord(item: unknown, kernel: Kernel): Asset | null;
|
|
15
|
+
export declare function collectionCards(value: unknown, kernel: Kernel): CollectionCard[];
|
package/dist/composables.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Gallery } from "./asset";
|
|
2
2
|
import { Menu } from "./menu";
|
|
3
|
+
import { Locales } from "./locales";
|
|
3
4
|
import { Page } from "./page";
|
|
4
5
|
import { type PluginHandle } from "./plugin";
|
|
5
6
|
import { Site } from "./site";
|
|
6
7
|
export declare function useMiroPage(): Page;
|
|
7
8
|
export declare function useMiroSite(): Site;
|
|
8
9
|
export declare function useMiroMenu(position?: string): Menu;
|
|
10
|
+
export declare function useMiroLocales(): Locales;
|
|
9
11
|
export declare function useMiroAssets(): Gallery;
|
|
10
12
|
export declare function usePlugin(name: string): PluginHandle;
|
|
11
13
|
export declare function useMiroConfig(): {
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue");function e(t,e){return{page:void 0!==e.page?e.page:t.page,site:void 0!==e.site?e.site:t.site,menus:e.menus?{...t.menus,...e.menus}:{...t.menus},locales:e.locales??t.locales,seo:void 0!==e.seo?e.seo:t.seo,options:e.options?{...t.options,...e.options}:{...t.options}}}function r(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)}function n(t){return r(t)?t:null}function s(t){return t?String(t.uuid||t.ulid||t.id||t.slug||t.full_url||""):""}function i(t){return t?String(t.uuid||t.domain||t.id||""):""}function o(t){return String.fromCharCode(...t.map(t=>23^t))}function u(t,e){const r=String(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return r?`${r}${n}`:n}function c(){const t=o([56,118,103,126]),e=o([97,38]),r=o([100,126,99,114,100]),n=o([103,118,112,114,100]),s=o([100,114,118,101,116,127]),i=o([122,114,121,98,100]),c=o([122,114,115,126,118]),a=o([103,123,98,112,126,121,100]);return{sites:()=>u("",`${t}/${e}/${r}`),site:n=>u("",`${t}/${e}/${r}/${encodeURIComponent(n)}`),pages:s=>u("",`${t}/${e}/${r}/${encodeURIComponent(s)}/${n}`),page:(s,i)=>u("",`${t}/${e}/${r}/${encodeURIComponent(s)}/${n}/${i.split("/").map(t=>encodeURIComponent(t)).join("/")}`),search:i=>u("",`${t}/${e}/${r}/${encodeURIComponent(i)}/${n}/${s}`),menus:n=>u("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${i}`),menu:(n,s)=>u("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${i}/${encodeURIComponent(s)}`),media:e=>u("",`${t}/${c}/${encodeURIComponent(e)}`),plugins:(e,r,n="")=>{const s=`${t}/${a}/${encodeURIComponent(e)}/${encodeURIComponent(r)}`;return n&&"/"!==n?`${s}${n.startsWith("/")?n:`/${n}`}`:s}}}function a(){if("undefined"==typeof globalThis)return{};const t=globalThis.MiroConfig;return t&&"object"==typeof t?t:{}}function l(t){return t&&"object"==typeof t&&"data"in t?t.data:t}function p(t){return null==t?"":"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):""}function h(t){const e=p(t);if(!e)return"";if("undefined"!=typeof document){const t=document.createElement("textarea");return t.innerHTML=e,t.value}return e.replace(/&#(\d+);/g,(t,e)=>String.fromCharCode(Number(e))).replace(/&#x([0-9a-f]+);/gi,(t,e)=>String.fromCharCode(parseInt(e,16))).replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function d(t){return h(t).replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi," ").replace(/<style[\s\S]*?>[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim()}class g extends String{kind;extra;constructor(t,e,r={}){super(h(e)),this.kind=t,this.extra=r,Object.setPrototypeOf(this,new.target.prototype)}toString(){return String.prototype.toString.call(this)}valueOf(){return String.prototype.valueOf.call(this)}raw(){return this.toString()}decode(){return h(this.toString())}cleanContent(){return d(this.toString())}stripHtml(){return this.cleanContent()}excerpt(t=160){const e=this.cleanContent();return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}firstParagraph(){return function(t){const e=h(t),r=e.match(/<p\b[^>]*>([\s\S]*?)<\/p>/i);return d(r?r[1]:e)}(this.toString())}isEmpty(){return""===this.cleanContent()}json(){const t=this.toString().trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}bool(){const t=this.toString().trim().toLowerCase();return"1"===t||"true"===t||"yes"===t||"on"===t}number(){const t=Number(this.toString().trim());return Number.isFinite(t)?t:null}}class f extends g{constructor(t){super("PageTitle",t)}}class m extends g{constructor(t){super("PageSubtitle",t)}}class y extends g{constructor(t){super("PageSmallTitle",t)}}class S extends g{constructor(t){super("PageSummary",t)}}class w extends g{constructor(t){super("PageContent",t)}html(){return this.toString()}}class $ extends g{constructor(t){super("SiteTitle",t)}}class b extends g{constructor(t){super("SiteName",t)}}class x extends g{key;constructor(t,e){super("OptionValue",A(e),{key:t}),this.key=t}present(){return!this.isEmpty()}}class k extends g{constructor(t){super("UrlValue",t)}path(){const t=this.toString().trim();if(!t)return"/";try{if(/^https?:\/\//i.test(t))return new URL(t).pathname.replace(/\/+$/,"")||"/"}catch{}return(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")||"/"}href(t=""){const e=this.path();return!t||/^https?:\/\//i.test(e)?e:`${String(t).replace(/\/+$/,"")}${e}`}}class j extends g{constructor(t){super("MenuTitle",t)}}class R extends g{constructor(t){super("AssetName",t)}}class C extends g{constructor(t){super("SeoTitle",t)}}class P extends g{constructor(t){super("SeoDescription",t)}}function A(t){if(null==t)return"";if("boolean"==typeof t||"number"==typeof t)return String(t);if("string"==typeof t){const e=t.trim();if(""===e||"[]"===e||"{}"===e)return"";if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")||e.startsWith('"')&&e.endsWith('"'))try{return A(JSON.parse(e))}catch{return h(t)}return h(t)}return Array.isArray(t)?t.length?A(t[0]):"":"object"==typeof t&&null!==t&&"value"in t?A(t.value):p(t)}function _(t,e){if(!t)return"";if(Array.isArray(t)){const r=t.find(t=>t&&"object"==typeof t&&t.key===e);return r&&"object"==typeof r?r.value:""}return"object"==typeof t?t[e]:""}class O{constructor(t){this.record=t}record;getTitle(){return new j(this.record.title)}getUrl(){return new k(this.record.url)}getChildren(){return v(this.record.children)}raw(){return{...this.record}}}class U{constructor(t,e){this.source=t,this.runtime=e}source;runtime;get record(){return"function"==typeof this.source?this.source():this.source}static async find(t,e){const r=function(){if(!M)throw new Error("Client is not installed.");return M}(),n=null!=e&&""!==String(e)?String(e):r.siteRef(),s=r.snapshot().menus,i=s[t]||Object.values(s).find(e=>!!e&&(String(e.uuid)===t||String(e.id)===t||String(e.name)===t||String(e.position)===t));if(i)return new U(i,r);const o=l(await r.request(c().menu(n,t)));return r.rememberMenu(o),new U(o,r)}getName(){return new j(this.record.name)}getPosition(){return String(this.record.position||"")}getItems(){return v(this.record.items)}raw(){return{...this.record}}}function v(t){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new O(t)):[]}let M=null;const T=[{mark:"1_8",width:256},{mark:"1_4",width:512},{mark:"1_2",width:1024},{mark:"2_3",width:1400}];class I{constructor(t,e){this.record=t,this.runtime=e}record;runtime;getUuid(){return String(this.record.uuid||this.record.id||"")}getName(){return new R(this.record.name)}getMime(){return String(this.record.mime_type||"")}isImage(){return!!this.getMime().startsWith("image/")||/\.(jpe?g|png|gif|webp|svg)(\?|$)/i.test(this.urlString())}url(){return new k(this.urlString())}srcset(){const t=this.urlString();if(!t||/\.svg([?#]|$)/i.test(t)||/^https?:\/\//i.test(t)||t.startsWith("//"))return"";if(!/\.webp([?#]|$)/i.test(t)||/\.(?:1_16|1_8|1_4|1_2|2_3)\.webp([?#]|$)/i.test(t))return"";const e=T.map(({mark:e,width:r})=>`${t.replace(/\.webp([?#].*)?$/i,`.${e}.webp$1`)} ${r}w`);return e.push(`${t} 2048w`),e.join(", ")}raw(){return{...this.record}}urlString(){const t=String(this.record.url||this.record.path||"");if(t)return t;const e=this.getUuid();if(!e)return"";const r=c().media(e),n=this.runtime.apiBase();return n?u(n,r):r}}class B{constructor(t){this.items=t}items;all(){return this.items.slice()}first(){return this.items[0]??null}extra(){return this.items.slice(1)}hero(){return this.first()}urls(){return this.items.map(t=>t.url())}isEmpty(){return 0===this.items.length}count(){return this.items.length}[Symbol.iterator](){return this.items[Symbol.iterator]()}}class q{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}static async find(t){const e=function(){if(!N)throw new Error("Client is not installed.");return N}(),r=null!=t&&""!==String(t)?String(t):e.siteRef(),n=e.snapshot().site;if(n&&(!t||String(n.uuid)===String(t)||String(n.id)===String(t)||String(n.domain)===String(t)||i(n)===String(t)))return new q(n,e);const s=l(await e.request(c().site(r)));return e.rememberSite(s),new q(s,e)}static async findPage(t,e){return E.find(t,e)}static async findMenu(t,e){return U.find(t,e)}getName(){return new b(this.record.name)}getTitle(){const t=_(this.record.options,"seo_title")||_(this.record.options,"title");return new $(t||this.record.name)}getDomain(){return String(this.record.domain||"")}getLang(){return String(this.record.lang||"")}getUuid(){return String(this.record.uuid||"")}getOption(t){return new x(t,_(this.record.options,t))}async findPage(t){return E.find(t,this.ref())}async findMenu(t){return U.find(t,this.ref())}async menus(){const t=this.kernel.snapshot().menus,e=Object.values(t).filter(Boolean);return e.length?e.map(t=>new U(t,this.kernel)):((await this.kernel.request(c().menus(this.ref()))).data??[]).map(t=>(this.kernel.rememberMenu(t),new U(t,this.kernel)))}async pages(t={}){const e=new URLSearchParams;for(const[n,s]of Object.entries(t))e.set(n,String(s));const r=e.toString()?`?${e.toString()}`:"";return((await this.kernel.request(`${c().pages(this.ref())}${r}`)).data??[]).map(t=>(this.kernel.rememberPage(t),new E(t,this.kernel)))}raw(){return{...this.record}}ref(){return String(this.record.uuid||this.record.domain||this.record.id||this.kernel.siteRef())}}let N=null;class E{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}setRecord(t){"function"!=typeof this.source?this.source=t:this.kernel.rememberPage(t)}static async findByUlid(t,e){return V(t,e)}static async find(t,e){return V(t,e)}static async search(t,e){const r=D(),n=L(r,e),s=`${c().search(n)}?q=${encodeURIComponent(t)}`,i=await r.request(s);return(Array.isArray(i?.data)?i.data:Array.isArray(i)?i:[]).map(t=>(r.rememberPage(t),new E(t,r)))}getTitle(){return new f(this.record.title)}getSubtitle(){return new m(this.record.subtitle)}getSmallTitle(){return new y(this.record.smalltitle)}getSummary(){return new S(this.record.summary)}getContent(){return new w(this.record.content)}getSlug(){return String(this.record.slug||"")}getUrl(){return new k(this.record.full_url||(this.record.slug?`/${this.record.slug}`:"/"))}getUuid(){return String(this.record.uuid||this.record.ulid||"")}getId(){return String(this.record.id||this.getUuid())}getLayout(){return String(this.record.layout||"")}getDisplay(){return String(this.record.display||"")}getOption(t){const e=_(this.record.options,t);if(null!=e&&""!==e)return new x(t,e);const r=this.kernel.snapshot().options[t];return new x(t,r)}getSeo(){const t=(this.record.seo&&"object"==typeof this.record.seo?this.record.seo:this.kernel.snapshot().seo)??{};return{title:new C(t.title??this.record.title),description:new P(t.description??this.record.summary),raw:{...t}}}getAssets(){return new B((t=this.record.assets,e=this.kernel,Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new I(t,e)):[]));var t,e}async getChildren(){return await this.ensure(["children"]),(Array.isArray(this.record.children)?this.record.children:[]).filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new E(t,this.kernel))}async getSiblings(){if(Array.isArray(this.record.siblings))return this.record.siblings.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new E(t,this.kernel));const t=this.record.parent_id,e=this.siteRef();if(null==t||""===t){const t=await this.kernel.request(`${c().pages(e)}?parent=root`);return this.excludeSelf(t.data??[])}const r=await this.kernel.request(`${c().pages(e)}?parent=${encodeURIComponent(String(t))}`);return this.excludeSelf(r.data??[])}async getParent(){if(this.record.parent&&"object"==typeof this.record.parent)return new E(this.record.parent,this.kernel);const t=this.record.parent_id;return null==t||""===t?null:V(String(t),this.siteRef())}async getSite(){if(this.record.site&&"object"==typeof this.record.site)return new q(this.record.site,this.kernel);const t=this.kernel.snapshot().site;if(t&&(String(t.id)===String(this.record.site_id)||!this.record.site_id))return new q(t,this.kernel);const e=this.record.site_id?String(this.record.site_id):this.kernel.siteRef(),r=l(await this.kernel.request(c().site(e)));return this.kernel.rememberSite(r),new q(r,this.kernel)}async load(){return await this.ensure(["content","options","assets","children"]),this}raw(){return{...this.record}}siteRef(){return this.record.site&&"object"==typeof this.record.site?i(this.record.site)||this.kernel.siteRef():this.record.site_id?String(this.record.site_id):this.kernel.siteRef()}excludeSelf(t){const e=s(this.record);return t.filter(t=>s(t)!==e).map(t=>new E(t,this.kernel))}async ensure(t){if(!t.some(t=>void 0===this.record[t]))return;const e=this.getUuid()||this.getSlug()||String(this.record.id||"");if(!e)return;const r=l(await this.kernel.request(c().page(this.siteRef(),e)));this.setRecord({...this.record,...r})}}let W=null;function D(){if(!W)throw new Error("Client is not installed.");return W}function L(t,e){return null!=e&&""!==String(e)?String(e):t.siteRef()}async function V(t,e){const r=D(),n=L(r,e),s=l(await r.request(c().page(n,t)));return r.rememberPage(s),new E(s,r)}class H{snap={page:null,site:null,menus:{},locales:[],seo:null,options:{}};options;constructor(t={}){this.options=t,t.page&&this.hydrate(t.page),W=this,N=this,M=this}hydrate(t){return this.snap=e(this.snap,function(t){const e={page:null,site:null,menus:{},locales:[],seo:null,options:{}};if(!t||"object"!=typeof t)return e;const s=t,i=r(s.props)?s.props:s;e.page=n(i.page),e.site=n(i.site),e.seo=r(i.seo)?i.seo:null,e.options=r(i.options)?i.options:{},e.locales=Array.isArray(i.locales)?i.locales:[];const o=i.menus;if(r(o))for(const[r,u]of Object.entries(o))e.menus[r]=n(u);return e}(t)),this.snap}snapshot(){return this.snap}apiBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=a();if(e.apiBase)return String(e.apiBase).replace(/\/+$/,"");if("undefined"==typeof location)return"";const r=location.hostname.replace(/^www\./i,"");return r&&"localhost"!==r&&"127.0.0.1"!==r?`${location.protocol}//api.${r}`:""}(this.options.apiBase)}siteBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=a();return e.siteBase?String(e.siteBase).replace(/\/+$/,""):"undefined"!=typeof location?location.origin:""}(this.options.siteBase)}siteRef(){return null!=this.options.site&&""!==String(this.options.site)?String(this.options.site):i(this.snap.site)}async request(t,e={}){const r=this.apiBase();if(!r)throw new Error("Remote origin is not configured.");return async function(t,e,r={}){const{fetchImpl:n,...s}=r,i=e.startsWith("http")?e:u(t,e),o=n??fetch,c=new Headers(s.headers);c.has("Accept")||c.set("Accept","application/json");const a=await o(i,{...s,headers:c}),l=await a.text();let p=null;if(l)try{p=JSON.parse(l)}catch{p={message:l}}if(!a.ok){const t=new Error(`Request failed (${a.status})`);throw t.status=a.status,t.body=p,t}return p}(r,t,{...e,fetchImpl:this.options.fetch})}rememberPage(t){const r=this.snap.page;r&&String(r.id)===String(t.id)&&(this.snap=e(this.snap,{page:{...r,...t}}))}rememberSite(t){this.snap=e(this.snap,{site:{...this.snap.site??{},...t}})}rememberMenu(t){const r=String(t.position||t.uuid||t.id||t.name||"menu");this.snap=e(this.snap,{menus:{[r]:t}})}}let J=null;function K(t={}){return J=new H(t),J}function z(){return J||(J=new H),J}const Z=Symbol.for("miro.client");function G(){return t.inject(Z,null)??z()}function F(t={}){return{install(e,r={}){const n=K({...t,...r});e.provide(Z,n),function(t){import("@inertiajs/vue3").then(e=>{const r=e.router;r?.on?.("success",e=>{const r=e?.detail?.page;r&&t.hydrate(r)}),r?.on?.("navigate",e=>{const r=e?.detail?.page;r&&t.hydrate(r)})}).catch(()=>{})}(n)}}}const Y=F();function Q(t){return`mc_${(String(t??"").trim().split("/").pop()??"").replace(/^@/,"").replace(/[^A-Za-z0-9]+/g,"_").replace(/^_+|_+$/g,"").toUpperCase()}`}function X(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[^A-Za-z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function tt(t){if("undefined"==typeof window)return{};const e=window[t];return e&&"object"==typeof e?e:{}}function et(){const t=G(),e=function(){try{const t=globalThis.__INERTIA_PAGE__;if(t?.props)return t.props}catch{}return null}();return e&&t.hydrate(e),t}function rt(){const t=et();return nt(t),new E(()=>t.snapshot().page??{},t)}function nt(e){try{const r=function(){try{return st??null}catch{return null}}();if(!r)return;const n=r.usePage();e.hydrate(t.unref(n))}catch{}}let st=null;import("@inertiajs/vue3").then(t=>{st=t}).catch(()=>{st=null});const it=Y;exports.Asset=I,exports.AssetName=R,exports.Gallery=B,exports.Menu=U,exports.MenuItem=O,exports.MenuTitle=j,exports.Miro=Y,exports.OptionValue=x,exports.Page=E,exports.PageContent=w,exports.PageSmallTitle=y,exports.PageSubtitle=m,exports.PageSummary=S,exports.PageTitle=f,exports.SDK_KEY=Z,exports.SeoDescription=P,exports.SeoTitle=C,exports.Site=q,exports.SiteName=b,exports.SiteTitle=$,exports.TextValue=g,exports.UrlValue=k,exports.createMiro=F,exports.createRuntime=K,exports.default=it,exports.getRuntime=z,exports.pluginWindowKey=Q,exports.useKernel=G,exports.useMiroAssets=function(){return rt().getAssets()},exports.useMiroConfig=function(){const e=G();return{apiBase:t.computed(()=>e.apiBase()),siteBase:t.computed(()=>e.siteBase()),siteRef:t.computed(()=>e.siteRef())}},exports.useMiroMenu=function(t="topbar"){const e=et();return nt(e),new U(()=>e.snapshot().menus[t]??{position:t,items:[]},e)},exports.useMiroPage=rt,exports.useMiroSite=function(){const t=et();return nt(t),new q(()=>t.snapshot().site??{},t)},exports.usePlugin=function(t){return function(t,e){const r=Q(t),n=function(t){const e=String(t??"").trim();if(e.includes("/")){const[t,...r]=e.split("/");return{vendor:t||"miroart",slug:X(r.join("/")||e)}}return{vendor:"miroart",slug:X(e)}}(t);return new Proxy({name:t,key:r,ready:async()=>async function(t){const e=Date.now();for(;Date.now()-e<4e3;){const e=tt(t);if(Object.keys(e).length)return e;await new Promise(t=>setTimeout(t,50))}return tt(t)}(r),api:()=>tt(r),call:(t,...e)=>{const n=tt(r),s=n[t];if("function"!=typeof s)throw new Error(`Missing plugin method: ${t}`);return s.apply(n,e)},request:async(t="/",r={})=>{const s=c().plugins(n.vendor,n.slug,t||"/"),i=new Headers(r.headers);let o=r.body;return void 0!==r.json&&(o=JSON.stringify(r.json)),l(await e.request(s,{...r,headers:i,body:o}))}},{get(t,e,n){if(e in t)return Reflect.get(t,e,n);if("then"===e||e===Symbol.toStringTag)return;const s=tt(r),i=s[String(e)];return"function"==typeof i?i.bind(s):i},has:(t,e)=>e in t||e in tt(r)})}(t,G())};
|
|
1
|
+
"use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),e=["primary","secondary","accent","neutral","base-100","base-content","info","success","warning","error"],r=["sans","serif"],n=/\\(\[\/?(?:b|i|u|s|c|f)(?:=[a-z0-9-]+)?\])|\[(\/?)(b|i|u|s|c|f)(?:=([a-z0-9-]+))?\]/g;function s(t,n){return"c"===t?e.includes(n??""):"f"===t?r.includes(n??""):void 0===n}function i(t,e){""!==e&&e.split(/\r?\n/).forEach((e,r)=>{if(r>0&&t.push({type:"br"}),""===e)return;const n=t[t.length-1];"text"===n?.type?n.value+=e:t.push({type:"text",value:e})})}function o(t){const e=String(t??""),r=[],o=[],a=()=>o[o.length-1]?.children??r,c=()=>{var t,e;t=o.pop(),e=a(),0!==t.children.length&&("c"===t.tag?e.push({type:"c",value:t.value,children:t.children}):"f"===t.tag?e.push({type:"f",value:t.value,children:t.children}):e.push({type:t.tag,children:t.children}))};let u,l=0;for(n.lastIndex=0;null!==(u=n.exec(e));){i(a(),e.slice(l,u.index)),l=n.lastIndex;const[t,r,p,h,d]=u;if(void 0===r){if("/"===p){const e=void 0===d?o.map(t=>t.tag).lastIndexOf(h):-1;if(-1===e){i(a(),t);continue}for(;o.length>e;)c();continue}!s(h,d)||o.length>=8?i(a(),t):o.push({tag:h,value:d??null,children:[]})}else i(a(),r)}for(i(a(),e.slice(l));o.length>0;)c();return r}function a(t,e){for(const r of t)"text"===r.type?e.push(r.value):"br"===r.type?e.push("\n"):a(r.children,e)}function c(t){const e=String(t??"");if(!e.includes("["))return e;const r=[];return a(o(e),r),r.join("")}const u=/[][]+/,l={b:"strong",i:"em",u:"u",s:"s"};function p(e){switch(e.type){case"text":return e.value;case"br":return t.h("br");case"c":return t.h("span",{style:{color:`var(--color-${e.value})`}},h(e.children));case"f":return t.h("span",{style:{fontFamily:`var(--font-${e.value})`}},h(e.children));default:return t.h(l[e.type],h(e.children))}}function h(t){return t.map(p)}const d=e=>{const r=t.toDisplayString(e.value),n=u.test(r);if(!n&&!function(t){return t.includes("[")||t.includes("\n")}(r))return r;const s=h(o(r));return n?t.h("span",{"data-miro-rich":"",style:{display:"contents"}},s):1===s.length?s[0]:s};function g(t,e){return{page:void 0!==e.page?e.page:t.page,site:void 0!==e.site?e.site:t.site,menus:e.menus?{...t.menus,...e.menus}:{...t.menus},locales:e.locales??t.locales,seo:void 0!==e.seo?e.seo:t.seo,options:e.options?{...t.options,...e.options}:{...t.options}}}function f(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)}function m(t){return f(t)?t:null}function y(t){return t?String(t.uuid||t.ulid||t.id||t.slug||t.full_url||""):""}function w(t){return t?String(t.uuid||t.domain||t.id||""):""}function S(t){return String.fromCharCode(...t.map(t=>23^t))}function b(t,e){const r=String(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return r?`${r}${n}`:n}function $(){const t=S([56,118,103,126]),e=S([97,38]),r=S([100,126,99,114,100]),n=S([103,118,112,114,100]),s=S([100,114,118,101,116,127]),i=S([122,114,121,98,100]),o=S([122,114,115,126,118]),a=S([103,123,98,112,126,121,100]),c=S([118,116,99,126,120,121,100]);return{sites:()=>b("",`${t}/${e}/${r}`),site:n=>b("",`${t}/${e}/${r}/${encodeURIComponent(n)}`),pages:s=>b("",`${t}/${e}/${r}/${encodeURIComponent(s)}/${n}`),page:(s,i)=>b("",`${t}/${e}/${r}/${encodeURIComponent(s)}/${n}/${i.split("/").map(t=>encodeURIComponent(t)).join("/")}`),search:i=>b("",`${t}/${e}/${r}/${encodeURIComponent(i)}/${n}/${s}`),menus:n=>b("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${i}`),menu:(n,s)=>b("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${i}/${encodeURIComponent(s)}`),media:e=>b("",`${t}/${o}/${encodeURIComponent(e)}`),action:e=>b("",`${t}/${c}/${encodeURIComponent(e)}`),plugins:(e,r,n="")=>{const s=`${t}/${a}/${encodeURIComponent(e)}/${encodeURIComponent(r)}`;return n&&"/"!==n?`${s}${n.startsWith("/")?n:`/${n}`}`:s}}}function x(){if("undefined"==typeof globalThis)return{};const t=globalThis.MiroConfig;return t&&"object"==typeof t?t:{}}function _(t){return t&&"object"==typeof t&&"data"in t?t.data:t}function j(t){return null==t?"":"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):""}function k(t){const e=j(t);if(!e)return"";if("undefined"!=typeof document){const t=document.createElement("textarea");return t.innerHTML=e,t.value}return e.replace(/&#(\d+);/g,(t,e)=>String.fromCharCode(Number(e))).replace(/&#x([0-9a-f]+);/gi,(t,e)=>String.fromCharCode(parseInt(e,16))).replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function A(t){return c(k(t)).replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi," ").replace(/<style[\s\S]*?>[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim()}d.props=["value"],d.displayName="MiroText";class v extends String{kind;extra;constructor(t,e,r={}){super(k(e)),this.kind=t,this.extra=r,Object.setPrototypeOf(this,new.target.prototype)}toString(){return String.prototype.toString.call(this)}valueOf(){return String.prototype.valueOf.call(this)}raw(){return this.toString()}decode(){return k(this.toString())}cleanContent(){return A(this.toString())}stripHtml(){return this.cleanContent()}plain(){return c(this.toString())}excerpt(t=160){const e=this.cleanContent();return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}firstParagraph(){return function(t){const e=k(t),r=e.match(/<p\b[^>]*>([\s\S]*?)<\/p>/i);return A(r?r[1]:e)}(this.toString())}isEmpty(){return""===this.cleanContent()}json(){const t=this.toString().trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}bool(){const t=this.toString().trim().toLowerCase();return"1"===t||"true"===t||"yes"===t||"on"===t}number(){const t=Number(this.toString().trim());return Number.isFinite(t)?t:null}}class P extends v{constructor(t){super("PageTitle",t)}}class C extends v{constructor(t){super("PageSubtitle",t)}}class M extends v{constructor(t){super("PageSmallTitle",t)}}class T extends v{constructor(t){super("PageSummary",t)}}class O extends v{constructor(t){super("PageContent",t)}html(){return this.toString()}}class R extends v{constructor(t){super("SiteTitle",t)}}class I extends v{constructor(t){super("SiteName",t)}}class U extends v{key;structured;constructor(t,e){const r=E(e);super("OptionValue",r.text,{key:t}),this.key=t,this.structured=r.structured}json(){return void 0!==this.structured?this.structured:super.json()}present(){return!this.isEmpty()}}class N extends v{constructor(t){super("UrlValue",t)}path(){const t=this.toString().trim();if(!t)return"/";try{if(/^https?:\/\//i.test(t))return new URL(t).pathname.replace(/\/+$/,"")||"/"}catch{}return(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")||"/"}href(t=""){const e=this.path();return!t||/^https?:\/\//i.test(e)?e:`${String(t).replace(/\/+$/,"")}${e}`}}class W extends v{constructor(t){super("MenuTitle",t)}}class L extends v{constructor(t){super("AssetName",t)}}class B extends v{constructor(t){super("SeoTitle",t)}}class q extends v{constructor(t){super("SeoDescription",t)}}function E(t){if(null==t)return{text:""};if("boolean"==typeof t||"number"==typeof t)return{text:String(t)};if("string"==typeof t){const e=t.trim();if(""===e||"[]"===e||"{}"===e)return{text:""};if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")||e.startsWith('"')&&e.endsWith('"'))try{return E(JSON.parse(e))}catch{return{text:k(t)}}return{text:k(t)}}return Array.isArray(t)?{text:JSON.stringify(t),structured:t}:"object"==typeof t?function(t){return"value"in t&&Object.keys(t).every(t=>"value"===t||"key"===t||"id"===t||"active"===t)}(t)?E(t.value):{text:JSON.stringify(t),structured:t}:{text:j(t)}}function G(t,e){if(!t)return"";if(Array.isArray(t)){const r=t.find(t=>t&&"object"==typeof t&&t.key===e);return r&&"object"==typeof r?r.value:""}return"object"==typeof t?t[e]:""}function D(t){if("string"==typeof t){const e=t.trim();return e?V(e)?{uuid:e}:{url:e,path:e}:null}if(!t||"object"!=typeof t||Array.isArray(t))return null;const e=t,r=F(e.source),n=z(e.url,e.preview_url,e.path,e.src,r?.url,r?.preview_url,r?.path),s=z(e.uuid,r?.uuid);if(n||s&&V(s))return e;const i=z(e.value);return i?D(i):null}function z(...t){for(const e of t)if("string"==typeof e&&""!==e.trim())return e.trim();return""}function J(t){return"string"==typeof t?t.trim():""}function F(t){return!t||"object"!=typeof t||Array.isArray(t)?null:t}function H(t){return t.startsWith("/media/")||t.startsWith("/_images/")||t.startsWith("/api/media/")||t.startsWith("/branding-assets/")||t.startsWith("/storage/")}function V(t){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)}const K=[{mark:"1_8",width:256},{mark:"1_4",width:512},{mark:"1_2",width:1024},{mark:"2_3",width:1400}];class Z{constructor(t,e){this.record=t,this.runtime=e}record;runtime;getUuid(){return String(this.record.uuid||this.record.id||"")}getName(){return new L(this.record.name)}getAlt(){return J(this.record.alt)}getCaption(){return J(this.record.caption)}getGallery(){return this.memberships()[0]??null}galleryUuid(){return this.memberships()[0]?.uuid??""}galleryName(){return this.memberships()[0]?.name??""}memberships(){const t=this.record.galleries;if(Array.isArray(t)&&t.length>0)return t.map(t=>Q(t)).filter(t=>null!==t);const e=String(this.record.gallery_uuid??"").trim(),r=String(this.record.gallery_name??"").trim();if(!e&&!r)return[];const n=this.record.gallery_id;return[{id:"number"==typeof n||"string"==typeof n?n:null,uuid:e,name:r,sort_order:X(this.record.gallery_sort_order)}]}getMime(){const t=F(this.record.source);return String(this.record.mime_type||t?.mime_type||"")}getSize(){const t=F(this.record.source),e=Number(this.record.size??t?.size??0);return Number.isFinite(e)?e:0}getType(){const t=J(this.record.type);if(t)return t;const e=this.getMime();return e.startsWith("image/")?"image":e.startsWith("video/")?"video":"application/pdf"===e?"pdf":""}getSortOrder(){const t=Number(this.record.sort_order??0);return Number.isFinite(t)?t:0}isImage(){return!!this.getMime().startsWith("image/")||/\.(jpe?g|png|gif|webp|svg)(\?|$)/i.test(this.urlString())}url(){return new N(this.urlString())}srcset(){const t=this.urlString();if(!t||/\.svg([?#]|$)/i.test(t)||/^https?:\/\//i.test(t)||t.startsWith("//"))return"";if(!/\.webp([?#]|$)/i.test(t)||/\.(?:1_16|1_8|1_4|1_2|2_3)\.webp([?#]|$)/i.test(t))return"";const e=K.map(({mark:e,width:r})=>`${t.replace(/\.webp([?#].*)?$/i,`.${e}.webp$1`)} ${r}w`);return e.push(`${t} 2048w`),e.join(", ")}raw(){return{...this.record}}urlString(){const t=F(this.record.source),e=z(this.record.uuid,t?.uuid),r=z(this.record.disk,t?.disk);let n=z(this.record.url,this.record.preview_url,this.record.path,this.record.src,t?.url,t?.preview_url,t?.path);if(e&&V(e)&&n&&function(t,e){return!!(/\/project-storage\//i.test(r=t)||/\/editor\/project-file/i.test(r)||/cms\.miroart\.pl/i.test(r)&&/\/(?:project-storage|storage)\//i.test(r))||"project_public"===e&&!H(t)&&!/^https?:\/\//i.test(t)&&!t.startsWith("//");var r}(n,r))return this.mediaUrl(e);if(!n)return e&&V(e)?this.mediaUrl(e):"";if(!0===globalThis.isSsg){if(n.startsWith("/_images/")||n.startsWith("_images/"))return n.startsWith("/")?n:`/${n}`;const e=function(t){const e=t.match(/[?&]path=([^&]+)/i);if(e)try{const t=decodeURIComponent(e[1].replace(/\+/g," ")).split(/[/\\]/).pop()||"";if(t&&"project-file"!==t.toLowerCase())return t.trim()}catch{}return(t.split("#")[0].split("?")[0].split(/[/\\]/).pop()||"").trim()}(z(t?.path,this.record.path,n)),r=/\.(jpe?g|png|gif|webp|svg)$/i.test(s=e)?/\.svg$/i.test(s)?`/_images/${s}`:`/_images/${s.replace(/\.(jpe?g|png|gif|webp)$/i,".webp")}`:null;if(r)return r}var s;if(/^https?:\/\//i.test(n)||n.startsWith("//"))return n;if(n.startsWith("_images/"))return`/${n}`;if(H(n))return n;n.includes("/")||n.includes("\\")||V(n)||(n=`images/${n}`);const i=n.startsWith("/")?n:`/${n}`;return H(i)||i.startsWith("/project-storage/")?i:`/storage${i}`}mediaUrl(t){const e=$().media(t),r=this.runtime.apiBase();return r?b(r,e):e}}class Y{constructor(t){this.items=t}items;all(){return this.items.slice()}first(){return this.items[0]??null}extra(){return this.items.slice(1)}hero(){return this.first()}urls(){return this.items.map(t=>t.url())}isEmpty(){return 0===this.items.length}count(){return this.items.length}[Symbol.iterator](){return this.items[Symbol.iterator]()}}function Q(t){if(!t||"object"!=typeof t)return null;const e=t,r=String(e.uuid??"").trim(),n=String(e.name??"").trim();if(!r&&!n)return null;const s=e.id;return{id:"number"==typeof s||"string"==typeof s?s:null,uuid:r,name:n,sort_order:X(e.sort_order)}}function X(t){const e=Number(t??0);return Number.isFinite(e)?e:0}function tt(t,e){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new Z(t,e)):[]}const et=new Set(["id","uuid","created_at","updated_at"]);class rt{constructor(t,e){this.row=t,this.kernel=e}row;kernel;getHref(){return new N(this.row.href)}getTitle(){return String(this.row.title??"")}item(){const t=this.row.item;return t&&"object"==typeof t?t:{}}image(){return nt(this.item(),this.kernel)}}function nt(t,e){if(!t||"object"!=typeof t)return null;for(const[r,n]of Object.entries(t)){if(et.has(r)||"string"!=typeof n||!st(n))continue;const t=D(n);if(t)return new Z(t,e)}return null}function st(t){const e=t.trim();return!!e&&(!!(e.startsWith("/media/")||e.startsWith("/_images/")||e.startsWith("_images/")||e.startsWith("/api/media/")||e.startsWith("/branding-assets/"))||/\.(jpe?g|png|gif|webp|svg)(\?|#|$)/i.test(e))}function it(t,e){const r=t&&"object"==typeof t?t.meta:null,n=r&&"object"==typeof r?r:{};return{currentPage:at(n.current_page,1),lastPage:at(n.last_page,1),perPage:at(n.per_page,Math.max(e,1)),total:ct(n.total,e)}}function ot(t,e){return Object.assign(t,{meta:e})}function at(t,e){const r=Number(t);return!Number.isFinite(r)||r<1?e:Math.floor(r)}function ct(t,e){if(null==t||""===t)return e;const r=Number(t);return!Number.isFinite(r)||r<0?e:Math.floor(r)}class ut{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}static async all(){const t=pt(),e=await t.request($().sites());return(Array.isArray(e?.data)?e.data:[]).filter(t=>Boolean(t)&&"object"==typeof t).map(e=>new ut(e,t))}static async find(t){const e=pt(),r=null!=t&&""!==String(t)?String(t):e.siteRef(),n=e.snapshot().site;if(n&&(!t||String(n.uuid)===String(t)||String(n.id)===String(t)||String(n.domain)===String(t)||w(n)===String(t)))return new ut(n,e);const s=_(await e.request($().site(r)));return e.rememberSite(s),new ut(s,e)}static async findPage(t,e){return ht.find(t,e)}static async findMenu(t,e){return xt.find(t,e)}getName(){return new I(this.record.name)}getTitle(){const t=G(this.record.options,"seo_title")||G(this.record.options,"title");return new R(t||this.record.name)}getDomain(){return String(this.record.domain||"")}getLang(){return String(this.record.lang||"")}getUuid(){return String(this.record.uuid||"")}getOption(t){return new U(t,G(this.record.options,t))}getImage(t){const e=this.getOption(t),r=e.json(),n=null==r?e.toString().trim():r;if(null==n||""===n)return null;const s=D(n);return s?new Z(s,this.kernel):null}async findPage(t){return ht.find(t,this.ref())}async findMenu(t){return xt.find(t,this.ref())}async menus(){const t=this.kernel.snapshot().menus,e=Object.values(t).filter(Boolean);return e.length?e.map(t=>new xt(t,this.kernel)):((await this.kernel.request($().menus(this.ref()))).data??[]).map(t=>(this.kernel.rememberMenu(t),new xt(t,this.kernel)))}async pages(t={}){const e=new URLSearchParams,r={...t};null!=r.perPage&&null==r.per_page&&(r.per_page=r.perPage,delete r.perPage);for(const[o,a]of Object.entries(r))e.set(o,String(a));const n=e.toString()?`?${e.toString()}`:"",s=await this.kernel.request(`${$().pages(this.ref())}${n}`),i=(s.data??[]).map(t=>(this.kernel.rememberPage(t),new ht(t,this.kernel)));return ot(i,it(s,i.length))}async runAction(t){const e=String(t.uuid||"").trim();if(!e)throw new Error("Action uuid is required.");const r=String(this.record.domain||this.ref());return this.kernel.request($().action(r),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({uuid:e,method:t.method||"GET",path:t.path||"",query:t.query||{},body:t.body||"",headers:t.headers||{},params:t.params||{},post:t.post||{}})})}raw(){return{...this.record}}ref(){return String(this.record.uuid||this.record.domain||this.record.id||this.kernel.siteRef())}}let lt=null;function pt(){if(!lt)throw new Error("Client is not installed.");return lt}class ht{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}setRecord(t){"function"!=typeof this.source?this.source=t:this.kernel.rememberPage(t)}static async findByUlid(t,e){return bt(t,e)}static async find(t,e){return bt(t,e)}static async search(t,e,r){const n=gt(),s=ft(n,e),i=new URLSearchParams;i.set("q",t),mt(i,r);const o=await n.request(`${$().search(s)}?${i.toString()}`),a=(Array.isArray(o?.data)?o.data:Array.isArray(o)?o:[]).map(t=>(n.rememberPage(t),new ht(t,n)));return ot(a,it(o,a.length))}getTitle(){return new P(this.record.title)}getSubtitle(){return new C(this.record.subtitle)}getSmallTitle(){return new M(this.record.smalltitle)}getSummary(){return new T(this.record.summary)}getContent(){return new O(this.record.content)}getSlug(){return String(this.record.slug||"")}getUrl(){return new N(this.record.full_url||(this.record.slug?`/${this.record.slug}`:"/"))}getUuid(){return String(this.record.uuid||this.record.ulid||"")}getId(){return String(this.record.id||this.getUuid())}getLayout(){return String(this.record.layout||"")}getDisplay(){return String(this.record.display||"")}getDisplayInMenu(){const t=this.record.display_in_menu;return null==t||""===t||!1!==t&&0!==t&&"0"!==t}getSortOrder(){const t=Number(this.record.sort_order??0);return Number.isFinite(t)?t:0}getLang(){const t=String(this.record.lang||"").trim();if(t)return t;const e=this.kernel.snapshot().site;return String(e?.lang||function(t){return t&&"object"==typeof t?String(t.lang||""):""}(this.record.site)||"")}getOption(t){const e=[G(this.record.options,t),this.kernel.snapshot().options[t],G(this.kernel.snapshot().site?.options,t),G(wt(this.record.site),t)];for(const r of e)if(yt(r))return new U(t,r);return new U(t,"")}getSeo(){const t=this.seoBag(),e=t=>null==t?"":String(t),r=t=>{const e=D(t);return e?new Z(e,this.kernel):null};return{title:new B(t.title??this.record.title),description:new q(t.description??this.record.summary),keywords:e(t.keywords),robots:e(t.robots),canonical:new N(t.canonical),ogTitle:e(t.og_title??t.title??this.record.title),ogDescription:e(t.og_description??t.description??this.record.summary),ogImage:r(t.og_image),ogType:e(t.og_type),ogUrl:new N(t.og_url||t.canonical),twitterCard:e(t.twitter_card),twitterTitle:e(t.twitter_title??t.og_title??t.title),twitterDescription:e(t.twitter_description??t.og_description??t.description),twitterImage:r(t.twitter_image||t.og_image),ldJson:St(t.ld_json),raw:{...t}}}get collectionItem(){const t=this.record.collectionItem;return t&&"object"==typeof t?t:{}}get collectionItems(){const t=this.record.collectionItems;return t&&"object"==typeof t?t:{}}get collectionGallery(){return t=this.record.collectionGallery,e=this.kernel,Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new rt(t,e)):[];var t,e}collectionImage(){return nt(this.collectionItem,this.kernel)}getAssets(){return new Y(tt(this.record.assets,this.kernel))}getGallery(t){const e=t.trim();if(!e)return new Y([]);const r=[];return tt(this.record.assets,this.kernel).forEach((t,n)=>{const s=t.memberships().find(t=>function(t,e){const r=e.trim().toLocaleLowerCase();return!!r&&(t.uuid.toLocaleLowerCase()===r||t.name.toLocaleLowerCase()===r)}(t,e));s&&r.push({asset:t,sort:s.sort_order,index:n})}),r.sort((t,e)=>t.sort-e.sort||t.index-e.index),new Y(r.map(t=>t.asset))}getGalleries(){const t=tt(this.record.assets,this.kernel);return this.galleryList(t).map(t=>({id:t.id,uuid:t.uuid,name:t.name,description:t.description,sort_order:t.sort_order,assets:this.getGallery(t.uuid||t.name)}))}async getChildren(t){const e=function(t){if(!Array.isArray(t))return[];const e=new Set(["options","assets"]),r=[];for(const n of t){const t=String(n).trim().toLowerCase();e.has(t)&&!r.includes(t)&&r.push(t)}return r}(t?.with),r=Array.isArray(this.record.children)?this.record.children:null;if(r&&function(t,e){return!e.length||t.every(t=>{if(!t||"object"!=typeof t)return!1;const r=t;if(e.includes("options")){const t=r.options;if(null==t||"object"!=typeof t)return!1}return!(e.includes("assets")&&!Array.isArray(r.assets))})}(r,e)){const e=function(t,e,r){const n=t.length;if(!e&&!r)return{items:t,meta:{currentPage:1,lastPage:1,perPage:Math.max(n,1),total:n}};const s=r&&r>0?Math.floor(r):Math.max(n,1),i=e&&e>0?Math.floor(e):1,o=Math.max(1,Math.ceil(n/s)),a=(i-1)*s;return{items:t.slice(a,a+s),meta:{currentPage:i,lastPage:o,perPage:s,total:n}}}(this.rowsToPages(r),t?.page,t?.perPage);return ot(e.items,e.meta)}const n=this.getUuid()||String(this.record.id??"");if(!n){const t=r?this.rowsToPages(r):[];return ot(t,it(null,t.length))}const s=new URLSearchParams;s.set("parent",n),e.length&&s.set("with",e.join(",")),mt(s,t);const i=await this.kernel.request(`${$().pages(this.siteRef())}?${s.toString()}`);return ot(this.rowsToPages(i.data??[]),it(i,(i.data??[]).length))}async getSiblings(){if(Array.isArray(this.record.siblings))return this.record.siblings.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new ht(t,this.kernel));const t=this.record.parent_id,e=this.siteRef();if(null==t||""===t){const t=await this.kernel.request(`${$().pages(e)}?parent=root`);return this.excludeSelf(t.data??[])}const r=await this.kernel.request(`${$().pages(e)}?parent=${encodeURIComponent(String(t))}`);return this.excludeSelf(r.data??[])}async getParent(){if(this.record.parent&&"object"==typeof this.record.parent)return new ht(this.record.parent,this.kernel);const t=this.record.parent_id;return null==t||""===t?null:bt(String(t),this.siteRef())}async getAncestors(){if(Array.isArray(this.record.ancestors))return this.rowsToPages(this.record.ancestors);const t=this.embeddedAncestors();if(t.length){const e=t[0],r=e.raw().parent_id;return null==r||""===r||0===r?t:[...await e.fetchAncestors(),...t]}return this.fetchAncestors()}async getSite(){if(this.record.site&&"object"==typeof this.record.site)return new ut(this.record.site,this.kernel);const t=this.kernel.snapshot().site;if(t&&(String(t.id)===String(this.record.site_id)||!this.record.site_id))return new ut(t,this.kernel);const e=this.record.site_id?String(this.record.site_id):this.kernel.siteRef(),r=_(await this.kernel.request($().site(e)));return this.kernel.rememberSite(r),new ut(r,this.kernel)}async load(){return await this.ensure(["content","options","assets","children"]),this}raw(){return{...this.record}}seoBag(){const t=this.record.seo&&"object"==typeof this.record.seo?this.record.seo:this.kernel.snapshot().seo;return t&&"object"==typeof t?{...t}:{}}galleryList(t){if(Array.isArray(this.record.galleries))return this.record.galleries.flatMap(t=>{const e=Q(t);if(!e)return[];const r=t&&"object"==typeof t?String(t.description??""):"";return[{...e,description:r}]});const e=new Map;for(const r of t)for(const t of r.memberships()){const r=(t.uuid||t.name).toLocaleLowerCase();r&&!e.has(r)&&e.set(r,{...t,description:""})}return[...e.values()]}siteRef(){return this.record.site&&"object"==typeof this.record.site?w(this.record.site)||this.kernel.siteRef():this.record.site_id?String(this.record.site_id):this.kernel.siteRef()}rowsToPages(t){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new ht(t,this.kernel)):[]}embeddedAncestors(){const t=[],e=new Set;let r=this.record.parent;for(;r&&"object"==typeof r&&t.length<12;){const n=r,s=String(n.uuid||n.id||"");if(!s||e.has(s))break;e.add(s),t.unshift(new ht(n,this.kernel)),r=n.parent}return t}async fetchAncestors(){const t=[],e=new Set;let r=await this.getParent();for(;r&&t.length<12;){const n=r.getUuid()||String(r.raw().id??"");if(!n||e.has(n))break;e.add(n),t.unshift(r),r=await r.getParent()}return t}excludeSelf(t){const e=y(this.record);return t.filter(t=>y(t)!==e).map(t=>new ht(t,this.kernel))}async ensure(t){if(!t.some(t=>void 0===this.record[t]))return;const e=this.getUuid()||this.getSlug()||String(this.record.id||"");if(!e)return;const r=_(await this.kernel.request($().page(this.siteRef(),e)));this.setRecord({...this.record,...r})}}let dt=null;function gt(){if(!dt)throw new Error("Client is not installed.");return dt}function ft(t,e){return null!=e&&""!==String(e)?String(e):t.siteRef()}function mt(t,e){e?.page&&e.page>0&&t.set("page",String(Math.floor(e.page))),e?.perPage&&e.perPage>0&&t.set("per_page",String(Math.floor(e.perPage)))}function yt(t){if(null==t)return!1;if("string"==typeof t){const e=t.trim();return""!==e&&"{}"!==e&&"[]"!==e}return Array.isArray(t)?t.length>0:"object"!=typeof t||Object.keys(t).length>0}function wt(t){if(t&&"object"==typeof t)return t.options}function St(t){if("string"==typeof t)return t;if(t&&"object"==typeof t)try{return JSON.stringify(t)}catch{return""}return""}async function bt(t,e){const r=gt(),n=ft(r,e),s=_(await r.request($().page(n,t)));return r.rememberPage(s),new ht(s,r)}class $t{constructor(t,e=null){this.record=t,this.kernel=e}record;kernel;getTitle(){return new W(this.record.title)}getUrl(){return new N(this.record.url)}getChildren(){return _t(this.record.children,this.kernel)}isCurrent(t){const e=this.getUrl().path();if(!e)return!1;if(t)return e===t.getUrl().path();const r=this.kernel??jt,n=r?.snapshot().page;return!(!r||!n)&&e===new ht(n,r).getUrl().path()}getPage(){const t=this.record.page;if(!t||"object"!=typeof t)return null;const e=this.kernel??jt;return e?new ht(t,e):null}raw(){return{...this.record}}}class xt{constructor(t,e){this.source=t,this.runtime=e}source;runtime;get record(){return"function"==typeof this.source?this.source():this.source}static async find(t,e){const r=function(){if(!jt)throw new Error("Client is not installed.");return jt}(),n=null!=e&&""!==String(e)?String(e):r.siteRef(),s=r.snapshot().menus,i=s[t]||Object.values(s).find(e=>!!e&&(String(e.uuid)===t||String(e.id)===t||String(e.name)===t||String(e.position)===t));if(i)return new xt(i,r);const o=_(await r.request($().menu(n,t)));return r.rememberMenu(o),new xt(o,r)}getName(){return new W(this.record.name)}getPosition(){return String(this.record.position||"")}getItems(){return _t(this.record.items,this.runtime)}raw(){return{...this.record}}}function _t(t,e=null){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new $t(t,e)):[]}let jt=null;class kt{snap={page:null,site:null,menus:{},locales:[],seo:null,options:{}};options;inflight=new Map;cache=new Map;constructor(t={}){this.options=t,t.page&&this.hydrate(t.page),dt=this,lt=this,jt=this}hydrate(t){return this.snap=g(this.snap,function(t){const e={page:null,site:null,menus:{},locales:[],seo:null,options:{}};if(!t||"object"!=typeof t)return e;const r=t,n=f(r.props)?r.props:r;e.page=m(n.page),e.site=m(n.site),e.seo=f(n.seo)?n.seo:null,e.options=f(n.options)?n.options:{},e.locales=Array.isArray(n.locales)?n.locales:[];const s=n.menus;if(f(s))for(const[i,o]of Object.entries(s))e.menus[i]=m(o);return e}(t)),this.snap}snapshot(){return this.snap}apiBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=x();return e.apiBase?String(e.apiBase).replace(/\/+$/,""):function(){if("undefined"==typeof location)return"";const t=String(location.origin||"").replace(/\/+$/,"");if(t&&"null"!==t)return t;const e=location.hostname||"";return e?`${location.protocol}//${e}`:""}()}(this.options.apiBase)}siteBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=x();return e.siteBase?String(e.siteBase).replace(/\/+$/,""):"undefined"!=typeof location?location.origin:""}(this.options.siteBase)}siteRef(){return null!=this.options.site&&""!==String(this.options.site)?String(this.options.site):w(this.snap.site)}async request(t,e={}){const r=String(e.method||"GET").toUpperCase(),n=`${r} ${t}`;if("GET"===r&&this.cache.has(n))return this.cache.get(n);if("GET"===r){const t=this.inflight.get(n);if(t)return t}const s=this.apiBase();if(!s)throw new Error("Remote origin is not configured.");const i=async function(t,e,r={}){const{fetchImpl:n,...s}=r,i=e.startsWith("http")?e:b(t,e),o=n??fetch,a=new Headers(s.headers);a.has("Accept")||a.set("Accept","application/json");const c=await o(i,{...s,headers:a}),u=await c.text();let l=null;if(u)try{l=JSON.parse(u)}catch{l={message:u}}if(!c.ok){const t=new Error(`Request failed (${c.status})`);throw t.status=c.status,t.body=l,t}return l}(s,t,{...e,fetchImpl:this.options.fetch}).then(t=>("GET"===r&&this.cache.set(n,t),t));return"GET"===r&&(this.inflight.set(n,i),i.finally(()=>{this.inflight.delete(n)}).catch(()=>{})),i}rememberPage(t){const e=this.snap.page;e&&String(e.id)===String(t.id)&&(this.snap=g(this.snap,{page:{...e,...t}}))}rememberSite(t){this.snap=g(this.snap,{site:{...this.snap.site??{},...t}})}rememberMenu(t){const e=String(t.position||t.uuid||t.id||t.name||"menu");this.snap=g(this.snap,{menus:{[e]:t}})}}let At=null;function vt(t={}){return At=new kt(t),At}function Pt(){return At||(At=new kt),At}const Ct=Symbol.for("miro.client");function Mt(){return t.inject(Ct,null)??Pt()}function Tt(t={}){return{install(e,r={}){const n=vt({...t,...r});e.provide(Ct,n),e.component("MiroText",d),function(t){import("@inertiajs/vue3").then(e=>{const r=e.router;r?.page&&t.hydrate(r.page),r?.on?.("success",e=>{const r=e?.detail?.page;r&&t.hydrate(r)}),r?.on?.("navigate",e=>{const r=e?.detail?.page;r&&t.hydrate(r)})}).catch(()=>{})}(n)}}}const Ot=Tt();class Rt{constructor(t){this.kernel=t}kernel;all(){return function(t,e=function(){return globalThis}()){const r=Array.isArray(t)?t.flatMap(t=>function(t){if(!t||"object"!=typeof t)return[];const e=t,r=It(String(e.lang??""));return r?[{lang:r,domain:Nt(String(e.domain??"")),url:String(e.url??"").trim()}]:[]}(t)):[];return r.length?r.flatMap(t=>{const r=Ut(t.url||function(t,e){const r=e[`locale_${t}_baseurl`];return"string"==typeof r?r.trim():""}(t.lang,e)||t.domain);return t.lang&&r?[{lang:t.lang,domain:t.domain||Nt(r),url:r}]:[]}):function(t){const e=[];for(const r of Object.keys(t)){const n=/^locale_([a-z]+)_baseurl$/.exec(r);if(!n)continue;const s=Ut(String(t[r]??""));s&&e.push({lang:n[1],domain:Nt(s),url:s})}return e}(e)}(this.kernel.snapshot().locales)}current(){return It(String(this.kernel.snapshot().site?.lang||""))}url(t){const e=It(t),r=this.all().find(t=>t.lang===e);return r?.url??""}}function It(t){return(t.trim().toLowerCase().replaceAll("_","-").split("-")[0]??"").replace(/[^a-z]/g,"")}function Ut(t){const e=t.trim();return e?(/^https?:\/\//i.test(e)?e:`https://${e.replace(/^\/+/,"")}`).replace(/\/+$/,""):""}function Nt(t){return t.trim().replace(/^https?:\/\//i,"").replace(/\/.*$/,"")}function Wt(t){return`mc_${(String(t??"").trim().split("/").pop()??"").replace(/^@/,"").replace(/[^A-Za-z0-9]+/g,"_").replace(/^_+|_+$/g,"").toUpperCase()}`}function Lt(t){if("undefined"==typeof window||""===t)return"";const e=window.__MIRO_WEB_PLUGINS__;if(!Array.isArray(e))return"";for(const r of e){const e=String(r??"").trim().toLowerCase(),n=e.lastIndexOf("/");if(n<=0)continue;const s=e.slice(0,n),i=e.slice(n+1);if(""!==s&&(i===t||Bt(i)===t))return s}return""}function Bt(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[^A-Za-z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function qt(t){if("undefined"==typeof window)return{};const e=window[t];return e&&"object"==typeof e?e:{}}function Et(){const t=Mt(),e=function(){try{const t=globalThis.__INERTIA_PAGE__;if(t?.props)return t.props}catch{}return function(){if("undefined"==typeof document)return null;const t=document.querySelector("[data-page]")?.getAttribute("data-page");if(!t)return null;try{return JSON.parse(t).props??null}catch{return null}}()}();return e&&t.hydrate(e),t}function Gt(){const t=Et();return Dt(t),new ht(()=>t.snapshot().page??{},t)}function Dt(e){try{const r=function(){try{return zt??null}catch{return null}}();if(!r)return;const n=r.usePage();e.hydrate(t.unref(n))}catch{}}let zt=null;import("@inertiajs/vue3").then(t=>{zt=t}).catch(()=>{zt=null});const Jt=Ot;exports.Asset=Z,exports.AssetName=L,exports.CollectionCard=rt,exports.Gallery=Y,exports.Locales=Rt,exports.Menu=xt,exports.MenuItem=$t,exports.MenuTitle=W,exports.Miro=Ot,exports.MiroText=d,exports.OptionValue=U,exports.Page=ht,exports.PageContent=O,exports.PageSmallTitle=M,exports.PageSubtitle=C,exports.PageSummary=T,exports.PageTitle=P,exports.RICH_COLORS=e,exports.RICH_FONTS=r,exports.SDK_KEY=Ct,exports.SeoDescription=q,exports.SeoTitle=B,exports.Site=ut,exports.SiteName=I,exports.SiteTitle=R,exports.TextValue=v,exports.UrlValue=N,exports.createMiro=Tt,exports.createRuntime=vt,exports.default=Jt,exports.getRuntime=Pt,exports.parseRichText=o,exports.plainText=c,exports.pluginWindowKey=Wt,exports.useKernel=Mt,exports.useMiroAssets=function(){return Gt().getAssets()},exports.useMiroConfig=function(){const e=Mt();return{apiBase:t.computed(()=>e.apiBase()),siteBase:t.computed(()=>e.siteBase()),siteRef:t.computed(()=>e.siteRef())}},exports.useMiroLocales=function(){const t=Et();return Dt(t),new Rt(t)},exports.useMiroMenu=function(t="topbar"){const e=Et();return Dt(e),new xt(()=>e.snapshot().menus[t]??{position:t,items:[]},e)},exports.useMiroPage=Gt,exports.useMiroSite=function(){const t=Et();return Dt(t),new ut(()=>t.snapshot().site??{},t)},exports.usePlugin=function(t){return function(t,e){const r=Wt(t),n=function(t){const e=String(t??"").trim();if(e.includes("/")){const[t,...r]=e.split("/");return{vendor:t||"miroart",slug:Bt(r.join("/")||e)}}const r=Bt(e);return{vendor:Lt(r)||"miroart",slug:r}}(t);return new Proxy({name:t,key:r,ready:async()=>async function(t){const e=Date.now();for(;Date.now()-e<4e3;){const e=qt(t);if(Object.keys(e).length)return e;await new Promise(t=>setTimeout(t,50))}return qt(t)}(r),api:()=>qt(r),call:(t,...e)=>{const n=qt(r),s=n[t];if("function"!=typeof s)throw new Error(`Missing plugin method: ${t}`);return s.apply(n,e)},request:async(t="/",r={})=>{const s=$().plugins(n.vendor,n.slug,t||"/"),i=new Headers(r.headers);let o=r.body;return void 0!==r.json&&(o=JSON.stringify(r.json)),_(await e.request(s,{...r,headers:i,body:o}))}},{get(t,e,n){if(e in t)return Reflect.get(t,e,n);if("then"===e||e===Symbol.toStringTag)return;const s=qt(r),i=s[String(e)];return"function"==typeof i?i.bind(s):i},has:(t,e)=>e in t||e in qt(r)})}(t,Mt())};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import type { Plugin } from "vue";
|
|
2
2
|
import { createMiro, Miro, SDK_KEY, useKernel } from "./install";
|
|
3
|
-
import { Page } from "./page";
|
|
3
|
+
import { Page, type PageGallery, type PageListQuery, type PagedPages, type SeoView } from "./page";
|
|
4
4
|
import { Site } from "./site";
|
|
5
5
|
import { Menu, MenuItem } from "./menu";
|
|
6
|
-
import { Asset, Gallery } from "./asset";
|
|
6
|
+
import { Asset, Gallery, type GalleryMembership } from "./asset";
|
|
7
|
+
import { CollectionCard } from "./collection";
|
|
8
|
+
import { Locales, type LocaleLink } from "./locales";
|
|
9
|
+
import type { PageListMeta } from "./list";
|
|
7
10
|
import { createRuntime, getRuntime } from "./runtime";
|
|
8
|
-
import { useMiroAssets, useMiroConfig, useMiroMenu, useMiroPage, useMiroSite, usePlugin } from "./composables";
|
|
11
|
+
import { useMiroAssets, useMiroConfig, useMiroLocales, useMiroMenu, useMiroPage, useMiroSite, usePlugin } from "./composables";
|
|
9
12
|
import { AssetName, MenuTitle, OptionValue, PageContent, PageSmallTitle, PageSubtitle, PageSummary, PageTitle, SeoDescription, SeoTitle, SiteName, SiteTitle, TextValue, UrlValue } from "./values";
|
|
10
13
|
import { pluginWindowKey } from "./plugin";
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
import { MiroText } from "./MiroText";
|
|
15
|
+
import { parseRichText, plainText, RICH_COLORS, RICH_FONTS, type RichColor, type RichFont, type RichNode } from "./richText";
|
|
16
|
+
import type { ActionCall, ClientOptions } from "./types";
|
|
17
|
+
export { Asset, AssetName, MiroText, parseRichText, plainText, RICH_COLORS, RICH_FONTS, CollectionCard, createMiro, createRuntime, Gallery, getRuntime, Locales, Menu, MenuItem, MenuTitle, Miro, OptionValue, Page, PageContent, PageSmallTitle, PageSubtitle, PageSummary, PageTitle, pluginWindowKey, SDK_KEY, SeoDescription, SeoTitle, Site, SiteName, SiteTitle, TextValue, UrlValue, useKernel, useMiroAssets, useMiroConfig, useMiroLocales, useMiroMenu, useMiroPage, useMiroSite, usePlugin, };
|
|
18
|
+
export type { ActionCall, ClientOptions, GalleryMembership, LocaleLink, PageGallery, PageListMeta, PageListQuery, PagedPages, RichColor, RichFont, RichNode, SeoView, };
|
|
14
19
|
declare const plugin: Plugin;
|
|
15
20
|
export default plugin;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{inject as t,computed as e,unref as r}from"vue";function n(t,e){return{page:void 0!==e.page?e.page:t.page,site:void 0!==e.site?e.site:t.site,menus:e.menus?{...t.menus,...e.menus}:{...t.menus},locales:e.locales??t.locales,seo:void 0!==e.seo?e.seo:t.seo,options:e.options?{...t.options,...e.options}:{...t.options}}}function s(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)}function i(t){return s(t)?t:null}function o(t){return t?String(t.uuid||t.ulid||t.id||t.slug||t.full_url||""):""}function c(t){return t?String(t.uuid||t.domain||t.id||""):""}function u(t){return String.fromCharCode(...t.map(t=>23^t))}function a(t,e){const r=String(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return r?`${r}${n}`:n}function l(){const t=u([56,118,103,126]),e=u([97,38]),r=u([100,126,99,114,100]),n=u([103,118,112,114,100]),s=u([100,114,118,101,116,127]),i=u([122,114,121,98,100]),o=u([122,114,115,126,118]),c=u([103,123,98,112,126,121,100]);return{sites:()=>a("",`${t}/${e}/${r}`),site:n=>a("",`${t}/${e}/${r}/${encodeURIComponent(n)}`),pages:s=>a("",`${t}/${e}/${r}/${encodeURIComponent(s)}/${n}`),page:(s,i)=>a("",`${t}/${e}/${r}/${encodeURIComponent(s)}/${n}/${i.split("/").map(t=>encodeURIComponent(t)).join("/")}`),search:i=>a("",`${t}/${e}/${r}/${encodeURIComponent(i)}/${n}/${s}`),menus:n=>a("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${i}`),menu:(n,s)=>a("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${i}/${encodeURIComponent(s)}`),media:e=>a("",`${t}/${o}/${encodeURIComponent(e)}`),plugins:(e,r,n="")=>{const s=`${t}/${c}/${encodeURIComponent(e)}/${encodeURIComponent(r)}`;return n&&"/"!==n?`${s}${n.startsWith("/")?n:`/${n}`}`:s}}}function h(){if("undefined"==typeof globalThis)return{};const t=globalThis.MiroConfig;return t&&"object"==typeof t?t:{}}function p(t){return t&&"object"==typeof t&&"data"in t?t.data:t}function d(t){return null==t?"":"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):""}function g(t){const e=d(t);if(!e)return"";if("undefined"!=typeof document){const t=document.createElement("textarea");return t.innerHTML=e,t.value}return e.replace(/&#(\d+);/g,(t,e)=>String.fromCharCode(Number(e))).replace(/&#x([0-9a-f]+);/gi,(t,e)=>String.fromCharCode(parseInt(e,16))).replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function f(t){return g(t).replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi," ").replace(/<style[\s\S]*?>[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim()}class m extends String{kind;extra;constructor(t,e,r={}){super(g(e)),this.kind=t,this.extra=r,Object.setPrototypeOf(this,new.target.prototype)}toString(){return String.prototype.toString.call(this)}valueOf(){return String.prototype.valueOf.call(this)}raw(){return this.toString()}decode(){return g(this.toString())}cleanContent(){return f(this.toString())}stripHtml(){return this.cleanContent()}excerpt(t=160){const e=this.cleanContent();return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}firstParagraph(){return function(t){const e=g(t),r=e.match(/<p\b[^>]*>([\s\S]*?)<\/p>/i);return f(r?r[1]:e)}(this.toString())}isEmpty(){return""===this.cleanContent()}json(){const t=this.toString().trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}bool(){const t=this.toString().trim().toLowerCase();return"1"===t||"true"===t||"yes"===t||"on"===t}number(){const t=Number(this.toString().trim());return Number.isFinite(t)?t:null}}class y extends m{constructor(t){super("PageTitle",t)}}class S extends m{constructor(t){super("PageSubtitle",t)}}class w extends m{constructor(t){super("PageSmallTitle",t)}}class $ extends m{constructor(t){super("PageSummary",t)}}class b extends m{constructor(t){super("PageContent",t)}html(){return this.toString()}}class k extends m{constructor(t){super("SiteTitle",t)}}class R extends m{constructor(t){super("SiteName",t)}}class C extends m{key;constructor(t,e){super("OptionValue",v(e),{key:t}),this.key=t}present(){return!this.isEmpty()}}class j extends m{constructor(t){super("UrlValue",t)}path(){const t=this.toString().trim();if(!t)return"/";try{if(/^https?:\/\//i.test(t))return new URL(t).pathname.replace(/\/+$/,"")||"/"}catch{}return(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")||"/"}href(t=""){const e=this.path();return!t||/^https?:\/\//i.test(e)?e:`${String(t).replace(/\/+$/,"")}${e}`}}class A extends m{constructor(t){super("MenuTitle",t)}}class _ extends m{constructor(t){super("AssetName",t)}}class x extends m{constructor(t){super("SeoTitle",t)}}class U extends m{constructor(t){super("SeoDescription",t)}}function v(t){if(null==t)return"";if("boolean"==typeof t||"number"==typeof t)return String(t);if("string"==typeof t){const e=t.trim();if(""===e||"[]"===e||"{}"===e)return"";if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")||e.startsWith('"')&&e.endsWith('"'))try{return v(JSON.parse(e))}catch{return g(t)}return g(t)}return Array.isArray(t)?t.length?v(t[0]):"":"object"==typeof t&&null!==t&&"value"in t?v(t.value):d(t)}function B(t,e){if(!t)return"";if(Array.isArray(t)){const r=t.find(t=>t&&"object"==typeof t&&t.key===e);return r&&"object"==typeof r?r.value:""}return"object"==typeof t?t[e]:""}class I{constructor(t){this.record=t}record;getTitle(){return new A(this.record.title)}getUrl(){return new j(this.record.url)}getChildren(){return q(this.record.children)}raw(){return{...this.record}}}class P{constructor(t,e){this.source=t,this.runtime=e}source;runtime;get record(){return"function"==typeof this.source?this.source():this.source}static async find(t,e){const r=function(){if(!O)throw new Error("Client is not installed.");return O}(),n=null!=e&&""!==String(e)?String(e):r.siteRef(),s=r.snapshot().menus,i=s[t]||Object.values(s).find(e=>!!e&&(String(e.uuid)===t||String(e.id)===t||String(e.name)===t||String(e.position)===t));if(i)return new P(i,r);const o=p(await r.request(l().menu(n,t)));return r.rememberMenu(o),new P(o,r)}getName(){return new A(this.record.name)}getPosition(){return String(this.record.position||"")}getItems(){return q(this.record.items)}raw(){return{...this.record}}}function q(t){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new I(t)):[]}let O=null;const T=[{mark:"1_8",width:256},{mark:"1_4",width:512},{mark:"1_2",width:1024},{mark:"2_3",width:1400}];class E{constructor(t,e){this.record=t,this.runtime=e}record;runtime;getUuid(){return String(this.record.uuid||this.record.id||"")}getName(){return new _(this.record.name)}getMime(){return String(this.record.mime_type||"")}isImage(){return!!this.getMime().startsWith("image/")||/\.(jpe?g|png|gif|webp|svg)(\?|$)/i.test(this.urlString())}url(){return new j(this.urlString())}srcset(){const t=this.urlString();if(!t||/\.svg([?#]|$)/i.test(t)||/^https?:\/\//i.test(t)||t.startsWith("//"))return"";if(!/\.webp([?#]|$)/i.test(t)||/\.(?:1_16|1_8|1_4|1_2|2_3)\.webp([?#]|$)/i.test(t))return"";const e=T.map(({mark:e,width:r})=>`${t.replace(/\.webp([?#].*)?$/i,`.${e}.webp$1`)} ${r}w`);return e.push(`${t} 2048w`),e.join(", ")}raw(){return{...this.record}}urlString(){const t=String(this.record.url||this.record.path||"");if(t)return t;const e=this.getUuid();if(!e)return"";const r=l().media(e),n=this.runtime.apiBase();return n?a(n,r):r}}class N{constructor(t){this.items=t}items;all(){return this.items.slice()}first(){return this.items[0]??null}extra(){return this.items.slice(1)}hero(){return this.first()}urls(){return this.items.map(t=>t.url())}isEmpty(){return 0===this.items.length}count(){return this.items.length}[Symbol.iterator](){return this.items[Symbol.iterator]()}}class M{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}static async find(t){const e=function(){if(!W)throw new Error("Client is not installed.");return W}(),r=null!=t&&""!==String(t)?String(t):e.siteRef(),n=e.snapshot().site;if(n&&(!t||String(n.uuid)===String(t)||String(n.id)===String(t)||String(n.domain)===String(t)||c(n)===String(t)))return new M(n,e);const s=p(await e.request(l().site(r)));return e.rememberSite(s),new M(s,e)}static async findPage(t,e){return L.find(t,e)}static async findMenu(t,e){return P.find(t,e)}getName(){return new R(this.record.name)}getTitle(){const t=B(this.record.options,"seo_title")||B(this.record.options,"title");return new k(t||this.record.name)}getDomain(){return String(this.record.domain||"")}getLang(){return String(this.record.lang||"")}getUuid(){return String(this.record.uuid||"")}getOption(t){return new C(t,B(this.record.options,t))}async findPage(t){return L.find(t,this.ref())}async findMenu(t){return P.find(t,this.ref())}async menus(){const t=this.kernel.snapshot().menus,e=Object.values(t).filter(Boolean);return e.length?e.map(t=>new P(t,this.kernel)):((await this.kernel.request(l().menus(this.ref()))).data??[]).map(t=>(this.kernel.rememberMenu(t),new P(t,this.kernel)))}async pages(t={}){const e=new URLSearchParams;for(const[n,s]of Object.entries(t))e.set(n,String(s));const r=e.toString()?`?${e.toString()}`:"";return((await this.kernel.request(`${l().pages(this.ref())}${r}`)).data??[]).map(t=>(this.kernel.rememberPage(t),new L(t,this.kernel)))}raw(){return{...this.record}}ref(){return String(this.record.uuid||this.record.domain||this.record.id||this.kernel.siteRef())}}let W=null;class L{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}setRecord(t){"function"!=typeof this.source?this.source=t:this.kernel.rememberPage(t)}static async findByUlid(t,e){return z(t,e)}static async find(t,e){return z(t,e)}static async search(t,e){const r=H(),n=J(r,e),s=`${l().search(n)}?q=${encodeURIComponent(t)}`,i=await r.request(s);return(Array.isArray(i?.data)?i.data:Array.isArray(i)?i:[]).map(t=>(r.rememberPage(t),new L(t,r)))}getTitle(){return new y(this.record.title)}getSubtitle(){return new S(this.record.subtitle)}getSmallTitle(){return new w(this.record.smalltitle)}getSummary(){return new $(this.record.summary)}getContent(){return new b(this.record.content)}getSlug(){return String(this.record.slug||"")}getUrl(){return new j(this.record.full_url||(this.record.slug?`/${this.record.slug}`:"/"))}getUuid(){return String(this.record.uuid||this.record.ulid||"")}getId(){return String(this.record.id||this.getUuid())}getLayout(){return String(this.record.layout||"")}getDisplay(){return String(this.record.display||"")}getOption(t){const e=B(this.record.options,t);if(null!=e&&""!==e)return new C(t,e);const r=this.kernel.snapshot().options[t];return new C(t,r)}getSeo(){const t=(this.record.seo&&"object"==typeof this.record.seo?this.record.seo:this.kernel.snapshot().seo)??{};return{title:new x(t.title??this.record.title),description:new U(t.description??this.record.summary),raw:{...t}}}getAssets(){return new N((t=this.record.assets,e=this.kernel,Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new E(t,e)):[]));var t,e}async getChildren(){return await this.ensure(["children"]),(Array.isArray(this.record.children)?this.record.children:[]).filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new L(t,this.kernel))}async getSiblings(){if(Array.isArray(this.record.siblings))return this.record.siblings.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new L(t,this.kernel));const t=this.record.parent_id,e=this.siteRef();if(null==t||""===t){const t=await this.kernel.request(`${l().pages(e)}?parent=root`);return this.excludeSelf(t.data??[])}const r=await this.kernel.request(`${l().pages(e)}?parent=${encodeURIComponent(String(t))}`);return this.excludeSelf(r.data??[])}async getParent(){if(this.record.parent&&"object"==typeof this.record.parent)return new L(this.record.parent,this.kernel);const t=this.record.parent_id;return null==t||""===t?null:z(String(t),this.siteRef())}async getSite(){if(this.record.site&&"object"==typeof this.record.site)return new M(this.record.site,this.kernel);const t=this.kernel.snapshot().site;if(t&&(String(t.id)===String(this.record.site_id)||!this.record.site_id))return new M(t,this.kernel);const e=this.record.site_id?String(this.record.site_id):this.kernel.siteRef(),r=p(await this.kernel.request(l().site(e)));return this.kernel.rememberSite(r),new M(r,this.kernel)}async load(){return await this.ensure(["content","options","assets","children"]),this}raw(){return{...this.record}}siteRef(){return this.record.site&&"object"==typeof this.record.site?c(this.record.site)||this.kernel.siteRef():this.record.site_id?String(this.record.site_id):this.kernel.siteRef()}excludeSelf(t){const e=o(this.record);return t.filter(t=>o(t)!==e).map(t=>new L(t,this.kernel))}async ensure(t){if(!t.some(t=>void 0===this.record[t]))return;const e=this.getUuid()||this.getSlug()||String(this.record.id||"");if(!e)return;const r=p(await this.kernel.request(l().page(this.siteRef(),e)));this.setRecord({...this.record,...r})}}let D=null;function H(){if(!D)throw new Error("Client is not installed.");return D}function J(t,e){return null!=e&&""!==String(e)?String(e):t.siteRef()}async function z(t,e){const r=H(),n=J(r,e),s=p(await r.request(l().page(n,t)));return r.rememberPage(s),new L(s,r)}class Z{snap={page:null,site:null,menus:{},locales:[],seo:null,options:{}};options;constructor(t={}){this.options=t,t.page&&this.hydrate(t.page),D=this,W=this,O=this}hydrate(t){return this.snap=n(this.snap,function(t){const e={page:null,site:null,menus:{},locales:[],seo:null,options:{}};if(!t||"object"!=typeof t)return e;const r=t,n=s(r.props)?r.props:r;e.page=i(n.page),e.site=i(n.site),e.seo=s(n.seo)?n.seo:null,e.options=s(n.options)?n.options:{},e.locales=Array.isArray(n.locales)?n.locales:[];const o=n.menus;if(s(o))for(const[s,c]of Object.entries(o))e.menus[s]=i(c);return e}(t)),this.snap}snapshot(){return this.snap}apiBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=h();if(e.apiBase)return String(e.apiBase).replace(/\/+$/,"");if("undefined"==typeof location)return"";const r=location.hostname.replace(/^www\./i,"");return r&&"localhost"!==r&&"127.0.0.1"!==r?`${location.protocol}//api.${r}`:""}(this.options.apiBase)}siteBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=h();return e.siteBase?String(e.siteBase).replace(/\/+$/,""):"undefined"!=typeof location?location.origin:""}(this.options.siteBase)}siteRef(){return null!=this.options.site&&""!==String(this.options.site)?String(this.options.site):c(this.snap.site)}async request(t,e={}){const r=this.apiBase();if(!r)throw new Error("Remote origin is not configured.");return async function(t,e,r={}){const{fetchImpl:n,...s}=r,i=e.startsWith("http")?e:a(t,e),o=n??fetch,c=new Headers(s.headers);c.has("Accept")||c.set("Accept","application/json");const u=await o(i,{...s,headers:c}),l=await u.text();let h=null;if(l)try{h=JSON.parse(l)}catch{h={message:l}}if(!u.ok){const t=new Error(`Request failed (${u.status})`);throw t.status=u.status,t.body=h,t}return h}(r,t,{...e,fetchImpl:this.options.fetch})}rememberPage(t){const e=this.snap.page;e&&String(e.id)===String(t.id)&&(this.snap=n(this.snap,{page:{...e,...t}}))}rememberSite(t){this.snap=n(this.snap,{site:{...this.snap.site??{},...t}})}rememberMenu(t){const e=String(t.position||t.uuid||t.id||t.name||"menu");this.snap=n(this.snap,{menus:{[e]:t}})}}let V=null;function F(t={}){return V=new Z(t),V}function G(){return V||(V=new Z),V}const K=/* @__PURE__ */Symbol.for("miro.client");function Q(){return t(K,null)??G()}function X(t={}){return{install(e,r={}){const n=F({...t,...r});e.provide(K,n),function(t){import("@inertiajs/vue3").then(e=>{const r=e.router;r?.on?.("success",e=>{const r=e?.detail?.page;r&&t.hydrate(r)}),r?.on?.("navigate",e=>{const r=e?.detail?.page;r&&t.hydrate(r)})}).catch(()=>{})}(n)}}}const Y=X();function tt(t){return`mc_${(String(t??"").trim().split("/").pop()??"").replace(/^@/,"").replace(/[^A-Za-z0-9]+/g,"_").replace(/^_+|_+$/g,"").toUpperCase()}`}function et(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[^A-Za-z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function rt(t){if("undefined"==typeof window)return{};const e=window[t];return e&&"object"==typeof e?e:{}}function nt(){const t=Q(),e=function(){try{const t=globalThis.__INERTIA_PAGE__;if(t?.props)return t.props}catch{}return null}();return e&&t.hydrate(e),t}function st(){const t=nt();return lt(t),new L(()=>t.snapshot().page??{},t)}function it(){const t=nt();return lt(t),new M(()=>t.snapshot().site??{},t)}function ot(t="topbar"){const e=nt();return lt(e),new P(()=>e.snapshot().menus[t]??{position:t,items:[]},e)}function ct(){return st().getAssets()}function ut(t){return function(t,e){const r=tt(t),n=function(t){const e=String(t??"").trim();if(e.includes("/")){const[t,...r]=e.split("/");return{vendor:t||"miroart",slug:et(r.join("/")||e)}}return{vendor:"miroart",slug:et(e)}}(t);return new Proxy({name:t,key:r,ready:async()=>async function(t){const e=Date.now();for(;Date.now()-e<4e3;){const e=rt(t);if(Object.keys(e).length)return e;await new Promise(t=>setTimeout(t,50))}return rt(t)}(r),api:()=>rt(r),call:(t,...e)=>{const n=rt(r),s=n[t];if("function"!=typeof s)throw new Error(`Missing plugin method: ${t}`);return s.apply(n,e)},request:async(t="/",r={})=>{const s=l().plugins(n.vendor,n.slug,t||"/"),i=new Headers(r.headers);let o=r.body;return void 0!==r.json&&(o=JSON.stringify(r.json)),p(await e.request(s,{...r,headers:i,body:o}))}},{get(t,e,n){if(e in t)return Reflect.get(t,e,n);if("then"===e||e===Symbol.toStringTag)return;const s=rt(r),i=s[String(e)];return"function"==typeof i?i.bind(s):i},has:(t,e)=>e in t||e in rt(r)})}(t,Q())}function at(){const t=Q();return{apiBase:e(()=>t.apiBase()),siteBase:e(()=>t.siteBase()),siteRef:e(()=>t.siteRef())}}function lt(t){try{const e=function(){try{return ht??null}catch{return null}}();if(!e)return;const n=e.usePage();t.hydrate(r(n))}catch{}}let ht=null;import("@inertiajs/vue3").then(t=>{ht=t}).catch(()=>{ht=null});const pt=Y;export{E as Asset,_ as AssetName,N as Gallery,P as Menu,I as MenuItem,A as MenuTitle,Y as Miro,C as OptionValue,L as Page,b as PageContent,w as PageSmallTitle,S as PageSubtitle,$ as PageSummary,y as PageTitle,K as SDK_KEY,U as SeoDescription,x as SeoTitle,M as Site,R as SiteName,k as SiteTitle,m as TextValue,j as UrlValue,X as createMiro,F as createRuntime,pt as default,G as getRuntime,tt as pluginWindowKey,Q as useKernel,ct as useMiroAssets,at as useMiroConfig,ot as useMiroMenu,st as useMiroPage,it as useMiroSite,ut as usePlugin};
|
|
1
|
+
import{toDisplayString as t,h as e,inject as r,computed as n,unref as i}from"vue";const s=["primary","secondary","accent","neutral","base-100","base-content","info","success","warning","error"],o=["sans","serif"],c=/\\(\[\/?(?:b|i|u|s|c|f)(?:=[a-z0-9-]+)?\])|\[(\/?)(b|i|u|s|c|f)(?:=([a-z0-9-]+))?\]/g;function a(t,e){return"c"===t?s.includes(e??""):"f"===t?o.includes(e??""):void 0===e}function u(t,e){""!==e&&e.split(/\r?\n/).forEach((e,r)=>{if(r>0&&t.push({type:"br"}),""===e)return;const n=t[t.length-1];"text"===n?.type?n.value+=e:t.push({type:"text",value:e})})}function l(t){const e=String(t??""),r=[],n=[],i=()=>n[n.length-1]?.children??r,s=()=>{var t,e;t=n.pop(),e=i(),0!==t.children.length&&("c"===t.tag?e.push({type:"c",value:t.value,children:t.children}):"f"===t.tag?e.push({type:"f",value:t.value,children:t.children}):e.push({type:t.tag,children:t.children}))};let o,l=0;for(c.lastIndex=0;null!==(o=c.exec(e));){u(i(),e.slice(l,o.index)),l=c.lastIndex;const[t,r,h,p,d]=o;if(void 0===r){if("/"===h){const e=void 0===d?n.map(t=>t.tag).lastIndexOf(p):-1;if(-1===e){u(i(),t);continue}for(;n.length>e;)s();continue}!a(p,d)||n.length>=8?u(i(),t):n.push({tag:p,value:d??null,children:[]})}else u(i(),r)}for(u(i(),e.slice(l));n.length>0;)s();return r}function h(t,e){for(const r of t)"text"===r.type?e.push(r.value):"br"===r.type?e.push("\n"):h(r.children,e)}function p(t){const e=String(t??"");if(!e.includes("["))return e;const r=[];return h(l(e),r),r.join("")}const d=/[][]+/,g={b:"strong",i:"em",u:"u",s:"s"};function f(t){switch(t.type){case"text":return t.value;case"br":return e("br");case"c":return e("span",{style:{color:`var(--color-${t.value})`}},m(t.children));case"f":return e("span",{style:{fontFamily:`var(--font-${t.value})`}},m(t.children));default:return e(g[t.type],m(t.children))}}function m(t){return t.map(f)}const y=r=>{const n=t(r.value),i=d.test(n);if(!i&&!function(t){return t.includes("[")||t.includes("\n")}(n))return n;const s=m(l(n));return i?e("span",{"data-miro-rich":"",style:{display:"contents"}},s):1===s.length?s[0]:s};function w(t,e){return{page:void 0!==e.page?e.page:t.page,site:void 0!==e.site?e.site:t.site,menus:e.menus?{...t.menus,...e.menus}:{...t.menus},locales:e.locales??t.locales,seo:void 0!==e.seo?e.seo:t.seo,options:e.options?{...t.options,...e.options}:{...t.options}}}function S(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)}function b(t){return S(t)?t:null}function $(t){return t?String(t.uuid||t.ulid||t.id||t.slug||t.full_url||""):""}function _(t){return t?String(t.uuid||t.domain||t.id||""):""}function k(t){return String.fromCharCode(...t.map(t=>23^t))}function j(t,e){const r=String(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return r?`${r}${n}`:n}function A(){const t=k([56,118,103,126]),e=k([97,38]),r=k([100,126,99,114,100]),n=k([103,118,112,114,100]),i=k([100,114,118,101,116,127]),s=k([122,114,121,98,100]),o=k([122,114,115,126,118]),c=k([103,123,98,112,126,121,100]),a=k([118,116,99,126,120,121,100]);return{sites:()=>j("",`${t}/${e}/${r}`),site:n=>j("",`${t}/${e}/${r}/${encodeURIComponent(n)}`),pages:i=>j("",`${t}/${e}/${r}/${encodeURIComponent(i)}/${n}`),page:(i,s)=>j("",`${t}/${e}/${r}/${encodeURIComponent(i)}/${n}/${s.split("/").map(t=>encodeURIComponent(t)).join("/")}`),search:s=>j("",`${t}/${e}/${r}/${encodeURIComponent(s)}/${n}/${i}`),menus:n=>j("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${s}`),menu:(n,i)=>j("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${s}/${encodeURIComponent(i)}`),media:e=>j("",`${t}/${o}/${encodeURIComponent(e)}`),action:e=>j("",`${t}/${a}/${encodeURIComponent(e)}`),plugins:(e,r,n="")=>{const i=`${t}/${c}/${encodeURIComponent(e)}/${encodeURIComponent(r)}`;return n&&"/"!==n?`${i}${n.startsWith("/")?n:`/${n}`}`:i}}}function v(){if("undefined"==typeof globalThis)return{};const t=globalThis.MiroConfig;return t&&"object"==typeof t?t:{}}function x(t){return t&&"object"==typeof t&&"data"in t?t.data:t}function P(t){return null==t?"":"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):""}function C(t){const e=P(t);if(!e)return"";if("undefined"!=typeof document){const t=document.createElement("textarea");return t.innerHTML=e,t.value}return e.replace(/&#(\d+);/g,(t,e)=>String.fromCharCode(Number(e))).replace(/&#x([0-9a-f]+);/gi,(t,e)=>String.fromCharCode(parseInt(e,16))).replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function R(t){return p(C(t)).replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi," ").replace(/<style[\s\S]*?>[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim()}y.props=["value"],y.displayName="MiroText";class U extends String{kind;extra;constructor(t,e,r={}){super(C(e)),this.kind=t,this.extra=r,Object.setPrototypeOf(this,new.target.prototype)}toString(){return String.prototype.toString.call(this)}valueOf(){return String.prototype.valueOf.call(this)}raw(){return this.toString()}decode(){return C(this.toString())}cleanContent(){return R(this.toString())}stripHtml(){return this.cleanContent()}plain(){return p(this.toString())}excerpt(t=160){const e=this.cleanContent();return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}firstParagraph(){return function(t){const e=C(t),r=e.match(/<p\b[^>]*>([\s\S]*?)<\/p>/i);return R(r?r[1]:e)}(this.toString())}isEmpty(){return""===this.cleanContent()}json(){const t=this.toString().trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}bool(){const t=this.toString().trim().toLowerCase();return"1"===t||"true"===t||"yes"===t||"on"===t}number(){const t=Number(this.toString().trim());return Number.isFinite(t)?t:null}}class I extends U{constructor(t){super("PageTitle",t)}}class T extends U{constructor(t){super("PageSubtitle",t)}}class M extends U{constructor(t){super("PageSmallTitle",t)}}class N extends U{constructor(t){super("PageSummary",t)}}class O extends U{constructor(t){super("PageContent",t)}html(){return this.toString()}}class W extends U{constructor(t){super("SiteTitle",t)}}class B extends U{constructor(t){super("SiteName",t)}}class L extends U{key;structured;constructor(t,e){const r=D(e);super("OptionValue",r.text,{key:t}),this.key=t,this.structured=r.structured}json(){return void 0!==this.structured?this.structured:super.json()}present(){return!this.isEmpty()}}class q extends U{constructor(t){super("UrlValue",t)}path(){const t=this.toString().trim();if(!t)return"/";try{if(/^https?:\/\//i.test(t))return new URL(t).pathname.replace(/\/+$/,"")||"/"}catch{}return(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")||"/"}href(t=""){const e=this.path();return!t||/^https?:\/\//i.test(e)?e:`${String(t).replace(/\/+$/,"")}${e}`}}class E extends U{constructor(t){super("MenuTitle",t)}}class G extends U{constructor(t){super("AssetName",t)}}class z extends U{constructor(t){super("SeoTitle",t)}}class J extends U{constructor(t){super("SeoDescription",t)}}function D(t){if(null==t)return{text:""};if("boolean"==typeof t||"number"==typeof t)return{text:String(t)};if("string"==typeof t){const e=t.trim();if(""===e||"[]"===e||"{}"===e)return{text:""};if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")||e.startsWith('"')&&e.endsWith('"'))try{return D(JSON.parse(e))}catch{return{text:C(t)}}return{text:C(t)}}return Array.isArray(t)?{text:JSON.stringify(t),structured:t}:"object"==typeof t?function(t){return"value"in t&&Object.keys(t).every(t=>"value"===t||"key"===t||"id"===t||"active"===t)}(t)?D(t.value):{text:JSON.stringify(t),structured:t}:{text:P(t)}}function F(t,e){if(!t)return"";if(Array.isArray(t)){const r=t.find(t=>t&&"object"==typeof t&&t.key===e);return r&&"object"==typeof r?r.value:""}return"object"==typeof t?t[e]:""}function H(t){if("string"==typeof t){const e=t.trim();return e?X(e)?{uuid:e}:{url:e,path:e}:null}if(!t||"object"!=typeof t||Array.isArray(t))return null;const e=t,r=K(e.source),n=Z(e.url,e.preview_url,e.path,e.src,r?.url,r?.preview_url,r?.path),i=Z(e.uuid,r?.uuid);if(n||i&&X(i))return e;const s=Z(e.value);return s?H(s):null}function Z(...t){for(const e of t)if("string"==typeof e&&""!==e.trim())return e.trim();return""}function V(t){return"string"==typeof t?t.trim():""}function K(t){return!t||"object"!=typeof t||Array.isArray(t)?null:t}function Q(t){return t.startsWith("/media/")||t.startsWith("/_images/")||t.startsWith("/api/media/")||t.startsWith("/branding-assets/")||t.startsWith("/storage/")}function X(t){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)}const Y=[{mark:"1_8",width:256},{mark:"1_4",width:512},{mark:"1_2",width:1024},{mark:"2_3",width:1400}];class tt{constructor(t,e){this.record=t,this.runtime=e}record;runtime;getUuid(){return String(this.record.uuid||this.record.id||"")}getName(){return new G(this.record.name)}getAlt(){return V(this.record.alt)}getCaption(){return V(this.record.caption)}getGallery(){return this.memberships()[0]??null}galleryUuid(){return this.memberships()[0]?.uuid??""}galleryName(){return this.memberships()[0]?.name??""}memberships(){const t=this.record.galleries;if(Array.isArray(t)&&t.length>0)return t.map(t=>rt(t)).filter(t=>null!==t);const e=String(this.record.gallery_uuid??"").trim(),r=String(this.record.gallery_name??"").trim();if(!e&&!r)return[];const n=this.record.gallery_id;return[{id:"number"==typeof n||"string"==typeof n?n:null,uuid:e,name:r,sort_order:nt(this.record.gallery_sort_order)}]}getMime(){const t=K(this.record.source);return String(this.record.mime_type||t?.mime_type||"")}getSize(){const t=K(this.record.source),e=Number(this.record.size??t?.size??0);return Number.isFinite(e)?e:0}getType(){const t=V(this.record.type);if(t)return t;const e=this.getMime();return e.startsWith("image/")?"image":e.startsWith("video/")?"video":"application/pdf"===e?"pdf":""}getSortOrder(){const t=Number(this.record.sort_order??0);return Number.isFinite(t)?t:0}isImage(){return!!this.getMime().startsWith("image/")||/\.(jpe?g|png|gif|webp|svg)(\?|$)/i.test(this.urlString())}url(){return new q(this.urlString())}srcset(){const t=this.urlString();if(!t||/\.svg([?#]|$)/i.test(t)||/^https?:\/\//i.test(t)||t.startsWith("//"))return"";if(!/\.webp([?#]|$)/i.test(t)||/\.(?:1_16|1_8|1_4|1_2|2_3)\.webp([?#]|$)/i.test(t))return"";const e=Y.map(({mark:e,width:r})=>`${t.replace(/\.webp([?#].*)?$/i,`.${e}.webp$1`)} ${r}w`);return e.push(`${t} 2048w`),e.join(", ")}raw(){return{...this.record}}urlString(){const t=K(this.record.source),e=Z(this.record.uuid,t?.uuid),r=Z(this.record.disk,t?.disk);let n=Z(this.record.url,this.record.preview_url,this.record.path,this.record.src,t?.url,t?.preview_url,t?.path);if(e&&X(e)&&n&&function(t,e){return!!(/\/project-storage\//i.test(r=t)||/\/editor\/project-file/i.test(r)||/cms\.miroart\.pl/i.test(r)&&/\/(?:project-storage|storage)\//i.test(r))||"project_public"===e&&!Q(t)&&!/^https?:\/\//i.test(t)&&!t.startsWith("//");var r}(n,r))return this.mediaUrl(e);if(!n)return e&&X(e)?this.mediaUrl(e):"";if(!0===globalThis.isSsg){if(n.startsWith("/_images/")||n.startsWith("_images/"))return n.startsWith("/")?n:`/${n}`;const e=function(t){const e=t.match(/[?&]path=([^&]+)/i);if(e)try{const t=decodeURIComponent(e[1].replace(/\+/g," ")).split(/[/\\]/).pop()||"";if(t&&"project-file"!==t.toLowerCase())return t.trim()}catch{}return(t.split("#")[0].split("?")[0].split(/[/\\]/).pop()||"").trim()}(Z(t?.path,this.record.path,n)),r=/\.(jpe?g|png|gif|webp|svg)$/i.test(i=e)?/\.svg$/i.test(i)?`/_images/${i}`:`/_images/${i.replace(/\.(jpe?g|png|gif|webp)$/i,".webp")}`:null;if(r)return r}var i;if(/^https?:\/\//i.test(n)||n.startsWith("//"))return n;if(n.startsWith("_images/"))return`/${n}`;if(Q(n))return n;n.includes("/")||n.includes("\\")||X(n)||(n=`images/${n}`);const s=n.startsWith("/")?n:`/${n}`;return Q(s)||s.startsWith("/project-storage/")?s:`/storage${s}`}mediaUrl(t){const e=A().media(t),r=this.runtime.apiBase();return r?j(r,e):e}}class et{constructor(t){this.items=t}items;all(){return this.items.slice()}first(){return this.items[0]??null}extra(){return this.items.slice(1)}hero(){return this.first()}urls(){return this.items.map(t=>t.url())}isEmpty(){return 0===this.items.length}count(){return this.items.length}[Symbol.iterator](){return this.items[Symbol.iterator]()}}function rt(t){if(!t||"object"!=typeof t)return null;const e=t,r=String(e.uuid??"").trim(),n=String(e.name??"").trim();if(!r&&!n)return null;const i=e.id;return{id:"number"==typeof i||"string"==typeof i?i:null,uuid:r,name:n,sort_order:nt(e.sort_order)}}function nt(t){const e=Number(t??0);return Number.isFinite(e)?e:0}function it(t,e){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new tt(t,e)):[]}const st=/* @__PURE__ */new Set(["id","uuid","created_at","updated_at"]);class ot{constructor(t,e){this.row=t,this.kernel=e}row;kernel;getHref(){return new q(this.row.href)}getTitle(){return String(this.row.title??"")}item(){const t=this.row.item;return t&&"object"==typeof t?t:{}}image(){return ct(this.item(),this.kernel)}}function ct(t,e){if(!t||"object"!=typeof t)return null;for(const[r,n]of Object.entries(t)){if(st.has(r)||"string"!=typeof n||!at(n))continue;const t=H(n);if(t)return new tt(t,e)}return null}function at(t){const e=t.trim();return!!e&&(!!(e.startsWith("/media/")||e.startsWith("/_images/")||e.startsWith("_images/")||e.startsWith("/api/media/")||e.startsWith("/branding-assets/"))||/\.(jpe?g|png|gif|webp|svg)(\?|#|$)/i.test(e))}function ut(t,e){const r=t&&"object"==typeof t?t.meta:null,n=r&&"object"==typeof r?r:{};return{currentPage:ht(n.current_page,1),lastPage:ht(n.last_page,1),perPage:ht(n.per_page,Math.max(e,1)),total:pt(n.total,e)}}function lt(t,e){return Object.assign(t,{meta:e})}function ht(t,e){const r=Number(t);return!Number.isFinite(r)||r<1?e:Math.floor(r)}function pt(t,e){if(null==t||""===t)return e;const r=Number(t);return!Number.isFinite(r)||r<0?e:Math.floor(r)}class dt{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}static async all(){const t=ft(),e=await t.request(A().sites());return(Array.isArray(e?.data)?e.data:[]).filter(t=>Boolean(t)&&"object"==typeof t).map(e=>new dt(e,t))}static async find(t){const e=ft(),r=null!=t&&""!==String(t)?String(t):e.siteRef(),n=e.snapshot().site;if(n&&(!t||String(n.uuid)===String(t)||String(n.id)===String(t)||String(n.domain)===String(t)||_(n)===String(t)))return new dt(n,e);const i=x(await e.request(A().site(r)));return e.rememberSite(i),new dt(i,e)}static async findPage(t,e){return mt.find(t,e)}static async findMenu(t,e){return vt.find(t,e)}getName(){return new B(this.record.name)}getTitle(){const t=F(this.record.options,"seo_title")||F(this.record.options,"title");return new W(t||this.record.name)}getDomain(){return String(this.record.domain||"")}getLang(){return String(this.record.lang||"")}getUuid(){return String(this.record.uuid||"")}getOption(t){return new L(t,F(this.record.options,t))}getImage(t){const e=this.getOption(t),r=e.json(),n=null==r?e.toString().trim():r;if(null==n||""===n)return null;const i=H(n);return i?new tt(i,this.kernel):null}async findPage(t){return mt.find(t,this.ref())}async findMenu(t){return vt.find(t,this.ref())}async menus(){const t=this.kernel.snapshot().menus,e=Object.values(t).filter(Boolean);return e.length?e.map(t=>new vt(t,this.kernel)):((await this.kernel.request(A().menus(this.ref()))).data??[]).map(t=>(this.kernel.rememberMenu(t),new vt(t,this.kernel)))}async pages(t={}){const e=new URLSearchParams,r={...t};null!=r.perPage&&null==r.per_page&&(r.per_page=r.perPage,delete r.perPage);for(const[o,c]of Object.entries(r))e.set(o,String(c));const n=e.toString()?`?${e.toString()}`:"",i=await this.kernel.request(`${A().pages(this.ref())}${n}`),s=(i.data??[]).map(t=>(this.kernel.rememberPage(t),new mt(t,this.kernel)));return lt(s,ut(i,s.length))}async runAction(t){const e=String(t.uuid||"").trim();if(!e)throw new Error("Action uuid is required.");const r=String(this.record.domain||this.ref());return this.kernel.request(A().action(r),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({uuid:e,method:t.method||"GET",path:t.path||"",query:t.query||{},body:t.body||"",headers:t.headers||{},params:t.params||{},post:t.post||{}})})}raw(){return{...this.record}}ref(){return String(this.record.uuid||this.record.domain||this.record.id||this.kernel.siteRef())}}let gt=null;function ft(){if(!gt)throw new Error("Client is not installed.");return gt}class mt{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}setRecord(t){"function"!=typeof this.source?this.source=t:this.kernel.rememberPage(t)}static async findByUlid(t,e){return jt(t,e)}static async find(t,e){return jt(t,e)}static async search(t,e,r){const n=wt(),i=St(n,e),s=new URLSearchParams;s.set("q",t),bt(s,r);const o=await n.request(`${A().search(i)}?${s.toString()}`),c=(Array.isArray(o?.data)?o.data:Array.isArray(o)?o:[]).map(t=>(n.rememberPage(t),new mt(t,n)));return lt(c,ut(o,c.length))}getTitle(){return new I(this.record.title)}getSubtitle(){return new T(this.record.subtitle)}getSmallTitle(){return new M(this.record.smalltitle)}getSummary(){return new N(this.record.summary)}getContent(){return new O(this.record.content)}getSlug(){return String(this.record.slug||"")}getUrl(){return new q(this.record.full_url||(this.record.slug?`/${this.record.slug}`:"/"))}getUuid(){return String(this.record.uuid||this.record.ulid||"")}getId(){return String(this.record.id||this.getUuid())}getLayout(){return String(this.record.layout||"")}getDisplay(){return String(this.record.display||"")}getDisplayInMenu(){const t=this.record.display_in_menu;return null==t||""===t||!1!==t&&0!==t&&"0"!==t}getSortOrder(){const t=Number(this.record.sort_order??0);return Number.isFinite(t)?t:0}getLang(){const t=String(this.record.lang||"").trim();if(t)return t;const e=this.kernel.snapshot().site;return String(e?.lang||function(t){return t&&"object"==typeof t?String(t.lang||""):""}(this.record.site)||"")}getOption(t){const e=[F(this.record.options,t),this.kernel.snapshot().options[t],F(this.kernel.snapshot().site?.options,t),F(_t(this.record.site),t)];for(const r of e)if($t(r))return new L(t,r);return new L(t,"")}getSeo(){const t=this.seoBag(),e=t=>null==t?"":String(t),r=t=>{const e=H(t);return e?new tt(e,this.kernel):null};return{title:new z(t.title??this.record.title),description:new J(t.description??this.record.summary),keywords:e(t.keywords),robots:e(t.robots),canonical:new q(t.canonical),ogTitle:e(t.og_title??t.title??this.record.title),ogDescription:e(t.og_description??t.description??this.record.summary),ogImage:r(t.og_image),ogType:e(t.og_type),ogUrl:new q(t.og_url||t.canonical),twitterCard:e(t.twitter_card),twitterTitle:e(t.twitter_title??t.og_title??t.title),twitterDescription:e(t.twitter_description??t.og_description??t.description),twitterImage:r(t.twitter_image||t.og_image),ldJson:kt(t.ld_json),raw:{...t}}}get collectionItem(){const t=this.record.collectionItem;return t&&"object"==typeof t?t:{}}get collectionItems(){const t=this.record.collectionItems;return t&&"object"==typeof t?t:{}}get collectionGallery(){return t=this.record.collectionGallery,e=this.kernel,Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new ot(t,e)):[];var t,e}collectionImage(){return ct(this.collectionItem,this.kernel)}getAssets(){return new et(it(this.record.assets,this.kernel))}getGallery(t){const e=t.trim();if(!e)return new et([]);const r=[];return it(this.record.assets,this.kernel).forEach((t,n)=>{const i=t.memberships().find(t=>function(t,e){const r=e.trim().toLocaleLowerCase();return!!r&&(t.uuid.toLocaleLowerCase()===r||t.name.toLocaleLowerCase()===r)}(t,e));i&&r.push({asset:t,sort:i.sort_order,index:n})}),r.sort((t,e)=>t.sort-e.sort||t.index-e.index),new et(r.map(t=>t.asset))}getGalleries(){const t=it(this.record.assets,this.kernel);return this.galleryList(t).map(t=>({id:t.id,uuid:t.uuid,name:t.name,description:t.description,sort_order:t.sort_order,assets:this.getGallery(t.uuid||t.name)}))}async getChildren(t){const e=function(t){if(!Array.isArray(t))return[];const e=/* @__PURE__ */new Set(["options","assets"]),r=[];for(const n of t){const t=String(n).trim().toLowerCase();e.has(t)&&!r.includes(t)&&r.push(t)}return r}(t?.with),r=Array.isArray(this.record.children)?this.record.children:null;if(r&&function(t,e){return!e.length||t.every(t=>{if(!t||"object"!=typeof t)return!1;const r=t;if(e.includes("options")){const t=r.options;if(null==t||"object"!=typeof t)return!1}return!(e.includes("assets")&&!Array.isArray(r.assets))})}(r,e)){const e=function(t,e,r){const n=t.length;if(!e&&!r)return{items:t,meta:{currentPage:1,lastPage:1,perPage:Math.max(n,1),total:n}};const i=r&&r>0?Math.floor(r):Math.max(n,1),s=e&&e>0?Math.floor(e):1,o=Math.max(1,Math.ceil(n/i)),c=(s-1)*i;return{items:t.slice(c,c+i),meta:{currentPage:s,lastPage:o,perPage:i,total:n}}}(this.rowsToPages(r),t?.page,t?.perPage);return lt(e.items,e.meta)}const n=this.getUuid()||String(this.record.id??"");if(!n){const t=r?this.rowsToPages(r):[];return lt(t,ut(null,t.length))}const i=new URLSearchParams;i.set("parent",n),e.length&&i.set("with",e.join(",")),bt(i,t);const s=await this.kernel.request(`${A().pages(this.siteRef())}?${i.toString()}`);return lt(this.rowsToPages(s.data??[]),ut(s,(s.data??[]).length))}async getSiblings(){if(Array.isArray(this.record.siblings))return this.record.siblings.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new mt(t,this.kernel));const t=this.record.parent_id,e=this.siteRef();if(null==t||""===t){const t=await this.kernel.request(`${A().pages(e)}?parent=root`);return this.excludeSelf(t.data??[])}const r=await this.kernel.request(`${A().pages(e)}?parent=${encodeURIComponent(String(t))}`);return this.excludeSelf(r.data??[])}async getParent(){if(this.record.parent&&"object"==typeof this.record.parent)return new mt(this.record.parent,this.kernel);const t=this.record.parent_id;return null==t||""===t?null:jt(String(t),this.siteRef())}async getAncestors(){if(Array.isArray(this.record.ancestors))return this.rowsToPages(this.record.ancestors);const t=this.embeddedAncestors();if(t.length){const e=t[0],r=e.raw().parent_id;return null==r||""===r||0===r?t:[...await e.fetchAncestors(),...t]}return this.fetchAncestors()}async getSite(){if(this.record.site&&"object"==typeof this.record.site)return new dt(this.record.site,this.kernel);const t=this.kernel.snapshot().site;if(t&&(String(t.id)===String(this.record.site_id)||!this.record.site_id))return new dt(t,this.kernel);const e=this.record.site_id?String(this.record.site_id):this.kernel.siteRef(),r=x(await this.kernel.request(A().site(e)));return this.kernel.rememberSite(r),new dt(r,this.kernel)}async load(){return await this.ensure(["content","options","assets","children"]),this}raw(){return{...this.record}}seoBag(){const t=this.record.seo&&"object"==typeof this.record.seo?this.record.seo:this.kernel.snapshot().seo;return t&&"object"==typeof t?{...t}:{}}galleryList(t){if(Array.isArray(this.record.galleries))return this.record.galleries.flatMap(t=>{const e=rt(t);if(!e)return[];const r=t&&"object"==typeof t?String(t.description??""):"";return[{...e,description:r}]});const e=/* @__PURE__ */new Map;for(const r of t)for(const t of r.memberships()){const r=(t.uuid||t.name).toLocaleLowerCase();r&&!e.has(r)&&e.set(r,{...t,description:""})}return[...e.values()]}siteRef(){return this.record.site&&"object"==typeof this.record.site?_(this.record.site)||this.kernel.siteRef():this.record.site_id?String(this.record.site_id):this.kernel.siteRef()}rowsToPages(t){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new mt(t,this.kernel)):[]}embeddedAncestors(){const t=[],e=/* @__PURE__ */new Set;let r=this.record.parent;for(;r&&"object"==typeof r&&t.length<12;){const n=r,i=String(n.uuid||n.id||"");if(!i||e.has(i))break;e.add(i),t.unshift(new mt(n,this.kernel)),r=n.parent}return t}async fetchAncestors(){const t=[],e=/* @__PURE__ */new Set;let r=await this.getParent();for(;r&&t.length<12;){const n=r.getUuid()||String(r.raw().id??"");if(!n||e.has(n))break;e.add(n),t.unshift(r),r=await r.getParent()}return t}excludeSelf(t){const e=$(this.record);return t.filter(t=>$(t)!==e).map(t=>new mt(t,this.kernel))}async ensure(t){if(!t.some(t=>void 0===this.record[t]))return;const e=this.getUuid()||this.getSlug()||String(this.record.id||"");if(!e)return;const r=x(await this.kernel.request(A().page(this.siteRef(),e)));this.setRecord({...this.record,...r})}}let yt=null;function wt(){if(!yt)throw new Error("Client is not installed.");return yt}function St(t,e){return null!=e&&""!==String(e)?String(e):t.siteRef()}function bt(t,e){e?.page&&e.page>0&&t.set("page",String(Math.floor(e.page))),e?.perPage&&e.perPage>0&&t.set("per_page",String(Math.floor(e.perPage)))}function $t(t){if(null==t)return!1;if("string"==typeof t){const e=t.trim();return""!==e&&"{}"!==e&&"[]"!==e}return Array.isArray(t)?t.length>0:"object"!=typeof t||Object.keys(t).length>0}function _t(t){if(t&&"object"==typeof t)return t.options}function kt(t){if("string"==typeof t)return t;if(t&&"object"==typeof t)try{return JSON.stringify(t)}catch{return""}return""}async function jt(t,e){const r=wt(),n=St(r,e),i=x(await r.request(A().page(n,t)));return r.rememberPage(i),new mt(i,r)}class At{constructor(t,e=null){this.record=t,this.kernel=e}record;kernel;getTitle(){return new E(this.record.title)}getUrl(){return new q(this.record.url)}getChildren(){return xt(this.record.children,this.kernel)}isCurrent(t){const e=this.getUrl().path();if(!e)return!1;if(t)return e===t.getUrl().path();const r=this.kernel??Pt,n=r?.snapshot().page;return!(!r||!n)&&e===new mt(n,r).getUrl().path()}getPage(){const t=this.record.page;if(!t||"object"!=typeof t)return null;const e=this.kernel??Pt;return e?new mt(t,e):null}raw(){return{...this.record}}}class vt{constructor(t,e){this.source=t,this.runtime=e}source;runtime;get record(){return"function"==typeof this.source?this.source():this.source}static async find(t,e){const r=function(){if(!Pt)throw new Error("Client is not installed.");return Pt}(),n=null!=e&&""!==String(e)?String(e):r.siteRef(),i=r.snapshot().menus,s=i[t]||Object.values(i).find(e=>!!e&&(String(e.uuid)===t||String(e.id)===t||String(e.name)===t||String(e.position)===t));if(s)return new vt(s,r);const o=x(await r.request(A().menu(n,t)));return r.rememberMenu(o),new vt(o,r)}getName(){return new E(this.record.name)}getPosition(){return String(this.record.position||"")}getItems(){return xt(this.record.items,this.runtime)}raw(){return{...this.record}}}function xt(t,e=null){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new At(t,e)):[]}let Pt=null;class Ct{snap={page:null,site:null,menus:{},locales:[],seo:null,options:{}};options;inflight=/* @__PURE__ */new Map;cache=/* @__PURE__ */new Map;constructor(t={}){this.options=t,t.page&&this.hydrate(t.page),yt=this,gt=this,Pt=this}hydrate(t){return this.snap=w(this.snap,function(t){const e={page:null,site:null,menus:{},locales:[],seo:null,options:{}};if(!t||"object"!=typeof t)return e;const r=t,n=S(r.props)?r.props:r;e.page=b(n.page),e.site=b(n.site),e.seo=S(n.seo)?n.seo:null,e.options=S(n.options)?n.options:{},e.locales=Array.isArray(n.locales)?n.locales:[];const i=n.menus;if(S(i))for(const[s,o]of Object.entries(i))e.menus[s]=b(o);return e}(t)),this.snap}snapshot(){return this.snap}apiBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=v();return e.apiBase?String(e.apiBase).replace(/\/+$/,""):function(){if("undefined"==typeof location)return"";const t=String(location.origin||"").replace(/\/+$/,"");if(t&&"null"!==t)return t;const e=location.hostname||"";return e?`${location.protocol}//${e}`:""}()}(this.options.apiBase)}siteBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=v();return e.siteBase?String(e.siteBase).replace(/\/+$/,""):"undefined"!=typeof location?location.origin:""}(this.options.siteBase)}siteRef(){return null!=this.options.site&&""!==String(this.options.site)?String(this.options.site):_(this.snap.site)}async request(t,e={}){const r=String(e.method||"GET").toUpperCase(),n=`${r} ${t}`;if("GET"===r&&this.cache.has(n))return this.cache.get(n);if("GET"===r){const t=this.inflight.get(n);if(t)return t}const i=this.apiBase();if(!i)throw new Error("Remote origin is not configured.");const s=async function(t,e,r={}){const{fetchImpl:n,...i}=r,s=e.startsWith("http")?e:j(t,e),o=n??fetch,c=new Headers(i.headers);c.has("Accept")||c.set("Accept","application/json");const a=await o(s,{...i,headers:c}),u=await a.text();let l=null;if(u)try{l=JSON.parse(u)}catch{l={message:u}}if(!a.ok){const t=new Error(`Request failed (${a.status})`);throw t.status=a.status,t.body=l,t}return l}(i,t,{...e,fetchImpl:this.options.fetch}).then(t=>("GET"===r&&this.cache.set(n,t),t));return"GET"===r&&(this.inflight.set(n,s),s.finally(()=>{this.inflight.delete(n)}).catch(()=>{})),s}rememberPage(t){const e=this.snap.page;e&&String(e.id)===String(t.id)&&(this.snap=w(this.snap,{page:{...e,...t}}))}rememberSite(t){this.snap=w(this.snap,{site:{...this.snap.site??{},...t}})}rememberMenu(t){const e=String(t.position||t.uuid||t.id||t.name||"menu");this.snap=w(this.snap,{menus:{[e]:t}})}}let Rt=null;function Ut(t={}){return Rt=new Ct(t),Rt}function It(){return Rt||(Rt=new Ct),Rt}const Tt=/* @__PURE__ */Symbol.for("miro.client");function Mt(){return r(Tt,null)??It()}function Nt(t={}){return{install(e,r={}){const n=Ut({...t,...r});e.provide(Tt,n),e.component("MiroText",y),function(t){import("@inertiajs/vue3").then(e=>{const r=e.router;r?.page&&t.hydrate(r.page),r?.on?.("success",e=>{const r=e?.detail?.page;r&&t.hydrate(r)}),r?.on?.("navigate",e=>{const r=e?.detail?.page;r&&t.hydrate(r)})}).catch(()=>{})}(n)}}}const Ot=Nt();class Wt{constructor(t){this.kernel=t}kernel;all(){return function(t,e=function(){return globalThis}()){const r=Array.isArray(t)?t.flatMap(t=>function(t){if(!t||"object"!=typeof t)return[];const e=t,r=Bt(String(e.lang??""));return r?[{lang:r,domain:qt(String(e.domain??"")),url:String(e.url??"").trim()}]:[]}(t)):[];return r.length?r.flatMap(t=>{const r=Lt(t.url||function(t,e){const r=e[`locale_${t}_baseurl`];return"string"==typeof r?r.trim():""}(t.lang,e)||t.domain);return t.lang&&r?[{lang:t.lang,domain:t.domain||qt(r),url:r}]:[]}):function(t){const e=[];for(const r of Object.keys(t)){const n=/^locale_([a-z]+)_baseurl$/.exec(r);if(!n)continue;const i=Lt(String(t[r]??""));i&&e.push({lang:n[1],domain:qt(i),url:i})}return e}(e)}(this.kernel.snapshot().locales)}current(){return Bt(String(this.kernel.snapshot().site?.lang||""))}url(t){const e=Bt(t),r=this.all().find(t=>t.lang===e);return r?.url??""}}function Bt(t){return(t.trim().toLowerCase().replaceAll("_","-").split("-")[0]??"").replace(/[^a-z]/g,"")}function Lt(t){const e=t.trim();return e?(/^https?:\/\//i.test(e)?e:`https://${e.replace(/^\/+/,"")}`).replace(/\/+$/,""):""}function qt(t){return t.trim().replace(/^https?:\/\//i,"").replace(/\/.*$/,"")}function Et(t){return`mc_${(String(t??"").trim().split("/").pop()??"").replace(/^@/,"").replace(/[^A-Za-z0-9]+/g,"_").replace(/^_+|_+$/g,"").toUpperCase()}`}function Gt(t){if("undefined"==typeof window||""===t)return"";const e=window.__MIRO_WEB_PLUGINS__;if(!Array.isArray(e))return"";for(const r of e){const e=String(r??"").trim().toLowerCase(),n=e.lastIndexOf("/");if(n<=0)continue;const i=e.slice(0,n),s=e.slice(n+1);if(""!==i&&(s===t||zt(s)===t))return i}return""}function zt(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[^A-Za-z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Jt(t){if("undefined"==typeof window)return{};const e=window[t];return e&&"object"==typeof e?e:{}}function Dt(){const t=Mt(),e=function(){try{const t=globalThis.__INERTIA_PAGE__;if(t?.props)return t.props}catch{}return function(){if("undefined"==typeof document)return null;const t=document.querySelector("[data-page]")?.getAttribute("data-page");if(!t)return null;try{return JSON.parse(t).props??null}catch{return null}}()}();return e&&t.hydrate(e),t}function Ft(){const t=Dt();return Yt(t),new mt(()=>t.snapshot().page??{},t)}function Ht(){const t=Dt();return Yt(t),new dt(()=>t.snapshot().site??{},t)}function Zt(t="topbar"){const e=Dt();return Yt(e),new vt(()=>e.snapshot().menus[t]??{position:t,items:[]},e)}function Vt(){const t=Dt();return Yt(t),new Wt(t)}function Kt(){return Ft().getAssets()}function Qt(t){return function(t,e){const r=Et(t),n=function(t){const e=String(t??"").trim();if(e.includes("/")){const[t,...r]=e.split("/");return{vendor:t||"miroart",slug:zt(r.join("/")||e)}}const r=zt(e);return{vendor:Gt(r)||"miroart",slug:r}}(t);return new Proxy({name:t,key:r,ready:async()=>async function(t){const e=Date.now();for(;Date.now()-e<4e3;){const e=Jt(t);if(Object.keys(e).length)return e;await new Promise(t=>setTimeout(t,50))}return Jt(t)}(r),api:()=>Jt(r),call:(t,...e)=>{const n=Jt(r),i=n[t];if("function"!=typeof i)throw new Error(`Missing plugin method: ${t}`);return i.apply(n,e)},request:async(t="/",r={})=>{const i=A().plugins(n.vendor,n.slug,t||"/"),s=new Headers(r.headers);let o=r.body;return void 0!==r.json&&(o=JSON.stringify(r.json)),x(await e.request(i,{...r,headers:s,body:o}))}},{get(t,e,n){if(e in t)return Reflect.get(t,e,n);if("then"===e||e===Symbol.toStringTag)return;const i=Jt(r),s=i[String(e)];return"function"==typeof s?s.bind(i):s},has:(t,e)=>e in t||e in Jt(r)})}(t,Mt())}function Xt(){const t=Mt();return{apiBase:n(()=>t.apiBase()),siteBase:n(()=>t.siteBase()),siteRef:n(()=>t.siteRef())}}function Yt(t){try{const e=function(){try{return te??null}catch{return null}}();if(!e)return;const r=e.usePage();t.hydrate(i(r))}catch{}}let te=null;import("@inertiajs/vue3").then(t=>{te=t}).catch(()=>{te=null});const ee=Ot;export{tt as Asset,G as AssetName,ot as CollectionCard,et as Gallery,Wt as Locales,vt as Menu,At as MenuItem,E as MenuTitle,Ot as Miro,y as MiroText,L as OptionValue,mt as Page,O as PageContent,M as PageSmallTitle,T as PageSubtitle,N as PageSummary,I as PageTitle,s as RICH_COLORS,o as RICH_FONTS,Tt as SDK_KEY,J as SeoDescription,z as SeoTitle,dt as Site,B as SiteName,W as SiteTitle,U as TextValue,q as UrlValue,Nt as createMiro,Ut as createRuntime,ee as default,It as getRuntime,l as parseRichText,p as plainText,Et as pluginWindowKey,Mt as useKernel,Kt as useMiroAssets,Xt as useMiroConfig,Vt as useMiroLocales,Zt as useMiroMenu,Ft as useMiroPage,Ht as useMiroSite,Qt as usePlugin};
|
package/dist/list.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type PageListMeta = {
|
|
2
|
+
currentPage: number;
|
|
3
|
+
lastPage: number;
|
|
4
|
+
perPage: number;
|
|
5
|
+
total: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function listMetaFromPayload(payload: unknown, count: number): PageListMeta;
|
|
8
|
+
export declare function sliceMeta<T>(items: T[], page?: number, perPage?: number): {
|
|
9
|
+
items: T[];
|
|
10
|
+
meta: PageListMeta;
|
|
11
|
+
};
|
|
12
|
+
export declare function attachMeta<T extends unknown[]>(items: T, meta: PageListMeta): T & {
|
|
13
|
+
meta: PageListMeta;
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Kernel } from "./context";
|
|
2
|
+
export type LocaleLink = {
|
|
3
|
+
lang: string;
|
|
4
|
+
domain: string;
|
|
5
|
+
url: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class Locales {
|
|
8
|
+
private readonly kernel;
|
|
9
|
+
constructor(kernel: Kernel);
|
|
10
|
+
all(): LocaleLink[];
|
|
11
|
+
current(): string;
|
|
12
|
+
url(lang: string): string;
|
|
13
|
+
}
|
|
14
|
+
export declare function readLocales(rows: unknown, bag?: Record<string, unknown>): LocaleLink[];
|
package/dist/menu.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { MenuTitle, UrlValue } from "./values";
|
|
2
2
|
import type { MenuItemRecord, MenuRecord } from "./types";
|
|
3
3
|
import type { Kernel } from "./context";
|
|
4
|
+
import { Page } from "./page";
|
|
4
5
|
export declare class MenuItem {
|
|
5
6
|
private readonly record;
|
|
6
|
-
|
|
7
|
+
private readonly kernel;
|
|
8
|
+
constructor(record: MenuItemRecord, kernel?: Kernel | null);
|
|
7
9
|
getTitle(): MenuTitle;
|
|
8
10
|
getUrl(): UrlValue;
|
|
9
11
|
getChildren(): MenuItem[];
|
|
12
|
+
isCurrent(page?: Page): boolean;
|
|
13
|
+
getPage(): Page | null;
|
|
10
14
|
raw(): MenuItemRecord;
|
|
11
15
|
}
|
|
12
16
|
export declare class Menu {
|
|
@@ -20,5 +24,5 @@ export declare class Menu {
|
|
|
20
24
|
getItems(): MenuItem[];
|
|
21
25
|
raw(): MenuRecord;
|
|
22
26
|
}
|
|
23
|
-
export declare function itemsFromUnknown(value: unknown): MenuItem[];
|
|
27
|
+
export declare function itemsFromUnknown(value: unknown, kernel?: Kernel | null): MenuItem[];
|
|
24
28
|
export declare function bindMenuRuntime(runtime: Kernel): void;
|
package/dist/page.d.ts
CHANGED
|
@@ -1,8 +1,44 @@
|
|
|
1
|
-
import { Gallery } from "./asset";
|
|
1
|
+
import { Asset, Gallery } from "./asset";
|
|
2
|
+
import { CollectionCard } from "./collection";
|
|
3
|
+
import { type PageListMeta } from "./list";
|
|
2
4
|
import type { Kernel } from "./context";
|
|
3
5
|
import { OptionValue, PageContent, PageSmallTitle, PageSubtitle, PageSummary, PageTitle, SeoDescription, SeoTitle, UrlValue } from "./values";
|
|
4
6
|
import type { Dict, PageRecord } from "./types";
|
|
5
7
|
import { Site } from "./site";
|
|
8
|
+
export type PageListQuery = {
|
|
9
|
+
with?: string[];
|
|
10
|
+
page?: number;
|
|
11
|
+
perPage?: number;
|
|
12
|
+
};
|
|
13
|
+
export type PagedPages = Page[] & {
|
|
14
|
+
meta: PageListMeta;
|
|
15
|
+
};
|
|
16
|
+
export type SeoView = {
|
|
17
|
+
title: SeoTitle;
|
|
18
|
+
description: SeoDescription;
|
|
19
|
+
keywords: string;
|
|
20
|
+
robots: string;
|
|
21
|
+
canonical: UrlValue;
|
|
22
|
+
ogTitle: string;
|
|
23
|
+
ogDescription: string;
|
|
24
|
+
ogImage: Asset | null;
|
|
25
|
+
ogType: string;
|
|
26
|
+
ogUrl: UrlValue;
|
|
27
|
+
twitterCard: string;
|
|
28
|
+
twitterTitle: string;
|
|
29
|
+
twitterDescription: string;
|
|
30
|
+
twitterImage: Asset | null;
|
|
31
|
+
ldJson: string;
|
|
32
|
+
raw: Dict;
|
|
33
|
+
};
|
|
34
|
+
export type PageGallery = {
|
|
35
|
+
id: number | string | null;
|
|
36
|
+
uuid: string;
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
sort_order: number;
|
|
40
|
+
assets: Gallery;
|
|
41
|
+
};
|
|
6
42
|
export declare class Page {
|
|
7
43
|
private source;
|
|
8
44
|
private readonly kernel;
|
|
@@ -11,7 +47,10 @@ export declare class Page {
|
|
|
11
47
|
private setRecord;
|
|
12
48
|
static findByUlid(id: string, site?: string | number): Promise<Page>;
|
|
13
49
|
static find(id: string, site?: string | number): Promise<Page>;
|
|
14
|
-
static search(query: string, site?: string | number
|
|
50
|
+
static search(query: string, site?: string | number, list?: {
|
|
51
|
+
page?: number;
|
|
52
|
+
perPage?: number;
|
|
53
|
+
}): Promise<PagedPages>;
|
|
15
54
|
getTitle(): PageTitle;
|
|
16
55
|
getSubtitle(): PageSubtitle;
|
|
17
56
|
getSmallTitle(): PageSmallTitle;
|
|
@@ -23,20 +62,31 @@ export declare class Page {
|
|
|
23
62
|
getId(): string;
|
|
24
63
|
getLayout(): string;
|
|
25
64
|
getDisplay(): string;
|
|
65
|
+
getDisplayInMenu(): boolean;
|
|
66
|
+
getSortOrder(): number;
|
|
67
|
+
getLang(): string;
|
|
26
68
|
getOption(key: string): OptionValue;
|
|
27
|
-
getSeo():
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
69
|
+
getSeo(): SeoView;
|
|
70
|
+
get collectionItem(): Dict;
|
|
71
|
+
get collectionItems(): Record<string, Dict>;
|
|
72
|
+
get collectionGallery(): CollectionCard[];
|
|
73
|
+
collectionImage(): Asset | null;
|
|
32
74
|
getAssets(): Gallery;
|
|
33
|
-
|
|
75
|
+
getGallery(nameOrUuid: string): Gallery;
|
|
76
|
+
getGalleries(): PageGallery[];
|
|
77
|
+
getChildren(query?: PageListQuery): Promise<PagedPages>;
|
|
34
78
|
getSiblings(): Promise<Page[]>;
|
|
35
79
|
getParent(): Promise<Page | null>;
|
|
80
|
+
getAncestors(): Promise<Page[]>;
|
|
36
81
|
getSite(): Promise<Site>;
|
|
37
82
|
load(): Promise<this>;
|
|
38
83
|
raw(): PageRecord;
|
|
84
|
+
private seoBag;
|
|
85
|
+
private galleryList;
|
|
39
86
|
private siteRef;
|
|
87
|
+
private rowsToPages;
|
|
88
|
+
private embeddedAncestors;
|
|
89
|
+
private fetchAncestors;
|
|
40
90
|
private excludeSelf;
|
|
41
91
|
private ensure;
|
|
42
92
|
}
|
package/dist/paths.d.ts
CHANGED
|
@@ -10,5 +10,6 @@ export declare function catalog(): {
|
|
|
10
10
|
menus: (site: string) => string;
|
|
11
11
|
menu: (site: string, menu: string) => string;
|
|
12
12
|
media: (uuid: string) => string;
|
|
13
|
+
action: (site: string) => string;
|
|
13
14
|
plugins: (vendor: string, slug: string, rest?: string) => string;
|
|
14
15
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatowanie w jednym stringu pola: `[b]`, `[i]`, `[u]`, `[s]`, `[c=primary]`, `[f=serif]`.
|
|
3
|
+
* Nie ma tu HTML-a: wynik to drzewo, z którego `MiroText` buduje węzły przez `h()`.
|
|
4
|
+
* Te same reguły są w nakładce edytora (`web/app/Support/VisualEdit/overlay.js`) i w
|
|
5
|
+
* `web/app/Support/RichInline.php`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const RICH_COLORS: readonly ["primary", "secondary", "accent", "neutral", "base-100", "base-content", "info", "success", "warning", "error"];
|
|
8
|
+
export declare const RICH_FONTS: readonly ["sans", "serif"];
|
|
9
|
+
export type RichColor = (typeof RICH_COLORS)[number];
|
|
10
|
+
export type RichFont = (typeof RICH_FONTS)[number];
|
|
11
|
+
export type RichNode = {
|
|
12
|
+
type: "text";
|
|
13
|
+
value: string;
|
|
14
|
+
} | {
|
|
15
|
+
type: "br";
|
|
16
|
+
} | {
|
|
17
|
+
type: "b" | "i" | "u" | "s";
|
|
18
|
+
children: RichNode[];
|
|
19
|
+
} | {
|
|
20
|
+
type: "c";
|
|
21
|
+
value: RichColor;
|
|
22
|
+
children: RichNode[];
|
|
23
|
+
} | {
|
|
24
|
+
type: "f";
|
|
25
|
+
value: RichFont;
|
|
26
|
+
children: RichNode[];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Nie rzuca wyjątku dla żadnego wejścia. Coś, co nie jest znanym znacznikiem z dozwoloną
|
|
30
|
+
* wartością, zostaje zwykłym tekstem. Niezamknięty znacznik kończy się z końcem wartości.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseRichText(value: unknown): RichNode[];
|
|
33
|
+
/** Do atrybutów (`alt`, `aria-label`), `<title>` i liczenia znaków: bez znaczników, `\n` zostaje. */
|
|
34
|
+
export declare function plainText(value: unknown): string;
|
|
35
|
+
/** Czy wartość w ogóle wymaga drzewa. Reszta to jeden węzeł tekstowy, jak przy `{{ }}`. */
|
|
36
|
+
export declare function needsRichRender(raw: string): boolean;
|
package/dist/runtime.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { ClientOptions, MenuRecord, PageRecord, SiteRecord, Snapshot } from
|
|
|
3
3
|
export declare class Runtime implements Kernel {
|
|
4
4
|
private snap;
|
|
5
5
|
private readonly options;
|
|
6
|
+
private readonly inflight;
|
|
7
|
+
private readonly cache;
|
|
6
8
|
constructor(options?: ClientOptions);
|
|
7
9
|
hydrate(payload: unknown): Snapshot;
|
|
8
10
|
snapshot(): Snapshot;
|
package/dist/site.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { Asset } from "./asset";
|
|
1
2
|
import type { Kernel } from "./context";
|
|
2
3
|
import { Menu } from "./menu";
|
|
3
|
-
import { Page } from "./page";
|
|
4
|
+
import { Page, type PagedPages } from "./page";
|
|
4
5
|
import { OptionValue, SiteName, SiteTitle } from "./values";
|
|
5
|
-
import type { SiteRecord } from "./types";
|
|
6
|
+
import type { ActionCall, SiteRecord } from "./types";
|
|
6
7
|
export declare class Site {
|
|
7
8
|
private readonly source;
|
|
8
9
|
private readonly kernel;
|
|
9
10
|
constructor(source: SiteRecord | (() => SiteRecord), kernel: Kernel);
|
|
10
11
|
private get record();
|
|
12
|
+
static all(): Promise<Site[]>;
|
|
11
13
|
static find(id?: string | number): Promise<Site>;
|
|
12
14
|
static findPage(id: string, site?: string | number): Promise<Page>;
|
|
13
15
|
static findMenu(key: string, site?: string | number): Promise<Menu>;
|
|
@@ -17,10 +19,12 @@ export declare class Site {
|
|
|
17
19
|
getLang(): string;
|
|
18
20
|
getUuid(): string;
|
|
19
21
|
getOption(key: string): OptionValue;
|
|
22
|
+
getImage(key: string): Asset | null;
|
|
20
23
|
findPage(id: string): Promise<Page>;
|
|
21
24
|
findMenu(key: string): Promise<Menu>;
|
|
22
25
|
menus(): Promise<Menu[]>;
|
|
23
|
-
pages(query?: Record<string, string | number | boolean>): Promise<
|
|
26
|
+
pages(query?: Record<string, string | number | boolean>): Promise<PagedPages>;
|
|
27
|
+
runAction(call: ActionCall): Promise<unknown>;
|
|
24
28
|
raw(): SiteRecord;
|
|
25
29
|
private ref;
|
|
26
30
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -17,13 +17,21 @@ export type PageRecord = Dict & {
|
|
|
17
17
|
content?: string;
|
|
18
18
|
layout?: string;
|
|
19
19
|
display?: string;
|
|
20
|
+
display_in_menu?: boolean | number | string | null;
|
|
21
|
+
sort_order?: number | string | null;
|
|
22
|
+
lang?: string | null;
|
|
20
23
|
options?: unknown;
|
|
21
24
|
assets?: unknown;
|
|
25
|
+
galleries?: unknown;
|
|
22
26
|
children?: unknown;
|
|
23
27
|
siblings?: unknown;
|
|
24
28
|
parent?: unknown;
|
|
29
|
+
ancestors?: unknown;
|
|
25
30
|
site?: unknown;
|
|
26
31
|
seo?: unknown;
|
|
32
|
+
collectionItem?: Dict | null;
|
|
33
|
+
collectionItems?: Record<string, Dict> | null;
|
|
34
|
+
collectionGallery?: unknown;
|
|
27
35
|
};
|
|
28
36
|
export type SiteRecord = Dict & {
|
|
29
37
|
id?: number | string;
|
|
@@ -46,14 +54,28 @@ export type AssetRecord = Dict & {
|
|
|
46
54
|
name?: string;
|
|
47
55
|
url?: string;
|
|
48
56
|
path?: string;
|
|
57
|
+
src?: string;
|
|
58
|
+
preview_url?: string;
|
|
59
|
+
disk?: string;
|
|
49
60
|
mime_type?: string;
|
|
61
|
+
size?: number | string | null;
|
|
62
|
+
type?: string | null;
|
|
63
|
+
source?: unknown;
|
|
50
64
|
sort_order?: number;
|
|
65
|
+
gallery_id?: number | string | null;
|
|
66
|
+
gallery_uuid?: string | null;
|
|
67
|
+
gallery_name?: string | null;
|
|
68
|
+
gallery_sort_order?: number | null;
|
|
69
|
+
galleries?: unknown;
|
|
70
|
+
alt?: string | null;
|
|
71
|
+
caption?: string | null;
|
|
51
72
|
};
|
|
52
73
|
export type MenuItemRecord = Dict & {
|
|
53
74
|
id?: number | string;
|
|
54
75
|
title?: string;
|
|
55
76
|
url?: string;
|
|
56
77
|
children?: unknown;
|
|
78
|
+
page?: unknown;
|
|
57
79
|
};
|
|
58
80
|
export type Snapshot = {
|
|
59
81
|
page: PageRecord | null;
|
|
@@ -75,3 +97,13 @@ export type ClientOptions = {
|
|
|
75
97
|
export type PluginRequestInit = RequestInit & {
|
|
76
98
|
json?: unknown;
|
|
77
99
|
};
|
|
100
|
+
export type ActionCall = {
|
|
101
|
+
uuid: string;
|
|
102
|
+
method?: string;
|
|
103
|
+
path?: string;
|
|
104
|
+
query?: Record<string, unknown>;
|
|
105
|
+
body?: string;
|
|
106
|
+
headers?: Record<string, string>;
|
|
107
|
+
params?: Record<string, unknown>;
|
|
108
|
+
post?: Record<string, unknown>;
|
|
109
|
+
};
|
package/dist/values.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export declare class TextValue extends String {
|
|
|
10
10
|
decode(): string;
|
|
11
11
|
cleanContent(): string;
|
|
12
12
|
stripHtml(): string;
|
|
13
|
+
/** Bez znaczników `[b]`, `[c=…]`: do atrybutów i `<title>`. Nowe linie zostają. */
|
|
14
|
+
plain(): string;
|
|
13
15
|
excerpt(length?: number): string;
|
|
14
16
|
firstParagraph(): string;
|
|
15
17
|
isEmpty(): boolean;
|
|
@@ -41,7 +43,9 @@ export declare class SiteName extends TextValue {
|
|
|
41
43
|
}
|
|
42
44
|
export declare class OptionValue extends TextValue {
|
|
43
45
|
readonly key: string;
|
|
46
|
+
private readonly structured;
|
|
44
47
|
constructor(key: string, value: unknown);
|
|
48
|
+
json<T = unknown>(): T | null;
|
|
45
49
|
present(): boolean;
|
|
46
50
|
}
|
|
47
51
|
export declare class UrlValue extends TextValue {
|