1 | import { Hash } from "crypto";
|
2 | import { RawSourceMap } from "source-map";
|
3 |
|
4 | import { MapOptions, SourceAndMapResult } from ".";
|
5 |
|
6 | /**
|
7 | * Base class for all sources.
|
8 | * A Source can be asked for source code, size, source map and hash.
|
9 | */
|
10 | declare abstract class Source {
|
11 | /**
|
12 | * Returns the represented source code as string.
|
13 | */
|
14 | source(): string | ArrayBuffer;
|
15 |
|
16 | /**
|
17 | * Returns the represented source code as Buffer. Strings are converted to utf-8.
|
18 | */
|
19 | buffer(): Buffer;
|
20 |
|
21 | /**
|
22 | * Returns the size in chars of the represented source code.
|
23 | */
|
24 | size(): number;
|
25 |
|
26 | /**
|
27 | * Returns the SourceMap of the represented source code as JSON.
|
28 | * May return `null` if no SourceMap is available.
|
29 | */
|
30 | map(options?: MapOptions): RawSourceMap | null;
|
31 |
|
32 | /**
|
33 | * Returns both, source code (like `Source.prototype.source()` and SourceMap (like `Source.prototype.map()`).
|
34 | * This method could have better performance than calling `source()` and `map()` separately.
|
35 | */
|
36 | sourceAndMap(options?: MapOptions): SourceAndMapResult;
|
37 |
|
38 | /**
|
39 | * Updates the provided Hash object with the content of the represented source code.
|
40 | * (Hash is an object with an update method, which is called with string values)
|
41 | */
|
42 | updateHash(hash: Hash): void;
|
43 | }
|
44 |
|
45 | export = Source;
|