UNPKG

1.96 kBTypeScriptView Raw
1import { RawSourceMap } from 'source-map';
2
3export import CachedSource = require('./CachedSource');
4export import CompatSource = require('./CompatSource');
5export import ConcatSource = require('./ConcatSource');
6export import OriginalSource = require('./OriginalSource');
7export import PrefixSource = require('./PrefixSource');
8export import RawSource = require('./RawSource');
9export import ReplaceSource = require('./ReplaceSource');
10export import SizeOnlySource = require('./SizeOnlySource');
11export import Source = require('./Source');
12export import SourceMapSource = require('./SourceMapSource');
13
14export interface MapOptions {
15 /**
16 * If set to false the implementation may omit mappings for columns
17 * @default true
18 */
19 columns?: boolean;
20 /**
21 * If set to false the implementation may omit inner mappings for modules.
22 * @default true
23 */
24 module?: boolean;
25}
26
27export interface SourceAndMapMixin {
28 /**
29 * Returns the SourceMap of the represented source code as JSON.
30 * May return `null` if no SourceMap is available.
31 */
32 map(options?: MapOptions): RawSourceMap | null;
33 /**
34 * Returns both, source code (like `Source.prototype.source()` and SourceMap (like `Source.prototype.map()`).
35 * This method could have better performance than calling `source()` and `map()` separately.
36 */
37 sourceAndMap(options?: MapOptions): SourceAndMapResult;
38}
39
40export interface SourceAndMapResult {
41 source: string | Buffer;
42 map: RawSourceMap | null;
43}
44
45export interface Replacement {
46 readonly start: number;
47 readonly end: number;
48 readonly content: string;
49 readonly insertIndex: number;
50 readonly name: string;
51}
52
53export type SourceLike = Partial<Pick<Source, 'source' | 'buffer' | 'size' | 'map' | 'sourceAndMap' | 'updateHash'>>;
54
55export interface CachedData {
56 buffer?: Buffer;
57 source?: string | boolean;
58 size?: number;
59 cachedData?: Map<any, any>;
60}