vite 5.1.0-beta.4 → 5.1.0-beta.6

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,324 @@
1
+ import { ModuleNamespace, ViteHotContext } from '../../types/hot.js';
2
+ import { Update, HMRPayload } from '../../types/hmrPayload.js';
3
+ import { InferCustomEventPayload } from '../../types/customEvent.js';
4
+
5
+ type CustomListenersMap = Map<string, ((data: any) => void)[]>;
6
+ interface HotModule {
7
+ id: string;
8
+ callbacks: HotCallback[];
9
+ }
10
+ interface HotCallback {
11
+ deps: string[];
12
+ fn: (modules: Array<ModuleNamespace | undefined>) => void;
13
+ }
14
+ interface HMRLogger {
15
+ error(msg: string | Error): void;
16
+ debug(...msg: unknown[]): void;
17
+ }
18
+ interface HMRConnection {
19
+ /**
20
+ * Checked before sending messages to the client.
21
+ */
22
+ isReady(): boolean;
23
+ /**
24
+ * Send message to the client.
25
+ */
26
+ send(messages: string): void;
27
+ }
28
+ declare class HMRMessenger {
29
+ private connection;
30
+ constructor(connection: HMRConnection);
31
+ private queue;
32
+ send(message: string): void;
33
+ flush(): void;
34
+ }
35
+ declare class HMRClient {
36
+ logger: HMRLogger;
37
+ private importUpdatedModule;
38
+ hotModulesMap: Map<string, HotModule>;
39
+ disposeMap: Map<string, (data: any) => void | Promise<void>>;
40
+ pruneMap: Map<string, (data: any) => void | Promise<void>>;
41
+ dataMap: Map<string, any>;
42
+ customListenersMap: CustomListenersMap;
43
+ ctxToListenersMap: Map<string, CustomListenersMap>;
44
+ messenger: HMRMessenger;
45
+ constructor(logger: HMRLogger, connection: HMRConnection, importUpdatedModule: (update: Update) => Promise<ModuleNamespace>);
46
+ notifyListeners<T extends string>(event: T, data: InferCustomEventPayload<T>): Promise<void>;
47
+ clear(): void;
48
+ prunePaths(paths: string[]): void;
49
+ protected warnFailedUpdate(err: Error, path: string | string[]): void;
50
+ private updateQueue;
51
+ private pendingUpdateQueue;
52
+ /**
53
+ * buffer multiple hot updates triggered by the same src change
54
+ * so that they are invoked in the same order they were sent.
55
+ * (otherwise the order may be inconsistent because of the http request round trip)
56
+ */
57
+ queueUpdate(payload: Update): Promise<void>;
58
+ private fetchUpdate;
59
+ }
60
+
61
+ interface SourceMapLike {
62
+ version: number;
63
+ mappings?: string;
64
+ names?: string[];
65
+ sources?: string[];
66
+ sourcesContent?: string[];
67
+ }
68
+ declare class DecodedMap {
69
+ map: SourceMapLike;
70
+ _encoded: string;
71
+ _decoded: undefined | number[][][];
72
+ _decodedMemo: Stats;
73
+ url: string;
74
+ version: number;
75
+ names: string[];
76
+ resolvedSources: string[];
77
+ constructor(map: SourceMapLike, from: string);
78
+ }
79
+ interface Stats {
80
+ lastKey: number;
81
+ lastNeedle: number;
82
+ lastIndex: number;
83
+ }
84
+
85
+ declare class ModuleCacheMap extends Map<string, ModuleCache> {
86
+ private root;
87
+ constructor(root: string, entries?: [string, ModuleCache][]);
88
+ normalize(fsPath: string): string;
89
+ /**
90
+ * Assign partial data to the map
91
+ */
92
+ update(fsPath: string, mod: ModuleCache): this;
93
+ setByModuleId(modulePath: string, mod: ModuleCache): this;
94
+ set(fsPath: string, mod: ModuleCache): this;
95
+ getByModuleId(modulePath: string): ModuleCache;
96
+ get(fsPath: string): ModuleCache;
97
+ deleteByModuleId(modulePath: string): boolean;
98
+ delete(fsPath: string): boolean;
99
+ /**
100
+ * Invalidate modules that dependent on the given modules, up to the main entry
101
+ */
102
+ invalidateDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
103
+ /**
104
+ * Invalidate dependency modules of the given modules, down to the bottom-level dependencies
105
+ */
106
+ invalidateSubDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
107
+ getSourceMap(moduleId: string): null | DecodedMap;
108
+ }
109
+
110
+ declare const ssrModuleExportsKey = "__vite_ssr_exports__";
111
+ declare const ssrImportKey = "__vite_ssr_import__";
112
+ declare const ssrDynamicImportKey = "__vite_ssr_dynamic_import__";
113
+ declare const ssrExportAllKey = "__vite_ssr_exportAll__";
114
+ declare const ssrImportMetaKey = "__vite_ssr_import_meta__";
115
+
116
+ interface ViteRuntimeDebugger {
117
+ (formatter: unknown, ...args: unknown[]): void;
118
+ }
119
+ declare class ViteRuntime {
120
+ options: ViteRuntimeOptions;
121
+ runner: ViteModuleRunner;
122
+ private debug?;
123
+ /**
124
+ * Holds the cache of modules
125
+ * Keys of the map are ids
126
+ */
127
+ moduleCache: ModuleCacheMap;
128
+ hmrClient?: HMRClient;
129
+ entrypoints: Set<string>;
130
+ private idToUrlMap;
131
+ private fileToIdMap;
132
+ private envProxy;
133
+ private _destroyed;
134
+ private _resetSourceMapSupport?;
135
+ constructor(options: ViteRuntimeOptions, runner: ViteModuleRunner, debug?: ViteRuntimeDebugger | undefined);
136
+ /**
137
+ * URL to execute. Accepts file path, server path or id relative to the root.
138
+ */
139
+ executeUrl<T = any>(url: string): Promise<T>;
140
+ /**
141
+ * Entrypoint URL to execute. Accepts file path, server path or id relative to the root.
142
+ * In the case of a full reload triggered by HMR, this is the module that will be reloaded.
143
+ * If this method is called multiple times, all entrypoints will be reloaded one at a time.
144
+ */
145
+ executeEntrypoint<T = any>(url: string): Promise<T>;
146
+ /**
147
+ * Clear all caches including HMR listeners.
148
+ */
149
+ clearCache(): void;
150
+ /**
151
+ * Clears all caches, removes all HMR listeners, and resets source map support.
152
+ * This method doesn't stop the HMR connection.
153
+ */
154
+ destroy(): Promise<void>;
155
+ /**
156
+ * Returns `true` if the runtime has been destroyed by calling `destroy()` method.
157
+ */
158
+ isDestroyed(): boolean;
159
+ private invalidateFiles;
160
+ private normalizeEntryUrl;
161
+ private processImport;
162
+ private cachedRequest;
163
+ private cachedModule;
164
+ protected directRequest(id: string, fetchResult: ResolvedResult, _callstack: string[]): Promise<any>;
165
+ }
166
+
167
+ interface RetrieveFileHandler {
168
+ (path: string): string | null | undefined | false;
169
+ }
170
+ interface RetrieveSourceMapHandler {
171
+ (path: string): null | {
172
+ url: string;
173
+ map: any;
174
+ };
175
+ }
176
+ interface InterceptorOptions {
177
+ retrieveFile?: RetrieveFileHandler;
178
+ retrieveSourceMap?: RetrieveSourceMapHandler;
179
+ }
180
+
181
+ interface DefineImportMetadata {
182
+ /**
183
+ * Imported names before being transformed to `ssrImportKey`
184
+ *
185
+ * import foo, { bar as baz, qux } from 'hello'
186
+ * => ['default', 'bar', 'qux']
187
+ *
188
+ * import * as namespace from 'world
189
+ * => undefined
190
+ */
191
+ importedNames?: string[];
192
+ }
193
+ interface HMRRuntimeConnection extends HMRConnection {
194
+ /**
195
+ * Configure how HMR is handled when this connection triggers an update.
196
+ * This method expects that connection will start listening for HMR updates and call this callback when it's received.
197
+ */
198
+ onUpdate(callback: (payload: HMRPayload) => void): void;
199
+ }
200
+ interface SSRImportMetadata extends DefineImportMetadata {
201
+ isDynamicImport?: boolean;
202
+ entrypoint?: boolean;
203
+ }
204
+ interface ViteRuntimeImportMeta extends ImportMeta {
205
+ url: string;
206
+ env: ImportMetaEnv;
207
+ hot?: ViteHotContext;
208
+ [key: string]: any;
209
+ }
210
+ interface ViteRuntimeModuleContext {
211
+ [ssrModuleExportsKey]: Record<string, any>;
212
+ [ssrImportKey]: (id: string, metadata?: DefineImportMetadata) => Promise<any>;
213
+ [ssrDynamicImportKey]: (id: string, options?: ImportCallOptions) => Promise<any>;
214
+ [ssrExportAllKey]: (obj: any) => void;
215
+ [ssrImportMetaKey]: ViteRuntimeImportMeta;
216
+ }
217
+ interface ViteModuleRunner {
218
+ /**
219
+ * Run code that was transformed by Vite.
220
+ * @param context Function context
221
+ * @param code Transformed code
222
+ * @param id ID that was used to fetch the module
223
+ */
224
+ runViteModule(context: ViteRuntimeModuleContext, code: string, id: string): Promise<any>;
225
+ /**
226
+ * Run externalized module.
227
+ * @param file File URL to the external module
228
+ */
229
+ runExternalModule(file: string): Promise<any>;
230
+ }
231
+ interface ModuleCache {
232
+ promise?: Promise<any>;
233
+ exports?: any;
234
+ evaluated?: boolean;
235
+ map?: DecodedMap;
236
+ meta?: FetchResult;
237
+ /**
238
+ * Module ids that imports this module
239
+ */
240
+ importers?: Set<string>;
241
+ imports?: Set<string>;
242
+ }
243
+ type FetchResult = ExternalFetchResult | ViteFetchResult;
244
+ interface ExternalFetchResult {
245
+ /**
246
+ * The path to the externalized module starting with file://,
247
+ * by default this will be imported via a dynamic "import"
248
+ * instead of being transformed by vite and loaded with vite runtime
249
+ */
250
+ externalize: string;
251
+ /**
252
+ * Type of the module. Will be used to determine if import statement is correct.
253
+ * For example, if Vite needs to throw an error if variable is not actually exported
254
+ */
255
+ type?: 'module' | 'commonjs' | 'builtin' | 'network';
256
+ }
257
+ interface ViteFetchResult {
258
+ /**
259
+ * Code that will be evaluated by vite runtime
260
+ * by default this will be wrapped in an async function
261
+ */
262
+ code: string;
263
+ /**
264
+ * File path of the module on disk.
265
+ * This will be resolved as import.meta.url/filename
266
+ */
267
+ file: string | null;
268
+ }
269
+ type ResolvedResult = (ExternalFetchResult | ViteFetchResult) & {
270
+ id: string;
271
+ };
272
+ /**
273
+ * @experimental
274
+ */
275
+ type FetchFunction = (id: string, importer?: string) => Promise<FetchResult>;
276
+ interface ViteRuntimeOptions {
277
+ /**
278
+ * Root of the project
279
+ */
280
+ root: string;
281
+ /**
282
+ * A method to get the information about the module.
283
+ * For SSR, Vite exposes `server.ssrFetchModule` function that you can use here.
284
+ * For other runtime use cases, Vite also exposes `fetchModule` from its main entry point.
285
+ */
286
+ fetchModule: FetchFunction;
287
+ /**
288
+ * Custom environment variables available on `import.meta.env`. This doesn't modify the actual `process.env`.
289
+ */
290
+ environmentVariables?: Record<string, any>;
291
+ /**
292
+ * Configure how source maps are resolved. Prefers `node` if `process.setSourceMapsEnabled` is available.
293
+ * Otherwise it will use `prepareStackTrace` by default which overrides `Error.prepareStackTrace` method.
294
+ * You can provide an object to configure how file contents and source maps are resolved for files that were not processed by Vite.
295
+ */
296
+ sourcemapInterceptor?: false | 'node' | 'prepareStackTrace' | InterceptorOptions;
297
+ /**
298
+ * Disable HMR or configure HMR options.
299
+ */
300
+ hmr?: false | {
301
+ /**
302
+ * Configure how HMR communicates between the client and the server.
303
+ */
304
+ connection: HMRRuntimeConnection;
305
+ /**
306
+ * Configure HMR logger.
307
+ */
308
+ logger?: false | HMRLogger;
309
+ };
310
+ /**
311
+ * Custom module cache. If not provided, creates a separate module cache for each ViteRuntime instance.
312
+ */
313
+ moduleCache?: ModuleCacheMap;
314
+ }
315
+ interface ImportMetaEnv {
316
+ [key: string]: any;
317
+ BASE_URL: string;
318
+ MODE: string;
319
+ DEV: boolean;
320
+ PROD: boolean;
321
+ SSR: boolean;
322
+ }
323
+
324
+ export { type FetchResult as F, type HMRLogger as H, ModuleCacheMap as M, type ResolvedResult as R, type SSRImportMetadata as S, type ViteRuntimeOptions as V, type ViteModuleRunner as a, ViteRuntime as b, type HMRRuntimeConnection as c, type FetchFunction as d, type ViteRuntimeModuleContext as e, type HMRConnection as f, type ModuleCache as g, type ViteRuntimeImportMeta as h, ssrExportAllKey as i, ssrImportKey as j, ssrImportMetaKey as k, ssrModuleExportsKey as l, ssrDynamicImportKey as s };
@@ -5545,7 +5545,7 @@ function isFileServingAllowed(url, server) {
5545
5545
  var main$1 = {exports: {}};
5546
5546
 
5547
5547
  var name = "dotenv";
5548
- var version$1 = "16.3.1";
5548
+ var version$1 = "16.3.2";
5549
5549
  var description = "Loads environment variables from .env file";
5550
5550
  var main = "lib/main.js";
5551
5551
  var types = "lib/main.d.ts";
@@ -5816,6 +5816,10 @@ function configDotenv (options) {
5816
5816
  }
5817
5817
  if (options.encoding != null) {
5818
5818
  encoding = options.encoding;
5819
+ } else {
5820
+ if (debug) {
5821
+ _debug('No encoding is specified. UTF-8 is used by default');
5822
+ }
5819
5823
  }
5820
5824
  }
5821
5825
 
@@ -5863,9 +5867,9 @@ function decrypt (encrypted, keyStr) {
5863
5867
  const key = Buffer.from(keyStr.slice(-64), 'hex');
5864
5868
  let ciphertext = Buffer.from(encrypted, 'base64');
5865
5869
 
5866
- const nonce = ciphertext.slice(0, 12);
5867
- const authTag = ciphertext.slice(-16);
5868
- ciphertext = ciphertext.slice(12, -16);
5870
+ const nonce = ciphertext.subarray(0, 12);
5871
+ const authTag = ciphertext.subarray(-16);
5872
+ ciphertext = ciphertext.subarray(12, -16);
5869
5873
 
5870
5874
  try {
5871
5875
  const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.1.0-beta.4",
3
+ "version": "5.1.0-beta.6",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -32,12 +32,23 @@
32
32
  "./client": {
33
33
  "types": "./client.d.ts"
34
34
  },
35
+ "./runtime": {
36
+ "types": "./dist/node/runtime.d.ts",
37
+ "import": "./dist/node/runtime.js"
38
+ },
35
39
  "./dist/client/*": "./dist/client/*",
36
40
  "./types/*": {
37
41
  "types": "./types/*"
38
42
  },
39
43
  "./package.json": "./package.json"
40
44
  },
45
+ "typesVersions": {
46
+ "*": {
47
+ "runtime": [
48
+ "dist/node/runtime.d.ts"
49
+ ]
50
+ }
51
+ },
41
52
  "files": [
42
53
  "bin",
43
54
  "dist",
@@ -71,7 +82,7 @@
71
82
  "devDependencies": {
72
83
  "@ampproject/remapping": "^2.2.1",
73
84
  "@babel/parser": "^7.23.6",
74
- "@jridgewell/trace-mapping": "^0.3.21",
85
+ "@jridgewell/trace-mapping": "^0.3.22",
75
86
  "@rollup/plugin-alias": "^5.1.0",
76
87
  "@rollup/plugin-commonjs": "^25.0.7",
77
88
  "@rollup/plugin-dynamic-import-vars": "^2.1.2",
@@ -92,7 +103,7 @@
92
103
  "cross-spawn": "^7.0.3",
93
104
  "debug": "^4.3.4",
94
105
  "dep-types": "link:./src/types",
95
- "dotenv": "^16.3.1",
106
+ "dotenv": "^16.3.2",
96
107
  "dotenv-expand": "^10.0.0",
97
108
  "es-module-lexer": "^1.4.1",
98
109
  "escape-html": "^1.0.3",
@@ -164,7 +175,7 @@
164
175
  "build": "rimraf dist && run-s build-bundle build-types",
165
176
  "build-bundle": "rollup --config rollup.config.ts --configPlugin typescript",
166
177
  "build-types": "run-s build-types-temp build-types-roll build-types-check",
167
- "build-types-temp": "tsc --emitDeclarationOnly --outDir temp/node -p src/node",
178
+ "build-types-temp": "tsc --emitDeclarationOnly --outDir temp -p src/node",
168
179
  "build-types-roll": "rollup --config rollup.dts.config.ts --configPlugin typescript && rimraf temp",
169
180
  "build-types-check": "tsc --project tsconfig.check.json",
170
181
  "typecheck": "tsc --noEmit",
@@ -24,6 +24,8 @@ export interface Update {
24
24
  explicitImportRequired?: boolean
25
25
  /** @internal */
26
26
  isWithinCircularImport?: boolean
27
+ /** @internal */
28
+ ssrInvalidates?: string[]
27
29
  }
28
30
 
29
31
  export interface PrunePayload {