@windrun-huaiin/lib 5.5.0 → 5.6.1

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/dist/index.d.mts CHANGED
@@ -1,5 +1,24 @@
1
1
  export { cn, formatTimestamp, handlePastePlainText } from './utils.mjs';
2
- export { AlbumIcon, AlignHorizontalJustifyEnd, ArrowLeft, ArrowRight, ArrowUp, Binary, Blocks, BookX, BotMessageSquare, BringToFront, Bug, Building2, Car, Check, CheckCheck, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Circle, CircleAlert, CircleSmall, CircleStop, ComponentIcon, Copy, Cpu, DatabaseZap, Dot, Download, ExternalLink, Eye, Facebook, File, FileDown, FileInput, FileLock2, FileUp, Fingerprint, Folder, FolderOpen, Gift, GitPullRequestArrow, Globe, GlobeLock, Grip, GripVertical, HandHeart, Handshake, Highlighter, HousePlus, ImageDown, ImageOff, ImageUp, Infinity, Info, Keyboard, LandPlot, Layout, LayoutTemplate, LibraryIcon, Link, ListTodo, Loader2, LogIn, LogOut, Mail, MessageCircleCode, MessageCircleMore, MoreHorizontal, MousePointerClick, Palette, PanelLeft, PanelsTopLeft, PawPrint, Pencil, Pi, QrCode, ReceiptText, RefreshCcw, Regex, Replace, Rocket, Rss, Scale, Search, SendHorizontal, Server, Share, Shield, ShieldUser, Sigma, Sparkles, SplinePointer, Sprout, SquareDashedBottomCode, SquareTerminal, Star, Tablets, Terminal, Twitter, Workflow, X, Zap } from 'lucide-react';
2
+ export { AlbumIcon, AlignHorizontalJustifyEnd, ArrowLeft, ArrowRight, ArrowUp, Binary, Blocks, BookX, BotMessageSquare, BringToFront, Bug, Building2, Car, Check, CheckCheck, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Circle, CircleAlert, CircleSmall, CircleStop, ComponentIcon, Copy, Cpu, DatabaseZap, Dot, Download, ExternalLink, Eye, Facebook, File, FileDown, FileInput, FileLock2, FileUp, Fingerprint, Folder, FolderOpen, Gift, GitMerge, GitPullRequestArrow, Globe, GlobeLock, Grip, GripVertical, HandHeart, Handshake, Highlighter, HousePlus, ImageDown, ImageOff, ImageUp, Infinity, Info, Keyboard, LandPlot, Layout, LayoutTemplate, LibraryIcon, Link, ListTodo, Loader2, LogIn, LogOut, Mail, MessageCircleCode, MessageCircleMore, MoreHorizontal, MousePointerClick, Palette, PanelLeft, PanelsTopLeft, PawPrint, Pencil, Pi, QrCode, ReceiptText, RefreshCcw, Regex, Replace, Rocket, Rss, Scale, Search, SendHorizontal, Server, Share, Shield, ShieldUser, Sigma, Sparkles, SplinePointer, Sprout, SquareDashedBottomCode, SquareTerminal, Star, Tablets, Terminal, Twitter, Workflow, X, Zap } from 'lucide-react';
3
3
  export { getLLMText } from './llm-utils.mjs';
4
4
  export { LOCALE_PRESETS, SupportedLocale, createCommonAppConfig, createI18nHelpers } from './common-app-config.mjs';
5
5
  import 'clsx';
6
+
7
+ type LLMCopyHandlerOptions = {
8
+ sourceDir: string;
9
+ dataSource: {
10
+ getPage: (slug: string[], locale: string) => any | undefined;
11
+ };
12
+ requestedPath: string;
13
+ locale: string;
14
+ };
15
+ /**
16
+ * General MDX content reading and processing tool function, logs are consistent with router.
17
+ */
18
+ declare function LLMCopyHandler(options: LLMCopyHandlerOptions): Promise<{
19
+ text?: string;
20
+ error?: string;
21
+ status: number;
22
+ }>;
23
+
24
+ export { LLMCopyHandler, type LLMCopyHandlerOptions };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,24 @@
1
1
  export { cn, formatTimestamp, handlePastePlainText } from './utils.js';
2
- export { AlbumIcon, AlignHorizontalJustifyEnd, ArrowLeft, ArrowRight, ArrowUp, Binary, Blocks, BookX, BotMessageSquare, BringToFront, Bug, Building2, Car, Check, CheckCheck, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Circle, CircleAlert, CircleSmall, CircleStop, ComponentIcon, Copy, Cpu, DatabaseZap, Dot, Download, ExternalLink, Eye, Facebook, File, FileDown, FileInput, FileLock2, FileUp, Fingerprint, Folder, FolderOpen, Gift, GitPullRequestArrow, Globe, GlobeLock, Grip, GripVertical, HandHeart, Handshake, Highlighter, HousePlus, ImageDown, ImageOff, ImageUp, Infinity, Info, Keyboard, LandPlot, Layout, LayoutTemplate, LibraryIcon, Link, ListTodo, Loader2, LogIn, LogOut, Mail, MessageCircleCode, MessageCircleMore, MoreHorizontal, MousePointerClick, Palette, PanelLeft, PanelsTopLeft, PawPrint, Pencil, Pi, QrCode, ReceiptText, RefreshCcw, Regex, Replace, Rocket, Rss, Scale, Search, SendHorizontal, Server, Share, Shield, ShieldUser, Sigma, Sparkles, SplinePointer, Sprout, SquareDashedBottomCode, SquareTerminal, Star, Tablets, Terminal, Twitter, Workflow, X, Zap } from 'lucide-react';
2
+ export { AlbumIcon, AlignHorizontalJustifyEnd, ArrowLeft, ArrowRight, ArrowUp, Binary, Blocks, BookX, BotMessageSquare, BringToFront, Bug, Building2, Car, Check, CheckCheck, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Circle, CircleAlert, CircleSmall, CircleStop, ComponentIcon, Copy, Cpu, DatabaseZap, Dot, Download, ExternalLink, Eye, Facebook, File, FileDown, FileInput, FileLock2, FileUp, Fingerprint, Folder, FolderOpen, Gift, GitMerge, GitPullRequestArrow, Globe, GlobeLock, Grip, GripVertical, HandHeart, Handshake, Highlighter, HousePlus, ImageDown, ImageOff, ImageUp, Infinity, Info, Keyboard, LandPlot, Layout, LayoutTemplate, LibraryIcon, Link, ListTodo, Loader2, LogIn, LogOut, Mail, MessageCircleCode, MessageCircleMore, MoreHorizontal, MousePointerClick, Palette, PanelLeft, PanelsTopLeft, PawPrint, Pencil, Pi, QrCode, ReceiptText, RefreshCcw, Regex, Replace, Rocket, Rss, Scale, Search, SendHorizontal, Server, Share, Shield, ShieldUser, Sigma, Sparkles, SplinePointer, Sprout, SquareDashedBottomCode, SquareTerminal, Star, Tablets, Terminal, Twitter, Workflow, X, Zap } from 'lucide-react';
3
3
  export { getLLMText } from './llm-utils.js';
4
4
  export { LOCALE_PRESETS, SupportedLocale, createCommonAppConfig, createI18nHelpers } from './common-app-config.js';
5
5
  import 'clsx';
6
+
7
+ type LLMCopyHandlerOptions = {
8
+ sourceDir: string;
9
+ dataSource: {
10
+ getPage: (slug: string[], locale: string) => any | undefined;
11
+ };
12
+ requestedPath: string;
13
+ locale: string;
14
+ };
15
+ /**
16
+ * General MDX content reading and processing tool function, logs are consistent with router.
17
+ */
18
+ declare function LLMCopyHandler(options: LLMCopyHandlerOptions): Promise<{
19
+ text?: string;
20
+ error?: string;
21
+ status: number;
22
+ }>;
23
+
24
+ export { LLMCopyHandler, type LLMCopyHandlerOptions };
package/dist/index.js CHANGED
@@ -9,12 +9,16 @@ var remarkGfm = require('remark-gfm');
9
9
  var remarkMdx = require('remark-mdx');
10
10
  var remarkFrontmatter = require('remark-frontmatter');
11
11
  var unistUtilVisit = require('unist-util-visit');
12
+ var fs = require('fs');
13
+ var nodePath = require('path');
12
14
 
13
15
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
16
 
15
17
  var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
16
18
  var remarkMdx__default = /*#__PURE__*/_interopDefault(remarkMdx);
17
19
  var remarkFrontmatter__default = /*#__PURE__*/_interopDefault(remarkFrontmatter);
20
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
21
+ var nodePath__default = /*#__PURE__*/_interopDefault(nodePath);
18
22
 
19
23
  var __defProp = Object.defineProperty;
20
24
  var __defProps = Object.defineProperties;
@@ -127,6 +131,73 @@ Error processing MDX content.`;
127
131
  }
128
132
  });
129
133
  }
134
+ function LLMCopyHandler(options) {
135
+ return __async(this, null, function* () {
136
+ const { sourceDir, dataSource, requestedPath, locale } = options;
137
+ console.log(`[LLMCopy] Received, locale=${locale}, path=${requestedPath}`);
138
+ if (!requestedPath) {
139
+ return { error: "Missing path query parameter", status: 400 };
140
+ }
141
+ const slug = requestedPath.split("/");
142
+ try {
143
+ console.log("[LLMCopy] Attempting to call getPage()");
144
+ const page = dataSource.getPage(slug, locale);
145
+ console.log("[LLMCopy] Call to getPage() completed.");
146
+ if (!page || !page.data) {
147
+ console.error(`[LLMCopy] Page or page.data not found for locale=${locale}, path=${requestedPath}`);
148
+ return { error: "Page data not found", status: 404 };
149
+ }
150
+ if (!page.data._file || !page.data._file.path) {
151
+ console.error(`[LLMCopy] _file path information missing in page.data for locale=${locale}, path=${requestedPath}`);
152
+ return { error: "Page file path information missing", status: 500 };
153
+ }
154
+ const title = page.data.title;
155
+ const description = page.data.description;
156
+ const relativeMdxFilePath = page.data._file.path;
157
+ const absoluteFilePath = nodePath__default.default.join(process.cwd(), sourceDir, relativeMdxFilePath);
158
+ console.log(`[LLMCopy] Attempting to read MDX content from: ${absoluteFilePath}`);
159
+ let mdxContent;
160
+ try {
161
+ mdxContent = fs__default.default.readFileSync(absoluteFilePath, "utf-8");
162
+ console.log(`[LLMCopy] Successfully read MDX content from: ${absoluteFilePath}`);
163
+ } catch (readError) {
164
+ console.error(`[LLMCopy] Failed to read file at: ${absoluteFilePath}. Error: ${readError.message}`);
165
+ console.error("[LLMCopy] Read Error object details:", JSON.stringify(readError, Object.getOwnPropertyNames(readError), 2));
166
+ try {
167
+ console.log(`[LLMCopy] Current CWD: ${process.cwd()}`);
168
+ console.log(`[LLMCopy] CWD contents: ${fs__default.default.readdirSync(process.cwd()).join(", ")}`);
169
+ const srcPath = nodePath__default.default.join(process.cwd(), "src");
170
+ if (fs__default.default.existsSync(srcPath)) {
171
+ console.log(`[LLMCopy] src dir contents: ${fs__default.default.readdirSync(srcPath).join(", ")}`);
172
+ const srcMdxPath = nodePath__default.default.join(process.cwd(), "src", "mdx");
173
+ if (fs__default.default.existsSync(srcMdxPath)) {
174
+ console.log(`[LLMCopy] src/mdx dir contents: ${fs__default.default.readdirSync(srcMdxPath).join(", ")}`);
175
+ const srcMdxDocsPath = nodePath__default.default.join(process.cwd(), sourceDir);
176
+ if (fs__default.default.existsSync(srcMdxDocsPath)) {
177
+ console.log(`[LLMCopy] ${sourceDir} dir contents: ${fs__default.default.readdirSync(srcMdxDocsPath).join(", ")}`);
178
+ }
179
+ }
180
+ }
181
+ } catch (listDirError) {
182
+ console.warn(`[LLMCopy] Could not list directory contents for debugging: ${listDirError.message}`);
183
+ }
184
+ return { error: `Error reading MDX file: ${readError.message}`, status: 500 };
185
+ }
186
+ try {
187
+ const text = yield getLLMText(mdxContent, title, description);
188
+ return { text, status: 200 };
189
+ } catch (error) {
190
+ console.error(`[LLMCopy] Error processing MDX content for locale=${locale}, path=${requestedPath}:`, error);
191
+ console.error("[LLMCopy] General Error object details:", JSON.stringify(error, Object.getOwnPropertyNames(error), 2));
192
+ return { error: "Error processing MDX content", status: 500 };
193
+ }
194
+ } catch (error) {
195
+ console.error(`[LLMCopy] General error for locale=${locale}, path=${requestedPath}:`, error);
196
+ console.error("[LLMCopy] General Error object details:", JSON.stringify(error, Object.getOwnPropertyNames(error), 2));
197
+ return { error: "Internal Server Error", status: 500 };
198
+ }
199
+ });
200
+ }
130
201
 
131
202
  // src/common-app-config.ts
132
203
  var ALL_LOCALE_LABELS = {
@@ -421,6 +492,10 @@ Object.defineProperty(exports, "Gift", {
421
492
  enumerable: true,
422
493
  get: function () { return lucideReact.Gift; }
423
494
  });
495
+ Object.defineProperty(exports, "GitMerge", {
496
+ enumerable: true,
497
+ get: function () { return lucideReact.GitMerge; }
498
+ });
424
499
  Object.defineProperty(exports, "GitPullRequestArrow", {
425
500
  enumerable: true,
426
501
  get: function () { return lucideReact.GitPullRequestArrow; }
@@ -669,6 +744,7 @@ Object.defineProperty(exports, "Zap", {
669
744
  enumerable: true,
670
745
  get: function () { return lucideReact.Zap; }
671
746
  });
747
+ exports.LLMCopyHandler = LLMCopyHandler;
672
748
  exports.LOCALE_PRESETS = LOCALE_PRESETS;
673
749
  exports.cn = cn;
674
750
  exports.createCommonAppConfig = createCommonAppConfig;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils.ts","../src/llm-utils.ts","../src/common-app-config.ts"],"names":["twMerge","clsx","isValid","format","visit","remark","remarkFrontmatter","remarkMdx","remarkGfm"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAOA,qBAAA,CAAQC,SAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;AAEO,SAAS,eAAA,CAAgB,WAAmB,SAAA,EAAmB;AACpE,EAAA,MAAM,IAAA,GAAO,EAAA;AACb,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,MAAM,WAAA,GAAc,QAAA,CAAS,SAAA,EAAW,EAAE,CAAA;AAC1C,EAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG;AACrB,IAAA,OAAO,IAAA;AAAA,EACV;AAEA,EAAA,MAAM,IAAA,GAAO,IAAI,IAAA,CAAK,WAAW,CAAA;AAGjC,EAAA,IAAI,CAACC,eAAA,CAAQ,IAAI,CAAA,EAAG;AAClB,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,IAAI;AAED,IAAA,OAAOC,cAAA,CAAO,MAAM,SAAS,CAAA;AAAA,EAChC,SAAS,KAAA,EAAO;AAEb,IAAA,OAAA,CAAQ,KAAA,CAAM,0BAA0B,KAAK,CAAA;AAC7C,IAAA,OAAO,IAAA;AAAA,EACV;AACF;AAGO,SAAS,qBAAqB,CAAA,EAAsC;AACzE,EAAA,CAAA,CAAE,cAAA,EAAe;AACjB,EAAA,MAAM,IAAA,GAAO,CAAA,CAAE,aAAA,CAAc,OAAA,CAAQ,YAAY,CAAA;AACjD,EAAA,MAAM,SAAA,GAAY,OAAO,YAAA,EAAa;AACtC,EAAA,IAAI,CAAC,SAAA,IAAa,CAAC,SAAA,CAAU,UAAA,EAAY;AAEzC,EAAA,SAAA,CAAU,kBAAA,EAAmB;A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AmB,UAAA,CAAW,OAAA,CAAQ,GAAA,CAAI,CAAC,GAAA,MAAS;AAAA,IACxD,IAAA,EAAM,UAAA,CAAW,YAAA,CAAa,GAA2C,CAAA,IAAK,GAAA;AAAA,IAC9E,MAAA,EAAQ;AAAA,GACV,CAAE,CAAA;AAEF,EAAA,OAAO;AAAA,IACL,iBAAA;AAAA,IACA,cAAA;AAAA,IACA;AAAA,GACF;AACF;AAGO,IAAM,cAAA,GAAiB;AAAA;AAAA,EAE5B,SAAS,EAAE,OAAA,EAAS,CAAC,IAAI,CAAA,EAAe,eAAe,IAAA,EAAe;AAAA;AAAA,EAGtE,KAAA,EAAO,EAAE,OAAA,EAAS,CAAC,MAAM,IAAI,CAAA,EAAe,eAAe,IAAA,EAAe;AAAA;AAAA,EAG1E,IAAA,EAAM,EAAE,OAAA,EAAS,CAAC,IAAA,EAAM,MAAM,IAAA,EAAM,IAAI,CAAA,EAAe,aAAA,EAAe,IAAA,EAAe;AAAA;AAAA,EAGrF,MAAA,EAAQ,EAAE,OAAA,EAAS,CAAC,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAI,CAAA,EAAe,aAAA,EAAe,IAAA,EAAe;AAAA;AAAA,EAG7F,QAAQ,EAAE,OAAA,EAAS,CAAC,IAAA,EAAM,MAAM,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,MAAM,IAAA,EAAM,IAAA,EAAM,IAAI,CAAA,EAAe,eAAe,IAAA,EAAe;AAAA;AAAA,EAG3H,MAAM,EAAE,OAAA,EAAS,EAAC,EAAe,eAAe,IAAA;AAClD","file":"index.js","sourcesContent":["import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\nimport { format, isValid } from 'date-fns';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n\nexport function formatTimestamp(timestamp: string, formatter: string) {\n const fail = \"\";\n if (!timestamp) {\n return fail;\n }\n\n // Assume gitTimestamp is a millisecond timestamp string\n const timestampMs = parseInt(timestamp, 10);\n if (isNaN(timestampMs)) {\n return fail;\n }\n\n const date = new Date(timestampMs); // or if it is determined to be seconds, use fromUnixTime(timestampSeconds)\n\n // Check if the date is valid\n if (!isValid(date)) {\n return fail;\n }\n\n // Format the date\n try {\n // 'yyyy-MM-dd HH:mm:ss' is the date-fns formatting pattern\n return format(date, formatter);\n } catch (error) {\n // format may also throw an error due to an invalid date (although isValid should have already caught it)\n console.error(\"Error formatting date:\", error);\n return fail;\n }\n} \n\n// Only allow pasting plain text, prohibit style content\nexport function handlePastePlainText(e: React.ClipboardEvent<HTMLElement>) {\n e.preventDefault();\n const text = e.clipboardData.getData('text/plain');\n const selection = window.getSelection();\n if (!selection || !selection.rangeCount) return;\n // Delete the current selected content\n selection.deleteFromDocument();\n // Insert plain text\n const textNode = document.createTextNode(text);\n const range = selection.getRangeAt(0);\n range.insertNode(textNode);\n // Move the cursor to the inserted text\n range.setStartAfter(textNode);\n range.collapse(true);\n selection.removeAllRanges();\n selection.addRange(range);\n}","import { remark } from 'remark';\nimport remarkGfm from 'remark-gfm';\nimport remarkMdx from 'remark-mdx';\nimport remarkFrontmatter from 'remark-frontmatter';\nimport { visit } from 'unist-util-visit';\n\nfunction remarkRemoveFrontmatter() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (tree: any) => {\n visit(tree, 'yaml', (_node, index, parent) => {\n if (parent && typeof index === 'number') {\n parent.children.splice(index, 1);\n }\n });\n };\n}\n\n// remark(), parse the MDX file into MDAST\n// remarkPlugins(), parse the MDAST into HAST\n// rehypePlugins(), render the HAST into React components, i.e. HTML code\nconst processor = remark()\n // parse the md file header\n .use(remarkFrontmatter, ['yaml'])\n // remove the md file header\n .use(remarkRemoveFrontmatter)\n .use(remarkMdx)\n .use(remarkGfm);\n\nexport async function getLLMText(mdxContent: string, title?: string, description?: string) {\n if (typeof mdxContent !== 'string') {\n console.error('getLLMText: mdxContent received was not a string. Type:', typeof mdxContent);\n return `# Error\\n\\nInvalid content received by text processor.`;\n }\n\n try {\n const processed = await processor.process(mdxContent);\n const contentWithoutFrontmatter = processed.value as string;\n\n const markdownParts = [\n title ? `# ${title}` : null,\n description,\n contentWithoutFrontmatter.trim()\n ];\n\n return markdownParts.filter(part => part != null).join('\\n\\n');\n } catch (processingError) {\n console.error('Error during remark processing in getLLMText:', processingError);\n return `# Error\\n\\nError processing MDX content.`;\n }\n} ","// Supported languages and their labels\nconst ALL_LOCALE_LABELS = {\n en: \"English\",\n zh: \"简体中文\",\n ja: \"日本語\", \n ko: \"한국어\",\n fr: \"Français\",\n de: \"Deutsch\",\n es: \"Español\",\n it: \"Italiano\",\n pt: \"Português\",\n tr: \"Türkçe\",\n pl: \"Polski\",\n ru: \"Русский\",\n ar: \"العربية\",\n hi: \"हिन्दी\",\n th: \"ไทย\",\n vi: \"Tiếng Việt\",\n} as const;\n\nexport type SupportedLocale = keyof typeof ALL_LOCALE_LABELS;\n\n// Helper function to get language configuration from environment variables\nfunction getLocaleLabels(locales: string[]) {\n return Object.fromEntries(\n locales.map(locale => [\n locale, \n ALL_LOCALE_LABELS[locale as SupportedLocale] || locale\n ])\n );\n}\n\n// Common application configuration creation function\nexport function createCommonAppConfig(options?: {\n // Optional: manually specify supported languages, otherwise read from environment variables\n locales?: string[];\n defaultLocale?: string;\n}) {\n // Priority: manual configuration > environment variables > default values\n const locales = options?.locales ?? \n process.env.NEXT_PUBLIC_I18N_LOCALES?.split(',').map(s => s.trim()) ?? \n ['en', 'zh'];\n \n const defaultLocale = options?.defaultLocale ?? \n process.env.NEXT_PUBLIC_I18N_DEFAULT_LOCALE ?? \n 'en';\n \n const storagePrefix = process.env.NEXT_PUBLIC_I18N_STORAGE_PREFIX || 'WINDRUN-HUAIIN';\n\n const config = {\n // Basic configuration\n baseUrl: process.env.NEXT_PUBLIC_BASE_URL || '',\n githubBaseUrl: process.env.NEXT_PUBLIC_GITHUB_BASE_URL || '',\n github: process.env.NEXT_PUBLIC_GITHUB || '',\n githubInfoToken: process.env.NEXT_PUBLIC_FUMA_GITHUB_TOKEN || '',\n\n // Internationalization configuration\n i18n: {\n locales: locales as readonly string[],\n defaultLocale,\n localeLabels: getLocaleLabels(locales),\n detector: {\n storageKey: process.env.NEXT_PUBLIC_I18N_STORAGE_KEY || 'language-preference-status',\n autoCloseTimeout: parseInt(process.env.NEXT_PUBLIC_I18N_AUTO_CLOSE_TIMEOUT || '10000'),\n expirationDays: parseInt(process.env.NEXT_PUBLIC_I18N_EXPIRATION_DAYS || '30'),\n storagePrefix\n },\n messageRoot: process.env.NEXT_PUBLIC_I18N_MESSAGE_ROOT || 'messages',\n },\n\n // Style configuration\n style: {\n icon: {\n uniformColor: process.env.NEXT_PUBLIC_STYLE_ICON_COLOR || \"text-purple-500\"\n },\n showBanner: process.env.NEXT_PUBLIC_STYLE_SHOW_BANNER === 'true',\n clerkAuthInModal: process.env.NEXT_PUBLIC_STYLE_CLERK_AUTH_IN_MODAL === 'true',\n clerkPageBanner: process.env.NEXT_PUBLIC_STYLE_CLERK_PAGE_BANNER === 'true',\n watermark: {\n enabled: process.env.NEXT_PUBLIC_STYLE_WATERMARK_ENABLED === 'true',\n text: process.env.NEXT_PUBLIC_STYLE_WATERMARK_TEXT || \"巽川·怀因\"\n },\n cdnBaseUrl: process.env.NEXT_PUBLIC_STYLE_CDN_BASE_URL || \"https://raw.githubusercontent.com/caofanCPU/wind-run-1/main/public\",\n placeHolder: {\n image: process.env.NEXT_PUBLIC_STYLE_PLACEHOLDER_IMAGE || \"/default.webp\"\n }\n },\n\n // Clerk configuration\n clerk: {\n signInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_URL || \"/sign-in\",\n fallbackSignInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL || \"/\",\n signUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_URL || \"/sign-up\", \n fallbackSignUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL || \"/\",\n waitlistUrl: process.env.NEXT_PUBLIC_CLERK_WAITLIST_URL || \"/waitlist\",\n debug: process.env.CLERK_DEBUG === 'true',\n },\n\n // MDX source file directory configuration\n mdxSourceDir: {\n docs: process.env.NEXT_PUBLIC_MDX_DOCS_DIR || \"src/mdx/docs\",\n blog: process.env.NEXT_PUBLIC_MDX_BLOG_DIR || \"src/mdx/blog\", \n legal: process.env.NEXT_PUBLIC_MDX_LEGAL_DIR || \"src/mdx/legal\"\n },\n };\n\n // Convenient constants - avoid deep nested access\n const shortcuts = {\n iconColor: config.style.icon.uniformColor,\n watermark: config.style.watermark,\n showBanner: config.style.showBanner,\n clerkPageBanner: config.style.clerkPageBanner,\n clerkAuthInModal: config.style.clerkAuthInModal,\n placeHolderImage: config.style.placeHolder.image,\n clerk: config.clerk,\n };\n\n return {\n ...config,\n shortcuts\n };\n}\n\n// Create internationalization helper functions\nexport function createI18nHelpers(i18nConfig: ReturnType<typeof createCommonAppConfig>['i18n']) {\n function isSupportedLocale(locale: string): locale is typeof i18nConfig.locales[number] {\n return (i18nConfig.locales as readonly string[]).includes(locale);\n }\n\n function getValidLocale(locale: string): typeof i18nConfig.locales[number] {\n return isSupportedLocale(locale) ? locale : i18nConfig.defaultLocale;\n }\n\n const generatedLocales = i18nConfig.locales.map((loc) => ({\n name: i18nConfig.localeLabels[loc as keyof typeof i18nConfig.localeLabels] || loc,\n locale: loc,\n }));\n\n return {\n isSupportedLocale,\n getValidLocale,\n generatedLocales\n };\n}\n\n// Convenient configuration presets\nexport const LOCALE_PRESETS = {\n // Only support English\n EN_ONLY: { locales: ['en'] as string[], defaultLocale: 'en' as string },\n \n // English and Chinese\n EN_ZH: { locales: ['en', 'zh'] as string[], defaultLocale: 'en' as string },\n \n // Main Asian languages\n ASIA: { locales: ['en', 'zh', 'ja', 'ko'] as string[], defaultLocale: 'en' as string },\n \n // Main European languages\n EUROPE: { locales: ['en', 'fr', 'de', 'es', 'it'] as string[], defaultLocale: 'en' as string },\n \n // Globalization\n GLOBAL: { locales: ['en', 'zh', 'ja', 'ko', 'fr', 'de', 'es', 'it', 'pt', 'ru'] as string[], defaultLocale: 'en' as string },\n \n // No internationalization (only default language)\n NONE: { locales: [] as string[], defaultLocale: 'en' as string }\n}; "]}
