PhoenixAssets. Engine
(PhoenixAssets v0.1.0)
View Source
Initialises plugins and collects their declarations.
The engine is the single place that turns a PhoenixAssets.Context (which
carries the resolved-but-uninitialised plugin list) into initialised plugins,
and gathers a given callback across all of them in order. The generators, the
graph builder, the dev supervisor, and the doctor all build on these two
primitives so plugin initialisation happens exactly once per operation and in
the resolved order.
Summary
Types
A plugin after initialisation: {module, opts, state}.
Functions
Calls callback/2 on every initialised plugin and concatenates the results.
Calls callback/2 on every initialised plugin and deep-merges the returned
maps.
Initialises every plugin in the context, in resolved order.
Types
Functions
@spec collect(PhoenixAssets.Context.t(), [initialized()], atom()) :: [term()]
Calls callback/2 on every initialised plugin and concatenates the results.
callback is one of the list-returning PhoenixAssets.Plugin callbacks
(:generated_files, :dev_processes, :graph_entries, :doctor_checks).
Each plugin receives (ctx, state).
@spec collect_map(PhoenixAssets.Context.t(), [initialized()], atom()) :: map()
Calls callback/2 on every initialised plugin and deep-merges the returned
maps.
Plugins are visited in resolved order and a later plugin wins on key
conflicts, so overrides follow the same deterministic ordering as every
other collection. Used for the map-returning :vite_config callback.
@spec init_plugins(PhoenixAssets.Context.t()) :: {:ok, [initialized()]} | {:error, {module(), term()}}
Initialises every plugin in the context, in resolved order.
Returns {:ok, initialized} or {:error, {plugin_module, reason}} on the
first plugin whose PhoenixAssets.Plugin.init/2 fails.