2023-07-05 13:34:03 +00:00
|
|
|
|
import { GracefulWorkerService } from "utils/WorkerUtil";
|
|
|
|
|
|
import type {
|
|
|
|
|
|
LintTreeRequestPayload,
|
|
|
|
|
|
updateJSLibraryProps,
|
|
|
|
|
|
} from "plugins/Linting/types";
|
|
|
|
|
|
import { LINT_WORKER_ACTIONS as LINT_ACTIONS } from "plugins/Linting/types";
|
2023-10-12 17:32:38 +00:00
|
|
|
|
import type { FeatureFlags } from "@appsmith/entities/FeatureFlag";
|
2023-07-05 13:34:03 +00:00
|
|
|
|
|
|
|
|
|
|
export interface ILinter {
|
2024-07-31 15:41:28 +00:00
|
|
|
|
// TODO: Fix this the next time the file is edited
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2023-07-05 13:34:03 +00:00
|
|
|
|
lintTree(args: LintTreeRequestPayload): any;
|
2024-07-31 15:41:28 +00:00
|
|
|
|
// TODO: Fix this the next time the file is edited
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2023-07-05 13:34:03 +00:00
|
|
|
|
updateJSLibraryGlobals(args: updateJSLibraryProps): any;
|
|
|
|
|
|
start(): void;
|
|
|
|
|
|
shutdown(): void;
|
2024-07-31 15:41:28 +00:00
|
|
|
|
// TODO: Fix this the next time the file is edited
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2023-10-12 17:32:38 +00:00
|
|
|
|
setup(args: FeatureFlags): any;
|
2023-07-05 13:34:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export class WorkerLinter implements ILinter {
|
|
|
|
|
|
server: GracefulWorkerService;
|
|
|
|
|
|
constructor() {
|
|
|
|
|
|
this.server = new GracefulWorkerService(
|
|
|
|
|
|
new Worker(new URL("./worker.ts", import.meta.url), {
|
|
|
|
|
|
type: "module",
|
|
|
|
|
|
// Note: the `Worker` part of the name is slightly important – LinkRelPreload_spec.js
|
|
|
|
|
|
// relies on it to find workers in the list of all requests.
|
|
|
|
|
|
name: "lintWorker",
|
|
|
|
|
|
}),
|
|
|
|
|
|
);
|
2023-10-12 17:32:38 +00:00
|
|
|
|
this.setup = this.setup.bind(this);
|
2023-07-05 13:34:03 +00:00
|
|
|
|
this.start = this.start.bind(this);
|
|
|
|
|
|
this.shutdown = this.shutdown.bind(this);
|
|
|
|
|
|
this.lintTree = this.lintTree.bind(this);
|
|
|
|
|
|
this.updateJSLibraryGlobals = this.updateJSLibraryGlobals.bind(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
*start() {
|
|
|
|
|
|
yield* this.server.start();
|
|
|
|
|
|
}
|
|
|
|
|
|
*shutdown() {
|
|
|
|
|
|
yield* this.server.shutdown();
|
|
|
|
|
|
}
|
|
|
|
|
|
*lintTree(args: LintTreeRequestPayload) {
|
|
|
|
|
|
return yield* this.server.request(LINT_ACTIONS.LINT_TREE, args);
|
|
|
|
|
|
}
|
|
|
|
|
|
*updateJSLibraryGlobals(args: updateJSLibraryProps) {
|
|
|
|
|
|
return yield* this.server.request(LINT_ACTIONS.UPDATE_LINT_GLOBALS, args);
|
|
|
|
|
|
}
|
2023-10-12 17:32:38 +00:00
|
|
|
|
*setup(args: FeatureFlags) {
|
|
|
|
|
|
return yield* this.server.request(LINT_ACTIONS.SETUP, args);
|
|
|
|
|
|
}
|
2023-07-05 13:34:03 +00:00
|
|
|
|
}
|