@windrun-huaiin/lib 7.0.0 → 7.1.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.
@@ -0,0 +1,127 @@
1
+ declare const ALL_LOCALE_LABELS: {
2
+ readonly en: "English";
3
+ readonly zh: "简体中文";
4
+ readonly ja: "日本語";
5
+ readonly ko: "한국어";
6
+ readonly fr: "Français";
7
+ readonly de: "Deutsch";
8
+ readonly es: "Español";
9
+ readonly it: "Italiano";
10
+ readonly pt: "Português";
11
+ readonly tr: "Türkçe";
12
+ readonly pl: "Polski";
13
+ readonly ru: "Русский";
14
+ readonly ar: "العربية";
15
+ readonly hi: "हिन्दी";
16
+ readonly th: "ไทย";
17
+ readonly vi: "Tiếng Việt";
18
+ };
19
+ export type SupportedLocale = keyof typeof ALL_LOCALE_LABELS;
20
+ export declare function createCommonAppConfig(options?: {
21
+ locales?: string[];
22
+ defaultLocale?: string;
23
+ }): {
24
+ shortcuts: {
25
+ iconColor: string;
26
+ watermark: {
27
+ enabled: boolean;
28
+ text: string;
29
+ };
30
+ showBanner: boolean;
31
+ clerkPageBanner: boolean;
32
+ clerkAuthInModal: boolean;
33
+ placeHolderImage: string;
34
+ clerk: {
35
+ signInUrl: string;
36
+ fallbackSignInUrl: string;
37
+ signUpUrl: string;
38
+ fallbackSignUpUrl: string;
39
+ waitlistUrl: string;
40
+ debug: boolean;
41
+ };
42
+ };
43
+ baseUrl: string;
44
+ githubBaseUrl: string;
45
+ github: string;
46
+ githubInfoToken: string;
47
+ i18n: {
48
+ locales: readonly string[];
49
+ defaultLocale: string;
50
+ localeLabels: {
51
+ [k: string]: "English" | "简体中文" | "日本語" | "한국어" | "Français" | "Deutsch" | "Español" | "Italiano" | "Português" | "Türkçe" | "Polski" | "Русский" | "العربية" | "हिन्दी" | "ไทย" | "Tiếng Việt";
52
+ };
53
+ detector: {
54
+ storageKey: string;
55
+ autoCloseTimeout: number;
56
+ expirationDays: number;
57
+ storagePrefix: string;
58
+ };
59
+ messageRoot: string;
60
+ };
61
+ style: {
62
+ icon: {
63
+ uniformColor: string;
64
+ };
65
+ showBanner: boolean;
66
+ clerkAuthInModal: boolean;
67
+ clerkPageBanner: boolean;
68
+ watermark: {
69
+ enabled: boolean;
70
+ text: string;
71
+ };
72
+ cdnBaseUrl: string;
73
+ cdnProxyUrl: string;
74
+ placeHolder: {
75
+ image: string;
76
+ };
77
+ };
78
+ clerk: {
79
+ signInUrl: string;
80
+ fallbackSignInUrl: string;
81
+ signUpUrl: string;
82
+ fallbackSignUpUrl: string;
83
+ waitlistUrl: string;
84
+ debug: boolean;
85
+ };
86
+ mdxSourceDir: {
87
+ docs: string;
88
+ blog: string;
89
+ legal: string;
90
+ };
91
+ };
92
+ export declare function createI18nHelpers(i18nConfig: ReturnType<typeof createCommonAppConfig>['i18n']): {
93
+ isSupportedLocale: (locale: string) => locale is (typeof i18nConfig.locales)[number];
94
+ getValidLocale: (locale: string) => (typeof i18nConfig.locales)[number];
95
+ generatedLocales: {
96
+ name: "English" | "简体中文" | "日本語" | "한국어" | "Français" | "Deutsch" | "Español" | "Italiano" | "Português" | "Türkçe" | "Polski" | "Русский" | "العربية" | "हिन्दी" | "ไทย" | "Tiếng Việt";
97
+ locale: string;
98
+ }[];
99
+ };
100
+ export declare const LOCALE_PRESETS: {
101
+ EN_ONLY: {
102
+ locales: string[];
103
+ defaultLocale: string;
104
+ };
105
+ EN_ZH: {
106
+ locales: string[];
107
+ defaultLocale: string;
108
+ };
109
+ ASIA: {
110
+ locales: string[];
111
+ defaultLocale: string;
112
+ };
113
+ EUROPE: {
114
+ locales: string[];
115
+ defaultLocale: string;
116
+ };
117
+ GLOBAL: {
118
+ locales: string[];
119
+ defaultLocale: string;
120
+ };
121
+ NONE: {
122
+ locales: string[];
123
+ defaultLocale: string;
124
+ };
125
+ };
126
+ export {};
127
+ //# sourceMappingURL=common-app-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common-app-config.d.ts","sourceRoot":"","sources":["../src/common-app-config.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;CAiBb,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAa7D,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE;IAE9C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;;;;;;;;;;;;;;;;;;;;;;;;;iBAqByB,SAAS,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgE1C;AAGD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC;gCACzD,MAAM,KAAG,MAAM,IAAI,CAAA,OAAO,UAAU,CAAC,OAAO,EAAC,MAAM,CAAC;6BAIvD,MAAM,KAAG,CAAA,OAAO,UAAU,CAAC,OAAO,EAAC,MAAM,CAAC;;;;;EAc3E;AAGD,eAAO,MAAM,cAAc;;iBAEK,MAAM,EAAE;uBAAyB,MAAM;;;iBAGnC,MAAM,EAAE;uBAAyB,MAAM;;;iBAG5B,MAAM,EAAE;uBAAyB,MAAM;;;iBAG/B,MAAM,EAAE;uBAAyB,MAAM;;;iBAGT,MAAM,EAAE;uBAAyB,MAAM;;;iBAGnG,MAAM,EAAE;uBAAyB,MAAM;;CAC/D,CAAC"}
@@ -0,0 +1,137 @@
1
+ 'use strict';
2
+
3
+ // Supported languages and their labels
4
+ const ALL_LOCALE_LABELS = {
5
+ en: "English",
6
+ zh: "简体中文",
7
+ ja: "日本語",
8
+ ko: "한국어",
9
+ fr: "Français",
10
+ de: "Deutsch",
11
+ es: "Español",
12
+ it: "Italiano",
13
+ pt: "Português",
14
+ tr: "Türkçe",
15
+ pl: "Polski",
16
+ ru: "Русский",
17
+ ar: "العربية",
18
+ hi: "हिन्दी",
19
+ th: "ไทย",
20
+ vi: "Tiếng Việt",
21
+ };
22
+ // Helper function to get language configuration from environment variables
23
+ function getLocaleLabels(locales) {
24
+ return Object.fromEntries(locales.map(locale => [
25
+ locale,
26
+ ALL_LOCALE_LABELS[locale] || locale
27
+ ]));
28
+ }
29
+ // Common application configuration creation function
30
+ function createCommonAppConfig(options) {
31
+ var _a, _b, _c, _d, _e;
32
+ // Priority: manual configuration > environment variables > default values
33
+ const locales = (_c = (_a = options === null || options === void 0 ? void 0 : options.locales) !== null && _a !== void 0 ? _a : (_b = process.env.NEXT_PUBLIC_I18N_LOCALES) === null || _b === void 0 ? void 0 : _b.split(',').map(s => s.trim())) !== null && _c !== void 0 ? _c : ['en', 'zh'];
34
+ const defaultLocale = (_e = (_d = options === null || options === void 0 ? void 0 : options.defaultLocale) !== null && _d !== void 0 ? _d : process.env.NEXT_PUBLIC_I18N_DEFAULT_LOCALE) !== null && _e !== void 0 ? _e : 'en';
35
+ const storagePrefix = process.env.NEXT_PUBLIC_I18N_STORAGE_PREFIX || 'WINDRUN-HUAIIN';
36
+ const config = {
37
+ // Basic configuration
38
+ baseUrl: process.env.NEXT_PUBLIC_BASE_URL || '',
39
+ githubBaseUrl: process.env.NEXT_PUBLIC_GITHUB_BASE_URL || '',
40
+ github: process.env.NEXT_PUBLIC_GITHUB || '',
41
+ githubInfoToken: process.env.NEXT_PUBLIC_FUMA_GITHUB_TOKEN || '',
42
+ // Internationalization configuration
43
+ i18n: {
44
+ locales: locales,
45
+ defaultLocale,
46
+ localeLabels: getLocaleLabels(locales),
47
+ detector: {
48
+ storageKey: process.env.NEXT_PUBLIC_I18N_STORAGE_KEY || 'language-preference-status',
49
+ autoCloseTimeout: parseInt(process.env.NEXT_PUBLIC_I18N_AUTO_CLOSE_TIMEOUT || '10000'),
50
+ expirationDays: parseInt(process.env.NEXT_PUBLIC_I18N_EXPIRATION_DAYS || '30'),
51
+ storagePrefix
52
+ },
53
+ messageRoot: process.env.NEXT_PUBLIC_I18N_MESSAGE_ROOT || 'messages',
54
+ },
55
+ // Style configuration
56
+ style: {
57
+ icon: {
58
+ uniformColor: process.env.NEXT_PUBLIC_STYLE_ICON_COLOR || "text-purple-500"
59
+ },
60
+ showBanner: process.env.NEXT_PUBLIC_STYLE_SHOW_BANNER === 'true',
61
+ clerkAuthInModal: process.env.NEXT_PUBLIC_STYLE_CLERK_AUTH_IN_MODAL === 'true',
62
+ clerkPageBanner: process.env.NEXT_PUBLIC_STYLE_CLERK_PAGE_BANNER === 'true',
63
+ watermark: {
64
+ enabled: process.env.NEXT_PUBLIC_STYLE_WATERMARK_ENABLED === 'true',
65
+ text: process.env.NEXT_PUBLIC_STYLE_WATERMARK_TEXT || "巽川·怀因"
66
+ },
67
+ cdnBaseUrl: process.env.NEXT_PUBLIC_STYLE_CDN_BASE_URL || "https://r2.d8ger.com",
68
+ cdnProxyUrl: process.env.NEXT_PUBLIC_STYLE_CDN_PROXY_URL || "https://r2-explorer-template.zcy777et.workers.dev/proxy",
69
+ placeHolder: {
70
+ image: process.env.NEXT_PUBLIC_STYLE_PLACEHOLDER_IMAGE || "/default.webp"
71
+ }
72
+ },
73
+ // Clerk configuration
74
+ clerk: {
75
+ signInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_URL || "/sign-in",
76
+ fallbackSignInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL || "/",
77
+ signUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_URL || "/sign-up",
78
+ fallbackSignUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL || "/",
79
+ waitlistUrl: process.env.NEXT_PUBLIC_CLERK_WAITLIST_URL || "/waitlist",
80
+ debug: process.env.CLERK_DEBUG === 'true',
81
+ },
82
+ // MDX source file directory configuration
83
+ mdxSourceDir: {
84
+ docs: process.env.NEXT_PUBLIC_MDX_DOCS_DIR || "src/mdx/docs",
85
+ blog: process.env.NEXT_PUBLIC_MDX_BLOG_DIR || "src/mdx/blog",
86
+ legal: process.env.NEXT_PUBLIC_MDX_LEGAL_DIR || "src/mdx/legal"
87
+ },
88
+ };
89
+ // Convenient constants - avoid deep nested access
90
+ const shortcuts = {
91
+ iconColor: config.style.icon.uniformColor,
92
+ watermark: config.style.watermark,
93
+ showBanner: config.style.showBanner,
94
+ clerkPageBanner: config.style.clerkPageBanner,
95
+ clerkAuthInModal: config.style.clerkAuthInModal,
96
+ placeHolderImage: config.style.placeHolder.image,
97
+ clerk: config.clerk,
98
+ };
99
+ return Object.assign(Object.assign({}, config), { shortcuts });
100
+ }
101
+ // Create internationalization helper functions
102
+ function createI18nHelpers(i18nConfig) {
103
+ function isSupportedLocale(locale) {
104
+ return i18nConfig.locales.includes(locale);
105
+ }
106
+ function getValidLocale(locale) {
107
+ return isSupportedLocale(locale) ? locale : i18nConfig.defaultLocale;
108
+ }
109
+ const generatedLocales = i18nConfig.locales.map((loc) => ({
110
+ name: i18nConfig.localeLabels[loc] || loc,
111
+ locale: loc,
112
+ }));
113
+ return {
114
+ isSupportedLocale,
115
+ getValidLocale,
116
+ generatedLocales
117
+ };
118
+ }
119
+ // Convenient configuration presets
120
+ const LOCALE_PRESETS = {
121
+ // Only support English
122
+ EN_ONLY: { locales: ['en'], defaultLocale: 'en' },
123
+ // English and Chinese
124
+ EN_ZH: { locales: ['en', 'zh'], defaultLocale: 'en' },
125
+ // Main Asian languages
126
+ ASIA: { locales: ['en', 'zh', 'ja', 'ko'], defaultLocale: 'en' },
127
+ // Main European languages
128
+ EUROPE: { locales: ['en', 'fr', 'de', 'es', 'it'], defaultLocale: 'en' },
129
+ // Globalization
130
+ GLOBAL: { locales: ['en', 'zh', 'ja', 'ko', 'fr', 'de', 'es', 'it', 'pt', 'ru'], defaultLocale: 'en' },
131
+ // No internationalization (only default language)
132
+ NONE: { locales: [], defaultLocale: 'en' }
133
+ };
134
+
135
+ exports.LOCALE_PRESETS = LOCALE_PRESETS;
136
+ exports.createCommonAppConfig = createCommonAppConfig;
137
+ exports.createI18nHelpers = createI18nHelpers;
@@ -0,0 +1,133 @@
1
+ // Supported languages and their labels
2
+ const ALL_LOCALE_LABELS = {
3
+ en: "English",
4
+ zh: "简体中文",
5
+ ja: "日本語",
6
+ ko: "한국어",
7
+ fr: "Français",
8
+ de: "Deutsch",
9
+ es: "Español",
10
+ it: "Italiano",
11
+ pt: "Português",
12
+ tr: "Türkçe",
13
+ pl: "Polski",
14
+ ru: "Русский",
15
+ ar: "العربية",
16
+ hi: "हिन्दी",
17
+ th: "ไทย",
18
+ vi: "Tiếng Việt",
19
+ };
20
+ // Helper function to get language configuration from environment variables
21
+ function getLocaleLabels(locales) {
22
+ return Object.fromEntries(locales.map(locale => [
23
+ locale,
24
+ ALL_LOCALE_LABELS[locale] || locale
25
+ ]));
26
+ }
27
+ // Common application configuration creation function
28
+ function createCommonAppConfig(options) {
29
+ var _a, _b, _c, _d, _e;
30
+ // Priority: manual configuration > environment variables > default values
31
+ const locales = (_c = (_a = options === null || options === void 0 ? void 0 : options.locales) !== null && _a !== void 0 ? _a : (_b = process.env.NEXT_PUBLIC_I18N_LOCALES) === null || _b === void 0 ? void 0 : _b.split(',').map(s => s.trim())) !== null && _c !== void 0 ? _c : ['en', 'zh'];
32
+ const defaultLocale = (_e = (_d = options === null || options === void 0 ? void 0 : options.defaultLocale) !== null && _d !== void 0 ? _d : process.env.NEXT_PUBLIC_I18N_DEFAULT_LOCALE) !== null && _e !== void 0 ? _e : 'en';
33
+ const storagePrefix = process.env.NEXT_PUBLIC_I18N_STORAGE_PREFIX || 'WINDRUN-HUAIIN';
34
+ const config = {
35
+ // Basic configuration
36
+ baseUrl: process.env.NEXT_PUBLIC_BASE_URL || '',
37
+ githubBaseUrl: process.env.NEXT_PUBLIC_GITHUB_BASE_URL || '',
38
+ github: process.env.NEXT_PUBLIC_GITHUB || '',
39
+ githubInfoToken: process.env.NEXT_PUBLIC_FUMA_GITHUB_TOKEN || '',
40
+ // Internationalization configuration
41
+ i18n: {
42
+ locales: locales,
43
+ defaultLocale,
44
+ localeLabels: getLocaleLabels(locales),
45
+ detector: {
46
+ storageKey: process.env.NEXT_PUBLIC_I18N_STORAGE_KEY || 'language-preference-status',
47
+ autoCloseTimeout: parseInt(process.env.NEXT_PUBLIC_I18N_AUTO_CLOSE_TIMEOUT || '10000'),
48
+ expirationDays: parseInt(process.env.NEXT_PUBLIC_I18N_EXPIRATION_DAYS || '30'),
49
+ storagePrefix
50
+ },
51
+ messageRoot: process.env.NEXT_PUBLIC_I18N_MESSAGE_ROOT || 'messages',
52
+ },
53
+ // Style configuration
54
+ style: {
55
+ icon: {
56
+ uniformColor: process.env.NEXT_PUBLIC_STYLE_ICON_COLOR || "text-purple-500"
57
+ },
58
+ showBanner: process.env.NEXT_PUBLIC_STYLE_SHOW_BANNER === 'true',
59
+ clerkAuthInModal: process.env.NEXT_PUBLIC_STYLE_CLERK_AUTH_IN_MODAL === 'true',
60
+ clerkPageBanner: process.env.NEXT_PUBLIC_STYLE_CLERK_PAGE_BANNER === 'true',
61
+ watermark: {
62
+ enabled: process.env.NEXT_PUBLIC_STYLE_WATERMARK_ENABLED === 'true',
63
+ text: process.env.NEXT_PUBLIC_STYLE_WATERMARK_TEXT || "巽川·怀因"
64
+ },
65
+ cdnBaseUrl: process.env.NEXT_PUBLIC_STYLE_CDN_BASE_URL || "https://r2.d8ger.com",
66
+ cdnProxyUrl: process.env.NEXT_PUBLIC_STYLE_CDN_PROXY_URL || "https://r2-explorer-template.zcy777et.workers.dev/proxy",
67
+ placeHolder: {
68
+ image: process.env.NEXT_PUBLIC_STYLE_PLACEHOLDER_IMAGE || "/default.webp"
69
+ }
70
+ },
71
+ // Clerk configuration
72
+ clerk: {
73
+ signInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_URL || "/sign-in",
74
+ fallbackSignInUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL || "/",
75
+ signUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_URL || "/sign-up",
76
+ fallbackSignUpUrl: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL || "/",
77
+ waitlistUrl: process.env.NEXT_PUBLIC_CLERK_WAITLIST_URL || "/waitlist",
78
+ debug: process.env.CLERK_DEBUG === 'true',
79
+ },
80
+ // MDX source file directory configuration
81
+ mdxSourceDir: {
82
+ docs: process.env.NEXT_PUBLIC_MDX_DOCS_DIR || "src/mdx/docs",
83
+ blog: process.env.NEXT_PUBLIC_MDX_BLOG_DIR || "src/mdx/blog",
84
+ legal: process.env.NEXT_PUBLIC_MDX_LEGAL_DIR || "src/mdx/legal"
85
+ },
86
+ };
87
+ // Convenient constants - avoid deep nested access
88
+ const shortcuts = {
89
+ iconColor: config.style.icon.uniformColor,
90
+ watermark: config.style.watermark,
91
+ showBanner: config.style.showBanner,
92
+ clerkPageBanner: config.style.clerkPageBanner,
93
+ clerkAuthInModal: config.style.clerkAuthInModal,
94
+ placeHolderImage: config.style.placeHolder.image,
95
+ clerk: config.clerk,
96
+ };
97
+ return Object.assign(Object.assign({}, config), { shortcuts });
98
+ }
99
+ // Create internationalization helper functions
100
+ function createI18nHelpers(i18nConfig) {
101
+ function isSupportedLocale(locale) {
102
+ return i18nConfig.locales.includes(locale);
103
+ }
104
+ function getValidLocale(locale) {
105
+ return isSupportedLocale(locale) ? locale : i18nConfig.defaultLocale;
106
+ }
107
+ const generatedLocales = i18nConfig.locales.map((loc) => ({
108
+ name: i18nConfig.localeLabels[loc] || loc,
109
+ locale: loc,
110
+ }));
111
+ return {
112
+ isSupportedLocale,
113
+ getValidLocale,
114
+ generatedLocales
115
+ };
116
+ }
117
+ // Convenient configuration presets
118
+ const LOCALE_PRESETS = {
119
+ // Only support English
120
+ EN_ONLY: { locales: ['en'], defaultLocale: 'en' },
121
+ // English and Chinese
122
+ EN_ZH: { locales: ['en', 'zh'], defaultLocale: 'en' },
123
+ // Main Asian languages
124
+ ASIA: { locales: ['en', 'zh', 'ja', 'ko'], defaultLocale: 'en' },
125
+ // Main European languages
126
+ EUROPE: { locales: ['en', 'fr', 'de', 'es', 'it'], defaultLocale: 'en' },
127
+ // Globalization
128
+ GLOBAL: { locales: ['en', 'zh', 'ja', 'ko', 'fr', 'de', 'es', 'it', 'pt', 'ru'], defaultLocale: 'en' },
129
+ // No internationalization (only default language)
130
+ NONE: { locales: [], defaultLocale: 'en' }
131
+ };
132
+
133
+ export { LOCALE_PRESETS, createCommonAppConfig, createI18nHelpers };
@@ -0,0 +1,4 @@
1
+ export * from './utils';
2
+ export * from './llm-utils';
3
+ export * from './common-app-config';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AAGxB,cAAc,aAAa,CAAC;AAG5B,cAAc,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var utils = require('./utils.js');
4
+ var llmUtils = require('./llm-utils.js');
5
+ var commonAppConfig = require('./common-app-config.js');
6
+
7
+
8
+
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 ADDED
@@ -0,0 +1,3 @@
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';
@@ -0,0 +1,2 @@
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"}
@@ -0,0 +1,53 @@
1
+ 'use strict';
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');
4
+ var remark = require('remark');
5
+ var remarkGfm = require('remark-gfm');
6
+ var remarkMdx = require('remark-mdx');
7
+ var remarkFrontmatter = require('remark-frontmatter');
8
+ var unistUtilVisit = require('unist-util-visit');
9
+
10
+ function remarkRemoveFrontmatter() {
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
+ };
19
+ }
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);
30
+ function getLLMText(mdxContent, title, description) {
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
+ });
51
+ }
52
+
53
+ exports.getLLMText = getLLMText;
@@ -0,0 +1,51 @@
1
+ import { __awaiter } from './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.mjs';
2
+ import { remark } from 'remark';
3
+ import remarkGfm from 'remark-gfm';
4
+ import remarkMdx from 'remark-mdx';
5
+ import remarkFrontmatter from 'remark-frontmatter';
6
+ import { visit } from 'unist-util-visit';
7
+
8
+ function remarkRemoveFrontmatter() {
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ return (tree) => {
11
+ visit(tree, 'yaml', (_node, index, parent) => {
12
+ if (parent && typeof index === 'number') {
13
+ parent.children.splice(index, 1);
14
+ }
15
+ });
16
+ };
17
+ }
18
+ // remark(), parse the MDX file into MDAST
19
+ // remarkPlugins(), parse the MDAST into HAST
20
+ // rehypePlugins(), render the HAST into React components, i.e. HTML code
21
+ const processor = remark()
22
+ // parse the md file header
23
+ .use(remarkFrontmatter, ['yaml'])
24
+ // remove the md file header
25
+ .use(remarkRemoveFrontmatter)
26
+ .use(remarkMdx)
27
+ .use(remarkGfm);
28
+ function getLLMText(mdxContent, title, description) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ if (typeof mdxContent !== 'string') {
31
+ console.error('getLLMText: mdxContent received was not a string. Type:', typeof mdxContent);
32
+ return `# Error\n\nInvalid content received by text processor.`;
33
+ }
34
+ try {
35
+ const processed = yield processor.process(mdxContent);
36
+ const contentWithoutFrontmatter = processed.value;
37
+ const markdownParts = [
38
+ title ? `# ${title}` : null,
39
+ description,
40
+ contentWithoutFrontmatter.trim()
41
+ ];
42
+ return markdownParts.filter(part => part != null).join('\n\n');
43
+ }
44
+ catch (processingError) {
45
+ console.error('Error during remark processing in getLLMText:', processingError);
46
+ return `# Error\n\nError processing MDX content.`;
47
+ }
48
+ });
49
+ }
50
+
51
+ export { getLLMText };
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ /******************************************************************************
4
+ Copyright (c) Microsoft Corporation.
5
+
6
+ Permission to use, copy, modify, and/or distribute this software for any
7
+ purpose with or without fee is hereby granted.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
16
+ ***************************************************************************** */
17
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
18
+
19
+
20
+ function __awaiter(thisArg, _arguments, P, generator) {
21
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
22
+ return new (P || (P = Promise))(function (resolve, reject) {
23
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
25
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
26
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
27
+ });
28
+ }
29
+
30
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
31
+ var e = new Error(message);
32
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
33
+ };
34
+
35
+ exports.__awaiter = __awaiter;
@@ -0,0 +1,33 @@
1
+ /******************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */
15
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
16
+
17
+
18
+ function __awaiter(thisArg, _arguments, P, generator) {
19
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
20
+ return new (P || (P = Promise))(function (resolve, reject) {
21
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
24
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
25
+ });
26
+ }
27
+
28
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
29
+ var e = new Error(message);
30
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
31
+ };
32
+
33
+ export { __awaiter };
@@ -0,0 +1,6 @@
1
+ import type * as React from "react";
2
+ import { type ClassValue } from "clsx";
3
+ export declare function cn(...inputs: ClassValue[]): string;
4
+ export declare function formatTimestamp(timestamp: string, formatter: string): string;
5
+ export declare function handlePastePlainText(e: React.ClipboardEvent<HTMLElement>): void;
6
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAI5C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UA4BnE;AAGD,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,QAgBxE"}
package/dist/utils.js ADDED
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ var clsx = require('clsx');
4
+ var tailwindMerge = require('tailwind-merge');
5
+ var dateFns = require('date-fns');
6
+
7
+ function cn(...inputs) {
8
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
9
+ }
10
+ function formatTimestamp(timestamp, formatter) {
11
+ const fail = "";
12
+ if (!timestamp) {
13
+ return fail;
14
+ }
15
+ // Assume gitTimestamp is a millisecond timestamp string
16
+ const timestampMs = parseInt(timestamp, 10);
17
+ if (isNaN(timestampMs)) {
18
+ return fail;
19
+ }
20
+ const date = new Date(timestampMs); // or if it is determined to be seconds, use fromUnixTime(timestampSeconds)
21
+ // Check if the date is valid
22
+ if (!dateFns.isValid(date)) {
23
+ return fail;
24
+ }
25
+ // Format the date
26
+ try {
27
+ // 'yyyy-MM-dd HH:mm:ss' is the date-fns formatting pattern
28
+ return dateFns.format(date, formatter);
29
+ }
30
+ catch (error) {
31
+ // format may also throw an error due to an invalid date (although isValid should have already caught it)
32
+ console.error("Error formatting date:", error);
33
+ return fail;
34
+ }
35
+ }
36
+ // Only allow pasting plain text, prohibit style content
37
+ function handlePastePlainText(e) {
38
+ e.preventDefault();
39
+ const text = e.clipboardData.getData('text/plain');
40
+ const selection = window.getSelection();
41
+ if (!selection || !selection.rangeCount)
42
+ return;
43
+ // Delete the current selected content
44
+ selection.deleteFromDocument();
45
+ // Insert plain text
46
+ const textNode = document.createTextNode(text);
47
+ const range = selection.getRangeAt(0);
48
+ range.insertNode(textNode);
49
+ // Move the cursor to the inserted text
50
+ range.setStartAfter(textNode);
51
+ range.collapse(true);
52
+ selection.removeAllRanges();
53
+ selection.addRange(range);
54
+ }
55
+
56
+ exports.cn = cn;
57
+ exports.formatTimestamp = formatTimestamp;
58
+ exports.handlePastePlainText = handlePastePlainText;
package/dist/utils.mjs ADDED
@@ -0,0 +1,54 @@
1
+ import { clsx } from 'clsx';
2
+ import { twMerge } from 'tailwind-merge';
3
+ import { isValid, format } from 'date-fns';
4
+
5
+ function cn(...inputs) {
6
+ return twMerge(clsx(inputs));
7
+ }
8
+ function formatTimestamp(timestamp, formatter) {
9
+ const fail = "";
10
+ if (!timestamp) {
11
+ return fail;
12
+ }
13
+ // Assume gitTimestamp is a millisecond timestamp string
14
+ const timestampMs = parseInt(timestamp, 10);
15
+ if (isNaN(timestampMs)) {
16
+ return fail;
17
+ }
18
+ const date = new Date(timestampMs); // or if it is determined to be seconds, use fromUnixTime(timestampSeconds)
19
+ // Check if the date is valid
20
+ if (!isValid(date)) {
21
+ return fail;
22
+ }
23
+ // Format the date
24
+ try {
25
+ // 'yyyy-MM-dd HH:mm:ss' is the date-fns formatting pattern
26
+ return format(date, formatter);
27
+ }
28
+ catch (error) {
29
+ // format may also throw an error due to an invalid date (although isValid should have already caught it)
30
+ console.error("Error formatting date:", error);
31
+ return fail;
32
+ }
33
+ }
34
+ // Only allow pasting plain text, prohibit style content
35
+ function handlePastePlainText(e) {
36
+ e.preventDefault();
37
+ const text = e.clipboardData.getData('text/plain');
38
+ const selection = window.getSelection();
39
+ if (!selection || !selection.rangeCount)
40
+ return;
41
+ // Delete the current selected content
42
+ selection.deleteFromDocument();
43
+ // Insert plain text
44
+ const textNode = document.createTextNode(text);
45
+ const range = selection.getRangeAt(0);
46
+ range.insertNode(textNode);
47
+ // Move the cursor to the inserted text
48
+ range.setStartAfter(textNode);
49
+ range.collapse(true);
50
+ selection.removeAllRanges();
51
+ selection.addRange(range);
52
+ }
53
+
54
+ export { cn, formatTimestamp, handlePastePlainText };
package/package.json CHANGED
@@ -1,12 +1,31 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/lib",
3
- "version": "7.0.0",
3
+ "version": "7.1.1",
4
4
  "description": "Common utilities and configuration",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
