Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@biomejs/js-api

Package Overview
Dependencies
Maintainers
6
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@biomejs/js-api - npm Package Compare versions

Comparing version
2.0.2
to
2.0.3
+8
dist/bundler.d.ts
import type { Configuration, Diagnostic } from "@biomejs/wasm-bundler";
import { BiomeCommon } from "./common";
export type * from "./common";
export type { Configuration, Diagnostic };
export declare class Biome extends BiomeCommon<Configuration, Diagnostic> {
constructor();
}
//# sourceMappingURL=bundler.d.ts.map
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../src/bundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,mBAAmB,UAAU,CAAC;AAC9B,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC;AAE1C,qBAAa,KAAM,SAAQ,WAAW,CAAC,aAAa,EAAE,UAAU,CAAC;;CAIhE"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Biome = void 0;
const moduleBundler = __importStar(require("@biomejs/wasm-bundler"));
const common_1 = require("./common");
class Biome extends common_1.BiomeCommon {
constructor() {
super(moduleBundler);
}
}
exports.Biome = Biome;
//# sourceMappingURL=bundler.js.map
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../src/bundler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qEAAuD;AACvD,qCAAuC;AAKvC,MAAa,KAAM,SAAQ,oBAAsC;IAChE;QACC,KAAK,CAAC,aAAa,CAAC,CAAC;IACtB,CAAC;CACD;AAJD,sBAIC"}
import type { FixFileMode, Module, OpenProjectResult, ProjectKey } from "./wasm";
export interface FormatContentDebugOptions extends FormatContentOptions {
/**
* If `true`, you'll be able to inspect the IR of the formatter
*/
debug: boolean;
}
export interface FormatContentOptions {
/**
* A virtual path of the file. You should add the extension, so Biome knows
* how to parse the content
*/
filePath: string;
/**
* The range where to format the content
*/
range?: [number, number];
}
export interface FormatResult<Diagnostic> {
/**
* The new formatted content
*/
content: string;
/**
* A series of errors encountered while executing an operation
*/
diagnostics: Diagnostic[];
}
export interface FormatDebugResult<Diagnostic> extends FormatResult<Diagnostic> {
/**
* The IR emitted by the formatter
*/
ir: string;
}
export interface LintContentOptions {
/**
* A virtual path of the file. You should add the extension, so Biome knows
* how to parse the content
*/
filePath: string;
fixFileMode?: FixFileMode;
}
export interface LintResult<Diagnostic> {
content: string;
diagnostics: Diagnostic[];
}
export interface PrintDiagnosticsOptions {
/**
* The name of the file to print diagnostics for
*/
filePath: string;
/**
* The content of the file the diagnostics were emitted for
*/
fileSource: string;
/**
* Whether to print the diagnostics in verbose mode
*/
verbose?: boolean;
}
export declare class BiomeCommon<Configuration, Diagnostic> {
private readonly module;
private readonly workspace;
constructor(module: Module<Configuration, Diagnostic>);
/**
* Stop this instance of Biome
*
* After calling `shutdown()` on this object, it should be considered
* unusable as calling any method on it will fail
*/
shutdown(): void;
/**
* Allows to apply a custom configuration.
*
* If fails when the configuration is incorrect.
*
* @param projectKey The identifier of the project
* @param configuration
*/
applyConfiguration(projectKey: ProjectKey, configuration: Configuration): void;
/**
* Open a possible workspace project folder. Returns the key of said project. Use this key when you want to switch to different projects.
*
* @param [path]
*/
openProject(path?: string): OpenProjectResult;
private withFile;
formatContent(projectKey: ProjectKey, content: string, options: FormatContentOptions): FormatResult<Diagnostic>;
formatContent(projectKey: ProjectKey, content: string, options: FormatContentDebugOptions): FormatDebugResult<Diagnostic>;
/**
* Lint the content of a file.
*
* @param projectKey The identifier of the project
* @param content The content to lint
* @param options Options needed when linting some content
*/
lintContent(projectKey: ProjectKey, content: string, { filePath, fixFileMode }: LintContentOptions): LintResult<Diagnostic>;
/**
* Print a list of diagnostics to an HTML string.
*
* @param diagnostics The list of diagnostics to print
* @param options Options needed for printing the diagnostics
*/
printDiagnostics(diagnostics: Diagnostic[], options: PrintDiagnosticsOptions): string;
}
//# sourceMappingURL=common.d.ts.map
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,WAAW,EACX,MAAM,EACN,iBAAiB,EACjB,UAAU,EAEV,MAAM,QAAQ,CAAC;AAGhB,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACtE;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzB;AAED,MAAM,WAAW,YAAY,CAAC,UAAU;IACvC;;OAE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,CAAC;IA6DhC;;;;;;OAMG;IACH,WAAW,CACV,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,MAAM,EACf,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,kBAAkB,GAC3C,UAAU,CAAC,UAAU,CAAC;IA6BzB;;;;;OAKG;IACH,gBAAgB,CACf,WAAW,EAAE,UAAU,EAAE,EACzB,OAAO,EAAE,uBAAuB,GAC9B,MAAM;CAwBT"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BiomeCommon = void 0;
const wasm_1 = require("./wasm");
function isFormatContentDebug(options) {
return "debug" in options && options.debug !== undefined;
}
/**
* List of modules that have been initialized.
*/
const initialized = new WeakSet();
class BiomeCommon {
constructor(module) {
this.module = module;
if (!initialized.has(module)) {
module.main();
initialized.add(module);
}
this.workspace = new module.Workspace();
}
/**
* Stop this instance of Biome
*
* After calling `shutdown()` on this object, it should be considered
* unusable as calling any method on it will fail
*/
shutdown() {
this.workspace.free();
}
/**
* Allows to apply a custom configuration.
*
* If fails when the configuration is incorrect.
*
* @param projectKey The identifier of the project
* @param configuration
*/
applyConfiguration(projectKey, configuration) {
(0, wasm_1.tryCatchWrapper)(() => {
this.workspace.updateSettings({
projectKey,
configuration,
workspaceDirectory: "./",
});
});
}
/**
* Open a possible workspace project folder. Returns the key of said project. Use this key when you want to switch to different projects.
*
* @param [path]
*/
openProject(path) {
return this.workspace.openProject({
path: path || "",
openUninitialized: true,
});
}
withFile(projectKey, path, content, func) {
return (0, wasm_1.tryCatchWrapper)(() => {
this.workspace.openFile({
projectKey,
content: { type: "fromClient", content, version: 0 },
path,
});
try {
return func(path);
}
finally {
this.workspace.closeFile({
projectKey,
path,
});
}
});
}
/**
* If formats some content.
*
* @param projectKey The identifier of the project
* @param content The content to format
* @param options Options needed when formatting some content
*/
formatContent(projectKey, content, options) {
return this.withFile(projectKey, options.filePath, content, (path) => {
let code = content;
const result = this.workspace.pullDiagnostics({
projectKey,
path,
categories: ["syntax"],
pullCodeActions: false,
});
if (0 === result.errors) {
if (options.range) {
const result = this.workspace.formatRange({
projectKey,
path,
range: options.range,
});
code = result.code;
}
else {
const result = this.workspace.formatFile({
projectKey,
path,
});
code = result.code;
}
if (isFormatContentDebug(options)) {
const ir = this.workspace.getFormatterIr({
projectKey,
path,
});
return {
content: code,
diagnostics: result.diagnostics,
ir,
};
}
}
return {
content: code,
diagnostics: result.diagnostics,
};
});
}
/**
* Lint the content of a file.
*
* @param projectKey The identifier of the project
* @param content The content to lint
* @param options Options needed when linting some content
*/
lintContent(projectKey, content, { filePath, fixFileMode }) {
const maybeFixedContent = fixFileMode
? this.withFile(projectKey, filePath, content, (path) => {
const { code } = this.workspace.fixFile({
projectKey,
path,
fixFileMode: fixFileMode,
shouldFormat: false,
ruleCategories: ["syntax", "lint", "action"],
});
return code;
})
: content;
return this.withFile(projectKey, filePath, maybeFixedContent, (path) => {
const { diagnostics } = this.workspace.pullDiagnostics({
projectKey,
path,
categories: ["syntax", "lint", "action"],
pullCodeActions: false,
});
return {
content: maybeFixedContent,
diagnostics,
};
});
}
/**
* Print a list of diagnostics to an HTML string.
*
* @param diagnostics The list of diagnostics to print
* @param options Options needed for printing the diagnostics
*/
printDiagnostics(diagnostics, options) {
return (0, wasm_1.tryCatchWrapper)(() => {
const printer = new this.module.DiagnosticPrinter(options.filePath, options.fileSource);
try {
for (const diag of diagnostics) {
if (options.verbose) {
printer.print_verbose(diag);
}
else {
printer.print_simple(diag);
}
}
return printer.finish();
}
catch (err) {
// Only call `free` if the `print` method throws, `finish` will
// take care of deallocating the printer even if it fails
printer.free();
throw err;
}
});
}
}
exports.BiomeCommon = BiomeCommon;
//# sourceMappingURL=common.js.map
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":";;;AAQA,iCAAyC;AAsDzC,SAAS,oBAAoB,CAC5B,OAAyD;IAEzD,OAAO,OAAO,IAAI,OAAO,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC;AAC1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AAG,IAAI,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAChD,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,UAAU,CAClB,CAAC;YAEF,IAAI,CAAC;gBACJ,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;oBAChC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;wBACrB,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;oBAC7B,CAAC;yBAAM,CAAC;wBACP,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;oBAC5B,CAAC;gBACF,CAAC;gBACD,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC;YACzB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,+DAA+D;gBAC/D,yDAAyD;gBACzD,OAAO,CAAC,IAAI,EAAE,CAAC;gBACf,MAAM,GAAG,CAAC;YACX,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AA9ND,kCA8NC"}
import type { Configuration as ConfigurationBundler, Diagnostic as DiagnosticBundler } from "@biomejs/wasm-bundler";
import type { Configuration as ConfigurationNodejs, Diagnostic as DiagnosticNodeJs } from "@biomejs/wasm-nodejs";
import type { Configuration as ConfigurationWeb, Diagnostic as DiagnosticWeb } from "@biomejs/wasm-web";
import { BiomeCommon } from "./common";
export type * from "./common";
export type Configuration = ConfigurationBundler | ConfigurationNodejs | ConfigurationWeb;
export type Diagnostic = DiagnosticBundler | DiagnosticNodeJs | DiagnosticWeb;
/**
* What kind of client Biome should use to communicate with the binary
*/
export declare enum Distribution {
/**
* Use this if you want to communicate with the WebAssembly client built for
* bundlers
*/
BUNDLER = 0,
/**
* Use this if you want to communicate with the WebAssembly client built for
* Node.JS
*/
NODE = 1,
/**
* Use this if you want to communicate with the WebAssembly client built for
* the Web
*/
WEB = 2
}
export interface BiomeCreate {
distribution: Distribution;
}
export declare class Biome extends BiomeCommon<Configuration, Diagnostic> {
/**
* It creates a new instance of the class {Biome}.
*/
static create({ distribution }: BiomeCreate): Promise<Biome>;
}
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,IAAI,oBAAoB,EACrC,UAAU,IAAI,iBAAiB,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACX,aAAa,IAAI,mBAAmB,EACpC,UAAU,IAAI,gBAAgB,EAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACX,aAAa,IAAI,gBAAgB,EACjC,UAAU,IAAI,aAAa,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,mBAAmB,UAAU,CAAC;AAC9B,MAAM,MAAM,aAAa,GACtB,oBAAoB,GACpB,mBAAmB,GACnB,gBAAgB,CAAC;AACpB,MAAM,MAAM,UAAU,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAE9E;;GAEG;AACH,oBAAY,YAAY;IACvB;;;OAGG;IACH,OAAO,IAAI;IACX;;;OAGG;IACH,IAAI,IAAI;IACR;;;OAGG;IACH,GAAG,IAAI;CACP;AAED,MAAM,WAAW,WAAW;IAC3B,YAAY,EAAE,YAAY,CAAC;CAC3B;AAED,qBAAa,KAAM,SAAQ,WAAW,CAAC,aAAa,EAAE,UAAU,CAAC;IAChE;;OAEG;WACU,MAAM,CAAC,EAAE,YAAY,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;CAYlE"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Biome = exports.Distribution = void 0;
const common_1 = require("./common");
/**
* What kind of client Biome should use to communicate with the binary
*/
var Distribution;
(function (Distribution) {
/**
* Use this if you want to communicate with the WebAssembly client built for
* bundlers
*/
Distribution[Distribution["BUNDLER"] = 0] = "BUNDLER";
/**
* Use this if you want to communicate with the WebAssembly client built for
* Node.JS
*/
Distribution[Distribution["NODE"] = 1] = "NODE";
/**
* Use this if you want to communicate with the WebAssembly client built for
* the Web
*/
Distribution[Distribution["WEB"] = 2] = "WEB";
})(Distribution || (exports.Distribution = Distribution = {}));
class Biome extends common_1.BiomeCommon {
/**
* It creates a new instance of the class {Biome}.
*/
static async create({ distribution }) {
switch (distribution) {
case Distribution.BUNDLER:
return new Biome(await Promise.resolve().then(() => __importStar(require("@biomejs/wasm-bundler"))));
case Distribution.NODE:
return new Biome(await Promise.resolve().then(() => __importStar(require("@biomejs/wasm-nodejs"))));
case Distribution.WEB:
return new Biome(await Promise.resolve().then(() => __importStar(require("@biomejs/wasm-web"))));
default:
throw new Error(`Unknown distribution: ${distribution}`);
}
}
}
exports.Biome = Biome;
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,qCAAuC;AASvC;;GAEG;AACH,IAAY,YAgBX;AAhBD,WAAY,YAAY;IACvB;;;OAGG;IACH,qDAAW,CAAA;IACX;;;OAGG;IACH,+CAAQ,CAAA;IACR;;;OAGG;IACH,6CAAO,CAAA;AACR,CAAC,EAhBW,YAAY,4BAAZ,YAAY,QAgBvB;AAMD,MAAa,KAAM,SAAQ,oBAAsC;IAChE;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,YAAY,EAAe;QAChD,QAAQ,YAAY,EAAE,CAAC;YACtB,KAAK,YAAY,CAAC,OAAO;gBACxB,OAAO,IAAI,KAAK,CAAC,wDAAa,uBAAuB,GAAC,CAAC,CAAC;YACzD,KAAK,YAAY,CAAC,IAAI;gBACrB,OAAO,IAAI,KAAK,CAAC,wDAAa,sBAAsB,GAAC,CAAC,CAAC;YACxD,KAAK,YAAY,CAAC,GAAG;gBACpB,OAAO,IAAI,KAAK,CAAC,wDAAa,mBAAmB,GAAC,CAAC,CAAC;YACrD;gBACC,MAAM,IAAI,KAAK,CAAC,yBAAyB,YAAY,EAAE,CAAC,CAAC;QAC3D,CAAC;IACF,CAAC;CACD;AAhBD,sBAgBC"}
import type { Configuration, Diagnostic } from "@biomejs/wasm-nodejs";
import { BiomeCommon } from "./common";
export type * from "./common";
export type { Configuration, Diagnostic };
export declare class Biome extends BiomeCommon<Configuration, Diagnostic> {
constructor();
}
//# sourceMappingURL=nodejs.d.ts.map
{"version":3,"file":"nodejs.d.ts","sourceRoot":"","sources":["../src/nodejs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,mBAAmB,UAAU,CAAC;AAC9B,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC;AAE1C,qBAAa,KAAM,SAAQ,WAAW,CAAC,aAAa,EAAE,UAAU,CAAC;;CAIhE"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Biome = void 0;
const moduleNodeJs = __importStar(require("@biomejs/wasm-nodejs"));
const common_1 = require("./common");
class Biome extends common_1.BiomeCommon {
constructor() {
super(moduleNodeJs);
}
}
exports.Biome = Biome;
//# sourceMappingURL=nodejs.js.map
{"version":3,"file":"nodejs.js","sourceRoot":"","sources":["../src/nodejs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mEAAqD;AACrD,qCAAuC;AAKvC,MAAa,KAAM,SAAQ,oBAAsC;IAChE;QACC,KAAK,CAAC,YAAY,CAAC,CAAC;IACrB,CAAC;CACD;AAJD,sBAIC"}
export type BiomePath = string;
export type ProjectKey = number;
interface UpdateSettingsParams<Configuration> {
configuration: Configuration;
projectKey: ProjectKey;
workspaceDirectory?: BiomePath;
}
type TextRange = [TextSize, TextSize];
type TextSize = number;
interface OpenProjectParams {
openUninitialized: boolean;
path: BiomePath;
}
export interface OpenProjectResult {
/**
* A unique identifier for this project
*/
projectKey: ProjectKey;
/**
* How to scan this project
*/
scanKind: ScanKind;
}
type ScanKind = "noScanner" | "knownFiles" | {
targetedKnownFiles: {
/**
* Determines whether the file scanner should descend into subdirectories of the target paths.
*/
descendFromTargets: boolean;
/**
* The paths to target by the scanner.
If a target path indicates a folder, all files within are scanned as well.
Target paths must be absolute.
*/
targetPaths: BiomePath[];
};
} | "project";
interface OpenFileParams {
content: FileContent;
path: BiomePath;
projectKey: ProjectKey;
}
type FileContent = {
content: string;
type: "fromClient";
version: number;
};
interface CloseFileParams {
path: BiomePath;
projectKey: ProjectKey;
}
interface GetFormatterIRParams {
path: BiomePath;
projectKey: ProjectKey;
}
interface PullDiagnosticsParams {
categories: RuleCategories;
path: BiomePath;
projectKey: ProjectKey;
/**
* When `false` the diagnostics, don't have code frames of the code actions
* (fixes, suppressions, etc.)
*/
pullCodeActions: boolean;
}
type RuleCategories = RuleCategory[];
type RuleCategory = "syntax" | "lint" | "action" | "transformation";
interface PullDiagnosticsResult<Diagnostic> {
diagnostics: Diagnostic[];
errors: number;
}
interface FormatFileParams {
path: BiomePath;
projectKey: ProjectKey;
}
interface FormatRangeParams {
path: BiomePath;
projectKey: ProjectKey;
range: TextRange;
}
interface FixFileParams {
fixFileMode: FixFileMode;
path: BiomePath;
projectKey: ProjectKey;
ruleCategories: RuleCategories;
shouldFormat: boolean;
}
export type FixFileMode = "safeFixes" | "safeAndUnsafeFixes" | "applySuppressions";
interface FixFileResult {
/**
* New source code for the file with all fixes applied
*/
code: string;
}
export interface DiagnosticPrinter<Diagnostic> {
free(): void;
print_simple(diagnostic: Diagnostic): void;
print_verbose(diagnostic: Diagnostic): void;
finish(): string;
}
export interface Workspace<Configuration, Diagnostic> {
free(): void;
updateSettings(params: UpdateSettingsParams<Configuration>): void;
openProject(params: OpenProjectParams): OpenProjectResult;
openFile(params: OpenFileParams): void;
closeFile(params: CloseFileParams): void;
pullDiagnostics(params: PullDiagnosticsParams): PullDiagnosticsResult<Diagnostic>;
formatRange(params: FormatRangeParams): any;
formatFile(params: FormatFileParams): any;
getFormatterIr(params: GetFormatterIRParams): string;
fixFile(params: FixFileParams): FixFileResult;
}
export interface Module<Configuration, Diagnostic> {
main: () => void;
DiagnosticPrinter: new (fileName: string, fileSource: string) => DiagnosticPrinter<Diagnostic>;
Workspace: new () => Workspace<Configuration, Diagnostic>;
}
/**
* Catch a WebAssembly error and wrap into a native JS Error
*
* @param func The function to execute
*/
export declare function tryCatchWrapper<T>(func: () => T): T;
export {};
//# sourceMappingURL=wasm.d.ts.map
{"version":3,"file":"wasm.d.ts","sourceRoot":"","sources":["../src/wasm.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,UAAU,oBAAoB,CAAC,aAAa;IAC3C,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,kBAAkB,CAAC,EAAE,SAAS,CAAC;CAC/B;AAED,KAAK,SAAS,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAEtC,KAAK,QAAQ,GAAG,MAAM,CAAC;AAEvB,UAAU,iBAAiB;IAC1B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,IAAI,EAAE,SAAS,CAAC;CAChB;AACD,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;IACvB;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACnB;AACD,KAAK,QAAQ,GACV,WAAW,GACX,YAAY,GACZ;IACA,kBAAkB,EAAE;QACnB;;WAEG;QACH,kBAAkB,EAAE,OAAO,CAAC;QAC5B;;;;;;EAMD;QACC,WAAW,EAAE,SAAS,EAAE,CAAC;KACzB,CAAC;CACD,G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CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAMnD"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tryCatchWrapper = tryCatchWrapper;
/**
* The error generated when communicating with WebAssembly
*/
class WasmError extends Error {
constructor(stackTrace) {
super();
this.stackTrace = stackTrace;
}
}
/**
* Catch a WebAssembly error and wrap into a native JS Error
*
* @param func The function to execute
*/
function tryCatchWrapper(func) {
try {
return func();
}
catch (err) {
throw new WasmError(err);
}
}
//# sourceMappingURL=wasm.js.map
{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../src/wasm.ts"],"names":[],"mappings":";;AAkKA,0CAMC;AA5BD;;GAEG;AACH,MAAM,SAAU,SAAQ,KAAK;IAQ5B,YAAY,UAAkB;QAC7B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;CACD;AAED;;;;GAIG;AACH,SAAgB,eAAe,CAAI,IAAa;IAC/C,IAAI,CAAC;QACJ,OAAO,IAAI,EAAE,CAAC;IACf,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,MAAM,IAAI,SAAS,CAAC,GAAa,CAAC,CAAC;IACpC,CAAC;AACF,CAAC"}
import type { Configuration, Diagnostic } from "@biomejs/wasm-web";
import { BiomeCommon } from "./common";
export type * from "./common";
export type { Configuration, Diagnostic };
export declare class Biome extends BiomeCommon<Configuration, Diagnostic> {
constructor();
}
//# sourceMappingURL=web.d.ts.map
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,mBAAmB,UAAU,CAAC;AAC9B,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC;AAE1C,qBAAa,KAAM,SAAQ,WAAW,CAAC,aAAa,EAAE,UAAU,CAAC;;CAIhE"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Biome = void 0;
const moduleWeb = __importStar(require("@biomejs/wasm-web"));
const common_1 = require("./common");
class Biome extends common_1.BiomeCommon {
constructor() {
super(moduleWeb);
}
}
exports.Biome = Biome;
//# sourceMappingURL=web.js.map
{"version":3,"file":"web.js","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6DAA+C;AAC/C,qCAAuC;AAKvC,MAAa,KAAM,SAAQ,oBAAsC;IAChE;QACC,KAAK,CAAC,SAAS,CAAC,CAAC;IAClB,CAAC;CACD;AAJD,sBAIC"}
+1
-1
{
"name": "@biomejs/js-api",
"version": "2.0.2",
"version": "2.0.3",
"description": "JavaScript APIs for the Biome package",

@@ -5,0 +5,0 @@ "files": [

import type { Configuration, Diagnostic } from "@biomejs/wasm-bundler";
import { BiomeCommon } from "./common";
export type * from "./common";
export type { Configuration, Diagnostic };
export declare class Biome extends BiomeCommon<Configuration, Diagnostic> {
constructor();
}
//# sourceMappingURL=bundler.d.ts.map
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../src/bundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,mBAAmB,UAAU,CAAC;AAC9B,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC;AAE1C,qBAAa,KAAM,SAAQ,WAAW,CAAC,aAAa,EAAE,UAAU,CAAC;;CAIhE"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Biome = void 0;
const moduleBundler = __importStar(require("@biomejs/wasm-bundler"));
const common_1 = require("./common");
class Biome extends common_1.BiomeCommon {
constructor() {
super(moduleBundler);
}
}
exports.Biome = Biome;
//# sourceMappingURL=bundler.js.map
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../src/bundler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qEAAuD;AACvD,qCAAuC;AAKvC,MAAa,KAAM,SAAQ,oBAAsC;IAChE;QACC,KAAK,CAAC,aAAa,CAAC,CAAC;IACtB,CAAC;CACD;AAJD,sBAIC"}
import type { FixFileMode, Module, OpenProjectResult, ProjectKey } from "./wasm";
export interface FormatContentDebugOptions extends FormatContentOptions {
/**
* If `true`, you'll be able to inspect the IR of the formatter
*/
debug: boolean;
}
export interface FormatContentOptions {
/**
* A virtual path of the file. You should add the extension, so Biome knows
* how to parse the content
*/
filePath: string;
/**
* The range where to format the content
*/
range?: [number, number];
}
export interface FormatResult<Diagnostic> {
/**
* The new formatted content
*/
content: string;
/**
* A series of errors encountered while executing an operation
*/
diagnostics: Diagnostic[];
}
export interface FormatDebugResult<Diagnostic> extends FormatResult<Diagnostic> {
/**
* The IR emitted by the formatter
*/
ir: string;
}
export interface LintContentOptions {
/**
* A virtual path of the file. You should add the extension, so Biome knows
* how to parse the content
*/
filePath: string;
fixFileMode?: FixFileMode;
}
export interface LintResult<Diagnostic> {
content: string;
diagnostics: Diagnostic[];
}
export interface PrintDiagnosticsOptions {
/**
* The name of the file to print diagnostics for
*/
filePath: string;
/**
* The content of the file the diagnostics were emitted for
*/
fileSource: string;
/**
* Whether to print the diagnostics in verbose mode
*/
verbose?: boolean;
}
export declare class BiomeCommon<Configuration, Diagnostic> {
private readonly module;
private readonly workspace;
constructor(module: Module<Configuration, Diagnostic>);
/**
* Stop this instance of Biome
*
* After calling `shutdown()` on this object, it should be considered
* unusable as calling any method on it will fail
*/
shutdown(): void;
/**
* Allows to apply a custom configuration.
*
* If fails when the configuration is incorrect.
*
* @param projectKey The identifier of the project
* @param configuration
*/
applyConfiguration(projectKey: ProjectKey, configuration: Configuration): void;
/**
* Open a possible workspace project folder. Returns the key of said project. Use this key when you want to switch to different projects.
*
* @param [path]
*/
openProject(path?: string): OpenProjectResult;
private withFile;
formatContent(projectKey: ProjectKey, content: string, options: FormatContentOptions): FormatResult<Diagnostic>;
formatContent(projectKey: ProjectKey, content: string, options: FormatContentDebugOptions): FormatDebugResult<Diagnostic>;
/**
* Lint the content of a file.
*
* @param projectKey The identifier of the project
* @param content The content to lint
* @param options Options needed when linting some content
*/
lintContent(projectKey: ProjectKey, content: string, { filePath, fixFileMode }: LintContentOptions): LintResult<Diagnostic>;
/**
* Print a list of diagnostics to an HTML string.
*
* @param diagnostics The list of diagnostics to print
* @param options Options needed for printing the diagnostics
*/
printDiagnostics(diagnostics: Diagnostic[], options: PrintDiagnosticsOptions): string;
}
//# sourceMappingURL=common.d.ts.map
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,WAAW,EACX,MAAM,EACN,iBAAiB,EACjB,UAAU,EAEV,MAAM,QAAQ,CAAC;AAGhB,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACtE;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzB;AAED,MAAM,WAAW,YAAY,CAAC,UAAU;IACvC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,WAAW,EAAE,UAAU,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB,CAAC,UAAU,CAC5C,SAAQ,YAAY,CAAC,UAAU,CAAC;IAChC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,kBAAkB;IAClC;;;OAG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uBAAuB,GAC9B,MAAM;CAwBT"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BiomeCommon = void 0;
const wasm_1 = require("./wasm");
function isFormatContentDebug(options) {
return "debug" in options && options.debug !== undefined;
}
/**
* List of modules that have been initialized.
*/
const initialized = new WeakSet();
class BiomeCommon {
constructor(module) {
this.module = module;
if (!initialized.has(module)) {
module.main();
initialized.add(module);
}
this.workspace = new module.Workspace();
}
/**
* Stop this instance of Biome
*
* After calling `shutdown()` on this object, it should be considered
* unusable as calling any method on it will fail
*/
shutdown() {
this.workspace.free();
}
/**
* Allows to apply a custom configuration.
*
* If fails when the configuration is incorrect.
*
* @param projectKey The identifier of the project
* @param configuration
*/
applyConfiguration(projectKey, configuration) {
(0, wasm_1.tryCatchWrapper)(() => {
this.workspace.updateSettings({
projectKey,
configuration,
workspaceDirectory: "./",
});
});
}
/**
* Open a possible workspace project folder. Returns the key of said project. Use this key when you want to switch to different projects.
*
* @param [path]
*/
openProject(path) {
return this.workspace.openProject({
path: path || "",
openUninitialized: true,
});
}
withFile(projectKey, path, content, func) {
return (0, wasm_1.tryCatchWrapper)(() => {
this.workspace.openFile({
projectKey,
content: { type: "fromClient", content, version: 0 },
path,
});
try {
return func(path);
}
finally {
this.workspace.closeFile({
projectKey,
path,
});
}
});
}
/**
* If formats some content.
*
* @param projectKey The identifier of the project
* @param content The content to format
* @param options Options needed when formatting some content
*/
formatContent(projectKey, content, options) {
return this.withFile(projectKey, options.filePath, content, (path) => {
let code = content;
const result = this.workspace.pullDiagnostics({
projectKey,
path,
categories: ["syntax"],
pullCodeActions: false,
});
if (0 === result.errors) {
if (options.range) {
const result = this.workspace.formatRange({
projectKey,
path,
range: options.range,
});
code = result.code;
}
else {
const result = this.workspace.formatFile({
projectKey,
path,
});
code = result.code;
}
if (isFormatContentDebug(options)) {
const ir = this.workspace.getFormatterIr({
projectKey,
path,
});
return {
content: code,
diagnostics: result.diagnostics,
ir,
};
}
}
return {
content: code,
diagnostics: result.diagnostics,
};
});
}
/**
* Lint the content of a file.
*
* @param projectKey The identifier of the project
* @param content The content to lint
* @param options Options needed when linting some content
*/
lintContent(projectKey, content, { filePath, fixFileMode }) {
const maybeFixedContent = fixFileMode
? this.withFile(projectKey, filePath, content, (path) => {
const { code } = this.workspace.fixFile({
projectKey,
path,
fixFileMode: fixFileMode,
shouldFormat: false,
ruleCategories: ["syntax", "lint", "action"],
});
return code;
})
: content;
return this.withFile(projectKey, filePath, maybeFixedContent, (path) => {
const { diagnostics } = this.workspace.pullDiagnostics({
projectKey,
path,
categories: ["syntax", "lint", "action"],
pullCodeActions: false,
});
return {
content: maybeFixedContent,
diagnostics,
};
});
}
/**
* Print a list of diagnostics to an HTML string.
*
* @param diagnostics The list of diagnostics to print
* @param options Options needed for printing the diagnostics
*/
printDiagnostics(diagnostics, options) {
return (0, wasm_1.tryCatchWrapper)(() => {
const printer = new this.module.DiagnosticPrinter(options.filePath, options.fileSource);
try {
for (const diag of diagnostics) {
if (options.verbose) {
printer.print_verbose(diag);
}
else {
printer.print_simple(diag);
}
}
return printer.finish();
}
catch (err) {
// Only call `free` if the `print` method throws, `finish` will
// take care of deallocating the printer even if it fails
printer.free();
throw err;
}
});
}
}
exports.BiomeCommon = BiomeCommon;
//# sourceMappingURL=common.js.map
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":";;;AAQA,iCAAyC;AAsDzC,SAAS,oBAAoB,CAC5B,OAAyD;IAEzD,OAAO,OAAO,IAAI,OAAO,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC;AAC1D,CAAC;AAiBD;;GAEG;AACH,MAAM,WAAW,GAAG,IAAI,OAAO,EAAE,CAAC;AAElC,MAAa,WAAW;IAGvB,YAA6B,MAAyC;QAAzC,WAAM,GAAN,MAAM,CAAmC;QACrE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9B,MAAM,CAAC,IAAI,EAAE,CAAC;Y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IAAI,CAAC,CAAC;oBAC7B,CAAC;yBAAM,CAAC;wBACP,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;oBAC5B,CAAC;gBACF,CAAC;gBACD,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC;YACzB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,+DAA+D;gBAC/D,yDAAyD;gBACzD,OAAO,CAAC,IAAI,EAAE,CAAC;gBACf,MAAM,GAAG,CAAC;YACX,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AA9ND,kCA8NC"}
import type { Configuration as ConfigurationBundler, Diagnostic as DiagnosticBundler } from "@biomejs/wasm-bundler";
import type { Configuration as ConfigurationNodejs, Diagnostic as DiagnosticNodeJs } from "@biomejs/wasm-nodejs";
import type { Configuration as ConfigurationWeb, Diagnostic as DiagnosticWeb } from "@biomejs/wasm-web";
import { BiomeCommon } from "./common";
export type * from "./common";
export type Configuration = ConfigurationBundler | ConfigurationNodejs | ConfigurationWeb;
export type Diagnostic = DiagnosticBundler | DiagnosticNodeJs | DiagnosticWeb;
/**
* What kind of client Biome should use to communicate with the binary
*/
export declare enum Distribution {
/**
* Use this if you want to communicate with the WebAssembly client built for
* bundlers
*/
BUNDLER = 0,
/**
* Use this if you want to communicate with the WebAssembly client built for
* Node.JS
*/
NODE = 1,
/**
* Use this if you want to communicate with the WebAssembly client built for
* the Web
*/
WEB = 2
}
export interface BiomeCreate {
distribution: Distribution;
}
export declare class Biome extends BiomeCommon<Configuration, Diagnostic> {
/**
* It creates a new instance of the class {Biome}.
*/
static create({ distribution }: BiomeCreate): Promise<Biome>;
}
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,IAAI,oBAAoB,EACrC,UAAU,IAAI,iBAAiB,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACX,aAAa,IAAI,mBAAmB,EACpC,UAAU,IAAI,gBAAgB,EAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACX,aAAa,IAAI,gBAAgB,EACjC,UAAU,IAAI,aAAa,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,mBAAmB,UAAU,CAAC;AAC9B,MAAM,MAAM,aAAa,GACtB,oBAAoB,GACpB,mBAAmB,GACnB,gBAAgB,CAAC;AACpB,MAAM,MAAM,UAAU,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAE9E;;GAEG;AACH,oBAAY,YAAY;IACvB;;;OAGG;IACH,OAAO,IAAI;IACX;;;OAGG;IACH,IAAI,IAAI;IACR;;;OAGG;IACH,GAAG,IAAI;CACP;AAED,MAAM,WAAW,WAAW;IAC3B,YAAY,EAAE,YAAY,CAAC;CAC3B;AAED,qBAAa,KAAM,SAAQ,WAAW,CAAC,aAAa,EAAE,UAAU,CAAC;IAChE;;OAEG;WACU,MAAM,CAAC,EAAE,YAAY,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;CAYlE"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Biome = exports.Distribution = void 0;
const common_1 = require("./common");
/**
* What kind of client Biome should use to communicate with the binary
*/
var Distribution;
(function (Distribution) {
/**
* Use this if you want to communicate with the WebAssembly client built for
* bundlers
*/
Distribution[Distribution["BUNDLER"] = 0] = "BUNDLER";
/**
* Use this if you want to communicate with the WebAssembly client built for
* Node.JS
*/
Distribution[Distribution["NODE"] = 1] = "NODE";
/**
* Use this if you want to communicate with the WebAssembly client built for
* the Web
*/
Distribution[Distribution["WEB"] = 2] = "WEB";
})(Distribution || (exports.Distribution = Distribution = {}));
class Biome extends common_1.BiomeCommon {
/**
* It creates a new instance of the class {Biome}.
*/
static async create({ distribution }) {
switch (distribution) {
case Distribution.BUNDLER:
return new Biome(await Promise.resolve().then(() => __importStar(require("@biomejs/wasm-bundler"))));
case Distribution.NODE:
return new Biome(await Promise.resolve().then(() => __importStar(require("@biomejs/wasm-nodejs"))));
case Distribution.WEB:
return new Biome(await Promise.resolve().then(() => __importStar(require("@biomejs/wasm-web"))));
default:
throw new Error(`Unknown distribution: ${distribution}`);
}
}
}
exports.Biome = Biome;
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,qCAAuC;AASvC;;GAEG;AACH,IAAY,YAgBX;AAhBD,WAAY,YAAY;IACvB;;;OAGG;IACH,qDAAW,CAAA;IACX;;;OAGG;IACH,+CAAQ,CAAA;IACR;;;OAGG;IACH,6CAAO,CAAA;AACR,CAAC,EAhBW,YAAY,4BAAZ,YAAY,QAgBvB;AAMD,MAAa,KAAM,SAAQ,oBAAsC;IAChE;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,YAAY,EAAe;QAChD,QAAQ,YAAY,EAAE,CAAC;YACtB,KAAK,YAAY,CAAC,OAAO;gBACxB,OAAO,IAAI,KAAK,CAAC,wDAAa,uBAAuB,GAAC,CAAC,CAAC;YACzD,KAAK,YAAY,CAAC,IAAI;gBACrB,OAAO,IAAI,KAAK,CAAC,wDAAa,sBAAsB,GAAC,CAAC,CAAC;YACxD,KAAK,YAAY,CAAC,GAAG;gBACpB,OAAO,IAAI,KAAK,CAAC,wDAAa,mBAAmB,GAAC,CAAC,CAAC;YACrD;gBACC,MAAM,IAAI,KAAK,CAAC,yBAAyB,YAAY,EAAE,CAAC,CAAC;QAC3D,CAAC;IACF,CAAC;CACD;AAhBD,sBAgBC"}
import type { Configuration, Diagnostic } from "@biomejs/wasm-nodejs";
import { BiomeCommon } from "./common";
export type * from "./common";
export type { Configuration, Diagnostic };
export declare class Biome extends BiomeCommon<Configuration, Diagnostic> {
constructor();
}
//# sourceMappingURL=nodejs.d.ts.map
{"version":3,"file":"nodejs.d.ts","sourceRoot":"","sources":["../src/nodejs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,mBAAmB,UAAU,CAAC;AAC9B,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC;AAE1C,qBAAa,KAAM,SAAQ,WAAW,CAAC,aAAa,EAAE,UAAU,CAAC;;CAIhE"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Biome = void 0;
const moduleNodeJs = __importStar(require("@biomejs/wasm-nodejs"));
const common_1 = require("./common");
class Biome extends common_1.BiomeCommon {
constructor() {
super(moduleNodeJs);
}
}
exports.Biome = Biome;
//# sourceMappingURL=nodejs.js.map
{"version":3,"file":"nodejs.js","sourceRoot":"","sources":["../src/nodejs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mEAAqD;AACrD,qCAAuC;AAKvC,MAAa,KAAM,SAAQ,oBAAsC;IAChE;QACC,KAAK,CAAC,YAAY,CAAC,CAAC;IACrB,CAAC;CACD;AAJD,sBAIC"}
export type BiomePath = string;
export type ProjectKey = number;
interface UpdateSettingsParams<Configuration> {
configuration: Configuration;
projectKey: ProjectKey;
workspaceDirectory?: BiomePath;
}
type TextRange = [TextSize, TextSize];
type TextSize = number;
interface OpenProjectParams {
openUninitialized: boolean;
path: BiomePath;
}
export interface OpenProjectResult {
/**
* A unique identifier for this project
*/
projectKey: ProjectKey;
/**
* How to scan this project
*/
scanKind: ScanKind;
}
type ScanKind = "noScanner" | "knownFiles" | {
targetedKnownFiles: {
/**
* Determines whether the file scanner should descend into subdirectories of the target paths.
*/
descendFromTargets: boolean;
/**
* The paths to target by the scanner.
If a target path indicates a folder, all files within are scanned as well.
Target paths must be absolute.
*/
targetPaths: BiomePath[];
};
} | "project";
interface OpenFileParams {
content: FileContent;
path: BiomePath;
projectKey: ProjectKey;
}
type FileContent = {
content: string;
type: "fromClient";
version: number;
};
interface CloseFileParams {
path: BiomePath;
projectKey: ProjectKey;
}
interface GetFormatterIRParams {
path: BiomePath;
projectKey: ProjectKey;
}
interface PullDiagnosticsParams {
categories: RuleCategories;
path: BiomePath;
projectKey: ProjectKey;
/**
* When `false` the diagnostics, don't have code frames of the code actions
* (fixes, suppressions, etc.)
*/
pullCodeActions: boolean;
}
type RuleCategories = RuleCategory[];
type RuleCategory = "syntax" | "lint" | "action" | "transformation";
interface PullDiagnosticsResult<Diagnostic> {
diagnostics: Diagnostic[];
errors: number;
}
interface FormatFileParams {
path: BiomePath;
projectKey: ProjectKey;
}
interface FormatRangeParams {
path: BiomePath;
projectKey: ProjectKey;
range: TextRange;
}
interface FixFileParams {
fixFileMode: FixFileMode;
path: BiomePath;
projectKey: ProjectKey;
ruleCategories: RuleCategories;
shouldFormat: boolean;
}
export type FixFileMode = "safeFixes" | "safeAndUnsafeFixes" | "applySuppressions";
interface FixFileResult {
/**
* New source code for the file with all fixes applied
*/
code: string;
}
export interface DiagnosticPrinter<Diagnostic> {
free(): void;
print_simple(diagnostic: Diagnostic): void;
print_verbose(diagnostic: Diagnostic): void;
finish(): string;
}
export interface Workspace<Configuration, Diagnostic> {
free(): void;
updateSettings(params: UpdateSettingsParams<Configuration>): void;
openProject(params: OpenProjectParams): OpenProjectResult;
openFile(params: OpenFileParams): void;
closeFile(params: CloseFileParams): void;
pullDiagnostics(params: PullDiagnosticsParams): PullDiagnosticsResult<Diagnostic>;
formatRange(params: FormatRangeParams): any;
formatFile(params: FormatFileParams): any;
getFormatterIr(params: GetFormatterIRParams): string;
fixFile(params: FixFileParams): FixFileResult;
}
export interface Module<Configuration, Diagnostic> {
main: () => void;
DiagnosticPrinter: new (fileName: string, fileSource: string) => DiagnosticPrinter<Diagnostic>;
Workspace: new () => Workspace<Configuration, Diagnostic>;
}
/**
* Catch a WebAssembly error and wrap into a native JS Error
*
* @param func The function to execute
*/
export declare function tryCatchWrapper<T>(func: () => T): T;
export {};
//# sourceMappingURL=wasm.d.ts.map
{"version":3,"file":"wasm.d.ts","sourceRoot":"","sources":["../src/wasm.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,UAAU,oBAAoB,CAAC,aAAa;IAC3C,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,kBAAkB,CAAC,EAAE,SAAS,CAAC;CAC/B;AAED,KAAK,SAAS,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAEtC,KAAK,QAAQ,GAAG,MAAM,CAAC;AAEvB,UAAU,iBAAiB;IAC1B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,IAAI,EAAE,SAAS,CAAC;CAChB;AACD,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;IACvB;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACnB;AACD,KAAK,QAAQ,GACV,WAAW,GACX,YAAY,GACZ;IACA,kBAAkB,EAAE;QACnB;;WAEG;QACH,kBAAkB,EAAE,OAAO,CAAC;QAC5B;;;;;;EAMD;QACC,WAAW,EAAE,SAAS,EAAE,CAAC;KACzB,CAAC;CACD,GACD,SAAS,CAAC;AACb,UAAU,cAAc;IACvB,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;CACvB;AACD,KAAK,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE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GAAG,IAAI,CAAC;IAC5C,MAAM,IAAI,MAAM,CAAC;CACjB;AACD,MAAM,WAAW,SAAS,CAAC,aAAa,EAAE,UAAU;IACnD,IAAI,IAAI,IAAI,CAAC;IACb,cAAc,CAAC,MAAM,EAAE,oBAAoB,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;IAClE,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,CAAC;IAC1D,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IACvC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IACzC,eAAe,CACd,MAAM,EAAE,qBAAqB,GAC3B,qBAAqB,CAAC,UAAU,CAAC,CAAC;IACrC,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,GAAG,CAAC;IAC5C,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,GAAG,CAAC;IAC1C,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAAC;IACrD,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAAC;CAC9C;AAED,MAAM,WAAW,MAAM,CAAC,aAAa,EAAE,UAAU;IAChD,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,iBAAiB,EAAE,KAClB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,KACd,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACnC,SAAS,EAAE,UAAU,SAAS,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;CAC1D;AAmBD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAMnD"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tryCatchWrapper = tryCatchWrapper;
/**
* The error generated when communicating with WebAssembly
*/
class WasmError extends Error {
constructor(stackTrace) {
super();
this.stackTrace = stackTrace;
}
}
/**
* Catch a WebAssembly error and wrap into a native JS Error
*
* @param func The function to execute
*/
function tryCatchWrapper(func) {
try {
return func();
}
catch (err) {
throw new WasmError(err);
}
}
//# sourceMappingURL=wasm.js.map
{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../src/wasm.ts"],"names":[],"mappings":";;AAkKA,0CAMC;AA5BD;;GAEG;AACH,MAAM,SAAU,SAAQ,KAAK;IAQ5B,YAAY,UAAkB;QAC7B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;CACD;AAED;;;;GAIG;AACH,SAAgB,eAAe,CAAI,IAAa;IAC/C,IAAI,CAAC;QACJ,OAAO,IAAI,EAAE,CAAC;IACf,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,MAAM,IAAI,SAAS,CAAC,GAAa,CAAC,CAAC;IACpC,CAAC;AACF,CAAC"}
import type { Configuration, Diagnostic } from "@biomejs/wasm-web";
import { BiomeCommon } from "./common";
export type * from "./common";
export type { Configuration, Diagnostic };
export declare class Biome extends BiomeCommon<Configuration, Diagnostic> {
constructor();
}
//# sourceMappingURL=web.d.ts.map
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,mBAAmB,UAAU,CAAC;AAC9B,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC;AAE1C,qBAAa,KAAM,SAAQ,WAAW,CAAC,aAAa,EAAE,UAAU,CAAC;;CAIhE"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Biome = void 0;
const moduleWeb = __importStar(require("@biomejs/wasm-web"));
const common_1 = require("./common");
class Biome extends common_1.BiomeCommon {
constructor() {
super(moduleWeb);
}
}
exports.Biome = Biome;
//# sourceMappingURL=web.js.map
{"version":3,"file":"web.js","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6DAA+C;AAC/C,qCAAuC;AAKvC,MAAa,KAAM,SAAQ,oBAAsC;IAChE;QACC,KAAK,CAAC,SAAS,CAAC,CAAC;IAClB,CAAC;CACD;AAJD,sBAIC"}