source: frontend/node_modules/@jridgewell/remapping/dist/remapping.mjs

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 4.7 KB
Line 
1// src/build-source-map-tree.ts
2import { TraceMap } from "@jridgewell/trace-mapping";
3
4// src/source-map-tree.ts
5import { GenMapping, maybeAddSegment, setIgnore, setSourceContent } from "@jridgewell/gen-mapping";
6import { traceSegment, decodedMappings } from "@jridgewell/trace-mapping";
7var SOURCELESS_MAPPING = /* @__PURE__ */ SegmentObject("", -1, -1, "", null, false);
8var EMPTY_SOURCES = [];
9function SegmentObject(source, line, column, name, content, ignore) {
10 return { source, line, column, name, content, ignore };
11}
12function Source(map, sources, source, content, ignore) {
13 return {
14 map,
15 sources,
16 source,
17 content,
18 ignore
19 };
20}
21function MapSource(map, sources) {
22 return Source(map, sources, "", null, false);
23}
24function OriginalSource(source, content, ignore) {
25 return Source(null, EMPTY_SOURCES, source, content, ignore);
26}
27function traceMappings(tree) {
28 const gen = new GenMapping({ file: tree.map.file });
29 const { sources: rootSources, map } = tree;
30 const rootNames = map.names;
31 const rootMappings = decodedMappings(map);
32 for (let i = 0; i < rootMappings.length; i++) {
33 const segments = rootMappings[i];
34 for (let j = 0; j < segments.length; j++) {
35 const segment = segments[j];
36 const genCol = segment[0];
37 let traced = SOURCELESS_MAPPING;
38 if (segment.length !== 1) {
39 const source2 = rootSources[segment[1]];
40 traced = originalPositionFor(
41 source2,
42 segment[2],
43 segment[3],
44 segment.length === 5 ? rootNames[segment[4]] : ""
45 );
46 if (traced == null) continue;
47 }
48 const { column, line, name, content, source, ignore } = traced;
49 maybeAddSegment(gen, i, genCol, source, line, column, name);
50 if (source && content != null) setSourceContent(gen, source, content);
51 if (ignore) setIgnore(gen, source, true);
52 }
53 }
54 return gen;
55}
56function originalPositionFor(source, line, column, name) {
57 if (!source.map) {
58 return SegmentObject(source.source, line, column, name, source.content, source.ignore);
59 }
60 const segment = traceSegment(source.map, line, column);
61 if (segment == null) return null;
62 if (segment.length === 1) return SOURCELESS_MAPPING;
63 return originalPositionFor(
64 source.sources[segment[1]],
65 segment[2],
66 segment[3],
67 segment.length === 5 ? source.map.names[segment[4]] : name
68 );
69}
70
71// src/build-source-map-tree.ts
72function asArray(value) {
73 if (Array.isArray(value)) return value;
74 return [value];
75}
76function buildSourceMapTree(input, loader) {
77 const maps = asArray(input).map((m) => new TraceMap(m, ""));
78 const map = maps.pop();
79 for (let i = 0; i < maps.length; i++) {
80 if (maps[i].sources.length > 1) {
81 throw new Error(
82 `Transformation map ${i} must have exactly one source file.
83Did you specify these with the most recent transformation maps first?`
84 );
85 }
86 }
87 let tree = build(map, loader, "", 0);
88 for (let i = maps.length - 1; i >= 0; i--) {
89 tree = MapSource(maps[i], [tree]);
90 }
91 return tree;
92}
93function build(map, loader, importer, importerDepth) {
94 const { resolvedSources, sourcesContent, ignoreList } = map;
95 const depth = importerDepth + 1;
96 const children = resolvedSources.map((sourceFile, i) => {
97 const ctx = {
98 importer,
99 depth,
100 source: sourceFile || "",
101 content: void 0,
102 ignore: void 0
103 };
104 const sourceMap = loader(ctx.source, ctx);
105 const { source, content, ignore } = ctx;
106 if (sourceMap) return build(new TraceMap(sourceMap, source), loader, source, depth);
107 const sourceContent = content !== void 0 ? content : sourcesContent ? sourcesContent[i] : null;
108 const ignored = ignore !== void 0 ? ignore : ignoreList ? ignoreList.includes(i) : false;
109 return OriginalSource(source, sourceContent, ignored);
110 });
111 return MapSource(map, children);
112}
113
114// src/source-map.ts
115import { toDecodedMap, toEncodedMap } from "@jridgewell/gen-mapping";
116var SourceMap = class {
117 constructor(map, options) {
118 const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map);
119 this.version = out.version;
120 this.file = out.file;
121 this.mappings = out.mappings;
122 this.names = out.names;
123 this.ignoreList = out.ignoreList;
124 this.sourceRoot = out.sourceRoot;
125 this.sources = out.sources;
126 if (!options.excludeContent) {
127 this.sourcesContent = out.sourcesContent;
128 }
129 }
130 toString() {
131 return JSON.stringify(this);
132 }
133};
134
135// src/remapping.ts
136function remapping(input, loader, options) {
137 const opts = typeof options === "object" ? options : { excludeContent: !!options, decodedMappings: false };
138 const tree = buildSourceMapTree(input, loader);
139 return new SourceMap(traceMappings(tree), opts);
140}
141export {
142 remapping as default
143};
144//# sourceMappingURL=remapping.mjs.map
Note: See TracBrowser for help on using the repository browser.