Pear User-Interface Library for Electron
> Pear User-Interface Library for Electron
``sh`
npm install pear-electron
pear configuration object contains a pre field pointing to pear-electron/pre.`js
{
"pear": {
"pre": "pear-electron/pre"
}
}
`Instantiate a
pear-electron runtime instance from a Pear Application's entrypoint JavaScript file:`js
import Runtime from 'pear-electron'
import Bridge from 'pear-bridge'const runtime = new Runtime()
const bridge = new Bridge()
await bridge.ready()
const pipe = runtime.start({ bridge })
Pear.teardown(() => pipe.end())
`Call
runtime.start to open the UI.> NOTE: naming the import
Runtime instead of PearElectron is intentional, for two reasons. The pear-electron import resolves to a runtime start library or a User Interface library depending on environment and using Runtime and ui as assigned names means switching out pear-electron with an equivalent alternative only involves changing the two pear-electron import specifiers.Given an
index.html containing in app.js import pear-electron User Interface API:`js
import ui from 'pear-electron'
`Application Configuration
pear.pre to pear-electron/pre (or ensure that it's imported at the top of any alternative pre script).
`json
{
"pear": {
"pre": "pear-electron/pre"
}
}`Prior to run from disk and prior to run from key, the
pear-electron/pre script automatically adjusts application configuration to include runtime binary pear.assets as well as adding statically analyzed script tags as pear.stage.entrypoints from the pear.gui.main HTML entrypoint.The application
package.json pear field can also define its own pear.assets.Initialization API
$3
Create the runtime instances with
new Runtime().$3
Prepare the runtime, runtime binaries for the runtime version may be bootstrapped peer-to-peer at this point. This only runs once per version and any prior bootstraps can be reused for subsequent versions where state hasn't changed. In a production scenario any bootstrapping would be performed in advance by the application distributable.
$3
Opens the UI.
#### Options
*
bridge - An instance of pear-bridge.User-Interface API
Inside the
pear-electron runtime desktop application, pear-electron resolves to a UI control API.index.html:
`html