vike 0.4.249-commit-55681da → 0.4.249-commit-ec50591

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.
@@ -0,0 +1,105 @@
1
+ export { buildFilterRolldown };
2
+ import { escapeRegex } from '../../utils.js';
3
+ import { parseImportString } from '../../shared/importString.js';
4
+ /**
5
+ * Build a filterRolldown from staticReplaceList by extracting all import strings.
6
+ * For a single entry, ALL import strings must be present (AND logic),
7
+ * except for call.match.function array which is OR logic.
8
+ * Between staticReplace entries it's OR logic.
9
+ */
10
+ function buildFilterRolldown(staticReplaceList) {
11
+ const rulePatterns = [];
12
+ // Process each entry separately
13
+ for (const staticReplaceEntry of staticReplaceList) {
14
+ const importStrings = new Set();
15
+ const functionImportStrings = new Set();
16
+ // Extract function import strings separately
17
+ extractImportStrings(staticReplaceEntry.match.function, functionImportStrings);
18
+ // Extract arg import strings
19
+ if (staticReplaceEntry.match.args) {
20
+ for (const condition of Object.values(staticReplaceEntry.match.args)) {
21
+ extractImportStringsFromCondition(condition, importStrings);
22
+ }
23
+ }
24
+ // Build pattern for this staticReplaceEntry
25
+ const ruleParts = [];
26
+ // For function imports: if array, use OR; otherwise use AND
27
+ if (functionImportStrings.size > 0) {
28
+ const functionPatterns = [];
29
+ for (const importStr of functionImportStrings) {
30
+ const parts = parseImportString(importStr);
31
+ if (parts) {
32
+ // Each function import should match both importPath and export name
33
+ functionPatterns.push(`(?=.*${escapeRegex(parts.importPath)})(?=.*${escapeRegex(parts.exportName)})`);
34
+ }
35
+ }
36
+ // If multiple functions, they are alternatives (OR)
37
+ if (functionPatterns.length > 0) {
38
+ if (functionPatterns.length === 1) {
39
+ ruleParts.push(functionPatterns[0]);
40
+ }
41
+ else {
42
+ // Multiple function patterns: file must match at least one
43
+ ruleParts.push(`(?:${functionPatterns.join('|')})`);
44
+ }
45
+ }
46
+ }
47
+ // For arg imports: all must be present (AND)
48
+ for (const importStr of importStrings) {
49
+ const parts = parseImportString(importStr);
50
+ if (parts) {
51
+ // Each arg import should match both importPath and export name
52
+ ruleParts.push(`(?=.*${escapeRegex(parts.importPath)})(?=.*${escapeRegex(parts.exportName)})`);
53
+ }
54
+ }
55
+ // Combine all parts for this rule with AND logic
56
+ if (ruleParts.length > 0) {
57
+ // All parts must match for this rule
58
+ rulePatterns.push(ruleParts.join(''));
59
+ }
60
+ }
61
+ if (rulePatterns.length === 0)
62
+ return null;
63
+ // Create a regex that matches if any rule pattern matches (OR between staticReplace entries)
64
+ const regex = new RegExp(rulePatterns.join('|'));
65
+ return {
66
+ code: {
67
+ include: regex,
68
+ },
69
+ };
70
+ }
71
+ /**
72
+ * Extract import strings from function patterns
73
+ */
74
+ function extractImportStrings(functions, result) {
75
+ const arr = Array.isArray(functions) ? functions : [functions];
76
+ for (const fn of arr) {
77
+ if (parseImportString(fn)) {
78
+ result.add(fn);
79
+ }
80
+ }
81
+ }
82
+ /**
83
+ * Extract import strings from argument conditions
84
+ */
85
+ function extractImportStringsFromCondition(condition, result) {
86
+ if (typeof condition === 'string') {
87
+ if (parseImportString(condition)) {
88
+ result.add(condition);
89
+ }
90
+ }
91
+ else if (condition && typeof condition === 'object') {
92
+ // Handle call condition
93
+ if ('call' in condition && typeof condition.call === 'string') {
94
+ if (parseImportString(condition.call)) {
95
+ result.add(condition.call);
96
+ }
97
+ // Recursively check nested args
98
+ if (condition.args) {
99
+ for (const nestedCondition of Object.values(condition.args)) {
100
+ extractImportStringsFromCondition(nestedCondition, result);
101
+ }
102
+ }
103
+ }
104
+ }
105
+ }
@@ -0,0 +1,4 @@
1
+ export { pluginStaticReplace };
2
+ import type { Plugin } from 'vite';
3
+ import { VikeConfigInternal } from '../shared/resolveVikeConfigInternal.js';
4
+ declare function pluginStaticReplace(vikeConfig: VikeConfigInternal): Plugin[];
@@ -0,0 +1,57 @@
1
+ export { pluginStaticReplace };
2
+ import { assert } from '../utils.js';
3
+ import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
4
+ import { applyStaticReplace } from './pluginStaticReplace/applyStaticReplace.js';
5
+ import { buildFilterRolldown } from './pluginStaticReplace/buildFilterRolldown.js';
6
+ function pluginStaticReplace(vikeConfig) {
7
+ let config;
8
+ const staticReplaceList = getStaticReplaceList(vikeConfig);
9
+ if (staticReplaceList.length === 0)
10
+ return [];
11
+ const filterRolldown = buildFilterRolldown(staticReplaceList);
12
+ assert(filterRolldown);
13
+ return [
14
+ {
15
+ name: 'vike:pluginStaticReplace',
16
+ enforce: 'post',
17
+ configResolved: {
18
+ async handler(config_) {
19
+ config = config_;
20
+ },
21
+ },
22
+ transform: {
23
+ filter: {
24
+ code: {
25
+ include: filterRolldown.code.include,
26
+ exclude: /node_modules/,
27
+ },
28
+ },
29
+ async handler(code, id, options) {
30
+ const env = isViteServerSide_extraSafe(config, this.environment, options) ? 'server' : 'client';
31
+ const result = await applyStaticReplace({
32
+ code,
33
+ id,
34
+ env,
35
+ options: staticReplaceList,
36
+ });
37
+ return result;
38
+ },
39
+ },
40
+ },
41
+ ];
42
+ }
43
+ /**
44
+ * Extract all staticReplaceList from vikeConfig
45
+ */
46
+ function getStaticReplaceList(vikeConfig) {
47
+ const staticReplaceConfigs = vikeConfig._from.configsCumulative.staticReplace;
48
+ if (!staticReplaceConfigs)
49
+ return [];
50
+ const staticReplaceList = [];
51
+ for (const configValue of staticReplaceConfigs.values) {
52
+ const entries = configValue.value;
53
+ assert(Array.isArray(entries));
54
+ staticReplaceList.push(...entries);
55
+ }
56
+ return staticReplaceList;
57
+ }
@@ -1,3 +1,4 @@
1
1
  export { pluginViteConfigVikeExtensions };
