@xosen/site-sdk 0.0.3 → 0.0.4
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/index.js +90 -73
- package/package.json +1 -1
- package/src/composables/useLivePreview.ts +53 -0
- package/src/index.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { onMounted as
|
|
2
|
-
import { useI18n as
|
|
1
|
+
import { onMounted as C, computed as f, defineComponent as y, openBlock as n, createElementBlock as a, Fragment as h, renderList as v, normalizeClass as k, toDisplayString as _, ref as w, onUnmounted as A, resolveComponent as E, createElementVNode as u, createVNode as P, withCtx as B, createBlock as T, createTextVNode as L, createCommentVNode as d, renderSlot as H, normalizeStyle as U, resolveDynamicComponent as R, watch as I, mergeProps as z } from "vue";
|
|
2
|
+
import { useI18n as M } from "vue-i18n";
|
|
3
3
|
function G(r) {
|
|
4
4
|
function o(e) {
|
|
5
5
|
const t = document.documentElement;
|
|
@@ -8,7 +8,7 @@ function G(r) {
|
|
|
8
8
|
i && t.style.setProperty(`--x-color-${J(c)}`, i);
|
|
9
9
|
e.typography?.fontFamily && t.style.setProperty("--x-font-family", e.typography.fontFamily), e.typography?.headingFont && t.style.setProperty("--x-font-heading", e.typography.headingFont), e.typography?.baseFontSize && t.style.setProperty("--x-font-size", e.typography.baseFontSize), e.shape?.borderRadius && t.style.setProperty("--x-border-radius", e.shape.borderRadius), e.shape?.maxWidth && t.style.setProperty("--x-max-width", e.shape.maxWidth);
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
C(() => {
|
|
12
12
|
if (r) {
|
|
13
13
|
o(r);
|
|
14
14
|
return;
|
|
@@ -48,7 +48,7 @@ const V = /* @__PURE__ */ y({
|
|
|
48
48
|
},
|
|
49
49
|
setup(r, { expose: o }) {
|
|
50
50
|
o();
|
|
51
|
-
const { locale: e } =
|
|
51
|
+
const { locale: e } = M();
|
|
52
52
|
function t(i) {
|
|
53
53
|
e.value = i, localStorage.setItem("site-locale", i);
|
|
54
54
|
}
|
|
@@ -80,11 +80,11 @@ const Z = /* @__PURE__ */ x(V, [["render", Y], ["__scopeId", "data-v-675f0bbd"],
|
|
|
80
80
|
__name: "XSiteNav",
|
|
81
81
|
setup(r, { expose: o }) {
|
|
82
82
|
o();
|
|
83
|
-
const { navigation: e, branding: t, locales: c } = F(), i =
|
|
83
|
+
const { navigation: e, branding: t, locales: c } = F(), i = w(!1), s = w(!1);
|
|
84
84
|
function l() {
|
|
85
85
|
i.value = window.scrollY > 20;
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
C(() => window.addEventListener("scroll", l)), A(() => window.removeEventListener("scroll", l));
|
|
88
88
|
const p = { navigation: e, branding: t, locales: c, scrolled: i, menuOpen: s, onScroll: l, XLocaleSwitcher: Z };
|
|
89
89
|
return Object.defineProperty(p, "__isScriptSetup", { enumerable: !1, value: !0 }), p;
|
|
90
90
|
}
|
|
@@ -93,7 +93,7 @@ const Z = /* @__PURE__ */ x(V, [["render", Y], ["__scopeId", "data-v-675f0bbd"],
|
|
|
93
93
|
class: "x-nav__logo-text"
|
|
94
94
|
}, oe = ["href"];
|
|
95
95
|
function ne(r, o, e, t, c, i) {
|
|
96
|
-
const s =
|
|
96
|
+
const s = E("router-link");
|
|
97
97
|
return n(), a(
|
|
98
98
|
"nav",
|
|
99
99
|
{
|
|
@@ -101,11 +101,11 @@ function ne(r, o, e, t, c, i) {
|
|
|
101
101
|
},
|
|
102
102
|
[
|
|
103
103
|
u("div", ee, [
|
|
104
|
-
|
|
104
|
+
P(s, {
|
|
105
105
|
to: "/",
|
|
106
106
|
class: "x-nav__logo"
|
|
107
107
|
}, {
|
|
108
|
-
default:
|
|
108
|
+
default: B(() => [
|
|
109
109
|
t.branding.logo ? (n(), a("img", {
|
|
110
110
|
key: 0,
|
|
111
111
|
src: t.branding.logo,
|
|
@@ -149,8 +149,8 @@ function ne(r, o, e, t, c, i) {
|
|
|
149
149
|
class: "x-nav__link",
|
|
150
150
|
onClick: o[1] || (o[1] = (p) => t.menuOpen = !1)
|
|
151
151
|
}, {
|
|
152
|
-
default:
|
|
153
|
-
|
|
152
|
+
default: B(() => [
|
|
153
|
+
L(
|
|
154
154
|
_(l.text),
|
|
155
155
|
1
|
|
156
156
|
/* TEXT */
|
|
@@ -221,7 +221,7 @@ const ae = /* @__PURE__ */ x(Q, [["render", ne], ["__scopeId", "data-v-07c4b748"
|
|
|
221
221
|
class: "x-footer__copyright"
|
|
222
222
|
};
|
|
223
223
|
function de(r, o, e, t, c, i) {
|
|
224
|
-
const s =
|
|
224
|
+
const s = E("router-link");
|
|
225
225
|
return n(), a("footer", ce, [
|
|
226
226
|
u("div", ie, [
|
|
227
227
|
t.footerConfig.links?.length ? (n(), a("div", le, [
|
|
@@ -233,8 +233,8 @@ function de(r, o, e, t, c, i) {
|
|
|
233
233
|
to: l.url,
|
|
234
234
|
class: "x-footer__link"
|
|
235
235
|
}, {
|
|
236
|
-
default:
|
|
237
|
-
|
|
236
|
+
default: B(() => [
|
|
237
|
+
L(
|
|
238
238
|
_(l.text),
|
|
239
239
|
1
|
|
240
240
|
/* TEXT */
|
|
@@ -267,11 +267,11 @@ const ue = /* @__PURE__ */ x(re, [["render", de], ["__scopeId", "data-v-f9b38381
|
|
|
267
267
|
}), fe = { class: "x-site-layout" }, me = { class: "x-site-layout__main" };
|
|
268
268
|
function he(r, o, e, t, c, i) {
|
|
269
269
|
return n(), a("div", fe, [
|
|
270
|
-
|
|
270
|
+
P(t.XSiteNav),
|
|
271
271
|
u("main", me, [
|
|
272
272
|
H(r.$slots, "default", {}, void 0, !0)
|
|
273
273
|
]),
|
|
274
|
-
|
|
274
|
+
P(t.XSiteFooter)
|
|
275
275
|
]);
|
|
276
276
|
}
|
|
277
277
|
const ts = /* @__PURE__ */ x(pe, [["render", he], ["__scopeId", "data-v-41b0f2a9"], ["__file", "/Users/yariksav/projects/xosen/xosen-monorepo/packages/site-sdk/src/components/layout/XSiteLayout.vue"]]), ve = /* @__PURE__ */ y({
|
|
@@ -382,7 +382,7 @@ const Ce = /* @__PURE__ */ x(ve, [["render", Te], ["__scopeId", "data-v-d8cfe56f
|
|
|
382
382
|
return Object.defineProperty(e, "__isScriptSetup", { enumerable: !1, value: !0 }), e;
|
|
383
383
|
}
|
|
384
384
|
}), Be = { class: "x-html-block" }, Oe = ["innerHTML"];
|
|
385
|
-
function
|
|
385
|
+
function Pe(r, o, e, t, c, i) {
|
|
386
386
|
return n(), a("section", Be, [
|
|
387
387
|
u("div", {
|
|
388
388
|
class: "x-html-block__content",
|
|
@@ -390,7 +390,7 @@ function Ie(r, o, e, t, c, i) {
|
|
|
390
390
|
}, null, 8, Oe)
|
|
391
391
|
]);
|
|
392
392
|
}
|
|
393
|
-
const
|
|
393
|
+
const Ie = /* @__PURE__ */ x(Xe, [["render", Pe], ["__scopeId", "data-v-abfd69e8"], ["__file", "/Users/yariksav/projects/xosen/xosen-monorepo/packages/site-sdk/src/components/blocks/XHtmlBlock.vue"]]), Le = /* @__PURE__ */ y({
|
|
394
394
|
__name: "XCardsBlock",
|
|
395
395
|
props: {
|
|
396
396
|
data: { type: Object, required: !0 },
|
|
@@ -423,21 +423,21 @@ const Pe = /* @__PURE__ */ x(Xe, [["render", Ie], ["__scopeId", "data-v-abfd69e8
|
|
|
423
423
|
const l = { props: e, gridStyle: t, iconStyle: c, iconMap: i, iconDisplay: s };
|
|
424
424
|
return Object.defineProperty(l, "__isScriptSetup", { enumerable: !1, value: !0 }), l;
|
|
425
425
|
}
|
|
426
|
-
}),
|
|
426
|
+
}), Ne = { class: "x-cards-block__container" }, Ae = {
|
|
427
427
|
key: 0,
|
|
428
428
|
class: "x-cards-block__title"
|
|
429
|
-
},
|
|
429
|
+
}, Ee = {
|
|
430
430
|
key: 1,
|
|
431
431
|
class: "x-cards-block__subtitle"
|
|
432
|
-
},
|
|
433
|
-
function
|
|
432
|
+
}, Ue = ["src", "alt"], Re = { class: "x-card__title" }, Me = { class: "x-card__desc" };
|
|
433
|
+
function Fe(r, o, e, t, c, i) {
|
|
434
434
|
return n(), a(
|
|
435
435
|
"section",
|
|
436
436
|
{
|
|
437
437
|
class: k(["x-cards-block", `x-cards-block--${e.variant}`])
|
|
438
438
|
},
|
|
439
439
|
[
|
|
440
|
-
u("div",
|
|
440
|
+
u("div", Ne, [
|
|
441
441
|
e.data.title ? (n(), a(
|
|
442
442
|
"h2",
|
|
443
443
|
Ae,
|
|
@@ -447,7 +447,7 @@ function qe(r, o, e, t, c, i) {
|
|
|
447
447
|
)) : d("v-if", !0),
|
|
448
448
|
e.data.subtitle ? (n(), a(
|
|
449
449
|
"p",
|
|
450
|
-
|
|
450
|
+
Ee,
|
|
451
451
|
_(e.data.subtitle),
|
|
452
452
|
1
|
|
453
453
|
/* TEXT */
|
|
@@ -462,18 +462,18 @@ function qe(r, o, e, t, c, i) {
|
|
|
462
462
|
(n(!0), a(
|
|
463
463
|
h,
|
|
464
464
|
null,
|
|
465
|
-
v(e.data.cards, (s, l) => (n(), T(
|
|
465
|
+
v(e.data.cards, (s, l) => (n(), T(R(s.link ? "a" : "div"), {
|
|
466
466
|
key: l,
|
|
467
467
|
class: "x-card",
|
|
468
468
|
href: s.link
|
|
469
469
|
}, {
|
|
470
|
-
default:
|
|
470
|
+
default: B(() => [
|
|
471
471
|
s.image && e.variant === "image-cards" ? (n(), a("img", {
|
|
472
472
|
key: 0,
|
|
473
473
|
src: s.image,
|
|
474
474
|
alt: s.title,
|
|
475
475
|
class: "x-card__image"
|
|
476
|
-
}, null, 8,
|
|
476
|
+
}, null, 8, Ue)) : d("v-if", !0),
|
|
477
477
|
s.icon && e.variant !== "image-cards" ? (n(), a(
|
|
478
478
|
"div",
|
|
479
479
|
{
|
|
@@ -494,7 +494,7 @@ function qe(r, o, e, t, c, i) {
|
|
|
494
494
|
),
|
|
495
495
|
u(
|
|
496
496
|
"p",
|
|
497
|
-
|
|
497
|
+
Me,
|
|
498
498
|
_(s.desc),
|
|
499
499
|
1
|
|
500
500
|
/* TEXT */
|
|
@@ -516,7 +516,7 @@ function qe(r, o, e, t, c, i) {
|
|
|
516
516
|
/* CLASS */
|
|
517
517
|
);
|
|
518
518
|
}
|
|
519
|
-
const
|
|
519
|
+
const qe = /* @__PURE__ */ x(Le, [["render", Fe], ["__scopeId", "data-v-a1505674"], ["__file", "/Users/yariksav/projects/xosen/xosen-monorepo/packages/site-sdk/src/components/blocks/XCardsBlock.vue"]]), De = /* @__PURE__ */ y({
|
|
520
520
|
__name: "XImageTextBlock",
|
|
521
521
|
props: {
|
|
522
522
|
data: { type: Object, required: !0 },
|
|
@@ -570,7 +570,7 @@ function Ze(r, o, e, t, c, i) {
|
|
|
570
570
|
1
|
|
571
571
|
/* TEXT */
|
|
572
572
|
),
|
|
573
|
-
|
|
573
|
+
L(
|
|
574
574
|
" " + _(s.text),
|
|
575
575
|
1
|
|
576
576
|
/* TEXT */
|
|
@@ -594,9 +594,9 @@ function Ze(r, o, e, t, c, i) {
|
|
|
594
594
|
/* CLASS */
|
|
595
595
|
);
|
|
596
596
|
}
|
|
597
|
-
const Qe = /* @__PURE__ */ x(
|
|
597
|
+
const Qe = /* @__PURE__ */ x(De, [["render", Ze], ["__scopeId", "data-v-5ca1e218"], ["__file", "/Users/yariksav/projects/xosen/xosen-monorepo/packages/site-sdk/src/components/blocks/XImageTextBlock.vue"]]);
|
|
598
598
|
function q(r, o) {
|
|
599
|
-
const e =
|
|
599
|
+
const e = w(null), { locale: t } = M(), c = window.__SITE_DATA__, i = c?.locale;
|
|
600
600
|
function s() {
|
|
601
601
|
return c && c[r] && t.value === i ? (e.value = c[r], !0) : !1;
|
|
602
602
|
}
|
|
@@ -607,9 +607,9 @@ function q(r, o) {
|
|
|
607
607
|
} catch {
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
|
-
return
|
|
610
|
+
return C(() => {
|
|
611
611
|
s() || l();
|
|
612
|
-
}),
|
|
612
|
+
}), I(t, () => {
|
|
613
613
|
l();
|
|
614
614
|
}), e;
|
|
615
615
|
}
|
|
@@ -642,14 +642,14 @@ const tt = /* @__PURE__ */ y({
|
|
|
642
642
|
},
|
|
643
643
|
setup(r, { expose: o }) {
|
|
644
644
|
o();
|
|
645
|
-
const e = r, t = f(() => e.data?.title), c = f(() => e.data?.subtitle), i =
|
|
646
|
-
|
|
645
|
+
const e = r, t = f(() => e.data?.title), c = f(() => e.data?.subtitle), i = w([]), s = w(""), l = q("tariffs", "tariffs"), p = et();
|
|
646
|
+
C(async () => {
|
|
647
647
|
if (e.source === "api")
|
|
648
648
|
try {
|
|
649
649
|
i.value = await p.getTariffs();
|
|
650
650
|
} catch {
|
|
651
651
|
}
|
|
652
|
-
}),
|
|
652
|
+
}), I(
|
|
653
653
|
l,
|
|
654
654
|
(m) => {
|
|
655
655
|
m && e.source === "kv" && (i.value = m);
|
|
@@ -657,18 +657,18 @@ const tt = /* @__PURE__ */ y({
|
|
|
657
657
|
{ immediate: !0 }
|
|
658
658
|
);
|
|
659
659
|
const g = f(() => {
|
|
660
|
-
const m = new Set(i.value.map((
|
|
660
|
+
const m = new Set(i.value.map((j) => j.tariffGroupName).filter(Boolean));
|
|
661
661
|
return Array.from(m);
|
|
662
662
|
});
|
|
663
|
-
|
|
663
|
+
I(
|
|
664
664
|
g,
|
|
665
665
|
(m) => {
|
|
666
666
|
m.length > 0 && !s.value && (s.value = m[0]);
|
|
667
667
|
},
|
|
668
668
|
{ immediate: !0 }
|
|
669
669
|
);
|
|
670
|
-
const b = f(() => !s.value || g.value.length <= 1 ? i.value : i.value.filter((m) => m.tariffGroupName === s.value)),
|
|
671
|
-
return Object.defineProperty(
|
|
670
|
+
const b = f(() => !s.value || g.value.length <= 1 ? i.value : i.value.filter((m) => m.tariffGroupName === s.value)), X = { props: e, title: t, subtitle: c, plans: i, activeGroup: s, kvTariffs: l, api: p, groups: g, activePlans: b };
|
|
671
|
+
return Object.defineProperty(X, "__isScriptSetup", { enumerable: !1, value: !0 }), X;
|
|
672
672
|
}
|
|
673
673
|
}), st = { class: "x-pricing" }, ot = { class: "x-pricing__container" }, nt = {
|
|
674
674
|
key: 0,
|
|
@@ -884,7 +884,7 @@ function Bt(r, o, e, t, c, i) {
|
|
|
884
884
|
])
|
|
885
885
|
]);
|
|
886
886
|
}
|
|
887
|
-
const Ot = /* @__PURE__ */ x(yt, [["render", Bt], ["__scopeId", "data-v-e873ba26"], ["__file", "/Users/yariksav/projects/xosen/xosen-monorepo/packages/site-sdk/src/components/blocks/XContactsBlock.vue"]]),
|
|
887
|
+
const Ot = /* @__PURE__ */ x(yt, [["render", Bt], ["__scopeId", "data-v-e873ba26"], ["__file", "/Users/yariksav/projects/xosen/xosen-monorepo/packages/site-sdk/src/components/blocks/XContactsBlock.vue"]]), Pt = /* @__PURE__ */ y({
|
|
888
888
|
__name: "XGalleryBlock",
|
|
889
889
|
props: {
|
|
890
890
|
data: { type: Object, required: !0 }
|
|
@@ -894,20 +894,20 @@ const Ot = /* @__PURE__ */ x(yt, [["render", Bt], ["__scopeId", "data-v-e873ba26
|
|
|
894
894
|
const e = {};
|
|
895
895
|
return Object.defineProperty(e, "__isScriptSetup", { enumerable: !1, value: !0 }), e;
|
|
896
896
|
}
|
|
897
|
-
}),
|
|
897
|
+
}), It = { class: "x-gallery-block" }, Lt = {
|
|
898
898
|
key: 0,
|
|
899
899
|
class: "x-gallery-block__title"
|
|
900
|
-
},
|
|
901
|
-
function
|
|
902
|
-
return n(), a("section",
|
|
900
|
+
}, Nt = { class: "x-gallery-block__grid" }, At = ["src", "alt"], Et = { key: 0 };
|
|
901
|
+
function Ut(r, o, e, t, c, i) {
|
|
902
|
+
return n(), a("section", It, [
|
|
903
903
|
e.data.title ? (n(), a(
|
|
904
904
|
"h2",
|
|
905
|
-
|
|
905
|
+
Lt,
|
|
906
906
|
_(e.data.title),
|
|
907
907
|
1
|
|
908
908
|
/* TEXT */
|
|
909
909
|
)) : d("v-if", !0),
|
|
910
|
-
u("div",
|
|
910
|
+
u("div", Nt, [
|
|
911
911
|
(n(!0), a(
|
|
912
912
|
h,
|
|
913
913
|
null,
|
|
@@ -922,7 +922,7 @@ function Et(r, o, e, t, c, i) {
|
|
|
922
922
|
}, null, 8, At),
|
|
923
923
|
s.caption ? (n(), a(
|
|
924
924
|
"figcaption",
|
|
925
|
-
|
|
925
|
+
Et,
|
|
926
926
|
_(s.caption),
|
|
927
927
|
1
|
|
928
928
|
/* TEXT */
|
|
@@ -934,7 +934,7 @@ function Et(r, o, e, t, c, i) {
|
|
|
934
934
|
])
|
|
935
935
|
]);
|
|
936
936
|
}
|
|
937
|
-
const Rt = /* @__PURE__ */ x(
|
|
937
|
+
const Rt = /* @__PURE__ */ x(Pt, [["render", Ut], ["__scopeId", "data-v-b99bb987"], ["__file", "/Users/yariksav/projects/xosen/xosen-monorepo/packages/site-sdk/src/components/blocks/XGalleryBlock.vue"]]), Mt = /* @__PURE__ */ y({
|
|
938
938
|
__name: "XMapBlock",
|
|
939
939
|
props: {
|
|
940
940
|
data: { type: Object, required: !0 }
|
|
@@ -947,20 +947,20 @@ const Rt = /* @__PURE__ */ x(It, [["render", Et], ["__scopeId", "data-v-b99bb987
|
|
|
947
947
|
}), c = { props: e, mapUrl: t };
|
|
948
948
|
return Object.defineProperty(c, "__isScriptSetup", { enumerable: !1, value: !0 }), c;
|
|
949
949
|
}
|
|
950
|
-
}),
|
|
950
|
+
}), Ft = { class: "x-map-block" }, qt = {
|
|
951
951
|
key: 0,
|
|
952
952
|
class: "x-map-block__title"
|
|
953
|
-
},
|
|
953
|
+
}, Dt = { class: "x-map-block__container" }, Ht = ["src"];
|
|
954
954
|
function zt(r, o, e, t, c, i) {
|
|
955
|
-
return n(), a("section",
|
|
955
|
+
return n(), a("section", Ft, [
|
|
956
956
|
e.data.title ? (n(), a(
|
|
957
957
|
"h2",
|
|
958
|
-
|
|
958
|
+
qt,
|
|
959
959
|
_(e.data.title),
|
|
960
960
|
1
|
|
961
961
|
/* TEXT */
|
|
962
962
|
)) : d("v-if", !0),
|
|
963
|
-
u("div",
|
|
963
|
+
u("div", Dt, [
|
|
964
964
|
u("iframe", {
|
|
965
965
|
src: t.mapUrl,
|
|
966
966
|
width: "100%",
|
|
@@ -973,7 +973,7 @@ function zt(r, o, e, t, c, i) {
|
|
|
973
973
|
])
|
|
974
974
|
]);
|
|
975
975
|
}
|
|
976
|
-
const Gt = /* @__PURE__ */ x(
|
|
976
|
+
const Gt = /* @__PURE__ */ x(Mt, [["render", zt], ["__scopeId", "data-v-583f4762"], ["__file", "/Users/yariksav/projects/xosen/xosen-monorepo/packages/site-sdk/src/components/blocks/XMapBlock.vue"]]), Jt = /* @__PURE__ */ y({
|
|
977
977
|
__name: "XBlockRenderer",
|
|
978
978
|
props: {
|
|
979
979
|
blocks: { type: Array, required: !0 }
|
|
@@ -982,8 +982,8 @@ const Gt = /* @__PURE__ */ x(Ft, [["render", zt], ["__scopeId", "data-v-583f4762
|
|
|
982
982
|
o();
|
|
983
983
|
const e = r, t = {
|
|
984
984
|
hero: Ce,
|
|
985
|
-
html:
|
|
986
|
-
cards:
|
|
985
|
+
html: Ie,
|
|
986
|
+
cards: qe,
|
|
987
987
|
"image-text": Qe,
|
|
988
988
|
pricing: vt,
|
|
989
989
|
contacts: Ot,
|
|
@@ -1006,7 +1006,7 @@ function Wt(r, o, e, t, c, i) {
|
|
|
1006
1006
|
h,
|
|
1007
1007
|
{ key: l },
|
|
1008
1008
|
[
|
|
1009
|
-
t.getBlockComponent(s.type) ? (n(), T(
|
|
1009
|
+
t.getBlockComponent(s.type) ? (n(), T(R(t.getBlockComponent(s.type)), z({
|
|
1010
1010
|
key: 0,
|
|
1011
1011
|
data: s.data || s.props
|
|
1012
1012
|
}, { ref_for: !0 }, s.settings, {
|
|
@@ -1021,7 +1021,23 @@ function Wt(r, o, e, t, c, i) {
|
|
|
1021
1021
|
))
|
|
1022
1022
|
]);
|
|
1023
1023
|
}
|
|
1024
|
-
const ss = /* @__PURE__ */ x(Jt, [["render", Wt], ["__file", "/Users/yariksav/projects/xosen/xosen-monorepo/packages/site-sdk/src/components/blocks/XBlockRenderer.vue"]])
|
|
1024
|
+
const ss = /* @__PURE__ */ x(Jt, [["render", Wt], ["__file", "/Users/yariksav/projects/xosen/xosen-monorepo/packages/site-sdk/src/components/blocks/XBlockRenderer.vue"]]);
|
|
1025
|
+
function os() {
|
|
1026
|
+
const r = w(null), o = w(!1);
|
|
1027
|
+
function e(t) {
|
|
1028
|
+
const c = t.data;
|
|
1029
|
+
c?.type === "xosen-preview-update" && c.page && (r.value = c.page, o.value = !0);
|
|
1030
|
+
}
|
|
1031
|
+
return C(() => {
|
|
1032
|
+
window.addEventListener("message", e), window.parent !== window && window.parent.postMessage({ type: "xosen-preview-ready" }, "*");
|
|
1033
|
+
}), A(() => {
|
|
1034
|
+
window.removeEventListener("message", e);
|
|
1035
|
+
}), {
|
|
1036
|
+
previewPage: r,
|
|
1037
|
+
isPreviewMode: o
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
const Kt = /\.(js|css|png|jpg|jpeg|gif|svg|ico|woff2?|ttf|eot|webp|avif|map|json|txt|xml|webmanifest)$/;
|
|
1025
1041
|
function Yt(r, o) {
|
|
1026
1042
|
const t = new URL(r.url).searchParams.get("lang");
|
|
1027
1043
|
if (t && o.supportedLocales?.includes(t)) return t;
|
|
@@ -1046,7 +1062,7 @@ function Zt(r, o) {
|
|
|
1046
1062
|
}) : Response.json({ error: "Not found" }, { status: 404 });
|
|
1047
1063
|
})() : Promise.resolve(Response.json({ error: "Key is required" }, { status: 400 }));
|
|
1048
1064
|
}
|
|
1049
|
-
function
|
|
1065
|
+
function N(r, o, e) {
|
|
1050
1066
|
let t = r;
|
|
1051
1067
|
if (o.title) {
|
|
1052
1068
|
const c = e ? ` — ${e}` : "";
|
|
@@ -1054,7 +1070,7 @@ function L(r, o, e) {
|
|
|
1054
1070
|
}
|
|
1055
1071
|
return o.meta?.description && (t = t.replace(/(<meta\s+name="description"\s+content=")[^"]*(")/, `$1${o.meta.description}$2`)), o.meta?.ogTitle && (t = t.replace(/(<meta\s+property="og:title"\s+content=")[^"]*(")/, `$1${o.meta.ogTitle}$2`)), o.html && (t = t.replace('<div id="app"></div>', `<div id="app">${o.html}</div>`)), t;
|
|
1056
1072
|
}
|
|
1057
|
-
function
|
|
1073
|
+
function ns(r) {
|
|
1058
1074
|
return {
|
|
1059
1075
|
async fetch(o, e) {
|
|
1060
1076
|
const t = new URL(o.url), c = Zt(t, e);
|
|
@@ -1066,9 +1082,9 @@ function os(r) {
|
|
|
1066
1082
|
const [g, b] = await Promise.all([
|
|
1067
1083
|
e.SITE_CONTENT.get("config"),
|
|
1068
1084
|
e.SITE_CONTENT.get(`content:${i}`)
|
|
1069
|
-
]),
|
|
1070
|
-
if (
|
|
1071
|
-
const $ =
|
|
1085
|
+
]), X = g ? JSON.parse(g) : {}, m = b ? JSON.parse(b) : {}, j = t.pathname.match(/^\/p\/(.+)$/);
|
|
1086
|
+
if (j) {
|
|
1087
|
+
const $ = j[1];
|
|
1072
1088
|
if (!m[$]) {
|
|
1073
1089
|
const S = await e.SITE_CONTENT.get(`page:${$}:${i}`);
|
|
1074
1090
|
S && (m[$] = JSON.parse(S));
|
|
@@ -1076,15 +1092,15 @@ function os(r) {
|
|
|
1076
1092
|
}
|
|
1077
1093
|
const O = {
|
|
1078
1094
|
locale: i,
|
|
1079
|
-
config:
|
|
1095
|
+
config: X
|
|
1080
1096
|
};
|
|
1081
1097
|
for (const [$, S] of Object.entries(m))
|
|
1082
1098
|
O[`page:${$}`] = S;
|
|
1083
|
-
if (
|
|
1084
|
-
const $ =
|
|
1085
|
-
S && (p =
|
|
1099
|
+
if (j) {
|
|
1100
|
+
const $ = j[1], S = O[`page:${$}`];
|
|
1101
|
+
S && (p = N(p, S, r.siteName));
|
|
1086
1102
|
}
|
|
1087
|
-
t.pathname === "/" && m.home && (p =
|
|
1103
|
+
t.pathname === "/" && m.home && (p = N(p, m.home, r.siteName));
|
|
1088
1104
|
const D = `<script>window.__SITE_DATA__ = ${JSON.stringify(O)};<\/script>`;
|
|
1089
1105
|
return p = p.replace("</head>", `${D}
|
|
1090
1106
|
</head>`), new Response(p, {
|
|
@@ -1098,11 +1114,11 @@ function os(r) {
|
|
|
1098
1114
|
}
|
|
1099
1115
|
export {
|
|
1100
1116
|
ss as XBlockRenderer,
|
|
1101
|
-
|
|
1117
|
+
qe as XCardsBlock,
|
|
1102
1118
|
Ot as XContactsBlock,
|
|
1103
1119
|
Rt as XGalleryBlock,
|
|
1104
1120
|
Ce as XHeroBlock,
|
|
1105
|
-
|
|
1121
|
+
Ie as XHtmlBlock,
|
|
1106
1122
|
Qe as XImageTextBlock,
|
|
1107
1123
|
Z as XLocaleSwitcher,
|
|
1108
1124
|
Gt as XMapBlock,
|
|
@@ -1110,7 +1126,8 @@ export {
|
|
|
1110
1126
|
ue as XSiteFooter,
|
|
1111
1127
|
ts as XSiteLayout,
|
|
1112
1128
|
ae as XSiteNav,
|
|
1113
|
-
|
|
1129
|
+
ns as createSiteWorker,
|
|
1130
|
+
os as useLivePreview,
|
|
1114
1131
|
et as useSiteApi,
|
|
1115
1132
|
F as useSiteConfig,
|
|
1116
1133
|
q as useSiteData,
|
package/package.json
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ref, onMounted, onUnmounted } from 'vue';
|
|
2
|
+
|
|
3
|
+
export interface PreviewMessage {
|
|
4
|
+
type: 'xosen-preview-update';
|
|
5
|
+
page: {
|
|
6
|
+
slug: string;
|
|
7
|
+
locale: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
blocks?: any[];
|
|
10
|
+
meta?: Record<string, any>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Listen for live preview messages from the admin UI.
|
|
16
|
+
* When the admin sends page data via postMessage, this composable
|
|
17
|
+
* provides reactive access to the preview data.
|
|
18
|
+
*
|
|
19
|
+
* Usage in template ContentPage:
|
|
20
|
+
* ```ts
|
|
21
|
+
* const { previewPage } = useLivePreview();
|
|
22
|
+
* // If previewPage matches current slug+locale, use it instead of KV/API data
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function useLivePreview() {
|
|
26
|
+
const previewPage = ref<PreviewMessage['page'] | null>(null);
|
|
27
|
+
const isPreviewMode = ref(false);
|
|
28
|
+
|
|
29
|
+
function handleMessage(event: MessageEvent) {
|
|
30
|
+
const data = event.data;
|
|
31
|
+
if (data?.type === 'xosen-preview-update' && data.page) {
|
|
32
|
+
previewPage.value = data.page;
|
|
33
|
+
isPreviewMode.value = true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
onMounted(() => {
|
|
38
|
+
window.addEventListener('message', handleMessage);
|
|
39
|
+
// Notify parent that preview is ready
|
|
40
|
+
if (window.parent !== window) {
|
|
41
|
+
window.parent.postMessage({ type: 'xosen-preview-ready' }, '*');
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
onUnmounted(() => {
|
|
46
|
+
window.removeEventListener('message', handleMessage);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
previewPage,
|
|
51
|
+
isPreviewMode,
|
|
52
|
+
};
|
|
53
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -22,6 +22,8 @@ export { useSiteData } from './composables/useSiteData.js';
|
|
|
22
22
|
export { useSiteConfig } from './composables/useSiteConfig.js';
|
|
23
23
|
export { useSkin } from './composables/useSkin.js';
|
|
24
24
|
export { useSiteApi } from './composables/useSiteApi.js';
|
|
25
|
+
export { useLivePreview } from './composables/useLivePreview.js';
|
|
26
|
+
export type { PreviewMessage } from './composables/useLivePreview.js';
|
|
25
27
|
|
|
26
28
|
// Worker
|
|
27
29
|
export { createSiteWorker } from './worker/index.js';
|