@documenso/embed-preact 0.0.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.
@@ -0,0 +1,24 @@
1
+ import { h } from 'preact';
2
+ export type EmbedDirectTemplateProps = {
3
+ className?: string;
4
+ host?: string;
5
+ token: string;
6
+ externalId?: string;
7
+ css?: string | undefined;
8
+ cssVars?: Record<string, string> | undefined;
9
+ email?: string | undefined;
10
+ lockEmail?: boolean | undefined;
11
+ name?: string | undefined;
12
+ lockName?: boolean | undefined;
13
+ onDocumentReady?: () => void;
14
+ onDocumentCompleted?: (data: {
15
+ token: string;
16
+ documentId: number;
17
+ recipientId: number;
18
+ }) => void;
19
+ onDocumentError?: (error: string) => void;
20
+ onFieldSigned?: () => void;
21
+ onFieldUnsigned?: () => void;
22
+ };
23
+ declare function EmbedDirectTemplate(props: EmbedDirectTemplateProps): h.JSX.Element;
24
+ export default EmbedDirectTemplate;
@@ -0,0 +1,2 @@
1
+ export { default as EmbedDirectTemplate } from './direct-template';
2
+ export { default as EmbedSignDocument } from './sign-document';
@@ -0,0 +1,2 @@
1
+ export { default as EmbedDirectTemplate } from './direct-template';
2
+ export { default as EmbedSignDocument } from './sign-document';
package/dist/index.js ADDED
@@ -0,0 +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;
package/dist/index.mjs ADDED
@@ -0,0 +1,180 @@
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
+ }
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
+ });
102
+ }
103
+ function O(e) {
104
+ const _ = T(null);
105
+ function t() {
106
+ const n = e.host || "https://app.documenso.com", o = btoa(
107
+ JSON.stringify({
108
+ name: e.name,
109
+ lockName: e.lockName,
110
+ email: e.email,
111
+ lockEmail: e.lockEmail,
112
+ css: e.css
113
+ })
114
+ ), i = new URL(`/embed/direct/${e.token}`, n);
115
+ return e.externalId && i.searchParams.set("externalId", e.externalId), `${i}#${o}`;
116
+ }
117
+ function a(n) {
118
+ var o, i, u, m, d, g;
119
+ if (((o = _.current) == null ? void 0 : o.contentWindow) === n.source)
120
+ switch (n.data.action) {
121
+ case "document-ready":
122
+ (i = e.onDocumentReady) == null || i.call(e);
123
+ break;
124
+ case "document-completed":
125
+ (u = e.onDocumentCompleted) == null || u.call(e, n.data.data);
126
+ break;
127
+ case "document-error":
128
+ (m = e.onDocumentError) == null || m.call(e, n.data.data);
129
+ break;
130
+ case "field-signed":
131
+ (d = e.onFieldSigned) == null || d.call(e);
132
+ break;
133
+ case "field-unsigned":
134
+ (g = e.onFieldUnsigned) == null || g.call(e);
135
+ break;
136
+ }
137
+ }
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() });
143
+ }
144
+ function R(e) {
145
+ const _ = T(null);
146
+ function t() {
147
+ const n = e.host || "https://app.documenso.com", o = btoa(
148
+ JSON.stringify({
149
+ name: e.name,
150
+ lockName: e.lockName,
151
+ css: e.css
152
+ })
153
+ );
154
+ return `${new URL(`/embed/sign/${e.token}`, n)}#${o}`;
155
+ }
156
+ function a(n) {
157
+ var o, i, u, m;
158
+ if (((o = _.current) == null ? void 0 : o.contentWindow) === n.source)
159
+ switch (n.data.action) {
160
+ case "document-ready":
161
+ (i = e.onDocumentReady) == null || i.call(e);
162
+ break;
163
+ case "document-completed":
164
+ (u = e.onDocumentCompleted) == null || u.call(e, n.data.data);
165
+ break;
166
+ case "document-error":
167
+ (m = e.onDocumentError) == null || m.call(e, n.data.data);
168
+ break;
169
+ }
170
+ }
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() });
176
+ }
177
+ export {
178
+ O as EmbedDirectTemplate,
179
+ R as EmbedSignDocument
180
+ };
@@ -0,0 +1,19 @@
1
+ import { h } from 'preact';
2
+ export type EmbedSignDocumentProps = {
3
+ className?: string;
4
+ host?: string;
5
+ token: string;
6
+ css?: string | undefined;
7
+ cssVars?: Record<string, string> | undefined;
8
+ name?: string | undefined;
9
+ lockName?: boolean | undefined;
10
+ onDocumentReady?: () => void;
11
+ onDocumentCompleted?: (data: {
12
+ token: string;
13
+ documentId: number;
14
+ recipientId: number;
15
+ }) => void;
16
+ onDocumentError?: (error: string) => void;
17
+ };
18
+ declare function EmbedSignDocument(props: EmbedSignDocumentProps): h.JSX.Element;
19
+ export default EmbedSignDocument;
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@documenso/embed-preact",
3
+ "version": "0.0.1",
4
+ "license": "MIT",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "types": "dist/index.d.ts",
9
+ "main": "dist/index.js",
10
+ "module": "dist/index.mjs",
11
+ "exports": {
12
+ "./package.json": "./package.json",
13
+ ".": {
14
+ "import": {
15
+ "types": "./dist/index.d.mts",
16
+ "default": "./dist/index.mjs"
17
+ },
18
+ "require": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ }
22
+ }
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "scripts": {
28
+ "build": "vite build",
29
+ "clean": "rimraf node_modules",
30
+ "check-exports": "attw --pack .",
31
+ "publint": "publint"
32
+ },
33
+ "dependencies": {},
34
+ "peerDependencies": {
35
+ "preact": "^10.0.0"
36
+ },
37
+ "devDependencies": {
38
+ "@documenso/embed": "*",
39
+ "@preact/preset-vite": "^2.9.0",
40
+ "vite": "^5.4.2",
41
+ "vite-plugin-dts": "^4.1.0"
42
+ }
43
+ }