@nibgate/sdk 0.2.33 → 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 +31 -11
- 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 +24 -11
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
|
}
|
|
@@ -214,7 +225,9 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
214
225
|
}
|
|
215
226
|
|
|
216
227
|
label.addEventListener('click', (e) => {
|
|
217
|
-
if (
|
|
228
|
+
if (e.target.dataset.nibgateDisconnect !== undefined) {
|
|
229
|
+
ctrl.disconnect().then(updateLabel);
|
|
230
|
+
} else if (!ctrl.getWalletAddress()) {
|
|
218
231
|
ctrl.connect().then(updateLabel).catch(() => updateLabel());
|
|
219
232
|
}
|
|
220
233
|
});
|
|
@@ -231,7 +244,7 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
231
244
|
card.addEventListener('remove', cleanup);
|
|
232
245
|
|
|
233
246
|
// ── Gateway balance + deposit icon ─────────────────────────────────────
|
|
234
|
-
let gwOverlay = null, balTimer = null;
|
|
247
|
+
let balEl = null, gwOverlay = null, balTimer = null;
|
|
235
248
|
|
|
236
249
|
function depIcon() {
|
|
237
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>';
|
|
@@ -272,7 +285,7 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
272
285
|
}
|
|
273
286
|
|
|
274
287
|
if (window.ethereum) {
|
|
275
|
-
balTimer = setInterval(refreshBal,
|
|
288
|
+
balTimer = setInterval(refreshBal, 15000);
|
|
276
289
|
setTimeout(refreshBal, 1000);
|
|
277
290
|
window.ethereum.on('accountsChanged', refreshBal);
|
|
278
291
|
}
|