Pure helpers for applying the Dala LiveView bridge patches to a freshly generated Phoenix project.
These are duplicated from DalaDev.Enable (which lives in dala_dev, a separate
package) to keep dala_new self-contained as a Mix archive with no runtime deps
on dala_dev.
What gets patched
assets/js/app.js—DalaHookdefinition inserted after the last import, andDalaHookregistered in theLiveSockethooks:option.lib/<app>_web/components/layouts/root.html.heex— hidden<div id="dala-bridge" phx-hook="DalaHook">inserted after<body>.lib/<app>/dala_screen.ex— generated (theDala.Screenthat opens the WebView).dala.exs—liveview_port: 4000added.mix.exs— dala / dala_dev deps injected into thedeps/0function.lib/<app>/application.ex—Dala.Appchild started in the supervision tree.
Summary
Functions
Generates lib/<app>_web/live/about_live.ex.
Returns the hidden bridge element string (for test assertions).
Generates dala.exs config content for a LiveView project.
Generates the dala_app.ex entry point for a LiveView project.
Generates the DalaScreen source file content for the given module name.
Generates the Erlang bootstrap for a LiveView project.
Injects the hidden bridge <div> immediately after the opening <body> tag.
Injects the DalaHook definition and registration into the given app.js content.
Injects dala / dala_dev dependencies into the deps/0 function in mix.exs content.
Generates the LiveView-specific ios/build.sh content.
Generates the create_notes Ecto migration.
Generates lib/<app>/note.ex — the Note Ecto schema.
Generates lib/<app>_web/live/note_editor_live.ex.
Generates lib/<app>/notes.ex — the Notes context with seed data.
Generates lib/<app>_web/live/notes_list_live.ex.
Generates lib/<app>_web/live/page_live.ex — a minimal starter LiveView
that replaces the default PageController route.
Generates lib/<app>/repo.ex — Ecto.Repo backed by SQLite3.
Functions
Generates lib/<app>_web/live/about_live.ex.
Returns the hidden bridge element string (for test assertions).
Generates dala.exs config content for a LiveView project.
Generates the dala_app.ex entry point for a LiveView project.
This module is called from the Erlang bootstrap (src/app_name.erl) instead
of a native Dala.App module. It starts the Phoenix OTP application (which
boots the endpoint) and then starts DalaScreen to open the WebView.
Unlike native Dala apps, this does NOT use Dala.App — Phoenix owns the
supervision tree. Dala is wired in at the BEAM entry level only.
secret_key_base and signing_salt are embedded directly because Mix config
files (config/*.exs) are not loaded on-device — Application.put_env/3 is
the only way to configure the endpoint before ensure_all_started/1 runs.
Port 4200 avoids conflicts with a host mix phx.server on 4000.
Generates the DalaScreen source file content for the given module name.
Generates the Erlang bootstrap for a LiveView project.
Calls ModuleName.DalaApp.start() instead of ModuleName.App.start().
Injects the hidden bridge <div> immediately after the opening <body> tag.
Idempotent: returns unchanged content if dala-bridge is already present.
Injects the DalaHook definition and registration into the given app.js content.
Idempotent: returns unchanged content if DalaHook is already present.
Injects dala / dala_dev dependencies into the deps/0 function in mix.exs content.
dala_dep and dala_dev_dep are the dependency tuple strings (already formatted).
Idempotent: no-op if :dala is already present.
Generates the LiveView-specific ios/build.sh content.
Key differences from the native build.sh:
- Copies ALL compiled deps (Phoenix, Plug, Bandit, etc.) with a glob loop
- Ships a full crypto shim: pbkdf2_hmac/5, exor/2, HMAC-MD5 via erlang:md5/1
- Copies pure-Erlang ssl beams from host OTP (thousand_island requires :ssl)
- Builds and deploys JS/CSS assets to BEAMS_DIR/priv/static/ so Plug.Static can serve them (code:priv_dir(:app) resolves relative to the flat BEAMS_DIR)
- No exqlite NIF cross-compile (no Ecto in LiveView projects)
Generates the create_notes Ecto migration.
Generates lib/<app>/note.ex — the Note Ecto schema.
Generates lib/<app>_web/live/note_editor_live.ex.
Generates lib/<app>/notes.ex — the Notes context with seed data.
Generates lib/<app>_web/live/notes_list_live.ex.
Generates lib/<app>_web/live/page_live.ex — a minimal starter LiveView
that replaces the default PageController route.
Generates lib/<app>/repo.ex — Ecto.Repo backed by SQLite3.