@seedprotocol/arweave 0.7.6-next.949.g73caafc → 0.7.6

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.
@@ -1,581 +0,0 @@
1
- import "graphql-request";
2
- //#region src/constants.ts
3
- var e = "ar.seedprotocol.io", t = "", n = "", r = "127.0.0.1", i = 1984, a = `https://${e}/graphql`, o = [
4
- "ar.seedprotocol.io",
5
- "arweave.net",
6
- "arweave.dev",
7
- "g8way.io",
8
- "permagate.io",
9
- "zigza.xyz"
10
- ], s = ["ARWEAVE_READ_GATEWAYS", "NEXT_PUBLIC_ARWEAVE_READ_GATEWAYS"], c = [
11
- "NEXT_PUBLIC_ARWEAVE_HOST",
12
- "ARWEAVE_HOST",
13
- "VITE_ARWEAVE_HOST"
14
- ];
15
- function l(e) {
16
- let t = e.trim();
17
- return t.startsWith("http://") ? t.slice(7).replace(/\/$/, "") : t.startsWith("https://") ? t.slice(8).replace(/\/$/, "") : t.replace(/\/$/, "");
18
- }
19
- function u() {
20
- if (typeof process < "u" && process.env) for (let e of c) {
21
- let t = process.env[e]?.trim();
22
- if (t) return l(t);
23
- }
24
- }
25
- function d(t, n) {
26
- let r = t.trim().toLowerCase().replace(/\/$/, ""), i = e.toLowerCase();
27
- return r === i ? [...n] : n.filter((e) => e.toLowerCase() !== i);
28
- }
29
- function f(e) {
30
- return m(e, d(e, p()));
31
- }
32
- function p() {
33
- if (typeof process > "u" || !process.env) return [...o];
34
- for (let e of s) {
35
- let t = process.env[e]?.trim();
36
- if (t) return t.split(",").map((e) => e.trim()).filter(Boolean);
37
- }
38
- return [...o];
39
- }
40
- function m(e, t) {
41
- let n = /* @__PURE__ */ new Set(), r = [], i = (e) => e.trim().toLowerCase().replace(/\/$/, ""), a = (e) => {
42
- let t = e.trim().replace(/\/$/, "");
43
- if (!t) return;
44
- let a = i(t);
45
- n.has(a) || (n.add(a), r.push(t));
46
- };
47
- a(e);
48
- for (let e of t) a(e);
49
- return r;
50
- }
51
- function h(e) {
52
- let t = e.trim().toLowerCase();
53
- if (!t) return !1;
54
- if (t.endsWith("arweave.net") || t.endsWith("ar-io.net")) return !0;
55
- for (let e of o) {
56
- let n = e.toLowerCase();
57
- if (t === n || t.endsWith(`.${n}`)) return !0;
58
- }
59
- return !1;
60
- }
61
- //#endregion
62
- //#region src/content/arweaveContent.ts
63
- var g;
64
- function _(e) {
65
- g = e;
66
- }
67
- function v() {
68
- return g !== void 0;
69
- }
70
- async function y(e, t) {
71
- return g ? g(e, t) : e;
72
- }
73
- function b(e) {
74
- return (e.headers?.get("content-type"))?.split(";")[0]?.trim().toLowerCase() || void 0;
75
- }
76
- async function x(e, t) {
77
- return y({
78
- bytes: new Uint8Array(await e.arrayBuffer()),
79
- contentType: b(e)
80
- }, t);
81
- }
82
- //#endregion
83
- //#region src/moduleOwner.ts
84
- var S = Symbol.for("@seedprotocol/arweave:clientOwner"), C = Object.freeze({ package: "@seedprotocol/arweave" });
85
- function w() {
86
- globalThis[S] = C;
87
- }
88
- var T = class extends Error {
89
- constructor() {
90
- 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";
91
- }
92
- };
93
- function E() {
94
- let e = globalThis[S];
95
- if (e !== void 0 && e !== C) throw new T();
96
- }
97
- function D() {
98
- delete globalThis[S];
99
- }
100
- //#endregion
101
- //#region src/ArweaveClient/BaseArweaveClient.ts
102
- function O(e) {
103
- let t = e.trim();
104
- return t.startsWith("http://") ? {
105
- protocol: "http",
106
- host: t.slice(7).replace(/\/$/, "")
107
- } : t.startsWith("https://") ? {
108
- protocol: "https",
109
- host: t.slice(8).replace(/\/$/, "")
110
- } : {
111
- protocol: "https",
112
- host: t.replace(/\/$/, "")
113
- };
114
- }
115
- var k = e, A = "https", j = !1, M = !1, N = class e {
116
- static _impl = null;
117
- static configure(t) {
118
- if (!t) throw Error("Cannot configure ArweaveClient with undefined or null. Ensure the platform-specific ArweaveClient is properly created.");
119
- e._impl = t, w();
120
- }
121
- static isConfigured() {
122
- return e._impl != null;
123
- }
124
- static requireImpl() {
125
- if (!e._impl) throw Error("ArweaveClient not configured. Import from @seedprotocol/arweave/node to register the Node.js implementation, or ensure SDK platform init has run.");
126
- return e._impl;
127
- }
128
- static resolveGateway() {
129
- let e = u();
130
- return e && !j && !M ? O(e) : {
131
- protocol: A,
132
- host: k
133
- };
134
- }
135
- static getHost() {
136
- return this.resolveGateway().host;
137
- }
138
- static getArweaveSdkHost() {
139
- let e = this.getHost(), t = e.indexOf("/");
140
- return t === -1 ? e : e.slice(0, t);
141
- }
142
- static getArweaveJsApiConfig() {
143
- let e = this.getProtocol(), t = e === "https" ? 443 : 80;
144
- try {
145
- let n = new URL(`${e}://${this.getArweaveSdkHost()}`);
146
- return {
147
- host: n.hostname,
148
- port: n.port ? Number(n.port) : t,
149
- protocol: e
150
- };
151
- } catch {
152
- return {
153
- host: this.getArweaveSdkHost(),
154
- port: t,
155
- protocol: e
156
- };
157
- }
158
- }
159
- static getGatewayPath() {
160
- let e = this.getHost(), t = e.indexOf("/");
161
- return t === -1 ? "" : e.slice(t).replace(/\/$/, "") || "";
162
- }
163
- static getProtocol() {
164
- return this.resolveGateway().protocol;
165
- }
166
- static getBaseUrl() {
167
- let { protocol: e, host: t } = this.resolveGateway();
168
- return `${e}://${t}`;
169
- }
170
- static setHost(e) {
171
- let t = O(e);
172
- k = t.host, A = t.protocol, j = !0, M = !1;
173
- }
174
- static isReadGatewayLocked() {
175
- return j;
176
- }
177
- static resetReadGatewaySelectionStateForTests() {
178
- M = !1;
179
- }
180
- static setPreferredReadGateway(e) {
181
- let t = O(e);
182
- k = t.host, A = t.protocol, j = !1;
183
- }
184
- static applyProbedReadGateway(e) {
185
- let t = O(e);
186
- k = t.host, A = t.protocol, j = !1, M = !0;
187
- }
188
- static getEndpoint() {
189
- return `${this.getBaseUrl()}/graphql`;
190
- }
191
- static getRawUrl(e) {
192
- return `${this.getBaseUrl()}/raw/${e}`;
193
- }
194
- static getStatusUrl(e) {
195
- return `${this.getBaseUrl()}/${e}`;
196
- }
197
- static getArweaveClient() {
198
- return e.requireImpl().getArweaveClient();
199
- }
200
- static getTransactionStatus(t) {
201
- return e.requireImpl().getTransactionStatus(t);
202
- }
203
- static async getTransactionData(t, n) {
204
- let r = await e.requireImpl().getTransactionData(t, n);
205
- if (n?.decode === !1 || !v()) return r;
206
- let i = typeof r == "string", { bytes: a } = await y({ bytes: i ? new TextEncoder().encode(r) : r }, { transactionId: t });
207
- return i ? new TextDecoder().decode(a) : a;
208
- }
209
- static getTransactionTags(t) {
210
- return e.requireImpl().getTransactionTags(t);
211
- }
212
- static createTransaction(t, n) {
213
- return e.requireImpl().createTransaction(t, n);
214
- }
215
- static downloadFiles(t) {
216
- return e.requireImpl().downloadFiles(t);
217
- }
218
- }, P = {
219
- "\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n": {
220
- kind: "Document",
221
- definitions: [{
222
- kind: "OperationDefinition",
223
- operation: "query",
224
- name: {
225
- kind: "Name",
226
- value: "GetTransactionTags"
227
- },
228
- variableDefinitions: [{
229
- kind: "VariableDefinition",
230
- variable: {
231
- kind: "Variable",
232
- name: {
233
- kind: "Name",
234
- value: "transactionId"
235
- }
236
- },
237
- type: {
238
- kind: "NonNullType",
239
- type: {
240
- kind: "NamedType",
241
- name: {
242
- kind: "Name",
243
- value: "ID"
244
- }
245
- }
246
- }
247
- }],
248
- selectionSet: {
249
- kind: "SelectionSet",
250
- selections: [{
251
- kind: "Field",
252
- alias: {
253
- kind: "Name",
254
- value: "tags"
255
- },
256
- name: {
257
- kind: "Name",
258
- value: "transaction"
259
- },
260
- arguments: [{
261
- kind: "Argument",
262
- name: {
263
- kind: "Name",
264
- value: "id"
265
- },
266
- value: {
267
- kind: "Variable",
268
- name: {
269
- kind: "Name",
270
- value: "transactionId"
271
- }
272
- }
273
- }],
274
- selectionSet: {
275
- kind: "SelectionSet",
276
- selections: [{
277
- kind: "Field",
278
- name: {
279
- kind: "Name",
280
- value: "id"
281
- }
282
- }, {
283
- kind: "Field",
284
- name: {
285
- kind: "Name",
286
- value: "tags"
287
- },
288
- selectionSet: {
289
- kind: "SelectionSet",
290
- selections: [{
291
- kind: "Field",
292
- name: {
293
- kind: "Name",
294
- value: "name"
295
- }
296
- }, {
297
- kind: "Field",
298
- name: {
299
- kind: "Name",
300
- value: "value"
301
- }
302
- }]
303
- }
304
- }]
305
- }
306
- }]
307
- }
308
- }]
309
- },
310
- "\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": {
311
- kind: "Document",
312
- definitions: [{
313
- kind: "OperationDefinition",
314
- operation: "query",
315
- name: {
316
- kind: "Name",
317
- value: "GetArweaveTransactions"
318
- },
319
- variableDefinitions: [
320
- {
321
- kind: "VariableDefinition",
322
- variable: {
323
- kind: "Variable",
324
- name: {
325
- kind: "Name",
326
- value: "owners"
327
- }
328
- },
329
- type: {
330
- kind: "ListType",
331
- type: {
332
- kind: "NonNullType",
333
- type: {
334
- kind: "NamedType",
335
- name: {
336
- kind: "Name",
337
- value: "String"
338
- }
339
- }
340
- }
341
- }
342
- },
343
- {
344
- kind: "VariableDefinition",
345
- variable: {
346
- kind: "Variable",
347
- name: {
348
- kind: "Name",
349
- value: "first"
350
- }
351
- },
352
- type: {
353
- kind: "NamedType",
354
- name: {
355
- kind: "Name",
356
- value: "Int"
357
- }
358
- }
359
- },
360
- {
361
- kind: "VariableDefinition",
362
- variable: {
363
- kind: "Variable",
364
- name: {
365
- kind: "Name",
366
- value: "after"
367
- }
368
- },
369
- type: {
370
- kind: "NamedType",
371
- name: {
372
- kind: "Name",
373
- value: "String"
374
- }
375
- }
376
- }
377
- ],
378
- selectionSet: {
379
- kind: "SelectionSet",
380
- selections: [{
381
- kind: "Field",
382
- name: {
383
- kind: "Name",
384
- value: "transactions"
385
- },
386
- arguments: [
387
- {
388
- kind: "Argument",
389
- name: {
390
- kind: "Name",
391
- value: "owners"
392
- },
393
- value: {
394
- kind: "Variable",
395
- name: {
396
- kind: "Name",
397
- value: "owners"
398
- }
399
- }
400
- },
401
- {
402
- kind: "Argument",
403
- name: {
404
- kind: "Name",
405
- value: "first"
406
- },
407
- value: {
408
- kind: "Variable",
409
- name: {
410
- kind: "Name",
411
- value: "first"
412
- }
413
- }
414
- },
415
- {
416
- kind: "Argument",
417
- name: {
418
- kind: "Name",
419
- value: "after"
420
- },
421
- value: {
422
- kind: "Variable",
423
- name: {
424
- kind: "Name",
425
- value: "after"
426
- }
427
- }
428
- }
429
- ],
430
- selectionSet: {
431
- kind: "SelectionSet",
432
- selections: [{
433
- kind: "Field",
434
- name: {
435
- kind: "Name",
436
- value: "edges"
437
- },
438
- selectionSet: {
439
- kind: "SelectionSet",
440
- selections: [{
441
- kind: "Field",
442
- name: {
443
- kind: "Name",
444
- value: "cursor"
445
- }
446
- }, {
447
- kind: "Field",
448
- name: {
449
- kind: "Name",
450
- value: "node"
451
- },
452
- selectionSet: {
453
- kind: "SelectionSet",
454
- selections: [
455
- {
456
- kind: "Field",
457
- name: {
458
- kind: "Name",
459
- value: "id"
460
- }
461
- },
462
- {
463
- kind: "Field",
464
- name: {
465
- kind: "Name",
466
- value: "anchor"
467
- }
468
- },
469
- {
470
- kind: "Field",
471
- name: {
472
- kind: "Name",
473
- value: "signature"
474
- }
475
- },
476
- {
477
- kind: "Field",
478
- name: {
479
- kind: "Name",
480
- value: "block"
481
- },
482
- selectionSet: {
483
- kind: "SelectionSet",
484
- selections: [{
485
- kind: "Field",
486
- name: {
487
- kind: "Name",
488
- value: "id"
489
- }
490
- }, {
491
- kind: "Field",
492
- name: {
493
- kind: "Name",
494
- value: "height"
495
- }
496
- }]
497
- }
498
- },
499
- {
500
- kind: "Field",
501
- name: {
502
- kind: "Name",
503
- value: "data"
504
- },
505
- selectionSet: {
506
- kind: "SelectionSet",
507
- selections: [{
508
- kind: "Field",
509
- name: {
510
- kind: "Name",
511
- value: "size"
512
- }
513
- }, {
514
- kind: "Field",
515
- name: {
516
- kind: "Name",
517
- value: "type"
518
- }
519
- }]
520
- }
521
- },
522
- {
523
- kind: "Field",
524
- name: {
525
- kind: "Name",
526
- value: "tags"
527
- },
528
- selectionSet: {
529
- kind: "SelectionSet",
530
- selections: [{
531
- kind: "Field",
532
- name: {
533
- kind: "Name",
534
- value: "name"
535
- }
536
- }, {
537
- kind: "Field",
538
- name: {
539
- kind: "Name",
540
- value: "value"
541
- }
542
- }]
543
- }
544
- }
545
- ]
546
- }
547
- }]
548
- }
549
- }, {
550
- kind: "Field",
551
- name: {
552
- kind: "Name",
553
- value: "pageInfo"
554
- },
555
- selectionSet: {
556
- kind: "SelectionSet",
557
- selections: [{
558
- kind: "Field",
559
- name: {
560
- kind: "Name",
561
- value: "hasNextPage"
562
- }
563
- }]
564
- }
565
- }]
566
- }
567
- }]
568
- }
569
- }]
570
- }
571
- };
572
- function F(e) {
573
- return P[e] ?? {};
574
- }
575
- //#endregion
576
- //#region src/ArweaveClient/queries.ts
577
- var I = F("\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n"), L = F("\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");
578
- //#endregion
579
- export { m as C, h as S, i as _, E as a, f as b, v as c, y as d, c as f, r as g, e as h, T as i, x as l, a as m, I as n, D as o, o as p, N as r, b as s, L as t, _ as u, t as v, u as w, p as x, n as y };
580
-
581
- //# sourceMappingURL=queries-t-LwBKFl.js.map