File tree Expand file tree Collapse file tree 1 file changed +5
-20
lines changed
Expand file tree Collapse file tree 1 file changed +5
-20
lines changed Original file line number Diff line number Diff line change @@ -14,26 +14,11 @@ class ChromaWASM {
1414 async init ( ) {
1515 try {
1616 // Create a new Go instance
17- this . go = new Go ( ) ;
18-
19- // Load the WASM module
20- const wasmResponse = await fetch ( "./static/chroma.wasm" ) ;
21- if ( ! wasmResponse . ok ) {
22- throw new Error ( `Failed to fetch chroma.wasm: ${ wasmResponse . status } ` ) ;
23- }
24-
25- const wasmBytes = await wasmResponse . arrayBuffer ( ) ;
26- const wasmModule = await WebAssembly . instantiate (
27- wasmBytes ,
28- this . go . importObject ,
29- ) ;
30-
31- this . wasm = wasmModule . instance ;
32-
33- // Run the Go program
34- this . go . run ( this . wasm ) ;
35-
36- this . ready = true ;
17+ const go = new Go ( ) ;
18+ WebAssembly . instantiateStreaming ( fetch ( "./static/chroma.wasm" ) , go . importObject ) . then ( ( result ) => {
19+ go . run ( result . instance ) ;
20+ this . ready = true ;
21+ } ) ;
3722 console . log ( "Chroma WASM module initialized successfully" ) ;
3823 } catch ( error ) {
3924 console . error ( "Failed to initialize Chroma WASM module:" , error ) ;
You can’t perform that action at this time.
0 commit comments