| 1 | (function (global, factory) {
|
|---|
| 2 | if (typeof exports === 'object' && typeof module !== 'undefined') {
|
|---|
| 3 | factory(module, require('@jridgewell/gen-mapping'), require('@jridgewell/trace-mapping'));
|
|---|
| 4 | module.exports = def(module);
|
|---|
| 5 | } else if (typeof define === 'function' && define.amd) {
|
|---|
| 6 | define(['module', '@jridgewell/gen-mapping', '@jridgewell/trace-mapping'], function(mod) {
|
|---|
| 7 | factory.apply(this, arguments);
|
|---|
| 8 | mod.exports = def(mod);
|
|---|
| 9 | });
|
|---|
| 10 | } else {
|
|---|
| 11 | const mod = { exports: {} };
|
|---|
| 12 | factory(mod, global.genMapping, global.traceMapping);
|
|---|
| 13 | global = typeof globalThis !== 'undefined' ? globalThis : global || self;
|
|---|
| 14 | global.remapping = def(mod);
|
|---|
| 15 | }
|
|---|
| 16 | function def(m) { return 'default' in m.exports ? m.exports.default : m.exports; }
|
|---|
| 17 | })(this, (function (module, require_genMapping, require_traceMapping) {
|
|---|
| 18 | "use strict";
|
|---|
| 19 | var __create = Object.create;
|
|---|
| 20 | var __defProp = Object.defineProperty;
|
|---|
| 21 | var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|---|
| 22 | var __getOwnPropNames = Object.getOwnPropertyNames;
|
|---|
| 23 | var __getProtoOf = Object.getPrototypeOf;
|
|---|
| 24 | var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|---|
| 25 | var __commonJS = (cb, mod) => function __require() {
|
|---|
| 26 | return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|---|
| 27 | };
|
|---|
| 28 | var __export = (target, all) => {
|
|---|
| 29 | for (var name in all)
|
|---|
| 30 | __defProp(target, name, { get: all[name], enumerable: true });
|
|---|
| 31 | };
|
|---|
| 32 | var __copyProps = (to, from, except, desc) => {
|
|---|
| 33 | if (from && typeof from === "object" || typeof from === "function") {
|
|---|
| 34 | for (let key of __getOwnPropNames(from))
|
|---|
| 35 | if (!__hasOwnProp.call(to, key) && key !== except)
|
|---|
| 36 | __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|---|
| 37 | }
|
|---|
| 38 | return to;
|
|---|
| 39 | };
|
|---|
| 40 | var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|---|
| 41 | // If the importer is in node compatibility mode or this is not an ESM
|
|---|
| 42 | // file that has been converted to a CommonJS file using a Babel-
|
|---|
| 43 | // compatible transform (i.e. "__esModule" has not been set), then set
|
|---|
| 44 | // "default" to the CommonJS "module.exports" for node compatibility.
|
|---|
| 45 | isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|---|
| 46 | mod
|
|---|
| 47 | ));
|
|---|
| 48 | var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|---|
| 49 |
|
|---|
| 50 | // umd:@jridgewell/trace-mapping
|
|---|
| 51 | var require_trace_mapping = __commonJS({
|
|---|
| 52 | "umd:@jridgewell/trace-mapping"(exports, module2) {
|
|---|
| 53 | module2.exports = require_traceMapping;
|
|---|
| 54 | }
|
|---|
| 55 | });
|
|---|
| 56 |
|
|---|
| 57 | // umd:@jridgewell/gen-mapping
|
|---|
| 58 | var require_gen_mapping = __commonJS({
|
|---|
| 59 | "umd:@jridgewell/gen-mapping"(exports, module2) {
|
|---|
| 60 | module2.exports = require_genMapping;
|
|---|
| 61 | }
|
|---|
| 62 | });
|
|---|
| 63 |
|
|---|
| 64 | // src/remapping.ts
|
|---|
| 65 | var remapping_exports = {};
|
|---|
| 66 | __export(remapping_exports, {
|
|---|
| 67 | default: () => remapping
|
|---|
| 68 | });
|
|---|
| 69 | module.exports = __toCommonJS(remapping_exports);
|
|---|
| 70 |
|
|---|
| 71 | // src/build-source-map-tree.ts
|
|---|
| 72 | var import_trace_mapping2 = __toESM(require_trace_mapping());
|
|---|
| 73 |
|
|---|
| 74 | // src/source-map-tree.ts
|
|---|
| 75 | var import_gen_mapping = __toESM(require_gen_mapping());
|
|---|
| 76 | var import_trace_mapping = __toESM(require_trace_mapping());
|
|---|
| 77 | var SOURCELESS_MAPPING = /* @__PURE__ */ SegmentObject("", -1, -1, "", null, false);
|
|---|
| 78 | var EMPTY_SOURCES = [];
|
|---|
| 79 | function SegmentObject(source, line, column, name, content, ignore) {
|
|---|
| 80 | return { source, line, column, name, content, ignore };
|
|---|
| 81 | }
|
|---|
| 82 | function Source(map, sources, source, content, ignore) {
|
|---|
| 83 | return {
|
|---|
| 84 | map,
|
|---|
| 85 | sources,
|
|---|
| 86 | source,
|
|---|
| 87 | content,
|
|---|
| 88 | ignore
|
|---|
| 89 | };
|
|---|
| 90 | }
|
|---|
| 91 | function MapSource(map, sources) {
|
|---|
| 92 | return Source(map, sources, "", null, false);
|
|---|
| 93 | }
|
|---|
| 94 | function OriginalSource(source, content, ignore) {
|
|---|
| 95 | return Source(null, EMPTY_SOURCES, source, content, ignore);
|
|---|
| 96 | }
|
|---|
| 97 | function traceMappings(tree) {
|
|---|
| 98 | const gen = new import_gen_mapping.GenMapping({ file: tree.map.file });
|
|---|
| 99 | const { sources: rootSources, map } = tree;
|
|---|
| 100 | const rootNames = map.names;
|
|---|
| 101 | const rootMappings = (0, import_trace_mapping.decodedMappings)(map);
|
|---|
| 102 | for (let i = 0; i < rootMappings.length; i++) {
|
|---|
| 103 | const segments = rootMappings[i];
|
|---|
| 104 | for (let j = 0; j < segments.length; j++) {
|
|---|
| 105 | const segment = segments[j];
|
|---|
| 106 | const genCol = segment[0];
|
|---|
| 107 | let traced = SOURCELESS_MAPPING;
|
|---|
| 108 | if (segment.length !== 1) {
|
|---|
| 109 | const source2 = rootSources[segment[1]];
|
|---|
| 110 | traced = originalPositionFor(
|
|---|
| 111 | source2,
|
|---|
| 112 | segment[2],
|
|---|
| 113 | segment[3],
|
|---|
| 114 | segment.length === 5 ? rootNames[segment[4]] : ""
|
|---|
| 115 | );
|
|---|
| 116 | if (traced == null) continue;
|
|---|
| 117 | }
|
|---|
| 118 | const { column, line, name, content, source, ignore } = traced;
|
|---|
| 119 | (0, import_gen_mapping.maybeAddSegment)(gen, i, genCol, source, line, column, name);
|
|---|
| 120 | if (source && content != null) (0, import_gen_mapping.setSourceContent)(gen, source, content);
|
|---|
| 121 | if (ignore) (0, import_gen_mapping.setIgnore)(gen, source, true);
|
|---|
| 122 | }
|
|---|
| 123 | }
|
|---|
| 124 | return gen;
|
|---|
| 125 | }
|
|---|
| 126 | function originalPositionFor(source, line, column, name) {
|
|---|
| 127 | if (!source.map) {
|
|---|
| 128 | return SegmentObject(source.source, line, column, name, source.content, source.ignore);
|
|---|
| 129 | }
|
|---|
| 130 | const segment = (0, import_trace_mapping.traceSegment)(source.map, line, column);
|
|---|
| 131 | if (segment == null) return null;
|
|---|
| 132 | if (segment.length === 1) return SOURCELESS_MAPPING;
|
|---|
| 133 | return originalPositionFor(
|
|---|
| 134 | source.sources[segment[1]],
|
|---|
| 135 | segment[2],
|
|---|
| 136 | segment[3],
|
|---|
| 137 | segment.length === 5 ? source.map.names[segment[4]] : name
|
|---|
| 138 | );
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | // src/build-source-map-tree.ts
|
|---|
| 142 | function asArray(value) {
|
|---|
| 143 | if (Array.isArray(value)) return value;
|
|---|
| 144 | return [value];
|
|---|
| 145 | }
|
|---|
| 146 | function buildSourceMapTree(input, loader) {
|
|---|
| 147 | const maps = asArray(input).map((m) => new import_trace_mapping2.TraceMap(m, ""));
|
|---|
| 148 | const map = maps.pop();
|
|---|
| 149 | for (let i = 0; i < maps.length; i++) {
|
|---|
| 150 | if (maps[i].sources.length > 1) {
|
|---|
| 151 | throw new Error(
|
|---|
| 152 | `Transformation map ${i} must have exactly one source file.
|
|---|
| 153 | Did you specify these with the most recent transformation maps first?`
|
|---|
| 154 | );
|
|---|
| 155 | }
|
|---|
| 156 | }
|
|---|
| 157 | let tree = build(map, loader, "", 0);
|
|---|
| 158 | for (let i = maps.length - 1; i >= 0; i--) {
|
|---|
| 159 | tree = MapSource(maps[i], [tree]);
|
|---|
| 160 | }
|
|---|
| 161 | return tree;
|
|---|
| 162 | }
|
|---|
| 163 | function build(map, loader, importer, importerDepth) {
|
|---|
| 164 | const { resolvedSources, sourcesContent, ignoreList } = map;
|
|---|
| 165 | const depth = importerDepth + 1;
|
|---|
| 166 | const children = resolvedSources.map((sourceFile, i) => {
|
|---|
| 167 | const ctx = {
|
|---|
| 168 | importer,
|
|---|
| 169 | depth,
|
|---|
| 170 | source: sourceFile || "",
|
|---|
| 171 | content: void 0,
|
|---|
| 172 | ignore: void 0
|
|---|
| 173 | };
|
|---|
| 174 | const sourceMap = loader(ctx.source, ctx);
|
|---|
| 175 | const { source, content, ignore } = ctx;
|
|---|
| 176 | if (sourceMap) return build(new import_trace_mapping2.TraceMap(sourceMap, source), loader, source, depth);
|
|---|
| 177 | const sourceContent = content !== void 0 ? content : sourcesContent ? sourcesContent[i] : null;
|
|---|
| 178 | const ignored = ignore !== void 0 ? ignore : ignoreList ? ignoreList.includes(i) : false;
|
|---|
| 179 | return OriginalSource(source, sourceContent, ignored);
|
|---|
| 180 | });
|
|---|
| 181 | return MapSource(map, children);
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | // src/source-map.ts
|
|---|
| 185 | var import_gen_mapping2 = __toESM(require_gen_mapping());
|
|---|
| 186 | var SourceMap = class {
|
|---|
| 187 | constructor(map, options) {
|
|---|
| 188 | const out = options.decodedMappings ? (0, import_gen_mapping2.toDecodedMap)(map) : (0, import_gen_mapping2.toEncodedMap)(map);
|
|---|
| 189 | this.version = out.version;
|
|---|
| 190 | this.file = out.file;
|
|---|
| 191 | this.mappings = out.mappings;
|
|---|
| 192 | this.names = out.names;
|
|---|
| 193 | this.ignoreList = out.ignoreList;
|
|---|
| 194 | this.sourceRoot = out.sourceRoot;
|
|---|
| 195 | this.sources = out.sources;
|
|---|
| 196 | if (!options.excludeContent) {
|
|---|
| 197 | this.sourcesContent = out.sourcesContent;
|
|---|
| 198 | }
|
|---|
| 199 | }
|
|---|
| 200 | toString() {
|
|---|
| 201 | return JSON.stringify(this);
|
|---|
| 202 | }
|
|---|
| 203 | };
|
|---|
| 204 |
|
|---|
| 205 | // src/remapping.ts
|
|---|
| 206 | function remapping(input, loader, options) {
|
|---|
| 207 | const opts = typeof options === "object" ? options : { excludeContent: !!options, decodedMappings: false };
|
|---|
| 208 | const tree = buildSourceMapTree(input, loader);
|
|---|
| 209 | return new SourceMap(traceMappings(tree), opts);
|
|---|
| 210 | }
|
|---|
| 211 | }));
|
|---|
| 212 | //# sourceMappingURL=remapping.umd.js.map
|
|---|