Skip to content

Commit 87aed2a

Browse files
authored
Merge pull request #2 from tomoemon/remove-key-generics
remove generic virtual key
2 parents cbe1d44 + 01da87a commit 87aed2a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4740
-1792
lines changed

examples/react-keyboardguide/src/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { KeyRect, KeyTop, KeyboardState, KeyboardStateReader, guide, keyboard } from 'emiel'
1+
import { KeyRect, KeyTop, KeyboardState, guide, keyboard } from 'emiel'
22
import { useEffect, useState } from 'react';
33
import * as emiel from 'emiel';
44

55
function App() {
6-
const [keyboardState, setKeyboardState] = useState<KeyboardStateReader>(new KeyboardState([]));
6+
const [keyboardState, setKeyboardState] = useState<emiel.KeyboardStateReader>(new KeyboardState([]));
77
useEffect(() => {
88
emiel.activate(window, (evt) => {
99
console.log("down", evt.input.key);
@@ -125,7 +125,7 @@ function KeyboardGuideComponent(props: {
125125
layoutName: string,
126126
physicalLayoutName: string,
127127
guideName: string,
128-
kbdState: KeyboardStateReader,
128+
kbdState: emiel.KeyboardStateReader,
129129
showVirtualKeyCodes: boolean,
130130
}) {
131131
// console.log("guide component", props.layout.name, props.kbdGuide.guideData.name);

examples/react-multi-word/src/App.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import "./App.css";
22
import * as emiel from "emiel";
33
import { useEffect, useState } from "react";
44
import { Word } from "./word";
5-
import { InputEvent } from "../../../dist/types/core/ruleStroke";
65

76
// 繰り返し次のワードを生成するジェネレータ
87
const wordGen = (function* wordGenerator(): Generator<string, string> {
@@ -26,7 +25,7 @@ const initialWords = Array.from({ length: 3 }, () => wordGen.next().value);
2625
class PositionAutomaton implements emiel.Inputtable {
2726
constructor(readonly base: emiel.Automaton, readonly position: number) {
2827
}
29-
input(stroke: InputEvent<emiel.VirtualKey>): emiel.InputResult {
28+
input(stroke: emiel.InputEvent): emiel.InputResult {
3029
return this.base.input(stroke);
3130
}
3231
reset(): void {

examples/react-result-record/src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ function App() {
1616
displayedAt: Date,
1717
missCount: number
1818
) => {
19-
setWordRecords([
19+
console.log("missCount: ", missCount);
20+
setWordRecords((wordRecords) => [
2021
...wordRecords,
2122
{
2223
automaton: a,

examples/react-result-record/src/Typing.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ export function Typing(props: {
2828
useEffect(() => {
2929
setWordDisplayedAt(new Date());
3030
return emiel.activate(window, (e) => {
31+
console.log("missCount in activate: ", missCount);
3132
setLastInputKey(e.input);
3233
const result = automaton.input(e);
3334
if (result.isFinished) {
35+
console.log("missCount in: ", missCount);
3436
props.onWordFinished(automaton, wordDisplayedAt, missCount);
3537
if (wordIndex === words.length - 1) {
3638
props.onFinished();
@@ -54,6 +56,12 @@ export function Typing(props: {
5456
<span style={{ color: "gray" }}>{automaton.finishedRoman}</span>{" "}
5557
{automaton.pendingRoman}
5658
</h1>
59+
<h2>
60+
Miss:{" "}
61+
<code>
62+
{missCount}
63+
</code>
64+
</h2>
5765
<h2>
5866
Key:{" "}
5967
<code style={{ border: "1px solid gray", padding: "0.2rem" }}>

examples/react-stroke-graph/src/typingGraph.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@ export function TypingGraph(props: {
4444
}
4545
});
4646
return deactivate;
47-
}, [props.automaton]);
47+
}, [automaton, graphData.edges, graphData.nodes, graphData.nodesMap, props, props.automaton]);
4848

49-
const finishedRomanSubstr = automaton.finishedRomanSubstr;
50-
const pendingRomanSubstr = automaton.pendingRomanSubstr;
49+
const finishedRomanSubstr = automaton.finishedRoman;
50+
const pendingRomanSubstr = automaton.pendingRoman;
5151
return (
5252
<>
5353
<h2>{props.ruleName}</h2>
5454
<h1>
55-
<span style={{ color: "gray" }}>{automaton.finishedWordSubstr}</span>{" "}
56-
{automaton.pendingWordSubstr}
55+
<span style={{ color: "gray" }}>{automaton.finishedWord}</span>{" "}
56+
{automaton.pendingWord}
5757
</h1>
5858
{finishedRomanSubstr || pendingRomanSubstr ? (
5959
<h1>
60-
<span style={{ color: "gray" }}>{automaton.finishedRomanSubstr}</span>{" "}
61-
{automaton.pendingRomanSubstr}
60+
<span style={{ color: "gray" }}>{automaton.finishedRoman}</span>{" "}
61+
{automaton.pendingRoman}
6262
</h1>
6363
) : (
6464
<></>

0 commit comments

Comments
 (0)