Sha256: 94644b0dbd0e1b5d6d8eca6d61f2015245ab99e56690fc4826d4074d52c3f0a4

Contents?: true

Size: 1.96 KB

Versions: 10

Compression:

Stored size: 1.96 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

function _sourceMap() {
  const data = _interopRequireDefault(require("source-map"));

  _sourceMap = function () {
    return data;
  };

  return data;
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

class SourceMap {
  constructor(opts, code) {
    this._cachedMap = null;
    this._code = code;
    this._opts = opts;
    this._rawMappings = [];
  }

  get() {
    if (!this._cachedMap) {
      const map = this._cachedMap = new (_sourceMap().default.SourceMapGenerator)({
        sourceRoot: this._opts.sourceRoot
      });
      const code = this._code;

      if (typeof code === "string") {
        map.setSourceContent(this._opts.sourceFileName, code);
      } else if (typeof code === "object") {
        Object.keys(code).forEach(sourceFileName => {
          map.setSourceContent(sourceFileName, code[sourceFileName]);
        });
      }

      this._rawMappings.forEach(map.addMapping, map);
    }

    return this._cachedMap.toJSON();
  }

  getRawMappings() {
    return this._rawMappings.slice();
  }

  mark(generatedLine, generatedColumn, line, column, identifierName, filename, force) {
    if (this._lastGenLine !== generatedLine && line === null) return;

    if (!force && this._lastGenLine === generatedLine && this._lastSourceLine === line && this._lastSourceColumn === column) {
      return;
    }

    this._cachedMap = null;
    this._lastGenLine = generatedLine;
    this._lastSourceLine = line;
    this._lastSourceColumn = column;

    this._rawMappings.push({
      name: identifierName || undefined,
      generated: {
        line: generatedLine,
        column: generatedColumn
      },
      source: line == null ? undefined : filename || this._opts.sourceFileName,
      original: line == null ? undefined : {
        line: line,
        column: column
      }
    });
  }

}

exports.default = SourceMap;

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
condenser-0.0.8 lib/condenser/processors/node_modules/@babel/generator/lib/source-map.js
jester-data-8.0.0 node_modules/@babel/generator/lib/source-map.js
ezii-os-5.2.1 node_modules/@babel/generator/lib/source-map.js
ezii-os-2.0.1 node_modules/@babel/generator/lib/source-map.js
ezii-os-1.1.0 node_modules/@babel/generator/lib/source-map.js
ezii-os-1.0.0 node_modules/@babel/generator/lib/source-map.js
condenser-0.0.7 lib/condenser/processors/node_modules/@babel/generator/lib/source-map.js
ezii-os-0.0.0.1.0 node_modules/@babel/generator/lib/source-map.js
ezii-os-0.0.0.0.1 node_modules/@babel/generator/lib/source-map.js
condenser-0.0.5 lib/condenser/processors/node_modules/@babel/generator/lib/source-map.js