Module: Three::Browser

Defined in:
lib/three/browser.rb

Defined Under Namespace

Classes: Application, Element, Error, Storage

Class Method Summary collapse

Class Method Details

.documentObject



301
302
303
# File 'lib/three/browser.rb', line 301

def document
  global[:document]
end

.globalObject



316
317
318
# File 'lib/three/browser.rb', line 316

def global
  js
end

.jsObject



309
310
311
312
313
314
# File 'lib/three/browser.rb', line 309

def js
  require "js"
  JS.global
rescue LoadError
  raise Error, "Three::Browser.js requires ruby.wasm's js gem"
end

.ready!Object



295
296
297
298
299
# File 'lib/three/browser.rb', line 295

def ready!
  ready = global[:__threeReady]
  ready.await if ready.respond_to?(:await)
  self
end

.run(**options) ⇒ Object



281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/three/browser.rb', line 281

def run(**options)
  app = nil
  begin
    install_runtime_extensions
    app = Application.new(**options)
    result = yield app
    app.running!
    result
  rescue StandardError => error
    app ? app.boot_failed(error.message) : notify_boot_failed(error.message)
    raise
  end
end

.windowObject



305
306
307
# File 'lib/three/browser.rb', line 305

def window
  global[:window]
end