@subconverter/core 0.1.0 → 0.2.1
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/LICENSE +674 -0
- package/README.md +69 -0
- package/dist/index.cjs +1442 -281
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +227 -2
- package/dist/index.d.ts +227 -2
- package/dist/index.js +1442 -281
- package/dist/index.js.map +1 -1
- package/package.json +24 -1
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,12 @@ interface ProxyGroupConfig {
|
|
|
31
31
|
}
|
|
32
32
|
/** Create a proxy group with subconverter's default field values. */
|
|
33
33
|
declare function createProxyGroupConfig(): ProxyGroupConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Create one select group that fans out to every proxy type, mirroring the
|
|
36
|
+
* CLI `--group` flag and the server `group` param. Shared so both
|
|
37
|
+
* entrypoints build byte-identical groups.
|
|
38
|
+
*/
|
|
39
|
+
declare function createSelectGroup(name: string): ProxyGroupConfig;
|
|
34
40
|
/** Resolve a textual group type (as found in config files). */
|
|
35
41
|
declare function parseProxyGroupType(value: string): ProxyGroupType | undefined;
|
|
36
42
|
|
|
@@ -144,6 +150,7 @@ interface Proxy {
|
|
|
144
150
|
authStr: string;
|
|
145
151
|
sni: string;
|
|
146
152
|
fingerprint: string;
|
|
153
|
+
shortId: string;
|
|
147
154
|
ca: string;
|
|
148
155
|
caStr: string;
|
|
149
156
|
recvWindowConn: number;
|
|
@@ -193,6 +200,7 @@ declare enum TargetFormat {
|
|
|
193
200
|
Clash = "clash",
|
|
194
201
|
ClashR = "clashr",
|
|
195
202
|
Surge = "surge",
|
|
203
|
+
Surfboard = "surfboard",
|
|
196
204
|
QuantumultX = "quanx",
|
|
197
205
|
Quantumult = "quan",
|
|
198
206
|
Loon = "loon",
|
|
@@ -201,6 +209,7 @@ declare enum TargetFormat {
|
|
|
201
209
|
Trojan = "trojan",
|
|
202
210
|
SSD = "ssd",
|
|
203
211
|
SSC = "ss",
|
|
212
|
+
SSSub = "sssub",
|
|
204
213
|
SSR = "ssr",
|
|
205
214
|
SingBox = "singbox",
|
|
206
215
|
Mixed = "mixed",
|
|
@@ -213,8 +222,21 @@ interface ExtraSettings {
|
|
|
213
222
|
overwriteOriginalRules: boolean;
|
|
214
223
|
renameArray: RegexMatchConfig[];
|
|
215
224
|
emojiArray: RegexMatchConfig[];
|
|
225
|
+
/** Regex rewrites applied to node names before every other naming rule. */
|
|
226
|
+
nameRegexArray: RegexMatchConfig[];
|
|
227
|
+
/** Literal fragments stripped from node names before every other naming rule. */
|
|
228
|
+
nameRemove: string[];
|
|
216
229
|
addEmoji: boolean;
|
|
217
230
|
removeEmoji: boolean;
|
|
231
|
+
/** Prefix node names with the server's country/region when the name lacks one. */
|
|
232
|
+
autoCountry: boolean;
|
|
233
|
+
/** Locale used for `Intl.DisplayNames` country names (default `zh-CN`). */
|
|
234
|
+
countryLocale: string;
|
|
235
|
+
/**
|
|
236
|
+
* Resolve a node's ISO 3166-1 alpha-2 country code. Platform-free: the Node
|
|
237
|
+
* adapter supplies a GeoIP-backed lookup; browsers may supply their own.
|
|
238
|
+
*/
|
|
239
|
+
countryResolver?: (node: Proxy) => string | undefined;
|
|
218
240
|
appendProxyType: boolean;
|
|
219
241
|
nodeList: boolean;
|
|
220
242
|
sortFlag: boolean;
|
|
@@ -245,12 +267,18 @@ interface RequestSettings {
|
|
|
245
267
|
ruleset: RulesetConfig[];
|
|
246
268
|
rename: RegexMatchConfig[];
|
|
247
269
|
emoji: RegexMatchConfig[];
|
|
270
|
+
/** Regex replacements applied to node names before renaming. */
|
|
271
|
+
nameRegex: RegexMatchConfig[];
|
|
272
|
+
/** Literal fragments removed from node names before renaming. */
|
|
273
|
+
nameRemove: string[];
|
|
248
274
|
includeRemarks: string[];
|
|
249
275
|
excludeRemarks: string[];
|
|
250
276
|
addEmoji: boolean;
|
|
251
277
|
removeEmoji: boolean;
|
|
278
|
+
autoCountry: boolean;
|
|
252
279
|
appendType: boolean;
|
|
253
280
|
nodeList: boolean;
|
|
281
|
+
dedupe: boolean;
|
|
254
282
|
sort: boolean;
|
|
255
283
|
filterDeprecated: boolean;
|
|
256
284
|
list: boolean;
|
|
@@ -269,6 +297,10 @@ interface RequestSettings {
|
|
|
269
297
|
proxyGroupsStyle: string;
|
|
270
298
|
autoExtract: boolean;
|
|
271
299
|
uploadPath: string;
|
|
300
|
+
/** Extra quota endpoint fetched server-side (`userinfo_url` / `userinfo-url`). */
|
|
301
|
+
userinfoUrl: string;
|
|
302
|
+
/** Converter for the quota endpoint (`jms` for Just-My-Socks, `subscription`, `auto`). */
|
|
303
|
+
userinfoProvider: string;
|
|
272
304
|
}
|
|
273
305
|
|
|
274
306
|
/** UTF-8 encode a string to bytes (browser + Node safe). */
|
|
@@ -370,6 +402,16 @@ declare function isBlank(input: string | undefined | null): boolean;
|
|
|
370
402
|
declare function urlDecode(input: string): string;
|
|
371
403
|
/** Percent-encode a URL component (RFC 3986 unreserved kept intact). */
|
|
372
404
|
declare function urlEncode(input: string): string;
|
|
405
|
+
/** Normalize a query key: case-insensitive with `_`/`-` equivalent. */
|
|
406
|
+
declare function normalizeQueryKey(key: string): string;
|
|
407
|
+
/**
|
|
408
|
+
* Read every occurrence of a parameter from a query string in document
|
|
409
|
+
* order (case-insensitive key with `_`/`-` equivalent, each value
|
|
410
|
+
* percent-decoded, `+` preserved).
|
|
411
|
+
* Shared by `getUrlArg` and server-side repeatable params (`url`, `group`,
|
|
412
|
+
* `ruleset`) so both entrypoints decode identically.
|
|
413
|
+
*/
|
|
414
|
+
declare function getAllUrlArgs(query: string, key: string): string[];
|
|
373
415
|
/**
|
|
374
416
|
* Read a parameter from a query string, mirroring subconverter's
|
|
375
417
|
* `getUrlArg` (last occurrence wins, value percent-decoded).
|
|
@@ -413,10 +455,13 @@ interface ExternalConfig {
|
|
|
413
455
|
rulesets: RulesetConfig[];
|
|
414
456
|
rename: RegexMatchConfig[];
|
|
415
457
|
emoji: RegexMatchConfig[];
|
|
458
|
+
nameRegex: RegexMatchConfig[];
|
|
459
|
+
nameRemove: string[];
|
|
416
460
|
includeRemarks: string[];
|
|
417
461
|
excludeRemarks: string[];
|
|
418
462
|
addEmoji: boolean;
|
|
419
463
|
removeEmoji: boolean;
|
|
464
|
+
autoCountry: boolean;
|
|
420
465
|
enableRuleGenerator: boolean;
|
|
421
466
|
overwriteOriginalRules: boolean;
|
|
422
467
|
baseFiles: Record<string, string>;
|
|
@@ -438,11 +483,70 @@ declare function parseRegexMatch(value: string, delimiter: string): RegexMatchCo
|
|
|
438
483
|
/** Parse a subconverter external configuration file. */
|
|
439
484
|
declare function parseExternalConfig(content: string): ExternalConfig;
|
|
440
485
|
|
|
486
|
+
/**
|
|
487
|
+
* Resolve the Clash field-name style. Defaults to the new `proxies` /
|
|
488
|
+
* `proxy-groups` / `rules` keys; `legacy=true` (or an explicit
|
|
489
|
+
* `new_name=false` / `new_field_name=false`) opts back into the legacy
|
|
490
|
+
* `Proxy` / `Proxy Group` / `Rule` keys.
|
|
491
|
+
*
|
|
492
|
+
* Exported so the CLI reuses the exact same semantics instead of
|
|
493
|
+
* maintaining a divergent copy.
|
|
494
|
+
*/
|
|
495
|
+
declare function resolveNewFieldName(query: string): boolean;
|
|
496
|
+
/**
|
|
497
|
+
* Read a boolean flag across aliases. Returns `undefined` when no alias is
|
|
498
|
+
* present; otherwise `true` when any occurrence is `true`/`1`/bare.
|
|
499
|
+
* Shared by server-side flags (`dedupe`, `sort`, `no_rules`, …) so they
|
|
500
|
+
* share one presence/OR semantic instead of per-callsite copies.
|
|
501
|
+
*/
|
|
502
|
+
declare function queryBoolFlag(query: string, ...keys: string[]): boolean | undefined;
|
|
441
503
|
/** Base {@link RequestSettings} with subconverter's defaults. */
|
|
442
504
|
declare function createRequestSettings(): RequestSettings;
|
|
443
505
|
/** Parse a request query string into {@link RequestSettings}. */
|
|
444
506
|
declare function parseRequestSettings(query: string): RequestSettings;
|
|
445
507
|
|
|
508
|
+
/** Normalized traffic counters for a `subscription-userinfo` header. */
|
|
509
|
+
interface UserinfoData {
|
|
510
|
+
/** Downloaded bytes. */
|
|
511
|
+
download: number;
|
|
512
|
+
/** Expiration as a unix timestamp in seconds (`0` when unknown). */
|
|
513
|
+
expire: number;
|
|
514
|
+
/** Total monthly bytes (`0` when unknown/unlimited). */
|
|
515
|
+
total: number;
|
|
516
|
+
/** Uploaded bytes. */
|
|
517
|
+
upload: number;
|
|
518
|
+
}
|
|
519
|
+
/** Supported `userinfo_provider` values for `/sub?userinfo_url=...`. */
|
|
520
|
+
type UserinfoProvider = "auto" | "jms" | "subscription";
|
|
521
|
+
/** Normalize a provider name (`JMS`, `justMySocks`, ...); unknown falls back to `auto`. */
|
|
522
|
+
declare function normalizeUserinfoProvider(provider: string | undefined | null): UserinfoProvider;
|
|
523
|
+
/**
|
|
524
|
+
* Guess the quota provider from a `userinfo_url` when the caller did not pass
|
|
525
|
+
* one explicitly. Just-My-Socks quota endpoints (`justmysocks*`,
|
|
526
|
+
* `jmssub*`, `getbwcounter*`) use the JMS JSON shape; anything else yields
|
|
527
|
+
* `undefined` (no suitable provider — the caller must skip conversion
|
|
528
|
+
* instead of guessing).
|
|
529
|
+
*/
|
|
530
|
+
declare function inferUserinfoProviderFromUrl(url: string): UserinfoProvider | undefined;
|
|
531
|
+
/**
|
|
532
|
+
* Compute the next reset timestamp (unix seconds, UTC midnight) for a
|
|
533
|
+
* monthly reset day, mirroring how providers reset quotas on a fixed
|
|
534
|
+
* day-of-month. Returns `0` when the reset day is invalid.
|
|
535
|
+
*/
|
|
536
|
+
declare function nextMonthlyResetTimestamp(resetDay: number, nowSec?: number): number;
|
|
537
|
+
/** Parse a Just-My-Socks JSON payload into normalized counters. */
|
|
538
|
+
declare function parseJmsUserinfo(raw: string, nowSec?: number): UserinfoData | undefined;
|
|
539
|
+
/** Parse a `subscription-userinfo` header value into normalized counters. */
|
|
540
|
+
declare function parseSubscriptionUserinfo(header: string): UserinfoData | undefined;
|
|
541
|
+
/** Render normalized counters as a `subscription-userinfo` header value. */
|
|
542
|
+
declare function formatSubscriptionUserinfo(data: UserinfoData): string;
|
|
543
|
+
/**
|
|
544
|
+
* Convert a raw `userinfo_url` response body into a `subscription-userinfo`
|
|
545
|
+
* header value using the given provider (`jms` for Just-My-Socks).
|
|
546
|
+
* Returns `undefined` when the payload cannot be understood.
|
|
547
|
+
*/
|
|
548
|
+
declare function convertUserinfo(raw: string, provider?: string, nowSec?: number): string | undefined;
|
|
549
|
+
|
|
446
550
|
/** Shadowsocks AEAD/stream ciphers recognized by the parser. */
|
|
447
551
|
declare const SS_CIPHERS: string[];
|
|
448
552
|
/** ShadowsocksR stream ciphers recognized by the parser. */
|
|
@@ -679,6 +783,8 @@ interface VlessOptions {
|
|
|
679
783
|
host?: string;
|
|
680
784
|
path?: string;
|
|
681
785
|
fingerprint?: string;
|
|
786
|
+
publicKey?: string;
|
|
787
|
+
shortId?: string;
|
|
682
788
|
alpn?: string[];
|
|
683
789
|
udp?: TriBool;
|
|
684
790
|
tfo?: TriBool;
|
|
@@ -789,6 +895,33 @@ declare function stringifyClash(doc: Record<string, unknown>): string;
|
|
|
789
895
|
/** Convert nodes into a Clash YAML configuration string. */
|
|
790
896
|
declare function toClash(nodes: Proxy[], extraProxyGroup: ProxyGroupConfig[], settings: ExtraSettings, clashR?: boolean): string;
|
|
791
897
|
|
|
898
|
+
/**
|
|
899
|
+
* Bundled default proxy groups, mirroring upstream `ACL4SSR.ini`
|
|
900
|
+
* (`tindy2013/subconverter/base/config/ACL4SSR.ini`).
|
|
901
|
+
*
|
|
902
|
+
* Used only when `generate(..., { includeRules: true })` is set and the caller
|
|
903
|
+
* did not provide explicit groups. Kept offline so the core engine stays
|
|
904
|
+
* platform-free (no fetch required).
|
|
905
|
+
*/
|
|
906
|
+
declare function getDefaultProxyGroups(): ProxyGroupConfig[];
|
|
907
|
+
/**
|
|
908
|
+
* Bundled offline default rules, mirroring the structure of upstream
|
|
909
|
+
* `ACL4SSR.ini` + its `rules/ACL4SSR` lists (LAN/China direct, ad reject,
|
|
910
|
+
* messenger/media proxy, final catch-all).
|
|
911
|
+
*
|
|
912
|
+
* These are intentionally compact (≈60 rules) so `includeRules: true` works
|
|
913
|
+
* without network access. Callers needing the full upstream lists should pass
|
|
914
|
+
* explicit {@link RulesetContent} (or {@link getDefaultRulesetConfigs} via the
|
|
915
|
+
* Node adapter, which fetches the remote lists).
|
|
916
|
+
*/
|
|
917
|
+
declare function getDefaultRulesets(): RulesetContent[];
|
|
918
|
+
/**
|
|
919
|
+
* Remote ruleset configs matching upstream `ACL4SSR.ini` for callers that can
|
|
920
|
+
* fetch (Node adapter / CLI `--config`). Paths follow the public ACL4SSR
|
|
921
|
+
* mirror; `collectRulesets` in `@subconverter/node` resolves them.
|
|
922
|
+
*/
|
|
923
|
+
declare function getDefaultRulesetConfigs(): RulesetConfig[];
|
|
924
|
+
|
|
792
925
|
/** Options controlling a single conversion. */
|
|
793
926
|
interface GenerateOptions {
|
|
794
927
|
target: TargetFormat;
|
|
@@ -797,6 +930,17 @@ interface GenerateOptions {
|
|
|
797
930
|
baseConf?: string;
|
|
798
931
|
surgeVersion?: number;
|
|
799
932
|
rulesets?: RulesetContent[];
|
|
933
|
+
/**
|
|
934
|
+
* Whether to attach rules (and default proxy groups) like upstream
|
|
935
|
+
* `tindy2013/subconverter` does with e.g. `config=ACL4SSR.ini`.
|
|
936
|
+
*
|
|
937
|
+
* - `true`/`undefined` (default): emit rules; when `rulesets` is empty,
|
|
938
|
+
* fall back to the bundled offline defaults. When `groups` is empty,
|
|
939
|
+
* fall back to the bundled default proxy groups so rule references
|
|
940
|
+
* resolve. Pass `no_rules`/`--no-rules` (`false`) to strip rules.
|
|
941
|
+
* - `false`: never emit rules, even if `rulesets` are provided.
|
|
942
|
+
*/
|
|
943
|
+
includeRules?: boolean;
|
|
800
944
|
}
|
|
801
945
|
/** Apply rename/emoji/sort preprocessing from settings to nodes. */
|
|
802
946
|
declare function runPreprocess(nodes: Proxy[], settings: ExtraSettings): void;
|
|
@@ -845,6 +989,11 @@ declare function rulesetToSingBoxRules(rulesets: RulesetContent[]): SingBoxRoute
|
|
|
845
989
|
interface LoonOptions {
|
|
846
990
|
baseConf: string;
|
|
847
991
|
nodeList: boolean;
|
|
992
|
+
/** Rule lines to inject, plus the section name to place them in. */
|
|
993
|
+
rules?: {
|
|
994
|
+
section: string;
|
|
995
|
+
lines: string[];
|
|
996
|
+
};
|
|
848
997
|
}
|
|
849
998
|
/** Convert nodes into a Loon configuration string. */
|
|
850
999
|
declare function toLoon(nodes: Proxy[], extraProxyGroup: ProxyGroupConfig[], settings: ExtraSettings, options: LoonOptions): string;
|
|
@@ -872,6 +1021,11 @@ declare function toSingBox(nodes: Proxy[], extraProxyGroup: ProxyGroupConfig[],
|
|
|
872
1021
|
interface QuanOptions {
|
|
873
1022
|
baseConf: string;
|
|
874
1023
|
nodeList: boolean;
|
|
1024
|
+
/** Rule lines to inject, plus the section name to place them in. */
|
|
1025
|
+
rules?: {
|
|
1026
|
+
section: string;
|
|
1027
|
+
lines: string[];
|
|
1028
|
+
};
|
|
875
1029
|
}
|
|
876
1030
|
/** Convert nodes into a Quantumult configuration string. */
|
|
877
1031
|
declare function toQuan(nodes: Proxy[], extraProxyGroup: ProxyGroupConfig[], settings: ExtraSettings, options: QuanOptions): string;
|
|
@@ -879,6 +1033,11 @@ declare function toQuan(nodes: Proxy[], extraProxyGroup: ProxyGroupConfig[], set
|
|
|
879
1033
|
interface QuanxOptions {
|
|
880
1034
|
baseConf: string;
|
|
881
1035
|
nodeList: boolean;
|
|
1036
|
+
/** Rule lines to inject, plus the section name to place them in. */
|
|
1037
|
+
rules?: {
|
|
1038
|
+
section: string;
|
|
1039
|
+
lines: string[];
|
|
1040
|
+
};
|
|
882
1041
|
}
|
|
883
1042
|
/** Convert nodes into a Quantumult X configuration string. */
|
|
884
1043
|
declare function toQuanX(nodes: Proxy[], extraProxyGroup: ProxyGroupConfig[], settings: ExtraSettings, options: QuanxOptions): string;
|
|
@@ -898,6 +1057,24 @@ interface SurgeOptions {
|
|
|
898
1057
|
/** Convert nodes into a Surge configuration string. */
|
|
899
1058
|
declare function toSurge(nodes: Proxy[], extraProxyGroup: ProxyGroupConfig[], settings: ExtraSettings, options: SurgeOptions): string;
|
|
900
1059
|
|
|
1060
|
+
interface SurfboardOptions {
|
|
1061
|
+
baseConf: string;
|
|
1062
|
+
nodeList: boolean;
|
|
1063
|
+
rules?: {
|
|
1064
|
+
section: string;
|
|
1065
|
+
lines: string[];
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Convert nodes into a Surfboard configuration.
|
|
1070
|
+
*
|
|
1071
|
+
* Surfboard is Surge-compatible but drops Hysteria2/AnyTLS nodes while keeping the same
|
|
1072
|
+
* latest-Surge proxy-line format for the rest (SS/SSR-less VMess/Trojan/
|
|
1073
|
+
* SOCKS/HTTP subset). Reuse the Surge generator on the filtered node list
|
|
1074
|
+
* so proxy-line fixes stay in one place.
|
|
1075
|
+
*/
|
|
1076
|
+
declare function toSurfboard(nodes: Proxy[], extraProxyGroup: ProxyGroupConfig[], settings: ExtraSettings, options: SurfboardOptions): string;
|
|
1077
|
+
|
|
901
1078
|
/** Build the JSON payload of a `vmess://` link. */
|
|
902
1079
|
declare function vmessLinkConstruct(remarks: string, add: string, port: string, type: string, id: string, aid: string, net: string, path: string, host: string, tls: string): string;
|
|
903
1080
|
/** Build an `ss://` link. */
|
|
@@ -940,18 +1117,66 @@ declare function groupGenerate(rule: string, nodeList: Proxy[], filteredNodeList
|
|
|
940
1117
|
declare function removeEmoji(originalRemark: string): string;
|
|
941
1118
|
/** Prefix an emoji chosen by the emoji rules. */
|
|
942
1119
|
declare function addEmoji(node: Proxy, emojiArray: RegexMatchConfig[]): string;
|
|
1120
|
+
/** Replace every match of the user-supplied regex rules in a node's remark. */
|
|
1121
|
+
declare function nodeNameRegex(node: Proxy, rules: RegexMatchConfig[]): void;
|
|
1122
|
+
/**
|
|
1123
|
+
* Remove literal fragments from a node's remark (e.g. `foo.server1.bar` with
|
|
1124
|
+
* `["foo", "bar"]` -> `server1`). Separators left at the edges or doubled by
|
|
1125
|
+
* the removal are collapsed.
|
|
1126
|
+
*/
|
|
1127
|
+
declare function nodeNameRemove(node: Proxy, removeList: string[]): void;
|
|
943
1128
|
/** Apply rename rules to a node's remark (script rules are ignored). */
|
|
944
1129
|
declare function nodeRename(node: Proxy, renameArray: RegexMatchConfig[]): void;
|
|
1130
|
+
/**
|
|
1131
|
+
* Prefix a node's remark with its server country/region when the remark does
|
|
1132
|
+
* not already mention one (e.g. `server1` -> `美国-server1`).
|
|
1133
|
+
*
|
|
1134
|
+
* `resolve` returns an ISO 3166-1 alpha-2 code; a missing/unknown code leaves
|
|
1135
|
+
* the remark untouched. Mirrors the request `auto_country` switch.
|
|
1136
|
+
*/
|
|
1137
|
+
declare function addCountryPrefix(node: Proxy, resolve: (node: Proxy) => string | undefined, locale?: string): string;
|
|
945
1138
|
interface PreprocessOptions {
|
|
946
1139
|
removeEmoji: boolean;
|
|
947
1140
|
addEmoji: boolean;
|
|
948
1141
|
sortFlag: boolean;
|
|
949
1142
|
renameArray: RegexMatchConfig[];
|
|
950
1143
|
emojiArray: RegexMatchConfig[];
|
|
1144
|
+
/** User regex rewrites applied before every other naming rule. */
|
|
1145
|
+
nameRegexArray?: RegexMatchConfig[];
|
|
1146
|
+
/** Literal fragments stripped from names before every other naming rule. */
|
|
1147
|
+
nameRemove?: string[];
|
|
1148
|
+
autoCountry?: boolean;
|
|
1149
|
+
countryLocale?: string;
|
|
1150
|
+
countryResolver?: (node: Proxy) => string | undefined;
|
|
951
1151
|
}
|
|
952
|
-
/** Apply emoji removal, renaming, emoji insertion, and optional sorting. */
|
|
1152
|
+
/** Apply name cleanup, emoji removal, renaming, emoji insertion, and optional sorting. */
|
|
953
1153
|
declare function preprocessNodes(nodes: Proxy[], options: PreprocessOptions): void;
|
|
954
1154
|
/** Remove nodes that share a type, server, port, and remark. Returns the count removed. */
|
|
955
1155
|
declare function dedupeNodes(nodes: Proxy[]): number;
|
|
956
1156
|
|
|
957
|
-
|
|
1157
|
+
/**
|
|
1158
|
+
* ISO 3166-1 alpha-2 region helpers used when a proxy name has no country.
|
|
1159
|
+
*
|
|
1160
|
+
* The display names come from `Intl.DisplayNames` (no bundled database), with
|
|
1161
|
+
* small overrides where the CLDR Chinese name is too verbose for a node name
|
|
1162
|
+
* (e.g. `中国香港特别行政区` -> `香港`). Flag emoji are derived from the code.
|
|
1163
|
+
*/
|
|
1164
|
+
/** Localized country/region name (e.g. `美国`), falling back to the code. */
|
|
1165
|
+
declare function regionDisplayName(code: string, locale?: string): string;
|
|
1166
|
+
/** Flag emoji for a region code, or `""` when the code is invalid. */
|
|
1167
|
+
declare function regionFlag(code: string): string;
|
|
1168
|
+
/** `true` when the code is a known ISO 3166-1 alpha-2 region. */
|
|
1169
|
+
declare function isRegionCode(code: string): boolean;
|
|
1170
|
+
/**
|
|
1171
|
+
* `true` when a node name already mentions a country/region — a localized
|
|
1172
|
+
* name, a common English spelling, a flag emoji, or an ISO code token such as
|
|
1173
|
+
* `US` in `US-01` / `US01`.
|
|
1174
|
+
*/
|
|
1175
|
+
declare function hasRegionName(remark: string): boolean;
|
|
1176
|
+
/**
|
|
1177
|
+
* Prepend `name-` to a node remark (e.g. `server1` -> `美国-server1`).
|
|
1178
|
+
* An empty remark becomes just the country name.
|
|
1179
|
+
*/
|
|
1180
|
+
declare function formatCountryRemark(remark: string, code: string, locale?: string): string;
|
|
1181
|
+
|
|
1182
|
+
export { BalanceStrategy, CLASH_RULE_TYPES, DEFAULT_GROUPS, type ExternalConfig, type ExtraSettings, type GenerateOptions, type IniDocument, type IniSection, type LoonOptions, type MellowOptions, type Proxy, type ProxyGroupConfig, ProxyGroupType, ProxyType, QUANX_RULE_TYPES, type QuanOptions, type QuanxOptions, type RawIniSection, type RegexMatchConfig, type RequestSettings, type RulesetConfig, type RulesetContent, RulesetType, SING_BOX_RULE_TYPES, SSR_CIPHERS, SS_CIPHERS, SURF_RULE_TYPES, SURGE2_RULE_TYPES, SURGE_RULE_TYPES, type SingBoxOptions, type SingBoxRoute, type SurfboardOptions, type SurgeRulesetResult, TargetFormat, type TemplateVars, type TriBool, type UserinfoData, type UserinfoProvider, addCountryPrefix, addEmoji, anyTlsConstruct, applyMatcher, base64Decode, base64Encode, buildClash, checkIgnore, convertRuleset, convertUserinfo, countOccurrences, createExtraSettings, createProxy, createProxyGroupConfig, createRequestSettings, createRulesetConfig, createSelectGroup, dedupeNodes, explode, explodeAnyTls, explodeClash, explodeHttp, explodeHttpSub, explodeHysteria2, explodeKitsunebi, explodeNetch, explodeNetchConf, explodeQuan, explodeShadowrocket, explodeSocks, explodeSs, explodeSsAndroid, explodeSsConf, explodeSsd, explodeSsr, explodeSsrConf, explodeSstap, explodeStdVmess, explodeSub, explodeSurge, explodeTrojan, explodeTuic, explodeVless, explodeVmess, explodeVmessConf, filterNodes, findSection, fnv1a64, fnv1a64Hex, formatCountryRemark, formatSingBoxInterval, formatSubscriptionUserinfo, generate, generatePeer, getAllUrlArgs, getDefaultProxyGroups, getDefaultRulesetConfigs, getDefaultRulesets, getSectionItems, getUrlArg, groupGenerate, hasRegionName, hasTemplatePlaceholders, httpConstruct, hysteria2Construct, hysteriaConstruct, inferUserinfoProviderFromUrl, isBlank, isFlattenableSsr, isIp, isIpv4, isIpv6, isLink, isRegionCode, isSsCipher, matchRange, nextMonthlyResetTimestamp, nodeNameRegex, nodeNameRemove, nodeRename, normalizeQueryKey, normalizeUserinfoProvider, pad2, parseClashText, parseConfContent, parseCustomProxyGroup, parseExternalConfig, parseGroupTimes, parseIni, parseJmsUserinfo, parseLink, parsePeers, parseProxyGroupType, parseRawIni, parseRegexMatch, parseRequestSettings, parseRulesetConfig, parseSubscription, parseSubscriptionUserinfo, parseTriBool, preprocessNodes, processRemark, proxyToSingle, proxyToSsSub, proxyToSsd, proxyTypeName, queryBoolFlag, regMatch, regReplace, regionDisplayName, regionFlag, removeEmoji, renderRawIni, renderTemplate, replaceAllDistinct, resolveNewFieldName, rulesetToClashRules, rulesetToSingBoxRules, rulesetToSurgeRules, runPreprocess, setRawSection, snellConstruct, socksConstruct, split, splitUrl, ssConstruct, ssLinkConstruct, ssrConstruct, ssrLinkConstruct, startsWith, strFind, stringifyClash, stripScheme, templateVariableNames, toBool, toClash, toInt, toLoon, toMellow, toQuan, toQuanX, toSingBox, toSip008, toSurfboard, toSurge, transformRuleToCommon, triBoolOr, trim, trimLowerCase, trojanConstruct, trojanLinkConstruct, tryBase64Decode, tuicConstruct, urlDecode, urlEncode, urlSafeBase64Decode, urlSafeBase64Encode, utf8Decode, utf8Encode, vlessConstruct, vmessConstruct, vmessLinkConstruct, wireGuardConstruct };
|