Blame view

天文台pc/tianwentai-ui/node_modules/@jridgewell/remapping/src/source-map.ts 1.33 KB
bc518174   王天杨   提交两个项目文件
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
  import { toDecodedMap, toEncodedMap } from '@jridgewell/gen-mapping';
  
  import type { GenMapping } from '@jridgewell/gen-mapping';
  import type { DecodedSourceMap, EncodedSourceMap, Options } from './types';
  
  /**
   * A SourceMap v3 compatible sourcemap, which only includes fields that were
   * provided to it.
   */
  export default class SourceMap {
    declare file?: string | null;
    declare mappings: EncodedSourceMap['mappings'] | DecodedSourceMap['mappings'];
    declare sourceRoot?: string;
    declare names: string[];
    declare sources: (string | null)[];
    declare sourcesContent?: (string | null)[];
    declare version: 3;
    declare ignoreList: number[] | undefined;
  
    constructor(map: GenMapping, options: Options) {
      const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map);
      this.version = out.version; // SourceMap spec says this should be first.
      this.file = out.file;
      this.mappings = out.mappings as SourceMap['mappings'];
      this.names = out.names as SourceMap['names'];
      this.ignoreList = out.ignoreList as SourceMap['ignoreList'];
      this.sourceRoot = out.sourceRoot;
  
      this.sources = out.sources as SourceMap['sources'];
      if (!options.excludeContent) {
        this.sourcesContent = out.sourcesContent as SourceMap['sourcesContent'];
      }
    }
  
    toString(): string {
      return JSON.stringify(this);
    }
  }