defmodule Mf2WasmEditor do @moduledoc """ Browser-side MF2 syntax highlighter for Phoenix LiveView apps. Ships three things: * The web-tree-sitter runtime (`tree-sitter.js`, `tree-sitter.wasm`). * The compiled `tree-sitter-mf2` grammar (`tree-sitter-mf2.wasm`). * A Phoenix LiveView hook (`mf2_editor.js`) that wires a transparent textarea + highlighted `
` into the grammar,
      highlighting and surfacing diagnostics on every keystroke —
      with no server round trip.

  The assets live under `priv/static/` inside this package. Consumers
  serve them as-is via `Plug.Static` (or equivalent) and include them
  with two `\\n) <>
        ~s()

      iex> Mf2WasmEditor.script_tags(base_url: "/assets/mf2")
      ~s(\\n) <>
        ~s()

  """
  @spec script_tags(keyword()) :: binary()
  def script_tags(options \\ []) do
    base_url = Keyword.get(options, :base_url, "/mf2_editor")

    ~s(\n) <>
      ~s()
  end

  @doc """
  File names served from `priv/static/`. Pass to
  `Plug.Static`'s `:only` option so nothing else in the package is
  exposed.

  ### Examples

      iex> Mf2WasmEditor.static_paths()
      ["highlights.scm", "mf2_editor.js", "tree-sitter-mf2.wasm",
       "tree-sitter.js", "tree-sitter.wasm"]

  """
  @spec static_paths() :: [String.t()]
  def static_paths do
    ~w(highlights.scm mf2_editor.js tree-sitter-mf2.wasm
       tree-sitter.js tree-sitter.wasm)
  end
end