Socket
Socket
Sign inDemoInstall

@web/test-runner-core

Package Overview
Dependencies
Maintainers
7
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web/test-runner-core - npm Package Compare versions

Comparing version 0.11.3 to 0.11.4

72

dist/server/plugins/api/createSourceMapFunction.js

@@ -28,49 +28,19 @@ "use strict";

var _a, _b;
const cacheKey = `${filePath}${userAgent}`;
if (!cachedSourceMaps.has(cacheKey)) {
cachedSourceMaps.set(cacheKey, (0, fetchSourceMap_1.fetchSourceMap)({
protocol,
host,
port,
browserUrl,
userAgent,
})
.then(({ sourceMap }) => sourceMap)
.catch(() => undefined));
}
const sourceMap = await cachedSourceMaps.get(cacheKey);
if (!sourceMap) {
return null;
}
try {
const cacheKey = `${filePath}${userAgent}`;
let cached = cachedSourceMaps.get(cacheKey);
if (cached) {
if (cached.loadingPromise) {
// a request for this source map is already being done in parallel, wait for it to finish
await cached.loadingPromise;
}
if (!cached.sourceMap) {
// we know there is no source map for this file
return null;
}
}
else {
cached = {};
}
cachedSourceMaps.set(cacheKey, cached);
// get the raw source map, from cache or new
let sourceMap;
if (cached.sourceMap) {
sourceMap = cached === null || cached === void 0 ? void 0 : cached.sourceMap;
}
else {
// fetch source map, maintain a loading boolean for parallel calls to wait before resolving
let resolveLoading;
const loadingPromise = new Promise(resolve => {
resolveLoading = resolve;
});
cached.loadingPromise = loadingPromise;
try {
const result = await (0, fetchSourceMap_1.fetchSourceMap)({
protocol,
host,
port,
browserUrl,
userAgent,
});
sourceMap = result.sourceMap;
cached.sourceMap = sourceMap;
}
finally {
resolveLoading();
}
}
if (!sourceMap) {
return null;
}
// if there is no line and column we're looking for just the associated file, for example

@@ -92,10 +62,3 @@ // the test file itself has source maps. if this is a single file source map, we can return

// do the actual source mapping
let consumer;
if (cached === null || cached === void 0 ? void 0 : cached.consumer) {
consumer = cached.consumer;
}
else {
consumer = await new source_map_1.SourceMapConsumer(sourceMap.sourcemap);
cachedSourceMaps.get(cacheKey).consumer = consumer;
}
const consumer = await new source_map_1.SourceMapConsumer(sourceMap.sourcemap);
let originalPosition = consumer.originalPositionFor({

@@ -113,2 +76,3 @@ line: line !== null && line !== void 0 ? line : 0,

}
consumer.destroy();
if (originalPosition.line == null) {

@@ -115,0 +79,0 @@ return null;

{
"name": "@web/test-runner-core",
"version": "0.11.3",
"version": "0.11.4",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

@@ -13,8 +13,2 @@ import path from 'path';

interface CachedSourceMap {
sourceMap?: SourceMapConverter;
consumer?: SourceMapConsumer;
loadingPromise?: Promise<void>;
}
function resolveRelativeTo(relativeTo: string, filePath: string): string {

@@ -40,53 +34,28 @@ if (path.isAbsolute(filePath)) {

): SourceMapFunction {
const cachedSourceMaps = new Map<string, CachedSourceMap | null>();
const cachedSourceMaps = new Map<string, Promise<SourceMapConverter | undefined>>();
return async ({ browserUrl, filePath, line, column }, userAgent) => {
try {
const cacheKey = `${filePath}${userAgent}`;
let cached = cachedSourceMaps.get(cacheKey);
if (cached) {
if (cached.loadingPromise) {
// a request for this source map is already being done in parallel, wait for it to finish
await cached.loadingPromise;
}
const cacheKey = `${filePath}${userAgent}`;
if (!cached.sourceMap) {
// we know there is no source map for this file
return null;
}
} else {
cached = {};
}
cachedSourceMaps.set(cacheKey, cached);
if (!cachedSourceMaps.has(cacheKey)) {
cachedSourceMaps.set(
cacheKey,
fetchSourceMap({
protocol,
host,
port,
browserUrl,
userAgent,
})
.then(({ sourceMap }) => sourceMap)
.catch(() => undefined),
);
}
// get the raw source map, from cache or new
let sourceMap: SourceMapConverter | undefined;
if (cached.sourceMap) {
sourceMap = cached?.sourceMap;
} else {
// fetch source map, maintain a loading boolean for parallel calls to wait before resolving
let resolveLoading: () => void;
const loadingPromise = new Promise<void>(resolve => {
resolveLoading = resolve;
});
cached.loadingPromise = loadingPromise;
const sourceMap = await cachedSourceMaps.get(cacheKey);
if (!sourceMap) {
return null;
}
try {
const result = await fetchSourceMap({
protocol,
host,
port,
browserUrl,
userAgent,
});
sourceMap = result.sourceMap;
cached.sourceMap = sourceMap;
} finally {
resolveLoading!();
}
}
if (!sourceMap) {
return null;
}
try {
// if there is no line and column we're looking for just the associated file, for example

@@ -109,9 +78,3 @@ // the test file itself has source maps. if this is a single file source map, we can return

// do the actual source mapping
let consumer: SourceMapConsumer;
if (cached?.consumer) {
consumer = cached.consumer;
} else {
consumer = await new SourceMapConsumer(sourceMap.sourcemap);
cachedSourceMaps.get(cacheKey)!.consumer = consumer;
}
const consumer: SourceMapConsumer = await new SourceMapConsumer(sourceMap.sourcemap);

@@ -132,2 +95,4 @@ let originalPosition = consumer.originalPositionFor({

consumer.destroy();
if (originalPosition.line == null) {

@@ -134,0 +99,0 @@ return null;

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
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc