@flyo/nitro-vue3 1.0.2 → 2.0.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 +196 -4
- package/dist/index.cjs +1 -0
- package/dist/index.mjs +163 -0
- package/package.json +18 -10
- package/dist/index.js +0 -277
package/README.md
CHANGED
|
@@ -1,9 +1,201 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @flyo/nitro-vue3
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Vue 3 integration for [Flyo Nitro](https://github.com/flyocloud/nitro-typescript-sdk) — build Vue 3 sites powered by the Flyo CMS with ready-made components and composables.
|
|
4
4
|
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @flyo/nitro-vue3
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
Register the plugin in your Vue application entry point. You need a Flyo API token from your Nitro configuration.
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { createApp } from 'vue'
|
|
17
|
+
import { FlyoVue } from '@flyo/nitro-vue3'
|
|
18
|
+
import App from './App.vue'
|
|
19
|
+
|
|
20
|
+
const app = createApp(App)
|
|
21
|
+
|
|
22
|
+
app.use(FlyoVue, {
|
|
23
|
+
apiToken: 'YOUR_FLYO_API_TOKEN',
|
|
24
|
+
// optional: override the API base URL
|
|
25
|
+
// apiBasePath: 'https://api.flyo.cloud/nitro/v1',
|
|
26
|
+
// optional: additional default request headers
|
|
27
|
+
// defaultHeaders: {},
|
|
28
|
+
// optional: enable live-edit mode (for use inside the Flyo preview iframe)
|
|
29
|
+
liveEdit: false,
|
|
30
|
+
liveEditOrigin: 'https://flyo.cloud'
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
app.mount('#app')
|
|
5
34
|
```
|
|
6
|
-
|
|
35
|
+
|
|
36
|
+
## Components
|
|
37
|
+
|
|
38
|
+
Both components are globally registered when you call `app.use(FlyoVue, ...)`.
|
|
39
|
+
|
|
40
|
+
### `<FlyoPage>`
|
|
41
|
+
|
|
42
|
+
Renders the blocks of a page returned by `useFlyoPage`. It handles the live-edit postMessage bridge automatically, so editors can preview changes in real time inside the Flyo UI.
|
|
43
|
+
|
|
44
|
+
**Props**
|
|
45
|
+
|
|
46
|
+
| Prop | Type | Default | Description |
|
|
47
|
+
|---|---|---|---|
|
|
48
|
+
| `page` | `Object \| Boolean` | `false` | The page object returned by `useFlyoPage().fetch()` |
|
|
49
|
+
|
|
50
|
+
**Events**
|
|
51
|
+
|
|
52
|
+
| Event | Payload | Description |
|
|
53
|
+
|---|---|---|
|
|
54
|
+
| `update:page` | updated page | Emitted when the Flyo live-edit bridge pushes a new page state |
|
|
55
|
+
|
|
56
|
+
**Example**
|
|
57
|
+
|
|
58
|
+
```vue
|
|
59
|
+
<script setup>
|
|
60
|
+
import { useFlyoPage } from '@flyo/nitro-vue3'
|
|
61
|
+
|
|
62
|
+
const { response: page, fetch } = useFlyoPage('about-us')
|
|
63
|
+
await fetch()
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<template>
|
|
67
|
+
<FlyoPage v-model:page="page" />
|
|
68
|
+
</template>
|
|
7
69
|
```
|
|
8
70
|
|
|
9
|
-
|
|
71
|
+
You can also use the default slot to wrap the output:
|
|
72
|
+
|
|
73
|
+
```vue
|
|
74
|
+
<FlyoPage :page="page">
|
|
75
|
+
<template #default="{ json }">
|
|
76
|
+
<FlyoBlock v-for="item in json" :key="item.uid" :item="item" />
|
|
77
|
+
</template>
|
|
78
|
+
</FlyoPage>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### `<FlyoBlock>`
|
|
84
|
+
|
|
85
|
+
Renders a single content block by resolving the block's `component` name to a locally or globally registered Vue component and passing all block data as props.
|
|
86
|
+
|
|
87
|
+
**Props**
|
|
88
|
+
|
|
89
|
+
| Prop | Type | Default | Description |
|
|
90
|
+
|---|---|---|---|
|
|
91
|
+
| `item` | `Object` | `{}` | A block object from `page.json` |
|
|
92
|
+
|
|
93
|
+
The resolved component receives: `config`, `content`, `items`, and `slots`.
|
|
94
|
+
|
|
95
|
+
**Example**
|
|
96
|
+
|
|
97
|
+
```vue
|
|
98
|
+
<FlyoBlock :item="item" />
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Composables
|
|
104
|
+
|
|
105
|
+
### `useFlyoConfig()`
|
|
106
|
+
|
|
107
|
+
Fetches the global Nitro config (navigation containers, available slugs, globals).
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
import { useFlyoConfig } from '@flyo/nitro-vue3'
|
|
111
|
+
|
|
112
|
+
const { isLoading, response, error, fetch } = useFlyoConfig()
|
|
113
|
+
|
|
114
|
+
// fetch once on mount
|
|
115
|
+
await fetch()
|
|
116
|
+
|
|
117
|
+
console.log(response.value) // ConfigResponse
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### `useFlyoPage(slug)`
|
|
123
|
+
|
|
124
|
+
Fetches a page by its slug.
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
import { useFlyoPage } from '@flyo/nitro-vue3'
|
|
128
|
+
|
|
129
|
+
const { isLoading, response, error, fetch } = useFlyoPage('about-us')
|
|
130
|
+
|
|
131
|
+
await fetch()
|
|
132
|
+
|
|
133
|
+
console.log(response.value) // Page object with .json blocks, meta info, etc.
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### `useFlyoEntity(uniqueid)`
|
|
139
|
+
|
|
140
|
+
Fetches a single entity by its Nitro unique identifier.
|
|
141
|
+
|
|
142
|
+
```js
|
|
143
|
+
import { useFlyoEntity } from '@flyo/nitro-vue3'
|
|
144
|
+
|
|
145
|
+
const { isLoading, response, error, fetch } = useFlyoEntity('my-blog-entry-uid')
|
|
146
|
+
|
|
147
|
+
await fetch()
|
|
148
|
+
|
|
149
|
+
console.log(response.value) // Entity fields
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
### `useFlyoSitemap()`
|
|
155
|
+
|
|
156
|
+
Fetches the full sitemap — all pages and mapped entities including their resolved `href` paths.
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
import { useFlyoSitemap } from '@flyo/nitro-vue3'
|
|
160
|
+
|
|
161
|
+
const { isLoading, response, error, fetch } = useFlyoSitemap()
|
|
162
|
+
|
|
163
|
+
await fetch()
|
|
164
|
+
|
|
165
|
+
console.log(response.value) // Array of sitemap items
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Composable return values
|
|
171
|
+
|
|
172
|
+
Every composable returns the same reactive shape:
|
|
173
|
+
|
|
174
|
+
| Key | Type | Description |
|
|
175
|
+
|---|---|---|
|
|
176
|
+
| `isLoading` | `Ref<boolean \| null>` | `true` while the request is in flight |
|
|
177
|
+
| `response` | `Ref<T \| null>` | The response data, `null` until fetched |
|
|
178
|
+
| `error` | `Ref<any \| null>` | The error object if the request failed |
|
|
179
|
+
| `fetch` | `async () => { response, error }` | Call this to trigger the request |
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Live-edit support
|
|
184
|
+
|
|
185
|
+
When your site is embedded in the Flyo preview iframe, `FlyoPage` automatically listens for `pageRefresh` messages and emits `update:page` so your component can reactively update without a full reload. Enable this by passing `liveEdit: true` to the plugin options.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Releases
|
|
190
|
+
|
|
191
|
+
This package uses [semantic-release](https://github.com/semantic-release/semantic-release) — versions are bumped automatically based on [Conventional Commits](https://www.conventionalcommits.org/):
|
|
192
|
+
|
|
193
|
+
| Commit prefix | Release type |
|
|
194
|
+
|---|---|
|
|
195
|
+
| `fix:` | Patch (`1.0.x`) |
|
|
196
|
+
| `feat:` | Minor (`1.x.0`) |
|
|
197
|
+
| `feat!:` / `BREAKING CHANGE` | Major (`x.0.0`) |
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("@flyo/nitro-typescript"),e=require("vue");let m=null;const F=({apiToken:n,apiBasePath:t,defaultHeaders:o})=>{m=new u.Configuration({apiKey:n,...t&&{basePath:t},headers:o||{}})},f=()=>m,N={name:"FlyoBlock"},y=Object.assign(N,{props:{item:{type:Object,default:()=>{}}},setup(n){return(t,o)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.item.component),{config:n.item.config,content:n.item.content,items:n.item.items,slots:n.item.slots},null,8,["config","content","items","slots"]))}}),J={name:"FlyoPage"},d=Object.assign(J,{props:{page:{type:[Object,Boolean],default:!1}},emits:["update:page"],setup(n,{emit:t}){const o=n,s=t,{liveEdit:a,liveEditOrigin:i}=e.inject("flyo"),p=r=>{const c=r.parent||r.opener;return r.self===c?!1:r.parent||r.opener},O=r=>{a&&process.client&&p(window)&&p(window).postMessage({action:"openEdit",data:JSON.parse(JSON.stringify({page:o.page,item:r}))},i)};return process.client&&p(window)&&window.addEventListener("message",r=>{if(r.origin!==i){console.log(`Message from ${r.origin} blocked. Expected ${i}.`);return}const c=r.data;c.action==="pageRefresh"&&s("update:page",c.data)}),(r,c)=>{const S=e.resolveComponent("FlyoBlock");return e.openBlock(),e.createElementBlock("div",null,[n.page?e.renderSlot(r.$slots,"default",e.normalizeProps(e.mergeProps({key:0},n.page)),()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.page.json,g=>(e.openBlock(),e.createBlock(S,{key:g.uid,item:g,onClick:()=>O(g)},null,8,["item","onClick"]))),128))]):e.createCommentVNode("",!0)])}}}),l=e.reactive({isLoading:null,response:null,error:null}),k=()=>{const n=async()=>{try{l.error=null,l.isLoading=!0,l.response=JSON.parse(JSON.stringify(await new u.ConfigApi(f()).config())),l.isLoading=!1}catch(t){l.isLoading=!1,l.response=null,l.error=JSON.parse(JSON.stringify(t))}return{response:l.response,error:l.error}};return{...e.toRefs(l),fetch:n}},h=n=>{const t=e.ref(!1),o=e.ref(null),s=e.ref(null);return{isLoading:t,response:o,error:s,fetch:async()=>{try{s.value=null,t.value=!0,o.value=JSON.parse(JSON.stringify(await new u.EntitiesApi(f()).entityByUniqueid({uniqueid:n}))),t.value=!1}catch(i){t.value=!1,o.value=null,s.value=JSON.parse(JSON.stringify(i))}return{response:e.unref(o),error:e.unref(s)}}}},E=n=>{const t=e.ref(!1),o=e.ref(null),s=e.ref(null);return{isLoading:t,response:o,error:s,fetch:async()=>{try{s.value=null,t.value=!0,o.value=JSON.parse(JSON.stringify(await new u.PagesApi(f()).page({slug:n}))),t.value=!1}catch(i){t.value=!1,o.value=null,s.value=JSON.parse(JSON.stringify(i))}return{response:e.unref(o),error:e.unref(s)}}}},B=()=>{const n=e.ref(!1),t=e.ref(null),o=e.ref(null);return{isLoading:n,response:t,error:o,fetch:async()=>{try{o.value=null,n.value=!0,t.value=JSON.parse(JSON.stringify(await new u.SitemapApi(f()).sitemap())),n.value=!1}catch(a){n.value=!1,t.value=null,o.value=JSON.parse(JSON.stringify(a))}return{response:e.unref(t),error:e.unref(o)}}}},v={install(n,t){F(t),n.component(y.name,y),n.component(d.name,d),n.provide("flyo",{liveEdit:t.liveEdit,liveEditOrigin:t.liveEditOrigin})}};exports.Block=y;exports.FlyoVue=v;exports.Page=d;exports.default=v;exports.getFlyoConfig=f;exports.useFlyoConfig=k;exports.useFlyoEntity=h;exports.useFlyoPage=E;exports.useFlyoSitemap=B;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { Configuration as h, ConfigApi as E, EntitiesApi as F, PagesApi as k, SitemapApi as w } from "@flyo/nitro-typescript";
|
|
2
|
+
import { openBlock as f, createBlock as O, resolveDynamicComponent as C, inject as L, resolveComponent as B, createElementBlock as y, renderSlot as b, normalizeProps as j, mergeProps as P, Fragment as A, renderList as $, createCommentVNode as _, reactive as x, toRefs as M, ref as a, unref as i } from "vue";
|
|
3
|
+
let S = null;
|
|
4
|
+
const R = ({ apiToken: e, apiBasePath: n, defaultHeaders: t }) => {
|
|
5
|
+
S = new h({
|
|
6
|
+
apiKey: e,
|
|
7
|
+
...n && { basePath: n },
|
|
8
|
+
headers: t || {}
|
|
9
|
+
});
|
|
10
|
+
}, p = () => S, W = {
|
|
11
|
+
name: "FlyoBlock"
|
|
12
|
+
}, d = /* @__PURE__ */ Object.assign(W, {
|
|
13
|
+
props: {
|
|
14
|
+
item: {
|
|
15
|
+
type: Object,
|
|
16
|
+
default: () => {
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
setup(e) {
|
|
21
|
+
return (n, t) => (f(), O(C(e.item.component), {
|
|
22
|
+
config: e.item.config,
|
|
23
|
+
content: e.item.content,
|
|
24
|
+
items: e.item.items,
|
|
25
|
+
slots: e.item.slots
|
|
26
|
+
}, null, 8, ["config", "content", "items", "slots"]));
|
|
27
|
+
}
|
|
28
|
+
}), q = {
|
|
29
|
+
name: "FlyoPage"
|
|
30
|
+
}, v = /* @__PURE__ */ Object.assign(q, {
|
|
31
|
+
props: {
|
|
32
|
+
page: {
|
|
33
|
+
type: [Object, Boolean],
|
|
34
|
+
default: !1
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
emits: ["update:page"],
|
|
38
|
+
setup(e, { emit: n }) {
|
|
39
|
+
const t = e, o = n, { liveEdit: c, liveEditOrigin: l } = L("flyo"), g = (s) => {
|
|
40
|
+
const u = s.parent || s.opener;
|
|
41
|
+
return s.self === u ? !1 : s.parent || s.opener;
|
|
42
|
+
}, N = (s) => {
|
|
43
|
+
c && process.client && g(window) && g(window).postMessage({
|
|
44
|
+
action: "openEdit",
|
|
45
|
+
data: JSON.parse(JSON.stringify({
|
|
46
|
+
page: t.page,
|
|
47
|
+
item: s
|
|
48
|
+
}))
|
|
49
|
+
}, l);
|
|
50
|
+
};
|
|
51
|
+
return process.client && g(window) && window.addEventListener("message", (s) => {
|
|
52
|
+
if (s.origin !== l) {
|
|
53
|
+
console.log(`Message from ${s.origin} blocked. Expected ${l}.`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const u = s.data;
|
|
57
|
+
u.action === "pageRefresh" && o("update:page", u.data);
|
|
58
|
+
}), (s, u) => {
|
|
59
|
+
const J = B("FlyoBlock");
|
|
60
|
+
return f(), y("div", null, [
|
|
61
|
+
e.page ? b(s.$slots, "default", j(P({ key: 0 }, e.page)), () => [
|
|
62
|
+
(f(!0), y(A, null, $(e.page.json, (m) => (f(), O(J, {
|
|
63
|
+
key: m.uid,
|
|
64
|
+
item: m,
|
|
65
|
+
onClick: () => N(m)
|
|
66
|
+
}, null, 8, ["item", "onClick"]))), 128))
|
|
67
|
+
]) : _("", !0)
|
|
68
|
+
]);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}), r = x({
|
|
72
|
+
isLoading: null,
|
|
73
|
+
response: null,
|
|
74
|
+
error: null
|
|
75
|
+
}), K = () => {
|
|
76
|
+
const e = async () => {
|
|
77
|
+
try {
|
|
78
|
+
r.error = null, r.isLoading = !0, r.response = JSON.parse(JSON.stringify(await new E(p()).config())), r.isLoading = !1;
|
|
79
|
+
} catch (n) {
|
|
80
|
+
r.isLoading = !1, r.response = null, r.error = JSON.parse(JSON.stringify(n));
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
response: r.response,
|
|
84
|
+
error: r.error
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
...M(r),
|
|
89
|
+
fetch: e
|
|
90
|
+
};
|
|
91
|
+
}, U = (e) => {
|
|
92
|
+
const n = a(!1), t = a(null), o = a(null);
|
|
93
|
+
return {
|
|
94
|
+
isLoading: n,
|
|
95
|
+
response: t,
|
|
96
|
+
error: o,
|
|
97
|
+
fetch: async () => {
|
|
98
|
+
try {
|
|
99
|
+
o.value = null, n.value = !0, t.value = JSON.parse(JSON.stringify(await new F(p()).entityByUniqueid({ uniqueid: e }))), n.value = !1;
|
|
100
|
+
} catch (l) {
|
|
101
|
+
n.value = !1, t.value = null, o.value = JSON.parse(JSON.stringify(l));
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
response: i(t),
|
|
105
|
+
error: i(o)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}, G = (e) => {
|
|
110
|
+
const n = a(!1), t = a(null), o = a(null);
|
|
111
|
+
return {
|
|
112
|
+
isLoading: n,
|
|
113
|
+
response: t,
|
|
114
|
+
error: o,
|
|
115
|
+
fetch: async () => {
|
|
116
|
+
try {
|
|
117
|
+
o.value = null, n.value = !0, t.value = JSON.parse(JSON.stringify(await new k(p()).page({ slug: e }))), n.value = !1;
|
|
118
|
+
} catch (l) {
|
|
119
|
+
n.value = !1, t.value = null, o.value = JSON.parse(JSON.stringify(l));
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
response: i(t),
|
|
123
|
+
error: i(o)
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}, H = () => {
|
|
128
|
+
const e = a(!1), n = a(null), t = a(null);
|
|
129
|
+
return {
|
|
130
|
+
isLoading: e,
|
|
131
|
+
response: n,
|
|
132
|
+
error: t,
|
|
133
|
+
fetch: async () => {
|
|
134
|
+
try {
|
|
135
|
+
t.value = null, e.value = !0, n.value = JSON.parse(JSON.stringify(await new w(p()).sitemap())), e.value = !1;
|
|
136
|
+
} catch (c) {
|
|
137
|
+
e.value = !1, n.value = null, t.value = JSON.parse(JSON.stringify(c));
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
response: i(n),
|
|
141
|
+
error: i(t)
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}, I = {
|
|
146
|
+
install(e, n) {
|
|
147
|
+
R(n), e.component(d.name, d), e.component(v.name, v), e.provide("flyo", {
|
|
148
|
+
liveEdit: n.liveEdit,
|
|
149
|
+
liveEditOrigin: n.liveEditOrigin
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
export {
|
|
154
|
+
d as Block,
|
|
155
|
+
I as FlyoVue,
|
|
156
|
+
v as Page,
|
|
157
|
+
I as default,
|
|
158
|
+
p as getFlyoConfig,
|
|
159
|
+
K as useFlyoConfig,
|
|
160
|
+
U as useFlyoEntity,
|
|
161
|
+
G as useFlyoPage,
|
|
162
|
+
H as useFlyoSitemap
|
|
163
|
+
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flyo/nitro-vue3",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Vue3 Components for Flyo Nitro",
|
|
5
|
-
"main": "./dist/index.
|
|
6
|
-
"module": "./dist/index.
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"import": "./dist/index.
|
|
9
|
+
"import": "./dist/index.mjs",
|
|
10
|
+
"require": "./dist/index.cjs"
|
|
10
11
|
}
|
|
11
12
|
},
|
|
12
13
|
"repository": "git@github.com:flyocloud/nitro-vue3.git",
|
|
@@ -17,19 +18,26 @@
|
|
|
17
18
|
"dist"
|
|
18
19
|
],
|
|
19
20
|
"scripts": {
|
|
20
|
-
"build": "
|
|
21
|
+
"build": "vite build",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest",
|
|
21
24
|
"release": "npm publish --access=public"
|
|
22
25
|
},
|
|
23
26
|
"peerDependencies": {
|
|
24
27
|
"vue": "^3.2.21"
|
|
25
28
|
},
|
|
26
29
|
"devDependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
30
|
+
"@semantic-release/changelog": "^6.0.0",
|
|
31
|
+
"@semantic-release/git": "^10.0.0",
|
|
32
|
+
"@vitejs/plugin-vue": "^5.0.0",
|
|
33
|
+
"@vue/compiler-sfc": "^3.4.0",
|
|
34
|
+
"@vue/test-utils": "^2.4.0",
|
|
35
|
+
"happy-dom": "^13.0.0",
|
|
36
|
+
"semantic-release": "^24.0.0",
|
|
37
|
+
"vite": "^5.0.0",
|
|
38
|
+
"vitest": "^1.0.0"
|
|
31
39
|
},
|
|
32
40
|
"dependencies": {
|
|
33
|
-
"@flyo/nitro-
|
|
41
|
+
"@flyo/nitro-typescript": "^1.4.0"
|
|
34
42
|
}
|
|
35
43
|
}
|
package/dist/index.js
DELETED
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
import { ApiClient, ConfigApi, EntitiesApi, PagesApi, SitemapApi } from '@flyo/nitro-js';
|
|
2
|
-
import { openBlock, createBlock, resolveDynamicComponent, inject, resolveComponent, createElementBlock, renderSlot, normalizeProps, mergeProps, Fragment, renderList, createCommentVNode, reactive, toRefs, ref, unref } from 'vue';
|
|
3
|
-
|
|
4
|
-
const initFlyoApi = ({ apiToken, apiBasePath, defaultHeaders }) => {
|
|
5
|
-
const defaultClient = ApiClient.instance;
|
|
6
|
-
defaultClient.defaultHeaders = defaultHeaders || {};
|
|
7
|
-
|
|
8
|
-
if (apiBasePath) {
|
|
9
|
-
defaultClient.basePath = apiBasePath;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const ApiToken = defaultClient.authentications["ApiToken"];
|
|
13
|
-
ApiToken.apiKey = apiToken;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const __default__$1 = {
|
|
17
|
-
name: 'FlyoBlock'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var script$1 = /*#__PURE__*/Object.assign(__default__$1, {
|
|
22
|
-
props: {
|
|
23
|
-
item: {
|
|
24
|
-
type: Object,
|
|
25
|
-
default: () => { }
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
setup(__props) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return (_ctx, _cache) => {
|
|
33
|
-
return (openBlock(), createBlock(resolveDynamicComponent(__props.item.component), {
|
|
34
|
-
config: __props.item.config,
|
|
35
|
-
content: __props.item.content,
|
|
36
|
-
items: __props.item.items,
|
|
37
|
-
slots: __props.item.slots
|
|
38
|
-
}, null, 8 /* PROPS */, ["config", "content", "items", "slots"]))
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
script$1.__file = "src/components/Block.vue";
|
|
45
|
-
|
|
46
|
-
const __default__ = {
|
|
47
|
-
name: 'FlyoPage'
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var script = /*#__PURE__*/Object.assign(__default__, {
|
|
52
|
-
props: {
|
|
53
|
-
page: {
|
|
54
|
-
type: [Object, Boolean],
|
|
55
|
-
default: false
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
emits: ['update:page'],
|
|
59
|
-
setup(__props, { emit: emits }) {
|
|
60
|
-
|
|
61
|
-
const props = __props;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const { liveEdit, liveEditOrigin } = inject('flyo');
|
|
68
|
-
|
|
69
|
-
const parentWindow = window => {
|
|
70
|
-
const parentWindow = window.parent || window.opener;
|
|
71
|
-
if (window.self === parentWindow) {
|
|
72
|
-
return false
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return window.parent || window.opener;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const openFlyoEdit = (item) => {
|
|
79
|
-
if (!liveEdit) {
|
|
80
|
-
return
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (process.client && parentWindow(window)) {
|
|
84
|
-
parentWindow(window).postMessage({
|
|
85
|
-
action: 'openEdit',
|
|
86
|
-
data: JSON.parse(JSON.stringify({
|
|
87
|
-
page: props.page,
|
|
88
|
-
item: item
|
|
89
|
-
}))
|
|
90
|
-
}, liveEditOrigin);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
if (process.client && parentWindow(window)) {
|
|
95
|
-
window.addEventListener("message", (event) => {
|
|
96
|
-
if (event.origin !== liveEditOrigin) {
|
|
97
|
-
console.log(`Message from ${event.origin} blocked. Expected ${liveEditOrigin}.`);
|
|
98
|
-
return
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const message = event.data;
|
|
102
|
-
if (message.action === 'pageRefresh') {
|
|
103
|
-
emits('update:page', message.data);
|
|
104
|
-
|
|
105
|
-
/*
|
|
106
|
-
const itemIndex = props.page.json.findIndex(item => item.uid === data.uid)
|
|
107
|
-
props.page.json[itemIndex] = {
|
|
108
|
-
...props.page.json[itemIndex],
|
|
109
|
-
...data
|
|
110
|
-
}
|
|
111
|
-
*/
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return (_ctx, _cache) => {
|
|
117
|
-
const _component_FlyoBlock = resolveComponent("FlyoBlock");
|
|
118
|
-
|
|
119
|
-
return (openBlock(), createElementBlock("div", null, [
|
|
120
|
-
(__props.page)
|
|
121
|
-
? renderSlot(_ctx.$slots, "default", normalizeProps(mergeProps({ key: 0 }, __props.page)), () => [
|
|
122
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.page.json, (item) => {
|
|
123
|
-
return (openBlock(), createBlock(_component_FlyoBlock, {
|
|
124
|
-
key: item.uid,
|
|
125
|
-
item: item,
|
|
126
|
-
onClick: () => openFlyoEdit(item)
|
|
127
|
-
}, null, 8 /* PROPS */, ["item", "onClick"]))
|
|
128
|
-
}), 128 /* KEYED_FRAGMENT */))
|
|
129
|
-
])
|
|
130
|
-
: createCommentVNode("v-if", true)
|
|
131
|
-
]))
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
script.__file = "src/components/Page.vue";
|
|
138
|
-
|
|
139
|
-
const flyoConfigState = reactive({
|
|
140
|
-
isLoading: null,
|
|
141
|
-
response: null,
|
|
142
|
-
error: null
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const useFlyoConfig = () => {
|
|
146
|
-
const fetch = async () => {
|
|
147
|
-
try {
|
|
148
|
-
flyoConfigState.error = null;
|
|
149
|
-
flyoConfigState.isLoading = true;
|
|
150
|
-
flyoConfigState.response = JSON.parse(JSON.stringify(await new ConfigApi().config()));
|
|
151
|
-
flyoConfigState.isLoading = false;
|
|
152
|
-
} catch (e) {
|
|
153
|
-
flyoConfigState.isLoading = false;
|
|
154
|
-
flyoConfigState.response = null;
|
|
155
|
-
flyoConfigState.error = JSON.parse(JSON.stringify(e));
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return {
|
|
159
|
-
response: flyoConfigState.response,
|
|
160
|
-
error: flyoConfigState.error
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
return {
|
|
165
|
-
...toRefs(flyoConfigState),
|
|
166
|
-
fetch
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const useFlyoEntity = (uniqueid) => {
|
|
171
|
-
const isLoading = ref(false);
|
|
172
|
-
const response = ref(null);
|
|
173
|
-
const error = ref(null);
|
|
174
|
-
|
|
175
|
-
const fetch = async () => {
|
|
176
|
-
try {
|
|
177
|
-
error.value = null;
|
|
178
|
-
isLoading.value = true;
|
|
179
|
-
response.value = JSON.parse(JSON.stringify(await new EntitiesApi().entity(uniqueid)));
|
|
180
|
-
} catch (e) {
|
|
181
|
-
isLoading.value = false;
|
|
182
|
-
response.value = null;
|
|
183
|
-
error.value = JSON.parse(JSON.stringify(e));
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return {
|
|
187
|
-
response: unref(response),
|
|
188
|
-
error: unref(error)
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
return {
|
|
193
|
-
isLoading,
|
|
194
|
-
response,
|
|
195
|
-
error,
|
|
196
|
-
fetch
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const useFlyoPage = (slug) => {
|
|
201
|
-
const isLoading = ref(false);
|
|
202
|
-
const response = ref(null);
|
|
203
|
-
const error = ref(null);
|
|
204
|
-
|
|
205
|
-
const fetch = async () => {
|
|
206
|
-
try {
|
|
207
|
-
error.value = null;
|
|
208
|
-
isLoading.value = true;
|
|
209
|
-
response.value = JSON.parse(JSON.stringify(await new PagesApi().page({ slug })));
|
|
210
|
-
} catch (e) {
|
|
211
|
-
isLoading.value = false;
|
|
212
|
-
response.value = null;
|
|
213
|
-
error.value = JSON.parse(JSON.stringify(e));
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
return {
|
|
217
|
-
response: unref(response),
|
|
218
|
-
error: unref(error)
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
return {
|
|
223
|
-
isLoading,
|
|
224
|
-
response,
|
|
225
|
-
error,
|
|
226
|
-
fetch
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
const useFlyoSitemap = () => {
|
|
231
|
-
const isLoading = ref(false);
|
|
232
|
-
const response = ref(null);
|
|
233
|
-
const error = ref(null);
|
|
234
|
-
|
|
235
|
-
const fetch = async () => {
|
|
236
|
-
try {
|
|
237
|
-
error.value = null;
|
|
238
|
-
isLoading.value = true;
|
|
239
|
-
response.value = JSON.parse(JSON.stringify(await new SitemapApi().sitemap()));
|
|
240
|
-
} catch (e) {
|
|
241
|
-
isLoading.value = false;
|
|
242
|
-
sitemap.value = null;
|
|
243
|
-
error.value = JSON.parse(JSON.stringify(e));
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return {
|
|
247
|
-
response: unref(response),
|
|
248
|
-
error: unref(error)
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
return {
|
|
253
|
-
isLoading,
|
|
254
|
-
response,
|
|
255
|
-
error,
|
|
256
|
-
fetch
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
const FlyoVue = {
|
|
261
|
-
install(Vue, options) {
|
|
262
|
-
// Initialize the flyo api
|
|
263
|
-
initFlyoApi(options);
|
|
264
|
-
|
|
265
|
-
// Setup flyo components
|
|
266
|
-
Vue.component(script$1.name, script$1);
|
|
267
|
-
Vue.component(script.name, script);
|
|
268
|
-
|
|
269
|
-
// Provide flyo object with global / persistent data
|
|
270
|
-
Vue.provide('flyo', {
|
|
271
|
-
liveEdit: options.liveEdit,
|
|
272
|
-
liveEditOrigin: options.liveEditOrigin
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
export { script$1 as Block, FlyoVue, script as Page, FlyoVue as default, useFlyoConfig, useFlyoEntity, useFlyoPage, useFlyoSitemap };
|