@candypoets/nipworker 0.94.0 → 0.95.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 (43) hide show
  1. package/dist/NarrowTypes.js +91 -87
  2. package/dist/cache/index.js +53 -53
  3. package/dist/cache/pkg/cache.d.ts +2 -2
  4. package/dist/cache/pkg/cache_bg.wasm.d.ts +2 -2
  5. package/dist/connections/index.js +13 -13
  6. package/dist/connections/pkg/connections.d.ts +5 -5
  7. package/dist/connections/pkg/connections_bg.wasm.d.ts +5 -5
  8. package/dist/connections/proxy.js +1 -1
  9. package/dist/connections/proxy.js.map +4 -4
  10. package/dist/crypto/index.js +40 -40
  11. package/dist/generated/nostr/fb/content-block.d.ts +3 -2
  12. package/dist/generated/nostr/fb/content-block.d.ts.map +1 -1
  13. package/dist/generated/nostr/fb/content-data.d.ts +5 -3
  14. package/dist/generated/nostr/fb/content-data.d.ts.map +1 -1
  15. package/dist/generated/nostr/fb/emoji-data.d.ts +30 -0
  16. package/dist/generated/nostr/fb/emoji-data.d.ts.map +1 -0
  17. package/dist/generated/nostr/fb/kind1018-parsed.d.ts +37 -0
  18. package/dist/generated/nostr/fb/kind1018-parsed.d.ts.map +1 -0
  19. package/dist/generated/nostr/fb/kind1068-parsed.d.ts +58 -0
  20. package/dist/generated/nostr/fb/kind1068-parsed.d.ts.map +1 -0
  21. package/dist/generated/nostr/fb/parsed-data-union.d.ts +2 -0
  22. package/dist/generated/nostr/fb/parsed-data-union.d.ts.map +1 -1
  23. package/dist/generated/nostr/fb/parsed-data.d.ts +17 -13
  24. package/dist/generated/nostr/fb/parsed-data.d.ts.map +1 -1
  25. package/dist/generated/nostr/fb/parsed-event.d.ts +4 -2
  26. package/dist/generated/nostr/fb/parsed-event.d.ts.map +1 -1
  27. package/dist/generated/nostr/fb/poll-option.d.ts +26 -0
  28. package/dist/generated/nostr/fb/poll-option.d.ts.map +1 -0
  29. package/dist/generated/nostr/fb/poll-type.d.ts +5 -0
  30. package/dist/generated/nostr/fb/poll-type.d.ts.map +1 -0
  31. package/dist/generated/nostr/fb.d.ts +5 -0
  32. package/dist/generated/nostr/fb.d.ts.map +1 -1
  33. package/dist/index.js +159 -150
  34. package/dist/index2.js +31 -31
  35. package/dist/lib/ConnectionTracker.d.ts +2 -0
  36. package/dist/lib/ConnectionTracker.d.ts.map +1 -1
  37. package/dist/lib/NarrowTypes.d.ts +2 -1
  38. package/dist/lib/NarrowTypes.d.ts.map +1 -1
  39. package/dist/parser/index.js +305 -305
  40. package/dist/relayProxyServer.js +298 -352
  41. package/dist/utils.js +91 -86
  42. package/dist/worker-message.js +1148 -759
  43. package/package.json +1 -1
package/dist/utils.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { nip19 as $, generateSecretKey as B, getPublicKey as A } from "nostr-tools";
2
2
  import { g as G } from "./index2.js";
3
3
  import { b as N } from "./NarrowTypes.js";
4
- import { l as ee, a4 as te, a2 as ne, f as se, j as ae, g as oe, a3 as ie, a5 as re, p as ce, r as de, L as le, N as ue, H as pe, J as ge, B as he, P as fe, D as ye, F as we, t as Ke, v as ke, x as me, z as ve, R as De, T as Se, V as xe, X as Ce, Z as be, a9 as Me, a7 as Te, $ as Be, a8 as Ae, e as Ie, d as Pe, a1 as Re, n as Ee, a6 as $e, k as Ge, h as Ne, c as Le, o as Ve, q as ze, K as Ze, M as _e, G as He, I as Oe, A as Ue, O as Qe, C as Fe, E as We, s as je, u as Je, w as Xe, y as Ye, Q as qe, S as et, U as tt, W as nt, Y as st, _ as at, a as ot, i as it, a0 as rt, m as ct } from "./NarrowTypes.js";
5
- import { J as h, v as d, O as k, Q as M, T, U as I, X as L, Y as V, Z as z, _ as Z, $ as _ } from "./worker-message.js";
6
- class F {
4
+ import { l as ee, a4 as te, a2 as ne, f as se, j as ae, aa as oe, g as ie, a3 as re, a5 as ce, p as de, r as le, L as ue, N as pe, H as ge, J as he, B as fe, P as ye, D as we, F as ke, t as Ke, v as me, x as ve, z as De, R as Se, T as xe, V as Ce, X as be, Z as Me, a9 as Te, a7 as Be, $ as Ae, a8 as Ie, e as Re, d as Ee, a1 as Pe, n as $e, a6 as Ge, k as Ne, h as Le, c as Ve, o as ze, q as Ze, K as _e, M as He, G as Oe, I as Ue, A as Qe, O as je, C as Fe, E as We, s as Xe, u as Ye, w as qe, y as Je, Q as et, S as tt, U as nt, W as st, Y as at, _ as ot, a as it, i as rt, a0 as ct, m as dt } from "./NarrowTypes.js";
5
+ import { O as h, v as d, Q as K, T as M, U as T, X as I, Y as L, Z as V, _ as z, $ as Z, a0 as _ } from "./worker-message.js";
6
+ class j {
7
7
  constructor() {
8
8
  this.knownRelays = /* @__PURE__ */ new Map(), this.incomingCount = 0, this.resolvedCount = 0;
9
9
  }
@@ -36,9 +36,13 @@ class F {
36
36
  get resolutionRate() {
37
37
  return this.incomingCount === 0 ? 0 : this.resolvedCount / this.incomingCount;
38
38
  }
39
+ /** Reset all tracking state for a fresh subscription */
40
+ reset() {
41
+ this.knownRelays.clear(), this.incomingCount = 0, this.resolvedCount = 0;
42
+ }
39
43
  }
40
44
  const t = new TextEncoder();
41
- async function W(c) {
45
+ async function F(c) {
42
46
  var _a, _b, _c, _d, _e2, _f, _g, _h, _i;
43
47
  const i = [], r = (e) => new h(t.encode("text"), t.encode(e), d.NONE, null), l = (e) => new h(
44
48
  t.encode("image"),
@@ -79,7 +83,7 @@ async function W(c) {
79
83
  t.encode(e),
80
84
  d.LinkPreviewData,
81
85
  new Z(t.encode(e), null, null, null)
82
- ), P = (e, s) => {
86
+ ), R = (e, s) => {
83
87
  try {
84
88
  const n = $.decode(e), p = n.type;
85
89
  let a = null, g = [], S = null, b = BigInt(0);
@@ -116,7 +120,7 @@ async function W(c) {
116
120
  } catch {
117
121
  return r(s);
118
122
  }
119
- }, R = [
123
+ }, E = [
120
124
  {
121
125
  type: "code",
122
126
  regex: /```([\s\S]*?)```/g,
@@ -148,7 +152,7 @@ async function W(c) {
148
152
  regex: /nostr:([a-z0-9]+)/gi,
149
153
  processMatch: (e) => {
150
154
  const s = e[1];
151
- return P(s || "", e[0]);
155
+ return R(s || "", e[0]);
152
156
  }
153
157
  },
154
158
  {
@@ -157,7 +161,7 @@ async function W(c) {
157
161
  processMatch: async (e) => v(e[0])
158
162
  }
159
163
  ], C = [];
160
- for (const e of R) {
164
+ for (const e of E) {
161
165
  let s;
162
166
  for (e.regex.lastIndex = 0; (s = e.regex.exec(c)) !== null; ) {
163
167
  const n = s.index, p = n + s[0].length, a = await e.processMatch(s);
@@ -175,36 +179,36 @@ async function W(c) {
175
179
  for (const { start: e, end: s, block: n } of x)
176
180
  e > D && i.push(r(c.substring(D, e))), i.push(n), D = s;
177
181
  D < c.length && i.push(r(c.substring(D)));
178
- const K = [];
182
+ const k = [];
179
183
  let u = [];
180
- const E = (e) => /^\s+$/.test(e);
184
+ const P = (e) => /^\s+$/.test(e);
181
185
  for (let e = 0; e < i.length; e++) {
182
186
  const s = i[e];
183
187
  if (((_a = s == null ? void 0 : s.type) == null ? void 0 : _a.toString()) === "image" || ((_b = s == null ? void 0 : s.type) == null ? void 0 : _b.toString()) === "video") {
184
188
  u.push(s);
185
189
  continue;
186
190
  }
187
- if (!(((_c = s == null ? void 0 : s.type) == null ? void 0 : _c.toString()) === "text" && typeof ((_d = s == null ? void 0 : s.text) == null ? void 0 : _d.toString()) == "string" && E((_e2 = s.text) == null ? void 0 : _e2.toString()) && u.length > 0 && e + 1 < i.length && (((_g = (_f = i[e + 1]) == null ? void 0 : _f.type) == null ? void 0 : _g.toString()) === "image" || ((_i = (_h = i[e + 1]) == null ? void 0 : _h.type) == null ? void 0 : _i.toString()) === "video"))) {
191
+ if (!(((_c = s == null ? void 0 : s.type) == null ? void 0 : _c.toString()) === "text" && typeof ((_d = s == null ? void 0 : s.text) == null ? void 0 : _d.toString()) == "string" && P((_e2 = s.text) == null ? void 0 : _e2.toString()) && u.length > 0 && e + 1 < i.length && (((_g = (_f = i[e + 1]) == null ? void 0 : _f.type) == null ? void 0 : _g.toString()) === "image" || ((_i = (_h = i[e + 1]) == null ? void 0 : _h.type) == null ? void 0 : _i.toString()) === "video"))) {
188
192
  if (u.length > 0) {
189
193
  if (u.length > 1) {
190
194
  const n = u.map((a) => {
191
195
  if (a.dataType === d.ImageData) {
192
196
  const g = a.data;
193
- return new k(
197
+ return new K(
194
198
  new M(t.encode(g.url ?? a.text), null),
195
199
  null
196
200
  );
197
201
  } else if (a.dataType === d.VideoData) {
198
202
  const g = a.data;
199
- return new k(
203
+ return new K(
200
204
  null,
201
205
  new T(t.encode(g.url ?? a.text), null)
202
206
  );
203
207
  }
204
- return new k(null, null);
208
+ return new K(null, null);
205
209
  }), p = u.map((a) => String(a.text ?? "")).join(`
206
210
  `);
207
- K.push(
211
+ k.push(
208
212
  new h(
209
213
  t.encode("mediaGrid"),
210
214
  t.encode(p),
@@ -213,10 +217,10 @@ async function W(c) {
213
217
  )
214
218
  );
215
219
  } else
216
- K.push(u[0]);
220
+ k.push(u[0]);
217
221
  u = [];
218
222
  }
219
- K.push(s);
223
+ k.push(s);
220
224
  }
221
225
  }
222
226
  if (u.length > 0)
@@ -224,21 +228,21 @@ async function W(c) {
224
228
  const e = u.map((n) => {
225
229
  if (n.dataType === d.ImageData) {
226
230
  const p = n.data;
227
- return new k(
231
+ return new K(
228
232
  new M(t.encode(p.url ?? n.text), null),
229
233
  null
230
234
  );
231
235
  } else if (n.dataType === d.VideoData) {
232
236
  const p = n.data;
233
- return new k(
237
+ return new K(
234
238
  null,
235
239
  new T(t.encode(p.url ?? n.text), null)
236
240
  );
237
241
  }
238
- return new k(null, null);
242
+ return new K(null, null);
239
243
  }), s = u.map((n) => String(n.text ?? "")).join(`
240
244
  `);
241
- K.push(
245
+ k.push(
242
246
  new h(
243
247
  t.encode("mediaGrid"),
244
248
  t.encode(s),
@@ -247,10 +251,10 @@ async function W(c) {
247
251
  )
248
252
  );
249
253
  } else
250
- K.push(u[0]);
251
- return K;
254
+ k.push(u[0]);
255
+ return k;
252
256
  }
253
- function j(c, i) {
257
+ function W(c, i) {
254
258
  const r = c[`${String(i)}Length`]();
255
259
  return {
256
260
  [Symbol.iterator]() {
@@ -268,7 +272,7 @@ function j(c, i) {
268
272
  }
269
273
  };
270
274
  }
271
- function J(c, i) {
275
+ function X(c, i) {
272
276
  var _a;
273
277
  if (!c) return [];
274
278
  const r = (_a = c[`${String(i)}Length`]) == null ? void 0 : _a.bind(c);
@@ -280,7 +284,7 @@ function J(c, i) {
280
284
  }
281
285
  return f;
282
286
  }
283
- async function X(c, i) {
287
+ async function Y(c, i) {
284
288
  const r = B(), l = A(r), f = Array.from(r).map((v) => v.toString(16).padStart(2, "0")).join(""), w = A(B()), y = new URLSearchParams();
285
289
  for (const v of i)
286
290
  y.append("relay", v);
@@ -289,73 +293,74 @@ async function X(c, i) {
289
293
  return console.log("connect url:", m), G().setNip46QR(m, f), m;
290
294
  }
291
295
  export {
292
- F as ConnectionTracker,
296
+ j as ConnectionTracker,
293
297
  ee as asBufferFull,
294
298
  te as asCashuData,
295
299
  ne as asCodeData,
296
300
  se as asConnectionStatus,
297
301
  ae as asCountResponse,
298
- oe as asEoce,
299
- ie as asHashtagData,
300
- re as asImageData,
301
- ce as asKind0,
302
- de as asKind1,
303
- le as asKind10002,
304
- ue as asKind10019,
305
- pe as asKind1111,
306
- ge as asKind1311,
307
- he as asKind17,
308
- fe as asKind17375,
309
- ye as asKind20,
310
- we as asKind22,
302
+ oe as asEmojiData,
303
+ ie as asEoce,
304
+ re as asHashtagData,
305
+ ce as asImageData,
306
+ de as asKind0,
307
+ le as asKind1,
308
+ ue as asKind10002,
309
+ pe as asKind10019,
310
+ ge as asKind1111,
311
+ he as asKind1311,
312
+ fe as asKind17,
313
+ ye as asKind17375,
314
+ we as asKind20,
315
+ ke as asKind22,
311
316
  Ke as asKind3,
312
- ke as asKind4,
313
- me as asKind6,
314
- ve as asKind7,
315
- De as asKind7374,
316
- Se as asKind7375,
317
- xe as asKind7376,
318
- Ce as asKind9321,
319
- be as asKind9735,
320
- Me as asLinkPreview,
321
- Te as asMediaGroupData,
322
- Be as asNip51,
323
- Ae as asNostrData,
324
- Ie as asNostrEvent,
325
- Pe as asParsedEvent,
326
- Re as asPreGeneric,
327
- Ee as asValidProofs,
328
- $e as asVideoData,
329
- X as connectWithQRCode,
330
- J as fbArray,
331
- j as fbIterable,
332
- Ge as isBufferFull,
317
+ me as asKind4,
318
+ ve as asKind6,
319
+ De as asKind7,
320
+ Se as asKind7374,
321
+ xe as asKind7375,
322
+ Ce as asKind7376,
323
+ be as asKind9321,
324
+ Me as asKind9735,
325
+ Te as asLinkPreview,
326
+ Be as asMediaGroupData,
327
+ Ae as asNip51,
328
+ Ie as asNostrData,
329
+ Re as asNostrEvent,
330
+ Ee as asParsedEvent,
331
+ Pe as asPreGeneric,
332
+ $e as asValidProofs,
333
+ Ge as asVideoData,
334
+ Y as connectWithQRCode,
335
+ X as fbArray,
336
+ W as fbIterable,
337
+ Ne as isBufferFull,
333
338
  N as isConnectionStatus,
334
- Ne as isCountResponse,
335
- Le as isEoce,
336
- Ve as isKind0,
337
- ze as isKind1,
338
- Ze as isKind10002,
339
- _e as isKind10019,
340
- He as isKind1111,
341
- Oe as isKind1311,
342
- Ue as isKind17,
343
- Qe as isKind17375,
339
+ Le as isCountResponse,
340
+ Ve as isEoce,
341
+ ze as isKind0,
342
+ Ze as isKind1,
343
+ _e as isKind10002,
344
+ He as isKind10019,
345
+ Oe as isKind1111,
346
+ Ue as isKind1311,
347
+ Qe as isKind17,
348
+ je as isKind17375,
344
349
  Fe as isKind20,
345
350
  We as isKind22,
346
- je as isKind3,
347
- Je as isKind4,
348
- Xe as isKind6,
349
- Ye as isKind7,
350
- qe as isKind7374,
351
- et as isKind7375,
352
- tt as isKind7376,
353
- nt as isKind9321,
354
- st as isKind9735,
355
- at as isNip51,
356
- ot as isNostrEvent,
357
- it as isParsedEvent,
358
- rt as isPreGeneric,
359
- ct as isValidProofs,
360
- W as parseContent
351
+ Xe as isKind3,
352
+ Ye as isKind4,
353
+ qe as isKind6,
354
+ Je as isKind7,
355
+ et as isKind7374,
356
+ tt as isKind7375,
357
+ nt as isKind7376,
358
+ st as isKind9321,
359
+ at as isKind9735,
360
+ ot as isNip51,
361
+ it as isNostrEvent,
362
+ rt as isParsedEvent,
363
+ ct as isPreGeneric,
364
+ dt as isValidProofs,
365
+ F as parseContent
361
366
  };