rspress 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,14 +1,14 @@
1
1
  # Rspress
2
2
 
3
3
  <picture>
4
- <img alt="Rspress Banner" src="https://assets.rspack.dev/rspress/rspress-banner.png">
4
+ <img alt="Rspress Banner" src="https://assets.rspack.rs/rspress/rspress-banner.png">
5
5
  </picture>
6
6
 
7
7
  <h2 align="center">A fast Rsbuild-based static site generator.</h2>
8
8
 
9
9
  ## Getting started
10
10
 
11
- Go to the [Quick start](https://rspress.dev/guide/start/getting-started.html) to get started.
11
+ Go to the [Quick start](https://rspress.rs/guide/start/getting-started.html) to get started.
12
12
 
13
13
  ### License
14
14
 
package/dist/index.js CHANGED
@@ -1,98 +1,47 @@
1
- import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
2
- import * as __WEBPACK_EXTERNAL_MODULE__rspress_core_1b2e46ce__ from "@rspress/core";
3
- import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__ from "@rspress/shared/logger";
4
- import * as __WEBPACK_EXTERNAL_MODULE_cac__ from "cac";
5
- import * as __WEBPACK_EXTERNAL_MODULE_chokidar__ from "chokidar";
6
- import * as __WEBPACK_EXTERNAL_MODULE_picocolors__ from "picocolors";
7
- import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
8
- import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__ from "@rspress/shared/constants";
9
- import * as __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__ from "node:child_process";
10
- import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
11
- var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.2"}');
12
- const findConfig = (basePath)=>__WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__.DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync);
1
+ import node_path from "node:path";
2
+ import { build, dev, serve } from "@rspress/core";
3
+ import { logger } from "@rspress/shared/logger";
4
+ import { cac } from "cac";
5
+ import chokidar from "chokidar";
6
+ import picocolors from "picocolors";
7
+ import node_fs from "node:fs";
8
+ import { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "@rspress/shared/constants";
9
+ var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.20"}');
10
+ const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
13
11
  async function loadConfigFile(customConfigFile) {
14
12
  const baseDir = process.cwd();
15
13
  let configFilePath = '';
16
- configFilePath = customConfigFile ? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(customConfigFile) ? customConfigFile : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(baseDir, customConfigFile) : findConfig(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(baseDir, __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__.DEFAULT_CONFIG_NAME));
14
+ configFilePath = customConfigFile ? node_path.isAbsolute(customConfigFile) ? customConfigFile : node_path.join(baseDir, customConfigFile) : findConfig(node_path.join(baseDir, DEFAULT_CONFIG_NAME));
17
15
  if (!configFilePath) {
18
- __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info(`No config file found in ${baseDir}`);
19
- return {};
16
+ logger.info(`No config file found in ${baseDir}`);
17
+ return {
18
+ config: {},
19
+ configFilePath: ''
20
+ };
20
21
  }
21
22
  const { loadConfig } = await import("@rsbuild/core");
22
23
  const { content } = await loadConfig({
23
- cwd: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(configFilePath),
24
+ cwd: node_path.dirname(configFilePath),
24
25
  path: configFilePath
25
26
  });
26
- return content;
27
+ return {
28
+ config: content,
29
+ configFilePath
30
+ };
27
31
  }
28
32
  function resolveDocRoot(cwd, cliRoot, configRoot) {
29
- if (cliRoot) return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(cwd, cliRoot);
30
- if (configRoot) return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(configRoot) ? configRoot : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(cwd, configRoot);
31
- return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(cwd, 'docs');
32
- }
33
- async function pathExists(path) {
34
- try {
35
- await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].access(path);
36
- return true;
37
- } catch {
38
- return false;
39
- }
40
- }
41
- const lockfileMap = {
42
- 'package-lock.json': 'npm',
43
- 'yarn.lock': 'yarn',
44
- 'pnpm-lock.yaml': 'pnpm',
45
- 'bun.lockb': 'bun'
46
- };
47
- async function getPackageManager(rootPath) {
48
- let packageManager = 'npm';
49
- for (const file of Object.keys(lockfileMap))if (await pathExists(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(rootPath, file))) {
50
- packageManager = lockfileMap[file];
51
- break;
52
- }
53
- return packageManager;
54
- }
55
- async function getRspressDependencies(rootPath) {
56
- const packageJson = JSON.parse(await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(rootPath, 'package.json'), {
57
- encoding: 'utf-8'
58
- }));
59
- const dependencies = packageJson?.dependencies ? Object.keys(packageJson.dependencies) : [];
60
- const devDependencies = packageJson?.devDependencies ? Object.keys(packageJson.devDependencies) : [];
61
- return dependencies.concat(devDependencies).filter((item)=>item.startsWith('@rspress') || item.startsWith('rspress'));
62
- }
63
- async function update() {
64
- const cwd = process.cwd();
65
- const packageManager = await getPackageManager(cwd);
66
- const rspressDependencies = await getRspressDependencies(cwd);
67
- __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.greet(`Using ${packageManager} to update ${rspressDependencies.join(' ')}`);
68
- if ('npm' === packageManager || 'bun' === packageManager) {
69
- const dependencies = rspressDependencies.map((item)=>`${item}@latest`);
70
- (0, __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.spawn)(packageManager, [
71
- 'install',
72
- '--save',
73
- ...dependencies
74
- ], {
75
- stdio: 'inherit'
76
- });
77
- } else {
78
- const subCommand = 'yarn' === packageManager ? 'upgrade' : 'update';
79
- (0, __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.spawn)(packageManager, [
80
- subCommand,
81
- '--latest',
82
- ...rspressDependencies
83
- ], {
84
- stdio: 'inherit'
85
- });
86
- }
33
+ if (cliRoot) return node_path.join(cwd, cliRoot);
34
+ if (configRoot) return node_path.isAbsolute(configRoot) ? configRoot : node_path.join(cwd, configRoot);
35
+ return node_path.join(cwd, 'docs');
87
36
  }
