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.2.7 to 0.3.0

94

dist/trace-mapping.umd.js

@@ -137,2 +137,21 @@ (function (global, factory) {

});
/**
* Returns the encoded (VLQ string) form of the SourceMap's mappings field.
*/
exports.encodedMappings = void 0;
/**
* Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
*/
exports.decodedMappings = void 0;
/**
* A low-level API to find the segment associated with a generated line/column (think, from a
* stack trace). Line and column here are 0-based, unlike `originalPositionFor`.
*/
exports.traceSegment = void 0;
/**
* A higher-level API to find the source/line/column associated with a generated line/column
* (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
* `source-map` library.
*/
exports.originalPositionFor = void 0;
class TraceMap {

@@ -162,48 +181,13 @@ constructor(map, mapUrl) {

}
/**
* Returns the encoded (VLQ string) form of the SourceMap's mappings field.
*/
encodedMappings() {
}
(() => {
exports.encodedMappings = (map) => {
var _a;
return ((_a = this._encoded) !== null && _a !== void 0 ? _a : (this._encoded = sourcemapCodec.encode(this._decoded)));
}
/**
* Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
*/
decodedMappings() {
return this._decoded;
}
/**
* Similar to Array.p.map, maps each segment into a new segment. Passes -1 for any values that do
* not exist in the SourceMapSegment. Both generatedLine and generatedColumn are 0-based.
*/
map(fn) {
const mapOut = [];
const decoded = this._decoded;
for (let i = 0; i < decoded.length; i++) {
const line = decoded[i];
const lineOut = [];
mapOut.push(lineOut);
for (let j = 0; j < line.length; j++) {
const seg = line[j];
const { length } = seg;
let segOut;
if (length === 4)
segOut = fn(i, seg[0], seg[1], seg[2], seg[3], -1);
else if (length === 5)
segOut = fn(i, seg[0], seg[1], seg[2], seg[3], seg[4]);
else
segOut = fn(i, seg[0], -1, -1, -1, -1);
if (segOut != null)
lineOut.push(segOut);
}
}
return mapOut;
}
/**
* A low-level API to find the segment associated with a generated line/column (think, from a
* stack trace). Line and column here are 0-based, unlike `originalPositionFor`.
*/
traceSegment(line, column) {
const decoded = this._decoded;
return ((_a = map._encoded) !== null && _a !== void 0 ? _a : (map._encoded = sourcemapCodec.encode(map._decoded)));
};
exports.decodedMappings = (map) => {
return map._decoded;
};
exports.traceSegment = (map, line, column) => {
const decoded = map._decoded;
// It's common for parent source maps to have pointers to lines that have no

@@ -214,3 +198,3 @@ // mapping (like a "//# sourceMappingURL=") at the end of the child file.

const segments = decoded[line];
const index = memoizedBinarySearch(segments, column, this._binarySearchMemo, line);
const index = memoizedBinarySearch(segments, column, map._binarySearchMemo, line);
// we come before any mapped segment

@@ -220,9 +204,4 @@ if (index < 0)

return segments[index];
}
/**
* A higher-level API to find the source/line/column associated with a generated line/column
* (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
* `source-map` library.
*/
originalPositionFor({ line, column }) {
};
exports.originalPositionFor = (map, { line, column }) => {
if (line < 1)

@@ -233,3 +212,3 @@ throw new Error('`line` must be greater than 0 (lines start at line 1)');

}
const segment = this.traceSegment(line - 1, column);
const segment = exports.traceSegment(map, line - 1, column);
if (segment == null)

@@ -239,3 +218,3 @@ return INVALID_MAPPING;

return INVALID_MAPPING;
const { names, resolvedSources } = this;
const { names, resolvedSources } = map;
return {

@@ -247,7 +226,6 @@ source: resolvedSources[segment[1]],

};
}
}
};
})();
exports.TraceMap = TraceMap;
exports["default"] = TraceMap;

@@ -254,0 +232,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

@@ -1,3 +0,22 @@

import type { SourceMapV3, DecodedSourceMap, EncodedSourceMap, InvalidMapping, Mapping, SourceMapSegment, SourceMapInput, Needle, MapSegmentFn, SourceMap } from './types';
export type { SourceMapSegment, SourceMapInput, DecodedSourceMap, EncodedSourceMap, MapSegmentFn, InvalidMapping, Mapping, } from './types';
import type { SourceMapV3, DecodedSourceMap, EncodedSourceMap, InvalidMapping, Mapping, SourceMapSegment, SourceMapInput, Needle, SourceMap } from './types';
export type { SourceMapSegment, SourceMapInput, DecodedSourceMap, EncodedSourceMap, InvalidMapping, Mapping, } from './types';
/**
* Returns the encoded (VLQ string) form of the SourceMap's mappings field.
*/
export declare let encodedMappings: (map: TraceMap) => EncodedSourceMap['mappings'];
/**
* Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
*/
export declare let decodedMappings: (map: TraceMap) => DecodedSourceMap['mappings'];
/**
* A low-level API to find the segment associated with a generated line/column (think, from a
* stack trace). Line and column here are 0-based, unlike `originalPositionFor`.
*/
export declare let traceSegment: (map: TraceMap, line: number, column: number) => SourceMapSegment | null;
/**
* A higher-level API to find the source/line/column associated with a generated line/column
* (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
* `source-map` library.
*/
export declare let originalPositionFor: (map: TraceMap, needle: Needle) => Mapping | InvalidMapping;
export declare class TraceMap implements SourceMap {

@@ -15,27 +34,2 @@ version: SourceMapV3['version'];

constructor(map: SourceMapInput, mapUrl?: string | null);
/**
* Returns the encoded (VLQ string) form of the SourceMap's mappings field.
*/
encodedMappings(): EncodedSourceMap['mappings'];
/**
* Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
*/
decodedMappings(): DecodedSourceMap['mappings'];
/**
* Similar to Array.p.map, maps each segment into a new segment. Passes -1 for any values that do
* not exist in the SourceMapSegment. Both generatedLine and generatedColumn are 0-based.
*/
map<T>(fn: MapSegmentFn<T>): NonNullable<T>[][];
/**
* A low-level API to find the segment associated with a generated line/column (think, from a
* stack trace). Line and column here are 0-based, unlike `originalPositionFor`.
*/
traceSegment(line: number, column: number): SourceMapSegment | null;
/**
* A higher-level API to find the source/line/column associated with a generated line/column
* (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
* `source-map` library.
*/
originalPositionFor({ line, column }: Needle): Mapping | InvalidMapping;
}
export { TraceMap as default };

@@ -38,9 +38,11 @@ export interface SourceMapV3 {

};
export declare type MapSegmentFn<T> = (generatedLine: number, generatedColumn: number, sourcesIndex: number, line: number, column: number, namesIndex: number) => T;
export declare abstract class SourceMap {
abstract encodedMappings(): EncodedSourceMap['mappings'];
abstract decodedMappings(): DecodedSourceMap['mappings'];
abstract map<T>(fn: MapSegmentFn<T>): NonNullable<T>[][];
abstract traceSegment(this: SourceMap, line: number, column: number): SourceMapSegment | null;
version: SourceMapV3['version'];
file: SourceMapV3['file'];
names: SourceMapV3['names'];
sourceRoot: SourceMapV3['sourceRoot'];
sources: SourceMapV3['sources'];
sourcesContent: SourceMapV3['sourcesContent'];
resolvedSources: SourceMapV3['sources'];
}
export {};
{
"name": "@jridgewell/trace-mapping",
"version": "0.2.7",
"version": "0.3.0",
"description": "Trace the original position through a source map",

@@ -5,0 +5,0 @@ "keywords": [

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