@documenso/embed-preact 0.2.3 → 0.3.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/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("preact"),s=require("preact/hooks");var b=0;function l(e,c,o,d,t,n){c||(c={});var a,i,m=c;if("ref"in m)for(i in m={},c)i=="ref"?a=c[i]:m[i]=c[i];var u={type:e,props:m,key:o,ref:a,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--b,__i:-1,__u:0,__source:t,__self:n};return f.options.vnode&&f.options.vnode(u),u}function k(e){const c=s.useRef(null);function o(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,email:e.email,lockEmail:e.lockEmail,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL(`/embed/direct/${e.token}`,t);return e.externalId&&a.searchParams.set("externalId",e.externalId),`${a}#${n}`}function d(t){var n,a,i,m,u,r;if(((n=c.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.action){case"document-ready":(a=e.onDocumentReady)==null||a.call(e);break;case"document-completed":(i=e.onDocumentCompleted)==null||i.call(e,t.data.data);break;case"document-error":(m=e.onDocumentError)==null||m.call(e,t.data.data);break;case"field-signed":(u=e.onFieldSigned)==null||u.call(e);break;case"field-unsigned":(r=e.onFieldUnsigned)==null||r.call(e);break}}return s.useEffect(()=>{window.addEventListener("message",d)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",d)},[]),l("iframe",{ref:c,className:e.className,src:o()})}function g(e){const c=s.useRef(null);function o(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,allowDocumentRejection:e.allowDocumentRejection,...e.additionalProps})));return`${new URL(`/embed/sign/${e.token}`,t)}#${n}`}function d(t){var n,a,i,m,u;if(((n=c.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.action){case"document-ready":(a=e.onDocumentReady)==null||a.call(e);break;case"document-completed":(i=e.onDocumentCompleted)==null||i.call(e,t.data.data);break;case"document-error":(m=e.onDocumentError)==null||m.call(e,t.data.data);break;case"document-rejected":(u=e.onDocumentRejected)==null||u.call(e,t.data.data);break}}return s.useEffect(()=>{window.addEventListener("message",d)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",d)},[]),l("iframe",{ref:c,className:e.className,src:o()})}function w(e){const c=s.useRef(null);function o(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL("/embed/v1/authoring/document/create",t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function d(t){var n,a;if(((n=c.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"document-created":(a=e.onDocumentCreated)==null||a.call(e,{documentId:t.data.documentId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",d)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",d)},[]),l("iframe",{ref:c,className:e.className,src:o()})}function h(e){const c=s.useRef(null);function o(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL("/embed/v1/authoring/template/create",t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function d(t){var n,a;if(((n=c.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"template-created":(a=e.onTemplateCreated)==null||a.call(e,{templateId:t.data.templateId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",d)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",d)},[]),l("iframe",{ref:c,className:e.className,src:o()})}function E(e){const c=s.useRef(null);function o(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({token:e.presignToken,externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL(`/embed/v1/authoring/document/edit/${e.documentId}`,t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function d(t){var n,a;if(((n=c.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"document-updated":(a=e.onDocumentUpdated)==null||a.call(e,{documentId:t.data.documentId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",d)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",d)},[]),l("iframe",{ref:c,className:e.className,src:o()})}function D(e){const c=s.useRef(null);function o(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),a=new URL(`/embed/v1/authoring/template/edit/${e.templateId}`,t);return a.searchParams.set("token",e.presignToken),a.hash=n,a.toString()}function d(t){var n,a;if(((n=c.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.type){case"template-updated":(a=e.onTemplateUpdated)==null||a.call(e,{templateId:t.data.templateId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",d)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",d)},[]),l("iframe",{ref:c,className:e.className,src:o()})}function _(e){const c=s.useRef(null);function o(){const t=e.host||"https://app.documenso.com",n=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,allowDocumentRejection:e.allowDocumentRejection,...e.additionalProps}))),a=new URL("/embed/v1/multisign",t);for(const i of e.tokens)a.searchParams.append("token",i);return`${a}#${n}`}function d(t){var n,a,i,m,u,r;if(((n=c.current)==null?void 0:n.contentWindow)===t.source)switch(t.data.action){case"document-ready":(a=e.onDocumentReady)==null||a.call(e);break;case"document-completed":(i=e.onDocumentCompleted)==null||i.call(e,t.data.data);break;case"document-error":(m=e.onDocumentError)==null||m.call(e,t.data.data);break;case"document-rejected":(u=e.onDocumentRejected)==null||u.call(e,t.data.data);break;case"all-documents-completed":(r=e.onAllDocumentsCompleted)==null||r.call(e,t.data.data);break}}return s.useEffect(()=>{window.addEventListener("message",d)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",d)},[]),l("iframe",{ref:c,className:e.className,src:o()})}exports.EmbedDirectTemplate=k;exports.EmbedSignDocument=g;exports.unstable_EmbedCreateDocument=w;exports.unstable_EmbedCreateTemplate=h;exports.unstable_EmbedMultiSignDocument=_;exports.unstable_EmbedUpdateDocument=E;exports.unstable_EmbedUpdateTemplate=D;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("preact"),s=require("preact/hooks");var f=0;function i(e,a,d,c,t,o){a||(a={});var n,r,m=a;if("ref"in m)for(r in m={},a)r=="ref"?n=a[r]:m[r]=a[r];var u={type:e,props:m,key:d,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--f,__i:-1,__u:0,__source:t,__self:o};return l.options.vnode&&l.options.vnode(u),u}function b(e){const a=s.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,email:e.email,lockEmail:e.lockEmail,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),n=new URL(`/embed/direct/${e.token}`,t);return e.externalId&&n.searchParams.set("externalId",e.externalId),`${n}#${o}`}function c(t){if(a.current?.contentWindow===t.source)switch(t.data.action){case"document-ready":e.onDocumentReady?.();break;case"document-completed":e.onDocumentCompleted?.(t.data.data);break;case"document-error":e.onDocumentError?.(t.data.data);break;case"field-signed":e.onFieldSigned?.();break;case"field-unsigned":e.onFieldUnsigned?.();break}}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function k(e){const a=s.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,allowDocumentRejection:e.allowDocumentRejection,...e.additionalProps})));return`${new URL(`/embed/sign/${e.token}`,t)}#${o}`}function c(t){if(a.current?.contentWindow===t.source)switch(t.data.action){case"document-ready":e.onDocumentReady?.();break;case"document-completed":e.onDocumentCompleted?.(t.data.data);break;case"document-error":e.onDocumentError?.(t.data.data);break;case"document-rejected":e.onDocumentRejected?.(t.data.data);break}}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function g(e){const a=s.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),n=new URL("/embed/v1/authoring/document/create",t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function c(t){if(a.current?.contentWindow===t.source)switch(t.data.type){case"document-created":e.onDocumentCreated?.({documentId:t.data.documentId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function w(e){const a=s.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),n=new URL("/embed/v1/authoring/template/create",t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function c(t){if(a.current?.contentWindow===t.source)switch(t.data.type){case"template-created":e.onTemplateCreated?.({templateId:t.data.templateId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function h(e){const a=s.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({token:e.presignToken,externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),n=new URL(`/embed/v1/authoring/document/edit/${e.documentId}`,t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function c(t){if(a.current?.contentWindow===t.source)switch(t.data.type){case"document-updated":e.onDocumentUpdated?.({documentId:t.data.documentId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function E(e){const a=s.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,...e.additionalProps}))),n=new URL(`/embed/v1/authoring/template/edit/${e.templateId}`,t);return n.searchParams.set("token",e.presignToken),n.hash=o,n.toString()}function c(t){if(a.current?.contentWindow===t.source)switch(t.data.type){case"template-updated":e.onTemplateUpdated?.({templateId:t.data.templateId,externalId:t.data.externalId});break}}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function D(e){const a=s.useRef(null);function d(){const t=e.host||"https://app.documenso.com",o=btoa(encodeURIComponent(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,allowDocumentRejection:e.allowDocumentRejection,...e.additionalProps}))),n=new URL("/embed/v1/multisign",t);for(const r of e.tokens)n.searchParams.append("token",r);return`${n}#${o}`}function c(t){if(a.current?.contentWindow===t.source)switch(t.data.action){case"document-ready":e.onDocumentReady?.();break;case"document-completed":e.onDocumentCompleted?.(t.data.data);break;case"document-error":e.onDocumentError?.(t.data.data);break;case"document-rejected":e.onDocumentRejected?.(t.data.data);break;case"all-documents-completed":e.onAllDocumentsCompleted?.(t.data.data);break}}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}exports.EmbedDirectTemplate=b;exports.EmbedSignDocument=k;exports.unstable_EmbedCreateDocument=g;exports.unstable_EmbedCreateTemplate=w;exports.unstable_EmbedMultiSignDocument=D;exports.unstable_EmbedUpdateDocument=h;exports.unstable_EmbedUpdateTemplate=E;
package/dist/index.mjs CHANGED
@@ -1,17 +1,17 @@
1
- import { options as b } from "preact";
2
- import { useRef as u, useEffect as m } from "preact/hooks";
3
- var k = 0;
4
- function r(e, d, i, c, a, n) {
5
- d || (d = {});
6
- var t, s, o = d;
7
- if ("ref" in o) for (s in o = {}, d) s == "ref" ? t = d[s] : o[s] = d[s];
8
- var l = { type: e, props: o, key: i, ref: t, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --k, __i: -1, __u: 0, __source: a, __self: n };
9
- return b.vnode && b.vnode(l), l;
1
+ import { options as f } from "preact";
2
+ import { useRef as i, useEffect as o } from "preact/hooks";
3
+ var b = 0;
4
+ function m(e, t, c, d, a, s) {
5
+ t || (t = {});
6
+ var n, r, l = t;
7
+ if ("ref" in l) for (r in l = {}, t) r == "ref" ? n = t[r] : l[r] = t[r];
8
+ var u = { type: e, props: l, key: c, ref: n, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --b, __i: -1, __u: 0, __source: a, __self: s };
9
+ return f.vnode && f.vnode(u), u;
10
10
  }
11
- function h(e) {
12
- const d = u(null);
13
- function i() {
14
- const a = e.host || "https://app.documenso.com", n = btoa(
11
+ function g(e) {
12
+ const t = i(null);
13
+ function c() {
14
+ const a = e.host || "https://app.documenso.com", s = btoa(
15
15
  encodeURIComponent(
16
16
  JSON.stringify({
17
17
  name: e.name,
@@ -24,40 +24,39 @@ function h(e) {
24
24
  ...e.additionalProps
25
25
  })
26
26
  )
27
- ), t = new URL(`/embed/direct/${e.token}`, a);
28
- return e.externalId && t.searchParams.set("externalId", e.externalId), `${t}#${n}`;
27
+ ), n = new URL(`/embed/direct/${e.token}`, a);
28
+ return e.externalId && n.searchParams.set("externalId", e.externalId), `${n}#${s}`;
29
29
  }
30
- function c(a) {
31
- var n, t, s, o, l, f;
32
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
30
+ function d(a) {
31
+ if (t.current?.contentWindow === a.source)
33
32
  switch (a.data.action) {
34
33
  case "document-ready":
35
- (t = e.onDocumentReady) == null || t.call(e);
34
+ e.onDocumentReady?.();
36
35
  break;
37
36
  case "document-completed":
38
- (s = e.onDocumentCompleted) == null || s.call(e, a.data.data);
37
+ e.onDocumentCompleted?.(a.data.data);
39
38
  break;
40
39
  case "document-error":
41
- (o = e.onDocumentError) == null || o.call(e, a.data.data);
40
+ e.onDocumentError?.(a.data.data);
42
41
  break;
43
42
  case "field-signed":
44
- (l = e.onFieldSigned) == null || l.call(e);
43
+ e.onFieldSigned?.();
45
44
  break;
46
45
  case "field-unsigned":
47
- (f = e.onFieldUnsigned) == null || f.call(e);
46
+ e.onFieldUnsigned?.();
48
47
  break;
49
48
  }
50
49
  }
51
- return m(() => {
52
- window.addEventListener("message", c);
53
- }, []), m(() => () => {
54
- window.removeEventListener("message", c);
55
- }, []), /* @__PURE__ */ r("iframe", { ref: d, className: e.className, src: i() });
50
+ return o(() => {
51
+ window.addEventListener("message", d);
52
+ }, []), o(() => () => {
53
+ window.removeEventListener("message", d);
54
+ }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: c() });
56
55
  }
57
- function _(e) {
58
- const d = u(null);
59
- function i() {
60
- const a = e.host || "https://app.documenso.com", n = btoa(
56
+ function h(e) {
57
+ const t = i(null);
58
+ function c() {
59
+ const a = e.host || "https://app.documenso.com", s = btoa(
61
60
  encodeURIComponent(
62
61
  JSON.stringify({
63
62
  name: e.name,
@@ -70,36 +69,35 @@ function _(e) {
70
69
  })
71
70
  )
72
71
  );
73
- return `${new URL(`/embed/sign/${e.token}`, a)}#${n}`;
72
+ return `${new URL(`/embed/sign/${e.token}`, a)}#${s}`;
74
73
  }
75
- function c(a) {
76
- var n, t, s, o, l;
77
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
74
+ function d(a) {
75
+ if (t.current?.contentWindow === a.source)
78
76
  switch (a.data.action) {
79
77
  case "document-ready":
80
- (t = e.onDocumentReady) == null || t.call(e);
78
+ e.onDocumentReady?.();
81
79
  break;
82
80
  case "document-completed":
83
- (s = e.onDocumentCompleted) == null || s.call(e, a.data.data);
81
+ e.onDocumentCompleted?.(a.data.data);
84
82
  break;
85
83
  case "document-error":
86
- (o = e.onDocumentError) == null || o.call(e, a.data.data);
84
+ e.onDocumentError?.(a.data.data);
87
85
  break;
88
86
  case "document-rejected":
89
- (l = e.onDocumentRejected) == null || l.call(e, a.data.data);
87
+ e.onDocumentRejected?.(a.data.data);
90
88
  break;
91
89
  }
92
90
  }
93
- return m(() => {
94
- window.addEventListener("message", c);
95
- }, []), m(() => () => {
96
- window.removeEventListener("message", c);
97
- }, []), /* @__PURE__ */ r("iframe", { ref: d, className: e.className, src: i() });
91
+ return o(() => {
92
+ window.addEventListener("message", d);
93
+ }, []), o(() => () => {
94
+ window.removeEventListener("message", d);
95
+ }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: c() });
98
96
  }
99
- function D(e) {
100
- const d = u(null);
101
- function i() {
102
- const a = e.host || "https://app.documenso.com", n = btoa(
97
+ function _(e) {
98
+ const t = i(null);
99
+ function c() {
100
+ const a = e.host || "https://app.documenso.com", s = btoa(
103
101
  encodeURIComponent(
104
102
  JSON.stringify({
105
103
  externalId: e.externalId,
@@ -110,31 +108,30 @@ function D(e) {
110
108
  ...e.additionalProps
111
109
  })
112
110
  )
113
- ), t = new URL("/embed/v1/authoring/document/create", a);
114
- return t.searchParams.set("token", e.presignToken), t.hash = n, t.toString();
111
+ ), n = new URL("/embed/v1/authoring/document/create", a);
112
+ return n.searchParams.set("token", e.presignToken), n.hash = s, n.toString();
115
113
  }
116
- function c(a) {
117
- var n, t;
118
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
114
+ function d(a) {
115
+ if (t.current?.contentWindow === a.source)
119
116
  switch (a.data.type) {
120
117
  case "document-created":
121
- (t = e.onDocumentCreated) == null || t.call(e, {
118
+ e.onDocumentCreated?.({
122
119
  documentId: a.data.documentId,
123
120
  externalId: a.data.externalId
124
121
  });
125
122
  break;
126
123
  }
127
124
  }
128
- return m(() => {
129
- window.addEventListener("message", c);
130
- }, []), m(() => () => {
131
- window.removeEventListener("message", c);
132
- }, []), /* @__PURE__ */ r("iframe", { ref: d, className: e.className, src: i() });
125
+ return o(() => {
126
+ window.addEventListener("message", d);
127
+ }, []), o(() => () => {
128
+ window.removeEventListener("message", d);
129
+ }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: c() });
133
130
  }
134
- function I(e) {
135
- const d = u(null);
136
- function i() {
137
- const a = e.host || "https://app.documenso.com", n = btoa(
131
+ function D(e) {
132
+ const t = i(null);
133
+ function c() {
134
+ const a = e.host || "https://app.documenso.com", s = btoa(
138
135
  encodeURIComponent(
139
136
  JSON.stringify({
140
137
  externalId: e.externalId,
@@ -145,31 +142,30 @@ function I(e) {
145
142
  ...e.additionalProps
146
143
  })
147
144
  )
148
- ), t = new URL("/embed/v1/authoring/template/create", a);
149
- return t.searchParams.set("token", e.presignToken), t.hash = n, t.toString();
145
+ ), n = new URL("/embed/v1/authoring/template/create", a);
146
+ return n.searchParams.set("token", e.presignToken), n.hash = s, n.toString();
150
147
  }
151
- function c(a) {
152
- var n, t;
153
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
148
+ function d(a) {
149
+ if (t.current?.contentWindow === a.source)
154
150
  switch (a.data.type) {
155
151
  case "template-created":
156
- (t = e.onTemplateCreated) == null || t.call(e, {
152
+ e.onTemplateCreated?.({
157
153
  templateId: a.data.templateId,
158
154
  externalId: a.data.externalId
159
155
  });
160
156
  break;
161
157
  }
162
158
  }
163
- return m(() => {
164
- window.addEventListener("message", c);
165
- }, []), m(() => () => {
166
- window.removeEventListener("message", c);
167
- }, []), /* @__PURE__ */ r("iframe", { ref: d, className: e.className, src: i() });
159
+ return o(() => {
160
+ window.addEventListener("message", d);
161
+ }, []), o(() => () => {
162
+ window.removeEventListener("message", d);
163
+ }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: c() });
168
164
  }
169
- function E(e) {
170
- const d = u(null);
171
- function i() {
172
- const a = e.host || "https://app.documenso.com", n = btoa(
165
+ function I(e) {
166
+ const t = i(null);
167
+ function c() {
168
+ const a = e.host || "https://app.documenso.com", s = btoa(
173
169
  encodeURIComponent(
174
170
  JSON.stringify({
175
171
  token: e.presignToken,
@@ -181,34 +177,33 @@ function E(e) {
181
177
  ...e.additionalProps
182
178
  })
183
179
  )
184
- ), t = new URL(
180
+ ), n = new URL(
185
181
  `/embed/v1/authoring/document/edit/${e.documentId}`,
186
182
  a
187
183
  );
188
- return t.searchParams.set("token", e.presignToken), t.hash = n, t.toString();
184
+ return n.searchParams.set("token", e.presignToken), n.hash = s, n.toString();
189
185
  }
190
- function c(a) {
191
- var n, t;
192
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
186
+ function d(a) {
187
+ if (t.current?.contentWindow === a.source)
193
188
  switch (a.data.type) {
194
189
  case "document-updated":
195
- (t = e.onDocumentUpdated) == null || t.call(e, {
190
+ e.onDocumentUpdated?.({
196
191
  documentId: a.data.documentId,
197
192
  externalId: a.data.externalId
198
193
  });
199
194
  break;
200
195
  }
201
196
  }
202
- return m(() => {
203
- window.addEventListener("message", c);
204
- }, []), m(() => () => {
205
- window.removeEventListener("message", c);
206
- }, []), /* @__PURE__ */ r("iframe", { ref: d, className: e.className, src: i() });
197
+ return o(() => {
198
+ window.addEventListener("message", d);
199
+ }, []), o(() => () => {
200
+ window.removeEventListener("message", d);
201
+ }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: c() });
207
202
  }
208
- function U(e) {
209
- const d = u(null);
210
- function i() {
211
- const a = e.host || "https://app.documenso.com", n = btoa(
203
+ function E(e) {
204
+ const t = i(null);
205
+ function c() {
206
+ const a = e.host || "https://app.documenso.com", s = btoa(
212
207
  encodeURIComponent(
213
208
  JSON.stringify({
214
209
  externalId: e.externalId,
@@ -219,34 +214,33 @@ function U(e) {
219
214
  ...e.additionalProps
220
215
  })
221
216
  )
222
- ), t = new URL(
217
+ ), n = new URL(
223
218
  `/embed/v1/authoring/template/edit/${e.templateId}`,
224
219
  a
225
220
  );
226
- return t.searchParams.set("token", e.presignToken), t.hash = n, t.toString();
221
+ return n.searchParams.set("token", e.presignToken), n.hash = s, n.toString();
227
222
  }
228
- function c(a) {
229
- var n, t;
230
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
223
+ function d(a) {
224
+ if (t.current?.contentWindow === a.source)
231
225
  switch (a.data.type) {
232
226
  case "template-updated":
233
- (t = e.onTemplateUpdated) == null || t.call(e, {
227
+ e.onTemplateUpdated?.({
234
228
  templateId: a.data.templateId,
235
229
  externalId: a.data.externalId
236
230
  });
237
231
  break;
238
232
  }
239
233
  }
240
- return m(() => {
241
- window.addEventListener("message", c);
242
- }, []), m(() => () => {
243
- window.removeEventListener("message", c);
244
- }, []), /* @__PURE__ */ r("iframe", { ref: d, className: e.className, src: i() });
234
+ return o(() => {
235
+ window.addEventListener("message", d);
236
+ }, []), o(() => () => {
237
+ window.removeEventListener("message", d);
238
+ }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: c() });
245
239
  }
246
- function N(e) {
247
- const d = u(null);
248
- function i() {
249
- const a = e.host || "https://app.documenso.com", n = btoa(
240
+ function U(e) {
241
+ const t = i(null);
242
+ function c() {
243
+ const a = e.host || "https://app.documenso.com", s = btoa(
250
244
  encodeURIComponent(
251
245
  JSON.stringify({
252
246
  name: e.name,
@@ -258,44 +252,43 @@ function N(e) {
258
252
  ...e.additionalProps
259
253
  })
260
254
  )
261
- ), t = new URL("/embed/v1/multisign", a);
262
- for (const s of e.tokens)
263
- t.searchParams.append("token", s);
264
- return `${t}#${n}`;
255
+ ), n = new URL("/embed/v1/multisign", a);
256
+ for (const r of e.tokens)
257
+ n.searchParams.append("token", r);
258
+ return `${n}#${s}`;
265
259
  }
266
- function c(a) {
267
- var n, t, s, o, l, f;
268
- if (((n = d.current) == null ? void 0 : n.contentWindow) === a.source)
260
+ function d(a) {
261
+ if (t.current?.contentWindow === a.source)
269
262
  switch (a.data.action) {
270
263
  case "document-ready":
271
- (t = e.onDocumentReady) == null || t.call(e);
264
+ e.onDocumentReady?.();
272
265
  break;
273
266
  case "document-completed":
274
- (s = e.onDocumentCompleted) == null || s.call(e, a.data.data);
267
+ e.onDocumentCompleted?.(a.data.data);
275
268
  break;
276
269
  case "document-error":
277
- (o = e.onDocumentError) == null || o.call(e, a.data.data);
270
+ e.onDocumentError?.(a.data.data);
278
271
  break;
279
272
  case "document-rejected":
280
- (l = e.onDocumentRejected) == null || l.call(e, a.data.data);
273
+ e.onDocumentRejected?.(a.data.data);
281
274
  break;
282
275
  case "all-documents-completed":
283
- (f = e.onAllDocumentsCompleted) == null || f.call(e, a.data.data);
276
+ e.onAllDocumentsCompleted?.(a.data.data);
284
277
  break;
285
278
  }
286
279
  }
287
- return m(() => {
288
- window.addEventListener("message", c);
289
- }, []), m(() => () => {
290
- window.removeEventListener("message", c);
291
- }, []), /* @__PURE__ */ r("iframe", { ref: d, className: e.className, src: i() });
280
+ return o(() => {
281
+ window.addEventListener("message", d);
282
+ }, []), o(() => () => {
283
+ window.removeEventListener("message", d);
284
+ }, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: c() });
292
285
  }
293
286
  export {
294
- h as EmbedDirectTemplate,
295
- _ as EmbedSignDocument,
296
- D as unstable_EmbedCreateDocument,
297
- I as unstable_EmbedCreateTemplate,
298
- N as unstable_EmbedMultiSignDocument,
299
- E as unstable_EmbedUpdateDocument,
300
- U as unstable_EmbedUpdateTemplate
287
+ g as EmbedDirectTemplate,
288
+ h as EmbedSignDocument,
289
+ _ as unstable_EmbedCreateDocument,
290
+ D as unstable_EmbedCreateTemplate,
291
+ U as unstable_EmbedMultiSignDocument,
292
+ I as unstable_EmbedUpdateDocument,
293
+ E as unstable_EmbedUpdateTemplate
301
294
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@documenso/embed-preact",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"
@@ -37,7 +37,7 @@
37
37
  "devDependencies": {
38
38
  "@documenso/embed": "*",
39
39
  "@preact/preset-vite": "^2.9.0",
40
- "vite": "^5.4.2",
40
+ "vite": "^7.0.0",
41
41
  "vite-plugin-dts": "^4.1.0"
42
42
  }
43
43
  }