88
37
  const CONFIG_FILES = [
89
38
  'rspress.config.ts',
90
39
  'rspress.config.js'
91
40
  ];
92
41
  const META_FILE = '_meta.json';
93
- const cli = (0, __WEBPACK_EXTERNAL_MODULE_cac__.cac)('rspress').version(package_namespaceObject.i8).help();
94
- const landingMessage = `🔥 Rspress v${package_namespaceObject.i8}\n`;
95
- __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.greet(landingMessage);
42
+ const cli = cac('rspress').version(package_namespaceObject.i8).help();
43
+ const landingMessage = `\u{1F525} Rspress v${package_namespaceObject.i8}\n`;
44
+ logger.greet(landingMessage);
96
45
  const setNodeEnv = (env)=>{
97
46
  process.env.NODE_ENV = env;
98
47
  };
@@ -105,13 +54,14 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
105
54
  let devServer;
106
55
  const startDevServer = async ()=>{
107
56
  const { port, host } = options || {};
108
- const config = await loadConfigFile(options?.config);
57
+ const { config, configFilePath } = await loadConfigFile(options?.config);
109
58
  config.root = resolveDocRoot(cwd, root, config.root);
110
59
  const docDirectory = config.root;
111
- devServer = await (0, __WEBPACK_EXTERNAL_MODULE__rspress_core_1b2e46ce__.dev)({
60
+ devServer = await dev({
112
61
  appDirectory: cwd,
113
62
  docDirectory,
114
63
  config,
64
+ configFilePath,
115
65
  extraBuilderConfig: {
116
66
  server: {
117
67
  port,
@@ -119,7 +69,7 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
119
69
  }
120
70
  }
121
71
  });
122
- cliWatcher = __WEBPACK_EXTERNAL_MODULE_chokidar__["default"].watch([
72
+ cliWatcher = chokidar.watch([
123
73
  `${cwd}/**/{${CONFIG_FILES.join(',')}}`,
124
74
  docDirectory
125
75
  ], {
@@ -131,10 +81,11 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
131
81
  ]
132
82
  });
133
83
  cliWatcher.on('all', async (eventName, filepath)=>{
134
- if ('add' === eventName || 'unlink' === eventName || 'change' === eventName && (CONFIG_FILES.includes(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filepath)) || __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filepath) === META_FILE)) {
84
+ if ('add' === eventName || 'unlink' === eventName || 'change' === eventName && (CONFIG_FILES.includes(node_path.basename(filepath)) || node_path.basename(filepath) === META_FILE)) {
135
85
  if (isRestarting) return;
136
86
  isRestarting = true;
137
- console.log(`\n✨ ${eventName} ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].green(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(cwd, filepath))}, dev server will restart...\n`);
87
+ console.log(`
88
+ \u{2728} ${eventName} ${picocolors.green(node_path.relative(cwd, filepath))}, dev server will restart...\n`);
138
89
  await devServer.close();
139
90
  await cliWatcher.close();
140
91
  await startDevServer();
@@ -157,16 +108,17 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
157
108
  cli.command('build [root]').action(async (root, options)=>{
158
109
  setNodeEnv('production');
159
110
  const cwd = process.cwd();
160
- const config = await loadConfigFile(options.config);
111
+ const { config, configFilePath } = await loadConfigFile(options.config);
161
112
  config.root = resolveDocRoot(cwd, root, config.root);
162
113
  const docDirectory = config.root;
163
114
  try {
164
- await (0, __WEBPACK_EXTERNAL_MODULE__rspress_core_1b2e46ce__.build)({
115
+ await build({
165
116
  docDirectory,
166
- config
117
+ config,
118
+ configFilePath
167
119
  });
168
120
  } catch (err) {
169
- __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(err);
121
+ logger.error(err);
170
122
  process.exit(1);
171
123
  }
172
124
  });
@@ -174,13 +126,13 @@ cli.command('preview [root]').alias('serve').option('--port [port]', 'port numbe
174
126
  setNodeEnv('production');
175
127
  const cwd = process.cwd();
176
128
  const { port, host } = options || {};
177
- const config = await loadConfigFile(options?.config);
129
+ const { config, configFilePath } = await loadConfigFile(options?.config);
178
130
  config.root = resolveDocRoot(cwd, root, config.root);
179
- await (0, __WEBPACK_EXTERNAL_MODULE__rspress_core_1b2e46ce__.serve)({
131
+ await serve({
180
132
  config,
181
133
  host,
182
- port
134
+ port,
135
+ configFilePath
183
136
  });
184
137
  });
185
- cli.command('update', 'update relevant packages about rspress').action(update);
186
138
  cli.parse();
@@ -0,0 +1,170 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$ref": "#/definitions/MetaJson",
4
+ "definitions": {
5
+ "MetaJson": {
6
+ "$ref": "#/definitions/SideMeta"
7
+ },
8
+ "SideMeta": {
9
+ "type": "array",
10
+ "items": {
11
+ "$ref": "#/definitions/SideMetaItem"
12
+ }
13
+ },
14
+ "SideMetaItem": {
15
+ "anyOf": [
16
+ {
17
+ "$ref": "#/definitions/FileSideMeta"
18
+ },
19
+ {
20
+ "$ref": "#/definitions/DirSideMeta"
21
+ },
22
+ {
23
+ "$ref": "#/definitions/DividerSideMeta"
24
+ },
25
+ {
26
+ "$ref": "#/definitions/SectionHeaderMeta"
27
+ },
28
+ {
29
+ "$ref": "#/definitions/CustomLinkMeta"
30
+ },
31
+ {
32
+ "type": "string"
33
+ }
34
+ ]
35
+ },
36
+ "FileSideMeta": {
37
+ "type": "object",
38
+ "properties": {
39
+ "type": {
40
+ "type": "string",
41
+ "const": "file"
42
+ },
43
+ "name": {
44
+ "type": "string"
45
+ },
46
+ "label": {
47
+ "type": "string"
48
+ },
49
+ "tag": {
50
+ "type": "string"
51
+ },
52
+ "overviewHeaders": {
53
+ "type": "array",
54
+ "items": {
55
+ "type": "number"
56
+ }
57
+ },
58
+ "context": {
59
+ "type": "string"
60
+ }
61
+ },
62
+ "required": [
63
+ "type",
64
+ "name"
65
+ ],
66
+ "additionalProperties": false
67
+ },
68
+ "DirSideMeta": {
69
+ "type": "object",
70
+ "properties": {
71
+ "type": {
72
+ "type": "string",
73
+ "const": "dir"
74
+ },
75
+ "name": {
76
+ "type": "string"
77
+ },
78
+ "label": {
79
+ "type": "string"
80
+ },
81
+ "collapsible": {
82
+ "type": "boolean"
83
+ },
84
+ "collapsed": {
85
+ "type": "boolean"
86
+ },
87
+ "tag": {
88
+ "type": "string"
89
+ },
90
+ "overviewHeaders": {
91
+ "type": "array",
92
+ "items": {
93
+ "type": "number"
94
+ }
95
+ },
96
+ "context": {
97
+ "type": "string"
98
+ }
99
+ },
100
+ "required": [
101
+ "type",
102
+ "name"
103
+ ],
104
+ "additionalProperties": false
105
+ },
106
+ "DividerSideMeta": {
107
+ "type": "object",
108
+ "properties": {
109
+ "type": {
110
+ "type": "string",
111
+ "const": "divider"
112
+ },
113
+ "dashed": {
114
+ "type": "boolean"
115
+ }
116
+ },
117
+ "required": [
118
+ "type"
119
+ ],
120
+ "additionalProperties": false
121
+ },
122
+ "SectionHeaderMeta": {
123
+ "type": "object",
124
+ "properties": {
125
+ "type": {
126
+ "type": "string",
127
+ "const": "section-header"
128
+ },
129
+ "label": {
130
+ "type": "string"
131
+ },
132
+ "tag": {
133
+ "type": "string"
134
+ }
135
+ },
136
+ "required": [
137
+ "type",
138
+ "label"
139
+ ],
140
+ "additionalProperties": false
141
+ },
142
+ "CustomLinkMeta": {
143
+ "type": "object",
144
+ "properties": {
145
+ "type": {
146
+ "type": "string",
147
+ "const": "custom-link"
148
+ },
149
+ "label": {
150
+ "type": "string"
151
+ },
152
+ "link": {
153
+ "type": "string"
154
+ },
155
+ "context": {
156
+ "type": "string"
157
+ },
158
+ "tag": {
159
+ "type": "string"
160
+ }
161
+ },
162
+ "required": [
163
+ "type",
164
+ "label",
165
+ "link"
166
+ ],
167
+ "additionalProperties": false
168
+ }
169
+ }
170
+ }
@@ -0,0 +1,118 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$ref": "#/definitions/NavJson",
4
+ "definitions": {
5
+ "NavJson": {
6
+ "type": "array",
7
+ "items": {
8
+ "$ref": "#/definitions/NavItem"
9
+ }
10
+ },
11
+ "NavItem": {
12
+ "anyOf": [
13
+ {
14
+ "$ref": "#/definitions/NavItemWithLink"
15
+ },
16
+ {
17
+ "$ref": "#/definitions/NavItemWithChildren"
18
+ },
19
+ {
20
+ "$ref": "#/definitions/NavItemWithLinkAndChildren"
21
+ }
22
+ ]
23
+ },
24
+ "NavItemWithLink": {
25
+ "type": "object",
26
+ "properties": {
27
+ "text": {
28
+ "type": "string"
29
+ },
30
+ "link": {
31
+ "type": "string"
32
+ },
33
+ "tag": {
34
+ "type": "string"
35
+ },
36
+ "activeMatch": {
37
+ "type": "string"
38
+ },
39
+ "position": {
40
+ "type": "string",
41
+ "enum": [
42
+ "left",
43
+ "right"
44
+ ]
45
+ }
46
+ },
47
+ "required": [
48
+ "text",
49
+ "link"
50
+ ],
51
+ "additionalProperties": false
52
+ },
53
+ "NavItemWithChildren": {
54
+ "type": "object",
55
+ "properties": {
56
+ "text": {
57
+ "type": "string"
58
+ },
59
+ "tag": {
60
+ "type": "string"
61
+ },
62
+ "items": {
63
+ "type": "array",
64
+ "items": {
65
+ "$ref": "#/definitions/NavItemWithLink"
66
+ }
67
+ },
68
+ "position": {
69
+ "type": "string",
70
+ "enum": [
71
+ "left",
72
+ "right"
73
+ ]
74
+ }
75
+ },
76
+ "required": [
77
+ "items"
78
+ ],
79
+ "additionalProperties": false
80
+ },
81
+ "NavItemWithLinkAndChildren": {
82
+ "type": "object",
83
+ "properties": {
84
+ "text": {
85
+ "type": "string"
86
+ },
87
+ "link": {
88
+ "type": "string"
89
+ },
90
+ "items": {
91
+ "type": "array",
92
+ "items": {
93
+ "$ref": "#/definitions/NavItemWithLink"
94
+ }
95
+ },
96
+ "tag": {
97
+ "type": "string"
98
+ },
99
+ "activeMatch": {
100
+ "type": "string"
101
+ },
102
+ "position": {
103
+ "type": "string",
104
+ "enum": [
105
+ "left",
106
+ "right"
107
+ ]
108
+ }
109
+ },
110
+ "required": [
111
+ "text",
112
+ "link",
113
+ "items"
114
+ ],
115
+ "additionalProperties": false
116
+ }
117
+ }
118
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rspress",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.20",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/web-infra-dev/rspress.git",
@@ -20,7 +20,11 @@
20
20
  },
21
21
  "./config": {
22
22
  "default": "./config.ts"
23
- }
23
+ },
24
+ "./shiki-transformers": {
25
+ "default": "./shiki-transformers.ts"
26
+ },
27
+ "./package.json": "./package.json"
24
28
  },
25
29
  "main": "./dist/index.js",
26
30
  "module": "./dist/index.js",
@@ -33,24 +37,28 @@
33
37
  "dist",
34
38
  "runtime.ts",
35
39
  "theme.ts",
36
- "config.ts"
40
+ "config.ts",
41
+ "shiki-transformers.ts",
42
+ "meta-json-schema.json",
43
+ "nav-json-schema.json"
37
44
  ],
38
45
  "dependencies": {
39
- "@rsbuild/core": "1.3.9",
46
+ "@rsbuild/core": "~1.4.3",
40
47
  "cac": "^6.7.14",
41
48
  "chokidar": "^3.6.0",
42
49
  "picocolors": "^1.1.1",
43
- "@rspress/shared": "2.0.0-beta.2",
44
- "@rspress/core": "2.0.0-beta.2"
50
+ "@rspress/core": "2.0.0-beta.20",
51
+ "@rspress/shared": "2.0.0-beta.20"
45
52
  },
46
53
  "devDependencies": {
47
- "@microsoft/api-extractor": "^7.52.4",
48
- "@rslib/core": "0.6.5",
54
+ "@microsoft/api-extractor": "^7.52.8",
55
+ "@rslib/core": "0.10.4",
49
56
  "@types/jest": "~29.5.14",
50
- "@types/node": "^18.11.17",
51
- "@types/react": "^18.3.20",
57
+ "@types/node": "^22.8.1",
58
+ "@types/react": "^19.1.8",
52
59
  "rimraf": "^6.0.1",
53
- "rsbuild-plugin-publint": "^0.3.0",
60
+ "rsbuild-plugin-publint": "^0.3.2",
61
+ "ts-json-schema-generator": "^2.4.0",
54
62
  "typescript": "^5.8.2"
55
63
  },
56
64
  "publishConfig": {
@@ -0,0 +1,2 @@
1
+ // FIXME: rspack-resolver bug, export * from '@rspress/core/shiki-transformers';
2
+ export * from '@rspress/core/dist/shiki-transformers.js';