@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
- export declare const ClgTemplateBuilder: DefineComponent< {}, {
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<{}> & 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, true, {
38
+ }>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
32
39
  unlayerIframe: HTMLIFrameElement;
33
40
  }, HTMLDivElement>;
34
41
 
@@ -1,106 +1,113 @@
1
- import { watch as M, getCurrentScope as _, onScopeDispose as x, computed as k, toValue as g, unref as S, defineComponent as D, ref as h, onMounted as W, createElementBlock as j, openBlock as A, createElementVNode as I, toRaw as L } from "vue";
2
- function O(e) {
3
- return _() ? (x(e), !0) : !1;
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 B = typeof window < "u" && typeof document < "u";
5
+ const O = typeof window < "u" && typeof document < "u";
6
6
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
7
- const G = Object.prototype.toString, P = (e) => G.call(e) === "[object Object]";
8
- function w(e) {
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 $(e, r, s) {
12
- return M(
11
+ function R(e, s, r) {
12
+ return x(
13
13
  e,
14
- r,
14
+ s,
15
15
  {
16
- ...s,
16
+ ...r,
17
17
  immediate: !0
18
18
  }
19
19
  );
20
20
  }
21
- const N = B ? window : void 0;
22
- function R(e) {
23
- var r;
24
- const s = g(e);
25
- return (r = s == null ? void 0 : s.$el) != null ? r : s;
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 U(...e) {
28
- const r = [], s = () => {
29
- r.forEach((n) => n()), r.length = 0;
30
- }, a = (n, t, o, u) => (n.addEventListener(t, o, u), () => n.removeEventListener(t, o, u)), c = k(() => {
31
- const n = w(g(e[0])).filter((t) => t != null);
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((o) => R(o))) != null ? t : [N].filter((o) => o != null),
38
- w(g(c.value ? e[1] : e[0])),
39
- w(S(c.value ? e[2] : e[1])),
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
- g(c.value ? e[3] : e[2])
41
+ h(c.value ? e[3] : e[2])
42
42
  ];
43
43
  },
44
- ([n, t, o, u]) => {
45
- if (s(), !(n != null && n.length) || !(t != null && t.length) || !(o != null && o.length))
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 y = P(u) ? { ...u } : u;
48
- r.push(
47
+ const g = G(a) ? { ...a } : a;
48
+ s.push(
49
49
  ...n.flatMap(
50
- (v) => t.flatMap(
51
- (b) => o.map((E) => a(v, b, E, y))
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(), s();
58
+ d(), r();
59
59
  };
60
- return O(s), m;
60
+ return I(r), m;
61
61
  }
62
- const V = { class: "flex flex-col w-full h-full" }, z = ["src"], F = /* @__PURE__ */ D({
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: r, emit: s }) {
66
- const a = s, c = h("https://cdn2.colegium.com/beta/unlayer/index.html"), d = h(), m = h(), n = h(null);
67
- U(window, "message", u);
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 l = new MessageChannel();
70
- d.value = l;
76
+ const o = new MessageChannel();
77
+ d.value = o;
71
78
  }
72
- function o() {
73
- const { port1: l } = d.value;
74
- m.value = l, m.value.onmessage = v;
79
+ function l() {
80
+ const { port1: o } = d.value;
81
+ m.value = o, m.value.onmessage = y;
75
82
  }
76
- function u({ data: l }) {
77
- "ready" in l && a("ready");
83
+ function a({ data: o }) {
84
+ "ready" in o && u("ready");
78
85
  }
79
- function y() {
80
- a("load"), o();
86
+ function g() {
87
+ u("load"), l();
81
88
  }
82
- function v(l) {
83
- const { data: i } = l;
89
+ function y(o) {
90
+ const { data: i } = o;
84
91
  if (i.status == "success") {
85
- const { template: f, originalTemplate: p, html: T } = i;
86
- a("onSuccess", { template: f, originalTemplate: p, html: T });
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
- a("onError", { message: f });
96
+ u("onError", { message: f });
90
97
  }
91
- t(), o();
98
+ t(), l();
92
99
  }
93
- const b = () => {
94
- C("GET");
95
- }, E = (l) => {
96
- C("PUT", { template: L(l) }), t(), o();
100
+ const v = () => {
101
+ S("GET");
102
+ }, w = (o) => {
103
+ S("PUT", { template: A(o) }), t(), l();
97
104
  };
98
- function C(l, i = {}) {
105
+ function S(o, i = {}) {
99
106
  var f, p;
100
- (p = (f = n.value) == null ? void 0 : f.contentWindow) == null || p.postMessage({ type: l, ...i }, "*", [d.value.port2]);
107
+ (p = (f = n.value) == null ? void 0 : f.contentWindow) == null || p.postMessage({ type: o, ...i }, "*", [d.value.port2]);
101
108
  }
102
- return W(() => t()), r({ getTemplateDesign: b, setTemplateDesign: E }), (l, i) => (A(), j("div", V, [
103
- I("iframe", {
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: `${S(c)}?v=${(/* @__PURE__ */ new Date()).getTime()}`,
113
- onLoad: y
119
+ src: T(c),
120
+ onLoad: g
114
121
  }, null, 40, z)
115
122
  ]));
116
123
  }
@@ -1 +1 @@
1
- (function(a,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(a=typeof globalThis<"u"?globalThis:a||self,e(a["@colegium/vue3-unlayer-embed"]={},a.Vue))})(this,(function(a,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 _=Object.prototype.toString,x=n=>_.call(n)==="[object Object]";function y(n){return Array.isArray(n)?n:[n]}function j(n,i,r){return e.watch(n,i,{...r,immediate:!0})}const V=M?window:void 0;function k(n){var i;const r=e.toValue(n);return(i=r==null?void 0:r.$el)!=null?i:r}function D(...n){const i=[],r=()=>{i.forEach(t=>t()),i.length=0},u=(t,o,l,c)=>(t.addEventListener(o,l,c),()=>t.removeEventListener(o,l,c)),f=e.computed(()=>{const t=y(e.toValue(n[0])).filter(o=>o!=null);return t.every(o=>typeof o!="string")?t:void 0}),m=j(()=>{var t,o;return[(o=(t=f.value)==null?void 0:t.map(l=>k(l)))!=null?o:[V].filter(l=>l!=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,l,c])=>{if(r(),!(t!=null&&t.length)||!(o!=null&&o.length)||!(l!=null&&l.length))return;const b=x(c)?{...c}:c;i.push(...t.flatMap(T=>o.flatMap(E=>l.map(S=>u(T,E,S,b)))))},{flush:"post"}),h=()=>{m(),r()};return C(r),h}const O={class:"flex flex-col w-full h-full"},W=["src"],A=e.defineComponent({__name:"App",emits:["load","ready","onSuccess","onError"],setup(n,{expose:i,emit:r}){const u=r,f=e.ref("https://cdn2.colegium.com/beta/unlayer/index.html"),m=e.ref(),h=e.ref(),t=e.ref(null);D(window,"message",c);function o(){const s=new MessageChannel;m.value=s}function l(){const{port1:s}=m.value;h.value=s,h.value.onmessage=T}function c({data:s}){"ready"in s&&u("ready")}function b(){u("load"),l()}function T(s){const{data:d}=s;if(d.status=="success"){const{template:p,originalTemplate:g,html:I}=d;u("onSuccess",{template:p,originalTemplate:g,html:I})}else{const{message:p}=d;u("onError",{message:p})}o(),l()}const E=()=>{w("GET")},S=s=>{w("PUT",{template:e.toRaw(s)}),o(),l()};function w(s,d={}){var p,g;(g=(p=t.value)==null?void 0:p.contentWindow)==null||g.postMessage({type:s,...d},"*",[m.value.port2])}return e.onMounted(()=>o()),i({getTemplateDesign:E,setTemplateDesign:S}),(s,d)=>(e.openBlock(),e.createElementBlock("div",O,[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)}?v=${new Date().getTime()}`,onLoad:b},null,40,W)]))}});a.ClgTemplateBuilder=A,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
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.14",
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 --tag beta"
28
+ "release": "pnpm publish --access public"
29
29
  }
30
30
  }