mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-02-22 13:53:23 +08:00
22 lines
628 B
Elixir
22 lines
628 B
Elixir
defmodule LivebookWeb.Output.JSComponent do
|
|
use LivebookWeb, :live_component
|
|
|
|
@impl true
|
|
def render(assigns) do
|
|
~H"""
|
|
<div id={"js-output-#{@id}-#{@info.ref}"}
|
|
phx-hook="JSOutput"
|
|
phx-update="ignore"
|
|
data-ref={@info.ref}
|
|
data-assets-base-path={Routes.session_path(@socket, :show_asset, @session_id, @info.assets.hash, [])}
|
|
data-js-path={@info.assets.js_path}
|
|
data-session-token={session_token(@info.pid)}
|
|
data-session-id={@session_id}>
|
|
</div>
|
|
"""
|
|
end
|
|
|
|
defp session_token(pid) do
|
|
Phoenix.Token.sign(LivebookWeb.Endpoint, "js output", %{pid: pid})
|
|
end
|
|
end
|