defmodule PhoenixLiveDebugConsole do @moduledoc false use Phoenix.LiveView import Phoenix.LiveView.Helpers import Phoenix.HTML, only: [javascript_escape: 1, raw: 1] import Phoenix.HTML.Tag, only: [csrf_meta_tag: 0] import Underthehood js_path = Path.join(__DIR__, "../dist/static/assets/app.js") css_path = Path.join(__DIR__, "../dist/static/assets/app.css") @external_resource js_path @external_resource css_path @app_js File.read!(js_path) @app_css File.read!(css_path) def mount(_params, session, socket) do socket = assign(socket, js_code_path: session["js_code_path"], css_path: session["css_path"] ) {:ok, socket} end def render(assigns) do assigns = assigns |> Map.put(:app_js, @app_js) |> Map.put(:app_css, @app_css) ~H""" <%= csrf_meta_tag() %> <.terminal/> """ end def render_console(conn, _status, _kind, _reason, _stack) do markup = conn |> live_render(__MODULE__, session: %{}, container: {:html, []}) |> Phoenix.HTML.safe_to_string() """
IEx Terminal
""" end end