Socket
Socket
Sign inDemoInstall

magic-string

Package Overview
Dependencies
1
Maintainers
3
Versions
114
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.25.3 to 0.25.4

4

CHANGELOG.md
# magic-string changelog
## 0.25.4
* Clone `intro` and `outro` ([#162](https://github.com/Rich-Harris/magic-string/issues/162))
## 0.25.3

@@ -4,0 +8,0 @@

86

dist/magic-string.cjs.js

@@ -288,2 +288,4 @@ 'use strict';

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

@@ -293,4 +295,4 @@ var first = true;

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

@@ -301,8 +303,8 @@

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

@@ -318,2 +320,4 @@

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

@@ -325,4 +329,4 @@

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

@@ -442,2 +446,5 @@ this.generatedCodeColumn = 0;

cloned.intro = this.intro;
cloned.outro = this.outro;
return cloned;

@@ -498,2 +505,4 @@ };

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

@@ -553,3 +562,3 @@

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

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

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

@@ -645,6 +654,8 @@ 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.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; }

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

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

@@ -761,3 +774,3 @@

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

@@ -819,7 +832,8 @@ 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.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; }

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

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

@@ -888,5 +904,5 @@

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

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

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

@@ -971,9 +989,9 @@

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

@@ -993,2 +1011,4 @@

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

@@ -1007,7 +1027,7 @@

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

@@ -1278,2 +1298,4 @@

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

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

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

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

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

@@ -1306,5 +1330,5 @@

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

@@ -1311,0 +1335,0 @@ }

@@ -286,2 +286,4 @@ import { encode } from 'sourcemap-codec';

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

@@ -291,4 +293,4 @@ var first = true;

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

@@ -299,8 +301,8 @@

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

@@ -316,2 +318,4 @@

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

@@ -323,4 +327,4 @@

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

@@ -440,2 +444,5 @@ this.generatedCodeColumn = 0;

cloned.intro = this.intro;
cloned.outro = this.outro;
return cloned;

@@ -496,2 +503,4 @@ };

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

@@ -551,3 +560,3 @@

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

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

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

@@ -643,6 +652,8 @@ 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.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; }

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

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

@@ -759,3 +772,3 @@

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

@@ -817,7 +830,8 @@ 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.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; }

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

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

@@ -886,5 +902,5 @@

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

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

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

@@ -969,9 +987,9 @@

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

@@ -991,2 +1009,4 @@

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

@@ -1005,7 +1025,7 @@

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

@@ -1276,2 +1296,4 @@

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

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

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

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

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

@@ -1304,5 +1328,5 @@

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

@@ -1309,0 +1333,0 @@ }

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

@@ -162,3 +162,7 @@ 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) {

@@ -343,2 +347,4 @@ var sourceFileIndex = 0; // second field

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

@@ -348,4 +354,4 @@ var first = true;

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

@@ -356,8 +362,8 @@

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

@@ -373,2 +379,4 @@

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

@@ -380,4 +388,4 @@

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

@@ -497,2 +505,5 @@ this.generatedCodeColumn = 0;

cloned.intro = this.intro;
cloned.outro = this.outro;
return cloned;

@@ -553,2 +564,4 @@ };

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

@@ -608,3 +621,3 @@

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

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

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

@@ -700,6 +713,8 @@ 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.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; }

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

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

@@ -816,3 +833,3 @@

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

@@ -874,7 +891,8 @@ 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.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; }

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

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

@@ -943,5 +963,5 @@

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

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

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

@@ -1026,9 +1048,9 @@

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

@@ -1048,2 +1070,4 @@

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

@@ -1062,7 +1086,7 @@

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

@@ -1333,2 +1357,4 @@

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

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

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

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

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

@@ -1361,5 +1389,5 @@

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

@@ -1377,3 +1405,3 @@ }

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

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

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

@@ -8,0 +8,0 @@ "main": "dist/magic-string.cjs.js",

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc