@tagadapay/plugin-sdk 3.1.12 → 3.1.24

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 (144) hide show
  1. package/build-cdn.js +397 -11
  2. package/dist/data/iso3166.d.ts +23 -33
  3. package/dist/data/iso3166.js +134 -198
  4. package/dist/data/languages.d.ts +5 -64
  5. package/dist/data/languages.js +23 -143
  6. package/dist/external-tracker.js +623 -3426
  7. package/dist/external-tracker.min.js +2 -25
  8. package/dist/external-tracker.min.js.map +4 -4
  9. package/dist/react/config/payment.d.ts +14 -4
  10. package/dist/react/config/payment.js +47 -9
  11. package/dist/react/hooks/useCheckout.d.ts +3 -0
  12. package/dist/react/hooks/useCheckout.js +4 -1
  13. package/dist/react/hooks/useISOData.js +1 -1
  14. package/dist/react/hooks/usePaymentPolling.d.ts +3 -3
  15. package/dist/react/hooks/usePluginConfig.js +9 -10
  16. package/dist/react/providers/TagadaProvider.js +1 -1
  17. package/dist/tagada-react-sdk-minimal.min.js +36 -0
  18. package/dist/tagada-react-sdk-minimal.min.js.map +7 -0
  19. package/dist/tagada-react-sdk.js +37821 -0
  20. package/dist/tagada-react-sdk.min.js +78 -0
  21. package/dist/tagada-react-sdk.min.js.map +7 -0
  22. package/dist/tagada-sdk.js +16044 -0
  23. package/dist/tagada-sdk.min.js +32 -0
  24. package/dist/tagada-sdk.min.js.map +7 -0
  25. package/dist/v2/cdn-react-minimal.d.ts +23 -0
  26. package/dist/v2/cdn-react-minimal.js +26 -0
  27. package/dist/v2/core/client.d.ts +4 -2
  28. package/dist/v2/core/client.js +5 -4
  29. package/dist/v2/core/config/environment.js +2 -1
  30. package/dist/v2/core/errors.d.ts +75 -0
  31. package/dist/v2/core/errors.js +104 -0
  32. package/dist/v2/core/funnelClient.d.ts +100 -10
  33. package/dist/v2/core/funnelClient.js +121 -27
  34. package/dist/v2/core/isoData.d.ts +4 -4
  35. package/dist/v2/core/isoData.js +7 -7
  36. package/dist/v2/core/pixelMapping.d.ts +49 -0
  37. package/dist/v2/core/pixelMapping.js +363 -0
  38. package/dist/v2/core/resources/apiClient.d.ts +2 -0
  39. package/dist/v2/core/resources/apiClient.js +52 -9
  40. package/dist/v2/core/resources/checkout.d.ts +99 -30
  41. package/dist/v2/core/resources/checkout.js +14 -0
  42. package/dist/v2/core/resources/customer.d.ts +20 -19
  43. package/dist/v2/core/resources/expressPaymentMethods.d.ts +1 -0
  44. package/dist/v2/core/resources/funnel.d.ts +17 -17
  45. package/dist/v2/core/resources/payments.d.ts +89 -13
  46. package/dist/v2/core/resources/payments.js +27 -9
  47. package/dist/v2/core/resources/postPurchases.d.ts +17 -0
  48. package/dist/v2/core/resources/postPurchases.js +20 -0
  49. package/dist/v2/core/types.d.ts +50 -12
  50. package/dist/v2/core/types.js +0 -3
  51. package/dist/v2/core/utils/checkout.d.ts +2 -2
  52. package/dist/v2/core/utils/checkout.js +7 -2
  53. package/dist/v2/core/utils/currency.d.ts +14 -0
  54. package/dist/v2/core/utils/currency.js +40 -0
  55. package/dist/v2/core/utils/deviceInfo.d.ts +0 -10
  56. package/dist/v2/core/utils/deviceInfo.js +152 -76
  57. package/dist/v2/core/utils/index.d.ts +1 -0
  58. package/dist/v2/core/utils/index.js +2 -0
  59. package/dist/v2/core/utils/order.d.ts +13 -9
  60. package/dist/v2/core/utils/pluginConfig.d.ts +8 -0
  61. package/dist/v2/core/utils/pluginConfig.js +36 -12
  62. package/dist/v2/index.d.ts +6 -3
  63. package/dist/v2/index.js +4 -2
  64. package/dist/v2/react/components/FunnelScriptInjector.js +166 -77
  65. package/dist/v2/react/components/StripeExpressButton.d.ts +13 -0
  66. package/dist/v2/react/components/StripeExpressButton.js +171 -0
  67. package/dist/v2/react/components/WhopCheckout.d.ts +24 -0
  68. package/dist/v2/react/components/WhopCheckout.js +237 -0
  69. package/dist/v2/react/hooks/__examples__/FunnelContextExample.js +1 -1
  70. package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.d.ts +14 -0
  71. package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.js +181 -0
  72. package/dist/v2/react/hooks/payment-actions/useErrorAction.d.ts +9 -0
  73. package/dist/v2/react/hooks/payment-actions/useErrorAction.js +21 -0
  74. package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.d.ts +14 -0
  75. package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.js +187 -0
  76. package/dist/v2/react/hooks/payment-actions/useKessPayAction.d.ts +11 -0
  77. package/dist/v2/react/hooks/payment-actions/useKessPayAction.js +91 -0
  78. package/dist/v2/react/hooks/payment-actions/useMasterCardAction.d.ts +24 -0
  79. package/dist/v2/react/hooks/payment-actions/useMasterCardAction.js +221 -0
  80. package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.d.ts +15 -0
  81. package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.js +142 -0
  82. package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.d.ts +3 -0
  83. package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.js +31 -0
  84. package/dist/v2/react/hooks/payment-actions/useRedirectAction.d.ts +10 -0
  85. package/dist/v2/react/hooks/payment-actions/useRedirectAction.js +35 -0
  86. package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.d.ts +14 -0
  87. package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.js +192 -0
  88. package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.d.ts +14 -0
  89. package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.js +81 -0
  90. package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.d.ts +11 -0
  91. package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.js +84 -0
  92. package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.d.ts +14 -0
  93. package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.js +36 -0
  94. package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.d.ts +31 -0
  95. package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.js +212 -0
  96. package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.d.ts +14 -0
  97. package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.js +207 -0
  98. package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.d.ts +12 -0
  99. package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.js +101 -0
  100. package/dist/v2/react/hooks/useApplePayCheckout.js +8 -8
  101. package/dist/v2/react/hooks/useCheckoutQuery.d.ts +16 -0
  102. package/dist/v2/react/hooks/useCheckoutQuery.js +63 -10
  103. package/dist/v2/react/hooks/useFunnel.d.ts +15 -4
  104. package/dist/v2/react/hooks/useFunnel.js +8 -4
  105. package/dist/v2/react/hooks/useGeoLocation.d.ts +2 -1
  106. package/dist/v2/react/hooks/useGeoLocation.js +4 -2
  107. package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +2 -0
  108. package/dist/v2/react/hooks/useGoogleAutocomplete.js +29 -15
  109. package/dist/v2/react/hooks/useISOData.d.ts +2 -5
  110. package/dist/v2/react/hooks/useISOData.js +26 -27
  111. package/dist/v2/react/hooks/usePaymentPolling.d.ts +3 -3
  112. package/dist/v2/react/hooks/usePaymentQuery.d.ts +18 -5
  113. package/dist/v2/react/hooks/usePaymentQuery.js +63 -1015
  114. package/dist/v2/react/hooks/usePaymentRetrieve.d.ts +3 -2
  115. package/dist/v2/react/hooks/usePaymentRetrieve.js +3 -1
  116. package/dist/v2/react/hooks/usePixelTracking.d.ts +5 -48
  117. package/dist/v2/react/hooks/usePixelTracking.js +283 -504
  118. package/dist/v2/react/hooks/usePostPurchasesQuery.js +34 -2
  119. package/dist/v2/react/hooks/useRemappableParams.d.ts +2 -6
  120. package/dist/v2/react/hooks/useRemappableParams.js +23 -23
  121. package/dist/v2/react/hooks/useSetPaymentMethod.d.ts +16 -0
  122. package/dist/v2/react/hooks/useSetPaymentMethod.js +33 -0
  123. package/dist/v2/react/hooks/useShippingRatesQuery.js +13 -5
  124. package/dist/v2/react/hooks/useStepConfig.d.ts +23 -6
  125. package/dist/v2/react/hooks/useStepConfig.js +14 -7
  126. package/dist/v2/react/hooks/useTranslation.js +23 -8
  127. package/dist/v2/react/hooks/useWhopPaymentPolling.d.ts +30 -0
  128. package/dist/v2/react/hooks/useWhopPaymentPolling.js +61 -0
  129. package/dist/v2/react/index.d.ts +15 -1
  130. package/dist/v2/react/index.js +7 -0
  131. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +3 -1
  132. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +12 -2
  133. package/dist/v2/react/providers/TagadaProvider.js +74 -5
  134. package/dist/v2/standalone/external-tracker.d.ts +52 -46
  135. package/dist/v2/standalone/external-tracker.js +205 -98
  136. package/dist/v2/standalone/index.d.ts +40 -0
  137. package/dist/v2/standalone/index.js +148 -1
  138. package/dist/v2/standalone/payment-service.d.ts +134 -0
  139. package/dist/v2/standalone/payment-service.js +928 -0
  140. package/package.json +6 -4
  141. package/dist/react/utils/__tests__/urlUtils.test.d.ts +0 -1
  142. package/dist/react/utils/__tests__/urlUtils.test.js +0 -189
  143. package/dist/v2/core/__tests__/pathRemapping.test.d.ts +0 -11
  144. package/dist/v2/core/__tests__/pathRemapping.test.js +0 -776
