typing-game-cli 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.js CHANGED
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { Text, Box, useInput, useStdout } from 'ink';
3
3
  import TextInput from 'ink-text-input-2';
4
4
  import { Spinner, Alert } from '@inkjs/ui';
5
+ import chalk from 'chalk';
5
6
  import Gradient from 'ink-gradient';
6
7
  import { proxy, useSnapshot } from 'valtio';
7
8
  import random from 'just-random';
@@ -11,6 +12,11 @@ const state = proxy({
11
12
  status: 'PAUSED',
12
13
  suite: getDefaultSuite(),
13
14
  source: null,
15
+ firstPart: '',
16
+ highlightedPart: '',
17
+ erroredPart: '',
18
+ highlighingColor: 'green',
19
+ lastPart: '',
14
20
  robotText: '',
15
21
  userText: '',
16
22
  intervalId: null,
@@ -29,6 +35,10 @@ export default function App({
29
35
  state.robotText = '';
30
36
  state.status = 'RUNNING';
31
37
  state.source = random(state.suite.sentences);
38
+ state.firstPart = '';
39
+ state.highlightedPart = '';
40
+ state.erroredPart = '';
41
+ state.lastPart = state.source;
32
42
  state.level = robotLevel || 'medium';
33
43
  const interval = setInterval(() => {
34
44
  state.robotText += state.source.slice(state.robotText.length, state.robotText.length + 1);
@@ -75,16 +85,21 @@ export default function App({
75
85
  }, "y"), ' ', "to start a new round.")), /*#__PURE__*/React.createElement(Box, {
76
86
  flexDirection: "column",
77
87
  alignItems: "center",
78
- justifyContent: "center"
79
- }, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Alert, {
88
+ justifyContent: "center",
89
+ paddingBottom: 1
90
+ }, /*#__PURE__*/React.createElement(Alert, {
80
91
  variant: getStatusVariant(snap.status)
81
- }, getMessage(snap.status))))) : /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Box, {
92
+ }, getMessage(snap.status)))) : /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Box, {
82
93
  borderStyle: "single",
83
94
  alignItems: "center",
84
95
  justifyContent: "center"
85
96
  }, /*#__PURE__*/React.createElement(Spinner, null), /*#__PURE__*/React.createElement(Text, null, " Running"))), /*#__PURE__*/React.createElement(Box, {
86
- paddingBottom: 1
87
- }, /*#__PURE__*/React.createElement(Text, null, snap.source)), /*#__PURE__*/React.createElement(Box, {
97
+ height: 3,
98
+ alignItems: "center",
99
+ paddingBottom: 1,
100
+ paddingX: 2,
101
+ flexDirection: "row"
102
+ }, /*#__PURE__*/React.createElement(Text, null, chalk.bgGreen(snap.firstPart), snap.erroredPart && chalk.bgRed(snap.erroredPart), snap.lastPart)), /*#__PURE__*/React.createElement(Box, {
88
103
  alignItems: "center",
89
104
  justifyContent: "center"
90
105
  }, /*#__PURE__*/React.createElement(Box, {
@@ -94,7 +109,16 @@ export default function App({
94
109
  }, isFinished(snap.status) ? /*#__PURE__*/React.createElement(Text, null, snap.userText) : /*#__PURE__*/React.createElement(TextInput, {
95
110
  value: snap.userText,
96
111
  onChange: value => {
97
- state.userText = value;
112
+ if (snap.source.indexOf(value) === 0) {
113
+ state.firstPart = value;
114
+ state.erroredPart = '';
115
+ state.lastPart = snap.source.slice(value.length);
116
+ state.userText = value;
117
+ } else {
118
+ state.firstPart = snap.userText;
119
+ state.erroredPart = snap.source.slice(value.length - 1, value.length);
120
+ state.lastPart = snap.source.slice(value.length);
121
+ }
98
122
  }
99
123
  })), /*#__PURE__*/React.createElement(Box, {
100
124
  borderStyle: "single",
@@ -3,7 +3,7 @@
3
3
  "Had it affected his mind? His reply to my question seemed to me then evidence that it had; perhaps I should think differently about it now.",
4
4
  "In an open spot in my garden I planted a climbing vine. When it was barely above the surface I set a stake into the soil a yard away.",
5
5
  "The vine at once made for it, but as it was about to reach it after several days I removed it a few feet. The vine at once altered its course, making an acute angle, and again made for the stake.",
6
- "We were speaking, not of plants, but of machines. They may be composed partly of wood - wood that has no longer vitality - or wholly of metal.",
6
+ "We were speaking, not of plants, but of machines. They may be composed partly of wood - wood that has no longer vitality - or wholly of metal.",
7
7
  "When soldiers form lines, or hollow squares, you call it reason. When wild geese in flight take the form of a letter V you say instinct.",
8
8
  "I read it thirty years ago. He may have altered it afterward, for anything I know, but in all that time I have been unable to think of a single word that could profitably be changed or added or removed.",
9
9
  "At each recurrence it broadened in meaning and deepened in suggestion. Why, here (I thought) is something upon which to found a philosophy.",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typing-game-cli",
3
3
  "description": "Command line game to practice your typing speed",
4
- "version": "1.0.0",
4
+ "version": "2.0.0",
5
5
  "homepage": "https://github.com/akgondber/typing-game-cli",
6
6
  "repository": "akgondber/typing-game-cli",
7
7
  "license": "MIT",
@@ -29,6 +29,7 @@
29
29
  ],
30
30
  "dependencies": {
31
31
  "@inkjs/ui": "^1.0.0",
32
+ "chalk": "^5.3.0",
32
33
  "fdir": "^6.1.1",
33
34
  "ink": "^4.2.0",
34
35
  "ink-gradient": "^3.0.0",
@@ -42,20 +43,19 @@
42
43
  "just-random": "^3.2.0",
43
44
  "meow": "^12.0.1",
44
45
  "react": "^18.2.0",
45
- "valtio": "^1.13.0"
46
+ "valtio": "^1.13.1"
46
47
  },
47
48
  "devDependencies": {
48
49
  "@babel/cli": "^7.22.5",
49
50
  "@babel/preset-react": "^7.22.5",
50
51
  "ava": "^6.1.1",
51
- "chalk": "^5.2.0",
52
52
  "eslint-config-xo-react": "^0.27.0",
53
53
  "eslint-plugin-react": "^7.32.2",
54
54
  "eslint-plugin-react-hooks": "^4.6.0",
55
55
  "import-jsx": "^5.0.0",
56
56
  "ink-testing-library": "^3.0.0",
57
57
  "prettier": "^2.8.8",
58
- "xo": "^0.54.2"
58
+ "xo": "^0.57.0"
59
59
  },
60
60
  "ava": {
61
61
  "environmentVariables": {