@rspress/shared 0.0.0-next-20231207111357 → 0.0.0-next-20240226105749

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,2 @@
1
+ export * from 'chalk';
2
+ export { default } from 'chalk';
package/dist/chalk.js ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/chalk.ts
32
+ var chalk_exports = {};
33
+ __export(chalk_exports, {
34
+ default: () => import_chalk.default
35
+ });
36
+ module.exports = __toCommonJS(chalk_exports);
37
+ __reExport(chalk_exports, require("chalk"), module.exports);
38
+ var import_chalk = __toESM(require("chalk"));
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ ...require("chalk")
42
+ });
package/dist/chalk.mjs ADDED
@@ -0,0 +1,6 @@
1
+ // src/chalk.ts
2
+ export * from "chalk";
3
+ import { default as default2 } from "chalk";
4
+ export {
5
+ default2 as default
6
+ };
@@ -0,0 +1,2 @@
1
+ export * from 'execa';
2
+ export { default } from 'execa';
package/dist/execa.js ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/execa.ts
32
+ var execa_exports = {};
33
+ __export(execa_exports, {
34
+ default: () => import_execa.default
35
+ });
36
+ module.exports = __toCommonJS(execa_exports);
37
+ __reExport(execa_exports, require("execa"), module.exports);
38
+ var import_execa = __toESM(require("execa"));
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ ...require("execa")
42
+ });
package/dist/execa.mjs ADDED
@@ -0,0 +1,6 @@
1
+ // src/execa.ts
2
+ export * from "execa";
3
+ import { default as default2 } from "execa";
4
+ export {
5
+ default2 as default
6
+ };
@@ -0,0 +1,2 @@
1
+ export * from 'fs-extra';
2
+ export { default } from 'fs-extra';
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/fs-extra.ts
32
+ var fs_extra_exports = {};
33
+ __export(fs_extra_exports, {
34
+ default: () => import_fs_extra.default
35
+ });
36
+ module.exports = __toCommonJS(fs_extra_exports);
37
+ __reExport(fs_extra_exports, require("fs-extra"), module.exports);
38
+ var import_fs_extra = __toESM(require("fs-extra"));
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ ...require("fs-extra")
42
+ });
@@ -0,0 +1,6 @@
1
+ // src/fs-extra.ts
2
+ export * from "fs-extra";
3
+ import { default as default2 } from "fs-extra";
4
+ export {
5
+ default2 as default
6
+ };
package/dist/index.d.ts CHANGED
@@ -111,6 +111,10 @@ interface Config$1 {
111
111
  * The next page text.
112
112
  */
113
113
  nextPageText?: string;
114
+ /**
115
+ * The source code text.
116
+ */
117
+ sourceCodeText?: string;
114
118
  /**
115
119
  * Locale config
116
120
  */
@@ -119,6 +123,10 @@ interface Config$1 {
119
123
  * Whether to open the full text search
120
124
  */
121
125
  search?: boolean;
126
+ /**
127
+ * The placeholder of search input
128
+ */
129
+ searchPlaceholderText?: string;
122
130
  /**
123
131
  * The behavior of hiding navbar
124
132
  */
@@ -127,6 +135,11 @@ interface Config$1 {
127
135
  * Whether to enable the animation for translation pages
128
136
  */
129
137
  enableContentAnimation?: boolean;
138
+ /**
139
+ * Enable scroll to top button on documentation
140
+ * @default false
141
+ */
142
+ enableScrollToTop?: boolean;
130
143
  }
131
144
  /**
132
145
  * locale config
@@ -150,7 +163,9 @@ interface LocaleConfig {
150
163
  editLink?: EditLink;
151
164
  prevPageText?: string;
152
165
  nextPageText?: string;
166
+ sourceCodeText?: string;
153
167
  langRoutePrefix?: string;
168
+ searchPlaceholderText?: string;
154
169
  }
155
170
  type Nav = NavItem[] | {
156
171
  [key: string]: NavItem[];
@@ -191,11 +206,19 @@ interface SidebarGroup {
191
206
  items: (SidebarItem | SidebarDivider | SidebarGroup | string)[];
192
207
  collapsible?: boolean;
193
208
  collapsed?: boolean;
209
+ /**
210
+ * For hmr usage in development
211
+ */
212
+ _fileKey?: string;
194
213
  }
195
214
  type SidebarItem = {
196
215
  text: string;
197
216
  link: string;
198
217
  tag?: string;
218
+ /**
219
+ * For hmr usage in development
220
+ */
221
+ _fileKey?: string;
199
222
  };
200
223
  type SidebarDivider = {
201
224
  dividerType: 'dashed' | 'solid';
@@ -227,7 +250,7 @@ interface SocialLink {
227
250
  mode: 'link' | 'text' | 'img';
228
251
  content: string;
229
252
  }
230
- type SocialLinkIcon = 'lark' | 'discord' | 'facebook' | 'github' | 'instagram' | 'linkedin' | 'slack' | 'twitter' | 'youtube' | 'wechat' | 'qq' | 'juejin' | 'zhihu' | 'bilibili' | 'weibo' | 'gitlab' | {
253
+ type SocialLinkIcon = 'lark' | 'discord' | 'facebook' | 'github' | 'instagram' | 'linkedin' | 'slack' | 'twitter' | 'youtube' | 'wechat' | 'qq' | 'juejin' | 'zhihu' | 'bilibili' | 'weibo' | 'gitlab' | 'X' | {
231
254
  svg: string;
232
255
  };
233
256
  interface Footer {
@@ -616,7 +639,7 @@ interface SearchHooks {
616
639
  searchHooks?: string;
617
640
  }
618
641
  type LocalSearchOptions = SearchHooks & {
619
- mode: 'local';
642
+ mode?: 'local';
620
643
  };
621
644
  type RemoteSearchIndexInfo = string | {
622
645
  value: string;
@@ -630,6 +653,12 @@ type RemoteSearchOptions = SearchHooks & {
630
653
  searchIndexes?: RemoteSearchIndexInfo[];
631
654
  };
632
655
  type SearchOptions = LocalSearchOptions | RemoteSearchOptions | false;
656
+ interface MdxRsOptions {
657
+ /**
658
+ * Determine whether the file use mdxRs compiler
659
+ */
660
+ include?: (filepath: string) => boolean;
661
+ }
633
662
  interface MarkdownOptions {
634
663
  remarkPlugins?: PluggableList;
635
664
  rehypePlugins?: PluggableList;
@@ -657,7 +686,7 @@ interface MarkdownOptions {
657
686
  /**
658
687
  * Whether to enable mdx-rs, default is true
659
688
  */
660
- mdxRs?: boolean;
689
+ mdxRs?: boolean | MdxRsOptions;
661
690
  /**
662
691
  * @deprecated, use `mdxRs` instead
663
692
  */
@@ -694,12 +723,12 @@ declare function replaceLang(rawUrl: string, lang: {
694
723
  }, version: {
695
724
  current: string;
696
725
  default: string;
697
- }, base?: string): string;
726
+ }, base?: string, cleanUrls?: boolean): string;
698
727
  declare function replaceVersion(rawUrl: string, version: {
699
728
  current: string;
700
729
  target: string;
701
730
  default: string;
702
- }, base?: string): string;
731
+ }, base?: string, cleanUrls?: boolean): string;
703
732
  declare const omit: (obj: Record<string, unknown>, keys: string[]) => {
704
733
  [x: string]: unknown;
705
734
  };
@@ -715,4 +744,4 @@ declare function removeBase(url: string, base: string): string;
715
744
  declare function withoutHash(url: string): string;
716
745
  declare const mergeDocConfig: (...configs: UserConfig[]) => UserConfig;
717
746
 
718
- export { APPEARANCE_KEY, AdditionalPage, BaseRuntimePageInfo, Config, DEFAULT_HIGHLIGHT_LANGUAGES, Config$1 as DefaultThemeConfig, DocFooter, EditLink, Feature, Footer, FrontMatterMeta, HASH_REGEXP, Header, Hero, Image, LocalSearchOptions, Locale, LocaleConfig, LocaleLink, LocaleLinks, MDX_REGEXP, MarkdownOptions, Nav, NavItem, NavItemWithChildren, NavItemWithLink, NavItemWithLinkAndChildren, NormalizedConfig, NormalizedConfig as NormalizedDefaultThemeConfig, NormalizedLocales, NormalizedSidebar, NormalizedSidebarGroup, PageData, PageIndexInfo, PageModule, PageType, RspressPlugin as Plugin, QUERY_REGEXP, RSPRESS_TEMP_DIR, RemotePageInfo, RemoteSearchIndexInfo, RemoteSearchOptions, ReplaceRule, Route, RouteMeta, RouteOptions, RspressPlugin, SEARCH_INDEX_NAME, SearchHooks, SearchOptions, Sidebar, SidebarDivider, SidebarGroup, SidebarItem, SiteData, SocialLink, SocialLinkIcon, UserConfig, addLeadingSlash, addTrailingSlash, cleanUrl, inBrowser, isDataUrl, isDebugMode, isExternalUrl, isProduction, isSCM, mergeDocConfig, normalizeHref, normalizePosixPath, normalizeSlash, omit, parseUrl, removeBase, removeHash, removeLeadingSlash, removeTrailingSlash, replaceLang, replaceVersion, slash, withBase, withoutBase, withoutHash, withoutLang };
747
+ export { APPEARANCE_KEY, type AdditionalPage, type BaseRuntimePageInfo, type Config, DEFAULT_HIGHLIGHT_LANGUAGES, type Config$1 as DefaultThemeConfig, type DocFooter, type EditLink, type Feature, type Footer, type FrontMatterMeta, HASH_REGEXP, type Header, type Hero, type Image, type LocalSearchOptions, type Locale, type LocaleConfig, type LocaleLink, type LocaleLinks, MDX_REGEXP, type MarkdownOptions, type MdxRsOptions, type Nav, type NavItem, type NavItemWithChildren, type NavItemWithLink, type NavItemWithLinkAndChildren, type NormalizedConfig, type NormalizedConfig as NormalizedDefaultThemeConfig, type NormalizedLocales, type NormalizedSidebar, type NormalizedSidebarGroup, type PageData, type PageIndexInfo, type PageModule, type PageType, type RspressPlugin as Plugin, QUERY_REGEXP, RSPRESS_TEMP_DIR, type RemotePageInfo, type RemoteSearchIndexInfo, type RemoteSearchOptions, type ReplaceRule, type Route, type RouteMeta, type RouteOptions, type RspressPlugin, SEARCH_INDEX_NAME, type SearchHooks, type SearchOptions, type Sidebar, type SidebarDivider, type SidebarGroup, type SidebarItem, type SiteData, type SocialLink, type SocialLinkIcon, type UserConfig, addLeadingSlash, addTrailingSlash, cleanUrl, inBrowser, isDataUrl, isDebugMode, isExternalUrl, isProduction, isSCM, mergeDocConfig, normalizeHref, normalizePosixPath, normalizeSlash, omit, parseUrl, removeBase, removeHash, removeLeadingSlash, removeTrailingSlash, replaceLang, replaceVersion, slash, withBase, withoutBase, withoutHash, withoutLang };
package/dist/index.js CHANGED
@@ -1111,7 +1111,7 @@ function isUndefined(value) {
1111
1111
  }
1112
1112
  var isUndefined_default = isUndefined;
1113
1113
 
1114
- // src/utils/index.ts
1114
+ // src/runtime-utils/index.ts
1115
1115
  var QUERY_REGEXP = /\?.*$/s;
1116
1116
  var HASH_REGEXP = /#.*$/s;
1117
1117
  var MDX_REGEXP = /\.mdx?$/;
@@ -1190,13 +1190,13 @@ function isExternalUrl(url = "") {
1190
1190
  function isDataUrl(url = "") {
1191
1191
  return /^\s*data:/i.test(url);
1192
1192
  }
1193
- function replaceLang(rawUrl, lang, version, base = "") {
1193
+ function replaceLang(rawUrl, lang, version, base = "", cleanUrls = false) {
1194
1194
  let url = removeBase(rawUrl, base);
1195
1195
  if (!url) {
1196
- url = "/index.html";
1196
+ url = cleanUrls ? "/index" : "/index.html";
1197
1197
  }
1198
1198
  if (url.endsWith("/")) {
1199
- url += "index.html";
1199
+ url += cleanUrls ? "/index" : "/index.html";
1200
1200
  }
1201
1201
  let versionPart = "";
1202
1202
  let langPart = "";
@@ -1215,7 +1215,7 @@ function replaceLang(rawUrl, lang, version, base = "") {
1215
1215
  }
1216
1216
  purePathPart = parts.join("/") || "";
1217
1217
  if ((versionPart || langPart) && !purePathPart) {
1218
- purePathPart = "index.html";
1218
+ purePathPart = cleanUrls ? "index" : "index.html";
1219
1219
  }
1220
1220
  return withBase(
1221
1221
  addLeadingSlash(
@@ -1224,10 +1224,10 @@ function replaceLang(rawUrl, lang, version, base = "") {
1224
1224
  base
1225
1225
  );
1226
1226
  }
1227
- function replaceVersion(rawUrl, version, base = "") {
1227
+ function replaceVersion(rawUrl, version, base = "", cleanUrls = false) {
1228
1228
  let url = removeBase(rawUrl, base);
1229
1229
  if (!url) {
1230
- url = "/index.html";
1230
+ url = cleanUrls ? "/index" : "/index.html";
1231
1231
  }
1232
1232
  let versionPart = "";
1233
1233
  const parts = url.split("/").filter(Boolean);
@@ -1241,7 +1241,7 @@ function replaceVersion(rawUrl, version, base = "") {
1241
1241
  }
1242
1242
  let restPart = parts.join("/") || "";
1243
1243
  if (versionPart && !restPart) {
1244
- restPart = "index.html";
1244
+ restPart = cleanUrls ? "index" : "index.html";
1245
1245
  }
1246
1246
  return withBase(
1247
1247
  addLeadingSlash([versionPart, restPart].filter(Boolean).join("/")),
package/dist/index.mjs CHANGED
@@ -1053,7 +1053,7 @@ function isUndefined(value) {
1053
1053
  }
1054
1054
  var isUndefined_default = isUndefined;
1055
1055
 
1056
- // src/utils/index.ts
1056
+ // src/runtime-utils/index.ts
1057
1057
  var QUERY_REGEXP = /\?.*$/s;
1058
1058
  var HASH_REGEXP = /#.*$/s;
1059
1059
  var MDX_REGEXP = /\.mdx?$/;
@@ -1132,13 +1132,13 @@ function isExternalUrl(url = "") {
1132
1132
  function isDataUrl(url = "") {
1133
1133
  return /^\s*data:/i.test(url);
1134
1134
  }
1135
- function replaceLang(rawUrl, lang, version, base = "") {
1135
+ function replaceLang(rawUrl, lang, version, base = "", cleanUrls = false) {
1136
1136
  let url = removeBase(rawUrl, base);
1137
1137
  if (!url) {
1138
- url = "/index.html";
1138
+ url = cleanUrls ? "/index" : "/index.html";
1139
1139
  }
1140
1140
  if (url.endsWith("/")) {
1141
- url += "index.html";
1141
+ url += cleanUrls ? "/index" : "/index.html";
1142
1142
  }
1143
1143
  let versionPart = "";
1144
1144
  let langPart = "";
@@ -1157,7 +1157,7 @@ function replaceLang(rawUrl, lang, version, base = "") {
1157
1157
  }
1158
1158
  purePathPart = parts.join("/") || "";
1159
1159
  if ((versionPart || langPart) && !purePathPart) {
1160
- purePathPart = "index.html";
1160
+ purePathPart = cleanUrls ? "index" : "index.html";
1161
1161
  }
1162
1162
  return withBase(
1163
1163
  addLeadingSlash(
@@ -1166,10 +1166,10 @@ function replaceLang(rawUrl, lang, version, base = "") {
1166
1166
  base
1167
1167
  );
1168
1168
  }
1169
- function replaceVersion(rawUrl, version, base = "") {
1169
+ function replaceVersion(rawUrl, version, base = "", cleanUrls = false) {
1170
1170
  let url = removeBase(rawUrl, base);
1171
1171
  if (!url) {
1172
- url = "/index.html";
1172
+ url = cleanUrls ? "/index" : "/index.html";
1173
1173
  }
1174
1174
  let versionPart = "";
1175
1175
  const parts = url.split("/").filter(Boolean);
@@ -1183,7 +1183,7 @@ function replaceVersion(rawUrl, version, base = "") {
1183
1183
  }
1184
1184
  let restPart = parts.join("/") || "";
1185
1185
  if (versionPart && !restPart) {
1186
- restPart = "index.html";
1186
+ restPart = cleanUrls ? "index" : "index.html";
1187
1187
  }
1188
1188
  return withBase(
1189
1189
  addLeadingSlash([versionPart, restPart].filter(Boolean).join("/")),
package/dist/logger.d.ts CHANGED
@@ -1 +1,4 @@
1
- export { logger } from 'rslog';
1
+ export { logger } from '@rsbuild/core';
2
+ import 'fs-extra';
3
+ import 'chalk';
4
+ import 'execa';
package/dist/logger.js CHANGED
@@ -20,10 +20,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/logger.ts
21
21
  var logger_exports = {};
22
22
  __export(logger_exports, {
23
- logger: () => import_rslog.logger
23
+ logger: () => import_core.logger
24
24
  });
25
25
  module.exports = __toCommonJS(logger_exports);
26
- var import_rslog = require("rslog");
26
+ var import_core = require("@rsbuild/core");
27
27
  // Annotate the CommonJS export names for ESM import in node:
28
28
  0 && (module.exports = {
29
29
  logger
package/dist/logger.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/logger.ts
2
- import { logger } from "rslog";
2
+ import { logger } from "@rsbuild/core";
3
3
  export {
4
4
  logger
5
5
  };
@@ -0,0 +1,6 @@
1
+ declare function loadFrontMatter(source: string, filepath: string, root: string, outputWarning?: boolean): {
2
+ frontmatter: Record<string, string>;
3
+ content: string;
4
+ };
5
+
6
+ export { loadFrontMatter };
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/node-utils.ts
31
+ var node_utils_exports = {};
32
+ __export(node_utils_exports, {
33
+ loadFrontMatter: () => loadFrontMatter
34
+ });
35
+ module.exports = __toCommonJS(node_utils_exports);
36
+
37
+ // src/node-utils/loadFrontMatter.ts
38
+ var import_path = __toESM(require("path"));
39
+ var import_gray_matter = __toESM(require("gray-matter"));
40
+
41
+ // src/logger.ts
42
+ var import_core = require("@rsbuild/core");
43
+
44
+ // src/node-utils/loadFrontMatter.ts
45
+ function loadFrontMatter(source, filepath, root, outputWarning = false) {
46
+ let frontmatter = {};
47
+ let content = "";
48
+ try {
49
+ ({ data: frontmatter, content } = (0, import_gray_matter.default)(source));
50
+ } catch (e) {
51
+ if (outputWarning) {
52
+ import_core.logger.warn(
53
+ `Parse frontmatter error: ${e.message} in ${import_path.default.relative(
54
+ root,
55
+ filepath
56
+ )}`
57
+ );
58
+ }
59
+ }
60
+ return { frontmatter, content };
61
+ }
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ loadFrontMatter
65
+ });
@@ -0,0 +1,28 @@
1
+ // src/node-utils/loadFrontMatter.ts
2
+ import path from "path";
3
+ import grayMatter from "gray-matter";
4
+
5
+ // src/logger.ts
6
+ import { logger } from "@rsbuild/core";
7
+
8
+ // src/node-utils/loadFrontMatter.ts
9
+ function loadFrontMatter(source, filepath, root, outputWarning = false) {
10
+ let frontmatter = {};
11
+ let content = "";
12
+ try {
13
+ ({ data: frontmatter, content } = grayMatter(source));
14
+ } catch (e) {
15
+ if (outputWarning) {
16
+ logger.warn(
17
+ `Parse frontmatter error: ${e.message} in ${path.relative(
18
+ root,
19
+ filepath
20
+ )}`
21
+ );
22
+ }
23
+ }
24
+ return { frontmatter, content };
25
+ }
26
+ export {
27
+ loadFrontMatter
28
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/shared",
3
- "version": "0.0.0-next-20231207111357",
3
+ "version": "0.0.0-next-20240226105749",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -15,17 +15,39 @@
15
15
  "require": "./dist/index.js",
16
16
  "types": "./dist/index.d.ts"
17
17
  },
18
+ "./execa": {
19
+ "import": "./dist/execa.mjs",
20
+ "require": "./dist/execa.js",
21
+ "types": "./dist/execa.d.ts"
22
+ },
23
+ "./chalk": {
24
+ "import": "./dist/chalk.mjs",
25
+ "require": "./dist/chalk.js",
26
+ "types": "./dist/chalk.d.ts"
27
+ },
28
+ "./fs-extra": {
29
+ "import": "./dist/fs-extra.mjs",
30
+ "require": "./dist/fs-extra.js",
31
+ "types": "./dist/fs-extra.d.ts"
32
+ },
18
33
  "./logger": {
19
34
  "import": "./dist/logger.mjs",
20
35
  "require": "./dist/logger.js",
21
36
  "types": "./dist/logger.d.ts"
37
+ },
38
+ "./node-utils": {
39
+ "import": "./dist/node-utils.mjs",
40
+ "require": "./dist/node-utils.js",
41
+ "types": "./dist/node-utils.d.ts"
22
42
  }
23
43
  },
24
44
  "dependencies": {
25
- "@rsbuild/core": "0.0.0-next-20231207110454",
45
+ "@rsbuild/core": "0.4.0",
26
46
  "unified": "10.1.2",
27
47
  "chalk": "4.1.2",
28
- "rslog": "^1.1.0"
48
+ "execa": "5.1.1",
49
+ "fs-extra": "11.2.0",
50
+ "gray-matter": "4.0.3"
29
51
  },
30
52
  "devDependencies": {
31
53
  "lodash-es": "^4.17.21",
@@ -39,7 +61,8 @@
39
61
  "rimraf": "~3.0.2",
40
62
  "ts-node": "^10.9.1",
41
63
  "typescript": "~5.0.4",
42
- "medium-zoom": "1.0.8"
64
+ "medium-zoom": "1.0.8",
65
+ "@types/fs-extra": "11.0.4"
43
66
  },
44
67
  "sideEffects": [],
45
68
  "publishConfig": {