@vuepress/core 2.0.0-beta.53 → 2.0.0-beta.55
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 +21 -21
- package/dist/index.js +8 -8
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ interface Bundler {
|
|
|
18
18
|
/**
|
|
19
19
|
* Vuepress Page
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
type Page<ExtraPageData extends Record<any, any> = Record<never, never>, ExtraPageFrontmatter extends Record<any, any> = Record<string, unknown>, ExtraPageFields extends Record<any, any> = Record<never, never>> = PageBase<ExtraPageFrontmatter> & ExtraPageFields & {
|
|
22
22
|
/**
|
|
23
23
|
* Data of the page, which will be available in client code
|
|
24
24
|
*/
|
|
@@ -158,19 +158,19 @@ interface PageOptions {
|
|
|
158
158
|
path?: string;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
type PromiseOrNot<T> = Promise<T> | T;
|
|
162
|
+
type Closable = {
|
|
163
163
|
close(): void;
|
|
164
164
|
};
|
|
165
|
-
|
|
165
|
+
type Hook<Exposed, Normalized = Exposed, Result = Normalized extends (...args: any) => infer U ? U extends Promise<infer V> ? V : U : void> = {
|
|
166
166
|
exposed: Exposed;
|
|
167
167
|
normalized: Normalized;
|
|
168
168
|
result: Result;
|
|
169
169
|
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
type LifeCycleHook<T extends unknown[] = []> = Hook<(app: App, ...args: T) => PromiseOrNot<void>>;
|
|
171
|
+
type ExtendsHook<T> = Hook<(extendable: T, app: App) => PromiseOrNot<void>>;
|
|
172
|
+
type ClientConfigFileHook = Hook<string | ((app: App) => PromiseOrNot<string>), (app: App) => Promise<string>>;
|
|
173
|
+
type AliasDefineHook = Hook<Record<string, any> | ((app: App, isServer: boolean) => PromiseOrNot<Record<string, any>>), (app: App, isServer: boolean) => Promise<Record<string, any>>>;
|
|
174
174
|
/**
|
|
175
175
|
* List of hooks
|
|
176
176
|
*/
|
|
@@ -191,23 +191,23 @@ interface Hooks {
|
|
|
191
191
|
/**
|
|
192
192
|
* Name of hooks
|
|
193
193
|
*/
|
|
194
|
-
|
|
194
|
+
type HooksName = keyof Hooks;
|
|
195
195
|
/**
|
|
196
196
|
* Exposed hooks API that can be accessed by a plugin
|
|
197
197
|
*/
|
|
198
|
-
|
|
198
|
+
type HooksExposed = {
|
|
199
199
|
[K in HooksName]: Hooks[K]['exposed'];
|
|
200
200
|
};
|
|
201
201
|
/**
|
|
202
202
|
* Normalized hooks
|
|
203
203
|
*/
|
|
204
|
-
|
|
204
|
+
type HooksNormalized = {
|
|
205
205
|
[K in HooksName]: Hooks[K]['normalized'];
|
|
206
206
|
};
|
|
207
207
|
/**
|
|
208
208
|
* Result of hooks
|
|
209
209
|
*/
|
|
210
|
-
|
|
210
|
+
type HooksResult = {
|
|
211
211
|
[K in HooksName]: Hooks[K]['result'];
|
|
212
212
|
};
|
|
213
213
|
/**
|
|
@@ -258,13 +258,13 @@ interface PluginApi {
|
|
|
258
258
|
*
|
|
259
259
|
* A plugin package should have a `Plugin` as the default export
|
|
260
260
|
*/
|
|
261
|
-
|
|
261
|
+
type Plugin<T extends PluginObject = PluginObject> = T | PluginFunction<T>;
|
|
262
262
|
/**
|
|
263
263
|
* Vuepress plugin function
|
|
264
264
|
*
|
|
265
265
|
* It accepts plugin options and vuepress app, returns plugin object
|
|
266
266
|
*/
|
|
267
|
-
|
|
267
|
+
type PluginFunction<T extends PluginObject = PluginObject> = (app: App) => T;
|
|
268
268
|
/**
|
|
269
269
|
* Vuepress plugin object
|
|
270
270
|
*/
|
|
@@ -275,7 +275,7 @@ interface PluginObject extends Partial<HooksExposed> {
|
|
|
275
275
|
/**
|
|
276
276
|
* Config field for plugins
|
|
277
277
|
*/
|
|
278
|
-
|
|
278
|
+
type PluginConfig = (Plugin | Plugin[])[];
|
|
279
279
|
|
|
280
280
|
/**
|
|
281
281
|
* Vuepress theme
|
|
@@ -286,11 +286,11 @@ declare type PluginConfig = (Plugin | Plugin[])[];
|
|
|
286
286
|
*
|
|
287
287
|
* A theme package should have a `Theme` as the default export
|
|
288
288
|
*/
|
|
289
|
-
|
|
289
|
+
type Theme = Plugin<ThemeObject>;
|
|
290
290
|
/**
|
|
291
291
|
* Vuepress theme function
|
|
292
292
|
*/
|
|
293
|
-
|
|
293
|
+
type ThemeFunction = PluginFunction<ThemeObject>;
|
|
294
294
|
/**
|
|
295
295
|
* Vuepress theme object
|
|
296
296
|
*/
|
|
@@ -404,16 +404,16 @@ interface AppConfigBuild {
|
|
|
404
404
|
/**
|
|
405
405
|
* Vuepress app config
|
|
406
406
|
*/
|
|
407
|
-
|
|
407
|
+
type AppConfig = AppConfigCommon & AppConfigDev & AppConfigBuild;
|
|
408
408
|
/**
|
|
409
409
|
* Vuepress app options
|
|
410
410
|
*/
|
|
411
|
-
|
|
411
|
+
type AppOptions = Required<AppConfig>;
|
|
412
412
|
|
|
413
413
|
/**
|
|
414
414
|
* Directory util function
|
|
415
415
|
*/
|
|
416
|
-
|
|
416
|
+
type AppDirFunction = (...args: string[]) => string;
|
|
417
417
|
/**
|
|
418
418
|
* Directory utils
|
|
419
419
|
*/
|
|
@@ -445,7 +445,7 @@ interface AppEnv {
|
|
|
445
445
|
/**
|
|
446
446
|
* Write temp file util
|
|
447
447
|
*/
|
|
448
|
-
|
|
448
|
+
type AppWriteTemp = (file: string, content: string) => Promise<string>;
|
|
449
449
|
|
|
450
450
|
/**
|
|
451
451
|
* Vuepress app
|
package/dist/index.js
CHANGED
|
@@ -385,7 +385,7 @@ var resolvePageLang = ({
|
|
|
385
385
|
|
|
386
386
|
// src/page/resolvePagePath.ts
|
|
387
387
|
import { ensureEndingSlash } from "@vuepress/shared";
|
|
388
|
-
import { logger as logger2 } from "@vuepress/utils";
|
|
388
|
+
import { logger as logger2, sanitizeFileName } from "@vuepress/utils";
|
|
389
389
|
var resolvePagePath = ({
|
|
390
390
|
permalink,
|
|
391
391
|
pathInferred,
|
|
@@ -400,7 +400,7 @@ var resolvePagePath = ({
|
|
|
400
400
|
if (!pagePath.endsWith(".html")) {
|
|
401
401
|
pagePath = ensureEndingSlash(pagePath);
|
|
402
402
|
}
|
|
403
|
-
return encodeURI(pagePath);
|
|
403
|
+
return encodeURI(pagePath.split("/").map(sanitizeFileName).join("/"));
|
|
404
404
|
};
|
|
405
405
|
|
|
406
406
|
// src/page/resolvePagePermalink.ts
|
|
@@ -613,7 +613,7 @@ var appPrepare = async (app) => {
|
|
|
613
613
|
};
|
|
614
614
|
|
|
615
615
|
// src/app/appUse.ts
|
|
616
|
-
import {
|
|
616
|
+
import { colors, debug as debug5, warn } from "@vuepress/utils";
|
|
617
617
|
|
|
618
618
|
// src/app/resolvePluginObject.ts
|
|
619
619
|
import { isFunction } from "@vuepress/shared";
|
|
@@ -627,7 +627,7 @@ var appUse = (app, rawPlugin) => {
|
|
|
627
627
|
warn(`an anonymous plugin or theme was detected and ignored`);
|
|
628
628
|
return app;
|
|
629
629
|
}
|
|
630
|
-
log5(`use plugin ${
|
|
630
|
+
log5(`use plugin ${colors.magenta(pluginObject.name)}`);
|
|
631
631
|
if (pluginObject.multiple !== true) {
|
|
632
632
|
const duplicateIndex = app.pluginApi.plugins.findIndex(
|
|
633
633
|
({ name }) => name === pluginObject.name
|
|
@@ -635,7 +635,7 @@ var appUse = (app, rawPlugin) => {
|
|
|
635
635
|
if (duplicateIndex !== -1) {
|
|
636
636
|
app.pluginApi.plugins.splice(duplicateIndex, 1);
|
|
637
637
|
warn(
|
|
638
|
-
`plugin ${
|
|
638
|
+
`plugin ${colors.magenta(
|
|
639
639
|
pluginObject.name
|
|
640
640
|
)} has been used multiple times, only the last one will take effect`
|
|
641
641
|
);
|
|
@@ -646,7 +646,7 @@ var appUse = (app, rawPlugin) => {
|
|
|
646
646
|
};
|
|
647
647
|
|
|
648
648
|
// src/pluginApi/createHookQueue.ts
|
|
649
|
-
import {
|
|
649
|
+
import { colors as colors2, debug as debug6, logger as logger3 } from "@vuepress/utils";
|
|
650
650
|
var log6 = debug6("vuepress:core/plugin-api");
|
|
651
651
|
var createHookQueue = (name) => {
|
|
652
652
|
const items = [];
|
|
@@ -660,7 +660,7 @@ var createHookQueue = (name) => {
|
|
|
660
660
|
const results = [];
|
|
661
661
|
for (const item of items) {
|
|
662
662
|
log6(
|
|
663
|
-
`process ${
|
|
663
|
+
`process ${colors2.magenta(name)} from ${colors2.magenta(
|
|
664
664
|
item.pluginName
|
|
665
665
|
)}`
|
|
666
666
|
);
|
|
@@ -671,7 +671,7 @@ var createHookQueue = (name) => {
|
|
|
671
671
|
}
|
|
672
672
|
} catch (e) {
|
|
673
673
|
logger3.error(
|
|
674
|
-
`error in hook ${
|
|
674
|
+
`error in hook ${colors2.magenta(name)} from ${colors2.magenta(
|
|
675
675
|
item.pluginName
|
|
676
676
|
)}`
|
|
677
677
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.55",
|
|
4
4
|
"description": "Core package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"
|
|
31
|
-
"@vuepress/
|
|
32
|
-
"@vuepress/shared": "2.0.0-beta.
|
|
33
|
-
"@vuepress/utils": "2.0.0-beta.
|
|
34
|
-
"
|
|
30
|
+
"vue": "^3.2.45",
|
|
31
|
+
"@vuepress/client": "2.0.0-beta.55",
|
|
32
|
+
"@vuepress/shared": "2.0.0-beta.55",
|
|
33
|
+
"@vuepress/utils": "2.0.0-beta.55",
|
|
34
|
+
"@vuepress/markdown": "2.0.0-beta.55"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|