refactor: reorganize services

This commit is contained in:
divocat
2025-10-14 21:32:06 +03:00
parent de3e67f999
commit 33dfb8c3f0
13 changed files with 122 additions and 120 deletions

View File

@@ -1,5 +1,5 @@
import { TabServiceInstance } from './tab.service';
import { store } from '../../store';
import { store } from './store.service';
export function coreService() {
TabServiceInstance.onChange((activeId, tabs) => {

View File

@@ -1,2 +1,4 @@
export * from './tab.service';
export * from './core.service';
export * from './socket.service';
export * from './store.service';

View File

@@ -1,5 +1,5 @@
import { Podkop } from './podkop/types';
import { initialDiagnosticStore } from './podkop/tabs/diagnostic/diagnostic.store';
import { Podkop } from '../types';
import { initialDiagnosticStore } from '../tabs/diagnostic/diagnostic.store';
function jsonStableStringify<T, V>(obj: T): string {
return JSON.stringify(obj, (_, value) => {
@@ -29,7 +29,7 @@ function jsonEqual<A, B>(a: A, b: B): boolean {
type Listener<T> = (next: T, prev: T, diff: Partial<T>) => void;
// eslint-disable-next-line
class Store<T extends Record<string, any>> {
class StoreService<T extends Record<string, any>> {
private value: T;
private readonly initial: T;
private listeners = new Set<Listener<T>>();
@@ -207,4 +207,4 @@ const initialStore: StoreType = {
...initialDiagnosticStore,
};
export const store = new Store<StoreType>(initialStore);
export const store = new StoreService<StoreType>(initialStore);

View File

@@ -4,8 +4,6 @@ import {
onMount,
preserveScrollForPage,
} from '../../../helpers';
import { store, StoreType } from '../../../store';
import { socket } from '../../../socket';
import { prettyBytes } from '../../../helpers/prettyBytes';
import { renderSections } from './renderSections';
import { renderWidget } from './renderWidget';
@@ -14,6 +12,7 @@ import {
CustomPodkopMethods,
PodkopShellMethods,
} from '../../methods';
import { socket, store, StoreType } from '../../services';
// Fetchers

View File

@@ -1,8 +1,8 @@
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
import { insertIf } from '../../../../helpers';
import { IDiagnosticsChecksItem } from '../../../../store';
import { DIAGNOSTICS_CHECKS_MAP } from './contstants';
import { PodkopShellMethods } from '../../../methods';
import { IDiagnosticsChecksItem } from '../../../services';
export async function runDnsCheck() {
const { order, title, code } = DIAGNOSTICS_CHECKS_MAP.DNS;

View File

@@ -1,8 +1,8 @@
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
import { insertIf } from '../../../../helpers';
import { IDiagnosticsChecksItem } from '../../../../store';
import { DIAGNOSTICS_CHECKS_MAP } from './contstants';
import { PodkopShellMethods, RemoteFakeIPMethods } from '../../../methods';
import { IDiagnosticsChecksItem } from '../../../services';
export async function runFakeIPCheck() {
const { order, title, code } = DIAGNOSTICS_CHECKS_MAP.FAKEIP;

View File

@@ -1,7 +1,6 @@
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
import { DIAGNOSTICS_CHECKS_MAP } from './contstants';
import { RemoteFakeIPMethods } from '../../../methods/fakeip';
import { PodkopShellMethods } from '../../../methods';
import { RemoteFakeIPMethods, PodkopShellMethods } from '../../../methods';
export async function runNftCheck() {
const { order, title, code } = DIAGNOSTICS_CHECKS_MAP.NFT;

View File

@@ -2,7 +2,7 @@ import {
DIAGNOSTICS_CHECKS,
DIAGNOSTICS_CHECKS_MAP,
} from './checks/contstants';
import { StoreType } from '../../../store';
import { StoreType } from '../../services';
export const initialDiagnosticStore: Pick<
StoreType,

View File

@@ -1,5 +1,4 @@
import { onMount, preserveScrollForPage } from '../../../helpers';
import { store, StoreType } from '../../../store';
import { renderCheckSection } from './renderCheckSection';
import { runDnsCheck } from './checks/runDnsCheck';
import { runSingBoxCheck } from './checks/runSingBoxCheck';
@@ -9,6 +8,7 @@ import { renderDiagnosticRunAction } from './renderDiagnosticRunAction';
import { renderAvailableActions } from './renderAvailableActions';
import { renderSystemInfo } from './renderSystemInfo';
import { loadingDiagnosticsChecksStore } from './diagnostic.store';
import { store, StoreType } from '../../services';
function renderDiagnosticsChecks() {
console.log('renderDiagnosticsChecks');

View File

@@ -8,7 +8,7 @@ import {
renderTriangleAlertIcon24,
renderXIcon24,
} from '../../../icons';
import { IDiagnosticsChecksStoreItem } from '../../../store';
import { IDiagnosticsChecksStoreItem } from '../../services';
type IRenderCheckSectionProps = IDiagnosticsChecksStoreItem;

View File

@@ -1,4 +1,4 @@
import { IDiagnosticsChecksStoreItem, store } from '../../../store';
import { IDiagnosticsChecksStoreItem, store } from '../../services';
export function updateDiagnosticsCheck(
check: IDiagnosticsChecksStoreItem,