@nibgate/sdk 0.2.34 → 0.2.35
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 +28 -10
- package/dist/nibgate.js.map +2 -2
- package/dist/nibgate.min.js +15 -15
- package/dist/nibgate.min.js.map +3 -3
- package/package.json +1 -1
- package/src/browser/default-ui.js +21 -10
package/package.json
CHANGED
|
@@ -84,7 +84,7 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
84
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:rgba(255,255,255,0.35);border-radius:10px;transition:width .05s linear;z-index:2"></div>
|
|
87
|
-
<button type="button" data-nibgate-unlock
|
|
87
|
+
<button type="button" data-nibgate-unlock 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};box-shadow:0 4px 12px rgba(0,0,0,0.15);transition:transform .1s,box-shadow .1s;font-family:inherit;display:flex;align-items:center;justify-content:center">${unlockSVG}Hold to pay</button></div>
|
|
88
88
|
<div class="nui-stat" style="text-align:center;margin-top:16px" data-nibgate-status></div>
|
|
89
89
|
</div>
|
|
90
90
|
<div data-nibgate-premium hidden style="margin-top:32px;border-top:1px solid ${theme.border};padding-top:32px">${options.premiumContentHTML || ''}</div>
|
|
@@ -153,12 +153,12 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
153
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
154
|
balEl = label.querySelector('[data-nibgate-bal]');
|
|
155
155
|
balEl?.addEventListener('click', showDeposit);
|
|
156
|
-
btn.
|
|
156
|
+
btn.style.opacity = '1';
|
|
157
157
|
btn.style.cursor = 'pointer';
|
|
158
158
|
} else {
|
|
159
159
|
label.innerHTML = 'Connect wallet';
|
|
160
|
-
btn.
|
|
161
|
-
btn.style.cursor = '
|
|
160
|
+
btn.style.opacity = '0.6';
|
|
161
|
+
btn.style.cursor = 'pointer';
|
|
162
162
|
btn.innerHTML = unlockSVG + 'Hold to pay';
|
|
163
163
|
}
|
|
164
164
|
}
|
|
@@ -169,7 +169,7 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
169
169
|
if (b && !b._clickAttached) { b.addEventListener('click', showDeposit); b._clickAttached = true; }
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
function setBtnText(t) { btn.innerHTML = unlockSVG + t; }
|
|
172
|
+
function setBtnText(t) { btn.innerHTML = unlockSVG + (t || 'Hold to pay'); }
|
|
173
173
|
|
|
174
174
|
function resetHold() {
|
|
175
175
|
holdActive = false;
|
|
@@ -178,12 +178,23 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
178
178
|
btn.style.transform = '';
|
|
179
179
|
btn.style.boxShadow = '';
|
|
180
180
|
prog.style.width = '0%';
|
|
181
|
-
|
|
181
|
+
setBtnText('Hold to pay');
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
function startHold(e) {
|
|
185
|
-
if (
|
|
185
|
+
if (holdActive) return;
|
|
186
186
|
e.preventDefault();
|
|
187
|
+
// Auto-connect wallet if not connected, then start hold immediately
|
|
188
|
+
if (!ctrl.getWalletAddress()) {
|
|
189
|
+
setBtnText('Connecting\u2026');
|
|
190
|
+
btn.style.opacity = '0.6';
|
|
191
|
+
ctrl.connect().then(() => { updateLabel(); btn.style.opacity = '1'; setBtnText('Hold\u2026'); beginHold(); }).catch(() => { updateLabel(); btn.style.opacity = '1'; setBtnText('Hold to pay'); });
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
beginHold();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function beginHold() {
|
|
187
198
|
holdActive = true;
|
|
188
199
|
holdComplete = false;
|
|
189
200
|
btn.style.transform = 'scale(0.96)';
|
|
@@ -202,7 +213,7 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
202
213
|
btn.style.boxShadow = '';
|
|
203
214
|
prog.style.transition = 'width .05s linear';
|
|
204
215
|
setBtnText('Processing\u2026');
|
|
205
|
-
btn.
|
|
216
|
+
btn.style.opacity = '0.6';
|
|
206
217
|
setTimeout(() => ctrl.unlock().then(updateLabel).catch(updateLabel), 300);
|
|
207
218
|
}, HOLD_MS);
|
|
208
219
|
}
|
|
@@ -233,7 +244,7 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
233
244
|
card.addEventListener('remove', cleanup);
|
|
234
245
|
|
|
235
246
|
// ── Gateway balance + deposit icon ─────────────────────────────────────
|
|
236
|
-
let gwOverlay = null, balTimer = null;
|
|
247
|
+
let balEl = null, gwOverlay = null, balTimer = null;
|
|
237
248
|
|
|
238
249
|
function depIcon() {
|
|
239
250
|
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>';
|
|
@@ -274,7 +285,7 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
274
285
|
}
|
|
275
286
|
|
|
276
287
|
if (window.ethereum) {
|
|
277
|
-
balTimer = setInterval(refreshBal,
|
|
288
|
+
balTimer = setInterval(refreshBal, 15000);
|
|
278
289
|
setTimeout(refreshBal, 1000);
|
|
279
290
|
window.ethereum.on('accountsChanged', refreshBal);
|
|
280
291
|
}
|