Class: Lilac::CLI::ComponentScriptsAssembler
- Inherits:
-
Object
- Object
- Lilac::CLI::ComponentScriptsAssembler
- Defined in:
- lib/lilac/cli/build/component_scripts_assembler.rb
Overview
Per-page assembly of the Ruby source one bundle script contains:
the user-authored <script> body of every component used on the
page. Binding is scanner-canonical (the runtime scanner wires
data-* at mount), so no Lilac::Bindings::<Class> codegen is
emitted here — this class only runs CrossRefLinter (to surface
signal/method mismatches as build errors) and returns the user
script unchanged.
Used only by PageCompiler (per-page injection). The :bundle
delivery writer takes a leaner path through BundleAssetWriter
because the bundle file gathers ALL components rather than the
"used on this page" subset, and skips the lint pass entirely.
Instance Method Summary collapse
-
#assemble(used_names, components, synthesized_names:, page_inline_scripts:) ⇒ Object
Returns
Array<String>— one Ruby source chunk per component that had a non-empty user script. -
#initialize(template_cache:) ⇒ ComponentScriptsAssembler
constructor
A new instance of ComponentScriptsAssembler.
Constructor Details
#initialize(template_cache:) ⇒ ComponentScriptsAssembler
Returns a new instance of ComponentScriptsAssembler.
21 22 23 |
# File 'lib/lilac/cli/build/component_scripts_assembler.rb', line 21 def initialize(template_cache:) @template_cache = template_cache end |
Instance Method Details
#assemble(used_names, components, synthesized_names:, page_inline_scripts:) ⇒ Object
Returns Array<String> — one Ruby source chunk per component
that had a non-empty user script. Order matches used_names
so that any user-side dependency on declaration order (e.g.
subclass after parent) is preserved across the bundle.
synthesized_names marks components that originate from a
page-inline <X data-component=...> (their comp.script slot
is empty by construction; the actual class body lives in the
page's <script type="text/ruby"> blocks). For those the
cross-ref linter reads the page-level inline Ruby instead so
@signal / def method lookups resolve.
36 37 38 39 40 41 |
# File 'lib/lilac/cli/build/component_scripts_assembler.rb', line 36 def assemble(used_names, components, synthesized_names:, page_inline_scripts:) synth_lint_script = page_inline_scripts.join("\n\n") used_names.map do |name| assemble_one(name, components[name], synthesized_names, synth_lint_script) end.reject(&:empty?) end |