@vuepress/core 2.0.0-rc.15 → 2.0.0-rc.16

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
@@ -5,7 +5,7 @@
5
5
 
6
6
  ## Documentation
7
7
 
8
- https://v2.vuepress.vuejs.org
8
+ https://vuepress.vuejs.org
9
9
 
10
10
  ## License
11
11
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MarkdownLink, MarkdownSfcBlocks, MarkdownOptions, Markdown, MarkdownHeader } from '@vuepress/markdown';
1
+ import { MarkdownLink, MarkdownSfcBlocks, MarkdownOptions, Markdown } from '@vuepress/markdown';
2
2
  import { PageBase, PageData, PageFrontmatter, SiteData } from '@vuepress/shared';
3
3
  export { HeadAttrsConfig, HeadConfig, HeadTag, HeadTagEmpty, HeadTagNonEmpty, LocaleConfig, LocaleData, PageData, PageFrontmatter, PageHeader, SiteData, SiteLocaleConfig } from '@vuepress/shared';
4
4
  import { TemplateRenderer } from '@vuepress/utils';
@@ -11,15 +11,25 @@ import { TemplateRenderer } from '@vuepress/utils';
11
11
  * - build: bundle assets for deployment
12
12
  */
13
13
  interface Bundler {
14
+ /**
15
+ * Name of the bundler
16
+ */
14
17
  name: string;
18
+ /**
19
+ * Method to run vuepress app in dev mode, starting dev server
20
+ */
15
21
  dev: (app: App) => Promise<() => Promise<void>>;
22
+ /**
23
+ * Method to run vuepress app in build mode, generating static pages and assets
24
+ */
16
25
  build: (app: App) => Promise<void>;
17
26
  }
27
+ type BundlerOptions = Record<string, unknown>;
18
28
 
19
29
  /**
20
30
  * Vuepress Page
21
31
  */
