vitepress 0.17.2 → 0.19.0
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/CHANGELOG.md +26 -0
- package/README.md +2 -6
- package/dist/client/app/router.js +2 -0
- package/dist/client/index.d.ts +127 -9
- package/dist/node/cli.js +289 -34
- package/dist/node/index.d.ts +138 -4
- package/dist/node/index.js +33 -17
- package/dist/node/serve-dbc4b971.js +47774 -0
- package/package.json +39 -28
- package/types/shared.d.ts +1 -1
- package/dist/client/app/components/ClientOnly.d.ts +0 -3
- package/dist/client/app/components/Content.d.ts +0 -3
- package/dist/client/app/composables/head.d.ts +0 -4
- package/dist/client/app/composables/preFetch.d.ts +0 -1
- package/dist/client/app/data.d.ts +0 -18
- package/dist/client/app/index.d.ts +0 -6
- package/dist/client/app/router.d.ts +0 -20
- package/dist/client/app/theme.d.ts +0 -13
- package/dist/client/app/utils.d.ts +0 -11
- package/dist/client/shared.d.ts +0 -12
- package/dist/client/theme-default/components/SideBarLink.d.ts +0 -6
- package/dist/client/theme-default/composables/activeSidebarLink.d.ts +0 -1
- package/dist/client/theme-default/composables/editLink.d.ts +0 -4
- package/dist/client/theme-default/composables/nav.d.ts +0 -2
- package/dist/client/theme-default/composables/navLink.d.ts +0 -15
- package/dist/client/theme-default/composables/nextAndPrevLinks.d.ts +0 -5
- package/dist/client/theme-default/composables/repo.d.ts +0 -5
- package/dist/client/theme-default/composables/sideBar.d.ts +0 -2
- package/dist/client/theme-default/config.d.ts +0 -112
- package/dist/client/theme-default/index.d.ts +0 -8
- package/dist/client/theme-default/support/sideBar.d.ts +0 -18
- package/dist/client/theme-default/utils.d.ts +0 -25
- package/dist/node/alias.d.ts +0 -8
- package/dist/node/alias.js +0 -50
- package/dist/node/alias.js.map +0 -1
- package/dist/node/build/build.d.ts +0 -2
- package/dist/node/build/build.js +0 -48
- package/dist/node/build/build.js.map +0 -1
- package/dist/node/build/bundle.d.ts +0 -6
- package/dist/node/build/bundle.js +0 -97
- package/dist/node/build/bundle.js.map +0 -1
- package/dist/node/build/render.d.ts +0 -4
- package/dist/node/build/render.js +0 -128
- package/dist/node/build/render.js.map +0 -1
- package/dist/node/cli.d.ts +0 -1
- package/dist/node/cli.js.map +0 -1
- package/dist/node/config.d.ts +0 -52
- package/dist/node/config.js +0 -119
- package/dist/node/config.js.map +0 -1
- package/dist/node/index.js.map +0 -1
- package/dist/node/markdown/markdown.d.ts +0 -25
- package/dist/node/markdown/markdown.js +0 -78
- package/dist/node/markdown/markdown.js.map +0 -1
- package/dist/node/markdown/plugins/component.d.ts +0 -2
- package/dist/node/markdown/plugins/component.js +0 -83
- package/dist/node/markdown/plugins/component.js.map +0 -1
- package/dist/node/markdown/plugins/containers.d.ts +0 -2
- package/dist/node/markdown/plugins/containers.js +0 -34
- package/dist/node/markdown/plugins/containers.js.map +0 -1
- package/dist/node/markdown/plugins/header.d.ts +0 -2
- package/dist/node/markdown/plugins/header.js +0 -25
- package/dist/node/markdown/plugins/header.js.map +0 -1
- package/dist/node/markdown/plugins/highlight.d.ts +0 -1
- package/dist/node/markdown/plugins/highlight.js +0 -49
- package/dist/node/markdown/plugins/highlight.js.map +0 -1
- package/dist/node/markdown/plugins/highlightLines.d.ts +0 -2
- package/dist/node/markdown/plugins/highlightLines.js +0 -46
- package/dist/node/markdown/plugins/highlightLines.js.map +0 -1
- package/dist/node/markdown/plugins/hoist.d.ts +0 -2
- package/dist/node/markdown/plugins/hoist.js +0 -22
- package/dist/node/markdown/plugins/hoist.js.map +0 -1
- package/dist/node/markdown/plugins/lineNumbers.d.ts +0 -2
- package/dist/node/markdown/plugins/lineNumbers.js +0 -23
- package/dist/node/markdown/plugins/lineNumbers.js.map +0 -1
- package/dist/node/markdown/plugins/link.d.ts +0 -2
- package/dist/node/markdown/plugins/link.js +0 -66
- package/dist/node/markdown/plugins/link.js.map +0 -1
- package/dist/node/markdown/plugins/preWrapper.d.ts +0 -2
- package/dist/node/markdown/plugins/preWrapper.js +0 -22
- package/dist/node/markdown/plugins/preWrapper.js.map +0 -1
- package/dist/node/markdown/plugins/slugify.d.ts +0 -1
- package/dist/node/markdown/plugins/slugify.js +0 -26
- package/dist/node/markdown/plugins/slugify.js.map +0 -1
- package/dist/node/markdown/plugins/snippet.d.ts +0 -2
- package/dist/node/markdown/plugins/snippet.js +0 -146
- package/dist/node/markdown/plugins/snippet.js.map +0 -1
- package/dist/node/markdownToVue.d.ts +0 -9
- package/dist/node/markdownToVue.js +0 -145
- package/dist/node/markdownToVue.js.map +0 -1
- package/dist/node/plugin.d.ts +0 -3
- package/dist/node/plugin.js +0 -199
- package/dist/node/plugin.js.map +0 -1
- package/dist/node/serve/serve.d.ts +0 -5
- package/dist/node/serve/serve.js +0 -36
- package/dist/node/serve/serve.js.map +0 -1
- package/dist/node/server.d.ts +0 -2
- package/dist/node/server.js +0 -18
- package/dist/node/server.js.map +0 -1
- package/dist/node/shared.d.ts +0 -12
- package/dist/node/shared.js +0 -70
- package/dist/node/shared.js.map +0 -1
- package/dist/node/utils/parseHeader.d.ts +0 -3
- package/dist/node/utils/parseHeader.js +0 -53
- package/dist/node/utils/parseHeader.js.map +0 -1
- package/dist/node/utils/slash.d.ts +0 -1
- package/dist/node/utils/slash.js +0 -8
- package/dist/node/utils/slash.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
# [0.19.0](https://github.com/vuejs/vitepress/compare/v0.18.1...v0.19.0) (2021-09-21)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- upgrade vue, simplify deps ([9030486](https://github.com/vuejs/vitepress/commit/9030486409f10a59115d874b9365f71348ed76c2))
|
|
6
|
+
- use `markdown-it-attrs` for markdown-it plugins ([#393](https://github.com/vuejs/vitepress/issues/393)) ([610e9b7](https://github.com/vuejs/vitepress/commit/610e9b7111462d3aace878017fa4d359cd2ae7ea))
|
|
7
|
+
|
|
8
|
+
## [0.18.1](https://github.com/vuejs/vitepress/compare/v0.18.0...v0.18.1) (2021-09-16)
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
- ensure stable pages entry order across builds ([929bcf5](https://github.com/vuejs/vitepress/commit/929bcf50ee634d9fe73adbe2aae5f7038b048e5a))
|
|
13
|
+
|
|
14
|
+
# [0.18.0](https://github.com/vuejs/vitepress/compare/v0.17.3...v0.18.0) (2021-09-14)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- map mode + remove deprecated options ([b94b163](https://github.com/vuejs/vitepress/commit/b94b163a3a931fe03e69547391d6ac22eb41b789))
|
|
19
|
+
- support `<script client>` in mpa mode ([e0b6997](https://github.com/vuejs/vitepress/commit/e0b69973f840bfa281fae209da1f1c674c1301a8))
|
|
20
|
+
|
|
21
|
+
## [0.17.3](https://github.com/vuejs/vitepress/compare/v0.17.2...v0.17.3) (2021-09-09)
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
- emit prevented hashchange event ([4fb387d](https://github.com/vuejs/vitepress/commit/4fb387d94ea9d7ae28a871929cbbc57e931b8d7a))
|
|
26
|
+
|
|
1
27
|
## [0.17.2](https://github.com/vuejs/vitepress/compare/v0.17.1...v0.17.2) (2021-09-08)
|
|
2
28
|
|
|
3
29
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -5,11 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
VitePress is [VuePress](http://vuepress.vuejs.org/)' little brother, built on top of [vite](https://github.com/vuejs/vite).
|
|
8
|
+
VitePress is [VuePress](http://vuepress.vuejs.org/)' spiritual successor, built on top of [vite](https://github.com/vuejs/vite).
|
|
13
9
|
|
|
14
10
|
## Documentation
|
|
15
11
|
|
|
@@ -17,7 +13,7 @@ To check out docs, visit [vitepress.vuejs.org](https://vitepress.vuejs.org).
|
|
|
17
13
|
|
|
18
14
|
## Changelog
|
|
19
15
|
|
|
20
|
-
Detailed changes for each release are documented in the [
|
|
16
|
+
Detailed changes for each release are documented in the [CHANGELOG](https://github.com/vuejs/vitepress/blob/master/CHANGELOG.md).
|
|
21
17
|
|
|
22
18
|
## Contribution
|
|
23
19
|
|
|
@@ -96,6 +96,8 @@ export function createRouter(loadPageModule, fallbackComponent) {
|
|
|
96
96
|
// scroll between hash anchors in the same page
|
|
97
97
|
if (hash && hash !== currentUrl.hash) {
|
|
98
98
|
history.pushState(null, '', hash);
|
|
99
|
+
// still emit the event so we can listen to it in themes
|
|
100
|
+
window.dispatchEvent(new Event('hashchange'));
|
|
99
101
|
// use smooth scroll when clicking on header anchor links
|
|
100
102
|
scrollTo(link, hash, link.classList.contains('header-anchor'));
|
|
101
103
|
}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,9 +1,127 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { AllowedComponentProps } from 'vue';
|
|
2
|
+
import { App } from 'vue';
|
|
3
|
+
import { Component } from 'vue';
|
|
4
|
+
import { ComponentCustomProps } from 'vue';
|
|
5
|
+
import { ComponentOptions } from 'vue';
|
|
6
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
7
|
+
import { DefineComponent } from 'vue';
|
|
8
|
+
import { EmitsOptions } from 'vue';
|
|
9
|
+
import { Ref } from 'vue';
|
|
10
|
+
import { RendererElement } from 'vue';
|
|
11
|
+
import { RendererNode } from 'vue';
|
|
12
|
+
import { VNode } from 'vue';
|
|
13
|
+
import { VNodeProps } from 'vue';
|
|
14
|
+
|
|
15
|
+
export declare const Content: DefineComponent< {}, () => VNode<RendererNode, RendererElement, {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<{} & {} & {}>, {}>;
|
|
18
|
+
|
|
19
|
+
export declare const Debug: ComponentOptions<{}, any, any, any, any, any, any, any>;
|
|
20
|
+
|
|
21
|
+
export declare interface EnhanceAppContext {
|
|
22
|
+
app: App;
|
|
23
|
+
router: Router;
|
|
24
|
+
siteData: Ref<SiteData>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare type HeadConfig =
|
|
28
|
+
| [string, Record<string, string>]
|
|
29
|
+
| [string, Record<string, string>, string]
|
|
30
|
+
|
|
31
|
+
export declare interface Header {
|
|
32
|
+
level: number
|
|
33
|
+
title: string
|
|
34
|
+
slug: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export declare const inBrowser: boolean;
|
|
38
|
+
|
|
39
|
+
export declare interface LocaleConfig {
|
|
40
|
+
lang: string
|
|
41
|
+
title?: string
|
|
42
|
+
description?: string
|
|
43
|
+
head?: HeadConfig[]
|
|
44
|
+
label?: string
|
|
45
|
+
selectText?: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export declare interface PageData {
|
|
49
|
+
relativePath: string
|
|
50
|
+
title: string
|
|
51
|
+
description: string
|
|
52
|
+
headers: Header[]
|
|
53
|
+
frontmatter: Record<string, any>
|
|
54
|
+
lastUpdated: number
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export declare interface Route {
|
|
58
|
+
path: string;
|
|
59
|
+
data: PageData;
|
|
60
|
+
component: Component | null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export declare interface Router {
|
|
64
|
+
route: Route;
|
|
65
|
+
go: (href?: string) => Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export declare interface SiteData<ThemeConfig = any> {
|
|
69
|
+
base: string
|
|
70
|
+
/**
|
|
71
|
+
* Language of the site as it should be set on the `html` element.
|
|
72
|
+
* @example `en-US`, `zh-CN`
|
|
73
|
+
*/
|
|
74
|
+
lang: string
|
|
75
|
+
title: string
|
|
76
|
+
description: string
|
|
77
|
+
head: HeadConfig[]
|
|
78
|
+
themeConfig: ThemeConfig
|
|
79
|
+
locales: Record<string, LocaleConfig>
|
|
80
|
+
/**
|
|
81
|
+
* Available locales for the site when it has defined `locales` in its
|
|
82
|
+
* `themeConfig`. This object is otherwise empty. Keys are paths like `/` or
|
|
83
|
+
* `/zh/`.
|
|
84
|
+
*/
|
|
85
|
+
langs: Record<
|
|
86
|
+
string,
|
|
87
|
+
{
|
|
88
|
+
/**
|
|
89
|
+
* Lang attribute as set on the `<html>` element.
|
|
90
|
+
* @example `en-US`, `zh-CN`
|
|
91
|
+
*/
|
|
92
|
+
lang: string
|
|
93
|
+
/**
|
|
94
|
+
* Label to display in the language menu.
|
|
95
|
+
* @example `English`, `简体中文`
|
|
96
|
+
*/
|
|
97
|
+
label: string
|
|
98
|
+
}
|
|
99
|
+
>
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export declare interface Theme {
|
|
103
|
+
Layout: Component;
|
|
104
|
+
NotFound?: Component;
|
|
105
|
+
enhanceApp?: (ctx: EnhanceAppContext) => void;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export declare function useData<T = any>(): VitePressData<T>;
|
|
109
|
+
|
|
110
|
+
export declare function useRoute(): Route;
|
|
111
|
+
|
|
112
|
+
export declare function useRouter(): Router;
|
|
113
|
+
|
|
114
|
+
export declare interface VitePressData<T = any> {
|
|
115
|
+
site: Ref<SiteData<T>>;
|
|
116
|
+
page: Ref<PageData>;
|
|
117
|
+
theme: Ref<T>;
|
|
118
|
+
frontmatter: Ref<PageData['frontmatter']>;
|
|
119
|
+
title: Ref<string>;
|
|
120
|
+
description: Ref<string>;
|
|
121
|
+
lang: Ref<string>;
|
|
122
|
+
localePath: Ref<string>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export declare function withBase(path: string): string;
|
|
126
|
+
|
|
127
|
+
export { }
|
package/dist/node/cli.js
CHANGED
|
@@ -1,41 +1,296 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var serve = require('./serve-dbc4b971.js');
|
|
4
|
+
require('vite');
|
|
5
|
+
require('readline');
|
|
6
|
+
require('assert');
|
|
7
|
+
require('events');
|
|
8
|
+
require('stream');
|
|
9
|
+
require('util');
|
|
10
|
+
require('buffer');
|
|
11
|
+
require('path');
|
|
12
|
+
require('fs');
|
|
13
|
+
require('punycode');
|
|
14
|
+
require('url');
|
|
15
|
+
require('@vitejs/plugin-vue');
|
|
16
|
+
require('querystring');
|
|
17
|
+
require('tty');
|
|
18
|
+
require('net');
|
|
19
|
+
require('zlib');
|
|
20
|
+
require('constants');
|
|
21
|
+
require('os');
|
|
22
|
+
|
|
23
|
+
var minimist = function (args, opts) {
|
|
24
|
+
if (!opts) opts = {};
|
|
25
|
+
|
|
26
|
+
var flags = { bools : {}, strings : {}, unknownFn: null };
|
|
27
|
+
|
|
28
|
+
if (typeof opts['unknown'] === 'function') {
|
|
29
|
+
flags.unknownFn = opts['unknown'];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
|
|
33
|
+
flags.allBools = true;
|
|
34
|
+
} else {
|
|
35
|
+
[].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
|
|
36
|
+
flags.bools[key] = true;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var aliases = {};
|
|
41
|
+
Object.keys(opts.alias || {}).forEach(function (key) {
|
|
42
|
+
aliases[key] = [].concat(opts.alias[key]);
|
|
43
|
+
aliases[key].forEach(function (x) {
|
|
44
|
+
aliases[x] = [key].concat(aliases[key].filter(function (y) {
|
|
45
|
+
return x !== y;
|
|
46
|
+
}));
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
[].concat(opts.string).filter(Boolean).forEach(function (key) {
|
|
51
|
+
flags.strings[key] = true;
|
|
52
|
+
if (aliases[key]) {
|
|
53
|
+
flags.strings[aliases[key]] = true;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
var defaults = opts['default'] || {};
|
|
58
|
+
|
|
59
|
+
var argv = { _ : [] };
|
|
60
|
+
Object.keys(flags.bools).forEach(function (key) {
|
|
61
|
+
setArg(key, defaults[key] === undefined ? false : defaults[key]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
var notFlags = [];
|
|
65
|
+
|
|
66
|
+
if (args.indexOf('--') !== -1) {
|
|
67
|
+
notFlags = args.slice(args.indexOf('--')+1);
|
|
68
|
+
args = args.slice(0, args.indexOf('--'));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function argDefined(key, arg) {
|
|
72
|
+
return (flags.allBools && /^--[^=]+$/.test(arg)) ||
|
|
73
|
+
flags.strings[key] || flags.bools[key] || aliases[key];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function setArg (key, val, arg) {
|
|
77
|
+
if (arg && flags.unknownFn && !argDefined(key, arg)) {
|
|
78
|
+
if (flags.unknownFn(arg) === false) return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
var value = !flags.strings[key] && isNumber(val)
|
|
82
|
+
? Number(val) : val
|
|
83
|
+
;
|
|
84
|
+
setKey(argv, key.split('.'), value);
|
|
85
|
+
|
|
86
|
+
(aliases[key] || []).forEach(function (x) {
|
|
87
|
+
setKey(argv, x.split('.'), value);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function setKey (obj, keys, value) {
|
|
92
|
+
var o = obj;
|
|
93
|
+
for (var i = 0; i < keys.length-1; i++) {
|
|
94
|
+
var key = keys[i];
|
|
95
|
+
if (key === '__proto__') return;
|
|
96
|
+
if (o[key] === undefined) o[key] = {};
|
|
97
|
+
if (o[key] === Object.prototype || o[key] === Number.prototype
|
|
98
|
+
|| o[key] === String.prototype) o[key] = {};
|
|
99
|
+
if (o[key] === Array.prototype) o[key] = [];
|
|
100
|
+
o = o[key];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
var key = keys[keys.length - 1];
|
|
104
|
+
if (key === '__proto__') return;
|
|
105
|
+
if (o === Object.prototype || o === Number.prototype
|
|
106
|
+
|| o === String.prototype) o = {};
|
|
107
|
+
if (o === Array.prototype) o = [];
|
|
108
|
+
if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') {
|
|
109
|
+
o[key] = value;
|
|
110
|
+
}
|
|
111
|
+
else if (Array.isArray(o[key])) {
|
|
112
|
+
o[key].push(value);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
o[key] = [ o[key], value ];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function aliasIsBoolean(key) {
|
|
120
|
+
return aliases[key].some(function (x) {
|
|
121
|
+
return flags.bools[x];
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
for (var i = 0; i < args.length; i++) {
|
|
126
|
+
var arg = args[i];
|
|
127
|
+
|
|
128
|
+
if (/^--.+=/.test(arg)) {
|
|
129
|
+
// Using [\s\S] instead of . because js doesn't support the
|
|
130
|
+
// 'dotall' regex modifier. See:
|
|
131
|
+
// http://stackoverflow.com/a/1068308/13216
|
|
132
|
+
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
|
|
133
|
+
var key = m[1];
|
|
134
|
+
var value = m[2];
|
|
135
|
+
if (flags.bools[key]) {
|
|
136
|
+
value = value !== 'false';
|
|
137
|
+
}
|
|
138
|
+
setArg(key, value, arg);
|
|
139
|
+
}
|
|
140
|
+
else if (/^--no-.+/.test(arg)) {
|
|
141
|
+
var key = arg.match(/^--no-(.+)/)[1];
|
|
142
|
+
setArg(key, false, arg);
|
|
143
|
+
}
|
|
144
|
+
else if (/^--.+/.test(arg)) {
|
|
145
|
+
var key = arg.match(/^--(.+)/)[1];
|
|
146
|
+
var next = args[i + 1];
|
|
147
|
+
if (next !== undefined && !/^-/.test(next)
|
|
148
|
+
&& !flags.bools[key]
|
|
149
|
+
&& !flags.allBools
|
|
150
|
+
&& (aliases[key] ? !aliasIsBoolean(key) : true)) {
|
|
151
|
+
setArg(key, next, arg);
|
|
152
|
+
i++;
|
|
153
|
+
}
|
|
154
|
+
else if (/^(true|false)$/.test(next)) {
|
|
155
|
+
setArg(key, next === 'true', arg);
|
|
156
|
+
i++;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
setArg(key, flags.strings[key] ? '' : true, arg);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else if (/^-[^-]+/.test(arg)) {
|
|
163
|
+
var letters = arg.slice(1,-1).split('');
|
|
164
|
+
|
|
165
|
+
var broken = false;
|
|
166
|
+
for (var j = 0; j < letters.length; j++) {
|
|
167
|
+
var next = arg.slice(j+2);
|
|
168
|
+
|
|
169
|
+
if (next === '-') {
|
|
170
|
+
setArg(letters[j], next, arg);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
|
|
175
|
+
setArg(letters[j], next.split('=')[1], arg);
|
|
176
|
+
broken = true;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (/[A-Za-z]/.test(letters[j])
|
|
181
|
+
&& /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
|
|
182
|
+
setArg(letters[j], next, arg);
|
|
183
|
+
broken = true;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (letters[j+1] && letters[j+1].match(/\W/)) {
|
|
188
|
+
setArg(letters[j], arg.slice(j+2), arg);
|
|
189
|
+
broken = true;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
var key = arg.slice(-1)[0];
|
|
198
|
+
if (!broken && key !== '-') {
|
|
199
|
+
if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
|
|
200
|
+
&& !flags.bools[key]
|
|
201
|
+
&& (aliases[key] ? !aliasIsBoolean(key) : true)) {
|
|
202
|
+
setArg(key, args[i+1], arg);
|
|
203
|
+
i++;
|
|
204
|
+
}
|
|
205
|
+
else if (args[i+1] && /^(true|false)$/.test(args[i+1])) {
|
|
206
|
+
setArg(key, args[i+1] === 'true', arg);
|
|
207
|
+
i++;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
setArg(key, flags.strings[key] ? '' : true, arg);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
|
|
216
|
+
argv._.push(
|
|
217
|
+
flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
if (opts.stopEarly) {
|
|
221
|
+
argv._.push.apply(argv._, args.slice(i + 1));
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
Object.keys(defaults).forEach(function (key) {
|
|
228
|
+
if (!hasKey(argv, key.split('.'))) {
|
|
229
|
+
setKey(argv, key.split('.'), defaults[key]);
|
|
230
|
+
|
|
231
|
+
(aliases[key] || []).forEach(function (x) {
|
|
232
|
+
setKey(argv, x.split('.'), defaults[key]);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
if (opts['--']) {
|
|
238
|
+
argv['--'] = new Array();
|
|
239
|
+
notFlags.forEach(function(key) {
|
|
240
|
+
argv['--'].push(key);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
notFlags.forEach(function(key) {
|
|
245
|
+
argv._.push(key);
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return argv;
|
|
4
250
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
console.log(chalk_1.default.cyan(`vitepress v${require('../../package.json').version}`));
|
|
11
|
-
console.log(chalk_1.default.cyan(`vite v${require('vite/package.json').version}`));
|
|
12
|
-
const command = argv._[0];
|
|
13
|
-
const root = argv._[command ? 1 : 0];
|
|
14
|
-
if (root) {
|
|
15
|
-
argv.root = root;
|
|
16
|
-
}
|
|
17
|
-
if (!command || command === 'dev') {
|
|
18
|
-
_1.createServer(root, argv)
|
|
19
|
-
.then((server) => server.listen())
|
|
20
|
-
.catch((err) => {
|
|
21
|
-
console.error(chalk_1.default.red(`failed to start server. error:\n`), err);
|
|
22
|
-
process.exit(1);
|
|
251
|
+
|
|
252
|
+
function hasKey (obj, keys) {
|
|
253
|
+
var o = obj;
|
|
254
|
+
keys.slice(0,-1).forEach(function (key) {
|
|
255
|
+
o = (o[key] || {});
|
|
23
256
|
});
|
|
257
|
+
|
|
258
|
+
var key = keys[keys.length - 1];
|
|
259
|
+
return key in o;
|
|
24
260
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
261
|
+
|
|
262
|
+
function isNumber (x) {
|
|
263
|
+
if (typeof x === 'number') return true;
|
|
264
|
+
if (/^0x[0-9a-f]+$/i.test(x)) return true;
|
|
265
|
+
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
|
|
30
266
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
267
|
+
|
|
268
|
+
const argv = minimist(process.argv.slice(2));
|
|
269
|
+
console.log(serve.source.cyan(`vitepress v${require("../../package.json").version}`));
|
|
270
|
+
const command = argv._[0];
|
|
271
|
+
const root = argv._[command ? 1 : 0];
|
|
272
|
+
if (root) {
|
|
273
|
+
argv.root = root;
|
|
36
274
|
}
|
|
37
|
-
|
|
38
|
-
|
|
275
|
+
if (!command || command === "dev") {
|
|
276
|
+
serve.createServer(root, argv).then((server) => server.listen()).catch((err) => {
|
|
277
|
+
console.error(serve.source.red(`failed to start server. error:
|
|
278
|
+
`), err);
|
|
279
|
+
process.exit(1);
|
|
280
|
+
});
|
|
281
|
+
} else if (command === "build") {
|
|
282
|
+
serve.build(root, argv).catch((err) => {
|
|
283
|
+
console.error(serve.source.red(`build error:
|
|
284
|
+
`), err);
|
|
285
|
+
process.exit(1);
|
|
286
|
+
});
|
|
287
|
+
} else if (command === "serve") {
|
|
288
|
+
serve.serve(argv).catch((err) => {
|
|
289
|
+
console.error(serve.source.red(`failed to start server. error:
|
|
290
|
+
`), err);
|
|
39
291
|
process.exit(1);
|
|
292
|
+
});
|
|
293
|
+
} else {
|
|
294
|
+
console.log(serve.source.red(`unknown command "${command}".`));
|
|
295
|
+
process.exit(1);
|
|
40
296
|
}
|
|
41
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,4 +1,138 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { AliasOptions } from 'vite';
|
|
2
|
+
import { AnchorOptions } from 'markdown-it-anchor';
|
|
3
|
+
import { BuildOptions } from 'vite';
|
|
4
|
+
import MarkdownIt from 'markdown-it';
|
|
5
|
+
import { Options } from '@vitejs/plugin-vue';
|
|
6
|
+
import { ServerOptions } from 'vite';
|
|
7
|
+
import { UserConfig as UserConfig_2 } from 'vite';
|
|
8
|
+
import { ViteDevServer } from 'vite';
|
|
9
|
+
|
|
10
|
+
export declare function build(root: string, buildOptions?: BuildOptions & {
|
|
11
|
+
mpa?: string;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
|
|
14
|
+
export declare function createServer(root?: string, serverOptions?: ServerOptions): Promise<ViteDevServer>;
|
|
15
|
+
|
|
16
|
+
export declare type HeadConfig =
|
|
17
|
+
| [string, Record<string, string>]
|
|
18
|
+
| [string, Record<string, string>, string]
|
|
19
|
+
|
|
20
|
+
export declare interface LocaleConfig {
|
|
21
|
+
lang: string
|
|
22
|
+
title?: string
|
|
23
|
+
description?: string
|
|
24
|
+
head?: HeadConfig[]
|
|
25
|
+
label?: string
|
|
26
|
+
selectText?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export declare interface MarkdownOptions extends MarkdownIt.Options {
|
|
30
|
+
lineNumbers?: boolean;
|
|
31
|
+
config?: (md: MarkdownIt) => void;
|
|
32
|
+
anchor?: {
|
|
33
|
+
permalink?: AnchorOptions['permalink'];
|
|
34
|
+
};
|
|
35
|
+
attrs?: {
|
|
36
|
+
leftDelimiter?: string;
|
|
37
|
+
rightDelimiter?: string;
|
|
38
|
+
allowedAttributes?: string[];
|
|
39
|
+
};
|
|
40
|
+
toc?: any;
|
|
41
|
+
externalLinks?: Record<string, string>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare type RawConfigExports = UserConfig | Promise<UserConfig> | (() => UserConfig | Promise<UserConfig>);
|
|
45
|
+
|
|
46
|
+
export declare function resolveConfig(root?: string): Promise<SiteConfig>;
|
|
47
|
+
|
|
48
|
+
export declare function resolveSiteData(root: string, userConfig?: UserConfig): Promise<SiteData>;
|
|
49
|
+
|
|
50
|
+
export declare function resolveSiteDataByRoute(siteData: SiteData, route: string): SiteData;
|
|
51
|
+
|
|
52
|
+
export declare function resolveUserConfig(root: string): Promise<UserConfig>;
|
|
53
|
+
|
|
54
|
+
export declare function serve(options?: ServeOptions): Promise<void>;
|
|
55
|
+
|
|
56
|
+
export declare interface ServeOptions {
|
|
57
|
+
root?: string;
|
|
58
|
+
port?: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export declare interface SiteConfig<ThemeConfig = any> {
|
|
62
|
+
root: string;
|
|
63
|
+
srcDir: string;
|
|
64
|
+
site: SiteData<ThemeConfig>;
|
|
65
|
+
configPath: string;
|
|
66
|
+
themeDir: string;
|
|
67
|
+
outDir: string;
|
|
68
|
+
tempDir: string;
|
|
69
|
+
alias: AliasOptions;
|
|
70
|
+
pages: string[];
|
|
71
|
+
markdown: MarkdownOptions | undefined;
|
|
72
|
+
vue: Options | undefined;
|
|
73
|
+
vite: UserConfig_2 | undefined;
|
|
74
|
+
mpa: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export declare interface SiteData<ThemeConfig = any> {
|
|
78
|
+
base: string
|
|
79
|
+
/**
|
|
80
|
+
* Language of the site as it should be set on the `html` element.
|
|
81
|
+
* @example `en-US`, `zh-CN`
|
|
82
|
+
*/
|
|
83
|
+
lang: string
|
|
84
|
+
title: string
|
|
85
|
+
description: string
|
|
86
|
+
head: HeadConfig[]
|
|
87
|
+
themeConfig: ThemeConfig
|
|
88
|
+
locales: Record<string, LocaleConfig>
|
|
89
|
+
/**
|
|
90
|
+
* Available locales for the site when it has defined `locales` in its
|
|
91
|
+
* `themeConfig`. This object is otherwise empty. Keys are paths like `/` or
|
|
92
|
+
* `/zh/`.
|
|
93
|
+
*/
|
|
94
|
+
langs: Record<
|
|
95
|
+
string,
|
|
96
|
+
{
|
|
97
|
+
/**
|
|
98
|
+
* Lang attribute as set on the `<html>` element.
|
|
99
|
+
* @example `en-US`, `zh-CN`
|
|
100
|
+
*/
|
|
101
|
+
lang: string
|
|
102
|
+
/**
|
|
103
|
+
* Label to display in the language menu.
|
|
104
|
+
* @example `English`, `简体中文`
|
|
105
|
+
*/
|
|
106
|
+
label: string
|
|
107
|
+
}
|
|
108
|
+
>
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export declare interface UserConfig<ThemeConfig = any> {
|
|
112
|
+
extends?: RawConfigExports;
|
|
113
|
+
lang?: string;
|
|
114
|
+
base?: string;
|
|
115
|
+
title?: string;
|
|
116
|
+
description?: string;
|
|
117
|
+
head?: HeadConfig[];
|
|
118
|
+
themeConfig?: ThemeConfig;
|
|
119
|
+
locales?: Record<string, LocaleConfig>;
|
|
120
|
+
markdown?: MarkdownOptions;
|
|
121
|
+
/**
|
|
122
|
+
* Opitons to pass on to `@vitejs/plugin-vue`
|
|
123
|
+
*/
|
|
124
|
+
vue?: Options;
|
|
125
|
+
/**
|
|
126
|
+
* Vite config
|
|
127
|
+
*/
|
|
128
|
+
vite?: UserConfig_2;
|
|
129
|
+
srcDir?: string;
|
|
130
|
+
srcExclude?: string[];
|
|
131
|
+
/**
|
|
132
|
+
* Enable MPA / zero-JS mode
|
|
133
|
+
* @experimental
|
|
134
|
+
*/
|
|
135
|
+
mpa?: boolean;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export { }
|