@cycle-robot-drivers/screen
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -38,3 +38,3 @@ "use strict"; | ||
} | ||
}).debug(); | ||
}); | ||
var action$ = xstream_1.default.merge(goal$, sources.TabletFace.animationFinish.mapTo({ | ||
@@ -41,0 +41,0 @@ type: 'END', |
@@ -1,4 +0,4 @@ | ||
export { ExpressCommandType, TabletFace } from './tablet_face'; | ||
export { ExpressCommandType, makeTabletFaceDriver } from './tablet_face'; | ||
export { FacialExpressionAction } from './FacialExpressionAction'; | ||
export { SpeechbubbleType, SpeechbubbleAction, IsolatedSpeechbubbleAction } from './SpeechbubbleAction'; | ||
export { TwoSpeechbubblesType, TwoSpeechbubblesAction, IsolatedTwoSpeechbubblesAction } from './TwoSpeechbubblesAction'; |
@@ -5,3 +5,3 @@ "use strict"; | ||
exports.ExpressCommandType = tablet_face_1.ExpressCommandType; | ||
exports.TabletFace = tablet_face_1.TabletFace; | ||
exports.makeTabletFaceDriver = tablet_face_1.makeTabletFaceDriver; | ||
var FacialExpressionAction_1 = require("./FacialExpressionAction"); | ||
@@ -8,0 +8,0 @@ exports.FacialExpressionAction = FacialExpressionAction_1.FacialExpressionAction; |
@@ -8,3 +8,3 @@ export declare enum ExpressCommandType { | ||
} | ||
export declare function TabletFace(sources: any, {styles: {faceColor, faceHeight, faceWidth, eyeColor, eyeSize, eyelidColor}}?: { | ||
export declare function makeTabletFaceDriver({styles: {faceColor, faceHeight, faceWidth, eyeColor, eyeSize, eyelidColor}}?: { | ||
styles?: { | ||
@@ -18,3 +18,3 @@ faceColor?: string; | ||
}; | ||
}): { | ||
}): (command$: any) => { | ||
DOM: any; | ||
@@ -21,0 +21,0 @@ animationFinish: any; |
@@ -215,3 +215,3 @@ "use strict"; | ||
})(ExpressCommandType = exports.ExpressCommandType || (exports.ExpressCommandType = {})); | ||
function TabletFace(sources, _a) { | ||
function makeTabletFaceDriver(_a) { | ||
var _b = (_a === void 0 ? { styles: {} } : _a).styles, _c = _b.faceColor, faceColor = _c === void 0 ? 'whitesmoke' : _c, _d = _b.faceHeight, faceHeight = _d === void 0 ? '100vh' : _d, _e = _b.faceWidth, faceWidth = _e === void 0 ? '100vw' : _e, _f = _b.eyeColor, eyeColor = _f === void 0 ? 'black' : _f, _g = _b.eyeSize, eyeSize = _g === void 0 ? '33.33vh' : _g, _h = _b.eyelidColor, eyelidColor = _h === void 0 ? 'whitesmoke' : _h; | ||
@@ -260,4 +260,11 @@ var styles = { | ||
var id = "face-" + String(Math.random()).substr(2); | ||
var faceElement$ = sources.DOM.select("#" + id).element(); | ||
faceElement$.addListener({ next: function (element) { | ||
return function (command$) { | ||
var load$ = xstream_1.default.create(); | ||
var intervalID = setInterval(function () { | ||
if (!document.querySelector("#" + id)) { | ||
console.debug('Waiting for `#${id}` to appear...'); | ||
return; | ||
} | ||
clearInterval(intervalID); | ||
var element = document.querySelector("#" + id); | ||
eyes.setElements({ | ||
@@ -271,60 +278,58 @@ leftEye: element.querySelector('.left.eye'), | ||
}); | ||
} }); | ||
var load$ = faceElement$ | ||
.filter(function () { return true; }) // convert MemoryStream to Stream | ||
.take(1) | ||
.mapTo(null); | ||
var animations = {}; | ||
var animationFinish$$ = xstream_1.default.create(); | ||
var speechbubblesDOM$ = xstream_1.default.create(); | ||
xstream_1.default.fromObservable(sources.command).addListener({ | ||
next: function (command) { | ||
if (!command) { | ||
Object.keys(animations).map(function (key) { | ||
animations[key].cancel(); | ||
}); | ||
return; | ||
load$.shamefullySendNext(null); | ||
}, 1000); | ||
var animations = {}; | ||
var animationFinish$$ = xstream_1.default.create(); | ||
var speechbubblesDOM$ = xstream_1.default.create(); | ||
xstream_1.default.fromObservable(command$).addListener({ | ||
next: function (command) { | ||
if (!command) { | ||
Object.keys(animations).map(function (key) { | ||
animations[key].cancel(); | ||
}); | ||
return; | ||
} | ||
switch (command.type) { | ||
case CommandType.EXPRESS: | ||
animations = eyes.express(command.value) || {}; | ||
animationFinish$$.shamefullySendNext(xstream_1.default.fromPromise(Promise.all(Object.keys(animations).map(function (key) { | ||
return new Promise(function (resolve, reject) { | ||
animations[key].onfinish = resolve; | ||
}); | ||
})))); | ||
break; | ||
case CommandType.START_BLINKING: | ||
eyes.startBlinking(command.value); | ||
break; | ||
case CommandType.STOP_BLINKING: | ||
eyes.stopBlinking(); | ||
break; | ||
case CommandType.SET_STATE: | ||
var value = command.value; | ||
var leftPos = value && value.leftEye || { x: null, y: null }; | ||
var rightPos = value && value.rightEye || { x: null, y: null }; | ||
eyes.setEyePosition(eyes.leftEye, leftPos.x, leftPos.y); | ||
eyes.setEyePosition(eyes.rightEye, rightPos.x, rightPos.y, true); | ||
break; | ||
case CommandType.SPEECHBUBBLES: | ||
speechbubblesDOM$.shamefullySendNext(command.value); | ||
break; | ||
} | ||
} | ||
switch (command.type) { | ||
case CommandType.EXPRESS: | ||
animations = eyes.express(command.value) || {}; | ||
animationFinish$$.shamefullySendNext(xstream_1.default.fromPromise(Promise.all(Object.keys(animations).map(function (key) { | ||
return new Promise(function (resolve, reject) { | ||
animations[key].onfinish = resolve; | ||
}); | ||
})))); | ||
break; | ||
case CommandType.START_BLINKING: | ||
eyes.startBlinking(command.value); | ||
break; | ||
case CommandType.STOP_BLINKING: | ||
eyes.stopBlinking(); | ||
break; | ||
case CommandType.SET_STATE: | ||
var value = command.value; | ||
var leftPos = value && value.leftEye || { x: null, y: null }; | ||
var rightPos = value && value.rightEye || { x: null, y: null }; | ||
eyes.setEyePosition(eyes.leftEye, leftPos.x, leftPos.y); | ||
eyes.setEyePosition(eyes.rightEye, rightPos.x, rightPos.y, true); | ||
break; | ||
case CommandType.SPEECHBUBBLES: | ||
speechbubblesDOM$.shamefullySendNext(command.value); | ||
break; | ||
} | ||
} | ||
}); | ||
var vnode$ = xstream_1.default.of(snabbdom_pragma_1.default.createElement("div", { className: "face", style: styles.face, id: id }, | ||
snabbdom_pragma_1.default.createElement("div", { className: "eye left", style: Object.assign({}, styles.eye, styles.left) }, | ||
snabbdom_pragma_1.default.createElement("div", { className: "eyelid upper", style: Object.assign({}, styles.eyelid, styles.upper) }), | ||
snabbdom_pragma_1.default.createElement("div", { className: "eyelid lower", style: Object.assign({}, styles.eyelid, styles.lower) })), | ||
snabbdom_pragma_1.default.createElement("div", { className: "eye right", style: Object.assign({}, styles.eye, styles.right) }, | ||
snabbdom_pragma_1.default.createElement("div", { className: "eyelid upper", style: Object.assign({}, styles.eyelid, styles.upper) }), | ||
snabbdom_pragma_1.default.createElement("div", { className: "eyelid lower", style: Object.assign({}, styles.eyelid, styles.lower) })))); | ||
return { | ||
DOM: adapt_1.adapt(vnode$), | ||
animationFinish: adapt_1.adapt(animationFinish$$.flatten()), | ||
load: adapt_1.adapt(load$), | ||
}); | ||
var vnode$ = xstream_1.default.of(snabbdom_pragma_1.default.createElement("div", { className: "face", style: styles.face, id: id }, | ||
snabbdom_pragma_1.default.createElement("div", { className: "eye left", style: Object.assign({}, styles.eye, styles.left) }, | ||
snabbdom_pragma_1.default.createElement("div", { className: "eyelid upper", style: Object.assign({}, styles.eyelid, styles.upper) }), | ||
snabbdom_pragma_1.default.createElement("div", { className: "eyelid lower", style: Object.assign({}, styles.eyelid, styles.lower) })), | ||
snabbdom_pragma_1.default.createElement("div", { className: "eye right", style: Object.assign({}, styles.eye, styles.right) }, | ||
snabbdom_pragma_1.default.createElement("div", { className: "eyelid upper", style: Object.assign({}, styles.eyelid, styles.upper) }), | ||
snabbdom_pragma_1.default.createElement("div", { className: "eyelid lower", style: Object.assign({}, styles.eyelid, styles.lower) })))); | ||
return { | ||
DOM: adapt_1.adapt(vnode$), | ||
animationFinish: adapt_1.adapt(animationFinish$$.flatten()), | ||
load: adapt_1.adapt(load$), | ||
}; | ||
}; | ||
} | ||
exports.TabletFace = TabletFace; | ||
exports.makeTabletFaceDriver = makeTabletFaceDriver; | ||
//# sourceMappingURL=tablet_face.js.map |
@@ -33,3 +33,3 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
} | ||
}).debug(); | ||
}); | ||
var action$ = xs.merge(goal$, sources.TabletFace.animationFinish.mapTo({ | ||
@@ -36,0 +36,0 @@ type: 'END', |
@@ -1,4 +0,4 @@ | ||
export { ExpressCommandType, TabletFace } from './tablet_face'; | ||
export { ExpressCommandType, makeTabletFaceDriver } from './tablet_face'; | ||
export { FacialExpressionAction } from './FacialExpressionAction'; | ||
export { SpeechbubbleType, SpeechbubbleAction, IsolatedSpeechbubbleAction } from './SpeechbubbleAction'; | ||
export { TwoSpeechbubblesType, TwoSpeechbubblesAction, IsolatedTwoSpeechbubblesAction } from './TwoSpeechbubblesAction'; |
@@ -1,2 +0,2 @@ | ||
export { ExpressCommandType, TabletFace, } from './tablet_face'; | ||
export { ExpressCommandType, makeTabletFaceDriver, } from './tablet_face'; | ||
export { FacialExpressionAction, } from './FacialExpressionAction'; | ||
@@ -3,0 +3,0 @@ export { SpeechbubbleType, SpeechbubbleAction, IsolatedSpeechbubbleAction, } from './SpeechbubbleAction'; |
@@ -8,3 +8,3 @@ export declare enum ExpressCommandType { | ||
} | ||
export declare function TabletFace(sources: any, {styles: {faceColor, faceHeight, faceWidth, eyeColor, eyeSize, eyelidColor}}?: { | ||
export declare function makeTabletFaceDriver({styles: {faceColor, faceHeight, faceWidth, eyeColor, eyeSize, eyelidColor}}?: { | ||
styles?: { | ||
@@ -18,3 +18,3 @@ faceColor?: string; | ||
}; | ||
}): { | ||
}): (command$: any) => { | ||
DOM: any; | ||
@@ -21,0 +21,0 @@ animationFinish: any; |
@@ -210,3 +210,3 @@ import Snabbdom from 'snabbdom-pragma'; | ||
})(ExpressCommandType || (ExpressCommandType = {})); | ||
export function TabletFace(sources, _a) { | ||
export function makeTabletFaceDriver(_a) { | ||
var _b = (_a === void 0 ? { styles: {} } : _a).styles, _c = _b.faceColor, faceColor = _c === void 0 ? 'whitesmoke' : _c, _d = _b.faceHeight, faceHeight = _d === void 0 ? '100vh' : _d, _e = _b.faceWidth, faceWidth = _e === void 0 ? '100vw' : _e, _f = _b.eyeColor, eyeColor = _f === void 0 ? 'black' : _f, _g = _b.eyeSize, eyeSize = _g === void 0 ? '33.33vh' : _g, _h = _b.eyelidColor, eyelidColor = _h === void 0 ? 'whitesmoke' : _h; | ||
@@ -255,4 +255,11 @@ var styles = { | ||
var id = "face-" + String(Math.random()).substr(2); | ||
var faceElement$ = sources.DOM.select("#" + id).element(); | ||
faceElement$.addListener({ next: function (element) { | ||
return function (command$) { | ||
var load$ = xs.create(); | ||
var intervalID = setInterval(function () { | ||
if (!document.querySelector("#" + id)) { | ||
console.debug('Waiting for `#${id}` to appear...'); | ||
return; | ||
} | ||
clearInterval(intervalID); | ||
var element = document.querySelector("#" + id); | ||
eyes.setElements({ | ||
@@ -266,59 +273,57 @@ leftEye: element.querySelector('.left.eye'), | ||
}); | ||
} }); | ||
var load$ = faceElement$ | ||
.filter(function () { return true; }) // convert MemoryStream to Stream | ||
.take(1) | ||
.mapTo(null); | ||
var animations = {}; | ||
var animationFinish$$ = xs.create(); | ||
var speechbubblesDOM$ = xs.create(); | ||
xs.fromObservable(sources.command).addListener({ | ||
next: function (command) { | ||
if (!command) { | ||
Object.keys(animations).map(function (key) { | ||
animations[key].cancel(); | ||
}); | ||
return; | ||
load$.shamefullySendNext(null); | ||
}, 1000); | ||
var animations = {}; | ||
var animationFinish$$ = xs.create(); | ||
var speechbubblesDOM$ = xs.create(); | ||
xs.fromObservable(command$).addListener({ | ||
next: function (command) { | ||
if (!command) { | ||
Object.keys(animations).map(function (key) { | ||
animations[key].cancel(); | ||
}); | ||
return; | ||
} | ||
switch (command.type) { | ||
case CommandType.EXPRESS: | ||
animations = eyes.express(command.value) || {}; | ||
animationFinish$$.shamefullySendNext(xs.fromPromise(Promise.all(Object.keys(animations).map(function (key) { | ||
return new Promise(function (resolve, reject) { | ||
animations[key].onfinish = resolve; | ||
}); | ||
})))); | ||
break; | ||
case CommandType.START_BLINKING: | ||
eyes.startBlinking(command.value); | ||
break; | ||
case CommandType.STOP_BLINKING: | ||
eyes.stopBlinking(); | ||
break; | ||
case CommandType.SET_STATE: | ||
var value = command.value; | ||
var leftPos = value && value.leftEye || { x: null, y: null }; | ||
var rightPos = value && value.rightEye || { x: null, y: null }; | ||
eyes.setEyePosition(eyes.leftEye, leftPos.x, leftPos.y); | ||
eyes.setEyePosition(eyes.rightEye, rightPos.x, rightPos.y, true); | ||
break; | ||
case CommandType.SPEECHBUBBLES: | ||
speechbubblesDOM$.shamefullySendNext(command.value); | ||
break; | ||
} | ||
} | ||
switch (command.type) { | ||
case CommandType.EXPRESS: | ||
animations = eyes.express(command.value) || {}; | ||
animationFinish$$.shamefullySendNext(xs.fromPromise(Promise.all(Object.keys(animations).map(function (key) { | ||
return new Promise(function (resolve, reject) { | ||
animations[key].onfinish = resolve; | ||
}); | ||
})))); | ||
break; | ||
case CommandType.START_BLINKING: | ||
eyes.startBlinking(command.value); | ||
break; | ||
case CommandType.STOP_BLINKING: | ||
eyes.stopBlinking(); | ||
break; | ||
case CommandType.SET_STATE: | ||
var value = command.value; | ||
var leftPos = value && value.leftEye || { x: null, y: null }; | ||
var rightPos = value && value.rightEye || { x: null, y: null }; | ||
eyes.setEyePosition(eyes.leftEye, leftPos.x, leftPos.y); | ||
eyes.setEyePosition(eyes.rightEye, rightPos.x, rightPos.y, true); | ||
break; | ||
case CommandType.SPEECHBUBBLES: | ||
speechbubblesDOM$.shamefullySendNext(command.value); | ||
break; | ||
} | ||
} | ||
}); | ||
var vnode$ = xs.of(Snabbdom.createElement("div", { className: "face", style: styles.face, id: id }, | ||
Snabbdom.createElement("div", { className: "eye left", style: Object.assign({}, styles.eye, styles.left) }, | ||
Snabbdom.createElement("div", { className: "eyelid upper", style: Object.assign({}, styles.eyelid, styles.upper) }), | ||
Snabbdom.createElement("div", { className: "eyelid lower", style: Object.assign({}, styles.eyelid, styles.lower) })), | ||
Snabbdom.createElement("div", { className: "eye right", style: Object.assign({}, styles.eye, styles.right) }, | ||
Snabbdom.createElement("div", { className: "eyelid upper", style: Object.assign({}, styles.eyelid, styles.upper) }), | ||
Snabbdom.createElement("div", { className: "eyelid lower", style: Object.assign({}, styles.eyelid, styles.lower) })))); | ||
return { | ||
DOM: adapt(vnode$), | ||
animationFinish: adapt(animationFinish$$.flatten()), | ||
load: adapt(load$), | ||
}); | ||
var vnode$ = xs.of(Snabbdom.createElement("div", { className: "face", style: styles.face, id: id }, | ||
Snabbdom.createElement("div", { className: "eye left", style: Object.assign({}, styles.eye, styles.left) }, | ||
Snabbdom.createElement("div", { className: "eyelid upper", style: Object.assign({}, styles.eyelid, styles.upper) }), | ||
Snabbdom.createElement("div", { className: "eyelid lower", style: Object.assign({}, styles.eyelid, styles.lower) })), | ||
Snabbdom.createElement("div", { className: "eye right", style: Object.assign({}, styles.eye, styles.right) }, | ||
Snabbdom.createElement("div", { className: "eyelid upper", style: Object.assign({}, styles.eyelid, styles.upper) }), | ||
Snabbdom.createElement("div", { className: "eyelid lower", style: Object.assign({}, styles.eyelid, styles.lower) })))); | ||
return { | ||
DOM: adapt(vnode$), | ||
animationFinish: adapt(animationFinish$$.flatten()), | ||
load: adapt(load$), | ||
}; | ||
}; | ||
} | ||
//# sourceMappingURL=tablet_face.js.map |
{ | ||
"name": "@cycle-robot-drivers/screen", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "Michael Jae-Yoon Chung", |
export { | ||
ExpressCommandType, | ||
TabletFace, | ||
makeTabletFaceDriver, | ||
} from './tablet_face'; | ||
@@ -5,0 +5,0 @@ export { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
162176
2774