feedkeeper 0.44.2 → 0.45.0

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.
@@ -64,3 +64,34 @@ If the Work includes a "NOTICE" text file as part of its distribution, then any
64
64
 
65
65
  END OF TERMS AND CONDITIONS
66
66
  ```
67
+
68
+ ## oEmbed Providers
69
+
70
+ - **Source:** [iamcal/oembed](https://github.com/iamcal/oembed) (`https://oembed.com/providers.json`)
71
+ - **Copyright:** Copyright (c) 2016 Cal Henderson
72
+ - **License:** MIT License
73
+ - **Used in:** [`server/src/feeds/content/patterns/providers.json`](server/src/feeds/content/patterns/providers.json)
74
+
75
+ ```text
76
+ The MIT License (MIT)
77
+
78
+ Copyright (c) 2016 Cal Henderson
79
+
80
+ Permission is hereby granted, free of charge, to any person obtaining a copy
81
+ of this software and associated documentation files (the "Software"), to deal
82
+ in the Software without restriction, including without limitation the rights
83
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
84
+ copies of the Software, and to permit persons to whom the Software is
85
+ furnished to do so, subject to the following conditions:
86
+
87
+ The above copyright notice and this permission notice shall be included in all
88
+ copies or substantial portions of the Software.
89
+
90
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
91
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
92
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
93
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
94
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
95
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
96
+ SOFTWARE.
97
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feedkeeper",
3
- "version": "0.44.2",
3
+ "version": "0.45.0",
4
4
  "description": "A lightweight, self-hosted RSS reader and remote MCP server for your news, blogs, and AI workflows.",
5
5
  "keywords": [
6
6
  "rss",
@@ -7,6 +7,7 @@ export const HELP = `FeedKeeper: a self-hosted RSS reader and remote MCP server
7
7
  Usage:
8
8
  feedkeeper [options] Start the server
9
9
  feedkeeper mcp [options] Start in stdio MCP mode
10
+ feedkeeper doctor [options] Check configuration, paths, and SQLite health
10
11
  feedkeeper backup <file> Back up the database (see docs for restore)
11
12
  feedkeeper restore <file> --force Restore the database from a backup
12
13
 
