@nibgate/sdk 0.2.18 → 0.2.19

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.18",
3
+ "version": "0.2.19",
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": [
@@ -89,7 +89,7 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
89
89
  <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>
90
90
  <div class="nui-stat" style="text-align:center;margin-top:16px" data-nibgate-status></div>
91
91
  </div>
92
- <div data-nibgate-premium hidden style="margin-top:32px;border-top:1px solid ${theme.border};padding-top:32px"></div>
92
+ <div data-nibgate-premium hidden style="margin-top:32px;border-top:1px solid ${theme.border};padding-top:32px">${options.premiumContentHTML || ''}</div>
93
93
  `;
94
94
 
95
95
  (typeof container === 'string' ? document.querySelector(container) : container)?.appendChild(card);
@@ -142,6 +142,19 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
142
142
  status: '[data-nibgate-status]',
143
143
  unlockedTarget: '[data-nibgate-premium]',
144
144
  onStatus: (msg) => status(st, msg),
145
+ onUnlock: options.premiumContentUrl ? async () => {
146
+ const premiumEl = card.querySelector('[data-nibgate-premium]');
147
+ if (!premiumEl) return;
148
+ premiumEl.innerHTML = 'Loading content...';
149
+ try {
150
+ const res = await fetch(options.premiumContentUrl);
151
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
152
+ const html = await res.text();
153
+ premiumEl.innerHTML = html;
154
+ } catch {
155
+ premiumEl.innerHTML = 'Could not load premium content. Refresh and try again.';
156
+ }
157
+ } : options.onUnlock,
145
158
  });
146
159
 
147
160
  function shortAddress(a) { return a ? a.slice(0, 6) + '...' + a.slice(-4) : ''; }