@@ -24,15 +24,14 @@ public class PhotonPool {
2424 private final BlockingQueue <Photon > photons ;
2525
2626 PhotonPool (ResourceResolver resourceResolve ) throws IOException {
27- URL photonModuleURL = resourceResolve .getResource ("classpath:photon/photon_rs .js" ).get ();
27+ URL photonModuleURL = resourceResolve .getResource ("classpath:photon/photon .js" ).get ();
2828 Source photonSource = Source .newBuilder ("js" , photonModuleURL ).mimeType ("application/javascript+module" ).build ();
29- byte [] wasmBytes = resourceResolve .getResourceAsStream ("classpath:photon/photon_rs_bg.wasm" ).get ().readAllBytes ();
3029 byte [] imageBytes = resourceResolve .getResourceAsStream ("classpath:daisies_fuji.jpg" ).get ().readAllBytes ();
3130
3231 int maxThreads = Runtime .getRuntime ().availableProcessors ();
3332 photons = new LinkedBlockingQueue <>(maxThreads );
3433 for (int i = 0 ; i < maxThreads ; i ++) {
35- photons .add (createPhoton (sharedEngine , photonSource , wasmBytes , imageBytes ));
34+ photons .add (createPhoton (sharedEngine , photonSource , imageBytes ));
3635 }
3736 }
3837
@@ -53,23 +52,20 @@ public void close() {
5352 sharedEngine .close ();
5453 }
5554
56- private static Photon createPhoton (Engine engine , Source photonSource , Object wasmBytes , Object imageBytes ) {
55+ private static Photon createPhoton (Engine engine , Source photonSource , Object imageBytes ) {
5756 org .graalvm .polyglot .Context context = org .graalvm .polyglot .Context .newBuilder ("js" , "wasm" )
5857 .engine (engine )
5958 .allowAllAccess (true )
6059 .allowExperimentalOptions (true )
6160 .option ("js.webassembly" , "true" )
6261 .option ("js.esm-eval-returns-exports" , "true" )
62+ .option ("js.text-encoding" , "true" )
6363 .build ();
6464
6565 // Get Uint8Array class from JavaScript
6666 Value uint8Array = context .eval ("js" , "Uint8Array" );
6767 // Load Photon module and initialize with wasm content
6868 Value photonModule = context .eval (photonSource );
69- // Create Uint8Array with wasm bytes
70- Value wasmContent = uint8Array .newInstance (wasmBytes );
71- // Initialize Photon module with wasm content
72- photonModule .invokeMember ("default" , wasmContent );
7369 // Create Uint8Array with image bytes
7470 Value imageContent = uint8Array .newInstance (imageBytes );
7571
0 commit comments