vike 0.4.260 → 0.4.261

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.
Files changed (65) hide show
  1. package/dist/client/runtime-client-routing/createPageContextClient.d.ts +10 -10
  2. package/dist/client/runtime-client-routing/getGlobalContextClientInternal.d.ts +10 -10
  3. package/dist/client/runtime-client-routing/getPageContext/removeBuiltInOverrides.d.ts +2 -2
  4. package/dist/client/runtime-client-routing/getPageContextFromHooks.d.ts +56 -56
  5. package/dist/client/runtime-client-routing/history.d.ts +1 -1
  6. package/dist/client/runtime-client-routing/renderPageClient.d.ts +49 -49
  7. package/dist/client/runtime-server-routing/createPageContextClient.d.ts +10 -10
  8. package/dist/client/runtime-server-routing/getGlobalContextClientInternal.d.ts +10 -10
  9. package/dist/client/shared/getGlobalContextClientInternalShared.d.ts +10 -10
  10. package/dist/node/api/resolveViteConfigUser.js +1 -1
  11. package/dist/node/api/startupLog.js +0 -1
  12. package/dist/node/cli/parseCli.js +1 -1
  13. package/dist/node/prerender/runPrerender.d.ts +22 -22
  14. package/dist/node/vite/plugins/pluginDev/autoAddVikeSkill.d.ts +3 -0
  15. package/dist/node/vite/plugins/pluginDev/autoAddVikeSkill.js +174 -0
  16. package/dist/node/vite/plugins/pluginDev.js +17 -0
  17. package/dist/node/vite/plugins/pluginVirtualFiles.js +1 -1
  18. package/dist/node/vite/shared/getMagicString.d.ts +1 -1
  19. package/dist/node/vite/shared/getMagicString.js +3 -0
  20. package/dist/node/vite/shared/loggerVite.js +3 -2
  21. package/dist/node/vite/shared/resolveVikeConfigInternal/assertExtensions.d.ts +1 -1
  22. package/dist/node/vite/shared/resolveVikeConfigInternal/{crawlPlusFilePaths.d.ts → crawlPlusFiles.d.ts} +2 -2
  23. package/dist/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +71 -0
  24. package/dist/node/vite/shared/resolveVikeConfigInternal/{getPlusFilesByLocationId.d.ts → getPlusFiles.d.ts} +2 -2
  25. package/dist/node/vite/shared/resolveVikeConfigInternal/{getPlusFilesByLocationId.js → getPlusFiles.js} +4 -5
  26. package/dist/node/vite/shared/resolveVikeConfigInternal/loadFileAtConfigTime.d.ts +1 -1
  27. package/dist/node/vite/shared/resolveVikeConfigInternal/metaBuiltIn.js +4 -0
  28. package/dist/node/vite/shared/resolveVikeConfigInternal.d.ts +2 -2
  29. package/dist/node/vite/shared/resolveVikeConfigInternal.js +5 -5
  30. package/dist/server/runtime/fetch.d.ts +1 -1
  31. package/dist/server/runtime/globalContext.d.ts +81 -81
  32. package/dist/server/runtime/renderPageServer/createPageContextServer.d.ts +22 -22
  33. package/dist/server/runtime/renderPageServer/execHookServer.d.ts +4 -3
  34. package/dist/server/runtime/renderPageServer/html/injectAssets/injectHtmlTags.js +3 -1
  35. package/dist/server/runtime/renderPageServer/loadPageConfigsLazyServerSide.d.ts +22 -22
  36. package/dist/server/runtime/renderPageServer/renderPageServerAfterRoute.d.ts +88 -88
  37. package/dist/server/runtime/renderPageServer.d.ts +22 -22
  38. package/dist/server/runtime/universal-middleware.d.ts +1 -1
  39. package/dist/shared-server-client/createGlobalContextShared.d.ts +20 -20
  40. package/dist/shared-server-client/getPageFiles/fileTypes.d.ts +1 -1
  41. package/dist/shared-server-client/hooks/execHook.d.ts +14 -5
  42. package/dist/shared-server-client/modifyUrlSameOrigin.js +1 -1
  43. package/dist/shared-server-client/page-configs/resolveVikeConfigPublic.d.ts +19 -19
  44. package/dist/shared-server-node/getFileSuffixes.d.ts +1 -1
  45. package/dist/types/Config.d.ts +21 -1
  46. package/dist/types/PageConfig.d.ts +1 -1
  47. package/dist/utils/PROJECT_VERSION.d.ts +1 -1
  48. package/dist/utils/PROJECT_VERSION.js +1 -1
  49. package/dist/utils/assertViteVersion.js +1 -1
  50. package/dist/utils/crawlFiles/ignorePatternsBuiltIn.d.ts +1 -0
  51. package/dist/{node/vite/shared/resolveVikeConfigInternal/crawlPlusFilePaths → utils/crawlFiles}/ignorePatternsBuiltIn.js +1 -1
  52. package/dist/utils/crawlFiles.d.ts +21 -0
  53. package/dist/utils/crawlFiles.js +195 -0
  54. package/dist/utils/genRandomId.d.ts +2 -0
  55. package/dist/utils/{getRandomId.js → genRandomId.js} +2 -2
  56. package/dist/{node/vite/shared → utils}/getEnvVarObject.d.ts +0 -1
  57. package/dist/{node/vite/shared → utils}/getEnvVarObject.js +4 -3
  58. package/dist/utils/getViteRPC.js +2 -2
  59. package/dist/utils/humanizeTime.d.ts +1 -1
  60. package/dist/utils/setTimeoutUnref.d.ts +2 -0
  61. package/dist/utils/setTimeoutUnref.js +11 -0
  62. package/package.json +11 -11
  63. package/dist/node/vite/shared/resolveVikeConfigInternal/crawlPlusFilePaths/ignorePatternsBuiltIn.d.ts +0 -2
  64. package/dist/node/vite/shared/resolveVikeConfigInternal/crawlPlusFilePaths.js +0 -259
  65. package/dist/utils/getRandomId.d.ts +0 -2
@@ -114,41 +114,41 @@ declare function resolvePageContextConfig(pageFiles: PageFile[], // V0.4 design
114
114
  pageConfig: PageConfigRuntimeLoaded | null, // V1 design
115
115
  pageConfigGlobal: PageConfigGlobalRuntime): PageContextConfig;
116
116
  declare function resolveGlobalContextConfig(pageConfigs: PageConfigRuntime[], pageConfigGlobal: PageConfigGlobalRuntime): {
117
+ config: ConfigResolved;
118
+ _source: Source;
119
+ _sources: Sources;
120
+ _from: From;
121
+ pages: {
122
+ [k: string]: PageConfigPublicWithRoute;
123
+ };
117
124
  _globalConfigPublic: {
118
- pages: {
119
- [k: string]: PageConfigPublicWithRoute;
120
- };
121
125
  config: ConfigResolved;
122
126
  _source: Source;
123
127
  _sources: Sources;
124
128
  _from: From;
129
+ pages: {
130
+ [k: string]: PageConfigPublicWithRoute;
131
+ };
125
132
  };
126
- pages: {
127
- [k: string]: PageConfigPublicWithRoute;
128
- };
133
+ };
134
+ type GlobalConfigPublic = Omit<ReturnType<typeof resolveGlobalConfigPublic>, '_globalConfigPublic'>;
135
+ declare function resolveGlobalConfigPublic<PageConfig extends PageConfigRuntime | PageConfigBuildTime, PageConfigGlobal extends PageConfigGlobalRuntime | PageConfigGlobalBuildTime>(pageConfigs: PageConfig[], pageConfigGlobal: PageConfigGlobal, getConfigValues: (config: PageConfig | PageConfigGlobal, isGlobalConfig?: true) => ConfigValues): {
129
136
  config: ConfigResolved;
130
137
  _source: Source;
131
138
  _sources: Sources;
132
139
  _from: From;
133
- };
134
- type GlobalConfigPublic = Omit<ReturnType<typeof resolveGlobalConfigPublic>, '_globalConfigPublic'>;
135
- declare function resolveGlobalConfigPublic<PageConfig extends PageConfigRuntime | PageConfigBuildTime, PageConfigGlobal extends PageConfigGlobalRuntime | PageConfigGlobalBuildTime>(pageConfigs: PageConfig[], pageConfigGlobal: PageConfigGlobal, getConfigValues: (config: PageConfig | PageConfigGlobal, isGlobalConfig?: true) => ConfigValues): {
140
+ pages: {
141
+ [k: string]: PageConfigPublicWithRoute;
142
+ };
136
143
  _globalConfigPublic: {
137
- pages: {
138
- [k: string]: PageConfigPublicWithRoute;
139
- };
140
144
  config: ConfigResolved;
141
145
  _source: Source;
142
146
  _sources: Sources;
143
147
  _from: From;
148
+ pages: {
149
+ [k: string]: PageConfigPublicWithRoute;
150
+ };
144
151
  };
145
- pages: {
146
- [k: string]: PageConfigPublicWithRoute;
147
- };
148
- config: ConfigResolved;
149
- _source: Source;
150
- _sources: Sources;
151
- _from: From;
152
152
  };
153
153
  declare function resolveConfigPublic_V1Design(pageConfig: {
154
154
  configValues: ConfigValues;
@@ -1,6 +1,6 @@
1
1
  export { getFileSuffixes };
2
2
  export { suffixesAssertFileEnv };
3
- declare const suffixesAssertFileEnv: readonly ["server", "client", "ssr"];
3
+ declare const suffixesAssertFileEnv: readonly ['server', 'client', 'ssr'];
4
4
  declare const suffixes: readonly ["server", "client", "ssr", "shared", "clear", "default"];
5
5
  type Suffix = (typeof suffixes)[number];
6
6
  declare function getFileSuffixes(fileName: string): Suffix[];
@@ -57,7 +57,7 @@ type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRende
57
57
  type HookNameGlobal = 'onBeforeRoute' | 'onPrerenderStart' | 'onCreatePageContext' | 'onCreateGlobalContext' | 'onError' | 'onHookCall';
58
58
  type HookNameOldDesign = 'render' | 'prerender' | 'onBeforePrerender';
59
59
  type ConfigNameBuiltIn = Exclude<keyof ConfigBuiltIn, keyof VikeVitePluginOptions | 'onBeforeRoute' | 'onPrerenderStart' | 'vite' | 'redirects' | 'pages'> | 'prerender' | 'hasServerOnlyHook' | 'isClientRuntimeLoaded' | 'onBeforeRenderEnv' | 'dataEnv' | 'guardEnv' | 'hooksTimeout' | 'clientHooks' | 'middleware' | 'server' | 'vercel';
60
- type ConfigNameBuiltInGlobal = 'onPrerenderStart' | 'onBeforeRoute' | 'pages' | 'prerender' | 'disableAutoFullBuild' | 'includeAssetsImportedByServer' | 'baseAssets' | 'baseServer' | 'redirects' | 'trailingSlash' | 'disableUrlNormalization' | 'vite';
60
+ type ConfigNameBuiltInGlobal = 'onPrerenderStart' | 'onBeforeRoute' | 'pages' | 'prerender' | 'ai' | 'disableAutoFullBuild' | 'includeAssetsImportedByServer' | 'baseAssets' | 'baseServer' | 'redirects' | 'trailingSlash' | 'disableUrlNormalization' | 'vite';
61
61
  type Config = ConfigBuiltIn & Vike.Config;
62
62
  /** @deprecated This type is deprecated, see:
63
63
  * - https://vike.dev/migration/hook-types
@@ -583,6 +583,26 @@ type ConfigBuiltIn = {
583
583
  * https://vike.dev/vercel
584
584
  */
585
585
  vercel?: Vercel;
586
+ /**
587
+ * Setting for Vike's AI integration.
588
+ *
589
+ * https://vike.dev/ai
590
+ */
591
+ ai?: ConfigAi;
592
+ };
593
+ type ConfigAi = {
594
+ /**
595
+ * Whether Vike automatically adds and updates `vike/SKILL.md` inside skills directories (e.g. `.agents/skills/` and `.claude/skills/`).
596
+ *
597
+ * - `true`: add `vike/SKILL.md` to every existing `skills/` directory
598
+ * - `false`: never add `vike/SKILL.md`
599
+ * - `string[]`: add `vike/SKILL.md` to exactly these directories
600
+ *
601
+ * @default true
602
+ *
603
+ * https://vike.dev/ai#skill
604
+ */
605
+ skill?: boolean | string[];
586
606
  };
587
607
  type Vercel = {
588
608
  /**
@@ -24,7 +24,7 @@ import type { ConfigValueSerialized } from '../shared-server-client/page-configs
24
24
  import type { LocationId } from '../node/vite/shared/resolveVikeConfigInternal/filesystemRouting.js';
25
25
  import type { FilePath } from './FilePath.js';
26
26
  import type { ConfigDefinitionsInternal } from '../node/vite/shared/resolveVikeConfigInternal/metaBuiltIn.js';
27
- import type { PlusFile } from '../node/vite/shared/resolveVikeConfigInternal/getPlusFilesByLocationId.js';
27
+ import type { PlusFile } from '../node/vite/shared/resolveVikeConfigInternal/getPlusFiles.js';
28
28
  import type { ApiOperation } from '../node/api/types.js';
29
29
  type PageConfigCommon = {
30
30
  pageId: string;
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.260";
1
+ export declare const PROJECT_VERSION: '0.4.261';
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.260';
2
+ export const PROJECT_VERSION = '0.4.261';
@@ -2,7 +2,7 @@ export { assertViteVersion };
2
2
  export { viteVersionMin };
3
3
  import { assertVersion } from './assertVersion.js';
4
4
  const viteVersionMin = '6.3.0';
5
- // node_modules/vike/package.json#peerDependencies isn't enough, as users often ignore it
5
+ // package.json#peerDependencies isn't enough, as users often ignore it
6
6
  function assertViteVersion(viteVersion) {
7
7
  // - This assertion isn't reliable: the user may still use a Vite version older than 6.0.0 — see https://github.com/vitejs/vite/pull/19355
8
8
  // - TO-DO/eventually: let's also use this.meta.viteVersion
@@ -0,0 +1 @@
1
+ export declare const ignorePatternsBuiltIn: readonly ['**/node_modules/**', '**/.git/**', '**/ejected/**', '**/*.telefunc.*', '**/.history/**', '**/*.generated.*', '**/*.spec.*', '**/*.test.*'];
@@ -1,6 +1,6 @@
1
- import '../../../assertEnvVite.js';
2
1
  export const ignorePatternsBuiltIn = [
3
2
  '**/node_modules/**',
3
+ '**/.git/**',
4
4
  // Ejected Vike extensions, see https://github.com/snake-py/eject
5
5
  '**/ejected/**',
6
6
  // Allow:
@@ -0,0 +1,21 @@
1
+ export { crawlFiles };
2
+ declare const globstar = "**/";
3
+ type FilePattern = `${typeof globstar}${'+*' | 'skills/*/SKILL'}`;
4
+ /**
5
+ * Crawl the files matching `filePattern`, using `$ git ls-files` and, as a fallback, [tinyglobby](https://github.com/SuperchupuDev/tinyglobby).
6
+ */
7
+ declare function crawlFiles(options: {
8
+ filePattern: FilePattern;
9
+ fileExtension: readonly string[];
10
+ cwd: string;
11
+ /**
12
+ * Whether dotfiles and dot directories are crawled.
13
+ *
14
+ * Same as tinyglobby's `dot` option.
15
+ */
16
+ dot: boolean;
17
+ /**
18
+ * Whether to fallback to tinyglobby if `$ git ls-files` doesn't find any file.
19
+ */
20
+ globFallback: boolean;
21
+ }): Promise<string[]>;
@@ -0,0 +1,195 @@
1
+ export { crawlFiles };
2
+ import { assert, assertUsage, assertWarning } from './assert.js';
3
+ import { assertIsNotProductionRuntime } from './assertSetup.js';
4
+ import { isVersionMatch } from './assertVersion.js';
5
+ import { createDebug } from './debug.js';
6
+ import { deepEqual } from './deepEqual.js';
7
+ import { getGlobalObject } from './getGlobalObject.js';
8
+ import { hasProp } from './hasProp.js';
9
+ import { isNotNullish } from './isNullish.js';
10
+ import path from 'node:path';
11
+ import { glob as tinyglobby } from 'tinyglobby';
12
+ import { exec } from 'node:child_process';
13
+ import { promisify } from 'node:util';
14
+ import { getEnvVarObject } from './getEnvVarObject.js';
15
+ import pc from '@brillout/picocolors';
16
+ import picomatch from 'picomatch';
17
+ import { ignorePatternsBuiltIn } from './crawlFiles/ignorePatternsBuiltIn.js';
18
+ assertIsNotProductionRuntime();
19
+ const execA = promisify(exec);
20
+ const debug = createDebug('vike:crawl');
21
+ const globalObject = getGlobalObject('crawlFiles.ts', {
22
+ gitIsNotUsable: false,
23
+ });
24
+ const globstar = '**/';
25
+ /**
26
+ * Crawl the files matching `filePattern`, using `$ git ls-files` and, as a fallback, [tinyglobby](https://github.com/SuperchupuDev/tinyglobby).
27
+ */
28
+ async function crawlFiles(options) {
29
+ const { filePattern, fileExtension, cwd, dot, globFallback } = options;
30
+ const userSettings = getUserSettings();
31
+ const globOptions = { cwd, dot, nocase: false, ignore: getIgnorePatterns(userSettings) };
32
+ // One pattern per file extension (the `filePattern` skips the file extension)
33
+ assert(!path.posix.basename(filePattern).includes('.'));
34
+ const patterns = fileExtension.map((ext) => `${filePattern}.${ext}`);
35
+ // Crawl
36
+ const filesGit = userSettings.git !== false && (await crawlGit(patterns, cwd, globOptions));
37
+ const useGlob =
38
+ // `!filesGit` => Git isn't usable => we *have* to use tinyglobby
39
+ !filesGit ||
40
+ // `filesGit.length === 0` => fallback to tinyglobby if globFallback is true
41
+ (filesGit.length === 0 && globFallback);
42
+ const filesGlob = (useGlob || debug.isActivated) && (await crawlGlob(patterns, globOptions));
43
+ const files = useGlob ? filesGlob : filesGit;
44
+ assert(files);
45
+ if (debug.isActivated && filesGit && filesGlob) {
46
+ assertWarning(deepEqual(filesGlob.slice().sort(), filesGit.slice().sort()), "Git and glob results aren't matching.", { onlyOnce: false });
47
+ }
48
+ return files;
49
+ }
50
+ // Same as crawlGlob() but using `$ git ls-files`
51
+ async function crawlGit(patterns, cwd, globOptions) {
52
+ if (globalObject.gitIsNotUsable)
53
+ return null;
54
+ // Preserve UTF-8 file paths.
55
+ // https://github.com/vikejs/vike/issues/1658
56
+ // https://stackoverflow.com/questions/22827239/how-to-make-git-properly-display-utf-8-encoded-pathnames-in-the-console-window/22828826#22828826
57
+ // https://stackoverflow.com/questions/15884180/how-do-i-override-git-configuration-options-by-command-line-parameters/15884261#15884261
58
+ const preserveUTF8 = '-c core.quotepath=off';
59
+ const cmd = [
60
+ 'git',
61
+ preserveUTF8,
62
+ 'ls-files',
63
+ // Performance gain seems negligible: https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
64
+ ...patterns.flatMap((pattern) => {
65
+ // A leading `**/` doesn't match the root directory: we therefore add a second pattern for it — e.g. `**/+*.js` doesn't match `+config.js` while `+*.js` does
66
+ const patternRootDir = pattern.slice(globstar.length);
67
+ assert(!patternRootDir.includes(globstar)); // `**/` in the middle of the pattern isn't supported (e.g. `pages/**/+*.js` doesn't match `pages/+Page.js`)
68
+ return [`"${pattern}"`, `"${patternRootDir}"`];
69
+ }),
70
+ // Performance gain is non-negligible.
71
+ // - https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
72
+ // - When node_modules/ is untracked the performance gain could be significant?
73
+ ...globOptions.ignore.map((pattern) => `--exclude="${pattern}"`),
74
+ // --others --exclude-standard => list untracked files (--others) while using .gitignore (--exclude-standard)
75
+ // --cached => list tracked files
76
+ '--others --exclude-standard --cached',
77
+ ].join(' ');
78
+ let filesAll;
79
+ let filesDeleted;
80
+ try {
81
+ ;
82
+ [filesAll, filesDeleted] = await Promise.all([
83
+ // Main command
84
+ runCmd1(cmd, cwd),
85
+ // Get tracked but deleted files
86
+ runCmd1('git ls-files --deleted', cwd),
87
+ ]);
88
+ }
89
+ catch (err) {
90
+ if (await isGitNotUsable(cwd)) {
91
+ globalObject.gitIsNotUsable = true;
92
+ return null;
93
+ }
94
+ throw err;
95
+ }
96
+ if (debug.isActivated) {
97
+ debug('[git] cwd:', cwd);
98
+ debug('[git] cmd:', cmd);
99
+ debug('[git] result:', filesAll);
100
+ debug('[git] filesDeleted:', filesDeleted);
101
+ }
102
+ // We have to filter again here because:
103
+ // - `$ git ls-files` matches more since wildcards are deep — e.g. `+*.js` matches `pages/+some-dir/some-file.js`
104
+ // - the option --exclude of `$ git ls-files` only applies to untracked files. (We use --exclude only to speed up the `$ git ls-files` command.)
105
+ const isMatch = picomatch(patterns, globOptions);
106
+ const isDeleted = new Set(filesDeleted);
107
+ const files = filesAll.filter((filePath) => isMatch(filePath) && !isDeleted.has(filePath));
108
+ return files;
109
+ }
110
+ // Same as crawlGit() but using tinyglobby
111
+ async function crawlGlob(patterns, globOptions) {
112
+ const files = await tinyglobby(patterns, globOptions);
113
+ // Make build deterministic, in order to get a stable generated hash for dist/client/assets/entries/entry-client-routing.${hash}.js
114
+ // https://github.com/vikejs/vike/pull/1750
115
+ files.sort();
116
+ if (debug.isActivated) {
117
+ debug('[glob] patterns:', patterns);
118
+ debug('[glob] options:', globOptions);
119
+ debug('[glob] result:', files);
120
+ }
121
+ return files;
122
+ }
123
+ // Whether Git is installed and whether we can use it
124
+ async function isGitNotUsable(cwd) {
125
+ // Check Git version
126
+ {
127
+ const res = await runCmd2('git --version', cwd);
128
+ if ('err' in res)
129
+ return true;
130
+ let { stdout, stderr } = res;
131
+ assert(stderr === '');
132
+ const prefix = 'git version ';
133
+ assert(stdout.startsWith(prefix));
134
+ const gitVersion = stdout.slice(prefix.length);
135
+ // - Works with Git 2.43.1 but also (most certainly) with earlier versions.
136
+ // - We didn't bother test which is the earliest version that works.
137
+ // - Git 2.32.0 doesn't seem to work: https://github.com/vikejs/vike/discussions/1549
138
+ // - Maybe it's because of StackBlitz: looking at the release notes, Git 2.32.0 should be working.
139
+ if (!isVersionMatch(gitVersion, ['2.43.1']))
140
+ return true;
141
+ }
142
+ // Is cwd inside a Git repository?
143
+ {
144
+ const res = await runCmd2('git rev-parse --is-inside-work-tree', cwd);
145
+ if ('err' in res)
146
+ return true;
147
+ let { stdout, stderr } = res;
148
+ assert(stderr === '');
149
+ assert(stdout === 'true');
150
+ return false;
151
+ }
152
+ }
153
+ async function runCmd1(cmd, cwd) {
154
+ const { stdout } = await execA(cmd, {
155
+ cwd,
156
+ // https://github.com/vikejs/vike/issues/1982
157
+ maxBuffer: Infinity,
158
+ });
159
+ /* Not always true: https://github.com/vikejs/vike/issues/1440#issuecomment-1892831303
160
+ assert(res.stderr === '')
161
+ */
162
+ return stdout.toString().split('\n').filter(Boolean);
163
+ }
164
+ async function runCmd2(cmd, cwd) {
165
+ let res;
166
+ try {
167
+ res = await execA(cmd, { cwd });
168
+ }
169
+ catch (err) {
170
+ return { err };
171
+ }
172
+ let { stdout, stderr } = res;
173
+ stdout = stdout.toString().trim();
174
+ stderr = stderr.toString().trim();
175
+ return { stdout, stderr };
176
+ }
177
+ function getUserSettings() {
178
+ const userSettings = getEnvVarObject('VIKE_CRAWL') ?? {};
179
+ const wrongUsage = (settingName, settingType) => `Setting ${pc.cyan(settingName)} in VIKE_CRAWL should be a ${pc.cyan(settingType)}`;
180
+ assertUsage(hasProp(userSettings, 'git', 'boolean') || hasProp(userSettings, 'git', 'undefined'), wrongUsage('git', 'boolean'));
181
+ assertUsage(hasProp(userSettings, 'ignore', 'string[]') ||
182
+ hasProp(userSettings, 'ignore', 'string') ||
183
+ hasProp(userSettings, 'ignore', 'undefined'), wrongUsage('ignore', 'string or an array of strings'));
184
+ assertUsage(hasProp(userSettings, 'ignoreBuiltIn', 'boolean') || hasProp(userSettings, 'ignoreBuiltIn', 'undefined'), wrongUsage('ignoreBuiltIn', 'boolean'));
185
+ const settingNames = ['git', 'ignore', 'ignoreBuiltIn'];
186
+ Object.keys(userSettings).forEach((name) => {
187
+ assertUsage(settingNames.includes(name), `Unknown setting ${pc.bold(pc.red(name))} in VIKE_CRAWL`);
188
+ });
189
+ return userSettings;
190
+ }
191
+ function getIgnorePatterns(userSettings) {
192
+ const ignorePatternsSetByUser = [userSettings.ignore].flat().filter(isNotNullish);
193
+ const { ignoreBuiltIn } = userSettings;
194
+ return [...(ignoreBuiltIn === false ? [] : ignorePatternsBuiltIn), ...ignorePatternsSetByUser];
195
+ }
@@ -0,0 +1,2 @@
1
+ export { genRandomId };
2
+ declare function genRandomId(length?: number): string;
@@ -1,7 +1,7 @@
1
- export { getRandomId };
1
+ export { genRandomId };
2
2
  import { assert } from './assert.js';
3
3
  // https://stackoverflow.com/questions/1349404/generate-random-string-characters-in-javascript
4
- function getRandomId(length = 12) {
4
+ function genRandomId(length = 12) {
5
5
  let randomId = '';
6
6
  while (randomId.length < length) {
7
7
  randomId += Math.random().toString(36).slice(2);
@@ -1,5 +1,4 @@
1
1
  export { getEnvVarObject };
2
2
  export { parseJson5 };
3
- import '../assertEnvVite.js';
4
3
  declare function getEnvVarObject(envVarName: 'VITE_CONFIG' | 'VIKE_CRAWL' | 'VIKE_CONFIG'): null | Record<string, unknown>;
5
4
  declare function parseJson5(valueStr: string, what: string): unknown;
@@ -1,10 +1,11 @@
1
1
  export { getEnvVarObject };
2
2
  export { parseJson5 };
3
3
  import pc from '@brillout/picocolors';
4
- import { assertUsage } from '../../../utils/assert.js';
5
- import { isObject } from '../../../utils/isObject.js';
4
+ import { assertUsage } from './assert.js';
5
+ import { isObject } from './isObject.js';
6
6
  import JSON5 from 'json5';
7
- import '../assertEnvVite.js';
7
+ import { assertIsNotProductionRuntime } from './assertSetup.js';
8
+ assertIsNotProductionRuntime();
8
9
  function getEnvVarObject(envVarName) {
9
10
  const valueStr = process.env[envVarName];
10
11
  if (!valueStr)
@@ -2,7 +2,7 @@ export { getViteRPC }; // consumer (aka RPC client)
2
2
  export { createViteRPC }; // provider (aka RPC server)
3
3
  import { assert } from './assert.js';
4
4
  import { genPromise } from './genPromise.js';
5
- import { getRandomId } from './getRandomId.js';
5
+ import { genRandomId } from './genRandomId.js';
6
6
  import { getGlobalObject } from './getGlobalObject.js';
7
7
  import { createDebug } from './debug.js';
8
8
  import { assertIsNotBrowser } from './assertIsNotBrowser.js';
@@ -35,7 +35,7 @@ function createRpcClient() {
35
35
  return async (...functionArgs) => {
36
36
  const hot = import.meta.hot;
37
37
  assert(hot);
38
- const callId = getRandomId();
38
+ const callId = genRandomId();
39
39
  const { promise, resolve } = genPromise({ timeout: 10 * 1000 });
40
40
  listeners.push({
41
41
  callId,
@@ -1,2 +1,2 @@
1
1
  export { humanizeTime };
2
- declare function humanizeTime(milliseconds: number): `${string} second` | `${string} seconds` | `${string} minute` | `${string} minutes`;
2
+ declare function humanizeTime(milliseconds: number): `${string} minute` | `${string} minutes` | `${string} second` | `${string} seconds`;
@@ -0,0 +1,2 @@
1
+ export { setTimeoutUnref };
2
+ declare function setTimeoutUnref(callback: () => void, milliseconds: number): ReturnType<typeof setTimeout>;
@@ -0,0 +1,11 @@
1
+ export { setTimeoutUnref };
2
+ // Same as setTimeout() but the timer never keeps the Node.js process alive (e.g. upon programmatic dev server usage that exits quickly, the process shouldn't linger because of some pending bookkeeping timer).
3
+ // - https://nodejs.org/api/timers.html#timeoutunref
4
+ // - Only use it for auxiliary timers (bookkeeping, diagnostics, background work) — never for:
5
+ // - Timers that resume the main flow (e.g. sleep()): the process could exit before the timer fires.
6
+ // - Watchdog timers (e.g. hooksTimeout, genPromise() timeout): their purpose is to fire when everything else hangs — being the last thing that keeps the process alive is their job (without them Node.js would silently exit with code 0).
7
+ function setTimeoutUnref(callback, milliseconds) {
8
+ const timeout = setTimeout(callback, milliseconds);
9
+ timeout.unref?.();
10
+ return timeout;
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.260",
3
+ "version": "0.4.261",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -127,24 +127,24 @@
127
127
  "@brillout/import": "^0.2.6",
128
128
  "@brillout/json-serializer": "^0.5.25",
129
129
  "@brillout/picocolors": "^1.0.31",
130
- "@brillout/vite-plugin-server-entry": "0.7.19",
131
- "@universal-deploy/store": "^0.2.1",
132
- "@universal-deploy/vite": "^0.1.10",
130
+ "@brillout/vite-plugin-server-entry": "^0.7.20",
131
+ "@universal-deploy/store": "^0.2.2",
132
+ "@universal-deploy/vite": "^0.1.11",
133
133
  "@universal-middleware/core": "^0.4.18",
134
- "@universal-middleware/node": "^0.2.1",
134
+ "@universal-middleware/node": "^0.2.2",
135
135
  "cac": "^6.0.0",
136
136
  "convert-route": "^1.1.1",
137
137
  "es-module-lexer": "^1.0.0",
138
138
  "esbuild": ">=0.19.0",
139
139
  "json5": "^2.0.0",
140
- "magic-string": "^0.30.17",
141
- "picomatch": "^4.0.4",
140
+ "magic-string": "^1.2.0",
141
+ "picomatch": "^4.0.5",
142
142
  "semver": "^7.8.5",
143
143
  "sirv": "^3.0.2",
144
144
  "source-map-support": "^0.5.0",
145
145
  "tinyglobby": "^0.2.17",
146
146
  "vite": ">=6.3.0",
147
- "vite-plugin-wrapper": "^0.1.0"
147
+ "vite-plugin-wrapper": "^0.1.1"
148
148
  },
149
149
  "peerDependencies": {
150
150
  "react-streaming": ">=0.3.42",
@@ -259,17 +259,17 @@
259
259
  "./fetch.js"
260
260
  ],
261
261
  "devDependencies": {
262
- "@brillout/release-me": "^0.4.15",
262
+ "@brillout/release-me": "^0.4.16",
263
263
  "@types/babel__core": "^7.20.5",
264
264
  "@types/estree": "^1.0.5",
265
265
  "@types/node": "^20.10.5",
266
- "@types/picomatch": "^4.0.2",
266
+ "@types/picomatch": "^4.0.3",
267
267
  "@types/semver": "^7.7.1",
268
268
  "@types/source-map-support": "^0.5.10",
269
269
  "react-streaming": "^0.4.20",
270
270
  "rimraf": "^6.1.3",
271
271
  "rolldown": "1.0.0-rc.17",
272
- "typescript": "^5.9.3",
272
+ "typescript": "^7.0.2",
273
273
  "vite": "^7.2.6"
274
274
  },
275
275
  "ai": "@AI (CRITICAL FOR AI AGENTS): ALWAYS LOAD https://vike.dev/llms.txt (Vike documentation index) in your context when using Vike",
@@ -1,2 +0,0 @@
1
- import '../../../assertEnvVite.js';
2
- export declare const ignorePatternsBuiltIn: readonly ["**/node_modules/**", "**/ejected/**", "**/*.telefunc.*", "**/.history/**", "**/*.generated.*", "**/*.spec.*", "**/*.test.*"];