@nibgate/sdk 0.2.20 → 0.2.21
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 +14 -74
- package/dist/nibgate.js.map +2 -2
- package/dist/nibgate.min.js +36 -41
- package/dist/nibgate.min.js.map +3 -3
- package/package.json +1 -1
- package/src/browser/default-ui.js +14 -55
package/dist/nibgate.js
CHANGED
|
@@ -27314,7 +27314,6 @@ ${prettyStateOverride(stateOverride)}`;
|
|
|
27314
27314
|
const s = h("style", { id: SID }, `
|
|
27315
27315
|
@keyframes nfade { from { opacity:0;transform:translateY(6px) } to { opacity:1;transform:translateY(0) } }
|
|
27316
27316
|
@keyframes nscale { from { opacity:0;transform:scale(0.96) } to { opacity:1;transform:scale(1) } }
|
|
27317
|
-
@keyframes nshimmer { 0% { transform:translateX(-100%) } 100% { transform:translateX(100%) } }
|
|
27318
27317
|
|
|
27319
27318
|
.nui { font-family:var(--font-content,'Kumbh Sans','ABC Favorit',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif);color:${theme.fg};line-height:1.5;-webkit-font-smoothing:antialiased;font-size:19px }
|
|
27320
27319
|
.nui *,.nui *::before,.nui *::after { box-sizing:border-box }
|
|
@@ -27344,74 +27343,25 @@ ${prettyStateOverride(stateOverride)}`;
|
|
|
27344
27343
|
if (!el2) return;
|
|
27345
27344
|
el2.textContent = msg || "";
|
|
27346
27345
|
}
|
|
27347
|
-
function esc(s) {
|
|
27348
|
-
const d = document.createElement("div");
|
|
27349
|
-
d.textContent = String(s ?? "");
|
|
27350
|
-
return d.innerHTML;
|
|
27351
|
-
}
|
|
27352
27346
|
function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
27353
27347
|
inject();
|
|
27354
27348
|
const card = el("div", { cls: "nui", style: { animation: "nfade .2s ease-out" } });
|
|
27355
|
-
const
|
|
27349
|
+
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>';
|
|
27356
27350
|
card.innerHTML = `
|
|
27357
|
-
<div style="display:flex;flex-direction:column;align-items:center;text-align:center;max-width:
|
|
27358
|
-
<div
|
|
27359
|
-
<div style="
|
|
27360
|
-
|
|
27361
|
-
|
|
27362
|
-
<div
|
|
27363
|
-
<div data-nibgate-unlock-progress style="position:absolute;inset:0;width:0%;background:linear-gradient(90deg,rgba(255,255,255,0.1),rgba(255,255,255,0.45));border-radius:12px;transition:width .05s linear;z-index:2"></div>
|
|
27364
|
-
<div data-nibgate-shimmer style="position:absolute;inset:0;width:100%;height:100%;background:linear-gradient(90deg,transparent,rgba(255,255,255,0.12),transparent);border-radius:12px;transform:translateX(-100%);z-index:3;pointer-events:none"></div>
|
|
27365
|
-
<button type="button" data-nibgate-unlock disabled class="nui-btn nui-btn-primary" style="width:100%;padding:24px 32px;font-size:24px;position:relative;z-index:4;background:${theme.accent};transition:transform .1s,opacity .15s;display:flex">${lockSVG}Hold to pay ${esc(resource.price)} USDC</button></div>
|
|
27366
|
-
<div class="nui-stat" style="text-align:center;margin-top:16px" data-nibgate-status></div>
|
|
27351
|
+
<div style="display:flex;flex-direction:column;align-items:center;text-align:center;max-width:420px;margin:0 auto;padding:24px 20px">
|
|
27352
|
+
<div data-nibgate-wallet-label class="nui-mono" style="font-size:15px;color:${theme.muted};margin-bottom:16px;min-height:24px">Connect wallet</div>
|
|
27353
|
+
<div data-nibgate-unlock-wrap style="width:100%;position:relative;border-radius:10px;overflow:hidden;cursor:pointer">
|
|
27354
|
+
<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>
|
|
27355
|
+
<button type="button" data-nibgate-unlock disabled style="width:100%;padding:12px 0;font-size:16px;font-weight:500;line-height:19px;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">${unlockSVG}Hold to pay</button></div>
|
|
27356
|
+
<div class="nui-stat" style="text-align:center;margin-top:12px" data-nibgate-status></div>
|
|
27367
27357
|
</div>
|
|
27368
|
-
<div data-nibgate-premium hidden style="margin-top:
|
|
27358
|
+
<div data-nibgate-premium hidden style="margin-top:24px;border-top:1px solid ${theme.border};padding-top:24px">${options.premiumContentHTML || ""}</div>
|
|
27369
27359
|
`;
|
|
27370
27360
|
(typeof container === "string" ? document.querySelector(container) : container)?.appendChild(card);
|
|
27371
|
-
(function loadLottie() {
|
|
27372
|
-
if (!document.getElementById("nibgate-lottie")) return;
|
|
27373
|
-
function startAnim(data) {
|
|
27374
|
-
var d = document.getElementById("nibgate-lottie");
|
|
27375
|
-
if (d && window.lottie) {
|
|
27376
|
-
window.lottie.loadAnimation({ container: d, animationData: data, loop: true, autoplay: true });
|
|
27377
|
-
}
|
|
27378
|
-
}
|
|
27379
|
-
if (window.lottie) {
|
|
27380
|
-
if (window._lottieData) {
|
|
27381
|
-
startAnim(window._lottieData);
|
|
27382
|
-
} else {
|
|
27383
|
-
fetch("/nibgate-unlock-key.json?t=1").then(function(r) {
|
|
27384
|
-
if (!r.ok) throw new Error();
|
|
27385
|
-
return r.json();
|
|
27386
|
-
}).then(function(d) {
|
|
27387
|
-
window._lottieData = d;
|
|
27388
|
-
startAnim(d);
|
|
27389
|
-
}).catch(function() {
|
|
27390
|
-
});
|
|
27391
|
-
}
|
|
27392
|
-
return;
|
|
27393
|
-
}
|
|
27394
|
-
if (window._lottieLoading) return;
|
|
27395
|
-
window._lottieLoading = true;
|
|
27396
|
-
var s = document.createElement("script");
|
|
27397
|
-
s.src = "https://cdnjs.cloudflare.com/ajax/libs/lottie-web/5.12.2/lottie.min.js";
|
|
27398
|
-
s.onload = function() {
|
|
27399
|
-
fetch("/nibgate-unlock-key.json?t=1").then(function(r) {
|
|
27400
|
-
if (!r.ok) throw new Error();
|
|
27401
|
-
return r.json();
|
|
27402
|
-
}).then(function(d) {
|
|
27403
|
-
window._lottieData = d;
|
|
27404
|
-
startAnim(d);
|
|
27405
|
-
}).catch(function() {
|
|
27406
|
-
});
|
|
27407
|
-
};
|
|
27408
|
-
document.head.appendChild(s);
|
|
27409
|
-
})();
|
|
27410
27361
|
const st = card.querySelector("[data-nibgate-status]");
|
|
27411
27362
|
const label = card.querySelector("[data-nibgate-wallet-label]");
|
|
27412
27363
|
const wrap3 = card.querySelector("[data-nibgate-unlock-wrap]");
|
|
27413
27364
|
const prog = card.querySelector("[data-nibgate-unlock-progress]");
|
|
27414
|
-
const shimmer = card.querySelector("[data-nibgate-shimmer]");
|
|
27415
27365
|
const btn = card.querySelector("[data-nibgate-unlock]");
|
|
27416
27366
|
const HOLD_MS = 1500;
|
|
27417
27367
|
let holdTimer = null, holdActive = false, holdComplete = false;
|
|
@@ -27450,21 +27400,20 @@ ${prettyStateOverride(stateOverride)}`;
|
|
|
27450
27400
|
label.textContent = "Connect wallet";
|
|
27451
27401
|
btn.disabled = true;
|
|
27452
27402
|
btn.style.cursor = "default";
|
|
27453
|
-
btn.innerHTML =
|
|
27403
|
+
btn.innerHTML = unlockSVG + "Hold to pay";
|
|
27454
27404
|
}
|
|
27455
27405
|
}
|
|
27456
27406
|
function setBtnText(t) {
|
|
27457
|
-
btn.innerHTML =
|
|
27407
|
+
btn.innerHTML = unlockSVG + t;
|
|
27458
27408
|
}
|
|
27459
27409
|
function resetHold() {
|
|
27460
27410
|
holdActive = false;
|
|
27461
27411
|
holdComplete = false;
|
|
27462
27412
|
holdTimer = null;
|
|
27463
27413
|
btn.style.transform = "scale(1)";
|
|
27414
|
+
btn.style.boxShadow = "0 4px 12px rgba(0,0,0,0.08)";
|
|
27464
27415
|
prog.style.width = "0%";
|
|
27465
|
-
|
|
27466
|
-
shimmer.style.transform = "translateX(-100%)";
|
|
27467
|
-
if (!btn.disabled) setBtnText("Hold to pay " + esc(resource.price) + " USDC");
|
|
27416
|
+
if (!btn.disabled) setBtnText("Hold to pay");
|
|
27468
27417
|
}
|
|
27469
27418
|
function startHold(e) {
|
|
27470
27419
|
if (btn.disabled || holdActive) return;
|
|
@@ -27472,28 +27421,19 @@ ${prettyStateOverride(stateOverride)}`;
|
|
|
27472
27421
|
holdActive = true;
|
|
27473
27422
|
holdComplete = false;
|
|
27474
27423
|
btn.style.transform = "scale(.97)";
|
|
27424
|
+
btn.style.boxShadow = "0 2px 6px rgba(0,0,0,0.12)";
|
|
27475
27425
|
prog.style.transition = "none";
|
|
27476
27426
|
prog.style.width = "0%";
|
|
27477
|
-
shimmer.style.animation = "nshimmer 1s ease-in-out infinite";
|
|
27478
|
-
shimmer.style.transform = "none";
|
|
27479
27427
|
setBtnText("Hold\u2026");
|
|
27480
27428
|
requestAnimationFrame(() => {
|
|
27481
27429
|
prog.style.transition = "width " + HOLD_MS + "ms linear";
|
|
27482
27430
|
prog.style.width = "100%";
|
|
27483
27431
|
});
|
|
27484
|
-
const t1 = setTimeout(() => {
|
|
27485
|
-
if (holdActive && !holdComplete) setBtnText("Keep holding\u2026");
|
|
27486
|
-
}, HOLD_MS * 0.4);
|
|
27487
|
-
const t2 = setTimeout(() => {
|
|
27488
|
-
if (holdActive && !holdComplete) setBtnText("Almost there\u2026");
|
|
27489
|
-
}, HOLD_MS * 0.75);
|
|
27490
27432
|
holdTimer = setTimeout(() => {
|
|
27491
27433
|
holdComplete = true;
|
|
27492
27434
|
holdActive = false;
|
|
27493
|
-
clearTimeout(t1);
|
|
27494
|
-
clearTimeout(t2);
|
|
27495
27435
|
btn.style.transform = "scale(1)";
|
|
27496
|
-
|
|
27436
|
+
btn.style.boxShadow = "0 4px 12px rgba(0,0,0,0.08)";
|
|
27497
27437
|
prog.style.transition = "width .05s linear";
|
|
27498
27438
|
setBtnText("Processing\u2026");
|
|
27499
27439
|
btn.disabled = true;
|