Skip to content

Commit

Permalink
chore: organize imports and entry files
Browse files Browse the repository at this point in the history
  • Loading branch information
marcincichocki authored Oct 19, 2022
1 parent 643a37a commit 05027bf
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 38 deletions.
1 change: 1 addition & 0 deletions src/common/node/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './resolver';
export * from './robot';
export * from './sharp-image-container';
export { WasmBreachProtocolRecognizer } from './recognizer-wasm';
2 changes: 1 addition & 1 deletion src/common/node/robot/auto-hotkey.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sleep } from '@/common/util';
import { sleep } from '@/common';
import { BreachProtocolRobotKeys } from './robot';
import { WindowsRobot } from './win32';

Expand Down
2 changes: 1 addition & 1 deletion src/common/node/robot/nircmd.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sleep } from '@/common/util';
import { sleep } from '@/common';
import { BreachProtocolRobotKeys } from './robot';
import { WindowsRobot } from './win32';

Expand Down
2 changes: 1 addition & 1 deletion src/common/node/robot/robot.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sleep } from '@/common';
import * as k from '@/common/keyboard';
import { sleep } from '@/common/util';
import { execFile } from 'child_process';
import { join } from 'path';
import sanitize from 'sanitize-filename';
Expand Down
2 changes: 1 addition & 1 deletion src/common/node/robot/xdotool.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sleep } from '@/common';
import * as k from '@/common/keyboard';
import { sleep } from '@/common/util';
import {
BreachProtocolRobot,
BreachProtocolRobotKeys,
Expand Down
3 changes: 3 additions & 0 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ export type {
BreachProtocolResultJSON,
BreachProtocolStrategy,
} from './solver/breach-protocol';
export { HexCodeSequence } from './solver/hex-code-sequence';
export { FocusHierarchyProvider } from './solver/hierarchy/focus-hierarchy-provider';
export type { HierarchyProvider } from './solver/hierarchy/hierarchy-provider';
export { IndexHierarchyProvider } from './solver/hierarchy/index-hierarchy-provider';
export { TypesHierarchyProvider } from './solver/hierarchy/types-hierarchy-provider';
export type { SequenceJSON } from './solver/sequence';
export * from './daemons';
6 changes: 4 additions & 2 deletions src/core/ocr/ocr.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { SharpImageContainer } from '@/common/node';
import { WasmBreachProtocolRecognizer } from '@/common/node/recognizer-wasm';
import {
SharpImageContainer,
WasmBreachProtocolRecognizer,
} from '@/common/node';
import type { BreachProtocolLanguage } from '@/core';
import { AppSettings } from '@/electron/common';
import { join } from 'path';
Expand Down
4 changes: 2 additions & 2 deletions src/core/solver/breach-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export class BreachProtocolResult implements Serializable {
// since in very rare cases longer daemon could create
// better sequence than its shorter peers(bigger overlap).
const shouldForceClose = daemons
.filter((d, i) => !this.sequence.indexes.includes(i))
.filter((_, i) => !this.sequence.indexes.includes(i))
.some((d) => {
const daemon = d.map(fromHex).join('');
const daemon = HexCodeSequence.fromHex(d);
const r = memoizedFindOverlap(base, daemon);

// If potential result(which will never happen) will
Expand Down
2 changes: 1 addition & 1 deletion src/core/solver/hierarchy/focus-hierarchy-provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BreachProtocolRawData } from '@/core/common';
import { BreachProtocolRawData } from '../../common';
import { HierarchyProvider } from './hierarchy-provider';

/** Focuses one daemon, and applies index to others. */
Expand Down
2 changes: 1 addition & 1 deletion src/core/solver/hierarchy/index-hierarchy-provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BreachProtocolRawData } from '@/core/common';
import { BreachProtocolRawData } from '../../common';
import { HierarchyProvider } from './hierarchy-provider';

/** Marks each daemon with its index. */
Expand Down
2 changes: 1 addition & 1 deletion src/core/solver/hierarchy/types-hierarchy-provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BreachProtocolRawData } from '@/core/common';
import { BreachProtocolRawData } from '../../common';
import { HierarchyProvider } from './hierarchy-provider';
import { IndexHierarchyProvider } from './index-hierarchy-provider';

Expand Down
2 changes: 1 addition & 1 deletion src/electron/common/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
DAEMON_OPTICS_JAMMER,
DAEMON_TURRET_SHUTDOWN,
DAEMON_WEAPONS_JAMMER,
} from '@/core/daemons';
} from '@/core';
import { AppSettings } from './common';

