0.2.2 • Published 5 years ago

@liquidcore/caraml-console v0.2.2

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

caraml

Download

NPM

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

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.

Step 1: Install LiquidCore

Follow the directions for installing LiquidCore from npm.

Step 2: Install caraml-console

$ 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.

JavaScript API

caraml Console

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)
})

Console

The Console class instance represents a console view that can be attached and detached to a caraml-core view.

Kind: global class

new Console(opts)

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.

ParamTypeDescription
optsObject
opts.textColorstringAn html-like description of text color, e.g. 'black' or '#ed5616'
opts.backgroundColorstringAn html-like description of background color
opts.fontSizenumberA floating-point font point size
opts.transformStdoutTransformA function to transform output string being sent to stdout
opts.transformStderrTransformA function to transform output strings being sent to stderr

console.display(caramlview) ⇒ Promise

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

ParamTypeDescription
caramlviewObjectA caraml-core view object obtained through var core = require('@liquidcore/caraml-core')

console.hide() ⇒ Promise

Detaches a previously displayed console.

Kind: instance method of Console
Returns: Promise - Resolved when the view is attached, or rejected with an error string

console.getParent() ⇒ Object

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

console.getState() ⇒ string

Returns one of 'init', 'detached', 'attaching', 'attached', 'detaching'

Kind: instance method of Console
Returns: string - The current state of the console

"ready"

Emitted when the console view has been created and is ready to be attached to a caraml-core view.

Kind: event emitted by Console

"attached"

Emitted when the console view has been attached to a caraml-core view.

Kind: event emitted by Console

"detached"

Emitted when the console view has been detached from a caraml-core view.

Kind: event emitted by Console

"error"

Emitted on error

Kind: event emitted by Console

TypeDescription
stringA human-readable error string

console.Transform ⇒ String

A function to transform output string, e.g. to add coloring with ANSI tags.

Kind: instance typedef of Console
Returns: String - Transformed string

ParamTypeDescription
inputStringInput string
0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

6 years ago