proxylang 0.1.6 → 0.1.7
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.
- package/dist/cli.js +5 -4
- package/dist/index.d.ts +232 -162
- package/dist/index.js +2 -2
- package/dist/{surge-build-DbQ9Ddhc.js → profile-build-BLB8hvyw.js} +1783 -1494
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { H as compile, U as explain, Z as StaticRuleSetUnknownError, a as surgeBuildFailure, i as runSurgeBuild, n as runBuild, nt as requestSchema, q as targetCatalog, s as buildToDirectory } from "./profile-build-BLB8hvyw.js";
|
|
3
3
|
import { open } from "node:fs/promises";
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
@@ -15,6 +15,7 @@ const failure = (code) => {
|
|
|
15
15
|
return 1;
|
|
16
16
|
};
|
|
17
17
|
const usages = {
|
|
18
|
+
"profile-build": ["proxylang profile-build config.ts --out DIRECTORY [--validation]"],
|
|
18
19
|
"surge-build": ["proxylang surge-build config.ts --out DIRECTORY [--validation]"],
|
|
19
20
|
targets: ["proxylang targets"],
|
|
20
21
|
check: ["proxylang check config.ts"],
|
|
@@ -84,7 +85,7 @@ async function main(args) {
|
|
|
84
85
|
});
|
|
85
86
|
return 0;
|
|
86
87
|
}
|
|
87
|
-
if (command === "surge-build") return surgeBuildCommand(file, rest);
|
|
88
|
+
if (command === "surge-build" || command === "profile-build") return surgeBuildCommand(file, rest, command === "profile-build");
|
|
88
89
|
if (![
|
|
89
90
|
"check",
|
|
90
91
|
"explain",
|
|
@@ -165,7 +166,7 @@ async function main(args) {
|
|
|
165
166
|
});
|
|
166
167
|
return built.exitCode;
|
|
167
168
|
}
|
|
168
|
-
async function surgeBuildCommand(file, args) {
|
|
169
|
+
async function surgeBuildCommand(file, args, portable) {
|
|
169
170
|
const invalid = () => {
|
|
170
171
|
print(surgeBuildFailure("INVALID_ARGUMENTS"));
|
|
171
172
|
return 1;
|
|
@@ -194,7 +195,7 @@ async function surgeBuildCommand(file, args) {
|
|
|
194
195
|
print(surgeBuildFailure("PROFILE_DEFINITION_FAILED", validation));
|
|
195
196
|
return 1;
|
|
196
197
|
}
|
|
197
|
-
const result = await runSurgeBuild(config, output, { validation });
|
|
198
|
+
const result = portable ? await runBuild(config, output, { validation }) : await runSurgeBuild(config, output, { validation });
|
|
198
199
|
print(result);
|
|
199
200
|
return result.exitCode;
|
|
200
201
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -494,6 +494,218 @@ export declare function compileSurgeProfile(input: unknown): SurgeProfileCompila
|
|
|
494
494
|
export declare function renderSurgeProfile(compilation: SurgeProfileCompilation, resolveSecret: (token: Secret) => string | undefined): SurgeProfileArtifact;
|
|
495
495
|
export declare function renderSurgeProfiles(compilations: readonly SurgeProfileCompilation[], resolveSecret: (token: Secret) => string | undefined): readonly SurgeProfileArtifact[];
|
|
496
496
|
//#endregion
|
|
497
|
+
//#region src/targets.d.ts
|
|
498
|
+
export declare const targetCatalog: readonly [{
|
|
499
|
+
readonly engine: "sing-box";
|
|
500
|
+
readonly version: "1.11.0";
|
|
501
|
+
readonly autoGroup: "urltest";
|
|
502
|
+
readonly platforms: readonly ["linux", "macos"];
|
|
503
|
+
readonly protocols: readonly ["trojan", "http", "shadowsocks", "vmess", "vless"];
|
|
504
|
+
readonly endpoints: readonly [];
|
|
505
|
+
readonly groups: readonly ["select", "urltest"];
|
|
506
|
+
readonly nativeRuleSets: readonly ["source", "binary"];
|
|
507
|
+
readonly dns: "legacy";
|
|
508
|
+
}, {
|
|
509
|
+
readonly engine: "sing-box";
|
|
510
|
+
readonly version: "1.12.0";
|
|
511
|
+
readonly autoGroup: "urltest";
|
|
512
|
+
readonly platforms: readonly ["linux", "macos"];
|
|
513
|
+
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
|
|
514
|
+
readonly endpoints: readonly ["sing-box-tailscale"];
|
|
515
|
+
readonly groups: readonly ["select", "urltest"];
|
|
516
|
+
readonly nativeRuleSets: readonly ["source", "binary"];
|
|
517
|
+
readonly dns: "typed";
|
|
518
|
+
}, {
|
|
519
|
+
readonly engine: "surge";
|
|
520
|
+
readonly version: "6.10.0";
|
|
521
|
+
readonly autoGroup: "surge-smart";
|
|
522
|
+
readonly platforms: readonly ["macos"];
|
|
523
|
+
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess"];
|
|
524
|
+
readonly endpoints: readonly [];
|
|
525
|
+
readonly groups: readonly ["select", "surge-smart"];
|
|
526
|
+
readonly nativeRuleSets: readonly ["rule-set", "domain-set"];
|
|
527
|
+
readonly dns: "general";
|
|
528
|
+
}, {
|
|
529
|
+
readonly engine: "mihomo";
|
|
530
|
+
readonly version: "1.19.32";
|
|
531
|
+
readonly autoGroup: "urltest";
|
|
532
|
+
readonly platforms: readonly ["linux", "macos"];
|
|
533
|
+
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
|
|
534
|
+
readonly endpoints: readonly [];
|
|
535
|
+
readonly groups: readonly ["select", "urltest"];
|
|
536
|
+
readonly nativeRuleSets: readonly ["yaml", "text"];
|
|
537
|
+
readonly dns: "clash";
|
|
538
|
+
}, {
|
|
539
|
+
readonly engine: "stash";
|
|
540
|
+
readonly version: "4.2.1";
|
|
541
|
+
readonly autoGroup: null;
|
|
542
|
+
readonly platforms: readonly ["macos"];
|
|
543
|
+
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess"];
|
|
544
|
+
readonly endpoints: readonly [];
|
|
545
|
+
readonly groups: readonly ["select"];
|
|
546
|
+
readonly nativeRuleSets: readonly [];
|
|
547
|
+
readonly dns: "external";
|
|
548
|
+
}];
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region src/compiler.d.ts
|
|
551
|
+
type TargetPlan = {
|
|
552
|
+
readonly target: Target;
|
|
553
|
+
readonly program: Omit<Program, "groups"> & {
|
|
554
|
+
readonly groups: readonly ConcreteGroup[];
|
|
555
|
+
};
|
|
556
|
+
readonly nativeRuleSets: readonly NativeRuleSet[];
|
|
557
|
+
readonly strategySelections: readonly StrategySelection[];
|
|
558
|
+
readonly rules: readonly ExpandedRule[];
|
|
559
|
+
readonly sourceMap: readonly {
|
|
560
|
+
readonly rule: string;
|
|
561
|
+
readonly nativeIndex: number;
|
|
562
|
+
readonly origin: readonly string[];
|
|
563
|
+
}[];
|
|
564
|
+
readonly preconditions: readonly string[];
|
|
565
|
+
readonly nativeValidation: "not-run";
|
|
566
|
+
};
|
|
567
|
+
type Compilation = {
|
|
568
|
+
readonly ok: boolean;
|
|
569
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
570
|
+
readonly plans: readonly TargetPlan[];
|
|
571
|
+
readonly cases: readonly CaseResult[];
|
|
572
|
+
};
|
|
573
|
+
type CaseResult = {
|
|
574
|
+
readonly id: string;
|
|
575
|
+
readonly passed: boolean;
|
|
576
|
+
readonly actual: {
|
|
577
|
+
readonly rule: string;
|
|
578
|
+
readonly action: Action;
|
|
579
|
+
};
|
|
580
|
+
} | {
|
|
581
|
+
readonly id: string;
|
|
582
|
+
readonly passed: false;
|
|
583
|
+
readonly code: "CASE_INDETERMINATE";
|
|
584
|
+
};
|
|
585
|
+
export declare function compile(input: unknown): Compilation;
|
|
586
|
+
export declare function explain(compilation: Compilation, target: string, request: Request): Explanation;
|
|
587
|
+
//#endregion
|
|
588
|
+
//#region src/surge-definitions.d.ts
|
|
589
|
+
type Builtin = Extract<SurgePolicy, {
|
|
590
|
+
builtin: string;
|
|
591
|
+
}>;
|
|
592
|
+
type Destination = ProxyNode | ProxyGroupDefinition | SurgeTunnel | Builtin;
|
|
593
|
+
interface ProxyGroupDefinition<A extends GroupAlgorithm = Extract<GroupAlgorithm, {
|
|
594
|
+
type: "select" | "surge-smart";
|
|
595
|
+
}>, D extends ProfileDestination = Destination> {
|
|
596
|
+
readonly type: "proxy-group";
|
|
597
|
+
readonly id: string;
|
|
598
|
+
readonly name: string;
|
|
599
|
+
readonly algorithm: A;
|
|
600
|
+
readonly members: readonly D[];
|
|
601
|
+
readonly url?: string;
|
|
602
|
+
readonly intervalSeconds?: number;
|
|
603
|
+
readonly timeoutSeconds?: number;
|
|
604
|
+
}
|
|
605
|
+
type RouteDefinition<C extends ProfileCondition = SurgeCondition, D extends ProfileDestination = Destination> = {
|
|
606
|
+
readonly type: "route";
|
|
607
|
+
readonly when: C;
|
|
608
|
+
readonly to: D;
|
|
609
|
+
};
|
|
610
|
+
type SurgeProfileDefinition = Omit<SurgeProfileInput, "groups" | "rules" | "fallback"> & {
|
|
611
|
+
readonly groups: readonly ProxyGroupDefinition[];
|
|
612
|
+
readonly routes: readonly RouteDefinition[];
|
|
613
|
+
readonly fallback: Destination;
|
|
614
|
+
};
|
|
615
|
+
export declare class ProfileDefinitionError extends Error {
|
|
616
|
+
readonly code: string;
|
|
617
|
+
constructor(code: string);
|
|
618
|
+
}
|
|
619
|
+
export declare const outbound: {
|
|
620
|
+
direct: Readonly<{
|
|
621
|
+
readonly builtin: "DIRECT";
|
|
622
|
+
}>;
|
|
623
|
+
reject: Readonly<{
|
|
624
|
+
readonly builtin: "REJECT";
|
|
625
|
+
}>;
|
|
626
|
+
rejectDrop: Readonly<{
|
|
627
|
+
readonly builtin: "REJECT-DROP";
|
|
628
|
+
}>;
|
|
629
|
+
rejectNoDrop: Readonly<{
|
|
630
|
+
readonly builtin: "REJECT-NO-DROP";
|
|
631
|
+
}>;
|
|
632
|
+
rejectTinyGif: Readonly<{
|
|
633
|
+
readonly builtin: "REJECT-TINYGIF";
|
|
634
|
+
}>;
|
|
635
|
+
};
|
|
636
|
+
export declare function defineProxyGroup<A extends GroupAlgorithm, D extends ProfileDestination>(input: Omit<ProxyGroupDefinition<A, D>, "type">): ProxyGroupDefinition<A, D>;
|
|
637
|
+
export declare function defineRoute<C extends ProfileCondition, D extends ProfileDestination>(input: Omit<RouteDefinition<C, D>, "type">): RouteDefinition<C, D>;
|
|
638
|
+
export declare function defineRoutes<C extends ProfileCondition, D extends ProfileDestination>(input: {
|
|
639
|
+
readonly when: readonly C[];
|
|
640
|
+
readonly to: D;
|
|
641
|
+
}): RouteDefinition<C, D>[];
|
|
642
|
+
export declare function selectProxies(nodes: readonly ProxyNode[], query?: {
|
|
643
|
+
ids?: readonly string[];
|
|
644
|
+
regions?: readonly string[];
|
|
645
|
+
providers?: readonly string[];
|
|
646
|
+
tags?: readonly string[];
|
|
647
|
+
}): ProxyNode[];
|
|
648
|
+
export declare function defineSurgeProfile(input: SurgeProfileDefinition): SurgeProfileInput;
|
|
649
|
+
//#endregion
|
|
650
|
+
//#region src/profile.d.ts
|
|
651
|
+
type DeepReadonly<T> = T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]>; } : T;
|
|
652
|
+
type ProfileCondition = Exclude<Match | SurgeCondition, {
|
|
653
|
+
type: "all" | "any" | "not";
|
|
654
|
+
}> | {
|
|
655
|
+
readonly type: "all" | "any";
|
|
656
|
+
readonly conditions: readonly ProfileCondition[];
|
|
657
|
+
readonly noResolve?: boolean;
|
|
658
|
+
readonly extendedMatching?: boolean;
|
|
659
|
+
} | {
|
|
660
|
+
readonly type: "not";
|
|
661
|
+
readonly condition: ProfileCondition;
|
|
662
|
+
readonly noResolve?: boolean;
|
|
663
|
+
readonly extendedMatching?: boolean;
|
|
664
|
+
};
|
|
665
|
+
interface ProfileProxyGroup extends ProxyGroupDefinition<GroupAlgorithm, ProfileDestination> {}
|
|
666
|
+
type ProfileDestination = ProxyNode | ProfileProxyGroup | SurgeTunnel | TailscaleEndpoint | {
|
|
667
|
+
readonly builtin: "DIRECT" | "REJECT" | "REJECT-DROP" | "REJECT-NO-DROP" | "REJECT-TINYGIF";
|
|
668
|
+
};
|
|
669
|
+
type SurgeConfig = Pick<SurgeProfileInput, "managed" | "general" | "hosts" | "names">;
|
|
670
|
+
type ProfileDefinition = {
|
|
671
|
+
readonly target: SurgeProfileInput["target"] | {
|
|
672
|
+
readonly engine: "sing-box";
|
|
673
|
+
readonly platform: "macos" | "linux";
|
|
674
|
+
readonly version: string;
|
|
675
|
+
};
|
|
676
|
+
readonly nodes: readonly ProxyNode[];
|
|
677
|
+
readonly groups: readonly ProxyGroupDefinition<GroupAlgorithm, ProfileDestination>[];
|
|
678
|
+
readonly routes: readonly RouteDefinition<ProfileCondition, ProfileDestination>[];
|
|
679
|
+
readonly fallback: ProfileDestination;
|
|
680
|
+
readonly endpoints?: readonly (SurgeTunnel | TailscaleEndpoint)[];
|
|
681
|
+
readonly surge?: DeepReadonly<SurgeConfig>;
|
|
682
|
+
readonly singBox?: {
|
|
683
|
+
readonly mode: "fragment" | "standalone";
|
|
684
|
+
readonly listener?: {
|
|
685
|
+
readonly port: number;
|
|
686
|
+
readonly resolver: string;
|
|
687
|
+
};
|
|
688
|
+
};
|
|
689
|
+
};
|
|
690
|
+
type Profile = DeepReadonly<ProfileDefinition>;
|
|
691
|
+
type ProfileCompilation = {
|
|
692
|
+
readonly engine: "surge";
|
|
693
|
+
readonly ok: boolean;
|
|
694
|
+
readonly compilation: SurgeProfileCompilation;
|
|
695
|
+
} | {
|
|
696
|
+
readonly engine: "sing-box";
|
|
697
|
+
readonly ok: boolean;
|
|
698
|
+
readonly compilation: Compilation;
|
|
699
|
+
} | {
|
|
700
|
+
readonly engine: "invalid";
|
|
701
|
+
readonly ok: false;
|
|
702
|
+
readonly code: string;
|
|
703
|
+
};
|
|
704
|
+
declare function surgeConfig(input: SurgeConfig): DeepReadonly<SurgeConfig>;
|
|
705
|
+
export declare function defineProfile(input: ProfileDefinition | Profile): Profile;
|
|
706
|
+
/** No secrets or I/O. All engine adaptations retain strict validation. */
|
|
707
|
+
export declare function compileProfile(input: ProfileDefinition | Profile): ProfileCompilation;
|
|
708
|
+
//#endregion
|
|
497
709
|
//#region src/proxy-builder.d.ts
|
|
498
710
|
type ProxyBuilder<N extends ProxyNode> = {
|
|
499
711
|
readonly via: (id: string) => ProxyBuilder<N>;
|
|
@@ -568,6 +780,7 @@ export declare const group: {
|
|
|
568
780
|
}>;
|
|
569
781
|
};
|
|
570
782
|
export declare const surge: {
|
|
783
|
+
config: typeof surgeConfig;
|
|
571
784
|
match: {
|
|
572
785
|
domain: (value: string, options?: {
|
|
573
786
|
readonly noResolve?: boolean;
|
|
@@ -655,97 +868,6 @@ export declare const singbox: {
|
|
|
655
868
|
tailscale: (options: Omit<TailscaleEndpoint, "type">) => TailscaleEndpoint;
|
|
656
869
|
};
|
|
657
870
|
//#endregion
|
|
658
|
-
//#region src/targets.d.ts
|
|
659
|
-
export declare const targetCatalog: readonly [{
|
|
660
|
-
readonly engine: "sing-box";
|
|
661
|
-
readonly version: "1.11.0";
|
|
662
|
-
readonly autoGroup: "urltest";
|
|
663
|
-
readonly platforms: readonly ["linux", "macos"];
|
|
664
|
-
readonly protocols: readonly ["trojan", "http", "shadowsocks", "vmess", "vless"];
|
|
665
|
-
readonly endpoints: readonly [];
|
|
666
|
-
readonly groups: readonly ["select", "urltest"];
|
|
667
|
-
readonly nativeRuleSets: readonly ["source", "binary"];
|
|
668
|
-
readonly dns: "legacy";
|
|
669
|
-
}, {
|
|
670
|
-
readonly engine: "sing-box";
|
|
671
|
-
readonly version: "1.12.0";
|
|
672
|
-
readonly autoGroup: "urltest";
|
|
673
|
-
readonly platforms: readonly ["linux", "macos"];
|
|
674
|
-
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
|
|
675
|
-
readonly endpoints: readonly ["sing-box-tailscale"];
|
|
676
|
-
readonly groups: readonly ["select", "urltest"];
|
|
677
|
-
readonly nativeRuleSets: readonly ["source", "binary"];
|
|
678
|
-
readonly dns: "typed";
|
|
679
|
-
}, {
|
|
680
|
-
readonly engine: "surge";
|
|
681
|
-
readonly version: "6.10.0";
|
|
682
|
-
readonly autoGroup: "surge-smart";
|
|
683
|
-
readonly platforms: readonly ["macos"];
|
|
684
|
-
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess"];
|
|
685
|
-
readonly endpoints: readonly [];
|
|
686
|
-
readonly groups: readonly ["select", "surge-smart"];
|
|
687
|
-
readonly nativeRuleSets: readonly ["rule-set", "domain-set"];
|
|
688
|
-
readonly dns: "general";
|
|
689
|
-
}, {
|
|
690
|
-
readonly engine: "mihomo";
|
|
691
|
-
readonly version: "1.19.32";
|
|
692
|
-
readonly autoGroup: "urltest";
|
|
693
|
-
readonly platforms: readonly ["linux", "macos"];
|
|
694
|
-
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
|
|
695
|
-
readonly endpoints: readonly [];
|
|
696
|
-
readonly groups: readonly ["select", "urltest"];
|
|
697
|
-
readonly nativeRuleSets: readonly ["yaml", "text"];
|
|
698
|
-
readonly dns: "clash";
|
|
699
|
-
}, {
|
|
700
|
-
readonly engine: "stash";
|
|
701
|
-
readonly version: "4.2.1";
|
|
702
|
-
readonly autoGroup: null;
|
|
703
|
-
readonly platforms: readonly ["macos"];
|
|
704
|
-
readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess"];
|
|
705
|
-
readonly endpoints: readonly [];
|
|
706
|
-
readonly groups: readonly ["select"];
|
|
707
|
-
readonly nativeRuleSets: readonly [];
|
|
708
|
-
readonly dns: "external";
|
|
709
|
-
}];
|
|
710
|
-
//#endregion
|
|
711
|
-
//#region src/compiler.d.ts
|
|
712
|
-
type TargetPlan = {
|
|
713
|
-
readonly target: Target;
|
|
714
|
-
readonly program: Omit<Program, "groups"> & {
|
|
715
|
-
readonly groups: readonly ConcreteGroup[];
|
|
716
|
-
};
|
|
717
|
-
readonly nativeRuleSets: readonly NativeRuleSet[];
|
|
718
|
-
readonly strategySelections: readonly StrategySelection[];
|
|
719
|
-
readonly rules: readonly ExpandedRule[];
|
|
720
|
-
readonly sourceMap: readonly {
|
|
721
|
-
readonly rule: string;
|
|
722
|
-
readonly nativeIndex: number;
|
|
723
|
-
readonly origin: readonly string[];
|
|
724
|
-
}[];
|
|
725
|
-
readonly preconditions: readonly string[];
|
|
726
|
-
readonly nativeValidation: "not-run";
|
|
727
|
-
};
|
|
728
|
-
type Compilation = {
|
|
729
|
-
readonly ok: boolean;
|
|
730
|
-
readonly diagnostics: readonly Diagnostic[];
|
|
731
|
-
readonly plans: readonly TargetPlan[];
|
|
732
|
-
readonly cases: readonly CaseResult[];
|
|
733
|
-
};
|
|
734
|
-
type CaseResult = {
|
|
735
|
-
readonly id: string;
|
|
736
|
-
readonly passed: boolean;
|
|
737
|
-
readonly actual: {
|
|
738
|
-
readonly rule: string;
|
|
739
|
-
readonly action: Action;
|
|
740
|
-
};
|
|
741
|
-
} | {
|
|
742
|
-
readonly id: string;
|
|
743
|
-
readonly passed: false;
|
|
744
|
-
readonly code: "CASE_INDETERMINATE";
|
|
745
|
-
};
|
|
746
|
-
export declare function compile(input: unknown): Compilation;
|
|
747
|
-
export declare function explain(compilation: Compilation, target: string, request: Request): Explanation;
|
|
748
|
-
//#endregion
|
|
749
871
|
//#region src/proxies.d.ts
|
|
750
872
|
export declare class RenderError extends Error {
|
|
751
873
|
readonly code: string;
|
|
@@ -854,87 +976,35 @@ export declare function surgeMembers(nodes: readonly ProxyNode[], query?: Parame
|
|
|
854
976
|
/** Complete-profile batches use the out symlink protocol; the Program host remains unchanged. */
|
|
855
977
|
export declare function buildSurgeProfilesToDirectory(profiles: Readonly<Record<string, SurgeProfileInput>>, output: string, resolveSecret?: (token: Secret) => string | undefined): Promise<BuildResult>;
|
|
856
978
|
//#endregion
|
|
857
|
-
//#region src/
|
|
858
|
-
type
|
|
859
|
-
builtin: string;
|
|
860
|
-
}>;
|
|
861
|
-
type Destination = ProxyNode | ProxyGroupDefinition | SurgeTunnel | Builtin;
|
|
862
|
-
type ProxyGroupDefinition = {
|
|
863
|
-
readonly type: "proxy-group";
|
|
864
|
-
readonly id: string;
|
|
865
|
-
readonly name: string;
|
|
866
|
-
readonly algorithm: Extract<GroupAlgorithm, {
|
|
867
|
-
type: "select" | "surge-smart";
|
|
868
|
-
}>;
|
|
869
|
-
readonly members: readonly Destination[];
|
|
870
|
-
readonly url?: string;
|
|
871
|
-
readonly intervalSeconds?: number;
|
|
872
|
-
readonly timeoutSeconds?: number;
|
|
873
|
-
};
|
|
874
|
-
type RouteDefinition = {
|
|
875
|
-
readonly type: "route";
|
|
876
|
-
readonly when: SurgeCondition;
|
|
877
|
-
readonly to: Destination;
|
|
878
|
-
};
|
|
879
|
-
type SurgeProfileDefinition = Omit<SurgeProfileInput, "groups" | "rules" | "fallback"> & {
|
|
880
|
-
readonly groups: readonly ProxyGroupDefinition[];
|
|
881
|
-
readonly routes: readonly RouteDefinition[];
|
|
882
|
-
readonly fallback: Destination;
|
|
883
|
-
};
|
|
884
|
-
export declare class ProfileDefinitionError extends Error {
|
|
885
|
-
readonly code: string;
|
|
886
|
-
constructor(code: string);
|
|
887
|
-
}
|
|
888
|
-
export declare const outbound: {
|
|
889
|
-
direct: Readonly<{
|
|
890
|
-
readonly builtin: "DIRECT";
|
|
891
|
-
}>;
|
|
892
|
-
reject: Readonly<{
|
|
893
|
-
readonly builtin: "REJECT";
|
|
894
|
-
}>;
|
|
895
|
-
rejectDrop: Readonly<{
|
|
896
|
-
readonly builtin: "REJECT-DROP";
|
|
897
|
-
}>;
|
|
898
|
-
rejectNoDrop: Readonly<{
|
|
899
|
-
readonly builtin: "REJECT-NO-DROP";
|
|
900
|
-
}>;
|
|
901
|
-
rejectTinyGif: Readonly<{
|
|
902
|
-
readonly builtin: "REJECT-TINYGIF";
|
|
903
|
-
}>;
|
|
904
|
-
};
|
|
905
|
-
export declare function defineProxyGroup(input: Omit<ProxyGroupDefinition, "type">): ProxyGroupDefinition;
|
|
906
|
-
export declare function defineRoute(input: Omit<RouteDefinition, "type">): RouteDefinition;
|
|
907
|
-
export declare function defineRoutes(input: {
|
|
908
|
-
readonly when: readonly SurgeCondition[];
|
|
909
|
-
readonly to: Destination;
|
|
910
|
-
}): RouteDefinition[];
|
|
911
|
-
export declare function selectProxies(nodes: readonly ProxyNode[], query?: {
|
|
912
|
-
ids?: readonly string[];
|
|
913
|
-
regions?: readonly string[];
|
|
914
|
-
providers?: readonly string[];
|
|
915
|
-
tags?: readonly string[];
|
|
916
|
-
}): ProxyNode[];
|
|
917
|
-
export declare function defineSurgeProfile(input: SurgeProfileDefinition): SurgeProfileInput;
|
|
918
|
-
//#endregion
|
|
919
|
-
//#region src/surge-build.d.ts
|
|
920
|
-
type SurgeBuildContext = {
|
|
979
|
+
//#region src/build-core.d.ts
|
|
980
|
+
type BuildContext = {
|
|
921
981
|
readonly validation: boolean;
|
|
922
982
|
};
|
|
923
|
-
type
|
|
924
|
-
readonly profiles: Readonly<Record<string,
|
|
983
|
+
type BuildDefinition$1<T> = {
|
|
984
|
+
readonly profiles: Readonly<Record<string, T>>;
|
|
925
985
|
readonly preflight?: () => readonly string[];
|
|
926
|
-
readonly resolveSecret?: (token: Secret, context:
|
|
986
|
+
readonly resolveSecret?: (token: Secret, context: BuildContext) => string | undefined;
|
|
927
987
|
};
|
|
928
|
-
type
|
|
988
|
+
type ProfileBuildResult = BuildResult & {
|
|
929
989
|
readonly warnings: Readonly<Record<string, number>>;
|
|
930
990
|
readonly validation: boolean;
|
|
931
991
|
readonly profileCount: number;
|
|
932
992
|
};
|
|
933
|
-
|
|
993
|
+
//#endregion
|
|
994
|
+
//#region src/surge-build.d.ts
|
|
995
|
+
type SurgeBuildContext = BuildContext;
|
|
996
|
+
type SurgeBuildDefinition = BuildDefinition$1<SurgeProfileInput>;
|
|
997
|
+
type SurgeBuildResult = ProfileBuildResult;
|
|
934
998
|
export declare function defineSurgeBuild(input: SurgeBuildDefinition): SurgeBuildDefinition;
|
|
935
|
-
/** Pure orchestration result; the CLI owns stdout and process exit status. */
|
|
936
999
|
export declare function runSurgeBuild(input: SurgeBuildDefinition, output: string, options?: {
|
|
937
1000
|
readonly validation?: boolean;
|
|
938
1001
|
}): Promise<SurgeBuildResult>;
|
|
939
1002
|
//#endregion
|
|
940
|
-
|
|
1003
|
+
//#region src/profile-build.d.ts
|
|
1004
|
+
type BuildDefinition = BuildDefinition$1<Profile>;
|
|
1005
|
+
export declare function defineBuild(input: BuildDefinition): BuildDefinition;
|
|
1006
|
+
export declare function runBuild(input: BuildDefinition, output: string, options?: {
|
|
1007
|
+
readonly validation?: boolean;
|
|
1008
|
+
}): Promise<ProfileBuildResult>;
|
|
1009
|
+
//#endregion
|
|
1010
|
+
export type { Artifact, BuildContext, BuildDefinition, BuildResult, CaseResult, Compilation, DeepReadonly, Destination, Profile, ProfileBuildResult, ProfileCompilation, ProfileCondition, ProfileDefinition, ProfileDestination, ProxyBuilder, ProxyGroupDefinition, ProxyNodeArtifact, ProxyNodeCompilation, ProxyNodeInput, RouteDefinition, StrategyGroupCompilation, StrategyGroupInput, SurgeBuildContext, SurgeBuildDefinition, SurgeBuildResult, SurgeCondition, SurgeConfig, SurgeGeneral, SurgeGroup, SurgeHost, SurgePolicy, SurgeProfileArtifact, SurgeProfileCompilation, SurgeProfileDefinition, SurgeProfileInput, SurgeRule, SurgeTunnel, TargetPlan };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { $ as deepFreeze, A as defineProfile, B as renderSurgeProfiles, C as sequence, D as surge, E as strategy, F as defineSurgeProfile, G as isReservedNativeName, H as compile, I as outbound, J as RenderError, K as nativeNameSchema, L as selectProxies, M as defineProxyGroup, N as defineRoute, O as use, P as defineRoutes, Q as assertData, R as compileSurgeProfile, S as selectNodes, T as slot, U as explain, V as secretReader, W as compileStrategyGroups, X as validateProxyOptions, Y as surgeProxy, Z as StaticRuleSetUnknownError, _ as reject, b as ruleSet, c as render, d as direct, et as idSchema, f as group, g as proxy, h as policy, i as runSurgeBuild, j as ProfileDefinitionError, k as compileProfile, l as block, m as mihomo, n as runBuild, o as buildSurgeProfilesToDirectory, p as match, q as targetCatalog, r as defineSurgeBuild, s as buildToDirectory, t as defineBuild, tt as nodeSchema, u as defineConfig, v as route, w as singbox, x as secret, y as rule, z as renderSurgeProfile } from "./profile-build-BLB8hvyw.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region src/proxy-fragments.ts
|
|
4
4
|
const inputSchema = z.strictObject({
|
|
@@ -148,4 +148,4 @@ function surgeMembers(nodes, query = {}) {
|
|
|
148
148
|
return selectNodes(nodes, query).map((ref) => ({ ref }));
|
|
149
149
|
}
|
|
150
150
|
//#endregion
|
|
151
|
-
export { ProfileDefinitionError, RenderError, StaticRuleSetUnknownError, block, buildSurgeProfilesToDirectory, buildToDirectory, compile, compileProxyNodes, compileStrategyGroups, compileSurgeProfile, defineConfig, defineProxyGroup, defineRoute, defineRoutes, defineSurgeBuild, defineSurgeProfile, direct, explain, group, match, mihomo, outbound, policy, proxy, reject, render, renderProxyNodes, renderSurgeProfile, renderSurgeProfiles, route, rule, ruleSet, runSurgeBuild, secret, selectNodes, selectProxies, sequence, singbox, slot, strategy, surge, surgeMembers, surgeProfile, targetCatalog, use };
|
|
151
|
+
export { ProfileDefinitionError, RenderError, StaticRuleSetUnknownError, block, buildSurgeProfilesToDirectory, buildToDirectory, compile, compileProfile, compileProxyNodes, compileStrategyGroups, compileSurgeProfile, defineBuild, defineConfig, defineProfile, defineProxyGroup, defineRoute, defineRoutes, defineSurgeBuild, defineSurgeProfile, direct, explain, group, match, mihomo, outbound, policy, proxy, reject, render, renderProxyNodes, renderSurgeProfile, renderSurgeProfiles, route, rule, ruleSet, runBuild, runSurgeBuild, secret, selectNodes, selectProxies, sequence, singbox, slot, strategy, surge, surgeMembers, surgeProfile, targetCatalog, use };
|