interface BreachProtocolOption {
Expand Down
49 changes: 32 additions & 17 deletions src/electron/renderer/components/DaemonPriority.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
import { DaemonId } from '@/core';
import * as d from '@/core/daemons';
import { eng } from '@/core/daemons-i18n';
import {
DaemonId,
DAEMON_CAMERA_SHUTDOWN,
DAEMON_DATAMINE_COPY_MALWARE,
DAEMON_DATAMINE_CRAFTING_SPECS,
DAEMON_DATAMINE_V1,
DAEMON_DATAMINE_V2,
DAEMON_DATAMINE_V3,
DAEMON_FRIENDLY_TURRETS,
DAEMON_GAIN_ACCESS,
DAEMON_ICEPICK,
DAEMON_MASS_VULNERABILITY,
DAEMON_NEUTRALIZE_MALWARE,
DAEMON_OPTICS_JAMMER,
DAEMON_TURRET_SHUTDOWN,
DAEMON_WEAPONS_JAMMER,
eng,
} from '@/core';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { flushSync } from 'react-dom';
import styled from 'styled-components';
Expand Down Expand Up @@ -46,29 +61,29 @@ function moveInArray<T>(data: T[], from: number, to: number) {
}

const commonDaemons: ReadonlySet<DaemonId> = new Set([
d.DAEMON_DATAMINE_V1,
d.DAEMON_DATAMINE_V2,
d.DAEMON_DATAMINE_V3,
d.DAEMON_ICEPICK,
DAEMON_DATAMINE_V1,
DAEMON_DATAMINE_V2,
DAEMON_DATAMINE_V3,
DAEMON_ICEPICK,
]);

const perkDaemons: ReadonlySet<DaemonId> = new Set([
d.DAEMON_MASS_VULNERABILITY,
d.DAEMON_CAMERA_SHUTDOWN,
d.DAEMON_FRIENDLY_TURRETS,
d.DAEMON_TURRET_SHUTDOWN,
DAEMON_MASS_VULNERABILITY,
DAEMON_CAMERA_SHUTDOWN,
DAEMON_FRIENDLY_TURRETS,
DAEMON_TURRET_SHUTDOWN,
]);

const legendaryDaemons: ReadonlySet<DaemonId> = new Set([
d.DAEMON_OPTICS_JAMMER,
d.DAEMON_WEAPONS_JAMMER,
DAEMON_OPTICS_JAMMER,
DAEMON_WEAPONS_JAMMER,
]);

const specialDaemons: ReadonlySet<DaemonId> = new Set([
d.DAEMON_DATAMINE_COPY_MALWARE,
d.DAEMON_NEUTRALIZE_MALWARE,
d.DAEMON_GAIN_ACCESS,
d.DAEMON_DATAMINE_CRAFTING_SPECS,
DAEMON_DATAMINE_COPY_MALWARE,
DAEMON_NEUTRALIZE_MALWARE,
DAEMON_GAIN_ACCESS,
DAEMON_DATAMINE_CRAFTING_SPECS,
]);

function getDaemonType(id: DaemonId): DaemonType {
Expand Down
6 changes: 3 additions & 3 deletions src/electron/renderer/components/HistoryViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
BreachProtocolResultJSON,
BUFFER_SIZE_MIN,
DaemonsRawData,
fromHex,
HexCodeSequence,
isBufferSizeFragment,
isDaemonsFragment,
isGridFragment,
Expand Down Expand Up @@ -33,11 +33,11 @@ function getDaemonBounds(daemons: DaemonsRawData, sequence?: SequenceJSON) {
return [];
}

const st = sequence.value.map(fromHex).join('') ?? '';
const st = HexCodeSequence.fromHex(sequence?.value ?? []);

return daemons
.map((daemon) => {
const dt = daemon.map(fromHex).join('');
const dt = HexCodeSequence.fromHex(daemon);
const start = st.indexOf(dt);

if (start === -1) {
Expand Down
2 changes: 1 addition & 1 deletion src/electron/renderer/components/RecognitionSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { BreachProtocolLanguage } from '@/core';
import { BUFFER_SIZE_MAX } from '@/core';
import type { BreachProtocolLanguage } from '@/core/daemons-i18n';
import { AppSettings } from '@/electron/common';
import type { ScreenshotDisplayOutput } from 'screenshot-desktop';
import { getDisplayName, nativeDialog } from '../common';
Expand Down
4 changes: 2 additions & 2 deletions src/electron/worker/autosolver.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { BitMask, sleep, uniqueWith } from '@/common';
import { BitMask, sleep } from '@/common';
import {
BreachProtocolKeyboardResolver,
BreachProtocolMouseResolver,
BreachProtocolResolver,
BreachProtocolRobot,
SharpImageContainer,
WasmBreachProtocolRecognizer,
} from '@/common/node';
import { WasmBreachProtocolRecognizer } from '@/common/node/recognizer-wasm';
import {
BreachProtocol,
breachProtocolOCR,
Expand Down
6 changes: 3 additions & 3 deletions src/electron/worker/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {
BreachProtocolRobot,
NirCmdRobot,
SharpImageContainer,
WasmBreachProtocolRecognizer,
XDoToolRobot,
} from '@/common/node';
import { WasmBreachProtocolRecognizer } from '@/common/node/recognizer-wasm';
import {
BreachProtocolBufferSizeFragment,
BreachProtocolDaemonsFragment,
Expand All @@ -15,10 +15,10 @@ import {
BreachProtocolResultJSON,
BreachProtocolTypesFragment,
FocusHierarchyProvider,
HierarchyProvider,
IndexHierarchyProvider,
TypesHierarchyProvider,
} from '@/core';
import { HierarchyProvider } from '@/core/solver/hierarchy/hierarchy-provider';
import { TypesHierarchyProvider } from '@/core/solver/hierarchy/types-hierarchy-provider';
import {
Action,
ActionTypes,
Expand Down

0 comments on commit 05027bf

Please sign in to comment.