@seedprotocol/arweave 0.7.12-next.1434.gd03298c → 0.7.12-next.1475.gf78a8a4

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