opal / opal-browser

Browser support for Opal.
MIT License
115 stars 36 forks source link

Cherry picking. #60

Closed meh closed 4 years ago

meh commented 8 years ago

Since everyone wants a more cherry-pickable opal-browser, and so do I, can we get some discussion going on how granular the cherry-picking should be?

Which parts of opal-browser are you using and which parts are getting included that you don't care about?

fazibear commented 8 years ago

The most important feature is Element with $document.[] method. Next one is events. All onclicks, keypresses etc. related to DOM.

Never used a builder that require paggio, so this one should be moved to separate module that is not required by default.

Otherwise this once I use frequently:

balmoral commented 8 years ago

Agree with last comment that Builder and Paggio should be separate.

Not currently using canvas, screen, css, database or event classes (directly).

Most used of course is document and node/element.

elia commented 8 years ago

For me too it's desirable to be able to leave out the DOM and CSSM DSLs, and maybe also make the events cherry-pickable, likely making them register themselves:

module Browser; class Event

class BeforeUnload < Event
  handle :beforeunload

  def self.supported?
    Browser.supports? 'Event.BeforeUnload'
  end

  if Browser.supports? 'Event.constructor'
    def self.construct(name, desc)
      `new BeforeUnloadEvent(#{name}, #{desc})`
    end
  end if supported?
end

end; end

and

  def self.class_for(name)
    handlers[name] || Custom
  end
hmdne commented 4 years ago

I think I did something about the issue. I did what @elia suggested and I made 4 possible require paths.

[user@localhost opal-browser]# opal -O -I ./opal --gem paggio --compile opal/browser.rb | wc -c
1351620
[user@localhost opal-browser]# opal -O -I ./opal --compile opal/browser/setup/large.rb | wc -c
1115893
[user@localhost opal-browser]# opal -O -I ./opal --compile opal/browser/setup/mini.rb | wc -c
651352
[user@localhost opal-browser]# opal -O -I ./opal --compile opal/browser/setup/base.rb | wc -c
82138
[user@localhost opal-browser]# 

"browser" is a traditional require path. It required what is required currently. "browser/setup/mini" doesn't include extraneous events, paggio (and native) "browser/setup/large" does what mini does, BUT it does require: