@nibgate/sdk 0.2.31 → 0.2.32
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 +15 -26
- package/dist/nibgate.js.map +2 -2
- package/dist/nibgate.min.js +23 -23
- package/dist/nibgate.min.js.map +3 -3
- package/package.json +1 -1
- package/src/browser/default-ui.js +14 -27
package/package.json
CHANGED
|
@@ -81,7 +81,7 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
81
81
|
<div id="nibgate-lottie" style="width:165px;height:168px;margin-bottom:24px"></div>
|
|
82
82
|
<div style="font-size:50px;font-weight:700;letter-spacing:-.03em;color:${theme.fg};margin-bottom:12px">${esc(resource.price)} USDC</div>
|
|
83
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
|
|
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>
|
|
85
85
|
<div data-nibgate-unlock-wrap style="width:100%;position:relative;border-radius:10px;overflow:hidden;cursor:pointer">
|
|
86
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>
|
|
87
87
|
<button type="button" data-nibgate-unlock disabled style="width:100%;padding:14px 0;font-size:17px;font-weight:600;line-height:1;border:0;border-radius:10px;outline:none;cursor:pointer;position:relative;z-index:4;color:#fff;background:${theme.accent};transition:box-shadow .3s,transform .3s;font-family:inherit;display:flex;align-items:center;justify-content:center">${unlockSVG}Hold to pay</button></div>
|
|
@@ -149,25 +149,26 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
149
149
|
|
|
150
150
|
function updateLabel() {
|
|
151
151
|
const addr = ctrl.getWalletAddress();
|
|
152
|
-
// Clear all children, keep text nodes
|
|
153
|
-
while (label.firstChild) label.removeChild(label.firstChild);
|
|
154
152
|
if (addr) {
|
|
155
|
-
label.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
label.appendChild(dc);
|
|
159
|
-
// Re-add balance element if it exists
|
|
160
|
-
if (balEl?.isConnected) label.appendChild(balEl);
|
|
153
|
+
label.innerHTML = shortAddress(addr) + ' <span data-nibgate-disconnect style="cursor:pointer">· Disconnect</span> <span data-nibgate-bal style="margin-left:4px;cursor:pointer;white-space:nowrap;color:var(--accent,#7c9a6d)">· <span data-nibgate-bal-txt></span> | ' + depIcon() + '</span>';
|
|
154
|
+
balEl = label.querySelector('[data-nibgate-bal]');
|
|
155
|
+
balEl?.addEventListener('click', showDeposit);
|
|
161
156
|
btn.disabled = false;
|
|
162
157
|
btn.style.cursor = 'pointer';
|
|
163
158
|
} else {
|
|
164
|
-
label.
|
|
159
|
+
label.innerHTML = 'Connect wallet';
|
|
165
160
|
btn.disabled = true;
|
|
166
161
|
btn.style.cursor = 'default';
|
|
167
162
|
btn.innerHTML = unlockSVG + 'Hold to pay';
|
|
168
163
|
}
|
|
169
164
|
}
|
|
170
165
|
|
|
166
|
+
// Re-attach bal click handler after refreshBal updates the text
|
|
167
|
+
function attachBalClick() {
|
|
168
|
+
const b = label.querySelector('[data-nibgate-bal]');
|
|
169
|
+
if (b && !b._clickAttached) { b.addEventListener('click', showDeposit); b._clickAttached = true; }
|
|
170
|
+
}
|
|
171
|
+
|
|
171
172
|
function setBtnText(t) { btn.innerHTML = unlockSVG + t; }
|
|
172
173
|
|
|
173
174
|
function resetHold() {
|
|
@@ -230,7 +231,7 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
230
231
|
card.addEventListener('remove', cleanup);
|
|
231
232
|
|
|
232
233
|
// ── Gateway balance + deposit icon ─────────────────────────────────────
|
|
233
|
-
let
|
|
234
|
+
let gwOverlay = null, balTimer = null;
|
|
234
235
|
|
|
235
236
|
function depIcon() {
|
|
236
237
|
return '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:inline;vertical-align:middle"><path d="M12 17V3"/><path d="m6 11 6 6 6-6"/><path d="M19 21H5"/></svg>';
|
|
@@ -251,28 +252,14 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
251
252
|
}
|
|
252
253
|
function onDepKey(e) { if (e.key === 'Escape' && gwOverlay) { gwOverlay.remove(); gwOverlay = null; document.removeEventListener('keydown', onDepKey); } }
|
|
253
254
|
|
|
254
|
-
function ensureBal() {
|
|
255
|
-
if (balEl && balEl.isConnected) return balEl;
|
|
256
|
-
balEl = label.querySelector('[data-nibgate-bal]');
|
|
257
|
-
if (balEl) {
|
|
258
|
-
balEl.style.display = '';
|
|
259
|
-
balEl.style.marginLeft = '4px';
|
|
260
|
-
balEl.style.cursor = 'pointer';
|
|
261
|
-
balEl.style.whiteSpace = 'nowrap';
|
|
262
|
-
balEl.style.color = 'var(--accent,#7c9a6d)';
|
|
263
|
-
balEl.innerHTML = '\u00b7\u00a0<span data-nibgate-bal-txt></span>\u00a0|\u00a0' + depIcon();
|
|
264
|
-
balEl.addEventListener('click', showDeposit);
|
|
265
|
-
}
|
|
266
|
-
return balEl;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
255
|
async function refreshBal() {
|
|
270
256
|
if (!card.isConnected || !window.ethereum || !options.gatewayBalanceUrl) return;
|
|
271
257
|
try {
|
|
272
258
|
const accts = await window.ethereum.request({ method: 'eth_accounts' });
|
|
273
259
|
const addr = Array.isArray(accts) && accts[0] ? accts[0] : null;
|
|
274
260
|
if (!addr) return;
|
|
275
|
-
|
|
261
|
+
attachBalClick();
|
|
262
|
+
const t = label.querySelector('[data-nibgate-bal-txt]');
|
|
276
263
|
if (!t) return;
|
|
277
264
|
const r = await fetch(options.gatewayBalanceUrl, {
|
|
278
265
|
method: 'POST',
|