@tagadapay/plugin-sdk 2.4.35 → 2.4.37

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.
@@ -18,7 +18,7 @@
18
18
  * - Headers for store/account info
19
19
  * - Meta tags for deployment config
20
20
  */
21
- import { useTagadaContext } from '../providers/TagadaProvider';
21
+ import { useTagadaContextSafe } from '../providers/TagadaProvider';
22
22
  // Simple cache for plugin configuration
23
23
  let cachedConfig = null;
24
24
  let configPromise = null;
@@ -161,7 +161,17 @@ export const loadPluginConfig = async (configVariant = 'default', rawConfig) =>
161
161
  * Gets config from TagadaProvider context (no parameters needed)
162
162
  */
163
163
  export const usePluginConfig = () => {
164
- const context = useTagadaContext();
164
+ const context = useTagadaContextSafe();
165
+ // If context is not ready yet, return loading state
166
+ if (!context) {
167
+ return {
168
+ storeId: undefined,
169
+ accountId: undefined,
170
+ basePath: '/',
171
+ config: {},
172
+ loading: true,
173
+ };
174
+ }
165
175
  const { pluginConfig, pluginConfigLoading } = context;
166
176
  return {
167
177
  storeId: pluginConfig.storeId,
@@ -22,7 +22,7 @@ export { useShippingRates } from './hooks/useShippingRates';
22
22
  export type { UseShippingRatesOptions, UseShippingRatesResult } from './hooks/useShippingRates';
23
23
  export { useTranslations } from './hooks/useTranslations';
24
24
  export { useVipOffers } from './hooks/useVipOffers';
25
- export { useTagadaContext } from './providers/TagadaProvider';
25
+ export { useTagadaContext, useTagadaContextSafe } from './providers/TagadaProvider';
26
26
  export { clearPluginConfigCache, debugPluginConfig, getPluginConfig, useBasePath, usePluginConfig } from './hooks/usePluginConfig';
27
27
  export type { PluginConfig } from './hooks/usePluginConfig';
28
28
  export { getAvailableLanguages, useCountryOptions, useISOData, useRegionOptions, useLanguageImport } from './hooks/useISOData';
@@ -24,7 +24,7 @@ export { useSession } from './hooks/useSession';
24
24
  export { useShippingRates } from './hooks/useShippingRates';
25
25
  export { useTranslations } from './hooks/useTranslations';
26
26
  export { useVipOffers } from './hooks/useVipOffers';
27
- export { useTagadaContext } from './providers/TagadaProvider';
27
+ export { useTagadaContext, useTagadaContextSafe } from './providers/TagadaProvider';
28
28
  // Plugin configuration hooks
29
29
  export { clearPluginConfigCache, debugPluginConfig, getPluginConfig, useBasePath, usePluginConfig } from './hooks/usePluginConfig';
30
30
  // ISO Data hooks
@@ -60,4 +60,5 @@ export declare function TagadaProvider({ children, environment, customApiConfig,
60
60
  localConfig, blockUntilSessionReady, // Default to new non-blocking behavior
61
61
  rawPluginConfig, }: TagadaProviderProps): import("react/jsx-runtime").JSX.Element;
62
62
  export declare function useTagadaContext(): TagadaContextValue;
63
+ export declare function useTagadaContextSafe(): TagadaContextValue | null;
63
64
  export {};
@@ -560,6 +560,10 @@ export function useTagadaContext() {
560
560
  }
561
561
  return context;
562
562
  }
563
+ // Safe version that returns null instead of throwing
564
+ export function useTagadaContextSafe() {
565
+ return useContext(TagadaContext);
566
+ }
563
567
  // Helper functions
564
568
  function getCurrencySymbol(code) {
565
569
  const symbols = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagadapay/plugin-sdk",
3
- "version": "2.4.35",
3
+ "version": "2.4.37",
4
4
  "description": "Modern React SDK for building Tagada Pay plugins",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",