@@ -73,6 +74,9 @@ export function parseArgs(argv) {
73
74
  else if (options.action === "start" && argument === "mcp") {
74
75
  options.action = "mcp";
75
76
  }
77
+ else if (options.action === "start" && argument === "doctor") {
78
+ options.action = "doctor";
79
+ }
76
80
  else if (options.action === "start" && (argument === "backup" || argument === "restore")) {
77
81
  options.action = argument;
78
82
  options.forwarded.push(argument);
@@ -0,0 +1,247 @@
1
+ import Database from "better-sqlite3";
2
+ import { constants, accessSync, existsSync, readFileSync, readdirSync, statfsSync } from "node:fs";
3
+ import { homedir } from "node:os";
4
+ import { dirname, join, resolve } from "node:path";
5
+ import { fileURLToPath, pathToFileURL } from "node:url";
6
+ import { APP_VERSION } from "./version.js";
7
+ const MIN_DISK_BYTES = 100 * 1024 * 1024; // 100 MiB
8
+ function parseSemver(version) {
9
+ const match = /^v?(\d+)\.(\d+)\.(\d+)/.exec(version.trim());
10
+ if (!match)
11
+ return null;
12
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
13
+ }
14
+ export function isSupportedNodeVersion(version) {
15
+ const parsed = parseSemver(version);
16
+ if (!parsed)
17
+ return false;
18
+ const [major, minor, patch] = parsed;
19
+ if (major === 22)
20
+ return minor > 22 || (minor === 22 && patch >= 2);
21
+ if (major === 24)
22
+ return minor > 15 || (minor === 15 && patch >= 0);
23
+ return major >= 26;
24
+ }
25
+ function nearestExistingDir(target) {
26
+ let current = resolve(target);
27
+ while (!existsSync(current)) {
28
+ const parent = dirname(current);
29
+ if (parent === current)
30
+ return null;
31
+ current = parent;
32
+ }
33
+ return current;
34
+ }
35
+ function isWritable(target) {
36
+ const existing = nearestExistingDir(target);
37
+ if (!existing)
38
+ return { writable: false, existing: null };
39
+ try {
40
+ accessSync(existing, constants.R_OK | constants.W_OK);
41
+ return { writable: true, existing };
42
+ }
43
+ catch {
44
+ return { writable: false, existing };
45
+ }
46
+ }
47
+ function formatMiB(bytes) {
48
+ return `${Math.round(bytes / (1024 * 1024))} MiB`;
49
+ }
50
+ /** Runs read-only diagnostics on the runtime, configuration, storage paths, and SQLite database. */
51
+ export function runDoctor(options = {}) {
52
+ const env = options.env ?? process.env;
53
+ const cwd = options.cwd ?? process.cwd();
54
+ const home = options.home ?? homedir();
55
+ const nodeVersion = options.nodeVersion ?? process.versions.node;
56
+ const checks = [];
57
+ if (isSupportedNodeVersion(nodeVersion)) {
58
+ checks.push({ name: "Node.js", status: "pass", detail: `v${nodeVersion} (supported)` });
59
+ }
60
+ else {
61
+ checks.push({
62
+ name: "Node.js",
63
+ status: "fail",
64
+ detail: `v${nodeVersion} is unsupported (requires ^22.22.2 || ^24.15.0 || >=26.0.0)`,
65
+ });
66
+ }
67
+ const configuredDb = env.DATABASE_PATH?.trim();
68
+ const dataDir = resolve(options.dataDir ?? (env.FEEDKEEPER_DATA_DIR?.trim() || (configuredDb ? dirname(resolve(configuredDb)) : join(home, ".feedkeeper"))));
69
+ const databasePath = options.dataDir !== undefined || !configuredDb ? join(dataDir, "feedkeeper.sqlite") : resolve(configuredDb);
70
+ const archivePath = env.ARCHIVE_PATH?.trim() ? resolve(env.ARCHIVE_PATH.trim()) : join(dirname(databasePath), "archive");
71
+ const imageCachePath = env.IMAGE_CACHE_PATH?.trim() ? resolve(env.IMAGE_CACHE_PATH.trim()) : join(dirname(databasePath), "image-cache");
72
+ const envSecret = env.SESSION_SECRET?.trim() ?? "";
73
+ const secretFilePath = join(dataDir, "session-secret");
74
+ let fileSecret = "";
75
+ if (!envSecret && existsSync(secretFilePath)) {
76
+ try {
77
+ fileSecret = readFileSync(secretFilePath, "utf8").trim();
78
+ }
79
+ catch (error) {
80
+ checks.push({
81
+ name: "SESSION_SECRET",
82
+ status: "fail",
83
+ detail: `Could not read ${secretFilePath}: ${error instanceof Error ? error.message : String(error)}`,
84
+ });
85
+ }
86
+ }
87
+ const effectiveSecret = envSecret || fileSecret;
88
+ if (effectiveSecret) {
89
+ const source = envSecret ? "environment" : secretFilePath;
90
+ if (effectiveSecret.length < 32) {
91
+ checks.push({
92
+ name: "SESSION_SECRET",
93
+ status: "warn",
94
+ detail: `Set via ${source}, but shorter than 32 characters`,
95
+ });
96
+ }
97
+ else {
98
+ checks.push({ name: "SESSION_SECRET", status: "pass", detail: `Configured via ${source}` });
99
+ }
100
+ }
101
+ else if (!checks.some(check => check.name === "SESSION_SECRET")) {
102
+ const envFile = resolve(cwd, ".env");
103
+ checks.push({
104
+ name: "SESSION_SECRET",
105
+ status: "warn",
106
+ detail: existsSync(envFile)
107
+ ? `Not set in ${envFile} or ${secretFilePath} (generated on first start in CLI mode)`
108
+ : "Not set (generated on first start in CLI mode; set explicitly for Docker/production)",
109
+ });
110
+ }
111
+ const publicUrl = (options.publicUrl ?? env.PUBLIC_URL?.trim()) || `http://localhost:${env.PORT?.trim() || 3000}`;
112
+ try {
113
+ const parsed = new URL(publicUrl);
114
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
115
+ checks.push({ name: "PUBLIC_URL", status: "fail", detail: `Invalid protocol "${parsed.protocol}" in ${publicUrl}` });
116
+ }
117
+ else if ((env.NODE_ENV ?? "production") === "production" && parsed.hostname === "localhost" && !env.PUBLIC_URL?.trim()) {
118
+ checks.push({ name: "PUBLIC_URL", status: "warn", detail: `Defaults to ${publicUrl} (set PUBLIC_URL for remote access or OAuth)` });
119
+ }
120
+ else {
121
+ checks.push({ name: "PUBLIC_URL", status: "pass", detail: publicUrl });
122
+ }
123
+ }
124
+ catch {
125
+ checks.push({ name: "PUBLIC_URL", status: "fail", detail: `Invalid URL "${publicUrl}"` });
126
+ }
127
+ for (const [label, target] of [
128
+ ["Data directory", dataDir],
129
+ ["Archive directory", archivePath],
130
+ ["Image cache directory", imageCachePath],
131
+ ]) {
132
+ const access = isWritable(target);
133
+ if (access.writable) {
134
+ const suffix = existsSync(target) ? "" : ` (will be created under ${access.existing})`;
135
+ checks.push({ name: label, status: "pass", detail: `${target} is writable${suffix}` });
136
+ }
137
+ else {
138
+ checks.push({
139
+ name: label,
140
+ status: "fail",
141
+ detail: `${target} is not writable${access.existing ? ` (checked ${access.existing})` : ""}`,
142
+ });
143
+ }
144
+ }
145
+ const diskTarget = nearestExistingDir(dataDir);
146
+ if (diskTarget) {
147
+ try {
148
+ const stats = statfsSync(diskTarget);
149
+ const freeBytes = Number(stats.bavail) * Number(stats.bsize);
150
+ if (freeBytes < MIN_DISK_BYTES) {
151
+ checks.push({ name: "Disk space", status: "warn", detail: `Only ${formatMiB(freeBytes)} free on ${diskTarget}` });
152
+ }
153
+ else {
154
+ checks.push({ name: "Disk space", status: "pass", detail: `${formatMiB(freeBytes)} free on ${diskTarget}` });
155
+ }
156
+ }
157
+ catch (error) {
158
+ checks.push({
159
+ name: "Disk space",
160
+ status: "warn",
161
+ detail: `Could not inspect free space on ${diskTarget}: ${error instanceof Error ? error.message : String(error)}`,
162
+ });
163
+ }
164
+ }
165
+ if (!existsSync(databasePath)) {
166
+ checks.push({
167
+ name: "SQLite database",
168
+ status: "warn",
169
+ detail: `${databasePath} does not exist yet (will be initialized on first start)`,
170
+ });
171
+ }
172
+ else {
173
+ let db = null;
174
+ try {
175
+ db = new Database(databasePath, { readonly: true, fileMustExist: true });
176
+ const integrity = db.pragma("quick_check", { simple: true });
177
+ if (integrity !== "ok") {
178
+ checks.push({ name: "SQLite database", status: "fail", detail: `${databasePath} failed quick_check: ${String(integrity)}` });
179
+ }
180
+ else {
181
+ const hasMigrations = db
182
+ .prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = '_migrations'")
183
+ .get();
184
+ if (!hasMigrations) {
185
+ checks.push({
186
+ name: "SQLite database",
187
+ status: "warn",
188
+ detail: `${databasePath} passed quick_check, but has no _migrations table yet`,
189
+ });
190
+ }
191
+ else {
192
+ const applied = db.prepare("SELECT COUNT(*) AS count FROM _migrations").get()?.count ?? 0;
193
+ const migrationsDir = join(dirname(fileURLToPath(import.meta.url)), "db", "migrations");
194
+ const available = existsSync(migrationsDir)
195
+ ? readdirSync(migrationsDir).filter(file => file.endsWith(".sql")).length
196
+ : applied;
197
+ const migrationInfo = applied < available ? `${applied}/${available} migrations applied` : `${applied} migrations applied`;
198
+ checks.push({ name: "SQLite database", status: "pass", detail: `${databasePath} ok (${migrationInfo})` });
199
+ }
200
+ }
201
+ }
202
+ catch (error) {
203
+ checks.push({
204
+ name: "SQLite database",
205
+ status: "fail",
206
+ detail: `Could not open ${databasePath}: ${error instanceof Error ? error.message : String(error)}`,
207
+ });
208
+ }
209
+ finally {
210
+ db?.close();
211
+ }
212
+ }
213
+ return {
214
+ version: APP_VERSION,
215
+ ok: checks.every(check => check.status !== "fail"),
216
+ checks,
217
+ };
218
+ }
219
+ export function formatDoctorReport(report) {
220
+ const tags = {
221
+ pass: "PASS",
222
+ warn: "WARN",
223
+ fail: "FAIL",
224
+ };
225
+ const lines = [`FeedKeeper doctor v${report.version}`, ""];
226
+ for (const check of report.checks) {
227
+ lines.push(`[${tags[check.status]}] ${check.name}: ${check.detail}`);
228
+ }
229
+ const fails = report.checks.filter(check => check.status === "fail").length;
230
+ const warns = report.checks.filter(check => check.status === "warn").length;
231
+ lines.push("");
232
+ lines.push(report.ok ? `Summary: ok (${warns} warning${warns === 1 ? "" : "s"})` : `Summary: ${fails} failed, ${warns} warning${warns === 1 ? "" : "s"}`);
233
+ return lines.join("\n");
234
+ }
235
+ export function runDoctorCli(options = {}) {
236
+ const envFile = resolve(options.cwd ?? process.cwd(), ".env");
237
+ if (existsSync(envFile) && !options.env) {
238
+ process.loadEnvFile(envFile);
239
+ }
240
+ const report = runDoctor(options);
241
+ console.log(formatDoctorReport(report));
242
+ return report.ok ? 0 : 1;
243
+ }
244
+ if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
245
+ process.exitCode = runDoctorCli();
246
+ }
247
+ //# sourceMappingURL=doctor-cli.js.map
@@ -14,6 +14,14 @@ async function main() {
14
14
  const envFile = resolve(process.cwd(), ".env");
15
15
  if (existsSync(envFile))
16
16
  process.loadEnvFile(envFile);
17
+ if (options.action === "doctor") {
18
+ const { runDoctorCli } = await import("./doctor-cli.js");
19
+ process.exitCode = runDoctorCli({
20
+ dataDir: options.dataDir,
21
+ publicUrl: options.publicUrl,
22
+ });
23
+ return;
24
+ }
17
25
  const prepared = prepareEnvironment(options, process.env);
18
26
  if (options.action === "backup" || options.action === "restore") {
19
27
  process.argv.splice(2, process.argv.length, ...options.forwarded);
@@ -5,12 +5,14 @@ export function socialPost(source) {
5
5
  const address = parseAddress(source.trim());
6
6
  if (!address || !/^https?:$/.test(address.protocol))
7
7
  return null;
8
- const host = address.hostname.replace(/^(?:www|m|mobile)\./, "");
9
- const platform = SOCIAL_PLATFORMS.find(candidate => candidate.host.test(host));
10
- if (!platform || !platform.post.test(`${address.pathname}${address.search}`))
8
+ const platform = SOCIAL_PLATFORMS.find(candidate => candidate.host.test(address.hostname) && candidate.post.test(address.href));
9
+ if (!platform)
11
10
  return null;
12
- const keepsQuery = platform.name === "Facebook";
13
- return { platform, url: `${address.origin}${address.pathname.replace(/\/embed\/?$/, "/")}${keepsQuery ? address.search : ""}` };
11
+ const keepsQuery = platform.name === "Facebook" || platform.name === "YouTube";
12
+ return {
13
+ platform,
14
+ url: `${address.origin}${address.pathname.replace(/\/embed\/?$/, "/")}${keepsQuery ? address.search : ""}`,
15
+ };
14
16
  }
15
17
  /** The post behind an embed iframe, which usually names it in the path or in a parameter. */
16
18
  export function socialFrameTarget(source) {
@@ -36,7 +38,10 @@ export function socialFrameTarget(source) {
36
38
  return inner ? socialPost(inner) : null;
37
39
  }
38
40
  if (MASTODON_EMBED_PATH.test(address.pathname) && /^https?:$/.test(address.protocol)) {
39
- return { platform: { name: "Mastodon", host: /.*/, post: MASTODON_EMBED_PATH, kind: "social" }, url: `${address.origin}${address.pathname.replace(/\/embed\/?$/, "")}` };
41
+ return {
42
+ platform: { name: "Mastodon", host: /.*/, post: MASTODON_EMBED_PATH, kind: "social" },
43
+ url: `${address.origin}${address.pathname.replace(/\/embed\/?$/, "")}`,
44
+ };
40
45
  }
41
46
  return socialPost(source);
42
47
  }
@@ -90,7 +95,7 @@ function resolveSocialEmbeds(root, stats) {
90
95
  /** Posts of social platforms and audio players become one link to the post. */
91
96
  export const socialEmbeds = {
92
97
  name: "social-embeds",
93
- description: "Instagram, X, TikTok, Bluesky, Threads, Reddit, Facebook posts and Spotify/SoundCloud players become one marked link.",
98
+ description: "Supported social posts and audio players become one marked link.",
94
99
  apply(root, stats) {
95
100
  const { changed, links } = resolveSocialEmbeds(root, stats);
96
101
  links.forEach(({ link, kind, source }) => {
@@ -1,4 +1,5 @@
1
1
  import { PLAY_LABEL, PLAYER_TITLES } from "../patterns/play-labels/index.js";
2
+ import { OEMBED_PROVIDER_PLATFORMS } from "../patterns/oembed-providers.js";
2
3
  import { flat, linkParagraph, parseAddress, pruneEmpty } from "../shared.js";
3
4
  const PLAY_SOURCE = /(?:^|[/_.-])play[-_]?(?:icon|button|btn)?\.(?:svg|png|webp|gif)(?:[?#]|$)/i;
4
5
  const DURATION = /^\d{1,2}:\d{2}(:\d{2})?$/;
@@ -8,39 +9,44 @@ function isPlayOverlay(image) {
8
9
  }
9
10
  /** Direct video URL of the embeds that are common enough to be worth a link. Anything else is not turned into a link. */
10
11
  export function embedTarget(source) {
11
- const parsed = parseAddress(source);
12
- if (!parsed)
12
+ const trimmed = source.trim();
13
+ const address = parseAddress(trimmed.startsWith("//") ? `https:${trimmed}` : trimmed);
14
+ if (!address || !/^https?:$/.test(address.protocol))
13
15
  return null;
14
- const address = parsed;
15
- const host = address.hostname.replace(/^www\./, "");
16
- const segments = address.pathname.split("/").filter(Boolean);
17
- if (/^youtube(-nocookie)?\.com$/.test(host) && segments[0] === "embed" && /^[\w-]{6,}$/.test(segments[1] ?? "")) {
18
- return { url: `https://www.youtube.com/watch?v=${segments[1]}`, name: "YouTube" };
19
- }
20
- if (/^(?:m\.)?youtube\.com$/.test(host) && segments[0] === "watch" && /^[\w-]{6,}$/.test(address.searchParams.get("v") ?? "")) {
21
- return { url: `https://www.youtube.com/watch?v=${address.searchParams.get("v")}`, name: "YouTube" };
16
+ const host = address.hostname.replace(/^(?:www|m|mobile)\./, "");
17
+ const provider = OEMBED_PROVIDER_PLATFORMS.find(candidate => candidate.kind === "video" && candidate.post.test(address.href));
18
+ if (provider?.name === "YouTube") {
19
+ const id = address.searchParams.get("v") ?? address.pathname.split("/").filter(Boolean).at(-1);
20
+ if (id && /^[\w-]{6,}$/.test(id)) {
21
+ return { url: `https://www.youtube.com/watch?v=${id}`, name: provider.name };
22
+ }
22
23
  }
23
- if (host === "youtu.be" && /^[\w-]{6,}$/.test(segments[0] ?? "")) {
24
- return { url: `https://www.youtube.com/watch?v=${segments[0]}`, name: "YouTube" };
24
+ if (provider?.name === "Vimeo" && host === "player.vimeo.com") {
25
+ const id = address.pathname.match(/\/video\/(\d{5,})$/)?.[1];
26
+ if (id) {
27
+ return { url: `https://vimeo.com/${id}`, name: provider.name };
28
+ }
25
29
  }
26
- if (host === "player.vimeo.com" && segments[0] === "video" && /^\d+$/.test(segments[1] ?? "")) {
27
- return { url: `https://vimeo.com/${segments[1]}`, name: "Vimeo" };
30
+ if (provider?.name === "Dailymotion") {
31
+ const id = address.pathname.match(/^\/video\/([a-zA-Z0-9]+)/)?.[1];
32
+ if (id) {
33
+ return { url: `https://www.dailymotion.com/video/${id}`, name: provider.name };
34
+ }
28
35
  }
29
- if (host === "dailymotion.com" && segments[0] === "embed" && segments[1] === "video" && /^\w+$/.test(segments[2] ?? "")) {
30
- return { url: `https://www.dailymotion.com/video/${segments[2]}`, name: "Dailymotion" };
36
+ if (host === "dailymotion.com") {
37
+ const id = address.pathname.match(/^\/embed\/video\/([\w]+)/)?.[1];
38
+ if (id) {
39
+ return { url: `https://www.dailymotion.com/video/${id}`, name: "Dailymotion" };
40
+ }
31
41
  }
32
42
  return null;
33
43
  }
34
44
  /** The name of the video site a watch-page address belongs to, for the labels of links that were saved without a title. */
35
45
  function videoSiteName(source) {
36
- const host = parseAddress(source)?.hostname.replace(/^(?:www|m)\./, "") ?? "";
37
- if (/^(?:youtube(?:-nocookie)?\.com|youtu\.be)$/.test(host))
38
- return "YouTube";
39
- if (/^(?:player\.)?vimeo\.com$/.test(host))
40
- return "Vimeo";
41
- if (/^dailymotion\.com$/.test(host))
42
- return "Dailymotion";
43
- return null;
46
+ const address = parseAddress(source);
47
+ if (!address)
48
+ return null;
49
+ return OEMBED_PROVIDER_PLATFORMS.find(platform => platform.kind === "video" && platform.post.test(address.href))?.name ?? null;
44
50
  }
45
51
  /**
46
52
  * Players need the publisher's script: a reader without it shows their play-button picture as a broken image and
@@ -0,0 +1,69 @@
1
+ import registry from "./providers.json" with { type: "json" };
2
+ export const OEMBED_PROVIDER_SNAPSHOT = registry.snapshot_date;
3
+ const VIDEO_PROVIDERS = new Set(["YouTube", "Vimeo", "Dailymotion"]);
4
+ const AUDIO_PROVIDERS = new Set(["SoundCloud", "Spotify"]);
5
+ function escapeRegex(value) {
6
+ return value.replace(/[.*+?^$()|[\]\\]/g, "\\$&");
7
+ }
8
+ function compileHost(rawHost) {
9
+ if (rawHost === "*.youtube.com") {
10
+ return `(?:[^.]+\\.)?youtube(?:-nocookie)?\\.com`;
11
+ }
12
+ if (rawHost.startsWith("*.")) {
13
+ return `(?:[^.]+\\.)?${escapeRegex(rawHost.slice(2)).replace(/\\\*/g, "[^.]+")}`;
14
+ }
15
+ const bare = rawHost.replace(/^www\./, "");
16
+ if (!bare.includes("*.") && bare.split(".").length === 2) {
17
+ return `(?:(?:www|m|mobile)\\.)?${escapeRegex(bare)}`;
18
+ }
19
+ return escapeRegex(rawHost).replace(/\\\*/g, "[^.]+");
20
+ }
21
+ function compileScheme(scheme) {
22
+ const match = /^(https?):\/\/([^/]+)(\/.*)$/.exec(scheme);
23
+ if (!match) {
24
+ throw new Error(`Invalid oEmbed scheme: ${scheme}`);
25
+ }
26
+ const host = compileHost(match[2]);
27
+ const path = escapeRegex(match[3]).replace(/\\\*/g, "[^#]*");
28
+ return new RegExp(`^${match[1]}://${host}${path}$`, "i");
29
+ }
30
+ /**
31
+ * Single-item URL matchers derived from the versioned oEmbed provider registry snapshot.
32
+ * Run `npm run update:oembed-providers` to refresh `providers.json`.
33
+ */
34
+ export const OEMBED_PROVIDER_PLATFORMS = registry.providers.map(provider => {
35
+ const name = provider.provider_name === "Bluesky Social" ? "Bluesky" : provider.provider_name;
36
+ const schemes = provider.schemes.map(compileScheme);
37
+ const paths = provider.item_paths.map(pattern => new RegExp(pattern, "i"));
38
+ const hosts = provider.schemes.map(scheme => {
39
+ const match = /^(https?):\/\/([^/]+)/.exec(scheme);
40
+ if (!match) {
41
+ throw new Error(`Invalid oEmbed scheme: ${scheme}`);
42
+ }
43
+ return compileHost(match[2]);
44
+ });
45
+ const host = new RegExp(`^(?:${[...new Set(hosts)].join("|")})$`, "i");
46
+ const post = {
47
+ test(value) {
48
+ try {
49
+ const url = new URL(value);
50
+ if (!host.test(url.hostname) ||
51
+ !schemes.some(pattern => pattern.test(url.href)) ||
52
+ !paths.some(pattern => pattern.test(url.pathname))) {
53
+ return false;
54
+ }
55
+ if (name === "YouTube" && url.pathname === "/watch" && !url.searchParams.has("v"))
56
+ return false;
57
+ if (name === "YouTube" && url.pathname === "/playlist" && !url.searchParams.has("list"))
58
+ return false;
59
+ return true;
60
+ }
61
+ catch {
62
+ return false;
63
+ }
64
+ },
65
+ };
66
+ const kind = VIDEO_PROVIDERS.has(name) ? "video" : AUDIO_PROVIDERS.has(name) ? "audio" : "social";
67
+ return { name, host, post, kind };
68
+ });
69
+ //# sourceMappingURL=oembed-providers.js.map
@@ -0,0 +1,152 @@
1
+ {
2
+ "source": "https://oembed.com/providers.json",
3
+ "snapshot_date": "2026-11-23",
4
+ "providers": [
5
+ {
6
+ "provider_name": "Bluesky Social",
7
+ "schemes": [
8
+ "https://bsky.app/profile/*/post/*"
9
+ ],
10
+ "item_paths": [
11
+ "^/profile/[^/]+/post/[^/]+/?$"
12
+ ]
13
+ },
14
+ {
15
+ "provider_name": "Dailymotion",
16
+ "schemes": [
17
+ "https://www.dailymotion.com/video/*",
18
+ "https://geo.dailymotion.com/player.html?video=*"
19
+ ],
20
+ "item_paths": [
21
+ "^/video/[A-Za-z0-9]+/?$"
22
+ ]
23
+ },
24
+ {
25
+ "provider_name": "Flickr",
26
+ "schemes": [
27
+ "https://*.flickr.com/photos/*",
28
+ "https://flic.kr/p/*",
29
+ "https://flic.kr/s/*",
30
+ "https://*.*.flickr.com/*/*"
31
+ ],
32
+ "item_paths": [
33
+ "^/photos/[^/]+/\\d+/?$",
34
+ "^/p/[^/]+/?$"
35
+ ]
36
+ },
37
+ {
38
+ "provider_name": "Instagram",
39
+ "schemes": [
40
+ "https://instagram.com/*/p/*",
41
+ "https://www.instagram.com/*/p/*",
42
+ "https://instagram.com/p/*",
43
+ "https://instagr.am/p/*",
44
+ "https://www.instagram.com/p/*",
45
+ "https://www.instagr.am/p/*",
46
+ "https://instagram.com/tv/*",
47
+ "https://instagr.am/tv/*",
48
+ "https://www.instagram.com/tv/*",
49
+ "https://www.instagr.am/tv/*",
50
+ "https://www.instagram.com/reel/*",
51
+ "https://instagram.com/reel/*",
52
+ "https://instagr.am/reel/*",
53
+ "https://www.instagram.com/*/reel/*",
54
+ "https://instagram.com/*/reel/*"
55
+ ],
56
+ "item_paths": [
57
+ "^/(?:[\\w.]+/)?(?:p|tv|reel|reels)/[\\w-]+/?$"
58
+ ]
59
+ },
60
+ {
61
+ "provider_name": "Reddit",
62
+ "schemes": [
63
+ "https://reddit.com/r/*/comments/*/*",
64
+ "https://www.reddit.com/r/*/comments/*/*"
65
+ ],
66
+ "item_paths": [
67
+ "^/r/[^/]+/comments/[^/]+"
68
+ ]
69
+ },
70
+ {
71
+ "provider_name": "SoundCloud",
72
+ "schemes": [
73
+ "https://soundcloud.com/*",
74
+ "https://on.soundcloud.com/*",
75
+ "https://soundcloud.app.goog.gl/*"
76
+ ],
77
+ "item_paths": [
78
+ "^/[^/]+/[^/]+/?$"
79
+ ]
80
+ },
81
+ {
82
+ "provider_name": "Spotify",
83
+ "schemes": [
84
+ "https://open.spotify.com/*",
85
+ "https://spotify.link/*"
86
+ ],
87
+ "item_paths": [
88
+ "^/(?:track|album|playlist|episode|show|artist)/[A-Za-z0-9]+/?$"
89
+ ]
90
+ },
91
+ {
92
+ "provider_name": "TikTok",
93
+ "schemes": [
94
+ "https://www.tiktok.com/*",
95
+ "https://www.tiktok.com/*/video/*"
96
+ ],
97
+ "item_paths": [
98
+ "^/@[^/]+/(?:video|photo)/\\d+/?$",
99
+ "^/(?:video|photo)/\\d+/?$"
100
+ ]
101
+ },
102
+ {
103
+ "provider_name": "Vimeo",
104
+ "schemes": [
105
+ "https://vimeo.com/*",
106
+ "https://vimeo.com/album/*/video/*",
107
+ "https://vimeo.com/channels/*/*",
108
+ "https://vimeo.com/groups/*/videos/*",
109
+ "https://vimeo.com/ondemand/*/*",
110
+ "https://player.vimeo.com/video/*",
111
+ "https://vimeo.com/event/*/*"
112
+ ],
113
+ "item_paths": [
114
+ "^/\\d{5,}/?$",
115
+ "^/channels/[^/]+/\\d{5,}/?$",
116
+ "^/video/\\d{5,}/?$"
117
+ ]
118
+ },
119
+ {
120
+ "provider_name": "X",
121
+ "schemes": [
122
+ "https://x.com/*",
123
+ "https://x.com/*/status/*",
124
+ "https://*.x.com/*/status/*"
125
+ ],
126
+ "item_paths": [
127
+ "^/(?:i/|[^/]+/)(?:web/)?status/\\d+/?$"
128
+ ]
129
+ },
130
+ {
131
+ "provider_name": "YouTube",
132
+ "schemes": [
133
+ "https://*.youtube.com/watch*",
134
+ "https://*.youtube.com/v/*",
135
+ "https://youtu.be/*",
136
+ "https://*.youtube.com/playlist?list=*",
137
+ "https://youtube.com/playlist?list=*",
138
+ "https://*.youtube.com/shorts*",
139
+ "https://youtube.com/shorts*",
140
+ "https://*.youtube.com/embed/*",
141
+ "https://*.youtube.com/live*",
142
+ "https://youtube.com/live*"
143
+ ],
144
+ "item_paths": [
145
+ "^/watch$",
146
+ "^/playlist$",
147
+ "^/(?:shorts|live|embed|v)/[\\w-]{6,}/?$",
148
+ "^/[\\w-]{6,}/?$"
149
+ ]
150
+ }
151
+ ]
152
+ }