From b0523e72af4379e31689055d2f2fc9f220001fb1 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Tue, 30 Jan 2024 18:37:16 +0100 Subject: [PATCH] Make undefined of wasmCode after instantiate --- examples.md | 5 ++--- src/js-executor/execute-es-module.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/examples.md b/examples.md index 04f271e..ef130dd 100644 --- a/examples.md +++ b/examples.md @@ -160,15 +160,13 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import org.jetbrains.compose.resources.ExperimentalResourceApi -import org.jetbrains.compose.resources.painterResource +//sampleStart @OptIn(ExperimentalComposeUiApi::class) fun main() { CanvasBasedWindow(canvasElementId = "ComposeTarget") { App() } } -@OptIn(ExperimentalResourceApi::class) @Composable fun App() { MaterialTheme { @@ -209,6 +207,7 @@ class Greeting { interface Platform { val name: String } +//sampleEnd ``` diff --git a/src/js-executor/execute-es-module.js b/src/js-executor/execute-es-module.js index 7716231..a6facfc 100644 --- a/src/js-executor/execute-es-module.js +++ b/src/js-executor/execute-es-module.js @@ -20,8 +20,8 @@ export async function executeWasmCode(container, jsCode, wasmCode) { ` + jsCode .replace( - "instantiateStreaming(fetch(wasmFilePath)", - "instantiate(window.wasmCode" + "instantiateStreaming(fetch(wasmFilePath), importObject)).instance;", + "instantiate(window.wasmCode, importObject)).instance;\nwindow.wasmCode = undefined;" ) .replace( "const importObject = {",