@seedprotocol/feed 0.7.9-next.1189.g5e63267 → 0.7.9
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 +7 -2
- package/dist/bootstrap.d.ts +7 -7
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/cache/CacheManager.d.ts +14 -12
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/FileCache.d.ts +0 -2
- package/dist/cache/FileCache.d.ts.map +1 -1
- package/dist/cache/MemoryCache.d.ts +2 -8
- package/dist/cache/MemoryCache.d.ts.map +1 -1
- package/dist/cache/config.d.ts +0 -2
- package/dist/cache/config.d.ts.map +1 -1
- package/dist/cache/types.d.ts +8 -13
- package/dist/cache/types.d.ts.map +1 -1
- package/dist/config.d.ts +4 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/debug.d.ts +4 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/getFeedItems.d.ts +13 -2
- package/dist/getFeedItems.d.ts.map +1 -1
- package/dist/index.d.ts +10 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +527 -639
- package/dist/index.js.map +1 -1
- package/dist/services/arweaveImageService.d.ts +8 -5
- package/dist/services/arweaveImageService.d.ts.map +1 -1
- package/dist/types.d.ts +6 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/etag.d.ts +0 -4
- package/dist/utils/etag.d.ts.map +1 -1
- package/package.json +5 -7
- package/dist/feedFieldStorageModel.d.ts +0 -3
- package/dist/feedFieldStorageModel.d.ts.map +0 -1
- package/dist/hydrateArweaveRichText.d.ts +0 -2
- package/dist/hydrateArweaveRichText.d.ts.map +0 -1
- package/dist/imageRelationEnrichment.d.ts +0 -2
- package/dist/imageRelationEnrichment.d.ts.map +0 -1
- package/dist/listRelationKey.d.ts +0 -2
- package/dist/listRelationKey.d.ts.map +0 -1
- package/dist/parseEasPropertyMetadataForFeed.d.ts +0 -3
- package/dist/parseEasPropertyMetadataForFeed.d.ts.map +0 -1
- package/dist/utils/arweaveUrl.d.ts +0 -2
- package/dist/utils/arweaveUrl.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,38 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseArweaveClient as
|
|
3
|
-
import { getEasChainDeployment as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { generateAtomFeed as
|
|
7
|
-
import { create as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
1
|
+
import { getArweaveUrlForTransaction as e, getFieldStorageModels as t, getListElementStorageModels as n, getQueryCacheManager as r, initializeQueryPlatform as i, isArweaveTransactionGatewayUrl as a, isRichBodyStorageSchema as o, queryBySchema as s, queryBySchemaForMonth as c, richBodyModelPriority as l, teardownQueryPlatform as u } from "@seedprotocol/query";
|
|
2
|
+
import { BaseArweaveClient as d, DEFAULT_ARWEAVE_HOST as f, SEED_RSS_IMAGE_RELATION_FIELD_KEYS as p, classifyMediaRef as m, ensureArweaveReadGatewayForFallback as h, getArweaveReadBaseUrls as g, getArweaveReadGatewayHostsForPrimary as _, getFeedItemStringField as ee, isEasAttestationExplorerUrl as te, isGatewayHostCircuitOpen as ne, normalizeFeedItemFields as re, recordGatewayHostFailure as ie, recordGatewayHostSuccess as ae, resolveArweaveHostFromEnv as oe, resolveSeedRssImageRelationFromItem as se, resolveSeedRssImageRelationRef as ce, resolveSeedRssImageRelationRef as le } from "@seedprotocol/arweave";
|
|
3
|
+
import { getEasChainDeployment as ue, getEasReadChainId as de } from "@seedprotocol/eas";
|
|
4
|
+
import fe from "rss-parser";
|
|
5
|
+
import v from "pluralize";
|
|
6
|
+
import { generateAtomFeed as pe, generateJsonFeed as me } from "feedsmith";
|
|
7
|
+
import { create as he } from "xmlbuilder2";
|
|
8
|
+
import { promises as y } from "fs";
|
|
9
|
+
import { join as b } from "path";
|
|
10
|
+
import { createHash as ge } from "crypto";
|
|
11
|
+
import _e from "image-size";
|
|
12
|
+
import ve from "debug";
|
|
12
13
|
//#region src/bootstrap.ts
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return e ?? te() ?? d;
|
|
16
|
-
}
|
|
17
|
-
async function E(e) {
|
|
18
|
-
if (T) return;
|
|
19
|
-
let [{ registerNodeEasPlatform: t }, { registerNodeArweavePlatform: n }] = await Promise.all([import("@seedprotocol/eas/node"), import("@seedprotocol/arweave/node")]);
|
|
20
|
-
if (t(), n({ arweaveDomain: pe(e?.arweaveDomain) }), e?.arweaveDomain) {
|
|
21
|
-
let { BaseArweaveClient: t } = await import("@seedprotocol/arweave");
|
|
22
|
-
t.setHost(e.arweaveDomain);
|
|
23
|
-
}
|
|
24
|
-
T = !0;
|
|
25
|
-
}
|
|
26
|
-
var me = E;
|
|
27
|
-
async function he() {
|
|
28
|
-
return await E(), { isInitialized: () => T };
|
|
14
|
+
async function x(e) {
|
|
15
|
+
await i(e);
|
|
29
16
|
}
|
|
30
|
-
async function
|
|
31
|
-
|
|
17
|
+
async function ye() {
|
|
18
|
+
await u();
|
|
32
19
|
}
|
|
33
20
|
//#endregion
|
|
34
21
|
//#region src/config.ts
|
|
35
|
-
var
|
|
22
|
+
var S = {
|
|
36
23
|
title: "Seed Protocol",
|
|
37
24
|
description: "Content published via Seed Protocol",
|
|
38
25
|
siteUrl: "https://seedprotocol.io",
|
|
@@ -45,15 +32,15 @@ var D = {
|
|
|
45
32
|
link: "https://seedprotocol.io"
|
|
46
33
|
}
|
|
47
34
|
};
|
|
48
|
-
function
|
|
35
|
+
function C(e) {
|
|
49
36
|
return {
|
|
50
37
|
...e,
|
|
51
38
|
author: e.author ? { ...e.author } : void 0
|
|
52
39
|
};
|
|
53
40
|
}
|
|
54
|
-
var
|
|
55
|
-
function
|
|
56
|
-
if (!e) return
|
|
41
|
+
var w = C(S);
|
|
42
|
+
function T(e, t = w) {
|
|
43
|
+
if (!e) return C(t);
|
|
57
44
|
let n = {
|
|
58
45
|
...t,
|
|
59
46
|
...e,
|
|
@@ -65,28 +52,26 @@ function A(e, t = k) {
|
|
|
65
52
|
name: e.author.name ?? n.author?.name ?? ""
|
|
66
53
|
}), n;
|
|
67
54
|
}
|
|
68
|
-
function
|
|
69
|
-
return
|
|
55
|
+
function be() {
|
|
56
|
+
return C(w);
|
|
70
57
|
}
|
|
71
|
-
function
|
|
72
|
-
return
|
|
58
|
+
function xe(e) {
|
|
59
|
+
return w = T(e, S), be();
|
|
73
60
|
}
|
|
74
|
-
function
|
|
75
|
-
|
|
61
|
+
function Se() {
|
|
62
|
+
w = C(S);
|
|
76
63
|
}
|
|
77
|
-
function
|
|
64
|
+
function E() {
|
|
78
65
|
return {
|
|
79
|
-
itemUrlBase: process.env.FEED_ITEM_URL_BASE?.trim() ||
|
|
66
|
+
itemUrlBase: process.env.FEED_ITEM_URL_BASE?.trim() || ue(de())?.explorerUrl || "https://easscan.org",
|
|
80
67
|
itemUrlPath: process.env.FEED_ITEM_URL_PATH?.trim() || "attestation/view",
|
|
81
|
-
|
|
82
|
-
expandRelations: process.env.FEED_EXPAND_RELATIONS?.toLowerCase() !== "false",
|
|
83
|
-
pageSize: parseInt(process.env.FEED_PAGE_SIZE || "25", 10),
|
|
68
|
+
pageSize: Math.max(1, parseInt(process.env.FEED_PAGE_SIZE || "25", 10) || 25),
|
|
84
69
|
richTextDataUriImages: process.env.FEED_INCLUDE_DATA_URI_HTML_ITEMS?.toLowerCase() === "true" ? "include_items" : "omit_items"
|
|
85
70
|
};
|
|
86
71
|
}
|
|
87
72
|
//#endregion
|
|
88
73
|
//#region src/getFeedItems.ts
|
|
89
|
-
var
|
|
74
|
+
var Ce = (e) => {
|
|
90
75
|
let t = /* @__PURE__ */ new Date(e * 1e3), n = [
|
|
91
76
|
"Sun",
|
|
92
77
|
"Mon",
|
|
@@ -110,111 +95,108 @@ var M = (e) => {
|
|
|
110
95
|
"Dec"
|
|
111
96
|
], i = n[t.getUTCDay()], a = r[t.getUTCMonth()], o = t.getUTCFullYear();
|
|
112
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`;
|
|
113
|
-
},
|
|
114
|
-
let { itemUrlBase: a, itemUrlPath: o
|
|
115
|
-
!
|
|
116
|
-
let
|
|
117
|
-
if (
|
|
118
|
-
|
|
98
|
+
}, we = (t, n, r, i) => {
|
|
99
|
+
let { itemUrlBase: a, itemUrlPath: o } = i;
|
|
100
|
+
!t.title && !t.Title ? (t.title = n, t.Title = n) : t.title && !t.Title ? t.Title = t.title : t.Title && !t.title && (t.title = t.Title);
|
|
101
|
+
let s = t.storage_transaction_id && typeof t.storage_transaction_id == "string" && t.storage_transaction_id.trim() !== "" && t.storage_transaction_id !== "undefined" && t.storage_transaction_id !== n ? t.storage_transaction_id.trim() : null, c = t.storageTransactionId && typeof t.storageTransactionId == "string" && t.storageTransactionId.trim() !== "" && t.storageTransactionId !== "undefined" && t.storageTransactionId !== n ? t.storageTransactionId.trim() : null, l = s || c, u = n && typeof n == "string" && n.trim() !== "" ? n : "unknown", d = `${a.replace(/\/$/, "")}/${o.replace(/^\//, "")}/${u}`;
|
|
102
|
+
if (l && l !== n && l.length > 0) try {
|
|
103
|
+
d = e(l);
|
|
119
104
|
} catch (e) {
|
|
120
|
-
console.error("[feed] [setFeedItemDefaults] Error generating Arweave URL:", e)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
e.link = t, e.Link = t;
|
|
105
|
+
console.error("[feed] [setFeedItemDefaults] Error generating Arweave URL:", e);
|
|
106
|
+
}
|
|
107
|
+
let f = t.link || t.Link;
|
|
108
|
+
!f || f === "undefined" || typeof f == "string" && f.trim() === "" ? (t.link = d, t.Link = d) : ((!t.link || t.link === "undefined") && (t.link = f), (!t.Link || t.Link === "undefined") && (t.Link = f));
|
|
109
|
+
let p = t.guid || t.Guid;
|
|
110
|
+
if (!p || p === "undefined" || typeof p == "string" && p.trim() === "" ? (t.guid = t.link || d, t.Guid = t.guid) : ((!t.guid || t.guid === "undefined") && (t.guid = p), (!t.Guid || t.Guid === "undefined") && (t.Guid = p)), t.timeCreated && !t.pubDate && !t.PubDate) {
|
|
111
|
+
let e = Ce(t.timeCreated);
|
|
112
|
+
t.pubDate = e, t.PubDate = e;
|
|
113
|
+
} else t.pubDate && !t.PubDate ? t.PubDate = t.pubDate : t.PubDate && !t.pubDate && (t.pubDate = t.PubDate);
|
|
114
|
+
!t.seedUid && !t.SeedUid ? (t.seedUid = n, t.SeedUid = n) : t.seedUid && !t.SeedUid ? t.SeedUid = t.seedUid : t.SeedUid && !t.seedUid && (t.seedUid = t.SeedUid), t.attester && !t.Attester ? t.Attester = t.attester : t.Attester && !t.attester && (t.attester = t.Attester);
|
|
115
|
+
}, Te = (t, n) => {
|
|
116
|
+
if (!t.title && !t.Title ? (t.title = n, t.Title = n) : t.title && !t.Title ? t.Title = t.title : t.Title && !t.title && (t.title = t.Title), t.timeCreated && !t.pubDate && !t.PubDate) {
|
|
117
|
+
let e = Ce(t.timeCreated);
|
|
118
|
+
t.pubDate = e, t.PubDate = e;
|
|
119
|
+
} else t.pubDate && !t.PubDate ? t.PubDate = t.pubDate : t.PubDate && !t.pubDate && (t.pubDate = t.PubDate);
|
|
120
|
+
!t.seedUid && !t.SeedUid ? (t.seedUid = n, t.SeedUid = n) : t.seedUid && !t.SeedUid ? t.SeedUid = t.seedUid : t.SeedUid && !t.seedUid && (t.seedUid = t.SeedUid), t.attester && !t.Attester ? t.Attester = t.attester : t.Attester && !t.attester && (t.attester = t.Attester);
|
|
121
|
+
let r = t.storage_transaction_id && typeof t.storage_transaction_id == "string" && t.storage_transaction_id.trim() !== "" && t.storage_transaction_id !== "undefined" && t.storage_transaction_id !== n ? t.storage_transaction_id.trim() : null, i = t.storageTransactionId && typeof t.storageTransactionId == "string" && t.storageTransactionId.trim() !== "" && t.storageTransactionId !== "undefined" && t.storageTransactionId !== n ? t.storageTransactionId.trim() : null, a = r || i;
|
|
122
|
+
if (delete t.link, delete t.Link, delete t.guid, delete t.Guid, a && a.length > 0) try {
|
|
123
|
+
let n = e(a);
|
|
124
|
+
t.link = n, t.Link = n;
|
|
141
125
|
} catch {}
|
|
142
126
|
};
|
|
143
|
-
function
|
|
127
|
+
function D(e) {
|
|
144
128
|
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
145
129
|
let t = e;
|
|
146
130
|
return typeof t.seedUid == "string" || typeof t.SeedUid == "string";
|
|
147
131
|
}
|
|
148
|
-
function
|
|
132
|
+
function Ee(e, t, n) {
|
|
149
133
|
let r = { ...e }, i = r.seedUid || r.SeedUid || "", a = typeof r.schemaName == "string" ? r.schemaName : t;
|
|
150
|
-
return a === "image" ?
|
|
134
|
+
return a === "image" ? Te(r, i) : we(r, i, a, n), r;
|
|
151
135
|
}
|
|
152
|
-
function
|
|
136
|
+
function De(e, t, n) {
|
|
153
137
|
let r = { ...e };
|
|
154
|
-
|
|
138
|
+
we(r, r.seedUid || r.SeedUid || "", t, n);
|
|
155
139
|
for (let e of Object.keys(r)) {
|
|
156
140
|
if (e.startsWith("_")) continue;
|
|
157
141
|
let i = r[e];
|
|
158
|
-
Array.isArray(i) ? i.some(
|
|
142
|
+
Array.isArray(i) ? i.some(D) && (r[e] = i.map((e) => D(e) ? Ee(e, t, n) : e)) : D(i) && (r[e] = Ee(i, t, n));
|
|
159
143
|
}
|
|
160
144
|
return r;
|
|
161
145
|
}
|
|
162
|
-
function
|
|
163
|
-
let n =
|
|
146
|
+
function Oe(e, t) {
|
|
147
|
+
let n = E(), r = {
|
|
164
148
|
itemUrlBase: n.itemUrlBase,
|
|
165
|
-
itemUrlPath: n.itemUrlPath
|
|
166
|
-
siteUrl: n.siteUrl
|
|
149
|
+
itemUrlPath: n.itemUrlPath
|
|
167
150
|
};
|
|
168
|
-
return t.map((t) =>
|
|
169
|
-
}
|
|
170
|
-
var
|
|
171
|
-
await
|
|
172
|
-
let n =
|
|
173
|
-
limit:
|
|
174
|
-
skip:
|
|
175
|
-
relations:
|
|
151
|
+
return t.map((t) => De(t.data, e, r));
|
|
152
|
+
}
|
|
153
|
+
var O = async (e, t) => {
|
|
154
|
+
await x();
|
|
155
|
+
let n = t?.limit ?? 100, r = t?.skip ?? 0, { items: i, etag: a } = await s(e, {
|
|
156
|
+
limit: n,
|
|
157
|
+
skip: r,
|
|
158
|
+
relations: "expand",
|
|
176
159
|
hydrateStorage: !0
|
|
177
160
|
});
|
|
178
|
-
return
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
};
|
|
161
|
+
return {
|
|
162
|
+
items: Oe(e, i),
|
|
163
|
+
etag: a
|
|
164
|
+
};
|
|
165
|
+
}, ke = async (e, t) => (await O(e, t)).items, k = async (e, t, n) => (await x(), Oe(e, await c(e, t, n, {
|
|
166
|
+
relations: "expand",
|
|
167
|
+
hydrateStorage: !0
|
|
168
|
+
})));
|
|
187
169
|
//#endregion
|
|
188
170
|
//#region src/consume/parseRss.ts
|
|
189
|
-
function
|
|
171
|
+
function Ae(e) {
|
|
190
172
|
try {
|
|
191
173
|
return JSON.parse(JSON.stringify(e));
|
|
192
174
|
} catch {
|
|
193
175
|
return { ...e };
|
|
194
176
|
}
|
|
195
177
|
}
|
|
196
|
-
var
|
|
178
|
+
var je = new fe({ customFields: { item: [
|
|
197
179
|
"featureImage",
|
|
198
180
|
"feature_image",
|
|
199
181
|
"content:encoded",
|
|
200
182
|
"seedUid",
|
|
201
183
|
"SeedUid"
|
|
202
184
|
] } });
|
|
203
|
-
async function
|
|
204
|
-
let t = await
|
|
185
|
+
async function Me(e) {
|
|
186
|
+
let t = await je.parseString(e);
|
|
205
187
|
return {
|
|
206
188
|
title: t.title,
|
|
207
189
|
link: t.link,
|
|
208
190
|
description: t.description,
|
|
209
|
-
items: (t.items ?? []).map(
|
|
191
|
+
items: (t.items ?? []).map(Ae)
|
|
210
192
|
};
|
|
211
193
|
}
|
|
212
194
|
//#endregion
|
|
213
195
|
//#region src/rss/generateRssXml.ts
|
|
214
|
-
var
|
|
196
|
+
var A = "http://purl.org/dc/elements/1.1/", j = "http://purl.org/rss/1.0/modules/content/", M = "http://search.yahoo.com/mrss/", Ne = { publication: {
|
|
215
197
|
prefix: "publication",
|
|
216
198
|
uri: "https://seedprotocol.io/ns/publication/1.0"
|
|
217
|
-
} },
|
|
199
|
+
} }, Pe = "https://seedprotocol.io/ns/relations", N = /* @__PURE__ */ new Set([
|
|
218
200
|
"xml",
|
|
219
201
|
"xmlns",
|
|
220
202
|
"dc",
|
|
@@ -222,17 +204,17 @@ var I = "http://purl.org/dc/elements/1.1/", L = "http://purl.org/rss/1.0/modules
|
|
|
222
204
|
"content",
|
|
223
205
|
"atom",
|
|
224
206
|
"fh"
|
|
225
|
-
]),
|
|
207
|
+
]), Fe = /* @__PURE__ */ new Set([
|
|
226
208
|
"Title",
|
|
227
209
|
"Link",
|
|
228
210
|
"Guid",
|
|
229
211
|
"PubDate",
|
|
230
212
|
"SeedUid"
|
|
231
213
|
]);
|
|
232
|
-
function
|
|
233
|
-
return
|
|
214
|
+
function Ie(e, t) {
|
|
215
|
+
return Fe.has(e) ? e.charAt(0).toLowerCase() + e.slice(1) in t : !1;
|
|
234
216
|
}
|
|
235
|
-
var
|
|
217
|
+
var P = [
|
|
236
218
|
"title",
|
|
237
219
|
"link",
|
|
238
220
|
"description",
|
|
@@ -256,7 +238,7 @@ var z = [
|
|
|
256
238
|
"media:category",
|
|
257
239
|
"media:group"
|
|
258
240
|
];
|
|
259
|
-
function
|
|
241
|
+
function F(e) {
|
|
260
242
|
if (e instanceof Date) return e.toUTCString();
|
|
261
243
|
if (typeof e == "string") {
|
|
262
244
|
let t = new Date(e);
|
|
@@ -264,13 +246,13 @@ function B(e) {
|
|
|
264
246
|
}
|
|
265
247
|
return String(e);
|
|
266
248
|
}
|
|
267
|
-
function
|
|
249
|
+
function Le(e) {
|
|
268
250
|
return /[<>&]|]]>/.test(e);
|
|
269
251
|
}
|
|
270
|
-
function
|
|
252
|
+
function I(e, t) {
|
|
271
253
|
let n = String(t);
|
|
272
254
|
if (n !== "") {
|
|
273
|
-
if (
|
|
255
|
+
if (Le(n)) {
|
|
274
256
|
if (n.includes("]]>")) {
|
|
275
257
|
let t = n.split("]]>");
|
|
276
258
|
for (let n = 0; n < t.length; n++) e.dat(t[n]), n < t.length - 1 && e.txt("]]>");
|
|
@@ -278,11 +260,11 @@ function V(e, t) {
|
|
|
278
260
|
} else e.txt(n);
|
|
279
261
|
}
|
|
280
262
|
}
|
|
281
|
-
function
|
|
263
|
+
function L(e) {
|
|
282
264
|
return typeof e == "object" && !!e && !Array.isArray(e) && !(e instanceof Date);
|
|
283
265
|
}
|
|
284
|
-
var
|
|
285
|
-
...
|
|
266
|
+
var Re = 4, ze = /* @__PURE__ */ new Set([
|
|
267
|
+
...P,
|
|
286
268
|
"guid",
|
|
287
269
|
"source",
|
|
288
270
|
"dc",
|
|
@@ -290,70 +272,70 @@ var Fe = 4, Ie = /* @__PURE__ */ new Set([
|
|
|
290
272
|
"content:encoded",
|
|
291
273
|
"items"
|
|
292
274
|
]);
|
|
293
|
-
function
|
|
275
|
+
function Be(e) {
|
|
294
276
|
return e.endsWith("s") && e.length > 1 ? e.slice(0, -1) : e;
|
|
295
277
|
}
|
|
296
|
-
function
|
|
278
|
+
function Ve(e) {
|
|
297
279
|
return e.trim().replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^[^A-Za-z_]+/, "").replace(/^$/, "rel").toLowerCase();
|
|
298
280
|
}
|
|
299
|
-
function
|
|
300
|
-
if (!t.has(e) && !
|
|
281
|
+
function He(e, t) {
|
|
282
|
+
if (!t.has(e) && !N.has(e)) return t.add(e), e;
|
|
301
283
|
let n = 2;
|
|
302
284
|
for (;;) {
|
|
303
285
|
let r = `${e}${n}`;
|
|
304
|
-
if (!t.has(r) && !
|
|
286
|
+
if (!t.has(r) && !N.has(r)) return t.add(r), r;
|
|
305
287
|
n += 1;
|
|
306
288
|
}
|
|
307
289
|
}
|
|
308
|
-
function
|
|
309
|
-
return Array.isArray(e) && e.length > 0 && e.every((e) =>
|
|
290
|
+
function R(e) {
|
|
291
|
+
return Array.isArray(e) && e.length > 0 && e.every((e) => L(e));
|
|
310
292
|
}
|
|
311
|
-
function
|
|
312
|
-
let t = { ...
|
|
293
|
+
function Ue(e) {
|
|
294
|
+
let t = { ...Ne }, n = new Set(Object.values(t).map((e) => e.prefix)), r = /* @__PURE__ */ new Set();
|
|
313
295
|
for (let t of e) for (let [e, n] of Object.entries(t)) {
|
|
314
|
-
let t = e === "author" &&
|
|
315
|
-
e.startsWith("_") || (!
|
|
296
|
+
let t = e === "author" && L(n) || e === "authors" && R(n);
|
|
297
|
+
e.startsWith("_") || (!ze.has(e) || t) && (L(n) || R(n)) && r.add(Be(e));
|
|
316
298
|
}
|
|
317
299
|
let i = [...r].sort();
|
|
318
300
|
for (let e of i) t[e] || (t[e] = {
|
|
319
|
-
prefix:
|
|
320
|
-
uri: `${
|
|
301
|
+
prefix: He(Ve(e), n),
|
|
302
|
+
uri: `${Pe}/${e}/1.0`
|
|
321
303
|
});
|
|
322
304
|
return t;
|
|
323
305
|
}
|
|
324
|
-
function
|
|
306
|
+
function z(e, t) {
|
|
325
307
|
if (e in t) return t[e];
|
|
326
308
|
if (e.endsWith("s") && e.length > 1) {
|
|
327
309
|
let n = e.slice(0, -1);
|
|
328
310
|
if (n in t) return t[n];
|
|
329
311
|
}
|
|
330
312
|
}
|
|
331
|
-
function
|
|
313
|
+
function We(e, t) {
|
|
332
314
|
return t ? `${t.prefix}:${e}` : e;
|
|
333
315
|
}
|
|
334
|
-
function
|
|
316
|
+
function B(e, t, n, r, i = 0, a) {
|
|
335
317
|
let o = e.ele(n);
|
|
336
318
|
for (let [e, n] of Object.entries(t)) {
|
|
337
319
|
if (n == null || e.startsWith("_") || e === "items") continue;
|
|
338
|
-
let t =
|
|
339
|
-
if (i >=
|
|
320
|
+
let t = We(e, a);
|
|
321
|
+
if (i >= Re) I(o.ele(t), typeof n == "object" ? JSON.stringify(n) : String(n));
|
|
340
322
|
else if (Array.isArray(n)) {
|
|
341
|
-
let t =
|
|
342
|
-
for (let e of n) e != null && (
|
|
343
|
-
} else
|
|
323
|
+
let t = We(e.endsWith("s") && e.length > 1 ? e.slice(0, -1) : e, a);
|
|
324
|
+
for (let e of n) e != null && (L(e) ? B(o, e, t, !1, i + 1, a) : I(o.ele(t), String(e)));
|
|
325
|
+
} else L(n) ? B(o, n, t, !1, i + 1, a) : I(o.ele(t), String(n));
|
|
344
326
|
}
|
|
345
327
|
if (r) {
|
|
346
328
|
let n = t.name ?? t.seedUid;
|
|
347
|
-
n && e.ele(
|
|
329
|
+
n && e.ele(A, "creator").txt(String(n));
|
|
348
330
|
}
|
|
349
331
|
}
|
|
350
|
-
function
|
|
332
|
+
function Ge(e, t, n, r, i) {
|
|
351
333
|
if (!(n == null || t.startsWith("_")) && t !== "items") {
|
|
352
334
|
if (t === "guid") {
|
|
353
335
|
let t = n, r = t?.value ?? String(n);
|
|
354
336
|
if (!r) return;
|
|
355
337
|
let i = {};
|
|
356
|
-
typeof t?.isPermaLink == "boolean" && (i.isPermaLink = t.isPermaLink ? "true" : "false"),
|
|
338
|
+
typeof t?.isPermaLink == "boolean" && (i.isPermaLink = t.isPermaLink ? "true" : "false"), I(e.ele("guid", i), r);
|
|
357
339
|
} else if (t === "source" && typeof n == "object" && n) {
|
|
358
340
|
let t = n, r = t.title ?? String(n);
|
|
359
341
|
if (!r) return;
|
|
@@ -372,28 +354,28 @@ function Ue(e, t, n, r, i) {
|
|
|
372
354
|
for (let [n, r] of Object.entries(t)) if (r != null) {
|
|
373
355
|
if (Array.isArray(r)) {
|
|
374
356
|
for (let t of r) if (t != null) {
|
|
375
|
-
let r = e.ele(
|
|
376
|
-
t instanceof Date ? r.txt(t.toISOString()) :
|
|
357
|
+
let r = e.ele(A, n);
|
|
358
|
+
t instanceof Date ? r.txt(t.toISOString()) : I(r, String(t));
|
|
377
359
|
}
|
|
378
360
|
} else {
|
|
379
|
-
let t = e.ele(
|
|
380
|
-
r instanceof Date ? t.txt(r.toISOString()) :
|
|
361
|
+
let t = e.ele(A, n);
|
|
362
|
+
r instanceof Date ? t.txt(r.toISOString()) : I(t, String(r));
|
|
381
363
|
}
|
|
382
364
|
}
|
|
383
|
-
} else if (t === "content:encoded")
|
|
384
|
-
else if (t === "content" && typeof n == "string" && !("content:encoded" in r))
|
|
365
|
+
} else if (t === "content:encoded") I(e.ele(j, "encoded"), String(n));
|
|
366
|
+
else if (t === "content" && typeof n == "string" && !("content:encoded" in r)) I(e.ele(j, "encoded"), String(n));
|
|
385
367
|
else if (t !== "content") {
|
|
386
368
|
if (t === "media:group" && Array.isArray(n)) {
|
|
387
369
|
for (let t of n) if (t && typeof t == "object") {
|
|
388
|
-
let n = e.ele(
|
|
370
|
+
let n = e.ele(M, "group");
|
|
389
371
|
for (let [e, r] of Object.entries(t)) if (r != null && e.startsWith("media:")) {
|
|
390
372
|
let t = e.slice(6);
|
|
391
373
|
if (Array.isArray(r)) {
|
|
392
374
|
for (let e of r) if (e && typeof e == "object") {
|
|
393
|
-
let r = n.ele(
|
|
394
|
-
for (let [t, n] of Object.entries(e)) n != null && (t === "url" || t === "value" ?
|
|
375
|
+
let r = n.ele(M, t);
|
|
376
|
+
for (let [t, n] of Object.entries(e)) n != null && (t === "url" || t === "value" ? I(r, String(n)) : r.att(t, String(n)));
|
|
395
377
|
}
|
|
396
|
-
} else typeof r == "string" &&
|
|
378
|
+
} else typeof r == "string" && I(n.ele(M, t), r);
|
|
397
379
|
}
|
|
398
380
|
}
|
|
399
381
|
} else if (t.startsWith("media:") && Array.isArray(n)) {
|
|
@@ -402,17 +384,17 @@ function Ue(e, t, n, r, i) {
|
|
|
402
384
|
if (typeof t != "object" || !t) continue;
|
|
403
385
|
let n = {}, i = null;
|
|
404
386
|
for (let [e, r] of Object.entries(t)) r != null && (e === "value" ? i = String(r) : n[e] = String(r));
|
|
405
|
-
let a = e.ele(
|
|
406
|
-
i !== null &&
|
|
387
|
+
let a = e.ele(M, r, n);
|
|
388
|
+
i !== null && I(a, i);
|
|
407
389
|
}
|
|
408
390
|
} else if (t.startsWith("media:") && typeof n == "string") {
|
|
409
391
|
let r = t.slice(6);
|
|
410
|
-
|
|
411
|
-
} else if (n instanceof Date) e.ele(t).txt(
|
|
412
|
-
else if (t === "author" &&
|
|
392
|
+
I(e.ele(M, r), n);
|
|
393
|
+
} else if (n instanceof Date) e.ele(t).txt(F(n));
|
|
394
|
+
else if (t === "author" && L(n)) B(e, n, "author", !0, 0, z(t, i));
|
|
413
395
|
else if (t === "authors" && Array.isArray(n)) {
|
|
414
|
-
let r =
|
|
415
|
-
for (let t of n) if (t &&
|
|
396
|
+
let r = z(t, i);
|
|
397
|
+
for (let t of n) if (t && L(t)) B(e, t, "author", !0, 0, r);
|
|
416
398
|
else {
|
|
417
399
|
let n = typeof t == "string" ? t : t && typeof t == "object" && "name" in t ? `${t.email ?? ""} (${t.name ?? ""})`.trim() || t.name : String(t);
|
|
418
400
|
n && e.ele("author").txt(n);
|
|
@@ -424,81 +406,62 @@ function Ue(e, t, n, r, i) {
|
|
|
424
406
|
e.ele("category", r).txt(n);
|
|
425
407
|
}
|
|
426
408
|
}
|
|
427
|
-
else if (Array.isArray(n) && n.length > 0 && n.every((e) =>
|
|
428
|
-
let r = t.endsWith("s") ? t.slice(0, -1) : t, a =
|
|
429
|
-
for (let t of n) t &&
|
|
409
|
+
else if (Array.isArray(n) && n.length > 0 && n.every((e) => L(e))) {
|
|
410
|
+
let r = t.endsWith("s") ? t.slice(0, -1) : t, a = z(t, i);
|
|
411
|
+
for (let t of n) t && B(e, t, r, !1, 0, a);
|
|
430
412
|
} else if (Array.isArray(n) && n.every((e) => typeof e == "string")) {
|
|
431
413
|
let r = t.endsWith("s") ? t.slice(0, -1) : t;
|
|
432
|
-
for (let t of n) t &&
|
|
433
|
-
} else
|
|
414
|
+
for (let t of n) t && I(e.ele(r), t);
|
|
415
|
+
} else L(n) ? B(e, n, t, !1, 0, z(t, i)) : I(e.ele(t), String(n));
|
|
434
416
|
}
|
|
435
417
|
}
|
|
436
418
|
}
|
|
437
|
-
var
|
|
438
|
-
function
|
|
439
|
-
let t =
|
|
419
|
+
var Ke = "http://www.w3.org/2005/Atom", qe = "http://purl.org/syndication/history/1.0";
|
|
420
|
+
function Je(e) {
|
|
421
|
+
let t = he({
|
|
440
422
|
version: "1.0",
|
|
441
423
|
encoding: "UTF-8"
|
|
442
|
-
}), n =
|
|
443
|
-
"xmlns:dc":
|
|
444
|
-
"xmlns:content":
|
|
445
|
-
"xmlns:media":
|
|
446
|
-
"xmlns:atom":
|
|
424
|
+
}), n = Ue(e.items), r = {
|
|
425
|
+
"xmlns:dc": A,
|
|
426
|
+
"xmlns:content": j,
|
|
427
|
+
"xmlns:media": M,
|
|
428
|
+
"xmlns:atom": Ke,
|
|
447
429
|
...Object.values(n).reduce((e, t) => (e[`xmlns:${t.prefix}`] = t.uri, e), {})
|
|
448
430
|
};
|
|
449
|
-
e.isArchive && (r["xmlns:fh"] =
|
|
431
|
+
e.isArchive && (r["xmlns:fh"] = qe);
|
|
450
432
|
let i = t.ele("rss", {
|
|
451
433
|
version: "2.0",
|
|
452
434
|
...r
|
|
453
435
|
}).ele("channel", {
|
|
454
|
-
"xmlns:dc":
|
|
455
|
-
"xmlns:content":
|
|
456
|
-
"xmlns:media":
|
|
436
|
+
"xmlns:dc": A,
|
|
437
|
+
"xmlns:content": j,
|
|
438
|
+
"xmlns:media": M
|
|
457
439
|
});
|
|
458
|
-
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(
|
|
440
|
+
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) {
|
|
459
441
|
let e = {
|
|
460
442
|
rel: t.rel,
|
|
461
443
|
href: t.href
|
|
462
444
|
};
|
|
463
|
-
t.type && (e.type = t.type), i.ele(
|
|
445
|
+
t.type && (e.type = t.type), i.ele(Ke, "link", e);
|
|
464
446
|
}
|
|
465
|
-
e.isArchive && i.ele(
|
|
466
|
-
let a = new Set(
|
|
447
|
+
e.isArchive && i.ele(qe, "archive");
|
|
448
|
+
let a = new Set(P);
|
|
467
449
|
for (let t of e.items) {
|
|
468
450
|
let e = i.ele("item"), r = /* @__PURE__ */ new Set();
|
|
469
|
-
for (let i of
|
|
470
|
-
let o = Object.keys(t).filter((e) => !r.has(e) && !a.has(e) && !e.startsWith("_") && !
|
|
471
|
-
for (let r of o)
|
|
451
|
+
for (let i of P) i in t && (Ge(e, i, t[i], t, n), r.add(i));
|
|
452
|
+
let o = Object.keys(t).filter((e) => !r.has(e) && !a.has(e) && !e.startsWith("_") && !Ie(e, t)).sort();
|
|
453
|
+
for (let r of o) Ge(e, r, t[r], t, n);
|
|
472
454
|
}
|
|
473
455
|
return t.end({ prettyPrint: !0 });
|
|
474
456
|
}
|
|
475
457
|
//#endregion
|
|
476
458
|
//#region src/cache/types.ts
|
|
477
|
-
function
|
|
459
|
+
function V(e, t, n) {
|
|
478
460
|
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}`;
|
|
479
461
|
}
|
|
480
462
|
//#endregion
|
|
481
|
-
//#region src/utils/etag.ts
|
|
482
|
-
function qe(e) {
|
|
483
|
-
return `"${de("md5").update(e).digest("hex").substring(0, 16)}"`;
|
|
484
|
-
}
|
|
485
|
-
function Je(e, t, n, r) {
|
|
486
|
-
return qe(`${e}-${t}-${n}-${r}`);
|
|
487
|
-
}
|
|
488
|
-
function Ye(e, t) {
|
|
489
|
-
let n = (e) => e.replace(/^"|"$/g, "");
|
|
490
|
-
return n(e) === n(t);
|
|
491
|
-
}
|
|
492
|
-
function Xe(e) {
|
|
493
|
-
return e ? e.split(",").map((e) => e.trim()).filter((e) => e.length > 0) : [];
|
|
494
|
-
}
|
|
495
|
-
function Ze(e, t) {
|
|
496
|
-
let n = Xe(e);
|
|
497
|
-
return n.length === 0 ? !1 : n.includes("*") ? !0 : n.some((e) => Ye(e, t));
|
|
498
|
-
}
|
|
499
|
-
//#endregion
|
|
500
463
|
//#region src/cache/MemoryCache.ts
|
|
501
|
-
var
|
|
464
|
+
var Ye = class {
|
|
502
465
|
feedContentCache = /* @__PURE__ */ new Map();
|
|
503
466
|
imageMetadataCache = /* @__PURE__ */ new Map();
|
|
504
467
|
config;
|
|
@@ -506,23 +469,11 @@ var Qe = class {
|
|
|
506
469
|
this.config = e;
|
|
507
470
|
}
|
|
508
471
|
getFeedContent(e, t, n) {
|
|
509
|
-
let r =
|
|
472
|
+
let r = V(e, t, n), i = this.feedContentCache.get(r);
|
|
510
473
|
return i ? Math.floor(Date.now() / 1e3) > i.expiresAt ? (this.feedContentCache.delete(r), null) : i : null;
|
|
511
474
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
content: n,
|
|
515
|
-
contentType: r,
|
|
516
|
-
etag: Je(e, t, s, n.length),
|
|
517
|
-
lastModified: s,
|
|
518
|
-
expiresAt: c
|
|
519
|
-
};
|
|
520
|
-
this.feedContentCache.set(o, l);
|
|
521
|
-
}
|
|
522
|
-
clearContentCache(e) {
|
|
523
|
-
let t = [];
|
|
524
|
-
for (let n of this.feedContentCache.keys()) n.startsWith(`${e}:`) && t.push(n);
|
|
525
|
-
t.forEach((e) => this.feedContentCache.delete(e));
|
|
475
|
+
putFeedContent(e, t, n, r) {
|
|
476
|
+
this.feedContentCache.set(V(e, t, r), n);
|
|
526
477
|
}
|
|
527
478
|
getImageMetadata(e) {
|
|
528
479
|
let t = this.imageMetadataCache.get(e);
|
|
@@ -536,22 +487,7 @@ var Qe = class {
|
|
|
536
487
|
};
|
|
537
488
|
this.imageMetadataCache.set(e, r);
|
|
538
489
|
}
|
|
539
|
-
|
|
540
|
-
this.feedContentCache.clear(), this.imageMetadataCache.clear();
|
|
541
|
-
}
|
|
542
|
-
updateConfig(e) {
|
|
543
|
-
this.config = {
|
|
544
|
-
...this.config,
|
|
545
|
-
...e
|
|
546
|
-
};
|
|
547
|
-
}
|
|
548
|
-
getStats() {
|
|
549
|
-
return {
|
|
550
|
-
feedContentCount: this.feedContentCache.size,
|
|
551
|
-
imageMetadataCount: this.imageMetadataCache.size
|
|
552
|
-
};
|
|
553
|
-
}
|
|
554
|
-
}, $e = class {
|
|
490
|
+
}, Xe = class {
|
|
555
491
|
cacheDir;
|
|
556
492
|
config;
|
|
557
493
|
constructor(e) {
|
|
@@ -561,30 +497,30 @@ var Qe = class {
|
|
|
561
497
|
}
|
|
562
498
|
async ensureCacheDir() {
|
|
563
499
|
try {
|
|
564
|
-
await
|
|
500
|
+
await y.mkdir(this.cacheDir, { recursive: !0 });
|
|
565
501
|
} catch (e) {
|
|
566
502
|
if (e.code !== "EEXIST") throw e;
|
|
567
503
|
}
|
|
568
504
|
}
|
|
569
505
|
getFeedContentPath(e, t, n) {
|
|
570
|
-
let r =
|
|
571
|
-
return
|
|
506
|
+
let r = V(e, t, n).replace(/:/g, "-");
|
|
507
|
+
return b(this.cacheDir, `${r}.json`);
|
|
572
508
|
}
|
|
573
509
|
getImageMetadataPath(e) {
|
|
574
|
-
let t =
|
|
575
|
-
return
|
|
510
|
+
let t = b(this.cacheDir, "image-metadata");
|
|
511
|
+
return b(t, `${e}.json`);
|
|
576
512
|
}
|
|
577
513
|
async ensureImageMetadataDir() {
|
|
578
514
|
try {
|
|
579
|
-
let e =
|
|
580
|
-
await
|
|
515
|
+
let e = b(this.cacheDir, "image-metadata");
|
|
516
|
+
await y.mkdir(e, { recursive: !0 });
|
|
581
517
|
} catch (e) {
|
|
582
518
|
if (e.code !== "EEXIST") throw e;
|
|
583
519
|
}
|
|
584
520
|
}
|
|
585
521
|
async getFeedContent(e, t, n) {
|
|
586
522
|
try {
|
|
587
|
-
let r = this.getFeedContentPath(e, t, n), i = await
|
|
523
|
+
let r = this.getFeedContentPath(e, t, n), i = await y.readFile(r, "utf-8"), a = JSON.parse(i);
|
|
588
524
|
return Math.floor(Date.now() / 1e3) > a.expiresAt ? (await this.clearFeedContent(e, t, n), null) : a;
|
|
589
525
|
} catch (n) {
|
|
590
526
|
return n.code === "ENOENT" || console.error(`Error reading feed content cache for ${e}:${t}:`, n), null;
|
|
@@ -594,7 +530,7 @@ var Qe = class {
|
|
|
594
530
|
try {
|
|
595
531
|
await this.ensureCacheDir();
|
|
596
532
|
let i = this.getFeedContentPath(e, t, r);
|
|
597
|
-
await
|
|
533
|
+
await y.writeFile(i, JSON.stringify(n, null, 2), "utf-8");
|
|
598
534
|
} catch (n) {
|
|
599
535
|
console.error(`Error writing feed content cache for ${e}:${t}:`, n);
|
|
600
536
|
}
|
|
@@ -602,22 +538,14 @@ var Qe = class {
|
|
|
602
538
|
async clearFeedContent(e, t, n) {
|
|
603
539
|
try {
|
|
604
540
|
let r = this.getFeedContentPath(e, t, n);
|
|
605
|
-
await
|
|
541
|
+
await y.unlink(r);
|
|
606
542
|
} catch (n) {
|
|
607
543
|
n.code !== "ENOENT" && console.error(`Error clearing feed content cache for ${e}:${t}:`, n);
|
|
608
544
|
}
|
|
609
545
|
}
|
|
610
|
-
async clearAllContentCache(e) {
|
|
611
|
-
try {
|
|
612
|
-
let t = await C.readdir(this.cacheDir), n = `${e}-`;
|
|
613
|
-
for (let r of t) r.startsWith(n) && r.endsWith(".json") && r !== `${e}.json` && await C.unlink(w(this.cacheDir, r));
|
|
614
|
-
} catch (t) {
|
|
615
|
-
console.error(`Error clearing all content cache for ${e}:`, t);
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
546
|
async getImageMetadata(e) {
|
|
619
547
|
try {
|
|
620
|
-
let t = this.getImageMetadataPath(e), n = await
|
|
548
|
+
let t = this.getImageMetadataPath(e), n = await y.readFile(t, "utf-8"), r = JSON.parse(n);
|
|
621
549
|
return Math.floor(Date.now() / 1e3) > r.expiresAt ? (await this.clearImageMetadata(e), null) : r.metadata;
|
|
622
550
|
} catch (t) {
|
|
623
551
|
return t.code === "ENOENT" || console.error(`Error reading image metadata cache for ${e}:`, t), null;
|
|
@@ -631,7 +559,7 @@ var Qe = class {
|
|
|
631
559
|
cachedAt: r,
|
|
632
560
|
expiresAt: r + (this.config.imageMetadata?.ttl || 604800)
|
|
633
561
|
};
|
|
634
|
-
await
|
|
562
|
+
await y.writeFile(n, JSON.stringify(i, null, 2), "utf-8");
|
|
635
563
|
} catch (t) {
|
|
636
564
|
console.error(`Error writing image metadata cache for ${e}:`, t);
|
|
637
565
|
}
|
|
@@ -639,146 +567,122 @@ var Qe = class {
|
|
|
639
567
|
async clearImageMetadata(e) {
|
|
640
568
|
try {
|
|
641
569
|
let t = this.getImageMetadataPath(e);
|
|
642
|
-
await
|
|
570
|
+
await y.unlink(t);
|
|
643
571
|
} catch (t) {
|
|
644
572
|
t.code !== "ENOENT" && console.error(`Error clearing image metadata cache for ${e}:`, t);
|
|
645
573
|
}
|
|
646
574
|
}
|
|
647
|
-
|
|
648
|
-
try {
|
|
649
|
-
let e = await C.readdir(this.cacheDir);
|
|
650
|
-
for (let t of e) t.endsWith(".json") && t.includes("-") && await C.unlink(w(this.cacheDir, t));
|
|
651
|
-
let t = w(this.cacheDir, "image-metadata");
|
|
652
|
-
try {
|
|
653
|
-
let e = await C.readdir(t);
|
|
654
|
-
for (let n of e) n.endsWith(".json") && await C.unlink(w(t, n));
|
|
655
|
-
} catch {}
|
|
656
|
-
} catch (e) {
|
|
657
|
-
console.error("Error clearing all caches:", e);
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
}, et = class {
|
|
575
|
+
}, Ze = class {
|
|
661
576
|
memoryCache;
|
|
662
577
|
fileCache;
|
|
663
578
|
config;
|
|
664
|
-
stats = {
|
|
665
|
-
hits: 0,
|
|
666
|
-
misses: 0,
|
|
667
|
-
refreshes: 0,
|
|
668
|
-
errors: 0
|
|
669
|
-
};
|
|
670
579
|
constructor(e) {
|
|
671
|
-
this.config = e, this.memoryCache = new
|
|
580
|
+
this.config = e, this.memoryCache = new Ye(e), this.fileCache = new Xe(e);
|
|
672
581
|
}
|
|
673
|
-
|
|
582
|
+
getConfig() {
|
|
583
|
+
return this.config;
|
|
584
|
+
}
|
|
585
|
+
async getFeedContent(e, t, n, r) {
|
|
674
586
|
if (!this.config.enabled) return null;
|
|
675
587
|
try {
|
|
676
|
-
let
|
|
677
|
-
return
|
|
588
|
+
let i = this.memoryCache.getFeedContent(e, t, n);
|
|
589
|
+
return i || (i = await this.fileCache.getFeedContent(e, t, n), i && this.memoryCache.putFeedContent(e, t, i, n)), !i || r !== void 0 && i.fingerprint !== r ? null : i;
|
|
678
590
|
} catch (n) {
|
|
679
|
-
return console.error(`Error getting feed content cache for ${e}:${t}:`, n),
|
|
591
|
+
return console.error(`Error getting feed content cache for ${e}:${t}:`, n), null;
|
|
680
592
|
}
|
|
681
593
|
}
|
|
682
|
-
async setFeedContent(e, t, n, r
|
|
683
|
-
if (this.config.enabled)
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
594
|
+
async setFeedContent(e, t, n, r) {
|
|
595
|
+
if (!this.config.enabled) return null;
|
|
596
|
+
try {
|
|
597
|
+
let i = this.config.ttl;
|
|
598
|
+
r?.archive ? i = this.config.archiveTtl ?? 86400 : r?.page != null && r.page > 1 && (i = this.config.pageTtl ?? 300);
|
|
599
|
+
let a = Math.floor(Date.now() / 1e3), o = {
|
|
600
|
+
...n,
|
|
601
|
+
lastModified: a,
|
|
602
|
+
expiresAt: a + i
|
|
603
|
+
};
|
|
604
|
+
return this.memoryCache.putFeedContent(e, t, o, r), await this.fileCache.setFeedContent(e, t, o, r), o;
|
|
688
605
|
} catch (n) {
|
|
689
|
-
console.error(`Error setting feed content cache for ${e}:${t}:`, n),
|
|
606
|
+
return console.error(`Error setting feed content cache for ${e}:${t}:`, n), null;
|
|
690
607
|
}
|
|
691
608
|
}
|
|
692
|
-
async clearContent(e) {
|
|
693
|
-
this.memoryCache.clearContentCache(e), await this.fileCache.clearAllContentCache(e);
|
|
694
|
-
}
|
|
695
|
-
async clearAll() {
|
|
696
|
-
this.memoryCache.clearAll(), await this.fileCache.clearAll();
|
|
697
|
-
}
|
|
698
|
-
updateConfig(e) {
|
|
699
|
-
this.config = {
|
|
700
|
-
...this.config,
|
|
701
|
-
...e
|
|
702
|
-
}, this.memoryCache.updateConfig(this.config);
|
|
703
|
-
}
|
|
704
|
-
getStats() {
|
|
705
|
-
return {
|
|
706
|
-
...this.stats,
|
|
707
|
-
memoryStats: this.memoryCache.getStats()
|
|
708
|
-
};
|
|
709
|
-
}
|
|
710
609
|
async getImageMetadata(e) {
|
|
711
|
-
if (!this.config.
|
|
610
|
+
if (!this.config.imageMetadata?.enabled) return null;
|
|
712
611
|
try {
|
|
713
612
|
let t = this.memoryCache.getImageMetadata(e);
|
|
714
|
-
return t
|
|
613
|
+
return t || (t = await this.fileCache.getImageMetadata(e), t ? (this.memoryCache.setImageMetadata(e, t), t) : null);
|
|
715
614
|
} catch (t) {
|
|
716
|
-
return console.error(`Error getting image metadata cache for ${e}:`, t),
|
|
615
|
+
return console.error(`Error getting image metadata cache for ${e}:`, t), null;
|
|
717
616
|
}
|
|
718
617
|
}
|
|
719
618
|
async setImageMetadata(e, t) {
|
|
720
|
-
if (this.config.
|
|
619
|
+
if (this.config.imageMetadata?.enabled) try {
|
|
721
620
|
this.memoryCache.setImageMetadata(e, t), await this.fileCache.setImageMetadata(e, t);
|
|
722
621
|
} catch (t) {
|
|
723
|
-
console.error(`Error setting image metadata cache for ${e}:`, t)
|
|
622
|
+
console.error(`Error setting image metadata cache for ${e}:`, t);
|
|
724
623
|
}
|
|
725
624
|
}
|
|
726
|
-
resetStats() {
|
|
727
|
-
this.stats = {
|
|
728
|
-
hits: 0,
|
|
729
|
-
misses: 0,
|
|
730
|
-
refreshes: 0,
|
|
731
|
-
errors: 0
|
|
732
|
-
};
|
|
733
|
-
}
|
|
734
625
|
};
|
|
735
626
|
//#endregion
|
|
736
627
|
//#region src/cache/config.ts
|
|
737
|
-
function
|
|
628
|
+
function Qe() {
|
|
738
629
|
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;
|
|
739
|
-
a = n ? !1 : r ? !0 : !i;
|
|
740
|
-
let o =
|
|
741
|
-
a || console.log(`⚠️ Cache is DISABLED (${n ? "CACHE_ENABLED=false" : i ? "NODE_ENV=development" : "CACHE_ENABLED=false"})`);
|
|
742
|
-
let c = {
|
|
630
|
+
a = n ? !1 : r ? !0 : !i, a || console.log(`⚠️ Cache is DISABLED (${n ? "CACHE_ENABLED=false" : i ? "NODE_ENV=development" : "CACHE_ENABLED=false"})`);
|
|
631
|
+
let o = {
|
|
743
632
|
enabled: process.env.IMAGE_METADATA_ENABLED !== "false",
|
|
744
633
|
ttl: parseInt(process.env.IMAGE_METADATA_TTL || "604800", 10),
|
|
745
|
-
gateways: process.env.IMAGE_METADATA_GATEWAYS ? process.env.IMAGE_METADATA_GATEWAYS.split(",").map((e) => e.trim()) :
|
|
634
|
+
gateways: process.env.IMAGE_METADATA_GATEWAYS ? process.env.IMAGE_METADATA_GATEWAYS.split(",").map((e) => e.trim()) : _(oe() ?? d.getHost()),
|
|
746
635
|
timeout: parseInt(process.env.IMAGE_METADATA_TIMEOUT || "5000", 10)
|
|
747
|
-
},
|
|
636
|
+
}, s = parseInt(process.env.CACHE_PAGE_TTL || "300", 10), c = parseInt(process.env.CACHE_ARCHIVE_TTL || "86400", 10);
|
|
748
637
|
return {
|
|
749
638
|
ttl: e,
|
|
750
639
|
cacheDir: t,
|
|
751
640
|
enabled: a,
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
pageTtl: u,
|
|
756
|
-
archiveTtl: d
|
|
641
|
+
imageMetadata: o,
|
|
642
|
+
pageTtl: s,
|
|
643
|
+
archiveTtl: c
|
|
757
644
|
};
|
|
758
645
|
}
|
|
759
646
|
//#endregion
|
|
647
|
+
//#region src/utils/etag.ts
|
|
648
|
+
function H(e) {
|
|
649
|
+
return `"${ge("md5").update(e).digest("hex").substring(0, 16)}"`;
|
|
650
|
+
}
|
|
651
|
+
function $e(e, t) {
|
|
652
|
+
let n = (e) => e.replace(/^"|"$/g, "");
|
|
653
|
+
return n(e) === n(t);
|
|
654
|
+
}
|
|
655
|
+
function et(e) {
|
|
656
|
+
return e ? e.split(",").map((e) => e.trim()).filter((e) => e.length > 0) : [];
|
|
657
|
+
}
|
|
658
|
+
function tt(e, t) {
|
|
659
|
+
let n = et(e);
|
|
660
|
+
return n.length === 0 ? !1 : n.includes("*") ? !0 : n.some((e) => $e(e, t));
|
|
661
|
+
}
|
|
662
|
+
//#endregion
|
|
760
663
|
//#region src/services/arweaveImageService.ts
|
|
761
|
-
var
|
|
664
|
+
var nt = class {
|
|
762
665
|
config;
|
|
763
666
|
constructor(e) {
|
|
764
667
|
this.config = e;
|
|
765
668
|
}
|
|
766
669
|
async detectImage(e) {
|
|
767
|
-
await
|
|
768
|
-
let t =
|
|
769
|
-
for (let n of t)
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
x(n), console.warn(`Failed to fetch from gateway ${n} for transaction ${e}:`, t);
|
|
774
|
-
continue;
|
|
670
|
+
await h();
|
|
671
|
+
let t = g({ fallbackHosts: this.config.gateways });
|
|
672
|
+
for (let n of t) {
|
|
673
|
+
if (ne(n)) continue;
|
|
674
|
+
let t = await this.probe(`${n}/${e}`, n);
|
|
675
|
+
if (t) return t;
|
|
775
676
|
}
|
|
776
|
-
return
|
|
677
|
+
return null;
|
|
678
|
+
}
|
|
679
|
+
async getImageMetadata(e, t) {
|
|
680
|
+
return await this.probe(e, t) ?? {
|
|
777
681
|
isImage: !1,
|
|
778
|
-
url:
|
|
682
|
+
url: e
|
|
779
683
|
};
|
|
780
684
|
}
|
|
781
|
-
async
|
|
685
|
+
async probe(e, t) {
|
|
782
686
|
let n = t ?? (() => {
|
|
783
687
|
try {
|
|
784
688
|
return new URL(e).host;
|
|
@@ -788,11 +692,8 @@ var tt = class {
|
|
|
788
692
|
})();
|
|
789
693
|
try {
|
|
790
694
|
let t = await this.fetchWithTimeout(e, { method: "HEAD" });
|
|
791
|
-
if (!t.ok) return
|
|
792
|
-
|
|
793
|
-
url: e
|
|
794
|
-
};
|
|
795
|
-
ee(n);
|
|
695
|
+
if (!t.ok) return null;
|
|
696
|
+
ae(n);
|
|
796
697
|
let r = t.headers.get("content-type") || "", i = t.headers.get("content-length");
|
|
797
698
|
if (!this.isImageContentType(r)) return {
|
|
798
699
|
isImage: !1,
|
|
@@ -813,10 +714,7 @@ var tt = class {
|
|
|
813
714
|
format: c
|
|
814
715
|
};
|
|
815
716
|
} catch (t) {
|
|
816
|
-
return
|
|
817
|
-
isImage: !1,
|
|
818
|
-
url: e
|
|
819
|
-
};
|
|
717
|
+
return ie(n), console.warn(`Error fetching image metadata from ${e}:`, t), null;
|
|
820
718
|
}
|
|
821
719
|
}
|
|
822
720
|
async getImageMetadataFromFullRequest(e, t, n) {
|
|
@@ -848,7 +746,7 @@ var tt = class {
|
|
|
848
746
|
}
|
|
849
747
|
extractImageDimensions(e, t) {
|
|
850
748
|
try {
|
|
851
|
-
let t =
|
|
749
|
+
let t = _e(e);
|
|
852
750
|
if (t.width && t.height) return {
|
|
853
751
|
width: t.width,
|
|
854
752
|
height: t.height
|
|
@@ -870,7 +768,7 @@ var tt = class {
|
|
|
870
768
|
}
|
|
871
769
|
}
|
|
872
770
|
try {
|
|
873
|
-
let e =
|
|
771
|
+
let e = _e(t);
|
|
874
772
|
if (e.type) return e.type.toLowerCase();
|
|
875
773
|
} catch {}
|
|
876
774
|
}
|
|
@@ -886,31 +784,31 @@ var tt = class {
|
|
|
886
784
|
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? Error(`Request timeout after ${this.config.timeout}ms`) : e;
|
|
887
785
|
}
|
|
888
786
|
}
|
|
889
|
-
};
|
|
787
|
+
}, U = ve("seedFeed");
|
|
890
788
|
//#endregion
|
|
891
789
|
//#region src/pickFeedItemRichText.ts
|
|
892
|
-
function
|
|
790
|
+
function W(e, t) {
|
|
893
791
|
for (let n of t) {
|
|
894
792
|
let t = e[n];
|
|
895
793
|
if (typeof t == "string" && t.trim() !== "") return t;
|
|
896
794
|
}
|
|
897
795
|
return "";
|
|
898
796
|
}
|
|
899
|
-
var
|
|
797
|
+
var rt = [
|
|
900
798
|
"summary",
|
|
901
799
|
"Summary",
|
|
902
800
|
"description",
|
|
903
801
|
"Description",
|
|
904
802
|
"text",
|
|
905
803
|
"Text"
|
|
906
|
-
],
|
|
804
|
+
], it = [
|
|
907
805
|
"html",
|
|
908
806
|
"Html",
|
|
909
807
|
"body",
|
|
910
808
|
"Body",
|
|
911
809
|
"content",
|
|
912
810
|
"Content"
|
|
913
|
-
],
|
|
811
|
+
], at = [
|
|
914
812
|
"summary",
|
|
915
813
|
"Summary",
|
|
916
814
|
"description",
|
|
@@ -918,76 +816,76 @@ var nt = [
|
|
|
918
816
|
"text",
|
|
919
817
|
"Text"
|
|
920
818
|
];
|
|
921
|
-
function
|
|
922
|
-
let
|
|
923
|
-
if (
|
|
924
|
-
let
|
|
925
|
-
return
|
|
926
|
-
}
|
|
927
|
-
function
|
|
928
|
-
let
|
|
929
|
-
if (
|
|
930
|
-
if (!o(
|
|
931
|
-
let
|
|
932
|
-
if (typeof
|
|
933
|
-
let
|
|
934
|
-
model:
|
|
935
|
-
key:
|
|
819
|
+
function ot(e, t) {
|
|
820
|
+
let n = l(e.model) - l(t.model);
|
|
821
|
+
if (n !== 0) return n;
|
|
822
|
+
let r = e.key.localeCompare(t.key);
|
|
823
|
+
return r === 0 ? e.index - t.index : r;
|
|
824
|
+
}
|
|
825
|
+
function st(e) {
|
|
826
|
+
let r = t(e), i = n(e), a = null;
|
|
827
|
+
if (r) for (let [t, n] of Object.entries(r)) {
|
|
828
|
+
if (!o(n)) continue;
|
|
829
|
+
let r = e[t];
|
|
830
|
+
if (typeof r != "string" || r.trim() === "") continue;
|
|
831
|
+
let i = {
|
|
832
|
+
model: n,
|
|
833
|
+
key: t,
|
|
936
834
|
index: 0,
|
|
937
|
-
value:
|
|
835
|
+
value: r
|
|
938
836
|
};
|
|
939
|
-
(!
|
|
940
|
-
}
|
|
941
|
-
if (
|
|
942
|
-
let
|
|
943
|
-
if (!Array.isArray(
|
|
944
|
-
let
|
|
945
|
-
for (let e = 0; e <
|
|
946
|
-
let
|
|
947
|
-
if (!o(
|
|
948
|
-
let s =
|
|
837
|
+
(!a || ot(i, a) < 0) && (a = i);
|
|
838
|
+
}
|
|
839
|
+
if (i) for (let [t, n] of Object.entries(i)) {
|
|
840
|
+
let r = e[t];
|
|
841
|
+
if (!Array.isArray(r)) continue;
|
|
842
|
+
let i = Math.min(n.length, r.length);
|
|
843
|
+
for (let e = 0; e < i; e++) {
|
|
844
|
+
let i = n[e];
|
|
845
|
+
if (!o(i)) continue;
|
|
846
|
+
let s = r[e];
|
|
949
847
|
if (typeof s != "string" || s.trim() === "") continue;
|
|
950
848
|
let c = {
|
|
951
|
-
model:
|
|
849
|
+
model: i,
|
|
952
850
|
key: t,
|
|
953
851
|
index: e,
|
|
954
852
|
value: s
|
|
955
853
|
};
|
|
956
|
-
(!
|
|
854
|
+
(!a || ot(c, a) < 0) && (a = c);
|
|
957
855
|
}
|
|
958
856
|
}
|
|
959
|
-
return
|
|
857
|
+
return a?.value ?? "";
|
|
960
858
|
}
|
|
961
|
-
function
|
|
962
|
-
return
|
|
859
|
+
function G(e) {
|
|
860
|
+
return W(e, rt);
|
|
963
861
|
}
|
|
964
862
|
function ct(e) {
|
|
965
|
-
let t =
|
|
863
|
+
let t = st(e);
|
|
966
864
|
if (t !== "") return t;
|
|
967
|
-
let n =
|
|
968
|
-
return n === "" ?
|
|
865
|
+
let n = W(e, it);
|
|
866
|
+
return n === "" ? W(e, at) : n;
|
|
969
867
|
}
|
|
970
|
-
function
|
|
868
|
+
function K(e) {
|
|
971
869
|
return typeof e == "string" && e.includes("data:image/") && e.includes(";base64,");
|
|
972
870
|
}
|
|
973
871
|
function lt(e) {
|
|
974
|
-
let
|
|
975
|
-
if (
|
|
976
|
-
for (let [
|
|
872
|
+
let r = t(e);
|
|
873
|
+
if (r) {
|
|
874
|
+
for (let [t, n] of Object.entries(r)) if (o(n) && K(e[t])) return !0;
|
|
977
875
|
}
|
|
978
|
-
let
|
|
979
|
-
if (
|
|
980
|
-
let
|
|
981
|
-
if (!Array.isArray(
|
|
982
|
-
let i = Math.min(
|
|
983
|
-
for (let e = 0; e < i; e++) if (o(
|
|
876
|
+
let i = n(e);
|
|
877
|
+
if (i) for (let [t, n] of Object.entries(i)) {
|
|
878
|
+
let r = e[t];
|
|
879
|
+
if (!Array.isArray(r)) continue;
|
|
880
|
+
let i = Math.min(n.length, r.length);
|
|
881
|
+
for (let e = 0; e < i; e++) if (o(n[e]) && K(r[e])) return !0;
|
|
984
882
|
}
|
|
985
883
|
return !1;
|
|
986
884
|
}
|
|
987
885
|
function ut(e) {
|
|
988
886
|
if (lt(e)) return !0;
|
|
989
|
-
for (let t of
|
|
990
|
-
for (let t of
|
|
887
|
+
for (let t of it) if (K(e[t])) return !0;
|
|
888
|
+
for (let t of rt) if (K(e[t])) return !0;
|
|
991
889
|
return !1;
|
|
992
890
|
}
|
|
993
891
|
function dt(e, t = "omit_items") {
|
|
@@ -996,9 +894,9 @@ function dt(e, t = "omit_items") {
|
|
|
996
894
|
//#endregion
|
|
997
895
|
//#region src/index.ts
|
|
998
896
|
function ft(e) {
|
|
999
|
-
return
|
|
897
|
+
return le(e)?.mediaUrl;
|
|
1000
898
|
}
|
|
1001
|
-
function
|
|
899
|
+
function q(e) {
|
|
1002
900
|
if (typeof e == "number" && Number.isFinite(e) && e > 0) return e;
|
|
1003
901
|
if (typeof e == "string") {
|
|
1004
902
|
let t = Number(e);
|
|
@@ -1020,16 +918,16 @@ function pt(e) {
|
|
|
1020
918
|
return {
|
|
1021
919
|
url: t,
|
|
1022
920
|
mimeType: typeof n.mimeType == "string" && n.mimeType || typeof n.type == "string" && n.type || typeof n.contentType == "string" && n.contentType || void 0,
|
|
1023
|
-
width:
|
|
1024
|
-
height:
|
|
1025
|
-
size:
|
|
921
|
+
width: q(n.width),
|
|
922
|
+
height: q(n.height),
|
|
923
|
+
size: q(n.size ?? n.fileSize),
|
|
1026
924
|
format: typeof n.format == "string" ? n.format : void 0
|
|
1027
925
|
};
|
|
1028
926
|
}
|
|
1029
927
|
return { url: t };
|
|
1030
928
|
}
|
|
1031
929
|
}
|
|
1032
|
-
function
|
|
930
|
+
function J(e) {
|
|
1033
931
|
if (e._hasImage && e._imageMetadata && typeof e._imageMetadata == "object") {
|
|
1034
932
|
let t = e._imageMetadata;
|
|
1035
933
|
if (t.url) return {
|
|
@@ -1057,7 +955,7 @@ function mt(e) {
|
|
|
1057
955
|
if (n) return n;
|
|
1058
956
|
}
|
|
1059
957
|
}
|
|
1060
|
-
function
|
|
958
|
+
function mt(e, t, n, r, i, a) {
|
|
1061
959
|
let o = n.mimeType || "image/jpeg";
|
|
1062
960
|
e.enclosures = [{
|
|
1063
961
|
url: n.url,
|
|
@@ -1093,69 +991,98 @@ function ht(e, t, n, r, i, a) {
|
|
|
1093
991
|
"media:description": l
|
|
1094
992
|
}], 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}`);
|
|
1095
993
|
}
|
|
1096
|
-
var
|
|
1097
|
-
function
|
|
1098
|
-
return
|
|
994
|
+
var Y = null;
|
|
995
|
+
function X() {
|
|
996
|
+
return Y ||= new Ze(Qe()), Y;
|
|
1099
997
|
}
|
|
1100
|
-
function
|
|
1101
|
-
|
|
998
|
+
function ht() {
|
|
999
|
+
Y = null;
|
|
1102
1000
|
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
try {
|
|
1111
|
-
let i = await n.getImageMetadata(r);
|
|
1112
|
-
return i || (console.log(`Detecting image for transaction ${r}`), i = await t.detectImage(r), await n.setImageMetadata(r, i)), i.isImage && (e._imageMetadata = i, e._hasImage = !0), e;
|
|
1113
|
-
} catch (t) {
|
|
1114
|
-
return console.warn(`Error enriching item with transaction ${r}:`, t), e;
|
|
1001
|
+
var gt = 8;
|
|
1002
|
+
async function _t(e, t) {
|
|
1003
|
+
let n = 0;
|
|
1004
|
+
await Promise.all(Array.from({ length: Math.min(t, e.length) }, async () => {
|
|
1005
|
+
for (; n < e.length;) {
|
|
1006
|
+
let t = e[n++];
|
|
1007
|
+
await t();
|
|
1115
1008
|
}
|
|
1116
|
-
})
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1009
|
+
}));
|
|
1010
|
+
}
|
|
1011
|
+
async function vt(e, t, n) {
|
|
1012
|
+
let r = await n.getImageMetadata(e);
|
|
1013
|
+
if (r) return r;
|
|
1014
|
+
U("detecting image for transaction %s", e);
|
|
1015
|
+
let i = await t.detectImage(e);
|
|
1016
|
+
return i && await n.setImageMetadata(e, i), i;
|
|
1017
|
+
}
|
|
1018
|
+
function yt(e) {
|
|
1019
|
+
if (a(e)) return new URL(e).pathname.replace(/^\//, "");
|
|
1020
|
+
}
|
|
1021
|
+
function bt(e, t) {
|
|
1022
|
+
let n = e;
|
|
1023
|
+
if (t === "image") return n.storageTransactionId || n.storage_transaction_id;
|
|
1024
|
+
let r = J(n);
|
|
1025
|
+
if (!(!r || r.width && r.height && r.mimeType)) return yt(r.url);
|
|
1124
1026
|
}
|
|
1125
|
-
function
|
|
1126
|
-
let
|
|
1127
|
-
|
|
1128
|
-
let
|
|
1027
|
+
async function xt(e, t, n, r) {
|
|
1028
|
+
let i = e, a = bt(e, t);
|
|
1029
|
+
if (a) try {
|
|
1030
|
+
let e = await vt(a, n, r);
|
|
1031
|
+
if (!e?.isImage) return;
|
|
1032
|
+
let o = t === "image" ? void 0 : J(i);
|
|
1033
|
+
i._imageMetadata = o ? {
|
|
1034
|
+
...e,
|
|
1035
|
+
url: o.url
|
|
1036
|
+
} : e, i._hasImage = !0;
|
|
1037
|
+
} catch (e) {
|
|
1038
|
+
console.warn(`Error enriching item with transaction ${a}:`, e);
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
async function St(e, t, n, r) {
|
|
1042
|
+
let i = e.filter((e) => bt(e, t));
|
|
1043
|
+
return U("enriching %d items with image metadata", i.length), await _t(i.map((e) => () => xt(e, t, n, r)), gt), e;
|
|
1044
|
+
}
|
|
1045
|
+
async function Ct(e, t, n) {
|
|
1046
|
+
let r = n.getConfig().imageMetadata;
|
|
1047
|
+
return r?.enabled ? St(e, t, new nt({
|
|
1048
|
+
gateways: r.gateways,
|
|
1049
|
+
timeout: r.timeout
|
|
1050
|
+
}), n) : e;
|
|
1051
|
+
}
|
|
1052
|
+
function wt(e, t) {
|
|
1053
|
+
let { itemUrlBase: n, itemUrlPath: r, richTextDataUriImages: i = "omit_items" } = t;
|
|
1054
|
+
return dt(e, i).map((e) => {
|
|
1055
|
+
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;
|
|
1129
1056
|
if (e.pubDate || e.PubDate) {
|
|
1130
1057
|
let t = e.pubDate || e.PubDate;
|
|
1131
|
-
|
|
1132
|
-
} else if (e.timeCreated)
|
|
1058
|
+
o = new Date(t);
|
|
1059
|
+
} else if (e.timeCreated) o = /* @__PURE__ */ new Date(e.timeCreated * 1e3);
|
|
1133
1060
|
else if (e.publishedAt || e.createdAt || e.updatedAt) {
|
|
1134
1061
|
let t = e.publishedAt || e.createdAt || e.updatedAt;
|
|
1135
|
-
|
|
1136
|
-
} else
|
|
1137
|
-
let
|
|
1062
|
+
o = t && typeof t == "object" && t.constructor === Date ? t : new Date(t);
|
|
1063
|
+
} else o = /* @__PURE__ */ new Date();
|
|
1064
|
+
let s = G(e), c = ct(e), l = {
|
|
1138
1065
|
...e,
|
|
1139
1066
|
id: t,
|
|
1140
1067
|
title: e.title || e.Title || "Untitled",
|
|
1141
|
-
link:
|
|
1142
|
-
description:
|
|
1143
|
-
content:
|
|
1144
|
-
pubDate:
|
|
1145
|
-
date:
|
|
1146
|
-
guid: e.guid || e.Guid || e.link || e.Link ||
|
|
1068
|
+
link: a,
|
|
1069
|
+
description: s,
|
|
1070
|
+
content: c,
|
|
1071
|
+
pubDate: o,
|
|
1072
|
+
date: o,
|
|
1073
|
+
guid: e.guid || e.Guid || e.link || e.Link || a
|
|
1147
1074
|
};
|
|
1148
|
-
return typeof
|
|
1149
|
-
let t =
|
|
1075
|
+
return typeof l.html == "string" && l.Html === void 0 && (l.Html = l.html), typeof l.Html == "string" && l.html === void 0 && (l.html = l.Html), typeof l.body == "string" && l.Body === void 0 && (l.Body = l.body), typeof l.Body == "string" && l.body === void 0 && (l.body = l.Body), e._imageMetadata && e._hasImage && (l._imageMetadata = e._imageMetadata, l._hasImage = !0), Object.keys(l).forEach((e) => {
|
|
1076
|
+
let t = l[e];
|
|
1150
1077
|
if (typeof t == "string" && /date|time|published|created|updated/i.test(e) && e !== "pubDate" && e !== "date") {
|
|
1151
1078
|
let n = new Date(t);
|
|
1152
|
-
isNaN(n.getTime()) || (
|
|
1079
|
+
isNaN(n.getTime()) || (l[e] = n);
|
|
1153
1080
|
}
|
|
1154
|
-
}),
|
|
1081
|
+
}), l;
|
|
1155
1082
|
});
|
|
1156
1083
|
}
|
|
1157
1084
|
var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
1158
|
-
let l =
|
|
1085
|
+
let l = T(c), u = v(t), d = `${l.feedUrl}/${u}/${n}`, f = r ? `${d}?v=${r}` : d, p = `${l.title} - ${Dt(u)}`, m = /* @__PURE__ */ new Date(), h = E(), g = [];
|
|
1159
1086
|
if (i) {
|
|
1160
1087
|
let e = i.baseUrl.replace(/\?.*$/, ""), t = e.includes("?") ? "&" : "?";
|
|
1161
1088
|
i.hasNext && g.push({
|
|
@@ -1173,9 +1100,8 @@ var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1173
1100
|
rel: e.rel,
|
|
1174
1101
|
href: e.href
|
|
1175
1102
|
});
|
|
1176
|
-
let _ =
|
|
1103
|
+
let _ = wt(e, {
|
|
1177
1104
|
schemaName: t,
|
|
1178
|
-
siteUrl: l.siteUrl,
|
|
1179
1105
|
itemUrlBase: h.itemUrlBase,
|
|
1180
1106
|
itemUrlPath: h.itemUrlPath,
|
|
1181
1107
|
richTextDataUriImages: s?.richTextDataUriImages ?? h.richTextDataUriImages
|
|
@@ -1229,7 +1155,7 @@ var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1229
1155
|
return t;
|
|
1230
1156
|
})
|
|
1231
1157
|
};
|
|
1232
|
-
return Promise.resolve(
|
|
1158
|
+
return Promise.resolve(pe(t));
|
|
1233
1159
|
}
|
|
1234
1160
|
case "json": {
|
|
1235
1161
|
let e = i?.hasNext ? `${i.baseUrl.replace(/\?.*$/, "")}?page=${i.page + 1}` : void 0, t = {
|
|
@@ -1258,7 +1184,7 @@ var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1258
1184
|
}
|
|
1259
1185
|
return t;
|
|
1260
1186
|
})
|
|
1261
|
-
}, n =
|
|
1187
|
+
}, n = me(t);
|
|
1262
1188
|
return Promise.resolve(typeof n == "string" ? n : JSON.stringify(n));
|
|
1263
1189
|
}
|
|
1264
1190
|
default: {
|
|
@@ -1286,26 +1212,26 @@ var Z = (e, t, n, r, i, a, o, s, c) => {
|
|
|
1286
1212
|
value: e.id,
|
|
1287
1213
|
isPermaLink: typeof e.id == "string" && (e.id.startsWith("http://") || e.id.startsWith("https://"))
|
|
1288
1214
|
});
|
|
1289
|
-
let r =
|
|
1290
|
-
if (r &&
|
|
1215
|
+
let r = J(e);
|
|
1216
|
+
if (r && mt(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) {
|
|
1291
1217
|
let t = /* @__PURE__ */ new Date(e.timeCreated * 1e3);
|
|
1292
1218
|
n.dc.dates || (n.dc.dates = []), n.dc.dates.push(t);
|
|
1293
1219
|
}
|
|
1294
1220
|
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;
|
|
1295
1221
|
})
|
|
1296
1222
|
};
|
|
1297
|
-
return Promise.resolve(
|
|
1223
|
+
return Promise.resolve(Je(e));
|
|
1298
1224
|
}
|
|
1299
1225
|
}
|
|
1300
1226
|
};
|
|
1301
|
-
function
|
|
1227
|
+
function Tt(e) {
|
|
1302
1228
|
switch (e) {
|
|
1303
1229
|
case "atom": return "application/atom+xml; charset=utf-8";
|
|
1304
1230
|
case "json": return "application/feed+json; charset=utf-8";
|
|
1305
1231
|
default: return "application/rss+xml; charset=utf-8";
|
|
1306
1232
|
}
|
|
1307
1233
|
}
|
|
1308
|
-
function
|
|
1234
|
+
function Et(e) {
|
|
1309
1235
|
let t = e.toLowerCase();
|
|
1310
1236
|
return [
|
|
1311
1237
|
"rss",
|
|
@@ -1313,204 +1239,166 @@ function $(e) {
|
|
|
1313
1239
|
"json"
|
|
1314
1240
|
].includes(t) ? t : null;
|
|
1315
1241
|
}
|
|
1316
|
-
function
|
|
1242
|
+
function Dt(e) {
|
|
1317
1243
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1318
1244
|
}
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1245
|
+
function Ot(e) {
|
|
1246
|
+
return H(JSON.stringify([
|
|
1247
|
+
e.sourceEtag ?? null,
|
|
1248
|
+
e.siteConfig,
|
|
1249
|
+
e.cacheBust ?? null
|
|
1250
|
+
]));
|
|
1251
|
+
}
|
|
1252
|
+
function Q(e, t, n, r = {}) {
|
|
1253
|
+
let i = {
|
|
1254
|
+
ETag: t.etag,
|
|
1255
|
+
"Last-Modified": (/* @__PURE__ */ new Date(t.lastModified * 1e3)).toUTCString(),
|
|
1256
|
+
"Cache-Control": `public, max-age=${e.maxAge}, s-maxage=${e.maxAge}, must-revalidate`,
|
|
1257
|
+
...r
|
|
1258
|
+
};
|
|
1259
|
+
return n !== 304 && (i["Content-Type"] = t.contentType ?? Tt(e.format), i["X-Feed-Schema"] = e.schemaName, i["X-Feed-Format"] = e.format), new Response(n === 304 ? null : t.content, {
|
|
1260
|
+
status: n,
|
|
1261
|
+
headers: i
|
|
1324
1262
|
});
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1263
|
+
}
|
|
1264
|
+
function $(e, t, n, r) {
|
|
1265
|
+
return e.ifNoneMatch && tt(e.ifNoneMatch, t.etag) ? (U("%s for %s:%s, 304", n, e.schemaName, e.format), Q(e, {
|
|
1266
|
+
...t,
|
|
1267
|
+
content: null
|
|
1268
|
+
}, 304)) : (U("%s for %s:%s", n, e.schemaName, e.format), Q(e, t, 200, {
|
|
1269
|
+
"X-Cache": n,
|
|
1270
|
+
...r
|
|
1271
|
+
}));
|
|
1272
|
+
}
|
|
1273
|
+
async function kt(e) {
|
|
1274
|
+
let { schemaName: t, format: n, contentKeyOptions: r } = e, i = X(), a = i.getConfig().enabled;
|
|
1328
1275
|
try {
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
"Last-Modified": (/* @__PURE__ */ new Date(e.lastModified * 1e3)).toUTCString(),
|
|
1336
|
-
"Cache-Control": "public, max-age=3600, s-maxage=3600, must-revalidate"
|
|
1337
|
-
}
|
|
1338
|
-
})) : (console.log(`Cache hit for ${s}:${o}`), new Response(e.content, {
|
|
1339
|
-
status: 200,
|
|
1340
|
-
headers: {
|
|
1341
|
-
"Content-Type": e.contentType,
|
|
1342
|
-
ETag: e.etag,
|
|
1343
|
-
"Last-Modified": (/* @__PURE__ */ new Date(e.lastModified * 1e3)).toUTCString(),
|
|
1344
|
-
"Cache-Control": "public, max-age=3600, s-maxage=3600, must-revalidate",
|
|
1345
|
-
"X-Feed-Schema": s,
|
|
1346
|
-
"X-Feed-Format": o,
|
|
1347
|
-
"X-Cache": "HIT"
|
|
1348
|
-
}
|
|
1349
|
-
}));
|
|
1350
|
-
}
|
|
1351
|
-
console.log(`Cache miss for ${s}:${o} - fetching items`);
|
|
1352
|
-
let e = await (async () => {
|
|
1353
|
-
let e = await we(s, {
|
|
1354
|
-
limit: f,
|
|
1355
|
-
skip: p
|
|
1356
|
-
});
|
|
1357
|
-
return console.log(`Found ${e.length} feed items for schema ${s}`), g.imageMetadata?.enabled ? vt(e, new tt({
|
|
1358
|
-
gateways: g.imageMetadata.gateways,
|
|
1359
|
-
timeout: g.imageMetadata.timeout
|
|
1360
|
-
}), h) : e;
|
|
1361
|
-
})(), t = `${l.feedUrl}/${c}/${o}`, i = e.length === f, u = [];
|
|
1362
|
-
if (d === 1) {
|
|
1363
|
-
let e = /* @__PURE__ */ new Date(), t = new Date(e.getFullYear(), e.getMonth() - 1, 1);
|
|
1364
|
-
u.push({
|
|
1365
|
-
rel: "prev-archive",
|
|
1366
|
-
href: `${l.feedUrl}/${c}/archive/${t.getFullYear()}/${t.getMonth() + 1}/${o}`
|
|
1367
|
-
});
|
|
1368
|
-
}
|
|
1369
|
-
let _ = await Z(e, s, o, r, {
|
|
1370
|
-
page: d,
|
|
1371
|
-
pageSize: f,
|
|
1372
|
-
hasNext: i,
|
|
1373
|
-
baseUrl: t
|
|
1374
|
-
}, u.length ? u : void 0, !1, void 0, a), v = Q(o);
|
|
1375
|
-
if (g.enabled) {
|
|
1376
|
-
await h.setFeedContent(s, o, _, v, m);
|
|
1377
|
-
let e = await h.getFeedContent(s, o, m), t = e?.etag || "", n = e?.lastModified || Math.floor(Date.now() / 1e3);
|
|
1378
|
-
return new Response(_, {
|
|
1379
|
-
status: 200,
|
|
1380
|
-
headers: {
|
|
1381
|
-
"Content-Type": v,
|
|
1382
|
-
ETag: t,
|
|
1383
|
-
"Last-Modified": (/* @__PURE__ */ new Date(n * 1e3)).toUTCString(),
|
|
1384
|
-
"Cache-Control": "public, max-age=3600, s-maxage=3600, must-revalidate",
|
|
1385
|
-
"X-Feed-Schema": s,
|
|
1386
|
-
"X-Feed-Format": o,
|
|
1387
|
-
"X-Cache": "MISS"
|
|
1388
|
-
}
|
|
1389
|
-
});
|
|
1390
|
-
}
|
|
1391
|
-
return new Response(_, {
|
|
1392
|
-
status: 200,
|
|
1393
|
-
headers: {
|
|
1394
|
-
"Content-Type": v,
|
|
1395
|
-
"Cache-Control": "public, max-age=3600, s-maxage=3600",
|
|
1396
|
-
"X-Feed-Schema": s,
|
|
1397
|
-
"X-Feed-Format": o
|
|
1398
|
-
}
|
|
1276
|
+
let o;
|
|
1277
|
+
e.revalidate && (o = await e.fetchItems());
|
|
1278
|
+
let s = Ot({
|
|
1279
|
+
sourceEtag: o?.sourceEtag,
|
|
1280
|
+
siteConfig: e.siteConfig,
|
|
1281
|
+
cacheBust: e.cacheBust
|
|
1399
1282
|
});
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1283
|
+
if (a) {
|
|
1284
|
+
let a = await i.getFeedContent(t, n, r, s);
|
|
1285
|
+
if (a) return $(e, a, "HIT");
|
|
1286
|
+
}
|
|
1287
|
+
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 = Tt(n), u = o.sourceEtag ? H(`${s}:${V(t, n, r)}`) : H(c), d = a ? await i.setFeedContent(t, n, {
|
|
1289
|
+
content: c,
|
|
1290
|
+
contentType: l,
|
|
1291
|
+
etag: u,
|
|
1292
|
+
fingerprint: s
|
|
1293
|
+
}, r) : null;
|
|
1294
|
+
return d ? $(e, d, "MISS") : Q(e, {
|
|
1295
|
+
content: c,
|
|
1296
|
+
contentType: l,
|
|
1297
|
+
etag: u,
|
|
1298
|
+
lastModified: Math.floor(Date.now() / 1e3)
|
|
1299
|
+
}, 200);
|
|
1300
|
+
} catch (o) {
|
|
1301
|
+
if (console.error(`Feed generation error for ${t}:${n}:`, o), a) {
|
|
1302
|
+
let a = await i.getFeedContent(t, n, r);
|
|
1303
|
+
if (a) return $(e, a, "STALE", { Warning: "110 - \"Response is stale\"" });
|
|
1415
1304
|
}
|
|
1416
1305
|
return new Response(JSON.stringify({
|
|
1417
1306
|
error: "Failed to generate feed",
|
|
1418
|
-
message:
|
|
1307
|
+
message: o instanceof Error ? o.message : "Unknown error"
|
|
1419
1308
|
}), {
|
|
1420
1309
|
status: 500,
|
|
1421
1310
|
headers: { "Content-Type": "application/json" }
|
|
1422
1311
|
});
|
|
1423
1312
|
}
|
|
1424
1313
|
}
|
|
1425
|
-
|
|
1426
|
-
|
|
1314
|
+
function At(e) {
|
|
1315
|
+
return new Response(JSON.stringify({ error: `Invalid feed format: ${e}` }), {
|
|
1427
1316
|
status: 400,
|
|
1428
1317
|
headers: { "Content-Type": "application/json" }
|
|
1429
1318
|
});
|
|
1430
|
-
|
|
1319
|
+
}
|
|
1320
|
+
async function jt(e, t, n, i, a, o) {
|
|
1321
|
+
let s = Et(t);
|
|
1322
|
+
if (!s) return At(t);
|
|
1323
|
+
let c = v.singular(e.toLowerCase()), l = v(c), u = T(o), d = Math.max(1, a ?? 1), f = E().pageSize, p = X(), m = !1;
|
|
1324
|
+
return kt({
|
|
1325
|
+
schemaName: c,
|
|
1326
|
+
format: s,
|
|
1327
|
+
contentKeyOptions: d > 1 ? { page: d } : void 0,
|
|
1328
|
+
ifNoneMatch: n,
|
|
1329
|
+
siteConfig: u,
|
|
1330
|
+
cacheBust: i,
|
|
1331
|
+
maxAge: d === 1 ? r().getConfig().maxAge ?? 0 : 3600,
|
|
1332
|
+
revalidate: d === 1,
|
|
1333
|
+
fetchItems: async () => {
|
|
1334
|
+
let { items: e, etag: t } = await O(c, {
|
|
1335
|
+
limit: f + 1,
|
|
1336
|
+
skip: (d - 1) * f
|
|
1337
|
+
});
|
|
1338
|
+
return m = e.length > f, {
|
|
1339
|
+
items: e.slice(0, f),
|
|
1340
|
+
sourceEtag: t
|
|
1341
|
+
};
|
|
1342
|
+
},
|
|
1343
|
+
render: async (e) => {
|
|
1344
|
+
let t = [];
|
|
1345
|
+
if (d === 1) {
|
|
1346
|
+
let e = /* @__PURE__ */ new Date(), n = new Date(Date.UTC(e.getUTCFullYear(), e.getUTCMonth() - 1, 1));
|
|
1347
|
+
t.push({
|
|
1348
|
+
rel: "prev-archive",
|
|
1349
|
+
href: `${u.feedUrl}/${l}/archive/${n.getUTCFullYear()}/${n.getUTCMonth() + 1}/${s}`
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
return Z(await Ct(e, c, p), c, s, i, {
|
|
1353
|
+
page: d,
|
|
1354
|
+
pageSize: f,
|
|
1355
|
+
hasNext: m,
|
|
1356
|
+
baseUrl: `${u.feedUrl}/${l}/${s}`
|
|
1357
|
+
}, t.length ? t : void 0, !1, void 0, o);
|
|
1358
|
+
}
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
async function Mt(e, t, n, r, i, a, o) {
|
|
1362
|
+
if (t < 1970 || t > 2100) return new Response(JSON.stringify({ error: `Invalid year: ${t}` }), {
|
|
1431
1363
|
status: 400,
|
|
1432
1364
|
headers: { "Content-Type": "application/json" }
|
|
1433
1365
|
});
|
|
1434
|
-
|
|
1435
|
-
if (!s) return new Response(JSON.stringify({ error: `Invalid feed format: ${r}` }), {
|
|
1366
|
+
if (n < 1 || n > 12) return new Response(JSON.stringify({ error: `Invalid month: ${n}` }), {
|
|
1436
1367
|
status: 400,
|
|
1437
1368
|
headers: { "Content-Type": "application/json" }
|
|
1438
1369
|
});
|
|
1439
|
-
let
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
rel: "prev-archive",
|
|
1468
|
-
href: `${m}/${n === 1 ? t - 1 : t}/${n === 1 ? 12 : n - 1}/${s}`
|
|
1469
|
-
}, {
|
|
1470
|
-
rel: "current",
|
|
1471
|
-
href: r
|
|
1472
|
-
}], g = n === 12 ? t + 1 : t, _ = n === 12 ? 1 : n + 1, v = /* @__PURE__ */ new Date();
|
|
1473
|
-
(g < v.getFullYear() || g === v.getFullYear() && _ <= v.getMonth() + 1) && h.push({
|
|
1474
|
-
rel: "next-archive",
|
|
1475
|
-
href: `${m}/${g}/${_}/${s}`
|
|
1476
|
-
});
|
|
1477
|
-
let y = await Z(e, c, s, a, void 0, h, !0, void 0, o), b = Q(s);
|
|
1478
|
-
if (p.enabled) {
|
|
1479
|
-
await f.setFeedContent(c, s, y, b, d);
|
|
1480
|
-
let e = await f.getFeedContent(c, s, d), t = e?.etag || "", n = e?.lastModified || Math.floor(Date.now() / 1e3);
|
|
1481
|
-
return new Response(y, {
|
|
1482
|
-
status: 200,
|
|
1483
|
-
headers: {
|
|
1484
|
-
"Content-Type": b,
|
|
1485
|
-
ETag: t,
|
|
1486
|
-
"Last-Modified": (/* @__PURE__ */ new Date(n * 1e3)).toUTCString(),
|
|
1487
|
-
"Cache-Control": "public, max-age=86400, s-maxage=86400, must-revalidate",
|
|
1488
|
-
"X-Feed-Schema": c,
|
|
1489
|
-
"X-Feed-Format": s,
|
|
1490
|
-
"X-Cache": "MISS"
|
|
1491
|
-
}
|
|
1492
|
-
});
|
|
1370
|
+
let s = Et(r);
|
|
1371
|
+
if (!s) return At(r);
|
|
1372
|
+
let c = v.singular(e.toLowerCase()), l = v(c), u = T(o), d = X();
|
|
1373
|
+
return kt({
|
|
1374
|
+
schemaName: c,
|
|
1375
|
+
format: s,
|
|
1376
|
+
contentKeyOptions: { archive: {
|
|
1377
|
+
year: t,
|
|
1378
|
+
month: n
|
|
1379
|
+
} },
|
|
1380
|
+
ifNoneMatch: i,
|
|
1381
|
+
siteConfig: u,
|
|
1382
|
+
cacheBust: a,
|
|
1383
|
+
maxAge: 86400,
|
|
1384
|
+
revalidate: !1,
|
|
1385
|
+
fetchItems: async () => ({ items: await k(c, t, n) }),
|
|
1386
|
+
render: async (e) => {
|
|
1387
|
+
let r = `${u.feedUrl}/${l}/${s}`, i = `${u.feedUrl}/${l}/archive`, f = [{
|
|
1388
|
+
rel: "prev-archive",
|
|
1389
|
+
href: `${i}/${n === 1 ? t - 1 : t}/${n === 1 ? 12 : n - 1}/${s}`
|
|
1390
|
+
}, {
|
|
1391
|
+
rel: "current",
|
|
1392
|
+
href: r
|
|
1393
|
+
}], p = n === 12 ? t + 1 : t, m = n === 12 ? 1 : n + 1, h = /* @__PURE__ */ new Date();
|
|
1394
|
+
return (p < h.getUTCFullYear() || p === h.getUTCFullYear() && m <= h.getUTCMonth() + 1) && f.push({
|
|
1395
|
+
rel: "next-archive",
|
|
1396
|
+
href: `${i}/${p}/${m}/${s}`
|
|
1397
|
+
}), Z(await Ct(e, c, d), c, s, a, void 0, f, !0, void 0, o);
|
|
1493
1398
|
}
|
|
1494
|
-
|
|
1495
|
-
status: 200,
|
|
1496
|
-
headers: {
|
|
1497
|
-
"Content-Type": b,
|
|
1498
|
-
"Cache-Control": "public, max-age=86400, s-maxage=86400",
|
|
1499
|
-
"X-Feed-Schema": c,
|
|
1500
|
-
"X-Feed-Format": s
|
|
1501
|
-
}
|
|
1502
|
-
});
|
|
1503
|
-
} catch (e) {
|
|
1504
|
-
return console.error("Archive feed generation error:", e), new Response(JSON.stringify({
|
|
1505
|
-
error: "Failed to generate archive feed",
|
|
1506
|
-
message: e instanceof Error ? e.message : "Unknown error"
|
|
1507
|
-
}), {
|
|
1508
|
-
status: 500,
|
|
1509
|
-
headers: { "Content-Type": "application/json" }
|
|
1510
|
-
});
|
|
1511
|
-
}
|
|
1399
|
+
});
|
|
1512
1400
|
}
|
|
1513
1401
|
//#endregion
|
|
1514
|
-
export {
|
|
1402
|
+
export { f as DEFAULT_ARWEAVE_HOST, S as DEFAULT_SITE_CONFIG, p as SEED_RSS_IMAGE_RELATION_FIELD_KEYS, m as classifyMediaRef, Z as createFeed, ut as feedItemRichTextContainsDataUriImage, O as fetchFeedItemsBySchemaName, dt as filterItemsByRichTextDataUriImagePolicy, ee as getFeedItemStringField, ke as getFeedItemsBySchemaName, k as getFeedItemsBySchemaNameForMonth, be as getSiteConfig, Mt as handleArchiveFeedRequest, jt as handleFeedRequest, x as initializeFeedPlatform, te as isEasAttestationExplorerUrl, E as loadFeedConfig, re as normalizeFeedItemFields, Me as parseRssString, ct as pickFeedItemContent, G as pickFeedItemDescription, ht as resetCacheManager, Se as resetSiteConfig, se as resolveSeedRssImageRelationFromItem, ce as resolveSeedRssImageRelationRef, T as resolveSiteConfig, xe as setSiteConfig, ye as teardownFeedPlatform };
|
|
1515
1403
|
|
|
1516
1404
|
//# sourceMappingURL=index.js.map
|