Socket
Socket
Sign inDemoInstall

@jridgewell/trace-mapping

Package Overview
Dependencies
2
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.15 to 0.3.16

95

dist/trace-mapping.umd.js

@@ -300,2 +300,3 @@ (function (global, factory) {

const GREATEST_LOWER_BOUND = 1;
const ALL_BOUND = 0;
/**

@@ -321,10 +322,10 @@ * Returns the encoded (VLQ string) form of the SourceMap's mappings field.

/**
* Finds the source/line/column directly after the mapping returned by originalPositionFor, provided
* the found mapping is from the same source and line as the originalPositionFor mapping.
*
* Eg, in the code `let id = 1`, `originalPositionAfter` could find the mapping associated with `1`
* using the same needle that would return `id` when calling `originalPositionFor`.
* Finds the generated line/column position of the provided source/line/column source position.
*/
exports.generatedPositionFor = void 0;
/**
* Finds all generated line/column positions of the provided source/line/column source position.
*/
exports.allGeneratedPositionsFor = void 0;
/**
* Iterates each mapping in generated position order.

@@ -395,3 +396,5 @@ */

return null;
return traceSegmentInternal(decoded[line], map._decodedMemo, line, column, GREATEST_LOWER_BOUND);
const segments = decoded[line];
const index = traceSegmentInternal(segments, map._decodedMemo, line, column, GREATEST_LOWER_BOUND);
return index === -1 ? null : segments[index];
};

@@ -409,6 +412,8 @@ exports.originalPositionFor = (map, { line, column, bias }) => {

return OMapping(null, null, null, null);
const segment = traceSegmentInternal(decoded[line], map._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
if (segment == null)
const segments = decoded[line];
const index = traceSegmentInternal(segments, map._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
if (index === -1)
return OMapping(null, null, null, null);
if (segment.length == 1)
const segment = segments[index];
if (segment.length === 1)
return OMapping(null, null, null, null);

@@ -418,23 +423,7 @@ const { names, resolvedSources } = map;

};
exports.allGeneratedPositionsFor = (map, { source, line, column }) => {
return generatedPosition(map, source, line, column, ALL_BOUND);
};
exports.generatedPositionFor = (map, { source, line, column, bias }) => {
line--;
if (line < 0)
throw new Error(LINE_GTR_ZERO);
if (column < 0)
throw new Error(COL_GTR_EQ_ZERO);
const { sources, resolvedSources } = map;
let sourceIndex = sources.indexOf(source);
if (sourceIndex === -1)
sourceIndex = resolvedSources.indexOf(source);
if (sourceIndex === -1)
return GMapping(null, null);
const generated = (map._bySources || (map._bySources = buildBySources(exports.decodedMappings(map), (map._bySourceMemos = sources.map(memoizedState)))));
const memos = map._bySourceMemos;
const segments = generated[sourceIndex][line];
if (segments == null)
return GMapping(null, null);
const segment = traceSegmentInternal(segments, memos[sourceIndex], line, column, bias || GREATEST_LOWER_BOUND);
if (segment == null)
return GMapping(null, null);
return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND);
};

@@ -492,2 +481,27 @@ exports.eachMapping = (map, cb) => {

};
function generatedPosition(map, source, line, column, bias) {
line--;
if (line < 0)
throw new Error(LINE_GTR_ZERO);
if (column < 0)
throw new Error(COL_GTR_EQ_ZERO);
const { sources, resolvedSources } = map;
let sourceIndex = sources.indexOf(source);
if (sourceIndex === -1)
sourceIndex = resolvedSources.indexOf(source);
if (sourceIndex === -1)
return bias === ALL_BOUND ? [] : GMapping(null, null);
const generated = (map._bySources || (map._bySources = buildBySources(exports.decodedMappings(map), (map._bySourceMemos = sources.map(memoizedState)))));
const segments = generated[sourceIndex][line];
if (segments == null)
return bias === ALL_BOUND ? [] : GMapping(null, null);
const memo = map._bySourceMemos[sourceIndex];
if (bias === ALL_BOUND)
return sliceGeneratedPositions(segments, memo, line, column);
const index = traceSegmentInternal(segments, memo, line, column, bias);
if (index === -1)
return GMapping(null, null);
const segment = segments[index];
return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
}
})();

