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

ink-spinner

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ink-spinner - npm Package Compare versions

Comparing version 3.1.0 to 4.0.0-0

build/index.d.ts

91

build/index.js

@@ -1,65 +0,26 @@

'use strict';
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
const React = require('react');
const PropTypes = require('prop-types');
const {
Box
} = require('ink');
const spinners = require('cli-spinners');
class Spinner extends React.Component {
constructor(...args) {
super(...args);
_defineProperty(this, "state", {
frame: 0
});
_defineProperty(this, "switchFrame", () => {
const {
frame
} = this.state;
const spinner = this.getSpinner();
const isLastFrame = frame === spinner.frames.length - 1;
const nextFrame = isLastFrame ? 0 : frame + 1;
this.setState({
frame: nextFrame
});
});
}
render() {
const spinner = this.getSpinner();
return /*#__PURE__*/React.createElement(Box, null, spinner.frames[this.state.frame]);
}
componentDidMount() {
const spinner = this.getSpinner();
this.timer = setInterval(this.switchFrame, spinner.interval);
}
componentWillUnmount() {
clearInterval(this.timer);
}
getSpinner() {
return spinners[this.props.type] || spinners.dots;
}
}
_defineProperty(Spinner, "propTypes", {
type: PropTypes.string
});
_defineProperty(Spinner, "defaultProps", {
type: 'dots'
});
module.exports = Spinner;
module.exports.default = Spinner;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = require("react");
const react_1 = require("react");
const ink_1 = require("ink");
const cli_spinners_1 = require("cli-spinners");
/**
* Spinner.
*/
const Spinner = ({ type = 'dots' }) => {
const [frame, setFrame] = react_1.useState(0);
const spinner = cli_spinners_1.default[type];
react_1.useEffect(() => {
const timer = setInterval(() => {
setFrame(previousFrame => {
const isLastFrame = previousFrame === spinner.frames.length - 1;
return isLastFrame ? 0 : previousFrame + 1;
});
}, spinner.interval);
return () => {
clearInterval(timer);
};
}, [spinner]);
return React.createElement(ink_1.Text, null, spinner.frames[frame]);
};
exports.default = Spinner;
{
"name": "ink-spinner",
"version": "3.1.0",
"version": "4.0.0-0",
"description": "Spinner component for Ink",

@@ -12,16 +12,13 @@ "license": "MIT",

},
"main": "build/index.js",
"types": "index.d.ts",
"main": "build",
"types": "build/index.d.ts",
"engines": {
"node": ">=8"
"node": ">=10"
},
"scripts": {
"pretest": "npm run build",
"test": "tsc --noEmit --jsx react --module commonjs index.test-d.tsx && xo && ava",
"build": "babel src --out-dir=build",
"prepare": "npm run build"
"test": "tsc && xo && ava",
"prepare": "tsc"
},
"files": [
"build",
"index.d.ts"
"build"
],

@@ -39,14 +36,11 @@ "keywords": [

"dependencies": {
"cli-spinners": "^1.0.0",
"prop-types": "^15.5.10"
"@types/react": "^16.9.38",
"cli-spinners": "^2.3.0"
},
"devDependencies": {
"@ava/babel": "^1.0.1",
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.3",
"@babel/plugin-proposal-class-properties": "^7.3.3",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.10.3",
"@babel/preset-react": "^7.10.1",
"@sindresorhus/tsconfig": "^0.7.0",
"@vdemedes/prettier-config": "^1.0.0",
"ava": "^3.9.0",
"babel-eslint": "^10.1.0",
"delay": "^4.1.0",

@@ -56,4 +50,7 @@ "eslint-config-xo-react": "^0.23.0",

"eslint-plugin-react-hooks": "^4.0.4",
"ink": "^2.0.0",
"ink-testing-library": "^1.0.0",
"husky": "^4.2.5",
"ink": "^3.0.0-4",
"ink-testing-library": "^2.0.0",
"prettier": "^2.0.5",
"pretty-quick": "^2.0.1",
"react": "^16.8.2",

@@ -65,28 +62,26 @@ "typescript": "^3.9.5",

"react": "^16.8.2",
"ink": "^2.0.0"
"ink": "^3.0.0-4"
},
"babel": {
"plugins": [
"@babel/plugin-proposal-class-properties"
],
"presets": [
"@babel/preset-react"
]
},
"ava": {
"babel": true,
"require": [
"@babel/register"
]
"babel": {
"testOptions": {
"presets": [
"@babel/preset-react"
]
}
}
},
"xo": {
"parser": "babel-eslint",
"extends": [
"xo-react"
],
"ignores": [
"index.d.ts",
"index.test-d.tsx"
]
"extends": "xo-react",
"prettier": true,
"rules": {
"react/prop-types": "off"
}
},
"prettier": "@vdemedes/prettier-config",
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
}
}

@@ -1,5 +0,6 @@

# ink-spinner [![Build Status](https://travis-ci.org/vadimdemedes/ink-spinner.svg?branch=master)](https://travis-ci.org/vadimdemedes/ink-spinner)
# ink-spinner ![test](https://github.com/vadimdemedes/ink-spinner/workflows/test/badge.svg)
> Spinner component for [Ink](https://github.com/vadimdemedes/ink). Uses [cli-spinners](https://github.com/sindresorhus/cli-spinners) for the collection of spinners.
Looking for a version compatible with Ink 2.x? Check out [previous release](https://github.com/vadimdemedes/ink-spinner/tree/v3.1.0).

@@ -12,15 +13,16 @@ ## Install

## Usage
```js
import React, {Fragment} from 'react';
import {render, Color} from 'ink';
```jsx
import React from 'react';
import { render, Text } from 'ink';
import Spinner from 'ink-spinner';
render(
<Fragment>
<Color green><Spinner type="dots"/></Color>
<Text>
<Text color="green">
<Spinner type="dots" />
</Text>
{' Loading'}
</Fragment>
</Text>
);

@@ -31,3 +33,2 @@ ```

## Props

@@ -41,6 +42,1 @@

Type of a spinner. See [cli-spinners](https://github.com/sindresorhus/cli-spinners) for available spinners.
## License
MIT © [Vadim Demedes](https://github.com/vadimdemedes)
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