@paywithglide/glide-react 0.0.36 → 0.0.37

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.
@@ -117,6 +117,7 @@ export type GlideDepositOptions = {
117
117
  autoCloseOnSuccess?: boolean;
118
118
  container?: HTMLElement;
119
119
  disableWithdrawToSelfSuggestion?: boolean;
120
+ hideSettlementCopy?: boolean;
120
121
  theme?: GlideWidgetTheme;
121
122
  popupsBlocked?: boolean;
122
123
  baseUrl?: string;
package/dist/glide.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var _ = Object.defineProperty;
2
2
  var ee = (s, t, e) => t in s ? _(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var z = (s, t, e) => ee(s, typeof t != "symbol" ? t + "" : t, e);
4
- import { useMemo as T } from "react";
3
+ var T = (s, t, e) => ee(s, typeof t != "symbol" ? t + "" : t, e);
4
+ import { useMemo as A } from "react";
5
5
  function te(s, { strict: t = !0 } = {}) {
6
6
  return !s || typeof s != "string" ? !1 : t ? /^0x[0-9a-fA-F]*$/.test(s) : s.startsWith("0x");
7
7
  }
@@ -9,7 +9,7 @@ function N(s) {
9
9
  return te(s, { strict: !1 }) ? Math.ceil((s.length - 2) / 2) : s.length;
10
10
  }
11
11
  const K = "2.21.51";
12
- let U = {
12
+ let z = {
13
13
  getDocsUrl: ({ docsBaseUrl: s, docsPath: t = "", docsSlug: e }) => t ? `${s ?? "https://viem.sh"}${t}${e ? `#${e}` : ""}` : void 0,
14
14
  version: `viem@${K}`
15
15
  };
@@ -19,13 +19,13 @@ class S extends Error {
19
19
  const i = (() => {
20
20
  var n;
21
21
  return e.cause instanceof S ? e.cause.details : (n = e.cause) != null && n.message ? e.cause.message : e.details;
22
- })(), o = e.cause instanceof S && e.cause.docsPath || e.docsPath, r = (a = U.getDocsUrl) == null ? void 0 : a.call(U, { ...e, docsPath: o }), c = [
22
+ })(), o = e.cause instanceof S && e.cause.docsPath || e.docsPath, r = (a = z.getDocsUrl) == null ? void 0 : a.call(z, { ...e, docsPath: o }), c = [
23
23
  t || "An error occurred.",
24
24
  "",
25
25
  ...e.metaMessages ? [...e.metaMessages, ""] : [],
26
26
  ...r ? [`Docs: ${r}`] : [],
27
27
  ...i ? [`Details: ${i}`] : [],
28
- ...U.version ? [`Version: ${U.version}`] : []
28
+ ...z.version ? [`Version: ${z.version}`] : []
29
29
  ].join(`
30
30
  `);
31
31
  super(c, e.cause ? { cause: e.cause } : void 0), Object.defineProperty(this, "details", {
@@ -72,7 +72,7 @@ class V extends S {
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 M(s, { dir: t, size: e = 32 } = {}) {
75
+ function D(s, { dir: t, size: e = 32 } = {}) {
76
76
  return typeof s == "string" ? se(s, { dir: t, size: e }) : ie(s, { dir: t, size: e });
77
77
  }
78
78
  function se(s, { dir: t, size: e = 32 } = {}) {
@@ -126,14 +126,14 @@ function ae(s, t = {}) {
126
126
  }
127
127
  function ce(s, t = {}) {
128
128
  const e = `0x${Number(s)}`;
129
- return typeof t.size == "number" ? (q(e, { size: t.size }), M(e, { size: t.size })) : e;
129
+ return typeof t.size == "number" ? (q(e, { size: t.size }), D(e, { size: t.size })) : e;
130
130
  }
131
131
  function J(s, t = {}) {
132
132
  let e = "";
133
133
  for (let o = 0; o < s.length; o++)
134
134
  e += ne[s[o]];
135
135
  const i = `0x${e}`;
136
- return typeof t.size == "number" ? (q(i, { size: t.size }), M(i, { dir: "right", size: t.size })) : i;
136
+ return typeof t.size == "number" ? (q(i, { size: t.size }), D(i, { dir: "right", size: t.size })) : i;
137
137
  }
138
138
  function de(s, t = {}) {
139
139
  const { signed: e, size: i } = t, o = BigInt(s);
@@ -151,17 +151,17 @@ function de(s, t = {}) {
151
151
  });
152
152
  }
153
153
  const a = `0x${(e && o < 0 ? (1n << BigInt(i * 8)) + BigInt(o) : o).toString(16)}`;
154
- return i ? M(a, { size: i }) : a;
154
+ return i ? D(a, { size: i }) : a;
155
155
  }
156
156
  const le = /* @__PURE__ */ new TextEncoder();
157
157
  function pe(s, t = {}) {
158
158
  const e = le.encode(s);
159
159
  return J(e, t);
160
160
  }
161
- class A {
161
+ class M {
162
162
  constructor(t) {
163
- z(this, "opts");
164
- z(this, "open", () => {
163
+ T(this, "opts");
164
+ T(this, "open", () => {
165
165
  if (!(!this.opts.container && document.body.classList.contains("glide-deposit-open"))) {
166
166
  if (this.opts.container || document.body.classList.add("glide-deposit-open"), (this.opts.mode === "deposit" || this.opts.mode === "buy") && !this.opts.recipient)
167
167
  throw new Error("recipient is required for deposit/buy mode");
@@ -172,8 +172,8 @@ class A {
172
172
  this.openUrl(`${this.baseUrl}${this.opts.app}?init=true&embed=true`), this.initialize();
173
173
  }
174
174
  });
175
- z(this, "iframeEventHandler", async (t) => {
176
- var i, o, r, c, a, n, h, u, m, g, f, y, w, d, l, b, v, $, I, P, E, k, x, D, C, G, W, j, B, H, O, L, R;
175
+ T(this, "iframeEventHandler", async (t) => {
176
+ var i, o, r, c, a, n, h, u, m, g, f, y, w, d, l, b, $, v, I, P, E, k, U, x, C, G, W, j, B, H, O, L, R;
177
177
  const e = t.data;
178
178
  switch (e.type) {
179
179
  case "sendInit": {
@@ -200,6 +200,7 @@ class A {
200
200
  sessionMetadata: this.opts.sessionMetadata,
201
201
  autoCloseOnSuccess: this.opts.autoCloseOnSuccess,
202
202
  disableWithdrawToSelfSuggestion: this.opts.disableWithdrawToSelfSuggestion,
203
+ hideSettlementCopy: this.opts.hideSettlementCopy,
203
204
  theme: {
204
205
  ...this.opts.theme || {},
205
206
  colorScheme: ((n = this.opts.theme) == null ? void 0 : n.colorScheme) || getComputedStyle(document.documentElement).colorScheme || ""
@@ -261,10 +262,10 @@ class A {
261
262
  (l = (d = this.opts) == null ? void 0 : d.onSuccess) == null || l.call(d, e.hash, e.session);
262
263
  break;
263
264
  case "close":
264
- this.removeIframe(), this.destroy(), (v = (b = this.opts) == null ? void 0 : b.onClose) == null || v.call(b);
265
+ this.removeIframe(), this.destroy(), ($ = (b = this.opts) == null ? void 0 : b.onClose) == null || $.call(b);
265
266
  break;
266
267
  case "setMode":
267
- (I = ($ = this.opts) == null ? void 0 : $.onSetMode) == null || I.call($, e.mode);
268
+ (I = (v = this.opts) == null ? void 0 : v.onSetMode) == null || I.call(v, e.mode);
268
269
  break;
269
270
  case "switchChain":
270
271
  if (!this.opts.walletProvider)
@@ -281,7 +282,7 @@ class A {
281
282
  this.baseUrl
282
283
  );
283
284
  } catch (p) {
284
- (x = (k = this.iframe) == null ? void 0 : k.contentWindow) == null || x.postMessage(
285
+ (U = (k = this.iframe) == null ? void 0 : k.contentWindow) == null || U.postMessage(
285
286
  {
286
287
  type: "didSwitchChain",
287
288
  success: !1,
@@ -299,7 +300,7 @@ class A {
299
300
  const p = await this.opts.walletProvider.sendTransactionAsync(
300
301
  e.tx
301
302
  );
302
- (C = (D = this.iframe) == null ? void 0 : D.contentWindow) == null || C.postMessage(
303
+ (C = (x = this.iframe) == null ? void 0 : x.contentWindow) == null || C.postMessage(
303
304
  {
304
305
  type: "didSendTransaction",
305
306
  success: !0,
@@ -366,7 +367,7 @@ class A {
366
367
  var t, e, i, o;
367
368
  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=${ae(
368
369
  this.opts.evm.value || 0n
369
- )}` : ""}${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.excludeChainIds) != null && t.length ? `&excludeChainIds=${this.opts.excludeChainIds.join(",")}` : ""}${(e = this.opts.excludeCurrencyTiers) != null && e.length ? `&excludeCurrencyTiers=${this.opts.excludeCurrencyTiers.join(",")}` : ""}${(i = this.opts.excludeFundingSources) != null && i.length ? `&excludeFundingSources=${this.opts.excludeFundingSources.join(",")}` : ""}${(o = this.opts.fundingSources) != null && o.length ? `&fundingSources=${this.opts.fundingSources.join(",")}` : ""}${this.opts.debug ? "&debug=true" : ""}${this.opts.popupsBlocked ? "&popupsBlocked=true" : ""}${this.opts.disableWithdrawToSelfSuggestion ? "&disableWithdrawToSelfSuggestion=true" : ""}${this.opts.gasRefuelAmountPerChain ? `&gasRefuelAmountPerChain=${encodeURIComponent(JSON.stringify(this.opts.gasRefuelAmountPerChain))}` : ""}`;
370
+ )}` : ""}${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.excludeChainIds) != null && t.length ? `&excludeChainIds=${this.opts.excludeChainIds.join(",")}` : ""}${(e = this.opts.excludeCurrencyTiers) != null && e.length ? `&excludeCurrencyTiers=${this.opts.excludeCurrencyTiers.join(",")}` : ""}${(i = this.opts.excludeFundingSources) != null && i.length ? `&excludeFundingSources=${this.opts.excludeFundingSources.join(",")}` : ""}${(o = this.opts.fundingSources) != null && o.length ? `&fundingSources=${this.opts.fundingSources.join(",")}` : ""}${this.opts.debug ? "&debug=true" : ""}${this.opts.popupsBlocked ? "&popupsBlocked=true" : ""}${this.opts.disableWithdrawToSelfSuggestion ? "&disableWithdrawToSelfSuggestion=true" : ""}${this.opts.hideSettlementCopy ? "&hideSettlementCopy=true" : ""}${this.opts.gasRefuelAmountPerChain ? `&gasRefuelAmountPerChain=${encodeURIComponent(JSON.stringify(this.opts.gasRefuelAmountPerChain))}` : ""}`;
370
371
  }
371
372
  initialize() {
372
373
  window.addEventListener("message", this.iframeEventHandler);
@@ -414,21 +415,22 @@ const me = ({
414
415
  excludeFundingSources: h,
415
416
  fundingSources: u,
416
417
  mode: m,
417
- sessionId: g,
418
- sessionMetadata: f,
419
- disableWithdrawToSelfSuggestion: y,
420
- theme: w,
421
- walletProvider: d,
422
- localStorageProvider: l,
423
- onOpen: b,
418
+ hideSettlementCopy: g,
419
+ sessionId: f,
420
+ sessionMetadata: y,
421
+ disableWithdrawToSelfSuggestion: w,
422
+ theme: d,
423
+ walletProvider: l,
424
+ localStorageProvider: b,
425
+ onOpen: $,
424
426
  onSuccess: v,
425
- onClose: $,
426
- autoCloseOnSuccess: I,
427
- popupsBlocked: P,
428
- baseUrl: E,
429
- debug: k
427
+ onClose: I,
428
+ autoCloseOnSuccess: P,
429
+ popupsBlocked: E,
430
+ baseUrl: k,
431
+ debug: U
430
432
  }) => {
431
- const x = T(() => new A({
433
+ const x = A(() => new M({
432
434
  app: s,
433
435
  recipient: t,
434
436
  chainId: e,
@@ -441,19 +443,20 @@ const me = ({
441
443
  excludeFundingSources: h,
442
444
  fundingSources: u,
443
445
  mode: m,
444
- sessionId: g,
445
- sessionMetadata: f,
446
- disableWithdrawToSelfSuggestion: y,
447
- theme: w,
448
- walletProvider: d,
449
- localStorageProvider: l,
450
- onOpen: b,
446
+ hideSettlementCopy: g,
447
+ sessionId: f,
448
+ sessionMetadata: y,
449
+ disableWithdrawToSelfSuggestion: w,
450
+ theme: d,
451
+ walletProvider: l,
452
+ localStorageProvider: b,
453
+ onOpen: $,
451
454
  onSuccess: v,
452
- onClose: $,
453
- autoCloseOnSuccess: I,
454
- popupsBlocked: P,
455
- baseUrl: E,
456
- debug: k
455
+ onClose: I,
456
+ autoCloseOnSuccess: P,
457
+ popupsBlocked: E,
458
+ baseUrl: k,
459
+ debug: U
457
460
  }), [
458
461
  s,
459
462
  t,
@@ -474,12 +477,13 @@ const me = ({
474
477
  d,
475
478
  l,
476
479
  b,
477
- v,
478
480
  $,
481
+ v,
479
482
  I,
480
483
  P,
481
484
  E,
482
- k
485
+ k,
486
+ U
483
487
  ]);
484
488
  return {
485
489
  openGlideDeposit: x.open,
@@ -493,21 +497,22 @@ const me = ({
493
497
  excludeCurrencyTiers: i,
494
498
  excludeFundingSources: o,
495
499
  fundingSources: r,
496
- amount: c,
497
- sessionId: a,
498
- sessionMetadata: n,
499
- theme: h,
500
- walletProvider: u,
501
- localStorageProvider: m,
502
- onOpen: g,
503
- onSuccess: f,
504
- onClose: y,
505
- autoCloseOnSuccess: w,
506
- popupsBlocked: d,
507
- baseUrl: l,
508
- debug: b
500
+ hideSettlementCopy: c,
501
+ amount: a,
502
+ sessionId: n,
503
+ sessionMetadata: h,
504
+ theme: u,
505
+ walletProvider: m,
506
+ localStorageProvider: g,
507
+ onOpen: f,
508
+ onSuccess: y,
509
+ onClose: w,
510
+ autoCloseOnSuccess: d,
511
+ popupsBlocked: l,
512
+ baseUrl: b,
513
+ debug: $
509
514
  }) => {
510
- const v = T(() => new A({
515
+ const v = A(() => new M({
511
516
  app: s,
512
517
  preferGaslessPayment: t,
513
518
  excludeChainIds: e,
@@ -515,19 +520,20 @@ const me = ({
515
520
  excludeFundingSources: o,
516
521
  fundingSources: r,
517
522
  mode: "pay",
518
- sessionId: a,
519
- amount: c,
520
- sessionMetadata: n,
521
- theme: h,
522
- walletProvider: u,
523
- localStorageProvider: m,
524
- onOpen: g,
525
- onSuccess: f,
526
- onClose: y,
527
- autoCloseOnSuccess: w,
528
- popupsBlocked: d,
529
- baseUrl: l,
530
- debug: b
523
+ hideSettlementCopy: c,
524
+ sessionId: n,
525
+ amount: a,
526
+ sessionMetadata: h,
527
+ theme: u,
528
+ walletProvider: m,
529
+ localStorageProvider: g,
530
+ onOpen: f,
531
+ onSuccess: y,
532
+ onClose: w,
533
+ autoCloseOnSuccess: d,
534
+ popupsBlocked: l,
535
+ baseUrl: b,
536
+ debug: $
531
537
  }), [
532
538
  s,
533
539
  t,
@@ -535,9 +541,9 @@ const me = ({
535
541
  i,
536
542
  o,
537
543
  r,
538
- a,
539
544
  c,
540
545
  n,
546
+ a,
541
547
  h,
542
548
  u,
543
549
  m,
@@ -547,7 +553,8 @@ const me = ({
547
553
  w,
548
554
  d,
549
555
  l,
550
- b
556
+ b,
557
+ $
551
558
  ]);
552
559
  return {
553
560
  openGlidePay: v.open,
@@ -574,7 +581,7 @@ const me = ({
574
581
  baseUrl: d,
575
582
  debug: l
576
583
  }) => {
577
- const b = T(() => new A({
584
+ const b = A(() => new M({
578
585
  app: s,
579
586
  evm: t,
580
587
  approval: e,
@@ -638,7 +645,7 @@ const me = ({
638
645
  autoCloseOnSuccess: w,
639
646
  baseUrl: d
640
647
  }) => {
641
- const l = T(() => new A({
648
+ const l = A(() => new M({
642
649
  app: s,
643
650
  recipient: t,
644
651
  chainId: e,
@@ -714,7 +721,7 @@ const me = ({
714
721
  })
715
722
  });
716
723
  export {
717
- A as GlideDeposit,
724
+ M as GlideDeposit,
718
725
  we as browserLocalStorageProvider,
719
726
  ye as useGlideBuy,
720
727
  fe as useGlideCall,
@@ -15,6 +15,7 @@ interface UseGlideDepositProps {
15
15
  fundingSources?: FundingSource[];
16
16
  mode?: "deposit" | "withdraw";
17
17
  hideWithdrawAddress?: boolean;
18
+ hideSettlementCopy?: boolean;
18
19
  sessionId?: string;
19
20
  sessionMetadata?: string;
20
21
  disableWithdrawToSelfSuggestion?: boolean;
@@ -29,7 +30,7 @@ interface UseGlideDepositProps {
29
30
  baseUrl?: string;
30
31
  debug?: boolean;
31
32
  }
32
- export declare const useGlideDeposit: ({ app, recipient, chainId, currencyId, amount, gasRefuelAmountPerChain, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, fundingSources, mode, sessionId, sessionMetadata, disableWithdrawToSelfSuggestion, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideDepositProps) => {
33
+ export declare const useGlideDeposit: ({ app, recipient, chainId, currencyId, amount, gasRefuelAmountPerChain, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, fundingSources, mode, hideSettlementCopy, sessionId, sessionMetadata, disableWithdrawToSelfSuggestion, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideDepositProps) => {
33
34
  openGlideDeposit: () => void;
34
35
  externalUrl: string;
35
36
  opts: import('./GlideDeposit.ts').GlideDepositOptions;
@@ -9,6 +9,7 @@ type UseGlidePayProps = {
9
9
  excludeCurrencyTiers?: ("tier1" | "tier2" | "tier3")[];
10
10
  excludeFundingSources?: FundingSource[];
11
11
  fundingSources?: FundingSource[];
12
+ hideSettlementCopy?: boolean;
12
13
  sessionId?: string;
13
14
  sessionMetadata?: string;
14
15
  theme?: GlideWidgetTheme;
@@ -22,7 +23,7 @@ type UseGlidePayProps = {
22
23
  baseUrl?: string;
23
24
  debug?: boolean;
24
25
  };
25
- export declare const useGlidePay: ({ app, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, fundingSources, amount, sessionId, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlidePayProps) => {
26
+ export declare const useGlidePay: ({ app, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, fundingSources, hideSettlementCopy, amount, sessionId, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlidePayProps) => {
26
27
  openGlidePay: () => void;
27
28
  externalUrl: string;
28
29
  opts: import('./GlideDeposit.ts').GlideDepositOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paywithglide/glide-react",
3
- "version": "0.0.36",
3
+ "version": "0.0.37",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -20,7 +20,7 @@
20
20
  "build": "tsc --p ./tsconfig.build.json && 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
- "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
23
+ "lint": "prettier --check . && eslint .",
24
24
  "preview": "vite preview",
25
25
  "prepublishOnly": "npm run build"
26
26
  },
@@ -39,6 +39,7 @@
39
39
  "eslint-plugin-react-hooks": "^5.0.0",
40
40
  "eslint-plugin-react-refresh": "^0.4.14",
41
41
  "globals": "^15.12.0",
42
+ "prettier": "^3.6.2",
42
43
  "react": "^18.3.1",
43
44
  "react-dom": "^18.3.1",
44
45
  "typescript": "~5.6.2",