mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-12-09 13:16:08 +08:00
* Prototype standalone mode with mix * Move runtime initialization into separate LiveViews * Make standalone node initialization async * Refactor async node initialization * Automatically scroll to the bottom of output * Refactor streaming output * Move MessageEmitter under Utils * Add path selector to the mix runtime picker * Update runtime descriptions * Add successful or error message at the end of output * Run formatter * Rename Standalone to ElixirStandalone for consistency * Show only directories when looking for a mix project * Update docs * Extract shared standalone logic * Make the remote primary process monitor Manager instead of session * Further refactoring and docs * Add tests for collectable Callback * Add missing macro doc * Apply review suggestions * Decouple sending asynchronous notifications from the runtime initialization * Apply suggestions
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
import "../css/app.css";
|
|
|
|
import "phoenix_html";
|
|
import { Socket } from "phoenix";
|
|
import NProgress from "nprogress";
|
|
import { LiveSocket } from "phoenix_live_view";
|
|
import ContentEditable from "./content_editable";
|
|
import Cell from "./cell";
|
|
import Session from "./session";
|
|
import FocusOnUpdate from "./focus_on_update";
|
|
import ScrollOnUpdate from "./scroll_on_update";
|
|
|
|
const Hooks = {
|
|
ContentEditable,
|
|
Cell,
|
|
Session,
|
|
FocusOnUpdate,
|
|
ScrollOnUpdate,
|
|
};
|
|
|
|
const csrfToken = document
|
|
.querySelector("meta[name='csrf-token']")
|
|
.getAttribute("content");
|
|
|
|
const liveSocket = new LiveSocket("/live", Socket, {
|
|
params: { _csrf_token: csrfToken },
|
|
hooks: Hooks,
|
|
});
|
|
|
|
// Show progress bar on live navigation and form submits
|
|
window.addEventListener("phx:page-loading-start", (info) => NProgress.start());
|
|
window.addEventListener("phx:page-loading-stop", (info) => NProgress.done());
|
|
|
|
// connect if there are any LiveViews on the page
|
|
liveSocket.connect();
|
|
|
|
// expose liveSocket on window for web console debug logs and latency simulation:
|
|
// >> liveSocket.enableDebug()
|
|
// >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session
|
|
// >> liveSocket.disableLatencySim()
|
|
window.liveSocket = liveSocket;
|