@documenso/embed-preact 0.0.1 → 0.0.2-rc.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 +1 -1
- package/dist/index.mjs +46 -138
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("preact"),u=require("preact/hooks");var _=0;function f(e,t,o,m,n,c){t||(t={});var a,d,i=t;if("ref"in i)for(d in i={},t)d=="ref"?a=t[d]:i[d]=t[d];var l={type:e,props:i,key:o,ref:a,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--_,__i:-1,__u:0,__source:n,__self:c};return r.options.vnode&&r.options.vnode(l),l}function b(e){const t=u.useRef(null);function o(){const n=e.host||"https://app.documenso.com",c=btoa(JSON.stringify({name:e.name,lockName:e.lockName,email:e.email,lockEmail:e.lockEmail,css:e.css})),a=new URL(`/embed/direct/${e.token}`,n);return e.externalId&&a.searchParams.set("externalId",e.externalId),`${a}#${c}`}function m(n){var c,a,d,i,l,s;if(((c=t.current)==null?void 0:c.contentWindow)===n.source)switch(n.data.action){case"document-ready":(a=e.onDocumentReady)==null||a.call(e);break;case"document-completed":(d=e.onDocumentCompleted)==null||d.call(e,n.data.data);break;case"document-error":(i=e.onDocumentError)==null||i.call(e,n.data.data);break;case"field-signed":(l=e.onFieldSigned)==null||l.call(e);break;case"field-unsigned":(s=e.onFieldUnsigned)==null||s.call(e);break}}return u.useEffect(()=>{window.addEventListener("message",m)},[]),u.useEffect(()=>()=>{window.removeEventListener("message",m)},[]),f("iframe",{ref:t,className:e.className,src:o()})}function k(e){const t=u.useRef(null);function o(){const n=e.host||"https://app.documenso.com",c=btoa(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css}));return`${new URL(`/embed/sign/${e.token}`,n)}#${c}`}function m(n){var c,a,d,i;if(((c=t.current)==null?void 0:c.contentWindow)===n.source)switch(n.data.action){case"document-ready":(a=e.onDocumentReady)==null||a.call(e);break;case"document-completed":(d=e.onDocumentCompleted)==null||d.call(e,n.data.data);break;case"document-error":(i=e.onDocumentError)==null||i.call(e,n.data.data);break}}return u.useEffect(()=>{window.addEventListener("message",m)},[]),u.useEffect(()=>()=>{window.removeEventListener("message",m)},[]),f("iframe",{ref:t,className:e.className,src:o()})}exports.EmbedDirectTemplate=b;exports.EmbedSignDocument=k;
|
package/dist/index.mjs
CHANGED
|
@@ -1,109 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var C = 0;
|
|
11
|
-
function S(e, _, t, a, n, o) {
|
|
12
|
-
_ || (_ = {});
|
|
13
|
-
var i, u, m = _;
|
|
14
|
-
if ("ref" in m) for (u in m = {}, _) u == "ref" ? i = _[u] : m[u] = _[u];
|
|
15
|
-
var d = { type: e, props: m, key: t, ref: i, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --C, __i: -1, __u: 0, __source: n, __self: o };
|
|
16
|
-
return l.vnode && l.vnode(d), d;
|
|
17
|
-
}
|
|
18
|
-
var h, r, v, H, k = 0, A = [], c = l, b = c.__b, y = c.__r, w = c.diffed, N = c.__c, D = c.unmount, F = c.__;
|
|
19
|
-
function L(e, _) {
|
|
20
|
-
c.__h && c.__h(r, e, k || _), k = 0;
|
|
21
|
-
var t = r.__H || (r.__H = { __: [], __h: [] });
|
|
22
|
-
return e >= t.__.length && t.__.push({}), t.__[e];
|
|
23
|
-
}
|
|
24
|
-
function s(e, _) {
|
|
25
|
-
var t = L(h++, 3);
|
|
26
|
-
!c.__s && U(t.__H, _) && (t.__ = e, t.i = _, r.__H.__h.push(t));
|
|
27
|
-
}
|
|
28
|
-
function T(e) {
|
|
29
|
-
return k = 5, P(function() {
|
|
30
|
-
return { current: e };
|
|
31
|
-
}, []);
|
|
32
|
-
}
|
|
33
|
-
function P(e, _) {
|
|
34
|
-
var t = L(h++, 7);
|
|
35
|
-
return U(t.__H, _) && (t.__ = e(), t.__H = _, t.__h = e), t.__;
|
|
36
|
-
}
|
|
37
|
-
function q() {
|
|
38
|
-
for (var e; e = A.shift(); ) if (e.__P && e.__H) try {
|
|
39
|
-
e.__H.__h.forEach(f), e.__H.__h.forEach(E), e.__H.__h = [];
|
|
40
|
-
} catch (_) {
|
|
41
|
-
e.__H.__h = [], c.__e(_, e.__v);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
c.__b = function(e) {
|
|
45
|
-
r = null, b && b(e);
|
|
46
|
-
}, c.__ = function(e, _) {
|
|
47
|
-
e && _.__k && _.__k.__m && (e.__m = _.__k.__m), F && F(e, _);
|
|
48
|
-
}, c.__r = function(e) {
|
|
49
|
-
y && y(e), h = 0;
|
|
50
|
-
var _ = (r = e.__c).__H;
|
|
51
|
-
_ && (v === r ? (_.__h = [], r.__h = [], _.__.forEach(function(t) {
|
|
52
|
-
t.__N && (t.__ = t.__N), t.i = t.__N = void 0;
|
|
53
|
-
})) : (_.__h.forEach(f), _.__h.forEach(E), _.__h = [], h = 0)), v = r;
|
|
54
|
-
}, c.diffed = function(e) {
|
|
55
|
-
w && w(e);
|
|
56
|
-
var _ = e.__c;
|
|
57
|
-
_ && _.__H && (_.__H.__h.length && (A.push(_) !== 1 && H === c.requestAnimationFrame || ((H = c.requestAnimationFrame) || x)(q)), _.__H.__.forEach(function(t) {
|
|
58
|
-
t.i && (t.__H = t.i), t.i = void 0;
|
|
59
|
-
})), v = r = null;
|
|
60
|
-
}, c.__c = function(e, _) {
|
|
61
|
-
_.some(function(t) {
|
|
62
|
-
try {
|
|
63
|
-
t.__h.forEach(f), t.__h = t.__h.filter(function(a) {
|
|
64
|
-
return !a.__ || E(a);
|
|
65
|
-
});
|
|
66
|
-
} catch (a) {
|
|
67
|
-
_.some(function(n) {
|
|
68
|
-
n.__h && (n.__h = []);
|
|
69
|
-
}), _ = [], c.__e(a, t.__v);
|
|
70
|
-
}
|
|
71
|
-
}), N && N(e, _);
|
|
72
|
-
}, c.unmount = function(e) {
|
|
73
|
-
D && D(e);
|
|
74
|
-
var _, t = e.__c;
|
|
75
|
-
t && t.__H && (t.__H.__.forEach(function(a) {
|
|
76
|
-
try {
|
|
77
|
-
f(a);
|
|
78
|
-
} catch (n) {
|
|
79
|
-
_ = n;
|
|
80
|
-
}
|
|
81
|
-
}), t.__H = void 0, _ && c.__e(_, t.__v));
|
|
82
|
-
};
|
|
83
|
-
var $ = typeof requestAnimationFrame == "function";
|
|
84
|
-
function x(e) {
|
|
85
|
-
var _, t = function() {
|
|
86
|
-
clearTimeout(a), $ && cancelAnimationFrame(_), setTimeout(e);
|
|
87
|
-
}, a = setTimeout(t, 100);
|
|
88
|
-
$ && (_ = requestAnimationFrame(t));
|
|
89
|
-
}
|
|
90
|
-
function f(e) {
|
|
91
|
-
var _ = r, t = e.__c;
|
|
92
|
-
typeof t == "function" && (e.__c = void 0, t()), r = _;
|
|
93
|
-
}
|
|
94
|
-
function E(e) {
|
|
95
|
-
var _ = r;
|
|
96
|
-
e.__c = e.__(), r = _;
|
|
97
|
-
}
|
|
98
|
-
function U(e, _) {
|
|
99
|
-
return !e || e.length !== _.length || _.some(function(t, a) {
|
|
100
|
-
return t !== e[a];
|
|
101
|
-
});
|
|
1
|
+
import { options as f } from "preact";
|
|
2
|
+
import { useRef as s, useEffect as o } from "preact/hooks";
|
|
3
|
+
var k = 0;
|
|
4
|
+
function _(e, a, u, m, n, c) {
|
|
5
|
+
a || (a = {});
|
|
6
|
+
var t, d, i = a;
|
|
7
|
+
if ("ref" in i) for (d in i = {}, a) d == "ref" ? t = a[d] : i[d] = a[d];
|
|
8
|
+
var l = { type: e, props: i, key: u, ref: t, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --k, __i: -1, __u: 0, __source: n, __self: c };
|
|
9
|
+
return f.vnode && f.vnode(l), l;
|
|
102
10
|
}
|
|
103
|
-
function
|
|
104
|
-
const
|
|
105
|
-
function
|
|
106
|
-
const n = e.host || "https://app.documenso.com",
|
|
11
|
+
function w(e) {
|
|
12
|
+
const a = s(null);
|
|
13
|
+
function u() {
|
|
14
|
+
const n = e.host || "https://app.documenso.com", c = btoa(
|
|
107
15
|
JSON.stringify({
|
|
108
16
|
name: e.name,
|
|
109
17
|
lockName: e.lockName,
|
|
@@ -111,70 +19,70 @@ function O(e) {
|
|
|
111
19
|
lockEmail: e.lockEmail,
|
|
112
20
|
css: e.css
|
|
113
21
|
})
|
|
114
|
-
),
|
|
115
|
-
return e.externalId &&
|
|
22
|
+
), t = new URL(`/embed/direct/${e.token}`, n);
|
|
23
|
+
return e.externalId && t.searchParams.set("externalId", e.externalId), `${t}#${c}`;
|
|
116
24
|
}
|
|
117
|
-
function
|
|
118
|
-
var
|
|
119
|
-
if (((
|
|
25
|
+
function m(n) {
|
|
26
|
+
var c, t, d, i, l, r;
|
|
27
|
+
if (((c = a.current) == null ? void 0 : c.contentWindow) === n.source)
|
|
120
28
|
switch (n.data.action) {
|
|
121
29
|
case "document-ready":
|
|
122
|
-
(
|
|
30
|
+
(t = e.onDocumentReady) == null || t.call(e);
|
|
123
31
|
break;
|
|
124
32
|
case "document-completed":
|
|
125
|
-
(
|
|
33
|
+
(d = e.onDocumentCompleted) == null || d.call(e, n.data.data);
|
|
126
34
|
break;
|
|
127
35
|
case "document-error":
|
|
128
|
-
(
|
|
36
|
+
(i = e.onDocumentError) == null || i.call(e, n.data.data);
|
|
129
37
|
break;
|
|
130
38
|
case "field-signed":
|
|
131
|
-
(
|
|
39
|
+
(l = e.onFieldSigned) == null || l.call(e);
|
|
132
40
|
break;
|
|
133
41
|
case "field-unsigned":
|
|
134
|
-
(
|
|
42
|
+
(r = e.onFieldUnsigned) == null || r.call(e);
|
|
135
43
|
break;
|
|
136
44
|
}
|
|
137
45
|
}
|
|
138
|
-
return
|
|
139
|
-
window.addEventListener("message",
|
|
140
|
-
}, []),
|
|
141
|
-
window.removeEventListener("message",
|
|
142
|
-
}, []), /* @__PURE__ */
|
|
46
|
+
return o(() => {
|
|
47
|
+
window.addEventListener("message", m);
|
|
48
|
+
}, []), o(() => () => {
|
|
49
|
+
window.removeEventListener("message", m);
|
|
50
|
+
}, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src: u() });
|
|
143
51
|
}
|
|
144
|
-
function
|
|
145
|
-
const
|
|
146
|
-
function
|
|
147
|
-
const n = e.host || "https://app.documenso.com",
|
|
52
|
+
function h(e) {
|
|
53
|
+
const a = s(null);
|
|
54
|
+
function u() {
|
|
55
|
+
const n = e.host || "https://app.documenso.com", c = btoa(
|
|
148
56
|
JSON.stringify({
|
|
149
57
|
name: e.name,
|
|
150
58
|
lockName: e.lockName,
|
|
151
59
|
css: e.css
|
|
152
60
|
})
|
|
153
61
|
);
|
|
154
|
-
return `${new URL(`/embed/sign/${e.token}`, n)}#${
|
|
62
|
+
return `${new URL(`/embed/sign/${e.token}`, n)}#${c}`;
|
|
155
63
|
}
|
|
156
|
-
function
|
|
157
|
-
var
|
|
158
|
-
if (((
|
|
64
|
+
function m(n) {
|
|
65
|
+
var c, t, d, i;
|
|
66
|
+
if (((c = a.current) == null ? void 0 : c.contentWindow) === n.source)
|
|
159
67
|
switch (n.data.action) {
|
|
160
68
|
case "document-ready":
|
|
161
|
-
(
|
|
69
|
+
(t = e.onDocumentReady) == null || t.call(e);
|
|
162
70
|
break;
|
|
163
71
|
case "document-completed":
|
|
164
|
-
(
|
|
72
|
+
(d = e.onDocumentCompleted) == null || d.call(e, n.data.data);
|
|
165
73
|
break;
|
|
166
74
|
case "document-error":
|
|
167
|
-
(
|
|
75
|
+
(i = e.onDocumentError) == null || i.call(e, n.data.data);
|
|
168
76
|
break;
|
|
169
77
|
}
|
|
170
78
|
}
|
|
171
|
-
return
|
|
172
|
-
window.addEventListener("message",
|
|
173
|
-
}, []),
|
|
174
|
-
window.removeEventListener("message",
|
|
175
|
-
}, []), /* @__PURE__ */
|
|
79
|
+
return o(() => {
|
|
80
|
+
window.addEventListener("message", m);
|
|
81
|
+
}, []), o(() => () => {
|
|
82
|
+
window.removeEventListener("message", m);
|
|
83
|
+
}, []), /* @__PURE__ */ _("iframe", { ref: a, className: e.className, src: u() });
|
|
176
84
|
}
|
|
177
85
|
export {
|
|
178
|
-
|
|
179
|
-
|
|
86
|
+
w as EmbedDirectTemplate,
|
|
87
|
+
h as EmbedSignDocument
|
|
180
88
|
};
|