# Wren Book ```elixir Mix.install([ {:kino, "~> 0.6.1"}, {:temp, "~> 0.4"} ]) ``` ## About Wren Think Smalltalk in a Lua-sized package with a dash of Erlang and wrapped up in a familiar, modern syntax. See more at https://wren.io/ ## Configuration Choose the binary file to execute Wren Scripts ```elixir defmodule Wren do # Binary Name # Currently using https://github.com/joshgoebel/wren-console/releases/tag/v0.3.1 # since it has more built in libraries @unix "wrenc" @macos "wrenc-mac" @windows "wrenc.exe" # Choose platform @current @macos def path(executable \\ @current) do Path.expand("#{__DIR__}/./bin/#{executable}") end def unix() do path(@unix) end def windows() do path(@windows) end def macos() do path(@macos) end end ``` ## Wren Cell Defines how Wren Scripts are executed. ```elixir defmodule KinoGuide.WrenCell do use Kino.JS use Kino.JS.Live use Kino.SmartCell, name: "Wren script" @impl true def init(_attrs, ctx) do {:ok, ctx, editor: [attribute: "source", language: "javascript"]} end @impl true def handle_connect(ctx) do {:ok, %{}, ctx} end @impl true def to_attrs(_ctx) do %{} end @impl true def to_source(attrs) do quote do path = Temp.path!() File.write!(path, unquote(attrs["source"])) System.shell( """ trap "rm -f #{path}" 0 2 3 15 #{Wren.path()} #{path} """, into: IO.stream(), stderr_to_stdout: true ) |> elem(1) end |> Kino.SmartCell.quoted_to_string() end asset "main.js" do """ export function init(ctx, payload) { ctx.importCSS("main.css"); root.innerHTML = `