Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

magic-string

Package Overview
Dependencies
Maintainers
3
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

magic-string - npm Package Compare versions

Comparing version 0.25.1 to 0.25.2

LICENSE

5

CHANGELOG.md
# magic-string changelog
## 0.25.2
* Remove deprecated `new Buffer(...)`
* Handle characters outside Latin1 range when generating a sourcemap in browser ([#154](https://github.com/Rich-Harris/magic-string/issues/154))
## 0.25.1

@@ -4,0 +9,0 @@

87

dist/magic-string.cjs.js

@@ -164,5 +164,5 @@ 'use strict';

if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
btoa = window.btoa;
btoa = function (str) { return window.btoa(unescape(encodeURIComponent(str))); };
} else if (typeof Buffer === 'function') {
btoa = function (str) { return new Buffer(str).toString('base64'); };
btoa = function (str) { return Buffer.from(str, 'utf-8').toString('base64'); };
}

@@ -289,4 +289,2 @@

Mappings.prototype.addUneditedChunk = function addUneditedChunk (sourceIndex, chunk, original, loc, sourcemapLocations) {
var this$1 = this;
var originalCharIndex = chunk.start;

@@ -296,4 +294,4 @@ var first = true;

while (originalCharIndex < chunk.end) {
if (this$1.hires || first || sourcemapLocations[originalCharIndex]) {
this$1.rawSegments.push([this$1.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
if (this.hires || first || sourcemapLocations[originalCharIndex]) {
this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
}

@@ -304,8 +302,8 @@

loc.column = 0;
this$1.generatedCodeLine += 1;
this$1.raw[this$1.generatedCodeLine] = this$1.rawSegments = [];
this$1.generatedCodeColumn = 0;
this.generatedCodeLine += 1;
this.raw[this.generatedCodeLine] = this.rawSegments = [];
this.generatedCodeColumn = 0;
} else {
loc.column += 1;
this$1.generatedCodeColumn += 1;
this.generatedCodeColumn += 1;
}

@@ -321,4 +319,2 @@

Mappings.prototype.advance = function advance (str) {
var this$1 = this;
if (!str) { return; }

@@ -330,4 +326,4 @@

for (var i = 0; i < lines.length - 1; i++) {
this$1.generatedCodeLine++;
this$1.raw[this$1.generatedCodeLine] = this$1.rawSegments = [];
this.generatedCodeLine++;
this.raw[this.generatedCodeLine] = this.rawSegments = [];
}

@@ -502,4 +498,2 @@ this.generatedCodeColumn = 0;

MagicString.prototype.indent = function indent (indentStr, options) {
var this$1 = this;
var pattern = /^[^\r\n]/gm;

@@ -559,3 +553,3 @@

if (!isExcluded[charIndex]) {
var char = this$1.original[charIndex];
var char = this.original[charIndex];

@@ -570,3 +564,3 @@ if (char === '\n') {

} else {
this$1._splitChunk(chunk, charIndex);
this._splitChunk(chunk, charIndex);
chunk = chunk.next;

@@ -651,8 +645,6 @@ chunk.prependRight(indentStr);

MagicString.prototype.overwrite = function overwrite (start, end, content, options) {
var this$1 = this;
if (typeof content !== 'string') { throw new TypeError('replacement content must be a string'); }
while (start < 0) { start += this$1.original.length; }
while (end < 0) { end += this$1.original.length; }
while (start < 0) { start += this.original.length; }
while (end < 0) { end += this.original.length; }

@@ -750,7 +742,5 @@ if (end > this.original.length) { throw new Error('end is out of bounds'); }

MagicString.prototype.remove = function remove (start, end) {
var this$1 = this;
while (start < 0) { start += this.original.length; }
while (end < 0) { end += this.original.length; }
while (start < 0) { start += this$1.original.length; }
while (end < 0) { end += this$1.original.length; }
if (start === end) { return this; }

@@ -771,3 +761,3 @@

chunk = end > chunk.end ? this$1.byStart[chunk.end] : null;
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
}

@@ -829,8 +819,7 @@ return this;

MagicString.prototype.slice = function slice (start, end) {
var this$1 = this;
if ( start === void 0 ) start = 0;
if ( end === void 0 ) end = this.original.length;
while (start < 0) { start += this$1.original.length; }
while (end < 0) { end += this$1.original.length; }
while (start < 0) { start += this.original.length; }
while (end < 0) { end += this.original.length; }

@@ -892,4 +881,2 @@ var result = '';

MagicString.prototype._split = function _split (index) {
var this$1 = this;
if (this.byStart[index] || this.byEnd[index]) { return; }

@@ -901,5 +888,5 @@

while (chunk) {
if (chunk.contains(index)) { return this$1._splitChunk(chunk, index); }
if (chunk.contains(index)) { return this._splitChunk(chunk, index); }
chunk = searchForward ? this$1.byStart[chunk.end] : this$1.byEnd[chunk.start];
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
}

@@ -970,4 +957,2 @@ };

MagicString.prototype.trimEndAborted = function trimEndAborted (charType) {
var this$1 = this;
var rx = new RegExp((charType || '\\s') + '+$');

@@ -986,9 +971,9 @@

if (chunk.end !== end) {
if (this$1.lastChunk === chunk) {
this$1.lastChunk = chunk.next;
if (this.lastChunk === chunk) {
this.lastChunk = chunk.next;
}
this$1.byEnd[chunk.end] = chunk;
this$1.byStart[chunk.next.start] = chunk.next;
this$1.byEnd[chunk.next.end] = chunk.next;
this.byEnd[chunk.end] = chunk;
this.byStart[chunk.next.start] = chunk.next;
this.byEnd[chunk.next.end] = chunk.next;
}

@@ -1008,4 +993,2 @@

MagicString.prototype.trimStartAborted = function trimStartAborted (charType) {
var this$1 = this;
var rx = new RegExp('^' + (charType || '\\s') + '+');

@@ -1024,7 +1007,7 @@

// special case...
if (chunk === this$1.lastChunk) { this$1.lastChunk = chunk.next; }
if (chunk === this.lastChunk) { this.lastChunk = chunk.next; }
this$1.byEnd[chunk.end] = chunk;
this$1.byStart[chunk.next.start] = chunk.next;
this$1.byEnd[chunk.next.end] = chunk.next;
this.byEnd[chunk.end] = chunk;
this.byStart[chunk.next.start] = chunk.next;
this.byEnd[chunk.next.end] = chunk.next;
}

@@ -1295,4 +1278,2 @@

Bundle.prototype.trimStart = function trimStart (charType) {
var this$1 = this;
var rx = new RegExp('^' + (charType || '\\s') + '+');

@@ -1306,3 +1287,3 @@ this.intro = this.intro.replace(rx, '');

do {
source = this$1.sources[i++];
source = this.sources[i++];
if (!source) {

@@ -1318,4 +1299,2 @@ break;

Bundle.prototype.trimEnd = function trimEnd (charType) {
var this$1 = this;
var rx = new RegExp((charType || '\\s') + '+$');

@@ -1327,5 +1306,5 @@

do {
source = this$1.sources[i--];
source = this.sources[i--];
if (!source) {
this$1.intro = this$1.intro.replace(rx, '');
this.intro = this.intro.replace(rx, '');
break;

@@ -1332,0 +1311,0 @@ }

@@ -162,5 +162,5 @@ import { encode } from 'sourcemap-codec';

if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
btoa = window.btoa;
btoa = function (str) { return window.btoa(unescape(encodeURIComponent(str))); };
} else if (typeof Buffer === 'function') {
btoa = function (str) { return new Buffer(str).toString('base64'); };
btoa = function (str) { return Buffer.from(str, 'utf-8').toString('base64'); };
}

@@ -287,4 +287,2 @@

Mappings.prototype.addUneditedChunk = function addUneditedChunk (sourceIndex, chunk, original, loc, sourcemapLocations) {
var this$1 = this;
var originalCharIndex = chunk.start;

@@ -294,4 +292,4 @@ var first = true;

while (originalCharIndex < chunk.end) {
if (this$1.hires || first || sourcemapLocations[originalCharIndex]) {
this$1.rawSegments.push([this$1.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
if (this.hires || first || sourcemapLocations[originalCharIndex]) {
this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
}

@@ -302,8 +300,8 @@

loc.column = 0;
this$1.generatedCodeLine += 1;
this$1.raw[this$1.generatedCodeLine] = this$1.rawSegments = [];
this$1.generatedCodeColumn = 0;
this.generatedCodeLine += 1;
this.raw[this.generatedCodeLine] = this.rawSegments = [];
this.generatedCodeColumn = 0;
} else {
loc.column += 1;
this$1.generatedCodeColumn += 1;
this.generatedCodeColumn += 1;
}

@@ -319,4 +317,2 @@

Mappings.prototype.advance = function advance (str) {
var this$1 = this;
if (!str) { return; }

@@ -328,4 +324,4 @@

for (var i = 0; i < lines.length - 1; i++) {
this$1.generatedCodeLine++;
this$1.raw[this$1.generatedCodeLine] = this$1.rawSegments = [];
this.generatedCodeLine++;
this.raw[this.generatedCodeLine] = this.rawSegments = [];
}

@@ -500,4 +496,2 @@ this.generatedCodeColumn = 0;

MagicString.prototype.indent = function indent (indentStr, options) {
var this$1 = this;
var pattern = /^[^\r\n]/gm;

@@ -557,3 +551,3 @@

if (!isExcluded[charIndex]) {
var char = this$1.original[charIndex];
var char = this.original[charIndex];

@@ -568,3 +562,3 @@ if (char === '\n') {

} else {
this$1._splitChunk(chunk, charIndex);
this._splitChunk(chunk, charIndex);
chunk = chunk.next;

@@ -649,8 +643,6 @@ chunk.prependRight(indentStr);

MagicString.prototype.overwrite = function overwrite (start, end, content, options) {
var this$1 = this;
if (typeof content !== 'string') { throw new TypeError('replacement content must be a string'); }
while (start < 0) { start += this$1.original.length; }
while (end < 0) { end += this$1.original.length; }
while (start < 0) { start += this.original.length; }
while (end < 0) { end += this.original.length; }

@@ -748,7 +740,5 @@ if (end > this.original.length) { throw new Error('end is out of bounds'); }

MagicString.prototype.remove = function remove (start, end) {
var this$1 = this;
while (start < 0) { start += this.original.length; }
while (end < 0) { end += this.original.length; }
while (start < 0) { start += this$1.original.length; }
while (end < 0) { end += this$1.original.length; }
if (start === end) { return this; }

@@ -769,3 +759,3 @@

chunk = end > chunk.end ? this$1.byStart[chunk.end] : null;
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
}

@@ -827,8 +817,7 @@ return this;

MagicString.prototype.slice = function slice (start, end) {
var this$1 = this;
if ( start === void 0 ) start = 0;
if ( end === void 0 ) end = this.original.length;
while (start < 0) { start += this$1.original.length; }
while (end < 0) { end += this$1.original.length; }
while (start < 0) { start += this.original.length; }
while (end < 0) { end += this.original.length; }

@@ -890,4 +879,2 @@ var result = '';

MagicString.prototype._split = function _split (index) {
var this$1 = this;
if (this.byStart[index] || this.byEnd[index]) { return; }

@@ -899,5 +886,5 @@

while (chunk) {
if (chunk.contains(index)) { return this$1._splitChunk(chunk, index); }
if (chunk.contains(index)) { return this._splitChunk(chunk, index); }
chunk = searchForward ? this$1.byStart[chunk.end] : this$1.byEnd[chunk.start];
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
}

@@ -968,4 +955,2 @@ };

MagicString.prototype.trimEndAborted = function trimEndAborted (charType) {
var this$1 = this;
var rx = new RegExp((charType || '\\s') + '+$');

@@ -984,9 +969,9 @@

if (chunk.end !== end) {
if (this$1.lastChunk === chunk) {
this$1.lastChunk = chunk.next;
if (this.lastChunk === chunk) {
this.lastChunk = chunk.next;
}
this$1.byEnd[chunk.end] = chunk;
this$1.byStart[chunk.next.start] = chunk.next;
this$1.byEnd[chunk.next.end] = chunk.next;
this.byEnd[chunk.end] = chunk;
this.byStart[chunk.next.start] = chunk.next;
this.byEnd[chunk.next.end] = chunk.next;
}

@@ -1006,4 +991,2 @@

MagicString.prototype.trimStartAborted = function trimStartAborted (charType) {
var this$1 = this;
var rx = new RegExp('^' + (charType || '\\s') + '+');

@@ -1022,7 +1005,7 @@

// special case...
if (chunk === this$1.lastChunk) { this$1.lastChunk = chunk.next; }
if (chunk === this.lastChunk) { this.lastChunk = chunk.next; }
this$1.byEnd[chunk.end] = chunk;
this$1.byStart[chunk.next.start] = chunk.next;
this$1.byEnd[chunk.next.end] = chunk.next;
this.byEnd[chunk.end] = chunk;
this.byStart[chunk.next.start] = chunk.next;
this.byEnd[chunk.next.end] = chunk.next;
}

@@ -1293,4 +1276,2 @@

Bundle.prototype.trimStart = function trimStart (charType) {
var this$1 = this;
var rx = new RegExp('^' + (charType || '\\s') + '+');

@@ -1304,3 +1285,3 @@ this.intro = this.intro.replace(rx, '');

do {
source = this$1.sources[i++];
source = this.sources[i++];
if (!source) {

@@ -1316,4 +1297,2 @@ break;

Bundle.prototype.trimEnd = function trimEnd (charType) {
var this$1 = this;
var rx = new RegExp((charType || '\\s') + '+$');

@@ -1325,5 +1304,5 @@

do {
source = this$1.sources[i--];
source = this.sources[i--];
if (!source) {
this$1.intro = this$1.intro.replace(rx, '');
this.intro = this.intro.replace(rx, '');
break;

@@ -1330,0 +1309,0 @@ }

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.MagicString = factory());
}(this, (function () { 'use strict';
(global = global || self, global.MagicString = factory());
}(this, function () { 'use strict';

@@ -162,7 +162,3 @@ var Chunk = function Chunk(start, end, content) {

var charToInteger = {};
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
for (var i = 0; i < chars.length; i++) {
charToInteger[chars.charCodeAt(i)] = i;
}
function encode(decoded) {

@@ -223,5 +219,5 @@ var sourceFileIndex = 0; // second field

if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
btoa = window.btoa;
btoa = function (str) { return window.btoa(unescape(encodeURIComponent(str))); };
} else if (typeof Buffer === 'function') {
btoa = function (str) { return new Buffer(str).toString('base64'); };
btoa = function (str) { return Buffer.from(str, 'utf-8').toString('base64'); };
}

@@ -348,4 +344,2 @@

Mappings.prototype.addUneditedChunk = function addUneditedChunk (sourceIndex, chunk, original, loc, sourcemapLocations) {
var this$1 = this;
var originalCharIndex = chunk.start;

@@ -355,4 +349,4 @@ var first = true;

while (originalCharIndex < chunk.end) {
if (this$1.hires || first || sourcemapLocations[originalCharIndex]) {
this$1.rawSegments.push([this$1.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
if (this.hires || first || sourcemapLocations[originalCharIndex]) {
this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
}

@@ -363,8 +357,8 @@

loc.column = 0;
this$1.generatedCodeLine += 1;
this$1.raw[this$1.generatedCodeLine] = this$1.rawSegments = [];
this$1.generatedCodeColumn = 0;
this.generatedCodeLine += 1;
this.raw[this.generatedCodeLine] = this.rawSegments = [];
this.generatedCodeColumn = 0;
} else {
loc.column += 1;
this$1.generatedCodeColumn += 1;
this.generatedCodeColumn += 1;
}

@@ -380,4 +374,2 @@

Mappings.prototype.advance = function advance (str) {
var this$1 = this;
if (!str) { return; }

@@ -389,4 +381,4 @@

for (var i = 0; i < lines.length - 1; i++) {
this$1.generatedCodeLine++;
this$1.raw[this$1.generatedCodeLine] = this$1.rawSegments = [];
this.generatedCodeLine++;
this.raw[this.generatedCodeLine] = this.rawSegments = [];
}

@@ -561,4 +553,2 @@ this.generatedCodeColumn = 0;

MagicString.prototype.indent = function indent (indentStr, options) {
var this$1 = this;
var pattern = /^[^\r\n]/gm;

@@ -618,3 +608,3 @@

if (!isExcluded[charIndex]) {
var char = this$1.original[charIndex];
var char = this.original[charIndex];

@@ -629,3 +619,3 @@ if (char === '\n') {

} else {
this$1._splitChunk(chunk, charIndex);
this._splitChunk(chunk, charIndex);
chunk = chunk.next;

@@ -710,8 +700,6 @@ chunk.prependRight(indentStr);

MagicString.prototype.overwrite = function overwrite (start, end, content, options) {
var this$1 = this;
if (typeof content !== 'string') { throw new TypeError('replacement content must be a string'); }
while (start < 0) { start += this$1.original.length; }
while (end < 0) { end += this$1.original.length; }
while (start < 0) { start += this.original.length; }
while (end < 0) { end += this.original.length; }

@@ -809,7 +797,5 @@ if (end > this.original.length) { throw new Error('end is out of bounds'); }

MagicString.prototype.remove = function remove (start, end) {
var this$1 = this;
while (start < 0) { start += this.original.length; }
while (end < 0) { end += this.original.length; }
while (start < 0) { start += this$1.original.length; }
while (end < 0) { end += this$1.original.length; }
if (start === end) { return this; }

@@ -830,3 +816,3 @@

chunk = end > chunk.end ? this$1.byStart[chunk.end] : null;
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
}

@@ -888,8 +874,7 @@ return this;

MagicString.prototype.slice = function slice (start, end) {
var this$1 = this;
if ( start === void 0 ) start = 0;
if ( end === void 0 ) end = this.original.length;
while (start < 0) { start += this$1.original.length; }
while (end < 0) { end += this$1.original.length; }
while (start < 0) { start += this.original.length; }
while (end < 0) { end += this.original.length; }

@@ -951,4 +936,2 @@ var result = '';

MagicString.prototype._split = function _split (index) {
var this$1 = this;
if (this.byStart[index] || this.byEnd[index]) { return; }

@@ -960,5 +943,5 @@

while (chunk) {
if (chunk.contains(index)) { return this$1._splitChunk(chunk, index); }
if (chunk.contains(index)) { return this._splitChunk(chunk, index); }
chunk = searchForward ? this$1.byStart[chunk.end] : this$1.byEnd[chunk.start];
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
}

@@ -1029,4 +1012,2 @@ };

MagicString.prototype.trimEndAborted = function trimEndAborted (charType) {
var this$1 = this;
var rx = new RegExp((charType || '\\s') + '+$');

@@ -1045,9 +1026,9 @@

if (chunk.end !== end) {
if (this$1.lastChunk === chunk) {
this$1.lastChunk = chunk.next;
if (this.lastChunk === chunk) {
this.lastChunk = chunk.next;
}
this$1.byEnd[chunk.end] = chunk;
this$1.byStart[chunk.next.start] = chunk.next;
this$1.byEnd[chunk.next.end] = chunk.next;
this.byEnd[chunk.end] = chunk;
this.byStart[chunk.next.start] = chunk.next;
this.byEnd[chunk.next.end] = chunk.next;
}

@@ -1067,4 +1048,2 @@

MagicString.prototype.trimStartAborted = function trimStartAborted (charType) {
var this$1 = this;
var rx = new RegExp('^' + (charType || '\\s') + '+');

@@ -1083,7 +1062,7 @@

// special case...
if (chunk === this$1.lastChunk) { this$1.lastChunk = chunk.next; }
if (chunk === this.lastChunk) { this.lastChunk = chunk.next; }
this$1.byEnd[chunk.end] = chunk;
this$1.byStart[chunk.next.start] = chunk.next;
this$1.byEnd[chunk.next.end] = chunk.next;
this.byEnd[chunk.end] = chunk;
this.byStart[chunk.next.start] = chunk.next;
this.byEnd[chunk.next.end] = chunk.next;
}

@@ -1354,4 +1333,2 @@

Bundle.prototype.trimStart = function trimStart (charType) {
var this$1 = this;
var rx = new RegExp('^' + (charType || '\\s') + '+');

@@ -1365,3 +1342,3 @@ this.intro = this.intro.replace(rx, '');

do {
source = this$1.sources[i++];
source = this.sources[i++];
if (!source) {

@@ -1377,4 +1354,2 @@ break;

Bundle.prototype.trimEnd = function trimEnd (charType) {
var this$1 = this;
var rx = new RegExp((charType || '\\s') + '+$');

@@ -1386,5 +1361,5 @@

do {
source = this$1.sources[i--];
source = this.sources[i--];
if (!source) {
this$1.intro = this$1.intro.replace(rx, '');
this.intro = this.intro.replace(rx, '');
break;

@@ -1402,3 +1377,3 @@ }

})));
}));
//# sourceMappingURL=magic-string.umd.js.map

@@ -5,3 +5,3 @@ {

"author": "Rich Harris",
"version": "0.25.1",
"version": "0.25.2",
"repository": "https://github.com/rich-harris/magic-string",

@@ -14,15 +14,15 @@ "main": "dist/magic-string.cjs.js",

"dependencies": {
"sourcemap-codec": "^1.4.1"
"sourcemap-codec": "^1.4.4"
},
"devDependencies": {
"buble": "^0.19.3",
"eslint": "^4.19.0",
"mocha": "^5.0.4",
"prettier": "^1.11.1",
"rollup": "^0.57.1",
"rollup-plugin-buble": "^0.19.2",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-replace": "^2.0.0",
"buble": "^0.19.6",
"eslint": "^5.13.0",
"mocha": "^5.2.0",
"prettier": "^1.16.4",
"rollup": "^1.1.2",
"rollup-plugin-buble": "^0.19.6",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-replace": "^2.1.0",
"source-map": "^0.6.1",
"source-map-support": "^0.5.4"
"source-map-support": "^0.5.10"
},

@@ -29,0 +29,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc