https://github.com/liquidplayer/caraml-console
An ANSI console addon for caraml
https://github.com/liquidplayer/caraml-console
android caraml console ios liquidcore
Last synced: about 1 month ago
JSON representation
An ANSI console addon for caraml
- Host: GitHub
- URL: https://github.com/liquidplayer/caraml-console
- Owner: LiquidPlayer
- License: mit
- Created: 2019-01-08T10:29:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T02:28:22.000Z (over 3 years ago)
- Last Synced: 2025-06-03T11:29:32.561Z (12 months ago)
- Topics: android, caraml, console, ios, liquidcore
- Language: Java
- Size: 804 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
caraml
------
[](https://www.npmjs.com/package/@liquidcore/caraml-console)
[](https://nodei.co/npm/@liquidcore/caraml-console)
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](https://github.com/LiquidPlayer/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`](https://github.com/LiquidPlayer/caraml-core) project.
### Step 1: Install LiquidCore
Follow the [directions for installing LiquidCore from `npm`](https://github.com/LiquidPlayer/LiquidCore/blob/master/README.md#installation).
### Step 2: Install caraml-console
```bash
$ 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:
```javascript
const Console = require('@liquidcore/caraml-console')
```
Example usage:
```javascript
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](#Console) class instance represents a console view that can be attached and detached to a caraml-core
view.
**Kind**: global class
* [Console](#Console)
* [new Console([opts])](#new_Console_new)
* [.display([caramlview])](#Console+display) ⇒ Promise
* [.hide()](#Console+hide) ⇒ Promise
* [.getParent()](#Console+getParent) ⇒ Object
* [.getState()](#Console+getState) ⇒ string
* ["ready"](#Console+event_ready)
* ["attached"](#Console+event_attached)
* ["detached"](#Console+event_detached)
* ["error"](#Console+event_error)
* [.Transform](#Console+Transform) ⇒ String
### 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.
| 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](#Console+Transform) | A function to transform output string being sent to stdout |
| [opts.transformStderr] | [Transform](#Console+Transform) | A 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](#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') |
### console.hide() ⇒ Promise
Detaches a previously displayed console.
**Kind**: instance method of [Console](#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](#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](#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](#Console)
### "attached"
Emitted when the console view has been attached to a caraml-core view.
**Kind**: event emitted by [Console](#Console)
### "detached"
Emitted when the console view has been detached from a caraml-core view.
**Kind**: event emitted by [Console](#Console)
### "error"
Emitted on error
**Kind**: event emitted by [Console](#Console)
| Type | Description |
| --- | --- |
| string | A 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](#Console)
**Returns**: String - Transformed string
| Param | Type | Description |
| --- | --- | --- |
| input | String | Input string |