@ox-content/vite-plugin 0.0.1-alpha.0 → 0.3.0-alpha.11

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.
@@ -0,0 +1,4 @@
1
+ const require_chunk = require('./chunk.cjs');
2
+ const require_mermaid = require('./mermaid2.cjs');
3
+
4
+ exports.transformMermaidStatic = require_mermaid.transformMermaidStatic;
@@ -0,0 +1,3 @@
1
+ import { n as transformMermaidStatic, t as mermaidClientScript } from "./mermaid2.js";
2
+
3
+ export { transformMermaidStatic };
@@ -0,0 +1,92 @@
1
+ const require_chunk = require('./chunk.cjs');
2
+ let node_fs = require("node:fs");
3
+ let node_path = require("node:path");
4
+ let node_url = require("node:url");
5
+
6
+ //#region src/plugins/mermaid.ts
7
+ /**
8
+ * Mermaid Plugin - Native Rust renderer via NAPI
9
+ *
10
+ * Renders mermaid code blocks to SVG using the native Rust renderer
11
+ * via NAPI. Delegates to the NAPI `transformMermaid` function which
12
+ * extracts mermaid code blocks from HTML and renders them using mmdc.
13
+ */
14
+ /** Cached NAPI bindings */
15
+ let napiBindings = null;
16
+ let napiLoadAttempted = false;
17
+ async function loadNapi() {
18
+ if (napiLoadAttempted) return napiBindings;
19
+ napiLoadAttempted = true;
20
+ try {
21
+ const mod = await import("@ox-content/napi");
22
+ const binding = mod.default ?? mod;
23
+ if (typeof binding.transformMermaid !== "function") {
24
+ napiBindings = null;
25
+ return null;
26
+ }
27
+ napiBindings = binding;
28
+ return binding;
29
+ } catch {
30
+ napiBindings = null;
31
+ return null;
32
+ }
33
+ }
34
+ let cachedMmdcPath;
35
+ function resolveMmdcPath() {
36
+ if (cachedMmdcPath !== void 0) return cachedMmdcPath;
37
+ try {
38
+ const entry = {}.resolve("@mermaid-js/mermaid-cli");
39
+ const cliPath = (0, node_url.fileURLToPath)(new URL("./cli.js", entry));
40
+ if ((0, node_fs.existsSync)(cliPath)) {
41
+ cachedMmdcPath = cliPath;
42
+ return cachedMmdcPath;
43
+ }
44
+ } catch {}
45
+ const binPath = (0, node_path.join)(process.cwd(), "node_modules", ".bin", "mmdc");
46
+ if ((0, node_fs.existsSync)(binPath)) {
47
+ cachedMmdcPath = binPath;
48
+ return cachedMmdcPath;
49
+ }
50
+ cachedMmdcPath = null;
51
+ return null;
52
+ }
53
+ /**
54
+ * Transforms mermaid code blocks in HTML to rendered SVG diagrams.
55
+ * Uses the native Rust NAPI transformMermaid function.
56
+ */
57
+ async function transformMermaidStatic(html, _options) {
58
+ const napi = await loadNapi();
59
+ if (!napi) return html;
60
+ const mmdcPath = resolveMmdcPath();
61
+ if (!mmdcPath) {
62
+ console.warn("[ox-content] mmdc not found, skipping mermaid rendering");
63
+ return html;
64
+ }
65
+ try {
66
+ const result = napi.transformMermaid(html, mmdcPath);
67
+ for (const error of result.errors) console.warn("[ox-content] Mermaid render error:", error);
68
+ return result.html;
69
+ } catch (err) {
70
+ console.warn("[ox-content] Mermaid transform error:", err);
71
+ return html;
72
+ }
73
+ }
74
+ /**
75
+ * @deprecated No longer used. Mermaid rendering is now done at build time via NAPI.
76
+ */
77
+ const mermaidClientScript = "";
78
+
79
+ //#endregion
80
+ Object.defineProperty(exports, 'mermaidClientScript', {
81
+ enumerable: true,
82
+ get: function () {
83
+ return mermaidClientScript;
84
+ }
85
+ });
86
+ Object.defineProperty(exports, 'transformMermaidStatic', {
87
+ enumerable: true,
88
+ get: function () {
89
+ return transformMermaidStatic;
90
+ }
91
+ });
92
+ //# sourceMappingURL=mermaid2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mermaid2.cjs","names":[],"sources":["../src/plugins/mermaid.ts"],"sourcesContent":["/**\n * Mermaid Plugin - Native Rust renderer via NAPI\n *\n * Renders mermaid code blocks to SVG using the native Rust renderer\n * via NAPI. Delegates to the NAPI `transformMermaid` function which\n * extracts mermaid code blocks from HTML and renders them using mmdc.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nexport interface MermaidOptions {\n /** Mermaid theme. Default: \"neutral\" */\n theme?: \"default\" | \"dark\" | \"forest\" | \"neutral\" | \"base\";\n}\n\n/** Cached NAPI bindings */\nlet napiBindings: {\n transformMermaid: (\n html: string,\n mmdcPath: string,\n ) => { html: string; errors: string[] };\n} | null = null;\n\nlet napiLoadAttempted = false;\n\nasync function loadNapi() {\n if (napiLoadAttempted) return napiBindings;\n napiLoadAttempted = true;\n try {\n const mod = await import(\"@ox-content/napi\");\n // CJS-to-ESM interop: native functions are on mod.default\n const binding = (mod.default ?? mod) as unknown as NonNullable<\n typeof napiBindings\n >;\n if (typeof binding.transformMermaid !== \"function\") {\n napiBindings = null;\n return null;\n }\n napiBindings = binding;\n return binding;\n } catch {\n napiBindings = null;\n return null;\n }\n}\n\nlet cachedMmdcPath: string | null | undefined;\n\nfunction resolveMmdcPath(): string | null {\n if (cachedMmdcPath !== undefined) return cachedMmdcPath;\n\n // 1. Resolve via import.meta.resolve (works in pnpm strict mode)\n // @mermaid-js/mermaid-cli exports ./src/index.js; cli.js is in the same dir\n try {\n const entry = import.meta.resolve(\"@mermaid-js/mermaid-cli\");\n const cliPath = fileURLToPath(new URL(\"./cli.js\", entry));\n if (existsSync(cliPath)) {\n cachedMmdcPath = cliPath;\n return cachedMmdcPath;\n }\n } catch {\n // not resolvable\n }\n\n // 2. Fallback: node_modules/.bin/mmdc relative to cwd\n const binPath = join(process.cwd(), \"node_modules\", \".bin\", \"mmdc\");\n if (existsSync(binPath)) {\n cachedMmdcPath = binPath;\n return cachedMmdcPath;\n }\n\n cachedMmdcPath = null;\n return null;\n}\n\n/**\n * Transforms mermaid code blocks in HTML to rendered SVG diagrams.\n * Uses the native Rust NAPI transformMermaid function.\n */\nexport async function transformMermaidStatic(\n html: string,\n _options?: MermaidOptions,\n): Promise<string> {\n const napi = await loadNapi();\n if (!napi) {\n return html;\n }\n\n const mmdcPath = resolveMmdcPath();\n if (!mmdcPath) {\n console.warn(\"[ox-content] mmdc not found, skipping mermaid rendering\");\n return html;\n }\n\n try {\n const result = napi.transformMermaid(html, mmdcPath);\n for (const error of result.errors) {\n console.warn(\"[ox-content] Mermaid render error:\", error);\n }\n return result.html;\n } catch (err) {\n console.warn(\"[ox-content] Mermaid transform error:\", err);\n return html;\n }\n}\n\n/**\n * @deprecated No longer used. Mermaid rendering is now done at build time via NAPI.\n */\nexport const mermaidClientScript = \"\";\n"],"mappings":";;;;;;;;;;;;;;AAkBA,IAAI,eAKO;AAEX,IAAI,oBAAoB;AAExB,eAAe,WAAW;AACxB,KAAI,kBAAmB,QAAO;AAC9B,qBAAoB;AACpB,KAAI;EACF,MAAM,MAAM,MAAM,OAAO;EAEzB,MAAM,UAAW,IAAI,WAAW;AAGhC,MAAI,OAAO,QAAQ,qBAAqB,YAAY;AAClD,kBAAe;AACf,UAAO;;AAET,iBAAe;AACf,SAAO;SACD;AACN,iBAAe;AACf,SAAO;;;AAIX,IAAI;AAEJ,SAAS,kBAAiC;AACxC,KAAI,mBAAmB,OAAW,QAAO;AAIzC,KAAI;EACF,MAAM,WAAoB,QAAQ,0BAA0B;EAC5D,MAAM,sCAAwB,IAAI,IAAI,YAAY,MAAM,CAAC;AACzD,8BAAe,QAAQ,EAAE;AACvB,oBAAiB;AACjB,UAAO;;SAEH;CAKR,MAAM,8BAAe,QAAQ,KAAK,EAAE,gBAAgB,QAAQ,OAAO;AACnE,6BAAe,QAAQ,EAAE;AACvB,mBAAiB;AACjB,SAAO;;AAGT,kBAAiB;AACjB,QAAO;;;;;;AAOT,eAAsB,uBACpB,MACA,UACiB;CACjB,MAAM,OAAO,MAAM,UAAU;AAC7B,KAAI,CAAC,KACH,QAAO;CAGT,MAAM,WAAW,iBAAiB;AAClC,KAAI,CAAC,UAAU;AACb,UAAQ,KAAK,0DAA0D;AACvE,SAAO;;AAGT,KAAI;EACF,MAAM,SAAS,KAAK,iBAAiB,MAAM,SAAS;AACpD,OAAK,MAAM,SAAS,OAAO,OACzB,SAAQ,KAAK,sCAAsC,MAAM;AAE3D,SAAO,OAAO;UACP,KAAK;AACZ,UAAQ,KAAK,yCAAyC,IAAI;AAC1D,SAAO;;;;;;AAOX,MAAa,sBAAsB"}
@@ -0,0 +1,80 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ //#region src/plugins/mermaid.ts
6
+ /**
7
+ * Mermaid Plugin - Native Rust renderer via NAPI
8
+ *
9
+ * Renders mermaid code blocks to SVG using the native Rust renderer
10
+ * via NAPI. Delegates to the NAPI `transformMermaid` function which
11
+ * extracts mermaid code blocks from HTML and renders them using mmdc.
12
+ */
13
+ /** Cached NAPI bindings */
14
+ let napiBindings = null;
15
+ let napiLoadAttempted = false;
16
+ async function loadNapi() {
17
+ if (napiLoadAttempted) return napiBindings;
18
+ napiLoadAttempted = true;
19
+ try {
20
+ const mod = await import("@ox-content/napi");
21
+ const binding = mod.default ?? mod;
22
+ if (typeof binding.transformMermaid !== "function") {
23
+ napiBindings = null;
24
+ return null;
25
+ }
26
+ napiBindings = binding;
27
+ return binding;
28
+ } catch {
29
+ napiBindings = null;
30
+ return null;
31
+ }
32
+ }
33
+ let cachedMmdcPath;
34
+ function resolveMmdcPath() {
35
+ if (cachedMmdcPath !== void 0) return cachedMmdcPath;
36
+ try {
37
+ const entry = import.meta.resolve("@mermaid-js/mermaid-cli");
38
+ const cliPath = fileURLToPath(new URL("./cli.js", entry));
39
+ if (existsSync(cliPath)) {
40
+ cachedMmdcPath = cliPath;
41
+ return cachedMmdcPath;
42
+ }
43
+ } catch {}
44
+ const binPath = join(process.cwd(), "node_modules", ".bin", "mmdc");
45
+ if (existsSync(binPath)) {
46
+ cachedMmdcPath = binPath;
47
+ return cachedMmdcPath;
48
+ }
49
+ cachedMmdcPath = null;
50
+ return null;
51
+ }
52
+ /**
53
+ * Transforms mermaid code blocks in HTML to rendered SVG diagrams.
54
+ * Uses the native Rust NAPI transformMermaid function.
55
+ */
56
+ async function transformMermaidStatic(html, _options) {
57
+ const napi = await loadNapi();
58
+ if (!napi) return html;
59
+ const mmdcPath = resolveMmdcPath();
60
+ if (!mmdcPath) {
61
+ console.warn("[ox-content] mmdc not found, skipping mermaid rendering");
62
+ return html;
63
+ }
64
+ try {
65
+ const result = napi.transformMermaid(html, mmdcPath);
66
+ for (const error of result.errors) console.warn("[ox-content] Mermaid render error:", error);
67
+ return result.html;
68
+ } catch (err) {
69
+ console.warn("[ox-content] Mermaid transform error:", err);
70
+ return html;
71
+ }
72
+ }
73
+ /**
74
+ * @deprecated No longer used. Mermaid rendering is now done at build time via NAPI.
75
+ */
76
+ const mermaidClientScript = "";
77
+
78
+ //#endregion
79
+ export { transformMermaidStatic as n, mermaidClientScript as t };
80
+ //# sourceMappingURL=mermaid2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mermaid2.js","names":[],"sources":["../src/plugins/mermaid.ts"],"sourcesContent":["/**\n * Mermaid Plugin - Native Rust renderer via NAPI\n *\n * Renders mermaid code blocks to SVG using the native Rust renderer\n * via NAPI. Delegates to the NAPI `transformMermaid` function which\n * extracts mermaid code blocks from HTML and renders them using mmdc.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nexport interface MermaidOptions {\n /** Mermaid theme. Default: \"neutral\" */\n theme?: \"default\" | \"dark\" | \"forest\" | \"neutral\" | \"base\";\n}\n\n/** Cached NAPI bindings */\nlet napiBindings: {\n transformMermaid: (\n html: string,\n mmdcPath: string,\n ) => { html: string; errors: string[] };\n} | null = null;\n\nlet napiLoadAttempted = false;\n\nasync function loadNapi() {\n if (napiLoadAttempted) return napiBindings;\n napiLoadAttempted = true;\n try {\n const mod = await import(\"@ox-content/napi\");\n // CJS-to-ESM interop: native functions are on mod.default\n const binding = (mod.default ?? mod) as unknown as NonNullable<\n typeof napiBindings\n >;\n if (typeof binding.transformMermaid !== \"function\") {\n napiBindings = null;\n return null;\n }\n napiBindings = binding;\n return binding;\n } catch {\n napiBindings = null;\n return null;\n }\n}\n\nlet cachedMmdcPath: string | null | undefined;\n\nfunction resolveMmdcPath(): string | null {\n if (cachedMmdcPath !== undefined) return cachedMmdcPath;\n\n // 1. Resolve via import.meta.resolve (works in pnpm strict mode)\n // @mermaid-js/mermaid-cli exports ./src/index.js; cli.js is in the same dir\n try {\n const entry = import.meta.resolve(\"@mermaid-js/mermaid-cli\");\n const cliPath = fileURLToPath(new URL(\"./cli.js\", entry));\n if (existsSync(cliPath)) {\n cachedMmdcPath = cliPath;\n return cachedMmdcPath;\n }\n } catch {\n // not resolvable\n }\n\n // 2. Fallback: node_modules/.bin/mmdc relative to cwd\n const binPath = join(process.cwd(), \"node_modules\", \".bin\", \"mmdc\");\n if (existsSync(binPath)) {\n cachedMmdcPath = binPath;\n return cachedMmdcPath;\n }\n\n cachedMmdcPath = null;\n return null;\n}\n\n/**\n * Transforms mermaid code blocks in HTML to rendered SVG diagrams.\n * Uses the native Rust NAPI transformMermaid function.\n */\nexport async function transformMermaidStatic(\n html: string,\n _options?: MermaidOptions,\n): Promise<string> {\n const napi = await loadNapi();\n if (!napi) {\n return html;\n }\n\n const mmdcPath = resolveMmdcPath();\n if (!mmdcPath) {\n console.warn(\"[ox-content] mmdc not found, skipping mermaid rendering\");\n return html;\n }\n\n try {\n const result = napi.transformMermaid(html, mmdcPath);\n for (const error of result.errors) {\n console.warn(\"[ox-content] Mermaid render error:\", error);\n }\n return result.html;\n } catch (err) {\n console.warn(\"[ox-content] Mermaid transform error:\", err);\n return html;\n }\n}\n\n/**\n * @deprecated No longer used. Mermaid rendering is now done at build time via NAPI.\n */\nexport const mermaidClientScript = \"\";\n"],"mappings":";;;;;;;;;;;;;AAkBA,IAAI,eAKO;AAEX,IAAI,oBAAoB;AAExB,eAAe,WAAW;AACxB,KAAI,kBAAmB,QAAO;AAC9B,qBAAoB;AACpB,KAAI;EACF,MAAM,MAAM,MAAM,OAAO;EAEzB,MAAM,UAAW,IAAI,WAAW;AAGhC,MAAI,OAAO,QAAQ,qBAAqB,YAAY;AAClD,kBAAe;AACf,UAAO;;AAET,iBAAe;AACf,SAAO;SACD;AACN,iBAAe;AACf,SAAO;;;AAIX,IAAI;AAEJ,SAAS,kBAAiC;AACxC,KAAI,mBAAmB,OAAW,QAAO;AAIzC,KAAI;EACF,MAAM,QAAQ,OAAO,KAAK,QAAQ,0BAA0B;EAC5D,MAAM,UAAU,cAAc,IAAI,IAAI,YAAY,MAAM,CAAC;AACzD,MAAI,WAAW,QAAQ,EAAE;AACvB,oBAAiB;AACjB,UAAO;;SAEH;CAKR,MAAM,UAAU,KAAK,QAAQ,KAAK,EAAE,gBAAgB,QAAQ,OAAO;AACnE,KAAI,WAAW,QAAQ,EAAE;AACvB,mBAAiB;AACjB,SAAO;;AAGT,kBAAiB;AACjB,QAAO;;;;;;AAOT,eAAsB,uBACpB,MACA,UACiB;CACjB,MAAM,OAAO,MAAM,UAAU;AAC7B,KAAI,CAAC,KACH,QAAO;CAGT,MAAM,WAAW,iBAAiB;AAClC,KAAI,CAAC,UAAU;AACb,UAAQ,KAAK,0DAA0D;AACvE,SAAO;;AAGT,KAAI;EACF,MAAM,SAAS,KAAK,iBAAiB,MAAM,SAAS;AACpD,OAAK,MAAM,SAAS,OAAO,OACzB,SAAQ,KAAK,sCAAsC,MAAM;AAE3D,SAAO,OAAO;UACP,KAAK;AACZ,UAAQ,KAAK,yCAAyC,IAAI;AAC1D,SAAO;;;;;;AAOX,MAAa,sBAAsB"}
package/dist/ogp.cjs ADDED
@@ -0,0 +1,4 @@
1
+ const require_chunk = require('./chunk.cjs');
2
+ const require_ogp = require('./ogp2.cjs');
3
+
4
+ exports.transformOgp = require_ogp.transformOgp;
package/dist/ogp.js ADDED
@@ -0,0 +1,3 @@
1
+ import { i as transformOgp, n as fetchOgpData, r as prefetchOgpData, t as collectOgpUrls } from "./ogp2.js";
2
+
3
+ export { transformOgp };
package/dist/ogp2.cjs ADDED
@@ -0,0 +1,306 @@
1
+ const require_chunk = require('./chunk.cjs');
2
+ let unified = require("unified");
3
+ let rehype_parse = require("rehype-parse");
4
+ rehype_parse = require_chunk.__toESM(rehype_parse);
5
+ let rehype_stringify = require("rehype-stringify");
6
+ rehype_stringify = require_chunk.__toESM(rehype_stringify);
7
+
8
+ //#region src/plugins/ogp.ts
9
+ /**
10
+ * OGP Card Plugin - Link card embedding
11
+ *
12
+ * Transforms <OgCard> components into static link preview cards
13
+ * by fetching OGP metadata at build time.
14
+ */
15
+ const defaultOptions = {
16
+ timeout: 1e4,
17
+ cache: true,
18
+ cacheTTL: 36e5,
19
+ userAgent: "ox-content-ogp-bot/1.0 (compatible; +https://github.com/ubugeeei/ox-content)"
20
+ };
21
+ const ogpCache = /* @__PURE__ */ new Map();
22
+ /**
23
+ * Get element attribute value.
24
+ */
25
+ function getAttribute(el, name) {
26
+ const value = el.properties?.[name];
27
+ if (typeof value === "string") return value;
28
+ if (Array.isArray(value)) return value.join(" ");
29
+ }
30
+ /**
31
+ * Extract domain from URL.
32
+ */
33
+ function extractDomain(url) {
34
+ try {
35
+ return new URL(url).hostname;
36
+ } catch {
37
+ return url;
38
+ }
39
+ }
40
+ /**
41
+ * Get favicon URL for a domain.
42
+ */
43
+ function getFaviconUrl(url) {
44
+ try {
45
+ return `https://www.google.com/s2/favicons?domain=${new URL(url).hostname}&sz=32`;
46
+ } catch {
47
+ return "";
48
+ }
49
+ }
50
+ /**
51
+ * Parse OGP metadata from HTML.
52
+ */
53
+ function parseOgpFromHtml(html, url) {
54
+ const result = {
55
+ url,
56
+ title: ""
57
+ };
58
+ const titleMatch = html.match(/<title[^>]*>([^<]+)<\/title>/i);
59
+ result.title = (html.match(/<meta[^>]*property=["']og:title["'][^>]*content=["']([^"']+)["']/i) || html.match(/<meta[^>]*content=["']([^"']+)["'][^>]*property=["']og:title["']/i))?.[1] || titleMatch?.[1] || extractDomain(url);
60
+ const descMatch = html.match(/<meta[^>]*property=["']og:description["'][^>]*content=["']([^"']+)["']/i) || html.match(/<meta[^>]*content=["']([^"']+)["'][^>]*property=["']og:description["']/i) || html.match(/<meta[^>]*name=["']description["'][^>]*content=["']([^"']+)["']/i) || html.match(/<meta[^>]*content=["']([^"']+)["'][^>]*name=["']description["']/i);
61
+ if (descMatch) result.description = descMatch[1];
62
+ const imageMatch = html.match(/<meta[^>]*property=["']og:image["'][^>]*content=["']([^"']+)["']/i) || html.match(/<meta[^>]*content=["']([^"']+)["'][^>]*property=["']og:image["']/i);
63
+ if (imageMatch) {
64
+ let imageUrl = imageMatch[1];
65
+ if (imageUrl.startsWith("/")) try {
66
+ const urlObj = new URL(url);
67
+ imageUrl = `${urlObj.protocol}//${urlObj.host}${imageUrl}`;
68
+ } catch {}
69
+ result.image = imageUrl;
70
+ }
71
+ const siteNameMatch = html.match(/<meta[^>]*property=["']og:site_name["'][^>]*content=["']([^"']+)["']/i) || html.match(/<meta[^>]*content=["']([^"']+)["'][^>]*property=["']og:site_name["']/i);
72
+ if (siteNameMatch) result.siteName = siteNameMatch[1];
73
+ result.favicon = getFaviconUrl(url);
74
+ return result;
75
+ }
76
+ /**
77
+ * Fetch OGP data for a URL.
78
+ */
79
+ async function fetchOgpData(url, options) {
80
+ if (options.cache) {
81
+ const cached = ogpCache.get(url);
82
+ if (cached && Date.now() - cached.timestamp < options.cacheTTL) return cached.data;
83
+ }
84
+ try {
85
+ const controller = new AbortController();
86
+ const timeoutId = setTimeout(() => controller.abort(), options.timeout);
87
+ const response = await fetch(url, {
88
+ headers: {
89
+ "User-Agent": options.userAgent,
90
+ Accept: "text/html,application/xhtml+xml"
91
+ },
92
+ signal: controller.signal
93
+ });
94
+ clearTimeout(timeoutId);
95
+ if (!response.ok) {
96
+ console.warn(`Failed to fetch OGP for ${url}: ${response.status}`);
97
+ return null;
98
+ }
99
+ const data = parseOgpFromHtml(await response.text(), url);
100
+ if (options.cache) ogpCache.set(url, {
101
+ data,
102
+ timestamp: Date.now()
103
+ });
104
+ return data;
105
+ } catch (error) {
106
+ if (error instanceof Error && error.name === "AbortError") console.warn(`Timeout fetching OGP for ${url}`);
107
+ else console.warn(`Error fetching OGP for ${url}:`, error);
108
+ return null;
109
+ }
110
+ }
111
+ /**
112
+ * Create OGP card element.
113
+ */
114
+ function createOgpCard(data) {
115
+ const children = [];
116
+ const contentChildren = [];
117
+ contentChildren.push({
118
+ type: "element",
119
+ tagName: "div",
120
+ properties: { className: ["ox-ogp-title"] },
121
+ children: [{
122
+ type: "text",
123
+ value: data.title
124
+ }]
125
+ });
126
+ if (data.description) contentChildren.push({
127
+ type: "element",
128
+ tagName: "div",
129
+ properties: { className: ["ox-ogp-description"] },
130
+ children: [{
131
+ type: "text",
132
+ value: data.description
133
+ }]
134
+ });
135
+ const metaChildren = [];
136
+ if (data.favicon) metaChildren.push({
137
+ type: "element",
138
+ tagName: "img",
139
+ properties: {
140
+ className: ["ox-ogp-favicon"],
141
+ src: data.favicon,
142
+ alt: "",
143
+ loading: "lazy"
144
+ },
145
+ children: []
146
+ });
147
+ metaChildren.push({
148
+ type: "element",
149
+ tagName: "span",
150
+ properties: { className: ["ox-ogp-domain"] },
151
+ children: [{
152
+ type: "text",
153
+ value: data.siteName || extractDomain(data.url)
154
+ }]
155
+ });
156
+ contentChildren.push({
157
+ type: "element",
158
+ tagName: "div",
159
+ properties: { className: ["ox-ogp-meta"] },
160
+ children: metaChildren
161
+ });
162
+ children.push({
163
+ type: "element",
164
+ tagName: "div",
165
+ properties: { className: ["ox-ogp-content"] },
166
+ children: contentChildren
167
+ });
168
+ if (data.image) children.push({
169
+ type: "element",
170
+ tagName: "img",
171
+ properties: {
172
+ className: ["ox-ogp-image"],
173
+ src: data.image,
174
+ alt: "",
175
+ loading: "lazy"
176
+ },
177
+ children: []
178
+ });
179
+ return {
180
+ type: "element",
181
+ tagName: "a",
182
+ properties: {
183
+ className: ["ox-ogp-card"],
184
+ href: data.url,
185
+ target: "_blank",
186
+ rel: "noopener noreferrer"
187
+ },
188
+ children
189
+ };
190
+ }
191
+ /**
192
+ * Create fallback element when OGP data is unavailable.
193
+ */
194
+ function createFallbackCard(url) {
195
+ return {
196
+ type: "element",
197
+ tagName: "a",
198
+ properties: {
199
+ className: ["ox-ogp-simple"],
200
+ href: url,
201
+ target: "_blank",
202
+ rel: "noopener noreferrer"
203
+ },
204
+ children: [{
205
+ type: "element",
206
+ tagName: "svg",
207
+ properties: {
208
+ viewBox: "0 0 24 24",
209
+ fill: "none",
210
+ stroke: "currentColor",
211
+ "stroke-width": "2"
212
+ },
213
+ children: [{
214
+ type: "element",
215
+ tagName: "path",
216
+ properties: { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14L21 3" },
217
+ children: []
218
+ }]
219
+ }, {
220
+ type: "text",
221
+ value: extractDomain(url)
222
+ }]
223
+ };
224
+ }
225
+ /**
226
+ * Collect all OGP URLs from HTML for pre-fetching.
227
+ */
228
+ async function collectOgpUrls(html) {
229
+ const urls = [];
230
+ const urlPattern = /<ogcard[^>]*\s+url=["']([^"']+)["']/gi;
231
+ let match;
232
+ while ((match = urlPattern.exec(html)) !== null) urls.push(match[1]);
233
+ return urls;
234
+ }
235
+ /**
236
+ * Pre-fetch all OGP data.
237
+ */
238
+ async function prefetchOgpData(urls, options) {
239
+ const mergedOptions = {
240
+ ...defaultOptions,
241
+ ...options
242
+ };
243
+ const results = /* @__PURE__ */ new Map();
244
+ await Promise.all(urls.map(async (url) => {
245
+ const data = await fetchOgpData(url, mergedOptions);
246
+ results.set(url, data);
247
+ }));
248
+ return results;
249
+ }
250
+ /**
251
+ * Rehype plugin to transform OgCard components.
252
+ */
253
+ function rehypeOgp(ogpDataMap) {
254
+ return (tree) => {
255
+ const visit = (node) => {
256
+ if ("children" in node) for (let i = 0; i < node.children.length; i++) {
257
+ const child = node.children[i];
258
+ if (child.type === "element") if (child.tagName.toLowerCase() === "ogcard") {
259
+ const url = getAttribute(child, "url");
260
+ if (url) {
261
+ const ogpData = ogpDataMap.get(url);
262
+ const cardElement = ogpData ? createOgpCard(ogpData) : createFallbackCard(url);
263
+ node.children[i] = cardElement;
264
+ }
265
+ } else visit(child);
266
+ }
267
+ };
268
+ visit(tree);
269
+ };
270
+ }
271
+ /**
272
+ * Transform OgCard components in HTML.
273
+ */
274
+ async function transformOgp(html, ogpDataMap, options) {
275
+ let dataMap = ogpDataMap;
276
+ if (!dataMap) dataMap = await prefetchOgpData(await collectOgpUrls(html), options);
277
+ const result = await (0, unified.unified)().use(rehype_parse.default, { fragment: true }).use(rehypeOgp, dataMap).use(rehype_stringify.default).process(html);
278
+ return String(result);
279
+ }
280
+
281
+ //#endregion
282
+ Object.defineProperty(exports, 'collectOgpUrls', {
283
+ enumerable: true,
284
+ get: function () {
285
+ return collectOgpUrls;
286
+ }
287
+ });
288
+ Object.defineProperty(exports, 'fetchOgpData', {
289
+ enumerable: true,
290
+ get: function () {
291
+ return fetchOgpData;
292
+ }
293
+ });
294
+ Object.defineProperty(exports, 'prefetchOgpData', {
295
+ enumerable: true,
296
+ get: function () {
297
+ return prefetchOgpData;
298
+ }
299
+ });
300
+ Object.defineProperty(exports, 'transformOgp', {
301
+ enumerable: true,
302
+ get: function () {
303
+ return transformOgp;
304
+ }
305
+ });
306
+ //# sourceMappingURL=ogp2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ogp2.cjs","names":["rehypeParse","rehypeStringify"],"sources":["../src/plugins/ogp.ts"],"sourcesContent":["/**\n * OGP Card Plugin - Link card embedding\n *\n * Transforms <OgCard> components into static link preview cards\n * by fetching OGP metadata at build time.\n */\n\nimport { unified } from \"unified\";\nimport rehypeParse from \"rehype-parse\";\nimport rehypeStringify from \"rehype-stringify\";\nimport type { Root, Element } from \"hast\";\n\nexport interface OgpData {\n url: string;\n title: string;\n description?: string;\n image?: string;\n siteName?: string;\n favicon?: string;\n}\n\nexport interface OgpOptions {\n /** Request timeout in milliseconds. Default: 10000 */\n timeout?: number;\n /** Cache fetched data. Default: true */\n cache?: boolean;\n /** Cache TTL in milliseconds. Default: 3600000 (1 hour) */\n cacheTTL?: number;\n /** User agent for requests */\n userAgent?: string;\n}\n\nconst defaultOptions: Required<OgpOptions> = {\n timeout: 10000,\n cache: true,\n cacheTTL: 3600000,\n userAgent: \"ox-content-ogp-bot/1.0 (compatible; +https://github.com/ubugeeei/ox-content)\",\n};\n\n// Simple in-memory cache\nconst ogpCache = new Map<string, { data: OgpData; timestamp: number }>();\n\n/**\n * Get element attribute value.\n */\nfunction getAttribute(el: Element, name: string): string | undefined {\n const value = el.properties?.[name];\n if (typeof value === \"string\") return value;\n if (Array.isArray(value)) return value.join(\" \");\n return undefined;\n}\n\n/**\n * Extract domain from URL.\n */\nfunction extractDomain(url: string): string {\n try {\n const urlObj = new URL(url);\n return urlObj.hostname;\n } catch {\n return url;\n }\n}\n\n/**\n * Get favicon URL for a domain.\n */\nfunction getFaviconUrl(url: string): string {\n try {\n const urlObj = new URL(url);\n // Use Google's favicon service as fallback\n return `https://www.google.com/s2/favicons?domain=${urlObj.hostname}&sz=32`;\n } catch {\n return \"\";\n }\n}\n\n/**\n * Parse OGP metadata from HTML.\n */\nfunction parseOgpFromHtml(html: string, url: string): OgpData {\n const result: OgpData = {\n url,\n title: \"\",\n };\n\n // Extract title\n const titleMatch = html.match(/<title[^>]*>([^<]+)<\\/title>/i);\n const ogTitleMatch = html.match(/<meta[^>]*property=[\"']og:title[\"'][^>]*content=[\"']([^\"']+)[\"']/i) ||\n html.match(/<meta[^>]*content=[\"']([^\"']+)[\"'][^>]*property=[\"']og:title[\"']/i);\n\n result.title = ogTitleMatch?.[1] || titleMatch?.[1] || extractDomain(url);\n\n // Extract description\n const descMatch = html.match(/<meta[^>]*property=[\"']og:description[\"'][^>]*content=[\"']([^\"']+)[\"']/i) ||\n html.match(/<meta[^>]*content=[\"']([^\"']+)[\"'][^>]*property=[\"']og:description[\"']/i) ||\n html.match(/<meta[^>]*name=[\"']description[\"'][^>]*content=[\"']([^\"']+)[\"']/i) ||\n html.match(/<meta[^>]*content=[\"']([^\"']+)[\"'][^>]*name=[\"']description[\"']/i);\n\n if (descMatch) {\n result.description = descMatch[1];\n }\n\n // Extract image\n const imageMatch = html.match(/<meta[^>]*property=[\"']og:image[\"'][^>]*content=[\"']([^\"']+)[\"']/i) ||\n html.match(/<meta[^>]*content=[\"']([^\"']+)[\"'][^>]*property=[\"']og:image[\"']/i);\n\n if (imageMatch) {\n let imageUrl = imageMatch[1];\n // Handle relative URLs\n if (imageUrl.startsWith(\"/\")) {\n try {\n const urlObj = new URL(url);\n imageUrl = `${urlObj.protocol}//${urlObj.host}${imageUrl}`;\n } catch {\n // Keep as is\n }\n }\n result.image = imageUrl;\n }\n\n // Extract site name\n const siteNameMatch = html.match(/<meta[^>]*property=[\"']og:site_name[\"'][^>]*content=[\"']([^\"']+)[\"']/i) ||\n html.match(/<meta[^>]*content=[\"']([^\"']+)[\"'][^>]*property=[\"']og:site_name[\"']/i);\n\n if (siteNameMatch) {\n result.siteName = siteNameMatch[1];\n }\n\n // Get favicon\n result.favicon = getFaviconUrl(url);\n\n return result;\n}\n\n/**\n * Fetch OGP data for a URL.\n */\nexport async function fetchOgpData(url: string, options: Required<OgpOptions>): Promise<OgpData | null> {\n // Check cache\n if (options.cache) {\n const cached = ogpCache.get(url);\n if (cached && Date.now() - cached.timestamp < options.cacheTTL) {\n return cached.data;\n }\n }\n\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), options.timeout);\n\n const response = await fetch(url, {\n headers: {\n \"User-Agent\": options.userAgent,\n Accept: \"text/html,application/xhtml+xml\",\n },\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n console.warn(`Failed to fetch OGP for ${url}: ${response.status}`);\n return null;\n }\n\n const html = await response.text();\n const data = parseOgpFromHtml(html, url);\n\n // Cache the result\n if (options.cache) {\n ogpCache.set(url, { data, timestamp: Date.now() });\n }\n\n return data;\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n console.warn(`Timeout fetching OGP for ${url}`);\n } else {\n console.warn(`Error fetching OGP for ${url}:`, error);\n }\n return null;\n }\n}\n\n/**\n * Create OGP card element.\n */\nfunction createOgpCard(data: OgpData): Element {\n const children: Element[\"children\"] = [];\n\n // Content section\n const contentChildren: Element[\"children\"] = [];\n\n // Title\n contentChildren.push({\n type: \"element\",\n tagName: \"div\",\n properties: { className: [\"ox-ogp-title\"] },\n children: [{ type: \"text\", value: data.title }],\n });\n\n // Description\n if (data.description) {\n contentChildren.push({\n type: \"element\",\n tagName: \"div\",\n properties: { className: [\"ox-ogp-description\"] },\n children: [{ type: \"text\", value: data.description }],\n });\n }\n\n // Meta (favicon + domain)\n const metaChildren: Element[\"children\"] = [];\n\n if (data.favicon) {\n metaChildren.push({\n type: \"element\",\n tagName: \"img\",\n properties: {\n className: [\"ox-ogp-favicon\"],\n src: data.favicon,\n alt: \"\",\n loading: \"lazy\",\n },\n children: [],\n });\n }\n\n metaChildren.push({\n type: \"element\",\n tagName: \"span\",\n properties: { className: [\"ox-ogp-domain\"] },\n children: [{ type: \"text\", value: data.siteName || extractDomain(data.url) }],\n });\n\n contentChildren.push({\n type: \"element\",\n tagName: \"div\",\n properties: { className: [\"ox-ogp-meta\"] },\n children: metaChildren,\n });\n\n children.push({\n type: \"element\",\n tagName: \"div\",\n properties: { className: [\"ox-ogp-content\"] },\n children: contentChildren,\n });\n\n // Image\n if (data.image) {\n children.push({\n type: \"element\",\n tagName: \"img\",\n properties: {\n className: [\"ox-ogp-image\"],\n src: data.image,\n alt: \"\",\n loading: \"lazy\",\n },\n children: [],\n });\n }\n\n return {\n type: \"element\",\n tagName: \"a\",\n properties: {\n className: [\"ox-ogp-card\"],\n href: data.url,\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n },\n children,\n };\n}\n\n/**\n * Create fallback element when OGP data is unavailable.\n */\nfunction createFallbackCard(url: string): Element {\n return {\n type: \"element\",\n tagName: \"a\",\n properties: {\n className: [\"ox-ogp-simple\"],\n href: url,\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n },\n children: [\n {\n type: \"element\",\n tagName: \"svg\",\n properties: {\n viewBox: \"0 0 24 24\",\n fill: \"none\",\n stroke: \"currentColor\",\n \"stroke-width\": \"2\",\n },\n children: [\n {\n type: \"element\",\n tagName: \"path\",\n properties: {\n d: \"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14L21 3\",\n },\n children: [],\n },\n ],\n },\n { type: \"text\", value: extractDomain(url) },\n ],\n };\n}\n\n/**\n * Collect all OGP URLs from HTML for pre-fetching.\n */\nexport async function collectOgpUrls(html: string): Promise<string[]> {\n const urls: string[] = [];\n const urlPattern = /<ogcard[^>]*\\s+url=[\"']([^\"']+)[\"']/gi;\n\n let match;\n while ((match = urlPattern.exec(html)) !== null) {\n urls.push(match[1]);\n }\n\n return urls;\n}\n\n/**\n * Pre-fetch all OGP data.\n */\nexport async function prefetchOgpData(urls: string[], options?: OgpOptions): Promise<Map<string, OgpData | null>> {\n const mergedOptions = { ...defaultOptions, ...options };\n const results = new Map<string, OgpData | null>();\n\n await Promise.all(\n urls.map(async (url) => {\n const data = await fetchOgpData(url, mergedOptions);\n results.set(url, data);\n }),\n );\n\n return results;\n}\n\n/**\n * Rehype plugin to transform OgCard components.\n */\nfunction rehypeOgp(ogpDataMap: Map<string, OgpData | null>) {\n return (tree: Root) => {\n const visit = (node: Root | Element) => {\n if (\"children\" in node) {\n for (let i = 0; i < node.children.length; i++) {\n const child = node.children[i];\n\n if (child.type === \"element\") {\n // Check for <OgCard> component\n if (child.tagName.toLowerCase() === \"ogcard\") {\n const url = getAttribute(child, \"url\");\n\n if (url) {\n const ogpData = ogpDataMap.get(url);\n const cardElement = ogpData ? createOgpCard(ogpData) : createFallbackCard(url);\n node.children[i] = cardElement;\n }\n } else {\n visit(child);\n }\n }\n }\n }\n };\n\n visit(tree);\n };\n}\n\n/**\n * Transform OgCard components in HTML.\n */\nexport async function transformOgp(\n html: string,\n ogpDataMap?: Map<string, OgpData | null>,\n options?: OgpOptions,\n): Promise<string> {\n // If no pre-fetched data, collect and fetch\n let dataMap = ogpDataMap;\n if (!dataMap) {\n const urls = await collectOgpUrls(html);\n dataMap = await prefetchOgpData(urls, options);\n }\n\n const result = await unified()\n .use(rehypeParse, { fragment: true })\n .use(rehypeOgp, dataMap)\n .use(rehypeStringify)\n .process(html);\n\n return String(result);\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,MAAM,iBAAuC;CAC3C,SAAS;CACT,OAAO;CACP,UAAU;CACV,WAAW;CACZ;AAGD,MAAM,2BAAW,IAAI,KAAmD;;;;AAKxE,SAAS,aAAa,IAAa,MAAkC;CACnE,MAAM,QAAQ,GAAG,aAAa;AAC9B,KAAI,OAAO,UAAU,SAAU,QAAO;AACtC,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO,MAAM,KAAK,IAAI;;;;;AAOlD,SAAS,cAAc,KAAqB;AAC1C,KAAI;AAEF,SADe,IAAI,IAAI,IAAI,CACb;SACR;AACN,SAAO;;;;;;AAOX,SAAS,cAAc,KAAqB;AAC1C,KAAI;AAGF,SAAO,6CAFQ,IAAI,IAAI,IAAI,CAEgC,SAAS;SAC9D;AACN,SAAO;;;;;;AAOX,SAAS,iBAAiB,MAAc,KAAsB;CAC5D,MAAM,SAAkB;EACtB;EACA,OAAO;EACR;CAGD,MAAM,aAAa,KAAK,MAAM,gCAAgC;AAI9D,QAAO,SAHc,KAAK,MAAM,oEAAoE,IAClG,KAAK,MAAM,oEAAoE,IAEnD,MAAM,aAAa,MAAM,cAAc,IAAI;CAGzE,MAAM,YAAY,KAAK,MAAM,0EAA0E,IACrG,KAAK,MAAM,0EAA0E,IACrF,KAAK,MAAM,mEAAmE,IAC9E,KAAK,MAAM,mEAAmE;AAEhF,KAAI,UACF,QAAO,cAAc,UAAU;CAIjC,MAAM,aAAa,KAAK,MAAM,oEAAoE,IAChG,KAAK,MAAM,oEAAo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