@tagadapay/plugin-sdk 2.2.9 → 2.3.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.
@@ -58,6 +58,8 @@ export function useCheckout(options = {}) {
58
58
  throw new Error('Cannot initialize new checkout when checkoutToken is already provided. The existing checkout will be auto-loaded.');
59
59
  }
60
60
  // Wait for CMS session to initialize before making API calls
61
+ // Note: If TagadaProvider has blockUntilSessionReady=true, this component won't render
62
+ // until session is ready, so this wait is mainly for the new non-blocking mode
61
63
  if (!isSessionInitialized) {
62
64
  console.log('🔄 [useCheckout] Waiting for session initialization to complete...');
63
65
  await new Promise((resolve) => {
@@ -53,8 +53,9 @@ interface TagadaProviderProps {
53
53
  customApiConfig?: Partial<EnvironmentConfig>;
54
54
  debugMode?: boolean;
55
55
  localConfig?: string;
56
+ blockUntilSessionReady?: boolean;
56
57
  }
57
58
  export declare function TagadaProvider({ children, environment, customApiConfig, debugMode, // Remove default, will be set based on environment
58
- localConfig, }: TagadaProviderProps): import("react/jsx-runtime").JSX.Element;
59
+ localConfig, blockUntilSessionReady, }: TagadaProviderProps): import("react/jsx-runtime").JSX.Element;
59
60
  export declare function useTagadaContext(): TagadaContextValue;
60
61
  export {};
@@ -46,7 +46,8 @@ const InitializationLoader = () => (_jsxs("div", { style: {
46
46
  ` })] }));
47
47
  const TagadaContext = createContext(null);
48
48
  export function TagadaProvider({ children, environment, customApiConfig, debugMode, // Remove default, will be set based on environment
49
- localConfig, }) {
49
+ localConfig, blockUntilSessionReady = false, // Default to new non-blocking behavior
50
+ }) {
50
51
  // LOCAL DEV ONLY: Use localConfig override if in local development, otherwise use default
51
52
  const isLocalDev = typeof window !== 'undefined' &&
52
53
  (window.location.hostname === 'localhost' ||
@@ -83,7 +84,12 @@ localConfig, }) {
83
84
  basePath: config.basePath,
84
85
  hasConfig: !!config.config,
85
86
  });
86
- console.log('🚀 Children can now render - Phase 3 (session init) will continue in background');
87
+ if (blockUntilSessionReady) {
88
+ console.log('⏳ Blocking mode: Children will render after Phase 3 (session init) completes');
89
+ }
90
+ else {
91
+ console.log('🚀 Non-blocking mode: Children can now render - Phase 3 (session init) will continue in background');
92
+ }
87
93
  }
88
94
  catch (error) {
89
95
  console.error('❌ Failed to load plugin config in TagadaProvider:', error);
@@ -517,9 +523,11 @@ localConfig, }) {
517
523
  ]);
518
524
  // Determine if we should show loading
519
525
  // Phase 1 & 2 are mandatory: config loading and storeId availability
520
- // Phase 3 (session initialization) is now optional/non-blocking
526
+ // Phase 3 (session initialization) is optional/non-blocking by default
521
527
  const shouldShowLoading = configLoading || (!storeId && configLoading);
522
- const canRenderChildren = !configLoading && storeId; // Remove isInitialized requirement
528
+ const canRenderChildren = blockUntilSessionReady
529
+ ? (!configLoading && storeId && isInitialized) // Old behavior: wait for all phases
530
+ : (!configLoading && storeId); // New behavior: render after phases 1 & 2
523
531
  return (_jsxs(TagadaContext.Provider, { value: contextValue, children: [shouldShowLoading && _jsx(InitializationLoader, {}), finalDebugMode && canRenderChildren && (_jsxs(_Fragment, { children: [_jsx("button", { onClick: () => setIsDebugDrawerOpen(true), style: {
524
532
  position: 'fixed',
525
533
  bottom: '16px',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagadapay/plugin-sdk",
3
- "version": "2.2.9",
3
+ "version": "2.3.0",
4
4
  "description": "Modern React SDK for building Tagada Pay plugins",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",