forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
159 lines (133 loc) · 4.28 KB
/
Copy pathindex.js
File metadata and controls
159 lines (133 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// @flow
const {
workerUtils: { WorkerDispatcher }
} = require("devtools-utils");
import type { SourceLocation, Source, SourceId } from "../../../src/types";
import type { SourceMapConsumer } from "source-map";
import type { locationOptions } from "./source-map";
export const dispatcher = new WorkerDispatcher();
const _getGeneratedRanges = dispatcher.task("getGeneratedRanges", {
queue: true
});
const _getGeneratedLocation = dispatcher.task("getGeneratedLocation", {
queue: true
});
const _getAllGeneratedLocations = dispatcher.task("getAllGeneratedLocations", {
queue: true
});
const _getOriginalLocation = dispatcher.task("getOriginalLocation", {
queue: true
});
export const setAssetRootURL = async (assetRoot: string): Promise<void> =>
dispatcher.invoke("setAssetRootURL", assetRoot);
export const getOriginalURLs = async (
generatedSource: Source
): Promise<SourceMapConsumer> =>
dispatcher.invoke("getOriginalURLs", generatedSource);
export const hasOriginalURL = async (url: string): Promise<boolean> =>
dispatcher.invoke("hasOriginalURL", url);
export const getOriginalRanges = async (
sourceId: SourceId,
url: string
): Promise<
Array<{
line: number,
columnStart: number,
columnEnd: number
}>
> => dispatcher.invoke("getOriginalRanges", sourceId, url);
export const getGeneratedRanges = async (
location: SourceLocation,
originalSource: Source
): Promise<
Array<{
line: number,
columnStart: number,
columnEnd: number
}>
> => _getGeneratedRanges(location, originalSource);
export const getGeneratedLocation = async (
location: SourceLocation,
originalSource: Source
): Promise<SourceLocation> => _getGeneratedLocation(location, originalSource);
export const getAllGeneratedLocations = async (
location: SourceLocation,
originalSource: Source
): Promise<Array<SourceLocation>> =>
_getAllGeneratedLocations(location, originalSource);
export const getOriginalLocation = async (
location: SourceLocation,
options: locationOptions = {}
): Promise<SourceLocation> => _getOriginalLocation(location, options);
export const getOriginalLocations = async (
locations: SourceLocation[],
options: locationOptions = {}
): Promise<SourceLocation[]> =>
dispatcher.invoke("getOriginalLocations", locations, options);
export const getGeneratedRangesForOriginal = async (
sourceId: SourceId,
url: string,
mergeUnmappedRegions?: boolean
): Promise<
Array<{
start: {
line: number,
column: number
},
end: {
line: number,
column: number
}
}>
> =>
dispatcher.invoke(
"getGeneratedRangesForOriginal",
sourceId,
url,
mergeUnmappedRegions
);
export const getFileGeneratedRange = async (
originalSource: Source
): Promise<?{ start: any, end: any }> =>
dispatcher.invoke("getFileGeneratedRange", originalSource);
export const getLocationScopes = dispatcher.task("getLocationScopes");
export const getOriginalSourceText = async (
originalSource: Source
): Promise<?{
text: string,
contentType: string
}> => dispatcher.invoke("getOriginalSourceText", originalSource);
export const applySourceMap = async (
generatedId: string,
url: string,
code: string,
mappings: Object
): Promise<void> =>
dispatcher.invoke("applySourceMap", generatedId, url, code, mappings);
export const clearSourceMaps = async (): Promise<void> =>
dispatcher.invoke("clearSourceMaps");
export const hasMappedSource = async (
location: SourceLocation
): Promise<boolean> => dispatcher.invoke("hasMappedSource", location);
export const getOriginalStackFrames = async (
generatedLocation: SourceLocation
): Promise<?Array<{
displayName: string,
location?: SourceLocation
}>> => dispatcher.invoke("getOriginalStackFrames", generatedLocation);
export {
originalToGeneratedId,
generatedToOriginalId,
isGeneratedId,
isOriginalId
} from "./utils";
export const startSourceMapWorker = (url: string, assetRoot: string) => {
dispatcher.start(url);
setAssetRootURL(assetRoot);
};
export const stopSourceMapWorker = dispatcher.stop.bind(dispatcher);
import * as self from "devtools-source-map";
export default self;