跳到正文

Class: BindingMagicString

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1273

Constructors

Constructor

ts
new BindingMagicString(source, options?): BindingMagicString;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1274

Parameters

source

string

options?

BindingMagicStringOptions | null

Returns

BindingMagicString

Accessors

filename

Get Signature

ts
get filename(): string | null;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1275

Returns

string | null

Methods

append()

ts
append(content): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1279

Parameters

content

string

Returns

this


appendLeft()

ts
appendLeft(index, content): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1282

Parameters

index

number

content

string

Returns

this


appendRight()

ts
appendRight(index, content): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1283

Parameters

index

number

content

string

Returns

this


clone()

ts
clone(): BindingMagicString;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1313

Returns a clone of the MagicString instance.

Returns

BindingMagicString


generateDecodedMap()

ts
generateDecodedMap(options?): BindingDecodedMap;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1340

Generates a decoded source map for the transformations applied to this MagicString. Returns a BindingDecodedMap object with mappings as an array of arrays.

Parameters

options?

BindingSourceMapOptions | null

Returns

BindingDecodedMap


generateMap()

ts
generateMap(options?): BindingSourceMap;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1335

Generates a source map for the transformations applied to this MagicString. Returns a BindingSourceMap object with version, file, sources, sourcesContent, names, mappings.

Parameters

options?

BindingSourceMapOptions | null

Returns

BindingSourceMap


hasChanged()

ts
hasChanged(): boolean;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1286

Returns

boolean


indent()

ts
indent(indentor?): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1298

Parameters

indentor?

string | null

Returns

this


insert()

ts
insert(index, content): void;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1311

Deprecated method that throws an error directing users to use prependRight or appendLeft. This matches the original magic-string API which deprecated this method.

Parameters

index

number

content

string

Returns

void


isEmpty()

ts
isEmpty(): boolean;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1288

Returns

boolean


lastChar()

ts
lastChar(): string;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1315

Returns the last character of the generated string, or an empty string if empty.

Returns

string


lastLine()

ts
lastLine(): string;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1317

Returns the content after the last newline in the generated string.

Returns

string


length()

ts
length(): number;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1287

Returns

number


move()

ts
move(
   start,
   end,
   index): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1297

Alias for relocate to match the original magic-string API. Moves the characters from start to end to index. Returns this for method chaining.

Parameters

start

number

end

number

index

number

Returns

this


overwrite()

ts
overwrite(
   start,
   end,
   content): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1284

Parameters

start

number

end

number

content

string

Returns

this


prepend()

ts
prepend(content): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1278

Parameters

content

string

Returns

this


prependLeft()

ts
prependLeft(index, content): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1280

Parameters

index

number

content

string

Returns

this


prependRight()

ts
prependRight(index, content): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1281

Parameters

index

number

content

string

Returns

this


relocate()

ts
relocate(
   start,
   end,
   to): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1291

Parameters

start

number

end

number

to

number

Returns

this


remove()

ts
remove(start, end): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1289

Parameters

start

number

end

number

Returns

this


replace()

ts
replace(from, to): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1276

Parameters

from

string

to

string

Returns

this


replaceAll()

ts
replaceAll(from, to): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1277

Parameters

from

string

to

string

Returns

this


reset()

ts
reset(start, end): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1325

Resets the portion of the string from start to end to its original content. This undoes any modifications made to that range. Supports negative indices (counting from the end).

Parameters

start

number

end

number

Returns

this


slice()

ts
slice(start?, end?): string;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1330

Returns the content between the specified original character positions. Supports negative indices (counting from the end).

Parameters

start?

number | null

end?

number | null

Returns

string


snip()

ts
snip(start, end): BindingMagicString;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1319

Returns a clone with content outside the specified range removed.

Parameters

start

number

end

number

Returns

BindingMagicString


toString()

ts
toString(): string;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1285

Returns

string


trim()

ts
trim(charType?): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1300

Trims whitespace or specified characters from the start and end.

Parameters

charType?

string | null

Returns

this


trimEnd()

ts
trimEnd(charType?): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1304

Trims whitespace or specified characters from the end.

Parameters

charType?

string | null

Returns

this


trimLines()

ts
trimLines(): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1306

Trims newlines from the start and end.

Returns

this


trimStart()

ts
trimStart(charType?): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1302

Trims whitespace or specified characters from the start.

Parameters

charType?

string | null

Returns

this


update()

ts
update(
   start,
   end,
   content): this;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/binding-B92Lq__Q.d.mts:1290

Parameters

start

number

end

number

content

string

Returns

this

Released under the MIT License.