@rspress/shared 2.0.0-beta.20 → 2.0.0-beta.22

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.ts CHANGED
@@ -2,7 +2,6 @@ import type { loadConfig } from '@rsbuild/core';
2
2
  import type { PluggableList } from 'unified';
3
3
  import type { RehypeShikiOptions } from '@shikijs/rehype';
4
4
  import type { RsbuildConfig } from '@rsbuild/core';
5
- import type { RsbuildPlugin } from '@rsbuild/core';
6
5
 
7
6
  /**
8
7
  * There are two ways to define what addition routes represent.
@@ -133,6 +132,7 @@ export declare interface DefaultThemeConfig {
133
132
  enableContentAnimation?: boolean;
134
133
  /**
135
134
  * Whether to enable view transition animation for the theme
135
+ * @default false
136
136
  */
137
137
  enableAppearanceAnimation?: boolean;
138
138
  /**
@@ -274,8 +274,6 @@ export declare function isExternalUrl(url?: string): boolean;
274
274
 
275
275
  export declare const isProduction: () => boolean;
276
276
 
277
- export declare const isSCM: () => boolean;
278
-
279
277
  export declare interface Locale {
280
278
  lang: string;
281
279
  label: string;
@@ -340,12 +338,14 @@ export declare interface MarkdownOptions {
340
338
  remarkPlugins?: PluggableList;
341
339
  rehypePlugins?: PluggableList;
342
340
  /**
343
- * Whether to enable check dead links, default is false
341
+ * Whether to enable check dead links
342
+ * @default false
344
343
  */
345
344
  checkDeadLinks?: boolean;
346
345
  showLineNumbers?: boolean;
347
346
  /**
348
- * Whether to wrap code by default, default is false
347
+ * Whether to wrap code by default
348
+ * @default false
349
349
  */
350
350
  defaultWrapCode?: boolean;
351
351
  /**
@@ -462,7 +462,6 @@ export declare interface PageIndexInfo {
462
462
  frontmatter: FrontMatterMeta;
463
463
  lang: string;
464
464
  version: string;
465
- domain: string;
466
465
  _filepath: string;
467
466
  _relativePath: string;
468
467
  }
@@ -494,20 +493,6 @@ export declare type RemotePageInfo = PageIndexInfo & {
494
493
  };
495
494
  };
496
495
 
497
- export declare type RemoteSearchIndexInfo = string | {
498
- value: string;
499
- label: string;
500
- };
501
-
502
- export declare type RemoteSearchOptions = SearchHooks & {
503
- mode: 'remote';
504
- apiUrl: string;
505
- domain?: string;
506
- indexName: string;
507
- searchIndexes?: RemoteSearchIndexInfo[];
508
- searchLoading?: boolean;
509
- };
510
-
511
496
  export declare function removeBase(url: string, base: string): string;
512
497
 
513
498
  export declare function removeHash(str: string): string;
@@ -573,6 +558,7 @@ export declare interface RouteOptions {
573
558
  exclude?: string[];
574
559
  /**
575
560
  * use links without .html files
561
+ * @default false
576
562
  */
577
563
  cleanUrls?: boolean;
578
564
  }
@@ -640,14 +626,6 @@ declare interface RspressPlugin {
640
626
  * Callback after routeService generated
641
627
  */
642
628
  routeServiceGenerated?: (routeService: any, isProd: boolean) => Promise<void> | void;
643
- /**
644
- * Add addition ssg routes, for dynamic routes.
645
- */
646
- addSSGRoutes?: (config: UserConfig, isProd: boolean) => {
647
- path: string;
648
- }[] | Promise<{
649
- path: string;
650
- }[]>;
651
629
  /**
652
630
  * @private
653
631
  * Modify search index data.
@@ -666,7 +644,7 @@ export declare interface SearchHooks {
666
644
  searchHooks?: string;
667
645
  }
668
646
 
669
- export declare type SearchOptions = LocalSearchOptions | RemoteSearchOptions | false;
647
+ export declare type SearchOptions = LocalSearchOptions | false;
670
648
 
671
649
  export declare interface Sidebar {
672
650
  [path: string]: (SidebarGroup | SidebarItem | SidebarDivider | SidebarSectionHeader)[];
@@ -727,7 +705,6 @@ export declare interface SiteData<ThemeConfig = NormalizedConfig> {
727
705
  logoText: string;
728
706
  pages: BaseRuntimePageInfo[];
729
707
  search: SearchOptions;
730
- ssg: boolean;
731
708
  markdown: {
732
709
  showLineNumbers: boolean;
733
710
  defaultWrapCode: boolean;
@@ -849,20 +826,29 @@ export declare interface UserConfig<ThemeConfig = DefaultThemeConfig> {
849
826
  */
850
827
  search?: SearchOptions;
851
828
  /**
852
- * Whether to enable ssg, default is true
829
+ * Whether to enable ssg
830
+ * @default true
853
831
  */
854
- ssg?: boolean;
832
+ ssg?: boolean | {
833
+ /**
834
+ * After enabled, you can use worker to accelerate the SSG process and reduce memory usage. It is suitable for large document sites and is based on [tinypool](https://github.com/tinylibs/tinypool).
835
+ * @default false
836
+ */
837
+ experimentalWorker?: boolean;
838
+ /**
839
+ * After enabled, some pages will not be rendered by SSG, and they will directly use html under CSR. This is suitable for SSG errors in large document sites bypassing a small number of pages. It is not recommended to enable this option actively.
840
+ * @default []
841
+ */
842
+ experimentalExcludeRoutePaths?: (string | RegExp)[];
843
+ };
855
844
  /**
856
- * Whether to enable medium-zoom, default is true
845
+ * Whether to enable medium-zoom
846
+ * @default true
857
847
  */
858
848
  mediumZoom?: boolean | {
859
849
  selector?: string;
860
850
  options?: ZoomOptions;
861
851
  };
862
- /**
863
- * Add some extra builder plugins
864
- */
865
- builderPlugins?: RsbuildPlugin[];
866
852
  /**
867
853
  * Multi version config
868
854
  */
package/dist/index.js CHANGED
@@ -45,7 +45,6 @@ const DEFAULT_HIGHLIGHT_LANGUAGES = [
45
45
  'tsx'
46
46
  ]
47
47
  ];
