@paywithglide/glide-react 0.0.7 → 0.0.9

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.
@@ -77,7 +77,8 @@ export type GlideDepositWalletProvider = {
77
77
  export type GlideDepositOptions = {
78
78
  app: string;
79
79
  recipient?: Hex;
80
- mode?: "deposit" | "withdraw";
80
+ mode?: "deposit" | "withdraw" | "pay";
81
+ amount?: string;
81
82
  preferGaslessPayment?: boolean;
82
83
  walletProvider?: GlideDepositWalletProvider;
83
84
  baseUrl?: string;
package/dist/glide.js CHANGED
@@ -1,8 +1,8 @@
1
- var v = Object.defineProperty;
2
- var b = (i, e, t) => e in i ? v(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var p = (i, e, t) => b(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { useMemo as P } from "react";
5
- class E {
1
+ var P = Object.defineProperty;
2
+ var D = (i, e, t) => e in i ? P(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var p = (i, e, t) => D(i, typeof e != "symbol" ? e + "" : e, t);
4
+ import { useMemo as v } from "react";
5
+ class b {
6
6
  constructor(e) {
7
7
  p(this, "opts");
8
8
  p(this, "open", () => {
@@ -14,14 +14,14 @@ class E {
14
14
  throw new Error(
15
15
  "walletProvider.signTypedDataAsync is required when preferGaslessPayment=true"
16
16
  );
17
- const a = this.opts.recipient, n = (e = this.opts.walletProvider) == null ? void 0 : e.address, d = (t = this.opts.walletProvider) == null ? void 0 : t.availableChainIds, l = (s = this.opts.walletProvider) == null ? void 0 : s.currentChainId, c = this.opts.preferGaslessPayment || !!((o = this.opts.walletProvider) != null && o.signTypedDataAsync);
17
+ const r = this.opts.recipient, n = (e = this.opts.walletProvider) == null ? void 0 : e.address, d = (t = this.opts.walletProvider) == null ? void 0 : t.availableChainIds, l = (s = this.opts.walletProvider) == null ? void 0 : s.currentChainId, c = this.opts.preferGaslessPayment || !!((o = this.opts.walletProvider) != null && o.signTypedDataAsync);
18
18
  this.openUrl(
19
- `${this.baseUrl}${this.opts.app}?embed=true${a ? `&recipient=${a}` : ""}${n ? `&connectedWalletAddress=${n}` : ""}${l ? `&currentChainId=${l}` : ""}${d ? `&availableChainIds=${d.join(",")}` : ""}${c ? "&preferGaslessPayment=true" : ""}${this.opts.mode ? `&mode=${this.opts.mode}` : ""}`
19
+ `${this.baseUrl}${this.opts.app}?embed=true${r ? `&recipient=${r}` : ""}${n ? `&connectedWalletAddress=${n}` : ""}${l ? `&currentChainId=${l}` : ""}${d ? `&availableChainIds=${d.join(",")}` : ""}${c ? "&preferGaslessPayment=true" : ""}${this.opts.mode ? `&mode=${this.opts.mode}` : ""}${this.opts.amount ? `&amount=${this.opts.amount}` : ""}`
20
20
  ), this.initialize();
21
21
  }
22
22
  });
23
23
  p(this, "iframeEventHandler", async (e) => {
24
- var s, o, a, n, d, l, c, h, m, w, y, u, f, g;
24
+ var s, o, r, n, d, l, c, h, m, y, w, u, f, g;
25
25
  const t = e.data;
26
26
  switch (t.type) {
27
27
  case "close":
@@ -41,12 +41,12 @@ class E {
41
41
  },
42
42
  this.baseUrl
43
43
  );
44
- } catch (r) {
45
- (n = (a = this.iframe) == null ? void 0 : a.contentWindow) == null || n.postMessage(
44
+ } catch (a) {
45
+ (n = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || n.postMessage(
46
46
  {
47
47
  type: "didSwitchChain",
48
48
  success: !1,
49
- error: r
49
+ error: a
50
50
  },
51
51
  this.baseUrl
52
52
  );
@@ -57,23 +57,23 @@ class E {
57
57
  if (!this.opts.walletProvider)
58
58
  throw new Error("walletProvider is not set");
59
59
  try {
60
- const r = await this.opts.walletProvider.sendTransactionAsync(
60
+ const a = await this.opts.walletProvider.sendTransactionAsync(
61
61
  t.tx
62
62
  );
63
63
  (l = (d = this.iframe) == null ? void 0 : d.contentWindow) == null || l.postMessage(
64
64
  {
65
65
  type: "didSendTransaction",
66
66
  success: !0,
67
- txHash: r
67
+ txHash: a
68
68
  },
69
69
  this.baseUrl
70
70
  );
71
- } catch (r) {
71
+ } catch (a) {
72
72
  (h = (c = this.iframe) == null ? void 0 : c.contentWindow) == null || h.postMessage(
73
73
  {
74
74
  type: "didSendTransaction",
75
75
  success: !1,
76
- error: r
76
+ error: a
77
77
  },
78
78
  this.baseUrl
79
79
  );
@@ -85,7 +85,7 @@ class E {
85
85
  if (!this.opts.walletProvider)
86
86
  throw new Error("walletProvider is not set");
87
87
  if (!this.opts.walletProvider.signTypedDataAsync) {
88
- (w = (m = this.iframe) == null ? void 0 : m.contentWindow) == null || w.postMessage(
88
+ (y = (m = this.iframe) == null ? void 0 : m.contentWindow) == null || y.postMessage(
89
89
  {
90
90
  type: "didSignTypedData",
91
91
  success: !1,
@@ -96,23 +96,23 @@ class E {
96
96
  return;
97
97
  }
98
98
  try {
99
- const r = await this.opts.walletProvider.signTypedDataAsync(
99
+ const a = await this.opts.walletProvider.signTypedDataAsync(
100
100
  t.data
101
101
  );
102
- (u = (y = this.iframe) == null ? void 0 : y.contentWindow) == null || u.postMessage(
102
+ (u = (w = this.iframe) == null ? void 0 : w.contentWindow) == null || u.postMessage(
103
103
  {
104
104
  type: "didSignTypedData",
105
105
  success: !0,
106
- signature: r
106
+ signature: a
107
107
  },
108
108
  this.baseUrl
109
109
  );
110
- } catch (r) {
110
+ } catch (a) {
111
111
  (g = (f = this.iframe) == null ? void 0 : f.contentWindow) == null || g.postMessage(
112
112
  {
113
113
  type: "didSignTypedData",
114
114
  success: !1,
115
- error: r
115
+ error: a
116
116
  },
117
117
  this.baseUrl
118
118
  );
@@ -168,24 +168,40 @@ class E {
168
168
  document.querySelectorAll(".glide-deposit-loader").forEach((e) => e.remove());
169
169
  }
170
170
  }
171
- const D = ({
171
+ const T = ({
172
172
  app: i,
173
173
  recipient: e,
174
174
  preferGaslessPayment: t,
175
175
  mode: s,
176
176
  walletProvider: o,
177
- baseUrl: a
177
+ baseUrl: r
178
178
  }) => ({
179
- openGlideDeposit: P(() => new E({
179
+ openGlideDeposit: v(() => new b({
180
180
  app: i,
181
181
  recipient: e,
182
182
  preferGaslessPayment: t,
183
183
  mode: s,
184
184
  walletProvider: o,
185
- baseUrl: a
186
- }), [i, e, t, s, o, a]).open
185
+ baseUrl: r
186
+ }), [i, e, t, s, o, r]).open
187
+ }), $ = ({
188
+ app: i,
189
+ preferGaslessPayment: e,
190
+ amount: t,
191
+ walletProvider: s,
192
+ baseUrl: o
193
+ }) => ({
194
+ openGlidePay: v(() => new b({
195
+ app: i,
196
+ preferGaslessPayment: e,
197
+ mode: "pay",
198
+ amount: t,
199
+ walletProvider: s,
200
+ baseUrl: o
201
+ }), [i, e, s, o, t]).open
187
202
  });
188
203
  export {
189
- E as GlideDeposit,
190
- D as useGlideDeposit
204
+ b as GlideDeposit,
205
+ T as useGlideDeposit,
206
+ $ as useGlidePay
191
207
  };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './GlideDeposit.ts';
2
2
  export * from './useGlideDeposit.ts';
3
+ export * from './useGlidePay.ts';
@@ -0,0 +1,12 @@
1
+ import { GlideDepositWalletProvider } from './GlideDeposit.ts';
2
+ interface UseGlidePayProps {
3
+ app: string;
4
+ preferGaslessPayment?: boolean;
5
+ amount: string;
6
+ walletProvider?: GlideDepositWalletProvider;
7
+ baseUrl?: string;
8
+ }
9
+ export declare const useGlidePay: ({ app, preferGaslessPayment, amount, walletProvider, baseUrl, }: UseGlidePayProps) => {
10
+ openGlidePay: () => void;
11
+ };
12
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paywithglide/glide-react",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -23,7 +23,7 @@
23
23
  "prepublishOnly": "npm run build"
24
24
  },
25
25
  "dependencies": {
26
- "@paywithglide/glide-js": "^0.9.35",
26
+ "@paywithglide/glide-js": "^0.10.0",
27
27
  "@tanstack/react-query": "^5.61.5",
28
28
  "react": "^18.3.1",
29
29
  "react-dom": "^18.3.1",
@@ -31,6 +31,7 @@
31
31
  "wagmi": "^2.13.0"
32
32
  },
33
33
  "devDependencies": {
34
+ "@antiwork/shortest": "^0.2.1",
34
35
  "@eslint/js": "^9.15.0",
35
36
  "@types/react": "^18.3.12",
36
37
  "@types/react-dom": "^18.3.1",