🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

magic-string

Package Overview
Dependencies
Maintainers
4
Versions
126
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
1.0.0
to
1.1.0
+1
-2
dist/index.d.mts

@@ -272,3 +272,2 @@ //#region src/SourceMap.d.ts

//#endregion
export { Bundle, type BundleOptions, type DecodedSourceMap, type ExclusionRange, type IndentOptions, MagicString, MagicString as default, type MagicStringOptions, type OverwriteOptions, type ReplacementFunction, SourceMap, type SourceMapOptions, type SourceMapSegment, type UpdateOptions };
//# sourceMappingURL=index.d.mts.map
export { Bundle, type BundleOptions, type DecodedSourceMap, type ExclusionRange, type IndentOptions, MagicString, MagicString as default, type MagicStringOptions, type OverwriteOptions, type ReplacementFunction, SourceMap, type SourceMapOptions, type SourceMapSegment, type UpdateOptions };

@@ -115,6 +115,4 @@ import { encode } from "@jridgewell/sourcemap-codec";

if (trimmed.length) {
if (trimmed !== this.content) {
this.split(this.start + trimmed.length).edit("", void 0, true);
if (this.edited) this.edit(trimmed, this.storeName, true);
}
if (trimmed !== this.content) if (this.edited) this.edit(trimmed, this.storeName, true);
else this.split(this.start + trimmed.length).edit("", void 0, true);
return true;

@@ -132,5 +130,5 @@ } else {

if (trimmed.length) {
if (trimmed !== this.content) {
const newChunk = this.split(this.end - trimmed.length);
if (this.edited) newChunk.edit(trimmed, this.storeName, true);
if (trimmed !== this.content) if (this.edited) this.edit(trimmed, this.storeName, true);
else {
this.split(this.end - trimmed.length);
this.edit("", void 0, true);

@@ -417,4 +415,4 @@ }

});
this.byStart[0] = chunk;
this.byEnd[string.length] = chunk;
this.byStart = /* @__PURE__ */ new Map([[0, chunk]]);
this.byEnd = /* @__PURE__ */ new Map([[string.length, chunk]]);
}

@@ -444,3 +442,3 @@ /**

this._split(index);
const chunk = this.byEnd[index];
const chunk = this.byEnd.get(index);
if (chunk) chunk.appendLeft(content);

@@ -459,3 +457,3 @@ else this.intro += content;

this._split(index);
const chunk = this.byStart[index];
const chunk = this.byStart.get(index);
if (chunk) chunk.appendRight(content);

@@ -476,4 +474,4 @@ else this.outro += content;

while (originalChunk) {
cloned.byStart[clonedChunk.start] = clonedChunk;
cloned.byEnd[clonedChunk.end] = clonedChunk;
cloned.byStart.set(clonedChunk.start, clonedChunk);
cloned.byEnd.set(clonedChunk.end, clonedChunk);
const nextOriginalChunk = originalChunk.next;

@@ -651,7 +649,7 @@ const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();

this._split(index);
const first = this.byStart[start];
const last = this.byEnd[end];
const first = this.byStart.get(start);
const last = this.byEnd.get(end);
const oldLeft = first.previous;
const oldRight = last.next;
const newRight = this.byStart[index];
const newRight = this.byStart.get(index);
if (!newRight && last === this.lastChunk) return this;

@@ -728,8 +726,8 @@ const newLeft = newRight ? newRight.previous : this.lastChunk;

}
const first = this.byStart[start];
const last = this.byEnd[end];
const first = this.byStart.get(start);
const last = this.byEnd.get(end);
if (first) {
let chunk = first;
while (chunk !== last) {
if (chunk.next !== this.byStart[chunk.end]) throw new Error("Cannot overwrite across a split point");
if (chunk.next !== this.byStart.get(chunk.end)) throw new Error("Cannot overwrite across a split point");
chunk = chunk.next;

@@ -761,3 +759,3 @@ chunk.edit("", false);

this._split(index);
const chunk = this.byEnd[index];
const chunk = this.byEnd.get(index);
if (chunk) chunk.prependLeft(content);

@@ -774,3 +772,3 @@ else this.intro = content + this.intro;

this._split(index);
const chunk = this.byStart[index];
const chunk = this.byStart.get(index);
if (chunk) chunk.prependRight(content);

@@ -796,3 +794,3 @@ else this.outro = content + this.outro;

this._split(end);
let chunk = this.byStart[start];
let chunk = this.byStart.get(start);
while (chunk) {

@@ -802,3 +800,3 @@ chunk.intro = "";

chunk.edit("");
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
}

@@ -822,6 +820,6 @@ return this;

this._split(end);
let chunk = this.byStart[start];
let chunk = this.byStart.get(start);
while (chunk) {
chunk.reset();
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
}

@@ -912,3 +910,3 @@ return this;

_split(index) {
if (this.byStart[index] || this.byEnd[index]) return;
if (this.byStart.get(index) || this.byEnd.get(index)) return;
let chunk = this.lastSearchedChunk;

@@ -919,3 +917,3 @@ let previousChunk = chunk;

if (chunk.contains(index)) return this._splitChunk(chunk, index);
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
chunk = searchForward ? this.byStart.get(chunk.end) : this.byEnd.get(chunk.start);
if (chunk === previousChunk) return;

@@ -932,5 +930,5 @@ previousChunk = chunk;

const newChunk = chunk.split(index);
this.byEnd[index] = chunk;
this.byStart[index] = newChunk;
this.byEnd[newChunk.end] = newChunk;
this.byEnd.set(index, chunk);
this.byStart.set(index, newChunk);
this.byEnd.set(newChunk.end, newChunk);
if (chunk === this.lastChunk) this.lastChunk = newChunk;

@@ -995,5 +993,5 @@ this.lastSearchedChunk = chunk;

if (this.lastChunk === chunk) this.lastChunk = chunk.next;
this.byEnd[chunk.end] = chunk;
this.byStart[chunk.next.start] = chunk.next;
this.byEnd[chunk.next.end] = chunk.next;
this.byEnd.set(chunk.end, chunk);
this.byStart.set(chunk.next.start, chunk.next);
this.byEnd.set(chunk.next.end, chunk.next);
}

@@ -1023,5 +1021,5 @@ if (aborted) return true;

if (chunk === this.lastChunk) this.lastChunk = chunk.next;
this.byEnd[chunk.end] = chunk;
this.byStart[chunk.next.start] = chunk.next;
this.byEnd[chunk.next.end] = chunk.next;
this.byEnd.set(chunk.end, chunk);
this.byStart.set(chunk.next.start, chunk.next);
this.byEnd.set(chunk.next.end, chunk.next);
}

@@ -1319,3 +1317,1 @@ if (aborted) return true;

export { Bundle, MagicString, MagicString as default, SourceMap };
//# sourceMappingURL=index.mjs.map
{
"name": "magic-string",
"type": "module",
"version": "1.0.0",
"version": "1.1.0",
"description": "Modify strings, generate sourcemaps",

@@ -6,0 +6,0 @@ "author": "Rich Harris",

Sorry, the diff of this file is too big to display