@candypoets/nipworker 0.94.0 → 0.96.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.
- package/dist/NarrowTypes.js +91 -87
- package/dist/cache/index.js +136 -128
- package/dist/cache/pkg/cache.d.ts +3 -3
- package/dist/cache/pkg/cache_bg.wasm.d.ts +3 -3
- package/dist/connections/index.js +68 -58
- package/dist/connections/pkg/connections.d.ts +4 -4
- package/dist/connections/pkg/connections_bg.wasm.d.ts +4 -4
- package/dist/connections/proxy.js +1 -1
- package/dist/connections/proxy.js.map +4 -4
- package/dist/crypto/index.js +86 -77
- package/dist/generated/nostr/fb/content-block.d.ts +3 -2
- package/dist/generated/nostr/fb/content-block.d.ts.map +1 -1
- package/dist/generated/nostr/fb/content-data.d.ts +5 -3
- package/dist/generated/nostr/fb/content-data.d.ts.map +1 -1
- package/dist/generated/nostr/fb/emoji-data.d.ts +30 -0
- package/dist/generated/nostr/fb/emoji-data.d.ts.map +1 -0
- package/dist/generated/nostr/fb/kind1018-parsed.d.ts +37 -0
- package/dist/generated/nostr/fb/kind1018-parsed.d.ts.map +1 -0
- package/dist/generated/nostr/fb/kind1068-parsed.d.ts +58 -0
- package/dist/generated/nostr/fb/kind1068-parsed.d.ts.map +1 -0
- package/dist/generated/nostr/fb/parsed-data-union.d.ts +2 -0
- package/dist/generated/nostr/fb/parsed-data-union.d.ts.map +1 -1
- package/dist/generated/nostr/fb/parsed-data.d.ts +17 -13
- package/dist/generated/nostr/fb/parsed-data.d.ts.map +1 -1
- package/dist/generated/nostr/fb/parsed-event.d.ts +4 -2
- package/dist/generated/nostr/fb/parsed-event.d.ts.map +1 -1
- package/dist/generated/nostr/fb/poll-option.d.ts +26 -0
- package/dist/generated/nostr/fb/poll-option.d.ts.map +1 -0
- package/dist/generated/nostr/fb/poll-type.d.ts +5 -0
- package/dist/generated/nostr/fb/poll-type.d.ts.map +1 -0
- package/dist/generated/nostr/fb.d.ts +5 -0
- package/dist/generated/nostr/fb.d.ts.map +1 -1
- package/dist/index.js +159 -150
- package/dist/index2.js +31 -31
- package/dist/lib/ConnectionTracker.d.ts +2 -0
- package/dist/lib/ConnectionTracker.d.ts.map +1 -1
- package/dist/lib/NarrowTypes.d.ts +2 -1
- package/dist/lib/NarrowTypes.d.ts.map +1 -1
- package/dist/parser/index.js +51 -52
- package/dist/relayProxyServer.js +298 -352
- package/dist/utils.js +91 -86
- package/dist/worker-message.js +1148 -759
- 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,
|
|
5
|
-
import {
|
|
6
|
-
class
|
|
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
|
|
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
|
-
),
|
|
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
|
-
},
|
|
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
|
|
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
|
|
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
|
|
182
|
+
const k = [];
|
|
179
183
|
let u = [];
|
|
180
|
-
const
|
|
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" &&
|
|
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
|
|
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
|
|
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
|
|
208
|
+
return new K(null, null);
|
|
205
209
|
}), p = u.map((a) => String(a.text ?? "")).join(`
|
|
206
210
|
`);
|
|
207
|
-
|
|
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
|
-
|
|
220
|
+
k.push(u[0]);
|
|
217
221
|
u = [];
|
|
218
222
|
}
|
|
219
|
-
|
|
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
|
|
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
|
|
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
|
|
242
|
+
return new K(null, null);
|
|
239
243
|
}), s = u.map((n) => String(n.text ?? "")).join(`
|
|
240
244
|
`);
|
|
241
|
-
|
|
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
|
-
|
|
251
|
-
return
|
|
254
|
+
k.push(u[0]);
|
|
255
|
+
return k;
|
|
252
256
|
}
|
|
253
|
-
function
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
299
|
-
ie as
|
|
300
|
-
re as
|
|
301
|
-
ce as
|
|
302
|
-
de as
|
|
303
|
-
le as
|
|
304
|
-
ue as
|
|
305
|
-
pe as
|
|
306
|
-
ge as
|
|
307
|
-
he as
|
|
308
|
-
fe as
|
|
309
|
-
ye as
|
|
310
|
-
we as
|
|
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
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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
|
};
|