@moneybar.online/moneybar 3.1.0 → 3.2.0
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/example-template.html +13 -4
- package/moneybar-config-template.js +44 -20
- package/package.json +1 -1
package/example-template.html
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<script type="importmap">
|
|
16
16
|
{
|
|
17
17
|
"imports": {
|
|
18
|
-
"@supabase/supabase-js": "https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2/+esm"
|
|
18
|
+
"@supabase/supabase-js": "https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2.86.0/+esm"
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
</script>
|
|
@@ -25,9 +25,10 @@
|
|
|
25
25
|
<!-- OPTION 2: Self-contained bundle (No import map needed) -->
|
|
26
26
|
<!-- Comment out the import map above and use this: -->
|
|
27
27
|
<script type="module">
|
|
28
|
-
import { MoneyBar } from 'https://cdn.jsdelivr.net/npm/@moneybar.online/moneybar/dist/index.bundle.js';
|
|
28
|
+
import { MoneyBar } from 'https://cdn.jsdelivr.net/npm/@moneybar.online/moneybar@3.1.0/dist/index.bundle.js';
|
|
29
29
|
|
|
30
30
|
const moneyBar = new MoneyBar({
|
|
31
|
+
actionFunction: 'myAction',
|
|
31
32
|
appId: 'test-app',
|
|
32
33
|
freeDownloadLimit: 3,
|
|
33
34
|
supabase: {
|
|
@@ -56,12 +57,20 @@
|
|
|
56
57
|
<!-- Uncomment this for traditional script tag usage: -->
|
|
57
58
|
<!--
|
|
58
59
|
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2/dist/umd/supabase.min.js"></script>
|
|
59
|
-
<script src="https://cdn.jsdelivr.net/npm/@moneybar.online/moneybar/dist/index.umd.js"></script>
|
|
60
|
+
<script src="https://cdn.jsdelivr.net/npm/@moneybar.online/moneybar@3.1.0/dist/index.umd.js"></script>
|
|
60
61
|
<script>
|
|
61
62
|
const moneyBar = new MoneyBar.MoneyBar({
|
|
63
|
+
actionFunction: 'myAction',
|
|
62
64
|
appId: 'test-app',
|
|
63
65
|
freeDownloadLimit: 3,
|
|
64
|
-
|
|
66
|
+
supabase: {
|
|
67
|
+
url: 'your-supabase-url',
|
|
68
|
+
anonKey: 'your-anon-key'
|
|
69
|
+
},
|
|
70
|
+
payment: {
|
|
71
|
+
productId: 'your-product-id',
|
|
72
|
+
mode: 'test'
|
|
73
|
+
}
|
|
65
74
|
});
|
|
66
75
|
</script>
|
|
67
76
|
-->
|
|
@@ -8,21 +8,25 @@ Add to your HTML:
|
|
|
8
8
|
<script type="importmap">
|
|
9
9
|
{
|
|
10
10
|
"imports": {
|
|
11
|
-
"@supabase/supabase-js": "https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2/+esm"
|
|
11
|
+
"@supabase/supabase-js": "https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2.86.0/+esm"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
</script>
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { MoneyBar } from 'https://cdn.jsdelivr.net/npm/@moneybar.online/moneybar/dist/index.browser.js';
|
|
17
|
+
import { MoneyBar } from 'https://cdn.jsdelivr.net/npm/@moneybar.online/moneybar@3.1.0/dist/index.browser.js';
|
|
18
18
|
|
|
19
19
|
// Option 2: Self-contained bundle (No import map needed)
|
|
20
|
-
// import { MoneyBar } from 'https://cdn.jsdelivr.net/npm/@moneybar.online/moneybar/dist/index.bundle.js';
|
|
20
|
+
// import { MoneyBar } from 'https://cdn.jsdelivr.net/npm/@moneybar.online/moneybar@3.1.0/dist/index.bundle.js';
|
|
21
21
|
|
|
22
22
|
// Option 3: NPM install usage (for projects with bundlers)
|
|
23
23
|
// import { MoneyBar } from '@moneybar.online/moneybar';
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
// Configuration object (matches examples structure)
|
|
26
|
+
window.APP_CONFIG = {
|
|
27
|
+
// REQUIRED: Function name that gets called
|
|
28
|
+
actionFunction: 'myAction',
|
|
29
|
+
|
|
26
30
|
// REQUIRED: Your unique app identifier
|
|
27
31
|
appId: 'my-app',
|
|
28
32
|
|
|
@@ -78,32 +82,52 @@ const moneyBar = new MoneyBar({
|
|
|
78
82
|
fromEmail: 'hello@yourapp.com'
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
|
-
}
|
|
85
|
+
};
|
|
82
86
|
|
|
83
|
-
//
|
|
84
|
-
moneyBar
|
|
85
|
-
// Your app's functionality here
|
|
86
|
-
console.log('User context:', userContext);
|
|
87
|
+
// Initialize MoneyBar with the configuration
|
|
88
|
+
const moneyBar = new MoneyBar(window.APP_CONFIG);
|
|
87
89
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
// Attach to button with your business logic
|
|
91
|
+
moneyBar.attachToButton('#action-btn', (userContext) => {
|
|
92
|
+
// Call the specified action function
|
|
93
|
+
if (typeof window[window.APP_CONFIG.actionFunction] === 'function') {
|
|
94
|
+
window[window.APP_CONFIG.actionFunction](userContext);
|
|
91
95
|
} else {
|
|
92
|
-
|
|
93
|
-
|
|
96
|
+
// Fallback action
|
|
97
|
+
myAction(userContext);
|
|
94
98
|
}
|
|
95
|
-
|
|
96
|
-
// Example: Your app logic
|
|
97
|
-
// generatePDF();
|
|
98
|
-
// downloadFile();
|
|
99
|
-
// processData();
|
|
100
99
|
});
|
|
101
100
|
|
|
102
|
-
// Global function for easy HTML usage
|
|
101
|
+
// Global function for easy HTML usage (matches actionFunction)
|
|
103
102
|
window.myAction = function(userContext) {
|
|
103
|
+
console.log('User context:', userContext);
|
|
104
|
+
|
|
104
105
|
if (userContext.isPremium) {
|
|
105
106
|
alert('Premium features unlocked!');
|
|
107
|
+
// Your premium functionality here
|
|
106
108
|
} else {
|
|
107
109
|
alert(`Free trial: ${userContext.remaining} uses left`);
|
|
110
|
+
// Your free tier functionality here
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// Example alternative action functions
|
|
115
|
+
window.createTemplate = function(userContext) {
|
|
116
|
+
if (userContext.isPremium) {
|
|
117
|
+
console.log('Creating premium template...');
|
|
118
|
+
alert('Premium template created!');
|
|
119
|
+
} else {
|
|
120
|
+
console.log('Creating basic template...');
|
|
121
|
+
alert(`Basic template created! ${userContext.remaining} uses remaining`);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
window.downloadFile = function(userContext) {
|
|
126
|
+
if (userContext.isPremium) {
|
|
127
|
+
console.log('Downloading premium file...');
|
|
128
|
+
// Premium download logic
|
|
129
|
+
} else {
|
|
130
|
+
console.log('Downloading basic file...');
|
|
131
|
+
// Basic download logic
|
|
108
132
|
}
|
|
109
133
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneybar.online/moneybar",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "The navbar of monetization. Fix the 3 money-blocking stages: forced sign-ins, silent drop-offs, and broken payment flows. Turn browsers into buyers.",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|