package/build-cdn.js CHANGED
@@ -4,8 +4,10 @@
4
4
  * Build script for creating standalone CDN bundles
5
5
  *
6
6
  * This creates:
7
- * - dist/external-tracker.min.js - Minified UMD bundle for CDN
7
+ * - dist/external-tracker.min.js - Minified UMD bundle for CDN (tracking only)
8
8
  * - dist/external-tracker.js - Non-minified for debugging
9
+ * - dist/tagada-sdk.min.js - Full standalone SDK bundle for CDN
10
+ * - dist/tagada-sdk.js - Non-minified for debugging
9
11
  *
10
12
  * Usage:
11
13
  * node build-cdn.js
@@ -14,16 +16,25 @@
14
16
 
15
17
  const esbuild = require('esbuild');
16
18
  const path = require('path');
19
+ const fs = require('fs');
17
20
 
18
- const ENTRY_POINT = path.join(__dirname, 'src/v2/standalone/external-tracker.ts');
21
+ const TRACKER_ENTRY = path.join(__dirname, 'src/v2/standalone/external-tracker.ts');
22
+ const SDK_ENTRY = path.join(__dirname, 'src/v2/standalone/index.ts');
23
+ const REACT_SDK_ENTRY = path.join(__dirname, 'src/v2/react/index.ts');
24
+ const REACT_SDK_MINIMAL_ENTRY = path.join(__dirname, 'src/v2/cdn-react-minimal.ts');
19
25
  const OUT_DIR = path.join(__dirname, 'dist');
