@tagadapay/plugin-sdk 2.3.0 → 2.3.3

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 (2) hide show
  1. package/README.md +90 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -15,6 +15,7 @@ A comprehensive React SDK for building plugins on the TagadaPay platform. Create
15
15
  ### Plugin Development
16
16
 
17
17
  - **[Plugin Configuration](./docs/PLUGIN_CONFIG.md)** - How to access store context, config, and branding
18
+ - **[Initialization Modes](#-initialization-modes)** - Choose between blocking and non-blocking initialization
18
19
  - **[Google Autocomplete](./docs/README-google-autocomplete.md)** - Address autocomplete with Google Places API
19
20
  - **[ISO Data](./docs/README-iso-data.md)** - Country and region data with Google integration
20
21
 
@@ -164,6 +165,95 @@ function App() {
164
165
  export default App;
165
166
  ```
166
167
 
168
+ ## 🚀 Initialization Modes
169
+
170
+ The TagadaProvider supports two initialization modes to give you control over when your components render:
171
+
172
+ ### Non-Blocking Mode (Default - Recommended)
173
+
174
+ ```tsx
175
+ <TagadaProvider>
176
+ {/* Children render immediately after config loads */}
177
+ <YourApp />
178
+ </TagadaProvider>
179
+
180
+ // OR explicitly
181
+ <TagadaProvider blockUntilSessionReady={false}>
182
+ <YourApp />
183
+ </TagadaProvider>
184
+ ```
185
+
186
+ **Flow:**
187
+ 1. **Phase 1 & 2** ✅ Plugin config loads → Children render immediately
188
+ 2. **Phase 3** 🔄 Session initialization runs in background
189
+ 3. **API calls** 🔄 Hooks automatically wait for session to be ready
190
+
191
+ **Benefits:**
192
+ - ⚡ **Faster rendering** - UI appears immediately
193
+ - 🎯 **Better UX** - Show loading states while session initializes
194
+ - 🔄 **Automatic waiting** - Hooks handle session timing for you
195
+
196
+ ### Blocking Mode (Legacy Behavior)
197
+
198
+ ```tsx
199
+ <TagadaProvider blockUntilSessionReady={true}>
200
+ {/* Children render only after ALL initialization completes */}
201
+ <YourApp />
202
+ </TagadaProvider>
203
+ ```
204
+
205
+ **Flow:**
206
+ 1. **All Phases** ⏳ Config + Session must complete before children render
207
+ 2. **API calls** ✅ Work immediately (no waiting needed)
208
+
209
+ **Use when:**
210
+ - 🔄 **Migrating** from older SDK versions
211
+ - 🎯 **Simple apps** that don't need progressive loading
212
+
213
+ ### Console Logs
214
+
215
+ The SDK logs help you understand which mode you're using:
216
+
217
+ **Non-blocking mode:**
218
+ ```
219
+ ✅ Phase 1 & 2 Complete - Plugin config loaded
220
+ 🚀 Non-blocking mode: Children can now render - Phase 3 will continue in background
221
+ 🔄 [useCheckout] Waiting for session initialization to complete...
222
+ ✅ Phase 3 Complete - Session initialization completed successfully
223
+ ✅ [useCheckout] Session initialized, proceeding with checkout init
224
+ ```
225
+
226
+ **Blocking mode:**
227
+ ```
228
+ ✅ Phase 1 & 2 Complete - Plugin config loaded
229
+ ⏳ Blocking mode: Children will render after Phase 3 completes
230
+ ✅ Phase 3 Complete - Session initialization completed successfully
231
+ ```
232
+
233
+ ### TagadaProvider API
234
+
235
+ ```tsx
236
+ interface TagadaProviderProps {
237
+ children: ReactNode;
238
+ environment?: 'local' | 'development' | 'staging' | 'production';
239
+ customApiConfig?: Partial<EnvironmentConfig>;
240
+ debugMode?: boolean;
241
+ localConfig?: string; // LOCAL DEV ONLY: Override config variant
242
+ blockUntilSessionReady?: boolean; // Default: false
243
+ }
244
+ ```
245
+
246
+ | Prop | Type | Default | Description |
247
+ |------|------|---------|-------------|
248
+ | `children` | `ReactNode` | - | Your plugin components |
249
+ | `environment` | `string` | auto-detect | Override environment detection |
250
+ | `customApiConfig` | `object` | - | Custom API configuration |
251
+ | `debugMode` | `boolean` | auto (false in prod) | Enable debug features |
252
+ | `localConfig` | `string` | `'default'` | Config variant for local dev |
253
+ | `blockUntilSessionReady` | `boolean` | `false` | Use legacy blocking behavior |
254
+
255
+ > **Version Compatibility:** The `blockUntilSessionReady` option was added in v2.3.0. For older versions, the blocking behavior was the default and only option.
256
+
167
257
  ### Development vs Production
168
258
 
169
259
  | Environment | Store/Account ID | Deployment Config | How it Works |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagadapay/plugin-sdk",
3
- "version": "2.3.0",
3
+ "version": "2.3.3",
4
4
  "description": "Modern React SDK for building Tagada Pay plugins",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",