@vuepress/core 2.0.0-beta.43 → 2.0.0-beta.46

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.
@@ -30,12 +30,8 @@ const appPrepare = async (app) => {
30
30
  await (0, prepare_1.prepareLayoutComponents)(app);
31
31
  // generate site data file
32
32
  await (0, prepare_1.prepareSiteData)(app);
33
- // generate client app enhances file
34
- await (0, prepare_1.prepareClientAppEnhances)(app);
35
- // generate client app root components file
36
- await (0, prepare_1.prepareClientAppRootComponents)(app);
37
- // generate client app setups file
38
- await (0, prepare_1.prepareClientAppSetups)(app);
33
+ // generate client configs file
34
+ await (0, prepare_1.prepareClientConfigs)(app);
39
35
  // plugin hook: onPrepared
40
36
  await app.pluginApi.hooks.onPrepared.process(app);
41
37
  log('prepare finish');
@@ -1,6 +1,4 @@
1
- export * from './prepareClientAppEnhances';
2
- export * from './prepareClientAppRootComponents';
3
- export * from './prepareClientAppSetups';
1
+ export * from './prepareClientConfigs';
4
2
  export * from './prepareLayoutComponents';
5
3
  export * from './preparePageComponent';
6
4
  export * from './preparePageData';
@@ -14,9 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./prepareClientAppEnhances"), exports);
18
- __exportStar(require("./prepareClientAppRootComponents"), exports);
19
- __exportStar(require("./prepareClientAppSetups"), exports);
17
+ __exportStar(require("./prepareClientConfigs"), exports);
20
18
  __exportStar(require("./prepareLayoutComponents"), exports);
21
19
  __exportStar(require("./preparePageComponent"), exports);
22
20
  __exportStar(require("./preparePageData"), exports);
@@ -0,0 +1,5 @@
1
+ import type { App } from '../../types';
2
+ /**
3
+ * Generate client configs temp file
4
+ */
5
+ export declare const prepareClientConfigs: (app: App) => Promise<void>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareClientConfigs = void 0;
4
+ /**
5
+ * Generate client configs temp file
6
+ */
7
+ const prepareClientConfigs = async (app) => {
8
+ // plugin hook: clientConfigFile
9
+ const clientConfigFiles = await app.pluginApi.hooks.clientConfigFile.process(app);
10
+ // generate client config files entry
11
+ const content = `\
12
+ ${clientConfigFiles
13
+ .map((filePath, index) => `import clientConfig${index} from '${filePath}'`)
14
+ .join('\n')}
15
+
16
+ export const clientConfigs = [
17
+ ${clientConfigFiles.map((_, index) => ` clientConfig${index},`).join('\n')}
18
+ ]
19
+ `;
20
+ await app.writeTemp('internal/clientConfigs.js', content);
21
+ };
22
+ exports.prepareClientConfigs = prepareClientConfigs;
@@ -7,7 +7,8 @@ exports.preparePageComponent = void 0;
7
7
  const preparePageComponent = async (app, page) => {
8
8
  await app.writeTemp(page.componentFilePathRelative, [
9
9
  // take the rendered markdown content as <template>
10
- `<template>${page.contentRendered}</template>\n`,
10
+ // #688: wrap the content with a <div> to avoid some potential issues of fragment component
11
+ `<template><div>${page.contentRendered}</div></template>\n`,
11
12
  // hoist `<script>`, `<style>` and other custom blocks
12
13
  ...page.hoistedTags,
13
14
  ].join('\n'));
@@ -14,10 +14,8 @@ const createPluginApiHooks = () => ({
14
14
  extendsPageOptions: (0, createHookQueue_1.createHookQueue)('extendsPageOptions'),
15
15
  extendsPage: (0, createHookQueue_1.createHookQueue)('extendsPage'),
16
16
  extendsBundlerOptions: (0, createHookQueue_1.createHookQueue)('extendsBundlerOptions'),
17
- // client files hooks
18
- clientAppEnhanceFiles: (0, createHookQueue_1.createHookQueue)('clientAppEnhanceFiles'),
19
- clientAppRootComponentFiles: (0, createHookQueue_1.createHookQueue)('clientAppRootComponentFiles'),
20
- clientAppSetupFiles: (0, createHookQueue_1.createHookQueue)('clientAppSetupFiles'),
17
+ // client config file hooks
18
+ clientConfigFile: (0, createHookQueue_1.createHookQueue)('clientConfigFile'),
21
19
  // bundler hooks
22
20
  alias: (0, createHookQueue_1.createHookQueue)('alias'),
23
21
  define: (0, createHookQueue_1.createHookQueue)('define'),
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createPluginApiRegisterHooks = void 0;
4
- const normalizeClientFilesHook_1 = require("./normalizeClientFilesHook");
4
+ const normalizeClientConfigFileHook_1 = require("./normalizeClientConfigFileHook");
5
5
  const normalizeReturnObjectHook_1 = require("./normalizeReturnObjectHook");
6
6
  const createPluginApiRegisterHooks = (plugins, hooks) => () => {
7
- plugins.forEach(({ name: pluginName, alias, define, clientAppEnhanceFiles, clientAppRootComponentFiles, clientAppSetupFiles, ...commonHooks }) => {
7
+ plugins.forEach(({ name: pluginName, alias, define, clientConfigFile, ...commonHooks }) => {
8
8
  /**
9
9
  * hooks that need to be normalized
10
10
  */
@@ -20,22 +20,10 @@ const createPluginApiRegisterHooks = (plugins, hooks) => () => {
20
20
  hook: (0, normalizeReturnObjectHook_1.normalizeReturnObjectHook)(define),
21
21
  });
22
22
  }
23
- if (clientAppEnhanceFiles) {
24
- hooks.clientAppEnhanceFiles.add({
23
+ if (clientConfigFile) {
24
+ hooks.clientConfigFile.add({
25
25
  pluginName,
26
- hook: (0, normalizeClientFilesHook_1.normalizeClientFilesHook)(clientAppEnhanceFiles),
27
- });
28
- }
29
- if (clientAppRootComponentFiles) {
30
- hooks.clientAppRootComponentFiles.add({
31
- pluginName,
32
- hook: (0, normalizeClientFilesHook_1.normalizeClientFilesHook)(clientAppRootComponentFiles),
33
- });
34
- }
35
- if (clientAppSetupFiles) {
36
- hooks.clientAppSetupFiles.add({
37
- pluginName,
38
- hook: (0, normalizeClientFilesHook_1.normalizeClientFilesHook)(clientAppSetupFiles),
26
+ hook: (0, normalizeClientConfigFileHook_1.normalizeClientConfigFileHook)(clientConfigFile),
39
27
  });
40
28
  }
41
29
  /**
@@ -2,5 +2,5 @@ export * from './createHookQueue';
2
2
  export * from './createPluginApi';
3
3
  export * from './createPluginApiHooks';
4
4
  export * from './createPluginApiRegisterHooks';
5
+ export * from './normalizeClientConfigFileHook';
5
6
  export * from './normalizeReturnObjectHook';
6
- export * from './normalizeClientFilesHook';
@@ -18,5 +18,5 @@ __exportStar(require("./createHookQueue"), exports);
18
18
  __exportStar(require("./createPluginApi"), exports);
19
19
  __exportStar(require("./createPluginApiHooks"), exports);
20
20
  __exportStar(require("./createPluginApiRegisterHooks"), exports);
21
+ __exportStar(require("./normalizeClientConfigFileHook"), exports);
21
22
  __exportStar(require("./normalizeReturnObjectHook"), exports);
22
- __exportStar(require("./normalizeClientFilesHook"), exports);
@@ -0,0 +1,5 @@
1
+ import type { ClientConfigFileHook } from '../types';
2
+ /**
3
+ * Normalize hook for client config file
4
+ */
5
+ export declare const normalizeClientConfigFileHook: (hook: ClientConfigFileHook['exposed']) => ClientConfigFileHook['normalized'];
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeClientConfigFileHook = void 0;
4
+ const shared_1 = require("@vuepress/shared");
5
+ const utils_1 = require("@vuepress/utils");
6
+ /**
7
+ * Normalize hook for client config file
8
+ */
9
+ const normalizeClientConfigFileHook = (hook) => async (app) => {
10
+ // resolve clientConfigFile result
11
+ const clientConfigFileResult = (0, shared_1.isFunction)(hook) ? await hook(app) : hook;
12
+ // filter files that do not exist
13
+ const isExisted = await utils_1.fs.pathExists(clientConfigFileResult);
14
+ if (!isExisted) {
15
+ throw utils_1.logger.createError(`client config file does not exist: ${clientConfigFileResult}`);
16
+ }
17
+ return clientConfigFileResult;
18
+ };
19
+ exports.normalizeClientConfigFileHook = normalizeClientConfigFileHook;
@@ -12,7 +12,7 @@ export declare type Hook<Exposed, Normalized = Exposed, Result = Normalized exte
12
12
  };
13
13
  export declare type LifeCycleHook<T extends unknown[] = []> = Hook<(app: App, ...args: T) => PromiseOrNot<void>>;
14
14
  export declare type ExtendsHook<T> = Hook<(extendable: T, app: App) => PromiseOrNot<void>>;
15
- export declare type ClientFilesHook = Hook<string | string[] | ((app: App) => PromiseOrNot<string | string[]>), (app: App) => Promise<string[]>>;
15
+ export declare type ClientConfigFileHook = Hook<string | ((app: App) => PromiseOrNot<string>), (app: App) => Promise<string>>;
16
16
  export declare type ReturnObjectHook = Hook<Record<string, any> | ((app: App) => PromiseOrNot<Record<string, any>>), (app: App) => Promise<Record<string, any>>>;
17
17
  /**
18
18
  * List of hooks
@@ -27,9 +27,7 @@ export interface Hooks {
27
27
  extendsPageOptions: ExtendsHook<PageOptions>;
28
28
  extendsPage: ExtendsHook<Page>;
29
29
  extendsBundlerOptions: ExtendsHook<any>;
30
- clientAppEnhanceFiles: ClientFilesHook;
31
- clientAppRootComponentFiles: ClientFilesHook;
32
- clientAppSetupFiles: ClientFilesHook;
30
+ clientConfigFile: ClientConfigFileHook;
33
31
  alias: ReturnObjectHook;
34
32
  define: ReturnObjectHook;
35
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/core",
3
- "version": "2.0.0-beta.43",
3
+ "version": "2.0.0-beta.46",
4
4
  "description": "Core package of VuePress",
5
5
  "keywords": [
6
6
  "vuepress",
@@ -22,13 +22,13 @@
22
22
  "lib"
23
23
  ],
24
24
  "dependencies": {
25
- "@vuepress/client": "2.0.0-beta.43",
26
- "@vuepress/markdown": "2.0.0-beta.43",
27
- "@vuepress/shared": "2.0.0-beta.43",
28
- "@vuepress/utils": "2.0.0-beta.43",
25
+ "@vuepress/client": "2.0.0-beta.46",
26
+ "@vuepress/markdown": "2.0.0-beta.46",
27
+ "@vuepress/shared": "2.0.0-beta.46",
28
+ "@vuepress/utils": "2.0.0-beta.46",
29
29
  "gray-matter": "^4.0.3",
30
30
  "toml": "^3.0.0",
31
- "vue": "^3.2.33"
31
+ "vue": "^3.2.35"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
@@ -1,5 +0,0 @@
1
- import type { App } from '../../types';
2
- /**
3
- * Generate client app enhances temp file
4
- */
5
- export declare const prepareClientAppEnhances: (app: App) => Promise<void>;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareClientAppEnhances = void 0;
4
- /**
5
- * Generate client app enhances temp file
6
- */
7
- const prepareClientAppEnhances = async (app) => {
8
- // plugin hook: clientAppEnhanceFiles
9
- const clientAppEnhanceFiles = await app.pluginApi.hooks.clientAppEnhanceFiles.process(app);
10
- // flat the hook result to get the file paths array
11
- const filePaths = clientAppEnhanceFiles.flat();
12
- // generate client app enhance files entry
13
- const content = `\
14
- ${filePaths
15
- .map((filePath, index) => `import clientAppEnhance${index} from '${filePath}'`)
16
- .join('\n')}
17
-
18
- export const clientAppEnhances = [
19
- ${filePaths.map((_, index) => ` clientAppEnhance${index},`).join('\n')}
20
- ]
21
- `;
22
- await app.writeTemp('internal/clientAppEnhances.js', content);
23
- };
24
- exports.prepareClientAppEnhances = prepareClientAppEnhances;
@@ -1,5 +0,0 @@
1
- import type { App } from '../../types';
2
- /**
3
- * Generate client app root components temp file
4
- */
5
- export declare const prepareClientAppRootComponents: (app: App) => Promise<void>;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareClientAppRootComponents = void 0;
4
- /**
5
- * Generate client app root components temp file
6
- */
7
- const prepareClientAppRootComponents = async (app) => {
8
- // plugin hook: clientAppRootComponentFiles
9
- const clientAppRootComponentFiles = await app.pluginApi.hooks.clientAppRootComponentFiles.process(app);
10
- // flat the hook result to get the file paths array
11
- const filePaths = clientAppRootComponentFiles.flat();
12
- // generate client app root components files entry
13
- const content = `\
14
- ${filePaths
15
- .map((filePath, index) => `import clientAppRootComponent${index} from '${filePath}'`)
16
- .join('\n')}
17
-
18
- export const clientAppRootComponents = [
19
- ${filePaths.map((_, index) => ` clientAppRootComponent${index},`).join('\n')}
20
- ]
21
- `;
22
- await app.writeTemp('internal/clientAppRootComponents.js', content);
23
- };
24
- exports.prepareClientAppRootComponents = prepareClientAppRootComponents;
@@ -1,5 +0,0 @@
1
- import type { App } from '../../types';
2
- /**
3
- * Generate client app setups temp file
4
- */
5
- export declare const prepareClientAppSetups: (app: App) => Promise<void>;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareClientAppSetups = void 0;
4
- /**
5
- * Generate client app setups temp file
6
- */
7
- const prepareClientAppSetups = async (app) => {
8
- // plugin hook: clientAppSetupFiles
9
- const clientAppSetupFiles = await app.pluginApi.hooks.clientAppSetupFiles.process(app);
10
- // flat the hook result to get the file paths array
11
- const filePaths = clientAppSetupFiles.flat();
12
- // generate client app setup files entry
13
- const content = `\
14
- ${filePaths
15
- .map((filePath, index) => `import clientAppSetup${index} from '${filePath}'`)
16
- .join('\n')}
17
-
18
- export const clientAppSetups = [
19
- ${filePaths.map((_, index) => ` clientAppSetup${index},`).join('\n')}
20
- ]
21
- `;
22
- await app.writeTemp('internal/clientAppSetups.js', content);
23
- };
24
- exports.prepareClientAppSetups = prepareClientAppSetups;
@@ -1,5 +0,0 @@
1
- import type { ClientFilesHook } from '../types';
2
- /**
3
- * Normalize hook for client files
4
- */
5
- export declare const normalizeClientFilesHook: (hook: ClientFilesHook['exposed']) => ClientFilesHook['normalized'];
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeClientFilesHook = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- const utils_1 = require("@vuepress/utils");
6
- /**
7
- * Normalize hook for client files
8
- */
9
- const normalizeClientFilesHook = (hook) => async (app) => {
10
- // resolve clientFiles result
11
- const clientFilesResult = (0, shared_1.isFunction)(hook) ? await hook(app) : hook;
12
- const clientFiles = (0, shared_1.isArray)(clientFilesResult)
13
- ? clientFilesResult
14
- : [clientFilesResult];
15
- // filter files that do not exist
16
- const result = [];
17
- for (const filePath of clientFiles) {
18
- const isExisted = await utils_1.fs.pathExists(filePath);
19
- if (isExisted) {
20
- result.push(filePath);
21
- }
22
- else {
23
- throw utils_1.logger.createError(`client file does not exist: ${filePath}`);
24
- }
25
- }
26
- return result;
27
- };
28
- exports.normalizeClientFilesHook = normalizeClientFilesHook;