From 3f2341f36f4afd6a95945ce0d3e6caa4d0d5ad7a Mon Sep 17 00:00:00 2001 From: Katsuyuki-Karasawa <4ranci0ne@gmail.com> Date: Sun, 2 Jun 2024 21:55:20 +0900 Subject: [PATCH 1/2] remove lodash dash and @types/lodash --- package.json | 1 - src/components/configure/keycodekey/KeyGen.ts | 3 +-- src/components/configure/macroeditor/MacroEditor.tsx | 8 ++++---- yarn.lock | 1 - 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 133e35dd..4f54dfd4 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,6 @@ "@types/ajv": "^1.0.0", "@types/axios": "^0.14.0", "@types/downloadjs": "^1.4.2", - "@types/lodash": "^4.14.167", "@types/node": "^14.14.22", "@types/prop-types": "^15.7.4", "@types/qs": "^6.9.6", diff --git a/src/components/configure/keycodekey/KeyGen.ts b/src/components/configure/keycodekey/KeyGen.ts index b3f42ac0..63570a01 100644 --- a/src/components/configure/keycodekey/KeyGen.ts +++ b/src/components/configure/keycodekey/KeyGen.ts @@ -8,7 +8,6 @@ import { KeyLabelLangs, } from '../../../services/labellang/KeyLabelLangs'; import { mods2Number } from '../customkey/Modifiers'; -import _ from 'lodash'; import { MOD_LEFT, MOD_RIGHT } from '../../../services/hid/Constraints'; export type Key = { @@ -98,7 +97,7 @@ export const genKey = (keymap: IKeymap, lang?: KeyboardLabelLang): Key => { let newKeymap: IKeymap = keymap; if (0 < keytop.keywords.length) { - newKeymap = _.cloneDeep(keymap) as IKeymap; + newKeymap = structuredClone(keymap) as IKeymap; newKeymap.keycodeInfo.keywords = newKeymap.keycodeInfo.keywords.concat( keytop.keywords ); diff --git a/src/components/configure/macroeditor/MacroEditor.tsx b/src/components/configure/macroeditor/MacroEditor.tsx index 250af85c..7f5f3c4c 100644 --- a/src/components/configure/macroeditor/MacroEditor.tsx +++ b/src/components/configure/macroeditor/MacroEditor.tsx @@ -60,7 +60,7 @@ export default class MacroEditor extends React.Component< indexInHold: number, newKeyDelayPair: KeyDelayPair ) { - const macroKeys: MacroKey[] = lodash.cloneDeep(this.props.macroKeys!); + const macroKeys: MacroKey[] = structuredClone(this.props.macroKeys!); if (Number.isNaN(indexInHold)) { // TODO: Set delay. const tap: Tap = { @@ -85,7 +85,7 @@ export default class MacroEditor extends React.Component< } private addTapKeys(index: number, newKeyDelayPairs: KeyDelayPair[]) { - const macroKeys: MacroKey[] = lodash.cloneDeep(this.props.macroKeys!); + const macroKeys: MacroKey[] = structuredClone(this.props.macroKeys!); const taps: Tap[] = newKeyDelayPairs.map((v) => { // TODO: Set delay. return { keyDelayPair: v, type: MacroTap }; @@ -95,7 +95,7 @@ export default class MacroEditor extends React.Component< } private popKey() { - const macroKeys: MacroKey[] = lodash.cloneDeep(this.props.macroKeys!); + const macroKeys: MacroKey[] = structuredClone(this.props.macroKeys!); this.props.updateMacroKeys!(macroKeys.slice(0, -1)); } @@ -129,7 +129,7 @@ export default class MacroEditor extends React.Component< if (fromIndex === toIndex && fromIndexInHold === toIndexInHold) { return; } - const macroKeys: MacroKey[] = lodash.cloneDeep(this.props.macroKeys!); + const macroKeys: MacroKey[] = structuredClone(this.props.macroKeys!); const srcMacroKey: MacroKey = macroKeys[fromIndex]; const dstMacroKey: MacroKey = macroKeys[toIndex]; if (fromIndex === toIndex && isHold(srcMacroKey)) { diff --git a/yarn.lock b/yarn.lock index c7918443..34ab3de8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5938,7 +5938,6 @@ __metadata: "@types/ajv": "npm:^1.0.0" "@types/axios": "npm:^0.14.0" "@types/downloadjs": "npm:^1.4.2" - "@types/lodash": "npm:^4.14.167" "@types/node": "npm:^14.14.22" "@types/prop-types": "npm:^15.7.4" "@types/qs": "npm:^6.9.6" From 3abb05ccfd81dc9323ee3a3742abd276319b433a Mon Sep 17 00:00:00 2001 From: Katsuyuki-Karasawa <4ranci0ne@gmail.com> Date: Sun, 2 Jun 2024 21:55:56 +0900 Subject: [PATCH 2/2] remove unused import --- src/components/configure/macroeditor/MacroEditor.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/configure/macroeditor/MacroEditor.tsx b/src/components/configure/macroeditor/MacroEditor.tsx index 7f5f3c4c..bd54a476 100644 --- a/src/components/configure/macroeditor/MacroEditor.tsx +++ b/src/components/configure/macroeditor/MacroEditor.tsx @@ -18,7 +18,6 @@ import { Tap, KeyDelayPair, } from '../../../services/macro/Macro'; -import lodash from 'lodash'; import FlashButton, { FlashButtonState } from '../../common/flash/FlashButton'; import { KeycodeCompositionFactory } from '../../../services/hid/Composition'; import { MacroDropSpacer } from './MacroDropSpacer';