@documenso/embed-solid 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,23 @@
1
+ export type EmbedDirectTemplateProps = {
2
+ className?: string;
3
+ host?: string;
4
+ token: string;
5
+ externalId?: string;
6
+ css?: string | undefined;
7
+ cssVars?: Record<string, string> | undefined;
8
+ email?: string | undefined;
9
+ lockEmail?: boolean | undefined;
10
+ name?: string | undefined;
11
+ lockName?: boolean | undefined;
12
+ onDocumentReady?: () => void;
13
+ onDocumentCompleted?: (data: {
14
+ token: string;
15
+ documentId: number;
16
+ recipientId: number;
17
+ }) => void;
18
+ onDocumentError?: (error: string) => void;
19
+ onFieldSigned?: () => void;
20
+ onFieldUnsigned?: () => void;
21
+ };
22
+ declare function EmbedDirectTemplate(props: EmbedDirectTemplateProps): import("solid-js").JSX.Element;
23
+ 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"});const P=(e,t)=>e===t,D={equals:P};let U=$;const h=1,b=2,W={owned:null,cleanups:null,context:null,owner:null};var a=null;let S=null,j=null,u=null,i=null,f=null,w=0;function x(e,t,s){const n=N(e,t,!1,h);d(n)}function G(e,t,s){U=z;const n=N(e,t,!1,h);n.user=!0,f?f.push(n):d(n)}function C(e,t,s){s=s?Object.assign({},D,s):D;const n=N(e,t,!0,0);return n.observers=null,n.observerSlots=null,n.comparator=s.equals||void 0,d(n),J.bind(n)}function k(e){if(u===null)return e();const t=u;u=null;try{return e()}finally{u=t}}function O(e){G(()=>k(e))}function J(){if(this.sources&&this.state)if(this.state===h)d(this);else{const e=i;i=null,E(()=>v(this)),i=e}if(u){const e=this.observers?this.observers.length:0;u.sources?(u.sources.push(this),u.sourceSlots.push(e)):(u.sources=[this],u.sourceSlots=[e]),this.observers?(this.observers.push(u),this.observerSlots.push(u.sources.length-1)):(this.observers=[u],this.observerSlots=[u.sources.length-1])}return this.value}function V(e,t,s){let n=e.value;return(!e.comparator||!e.comparator(n,t))&&(e.value=t,e.observers&&e.observers.length&&E(()=>{for(let r=0;r<e.observers.length;r+=1){const l=e.observers[r],c=S&&S.running;c&&S.disposed.has(l),(c?!l.tState:!l.state)&&(l.pure?i.push(l):f.push(l),l.observers&&L(l)),c||(l.state=h)}if(i.length>1e6)throw i=[],new Error})),t}function d(e){if(!e.fn)return;y(e);const t=w;H(e,e.value,t)}function H(e,t,s){let n;const r=a,l=u;u=a=e;try{n=e.fn(t)}catch(c){return e.pure&&(e.state=h,e.owned&&e.owned.forEach(y),e.owned=null),e.updatedAt=s+1,T(c)}finally{u=l,a=r}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?V(e,n):e.value=n,e.updatedAt=s)}function N(e,t,s,n=h,r){const l={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:a,context:a?a.context:null,pure:s};return a===null||a!==W&&(a.owned?a.owned.push(l):a.owned=[l]),l}function g(e){if(e.state===0)return;if(e.state===b)return v(e);if(e.suspense&&k(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<w);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===h)d(e);else if(e.state===b){const n=i;i=null,E(()=>v(e,t[0])),i=n}}function E(e,t){if(i)return e();let s=!1;i=[],f?s=!0:f=[],w++;try{const n=e();return Q(s),n}catch(n){s||(f=null),i=null,T(n)}}function Q(e){if(i&&($(i),i=null),e)return;const t=f;f=null,t.length&&E(()=>U(t))}function $(e){for(let t=0;t<e.length;t++)g(e[t])}function z(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:g(n)}for(t=0;t<s;t++)g(e[t])}function v(e,t){e.state=0;for(let s=0;s<e.sources.length;s+=1){const n=e.sources[s];if(n.sources){const r=n.state;r===h?n!==t&&(!n.updatedAt||n.updatedAt<w)&&g(n):r===b&&v(n,t)}}}function L(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=b,s.pure?i.push(s):f.push(s),s.observers&&L(s))}}function y(e){let t;if(e.sources)for(;e.sources.length;){const s=e.sources.pop(),n=e.sourceSlots.pop(),r=s.observers;if(r&&r.length){const l=r.pop(),c=s.observerSlots.pop();n<r.length&&(l.sourceSlots[c]=n,r[n]=l,s.observerSlots[n]=c)}}if(e.owned){for(t=e.owned.length-1;t>=0;t--)y(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function B(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function T(e,t=a){throw B(e)}function M(e,t,s){let n;const r=()=>{const c=document.createElement("template");return c.innerHTML=e,c.content.firstChild},l=()=>(n||(n=r())).cloneNode(!0);return l.cloneNode=l,l}function R(e,t,s){s==null?e.removeAttribute(t):e.setAttribute(t,s)}function F(e,t){t==null?e.removeAttribute("class"):e.className=t}function I(e,t,s){return k(()=>e(t,s))}var K=M("<iframe>");function X(e){const t=C(()=>{const r=e.host||"https://app.documenso.com",l=btoa(JSON.stringify({name:e.name,lockName:e.lockName,email:e.email,lockEmail:e.lockEmail,css:e.css})),c=new URL(`/embed/direct/${e.token}`,r);return e.externalId&&c.searchParams.set("externalId",e.externalId),`${c}#${l}`});function s(r){var l,c,o,m,A;if((n==null?void 0:n.contentWindow)===r.source)switch(r.data.action){case"document-ready":(l=e.onDocumentReady)==null||l.call(e);break;case"document-completed":(c=e.onDocumentCompleted)==null||c.call(e,r.data.data);break;case"document-error":(o=e.onDocumentError)==null||o.call(e,r.data.data);break;case"field-signed":(m=e.onFieldSigned)==null||m.call(e);break;case"field-unsigned":(A=e.onFieldUnsigned)==null||A.call(e);break}}let n;return O(()=>{window.addEventListener("message",s)}),(()=>{var r=K(),l=n;return typeof l=="function"?I(l,r):n=r,x(c=>{var o=e.className,m=t();return o!==c.e&&F(r,c.e=o),m!==c.t&&R(r,"src",c.t=m),c},{e:void 0,t:void 0}),r})()}var Y=M("<iframe>");function Z(e){const t=C(()=>{const r=e.host||"https://app.documenso.com",l=btoa(JSON.stringify({name:e.name,lockName:e.lockName,css:e.css}));return`${new URL(`/embed/sign/${e.token}`,r)}#${l}`});function s(r){var l,c,o;if((n==null?void 0:n.contentWindow)===r.source)switch(r.data.action){case"document-ready":(l=e.onDocumentReady)==null||l.call(e);break;case"document-completed":(c=e.onDocumentCompleted)==null||c.call(e,r.data.data);break;case"document-error":(o=e.onDocumentError)==null||o.call(e,r.data.data);break}}let n;return O(()=>{window.addEventListener("message",s)}),(()=>{var r=Y(),l=n;return typeof l=="function"?I(l,r):n=r,x(c=>{var o=e.className,m=t();return o!==c.e&&F(r,c.e=o),m!==c.t&&R(r,"src",c.t=m),c},{e:void 0,t:void 0}),r})()}exports.EmbedDirectTemplate=X;exports.EmbedSignDocument=Z;
package/dist/index.mjs ADDED
@@ -0,0 +1,291 @@
1
+ const W = (e, t) => e === t, U = {
2
+ equals: W
3
+ };
4
+ let x = L;
5
+ const m = 1, b = 2, G = {
6
+ owned: null,
7
+ cleanups: null,
8
+ context: null,
9
+ owner: null
10
+ };
11
+ var i = null;
12
+ let k = null, J = null, u = null, a = null, f = null, g = 0;
13
+ function D(e, t, s) {
14
+ const n = N(e, t, !1, m);
15
+ d(n);
16
+ }
17
+ function P(e, t, s) {
18
+ x = z;
19
+ const n = N(e, t, !1, m);
20
+ n.user = !0, f ? f.push(n) : d(n);
21
+ }
22
+ function C(e, t, s) {
23
+ s = s ? Object.assign({}, U, s) : U;
24
+ const n = N(e, t, !0, 0);
25
+ return n.observers = null, n.observerSlots = null, n.comparator = s.equals || void 0, d(n), V.bind(n);
26
+ }
27
+ function S(e) {
28
+ if (u === null) return e();
29
+ const t = u;
30
+ u = null;
31
+ try {
32
+ return e();
33
+ } finally {
34
+ u = t;
35
+ }
36
+ }
37
+ function $(e) {
38
+ P(() => S(e));
39
+ }
40
+ function V() {
41
+ if (this.sources && this.state)
42
+ if (this.state === m) d(this);
43
+ else {
44
+ const e = a;
45
+ a = null, E(() => w(this)), a = e;
46
+ }
47
+ if (u) {
48
+ const e = this.observers ? this.observers.length : 0;
49
+ u.sources ? (u.sources.push(this), u.sourceSlots.push(e)) : (u.sources = [this], u.sourceSlots = [e]), this.observers ? (this.observers.push(u), this.observerSlots.push(u.sources.length - 1)) : (this.observers = [u], this.observerSlots = [u.sources.length - 1]);
50
+ }
51
+ return this.value;
52
+ }
53
+ function j(e, t, s) {
54
+ let n = e.value;
55
+ return (!e.comparator || !e.comparator(n, t)) && (e.value = t, e.observers && e.observers.length && E(() => {
56
+ for (let r = 0; r < e.observers.length; r += 1) {
57
+ const l = e.observers[r], c = k && k.running;
58
+ c && k.disposed.has(l), (c ? !l.tState : !l.state) && (l.pure ? a.push(l) : f.push(l), l.observers && O(l)), c || (l.state = m);
59
+ }
60
+ if (a.length > 1e6)
61
+ throw a = [], new Error();
62
+ })), t;
63
+ }
64
+ function d(e) {
65
+ if (!e.fn) return;
66
+ A(e);
67
+ const t = g;
68
+ H(e, e.value, t);
69
+ }
70
+ function H(e, t, s) {
71
+ let n;
72
+ const r = i, l = u;
73
+ u = i = e;
74
+ try {
75
+ n = e.fn(t);
76
+ } catch (c) {
77
+ return e.pure && (e.state = m, e.owned && e.owned.forEach(A), e.owned = null), e.updatedAt = s + 1, R(c);
78
+ } finally {
79
+ u = l, i = r;
80
+ }
81
+ (!e.updatedAt || e.updatedAt <= s) && (e.updatedAt != null && "observers" in e ? j(e, n) : e.value = n, e.updatedAt = s);
82
+ }
83
+ function N(e, t, s, n = m, r) {
84
+ const l = {
85
+ fn: e,
86
+ state: n,
87
+ updatedAt: null,
88
+ owned: null,
89
+ sources: null,
90
+ sourceSlots: null,
91
+ cleanups: null,
92
+ value: t,
93
+ owner: i,
94
+ context: i ? i.context : null,
95
+ pure: s
96
+ };
97
+ return i === null || i !== G && (i.owned ? i.owned.push(l) : i.owned = [l]), l;
98
+ }
99
+ function v(e) {
100
+ if (e.state === 0) return;
101
+ if (e.state === b) return w(e);
102
+ if (e.suspense && S(e.suspense.inFallback)) return e.suspense.effects.push(e);
103
+ const t = [e];
104
+ for (; (e = e.owner) && (!e.updatedAt || e.updatedAt < g); )
105
+ e.state && t.push(e);
106
+ for (let s = t.length - 1; s >= 0; s--)
107
+ if (e = t[s], e.state === m)
108
+ d(e);
109
+ else if (e.state === b) {
110
+ const n = a;
111
+ a = null, E(() => w(e, t[0])), a = n;
112
+ }
113
+ }
114
+ function E(e, t) {
115
+ if (a) return e();
116
+ let s = !1;
117
+ a = [], f ? s = !0 : f = [], g++;
118
+ try {
119
+ const n = e();
120
+ return Q(s), n;
121
+ } catch (n) {
122
+ s || (f = null), a = null, R(n);
123
+ }
124
+ }
125
+ function Q(e) {
126
+ if (a && (L(a), a = null), e) return;
127
+ const t = f;
128
+ f = null, t.length && E(() => x(t));
129
+ }
130
+ function L(e) {
131
+ for (let t = 0; t < e.length; t++) v(e[t]);
132
+ }
133
+ function z(e) {
134
+ let t, s = 0;
135
+ for (t = 0; t < e.length; t++) {
136
+ const n = e[t];
137
+ n.user ? e[s++] = n : v(n);
138
+ }
139
+ for (t = 0; t < s; t++) v(e[t]);
140
+ }
141
+ function w(e, t) {
142
+ e.state = 0;
143
+ for (let s = 0; s < e.sources.length; s += 1) {
144
+ const n = e.sources[s];
145
+ if (n.sources) {
146
+ const r = n.state;
147
+ r === m ? n !== t && (!n.updatedAt || n.updatedAt < g) && v(n) : r === b && w(n, t);
148
+ }
149
+ }
150
+ }
151
+ function O(e) {
152
+ for (let t = 0; t < e.observers.length; t += 1) {
153
+ const s = e.observers[t];
154
+ s.state || (s.state = b, s.pure ? a.push(s) : f.push(s), s.observers && O(s));
155
+ }
156
+ }
157
+ function A(e) {
158
+ let t;
159
+ if (e.sources)
160
+ for (; e.sources.length; ) {
161
+ const s = e.sources.pop(), n = e.sourceSlots.pop(), r = s.observers;
162
+ if (r && r.length) {
163
+ const l = r.pop(), c = s.observerSlots.pop();
164
+ n < r.length && (l.sourceSlots[c] = n, r[n] = l, s.observerSlots[n] = c);
165
+ }
166
+ }
167
+ if (e.owned) {
168
+ for (t = e.owned.length - 1; t >= 0; t--) A(e.owned[t]);
169
+ e.owned = null;
170
+ }
171
+ if (e.cleanups) {
172
+ for (t = e.cleanups.length - 1; t >= 0; t--) e.cleanups[t]();
173
+ e.cleanups = null;
174
+ }
175
+ e.state = 0;
176
+ }
177
+ function B(e) {
178
+ return e instanceof Error ? e : new Error(typeof e == "string" ? e : "Unknown error", {
179
+ cause: e
180
+ });
181
+ }
182
+ function R(e, t = i) {
183
+ throw B(e);
184
+ }
185
+ function T(e, t, s) {
186
+ let n;
187
+ const r = () => {
188
+ const c = document.createElement("template");
189
+ return c.innerHTML = e, c.content.firstChild;
190
+ }, l = () => (n || (n = r())).cloneNode(!0);
191
+ return l.cloneNode = l, l;
192
+ }
193
+ function M(e, t, s) {
194
+ s == null ? e.removeAttribute(t) : e.setAttribute(t, s);
195
+ }
196
+ function F(e, t) {
197
+ t == null ? e.removeAttribute("class") : e.className = t;
198
+ }
199
+ function I(e, t, s) {
200
+ return S(() => e(t, s));
201
+ }
202
+ var K = /* @__PURE__ */ T("<iframe>");
203
+ function Y(e) {
204
+ const t = C(() => {
205
+ const r = e.host || "https://app.documenso.com", l = btoa(JSON.stringify({
206
+ name: e.name,
207
+ lockName: e.lockName,
208
+ email: e.email,
209
+ lockEmail: e.lockEmail,
210
+ css: e.css
211
+ })), c = new URL(`/embed/direct/${e.token}`, r);
212
+ return e.externalId && c.searchParams.set("externalId", e.externalId), `${c}#${l}`;
213
+ });
214
+ function s(r) {
215
+ var l, c, o, h, y;
216
+ if ((n == null ? void 0 : n.contentWindow) === r.source)
217
+ switch (r.data.action) {
218
+ case "document-ready":
219
+ (l = e.onDocumentReady) == null || l.call(e);
220
+ break;
221
+ case "document-completed":
222
+ (c = e.onDocumentCompleted) == null || c.call(e, r.data.data);
223
+ break;
224
+ case "document-error":
225
+ (o = e.onDocumentError) == null || o.call(e, r.data.data);
226
+ break;
227
+ case "field-signed":
228
+ (h = e.onFieldSigned) == null || h.call(e);
229
+ break;
230
+ case "field-unsigned":
231
+ (y = e.onFieldUnsigned) == null || y.call(e);
232
+ break;
233
+ }
234
+ }
235
+ let n;
236
+ return $(() => {
237
+ window.addEventListener("message", s);
238
+ }), (() => {
239
+ var r = K(), l = n;
240
+ return typeof l == "function" ? I(l, r) : n = r, D((c) => {
241
+ var o = e.className, h = t();
242
+ return o !== c.e && F(r, c.e = o), h !== c.t && M(r, "src", c.t = h), c;
243
+ }, {
244
+ e: void 0,
245
+ t: void 0
246
+ }), r;
247
+ })();
248
+ }
249
+ var X = /* @__PURE__ */ T("<iframe>");
250
+ function Z(e) {
251
+ const t = C(() => {
252
+ const r = e.host || "https://app.documenso.com", l = btoa(JSON.stringify({
253
+ name: e.name,
254
+ lockName: e.lockName,
255
+ css: e.css
256
+ }));
257
+ return `${new URL(`/embed/sign/${e.token}`, r)}#${l}`;
258
+ });
259
+ function s(r) {
260
+ var l, c, o;
261
+ if ((n == null ? void 0 : n.contentWindow) === r.source)
262
+ switch (r.data.action) {
263
+ case "document-ready":
264
+ (l = e.onDocumentReady) == null || l.call(e);
265
+ break;
266
+ case "document-completed":
267
+ (c = e.onDocumentCompleted) == null || c.call(e, r.data.data);
268
+ break;
269
+ case "document-error":
270
+ (o = e.onDocumentError) == null || o.call(e, r.data.data);
271
+ break;
272
+ }
273
+ }
274
+ let n;
275
+ return $(() => {
276
+ window.addEventListener("message", s);
277
+ }), (() => {
278
+ var r = X(), l = n;
279
+ return typeof l == "function" ? I(l, r) : n = r, D((c) => {
280
+ var o = e.className, h = t();
281
+ return o !== c.e && F(r, c.e = o), h !== c.t && M(r, "src", c.t = h), c;
282
+ }, {
283
+ e: void 0,
284
+ t: void 0
285
+ }), r;
286
+ })();
287
+ }
288
+ export {
289
+ Y as EmbedDirectTemplate,
290
+ Z as EmbedSignDocument
291
+ };
@@ -0,0 +1,18 @@
1
+ export type EmbedSignDocumentProps = {
2
+ className?: string;
3
+ host?: string;
4
+ token: string;
5
+ css?: string | undefined;
6
+ cssVars?: Record<string, string> | undefined;
7
+ name?: string | undefined;
8
+ lockName?: boolean | undefined;
9
+ onDocumentReady?: () => void;
10
+ onDocumentCompleted?: (data: {
11
+ token: string;
12
+ documentId: number;
13
+ recipientId: number;
14
+ }) => void;
15
+ onDocumentError?: (error: string) => void;
16
+ };
17
+ declare function EmbedSignDocument(props: EmbedSignDocumentProps): import("solid-js").JSX.Element;
18
+ export default EmbedSignDocument;
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@documenso/embed-solid",
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
+ "solid-js": "^1.8.0"
36
+ },
37
+ "devDependencies": {
38
+ "@documenso/embed": "*",
39
+ "vite-plugin-solid": "^2.10.2",
40
+ "vite": "^5.4.2",
41
+ "vite-plugin-dts": "^4.1.0"
42
+ }
43
+ }