@aoexl/sign-svelte 1.0.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/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # @aoexl/sign-svelte
2
+
3
+ Svelte 4 integration for the [Aoexl Sign](https://aoexl.com) PDF eSignature SDK.
4
+
5
+ ---
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @aoexl/sign-svelte @aoexl/sign
11
+ # peer dep
12
+ npm install svelte
13
+ ```
14
+
15
+ ---
16
+
17
+ ## Quick start
18
+
19
+ ```svelte
20
+ <script>
21
+ import AoexlSign from '@aoexl/sign-svelte'
22
+
23
+ const signers = [{ name: 'Jane Doe', email: 'jane@example.com', role: 'signer' }]
24
+
25
+ function handleComplete(event) {
26
+ const { signedPdfBytes, fields } = event.detail
27
+ console.log('Signing complete', fields)
28
+ // upload signedPdfBytes to your server
29
+ }
30
+
31
+ function handleError(event) {
32
+ console.error('Signing error', event.detail)
33
+ }
34
+ </script>
35
+
36
+ <AoexlSign
37
+ licenseKey="pk_live_xxxxxxxxxxxx"
38
+ pdfUrl="https://your-server.com/contract.pdf"
39
+ mode="sign"
40
+ {signers}
41
+ on:complete={handleComplete}
42
+ on:error={handleError}
43
+ style="display:block;height:700px;"
44
+ />
45
+ ```
46
+
47
+ ---
48
+
49
+ ## Props
50
+
51
+ | Prop | Type | Default | Description |
52
+ |------|------|---------|-------------|
53
+ | `licenseKey` | `string` | — | **Required.** Your Aoexl license key. |
54
+ | `pdfUrl` | `string` | — | **Required.** URL or data-URL of the PDF. |
55
+ | `mode` | `'prepare' \| 'sign' \| 'view'` | `'sign'` | Viewer mode. |
56
+ | `signers` | `Signer[]` | `[]` | Signer definitions. |
57
+ | `fields` | `Field[]` | `[]` | Pre-placed fields (required in `sign`/`view` mode). |
58
+ | `theme` | `{ primary?: string; accent?: string }` | `{}` | Color overrides. |
59
+ | `workerSrc` | `string` | — | Custom PDF.js worker URL. |
60
+
61
+ ## Events
62
+
63
+ | Event | `event.detail` type | Description |
64
+ |-------|---------------------|-------------|
65
+ | `complete` | `CompleteResult` | Fired when the user finishes signing / preparing. |
66
+ | `error` | `Error` | Fired on any error (license, PDF load, etc.). |
67
+
68
+ ---
69
+
70
+ ## Modes
71
+
72
+ | Mode | Description |
73
+ |------|-------------|
74
+ | `prepare` | Drag and drop fields onto the PDF; emits `complete` with the field layout and signer list. |
75
+ | `sign` | Present pre-placed fields for the signer to fill and sign. |
76
+ | `view` | Read-only rendering of a signed PDF. |
77
+
78
+ ---
79
+
80
+ ## Prepare mode example
81
+
82
+ ```svelte
83
+ <script>
84
+ import AoexlSign from '@aoexl/sign-svelte'
85
+
86
+ let preparedFields = []
87
+ let preparedSigners = []
88
+
89
+ function handleComplete(event) {
90
+ preparedFields = event.detail.fields
91
+ preparedSigners = event.detail.signers
92
+ // Save to your backend and send signing invitations
93
+ }
94
+ </script>
95
+
96
+ <AoexlSign
97
+ licenseKey="pk_live_xxxxxxxxxxxx"
98
+ pdfUrl="https://your-server.com/blank-contract.pdf"
99
+ mode="prepare"
100
+ on:complete={handleComplete}
101
+ on:error={(e) => console.error(e.detail)}
102
+ style="display:block;height:700px;"
103
+ />
104
+ ```
105
+
106
+ ---
107
+
108
+ ## TypeScript
109
+
110
+ ```ts
111
+ import type { AoexlSignProps, AoexlSignEvents, Field, Signer, CompleteResult } from '@aoexl/sign-svelte'
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Building
117
+
118
+ ```bash
119
+ npm run build # outputs dist/aoexl-sign-svelte.js (ESM) + dist/aoexl-sign-svelte.cjs (CJS)
120
+ ```
121
+
122
+ ---
123
+
124
+ ## License
125
+
126
+ UNLICENSED — contact [Aoexl](https://aoexl.com) for a commercial license.
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("svelte/internal"),g=require("svelte"),v=require("@aoexl/sign"),x="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(x);function S(o){let e;return{c(){e=t.element("div"),e.textContent="Activating Aoexl Sign…",t.set_style(e,"position","absolute"),t.set_style(e,"inset","0"),t.set_style(e,"display","flex"),t.set_style(e,"align-items","center"),t.set_style(e,"justify-content","center"),t.set_style(e,"background","#F8FAFC"),t.set_style(e,"font-family","system-ui,sans-serif"),t.set_style(e,"color","#64748B"),t.set_style(e,"font-size","14px"),t.set_style(e,"z-index","10")},m(l,s){t.insert(l,e,s)},d(l){l&&t.detach(e)}}}function A(o){let e,l,s,i=o[1]&&S();return{c(){e=t.element("div"),i&&i.c(),l=t.space(),s=t.element("div"),t.set_style(s,"width","100%"),t.set_style(s,"height","100%"),t.set_style(e,"position","relative"),t.set_style(e,"width","100%"),t.set_style(e,"height","100%")},m(r,c){t.insert(r,e,c),i&&i.m(e,null),t.append(e,l),t.append(e,s),o[9](s)},p(r,[c]){r[1]?i||(i=S(),i.c(),i.m(e,l)):i&&(i.d(1),i=null)},i:t.noop,o:t.noop,d(r){r&&t.detach(e),i&&i.d(),o[9](null)}}}function C(o,e,l){let{licenseKey:s}=e,{pdfUrl:i}=e,{mode:r="sign"}=e,{signers:c=[]}=e,{fields:u=[]}=e,{theme:y={}}=e,{workerSrc:_=void 0}=e;const m=g.createEventDispatcher();let f,d=null,a=!1;async function h(){if(!(!f||!s||!i)){l(1,a=!0);try{d=await v.init({licenseKey:s,container:f,pdfUrl:i,mode:r,signers:c,fields:u,theme:y,workerSrc:_,onComplete:n=>m("complete",n),onError:n=>m("error",n)})}catch(n){m("error",n)}finally{l(1,a=!1)}}}function w(){d==null||d.destroy(),d=null}g.onMount(h),g.onDestroy(w);function k(n){t.binding_callbacks[n?"unshift":"push"](()=>{f=n,l(0,f)})}return o.$$set=n=>{"licenseKey"in n&&l(2,s=n.licenseKey),"pdfUrl"in n&&l(3,i=n.pdfUrl),"mode"in n&&l(4,r=n.mode),"signers"in n&&l(5,c=n.signers),"fields"in n&&l(6,u=n.fields),"theme"in n&&l(7,y=n.theme),"workerSrc"in n&&l(8,_=n.workerSrc)},o.$$.update=()=>{o.$$.dirty&28&&(s||i||r)&&(w(),h())},[f,a,s,i,r,c,u,y,_,k]}class b extends t.SvelteComponent{constructor(e){super(),t.init(this,e,C,A,t.safe_not_equal,{licenseKey:2,pdfUrl:3,mode:4,signers:5,fields:6,theme:7,workerSrc:8})}}exports.AoexlSign=b;exports.default=b;
2
+ //# sourceMappingURL=aoexl-sign-svelte.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aoexl-sign-svelte.cjs","sources":["../../../../node_modules/svelte/src/shared/version.js","../../../../node_modules/svelte/src/runtime/internal/disclose-version/index.js","../src/AoexlSign.svelte"],"sourcesContent":["// generated during release, do not modify\n\n/**\n * The current version, as set in package.json.\n *\n * https://svelte.dev/docs/svelte-compiler#svelte-version\n * @type {string}\n */\nexport const VERSION = '4.2.20';\nexport const PUBLIC_VERSION = '4';\n","import { PUBLIC_VERSION } from '../../../shared/version.js';\n\nif (typeof window !== 'undefined')\n\t// @ts-ignore\n\t(window.__svelte || (window.__svelte = { v: new Set() })).v.add(PUBLIC_VERSION);\n","<script>\n /**\n * @aoexl/sign-svelte — AoexlSign component\n *\n * Usage:\n * <script>\n * import AoexlSign from '@aoexl/sign-svelte'\n * <\\/script>\n *\n * <AoexlSign\n * licenseKey=\"pk_live_xxx\"\n * pdfUrl=\"https://...\"\n * mode=\"sign\"\n * {signers}\n * {fields}\n * on:complete={handleComplete}\n * on:error={handleError}\n * style=\"height:600px\"\n * />\n */\n\n import { onMount, onDestroy, createEventDispatcher } from 'svelte'\n import AoexlSign from '@aoexl/sign'\n\n export let licenseKey\n export let pdfUrl\n export let mode = 'sign' // 'prepare' | 'sign' | 'view'\n export let signers = []\n export let fields = []\n export let theme = {}\n export let workerSrc = undefined\n\n const dispatch = createEventDispatcher()\n\n let container\n let instance = null\n let loading = false\n\n async function mount() {\n if (!container || !licenseKey || !pdfUrl) return\n loading = true\n try {\n instance = await AoexlSign.init({\n licenseKey,\n container,\n pdfUrl,\n mode,\n signers,\n fields,\n theme,\n workerSrc,\n onComplete: (result) => dispatch('complete', result),\n onError: (err) => dispatch('error', err),\n })\n } catch (err) {\n dispatch('error', err)\n } finally {\n loading = false\n }\n }\n\n function destroy() {\n instance?.destroy()\n instance = null\n }\n\n onMount(mount)\n onDestroy(destroy)\n\n // Reactive: re-mount when key, URL or mode changes\n $: if (licenseKey || pdfUrl || mode) {\n destroy()\n mount()\n }\n</script>\n\n<div style=\"position:relative;width:100%;height:100%\">\n {#if loading}\n <!-- Loading overlay shown while the SDK initialises -->\n <div\n style=\"\n position:absolute;\n inset:0;\n display:flex;\n align-items:center;\n justify-content:center;\n background:#F8FAFC;\n font-family:system-ui,sans-serif;\n color:#64748B;\n font-size:14px;\n z-index:10;\n \"\n >\n Activating Aoexl Sign&hellip;\n </div>\n {/if}\n <div bind:this={container} style=\"width:100%;height:100%\" />\n</div>\n"],"names":["PUBLIC_VERSION","insert","target","div","anchor","ctx","create_if_block","div1","append","div0","licenseKey","$$props","pdfUrl","mode","signers","fields","theme","workerSrc","dispatch","createEventDispatcher","container","instance","loading","mount","$$invalidate","AoexlSign","result","err","destroy","onMount","onDestroy","$$value"],"mappings":"4LASaA,EAAiB,ICP1B,OAAO,OAAW,MAEpB,OAAO,WAAa,OAAO,SAAW,CAAE,EAAG,IAAI,GAAK,IAAK,EAAE,IAAIA,CAAc,8cC2E3EC,SAeMC,EAAAC,EAAAC,CAAA,mDAjBHC,EAAO,CAAA,GAAAC,EAAA,+OADdL,SAqBMC,EAAAK,EAAAH,CAAA,+BADJI,EAAAA,OAA4DD,EAAAE,CAAA,oBAnBvDJ,EAAO,CAAA,kIArDD,WAAAK,CAAU,EAAAC,GACV,OAAAC,CAAM,EAAAD,EACN,CAAA,KAAAE,EAAY,MAAM,EAAAF,GAClB,QAAAG,EAAO,CAAA,CAAA,EAAAH,GACP,OAAAI,EAAM,CAAA,CAAA,EAAAJ,GACN,MAAAK,EAAK,CAAA,CAAA,EAAAL,EACL,CAAA,UAAAM,EAAY,MAAS,EAAAN,EAE1B,MAAAO,EAAWC,EAAAA,sBAAqB,MAElCC,EACAC,EAAW,KACXC,EAAW,kBAEAC,GAAK,OACbH,GAAS,CAAKV,GAAU,CAAKE,GAClC,CAAAY,EAAA,EAAAF,EAAU,EAAI,MAEZD,EAAQ,MAASI,EAAU,KAAI,CAC7B,WAAAf,EACA,UAAAU,EACA,OAAAR,EACA,KAAAC,EACA,QAAAC,EACA,OAAAC,EACA,MAAAC,EACA,UAAAC,EACA,WAAaS,GAAWR,EAAS,WAAYQ,CAAM,EACnD,QAAaC,GAAWT,EAAS,QAASS,CAAG,UAExCA,EAAG,CACVT,EAAS,QAASS,CAAG,UAErBH,EAAA,EAAAF,EAAU,EAAK,aAIVM,GAAO,CACdP,GAAA,MAAAA,EAAU,UACVA,EAAW,KAGbQ,EAAAA,QAAQN,CAAK,EACbO,EAAAA,UAAUF,CAAO,6DA6BDR,EAASW,4RA1BlBrB,GAAcE,GAAUC,KAC7Be,EAAO,EACPL,EAAK","x_google_ignoreList":[0,1]}
@@ -0,0 +1,114 @@
1
+ import { SvelteComponent as C, init as U, safe_not_equal as K, noop as S, detach as b, insert as A, append as x, element as h, space as E, set_style as l, binding_callbacks as F } from "svelte/internal";
2
+ import { createEventDispatcher as z, onMount as B, onDestroy as D } from "svelte";
3
+ import I from "@aoexl/sign";
4
+ const j = "4";
5
+ typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(j);
6
+ function k(r) {
7
+ let e;
8
+ return {
9
+ c() {
10
+ e = h("div"), e.textContent = "Activating Aoexl Sign…", l(e, "position", "absolute"), l(e, "inset", "0"), l(e, "display", "flex"), l(e, "align-items", "center"), l(e, "justify-content", "center"), l(e, "background", "#F8FAFC"), l(e, "font-family", "system-ui,sans-serif"), l(e, "color", "#64748B"), l(e, "font-size", "14px"), l(e, "z-index", "10");
11
+ },
12
+ m(n, f) {
13
+ A(n, e, f);
14
+ },
15
+ d(n) {
16
+ n && b(e);
17
+ }
18
+ };
19
+ }
20
+ function q(r) {
21
+ let e, n, f, i = (
22
+ /*loading*/
23
+ r[1] && k()
24
+ );
25
+ return {
26
+ c() {
27
+ e = h("div"), i && i.c(), n = E(), f = h("div"), l(f, "width", "100%"), l(f, "height", "100%"), l(e, "position", "relative"), l(e, "width", "100%"), l(e, "height", "100%");
28
+ },
29
+ m(o, c) {
30
+ A(o, e, c), i && i.m(e, null), x(e, n), x(e, f), r[9](f);
31
+ },
32
+ p(o, [c]) {
33
+ /*loading*/
34
+ o[1] ? i || (i = k(), i.c(), i.m(e, n)) : i && (i.d(1), i = null);
35
+ },
36
+ i: S,
37
+ o: S,
38
+ d(o) {
39
+ o && b(e), i && i.d(), r[9](null);
40
+ }
41
+ };
42
+ }
43
+ function L(r, e, n) {
44
+ let { licenseKey: f } = e, { pdfUrl: i } = e, { mode: o = "sign" } = e, { signers: c = [] } = e, { fields: u = [] } = e, { theme: m = {} } = e, { workerSrc: g = void 0 } = e;
45
+ const y = z();
46
+ let d, s = null, a = !1;
47
+ async function _() {
48
+ if (!(!d || !f || !i)) {
49
+ n(1, a = !0);
50
+ try {
51
+ s = await I.init({
52
+ licenseKey: f,
53
+ container: d,
54
+ pdfUrl: i,
55
+ mode: o,
56
+ signers: c,
57
+ fields: u,
58
+ theme: m,
59
+ workerSrc: g,
60
+ onComplete: (t) => y("complete", t),
61
+ onError: (t) => y("error", t)
62
+ });
63
+ } catch (t) {
64
+ y("error", t);
65
+ } finally {
66
+ n(1, a = !1);
67
+ }
68
+ }
69
+ }
70
+ function w() {
71
+ s == null || s.destroy(), s = null;
72
+ }
73
+ B(_), D(w);
74
+ function v(t) {
75
+ F[t ? "unshift" : "push"](() => {
76
+ d = t, n(0, d);
77
+ });
78
+ }
79
+ return r.$$set = (t) => {
80
+ "licenseKey" in t && n(2, f = t.licenseKey), "pdfUrl" in t && n(3, i = t.pdfUrl), "mode" in t && n(4, o = t.mode), "signers" in t && n(5, c = t.signers), "fields" in t && n(6, u = t.fields), "theme" in t && n(7, m = t.theme), "workerSrc" in t && n(8, g = t.workerSrc);
81
+ }, r.$$.update = () => {
82
+ r.$$.dirty & /*licenseKey, pdfUrl, mode*/
83
+ 28 && (f || i || o) && (w(), _());
84
+ }, [
85
+ d,
86
+ a,
87
+ f,
88
+ i,
89
+ o,
90
+ c,
91
+ u,
92
+ m,
93
+ g,
94
+ v
95
+ ];
96
+ }
97
+ class P extends C {
98
+ constructor(e) {
99
+ super(), U(this, e, L, q, K, {
100
+ licenseKey: 2,
101
+ pdfUrl: 3,
102
+ mode: 4,
103
+ signers: 5,
104
+ fields: 6,
105
+ theme: 7,
106
+ workerSrc: 8
107
+ });
108
+ }
109
+ }
110
+ export {
111
+ P as AoexlSign,
112
+ P as default
113
+ };
114
+ //# sourceMappingURL=aoexl-sign-svelte.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aoexl-sign-svelte.js","sources":["../../../../node_modules/svelte/src/shared/version.js","../../../../node_modules/svelte/src/runtime/internal/disclose-version/index.js","../src/AoexlSign.svelte"],"sourcesContent":["// generated during release, do not modify\n\n/**\n * The current version, as set in package.json.\n *\n * https://svelte.dev/docs/svelte-compiler#svelte-version\n * @type {string}\n */\nexport const VERSION = '4.2.20';\nexport const PUBLIC_VERSION = '4';\n","import { PUBLIC_VERSION } from '../../../shared/version.js';\n\nif (typeof window !== 'undefined')\n\t// @ts-ignore\n\t(window.__svelte || (window.__svelte = { v: new Set() })).v.add(PUBLIC_VERSION);\n","<script>\n /**\n * @aoexl/sign-svelte — AoexlSign component\n *\n * Usage:\n * <script>\n * import AoexlSign from '@aoexl/sign-svelte'\n * <\\/script>\n *\n * <AoexlSign\n * licenseKey=\"pk_live_xxx\"\n * pdfUrl=\"https://...\"\n * mode=\"sign\"\n * {signers}\n * {fields}\n * on:complete={handleComplete}\n * on:error={handleError}\n * style=\"height:600px\"\n * />\n */\n\n import { onMount, onDestroy, createEventDispatcher } from 'svelte'\n import AoexlSign from '@aoexl/sign'\n\n export let licenseKey\n export let pdfUrl\n export let mode = 'sign' // 'prepare' | 'sign' | 'view'\n export let signers = []\n export let fields = []\n export let theme = {}\n export let workerSrc = undefined\n\n const dispatch = createEventDispatcher()\n\n let container\n let instance = null\n let loading = false\n\n async function mount() {\n if (!container || !licenseKey || !pdfUrl) return\n loading = true\n try {\n instance = await AoexlSign.init({\n licenseKey,\n container,\n pdfUrl,\n mode,\n signers,\n fields,\n theme,\n workerSrc,\n onComplete: (result) => dispatch('complete', result),\n onError: (err) => dispatch('error', err),\n })\n } catch (err) {\n dispatch('error', err)\n } finally {\n loading = false\n }\n }\n\n function destroy() {\n instance?.destroy()\n instance = null\n }\n\n onMount(mount)\n onDestroy(destroy)\n\n // Reactive: re-mount when key, URL or mode changes\n $: if (licenseKey || pdfUrl || mode) {\n destroy()\n mount()\n }\n</script>\n\n<div style=\"position:relative;width:100%;height:100%\">\n {#if loading}\n <!-- Loading overlay shown while the SDK initialises -->\n <div\n style=\"\n position:absolute;\n inset:0;\n display:flex;\n align-items:center;\n justify-content:center;\n background:#F8FAFC;\n font-family:system-ui,sans-serif;\n color:#64748B;\n font-size:14px;\n z-index:10;\n \"\n >\n Activating Aoexl Sign&hellip;\n </div>\n {/if}\n <div bind:this={container} style=\"width:100%;height:100%\" />\n</div>\n"],"names":["PUBLIC_VERSION","insert","target","div","anchor","ctx","create_if_block","div1","append","div0","licenseKey","$$props","pdfUrl","mode","signers","fields","theme","workerSrc","dispatch","createEventDispatcher","container","instance","loading","mount","$$invalidate","AoexlSign","result","err","destroy","onMount","onDestroy","$$value"],"mappings":";;;AASO,MAAMA,IAAiB;ACP1B,OAAO,SAAW,QAEpB,OAAO,aAAa,OAAO,WAAW,EAAE,GAAG,oBAAI,IAAG,EAAE,IAAK,EAAE,IAAIA,CAAc;;;;;;;;AC2E3E,MAAAC,EAeMC,GAAAC,GAAAC,CAAA;AAAA;;;;;;;;;IAjBHC,EAAO,CAAA,KAAAC,EAAA;AAAA;;;;;;AADd,MAAAL,EAqBMC,GAAAK,GAAAH,CAAA,+BADJI,EAA4DD,GAAAE,CAAA;;;;MAnBvDJ,EAAO,CAAA;;;;;;;;;;QArDD,YAAAK,EAAU,IAAAC,KACV,QAAAC,EAAM,IAAAD,GACN,EAAA,MAAAE,IAAY,OAAM,IAAAF,KAClB,SAAAG,IAAO,CAAA,EAAA,IAAAH,KACP,QAAAI,IAAM,CAAA,EAAA,IAAAJ,KACN,OAAAK,IAAK,CAAA,EAAA,IAAAL,GACL,EAAA,WAAAM,IAAY,OAAS,IAAAN;AAE1B,QAAAO,IAAWC,EAAqB;MAElCC,GACAC,IAAW,MACXC,IAAW;iBAEAC,IAAK;WACbH,KAAS,CAAKV,KAAU,CAAKE,IAClC;AAAA,MAAAY,EAAA,GAAAF,IAAU,EAAI;;AAEZ,QAAAD,IAAQ,MAASI,EAAU,KAAI;AAAA,UAC7B,YAAAf;AAAA,UACA,WAAAU;AAAA,UACA,QAAAR;AAAA,UACA,MAAAC;AAAA,UACA,SAAAC;AAAA,UACA,QAAAC;AAAA,UACA,OAAAC;AAAA,UACA,WAAAC;AAAA,UACA,YAAa,CAAAS,MAAWR,EAAS,YAAYQ,CAAM;AAAA,UACnD,SAAa,CAAAC,MAAWT,EAAS,SAASS,CAAG;AAAA;eAExCA,GAAG;AACV,QAAAT,EAAS,SAASS,CAAG;AAAA;AAErB,QAAAH,EAAA,GAAAF,IAAU,EAAK;AAAA;;;WAIVM,IAAO;AACd,IAAAP,KAAA,QAAAA,EAAU,WACVA,IAAW;AAAA;AAGb,EAAAQ,EAAQN,CAAK,GACbO,EAAUF,CAAO;;;AA6BD,MAAAR,IAASW;;;;;;;WA1BlBrB,KAAcE,KAAUC,OAC7Be,EAAO,GACPL,EAAK;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0,1]}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@aoexl/sign-svelte",
3
+ "version": "1.0.0",
4
+ "description": "Svelte integration for Aoexl Sign PDF eSignature SDK",
5
+ "main": "dist/aoexl-sign-svelte.cjs",
6
+ "module": "dist/aoexl-sign-svelte.js",
7
+ "svelte": "src/AoexlSign.svelte",
8
+ "types": "src/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "svelte": "./src/AoexlSign.svelte",
12
+ "import": "./dist/aoexl-sign-svelte.js",
13
+ "require": "./dist/aoexl-sign-svelte.cjs"
14
+ }
15
+ },
16
+ "files": ["dist", "src/AoexlSign.svelte", "src/index.js", "src/index.d.ts"],
17
+ "scripts": {
18
+ "build": "vite build --config vite.config.mjs",
19
+ "prepublishOnly": "npm run build"
20
+ },
21
+ "peerDependencies": {
22
+ "svelte": ">=4"
23
+ },
24
+ "dependencies": {
25
+ "@aoexl/sign": "^1.0.0"
26
+ },
27
+ "devDependencies": {
28
+ "@sveltejs/vite-plugin-svelte": "^3.0.0",
29
+ "svelte": "^4.0.0",
30
+ "vite": "^5.4.2"
31
+ },
32
+ "license": "UNLICENSED",
33
+ "private": false,
34
+ "publishConfig": {
35
+ "access": "public"
36
+ }
37
+ }
@@ -0,0 +1,98 @@
1
+ <script>
2
+ /**
3
+ * @aoexl/sign-svelte — AoexlSign component
4
+ *
5
+ * Usage:
6
+ * <script>
7
+ * import AoexlSign from '@aoexl/sign-svelte'
8
+ * <\/script>
9
+ *
10
+ * <AoexlSign
11
+ * licenseKey="pk_live_xxx"
12
+ * pdfUrl="https://..."
13
+ * mode="sign"
14
+ * {signers}
15
+ * {fields}
16
+ * on:complete={handleComplete}
17
+ * on:error={handleError}
18
+ * style="height:600px"
19
+ * />
20
+ */
21
+
22
+ import { onMount, onDestroy, createEventDispatcher } from 'svelte'
23
+ import AoexlSign from '@aoexl/sign'
24
+
25
+ export let licenseKey
26
+ export let pdfUrl
27
+ export let mode = 'sign' // 'prepare' | 'sign' | 'view'
28
+ export let signers = []
29
+ export let fields = []
30
+ export let theme = {}
31
+ export let workerSrc = undefined
32
+
33
+ const dispatch = createEventDispatcher()
34
+
35
+ let container
36
+ let instance = null
37
+ let loading = false
38
+
39
+ async function mount() {
40
+ if (!container || !licenseKey || !pdfUrl) return
41
+ loading = true
42
+ try {
43
+ instance = await AoexlSign.init({
44
+ licenseKey,
45
+ container,
46
+ pdfUrl,
47
+ mode,
48
+ signers,
49
+ fields,
50
+ theme,
51
+ workerSrc,
52
+ onComplete: (result) => dispatch('complete', result),
53
+ onError: (err) => dispatch('error', err),
54
+ })
55
+ } catch (err) {
56
+ dispatch('error', err)
57
+ } finally {
58
+ loading = false
59
+ }
60
+ }
61
+
62
+ function destroy() {
63
+ instance?.destroy()
64
+ instance = null
65
+ }
66
+
67
+ onMount(mount)
68
+ onDestroy(destroy)
69
+
70
+ // Reactive: re-mount when key, URL or mode changes
71
+ $: if (licenseKey || pdfUrl || mode) {
72
+ destroy()
73
+ mount()
74
+ }
75
+ </script>
76
+
77
+ <div style="position:relative;width:100%;height:100%">
78
+ {#if loading}
79
+ <!-- Loading overlay shown while the SDK initialises -->
80
+ <div
81
+ style="
82
+ position:absolute;
83
+ inset:0;
84
+ display:flex;
85
+ align-items:center;
86
+ justify-content:center;
87
+ background:#F8FAFC;
88
+ font-family:system-ui,sans-serif;
89
+ color:#64748B;
90
+ font-size:14px;
91
+ z-index:10;
92
+ "
93
+ >
94
+ Activating Aoexl Sign&hellip;
95
+ </div>
96
+ {/if}
97
+ <div bind:this={container} style="width:100%;height:100%" />
98
+ </div>
package/src/index.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ import type { SvelteComponentTyped } from 'svelte'
2
+ import type { Field, Signer, CompleteResult, Theme } from '@aoexl/sign'
3
+
4
+ // ── Re-export core types ─────────────────────────────────────────────────────
5
+ export type { Field, Signer, CompleteResult, Theme }
6
+
7
+ // ── Component props ──────────────────────────────────────────────────────────
8
+ export interface AoexlSignProps {
9
+ licenseKey: string
10
+ pdfUrl: string
11
+ mode?: 'prepare' | 'sign' | 'view'
12
+ signers?: Signer[]
13
+ fields?: Field[]
14
+ theme?: Theme
15
+ workerSrc?: string
16
+ }
17
+
18
+ // ── Component events ─────────────────────────────────────────────────────────
19
+ export interface AoexlSignEvents {
20
+ complete: CustomEvent<CompleteResult>
21
+ error: CustomEvent<Error>
22
+ }
23
+
24
+ /**
25
+ * Svelte 4 component wrapping the Aoexl Sign SDK.
26
+ *
27
+ * @example
28
+ * <AoexlSign
29
+ * licenseKey="pk_live_xxx"
30
+ * pdfUrl="https://example.com/doc.pdf"
31
+ * mode="sign"
32
+ * {signers}
33
+ * on:complete={handleComplete}
34
+ * on:error={handleError}
35
+ * style="height:600px"
36
+ * />
37
+ */
38
+ export declare class AoexlSign extends SvelteComponentTyped<
39
+ AoexlSignProps,
40
+ AoexlSignEvents,
41
+ {}
42
+ > {}
43
+
44
+ export default AoexlSign
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from './AoexlSign.svelte'
2
+ export { default as AoexlSign } from './AoexlSign.svelte'