22
- 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 & {
32
+ type Page<ExtraPageData extends Record<string, unknown> = Record<string, unknown>, ExtraPageFrontmatter extends Record<string, unknown> = Record<string, unknown>, ExtraPageFields extends Record<string, unknown> = Record<string, unknown>> = ExtraPageFields & PageBase<ExtraPageFrontmatter> & {
23
33
  /**
24
34
  * Data of the page, which will be available in client code
25
35
  */
@@ -132,11 +142,10 @@ type Page<ExtraPageData extends Record<any, any> = Record<never, never>, ExtraPa
132
142
  */
133
143
  interface PageOptions {
134
144
  /**
135
- * If `filePath` is not set, this option will be used as the raw
136
- * markdown content of the page.
145
+ * The raw markdown content of the page.
137
146
  *
138
- * If `filePath` is set, this option will be ignored, while the
139
- * content of the file will be used.
147
+ * If `content` is not provided, the file content of the `filePath`
148
+ * will be used.
140
149
  */
141
150
  content?: string;
142
151
  /**
@@ -159,7 +168,7 @@ type PromiseOrNot<T> = Promise<T> | T;
159
168
  interface Closable {
160
169
  close(): void;
161
170
  }
162
- interface Hook<Exposed, Normalized = Exposed, Result = Normalized extends (...args: any) => infer U ? U extends Promise<infer V> ? V : U : void> {
171
+ interface Hook<Exposed, Normalized = Exposed, Result = Normalized extends (...args: any) => infer U ? U extends Promise<infer V> ? V : U : never> {
163
172
  exposed: Exposed;
164
173
  normalized: Normalized;
165
174
  result: Result;
@@ -167,7 +176,7 @@ interface Hook<Exposed, Normalized = Exposed, Result = Normalized extends (...ar
167
176
  type LifeCycleHook<T extends unknown[] = []> = Hook<(app: App, ...args: T) => PromiseOrNot<void>>;
168
177
  type ExtendsHook<T> = Hook<(extendable: T, app: App) => PromiseOrNot<void>>;
169
178
  type ClientConfigFileHook = Hook<string | ((app: App) => PromiseOrNot<string>), (app: App) => Promise<string>>;
170
- type AliasDefineHook = Hook<Record<string, any> | ((app: App, isServer: boolean) => PromiseOrNot<Record<string, any>>), (app: App, isServer: boolean) => Promise<Record<string, any>>>;
179
+ type AliasDefineHook = Hook<Record<string, unknown> | ((app: App, isServer: boolean) => PromiseOrNot<Record<string, unknown>>), (app: App, isServer: boolean) => Promise<Record<string, unknown>>>;
171
180
  /**
172
181
  * List of hooks
173
182
  */
@@ -180,7 +189,7 @@ interface Hooks {
180
189
  extendsMarkdown: ExtendsHook<Markdown>;
181
190
  extendsPageOptions: ExtendsHook<PageOptions>;
182
191
  extendsPage: ExtendsHook<Page>;
183
- extendsBundlerOptions: ExtendsHook<any>;
192
+ extendsBundlerOptions: ExtendsHook<BundlerOptions>;
184
193
  clientConfigFile: ClientConfigFileHook;
185
194
  alias: AliasDefineHook;
186
195
  define: AliasDefineHook;
@@ -255,7 +264,7 @@ interface PluginApi {
255
264
  *
256
265
  * A plugin package should have a `Plugin` as the default export
257
266
  */
258
- type Plugin<T extends PluginObject = PluginObject> = T | PluginFunction<T>;
267
+ type Plugin<T extends PluginObject = PluginObject> = PluginFunction<T> | T;
259
268
  /**
260
269
  * Vuepress plugin function
261
270
  *
@@ -266,7 +275,13 @@ type PluginFunction<T extends PluginObject = PluginObject> = (app: App) => T;
266
275
  * Vuepress plugin object
267
276
  */
268
277
  interface PluginObject extends Partial<HooksExposed> {
278
+ /**
279
+ * Name of the plugin
280
+ */
269
281
  name: string;
282
+ /**
283
+ * Allow the plugin to be used multiple times or not
284
+ */
270
285
  multiple?: boolean;
271
286
  }
272
287
  /**
@@ -339,17 +354,87 @@ interface ThemeInfo {
339
354
  * Vuepress app common config that shared between dev and build
340
355
  */
341
356
  interface AppConfigCommon extends Partial<SiteData> {
357
+ /**
358
+ * Source directory of the markdown files.
359
+ *
360
+ * Vuepress will load markdown files from this directory.
361
+ *
362
+ * @required
363
+ */
342
364
  source: string;
365
+ /**
366
+ * Destination directory of the output files.
367
+ *
368
+ * Vuepress will output the static site files to this directory.
369
+ *
370
+ * @default `${source}/.vuepress/dist`
371
+ */
343
372
  dest?: string;
373
+ /**
374
+ * Temp files directory.
375
+ *
376
+ * Vuepress will write temp files to this directory.
377
+ *
378
+ * @default `${source}/.vuepress/.temp`
379
+ */
344
380
  temp?: string;
381
+ /**
382
+ * Cache files directory.
383
+ *
384
+ * Vuepress will write cache files to this directory.
385
+ *
386
+ * @default `${source}/.vuepress/.cache`
387
+ */
345
388
  cache?: string;
389
+ /**
390
+ * Public files directory.
391
+ *
392
+ * Vuepress will copy the files from public directory to the output directory.
393
+ *
394
+ * @default `${source}/.vuepress/public`
395
+ */
346
396
  public?: string;
397
+ /**
398
+ * Whether to enable debug mode
399
+ *
400
+ * @default false
401
+ */
347
402
  debug?: boolean;
403
+ /**
404
+ * Markdown options
405
+ *
406
+ * @default {}
407
+ */
348
408
  markdown?: MarkdownOptions;
409
+ /**
410
+ * Patterns to match the markdown files as pages
411
+ *
412
+ * @default ['**\/*.md', '!.vuepress', '!node_modules']
413
+ */
349
414
  pagePatterns?: string[];
415
+ /**
416
+ * Pattern to generate permalink for pages
417
+ *
418
+ * @default null
419
+ */
350
420
  permalinkPattern?: string | null;
421
+ /**
422
+ * Vuepress bundler
423
+ *
424
+ * @required
425
+ */
351
426
  bundler: Bundler;
427
+ /**
428
+ * Vuepress theme
429
+ *
430
+ * @required
431
+ */
352
432
  theme: Theme;
433
+ /**
434
+ * Vuepress plugins
435
+ *
436
+ * @default []
437
+ */
353
438
  plugins?: PluginConfig;
354
439
  }
355
440
  /**
@@ -391,14 +476,14 @@ interface AppConfigBuild {
391
476
  *
392
477
  * @default true
393
478
  */
394
- shouldPreload?: ((file: string, type: string) => boolean) | boolean;
479
+ shouldPreload?: boolean | ((file: string, type: string) => boolean);
395
480
  /**
396
481
  * Determine what resource files should be prefetched. Use boolean value to
397
482
  * totally enable / disable.
398
483
  *
399
484
  * @default true
400
485
  */
401
- shouldPrefetch?: ((file: string, type: string) => boolean) | boolean;
486
+ shouldPrefetch?: boolean | ((file: string, type: string) => boolean);
402
487
  /**
403
488
  * Specify the path of the HTML template to be used for build
404
489
  *
@@ -408,16 +493,20 @@ interface AppConfigBuild {
408
493
  /**
409
494
  * Specify the HTML template renderer to be used for build
410
495
  *
411
- * @default templateRenderer from '@vuepress/utils'
496
+ * @default `import { templateRenderer } from '@vuepress/utils'`
412
497
  */
413
498
  templateBuildRenderer?: TemplateRenderer;
414
499
  }
415
500
  /**
416
- * Vuepress app config
501
+ * Vuepress app user config.
502
+ *
503
+ * It would be provided by user, typically via a config file.
417
504
  */
418
- type AppConfig = AppConfigCommon & AppConfigDev & AppConfigBuild;
505
+ type AppConfig = AppConfigBuild & AppConfigCommon & AppConfigDev;
419
506
  /**
420
- * Vuepress app options
507
+ * Vuepress app options that resolved from user config.
508
+ *
509
+ * It fills all optional fields with a default value.
421
510
  */
422
511
  type AppOptions = Required<AppConfig>;
423
512
 
@@ -429,11 +518,29 @@ type AppDirFunction = (...args: string[]) => string;
429
518
  * Directory utils
430
519
  */
431
520
  interface AppDir {
521
+ /**
522
+ * Resolve file path in cache directory
523
+ */
432
524
  cache: AppDirFunction;
525
+ /**
526
+ * Resolve file path in temp directory
527
+ */
433
528
  temp: AppDirFunction;
529
+ /**
530
+ * Resolve file path in source directory
531
+ */
434
532
  source: AppDirFunction;
533
+ /**
534
+ * Resolve file path in dest directory
535
+ */
435
536
  dest: AppDirFunction;
537
+ /**
538
+ * Resolve file path in public directory
539
+ */
436
540
  public: AppDirFunction;
541
+ /**
542
+ * Resolve file path in client directory
543
+ */
437
544
  client: AppDirFunction;
438
545
  }
439
546
  /**
@@ -459,41 +566,33 @@ interface AppEnv {
459
566
  type AppWriteTemp = (file: string, content: string) => Promise<string>;
460
567
 
461
568
  /**
462
- * Vuepress app
569
+ * App base properties, will be available after creation, even before initialization
463
570
  */
464
- interface App {
571
+ interface AppPropertiesBase {
465
572
  /**
466
- * Directory utils
573
+ * Directory utils.
467
574
  */
468
575
  dir: AppDir;
469
576
  /**
470
- * Environment flags
577
+ * Environment flags.
471
578
  */
472
579
  env: AppEnv;
473
580
  /**
474
- * Options that filled all optional fields with a default value
581
+ * Options that filled all optional fields with a default value.
475
582
  */
476
583
  options: AppOptions;
477
584
  /**
478
- * Plugin system
585
+ * Plugin system.
479
586
  */
480
587
  pluginApi: PluginApi;
481
588
  /**
482
- * Site data, which will be used in client side
589
+ * Site data, which will be used in client side.
483
590
  */
484
591
  siteData: SiteData;
485
592
  /**
486
- * Version of vuepress core
593
+ * Version of vuepress core.
487
594
  */
488
595
  version: string;
489
- /**
490
- * Write temp file
491
- */
492
- writeTemp: AppWriteTemp;
493
- /**
494
- * Use a plugin
495
- */
496
- use: (plugin: Plugin) => this;
497
596
  /**
498
597
  * Initialize app.
499
598
  *
@@ -507,6 +606,21 @@ interface App {
507
606
  * Should be called after `app.init()`.
508
607
  */
509
608
  prepare: () => Promise<void>;
609
+ /**
610
+ * Use a plugin.
611
+ *
612
+ * Should be called before `app.init()`.
613
+ */
614
+ use: (plugin: Plugin) => this;
615
+ /**
616
+ * Util to write temp file
617
+ */
618
+ writeTemp: AppWriteTemp;
619
+ }
620
+ /**
621
+ * App initialized properties, will only be available after initialization
622
+ */
623
+ interface AppPropertiesInitialized {
510
624
  /**
511
625
  * Markdown-it instance.
512
626
  *
@@ -520,6 +634,10 @@ interface App {
520
634
  */
521
635
  pages: Page[];
522
636
  }
637
+ /**
638
+ * Vuepress app instance
639
+ */
640
+ type App = AppPropertiesBase & AppPropertiesInitialized;
523
641
  /**
524
642
  * Vuepress dev app
525
643
  */
@@ -543,11 +661,6 @@ interface BuildApp extends App {
543
661
  build: () => ReturnType<Bundler['build']>;
544
662
  }
545
663
 
546
- /**
547
- * Generate client configs temp file
548
- */
549
- declare const prepareClientConfigs: (app: App) => Promise<void>;
550
-
551
664
  /**
552
665
  * Generate page chunk temp file of a single page
553
666
  */
@@ -564,255 +677,32 @@ declare const preparePageComponent: (app: App, page: Page) => Promise<void>;
564
677
  declare const prepareRoutes: (app: App) => Promise<void>;
565
678
 
566
679
  /**
567
- * Generate site data temp file
568
- */
569
- declare const prepareSiteData: (app: App) => Promise<void>;
570
-
571
- /**
572
- * Initialize a vuepress app
680
+ * Create base vuepress app.
573
681
  *
574
- * Plugins should be used before initialization.
575
- */
576
- declare const appInit: (app: App) => Promise<void>;
577
-
578
- /**
579
- * Prepare files for development or build
682
+ * Notice that the base app could not be used for dev nor build.
580
683
  *
581
- * - page components
582
- * - page chunks
583
- * - routes
584
- * - site data
585
- * - other files that generated by plugins
684
+ * It would be used for creating dev app or build app, or for testing.
586
685
  */
587
- declare const appPrepare: (app: App) => Promise<void>;
588
-
589
- declare const appUse: (app: App, rawPlugin: Plugin) => App;
590
-
591
- /**
592
- * Create vuepress app
593
- */
594
- declare const createBaseApp: (config: AppConfig, isBuild?: boolean) => App;
686
+ declare const createBaseApp: (config: AppConfig) => App;
595
687
 
596
688
  /**
597
- * Create vuepress build app
689
+ * Create vuepress build app.
598
690
  */
599
691
  declare const createBuildApp: (config: AppConfig) => BuildApp;
600
692
 
601
693
  /**
602
- * Create vuepress dev app
694
+ * Create vuepress dev app.
603
695
  */
604
696
  declare const createDevApp: (config: AppConfig) => DevApp;
605
697
 
606
- /**
607
- * Create directory util function
608
- */
609
- declare const createAppDirFunction: (baseDir: string) => AppDirFunction;
610
698
  /**
611
699
  * Resolve directory utils for vuepress app
612
700
  */
613
701
  declare const resolveAppDir: (options: AppOptions) => AppDir;
614
702
 
615
703
  /**
616
- * Resolve environment flags for vuepress app
704
+ * Create vuepress page object
617
705
  */
618
- declare const resolveAppEnv: (options: AppOptions, isBuild: boolean) => AppEnv;
619
-
620
- /**
621
- * Create app options with default values
622
- */
623
- declare const resolveAppOptions: ({ base, lang, title, description, head, locales, source, dest, temp, cache, public: publicDir, host, port, open, templateDev, shouldPreload, shouldPrefetch, templateBuild, bundler, debug, markdown, pagePatterns, permalinkPattern, plugins, theme, }: AppConfig) => AppOptions;
624
-
625
- /**
626
- * Resolve pages for vuepress app
627
- */
628
- declare const resolveAppPages: (app: App) => Promise<Page[]>;
629
-
630
- /**
631
- * Resolve site data for vuepress app
632
- *
633
- * Site data will also be used in client
634
- */
635
- declare const resolveAppSiteData: (options: AppOptions) => SiteData;
636
-
637
- /**
638
- * Resolve version of vuepress app
639
- */
640
- declare const resolveAppVersion: () => string;
641
-
642
- /**
643
- * Resolve write temp file util for vuepress app
644
- */
645
- declare const resolveAppWriteTemp: (dir: AppDir) => AppWriteTemp;
646
-
647
- /**
648
- * Resolve a plugin object according to name / path / module and config
649
- */
650
- declare const resolvePluginObject: <T extends PluginObject = PluginObject>(app: App, plugin: Plugin<T>) => T;
651
-
652
- /**
653
- * Resolve theme info and its parent theme info
654
- */
655
- declare const resolveThemeInfo: (app: App, theme: Theme) => ThemeInfo;
656
-
657
706
  declare const createPage: (app: App, options: PageOptions) => Promise<Page>;
658
707
 
659
- /**
660
- * Infer page path according to file path
661
- */
662
- declare const inferPagePath: ({ app, filePathRelative, }: {
663
- app: App;
664
- filePathRelative: string | null;
665
- }) => {
666
- pathInferred: string | null;
667
- pathLocale: string;
668
- };
669
-
670
- /**
671
- * Render page content and extract related info
672
- */
673
- declare const renderPageContent: ({ app, content, filePath, filePathRelative, options, }: {
674
- app: App;
675
- content: string;
676
- filePath: string | null;
677
- filePathRelative: string | null;
678
- options: PageOptions;
679
- }) => {
680
- contentRendered: string;
681
- deps: string[];
682
- markdownEnv: Record<string, unknown>;
683
- frontmatter: PageFrontmatter;
684
- headers: MarkdownHeader[];
685
- links: MarkdownLink[];
686
- sfcBlocks: MarkdownSfcBlocks;
687
- title: string;
688
- };
689
-
690
- /**
691
- * Resolve page data file path
692
- */
693
- declare const resolvePageChunkInfo: ({ app, htmlFilePathRelative, }: {
694
- app: App;
695
- htmlFilePathRelative: string;
696
- }) => {
697
- chunkFilePath: string;
698
- chunkFilePathRelative: string;
699
- chunkName: string;
700
- };
701
-
702
- /**
703
- * Resolve page component and related info
704
- */
705
- declare const resolvePageComponentInfo: ({ app, htmlFilePathRelative, }: {
706
- app: App;
707
- htmlFilePathRelative: string;
708
- }) => Promise<{
709
- componentFilePath: string;
710
- componentFilePathRelative: string;
711
- }>;
712
-
713
- /**
714
- * Resolve page date according to frontmatter or file path
715
- *
716
- * It will be resolved as 'yyyy-MM-dd' format
717
- */
718
- declare const resolvePageDate: ({ frontmatter, filePathRelative, }: {
719
- frontmatter: PageFrontmatter;
720
- filePathRelative: string | null;
721
- }) => string;
722
-
723
- /**
724
- * Resolve page file content according to filePath or options content
725
- */
726
- declare const resolvePageFileContent: ({ filePath, options, }: {
727
- filePath: string | null;
728
- options: PageOptions;
729
- }) => Promise<string>;
730
-
731
- /**
732
- * Resolve absolute and relative path of page file
733
- */
734
- declare const resolvePageFilePath: ({ app, options, }: {
735
- app: App;
736
- options: PageOptions;
737
- }) => {
738
- filePath: string | null;
739
- filePathRelative: string | null;
740
- };
741
-
742
- /**
743
- * Resolve page rendered html file path
744
- */
745
- declare const resolvePageHtmlInfo: ({ app, path: pagePath, }: {
746
- app: App;
747
- path: string;
748
- }) => {
749
- htmlFilePath: string;
750
- htmlFilePathRelative: string;
751
- };
752
-
753
- /**
754
- * Resolve language of page
755
- */
756
- declare const resolvePageLang: ({ app, frontmatter, pathLocale, }: {
757
- app: App;
758
- frontmatter: PageFrontmatter;
759
- pathLocale: string;
760
- }) => string;
761
-
762
- /**
763
- * Resolve the final route path of a page
764
- */
765
- declare const resolvePagePath: ({ permalink, pathInferred, options, }: {
766
- permalink: string | null;
767
- pathInferred: string | null;
768
- options: PageOptions;
769
- }) => string;
770
-
771
- /**
772
- * Resolve page permalink from frontmatter / options / pattern
773
- */
774
- declare const resolvePagePermalink: ({ app, frontmatter, slug, date, pathInferred, pathLocale, }: {
775
- app: App;
776
- frontmatter: PageFrontmatter;
777
- slug: string;
778
- date: string;
779
- pathInferred: string | null;
780
- pathLocale: string;
781
- }) => string | null;
782
-
783
- /**
784
- * Resolve page route meta
785
- */
786
- declare const resolvePageRouteMeta: ({ frontmatter, }: {
787
- frontmatter: PageFrontmatter;
788
- }) => Record<string, unknown>;
789
-
790
- /**
791
- * Resolve page slug from filename
792
- */
793
- declare const resolvePageSlug: ({ filePathRelative, }: {
794
- filePathRelative: string | null;
795
- }) => string;
796
-
797
- /**
798
- * Create hook queue for plugin system
799
- */
800
- declare const createHookQueue: <T extends HooksName>(name: T) => HookQueue<T>;
801
-
802
- declare const createPluginApi: () => PluginApi;
803
-
804
- declare const createPluginApiHooks: () => PluginApi["hooks"];
805
-
806
- declare const createPluginApiRegisterHooks: (plugins: PluginApi["plugins"], hooks: PluginApi["hooks"]) => PluginApi["registerHooks"];
807
-
808
- /**
809
- * Normalize alias and define hook
810
- */
811
- declare const normalizeAliasDefineHook: (hook: AliasDefineHook["exposed"]) => AliasDefineHook["normalized"];
812
-
813
- /**
814
- * Normalize hook for client config file
815
- */
816
- declare const normalizeClientConfigFileHook: (hook: ClientConfigFileHook["exposed"]) => ClientConfigFileHook["normalized"];
817
-
818
- export { type AliasDefineHook, type App, type AppConfig, type AppConfigBuild, type AppConfigCommon, type AppConfigDev, type AppDir, type AppDirFunction, type AppEnv, type AppOptions, type AppWriteTemp, type BuildApp, type Bundler, type ClientConfigFileHook, type DevApp, type ExtendsHook, type Hook, type HookItem, type HookQueue, type Hooks, type HooksExposed, type HooksName, type HooksNormalized, type HooksResult, type LifeCycleHook, type Page, type PageOptions, type Plugin, type PluginApi, type PluginConfig, type PluginFunction, type PluginObject, type Theme, type ThemeFunction, type ThemeInfo, type ThemeObject, appInit, appPrepare, appUse, createAppDirFunction, createBaseApp, createBuildApp, createDevApp, createHookQueue, createPage, createPluginApi, createPluginApiHooks, createPluginApiRegisterHooks, inferPagePath, normalizeAliasDefineHook, normalizeClientConfigFileHook, prepareClientConfigs, preparePageChunk, preparePageComponent, prepareRoutes, prepareSiteData, renderPageContent, resolveAppDir, resolveAppEnv, resolveAppOptions, resolveAppPages, resolveAppSiteData, resolveAppVersion, resolveAppWriteTemp, resolvePageChunkInfo, resolvePageComponentInfo, resolvePageDate, resolvePageFileContent, resolvePageFilePath, resolvePageHtmlInfo, resolvePageLang, resolvePagePath, resolvePagePermalink, resolvePageRouteMeta, resolvePageSlug, resolvePluginObject, resolveThemeInfo };
708
+ export { type AliasDefineHook, 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, type DevApp, type ExtendsHook, type Hook, type HookItem, type HookQueue, type Hooks, type HooksExposed, type HooksName, type HooksNormalized, type HooksResult, type LifeCycleHook, type Page, type PageOptions, type Plugin, type PluginApi, type PluginConfig, type PluginFunction, type PluginObject, type Theme, type ThemeFunction, type ThemeInfo, type ThemeObject, createBaseApp, createBuildApp, createDevApp, createPage, preparePageChunk, preparePageComponent, prepareRoutes, resolveAppDir };
package/dist/index.js CHANGED
@@ -38,123 +38,12 @@ export { comp, data }
38
38
  await app.writeTemp(page.chunkFilePathRelative, content);
39
39
  };
40
40
 
41
- // src/app/prepare/preparePageComponent.ts
42
- var preparePageComponent = async (app, page) => {
43
- await app.writeTemp(
44
- page.componentFilePathRelative,
45
- [
46
- // #688: wrap the content of `<template>` with a `<div>` to avoid some potential issues of fragment component
47
- `${page.sfcBlocks.template?.tagOpen}<div>${page.sfcBlocks.template?.contentStripped}</div>${page.sfcBlocks.template?.tagClose}
48
- `,
49
- // hoist `<script>`, `<style>` and other custom blocks
50
- page.sfcBlocks.script?.content,
51
- page.sfcBlocks.scriptSetup?.content,
52
- ...page.sfcBlocks.styles.map((item) => item.content),
53
- ...page.sfcBlocks.customBlocks.map((item) => item.content)
54
- ].join("\n")
55
- );
56
- };
57
-
58
- // src/app/prepare/prepareRoutes.ts
59
- import { normalizeRoutePath } from "@vuepress/shared";
60
- var HMR_CODE2 = `
61
- if (import.meta.webpackHot) {
62
- import.meta.webpackHot.accept()
63
- if (__VUE_HMR_RUNTIME__.updateRoutes) {
64
- __VUE_HMR_RUNTIME__.updateRoutes(routes)
65
- }
66
- if (__VUE_HMR_RUNTIME__.updateRedirects) {
67
- __VUE_HMR_RUNTIME__.updateRedirects(redirects)
68
- }
69
- }
70
-
71
- if (import.meta.hot) {
72
- import.meta.hot.accept(({ routes, redirects }) => {
73
- __VUE_HMR_RUNTIME__.updateRoutes(routes)
74
- __VUE_HMR_RUNTIME__.updateRedirects(redirects)
75
- })
76
- }
77
- `;
78
- var resolvePageRedirects = ({ path: path9, pathInferred }) => {
79
- const redirectsSet = /* @__PURE__ */ new Set();
80
- if (pathInferred !== null) {
81
- const normalizedPathInferred = normalizeRoutePath(pathInferred);
82
- const encodedPathInferred = encodeURI(normalizedPathInferred);
83
- if (normalizedPathInferred !== path9 && encodedPathInferred !== path9) {
84
- redirectsSet.add(encodedPathInferred);
85
- }
86
- }
87
- return Array.from(redirectsSet);
88
- };
89
- var prepareRoutes = async (app) => {
90
- let content = `export const redirects = JSON.parse(${JSON.stringify(
91
- JSON.stringify(
92
- Object.fromEntries(
93
- app.pages.flatMap(
94
- (page) => resolvePageRedirects(page).map((redirect) => [redirect, page.path])
95
- )
96
- )
97
- )
98
- )})
99
-
100
- export const routes = Object.fromEntries([
101
- ${app.pages.map(
102
- ({ chunkFilePath, chunkName, path: path9, routeMeta }) => ` [${JSON.stringify(path9)}, { loader: () => import(${chunkName ? `/* webpackChunkName: "${chunkName}" */` : ""}${JSON.stringify(chunkFilePath)}), meta: ${JSON.stringify(routeMeta)} }],`
103
- ).join("\n")}
104
- ]);
105
- `;
106
- if (app.env.isDev) {
107
- content += HMR_CODE2;
108
- }
109
- await app.writeTemp("internal/routes.js", content);
110
- };
111
-
112
- // src/app/prepare/prepareSiteData.ts
113
- var HMR_CODE3 = `
114
- if (import.meta.webpackHot) {
115
- import.meta.webpackHot.accept()
116
- if (__VUE_HMR_RUNTIME__.updateSiteData) {
117
- __VUE_HMR_RUNTIME__.updateSiteData(siteData)
118
- }
119
- }
120
-
121
- if (import.meta.hot) {
122
- import.meta.hot.accept(({ siteData }) => {
123
- __VUE_HMR_RUNTIME__.updateSiteData(siteData)
124
- })
125
- }
126
- `;
127
- var prepareSiteData = async (app) => {
128
- let content = `export const siteData = JSON.parse(${JSON.stringify(
129
- JSON.stringify(app.siteData)
130
- )})
131
- `;
132
- if (app.env.isDev) {
133
- content += HMR_CODE3;
134
- }
135
- await app.writeTemp("internal/siteData.js", content);
136
- };
137
-
138
- // src/app/appInit.ts
139
- import { debug as debug3 } from "@vuepress/utils";
140
-
141
- // src/app/resolveAppMarkdown.ts
142
- import { createMarkdown } from "@vuepress/markdown";
143
- var resolveAppMarkdown = async (app) => {
144
- await app.pluginApi.hooks.extendsMarkdownOptions.process(
145
- app.options.markdown,
146
- app
147
- );
148
- const markdown = createMarkdown(app.options.markdown);
149
- await app.pluginApi.hooks.extendsMarkdown.process(markdown, app);
150
- return markdown;
151
- };
152
-
153
- // src/app/resolveAppPages.ts
154
- import { debug as debug2, globby } from "@vuepress/utils";
155
-
156
41
  // src/page/inferPagePath.ts
157
- import { ensureLeadingSlash, resolveLocalePath } from "@vuepress/shared";
42
+ import {
43
+ ensureLeadingSlash,
44
+ inferRoutePath,
45
+ resolveLocalePath
46
+ } from "@vuepress/shared";
158
47
  var inferPagePath = ({
159
48
  app,
160
49
  filePathRelative
@@ -165,7 +54,7 @@ var inferPagePath = ({
165
54
  pathLocale: "/"
166
55
  };
167
56
  }
168
- const pathInferred = ensureLeadingSlash(filePathRelative).replace(/\.md$/, ".html").replace(/\/(README|index).html$/i, "/");
57
+ const pathInferred = inferRoutePath(ensureLeadingSlash(filePathRelative));
169
58
  const pathLocale = resolveLocalePath(app.siteData.locales, pathInferred);
170
59
  return {
171
60
  pathInferred,
@@ -173,9 +62,9 @@ var inferPagePath = ({
173
62
  };
174
63
  };
175
64
 
176
- // src/page/renderPageContent.ts
65
+ // src/page/parsePageContent.ts
177
66
  import { omit } from "@vuepress/shared";
178
- var renderPageContent = ({
67
+ var parsePageContent = ({
179
68
  app,
180
69
  content,
181
70
  filePath,
@@ -220,6 +109,7 @@ var renderPageContent = ({
220
109
  "frontmatter"
221
110
  ),
222
111
  sfcBlocks,
112
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-template-expression -- the title from frontmatter is not guaranteed to be a string
223
113
  title: frontmatter.title ? `${frontmatter.title}` : title
224
114
  };
225
115
  };
@@ -242,7 +132,7 @@ var resolvePageChunkInfo = ({
242
132
 
243
133
  // src/page/resolvePageComponentInfo.ts
244
134
  import { path as path2 } from "@vuepress/utils";
245
- var resolvePageComponentInfo = async ({
135
+ var resolvePageComponentInfo = ({
246
136
  app,
247
137
  htmlFilePathRelative
248
138
  }) => {
@@ -257,8 +147,31 @@ var resolvePageComponentInfo = async ({
257
147
  };
258
148
  };
259
149
 
150
+ // src/page/resolvePageContent.ts
151
+ import { isString } from "@vuepress/shared";
152
+ import { debug, fs } from "@vuepress/utils";
153
+ var log = debug("vuepress:core/page");
154
+ var FALLBACK_CONTENT = "";
155
+ var resolvePageContent = async ({
156
+ filePath,
157
+ options
158
+ }) => {
159
+ if (isString(options.content)) {
160
+ return options.content;
161
+ }
162
+ if (filePath) {
163
+ try {
164
+ const content = await fs.readFile(filePath, "utf-8");
165
+ return content;
166
+ } catch (e) {
167
+ log(e instanceof Error ? e.message : e);
168
+ }
169
+ }
170
+ return FALLBACK_CONTENT;
171
+ };
172
+
260
173
  // src/page/resolvePageDate.ts
261
- import { formatDateString, isString } from "@vuepress/shared";
174
+ import { formatDateString, isString as isString2 } from "@vuepress/shared";
262
175
  import { path as path3 } from "@vuepress/utils";
263
176
  var FILENAME_DATE_RE = /^(\d{4})-(\d{1,2})(?:-(\d{1,2}))?-(.*)$/;
264
177
  var DIRNAME_DATE_RE = /(\d{4})\/(\d{1,2})(?:\/(\d{1,2}))?(\/|$)/;
@@ -277,7 +190,7 @@ var resolvePageDate = ({
277
190
  DEFAULT_DATE
278
191
  );
279
192
  }
280
- if (isString(frontmatter.date)) {
193
+ if (isString2(frontmatter.date)) {
281
194
  return formatDateString(frontmatter.date, DEFAULT_DATE);
282
195
  }
283
196
  if (filePathRelative === null) {
@@ -288,6 +201,7 @@ var resolvePageDate = ({
288
201
  const matches = filename.match(FILENAME_DATE_RE);
289
202
  if (matches) {
290
203
  return formatDateString(
204
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- unsafe indexed access
291
205
  `${matches[1]}-${matches[2]}-${matches[3] ?? "01"}`,
292
206
  DEFAULT_DATE
293
207
  );
@@ -298,6 +212,7 @@ var resolvePageDate = ({
298
212
  const matches = dirname.match(DIRNAME_DATE_RE);
299
213
  if (matches) {
300
214
  return formatDateString(
215
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- unsafe indexed access
301
216
  `${matches[1]}-${matches[2]}-${matches[3] ?? "01"}`,
302
217
  DEFAULT_DATE
303
218
  );
@@ -306,24 +221,6 @@ var resolvePageDate = ({
306
221
  return DEFAULT_DATE;
307
222
  };
308
223
 
309
- // src/page/resolvePageFileContent.ts
310
- import { debug, fs } from "@vuepress/utils";
311
- var log = debug("vuepress:core/page");
312
- var resolvePageFileContent = async ({
313
- filePath,
314
- options
315
- }) => {
316
- if (filePath) {
317
- try {
318
- const content = await fs.readFile(filePath, "utf-8");
319
- return content;
320
- } catch (e) {
321
- log(e instanceof Error ? e.message : e);
322
- }
323
- }
324
- return options.content ?? "";
325
- };
326
-
327
224
  // src/page/resolvePageFilePath.ts
328
225
  import { logger, path as path4 } from "@vuepress/utils";
329
226
  var resolvePageFilePath = ({
@@ -355,7 +252,7 @@ var resolvePageHtmlInfo = ({
355
252
  }) => {
356
253
  const path9 = decodeURI(pagePath);
357
254
  const htmlFilePathRelative = removeLeadingSlash(
358
- path9.endsWith("/") ? path9 + "index.html" : path9.endsWith(".html") ? path9 : path9 + ".html"
255
+ path9.endsWith("/") ? `${path9}index.html` : path9.endsWith(".html") ? path9 : `${path9}.html`
359
256
  );
360
257
  const htmlFilePath = app.dir.dest(htmlFilePathRelative);
361
258
  return {
@@ -365,13 +262,13 @@ var resolvePageHtmlInfo = ({
365
262
  };
366
263
 
367
264
  // src/page/resolvePageLang.ts
368
- import { isString as isString2 } from "@vuepress/shared";
265
+ import { isString as isString3 } from "@vuepress/shared";
369
266
  var resolvePageLang = ({
370
267
  app,
371
268
  frontmatter,
372
269
  pathLocale
373
270
  }) => {
374
- if (isString2(frontmatter.lang) && frontmatter.lang) {
271
+ if (isString3(frontmatter.lang) && frontmatter.lang) {
375
272
  return frontmatter.lang;
376
273
  }
377
274
  return app.siteData.locales[pathLocale]?.lang ?? app.siteData.lang;
@@ -394,7 +291,7 @@ var resolvePagePath = ({
394
291
  };
395
292
 
396
293
  // src/page/resolvePagePermalink.ts
397
- import { ensureLeadingSlash as ensureLeadingSlash2, isString as isString3 } from "@vuepress/shared";
294
+ import { ensureLeadingSlash as ensureLeadingSlash2, isString as isString4 } from "@vuepress/shared";
398
295
  import { path as path5 } from "@vuepress/utils";
399
296
  var resolvePagePermalink = ({
400
297
  app,
@@ -407,14 +304,14 @@ var resolvePagePermalink = ({
407
304
  if (frontmatter.permalink === null) {
408
305
  return null;
409
306
  }
410
- if (isString3(frontmatter.permalink)) {
307
+ if (isString4(frontmatter.permalink)) {
411
308
  return frontmatter.permalink;
412
309
  }
413
310
  if (frontmatter.permalinkPattern === null) {
414
311
  return null;
415
312
  }
416
313
  const permalinkPattern = frontmatter.permalinkPattern || app.options.permalinkPattern;
417
- if (!isString3(permalinkPattern)) {
314
+ if (!isString4(permalinkPattern)) {
418
315
  return null;
419
316
  }
420
317
  const [year, month, day] = date.split("-");
@@ -451,7 +348,7 @@ var createPage = async (app, options) => {
451
348
  app,
452
349
  options
453
350
  });
454
- const content = await resolvePageFileContent({ filePath, options });
351
+ const content = await resolvePageContent({ filePath, options });
455
352
  const {
456
353
  contentRendered,
457
354
  deps,
@@ -461,7 +358,7 @@ var createPage = async (app, options) => {
461
358
  markdownEnv,
462
359
  sfcBlocks,
463
360
  title
464
- } = renderPageContent({
361
+ } = parsePageContent({
465
362
  app,
466
363
  content,
467
364
  filePath,
@@ -486,7 +383,7 @@ var createPage = async (app, options) => {
486
383
  app,
487
384
  path: path9
488
385
  });
489
- const { componentFilePath, componentFilePathRelative } = await resolvePageComponentInfo({
386
+ const { componentFilePath, componentFilePathRelative } = resolvePageComponentInfo({
490
387
  app,
491
388
  htmlFilePathRelative
492
389
  });
@@ -534,7 +431,123 @@ var createPage = async (app, options) => {
534
431
  return page;
535
432
  };
536
433
 
434
+ // src/page/renderPageSfcBlocksToVue.ts
435
+ var renderPageSfcBlocksToVue = (sfcBlocks) => [
436
+ // #688: wrap the content of `<template>` with a `<div>` to avoid some potential issues of fragment component
437
+ `${sfcBlocks.template?.tagOpen}<div>${sfcBlocks.template?.contentStripped}</div>${sfcBlocks.template?.tagClose}
438
+ `,
439
+ // hoist `<script>`, `<style>` and other custom blocks
440
+ sfcBlocks.script?.content,
441
+ sfcBlocks.scriptSetup?.content,
442
+ ...sfcBlocks.styles.map((item) => item.content),
443
+ ...sfcBlocks.customBlocks.map((item) => item.content)
444
+ ].join("\n");
445
+
446
+ // src/app/prepare/preparePageComponent.ts
447
+ var preparePageComponent = async (app, page) => {
448
+ await app.writeTemp(
449
+ page.componentFilePathRelative,
450
+ renderPageSfcBlocksToVue(page.sfcBlocks)
451
+ );
452
+ };
453
+
454
+ // src/app/prepare/prepareRoutes.ts
455
+ import { normalizeRoutePath } from "@vuepress/shared";
456
+ var HMR_CODE2 = `
457
+ if (import.meta.webpackHot) {
458
+ import.meta.webpackHot.accept()
459
+ if (__VUE_HMR_RUNTIME__.updateRoutes) {
460
+ __VUE_HMR_RUNTIME__.updateRoutes(routes)
461
+ }
462
+ if (__VUE_HMR_RUNTIME__.updateRedirects) {
463
+ __VUE_HMR_RUNTIME__.updateRedirects(redirects)
464
+ }
465
+ }
466
+
467
+ if (import.meta.hot) {
468
+ import.meta.hot.accept(({ routes, redirects }) => {
469
+ __VUE_HMR_RUNTIME__.updateRoutes(routes)
470
+ __VUE_HMR_RUNTIME__.updateRedirects(redirects)
471
+ })
472
+ }
473
+ `;
474
+ var resolvePageRedirects = ({ path: path9, pathInferred }) => {
475
+ const redirectsSet = /* @__PURE__ */ new Set();
476
+ if (pathInferred !== null) {
477
+ const normalizedPathInferred = normalizeRoutePath(pathInferred);
478
+ const encodedPathInferred = encodeURI(normalizedPathInferred);
479
+ if (normalizedPathInferred !== path9 && encodedPathInferred !== path9) {
480
+ redirectsSet.add(encodedPathInferred);
481
+ }
482
+ }
483
+ return Array.from(redirectsSet);
484
+ };
485
+ var prepareRoutes = async (app) => {
486
+ let content = `export const redirects = JSON.parse(${JSON.stringify(
487
+ JSON.stringify(
488
+ Object.fromEntries(
489
+ app.pages.flatMap(
490
+ (page) => resolvePageRedirects(page).map((redirect) => [redirect, page.path])
491
+ )
492
+ )
493
+ )
494
+ )})
495
+
496
+ export const routes = Object.fromEntries([
497
+ ${app.pages.map(
498
+ ({ chunkFilePath, chunkName, path: path9, routeMeta }) => ` [${JSON.stringify(path9)}, { loader: () => import(${chunkName ? `/* webpackChunkName: "${chunkName}" */` : ""}${JSON.stringify(chunkFilePath)}), meta: ${JSON.stringify(routeMeta)} }],`
499
+ ).join("\n")}
500
+ ]);
501
+ `;
502
+ if (app.env.isDev) {
503
+ content += HMR_CODE2;
504
+ }
505
+ await app.writeTemp("internal/routes.js", content);
506
+ };
507
+
508
+ // src/app/prepare/prepareSiteData.ts
509
+ var HMR_CODE3 = `
510
+ if (import.meta.webpackHot) {
511
+ import.meta.webpackHot.accept()
512
+ if (__VUE_HMR_RUNTIME__.updateSiteData) {
513
+ __VUE_HMR_RUNTIME__.updateSiteData(siteData)
514
+ }
515
+ }
516
+
517
+ if (import.meta.hot) {
518
+ import.meta.hot.accept(({ siteData }) => {
519
+ __VUE_HMR_RUNTIME__.updateSiteData(siteData)
520
+ })
521
+ }
522
+ `;
523
+ var prepareSiteData = async (app) => {
524
+ let content = `export const siteData = JSON.parse(${JSON.stringify(
525
+ JSON.stringify(app.siteData)
526
+ )})
527
+ `;
528
+ if (app.env.isDev) {
529
+ content += HMR_CODE3;
530
+ }
531
+ await app.writeTemp("internal/siteData.js", content);
532
+ };
533
+
534
+ // src/app/appInit.ts
535
+ import { debug as debug3 } from "@vuepress/utils";
536
+
537
+ // src/app/resolveAppMarkdown.ts
538
+ import { createMarkdown } from "@vuepress/markdown";
539
+ var resolveAppMarkdown = async (app) => {
540
+ await app.pluginApi.hooks.extendsMarkdownOptions.process(
541
+ app.options.markdown,
542
+ app
543
+ );
544
+ const markdown = createMarkdown(app.options.markdown);
545
+ await app.pluginApi.hooks.extendsMarkdown.process(markdown, app);
546
+ return markdown;
547
+ };
548
+
537
549
  // src/app/resolveAppPages.ts
550
+ import { debug as debug2, globby } from "@vuepress/utils";
538
551
  var log2 = debug2("vuepress:core/app");
539
552
  var resolveAppPages = async (app) => {
540
553
  log2("resolveAppPages start");
@@ -542,13 +555,18 @@ var resolveAppPages = async (app) => {
542
555
  absolute: true,
543
556
  cwd: app.dir.source()
544
557
  });
558
+ let hasNotFoundPage = false;
545
559
  const pages = await Promise.all(
546
- pageFilePaths.map((filePath) => createPage(app, { filePath }))
560
+ pageFilePaths.map(async (filePath) => {
561
+ const page = await createPage(app, { filePath });
562
+ if (page.path === "/404.html") {
563
+ page.frontmatter.layout ??= "NotFound";
564
+ hasNotFoundPage = true;
565
+ }
566
+ return page;
567
+ })
547
568
  );
548
- const notFoundPage = pages.find((page) => page.path === "/404.html");
549
- if (notFoundPage) {
550
- notFoundPage.frontmatter.layout ??= "NotFound";
551
- } else {
569
+ if (!hasNotFoundPage) {
552
570
  pages.push(
553
571
  await createPage(app, {
554
572
  path: "/404.html",
@@ -733,6 +751,7 @@ var createPluginApiRegisterHooks = (plugins, hooks) => () => {
733
751
  if (hooks[key] && commonHooks[key]) {
734
752
  hooks[key].add({
735
753
  pluginName,
754
+ // @ts-expect-error: the type could not be narrowed correctly
736
755
  hook: commonHooks[key]
737
756
  });
738
757
  }
@@ -754,12 +773,10 @@ var createPluginApi = () => {
754
773
  };
755
774
 
756
775
  // src/app/resolveAppDir.ts
757
- import { createRequire } from "module";
776
+ import { createRequire } from "node:module";
758
777
  import { path as path7 } from "@vuepress/utils";
759
778
  var require2 = createRequire(import.meta.url);
760
- var createAppDirFunction = (baseDir) => {
761
- return (...args) => path7.resolve(baseDir, ...args);
762
- };
779
+ var createAppDirFunction = (baseDir) => (...args) => path7.resolve(baseDir, ...args);
763
780
  var resolveAppDir = (options) => {
764
781
  const cache = createAppDirFunction(options.cache);
765
782
  const temp = createAppDirFunction(options.temp);
@@ -780,14 +797,14 @@ var resolveAppDir = (options) => {
780
797
  };
781
798
 
782
799
  // src/app/resolveAppEnv.ts
783
- var resolveAppEnv = (options, isBuild) => ({
784
- isBuild,
785
- isDev: !isBuild,
800
+ var resolveAppEnv = (options) => ({
801
+ isBuild: false,
802
+ isDev: false,
786
803
  isDebug: options.debug
787
804
  });
788
805
 
789
806
  // src/app/resolveAppOptions.ts
790
- import { createRequire as createRequire2 } from "module";
807
+ import { createRequire as createRequire2 } from "node:module";
791
808
  import { path as path8, templateRenderer } from "@vuepress/utils";
792
809
  var require3 = createRequire2(import.meta.url);
793
810
  var resolveAppOptions = ({
@@ -817,6 +834,7 @@ var resolveAppOptions = ({
817
834
  templateBuild = path8.normalize(
818
835
  require3.resolve("@vuepress/client/templates/build.html")
819
836
  ),
837
+ templateBuildRenderer = templateRenderer,
820
838
  // common config
821
839
  bundler,
822
840
  debug: debug7 = false,
@@ -844,7 +862,7 @@ var resolveAppOptions = ({
844
862
  shouldPreload,
845
863
  shouldPrefetch,
846
864
  templateBuild,
847
- templateBuildRenderer: templateRenderer,
865
+ templateBuildRenderer,
848
866
  bundler,
849
867
  debug: debug7,
850
868
  markdown,
@@ -865,7 +883,7 @@ var resolveAppSiteData = (options) => ({
865
883
  });
866
884
 
867
885
  // src/app/resolveAppVersion.ts
868
- import { createRequire as createRequire3 } from "module";
886
+ import { createRequire as createRequire3 } from "node:module";
869
887
  import { fs as fs3 } from "@vuepress/utils";
870
888
  var require4 = createRequire3(import.meta.url);
871
889
  var resolveAppVersion = () => {
@@ -917,10 +935,10 @@ var setupAppThemeAndPlugins = (app, config) => {
917
935
  };
918
936
 
919
937
  // src/app/createBaseApp.ts
920
- var createBaseApp = (config, isBuild = false) => {
938
+ var createBaseApp = (config) => {
921
939
  const options = resolveAppOptions(config);
922
940
  const dir = resolveAppDir(options);
923
- const env = resolveAppEnv(options, isBuild);
941
+ const env = resolveAppEnv(options);
924
942
  const pluginApi = createPluginApi();
925
943
  const siteData = resolveAppSiteData(options);
926
944
  const version = resolveAppVersion();
@@ -936,8 +954,8 @@ var createBaseApp = (config, isBuild = false) => {
936
954
  writeTemp,
937
955
  // methods
938
956
  use: (plugin) => appUse(app, plugin),
939
- init: () => appInit(app),
940
- prepare: () => appPrepare(app)
957
+ init: async () => appInit(app),
958
+ prepare: async () => appPrepare(app)
941
959
  };
942
960
  setupAppThemeAndPlugins(app, config);
943
961
  return app;
@@ -945,15 +963,17 @@ var createBaseApp = (config, isBuild = false) => {
945
963
 
946
964
  // src/app/createBuildApp.ts
947
965
  var createBuildApp = (config) => {
948
- const app = createBaseApp(config, true);
949
- app.build = () => app.options.bundler.build(app);
966
+ const app = createBaseApp(config);
967
+ app.env.isBuild = true;
968
+ app.build = async () => app.options.bundler.build(app);
950
969
  return app;
951
970
  };
952
971
 
953
972
  // src/app/createDevApp.ts
954
973
  var createDevApp = (config) => {
955
- const app = createBaseApp(config, false);
956
- app.dev = () => app.options.bundler.dev(app);
974
+ const app = createBaseApp(config);
975
+ app.env.isDev = true;
976
+ app.dev = async () => app.options.bundler.dev(app);
957
977
  return app;
958
978
  };
959
979
  export {
@@ -972,12 +992,13 @@ export {
972
992
  inferPagePath,
973
993
  normalizeAliasDefineHook,
974
994
  normalizeClientConfigFileHook,
995
+ parsePageContent,
975
996
  prepareClientConfigs,
976
997
  preparePageChunk,
977
998
  preparePageComponent,
978
999
  prepareRoutes,
979
1000
  prepareSiteData,
980
- renderPageContent,
1001
+ renderPageSfcBlocksToVue,
981
1002
  resolveAppDir,
982
1003
  resolveAppEnv,
983
1004
  resolveAppOptions,
@@ -987,8 +1008,8 @@ export {
987
1008
  resolveAppWriteTemp,
988
1009
  resolvePageChunkInfo,
989
1010
  resolvePageComponentInfo,
1011
+ resolvePageContent,
990
1012
  resolvePageDate,
991
- resolvePageFileContent,
992
1013
  resolvePageFilePath,
993
1014
  resolvePageHtmlInfo,
994
1015
  resolvePageLang,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/core",
3
- "version": "2.0.0-rc.15",
3
+ "version": "2.0.0-rc.16",
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
- "vue": "^3.4.37",
31
- "@vuepress/client": "2.0.0-rc.15",
32
- "@vuepress/markdown": "2.0.0-rc.15",
33
- "@vuepress/utils": "2.0.0-rc.15",
34
- "@vuepress/shared": "2.0.0-rc.15"
30
+ "vue": "^3.5.10",
31
+ "@vuepress/shared": "2.0.0-rc.16",
32
+ "@vuepress/utils": "2.0.0-rc.16",
33
+ "@vuepress/client": "2.0.0-rc.16",
34
+ "@vuepress/markdown": "2.0.0-rc.16"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"