1
+ {"version":3,"sources":["../src/utils.ts","../src/llm-utils.ts","../src/llm-copy-handler.ts","../src/common-app-config.ts"],"names":["twMerge","clsx","isValid","format","visit","remark","remarkFrontmatter","remarkMdx","remarkGfm","nodePath","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAOA,qBAAA,CAAQC,SAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;AAEO,SAAS,eAAA,CAAgB,WAAmB,SAAA,EAAmB;AACpE,EAAA,MAAM,IAAA,GAAO,EAAA;AACb,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,MAAM,WAAA,GAAc,QAAA,CAAS,SAAA,EAAW,EAAE,CAAA;AAC1C,EAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG;AACrB,IAAA,OAAO,IAAA;AAAA,EACV;AAEA,EAAA,MAAM,IAAA,GAAO,IAAI,IAAA,CAAK,WAAW,CAAA;AAGjC,EAAA,IAAI,CAACC,eAAA,CAAQ,IAAI,CAAA,EAAG;AAClB,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,IAAI;AAED,IAAA,OAAOC,cAAA,CAAO,MAAM,SAAS,CAAA;AAAA,EAChC,SAAS,KAAA,EAAO;AAEb,IAAA,OAAA,CAAQ,KAAA,CAAM,0BAA0B,KAAK,CAAA;AAC7C,IAAA,OAAO,IAAA;AAAA,EACV;AACF;AAGO,SAAS,qBAAqB,CAAA,EAAsC;AACzE,EAAA,CAAA,CAAE,cAAA,EAAe;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,IACA,cAAA;AAAA,IACA;AAAA,GACF;AACF;AAGO,IAAM,cAAA,GAAiB;AAAA;AAAA,EAE5B,SAAS,EAAE,OAAA,EAAS,CAAC,IAAI,CAAA,EAAe,eAAe,IAAA,EAAe;AAAA;AAAA,EAGtE,KAAA,EAAO,EAAE,OAAA,EAAS,CAAC,MAAM,IAAI,CAAA,EAAe,eAAe,IAAA,EAAe;AAAA;AAAA,EAG1E,IAAA,EAAM,EAAE,OAAA,EAAS,CAAC,IAAA,EAAM,MAAM,IAAA,EAAM,IAAI,CAAA,EAAe,aAAA,EAAe,IAAA,EAAe;AAAA;AAAA,EAGrF,MAAA,EAAQ,EAAE,OAAA,EAAS,CAAC,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAI,CAAA,EAAe,aAAA,EAAe,IAAA,EAAe;AAAA;AAAA,EAG7F,QAAQ,EAAE,OAAA,EAAS,CAAC,IAAA,EAAM,MAAM,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,MAAM,IAAA,EAAM,IAAA,EAAM,IAAI,CAAA,EAAe,eAAe,IAAA,EAAe;AAAA;AAAA,EAG3H,MAAM,EAAE,OAAA,EAAS,EAAC,EAAe,eAAe,IAAA;AAClD","file":"index.js","sourcesContent":["import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\nimport { format, isValid } from 'date-fns';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n\nexport function formatTimestamp(timestamp: string, formatter: string) {\n const fail = \"\";\n if (!timestamp) {\n return fail;\n }\n\n // Assume gitTimestamp is a millisecond timestamp string\n const timestampMs = parseInt(timestamp, 10);\n if (isNaN(timestampMs)) {\n return fail;\n }\n\n const date = new Date(timestampMs); // or if it is determined to be seconds, use fromUnixTime(timestampSeconds)\n\n // Check if the date is valid\n if (!isValid(date)) {\n return fail;\n }\n\n // Format the date\n try {\n // 'yyyy-MM-dd HH:mm:ss' is the date-fns formatting pattern\n return format(date, formatter);\n } catch (error) {\n // format may also throw an error due to an invalid date (although isValid should have already caught it)\n console.error(\"Error formatting date:\", error);\n return fail;\n }\n} \n\n// Only allow pasting plain text, prohibit style content\nexport function handlePastePlainText(e: React.ClipboardEvent<HTMLElement>) {\n e.preventDefault();\n const text = e.clipboardData.getData('text/plain');\n const selection = window.getSelection();\n if (!selection || !selection.rangeCount) return;\n // Delete the current selected content\n selection.deleteFromDocument();\n // Insert plain text\n const textNode = document.createTextNode(text);\n const range = selection.getRangeAt(0);\n range.insertNode(textNode);\n // Move the cursor to the inserted text\n range.setStartAfter(textNode);\n range.collapse(true);\n selection.removeAllRanges();\n selection.addRange(range);\n}","import { remark } from 'remark';\nimport remarkGfm from 'remark-gfm';\nimport remarkMdx from 'remark-mdx';\nimport remarkFrontmatter from 'remark-frontmatter';\nimport { visit } from 'unist-util-visit';\n\nfunction remarkRemoveFrontmatter() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (tree: any) => {\n visit(tree, 'yaml', (_node, index, parent) => {\n if (parent && typeof index === 'number') {\n parent.children.splice(index, 1);\n }\n });\n };\n}\n\n// remark(), parse the MDX file into MDAST\n// remarkPlugins(), parse the MDAST into HAST\n// rehypePlugins(), render the HAST into React components, i.e. HTML code\nconst processor = remark()\n // parse the md file header\n .use(remarkFrontmatter, ['yaml'])\n // remove the md file header\n .use(remarkRemoveFrontmatter)\n .use(remarkMdx)\n .use(remarkGfm);\n\nexport async function getLLMText(mdxContent: string, title?: string, description?: string) {\n if (typeof mdxContent !== 'string') {\n console.error('getLLMText: mdxContent received was not a string. Type:', typeof mdxContent);\n return `# Error\\n\\nInvalid content received by text processor.`;\n }\n\n try {\n const processed = await processor.process(mdxContent);\n const contentWithoutFrontmatter = processed.value as string;\n\n const markdownParts = [\n title ? `# ${title}` : null,\n description,\n contentWithoutFrontmatter.trim()\n ];\n\n return markdownParts.filter(part => part != null).join('\\n\\n');\n } catch (processingError) {\n console.error('Error during remark processing in getLLMText:', processingError);\n return `# Error\\n\\nError processing MDX content.`;\n }\n} ","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport fs from 'node:fs';\nimport nodePath from 'node:path';\nimport { getLLMText } from '@lib/llm-utils';\n\nexport type LLMCopyHandlerOptions = {\n // for example: \"src/mdx/blog\"\n sourceDir: string;\n // data source object, like blogSource, legalSource\n dataSource: {\n getPage: (slug: string[], locale: string) => any | undefined;\n };\n // for example: \"blog/2025/07/07/test\"\n requestedPath: string;\n locale: string;\n};\n\n/**\n * General MDX content reading and processing tool function, logs are consistent with router.\n */\nexport async function LLMCopyHandler(options: LLMCopyHandlerOptions): Promise<{ text?: string; error?: string; status: number }> {\n const { sourceDir, dataSource, requestedPath, locale } = options;\n\n // log received parameters\n console.log(`[LLMCopy] Received, locale=${locale}, path=${requestedPath}`);\n\n if (!requestedPath) {\n return { error: 'Missing path query parameter', status: 400 };\n }\n const slug = requestedPath.split('/');\n\n try {\n console.log('[LLMCopy] Attempting to call getPage()');\n const page = dataSource.getPage(slug, locale);\n console.log('[LLMCopy] Call to getPage() completed.');\n\n if (!page || !page.data) {\n console.error(`[LLMCopy] Page or page.data not found for locale=${locale}, path=${requestedPath}`);\n return { error: 'Page data not found', status: 404 };\n }\n if (!page.data._file || !page.data._file.path) {\n console.error(`[LLMCopy] _file path information missing in page.data for locale=${locale}, path=${requestedPath}`);\n return { error: 'Page file path information missing', status: 500 };\n }\n\n const title = page.data.title;\n const description = page.data.description;\n const relativeMdxFilePath = page.data._file.path;\n const absoluteFilePath = nodePath.join(process.cwd(), sourceDir, relativeMdxFilePath);\n console.log(`[LLMCopy] Attempting to read MDX content from: ${absoluteFilePath}`);\n\n let mdxContent: string;\n try {\n mdxContent = fs.readFileSync(absoluteFilePath, 'utf-8');\n console.log(`[LLMCopy] Successfully read MDX content from: ${absoluteFilePath}`);\n } catch (readError: any) {\n console.error(`[LLMCopy] Failed to read file at: ${absoluteFilePath}. Error: ${readError.message}`);\n console.error('[LLMCopy] Read Error object details:', JSON.stringify(readError, Object.getOwnPropertyNames(readError), 2));\n // directory traversal debug logs\n try {\n console.log(`[LLMCopy] Current CWD: ${process.cwd()}`);\n console.log(`[LLMCopy] CWD contents: ${fs.readdirSync(process.cwd()).join(', ')}`);\n const srcPath = nodePath.join(process.cwd(), 'src');\n if (fs.existsSync(srcPath)) {\n console.log(`[LLMCopy] src dir contents: ${fs.readdirSync(srcPath).join(', ')}`);\n const srcMdxPath = nodePath.join(process.cwd(), 'src', 'mdx');\n if (fs.existsSync(srcMdxPath)) {\n console.log(`[LLMCopy] src/mdx dir contents: ${fs.readdirSync(srcMdxPath).join(', ')}`);\n const srcMdxDocsPath = nodePath.join(process.cwd(), sourceDir);\n if (fs.existsSync(srcMdxDocsPath)) {\n console.log(`[LLMCopy] ${sourceDir} dir contents: ${fs.readdirSync(srcMdxDocsPath).join(', ')}`);\n }\n }\n }\n } catch (listDirError: any) {\n console.warn(`[LLMCopy] Could not list directory contents for debugging: ${listDirError.message}`);\n }\n return { error: `Error reading MDX file: ${readError.message}`, status: 500 };\n }\n\n try {\n const text = await getLLMText(mdxContent, title, description);\n return { text, status: 200 };\n } catch (error: any) {\n console.error(`[LLMCopy] Error processing MDX content for locale=${locale}, path=${requestedPath}:`, error);\n console.error('[LLMCopy] General Error object details:', JSON.stringify(error, Object.getOwnPropertyNames(error), 2));\n return { error: 'Error processing MDX content', status: 500 };\n }\n } catch (error: any) {\n console.error(`[LLMCopy] General error for locale=${locale}, path=${requestedPath}:`, error);\n console.error('[LLMCopy] General Error object details:', JSON.stringify(error, Object.getOwnPropertyNames(error), 2));\n return { error: 'Internal Server Error', status: 500 };\n }\n} ","// Supported languages and their labels\nconst ALL_LOCALE_LABELS = {\n en: \"English\",\n zh: \"简体中文\",\n ja: \"日本語\", \n ko: \"한국어\",\n fr: \"Français\",\n de: \"Deutsch\",\n es: \"Español\",\n it: \"Italiano\",\n pt: \"Português\",\n tr: \"Türkçe\",\n pl: \"Polski\",\n ru: \"Русский\",\n ar: \"العربية\",\n hi: \"हिन्दी\",\n th: \"ไทย\",\n vi: \"Tiếng Việt\",\n} as const;\n\nexport type SupportedLocale = keyof typeof ALL_LOCALE_LABELS;\n\n// Helper function to get language configuration from environment variables\nfunction getLocaleLabels(locales: string[]) {\n return Object.fromEntries(\n locales.map(locale => [\n locale, \n ALL_LOCALE_LABELS[locale as SupportedLocale] || locale\n ])\n );\n}\n\n// Common application configuration creation function\nexport function createCommonAppConfig(options?: {\n // Optional: manually specify supported languages, otherwise read from environment variables\n locales?: string[];\n defaultLocale?: string;\n}) {\n // Priority: manual configuration > environment variables > default values\n const locales = options?.locales ?? \n process.env.NEXT_PUBLIC_I18N_LOCALES?.split(',').map(s => s.trim()) ?? \n ['en', 'zh'];\n \n const defaultLocale = options?.defaultLocale ?? \n process.env.NEXT_PUBLIC_I18N_DEFAULT_LOCALE ?? \n 'en';\n \n const storagePrefix = process.env.NEXT_PUBLIC_I18N_STORAGE_PREFIX || 'WINDRUN-HUAIIN';\n\n const config = {\n // Basic configuration\n baseUrl: process.env.NEXT_PUBLIC_BASE_URL || '',\n githubBaseUrl: process.env.NEXT_PUBLIC_GITHUB_BASE_URL || '',\n github: process.env.NEXT_PUBLIC_GITHUB || '',\n githubInfoToken: process.env.NEXT_PUBLIC_FUMA_GITHUB_TOKEN || '',\n\n // Internationalization configuration\n i18n: {\n locales: locales as readonly string[],\n defaultLocale,\n localeLabels: getLocaleLabels(locales),\n detector: {\n storageKey: process.env.NEXT_PUBLIC_I18N_STORAGE_KEY || 'language-preference-status',\n autoCloseTimeout: parseInt(process.env.NEXT_PUBLIC_I18N_AUTO_CLOSE_TIMEOUT || '10000'),\n expirationDays: parseInt(process.env.NEXT_PUBLIC_I18N_EXPIRATION_DAYS || '30'),\n storagePrefix\n },\n messageRoot: process.env.NEXT_PUBLIC_I18N_MESSAGE_ROOT || 'messages',\n },\n\n // Style configuration\n style: {\n icon: {\n uniformColor: process.env.NEXT_PUBLIC_STYLE_ICON_COLOR || \"text-purple-500\"\n },\n showBanner: process.env.NEXT_PUBLIC_STYLE_SHOW_BANNER === 'true',\n clerkAuthInModal: process.env.NEXT_PUBLIC_STYLE_CLERK_AUTH_IN_MODAL === 'true',\n clerkPageBanner: process.env.NEXT_PUBLIC_STYLE_CLERK_PAGE_BANNER === 'true',\n watermark: {\n enabled: process.env.NEXT_PUBLIC_STYLE_WATERMARK_ENABLED === 'true',\n text: process.env.NEXT_PUBLIC_STYLE_WATERMARK_TEXT || \"巽川·怀因\"\n },\n cdnBaseUrl: process.env.NEXT_PUBLIC_STYLE_CDN_BASE_URL || \"https://raw.githubusercontent.com/caofanCPU/wind-run-1/main/public\",\n placeHolder: {\n image: process.env.NEXT_PUBLIC_STYLE_PLACEHOLDER_IMAGE || \"/default.webp\"\n }\n },\n\n // Clerk configuration\n clerk: {\n signInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_URL || \"/sign-in\",\n fallbackSignInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL || \"/\",\n signUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_URL || \"/sign-up\", \n fallbackSignUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL || \"/\",\n waitlistUrl: process.env.NEXT_PUBLIC_CLERK_WAITLIST_URL || \"/waitlist\",\n debug: process.env.CLERK_DEBUG === 'true',\n },\n\n // MDX source file directory configuration\n mdxSourceDir: {\n docs: process.env.NEXT_PUBLIC_MDX_DOCS_DIR || \"src/mdx/docs\",\n blog: process.env.NEXT_PUBLIC_MDX_BLOG_DIR || \"src/mdx/blog\", \n legal: process.env.NEXT_PUBLIC_MDX_LEGAL_DIR || \"src/mdx/legal\"\n },\n };\n\n // Convenient constants - avoid deep nested access\n const shortcuts = {\n iconColor: config.style.icon.uniformColor,\n watermark: config.style.watermark,\n showBanner: config.style.showBanner,\n clerkPageBanner: config.style.clerkPageBanner,\n clerkAuthInModal: config.style.clerkAuthInModal,\n placeHolderImage: config.style.placeHolder.image,\n clerk: config.clerk,\n };\n\n return {\n ...config,\n shortcuts\n };\n}\n\n// Create internationalization helper functions\nexport function createI18nHelpers(i18nConfig: ReturnType<typeof createCommonAppConfig>['i18n']) {\n function isSupportedLocale(locale: string): locale is typeof i18nConfig.locales[number] {\n return (i18nConfig.locales as readonly string[]).includes(locale);\n }\n\n function getValidLocale(locale: string): typeof i18nConfig.locales[number] {\n return isSupportedLocale(locale) ? locale : i18nConfig.defaultLocale;\n }\n\n const generatedLocales = i18nConfig.locales.map((loc) => ({\n name: i18nConfig.localeLabels[loc as keyof typeof i18nConfig.localeLabels] || loc,\n locale: loc,\n }));\n\n return {\n isSupportedLocale,\n getValidLocale,\n generatedLocales\n };\n}\n\n// Convenient configuration presets\nexport const LOCALE_PRESETS = {\n // Only support English\n EN_ONLY: { locales: ['en'] as string[], defaultLocale: 'en' as string },\n \n // English and Chinese\n EN_ZH: { locales: ['en', 'zh'] as string[], defaultLocale: 'en' as string },\n \n // Main Asian languages\n ASIA: { locales: ['en', 'zh', 'ja', 'ko'] as string[], defaultLocale: 'en' as string },\n \n // Main European languages\n EUROPE: { locales: ['en', 'fr', 'de', 'es', 'it'] as string[], defaultLocale: 'en' as string },\n \n // Globalization\n GLOBAL: { locales: ['en', 'zh', 'ja', 'ko', 'fr', 'de', 'es', 'it', 'pt', 'ru'] as string[], defaultLocale: 'en' as string },\n \n // No internationalization (only default language)\n NONE: { locales: [] as string[], defaultLocale: 'en' as string }\n}; "]}
package/dist/index.mjs CHANGED
@@ -1,12 +1,14 @@
1
1
  import { clsx } from 'clsx';
2
2
  import { twMerge } from 'tailwind-merge';
3
3
  import { isValid, format } from 'date-fns';
4
- export { AlbumIcon, AlignHorizontalJustifyEnd, ArrowLeft, ArrowRight, ArrowUp, Binary, Blocks, BookX, BotMessageSquare, BringToFront, Bug, Building2, Car, Check, CheckCheck, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Circle, CircleAlert, CircleSmall, CircleStop, ComponentIcon, Copy, Cpu, DatabaseZap, Dot, Download, ExternalLink, Eye, Facebook, File, FileDown, FileInput, FileLock2, FileUp, Fingerprint, Folder, FolderOpen, Gift, GitPullRequestArrow, Globe, GlobeLock, Grip, GripVertical, HandHeart, Handshake, Highlighter, HousePlus, ImageDown, ImageOff, ImageUp, Infinity, Info, Keyboard, LandPlot, Layout, LayoutTemplate, LibraryIcon, Link, ListTodo, Loader2, LogIn, LogOut, Mail, MessageCircleCode, MessageCircleMore, MoreHorizontal, MousePointerClick, Palette, PanelLeft, PanelsTopLeft, PawPrint, Pencil, Pi, QrCode, ReceiptText, RefreshCcw, Regex, Replace, Rocket, Rss, Scale, Search, SendHorizontal, Server, Share, Shield, ShieldUser, Sigma, Sparkles, SplinePointer, Sprout, SquareDashedBottomCode, SquareTerminal, Star, Tablets, Terminal, Twitter, Workflow, X, Zap } from 'lucide-react';
4
+ export { AlbumIcon, AlignHorizontalJustifyEnd, ArrowLeft, ArrowRight, ArrowUp, Binary, Blocks, BookX, BotMessageSquare, BringToFront, Bug, Building2, Car, Check, CheckCheck, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Circle, CircleAlert, CircleSmall, CircleStop, ComponentIcon, Copy, Cpu, DatabaseZap, Dot, Download, ExternalLink, Eye, Facebook, File, FileDown, FileInput, FileLock2, FileUp, Fingerprint, Folder, FolderOpen, Gift, GitMerge, GitPullRequestArrow, Globe, GlobeLock, Grip, GripVertical, HandHeart, Handshake, Highlighter, HousePlus, ImageDown, ImageOff, ImageUp, Infinity, Info, Keyboard, LandPlot, Layout, LayoutTemplate, LibraryIcon, Link, ListTodo, Loader2, LogIn, LogOut, Mail, MessageCircleCode, MessageCircleMore, MoreHorizontal, MousePointerClick, Palette, PanelLeft, PanelsTopLeft, PawPrint, Pencil, Pi, QrCode, ReceiptText, RefreshCcw, Regex, Replace, Rocket, Rss, Scale, Search, SendHorizontal, Server, Share, Shield, ShieldUser, Sigma, Sparkles, SplinePointer, Sprout, SquareDashedBottomCode, SquareTerminal, Star, Tablets, Terminal, Twitter, Workflow, X, Zap } from 'lucide-react';
5
5
  import { remark } from 'remark';
6
6
  import remarkGfm from 'remark-gfm';
7
7
  import remarkMdx from 'remark-mdx';
8
8
  import remarkFrontmatter from 'remark-frontmatter';
9
9
  import { visit } from 'unist-util-visit';
10
+ import fs from 'fs';
11
+ import nodePath from 'path';
10
12
 
11
13
  var __defProp = Object.defineProperty;
12
14
  var __defProps = Object.defineProperties;
@@ -119,6 +121,73 @@ Error processing MDX content.`;
119
121
  }
120
122
  });
121
123
  }
124
+ function LLMCopyHandler(options) {
125
+ return __async(this, null, function* () {
126
+ const { sourceDir, dataSource, requestedPath, locale } = options;
127
+ console.log(`[LLMCopy] Received, locale=${locale}, path=${requestedPath}`);
128
+ if (!requestedPath) {
129
+ return { error: "Missing path query parameter", status: 400 };
130
+ }
131
+ const slug = requestedPath.split("/");
132
+ try {
133
+ console.log("[LLMCopy] Attempting to call getPage()");
134
+ const page = dataSource.getPage(slug, locale);
135
+ console.log("[LLMCopy] Call to getPage() completed.");
136
+ if (!page || !page.data) {
137
+ console.error(`[LLMCopy] Page or page.data not found for locale=${locale}, path=${requestedPath}`);
138
+ return { error: "Page data not found", status: 404 };
139
+ }
140
+ if (!page.data._file || !page.data._file.path) {
141
+ console.error(`[LLMCopy] _file path information missing in page.data for locale=${locale}, path=${requestedPath}`);
142
+ return { error: "Page file path information missing", status: 500 };
143
+ }
144
+ const title = page.data.title;
145
+ const description = page.data.description;
146
+ const relativeMdxFilePath = page.data._file.path;
147
+ const absoluteFilePath = nodePath.join(process.cwd(), sourceDir, relativeMdxFilePath);
148
+ console.log(`[LLMCopy] Attempting to read MDX content from: ${absoluteFilePath}`);
149
+ let mdxContent;
150
+ try {
151
+ mdxContent = fs.readFileSync(absoluteFilePath, "utf-8");
152
+ console.log(`[LLMCopy] Successfully read MDX content from: ${absoluteFilePath}`);
153
+ } catch (readError) {
154
+ console.error(`[LLMCopy] Failed to read file at: ${absoluteFilePath}. Error: ${readError.message}`);
155
+ console.error("[LLMCopy] Read Error object details:", JSON.stringify(readError, Object.getOwnPropertyNames(readError), 2));
156
+ try {
157
+ console.log(`[LLMCopy] Current CWD: ${process.cwd()}`);
158
+ console.log(`[LLMCopy] CWD contents: ${fs.readdirSync(process.cwd()).join(", ")}`);
159
+ const srcPath = nodePath.join(process.cwd(), "src");
160
+ if (fs.existsSync(srcPath)) {
161
+ console.log(`[LLMCopy] src dir contents: ${fs.readdirSync(srcPath).join(", ")}`);
162
+ const srcMdxPath = nodePath.join(process.cwd(), "src", "mdx");
163
+ if (fs.existsSync(srcMdxPath)) {
164
+ console.log(`[LLMCopy] src/mdx dir contents: ${fs.readdirSync(srcMdxPath).join(", ")}`);
165
+ const srcMdxDocsPath = nodePath.join(process.cwd(), sourceDir);
166
+ if (fs.existsSync(srcMdxDocsPath)) {
167
+ console.log(`[LLMCopy] ${sourceDir} dir contents: ${fs.readdirSync(srcMdxDocsPath).join(", ")}`);
168
+ }
169
+ }
170
+ }
171
+ } catch (listDirError) {
172
+ console.warn(`[LLMCopy] Could not list directory contents for debugging: ${listDirError.message}`);
173
+ }
174
+ return { error: `Error reading MDX file: ${readError.message}`, status: 500 };
175
+ }
176
+ try {
177
+ const text = yield getLLMText(mdxContent, title, description);
178
+ return { text, status: 200 };
179
+ } catch (error) {
180
+ console.error(`[LLMCopy] Error processing MDX content for locale=${locale}, path=${requestedPath}:`, error);
181
+ console.error("[LLMCopy] General Error object details:", JSON.stringify(error, Object.getOwnPropertyNames(error), 2));
182
+ return { error: "Error processing MDX content", status: 500 };
183
+ }
184
+ } catch (error) {
185
+ console.error(`[LLMCopy] General error for locale=${locale}, path=${requestedPath}:`, error);
186
+ console.error("[LLMCopy] General Error object details:", JSON.stringify(error, Object.getOwnPropertyNames(error), 2));
187
+ return { error: "Internal Server Error", status: 500 };
188
+ }
189
+ });
190
+ }
122
191
 
123
192
  // src/common-app-config.ts
124
193
  var ALL_LOCALE_LABELS = {
@@ -249,6 +318,6 @@ var LOCALE_PRESETS = {
249
318
  NONE: { locales: [], defaultLocale: "en" }
250
319
  };
251
320
 
252
- export { LOCALE_PRESETS, cn, createCommonAppConfig, createI18nHelpers, formatTimestamp, getLLMText, handlePastePlainText };
321
+ export { LLMCopyHandler, LOCALE_PRESETS, cn, createCommonAppConfig, createI18nHelpers, formatTimestamp, getLLMText, handlePastePlainText };
253
322
  //# sourceMappingURL=index.mjs.map
254
323
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils.ts","../src/llm-utils.ts","../src/common-app-config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;AAEO,SAAS,eAAA,CAAgB,WAAmB,SAAA,EAAmB;AACpE,EAAA,MAAM,IAAA,GAAO,EAAA;AACb,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,MAAM,WAAA,GAAc,QAAA,CAAS,SAAA,EAAW,EAAE,CAAA;AAC1C,EAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG;AACrB,IAAA,OAAO,IAAA;AAAA,EACV;AAEA,EAAA,MAAM,IAAA,GAAO,IAAI,IAAA,CAAK,WAAW,CAAA;AAGjC,EAAA,IAAI,CAAC,OAAA,CAAQ,IAAI,CAAA,EAAG;AAClB,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,IAAI;AAED,IAAA,OAAO,MAAA,CAAO,MAAM,SAAS,CAAA;AAAA,EAChC,SAAS,KAAA,EAAO;AAEb,IAAA,OAAA,CAAQ,KAAA,CAAM,0BAA0B,KAAK,CAAA;AAC7C,IAAA,OAAO,IAAA;AAAA,EACV;AACF;AAGO,SAAS,qBAAqB,CAAA,EAAsC;AACzE,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EAAe,eAAe,IAAA;AAClD","file":"index.mjs","sourcesContent":["import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\nimport { format, isValid } from 'date-fns';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n\nexport function formatTimestamp(timestamp: string, formatter: string) {\n const fail = \"\";\n if (!timestamp) {\n return fail;\n }\n\n // Assume gitTimestamp is a millisecond timestamp string\n const timestampMs = parseInt(timestamp, 10);\n if (isNaN(timestampMs)) {\n return fail;\n }\n\n const date = new Date(timestampMs); // or if it is determined to be seconds, use fromUnixTime(timestampSeconds)\n\n // Check if the date is valid\n if (!isValid(date)) {\n return fail;\n }\n\n // Format the date\n try {\n // 'yyyy-MM-dd HH:mm:ss' is the date-fns formatting pattern\n return format(date, formatter);\n } catch (error) {\n // format may also throw an error due to an invalid date (although isValid should have already caught it)\n console.error(\"Error formatting date:\", error);\n return fail;\n }\n} \n\n// Only allow pasting plain text, prohibit style content\nexport function handlePastePlainText(e: React.ClipboardEvent<HTMLElement>) {\n e.preventDefault();\n const text = e.clipboardData.getData('text/plain');\n const selection = window.getSelection();\n if (!selection || !selection.rangeCount) return;\n // Delete the current selected content\n selection.deleteFromDocument();\n // Insert plain text\n const textNode = document.createTextNode(text);\n const range = selection.getRangeAt(0);\n range.insertNode(textNode);\n // Move the cursor to the inserted text\n range.setStartAfter(textNode);\n range.collapse(true);\n selection.removeAllRanges();\n selection.addRange(range);\n}","import { remark } from 'remark';\nimport remarkGfm from 'remark-gfm';\nimport remarkMdx from 'remark-mdx';\nimport remarkFrontmatter from 'remark-frontmatter';\nimport { visit } from 'unist-util-visit';\n\nfunction remarkRemoveFrontmatter() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (tree: any) => {\n visit(tree, 'yaml', (_node, index, parent) => {\n if (parent && typeof index === 'number') {\n parent.children.splice(index, 1);\n }\n });\n };\n}\n\n// remark(), parse the MDX file into MDAST\n// remarkPlugins(), parse the MDAST into HAST\n// rehypePlugins(), render the HAST into React components, i.e. HTML code\nconst processor = remark()\n // parse the md file header\n .use(remarkFrontmatter, ['yaml'])\n // remove the md file header\n .use(remarkRemoveFrontmatter)\n .use(remarkMdx)\n .use(remarkGfm);\n\nexport async function getLLMText(mdxContent: string, title?: string, description?: string) {\n if (typeof mdxContent !== 'string') {\n console.error('getLLMText: mdxContent received was not a string. Type:', typeof mdxContent);\n return `# Error\\n\\nInvalid content received by text processor.`;\n }\n\n try {\n const processed = await processor.process(mdxContent);\n const contentWithoutFrontmatter = processed.value as string;\n\n const markdownParts = [\n title ? `# ${title}` : null,\n description,\n contentWithoutFrontmatter.trim()\n ];\n\n return markdownParts.filter(part => part != null).join('\\n\\n');\n } catch (processingError) {\n console.error('Error during remark processing in getLLMText:', processingError);\n return `# Error\\n\\nError processing MDX content.`;\n }\n} ","// Supported languages and their labels\nconst ALL_LOCALE_LABELS = {\n en: \"English\",\n zh: \"简体中文\",\n ja: \"日本語\", \n ko: \"한국어\",\n fr: \"Français\",\n de: \"Deutsch\",\n es: \"Español\",\n it: \"Italiano\",\n pt: \"Português\",\n tr: \"Türkçe\",\n pl: \"Polski\",\n ru: \"Русский\",\n ar: \"العربية\",\n hi: \"हिन्दी\",\n th: \"ไทย\",\n vi: \"Tiếng Việt\",\n} as const;\n\nexport type SupportedLocale = keyof typeof ALL_LOCALE_LABELS;\n\n// Helper function to get language configuration from environment variables\nfunction getLocaleLabels(locales: string[]) {\n return Object.fromEntries(\n locales.map(locale => [\n locale, \n ALL_LOCALE_LABELS[locale as SupportedLocale] || locale\n ])\n );\n}\n\n// Common application configuration creation function\nexport function createCommonAppConfig(options?: {\n // Optional: manually specify supported languages, otherwise read from environment variables\n locales?: string[];\n defaultLocale?: string;\n}) {\n // Priority: manual configuration > environment variables > default values\n const locales = options?.locales ?? \n process.env.NEXT_PUBLIC_I18N_LOCALES?.split(',').map(s => s.trim()) ?? \n ['en', 'zh'];\n \n const defaultLocale = options?.defaultLocale ?? \n process.env.NEXT_PUBLIC_I18N_DEFAULT_LOCALE ?? \n 'en';\n \n const storagePrefix = process.env.NEXT_PUBLIC_I18N_STORAGE_PREFIX || 'WINDRUN-HUAIIN';\n\n const config = {\n // Basic configuration\n baseUrl: process.env.NEXT_PUBLIC_BASE_URL || '',\n githubBaseUrl: process.env.NEXT_PUBLIC_GITHUB_BASE_URL || '',\n github: process.env.NEXT_PUBLIC_GITHUB || '',\n githubInfoToken: process.env.NEXT_PUBLIC_FUMA_GITHUB_TOKEN || '',\n\n // Internationalization configuration\n i18n: {\n locales: locales as readonly string[],\n defaultLocale,\n localeLabels: getLocaleLabels(locales),\n detector: {\n storageKey: process.env.NEXT_PUBLIC_I18N_STORAGE_KEY || 'language-preference-status',\n autoCloseTimeout: parseInt(process.env.NEXT_PUBLIC_I18N_AUTO_CLOSE_TIMEOUT || '10000'),\n expirationDays: parseInt(process.env.NEXT_PUBLIC_I18N_EXPIRATION_DAYS || '30'),\n storagePrefix\n },\n messageRoot: process.env.NEXT_PUBLIC_I18N_MESSAGE_ROOT || 'messages',\n },\n\n // Style configuration\n style: {\n icon: {\n uniformColor: process.env.NEXT_PUBLIC_STYLE_ICON_COLOR || \"text-purple-500\"\n },\n showBanner: process.env.NEXT_PUBLIC_STYLE_SHOW_BANNER === 'true',\n clerkAuthInModal: process.env.NEXT_PUBLIC_STYLE_CLERK_AUTH_IN_MODAL === 'true',\n clerkPageBanner: process.env.NEXT_PUBLIC_STYLE_CLERK_PAGE_BANNER === 'true',\n watermark: {\n enabled: process.env.NEXT_PUBLIC_STYLE_WATERMARK_ENABLED === 'true',\n text: process.env.NEXT_PUBLIC_STYLE_WATERMARK_TEXT || \"巽川·怀因\"\n },\n cdnBaseUrl: process.env.NEXT_PUBLIC_STYLE_CDN_BASE_URL || \"https://raw.githubusercontent.com/caofanCPU/wind-run-1/main/public\",\n placeHolder: {\n image: process.env.NEXT_PUBLIC_STYLE_PLACEHOLDER_IMAGE || \"/default.webp\"\n }\n },\n\n // Clerk configuration\n clerk: {\n signInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_URL || \"/sign-in\",\n fallbackSignInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL || \"/\",\n signUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_URL || \"/sign-up\", \n fallbackSignUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL || \"/\",\n waitlistUrl: process.env.NEXT_PUBLIC_CLERK_WAITLIST_URL || \"/waitlist\",\n debug: process.env.CLERK_DEBUG === 'true',\n },\n\n // MDX source file directory configuration\n mdxSourceDir: {\n docs: process.env.NEXT_PUBLIC_MDX_DOCS_DIR || \"src/mdx/docs\",\n blog: process.env.NEXT_PUBLIC_MDX_BLOG_DIR || \"src/mdx/blog\", \n legal: process.env.NEXT_PUBLIC_MDX_LEGAL_DIR || \"src/mdx/legal\"\n },\n };\n\n // Convenient constants - avoid deep nested access\n const shortcuts = {\n iconColor: config.style.icon.uniformColor,\n watermark: config.style.watermark,\n showBanner: config.style.showBanner,\n clerkPageBanner: config.style.clerkPageBanner,\n clerkAuthInModal: config.style.clerkAuthInModal,\n placeHolderImage: config.style.placeHolder.image,\n clerk: config.clerk,\n };\n\n return {\n ...config,\n shortcuts\n };\n}\n\n// Create internationalization helper functions\nexport function createI18nHelpers(i18nConfig: ReturnType<typeof createCommonAppConfig>['i18n']) {\n function isSupportedLocale(locale: string): locale is typeof i18nConfig.locales[number] {\n return (i18nConfig.locales as readonly string[]).includes(locale);\n }\n\n function getValidLocale(locale: string): typeof i18nConfig.locales[number] {\n return isSupportedLocale(locale) ? locale : i18nConfig.defaultLocale;\n }\n\n const generatedLocales = i18nConfig.locales.map((loc) => ({\n name: i18nConfig.localeLabels[loc as keyof typeof i18nConfig.localeLabels] || loc,\n locale: loc,\n }));\n\n return {\n isSupportedLocale,\n getValidLocale,\n generatedLocales\n };\n}\n\n// Convenient configuration presets\nexport const LOCALE_PRESETS = {\n // Only support English\n EN_ONLY: { locales: ['en'] as string[], defaultLocale: 'en' as string },\n \n // English and Chinese\n EN_ZH: { locales: ['en', 'zh'] as string[], defaultLocale: 'en' as string },\n \n // Main Asian languages\n ASIA: { locales: ['en', 'zh', 'ja', 'ko'] as string[], defaultLocale: 'en' as string },\n \n // Main European languages\n EUROPE: { locales: ['en', 'fr', 'de', 'es', 'it'] as string[], defaultLocale: 'en' as string },\n \n // Globalization\n GLOBAL: { locales: ['en', 'zh', 'ja', 'ko', 'fr', 'de', 'es', 'it', 'pt', 'ru'] as string[], defaultLocale: 'en' as string },\n \n // No internationalization (only default language)\n NONE: { locales: [] as string[], defaultLocale: 'en' as string }\n}; "]}
1
+ {"version":3,"sources":["../src/utils.ts","../src/llm-utils.ts","../src/llm-copy-handler.ts","../src/common-app-config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;AAEO,SAAS,eAAA,CAAgB,WAAmB,SAAA,EAAmB;AACpE,EAAA,MAAM,IAAA,GAAO,EAAA;AACb,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,MAAM,WAAA,GAAc,QAAA,CAAS,SAAA,EAAW,EAAE,CAAA;AAC1C,EAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG;AACrB,IAAA,OAAO,IAAA;AAAA,EACV;AAEA,EAAA,MAAM,IAAA,GAAO,IAAI,IAAA,CAAK,WAAW,CAAA;AAGjC,EAAA,IAAI,CAAC,OAAA,CAAQ,IAAI,CAAA,EAAG;AAClB,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,IAAI;AAED,IAAA,OAAO,MAAA,CAAO,MAAM,SAAS,CAAA;AAAA,EAChC,SAAS,KA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UAAA,CAAW,YAAA,CAAa,GAA2C,CAAA,IAAK,GAAA;AAAA,IAC9E,MAAA,EAAQ;AAAA,GACV,CAAE,CAAA;AAEF,EAAA,OAAO;AAAA,IACL,iBAAA;AAAA,IACA,cAAA;AAAA,IACA;AAAA,GACF;AACF;AAGO,IAAM,cAAA,GAAiB;AAAA;AAAA,EAE5B,SAAS,EAAE,OAAA,EAAS,CAAC,IAAI,CAAA,EAAe,eAAe,IAAA,EAAe;AAAA;AAAA,EAGtE,KAAA,EAAO,EAAE,OAAA,EAAS,CAAC,MAAM,IAAI,CAAA,EAAe,eAAe,IAAA,EAAe;AAAA;AAAA,EAG1E,IAAA,EAAM,EAAE,OAAA,EAAS,CAAC,IAAA,EAAM,MAAM,IAAA,EAAM,IAAI,CAAA,EAAe,aAAA,EAAe,IAAA,EAAe;AAAA;AAAA,EAGrF,MAAA,EAAQ,EAAE,OAAA,EAAS,CAAC,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAI,CAAA,EAAe,aAAA,EAAe,IAAA,EAAe;AAAA;AAAA,EAG7F,QAAQ,EAAE,OAAA,EAAS,CAAC,IAAA,EAAM,MAAM,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,MAAM,IAAA,EAAM,IAAA,EAAM,IAAI,CAAA,EAAe,eAAe,IAAA,EAAe;AAAA;AAAA,EAG3H,MAAM,EAAE,OAAA,EAAS,EAAC,EAAe,eAAe,IAAA;AAClD","file":"index.mjs","sourcesContent":["import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\nimport { format, isValid } from 'date-fns';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n\nexport function formatTimestamp(timestamp: string, formatter: string) {\n const fail = \"\";\n if (!timestamp) {\n return fail;\n }\n\n // Assume gitTimestamp is a millisecond timestamp string\n const timestampMs = parseInt(timestamp, 10);\n if (isNaN(timestampMs)) {\n return fail;\n }\n\n const date = new Date(timestampMs); // or if it is determined to be seconds, use fromUnixTime(timestampSeconds)\n\n // Check if the date is valid\n if (!isValid(date)) {\n return fail;\n }\n\n // Format the date\n try {\n // 'yyyy-MM-dd HH:mm:ss' is the date-fns formatting pattern\n return format(date, formatter);\n } catch (error) {\n // format may also throw an error due to an invalid date (although isValid should have already caught it)\n console.error(\"Error formatting date:\", error);\n return fail;\n }\n} \n\n// Only allow pasting plain text, prohibit style content\nexport function handlePastePlainText(e: React.ClipboardEvent<HTMLElement>) {\n e.preventDefault();\n const text = e.clipboardData.getData('text/plain');\n const selection = window.getSelection();\n if (!selection || !selection.rangeCount) return;\n // Delete the current selected content\n selection.deleteFromDocument();\n // Insert plain text\n const textNode = document.createTextNode(text);\n const range = selection.getRangeAt(0);\n range.insertNode(textNode);\n // Move the cursor to the inserted text\n range.setStartAfter(textNode);\n range.collapse(true);\n selection.removeAllRanges();\n selection.addRange(range);\n}","import { remark } from 'remark';\nimport remarkGfm from 'remark-gfm';\nimport remarkMdx from 'remark-mdx';\nimport remarkFrontmatter from 'remark-frontmatter';\nimport { visit } from 'unist-util-visit';\n\nfunction remarkRemoveFrontmatter() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (tree: any) => {\n visit(tree, 'yaml', (_node, index, parent) => {\n if (parent && typeof index === 'number') {\n parent.children.splice(index, 1);\n }\n });\n };\n}\n\n// remark(), parse the MDX file into MDAST\n// remarkPlugins(), parse the MDAST into HAST\n// rehypePlugins(), render the HAST into React components, i.e. HTML code\nconst processor = remark()\n // parse the md file header\n .use(remarkFrontmatter, ['yaml'])\n // remove the md file header\n .use(remarkRemoveFrontmatter)\n .use(remarkMdx)\n .use(remarkGfm);\n\nexport async function getLLMText(mdxContent: string, title?: string, description?: string) {\n if (typeof mdxContent !== 'string') {\n console.error('getLLMText: mdxContent received was not a string. Type:', typeof mdxContent);\n return `# Error\\n\\nInvalid content received by text processor.`;\n }\n\n try {\n const processed = await processor.process(mdxContent);\n const contentWithoutFrontmatter = processed.value as string;\n\n const markdownParts = [\n title ? `# ${title}` : null,\n description,\n contentWithoutFrontmatter.trim()\n ];\n\n return markdownParts.filter(part => part != null).join('\\n\\n');\n } catch (processingError) {\n console.error('Error during remark processing in getLLMText:', processingError);\n return `# Error\\n\\nError processing MDX content.`;\n }\n} ","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport fs from 'node:fs';\nimport nodePath from 'node:path';\nimport { getLLMText } from '@lib/llm-utils';\n\nexport type LLMCopyHandlerOptions = {\n // for example: \"src/mdx/blog\"\n sourceDir: string;\n // data source object, like blogSource, legalSource\n dataSource: {\n getPage: (slug: string[], locale: string) => any | undefined;\n };\n // for example: \"blog/2025/07/07/test\"\n requestedPath: string;\n locale: string;\n};\n\n/**\n * General MDX content reading and processing tool function, logs are consistent with router.\n */\nexport async function LLMCopyHandler(options: LLMCopyHandlerOptions): Promise<{ text?: string; error?: string; status: number }> {\n const { sourceDir, dataSource, requestedPath, locale } = options;\n\n // log received parameters\n console.log(`[LLMCopy] Received, locale=${locale}, path=${requestedPath}`);\n\n if (!requestedPath) {\n return { error: 'Missing path query parameter', status: 400 };\n }\n const slug = requestedPath.split('/');\n\n try {\n console.log('[LLMCopy] Attempting to call getPage()');\n const page = dataSource.getPage(slug, locale);\n console.log('[LLMCopy] Call to getPage() completed.');\n\n if (!page || !page.data) {\n console.error(`[LLMCopy] Page or page.data not found for locale=${locale}, path=${requestedPath}`);\n return { error: 'Page data not found', status: 404 };\n }\n if (!page.data._file || !page.data._file.path) {\n console.error(`[LLMCopy] _file path information missing in page.data for locale=${locale}, path=${requestedPath}`);\n return { error: 'Page file path information missing', status: 500 };\n }\n\n const title = page.data.title;\n const description = page.data.description;\n const relativeMdxFilePath = page.data._file.path;\n const absoluteFilePath = nodePath.join(process.cwd(), sourceDir, relativeMdxFilePath);\n console.log(`[LLMCopy] Attempting to read MDX content from: ${absoluteFilePath}`);\n\n let mdxContent: string;\n try {\n mdxContent = fs.readFileSync(absoluteFilePath, 'utf-8');\n console.log(`[LLMCopy] Successfully read MDX content from: ${absoluteFilePath}`);\n } catch (readError: any) {\n console.error(`[LLMCopy] Failed to read file at: ${absoluteFilePath}. Error: ${readError.message}`);\n console.error('[LLMCopy] Read Error object details:', JSON.stringify(readError, Object.getOwnPropertyNames(readError), 2));\n // directory traversal debug logs\n try {\n console.log(`[LLMCopy] Current CWD: ${process.cwd()}`);\n console.log(`[LLMCopy] CWD contents: ${fs.readdirSync(process.cwd()).join(', ')}`);\n const srcPath = nodePath.join(process.cwd(), 'src');\n if (fs.existsSync(srcPath)) {\n console.log(`[LLMCopy] src dir contents: ${fs.readdirSync(srcPath).join(', ')}`);\n const srcMdxPath = nodePath.join(process.cwd(), 'src', 'mdx');\n if (fs.existsSync(srcMdxPath)) {\n console.log(`[LLMCopy] src/mdx dir contents: ${fs.readdirSync(srcMdxPath).join(', ')}`);\n const srcMdxDocsPath = nodePath.join(process.cwd(), sourceDir);\n if (fs.existsSync(srcMdxDocsPath)) {\n console.log(`[LLMCopy] ${sourceDir} dir contents: ${fs.readdirSync(srcMdxDocsPath).join(', ')}`);\n }\n }\n }\n } catch (listDirError: any) {\n console.warn(`[LLMCopy] Could not list directory contents for debugging: ${listDirError.message}`);\n }\n return { error: `Error reading MDX file: ${readError.message}`, status: 500 };\n }\n\n try {\n const text = await getLLMText(mdxContent, title, description);\n return { text, status: 200 };\n } catch (error: any) {\n console.error(`[LLMCopy] Error processing MDX content for locale=${locale}, path=${requestedPath}:`, error);\n console.error('[LLMCopy] General Error object details:', JSON.stringify(error, Object.getOwnPropertyNames(error), 2));\n return { error: 'Error processing MDX content', status: 500 };\n }\n } catch (error: any) {\n console.error(`[LLMCopy] General error for locale=${locale}, path=${requestedPath}:`, error);\n console.error('[LLMCopy] General Error object details:', JSON.stringify(error, Object.getOwnPropertyNames(error), 2));\n return { error: 'Internal Server Error', status: 500 };\n }\n} ","// Supported languages and their labels\nconst ALL_LOCALE_LABELS = {\n en: \"English\",\n zh: \"简体中文\",\n ja: \"日本語\", \n ko: \"한국어\",\n fr: \"Français\",\n de: \"Deutsch\",\n es: \"Español\",\n it: \"Italiano\",\n pt: \"Português\",\n tr: \"Türkçe\",\n pl: \"Polski\",\n ru: \"Русский\",\n ar: \"العربية\",\n hi: \"हिन्दी\",\n th: \"ไทย\",\n vi: \"Tiếng Việt\",\n} as const;\n\nexport type SupportedLocale = keyof typeof ALL_LOCALE_LABELS;\n\n// Helper function to get language configuration from environment variables\nfunction getLocaleLabels(locales: string[]) {\n return Object.fromEntries(\n locales.map(locale => [\n locale, \n ALL_LOCALE_LABELS[locale as SupportedLocale] || locale\n ])\n );\n}\n\n// Common application configuration creation function\nexport function createCommonAppConfig(options?: {\n // Optional: manually specify supported languages, otherwise read from environment variables\n locales?: string[];\n defaultLocale?: string;\n}) {\n // Priority: manual configuration > environment variables > default values\n const locales = options?.locales ?? \n process.env.NEXT_PUBLIC_I18N_LOCALES?.split(',').map(s => s.trim()) ?? \n ['en', 'zh'];\n \n const defaultLocale = options?.defaultLocale ?? \n process.env.NEXT_PUBLIC_I18N_DEFAULT_LOCALE ?? \n 'en';\n \n const storagePrefix = process.env.NEXT_PUBLIC_I18N_STORAGE_PREFIX || 'WINDRUN-HUAIIN';\n\n const config = {\n // Basic configuration\n baseUrl: process.env.NEXT_PUBLIC_BASE_URL || '',\n githubBaseUrl: process.env.NEXT_PUBLIC_GITHUB_BASE_URL || '',\n github: process.env.NEXT_PUBLIC_GITHUB || '',\n githubInfoToken: process.env.NEXT_PUBLIC_FUMA_GITHUB_TOKEN || '',\n\n // Internationalization configuration\n i18n: {\n locales: locales as readonly string[],\n defaultLocale,\n localeLabels: getLocaleLabels(locales),\n detector: {\n storageKey: process.env.NEXT_PUBLIC_I18N_STORAGE_KEY || 'language-preference-status',\n autoCloseTimeout: parseInt(process.env.NEXT_PUBLIC_I18N_AUTO_CLOSE_TIMEOUT || '10000'),\n expirationDays: parseInt(process.env.NEXT_PUBLIC_I18N_EXPIRATION_DAYS || '30'),\n storagePrefix\n },\n messageRoot: process.env.NEXT_PUBLIC_I18N_MESSAGE_ROOT || 'messages',\n },\n\n // Style configuration\n style: {\n icon: {\n uniformColor: process.env.NEXT_PUBLIC_STYLE_ICON_COLOR || \"text-purple-500\"\n },\n showBanner: process.env.NEXT_PUBLIC_STYLE_SHOW_BANNER === 'true',\n clerkAuthInModal: process.env.NEXT_PUBLIC_STYLE_CLERK_AUTH_IN_MODAL === 'true',\n clerkPageBanner: process.env.NEXT_PUBLIC_STYLE_CLERK_PAGE_BANNER === 'true',\n watermark: {\n enabled: process.env.NEXT_PUBLIC_STYLE_WATERMARK_ENABLED === 'true',\n text: process.env.NEXT_PUBLIC_STYLE_WATERMARK_TEXT || \"巽川·怀因\"\n },\n cdnBaseUrl: process.env.NEXT_PUBLIC_STYLE_CDN_BASE_URL || \"https://raw.githubusercontent.com/caofanCPU/wind-run-1/main/public\",\n placeHolder: {\n image: process.env.NEXT_PUBLIC_STYLE_PLACEHOLDER_IMAGE || \"/default.webp\"\n }\n },\n\n // Clerk configuration\n clerk: {\n signInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_URL || \"/sign-in\",\n fallbackSignInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL || \"/\",\n signUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_URL || \"/sign-up\", \n fallbackSignUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL || \"/\",\n waitlistUrl: process.env.NEXT_PUBLIC_CLERK_WAITLIST_URL || \"/waitlist\",\n debug: process.env.CLERK_DEBUG === 'true',\n },\n\n // MDX source file directory configuration\n mdxSourceDir: {\n docs: process.env.NEXT_PUBLIC_MDX_DOCS_DIR || \"src/mdx/docs\",\n blog: process.env.NEXT_PUBLIC_MDX_BLOG_DIR || \"src/mdx/blog\", \n legal: process.env.NEXT_PUBLIC_MDX_LEGAL_DIR || \"src/mdx/legal\"\n },\n };\n\n // Convenient constants - avoid deep nested access\n const shortcuts = {\n iconColor: config.style.icon.uniformColor,\n watermark: config.style.watermark,\n showBanner: config.style.showBanner,\n clerkPageBanner: config.style.clerkPageBanner,\n clerkAuthInModal: config.style.clerkAuthInModal,\n placeHolderImage: config.style.placeHolder.image,\n clerk: config.clerk,\n };\n\n return {\n ...config,\n shortcuts\n };\n}\n\n// Create internationalization helper functions\nexport function createI18nHelpers(i18nConfig: ReturnType<typeof createCommonAppConfig>['i18n']) {\n function isSupportedLocale(locale: string): locale is typeof i18nConfig.locales[number] {\n return (i18nConfig.locales as readonly string[]).includes(locale);\n }\n\n function getValidLocale(locale: string): typeof i18nConfig.locales[number] {\n return isSupportedLocale(locale) ? locale : i18nConfig.defaultLocale;\n }\n\n const generatedLocales = i18nConfig.locales.map((loc) => ({\n name: i18nConfig.localeLabels[loc as keyof typeof i18nConfig.localeLabels] || loc,\n locale: loc,\n }));\n\n return {\n isSupportedLocale,\n getValidLocale,\n generatedLocales\n };\n}\n\n// Convenient configuration presets\nexport const LOCALE_PRESETS = {\n // Only support English\n EN_ONLY: { locales: ['en'] as string[], defaultLocale: 'en' as string },\n \n // English and Chinese\n EN_ZH: { locales: ['en', 'zh'] as string[], defaultLocale: 'en' as string },\n \n // Main Asian languages\n ASIA: { locales: ['en', 'zh', 'ja', 'ko'] as string[], defaultLocale: 'en' as string },\n \n // Main European languages\n EUROPE: { locales: ['en', 'fr', 'de', 'es', 'it'] as string[], defaultLocale: 'en' as string },\n \n // Globalization\n GLOBAL: { locales: ['en', 'zh', 'ja', 'ko', 'fr', 'de', 'es', 'it', 'pt', 'ru'] as string[], defaultLocale: 'en' as string },\n \n // No internationalization (only default language)\n NONE: { locales: [] as string[], defaultLocale: 'en' as string }\n}; "]}
@@ -1 +1 @@
1
- export { AlbumIcon, AlignHorizontalJustifyEnd, ArrowLeft, ArrowRight, ArrowUp, Binary, Blocks, BookX, BotMessageSquare, BringToFront, Bug, Building2, Car, Check, CheckCheck, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Circle, CircleAlert, CircleSmall, CircleStop, ComponentIcon, Copy, Cpu, DatabaseZap, Dot, Download, ExternalLink, Eye, Facebook, File, FileDown, FileInput, FileLock2, FileUp, Fingerprint, Folder, FolderOpen, Gift, GitPullRequestArrow, Globe, GlobeLock, Grip, GripVertical, HandHeart, Handshake, Highlighter, HousePlus, ImageDown, ImageOff, ImageUp, Infinity, Info, Keyboard, LandPlot, Layout, LayoutTemplate, LibraryIcon, Link, ListTodo, Loader2, LogIn, LogOut, Mail, MessageCircleCode, MessageCircleMore, MoreHorizontal, MousePointerClick, Palette, PanelLeft, PanelsTopLeft, PawPrint, Pencil, Pi, QrCode, ReceiptText, RefreshCcw, Regex, Replace, Rocket, Rss, Scale, Search, SendHorizontal, Server, Share, Shield, ShieldUser, Sigma, Sparkles, SplinePointer, Sprout, SquareDashedBottomCode, SquareTerminal, Star, Tablets, Terminal, Twitter, Workflow, X, Zap } from 'lucide-react';
1
+ export { AlbumIcon, AlignHorizontalJustifyEnd, ArrowLeft, ArrowRight, ArrowUp, Binary, Blocks, BookX, BotMessageSquare, BringToFront, Bug, Building2, Car, Check, CheckCheck, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Circle, CircleAlert, CircleSmall, CircleStop, ComponentIcon, Copy, Cpu, DatabaseZap, Dot, Download, ExternalLink, Eye, Facebook, File, FileDown, FileInput, FileLock2, FileUp, Fingerprint, Folder, FolderOpen, Gift, GitMerge, GitPullRequestArrow, Globe, GlobeLock, Grip, GripVertical, HandHeart, Handshake, Highlighter, HousePlus, ImageDown, ImageOff, ImageUp, Infinity, Info, Keyboard, LandPlot, Layout, LayoutTemplate, LibraryIcon, Link, ListTodo, Loader2, LogIn, LogOut, Mail, MessageCircleCode, MessageCircleMore, MoreHorizontal, MousePointerClick, Palette, PanelLeft, PanelsTopLeft, PawPrint, Pencil, Pi, QrCode, ReceiptText, RefreshCcw, Regex, Replace, Rocket, Rss, Scale, Search, SendHorizontal, Server, Share, Shield, ShieldUser, Sigma, Sparkles, SplinePointer, Sprout, SquareDashedBottomCode, SquareTerminal, Star, Tablets, Terminal, Twitter, Workflow, X, Zap } from 'lucide-react';
@@ -1 +1 @@
1
- export { AlbumIcon, AlignHorizontalJustifyEnd, ArrowLeft, ArrowRight, ArrowUp, Binary, Blocks, BookX, BotMessageSquare, BringToFront, Bug, Building2, Car, Check, CheckCheck, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Circle, CircleAlert, CircleSmall, CircleStop, ComponentIcon, Copy, Cpu, DatabaseZap, Dot, Download, ExternalLink, Eye, Facebook, File, FileDown, FileInput, FileLock2, FileUp, Fingerprint, Folder, FolderOpen, Gift, GitPullRequestArrow, Globe, GlobeLock, Grip, GripVertical, HandHeart, Handshake, Highlighter, HousePlus, ImageDown, ImageOff, ImageUp, Infinity, Info, Keyboard, LandPlot, Layout, LayoutTemplate, LibraryIcon, Link, ListTodo, Loader2, LogIn, LogOut, Mail, MessageCircleCode, MessageCircleMore, MoreHorizontal, MousePointerClick, Palette, PanelLeft, PanelsTopLeft, PawPrint, Pencil, Pi, QrCode, ReceiptText, RefreshCcw, Regex, Replace, Rocket, Rss, Scale, Search, SendHorizontal, Server, Share, Shield, ShieldUser, Sigma, Sparkles, SplinePointer, Sprout, SquareDashedBottomCode, SquareTerminal, Star, Tablets, Terminal, Twitter, Workflow, X, Zap } from 'lucide-react';
1
+ export { AlbumIcon, AlignHorizontalJustifyEnd, ArrowLeft, ArrowRight, ArrowUp, Binary, Blocks, BookX, BotMessageSquare, BringToFront, Bug, Building2, Car, Check, CheckCheck, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Circle, CircleAlert, CircleSmall, CircleStop, ComponentIcon, Copy, Cpu, DatabaseZap, Dot, Download, ExternalLink, Eye, Facebook, File, FileDown, FileInput, FileLock2, FileUp, Fingerprint, Folder, FolderOpen, Gift, GitMerge, GitPullRequestArrow, Globe, GlobeLock, Grip, GripVertical, HandHeart, Handshake, Highlighter, HousePlus, ImageDown, ImageOff, ImageUp, Infinity, Info, Keyboard, LandPlot, Layout, LayoutTemplate, LibraryIcon, Link, ListTodo, Loader2, LogIn, LogOut, Mail, MessageCircleCode, MessageCircleMore, MoreHorizontal, MousePointerClick, Palette, PanelLeft, PanelsTopLeft, PawPrint, Pencil, Pi, QrCode, ReceiptText, RefreshCcw, Regex, Replace, Rocket, Rss, Scale, Search, SendHorizontal, Server, Share, Shield, ShieldUser, Sigma, Sparkles, SplinePointer, Sprout, SquareDashedBottomCode, SquareTerminal, Star, Tablets, Terminal, Twitter, Workflow, X, Zap } from 'lucide-react';
@@ -168,6 +168,10 @@ Object.defineProperty(exports, "Gift", {
168
168
  enumerable: true,
169
169
  get: function () { return lucideReact.Gift; }
170
170
  });
171
+ Object.defineProperty(exports, "GitMerge", {
172
+ enumerable: true,
173
+ get: function () { return lucideReact.GitMerge; }
174
+ });
171
175
  Object.defineProperty(exports, "GitPullRequestArrow", {
172
176
  enumerable: true,
173
177
  get: function () { return lucideReact.GitPullRequestArrow; }
@@ -1,3 +1,3 @@
1
- export { AlbumIcon, AlignHorizontalJustifyEnd, ArrowLeft, ArrowRight, ArrowUp, Binary, Blocks, BookX, BotMessageSquare, BringToFront, Bug, Building2, Car, Check, CheckCheck, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Circle, CircleAlert, CircleSmall, CircleStop, ComponentIcon, Copy, Cpu, DatabaseZap, Dot, Download, ExternalLink, Eye, Facebook, File, FileDown, FileInput, FileLock2, FileUp, Fingerprint, Folder, FolderOpen, Gift, GitPullRequestArrow, Globe, GlobeLock, Grip, GripVertical, HandHeart, Handshake, Highlighter, HousePlus, ImageDown, ImageOff, ImageUp, Infinity, Info, Keyboard, LandPlot, Layout, LayoutTemplate, LibraryIcon, Link, ListTodo, Loader2, LogIn, LogOut, Mail, MessageCircleCode, MessageCircleMore, MoreHorizontal, MousePointerClick, Palette, PanelLeft, PanelsTopLeft, PawPrint, Pencil, Pi, QrCode, ReceiptText, RefreshCcw, Regex, Replace, Rocket, Rss, Scale, Search, SendHorizontal, Server, Share, Shield, ShieldUser, Sigma, Sparkles, SplinePointer, Sprout, SquareDashedBottomCode, SquareTerminal, Star, Tablets, Terminal, Twitter, Workflow, X, Zap } from 'lucide-react';
1
+ export { AlbumIcon, AlignHorizontalJustifyEnd, ArrowLeft, ArrowRight, ArrowUp, Binary, Blocks, BookX, BotMessageSquare, BringToFront, Bug, Building2, Car, Check, CheckCheck, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Circle, CircleAlert, CircleSmall, CircleStop, ComponentIcon, Copy, Cpu, DatabaseZap, Dot, Download, ExternalLink, Eye, Facebook, File, FileDown, FileInput, FileLock2, FileUp, Fingerprint, Folder, FolderOpen, Gift, GitMerge, GitPullRequestArrow, Globe, GlobeLock, Grip, GripVertical, HandHeart, Handshake, Highlighter, HousePlus, ImageDown, ImageOff, ImageUp, Infinity, Info, Keyboard, LandPlot, Layout, LayoutTemplate, LibraryIcon, Link, ListTodo, Loader2, LogIn, LogOut, Mail, MessageCircleCode, MessageCircleMore, MoreHorizontal, MousePointerClick, Palette, PanelLeft, PanelsTopLeft, PawPrint, Pencil, Pi, QrCode, ReceiptText, RefreshCcw, Regex, Replace, Rocket, Rss, Scale, Search, SendHorizontal, Server, Share, Shield, ShieldUser, Sigma, Sparkles, SplinePointer, Sprout, SquareDashedBottomCode, SquareTerminal, Star, Tablets, Terminal, Twitter, Workflow, X, Zap } from 'lucide-react';
2
2
  //# sourceMappingURL=limited-lucide-icons.mjs.map
3
3
  //# sourceMappingURL=limited-lucide-icons.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/lib",
3
- "version": "5.5.0",
3
+ "version": "5.6.1",
4
4
  "description": "Common utilities and configuration",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
package/src/index.ts CHANGED
@@ -6,6 +6,7 @@ export * from './limited-lucide-icons';
6
6
 
7
7
  // export the LLM related functions
8
8
  export * from './llm-utils';
9
+ export * from './llm-copy-handler';
9
10
 
10
11
  // export the common app config
11
12
  export * from './common-app-config';
@@ -47,6 +47,7 @@ export {
47
47
  Folder,
48
48
  FolderOpen,
49
49
  Gift,
50
+ GitMerge,
50
51
  GitPullRequestArrow,
51
52
  Globe,
52
53
  GlobeLock,
@@ -0,0 +1,95 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
3
+ import fs from 'node:fs';
4
+ import nodePath from 'node:path';
5
+ import { getLLMText } from '@lib/llm-utils';
6
+
7
+ export type LLMCopyHandlerOptions = {
8
+ // for example: "src/mdx/blog"
9
+ sourceDir: string;
10
+ // data source object, like blogSource, legalSource
11
+ dataSource: {
12
+ getPage: (slug: string[], locale: string) => any | undefined;
13
+ };
14
+ // for example: "blog/2025/07/07/test"
15
+ requestedPath: string;
16
+ locale: string;
17
+ };
18
+
19
+ /**
20
+ * General MDX content reading and processing tool function, logs are consistent with router.
21
+ */
22
+ export async function LLMCopyHandler(options: LLMCopyHandlerOptions): Promise<{ text?: string; error?: string; status: number }> {
23
+ const { sourceDir, dataSource, requestedPath, locale } = options;
24
+
25
+ // log received parameters
26
+ console.log(`[LLMCopy] Received, locale=${locale}, path=${requestedPath}`);
27
+
28
+ if (!requestedPath) {
29
+ return { error: 'Missing path query parameter', status: 400 };
30
+ }
31
+ const slug = requestedPath.split('/');
32
+
33
+ try {
34
+ console.log('[LLMCopy] Attempting to call getPage()');
35
+ const page = dataSource.getPage(slug, locale);
36
+ console.log('[LLMCopy] Call to getPage() completed.');
37
+
38
+ if (!page || !page.data) {
39
+ console.error(`[LLMCopy] Page or page.data not found for locale=${locale}, path=${requestedPath}`);
40
+ return { error: 'Page data not found', status: 404 };
41
+ }
42
+ if (!page.data._file || !page.data._file.path) {
43
+ console.error(`[LLMCopy] _file path information missing in page.data for locale=${locale}, path=${requestedPath}`);
44
+ return { error: 'Page file path information missing', status: 500 };
45
+ }
46
+
47
+ const title = page.data.title;
48
+ const description = page.data.description;
49
+ const relativeMdxFilePath = page.data._file.path;
50
+ const absoluteFilePath = nodePath.join(process.cwd(), sourceDir, relativeMdxFilePath);
51
+ console.log(`[LLMCopy] Attempting to read MDX content from: ${absoluteFilePath}`);
52
+
53
+ let mdxContent: string;
54
+ try {
55
+ mdxContent = fs.readFileSync(absoluteFilePath, 'utf-8');
56
+ console.log(`[LLMCopy] Successfully read MDX content from: ${absoluteFilePath}`);
57
+ } catch (readError: any) {
58
+ console.error(`[LLMCopy] Failed to read file at: ${absoluteFilePath}. Error: ${readError.message}`);
59
+ console.error('[LLMCopy] Read Error object details:', JSON.stringify(readError, Object.getOwnPropertyNames(readError), 2));
60
+ // directory traversal debug logs
61
+ try {
62
+ console.log(`[LLMCopy] Current CWD: ${process.cwd()}`);
63
+ console.log(`[LLMCopy] CWD contents: ${fs.readdirSync(process.cwd()).join(', ')}`);
64
+ const srcPath = nodePath.join(process.cwd(), 'src');
65
+ if (fs.existsSync(srcPath)) {
66
+ console.log(`[LLMCopy] src dir contents: ${fs.readdirSync(srcPath).join(', ')}`);
67
+ const srcMdxPath = nodePath.join(process.cwd(), 'src', 'mdx');
68
+ if (fs.existsSync(srcMdxPath)) {
69
+ console.log(`[LLMCopy] src/mdx dir contents: ${fs.readdirSync(srcMdxPath).join(', ')}`);
70
+ const srcMdxDocsPath = nodePath.join(process.cwd(), sourceDir);
71
+ if (fs.existsSync(srcMdxDocsPath)) {
72
+ console.log(`[LLMCopy] ${sourceDir} dir contents: ${fs.readdirSync(srcMdxDocsPath).join(', ')}`);
73
+ }
74
+ }
75
+ }
76
+ } catch (listDirError: any) {
77
+ console.warn(`[LLMCopy] Could not list directory contents for debugging: ${listDirError.message}`);
78
+ }
79
+ return { error: `Error reading MDX file: ${readError.message}`, status: 500 };
80
+ }
81
+
82
+ try {
83
+ const text = await getLLMText(mdxContent, title, description);
84
+ return { text, status: 200 };
85
+ } catch (error: any) {
86
+ console.error(`[LLMCopy] Error processing MDX content for locale=${locale}, path=${requestedPath}:`, error);
87
+ console.error('[LLMCopy] General Error object details:', JSON.stringify(error, Object.getOwnPropertyNames(error), 2));
88
+ return { error: 'Error processing MDX content', status: 500 };
89
+ }
90
+ } catch (error: any) {
91
+ console.error(`[LLMCopy] General error for locale=${locale}, path=${requestedPath}:`, error);
92
+ console.error('[LLMCopy] General Error object details:', JSON.stringify(error, Object.getOwnPropertyNames(error), 2));
93
+ return { error: 'Internal Server Error', status: 500 };
94
+ }
95
+ }