caraml is a native mobile UI markup language designed for running native micro-apps on Android and iOS from node.js instances. It is built on top of LiquidCore, a library which provides node-based virtual machines on mobile devices.
caraml is very much a work in progress.
caraml-console is a UI surface for use with caraml. It provides an ANSI-compatible Node.js console that can interact with a LiquidCore micro service. This surface is most useful for debugging.
To integrate, clients must instantiate a CaramlView
as described in the caraml-core
project.
Follow the directions for installing LiquidCore from npm
.
$ npm install @liquidcore/caraml-console
$ npm install
The second npm install
triggers a post-install script in your project that will automatically set up caraml-console
into your build.
The caraml-console
module provides an ANSI-compatible console surface for use with LiquidCore and caraml.
It can be accessed using:
const Console = require('@liquidcore/caraml-console')
Example usage:
const core = require('@liquidcore/caraml-core')
const Console = require('@liquidcore/caraml-console')
// Stop process from exiting
setInterval(()=>{},1000)
let cons = new Console({
fontSize : 11,
backgroundColor: 'black',
textColor: '#32cd32'
})
cons.display(core)
.then(()=>{
console.error('Welcome to caraml-console')
console.log('Enter javascript commands and play around.')
console.log()
})
.catch(e => {
console.error(e)
})
The Console class instance represents a console view that can be attached and detached to a caraml-core view.
Kind: global class
- Console
- new Console([opts])
- .display([caramlview]) ⇒
Promise
- .hide() ⇒
Promise
- .getParent() ⇒
Object
- .getState() ⇒
string
- "ready"
- "attached"
- "detached"
- "error"
- .Transform ⇒
String
Creates a new console that will redirect stderr and stdout through it. Multiple consoles will be chained, i.e. the output streams will pass through all console instances.
Param | Type | Description |
---|---|---|
[opts] | Object |
|
[opts.textColor] | string |
An html-like description of text color, e.g. 'black' or '#ed5616' |
[opts.backgroundColor] | string |
An html-like description of background color |
[opts.fontSize] | number |
A floating-point font point size |
[opts.transformStdout] | Transform |
A function to transform output string being sent to stdout |
[opts.transformStderr] | Transform |
A function to transform output strings being sent to stderr |
Requests the console to be displayed (attached) on a caraml-core view. If no caramlview is provided, the default core view will be used.
Kind: instance method of Console
Returns: Promise
- Promise which is resolved when the view is attached, or rejected with an error string
Param | Type | Description |
---|---|---|
[caramlview] | Object |
A caraml-core view object obtained through var core = require('@liquidcore/caraml-core') |
Detaches a previously displayed console.
Kind: instance method of Console
Returns: Promise
- Resolved when the view is attached, or rejected with an error string
Returns the parent caraml-core view
Kind: instance method of Console
Returns: Object
- The caraml-core view to which the console is attached or undefined if not attached
Returns one of 'init', 'detached', 'attaching', 'attached', 'detaching'
Kind: instance method of Console
Returns: string
- The current state of the console
Emitted when the console view has been created and is ready to be attached to a caraml-core view.
Kind: event emitted by Console
Emitted when the console view has been attached to a caraml-core view.
Kind: event emitted by Console
Emitted when the console view has been detached from a caraml-core view.
Kind: event emitted by Console
Emitted on error
Kind: event emitted by Console
Type | Description |
---|---|
string |
A human-readable error string |
A function to transform output string, e.g. to add coloring with ANSI tags.
Kind: instance typedef of Console
Returns: String
- Transformed string
Param | Type | Description |
---|---|---|
input | String |
Input string |