Pear API Base & Integration Module
Status: WIP
Supplies the API base for the Pear API (https://docs.pears.com/pear-runtime/api).
Typically for extending from for user-interface-runtime purposes:
const Worker = require('pear-api/worker')
class API extends require('pear-api') {
constructor (ipc, state, { worker, teardown } = {}) {
super(ipc, state, { worker, teardown })
this[this.constructor.UI] = new UIAPI()
}
}
const worker = new Worker()
global.Pear = new API(ipc, state, { worker })
This creates the usual global.Pear
API with the interface-runtime-specific UIAPI
stored on a symbolic reference so it can later be exported from interface module entrypoint. The global.Pear.worker
API can also be customized by extending pear-api/worker
and passing an instance of the extended worker to API
.
The pear-api
module also exposes libraries that provide platform core functionality.
Platform constants.
Platform gunk - glue-state for native and protocol integration.
Base State
class for cross-process state management.
Platform error types. Includes known
method for checking if error is recognized.
Sets up crash handlers and outputs crash logs to a known location on-disk.
Attempt to boot the sidecar. Useful when establishing a pear-ipc
connection from an interface-runtime to Pear Sidecar, pass it as the connect
option.
Internal class, pass this (or a subclass of it) to the pear-api
API
constructor for Pear.run
to use.
Parse pear://
links per pear-link
.
The Pear.teardown
function.
A minimal transformer for __LOCALVAR__
-style templates.
Parse out platform flags while ignoring the rest of the command. Useful for parsing platform flags regardless of whether the flags after <cmd>
are valid.
Paparam definition array for the pear
command. Useful for parsing platform flags passed to an interface-runtime.
Paparam definition array for the pear run
command. Useful for parsing run flags passed to an interface-runtime.
Apache 2.0