20
26
 
21
27
  async function build() {
22
- console.log('šŸ”Ø Building external-tracker CDN bundles...\n');
28
+ console.log('šŸ”Ø Building CDN bundles...\n');
23
29
 
30
+ // ==========================================================================
31
+ // EXTERNAL TRACKER (lightweight, tracking only)
32
+ // ==========================================================================
33
+ console.log('šŸ“¦ Building external-tracker...');
34
+
24
35
  // Build minified UMD bundle
25
36
  await esbuild.build({
26
- entryPoints: [ENTRY_POINT],
37
+ entryPoints: [TRACKER_ENTRY],
27
38
  bundle: true,
28
39
  minify: true,
29
40
  sourcemap: true,
@@ -59,7 +70,7 @@ if (typeof window !== 'undefined' && TagadaTrackerBundle && TagadaTrackerBundle.
59
70
 
60
71
  // Build non-minified version for debugging
61
72
  await esbuild.build({
62
- entryPoints: [ENTRY_POINT],
73
+ entryPoints: [TRACKER_ENTRY],
63
74
  bundle: true,
64
75
  minify: false,
65
76
  sourcemap: false,
@@ -90,19 +101,394 @@ if (typeof window !== 'undefined' && TagadaTrackerBundle && TagadaTrackerBundle.
90
101
 
91
102
  console.log(' āœ… dist/external-tracker.js (non-minified for debugging)');
92
103
 
104
+ // ==========================================================================
105
+ // FULL STANDALONE SDK (createTagadaClient, config loading, hot reload, etc.)
106
+ // ==========================================================================
107
+ console.log('\nšŸ“¦ Building tagada-sdk (full standalone SDK)...');
108
+
109
+ // Build minified SDK bundle
110
+ await esbuild.build({
111
+ entryPoints: [SDK_ENTRY],
112
+ bundle: true,
113
+ minify: true,
114
+ sourcemap: true,
115
+ target: ['es2018', 'chrome58', 'firefox57', 'safari11', 'edge79'],
116
+ format: 'iife',
117
+ globalName: 'TagadaSDKBundle',
118
+ outfile: path.join(OUT_DIR, 'tagada-sdk.min.js'),
119
+ external: [],
120
+ define: {
121
+ 'process.env.NODE_ENV': '"production"',
122
+ },
123
+ footer: {
124
+ js: `
125
+ // Expose SDK under window.tgd namespace (clean, single global)
126
+ if (typeof window !== 'undefined' && TagadaSDKBundle) {
127
+ window.tgd = window.tgd || {};
128
+ // Core
129
+ window.tgd.createTagadaClient = TagadaSDKBundle.createTagadaClient;
130
+ // Config utilities
131
+ window.tgd.getPluginConfig = TagadaSDKBundle.getPluginConfig;
132
+ window.tgd.loadPluginConfig = TagadaSDKBundle.loadPluginConfig;
133
+ // Hot reload
134
+ window.tgd.onConfigUpdate = TagadaSDKBundle.onConfigUpdate;
135
+ window.tgd.sendConfigUpdate = TagadaSDKBundle.sendConfigUpdate;
136
+ window.tgd.broadcastConfigUpdate = TagadaSDKBundle.broadcastConfigUpdate;
137
+ // Currency
138
+ window.tgd.formatMoney = TagadaSDKBundle.formatMoney;
139
+ // Script injection (auto-runs on load, but can be manually called)
140
+ window.tgd.injectStepConfigScripts = TagadaSDKBundle.injectStepConfigScripts;
141
+ // Full bundle reference
142
+ window.tgd.sdk = TagadaSDKBundle;
143
+ }
144
+ `.trim(),
145
+ },
146
+ banner: {
147
+ js: `/**
148
+ * TagadaPay SDK v${require('./package.json').version}
149
+ * CDN Bundle - Full standalone SDK for external/vanilla pages
150
+ * Usage: window.tgd.createTagadaClient(), window.tgd.formatMoney(), etc.
151
+ * @license MIT
152
+ */`,
153
+ },
154
+ });
155
+
156
+ console.log(' āœ… dist/tagada-sdk.min.js (minified + sourcemap)');
157
+
158
+ // Build non-minified SDK version for debugging
159
+ await esbuild.build({
160
+ entryPoints: [SDK_ENTRY],
161
+ bundle: true,
162
+ minify: false,
163
+ sourcemap: false,
164
+ target: ['es2018', 'chrome58', 'firefox57', 'safari11', 'edge79'],
165
+ format: 'iife',
166
+ globalName: 'TagadaSDKBundle',
167
+ outfile: path.join(OUT_DIR, 'tagada-sdk.js'),
168
+ external: [],
169
+ define: {
170
+ 'process.env.NODE_ENV': '"development"',
171
+ },
172
+ footer: {
173
+ js: `
174
+ // Expose SDK under window.tgd namespace (clean, single global)
175
+ if (typeof window !== 'undefined' && TagadaSDKBundle) {
176
+ window.tgd = window.tgd || {};
177
+ window.tgd.createTagadaClient = TagadaSDKBundle.createTagadaClient;
178
+ window.tgd.getPluginConfig = TagadaSDKBundle.getPluginConfig;
179
+ window.tgd.loadPluginConfig = TagadaSDKBundle.loadPluginConfig;
180
+ window.tgd.onConfigUpdate = TagadaSDKBundle.onConfigUpdate;
181
+ window.tgd.sendConfigUpdate = TagadaSDKBundle.sendConfigUpdate;
182
+ window.tgd.broadcastConfigUpdate = TagadaSDKBundle.broadcastConfigUpdate;
183
+ window.tgd.formatMoney = TagadaSDKBundle.formatMoney;
184
+ window.tgd.injectStepConfigScripts = TagadaSDKBundle.injectStepConfigScripts;
185
+ window.tgd.sdk = TagadaSDKBundle;
186
+ }
187
+ `.trim(),
188
+ },
189
+ banner: {
190
+ js: `/**
191
+ * TagadaPay SDK v${require('./package.json').version}
192
+ * CDN Bundle - Full standalone SDK (Debug Build)
193
+ * Usage: window.tgd.createTagadaClient(), window.tgd.formatMoney(), etc.
194
+ * @license MIT
195
+ */`,
196
+ },
197
+ });
198
+
199
+ console.log(' āœ… dist/tagada-sdk.js (non-minified for debugging)');
200
+
201
+ // ==========================================================================
202
+ // REACT SDK (TagadaProvider, hooks - for use with React apps via CDN)
203
+ // ==========================================================================
204
+ console.log('\nšŸ“¦ Building tagada-react-sdk (React hooks & provider)...');
205
+
206
+ // Build minified React SDK bundle
207
+ await esbuild.build({
208
+ entryPoints: [REACT_SDK_ENTRY],
209
+ bundle: true,
210
+ minify: true,
211
+ sourcemap: true,
212
+ target: ['es2018', 'chrome58', 'firefox57', 'safari11', 'edge79'],
213
+ format: 'iife',
214
+ globalName: 'TagadaReactSDKBundle',
215
+ outfile: path.join(OUT_DIR, 'tagada-react-sdk.min.js'),
216
+ // React is external - expects window.React
217
+ external: ['react', 'react-dom'],
218
+ define: {
219
+ 'process.env.NODE_ENV': '"production"',
220
+ },
221
+ footer: {
222
+ js: `
223
+ // Expose React SDK under window.tgd namespace
224
+ if (typeof window !== 'undefined' && TagadaReactSDKBundle) {
225
+ window.tgd = window.tgd || {};
226
+ // Provider
227
+ window.tgd.TagadaProvider = TagadaReactSDKBundle.TagadaProvider;
228
+ window.tgd.useTagadaContext = TagadaReactSDKBundle.useTagadaContext;
229
+ // Core hooks
230
+ window.tgd.useCheckout = TagadaReactSDKBundle.useCheckout;
231
+ window.tgd.useCheckoutSession = TagadaReactSDKBundle.useCheckoutSession;
232
+ window.tgd.useSession = TagadaReactSDKBundle.useSession;
233
+ window.tgd.useCustomer = TagadaReactSDKBundle.useCustomer;
234
+ window.tgd.useCustomerInfos = TagadaReactSDKBundle.useCustomerInfos;
235
+ window.tgd.useEnvironment = TagadaReactSDKBundle.useEnvironment;
236
+ window.tgd.useCurrency = TagadaReactSDKBundle.useCurrency;
237
+ window.tgd.useLocale = TagadaReactSDKBundle.useLocale;
238
+ // Commerce hooks
239
+ window.tgd.useShippingRates = TagadaReactSDKBundle.useShippingRates;
240
+ window.tgd.useDiscounts = TagadaReactSDKBundle.useDiscounts;
241
+ window.tgd.useOrderBump = TagadaReactSDKBundle.useOrderBump;
242
+ window.tgd.useOrderBumpV2 = TagadaReactSDKBundle.useOrderBumpV2;
243
+ window.tgd.useOrderBumpV3 = TagadaReactSDKBundle.useOrderBumpV3;
244
+ window.tgd.useProducts = TagadaReactSDKBundle.useProducts;
245
+ window.tgd.useOffers = TagadaReactSDKBundle.useOffers;
246
+ window.tgd.usePostPurchases = TagadaReactSDKBundle.usePostPurchases;
247
+ // Payment hooks
248
+ window.tgd.usePayment = TagadaReactSDKBundle.usePayment;
249
+ window.tgd.useThreeds = TagadaReactSDKBundle.useThreeds;
250
+ window.tgd.useApplePay = TagadaReactSDKBundle.useApplePay;
251
+ window.tgd.useGooglePay = TagadaReactSDKBundle.useGooglePay;
252
+ window.tgd.useExpressPaymentMethods = TagadaReactSDKBundle.useExpressPaymentMethods;
253
+ window.tgd.ExpressPaymentMethodsProvider = TagadaReactSDKBundle.ExpressPaymentMethodsProvider;
254
+ // Utility hooks
255
+ window.tgd.useGeoLocation = TagadaReactSDKBundle.useGeoLocation;
256
+ window.tgd.useGoogleAutocomplete = TagadaReactSDKBundle.useGoogleAutocomplete;
257
+ window.tgd.useISOData = TagadaReactSDKBundle.useISOData;
258
+ window.tgd.usePluginConfig = TagadaReactSDKBundle.usePluginConfig;
259
+ window.tgd.useTranslations = TagadaReactSDKBundle.useTranslations;
260
+ // Funnel
261
+ window.tgd.useFunnel = TagadaReactSDKBundle.useFunnel;
262
+ // Components
263
+ window.tgd.Button = TagadaReactSDKBundle.Button;
264
+ window.tgd.ApplePayButton = TagadaReactSDKBundle.ApplePayButton;
265
+ window.tgd.GooglePayButton = TagadaReactSDKBundle.GooglePayButton;
266
+ // Utilities
267
+ window.tgd.formatMoney = TagadaReactSDKBundle.formatMoney;
268
+ // Full bundle reference
269
+ window.tgd.react = TagadaReactSDKBundle;
270
+ }
271
+ `.trim(),
272
+ },
273
+ banner: {
274
+ js: `/**
275
+ * TagadaPay React SDK v${require('./package.json').version}
276
+ * CDN Bundle - React hooks and TagadaProvider for checkout integration
277
+ * Requires: React 18+ loaded before this script
278
+ * Usage: window.tgd.TagadaProvider, window.tgd.useCheckout, etc.
279
+ * @license MIT
280
+ */`,
281
+ },
282
+ });
283
+
284
+ console.log(' āœ… dist/tagada-react-sdk.min.js (minified + sourcemap)');
285
+
286
+ // Build non-minified React SDK version for debugging
287
+ await esbuild.build({
288
+ entryPoints: [REACT_SDK_ENTRY],
289
+ bundle: true,
290
+ minify: false,
291
+ sourcemap: false,
292
+ target: ['es2018', 'chrome58', 'firefox57', 'safari11', 'edge79'],
293
+ format: 'iife',
294
+ globalName: 'TagadaReactSDKBundle',
295
+ outfile: path.join(OUT_DIR, 'tagada-react-sdk.js'),
296
+ external: ['react', 'react-dom'],
297
+ define: {
298
+ 'process.env.NODE_ENV': '"development"',
299
+ },
300
+ footer: {
301
+ js: `
302
+ // Expose React SDK under window.tgd namespace
303
+ if (typeof window !== 'undefined' && TagadaReactSDKBundle) {
304
+ window.tgd = window.tgd || {};
305
+ window.tgd.TagadaProvider = TagadaReactSDKBundle.TagadaProvider;
306
+ window.tgd.useTagadaContext = TagadaReactSDKBundle.useTagadaContext;
307
+ window.tgd.useCheckout = TagadaReactSDKBundle.useCheckout;
308
+ window.tgd.useCheckoutSession = TagadaReactSDKBundle.useCheckoutSession;
309
+ window.tgd.useSession = TagadaReactSDKBundle.useSession;
310
+ window.tgd.useCustomer = TagadaReactSDKBundle.useCustomer;
311
+ window.tgd.useCustomerInfos = TagadaReactSDKBundle.useCustomerInfos;
312
+ window.tgd.useEnvironment = TagadaReactSDKBundle.useEnvironment;
313
+ window.tgd.useCurrency = TagadaReactSDKBundle.useCurrency;
314
+ window.tgd.useLocale = TagadaReactSDKBundle.useLocale;
315
+ window.tgd.useShippingRates = TagadaReactSDKBundle.useShippingRates;
316
+ window.tgd.useDiscounts = TagadaReactSDKBundle.useDiscounts;
317
+ window.tgd.useOrderBump = TagadaReactSDKBundle.useOrderBump;
318
+ window.tgd.useOrderBumpV2 = TagadaReactSDKBundle.useOrderBumpV2;
319
+ window.tgd.useOrderBumpV3 = TagadaReactSDKBundle.useOrderBumpV3;
320
+ window.tgd.useProducts = TagadaReactSDKBundle.useProducts;
321
+ window.tgd.useOffers = TagadaReactSDKBundle.useOffers;
322
+ window.tgd.usePostPurchases = TagadaReactSDKBundle.usePostPurchases;
323
+ window.tgd.usePayment = TagadaReactSDKBundle.usePayment;
324
+ window.tgd.useThreeds = TagadaReactSDKBundle.useThreeds;
325
+ window.tgd.useApplePay = TagadaReactSDKBundle.useApplePay;
326
+ window.tgd.useGooglePay = TagadaReactSDKBundle.useGooglePay;
327
+ window.tgd.useExpressPaymentMethods = TagadaReactSDKBundle.useExpressPaymentMethods;
328
+ window.tgd.ExpressPaymentMethodsProvider = TagadaReactSDKBundle.ExpressPaymentMethodsProvider;
329
+ window.tgd.useGeoLocation = TagadaReactSDKBundle.useGeoLocation;
330
+ window.tgd.useGoogleAutocomplete = TagadaReactSDKBundle.useGoogleAutocomplete;
331
+ window.tgd.useISOData = TagadaReactSDKBundle.useISOData;
332
+ window.tgd.usePluginConfig = TagadaReactSDKBundle.usePluginConfig;
333
+ window.tgd.useTranslations = TagadaReactSDKBundle.useTranslations;
334
+ window.tgd.useFunnel = TagadaReactSDKBundle.useFunnel;
335
+ window.tgd.Button = TagadaReactSDKBundle.Button;
336
+ window.tgd.ApplePayButton = TagadaReactSDKBundle.ApplePayButton;
337
+ window.tgd.GooglePayButton = TagadaReactSDKBundle.GooglePayButton;
338
+ window.tgd.formatMoney = TagadaReactSDKBundle.formatMoney;
339
+ window.tgd.react = TagadaReactSDKBundle;
340
+ }
341
+ `.trim(),
342
+ },
343
+ banner: {
344
+ js: `/**
345
+ * TagadaPay React SDK v${require('./package.json').version}
346
+ * CDN Bundle - React hooks and TagadaProvider (Debug Build)
347
+ * @license MIT
348
+ */`,
349
+ },
350
+ });
351
+
352
+ console.log(' āœ… dist/tagada-react-sdk.js (non-minified for debugging)');
353
+
354
+ // ==========================================================================
355
+ // MINIMAL REACT SDK (TagadaProvider + essential checkout hooks only)
356
+ // ==========================================================================
357
+ console.log('\nšŸ“¦ Building tagada-react-sdk-minimal (slim checkout SDK)...');
358
+
359
+ // Plugin to replace React imports with window globals
360
+ const reactGlobalsPlugin = {
361
+ name: 'react-globals',
362
+ setup(build) {
363
+ // Intercept react imports and return window globals
364
+ build.onResolve({ filter: /^react(-dom)?(\/.*)?$/ }, args => ({
365
+ path: args.path,
366
+ namespace: 'react-global',
367
+ }));
368
+
369
+ build.onLoad({ filter: /.*/, namespace: 'react-global' }, args => {
370
+ if (args.path === 'react') {
371
+ return {
372
+ contents: 'module.exports = window.React;',
373
+ loader: 'js',
374
+ };
375
+ }
376
+ // Handle JSX runtime - map to React.createElement
377
+ if (args.path === 'react/jsx-runtime' || args.path === 'react/jsx-dev-runtime') {
378
+ return {
379
+ contents: `
380
+ var React = window.React;
381
+ module.exports = {
382
+ jsx: React.createElement,
383
+ jsxs: React.createElement,
384
+ jsxDEV: React.createElement,
385
+ Fragment: React.Fragment,
386
+ };
387
+ `,
388
+ loader: 'js',
389
+ };
390
+ }
391
+ if (args.path === 'react-dom' || args.path === 'react-dom/client') {
392
+ return {
393
+ contents: 'module.exports = window.ReactDOM;',
394
+ loader: 'js',
395
+ };
396
+ }
397
+ return { contents: 'module.exports = {};', loader: 'js' };
398
+ });
399
+ },
400
+ };
401
+
402
+ // Build minified minimal React SDK bundle
403
+ await esbuild.build({
404
+ entryPoints: [REACT_SDK_MINIMAL_ENTRY],
405
+ bundle: true,
406
+ minify: true,
407
+ sourcemap: true,
408
+ target: ['es2018', 'chrome58', 'firefox57', 'safari11', 'edge79'],
409
+ format: 'iife',
410
+ globalName: 'TagadaReactMinimalBundle',
411
+ outfile: path.join(OUT_DIR, 'tagada-react-sdk-minimal.min.js'),
412
+ plugins: [reactGlobalsPlugin],
413
+ define: {
414
+ 'process.env.NODE_ENV': '"production"',
415
+ },
416
+ footer: {
417
+ js: `
418
+ // Expose minimal React SDK under window.tgd namespace
419
+ if (typeof window !== 'undefined' && TagadaReactMinimalBundle) {
420
+ window.tgd = window.tgd || {};
421
+ // Provider
422
+ window.tgd.TagadaProvider = TagadaReactMinimalBundle.TagadaProvider;
423
+ window.tgd.useTagadaContext = TagadaReactMinimalBundle.useTagadaContext;
424
+ // Core checkout hooks
425
+ window.tgd.useCheckout = TagadaReactMinimalBundle.useCheckout;
426
+ window.tgd.useShippingRates = TagadaReactMinimalBundle.useShippingRates;
427
+ window.tgd.useDiscounts = TagadaReactMinimalBundle.useDiscounts;
428
+ window.tgd.useOrderBump = TagadaReactMinimalBundle.useOrderBump;
429
+ window.tgd.usePostPurchases = TagadaReactMinimalBundle.usePostPurchases;
430
+ window.tgd.usePayment = TagadaReactMinimalBundle.usePayment;
431
+ window.tgd.useThreeds = TagadaReactMinimalBundle.useThreeds;
432
+ // Utilities
433
+ window.tgd.useCurrency = TagadaReactMinimalBundle.useCurrency;
434
+ window.tgd.usePluginConfig = TagadaReactMinimalBundle.usePluginConfig;
435
+ window.tgd.useFunnel = TagadaReactMinimalBundle.useFunnel;
436
+ window.tgd.formatMoney = TagadaReactMinimalBundle.formatMoney;
437
+ // Mark as minimal
438
+ window.tgd._minimal = true;
439
+ }
440
+ `.trim(),
441
+ },
442
+ banner: {
443
+ js: `/**
444
+ * TagadaPay React SDK MINIMAL v${require('./package.json').version}
445
+ * CDN Bundle - Slim checkout SDK (TagadaProvider + essential hooks only)
446
+ * Requires: React 18+ loaded before this script
447
+ * For full SDK with all hooks, use tagada-react-sdk.min.js instead
448
+ * @license MIT
449
+ */`,
450
+ },
451
+ });
452
+
453
+ console.log(' āœ… dist/tagada-react-sdk-minimal.min.js (minified + sourcemap)');
454
+
93
455
  // Get file sizes
94
- const fs = require('fs');
95
- const minSize = fs.statSync(path.join(OUT_DIR, 'external-tracker.min.js')).size;
96
- const fullSize = fs.statSync(path.join(OUT_DIR, 'external-tracker.js')).size;
456
+ const trackerMinSize = fs.statSync(path.join(OUT_DIR, 'external-tracker.min.js')).size;
457
+ const trackerFullSize = fs.statSync(path.join(OUT_DIR, 'external-tracker.js')).size;
458
+ const sdkMinSize = fs.statSync(path.join(OUT_DIR, 'tagada-sdk.min.js')).size;
459
+ const sdkFullSize = fs.statSync(path.join(OUT_DIR, 'tagada-sdk.js')).size;
460
+ const reactSdkMinSize = fs.statSync(path.join(OUT_DIR, 'tagada-react-sdk.min.js')).size;
461
+ const reactSdkFullSize = fs.statSync(path.join(OUT_DIR, 'tagada-react-sdk.js')).size;
462
+ const reactSdkMinimalSize = fs.statSync(path.join(OUT_DIR, 'tagada-react-sdk-minimal.min.js')).size;
97
463
 
98
464
  console.log('\nšŸ“¦ Bundle sizes:');
99
- console.log(` external-tracker.min.js: ${(minSize / 1024).toFixed(2)} KB`);
100
- console.log(` external-tracker.js: ${(fullSize / 1024).toFixed(2)} KB`);
465
+ console.log(` external-tracker.min.js: ${(trackerMinSize / 1024).toFixed(2)} KB`);
466
+ console.log(` external-tracker.js: ${(trackerFullSize / 1024).toFixed(2)} KB`);
467
+ console.log(` tagada-sdk.min.js: ${(sdkMinSize / 1024).toFixed(2)} KB`);
468
+ console.log(` tagada-sdk.js: ${(sdkFullSize / 1024).toFixed(2)} KB`);
469
+ console.log(` tagada-react-sdk.min.js: ${(reactSdkMinSize / 1024).toFixed(2)} KB (full)`);
470
+ console.log(` tagada-react-sdk.js: ${(reactSdkFullSize / 1024).toFixed(2)} KB`);
471
+ console.log(` tagada-react-sdk-minimal.min.js: ${(reactSdkMinimalSize / 1024).toFixed(2)} KB (slim) ⭐`);
101
472
 
102
473
  console.log('\n✨ CDN build complete!\n');
103
474
  console.log('Usage via CDN:');
475
+ console.log('');
476
+ console.log(' // External Tracker (lightweight, tracking only):');
104
477
  console.log(' <script src="https://cdn.jsdelivr.net/npm/@tagadapay/plugin-sdk/dist/external-tracker.min.js"></script>');
105
- console.log(' <script>TagadaTracker.init({ storeId: "store_xxx", ... });</script>\n');
478
+ console.log(' <script>TagadaTracker.init({ storeId: "store_xxx", ... });</script>');
479
+ console.log('');
480
+ console.log(' // Full SDK (createTagadaClient, config, hot reload):');
481
+ console.log(' <script src="https://cdn.jsdelivr.net/npm/@tagadapay/plugin-sdk/dist/tagada-sdk.min.js"></script>');
482
+ console.log(' <script>');
483
+ console.log(' const client = window.tgd.createTagadaClient({ features: { funnel: true } });');
484
+ console.log(' client.subscribe((state) => console.log(state));');
485
+ console.log(' </script>');
486
+ console.log('');
487
+ console.log(' // React SDK (hooks & TagadaProvider - requires React 18+):');
488
+ console.log(' <script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>');
489
+ console.log(' <script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>');
490
+ console.log(' <script src="https://cdn.jsdelivr.net/npm/@tagadapay/plugin-sdk/dist/tagada-react-sdk.min.js"></script>');
491
+ console.log(' // Then use: window.tgd.TagadaProvider, window.tgd.useCheckout, etc.\n');
106
492
  }
107
493
 
108
494
  build().catch((err) => {
@@ -1,33 +1,16 @@
1
- export declare const AVAILABLE_LANGUAGES: readonly ["en", "ru", "de", "fr", "es", "zh", "hi", "pt", "ja", "ar", "it", "he"];
2
- export type SupportedLanguage = typeof AVAILABLE_LANGUAGES[number];
3
- /**
4
- * Register a language database for use
5
- * @param language - Language code
6
- * @param database - The language database from iso3166-2-db
7
- * @example
8
- * import ruDatabase from 'iso3166-2-db/i18n/dispute/UN/ru';
9
- * registerLanguage('ru', ruDatabase);
10
- */
11
- export declare function registerLanguage(language: SupportedLanguage, database: any): void;
12
- /**
13
- * Check if a language is registered
14
- * @param language - Language code to check
15
- * @returns true if the language is registered
16
- */
17
- export declare function isLanguageRegistered(language: SupportedLanguage): boolean;
18
- /**
19
- * Get list of registered languages
20
- * @returns Array of registered language codes
21
- */
22
- export declare function getRegisteredLanguages(): SupportedLanguage[];
23
1
  /**
24
- * Dynamically import and register a language
25
- * @param language - Language code to import
26
- * @returns Promise that resolves when language is registered
27
- * @example
28
- * await importLanguage('ru');
2
+ * Geodata — CDN-backed country/region data.
3
+ *
4
+ * Instead of bundling the 775KB iso3166-2-db package, we fetch slim JSON
5
+ * from Vercel Blob CDN on demand:
6
+ * - countries.json (~10KB) — fetched once on first getCountries() call
7
+ * - regions.json (~95KB) — fetched lazily on first getStatesForCountry() call
8
+ *
9
+ * Both are cached in memory after first fetch. The API surface is identical
10
+ * to the previous static-import version so all consumers work unchanged.
29
11
  */
30
- export declare function importLanguage(language: SupportedLanguage): Promise<void>;
12
+ export declare const AVAILABLE_LANGUAGES: readonly ["en", "ru", "de", "da", "fr", "es", "zh", "hi", "pt", "ja", "ar", "it", "he"];
13
+ export type SupportedLanguage = typeof AVAILABLE_LANGUAGES[number];
31
14
  export interface Country {
32
15
  code: string;
33
16
  name: string;
@@ -41,20 +24,27 @@ export interface State {
41
24
  countryCode: string;
42
25
  uniqueKey?: string;
43
26
  }
27
+ export declare function ensureCountriesLoaded(language?: SupportedLanguage): Promise<void>;
28
+ export declare function ensureRegionsLoaded(language?: SupportedLanguage): Promise<void>;
29
+ export declare function ensureGeoDataLoaded(language?: SupportedLanguage): Promise<void>;
44
30
  export declare const getCountries: (language?: SupportedLanguage) => Country[];
45
- export declare const getAllStates: (language?: SupportedLanguage) => State[];
46
31
  export declare const getStatesForCountry: (countryCode: string, language?: SupportedLanguage) => State[];
32
+ export declare const getAllStates: (language?: SupportedLanguage) => State[];
47
33
  export declare const findCountryByName: (countryName: string, language?: SupportedLanguage) => Country | null;
48
34
  export declare const findRegionByCode: (regionCode: string, language?: SupportedLanguage) => State | null;
49
35
  export declare const isValidCountryCode: (countryCode: string, language?: SupportedLanguage) => boolean;
50
36
  export declare const isValidStateCode: (countryCode: string, stateCode: string, language?: SupportedLanguage) => boolean;
51
37
  export declare const getCountryWithRegions: (countryCode: string, language?: SupportedLanguage) => {
52
38
  country: {
53
- code: any;
54
- name: any;
55
- iso3: any;
56
- numeric: any;
39
+ code: string;
40
+ name: string;
41
+ iso3: string | undefined;
42
+ numeric: number | undefined;
57
43
  uniqueKey: string;
58
44
  };
59
45
  regions: State[];
60
46
  } | null;
47
+ export declare function registerLanguage(_language: SupportedLanguage, _database: any): void;
48
+ export declare function isLanguageRegistered(language: SupportedLanguage): boolean;
49
+ export declare function getRegisteredLanguages(): SupportedLanguage[];
50
+ export declare function importLanguage(language: SupportedLanguage): Promise<void>;