@tagadapay/plugin-sdk 2.4.37 → 2.4.39
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/dist/react/hooks/usePayment.d.ts +1 -1
- package/dist/react/hooks/usePluginConfig.js +2 -13
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/providers/TagadaProvider.d.ts +0 -1
- package/dist/react/providers/TagadaProvider.js +16 -12
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* - Headers for store/account info
|
|
19
19
|
* - Meta tags for deployment config
|
|
20
20
|
*/
|
|
21
|
-
import {
|
|
21
|
+
import { useTagadaContext } from '../providers/TagadaProvider';
|
|
22
22
|
// Simple cache for plugin configuration
|
|
23
23
|
let cachedConfig = null;
|
|
24
24
|
let configPromise = null;
|
|
@@ -161,18 +161,7 @@ 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
|
|
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
|
-
}
|
|
175
|
-
const { pluginConfig, pluginConfigLoading } = context;
|
|
164
|
+
const { pluginConfig, pluginConfigLoading } = useTagadaContext();
|
|
176
165
|
return {
|
|
177
166
|
storeId: pluginConfig.storeId,
|
|
178
167
|
accountId: pluginConfig.accountId,
|
package/dist/react/index.d.ts
CHANGED
|
@@ -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
|
|
25
|
+
export { useTagadaContext } 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';
|
package/dist/react/index.js
CHANGED
|
@@ -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
|
|
27
|
+
export { useTagadaContext } 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,5 +60,4 @@ 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;
|
|
64
63
|
export {};
|
|
@@ -66,8 +66,19 @@ rawPluginConfig, }) {
|
|
|
66
66
|
hasLoggedRef.current = true;
|
|
67
67
|
}
|
|
68
68
|
// Load plugin configuration directly (not using hook to avoid circular dependency)
|
|
69
|
-
|
|
70
|
-
const [
|
|
69
|
+
// Initialize with raw config if available to avoid empty config during loading
|
|
70
|
+
const [pluginConfig, setPluginConfig] = useState(() => {
|
|
71
|
+
if (rawPluginConfig) {
|
|
72
|
+
return {
|
|
73
|
+
storeId: rawPluginConfig.storeId,
|
|
74
|
+
accountId: rawPluginConfig.accountId,
|
|
75
|
+
basePath: rawPluginConfig.basePath ?? '/',
|
|
76
|
+
config: rawPluginConfig.config ?? {},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return { basePath: '/', config: {} };
|
|
80
|
+
});
|
|
81
|
+
const [configLoading, setConfigLoading] = useState(!rawPluginConfig);
|
|
71
82
|
// Load plugin config on mount with the specified variant
|
|
72
83
|
useEffect(() => {
|
|
73
84
|
const loadConfig = async () => {
|
|
@@ -524,12 +535,9 @@ rawPluginConfig, }) {
|
|
|
524
535
|
refreshCoordinator,
|
|
525
536
|
]);
|
|
526
537
|
// Determine if we should show loading
|
|
527
|
-
//
|
|
528
|
-
|
|
529
|
-
const
|
|
530
|
-
const canRenderChildren = blockUntilSessionReady
|
|
531
|
-
? !configLoading && storeId && isInitialized // Old behavior: wait for all phases
|
|
532
|
-
: !configLoading && storeId; // New behavior: render after phases 1 & 2
|
|
538
|
+
// Always block until config is loaded (even if empty)
|
|
539
|
+
const shouldShowLoading = configLoading;
|
|
540
|
+
const canRenderChildren = !configLoading;
|
|
533
541
|
return (_jsxs(TagadaContext.Provider, { value: contextValue, children: [shouldShowLoading && _jsx(InitializationLoader, {}), finalDebugMode && canRenderChildren && (_jsxs(_Fragment, { children: [_jsx("button", { onClick: () => setIsDebugDrawerOpen(true), style: {
|
|
534
542
|
position: 'fixed',
|
|
535
543
|
bottom: '16px',
|
|
@@ -560,10 +568,6 @@ export function useTagadaContext() {
|
|
|
560
568
|
}
|
|
561
569
|
return context;
|
|
562
570
|
}
|
|
563
|
-
// Safe version that returns null instead of throwing
|
|
564
|
-
export function useTagadaContextSafe() {
|
|
565
|
-
return useContext(TagadaContext);
|
|
566
|
-
}
|
|
567
571
|
// Helper functions
|
|
568
572
|
function getCurrencySymbol(code) {
|
|
569
573
|
const symbols = {
|