@funkit/connect-rn 0.0.0-20260710210119

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.
Files changed (131) hide show
  1. package/CHANGELOG.md +350 -0
  2. package/README.md +220 -0
  3. package/dist/index.d.ts +24 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +4158 -0
  6. package/dist/index.js.map +7 -0
  7. package/dist/src/flow/AddressCopiedToast.d.ts +18 -0
  8. package/dist/src/flow/AddressCopiedToast.d.ts.map +1 -0
  9. package/dist/src/flow/FlowSheet.d.ts +47 -0
  10. package/dist/src/flow/FlowSheet.d.ts.map +1 -0
  11. package/dist/src/flow/FunkitFlowProvider.d.ts +23 -0
  12. package/dist/src/flow/FunkitFlowProvider.d.ts.map +1 -0
  13. package/dist/src/flow/depositFlowConfig.d.ts +101 -0
  14. package/dist/src/flow/depositFlowConfig.d.ts.map +1 -0
  15. package/dist/src/flow/useKeyboardHeight.d.ts +21 -0
  16. package/dist/src/flow/useKeyboardHeight.d.ts.map +1 -0
  17. package/dist/src/geo/isCountryBlocked.d.ts +3 -0
  18. package/dist/src/geo/isCountryBlocked.d.ts.map +1 -0
  19. package/dist/src/geo/useCheckoutBlocked.d.ts +10 -0
  20. package/dist/src/geo/useCheckoutBlocked.d.ts.map +1 -0
  21. package/dist/src/geo/useUserIpInfo.d.ts +22 -0
  22. package/dist/src/geo/useUserIpInfo.d.ts.map +1 -0
  23. package/dist/src/icons/CopyAddressIcon.d.ts +9 -0
  24. package/dist/src/icons/CopyAddressIcon.d.ts.map +1 -0
  25. package/dist/src/icons/CryptoBitcoinIcon.d.ts +9 -0
  26. package/dist/src/icons/CryptoBitcoinIcon.d.ts.map +1 -0
  27. package/dist/src/icons/CryptoTransferQRIcon.d.ts +9 -0
  28. package/dist/src/icons/CryptoTransferQRIcon.d.ts.map +1 -0
  29. package/dist/src/icons/FigmaSystemIcons.d.ts +19 -0
  30. package/dist/src/icons/FigmaSystemIcons.d.ts.map +1 -0
  31. package/dist/src/icons/FunIcon.d.ts +18 -0
  32. package/dist/src/icons/FunIcon.d.ts.map +1 -0
  33. package/dist/src/icons/PaymentBrandIcons.d.ts +24 -0
  34. package/dist/src/icons/PaymentBrandIcons.d.ts.map +1 -0
  35. package/dist/src/icons/QrChainCluster.d.ts +22 -0
  36. package/dist/src/icons/QrChainCluster.d.ts.map +1 -0
  37. package/dist/src/icons/SourceTokenCluster.d.ts +31 -0
  38. package/dist/src/icons/SourceTokenCluster.d.ts.map +1 -0
  39. package/dist/src/icons/TokenChainIcon.d.ts +19 -0
  40. package/dist/src/icons/TokenChainIcon.d.ts.map +1 -0
  41. package/dist/src/icons/assetLogos.d.ts +12 -0
  42. package/dist/src/icons/assetLogos.d.ts.map +1 -0
  43. package/dist/src/icons/funIconUri.d.ts +16 -0
  44. package/dist/src/icons/funIconUri.d.ts.map +1 -0
  45. package/dist/src/identity/IdentityContext.d.ts +52 -0
  46. package/dist/src/identity/IdentityContext.d.ts.map +1 -0
  47. package/dist/src/logging/consoleLogTransport.d.ts +10 -0
  48. package/dist/src/logging/consoleLogTransport.d.ts.map +1 -0
  49. package/dist/src/logging/datadogHttpLogTransport.d.ts +46 -0
  50. package/dist/src/logging/datadogHttpLogTransport.d.ts.map +1 -0
  51. package/dist/src/logging/logger.d.ts +9 -0
  52. package/dist/src/logging/logger.d.ts.map +1 -0
  53. package/dist/src/providers/FunkitProvider.d.ts +65 -0
  54. package/dist/src/providers/FunkitProvider.d.ts.map +1 -0
  55. package/dist/src/providers/FunkitStatsigProvider.d.ts +13 -0
  56. package/dist/src/providers/FunkitStatsigProvider.d.ts.map +1 -0
  57. package/dist/src/providers/useFunkitCheckout.d.ts +14 -0
  58. package/dist/src/providers/useFunkitCheckout.d.ts.map +1 -0
  59. package/dist/src/screens/AddMoneyScreen.d.ts +86 -0
  60. package/dist/src/screens/AddMoneyScreen.d.ts.map +1 -0
  61. package/dist/src/screens/AvailableChainsScreen.d.ts +33 -0
  62. package/dist/src/screens/AvailableChainsScreen.d.ts.map +1 -0
  63. package/dist/src/screens/CheckoutBlockedScreen.d.ts +2 -0
  64. package/dist/src/screens/CheckoutBlockedScreen.d.ts.map +1 -0
  65. package/dist/src/screens/NetworkSelector.d.ts +31 -0
  66. package/dist/src/screens/NetworkSelector.d.ts.map +1 -0
  67. package/dist/src/screens/QrCodeScreen.d.ts +42 -0
  68. package/dist/src/screens/QrCodeScreen.d.ts.map +1 -0
  69. package/dist/src/screens/TransferCryptoScreen.d.ts +40 -0
  70. package/dist/src/screens/TransferCryptoScreen.d.ts.map +1 -0
  71. package/dist/src/statsig/StatsigClientRN.d.ts +6 -0
  72. package/dist/src/statsig/StatsigClientRN.d.ts.map +1 -0
  73. package/dist/src/statsig/StatsigProviderRN.d.ts +7 -0
  74. package/dist/src/statsig/StatsigProviderRN.d.ts.map +1 -0
  75. package/dist/src/statsig/appVisibilityShim.d.ts +2 -0
  76. package/dist/src/statsig/appVisibilityShim.d.ts.map +1 -0
  77. package/dist/src/statsig/preloadedAsyncStorage.d.ts +3 -0
  78. package/dist/src/statsig/preloadedAsyncStorage.d.ts.map +1 -0
  79. package/dist/src/statsig/rnSetup.d.ts +3 -0
  80. package/dist/src/statsig/rnSetup.d.ts.map +1 -0
  81. package/dist/src/statsig/statsigMetadata.d.ts +2 -0
  82. package/dist/src/statsig/statsigMetadata.d.ts.map +1 -0
  83. package/dist/src/statsig/useClientAsyncInitRN.d.ts +7 -0
  84. package/dist/src/statsig/useClientAsyncInitRN.d.ts.map +1 -0
  85. package/dist/src/statsig/useClientBootstrapInitRN.d.ts +4 -0
  86. package/dist/src/statsig/useClientBootstrapInitRN.d.ts.map +1 -0
  87. package/dist/src/swapped/SwappedScreen.d.ts +21 -0
  88. package/dist/src/swapped/SwappedScreen.d.ts.map +1 -0
  89. package/dist/src/swapped/SwappedWebView.d.ts +18 -0
  90. package/dist/src/swapped/SwappedWebView.d.ts.map +1 -0
  91. package/dist/src/swapped/buildSwappedTheme.d.ts +31 -0
  92. package/dist/src/swapped/buildSwappedTheme.d.ts.map +1 -0
  93. package/dist/src/swapped/webViewSwappedTransport.d.ts +74 -0
  94. package/dist/src/swapped/webViewSwappedTransport.d.ts.map +1 -0
  95. package/dist/src/theme/FunkitThemeProvider.d.ts +50 -0
  96. package/dist/src/theme/FunkitThemeProvider.d.ts.map +1 -0
  97. package/dist/src/theme/restyle.d.ts +5606 -0
  98. package/dist/src/theme/restyle.d.ts.map +1 -0
  99. package/dist/src/theme/toRestyleTheme.d.ts +490 -0
  100. package/dist/src/theme/toRestyleTheme.d.ts.map +1 -0
  101. package/dist/src/theme/tokens.d.ts +159 -0
  102. package/dist/src/theme/tokens.d.ts.map +1 -0
  103. package/dist/src/theme/useColorScheme.d.ts +25 -0
  104. package/dist/src/theme/useColorScheme.d.ts.map +1 -0
  105. package/dist/src/theme/useFunkitTheme.d.ts +29 -0
  106. package/dist/src/theme/useFunkitTheme.d.ts.map +1 -0
  107. package/dist/src/transfer/QrCode.d.ts +24 -0
  108. package/dist/src/transfer/QrCode.d.ts.map +1 -0
  109. package/dist/src/transfer/availableChains.d.ts +53 -0
  110. package/dist/src/transfer/availableChains.d.ts.map +1 -0
  111. package/dist/src/transfer/clipboard.d.ts +23 -0
  112. package/dist/src/transfer/clipboard.d.ts.map +1 -0
  113. package/dist/src/transfer/fops.d.ts +26 -0
  114. package/dist/src/transfer/fops.d.ts.map +1 -0
  115. package/dist/src/transfer/formatDepositAddress.d.ts +9 -0
  116. package/dist/src/transfer/formatDepositAddress.d.ts.map +1 -0
  117. package/dist/src/transfer/hooks/useFops.d.ts +47 -0
  118. package/dist/src/transfer/hooks/useFops.d.ts.map +1 -0
  119. package/dist/src/transfer/hooks/useSupportedTokens.d.ts +26 -0
  120. package/dist/src/transfer/hooks/useSupportedTokens.d.ts.map +1 -0
  121. package/dist/src/transfer/hooks/useTokenTransfer.d.ts +33 -0
  122. package/dist/src/transfer/hooks/useTokenTransfer.d.ts.map +1 -0
  123. package/dist/src/transfer/hooks/useTransferInit.d.ts +27 -0
  124. package/dist/src/transfer/hooks/useTransferInit.d.ts.map +1 -0
  125. package/dist/src/transfer/hooks/useUDAParams.d.ts +9 -0
  126. package/dist/src/transfer/hooks/useUDAParams.d.ts.map +1 -0
  127. package/dist/src/transfer/supportedTokens.d.ts +34 -0
  128. package/dist/src/transfer/supportedTokens.d.ts.map +1 -0
  129. package/dist/src/version.d.ts +2 -0
  130. package/dist/src/version.d.ts.map +1 -0
  131. package/package.json +109 -0
