cycle-classic-dom
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -31,3 +31,3 @@ "use strict"; | ||
data$: data$, | ||
vnode: readme_1.makeElement(function (el) { | ||
vnode: readme_1.makeVNode(function (el) { | ||
term.open(el); | ||
@@ -34,0 +34,0 @@ term.refresh(0, term.rows - 1); |
@@ -0,3 +1,14 @@ | ||
/** | ||
* cycle-classic-dom | ||
* ------------------- | ||
* | ||
* A tiny helper library for working with classic JS libraries. | ||
* | ||
* That is to say, any JS library that works by taking a reference | ||
* to an element and manipulating the DOM directly. | ||
* | ||
* `npm install cycle-classic-dom` | ||
*/ | ||
import { VNode } from "@cycle/dom"; | ||
export declare type Constructor = (el: HTMLElement) => void; | ||
export declare function makeElement(ctor: Constructor): VNode; | ||
export declare function makeVNode(ctor: Constructor): VNode; |
"use strict"; | ||
/** | ||
* cycle-classic-dom | ||
* ------------------- | ||
* | ||
* A tiny helper library for working with classic JS libraries. | ||
* | ||
* That is to say, any JS library that works by taking a reference | ||
* to an element and manipulating the DOM directly. | ||
* | ||
* `npm install cycle-classic-dom` | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var dom_1 = require("@cycle/dom"); | ||
function makeElement(ctor) { | ||
function makeVNode(ctor) { | ||
return dom_1.div({ | ||
@@ -10,2 +21,29 @@ key: Math.random().toString(), | ||
} | ||
exports.makeElement = makeElement; | ||
exports.makeVNode = makeVNode; | ||
/** | ||
* Example, sets up a simple xterm.js powered terminal: | ||
* | ||
* import { makeVNode } from 'cycle-classic-dom'; | ||
* import { makeDOMDriver } from '@cycle/dom'; | ||
* import { Terminal } from 'xterm' | ||
* import xs from 'xstream'; | ||
* | ||
* function main() { | ||
* const terminal = new Terminal(); | ||
* | ||
* terminal.write("Hello from \x1B[1;3;31mxterm.js\x1B[0m $ "); | ||
* | ||
* const terminalVNode = makeVNode(element => { | ||
* terminal.open(element); | ||
* terminal.refresh(0, terminal.rows - 1); | ||
* }); | ||
* | ||
* return { | ||
* DOM: xs.of(terminalVNode) | ||
* } | ||
* } | ||
* | ||
* run(main, {DOM: makeDOMDriver(document.body)}); | ||
* | ||
* For a larger example including capturing output, see the example directory | ||
*/ |
{ | ||
"name": "cycle-classic-dom", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "", | ||
@@ -10,3 +10,4 @@ "main": "lib/readme.js", | ||
"lib": "tsc", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"prepublish": "npm run lib" | ||
}, | ||
@@ -13,0 +14,0 @@ "keywords": [], |
13677
310