@flyo/nitro-vue3 2.2.1 → 2.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/README.md +3 -16
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +217 -215
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -182,30 +182,17 @@ Every composable returns the same reactive shape:
|
|
|
182
182
|
|
|
183
183
|
## Live-edit support
|
|
184
184
|
|
|
185
|
-
When your site is embedded in the Flyo preview iframe, you can enable a full live-editing experience by passing `liveEdit: true` to the plugin options
|
|
185
|
+
When your site is embedded in the Flyo preview iframe, you can enable a full live-editing experience by passing `liveEdit: true` to the plugin options. `FlyoPage` now initializes `useFlyoLiveEdit()` automatically in component setup, so users no longer need to call it manually in `App.vue` or a root layout.
|
|
186
186
|
|
|
187
187
|
### `useFlyoLiveEdit()`
|
|
188
188
|
|
|
189
|
-
|
|
189
|
+
This composable is automatically called by `FlyoPage` when `liveEdit` is enabled. It activates the bridge features from `@flyo/nitro-js-bridge`:
|
|
190
190
|
|
|
191
191
|
- **`reload()`** — reloads the page when Flyo sends a `pageRefresh` message.
|
|
192
192
|
- **`scrollTo()`** — scrolls to a specific block when Flyo sends a `scrollTo` message.
|
|
193
193
|
- **`highlightAndClick()`** — adds hover highlight and click-to-edit on every element with a `data-flyo-uid` attribute. A `MutationObserver` automatically wires up elements that are added after the initial render.
|
|
194
194
|
|
|
195
|
-
The composable is a no-op when `liveEdit` is `false
|
|
196
|
-
|
|
197
|
-
```vue
|
|
198
|
-
<!-- App.vue or your root layout component -->
|
|
199
|
-
<script setup>
|
|
200
|
-
import { useFlyoLiveEdit } from '@flyo/nitro-vue3'
|
|
201
|
-
|
|
202
|
-
useFlyoLiveEdit()
|
|
203
|
-
</script>
|
|
204
|
-
|
|
205
|
-
<template>
|
|
206
|
-
<router-view />
|
|
207
|
-
</template>
|
|
208
|
-
```
|
|
195
|
+
The composable remains exported for advanced use-cases, and it is a no-op when `liveEdit` is `false`.
|
|
209
196
|
|
|
210
197
|
### `editable(block)`
|
|
211
198
|
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("@flyo/nitro-typescript"),o=require("vue");let
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("@flyo/nitro-typescript"),o=require("vue");let le=null;const he=({apiToken:e,apiBasePath:n,defaultHeaders:l})=>{le=new x.Configuration({apiKey:e,...n&&{basePath:n},headers:l||{}})},M=()=>le,ge={name:"FlyoBlock"},I=Object.assign(ge,{props:{item:{type:Object,default:()=>{}}},setup(e){return(n,l)=>(o.openBlock(),o.createBlock(o.resolveDynamicComponent(e.item.component),{block:e.item,config:e.item.config,content:e.item.content,items:e.item.items,slots:e.item.slots},null,8,["block","config","content","items","slots"]))}});function B(){return typeof window>"u"?!1:window!==window.top}function we(){return typeof window>"u"?!1:B()?window.parent:window}function Ee(e){var n=we();n&&n.postMessage({action:"openEdit",data:JSON.parse(JSON.stringify({item:{uid:e}}))},"https://flyo.cloud")}function be(){typeof window>"u"||B()&&window.addEventListener("message",e=>{var n;((n=e.data)==null?void 0:n.action)==="pageRefresh"&&window.location.reload()})}function Le(){typeof window>"u"||B()&&window.addEventListener("message",e=>{var n,l,r,t;if(((n=e.data)==null?void 0:n.action)==="scrollTo"){const s=(t=(r=(l=e.data)==null?void 0:l.data)==null?void 0:r.item)==null?void 0:t.uid;if(!s)return;const u=document.querySelector(`[data-flyo-uid="${CSS.escape(s)}"]`);u&&u.scrollIntoView({behavior:"smooth",block:"start"})}})}function xe(e,n){const l=()=>Ee(e);if(!B()||!n)return l;const r=n,t=document.createElement("button");t.type="button",t.setAttribute("aria-label","Edit block"),t.style.position="fixed",t.style.top="0px",t.style.left="0px",t.style.zIndex="9999",t.style.width="44px",t.style.height="44px",t.style.display="none",t.style.alignItems="center",t.style.justifyContent="center",t.style.border="0px solid #000",t.style.borderRadius="9999px",t.style.boxSizing="border-box",t.style.cursor="pointer",t.style.background="#FFD466",t.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25z" fill="#111"/><path d="M20.71 7.04a1 1 0 0 0 0-1.41l-2.34-2.34a1 1 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" fill="#111"/></svg>';const s=document.createElement("div");s.style.position="fixed",s.style.top="0px",s.style.left="0px",s.style.zIndex="9998",s.style.display="none",s.style.pointerEvents="none",s.style.background="transparent",s.style.border="none",t.addEventListener("click",l),document.body.appendChild(s),document.body.appendChild(t);const u=44,V=6,ae=6,a=6,S=10,ue=180,O=()=>window.innerWidth||document.documentElement.clientWidth,N=()=>window.innerHeight||document.documentElement.clientHeight,de=i=>!(i.bottom<0||i.right<0||i.top>N()||i.left>O()||i.width===0&&i.height===0),z=(i,f)=>i>=a&&f>=a&&i+u<=O()-a&&f+u<=N()-a,U=(i,f)=>({x:Math.max(a,Math.min(i,O()-u-a)),y:Math.max(a,Math.min(f,N()-u-a))});function A(){const i=r.getBoundingClientRect(),f=i.width<u||i.height<u,g=Math.round(i.left),w=Math.round(i.top)-u-ae,P=Math.round(i.left)+V,R=Math.round(i.top)+V;let E,b;if(f&&z(g,w))E=g,b=w;else if(z(P,R))E=P,b=R;else if(z(g,w))E=g,b=w;else{const _=U(g,w),q=U(P,R),me=Math.abs(_.x-i.left)+Math.abs(_.y-i.top),ve=Math.abs(q.x-i.left)+Math.abs(q.y-i.top);({x:E,y:b}=me<=ve?_:q)}t.style.left=`${E}px`,t.style.top=`${b}px`;const te=Math.max(a,Math.round(i.left)-S),ne=Math.max(a,Math.round(i.top)-S),ye=Math.min(O()-a,Math.round(i.right)+S),pe=Math.min(N()-a,Math.round(i.bottom)+S);s.style.left=`${te}px`,s.style.top=`${ne}px`,s.style.width=`${Math.max(0,ye-te)}px`,s.style.height=`${Math.max(0,pe-ne)}px`}let y=!1,p=!1,m=!1,F=!1,v=null;const C=()=>{v!==null&&(clearTimeout(v),v=null)},$=()=>{C();try{const i=r.getBoundingClientRect();if(!de(i)){h(!0);return}A(),t.style.display="flex",s.style.display="block",ce()}catch{h(!0)}},h=(i=!1)=>{if(i){C(),t.style.display="none",s.style.display="none",j();return}C(),v=window.setTimeout(()=>{!y&&!p&&!m&&(t.style.display="none",s.style.display="none",j()),v=null},ue)},T=()=>{t.style.display!=="none"&&A()},W=T;let c=null;const K=window.ResizeObserver,ce=()=>{F||(F=!0,window.addEventListener("scroll",T,!0),window.addEventListener("resize",W),typeof K=="function"&&(c=new K(()=>{t.style.display!=="none"&&A()}),c==null||c.observe(r)))},j=()=>{if(F){F=!1,window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",W);try{c==null||c.disconnect()}catch{}c=null}},G=()=>{y=!0,$()},Q=()=>{y=!1,!p&&!m&&h()},X=()=>{p=!0,$()},Y=()=>{p=!1,!y&&!m&&h()},Z=()=>{m=!0,$()},ee=()=>{m=!1,!y&&!p&&h()};r.addEventListener("mouseenter",G),r.addEventListener("mouseleave",Q),t.addEventListener("mouseenter",X),t.addEventListener("mouseleave",Y),s.addEventListener("mouseenter",Z),s.addEventListener("mouseleave",ee),t.addEventListener("click",l);function fe(){C(),j(),t.removeEventListener("click",l),r.removeEventListener("mouseenter",G),r.removeEventListener("mouseleave",Q),t.removeEventListener("mouseenter",X),t.removeEventListener("mouseleave",Y),s.removeEventListener("mouseenter",Z),s.removeEventListener("mouseleave",ee),t.parentElement===document.body&&document.body.removeChild(t),s.parentElement===document.body&&document.body.removeChild(s)}return fe}let L=null,k=0,J=!1;const H=[],ie=()=>{H.forEach(e=>e()),H.length=0},oe=()=>{ie(),document.querySelectorAll("[data-flyo-uid]").forEach(e=>{const n=e.getAttribute("data-flyo-uid");if(n&&e instanceof HTMLElement){const l=xe(n,e);typeof l=="function"&&H.push(l)}})},Me=()=>{J||(be(),Le(),oe(),L=new MutationObserver(e=>{e.some(l=>Array.from(l.addedNodes).some(r=>{if(r.nodeType!==Node.ELEMENT_NODE)return!1;const t=r;return t.hasAttribute("data-flyo-uid")||t.querySelector("[data-flyo-uid]")}))&&oe()}),L.observe(document.body,{childList:!0,subtree:!0}),J=!0)},Se=()=>{J&&(L&&(L.disconnect(),L=null),ie(),J=!1)},Oe=e=>typeof(e==null?void 0:e.uid)=="string"&&e.uid.trim()!==""?{"data-flyo-uid":e.uid}:{},se=()=>{const e=o.inject("flyo");e!=null&&e.liveEdit&&(o.onMounted(()=>{k+=1,Me()}),o.onUnmounted(()=>{k=Math.max(0,k-1),k===0&&Se()}))},Ne={name:"FlyoPage"},D=Object.assign(Ne,{props:{page:{type:[Object,Boolean],default:!1}},setup(e){return se(),(n,l)=>{const r=o.resolveComponent("FlyoBlock");return o.openBlock(),o.createElementBlock("div",null,[e.page?o.renderSlot(n.$slots,"default",o.normalizeProps(o.mergeProps({key:0},e.page)),()=>[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(e.page.json,t=>(o.openBlock(),o.createBlock(r,{key:t.uid,item:t},null,8,["item"]))),128))]):o.createCommentVNode("",!0)])}}}),d=o.reactive({isLoading:null,response:null,error:null}),Fe=()=>{const e=async()=>{try{d.error=null,d.isLoading=!0,d.response=JSON.parse(JSON.stringify(await new x.ConfigApi(M()).config())),d.isLoading=!1}catch(n){d.isLoading=!1,d.response=null,d.error=JSON.parse(JSON.stringify(n))}return{response:d.response,error:d.error}};return{...o.toRefs(d),fetch:e}},Ce=e=>{const n=o.ref(!1),l=o.ref(null),r=o.ref(null);return{isLoading:n,response:l,error:r,fetch:async()=>{try{r.value=null,n.value=!0,l.value=JSON.parse(JSON.stringify(await new x.EntitiesApi(M()).entityByUniqueid({uniqueid:e}))),n.value=!1}catch(s){n.value=!1,l.value=null,r.value=JSON.parse(JSON.stringify(s))}return{response:o.unref(l),error:o.unref(r)}}}},ke=e=>{const n=o.ref(!1),l=o.ref(null),r=o.ref(null);return{isLoading:n,response:l,error:r,fetch:async()=>{try{r.value=null,n.value=!0,l.value=JSON.parse(JSON.stringify(await new x.PagesApi(M()).page({slug:e}))),n.value=!1}catch(s){n.value=!1,l.value=null,r.value=JSON.parse(JSON.stringify(s))}return{response:o.unref(l),error:o.unref(r)}}}},Je=()=>{const e=o.ref(!1),n=o.ref(null),l=o.ref(null);return{isLoading:e,response:n,error:l,fetch:async()=>{try{l.value=null,e.value=!0,n.value=JSON.parse(JSON.stringify(await new x.SitemapApi(M()).sitemap())),e.value=!1}catch(t){e.value=!1,n.value=null,l.value=JSON.parse(JSON.stringify(t))}return{response:o.unref(n),error:o.unref(l)}}}},re={install(e,n){he(n),e.component(I.name,I),e.component(D.name,D),e.provide("flyo",{liveEdit:n.liveEdit,liveEditOrigin:n.liveEditOrigin})}};exports.Block=I;exports.FlyoVue=re;exports.Page=D;exports.default=re;exports.editable=Oe;exports.getFlyoConfig=M;exports.useFlyoConfig=Fe;exports.useFlyoEntity=Ce;exports.useFlyoLiveEdit=se;exports.useFlyoPage=ke;exports.useFlyoSitemap=Je;
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Configuration as
|
|
2
|
-
import { openBlock as F, createBlock as
|
|
3
|
-
let
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
apiKey:
|
|
1
|
+
import { Configuration as ge, ConfigApi as we, EntitiesApi as Ee, PagesApi as be, SitemapApi as Le } from "@flyo/nitro-typescript";
|
|
2
|
+
import { openBlock as F, createBlock as ie, resolveDynamicComponent as xe, inject as Me, onMounted as Se, onUnmounted as Oe, resolveComponent as Ne, createElementBlock as ne, renderSlot as Ce, normalizeProps as Je, mergeProps as Fe, Fragment as ke, renderList as Be, createCommentVNode as ze, reactive as Ae, toRefs as $e, ref as d, unref as y } from "vue";
|
|
3
|
+
let re = null;
|
|
4
|
+
const Re = ({ apiToken: e, apiBasePath: n, defaultHeaders: o }) => {
|
|
5
|
+
re = new ge({
|
|
6
|
+
apiKey: e,
|
|
7
7
|
...n && { basePath: n },
|
|
8
|
-
headers:
|
|
8
|
+
headers: o || {}
|
|
9
9
|
});
|
|
10
|
-
},
|
|
10
|
+
}, B = () => re, je = {
|
|
11
11
|
name: "FlyoBlock"
|
|
12
|
-
},
|
|
12
|
+
}, oe = /* @__PURE__ */ Object.assign(je, {
|
|
13
13
|
props: {
|
|
14
14
|
item: {
|
|
15
15
|
type: Object,
|
|
@@ -17,281 +17,283 @@ const Fe = ({ apiToken: t, apiBasePath: n, defaultHeaders: l }) => {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
|
-
setup(
|
|
21
|
-
return (n,
|
|
22
|
-
block:
|
|
23
|
-
config:
|
|
24
|
-
content:
|
|
25
|
-
items:
|
|
26
|
-
slots:
|
|
20
|
+
setup(e) {
|
|
21
|
+
return (n, o) => (F(), ie(xe(e.item.component), {
|
|
22
|
+
block: e.item,
|
|
23
|
+
config: e.item.config,
|
|
24
|
+
content: e.item.content,
|
|
25
|
+
items: e.item.items,
|
|
26
|
+
slots: e.item.slots
|
|
27
27
|
}, null, 8, ["block", "config", "content", "items", "slots"]));
|
|
28
28
|
}
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
}, te = /* @__PURE__ */ Object.assign(Ae, {
|
|
32
|
-
props: {
|
|
33
|
-
page: {
|
|
34
|
-
type: [Object, Boolean],
|
|
35
|
-
default: !1
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
setup(t) {
|
|
39
|
-
return (n, l) => {
|
|
40
|
-
const i = ge("FlyoBlock");
|
|
41
|
-
return F(), Z("div", null, [
|
|
42
|
-
t.page ? we(n.$slots, "default", Ee(be({ key: 0 }, t.page)), () => [
|
|
43
|
-
(F(!0), Z(Le, null, xe(t.page.json, (e) => (F(), ne(i, {
|
|
44
|
-
key: e.uid,
|
|
45
|
-
item: e
|
|
46
|
-
}, null, 8, ["item"]))), 128))
|
|
47
|
-
]) : Me("", !0)
|
|
48
|
-
]);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
}), u = Se({
|
|
52
|
-
isLoading: null,
|
|
53
|
-
response: null,
|
|
54
|
-
error: null
|
|
55
|
-
}), _e = () => {
|
|
56
|
-
const t = async () => {
|
|
57
|
-
try {
|
|
58
|
-
u.error = null, u.isLoading = !0, u.response = JSON.parse(JSON.stringify(await new ye(k()).config())), u.isLoading = !1;
|
|
59
|
-
} catch (n) {
|
|
60
|
-
u.isLoading = !1, u.response = null, u.error = JSON.parse(JSON.stringify(n));
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
response: u.response,
|
|
64
|
-
error: u.error
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
return {
|
|
68
|
-
...Oe(u),
|
|
69
|
-
fetch: t
|
|
70
|
-
};
|
|
71
|
-
}, qe = (t) => {
|
|
72
|
-
const n = d(!1), l = d(null), i = d(null);
|
|
73
|
-
return {
|
|
74
|
-
isLoading: n,
|
|
75
|
-
response: l,
|
|
76
|
-
error: i,
|
|
77
|
-
fetch: async () => {
|
|
78
|
-
try {
|
|
79
|
-
i.value = null, n.value = !0, l.value = JSON.parse(JSON.stringify(await new me(k()).entityByUniqueid({ uniqueid: t }))), n.value = !1;
|
|
80
|
-
} catch (o) {
|
|
81
|
-
n.value = !1, l.value = null, i.value = JSON.parse(JSON.stringify(o));
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
response: y(l),
|
|
85
|
-
error: y(i)
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
function A() {
|
|
29
|
+
});
|
|
30
|
+
function z() {
|
|
91
31
|
return typeof window > "u" ? !1 : window !== window.top;
|
|
92
32
|
}
|
|
93
|
-
function
|
|
94
|
-
return typeof window > "u" ? !1 :
|
|
33
|
+
function Te() {
|
|
34
|
+
return typeof window > "u" ? !1 : z() ? window.parent : window;
|
|
95
35
|
}
|
|
96
|
-
function
|
|
97
|
-
var n =
|
|
36
|
+
function Ie(e) {
|
|
37
|
+
var n = Te();
|
|
98
38
|
n && n.postMessage({
|
|
99
39
|
action: "openEdit",
|
|
100
|
-
data: JSON.parse(JSON.stringify({ item: { uid:
|
|
40
|
+
data: JSON.parse(JSON.stringify({ item: { uid: e } }))
|
|
101
41
|
}, "https://flyo.cloud");
|
|
102
42
|
}
|
|
103
|
-
function
|
|
104
|
-
typeof window > "u" ||
|
|
43
|
+
function Pe() {
|
|
44
|
+
typeof window > "u" || z() && window.addEventListener("message", (e) => {
|
|
105
45
|
var n;
|
|
106
|
-
((n =
|
|
46
|
+
((n = e.data) == null ? void 0 : n.action) === "pageRefresh" && window.location.reload();
|
|
107
47
|
});
|
|
108
48
|
}
|
|
109
|
-
function
|
|
110
|
-
typeof window > "u" ||
|
|
111
|
-
var n,
|
|
112
|
-
if (((n =
|
|
113
|
-
const
|
|
114
|
-
if (!
|
|
49
|
+
function _e() {
|
|
50
|
+
typeof window > "u" || z() && window.addEventListener("message", (e) => {
|
|
51
|
+
var n, o, i, t;
|
|
52
|
+
if (((n = e.data) == null ? void 0 : n.action) === "scrollTo") {
|
|
53
|
+
const s = (t = (i = (o = e.data) == null ? void 0 : o.data) == null ? void 0 : i.item) == null ? void 0 : t.uid;
|
|
54
|
+
if (!s)
|
|
115
55
|
return;
|
|
116
|
-
const
|
|
117
|
-
|
|
56
|
+
const a = document.querySelector(`[data-flyo-uid="${CSS.escape(s)}"]`);
|
|
57
|
+
a && a.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
118
58
|
}
|
|
119
59
|
});
|
|
120
60
|
}
|
|
121
|
-
function
|
|
122
|
-
const
|
|
123
|
-
if (!
|
|
124
|
-
return
|
|
125
|
-
const i = n,
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
x: Math.max(
|
|
131
|
-
y: Math.max(
|
|
61
|
+
function qe(e, n) {
|
|
62
|
+
const o = () => Ie(e);
|
|
63
|
+
if (!z() || !n)
|
|
64
|
+
return o;
|
|
65
|
+
const i = n, t = document.createElement("button");
|
|
66
|
+
t.type = "button", t.setAttribute("aria-label", "Edit block"), t.style.position = "fixed", t.style.top = "0px", t.style.left = "0px", t.style.zIndex = "9999", t.style.width = "44px", t.style.height = "44px", t.style.display = "none", t.style.alignItems = "center", t.style.justifyContent = "center", t.style.border = "0px solid #000", t.style.borderRadius = "9999px", t.style.boxSizing = "border-box", t.style.cursor = "pointer", t.style.background = "#FFD466", t.innerHTML = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25z" fill="#111"/><path d="M20.71 7.04a1 1 0 0 0 0-1.41l-2.34-2.34a1 1 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" fill="#111"/></svg>';
|
|
67
|
+
const s = document.createElement("div");
|
|
68
|
+
s.style.position = "fixed", s.style.top = "0px", s.style.left = "0px", s.style.zIndex = "9998", s.style.display = "none", s.style.pointerEvents = "none", s.style.background = "transparent", s.style.border = "none", t.addEventListener("click", o), document.body.appendChild(s), document.body.appendChild(t);
|
|
69
|
+
const a = 44, D = 6, ue = 6, r = 6, M = 10, de = 180, S = () => window.innerWidth || document.documentElement.clientWidth, O = () => window.innerHeight || document.documentElement.clientHeight, ce = (l) => !(l.bottom < 0 || l.right < 0 || l.top > O() || l.left > S() || l.width === 0 && l.height === 0), A = (l, f) => l >= r && f >= r && l + a <= S() - r && f + a <= O() - r, U = (l, f) => ({
|
|
70
|
+
x: Math.max(r, Math.min(l, S() - a - r)),
|
|
71
|
+
y: Math.max(r, Math.min(f, O() - a - r))
|
|
132
72
|
});
|
|
133
73
|
function $() {
|
|
134
|
-
const
|
|
135
|
-
let
|
|
136
|
-
if (f &&
|
|
137
|
-
|
|
138
|
-
else if (
|
|
139
|
-
|
|
140
|
-
else if (
|
|
141
|
-
|
|
74
|
+
const l = i.getBoundingClientRect(), f = l.width < a || l.height < a, w = Math.round(l.left), E = Math.round(l.top) - a - ue, I = Math.round(l.left) + D, P = Math.round(l.top) + D;
|
|
75
|
+
let b, L;
|
|
76
|
+
if (f && A(w, E))
|
|
77
|
+
b = w, L = E;
|
|
78
|
+
else if (A(I, P))
|
|
79
|
+
b = I, L = P;
|
|
80
|
+
else if (A(w, E))
|
|
81
|
+
b = w, L = E;
|
|
142
82
|
else {
|
|
143
|
-
const _ =
|
|
144
|
-
({ x:
|
|
83
|
+
const _ = U(w, E), q = U(I, P), ve = Math.abs(_.x - l.left) + Math.abs(_.y - l.top), he = Math.abs(q.x - l.left) + Math.abs(q.y - l.top);
|
|
84
|
+
({ x: b, y: L } = ve <= he ? _ : q);
|
|
145
85
|
}
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
|
|
86
|
+
t.style.left = `${b}px`, t.style.top = `${L}px`;
|
|
87
|
+
const ee = Math.max(r, Math.round(l.left) - M), te = Math.max(r, Math.round(l.top) - M), me = Math.min(S() - r, Math.round(l.right) + M), pe = Math.min(O() - r, Math.round(l.bottom) + M);
|
|
88
|
+
s.style.left = `${ee}px`, s.style.top = `${te}px`, s.style.width = `${Math.max(0, me - ee)}px`, s.style.height = `${Math.max(0, pe - te)}px`;
|
|
149
89
|
}
|
|
150
|
-
let
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
},
|
|
154
|
-
|
|
90
|
+
let m = !1, p = !1, v = !1, N = !1, h = null;
|
|
91
|
+
const C = () => {
|
|
92
|
+
h !== null && (clearTimeout(h), h = null);
|
|
93
|
+
}, R = () => {
|
|
94
|
+
C();
|
|
155
95
|
try {
|
|
156
|
-
const
|
|
157
|
-
if (!
|
|
158
|
-
|
|
96
|
+
const l = i.getBoundingClientRect();
|
|
97
|
+
if (!ce(l)) {
|
|
98
|
+
g(!0);
|
|
159
99
|
return;
|
|
160
100
|
}
|
|
161
|
-
$(),
|
|
101
|
+
$(), t.style.display = "flex", s.style.display = "block", fe();
|
|
162
102
|
} catch {
|
|
163
|
-
|
|
103
|
+
g(!0);
|
|
164
104
|
}
|
|
165
|
-
},
|
|
166
|
-
if (
|
|
167
|
-
|
|
105
|
+
}, g = (l = !1) => {
|
|
106
|
+
if (l) {
|
|
107
|
+
C(), t.style.display = "none", s.style.display = "none", T();
|
|
168
108
|
return;
|
|
169
109
|
}
|
|
170
|
-
|
|
171
|
-
!
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
},
|
|
110
|
+
C(), h = window.setTimeout(() => {
|
|
111
|
+
!m && !p && !v && (t.style.display = "none", s.style.display = "none", T()), h = null;
|
|
112
|
+
}, de);
|
|
113
|
+
}, j = () => {
|
|
114
|
+
t.style.display !== "none" && $();
|
|
115
|
+
}, V = j;
|
|
176
116
|
let c = null;
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
117
|
+
const W = window.ResizeObserver, fe = () => {
|
|
118
|
+
N || (N = !0, window.addEventListener("scroll", j, !0), window.addEventListener("resize", V), typeof W == "function" && (c = new W(() => {
|
|
119
|
+
t.style.display !== "none" && $();
|
|
180
120
|
}), c == null || c.observe(i)));
|
|
181
|
-
},
|
|
182
|
-
if (
|
|
183
|
-
|
|
121
|
+
}, T = () => {
|
|
122
|
+
if (N) {
|
|
123
|
+
N = !1, window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", V);
|
|
184
124
|
try {
|
|
185
125
|
c == null || c.disconnect();
|
|
186
126
|
} catch {
|
|
187
127
|
}
|
|
188
128
|
c = null;
|
|
189
129
|
}
|
|
190
|
-
}, U = () => {
|
|
191
|
-
p = !0, z();
|
|
192
|
-
}, V = () => {
|
|
193
|
-
p = !1, !v && !h && w();
|
|
194
|
-
}, W = () => {
|
|
195
|
-
v = !0, z();
|
|
196
130
|
}, K = () => {
|
|
197
|
-
|
|
131
|
+
m = !0, R();
|
|
198
132
|
}, G = () => {
|
|
199
|
-
|
|
133
|
+
m = !1, !p && !v && g();
|
|
200
134
|
}, Q = () => {
|
|
201
|
-
|
|
135
|
+
p = !0, R();
|
|
136
|
+
}, X = () => {
|
|
137
|
+
p = !1, !m && !v && g();
|
|
138
|
+
}, Y = () => {
|
|
139
|
+
v = !0, R();
|
|
140
|
+
}, Z = () => {
|
|
141
|
+
v = !1, !m && !p && g();
|
|
202
142
|
};
|
|
203
|
-
i.addEventListener("mouseenter",
|
|
204
|
-
function
|
|
205
|
-
|
|
143
|
+
i.addEventListener("mouseenter", K), i.addEventListener("mouseleave", G), t.addEventListener("mouseenter", Q), t.addEventListener("mouseleave", X), s.addEventListener("mouseenter", Y), s.addEventListener("mouseleave", Z), t.addEventListener("click", o);
|
|
144
|
+
function ye() {
|
|
145
|
+
C(), T(), t.removeEventListener("click", o), i.removeEventListener("mouseenter", K), i.removeEventListener("mouseleave", G), t.removeEventListener("mouseenter", Q), t.removeEventListener("mouseleave", X), s.removeEventListener("mouseenter", Y), s.removeEventListener("mouseleave", Z), t.parentElement === document.body && document.body.removeChild(t), s.parentElement === document.body && document.body.removeChild(s);
|
|
206
146
|
}
|
|
207
|
-
return
|
|
147
|
+
return ye;
|
|
208
148
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const o = e
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
149
|
+
let x = null, J = 0, k = !1;
|
|
150
|
+
const H = [], ae = () => {
|
|
151
|
+
H.forEach((e) => e()), H.length = 0;
|
|
152
|
+
}, le = () => {
|
|
153
|
+
ae(), document.querySelectorAll("[data-flyo-uid]").forEach((e) => {
|
|
154
|
+
const n = e.getAttribute("data-flyo-uid");
|
|
155
|
+
if (n && e instanceof HTMLElement) {
|
|
156
|
+
const o = qe(n, e);
|
|
157
|
+
typeof o == "function" && H.push(o);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}, He = () => {
|
|
161
|
+
k || (Pe(), _e(), le(), x = new MutationObserver((e) => {
|
|
162
|
+
e.some(
|
|
163
|
+
(o) => Array.from(o.addedNodes).some((i) => {
|
|
164
|
+
if (i.nodeType !== Node.ELEMENT_NODE)
|
|
165
|
+
return !1;
|
|
166
|
+
const t = i;
|
|
167
|
+
return t.hasAttribute("data-flyo-uid") || t.querySelector("[data-flyo-uid]");
|
|
168
|
+
})
|
|
169
|
+
) && le();
|
|
170
|
+
}), x.observe(document.body, {
|
|
171
|
+
childList: !0,
|
|
172
|
+
subtree: !0
|
|
173
|
+
}), k = !0);
|
|
174
|
+
}, De = () => {
|
|
175
|
+
k && (x && (x.disconnect(), x = null), ae(), k = !1);
|
|
176
|
+
}, Ge = (e) => typeof (e == null ? void 0 : e.uid) == "string" && e.uid.trim() !== "" ? { "data-flyo-uid": e.uid } : {}, Ue = () => {
|
|
177
|
+
const e = Me("flyo");
|
|
178
|
+
e != null && e.liveEdit && (Se(() => {
|
|
179
|
+
J += 1, He();
|
|
180
|
+
}), Oe(() => {
|
|
181
|
+
J = Math.max(0, J - 1), J === 0 && De();
|
|
182
|
+
}));
|
|
183
|
+
}, Ve = {
|
|
184
|
+
name: "FlyoPage"
|
|
185
|
+
}, se = /* @__PURE__ */ Object.assign(Ve, {
|
|
186
|
+
props: {
|
|
187
|
+
page: {
|
|
188
|
+
type: [Object, Boolean],
|
|
189
|
+
default: !1
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
setup(e) {
|
|
193
|
+
return Ue(), (n, o) => {
|
|
194
|
+
const i = Ne("FlyoBlock");
|
|
195
|
+
return F(), ne("div", null, [
|
|
196
|
+
e.page ? Ce(n.$slots, "default", Je(Fe({ key: 0 }, e.page)), () => [
|
|
197
|
+
(F(!0), ne(ke, null, Be(e.page.json, (t) => (F(), ie(i, {
|
|
198
|
+
key: t.uid,
|
|
199
|
+
item: t
|
|
200
|
+
}, null, 8, ["item"]))), 128))
|
|
201
|
+
]) : ze("", !0)
|
|
202
|
+
]);
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}), u = Ae({
|
|
206
|
+
isLoading: null,
|
|
207
|
+
response: null,
|
|
208
|
+
error: null
|
|
209
|
+
}), Qe = () => {
|
|
210
|
+
const e = async () => {
|
|
211
|
+
try {
|
|
212
|
+
u.error = null, u.isLoading = !0, u.response = JSON.parse(JSON.stringify(await new we(B()).config())), u.isLoading = !1;
|
|
213
|
+
} catch (n) {
|
|
214
|
+
u.isLoading = !1, u.response = null, u.error = JSON.parse(JSON.stringify(n));
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
response: u.response,
|
|
218
|
+
error: u.error
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
return {
|
|
222
|
+
...$e(u),
|
|
223
|
+
fetch: e
|
|
224
|
+
};
|
|
225
|
+
}, Xe = (e) => {
|
|
226
|
+
const n = d(!1), o = d(null), i = d(null);
|
|
227
|
+
return {
|
|
228
|
+
isLoading: n,
|
|
229
|
+
response: o,
|
|
230
|
+
error: i,
|
|
231
|
+
fetch: async () => {
|
|
232
|
+
try {
|
|
233
|
+
i.value = null, n.value = !0, o.value = JSON.parse(JSON.stringify(await new Ee(B()).entityByUniqueid({ uniqueid: e }))), n.value = !1;
|
|
234
|
+
} catch (s) {
|
|
235
|
+
n.value = !1, o.value = null, i.value = JSON.parse(JSON.stringify(s));
|
|
220
236
|
}
|
|
221
|
-
|
|
237
|
+
return {
|
|
238
|
+
response: y(o),
|
|
239
|
+
error: y(i)
|
|
240
|
+
};
|
|
241
|
+
}
|
|
222
242
|
};
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
e.some(
|
|
226
|
-
(r) => Array.from(r.addedNodes).some((m) => {
|
|
227
|
-
if (m.nodeType === Node.ELEMENT_NODE) {
|
|
228
|
-
const M = m;
|
|
229
|
-
return M.hasAttribute("data-flyo-uid") || M.querySelector("[data-flyo-uid]");
|
|
230
|
-
}
|
|
231
|
-
return !1;
|
|
232
|
-
})
|
|
233
|
-
) && i();
|
|
234
|
-
}), n.observe(document.body, {
|
|
235
|
-
childList: !0,
|
|
236
|
-
subtree: !0
|
|
237
|
-
});
|
|
238
|
-
}), Je(() => {
|
|
239
|
-
n && n.disconnect(), l.forEach((e) => e()), l.length = 0;
|
|
240
|
-
});
|
|
241
|
-
}, De = (t) => {
|
|
242
|
-
const n = d(!1), l = d(null), i = d(null);
|
|
243
|
+
}, Ye = (e) => {
|
|
244
|
+
const n = d(!1), o = d(null), i = d(null);
|
|
243
245
|
return {
|
|
244
246
|
isLoading: n,
|
|
245
|
-
response:
|
|
247
|
+
response: o,
|
|
246
248
|
error: i,
|
|
247
249
|
fetch: async () => {
|
|
248
250
|
try {
|
|
249
|
-
i.value = null, n.value = !0,
|
|
250
|
-
} catch (
|
|
251
|
-
n.value = !1,
|
|
251
|
+
i.value = null, n.value = !0, o.value = JSON.parse(JSON.stringify(await new be(B()).page({ slug: e }))), n.value = !1;
|
|
252
|
+
} catch (s) {
|
|
253
|
+
n.value = !1, o.value = null, i.value = JSON.parse(JSON.stringify(s));
|
|
252
254
|
}
|
|
253
255
|
return {
|
|
254
|
-
response: y(
|
|
256
|
+
response: y(o),
|
|
255
257
|
error: y(i)
|
|
256
258
|
};
|
|
257
259
|
}
|
|
258
260
|
};
|
|
259
|
-
},
|
|
260
|
-
const
|
|
261
|
+
}, Ze = () => {
|
|
262
|
+
const e = d(!1), n = d(null), o = d(null);
|
|
261
263
|
return {
|
|
262
|
-
isLoading:
|
|
264
|
+
isLoading: e,
|
|
263
265
|
response: n,
|
|
264
|
-
error:
|
|
266
|
+
error: o,
|
|
265
267
|
fetch: async () => {
|
|
266
268
|
try {
|
|
267
|
-
|
|
268
|
-
} catch (
|
|
269
|
-
|
|
269
|
+
o.value = null, e.value = !0, n.value = JSON.parse(JSON.stringify(await new Le(B()).sitemap())), e.value = !1;
|
|
270
|
+
} catch (t) {
|
|
271
|
+
e.value = !1, n.value = null, o.value = JSON.parse(JSON.stringify(t));
|
|
270
272
|
}
|
|
271
273
|
return {
|
|
272
274
|
response: y(n),
|
|
273
|
-
error: y(
|
|
275
|
+
error: y(o)
|
|
274
276
|
};
|
|
275
277
|
}
|
|
276
278
|
};
|
|
277
|
-
},
|
|
278
|
-
install(
|
|
279
|
-
|
|
279
|
+
}, et = {
|
|
280
|
+
install(e, n) {
|
|
281
|
+
Re(n), e.component(oe.name, oe), e.component(se.name, se), e.provide("flyo", {
|
|
280
282
|
liveEdit: n.liveEdit,
|
|
281
283
|
liveEditOrigin: n.liveEditOrigin
|
|
282
284
|
});
|
|
283
285
|
}
|
|
284
286
|
};
|
|
285
287
|
export {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
288
|
+
oe as Block,
|
|
289
|
+
et as FlyoVue,
|
|
290
|
+
se as Page,
|
|
291
|
+
et as default,
|
|
292
|
+
Ge as editable,
|
|
293
|
+
B as getFlyoConfig,
|
|
294
|
+
Qe as useFlyoConfig,
|
|
295
|
+
Xe as useFlyoEntity,
|
|
296
|
+
Ue as useFlyoLiveEdit,
|
|
297
|
+
Ye as useFlyoPage,
|
|
298
|
+
Ze as useFlyoSitemap
|
|
297
299
|
};
|