@nibgate/sdk 0.2.23 → 0.2.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nibgate/sdk",
3
- "version": "0.2.23",
3
+ "version": "0.2.24",
4
4
  "description": "Framework-agnostic browser and server package for creator-owned gated content, unlock events, and receipts.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -224,71 +224,7 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
224
224
  const cleanup = () => { document.removeEventListener('mouseup', cancelHold); document.removeEventListener('touchend', cancelHold); };
225
225
  card.addEventListener('remove', cleanup);
226
226
 
227
- // ── Gateway balance + deposit icon ─────────────────────────────────────
228
- let gwOverlayEl = null;
229
- let balTimer = null;
230
- let balEl = null;
231
-
232
- function depositIconHTML() {
233
- return '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:inline;vertical-align:baseline"><path d="M12 17V3"/><path d="m6 11 6 6 6-6"/><path d="M19 21H5"/></svg>';
234
- }
235
-
236
- async function showGatewayWallet() {
237
- if (gwOverlayEl) return;
238
- gwOverlayEl = el('div', { style: 'position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,0.5);display:flex;align-items:center;justify-content:center;padding:20px;animation:nfade .15s ease-out' });
239
- const modal = el('div', { style: 'background:' + theme.bg + ';border-radius:16px;max-width:540px;width:100%;max-height:90vh;overflow:auto;position:relative;box-shadow:0 8px 32px rgba(0,0,0,0.12);animation:nscale .15s ease-out' });
240
- const close = el('button', { style: 'position:absolute;top:12px;right:16px;z-index:20;background:none;border:none;font-size:28px;cursor:pointer;color:' + theme.muted + ';font-family:inherit;line-height:1' }, '\u00d7');
241
- close.addEventListener('click', closeGatewayWallet);
242
- modal.appendChild(close);
243
- gwOverlayEl.appendChild(modal);
244
- gwOverlayEl.addEventListener('click', (e) => { if (e.target === gwOverlayEl) closeGatewayWallet(); });
245
- document.body.appendChild(gwOverlayEl);
246
- document.addEventListener('keydown', onGwKey);
247
-
248
- const gw = await import('./default-ui.js');
249
- gw.renderDefaultGatewayWalletUI(modal, options.gatewayOptions || {});
250
- }
251
-
252
- function closeGatewayWallet() {
253
- if (!gwOverlayEl) return;
254
- gwOverlayEl.remove();
255
- gwOverlayEl = null;
256
- document.removeEventListener('keydown', onGwKey);
257
- }
258
-
259
- function onGwKey(e) { if (e.key === 'Escape') closeGatewayWallet(); }
260
-
261
- function ensureBalEl() {
262
- if (balEl && balEl.isConnected) return balEl;
263
- balEl = el('span', { 'data-nibgate-bal': '', style: 'margin-left:6px;cursor:pointer;white-space:nowrap' }, depositIconHTML() + ' <span data-nibgate-bal-text></span>');
264
- balEl.addEventListener('click', showGatewayWallet);
265
- if (label.parentNode) label.parentNode.insertBefore(balEl, label.nextSibling);
266
- return balEl;
267
- }
268
-
269
- async function refreshBalance() {
270
- if (!card.isConnected) return;
271
- const addr = ctrl.getWalletAddress();
272
- if (!addr) return;
273
- const txt = ensureBalEl().querySelector('[data-nibgate-bal-text]');
274
- if (options.gatewayBalanceUrl) {
275
- try {
276
- const res = await fetch(options.gatewayBalanceUrl + '?address=' + encodeURIComponent(addr));
277
- const data = await res.json();
278
- if (txt) txt.textContent = data?.balance || data?.availableBalance || '\u2026';
279
- return;
280
- } catch {}
281
- }
282
- if (txt) txt.textContent = '\u2026';
283
- }
284
-
285
- if (window.ethereum) {
286
- balTimer = setInterval(refreshBalance, 3000);
287
- setTimeout(refreshBalance, 1000);
288
- window.ethereum.on('accountsChanged', refreshBalance);
289
- }
290
-
291
- return { ...ctrl, element: card, destroy: () => { cleanup(); card.remove(); if (balTimer) clearInterval(balTimer); closeGatewayWallet(); } };
227
+ return { ...ctrl, element: card, destroy: () => { cleanup(); card.remove(); } };
292
228
  }
293
229
 
294
230
  export function renderDefaultRatingUI(container, resource, options = {}) {