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.
The pear-api
module also exposes libraries that provide platform core functionality.
Platform constants.
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.
Logger class with only error
, info
, trace
log methods, supports log labels and default options honour pear --log*
and/or pear run --log*
flags.
level
<String>
- Level to log at. 0,1,2,3 (OFF,ERR,INF,TRC). Overridespear --log-level
. Default: 2 ifpear --log
else 0.labels
<String>
- Labels to log out. Mixes with user definedpear --log-labels
.fields
<String>
- Fields to show/hide.<field>
shows,h:<field>
hides. Overrides individu A278 alpear --log-fields
with defaulth:time,h:data,level,label,delta
.stacks
<Boolean>
- Print stack traces with all logs. Defaultpear --log-stacks
elsefalse
.pretty
<Boolean>
- Enables label field if more than 2 labels, disables level field default. Defaultfalse
.
OFF
- true if logging is offERR
- true if logging is at error levelINF
- true if logging is at info levelTRC
- true if logging is at trace levelLEVEL
- level: 0, 1,2,3
error(label, ...args)
- Logargs
at error level withlabel
info(label, ...args)
- Logargs
at info level withlabel
trace(label, ...args)
- Logargs
at trace level withlabel
switches
<Object>
- User specified according to--log*
flagslevel
:pear --log-level
labels
:pear --log-labels
fields
:pear --log-fields
stacks
:pear --log-stacks
log
:pear --log
Base State
class for cross-process state management.
Platform gunk - glue-state for native and protocol integration.
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.
opwait(stream, onstatus) -> Promise
. An op is an operation executed by pear sidecar represented by a status stream, commands such as dump, stage, seed, release & info are ops. The opwait
function returns a promise that waits for the stream to finish and resolves with the final
tagged object. The onstatus
function is called for each data
event on the stream.
Link parsing & normalizing of pear://
links using a pear-link
instance.
The Pear.teardown
function.
A minimal transformer for __LOCALVAR__
-style templates.
Terminal interface.
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