vike 0.4.172-commit-605b4a5 → 0.4.172-commit-c1dcd5f

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.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.configDefinitionsBuiltInGlobal = exports.configDefinitionsBuiltIn = void 0;
4
4
  const utils_js_1 = require("../../../../utils.js");
5
+ const getConfigDefinedAt_js_1 = require("../../../../../../shared/page-configs/getConfigDefinedAt.js");
5
6
  const configDefinitionsBuiltIn = {
6
7
  onRenderHtml: {
7
8
  env: { server: true }
@@ -55,6 +56,9 @@ const configDefinitionsBuiltIn = {
55
56
  // We could make it { client: false } but we don't yet because of some legacy V0.4 design code
56
57
  env: { server: true, client: true, config: true, eager: true }
57
58
  },
59
+ clientHooks: {
60
+ env: { config: true }
61
+ },
58
62
  prerender: {
59
63
  env: { config: true }
60
64
  },
@@ -70,11 +74,22 @@ const configDefinitionsBuiltIn = {
70
74
  meta: {
71
75
  env: { config: true }
72
76
  },
73
- isClientSideRenderable: {
77
+ clientEntryLoaded: {
74
78
  env: { server: true, client: true, eager: true },
75
- _computed: (configValueSources) => isConfigSet(configValueSources, 'onRenderClient') &&
76
- isConfigSet(configValueSources, 'Page') &&
77
- !!getConfigEnv(configValueSources, 'Page')?.client
79
+ _computed: (configValueSources) => {
80
+ {
81
+ const source = getConfigValueSource(configValueSources, 'clientHooks');
82
+ if (source && source.value !== null) {
83
+ const { value } = source;
84
+ const definedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', 'clientHooks', source.definedAtFilePath);
85
+ (0, utils_js_1.assertUsage)(typeof value === 'boolean', `${definedAt} should be a boolean`);
86
+ return value;
87
+ }
88
+ }
89
+ return (isConfigSet(configValueSources, 'onRenderClient') &&
90
+ isConfigSet(configValueSources, 'Page') &&
91
+ !!getConfigEnv(configValueSources, 'Page')?.client);
92
+ }
78
93
  },
79
94
  onBeforeRenderEnv: {
80
95
  env: { client: true },
@@ -9,17 +9,17 @@ const globalContext_js_1 = require("../globalContext.js");
9
9
  const getConfigValue_js_1 = require("../../../shared/page-configs/getConfigValue.js");
10
10
  function analyzePage(pageFilesAll, pageConfig, pageId) {
11
11
  if (pageConfig) {
12
- const { isClientSideRenderable, isClientRouting } = (0, analyzeClientSide_js_1.analyzeClientSide)(pageConfig, pageFilesAll, pageId);
12
+ const { clientEntryLoaded, isClientRouting } = (0, analyzeClientSide_js_1.analyzeClientSide)(pageConfig, pageFilesAll, pageId);
13
13
  const clientEntries = [];
14
14
  const clientFilePath = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'client', 'string')?.value ?? null;
15
15
  if (clientFilePath)
16
16
  clientEntries.push(clientFilePath);
17
- if (isClientSideRenderable)
17
+ if (clientEntryLoaded)
18
18
  clientEntries.push((0, determineClientEntry_js_1.getVikeClientEntry)(isClientRouting));
19
19
  const clientDependencies = [];
20
20
  clientDependencies.push({
21
21
  id: (0, virtualFilePageConfigValuesAll_js_1.getVirtualFileIdPageConfigValuesAll)(pageConfig.pageId, true),
22
- onlyAssets: isClientSideRenderable ? false : true,
22
+ onlyAssets: clientEntryLoaded ? false : true,
23
23
  eagerlyImported: false
24
24
  });
25
25
  // In production we inject the import of the server virtual module with ?extractAssets inside the client virtual module
@@ -55,7 +55,7 @@ function analyzePage(pageFilesAll, pageConfig, pageId) {
55
55
  });
56
56
  });
57
57
  return {
58
- isHtmlOnly: !isClientSideRenderable,
58
+ isHtmlOnly: !clientEntryLoaded,
59
59
  isClientRouting,
60
60
  clientEntries,
61
61
  clientDependencies,
@@ -7,14 +7,14 @@ function analyzeClientSide(pageConfig, pageFilesAll, pageId) {
7
7
  // V1 design
8
8
  if (pageConfig) {
9
9
  const isClientRouting = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
10
- const isClientSideRenderable = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'isClientSideRenderable', 'boolean')?.value ?? false;
11
- return { isClientSideRenderable, isClientRouting };
10
+ const clientEntryLoaded = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'clientEntryLoaded', 'boolean')?.value ?? false;
11
+ return { clientEntryLoaded, isClientRouting };
12
12
  }
13
13
  else {
14
14
  // TODO/v1-release: remove
15
15
  // V0.4 design
16
16
  const { isHtmlOnly, isClientRouting } = (0, analyzePageClientSide_js_1.analyzePageClientSide)(pageFilesAll, pageId);
17
- return { isClientSideRenderable: !isHtmlOnly, isClientRouting };
17
+ return { clientEntryLoaded: !isHtmlOnly, isClientRouting };
18
18
  }
19
19
  }
20
20
  exports.analyzeClientSide = analyzeClientSide;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = exports.projectInfo = void 0;
4
- const PROJECT_VERSION = '0.4.172-commit-605b4a5';
4
+ const PROJECT_VERSION = '0.4.172-commit-c1dcd5f';
5
5
  exports.PROJECT_VERSION = PROJECT_VERSION;
6
6
  const projectInfo = {
7
7
  projectName: 'Vike',
@@ -7,6 +7,6 @@ async function isClientSideRoutable(pageId, pageContext) {
7
7
  sharedPageFilesAlreadyLoaded: false
8
8
  });
9
9
  const pageConfig = findPageConfig(pageContext._pageConfigs, pageId);
10
- const { isClientSideRenderable, isClientRouting } = analyzeClientSide(pageConfig, pageContext._pageFilesAll, pageId);
11
- return isClientSideRenderable && isClientRouting;
10
+ const { clientEntryLoaded, isClientRouting } = analyzeClientSide(pageConfig, pageContext._pageFilesAll, pageId);
11
+ return clientEntryLoaded && isClientRouting;
12
12
  }
@@ -7,7 +7,7 @@ export type { ConfigNameGlobal };
7
7
  export type { ConfigEffect };
8
8
  import type { ConfigEnvInternal, ConfigEnv, ConfigValueSources, DefinedAtFilePath } from '../../../../../../shared/page-configs/PageConfig.js';
9
9
  import type { Config, ConfigNameBuiltIn } from '../../../../../../shared/page-configs/Config.js';
10
- import type { ConfigDefinedAt } from '../../../../../../shared/page-configs/getConfigDefinedAt.js';
10
+ import { type ConfigDefinedAt } from '../../../../../../shared/page-configs/getConfigDefinedAt.js';
11
11
  /** The meta definition of a config.
12
12
  *
13
13
  * https://vike.dev/meta
@@ -1,6 +1,7 @@
1
1
  export { configDefinitionsBuiltIn };
2
2
  export { configDefinitionsBuiltInGlobal };
3
- import { assert } from '../../../../utils.js';
3
+ import { assert, assertUsage } from '../../../../utils.js';
4
+ import { getConfigDefinedAt } from '../../../../../../shared/page-configs/getConfigDefinedAt.js';
4
5
  const configDefinitionsBuiltIn = {
5
6
  onRenderHtml: {
6
7
  env: { server: true }
@@ -54,6 +55,9 @@ const configDefinitionsBuiltIn = {
54
55
  // We could make it { client: false } but we don't yet because of some legacy V0.4 design code
55
56
  env: { server: true, client: true, config: true, eager: true }
56
57
  },
58
+ clientHooks: {
59
+ env: { config: true }
60
+ },
57
61
  prerender: {
58
62
  env: { config: true }
59
63
  },
@@ -69,11 +73,22 @@ const configDefinitionsBuiltIn = {
69
73
  meta: {
70
74
  env: { config: true }
71
75
  },
72
- isClientSideRenderable: {
76
+ clientEntryLoaded: {
73
77
  env: { server: true, client: true, eager: true },
74
- _computed: (configValueSources) => isConfigSet(configValueSources, 'onRenderClient') &&
75
- isConfigSet(configValueSources, 'Page') &&
76
- !!getConfigEnv(configValueSources, 'Page')?.client
78
+ _computed: (configValueSources) => {
79
+ {
80
+ const source = getConfigValueSource(configValueSources, 'clientHooks');
81
+ if (source && source.value !== null) {
82
+ const { value } = source;
83
+ const definedAt = getConfigDefinedAt('Config', 'clientHooks', source.definedAtFilePath);
84
+ assertUsage(typeof value === 'boolean', `${definedAt} should be a boolean`);
85
+ return value;
86
+ }
87
+ }
88
+ return (isConfigSet(configValueSources, 'onRenderClient') &&
89
+ isConfigSet(configValueSources, 'Page') &&
90
+ !!getConfigEnv(configValueSources, 'Page')?.client);
91
+ }
77
92
  },
78
93
  onBeforeRenderEnv: {
79
94
  env: { client: true },
@@ -7,17 +7,17 @@ import { getGlobalContext } from '../globalContext.js';
7
7
  import { getConfigValueRuntime } from '../../../shared/page-configs/getConfigValue.js';
8
8
  function analyzePage(pageFilesAll, pageConfig, pageId) {
9
9
  if (pageConfig) {
10
- const { isClientSideRenderable, isClientRouting } = analyzeClientSide(pageConfig, pageFilesAll, pageId);
10
+ const { clientEntryLoaded, isClientRouting } = analyzeClientSide(pageConfig, pageFilesAll, pageId);
11
11
  const clientEntries = [];
12
12
  const clientFilePath = getConfigValueRuntime(pageConfig, 'client', 'string')?.value ?? null;
13
13
  if (clientFilePath)
14
14
  clientEntries.push(clientFilePath);
15
- if (isClientSideRenderable)
15
+ if (clientEntryLoaded)
16
16
  clientEntries.push(getVikeClientEntry(isClientRouting));
17
17
  const clientDependencies = [];
18
18
  clientDependencies.push({
19
19
  id: getVirtualFileIdPageConfigValuesAll(pageConfig.pageId, true),
20
- onlyAssets: isClientSideRenderable ? false : true,
20
+ onlyAssets: clientEntryLoaded ? false : true,
21
21
  eagerlyImported: false
22
22
  });
23
23
  // In production we inject the import of the server virtual module with ?extractAssets inside the client virtual module
@@ -53,7 +53,7 @@ function analyzePage(pageFilesAll, pageConfig, pageId) {
53
53
  });
54
54
  });
55
55
  return {
56
- isHtmlOnly: !isClientSideRenderable,
56
+ isHtmlOnly: !clientEntryLoaded,
57
57
  isClientRouting,
58
58
  clientEntries,
59
59
  clientDependencies,
@@ -2,6 +2,6 @@ export { analyzeClientSide };
2
2
  import type { PageConfigRuntime } from '../page-configs/PageConfig.js';
3
3
  import type { PageFile } from './getPageFileObject.js';
4
4
  declare function analyzeClientSide(pageConfig: PageConfigRuntime | null, pageFilesAll: PageFile[], pageId: string): {
5
- isClientSideRenderable: boolean;
5
+ clientEntryLoaded: boolean;
6
6
  isClientRouting: boolean;
7
7
  };
@@ -5,13 +5,13 @@ function analyzeClientSide(pageConfig, pageFilesAll, pageId) {
5
5
  // V1 design
6
6
  if (pageConfig) {
7
7
  const isClientRouting = getConfigValueRuntime(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
8
- const isClientSideRenderable = getConfigValueRuntime(pageConfig, 'isClientSideRenderable', 'boolean')?.value ?? false;
9
- return { isClientSideRenderable, isClientRouting };
8
+ const clientEntryLoaded = getConfigValueRuntime(pageConfig, 'clientEntryLoaded', 'boolean')?.value ?? false;
9
+ return { clientEntryLoaded, isClientRouting };
10
10
  }
11
11
  else {
12
12
  // TODO/v1-release: remove
13
13
  // V0.4 design
14
14
  const { isHtmlOnly, isClientRouting } = analyzePageClientSide(pageFilesAll, pageId);
15
- return { isClientSideRenderable: !isHtmlOnly, isClientRouting };
15
+ return { clientEntryLoaded: !isHtmlOnly, isClientRouting };
16
16
  }
17
17
  }
@@ -40,7 +40,7 @@ type HookName = HookNamePage | HookNameGlobal | HookNameOldDesign;
40
40
  type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRender' | 'onPageTransitionStart' | 'onPageTransitionEnd' | 'onRenderHtml' | 'onRenderClient' | 'guard' | 'data';
41
41
  type HookNameGlobal = 'onBeforePrerender' | 'onBeforeRoute' | 'onPrerenderStart';
42
42
  type HookNameOldDesign = 'render' | 'prerender';
43
- type ConfigNameBuiltIn = Exclude<keyof Config, keyof ConfigVikeUserProvided | 'onBeforeRoute' | 'onPrerenderStart'> | 'prerender' | 'isClientSideRenderable' | 'onBeforeRenderEnv' | 'dataEnv' | 'hooksTimeout';
43
+ type ConfigNameBuiltIn = Exclude<keyof Config, keyof ConfigVikeUserProvided | 'onBeforeRoute' | 'onPrerenderStart'> | 'prerender' | 'clientEntryLoaded' | 'onBeforeRenderEnv' | 'dataEnv' | 'hooksTimeout' | 'clientHooks';
44
44
  type Config = ConfigBuiltIn & Vike.Config & (VikePackages.ConfigVikeReact | VikePackages.ConfigVikeVue | VikePackages.ConfigVikeSolid | VikePackages.ConfigVikeSvelte | VikePackages.ConfigVikeAngular);
45
45
  /** Hook for fetching data.
46
46
  *
@@ -326,6 +326,12 @@ type ConfigBuiltIn = {
326
326
  * https://vike.dev/clientRouting
327
327
  */
328
328
  clientRouting?: boolean | ImportString;
329
+ /**
330
+ * Whether hooks are loaded on the client-side.
331
+ *
332
+ * https://vike.dev/clientHooks
333
+ */
334
+ clientHooks?: boolean | null | ImportString;
329
335
  /** Create new or modify existing configurations.
330
336
  *
331
337
  * https://vike.dev/meta
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- declare const PROJECT_VERSION: "0.4.172-commit-605b4a5";
3
+ declare const PROJECT_VERSION: "0.4.172-commit-c1dcd5f";
4
4
  declare const projectInfo: {
5
5
  projectName: "Vike";
6
- projectVersion: "0.4.172-commit-605b4a5";
6
+ projectVersion: "0.4.172-commit-c1dcd5f";
7
7
  };
@@ -1,6 +1,6 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- const PROJECT_VERSION = '0.4.172-commit-605b4a5';
3
+ const PROJECT_VERSION = '0.4.172-commit-c1dcd5f';
4
4
  const projectInfo = {
5
5
  projectName: 'Vike',
6
6
  projectVersion: PROJECT_VERSION
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.172-commit-605b4a5",
3
+ "version": "0.4.172-commit-c1dcd5f",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",