@tagadapay/plugin-sdk 3.1.5 ā 3.1.9
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/README.md +1129 -1129
- package/build-cdn.js +220 -113
- package/dist/external-tracker.js +1225 -558
- package/dist/external-tracker.min.js +2 -2
- package/dist/external-tracker.min.js.map +4 -4
- package/dist/react/hooks/useApplePay.js +25 -36
- package/dist/react/hooks/usePaymentPolling.d.ts +9 -3
- package/dist/react/providers/TagadaProvider.js +5 -5
- package/dist/react/utils/money.d.ts +4 -3
- package/dist/react/utils/money.js +39 -6
- package/dist/react/utils/trackingUtils.js +1 -0
- package/dist/tagada-sdk.js +10142 -0
- package/dist/tagada-sdk.min.js +43 -0
- package/dist/tagada-sdk.min.js.map +7 -0
- package/dist/v2/core/client.js +34 -2
- package/dist/v2/core/config/environment.js +9 -2
- package/dist/v2/core/funnelClient.d.ts +180 -2
- package/dist/v2/core/funnelClient.js +289 -6
- package/dist/v2/core/resources/apiClient.js +1 -1
- package/dist/v2/core/resources/checkout.d.ts +68 -0
- package/dist/v2/core/resources/funnel.d.ts +25 -0
- package/dist/v2/core/resources/payments.d.ts +70 -3
- package/dist/v2/core/resources/payments.js +72 -7
- package/dist/v2/core/utils/index.d.ts +1 -0
- package/dist/v2/core/utils/index.js +2 -0
- package/dist/v2/core/utils/pluginConfig.d.ts +8 -0
- package/dist/v2/core/utils/pluginConfig.js +68 -5
- package/dist/v2/core/utils/previewMode.d.ts +7 -0
- package/dist/v2/core/utils/previewMode.js +72 -14
- package/dist/v2/core/utils/previewModeIndicator.d.ts +19 -0
- package/dist/v2/core/utils/previewModeIndicator.js +414 -0
- package/dist/v2/core/utils/tokenStorage.d.ts +4 -0
- package/dist/v2/core/utils/tokenStorage.js +15 -1
- package/dist/v2/index.d.ts +9 -3
- package/dist/v2/index.js +8 -3
- package/dist/v2/react/components/ApplePayButton.d.ts +22 -123
- package/dist/v2/react/components/ApplePayButton.js +247 -317
- package/dist/v2/react/components/FunnelScriptInjector.d.ts +3 -1
- package/dist/v2/react/components/FunnelScriptInjector.js +255 -162
- package/dist/v2/react/components/GooglePayButton.d.ts +2 -0
- package/dist/v2/react/components/GooglePayButton.js +80 -64
- package/dist/v2/react/components/PreviewModeIndicator.d.ts +46 -0
- package/dist/v2/react/components/PreviewModeIndicator.js +113 -0
- package/dist/v2/react/hooks/useApplePayCheckout.d.ts +16 -0
- package/dist/v2/react/hooks/useApplePayCheckout.js +193 -0
- package/dist/v2/react/hooks/useFunnel.d.ts +48 -6
- package/dist/v2/react/hooks/useFunnel.js +25 -5
- package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +10 -0
- package/dist/v2/react/hooks/useGoogleAutocomplete.js +48 -0
- package/dist/v2/react/hooks/useGooglePayCheckout.d.ts +21 -0
- package/dist/v2/react/hooks/useGooglePayCheckout.js +198 -0
- package/dist/v2/react/hooks/usePaymentPolling.d.ts +15 -3
- package/dist/v2/react/hooks/usePaymentPolling.js +31 -9
- package/dist/v2/react/hooks/usePaymentQuery.d.ts +34 -2
- package/dist/v2/react/hooks/usePaymentQuery.js +731 -7
- package/dist/v2/react/hooks/usePaymentRetrieve.d.ts +26 -0
- package/dist/v2/react/hooks/usePaymentRetrieve.js +175 -0
- package/dist/v2/react/hooks/usePixelTracking.d.ts +56 -0
- package/dist/v2/react/hooks/usePixelTracking.js +508 -0
- package/dist/v2/react/hooks/useStepConfig.d.ts +64 -0
- package/dist/v2/react/hooks/useStepConfig.js +53 -0
- package/dist/v2/react/index.d.ts +15 -5
- package/dist/v2/react/index.js +8 -2
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +1 -0
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +41 -13
- package/dist/v2/react/providers/TagadaProvider.js +24 -23
- package/dist/v2/standalone/external-tracker.d.ts +2 -0
- package/dist/v2/standalone/external-tracker.js +6 -3
- package/package.json +112 -112
- package/dist/v2/react/hooks/useApplePay.d.ts +0 -16
- package/dist/v2/react/hooks/useApplePay.js +0 -247
package/build-cdn.js
CHANGED
|
@@ -1,113 +1,220 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Build script for creating standalone CDN bundles
|
|
5
|
-
*
|
|
6
|
-
* This creates:
|
|
7
|
-
* - dist/external-tracker.min.js - Minified UMD bundle for CDN
|
|
8
|
-
* - dist/external-tracker.js - Non-minified for debugging
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
console.log(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
console.log('
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
build(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Build script for creating standalone CDN bundles
|
|
5
|
+
*
|
|
6
|
+
* This creates:
|
|
7
|
+
* - dist/external-tracker.min.js - Minified UMD bundle for CDN (tracking only)
|
|
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
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* node build-cdn.js
|
|
14
|
+
* npm run build:cdn
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const esbuild = require('esbuild');
|
|
18
|
+
const path = require('path');
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
|
|
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 OUT_DIR = path.join(__dirname, 'dist');
|
|
24
|
+
|
|
25
|
+
async function build() {
|
|
26
|
+
console.log('šØ Building CDN bundles...\n');
|
|
27
|
+
|
|
28
|
+
// ==========================================================================
|
|
29
|
+
// EXTERNAL TRACKER (lightweight, tracking only)
|
|
30
|
+
// ==========================================================================
|
|
31
|
+
console.log('š¦ Building external-tracker...');
|
|
32
|
+
|
|
33
|
+
// Build minified UMD bundle
|
|
34
|
+
await esbuild.build({
|
|
35
|
+
entryPoints: [TRACKER_ENTRY],
|
|
36
|
+
bundle: true,
|
|
37
|
+
minify: true,
|
|
38
|
+
sourcemap: true,
|
|
39
|
+
target: ['es2018', 'chrome58', 'firefox57', 'safari11', 'edge79'],
|
|
40
|
+
format: 'iife',
|
|
41
|
+
globalName: 'TagadaTrackerBundle',
|
|
42
|
+
outfile: path.join(OUT_DIR, 'external-tracker.min.js'),
|
|
43
|
+
// Don't include React - this is a standalone script
|
|
44
|
+
external: [],
|
|
45
|
+
// Define globals for browser environment
|
|
46
|
+
define: {
|
|
47
|
+
'process.env.NODE_ENV': '"production"',
|
|
48
|
+
},
|
|
49
|
+
// Footer to expose TagadaTracker on window
|
|
50
|
+
footer: {
|
|
51
|
+
js: `
|
|
52
|
+
// Expose TagadaTracker globally (if not already done in bundle)
|
|
53
|
+
if (typeof window !== 'undefined' && TagadaTrackerBundle && TagadaTrackerBundle.TagadaTracker) {
|
|
54
|
+
window.TagadaTracker = TagadaTrackerBundle.TagadaTracker;
|
|
55
|
+
}
|
|
56
|
+
`.trim(),
|
|
57
|
+
},
|
|
58
|
+
banner: {
|
|
59
|
+
js: `/**
|
|
60
|
+
* TagadaPay External Tracker v${require('./package.json').version}
|
|
61
|
+
* CDN Bundle - Standalone tracking for external pages
|
|
62
|
+
* @license MIT
|
|
63
|
+
*/`,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
console.log(' ā
dist/external-tracker.min.js (minified + sourcemap)');
|
|
68
|
+
|
|
69
|
+
// Build non-minified version for debugging
|
|
70
|
+
await esbuild.build({
|
|
71
|
+
entryPoints: [TRACKER_ENTRY],
|
|
72
|
+
bundle: true,
|
|
73
|
+
minify: false,
|
|
74
|
+
sourcemap: false,
|
|
75
|
+
target: ['es2018', 'chrome58', 'firefox57', 'safari11', 'edge79'],
|
|
76
|
+
format: 'iife',
|
|
77
|
+
globalName: 'TagadaTrackerBundle',
|
|
78
|
+
outfile: path.join(OUT_DIR, 'external-tracker.js'),
|
|
79
|
+
external: [],
|
|
80
|
+
define: {
|
|
81
|
+
'process.env.NODE_ENV': '"development"',
|
|
82
|
+
},
|
|
83
|
+
footer: {
|
|
84
|
+
js: `
|
|
85
|
+
// Expose TagadaTracker globally
|
|
86
|
+
if (typeof window !== 'undefined' && TagadaTrackerBundle && TagadaTrackerBundle.TagadaTracker) {
|
|
87
|
+
window.TagadaTracker = TagadaTrackerBundle.TagadaTracker;
|
|
88
|
+
}
|
|
89
|
+
`.trim(),
|
|
90
|
+
},
|
|
91
|
+
banner: {
|
|
92
|
+
js: `/**
|
|
93
|
+
* TagadaPay External Tracker v${require('./package.json').version}
|
|
94
|
+
* CDN Bundle - Standalone tracking for external pages (Debug Build)
|
|
95
|
+
* @license MIT
|
|
96
|
+
*/`,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
console.log(' ā
dist/external-tracker.js (non-minified for debugging)');
|
|
101
|
+
|
|
102
|
+
// ==========================================================================
|
|
103
|
+
// FULL STANDALONE SDK (createTagadaClient, config loading, hot reload, etc.)
|
|
104
|
+
// ==========================================================================
|
|
105
|
+
console.log('\nš¦ Building tagada-sdk (full standalone SDK)...');
|
|
106
|
+
|
|
107
|
+
// Build minified SDK bundle
|
|
108
|
+
await esbuild.build({
|
|
109
|
+
entryPoints: [SDK_ENTRY],
|
|
110
|
+
bundle: true,
|
|
111
|
+
minify: true,
|
|
112
|
+
sourcemap: true,
|
|
113
|
+
target: ['es2018', 'chrome58', 'firefox57', 'safari11', 'edge79'],
|
|
114
|
+
format: 'iife',
|
|
115
|
+
globalName: 'TagadaSDKBundle',
|
|
116
|
+
outfile: path.join(OUT_DIR, 'tagada-sdk.min.js'),
|
|
117
|
+
external: [],
|
|
118
|
+
define: {
|
|
119
|
+
'process.env.NODE_ENV': '"production"',
|
|
120
|
+
},
|
|
121
|
+
footer: {
|
|
122
|
+
js: `
|
|
123
|
+
// Expose SDK exports globally
|
|
124
|
+
if (typeof window !== 'undefined' && TagadaSDKBundle) {
|
|
125
|
+
window.TagadaSDK = TagadaSDKBundle;
|
|
126
|
+
window.createTagadaClient = TagadaSDKBundle.createTagadaClient;
|
|
127
|
+
// Config utilities (sync and async)
|
|
128
|
+
window.getPluginConfig = TagadaSDKBundle.getPluginConfig; // Sync - reads from meta tags
|
|
129
|
+
window.loadPluginConfig = TagadaSDKBundle.loadPluginConfig; // Async - full config loading
|
|
130
|
+
// Hot reload utilities
|
|
131
|
+
window.onConfigUpdate = TagadaSDKBundle.onConfigUpdate; // Listen for config changes
|
|
132
|
+
window.sendConfigUpdate = TagadaSDKBundle.sendConfigUpdate; // Send config updates to iframes
|
|
133
|
+
window.broadcastConfigUpdate = TagadaSDKBundle.broadcastConfigUpdate;
|
|
134
|
+
}
|
|
135
|
+
`.trim(),
|
|
136
|
+
},
|
|
137
|
+
banner: {
|
|
138
|
+
js: `/**
|
|
139
|
+
* TagadaPay SDK v${require('./package.json').version}
|
|
140
|
+
* CDN Bundle - Full standalone SDK for external/vanilla pages
|
|
141
|
+
* Includes: createTagadaClient, getPluginConfig, onConfigUpdate (hot reload)
|
|
142
|
+
* @license MIT
|
|
143
|
+
*/`,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
console.log(' ā
dist/tagada-sdk.min.js (minified + sourcemap)');
|
|
148
|
+
|
|
149
|
+
// Build non-minified SDK version for debugging
|
|
150
|
+
await esbuild.build({
|
|
151
|
+
entryPoints: [SDK_ENTRY],
|
|
152
|
+
bundle: true,
|
|
153
|
+
minify: false,
|
|
154
|
+
sourcemap: false,
|
|
155
|
+
target: ['es2018', 'chrome58', 'firefox57', 'safari11', 'edge79'],
|
|
156
|
+
format: 'iife',
|
|
157
|
+
globalName: 'TagadaSDKBundle',
|
|
158
|
+
outfile: path.join(OUT_DIR, 'tagada-sdk.js'),
|
|
159
|
+
external: [],
|
|
160
|
+
define: {
|
|
161
|
+
'process.env.NODE_ENV': '"development"',
|
|
162
|
+
},
|
|
163
|
+
footer: {
|
|
164
|
+
js: `
|
|
165
|
+
// Expose SDK exports globally
|
|
166
|
+
if (typeof window !== 'undefined' && TagadaSDKBundle) {
|
|
167
|
+
window.TagadaSDK = TagadaSDKBundle;
|
|
168
|
+
window.createTagadaClient = TagadaSDKBundle.createTagadaClient;
|
|
169
|
+
window.getPluginConfig = TagadaSDKBundle.getPluginConfig;
|
|
170
|
+
window.loadPluginConfig = TagadaSDKBundle.loadPluginConfig;
|
|
171
|
+
window.onConfigUpdate = TagadaSDKBundle.onConfigUpdate;
|
|
172
|
+
window.sendConfigUpdate = TagadaSDKBundle.sendConfigUpdate;
|
|
173
|
+
window.broadcastConfigUpdate = TagadaSDKBundle.broadcastConfigUpdate;
|
|
174
|
+
}
|
|
175
|
+
`.trim(),
|
|
176
|
+
},
|
|
177
|
+
banner: {
|
|
178
|
+
js: `/**
|
|
179
|
+
* TagadaPay SDK v${require('./package.json').version}
|
|
180
|
+
* CDN Bundle - Full standalone SDK for external/vanilla pages (Debug Build)
|
|
181
|
+
* @license MIT
|
|
182
|
+
*/`,
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
console.log(' ā
dist/tagada-sdk.js (non-minified for debugging)');
|
|
187
|
+
|
|
188
|
+
// Get file sizes
|
|
189
|
+
const trackerMinSize = fs.statSync(path.join(OUT_DIR, 'external-tracker.min.js')).size;
|
|
190
|
+
const trackerFullSize = fs.statSync(path.join(OUT_DIR, 'external-tracker.js')).size;
|
|
191
|
+
const sdkMinSize = fs.statSync(path.join(OUT_DIR, 'tagada-sdk.min.js')).size;
|
|
192
|
+
const sdkFullSize = fs.statSync(path.join(OUT_DIR, 'tagada-sdk.js')).size;
|
|
193
|
+
|
|
194
|
+
console.log('\nš¦ Bundle sizes:');
|
|
195
|
+
console.log(` external-tracker.min.js: ${(trackerMinSize / 1024).toFixed(2)} KB`);
|
|
196
|
+
console.log(` external-tracker.js: ${(trackerFullSize / 1024).toFixed(2)} KB`);
|
|
197
|
+
console.log(` tagada-sdk.min.js: ${(sdkMinSize / 1024).toFixed(2)} KB`);
|
|
198
|
+
console.log(` tagada-sdk.js: ${(sdkFullSize / 1024).toFixed(2)} KB`);
|
|
199
|
+
|
|
200
|
+
console.log('\n⨠CDN build complete!\n');
|
|
201
|
+
console.log('Usage via CDN:');
|
|
202
|
+
console.log('');
|
|
203
|
+
console.log(' // External Tracker (lightweight, tracking only):');
|
|
204
|
+
console.log(' <script src="https://cdn.jsdelivr.net/npm/@tagadapay/plugin-sdk/dist/external-tracker.min.js"></script>');
|
|
205
|
+
console.log(' <script>TagadaTracker.init({ storeId: "store_xxx", ... });</script>');
|
|
206
|
+
console.log('');
|
|
207
|
+
console.log(' // Full SDK (createTagadaClient, config, hot reload):');
|
|
208
|
+
console.log(' <script src="https://cdn.jsdelivr.net/npm/@tagadapay/plugin-sdk/dist/tagada-sdk.min.js"></script>');
|
|
209
|
+
console.log(' <script>');
|
|
210
|
+
console.log(' const client = createTagadaClient({ features: { funnel: true } });');
|
|
211
|
+
console.log(' client.subscribe((state) => console.log(state));');
|
|
212
|
+
console.log(' </script>\n');
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
build().catch((err) => {
|
|
216
|
+
console.error('Build failed:', err);
|
|
217
|
+
process.exit(1);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
|