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

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/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # @rspress/core
2
2
 
3
- The core package for [Rspress](https://rspress.dev).
3
+ The core package for [Rspress](https://rspress.rs).
package/dist/index.d.ts CHANGED
@@ -16,6 +16,7 @@ export declare function build(options: BuildOptions): Promise<void>;
16
16
  declare interface BuildOptions {
17
17
  docDirectory: string;
18
18
  config: UserConfig;
19
+ configFilePath: string;
19
20
  }
20
21
 
21
22
  /**
@@ -44,9 +45,17 @@ declare interface DevOptions {
44
45
  appDirectory: string;
45
46
  docDirectory: string;
46
47
  config: UserConfig;
48
+ configFilePath: string;
47
49
  extraBuilderConfig?: RsbuildConfig;
48
50
  }
49
51
 
52
+ declare interface InitOptions {
53
+ scanDir: string;
54
+ config: UserConfig;
55
+ runtimeTempDir: string;
56
+ pluginDriver: PluginDriver;
57
+ }
58
+
50
59
  export { mergeDocConfig }
51
60
 
52
61
  /**
@@ -85,7 +94,8 @@ declare interface Parent extends Node_2 {
85
94
 
86
95
  declare class PluginDriver {
87
96
  #private;
88
- constructor(config: UserConfig, isProd: boolean);
97
+ constructor(config: UserConfig, configFilePath: string, isProd: boolean);
98
+ getConfigFilePath(): string;
89
99
  init(): Promise<void>;
90
100
  addPlugin(plugin: RspressPlugin): void;
91
101
  getPlugins(): RspressPlugin[];
@@ -116,9 +126,10 @@ declare class PluginDriver {
116
126
  */
117
127
  export declare const remarkPluginNormalizeLink: Plugin_2<[
118
128
  {
119
- root: string;
120
129
  cleanUrls: boolean | string;
121
- routeService?: RouteService;
130
+ routeService: RouteService | null;
131
+ checkDeadLinks?: boolean;
132
+ __base?: string;
122
133
  }
123
134
  ], Root>;
124
135
 
@@ -151,33 +162,48 @@ declare type RootContent = RootContentMap[keyof RootContentMap];
151
162
  */
152
163
  declare interface RootData extends Data {}
153
164
 
165
+ declare class RoutePage {
166
+ #private;
167
+ routeMeta: RouteMeta;
168
+ static create(absolutePath: string, docsDir: string): RoutePage;
169
+ static createFromExternal(routePath: string, filepath: string, docDir: string): RoutePage;
170
+ private constructor();
171
+ static generateRouteMeta(routePath: string, filepath: string, docDir: string): RouteMeta;
172
+ }
173
+
154
174
  export declare class RouteService {
155
175
  #private;
156
- routeData: Map<string, RouteMeta>;
157
- constructor(scanDir: string, userConfig: UserConfig, tempDir: string, pluginDriver: PluginDriver);
176
+ routeData: Map<string, RoutePage>;
177
+ static __instance__: RouteService | null;
178
+ static getInstance(): RouteService;
179
+ static create(options: InitOptions): Promise<RouteService>;
180
+ private constructor();
158
181
  get extensions(): readonly string[];
159
- init(): Promise<void>;
160
- addRoute(routeInfo: RouteMeta): void;
161
- removeRoute(filePath: string): void;
182
+ addRoute(routePage: RoutePage): Promise<void>;
162
183
  getRoutes(): RouteMeta[];
184
+ getRoutePages(): RoutePage[];
163
185
  isExistRoute(routePath: string): boolean;
164
- isEmpty(): boolean;
165
- generateRoutesCode(isStaticImport?: boolean): string;
166
- generateRoutesCodeByRouteMeta(routeMeta: RouteMeta[], isStaticImport: boolean): string;
167
- getRoutePathParts(routePath: string): readonly [string, string, string];
168
- normalizeRoutePath(routePath: string): {
186
+ generateRoutesCode(): string;
187
+ generateRoutesCodeByRouteMeta(routeMeta: RouteMeta[]): string;
188
+ getRoutePathParts(relativePath: string): readonly [string, string, string];
189
+ normalizeRoutePath(relativePath: string): {
190
+ pureRoutePath: string;
169
191
  routePath: string;
170
192
  lang: string;
171
193
  version: string;
172
194
  };
195
+ absolutePathToRoutePath(absolutePath: string): string;
196
+ absolutePathToRelativePath(absolutePath: string): string;
197
+ getRoutePageByRoutePath(routePath: string): RoutePage | undefined;
173
198
  }
174
199
 
175
- declare type RspressPluginHookKeys = 'beforeBuild' | 'afterBuild' | 'addPages' | 'addRuntimeModules' | 'routeGenerated' | 'routeServiceGenerated' | 'addSSGRoutes' | 'extendPageData' | 'modifySearchIndexData';
200
+ declare type RspressPluginHookKeys = 'beforeBuild' | 'config' | 'afterBuild' | 'addPages' | 'addRuntimeModules' | 'routeGenerated' | 'routeServiceGenerated' | 'addSSGRoutes' | 'extendPageData' | 'modifySearchIndexData';
176
201
 
177
202
  export declare function serve(options: ServeOptions): Promise<ReturnType<RsbuildInstance['preview']>>;
178
203
 
179
204
  declare interface ServeOptions {
180
205
  config: UserConfig;
206
+ configFilePath: string;
181
207
  port?: number;
182
208
  host?: string;
183
209
  }