@paywithglide/glide-react 0.0.43 → 0.0.45

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/glide.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var ee = Object.defineProperty;
2
2
  var te = (s, t, e) => t in s ? ee(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var j = (s, t, e) => te(s, typeof t != "symbol" ? t + "" : t, e);
3
+ var L = (s, t, e) => te(s, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { useMemo as G } from "react";
5
5
  function se(s, { strict: t = !0 } = {}) {
6
6
  return !s || typeof s != "string" ? !1 : t ? /^0x[0-9a-fA-F]*$/.test(s) : s.startsWith("0x");
@@ -9,26 +9,26 @@ function q(s) {
9
9
  return se(s, { strict: !1 }) ? Math.ceil((s.length - 2) / 2) : s.length;
10
10
  }
11
11
  const N = "2.21.51";
12
- let L = {
12
+ let W = {
13
13
  getDocsUrl: ({ docsBaseUrl: s, docsPath: t = "", docsSlug: e }) => t ? `${s ?? "https://viem.sh"}${t}${e ? `#${e}` : ""}` : void 0,
14
14
  version: `viem@${N}`
15
15
  };
16
- class z extends Error {
16
+ class D extends Error {
17
17
  constructor(t, e = {}) {
18
18
  var d;
19
19
  const i = (() => {
20
20
  var a;
21
- return e.cause instanceof z ? e.cause.details : (a = e.cause) != null && a.message ? e.cause.message : e.details;
22
- })(), o = e.cause instanceof z && e.cause.docsPath || e.docsPath, r = (d = L.getDocsUrl) == null ? void 0 : d.call(L, { ...e, docsPath: o }), p = [
21
+ return e.cause instanceof D ? e.cause.details : (a = e.cause) != null && a.message ? e.cause.message : e.details;
22
+ })(), o = e.cause instanceof D && e.cause.docsPath || e.docsPath, n = (d = W.getDocsUrl) == null ? void 0 : d.call(W, { ...e, docsPath: o }), c = [
23
23
  t || "An error occurred.",
24
24
  "",
25
25
  ...e.metaMessages ? [...e.metaMessages, ""] : [],
26
- ...r ? [`Docs: ${r}`] : [],
26
+ ...n ? [`Docs: ${n}`] : [],
27
27
  ...i ? [`Details: ${i}`] : [],
28
- ...L.version ? [`Version: ${L.version}`] : []
28
+ ...W.version ? [`Version: ${W.version}`] : []
29
29
  ].join(`
30
30
  `);
31
- super(p, e.cause ? { cause: e.cause } : void 0), Object.defineProperty(this, "details", {
31
+ super(c, e.cause ? { cause: e.cause } : void 0), Object.defineProperty(this, "details", {
32
32
  enumerable: !0,
33
33
  configurable: !0,
34
34
  writable: !0,
@@ -67,12 +67,12 @@ class z extends Error {
67
67
  function V(s, t) {
68
68
  return t != null && t(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ? V(s.cause, t) : t ? null : s;
69
69
  }
70
- class F extends z {
70
+ class F extends D {
71
71
  constructor({ size: t, targetSize: e, type: i }) {
72
72
  super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${t}) exceeds padding size (${e}).`, { name: "SizeExceedsPaddingSizeError" });
73
73
  }
74
74
  }
75
- function O(s, { dir: t, size: e = 32 } = {}) {
75
+ function H(s, { dir: t, size: e = 32 } = {}) {
76
76
  return typeof s == "string" ? ie(s, { dir: t, size: e }) : oe(s, { dir: t, size: e });
77
77
  }
78
78
  function ie(s, { dir: t, size: e = 32 } = {}) {
@@ -98,108 +98,111 @@ function oe(s, { dir: t, size: e = 32 } = {}) {
98
98
  });
99
99
  const i = new Uint8Array(e);
100
100
  for (let o = 0; o < e; o++) {
101
- const r = t === "right";
102
- i[r ? o : e - o - 1] = s[r ? o : s.length - o - 1];
101
+ const n = t === "right";
102
+ i[n ? o : e - o - 1] = s[n ? o : s.length - o - 1];
103
103
  }
104
104
  return i;
105
105
  }
106
- class re extends z {
107
- constructor({ max: t, min: e, signed: i, size: o, value: r }) {
108
- super(`Number "${r}" is not in safe ${o ? `${o * 8}-bit ${i ? "signed" : "unsigned"} ` : ""}integer range ${t ? `(${e} to ${t})` : `(above ${e})`}`, { name: "IntegerOutOfRangeError" });
106
+ class ne extends D {
107
+ constructor({ max: t, min: e, signed: i, size: o, value: n }) {
108
+ super(`Number "${n}" is not in safe ${o ? `${o * 8}-bit ${i ? "signed" : "unsigned"} ` : ""}integer range ${t ? `(${e} to ${t})` : `(above ${e})`}`, { name: "IntegerOutOfRangeError" });
109
109
  }
110
110
  }
111
- class ne extends z {
111
+ class re extends D {
112
112
  constructor({ givenSize: t, maxSize: e }) {
113
113
  super(`Size cannot exceed ${e} bytes. Given size: ${t} bytes.`, { name: "SizeOverflowError" });
114
114
  }
115
115
  }
116
116
  function J(s, { size: t }) {
117
117
  if (q(s) > t)
118
- throw new ne({
118
+ throw new re({
119
119
  givenSize: q(s),
120
120
  maxSize: t
121
121
  });
122
122
  }
123
123
  const ae = /* @__PURE__ */ Array.from({ length: 256 }, (s, t) => t.toString(16).padStart(2, "0"));
124
124
  function de(s, t = {}) {
125
- return typeof s == "number" || typeof s == "bigint" ? ce(s, t) : typeof s == "string" ? he(s, t) : typeof s == "boolean" ? pe(s, t) : X(s, t);
125
+ return typeof s == "number" || typeof s == "bigint" ? pe(s, t) : typeof s == "string" ? he(s, t) : typeof s == "boolean" ? ce(s, t) : X(s, t);
126
126
  }
127
- function pe(s, t = {}) {
127
+ function ce(s, t = {}) {
128
128
  const e = `0x${Number(s)}`;
129
- return typeof t.size == "number" ? (J(e, { size: t.size }), O(e, { size: t.size })) : e;
129
+ return typeof t.size == "number" ? (J(e, { size: t.size }), H(e, { size: t.size })) : e;
130
130
  }
131
131
  function X(s, t = {}) {
132
132
  let e = "";
133
133
  for (let o = 0; o < s.length; o++)
134
134
  e += ae[s[o]];
135
135
  const i = `0x${e}`;
136
- return typeof t.size == "number" ? (J(i, { size: t.size }), O(i, { dir: "right", size: t.size })) : i;
136
+ return typeof t.size == "number" ? (J(i, { size: t.size }), H(i, { dir: "right", size: t.size })) : i;
137
137
  }
138
- function ce(s, t = {}) {
138
+ function pe(s, t = {}) {
139
139
  const { signed: e, size: i } = t, o = BigInt(s);
140
- let r;
141
- i ? e ? r = (1n << BigInt(i) * 8n - 1n) - 1n : r = 2n ** (BigInt(i) * 8n) - 1n : typeof s == "number" && (r = BigInt(Number.MAX_SAFE_INTEGER));
142
- const p = typeof r == "bigint" && e ? -r - 1n : 0;
143
- if (r && o > r || o < p) {
140
+ let n;
141
+ i ? e ? n = (1n << BigInt(i) * 8n - 1n) - 1n : n = 2n ** (BigInt(i) * 8n) - 1n : typeof s == "number" && (n = BigInt(Number.MAX_SAFE_INTEGER));
142
+ const c = typeof n == "bigint" && e ? -n - 1n : 0;
143
+ if (n && o > n || o < c) {
144
144
  const a = typeof s == "bigint" ? "n" : "";
145
- throw new re({
146
- max: r ? `${r}${a}` : void 0,
147
- min: `${p}${a}`,
145
+ throw new ne({
146
+ max: n ? `${n}${a}` : void 0,
147
+ min: `${c}${a}`,
148
148
  signed: e,
149
149
  size: i,
150
150
  value: `${s}${a}`
151
151
  });
152
152
  }
153
153
  const d = `0x${(e && o < 0 ? (1n << BigInt(i * 8)) + BigInt(o) : o).toString(16)}`;
154
- return i ? O(d, { size: i }) : d;
154
+ return i ? H(d, { size: i }) : d;
155
155
  }
156
156
  const le = /* @__PURE__ */ new TextEncoder();
157
157
  function he(s, t = {}) {
158
158
  const e = le.encode(s);
159
159
  return X(e, t);
160
160
  }
161
- let K = !1;
162
161
  function ue(s) {
162
+ return s instanceof Error;
163
+ }
164
+ let K = !1;
165
+ function me(s) {
163
166
  if (K)
164
167
  return;
165
168
  K = !0;
166
- const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), o = (p) => {
167
- const d = p.detail;
169
+ const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), o = (c) => {
170
+ const d = c.detail;
168
171
  t.has(d.info.uuid) || t.set(d.info.uuid, d);
169
172
  };
170
- window.addEventListener("eip6963:announceProvider", o), window.dispatchEvent(new Event("eip6963:requestProvider")), window.addEventListener("message", async (p) => {
173
+ window.addEventListener("eip6963:announceProvider", o), window.dispatchEvent(new Event("eip6963:requestProvider")), window.addEventListener("message", async (c) => {
171
174
  var f;
172
- if (p.origin !== s) return;
173
- const { type: d, data: a } = p.data;
175
+ if (c.origin !== s) return;
176
+ const { type: d, data: a } = c.data;
174
177
  switch (d) {
175
178
  case "glide:getProviders": {
176
- const c = Array.from(t.values()).map(
179
+ const p = Array.from(t.values()).map(
177
180
  ({ info: h, provider: l }) => ({
178
181
  info: h,
179
182
  isConnected: typeof l.isConnected == "boolean" ? l.isConnected : void 0,
180
183
  chainId: l.chainId,
181
184
  selectedAddress: l.selectedAddress
182
185
  })
183
- ), n = document.getElementById(
186
+ ), r = document.getElementById(
184
187
  "glide-deposit-iframe"
185
188
  );
186
- n != null && n.contentWindow && n.contentWindow.postMessage(
189
+ r != null && r.contentWindow && r.contentWindow.postMessage(
187
190
  {
188
191
  type: "glide:providers",
189
- providers: c
192
+ providers: p
190
193
  },
191
194
  s
192
195
  );
193
196
  break;
194
197
  }
195
198
  case "glide:providerRequest": {
196
- const { uuid: c, requestId: n, method: h, params: l } = a;
197
- if (i.has(n))
199
+ const { uuid: p, requestId: r, method: h, params: l } = a;
200
+ if (i.has(r))
198
201
  return;
199
- i.set(n, !0);
200
- const m = t.get(c);
202
+ i.set(r, !0);
203
+ const m = t.get(p);
201
204
  if (!m) {
202
- i.delete(n), r(n, { error: "Provider not found" });
205
+ i.delete(r), n(r, { error: "Provider not found" });
203
206
  return;
204
207
  }
205
208
  try {
@@ -207,20 +210,22 @@ function ue(s) {
207
210
  method: h,
208
211
  params: l
209
212
  });
210
- i.delete(n), r(n, { result: u });
213
+ i.delete(r), n(r, { result: u });
211
214
  } catch (u) {
212
- i.delete(n), r(n, {
215
+ i.delete(r), ue(u) ? n(r, {
213
216
  error: u.message || String(u),
214
217
  code: u.code,
215
218
  data: u.data
219
+ }) : n(r, {
220
+ error: String(u)
216
221
  });
217
222
  }
218
223
  break;
219
224
  }
220
225
  case "glide:addEventListener": {
221
- const { uuid: c, requestId: n, eventName: h } = a, l = t.get(c);
226
+ const { uuid: p, requestId: r, eventName: h } = a, l = t.get(p);
222
227
  if (!l || !l.provider.on) {
223
- r(n, { error: "Provider or method not found" });
228
+ n(r, { error: "Provider or method not found" });
224
229
  return;
225
230
  }
226
231
  const m = (...u) => {
@@ -230,48 +235,61 @@ function ue(s) {
230
235
  g != null && g.contentWindow && g.contentWindow.postMessage(
231
236
  {
232
237
  type: "glide:providerEvent",
233
- uuid: c,
238
+ uuid: p,
234
239
  eventName: h,
235
240
  args: u
236
241
  },
237
242
  s
238
243
  );
239
244
  };
240
- e.has(c) || e.set(c, /* @__PURE__ */ new Map()), e.get(c).has(h) || e.get(c).set(h, /* @__PURE__ */ new Set()), e.get(c).get(h).add(m), l.provider.on(h, m), r(n, { result: !0 });
245
+ e.has(p) || e.set(p, /* @__PURE__ */ new Map()), e.get(p).has(h) || e.get(p).set(h, /* @__PURE__ */ new Set()), e.get(p).get(h).add(m), l.provider.on(h, m), n(r, { result: !0 });
241
246
  break;
242
247
  }
243
248
  case "glide:removeEventListener": {
244
- const { uuid: c, requestId: n, eventName: h } = a, l = t.get(c);
249
+ const { uuid: p, requestId: r, eventName: h } = a, l = t.get(p);
245
250
  if (!l || !l.provider.removeListener) {
246
- r(n, { error: "Provider or method not found" });
251
+ n(r, { error: "Provider or method not found" });
247
252
  return;
248
253
  }
249
- const m = (f = e.get(c)) == null ? void 0 : f.get(h);
254
+ const m = (f = e.get(p)) == null ? void 0 : f.get(h);
250
255
  m && (m.forEach((u) => {
251
256
  l.provider.removeListener(h, u);
252
- }), m.clear()), r(n, { result: !0 });
257
+ }), m.clear()), n(r, { result: !0 });
253
258
  break;
254
259
  }
255
260
  }
256
261
  });
257
- function r(p, d) {
262
+ function n(c, d) {
258
263
  const a = document.getElementById(
259
264
  "glide-deposit-iframe"
260
265
  );
261
266
  a != null && a.contentWindow && a.contentWindow.postMessage(
262
267
  {
263
268
  type: "glide:providerResponse",
264
- requestId: p,
269
+ requestId: c,
265
270
  ...d
266
271
  },
267
272
  s
268
273
  );
269
274
  }
270
275
  }
271
- class H {
276
+ const ge = "@paywithglide/glide-react", fe = "0.0.45", ye = "module", we = ["dist"], ve = "dist/glide.js", be = "dist/index.d.ts", $e = { ".": { types: "./dist/index.d.ts", default: "./dist/glide.js" }, "./package.json": "./package.json" }, xe = !1, Ie = { dev: "vite", build: "bun run lint && vite build", "build-web": "tsc --p ./tsconfig.build.json && vite build --mode web", "build-chromeext": "tsc --p ./tsconfig.build.json && vite build --mode chromeext:popup && vite build --mode chromeext:content && vite build --mode chromeext:background", lint: "prettier --check . && eslint . --max-warnings 0 && tsc --p ./tsconfig.build.json", preview: "vite preview", prepublishOnly: "bun run build" }, Se = { "@paywithglide/glide-js": "0.13.10" }, Pe = { "@antiwork/shortest": "^0.2.1", "@eslint/js": "^9.15.0", "@tanstack/react-query": "^5.61.5", "@types/chrome": "^0.0.299", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "@vitejs/plugin-react": "^4.3.4", eslint: "^9.15.0", "eslint-plugin-react-hooks": "^5.0.0", "eslint-plugin-react-refresh": "^0.4.14", globals: "^15.12.0", prettier: "^3.6.2", react: "^18.3.1", "react-dom": "^18.3.1", typescript: "~5.6.2", "typescript-eslint": "^8.15.0", viem: "^2.21.51", vite: "^6.0.1", "vite-plugin-dts": "^4.3.0", "vite-plugin-static-copy": "^2.2.0", wagmi: "^2.13.0" }, Ee = {
277
+ name: ge,
278
+ version: fe,
279
+ type: ye,
280
+ files: we,
281
+ module: ve,
282
+ types: be,
283
+ exports: $e,
284
+ sideEffects: xe,
285
+ scripts: Ie,
286
+ dependencies: Se,
287
+ devDependencies: Pe
288
+ }, ke = Ee.version;
289
+ class O {
272
290
  constructor(t) {
273
- j(this, "opts");
274
- j(this, "open", () => {
291
+ L(this, "opts");
292
+ L(this, "open", () => {
275
293
  if (!(!this.opts.container && document.body.classList.contains("glide-deposit-open"))) {
276
294
  if (this.opts.container || document.body.classList.add("glide-deposit-open"), (this.opts.mode === "deposit" || this.opts.mode === "buy") && !this.opts.recipient)
277
295
  throw new Error("recipient is required for deposit/buy mode");
@@ -282,12 +300,12 @@ class H {
282
300
  this.openUrl(`${this.baseUrl}${this.opts.app}?init=true&embed=true`), this.initialize();
283
301
  }
284
302
  });
285
- j(this, "iframeEventHandler", async (t) => {
286
- var i, o, r, p, d, a, f, c, n, h, l, m, u, g, $, y, I, w, x, v, S, E, U, M, C, k, P, D, T, R, B, W, A;
303
+ L(this, "iframeEventHandler", async (t) => {
304
+ var i, o, n, c, d, a, f, p, r, h, l, m, u, g, $, y, x, w, I, v, S, E, k, U, M, C, P, z, j, T, R, B, A;
287
305
  const e = t.data;
288
306
  switch (e.type) {
289
307
  case "sendInit": {
290
- const b = this.opts.recipient, Q = (i = this.opts.walletProvider) == null ? void 0 : i.address, Y = (o = this.opts.walletProvider) == null ? void 0 : o.availableChainIds, Z = (r = this.opts.walletProvider) == null ? void 0 : r.currentChainId, _ = this.opts.preferGaslessPayment || !!((p = this.opts.walletProvider) != null && p.signTypedDataAsync);
308
+ const b = this.opts.recipient, Q = (i = this.opts.walletProvider) == null ? void 0 : i.address, Y = (o = this.opts.walletProvider) == null ? void 0 : o.availableChainIds, Z = (n = this.opts.walletProvider) == null ? void 0 : n.currentChainId, _ = this.opts.preferGaslessPayment || !!((c = this.opts.walletProvider) != null && c.signTypedDataAsync);
291
309
  (f = (d = this.iframe) == null ? void 0 : d.contentWindow) == null || f.postMessage(
292
310
  {
293
311
  type: "initialize",
@@ -329,14 +347,16 @@ class H {
329
347
  didProvideLocalStorage: !!this.opts.localStorageProvider,
330
348
  debug: this.opts.debug,
331
349
  popupsBlocked: this.opts.popupsBlocked,
332
- gasRefuelAmountPerChain: this.opts.gasRefuelAmountPerChain
350
+ gasRefuelAmountPerChain: this.opts.gasRefuelAmountPerChain,
351
+ sdkVersion: ke,
352
+ referrerDomain: typeof window < "u" ? window.location.origin : void 0
333
353
  },
334
354
  new URL(this.baseUrl).origin
335
355
  );
336
356
  break;
337
357
  }
338
358
  case "didOpen": {
339
- this.iframe.style.opacity = "1", (n = (c = this.opts).onOpen) == null || n.call(c);
359
+ this.iframe.style.opacity = "1", (r = (p = this.opts).onOpen) == null || r.call(p);
340
360
  break;
341
361
  }
342
362
  case "localStorage.getKeys": {
@@ -383,10 +403,10 @@ class H {
383
403
  ($ = (g = this.opts) == null ? void 0 : g.onSuccess) == null || $.call(g, e.hash, e.session);
384
404
  break;
385
405
  case "close":
386
- this.removeIframe(), this.destroy(), (I = (y = this.opts) == null ? void 0 : y.onClose) == null || I.call(y);
406
+ this.removeIframe(), this.destroy(), (x = (y = this.opts) == null ? void 0 : y.onClose) == null || x.call(y);
387
407
  break;
388
408
  case "setMode":
389
- (x = (w = this.opts) == null ? void 0 : w.onSetMode) == null || x.call(w, e.mode);
409
+ (I = (w = this.opts) == null ? void 0 : w.onSetMode) == null || I.call(w, e.mode);
390
410
  break;
391
411
  case "switchChain":
392
412
  if (!this.opts.walletProvider)
@@ -403,7 +423,7 @@ class H {
403
423
  this.baseUrl
404
424
  );
405
425
  } catch (b) {
406
- (U = (E = this.iframe) == null ? void 0 : E.contentWindow) == null || U.postMessage(
426
+ (k = (E = this.iframe) == null ? void 0 : E.contentWindow) == null || k.postMessage(
407
427
  {
408
428
  type: "didSwitchChain",
409
429
  success: !1,
@@ -421,7 +441,7 @@ class H {
421
441
  const b = await this.opts.walletProvider.sendTransactionAsync(
422
442
  e.tx
423
443
  );
424
- (C = (M = this.iframe) == null ? void 0 : M.contentWindow) == null || C.postMessage(
444
+ (M = (U = this.iframe) == null ? void 0 : U.contentWindow) == null || M.postMessage(
425
445
  {
426
446
  type: "didSendTransaction",
427
447
  success: !0,
@@ -430,7 +450,7 @@ class H {
430
450
  this.baseUrl
431
451
  );
432
452
  } catch (b) {
433
- (P = (k = this.iframe) == null ? void 0 : k.contentWindow) == null || P.postMessage(
453
+ (P = (C = this.iframe) == null ? void 0 : C.contentWindow) == null || P.postMessage(
434
454
  {
435
455
  type: "didSendTransaction",
436
456
  success: !1,
@@ -446,7 +466,7 @@ class H {
446
466
  if (!this.opts.walletProvider)
447
467
  throw new Error("walletProvider is not set");
448
468
  if (!this.opts.walletProvider.signTypedDataAsync) {
449
- (T = (D = this.iframe) == null ? void 0 : D.contentWindow) == null || T.postMessage(
469
+ (j = (z = this.iframe) == null ? void 0 : z.contentWindow) == null || j.postMessage(
450
470
  {
451
471
  type: "didSignTypedData",
452
472
  success: !1,
@@ -460,7 +480,7 @@ class H {
460
480
  const b = await this.opts.walletProvider.signTypedDataAsync(
461
481
  e.data
462
482
  );
463
- (B = (R = this.iframe) == null ? void 0 : R.contentWindow) == null || B.postMessage(
483
+ (R = (T = this.iframe) == null ? void 0 : T.contentWindow) == null || R.postMessage(
464
484
  {
465
485
  type: "didSignTypedData",
466
486
  success: !0,
@@ -469,7 +489,7 @@ class H {
469
489
  this.baseUrl
470
490
  );
471
491
  } catch (b) {
472
- (A = (W = this.iframe) == null ? void 0 : W.contentWindow) == null || A.postMessage(
492
+ (A = (B = this.iframe) == null ? void 0 : B.contentWindow) == null || A.postMessage(
473
493
  {
474
494
  type: "didSignTypedData",
475
495
  success: !1,
@@ -485,15 +505,15 @@ class H {
485
505
  this.opts = t;
486
506
  }
487
507
  get externalUrl() {
488
- var t, e, i, o, r, p, d, a, f;
508
+ var t, e, i, o, n, c, d, a, f;
489
509
  return `${this.baseUrl}${this.opts.app}?${this.opts.recipient ? `&recipient=${this.opts.recipient}` : ""}${this.opts.preferGaslessPayment ? "&preferGaslessPayment=true" : ""}${this.opts.mode ? `&mode=${this.opts.mode}` : ""}${this.opts.amount ? `&amount=${this.opts.amount}` : ""}${this.opts.chainId ? `&chainId=${this.opts.chainId}` : ""}${this.opts.currencyId ? `&currencyId=${this.opts.currencyId}` : ""}${this.opts.evm ? `&evm.chainId=${this.opts.evm.chainId}&evm.to=${this.opts.evm.to}&evm.data=${this.opts.evm.data || "0x0"}&evm.value=${de(
490
510
  this.opts.evm.value || 0n
491
- )}` : ""}${this.opts.approval ? `&approval.token=${this.opts.approval.token}&approval.amount=${this.opts.approval.amount}` : ""}${this.opts.sessionMetadata ? `&metadata=${this.opts.sessionMetadata}` : ""}${this.opts.autoCloseOnSuccess ? "&autoCloseOnSuccess=true" : ""}${this.opts.sessionId ? `&sessionId=${this.opts.sessionId}` : ""}${(t = this.opts.chainIds) != null && t.length ? `&chainIds=${this.opts.chainIds.join(",")}` : ""}${(e = this.opts.excludeChainIds) != null && e.length ? `&excludeChainIds=${this.opts.excludeChainIds.join(",")}` : ""}${(i = this.opts.excludeCurrencyTiers) != null && i.length ? `&excludeCurrencyTiers=${this.opts.excludeCurrencyTiers.join(",")}` : ""}${(o = this.opts.excludeFundingSources) != null && o.length ? `&excludeFundingSources=${this.opts.excludeFundingSources.join(",")}` : ""}${(r = this.opts.fundingSources) != null && r.length ? `&fundingSources=${this.opts.fundingSources.join(",")}` : ""}${(p = this.opts.allowedPaymentCurrencies) != null && p.length ? `&allowedPaymentCurrencies=${this.opts.allowedPaymentCurrencies.join(",")}` : ""}${(d = this.opts.appMetadata) != null && d.name ? `&appMetadata.name=${encodeURIComponent(this.opts.appMetadata.name)}` : ""}${(a = this.opts.appMetadata) != null && a.logoUrl ? `&appMetadata.logoUrl=${encodeURIComponent(this.opts.appMetadata.logoUrl)}` : ""}${(f = this.opts.appMetadata) != null && f.faviconUrl ? `&appMetadata.faviconUrl=${encodeURIComponent(this.opts.appMetadata.faviconUrl)}` : ""}${this.opts.enableRefundEmails ? "&enableRefundEmails=true" : ""}${this.opts.payerEmail ? `&payerEmail=${encodeURIComponent(this.opts.payerEmail)}` : ""}${this.opts.debug ? "&debug=true" : ""}${this.opts.popupsBlocked ? "&popupsBlocked=true" : ""}${this.opts.disableWithdrawToSelfSuggestion ? "&disableWithdrawToSelfSuggestion=true" : ""}${this.opts.hideSettlementCopy ? "&hideSettlementCopy=true" : ""}${this.opts.showAppLogo ? `&showAppLogo=${this.opts.showAppLogo}` : ""}${this.opts.showOnrampFirst ? "&showOnrampFirst=true" : ""}${this.opts.debitCardAlias ? `&debitCardAlias=${this.opts.debitCardAlias}` : ""}${this.opts.copyOverrides ? `&copyOverrides=${encodeURIComponent(JSON.stringify(this.opts.copyOverrides))}` : ""}${this.opts.stableDepositAddressKey ? `&stableDepositAddressKey=${encodeURIComponent(this.opts.stableDepositAddressKey)}` : ""}${this.opts.gasRefuelAmountPerChain ? `&gasRefuelAmountPerChain=${encodeURIComponent(JSON.stringify(this.opts.gasRefuelAmountPerChain))}` : ""}`;
511
+ )}` : ""}${this.opts.approval ? `&approval.token=${this.opts.approval.token}&approval.amount=${this.opts.approval.amount}` : ""}${this.opts.sessionMetadata ? `&metadata=${this.opts.sessionMetadata}` : ""}${this.opts.autoCloseOnSuccess ? "&autoCloseOnSuccess=true" : ""}${this.opts.sessionId ? `&sessionId=${this.opts.sessionId}` : ""}${(t = this.opts.chainIds) != null && t.length ? `&chainIds=${this.opts.chainIds.join(",")}` : ""}${(e = this.opts.excludeChainIds) != null && e.length ? `&excludeChainIds=${this.opts.excludeChainIds.join(",")}` : ""}${(i = this.opts.excludeCurrencyTiers) != null && i.length ? `&excludeCurrencyTiers=${this.opts.excludeCurrencyTiers.join(",")}` : ""}${(o = this.opts.excludeFundingSources) != null && o.length ? `&excludeFundingSources=${this.opts.excludeFundingSources.join(",")}` : ""}${(n = this.opts.fundingSources) != null && n.length ? `&fundingSources=${this.opts.fundingSources.join(",")}` : ""}${(c = this.opts.allowedPaymentCurrencies) != null && c.length ? `&allowedPaymentCurrencies=${this.opts.allowedPaymentCurrencies.join(",")}` : ""}${(d = this.opts.appMetadata) != null && d.name ? `&appMetadata.name=${encodeURIComponent(this.opts.appMetadata.name)}` : ""}${(a = this.opts.appMetadata) != null && a.logoUrl ? `&appMetadata.logoUrl=${encodeURIComponent(this.opts.appMetadata.logoUrl)}` : ""}${(f = this.opts.appMetadata) != null && f.faviconUrl ? `&appMetadata.faviconUrl=${encodeURIComponent(this.opts.appMetadata.faviconUrl)}` : ""}${this.opts.enableRefundEmails ? "&enableRefundEmails=true" : ""}${this.opts.payerEmail ? `&payerEmail=${encodeURIComponent(this.opts.payerEmail)}` : ""}${this.opts.debug ? "&debug=true" : ""}${this.opts.popupsBlocked ? "&popupsBlocked=true" : ""}${this.opts.disableWithdrawToSelfSuggestion ? "&disableWithdrawToSelfSuggestion=true" : ""}${this.opts.hideSettlementCopy ? "&hideSettlementCopy=true" : ""}${this.opts.showAppLogo ? `&showAppLogo=${this.opts.showAppLogo}` : ""}${this.opts.showOnrampFirst ? "&showOnrampFirst=true" : ""}${this.opts.debitCardAlias ? `&debitCardAlias=${this.opts.debitCardAlias}` : ""}${this.opts.copyOverrides ? `&copyOverrides=${encodeURIComponent(JSON.stringify(this.opts.copyOverrides))}` : ""}${this.opts.stableDepositAddressKey ? `&stableDepositAddressKey=${encodeURIComponent(this.opts.stableDepositAddressKey)}` : ""}${this.opts.gasRefuelAmountPerChain ? `&gasRefuelAmountPerChain=${encodeURIComponent(JSON.stringify(this.opts.gasRefuelAmountPerChain))}` : ""}`;
492
512
  }
493
513
  initialize() {
494
514
  window.addEventListener("message", this.iframeEventHandler);
495
515
  const t = new URL(this.baseUrl).origin;
496
- ue(t);
516
+ me(t);
497
517
  }
498
518
  destroy() {
499
519
  window.removeEventListener("message", this.iframeEventHandler);
@@ -537,19 +557,19 @@ class H {
537
557
  t && (t.remove(), document.body.classList.remove("glide-deposit-open"));
538
558
  }
539
559
  }
540
- const fe = ({
560
+ const Ce = ({
541
561
  app: s,
542
562
  recipient: t,
543
563
  chainId: e,
544
564
  currencyId: i,
545
565
  amount: o,
546
- gasRefuelAmountPerChain: r,
547
- preferGaslessPayment: p,
566
+ gasRefuelAmountPerChain: n,
567
+ preferGaslessPayment: c,
548
568
  chainIds: d,
549
569
  excludeChainIds: a,
550
570
  excludeCurrencyTiers: f,
551
- excludeFundingSources: c,
552
- fundingSources: n,
571
+ excludeFundingSources: p,
572
+ fundingSources: r,
553
573
  appMetadata: h,
554
574
  enableRefundEmails: l,
555
575
  payerEmail: m,
@@ -557,36 +577,36 @@ const fe = ({
557
577
  hideSettlementCopy: g,
558
578
  showAppLogo: $,
559
579
  showOnrampFirst: y,
560
- debitCardAlias: I,
580
+ debitCardAlias: x,
561
581
  copyOverrides: w,
562
- stableDepositAddressKey: x,
582
+ stableDepositAddressKey: I,
563
583
  sessionId: v,
564
584
  sessionMetadata: S,
565
585
  disableWithdrawToSelfSuggestion: E,
566
- theme: U,
567
- walletProvider: M,
568
- localStorageProvider: C,
569
- onOpen: k,
586
+ theme: k,
587
+ walletProvider: U,
588
+ localStorageProvider: M,
589
+ onOpen: C,
570
590
  onSuccess: P,
571
- onClose: D,
572
- autoCloseOnSuccess: T,
573
- popupsBlocked: R,
574
- baseUrl: B,
575
- debug: W
591
+ onClose: z,
592
+ autoCloseOnSuccess: j,
593
+ popupsBlocked: T,
594
+ baseUrl: R,
595
+ debug: B
576
596
  }) => {
577
- const A = G(() => new H({
597
+ const A = G(() => new O({
578
598
  app: s,
579
599
  recipient: t,
580
600
  chainId: e,
581
601
  currencyId: i,
582
602
  amount: o,
583
- gasRefuelAmountPerChain: r,
584
- preferGaslessPayment: p,
603
+ gasRefuelAmountPerChain: n,
604
+ preferGaslessPayment: c,
585
605
  chainIds: d,
586
606
  excludeChainIds: a,
587
607
  excludeCurrencyTiers: f,
588
- excludeFundingSources: c,
589
- fundingSources: n,
608
+ excludeFundingSources: p,
609
+ fundingSources: r,
590
610
  appMetadata: h,
591
611
  enableRefundEmails: l,
592
612
  payerEmail: m,
@@ -594,35 +614,35 @@ const fe = ({
594
614
  hideSettlementCopy: g,
595
615
  showAppLogo: $,
596
616
  showOnrampFirst: y,
597
- debitCardAlias: I,
617
+ debitCardAlias: x,
598
618
  copyOverrides: w,
599
- stableDepositAddressKey: x,
619
+ stableDepositAddressKey: I,
600
620
  sessionId: v,
601
621
  sessionMetadata: S,
602
622
  disableWithdrawToSelfSuggestion: E,
603
- theme: U,
604
- walletProvider: M,
605
- localStorageProvider: C,
606
- onOpen: k,
623
+ theme: k,
624
+ walletProvider: U,
625
+ localStorageProvider: M,
626
+ onOpen: C,
607
627
  onSuccess: P,
608
- onClose: D,
609
- autoCloseOnSuccess: T,
610
- popupsBlocked: R,
611
- baseUrl: B,
612
- debug: W
628
+ onClose: z,
629
+ autoCloseOnSuccess: j,
630
+ popupsBlocked: T,
631
+ baseUrl: R,
632
+ debug: B
613
633
  }), [
614
634
  s,
615
635
  t,
616
636
  e,
617
637
  i,
618
638
  o,
619
- r,
620
- p,
639
+ n,
640
+ c,
621
641
  d,
622
642
  a,
623
643
  f,
624
- c,
625
- n,
644
+ p,
645
+ r,
626
646
  h,
627
647
  l,
628
648
  m,
@@ -630,41 +650,41 @@ const fe = ({
630
650
  g,
631
651
  $,
632
652
  y,
633
- I,
634
- w,
635
653
  x,
654
+ w,
655
+ I,
636
656
  v,
637
657
  S,
638
658
  E,
659
+ k,
639
660
  U,
640
661
  M,
641
662
  C,
642
- k,
643
663
  P,
644
- D,
664
+ z,
665
+ j,
645
666
  T,
646
667
  R,
647
- B,
648
- W
668
+ B
649
669
  ]);
650
670
  return {
651
671
  openGlideDeposit: A.open,
652
672
  externalUrl: A.externalUrl,
653
673
  opts: A.opts
654
674
  };
655
- }, ye = ({
675
+ }, Ae = ({
656
676
  app: s,
657
677
  preferGaslessPayment: t,
658
678
  chainIds: e,
659
679
  excludeChainIds: i,
660
680
  excludeCurrencyTiers: o,
661
- excludeFundingSources: r,
662
- fundingSources: p,
681
+ excludeFundingSources: n,
682
+ fundingSources: c,
663
683
  allowedPaymentCurrencies: d,
664
684
  appMetadata: a,
665
685
  enableRefundEmails: f,
666
- payerEmail: c,
667
- hideSettlementCopy: n,
686
+ payerEmail: p,
687
+ hideSettlementCopy: r,
668
688
  showAppLogo: h,
669
689
  showOnrampFirst: l,
670
690
  debitCardAlias: m,
@@ -672,31 +692,31 @@ const fe = ({
672
692
  amount: g,
673
693
  sessionId: $,
674
694
  sessionMetadata: y,
675
- theme: I,
695
+ theme: x,
676
696
  walletProvider: w,
677
- localStorageProvider: x,
697
+ localStorageProvider: I,
678
698
  onOpen: v,
679
699
  onSuccess: S,
680
700
  onClose: E,
681
- autoCloseOnSuccess: U,
682
- popupsBlocked: M,
683
- baseUrl: C,
684
- debug: k
701
+ autoCloseOnSuccess: k,
702
+ popupsBlocked: U,
703
+ baseUrl: M,
704
+ debug: C
685
705
  }) => {
686
- const P = G(() => new H({
706
+ const P = G(() => new O({
687
707
  app: s,
688
708
  preferGaslessPayment: t,
689
709
  chainIds: e,
690
710
  excludeChainIds: i,
691
711
  excludeCurrencyTiers: o,
692
- excludeFundingSources: r,
693
- fundingSources: p,
712
+ excludeFundingSources: n,
713
+ fundingSources: c,
694
714
  allowedPaymentCurrencies: d,
695
715
  appMetadata: a,
696
716
  enableRefundEmails: f,
697
- payerEmail: c,
717
+ payerEmail: p,
698
718
  mode: "pay",
699
- hideSettlementCopy: n,
719
+ hideSettlementCopy: r,
700
720
  showAppLogo: h,
701
721
  showOnrampFirst: l,
702
722
  debitCardAlias: m,
@@ -704,29 +724,29 @@ const fe = ({
704
724
  sessionId: $,
705
725
  amount: g,
706
726
  sessionMetadata: y,
707
- theme: I,
727
+ theme: x,
708
728
  walletProvider: w,
709
- localStorageProvider: x,
729
+ localStorageProvider: I,
710
730
  onOpen: v,
711
731
  onSuccess: S,
712
732
  onClose: E,
713
- autoCloseOnSuccess: U,
714
- popupsBlocked: M,
715
- baseUrl: C,
716
- debug: k
733
+ autoCloseOnSuccess: k,
734
+ popupsBlocked: U,
735
+ baseUrl: M,
736
+ debug: C
717
737
  }), [
718
738
  s,
719
739
  t,
720
740
  e,
721
741
  i,
722
742
  o,
723
- r,
724
- p,
743
+ n,
744
+ c,
725
745
  d,
726
746
  a,
727
747
  f,
728
- c,
729
- n,
748
+ p,
749
+ r,
730
750
  h,
731
751
  l,
732
752
  m,
@@ -734,35 +754,35 @@ const fe = ({
734
754
  $,
735
755
  g,
736
756
  y,
737
- I,
738
- w,
739
757
  x,
758
+ w,
759
+ I,
740
760
  v,
741
761
  S,
742
762
  E,
763
+ k,
743
764
  U,
744
765
  M,
745
- C,
746
- k
766
+ C
747
767
  ]);
748
768
  return {
749
769
  openGlidePay: P.open,
750
770
  externalUrl: P.externalUrl,
751
771
  opts: P.opts
752
772
  };
753
- }, we = ({
773
+ }, De = ({
754
774
  app: s,
755
775
  evm: t,
756
776
  approval: e,
757
777
  preferGaslessPayment: i,
758
778
  chainIds: o,
759
- excludeChainIds: r,
760
- excludeCurrencyTiers: p,
779
+ excludeChainIds: n,
780
+ excludeCurrencyTiers: c,
761
781
  excludeFundingSources: d,
762
782
  sessionMetadata: a,
763
783
  showAppLogo: f,
764
- showOnrampFirst: c,
765
- debitCardAlias: n,
784
+ showOnrampFirst: p,
785
+ debitCardAlias: r,
766
786
  copyOverrides: h,
767
787
  theme: l,
768
788
  walletProvider: m,
@@ -770,24 +790,24 @@ const fe = ({
770
790
  onOpen: g,
771
791
  onSuccess: $,
772
792
  onClose: y,
773
- autoCloseOnSuccess: I,
793
+ autoCloseOnSuccess: x,
774
794
  popupsBlocked: w,
775
- baseUrl: x,
795
+ baseUrl: I,
776
796
  debug: v
777
797
  }) => {
778
- const S = G(() => new H({
798
+ const S = G(() => new O({
779
799
  app: s,
780
800
  evm: t,
781
801
  approval: e,
782
802
  preferGaslessPayment: i,
783
803
  chainIds: o,
784
- excludeChainIds: r,
785
- excludeCurrencyTiers: p,
804
+ excludeChainIds: n,
805
+ excludeCurrencyTiers: c,
786
806
  excludeFundingSources: d,
787
807
  sessionMetadata: a,
788
808
  showAppLogo: f,
789
- showOnrampFirst: c,
790
- debitCardAlias: n,
809
+ showOnrampFirst: p,
810
+ debitCardAlias: r,
791
811
  copyOverrides: h,
792
812
  mode: "call",
793
813
  theme: l,
@@ -796,9 +816,9 @@ const fe = ({
796
816
  onOpen: g,
797
817
  onSuccess: $,
798
818
  onClose: y,
799
- autoCloseOnSuccess: I,
819
+ autoCloseOnSuccess: x,
800
820
  popupsBlocked: w,
801
- baseUrl: x,
821
+ baseUrl: I,
802
822
  debug: v
803
823
  }), [
804
824
  s,
@@ -806,13 +826,13 @@ const fe = ({
806
826
  e,
807
827
  i,
808
828
  o,
809
- r,
810
- p,
829
+ n,
830
+ c,
811
831
  d,
812
832
  a,
813
833
  f,
814
- c,
815
- n,
834
+ p,
835
+ r,
816
836
  h,
817
837
  l,
818
838
  m,
@@ -820,9 +840,9 @@ const fe = ({
820
840
  g,
821
841
  $,
822
842
  y,
823
- I,
824
- w,
825
843
  x,
844
+ w,
845
+ I,
826
846
  v
827
847
  ]);
828
848
  return {
@@ -830,19 +850,19 @@ const fe = ({
830
850
  externalUrl: S.externalUrl,
831
851
  opts: S.opts
832
852
  };
833
- }, ve = ({
853
+ }, ze = ({
834
854
  app: s,
835
855
  recipient: t,
836
856
  chainId: e,
837
857
  currencyId: i,
838
858
  preferGaslessPayment: o,
839
- chainIds: r,
840
- excludeChainIds: p,
859
+ chainIds: n,
860
+ excludeChainIds: c,
841
861
  excludeCurrencyTiers: d,
842
862
  excludeFundingSources: a,
843
863
  sessionMetadata: f,
844
- showAppLogo: c,
845
- showOnrampFirst: n,
864
+ showAppLogo: p,
865
+ showOnrampFirst: r,
846
866
  debitCardAlias: h,
847
867
  copyOverrides: l,
848
868
  theme: m,
@@ -850,23 +870,23 @@ const fe = ({
850
870
  localStorageProvider: g,
851
871
  onOpen: $,
852
872
  onSuccess: y,
853
- onClose: I,
873
+ onClose: x,
854
874
  autoCloseOnSuccess: w,
855
- baseUrl: x
875
+ baseUrl: I
856
876
  }) => {
857
- const v = G(() => new H({
877
+ const v = G(() => new O({
858
878
  app: s,
859
879
  recipient: t,
860
880
  chainId: e,
861
881
  currencyId: i,
862
882
  preferGaslessPayment: o,
863
- chainIds: r,
864
- excludeChainIds: p,
883
+ chainIds: n,
884
+ excludeChainIds: c,
865
885
  excludeCurrencyTiers: d,
866
886
  excludeFundingSources: a,
867
887
  sessionMetadata: f,
868
- showAppLogo: c,
869
- showOnrampFirst: n,
888
+ showAppLogo: p,
889
+ showOnrampFirst: r,
870
890
  debitCardAlias: h,
871
891
  copyOverrides: l,
872
892
  mode: "buy",
@@ -875,22 +895,22 @@ const fe = ({
875
895
  localStorageProvider: g,
876
896
  onOpen: $,
877
897
  onSuccess: y,
878
- onClose: I,
898
+ onClose: x,
879
899
  autoCloseOnSuccess: w,
880
- baseUrl: x
900
+ baseUrl: I
881
901
  }), [
882
902
  s,
883
903
  t,
884
904
  e,
885
905
  i,
886
906
  o,
887
- r,
888
- p,
907
+ n,
908
+ c,
889
909
  d,
890
910
  a,
891
911
  f,
892
- c,
893
- n,
912
+ p,
913
+ r,
894
914
  h,
895
915
  l,
896
916
  m,
@@ -898,16 +918,16 @@ const fe = ({
898
918
  g,
899
919
  $,
900
920
  y,
901
- I,
921
+ x,
902
922
  w,
903
- x
923
+ I
904
924
  ]);
905
925
  return {
906
926
  openGlideBuy: v.open,
907
927
  externalUrl: v.externalUrl,
908
928
  opts: v.opts
909
929
  };
910
- }, be = Object.freeze({
930
+ }, je = Object.freeze({
911
931
  getItem: (s) => new Promise((t, e) => {
912
932
  try {
913
933
  const i = localStorage.getItem(s);
@@ -940,11 +960,11 @@ const fe = ({
940
960
  })
941
961
  });
942
962
  export {
943
- H as GlideDeposit,
944
- be as browserLocalStorageProvider,
945
- ue as initializeParentBridge,
946
- ve as useGlideBuy,
947
- we as useGlideCall,
948
- fe as useGlideDeposit,
949
- ye as useGlidePay
963
+ O as GlideDeposit,
964
+ je as browserLocalStorageProvider,
965
+ me as initializeParentBridge,
966
+ ze as useGlideBuy,
967
+ De as useGlideCall,
968
+ Ce as useGlideDeposit,
969
+ Ae as useGlidePay
950
970
  };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,2 @@
1
- export * from './GlideDeposit.ts';
2
- export * from './useGlideDeposit.ts';
3
- export * from './useGlidePay.ts';
4
- export * from './useGlideCall.ts';
5
- export * from './useGlideBuy.ts';
6
- export * from './theme.ts';
7
- export * from './browserLocalStorageProvider.ts';
8
- export * from './walletProviderBridge.ts';
1
+ export * from './pkg/index'
2
+ export {}
@@ -0,0 +1,8 @@
1
+ export * from './GlideDeposit.ts';
2
+ export * from './useGlideDeposit.ts';
3
+ export * from './useGlidePay.ts';
4
+ export * from './useGlideCall.ts';
5
+ export * from './useGlideBuy.ts';
6
+ export * from './theme.ts';
7
+ export * from './browserLocalStorageProvider.ts';
8
+ export * from './walletProviderBridge.ts';
@@ -14,6 +14,9 @@ export interface EIP1193Provider {
14
14
  }): Promise<unknown>;
15
15
  on?(event: string, listener: (...args: unknown[]) => void): void;
16
16
  removeListener?(event: string, listener: (...args: unknown[]) => void): void;
17
+ isConnected?: boolean;
18
+ chainId?: string;
19
+ selectedAddress?: string;
17
20
  }
18
21
  export interface EIP6963ProviderInfo {
19
22
  uuid: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paywithglide/glide-react",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -17,12 +17,12 @@
17
17
  "sideEffects": false,
18
18
  "scripts": {
19
19
  "dev": "vite",
20
- "build": "tsc --p ./tsconfig.build.json && vite build",
20
+ "build": "bun run lint && vite build",
21
21
  "build-web": "tsc --p ./tsconfig.build.json && vite build --mode web",
22
22
  "build-chromeext": "tsc --p ./tsconfig.build.json && vite build --mode chromeext:popup && vite build --mode chromeext:content && vite build --mode chromeext:background",
23
23
  "lint": "prettier --check . && eslint . --max-warnings 0 && tsc --p ./tsconfig.build.json",
24
24
  "preview": "vite preview",
25
- "prepublishOnly": "npm run build"
25
+ "prepublishOnly": "bun run build"
26
26
  },
27
27
  "dependencies": {
28
28
  "@paywithglide/glide-js": "0.13.10"
File without changes
File without changes
File without changes