diff --git a/.gitignore b/.gitignore
index a7a57a6..1966505 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,6 @@ build/
# MacOS
.DS_Store
+
+#lockfile
+deno.lock
\ No newline at end of file
diff --git a/examples/bind.ts b/examples/bind.ts
index 30d19a4..9cda3cd 100644
--- a/examples/bind.ts
+++ b/examples/bind.ts
@@ -13,7 +13,7 @@ const html = `
const webview = new Webview();
-webview.navigate(`data:text/html,${encodeURIComponent(html)}`);
+webview.setHTML(html);
let counter = 0;
webview.bind("press", (a, b, c) => {
diff --git a/examples/local.ts b/examples/local.ts
index e264cd7..cfb24ff 100644
--- a/examples/local.ts
+++ b/examples/local.ts
@@ -10,5 +10,5 @@ const html = `
const webview = new Webview();
-webview.navigate(`data:text/html,${encodeURIComponent(html)}`);
+webview.setHTML(html);
webview.run();
diff --git a/examples/ssr/main.ts b/examples/ssr/main.ts
index 2138003..1064360 100644
--- a/examples/ssr/main.ts
+++ b/examples/ssr/main.ts
@@ -1,4 +1,4 @@
-import { dirname, join } from "https://deno.land/std@0.157.0/path/mod.ts";
+import { dirname, join } from "https://deno.land/std@0.197.0/path/mod.ts";
import { Webview } from "../../mod.ts";
const worker = new Worker(
diff --git a/examples/ssr/worker.tsx b/examples/ssr/worker.tsx
index f0f089a..de4d68f 100644
--- a/examples/ssr/worker.tsx
+++ b/examples/ssr/worker.tsx
@@ -4,7 +4,6 @@
///
///
-import { serve } from "https://deno.land/std@0.157.0/http/server.ts";
import { h, ssr, tw } from "https://crux.land/nanossr@0.0.1";
const Hello = (props: { name: string }) => (
@@ -15,12 +14,11 @@ const Hello = (props: { name: string }) => (
);
-const server = serve((req) => {
+Deno.serve({ port: 8000 }, (req) => {
console.log(req);
const url = new URL(req.url);
const name = url.searchParams.get("name") ?? "world";
return ssr(() => );
-}, { port: 8000 });
+});
console.log("[runner] Listening on http://localhost:8000");
-await server;
diff --git a/examples/user_agent.ts b/examples/user_agent.ts
index a3cd16a..6e4bea8 100644
--- a/examples/user_agent.ts
+++ b/examples/user_agent.ts
@@ -10,5 +10,5 @@ const html = `
const webview = new Webview();
-webview.navigate(`data:text/html,${encodeURIComponent(html)}`);
+webview.setHTML(html);
webview.run();
diff --git a/src/ffi.ts b/src/ffi.ts
index ea7799b..aa610b3 100644
--- a/src/ffi.ts
+++ b/src/ffi.ts
@@ -142,7 +142,7 @@ export const lib = await dlopen(
result: "void",
},
"webview_set_html": {
- parameters: ["pointer", "pointer"],
+ parameters: ["pointer", "buffer"],
result: "void",
},
"webview_init": {
diff --git a/src/webview.ts b/src/webview.ts
index d20f091..7e5e87d 100644
--- a/src/webview.ts
+++ b/src/webview.ts
@@ -227,6 +227,16 @@ export class Webview {
);
}
+ /**
+ * Sets the current HTML of the webview to the given `html` string.
+ */
+ setHTML(html: string) {
+ lib.symbols.webview_set_html(
+ this.#handle,
+ encodeCString(html),
+ );
+ }
+
/**
* Runs the main event loop until it's terminated. After this function exits
* the webview is automatically destroyed.
diff --git a/webview b/webview
index 2ee04cc..5958ba2 160000
--- a/webview
+++ b/webview
@@ -1 +1 @@
-Subproject commit 2ee04ccd0530e3928a872f5d508c114403803e61
+Subproject commit 5958ba2c1ea4ce60dab7826e3d2fce1c480ac019