@seedprotocol/feed 0.7.11 → 0.7.12-next.1410.gda14c61
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/README.md +3 -3
- package/dist/getFeedItems.d.ts.map +1 -1
- package/dist/index.js +261 -253
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseArweaveClient as
|
|
3
|
-
import { getEasChainDeployment as
|
|
4
|
-
import
|
|
1
|
+
import { getFieldStorageModels as e, getListElementStorageModels as t, getQueryCacheManager as n, initializeQueryPlatform as r, isArweaveTransactionGatewayUrl as i, isRichBodyStorageSchema as a, queryBySchema as o, queryBySchemaForMonth as s, richBodyModelPriority as c, teardownQueryPlatform as l } from "@seedprotocol/query";
|
|
2
|
+
import { BaseArweaveClient as u, DEFAULT_ARWEAVE_HOST as d, SEED_RSS_IMAGE_RELATION_FIELD_KEYS as f, buildArweaveTransactionLink as p, classifyMediaRef as m, ensureArweaveReadGatewayForFallback as h, getArweaveReadBaseUrls as g, getArweaveReadGatewayHostsForPrimary as _, getFeedItemStringField as ee, getPublicArweaveBaseUrl as te, getPublicArweaveRawUrl as ne, isEasAttestationExplorerUrl as re, isGatewayHostCircuitOpen as ie, normalizeFeedItemFields as ae, parseArweaveTransactionLink as oe, publishedArweaveLinksInHtml as se, recordGatewayHostFailure as ce, recordGatewayHostSuccess as le, resolveArweaveHostFromEnv as ue, resolveSeedRssImageRelationFromItem as de, resolveSeedRssImageRelationRef as fe, resolveSeedRssImageRelationRef as pe } from "@seedprotocol/arweave";
|
|
3
|
+
import { getEasChainDeployment as me, getEasReadChainId as he } from "@seedprotocol/eas";
|
|
4
|
+
import ge from "rss-parser";
|
|
5
5
|
import v from "pluralize";
|
|
6
|
-
import { generateAtomFeed as
|
|
7
|
-
import { create as
|
|
6
|
+
import { generateAtomFeed as _e, generateJsonFeed as ve } from "feedsmith";
|
|
7
|
+
import { create as ye } from "xmlbuilder2";
|
|
8
8
|
import { promises as y } from "fs";
|
|
9
9
|
import { join as b } from "path";
|
|
10
|
-
import { createHash as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
10
|
+
import { createHash as be } from "crypto";
|
|
11
|
+
import xe from "image-size";
|
|
12
|
+
import Se from "debug";
|
|
13
13
|
//#region src/bootstrap.ts
|
|
14
14
|
async function x(e) {
|
|
15
|
-
await
|
|
15
|
+
await r(e);
|
|
16
16
|
}
|
|
17
|
-
async function
|
|
18
|
-
await
|
|
17
|
+
async function Ce() {
|
|
18
|
+
await l();
|
|
19
19
|
}
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/config.ts
|
|
@@ -52,18 +52,18 @@ function T(e, t = w) {
|
|
|
52
52
|
name: e.author.name ?? n.author?.name ?? ""
|
|
53
53
|
}), n;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function we() {
|
|
56
56
|
return C(w);
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
return w = T(e, S),
|
|
58
|
+
function Te(e) {
|
|
59
|
+
return w = T(e, S), we();
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function Ee() {
|
|
62
62
|
w = C(S);
|
|
63
63
|
}
|
|
64
64
|
function E() {
|
|
65
65
|
return {
|
|
66
|
-
itemUrlBase: process.env.FEED_ITEM_URL_BASE?.trim() ||
|
|
66
|
+
itemUrlBase: process.env.FEED_ITEM_URL_BASE?.trim() || me(he())?.explorerUrl || "https://easscan.org",
|
|
67
67
|
itemUrlPath: process.env.FEED_ITEM_URL_PATH?.trim() || "attestation/view",
|
|
68
68
|
pageSize: Math.max(1, parseInt(process.env.FEED_PAGE_SIZE || "25", 10) || 25),
|
|
69
69
|
richTextDataUriImages: process.env.FEED_INCLUDE_DATA_URI_HTML_ITEMS?.toLowerCase() === "true" ? "include_items" : "omit_items"
|
|
@@ -71,7 +71,7 @@ function E() {
|
|
|
71
71
|
}
|
|
72
72
|
//#endregion
|
|
73
73
|
//#region src/getFeedItems.ts
|
|
74
|
-
var
|
|
74
|
+
var D = (e) => {
|
|
75
75
|
let t = /* @__PURE__ */ new Date(e * 1e3), n = [
|
|
76
76
|
"Sun",
|
|
77
77
|
"Mon",
|
|
@@ -95,108 +95,116 @@ var Ce = (e) => {
|
|
|
95
95
|
"Dec"
|
|
96
96
|
], i = n[t.getUTCDay()], a = r[t.getUTCMonth()], o = t.getUTCFullYear();
|
|
97
97
|
return `${i}, ${t.getUTCDate().toString().padStart(2, "0")} ${a} ${o} ${t.getUTCHours().toString().padStart(2, "0")}:${t.getUTCMinutes().toString().padStart(2, "0")}:${t.getUTCSeconds().toString().padStart(2, "0")} GMT`;
|
|
98
|
-
},
|
|
99
|
-
let { itemUrlBase:
|
|
100
|
-
!
|
|
101
|
-
let
|
|
102
|
-
if (
|
|
103
|
-
|
|
98
|
+
}, De = (e, t, n, r) => {
|
|
99
|
+
let { itemUrlBase: i, itemUrlPath: a } = r;
|
|
100
|
+
!e.title && !e.Title ? (e.title = t, e.Title = t) : e.title && !e.Title ? e.Title = e.title : e.Title && !e.title && (e.title = e.Title);
|
|
101
|
+
let o = e.storage_transaction_id && typeof e.storage_transaction_id == "string" && e.storage_transaction_id.trim() !== "" && e.storage_transaction_id !== "undefined" && e.storage_transaction_id !== t ? e.storage_transaction_id.trim() : null, s = e.storageTransactionId && typeof e.storageTransactionId == "string" && e.storageTransactionId.trim() !== "" && e.storageTransactionId !== "undefined" && e.storageTransactionId !== t ? e.storageTransactionId.trim() : null, c = o || s, l = t && typeof t == "string" && t.trim() !== "" ? t : "unknown", u = `${i.replace(/\/$/, "")}/${a.replace(/^\//, "")}/${l}`;
|
|
102
|
+
if (c && c !== t && c.length > 0) try {
|
|
103
|
+
u = ne(c);
|
|
104
104
|
} catch (e) {
|
|
105
105
|
console.error("[feed] [setFeedItemDefaults] Error generating Arweave URL:", e);
|
|
106
106
|
}
|
|
107
|
-
let
|
|
108
|
-
!
|
|
109
|
-
let
|
|
110
|
-
if (!
|
|
111
|
-
let
|
|
112
|
-
|
|
113
|
-
} else
|
|
114
|
-
!
|
|
115
|
-
},
|
|
116
|
-
if (!
|
|
117
|
-
let
|
|
118
|
-
|
|
119
|
-
} else
|
|
120
|
-
!
|
|
121
|
-
let
|
|
122
|
-
if (delete
|
|
123
|
-
let
|
|
124
|
-
|
|
107
|
+
let d = e.link || e.Link;
|
|
108
|
+
!d || d === "undefined" || typeof d == "string" && d.trim() === "" ? (e.link = u, e.Link = u) : ((!e.link || e.link === "undefined") && (e.link = d), (!e.Link || e.Link === "undefined") && (e.Link = d));
|
|
109
|
+
let f = e.guid || e.Guid;
|
|
110
|
+
if (!f || f === "undefined" || typeof f == "string" && f.trim() === "" ? (e.guid = e.link || u, e.Guid = e.guid) : ((!e.guid || e.guid === "undefined") && (e.guid = f), (!e.Guid || e.Guid === "undefined") && (e.Guid = f)), e.timeCreated && !e.pubDate && !e.PubDate) {
|
|
111
|
+
let t = D(e.timeCreated);
|
|
112
|
+
e.pubDate = t, e.PubDate = t;
|
|
113
|
+
} else e.pubDate && !e.PubDate ? e.PubDate = e.pubDate : e.PubDate && !e.pubDate && (e.pubDate = e.PubDate);
|
|
114
|
+
!e.seedUid && !e.SeedUid ? (e.seedUid = t, e.SeedUid = t) : e.seedUid && !e.SeedUid ? e.SeedUid = e.seedUid : e.SeedUid && !e.seedUid && (e.seedUid = e.SeedUid), e.attester && !e.Attester ? e.Attester = e.attester : e.Attester && !e.attester && (e.attester = e.Attester);
|
|
115
|
+
}, Oe = (e, t) => {
|
|
116
|
+
if (!e.title && !e.Title ? (e.title = t, e.Title = t) : e.title && !e.Title ? e.Title = e.title : e.Title && !e.title && (e.title = e.Title), e.timeCreated && !e.pubDate && !e.PubDate) {
|
|
117
|
+
let t = D(e.timeCreated);
|
|
118
|
+
e.pubDate = t, e.PubDate = t;
|
|
119
|
+
} else e.pubDate && !e.PubDate ? e.PubDate = e.pubDate : e.PubDate && !e.pubDate && (e.pubDate = e.PubDate);
|
|
120
|
+
!e.seedUid && !e.SeedUid ? (e.seedUid = t, e.SeedUid = t) : e.seedUid && !e.SeedUid ? e.SeedUid = e.seedUid : e.SeedUid && !e.seedUid && (e.seedUid = e.SeedUid), e.attester && !e.Attester ? e.Attester = e.attester : e.Attester && !e.attester && (e.attester = e.Attester);
|
|
121
|
+
let n = e.storage_transaction_id && typeof e.storage_transaction_id == "string" && e.storage_transaction_id.trim() !== "" && e.storage_transaction_id !== "undefined" && e.storage_transaction_id !== t ? e.storage_transaction_id.trim() : null, r = e.storageTransactionId && typeof e.storageTransactionId == "string" && e.storageTransactionId.trim() !== "" && e.storageTransactionId !== "undefined" && e.storageTransactionId !== t ? e.storageTransactionId.trim() : null, i = n || r;
|
|
122
|
+
if (delete e.link, delete e.Link, delete e.guid, delete e.Guid, i && i.length > 0) try {
|
|
123
|
+
let t = ne(i);
|
|
124
|
+
e.link = t, e.Link = t;
|
|
125
125
|
} catch {}
|
|
126
126
|
};
|
|
127
|
-
function
|
|
127
|
+
function O(e) {
|
|
128
128
|
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
129
129
|
let t = e;
|
|
130
130
|
return typeof t.seedUid == "string" || typeof t.SeedUid == "string";
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function ke(e, t, n) {
|
|
133
133
|
let r = { ...e }, i = r.seedUid || r.SeedUid || "", a = typeof r.schemaName == "string" ? r.schemaName : t;
|
|
134
|
-
return a === "image" ?
|
|
134
|
+
return a === "image" ? Oe(r, i) : De(r, i, a, n), r;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function Ae(e, t, n) {
|
|
137
137
|
let r = { ...e };
|
|
138
|
-
|
|
138
|
+
De(r, r.seedUid || r.SeedUid || "", t, n);
|
|
139
139
|
for (let e of Object.keys(r)) {
|
|
140
140
|
if (e.startsWith("_")) continue;
|
|
141
141
|
let i = r[e];
|
|
142
|
-
Array.isArray(i) ? i.some(
|
|
142
|
+
Array.isArray(i) ? i.some(O) && (r[e] = i.map((e) => O(e) ? ke(e, t, n) : e)) : O(i) && (r[e] = ke(i, t, n));
|
|
143
143
|
}
|
|
144
144
|
return r;
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function je(e, t) {
|
|
147
147
|
let n = E(), r = {
|
|
148
148
|
itemUrlBase: n.itemUrlBase,
|
|
149
149
|
itemUrlPath: n.itemUrlPath
|
|
150
|
-
};
|
|
151
|
-
return t.map((t) =>
|
|
150
|
+
}, i = te();
|
|
151
|
+
return t.map((t) => k(Ae(t.data, e, r), i));
|
|
152
|
+
}
|
|
153
|
+
function k(e, t) {
|
|
154
|
+
if (typeof e == "string") {
|
|
155
|
+
if (e.includes("<")) return se(e, { publicBaseUrl: t });
|
|
156
|
+
let n = oe(e);
|
|
157
|
+
return n ? p(n, t) : e;
|
|
158
|
+
}
|
|
159
|
+
return Array.isArray(e) ? e.map((e) => k(e, t)) : e && typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype ? Object.fromEntries(Object.entries(e).map(([e, n]) => [e, k(n, t)])) : e;
|
|
152
160
|
}
|
|
153
|
-
var
|
|
161
|
+
var A = async (e, t) => {
|
|
154
162
|
await x();
|
|
155
|
-
let n = t?.limit ?? 100, r = t?.skip ?? 0, { items: i, etag: a } = await
|
|
163
|
+
let n = t?.limit ?? 100, r = t?.skip ?? 0, { items: i, etag: a } = await o(e, {
|
|
156
164
|
limit: n,
|
|
157
165
|
skip: r,
|
|
158
166
|
relations: "expand",
|
|
159
167
|
hydrateStorage: !0
|
|
160
168
|
});
|
|
161
169
|
return {
|
|
162
|
-
items:
|
|
170
|
+
items: je(e, i),
|
|
163
171
|
etag: a
|
|
164
172
|
};
|
|
165
|
-
},
|
|
173
|
+
}, Me = async (e, t) => (await A(e, t)).items, Ne = async (e, t, n) => (await x(), je(e, await s(e, t, n, {
|
|
166
174
|
relations: "expand",
|
|
167
175
|
hydrateStorage: !0
|
|
168
176
|
})));
|
|
169
177
|
//#endregion
|
|
170
178
|
//#region src/consume/parseRss.ts
|
|
171
|
-
function
|
|
179
|
+
function Pe(e) {
|
|
172
180
|
try {
|
|
173
181
|
return JSON.parse(JSON.stringify(e));
|
|
174
182
|
} catch {
|
|
175
183
|
return { ...e };
|
|
176
184
|
}
|
|
177
185
|
}
|
|
178
|
-
var
|
|
186
|
+
var Fe = new ge({ customFields: { item: [
|
|
179
187
|
"featureImage",
|
|
180
188
|
"feature_image",
|
|
181
189
|
"content:encoded",
|
|
182
190
|
"seedUid",
|
|
183
191
|
"SeedUid"
|
|
184
192
|
] } });
|
|
185
|
-
async function
|
|
186
|
-
let t = await
|
|
193
|
+
async function Ie(e) {
|
|
194
|
+
let t = await Fe.parseString(e);
|
|
187
195
|
return {
|
|
188
196
|
title: t.title,
|
|
189
197
|
link: t.link,
|
|
190
198
|
description: t.description,
|
|
191
|
-
items: (t.items ?? []).map(
|
|
199
|
+
items: (t.items ?? []).map(Pe)
|
|
192
200
|
};
|
|
193
201
|
}
|
|
194
202
|
//#endregion
|
|
195
203
|
//#region src/rss/generateRssXml.ts
|
|
196
|
-
var
|
|
204
|
+
var j = "http://purl.org/dc/elements/1.1/", M = "http://purl.org/rss/1.0/modules/content/", N = "http://search.yahoo.com/mrss/", Le = { publication: {
|
|
197
205
|
prefix: "publication",
|
|
198
206
|
uri: "https://seedprotocol.io/ns/publication/1.0"
|
|
199
|
-
} },
|
|
207
|
+
} }, Re = "https://seedprotocol.io/ns/relations", ze = /* @__PURE__ */ new Set([
|
|
200
208
|
"xml",
|
|
201
209
|
"xmlns",
|
|
202
210
|
"dc",
|
|
@@ -204,15 +212,15 @@ var A = "http://purl.org/dc/elements/1.1/", j = "http://purl.org/rss/1.0/modules
|
|
|
204
212
|
"content",
|
|
205
213
|
"atom",
|
|
206
214
|
"fh"
|
|
207
|
-
]),
|
|
215
|
+
]), Be = /* @__PURE__ */ new Set([
|
|
208
216
|
"Title",
|
|
209
217
|
"Link",
|
|
210
218
|
"Guid",
|
|
211
219
|
"PubDate",
|
|
212
220
|
"SeedUid"
|
|
213
221
|
]);
|
|
214
|
-
function
|
|
215
|
-
return
|
|
222
|
+
function Ve(e, t) {
|
|
223
|
+
return Be.has(e) ? e.charAt(0).toLowerCase() + e.slice(1) in t : !1;
|
|
216
224
|
}
|
|
217
225
|
var P = [
|
|
218
226
|
"title",
|
|
@@ -246,13 +254,13 @@ function F(e) {
|
|
|
246
254
|
}
|
|
247
255
|
return String(e);
|
|
248
256
|
}
|
|
249
|
-
function
|
|
257
|
+
function He(e) {
|
|
250
258
|
return /[<>&]|]]>/.test(e);
|
|
251
259
|
}
|
|
252
260
|
function I(e, t) {
|
|
253
261
|
let n = String(t);
|
|
254
262
|
if (n !== "") {
|
|
255
|
-
if (
|
|
263
|
+
if (He(n)) {
|
|
256
264
|
if (n.includes("]]>")) {
|
|
257
265
|
let t = n.split("]]>");
|
|
258
266
|
for (let n = 0; n < t.length; n++) e.dat(t[n]), n < t.length - 1 && e.txt("]]>");
|
|
@@ -263,7 +271,7 @@ function I(e, t) {
|
|
|
263
271
|
function L(e) {
|
|
264
272
|
return typeof e == "object" && !!e && !Array.isArray(e) && !(e instanceof Date);
|
|
265
273
|
}
|
|
266
|
-
var
|
|
274
|
+
var Ue = 4, We = /* @__PURE__ */ new Set([
|
|
267
275
|
...P,
|
|
268
276
|
"guid",
|
|
269
277
|
"source",
|
|
@@ -272,34 +280,34 @@ var Re = 4, ze = /* @__PURE__ */ new Set([
|
|
|
272
280
|
"content:encoded",
|
|
273
281
|
"items"
|
|
274
282
|
]);
|
|
275
|
-
function
|
|
283
|
+
function Ge(e) {
|
|
276
284
|
return e.endsWith("s") && e.length > 1 ? e.slice(0, -1) : e;
|
|
277
285
|
}
|
|
278
|
-
function
|
|
286
|
+
function Ke(e) {
|
|
279
287
|
return e.trim().replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^[^A-Za-z_]+/, "").replace(/^$/, "rel").toLowerCase();
|
|
280
288
|
}
|
|
281
|
-
function
|
|
282
|
-
if (!t.has(e) && !
|
|
289
|
+
function qe(e, t) {
|
|
290
|
+
if (!t.has(e) && !ze.has(e)) return t.add(e), e;
|
|
283
291
|
let n = 2;
|
|
284
292
|
for (;;) {
|
|
285
293
|
let r = `${e}${n}`;
|
|
286
|
-
if (!t.has(r) && !
|
|
294
|
+
if (!t.has(r) && !ze.has(r)) return t.add(r), r;
|
|
287
295
|
n += 1;
|
|
288
296
|
}
|
|
289
297
|
}
|
|
290
298
|
function R(e) {
|
|
291
299
|
return Array.isArray(e) && e.length > 0 && e.every((e) => L(e));
|
|
292
300
|
}
|
|
293
|
-
function
|
|
294
|
-
let t = { ...
|
|
301
|
+
function Je(e) {
|
|
302
|
+
let t = { ...Le }, n = new Set(Object.values(t).map((e) => e.prefix)), r = /* @__PURE__ */ new Set();
|
|
295
303
|
for (let t of e) for (let [e, n] of Object.entries(t)) {
|
|
296
304
|
let t = e === "author" && L(n) || e === "authors" && R(n);
|
|
297
|
-
e.startsWith("_") || (!
|
|
305
|
+
e.startsWith("_") || (!We.has(e) || t) && (L(n) || R(n)) && r.add(Ge(e));
|
|
298
306
|
}
|
|
299
307
|
let i = [...r].sort();
|
|
300
308
|
for (let e of i) t[e] || (t[e] = {
|
|
301
|
-
prefix:
|
|
302
|
-
uri: `${
|
|
309
|
+
prefix: qe(Ke(e), n),
|
|
310
|
+
uri: `${Re}/${e}/1.0`
|
|
303
311
|
});
|
|
304
312
|
return t;
|
|
305
313
|
}
|
|
@@ -310,26 +318,26 @@ function z(e, t) {
|
|
|
310
318
|
if (n in t) return t[n];
|
|
311
319
|
}
|
|
312
320
|
}
|
|
313
|
-
function
|
|
321
|
+
function Ye(e, t) {
|
|
314
322
|
return t ? `${t.prefix}:${e}` : e;
|
|
315
323
|
}
|
|
316
324
|
function B(e, t, n, r, i = 0, a) {
|
|
317
325
|
let o = e.ele(n);
|
|
318
326
|
for (let [e, n] of Object.entries(t)) {
|
|
319
327
|
if (n == null || e.startsWith("_") || e === "items") continue;
|
|
320
|
-
let t =
|
|
321
|
-
if (i >=
|
|
328
|
+
let t = Ye(e, a);
|
|
329
|
+
if (i >= Ue) I(o.ele(t), typeof n == "object" ? JSON.stringify(n) : String(n));
|
|
322
330
|
else if (Array.isArray(n)) {
|
|
323
|
-
let t =
|
|
331
|
+
let t = Ye(e.endsWith("s") && e.length > 1 ? e.slice(0, -1) : e, a);
|
|
324
332
|
for (let e of n) e != null && (L(e) ? B(o, e, t, !1, i + 1, a) : I(o.ele(t), String(e)));
|
|
325
333
|
} else L(n) ? B(o, n, t, !1, i + 1, a) : I(o.ele(t), String(n));
|
|
326
334
|
}
|
|
327
335
|
if (r) {
|
|
328
336
|
let n = t.name ?? t.seedUid;
|
|
329
|
-
n && e.ele(
|
|
337
|
+
n && e.ele(j, "creator").txt(String(n));
|
|
330
338
|
}
|
|
331
339
|
}
|
|
332
|
-
function
|
|
340
|
+
function Xe(e, t, n, r, i) {
|
|
333
341
|
if (!(n == null || t.startsWith("_")) && t !== "items") {
|
|
334
342
|
if (t === "guid") {
|
|
335
343
|
let t = n, r = t?.value ?? String(n);
|
|
@@ -354,28 +362,28 @@ function Ge(e, t, n, r, i) {
|
|
|
354
362
|
for (let [n, r] of Object.entries(t)) if (r != null) {
|
|
355
363
|
if (Array.isArray(r)) {
|
|
356
364
|
for (let t of r) if (t != null) {
|
|
357
|
-
let r = e.ele(
|
|
365
|
+
let r = e.ele(j, n);
|
|
358
366
|
t instanceof Date ? r.txt(t.toISOString()) : I(r, String(t));
|
|
359
367
|
}
|
|
360
368
|
} else {
|
|
361
|
-
let t = e.ele(
|
|
369
|
+
let t = e.ele(j, n);
|
|
362
370
|
r instanceof Date ? t.txt(r.toISOString()) : I(t, String(r));
|
|
363
371
|
}
|
|
364
372
|
}
|
|
365
|
-
} else if (t === "content:encoded") I(e.ele(
|
|
366
|
-
else if (t === "content" && typeof n == "string" && !("content:encoded" in r)) I(e.ele(
|
|
373
|
+
} else if (t === "content:encoded") I(e.ele(M, "encoded"), String(n));
|
|
374
|
+
else if (t === "content" && typeof n == "string" && !("content:encoded" in r)) I(e.ele(M, "encoded"), String(n));
|
|
367
375
|
else if (t !== "content") {
|
|
368
376
|
if (t === "media:group" && Array.isArray(n)) {
|
|
369
377
|
for (let t of n) if (t && typeof t == "object") {
|
|
370
|
-
let n = e.ele(
|
|
378
|
+
let n = e.ele(N, "group");
|
|
371
379
|
for (let [e, r] of Object.entries(t)) if (r != null && e.startsWith("media:")) {
|
|
372
380
|
let t = e.slice(6);
|
|
373
381
|
if (Array.isArray(r)) {
|
|
374
382
|
for (let e of r) if (e && typeof e == "object") {
|
|
375
|
-
let r = n.ele(
|
|
383
|
+
let r = n.ele(N, t);
|
|
376
384
|
for (let [t, n] of Object.entries(e)) n != null && (t === "url" || t === "value" ? I(r, String(n)) : r.att(t, String(n)));
|
|
377
385
|
}
|
|
378
|
-
} else typeof r == "string" && I(n.ele(
|
|
386
|
+
} else typeof r == "string" && I(n.ele(N, t), r);
|
|
379
387
|
}
|
|
380
388
|
}
|
|
381
389
|
} else if (t.startsWith("media:") && Array.isArray(n)) {
|
|
@@ -384,12 +392,12 @@ function Ge(e, t, n, r, i) {
|
|
|
384
392
|
if (typeof t != "object" || !t) continue;
|
|
385
393
|
let n = {}, i = null;
|
|
386
394
|
for (let [e, r] of Object.entries(t)) r != null && (e === "value" ? i = String(r) : n[e] = String(r));
|
|
387
|
-
let a = e.ele(
|
|
395
|
+
let a = e.ele(N, r, n);
|
|
388
396
|
i !== null && I(a, i);
|
|
389
397
|
}
|
|
390
398
|
} else if (t.startsWith("media:") && typeof n == "string") {
|
|
391
399
|
let r = t.slice(6);
|
|
392
|
-
I(e.ele(
|
|
400
|
+
I(e.ele(N, r), n);
|
|
393
401
|
} else if (n instanceof Date) e.ele(t).txt(F(n));
|
|
394
402
|
else if (t === "author" && L(n)) B(e, n, "author", !0, 0, z(t, i));
|
|
395
403
|
else if (t === "authors" && Array.isArray(n)) {
|
|
@@ -416,41 +424,41 @@ function Ge(e, t, n, r, i) {
|
|
|
416
424
|
}
|
|
417
425
|
}
|
|
418
426
|
}
|
|
419
|
-
var
|
|
420
|
-
function
|
|
421
|
-
let t =
|
|
427
|
+
var Ze = "http://www.w3.org/2005/Atom", Qe = "http://purl.org/syndication/history/1.0";
|
|
428
|
+
function $e(e) {
|
|
429
|
+
let t = ye({
|
|
422
430
|
version: "1.0",
|
|
423
431
|
encoding: "UTF-8"
|
|
424
|
-
}), n =
|
|
425
|
-
"xmlns:dc":
|
|
426
|
-
"xmlns:content":
|
|
427
|
-
"xmlns:media":
|
|
428
|
-
"xmlns:atom":
|
|
432
|
+
}), n = Je(e.items), r = {
|
|
433
|
+
"xmlns:dc": j,
|
|
434
|
+
"xmlns:content": M,
|
|
435
|
+
"xmlns:media": N,
|
|
436
|
+
"xmlns:atom": Ze,
|
|
429
437
|
...Object.values(n).reduce((e, t) => (e[`xmlns:${t.prefix}`] = t.uri, e), {})
|
|
430
438
|
};
|
|
431
|
-
e.isArchive && (r["xmlns:fh"] =
|
|
439
|
+
e.isArchive && (r["xmlns:fh"] = Qe);
|
|
432
440
|
let i = t.ele("rss", {
|
|
433
441
|
version: "2.0",
|
|
434
442
|
...r
|
|
435
443
|
}).ele("channel", {
|
|
436
|
-
"xmlns:dc":
|
|
437
|
-
"xmlns:content":
|
|
438
|
-
"xmlns:media":
|
|
444
|
+
"xmlns:dc": j,
|
|
445
|
+
"xmlns:content": M,
|
|
446
|
+
"xmlns:media": N
|
|
439
447
|
});
|
|
440
448
|
if (i.ele("title").txt(e.title), e.link && i.ele("link").txt(e.link), i.ele("description").txt(e.description), e.language && i.ele("language").txt(e.language), e.copyright && i.ele("copyright").txt(e.copyright), e.webMaster && i.ele("webMaster").txt(e.webMaster), e.pubDate && i.ele("pubDate").txt(F(e.pubDate)), e.lastBuildDate && i.ele("lastBuildDate").txt(F(e.lastBuildDate)), e.links?.length) for (let t of e.links) {
|
|
441
449
|
let e = {
|
|
442
450
|
rel: t.rel,
|
|
443
451
|
href: t.href
|
|
444
452
|
};
|
|
445
|
-
t.type && (e.type = t.type), i.ele(
|
|
453
|
+
t.type && (e.type = t.type), i.ele(Ze, "link", e);
|
|
446
454
|
}
|
|
447
|
-
e.isArchive && i.ele(
|
|
455
|
+
e.isArchive && i.ele(Qe, "archive");
|
|
448
456
|
let a = new Set(P);
|
|
449
457
|
for (let t of e.items) {
|
|
450
458
|
let e = i.ele("item"), r = /* @__PURE__ */ new Set();
|
|
451
|
-
for (let i of P) i in t && (
|
|
452
|
-
let o = Object.keys(t).filter((e) => !r.has(e) && !a.has(e) && !e.startsWith("_") && !
|
|
453
|
-
for (let r of o)
|
|
459
|
+
for (let i of P) i in t && (Xe(e, i, t[i], t, n), r.add(i));
|
|
460
|
+
let o = Object.keys(t).filter((e) => !r.has(e) && !a.has(e) && !e.startsWith("_") && !Ve(e, t)).sort();
|
|
461
|
+
for (let r of o) Xe(e, r, t[r], t, n);
|
|
454
462
|
}
|
|
455
463
|
return t.end({ prettyPrint: !0 });
|
|
456
464
|
}
|
|
@@ -461,7 +469,7 @@ function V(e, t, n) {
|
|
|
461
469
|
}
|
|
462
470
|
//#endregion
|
|
463
471
|
//#region src/cache/MemoryCache.ts
|
|
464
|
-
var
|
|
472
|
+
var et = class {
|
|
465
473
|
feedContentCache = /* @__PURE__ */ new Map();
|
|
466
474
|
imageMetadataCache = /* @__PURE__ */ new Map();
|
|
467
475
|
config;
|
|
@@ -487,7 +495,7 @@ var Ye = class {
|
|
|
487
495
|
};
|
|
488
496
|
this.imageMetadataCache.set(e, r);
|
|
489
497
|
}
|
|
490
|
-
},
|
|
498
|
+
}, tt = class {
|
|
491
499
|
cacheDir;
|
|
492
500
|
config;
|
|
493
501
|
constructor(e) {
|
|
@@ -572,12 +580,12 @@ var Ye = class {
|
|
|
572
580
|
t.code !== "ENOENT" && console.error(`Error clearing image metadata cache for ${e}:`, t);
|
|
573
581
|
}
|
|
574
582
|
}
|
|
575
|
-
},
|
|
583
|
+
}, nt = class {
|
|
576
584
|
memoryCache;
|
|
577
585
|
fileCache;
|
|
578
586
|
config;
|
|
579
587
|
constructor(e) {
|
|
580
|
-
this.config = e, this.memoryCache = new
|
|
588
|
+
this.config = e, this.memoryCache = new et(e), this.fileCache = new tt(e);
|
|
581
589
|
}
|
|
582
590
|
getConfig() {
|
|
583
591
|
return this.config;
|
|
@@ -625,13 +633,13 @@ var Ye = class {
|
|
|
625
633
|
};
|
|
626
634
|
//#endregion
|
|
627
635
|
//#region src/cache/config.ts
|
|
628
|
-
function
|
|
636
|
+
function rt() {
|
|
629
637
|
let e = parseInt(process.env.CACHE_TTL || "3600", 10), t = process.env.CACHE_DIR || "./cache", n = process.env.CACHE_ENABLED === "false" || process.env.CACHE_ENABLED === "0" || process.env.CACHE_ENABLED === "no" || process.env.CACHE_ENABLED === "off", r = process.env.CACHE_ENABLED === "true" || process.env.CACHE_ENABLED === "1" || process.env.CACHE_ENABLED === "yes", i = process.env.NODE_ENV === "development", a;
|
|
630
638
|
a = n ? !1 : r ? !0 : !i, a || console.log(`⚠️ Cache is DISABLED (${n ? "CACHE_ENABLED=false" : i ? "NODE_ENV=development" : "CACHE_ENABLED=false"})`);
|
|
631
639
|
let o = {
|
|
632
640
|
enabled: process.env.IMAGE_METADATA_ENABLED !== "false",
|
|
633
641
|
ttl: parseInt(process.env.IMAGE_METADATA_TTL || "604800", 10),
|
|
634
|
-
gateways: process.env.IMAGE_METADATA_GATEWAYS ? process.env.IMAGE_METADATA_GATEWAYS.split(",").map((e) => e.trim()) : _(
|
|
642
|
+
gateways: process.env.IMAGE_METADATA_GATEWAYS ? process.env.IMAGE_METADATA_GATEWAYS.split(",").map((e) => e.trim()) : _(ue() ?? u.getHost()),
|
|
635
643
|
timeout: parseInt(process.env.IMAGE_METADATA_TIMEOUT || "5000", 10)
|
|
636
644
|
}, s = parseInt(process.env.CACHE_PAGE_TTL || "300", 10), c = parseInt(process.env.CACHE_ARCHIVE_TTL || "86400", 10);
|
|
637
645
|
return {
|
|
@@ -646,22 +654,22 @@ function Qe() {
|
|
|
646
654
|
//#endregion
|
|
647
655
|
//#region src/utils/etag.ts
|
|
648
656
|
function H(e) {
|
|
649
|
-
return `"${
|
|
657
|
+
return `"${be("md5").update(e).digest("hex").substring(0, 16)}"`;
|
|
650
658
|
}
|
|
651
|
-
function
|
|
659
|
+
function it(e, t) {
|
|
652
660
|
let n = (e) => e.replace(/^"|"$/g, "");
|
|
653
661
|
return n(e) === n(t);
|
|
654
662
|
}
|
|
655
|
-
function
|
|
663
|
+
function at(e) {
|
|
656
664
|
return e ? e.split(",").map((e) => e.trim()).filter((e) => e.length > 0) : [];
|
|
657
665
|
}
|
|
658
|
-
function
|
|
659
|
-
let n =
|
|
660
|
-
return n.length === 0 ? !1 : n.includes("*") ? !0 : n.some((e) =>
|
|
666
|
+
function ot(e, t) {
|
|
667
|
+
let n = at(e);
|
|
668
|
+
return n.length === 0 ? !1 : n.includes("*") ? !0 : n.some((e) => it(e, t));
|
|
661
669
|
}
|
|
662
670
|
//#endregion
|
|
663
671
|
//#region src/services/arweaveImageService.ts
|
|
664
|
-
var
|
|
672
|
+
var st = class {
|
|
665
673
|
config;
|
|
666
674
|
constructor(e) {
|
|
667
675
|
this.config = e;
|
|
@@ -670,7 +678,7 @@ var nt = class {
|
|
|
670
678
|
await h();
|
|
671
679
|
let t = g({ fallbackHosts: this.config.gateways });
|
|
672
680
|
for (let n of t) {
|
|
673
|
-
if (
|
|
681
|
+
if (ie(n)) continue;
|
|
674
682
|
let t = await this.probe(`${n}/${e}`, n);
|
|
675
683
|
if (t) return t;
|
|
676
684
|
}
|
|
@@ -693,7 +701,7 @@ var nt = class {
|
|
|
693
701
|
try {
|
|
694
702
|
let t = await this.fetchWithTimeout(e, { method: "HEAD" });
|
|
695
703
|
if (!t.ok) return null;
|
|
696
|
-
|
|
704
|
+
le(n);
|
|
697
705
|
let r = t.headers.get("content-type") || "", i = t.headers.get("content-length");
|
|
698
706
|
if (!this.isImageContentType(r)) return {
|
|
699
707
|
isImage: !1,
|
|
@@ -714,7 +722,7 @@ var nt = class {
|
|
|
714
722
|
format: c
|
|
715
723
|
};
|
|
716
724
|
} catch (t) {
|
|
717
|
-
return
|
|
725
|
+
return ce(n), console.warn(`Error fetching image metadata from ${e}:`, t), null;
|
|
718
726
|
}
|
|
719
727
|
}
|
|
720
728
|
async getImageMetadataFromFullRequest(e, t, n) {
|
|
@@ -746,7 +754,7 @@ var nt = class {
|
|
|
746
754
|
}
|
|
747
755
|
extractImageDimensions(e, t) {
|
|
748
756
|
try {
|
|
749
|
-
let t =
|
|
757
|
+
let t = xe(e);
|
|
750
758
|
if (t.width && t.height) return {
|
|
751
759
|
width: t.width,
|
|
752
760
|
height: t.height
|
|
@@ -768,7 +776,7 @@ var nt = class {
|
|
|
768
776
|
}
|
|
769
777
|
}
|
|
770
778
|
try {
|
|
771
|
-
let e =
|
|
779
|
+
let e = xe(t);
|
|
772
780
|
if (e.type) return e.type.toLowerCase();
|
|
773
781
|
} catch {}
|
|
774
782
|
}
|
|
@@ -784,7 +792,7 @@ var nt = class {
|
|
|
784
792
|
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? Error(`Request timeout after ${this.config.timeout}ms`) : e;
|
|
785
793
|
}
|
|
786
794
|
}
|
|
787
|
-
}, U =
|
|
795
|
+
}, U = Se("seedFeed");
|
|
788
796
|
//#endregion
|
|
789
797
|
//#region src/pickFeedItemRichText.ts
|
|
790
798
|
function W(e, t) {
|
|
@@ -794,21 +802,21 @@ function W(e, t) {
|
|
|
794
802
|
}
|
|
795
803
|
return "";
|
|
796
804
|
}
|
|
797
|
-
var
|
|
805
|
+
var ct = [
|
|
798
806
|
"summary",
|
|
799
807
|
"Summary",
|
|
800
808
|
"description",
|
|
801
809
|
"Description",
|
|
802
810
|
"text",
|
|
803
811
|
"Text"
|
|
804
|
-
],
|
|
812
|
+
], lt = [
|
|
805
813
|
"html",
|
|
806
814
|
"Html",
|
|
807
815
|
"body",
|
|
808
816
|
"Body",
|
|
809
817
|
"content",
|
|
810
818
|
"Content"
|
|
811
|
-
],
|
|
819
|
+
], ut = [
|
|
812
820
|
"summary",
|
|
813
821
|
"Summary",
|
|
814
822
|
"description",
|
|
@@ -816,118 +824,118 @@ var rt = [
|
|
|
816
824
|
"text",
|
|
817
825
|
"Text"
|
|
818
826
|
];
|
|
819
|
-
function
|
|
820
|
-
let n =
|
|
827
|
+
function dt(e, t) {
|
|
828
|
+
let n = c(e.model) - c(t.model);
|
|
821
829
|
if (n !== 0) return n;
|
|
822
830
|
let r = e.key.localeCompare(t.key);
|
|
823
831
|
return r === 0 ? e.index - t.index : r;
|
|
824
832
|
}
|
|
825
|
-
function
|
|
826
|
-
let r =
|
|
827
|
-
if (r) for (let [
|
|
828
|
-
if (!
|
|
829
|
-
let r = e
|
|
833
|
+
function ft(n) {
|
|
834
|
+
let r = e(n), i = t(n), o = null;
|
|
835
|
+
if (r) for (let [e, t] of Object.entries(r)) {
|
|
836
|
+
if (!a(t)) continue;
|
|
837
|
+
let r = n[e];
|
|
830
838
|
if (typeof r != "string" || r.trim() === "") continue;
|
|
831
839
|
let i = {
|
|
832
|
-
model:
|
|
833
|
-
key:
|
|
840
|
+
model: t,
|
|
841
|
+
key: e,
|
|
834
842
|
index: 0,
|
|
835
843
|
value: r
|
|
836
844
|
};
|
|
837
|
-
(!
|
|
845
|
+
(!o || dt(i, o) < 0) && (o = i);
|
|
838
846
|
}
|
|
839
|
-
if (i) for (let [
|
|
840
|
-
let r = e
|
|
847
|
+
if (i) for (let [e, t] of Object.entries(i)) {
|
|
848
|
+
let r = n[e];
|
|
841
849
|
if (!Array.isArray(r)) continue;
|
|
842
|
-
let i = Math.min(
|
|
843
|
-
for (let
|
|
844
|
-
let i = n
|
|
845
|
-
if (!
|
|
846
|
-
let s = r[
|
|
850
|
+
let i = Math.min(t.length, r.length);
|
|
851
|
+
for (let n = 0; n < i; n++) {
|
|
852
|
+
let i = t[n];
|
|
853
|
+
if (!a(i)) continue;
|
|
854
|
+
let s = r[n];
|
|
847
855
|
if (typeof s != "string" || s.trim() === "") continue;
|
|
848
856
|
let c = {
|
|
849
857
|
model: i,
|
|
850
|
-
key:
|
|
851
|
-
index:
|
|
858
|
+
key: e,
|
|
859
|
+
index: n,
|
|
852
860
|
value: s
|
|
853
861
|
};
|
|
854
|
-
(!
|
|
862
|
+
(!o || dt(c, o) < 0) && (o = c);
|
|
855
863
|
}
|
|
856
864
|
}
|
|
857
|
-
return
|
|
865
|
+
return o?.value ?? "";
|
|
858
866
|
}
|
|
859
|
-
function
|
|
860
|
-
return W(e,
|
|
867
|
+
function pt(e) {
|
|
868
|
+
return W(e, ct);
|
|
861
869
|
}
|
|
862
|
-
function
|
|
863
|
-
let t =
|
|
870
|
+
function mt(e) {
|
|
871
|
+
let t = ft(e);
|
|
864
872
|
if (t !== "") return t;
|
|
865
|
-
let n = W(e,
|
|
866
|
-
return n === "" ? W(e,
|
|
873
|
+
let n = W(e, lt);
|
|
874
|
+
return n === "" ? W(e, ut) : n;
|
|
867
875
|
}
|
|
868
|
-
function
|
|
876
|
+
function G(e) {
|
|
869
877
|
return typeof e == "string" && e.includes("data:image/") && e.includes(";base64,");
|
|
870
878
|
}
|
|
871
|
-
function
|
|
872
|
-
let r =
|
|
879
|
+
function ht(n) {
|
|
880
|
+
let r = e(n);
|
|
873
881
|
if (r) {
|
|
874
|
-
for (let [
|
|
882
|
+
for (let [e, t] of Object.entries(r)) if (a(t) && G(n[e])) return !0;
|
|
875
883
|
}
|
|
876
|
-
let i = n
|
|
877
|
-
if (i) for (let [
|
|
878
|
-
let r = e
|
|
884
|
+
let i = t(n);
|
|
885
|
+
if (i) for (let [e, t] of Object.entries(i)) {
|
|
886
|
+
let r = n[e];
|
|
879
887
|
if (!Array.isArray(r)) continue;
|
|
880
|
-
let i = Math.min(
|
|
881
|
-
for (let e = 0; e < i; e++) if (
|
|
888
|
+
let i = Math.min(t.length, r.length);
|
|
889
|
+
for (let e = 0; e < i; e++) if (a(t[e]) && G(r[e])) return !0;
|
|
882
890
|
}
|
|
883
891
|
return !1;
|
|
884
892
|
}
|
|
885
|
-
function
|
|
886
|
-
if (
|
|
887
|
-
for (let t of
|
|
888
|
-
for (let t of
|
|
893
|
+
function gt(e) {
|
|
894
|
+
if (ht(e)) return !0;
|
|
895
|
+
for (let t of lt) if (G(e[t])) return !0;
|
|
896
|
+
for (let t of ct) if (G(e[t])) return !0;
|
|
889
897
|
return !1;
|
|
890
898
|
}
|
|
891
|
-
function
|
|
892
|
-
return t === "include_items" ? [...e] : e.filter((e) => !
|
|
899
|
+
function _t(e, t = "omit_items") {
|
|
900
|
+
return t === "include_items" ? [...e] : e.filter((e) => !gt(e));
|
|
893
901
|
}
|
|
894
902
|
//#endregion
|
|
895
903
|
//#region src/index.ts
|
|
896
|
-
function
|
|
897
|
-
return
|
|
904
|
+
function vt(e) {
|
|
905
|
+
return pe(e)?.mediaUrl;
|
|
898
906
|
}
|
|
899
|
-
function
|
|
907
|
+
function K(e) {
|
|
900
908
|
if (typeof e == "number" && Number.isFinite(e) && e > 0) return e;
|
|
901
909
|
if (typeof e == "string") {
|
|
902
910
|
let t = Number(e);
|
|
903
911
|
if (Number.isFinite(t) && t > 0) return t;
|
|
904
912
|
}
|
|
905
913
|
}
|
|
906
|
-
function
|
|
914
|
+
function yt(e) {
|
|
907
915
|
if (Array.isArray(e)) {
|
|
908
916
|
for (let t of e) {
|
|
909
|
-
let e =
|
|
917
|
+
let e = yt(t);
|
|
910
918
|
if (e) return e;
|
|
911
919
|
}
|
|
912
920
|
return;
|
|
913
921
|
}
|
|
914
|
-
let t =
|
|
922
|
+
let t = vt(e);
|
|
915
923
|
if (t) {
|
|
916
924
|
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
917
925
|
let n = e;
|
|
918
926
|
return {
|
|
919
927
|
url: t,
|
|
920
928
|
mimeType: typeof n.mimeType == "string" && n.mimeType || typeof n.type == "string" && n.type || typeof n.contentType == "string" && n.contentType || void 0,
|
|
921
|
-
width:
|
|
922
|
-
height:
|
|
923
|
-
size:
|
|
929
|
+
width: K(n.width),
|
|
930
|
+
height: K(n.height),
|
|
931
|
+
size: K(n.size ?? n.fileSize),
|
|
924
932
|
format: typeof n.format == "string" ? n.format : void 0
|
|
925
933
|
};
|
|
926
934
|
}
|
|
927
935
|
return { url: t };
|
|
928
936
|
}
|
|
929
937
|
}
|
|
930
|
-
function
|
|
938
|
+
function q(e) {
|
|
931
939
|
if (e._hasImage && e._imageMetadata && typeof e._imageMetadata == "object") {
|
|
932
940
|
let t = e._imageMetadata;
|
|
933
941
|
if (t.url) return {
|
|
@@ -951,11 +959,11 @@ function J(e) {
|
|
|
951
959
|
"thumbnailImage"
|
|
952
960
|
]) {
|
|
953
961
|
if (!(t in e)) continue;
|
|
954
|
-
let n =
|
|
962
|
+
let n = yt(e[t]);
|
|
955
963
|
if (n) return n;
|
|
956
964
|
}
|
|
957
965
|
}
|
|
958
|
-
function
|
|
966
|
+
function bt(e, t, n, r, i, a) {
|
|
959
967
|
let o = n.mimeType || "image/jpeg";
|
|
960
968
|
e.enclosures = [{
|
|
961
969
|
url: n.url,
|
|
@@ -991,15 +999,15 @@ function mt(e, t, n, r, i, a) {
|
|
|
991
999
|
"media:description": l
|
|
992
1000
|
}], n.url && typeof t.content == "string" && t.content.trim() !== "" && !t.content.includes(n.url) && (e["content:encoded"] = `${`<img src="${n.url}" alt="${t.title || ""}"${n.width ? ` width="${n.width}"` : ""}${n.height ? ` height="${n.height}"` : ""} />`}\n${t.content}`);
|
|
993
1001
|
}
|
|
994
|
-
var
|
|
995
|
-
function
|
|
996
|
-
return
|
|
1002
|
+
var J = null;
|
|
1003
|
+
function Y() {
|
|
1004
|
+
return J ||= new nt(rt()), J;
|
|
997
1005
|
}
|
|
998
|
-
function
|
|
999
|
-
|
|
1006
|
+
function xt() {
|
|
1007
|
+
J = null;
|
|
1000
1008
|
}
|
|
1001
|
-
var
|
|
1002
|
-
async function
|
|
1009
|
+
var St = 8;
|
|
1010
|
+
async function Ct(e, t) {
|
|
1003
1011
|
let n = 0;
|
|
1004
1012
|
await Promise.all(Array.from({ length: Math.min(t, e.length) }, async () => {
|
|
1005
1013
|
for (; n < e.length;) {
|
|
@@ -1008,28 +1016,28 @@ async function _t(e, t) {
|
|
|
1008
1016
|
}
|
|
1009
1017
|
}));
|
|
1010
1018
|
}
|
|
1011
|
-
async function
|
|
1019
|
+
async function wt(e, t, n) {
|
|
1012
1020
|
let r = await n.getImageMetadata(e);
|
|
1013
1021
|
if (r) return r;
|
|
1014
1022
|
U("detecting image for transaction %s", e);
|
|
1015
1023
|
let i = await t.detectImage(e);
|
|
1016
1024
|
return i && await n.setImageMetadata(e, i), i;
|
|
1017
1025
|
}
|
|
1018
|
-
function
|
|
1019
|
-
if (
|
|
1026
|
+
function Tt(e) {
|
|
1027
|
+
if (i(e)) return new URL(e).pathname.replace(/^\//, "");
|
|
1020
1028
|
}
|
|
1021
|
-
function
|
|
1029
|
+
function Et(e, t) {
|
|
1022
1030
|
let n = e;
|
|
1023
1031
|
if (t === "image") return n.storageTransactionId || n.storage_transaction_id;
|
|
1024
|
-
let r =
|
|
1025
|
-
if (!(!r || r.width && r.height && r.mimeType)) return
|
|
1032
|
+
let r = q(n);
|
|
1033
|
+
if (!(!r || r.width && r.height && r.mimeType)) return Tt(r.url);
|
|
1026
1034
|
}
|
|
1027
|
-
async function
|
|
1028
|
-
let i = e, a =
|
|
1035
|
+
async function Dt(e, t, n, r) {
|
|
1036
|
+
let i = e, a = Et(e, t);
|
|
1029
1037
|
if (a) try {
|
|
1030
|
-
let e = await
|
|
1038
|
+
let e = await wt(a, n, r);
|
|
1031
1039
|
if (!e?.isImage) return;
|
|
1032
|
-
let o = t === "image" ? void 0 :
|
|
1040
|
+
let o = t === "image" ? void 0 : q(i);
|
|
1033
1041
|
i._imageMetadata = o ? {
|
|
1034
1042
|
...e,
|
|
1035
1043
|
url: o.url
|
|
@@ -1038,20 +1046,20 @@ async function xt(e, t, n, r) {
|
|
|
1038
1046
|
console.warn(`Error enriching item with transaction ${a}:`, e);
|
|
1039
1047
|
}
|
|
1040
1048
|
}
|
|
1041
|
-
async function
|
|
1042
|
-
let i = e.filter((e) =>
|
|
1043
|
-
return U("enriching %d items with image metadata", i.length), await
|
|
1049
|
+
async function Ot(e, t, n, r) {
|
|
1050
|
+
let i = e.filter((e) => Et(e, t));
|
|
1051
|
+
return U("enriching %d items with image metadata", i.length), await Ct(i.map((e) => () => Dt(e, t, n, r)), St), e;
|
|
1044
1052
|
}
|
|
1045
|
-
async function
|
|
1053
|
+
async function kt(e, t, n) {
|
|
1046
1054
|
let r = n.getConfig().imageMetadata;
|
|
1047
|
-
return r?.enabled ?
|
|
1055
|
+
return r?.enabled ? Ot(e, t, new st({
|
|
1048
1056
|
gateways: r.gateways,
|
|
1049
1057
|
timeout: r.timeout
|
|
1050
1058
|
}), n) : e;
|
|
1051
1059
|
}
|
|
1052
|
-
function
|
|
1060
|
+
function At(e, t) {
|
|
1053
1061
|
let { itemUrlBase: n, itemUrlPath: r, richTextDataUriImages: i = "omit_items" } = t;
|
|
1054
|
-
return
|
|
1062
|
+
return _t(e, i).map((e) => {
|
|
1055
1063
|
let t = e.id || e.seedUid || e.SeedUid || e.storageTransactionId || e.storage_transaction_id, i = `${n.replace(/\/$/, "")}/${r.replace(/^\//, "")}/${t}`, a = e.link || e.Link || e.import_url || e.importUrl || i, o;
|
|
1056
1064
|
if (e.pubDate || e.PubDate) {
|
|
1057
1065
|
let t = e.pubDate || e.PubDate;
|
|
@@ -1061,7 +1069,7 @@ function wt(e, t) {
|
|
|
1061
1069
|
let t = e.publishedAt || e.createdAt || e.updatedAt;
|
|
1062
1070
|
o = t && typeof t == "object" && t.constructor === Date ? t : new Date(t);
|
|
1063
1071
|
} else o = /* @__PURE__ */ new Date();
|
|
1064
|
-
let s =
|
|
1072
|
+
let s = pt(e), c = mt(e), l = {
|
|
1065
1073
|
...e,
|
|
1066
1074
|
id: t,
|
|
1067
1075
|
title: e.title || e.Title || "Untitled",
|
|
@@ -1081,8 +1089,8 @@ function wt(e, t) {
|
|
|
1081
1089
|
}), l;
|
|
1082
1090
|
});
|
|
1083
1091
|
}
|
|
1084
|
-
var
|
|
1085
|
-
let l = T(c), u = v(t), d = `${l.feedUrl}/${u}/${n}`, f = r ? `${d}?v=${r}` : d, p = `${l.title} - ${
|
|
1092
|
+
var X = (e, t, n, r, i, a, o, s, c) => {
|
|
1093
|
+
let l = T(c), u = v(t), d = `${l.feedUrl}/${u}/${n}`, f = r ? `${d}?v=${r}` : d, p = `${l.title} - ${Nt(u)}`, m = /* @__PURE__ */ new Date(), h = E(), g = [];
|
|
1086
1094
|
if (i) {
|
|
1087
1095
|
let e = i.baseUrl.replace(/\?.*$/, ""), t = e.includes("?") ? "&" : "?";
|
|
1088
1096
|
i.hasNext && g.push({
|
|
@@ -1100,7 +1108,7 @@ var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1100
1108
|
rel: e.rel,
|
|
1101
1109
|
href: e.href
|
|
1102
1110
|
});
|
|
1103
|
-
let _ =
|
|
1111
|
+
let _ = At(e, {
|
|
1104
1112
|
schemaName: t,
|
|
1105
1113
|
itemUrlBase: h.itemUrlBase,
|
|
1106
1114
|
itemUrlPath: h.itemUrlPath,
|
|
@@ -1155,7 +1163,7 @@ var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1155
1163
|
return t;
|
|
1156
1164
|
})
|
|
1157
1165
|
};
|
|
1158
|
-
return Promise.resolve(
|
|
1166
|
+
return Promise.resolve(_e(t));
|
|
1159
1167
|
}
|
|
1160
1168
|
case "json": {
|
|
1161
1169
|
let e = i?.hasNext ? `${i.baseUrl.replace(/\?.*$/, "")}?page=${i.page + 1}` : void 0, t = {
|
|
@@ -1184,7 +1192,7 @@ var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1184
1192
|
}
|
|
1185
1193
|
return t;
|
|
1186
1194
|
})
|
|
1187
|
-
}, n =
|
|
1195
|
+
}, n = ve(t);
|
|
1188
1196
|
return Promise.resolve(typeof n == "string" ? n : JSON.stringify(n));
|
|
1189
1197
|
}
|
|
1190
1198
|
default: {
|
|
@@ -1212,26 +1220,26 @@ var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1212
1220
|
value: e.id,
|
|
1213
1221
|
isPermaLink: typeof e.id == "string" && (e.id.startsWith("http://") || e.id.startsWith("https://"))
|
|
1214
1222
|
});
|
|
1215
|
-
let r =
|
|
1216
|
-
if (r &&
|
|
1223
|
+
let r = q(e);
|
|
1224
|
+
if (r && bt(n, e, r, t, l.author, l.copyright), typeof e.content == "string" && e.content.trim() !== "" && n["content:encoded"] === void 0 && (n["content:encoded"] = e.content), n.dc = {}, (e.date || e.pubDate) && (n.dc.date = e.date || e.pubDate), e.timeCreated) {
|
|
1217
1225
|
let t = /* @__PURE__ */ new Date(e.timeCreated * 1e3);
|
|
1218
1226
|
n.dc.dates || (n.dc.dates = []), n.dc.dates.push(t);
|
|
1219
1227
|
}
|
|
1220
1228
|
return (e.seedUid || e.SeedUid) && (n.dc.identifier || (n.dc.identifier = []), n.dc.identifier.push(e.seedUid || e.SeedUid)), (e.storageTransactionId || e.storage_transaction_id) && (n.dc.identifier || (n.dc.identifier = []), n.dc.identifier.push(e.storageTransactionId || e.storage_transaction_id)), (e.import_url || e.importUrl) && (n.dc.source = e.import_url || e.importUrl), (e.seedUid || e.SeedUid) && (n.seedUid = e.seedUid || e.SeedUid), (e.storageTransactionId || e.storage_transaction_id) && (n.storageTransactionId = e.storageTransactionId || e.storage_transaction_id), e.timeCreated && (n.timeCreated = e.timeCreated), n;
|
|
1221
1229
|
})
|
|
1222
1230
|
};
|
|
1223
|
-
return Promise.resolve(
|
|
1231
|
+
return Promise.resolve($e(e));
|
|
1224
1232
|
}
|
|
1225
1233
|
}
|
|
1226
1234
|
};
|
|
1227
|
-
function
|
|
1235
|
+
function jt(e) {
|
|
1228
1236
|
switch (e) {
|
|
1229
1237
|
case "atom": return "application/atom+xml; charset=utf-8";
|
|
1230
1238
|
case "json": return "application/feed+json; charset=utf-8";
|
|
1231
1239
|
default: return "application/rss+xml; charset=utf-8";
|
|
1232
1240
|
}
|
|
1233
1241
|
}
|
|
1234
|
-
function
|
|
1242
|
+
function Mt(e) {
|
|
1235
1243
|
let t = e.toLowerCase();
|
|
1236
1244
|
return [
|
|
1237
1245
|
"rss",
|
|
@@ -1239,59 +1247,59 @@ function Et(e) {
|
|
|
1239
1247
|
"json"
|
|
1240
1248
|
].includes(t) ? t : null;
|
|
1241
1249
|
}
|
|
1242
|
-
function
|
|
1250
|
+
function Nt(e) {
|
|
1243
1251
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1244
1252
|
}
|
|
1245
|
-
function
|
|
1253
|
+
function Pt(e) {
|
|
1246
1254
|
return H(JSON.stringify([
|
|
1247
1255
|
e.sourceEtag ?? null,
|
|
1248
1256
|
e.siteConfig,
|
|
1249
1257
|
e.cacheBust ?? null
|
|
1250
1258
|
]));
|
|
1251
1259
|
}
|
|
1252
|
-
function
|
|
1260
|
+
function Z(e, t, n, r = {}) {
|
|
1253
1261
|
let i = {
|
|
1254
1262
|
ETag: t.etag,
|
|
1255
1263
|
"Last-Modified": (/* @__PURE__ */ new Date(t.lastModified * 1e3)).toUTCString(),
|
|
1256
1264
|
"Cache-Control": `public, max-age=${e.maxAge}, s-maxage=${e.maxAge}, must-revalidate`,
|
|
1257
1265
|
...r
|
|
1258
1266
|
};
|
|
1259
|
-
return n !== 304 && (i["Content-Type"] = t.contentType ??
|
|
1267
|
+
return n !== 304 && (i["Content-Type"] = t.contentType ?? jt(e.format), i["X-Feed-Schema"] = e.schemaName, i["X-Feed-Format"] = e.format), new Response(n === 304 ? null : t.content, {
|
|
1260
1268
|
status: n,
|
|
1261
1269
|
headers: i
|
|
1262
1270
|
});
|
|
1263
1271
|
}
|
|
1264
|
-
function
|
|
1265
|
-
return e.ifNoneMatch &&
|
|
1272
|
+
function Q(e, t, n, r) {
|
|
1273
|
+
return e.ifNoneMatch && ot(e.ifNoneMatch, t.etag) ? (U("%s for %s:%s, 304", n, e.schemaName, e.format), Z(e, {
|
|
1266
1274
|
...t,
|
|
1267
1275
|
content: null
|
|
1268
|
-
}, 304)) : (U("%s for %s:%s", n, e.schemaName, e.format),
|
|
1276
|
+
}, 304)) : (U("%s for %s:%s", n, e.schemaName, e.format), Z(e, t, 200, {
|
|
1269
1277
|
"X-Cache": n,
|
|
1270
1278
|
...r
|
|
1271
1279
|
}));
|
|
1272
1280
|
}
|
|
1273
|
-
async function
|
|
1274
|
-
let { schemaName: t, format: n, contentKeyOptions: r } = e, i =
|
|
1281
|
+
async function Ft(e) {
|
|
1282
|
+
let { schemaName: t, format: n, contentKeyOptions: r } = e, i = Y(), a = i.getConfig().enabled;
|
|
1275
1283
|
try {
|
|
1276
1284
|
let o;
|
|
1277
1285
|
e.revalidate && (o = await e.fetchItems());
|
|
1278
|
-
let s =
|
|
1286
|
+
let s = Pt({
|
|
1279
1287
|
sourceEtag: o?.sourceEtag,
|
|
1280
1288
|
siteConfig: e.siteConfig,
|
|
1281
1289
|
cacheBust: e.cacheBust
|
|
1282
1290
|
});
|
|
1283
1291
|
if (a) {
|
|
1284
1292
|
let a = await i.getFeedContent(t, n, r, s);
|
|
1285
|
-
if (a) return
|
|
1293
|
+
if (a) return Q(e, a, "HIT");
|
|
1286
1294
|
}
|
|
1287
1295
|
o ??= await e.fetchItems(), U("building %s:%s from %d items", t, n, o.items.length);
|
|
1288
|
-
let c = await e.render(o.items), l =
|
|
1296
|
+
let c = await e.render(o.items), l = jt(n), u = o.sourceEtag ? H(`${s}:${V(t, n, r)}`) : H(c), d = a ? await i.setFeedContent(t, n, {
|
|
1289
1297
|
content: c,
|
|
1290
1298
|
contentType: l,
|
|
1291
1299
|
etag: u,
|
|
1292
1300
|
fingerprint: s
|
|
1293
1301
|
}, r) : null;
|
|
1294
|
-
return d ?
|
|
1302
|
+
return d ? Q(e, d, "MISS") : Z(e, {
|
|
1295
1303
|
content: c,
|
|
1296
1304
|
contentType: l,
|
|
1297
1305
|
etag: u,
|
|
@@ -1300,7 +1308,7 @@ async function kt(e) {
|
|
|
1300
1308
|
} catch (o) {
|
|
1301
1309
|
if (console.error(`Feed generation error for ${t}:${n}:`, o), a) {
|
|
1302
1310
|
let a = await i.getFeedContent(t, n, r);
|
|
1303
|
-
if (a) return
|
|
1311
|
+
if (a) return Q(e, a, "STALE", { Warning: "110 - \"Response is stale\"" });
|
|
1304
1312
|
}
|
|
1305
1313
|
return new Response(JSON.stringify({
|
|
1306
1314
|
error: "Failed to generate feed",
|
|
@@ -1311,27 +1319,27 @@ async function kt(e) {
|
|
|
1311
1319
|
});
|
|
1312
1320
|
}
|
|
1313
1321
|
}
|
|
1314
|
-
function
|
|
1322
|
+
function $(e) {
|
|
1315
1323
|
return new Response(JSON.stringify({ error: `Invalid feed format: ${e}` }), {
|
|
1316
1324
|
status: 400,
|
|
1317
1325
|
headers: { "Content-Type": "application/json" }
|
|
1318
1326
|
});
|
|
1319
1327
|
}
|
|
1320
|
-
async function
|
|
1321
|
-
let s =
|
|
1322
|
-
if (!s) return
|
|
1323
|
-
let c = v.singular(e.toLowerCase()), l = v(c), u = T(o), d = Math.max(1, a ?? 1), f = E().pageSize, p =
|
|
1324
|
-
return
|
|
1328
|
+
async function It(e, t, r, i, a, o) {
|
|
1329
|
+
let s = Mt(t);
|
|
1330
|
+
if (!s) return $(t);
|
|
1331
|
+
let c = v.singular(e.toLowerCase()), l = v(c), u = T(o), d = Math.max(1, a ?? 1), f = E().pageSize, p = Y(), m = !1;
|
|
1332
|
+
return Ft({
|
|
1325
1333
|
schemaName: c,
|
|
1326
1334
|
format: s,
|
|
1327
1335
|
contentKeyOptions: d > 1 ? { page: d } : void 0,
|
|
1328
|
-
ifNoneMatch:
|
|
1336
|
+
ifNoneMatch: r,
|
|
1329
1337
|
siteConfig: u,
|
|
1330
1338
|
cacheBust: i,
|
|
1331
|
-
maxAge: d === 1 ?
|
|
1339
|
+
maxAge: d === 1 ? n().getConfig().maxAge ?? 0 : 3600,
|
|
1332
1340
|
revalidate: d === 1,
|
|
1333
1341
|
fetchItems: async () => {
|
|
1334
|
-
let { items: e, etag: t } = await
|
|
1342
|
+
let { items: e, etag: t } = await A(c, {
|
|
1335
1343
|
limit: f + 1,
|
|
1336
1344
|
skip: (d - 1) * f
|
|
1337
1345
|
});
|
|
@@ -1349,7 +1357,7 @@ async function jt(e, t, n, i, a, o) {
|
|
|
1349
1357
|
href: `${u.feedUrl}/${l}/archive/${n.getUTCFullYear()}/${n.getUTCMonth() + 1}/${s}`
|
|
1350
1358
|
});
|
|
1351
1359
|
}
|
|
1352
|
-
return
|
|
1360
|
+
return X(await kt(e, c, p), c, s, i, {
|
|
1353
1361
|
page: d,
|
|
1354
1362
|
pageSize: f,
|
|
1355
1363
|
hasNext: m,
|
|
@@ -1358,7 +1366,7 @@ async function jt(e, t, n, i, a, o) {
|
|
|
1358
1366
|
}
|
|
1359
1367
|
});
|
|
1360
1368
|
}
|
|
1361
|
-
async function
|
|
1369
|
+
async function Lt(e, t, n, r, i, a, o) {
|
|
1362
1370
|
if (t < 1970 || t > 2100) return new Response(JSON.stringify({ error: `Invalid year: ${t}` }), {
|
|
1363
1371
|
status: 400,
|
|
1364
1372
|
headers: { "Content-Type": "application/json" }
|
|
@@ -1367,10 +1375,10 @@ async function Mt(e, t, n, r, i, a, o) {
|
|
|
1367
1375
|
status: 400,
|
|
1368
1376
|
headers: { "Content-Type": "application/json" }
|
|
1369
1377
|
});
|
|
1370
|
-
let s =
|
|
1371
|
-
if (!s) return
|
|
1372
|
-
let c = v.singular(e.toLowerCase()), l = v(c), u = T(o), d =
|
|
1373
|
-
return
|
|
1378
|
+
let s = Mt(r);
|
|
1379
|
+
if (!s) return $(r);
|
|
1380
|
+
let c = v.singular(e.toLowerCase()), l = v(c), u = T(o), d = Y();
|
|
1381
|
+
return Ft({
|
|
1374
1382
|
schemaName: c,
|
|
1375
1383
|
format: s,
|
|
1376
1384
|
contentKeyOptions: { archive: {
|
|
@@ -1382,7 +1390,7 @@ async function Mt(e, t, n, r, i, a, o) {
|
|
|
1382
1390
|
cacheBust: a,
|
|
1383
1391
|
maxAge: 86400,
|
|
1384
1392
|
revalidate: !1,
|
|
1385
|
-
fetchItems: async () => ({ items: await
|
|
1393
|
+
fetchItems: async () => ({ items: await Ne(c, t, n) }),
|
|
1386
1394
|
render: async (e) => {
|
|
1387
1395
|
let r = `${u.feedUrl}/${l}/${s}`, i = `${u.feedUrl}/${l}/archive`, f = [{
|
|
1388
1396
|
rel: "prev-archive",
|
|
@@ -1394,11 +1402,11 @@ async function Mt(e, t, n, r, i, a, o) {
|
|
|
1394
1402
|
return (p < h.getUTCFullYear() || p === h.getUTCFullYear() && m <= h.getUTCMonth() + 1) && f.push({
|
|
1395
1403
|
rel: "next-archive",
|
|
1396
1404
|
href: `${i}/${p}/${m}/${s}`
|
|
1397
|
-
}),
|
|
1405
|
+
}), X(await kt(e, c, d), c, s, a, void 0, f, !0, void 0, o);
|
|
1398
1406
|
}
|
|
1399
1407
|
});
|
|
1400
1408
|
}
|
|
1401
1409
|
//#endregion
|
|
1402
|
-
export {
|
|
1410
|
+
export { d as DEFAULT_ARWEAVE_HOST, S as DEFAULT_SITE_CONFIG, f as SEED_RSS_IMAGE_RELATION_FIELD_KEYS, m as classifyMediaRef, X as createFeed, gt as feedItemRichTextContainsDataUriImage, A as fetchFeedItemsBySchemaName, _t as filterItemsByRichTextDataUriImagePolicy, ee as getFeedItemStringField, Me as getFeedItemsBySchemaName, Ne as getFeedItemsBySchemaNameForMonth, we as getSiteConfig, Lt as handleArchiveFeedRequest, It as handleFeedRequest, x as initializeFeedPlatform, re as isEasAttestationExplorerUrl, E as loadFeedConfig, ae as normalizeFeedItemFields, Ie as parseRssString, mt as pickFeedItemContent, pt as pickFeedItemDescription, xt as resetCacheManager, Ee as resetSiteConfig, de as resolveSeedRssImageRelationFromItem, fe as resolveSeedRssImageRelationRef, T as resolveSiteConfig, Te as setSiteConfig, Ce as teardownFeedPlatform };
|
|
1403
1411
|
|
|
1404
1412
|
//# sourceMappingURL=index.js.map
|