2
2
  import type { Plugin } from 'vite';
3
- declare function pluginViteConfigVikeExtensions(): Promise<Plugin[]>;
3
+ import type { VikeConfigInternal } from '../shared/resolveVikeConfigInternal.js';
4
+ declare function pluginViteConfigVikeExtensions(vikeConfig: VikeConfigInternal): Promise<Plugin[]>;
@@ -1,11 +1,9 @@
1
1
  export { pluginViteConfigVikeExtensions };
2
2
  import { mergeConfig } from 'vite';
3
3
  import { assertUsage, isCallable, isObject } from '../utils.js';
4
- import { getVikeConfigInternalEarly } from '../../api/resolveViteConfigFromUser.js';
5
4
  // Apply +vite
6
5
  // - For example, Vike extensions adding Vite plugins
7
- async function pluginViteConfigVikeExtensions() {
8
- const vikeConfig = await getVikeConfigInternalEarly();
6
+ async function pluginViteConfigVikeExtensions(vikeConfig) {
9
7
  if (vikeConfig === null)
10
8
  return [];
11
9
  let viteConfigFromExtensions = {};
@@ -0,0 +1,50 @@
1
+ export { parseImportString };
2
+ export { isImportString };
3
+ export { serializeImportString };
4
+ export type { ImportString };
5
+ export type { ImportStringList };
6
+ export type { ImportStringParsed };
7
+ /** `import:${importPath}:${exportName}`
8
+ * @example import:./Layout:default
9
+ */
10
+ type ImportString = `import:${string}:${string}`;
11
+ type ImportStringList = ImportString | ImportString[];
12
+ type ImportStringParsed = {
13
+ importPath: string;
14
+ exportName: string;
15
+ };
16
+ /**
17
+ * Parse import string in format: import:importPath:exportName
18
+ *
19
+ * @example parseImportString('import:react/jsx-runtime:jsx')
20
+ * // => { importPath: 'react/jsx-runtime', exportName: 'jsx' }
21
+ *
22
+ * @example parseImportString('import:./Layout:default')
23
+ * // => { importPath: './Layout', exportName: 'default' }
24
+ *
25
+ * @example parseImportString('import:./Layout', { legacy: true })
26
+ * // => { importPath: './Layout', exportName: 'default' }
27
+ */
28
+ declare function parseImportString(importString: string, { legacy }?: {
29
+ legacy?: boolean;
30
+ }): null | ImportStringParsed;
31
+ /**
32
+ * Check if a string is an import string (starts with 'import:').
33
+ *
34
+ * @example isImportString('import:react:jsx')
35
+ * // => true
36
+ *
37
+ * @example isImportString('some-other-string')
38
+ * // => false
39
+ */
40
+ declare function isImportString(str: string): str is ImportString;
41
+ /**
42
+ * Serialize import string from importPath and export name.
43
+ *
44
+ * @example serializeImportString({ importPath: 'react/jsx-runtime', exportName: 'jsx' })
45
+ * // => 'import:react/jsx-runtime:jsx'
46
+ *
47
+ * @example serializeImportString({ importPath: './Layout', exportName: 'default' })
48
+ * // => 'import:./Layout:default'
49
+ */
50
+ declare function serializeImportString({ importPath, exportName }: ImportStringParsed): `import:${string}:${string}`;
@@ -0,0 +1,64 @@
1
+ export { parseImportString };
2
+ export { isImportString };
3
+ export { serializeImportString };
4
+ import { assert } from '../utils.js';
5
+ const IMPORT = 'import';
6
+ const SEP = ':';
7
+ /**
8
+ * Parse import string in format: import:importPath:exportName
9
+ *
10
+ * @example parseImportString('import:react/jsx-runtime:jsx')
11
+ * // => { importPath: 'react/jsx-runtime', exportName: 'jsx' }
12
+ *
13
+ * @example parseImportString('import:./Layout:default')
14
+ * // => { importPath: './Layout', exportName: 'default' }
15
+ *
16
+ * @example parseImportString('import:./Layout', { legacy: true })
17
+ * // => { importPath: './Layout', exportName: 'default' }
18
+ */
19
+ function parseImportString(importString, { legacy = false } = {}) {
20
+ if (!isImportString(importString))
21
+ return null;
22
+ const parts = importString.split(SEP);
23
+ assert(parts[0] === IMPORT);
24
+ if (legacy && parts.length === 2) {
25
+ /* TODO
26
+ assertWarning(false, 'To-Do', { onlyOnce: true, showStackTrace: true })
27
+ */
28
+ const exportName = 'default';
29
+ const importPath = parts[1];
30
+ assert(importPath);
31
+ return { importPath, exportName };
32
+ }
33
+ assert(parts.length >= 3);
34
+ const exportName = parts[parts.length - 1];
35
+ const importPath = parts.slice(1, -1).join(SEP);
36
+ assert(exportName);
37
+ assert(importPath);
38
+ return { importPath, exportName };
39
+ }
40
+ /**
41
+ * Check if a string is an import string (starts with 'import:').
42
+ *
43
+ * @example isImportString('import:react:jsx')
44
+ * // => true
45
+ *
46
+ * @example isImportString('some-other-string')
47
+ * // => false
48
+ */
49
+ function isImportString(str) {
50
+ return str.startsWith(`${IMPORT}${SEP}`);
51
+ }
52
+ /**
53
+ * Serialize import string from importPath and export name.
54
+ *
55
+ * @example serializeImportString({ importPath: 'react/jsx-runtime', exportName: 'jsx' })
56
+ * // => 'import:react/jsx-runtime:jsx'
57
+ *
58
+ * @example serializeImportString({ importPath: './Layout', exportName: 'default' })
59
+ * // => 'import:./Layout:default'
60
+ */
61
+ function serializeImportString({ importPath, exportName }) {
62
+ const importString = `${IMPORT}${SEP}${importPath}${SEP}${exportName}`;
63
+ return importString;
64
+ }
@@ -270,6 +270,13 @@ const configDefinitionsBuiltIn = {
270
270
  env: { server: true },
271
271
  cumulative: true,
272
272
  },
273
+ staticReplace: {
274
+ env: { config: true },
275
+ cumulative: true,
276
+ /* TODO
277
+ vite: true,
278
+ */
279
+ },
273
280
  };
274
281
  function getConfigEnv(pageConfig, configName) {
275
282
  const source = getConfigValueSourceRelevantAnyEnv(configName, pageConfig);
@@ -5,6 +5,7 @@ export { assertPointerImportPath };
5
5
  // Playground: https://github.com/brillout/acorn-playground
6
6
  // Notes about `with { type: 'pointer' }`
7
7
  // - It works well with TypeScript: it doesn't complain upon `with { type: 'unknown-to-typescript' }` and go-to-definition & types are preserved: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#import-attributes
8
+ // - Babel already supports it: https://babeljs.io/docs/babel-parser#plugins => search for `importAttributes`
8
9
  // - Acorn support for import attributes: https://github.com/acornjs/acorn/issues/983
9
10
  // - Acorn plugin: https://github.com/acornjs/acorn/issues/983
10
11
  // - Isn't stage 4 yet: https://github.com/tc39/proposal-import-attributes
@@ -17,9 +18,10 @@ export { assertPointerImportPath };
17
18
  // - Using a magic comment `// @vike-real-import` is probably a bad idea:
18
19
  // - Esbuild removes comments: https://github.com/evanw/esbuild/issues/1439#issuecomment-877656182
19
20
  // - Using source maps to track these magic comments is brittle (source maps can easily break)
20
- import { parse } from 'acorn';
21
+ import { parseSync } from '@babel/core';
21
22
  import { assert, assertUsage, assertWarning, isFilePathAbsolute, isImportPath, styleFileRE } from '../../utils.js';
22
23
  import pc from '@brillout/picocolors';
24
+ import { parseImportString, isImportString, serializeImportString } from '../importString.js';
23
25
  function transformPointerImports(code, filePathToShowToUser2, pointerImports,
24
26
  // For ./transformPointerImports.spec.ts
25
27
  skipWarnings) {
@@ -103,11 +105,11 @@ skipWarnings) {
103
105
  return codeMod;
104
106
  }
105
107
  function getImports(code) {
106
- const { body } = parse(code, {
107
- ecmaVersion: 'latest',
108
+ const result = parseSync(code, {
108
109
  sourceType: 'module',
109
- // https://github.com/acornjs/acorn/issues/1136
110
110
  });
111
+ assert(result);
112
+ const { body } = result.program;
111
113
  const imports = [];
112
114
  body.forEach((node) => {
113
115
  if (node.type === 'ImportDeclaration')
@@ -115,16 +117,13 @@ function getImports(code) {
115
117
  });
116
118
  return imports;
117
119
  }
118
- const import_ = 'import';
119
- const SEP = ':';
120
120
  const zeroWidthSpace = '\u200b';
121
121
  function serializePointerImportData({ importPath, exportName, importStringWasGenerated, }) {
122
122
  const tag = importStringWasGenerated ? zeroWidthSpace : '';
123
- // `import:${importPath}:${importPath}`
124
- return `${tag}${import_}${SEP}${importPath}${SEP}${exportName}`;
123
+ return `${tag}${serializeImportString({ importPath, exportName })}`;
125
124
  }
126
125
  function isPointerImportData(str) {
127
- return str.startsWith(import_ + SEP) || str.startsWith(zeroWidthSpace + import_ + SEP);
126
+ return isImportString(str) || (str.startsWith(zeroWidthSpace) && isImportString(str.slice(1)));
128
127
  }
129
128
  function parsePointerImportData(importString) {
130
129
  if (!isPointerImportData(importString)) {
@@ -136,15 +135,9 @@ function parsePointerImportData(importString) {
136
135
  assert(zeroWidthSpace.length === 1);
137
136
  importString = importString.slice(1);
138
137
  }
139
- const parts = importString.split(SEP).slice(1);
140
- if (!importStringWasGenerated && parts.length === 1) {
141
- const exportName = 'default';
142
- const importPath = parts[0];
143
- return { importPath, exportName, importStringWasGenerated, importString };
144
- }
145
- assert(parts.length >= 2);
146
- const exportName = parts[parts.length - 1];
147
- const importPath = parts.slice(0, -1).join(SEP);
138
+ const parsed = parseImportString(importString, { legacy: !importStringWasGenerated });
139
+ assert(parsed);
140
+ const { importPath, exportName } = parsed;
148
141
  if (importPath.startsWith('.') && !(importPath.startsWith('./') || importPath.startsWith('../'))) {
149
142
  assert(!importStringWasGenerated);
150
143
  assertUsage(false, `Invalid relative import path ${pc.code(importPath)} defined by ${pc.code(JSON.stringify(importString))} because it should start with ${pc.code('./')} or ${pc.code('../')}, or use an npm package import instead.`);
@@ -32,6 +32,7 @@ async function generateNonce() {
32
32
  return cryptoModule.randomBytes(16).toString('base64url');
33
33
  }
34
34
  function inferNonceAttr(pageContext) {
35
+ // No need to escape the injected HTML — pageContext.cspNone is controlled by the developer, not by the website visitor (I wouldn't know why the developer would set +csp.none to a value coming from the database)
35
36
  const nonceAttr = pageContext.cspNonce ? ` nonce="${pageContext.cspNonce}"` : '';
36
37
  return nonceAttr;
37
38
  }
@@ -41,5 +42,6 @@ function addCspResponseHeader(pageContext, headersResponse) {
41
42
  return;
42
43
  if (headersResponse.get('Content-Security-Policy'))
43
44
  return;
45
+ // No need to sanitize the injected header — see comment above about not escaping HTML
44
46
  headersResponse.set('Content-Security-Policy', `script-src 'self' 'nonce-${pageContext.cspNonce}'`);
45
47
  }
@@ -1,8 +1,9 @@
1
1
  export type { ConfigResolved };
2
- import type { ConfigBuiltIn, ConfigBuiltInResolved, ImportString } from '../Config.js';
2
+ import type { ConfigBuiltIn, ConfigBuiltInResolved } from '../Config.js';
3
+ import type { ImportStringList } from '../../node/vite/shared/importString.js';
3
4
  type ConfigUnresolved = WithoutImportString<ConfigBuiltIn & Vike.Config>;
4
5
  type ConfigResolvedOnly = ConfigBuiltInResolved & Vike.ConfigResolved;
5
6
  type ConfigResolved = ConfigResolvedOnly & Omit<ConfigUnresolved, keyof ConfigResolvedOnly>;
6
7
  type WithoutImportString<T> = {
7
- [K in keyof T]: Exclude<T[K], ImportString>;
8
+ [K in keyof T]: Exclude<T[K], ImportStringList>;
8
9
  };
@@ -8,7 +8,6 @@ export type { HookName };
8
8
  export type { HookNameOld };
9
9
  export type { HookNamePage };
10
10
  export type { HookNameGlobal };
11
- export type { ImportString };
12
11
  export type { Route };
13
12
  export type { KeepScrollPosition };
14
13
  export type { DataAsync };
@@ -47,6 +46,8 @@ import type { GlobalContext } from './GlobalContext.js';
47
46
  import type { InlineConfig } from 'vite';
48
47
  import type { PassToClientPublic } from '../server/runtime/renderPageServer/html/serializeContext.js';
49
48
  import type { CliPreviewConfig } from '../node/api/preview.js';
49
+ import type { StaticReplace } from '../node/vite/plugins/pluginStaticReplace/applyStaticReplace.js';
50
+ import type { ImportStringList } from '../node/vite/shared/importString.js';
50
51
  type HookNameOld = HookName | HookNameOldDesign;
51
52
  type HookName = HookNamePage | HookNameGlobal;
52
53
  type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRender' | 'onPageTransitionStart' | 'onPageTransitionEnd' | 'onRenderHtml' | 'onRenderClient' | 'guard' | 'data' | 'onData' | 'route';
@@ -250,12 +251,12 @@ type ConfigBuiltIn = {
250
251
  *
251
252
  * https://vike.dev/route
252
253
  */
253
- route?: Route | ImportString;
254
+ route?: Route | ImportStringList;
254
255
  /** Protect page(s), e.g. forbid unauthorized access.
255
256
  *
256
257
  * https://vike.dev/guard
257
258
  */
258
- guard?: GuardAsync | GuardSync | ImportString;
259
+ guard?: GuardAsync | GuardSync | ImportStringList;
259
260
  /**
260
261
  * Pre-render page(s).
261
262
  *
@@ -264,7 +265,7 @@ type ConfigBuiltIn = {
264
265
  *
265
266
  * @default false
266
267
  */
267
- prerender?: boolean | ImportString | {
268
+ prerender?: boolean | ImportStringList | {
268
269
  /**
269
270
  * Allow only some of your pages to be pre-rendered.
270
271
  *
@@ -339,32 +340,32 @@ type ConfigBuiltIn = {
339
340
  *
340
341
  * https://vike.dev/extends
341
342
  */
342
- extends?: Config | Config[] | ImportString;
343
+ extends?: Config | Config[] | ImportStringList;
343
344
  /** Hook called before the page is rendered.
344
345
  *
345
346
  * https://vike.dev/onBeforeRender
346
347
  */
347
- onBeforeRender?: OnBeforeRenderAsync | OnBeforeRenderSync | ImportString | null;
348
+ onBeforeRender?: OnBeforeRenderAsync | OnBeforeRenderSync | ImportStringList | null;
348
349
  /** Hook called when a `pageContext` object is created.
349
350
  *
350
351
  * https://vike.dev/onCreatePageContext
351
352
  */
352
- onCreatePageContext?: ((pageContext: PageContextServer) => void) | ImportString | null;
353
+ onCreatePageContext?: ((pageContext: PageContextServer) => void) | ImportStringList | null;
353
354
  /** Hook called when an error occurs during server-side rendering.
354
355
  *
355
356
  * https://vike.dev/onError
356
357
  */
357
- onError?: ((error: unknown, pageContext: null | PageContextServer) => void) | ImportString | null;
358
+ onError?: ((error: unknown, pageContext: null | PageContextServer) => void) | ImportStringList | null;
358
359
  /** Hook called when the `globalContext` object is created.
359
360
  *
360
361
  * https://vike.dev/onCreateGlobalContext
361
362
  */
362
- onCreateGlobalContext?: ((globalContext: GlobalContext) => void) | ImportString | null;
363
+ onCreateGlobalContext?: ((globalContext: GlobalContext) => void) | ImportStringList | null;
363
364
  /** Hook for fetching data.
364
365
  *
365
366
  * https://vike.dev/data
366
367
  */
367
- data?: DataAsync<unknown> | DataSync<unknown> | ImportString | null;
368
+ data?: DataAsync<unknown> | DataSync<unknown> | ImportStringList | null;
368
369
  /** Hook called as soon as `pageContext.data` is available.
369
370
  *
370
371
  * https://vike.dev/onData
@@ -374,83 +375,83 @@ type ConfigBuiltIn = {
374
375
  *
375
376
  * https://vike.dev/passToClient
376
377
  */
377
- passToClient?: PassToClientPublic | ImportString;
378
+ passToClient?: PassToClientPublic | ImportStringList;
378
379
  /** Hook called when page is rendered on the client-side.
379
380
  *
380
381
  * https://vike.dev/onRenderClient
381
382
  */
382
- onRenderClient?: OnRenderClientAsync | OnRenderClientSync | ImportString;
383
+ onRenderClient?: OnRenderClientAsync | OnRenderClientSync | ImportStringList;
383
384
  /** Hook called when page is rendered to HTML on the server-side.
384
385
  *
385
386
  * https://vike.dev/onRenderHtml
386
387
  */
387
- onRenderHtml?: OnRenderHtmlAsync | OnRenderHtmlSync | ImportString;
388
+ onRenderHtml?: OnRenderHtmlAsync | OnRenderHtmlSync | ImportStringList;
388
389
  /** Enable async Route Functions.
389
390
  *
390
391
  * https://vike.dev/route-function#async
391
392
  */
392
- iKnowThePerformanceRisksOfAsyncRouteFunctions?: boolean | ImportString;
393
+ iKnowThePerformanceRisksOfAsyncRouteFunctions?: boolean | ImportStringList;
393
394
  /** Change the URL root of Filesystem Routing.
394
395
  *
395
396
  * https://vike.dev/filesystemRoutingRoot
396
397
  */
397
- filesystemRoutingRoot?: string | ImportString;
398
+ filesystemRoutingRoot?: string | ImportStringList;
398
399
  /** Page Hook called when pre-rendering starts.
399
400
  *
400
401
  * https://vike.dev/onPrerenderStart
401
402
  */
402
- onPrerenderStart?: OnPrerenderStartAsync | OnPrerenderStartSync | ImportString;
403
+ onPrerenderStart?: OnPrerenderStartAsync | OnPrerenderStartSync | ImportStringList;
403
404
  /** Global Hook called before the whole pre-rendering process starts.
404
405
  *
405
406
  * https://vike.dev/onBeforePrerenderStart
406
407
  */
407
- onBeforePrerenderStart?: OnBeforePrerenderStartAsync | OnBeforePrerenderStartSync | ImportString;
408
+ onBeforePrerenderStart?: OnBeforePrerenderStartAsync | OnBeforePrerenderStartSync | ImportStringList;
408
409
  /** Hook called before the URL is routed to a page.
409
410
  *
410
411
  * https://vike.dev/onBeforeRoute
411
412
  */
412
- onBeforeRoute?: OnBeforeRouteAsync | OnBeforeRouteSync | ImportString;
413
+ onBeforeRoute?: OnBeforeRouteAsync | OnBeforeRouteSync | ImportStringList;
413
414
  /** Hook called after the page is hydrated.
414
415
  *
415
416
  * https://vike.dev/onHydrationEnd
416
417
  */
417
- onHydrationEnd?: OnHydrationEndAsync | OnHydrationEndSync | ImportString;
418
+ onHydrationEnd?: OnHydrationEndAsync | OnHydrationEndSync | ImportStringList;
418
419
  /** Hook called before the user navigates to a new page.
419
420
  *
420
421
  * https://vike.dev/onPageTransitionStart
421
422
  */
422
- onPageTransitionStart?: OnPageTransitionStartAsync | OnPageTransitionStartSync | ImportString;
423
+ onPageTransitionStart?: OnPageTransitionStartAsync | OnPageTransitionStartSync | ImportStringList;
423
424
  /** Hook called after the user navigates to a new page.
424
425
  *
425
426
  * https://vike.dev/onPageTransitionEnd
426
427
  */
427
- onPageTransitionEnd?: OnPageTransitionEndAsync | OnPageTransitionEndSync | ImportString;
428
+ onPageTransitionEnd?: OnPageTransitionEndAsync | OnPageTransitionEndSync | ImportStringList;
428
429
  /** Whether the UI framework (React/Vue/Solid/...) allows the page's hydration to be aborted.
429
430
  *
430
431
  * https://vike.dev/hydrationCanBeAborted
431
432
  */
432
- hydrationCanBeAborted?: boolean | ImportString;
433
+ hydrationCanBeAborted?: boolean | ImportStringList;
433
434
  /** Add client code.
434
435
  *
435
436
  * https://vike.dev/client
436
437
  */
437
- client?: string | ImportString;
438
+ client?: string | ImportStringList;
438
439
  /** Enable Client Routing.
439
440
  *
440
441
  * https://vike.dev/clientRouting
441
442
  */
442
- clientRouting?: boolean | ImportString;
443
+ clientRouting?: boolean | ImportStringList;
443
444
  /**
444
445
  * Whether hooks are loaded on the client-side.
445
446
  *
446
447
  * https://vike.dev/clientHooks
447
448
  */
448
- clientHooks?: boolean | null | ImportString;
449
+ clientHooks?: boolean | null | ImportStringList;
449
450
  /** Create new or modify existing configurations.
450
451
  *
451
452
  * https://vike.dev/meta
452
453
  */
453
- meta?: ConfigMeta | ImportString;
454
+ meta?: ConfigMeta | ImportStringList;
454
455
  /** Vite configuration.
455
456
  *
456
457
  * https://vite.dev/config/
@@ -498,13 +499,13 @@ type ConfigBuiltIn = {
498
499
  *
499
500
  * https://vike.dev/prefetch
500
501
  */
501
- prefetch?: PrefetchSetting | ImportString;
502
+ prefetch?: PrefetchSetting | ImportStringList;
502
503
  /** @deprecated Use `prefetch` setting (https://vike.dev/prefetch) instead. */
503
504
  /** Prefetch links.
504
505
  *
505
506
  * https://vike.dev/prefetchStaticAssets
506
507
  */
507
- prefetchStaticAssets?: PrefetchStaticAssets | ImportString;
508
+ prefetchStaticAssets?: PrefetchStaticAssets | ImportStringList;
508
509
  /** Modify the timeouts of hooks. */
509
510
  hooksTimeout?: HooksTimeoutProvidedByUser;
510
511
  /** `Cache-Control` HTTP header value.
@@ -587,14 +588,19 @@ type ConfigBuiltIn = {
587
588
  cli?: {
588
589
  preview?: CliPreviewConfig;
589
590
  };
591
+ /**
592
+ * Static code transformations for optimizations like removing component children server-side.
593
+ *
594
+ * @experimental
595
+ */
596
+ staticReplace?: StaticReplace[];
590
597
  };
591
598
  type ConfigBuiltInResolved = {
592
599
  passToClient?: string[][];
593
600
  redirects?: Record<string, string>[];
594
- prerender?: Exclude<Config['prerender'], ImportString | undefined>[];
601
+ prerender?: Exclude<Config['prerender'], ImportStringList | undefined>[];
595
602
  middleware?: Function[];
596
- headersResponse?: Exclude<Config['headersResponse'], ImportString | undefined>[];
603
+ headersResponse?: Exclude<Config['headersResponse'], ImportStringList | undefined>[];
604
+ staticReplace?: StaticReplace[][];
597
605
  };
598
606
  type ConfigMeta = Record<string, ConfigDefinition>;
599
- type ImportString = ImportStringVal | ImportStringVal[];
600
- type ImportStringVal = `import:${string}`;
@@ -4,7 +4,8 @@ export type { PrerenderContextPublic as PrerenderContext } from '../node/prerend
4
4
  export type { PageContextBuiltInServer } from './PageContext.js';
5
5
  export type { PageContextBuiltInClientWithClientRouting } from './PageContext.js';
6
6
  export type { PageContextBuiltInClientWithServerRouting } from './PageContext.js';
7
- export type { Config, ConfigMeta as Meta, ImportString, KeepScrollPosition, } from './Config.js';
7
+ export type { Config, ConfigMeta as Meta, KeepScrollPosition, } from './Config.js';
8
+ export type { ImportString } from '../node/vite/shared/importString.js';
8
9
  export type { DataAsync, DataSync, GuardAsync, GuardSync, OnBeforePrerenderStartAsync, OnBeforePrerenderStartSync, OnBeforeRenderAsync, OnBeforeRenderSync, OnBeforeRouteAsync, OnBeforeRouteSync, OnHydrationEndAsync, OnHydrationEndSync, OnPageTransitionEndAsync, OnPageTransitionEndSync, OnPageTransitionStartAsync, OnPageTransitionStartSync, OnPrerenderStartAsync, OnPrerenderStartSync, OnRenderClientAsync, OnRenderClientSync, OnRenderHtmlAsync, OnRenderHtmlSync, RouteAsync, RouteSync, } from './Config.js';
9
10
  export type { ConfigResolved } from './Config/ConfigResolved.js';
10
11
  export type { ConfigEnv } from './PageConfig.js';
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.249-commit-55681da";
1
+ export declare const PROJECT_VERSION: "0.4.249-commit-ec50591";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.249-commit-55681da';
2
+ export const PROJECT_VERSION = '0.4.249-commit-ec50591';