@windrun-huaiin/lib 6.2.1 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,268 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var clsx = require('clsx');
4
- var tailwindMerge = require('tailwind-merge');
5
- var dateFns = require('date-fns');
6
- var remark = require('remark');
7
- var remarkGfm = require('remark-gfm');
8
- var remarkMdx = require('remark-mdx');
9
- var remarkFrontmatter = require('remark-frontmatter');
10
- var unistUtilVisit = require('unist-util-visit');
3
+ var utils = require('./utils.js');
4
+ var llmUtils = require('./llm-utils.js');
5
+ var commonAppConfig = require('./common-app-config.js');
11
6
 
12
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
7
 
14
- var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
15
- var remarkMdx__default = /*#__PURE__*/_interopDefault(remarkMdx);
16
- var remarkFrontmatter__default = /*#__PURE__*/_interopDefault(remarkFrontmatter);
17
8
 
18
- var __defProp = Object.defineProperty;
19
- var __defProps = Object.defineProperties;
20
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
21
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
22
- var __hasOwnProp = Object.prototype.hasOwnProperty;
23
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
24
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
25
- var __spreadValues = (a, b) => {
26
- for (var prop in b || (b = {}))
27
- if (__hasOwnProp.call(b, prop))
28
- __defNormalProp(a, prop, b[prop]);
29
- if (__getOwnPropSymbols)
30
- for (var prop of __getOwnPropSymbols(b)) {
31
- if (__propIsEnum.call(b, prop))
32
- __defNormalProp(a, prop, b[prop]);
33
- }
34
- return a;
35
- };
36
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
37
- var __async = (__this, __arguments, generator) => {
38
- return new Promise((resolve, reject) => {
39
- var fulfilled = (value) => {
40
- try {
41
- step(generator.next(value));
42
- } catch (e) {
43
- reject(e);
44
- }
45
- };
46
- var rejected = (value) => {
47
- try {
48
- step(generator.throw(value));
49
- } catch (e) {
50
- reject(e);
51
- }
52
- };
53
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
54
- step((generator = generator.apply(__this, __arguments)).next());
55
- });
56
- };
57
- function cn(...inputs) {
58
- return tailwindMerge.twMerge(clsx.clsx(inputs));
59
- }
60
- function formatTimestamp(timestamp, formatter) {
61
- const fail = "";
62
- if (!timestamp) {
63
- return fail;
64
- }
65
- const timestampMs = parseInt(timestamp, 10);
66
- if (isNaN(timestampMs)) {
67
- return fail;
68
- }
69
- const date = new Date(timestampMs);
70
- if (!dateFns.isValid(date)) {
71
- return fail;
72
- }
73
- try {
74
- return dateFns.format(date, formatter);
75
- } catch (error) {
76
- console.error("Error formatting date:", error);
77
- return fail;
78
- }
79
- }
80
- function handlePastePlainText(e) {
81
- e.preventDefault();
82
- const text = e.clipboardData.getData("text/plain");
83
- const selection = window.getSelection();
84
- if (!selection || !selection.rangeCount) return;
85
- selection.deleteFromDocument();
86
- const textNode = document.createTextNode(text);
87
- const range = selection.getRangeAt(0);
88
- range.insertNode(textNode);
89
- range.setStartAfter(textNode);
90
- range.collapse(true);
91
- selection.removeAllRanges();
92
- selection.addRange(range);
93
- }
94
- function remarkRemoveFrontmatter() {
95
- return (tree) => {
96
- unistUtilVisit.visit(tree, "yaml", (_node, index, parent) => {
97
- if (parent && typeof index === "number") {
98
- parent.children.splice(index, 1);
99
- }
100
- });
101
- };
102
- }
103
- var processor = remark.remark().use(remarkFrontmatter__default.default, ["yaml"]).use(remarkRemoveFrontmatter).use(remarkMdx__default.default).use(remarkGfm__default.default);
104
- function getLLMText(mdxContent, title, description) {
105
- return __async(this, null, function* () {
106
- if (typeof mdxContent !== "string") {
107
- console.error("getLLMText: mdxContent received was not a string. Type:", typeof mdxContent);
108
- return `# Error
109
-
110
- Invalid content received by text processor.`;
111
- }
112
- try {
113
- const processed = yield processor.process(mdxContent);
114
- const contentWithoutFrontmatter = processed.value;
115
- const markdownParts = [
116
- title ? `# ${title}` : null,
117
- description,
118
- contentWithoutFrontmatter.trim()
119
- ];
120
- return markdownParts.filter((part) => part != null).join("\n\n");
121
- } catch (processingError) {
122
- console.error("Error during remark processing in getLLMText:", processingError);
123
- return `# Error
124
-
125
- Error processing MDX content.`;
126
- }
127
- });
128
- }
129
-
130
- // src/common-app-config.ts
131
- var ALL_LOCALE_LABELS = {
132
- en: "English",
133
- zh: "\u7B80\u4F53\u4E2D\u6587",
134
- ja: "\u65E5\u672C\u8A9E",
135
- ko: "\uD55C\uAD6D\uC5B4",
136
- fr: "Fran\xE7ais",
137
- de: "Deutsch",
138
- es: "Espa\xF1ol",
139
- it: "Italiano",
140
- pt: "Portugu\xEAs",
141
- tr: "T\xFCrk\xE7e",
142
- pl: "Polski",
143
- ru: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439",
144
- ar: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629",
145
- hi: "\u0939\u093F\u0928\u094D\u0926\u0940",
146
- th: "\u0E44\u0E17\u0E22",
147
- vi: "Ti\u1EBFng Vi\u1EC7t"
148
- };
149
- function getLocaleLabels(locales) {
150
- return Object.fromEntries(
151
- locales.map((locale) => [
152
- locale,
153
- ALL_LOCALE_LABELS[locale] || locale
154
- ])
155
- );
156
- }
157
- function createCommonAppConfig(options) {
158
- var _a, _b, _c, _d, _e;
159
- const locales = (_c = (_b = options == null ? void 0 : options.locales) != null ? _b : (_a = process.env.NEXT_PUBLIC_I18N_LOCALES) == null ? void 0 : _a.split(",").map((s) => s.trim())) != null ? _c : ["en", "zh"];
160
- const defaultLocale = (_e = (_d = options == null ? void 0 : options.defaultLocale) != null ? _d : process.env.NEXT_PUBLIC_I18N_DEFAULT_LOCALE) != null ? _e : "en";
161
- const storagePrefix = process.env.NEXT_PUBLIC_I18N_STORAGE_PREFIX || "WINDRUN-HUAIIN";
162
- const config = {
163
- // Basic configuration
164
- baseUrl: process.env.NEXT_PUBLIC_BASE_URL || "",
165
- githubBaseUrl: process.env.NEXT_PUBLIC_GITHUB_BASE_URL || "",
166
- github: process.env.NEXT_PUBLIC_GITHUB || "",
167
- githubInfoToken: process.env.NEXT_PUBLIC_FUMA_GITHUB_TOKEN || "",
168
- // Internationalization configuration
169
- i18n: {
170
- locales,
171
- defaultLocale,
172
- localeLabels: getLocaleLabels(locales),
173
- detector: {
174
- storageKey: process.env.NEXT_PUBLIC_I18N_STORAGE_KEY || "language-preference-status",
175
- autoCloseTimeout: parseInt(process.env.NEXT_PUBLIC_I18N_AUTO_CLOSE_TIMEOUT || "10000"),
176
- expirationDays: parseInt(process.env.NEXT_PUBLIC_I18N_EXPIRATION_DAYS || "30"),
177
- storagePrefix
178
- },
179
- messageRoot: process.env.NEXT_PUBLIC_I18N_MESSAGE_ROOT || "messages"
180
- },
181
- // Style configuration
182
- style: {
183
- icon: {
184
- uniformColor: process.env.NEXT_PUBLIC_STYLE_ICON_COLOR || "text-purple-500"
185
- },
186
- showBanner: process.env.NEXT_PUBLIC_STYLE_SHOW_BANNER === "true",
187
- clerkAuthInModal: process.env.NEXT_PUBLIC_STYLE_CLERK_AUTH_IN_MODAL === "true",
188
- clerkPageBanner: process.env.NEXT_PUBLIC_STYLE_CLERK_PAGE_BANNER === "true",
189
- watermark: {
190
- enabled: process.env.NEXT_PUBLIC_STYLE_WATERMARK_ENABLED === "true",
191
- text: process.env.NEXT_PUBLIC_STYLE_WATERMARK_TEXT || "\u5DFD\u5DDD\xB7\u6000\u56E0"
192
- },
193
- cdnBaseUrl: process.env.NEXT_PUBLIC_STYLE_CDN_BASE_URL || "https://r2.d8ger.com",
194
- cdnProxyUrl: process.env.NEXT_PUBLIC_STYLE_CDN_PROXY_URL || "https://r2-explorer-template.zcy777et.workers.dev/proxy",
195
- placeHolder: {
196
- image: process.env.NEXT_PUBLIC_STYLE_PLACEHOLDER_IMAGE || "/default.webp"
197
- }
198
- },
199
- // Clerk configuration
200
- clerk: {
201
- signInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_URL || "/sign-in",
202
- fallbackSignInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL || "/",
203
- signUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_URL || "/sign-up",
204
- fallbackSignUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL || "/",
205
- waitlistUrl: process.env.NEXT_PUBLIC_CLERK_WAITLIST_URL || "/waitlist",
206
- debug: process.env.CLERK_DEBUG === "true"
207
- },
208
- // MDX source file directory configuration
209
- mdxSourceDir: {
210
- docs: process.env.NEXT_PUBLIC_MDX_DOCS_DIR || "src/mdx/docs",
211
- blog: process.env.NEXT_PUBLIC_MDX_BLOG_DIR || "src/mdx/blog",
212
- legal: process.env.NEXT_PUBLIC_MDX_LEGAL_DIR || "src/mdx/legal"
213
- }
214
- };
215
- const shortcuts = {
216
- iconColor: config.style.icon.uniformColor,
217
- watermark: config.style.watermark,
218
- showBanner: config.style.showBanner,
219
- clerkPageBanner: config.style.clerkPageBanner,
220
- clerkAuthInModal: config.style.clerkAuthInModal,
221
- placeHolderImage: config.style.placeHolder.image,
222
- clerk: config.clerk
223
- };
224
- return __spreadProps(__spreadValues({}, config), {
225
- shortcuts
226
- });
227
- }
228
- function createI18nHelpers(i18nConfig) {
229
- function isSupportedLocale(locale) {
230
- return i18nConfig.locales.includes(locale);
231
- }
232
- function getValidLocale(locale) {
233
- return isSupportedLocale(locale) ? locale : i18nConfig.defaultLocale;
234
- }
235
- const generatedLocales = i18nConfig.locales.map((loc) => ({
236
- name: i18nConfig.localeLabels[loc] || loc,
237
- locale: loc
238
- }));
239
- return {
240
- isSupportedLocale,
241
- getValidLocale,
242
- generatedLocales
243
- };
244
- }
245
- var LOCALE_PRESETS = {
246
- // Only support English
247
- EN_ONLY: { locales: ["en"], defaultLocale: "en" },
248
- // English and Chinese
249
- EN_ZH: { locales: ["en", "zh"], defaultLocale: "en" },
250
- // Main Asian languages
251
- ASIA: { locales: ["en", "zh", "ja", "ko"], defaultLocale: "en" },
252
- // Main European languages
253
- EUROPE: { locales: ["en", "fr", "de", "es", "it"], defaultLocale: "en" },
254
- // Globalization
255
- GLOBAL: { locales: ["en", "zh", "ja", "ko", "fr", "de", "es", "it", "pt", "ru"], defaultLocale: "en" },
256
- // No internationalization (only default language)
257
- NONE: { locales: [], defaultLocale: "en" }
258
- };
259
-
260
- exports.LOCALE_PRESETS = LOCALE_PRESETS;
261
- exports.cn = cn;
262
- exports.createCommonAppConfig = createCommonAppConfig;
263
- exports.createI18nHelpers = createI18nHelpers;
264
- exports.formatTimestamp = formatTimestamp;
265
- exports.getLLMText = getLLMText;
266
- exports.handlePastePlainText = handlePastePlainText;
267
- //# sourceMappingURL=index.js.map
268
- //# sourceMappingURL=index.js.map
9
+ exports.cn = utils.cn;
10
+ exports.formatTimestamp = utils.formatTimestamp;
11
+ exports.handlePastePlainText = utils.handlePastePlainText;
12
+ exports.getLLMText = llmUtils.getLLMText;
13
+ exports.LOCALE_PRESETS = commonAppConfig.LOCALE_PRESETS;
14
+ exports.createCommonAppConfig = commonAppConfig.createCommonAppConfig;
15
+ exports.createI18nHelpers = commonAppConfig.createI18nHelpers;
package/dist/index.mjs CHANGED
@@ -1,254 +1,3 @@
1
- import { clsx } from 'clsx';
2
- import { twMerge } from 'tailwind-merge';
3
- import { isValid, format } from 'date-fns';
4
- import { remark } from 'remark';
5
- import remarkGfm from 'remark-gfm';
6
- import remarkMdx from 'remark-mdx';
7
- import remarkFrontmatter from 'remark-frontmatter';
8
- import { visit } from 'unist-util-visit';
9
-
10
- var __defProp = Object.defineProperty;
11
- var __defProps = Object.defineProperties;
12
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
13
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
14
- var __hasOwnProp = Object.prototype.hasOwnProperty;
15
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
16
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17
- var __spreadValues = (a, b) => {
18
- for (var prop in b || (b = {}))
19
- if (__hasOwnProp.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- if (__getOwnPropSymbols)
22
- for (var prop of __getOwnPropSymbols(b)) {
23
- if (__propIsEnum.call(b, prop))
24
- __defNormalProp(a, prop, b[prop]);
25
- }
26
- return a;
27
- };
28
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
29
- var __async = (__this, __arguments, generator) => {
30
- return new Promise((resolve, reject) => {
31
- var fulfilled = (value) => {
32
- try {
33
- step(generator.next(value));
34
- } catch (e) {
35
- reject(e);
36
- }
37
- };
38
- var rejected = (value) => {
39
- try {
40
- step(generator.throw(value));
41
- } catch (e) {
42
- reject(e);
43
- }
44
- };
45
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
46
- step((generator = generator.apply(__this, __arguments)).next());
47
- });
48
- };
49
- function cn(...inputs) {
50
- return twMerge(clsx(inputs));
51
- }
52
- function formatTimestamp(timestamp, formatter) {
53
- const fail = "";
54
- if (!timestamp) {
55
- return fail;
56
- }
57
- const timestampMs = parseInt(timestamp, 10);
58
- if (isNaN(timestampMs)) {
59
- return fail;
60
- }
61
- const date = new Date(timestampMs);
62
- if (!isValid(date)) {
63
- return fail;
64
- }
65
- try {
66
- return format(date, formatter);
67
- } catch (error) {
68
- console.error("Error formatting date:", error);
69
- return fail;
70
- }
71
- }
72
- function handlePastePlainText(e) {
73
- e.preventDefault();
74
- const text = e.clipboardData.getData("text/plain");
75
- const selection = window.getSelection();
76
- if (!selection || !selection.rangeCount) return;
77
- selection.deleteFromDocument();
78
- const textNode = document.createTextNode(text);
79
- const range = selection.getRangeAt(0);
80
- range.insertNode(textNode);
81
- range.setStartAfter(textNode);
82
- range.collapse(true);
83
- selection.removeAllRanges();
84
- selection.addRange(range);
85
- }
86
- function remarkRemoveFrontmatter() {
87
- return (tree) => {
88
- visit(tree, "yaml", (_node, index, parent) => {
89
- if (parent && typeof index === "number") {
90
- parent.children.splice(index, 1);
91
- }
92
- });
93
- };
94
- }
95
- var processor = remark().use(remarkFrontmatter, ["yaml"]).use(remarkRemoveFrontmatter).use(remarkMdx).use(remarkGfm);
96
- function getLLMText(mdxContent, title, description) {
97
- return __async(this, null, function* () {
98
- if (typeof mdxContent !== "string") {
99
- console.error("getLLMText: mdxContent received was not a string. Type:", typeof mdxContent);
100
- return `# Error
101
-
102
- Invalid content received by text processor.`;
103
- }
104
- try {
105
- const processed = yield processor.process(mdxContent);
106
- const contentWithoutFrontmatter = processed.value;
107
- const markdownParts = [
108
- title ? `# ${title}` : null,
109
- description,
110
- contentWithoutFrontmatter.trim()
111
- ];
112
- return markdownParts.filter((part) => part != null).join("\n\n");
113
- } catch (processingError) {
114
- console.error("Error during remark processing in getLLMText:", processingError);
115
- return `# Error
116
-
117
- Error processing MDX content.`;
118
- }
119
- });
120
- }
121
-
122
- // src/common-app-config.ts
123
- var ALL_LOCALE_LABELS = {
124
- en: "English",
125
- zh: "\u7B80\u4F53\u4E2D\u6587",
126
- ja: "\u65E5\u672C\u8A9E",
127
- ko: "\uD55C\uAD6D\uC5B4",
128
- fr: "Fran\xE7ais",
129
- de: "Deutsch",
130
- es: "Espa\xF1ol",
131
- it: "Italiano",
132
- pt: "Portugu\xEAs",
133
- tr: "T\xFCrk\xE7e",
134
- pl: "Polski",
135
- ru: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439",
136
- ar: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629",
137
- hi: "\u0939\u093F\u0928\u094D\u0926\u0940",
138
- th: "\u0E44\u0E17\u0E22",
139
- vi: "Ti\u1EBFng Vi\u1EC7t"
140
- };
141
- function getLocaleLabels(locales) {
142
- return Object.fromEntries(
143
- locales.map((locale) => [
144
- locale,
145
- ALL_LOCALE_LABELS[locale] || locale
146
- ])
147
- );
148
- }
149
- function createCommonAppConfig(options) {
150
- var _a, _b, _c, _d, _e;
151
- const locales = (_c = (_b = options == null ? void 0 : options.locales) != null ? _b : (_a = process.env.NEXT_PUBLIC_I18N_LOCALES) == null ? void 0 : _a.split(",").map((s) => s.trim())) != null ? _c : ["en", "zh"];
152
- const defaultLocale = (_e = (_d = options == null ? void 0 : options.defaultLocale) != null ? _d : process.env.NEXT_PUBLIC_I18N_DEFAULT_LOCALE) != null ? _e : "en";
153
- const storagePrefix = process.env.NEXT_PUBLIC_I18N_STORAGE_PREFIX || "WINDRUN-HUAIIN";
154
- const config = {
155
- // Basic configuration
156
- baseUrl: process.env.NEXT_PUBLIC_BASE_URL || "",
157
- githubBaseUrl: process.env.NEXT_PUBLIC_GITHUB_BASE_URL || "",
158
- github: process.env.NEXT_PUBLIC_GITHUB || "",
159
- githubInfoToken: process.env.NEXT_PUBLIC_FUMA_GITHUB_TOKEN || "",
160
- // Internationalization configuration
161
- i18n: {
162
- locales,
163
- defaultLocale,
164
- localeLabels: getLocaleLabels(locales),
165
- detector: {
166
- storageKey: process.env.NEXT_PUBLIC_I18N_STORAGE_KEY || "language-preference-status",
167
- autoCloseTimeout: parseInt(process.env.NEXT_PUBLIC_I18N_AUTO_CLOSE_TIMEOUT || "10000"),
168
- expirationDays: parseInt(process.env.NEXT_PUBLIC_I18N_EXPIRATION_DAYS || "30"),
169
- storagePrefix
170
- },
171
- messageRoot: process.env.NEXT_PUBLIC_I18N_MESSAGE_ROOT || "messages"
172
- },
173
- // Style configuration
174
- style: {
175
- icon: {
176
- uniformColor: process.env.NEXT_PUBLIC_STYLE_ICON_COLOR || "text-purple-500"
177
- },
178
- showBanner: process.env.NEXT_PUBLIC_STYLE_SHOW_BANNER === "true",
179
- clerkAuthInModal: process.env.NEXT_PUBLIC_STYLE_CLERK_AUTH_IN_MODAL === "true",
180
- clerkPageBanner: process.env.NEXT_PUBLIC_STYLE_CLERK_PAGE_BANNER === "true",
181
- watermark: {
182
- enabled: process.env.NEXT_PUBLIC_STYLE_WATERMARK_ENABLED === "true",
183
- text: process.env.NEXT_PUBLIC_STYLE_WATERMARK_TEXT || "\u5DFD\u5DDD\xB7\u6000\u56E0"
184
- },
185
- cdnBaseUrl: process.env.NEXT_PUBLIC_STYLE_CDN_BASE_URL || "https://r2.d8ger.com",
186
- cdnProxyUrl: process.env.NEXT_PUBLIC_STYLE_CDN_PROXY_URL || "https://r2-explorer-template.zcy777et.workers.dev/proxy",
187
- placeHolder: {
188
- image: process.env.NEXT_PUBLIC_STYLE_PLACEHOLDER_IMAGE || "/default.webp"
189
- }
190
- },
191
- // Clerk configuration
192
- clerk: {
193
- signInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_URL || "/sign-in",
194
- fallbackSignInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL || "/",
195
- signUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_URL || "/sign-up",
196
- fallbackSignUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL || "/",
197
- waitlistUrl: process.env.NEXT_PUBLIC_CLERK_WAITLIST_URL || "/waitlist",
198
- debug: process.env.CLERK_DEBUG === "true"
199
- },
200
- // MDX source file directory configuration
201
- mdxSourceDir: {
202
- docs: process.env.NEXT_PUBLIC_MDX_DOCS_DIR || "src/mdx/docs",
203
- blog: process.env.NEXT_PUBLIC_MDX_BLOG_DIR || "src/mdx/blog",
204
- legal: process.env.NEXT_PUBLIC_MDX_LEGAL_DIR || "src/mdx/legal"
205
- }
206
- };
207
- const shortcuts = {
208
- iconColor: config.style.icon.uniformColor,
209
- watermark: config.style.watermark,
210
- showBanner: config.style.showBanner,
211
- clerkPageBanner: config.style.clerkPageBanner,
212
- clerkAuthInModal: config.style.clerkAuthInModal,
213
- placeHolderImage: config.style.placeHolder.image,
214
- clerk: config.clerk
215
- };
216
- return __spreadProps(__spreadValues({}, config), {
217
- shortcuts
218
- });
219
- }
220
- function createI18nHelpers(i18nConfig) {
221
- function isSupportedLocale(locale) {
222
- return i18nConfig.locales.includes(locale);
223
- }
224
- function getValidLocale(locale) {
225
- return isSupportedLocale(locale) ? locale : i18nConfig.defaultLocale;
226
- }
227
- const generatedLocales = i18nConfig.locales.map((loc) => ({
228
- name: i18nConfig.localeLabels[loc] || loc,
229
- locale: loc
230
- }));
231
- return {
232
- isSupportedLocale,
233
- getValidLocale,
234
- generatedLocales
235
- };
236
- }
237
- var LOCALE_PRESETS = {
238
- // Only support English
239
- EN_ONLY: { locales: ["en"], defaultLocale: "en" },
240
- // English and Chinese
241
- EN_ZH: { locales: ["en", "zh"], defaultLocale: "en" },
242
- // Main Asian languages
243
- ASIA: { locales: ["en", "zh", "ja", "ko"], defaultLocale: "en" },
244
- // Main European languages
245
- EUROPE: { locales: ["en", "fr", "de", "es", "it"], defaultLocale: "en" },
246
- // Globalization
247
- GLOBAL: { locales: ["en", "zh", "ja", "ko", "fr", "de", "es", "it", "pt", "ru"], defaultLocale: "en" },
248
- // No internationalization (only default language)
249
- NONE: { locales: [], defaultLocale: "en" }
250
- };
251
-
252
- export { LOCALE_PRESETS, cn, createCommonAppConfig, createI18nHelpers, formatTimestamp, getLLMText, handlePastePlainText };
253
- //# sourceMappingURL=index.mjs.map
254
- //# sourceMappingURL=index.mjs.map
1
+ export { cn, formatTimestamp, handlePastePlainText } from './utils.mjs';
2
+ export { getLLMText } from './llm-utils.mjs';
3
+ export { LOCALE_PRESETS, createCommonAppConfig, createI18nHelpers } from './common-app-config.mjs';
@@ -1,3 +1,2 @@
1
- declare function getLLMText(mdxContent: string, title?: string, description?: string): Promise<string>;
2
-
3
- export { getLLMText };
1
+ export declare function getLLMText(mdxContent: string, title?: string, description?: string): Promise<string>;
2
+ //# sourceMappingURL=llm-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-utils.d.ts","sourceRoot":"","sources":["../src/llm-utils.ts"],"names":[],"mappings":"AA4BA,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,mBAqBxF"}
package/dist/llm-utils.js CHANGED
@@ -1,73 +1,53 @@
1
1
  'use strict';
2
2
 
3
+ var tslib_es6 = require('./node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.2/node_modules/tslib/tslib.es6.js');
3
4
  var remark = require('remark');
4
5
  var remarkGfm = require('remark-gfm');
5
6
  var remarkMdx = require('remark-mdx');
6
7
  var remarkFrontmatter = require('remark-frontmatter');
7
8
  var unistUtilVisit = require('unist-util-visit');
8
9
 
9
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
-
11
- var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
12
- var remarkMdx__default = /*#__PURE__*/_interopDefault(remarkMdx);
13
- var remarkFrontmatter__default = /*#__PURE__*/_interopDefault(remarkFrontmatter);
14
-
15
- var __async = (__this, __arguments, generator) => {
16
- return new Promise((resolve, reject) => {
17
- var fulfilled = (value) => {
18
- try {
19
- step(generator.next(value));
20
- } catch (e) {
21
- reject(e);
22
- }
23
- };
24
- var rejected = (value) => {
25
- try {
26
- step(generator.throw(value));
27
- } catch (e) {
28
- reject(e);
29
- }
30
- };
31
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
32
- step((generator = generator.apply(__this, __arguments)).next());
33
- });
34
- };
35
10
  function remarkRemoveFrontmatter() {
36
- return (tree) => {
37
- unistUtilVisit.visit(tree, "yaml", (_node, index, parent) => {
38
- if (parent && typeof index === "number") {
39
- parent.children.splice(index, 1);
40
- }
41
- });
42
- };
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ return (tree) => {
13
+ unistUtilVisit.visit(tree, 'yaml', (_node, index, parent) => {
14
+ if (parent && typeof index === 'number') {
15
+ parent.children.splice(index, 1);
16
+ }
17
+ });
18
+ };
43
19
  }
44
- var processor = remark.remark().use(remarkFrontmatter__default.default, ["yaml"]).use(remarkRemoveFrontmatter).use(remarkMdx__default.default).use(remarkGfm__default.default);
20
+ // remark(), parse the MDX file into MDAST
21
+ // remarkPlugins(), parse the MDAST into HAST
22
+ // rehypePlugins(), render the HAST into React components, i.e. HTML code
23
+ const processor = remark.remark()
24
+ // parse the md file header
25
+ .use(remarkFrontmatter, ['yaml'])
26
+ // remove the md file header
27
+ .use(remarkRemoveFrontmatter)
28
+ .use(remarkMdx)
29
+ .use(remarkGfm);
45
30
  function getLLMText(mdxContent, title, description) {
46
- return __async(this, null, function* () {
47
- if (typeof mdxContent !== "string") {
48
- console.error("getLLMText: mdxContent received was not a string. Type:", typeof mdxContent);
49
- return `# Error
50
-
51
- Invalid content received by text processor.`;
52
- }
53
- try {
54
- const processed = yield processor.process(mdxContent);
55
- const contentWithoutFrontmatter = processed.value;
56
- const markdownParts = [
57
- title ? `# ${title}` : null,
58
- description,
59
- contentWithoutFrontmatter.trim()
60
- ];
61
- return markdownParts.filter((part) => part != null).join("\n\n");
62
- } catch (processingError) {
63
- console.error("Error during remark processing in getLLMText:", processingError);
64
- return `# Error
65
-
66
- Error processing MDX content.`;
67
- }
68
- });
31
+ return tslib_es6.__awaiter(this, void 0, void 0, function* () {
32
+ if (typeof mdxContent !== 'string') {
33
+ console.error('getLLMText: mdxContent received was not a string. Type:', typeof mdxContent);
34
+ return `# Error\n\nInvalid content received by text processor.`;
35
+ }
36
+ try {
37
+ const processed = yield processor.process(mdxContent);
38
+ const contentWithoutFrontmatter = processed.value;
39
+ const markdownParts = [
40
+ title ? `# ${title}` : null,
41
+ description,
42
+ contentWithoutFrontmatter.trim()
43
+ ];
44
+ return markdownParts.filter(part => part != null).join('\n\n');
45
+ }
46
+ catch (processingError) {
47
+ console.error('Error during remark processing in getLLMText:', processingError);
48
+ return `# Error\n\nError processing MDX content.`;
49
+ }
50
+ });
69
51
  }
70
52
 
71
53
  exports.getLLMText = getLLMText;
72
- //# sourceMappingURL=llm-utils.js.map
73
- //# sourceMappingURL=llm-utils.js.map