Skip to content

Interface: RolldownMagicString

Extends

  • BindingMagicString

Properties

isRolldownMagicString

  • Type: true

Accessors

filename

Get Signature

  • Type: () => string | null
Defined in: binding.d.cts:1485
Returns

string | null

Inherited from

NativeBindingMagicString.filename


ignoreList

Get Signature

  • Type: () => boolean
Defined in: binding.d.cts:1487
Returns

boolean

Inherited from

NativeBindingMagicString.ignoreList


indentExclusionRanges

Get Signature

  • Type: () => number[] | number[][] | null
Defined in: binding.d.cts:1486
Returns

number[] | number[][] | null

Inherited from

NativeBindingMagicString.indentExclusionRanges


offset

Get Signature

  • Type: () => number
Defined in: binding.d.cts:1488
Returns

number

Set Signature

  • Type: (offset: number) => void
Defined in: binding.d.cts:1489
Parameters
offset

number

Returns

void

Inherited from

NativeBindingMagicString.offset


original

Get Signature

  • Type: () => string
Defined in: binding.d.cts:1484
Returns

string

Inherited from

NativeBindingMagicString.original

Methods

append()

  • Type: (content: string) => this
Defined in: binding.d.cts:1493

Parameters

content

string

Returns

this

Inherited from

NativeBindingMagicString.append


appendLeft()

  • Type: (index: number, content: string) => this
Defined in: binding.d.cts:1496

Parameters

index

number

content

string

Returns

this

Inherited from

NativeBindingMagicString.appendLeft


appendRight()

  • Type: (index: number, content: string) => this
Defined in: binding.d.cts:1497

Parameters

index

number

content

string

Returns

this

Inherited from

NativeBindingMagicString.appendRight


clone()

  • Type: () => BindingMagicString
Defined in: binding.d.cts:1527

Returns a clone of the MagicString instance.

Returns

BindingMagicString

Inherited from

NativeBindingMagicString.clone


generateDecodedMap()

  • Type: (options?: BindingSourceMapOptions | null) => BindingDecodedMap
Defined in: binding.d.cts:1560

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

Inherited from

NativeBindingMagicString.generateDecodedMap


generateMap()

  • Type: (options?: BindingSourceMapOptions | null) => BindingSourceMap
Defined in: binding.d.cts:1555

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

Inherited from

NativeBindingMagicString.generateMap


getIndentString()

  • Type: () => string
Defined in: binding.d.cts:1533

Returns the guessed indentation string, or \t if none is found.

Returns

string

Inherited from

NativeBindingMagicString.getIndentString


hasChanged()

  • Type: () => boolean
Defined in: binding.d.cts:1500

Returns

boolean

Inherited from

NativeBindingMagicString.hasChanged


indent()

  • Type: (indentor?: string | null, options?: BindingIndentOptions | null) => this
Defined in: binding.d.cts:1512

Parameters

indentor?

string | null

options?

BindingIndentOptions | null

Returns

this

Inherited from

NativeBindingMagicString.indent


insert()

  • Type: (index: number, content: string) => void
Defined in: binding.d.cts:1525

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

Inherited from

NativeBindingMagicString.insert


isEmpty()

  • Type: () => boolean
Defined in: binding.d.cts:1502

Returns

boolean

Inherited from

NativeBindingMagicString.isEmpty


lastChar()

  • Type: () => string
Defined in: binding.d.cts:1529

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

Returns

string

Inherited from

NativeBindingMagicString.lastChar


lastLine()

  • Type: () => string
Defined in: binding.d.cts:1531

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

Returns

string

Inherited from

NativeBindingMagicString.lastLine


length()

  • Type: () => number
Defined in: binding.d.cts:1501

Returns

number

Inherited from

NativeBindingMagicString.length


move()

  • Type: (start: number, end: number, index: number) => this
Defined in: binding.d.cts:1511

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

Inherited from

NativeBindingMagicString.move


overwrite()

  • Type: (start: number, end: number, content: string) => this
Defined in: binding.d.cts:1498

Parameters

start

number

end

number

content

string

Returns

this

Inherited from

NativeBindingMagicString.overwrite


prepend()

  • Type: (content: string) => this
Defined in: binding.d.cts:1492

Parameters

content

string

Returns

this

Inherited from

NativeBindingMagicString.prepend


prependLeft()

  • Type: (index: number, content: string) => this
Defined in: binding.d.cts:1494

Parameters

index

number

content

string

Returns

this

Inherited from

NativeBindingMagicString.prependLeft


prependRight()

  • Type: (index: number, content: string) => this
Defined in: binding.d.cts:1495

Parameters

index

number

content

string

Returns

this

Inherited from

NativeBindingMagicString.prependRight


relocate()

  • Type: (start: number, end: number, to: number) => this
Defined in: binding.d.cts:1505

Parameters

start

number

end

number

to

number

Returns

this

Inherited from

NativeBindingMagicString.relocate


remove()

  • Type: (start: number, end: number) => this
Defined in: binding.d.cts:1503

Parameters

start

number

end

number

Returns

this

Inherited from

NativeBindingMagicString.remove


replace()

  • Type: (from: string, to: string) => this
Defined in: binding.d.cts:1490

Parameters

from

string

to

string

Returns

this

Inherited from

NativeBindingMagicString.replace


replaceAll()

  • Type: (from: string, to: string) => this
Defined in: binding.d.cts:1491

Parameters

from

string

to

string

Returns

this

Inherited from

NativeBindingMagicString.replaceAll


reset()

  • Type: (start: number, end: number) => this
Defined in: binding.d.cts:1541

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

Inherited from

NativeBindingMagicString.reset


slice()

  • Type: (start?: number | null, end?: number | null) => string
Defined in: binding.d.cts:1550

Returns the content between the specified UTF-16 code unit positions (JS string indices). Supports negative indices (counting from the end).

When an index falls in the middle of a surrogate pair, the lone surrogate is included in the result (matching the original magic-string / JS behavior). This is done by returning a UTF-16 encoded JS string via napi_create_string_utf16.

Parameters

start?

number | null

end?

number | null

Returns

string

Inherited from

NativeBindingMagicString.slice


snip()

  • Type: (start: number, end: number) => BindingMagicString
Defined in: binding.d.cts:1535

Returns a clone with content outside the specified range removed.

Parameters

start

number

end

number

Returns

BindingMagicString

Inherited from

NativeBindingMagicString.snip


toString()

  • Type: () => string
Defined in: binding.d.cts:1499

Returns

string

Inherited from

NativeBindingMagicString.toString


trim()

  • Type: (charType?: string | null) => this
Defined in: binding.d.cts:1514

Trims whitespace or specified characters from the start and end.

Parameters

charType?

string | null

Returns

this

Inherited from

NativeBindingMagicString.trim


trimEnd()

  • Type: (charType?: string | null) => this
Defined in: binding.d.cts:1518

Trims whitespace or specified characters from the end.

Parameters

charType?

string | null

Returns

this

Inherited from

NativeBindingMagicString.trimEnd


trimLines()

  • Type: () => this
Defined in: binding.d.cts:1520

Trims newlines from the start and end.

Returns

this

Inherited from

NativeBindingMagicString.trimLines


trimStart()

  • Type: (charType?: string | null) => this
Defined in: binding.d.cts:1516

Trims whitespace or specified characters from the start.

Parameters

charType?

string | null

Returns

this

Inherited from

NativeBindingMagicString.trimStart


update()

  • Type: (start: number, end: number, content: string) => this
Defined in: binding.d.cts:1504

Parameters

start

number

end

number

content

string

Returns

this

Inherited from

NativeBindingMagicString.update