Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-typist

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-typist - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

14

dist/standalone/Typist.js

@@ -1647,2 +1647,10 @@ (function webpackUniversalModuleDefinition(root, factory) {

var _Backspace = __webpack_require__(13);
var _Backspace2 = _interopRequireDefault(_Backspace);
var _Delay = __webpack_require__(14);
var _Delay2 = _interopRequireDefault(_Delay);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -1698,4 +1706,3 @@

if (_react2.default.isValidElement(current)) {
var name = current.type && current.type.name;
if (name === 'Backspace' || name === 'Delay') {
if (current.type === _Backspace2.default || current.type === _Delay2.default) {
// If it is a `Backspace` or `Delay` element, we want to keep it in our

@@ -1767,4 +1774,3 @@ // `textLines` state. These will serve as markers when updating the

var name = element.type && element.type.name;
var isNonTypistElement = _react2.default.isValidElement(element) && !(name === 'Delay' || name === 'Backspace');
var isNonTypistElement = _react2.default.isValidElement(element) && !(element.type === _Delay2.default || element.type === _Backspace2.default);

@@ -1771,0 +1777,0 @@ if (isNonTypistElement) {

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.Typist=t(require("react")):e.Typist=t(e.react)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function o(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(1),f=o(c),p=n(2),d=o(p),y=n(7),h=o(y),v=n(9),m=o(v),b=n(10),g=o(b),T=n(11),_=r(T),D=["🔙","⏰"],x=function(e){function t(e){i(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={textLines:[],isDone:!1},n.onTypingDone=function(){n.mounted&&(n.setState({isDone:!0}),n.props.onTypingDone())},n.delayGenerator=function(e,t,r,o){var i=n.props.avgTypingDelay,u=n.props.stdTypingDelay;return n.props.delayGenerator(i,u,{line:e,lineIdx:t,character:r,charIdx:o,defDelayGenerator:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u;return _.gaussianRnd(e,t)}})},n.typeLine=function(e,t){if(!n.mounted)return Promise.resolve();var r="string"!=typeof e,o=e,i=n.props.onLineTyped;return r&&(e.type&&"Backspace"===e.type.name?(e.props.delay>0&&(n.introducedDelay=e.props.delay),o=String("🔙").repeat(e.props.count)):e.type&&"Delay"===e.type.name&&(n.introducedDelay=e.props.ms,o="⏰")),new Promise(function(e,r){n.setState({textLines:n.state.textLines.concat([""])},function(){_.eachPromise(o,n.typeCharacter,o,t).then(function(){return i(o,t)}).then(e).catch(r)})})},n.typeCharacter=function(e,t,r,o){if(!n.mounted)return Promise.resolve();var i=n.props.onCharacterTyped;return new Promise(function(u){var a=n.state.textLines.slice();_.sleep(n.introducedDelay).then(function(){n.introducedDelay=null;var s="🔙"===e,l="⏰"===e;if(l)return void u();if(s&&o>0){for(var c=o-1,f=a[c],p=c;p>=0&&(!(f.length>0)||D.includes(f[0]));p--)c=p,f=a[c];a[c]=f.substr(0,f.length-1)}else a[o]+=e;n.setState({textLines:a},function(){var a=n.delayGenerator(r,o,e,t);i(e,t),setTimeout(u,a)})})})},n.mounted=!1,n.linesToType=[],n.introducedDelay=null,e.children&&(n.linesToType=_.extractTextFromElement(e.children)),n}return a(t,e),l(t,[{key:"componentDidMount",value:function(){this.mounted=!0;var e=this.props,t=e.children,n=e.startDelay;t?n>0&&"undefined"!=typeof window?setTimeout(this.typeAllLines.bind(this),n):this.typeAllLines():this.onTypingDone()}},{key:"shouldComponentUpdate",value:function(e,t){if(t.textLines.length!==this.state.textLines.length)return!0;for(var n=0;n<t.textLines.length;n++){var r=this.state.textLines[n],o=t.textLines[n];if(r!==o)return!0}return this.state.isDone!==t.isDone}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"typeAllLines",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.linesToType;return _.eachPromise(t,this.typeLine).then(function(){return e.onTypingDone()})}},{key:"render",value:function(){var e=this.props,t=e.className,n=e.cursor,r=this.state.isDone,o=_.cloneElementWithSpecifiedText({element:this.props.children,textLines:this.state.textLines});return f.default.createElement("div",{className:"Typist "+t},o,f.default.createElement(h.default,s({isDone:r},n)))}}]),t}(c.Component);x.propTypes={children:d.default.node,className:d.default.string,avgTypingDelay:d.default.number,stdTypingDelay:d.default.number,startDelay:d.default.number,cursor:d.default.object,onCharacterTyped:d.default.func,onLineTyped:d.default.func,onTypingDone:d.default.func,delayGenerator:d.default.func},x.defaultProps={className:"",avgTypingDelay:70,stdTypingDelay:25,startDelay:0,cursor:{},onCharacterTyped:function(){},onLineTyped:function(){},onTypingDone:function(){},delayGenerator:_.gaussianRnd},t.default=x,x.Backspace=m.default,x.Delay=g.default},function(t,n){t.exports=e},function(e,t,n){e.exports=n(3)()},function(e,t,n){"use strict";var r=n(4),o=n(5),i=n(6);e.exports=function(){function e(e,t,n,r,u,a){a!==i&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t){"use strict";function n(e){return function(){return e}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){"use strict";function r(e,t,n,r,i,u,a,s){if(o(t),!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,i,u,a,s],f=0;l=new Error(t.replace(/%s/g,function(){return c[f++]})),l.name="Invariant Violation"}throw l.framesToPop=1,l}}var o=function(e){};e.exports=r},function(e,t){"use strict";var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(1),l=r(s),c=n(2),f=r(c);n(8);var p=function(e){function t(e){o(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n._isReRenderingCursor=!1,n.state={shouldRender:n.props.show},n}return u(t,e),a(t,[{key:"componentWillReceiveProps",value:function(e){var t=this,n=!this.props.isDone&&e.isDone&&this.props.hideWhenDone;n&&setTimeout(function(){return t.setState({shouldRender:!1})},this.props.hideWhenDoneDelay)}},{key:"componentDidUpdate",value:function(){var e=this.props,t=e.show,n=e.isDone;t&&(n||this._isReRenderingCursor||this._reRenderCursor())}},{key:"_reRenderCursor",value:function(){var e=this;this._isReRenderingCursor=!0,this.setState({shouldRender:!1},function(){e.setState({shouldRender:!0},function(){e._isReRenderingCursor=!1})})}},{key:"render",value:function(){if(this.state.shouldRender){var e=this.props.blink?" Cursor--blinking":"";return l.default.createElement("span",{className:"Cursor"+e},this.props.element)}return null}}]),t}(s.Component);p.propTypes={blink:f.default.bool,show:f.default.bool,element:f.default.node,hideWhenDone:f.default.bool,hideWhenDoneDelay:f.default.number,isDone:f.default.bool},p.defaultProps={blink:!0,show:!0,element:"|",hideWhenDone:!1,hideWhenDoneDelay:1e3,isDone:!1},t.default=p},function(e,t){},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),u=n(2),a=r(u),s=function(){return i.default.createElement("noscript",null)};s.propTypes={count:a.default.number,delay:a.default.number},s.defaultProps={count:1,delay:0},t.default=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),u=n(2),a=r(u),s=function(){return i.default.createElement("noscript",null)};s.propTypes={ms:a.default.number.isRequired},t.default=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function i(e,t){for(var n=12,r=0,o=0;o<n;o++)r+=Math.random();return r-=n/2,Math.round(r*t)+e}function u(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];var i=function(e,n,o){return e.then(function(){return t.apply(void 0,[n,o].concat(r))})};return Array.from(e).reduce(i,Promise.resolve())}function a(e,t){var n={};for(var r in e)t.indexOf(r)===-1&&(n[r]=e[r]);return n}function s(e){for(var t=e?[e]:[],n=[];t.length>0;){var r=t.pop();if(y.default.isValidElement(r)){var o=r.type&&r.type.name;"Backspace"===o||"Delay"===o?n.unshift(r):y.default.Children.forEach(r.props.children,function(e){t.push(e)})}else if(Array.isArray(r)){var i=!0,u=!1,a=void 0;try{for(var s,l=r[Symbol.iterator]();!(i=(s=l.next()).done);i=!0){var c=s.value;t.push(c)}}catch(e){u=!0,a=e}finally{try{!i&&l.return&&l.return()}finally{if(u)throw a}}}else n.unshift(r)}return n}function l(e,t){var n=e.type,r=a(e.props,["children"]);return r.key="Typist-element-"+n+"-"+(Date.now()+Math.random()+Math.random()),y.default.createElement.apply(y.default,[n,r].concat(o(t)))}function c(e,t,n){if(n>=t.length)return[null,n];var r=n,o=function(e){var n=c(e,t,r),o=p(n,2),i=o[0],u=o[1];return r=u,i},i=e.type&&e.type.name,u=y.default.isValidElement(e)&&!("Delay"===i||"Backspace"===i);if(u){var a=y.default.Children.map(e.props.children,o)||[];return[l(e,a),r]}if(Array.isArray(e)){var s=e.map(o);return[s,r]}return[t[r],r+1]}function f(e){var t=e.element,n=e.textLines;if(t)return c(t,n,0)[0]}Object.defineProperty(t,"__esModule",{value:!0}),t.sleep=void 0;var p=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.gaussianRnd=i,t.eachPromise=u,t.exclude=a,t.extractTextFromElement=s,t.cloneElement=l,t.cloneElementWithSpecifiedText=f;var d=n(1),y=r(d);t.sleep=function(e){return new Promise(function(t){return null!=e?setTimeout(t,e):t()})}}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.Typist=t(require("react")):e.Typist=t(e.react)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function o(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(1),f=o(c),p=n(2),d=o(p),y=n(7),h=o(y),v=n(9),m=o(v),b=n(10),g=o(b),T=n(11),_=r(T),D=["🔙","⏰"],x=function(e){function t(e){i(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={textLines:[],isDone:!1},n.onTypingDone=function(){n.mounted&&(n.setState({isDone:!0}),n.props.onTypingDone())},n.delayGenerator=function(e,t,r,o){var i=n.props.avgTypingDelay,u=n.props.stdTypingDelay;return n.props.delayGenerator(i,u,{line:e,lineIdx:t,character:r,charIdx:o,defDelayGenerator:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u;return _.gaussianRnd(e,t)}})},n.typeLine=function(e,t){if(!n.mounted)return Promise.resolve();var r="string"!=typeof e,o=e,i=n.props.onLineTyped;return r&&(e.type&&"Backspace"===e.type.name?(e.props.delay>0&&(n.introducedDelay=e.props.delay),o=String("🔙").repeat(e.props.count)):e.type&&"Delay"===e.type.name&&(n.introducedDelay=e.props.ms,o="⏰")),new Promise(function(e,r){n.setState({textLines:n.state.textLines.concat([""])},function(){_.eachPromise(o,n.typeCharacter,o,t).then(function(){return i(o,t)}).then(e).catch(r)})})},n.typeCharacter=function(e,t,r,o){if(!n.mounted)return Promise.resolve();var i=n.props.onCharacterTyped;return new Promise(function(u){var a=n.state.textLines.slice();_.sleep(n.introducedDelay).then(function(){n.introducedDelay=null;var s="🔙"===e,l="⏰"===e;if(l)return void u();if(s&&o>0){for(var c=o-1,f=a[c],p=c;p>=0&&(!(f.length>0)||D.includes(f[0]));p--)c=p,f=a[c];a[c]=f.substr(0,f.length-1)}else a[o]+=e;n.setState({textLines:a},function(){var a=n.delayGenerator(r,o,e,t);i(e,t),setTimeout(u,a)})})})},n.mounted=!1,n.linesToType=[],n.introducedDelay=null,e.children&&(n.linesToType=_.extractTextFromElement(e.children)),n}return a(t,e),l(t,[{key:"componentDidMount",value:function(){this.mounted=!0;var e=this.props,t=e.children,n=e.startDelay;t?n>0&&"undefined"!=typeof window?setTimeout(this.typeAllLines.bind(this),n):this.typeAllLines():this.onTypingDone()}},{key:"shouldComponentUpdate",value:function(e,t){if(t.textLines.length!==this.state.textLines.length)return!0;for(var n=0;n<t.textLines.length;n++){var r=this.state.textLines[n],o=t.textLines[n];if(r!==o)return!0}return this.state.isDone!==t.isDone}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"typeAllLines",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.linesToType;return _.eachPromise(t,this.typeLine).then(function(){return e.onTypingDone()})}},{key:"render",value:function(){var e=this.props,t=e.className,n=e.cursor,r=this.state.isDone,o=_.cloneElementWithSpecifiedText({element:this.props.children,textLines:this.state.textLines});return f.default.createElement("div",{className:"Typist "+t},o,f.default.createElement(h.default,s({isDone:r},n)))}}]),t}(c.Component);x.propTypes={children:d.default.node,className:d.default.string,avgTypingDelay:d.default.number,stdTypingDelay:d.default.number,startDelay:d.default.number,cursor:d.default.object,onCharacterTyped:d.default.func,onLineTyped:d.default.func,onTypingDone:d.default.func,delayGenerator:d.default.func},x.defaultProps={className:"",avgTypingDelay:70,stdTypingDelay:25,startDelay:0,cursor:{},onCharacterTyped:function(){},onLineTyped:function(){},onTypingDone:function(){},delayGenerator:_.gaussianRnd},t.default=x,x.Backspace=m.default,x.Delay=g.default},function(t,n){t.exports=e},function(e,t,n){e.exports=n(3)()},function(e,t,n){"use strict";var r=n(4),o=n(5),i=n(6);e.exports=function(){function e(e,t,n,r,u,a){a!==i&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t){"use strict";function n(e){return function(){return e}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){"use strict";function r(e,t,n,r,i,u,a,s){if(o(t),!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,i,u,a,s],f=0;l=new Error(t.replace(/%s/g,function(){return c[f++]})),l.name="Invariant Violation"}throw l.framesToPop=1,l}}var o=function(e){};e.exports=r},function(e,t){"use strict";var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(1),l=r(s),c=n(2),f=r(c);n(8);var p=function(e){function t(e){o(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n._isReRenderingCursor=!1,n.state={shouldRender:n.props.show},n}return u(t,e),a(t,[{key:"componentWillReceiveProps",value:function(e){var t=this,n=!this.props.isDone&&e.isDone&&this.props.hideWhenDone;n&&setTimeout(function(){return t.setState({shouldRender:!1})},this.props.hideWhenDoneDelay)}},{key:"componentDidUpdate",value:function(){var e=this.props,t=e.show,n=e.isDone;t&&(n||this._isReRenderingCursor||this._reRenderCursor())}},{key:"_reRenderCursor",value:function(){var e=this;this._isReRenderingCursor=!0,this.setState({shouldRender:!1},function(){e.setState({shouldRender:!0},function(){e._isReRenderingCursor=!1})})}},{key:"render",value:function(){if(this.state.shouldRender){var e=this.props.blink?" Cursor--blinking":"";return l.default.createElement("span",{className:"Cursor"+e},this.props.element)}return null}}]),t}(s.Component);p.propTypes={blink:f.default.bool,show:f.default.bool,element:f.default.node,hideWhenDone:f.default.bool,hideWhenDoneDelay:f.default.number,isDone:f.default.bool},p.defaultProps={blink:!0,show:!0,element:"|",hideWhenDone:!1,hideWhenDoneDelay:1e3,isDone:!1},t.default=p},function(e,t){},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),u=n(2),a=r(u),s=function(){return i.default.createElement("noscript",null)};s.propTypes={count:a.default.number,delay:a.default.number},s.defaultProps={count:1,delay:0},t.default=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),u=n(2),a=r(u),s=function(){return i.default.createElement("noscript",null)};s.propTypes={ms:a.default.number.isRequired},t.default=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function i(e,t){for(var n=12,r=0,o=0;o<n;o++)r+=Math.random();return r-=n/2,Math.round(r*t)+e}function u(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];var i=function(e,n,o){return e.then(function(){return t.apply(void 0,[n,o].concat(r))})};return Array.from(e).reduce(i,Promise.resolve())}function a(e,t){var n={};for(var r in e)t.indexOf(r)===-1&&(n[r]=e[r]);return n}function s(e){for(var t=e?[e]:[],n=[];t.length>0;){var r=t.pop();if(y.default.isValidElement(r))r.type===v.default||r.type===b.default?n.unshift(r):y.default.Children.forEach(r.props.children,function(e){t.push(e)});else if(Array.isArray(r)){var o=!0,i=!1,u=void 0;try{for(var a,s=r[Symbol.iterator]();!(o=(a=s.next()).done);o=!0){var l=a.value;t.push(l)}}catch(e){i=!0,u=e}finally{try{!o&&s.return&&s.return()}finally{if(i)throw u}}}else n.unshift(r)}return n}function l(e,t){var n=e.type,r=a(e.props,["children"]);return r.key="Typist-element-"+n+"-"+(Date.now()+Math.random()+Math.random()),y.default.createElement.apply(y.default,[n,r].concat(o(t)))}function c(e,t,n){if(n>=t.length)return[null,n];var r=n,o=function(e){var n=c(e,t,r),o=p(n,2),i=o[0],u=o[1];return r=u,i},i=y.default.isValidElement(e)&&!(e.type===b.default||e.type===v.default);if(i){var u=y.default.Children.map(e.props.children,o)||[];return[l(e,u),r]}if(Array.isArray(e)){var a=e.map(o);return[a,r]}return[t[r],r+1]}function f(e){var t=e.element,n=e.textLines;if(t)return c(t,n,0)[0]}Object.defineProperty(t,"__esModule",{value:!0}),t.sleep=void 0;var p=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.gaussianRnd=i,t.eachPromise=u,t.exclude=a,t.extractTextFromElement=s,t.cloneElement=l,t.cloneElementWithSpecifiedText=f;var d=n(1),y=r(d),h=n(9),v=r(h),m=n(10),b=r(m);t.sleep=function(e){return new Promise(function(t){return null!=e?setTimeout(t,e):t()})}}])});

@@ -1443,2 +1443,10 @@ module.exports =

var _Backspace = __webpack_require__(12);
var _Backspace2 = _interopRequireDefault(_Backspace);
var _Delay = __webpack_require__(13);
var _Delay2 = _interopRequireDefault(_Delay);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -1494,4 +1502,3 @@

if (_react2.default.isValidElement(current)) {
var name = current.type && current.type.name;
if (name === 'Backspace' || name === 'Delay') {
if (current.type === _Backspace2.default || current.type === _Delay2.default) {
// If it is a `Backspace` or `Delay` element, we want to keep it in our

@@ -1563,4 +1570,3 @@ // `textLines` state. These will serve as markers when updating the

var name = element.type && element.type.name;
var isNonTypistElement = _react2.default.isValidElement(element) && !(name === 'Delay' || name === 'Backspace');
var isNonTypistElement = _react2.default.isValidElement(element) && !(element.type === _Delay2.default || element.type === _Backspace2.default);

@@ -1567,0 +1573,0 @@ if (isNonTypistElement) {

{
"name": "react-typist",
"version": "2.0.2",
"version": "2.0.3",
"description": "Typing animations with React",

@@ -5,0 +5,0 @@ "main": "dist/Typist.js",

import React from 'react';
import Backspace from './Backspace';
import Delay from './Delay';

@@ -41,4 +43,3 @@ export const sleep = (val) => new Promise((resolve) => (

if (React.isValidElement(current)) {
const name = current.type && current.type.name;
if (name === 'Backspace' || name === 'Delay') {
if (current.type === Backspace || current.type === Delay) {
// If it is a `Backspace` or `Delay` element, we want to keep it in our

@@ -89,6 +90,5 @@ // `textLines` state. These will serve as markers when updating the

const name = element.type && element.type.name;
const isNonTypistElement = (
React.isValidElement(element) &&
!(name === 'Delay' || name === 'Backspace')
!(element.type === Delay || element.type === Backspace)
);

@@ -95,0 +95,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc