@vuepress/core 2.0.0-rc.30 → 2.0.0-rc.31

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 CHANGED
@@ -1,7 +1,11 @@
1
1
  import { HeadAttrsConfig, HeadConfig, HeadTag, HeadTagEmpty, HeadTagNonEmpty, LocaleConfig, LocaleData, PageBase, PageData, PageData as PageData$1, PageFrontmatter, PageFrontmatter as PageFrontmatter$1, PageHeader, PageHeader as PageHeader$1, SiteData, SiteData as SiteData$1, SiteLocaleConfig } from "@vuepress/shared";
2
2
  import { TemplateRenderer } from "@vuepress/utils";
3
3
  import { Markdown, MarkdownLink, MarkdownOptions, MarkdownSfcBlocks } from "@vuepress/markdown";
4
-
4
+ //#region src/types/helpers.d.ts
5
+ type DeepPartialArray<T> = DeepPartial<T>[];
6
+ type DeepPartialObject<T> = { [P in keyof T]?: DeepPartial<T[P]>; };
7
+ type DeepPartial<T> = T extends Function ? T : T extends (infer U)[] ? DeepPartialArray<U> : T extends object ? DeepPartialObject<T> : T | undefined;
8
+ //#endregion
5
9
  //#region src/types/bundler.d.ts
6
10
  /**
7
11
  * Vuepress bundler
@@ -15,6 +19,10 @@ interface Bundler {
15
19
  * Name of the bundler
16
20
  */
17
21
  name: string;
22
+ /**
23
+ * Type of the bundler, e.g. 'vite' or 'webpack'
24
+ */
25
+ type: string;
18
26
  /**
19
27
  * Method to run vuepress app in dev mode, starting dev server
20
28
  */
@@ -23,6 +31,10 @@ interface Bundler {
23
31
  * Method to run vuepress app in build mode, generating static pages and assets
24
32
  */
25
33
  build: (app: App) => Promise<void>;
34
+ /**
35
+ * Merge config helper for current bundler.
36
+ */
37
+ mergeConfig: <Config extends Record<string, unknown> = Record<string, unknown>>(currentConfig: Config, newConfig: DeepPartial<Config>) => Config;
26
38
  }
27
39
  type BundlerOptions = Record<string, unknown>;
28
40
  //#endregion
@@ -166,7 +178,7 @@ type PromiseOrNot<T> = Promise<T> | T;
166
178
  interface Closable {
167
179
  close(): void;
168
180
  }
