@colegium_dev/vue3-unlayer-embed 1.0.8 → 1.0.9
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.
|
@@ -1,105 +1,108 @@
|
|
|
1
|
-
import { watch as
|
|
2
|
-
function
|
|
3
|
-
return
|
|
1
|
+
import { watch as C, getCurrentScope as S, onScopeDispose as x, computed as M, toValue as g, unref as b, defineComponent as W, ref as m, onMounted as _, createElementBlock as k, openBlock as D, createTextVNode as I, createElementVNode as j, toRaw as A } from "vue";
|
|
2
|
+
function L(e) {
|
|
3
|
+
return S() ? (x(e), !0) : !1;
|
|
4
4
|
}
|
|
5
|
-
const
|
|
5
|
+
const O = typeof window < "u" && typeof document < "u";
|
|
6
6
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
7
|
-
const
|
|
8
|
-
function
|
|
7
|
+
const B = Object.prototype.toString, G = (e) => B.call(e) === "[object Object]";
|
|
8
|
+
function E(e) {
|
|
9
9
|
return Array.isArray(e) ? e : [e];
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return
|
|
11
|
+
function N(e, a, r) {
|
|
12
|
+
return C(
|
|
13
13
|
e,
|
|
14
|
-
|
|
14
|
+
a,
|
|
15
15
|
{
|
|
16
|
-
...
|
|
16
|
+
...r,
|
|
17
17
|
immediate: !0
|
|
18
18
|
}
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
|
-
const P =
|
|
22
|
-
function
|
|
23
|
-
var
|
|
24
|
-
const
|
|
25
|
-
return (
|
|
21
|
+
const P = O ? window : void 0;
|
|
22
|
+
function V(e) {
|
|
23
|
+
var a;
|
|
24
|
+
const r = g(e);
|
|
25
|
+
return (a = r == null ? void 0 : r.$el) != null ? a : r;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
}, c = (n, t, o, u) => (n.addEventListener(t, o, u), () => n.removeEventListener(t, o, u)), i =
|
|
31
|
-
const n =
|
|
27
|
+
function $(...e) {
|
|
28
|
+
const a = [], r = () => {
|
|
29
|
+
a.forEach((n) => n()), a.length = 0;
|
|
30
|
+
}, c = (n, t, o, u) => (n.addEventListener(t, o, u), () => n.removeEventListener(t, o, u)), i = M(() => {
|
|
31
|
+
const n = E(g(e[0])).filter((t) => t != null);
|
|
32
32
|
return n.every((t) => typeof t != "string") ? n : void 0;
|
|
33
|
-
}), f =
|
|
33
|
+
}), f = N(
|
|
34
34
|
() => {
|
|
35
35
|
var n, t;
|
|
36
36
|
return [
|
|
37
|
-
(t = (n = i.value) == null ? void 0 : n.map((o) =>
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
(t = (n = i.value) == null ? void 0 : n.map((o) => V(o))) != null ? t : [P].filter((o) => o != null),
|
|
38
|
+
E(g(i.value ? e[1] : e[0])),
|
|
39
|
+
E(b(i.value ? e[2] : e[1])),
|
|
40
40
|
// @ts-expect-error - TypeScript gets the correct types, but somehow still complains
|
|
41
|
-
|
|
41
|
+
g(i.value ? e[3] : e[2])
|
|
42
42
|
];
|
|
43
43
|
},
|
|
44
44
|
([n, t, o, u]) => {
|
|
45
|
-
if (
|
|
45
|
+
if (r(), !(n != null && n.length) || !(t != null && t.length) || !(o != null && o.length))
|
|
46
46
|
return;
|
|
47
|
-
const
|
|
48
|
-
|
|
47
|
+
const y = G(u) ? { ...u } : u;
|
|
48
|
+
a.push(
|
|
49
49
|
...n.flatMap(
|
|
50
|
-
(
|
|
51
|
-
(v) => o.map((
|
|
50
|
+
(h) => t.flatMap(
|
|
51
|
+
(v) => o.map((w) => c(h, v, w, y))
|
|
52
52
|
)
|
|
53
53
|
)
|
|
54
54
|
);
|
|
55
55
|
},
|
|
56
56
|
{ flush: "post" }
|
|
57
57
|
), p = () => {
|
|
58
|
-
f(),
|
|
58
|
+
f(), r();
|
|
59
59
|
};
|
|
60
|
-
return
|
|
60
|
+
return L(r), p;
|
|
61
61
|
}
|
|
62
|
-
const R = { class: "flex flex-col w-full h-full" }, U = ["src"],
|
|
62
|
+
const R = { class: "flex flex-col w-full h-full" }, U = ["src"], H = /* @__PURE__ */ W({
|
|
63
63
|
__name: "App",
|
|
64
64
|
emits: ["load", "ready", "onSuccess", "onError"],
|
|
65
|
-
setup(e, { expose:
|
|
66
|
-
const c =
|
|
67
|
-
|
|
65
|
+
setup(e, { expose: a, emit: r }) {
|
|
66
|
+
const c = r, i = m("https://cdn2.colegium.com/production/unlayer/index.html"), f = m(), p = m(), n = m(null);
|
|
67
|
+
$(window, "message", u);
|
|
68
68
|
function t() {
|
|
69
69
|
const l = new MessageChannel();
|
|
70
70
|
f.value = l;
|
|
71
71
|
}
|
|
72
72
|
function o() {
|
|
73
73
|
const { port1: l } = f.value;
|
|
74
|
-
p.value = l, p.value.onmessage =
|
|
74
|
+
p.value = l, p.value.onmessage = h;
|
|
75
75
|
}
|
|
76
76
|
function u({ data: l }) {
|
|
77
77
|
"ready" in l && c("ready");
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function y() {
|
|
80
80
|
c("load"), o();
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
const { data:
|
|
84
|
-
if (
|
|
85
|
-
const { template: d, originalTemplate:
|
|
86
|
-
c("onSuccess", { template: d, originalTemplate:
|
|
82
|
+
function h(l) {
|
|
83
|
+
const { data: s } = l;
|
|
84
|
+
if (s.status == "success") {
|
|
85
|
+
const { template: d, originalTemplate: T } = s;
|
|
86
|
+
c("onSuccess", { template: d, originalTemplate: T });
|
|
87
87
|
} else {
|
|
88
|
-
const { message: d } =
|
|
88
|
+
const { message: d } = s;
|
|
89
89
|
c("onError", { message: d });
|
|
90
90
|
}
|
|
91
91
|
t(), o();
|
|
92
92
|
}
|
|
93
93
|
const v = () => {
|
|
94
|
-
var l,
|
|
95
|
-
(
|
|
96
|
-
},
|
|
97
|
-
var
|
|
98
|
-
(d = (
|
|
94
|
+
var l, s;
|
|
95
|
+
(s = (l = n.value) == null ? void 0 : l.contentWindow) == null || s.postMessage({ type: "GET" }, "*", [f.value.port2]);
|
|
96
|
+
}, w = (l) => {
|
|
97
|
+
var s, d;
|
|
98
|
+
(d = (s = n.value) == null ? void 0 : s.contentWindow) == null || d.postMessage({ template: A(l), type: "PUT" }, "*", [
|
|
99
99
|
f.value.port2
|
|
100
100
|
]), t(), o();
|
|
101
101
|
};
|
|
102
|
-
return
|
|
102
|
+
return _(async () => {
|
|
103
|
+
console.log("unlayerIframe.value", n.value), t();
|
|
104
|
+
}), a({ getTemplateDesign: v, setTemplateDesign: w }), (l, s) => (D(), k("div", R, [
|
|
105
|
+
s[0] || (s[0] = I(" Hola gominolax ", -1)),
|
|
103
106
|
j("iframe", {
|
|
104
107
|
class: "w-full h-full overflow-hidden",
|
|
105
108
|
style: { width: "100%", height: "100%" },
|
|
@@ -109,12 +112,12 @@ const R = { class: "flex flex-col w-full h-full" }, U = ["src"], z = /* @__PURE_
|
|
|
109
112
|
loading: "lazy",
|
|
110
113
|
"no-referrer": "",
|
|
111
114
|
title: "Colegium Unlayer Embed",
|
|
112
|
-
src: `${
|
|
113
|
-
onLoad:
|
|
115
|
+
src: `${b(i)}?v=${(/* @__PURE__ */ new Date()).getTime()}`,
|
|
116
|
+
onLoad: y
|
|
114
117
|
}, null, 40, U)
|
|
115
118
|
]));
|
|
116
119
|
}
|
|
117
120
|
});
|
|
118
121
|
export {
|
|
119
|
-
|
|
122
|
+
H as ClgTemplateBuilder
|
|
120
123
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(c,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(c=typeof globalThis<"u"?globalThis:c||self,e(c["@colegium/vue3-unlayer-embed"]={},c.Vue))})(this,(function(c,e){"use strict";function E(n){return e.getCurrentScope()?(e.onScopeDispose(n),!0):!1}const S=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const x=Object.prototype.toString,C=n=>x.call(n)==="[object Object]";function g(n){return Array.isArray(n)?n:[n]}function M(n,i,a){return e.watch(n,i,{...a,immediate:!0})}const V=S?window:void 0;function j(n){var i;const a=e.toValue(n);return(i=a==null?void 0:a.$el)!=null?i:a}function W(...n){const i=[],a=()=>{i.forEach(t=>t()),i.length=0},f=(t,o,l,u)=>(t.addEventListener(o,l,u),()=>t.removeEventListener(o,l,u)),d=e.computed(()=>{const t=g(e.toValue(n[0])).filter(o=>o!=null);return t.every(o=>typeof o!="string")?t:void 0}),p=M(()=>{var t,o;return[(o=(t=d.value)==null?void 0:t.map(l=>j(l)))!=null?o:[V].filter(l=>l!=null),g(e.toValue(d.value?n[1]:n[0])),g(e.unref(d.value?n[2]:n[1])),e.toValue(d.value?n[3]:n[2])]},([t,o,l,u])=>{if(a(),!(t!=null&&t.length)||!(o!=null&&o.length)||!(l!=null&&l.length))return;const h=C(u)?{...u}:u;i.push(...t.flatMap(b=>o.flatMap(T=>l.map(w=>f(b,T,w,h)))))},{flush:"post"}),y=()=>{p(),a()};return E(a),y}const _={class:"flex flex-col w-full h-full"},k=["src"],D=e.defineComponent({__name:"App",emits:["load","ready","onSuccess","onError"],setup(n,{expose:i,emit:a}){const f=a,d=e.ref("https://cdn2.colegium.com/production/unlayer/index.html"),p=e.ref(),y=e.ref(),t=e.ref(null);W(window,"message",u);function o(){const s=new MessageChannel;p.value=s}function l(){const{port1:s}=p.value;y.value=s,y.value.onmessage=b}function u({data:s}){"ready"in s&&f("ready")}function h(){f("load"),l()}function b(s){const{data:r}=s;if(r.status=="success"){const{template:m,originalTemplate:I}=r;f("onSuccess",{template:m,originalTemplate:I})}else{const{message:m}=r;f("onError",{message:m})}o(),l()}const T=()=>{var s,r;(r=(s=t.value)==null?void 0:s.contentWindow)==null||r.postMessage({type:"GET"},"*",[p.value.port2])},w=s=>{var r,m;(m=(r=t.value)==null?void 0:r.contentWindow)==null||m.postMessage({template:e.toRaw(s),type:"PUT"},"*",[p.value.port2]),o(),l()};return e.onMounted(async()=>{console.log("unlayerIframe.value",t.value),o()}),i({getTemplateDesign:T,setTemplateDesign:w}),(s,r)=>(e.openBlock(),e.createElementBlock("div",_,[r[0]||(r[0]=e.createTextVNode(" Hola gominolax ",-1)),e.createElementVNode("iframe",{class:"w-full h-full overflow-hidden",style:{width:"100%",height:"100%"},ref_key:"unlayerIframe",ref:t,frameborder:"0",loading:"lazy","no-referrer":"",title:"Colegium Unlayer Embed",src:`${e.unref(d)}?v=${new Date().getTime()}`,onLoad:h},null,40,k)]))}});c.ClgTemplateBuilder=D,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|