@documenso/embed-preact 0.0.1 → 0.0.2-rc.1

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"});var l;l={__e:function(e,_,t,a){for(var n,o,i;_=_.__;)if((n=_.__c)&&!n.__)try{if((o=n.constructor)&&o.getDerivedStateFromError!=null&&(n.setState(o.getDerivedStateFromError(e)),i=n.__d),n.componentDidCatch!=null&&(n.componentDidCatch(e,a||{}),i=n.__d),i)return n.__E=n}catch(u){e=u}throw e}},typeof Promise=="function"&&Promise.prototype.then.bind(Promise.resolve());var U=0;function $(e,_,t,a,n,o){_||(_={});var i,u,m=_;if("ref"in m)for(u in m={},_)u=="ref"?i=_[u]:m[u]=_[u];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:--U,__i:-1,__u:0,__source:n,__self:o};return l.vnode&&l.vnode(d),d}var h,r,v,k,g=0,T=[],c=l,y=c.__b,H=c.__r,w=c.diffed,D=c.__c,N=c.unmount,S=c.__;function A(e,_){c.__h&&c.__h(r,e,g||_),g=0;var t=r.__H||(r.__H={__:[],__h:[]});return e>=t.__.length&&t.__.push({}),t.__[e]}function s(e,_){var t=A(h++,3);!c.__s&&P(t.__H,_)&&(t.__=e,t.i=_,r.__H.__h.push(t))}function L(e){return g=5,C(function(){return{current:e}},[])}function C(e,_){var t=A(h++,7);return P(t.__H,_)&&(t.__=e(),t.__H=_,t.__h=e),t.__}function O(){for(var e;e=T.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(f),e.__H.__h.forEach(E),e.__H.__h=[]}catch(_){e.__H.__h=[],c.__e(_,e.__v)}}c.__b=function(e){r=null,y&&y(e)},c.__=function(e,_){e&&_.__k&&_.__k.__m&&(e.__m=_.__k.__m),S&&S(e,_)},c.__r=function(e){H&&H(e),h=0;var _=(r=e.__c).__H;_&&(v===r?(_.__h=[],r.__h=[],_.__.forEach(function(t){t.__N&&(t.__=t.__N),t.i=t.__N=void 0})):(_.__h.forEach(f),_.__h.forEach(E),_.__h=[],h=0)),v=r},c.diffed=function(e){w&&w(e);var _=e.__c;_&&_.__H&&(_.__H.__h.length&&(T.push(_)!==1&&k===c.requestAnimationFrame||((k=c.requestAnimationFrame)||q)(O)),_.__H.__.forEach(function(t){t.i&&(t.__H=t.i),t.i=void 0})),v=r=null},c.__c=function(e,_){_.some(function(t){try{t.__h.forEach(f),t.__h=t.__h.filter(function(a){return!a.__||E(a)})}catch(a){_.some(function(n){n.__h&&(n.__h=[])}),_=[],c.__e(a,t.__v)}}),D&&D(e,_)},c.unmount=function(e){N&&N(e);var _,t=e.__c;t&&t.__H&&(t.__H.__.forEach(function(a){try{f(a)}catch(n){_=n}}),t.__H=void 0,_&&c.__e(_,t.__v))};var F=typeof requestAnimationFrame=="function";function q(e){var _,t=function(){clearTimeout(a),F&&cancelAnimationFrame(_),setTimeout(e)},a=setTimeout(t,100);F&&(_=requestAnimationFrame(t))}function f(e){var _=r,t=e.__c;typeof t=="function"&&(e.__c=void 0,t()),r=_}function E(e){var _=r;e.__c=e.__(),r=_}function P(e,_){return!e||e.length!==_.length||_.some(function(t,a){return t!==e[a]})}function R(e){const _=L(null);function t(){const n=e.host||"https://app.documenso.com",o=btoa(JSON.stringify({name:e.name,lockName:e.lockName,email:e.email,lockEmail:e.lockEmail,css:e.css})),i=new URL(`/embed/direct/${e.token}`,n);return e.externalId&&i.searchParams.set("externalId",e.externalId),`${i}#${o}`}function a(n){var o,i,u,m,d,b;if(((o=_.current)==null?void 0:o.contentWindow)===n.source)switch(n.data.action){case"document-ready":(i=e.onDocumentReady)==null||i.call(e);break;case"document-completed":(u=e.onDocumentCompleted)==null||u.call(e,n.data.data);break;case"document-error":(m=e.onDocumentError)==null||m.call(e,n.data.data);break;case"field-signed":(d=e.onFieldSigned)==null||d.call(e);break;case"field-unsigned":(b=e.onFieldUnsigned)==null||b.call(e);break}}return s(()=>{window.addEventListener("message",a)},[]),s(()=>()=>{window.removeEventListener("message",a)},[]),$("iframe",{ref:_,className:e.className,src:t()})}function x(e){const _=L(null);function t(){const n=e.host||"https://app.documenso.com",o=btoa(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css}));return`${new URL(`/embed/sign/${e.token}`,n)}#${o}`}function a(n){var o,i,u,m;if(((o=_.current)==null?void 0:o.contentWindow)===n.source)switch(n.data.action){case"document-ready":(i=e.onDocumentReady)==null||i.call(e);break;case"document-completed":(u=e.onDocumentCompleted)==null||u.call(e,n.data.data);break;case"document-error":(m=e.onDocumentError)==null||m.call(e,n.data.data);break}}return s(()=>{window.addEventListener("message",a)},[]),s(()=>()=>{window.removeEventListener("message",a)},[]),$("iframe",{ref:_,className:e.className,src:t()})}exports.EmbedDirectTemplate=R;exports.EmbedSignDocument=x;
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
- var l;
2
- l = { __e: function(e, _, t, a) {
3
- for (var n, o, i; _ = _.__; ) if ((n = _.__c) && !n.__) try {
4
- if ((o = n.constructor) && o.getDerivedStateFromError != null && (n.setState(o.getDerivedStateFromError(e)), i = n.__d), n.componentDidCatch != null && (n.componentDidCatch(e, a || {}), i = n.__d), i) return n.__E = n;
5
- } catch (u) {
6
- e = u;
7
- }
8
- throw e;
9
- } }, typeof Promise == "function" && Promise.prototype.then.bind(Promise.resolve());
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
- }
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;
43
10
  }
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
- });
102
- }
103
- function O(e) {
104
- const _ = T(null);
105
- function t() {
106
- const n = e.host || "https://app.documenso.com", o = btoa(
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
- ), i = new URL(`/embed/direct/${e.token}`, n);
115
- return e.externalId && i.searchParams.set("externalId", e.externalId), `${i}#${o}`;
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 a(n) {
118
- var o, i, u, m, d, g;
119
- if (((o = _.current) == null ? void 0 : o.contentWindow) === n.source)
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
- (i = e.onDocumentReady) == null || i.call(e);
30
+ (t = e.onDocumentReady) == null || t.call(e);
123
31
  break;
124
32
  case "document-completed":
125
- (u = e.onDocumentCompleted) == null || u.call(e, n.data.data);
33
+ (d = e.onDocumentCompleted) == null || d.call(e, n.data.data);
126
34
  break;
127
35
  case "document-error":
128
- (m = e.onDocumentError) == null || m.call(e, n.data.data);
36
+ (i = e.onDocumentError) == null || i.call(e, n.data.data);
129
37
  break;
130
38
  case "field-signed":
131
- (d = e.onFieldSigned) == null || d.call(e);
39
+ (l = e.onFieldSigned) == null || l.call(e);
132
40
  break;
133
41
  case "field-unsigned":
134
- (g = e.onFieldUnsigned) == null || g.call(e);
42
+ (r = e.onFieldUnsigned) == null || r.call(e);
135
43
  break;
136
44
  }
137
45
  }
138
- return s(() => {
139
- window.addEventListener("message", a);
140
- }, []), s(() => () => {
141
- window.removeEventListener("message", a);
142
- }, []), /* @__PURE__ */ S("iframe", { ref: _, className: e.className, src: t() });
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 R(e) {
145
- const _ = T(null);
146
- function t() {
147
- const n = e.host || "https://app.documenso.com", o = btoa(
52
+ function E(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)}#${o}`;
62
+ return `${new URL(`/embed/sign/${e.token}`, n)}#${c}`;
155
63
  }
156
- function a(n) {
157
- var o, i, u, m;
158
- if (((o = _.current) == null ? void 0 : o.contentWindow) === n.source)
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
- (i = e.onDocumentReady) == null || i.call(e);
69
+ (t = e.onDocumentReady) == null || t.call(e);
162
70
  break;
163
71
  case "document-completed":
164
- (u = e.onDocumentCompleted) == null || u.call(e, n.data.data);
72
+ (d = e.onDocumentCompleted) == null || d.call(e, n.data.data);
165
73
  break;
166
74
  case "document-error":
167
- (m = e.onDocumentError) == null || m.call(e, n.data.data);
75
+ (i = e.onDocumentError) == null || i.call(e, n.data.data);
168
76
  break;
169
77
  }
170
78
  }
171
- return s(() => {
172
- window.addEventListener("message", a);
173
- }, []), s(() => () => {
174
- window.removeEventListener("message", a);
175
- }, []), /* @__PURE__ */ S("iframe", { ref: _, className: e.className, src: t() });
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
- O as EmbedDirectTemplate,
179
- R as EmbedSignDocument
86
+ w as EmbedDirectTemplate,
87
+ E as EmbedSignDocument
180
88
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@documenso/embed-preact",
3
- "version": "0.0.1",
3
+ "version": "0.0.2-rc.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "scripts": {
28
28
  "build": "vite build",
29
- "clean": "rimraf node_modules",
29
+ "clean": "rimraf node_modules && rimraf src",
30
30
  "check-exports": "attw --pack .",
31
31
  "publint": "publint"
32
32
  },