@@ -519,5 +533,24 @@ function clone(map, mappings) {

if (index === -1 || index === segments.length)
return null;
return segments[index];
return -1;
return index;
}
function sliceGeneratedPositions(segments, memo, line, column) {
let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND);
if (min === -1)
return [];
// We may have found the segment that started at an earlier column. If this is the case, then we
// need to slice all generated segments that match _that_ column, because all such segments span
// to our desired column.
const matchedColumn = found ? column : segments[min][COLUMN];
// The binary search is not guaranteed to find the lower bound when a match wasn't found.
if (!found)
min = lowerBound(segments, matchedColumn, min);
const max = upperBound(segments, matchedColumn, min);
const result = [];
for (; min <= max; min++) {
const segment = segments[min];
result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]));
}
return result;
}

@@ -524,0 +557,0 @@ exports.AnyMap = AnyMap;

@@ -27,10 +27,10 @@ import type { SourceMapSegment } from './sourcemap-segment';

/**
* Finds the source/line/column directly after the mapping returned by originalPositionFor, provided
* the found mapping is from the same source and line as the originalPositionFor mapping.
*
* Eg, in the code `let id = 1`, `originalPositionAfter` could find the mapping associated with `1`
* using the same needle that would return `id` when calling `originalPositionFor`.
* Finds the generated line/column position of the provided source/line/column source position.
*/
export declare let generatedPositionFor: (map: TraceMap, needle: SourceNeedle) => GeneratedMapping | InvalidGeneratedMapping;
/**
* Finds all generated line/column positions of the provided source/line/column source position.
*/
export declare let allGeneratedPositionsFor: (map: TraceMap, needle: SourceNeedle) => GeneratedMapping[];
/**
* Iterates each mapping in generated position order.

@@ -37,0 +37,0 @@ */

import type { SourceMapSegment } from './sourcemap-segment';
import type { TraceMap } from './trace-mapping';
import type { GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND, TraceMap } from './trace-mapping';
export interface SourceMapV3 {

@@ -49,8 +49,9 @@ file?: string | null;

};
export declare type SourceMapInput = string | EncodedSourceMap | DecodedSourceMap | TraceMap;
export declare type SectionedSourceMapInput = SourceMapInput | SectionedSourceMap;
export declare type Bias = typeof GREATEST_LOWER_BOUND | typeof LEAST_UPPER_BOUND;
export declare type SourceMapInput = string | Ro<EncodedSourceMap> | Ro<DecodedSourceMap> | TraceMap;
export declare type SectionedSourceMapInput = SourceMapInput | Ro<SectionedSourceMap>;
export declare type Needle = {
line: number;
column: number;
bias?: 1 | -1;
bias?: Bias;
};

@@ -61,3 +62,3 @@ export declare type SourceNeedle = {

column: number;
bias?: 1 | -1;
bias?: Bias;
};

@@ -88,1 +89,7 @@ export declare type EachMapping = {

}
export declare 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;
declare type RoArray<T> = Ro<T>[];
declare type RoObject<T> = {
[K in keyof T]: T[K] | Ro<T[K]>;
};
export {};
{
"name": "@jridgewell/trace-mapping",
"version": "0.3.15",
"version": "0.3.16",
"description": "Trace the original position through a source map",

@@ -55,22 +55,22 @@ "keywords": [

"devDependencies": {
"@rollup/plugin-typescript": "8.3.2",
"@typescript-eslint/eslint-plugin": "5.23.0",
"@typescript-eslint/parser": "5.23.0",
"ava": "4.2.0",
"@rollup/plugin-typescript": "8.5.0",
"@typescript-eslint/eslint-plugin": "5.39.0",
"@typescript-eslint/parser": "5.39.0",
"ava": "4.3.3",
"benchmark": "2.1.4",
"c8": "7.11.2",
"esbuild": "0.14.38",
"esbuild-node-loader": "0.8.0",
"eslint": "8.15.0",
"c8": "7.12.0",
"esbuild": "0.15.10",
"eslint": "8.25.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-no-only-tests": "2.6.0",
"eslint-plugin-no-only-tests": "3.0.0",
"npm-run-all": "4.1.5",
"prettier": "2.6.2",
"rollup": "2.72.1",
"typescript": "4.6.4"
"prettier": "2.7.1",
"rollup": "2.79.1",
"tsx": "3.10.1",
"typescript": "4.8.4"
},
"dependencies": {
"@jridgewell/resolve-uri": "^3.0.3",
"@jridgewell/sourcemap-codec": "^1.4.10"
"@jridgewell/resolve-uri": "3.1.0",
"@jridgewell/sourcemap-codec": "1.4.14"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc