vitepress 1.0.0-beta.2 → 1.0.0-beta.3
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/client/app/composables/copyCode.js +2 -3
- package/dist/client/index.d.ts +3 -2
- package/dist/client/index.js +1 -1
- package/dist/client/theme-default/components/VPLocalSearchBox.vue +1 -2
- package/dist/client/theme-default/components/VPNavBarSearch.vue +3 -1
- package/dist/node/cli.js +2 -2
- package/dist/node/index.d.ts +5 -3
- package/dist/node/index.js +2 -2
- package/dist/node/{serve-9050e258.js → serve-ec0537e0.js} +9 -9
- package/dist/node-cjs/cli.cjs +2 -2
- package/dist/node-cjs/index.cjs +1 -1
- package/dist/node-cjs/{serve-1a76c42b.cjs → serve-9a16cbd6.cjs} +14 -14
- package/package.json +1 -1
- package/template/.vitepress/theme/index.js +1 -1
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { inBrowser } from 'vitepress';
|
|
2
2
|
export function useCopyCode() {
|
|
3
3
|
if (inBrowser) {
|
|
4
|
-
const timeoutIdMap = new
|
|
4
|
+
const timeoutIdMap = new WeakMap();
|
|
5
5
|
window.addEventListener('click', (e) => {
|
|
6
6
|
const el = e.target;
|
|
7
7
|
if (el.matches('div[class*="language-"] > button.copy')) {
|
|
8
8
|
const parent = el.parentElement;
|
|
9
|
-
const sibling = el.nextElementSibling
|
|
10
|
-
?.nextElementSibling;
|
|
9
|
+
const sibling = el.nextElementSibling?.nextElementSibling;
|
|
11
10
|
if (!parent || !sibling) {
|
|
12
11
|
return;
|
|
13
12
|
}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { Component, Ref, App, AsyncComponentLoader } from 'vue';
|
|
2
|
+
import { Component, InjectionKey, Ref, App, AsyncComponentLoader } from 'vue';
|
|
3
3
|
import { PageData, Awaitable, SiteData } from '../../types/shared.js';
|
|
4
4
|
export { HeadConfig, Header, PageData, SiteData } from '../../types/shared.js';
|
|
5
5
|
|
|
@@ -19,6 +19,7 @@ interface Router {
|
|
|
19
19
|
declare function useRouter(): Router;
|
|
20
20
|
declare function useRoute(): Route;
|
|
21
21
|
|
|
22
|
+
declare const dataSymbol: InjectionKey<VitePressData>;
|
|
22
23
|
interface VitePressData<T = any> {
|
|
23
24
|
/**
|
|
24
25
|
* Site-level metadata
|
|
@@ -96,4 +97,4 @@ declare const Content: vue.DefineComponent<{
|
|
|
96
97
|
as: string | Record<string, any>;
|
|
97
98
|
}, {}>;
|
|
98
99
|
|
|
99
|
-
export { Content, EnhanceAppContext, Route, Router, Theme, VitePressData, defineClientComponent, inBrowser, onContentUpdated, useData, useRoute, useRouter, withBase };
|
|
100
|
+
export { Content, EnhanceAppContext, Route, Router, Theme, VitePressData, dataSymbol, defineClientComponent, inBrowser, onContentUpdated, useData, useRoute, useRouter, withBase };
|
package/dist/client/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// exports in this file are exposed to themes and md files via 'vitepress'
|
|
2
2
|
// so the user can do `import { useRoute, useSiteData } from 'vitepress'`
|
|
3
3
|
// composables
|
|
4
|
-
export { useData } from './app/data';
|
|
4
|
+
export { useData, dataSymbol } from './app/data';
|
|
5
5
|
export { useRoute, useRouter } from './app/router';
|
|
6
6
|
// utilities
|
|
7
7
|
export { inBrowser, onContentUpdated, defineClientComponent, withBase } from './app/utils';
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import { useFocusTrap } from '@vueuse/integrations/useFocusTrap'
|
|
13
13
|
import Mark from 'mark.js/src/vanilla.js'
|
|
14
14
|
import MiniSearch, { type SearchResult } from 'minisearch'
|
|
15
|
-
import { useRouter } from 'vitepress'
|
|
15
|
+
import { useRouter, dataSymbol } from 'vitepress'
|
|
16
16
|
import {
|
|
17
17
|
computed,
|
|
18
18
|
createApp,
|
|
@@ -27,7 +27,6 @@ import {
|
|
|
27
27
|
type Ref
|
|
28
28
|
} from 'vue'
|
|
29
29
|
import type { ModalTranslations } from '../../../../types/local-search'
|
|
30
|
-
import { dataSymbol } from '../../app/data'
|
|
31
30
|
import { pathToFile } from '../../app/utils'
|
|
32
31
|
import { useData } from '../composables/data'
|
|
33
32
|
import { createTranslate } from '../support/translation'
|
|
@@ -26,6 +26,7 @@ const { theme, localeIndex } = useData()
|
|
|
26
26
|
// payload), we delay initializing it until the user has actually clicked or
|
|
27
27
|
// hit the hotkey to invoke it.
|
|
28
28
|
const loaded = ref(false)
|
|
29
|
+
const actuallyLoaded = ref(false)
|
|
29
30
|
|
|
30
31
|
const buttonText = computed(() => {
|
|
31
32
|
const options = theme.value.search?.options ?? theme.value.algolia
|
|
@@ -169,9 +170,10 @@ const provider = __ALGOLIA__ ? 'algolia' : __VP_LOCAL_SEARCH__ ? 'local' : ''
|
|
|
169
170
|
<VPAlgoliaSearchBox
|
|
170
171
|
v-if="loaded"
|
|
171
172
|
:algolia="theme.search?.options ?? theme.algolia"
|
|
173
|
+
@vue:beforeMount="actuallyLoaded = true"
|
|
172
174
|
/>
|
|
173
175
|
|
|
174
|
-
<div v-
|
|
176
|
+
<div v-if="!actuallyLoaded" id="docsearch">
|
|
175
177
|
<VPNavBarSearchButton :placeholder="buttonText" @click="load" />
|
|
176
178
|
</div>
|
|
177
179
|
</template>
|
package/dist/node/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as getDefaultExportFromCjs, p as c, q as clearCache, k as build, s as serve, l as init, j as createServer } from './serve-
|
|
1
|
+
import { o as getDefaultExportFromCjs, p as c, q as clearCache, k as build, s as serve, l as init, j as createServer } from './serve-ec0537e0.js';
|
|
2
2
|
import { createLogger } from 'vite';
|
|
3
3
|
import 'url';
|
|
4
4
|
import 'path';
|
|
@@ -294,7 +294,7 @@ var minimist = function (args, opts) {
|
|
|
294
294
|
|
|
295
295
|
var minimist$1 = /*@__PURE__*/getDefaultExportFromCjs(minimist);
|
|
296
296
|
|
|
297
|
-
var version = "1.0.0-beta.
|
|
297
|
+
var version = "1.0.0-beta.3";
|
|
298
298
|
|
|
299
299
|
function bindShortcuts(server, createDevServer) {
|
|
300
300
|
if (!server.httpServer || !process.stdin.isTTY || process.env.CI) {
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1939,16 +1939,18 @@ type UserConfigExport<ThemeConfig> = UserConfig<ThemeConfig> | Promise<UserConfi
|
|
|
1939
1939
|
/**
|
|
1940
1940
|
* Type config helper
|
|
1941
1941
|
*/
|
|
1942
|
-
declare function defineConfig(config:
|
|
1942
|
+
declare function defineConfig(config: UserConfig<DefaultTheme.Config>): UserConfig<DefaultTheme.Config>;
|
|
1943
1943
|
/**
|
|
1944
1944
|
* Type config helper for custom theme config
|
|
1945
1945
|
*/
|
|
1946
|
-
declare function defineConfigWithTheme<ThemeConfig>(config:
|
|
1946
|
+
declare function defineConfigWithTheme<ThemeConfig>(config: UserConfig<ThemeConfig>): UserConfig<ThemeConfig>;
|
|
1947
1947
|
declare function resolveConfig(root?: string, command?: 'serve' | 'build', mode?: string): Promise<SiteConfig>;
|
|
1948
1948
|
declare function resolveUserConfig(root: string, command: 'serve' | 'build', mode: string): Promise<[UserConfig, string | undefined, string[]]>;
|
|
1949
1949
|
declare function resolveSiteData(root: string, userConfig?: UserConfig, command?: 'serve' | 'build', mode?: string): Promise<SiteData>;
|
|
1950
1950
|
|
|
1951
|
-
declare function createServer(root?: string, serverOptions?: ServerOptions
|
|
1951
|
+
declare function createServer(root?: string, serverOptions?: ServerOptions & {
|
|
1952
|
+
base?: string;
|
|
1953
|
+
}, recreateServer?: () => Promise<void>): Promise<vite.ViteDevServer>;
|
|
1952
1954
|
|
|
1953
1955
|
declare function build(root?: string, buildOptions?: BuildOptions & {
|
|
1954
1956
|
base?: string;
|
package/dist/node/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as glob, c as createMarkdownRenderer, f as fs, m as matter } from './serve-
|
|
2
|
-
export { S as ScaffoldThemeType, k as build, j as createServer, a as defineConfig, b as defineConfigWithTheme, d as defineLoader, l as init, r as resolveConfig, i as resolvePages, h as resolveSiteData, e as resolveUserConfig, n as scaffold, s as serve } from './serve-
|
|
1
|
+
import { g as glob, c as createMarkdownRenderer, f as fs, m as matter } from './serve-ec0537e0.js';
|
|
2
|
+
export { S as ScaffoldThemeType, k as build, j as createServer, a as defineConfig, b as defineConfigWithTheme, d as defineLoader, l as init, r as resolveConfig, i as resolvePages, h as resolveSiteData, e as resolveUserConfig, n as scaffold, s as serve } from './serve-ec0537e0.js';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { normalizePath } from 'vite';
|
|
5
5
|
export { loadEnv } from 'vite';
|
|
@@ -10761,8 +10761,8 @@ function pathToRegexp(path, keys, options) {
|
|
|
10761
10761
|
|
|
10762
10762
|
function resolveRewrites(pages, userRewrites) {
|
|
10763
10763
|
const rewriteRules = Object.entries(userRewrites || {}).map(([from, to]) => ({
|
|
10764
|
-
toPath: compile$1(to),
|
|
10765
|
-
matchUrl: match$1(from)
|
|
10764
|
+
toPath: compile$1(to, { validate: false }),
|
|
10765
|
+
matchUrl: match$1(from.startsWith("^") ? new RegExp(from) : from)
|
|
10766
10766
|
}));
|
|
10767
10767
|
const pageToRewrite = {};
|
|
10768
10768
|
const rewriteToPage = {};
|
|
@@ -63268,11 +63268,11 @@ function trimChar(str, char) {
|
|
|
63268
63268
|
}
|
|
63269
63269
|
async function serve(options = {}) {
|
|
63270
63270
|
var _a;
|
|
63271
|
-
const port = options.port
|
|
63272
|
-
const
|
|
63273
|
-
const base = trimChar((options == null ? void 0 : options.base) ?? ((_a =
|
|
63271
|
+
const port = options.port ?? 4173;
|
|
63272
|
+
const config = await resolveConfig(options.root, "serve", "production");
|
|
63273
|
+
const base = trimChar((options == null ? void 0 : options.base) ?? ((_a = config == null ? void 0 : config.site) == null ? void 0 : _a.base) ?? "", "/");
|
|
63274
63274
|
const notAnAsset = (pathname) => !pathname.includes("/assets/");
|
|
63275
|
-
const notFound = fs$a.readFileSync(path$q.resolve(
|
|
63275
|
+
const notFound = fs$a.readFileSync(path$q.resolve(config.outDir, "./404.html"));
|
|
63276
63276
|
const onNoMatch = (req, res) => {
|
|
63277
63277
|
res.statusCode = 404;
|
|
63278
63278
|
if (notAnAsset(req.path))
|
|
@@ -63280,7 +63280,7 @@ async function serve(options = {}) {
|
|
|
63280
63280
|
res.end();
|
|
63281
63281
|
};
|
|
63282
63282
|
const compress = compression$1();
|
|
63283
|
-
const serve2 = sirv(
|
|
63283
|
+
const serve2 = sirv(config.outDir, {
|
|
63284
63284
|
etag: true,
|
|
63285
63285
|
maxAge: 31536e3,
|
|
63286
63286
|
immutable: true,
|
|
@@ -63292,13 +63292,13 @@ async function serve(options = {}) {
|
|
|
63292
63292
|
});
|
|
63293
63293
|
if (base) {
|
|
63294
63294
|
return polka({ onNoMatch }).use(base, compress, serve2).listen(port, () => {
|
|
63295
|
-
|
|
63295
|
+
config.logger.info(
|
|
63296
63296
|
`Built site served at http://localhost:${port}/${base}/`
|
|
63297
63297
|
);
|
|
63298
63298
|
});
|
|
63299
63299
|
} else {
|
|
63300
63300
|
return polka({ onNoMatch }).use(compress, serve2).listen(port, () => {
|
|
63301
|
-
|
|
63301
|
+
config.logger.info(`Built site served at http://localhost:${port}/`);
|
|
63302
63302
|
});
|
|
63303
63303
|
}
|
|
63304
63304
|
}
|
package/dist/node-cjs/cli.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var init = require('./serve-
|
|
3
|
+
var init = require('./serve-9a16cbd6.cjs');
|
|
4
4
|
var vite = require('vite');
|
|
5
5
|
require('url');
|
|
6
6
|
require('path');
|
|
@@ -296,7 +296,7 @@ var minimist = function (args, opts) {
|
|
|
296
296
|
|
|
297
297
|
var minimist$1 = /*@__PURE__*/init.getDefaultExportFromCjs(minimist);
|
|
298
298
|
|
|
299
|
-
var version = "1.0.0-beta.
|
|
299
|
+
var version = "1.0.0-beta.3";
|
|
300
300
|
|
|
301
301
|
function bindShortcuts(server, createDevServer) {
|
|
302
302
|
if (!server.httpServer || !process.stdin.isTTY || process.env.CI) {
|
package/dist/node-cjs/index.cjs
CHANGED
|
@@ -3731,8 +3731,8 @@ picocolors.exports.createColors = createColors;
|
|
|
3731
3731
|
var picocolorsExports = picocolors.exports;
|
|
3732
3732
|
var c$2 = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
|
|
3733
3733
|
|
|
3734
|
-
const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('serve-
|
|
3735
|
-
const PKG_ROOT = path$q.resolve(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('serve-
|
|
3734
|
+
const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('serve-9a16cbd6.cjs', document.baseURI).href)));
|
|
3735
|
+
const PKG_ROOT = path$q.resolve(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('serve-9a16cbd6.cjs', document.baseURI).href))), "../..");
|
|
3736
3736
|
const DIST_CLIENT_PATH = path$q.resolve(PKG_ROOT, "client");
|
|
3737
3737
|
const APP_PATH = path$q.join(DIST_CLIENT_PATH, "app");
|
|
3738
3738
|
path$q.join(DIST_CLIENT_PATH, "shared");
|
|
@@ -10782,8 +10782,8 @@ function pathToRegexp(path, keys, options) {
|
|
|
10782
10782
|
|
|
10783
10783
|
function resolveRewrites(pages, userRewrites) {
|
|
10784
10784
|
const rewriteRules = Object.entries(userRewrites || {}).map(([from, to]) => ({
|
|
10785
|
-
toPath: compile$1(to),
|
|
10786
|
-
matchUrl: match$1(from)
|
|
10785
|
+
toPath: compile$1(to, { validate: false }),
|
|
10786
|
+
matchUrl: match$1(from.startsWith("^") ? new RegExp(from) : from)
|
|
10787
10787
|
}));
|
|
10788
10788
|
const pageToRewrite = {};
|
|
10789
10789
|
const rewriteToPage = {};
|
|
@@ -48132,7 +48132,7 @@ const okMark = "\x1B[32m\u2713\x1B[0m";
|
|
|
48132
48132
|
const failMark = "\x1B[31m\u2716\x1B[0m";
|
|
48133
48133
|
const lazyDefaultThemeComponentsRE = /VP(HomeSponsors|DocAsideSponsors|TeamPage|TeamMembers|LocalSearchBox|AlgoliaSearchBox|CarbonAds|DocAsideCarbonAds)/;
|
|
48134
48134
|
const clientDir = vite.normalizePath(
|
|
48135
|
-
path$q.resolve(path$q.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('serve-
|
|
48135
|
+
path$q.resolve(path$q.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('serve-9a16cbd6.cjs', document.baseURI).href)))), "../client")
|
|
48136
48136
|
);
|
|
48137
48137
|
async function bundle(config, options) {
|
|
48138
48138
|
const pageToHashMap = /* @__PURE__ */ Object.create(null);
|
|
@@ -48651,7 +48651,7 @@ function linkVue() {
|
|
|
48651
48651
|
if (root) {
|
|
48652
48652
|
const dest = path$q.resolve(root, "node_modules/vue");
|
|
48653
48653
|
if (!fs$a.existsSync(dest)) {
|
|
48654
|
-
const src = path$q.dirname(module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('serve-
|
|
48654
|
+
const src = path$q.dirname(module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('serve-9a16cbd6.cjs', document.baseURI).href))).resolve("vue"));
|
|
48655
48655
|
fs$a.ensureSymlinkSync(src, dest, "junction");
|
|
48656
48656
|
return () => {
|
|
48657
48657
|
fs$a.unlinkSync(dest);
|
|
@@ -63289,11 +63289,11 @@ function trimChar(str, char) {
|
|
|
63289
63289
|
}
|
|
63290
63290
|
async function serve(options = {}) {
|
|
63291
63291
|
var _a;
|
|
63292
|
-
const port = options.port
|
|
63293
|
-
const
|
|
63294
|
-
const base = trimChar((options == null ? void 0 : options.base) ?? ((_a =
|
|
63292
|
+
const port = options.port ?? 4173;
|
|
63293
|
+
const config = await resolveConfig(options.root, "serve", "production");
|
|
63294
|
+
const base = trimChar((options == null ? void 0 : options.base) ?? ((_a = config == null ? void 0 : config.site) == null ? void 0 : _a.base) ?? "", "/");
|
|
63295
63295
|
const notAnAsset = (pathname) => !pathname.includes("/assets/");
|
|
63296
|
-
const notFound = fs$a.readFileSync(path$q.resolve(
|
|
63296
|
+
const notFound = fs$a.readFileSync(path$q.resolve(config.outDir, "./404.html"));
|
|
63297
63297
|
const onNoMatch = (req, res) => {
|
|
63298
63298
|
res.statusCode = 404;
|
|
63299
63299
|
if (notAnAsset(req.path))
|
|
@@ -63301,7 +63301,7 @@ async function serve(options = {}) {
|
|
|
63301
63301
|
res.end();
|
|
63302
63302
|
};
|
|
63303
63303
|
const compress = compression$1();
|
|
63304
|
-
const serve2 = sirv(
|
|
63304
|
+
const serve2 = sirv(config.outDir, {
|
|
63305
63305
|
etag: true,
|
|
63306
63306
|
maxAge: 31536e3,
|
|
63307
63307
|
immutable: true,
|
|
@@ -63313,13 +63313,13 @@ async function serve(options = {}) {
|
|
|
63313
63313
|
});
|
|
63314
63314
|
if (base) {
|
|
63315
63315
|
return polka({ onNoMatch }).use(base, compress, serve2).listen(port, () => {
|
|
63316
|
-
|
|
63316
|
+
config.logger.info(
|
|
63317
63317
|
`Built site served at http://localhost:${port}/${base}/`
|
|
63318
63318
|
);
|
|
63319
63319
|
});
|
|
63320
63320
|
} else {
|
|
63321
63321
|
return polka({ onNoMatch }).use(compress, serve2).listen(port, () => {
|
|
63322
|
-
|
|
63322
|
+
config.logger.info(`Built site served at http://localhost:${port}/`);
|
|
63323
63323
|
});
|
|
63324
63324
|
}
|
|
63325
63325
|
}
|
|
@@ -65558,7 +65558,7 @@ function scaffold({
|
|
|
65558
65558
|
var _a, _b;
|
|
65559
65559
|
const resolvedRoot = path$q.resolve(root);
|
|
65560
65560
|
const templateDir = path$q.resolve(
|
|
65561
|
-
path$q.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('serve-
|
|
65561
|
+
path$q.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('serve-9a16cbd6.cjs', document.baseURI).href)))),
|
|
65562
65562
|
"../../template"
|
|
65563
65563
|
);
|
|
65564
65564
|
const data = {
|
package/package.json
CHANGED