@oaklean/profiler-core
Version:
Part of the @oaklean suite. It provides all basic functions to work with the `.oak` file format. It allows parsing the `.oak` file format as well as tools for analyzing the measurement values. It also provides all necessary capabilities required for prec
57 lines (56 loc) • 1.82 kB
TypeScript
import { UnifiedPath } from '../system/UnifiedPath';
import { UrlProtocols } from '../types/helper/UrlProtocolHelper';
/**
* This helper is used to transform source paths from different protocols to the actual file path.
*
* E.g. webpack urls are in the format of:
* - webpack://[namespace]/[resourcePath]?[options]
* - webpack-internal:///[namespace]/[resourcePath]?[options]
*
* a also common format is:
* - file://[path]
*
*/
export declare class UrlProtocolHelper {
static extractProtocol(url: string): "file" | "webpack" | "webpack-internal" | null;
/**
* Converts a webpack source map path to the actual file path.
*
* In sourcemaps the source path is often a webpack url like:
* webpack://<module>/<file-path>
*
* This method converts the webpack url to the actual file path.
*
* Example:
* input: webpack://_N_E/node_modules/next/dist/esm/server/web/adapter.js?4fab
* rootDir: /Users/user/project
*
* result: /Users/user/project/node_modules/next/dist/esm/server/web/adapter.js
*
*/
static webpackSourceMapUrlToOriginalUrl(rootDir: UnifiedPath, originalSource: string): {
url: UnifiedPath;
protocol: UrlProtocols | null;
};
/**
* Extracts the source path from a webpack internal url with the format:
* - webpack://[namespace]/[resourcePath]?[options]
* - webpack-internal:///[namespace]/[resourcePath]?[options]
*
* Returns:
*
* {
* type: 'webpack' | 'webpack-internal',
* namespace: string,
* filePath: string,
* options: string
* }
*
*/
static parseWebpackSourceUrl(url: string): {
protocol: UrlProtocols;
namespace: string;
filePath: string;
options: string;
} | null;
}