Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@google-cloud/debug-agent

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/debug-agent - npm Package Compare versions

Comparing version 5.2.1 to 5.2.2

2

build/src/agent/io/sourcemapper.d.ts

@@ -5,3 +5,3 @@ import * as sourceMap from 'source-map';

mapFile: string;
mapConsumer: sourceMap.RawSourceMap;
mapConsumer: sourceMap.SourceMapConsumer;
sources: string[];

@@ -8,0 +8,0 @@ }

@@ -41,5 +41,5 @@ "use strict";

mapPath = path.normalize(mapPath);
let contents;
let rawSourceMapString;
try {
contents = await readFilep(mapPath, 'utf8');
rawSourceMapString = await readFilep(mapPath, 'utf8');
}

@@ -49,11 +49,12 @@ catch (e) {

}
let rawSourceMap;
try {
rawSourceMap = JSON.parse(rawSourceMapString);
}
catch (e) {
throw new Error('Could not parse the raw sourcemap ' + mapPath + ': ' + e);
}
let consumer;
try {
// TODO: Determine how to reconsile the type conflict where `consumer`
// is constructed as a SourceMapConsumer but is used as a
// RawSourceMap.
// TODO: Resolve the cast of `contents as any` (This is needed because the
// type is expected to be of `RawSourceMap` but the existing
// working code uses a string.)
consumer = new sourceMap.SourceMapConsumer(contents);
consumer = await new sourceMap.SourceMapConsumer(rawSourceMapString);
}

@@ -73,12 +74,27 @@ catch (e) {

*/
const outputBase = consumer.file
? consumer.file
const outputBase = rawSourceMap.file
? rawSourceMap.file
: path.basename(mapPath, '.map');
const parentDir = path.dirname(mapPath);
const outputPath = path.normalize(path.join(parentDir, outputBase));
// the sources are in ascending order from shortest to longest
const nonemptySources = consumer.sources
.filter(val => !!val)
// The paths of the sources that are relative to the source map file. Sort
// them in ascending order from shortest to longest.
// For webpack file path, normalize the path after the webpack prefix so that
// the source map library can recognize it.
const sourcesRelToSrcmap = rawSourceMap.sources
.filter((val) => !!val)
.map((val) => {
if (val.toLowerCase().startsWith(WEBPACK_PREFIX)) {
return (WEBPACK_PREFIX +
path.normalize(val.substr(WEBPACK_PREFIX.length)).replace(/\\/g, '/'));
}
return val;
})
.sort((src1, src2) => src1.length - src2.length);
const normalizedSources = nonemptySources
// The paths of the sources that are relative to the current process's working
// directory. These are the ones that are used for the fuzzy search (thus are
// platform specific, e.g. using '\\' on Windows and using '/' in Unix, etc.).
// For webpack file path, the prefix is filtered out for better fuzzy search
// result.
const normalizedSourcesRelToProc = sourcesRelToSrcmap
.map((src) => {

@@ -91,11 +107,10 @@ if (src.toLowerCase().startsWith(WEBPACK_PREFIX)) {

.map((relPath) => {
// resolve the paths relative to the map file so that
// they are relative to the process's current working
// directory
// resolve the paths relative to the map file so that they are relative to
// the process's current working directory
return path.normalize(path.join(parentDir, relPath));
});
if (normalizedSources.length === 0) {
if (normalizedSourcesRelToProc.length === 0) {
throw new Error('No sources listed in the sourcemap file ' + mapPath);
}
for (const src of normalizedSources) {
for (const src of normalizedSourcesRelToProc) {
infoMap.set(path.normalize(src), {

@@ -105,3 +120,3 @@ outputFile: outputPath,

mapConsumer: consumer,
sources: nonemptySources,
sources: sourcesRelToSrcmap,
});

@@ -179,2 +194,3 @@ }

mappingInfo(inputPath, lineNumber, colNumber) {
var _a;
inputPath = path.normalize(inputPath);

@@ -207,5 +223,3 @@ const entry = this.getMappingInfo(inputPath);

};
// TODO: Determine how to remove the explicit cast here.
const consumer = entry.mapConsumer;
const allPos = consumer.allGeneratedPositionsFor(sourcePos);
const allPos = entry.mapConsumer.allGeneratedPositionsFor(sourcePos);
/*

@@ -220,8 +234,11 @@ * Based on testing, it appears that the following code is needed to

? allPos.reduce((accumulator, value) => {
return value.line < accumulator.line ? value : accumulator;
var _a, _b;
return ((_a = value.line) !== null && _a !== void 0 ? _a : 0) < ((_b = accumulator.line) !== null && _b !== void 0 ? _b : 0)
? value
: accumulator;
})
: consumer.generatedPositionFor(sourcePos);
: entry.mapConsumer.generatedPositionFor(sourcePos);
return {
file: entry.outputFile,
line: mappedPos.line - 1,
line: ((_a = mappedPos.line) !== null && _a !== void 0 ? _a : 0) - 1,
// by the SourceMapConsumer to the expected

@@ -228,0 +245,0 @@ // zero-based output.

{
"name": "@google-cloud/debug-agent",
"version": "5.2.1",
"version": "5.2.2",
"author": "Google Inc.",

@@ -58,3 +58,3 @@ "description": "Stackdriver Debug Agent for Node.js",

"semver": "^7.0.0",
"source-map": "^0.6.1",
"source-map": "^0.7.3",
"split": "^1.0.0"

@@ -71,3 +71,3 @@ },

"@types/ncp": "^2.0.3",
"@types/node": "~10.17.0",
"@types/node": "^14.17.2",
"@types/proxyquire": "^1.3.28",

@@ -74,0 +74,0 @@ "@types/semver": "^7.0.0",

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 too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc