Draft: ui: Refactor main to be class-based, add getShell() global utility
Context
When ESM (ECMAScript Modules) land, it will no longer be possible
to treat imports.ui.main
as an object where properties (exports)
can be re-assigned. To handle this change, imports.ui.main
is
refactored into a GnomeShell
class which is the instantiated as a
singleton in shell.js
. shell.js
uses a proxy to allow for circular
references, this emulates how ES module imports are "live" and can be
updated.
ECMAScript Modules are entirely asynchronous so to ensure
shell
/GnomeShell
can be conditionally accessed synchronously outside
of the imports system (e.g. in looking glass, extension utilities,
etc.), add global.getShell() to retrieve the "shell" object in these
contexts.
Notes
This MR refactors all imports of imports.ui.main
and usages of Main.
, each of these imports will already be refactored when ESM is landed.