48
- const isSCM = ()=>Boolean(process.env.BUILD_VERSION);
49
48
  const isProduction = ()=>'production' === process.env.NODE_ENV;
50
49
  const isDebugMode = ()=>{
51
50
  if (!process.env.DEBUG) return false;
@@ -168,4 +167,4 @@ function withBase(url, base) {
168
167
  function removeBase(url, base) {
169
168
  return addLeadingSlash(url).replace(new RegExp(`^${normalizeSlash(base)}`), '');
170
169
  }
171
- export { APPEARANCE_KEY, DEFAULT_HIGHLIGHT_LANGUAGES, HASH_REGEXP, MDX_OR_MD_REGEXP, QUERY_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, utils_cleanUrl as cleanUrl, getSidebarDataGroup, inBrowser, isDataUrl, isDebugMode, isDevDebugMode, isExternalUrl, isProduction, isSCM, matchNavbar, matchSidebar, normalizeHref, normalizePosixPath, normalizeSlash, parseUrl, removeBase, removeHash, removeLeadingSlash, removeTrailingSlash, replaceLang, replaceVersion, slash, withBase, withoutLang };
170
+ export { APPEARANCE_KEY, DEFAULT_HIGHLIGHT_LANGUAGES, HASH_REGEXP, MDX_OR_MD_REGEXP, QUERY_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, utils_cleanUrl as cleanUrl, getSidebarDataGroup, inBrowser, isDataUrl, isDebugMode, isDevDebugMode, isExternalUrl, isProduction, matchNavbar, matchSidebar, normalizeHref, normalizePosixPath, normalizeSlash, parseUrl, removeBase, removeHash, removeLeadingSlash, removeTrailingSlash, replaceLang, replaceVersion, slash, withBase, withoutLang };
@@ -6,7 +6,6 @@ import type { MdxJsxTextElement } from 'mdast-util-mdx-jsx';
6
6
  import type { PluggableList } from 'unified';
7
7
  import type { RehypeShikiOptions } from '@shikijs/rehype';
8
8
  import type { RsbuildConfig } from '@rsbuild/core';
9
- import type { RsbuildPlugin } from '@rsbuild/core';
10
9
 
11
10
  /**
12
11
  * There are two ways to define what addition routes represent.
@@ -121,6 +120,7 @@ declare interface Config {
121
120
  enableContentAnimation?: boolean;
122
121
  /**
123
122
  * Whether to enable view transition animation for the theme
123
+ * @default false
124
124
  */
125
125
  enableAppearanceAnimation?: boolean;
126
126
  /**
@@ -315,12 +315,14 @@ declare interface MarkdownOptions {
315
315
  remarkPlugins?: PluggableList;
316
316
  rehypePlugins?: PluggableList;
317
317
  /**
318
- * Whether to enable check dead links, default is false
318
+ * Whether to enable check dead links
319
+ * @default false
319
320
  */
320
321
  checkDeadLinks?: boolean;
321
322
  showLineNumbers?: boolean;
322
323
  /**
323
- * Whether to wrap code by default, default is false
324
+ * Whether to wrap code by default
325
+ * @default false
324
326
  */
325
327
  defaultWrapCode?: boolean;
326
328
  /**
@@ -385,7 +387,6 @@ declare interface PageIndexInfo {
385
387
  frontmatter: FrontMatterMeta;
386
388
  lang: string;
387
389
  version: string;
388
- domain: string;
389
390
  _filepath: string;
390
391
  _relativePath: string;
391
392
  }
@@ -394,20 +395,6 @@ declare type PageType = 'home' | 'doc' | 'custom' | '404' | 'blank';
394
395
 
395
396
  declare type PluginShikiOptions = RehypeShikiOptions;
396
397
 
397
- declare type RemoteSearchIndexInfo = string | {
398
- value: string;
399
- label: string;
400
- };
401
-
402
- declare type RemoteSearchOptions = SearchHooks & {
403
- mode: 'remote';
404
- apiUrl: string;
405
- domain?: string;
406
- indexName: string;
407
- searchIndexes?: RemoteSearchIndexInfo[];
408
- searchLoading?: boolean;
409
- };
410
-
411
398
  declare interface ReplaceRule {
412
399
  search: string | RegExp;
413
400
  replace: string;
@@ -438,6 +425,7 @@ declare interface RouteOptions {
438
425
  exclude?: string[];
439
426
  /**
440
427
  * use links without .html files
428
+ * @default false
441
429
  */
442
430
  cleanUrls?: boolean;
443
431
  }
@@ -503,14 +491,6 @@ declare interface RspressPlugin {
503
491
  * Callback after routeService generated
504
492
  */
505
493
  routeServiceGenerated?: (routeService: any, isProd: boolean) => Promise<void> | void;
506
- /**
507
- * Add addition ssg routes, for dynamic routes.
508
- */
509
- addSSGRoutes?: (config: UserConfig, isProd: boolean) => {
510
- path: string;
511
- }[] | Promise<{
512
- path: string;
513
- }[]>;
514
494
  /**
515
495
  * @private
516
496
  * Modify search index data.
@@ -525,7 +505,7 @@ declare interface SearchHooks {
525
505
  searchHooks?: string;
526
506
  }
527
507
 
528
- declare type SearchOptions = LocalSearchOptions | RemoteSearchOptions | false;
508
+ declare type SearchOptions = LocalSearchOptions | false;
529
509
 
530
510
  declare interface Sidebar {
531
511
  [path: string]: (SidebarGroup | SidebarItem | SidebarDivider | SidebarSectionHeader)[];
@@ -675,20 +655,29 @@ declare interface UserConfig<ThemeConfig = Config> {
675
655
  */
676
656
  search?: SearchOptions;
677
657
  /**
678
- * Whether to enable ssg, default is true
658
+ * Whether to enable ssg
659
+ * @default true
679
660
  */
680
- ssg?: boolean;
661
+ ssg?: boolean | {
662
+ /**
663
+ * After enabled, you can use worker to accelerate the SSG process and reduce memory usage. It is suitable for large document sites and is based on [tinypool](https://github.com/tinylibs/tinypool).
664
+ * @default false
665
+ */
666
+ experimentalWorker?: boolean;
667
+ /**
668
+ * After enabled, some pages will not be rendered by SSG, and they will directly use html under CSR. This is suitable for SSG errors in large document sites bypassing a small number of pages. It is not recommended to enable this option actively.
669
+ * @default []
670
+ */
671
+ experimentalExcludeRoutePaths?: (string | RegExp)[];
672
+ };
681
673
  /**
682
- * Whether to enable medium-zoom, default is true
674
+ * Whether to enable medium-zoom
675
+ * @default true
683
676
  */
684
677
  mediumZoom?: boolean | {
685
678
  selector?: string;
686
679
  options?: ZoomOptions;
687
680
  };
688
- /**
689
- * Add some extra builder plugins
690
- */
691
- builderPlugins?: RsbuildPlugin[];
692
681
  /**
693
682
  * Multi version config
694
683
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/shared",
3
- "version": "2.0.0-beta.20",
3
+ "version": "2.0.0-beta.22",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/web-infra-dev/rspress.git",
@@ -32,14 +32,14 @@
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "@rsbuild/core": "~1.4.3",
36
- "@shikijs/rehype": "^3.4.2",
35
+ "@rsbuild/core": "~1.4.8",
36
+ "@shikijs/rehype": "^3.8.1",
37
37
  "gray-matter": "4.0.3",
38
38
  "lodash-es": "^4.17.21",
39
39
  "unified": "^11.0.5"
40
40
  },
41
41
  "devDependencies": {
42
- "@rslib/core": "0.10.4",
42
+ "@rslib/core": "0.10.6",
43
43
  "@types/jest": "~29.5.14",
44
44
  "@types/lodash-es": "^4.17.12",
45
45
  "@types/node": "^22.8.1",