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
  @config ||= ViteRuby::Config.resolve_config
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 true if defined?(@running_at) && @running_at && Time.now - @running_at < 1
  Socket.tcp(config.host, config.port, connect_timeout: config.dev_server_connect_timeout).close
  @running_at = Time.now
  true
rescue StandardError
  @running_at = false
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 ||= load_env_variables
end

def framework_libraries

variant of Vite Ruby.
Internal: Detects if the application has installed a framework-specific
def framework_libraries
  SUPPORTED_FRAMEWORKS.map { |framework|
    if library = Gem.loaded_specs["vite_#{ framework }"]
      [framework, library]
    end
  }.compact
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 ||= ViteRuby.new
end

def load_env_variables

Internal: Allows to obtain any env variables for configuration options.
def load_env_variables
  ENV.select { |key, _| key.start_with?(ENV_PREFIX) }
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(env_vars)

Internal: Refreshes the config after setting the env vars.
def reload_with(env_vars)
  env.update(env_vars)
  @instance = nil
  config
end

def run(argv, **options)

Internal: Executes the vite binary.
def run(argv, **options)
  ViteRuby::Runner.new(instance).run(argv, **options)
end

def run_proxy?

Public: The proxy for assets should only run in development mode.
def run_proxy?
  config.mode == 'development'
rescue StandardError => error
  logger.error("Failed to check mode for Vite: #{ error.message }")
  false
end