UNPKG

2.74 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/source-list-map`
3
4# Summary
5This package contains type definitions for source-list-map (https://github.com/webpack/source-list-map.git).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/source-list-map.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/source-list-map/index.d.ts)
10````ts
11export class CodeNode {
12 generatedCode: string;
13
14 constructor(generatedCode: string);
15
16 clone(): CodeNode;
17
18 getGeneratedCode(): string;
19
20 getMappings(mappingsContext?: MappingsContext): string;
21
22 addGeneratedCode(generatedCode: string): void;
23
24 mapGeneratedCode(fn: (code: string) => string): void;
25}
26
27export class MappingsContext {
28 sources: string[];
29 sourcesContent: string[];
30 hasSourceContent: boolean;
31 currentOriginalLine: number;
32 currentSource: number;
33
34 constructor();
35
36 ensureSource(source: string, originalSource: string): number;
37}
38
39export class SourceNode {
40 generatedCode: string;
41 source: string;
42 originalSource: string;
43 startingLine: number;
44
45 constructor(generatedCode: string, source: string, originalSource: string, startingLine?: number);
46
47 clone(): SourceNode;
48
49 getGeneratedCode(): string;
50
51 getMappings(mappingsContext: MappingsContext): string;
52
53 mapGeneratedCode(fn: (code: string) => string): void;
54}
55
56export class SourceListMap {
57 children: Array<SourceNode | CodeNode>;
58
59 constructor(generatedCode: Array<SourceNode | CodeNode>);
60 constructor(
61 generatedCode?: string | SourceNode | CodeNode | SourceListMap,
62 source?: string,
63 originalSource?: string,
64 );
65
66 add(
67 generatedCode: string | CodeNode | SourceNode | SourceListMap,
68 source?: string,
69 originalSource?: string,
70 ): void;
71
72 prepend(generatedCode: SourceListMap | SourceNode | CodeNode, source?: string, originalSource?: string): void;
73
74 mapGeneratedCode(fn: (code: string) => string): void;
75
76 toString(): string;
77
78 toStringWithSourceMap(options: { file: any }): {
79 source: string;
80 map: {
81 version: number;
82 file: any;
83 sources: string[];
84 sourcesContent: string[];
85 mappings: string;
86 };
87 };
88}
89
90export function fromStringWithSourceMap(
91 code: string,
92 map: {
93 sources: Array<string | SourceNode | CodeNode>;
94 sourcesContent: string[];
95 mappings: string;
96 },
97): SourceListMap;
98
99````
100
101### Additional Details
102 * Last updated: Mon, 20 Nov 2023 23:36:24 GMT
103 * Dependencies: none
104
105# Credits
106These definitions were written by [e-cloud](https://github.com/e-cloud).
107
\No newline at end of file