@documenso/embed-preact 0.4.0 → 0.5.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 +1 -1
- package/dist/index.mjs +23 -43
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("preact"),s=require("preact/hooks");var g=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,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("preact"),s=require("preact/hooks");var g=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,__c:null,constructor:void 0,__v:--g,__i:-1,__u:0,__source:t,__self:o};return l.options.vnode&&l.options.vnode(u),u}function w(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 h(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 f(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){a.current?.contentWindow===t.source&&t.data.type==="document-created"&&e.onDocumentCreated?.({documentId:t.data.documentId,externalId:t.data.externalId})}return s.useEffect(()=>{window.addEventListener("message",c)},[]),s.useEffect(()=>()=>{window.removeEventListener("message",c)},[]),i("iframe",{ref:a,className:e.className,src:d()})}function b(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){a.current?.contentWindow===t.source&&t.data.type==="template-created"&&e.onTemplateCreated?.({templateId:t.data.templateId,externalId:t.data.externalId})}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({token:e.presignToken,externalId:e.externalId,features:e.features,css:e.css,cssVars:e.cssVars,darkModeDisabled:e.darkModeDisabled,onlyEditFields:e.onlyEditFields,...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){a.current?.contentWindow===t.source&&t.data.type==="document-updated"&&e.onDocumentUpdated?.({documentId:t.data.documentId,externalId:t.data.externalId})}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,onlyEditFields:e.onlyEditFields,...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){a.current?.contentWindow===t.source&&t.data.type==="template-updated"&&e.onTemplateUpdated?.({templateId:t.data.templateId,externalId:t.data.externalId})}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.EmbedCreateDocumentV1=f;exports.EmbedCreateTemplateV1=b;exports.EmbedDirectTemplate=w;exports.EmbedSignDocument=h;exports.EmbedUpdateDocumentV1=k;exports.EmbedUpdateTemplateV1=E;exports.unstable_EmbedCreateDocument=f;exports.unstable_EmbedCreateTemplate=b;exports.unstable_EmbedMultiSignDocument=D;exports.unstable_EmbedUpdateDocument=k;exports.unstable_EmbedUpdateTemplate=E;
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ function m(e, t, s, d, a, c) {
|
|
|
5
5
|
t || (t = {});
|
|
6
6
|
var n, r, l = t;
|
|
7
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: s, ref: n, __k: null, __: null, __b: 0, __e: null,
|
|
8
|
+
var u = { type: e, props: l, key: s, ref: n, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --b, __i: -1, __u: 0, __source: a, __self: c };
|
|
9
9
|
return f.vnode && f.vnode(u), u;
|
|
10
10
|
}
|
|
11
11
|
function g(e) {
|
|
@@ -112,15 +112,10 @@ function D(e) {
|
|
|
112
112
|
return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
|
|
113
113
|
}
|
|
114
114
|
function d(a) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
documentId: a.data.documentId,
|
|
120
|
-
externalId: a.data.externalId
|
|
121
|
-
});
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
115
|
+
t.current?.contentWindow === a.source && a.data.type === "document-created" && e.onDocumentCreated?.({
|
|
116
|
+
documentId: a.data.documentId,
|
|
117
|
+
externalId: a.data.externalId
|
|
118
|
+
});
|
|
124
119
|
}
|
|
125
120
|
return o(() => {
|
|
126
121
|
window.addEventListener("message", d);
|
|
@@ -128,7 +123,7 @@ function D(e) {
|
|
|
128
123
|
window.removeEventListener("message", d);
|
|
129
124
|
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
130
125
|
}
|
|
131
|
-
function
|
|
126
|
+
function E(e) {
|
|
132
127
|
const t = i(null);
|
|
133
128
|
function s() {
|
|
134
129
|
const a = e.host || "https://app.documenso.com", c = btoa(
|
|
@@ -146,15 +141,10 @@ function _(e) {
|
|
|
146
141
|
return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
|
|
147
142
|
}
|
|
148
143
|
function d(a) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
templateId: a.data.templateId,
|
|
154
|
-
externalId: a.data.externalId
|
|
155
|
-
});
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
144
|
+
t.current?.contentWindow === a.source && a.data.type === "template-created" && e.onTemplateCreated?.({
|
|
145
|
+
templateId: a.data.templateId,
|
|
146
|
+
externalId: a.data.externalId
|
|
147
|
+
});
|
|
158
148
|
}
|
|
159
149
|
return o(() => {
|
|
160
150
|
window.addEventListener("message", d);
|
|
@@ -162,7 +152,7 @@ function _(e) {
|
|
|
162
152
|
window.removeEventListener("message", d);
|
|
163
153
|
}, []), /* @__PURE__ */ m("iframe", { ref: t, className: e.className, src: s() });
|
|
164
154
|
}
|
|
165
|
-
function
|
|
155
|
+
function _(e) {
|
|
166
156
|
const t = i(null);
|
|
167
157
|
function s() {
|
|
168
158
|
const a = e.host || "https://app.documenso.com", c = btoa(
|
|
@@ -185,15 +175,10 @@ function E(e) {
|
|
|
185
175
|
return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
|
|
186
176
|
}
|
|
187
177
|
function d(a) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
documentId: a.data.documentId,
|
|
193
|
-
externalId: a.data.externalId
|
|
194
|
-
});
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
178
|
+
t.current?.contentWindow === a.source && a.data.type === "document-updated" && e.onDocumentUpdated?.({
|
|
179
|
+
documentId: a.data.documentId,
|
|
180
|
+
externalId: a.data.externalId
|
|
181
|
+
});
|
|
197
182
|
}
|
|
198
183
|
return o(() => {
|
|
199
184
|
window.addEventListener("message", d);
|
|
@@ -223,15 +208,10 @@ function I(e) {
|
|
|
223
208
|
return n.searchParams.set("token", e.presignToken), n.hash = c, n.toString();
|
|
224
209
|
}
|
|
225
210
|
function d(a) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
templateId: a.data.templateId,
|
|
231
|
-
externalId: a.data.externalId
|
|
232
|
-
});
|
|
233
|
-
break;
|
|
234
|
-
}
|
|
211
|
+
t.current?.contentWindow === a.source && a.data.type === "template-updated" && e.onTemplateUpdated?.({
|
|
212
|
+
templateId: a.data.templateId,
|
|
213
|
+
externalId: a.data.externalId
|
|
214
|
+
});
|
|
235
215
|
}
|
|
236
216
|
return o(() => {
|
|
237
217
|
window.addEventListener("message", d);
|
|
@@ -287,14 +267,14 @@ function U(e) {
|
|
|
287
267
|
}
|
|
288
268
|
export {
|
|
289
269
|
D as EmbedCreateDocumentV1,
|
|
290
|
-
|
|
270
|
+
E as EmbedCreateTemplateV1,
|
|
291
271
|
g as EmbedDirectTemplate,
|
|
292
272
|
h as EmbedSignDocument,
|
|
293
|
-
|
|
273
|
+
_ as EmbedUpdateDocumentV1,
|
|
294
274
|
I as EmbedUpdateTemplateV1,
|
|
295
275
|
D as unstable_EmbedCreateDocument,
|
|
296
|
-
|
|
276
|
+
E as unstable_EmbedCreateTemplate,
|
|
297
277
|
U as unstable_EmbedMultiSignDocument,
|
|
298
|
-
|
|
278
|
+
_ as unstable_EmbedUpdateDocument,
|
|
299
279
|
I as unstable_EmbedUpdateTemplate
|
|
300
280
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@documenso/embed-preact",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@documenso/embed": "*",
|
|
39
|
-
"@preact/preset-vite": "^2.
|
|
39
|
+
"@preact/preset-vite": "^2.0.0",
|
|
40
40
|
"vite": "^7.0.0",
|
|
41
|
-
"vite-plugin-dts": "^4.
|
|
41
|
+
"vite-plugin-dts": "^4.0.0"
|
|
42
42
|
}
|
|
43
43
|
}
|