-
Notifications
You must be signed in to change notification settings - Fork 481
Expand file tree
/
Copy pathsource-map-worker-types.ts
More file actions
70 lines (64 loc) · 2.71 KB
/
Copy pathsource-map-worker-types.ts
File metadata and controls
70 lines (64 loc) · 2.71 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
/* 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/. */
import type {
IndexIntoFuncTable,
IndexIntoFrameTable,
IndexIntoSourceTable,
} from 'firefox-profiler/types';
import type { RawSourceMap } from 'source-map';
import type { SourceMapSymbolicationInput } from './source-map-symbolication';
/**
* Data sent from the main thread to the source map symbolication worker.
* All values are structured-cloned (copied) across the thread boundary.
*/
export type WorkerInput = SourceMapSymbolicationInput & {
resolvedSourceMaps: Map<IndexIntoSourceTable, RawSourceMap>;
// Compiled source texts keyed by bundle source index.
compiledSources: Map<IndexIntoSourceTable, string>;
};
/**
* Resolved original location for a single frame. Line/column are 1-based
* (Gecko convention). `originalSource` is a URL string; the apply step on
* the main thread looks it up against the current sources table.
*/
export type FrameResolution = {
originalSource: string;
originalLine: number;
originalColumn: number;
};
/**
* Resolved original location plus optional function name for a single func.
* `name` is null when no name could be determined, in which case the existing
* funcTable.name entry is kept.
*/
export type FuncResolution = FrameResolution & {
name: string | null;
};
/**
* Opaque, position-keyed worker result. The apply step on the main thread
* (applySourceMapSymbolicationResponse) consumes this plus the current shared
* tables to produce new ones.
*
* Modeled like a symbolication API response: the worker doesn't allocate
* source-table or originalLocation indices, and doesn't intern strings. That
* bookkeeping happens main-side against the latest state, so concurrent
* worker runs compose correctly instead of one's stale snapshot stomping
* another's result.
*/
export type SourceMapSymbolicationResponse = {
// Funcs the worker resolved. Funcs not in this map keep their existing data.
// JS source-map symbolication never adds funcs, so funcIndex stays stable
// across concurrent runs.
funcResults: Map<IndexIntoFuncTable, FuncResolution>;
// Same idea for frames.
frameResults: Map<IndexIntoFrameTable, FrameResolution>;
// Original sources discovered during symbolication, keyed by URL. content
// is null when the source map didn't carry sourcesContent for this URL.
// The apply step dedupes URLs against the current sources table.
originalSources: Map<string, { content: string | null }>;
};
export type WorkerOutput =
| { type: 'success'; response: SourceMapSymbolicationResponse }
| { type: 'no-op' }
| { type: 'error'; message: string };