@nsite/stealthis 0.1.0 → 0.2.0

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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/src/nostr.ts +15 -15
  3. package/src/widget.ts +16 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsite/stealthis",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "main": "dist/stealthis.js",
6
6
  "module": "dist/stealthis.mjs",
package/src/nostr.ts CHANGED
@@ -9,7 +9,7 @@ export interface NsiteContext {
9
9
  baseDomain: string;
10
10
  }
11
11
 
12
- export interface Thief {
12
+ export interface Muse {
13
13
  index: number;
14
14
  pubkey: string;
15
15
  relays: string[];
@@ -232,11 +232,11 @@ export async function checkExistingSite(
232
232
  return events.length > 0;
233
233
  }
234
234
 
235
- const MAX_THIEF_TAGS = 9;
235
+ const MAX_MUSE_TAGS = 9;
236
236
 
237
- export function extractThieves(event: RelayEvent): Thief[] {
237
+ export function extractMuses(event: RelayEvent): Muse[] {
238
238
  return event.tags
239
- .filter((t) => t[0] === 'thief' && t[1] && t[2])
239
+ .filter((t) => t[0] === 'muse' && t[1] && t[2])
240
240
  .map((t) => ({ index: parseInt(t[1], 10), pubkey: t[2], relays: t.slice(3) }))
241
241
  .sort((a, b) => a.index - b.index);
242
242
  }
@@ -257,25 +257,25 @@ export function createDeployEvent(
257
257
  if (t[0] === 'path' || t[0] === 'server') tags.push([...t]);
258
258
  }
259
259
 
260
- // Paper trail: copy thief tags, add new one, enforce max 9
261
- const sourceThieves = source.tags
262
- .filter((t) => t[0] === 'thief' && t[1] && t[2])
260
+ // Paper trail: copy muse tags, add new one, enforce max 9
261
+ const sourceMuses = source.tags
262
+ .filter((t) => t[0] === 'muse' && t[1] && t[2])
263
263
  .map((t) => [...t])
264
264
  .sort((a, b) => parseInt(a[1], 10) - parseInt(b[1], 10));
265
265
 
266
- const maxIndex = sourceThieves.length > 0
267
- ? Math.max(...sourceThieves.map((t) => parseInt(t[1], 10)))
266
+ const maxIndex = sourceMuses.length > 0
267
+ ? Math.max(...sourceMuses.map((t) => parseInt(t[1], 10)))
268
268
  : -1;
269
- const newThief = ['thief', String(maxIndex + 1), options.deployerPubkey, ...options.deployerRelays];
270
- const allThieves = [...sourceThieves, newThief];
269
+ const newMuse = ['muse', String(maxIndex + 1), options.deployerPubkey, ...options.deployerRelays];
270
+ const allMuses = [...sourceMuses, newMuse];
271
271
 
272
272
  // Keep index 0 (originator) + newest, FIFO truncate the middle
273
- if (allThieves.length > MAX_THIEF_TAGS) {
274
- const originator = allThieves[0];
275
- const keep = allThieves.slice(allThieves.length - (MAX_THIEF_TAGS - 1));
273
+ if (allMuses.length > MAX_MUSE_TAGS) {
274
+ const originator = allMuses[0];
275
+ const keep = allMuses.slice(allMuses.length - (MAX_MUSE_TAGS - 1));
276
276
  tags.push(originator, ...keep);
277
277
  } else {
278
- for (const t of allThieves) tags.push(t);
278
+ for (const t of allMuses) tags.push(t);
279
279
  }
280
280
 
281
281
  if (options.title) tags.push(['title', options.title]);
package/src/widget.ts CHANGED
@@ -45,8 +45,8 @@ export class NsiteDeployButton extends HTMLElement {
45
45
  private ncConnect: ReturnType<typeof prepareNostrConnect> | null = null;
46
46
  private manifestPromise: Promise<nostr.SignedEvent | null> | null = null;
47
47
  private relaysPromise: Promise<string[]> | null = null;
48
- private thieves: nostr.Thief[] = [];
49
- private thievesExpanded = false;
48
+ private muses: nostr.Muse[] = [];
49
+ private musesExpanded = false;
50
50
 
51
51
  constructor() {
52
52
  super();
@@ -56,8 +56,8 @@ export class NsiteDeployButton extends HTMLElement {
56
56
  this.manifestPromise = nostr.fetchManifest(this.ctx);
57
57
  this.manifestPromise.then((manifest) => {
58
58
  if (manifest) {
59
- this.thieves = nostr.extractThieves(manifest);
60
- if (this.thieves.length > 0 && this.state === 'idle') this.render();
59
+ this.muses = nostr.extractMuses(manifest);
60
+ if (this.muses.length > 0 && this.state === 'idle') this.render();
61
61
  }
62
62
  });
63
63
  this.render();
@@ -172,18 +172,18 @@ export class NsiteDeployButton extends HTMLElement {
172
172
  // --- Content builders ---
173
173
 
174
174
  private paperTrailContent(): string {
175
- if (this.thieves.length === 0) return '';
175
+ if (this.muses.length === 0) return '';
176
176
 
177
177
  let html = `<div class="nd-trail">
178
- <button class="nd-trail-toggle" data-action="toggle-trail">Stolen by ${this.thieves.length} npub${this.thieves.length === 1 ? '' : 's'}</button>`;
178
+ <button class="nd-trail-toggle" data-action="toggle-trail">Inspired ${this.muses.length} npub${this.muses.length === 1 ? '' : 's'}</button>`;
179
179
 
180
- if (this.thievesExpanded) {
180
+ if (this.musesExpanded) {
181
181
  html += `<div class="nd-trail-list">`;
182
- const first = this.thieves[0];
183
- const second = this.thieves.length > 1 ? this.thieves[1] : null;
182
+ const first = this.muses[0];
183
+ const second = this.muses.length > 1 ? this.muses[1] : null;
184
184
 
185
185
  // Show originator
186
- html += this.thiefItem(first);
186
+ html += this.museItem(first);
187
187
 
188
188
  // Show gap if indices aren't sequential (truncated middle)
189
189
  if (second && second.index > first.index + 1) {
@@ -192,8 +192,8 @@ export class NsiteDeployButton extends HTMLElement {
192
192
  }
193
193
 
194
194
  // Show the rest
195
- for (let i = 1; i < this.thieves.length; i++) {
196
- html += this.thiefItem(this.thieves[i]);
195
+ for (let i = 1; i < this.muses.length; i++) {
196
+ html += this.museItem(this.muses[i]);
197
197
  }
198
198
  html += `</div>`;
199
199
  }
@@ -202,11 +202,11 @@ export class NsiteDeployButton extends HTMLElement {
202
202
  return html;
203
203
  }
204
204
 
205
- private thiefItem(thief: nostr.Thief): string {
206
- const npub = nostr.npubEncode(thief.pubkey);
205
+ private museItem(muse: nostr.Muse): string {
206
+ const npub = nostr.npubEncode(muse.pubkey);
207
207
  const short = npub.slice(0, 12) + '...' + npub.slice(-4);
208
208
  return `<div class="nd-trail-item">
209
- <span class="nd-trail-idx">#${thief.index}</span>
209
+ <span class="nd-trail-idx">#${muse.index}</span>
210
210
  <span class="nd-trail-pk">${short}</span>
211
211
  </div>`;
212
212
  }
@@ -345,7 +345,7 @@ export class NsiteDeployButton extends HTMLElement {
345
345
  this.shadow
346
346
  .querySelector('[data-action="toggle-trail"]')
347
347
  ?.addEventListener('click', () => {
348
- this.thievesExpanded = !this.thievesExpanded;
348
+ this.musesExpanded = !this.musesExpanded;
349
349
  this.render();
350
350
  });
351
351
  this.shadow