11import { DotnetHostBuilder , MonoConfig } from "./dotnetdefs" ;
2- import { recursiveGetDirectory , rootFolder } from "../fs" ;
2+ import { calculateXXH64 , recursiveGetDirectory , rootFolder } from "../fs" ;
33import { SteamJS } from "../achievements" ;
44import { JsSplash } from "./loading" ;
55import { epoxyFetch , EpxTcpWs , EpxWs , getWispUrl } from "../epoxy" ;
@@ -67,13 +67,13 @@ function hookfmod() {
6767 for ( let context of contexts ) {
6868 try {
6969 await context . resume ( ) ;
70- } catch { }
70+ } catch { }
7171 }
7272 } else {
7373 for ( let context of contexts ) {
7474 try {
7575 await context . suspend ( ) ;
76- } catch { }
76+ } catch { }
7777 }
7878 }
7979 } ) ;
@@ -89,7 +89,7 @@ useChange([gameState.playing, gameState.initting], () => {
8989 // @ts -expect-error
9090 navigator . keyboard . unlock ( ) ;
9191 }
92- } catch ( err ) { }
92+ } catch ( err ) { }
9393} ) ;
9494
9595let nativefetch = window . fetch ;
@@ -133,15 +133,15 @@ function encryptRSA(data: Uint8Array, n: bigint, e: bigint): Uint8Array {
133133
134134 return BigInt (
135135 "0x" +
136- [
137- "00" ,
138- "02" ,
139- ...padding . map ( ( byte ) => byte . toString ( 16 ) . padStart ( 2 , "0" ) ) ,
140- "00" ,
141- ...Array . from ( messageBytes ) . map ( ( byte : any ) =>
142- byte . toString ( 16 ) . padStart ( 2 , "0" )
143- ) ,
144- ] . join ( "" )
136+ [
137+ "00" ,
138+ "02" ,
139+ ...padding . map ( ( byte ) => byte . toString ( 16 ) . padStart ( 2 , "0" ) ) ,
140+ "00" ,
141+ ...Array . from ( messageBytes ) . map ( ( byte : any ) =>
142+ byte . toString ( 16 ) . padStart ( 2 , "0" )
143+ ) ,
144+ ] . join ( "" )
145145 ) ;
146146 } ;
147147 const paddedMessage = pkcs1v15Pad ( data , n ) ;
@@ -273,7 +273,7 @@ export async function preInit() {
273273 let h = await file . getFile ( ) ;
274274 console . log ( "got file cached" , last ) ;
275275 return new Response ( h . stream ( ) ) ;
276- } catch { }
276+ } catch { }
277277 dl . download = "cross origin lol" ;
278278 dl . href = args [ 0 ] ;
279279 dl . click ( ) ;
@@ -286,7 +286,7 @@ export async function preInit() {
286286 let h = await file . getFile ( ) ;
287287 console . log ( "got file" , last ) ;
288288 return new Response ( h . stream ( ) ) ;
289- } catch { }
289+ } catch { }
290290 await new Promise ( ( r ) => setTimeout ( r , 100 ) ) ;
291291 }
292292 }
@@ -314,6 +314,22 @@ export async function preInit() {
314314 let encrypted = encryptRSA ( data , modulus , exponent ) ;
315315 return new Uint8Array ( encrypted ) ;
316316 } ,
317+ XXHash64_Fast : async ( path : string ) => {
318+ if ( ! path . startsWith ( "/libsdl/" ) ) throw new Error ( "can't hash things not in opfs" ) ;
319+ path = path . slice ( "/libsdl/" . length ) ;
320+
321+ let start = performance . now ( ) ;
322+ let hex = await calculateXXH64 ( path ) ;
323+ let bytes = new Uint8Array ( 8 ) ;
324+ for ( let i = 0 ; i < 8 ; i ++ ) {
325+ bytes [ i ] = parseInt ( hex . slice ( i * 2 , i * 2 + 2 ) , 16 ) ;
326+ }
327+ let end = performance . now ( ) ;
328+
329+ console . debug ( "xxh64_fast:" , path , ( end - start ) . toFixed ( 1 ) ) ;
330+
331+ return { ret : bytes } ;
332+ }
317333 } ) ;
318334
319335 ( self as any ) . wasm = {
0 commit comments