@swype-org/deposit 0.3.22 → 0.3.26

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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { D as DepositStatus, a as DepositResult, b as DepositError, c as DepositConfig, d as DepositRequest } from './types-iQf3f-_m.cjs';
2
- export { C as CheckoutConfig, e as CheckoutError, f as CheckoutErrorCode, g as CheckoutStatus, h as DepositErrorCode, S as SignerFunction, i as SignerRequest, j as SignerResponse, T as TransferSummary, k as getDisplayMessage } from './types-iQf3f-_m.cjs';
1
+ import { D as DepositStatus, a as DepositResult, b as DepositError, c as DepositConfig, d as DepositRequest } from './types-BjnQ2ux2.cjs';
2
+ export { C as CheckoutConfig, e as CheckoutError, f as CheckoutErrorCode, g as CheckoutStatus, h as DepositErrorCode, S as SignerFunction, i as SignerRequest, j as SignerResponse, T as TransferSummary, k as getDisplayMessage } from './types-BjnQ2ux2.cjs';
3
3
 
4
4
  declare const DEFAULT_WEBVIEW_BASE_URL = "https://pay.blink.cash";
5
5
  declare const SANDBOX_WEBVIEW_BASE_URL = "https://pay-sandbox.blink.cash";
@@ -94,6 +94,18 @@ declare class Deposit {
94
94
  * config, so the full widget renders only when both allow it.
95
95
  */
96
96
  private applyFullWidgetParam;
97
+ /**
98
+ * Appends `appearance=dark` (or `appearance=system`) to the hosted-flow URL.
99
+ * An explicit `appearance: { theme }` config always wins — including
100
+ * `theme: 'light'`, which pins light regardless of the merchant page. When
101
+ * the merchant passes no theme, the default follows the merchant page's own
102
+ * declared color scheme (see {@link detectMerchantColorScheme}) so the flow
103
+ * doesn't render a light modal on a page that says it is dark. Absence of
104
+ * the param means light. The hosted flow resolves `system` against the
105
+ * user's `prefers-color-scheme`. Applied alongside the full-widget param on
106
+ * every hosted/preload URL.
107
+ */
108
+ private applyAppearanceParam;
97
109
  /** Fluid is the default; `layout: 'fixed'` opts back into the legacy container. */
98
110
  private isFluidLayout;
99
111
  /**
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { D as DepositStatus, a as DepositResult, b as DepositError, c as DepositConfig, d as DepositRequest } from './types-iQf3f-_m.js';
2
- export { C as CheckoutConfig, e as CheckoutError, f as CheckoutErrorCode, g as CheckoutStatus, h as DepositErrorCode, S as SignerFunction, i as SignerRequest, j as SignerResponse, T as TransferSummary, k as getDisplayMessage } from './types-iQf3f-_m.js';
1
+ import { D as DepositStatus, a as DepositResult, b as DepositError, c as DepositConfig, d as DepositRequest } from './types-BjnQ2ux2.js';
2
+ export { C as CheckoutConfig, e as CheckoutError, f as CheckoutErrorCode, g as CheckoutStatus, h as DepositErrorCode, S as SignerFunction, i as SignerRequest, j as SignerResponse, T as TransferSummary, k as getDisplayMessage } from './types-BjnQ2ux2.js';
3
3
 
4
4
  declare const DEFAULT_WEBVIEW_BASE_URL = "https://pay.blink.cash";
5
5
  declare const SANDBOX_WEBVIEW_BASE_URL = "https://pay-sandbox.blink.cash";
@@ -94,6 +94,18 @@ declare class Deposit {
94
94
  * config, so the full widget renders only when both allow it.
95
95
  */
96
96
  private applyFullWidgetParam;
97
+ /**
98
+ * Appends `appearance=dark` (or `appearance=system`) to the hosted-flow URL.
99
+ * An explicit `appearance: { theme }` config always wins — including
100
+ * `theme: 'light'`, which pins light regardless of the merchant page. When
101
+ * the merchant passes no theme, the default follows the merchant page's own
102
+ * declared color scheme (see {@link detectMerchantColorScheme}) so the flow
103
+ * doesn't render a light modal on a page that says it is dark. Absence of
104
+ * the param means light. The hosted flow resolves `system` against the
105
+ * user's `prefers-color-scheme`. Applied alongside the full-widget param on
106
+ * every hosted/preload URL.
107
+ */
108
+ private applyAppearanceParam;
97
109
  /** Fluid is the default; `layout: 'fixed'` opts back into the legacy container. */
98
110
  private isFluidLayout;
99
111
  /**
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { ALLOWED_RPC_METHODS, BRIDGE_PROTOCOL_VERSION, Checkout, CheckoutError, DEFAULT_WEBVIEW_BASE_URL, Deposit, DepositError, SANDBOX_WEBVIEW_BASE_URL, attachRpcHost, createWalletDiscoverer, getDisplayMessage, parseBridgeMessage } from './chunk-NZ7DOPZ5.js';
1
+ export { ALLOWED_RPC_METHODS, BRIDGE_PROTOCOL_VERSION, Checkout, CheckoutError, DEFAULT_WEBVIEW_BASE_URL, Deposit, DepositError, SANDBOX_WEBVIEW_BASE_URL, attachRpcHost, createWalletDiscoverer, getDisplayMessage, parseBridgeMessage } from './chunk-S3SPMEXQ.js';
2
2
 
3
3
  // src/index.ts
4
4
  var VERSION = "0.3.0";
package/dist/react.cjs CHANGED
@@ -337,13 +337,20 @@ function attachRpcHost(options) {
337
337
  });
338
338
  }
339
339
  }
340
- function advertiseWallets(snapshot) {
340
+ let lastAdvertisedKey = null;
341
+ function advertiseWallets(snapshot, opts) {
341
342
  const wallets = snapshot.map((entry) => ({
342
343
  uuid: entry.info.uuid,
343
344
  rdns: entry.info.rdns,
344
345
  name: entry.info.name,
345
346
  icon: entry.info.icon
346
347
  }));
348
+ const key = JSON.stringify(wallets.map((w) => [w.uuid, w.rdns, w.name, w.icon]));
349
+ if (!opts?.force && key === lastAdvertisedKey) {
350
+ log("skipping identical re-advertisement", { count: wallets.length });
351
+ return;
352
+ }
353
+ lastAdvertisedKey = key;
347
354
  console.info("[blink-bridge:parent] advertising wallets", wallets.map((w) => ({
348
355
  rdns: w.rdns,
349
356
  name: w.name
@@ -424,7 +431,7 @@ function attachRpcHost(options) {
424
431
  if (!message) return;
425
432
  switch (message.type) {
426
433
  case "blink:bridge-hello": {
427
- advertiseWallets(discoverer.list());
434
+ advertiseWallets(discoverer.list(), { force: true });
428
435
  discoverer.requestProviders();
429
436
  return;
430
437
  }
@@ -564,7 +571,7 @@ var STYLES = `
564
571
  [data-blink-overlay][data-blink-mobile-sheet]{align-items:flex-end;touch-action:none;overscroll-behavior:contain}
565
572
  [data-blink-container]{width:min(420px,92vw);height:min(600px,85vh);border-radius:24px;overflow:hidden;box-shadow:0 24px 80px rgba(0,0,0,.4);animation:blink-slide-up .25s ease-out;display:flex;flex-direction:column;background:transparent}
566
573
  [data-blink-overlay][data-blink-closing] [data-blink-container]{opacity:0;transition:opacity ${CLOSE_DURATION_MS}ms ease-in}
567
- [data-blink-container] iframe{width:100%;flex:1;border:none;display:block;background:transparent;color-scheme:normal;border-radius:inherit}
574
+ [data-blink-container] iframe{width:100%;flex:1;border:none;display:block;background:transparent;color-scheme:light;border-radius:inherit}
568
575
  [data-blink-overlay][data-blink-mobile-sheet] [data-blink-container]{width:100%;max-width:100%;height:79vh;border-radius:24px 24px 0 0;box-shadow:0 -8px 40px rgba(0,0,0,.25);animation:blink-slide-up-full .35s cubic-bezier(.32,.72,0,1);padding-bottom:env(safe-area-inset-bottom,0px)}
569
576
  [data-blink-overlay][data-blink-mobile-sheet][data-blink-closing] [data-blink-container]{opacity:1;animation:blink-slide-down-full ${CLOSE_DURATION_MS}ms ease-in forwards}
570
577
  @media(max-width:${MOBILE_SHEET_MAX_VIEWPORT_PX}px){[data-blink-overlay]{align-items:flex-end;touch-action:none;overscroll-behavior:contain}[data-blink-container]{width:100%;max-width:100%;height:79vh;border-radius:24px 24px 0 0;box-shadow:0 -8px 40px rgba(0,0,0,.25);animation:blink-slide-up-full .35s cubic-bezier(.32,.72,0,1);padding-bottom:env(safe-area-inset-bottom,0px)}[data-blink-overlay][data-blink-closing] [data-blink-container]{opacity:1;animation:blink-slide-down-full ${CLOSE_DURATION_MS}ms ease-in forwards}}
@@ -1171,6 +1178,24 @@ var Deposit = class {
1171
1178
  if (this.config.enableFullWidget === false) {
1172
1179
  url.searchParams.set("enableFullWidget", "false");
1173
1180
  }
1181
+ this.applyAppearanceParam(url);
1182
+ }
1183
+ /**
1184
+ * Appends `appearance=dark` (or `appearance=system`) to the hosted-flow URL.
1185
+ * An explicit `appearance: { theme }` config always wins — including
1186
+ * `theme: 'light'`, which pins light regardless of the merchant page. When
1187
+ * the merchant passes no theme, the default follows the merchant page's own
1188
+ * declared color scheme (see {@link detectMerchantColorScheme}) so the flow
1189
+ * doesn't render a light modal on a page that says it is dark. Absence of
1190
+ * the param means light. The hosted flow resolves `system` against the
1191
+ * user's `prefers-color-scheme`. Applied alongside the full-widget param on
1192
+ * every hosted/preload URL.
1193
+ */
1194
+ applyAppearanceParam(url) {
1195
+ const theme = this.config.appearance?.theme ?? detectMerchantColorScheme();
1196
+ if (theme === "dark" || theme === "system") {
1197
+ url.searchParams.set("appearance", theme);
1198
+ }
1174
1199
  }
1175
1200
  /** Fluid is the default; `layout: 'fixed'` opts back into the legacy container. */
1176
1201
  isFluidLayout() {
@@ -1433,6 +1458,23 @@ var Deposit = class {
1433
1458
  }
1434
1459
  }
1435
1460
  };
1461
+ function detectMerchantColorScheme() {
1462
+ if (typeof window === "undefined" || typeof document === "undefined") return null;
1463
+ const root = document.documentElement;
1464
+ if (!root || typeof window.getComputedStyle !== "function") return null;
1465
+ let value;
1466
+ try {
1467
+ value = window.getComputedStyle(root).colorScheme ?? "";
1468
+ } catch {
1469
+ return null;
1470
+ }
1471
+ const tokens = value.toLowerCase().split(/\s+/);
1472
+ const dark = tokens.includes("dark");
1473
+ const light = tokens.includes("light");
1474
+ if (dark && light) return "system";
1475
+ if (dark) return "dark";
1476
+ return null;
1477
+ }
1436
1478
  function svgToDataUri(svg) {
1437
1479
  return `data:image/svg+xml,${encodeURIComponent(svg)}`;
1438
1480
  }