@rspress/core 2.0.0-beta.2 → 2.0.0-beta.21

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/loader.d.ts CHANGED
@@ -1,35 +1,33 @@
1
1
  import { AdditionalPage } from '@rspress/shared';
2
2
  import { DefaultThemeConfig } from '@rspress/shared';
3
- import type { FrontMatterMeta } from '@rspress/shared';
4
3
  import type { PageIndexInfo } from '@rspress/shared';
5
4
  import type { RouteMeta } from '@rspress/shared';
6
- import type { Rspack as Rspack_2 } from '@rsbuild/core';
5
+ import { Rspack as Rspack_2 } from '@rsbuild/core';
7
6
  import type { RspressPlugin } from '@rspress/shared';
8
7
  import type { UserConfig } from '@rspress/shared';
9
8
 
10
- export declare function createCheckPageMetaUpdateFn(): (modulePath: string, pageMeta: PageMeta) => void;
11
-
12
- declare interface LoaderOptions {
9
+ declare interface InitOptions {
10
+ scanDir: string;
13
11
  config: UserConfig;
14
- docDirectory: string;
15
- checkDeadLinks: boolean;
16
- routeService: RouteService;
12
+ runtimeTempDir: string;
17
13
  pluginDriver: PluginDriver;
18
14
  }
19
15
 
20
- declare function mdxLoader(this: Rspack_2.LoaderContext<LoaderOptions>, source: string): Promise<void>;
16
+ declare function mdxLoader(this: Rspack_2.LoaderContext<MdxLoaderOptions>, source: string): Promise<void>;
21
17
  export default mdxLoader;
22
18
 
23
- export declare interface PageMeta {
24
- toc: TocItem[];
25
- title: string;
26
- headingTitle: string;
27
- frontmatter?: FrontMatterMeta;
19
+ declare interface MdxLoaderOptions {
20
+ config: UserConfig;
21
+ docDirectory: string;
22
+ checkDeadLinks: boolean;
23
+ routeService: RouteService;
24
+ pluginDriver: PluginDriver;
28
25
  }
29
26
 
30
27
  declare class PluginDriver {
31
28
  #private;
32
- constructor(config: UserConfig, isProd: boolean);
29
+ constructor(config: UserConfig, configFilePath: string, isProd: boolean);
30
+ getConfigFilePath(): string;
33
31
  init(): Promise<void>;
34
32
  addPlugin(plugin: RspressPlugin): void;
35
33
  getPlugins(): RspressPlugin[];
@@ -55,35 +53,41 @@ declare class PluginDriver {
55
53
  _runSerialAsyncHook<H extends RspressPluginHookKeys>(hookName: H, ...args: Parameters<Required<RspressPlugin>[H]>): RspressPlugin;
56
54
  }
57
55
 
56
+ declare class RoutePage {
57
+ #private;
58
+ routeMeta: RouteMeta;
59
+ static create(absolutePath: string, docsDir: string): RoutePage;
60
+ static createFromExternal(routePath: string, filepath: string, docDir: string): RoutePage;
61
+ private constructor();
62
+ static generateRouteMeta(routePath: string, filepath: string, docDir: string): RouteMeta;
63
+ }
64
+
58
65
  declare class RouteService {
59
66
  #private;
60
- routeData: Map<string, RouteMeta>;
61
- constructor(scanDir: string, userConfig: UserConfig, tempDir: string, pluginDriver: PluginDriver);
67
+ routeData: Map<string, RoutePage>;
68
+ static __instance__: RouteService | null;
69
+ static getInstance(): RouteService;
70
+ static create(options: InitOptions): Promise<RouteService>;
71
+ private constructor();
62
72
  get extensions(): readonly string[];
63
- init(): Promise<void>;
64
- addRoute(routeInfo: RouteMeta): void;
65
- removeRoute(filePath: string): void;
73
+ addRoute(routePage: RoutePage): Promise<void>;
66
74
  getRoutes(): RouteMeta[];
75
+ getRoutePages(): RoutePage[];
67
76
  isExistRoute(routePath: string): boolean;
68
- isEmpty(): boolean;
69
- generateRoutesCode(isStaticImport?: boolean): string;
70
- generateRoutesCodeByRouteMeta(routeMeta: RouteMeta[], isStaticImport: boolean): string;
71
- getRoutePathParts(routePath: string): readonly [string, string, string];
72
- normalizeRoutePath(routePath: string): {
77
+ generateRoutesCode(): string;
78
+ private generateRoutesCodeByRouteMeta;
79
+ getRoutePathParts(relativePath: string): readonly [string, string, string];
80
+ normalizeRoutePath(relativePath: string): {
81
+ pureRoutePath: string;
73
82
  routePath: string;
74
83
  lang: string;
75
84
  version: string;
76
85
  };
86
+ absolutePathToRoutePath(absolutePath: string): string;
87
+ absolutePathToRelativePath(absolutePath: string): string;
88
+ getRoutePageByRoutePath(routePath: string): RoutePage | undefined;
77
89
  }
78
90
 
79
- declare type RspressPluginHookKeys = 'beforeBuild' | 'afterBuild' | 'addPages' | 'addRuntimeModules' | 'routeGenerated' | 'routeServiceGenerated' | 'addSSGRoutes' | 'extendPageData' | 'modifySearchIndexData';
80
-
81
- declare interface TocItem {
82
- id: string;
83
- text: string;
84
- depth: number;
85
- }
86
-
87
- export declare function updateSiteDataRuntimeModule(modulePath: string, pageMeta: PageMeta): Promise<void>;
91
+ declare type RspressPluginHookKeys = 'beforeBuild' | 'config' | 'afterBuild' | 'addPages' | 'addRuntimeModules' | 'routeGenerated' | 'routeServiceGenerated' | 'addSSGRoutes' | 'extendPageData' | 'modifySearchIndexData';
88
92
 
89
93
  export { }