Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/project/conat/formatter.ts
1447 views
1
/*
2
File formatting service.
3
*/
4
5
import { run_formatter, type Options } from "../formatters";
6
import { createFormatterService as create } from "@cocalc/conat/service/formatter";
7
import { compute_server_id, project_id } from "@cocalc/project/data";
8
9
interface Message {
10
path: string;
11
options: Options;
12
}
13
14
export async function createFormatterService({ openSyncDocs }) {
15
const impl = {
16
formatter: async (opts: Message) => {
17
const syncstring = openSyncDocs[opts.path];
18
if (syncstring == null) {
19
throw Error(`"${opts.path}" is not opened`);
20
}
21
return await run_formatter({ ...opts, syncstring });
22
},
23
};
24
return await create({ compute_server_id, project_id, impl });
25
}
26
27