vite-node 4.0.0-beta.2 → 4.0.0-beta.3
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/README.md +4 -2
- package/dist/cli.cjs +1 -1
- package/dist/cli.d.ts +2 -2
- package/dist/cli.mjs +3 -3
- package/dist/client.cjs +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.mjs +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/hmr.d.ts +4 -4
- package/dist/{index.d-DGmxD2U7.d.ts → index.d-CvIJUDRh.d.ts} +6 -6
- package/dist/index.d.ts +2 -2
- package/dist/server.d.ts +4 -4
- package/dist/source-map.cjs +159 -193
- package/dist/source-map.d.ts +4 -4
- package/dist/source-map.mjs +161 -195
- package/dist/{trace-mapping.d-DLVdEqOp.d.ts → trace-mapping.d-BWFx6tPc.d.ts} +6 -1
- package/dist/types.d.ts +2 -2
- package/dist/utils.cjs +4 -4
- package/dist/utils.d.ts +5 -5
- package/dist/utils.mjs +4 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -91,10 +91,12 @@ import { installSourcemapsSupport } from 'vite-node/source-map'
|
|
|
91
91
|
const server = await createServer({
|
|
92
92
|
optimizeDeps: {
|
|
93
93
|
// It's recommended to disable deps optimization
|
|
94
|
-
|
|
94
|
+
noDiscovery: true,
|
|
95
|
+
include: undefined,
|
|
95
96
|
},
|
|
96
97
|
})
|
|
97
|
-
|
|
98
|
+
|
|
99
|
+
// For old Vite, this is needed to initialize the plugins.
|
|
98
100
|
if (Number(viteVersion.split('.')[0]) < 6) {
|
|
99
101
|
await server.pluginContainer.buildStart({})
|
|
100
102
|
}
|
package/dist/cli.cjs
CHANGED
|
@@ -21,7 +21,7 @@ require('node:perf_hooks');
|
|
|
21
21
|
require('es-module-lexer');
|
|
22
22
|
require('./constants.cjs');
|
|
23
23
|
|
|
24
|
-
var version = "4.0.0-beta.
|
|
24
|
+
var version = "4.0.0-beta.3";
|
|
25
25
|
|
|
26
26
|
const cli = cac("vite-node");
|
|
27
27
|
cli.option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-m, --mode <mode>", "Set env mode").option("-w, --watch", "Restart on file changes, similar to \"nodemon\"").option("--script", "Use vite-node as a script runner").option("--options <options>", "Use specified Vite server options").option("-v, --version", "Output the version number").option("-h, --help", "Display help for command");
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -3,23 +3,23 @@ import cac from 'cac';
|
|
|
3
3
|
import { s } from './chunk-browser.mjs';
|
|
4
4
|
import { createServer, version as version$1, loadEnv } from 'vite';
|
|
5
5
|
import { ViteNodeRunner } from './client.mjs';
|
|
6
|
+
import { v as viteNodeHmrPlugin, a as createHotContext, h as handleMessage } from './chunk-hmr.mjs';
|
|
6
7
|
import { ViteNodeServer } from './server.mjs';
|
|
7
8
|
import { installSourcemapsSupport } from './source-map.mjs';
|
|
8
9
|
import { toArray } from './utils.mjs';
|
|
9
|
-
import { v as viteNodeHmrPlugin, a as createHotContext, h as handleMessage } from './chunk-hmr.mjs';
|
|
10
10
|
import 'node:module';
|
|
11
11
|
import 'node:url';
|
|
12
12
|
import 'node:vm';
|
|
13
13
|
import 'debug';
|
|
14
14
|
import 'pathe';
|
|
15
15
|
import 'node:fs';
|
|
16
|
+
import 'node:events';
|
|
16
17
|
import 'node:assert';
|
|
17
18
|
import 'node:perf_hooks';
|
|
18
19
|
import 'es-module-lexer';
|
|
19
20
|
import './constants.mjs';
|
|
20
|
-
import 'node:events';
|
|
21
21
|
|
|
22
|
-
var version = "4.0.0-beta.
|
|
22
|
+
var version = "4.0.0-beta.3";
|
|
23
23
|
|
|
24
24
|
const cli = cac("vite-node");
|
|
25
25
|
cli.option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-m, --mode <mode>", "Set env mode").option("-w, --watch", "Restart on file changes, similar to \"nodemon\"").option("--script", "Use vite-node as a script runner").option("--options <options>", "Use specified Vite server options").option("-v, --version", "Output the version number").option("-h, --help", "Display help for command");
|
package/dist/client.cjs
CHANGED
|
@@ -206,7 +206,7 @@ class ViteNodeRunner {
|
|
|
206
206
|
const resolved = await this.options.resolveId(dep, importer);
|
|
207
207
|
// supported since Vite 5-beta.19
|
|
208
208
|
if (resolved === null || resolved === void 0 || (_resolved$meta = resolved.meta) === null || _resolved$meta === void 0 || (_resolved$meta = _resolved$meta["vite:alias"]) === null || _resolved$meta === void 0 ? void 0 : _resolved$meta.noResolved) {
|
|
209
|
-
const error = new Error(`Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ""}.
|
|
209
|
+
const error = /* @__PURE__ */ new Error(`Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ""}.
|
|
210
210
|
|
|
211
211
|
- If you rely on tsconfig.json's "paths" to resolve modules, please install "vite-tsconfig-paths" plugin to handle module resolution.
|
|
212
212
|
- Make sure you don't have relative aliases in your Vitest config. Use absolute paths instead. Read more: https://vitest.dev/guide/common-errors`);
|
package/dist/client.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './trace-mapping.d-
|
|
2
|
-
export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, f as ModuleExecutionInfo, g as ModuleExecutionInfoEntry, a as ViteNodeRunner } from './index.d-
|
|
1
|
+
import './trace-mapping.d-BWFx6tPc.js';
|
|
2
|
+
export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, f as ModuleExecutionInfo, g as ModuleExecutionInfoEntry, a as ViteNodeRunner } from './index.d-CvIJUDRh.js';
|
package/dist/client.mjs
CHANGED
|
@@ -204,7 +204,7 @@ class ViteNodeRunner {
|
|
|
204
204
|
const resolved = await this.options.resolveId(dep, importer);
|
|
205
205
|
// supported since Vite 5-beta.19
|
|
206
206
|
if (resolved === null || resolved === void 0 || (_resolved$meta = resolved.meta) === null || _resolved$meta === void 0 || (_resolved$meta = _resolved$meta["vite:alias"]) === null || _resolved$meta === void 0 ? void 0 : _resolved$meta.noResolved) {
|
|
207
|
-
const error = new Error(`Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ""}.
|
|
207
|
+
const error = /* @__PURE__ */ new Error(`Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ""}.
|
|
208
208
|
|
|
209
209
|
- If you rely on tsconfig.json's "paths" to resolve modules, please install "vite-tsconfig-paths" plugin to handle module resolution.
|
|
210
210
|
- Make sure you don't have relative aliases in your Vitest config. Use absolute paths instead. Read more: https://vitest.dev/guide/common-errors`);
|
package/dist/constants.cjs
CHANGED
|
@@ -28,7 +28,7 @@ const KNOWN_ASSET_TYPES = [
|
|
|
28
28
|
"pdf",
|
|
29
29
|
"txt"
|
|
30
30
|
];
|
|
31
|
-
const KNOWN_ASSET_RE = new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`);
|
|
31
|
+
const KNOWN_ASSET_RE = /* @__PURE__ */ new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`);
|
|
32
32
|
const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
|
33
33
|
|
|
34
34
|
exports.CSS_LANGS_RE = CSS_LANGS_RE;
|
package/dist/constants.mjs
CHANGED
|
@@ -26,7 +26,7 @@ const KNOWN_ASSET_TYPES = [
|
|
|
26
26
|
"pdf",
|
|
27
27
|
"txt"
|
|
28
28
|
];
|
|
29
|
-
const KNOWN_ASSET_RE = new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`);
|
|
29
|
+
const KNOWN_ASSET_RE = /* @__PURE__ */ new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`);
|
|
30
30
|
const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
|
31
31
|
|
|
32
32
|
export { CSS_LANGS_RE, KNOWN_ASSET_RE, KNOWN_ASSET_TYPES };
|
package/dist/hmr.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HMRPayload, Plugin } from 'vite';
|
|
2
2
|
import { EventEmitter } from 'node:events';
|
|
3
|
-
import { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index.d-
|
|
4
|
-
import './trace-mapping.d-
|
|
3
|
+
import { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index.d-CvIJUDRh.js';
|
|
4
|
+
import './trace-mapping.d-BWFx6tPc.js';
|
|
5
5
|
|
|
6
6
|
type EventType = string | symbol;
|
|
7
7
|
type Handler<T = unknown> = (event: T) => void;
|
|
@@ -11,7 +11,7 @@ interface Emitter<Events extends Record<EventType, unknown>> {
|
|
|
11
11
|
emit: (<Key extends keyof Events>(type: Key, event: Events[Key]) => void) & (<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never) => void);
|
|
12
12
|
}
|
|
13
13
|
type HMREmitter = Emitter<{
|
|
14
|
-
message: HMRPayload
|
|
14
|
+
message: HMRPayload;
|
|
15
15
|
}> & EventEmitter;
|
|
16
16
|
declare module "vite" {
|
|
17
17
|
interface ViteDevServer {
|
|
@@ -24,7 +24,7 @@ declare function viteNodeHmrPlugin(): Plugin;
|
|
|
24
24
|
/* eslint-disable no-console */
|
|
25
25
|
|
|
26
26
|
type ModuleNamespace = Record<string, any> & {
|
|
27
|
-
[Symbol.toStringTag]: "Module"
|
|
27
|
+
[Symbol.toStringTag]: "Module";
|
|
28
28
|
};
|
|
29
29
|
type InferCustomEventPayload<T extends string> = T extends keyof CustomEventMap ? CustomEventMap[T] : any;
|
|
30
30
|
interface HotModule {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EncodedSourceMap } from './trace-mapping.d-
|
|
1
|
+
import { E as EncodedSourceMap } from './trace-mapping.d-BWFx6tPc.js';
|
|
2
2
|
|
|
3
3
|
/** @deprecated use HotPayload */
|
|
4
4
|
type HMRPayload = HotPayload
|
|
@@ -223,9 +223,9 @@ declare class ViteNodeRunner {
|
|
|
223
223
|
resolveUrl(id: string, importee?: string): Promise<[url: string, fsPath: string]>;
|
|
224
224
|
private _fetchModule;
|
|
225
225
|
protected getContextPrimitives(): {
|
|
226
|
-
Object: ObjectConstructor
|
|
227
|
-
Reflect: typeof Reflect
|
|
228
|
-
Symbol: SymbolConstructor
|
|
226
|
+
Object: ObjectConstructor;
|
|
227
|
+
Reflect: typeof Reflect;
|
|
228
|
+
Symbol: SymbolConstructor;
|
|
229
229
|
};
|
|
230
230
|
protected runModule(context: Record<string, any>, transformed: string): Promise<void>;
|
|
231
231
|
/**
|
|
@@ -341,8 +341,8 @@ interface ViteNodeServerOptions {
|
|
|
341
341
|
* Transform method for modules
|
|
342
342
|
*/
|
|
343
343
|
transformMode?: {
|
|
344
|
-
ssr?: RegExp[]
|
|
345
|
-
web?: RegExp[]
|
|
344
|
+
ssr?: RegExp[];
|
|
345
|
+
web?: RegExp[];
|
|
346
346
|
};
|
|
347
347
|
debug?: DebuggerOptions;
|
|
348
348
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as Arrayable, h as Awaitable, k as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, i as FetchFunction, F as FetchResult, b as HotContext, l as ModuleCache, M as ModuleCacheMap, f as ModuleExecutionInfo, N as Nullable, R as RawSourceMap, j as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, n as ViteNodeResolveModule, m as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index.d-
|
|
2
|
-
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-
|
|
1
|
+
export { A as Arrayable, h as Awaitable, k as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, i as FetchFunction, F as FetchResult, b as HotContext, l as ModuleCache, M as ModuleCacheMap, f as ModuleExecutionInfo, N as Nullable, R as RawSourceMap, j as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, n as ViteNodeResolveModule, m as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index.d-CvIJUDRh.js';
|
|
2
|
+
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-BWFx6tPc.js';
|
package/dist/server.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { TransformResult, ViteDevServer } from 'vite';
|
|
2
|
-
import { D as DebuggerOptions, c as DepsHandlingOptions, V as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId } from './index.d-
|
|
3
|
-
import { E as EncodedSourceMap } from './trace-mapping.d-
|
|
2
|
+
import { D as DebuggerOptions, c as DepsHandlingOptions, V as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId } from './index.d-CvIJUDRh.js';
|
|
3
|
+
import { E as EncodedSourceMap } from './trace-mapping.d-BWFx6tPc.js';
|
|
4
4
|
|
|
5
5
|
declare class Debugger {
|
|
6
|
-
options:
|
|
6
|
+
options: string;
|
|
7
7
|
dumpDir: string | undefined;
|
|
8
8
|
initPromise: Promise<void> | undefined;
|
|
9
9
|
externalizeMap: Map<string, string>;
|
|
@@ -46,7 +46,7 @@ declare class ViteNodeServer {
|
|
|
46
46
|
fetchResult(id: string, mode: "web" | "ssr"): Promise<FetchResult>;
|
|
47
47
|
transformRequest(id: string, filepath?: string, transformMode?: "web" | "ssr"): Promise<TransformResult | null | undefined>;
|
|
48
48
|
transformModule(id: string, transformMode?: "web" | "ssr"): Promise<{
|
|
49
|
-
code: string | undefined
|
|
49
|
+
code: string | undefined;
|
|
50
50
|
}>;
|
|
51
51
|
getTransformMode(id: string): "ssr" | "web";
|
|
52
52
|
private getChangedModule;
|
package/dist/source-map.cjs
CHANGED
|
@@ -289,7 +289,7 @@ function normalizePath(url, type) {
|
|
|
289
289
|
/**
|
|
290
290
|
* Attempts to resolve `input` URL/path relative to `base`.
|
|
291
291
|
*/
|
|
292
|
-
function resolve
|
|
292
|
+
function resolve(input, base) {
|
|
293
293
|
if (!input && !base)
|
|
294
294
|
return '';
|
|
295
295
|
const url = parseUrl(input);
|
|
@@ -349,238 +349,204 @@ function resolve$1(input, base) {
|
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
-
|
|
353
|
-
// The base is always treated as a directory, if it's not empty.
|
|
354
|
-
// https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327
|
|
355
|
-
// https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401
|
|
356
|
-
if (base && !base.endsWith('/'))
|
|
357
|
-
base += '/';
|
|
358
|
-
return resolve$1(input, base);
|
|
359
|
-
}
|
|
352
|
+
// src/trace-mapping.ts
|
|
360
353
|
|
|
361
|
-
|
|
362
|
-
* Removes everything after the last "/", but leaves the slash.
|
|
363
|
-
*/
|
|
354
|
+
// src/strip-filename.ts
|
|
364
355
|
function stripFilename(path) {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
return path.slice(0, index + 1);
|
|
356
|
+
if (!path) return "";
|
|
357
|
+
const index = path.lastIndexOf("/");
|
|
358
|
+
return path.slice(0, index + 1);
|
|
369
359
|
}
|
|
370
360
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
const
|
|
374
|
-
const
|
|
375
|
-
|
|
361
|
+
// src/resolve.ts
|
|
362
|
+
function resolver(mapUrl, sourceRoot) {
|
|
363
|
+
const from = stripFilename(mapUrl);
|
|
364
|
+
const prefix = sourceRoot ? sourceRoot + "/" : "";
|
|
365
|
+
return (source) => resolve(prefix + (source || ""), from);
|
|
366
|
+
}
|
|
376
367
|
|
|
368
|
+
// src/sourcemap-segment.ts
|
|
369
|
+
var COLUMN = 0;
|
|
370
|
+
var SOURCES_INDEX = 1;
|
|
371
|
+
var SOURCE_LINE = 2;
|
|
372
|
+
var SOURCE_COLUMN = 3;
|
|
373
|
+
var NAMES_INDEX = 4;
|
|
374
|
+
|
|
375
|
+
// src/sort.ts
|
|
377
376
|
function maybeSort(mappings, owned) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
|
|
386
|
-
mappings[i] = sortSegments(mappings[i], owned);
|
|
387
|
-
}
|
|
388
|
-
return mappings;
|
|
377
|
+
const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
|
|
378
|
+
if (unsortedIndex === mappings.length) return mappings;
|
|
379
|
+
if (!owned) mappings = mappings.slice();
|
|
380
|
+
for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
|
|
381
|
+
mappings[i] = sortSegments(mappings[i], owned);
|
|
382
|
+
}
|
|
383
|
+
return mappings;
|
|
389
384
|
}
|
|
390
385
|
function nextUnsortedSegmentLine(mappings, start) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
return mappings.length;
|
|
386
|
+
for (let i = start; i < mappings.length; i++) {
|
|
387
|
+
if (!isSorted(mappings[i])) return i;
|
|
388
|
+
}
|
|
389
|
+
return mappings.length;
|
|
396
390
|
}
|
|
397
391
|
function isSorted(line) {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
}
|
|
392
|
+
for (let j = 1; j < line.length; j++) {
|
|
393
|
+
if (line[j][COLUMN] < line[j - 1][COLUMN]) {
|
|
394
|
+
return false;
|
|
402
395
|
}
|
|
403
|
-
|
|
396
|
+
}
|
|
397
|
+
return true;
|
|
404
398
|
}
|
|
405
399
|
function sortSegments(line, owned) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
return line.sort(sortComparator);
|
|
400
|
+
if (!owned) line = line.slice();
|
|
401
|
+
return line.sort(sortComparator);
|
|
409
402
|
}
|
|
410
403
|
function sortComparator(a, b) {
|
|
411
|
-
|
|
404
|
+
return a[COLUMN] - b[COLUMN];
|
|
412
405
|
}
|
|
413
406
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
* A binary search implementation that returns the index if a match is found.
|
|
417
|
-
* If no match is found, then the left-index (the index associated with the item that comes just
|
|
418
|
-
* before the desired index) is returned. To maintain proper sort order, a splice would happen at
|
|
419
|
-
* the next index:
|
|
420
|
-
*
|
|
421
|
-
* ```js
|
|
422
|
-
* const array = [1, 3];
|
|
423
|
-
* const needle = 2;
|
|
424
|
-
* const index = binarySearch(array, needle, (item, needle) => item - needle);
|
|
425
|
-
*
|
|
426
|
-
* assert.equal(index, 0);
|
|
427
|
-
* array.splice(index + 1, 0, needle);
|
|
428
|
-
* assert.deepEqual(array, [1, 2, 3]);
|
|
429
|
-
* ```
|
|
430
|
-
*/
|
|
407
|
+
// src/binary-search.ts
|
|
408
|
+
var found = false;
|
|
431
409
|
function binarySearch(haystack, needle, low, high) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
}
|
|
439
|
-
if (cmp < 0) {
|
|
440
|
-
low = mid + 1;
|
|
441
|
-
}
|
|
442
|
-
else {
|
|
443
|
-
high = mid - 1;
|
|
444
|
-
}
|
|
410
|
+
while (low <= high) {
|
|
411
|
+
const mid = low + (high - low >> 1);
|
|
412
|
+
const cmp = haystack[mid][COLUMN] - needle;
|
|
413
|
+
if (cmp === 0) {
|
|
414
|
+
found = true;
|
|
415
|
+
return mid;
|
|
445
416
|
}
|
|
446
|
-
|
|
447
|
-
|
|
417
|
+
if (cmp < 0) {
|
|
418
|
+
low = mid + 1;
|
|
419
|
+
} else {
|
|
420
|
+
high = mid - 1;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
found = false;
|
|
424
|
+
return low - 1;
|
|
448
425
|
}
|
|
449
426
|
function upperBound(haystack, needle, index) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
return index;
|
|
427
|
+
for (let i = index + 1; i < haystack.length; index = i++) {
|
|
428
|
+
if (haystack[i][COLUMN] !== needle) break;
|
|
429
|
+
}
|
|
430
|
+
return index;
|
|
455
431
|
}
|
|
456
432
|
function lowerBound(haystack, needle, index) {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
return index;
|
|
433
|
+
for (let i = index - 1; i >= 0; index = i--) {
|
|
434
|
+
if (haystack[i][COLUMN] !== needle) break;
|
|
435
|
+
}
|
|
436
|
+
return index;
|
|
462
437
|
}
|
|
463
438
|
function memoizedState() {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
439
|
+
return {
|
|
440
|
+
lastKey: -1,
|
|
441
|
+
lastNeedle: -1,
|
|
442
|
+
lastIndex: -1
|
|
443
|
+
};
|
|
469
444
|
}
|
|
470
|
-
/**
|
|
471
|
-
* This overly complicated beast is just to record the last tested line/column and the resulting
|
|
472
|
-
* index, allowing us to skip a few tests if mappings are monotonically increasing.
|
|
473
|
-
*/
|
|
474
445
|
function memoizedBinarySearch(haystack, needle, state, key) {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
else {
|
|
488
|
-
high = lastIndex;
|
|
489
|
-
}
|
|
446
|
+
const { lastKey, lastNeedle, lastIndex } = state;
|
|
447
|
+
let low = 0;
|
|
448
|
+
let high = haystack.length - 1;
|
|
449
|
+
if (key === lastKey) {
|
|
450
|
+
if (needle === lastNeedle) {
|
|
451
|
+
found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
|
|
452
|
+
return lastIndex;
|
|
453
|
+
}
|
|
454
|
+
if (needle >= lastNeedle) {
|
|
455
|
+
low = lastIndex === -1 ? 0 : lastIndex;
|
|
456
|
+
} else {
|
|
457
|
+
high = lastIndex;
|
|
490
458
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
459
|
+
}
|
|
460
|
+
state.lastKey = key;
|
|
461
|
+
state.lastNeedle = needle;
|
|
462
|
+
return state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
494
463
|
}
|
|
495
464
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
const GREATEST_LOWER_BOUND = 1;
|
|
500
|
-
class TraceMap {
|
|
501
|
-
constructor(map, mapUrl) {
|
|
502
|
-
const isString = typeof map === 'string';
|
|
503
|
-
if (!isString && map._decodedMemo)
|
|
504
|
-
return map;
|
|
505
|
-
const parsed = (isString ? JSON.parse(map) : map);
|
|
506
|
-
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
507
|
-
this.version = version;
|
|
508
|
-
this.file = file;
|
|
509
|
-
this.names = names || [];
|
|
510
|
-
this.sourceRoot = sourceRoot;
|
|
511
|
-
this.sources = sources;
|
|
512
|
-
this.sourcesContent = sourcesContent;
|
|
513
|
-
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
|
|
514
|
-
const from = resolve(sourceRoot || '', stripFilename(mapUrl));
|
|
515
|
-
this.resolvedSources = sources.map((s) => resolve(s || '', from));
|
|
516
|
-
const { mappings } = parsed;
|
|
517
|
-
if (typeof mappings === 'string') {
|
|
518
|
-
this._encoded = mappings;
|
|
519
|
-
this._decoded = undefined;
|
|
520
|
-
}
|
|
521
|
-
else {
|
|
522
|
-
this._encoded = undefined;
|
|
523
|
-
this._decoded = maybeSort(mappings, isString);
|
|
524
|
-
}
|
|
525
|
-
this._decodedMemo = memoizedState();
|
|
526
|
-
this._bySources = undefined;
|
|
527
|
-
this._bySourceMemos = undefined;
|
|
528
|
-
}
|
|
465
|
+
// src/types.ts
|
|
466
|
+
function parse(map) {
|
|
467
|
+
return typeof map === "string" ? JSON.parse(map) : map;
|
|
529
468
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
469
|
+
|
|
470
|
+
// src/trace-mapping.ts
|
|
471
|
+
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
|
|
472
|
+
var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
|
|
473
|
+
var LEAST_UPPER_BOUND = -1;
|
|
474
|
+
var GREATEST_LOWER_BOUND = 1;
|
|
475
|
+
var TraceMap = class {
|
|
476
|
+
constructor(map, mapUrl) {
|
|
477
|
+
const isString = typeof map === "string";
|
|
478
|
+
if (!isString && map._decodedMemo) return map;
|
|
479
|
+
const parsed = parse(map);
|
|
480
|
+
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
481
|
+
this.version = version;
|
|
482
|
+
this.file = file;
|
|
483
|
+
this.names = names || [];
|
|
484
|
+
this.sourceRoot = sourceRoot;
|
|
485
|
+
this.sources = sources;
|
|
486
|
+
this.sourcesContent = sourcesContent;
|
|
487
|
+
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
|
|
488
|
+
const resolve = resolver(mapUrl, sourceRoot);
|
|
489
|
+
this.resolvedSources = sources.map(resolve);
|
|
490
|
+
const { mappings } = parsed;
|
|
491
|
+
if (typeof mappings === "string") {
|
|
492
|
+
this._encoded = mappings;
|
|
493
|
+
this._decoded = void 0;
|
|
494
|
+
} else if (Array.isArray(mappings)) {
|
|
495
|
+
this._encoded = void 0;
|
|
496
|
+
this._decoded = maybeSort(mappings, isString);
|
|
497
|
+
} else if (parsed.sections) {
|
|
498
|
+
throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
|
|
499
|
+
} else {
|
|
500
|
+
throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
|
|
501
|
+
}
|
|
502
|
+
this._decodedMemo = memoizedState();
|
|
503
|
+
this._bySources = void 0;
|
|
504
|
+
this._bySourceMemos = void 0;
|
|
505
|
+
}
|
|
506
|
+
};
|
|
534
507
|
function cast(map) {
|
|
535
|
-
|
|
508
|
+
return map;
|
|
536
509
|
}
|
|
537
|
-
/**
|
|
538
|
-
* Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
|
|
539
|
-
*/
|
|
540
510
|
function decodedMappings(map) {
|
|
541
|
-
|
|
542
|
-
|
|
511
|
+
var _a;
|
|
512
|
+
return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
|
|
543
513
|
}
|
|
544
|
-
/**
|
|
545
|
-
* A higher-level API to find the source/line/column associated with a generated line/column
|
|
546
|
-
* (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
|
|
547
|
-
* `source-map` library.
|
|
548
|
-
*/
|
|
549
514
|
function originalPositionFor(map, needle) {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
515
|
+
let { line, column, bias } = needle;
|
|
516
|
+
line--;
|
|
517
|
+
if (line < 0) throw new Error(LINE_GTR_ZERO);
|
|
518
|
+
if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
|
|
519
|
+
const decoded = decodedMappings(map);
|
|
520
|
+
if (line >= decoded.length) return OMapping(null, null, null, null);
|
|
521
|
+
const segments = decoded[line];
|
|
522
|
+
const index = traceSegmentInternal(
|
|
523
|
+
segments,
|
|
524
|
+
cast(map)._decodedMemo,
|
|
525
|
+
line,
|
|
526
|
+
column,
|
|
527
|
+
bias || GREATEST_LOWER_BOUND
|
|
528
|
+
);
|
|
529
|
+
if (index === -1) return OMapping(null, null, null, null);
|
|
530
|
+
const segment = segments[index];
|
|
531
|
+
if (segment.length === 1) return OMapping(null, null, null, null);
|
|
532
|
+
const { names, resolvedSources } = map;
|
|
533
|
+
return OMapping(
|
|
534
|
+
resolvedSources[segment[SOURCES_INDEX]],
|
|
535
|
+
segment[SOURCE_LINE] + 1,
|
|
536
|
+
segment[SOURCE_COLUMN],
|
|
537
|
+
segment.length === 5 ? names[segment[NAMES_INDEX]] : null
|
|
538
|
+
);
|
|
570
539
|
}
|
|
571
540
|
function OMapping(source, line, column, name) {
|
|
572
|
-
|
|
541
|
+
return { source, line, column, name };
|
|
573
542
|
}
|
|
574
543
|
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
if (index === -1 || index === segments.length)
|
|
582
|
-
return -1;
|
|
583
|
-
return index;
|
|
544
|
+
let index = memoizedBinarySearch(segments, column, memo, line);
|
|
545
|
+
if (found) {
|
|
546
|
+
index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
|
|
547
|
+
} else if (bias === LEAST_UPPER_BOUND) index++;
|
|
548
|
+
if (index === -1 || index === segments.length) return -1;
|
|
549
|
+
return index;
|
|
584
550
|
}
|
|
585
551
|
|
|
586
552
|
// Only install once if called multiple times
|
package/dist/source-map.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { TransformResult } from 'vite';
|
|
2
|
-
import { E as EncodedSourceMap } from './trace-mapping.d-
|
|
2
|
+
import { E as EncodedSourceMap } from './trace-mapping.d-BWFx6tPc.js';
|
|
3
3
|
|
|
4
4
|
interface InstallSourceMapSupportOptions {
|
|
5
5
|
getSourceMap: (source: string) => EncodedSourceMap | null | undefined;
|
|
6
6
|
}
|
|
7
7
|
declare function withInlineSourcemap(result: TransformResult, options: {
|
|
8
|
-
root: string
|
|
9
|
-
filepath: string
|
|
10
|
-
noFirstLineMapping?: boolean
|
|
8
|
+
root: string;
|
|
9
|
+
filepath: string;
|
|
10
|
+
noFirstLineMapping?: boolean;
|
|
11
11
|
}): TransformResult;
|
|
12
12
|
declare function extractSourceMap(code: string): EncodedSourceMap | null;
|
|
13
13
|
declare function installSourcemapsSupport(options: InstallSourceMapSupportOptions): void;
|
package/dist/source-map.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isAbsolute, resolve as resolve$
|
|
1
|
+
import { isAbsolute, resolve as resolve$1, relative, dirname } from 'pathe';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { withTrailingSlash } from './utils.mjs';
|
|
@@ -287,7 +287,7 @@ function normalizePath(url, type) {
|
|
|
287
287
|
/**
|
|
288
288
|
* Attempts to resolve `input` URL/path relative to `base`.
|
|
289
289
|
*/
|
|
290
|
-
function resolve
|
|
290
|
+
function resolve(input, base) {
|
|
291
291
|
if (!input && !base)
|
|
292
292
|
return '';
|
|
293
293
|
const url = parseUrl(input);
|
|
@@ -347,238 +347,204 @@ function resolve$1(input, base) {
|
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
|
|
351
|
-
// The base is always treated as a directory, if it's not empty.
|
|
352
|
-
// https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327
|
|
353
|
-
// https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401
|
|
354
|
-
if (base && !base.endsWith('/'))
|
|
355
|
-
base += '/';
|
|
356
|
-
return resolve$1(input, base);
|
|
357
|
-
}
|
|
350
|
+
// src/trace-mapping.ts
|
|
358
351
|
|
|
359
|
-
|
|
360
|
-
* Removes everything after the last "/", but leaves the slash.
|
|
361
|
-
*/
|
|
352
|
+
// src/strip-filename.ts
|
|
362
353
|
function stripFilename(path) {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
return path.slice(0, index + 1);
|
|
354
|
+
if (!path) return "";
|
|
355
|
+
const index = path.lastIndexOf("/");
|
|
356
|
+
return path.slice(0, index + 1);
|
|
367
357
|
}
|
|
368
358
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
const
|
|
372
|
-
const
|
|
373
|
-
|
|
359
|
+
// src/resolve.ts
|
|
360
|
+
function resolver(mapUrl, sourceRoot) {
|
|
361
|
+
const from = stripFilename(mapUrl);
|
|
362
|
+
const prefix = sourceRoot ? sourceRoot + "/" : "";
|
|
363
|
+
return (source) => resolve(prefix + (source || ""), from);
|
|
364
|
+
}
|
|
374
365
|
|
|
366
|
+
// src/sourcemap-segment.ts
|
|
367
|
+
var COLUMN = 0;
|
|
368
|
+
var SOURCES_INDEX = 1;
|
|
369
|
+
var SOURCE_LINE = 2;
|
|
370
|
+
var SOURCE_COLUMN = 3;
|
|
371
|
+
var NAMES_INDEX = 4;
|
|
372
|
+
|
|
373
|
+
// src/sort.ts
|
|
375
374
|
function maybeSort(mappings, owned) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
|
|
384
|
-
mappings[i] = sortSegments(mappings[i], owned);
|
|
385
|
-
}
|
|
386
|
-
return mappings;
|
|
375
|
+
const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
|
|
376
|
+
if (unsortedIndex === mappings.length) return mappings;
|
|
377
|
+
if (!owned) mappings = mappings.slice();
|
|
378
|
+
for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
|
|
379
|
+
mappings[i] = sortSegments(mappings[i], owned);
|
|
380
|
+
}
|
|
381
|
+
return mappings;
|
|
387
382
|
}
|
|
388
383
|
function nextUnsortedSegmentLine(mappings, start) {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
return mappings.length;
|
|
384
|
+
for (let i = start; i < mappings.length; i++) {
|
|
385
|
+
if (!isSorted(mappings[i])) return i;
|
|
386
|
+
}
|
|
387
|
+
return mappings.length;
|
|
394
388
|
}
|
|
395
389
|
function isSorted(line) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
}
|
|
390
|
+
for (let j = 1; j < line.length; j++) {
|
|
391
|
+
if (line[j][COLUMN] < line[j - 1][COLUMN]) {
|
|
392
|
+
return false;
|
|
400
393
|
}
|
|
401
|
-
|
|
394
|
+
}
|
|
395
|
+
return true;
|
|
402
396
|
}
|
|
403
397
|
function sortSegments(line, owned) {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
return line.sort(sortComparator);
|
|
398
|
+
if (!owned) line = line.slice();
|
|
399
|
+
return line.sort(sortComparator);
|
|
407
400
|
}
|
|
408
401
|
function sortComparator(a, b) {
|
|
409
|
-
|
|
402
|
+
return a[COLUMN] - b[COLUMN];
|
|
410
403
|
}
|
|
411
404
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
* A binary search implementation that returns the index if a match is found.
|
|
415
|
-
* If no match is found, then the left-index (the index associated with the item that comes just
|
|
416
|
-
* before the desired index) is returned. To maintain proper sort order, a splice would happen at
|
|
417
|
-
* the next index:
|
|
418
|
-
*
|
|
419
|
-
* ```js
|
|
420
|
-
* const array = [1, 3];
|
|
421
|
-
* const needle = 2;
|
|
422
|
-
* const index = binarySearch(array, needle, (item, needle) => item - needle);
|
|
423
|
-
*
|
|
424
|
-
* assert.equal(index, 0);
|
|
425
|
-
* array.splice(index + 1, 0, needle);
|
|
426
|
-
* assert.deepEqual(array, [1, 2, 3]);
|
|
427
|
-
* ```
|
|
428
|
-
*/
|
|
405
|
+
// src/binary-search.ts
|
|
406
|
+
var found = false;
|
|
429
407
|
function binarySearch(haystack, needle, low, high) {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
}
|
|
437
|
-
if (cmp < 0) {
|
|
438
|
-
low = mid + 1;
|
|
439
|
-
}
|
|
440
|
-
else {
|
|
441
|
-
high = mid - 1;
|
|
442
|
-
}
|
|
408
|
+
while (low <= high) {
|
|
409
|
+
const mid = low + (high - low >> 1);
|
|
410
|
+
const cmp = haystack[mid][COLUMN] - needle;
|
|
411
|
+
if (cmp === 0) {
|
|
412
|
+
found = true;
|
|
413
|
+
return mid;
|
|
443
414
|
}
|
|
444
|
-
|
|
445
|
-
|
|
415
|
+
if (cmp < 0) {
|
|
416
|
+
low = mid + 1;
|
|
417
|
+
} else {
|
|
418
|
+
high = mid - 1;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
found = false;
|
|
422
|
+
return low - 1;
|
|
446
423
|
}
|
|
447
424
|
function upperBound(haystack, needle, index) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
return index;
|
|
425
|
+
for (let i = index + 1; i < haystack.length; index = i++) {
|
|
426
|
+
if (haystack[i][COLUMN] !== needle) break;
|
|
427
|
+
}
|
|
428
|
+
return index;
|
|
453
429
|
}
|
|
454
430
|
function lowerBound(haystack, needle, index) {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
return index;
|
|
431
|
+
for (let i = index - 1; i >= 0; index = i--) {
|
|
432
|
+
if (haystack[i][COLUMN] !== needle) break;
|
|
433
|
+
}
|
|
434
|
+
return index;
|
|
460
435
|
}
|
|
461
436
|
function memoizedState() {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
437
|
+
return {
|
|
438
|
+
lastKey: -1,
|
|
439
|
+
lastNeedle: -1,
|
|
440
|
+
lastIndex: -1
|
|
441
|
+
};
|
|
467
442
|
}
|
|
468
|
-
/**
|
|
469
|
-
* This overly complicated beast is just to record the last tested line/column and the resulting
|
|
470
|
-
* index, allowing us to skip a few tests if mappings are monotonically increasing.
|
|
471
|
-
*/
|
|
472
443
|
function memoizedBinarySearch(haystack, needle, state, key) {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
else {
|
|
486
|
-
high = lastIndex;
|
|
487
|
-
}
|
|
444
|
+
const { lastKey, lastNeedle, lastIndex } = state;
|
|
445
|
+
let low = 0;
|
|
446
|
+
let high = haystack.length - 1;
|
|
447
|
+
if (key === lastKey) {
|
|
448
|
+
if (needle === lastNeedle) {
|
|
449
|
+
found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
|
|
450
|
+
return lastIndex;
|
|
451
|
+
}
|
|
452
|
+
if (needle >= lastNeedle) {
|
|
453
|
+
low = lastIndex === -1 ? 0 : lastIndex;
|
|
454
|
+
} else {
|
|
455
|
+
high = lastIndex;
|
|
488
456
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
457
|
+
}
|
|
458
|
+
state.lastKey = key;
|
|
459
|
+
state.lastNeedle = needle;
|
|
460
|
+
return state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
492
461
|
}
|
|
493
462
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
const GREATEST_LOWER_BOUND = 1;
|
|
498
|
-
class TraceMap {
|
|
499
|
-
constructor(map, mapUrl) {
|
|
500
|
-
const isString = typeof map === 'string';
|
|
501
|
-
if (!isString && map._decodedMemo)
|
|
502
|
-
return map;
|
|
503
|
-
const parsed = (isString ? JSON.parse(map) : map);
|
|
504
|
-
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
505
|
-
this.version = version;
|
|
506
|
-
this.file = file;
|
|
507
|
-
this.names = names || [];
|
|
508
|
-
this.sourceRoot = sourceRoot;
|
|
509
|
-
this.sources = sources;
|
|
510
|
-
this.sourcesContent = sourcesContent;
|
|
511
|
-
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
|
|
512
|
-
const from = resolve(sourceRoot || '', stripFilename(mapUrl));
|
|
513
|
-
this.resolvedSources = sources.map((s) => resolve(s || '', from));
|
|
514
|
-
const { mappings } = parsed;
|
|
515
|
-
if (typeof mappings === 'string') {
|
|
516
|
-
this._encoded = mappings;
|
|
517
|
-
this._decoded = undefined;
|
|
518
|
-
}
|
|
519
|
-
else {
|
|
520
|
-
this._encoded = undefined;
|
|
521
|
-
this._decoded = maybeSort(mappings, isString);
|
|
522
|
-
}
|
|
523
|
-
this._decodedMemo = memoizedState();
|
|
524
|
-
this._bySources = undefined;
|
|
525
|
-
this._bySourceMemos = undefined;
|
|
526
|
-
}
|
|
463
|
+
// src/types.ts
|
|
464
|
+
function parse(map) {
|
|
465
|
+
return typeof map === "string" ? JSON.parse(map) : map;
|
|
527
466
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
467
|
+
|
|
468
|
+
// src/trace-mapping.ts
|
|
469
|
+
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
|
|
470
|
+
var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
|
|
471
|
+
var LEAST_UPPER_BOUND = -1;
|
|
472
|
+
var GREATEST_LOWER_BOUND = 1;
|
|
473
|
+
var TraceMap = class {
|
|
474
|
+
constructor(map, mapUrl) {
|
|
475
|
+
const isString = typeof map === "string";
|
|
476
|
+
if (!isString && map._decodedMemo) return map;
|
|
477
|
+
const parsed = parse(map);
|
|
478
|
+
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
479
|
+
this.version = version;
|
|
480
|
+
this.file = file;
|
|
481
|
+
this.names = names || [];
|
|
482
|
+
this.sourceRoot = sourceRoot;
|
|
483
|
+
this.sources = sources;
|
|
484
|
+
this.sourcesContent = sourcesContent;
|
|
485
|
+
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
|
|
486
|
+
const resolve = resolver(mapUrl, sourceRoot);
|
|
487
|
+
this.resolvedSources = sources.map(resolve);
|
|
488
|
+
const { mappings } = parsed;
|
|
489
|
+
if (typeof mappings === "string") {
|
|
490
|
+
this._encoded = mappings;
|
|
491
|
+
this._decoded = void 0;
|
|
492
|
+
} else if (Array.isArray(mappings)) {
|
|
493
|
+
this._encoded = void 0;
|
|
494
|
+
this._decoded = maybeSort(mappings, isString);
|
|
495
|
+
} else if (parsed.sections) {
|
|
496
|
+
throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
|
|
497
|
+
} else {
|
|
498
|
+
throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
|
|
499
|
+
}
|
|
500
|
+
this._decodedMemo = memoizedState();
|
|
501
|
+
this._bySources = void 0;
|
|
502
|
+
this._bySourceMemos = void 0;
|
|
503
|
+
}
|
|
504
|
+
};
|
|
532
505
|
function cast(map) {
|
|
533
|
-
|
|
506
|
+
return map;
|
|
534
507
|
}
|
|
535
|
-
/**
|
|
536
|
-
* Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
|
|
537
|
-
*/
|
|
538
508
|
function decodedMappings(map) {
|
|
539
|
-
|
|
540
|
-
|
|
509
|
+
var _a;
|
|
510
|
+
return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
|
|
541
511
|
}
|
|
542
|
-
/**
|
|
543
|
-
* A higher-level API to find the source/line/column associated with a generated line/column
|
|
544
|
-
* (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
|
|
545
|
-
* `source-map` library.
|
|
546
|
-
*/
|
|
547
512
|
function originalPositionFor(map, needle) {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
513
|
+
let { line, column, bias } = needle;
|
|
514
|
+
line--;
|
|
515
|
+
if (line < 0) throw new Error(LINE_GTR_ZERO);
|
|
516
|
+
if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
|
|
517
|
+
const decoded = decodedMappings(map);
|
|
518
|
+
if (line >= decoded.length) return OMapping(null, null, null, null);
|
|
519
|
+
const segments = decoded[line];
|
|
520
|
+
const index = traceSegmentInternal(
|
|
521
|
+
segments,
|
|
522
|
+
cast(map)._decodedMemo,
|
|
523
|
+
line,
|
|
524
|
+
column,
|
|
525
|
+
bias || GREATEST_LOWER_BOUND
|
|
526
|
+
);
|
|
527
|
+
if (index === -1) return OMapping(null, null, null, null);
|
|
528
|
+
const segment = segments[index];
|
|
529
|
+
if (segment.length === 1) return OMapping(null, null, null, null);
|
|
530
|
+
const { names, resolvedSources } = map;
|
|
531
|
+
return OMapping(
|
|
532
|
+
resolvedSources[segment[SOURCES_INDEX]],
|
|
533
|
+
segment[SOURCE_LINE] + 1,
|
|
534
|
+
segment[SOURCE_COLUMN],
|
|
535
|
+
segment.length === 5 ? names[segment[NAMES_INDEX]] : null
|
|
536
|
+
);
|
|
568
537
|
}
|
|
569
538
|
function OMapping(source, line, column, name) {
|
|
570
|
-
|
|
539
|
+
return { source, line, column, name };
|
|
571
540
|
}
|
|
572
541
|
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
if (index === -1 || index === segments.length)
|
|
580
|
-
return -1;
|
|
581
|
-
return index;
|
|
542
|
+
let index = memoizedBinarySearch(segments, column, memo, line);
|
|
543
|
+
if (found) {
|
|
544
|
+
index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
|
|
545
|
+
} else if (bias === LEAST_UPPER_BOUND) index++;
|
|
546
|
+
if (index === -1 || index === segments.length) return -1;
|
|
547
|
+
return index;
|
|
582
548
|
}
|
|
583
549
|
|
|
584
550
|
// Only install once if called multiple times
|
|
@@ -932,7 +898,7 @@ function withInlineSourcemap(result, options) {
|
|
|
932
898
|
// this is a bug in Vite
|
|
933
899
|
// all files should be either absolute to the file system or relative to the source map file
|
|
934
900
|
if (isAbsolute(source)) {
|
|
935
|
-
const actualPath = !source.startsWith(withTrailingSlash(options.root)) && source.startsWith("/") ? resolve$
|
|
901
|
+
const actualPath = !source.startsWith(withTrailingSlash(options.root)) && source.startsWith("/") ? resolve$1(options.root, source.slice(1)) : source;
|
|
936
902
|
return relative(dirname(options.filepath), actualPath);
|
|
937
903
|
}
|
|
938
904
|
return source;
|
|
@@ -36,6 +36,11 @@ declare abstract class SourceMap {
|
|
|
36
36
|
resolvedSources: SourceMapV3['sources'];
|
|
37
37
|
ignoreList: SourceMapV3['ignoreList'];
|
|
38
38
|
}
|
|
39
|
+
type Ro<T> = T extends Array<infer V> ? V[] | Readonly<V[]> | RoArray<V> | Readonly<RoArray<V>> : T extends object ? T | Readonly<T> | RoObject<T> | Readonly<RoObject<T>> : T;
|
|
40
|
+
type RoArray<T> = Ro<T>[];
|
|
41
|
+
type RoObject<T> = {
|
|
42
|
+
[K in keyof T]: T[K] | Ro<T[K]>;
|
|
43
|
+
};
|
|
39
44
|
|
|
40
45
|
declare class TraceMap implements SourceMap {
|
|
41
46
|
version: SourceMapV3['version'];
|
|
@@ -51,7 +56,7 @@ declare class TraceMap implements SourceMap {
|
|
|
51
56
|
private _decodedMemo;
|
|
52
57
|
private _bySources;
|
|
53
58
|
private _bySourceMemos;
|
|
54
|
-
constructor(map: SourceMapInput
|
|
59
|
+
constructor(map: Ro<SourceMapInput>, mapUrl?: string | null);
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
export type { DecodedSourceMap as D, EncodedSourceMap as E, SourceMapInput as S };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-
|
|
2
|
-
export { A as Arrayable, h as Awaitable, k as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, i as FetchFunction, F as FetchResult, b as HotContext, l as ModuleCache, M as ModuleCacheMap, f as ModuleExecutionInfo, N as Nullable, R as RawSourceMap, j as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, n as ViteNodeResolveModule, m as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index.d-
|
|
1
|
+
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-BWFx6tPc.js';
|
|
2
|
+
export { A as Arrayable, h as Awaitable, k as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, i as FetchFunction, F as FetchResult, b as HotContext, l as ModuleCache, M as ModuleCacheMap, f as ModuleExecutionInfo, N as Nullable, R as RawSourceMap, j as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, n as ViteNodeResolveModule, m as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index.d-CvIJUDRh.js';
|
package/dist/utils.cjs
CHANGED
|
@@ -8,8 +8,8 @@ var pathe = require('pathe');
|
|
|
8
8
|
const isWindows = process.platform === "win32";
|
|
9
9
|
const drive = isWindows ? process.cwd()[0] : null;
|
|
10
10
|
const driveOpposite = drive ? drive === drive.toUpperCase() ? drive.toLowerCase() : drive.toUpperCase() : null;
|
|
11
|
-
const driveRegexp = drive ? new RegExp(`(?:^|/@fs/)${drive}(\:[\\/])`) : null;
|
|
12
|
-
const driveOppositeRegext = driveOpposite ? new RegExp(`(?:^|/@fs/)${driveOpposite}(\:[\\/])`) : null;
|
|
11
|
+
const driveRegexp = drive ? /* @__PURE__ */ new RegExp(`(?:^|/@fs/)${drive}(\:[\\/])`) : null;
|
|
12
|
+
const driveOppositeRegext = driveOpposite ? /* @__PURE__ */ new RegExp(`(?:^|/@fs/)${driveOpposite}(\:[\\/])`) : null;
|
|
13
13
|
function slash(str) {
|
|
14
14
|
return str.replace(/\\/g, "/");
|
|
15
15
|
}
|
|
@@ -43,7 +43,7 @@ function splitFileAndPostfix(path) {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
const internalRequests = ["@vite/client", "@vite/env"];
|
|
46
|
-
const internalRequestRegexp = new RegExp(`^/?(?:${internalRequests.join("|")})$`);
|
|
46
|
+
const internalRequestRegexp = /* @__PURE__ */ new RegExp(`^/?(?:${internalRequests.join("|")})$`);
|
|
47
47
|
function isInternalRequest(id) {
|
|
48
48
|
return internalRequestRegexp.test(id);
|
|
49
49
|
}
|
|
@@ -111,7 +111,7 @@ function toFilePath(id, root) {
|
|
|
111
111
|
const NODE_BUILTIN_NAMESPACE = "node:";
|
|
112
112
|
function isNodeBuiltin(id) {
|
|
113
113
|
if (prefixedBuiltins.has(id)) return true;
|
|
114
|
-
return builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(
|
|
114
|
+
return builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(5) : id);
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* Convert `Arrayable<T>` to `Array<T>`
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as Nullable, A as Arrayable } from './index.d-
|
|
2
|
-
import './trace-mapping.d-
|
|
1
|
+
import { N as Nullable, A as Arrayable } from './index.d-CvIJUDRh.js';
|
|
2
|
+
import './trace-mapping.d-BWFx6tPc.js';
|
|
3
3
|
|
|
4
4
|
declare const isWindows: boolean;
|
|
5
5
|
declare function slash(str: string): string;
|
|
@@ -11,8 +11,8 @@ declare function isInternalRequest(id: string): boolean;
|
|
|
11
11
|
declare function normalizeModuleId(id: string): string;
|
|
12
12
|
declare function isPrimitive(v: any): boolean;
|
|
13
13
|
declare function toFilePath(id: string, root: string): {
|
|
14
|
-
path: string
|
|
15
|
-
exists: boolean
|
|
14
|
+
path: string;
|
|
15
|
+
exists: boolean;
|
|
16
16
|
};
|
|
17
17
|
declare function isNodeBuiltin(id: string): boolean;
|
|
18
18
|
/**
|
|
@@ -26,7 +26,7 @@ declare function setCacheData<T>(cache: Map<string, T>, data: T, basedir: string
|
|
|
26
26
|
declare function withTrailingSlash(path: string): string;
|
|
27
27
|
declare function createImportMetaEnvProxy(): NodeJS.ProcessEnv;
|
|
28
28
|
declare function findNearestPackageData(basedir: string): Promise<{
|
|
29
|
-
type?: "module" | "commonjs"
|
|
29
|
+
type?: "module" | "commonjs";
|
|
30
30
|
}>;
|
|
31
31
|
|
|
32
32
|
export { VALID_ID_PREFIX, cleanUrl, createImportMetaEnvProxy, findNearestPackageData, getCachedData, isBareImport, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, setCacheData, slash, toArray, toFilePath, withTrailingSlash };
|
package/dist/utils.mjs
CHANGED
|
@@ -6,8 +6,8 @@ import { resolve, join, dirname } from 'pathe';
|
|
|
6
6
|
const isWindows = process.platform === "win32";
|
|
7
7
|
const drive = isWindows ? process.cwd()[0] : null;
|
|
8
8
|
const driveOpposite = drive ? drive === drive.toUpperCase() ? drive.toLowerCase() : drive.toUpperCase() : null;
|
|
9
|
-
const driveRegexp = drive ? new RegExp(`(?:^|/@fs/)${drive}(\:[\\/])`) : null;
|
|
10
|
-
const driveOppositeRegext = driveOpposite ? new RegExp(`(?:^|/@fs/)${driveOpposite}(\:[\\/])`) : null;
|
|
9
|
+
const driveRegexp = drive ? /* @__PURE__ */ new RegExp(`(?:^|/@fs/)${drive}(\:[\\/])`) : null;
|
|
10
|
+
const driveOppositeRegext = driveOpposite ? /* @__PURE__ */ new RegExp(`(?:^|/@fs/)${driveOpposite}(\:[\\/])`) : null;
|
|
11
11
|
function slash(str) {
|
|
12
12
|
return str.replace(/\\/g, "/");
|
|
13
13
|
}
|
|
@@ -41,7 +41,7 @@ function splitFileAndPostfix(path) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
const internalRequests = ["@vite/client", "@vite/env"];
|
|
44
|
-
const internalRequestRegexp = new RegExp(`^/?(?:${internalRequests.join("|")})$`);
|
|
44
|
+
const internalRequestRegexp = /* @__PURE__ */ new RegExp(`^/?(?:${internalRequests.join("|")})$`);
|
|
45
45
|
function isInternalRequest(id) {
|
|
46
46
|
return internalRequestRegexp.test(id);
|
|
47
47
|
}
|
|
@@ -109,7 +109,7 @@ function toFilePath(id, root) {
|
|
|
109
109
|
const NODE_BUILTIN_NAMESPACE = "node:";
|
|
110
110
|
function isNodeBuiltin(id) {
|
|
111
111
|
if (prefixedBuiltins.has(id)) return true;
|
|
112
|
-
return builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(
|
|
112
|
+
return builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(5) : id);
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
115
|
* Convert `Arrayable<T>` to `Array<T>`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-node",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.3",
|
|
5
5
|
"description": "Vite as Node.js runtime",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@jridgewell/trace-mapping": "^0.3.
|
|
87
|
+
"@jridgewell/trace-mapping": "^0.3.29",
|
|
88
88
|
"@types/debug": "^4.1.12",
|
|
89
89
|
"tinyrainbow": "^2.0.0"
|
|
90
90
|
},
|