5
8
  "exports": {
6
- ".": "./src/index.ts",
7
- "./utils": "./src/utils.ts",
8
- "./llm-utils": "./src/llm-utils.ts",
9
- "./common-app-config": "./src/common-app-config.ts",
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ },
14
+ "./utils": {
15
+ "types": "./dist/utils.d.ts",
16
+ "import": "./dist/utils.mjs",
17
+ "require": "./dist/utils.js"
18
+ },
19
+ "./llm-utils": {
20
+ "types": "./dist/llm-utils.d.ts",
21
+ "import": "./dist/llm-utils.mjs",
22
+ "require": "./dist/llm-utils.js"
23
+ },
24
+ "./common-app-config": {
25
+ "types": "./dist/common-app-config.d.ts",
26
+ "import": "./dist/common-app-config.mjs",
27
+ "require": "./dist/common-app-config.js"
28
+ },
10
29
  "./package.json": "./package.json"
11
30
  },
12
31
  "files": [
@@ -48,10 +67,11 @@
48
67
  "access": "public"
49
68
  },
50
69
  "scripts": {
51
- "build": "echo '📦 No build needed - shipping TypeScript source!' && tsc --noEmit",
70
+ "build": "rollup -c rollup.config.mjs",
71
+ "build:prod": "rollup -c rollup.config.mjs",
72
+ "dev": "rollup -c rollup.config.mjs --watch",
73
+ "clean": "rm -rf dist",
52
74
  "type-check": "tsc --noEmit",
53
- "clean": "echo 'No dist to clean'",
54
- "dev": "tsc --noEmit --watch",
55
75
  "lint": "eslint src"
56
76
  }
57
77
  }