169
- interface Hook<Exposed, Normalized = Exposed, Result = (Normalized extends ((...args: any) => infer U) ? U extends Promise<infer V> ? V : U : never)> {
181
+ interface Hook<Exposed, Normalized = Exposed, Result = Normalized extends ((...args: any) => infer U) ? U extends Promise<infer V> ? V : U : never> {
170
182
  exposed: Exposed;
171
183
  normalized: Normalized;
172
184
  result: Result;
@@ -201,15 +213,15 @@ type HooksName = keyof Hooks;
201
213
  /**
202
214
  * Exposed hooks API that can be accessed by a plugin
203
215
  */
204
- type HooksExposed = { [K in HooksName]: Hooks[K]['exposed'] };
216
+ type HooksExposed = { [K in HooksName]: Hooks[K]['exposed']; };
205
217
  /**
206
218
  * Normalized hooks
207
219
  */
208
- type HooksNormalized = { [K in HooksName]: Hooks[K]['normalized'] };
220
+ type HooksNormalized = { [K in HooksName]: Hooks[K]['normalized']; };
209
221
  /**
210
222
  * Result of hooks
211
223
  */
212
- type HooksResult = { [K in HooksName]: Hooks[K]['result'] };
224
+ type HooksResult = { [K in HooksName]: Hooks[K]['result']; };
213
225
  /**
214
226
  * Hook item
215
227
  */
@@ -239,7 +251,7 @@ interface PluginApi {
239
251
  /**
240
252
  * All available hooks
241
253
  */
242
- hooks: { [K in HooksName]: HookQueue<K> };
254
+ hooks: { [K in HooksName]: HookQueue<K>; };
243
255
  /**
244
256
  * Register hooks of plugins
245
257
  *
@@ -479,19 +491,29 @@ interface AppConfigDev {
479
491
  */
480
492
  interface AppConfigBuild {
481
493
  /**
482
- * Determine what resource files should be preloaded. Use boolean value to
483
- * totally enable / disable.
494
+ * Determine what resource files should be preloaded.
495
+ *
496
+ * - `false` disables preloading.
497
+ * - `true` preloads script and style resource files used by the current page.
498
+ * - A function preloads a candidate file when it returns `true`. It receives
499
+ * the output file name and inferred resource type.
484
500
  *
485
501
  * @default true
486
502
  */
487
503
  shouldPreload?: boolean | ((file: string, type: string) => boolean);
488
504
  /**
489
- * Determine what resource files should be prefetched. Use boolean value to
490
- * totally enable / disable.
505
+ * Determine what resource files should be prefetched.
491
506
  *
492
- * @default true
507
+ * - `false` disables prefetching.
508
+ * - `true` prefetches all async resource files not used by the current page.
509
+ * - `'as-needed'` prefetches async resource files only for pages linked from
510
+ * the current page's Markdown content.
511
+ * - A function prefetches a candidate file when it returns `true`. It receives
512
+ * the output file name and inferred resource type.
513
+ *
514
+ * @default 'as-needed'
493
515
  */
494
- shouldPrefetch?: boolean | ((file: string, type: string) => boolean);
516
+ shouldPrefetch?: boolean | 'as-needed' | ((file: string, type: string) => boolean);
495
517
  /**
496
518
  * Specify the path of the HTML template to be used for build
497
519
  *
@@ -733,4 +755,4 @@ declare const renderPageToVue: (app: App, page: Page) => string;
733
755
  //#region src/constants.d.ts
734
756
  declare const DEFAULT_IGNORE_PATTERNS: string[];
735
757
  //#endregion
736
- export { AliasHook, App, AppConfig, AppConfigBuild, AppConfigCommon, AppConfigDev, AppDir, AppDirFunction, AppEnv, AppOptions, AppPropertiesBase, AppPropertiesInitialized, AppWriteTemp, BuildApp, Bundler, BundlerOptions, ClientConfigFileHook, DEFAULT_IGNORE_PATTERNS, DefineHook, DevApp, ExtendsHook, type HeadAttrsConfig, type HeadConfig, type HeadTag, type HeadTagEmpty, type HeadTagNonEmpty, Hook, HookItem, HookQueue, Hooks, HooksExposed, HooksName, HooksNormalized, HooksResult, LifeCycleHook, type LocaleConfig, type LocaleData, Page, type PageData, type PageFrontmatter, type PageHeader, PageOptions, Plugin, PluginApi, PluginConfig, PluginFunction, PluginObject, type SiteData, type SiteLocaleConfig, Theme, ThemeFunction, ThemeInfo, ThemeObject, createBuildApp, createDevApp, createPage, preparePageChunk, prepareRoutes, renderPageToVue, resolveAppDir };
758
+ export { type AliasHook, type App, type AppConfig, type AppConfigBuild, type AppConfigCommon, type AppConfigDev, type AppDir, type AppDirFunction, type AppEnv, type AppOptions, type AppPropertiesBase, type AppPropertiesInitialized, type AppWriteTemp, type BuildApp, type Bundler, type BundlerOptions, type ClientConfigFileHook, DEFAULT_IGNORE_PATTERNS, type DefineHook, type DevApp, type ExtendsHook, type HeadAttrsConfig, type HeadConfig, type HeadTag, type HeadTagEmpty, type HeadTagNonEmpty, type Hook, type HookItem, type HookQueue, type Hooks, type HooksExposed, type HooksName, type HooksNormalized, type HooksResult, type LifeCycleHook, type LocaleConfig, type LocaleData, type Page, type PageData, type PageFrontmatter, type PageHeader, type PageOptions, type Plugin, type PluginApi, type PluginConfig, type PluginFunction, type PluginObject, type SiteData, type SiteLocaleConfig, type Theme, type ThemeFunction, type ThemeInfo, type ThemeObject, createBuildApp, createDevApp, createPage, preparePageChunk, prepareRoutes, renderPageToVue, resolveAppDir };
package/dist/index.js CHANGED
@@ -524,6 +524,10 @@ const prepareUserStyle = async (app, fileExists = null) => {
524
524
  */
525
525
  const resolveAppMarkdown = async (app) => {
526
526
  await app.pluginApi.hooks.extendsMarkdownOptions.process(app.options.markdown, app);
527
+ if (app.options.markdown.assets !== false) {
528
+ app.options.markdown.assets ??= {};
529
+ app.options.markdown.assets.absolutePathPrependBase ??= app.options.bundler.type === "webpack";
530
+ }
527
531
  const markdown = createMarkdown(app.options.markdown);
528
532
  await app.pluginApi.hooks.extendsMarkdown.process(markdown, app);
529
533
  return markdown;
@@ -826,7 +830,7 @@ const require$1 = createRequire(import.meta.url);
826
830
  *
827
831
  * @internal
828
832
  */
829
- const resolveAppOptions = ({ base = "/", lang = "en-US", title = "", description = "", head = [], locales = {}, source, dest = path.resolve(source, ".vuepress/dist"), temp = path.resolve(source, ".vuepress/.temp"), cache = path.resolve(source, ".vuepress/.cache"), public: publicDir = path.resolve(source, ".vuepress/public"), host = "0.0.0.0", port = 8080, open = false, templateDev = path.normalize(require$1.resolve("@vuepress/client/templates/dev.html")), shouldPreload = true, shouldPrefetch = true, templateBuild = path.normalize(require$1.resolve("@vuepress/client/templates/build.html")), templateBuildRenderer = templateRenderer, bundler, debug = false, markdown = {}, pagePatterns = ["**/*.md", "!.vuepress"], permalinkPattern = null, userStyle = null, plugins = [], theme }) => {
833
+ const resolveAppOptions = ({ base = "/", lang = "en-US", title = "", description = "", head = [], locales = {}, source, dest = path.resolve(source, ".vuepress/dist"), temp = path.resolve(source, ".vuepress/.temp"), cache = path.resolve(source, ".vuepress/.cache"), public: publicDir = path.resolve(source, ".vuepress/public"), host = "0.0.0.0", port = 8080, open = false, templateDev = path.normalize(require$1.resolve("@vuepress/client/templates/dev.html")), shouldPreload = true, shouldPrefetch = "as-needed", templateBuild = path.normalize(require$1.resolve("@vuepress/client/templates/build.html")), templateBuildRenderer = templateRenderer, bundler, debug = false, markdown = {}, pagePatterns = ["**/*.md", "!.vuepress"], permalinkPattern = null, userStyle = null, plugins = [], theme }) => {
830
834
  locales["/"] ??= {
831
835
  lang,
832
836
  title,
@@ -1020,4 +1024,4 @@ const createDevApp = (config) => {
1020
1024
  return app;
1021
1025
  };
1022
1026
  //#endregion
1023
- export { DEFAULT_IGNORE_PATTERNS, appInit, appPrepare, appUse, createAppDirFunction, createBaseApp, createBuildApp, createDevApp, createHookQueue, createPage, createPluginApi, createPluginApiHooks, createPluginApiRegisterHooks, inferPagePath, normalizeAliasDefineHook, normalizeClientConfigFileHook, parsePageContent, prepareClientConfigs, preparePageChunk, prepareRoutes, prepareSiteData, prepareUserStyle, renderPageToVue, resolveAppDir, resolveAppEnv, resolveAppOptions, resolveAppPages, resolveAppSiteData, resolveAppVersion, resolveAppWriteTemp, resolvePageChunkInfo, resolvePageContent, resolvePageDate, resolvePageFilePath, resolvePageHtmlInfo, resolvePageLang, resolvePagePath, resolvePagePermalink, resolvePageRouteMeta, resolvePageSlug, resolvePluginObject, resolveThemeInfo };
1027
+ export { DEFAULT_IGNORE_PATTERNS, appInit, appPrepare, appUse, createAppDirFunction, createBaseApp, createBuildApp, createDevApp, createHookQueue, createPage, createPluginApi, createPluginApiHooks, createPluginApiRegisterHooks, inferPagePath, normalizeAliasDefineHook, normalizeClientConfigFileHook, parsePageContent, prepareClientConfigs, preparePageChunk, prepareRoutes, prepareSiteData, prepareUserStyle, renderPageToVue, resolveAppDir, resolveAppEnv, resolveAppOptions, resolveAppPages, resolveAppSiteData, resolveAppVersion, resolveAppWriteTemp, resolvePageChunkInfo, resolvePageContent, resolvePageDate, resolvePageFilePath, resolvePageHtmlInfo, resolvePageLang, resolvePagePath, resolvePagePermalink, resolvePageRedirects, resolvePageRouteMeta, resolvePageSlug, resolvePluginObject, resolveThemeInfo };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/core",
3
- "version": "2.0.0-rc.30",
3
+ "version": "2.0.0-rc.31",
4
4
  "description": "Core package of VuePress",
5
5
  "keywords": [
6
6
  "core",
@@ -31,11 +31,11 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "vue": "^3.5.34",
35
- "@vuepress/shared": "2.0.0-rc.30",
36
- "@vuepress/utils": "2.0.0-rc.30",
37
- "@vuepress/client": "2.0.0-rc.30",
38
- "@vuepress/markdown": "2.0.0-rc.30"
34
+ "vue": "^3.5.40",
35
+ "@vuepress/markdown": "2.0.0-rc.31",
36
+ "@vuepress/client": "2.0.0-rc.31",
37
+ "@vuepress/utils": "2.0.0-rc.31",
38
+ "@vuepress/shared": "2.0.0-rc.31"
39
39
  },
40
40
  "tsdown": {
41
41
  "dts": true,