Files
FrenoCorp/node_modules/@stripe/stripe-js/src/index.ts
Michael Freno 7c684a42cc FRE-600: Fix code review blockers
- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 00:08:01 -04:00

39 lines
1012 B
TypeScript

import {StripeConstructor} from '../types';
import {loadScript, initStripe, LoadStripe} from './shared';
let stripePromise: Promise<StripeConstructor | null> | null;
let loadCalled = false;
const getStripePromise: () => Promise<StripeConstructor | null> = () => {
if (stripePromise) {
return stripePromise;
}
stripePromise = loadScript(null).catch((error) => {
// clear cache on error
stripePromise = null;
return Promise.reject(error);
});
return stripePromise;
};
// Execute our own script injection after a tick to give users time to do their
// own script injection.
Promise.resolve()
.then(() => getStripePromise())
.catch((error) => {
if (!loadCalled) {
console.warn(error);
}
});
export const loadStripe: LoadStripe = (...args) => {
loadCalled = true;
const startTime = Date.now();
// if previous attempts are unsuccessful, will re-load script
return getStripePromise().then((maybeStripe) =>
initStripe(maybeStripe, args, startTime)
);
};