Sha256: 5dc7f9337e48936d6f02a987c95c7cf7dc5958df58e2b4c11a7ed477e1f0a038
Contents?: true
Size: 1.21 KB
Versions: 9
Compression:
Stored size: 1.21 KB
Contents
module Hyperstack module Internal module Component module Rails class ComponentLoader attr_reader :v8_context private :v8_context def initialize(v8_context) unless v8_context raise ArgumentError.new('Could not obtain ExecJS runtime context') end @v8_context = v8_context end def load(file = components) return true if loaded? !!v8_context.eval(opal(file)) end def load!(file = components) return true if loaded? self.load(file) ensure raise "No Hyperstack components found in #{components}" unless loaded? end def loaded? !!v8_context.eval('Opal.Hyperstack !== undefined') rescue ::ExecJS::Error false end private def components opts = ::Rails.configuration.react.server_renderer_options return opts[:files].first.gsub(/.js$/,'') if opts && opts[:files] 'components' end def opal(file) Opal::Sprockets.load_asset(file) end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems