@funkit/connect 9.23.0 → 9.23.2-next.0
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/CHANGELOG.md +38 -0
- package/dist/__generated__/default_configs.d.ts +901 -0
- package/dist/__generated__/default_feature_gates.d.ts +20 -0
- package/dist/clients/aave.d.ts +1 -1
- package/dist/clients/chunk-25ICASD7.js +2371 -0
- package/dist/clients/chunk-3GO74QTP.js +2382 -0
- package/dist/clients/{chunk-NCCAYPLO.js → chunk-4HCOSF4M.js} +1 -1
- package/dist/clients/chunk-7GWX2ZS4.js +69 -0
- package/dist/clients/{chunk-KSSSSWR6.js → chunk-7HNGV6JU.js} +1 -1
- package/dist/clients/chunk-CEBG7XQ5.js +2382 -0
- package/dist/clients/{chunk-ZMVXBMON.js → chunk-ELLXM7RO.js} +1 -1
- package/dist/clients/chunk-GGXTLJ7J.js +290 -0
- package/dist/clients/chunk-HRWCNZJA.js +230 -0
- package/dist/clients/chunk-JD3FIVZ7.js +69 -0
- package/dist/clients/chunk-JTGKAPID.js +2382 -0
- package/dist/clients/{chunk-4752IYY6.js → chunk-KWIR3HO4.js} +1 -1
- package/dist/clients/chunk-L7PABCF2.js +54 -0
- package/dist/clients/chunk-LII3SVUH.js +230 -0
- package/dist/clients/{chunk-OWXKWC7I.js → chunk-NCUPPJ2Z.js} +8 -8
- package/dist/clients/chunk-NUJ6ZM5F.js +186 -0
- package/dist/clients/chunk-UVWNEQMD.js +186 -0
- package/dist/clients/chunk-VVTNR7YH.js +2382 -0
- package/dist/clients/chunk-ZNVFASTH.js +54 -0
- package/dist/clients/fanatics.css +2 -2
- package/dist/clients/fanatics.js +3 -3
- package/dist/clients/lighter.css +2 -2
- package/dist/clients/lighter.d.ts +1 -1
- package/dist/clients/lighter.js +5 -3
- package/dist/clients/mallard.d.ts +49 -0
- package/dist/clients/mallard.js +86 -0
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.css +97 -87
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.d.ts +1 -1
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +6 -6
- package/dist/clients/polymarket/createPolymarketDepositConfig.d.ts +1 -1
- package/dist/clients/polymarket/createPolymarketDepositConfig.js +2 -2
- package/dist/clients/polymarket/index.css +97 -87
- package/dist/clients/polymarket/index.js +6 -6
- package/dist/clients/polymarket/polymarket.d.ts +2 -2
- package/dist/clients/polymarket/polymarket.js +1 -1
- package/dist/clients/polymarket.d.ts +161 -0
- package/dist/clients/polymarket.js +688 -0
- package/dist/clients/rolly.d.ts +1 -1
- package/dist/clients/rolly.js +1 -14
- package/dist/components/ApprovalMethodToggle/ApprovalMethodToggle.d.ts +1 -1
- package/dist/components/BottomLinks/BottomLinks.css.d.ts +6 -0
- package/dist/components/BottomLinks/BottomLinks.d.ts +14 -0
- package/dist/components/Box/Box.d.ts +21 -21
- package/dist/components/Dropdown/ChainDropdown.d.ts +1 -1
- package/dist/components/Dropdown/TokenAndChainDropdown.d.ts +1 -1
- package/dist/components/Dropdown/TokenDropdown.d.ts +1 -1
- package/dist/components/FunAsset/FunAssetItem.d.ts +1 -1
- package/dist/components/FunCheckoutHistory/AddTokenToWalletButton.d.ts +1 -1
- package/dist/components/FunCheckoutHistory/FunDirectExecutionHistoryBottomBar.d.ts +1 -1
- package/dist/components/FunCheckoutHistory/FunDirectExecutionHistoryDetail.d.ts +1 -1
- package/dist/components/FunCheckoutHistory/PendingSuccessScreen.d.ts +2 -2
- package/dist/components/FunCheckoutHistory/YouSendItem.d.ts +1 -1
- package/dist/components/FunNotificationBanner/FunNotificationBannerIcon.d.ts +1 -1
- package/dist/components/FunPayments/FunPaymentMethods.d.ts +1 -1
- package/dist/components/FunSelectBrokerage/FunSelectBrokerage.d.ts +1 -1
- package/dist/components/FunTransactionSummary/DestinationYieldRows.d.ts +1 -1
- package/dist/components/FunTransactionSummary/PaymentAmountSummary.d.ts +3 -3
- package/dist/components/FunTransactionSummary/PaymentFeesSummary.d.ts +2 -2
- package/dist/components/FunTransactionSummary/PaymentFeesSummary.track.d.ts +2 -2
- package/dist/components/FunTransactionSummary/PaymentMethodSummary.d.ts +2 -2
- package/dist/components/FunTransactionSummary/PaymentRouteSummary.d.ts +1 -1
- package/dist/components/ModalHeightAnimationLayer/FunCheckoutModalHeightAnimationWrapper.d.ts +2 -2
- package/dist/components/NewTokenDepositAlert/NewTokenDepositAlert.d.ts +1 -1
- package/dist/components/ReceiveAmount/ReceiveAmount.d.ts +2 -2
- package/dist/components/SourcePaymentMethodItem/SourcePaymentMethodItem.d.ts +1 -1
- package/dist/components/TransactionStatus/AnimatedSpinner/AnimatedSpinner.d.ts +1 -1
- package/dist/components/TransactionStatus/StepSpinner.d.ts +1 -1
- package/dist/components/TransactionStatus/TransactionStatus.d.ts +2 -2
- package/dist/components/TransferTokenDetails/TransferTokenDetails.d.ts +1 -1
- package/dist/consts/customers.d.ts +3 -1
- package/dist/consts/funkit.d.ts +1 -0
- package/dist/css/sprinkles.css.d.ts +21 -21
- package/dist/domains/aave.d.ts +1 -1
- package/dist/domains/asset.d.ts +4 -4
- package/dist/domains/checkout.d.ts +1 -1
- package/dist/domains/checkoutErrors.d.ts +2 -2
- package/dist/domains/checkoutRecipient.d.ts +1 -1
- package/dist/domains/clientMetadata.d.ts +7 -2
- package/dist/domains/dynamicRouting.d.ts +1 -1
- package/dist/domains/fees.d.ts +3 -3
- package/dist/domains/paymentMethods.d.ts +1 -1
- package/dist/domains/quote.d.ts +5 -5
- package/dist/domains/quoteMode/exactOut.d.ts +1 -1
- package/dist/domains/quoteMode/resolveQuoteMode.d.ts +1 -1
- package/dist/domains/quoteMode/types.d.ts +2 -2
- package/dist/hooks/queries/useLightningQuote.d.ts +1 -1
- package/dist/hooks/queries/useMeldDefaultCurrency.d.ts +1 -1
- package/dist/hooks/queries/useRecentCheckouts.d.ts +1 -1
- package/dist/hooks/queries/useRecentDeposits.d.ts +1 -1
- package/dist/hooks/queries/useWithdrawalQuote.d.ts +31 -31
- package/dist/hooks/track/useTrack.d.ts +1 -1
- package/dist/hooks/useBluvo.d.ts +3 -3
- package/dist/hooks/useCheckoutDirectExecution.d.ts +3 -3
- package/dist/hooks/useCheckoutDirectExecutionHistory.d.ts +1 -1
- package/dist/hooks/useCheckoutItemDisplay.d.ts +2 -2
- package/dist/hooks/useCheckoutTimeEstimate.d.ts +2 -2
- package/dist/hooks/useCountdown.d.ts +1 -1
- package/dist/hooks/useEnabledTokenTransferChainTokens.d.ts +1 -1
- package/dist/hooks/useExchangeOptions.d.ts +1 -1
- package/dist/hooks/useFrogAccount.d.ts +1 -1
- package/dist/hooks/useIsBlacklisted.d.ts +1 -1
- package/dist/hooks/useIsDynamicRoutingEnabled.d.ts +1 -1
- package/dist/hooks/useMinDeposit.d.ts +1 -1
- package/dist/hooks/useNewTokenBanner.d.ts +1 -1
- package/dist/hooks/useOnNewNotification.d.ts +1 -1
- package/dist/hooks/usePaymentMethodTabs.d.ts +1 -1
- package/dist/hooks/usePaymentSources.d.ts +2 -2
- package/dist/hooks/useRelayBypass.d.ts +1 -1
- package/dist/hooks/useStepQueryReadiness.d.ts +3 -3
- package/dist/hooks/useTokenAndChainDropdown.d.ts +1 -1
- package/dist/hooks/useTokenTransfer.d.ts +1 -1
- package/dist/hooks/useTokenTransferConfig.d.ts +8 -1
- package/dist/hooks/useUserIpInfo.d.ts +1 -1
- package/dist/index.css +42 -32
- package/dist/index.js +751 -763
- package/dist/interfaces/identity.d.ts +1 -1
- package/dist/interfaces/logTransport.d.ts +51 -0
- package/dist/interfaces/swapped-transport.d.ts +78 -0
- package/dist/modals/ChainModal/Chain.d.ts +1 -1
- package/dist/modals/CheckoutModal/Brokerage/BrokerageSuccessModal.d.ts +1 -1
- package/dist/modals/CheckoutModal/Brokerage/BrokerageTwoFA.d.ts +2 -2
- package/dist/modals/CheckoutModal/Brokerage/ConnectExchange.d.ts +2 -2
- package/dist/modals/CheckoutModal/Brokerage/SelectBrokerage.d.ts +2 -2
- package/dist/modals/CheckoutModal/ConfirmationStep/CheckoutPrimaryInfo.d.ts +2 -2
- package/dist/modals/CheckoutModal/ConfirmationStep/ConfirmationStep.d.ts +1 -1
- package/dist/modals/CheckoutModal/ConfirmationStep/DisclaimerText.d.ts +1 -1
- package/dist/modals/CheckoutModal/ConfirmationStep/mapRetryAction.d.ts +1 -1
- package/dist/modals/CheckoutModal/ConfirmationStep/useCheckoutConfirmation.d.ts +1 -1
- package/dist/modals/CheckoutModal/ConfirmationStep/useCheckoutQuote.d.ts +2 -2
- package/dist/modals/CheckoutModal/ConfirmationStep/usePostCheckout.d.ts +2 -2
- package/dist/modals/CheckoutModal/ConfirmationStep/useQuoteRefresh.d.ts +1 -1
- package/dist/modals/CheckoutModal/ConfirmationStep/useSourceAssetConfirm.d.ts +2 -2
- package/dist/modals/CheckoutModal/FunCheckoutStep.d.ts +3 -1
- package/dist/modals/CheckoutModal/InputAmount/InputAmount.d.ts +1 -1
- package/dist/modals/CheckoutModal/InputAmount/InputAmountLoaded.d.ts +2 -2
- package/dist/modals/CheckoutModal/InputAmount/state.d.ts +3 -3
- package/dist/modals/CheckoutModal/InputAmount/useAaveNativeSupply.d.ts +3 -3
- package/dist/modals/CheckoutModal/InputAmount/useAmountInput.d.ts +1 -1
- package/dist/modals/CheckoutModal/InputAmount/useAvailableBalanceForCheckout.d.ts +3 -3
- package/dist/modals/CheckoutModal/InputAmount/useCheckoutAmountLimits.d.ts +2 -2
- package/dist/modals/CheckoutModal/InputAmount/useMeld.d.ts +1 -1
- package/dist/modals/CheckoutModal/InputAmount/utils.d.ts +2 -2
- package/dist/modals/CheckoutModal/LightningInvoice/LightningInvoice.d.ts +1 -1
- package/dist/modals/CheckoutModal/LightningInvoice/LightningInvoiceQrCode.d.ts +1 -1
- package/dist/modals/CheckoutModal/MeldCurrencySelect/MeldCurrencySelect.d.ts +1 -1
- package/dist/modals/CheckoutModal/MeldQuotes/MeldQuotes.d.ts +1 -1
- package/dist/modals/CheckoutModal/MeldRedirect/MeldRedirect.d.ts +1 -1
- package/dist/modals/CheckoutModal/SelectAsset/SelectAsset.d.ts +5 -5
- package/dist/modals/CheckoutModal/SelectAsset/SelectAssetInfoSection.d.ts +2 -2
- package/dist/modals/CheckoutModal/SelectAsset/SelectAssetList.d.ts +2 -2
- package/dist/modals/CheckoutModal/SourceChange/ConnectedSource.d.ts +1 -1
- package/dist/modals/CheckoutModal/SourceChange/CryptoCashToggle.d.ts +2 -2
- package/dist/modals/CheckoutModal/SourceChange/EmptyFormOfPaymentsMessage.d.ts +4 -0
- package/dist/modals/CheckoutModal/SourceChange/SourceChange.d.ts +2 -2
- package/dist/modals/CheckoutModal/SourceChange/useSourceChangeLayout.d.ts +1 -1
- package/dist/modals/CheckoutModal/SourceChange/useUpdateSourceAssetForCard.d.ts +4 -0
- package/dist/modals/CheckoutModal/SwappedIframe/SwappedErrorMessage.d.ts +6 -0
- package/dist/modals/CheckoutModal/SwappedIframe/SwappedIframeController.d.ts +2 -2
- package/dist/modals/CheckoutModal/TransferToken/CheckoutNotification.d.ts +1 -1
- package/dist/modals/CheckoutModal/TransferToken/CheckoutNotifications.track.d.ts +1 -1
- package/dist/modals/CheckoutModal/TransferToken/DirectExecutionNotification.d.ts +1 -1
- package/dist/modals/CheckoutModal/TransferToken/TransferToken.d.ts +1 -1
- package/dist/modals/CheckoutModal/TransferToken/types.d.ts +1 -1
- package/dist/modals/CheckoutModal/VirtualFiatAccount/BridgeCustomer.d.ts +2 -2
- package/dist/modals/CheckoutModal/VirtualFiatAccount/BridgeKyc.d.ts +1 -1
- package/dist/modals/CheckoutModal/VirtualFiatAccount/ErrorScreen.d.ts +1 -1
- package/dist/modals/CheckoutModal/VirtualFiatAccount/FiatAccountDetail.d.ts +1 -1
- package/dist/modals/CheckoutModal/VirtualFiatAccount/KycIframe.d.ts +2 -2
- package/dist/modals/CheckoutModal/VirtualFiatAccount/VirtualFiatAccount.d.ts +2 -2
- package/dist/modals/CheckoutModal/Withdrawal/WithdrawalComplete.d.ts +14 -0
- package/dist/modals/CheckoutModal/Withdrawal/WithdrawalEnterAmount.d.ts +15 -0
- package/dist/modals/CheckoutModal/stepTransition.d.ts +11 -5
- package/dist/modals/CheckoutModal/stepTransition.track.d.ts +3 -3
- package/dist/modals/ProfileDetails/FunProfileViews/Home/HomeCheckoutDisplayRow.d.ts +2 -2
- package/dist/modals/ProfileDetails/FunProfileViews/Home/HomeTokenDisplayRow.d.ts +1 -1
- package/dist/modals/ProfileDetails/FunProfileViews/Home/ProfileTitleSection.d.ts +2 -2
- package/dist/modals/ProfileDetails/FunProfileViews/Home/index.d.ts +1 -1
- package/dist/modals/WithdrawalModal/ErrorMessage.d.ts +2 -2
- package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +4 -4
- package/dist/modals/WithdrawalModal/RecipientAddress.d.ts +1 -1
- package/dist/modals/WithdrawalModal/WithdrawAmountInput.d.ts +1 -1
- package/dist/modals/WithdrawalModal/WithdrawalCallbackSuccess.d.ts +1 -1
- package/dist/modals/WithdrawalModal/WithdrawalContent.d.ts +1 -1
- package/dist/modals/WithdrawalModal/WithdrawalModal.d.ts +1 -1
- package/dist/modals/WithdrawalModal/WithdrawalTypeSelect.d.ts +1 -1
- package/dist/modals/WithdrawalModal/useWithdrawal.d.ts +3 -3
- package/dist/providers/FunkitBrokerageProvider.d.ts +2 -2
- package/dist/providers/FunkitCheckoutContext/index.d.ts +1 -1
- package/dist/providers/FunkitCheckoutContext/track.d.ts +4 -4
- package/dist/providers/FunkitCheckoutContext/types.d.ts +2 -28
- package/dist/providers/FunkitConfigContext.d.ts +3 -3
- package/dist/providers/FunkitHistoryContext.d.ts +2 -2
- package/dist/providers/FunkitProvider.d.ts +2 -2
- package/dist/providers/FunkitQuoteContext.track.d.ts +4 -4
- package/dist/providers/GeneralWalletProvider.d.ts +2 -2
- package/dist/providers/QuoteModeContext.d.ts +1 -1
- package/dist/providers/SwappedProvider.d.ts +1 -1
- package/dist/utils/assets.d.ts +1 -1
- package/dist/utils/bluvo.d.ts +3 -3
- package/dist/utils/checkout.d.ts +3 -3
- package/dist/utils/depositCutoff.d.ts +1 -1
- package/dist/utils/flags/resolver.d.ts +34 -0
- package/dist/utils/funkitProvider.d.ts +1 -1
- package/dist/utils/payment.d.ts +1 -1
- package/dist/utils/polygonRpcCheck.d.ts +1 -1
- package/dist/utils/purifyCheckoutHistoryItem.d.ts +1 -1
- package/dist/utils/swapped.d.ts +1 -1
- package/dist/utils/tokenTransfer/disabledList.d.ts +1 -14
- package/dist/utils/tokenTransfer/types.d.ts +5 -30
- package/dist/utils/withdrawal.d.ts +1 -1
- package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
- package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
- package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
- package/dist/wallets/walletConnectors/chunk-2VP2F6EK.js +70 -0
- package/dist/wallets/walletConnectors/chunk-4T6ZSRJF.js +69 -0
- package/dist/wallets/walletConnectors/chunk-6BW3HLBG.js +96 -0
- package/dist/wallets/walletConnectors/chunk-CCQV2ZET.js +218 -0
- package/dist/wallets/walletConnectors/chunk-CPI4TD43.js +99 -0
- package/dist/wallets/walletConnectors/chunk-F5XEEVG6.js +98 -0
- package/dist/wallets/walletConnectors/chunk-HNRB7KJU.js +92 -0
- package/dist/wallets/walletConnectors/chunk-HTHAK6XB.js +93 -0
- package/dist/wallets/walletConnectors/chunk-MIQTHJ6X.js +66 -0
- package/dist/wallets/walletConnectors/chunk-RB3HR4R2.js +95 -0
- package/dist/wallets/walletConnectors/chunk-RVOY537T.js +100 -0
- package/dist/wallets/walletConnectors/chunk-STVVP43G.js +94 -0
- package/dist/wallets/walletConnectors/chunk-UK7C2JXW.js +87 -0
- package/dist/wallets/walletConnectors/chunk-VAPGUPHO.js +92 -0
- package/dist/wallets/walletConnectors/chunk-VTM6EECM.js +110 -0
- package/dist/wallets/walletConnectors/chunk-X6CGV36L.js +103 -0
- package/dist/wallets/walletConnectors/chunk-YEZM4CK4.js +96 -0
- package/dist/wallets/walletConnectors/chunk-ZNX4EMPB.js +106 -0
- package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
- package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
- package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
- package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
- package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
- package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
- package/dist/wallets/walletConnectors/index.js +63 -63
- package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
- package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
- package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
- package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
- package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
- package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
- package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
- package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
- package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
- package/package.json +5 -5
- /package/dist/clients/{chunk-52NKHZS2.js → chunk-7FIVHWNC.js} +0 -0
- /package/dist/clients/{chunk-MOUTRRN3.js → chunk-S7FRYR55.js} +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Box
|
|
4
|
+
} from "./chunk-7GWX2ZS4.js";
|
|
5
|
+
import {
|
|
6
|
+
logger
|
|
7
|
+
} from "./chunk-UUHGOBKZ.js";
|
|
8
|
+
|
|
9
|
+
// src/components/AsyncImage/useAsyncImage.ts
|
|
10
|
+
import { useEffect, useReducer } from "react";
|
|
11
|
+
var cachedUrls = /* @__PURE__ */ new Map();
|
|
12
|
+
var cachedRequestPromises = /* @__PURE__ */ new Map();
|
|
13
|
+
async function loadAsyncImage(asyncImage) {
|
|
14
|
+
const cachedRequestPromise = cachedRequestPromises.get(asyncImage);
|
|
15
|
+
if (cachedRequestPromise) {
|
|
16
|
+
return cachedRequestPromise;
|
|
17
|
+
}
|
|
18
|
+
const load = async () => asyncImage().then(async (url) => {
|
|
19
|
+
cachedUrls.set(asyncImage, url);
|
|
20
|
+
return url;
|
|
21
|
+
});
|
|
22
|
+
const requestPromise = load().catch(async () => {
|
|
23
|
+
return load().catch(() => {
|
|
24
|
+
cachedRequestPromises.delete(asyncImage);
|
|
25
|
+
return void 0;
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
cachedRequestPromises.set(asyncImage, requestPromise);
|
|
29
|
+
return requestPromise;
|
|
30
|
+
}
|
|
31
|
+
function useForceUpdate() {
|
|
32
|
+
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
33
|
+
return forceUpdate;
|
|
34
|
+
}
|
|
35
|
+
function useAsyncImage(url) {
|
|
36
|
+
const cachedUrl = typeof url === "function" ? cachedUrls.get(url) : void 0;
|
|
37
|
+
const forceUpdate = useForceUpdate();
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (typeof url === "function" && !cachedUrl) {
|
|
40
|
+
loadAsyncImage(url).then(forceUpdate);
|
|
41
|
+
}
|
|
42
|
+
}, [url, cachedUrl, forceUpdate]);
|
|
43
|
+
return typeof url === "function" ? cachedUrl : url;
|
|
44
|
+
}
|
|
45
|
+
var REMOTE_IMG_CACHE = /* @__PURE__ */ new Set();
|
|
46
|
+
function preloadRemoteImages(...imageUrls) {
|
|
47
|
+
for (const imageUrl of imageUrls) {
|
|
48
|
+
try {
|
|
49
|
+
const { protocol } = new URL(imageUrl);
|
|
50
|
+
if (protocol !== "https:" && protocol !== "http:") {
|
|
51
|
+
logger.warn("preloadRemoteImages:invalidUrl", {
|
|
52
|
+
message: "Invalid protocol",
|
|
53
|
+
imageUrl
|
|
54
|
+
});
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (!REMOTE_IMG_CACHE.has(imageUrl)) {
|
|
58
|
+
REMOTE_IMG_CACHE.add(imageUrl);
|
|
59
|
+
const preloadImage = new Image();
|
|
60
|
+
preloadImage.src = imageUrl;
|
|
61
|
+
}
|
|
62
|
+
} catch (error) {
|
|
63
|
+
logger.warn("preloadRemoteImages:error", {
|
|
64
|
+
message: "Unable to preload image",
|
|
65
|
+
imageUrl,
|
|
66
|
+
error
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/components/AsyncImage/AsyncImage.tsx
|
|
73
|
+
import React, { useMemo, useReducer as useReducer2, useState } from "react";
|
|
74
|
+
|
|
75
|
+
// src/utils/sanitizeUrl.ts
|
|
76
|
+
var SAFE_URL_PROTOCOLS = /* @__PURE__ */ new Set(["https:", "http:"]);
|
|
77
|
+
function sanitizeUrl(url) {
|
|
78
|
+
if (!url) {
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const parsed = new URL(url);
|
|
83
|
+
if (SAFE_URL_PROTOCOLS.has(parsed.protocol)) {
|
|
84
|
+
return parsed.href;
|
|
85
|
+
}
|
|
86
|
+
return void 0;
|
|
87
|
+
} catch {
|
|
88
|
+
return void 0;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function sanitizeCssUrl(url) {
|
|
92
|
+
const safeUrl = sanitizeUrl(url);
|
|
93
|
+
if (!safeUrl) {
|
|
94
|
+
return void 0;
|
|
95
|
+
}
|
|
96
|
+
return safeUrl.replace(/['()\\]/g, (char) => {
|
|
97
|
+
return `%${char.charCodeAt(0).toString(16).padStart(2, "0")}`;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/components/AsyncImage/AsyncImage.tsx
|
|
102
|
+
function useTriggeredOnce() {
|
|
103
|
+
return useReducer2(() => true, false);
|
|
104
|
+
}
|
|
105
|
+
function AsyncImage({
|
|
106
|
+
alt,
|
|
107
|
+
background,
|
|
108
|
+
borderColor,
|
|
109
|
+
borderRadius,
|
|
110
|
+
boxShadow,
|
|
111
|
+
height,
|
|
112
|
+
useAsImage,
|
|
113
|
+
src: srcProp,
|
|
114
|
+
fallbackSrc,
|
|
115
|
+
fallbackElement,
|
|
116
|
+
width,
|
|
117
|
+
testId
|
|
118
|
+
}) {
|
|
119
|
+
const src = useAsyncImage(srcProp || fallbackSrc);
|
|
120
|
+
const isRemoteImage = src !== void 0 && /^(https?|data):/.test(src);
|
|
121
|
+
const [isRemoteImageLoaded, setRemoteImageLoaded] = useTriggeredOnce();
|
|
122
|
+
const [hasError, setHasError] = useState(
|
|
123
|
+
srcProp === void 0 && fallbackSrc === void 0
|
|
124
|
+
);
|
|
125
|
+
const { asyncStyle, imgProps } = useMemo(() => {
|
|
126
|
+
const asyncStyle2 = !useAsImage ? getRemoteImageStyles(isRemoteImage, isRemoteImageLoaded, src) : {};
|
|
127
|
+
if (useAsImage || isRemoteImage) {
|
|
128
|
+
const imgProps2 = {
|
|
129
|
+
as: "img",
|
|
130
|
+
src,
|
|
131
|
+
"aria-hidden": true,
|
|
132
|
+
onError: ({
|
|
133
|
+
currentTarget
|
|
134
|
+
}) => {
|
|
135
|
+
currentTarget.onerror = null;
|
|
136
|
+
if (fallbackSrc !== void 0) {
|
|
137
|
+
currentTarget.src = fallbackSrc;
|
|
138
|
+
} else {
|
|
139
|
+
setHasError(true);
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
onLoad: isRemoteImage ? setRemoteImageLoaded : void 0
|
|
143
|
+
};
|
|
144
|
+
return { imgProps: imgProps2, asyncStyle: asyncStyle2 };
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
imgProps: {
|
|
148
|
+
backgroundSize: "cover"
|
|
149
|
+
},
|
|
150
|
+
asyncStyle: {
|
|
151
|
+
...asyncStyle2,
|
|
152
|
+
// has to be added as a inline style because vanilla-extract doesn't recognize this as a valid style
|
|
153
|
+
backgroundPosition: "center"
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}, [
|
|
157
|
+
fallbackSrc,
|
|
158
|
+
isRemoteImage,
|
|
159
|
+
isRemoteImageLoaded,
|
|
160
|
+
src,
|
|
161
|
+
useAsImage,
|
|
162
|
+
setRemoteImageLoaded
|
|
163
|
+
]);
|
|
164
|
+
const mainElement = hasError && fallbackElement || /* @__PURE__ */ React.createElement(
|
|
165
|
+
Box,
|
|
166
|
+
{
|
|
167
|
+
...imgProps,
|
|
168
|
+
height: "full",
|
|
169
|
+
position: "absolute",
|
|
170
|
+
style: {
|
|
171
|
+
WebkitTouchCallout: "none",
|
|
172
|
+
transition: "opacity .15s linear",
|
|
173
|
+
userSelect: "none",
|
|
174
|
+
...asyncStyle
|
|
175
|
+
},
|
|
176
|
+
width: "full"
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
return /* @__PURE__ */ React.createElement(
|
|
180
|
+
Box,
|
|
181
|
+
{
|
|
182
|
+
"aria-label": alt,
|
|
183
|
+
borderRadius,
|
|
184
|
+
boxShadow,
|
|
185
|
+
height: typeof height === "string" ? height : void 0,
|
|
186
|
+
overflow: "hidden",
|
|
187
|
+
position: "relative",
|
|
188
|
+
role: "img",
|
|
189
|
+
style: {
|
|
190
|
+
background,
|
|
191
|
+
height: typeof height === "number" ? height : void 0,
|
|
192
|
+
width: typeof width === "number" ? width : void 0
|
|
193
|
+
},
|
|
194
|
+
width: typeof width === "string" ? width : void 0,
|
|
195
|
+
testId
|
|
196
|
+
},
|
|
197
|
+
mainElement,
|
|
198
|
+
borderColor ? /* @__PURE__ */ React.createElement(
|
|
199
|
+
Box,
|
|
200
|
+
{
|
|
201
|
+
...typeof borderColor === "object" && "custom" in borderColor ? { style: { borderColor: borderColor.custom } } : { borderColor },
|
|
202
|
+
borderRadius,
|
|
203
|
+
borderStyle: "solid",
|
|
204
|
+
borderWidth: "1",
|
|
205
|
+
height: "full",
|
|
206
|
+
position: "relative",
|
|
207
|
+
width: "full"
|
|
208
|
+
}
|
|
209
|
+
) : null
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
var getRemoteImageStyles = (isRemoteImage, isRemoteImageLoaded, src) => {
|
|
213
|
+
if (isRemoteImage) {
|
|
214
|
+
return {
|
|
215
|
+
opacity: isRemoteImageLoaded ? 1 : 0
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
const safeSrc = sanitizeCssUrl(src);
|
|
219
|
+
return {
|
|
220
|
+
// note the url must have quotation, see https://github.com/evanw/esbuild/issues/1843#issuecomment-1370108070
|
|
221
|
+
backgroundImage: safeSrc ? `url('${safeSrc}')` : void 0,
|
|
222
|
+
backgroundRepeat: "no-repeat",
|
|
223
|
+
opacity: src ? 1 : 0
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export {
|
|
228
|
+
preloadRemoteImages,
|
|
229
|
+
AsyncImage
|
|
230
|
+
};
|