@nibgate/sdk 0.2.21 → 0.2.23
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/nibgate.js +48 -6
- package/dist/nibgate.js.map +2 -2
- package/dist/nibgate.min.js +57 -54
- package/dist/nibgate.min.js.map +3 -3
- package/package.json +1 -1
- package/src/browser/default-ui.js +30 -6
package/package.json
CHANGED
|
@@ -77,17 +77,41 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
77
77
|
const unlockSVG = '<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:middle;margin-right:6px"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 9.9-1"/></svg>';
|
|
78
78
|
|
|
79
79
|
card.innerHTML = `
|
|
80
|
-
<div style="display:flex;flex-direction:column;align-items:center;text-align:center;max-width:
|
|
81
|
-
<div
|
|
80
|
+
<div style="display:flex;flex-direction:column;align-items:center;text-align:center;max-width:580px;margin:0 auto;padding:40px 52px">
|
|
81
|
+
<div id="nibgate-lottie" style="width:165px;height:168px;margin-bottom:24px"></div>
|
|
82
|
+
<div style="font-size:50px;font-weight:700;letter-spacing:-.03em;color:${theme.fg};margin-bottom:12px">${esc(resource.price)} USDC</div>
|
|
83
|
+
<div style="font-size:21px;color:${theme.muted};margin-bottom:48px">Pay to unlock this content</div>
|
|
84
|
+
<div data-nibgate-wallet-label class="nui-mono" style="font-size:18px;color:${theme.muted};margin-bottom:40px;min-height:28px">Connect wallet</div>
|
|
82
85
|
<div data-nibgate-unlock-wrap style="width:100%;position:relative;border-radius:10px;overflow:hidden;cursor:pointer">
|
|
83
86
|
<div data-nibgate-unlock-progress style="position:absolute;inset:0;width:0%;background:${theme.accent};opacity:0.15;border-radius:10px;transition:width .05s linear;z-index:2"></div>
|
|
84
|
-
<button type="button" data-nibgate-unlock disabled style="width:100%;padding:
|
|
85
|
-
<div class="nui-stat" style="text-align:center;margin-top:
|
|
87
|
+
<button type="button" data-nibgate-unlock disabled style="width:100%;padding:14px 0;font-size:17px;font-weight:500;line-height:1;border:0;border-radius:10px;outline:none;cursor:pointer;position:relative;z-index:4;color:${theme.accent};background:rgba(124,154,109,0.08);transition:box-shadow .3s,transform .3s;font-family:inherit;display:flex;align-items:center;justify-content:center">${unlockSVG}Hold to pay</button></div>
|
|
88
|
+
<div class="nui-stat" style="text-align:center;margin-top:16px" data-nibgate-status></div>
|
|
86
89
|
</div>
|
|
87
|
-
<div data-nibgate-premium hidden style="margin-top:
|
|
90
|
+
<div data-nibgate-premium hidden style="margin-top:32px;border-top:1px solid ${theme.border};padding-top:32px">${options.premiumContentHTML || ''}</div>
|
|
88
91
|
`;
|
|
89
92
|
|
|
90
93
|
(typeof container === 'string' ? document.querySelector(container) : container)?.appendChild(card);
|
|
94
|
+
// Load Lottie animation
|
|
95
|
+
(function loadLottie() {
|
|
96
|
+
if (!document.getElementById('nibgate-lottie')) return;
|
|
97
|
+
function startAnim(data) {
|
|
98
|
+
var d = document.getElementById('nibgate-lottie');
|
|
99
|
+
if (d && window.lottie) window.lottie.loadAnimation({ container: d, animationData: data, loop: true, autoplay: true });
|
|
100
|
+
}
|
|
101
|
+
if (window.lottie) {
|
|
102
|
+
if (window._lottieData) startAnim(window._lottieData);
|
|
103
|
+
else fetch('/nibgate-unlock-key.json?t=1').then(function(r) { if (!r.ok) throw new Error(); return r.json(); }).then(function(d) { window._lottieData = d; startAnim(d); }).catch(function() {});
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (window._lottieLoading) return;
|
|
107
|
+
window._lottieLoading = true;
|
|
108
|
+
var s = document.createElement('script');
|
|
109
|
+
s.src = 'https://cdnjs.cloudflare.com/ajax/libs/lottie-web/5.12.2/lottie.min.js';
|
|
110
|
+
s.onload = function() {
|
|
111
|
+
fetch('/nibgate-unlock-key.json?t=1').then(function(r) { if (!r.ok) throw new Error(); return r.json(); }).then(function(d) { window._lottieData = d; startAnim(d); }).catch(function() {});
|
|
112
|
+
};
|
|
113
|
+
document.head.appendChild(s);
|
|
114
|
+
})();
|
|
91
115
|
|
|
92
116
|
const st = card.querySelector('[data-nibgate-status]');
|
|
93
117
|
const label = card.querySelector('[data-nibgate-wallet-label]');
|
|
@@ -243,7 +267,7 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
243
267
|
}
|
|
244
268
|
|
|
245
269
|
async function refreshBalance() {
|
|
246
|
-
if (
|
|
270
|
+
if (!card.isConnected) return;
|
|
247
271
|
const addr = ctrl.getWalletAddress();
|
|
248
272
|
if (!addr) return;
|
|
249
273
|
const txt = ensureBalEl().querySelector('[data-nibgate-bal-text]');
|