@colegium_dev/vue3-unlayer-embed 1.0.14 → 1.0.15
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.d.ts
CHANGED
|
@@ -3,7 +3,14 @@ import { ComponentProvideOptions } from 'vue';
|
|
|
3
3
|
import { DefineComponent } from 'vue';
|
|
4
4
|
import { PublicProps } from 'vue';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
declare type __VLS_Props = {
|
|
7
|
+
/** URL del iframe publicado en el CDN. Por defecto, producción. */
|
|
8
|
+
iframeUrl?: string;
|
|
9
|
+
/** Módulo que abre el editor (define su configuración). Sin valor, el iframe usa `mensajes`. */
|
|
10
|
+
module?: 'mensajes' | 'matricula';
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export declare const ClgTemplateBuilder: DefineComponent<__VLS_Props, {
|
|
7
14
|
getTemplateDesign: () => void;
|
|
8
15
|
setTemplateDesign: (template: unknown) => void;
|
|
9
16
|
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
|
|
@@ -17,7 +24,7 @@ html: string;
|
|
|
17
24
|
onError: (args_0: {
|
|
18
25
|
message: string;
|
|
19
26
|
}) => any;
|
|
20
|
-
}, string, PublicProps, Readonly<
|
|
27
|
+
}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
21
28
|
onLoad?: (() => any) | undefined;
|
|
22
29
|
onReady?: (() => any) | undefined;
|
|
23
30
|
onOnSuccess?: ((args_0: {
|
|
@@ -28,7 +35,7 @@ html: string;
|
|
|
28
35
|
onOnError?: ((args_0: {
|
|
29
36
|
message: string;
|
|
30
37
|
}) => any) | undefined;
|
|
31
|
-
}>, {}, {}, {}, {}, string, ComponentProvideOptions,
|
|
38
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
32
39
|
unlayerIframe: HTMLIFrameElement;
|
|
33
40
|
}, HTMLDivElement>;
|
|
34
41
|
|
|
@@ -1,106 +1,113 @@
|
|
|
1
|
-
import { watch as
|
|
2
|
-
function
|
|
3
|
-
return
|
|
1
|
+
import { watch as x, getCurrentScope as k, onScopeDispose as D, computed as C, toValue as h, unref as T, defineComponent as L, ref as E, onMounted as P, createElementBlock as U, openBlock as W, createElementVNode as j, toRaw as A } from "vue";
|
|
2
|
+
function I(e) {
|
|
3
|
+
return k() ? (D(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 b(e) {
|
|
9
9
|
return Array.isArray(e) ? e : [e];
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return
|
|
11
|
+
function R(e, s, r) {
|
|
12
|
+
return x(
|
|
13
13
|
e,
|
|
14
|
-
|
|
14
|
+
s,
|
|
15
15
|
{
|
|
16
|
-
...
|
|
16
|
+
...r,
|
|
17
17
|
immediate: !0
|
|
18
18
|
}
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
|
-
const N =
|
|
22
|
-
function
|
|
23
|
-
var
|
|
24
|
-
const
|
|
25
|
-
return (
|
|
21
|
+
const N = O ? window : void 0;
|
|
22
|
+
function V(e) {
|
|
23
|
+
var s;
|
|
24
|
+
const r = h(e);
|
|
25
|
+
return (s = r == null ? void 0 : r.$el) != null ? s : r;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
const n =
|
|
27
|
+
function _(...e) {
|
|
28
|
+
const s = [], r = () => {
|
|
29
|
+
s.forEach((n) => n()), s.length = 0;
|
|
30
|
+
}, u = (n, t, l, a) => (n.addEventListener(t, l, a), () => n.removeEventListener(t, l, a)), c = C(() => {
|
|
31
|
+
const n = b(h(e[0])).filter((t) => t != null);
|
|
32
32
|
return n.every((t) => typeof t != "string") ? n : void 0;
|
|
33
|
-
}), d =
|
|
33
|
+
}), d = R(
|
|
34
34
|
() => {
|
|
35
35
|
var n, t;
|
|
36
36
|
return [
|
|
37
|
-
(t = (n = c.value) == null ? void 0 : n.map((
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
(t = (n = c.value) == null ? void 0 : n.map((l) => V(l))) != null ? t : [N].filter((l) => l != null),
|
|
38
|
+
b(h(c.value ? e[1] : e[0])),
|
|
39
|
+
b(T(c.value ? e[2] : e[1])),
|
|
40
40
|
// @ts-expect-error - TypeScript gets the correct types, but somehow still complains
|
|
41
|
-
|
|
41
|
+
h(c.value ? e[3] : e[2])
|
|
42
42
|
];
|
|
43
43
|
},
|
|
44
|
-
([n, t,
|
|
45
|
-
if (
|
|
44
|
+
([n, t, l, a]) => {
|
|
45
|
+
if (r(), !(n != null && n.length) || !(t != null && t.length) || !(l != null && l.length))
|
|
46
46
|
return;
|
|
47
|
-
const
|
|
48
|
-
|
|
47
|
+
const g = G(a) ? { ...a } : a;
|
|
48
|
+
s.push(
|
|
49
49
|
...n.flatMap(
|
|
50
|
-
(
|
|
51
|
-
(
|
|
50
|
+
(y) => t.flatMap(
|
|
51
|
+
(v) => l.map((w) => u(y, v, w, g))
|
|
52
52
|
)
|
|
53
53
|
)
|
|
54
54
|
);
|
|
55
55
|
},
|
|
56
56
|
{ flush: "post" }
|
|
57
57
|
), m = () => {
|
|
58
|
-
d(),
|
|
58
|
+
d(), r();
|
|
59
59
|
};
|
|
60
|
-
return
|
|
60
|
+
return I(r), m;
|
|
61
61
|
}
|
|
62
|
-
const
|
|
62
|
+
const $ = { class: "flex flex-col w-full h-full" }, z = ["src"], F = /* @__PURE__ */ L({
|
|
63
63
|
__name: "App",
|
|
64
|
+
props: {
|
|
65
|
+
iframeUrl: { default: () => "https://cdn2.colegium.com/production/unlayer/index.html" },
|
|
66
|
+
module: {}
|
|
67
|
+
},
|
|
64
68
|
emits: ["load", "ready", "onSuccess", "onError"],
|
|
65
|
-
setup(e, { expose:
|
|
66
|
-
const
|
|
67
|
-
|
|
69
|
+
setup(e, { expose: s, emit: r }) {
|
|
70
|
+
const u = r, c = C(() => {
|
|
71
|
+
const o = new URL(e.iframeUrl, window.location.href);
|
|
72
|
+
return e.module && o.searchParams.set("module", e.module), o.searchParams.set("v", `${(/* @__PURE__ */ new Date()).getTime()}`), o.toString();
|
|
73
|
+
}), d = E(), m = E(), n = E(null);
|
|
74
|
+
_(window, "message", a);
|
|
68
75
|
function t() {
|
|
69
|
-
const
|
|
70
|
-
d.value =
|
|
76
|
+
const o = new MessageChannel();
|
|
77
|
+
d.value = o;
|
|
71
78
|
}
|
|
72
|
-
function
|
|
73
|
-
const { port1:
|
|
74
|
-
m.value =
|
|
79
|
+
function l() {
|
|
80
|
+
const { port1: o } = d.value;
|
|
81
|
+
m.value = o, m.value.onmessage = y;
|
|
75
82
|
}
|
|
76
|
-
function
|
|
77
|
-
"ready" in
|
|
83
|
+
function a({ data: o }) {
|
|
84
|
+
"ready" in o && u("ready");
|
|
78
85
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
86
|
+
function g() {
|
|
87
|
+
u("load"), l();
|
|
81
88
|
}
|
|
82
|
-
function
|
|
83
|
-
const { data: i } =
|
|
89
|
+
function y(o) {
|
|
90
|
+
const { data: i } = o;
|
|
84
91
|
if (i.status == "success") {
|
|
85
|
-
const { template: f, originalTemplate: p, html:
|
|
86
|
-
|
|
92
|
+
const { template: f, originalTemplate: p, html: M } = i;
|
|
93
|
+
u("onSuccess", { template: f, originalTemplate: p, html: M });
|
|
87
94
|
} else {
|
|
88
95
|
const { message: f } = i;
|
|
89
|
-
|
|
96
|
+
u("onError", { message: f });
|
|
90
97
|
}
|
|
91
|
-
t(),
|
|
98
|
+
t(), l();
|
|
92
99
|
}
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
|
|
100
|
+
const v = () => {
|
|
101
|
+
S("GET");
|
|
102
|
+
}, w = (o) => {
|
|
103
|
+
S("PUT", { template: A(o) }), t(), l();
|
|
97
104
|
};
|
|
98
|
-
function
|
|
105
|
+
function S(o, i = {}) {
|
|
99
106
|
var f, p;
|
|
100
|
-
(p = (f = n.value) == null ? void 0 : f.contentWindow) == null || p.postMessage({ type:
|
|
107
|
+
(p = (f = n.value) == null ? void 0 : f.contentWindow) == null || p.postMessage({ type: o, ...i }, "*", [d.value.port2]);
|
|
101
108
|
}
|
|
102
|
-
return
|
|
103
|
-
|
|
109
|
+
return P(() => t()), s({ getTemplateDesign: v, setTemplateDesign: w }), (o, i) => (W(), U("div", $, [
|
|
110
|
+
j("iframe", {
|
|
104
111
|
class: "w-full h-full overflow-hidden",
|
|
105
112
|
style: { width: "100%", height: "100%" },
|
|
106
113
|
ref_key: "unlayerIframe",
|
|
@@ -109,8 +116,8 @@ const V = { class: "flex flex-col w-full h-full" }, z = ["src"], F = /* @__PURE_
|
|
|
109
116
|
loading: "lazy",
|
|
110
117
|
"no-referrer": "",
|
|
111
118
|
title: "Colegium Unlayer Embed",
|
|
112
|
-
src:
|
|
113
|
-
onLoad:
|
|
119
|
+
src: T(c),
|
|
120
|
+
onLoad: g
|
|
114
121
|
}, null, 40, z)
|
|
115
122
|
]));
|
|
116
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 C(n){return e.getCurrentScope()?(e.onScopeDispose(n),!0):!1}const M=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const x=Object.prototype.toString,j=n=>x.call(n)==="[object Object]";function y(n){return Array.isArray(n)?n:[n]}function P(n,i,s){return e.watch(n,i,{...s,immediate:!0})}const V=M?window:void 0;function k(n){var i;const s=e.toValue(n);return(i=s==null?void 0:s.$el)!=null?i:s}function D(...n){const i=[],s=()=>{i.forEach(t=>t()),i.length=0},u=(t,o,r,a)=>(t.addEventListener(o,r,a),()=>t.removeEventListener(o,r,a)),f=e.computed(()=>{const t=y(e.toValue(n[0])).filter(o=>o!=null);return t.every(o=>typeof o!="string")?t:void 0}),p=P(()=>{var t,o;return[(o=(t=f.value)==null?void 0:t.map(r=>k(r)))!=null?o:[V].filter(r=>r!=null),y(e.toValue(f.value?n[1]:n[0])),y(e.unref(f.value?n[2]:n[1])),e.toValue(f.value?n[3]:n[2])]},([t,o,r,a])=>{if(s(),!(t!=null&&t.length)||!(o!=null&&o.length)||!(r!=null&&r.length))return;const b=j(a)?{...a}:a;i.push(...t.flatMap(w=>o.flatMap(S=>r.map(T=>u(w,S,T,b)))))},{flush:"post"}),h=()=>{p(),s()};return C(s),h}const L={class:"flex flex-col w-full h-full"},O=["src"],U=e.defineComponent({__name:"App",props:{iframeUrl:{default:()=>"https://cdn2.colegium.com/production/unlayer/index.html"},module:{}},emits:["load","ready","onSuccess","onError"],setup(n,{expose:i,emit:s}){const u=s,f=e.computed(()=>{const l=new URL(n.iframeUrl,window.location.href);return n.module&&l.searchParams.set("module",n.module),l.searchParams.set("v",`${new Date().getTime()}`),l.toString()}),p=e.ref(),h=e.ref(),t=e.ref(null);D(window,"message",a);function o(){const l=new MessageChannel;p.value=l}function r(){const{port1:l}=p.value;h.value=l,h.value.onmessage=w}function a({data:l}){"ready"in l&&u("ready")}function b(){u("load"),r()}function w(l){const{data:d}=l;if(d.status=="success"){const{template:m,originalTemplate:g,html:W}=d;u("onSuccess",{template:m,originalTemplate:g,html:W})}else{const{message:m}=d;u("onError",{message:m})}o(),r()}const S=()=>{E("GET")},T=l=>{E("PUT",{template:e.toRaw(l)}),o(),r()};function E(l,d={}){var m,g;(g=(m=t.value)==null?void 0:m.contentWindow)==null||g.postMessage({type:l,...d},"*",[p.value.port2])}return e.onMounted(()=>o()),i({getTemplateDesign:S,setTemplateDesign:T}),(l,d)=>(e.openBlock(),e.createElementBlock("div",L,[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(f),onLoad:b},null,40,O)]))}});c.ClgTemplateBuilder=U,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colegium_dev/vue3-unlayer-embed",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "Unlayer Embed project for Colegium Cloud Platform",
|
|
5
5
|
"author": "Colegium Frontend Team",
|
|
6
6
|
"type": "module",
|
|
@@ -25,6 +25,6 @@
|
|
|
25
25
|
"version-patch": "pnpm version patch",
|
|
26
26
|
"version-minor": "pnpm version minor",
|
|
27
27
|
"version-major": "pnpm version major",
|
|
28
|
-
"release": "pnpm publish --access public
|
|
28
|
+
"release": "pnpm publish --access public"
|
|
29
29
|
}
|
|
30
30
|
}
|