vike 0.4.144-commit-6aef8a6 → 0.4.144-commit-7f5e99a
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/cjs/__internal/index.js +6 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/cjs/node/plugin/plugins/commonConfig.js +0 -3
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -5
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +1 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +29 -42
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +14 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/helpers.js +1 -14
- package/dist/cjs/node/plugin/plugins/previewConfig.js +11 -2
- package/dist/cjs/node/prerender/runPrerender.js +16 -17
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +20 -6
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -2
- package/dist/cjs/node/runtime/renderPage.js +2 -2
- package/dist/cjs/node/runtime/utils.js +1 -1
- package/dist/cjs/node/shared/getClientEntryFilePath.js +2 -2
- package/dist/cjs/shared/addUrlComputedProps.js +24 -12
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +4 -6
- package/dist/cjs/shared/getPageFiles/getExports.js +3 -3
- package/dist/cjs/shared/hooks/getHook.js +1 -1
- package/dist/cjs/shared/page-configs/helpers/getConfigDefinedAtString.js +43 -0
- package/dist/cjs/shared/page-configs/helpers/getConfigValue.js +44 -0
- package/dist/cjs/shared/page-configs/helpers.js +33 -0
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +6 -8
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +2 -2
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +2 -2
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +11 -13
- package/dist/cjs/shared/route/index.js +3 -3
- package/dist/cjs/shared/route/loadPageRoutes.js +11 -10
- package/dist/cjs/shared/route/resolveRouteFunction.js +1 -1
- package/dist/cjs/shared/utils.js +1 -1
- package/dist/cjs/utils/{hasPropertyGetter.js → isPropertyGetter.js} +3 -3
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/__internal/index.d.ts +6 -3
- package/dist/esm/__internal/index.js +8 -3
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +2 -3
- package/dist/esm/client/client-routing-runtime/createPageContext.js +3 -3
- package/dist/esm/client/client-routing-runtime/entry.js +2 -2
- package/dist/esm/client/client-routing-runtime/getPageContext.d.ts +0 -1
- package/dist/esm/client/client-routing-runtime/getPageContext.js +4 -7
- package/dist/esm/client/client-routing-runtime/getPageId.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/getPageId.js +4 -7
- package/dist/esm/client/client-routing-runtime/history.d.ts +3 -1
- package/dist/esm/client/client-routing-runtime/history.js +26 -8
- package/dist/esm/client/client-routing-runtime/installClientRouter.d.ts +21 -0
- package/dist/esm/client/client-routing-runtime/{useClientRouter.js → installClientRouter.js} +248 -242
- package/dist/esm/client/client-routing-runtime/isClientSideRoutable.d.ts +8 -0
- package/dist/esm/client/client-routing-runtime/isClientSideRoutable.js +15 -0
- package/dist/esm/client/client-routing-runtime/navigate.d.ts +0 -2
- package/dist/esm/client/client-routing-runtime/navigate.js +10 -8
- package/dist/esm/client/client-routing-runtime/prefetch.js +12 -5
- package/dist/esm/client/client-routing-runtime/skipLink.d.ts +0 -1
- package/dist/esm/client/client-routing-runtime/skipLink.js +1 -2
- package/dist/esm/client/shared/executeOnRenderClientHook.js +6 -5
- package/dist/esm/client/shared/getPageContextProxyForUser.js +13 -7
- package/dist/esm/node/plugin/plugins/buildConfig.js +1 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +0 -3
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -5
- package/dist/esm/node/plugin/plugins/devConfig/index.js +1 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +29 -42
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +15 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/helpers.js +1 -14
- package/dist/esm/node/plugin/plugins/previewConfig.js +11 -2
- package/dist/esm/node/prerender/runPrerender.js +11 -12
- package/dist/esm/node/prerender/utils.d.ts +1 -1
- package/dist/esm/node/prerender/utils.js +1 -1
- package/dist/esm/node/runtime/html/serializePageContextClientSide.js +21 -7
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +1 -1
- package/dist/esm/node/runtime/renderPage.js +2 -2
- package/dist/esm/node/runtime/utils.d.ts +1 -1
- package/dist/esm/node/runtime/utils.js +1 -1
- package/dist/esm/node/shared/getClientEntryFilePath.js +1 -1
- package/dist/esm/shared/addUrlComputedProps.d.ts +1 -0
- package/dist/esm/shared/addUrlComputedProps.js +25 -13
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +2 -4
- package/dist/esm/shared/getPageFiles/getExports.js +2 -2
- package/dist/esm/shared/hooks/getHook.js +1 -1
- package/dist/esm/shared/page-configs/PageConfig.d.ts +4 -12
- package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.d.ts +7 -0
- package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.js +37 -0
- package/dist/esm/shared/page-configs/helpers/getConfigValue.d.ts +14 -0
- package/dist/esm/shared/page-configs/helpers/getConfigValue.js +38 -0
- package/dist/esm/shared/page-configs/helpers.d.ts +13 -0
- package/dist/esm/shared/page-configs/helpers.js +27 -0
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +6 -8
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +2 -2
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +2 -2
- package/dist/esm/shared/route/executeOnBeforeRouteHook.d.ts +1 -1
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +11 -13
- package/dist/esm/shared/route/index.d.ts +11 -9
- package/dist/esm/shared/route/index.js +3 -3
- package/dist/esm/shared/route/loadPageRoutes.js +7 -6
- package/dist/esm/shared/route/resolveRouteFunction.js +1 -1
- package/dist/esm/shared/utils.d.ts +1 -1
- package/dist/esm/shared/utils.js +1 -1
- package/dist/esm/utils/isPropertyGetter.d.ts +1 -0
- package/dist/esm/utils/{hasPropertyGetter.js → isPropertyGetter.js} +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/shared/page-configs/utils.js +0 -96
- package/dist/esm/client/client-routing-runtime/skipLink/isClientSideRoutable.d.ts +0 -2
- package/dist/esm/client/client-routing-runtime/skipLink/isClientSideRoutable.js +0 -15
- package/dist/esm/client/client-routing-runtime/useClientRouter.d.ts +0 -6
- package/dist/esm/shared/page-configs/utils.d.ts +0 -35
- package/dist/esm/shared/page-configs/utils.js +0 -90
- package/dist/esm/utils/hasPropertyGetter.d.ts +0 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { route };
|
|
2
|
-
export type {
|
|
2
|
+
export type { PageContextForRoute };
|
|
3
|
+
export type { PageContextFromRoute };
|
|
4
|
+
export type { PageRoutes };
|
|
5
|
+
export type { RouteMatches };
|
|
3
6
|
import type { PageFile } from '../getPageFiles.js';
|
|
4
7
|
import { PageContextUrlComputedPropsInternal, PageContextUrlSources } from '../addUrlComputedProps.js';
|
|
5
8
|
import { type OnBeforeRouteHook } from './executeOnBeforeRouteHook.js';
|
|
@@ -13,6 +16,12 @@ type PageContextForRoute = PageContextUrlComputedPropsInternal & {
|
|
|
13
16
|
_pageRoutes: PageRoutes;
|
|
14
17
|
_onBeforeRouteHook: OnBeforeRouteHook | null;
|
|
15
18
|
} & PageContextUrlSources;
|
|
19
|
+
type PageContextFromRoute = {
|
|
20
|
+
_pageId: string | null;
|
|
21
|
+
routeParams: Record<string, string>;
|
|
22
|
+
_routingProvidedByOnBeforeRouteHook: boolean;
|
|
23
|
+
_routeMatches: RouteMatches;
|
|
24
|
+
};
|
|
16
25
|
type RouteMatch = {
|
|
17
26
|
pageId: string;
|
|
18
27
|
routeString?: string;
|
|
@@ -21,11 +30,4 @@ type RouteMatch = {
|
|
|
21
30
|
routeParams: Record<string, string>;
|
|
22
31
|
};
|
|
23
32
|
type RouteMatches = 'CUSTOM_ROUTE' | RouteMatch[];
|
|
24
|
-
declare function route(pageContext: PageContextForRoute): Promise<
|
|
25
|
-
pageContextAddendum: {
|
|
26
|
-
_pageId: string | null;
|
|
27
|
-
routeParams: Record<string, string>;
|
|
28
|
-
_routingProvidedByOnBeforeRouteHook: boolean;
|
|
29
|
-
_routeMatches: RouteMatches;
|
|
30
|
-
} & Record<string, unknown>;
|
|
31
|
-
}>;
|
|
33
|
+
declare function route(pageContext: PageContextForRoute): Promise<PageContextFromRoute>;
|
|
@@ -33,7 +33,7 @@ async function route(pageContext) {
|
|
|
33
33
|
_routingProvidedByOnBeforeRouteHook: true,
|
|
34
34
|
_routeMatches: 'CUSTOM_ROUTE'
|
|
35
35
|
});
|
|
36
|
-
return
|
|
36
|
+
return pageContextAddendum;
|
|
37
37
|
}
|
|
38
38
|
// We already assign so that `pageContext.urlOriginal === pageContextAddendum.urlOriginal`; enabling the `onBeforeRoute()` hook to mutate `pageContext.urlOriginal` before routing.
|
|
39
39
|
objectAssign(pageContext, pageContextAddendum);
|
|
@@ -99,7 +99,7 @@ async function route(pageContext) {
|
|
|
99
99
|
_pageId: null,
|
|
100
100
|
routeParams: {}
|
|
101
101
|
});
|
|
102
|
-
return
|
|
102
|
+
return pageContextAddendum;
|
|
103
103
|
}
|
|
104
104
|
{
|
|
105
105
|
const { routeParams } = winner;
|
|
@@ -109,5 +109,5 @@ async function route(pageContext) {
|
|
|
109
109
|
routeParams: winner.routeParams
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
-
return
|
|
112
|
+
return pageContextAddendum;
|
|
113
113
|
}
|
|
@@ -3,10 +3,10 @@ import { isErrorPageId } from '../error-page.js';
|
|
|
3
3
|
import { assert, assertUsage, hasProp, slice } from './utils.js';
|
|
4
4
|
import { deduceRouteStringFromFilesystemPath } from './deduceRouteStringFromFilesystemPath.js';
|
|
5
5
|
import { isCallable } from '../utils.js';
|
|
6
|
-
import { getConfigValue, getDefinedAtString, getHookFilePathToShowToUser } from '../page-configs/
|
|
6
|
+
import { getConfigDefinedAtString, getConfigValue, getDefinedAtString, getHookFilePathToShowToUser } from '../page-configs/helpers.js';
|
|
7
7
|
import { warnDeprecatedAllowKey } from './resolveRouteFunction.js';
|
|
8
8
|
async function loadPageRoutes(
|
|
9
|
-
//
|
|
9
|
+
// Remove all arguments and use GlobalContext instead?
|
|
10
10
|
pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds) {
|
|
11
11
|
await Promise.all(pageFilesAll.filter((p) => p.fileType === '.page.route').map((p) => p.loadFile?.()));
|
|
12
12
|
const { onBeforeRouteHook, filesystemRoots } = getGlobalHooks(pageFilesAll, pageConfigs, pageConfigGlobal);
|
|
@@ -136,12 +136,13 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
136
136
|
function getGlobalHooks(pageFilesAll, pageConfigs, pageConfigGlobal) {
|
|
137
137
|
// V1 Design
|
|
138
138
|
if (pageConfigs.length > 0) {
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
const hookName = 'onBeforeRoute';
|
|
140
|
+
if (pageConfigGlobal.configValues[hookName]?.value) {
|
|
141
|
+
const configValue = pageConfigGlobal.configValues[hookName];
|
|
141
142
|
const { value: hookFn } = configValue;
|
|
142
143
|
const hookFilePath = getHookFilePathToShowToUser(configValue);
|
|
143
|
-
|
|
144
|
-
assertUsage(isCallable(hookFn),
|
|
144
|
+
const hookDefinedAt = getConfigDefinedAtString('Hook', hookName, configValue);
|
|
145
|
+
assertUsage(isCallable(hookFn), `${hookDefinedAt} should be a function.`);
|
|
145
146
|
const onBeforeRouteHook = {
|
|
146
147
|
hookFilePath: hookFilePath,
|
|
147
148
|
onBeforeRoute: hookFn
|
|
@@ -9,7 +9,7 @@ async function resolveRouteFunction(routeFunction, pageContext, routeDefinedAt)
|
|
|
9
9
|
assertPageContextUrlComputedProps(pageContext);
|
|
10
10
|
let result = routeFunction(pageContext);
|
|
11
11
|
assertSyncRouting(result, `The Route Function ${routeDefinedAt}`);
|
|
12
|
-
// TODO/v1-release
|
|
12
|
+
// TODO/v1-release: make resolveRouteFunction() and route() sync
|
|
13
13
|
//* We disallow asynchronous routing, because we need to check whether a link is a Vike link in a synchronous fashion before calling ev.preventDefault() in the 'click' event listener
|
|
14
14
|
result = await result;
|
|
15
15
|
//*/
|
|
@@ -15,7 +15,7 @@ export * from '../utils/stringifyStringArray.js';
|
|
|
15
15
|
export * from '../utils/filesystemPathHandling.js';
|
|
16
16
|
export * from '../utils/cast.js';
|
|
17
17
|
export * from '../utils/projectInfo.js';
|
|
18
|
-
export * from '../utils/
|
|
18
|
+
export * from '../utils/isPropertyGetter.js';
|
|
19
19
|
export * from '../utils/isPromise.js';
|
|
20
20
|
export * from '../utils/checkType.js';
|
|
21
21
|
export * from '../utils/objectEntries.js';
|
package/dist/esm/shared/utils.js
CHANGED
|
@@ -19,7 +19,7 @@ export * from '../utils/stringifyStringArray.js';
|
|
|
19
19
|
export * from '../utils/filesystemPathHandling.js';
|
|
20
20
|
export * from '../utils/cast.js';
|
|
21
21
|
export * from '../utils/projectInfo.js';
|
|
22
|
-
export * from '../utils/
|
|
22
|
+
export * from '../utils/isPropertyGetter.js';
|
|
23
23
|
export * from '../utils/isPromise.js';
|
|
24
24
|
export * from '../utils/checkType.js';
|
|
25
25
|
export * from '../utils/objectEntries.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isPropertyGetter(obj: Object, prop: string): boolean;
|
|
@@ -5,7 +5,7 @@ type ProjectVersion = typeof projectInfo.projectVersion;
|
|
|
5
5
|
type ProjectTag = `[${PackageName}]` | `[${PackageName}@${ProjectVersion}]`;
|
|
6
6
|
declare const projectInfo: {
|
|
7
7
|
projectName: "Vike";
|
|
8
|
-
projectVersion: "0.4.144-commit-
|
|
8
|
+
projectVersion: "0.4.144-commit-7f5e99a";
|
|
9
9
|
npmPackageName: "vike";
|
|
10
10
|
githubRepository: "https://github.com/vikejs/vike";
|
|
11
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
import { onProjectInfo } from './assertSingleInstance.js';
|
|
3
|
-
const PROJECT_VERSION = '0.4.144-commit-
|
|
3
|
+
const PROJECT_VERSION = '0.4.144-commit-7f5e99a';
|
|
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.144-commit-
|
|
3
|
+
"version": "0.4.144-commit-7f5e99a",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc --watch",
|
|
6
6
|
"build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@brillout/import": "0.2.3",
|
|
16
|
-
"@brillout/json-serializer": "^0.5.
|
|
16
|
+
"@brillout/json-serializer": "^0.5.8",
|
|
17
17
|
"@brillout/picocolors": "^1.0.9",
|
|
18
18
|
"@brillout/require-shim": "^0.1.2",
|
|
19
19
|
"@brillout/vite-plugin-import-build": "^0.2.20",
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getHookFilePathToShowToUser = exports.getConfigValueFilePathToShowToUser = exports.getDefinedAtString = exports.getConfigDefinedAtString = exports.getPageConfig = exports.getConfigValue = void 0;
|
|
7
|
-
const utils_js_1 = require("../utils.js");
|
|
8
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
|
-
const getExportPath_js_1 = require("./getExportPath.js");
|
|
10
|
-
// prettier-ignore
|
|
11
|
-
function getConfigValue(pageConfig, configName, type) {
|
|
12
|
-
const configValue = getConfigValueEntry(pageConfig, configName);
|
|
13
|
-
if (configValue === null)
|
|
14
|
-
return null;
|
|
15
|
-
const { value, definedAt } = configValue;
|
|
16
|
-
if (type)
|
|
17
|
-
assertConfigValueType(value, type, configName, definedAt);
|
|
18
|
-
return configValue;
|
|
19
|
-
}
|
|
20
|
-
exports.getConfigValue = getConfigValue;
|
|
21
|
-
function assertConfigValueType(value, type, configName, definedAt) {
|
|
22
|
-
(0, utils_js_1.assert)(value !== null);
|
|
23
|
-
const typeActual = typeof value;
|
|
24
|
-
if (typeActual === type)
|
|
25
|
-
return;
|
|
26
|
-
const valuePrintable = (0, utils_js_1.getValuePrintable)(value);
|
|
27
|
-
const problem = valuePrintable !== null ? `value ${picocolors_1.default.cyan(valuePrintable)}` : `type ${picocolors_1.default.cyan(typeActual)}`;
|
|
28
|
-
const configDefinedAt = getConfigDefinedAtString(configName, { definedAt }, true);
|
|
29
|
-
(0, utils_js_1.assertUsage)(false, `${configDefinedAt} has an invalid ${problem}: it should be a ${picocolors_1.default.cyan(type)} instead`);
|
|
30
|
-
}
|
|
31
|
-
function getConfigValueEntry(pageConfig, configName) {
|
|
32
|
-
const configValue = pageConfig.configValues[configName];
|
|
33
|
-
if (!configValue)
|
|
34
|
-
return null;
|
|
35
|
-
// Enable users to suppress global config values by setting the local config value to null
|
|
36
|
-
if (configValue.value === null)
|
|
37
|
-
return null;
|
|
38
|
-
return configValue;
|
|
39
|
-
}
|
|
40
|
-
function getPageConfig(pageId, pageConfigs) {
|
|
41
|
-
const pageConfig = pageConfigs.find((p) => p.pageId === pageId);
|
|
42
|
-
(0, utils_js_1.assert)(pageConfigs.length > 0);
|
|
43
|
-
(0, utils_js_1.assert)(pageConfig);
|
|
44
|
-
return pageConfig;
|
|
45
|
-
}
|
|
46
|
-
exports.getPageConfig = getPageConfig;
|
|
47
|
-
function getConfigDefinedAtString(configName, { definedAt }, sentenceBegin) {
|
|
48
|
-
const definedAtString = getDefinedAtString(definedAt, configName);
|
|
49
|
-
const definedAtStr = definedAtString === 'internally' ? definedAtString : `at ${definedAtString}`;
|
|
50
|
-
const configDefinedAt = `${sentenceBegin ? `Config` : `config`} ${picocolors_1.default.cyan(configName)} defined ${definedAtStr}`;
|
|
51
|
-
return configDefinedAt;
|
|
52
|
-
}
|
|
53
|
-
exports.getConfigDefinedAtString = getConfigDefinedAtString;
|
|
54
|
-
function getDefinedAtString(definedAt, configName) {
|
|
55
|
-
if (definedAt.isComputed) {
|
|
56
|
-
return 'internally';
|
|
57
|
-
}
|
|
58
|
-
let files;
|
|
59
|
-
if (definedAt.isCumulative) {
|
|
60
|
-
files = definedAt.files;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
files = [definedAt.file];
|
|
64
|
-
}
|
|
65
|
-
(0, utils_js_1.assert)(files.length >= 1);
|
|
66
|
-
const definedAtString = files
|
|
67
|
-
.map((source) => {
|
|
68
|
-
const { filePathToShowToUser, fileExportPathToShowToUser } = source;
|
|
69
|
-
let s = filePathToShowToUser;
|
|
70
|
-
const exportPath = (0, getExportPath_js_1.getExportPath)(fileExportPathToShowToUser, configName);
|
|
71
|
-
if (exportPath) {
|
|
72
|
-
s = `${s} > ${picocolors_1.default.cyan(exportPath)}`;
|
|
73
|
-
}
|
|
74
|
-
return s;
|
|
75
|
-
})
|
|
76
|
-
.join(' / ');
|
|
77
|
-
return definedAtString;
|
|
78
|
-
}
|
|
79
|
-
exports.getDefinedAtString = getDefinedAtString;
|
|
80
|
-
function getConfigValueFilePathToShowToUser({ definedAt }) {
|
|
81
|
-
// A unique file path only exists if the config value isn't cumulative nor computed:
|
|
82
|
-
// - cumulative config values have multiple file paths
|
|
83
|
-
// - computed values don't have any file path
|
|
84
|
-
if (definedAt.isComputed || definedAt.isCumulative)
|
|
85
|
-
return null;
|
|
86
|
-
const { filePathToShowToUser } = definedAt.file;
|
|
87
|
-
(0, utils_js_1.assert)(filePathToShowToUser);
|
|
88
|
-
return filePathToShowToUser;
|
|
89
|
-
}
|
|
90
|
-
exports.getConfigValueFilePathToShowToUser = getConfigValueFilePathToShowToUser;
|
|
91
|
-
function getHookFilePathToShowToUser({ definedAt }) {
|
|
92
|
-
const filePathToShowToUser = getConfigValueFilePathToShowToUser({ definedAt });
|
|
93
|
-
(0, utils_js_1.assert)(filePathToShowToUser);
|
|
94
|
-
return filePathToShowToUser;
|
|
95
|
-
}
|
|
96
|
-
exports.getHookFilePathToShowToUser = getHookFilePathToShowToUser;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export { isClientSideRoutable };
|
|
2
|
-
import { getPageId } from '../getPageId.js';
|
|
3
|
-
import { analyzePageClientSideInit } from '../../../shared/getPageFiles/analyzePageClientSide.js';
|
|
4
|
-
import { findPageConfig } from '../../../shared/page-configs/findPageConfig.js';
|
|
5
|
-
import { analyzeClientSide } from '../../../shared/getPageFiles/analyzeClientSide.js';
|
|
6
|
-
async function isClientSideRoutable(url) {
|
|
7
|
-
const { pageId, pageFilesAll, pageConfigs } = await getPageId(url);
|
|
8
|
-
if (!pageId) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
await analyzePageClientSideInit(pageFilesAll, pageId, { sharedPageFilesAlreadyLoaded: false });
|
|
12
|
-
const pageConfig = findPageConfig(pageConfigs, pageId);
|
|
13
|
-
const { isClientSideRenderable, isClientRouting } = analyzeClientSide(pageConfig, pageFilesAll, pageId);
|
|
14
|
-
return isClientSideRenderable && isClientRouting;
|
|
15
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { useClientRouter };
|
|
2
|
-
export { disableClientRouting };
|
|
3
|
-
export { isDisableAutomaticLinkInterception };
|
|
4
|
-
declare function disableClientRouting(err: unknown, log: boolean): void;
|
|
5
|
-
declare function useClientRouter(): void;
|
|
6
|
-
declare function isDisableAutomaticLinkInterception(): boolean;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export { getConfigValue };
|
|
2
|
-
export { getPageConfig };
|
|
3
|
-
export { getConfigDefinedAtString };
|
|
4
|
-
export { getDefinedAtString };
|
|
5
|
-
export { getConfigValueFilePathToShowToUser };
|
|
6
|
-
export { getHookFilePathToShowToUser };
|
|
7
|
-
import type { PageConfigRuntime, PageConfigBuildTime, ConfigValue, DefinedAt } from './PageConfig.js';
|
|
8
|
-
import type { ConfigNameBuiltIn } from './Config.js';
|
|
9
|
-
type PageConfigCommon = PageConfigRuntime | PageConfigBuildTime;
|
|
10
|
-
type ConfigName = ConfigNameBuiltIn;
|
|
11
|
-
declare function getConfigValue(pageConfig: PageConfigCommon, configName: ConfigName, type: 'string'): null | ConfigValue & {
|
|
12
|
-
value: string;
|
|
13
|
-
};
|
|
14
|
-
declare function getConfigValue(pageConfig: PageConfigCommon, configName: ConfigName, type: 'boolean'): null | ConfigValue & {
|
|
15
|
-
value: boolean;
|
|
16
|
-
};
|
|
17
|
-
declare function getConfigValue(pageConfig: PageConfigCommon, configName: ConfigName): null | ConfigValue & {
|
|
18
|
-
value: unknown;
|
|
19
|
-
};
|
|
20
|
-
declare function getPageConfig(pageId: string, pageConfigs: PageConfigRuntime[]): PageConfigRuntime;
|
|
21
|
-
type ConfigDefinedAtUppercase<ConfigName extends string> = `Config ${ConfigName} defined ${'internally' | `at ${string}`}`;
|
|
22
|
-
type ConfigDefinedAtLowercase<ConfigName extends string> = `config ${ConfigName} defined ${'internally' | `at ${string}`}`;
|
|
23
|
-
declare function getConfigDefinedAtString<ConfigName extends string>(configName: ConfigName, { definedAt }: {
|
|
24
|
-
definedAt: DefinedAt;
|
|
25
|
-
}, sentenceBegin: true): ConfigDefinedAtUppercase<ConfigName>;
|
|
26
|
-
declare function getConfigDefinedAtString<ConfigName extends string>(configName: ConfigName, { definedAt }: {
|
|
27
|
-
definedAt: DefinedAt;
|
|
28
|
-
}, sentenceBegin: false): ConfigDefinedAtLowercase<ConfigName>;
|
|
29
|
-
declare function getDefinedAtString(definedAt: DefinedAt, configName: string): string;
|
|
30
|
-
declare function getConfigValueFilePathToShowToUser({ definedAt }: {
|
|
31
|
-
definedAt: DefinedAt;
|
|
32
|
-
}): null | string;
|
|
33
|
-
declare function getHookFilePathToShowToUser({ definedAt }: {
|
|
34
|
-
definedAt: DefinedAt;
|
|
35
|
-
}): string;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
export { getConfigValue };
|
|
2
|
-
export { getPageConfig };
|
|
3
|
-
export { getConfigDefinedAtString };
|
|
4
|
-
export { getDefinedAtString };
|
|
5
|
-
export { getConfigValueFilePathToShowToUser };
|
|
6
|
-
export { getHookFilePathToShowToUser };
|
|
7
|
-
import { assert, assertUsage, getValuePrintable } from '../utils.js';
|
|
8
|
-
import pc from '@brillout/picocolors';
|
|
9
|
-
import { getExportPath } from './getExportPath.js';
|
|
10
|
-
// prettier-ignore
|
|
11
|
-
function getConfigValue(pageConfig, configName, type) {
|
|
12
|
-
const configValue = getConfigValueEntry(pageConfig, configName);
|
|
13
|
-
if (configValue === null)
|
|
14
|
-
return null;
|
|
15
|
-
const { value, definedAt } = configValue;
|
|
16
|
-
if (type)
|
|
17
|
-
assertConfigValueType(value, type, configName, definedAt);
|
|
18
|
-
return configValue;
|
|
19
|
-
}
|
|
20
|
-
function assertConfigValueType(value, type, configName, definedAt) {
|
|
21
|
-
assert(value !== null);
|
|
22
|
-
const typeActual = typeof value;
|
|
23
|
-
if (typeActual === type)
|
|
24
|
-
return;
|
|
25
|
-
const valuePrintable = getValuePrintable(value);
|
|
26
|
-
const problem = valuePrintable !== null ? `value ${pc.cyan(valuePrintable)}` : `type ${pc.cyan(typeActual)}`;
|
|
27
|
-
const configDefinedAt = getConfigDefinedAtString(configName, { definedAt }, true);
|
|
28
|
-
assertUsage(false, `${configDefinedAt} has an invalid ${problem}: it should be a ${pc.cyan(type)} instead`);
|
|
29
|
-
}
|
|
30
|
-
function getConfigValueEntry(pageConfig, configName) {
|
|
31
|
-
const configValue = pageConfig.configValues[configName];
|
|
32
|
-
if (!configValue)
|
|
33
|
-
return null;
|
|
34
|
-
// Enable users to suppress global config values by setting the local config value to null
|
|
35
|
-
if (configValue.value === null)
|
|
36
|
-
return null;
|
|
37
|
-
return configValue;
|
|
38
|
-
}
|
|
39
|
-
function getPageConfig(pageId, pageConfigs) {
|
|
40
|
-
const pageConfig = pageConfigs.find((p) => p.pageId === pageId);
|
|
41
|
-
assert(pageConfigs.length > 0);
|
|
42
|
-
assert(pageConfig);
|
|
43
|
-
return pageConfig;
|
|
44
|
-
}
|
|
45
|
-
function getConfigDefinedAtString(configName, { definedAt }, sentenceBegin) {
|
|
46
|
-
const definedAtString = getDefinedAtString(definedAt, configName);
|
|
47
|
-
const definedAtStr = definedAtString === 'internally' ? definedAtString : `at ${definedAtString}`;
|
|
48
|
-
const configDefinedAt = `${sentenceBegin ? `Config` : `config`} ${pc.cyan(configName)} defined ${definedAtStr}`;
|
|
49
|
-
return configDefinedAt;
|
|
50
|
-
}
|
|
51
|
-
function getDefinedAtString(definedAt, configName) {
|
|
52
|
-
if (definedAt.isComputed) {
|
|
53
|
-
return 'internally';
|
|
54
|
-
}
|
|
55
|
-
let files;
|
|
56
|
-
if (definedAt.isCumulative) {
|
|
57
|
-
files = definedAt.files;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
files = [definedAt.file];
|
|
61
|
-
}
|
|
62
|
-
assert(files.length >= 1);
|
|
63
|
-
const definedAtString = files
|
|
64
|
-
.map((source) => {
|
|
65
|
-
const { filePathToShowToUser, fileExportPathToShowToUser } = source;
|
|
66
|
-
let s = filePathToShowToUser;
|
|
67
|
-
const exportPath = getExportPath(fileExportPathToShowToUser, configName);
|
|
68
|
-
if (exportPath) {
|
|
69
|
-
s = `${s} > ${pc.cyan(exportPath)}`;
|
|
70
|
-
}
|
|
71
|
-
return s;
|
|
72
|
-
})
|
|
73
|
-
.join(' / ');
|
|
74
|
-
return definedAtString;
|
|
75
|
-
}
|
|
76
|
-
function getConfigValueFilePathToShowToUser({ definedAt }) {
|
|
77
|
-
// A unique file path only exists if the config value isn't cumulative nor computed:
|
|
78
|
-
// - cumulative config values have multiple file paths
|
|
79
|
-
// - computed values don't have any file path
|
|
80
|
-
if (definedAt.isComputed || definedAt.isCumulative)
|
|
81
|
-
return null;
|
|
82
|
-
const { filePathToShowToUser } = definedAt.file;
|
|
83
|
-
assert(filePathToShowToUser);
|
|
84
|
-
return filePathToShowToUser;
|
|
85
|
-
}
|
|
86
|
-
function getHookFilePathToShowToUser({ definedAt }) {
|
|
87
|
-
const filePathToShowToUser = getConfigValueFilePathToShowToUser({ definedAt });
|
|
88
|
-
assert(filePathToShowToUser);
|
|
89
|
-
return filePathToShowToUser;
|
|
90
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function hasPropertyGetter(obj: Object, prop: string): boolean;
|