Skip to content

Commit

Permalink
#304: Remove unused deps
Browse files Browse the repository at this point in the history
  • Loading branch information
caiiiycuk committed Jul 5, 2024
1 parent 218b330 commit 5de0535
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 72 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
},
"dependencies": {
"@reduxjs/toolkit": "^1.9.7",
"element-resize-detector": "^1.2.4",
"nipplejs": "^0.10.2",
"preact": "^10.19.3",
"react-checkbox-tree": "^1.8.0",
"react-redux": "^8.1.3",
"simple-keyboard": "^3.4.126"
"react-redux": "^8.1.3"
},
"devDependencies": {
"@preact/preset-vite": "^2.8.1",
Expand Down
100 changes: 48 additions & 52 deletions src/layers/dom/layers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Keyboard from "simple-keyboard";
import elementResizeDetector from "element-resize-detector";
import { createDiv, stopPropagation } from "./helpers";

/* eslint-disable camelcase */
Expand Down Expand Up @@ -42,8 +40,6 @@ export class Layers {

// eslint-disable-next-line
constructor(root: HTMLDivElement, canvas: HTMLCanvasElement, options: LayersOptions) {
const resizeDetector = elementResizeDetector({});

this.options = options;
this.root = root;
this.root.classList.add("emulator-root");
Expand All @@ -63,17 +59,17 @@ export class Layers {
this.onKeyPress = () => {/**/};
this.onKeysPress = () => {/**/};

resizeDetector.listenTo(this.root, (el: HTMLElement) => {
if (el !== root) {
return;
}

this.width = el.offsetWidth;
this.height = el.offsetHeight;
for (const next of this.onResize) {
next(this.width, this.height);
new ResizeObserver((entries) => {
for (const e of entries) {
if (e.target === root) {
this.width = e.contentRect.width;
this.height = e.contentRect.height;
for (const next of this.onResize) {
next(this.width, this.height);
}
}
}
});
}).observe(this.root);

this.initKeyEvents();
this.initKeyboard();
Expand Down Expand Up @@ -195,50 +191,50 @@ export class Layers {
",": "б", ".": "ю",
};
const displayOrder = [enLayoutDisplay, ruLayoutDisplay];

Check failure on line 193 in src/layers/dom/layers.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'displayOrder' is assigned a value but never used
let displayIndex = 0;
const displayIndex = 0;

Check failure on line 194 in src/layers/dom/layers.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'displayIndex' is assigned a value but never used

const keyboardDiv = this.options.keyboardDiv || createDiv("");
keyboardDiv.classList.add("emulator-keyboard");
keyboardDiv.style.display = "none";
stopPropagation(keyboardDiv);

const keyboard = new Keyboard(keyboardDiv, {
layout,
layoutName: "en",
display: displayOrder[displayIndex],
onKeyPress: (button: string) => {
if (button === "⎘") {
return;
}

const keyCodes = buttonToCode(button);
for (const keyCode of keyCodes) {
this.fireKeyDown(keyCode);
}
},
onKeyReleased: (button: string) => {
if (button === "⎘") {
displayIndex = (displayIndex + 1) % displayOrder.length;
keyboard.setOptions({
display: displayOrder[displayIndex],
});
return;
}

const keyCodes = buttonToCode(button);
for (const keyCode of keyCodes) {
this.fireKeyUp(keyCode);
}
},
preventMouseDownDefault: true,
preventMouseUpDefault: true,
stopMouseDownPropagation: true,
stopMouseUpPropagation: true,
physicalKeyboardHighlight: false,
physicalKeyboardHighlightPress: false,
physicalKeyboardHighlightPressUseClick: false,
physicalKeyboardHighlightPressUsePointerEvents: false,
});
// const keyboard = new Keyboard(keyboardDiv, {
// layout,
// layoutName: "en",
// display: displayOrder[displayIndex],
// onKeyPress: (button: string) => {
// if (button === "⎘") {
// return;
// }

// const keyCodes = buttonToCode(button);
// for (const keyCode of keyCodes) {
// this.fireKeyDown(keyCode);
// }
// },
// onKeyReleased: (button: string) => {
// if (button === "⎘") {
// displayIndex = (displayIndex + 1) % displayOrder.length;
// keyboard.setOptions({
// display: displayOrder[displayIndex],
// });
// return;
// }

// const keyCodes = buttonToCode(button);
// for (const keyCode of keyCodes) {
// this.fireKeyUp(keyCode);
// }
// },
// preventMouseDownDefault: true,
// preventMouseUpDefault: true,
// stopMouseDownPropagation: true,
// stopMouseUpPropagation: true,
// physicalKeyboardHighlight: false,
// physicalKeyboardHighlightPress: false,
// physicalKeyboardHighlightPressUseClick: false,
// physicalKeyboardHighlightPressUsePointerEvents: false,
// });

this.toggleKeyboard = () => {
keyboardVisible = !keyboardVisible;
Expand Down
17 changes: 0 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -866,11 +866,6 @@ balanced-match@^1.0.0:
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==

[email protected]:
version "1.0.0"
resolved "https://registry.yarnpkg.com/batch-processor/-/batch-processor-1.0.0.tgz#75c95c32b748e0850d10c2b168f6bdbe9891ace8"
integrity sha512-xoLQD8gmmR32MeuBHgH0Tzd5PuSZx71ZsbhVxOCRbgktZEPe4SQy7s9Z50uPp0F/f7iw2XmkHN2xkgbMfckMDA==

binary-extensions@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
Expand Down Expand Up @@ -1164,13 +1159,6 @@ electron-to-chromium@^1.4.648:
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.653.tgz#832ab25e80ad698ac09c1ca547bd9ee6cce7df10"
integrity sha512-wA2A2LQCqnEwQAvwADQq3KpMpNwgAUBnRmrFgRzHnPhbQUFArTR32Ab46f4p0MovDLcg4uqd4nCsN2hTltslpA==

element-resize-detector@^1.2.4:
version "1.2.4"
resolved "https://registry.yarnpkg.com/element-resize-detector/-/element-resize-detector-1.2.4.tgz#3e6c5982dd77508b5fa7e6d5c02170e26325c9b1"
integrity sha512-Fl5Ftk6WwXE0wqCgNoseKWndjzZlDCwuPTcoVZfCP9R3EHQF8qUtr3YUPNETegRBOKqQKPW3n4kiIWngGi8tKg==
dependencies:
batch-processor "1.0.0"

[email protected]:
version "8.1.3"
resolved "https://registry.yarnpkg.com/emulators/-/emulators-8.1.3.tgz#6267371bc85eeafe66f709ceba830cbfba7780bd"
Expand Down Expand Up @@ -2210,11 +2198,6 @@ shebang-regex@^3.0.0:
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==

simple-keyboard@^3.4.126:
version "3.7.88"
resolved "https://registry.yarnpkg.com/simple-keyboard/-/simple-keyboard-3.7.88.tgz#d94421b350054e798c3cc70d1d806423eec99efa"
integrity sha512-HnW2MfB4SZkvg+4BaHLf5+QWnTr/XZZ3da9tO1Txj0vs5teAgGQKa9O9fp2ZMDiNY0VJoMWt/X6QIpBghpgi1g==

slash@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
Expand Down

0 comments on commit 5de0535

Please sign in to comment.