@biomejs/js-api
Advanced tools
Comparing version 0.3.0-nightly.0b5a3fd to 0.3.0-nightly.384b31d
@@ -1,4 +0,5 @@ | ||
import type { Configuration, Diagnostic, PullDiagnosticsResult } from "@biomejs/wasm-nodejs"; | ||
import type { Diagnostic, PartialConfiguration, PullDiagnosticsResult } from "@biomejs/wasm-nodejs"; | ||
import { Distribution } from "./wasm"; | ||
export type { Configuration, Diagnostic }; | ||
export declare type Configuration = PartialConfiguration; | ||
export type { Diagnostic }; | ||
export { Distribution }; | ||
@@ -14,3 +15,3 @@ export interface FormatContentDebugOptions extends FormatContentOptions { | ||
* A virtual path of the file. You should add the extension, | ||
* so Rome knows how to parse the content | ||
* so Biome knows how to parse the content | ||
*/ | ||
@@ -33,12 +34,4 @@ filePath: string; | ||
} | ||
export interface FormatDebugResult { | ||
export interface FormatDebugResult extends FormatResult { | ||
/** | ||
* The new formatted content | ||
*/ | ||
content: string; | ||
/** | ||
* A series of errors encountered while executing an operation | ||
*/ | ||
diagnostics: Diagnostic[]; | ||
/** | ||
* The IR emitted by the formatter | ||
@@ -51,7 +44,7 @@ */ | ||
* A virtual path of the file. You should add the extension, | ||
* so Rome knows how to parse the content | ||
* so Biome knows how to parse the content | ||
*/ | ||
filePath: string; | ||
} | ||
export interface RomeCreate { | ||
export interface BiomeCreate { | ||
distribution: Distribution; | ||
@@ -73,3 +66,3 @@ } | ||
} | ||
export declare class Rome { | ||
export declare class Biome { | ||
private readonly module; | ||
@@ -79,7 +72,7 @@ private readonly workspace; | ||
/** | ||
* It creates a new instance of the class {Rome}. | ||
* It creates a new instance of the class {Biome}. | ||
*/ | ||
static create(options: RomeCreate): Promise<Rome>; | ||
static create(options: BiomeCreate): Promise<Biome>; | ||
/** | ||
* Stop this instance of Rome | ||
* Stop this instance of Biome | ||
* | ||
@@ -98,2 +91,3 @@ * After calling `shutdown()` on this object, it should be considered | ||
applyConfiguration(configuration: Configuration): void; | ||
private tryCatchWrapper; | ||
private withFile; | ||
@@ -100,0 +94,0 @@ formatContent(content: string, options: FormatContentOptions): FormatResult; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Rome = exports.Distribution = void 0; | ||
exports.Biome = exports.Distribution = void 0; | ||
const wasm_1 = require("./wasm"); | ||
@@ -9,3 +9,3 @@ Object.defineProperty(exports, "Distribution", { enumerable: true, get: function () { return wasm_1.Distribution; } }); | ||
} | ||
class Rome { | ||
class Biome { | ||
constructor(module, workspace) { | ||
@@ -16,3 +16,3 @@ this.module = module; | ||
/** | ||
* It creates a new instance of the class {Rome}. | ||
* It creates a new instance of the class {Biome}. | ||
*/ | ||
@@ -22,6 +22,6 @@ static async create(options) { | ||
const workspace = new module.Workspace(); | ||
return new Rome(module, workspace); | ||
return new Biome(module, workspace); | ||
} | ||
/** | ||
* Stop this instance of Rome | ||
* Stop this instance of Biome | ||
* | ||
@@ -45,2 +45,3 @@ * After calling `shutdown()` on this object, it should be considered | ||
configuration, | ||
gitignore_matches: [], | ||
}); | ||
@@ -52,5 +53,13 @@ } | ||
} | ||
tryCatchWrapper(func) { | ||
try { | ||
return func(); | ||
} | ||
catch (err) { | ||
throw (0, wasm_1.wrapError)(err); | ||
} | ||
} | ||
withFile(path, content, func) { | ||
try { | ||
const romePath = { | ||
return this.tryCatchWrapper(() => { | ||
const biomePath = { | ||
path, | ||
@@ -61,16 +70,13 @@ }; | ||
version: 0, | ||
path: romePath, | ||
path: biomePath, | ||
}); | ||
try { | ||
return func(romePath); | ||
return func(biomePath); | ||
} | ||
finally { | ||
this.workspace.closeFile({ | ||
path: romePath, | ||
path: biomePath, | ||
}); | ||
} | ||
} | ||
catch (err) { | ||
throw (0, wasm_1.wrapError)(err); | ||
} | ||
}); | ||
} | ||
@@ -145,3 +151,3 @@ /** | ||
printDiagnostics(diagnostics, options) { | ||
try { | ||
return this.tryCatchWrapper(() => { | ||
const printer = new this.module.DiagnosticPrinter(options.filePath, options.fileSource); | ||
@@ -157,2 +163,3 @@ try { | ||
} | ||
return printer.finish(); | ||
} | ||
@@ -165,10 +172,6 @@ catch (err) { | ||
} | ||
return printer.finish(); | ||
} | ||
catch (err) { | ||
throw (0, wasm_1.wrapError)(err); | ||
} | ||
}); | ||
} | ||
} | ||
exports.Rome = Rome; | ||
exports.Biome = Biome; | ||
//# sourceMappingURL=index.js.map |
@@ -6,3 +6,3 @@ export declare type WasmBundler = typeof import("@biomejs/wasm-bundler"); | ||
/** | ||
* What kind of client Rome should use to communicate with the binary | ||
* What kind of client Biome should use to communicate with the binary | ||
*/ | ||
@@ -9,0 +9,0 @@ export declare enum Distribution { |
@@ -28,3 +28,3 @@ "use strict"; | ||
/** | ||
* What kind of client Rome should use to communicate with the binary | ||
* What kind of client Biome should use to communicate with the binary | ||
*/ | ||
@@ -31,0 +31,0 @@ var Distribution; |
@@ -1,1 +0,1 @@ | ||
{"name":"@biomejs/js-api","version":"0.3.0-nightly.0b5a3fd","description":"JavaScript APIs for the Biome package","scripts":{"tsc":"tsc --noEmit","format":"cargo biome-cli-dev format ./ --write","ci":"cargo biome-cli-dev ci ./src && tsc --noEmit","check":"pnpm rome:check && tsc --noEmit","rome:check":"cargo biome-cli-dev check ./","check:apply":"cargo biome-cli-dev check ./ --apply-unsafe","build:wasm-bundler-dev":"wasm-pack build --out-dir ../../packages/@biomejs/wasm-bundler --target bundler --dev --scope biomedev ../../../crates/rome_wasm","build:wasm-bundler":"wasm-pack build --out-dir ../../packages/@biomejs/wasm-bundler --target bundler --release --scope biomedev ../../../crates/rome_wasm","build:wasm-node-dev":"wasm-pack build --out-dir ../../packages/@biomejs/wasm-nodejs --target nodejs --dev --scope biomedev ../../../crates/rome_wasm","build:wasm-node":"wasm-pack build --out-dir ../../packages/@biomejs/wasm-nodejs --target nodejs --release --scope biomedev ../../../crates/rome_wasm","build:wasm-web-dev":"wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --dev --scope biomedev ../../../crates/rome_wasm","build:wasm-web":"wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --release --scope biomedev ../../../crates/rome_wasm","test":"vitest","test:ci":"vitest --run","build":"tsc "},"files":["README.md","dist/"],"main":"./dist/index.js","types":"./dist/index.d.ts","keywords":["JavaScript","bindings","APIs","biome"],"license":"MIT","homepage":"https://biomejs.dev","repository":{"type":"git","url":"https://github.com/biomejs/biome.git","directory":"packages/@biomejs/js-api"},"author":"Biome Developers and Contributors","bugs":"https://github.com/biomejs/biome/issues","devDependencies":{"typescript":"^4.8.2","vitest":"^0.22.0","vite":"^3.0.8","@biomejs/wasm-bundler":"../wasm-bundler","@biomejs/wasm-nodejs":"../wasm-nodejs","@biomejs/wasm-web":"../wasm-web"},"peerDependencies":{"@biomejs/wasm-bundler":"^10.0.0","@biomejs/wasm-nodejs":"^10.0.0","@biomejs/wasm-web":"^10.0.0"},"peerDependenciesMeta":{"@biomejs/wasm-bundler":{"optional":true},"@biomejs/wasm-nodejs":{"optional":true},"@biomejs/wasm-web":{"optional":true}}} | ||
{"name":"@biomejs/js-api","version":"0.3.0-nightly.384b31d","description":"JavaScript APIs for the Biome package","scripts":{"tsc":"tsc --noEmit","format":"cargo biome-cli-dev format ./ --write","ci":"cargo biome-cli-dev ci ./src && tsc --noEmit","check":"pnpm biome:check && tsc --noEmit","biome:check":"cargo biome-cli-dev check ./","check:apply":"cargo biome-cli-dev check ./ --apply-unsafe","build:wasm-bundler-dev":"wasm-pack build --out-dir ../../packages/@biomejs/wasm-bundler --target bundler --dev --scope biomedev ../../../crates/biome_wasm","build:wasm-bundler":"wasm-pack build --out-dir ../../packages/@biomejs/wasm-bundler --target bundler --release --scope biomedev ../../../crates/biome_wasm","build:wasm-node-dev":"wasm-pack build --out-dir ../../packages/@biomejs/wasm-nodejs --target nodejs --dev --scope biomedev ../../../crates/biome_wasm","build:wasm-node":"wasm-pack build --out-dir ../../packages/@biomejs/wasm-nodejs --target nodejs --release --scope biomedev ../../../crates/biome_wasm","build:wasm-web-dev":"wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --dev --scope biomedev ../../../crates/biome_wasm","build:wasm-web":"wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --release --scope biomedev ../../../crates/biome_wasm","test":"vitest","test:ci":"vitest --run","build":"tsc "},"files":["README.md","LICENSE-APACHE","LICENSE-MIT","ROME-LICENSE-MIT","dist/"],"main":"./dist/index.js","types":"./dist/index.d.ts","keywords":["JavaScript","bindings","APIs","biome"],"license":"MIT OR Apache-2.0","homepage":"https://biomejs.dev","repository":{"type":"git","url":"https://github.com/biomejs/biome.git","directory":"packages/@biomejs/js-api"},"author":"Biome Developers and Contributors","bugs":"https://github.com/biomejs/biome/issues","devDependencies":{"typescript":"^4.8.2","vitest":"^0.22.0","vite":"^3.0.8","@biomejs/wasm-bundler":"../wasm-bundler","@biomejs/wasm-nodejs":"../wasm-nodejs","@biomejs/wasm-web":"../wasm-web"},"peerDependencies":{"@biomejs/wasm-bundler":"^1.5.3","@biomejs/wasm-nodejs":"^1.5.3","@biomejs/wasm-web":"^1.5.3"},"peerDependenciesMeta":{"@biomejs/wasm-bundler":{"optional":true},"@biomejs/wasm-nodejs":{"optional":true},"@biomejs/wasm-web":{"optional":true}}} |
@@ -11,7 +11,7 @@ # Biome JavaScript Bindings | ||
```shell | ||
npm i @rometools/js-api | ||
npm i @rometools/wasm-<dist> | ||
npm i @biomejs/js-api | ||
npm i @biomejs/wasm-<dist> | ||
``` | ||
You need to install one of the `@rometools/wasm-*` package as a **peer dependency** for this package to work correctly, out of the following distributions: | ||
You need to install one of the `@biomejs/wasm-*` package as a **peer dependency** for this package to work correctly, out of the following distributions: | ||
- `@biomejs/wasm-bundler`: Install this package if you're using a bundler that supports importing `*.wasm` files directly | ||
@@ -24,9 +24,9 @@ - `@biomejs/wasm-nodejs`: Install this package if you're using Node.js to load the WebAssembly bundle use the `fs` API | ||
```js | ||
import { Rome, Distribution } from "@biomejs/js-api"; | ||
import { Biome, Distribution } from "@biomejs/js-api"; | ||
const rome = await Rome.create({ | ||
const biome = await Biome.create({ | ||
distribution: Distribution.NODE, // Or BUNDLER / WEB depending on the distribution package you've installed | ||
}); | ||
const formatted = await rome.formatContent("function f (a, b) { return a == b; }", { | ||
const formatted = biome.formatContent("function f (a, b) { return a == b; }", { | ||
filePath: "example.js", | ||
@@ -37,7 +37,7 @@ }); | ||
const result = await rome.lintContent(formatted.content, { | ||
const result = biome.lintContent(formatted.content, { | ||
filePath: "example.js", | ||
}); | ||
const html = rome.printDiagnostics(result.diagnostics, { | ||
const html = biome.printDiagnostics(result.diagnostics, { | ||
filePath: "example.js", | ||
@@ -52,3 +52,3 @@ fileSource: formatted.content, | ||
The project philosophy can be found on our [website](https://docs.rome.tools/internals/philosophy/). | ||
The project philosophy can be found on our [website](https://biomejs.dev/internals/philosophy/). | ||
@@ -59,2 +59,2 @@ ## Community | ||
Additional project coordination and real-time discussion happens on our [Discord server](https://discord.gg/rome). Remember that all activity on the Discord server is still moderated and will be strictly enforced under the project's [Code of Conduct](../../CODE_OF_CONDUCT.md). | ||
Additional project coordination and real-time discussion happens on our [Discord server](https://discord.gg/BypW39g6Yc). Remember that all activity on the Discord server is still moderated and will be strictly enforced under the project's [Code of Conduct](../../CODE_OF_CONDUCT.md). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Mixed license
License(Experimental) Package contains multiple licenses.
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
37394
13
1
407