@napi-rs/magic-string
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -0,3 +1,6 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/* auto-generated by NAPI-RS */ | ||
export class ExternalObject<T> { | ||
@@ -24,2 +27,3 @@ readonly '': { | ||
includeContent: boolean | ||
hires: boolean | ||
} | ||
@@ -42,3 +46,3 @@ /** Only for .d.ts generation */ | ||
content: string, | ||
options: OverwriteOptions, | ||
options?: OverwriteOptions, | ||
): this | ||
@@ -50,23 +54,19 @@ trim(pattern?: string | undefined | null): this | ||
remove(start: number, end: number): this | ||
generateMap(options?: GenerateDecodedMapOptions | undefined | null): { | ||
version: number | ||
file: string | ||
sources: string[] | ||
sourcesContent: string[] | ||
names: string[] | ||
mappings: string | ||
sourceRoot?: string | ||
isEmpty(): boolean | ||
generateMap(options?: Partial<GenerateDecodedMapOptions>): { | ||
toString: () => string | ||
toUrl: () => string | ||
toMap: () => { | ||
version: number | ||
file?: string | ||
sources: string[] | ||
sourcesContent: string[] | ||
names: string[] | ||
mappings: string | ||
sourceRoot?: string | ||
} | ||
} | ||
/** @internal */ | ||
toSourcemapString(sourcemap: ExternalObject<SourceMap>): string | ||
/** @internal */ | ||
toSourcemapUrl(sourcemap: ExternalObject<SourceMap>): string | ||
generateDecodedMap( | ||
options?: GenerateDecodedMapOptions | undefined | null, | ||
): DecodedMap | ||
generateDecodedMap(options?: Partial<GenerateDecodedMapOptions>): DecodedMap | ||
toString(): string | ||
length(): number | ||
} |
47
index.js
const { MagicString: MagicStringNative } = require('./binding') | ||
module.exports.MagicString = class MagicString extends MagicStringNative { | ||
generateDecodedMap(options) { | ||
return JSON.parse(super.generateDecodedMap(options)) | ||
overwrite(start, end, content, options) { | ||
options = { | ||
contentOnly: false, | ||
...options | ||
} | ||
return super.overwrite(start, end, content, options) | ||
} | ||
generateMap(options) { | ||
const sourcemap = super.generateMap({ | ||
options = { | ||
file: null, | ||
@@ -13,19 +17,27 @@ source: null, | ||
includeContent: false, | ||
hires: false, | ||
...options, | ||
}) | ||
} | ||
const str = super.toSourcemapString(sourcemap) | ||
const obj = JSON.parse(str) | ||
const toString = () => super.toSourcemapString(options) | ||
const toUrl = () => super.toSourcemapUrl(options) | ||
const toMap = () => JSON.parse(toString(options)) | ||
const toString = () => str | ||
const toUrl = () => super.toSourcemapUrl(sourcemap) | ||
return { | ||
toString, | ||
toUrl, | ||
toMap, | ||
} | ||
} | ||
generateDecodedMap(options) { | ||
options = { | ||
file: null, | ||
source: null, | ||
sourceRoot: null, | ||
includeContent: false, | ||
hires: false, | ||
...options, | ||
} | ||
Object.defineProperty(obj, 'toString', { | ||
value: toString, | ||
}) | ||
Object.defineProperty(obj, 'toUrl', { | ||
value: toUrl, | ||
}) | ||
return obj | ||
return JSON.parse(super.generateDecodedMap(options)) | ||
} | ||
@@ -44,2 +56,5 @@ toSourcemapString() { | ||
Object.assign(exports, '__esModule', { | ||
value: true, | ||
}) | ||
module.exports.default = module.exports.MagicString |
{ | ||
"name": "@napi-rs/magic-string", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "rusty magic-string", | ||
@@ -40,2 +40,3 @@ "main": "index.js", | ||
"prepublishOnly": "napi prepublish -t npm && esbuild --minify --outfile=binding.js --allow-overwrite binding.js", | ||
"prof": "node --cpu-prof prof/index.js", | ||
"lint": "echo lint", | ||
@@ -67,16 +68,16 @@ "version": "napi version" | ||
"optionalDependencies": { | ||
"@napi-rs/magic-string-win32-x64-msvc": "0.3.3", | ||
"@napi-rs/magic-string-darwin-x64": "0.3.3", | ||
"@napi-rs/magic-string-linux-x64-gnu": "0.3.3", | ||
"@napi-rs/magic-string-linux-x64-musl": "0.3.3", | ||
"@napi-rs/magic-string-linux-arm64-gnu": "0.3.3", | ||
"@napi-rs/magic-string-win32-ia32-msvc": "0.3.3", | ||
"@napi-rs/magic-string-linux-arm-gnueabihf": "0.3.3", | ||
"@napi-rs/magic-string-darwin-arm64": "0.3.3", | ||
"@napi-rs/magic-string-freebsd-x64": "0.3.3", | ||
"@napi-rs/magic-string-linux-arm64-musl": "0.3.3", | ||
"@napi-rs/magic-string-win32-arm64-msvc": "0.3.3", | ||
"@napi-rs/magic-string-android-arm64": "0.3.3", | ||
"@napi-rs/magic-string-android-arm-eabi": "0.3.3" | ||
"@napi-rs/magic-string-win32-x64-msvc": "0.3.4", | ||
"@napi-rs/magic-string-darwin-x64": "0.3.4", | ||
"@napi-rs/magic-string-linux-x64-gnu": "0.3.4", | ||
"@napi-rs/magic-string-linux-x64-musl": "0.3.4", | ||
"@napi-rs/magic-string-linux-arm64-gnu": "0.3.4", | ||
"@napi-rs/magic-string-win32-ia32-msvc": "0.3.4", | ||
"@napi-rs/magic-string-linux-arm-gnueabihf": "0.3.4", | ||
"@napi-rs/magic-string-darwin-arm64": "0.3.4", | ||
"@napi-rs/magic-string-freebsd-x64": "0.3.4", | ||
"@napi-rs/magic-string-linux-arm64-musl": "0.3.4", | ||
"@napi-rs/magic-string-win32-arm64-msvc": "0.3.4", | ||
"@napi-rs/magic-string-android-arm64": "0.3.4", | ||
"@napi-rs/magic-string-android-arm-eabi": "0.3.4" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9837
137