my-singbox 2.0.0-next.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,7 +27,6 @@ export declare class IspService {
27
27
  checkCandidate(image: string, candidatePath: string): Promise<boolean>;
28
28
  portListening(proto: 'tcp' | 'udp', port: number): Promise<ListenerStatus>;
29
29
  waitListening(proto: 'tcp' | 'udp', port: number): Promise<boolean>;
30
- portsFree(): Promise<void>;
31
- verifyService(expectIsp: boolean): Promise<boolean>;
30
+ verifyService(): Promise<boolean>;
32
31
  socksEgressIp(isp: IspSocks): Promise<string | undefined>;
33
32
  }
@@ -1,7 +1,9 @@
1
1
  import { type IspSocks } from '../model.js';
2
2
  import type { SingboxConfig } from './render-config.js';
3
+ import { type RoutePolicy } from './routing.js';
3
4
  export declare const ISP_BACKUP_DIR = ".isp-backup", ISP_LOCK_FILE = ".isp.lock", ISP_TMP_PREFIX = ".isp-tmp.", GROUP_MAIN = "Proxy";
4
- export declare const MANAGED_FILES: readonly ['config.json', 'clash.yaml', '.env'];
5
+ export declare const MANAGED_FILES: readonly ['config.json', '.env'];
6
+ export type ManagedFile = typeof MANAGED_FILES[number] | 'clash.yaml';
5
7
  export declare class IspError extends Error {
6
8
  name: string;
7
9
  }
@@ -9,13 +11,11 @@ export declare function envGet(text: string, key: string): string | undefined;
9
11
  export declare function envHasIsp(text: string): boolean;
10
12
  export declare function checkIspConfig(config: unknown): asserts config is SingboxConfig;
11
13
  export declare function configHasIsp(config: SingboxConfig): boolean;
12
- export declare function addIspToConfig(config: SingboxConfig, isp: IspSocks): SingboxConfig;
13
- export declare function clashHasIsp(text: string): boolean;
14
- export declare function addIspToClash(text: string, realityPrivateKey?: string): string;
14
+ export declare function addIspToConfig(config: SingboxConfig, isp: IspSocks, routeDefaults?: RoutePolicy): SingboxConfig;
15
+ export declare function removeIspFromConfig(config: SingboxConfig): SingboxConfig;
15
16
  export declare function makeTmpPath(projectDir: string): string;
16
17
  export declare function installFile(dest: string, data: string | Uint8Array, projectDir: string): void;
17
- export declare function makeBackup(projectDir: string): string;
18
- export declare function findCleanBackup(projectDir: string): string | undefined;
19
- export declare function restoreBackup(projectDir: string, backupDir: string): void;
18
+ export declare function makeBackup(projectDir: string, files?: readonly ManagedFile[]): string;
19
+ export declare function restoreBackup(projectDir: string, backupDir: string, files?: readonly ManagedFile[]): void;
20
20
  export declare function sweepStaleTmp(projectDir: string): void;
21
21
  export declare function withLock<T>(projectDir: string, fn: () => Promise<T>): Promise<T>;
@@ -10,4 +10,4 @@ export interface SingboxConfig {
10
10
  }
11
11
  export declare function renderSingbox(model: Model, template: unknown): SingboxConfig;
12
12
  export declare function serializeSingbox(config: SingboxConfig): string;
13
- export declare function loadSingboxTemplate(projectDir?: string): unknown;
13
+ export declare function loadSingboxTemplate(projectDir?: string): SingboxConfig;
@@ -0,0 +1,13 @@
1
+ import { type IspSocks } from '../model.js';
2
+ import type { SingboxConfig } from './render-config.js';
3
+ export type RoutePolicy = NonNullable<SingboxConfig['route']>;
4
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
5
+ export declare function isIspRule(value: unknown): value is Record<string, unknown>;
6
+ /** The old generated rule selected only the dedicated ISP listener tags. */
7
+ export declare function isLegacyIspRule(value: unknown): boolean;
8
+ /** Fail rather than silently changing references outside optional top-level rules. */
9
+ export declare function checkNoIspReferences(config: SingboxConfig): void;
10
+ export declare function upsertIspOutbound(config: SingboxConfig, isp: IspSocks): void;
11
+ /** Mutates only the optional outbound and top-level rules targeting it. */
12
+ export declare function omitIsp(config: SingboxConfig): void;
13
+ export declare function ensureRoute(config: SingboxConfig, defaults?: RoutePolicy): void;