1 | // Type definitions for webpack-sources 0.1
|
---|
2 | // Project: https://github.com/webpack/webpack-sources
|
---|
3 | // Definitions by: e-cloud <https://github.com/e-cloud>
|
---|
4 | // Chris Eppstein <https://github.com/chriseppstein>
|
---|
5 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
---|
6 |
|
---|
7 | /// <reference types="node" />
|
---|
8 |
|
---|
9 | import { Hash } from 'crypto';
|
---|
10 | import { SourceNode, RawSourceMap, SourceMapGenerator } from 'source-map';
|
---|
11 | import { SourceListMap } from 'source-list-map';
|
---|
12 |
|
---|
13 | export abstract class Source {
|
---|
14 | size(): number;
|
---|
15 |
|
---|
16 | map(options?: any): any;
|
---|
17 |
|
---|
18 | sourceAndMap(options?: any): {
|
---|
19 | source: string;
|
---|
20 | map: RawSourceMap;
|
---|
21 | };
|
---|
22 |
|
---|
23 | updateHash(hash: Hash): void;
|
---|
24 |
|
---|
25 | source(options?: any): string;
|
---|
26 |
|
---|
27 | node(options?: any): any;
|
---|
28 |
|
---|
29 | listNode(options?: any): any;
|
---|
30 |
|
---|
31 | listMap(options?: any): any;
|
---|
32 | }
|
---|
33 |
|
---|
34 | export interface SourceAndMapMixin {
|
---|
35 | map(options: { columns?: boolean | undefined }): RawSourceMap;
|
---|
36 | sourceAndMap(options: { columns?: boolean | undefined }): {
|
---|
37 | source: string;
|
---|
38 | map: RawSourceMap;
|
---|
39 | };
|
---|
40 | }
|
---|
41 |
|
---|
42 | export class CachedSource extends Source {
|
---|
43 | _source: Source;
|
---|
44 | _cachedSource: string;
|
---|
45 | _cachedSize: number;
|
---|
46 | _cachedMaps: {
|
---|
47 | [prop: string]: RawSourceMap
|
---|
48 | };
|
---|
49 |
|
---|
50 | constructor(source: Source);
|
---|
51 |
|
---|
52 | source(): string;
|
---|
53 |
|
---|
54 | size(): number;
|
---|
55 |
|
---|
56 | node(options: any): SourceNode;
|
---|
57 |
|
---|
58 | listMap(options: any): SourceListMap;
|
---|
59 |
|
---|
60 | sourceAndMap(options: any): {
|
---|
61 | source: string;
|
---|
62 | map: RawSourceMap;
|
---|
63 | };
|
---|
64 |
|
---|
65 | map(options: any): RawSourceMap;
|
---|
66 |
|
---|
67 | updateHash(hash: Hash): void;
|
---|
68 | }
|
---|
69 |
|
---|
70 | export class ConcatSource extends Source implements SourceAndMapMixin {
|
---|
71 | children: Array<(string | Source)>;
|
---|
72 |
|
---|
73 | constructor(...args: Array<(string | Source)>);
|
---|
74 |
|
---|
75 | add(item: string | Source): void;
|
---|
76 |
|
---|
77 | source(): string;
|
---|
78 |
|
---|
79 | size(): number;
|
---|
80 |
|
---|
81 | node(options: any): SourceNode;
|
---|
82 |
|
---|
83 | listMap(options: any): SourceListMap;
|
---|
84 |
|
---|
85 | updateHash(hash: Hash): void;
|
---|
86 | }
|
---|
87 |
|
---|
88 | export class LineToLineMappedSource extends Source implements SourceAndMapMixin {
|
---|
89 | _value: string;
|
---|
90 | _name: string;
|
---|
91 | _originalSource: string;
|
---|
92 |
|
---|
93 | constructor(value: string, name: string, originalSource: string);
|
---|
94 |
|
---|
95 | source(): string;
|
---|
96 |
|
---|
97 | node(options: any): SourceNode;
|
---|
98 |
|
---|
99 | listMap(options: any): SourceListMap;
|
---|
100 |
|
---|
101 | updateHash(hash: Hash): void;
|
---|
102 | }
|
---|
103 |
|
---|
104 | export class OriginalSource extends Source implements SourceAndMapMixin {
|
---|
105 | _value: string;
|
---|
106 | _name: string;
|
---|
107 |
|
---|
108 | constructor(value: string, name: string);
|
---|
109 |
|
---|
110 | source(): string;
|
---|
111 |
|
---|
112 | node(
|
---|
113 | options?: {
|
---|
114 | columns?: boolean | undefined;
|
---|
115 | }
|
---|
116 | ): SourceNode;
|
---|
117 |
|
---|
118 | listMap(options: any): SourceListMap;
|
---|
119 |
|
---|
120 | updateHash(hash: Hash): void;
|
---|
121 | }
|
---|
122 |
|
---|
123 | export class PrefixSource extends Source implements SourceAndMapMixin {
|
---|
124 | _source: Source | string;
|
---|
125 | _prefix: Source | string;
|
---|
126 |
|
---|
127 | constructor(prefix: Source | string, source: Source | string);
|
---|
128 |
|
---|
129 | source(): string;
|
---|
130 |
|
---|
131 | node(options: any): SourceNode;
|
---|
132 |
|
---|
133 | listMap(options: any): SourceListMap;
|
---|
134 |
|
---|
135 | updateHash(hash: Hash): void;
|
---|
136 | }
|
---|
137 |
|
---|
138 | export class RawSource extends Source {
|
---|
139 | _value: string;
|
---|
140 |
|
---|
141 | constructor(value: string);
|
---|
142 |
|
---|
143 | source(): string;
|
---|
144 |
|
---|
145 | map(options: any): null;
|
---|
146 |
|
---|
147 | node(options: any): SourceNode;
|
---|
148 |
|
---|
149 | listMap(options: any): SourceListMap;
|
---|
150 |
|
---|
151 | updateHash(hash: Hash): void;
|
---|
152 | }
|
---|
153 |
|
---|
154 | export class ReplaceSource extends Source implements SourceAndMapMixin {
|
---|
155 | _source: Source;
|
---|
156 | _name: string;
|
---|
157 | replacements: any[][];
|
---|
158 |
|
---|
159 | constructor(source: Source, name?: string);
|
---|
160 |
|
---|
161 | replace(start: number, end: number, newValue: string): void;
|
---|
162 |
|
---|
163 | insert(pos: number, newValue: string): void;
|
---|
164 |
|
---|
165 | source(): string;
|
---|
166 |
|
---|
167 | _sortReplacements(): void;
|
---|
168 |
|
---|
169 | _replaceString(str: string): string;
|
---|
170 |
|
---|
171 | node(options: any): SourceNode;
|
---|
172 |
|
---|
173 | listMap(options: any): SourceListMap;
|
---|
174 |
|
---|
175 | _replacementToSourceNode(oldNode: SourceNode, newString: string): string | SourceNode;
|
---|
176 |
|
---|
177 | _splitSourceNode(node: SourceNode, position: SourceNode[]): SourceNode[];
|
---|
178 | _splitSourceNode(node: string, position: number): number;
|
---|
179 |
|
---|
180 | _splitString(str: string, position: number): string[];
|
---|
181 | }
|
---|
182 |
|
---|
183 | export class SourceMapSource extends Source implements SourceAndMapMixin {
|
---|
184 | _value: string;
|
---|
185 | _name: string;
|
---|
186 | _sourceMap: SourceMapGenerator | RawSourceMap;
|
---|
187 | _originalSource: string;
|
---|
188 | _innerSourceMap: RawSourceMap;
|
---|
189 |
|
---|
190 | constructor(
|
---|
191 | value: string,
|
---|
192 | name: string,
|
---|
193 | sourceMap: SourceMapGenerator | RawSourceMap,
|
---|
194 | originalSource?: string,
|
---|
195 | innerSourceMap?: RawSourceMap,
|
---|
196 | removeOriginalSource?: boolean,
|
---|
197 | );
|
---|
198 |
|
---|
199 | source(): string;
|
---|
200 |
|
---|
201 | node(): SourceNode;
|
---|
202 |
|
---|
203 | listMap(
|
---|
204 | options: {
|
---|
205 | module?: boolean | undefined;
|
---|
206 | }
|
---|
207 | ): SourceListMap;
|
---|
208 |
|
---|
209 | updateHash(hash: Hash): void;
|
---|
210 | }
|
---|