Skip to content

Commit ecc8795

Browse files
format code
1 parent 0e66362 commit ecc8795

File tree

10 files changed

+137
-140
lines changed

10 files changed

+137
-140
lines changed

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
coverage

prettier.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default {};

src/compiler/index.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ async function downloadMultiData(
4545
percent: number;
4646
loaded: number;
4747
total: number | undefined;
48-
}) => void
48+
}) => void,
4949
) {
5050
const tasks = urls.map(
5151
(
52-
url
52+
url,
5353
): {
5454
loaded: number;
5555
total: number | undefined;
@@ -70,7 +70,7 @@ async function downloadMultiData(
7070
a == undefined || b.total === undefined
7171
? undefined
7272
: a + b.total,
73-
0
73+
0,
7474
);
7575
report({
7676
percent: totalSize ? (totalLoaded / totalSize) * 100 : 0,
@@ -83,11 +83,11 @@ async function downloadMultiData(
8383
url,
8484
new Response(res.data, {
8585
headers: { "Content-Type": "application/octet-stream" },
86-
})
86+
}),
8787
);
8888
return res.data;
8989
},
90-
})
90+
}),
9191
);
9292
return await Promise.all(tasks.map((x) => x.exec()));
9393
}
@@ -109,7 +109,7 @@ export class TypstInitTask {
109109
(e) => {
110110
this.status = "rejected";
111111
throw e;
112-
}
112+
},
113113
);
114114
}
115115
updateProgress(info: {
@@ -143,7 +143,7 @@ export const typstInitInfo: {
143143
} = {
144144
compiler: new TypstInitTask(
145145
downloadMultiData([TypstCompilerWasmUrl, TypstRendererWasmUrl], (x) =>
146-
typstInitInfo.compiler.updateProgress(x)
146+
typstInitInfo.compiler.updateProgress(x),
147147
).then(
148148
(res) => {
149149
typstCompilerWasm = res[0];
@@ -153,8 +153,8 @@ export const typstInitInfo: {
153153
(e) => {
154154
typstInitInfo.compiler.status = "rejected";
155155
throw e;
156-
}
157-
)
156+
},
157+
),
158158
),
159159
font: new TypstInitTask(
160160
(async () => {
@@ -174,7 +174,7 @@ export const typstInitInfo: {
174174
postscriptName: fontName,
175175
blob: () => cached.blob(),
176176
});
177-
})
177+
}),
178178
);
179179
if (unCachedFontUrlEntries.length && window.queryLocalFonts) {
180180
await requestFontAccessConfirm();
@@ -189,60 +189,60 @@ export const typstInitInfo: {
189189
blob: async () => {
190190
const blob = await x.blob();
191191
const fontUrl = unCachedFontUrlEntries.find(
192-
(v) => v[0] === x.postscriptName
192+
(v) => v[0] === x.postscriptName,
193193
)?.[1];
194194
if (fontUrl)
195195
browserCache.put(
196196
fontUrl,
197197
new Response(blob, {
198198
headers: { "Content-Type": "application/octet-stream" },
199-
})
199+
}),
200200
);
201201
return blob;
202202
},
203-
}))
203+
})),
204204
);
205205
} catch {
206206
// ignore
207207
}
208208
}
209209
for (const [fontName, fontUrl] of fontUrlEntries) {
210210
const fontData = localFontDatas.find(
211-
(x) => x.postscriptName === fontName
211+
(x) => x.postscriptName === fontName,
212212
);
213213
if (fontData)
214214
localFontPromises.push(
215-
fontData.blob().then(async (b) => await b.arrayBuffer())
215+
fontData.blob().then(async (b) => await b.arrayBuffer()),
216216
);
217217
else remoteFontUrls.push(fontUrl);
218218
}
219219
fontBuffers = (
220220
await Promise.all([
221221
...localFontPromises,
222222
downloadMultiData(remoteFontUrls, (x) =>
223-
typstInitInfo.font.updateProgress(x)
223+
typstInitInfo.font.updateProgress(x),
224224
),
225225
])
226226
).flat();
227-
})()
227+
})(),
228228
),
229229
package: new TypstInitTask(
230230
(async () => {
231231
const urls = RequiredPreloadPackages.map(
232232
(pkg) =>
233-
`https://packages.typst.org/preview/${pkg.name}-${pkg.version}.tar.gz`
233+
`https://packages.typst.org/preview/${pkg.name}-${pkg.version}.tar.gz`,
234234
);
235235
const datas = await downloadMultiData(urls, (x) =>
236-
typstInitInfo.package.updateProgress(x)
236+
typstInitInfo.package.updateProgress(x),
237237
);
238238
for (let i = 0; i < urls.length; ++i)
239239
preloadedPackages.set(urls[i], datas[i]);
240-
})()
240+
})(),
241241
),
242242
};
243243
export let typstInitStatus: PromiseStatus = "pending";
244244
export const typstInitPromise = Promise.all(
245-
Object.values(typstInitInfo).map((x) => x.promise)
245+
Object.values(typstInitInfo).map((x) => x.promise),
246246
)
247247
.then(async () => {
248248
await send<InitMessage>("init", worker, {
@@ -266,7 +266,7 @@ const processor = unified()
266266
.freeze();
267267

268268
function compilerPrepare(
269-
data: ContestData<{ withMarkdown: true }>
269+
data: ContestData<{ withMarkdown: true }>,
270270
): [ContestData<{ withTypst: true }>, [string, string][]] {
271271
const assets = new Map<string, string>();
272272
const problemsWithTypst = data.problems.map((problem) => {
@@ -393,7 +393,7 @@ async function fetchAsset(url: string): Promise<ArrayBuffer> {
393393
if (isAxiosError(e)) {
394394
console.error("Failed to download assets.", e);
395395
throw new Error(
396-
"下载资源失败。这或许是因为浏览器的跨域限制。你可以尝试手动上传图片。"
396+
"下载资源失败。这或许是因为浏览器的跨域限制。你可以尝试手动上传图片。",
397397
);
398398
}
399399
throw e;

src/compiler/remarkTypst/compiler.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function initContext(): CompilerContext {
4242

4343
export function collectDefinitions(
4444
tree: mdast.Root,
45-
{ definitionById, footnoteById }: CompilerContext
45+
{ definitionById, footnoteById }: CompilerContext,
4646
) {
4747
// Collect definitions and footnote definitions
4848
visit(tree, (node) => {
@@ -60,7 +60,7 @@ export function collectDefinitions(
6060
// Revert reference nodes to plain text
6161
function revert(
6262
node: Extract<mdast.Nodes, mdast.Reference>,
63-
ctx: CompilerContext
63+
ctx: CompilerContext,
6464
) {
6565
const { data } = ctx;
6666
let suffix = '#"]';
@@ -75,7 +75,7 @@ function revert(
7575
'#"!["#"',
7676
node.alt ? escapeTypstString(node.alt) : "",
7777
'"',
78-
suffix
78+
suffix,
7979
);
8080
return;
8181
}
@@ -140,18 +140,18 @@ export const handlers = {
140140
? "txt"
141141
: node.lang === "markdown"
142142
? "md"
143-
: node.lang
143+
: node.lang,
144144
)}", "`,
145145
escapeTypstString(node.value),
146-
'")\n'
146+
'")\n',
147147
);
148148
},
149149
inlineCode: (node, ctx) => {
150150
const { data } = ctx;
151151
data.push(
152152
`#raw(block: false, lang: "txt", "`,
153153
escapeTypstString(node.value),
154-
'")'
154+
'")',
155155
);
156156
},
157157
list: (node, ctx) => {
@@ -277,7 +277,7 @@ export const handlers = {
277277
data.push(
278278
'#footnote(label("',
279279
FOOTNOTE_ID_PREFIX + escapeTypstString(node.identifier),
280-
'"))'
280+
'"))',
281281
);
282282
} else {
283283
data.push('#"[^', escapeTypstString(node.identifier), ']"');
@@ -289,7 +289,7 @@ export const handlers = {
289289
data.push(
290290
'#raw(block: false, lang: "html", "',
291291
escapeTypstString(node.value),
292-
'")'
292+
'")',
293293
);
294294
},
295295
yaml: () => {
@@ -298,7 +298,7 @@ export const handlers = {
298298
} as const satisfies {
299299
[K in keyof mdast.RootContentMap]: (
300300
node: mdast.RootContentMap[K],
301-
ctx: CompilerContext
301+
ctx: CompilerContext,
302302
) => void;
303303
};
304304

src/contestEditor/body.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ const Body: FC<{
2020
updateContestData: Updater<ImmerContestData>;
2121
panel: string;
2222
setPanel: Dispatch<SetStateAction<string>>;
23-
}> = ({
24-
panel,
25-
contestData,
26-
updateContestData,
27-
setPanel,
28-
}) => {
23+
}> = ({ panel, contestData, updateContestData, setPanel }) => {
2924
const divRef = useRef<HTMLDivElement>(null);
3025
const [sizes, setSizes] = useState<number[] | undefined>(undefined);
3126

@@ -84,7 +79,7 @@ const Body: FC<{
8479
: {
8580
code: (() => {
8681
const p = contestData.problems.find(
87-
(y) => y.key === panel
82+
(y) => y.key === panel,
8883
);
8984
if (!p) throw new Error("Target panel not found");
9085
return p.statementMarkdown;

0 commit comments

Comments
 (0)