@seedprotocol/arweave 0.7.12 → 0.7.13-next.1527.g318ec68

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.
@@ -3,25 +3,24 @@ import t from "debug";
3
3
  //#region src/constants.ts
4
4
  var n = "arweave.net", r = "", i = "", a = "127.0.0.1", o = 1984, s = `https://${n}/graphql`, c = [
5
5
  "arweave.net",
6
- "permagate.io",
7
6
  "zigza.xyz",
8
7
  "ar.seedprotocol.io"
9
- ], ee = ["ARWEAVE_READ_GATEWAYS", "NEXT_PUBLIC_ARWEAVE_READ_GATEWAYS"], l = [
8
+ ], l = ["permagate.io"], u = [...c, ...l], ee = ["ARWEAVE_READ_GATEWAYS", "NEXT_PUBLIC_ARWEAVE_READ_GATEWAYS"], te = [
10
9
  "NEXT_PUBLIC_ARWEAVE_HOST",
11
10
  "ARWEAVE_HOST",
12
11
  "VITE_ARWEAVE_HOST"
13
12
  ];
14
- function te(e) {
13
+ function ne(e) {
15
14
  let t = e.trim();
16
15
  return t.startsWith("http://") ? t.slice(7).replace(/\/$/, "") : t.startsWith("https://") ? t.slice(8).replace(/\/$/, "") : t.replace(/\/$/, "");
17
16
  }
18
- function ne() {
19
- if (typeof process < "u" && process.env) for (let e of l) {
17
+ function d() {
18
+ if (typeof process < "u" && process.env) for (let e of te) {
20
19
  let t = process.env[e]?.trim();
21
- if (t) return te(t);
20
+ if (t) return ne(t);
22
21
  }
23
22
  }
24
- function u(e) {
23
+ function f(e) {
25
24
  return ie(e, re());
26
25
  }
27
26
  function re() {
@@ -47,7 +46,7 @@ function ae(e) {
47
46
  let t = e.trim().toLowerCase();
48
47
  if (!t) return !1;
49
48
  if (t.endsWith("arweave.net") || t.endsWith("ar-io.net")) return !0;
50
- for (let e of c) {
49
+ for (let e of u) {
51
50
  let n = e.toLowerCase();
52
51
  if (t === n || t.endsWith(`.${n}`)) return !0;
53
52
  }
@@ -55,46 +54,46 @@ function ae(e) {
55
54
  }
56
55
  //#endregion
57
56
  //#region src/content/arweaveContent.ts
58
- var d;
57
+ var p;
59
58
  function oe(e) {
60
- d = e;
59
+ p = e;
61
60
  }
62
61
  function se() {
63
- return d !== void 0;
62
+ return p !== void 0;
64
63
  }
65
- async function f(e, t) {
66
- return d ? d(e, t) : e;
64
+ async function m(e, t) {
65
+ return p ? p(e, t) : e;
67
66
  }
68
- function p(e) {
67
+ function ce(e) {
69
68
  return (e.headers?.get("content-type"))?.split(";")[0]?.trim().toLowerCase() || void 0;
70
69
  }
71
- async function ce(e, t) {
72
- return f({
70
+ async function le(e, t) {
71
+ return m({
73
72
  bytes: new Uint8Array(await e.arrayBuffer()),
74
- contentType: p(e)
73
+ contentType: ce(e)
75
74
  }, t);
76
75
  }
77
76
  //#endregion
78
77
  //#region src/moduleOwner.ts
79
- var m = Symbol.for("@seedprotocol/arweave:clientOwner"), le = Object.freeze({ package: "@seedprotocol/arweave" });
78
+ var h = Symbol.for("@seedprotocol/arweave:clientOwner"), g = Object.freeze({ package: "@seedprotocol/arweave" });
80
79
  function ue() {
81
- globalThis[m] = le;
80
+ globalThis[h] = g;
82
81
  }
83
- var h = class extends Error {
82
+ var _ = class extends Error {
84
83
  constructor() {
85
84
  super("Two copies of @seedprotocol/arweave are loaded, and the Arweave client was registered on the other copy (e.g. by SeedClient). Reads through this copy would use a different client and gateway. Make sure every @seedprotocol/* package is the same version and installed once (`npm ls @seedprotocol/arweave`). With Vite, keep @seedprotocol/* packages out of optimizeDeps.exclude so they are pre-bundled together, and dedupe them (seedVitePlugin does) when they are linked into the app."), this.name = "DuplicateArweaveModuleError";
86
85
  }
87
86
  };
88
87
  function de() {
89
- let e = globalThis[m];
90
- if (e !== void 0 && e !== le) throw new h();
88
+ let e = globalThis[h];
89
+ if (e !== void 0 && e !== g) throw new _();
91
90
  }
92
91
  function fe() {
93
- delete globalThis[m];
92
+ delete globalThis[h];
94
93
  }
95
94
  //#endregion
96
95
  //#region src/ArweaveClient/BaseArweaveClient.ts
97
- function g(e) {
96
+ function v(e) {
98
97
  let t = e.trim();
99
98
  return t.startsWith("http://") ? {
100
99
  protocol: "http",
@@ -107,7 +106,7 @@ function g(e) {
107
106
  host: t.replace(/\/$/, "")
108
107
  };
109
108
  }
110
- var _ = n, v = "https", y = !1, b = !1, x = class e {
109
+ var y = n, b = "https", x = !1, S = !1, C = class e {
111
110
  static _impl = null;
112
111
  static configure(t) {
113
112
  if (!t) throw Error("Cannot configure ArweaveClient with undefined or null. Ensure the platform-specific ArweaveClient is properly created.");
@@ -121,10 +120,10 @@ var _ = n, v = "https", y = !1, b = !1, x = class e {
121
120
  return e._impl;
122
121
  }
123
122
  static resolveGateway() {
124
- let e = ne();
125
- return e && !y && !b ? g(e) : {
126
- protocol: v,
127
- host: _
123
+ let e = d();
124
+ return e && !x && !S ? v(e) : {
125
+ protocol: b,
126
+ host: y
128
127
  };
129
128
  }
130
129
  static getHost() {
@@ -163,22 +162,22 @@ var _ = n, v = "https", y = !1, b = !1, x = class e {
163
162
  return `${e}://${t}`;
164
163
  }
165
164
  static setHost(e) {
166
- let t = g(e);
167
- _ = t.host, v = t.protocol, y = !0, b = !1;
165
+ let t = v(e);
166
+ y = t.host, b = t.protocol, x = !0, S = !1;
168
167
  }
169
168
  static isReadGatewayLocked() {
170
- return y;
169
+ return x;
171
170
  }
172
171
  static resetReadGatewaySelectionStateForTests() {
173
- b = !1;
172
+ S = !1;
174
173
  }
175
174
  static setPreferredReadGateway(e) {
176
- let t = g(e);
177
- _ = t.host, v = t.protocol, y = !1;
175
+ let t = v(e);
176
+ y = t.host, b = t.protocol, x = !1;
178
177
  }
179
178
  static applyProbedReadGateway(e) {
180
- let t = g(e);
181
- _ = t.host, v = t.protocol, y = !1, b = !0;
179
+ let t = v(e);
180
+ y = t.host, b = t.protocol, x = !1, S = !0;
182
181
  }
183
182
  static getEndpoint() {
184
183
  return `${this.getBaseUrl()}/graphql`;
@@ -198,7 +197,7 @@ var _ = n, v = "https", y = !1, b = !1, x = class e {
198
197
  static async getTransactionData(t, n) {
199
198
  let r = await e.requireImpl().getTransactionData(t, n);
200
199
  if (n?.decode === !1 || !se()) return r;
201
- let i = typeof r == "string", { bytes: a } = await f({ bytes: i ? new TextEncoder().encode(r) : r }, { transactionId: t });
200
+ let i = typeof r == "string", { bytes: a } = await m({ bytes: i ? new TextEncoder().encode(r) : r }, { transactionId: t });
202
201
  return i ? new TextDecoder().decode(a) : a;
203
202
  }
204
203
  static getTransactionTags(t) {
@@ -210,163 +209,172 @@ var _ = n, v = "https", y = !1, b = !1, x = class e {
210
209
  static downloadFiles(t) {
211
210
  return e.requireImpl().downloadFiles(t);
212
211
  }
213
- }, pe = 1, me = 6e4, S = pe, C = me, w = /* @__PURE__ */ new Map();
214
- function T(e) {
212
+ }, pe = 1, me = 6e4, w = pe, T = me, E = /* @__PURE__ */ new Map();
213
+ function D(e) {
215
214
  let t = e.trim();
216
215
  return t ? (t.startsWith("http://") ? t = t.slice(7) : t.startsWith("https://") && (t = t.slice(8)), t.replace(/\/$/, "").toLowerCase()) : "";
217
216
  }
218
- function E(e) {
219
- let t = w.get(e);
217
+ function he(e) {
218
+ let t = E.get(e);
220
219
  return t || (t = {
221
220
  failures: 0,
222
221
  openedAt: null,
223
222
  halfOpenProbeInFlight: !1
224
- }, w.set(e, t)), t;
223
+ }, E.set(e, t)), t;
225
224
  }
226
- function D(e, t) {
227
- return e.openedAt == null ? "closed" : t - e.openedAt >= C ? "half-open" : "open";
225
+ function O(e, t) {
226
+ return e.openedAt == null ? "closed" : t - e.openedAt >= T ? "half-open" : "open";
228
227
  }
229
- function he(e) {
230
- e.failureThreshold != null && e.failureThreshold >= 1 && (S = e.failureThreshold), e.openDurationMs != null && e.openDurationMs >= 0 && (C = e.openDurationMs);
228
+ function ge(e) {
229
+ e.failureThreshold != null && e.failureThreshold >= 1 && (w = e.failureThreshold), e.openDurationMs != null && e.openDurationMs >= 0 && (T = e.openDurationMs);
231
230
  }
232
- function ge() {
233
- w.clear(), S = pe, C = me;
231
+ function _e() {
232
+ E.clear(), w = pe, T = me;
234
233
  }
235
- function O(e, t = Date.now()) {
236
- let n = T(e);
234
+ function k(e, t = Date.now()) {
235
+ let n = D(e);
237
236
  if (!n) return !1;
238
- let r = w.get(n);
237
+ let r = E.get(n);
239
238
  if (!r) return !1;
240
- let i = D(r, t);
239
+ let i = O(r, t);
241
240
  return !!(i === "open" || i === "half-open" && r.halfOpenProbeInFlight);
242
241
  }
243
- function _e(e, t = Date.now()) {
244
- let n = T(e);
242
+ function ve(e, t = Date.now()) {
243
+ let n = D(e);
245
244
  if (!n) return "closed";
246
- let r = w.get(n);
247
- return r ? D(r, t) : "closed";
245
+ let r = E.get(n);
246
+ return r ? O(r, t) : "closed";
248
247
  }
249
- function ve(e, t = Date.now()) {
250
- let n = T(e);
248
+ function A(e, t = Date.now()) {
249
+ let n = D(e);
251
250
  if (!n) return;
252
- let r = E(n);
253
- D(r, t) === "half-open" && (r.halfOpenProbeInFlight = !0);
251
+ let r = he(n);
252
+ O(r, t) === "half-open" && (r.halfOpenProbeInFlight = !0);
253
+ }
254
+ function j(e) {
255
+ let t = D(e), n = t ? E.get(t) : void 0;
256
+ n && (n.halfOpenProbeInFlight = !1);
254
257
  }
255
- function k(e) {
256
- let t = T(e);
257
- t && w.set(t, {
258
+ function M(e) {
259
+ let t = D(e);
260
+ t && E.set(t, {
258
261
  failures: 0,
259
262
  openedAt: null,
260
263
  halfOpenProbeInFlight: !1
261
264
  });
262
265
  }
263
- function A(e, t = Date.now()) {
264
- let n = T(e);
266
+ function N(e, t = Date.now()) {
267
+ let n = D(e);
265
268
  if (!n) return;
266
- let r = E(n);
267
- r.failures += 1, r.halfOpenProbeInFlight = !1, r.failures >= S && (r.openedAt = t);
269
+ let r = he(n);
270
+ r.failures += 1, r.halfOpenProbeInFlight = !1, r.failures >= w && (r.openedAt = t);
268
271
  }
269
272
  function ye(e = Date.now()) {
270
273
  let t = [];
271
- for (let n of w.keys()) O(n, e) && t.push(n);
274
+ for (let n of E.keys()) k(n, e) && t.push(n);
272
275
  return t;
273
276
  }
274
277
  //#endregion
275
278
  //#region src/ArweaveClient/selectReadGateway.ts
276
- var be = 18e4, xe = 6e4, Se = 5e3, j = null, M = null, N = null;
277
- function P() {
278
- j = null, M = null;
279
+ var P = 18e4, be = 6e4, xe = 5e3, F = null, I = null, L = null;
280
+ function R() {
281
+ F = null, I = null;
282
+ }
283
+ function Se() {
284
+ R(), L = null, _e(), C.resetReadGatewaySelectionStateForTests(), C.isReadGatewayLocked() || C.setPreferredReadGateway(n);
279
285
  }
280
286
  function Ce() {
281
- P(), N = null, ge(), x.resetReadGatewaySelectionStateForTests(), x.isReadGatewayLocked() || x.setPreferredReadGateway(n);
287
+ return C.isReadGatewayLocked() ? !0 : F && Date.now() < F.expiresAt ? F.healthy : L != null;
282
288
  }
283
289
  function we() {
284
- return x.isReadGatewayLocked() ? !0 : j && Date.now() < j.expiresAt ? j.healthy : N != null;
290
+ return L;
285
291
  }
286
- function Te() {
287
- return N;
288
- }
289
- async function F(e, t) {
290
- let n = `${e.replace(/\/$/, "")}/info`, r = e;
292
+ async function z(e, { signal: t, timeoutMs: n = xe, recordCircuit: r = !0 } = {}) {
293
+ let i = `${e.replace(/\/$/, "")}/info`, a = e;
291
294
  try {
292
- r = new URL(e.includes("://") ? e : `https://${e}`).host;
295
+ a = new URL(e.includes("://") ? e : `https://${e}`).host;
293
296
  } catch {
294
- r = e.replace(/^https?:\/\//, "").replace(/\/$/, "");
297
+ a = e.replace(/^https?:\/\//, "").replace(/\/$/, "");
298
+ }
299
+ if (r) {
300
+ if (k(a)) return !1;
301
+ A(a);
295
302
  }
296
- if (O(r)) return !1;
297
- ve(r);
298
- let i, a = new AbortController(), o = t ?? a.signal;
299
- t || (i = setTimeout(() => a.abort(), Se));
303
+ let o = (e) => (r && (e ? M(a) : N(a)), e), s = () => (r && j(a), !1);
304
+ if (t?.aborted) return s();
305
+ let c = new AbortController(), l = setTimeout(() => c.abort(), n), u = () => c.abort(t?.reason);
306
+ t?.addEventListener("abort", u, { once: !0 });
300
307
  try {
301
- let e = await fetch(n, {
308
+ let e = await fetch(i, {
302
309
  method: "GET",
303
- signal: o,
310
+ signal: c.signal,
304
311
  headers: { Accept: "application/json" }
305
312
  });
306
- if (!e.ok) return A(r), !1;
313
+ if (!e.ok) return o(!1);
307
314
  let t = await e.text();
308
- if (!t.trim()) return A(r), !1;
315
+ if (!t.trim()) return o(!1);
309
316
  try {
310
- let e = JSON.parse(t), n = typeof e == "object" && !!e;
311
- return n ? k(r) : A(r), n;
317
+ let e = JSON.parse(t);
318
+ return o(typeof e == "object" && !!e);
312
319
  } catch {
313
- return A(r), !1;
320
+ return o(!1);
314
321
  }
315
322
  } catch {
316
- return A(r), !1;
323
+ return t?.aborted ? s() : o(!1);
317
324
  } finally {
318
- i && clearTimeout(i);
325
+ clearTimeout(l), t?.removeEventListener("abort", u);
319
326
  }
320
327
  }
321
- async function I(e, t = "https", n) {
328
+ async function B(e, t = "https", n) {
322
329
  for (let r of e) {
323
330
  let e = r.trim().replace(/\/$/, "");
324
- if (e && !O(e) && await F(`${t}://${e}`, n)) return e;
331
+ if (e && !k(e) && await z(`${t}://${e}`, { signal: n })) return e;
325
332
  }
326
333
  return null;
327
334
  }
328
- function Ee() {
329
- return u(x.getHost());
330
- }
331
- async function L(e) {
332
- if (x.isReadGatewayLocked()) return x.getHost();
333
- if (j && Date.now() < j.expiresAt) return j.host;
334
- if (M) return M;
335
- M = (async () => {
336
- let t = await I(Ee(), x.getProtocol(), e);
337
- if (x.isReadGatewayLocked()) j = {
338
- host: x.getHost(),
335
+ function Te() {
336
+ return f(C.getHost());
337
+ }
338
+ async function V(e) {
339
+ if (C.isReadGatewayLocked()) return C.getHost();
340
+ if (F && Date.now() < F.expiresAt) return F.host;
341
+ if (I) return I;
342
+ I = (async () => {
343
+ let t = await B(Te(), C.getProtocol(), e);
344
+ if (!t && e?.aborted) return L ?? C.getHost();
345
+ if (C.isReadGatewayLocked()) F = {
346
+ host: C.getHost(),
339
347
  healthy: !0,
340
- expiresAt: Date.now() + be
348
+ expiresAt: Date.now() + P
341
349
  };
342
- else if (t) x.applyProbedReadGateway(t), N = t, j = {
350
+ else if (t) C.applyProbedReadGateway(t), L = t, F = {
343
351
  host: t,
344
352
  healthy: !0,
345
- expiresAt: Date.now() + be
353
+ expiresAt: Date.now() + P
346
354
  };
347
355
  else {
348
- let e = N ?? x.getHost();
349
- N && x.getHost() !== N && x.applyProbedReadGateway(N), j = {
356
+ let e = L ?? C.getHost();
357
+ L && C.getHost() !== L && C.applyProbedReadGateway(L), F = {
350
358
  host: e,
351
359
  healthy: !1,
352
- expiresAt: Date.now() + xe
360
+ expiresAt: Date.now() + be
353
361
  };
354
362
  }
355
- return j.host;
363
+ return F.host;
356
364
  })();
357
365
  try {
358
- return await M;
366
+ return await I;
359
367
  } finally {
360
- M = null;
368
+ I = null;
361
369
  }
362
370
  }
363
371
  //#endregion
364
372
  //#region src/gateway/resolveSeedGatewayEndpoints.ts
365
- var R = 18e4, z = null, B = /* @__PURE__ */ new Map();
366
- function V() {
367
- z = null, B.clear();
373
+ var Ee = 18e4, De = 6e4, H = null, U = /* @__PURE__ */ new Map();
374
+ function Oe() {
375
+ H = null, U.clear();
368
376
  }
369
- function H(e) {
377
+ function ke(e) {
370
378
  let t = e?.trim() || "arweave.net";
371
379
  return t.startsWith("http://") ? {
372
380
  protocol: "http",
@@ -379,8 +387,8 @@ function H(e) {
379
387
  host: t.replace(/\/$/, "")
380
388
  };
381
389
  }
382
- function U(e) {
383
- let { host: t, protocol: n } = H(e.arweaveDomain);
390
+ function Ae(e) {
391
+ let { host: t, protocol: n } = ke(e.arweaveDomain);
384
392
  return `${n}://${t}`;
385
393
  }
386
394
  function W(e) {
@@ -391,7 +399,7 @@ function W(e) {
391
399
  baseUrl: `http://${t}:${n}`
392
400
  };
393
401
  }
394
- function De() {
402
+ function je() {
395
403
  try {
396
404
  let e = globalThis.window?.location?.origin;
397
405
  return typeof e == "string" && e.length > 0 ? e.replace(/\/$/, "") : void 0;
@@ -404,32 +412,25 @@ function G(e, t) {
404
412
  if (!n) throw Error("proxyBaseUrl is empty");
405
413
  if (n.startsWith("http://") || n.startsWith("https://")) return n.replace(/\/$/, "");
406
414
  if (n.startsWith("/")) {
407
- let r = (t?.origin?.trim() || De() || "").replace(/\/$/, "");
415
+ let r = (t?.origin?.trim() || je() || "").replace(/\/$/, "");
408
416
  if (!r) throw Error(`Relative proxyBaseUrl "${e}" requires a browser origin or resolve options.origin`);
409
417
  return `${r}${n.replace(/\/$/, "")}`;
410
418
  }
411
419
  return `https://${n.replace(/\/$/, "")}`;
412
420
  }
413
421
  async function K(e, t, n) {
414
- let r = Date.now();
415
- if (t === "sidecar") {
416
- if (z && r < z.expiresAt) return z.healthy;
417
- let t = await F(e, n);
418
- return z = {
419
- healthy: t,
420
- expiresAt: r + R
421
- }, t;
422
- }
423
- let i = B.get(t);
422
+ let r = Date.now(), i = t === "sidecar" ? H : U.get(t);
424
423
  if (i && r < i.expiresAt) return i.healthy;
425
- let a = await F(e, n);
426
- return B.set(t, {
424
+ let a = await z(e, { signal: n });
425
+ if (!a && n?.aborted) return !1;
426
+ let o = {
427
427
  healthy: a,
428
- expiresAt: r + R
429
- }), a;
428
+ expiresAt: r + (a ? Ee : De)
429
+ };
430
+ return t === "sidecar" ? H = o : U.set(t, o), a;
430
431
  }
431
- function Oe(e) {
432
- let { host: t, protocol: n } = H(e.arweaveDomain), r = `${n}://${t}`, i = e.uploadApiBaseUrl?.trim() ?? "";
432
+ function Me(e) {
433
+ let { host: t, protocol: n } = ke(e.arweaveDomain), r = `${n}://${t}`, i = e.uploadApiBaseUrl?.trim() ?? "";
433
434
  return {
434
435
  mode: e.transport ?? "http-gateway",
435
436
  arweaveHost: t,
@@ -442,7 +443,7 @@ function Oe(e) {
442
443
  publicArweaveBaseUrl: r
443
444
  };
444
445
  }
445
- function ke(e) {
446
+ function Ne(e) {
446
447
  let t = W(e), n = e.hyper?.gatewayHyperKey?.trim();
447
448
  return {
448
449
  mode: "hyper",
@@ -453,10 +454,10 @@ function ke(e) {
453
454
  uploadApiBaseUrl: t.baseUrl,
454
455
  activePath: "hyper-sidecar",
455
456
  gatewayHyperKey: n || void 0,
456
- publicArweaveBaseUrl: U(e)
457
+ publicArweaveBaseUrl: Ae(e)
457
458
  };
458
459
  }
459
- function Ae(e, t) {
460
+ function Pe(e, t) {
460
461
  let n = new URL(t), r = n.protocol === "http:" ? "http" : "https", i = n.pathname.replace(/\/$/, ""), a = i ? `${n.host}${i}` : n.host, o = `${r}://${a}`;
461
462
  return {
462
463
  mode: e.transport ?? "http-gateway",
@@ -468,72 +469,84 @@ function Ae(e, t) {
468
469
  activePath: "http-proxy",
469
470
  gatewayHyperKey: e.hyper?.gatewayHyperKey?.trim() || void 0,
470
471
  proxyBaseUrl: t,
471
- publicArweaveBaseUrl: U(e)
472
+ publicArweaveBaseUrl: Ae(e)
472
473
  };
473
474
  }
474
- function je(e) {
475
+ function Fe(e) {
475
476
  return (e.hyper?.probeProxy ?? e.hyper?.probeSidecar) !== !1;
476
477
  }
477
- var Me = /^(localhost|127(?:\.\d{1,3}){3}|\[::1\]|::1)$|\.localhost$/i;
478
- function Ne(e, t) {
478
+ var Ie = /^(localhost|127(?:\.\d{1,3}){3}|\[::1\]|::1)$|\.localhost$/i;
479
+ function Le(e, t) {
479
480
  if (e.hyper?.probeSidecarFromBrowser) return !0;
480
481
  let n = globalThis.window;
481
482
  if (!n) return !0;
482
483
  let r = t ?? n.location?.origin;
483
484
  if (!r) return !0;
484
485
  try {
485
- return Me.test(new URL(r).hostname);
486
+ return Ie.test(new URL(r).hostname);
486
487
  } catch {
487
488
  return !1;
488
489
  }
489
490
  }
490
- async function Pe(e, t) {
491
+ async function Re(e, t) {
491
492
  let n = e.proxyBaseUrl?.trim();
492
493
  if (!n) return null;
493
494
  let r = G(n, { origin: t?.origin });
494
- return je(e) && !await K(r, `proxy:${r}`, t?.signal) ? null : Ae(e, r);
495
+ return Fe(e) && !await K(r, `proxy:${r}`, t?.signal) ? null : Pe(e, r);
496
+ }
497
+ async function ze(e, t) {
498
+ if (t?.forceSidecarProbe && Oe(), t?.timeoutMs === void 0) return Be(e, t);
499
+ let n = new AbortController(), r = setTimeout(() => n.abort(), t.timeoutMs), i = t.signal, a = () => n.abort(i?.reason);
500
+ i?.aborted ? a() : i?.addEventListener("abort", a, { once: !0 });
501
+ try {
502
+ return await Be(e, {
503
+ ...t,
504
+ signal: n.signal
505
+ });
506
+ } finally {
507
+ clearTimeout(r), i?.removeEventListener("abort", a);
508
+ }
495
509
  }
496
- async function Fe(e, t) {
497
- t?.forceSidecarProbe && V();
510
+ async function Be(e, t) {
498
511
  let n = e.transport ?? "http-gateway", r = e.hyper?.probeSidecar !== !1;
499
512
  if (n === "http-gateway") {
500
513
  if (e.proxyBaseUrl?.trim()) {
501
514
  let r = G(e.proxyBaseUrl, { origin: t?.origin });
502
- if (je(e) && !await K(r, `proxy:${r}`, t?.signal)) throw Error(`Gateway HTTP proxy not reachable at ${r}. Ensure your Node route runs createGatewayProxy (or equivalent) and mounts at proxyBaseUrl.`);
503
- return Ae({
515
+ if (Fe(e) && !await K(r, `proxy:${r}`, t?.signal)) throw Error(`Gateway HTTP proxy not reachable at ${r}. Ensure your Node route runs createGatewayProxy (or equivalent) and mounts at proxyBaseUrl.`);
516
+ return Pe({
504
517
  ...e,
505
518
  transport: n
506
519
  }, r);
507
520
  }
508
- return Oe({
521
+ return Me({
509
522
  ...e,
510
523
  transport: n
511
524
  });
512
525
  }
513
526
  if (n === "hyper") {
514
- let i = await Pe({
527
+ let i = await Re({
515
528
  ...e,
516
529
  transport: n
517
530
  }, t);
518
531
  if (i) return i;
519
- let a = ke({
532
+ let a = Ne({
520
533
  ...e,
521
534
  transport: n
522
535
  });
523
536
  if (r && !await K(a.arweaveBaseUrl, "sidecar", t?.signal)) throw Error(`Gateway Hyper sidecar not reachable at ${a.arweaveBaseUrl}. Run: seed-gateway connect <operator-z32-key> — or configure gateway.proxyBaseUrl for an app-server proxy.`);
524
537
  return a;
525
538
  }
526
- let i = await Pe({
539
+ let i = await Re({
527
540
  ...e,
528
541
  transport: n
529
542
  }, t);
530
543
  if (i) return i;
531
544
  let a = W(e);
532
- return r && Ne(e, t?.origin) && await K(a.baseUrl, "sidecar", t?.signal) ? ke({
545
+ return r && Le(e, t?.origin) && await K(a.baseUrl, "sidecar", t?.signal) ? Ne({
533
546
  ...e,
534
547
  transport: "hyper"
535
548
  }) : {
536
- ...Oe({
549
+ ...Me({
537
550
  ...e,
538
551
  transport: "http-gateway"
539
552
  }),
@@ -541,27 +554,27 @@ async function Fe(e, t) {
541
554
  activePath: "hybrid-fallback-http"
542
555
  };
543
556
  }
544
- function Ie(e, t) {
557
+ function Ve(e, t) {
545
558
  if (e.activePath === "hyper-sidecar" || e.activePath === "http-proxy") {
546
- let t = new URL(e.publicArweaveBaseUrl), n = u(t.host).map((e, n) => n === 0 ? `${t.protocol}//${e}` : `https://${e}`);
559
+ let t = new URL(e.publicArweaveBaseUrl), n = f(t.host).map((e, n) => n === 0 ? `${t.protocol}//${e}` : `https://${e}`);
547
560
  return [e.arweaveBaseUrl, ...n];
548
561
  }
549
- return u(e.arweaveHost);
562
+ return f(e.arweaveHost);
550
563
  }
551
564
  //#endregion
552
565
  //#region src/gateway/gatewayState.ts
553
- var Le = null;
566
+ var He = null;
554
567
  function q() {
555
- return Le;
568
+ return He;
556
569
  }
557
- function Re(e) {
558
- Le = e;
570
+ function Ue(e) {
571
+ He = e;
559
572
  }
560
- var ze = [];
573
+ var We = [];
561
574
  function J() {
562
- return ze;
575
+ return We;
563
576
  }
564
- function Be(e) {
577
+ function Ge(e) {
565
578
  let t = [], n = /* @__PURE__ */ new Set();
566
579
  for (let r of e) {
567
580
  let e = r?.trim();
@@ -575,34 +588,34 @@ function Be(e) {
575
588
  }
576
589
  n.has(i) || (n.add(i), t.push(i));
577
590
  }
578
- ze = t;
591
+ We = t;
579
592
  }
580
593
  //#endregion
581
594
  //#region src/gateway/readBaseUrls.ts
582
- var Ve = 1e4;
595
+ var Ke = 1e4;
583
596
  function Y(e, t, n) {
584
597
  let r = n.trim().replace(/\/$/, "");
585
598
  r && !t.has(r) && (t.add(r), e.push(r));
586
599
  }
587
600
  function X(e) {
588
- let t = q(), n = x.getProtocol(), r = t ? Ie(t) : e?.fallbackHosts?.length ? [...e.fallbackHosts] : u(x.getHost()), i = [], a = /* @__PURE__ */ new Set();
601
+ let t = q(), n = C.getProtocol(), r = t ? Ve(t) : e?.fallbackHosts?.length ? [...e.fallbackHosts] : f(C.getHost()), i = [], a = /* @__PURE__ */ new Set();
589
602
  for (let e of r) {
590
603
  let t = e.trim();
591
604
  t && Y(i, a, /^https?:\/\//i.test(t) ? t : `${n}://${t}`);
592
605
  }
593
606
  return i;
594
607
  }
595
- function He(e) {
608
+ function qe(e) {
596
609
  let t = [], n = /* @__PURE__ */ new Set();
597
610
  for (let e of J()) Y(t, n, e);
598
611
  for (let r of X(e)) Y(t, n, r);
599
612
  return t;
600
613
  }
601
- async function Ue() {
614
+ async function Je() {
602
615
  try {
603
616
  let e = q();
604
617
  if (e && (e.activePath === "hyper-sidecar" || e.activePath === "http-proxy")) return;
605
- await L();
618
+ await V();
606
619
  } catch {}
607
620
  }
608
621
  async function Z(e, t, n) {
@@ -620,23 +633,23 @@ async function Z(e, t, n) {
620
633
  clearTimeout(i);
621
634
  }
622
635
  }
623
- async function We(e, t) {
636
+ async function Ye(e, t) {
624
637
  let n = /* @__PURE__ */ new Set(), r = async (r) => {
625
638
  for (let i of r) {
626
639
  if (n.has(i)) continue;
627
640
  n.add(i);
628
641
  let r = await Z(i, e, t);
629
642
  if (r) try {
630
- let { bytes: t } = await ce(r, { transactionId: e }), n = new TextDecoder().decode(t);
643
+ let { bytes: t } = await le(r, { transactionId: e }), n = new TextDecoder().decode(t);
631
644
  if (n.length > 0) return n;
632
645
  } catch {}
633
646
  }
634
647
  };
635
- return await r(J()) || (await Ue(), r(X(t)));
648
+ return await r(J()) || (await Je(), r(X(t)));
636
649
  }
637
650
  //#endregion
638
651
  //#region src/graphql/gql/gql.ts
639
- var Ge = {
652
+ var Xe = {
640
653
  "\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n": {
641
654
  kind: "Document",
642
655
  definitions: [{
@@ -990,13 +1003,13 @@ var Ge = {
990
1003
  }]
991
1004
  }
992
1005
  };
993
- function Ke(e) {
994
- return Ge[e] ?? {};
1006
+ function Ze(e) {
1007
+ return Xe[e] ?? {};
995
1008
  }
996
1009
  //#endregion
997
1010
  //#region src/ArweaveClient/queries.ts
998
- var qe = Ke("\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n"), Je = Ke("\n query GetArweaveTransactions(\n $owners: [String!]\n $first: Int\n $after: String\n ) {\n transactions(owners: $owners, first: $first, after: $after) {\n edges {\n cursor\n node {\n id\n anchor\n signature\n block {\n id\n height\n }\n data {\n size\n type\n }\n tags {\n name\n value\n }\n }\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n"), Ye = 1e4, Xe = 2e4, Ze = 1e3, Qe = (e) => e >= 500 || e === 429;
999
- async function $e(e, t, n) {
1011
+ var Qe = Ze("\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n"), $e = Ze("\n query GetArweaveTransactions(\n $owners: [String!]\n $first: Int\n $after: String\n ) {\n transactions(owners: $owners, first: $first, after: $after) {\n edges {\n cursor\n node {\n id\n anchor\n signature\n block {\n id\n height\n }\n data {\n size\n type\n }\n tags {\n name\n value\n }\n }\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n"), et = 1e4, tt = 2e4, nt = 1e3, rt = (e) => e >= 500 || e === 429;
1012
+ async function it(e, t, n) {
1000
1013
  let r = new AbortController(), i = setTimeout(() => r.abort(), n);
1001
1014
  try {
1002
1015
  let n = await fetch(`${e.replace(/\/$/, "")}/${encodeURIComponent(t)}`, {
@@ -1004,7 +1017,7 @@ async function $e(e, t, n) {
1004
1017
  credentials: "omit",
1005
1018
  signal: r.signal
1006
1019
  });
1007
- return await n.body?.cancel().catch(() => {}), Qe(n.status) ? {
1020
+ return await n.body?.cancel().catch(() => {}), rt(n.status) ? {
1008
1021
  kind: "retry",
1009
1022
  status: n.status
1010
1023
  } : {
@@ -1020,23 +1033,23 @@ async function $e(e, t, n) {
1020
1033
  clearTimeout(i);
1021
1034
  }
1022
1035
  }
1023
- function et() {
1024
- let e = He(), t = q();
1036
+ function at() {
1037
+ let e = qe(), t = q();
1025
1038
  if (t?.activePath !== "hyper-sidecar" && t?.activePath !== "http-proxy") return e;
1026
1039
  let n = /* @__PURE__ */ new Set([...J(), t.arweaveBaseUrl.replace(/\/$/, "")]);
1027
1040
  return e.filter((e) => n.has(e));
1028
1041
  }
1029
- async function tt(e, t = {}) {
1030
- let n = t.timeoutMs ?? 1e4, r = performance.now() + (t.totalTimeoutMs ?? 2e4), i = t.baseUrls ?? et(), a = i.filter((e) => !O(e)), o = a.length > 0 ? a : i, s = 500;
1042
+ async function ot(e, t = {}) {
1043
+ let n = t.timeoutMs ?? 1e4, r = performance.now() + (t.totalTimeoutMs ?? 2e4), i = t.baseUrls ?? at(), a = i.filter((e) => !k(e)), o = a.length > 0 ? a : i, s = 500;
1031
1044
  for (let [t, i] of o.entries()) {
1032
1045
  let a = r - performance.now();
1033
1046
  if (a <= 0 || t > 0 && a < Math.min(n, 1e3)) break;
1034
- let o = await $e(i, e, Math.min(n, a));
1035
- if (o.kind === "answer") return k(i), {
1047
+ let o = await it(i, e, Math.min(n, a));
1048
+ if (o.kind === "answer") return M(i), {
1036
1049
  status: o.status >= 200 && o.status < 300 ? 200 : o.status,
1037
1050
  confirmed: null
1038
1051
  };
1039
- A(i), s = o.status;
1052
+ N(i), s = o.status;
1040
1053
  }
1041
1054
  return {
1042
1055
  status: s,
@@ -1045,8 +1058,8 @@ async function tt(e, t = {}) {
1045
1058
  }
1046
1059
  //#endregion
1047
1060
  //#region src/default/ArweaveClient.ts
1048
- var Q = t("seedArweave:ArweaveClient"), nt = 3e4;
1049
- function rt(e) {
1061
+ var Q = t("seedArweave:ArweaveClient"), st = 3e4;
1062
+ function ct(e) {
1050
1063
  return (t, n) => {
1051
1064
  if (typeof AbortController > "u") return fetch(t, n);
1052
1065
  let r = new AbortController(), i = n?.signal ?? void 0, a = setTimeout(() => r.abort(/* @__PURE__ */ Error(`Arweave GraphQL request timed out after ${e} ms`)), e), o = () => r.abort(i?.reason);
@@ -1058,17 +1071,17 @@ function rt(e) {
1058
1071
  });
1059
1072
  };
1060
1073
  }
1061
- var $ = null, it = null, at = async () => {
1062
- let e = `${x.getProtocol()}://${x.getHost()}`;
1063
- if ($ && it === e) return $;
1074
+ var $ = null, lt = null, ut = async () => {
1075
+ let e = `${C.getProtocol()}://${C.getHost()}`;
1076
+ if ($ && lt === e) return $;
1064
1077
  let t = await import("arweave"), n = t.default ?? t;
1065
- return typeof n.init != "function" && typeof n.default?.init == "function" && (n = n.default), it = e, $ = n.init(x.getArweaveJsApiConfig()), $;
1066
- }, ot = class {
1078
+ return typeof n.init != "function" && typeof n.default?.init == "function" && (n = n.default), lt = e, $ = n.init(C.getArweaveJsApiConfig()), $;
1079
+ }, dt = class {
1067
1080
  getArweaveClient() {
1068
- return new e(x.getEndpoint(), { fetch: rt(nt) });
1081
+ return new e(C.getEndpoint(), { fetch: ct(st) });
1069
1082
  }
1070
1083
  async getTransactionStatus(e) {
1071
- return tt(e);
1084
+ return ot(e);
1072
1085
  }
1073
1086
  async getTransactionData(e, t) {
1074
1087
  let n = t?.decode === !1 ? [] : J();
@@ -1080,12 +1093,12 @@ var $ = null, it = null, at = async () => {
1080
1093
  Q("Error reading preferred gateway response:", e);
1081
1094
  }
1082
1095
  }
1083
- if (x.getGatewayPath()) {
1084
- let n = await fetch(x.getRawUrl(e));
1096
+ if (C.getGatewayPath()) {
1097
+ let n = await fetch(C.getRawUrl(e));
1085
1098
  if (!n.ok) throw Error(`Failed to fetch transaction data: HTTP ${n.status}`);
1086
1099
  return t?.string ? n.text() : new Uint8Array(await n.arrayBuffer());
1087
1100
  }
1088
- let r = await at();
1101
+ let r = await ut();
1089
1102
  try {
1090
1103
  let n = await r.transactions.getData(e, {
1091
1104
  decode: t?.decode ?? !0,
@@ -1099,7 +1112,7 @@ var $ = null, it = null, at = async () => {
1099
1112
  async getTransactionTags(e) {
1100
1113
  let t = this.getArweaveClient();
1101
1114
  try {
1102
- let n = await t.request(qe, { transactionId: e });
1115
+ let n = await t.request(Qe, { transactionId: e });
1103
1116
  return n.tags?.tags ? n.tags.tags.map((e) => ({
1104
1117
  name: e.name,
1105
1118
  value: e.value
@@ -1109,12 +1122,12 @@ var $ = null, it = null, at = async () => {
1109
1122
  }
1110
1123
  }
1111
1124
  async createTransaction(e, t) {
1112
- let n = await (await at()).createTransaction({ data: e });
1125
+ let n = await (await ut()).createTransaction({ data: e });
1113
1126
  if (t?.tags) for (let e of t.tags) n.addTag(e.name, e.value);
1114
1127
  return n;
1115
1128
  }
1116
1129
  async downloadFiles(e) {
1117
- let { transactionIds: t, excludedTransactions: n } = e, r = [], i = x.getBaseUrl();
1130
+ let { transactionIds: t, excludedTransactions: n } = e, r = [], i = C.getBaseUrl();
1118
1131
  for (let e of t) if (!n?.has(e)) try {
1119
1132
  let t = `${i}/raw/${e}`, n = await fetch(t);
1120
1133
  if (!n.ok) {
@@ -1143,6 +1156,6 @@ var $ = null, it = null, at = async () => {
1143
1156
  }
1144
1157
  };
1145
1158
  //#endregion
1146
- export { r as $, he as A, de as B, Te as C, Ce as D, F as E, A as F, oe as G, p as H, k as I, c as J, f as K, ge as L, O as M, ye as N, I as O, T as P, o as Q, x as R, L as S, we as T, se as U, fe as V, ce as W, n as X, s as Y, a as Z, Re as _, tt as a, ne as at, G as b, Ve as c, We as d, i as et, He as f, Be as g, q as h, Ze as i, ie as it, _e as j, ve as k, Ue as l, J as m, Ye as n, re as nt, Je as o, X as p, l as q, Xe as r, ae as rt, qe as s, ot as t, u as tt, Z as u, Ie as v, P as w, Fe as x, V as y, h as z };
1159
+ export { n as $, B as A, _e as B, W as C, Ce as D, R as E, k as F, ce as G, _ as H, ye as I, oe as J, se as K, D as L, j as M, ge as N, z as O, ve as P, s as Q, N as R, ze as S, we as T, de as U, C as V, fe as W, te as X, m as Y, c as Z, Ge as _, nt as a, f as at, Oe as b, Qe as c, ie as ct, Z as d, a as et, Ye as f, q as g, J as h, tt as i, u as it, A as j, Se as k, Ke as l, d as lt, X as m, dt as n, r as nt, ot as o, re as ot, qe as p, le as q, et as r, i as rt, $e as s, ae as st, st as t, o as tt, Je as u, Ue as v, V as w, G as x, Ve as y, M as z };
1147
1160
 
1148
- //# sourceMappingURL=ArweaveClient-CFAd2I4l.js.map
1161
+ //# sourceMappingURL=ArweaveClient-DENyqpd_.js.map