@@ -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} ;
243243export let typstInitStatus : PromiseStatus = "pending" ;
244244export 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
268268function 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 ;
0 commit comments