@@ -0,0 +1,74 @@
1
+ import { type SwappedInboundMessage, type SwappedOutboundMessage, type SwappedTransport } from '@funkit/connect-core';
2
+ /**
3
+ * Marker key on host → embed envelopes (see {@link buildSwappedSendScript}).
4
+ * The injected bridge recognizes the mark, unwraps the payload, and delivers it
5
+ * to the page; everything unmarked is embed traffic and goes to native.
6
+ */
7
+ export declare const FUNKIT_ENVELOPE_KEY = "__funkitSwapped";
8
+ /**
9
+ * Injected into the Swapped WebView before its content loads. Installs one
10
+ * bridged `postMessage` that routes BOTH directions:
11
+ *
12
+ * - **embed → native**: the embed talks to its host by calling
13
+ * `window.parent.postMessage(obj, origin)` (the web iframe contract); at the
14
+ * top level `window.parent === window`, so overriding `window.postMessage`
15
+ * intercepts those calls and forwards them — JSON-stringified — to React
16
+ * Native via `window.ReactNativeWebView.postMessage`. The RN side parses +
17
+ * origin-validates via {@link handleWebViewMessage}.
18
+ * - **native → embed**: messages injected by {@link buildSwappedSendScript}
19
+ * arrive at the same bridged function wrapped in a funkit-marked envelope
20
+ * ({@link FUNKIT_ENVELOPE_KEY}); the bridge unwraps them and re-dispatches
21
+ * the payload through the REAL `postMessage` (captured before the override),
22
+ * so the embed's `message` listeners receive a genuine, trusted MessageEvent
23
+ * with an object `event.data` — exactly what they get from an iframe parent.
24
+ *
25
+ * It also installs a fake `window.opener` wired to the native channel: with no
26
+ * parent frame the widget posts its lifecycle messages (`SWAPPED_READY`, …) to
27
+ * `opener` instead of `parent`, and a top-level WebView has neither — without
28
+ * the shim those messages are silently dropped.
29
+ */
30
+ export declare const SWAPPED_WEBVIEW_INJECTED_JS = "(function () {\n if (window.__funkitSwappedBridge) { return; }\n window.__funkitSwappedBridge = true;\n // The REAL postMessage, captured before the override below.\n var postToPage = window.postMessage.bind(window);\n function forwardToNative(message) {\n try {\n var data = typeof message === 'string' ? message : JSON.stringify(message);\n window.ReactNativeWebView && window.ReactNativeWebView.postMessage(data);\n } catch (e) {}\n }\n function bridged(message) {\n // funkit envelope (host \u2192 embed): unwrap + deliver to the page's listeners.\n if (message && message.__funkitSwapped) {\n try { postToPage(message.payload, '*'); } catch (e) {}\n return;\n }\n // Anything else is the embed talking to its host \u2192 forward to native.\n forwardToNative(message);\n }\n // The embed posts to window.parent (and sometimes window) \u2014 both are this\n // window at the top level, so both assignments install the same bridge.\n try { if (window.parent) { window.parent.postMessage = bridged; } } catch (e) {}\n try { window.postMessage = bridged; } catch (e) {}\n // No parent frame \u2192 the widget posts lifecycle messages to window.opener.\n try { if (!window.opener) { window.opener = { postMessage: forwardToNative }; } } catch (e) {}\n true;\n})();\ntrue;";
31
+ /**
32
+ * Build the JS snippet that delivers an outbound message INTO the embed, run
33
+ * via `webView.injectJavaScript`. One shape for every message type: the payload
34
+ * is wrapped in a funkit-marked envelope and handed to the (bridged)
35
+ * `window.postMessage` — the bridge unwraps it and re-dispatches via the real
36
+ * `postMessage` (see {@link SWAPPED_WEBVIEW_INJECTED_JS}). If the bridge isn't
37
+ * installed, the envelope dispatches as-is and the embed ignores it (no `type`).
38
+ */
39
+ export declare function buildSwappedSendScript(msg: SwappedOutboundMessage): string;
40
+ /**
41
+ * Parse + validate a raw WebView `onMessage` payload into a typed inbound
42
+ * Swapped message. Returns `null` (drop the message) when:
43
+ * - the payload isn't valid JSON with a string `type`, or
44
+ * - a `url` is supplied whose origin isn't a Swapped origin (mirrors web's
45
+ * `isSwappedOrigin(event.origin)` guard in the iframe transport).
46
+ *
47
+ * `url` is the WebView's current page URL (`nativeEvent.url`); when omitted the
48
+ * origin check is skipped (the caller already trusts the source).
49
+ */
50
+ export declare function handleWebViewMessage(rawData: unknown, url?: string): SwappedInboundMessage | null;
51
+ /** Minimal surface of `react-native-webview`'s ref the transport needs. */
52
+ export interface WebViewLike {
53
+ injectJavaScript(script: string): void;
54
+ }
55
+ export interface WebViewSwappedTransport {
56
+ /** Implements the shared {@link SwappedTransport} contract. */
57
+ transport: SwappedTransport;
58
+ /**
59
+ * Feed a raw WebView `onMessage` payload (+ optional page url) through origin
60
+ * validation and fan it out to `transport.onMessage` subscribers.
61
+ */
62
+ dispatch(rawData: unknown, url?: string): void;
63
+ }
64
+ /**
65
+ * React Native {@link SwappedTransport}: bridges the typed Swapped message
66
+ * contract over a `WebView` instead of web's `<iframe>` + `window.postMessage`.
67
+ * `send` delivers into the embed by injecting an in-page `postMessage` call
68
+ * ({@link buildSwappedSendScript}); inbound messages arrive through
69
+ * {@link dispatch} (wired to the WebView's `onMessage`).
70
+ */
71
+ export declare function createWebViewSwappedTransport({ getWebView, }: {
72
+ getWebView: () => WebViewLike | null;
73
+ }): WebViewSwappedTransport;
74
+ //# sourceMappingURL=webViewSwappedTransport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webViewSwappedTransport.d.ts","sourceRoot":"","sources":["../../../src/swapped/webViewSwappedTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EAEtB,MAAM,sBAAsB,CAAA;AAE7B;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,oBAAoB,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,2BAA2B,mzCA4BlC,CAAA;AAEN;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,sBAAsB,GAAG,MAAM,CAM1E;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,EAChB,GAAG,CAAC,EAAE,MAAM,GACX,qBAAqB,GAAG,IAAI,CAmB9B;AAED,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CACvC;AAED,MAAM,WAAW,uBAAuB;IACtC,+DAA+D;IAC/D,SAAS,EAAE,gBAAgB,CAAA;IAC3B;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/C;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,EAC5C,UAAU,GACX,EAAE;IACD,UAAU,EAAE,MAAM,WAAW,GAAG,IAAI,CAAA;CACrC,GAAG,uBAAuB,CA8B1B"}
@@ -0,0 +1,50 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type ColorScheme } from './useColorScheme';
3
+ import { type FunkitThemeSet } from './useFunkitTheme';
4
+ interface FunkitColorSchemeValue {
5
+ /** The active, resolved color scheme. */
6
+ colorScheme: ColorScheme;
7
+ /**
8
+ * Flip light↔dark, or set a specific scheme when an argument is given.
9
+ * **No-op when the provider's `colorScheme` prop is set** (controlled mode) —
10
+ * the host owns the scheme in that case.
11
+ */
12
+ toggleColorScheme: (next?: ColorScheme) => void;
13
+ /** True when the scheme is forced by the `colorScheme` prop (uncontrolled toggle disabled). */
14
+ isControlled: boolean;
15
+ }
16
+ export interface FunkitThemeProviderProps {
17
+ children: ReactNode;
18
+ /**
19
+ * The light/dark Restyle theme set. Defaults to the built-in Fun Mobile
20
+ * themes. Pass `{ light, dark }` from `toRestyleTheme(...)` to customize.
21
+ */
22
+ themes?: FunkitThemeSet;
23
+ /**
24
+ * Force a color scheme. When provided the provider is **controlled**: it
25
+ * always renders this scheme, ignores the system Appearance, and
26
+ * `toggleColorScheme()` becomes a no-op. When omitted the provider is
27
+ * **uncontrolled**: the scheme follows the system Appearance and can be
28
+ * flipped with `toggleColorScheme()`.
29
+ */
30
+ colorScheme?: ColorScheme;
31
+ }
32
+ /**
33
+ * The styling layer for `@funkit/connect-rn`. Resolves the active Restyle theme
34
+ * (selected from `themes` by color scheme), wires it into Restyle's
35
+ * `ThemeProvider`, and exposes the scheme + a manual toggle via
36
+ * {@link useFunkitColorScheme}.
37
+ *
38
+ * This is an internal-ish provider — host apps mount the user-facing
39
+ * {@link FunkitProvider}, which passes `themes` / `colorScheme` down to this.
40
+ */
41
+ export declare function FunkitThemeProvider({ children, themes, colorScheme, }: FunkitThemeProviderProps): import("react").JSX.Element;
42
+ /**
43
+ * Read the active color scheme and toggle it. Must be used within a
44
+ * {@link FunkitProvider} (which mounts {@link FunkitThemeProvider}).
45
+ * `toggleColorScheme` is a no-op when the provider is in controlled mode (a
46
+ * `colorScheme` prop was passed).
47
+ */
48
+ export declare function useFunkitColorScheme(): FunkitColorSchemeValue;
49
+ export {};
50
+ //# sourceMappingURL=FunkitThemeProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunkitThemeProvider.d.ts","sourceRoot":"","sources":["../../../src/theme/FunkitThemeProvider.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,OAAO,CAAA;AAGd,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,kBAAkB,CAAA;AAOnE,UAAU,sBAAsB;IAC9B,yCAAyC;IACzC,WAAW,EAAE,WAAW,CAAA;IACxB;;;;OAIG;IACH,iBAAiB,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,IAAI,CAAA;IAC/C,+FAA+F;IAC/F,YAAY,EAAE,OAAO,CAAA;CACtB;AAMD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,SAAS,CAAA;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,MAAuB,EACvB,WAAW,GACZ,EAAE,wBAAwB,+BAqC1B;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,sBAAsB,CAM7D"}