-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chris Nelson
committed
Oct 6, 2023
1 parent
7614bd4
commit d9a5169
Showing
9 changed files
with
654 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
elixir 1.14.2-otp-25 | ||
erlang 25.2 | ||
nodejs 16.13.1 | ||
rust 1.73.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
defmodule LivestateTestbedWeb.JsWasmChannel do | ||
use LiveState.Channel, web_module: LivestateTestbedWeb | ||
|
||
def init(_channel, _payload, socket) do | ||
manifest = %{wasm: [ %{ path: "priv/wasm/dist/plugin.wasm" } ] } | ||
{:ok, plugin} = Extism.Plugin.new(manifest, true) | ||
{:ok, initial_state} = Extism.Plugin.call(plugin, "init", "") | ||
{:ok, Jason.decode!(initial_state), socket |> assign(:plugin, plugin)} | ||
end | ||
|
||
def handle_event(event, payload, state, %{assigns: %{plugin: plugin}} = socket) do | ||
{:ok, new_state} = Extism.Plugin.call(plugin, event, Jason.encode!([payload, state])) | ||
{:noreply, Jason.decode!(new_state), socket} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const esbuild = require('esbuild'); | ||
|
||
esbuild | ||
.build({ | ||
entryPoints: ['src/index.js'], | ||
outdir: 'dist', | ||
bundle: true, | ||
sourcemap: true, | ||
minify: false, // might want to use true for production build | ||
format: 'cjs', // needs to be CJS for now | ||
target: ['es2020'] // don't go over es2020 because quickjs doesn't support it | ||
}) |
Oops, something went wrong.