@seedprotocol/feed 0.8.2 → 0.8.3-next.1883.gdf94512
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 +4 -0
- package/dist/agentReadable.d.ts +69 -0
- package/dist/agentReadable.d.ts.map +1 -0
- package/dist/getFeedItems.d.ts +8 -0
- package/dist/getFeedItems.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +414 -325
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
package/dist/index.js
CHANGED
|
@@ -2,19 +2,20 @@ import { getFieldStorageModels as e, getListElementStorageModels as t, getQueryC
|
|
|
2
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
3
|
import { getEasChainDeployment as me, getEasReadChainId as he } from "@seedprotocol/eas";
|
|
4
4
|
import ge from "rss-parser";
|
|
5
|
+
import _e from "turndown";
|
|
5
6
|
import v from "pluralize";
|
|
6
|
-
import { generateAtomFeed as
|
|
7
|
-
import { create as
|
|
7
|
+
import { generateAtomFeed as ve, generateJsonFeed as ye } from "feedsmith";
|
|
8
|
+
import { create as be } from "xmlbuilder2";
|
|
8
9
|
import { promises as y } from "fs";
|
|
9
10
|
import { join as b } from "path";
|
|
10
|
-
import { createHash as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
11
|
+
import { createHash as xe } from "crypto";
|
|
12
|
+
import { imageSize as Se } from "image-size";
|
|
13
|
+
import Ce from "debug";
|
|
13
14
|
//#region src/bootstrap.ts
|
|
14
15
|
async function x(e) {
|
|
15
16
|
await r(e);
|
|
16
17
|
}
|
|
17
|
-
async function
|
|
18
|
+
async function we() {
|
|
18
19
|
await l();
|
|
19
20
|
}
|
|
20
21
|
//#endregion
|
|
@@ -52,13 +53,13 @@ function T(e, t = w) {
|
|
|
52
53
|
name: e.author.name ?? n.author?.name ?? ""
|
|
53
54
|
}), n;
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
+
function Te() {
|
|
56
57
|
return C(w);
|
|
57
58
|
}
|
|
58
|
-
function
|
|
59
|
-
return w = T(e, S),
|
|
59
|
+
function Ee(e) {
|
|
60
|
+
return w = T(e, S), Te();
|
|
60
61
|
}
|
|
61
|
-
function
|
|
62
|
+
function De() {
|
|
62
63
|
w = C(S);
|
|
63
64
|
}
|
|
64
65
|
function E() {
|
|
@@ -71,7 +72,7 @@ function E() {
|
|
|
71
72
|
}
|
|
72
73
|
//#endregion
|
|
73
74
|
//#region src/getFeedItems.ts
|
|
74
|
-
var
|
|
75
|
+
var Oe = (e) => {
|
|
75
76
|
let t = /* @__PURE__ */ new Date(e * 1e3), n = [
|
|
76
77
|
"Sun",
|
|
77
78
|
"Mon",
|
|
@@ -95,7 +96,7 @@ var D = (e) => {
|
|
|
95
96
|
"Dec"
|
|
96
97
|
], i = n[t.getUTCDay()], a = r[t.getUTCMonth()], o = t.getUTCFullYear();
|
|
97
98
|
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
|
+
}, ke = (e, t, n, r) => {
|
|
99
100
|
let { itemUrlBase: i, itemUrlPath: a } = r;
|
|
100
101
|
!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
102
|
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}`;
|
|
@@ -108,13 +109,13 @@ var D = (e) => {
|
|
|
108
109
|
f ? (e.link = u, e.Link = u) : ((!e.link || e.link === "undefined") && (e.link = d), (!e.Link || e.Link === "undefined") && (e.Link = d));
|
|
109
110
|
let p = e.guid || e.Guid;
|
|
110
111
|
if (!p || p === "undefined" || typeof p == "string" && p.trim() === "" ? (e.guid = c && f ? `ar://${c}` : e.link || u, e.Guid = e.guid) : ((!e.guid || e.guid === "undefined") && (e.guid = p), (!e.Guid || e.Guid === "undefined") && (e.Guid = p)), e.timeCreated && !e.pubDate && !e.PubDate) {
|
|
111
|
-
let t =
|
|
112
|
+
let t = Oe(e.timeCreated);
|
|
112
113
|
e.pubDate = t, e.PubDate = t;
|
|
113
114
|
} else e.pubDate && !e.PubDate ? e.PubDate = e.pubDate : e.PubDate && !e.pubDate && (e.pubDate = e.PubDate);
|
|
114
115
|
!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
|
-
},
|
|
116
|
+
}, Ae = (e, t) => {
|
|
116
117
|
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 =
|
|
118
|
+
let t = Oe(e.timeCreated);
|
|
118
119
|
e.pubDate = t, e.PubDate = t;
|
|
119
120
|
} else e.pubDate && !e.PubDate ? e.PubDate = e.pubDate : e.PubDate && !e.pubDate && (e.pubDate = e.PubDate);
|
|
120
121
|
!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);
|
|
@@ -124,42 +125,42 @@ var D = (e) => {
|
|
|
124
125
|
e.link = t, e.Link = t;
|
|
125
126
|
} catch {}
|
|
126
127
|
};
|
|
127
|
-
function
|
|
128
|
+
function je(e) {
|
|
128
129
|
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
129
130
|
let t = e;
|
|
130
131
|
return typeof t.seedUid == "string" || typeof t.SeedUid == "string";
|
|
131
132
|
}
|
|
132
|
-
function
|
|
133
|
+
function Me(e, t, n) {
|
|
133
134
|
let r = { ...e }, i = r.seedUid || r.SeedUid || "", a = typeof r.schemaName == "string" ? r.schemaName : t;
|
|
134
|
-
return a === "image" ?
|
|
135
|
+
return a === "image" ? Ae(r, i) : ke(r, i, a, n), r;
|
|
135
136
|
}
|
|
136
|
-
function
|
|
137
|
+
function Ne(e, t, n) {
|
|
137
138
|
let r = { ...e };
|
|
138
|
-
|
|
139
|
+
ke(r, r.seedUid || r.SeedUid || "", t, n);
|
|
139
140
|
for (let e of Object.keys(r)) {
|
|
140
141
|
if (e.startsWith("_")) continue;
|
|
141
142
|
let i = r[e];
|
|
142
|
-
Array.isArray(i) ? i.some(
|
|
143
|
+
Array.isArray(i) ? i.some(je) && (r[e] = i.map((e) => je(e) ? Me(e, t, n) : e)) : je(i) && (r[e] = Me(i, t, n));
|
|
143
144
|
}
|
|
144
145
|
return r;
|
|
145
146
|
}
|
|
146
|
-
function
|
|
147
|
+
function Pe(e, t) {
|
|
147
148
|
let n = E(), r = {
|
|
148
149
|
itemUrlBase: n.itemUrlBase,
|
|
149
150
|
itemUrlPath: n.itemUrlPath
|
|
150
151
|
}, i = te();
|
|
151
|
-
return t.map((t) =>
|
|
152
|
+
return t.map((t) => D(Ne(t.data, e, r), i));
|
|
152
153
|
}
|
|
153
|
-
var
|
|
154
|
-
function
|
|
154
|
+
var Fe = /* @__PURE__ */ new Set(["guid", "Guid"]);
|
|
155
|
+
function D(e, t) {
|
|
155
156
|
if (typeof e == "string") {
|
|
156
157
|
if (e.includes("<")) return se(e, { publicBaseUrl: t });
|
|
157
158
|
let n = oe(e);
|
|
158
159
|
return n ? p(n, t) : e;
|
|
159
160
|
}
|
|
160
|
-
return Array.isArray(e) ? e.map((e) =>
|
|
161
|
+
return Array.isArray(e) ? e.map((e) => D(e, t)) : e && typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype ? Object.fromEntries(Object.entries(e).map(([e, n]) => [e, Fe.has(e) ? n : D(n, t)])) : e;
|
|
161
162
|
}
|
|
162
|
-
var
|
|
163
|
+
var O = async (e, t) => {
|
|
163
164
|
await x();
|
|
164
165
|
let n = t?.limit ?? 100, r = t?.skip ?? 0, { items: i, etag: a } = await o(e, {
|
|
165
166
|
limit: n,
|
|
@@ -168,40 +169,40 @@ var A = async (e, t) => {
|
|
|
168
169
|
hydrateStorage: !0
|
|
169
170
|
});
|
|
170
171
|
return {
|
|
171
|
-
items:
|
|
172
|
+
items: Pe(e, i),
|
|
172
173
|
etag: a
|
|
173
174
|
};
|
|
174
|
-
},
|
|
175
|
+
}, Ie = async (e, t) => (await O(e, t)).items, Le = async (e, t, n) => (await x(), Pe(e, await s(e, t, n, {
|
|
175
176
|
relations: "expand",
|
|
176
177
|
hydrateStorage: !0
|
|
177
178
|
})));
|
|
178
179
|
//#endregion
|
|
179
180
|
//#region src/consume/parseRss.ts
|
|
180
|
-
function
|
|
181
|
+
function Re(e) {
|
|
181
182
|
try {
|
|
182
183
|
return JSON.parse(JSON.stringify(e));
|
|
183
184
|
} catch {
|
|
184
185
|
return { ...e };
|
|
185
186
|
}
|
|
186
187
|
}
|
|
187
|
-
var
|
|
188
|
-
function
|
|
188
|
+
var ze = ["creatorList", "authorList"];
|
|
189
|
+
function Be(e) {
|
|
189
190
|
let t = e && typeof e == "object" ? e.name : e, n = Array.isArray(t) ? t[0] : t;
|
|
190
191
|
return typeof n == "string" && n.trim() ? n.normalize("NFC").replace(/\s+/g, " ").trim() : void 0;
|
|
191
192
|
}
|
|
192
|
-
function
|
|
193
|
+
function Ve(e) {
|
|
193
194
|
let t = /* @__PURE__ */ new Map();
|
|
194
195
|
for (let n of e) {
|
|
195
|
-
let e =
|
|
196
|
+
let e = Be(n), r = e?.toUpperCase().toLowerCase();
|
|
196
197
|
e && r && !t.has(r) && t.set(r, e);
|
|
197
198
|
}
|
|
198
199
|
return [...t.values()];
|
|
199
200
|
}
|
|
200
|
-
function
|
|
201
|
-
for (let t of
|
|
201
|
+
function He(e) {
|
|
202
|
+
for (let t of ze) Array.isArray(e[t]) && (e[t] = Ve(e[t]));
|
|
202
203
|
return e;
|
|
203
204
|
}
|
|
204
|
-
var
|
|
205
|
+
var Ue = new ge({ customFields: { item: [
|
|
205
206
|
"featureImage",
|
|
206
207
|
"feature_image",
|
|
207
208
|
"content:encoded",
|
|
@@ -218,21 +219,215 @@ var Be = new ge({ customFields: { item: [
|
|
|
218
219
|
{ keepArray: !0 }
|
|
219
220
|
]
|
|
220
221
|
] } });
|
|
221
|
-
async function
|
|
222
|
-
let t = await
|
|
222
|
+
async function We(e) {
|
|
223
|
+
let t = await Ue.parseString(e);
|
|
223
224
|
return {
|
|
224
225
|
title: t.title,
|
|
225
226
|
link: t.link,
|
|
226
227
|
description: t.description,
|
|
227
|
-
items: (t.items ?? []).map((e) =>
|
|
228
|
+
items: (t.items ?? []).map((e) => He(Re(e)))
|
|
228
229
|
};
|
|
229
230
|
}
|
|
230
231
|
//#endregion
|
|
232
|
+
//#region src/pickFeedItemRichText.ts
|
|
233
|
+
function k(e, t) {
|
|
234
|
+
for (let n of t) {
|
|
235
|
+
let t = e[n];
|
|
236
|
+
if (typeof t == "string" && t.trim() !== "") return t;
|
|
237
|
+
}
|
|
238
|
+
return "";
|
|
239
|
+
}
|
|
240
|
+
var Ge = [
|
|
241
|
+
"summary",
|
|
242
|
+
"Summary",
|
|
243
|
+
"description",
|
|
244
|
+
"Description",
|
|
245
|
+
"text",
|
|
246
|
+
"Text"
|
|
247
|
+
], Ke = [
|
|
248
|
+
"html",
|
|
249
|
+
"Html",
|
|
250
|
+
"body",
|
|
251
|
+
"Body",
|
|
252
|
+
"content",
|
|
253
|
+
"Content"
|
|
254
|
+
], qe = [
|
|
255
|
+
"summary",
|
|
256
|
+
"Summary",
|
|
257
|
+
"description",
|
|
258
|
+
"Description",
|
|
259
|
+
"text",
|
|
260
|
+
"Text"
|
|
261
|
+
];
|
|
262
|
+
function Je(e, t) {
|
|
263
|
+
let n = c(e.model) - c(t.model);
|
|
264
|
+
if (n !== 0) return n;
|
|
265
|
+
let r = e.key.localeCompare(t.key);
|
|
266
|
+
return r === 0 ? e.index - t.index : r;
|
|
267
|
+
}
|
|
268
|
+
function Ye(n) {
|
|
269
|
+
let r = e(n), i = t(n), o = null;
|
|
270
|
+
if (r) for (let [e, t] of Object.entries(r)) {
|
|
271
|
+
if (!a(t)) continue;
|
|
272
|
+
let r = n[e];
|
|
273
|
+
if (typeof r != "string" || r.trim() === "") continue;
|
|
274
|
+
let i = {
|
|
275
|
+
model: t,
|
|
276
|
+
key: e,
|
|
277
|
+
index: 0,
|
|
278
|
+
value: r
|
|
279
|
+
};
|
|
280
|
+
(!o || Je(i, o) < 0) && (o = i);
|
|
281
|
+
}
|
|
282
|
+
if (i) for (let [e, t] of Object.entries(i)) {
|
|
283
|
+
let r = n[e];
|
|
284
|
+
if (!Array.isArray(r)) continue;
|
|
285
|
+
let i = Math.min(t.length, r.length);
|
|
286
|
+
for (let n = 0; n < i; n++) {
|
|
287
|
+
let i = t[n];
|
|
288
|
+
if (!a(i)) continue;
|
|
289
|
+
let s = r[n];
|
|
290
|
+
if (typeof s != "string" || s.trim() === "") continue;
|
|
291
|
+
let c = {
|
|
292
|
+
model: i,
|
|
293
|
+
key: e,
|
|
294
|
+
index: n,
|
|
295
|
+
value: s
|
|
296
|
+
};
|
|
297
|
+
(!o || Je(c, o) < 0) && (o = c);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return o?.value ?? "";
|
|
301
|
+
}
|
|
302
|
+
function A(e) {
|
|
303
|
+
return k(e, Ge);
|
|
304
|
+
}
|
|
305
|
+
function j(e) {
|
|
306
|
+
let t = Ye(e);
|
|
307
|
+
if (t !== "") return t;
|
|
308
|
+
let n = k(e, Ke);
|
|
309
|
+
return n === "" ? k(e, qe) : n;
|
|
310
|
+
}
|
|
311
|
+
function M(e) {
|
|
312
|
+
return typeof e == "string" && e.includes("data:image/") && e.includes(";base64,");
|
|
313
|
+
}
|
|
314
|
+
function Xe(n) {
|
|
315
|
+
let r = e(n);
|
|
316
|
+
if (r) {
|
|
317
|
+
for (let [e, t] of Object.entries(r)) if (a(t) && M(n[e])) return !0;
|
|
318
|
+
}
|
|
319
|
+
let i = t(n);
|
|
320
|
+
if (i) for (let [e, t] of Object.entries(i)) {
|
|
321
|
+
let r = n[e];
|
|
322
|
+
if (!Array.isArray(r)) continue;
|
|
323
|
+
let i = Math.min(t.length, r.length);
|
|
324
|
+
for (let e = 0; e < i; e++) if (a(t[e]) && M(r[e])) return !0;
|
|
325
|
+
}
|
|
326
|
+
return !1;
|
|
327
|
+
}
|
|
328
|
+
function Ze(e) {
|
|
329
|
+
if (Xe(e)) return !0;
|
|
330
|
+
for (let t of Ke) if (M(e[t])) return !0;
|
|
331
|
+
for (let t of Ge) if (M(e[t])) return !0;
|
|
332
|
+
return !1;
|
|
333
|
+
}
|
|
334
|
+
function Qe(e, t = "omit_items") {
|
|
335
|
+
return t === "include_items" ? [...e] : e.filter((e) => !Ze(e));
|
|
336
|
+
}
|
|
337
|
+
//#endregion
|
|
338
|
+
//#region src/agentReadable.ts
|
|
339
|
+
var N;
|
|
340
|
+
function $e() {
|
|
341
|
+
if (N) return N;
|
|
342
|
+
let e = new _e({
|
|
343
|
+
headingStyle: "atx",
|
|
344
|
+
bulletListMarker: "-",
|
|
345
|
+
codeBlockStyle: "fenced"
|
|
346
|
+
});
|
|
347
|
+
return e.remove([
|
|
348
|
+
"script",
|
|
349
|
+
"style",
|
|
350
|
+
"noscript",
|
|
351
|
+
"iframe"
|
|
352
|
+
]), e.keep(["table"]), e.addRule("embeddedImage", {
|
|
353
|
+
filter: (e) => {
|
|
354
|
+
let t = e;
|
|
355
|
+
return t.nodeName === "IMG" && (t.getAttribute("src") ?? "").startsWith("data:");
|
|
356
|
+
},
|
|
357
|
+
replacement: (e, t) => {
|
|
358
|
+
let n = t.getAttribute("alt")?.trim();
|
|
359
|
+
return n ? `[image: ${n}]` : "[image]";
|
|
360
|
+
}
|
|
361
|
+
}), N = e, e;
|
|
362
|
+
}
|
|
363
|
+
function et(e) {
|
|
364
|
+
return $e().turndown(e);
|
|
365
|
+
}
|
|
366
|
+
function tt(e, t) {
|
|
367
|
+
for (let n of t) {
|
|
368
|
+
let t = e[n];
|
|
369
|
+
if (typeof t == "string" && t.trim() !== "") return t.trim();
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
function nt(e) {
|
|
373
|
+
return tt(e.data, ["title", "Title"]) ?? e.seedUid;
|
|
374
|
+
}
|
|
375
|
+
function rt(e) {
|
|
376
|
+
let t = e.authors ?? e.Authors;
|
|
377
|
+
return Array.isArray(t) ? t.flatMap((e) => {
|
|
378
|
+
if (typeof e == "string") return e.trim() ? [e.trim()] : [];
|
|
379
|
+
if (e && typeof e == "object") {
|
|
380
|
+
let t = tt(e, ["name", "displayName"]);
|
|
381
|
+
return t ? [t] : [];
|
|
382
|
+
}
|
|
383
|
+
return [];
|
|
384
|
+
}) : [];
|
|
385
|
+
}
|
|
386
|
+
var P = (e) => JSON.stringify(e);
|
|
387
|
+
function it(e, t = {}) {
|
|
388
|
+
let n = D(e.data, te()), r = nt(e), i = [
|
|
389
|
+
"---",
|
|
390
|
+
`title: ${P(r)}`,
|
|
391
|
+
`seed_uid: ${P(e.seedUid)}`
|
|
392
|
+
];
|
|
393
|
+
e.versionUid && i.push(`version_uid: ${P(e.versionUid)}`), e.attester && i.push(`attester: ${P(e.attester)}`), i.push(`schema: ${P(e.schemaName)}`), e.timeCreated > 0 && i.push(`published: ${P((/* @__PURE__ */ new Date(e.timeCreated * 1e3)).toISOString())}`);
|
|
394
|
+
let a = rt(n);
|
|
395
|
+
a.length > 0 && i.push("authors:", ...a.map((e) => ` - ${P(e)}`));
|
|
396
|
+
let o = A(n).trim();
|
|
397
|
+
o && i.push(`summary: ${P(o)}`), t.url && i.push(`url: ${P(t.url)}`), t.license && (i.push(`license: ${P(t.license.name)}`), t.license.url && i.push(`license_url: ${P(t.license.url)}`), t.license.summary && i.push(`license_summary: ${P(t.license.summary)}`)), i.push("---", "", `# ${r}`, "");
|
|
398
|
+
let s = j(n).trim(), c = s.includes("<") ? et(s) : s;
|
|
399
|
+
return c && i.push(c, ""), i.join("\n");
|
|
400
|
+
}
|
|
401
|
+
var F = (e) => e.replace(/\s+/g, " ").trim(), at = (e) => F(e).replace(/[[\]]/g, (e) => `\\${e}`);
|
|
402
|
+
function ot(e) {
|
|
403
|
+
return e.map((e) => {
|
|
404
|
+
let t = e.note ? F(e.note) : "";
|
|
405
|
+
return `- [${at(e.title)}](${e.url})${t ? `: ${t}` : ""}`;
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
function st(e) {
|
|
409
|
+
let t = [`# ${F(e.title)}`];
|
|
410
|
+
e.description && t.push(`> ${F(e.description)}`), e.details?.trim() && t.push(e.details.trim());
|
|
411
|
+
let n = [];
|
|
412
|
+
for (let r of e.sections) r.optional ? n.push(...r.links) : r.links.length > 0 && t.push(`## ${F(r.name)}`, ot(r.links).join("\n"));
|
|
413
|
+
return n.length > 0 && t.push("## Optional", ot(n).join("\n")), `${t.join("\n\n")}\n`;
|
|
414
|
+
}
|
|
415
|
+
function ct(e, t) {
|
|
416
|
+
return e.map((e) => {
|
|
417
|
+
let n = A(e.data).trim();
|
|
418
|
+
return {
|
|
419
|
+
title: nt(e),
|
|
420
|
+
url: t(e),
|
|
421
|
+
...n ? { note: n } : {}
|
|
422
|
+
};
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
//#endregion
|
|
231
426
|
//#region src/rss/generateRssXml.ts
|
|
232
|
-
var
|
|
427
|
+
var I = "http://purl.org/dc/elements/1.1/", L = "http://purl.org/rss/1.0/modules/content/", R = "http://search.yahoo.com/mrss/", lt = { publication: {
|
|
233
428
|
prefix: "publication",
|
|
234
429
|
uri: "https://seedprotocol.io/ns/publication/1.0"
|
|
235
|
-
} },
|
|
430
|
+
} }, ut = "https://seedprotocol.io/ns/relations", dt = /* @__PURE__ */ new Set([
|
|
236
431
|
"xml",
|
|
237
432
|
"xmlns",
|
|
238
433
|
"dc",
|
|
@@ -240,17 +435,17 @@ var j = "http://purl.org/dc/elements/1.1/", M = "http://purl.org/rss/1.0/modules
|
|
|
240
435
|
"content",
|
|
241
436
|
"atom",
|
|
242
437
|
"fh"
|
|
243
|
-
]),
|
|
438
|
+
]), ft = /* @__PURE__ */ new Set([
|
|
244
439
|
"Title",
|
|
245
440
|
"Link",
|
|
246
441
|
"Guid",
|
|
247
442
|
"PubDate",
|
|
248
443
|
"SeedUid"
|
|
249
444
|
]);
|
|
250
|
-
function
|
|
251
|
-
return
|
|
445
|
+
function pt(e, t) {
|
|
446
|
+
return ft.has(e) ? e.charAt(0).toLowerCase() + e.slice(1) in t : !1;
|
|
252
447
|
}
|
|
253
|
-
var
|
|
448
|
+
var z = [
|
|
254
449
|
"title",
|
|
255
450
|
"link",
|
|
256
451
|
"description",
|
|
@@ -274,7 +469,7 @@ var P = [
|
|
|
274
469
|
"media:category",
|
|
275
470
|
"media:group"
|
|
276
471
|
];
|
|
277
|
-
function
|
|
472
|
+
function B(e) {
|
|
278
473
|
if (e instanceof Date) return e.toUTCString();
|
|
279
474
|
if (typeof e == "string") {
|
|
280
475
|
let t = new Date(e);
|
|
@@ -282,13 +477,13 @@ function F(e) {
|
|
|
282
477
|
}
|
|
283
478
|
return String(e);
|
|
284
479
|
}
|
|
285
|
-
function
|
|
480
|
+
function mt(e) {
|
|
286
481
|
return /[<>&]|]]>/.test(e);
|
|
287
482
|
}
|
|
288
|
-
function
|
|
483
|
+
function V(e, t) {
|
|
289
484
|
let n = String(t);
|
|
290
485
|
if (n !== "") {
|
|
291
|
-
if (
|
|
486
|
+
if (mt(n)) {
|
|
292
487
|
if (n.includes("]]>")) {
|
|
293
488
|
let t = n.split("]]>");
|
|
294
489
|
for (let n = 0; n < t.length; n++) e.dat(t[n]), n < t.length - 1 && e.txt("]]>");
|
|
@@ -296,11 +491,11 @@ function I(e, t) {
|
|
|
296
491
|
} else e.txt(n);
|
|
297
492
|
}
|
|
298
493
|
}
|
|
299
|
-
function
|
|
494
|
+
function H(e) {
|
|
300
495
|
return typeof e == "object" && !!e && !Array.isArray(e) && !(e instanceof Date);
|
|
301
496
|
}
|
|
302
|
-
var
|
|
303
|
-
...
|
|
497
|
+
var ht = 4, gt = /* @__PURE__ */ new Set([
|
|
498
|
+
...z,
|
|
304
499
|
"guid",
|
|
305
500
|
"source",
|
|
306
501
|
"dc",
|
|
@@ -308,70 +503,70 @@ var Je = 4, Ye = /* @__PURE__ */ new Set([
|
|
|
308
503
|
"content:encoded",
|
|
309
504
|
"items"
|
|
310
505
|
]);
|
|
311
|
-
function
|
|
506
|
+
function _t(e) {
|
|
312
507
|
return e.endsWith("s") && e.length > 1 ? e.slice(0, -1) : e;
|
|
313
508
|
}
|
|
314
|
-
function
|
|
509
|
+
function vt(e) {
|
|
315
510
|
return e.trim().replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^[^A-Za-z_]+/, "").replace(/^$/, "rel").toLowerCase();
|
|
316
511
|
}
|
|
317
|
-
function
|
|
318
|
-
if (!t.has(e) && !
|
|
512
|
+
function yt(e, t) {
|
|
513
|
+
if (!t.has(e) && !dt.has(e)) return t.add(e), e;
|
|
319
514
|
let n = 2;
|
|
320
515
|
for (;;) {
|
|
321
516
|
let r = `${e}${n}`;
|
|
322
|
-
if (!t.has(r) && !
|
|
517
|
+
if (!t.has(r) && !dt.has(r)) return t.add(r), r;
|
|
323
518
|
n += 1;
|
|
324
519
|
}
|
|
325
520
|
}
|
|
326
|
-
function
|
|
327
|
-
return Array.isArray(e) && e.length > 0 && e.every((e) =>
|
|
521
|
+
function bt(e) {
|
|
522
|
+
return Array.isArray(e) && e.length > 0 && e.every((e) => H(e));
|
|
328
523
|
}
|
|
329
|
-
function
|
|
330
|
-
let t = { ...
|
|
524
|
+
function xt(e) {
|
|
525
|
+
let t = { ...lt }, n = new Set(Object.values(t).map((e) => e.prefix)), r = /* @__PURE__ */ new Set();
|
|
331
526
|
for (let t of e) for (let [e, n] of Object.entries(t)) {
|
|
332
|
-
let t = e === "author" &&
|
|
333
|
-
e.startsWith("_") || (!
|
|
527
|
+
let t = e === "author" && H(n) || e === "authors" && bt(n);
|
|
528
|
+
e.startsWith("_") || (!gt.has(e) || t) && (H(n) || bt(n)) && r.add(_t(e));
|
|
334
529
|
}
|
|
335
530
|
let i = [...r].sort();
|
|
336
531
|
for (let e of i) t[e] || (t[e] = {
|
|
337
|
-
prefix:
|
|
338
|
-
uri: `${
|
|
532
|
+
prefix: yt(vt(e), n),
|
|
533
|
+
uri: `${ut}/${e}/1.0`
|
|
339
534
|
});
|
|
340
535
|
return t;
|
|
341
536
|
}
|
|
342
|
-
function
|
|
537
|
+
function U(e, t) {
|
|
343
538
|
if (e in t) return t[e];
|
|
344
539
|
if (e.endsWith("s") && e.length > 1) {
|
|
345
540
|
let n = e.slice(0, -1);
|
|
346
541
|
if (n in t) return t[n];
|
|
347
542
|
}
|
|
348
543
|
}
|
|
349
|
-
function
|
|
544
|
+
function St(e, t) {
|
|
350
545
|
return t ? `${t.prefix}:${e}` : e;
|
|
351
546
|
}
|
|
352
|
-
function
|
|
547
|
+
function W(e, t, n, r, i = 0, a) {
|
|
353
548
|
let o = e.ele(n);
|
|
354
549
|
for (let [e, n] of Object.entries(t)) {
|
|
355
550
|
if (n == null || e.startsWith("_") || e === "items") continue;
|
|
356
|
-
let t =
|
|
357
|
-
if (i >=
|
|
551
|
+
let t = St(e, a);
|
|
552
|
+
if (i >= ht) V(o.ele(t), typeof n == "object" ? JSON.stringify(n) : String(n));
|
|
358
553
|
else if (Array.isArray(n)) {
|
|
359
|
-
let t =
|
|
360
|
-
for (let e of n) e != null && (
|
|
361
|
-
} else
|
|
554
|
+
let t = St(e.endsWith("s") && e.length > 1 ? e.slice(0, -1) : e, a);
|
|
555
|
+
for (let e of n) e != null && (H(e) ? W(o, e, t, !1, i + 1, a) : V(o.ele(t), String(e)));
|
|
556
|
+
} else H(n) ? W(o, n, t, !1, i + 1, a) : V(o.ele(t), String(n));
|
|
362
557
|
}
|
|
363
558
|
if (r) {
|
|
364
559
|
let n = t.name ?? t.seedUid;
|
|
365
|
-
n && e.ele(
|
|
560
|
+
n && e.ele(I, "creator").txt(String(n));
|
|
366
561
|
}
|
|
367
562
|
}
|
|
368
|
-
function
|
|
563
|
+
function Ct(e, t, n, r, i) {
|
|
369
564
|
if (!(n == null || t.startsWith("_")) && t !== "items") {
|
|
370
565
|
if (t === "guid") {
|
|
371
566
|
let t = n, r = t?.value ?? String(n);
|
|
372
567
|
if (!r) return;
|
|
373
568
|
let i = {};
|
|
374
|
-
typeof t?.isPermaLink == "boolean" && (i.isPermaLink = t.isPermaLink ? "true" : "false"),
|
|
569
|
+
typeof t?.isPermaLink == "boolean" && (i.isPermaLink = t.isPermaLink ? "true" : "false"), V(e.ele("guid", i), r);
|
|
375
570
|
} else if (t === "source" && typeof n == "object" && n) {
|
|
376
571
|
let t = n, r = t.title ?? String(n);
|
|
377
572
|
if (!r) return;
|
|
@@ -390,28 +585,28 @@ function tt(e, t, n, r, i) {
|
|
|
390
585
|
for (let [n, r] of Object.entries(t)) if (r != null) {
|
|
391
586
|
if (Array.isArray(r)) {
|
|
392
587
|
for (let t of r) if (t != null) {
|
|
393
|
-
let r = e.ele(
|
|
394
|
-
t instanceof Date ? r.txt(t.toISOString()) :
|
|
588
|
+
let r = e.ele(I, n);
|
|
589
|
+
t instanceof Date ? r.txt(t.toISOString()) : V(r, String(t));
|
|
395
590
|
}
|
|
396
591
|
} else {
|
|
397
|
-
let t = e.ele(
|
|
398
|
-
r instanceof Date ? t.txt(r.toISOString()) :
|
|
592
|
+
let t = e.ele(I, n);
|
|
593
|
+
r instanceof Date ? t.txt(r.toISOString()) : V(t, String(r));
|
|
399
594
|
}
|
|
400
595
|
}
|
|
401
|
-
} else if (t === "content:encoded")
|
|
402
|
-
else if (t === "content" && typeof n == "string" && !("content:encoded" in r))
|
|
596
|
+
} else if (t === "content:encoded") V(e.ele(L, "encoded"), String(n));
|
|
597
|
+
else if (t === "content" && typeof n == "string" && !("content:encoded" in r)) V(e.ele(L, "encoded"), String(n));
|
|
403
598
|
else if (t !== "content") {
|
|
404
599
|
if (t === "media:group" && Array.isArray(n)) {
|
|
405
600
|
for (let t of n) if (t && typeof t == "object") {
|
|
406
|
-
let n = e.ele(
|
|
601
|
+
let n = e.ele(R, "group");
|
|
407
602
|
for (let [e, r] of Object.entries(t)) if (r != null && e.startsWith("media:")) {
|
|
408
603
|
let t = e.slice(6);
|
|
409
604
|
if (Array.isArray(r)) {
|
|
410
605
|
for (let e of r) if (e && typeof e == "object") {
|
|
411
|
-
let r = n.ele(
|
|
412
|
-
for (let [t, n] of Object.entries(e)) n != null && (t === "url" || t === "value" ?
|
|
606
|
+
let r = n.ele(R, t);
|
|
607
|
+
for (let [t, n] of Object.entries(e)) n != null && (t === "url" || t === "value" ? V(r, String(n)) : r.att(t, String(n)));
|
|
413
608
|
}
|
|
414
|
-
} else typeof r == "string" &&
|
|
609
|
+
} else typeof r == "string" && V(n.ele(R, t), r);
|
|
415
610
|
}
|
|
416
611
|
}
|
|
417
612
|
} else if (t.startsWith("media:") && Array.isArray(n)) {
|
|
@@ -420,17 +615,17 @@ function tt(e, t, n, r, i) {
|
|
|
420
615
|
if (typeof t != "object" || !t) continue;
|
|
421
616
|
let n = {}, i = null;
|
|
422
617
|
for (let [e, r] of Object.entries(t)) r != null && (e === "value" ? i = String(r) : n[e] = String(r));
|
|
423
|
-
let a = e.ele(
|
|
424
|
-
i !== null &&
|
|
618
|
+
let a = e.ele(R, r, n);
|
|
619
|
+
i !== null && V(a, i);
|
|
425
620
|
}
|
|
426
621
|
} else if (t.startsWith("media:") && typeof n == "string") {
|
|
427
622
|
let r = t.slice(6);
|
|
428
|
-
|
|
429
|
-
} else if (n instanceof Date) e.ele(t).txt(
|
|
430
|
-
else if (t === "author" &&
|
|
623
|
+
V(e.ele(R, r), n);
|
|
624
|
+
} else if (n instanceof Date) e.ele(t).txt(B(n));
|
|
625
|
+
else if (t === "author" && H(n)) W(e, n, "author", !0, 0, U(t, i));
|
|
431
626
|
else if (t === "authors" && Array.isArray(n)) {
|
|
432
|
-
let r =
|
|
433
|
-
for (let t of n) if (t &&
|
|
627
|
+
let r = U(t, i);
|
|
628
|
+
for (let t of n) if (t && H(t)) W(e, t, "author", !0, 0, r);
|
|
434
629
|
else {
|
|
435
630
|
let n = typeof t == "string" ? t : t && typeof t == "object" && "name" in t ? `${t.email ?? ""} (${t.name ?? ""})`.trim() || t.name : String(t);
|
|
436
631
|
n && e.ele("author").txt(n);
|
|
@@ -442,62 +637,62 @@ function tt(e, t, n, r, i) {
|
|
|
442
637
|
e.ele("category", r).txt(n);
|
|
443
638
|
}
|
|
444
639
|
}
|
|
445
|
-
else if (Array.isArray(n) && n.length > 0 && n.every((e) =>
|
|
446
|
-
let r = t.endsWith("s") ? t.slice(0, -1) : t, a =
|
|
447
|
-
for (let t of n) t &&
|
|
640
|
+
else if (Array.isArray(n) && n.length > 0 && n.every((e) => H(e))) {
|
|
641
|
+
let r = t.endsWith("s") ? t.slice(0, -1) : t, a = U(t, i);
|
|
642
|
+
for (let t of n) t && W(e, t, r, !1, 0, a);
|
|
448
643
|
} else if (Array.isArray(n) && n.every((e) => typeof e == "string")) {
|
|
449
644
|
let r = t.endsWith("s") ? t.slice(0, -1) : t;
|
|
450
|
-
for (let t of n) t &&
|
|
451
|
-
} else
|
|
645
|
+
for (let t of n) t && V(e.ele(r), t);
|
|
646
|
+
} else H(n) ? W(e, n, t, !1, 0, U(t, i)) : V(e.ele(t), String(n));
|
|
452
647
|
}
|
|
453
648
|
}
|
|
454
649
|
}
|
|
455
|
-
var
|
|
456
|
-
function
|
|
457
|
-
let t =
|
|
650
|
+
var wt = "http://www.w3.org/2005/Atom", Tt = "http://purl.org/syndication/history/1.0";
|
|
651
|
+
function Et(e) {
|
|
652
|
+
let t = be({
|
|
458
653
|
version: "1.0",
|
|
459
654
|
encoding: "UTF-8"
|
|
460
|
-
}), n =
|
|
461
|
-
"xmlns:dc":
|
|
462
|
-
"xmlns:content":
|
|
463
|
-
"xmlns:media":
|
|
464
|
-
"xmlns:atom":
|
|
655
|
+
}), n = xt(e.items), r = {
|
|
656
|
+
"xmlns:dc": I,
|
|
657
|
+
"xmlns:content": L,
|
|
658
|
+
"xmlns:media": R,
|
|
659
|
+
"xmlns:atom": wt,
|
|
465
660
|
...Object.values(n).reduce((e, t) => (e[`xmlns:${t.prefix}`] = t.uri, e), {})
|
|
466
661
|
};
|
|
467
|
-
e.isArchive && (r["xmlns:fh"] =
|
|
662
|
+
e.isArchive && (r["xmlns:fh"] = Tt);
|
|
468
663
|
let i = t.ele("rss", {
|
|
469
664
|
version: "2.0",
|
|
470
665
|
...r
|
|
471
666
|
}).ele("channel", {
|
|
472
|
-
"xmlns:dc":
|
|
473
|
-
"xmlns:content":
|
|
474
|
-
"xmlns:media":
|
|
667
|
+
"xmlns:dc": I,
|
|
668
|
+
"xmlns:content": L,
|
|
669
|
+
"xmlns:media": R
|
|
475
670
|
});
|
|
476
|
-
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(
|
|
671
|
+
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(B(e.pubDate)), e.lastBuildDate && i.ele("lastBuildDate").txt(B(e.lastBuildDate)), e.links?.length) for (let t of e.links) {
|
|
477
672
|
let e = {
|
|
478
673
|
rel: t.rel,
|
|
479
674
|
href: t.href
|
|
480
675
|
};
|
|
481
|
-
t.type && (e.type = t.type), i.ele(
|
|
676
|
+
t.type && (e.type = t.type), i.ele(wt, "link", e);
|
|
482
677
|
}
|
|
483
|
-
e.isArchive && i.ele(
|
|
484
|
-
let a = new Set(
|
|
678
|
+
e.isArchive && i.ele(Tt, "archive");
|
|
679
|
+
let a = new Set(z);
|
|
485
680
|
for (let t of e.items) {
|
|
486
681
|
let e = i.ele("item"), r = /* @__PURE__ */ new Set();
|
|
487
|
-
for (let i of
|
|
488
|
-
let o = Object.keys(t).filter((e) => !r.has(e) && !a.has(e) && !e.startsWith("_") && !
|
|
489
|
-
for (let r of o)
|
|
682
|
+
for (let i of z) i in t && (Ct(e, i, t[i], t, n), r.add(i));
|
|
683
|
+
let o = Object.keys(t).filter((e) => !r.has(e) && !a.has(e) && !e.startsWith("_") && !pt(e, t)).sort();
|
|
684
|
+
for (let r of o) Ct(e, r, t[r], t, n);
|
|
490
685
|
}
|
|
491
686
|
return t.end({ prettyPrint: !0 });
|
|
492
687
|
}
|
|
493
688
|
//#endregion
|
|
494
689
|
//#region src/cache/types.ts
|
|
495
|
-
function
|
|
690
|
+
function G(e, t, n) {
|
|
496
691
|
return n?.archive ? `${e}:${t}:archive-${n.archive.year}-${n.archive.month}` : n?.page != null && n.page > 1 ? `${e}:${t}:page-${n.page}` : `${e}:${t}`;
|
|
497
692
|
}
|
|
498
693
|
//#endregion
|
|
499
694
|
//#region src/cache/MemoryCache.ts
|
|
500
|
-
var
|
|
695
|
+
var Dt = class {
|
|
501
696
|
feedContentCache = /* @__PURE__ */ new Map();
|
|
502
697
|
imageMetadataCache = /* @__PURE__ */ new Map();
|
|
503
698
|
config;
|
|
@@ -505,11 +700,11 @@ var at = class {
|
|
|
505
700
|
this.config = e;
|
|
506
701
|
}
|
|
507
702
|
getFeedContent(e, t, n) {
|
|
508
|
-
let r =
|
|
703
|
+
let r = G(e, t, n), i = this.feedContentCache.get(r);
|
|
509
704
|
return i ? Math.floor(Date.now() / 1e3) > i.expiresAt ? (this.feedContentCache.delete(r), null) : i : null;
|
|
510
705
|
}
|
|
511
706
|
putFeedContent(e, t, n, r) {
|
|
512
|
-
this.feedContentCache.set(
|
|
707
|
+
this.feedContentCache.set(G(e, t, r), n);
|
|
513
708
|
}
|
|
514
709
|
getImageMetadata(e) {
|
|
515
710
|
let t = this.imageMetadataCache.get(e);
|
|
@@ -523,7 +718,7 @@ var at = class {
|
|
|
523
718
|
};
|
|
524
719
|
this.imageMetadataCache.set(e, r);
|
|
525
720
|
}
|
|
526
|
-
},
|
|
721
|
+
}, Ot = class {
|
|
527
722
|
cacheDir;
|
|
528
723
|
config;
|
|
529
724
|
constructor(e) {
|
|
@@ -539,7 +734,7 @@ var at = class {
|
|
|
539
734
|
}
|
|
540
735
|
}
|
|
541
736
|
getFeedContentPath(e, t, n) {
|
|
542
|
-
let r =
|
|
737
|
+
let r = G(e, t, n).replace(/:/g, "-");
|
|
543
738
|
return b(this.cacheDir, `${r}.json`);
|
|
544
739
|
}
|
|
545
740
|
getImageMetadataPath(e) {
|
|
@@ -608,12 +803,12 @@ var at = class {
|
|
|
608
803
|
t.code !== "ENOENT" && console.error(`Error clearing image metadata cache for ${e}:`, t);
|
|
609
804
|
}
|
|
610
805
|
}
|
|
611
|
-
},
|
|
806
|
+
}, kt = class {
|
|
612
807
|
memoryCache;
|
|
613
808
|
fileCache;
|
|
614
809
|
config;
|
|
615
810
|
constructor(e) {
|
|
616
|
-
this.config = e, this.memoryCache = new
|
|
811
|
+
this.config = e, this.memoryCache = new Dt(e), this.fileCache = new Ot(e);
|
|
617
812
|
}
|
|
618
813
|
getConfig() {
|
|
619
814
|
return this.config;
|
|
@@ -661,7 +856,7 @@ var at = class {
|
|
|
661
856
|
};
|
|
662
857
|
//#endregion
|
|
663
858
|
//#region src/cache/config.ts
|
|
664
|
-
function
|
|
859
|
+
function At() {
|
|
665
860
|
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;
|
|
666
861
|
a = n ? !1 : r ? !0 : !i, a || console.log(`⚠️ Cache is DISABLED (${n ? "CACHE_ENABLED=false" : i ? "NODE_ENV=development" : "CACHE_ENABLED=false"})`);
|
|
667
862
|
let o = {
|
|
@@ -681,23 +876,23 @@ function ct() {
|
|
|
681
876
|
}
|
|
682
877
|
//#endregion
|
|
683
878
|
//#region src/utils/etag.ts
|
|
684
|
-
function
|
|
685
|
-
return `"${
|
|
879
|
+
function K(e) {
|
|
880
|
+
return `"${xe("md5").update(e).digest("hex").substring(0, 16)}"`;
|
|
686
881
|
}
|
|
687
|
-
function
|
|
882
|
+
function jt(e, t) {
|
|
688
883
|
let n = (e) => e.replace(/^W\//, "").replace(/^"|"$/g, "");
|
|
689
884
|
return n(e) === n(t);
|
|
690
885
|
}
|
|
691
|
-
function
|
|
886
|
+
function Mt(e) {
|
|
692
887
|
return e ? e.split(",").map((e) => e.trim()).filter((e) => e.length > 0) : [];
|
|
693
888
|
}
|
|
694
|
-
function
|
|
695
|
-
let n =
|
|
696
|
-
return n.length === 0 ? !1 : n.includes("*") ? !0 : n.some((e) =>
|
|
889
|
+
function Nt(e, t) {
|
|
890
|
+
let n = Mt(e);
|
|
891
|
+
return n.length === 0 ? !1 : n.includes("*") ? !0 : n.some((e) => jt(e, t));
|
|
697
892
|
}
|
|
698
893
|
//#endregion
|
|
699
894
|
//#region src/services/arweaveImageService.ts
|
|
700
|
-
var
|
|
895
|
+
var Pt = class {
|
|
701
896
|
config;
|
|
702
897
|
constructor(e) {
|
|
703
898
|
this.config = e;
|
|
@@ -782,7 +977,7 @@ var ft = class {
|
|
|
782
977
|
}
|
|
783
978
|
extractImageDimensions(e, t) {
|
|
784
979
|
try {
|
|
785
|
-
let t =
|
|
980
|
+
let t = Se(e);
|
|
786
981
|
if (t.width && t.height) return {
|
|
787
982
|
width: t.width,
|
|
788
983
|
height: t.height
|
|
@@ -804,7 +999,7 @@ var ft = class {
|
|
|
804
999
|
}
|
|
805
1000
|
}
|
|
806
1001
|
try {
|
|
807
|
-
let e =
|
|
1002
|
+
let e = Se(t);
|
|
808
1003
|
if (e.type) return e.type.toLowerCase();
|
|
809
1004
|
} catch {}
|
|
810
1005
|
}
|
|
@@ -820,150 +1015,44 @@ var ft = class {
|
|
|
820
1015
|
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? Error(`Request timeout after ${this.config.timeout}ms`) : e;
|
|
821
1016
|
}
|
|
822
1017
|
}
|
|
823
|
-
},
|
|
824
|
-
//#endregion
|
|
825
|
-
//#region src/pickFeedItemRichText.ts
|
|
826
|
-
function W(e, t) {
|
|
827
|
-
for (let n of t) {
|
|
828
|
-
let t = e[n];
|
|
829
|
-
if (typeof t == "string" && t.trim() !== "") return t;
|
|
830
|
-
}
|
|
831
|
-
return "";
|
|
832
|
-
}
|
|
833
|
-
var pt = [
|
|
834
|
-
"summary",
|
|
835
|
-
"Summary",
|
|
836
|
-
"description",
|
|
837
|
-
"Description",
|
|
838
|
-
"text",
|
|
839
|
-
"Text"
|
|
840
|
-
], mt = [
|
|
841
|
-
"html",
|
|
842
|
-
"Html",
|
|
843
|
-
"body",
|
|
844
|
-
"Body",
|
|
845
|
-
"content",
|
|
846
|
-
"Content"
|
|
847
|
-
], ht = [
|
|
848
|
-
"summary",
|
|
849
|
-
"Summary",
|
|
850
|
-
"description",
|
|
851
|
-
"Description",
|
|
852
|
-
"text",
|
|
853
|
-
"Text"
|
|
854
|
-
];
|
|
855
|
-
function gt(e, t) {
|
|
856
|
-
let n = c(e.model) - c(t.model);
|
|
857
|
-
if (n !== 0) return n;
|
|
858
|
-
let r = e.key.localeCompare(t.key);
|
|
859
|
-
return r === 0 ? e.index - t.index : r;
|
|
860
|
-
}
|
|
861
|
-
function _t(n) {
|
|
862
|
-
let r = e(n), i = t(n), o = null;
|
|
863
|
-
if (r) for (let [e, t] of Object.entries(r)) {
|
|
864
|
-
if (!a(t)) continue;
|
|
865
|
-
let r = n[e];
|
|
866
|
-
if (typeof r != "string" || r.trim() === "") continue;
|
|
867
|
-
let i = {
|
|
868
|
-
model: t,
|
|
869
|
-
key: e,
|
|
870
|
-
index: 0,
|
|
871
|
-
value: r
|
|
872
|
-
};
|
|
873
|
-
(!o || gt(i, o) < 0) && (o = i);
|
|
874
|
-
}
|
|
875
|
-
if (i) for (let [e, t] of Object.entries(i)) {
|
|
876
|
-
let r = n[e];
|
|
877
|
-
if (!Array.isArray(r)) continue;
|
|
878
|
-
let i = Math.min(t.length, r.length);
|
|
879
|
-
for (let n = 0; n < i; n++) {
|
|
880
|
-
let i = t[n];
|
|
881
|
-
if (!a(i)) continue;
|
|
882
|
-
let s = r[n];
|
|
883
|
-
if (typeof s != "string" || s.trim() === "") continue;
|
|
884
|
-
let c = {
|
|
885
|
-
model: i,
|
|
886
|
-
key: e,
|
|
887
|
-
index: n,
|
|
888
|
-
value: s
|
|
889
|
-
};
|
|
890
|
-
(!o || gt(c, o) < 0) && (o = c);
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
return o?.value ?? "";
|
|
894
|
-
}
|
|
895
|
-
function vt(e) {
|
|
896
|
-
return W(e, pt);
|
|
897
|
-
}
|
|
898
|
-
function yt(e) {
|
|
899
|
-
let t = _t(e);
|
|
900
|
-
if (t !== "") return t;
|
|
901
|
-
let n = W(e, mt);
|
|
902
|
-
return n === "" ? W(e, ht) : n;
|
|
903
|
-
}
|
|
904
|
-
function G(e) {
|
|
905
|
-
return typeof e == "string" && e.includes("data:image/") && e.includes(";base64,");
|
|
906
|
-
}
|
|
907
|
-
function bt(n) {
|
|
908
|
-
let r = e(n);
|
|
909
|
-
if (r) {
|
|
910
|
-
for (let [e, t] of Object.entries(r)) if (a(t) && G(n[e])) return !0;
|
|
911
|
-
}
|
|
912
|
-
let i = t(n);
|
|
913
|
-
if (i) for (let [e, t] of Object.entries(i)) {
|
|
914
|
-
let r = n[e];
|
|
915
|
-
if (!Array.isArray(r)) continue;
|
|
916
|
-
let i = Math.min(t.length, r.length);
|
|
917
|
-
for (let e = 0; e < i; e++) if (a(t[e]) && G(r[e])) return !0;
|
|
918
|
-
}
|
|
919
|
-
return !1;
|
|
920
|
-
}
|
|
921
|
-
function xt(e) {
|
|
922
|
-
if (bt(e)) return !0;
|
|
923
|
-
for (let t of mt) if (G(e[t])) return !0;
|
|
924
|
-
for (let t of pt) if (G(e[t])) return !0;
|
|
925
|
-
return !1;
|
|
926
|
-
}
|
|
927
|
-
function St(e, t = "omit_items") {
|
|
928
|
-
return t === "include_items" ? [...e] : e.filter((e) => !xt(e));
|
|
929
|
-
}
|
|
1018
|
+
}, q = Ce("seedFeed");
|
|
930
1019
|
//#endregion
|
|
931
1020
|
//#region src/index.ts
|
|
932
|
-
function
|
|
1021
|
+
function Ft(e) {
|
|
933
1022
|
return pe(e)?.mediaUrl;
|
|
934
1023
|
}
|
|
935
|
-
function
|
|
1024
|
+
function J(e) {
|
|
936
1025
|
if (typeof e == "number" && Number.isFinite(e) && e > 0) return e;
|
|
937
1026
|
if (typeof e == "string") {
|
|
938
1027
|
let t = Number(e);
|
|
939
1028
|
if (Number.isFinite(t) && t > 0) return t;
|
|
940
1029
|
}
|
|
941
1030
|
}
|
|
942
|
-
function
|
|
1031
|
+
function It(e) {
|
|
943
1032
|
if (Array.isArray(e)) {
|
|
944
1033
|
for (let t of e) {
|
|
945
|
-
let e =
|
|
1034
|
+
let e = It(t);
|
|
946
1035
|
if (e) return e;
|
|
947
1036
|
}
|
|
948
1037
|
return;
|
|
949
1038
|
}
|
|
950
|
-
let t =
|
|
1039
|
+
let t = Ft(e);
|
|
951
1040
|
if (t) {
|
|
952
1041
|
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
953
1042
|
let n = e;
|
|
954
1043
|
return {
|
|
955
1044
|
url: t,
|
|
956
1045
|
mimeType: typeof n.mimeType == "string" && n.mimeType || typeof n.type == "string" && n.type || typeof n.contentType == "string" && n.contentType || void 0,
|
|
957
|
-
width:
|
|
958
|
-
height:
|
|
959
|
-
size:
|
|
1046
|
+
width: J(n.width),
|
|
1047
|
+
height: J(n.height),
|
|
1048
|
+
size: J(n.size ?? n.fileSize),
|
|
960
1049
|
format: typeof n.format == "string" ? n.format : void 0
|
|
961
1050
|
};
|
|
962
1051
|
}
|
|
963
1052
|
return { url: t };
|
|
964
1053
|
}
|
|
965
1054
|
}
|
|
966
|
-
function
|
|
1055
|
+
function Y(e) {
|
|
967
1056
|
if (e._hasImage && e._imageMetadata && typeof e._imageMetadata == "object") {
|
|
968
1057
|
let t = e._imageMetadata;
|
|
969
1058
|
if (t.url) return {
|
|
@@ -987,11 +1076,11 @@ function q(e) {
|
|
|
987
1076
|
"thumbnailImage"
|
|
988
1077
|
]) {
|
|
989
1078
|
if (!(t in e)) continue;
|
|
990
|
-
let n =
|
|
1079
|
+
let n = It(e[t]);
|
|
991
1080
|
if (n) return n;
|
|
992
1081
|
}
|
|
993
1082
|
}
|
|
994
|
-
function
|
|
1083
|
+
function Lt(e, t, n, r, i, a) {
|
|
995
1084
|
let o = n.mimeType || "image/jpeg";
|
|
996
1085
|
e.enclosures = [{
|
|
997
1086
|
url: n.url,
|
|
@@ -1027,15 +1116,15 @@ function Tt(e, t, n, r, i, a) {
|
|
|
1027
1116
|
"media:description": l
|
|
1028
1117
|
}], 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}`);
|
|
1029
1118
|
}
|
|
1030
|
-
var
|
|
1031
|
-
function
|
|
1032
|
-
return
|
|
1119
|
+
var X = null;
|
|
1120
|
+
function Z() {
|
|
1121
|
+
return X ||= new kt(At()), X;
|
|
1033
1122
|
}
|
|
1034
|
-
function
|
|
1035
|
-
|
|
1123
|
+
function Rt() {
|
|
1124
|
+
X = null;
|
|
1036
1125
|
}
|
|
1037
|
-
var
|
|
1038
|
-
async function
|
|
1126
|
+
var zt = 8;
|
|
1127
|
+
async function Bt(e, t) {
|
|
1039
1128
|
let n = 0;
|
|
1040
1129
|
await Promise.all(Array.from({ length: Math.min(t, e.length) }, async () => {
|
|
1041
1130
|
for (; n < e.length;) {
|
|
@@ -1044,28 +1133,28 @@ async function Ot(e, t) {
|
|
|
1044
1133
|
}
|
|
1045
1134
|
}));
|
|
1046
1135
|
}
|
|
1047
|
-
async function
|
|
1136
|
+
async function Vt(e, t, n) {
|
|
1048
1137
|
let r = await n.getImageMetadata(e);
|
|
1049
1138
|
if (r) return r;
|
|
1050
|
-
|
|
1139
|
+
q("detecting image for transaction %s", e);
|
|
1051
1140
|
let i = await t.detectImage(e);
|
|
1052
1141
|
return i && await n.setImageMetadata(e, i), i;
|
|
1053
1142
|
}
|
|
1054
|
-
function
|
|
1143
|
+
function Ht(e) {
|
|
1055
1144
|
if (i(e)) return new URL(e).pathname.replace(/^\//, "");
|
|
1056
1145
|
}
|
|
1057
|
-
function
|
|
1146
|
+
function Ut(e, t) {
|
|
1058
1147
|
let n = e;
|
|
1059
1148
|
if (t === "image") return n.storageTransactionId || n.storage_transaction_id;
|
|
1060
|
-
let r =
|
|
1061
|
-
if (!(!r || r.width && r.height && r.mimeType)) return
|
|
1149
|
+
let r = Y(n);
|
|
1150
|
+
if (!(!r || r.width && r.height && r.mimeType)) return Ht(r.url);
|
|
1062
1151
|
}
|
|
1063
|
-
async function
|
|
1064
|
-
let i = e, a =
|
|
1152
|
+
async function Wt(e, t, n, r) {
|
|
1153
|
+
let i = e, a = Ut(e, t);
|
|
1065
1154
|
if (a) try {
|
|
1066
|
-
let e = await
|
|
1155
|
+
let e = await Vt(a, n, r);
|
|
1067
1156
|
if (!e?.isImage) return;
|
|
1068
|
-
let o = t === "image" ? void 0 :
|
|
1157
|
+
let o = t === "image" ? void 0 : Y(i);
|
|
1069
1158
|
i._imageMetadata = o ? {
|
|
1070
1159
|
...e,
|
|
1071
1160
|
url: o.url
|
|
@@ -1074,20 +1163,20 @@ async function Mt(e, t, n, r) {
|
|
|
1074
1163
|
console.warn(`Error enriching item with transaction ${a}:`, e);
|
|
1075
1164
|
}
|
|
1076
1165
|
}
|
|
1077
|
-
async function
|
|
1078
|
-
let i = e.filter((e) =>
|
|
1079
|
-
return
|
|
1166
|
+
async function Gt(e, t, n, r) {
|
|
1167
|
+
let i = e.filter((e) => Ut(e, t));
|
|
1168
|
+
return q("enriching %d items with image metadata", i.length), await Bt(i.map((e) => () => Wt(e, t, n, r)), zt), e;
|
|
1080
1169
|
}
|
|
1081
|
-
async function
|
|
1170
|
+
async function Kt(e, t, n) {
|
|
1082
1171
|
let r = n.getConfig().imageMetadata;
|
|
1083
|
-
return r?.enabled ?
|
|
1172
|
+
return r?.enabled ? Gt(e, t, new Pt({
|
|
1084
1173
|
gateways: r.gateways,
|
|
1085
1174
|
timeout: r.timeout
|
|
1086
1175
|
}), n) : e;
|
|
1087
1176
|
}
|
|
1088
|
-
function
|
|
1177
|
+
function qt(e, t) {
|
|
1089
1178
|
let { itemUrlBase: n, itemUrlPath: r, richTextDataUriImages: i = "omit_items" } = t;
|
|
1090
|
-
return
|
|
1179
|
+
return Qe(e, i).map((e) => {
|
|
1091
1180
|
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;
|
|
1092
1181
|
if (e.pubDate || e.PubDate) {
|
|
1093
1182
|
let t = e.pubDate || e.PubDate;
|
|
@@ -1097,7 +1186,7 @@ function Ft(e, t) {
|
|
|
1097
1186
|
let t = e.publishedAt || e.createdAt || e.updatedAt;
|
|
1098
1187
|
o = t && typeof t == "object" && t.constructor === Date ? t : new Date(t);
|
|
1099
1188
|
} else o = /* @__PURE__ */ new Date();
|
|
1100
|
-
let s =
|
|
1189
|
+
let s = A(e), c = j(e), l = {
|
|
1101
1190
|
...e,
|
|
1102
1191
|
id: t,
|
|
1103
1192
|
title: e.title || e.Title || "Untitled",
|
|
@@ -1117,12 +1206,12 @@ function Ft(e, t) {
|
|
|
1117
1206
|
}), l;
|
|
1118
1207
|
});
|
|
1119
1208
|
}
|
|
1120
|
-
function
|
|
1209
|
+
function Q(e) {
|
|
1121
1210
|
let t = e instanceof Date ? e : typeof e == "string" && e.trim() ? new Date(e) : void 0;
|
|
1122
1211
|
return t && Number.isFinite(t.getTime()) ? t : void 0;
|
|
1123
1212
|
}
|
|
1124
|
-
var
|
|
1125
|
-
let l = T(c), u = v(t), d = `${l.feedUrl}/${u}/${n}`, f = r ? `${d}?v=${r}` : d, p = `${l.title} - ${
|
|
1213
|
+
var Jt = (e, t, n, r, i, a, o, s, c) => {
|
|
1214
|
+
let l = T(c), u = v(t), d = `${l.feedUrl}/${u}/${n}`, f = r ? `${d}?v=${r}` : d, p = `${l.title} - ${Zt(u)}`, m = /* @__PURE__ */ new Date(), h = E(), g = [];
|
|
1126
1215
|
if (i) {
|
|
1127
1216
|
let e = i.baseUrl.replace(/\?.*$/, ""), t = e.includes("?") ? "&" : "?";
|
|
1128
1217
|
i.hasNext && g.push({
|
|
@@ -1140,7 +1229,7 @@ var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1140
1229
|
rel: e.rel,
|
|
1141
1230
|
href: e.href
|
|
1142
1231
|
});
|
|
1143
|
-
let _ =
|
|
1232
|
+
let _ = qt(e, {
|
|
1144
1233
|
schemaName: t,
|
|
1145
1234
|
itemUrlBase: h.itemUrlBase,
|
|
1146
1235
|
itemUrlPath: h.itemUrlPath,
|
|
@@ -1172,7 +1261,7 @@ var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1172
1261
|
entries: _.map((e) => {
|
|
1173
1262
|
let t = {
|
|
1174
1263
|
...e,
|
|
1175
|
-
updated:
|
|
1264
|
+
updated: Q(e.updated) ?? Q(e.date) ?? Q(e.pubDate) ?? m,
|
|
1176
1265
|
links: e.links ?? (e.link ? [{ href: e.link }] : []),
|
|
1177
1266
|
id: e.guid || e.id || e.link
|
|
1178
1267
|
};
|
|
@@ -1196,7 +1285,7 @@ var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1196
1285
|
return t;
|
|
1197
1286
|
})
|
|
1198
1287
|
};
|
|
1199
|
-
return Promise.resolve(
|
|
1288
|
+
return Promise.resolve(ve(t));
|
|
1200
1289
|
}
|
|
1201
1290
|
case "json": {
|
|
1202
1291
|
let e = i?.hasNext ? `${i.baseUrl.replace(/\?.*$/, "")}?page=${i.page + 1}` : void 0, t = {
|
|
@@ -1227,7 +1316,7 @@ var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1227
1316
|
}
|
|
1228
1317
|
return t;
|
|
1229
1318
|
})
|
|
1230
|
-
}, n =
|
|
1319
|
+
}, n = ye(t);
|
|
1231
1320
|
return Promise.resolve(typeof n == "string" ? n : JSON.stringify(n));
|
|
1232
1321
|
}
|
|
1233
1322
|
default: {
|
|
@@ -1255,8 +1344,8 @@ var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1255
1344
|
value: e.id,
|
|
1256
1345
|
isPermaLink: typeof e.id == "string" && (e.id.startsWith("http://") || e.id.startsWith("https://"))
|
|
1257
1346
|
});
|
|
1258
|
-
let r =
|
|
1259
|
-
r &&
|
|
1347
|
+
let r = Y(e);
|
|
1348
|
+
r && Lt(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);
|
|
1260
1349
|
let i = {};
|
|
1261
1350
|
if (n.dc = i, (e.date || e.pubDate) && (i.date = e.date || e.pubDate), e.timeCreated) {
|
|
1262
1351
|
let t = /* @__PURE__ */ new Date(Number(e.timeCreated) * 1e3);
|
|
@@ -1265,18 +1354,18 @@ var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1265
1354
|
return (e.seedUid || e.SeedUid) && (i.identifier ||= [], i.identifier.push(e.seedUid || e.SeedUid)), (e.storageTransactionId || e.storage_transaction_id) && (i.identifier ||= [], i.identifier.push(e.storageTransactionId || e.storage_transaction_id)), (e.import_url || e.importUrl) && (i.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;
|
|
1266
1355
|
})
|
|
1267
1356
|
};
|
|
1268
|
-
return Promise.resolve(
|
|
1357
|
+
return Promise.resolve(Et(e));
|
|
1269
1358
|
}
|
|
1270
1359
|
}
|
|
1271
1360
|
};
|
|
1272
|
-
function
|
|
1361
|
+
function Yt(e) {
|
|
1273
1362
|
switch (e) {
|
|
1274
1363
|
case "atom": return "application/atom+xml; charset=utf-8";
|
|
1275
1364
|
case "json": return "application/feed+json; charset=utf-8";
|
|
1276
1365
|
default: return "application/rss+xml; charset=utf-8";
|
|
1277
1366
|
}
|
|
1278
1367
|
}
|
|
1279
|
-
function
|
|
1368
|
+
function Xt(e) {
|
|
1280
1369
|
let t = e.toLowerCase();
|
|
1281
1370
|
return [
|
|
1282
1371
|
"rss",
|
|
@@ -1284,46 +1373,46 @@ function Lt(e) {
|
|
|
1284
1373
|
"json"
|
|
1285
1374
|
].includes(t) ? t : null;
|
|
1286
1375
|
}
|
|
1287
|
-
function
|
|
1376
|
+
function Zt(e) {
|
|
1288
1377
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1289
1378
|
}
|
|
1290
|
-
function
|
|
1291
|
-
return
|
|
1379
|
+
function Qt(e) {
|
|
1380
|
+
return K(JSON.stringify(e));
|
|
1292
1381
|
}
|
|
1293
|
-
function
|
|
1294
|
-
return
|
|
1382
|
+
function $t(e) {
|
|
1383
|
+
return K(JSON.stringify([
|
|
1295
1384
|
e.sourceEtag ?? null,
|
|
1296
1385
|
e.siteConfig,
|
|
1297
1386
|
e.cacheBust ?? null
|
|
1298
1387
|
]));
|
|
1299
1388
|
}
|
|
1300
|
-
function
|
|
1389
|
+
function en(e, t, n, r = {}) {
|
|
1301
1390
|
let i = {
|
|
1302
1391
|
ETag: t.etag,
|
|
1303
1392
|
"Last-Modified": (/* @__PURE__ */ new Date(t.lastModified * 1e3)).toUTCString(),
|
|
1304
1393
|
"Cache-Control": `public, max-age=${e.maxAge}, s-maxage=${e.maxAge}, must-revalidate`,
|
|
1305
1394
|
...r
|
|
1306
1395
|
};
|
|
1307
|
-
return n !== 304 && (i["Content-Type"] = t.contentType ??
|
|
1396
|
+
return n !== 304 && (i["Content-Type"] = t.contentType ?? Yt(e.format), i["X-Feed-Schema"] = e.schemaName, i["X-Feed-Format"] = e.format), new Response(n === 304 ? null : t.content, {
|
|
1308
1397
|
status: n,
|
|
1309
1398
|
headers: i
|
|
1310
1399
|
});
|
|
1311
1400
|
}
|
|
1312
1401
|
function $(e, t, n, r) {
|
|
1313
|
-
return e.ifNoneMatch &&
|
|
1402
|
+
return e.ifNoneMatch && Nt(e.ifNoneMatch, t.etag) ? (q("%s for %s:%s, 304", n, e.schemaName, e.format), en(e, {
|
|
1314
1403
|
...t,
|
|
1315
1404
|
content: null
|
|
1316
|
-
}, 304)) : (
|
|
1405
|
+
}, 304)) : (q("%s for %s:%s", n, e.schemaName, e.format), en(e, t, 200, {
|
|
1317
1406
|
"X-Cache": n,
|
|
1318
1407
|
...r
|
|
1319
1408
|
}));
|
|
1320
1409
|
}
|
|
1321
|
-
async function
|
|
1322
|
-
let { schemaName: t, format: n, contentKeyOptions: r } = e, i =
|
|
1410
|
+
async function tn(e) {
|
|
1411
|
+
let { schemaName: t, format: n, contentKeyOptions: r } = e, i = Z(), a = i.getConfig().enabled;
|
|
1323
1412
|
try {
|
|
1324
1413
|
let o;
|
|
1325
1414
|
e.revalidate && (o = await e.fetchItems());
|
|
1326
|
-
let s =
|
|
1415
|
+
let s = $t({
|
|
1327
1416
|
sourceEtag: o?.sourceEtag,
|
|
1328
1417
|
siteConfig: e.siteConfig,
|
|
1329
1418
|
cacheBust: e.cacheBust
|
|
@@ -1332,15 +1421,15 @@ async function Vt(e) {
|
|
|
1332
1421
|
let a = await i.getFeedContent(t, n, r, { fingerprint: s });
|
|
1333
1422
|
if (a) return $(e, a, "HIT");
|
|
1334
1423
|
}
|
|
1335
|
-
o ??= await e.fetchItems(),
|
|
1336
|
-
let c = await e.render(o.items), l =
|
|
1424
|
+
o ??= await e.fetchItems(), q("building %s:%s from %d items", t, n, o.items.length);
|
|
1425
|
+
let c = await e.render(o.items), l = Yt(n), u = o.sourceEtag ? K(`${s}:${G(t, n, r)}`) : K(c), d = a ? await i.setFeedContent(t, n, {
|
|
1337
1426
|
content: c,
|
|
1338
1427
|
contentType: l,
|
|
1339
1428
|
etag: u,
|
|
1340
1429
|
fingerprint: s,
|
|
1341
|
-
siteFingerprint:
|
|
1430
|
+
siteFingerprint: Qt(e.siteConfig)
|
|
1342
1431
|
}, r) : null;
|
|
1343
|
-
return d ? $(e, d, "MISS") :
|
|
1432
|
+
return d ? $(e, d, "MISS") : en(e, {
|
|
1344
1433
|
content: c,
|
|
1345
1434
|
contentType: l,
|
|
1346
1435
|
etag: u,
|
|
@@ -1348,7 +1437,7 @@ async function Vt(e) {
|
|
|
1348
1437
|
}, 200);
|
|
1349
1438
|
} catch (o) {
|
|
1350
1439
|
if (console.error(`Feed generation error for ${t}:${n}:`, o), a) {
|
|
1351
|
-
let a = await i.getFeedContent(t, n, r, { siteFingerprint:
|
|
1440
|
+
let a = await i.getFeedContent(t, n, r, { siteFingerprint: Qt(e.siteConfig) });
|
|
1352
1441
|
if (a) return $(e, a, "STALE", { Warning: "110 - \"Response is stale\"" });
|
|
1353
1442
|
}
|
|
1354
1443
|
return new Response(JSON.stringify({
|
|
@@ -1360,17 +1449,17 @@ async function Vt(e) {
|
|
|
1360
1449
|
});
|
|
1361
1450
|
}
|
|
1362
1451
|
}
|
|
1363
|
-
function
|
|
1452
|
+
function nn(e) {
|
|
1364
1453
|
return new Response(JSON.stringify({ error: `Invalid feed format: ${e}` }), {
|
|
1365
1454
|
status: 400,
|
|
1366
1455
|
headers: { "Content-Type": "application/json" }
|
|
1367
1456
|
});
|
|
1368
1457
|
}
|
|
1369
|
-
async function
|
|
1370
|
-
let s =
|
|
1371
|
-
if (!s) return
|
|
1372
|
-
let c = v.singular(e.toLowerCase()), l = v(c), u = T(o), d = Math.max(1, a ?? 1), f = E().pageSize, p =
|
|
1373
|
-
return
|
|
1458
|
+
async function rn(e, t, r, i, a, o) {
|
|
1459
|
+
let s = Xt(t);
|
|
1460
|
+
if (!s) return nn(t);
|
|
1461
|
+
let c = v.singular(e.toLowerCase()), l = v(c), u = T(o), d = Math.max(1, a ?? 1), f = E().pageSize, p = Z(), m = !1;
|
|
1462
|
+
return tn({
|
|
1374
1463
|
schemaName: c,
|
|
1375
1464
|
format: s,
|
|
1376
1465
|
contentKeyOptions: d > 1 ? { page: d } : void 0,
|
|
@@ -1380,7 +1469,7 @@ async function Ut(e, t, r, i, a, o) {
|
|
|
1380
1469
|
maxAge: d === 1 ? n().getConfig().maxAge ?? 0 : 3600,
|
|
1381
1470
|
revalidate: d === 1,
|
|
1382
1471
|
fetchItems: async () => {
|
|
1383
|
-
let { items: e, etag: t } = await
|
|
1472
|
+
let { items: e, etag: t } = await O(c, {
|
|
1384
1473
|
limit: f + 1,
|
|
1385
1474
|
skip: (d - 1) * f
|
|
1386
1475
|
});
|
|
@@ -1398,7 +1487,7 @@ async function Ut(e, t, r, i, a, o) {
|
|
|
1398
1487
|
href: `${u.feedUrl}/${l}/archive/${n.getUTCFullYear()}/${n.getUTCMonth() + 1}/${s}`
|
|
1399
1488
|
});
|
|
1400
1489
|
}
|
|
1401
|
-
return
|
|
1490
|
+
return Jt(await Kt(e, c, p), c, s, i, {
|
|
1402
1491
|
page: d,
|
|
1403
1492
|
pageSize: f,
|
|
1404
1493
|
hasNext: m,
|
|
@@ -1407,7 +1496,7 @@ async function Ut(e, t, r, i, a, o) {
|
|
|
1407
1496
|
}
|
|
1408
1497
|
});
|
|
1409
1498
|
}
|
|
1410
|
-
async function
|
|
1499
|
+
async function an(e, t, n, r, i, a, o) {
|
|
1411
1500
|
if (!Number.isInteger(t) || t < 1970 || t > 2100) return new Response(JSON.stringify({ error: `Invalid year: ${t}` }), {
|
|
1412
1501
|
status: 400,
|
|
1413
1502
|
headers: { "Content-Type": "application/json" }
|
|
@@ -1416,10 +1505,10 @@ async function Wt(e, t, n, r, i, a, o) {
|
|
|
1416
1505
|
status: 400,
|
|
1417
1506
|
headers: { "Content-Type": "application/json" }
|
|
1418
1507
|
});
|
|
1419
|
-
let s =
|
|
1420
|
-
if (!s) return
|
|
1421
|
-
let c = v.singular(e.toLowerCase()), l = v(c), u = T(o), d =
|
|
1422
|
-
return
|
|
1508
|
+
let s = Xt(r);
|
|
1509
|
+
if (!s) return nn(r);
|
|
1510
|
+
let c = v.singular(e.toLowerCase()), l = v(c), u = T(o), d = Z();
|
|
1511
|
+
return tn({
|
|
1423
1512
|
schemaName: c,
|
|
1424
1513
|
format: s,
|
|
1425
1514
|
contentKeyOptions: { archive: {
|
|
@@ -1431,7 +1520,7 @@ async function Wt(e, t, n, r, i, a, o) {
|
|
|
1431
1520
|
cacheBust: a,
|
|
1432
1521
|
maxAge: 86400,
|
|
1433
1522
|
revalidate: !1,
|
|
1434
|
-
fetchItems: async () => ({ items: await
|
|
1523
|
+
fetchItems: async () => ({ items: await Le(c, t, n) }),
|
|
1435
1524
|
render: async (e) => {
|
|
1436
1525
|
let r = `${u.feedUrl}/${l}/${s}`, i = `${u.feedUrl}/${l}/archive`, f = [{
|
|
1437
1526
|
rel: "prev-archive",
|
|
@@ -1443,11 +1532,11 @@ async function Wt(e, t, n, r, i, a, o) {
|
|
|
1443
1532
|
return (p < h.getUTCFullYear() || p === h.getUTCFullYear() && m <= h.getUTCMonth() + 1) && f.push({
|
|
1444
1533
|
rel: "next-archive",
|
|
1445
1534
|
href: `${i}/${p}/${m}/${s}`
|
|
1446
|
-
}),
|
|
1535
|
+
}), Jt(await Kt(e, c, d), c, s, a, void 0, f, !0, void 0, o);
|
|
1447
1536
|
}
|
|
1448
1537
|
});
|
|
1449
1538
|
}
|
|
1450
1539
|
//#endregion
|
|
1451
|
-
export { d as DEFAULT_ARWEAVE_HOST, S as DEFAULT_SITE_CONFIG, f as SEED_RSS_IMAGE_RELATION_FIELD_KEYS, m as classifyMediaRef,
|
|
1540
|
+
export { d as DEFAULT_ARWEAVE_HOST, S as DEFAULT_SITE_CONFIG, f as SEED_RSS_IMAGE_RELATION_FIELD_KEYS, m as classifyMediaRef, Jt as createFeed, Ze as feedItemRichTextContainsDataUriImage, O as fetchFeedItemsBySchemaName, Qe as filterItemsByRichTextDataUriImagePolicy, ee as getFeedItemStringField, Ie as getFeedItemsBySchemaName, Le as getFeedItemsBySchemaNameForMonth, Te as getSiteConfig, an as handleArchiveFeedRequest, rn as handleFeedRequest, et as htmlToMarkdown, x as initializeFeedPlatform, re as isEasAttestationExplorerUrl, it as itemMarkdown, st as llmsTxt, ct as llmsTxtItemLinks, E as loadFeedConfig, ae as normalizeFeedItemFields, We as parseRssString, j as pickFeedItemContent, A as pickFeedItemDescription, Rt as resetCacheManager, De as resetSiteConfig, de as resolveSeedRssImageRelationFromItem, fe as resolveSeedRssImageRelationRef, T as resolveSiteConfig, Ee as setSiteConfig, we as teardownFeedPlatform };
|
|
1452
1541
|
|
|
1453
1542
|
//# sourceMappingURL=index.js.map
|