class ViteRuby

def bootstrap

Internal: Refreshes the manifest.
def bootstrap
  instance.manifest.refresh
end

def builder

Public: Keeps track of watched files and triggers builds as needed.
def builder
  @builder ||= ViteRuby::Builder.new(self)
end

def commands

Internal: Helper to run commands related with Vite.
def commands
  @commands ||= ViteRuby::Commands.new(self)
end

def config

Public: Current instance configuration for Vite.
def config
  unless defined?(@config)
    configure
    @config.load_ruby_config
  end
  @config
end

def configure(**options)

Public: Allows overriding the configuration for this instance.
def configure(**options)
  @config = ViteRuby::Config.resolve_config(**@config_options, **options)
end

def dev_server_running?

NOTE: Checks only once every second since every lookup calls this method.
Public: Returns true if the Vite development server is currently running.
def dev_server_running?
  return false unless run_proxy?
  return @running if defined?(@running) && Time.now - @running_checked_at < 1
  begin
    Socket.tcp(config.host, config.port, connect_timeout: config.dev_server_connect_timeout).close
    @running = true
  rescue
    @running = false
  ensure
    @running_checked_at = Time.now
  end
end

def digest

changes. Useful to perform version checks in single-page applications.
Public: Returns a digest of all the watched files, allowing to detect
def digest
  builder.send(:watched_files_digest)
end

def env

ViteRuby.env['VITE_RUBY_CONFIG_PATH'] = 'config/alternate_vite.json'
Example:

Public: Additional environment variables to pass to Vite.
def env
  @env ||= ENV.select { |key, _| key.start_with?(ENV_PREFIX) }
end

def framework_libraries

variant of Vite Ruby.
Internal: Detects if the application has installed a framework-specific
def framework_libraries
  COMPANION_LIBRARIES.filter_map { |name, framework|
    if library = Gem.loaded_specs[name]
      [framework, library]
    end
  }
end

def initialize(**config_options)

def initialize(**config_options)
  @config_options = config_options
end

def install_tasks

Internal: Loads all available rake tasks.
def install_tasks
  load File.expand_path("tasks/vite.rake", __dir__)
end

def instance

def instance
  @instance ||= new
end

def logger

def logger
  @logger ||= Logger.new($stdout)
end

def manifest

Public: Enables looking up assets managed by Vite using name and type.
def manifest
  @manifest ||= ViteRuby::Manifest.new(self)
end

def reload_with(**config_options)

Internal: Creates a new instance with the specified options.
def reload_with(**config_options)
  @instance = new(**config_options)
end

def run(argv, **options)

Internal: Executes the vite binary.
def run(argv, **options)
  (@runner ||= ViteRuby::Runner.new(self)).run(argv, **options)
end

def run_proxy?

Public: The proxy for assets should only run in development mode.
def run_proxy?
  config.mode == "development" || (config.mode == "test" && !ENV["CI"])
rescue => error
  logger.error("Failed to check mode for Vite: #{error.message}")
  false
end